1 2 /****************************************************************************** 3 * MODULE : editor.hpp 4 * DESCRIPTION: abstract TeXmacs editors 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 ******************************************************************************/ 11 12 #ifndef EDITOR_H 13 #define EDITOR_H 14 #include "typesetter.hpp" 15 #include "tree_select.hpp" 16 #ifdef AQUATEXMACS 17 # include "Cocoa/aqua_simple_widget.h" 18 #else 19 # ifdef QTTEXMACS 20 # include "Qt/qt_simple_widget.hpp" 21 # else 22 # include "Widkit/simple_wk_widget.hpp" 23 # endif 24 #endif 25 #include "server.hpp" 26 #include "drd_info.hpp" 27 #ifdef EXPERIMENTAL 28 # include "../Style/Environment/environment.hpp" 29 # include "../Style/Memorizer/memorizer.hpp" 30 #endif 31 #include "new_data.hpp" 32 #define TEXMACS_COPYRIGHT (string("(c) 1999-2013 by Joris van der Hoeven and others")) 33 34 #define THE_CURSOR 1 35 #define THE_FOCUS 2 36 #define THE_TREE 4 37 #define THE_ENVIRONMENT 8 38 #define THE_SELECTION 16 39 #define THE_DECORATIONS 32 40 #define THE_EXTENTS 64 41 #define THE_LOCUS 128 42 43 class tm_buffer_rep; 44 class tm_view_rep; 45 class server_rep; 46 typedef tm_buffer_rep* tm_buffer; 47 typedef tm_view_rep* tm_view; 48 class modification; 49 class editor; 50 extern bool enable_fastenv; 51 52 class editor_rep: public simple_widget_rep { 53 public: 54 server_rep* sv; // the underlying texmacs server 55 widget_rep* cvw; // non reference counted canvas widget 56 tm_view_rep* mvw; // master view 57 58 protected: 59 tm_buffer buf; // the underlying buffer 60 drd_info drd; // the drd for the buffer 61 tree& et; // all TeXmacs trees 62 box eb; // box translation of tree 63 path rp; // path to the root of the document in et 64 path tp; // path of cursor in tree 65 #ifdef EXPERIMENTAL 66 environment ste; // environment for style rewriting 67 tree cct; // clean copy of the document tree 68 memorizer mem; // style converted document tree 69 #endif 70 71 /* exchanging information with the interface */ 72 virtual void get_selection (path& start, path& end) = 0; 73 virtual void set_selection (path start, path end) = 0; 74 virtual cursor& the_cursor () = 0; 75 virtual cursor& the_ghost_cursor () = 0; 76 77 /* exchanging information with the typesetter */ 78 virtual typesetter get_typesetter () = 0; 79 virtual hashmap<string,tree> get_init () = 0; 80 virtual hashmap<string,tree> get_fin () = 0; 81 virtual hashmap<string,tree> get_att () = 0; 82 virtual void set_init (hashmap<string,tree> H= tree ("?"))=0; 83 virtual void add_init (hashmap<string,tree> H) = 0; 84 virtual void set_fin (hashmap<string,tree> H) = 0; 85 virtual void set_att (hashmap<string,tree> H) = 0; 86 87 /* exchanging property information */ 88 virtual void set_bool_property (string what, bool val) = 0; 89 virtual void set_int_property (string what, int val) = 0; 90 virtual void set_string_property (string what, string val) = 0; 91 virtual bool get_bool_property (string what) = 0; 92 virtual int get_int_property (string what) = 0; 93 virtual string get_string_property (string what) = 0; 94 95 protected: 96 /* protected routines from edit_typeset */ 97 virtual void typeset_preamble () = 0; 98 virtual void typeset_invalidate_env () = 0; 99 virtual void typeset (SI& x1, SI& y1, SI& x2, SI& y2) = 0; 100 101 /* protected subroutines for deletion of content */ 102 virtual void back_around (tree t, path p, bool forward) = 0; 103 virtual void back_prime (tree t, path p, bool forward) = 0; 104 virtual void back_in_around (tree t, path p, bool forward) = 0; 105 virtual void back_in_long_arrow (tree t, path p, bool forward) = 0; 106 virtual void back_in_wide (tree t, path p, bool forward) = 0; 107 virtual void back_in_tree (tree t, path p, bool forward) = 0; 108 virtual void pre_remove_around (path p) = 0; 109 virtual void back_table (path p, bool forward) = 0; 110 virtual void back_in_table (tree t, path p, bool forward) = 0; 111 virtual void back_monolithic (path p) = 0; 112 virtual void back_general (path p, bool forward) = 0; 113 virtual void back_in_with (tree t, path p, bool forward) = 0; 114 virtual void back_in_general (tree t, path p, bool forward) = 0; 115 virtual void back_in_text_at (tree t, path p, bool forward) = 0; 116 117 /* other protected subroutines */ 118 virtual tree kbd (string s) = 0; 119 virtual tree kbd_shortcut (string s) = 0; 120 virtual path tree_path (path sp, SI x, SI y, SI delta) = 0; 121 virtual void apply_changes () = 0; 122 virtual void animate () = 0; 123 virtual path search_format () = 0; 124 virtual path search_format (int& row, int& col) = 0; 125 virtual void table_get_extents (path fp, int& nr_rows, int& nr_cols) = 0; 126 virtual void table_bound (path fp, int& i1, int& j1, int& i2, int& j2) = 0; 127 virtual tree table_get_subtable (path p, int i1, int j1, int i2, int j2) = 0; 128 virtual void table_write_subtable (path fp, int row, int col, tree subt) = 0; 129 virtual void table_del_format (path fp, int I1, int J1, 130 int I2, int J2, string var) = 0; 131 virtual void table_insert (path fp, int row, int col, 132 int nr_rows, int nr_cols) = 0; 133 virtual void table_remove (path fp, int row, int col, 134 int nr_rows, int nr_cols) = 0; 135 136 public: 137 editor_rep (); 138 editor_rep (server_rep* sv, tm_buffer buf); ~editor_rep()139 inline virtual ~editor_rep () {} 140 141 /* public routines from edit_interface */ 142 virtual void suspend () = 0; 143 virtual void resume () = 0; 144 virtual void keyboard_focus_on (string field) = 0; 145 virtual int get_pixel_size () = 0; 146 virtual SI get_visible_width () = 0; 147 virtual SI get_visible_height () = 0; 148 virtual SI get_window_width () = 0; 149 virtual SI get_window_height () = 0; 150 virtual void invalidate (SI x1, SI y1, SI x2, SI y2) = 0; 151 virtual void invalidate (rectangles rs) = 0; 152 virtual void invalidate_all () = 0; 153 virtual void notify_change (int changed) = 0; 154 virtual bool has_changed (int question) = 0; 155 virtual int idle_time (int event_type= ANY_EVENT) = 0; 156 virtual int change_time () = 0; 157 virtual void full_screen_mode (bool flag) = 0; 158 virtual void before_menu_action () = 0; 159 virtual void after_menu_action () = 0; 160 virtual void cancel_menu_action () = 0; 161 virtual rectangle get_window_extents () = 0; 162 virtual cursor search_cursor (path p) = 0; 163 virtual selection search_selection (path start, path end) = 0; 164 virtual int get_input_mode () = 0; 165 virtual void set_input_mode (int mode) = 0; 166 virtual void set_input_normal () = 0; 167 virtual bool in_normal_mode () = 0; 168 virtual bool in_search_mode () = 0; 169 virtual bool in_replace_mode () = 0; 170 virtual bool in_spell_mode () = 0; 171 virtual void interrupt_shortcut () = 0; 172 virtual bool kbd_get_command (string cmd_s, string& help, command& cmd) = 0; 173 virtual void key_press (string key) = 0; 174 virtual void emulate_keyboard (string keys, string action= "") = 0; 175 virtual bool complete_try () = 0; 176 virtual void complete_start (string prefix, array<string> compls) = 0; 177 virtual bool complete_keypress (string key) = 0; 178 virtual string session_complete_command (tree t) = 0; 179 virtual void custom_complete (tree t) = 0; 180 virtual void mouse_any (string s, SI x, SI y, int mods, time_t t) = 0; 181 virtual void mouse_click (SI x, SI y) = 0; 182 virtual bool mouse_extra_click (SI x, SI y) = 0; 183 virtual void mouse_drag (SI x, SI y) = 0; 184 virtual void mouse_select (SI x, SI y, int mods, bool drag) = 0; 185 virtual void mouse_paste (SI x, SI y) = 0; 186 virtual void mouse_adjust (SI x, SI y, int mods) = 0; 187 virtual void mouse_adjust_selection (SI x, SI y, int mods) = 0; 188 virtual void mouse_scroll (SI x, SI y, bool up) = 0; 189 virtual cursor get_cursor () = 0; 190 virtual array<SI> get_mouse_position () = 0; 191 virtual void set_pointer (string name) = 0; 192 virtual void set_pointer (string curs_name, string mask_name) = 0; 193 virtual void set_message (tree l, tree r= "", bool temp= false) = 0; 194 virtual void recall_message () = 0; 195 196 /* public routines from edit_cursor */ 197 virtual path make_cursor_accessible (path p, bool forwards) = 0; 198 virtual bool cursor_is_accessible () = 0; 199 virtual void show_cursor_if_hidden () = 0; 200 virtual void go_to (SI x, SI y, bool absolute= true) = 0; 201 virtual void go_left_physical () = 0; 202 virtual void go_right_physical () = 0; 203 virtual void go_left () = 0; 204 virtual void go_right () = 0; 205 virtual void go_up () = 0; 206 virtual void go_down () = 0; 207 virtual void go_start_line () = 0; 208 virtual void go_end_line () = 0; 209 virtual void go_page_up () = 0; 210 virtual void go_page_down () = 0; 211 virtual void go_to (path p) = 0; 212 virtual void go_to_correct (path p) = 0; 213 virtual void go_to_start (path p) = 0; 214 virtual void go_to_end (path p) = 0; 215 virtual void go_to_border (path p, bool at_start) = 0; 216 virtual void go_to_here () = 0; 217 virtual void go_start () = 0; 218 virtual void go_end () = 0; 219 virtual void go_start_of (tree_label what) = 0; 220 virtual void go_end_of (tree_label what) = 0; 221 virtual void go_start_with (string var, string val) = 0; 222 virtual void go_end_with (string var, string val) = 0; 223 virtual void go_start_paragraph () = 0; 224 virtual void go_end_paragraph () = 0; 225 virtual void go_to_label (string s) = 0; 226 virtual tree get_labels () = 0; 227 228 /* public routines from edit_graphics */ 229 virtual bool inside_graphics (bool b=true) = 0; 230 virtual bool inside_active_graphics (bool b=true) = 0; 231 virtual bool over_graphics (SI x, SI y) = 0; 232 virtual tree get_graphics () = 0; 233 virtual double get_x () = 0; 234 virtual double get_y () = 0; 235 virtual frame find_frame (bool last= false) = 0; 236 virtual grid find_grid () = 0; 237 virtual void find_limits (point& lim1, point& lim2) = 0; 238 virtual bool find_graphical_region (SI& x1, SI& y1, SI& x2, SI& y2) = 0; 239 virtual point adjust (point p) = 0; 240 virtual tree find_point (point p) = 0; 241 virtual tree graphical_select (double x, double y) = 0; 242 virtual tree graphical_select (double x1, double y1, 243 double x2, double y2) = 0; 244 virtual tree get_graphical_object () = 0; 245 virtual void set_graphical_object (tree t) = 0; 246 virtual void invalidate_graphical_object () = 0; 247 virtual void draw_graphical_object (renderer ren) = 0; 248 virtual bool mouse_graphics (string s, SI x, SI y, int mods, time_t t) = 0; 249 250 /* public routines from edit_typeset */ 251 virtual void clear_local_info () = 0; 252 virtual void set_data (new_data data) = 0; 253 virtual void get_data (new_data& data) = 0; 254 virtual SI as_length (string l) = 0; 255 virtual string add_lengths (string l1, string l2) = 0; 256 virtual string multiply_length (double x, string l) = 0; 257 virtual bool is_length (string s) = 0; 258 virtual double divide_lengths (string l1, string l2) = 0; 259 virtual void drd_update () = 0; 260 #ifdef EXPERIMENTAL 261 virtual void environment_update () = 0; 262 #endif 263 virtual tree get_full_env () = 0; 264 virtual bool defined_at_cursor (string var_name) = 0; 265 virtual bool defined_at_init (string var_name) = 0; 266 virtual bool defined_in_init (string var_name) = 0; 267 virtual tree get_env_value (string var_name, path p) = 0; 268 virtual tree get_env_value (string var_name) = 0; 269 virtual tree get_init_value (string var_name) = 0; 270 virtual string get_env_string (string var_name) = 0; 271 virtual string get_init_string (string var_name) = 0; 272 virtual int get_env_int (string var_name) = 0; 273 virtual int get_init_int (string var_name) = 0; 274 virtual double get_env_double (string var_name) = 0; 275 virtual double get_init_double (string var_name) = 0; 276 virtual language get_env_language () = 0; 277 virtual SI get_page_width () = 0; 278 virtual SI get_page_height () = 0; 279 virtual tree exec_texmacs (tree t, path p) = 0; 280 virtual tree exec_texmacs (tree t) = 0; 281 virtual tree exec_verbatim (tree t, path p) = 0; 282 virtual tree exec_verbatim (tree t) = 0; 283 virtual tree exec_html (tree t, path p) = 0; 284 virtual tree exec_html (tree t) = 0; 285 virtual tree exec_latex (tree t, path p) = 0; 286 virtual tree exec_latex (tree t) = 0; 287 virtual tree texmacs_exec (tree t) = 0; 288 virtual tree get_style () = 0; 289 virtual void set_style (tree t) = 0; 290 virtual void init_style () = 0; 291 virtual void init_style (string style) = 0; 292 virtual void change_style (tree style) = 0; 293 virtual tree get_init_all () = 0; 294 virtual void init_env (string var, tree by) = 0; 295 virtual void init_default (string var) = 0; 296 virtual tree get_att (string key) = 0; 297 virtual void set_att (string key, tree im) = 0; 298 virtual void reset_att (string key) = 0; 299 virtual array<string> list_atts () = 0; 300 virtual void typeset_invalidate (path p) = 0; 301 virtual void typeset_invalidate_all () = 0; 302 303 /* public routines from edit_modify */ 304 virtual void notify_assign (path p, tree u) = 0; 305 virtual void notify_insert (path p, tree u) = 0; 306 virtual void notify_remove (path p, int nr) = 0; 307 virtual void notify_split (path p) = 0; 308 virtual void notify_join (path p) = 0; 309 virtual void notify_assign_node (path p, tree_label op) = 0; 310 virtual void notify_insert_node (path p, tree t) = 0; 311 virtual void notify_remove_node (path p) = 0; 312 virtual void notify_set_cursor (path p, tree data) = 0; 313 virtual void post_notify (path p) = 0; 314 virtual void clear_undo_history () = 0; 315 virtual double this_author () = 0; 316 virtual void archive_state () = 0; 317 virtual void start_editing () = 0; 318 virtual void end_editing () = 0; 319 virtual void cancel_editing () = 0; 320 virtual void start_slave (double a) = 0; 321 virtual void mark_start (double a) = 0; 322 virtual bool mark_cancel (double a) = 0; 323 virtual void mark_end (double a) = 0; 324 virtual void add_undo_mark () = 0; 325 virtual void remove_undo_mark () = 0; 326 virtual int undo_possibilities () = 0; 327 virtual void unredoable_undo () = 0; 328 virtual void undo (int i=0) = 0; 329 virtual int redo_possibilities () = 0; 330 virtual void redo (int i=0) = 0; 331 virtual void require_save () = 0; 332 virtual void notify_save (bool real_save= true) = 0; 333 virtual bool need_save (bool real_save= true) = 0; 334 virtual void show_history () = 0; 335 virtual observer position_new (path p) = 0; 336 virtual void position_delete (observer o) = 0; 337 virtual void position_set (observer o, path p) = 0; 338 virtual path position_get (observer o) = 0; 339 340 /* public routines from edit_text */ 341 virtual void correct (path p) = 0; 342 virtual void correct_concat (path p, int done=0) = 0; 343 virtual bool insert_return () = 0; 344 virtual void remove_return (path p) = 0; 345 virtual void insert_tree (tree t, path p_in_t) = 0; 346 virtual void var_insert_tree (tree t, path p_in_t) = 0; 347 virtual void insert_tree (tree t) = 0; 348 virtual void remove_text (bool forward) = 0; 349 virtual void remove_structure (bool forward) = 0; 350 virtual void remove_structure_upwards () = 0; 351 352 virtual void make_space (tree t) = 0; 353 virtual void make_space (string w) = 0; 354 virtual void make_space (string w, string y1, string y2) = 0; 355 virtual void make_hspace (string s) = 0; 356 virtual void make_hspace (string smin, string sdef, string smax) = 0; 357 virtual void make_vspace_before (string s) = 0; 358 virtual void make_vspace_before (string smin, string sdef, string smax) = 0; 359 virtual void make_vspace_after (string s) = 0; 360 virtual void make_vspace_after (string smin, string sdef, string smax) = 0; 361 virtual void make_htab (string spc) = 0; 362 virtual void make_image (string file_name, bool link, 363 string w, string h, string x, string y) = 0; 364 365 /* public routines from edit_math */ 366 virtual void make_rigid () = 0; 367 virtual void make_lprime (string s) = 0; 368 virtual void make_rprime (string s) = 0; 369 virtual void make_below () = 0; 370 virtual void make_above () = 0; 371 virtual void make_script (bool sup, bool right) = 0; 372 virtual void make_fraction () = 0; 373 virtual void make_sqrt () = 0; 374 virtual void make_var_sqrt () = 0; 375 virtual void make_wide (string wide) = 0; 376 virtual void make_wide_under (string wide) = 0; 377 virtual void make_neg () = 0; 378 virtual void make_tree () = 0; 379 380 /* public routines from edit_table */ 381 virtual void make_table (int nr_rows=1, int nr_cols=1) = 0; 382 virtual void make_subtable (int nr_rows=1, int nr_cols=1) = 0; 383 virtual void table_deactivate () = 0; 384 virtual void table_extract_format () = 0; 385 virtual void table_insert_row (bool forward) = 0; 386 virtual void table_insert_column (bool forward) = 0; 387 virtual void table_remove_row (bool forward, bool flag= false) = 0; 388 virtual void table_remove_column (bool forward, bool flag= false) = 0; 389 virtual int table_nr_rows () = 0; 390 virtual int table_nr_columns () = 0; 391 virtual array<int> table_get_extents () = 0; 392 virtual void table_set_extents (int rows, int cols) = 0; 393 virtual int table_which_row () = 0; 394 virtual int table_which_column () = 0; 395 virtual array<int> table_which_cells () = 0; 396 virtual path table_search_cell (int row, int col) = 0; 397 virtual void table_go_to (int row, int col) = 0; 398 virtual void table_set_format (string var, tree val) = 0; 399 virtual tree table_get_format () = 0; 400 virtual string table_get_format (string var) = 0; 401 virtual void table_del_format (string var= "") = 0; 402 virtual void table_format_center () = 0; 403 virtual void table_row_decoration (bool forward) = 0; 404 virtual void table_column_decoration (bool forward) = 0; 405 virtual void table_correct_block_content () = 0; 406 virtual void table_resize_notify () = 0; 407 virtual void set_cell_mode (string mode) = 0; 408 virtual string get_cell_mode () = 0; 409 virtual void cell_set_format (string var, tree val) = 0; 410 virtual string cell_get_format (string var) = 0; 411 virtual void cell_del_format (string var= "") = 0; 412 virtual void table_test () = 0; 413 414 /* public routines from edit_dynamic */ 415 virtual bool in_source () = 0; 416 virtual path find_dynamic (path p) = 0; 417 virtual void make_compound (tree_label l, int n=-1) = 0; 418 virtual void activate () = 0; 419 virtual void go_to_argument (path p, bool start_flag) = 0; 420 virtual void insert_argument (path p, bool forward) = 0; 421 virtual void insert_argument (bool forward) = 0; 422 virtual void remove_empty_argument (path p, bool forward) = 0; 423 virtual void remove_argument (path p, bool forward) = 0; 424 virtual void remove_argument (bool forward) = 0; 425 virtual void make_with (string var, string val) = 0; 426 virtual void insert_with (path p, string var, tree val) = 0; 427 virtual void remove_with (path p, string var) = 0; 428 virtual void make_mod_active (tree_label l) = 0; 429 virtual void make_style_with (string var, string val) = 0; 430 virtual void make_hybrid () = 0; 431 virtual bool activate_latex () = 0; 432 virtual void activate_hybrid (bool with_args_hint) = 0; 433 virtual void activate_symbol () = 0; 434 virtual bool make_return_before () = 0; 435 virtual bool make_return_after () = 0; 436 virtual void temp_proof_fix () = 0; 437 438 /* public routines from edit_process */ 439 virtual void generate_bibliography (string bib, string sty, string fname)= 0; 440 virtual void generate_table_of_contents (string toc) = 0; 441 virtual void generate_index (string idx) = 0; 442 virtual void generate_glossary (string glo) = 0; 443 virtual void generate_aux (string which= "") = 0; 444 virtual bool get_save_aux () = 0; 445 446 /* public routines from edit_select */ 447 virtual path semantic_root (path p) = 0; 448 virtual bool semantic_active (path p) = 0; 449 virtual bool semantic_select (path p, path& q1, path& q2, int mode) = 0; 450 451 virtual void select (path p) = 0; 452 virtual void select (path start, path end) = 0; 453 virtual void select_all () = 0; 454 virtual void select_line () = 0; 455 virtual void select_from_cursor () = 0; 456 virtual void select_from_cursor_if_active () = 0; 457 virtual void select_from_keyboard (bool flag) = 0; 458 virtual void select_from_shift_keyboard () = 0; 459 virtual void select_enlarge_text () = 0; 460 virtual void select_enlarge () = 0; 461 virtual void select_enlarge_environmental () = 0; 462 463 virtual bool selection_active_any () = 0; 464 virtual bool selection_active_normal () = 0; 465 virtual bool selection_active_table (bool strict= true) = 0; 466 virtual bool selection_active_small () = 0; 467 virtual bool selection_active_enlarging () = 0; 468 469 virtual void selection_raw_set (string key, tree t) = 0; 470 virtual tree selection_raw_get (string key) = 0; 471 virtual void selection_correct (path i1, path i2, path& o1, path& o2) = 0; 472 virtual path selection_get_subtable (int& i1, int& j1, int& i2, int& j2) = 0; 473 virtual selection compute_selection (path p1, path p2) = 0; 474 virtual selection compute_selection (range_set sel) = 0; 475 virtual void selection_get (selection& sel) = 0; 476 virtual void selection_get (path& start, path& end) = 0; 477 virtual path selection_get_start () = 0; 478 virtual path selection_get_end () = 0; 479 virtual path selection_get_path () = 0; 480 virtual path selection_get_cursor_path () = 0; 481 virtual tree selection_get_env_value (string var) = 0; 482 virtual void selection_set (string key, tree t, bool persistant= false) = 0; 483 virtual void selection_set (tree t) = 0; 484 virtual void selection_set_start (path p= path()) = 0; 485 virtual void selection_set_end (path p= path()) = 0; 486 virtual void selection_set_paths (path start, path end) = 0; 487 virtual void selection_set_range_set (range_set sel) = 0; 488 virtual void selection_copy (string key= "primary") = 0; 489 virtual void selection_paste (string key= "primary") = 0; 490 virtual void selection_clear (string key= "primary") = 0; 491 virtual void selection_cancel () = 0; 492 virtual void selection_set_import (string fm) = 0; 493 virtual void selection_set_export (string fm) = 0; 494 virtual string selection_get_import () = 0; 495 virtual string selection_get_export () = 0; 496 497 virtual tree selection_get () = 0; 498 virtual void selection_cut (string key= "primary") = 0; 499 virtual tree selection_get_cut () = 0; 500 virtual void selection_move () = 0; 501 virtual void cut (path p) = 0; 502 virtual void cut (path start, path end) = 0; 503 virtual path manual_focus_get () = 0; 504 virtual void manual_focus_set (path p, bool force= true) = 0; 505 virtual void manual_focus_release () = 0; 506 virtual path focus_get (bool skip_flag= true) = 0; 507 508 virtual void set_alt_selection (string s, range_set sel) = 0; 509 virtual range_set get_alt_selection (string s) = 0; 510 virtual void cancel_alt_selection (string s) = 0; 511 virtual void cancel_alt_selections () = 0; 512 513 /* public routines from edit_replace */ 514 virtual bool inside (string what) = 0; 515 virtual bool inside (tree_label l) = 0; 516 virtual bool inside_with (string var, string val) = 0; 517 virtual string inside_which (tree t) = 0; 518 virtual path search_upwards (string what) = 0; 519 virtual path search_upwards (tree_label l) = 0; 520 virtual path search_parent_upwards (tree_label l) = 0; 521 virtual path search_parent_upwards (tree_label l, int& last) = 0; 522 virtual path search_upwards_with (string var, string val) = 0; 523 virtual path search_upwards_in_set (tree t) = 0; 524 virtual path search_previous_compound (path init, string which) = 0; 525 virtual path search_next_compound (path init, string which) = 0; 526 virtual void search_start (bool forward= true) = 0; 527 virtual void search_button_next () = 0; 528 virtual bool search_keypress (string s) = 0; 529 virtual void replace_start (tree what, tree by, bool forward= true) = 0; 530 virtual bool replace_keypress (string s) = 0; 531 virtual void spell_start () = 0; 532 virtual void spell_replace (string by) = 0; 533 virtual bool spell_keypress (string s) = 0; 534 535 /* public routines from edit_main */ 536 virtual void set_property (scheme_tree what, scheme_tree val) = 0; 537 virtual scheme_tree get_property (scheme_tree what) = 0; 538 virtual void clear_buffer () = 0; 539 virtual void new_window () = 0; 540 virtual void clone_window () = 0; 541 virtual void tex_buffer () = 0; 542 virtual url get_name () = 0; 543 virtual void focus_on_this_editor () = 0; 544 virtual void notify_page_change () = 0; 545 virtual string get_metadata (string kind) = 0; 546 virtual void print (url ps_name, bool to_file, int first, int last) = 0; 547 virtual void print_to_file (url ps_name, 548 string first="1", string last="1000000") = 0; 549 virtual void print_buffer (string first="1", string last="1000000") = 0; 550 virtual void export_ps (url ps_name, 551 string first="1", string last="1000000") = 0; 552 virtual array<int> print_snippet (url u, tree t) = 0; 553 virtual bool graphics_file_to_clipboard (url output) = 0; 554 virtual void footer_eval (string s) = 0; 555 virtual tree the_line () = 0; 556 virtual tree the_root () = 0; 557 virtual tree the_buffer () = 0; 558 virtual tree the_subtree (path p) = 0; 559 virtual path the_path () = 0; 560 virtual path the_shifted_path () = 0; 561 virtual path the_buffer_path () = 0; 562 virtual void show_tree () = 0; 563 virtual void show_env () = 0; 564 virtual void show_path () = 0; 565 virtual void show_cursor () = 0; 566 virtual void show_selection () = 0; 567 virtual void show_meminfo () = 0; 568 virtual void edit_special () = 0; 569 virtual void edit_test () = 0; 570 571 friend class tm_window_rep; 572 friend class tm_server_rep; 573 friend class server_command_rep; 574 friend void edit_announce (editor_rep* ed, modification mod); 575 friend void edit_done (editor_rep* ed, modification mod); 576 friend string get_editor_status_report (); 577 friend void tm_failure (const char* msg); 578 friend void set_buffer_tree (url name, tree doc); 579 friend void set_current_view (url u); 580 friend void focus_on_editor (editor ed); 581 }; 582 583 class editor { 584 EXTEND_NULL(widget,editor); 585 public: operator ==(editor w)586 inline bool operator == (editor w) { return rep == w.rep; } operator !=(editor w)587 inline bool operator != (editor w) { return rep != w.rep; } 588 }; 589 EXTEND_NULL_CODE(widget,editor); 590 591 editor new_editor (server_rep* sv, tm_buffer buf); 592 593 #define SERVER(cmd) { \ 594 url temp= get_current_view_safe (); \ 595 focus_on_this_editor (); \ 596 sv->cmd; \ 597 set_current_view (temp); \ 598 } 599 600 #endif // defined EDITOR_H 601