Back to index

texmacs  1.0.7.15
edit_interface.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : edit_interface.hpp
00004 * DESCRIPTION: the interface for TeXmacs
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef EDIT_INTERFACE_H
00013 #define EDIT_INTERFACE_H
00014 #include "editor.hpp"
00015 #include "timer.hpp"
00016 #include "widget.hpp"
00017 
00018 #define INPUT_NORMAL      0
00019 #define INPUT_SEARCH      1
00020 #define INPUT_REPLACE     2
00021 #define INPUT_SPELL       3
00022 #define INPUT_COMPLETE    4
00023 
00024 string MODE_LANGUAGE (string mode);
00025 
00026 class edit_interface_rep: virtual public editor_rep {
00027 protected:
00028   int           env_change;    // which things have been changed ?
00029   time_t        last_change;   // time of last processed change
00030   time_t        last_update;   // time of last update of menu, icons and footer
00031   bool          do_animate;    // are we in an animation ?
00032   time_t        next_animate;  // time for next animation
00033   bool          full_screen;   // full screen mode ?
00034   bool          got_focus;     // do we have keyboard focus ?
00035   string        sh_s;          // current string for shortcuts
00036   double        sh_mark;       // 0 or mark for undoing shortcut
00037   string        pre_edit_s;    // pre-edit string
00038   double        pre_edit_mark; // 0 or mark for undoing pre-edit
00039   widget        popup_win;     // the current popup window
00040   tree          message_l;     // a left message to display
00041   tree          message_r;     // a right message to display
00042   tree          last_l;        // last displayed left message
00043   tree          last_r;        // last displayed right message
00044   int           sfactor;       // the current shrinking factor
00045   SI            pixel;         // sfactor*PIXEL
00046   rectangles    copy_always;   // for wiping out cursor
00047   int           input_mode;    // INPUT_NORMAL, INPUT_SEARCH, INPUT_REPLACE
00048 
00049 protected:
00050   SI            last_x, last_y;
00051   time_t        last_t;
00052   SI            start_x, start_y;
00053   SI            end_x, end_y;
00054   bool          made_selection;
00055   bool          table_selection;
00056   rectangles    selection_rects;
00057   rectangles    env_rects;
00058   rectangles    foc_rects;
00059   rectangles    sem_rects;
00060   bool          sem_correct;
00061   cursor        oc;
00062   bool          temp_invalid_cursor;
00063   array<string> completions;
00064   string        completion_prefix;
00065   int           completion_pos;
00066   renderer      shadow;
00067   SI            vx1, vy1, vx2, vy2;
00068   rectangles    stored_rects;
00069   renderer      stored;
00070   rectangles    locus_new_rects;
00071   rectangles    locus_rects;
00072   list<string>  active_ids;
00073   int           cur_sb, cur_wb;
00074   SI            cur_wx, cur_wy;
00075 
00076 public:
00077   edit_interface_rep ();
00078   ~edit_interface_rep ();
00079   operator tree ();
00080   void suspend ();
00081   void resume ();
00082   void get_size (SI& wx, SI& wy);
00083 
00084   /* routines for dealing with shrinked coordinates */
00085   int  get_pixel_size ();
00086   void set_shrinking_factor (int sf);
00087   void invalidate (SI x1, SI y1, SI x2, SI y2);
00088   void invalidate (rectangles rs);
00089   void update_visible ();
00090   SI   get_window_height ();
00091   void scroll_to (SI x, SI y1);
00092   void set_extents (SI x1, SI y1, SI x2, SI y2);
00093 
00094   /* repainting the window */
00095   void draw_text (renderer ren, rectangles& l);
00096   void draw_surround (renderer ren, rectangle r);
00097   void draw_context (renderer ren, rectangle r);
00098   void draw_env (renderer ren);
00099   void draw_cursor (renderer ren);
00100   void draw_selection (renderer ren);
00101   void draw_graphics (renderer ren);
00102   void draw_pre (renderer ren, rectangle r);
00103   void draw_post (renderer ren, rectangle r);
00104   void draw_with_shadow (rectangle r);
00105   void draw_with_stored (rectangle r);
00106 
00107   /* handle changes */
00108   void notify_change (int changed);
00109   bool has_changed (int question);
00110   int  idle_time (int event_type= ANY_EVENT);
00111   int  change_time ();
00112   void apply_changes ();
00113   void animate ();
00114 
00115   /* miscellaneous */
00116   void compute_env_rects (path p, rectangles& rs, bool recurse);
00117   void cursor_visible ();
00118   void selection_visible ();
00119   void full_screen_mode (bool flag);
00120   void before_menu_action ();
00121   void after_menu_action ();
00122   cursor search_cursor (path p);
00123   selection search_selection (path start, path end);
00124   rectangle get_window_extents ();
00125 
00126   /* keyboard handling */
00127   int  get_input_mode ();
00128   void set_input_mode (int mode);
00129   void set_input_normal ();
00130   bool in_normal_mode ();
00131   bool in_search_mode ();
00132   bool in_replace_mode ();
00133   bool in_spell_mode ();
00134   bool kbd_get_command (string which, string& help, command& cmd);
00135   void interrupt_shortcut ();
00136   bool try_shortcut (string comb);
00137   tree kbd (string s);
00138   tree kbd_shortcut (string s);
00139   void key_press (string key);
00140   void emulate_keyboard (string keys, string action= "");
00141   bool complete_try ();
00142   void complete_message ();
00143   void complete_start (string prefix, array<string> compls);
00144   bool complete_keypress (string key);
00145   string session_complete_command (tree t);
00146   void custom_complete (tree t);
00147 
00148   /* mouse handling */
00149   void mouse_any (string s, SI x, SI y, int mods, time_t t);
00150   void mouse_click (SI x, SI y);
00151   bool mouse_extra_click (SI x, SI y);
00152   void mouse_drag (SI x, SI y);
00153   void mouse_select (SI x, SI y, int mods, bool drag);
00154   void mouse_paste (SI x, SI y);
00155   void mouse_adjust (SI x, SI y);
00156   void mouse_scroll (SI x, SI y, bool up);
00157   cursor get_cursor ();
00158   void set_pointer (string name);
00159   void set_pointer (string curs_name, string mask_name);
00160   void update_active_loci ();
00161 
00162   /* the footer */
00163   tree compute_text_footer (tree st);
00164   tree compute_operation_footer (tree st);
00165   tree compute_compound_footer (tree t, path p);
00166   bool set_latex_footer (tree st);
00167   bool set_hybrid_footer (tree st);
00168   void set_left_footer (tree l);
00169   void append_left_footer (tree& l, string env_var);
00170   void set_left_footer ();
00171   void set_right_footer (tree r);
00172   void set_right_footer ();
00173   void set_footer ();
00174   void set_message (tree l, tree r= "", bool temp= false);
00175   void recall_message ();
00176 
00177   /* event handlers */
00178   void handle_get_size_hint (SI& w, SI& h);
00179   void handle_notify_resize (SI w, SI h);
00180   void handle_keypress (string key, time_t t);
00181   void handle_keyboard_focus (bool has_focus, time_t t);
00182   void handle_mouse (string kind, SI x, SI y, int mods, time_t t);
00183   void handle_set_shrinking_factor (int sf);
00184   void handle_clear (SI x1, SI y1, SI x2, SI y2);
00185   void handle_repaint (SI x1, SI y1, SI x2, SI y2);
00186 
00187   friend class interactive_command_rep;
00188   friend class tm_window_rep;
00189 };
00190 
00191 #endif // defined EDIT_INTERFACE_H