Fix tab completion
[texmacs.git] / src / src / Edit / Interface / edit_interface.hpp
blob572dd746afc491c22ae08f536ea1b251d9db6e8c
2 /******************************************************************************
3 * MODULE : edit_interface.hpp
4 * DESCRIPTION: the interface for TeXmacs
5 * COPYRIGHT : (C) 1999 Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
12 #ifndef EDIT_INTERFACE_H
13 #define EDIT_INTERFACE_H
14 #include "editor.hpp"
15 #include "timer.hpp"
16 #include "widget.hpp"
18 #define INPUT_NORMAL 0
19 #define INPUT_SEARCH 1
20 #define INPUT_REPLACE 2
21 #define INPUT_SPELL 3
22 #define INPUT_COMPLETE 4
24 string MODE_LANGUAGE (string mode);
26 class edit_interface_rep: virtual public editor_rep {
27 protected:
28 int env_change; // which things have been changed ?
29 time_t last_change; // time of last processed change
30 time_t last_update; // time of last update of menu, icons and footer
31 bool do_animate; // are we in an animation ?
32 time_t next_animate; // time for next animation
33 bool full_screen; // full screen mode ?
34 bool got_focus; // do we have keyboard focus ?
35 string sh_s; // current string for shortcuts
36 double sh_mark; // 0 or mark for undoing shortcut
37 widget popup_win; // the current popup window
38 string message_l; // a left message to display
39 string message_r; // a right message to display
40 string last_l; // last displayed left message
41 string last_r; // last displayed right message
42 int sfactor; // the current shrinking factor
43 SI pixel; // sfactor*PIXEL
44 rectangles copy_always; // for wiping out cursor
45 int input_mode; // INPUT_NORMAL, INPUT_SEARCH, INPUT_REPLACE
47 protected:
48 time_t last_click; // last click on left mouse button
49 SI last_x, last_y;
50 bool start_drag, start_right_drag;
51 bool dragging, right_dragging;
52 SI start_x, start_y;
53 SI end_x, end_y;
54 bool made_selection;
55 bool table_selection;
56 rectangles selection_rects;
57 rectangles env_rects;
58 cursor oc;
59 bool temp_invalid_cursor;
60 array<string> completions;
61 string completion_prefix;
62 int completion_pos;
63 renderer shadow;
64 SI vx1, vy1, vx2, vy2;
65 rectangles stored_rects;
66 renderer stored;
67 rectangles locus_new_rects;
68 rectangles locus_rects;
69 list<string> active_ids;
70 int cur_sb, cur_wb;
71 SI cur_wx, cur_wy;
73 public:
74 edit_interface_rep ();
75 ~edit_interface_rep ();
76 operator tree ();
77 void suspend ();
78 void resume ();
79 void get_size (SI& wx, SI& wy);
81 /* routines for dealing with shrinked coordinates */
82 int get_pixel_size ();
83 void set_shrinking_factor (int sf);
84 void invalidate (SI x1, SI y1, SI x2, SI y2);
85 void invalidate (rectangles rs);
86 void update_visible ();
87 SI get_window_height ();
88 void scroll_to (SI x, SI y1);
89 void set_extents (SI x1, SI y1, SI x2, SI y2);
91 /* repainting the window */
92 void draw_text (renderer ren, rectangles& l);
93 void draw_surround (renderer ren, rectangle r);
94 void draw_context (renderer ren, rectangle r);
95 void draw_env (renderer ren);
96 void draw_cursor (renderer ren);
97 void draw_selection (renderer ren);
98 void draw_graphics (renderer ren);
99 void draw_pre (renderer ren, rectangle r);
100 void draw_post (renderer ren, rectangle r);
101 void draw_with_shadow (rectangle r);
102 void draw_with_stored (rectangle r);
104 /* handle changes */
105 void notify_change (int changed);
106 bool has_changed (int question);
107 int idle_time (int event_type= ANY_EVENT);
108 int change_time ();
109 void apply_changes ();
110 void animate ();
112 /* miscellaneous */
113 void compute_env_rects (path p, rectangles& rs, bool recurse);
114 void cursor_visible ();
115 void selection_visible ();
116 void full_screen_mode (bool flag);
117 void before_menu_action ();
118 void after_menu_action ();
120 /* keyboard handling */
121 int get_input_mode ();
122 void set_input_mode (int mode);
123 void set_input_normal ();
124 bool in_normal_mode ();
125 bool in_search_mode ();
126 bool in_replace_mode ();
127 bool in_spell_mode ();
128 bool kbd_get_command (string which, string& help, command& cmd);
129 void interrupt_shortcut ();
130 bool try_shortcut (string comb);
131 void key_press (string key);
132 void emulate_keyboard (string keys, string action= "");
133 bool complete_try ();
134 void complete_message ();
135 void complete_start (string prefix, array<string> compls);
136 bool complete_keypress (string key);
137 string session_complete_command (tree t);
138 void custom_complete (tree t);
140 /* mouse handling */
141 void mouse_any (string s, SI x, SI y, int mods, time_t t);
142 void mouse_click (SI x, SI y);
143 bool mouse_extra_click (SI x, SI y);
144 void mouse_drag (SI x, SI y);
145 void mouse_select (SI x, SI y, int mods);
146 void mouse_paste (SI x, SI y);
147 void mouse_adjust (SI x, SI y);
148 void mouse_scroll (SI x, SI y, bool up);
149 cursor get_cursor ();
150 void set_pointer (string name);
151 void set_pointer (string curs_name, string mask_name);
152 void update_active_loci ();
154 /* the footer */
155 string compute_text_footer (tree st);
156 string compute_operation_footer (tree st);
157 string compute_compound_footer (tree t, path p);
158 bool set_latex_footer (tree st);
159 bool set_hybrid_footer (tree st);
160 void set_left_footer (string l);
161 void append_left_footer (string& s, string env_var);
162 void set_left_footer ();
163 void set_right_footer (string r);
164 void set_right_footer ();
165 void set_footer ();
166 void set_message (string l, string r= "", bool temp= false);
167 void recall_message ();
169 /* event handlers */
170 void handle_get_size_hint (SI& w, SI& h);
171 void handle_notify_resize (SI w, SI h);
172 void handle_keypress (string key, time_t t);
173 void handle_keyboard_focus (bool has_focus, time_t t);
174 void handle_mouse (string kind, SI x, SI y, int mods, time_t t);
175 void handle_set_shrinking_factor (int sf);
176 void handle_clear (SI x1, SI y1, SI x2, SI y2);
177 void handle_repaint (SI x1, SI y1, SI x2, SI y2);
179 friend class interactive_command_rep;
180 friend class tm_window_rep;
181 friend class tm_project_rep;
184 #endif // defined EDIT_INTERFACE_H