1 /*
2 * FIG : Facility for Interactive Generation of figures
3 * Copyright (c) 1985-1988 by Supoj Sutanthavibul
4 * Parts Copyright (c) 1989-2015 by Brian V. Smith
5 * Parts Copyright (c) 1991 by Paul King
6 * Parts Copyright (c) 2016-2020 by Thomas Loimer
7 *
8 * Any party obtaining a copy of these files is granted, free of charge, a
9 * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
10 * nonexclusive right and license to deal in this software and documentation
11 * files (the "Software"), including without limitation the rights to use,
12 * copy, modify, merge, publish, distribute, sublicense and/or sell copies of
13 * the Software, and to permit persons who receive copies from any such
14 * party to do so, with the only requirement being that the above copyright
15 * and this permission notice remain intact.
16 *
17 */
18
19 #include "e_break.h"
20
21 #include "resources.h"
22 #include "mode.h"
23 #include "object.h"
24 #include "u_search.h"
25 #include "u_list.h"
26 #include "u_markers.h"
27 #include "u_undo.h"
28 #include "w_canvas.h"
29 #include "w_cursor.h"
30 #include "w_mousefun.h"
31
32
33 static void init_break(F_line *p, int type, int x, int y, int px, int py,
34 int loc_tag);
35 static void init_break_only(F_line *p, int type, int x, int y, int px,
36 int py);
37 static void init_break_tag(F_line *p, int type, int x, int y, int px,
38 int py);
39
40
41
42 void
break_selected(void)43 break_selected(void)
44 {
45 set_mousefun("break compound", "break and tag", "", LOC_OBJ, LOC_OBJ, LOC_OBJ);
46 canvas_kbd_proc = null_proc;
47 canvas_locmove_proc = null_proc;
48 canvas_ref_proc = null_proc;
49 init_searchproc_left(init_break_only);
50 init_searchproc_middle(init_break_tag);
51 canvas_leftbut_proc = object_search_left;
52 canvas_middlebut_proc = object_search_middle;
53 canvas_rightbut_proc = null_proc;
54 set_cursor(pick15_cursor);
55 reset_action_on();
56 }
57
58 static void
init_break_only(F_line * p,int type,int x,int y,int px,int py)59 init_break_only(F_line *p, int type, int x, int y, int px, int py)
60 {
61 init_break(p, type, x, y, px, py, 0);
62 }
63
64 static void
init_break_tag(F_line * p,int type,int x,int y,int px,int py)65 init_break_tag(F_line *p, int type, int x, int y, int px, int py)
66 {
67 init_break(p, type, x, y, px, py, 1);
68 }
69
70 static void
init_break(F_line * p,int type,int x,int y,int px,int py,int loc_tag)71 init_break(F_line *p, int type, int x, int y, int px, int py, int loc_tag)
72 {
73 (void)x;
74 (void)y;
75 (void)px;
76 (void)py;
77
78 if (type != O_COMPOUND)
79 return;
80
81 cur_c = (F_compound *) p;
82 mask_toggle_compoundmarker(cur_c);
83 clean_up();
84 list_delete_compound(&objects.compounds, cur_c);
85 tail(&objects, &object_tails);
86 append_objects(&objects, cur_c, &object_tails);
87 toggle_markers_in_compound(cur_c);
88 set_tags(cur_c, loc_tag);
89 set_action(F_BREAK);
90 set_latestcompound(cur_c);
91 set_modifiedflag();
92 }
93