root/src/editor/edit-impl.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. edit_reload

   1 /*
   2    editor private API
   3  */
   4 
   5 /** \file edit-impl.h
   6  *  \brief Header: editor low level data handling and cursor fundamentals
   7  *  \author Paul Sheer
   8  *  \date 1996, 1997
   9  */
  10 
  11 #ifndef MC__EDIT_IMPL_H
  12 #define MC__EDIT_IMPL_H
  13 
  14 #include <stdio.h>
  15 
  16 #include "lib/search.h"         /* mc_search_type_t */
  17 #include "lib/widget.h"         /* cb_ret_t */
  18 #include "lib/vfs/vfs.h"        /* vfs_path_t */
  19 
  20 #include "src/setup.h"          /* option_tab_spacing */
  21 
  22 #include "edit.h"
  23 
  24 /*** typedefs(not structures) and defined constants **********************************************/
  25 
  26 #define REDRAW_LINE          (1 << 0)
  27 #define REDRAW_LINE_ABOVE    (1 << 1)
  28 #define REDRAW_LINE_BELOW    (1 << 2)
  29 #define REDRAW_AFTER_CURSOR  (1 << 3)
  30 #define REDRAW_BEFORE_CURSOR (1 << 4)
  31 #define REDRAW_PAGE          (1 << 5)
  32 #define REDRAW_IN_BOUNDS     (1 << 6)
  33 #define REDRAW_CHAR_ONLY     (1 << 7)
  34 #define REDRAW_COMPLETELY    (1 << 8)
  35 
  36 #define EDIT_TEXT_HORIZONTAL_OFFSET 0
  37 #define EDIT_TEXT_VERTICAL_OFFSET   0
  38 
  39 #define EDIT_RIGHT_EXTREME 0
  40 #define EDIT_LEFT_EXTREME 0
  41 #define EDIT_TOP_EXTREME 0
  42 #define EDIT_BOTTOM_EXTREME 0
  43 
  44 /* Initial size of the undo stack, in bytes */
  45 #define START_STACK_SIZE 32
  46 
  47 /* Some codes that may be pushed onto or returned from the undo stack */
  48 #define CURS_LEFT       601
  49 #define CURS_RIGHT      602
  50 #define DELCHAR         603
  51 #define BACKSPACE       604
  52 #define STACK_BOTTOM    605
  53 #define CURS_LEFT_LOTS  606
  54 #define CURS_RIGHT_LOTS 607
  55 #define COLUMN_ON       608
  56 #define COLUMN_OFF      609
  57 #define DELCHAR_BR      610
  58 #define BACKSPACE_BR    611
  59 #define MARK_1          1000
  60 #define MARK_2          500000000
  61 #define MARK_CURS       1000000000
  62 #define KEY_PRESS       1500000000
  63 
  64 /* Tabs spaces: (sofar only HALF_TAB_SIZE is used: */
  65 #define TAB_SIZE      option_tab_spacing
  66 #define HALF_TAB_SIZE ((int) option_tab_spacing / 2)
  67 
  68 /* max count stack files */
  69 #define MAX_HISTORY_MOVETO     50
  70 #define LINE_STATE_WIDTH 8
  71 
  72 #define LB_NAMES (LB_MAC + 1)
  73 
  74 #define get_sys_error(s) (s)
  75 
  76 #define edit_error_dialog(h,s) query_dialog (h, s, D_ERROR, 1, _("&Dismiss"))
  77 #define edit_query_dialog(h,s) query_dialog (h, s, D_NORMAL, 1, _("&Dismiss"))
  78 #define edit_query_dialog2(h,t,a,b) query_dialog (h, t, D_NORMAL, 2, a, b)
  79 #define edit_query_dialog3(h,t,a,b,c) query_dialog (h, t, D_NORMAL, 3, a, b, c)
  80 
  81 /*** enums ***************************************************************************************/
  82 
  83 /* line breaks */
  84 typedef enum
  85 {
  86     LB_ASIS = 0,
  87     LB_UNIX,
  88     LB_WIN,
  89     LB_MAC
  90 } LineBreaks;
  91 
  92 typedef enum
  93 {
  94     EDIT_QUICK_SAVE = 0,
  95     EDIT_SAFE_SAVE,
  96     EDIT_DO_BACKUP
  97 } edit_save_mode_t;
  98 
  99 /*** structures declarations (and typedefs of structures)*****************************************/
 100 
 101 /* search/replace options */
 102 typedef struct edit_search_options_t
 103 {
 104     mc_search_type_t type;
 105     gboolean case_sens;
 106     gboolean backwards;
 107     gboolean only_in_selection;
 108     gboolean whole_words;
 109     gboolean all_codepages;
 110 } edit_search_options_t;
 111 
 112 typedef struct edit_stack_type
 113 {
 114     long line;
 115     vfs_path_t *filename_vpath;
 116 } edit_stack_type;
 117 
 118 /*** global variables defined in .c file *********************************************************/
 119 
 120 extern const char VERTICAL_MAGIC[5];
 121 /* if enable_show_tabs_tws == TRUE then use visible_tab visible_tws */
 122 extern gboolean enable_show_tabs_tws;
 123 
 124 extern edit_search_options_t edit_search_options;
 125 
 126 extern unsigned int edit_stack_iterator;
 127 extern edit_stack_type edit_history_moveto[MAX_HISTORY_MOVETO];
 128 
 129 extern int max_undo;
 130 extern gboolean auto_syntax;
 131 
 132 extern gboolean search_create_bookmark;
 133 
 134 extern char *edit_window_state_char;
 135 extern char *edit_window_close_char;
 136 
 137 /*** declarations of public functions ************************************************************/
 138 
 139 gboolean edit_add_window (WDialog * h, const WRect * r, const vfs_path_t * f, long fline);
 140 WEdit *edit_find_editor (const WDialog * h);
 141 gboolean edit_widget_is_editor (const Widget * w);
 142 gboolean edit_drop_hotkey_menu (WDialog * h, int key);
 143 void edit_menu_cmd (WDialog * h);
 144 void edit_user_menu (WEdit * edit, const char *menu_file, int selected_entry);
 145 void edit_init_menu (WMenuBar * menubar);
 146 void edit_save_mode_cmd (void);
 147 off_t edit_move_forward3 (const WEdit * edit, off_t current, long cols, off_t upto);
 148 void edit_scroll_screen_over_cursor (WEdit * edit);
 149 void edit_render_keypress (WEdit * edit);
 150 void edit_scroll_upward (WEdit * edit, long i);
 151 void edit_scroll_downward (WEdit * edit, long i);
 152 void edit_scroll_right (WEdit * edit, long i);
 153 void edit_scroll_left (WEdit * edit, long i);
 154 void edit_move_up (WEdit * edit, long i, gboolean do_scroll);
 155 void edit_move_down (WEdit * edit, long i, gboolean do_scroll);
 156 void edit_move_to_prev_col (WEdit * edit, off_t p);
 157 long edit_get_col (const WEdit * edit);
 158 void edit_update_curs_row (WEdit * edit);
 159 void edit_update_curs_col (WEdit * edit);
 160 void edit_find_bracket (WEdit * edit);
 161 gboolean edit_reload_line (WEdit * edit, const vfs_path_t * filename_vpath, long line);
 162 void edit_set_codeset (WEdit * edit);
 163 
 164 void edit_block_copy_cmd (WEdit * edit);
 165 void edit_block_move_cmd (WEdit * edit);
 166 gboolean edit_block_delete_cmd (WEdit * edit);
 167 void edit_delete_line (WEdit * edit);
 168 
 169 int edit_delete (WEdit * edit, gboolean byte_delete);
 170 int edit_backspace (WEdit * edit, gboolean byte_delete);
 171 void edit_insert (WEdit * edit, int c);
 172 void edit_insert_over (WEdit * edit);
 173 void edit_cursor_move (WEdit * edit, off_t increment);
 174 void edit_push_undo_action (WEdit * edit, long c);
 175 void edit_push_redo_action (WEdit * edit, long c);
 176 void edit_push_key_press (WEdit * edit);
 177 void edit_insert_ahead (WEdit * edit, int c);
 178 off_t edit_write_stream (WEdit * edit, FILE * f);
 179 char *edit_get_write_filter (const vfs_path_t * write_name_vpath,
 180                              const vfs_path_t * filename_vpath);
 181 gboolean edit_save_confirm_cmd (WEdit * edit);
 182 gboolean edit_save_as_cmd (WEdit * edit);
 183 WEdit *edit_init (WEdit * edit, const WRect * r, const vfs_path_t * filename_vpath, long line);
 184 gboolean edit_clean (WEdit * edit);
 185 gboolean edit_ok_to_exit (WEdit * edit);
 186 gboolean edit_load_cmd (WDialog * h);
 187 gboolean edit_load_file_from_filename (WDialog * h, const vfs_path_t * vpath, long line);
 188 gboolean edit_load_file_from_history (WDialog * h);
 189 gboolean edit_load_syntax_file (WDialog * h);
 190 gboolean edit_load_menu_file (WDialog * h);
 191 gboolean edit_close_cmd (WEdit * edit);
 192 void edit_mark_cmd (WEdit * edit, gboolean unmark);
 193 void edit_mark_current_word_cmd (WEdit * edit);
 194 void edit_mark_current_line_cmd (WEdit * edit);
 195 void edit_set_markers (WEdit * edit, off_t m1, off_t m2, long c1, long c2);
 196 void edit_push_markers (WEdit * edit);
 197 
 198 gboolean edit_save_block (WEdit * edit, const char *filename, off_t start, off_t finish);
 199 gboolean edit_save_block_cmd (WEdit * edit);
 200 gboolean edit_insert_file_cmd (WEdit * edit);
 201 
 202 off_t edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath);
 203 gboolean edit_load_back_cmd (WEdit * edit);
 204 gboolean edit_load_forward_cmd (WEdit * edit);
 205 void edit_block_process_cmd (WEdit * edit, int macro_number);
 206 void edit_refresh_cmd (void);
 207 void edit_syntax_onoff_cmd (WDialog * h);
 208 void edit_show_tabs_tws_cmd (WDialog * h);
 209 void edit_show_margin_cmd (WDialog * h);
 210 void edit_show_numbers_cmd (WDialog * h);
 211 void edit_date_cmd (WEdit * edit);
 212 void edit_goto_cmd (WEdit * edit);
 213 gboolean eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark);
 214 void edit_status (WEdit * edit, gboolean active);
 215 void edit_execute_key_command (WEdit * edit, long command, int char_for_insertion);
 216 void edit_update_screen (WEdit * edit);
 217 void edit_save_size (WEdit * edit);
 218 gboolean edit_handle_move_resize (WEdit * edit, long command);
 219 void edit_toggle_fullscreen (WEdit * edit);
 220 void edit_move_to_line (WEdit * e, long line);
 221 void edit_move_display (WEdit * e, long line);
 222 void edit_word_wrap (WEdit * edit);
 223 int edit_sort_cmd (WEdit * edit);
 224 int edit_ext_cmd (WEdit * edit);
 225 
 226 gboolean edit_copy_to_X_buf_cmd (WEdit * edit);
 227 gboolean edit_cut_to_X_buf_cmd (WEdit * edit);
 228 gboolean edit_paste_from_X_buf_cmd (WEdit * edit);
 229 
 230 void edit_select_codepage_cmd (WEdit * edit);
 231 void edit_insert_literal_cmd (WEdit * edit);
 232 
 233 void edit_paste_from_history (WEdit * edit);
 234 
 235 void edit_set_filename (WEdit * edit, const vfs_path_t * name_vpath);
 236 
 237 void edit_load_syntax (WEdit * edit, GPtrArray * pnames, const char *type);
 238 void edit_free_syntax_rules (WEdit * edit);
 239 int edit_get_syntax_color (WEdit * edit, off_t byte_index);
 240 void edit_syntax_dialog (WEdit * edit);
 241 
 242 void book_mark_insert (WEdit * edit, long line, int c);
 243 gboolean book_mark_query_color (WEdit * edit, long line, int c);
 244 struct edit_book_mark_t *book_mark_find (WEdit * edit, long line);
 245 gboolean book_mark_clear (WEdit * edit, long line, int c);
 246 void book_mark_flush (WEdit * edit, int c);
 247 void book_mark_inc (WEdit * edit, long line);
 248 void book_mark_dec (WEdit * edit, long line);
 249 void book_mark_serialize (WEdit * edit, int color);
 250 void book_mark_restore (WEdit * edit, int color);
 251 
 252 gboolean edit_line_is_blank (WEdit * edit, long line);
 253 gboolean is_break_char (char c);
 254 void edit_options_dialog (WDialog * h);
 255 void edit_mail_dialog (WEdit * edit);
 256 void format_paragraph (WEdit * edit, gboolean force);
 257 
 258 /* either command or char_for_insertion must be passed as -1 */
 259 void edit_execute_cmd (WEdit * edit, long command, int char_for_insertion);
 260 
 261 int editcmd_dialog_raw_key_query (const char *heading, const char *query, gboolean cancel);
 262 
 263 /*** inline functions ****************************************************************************/
 264 
 265 /**
 266  * Load a new file into the editor.  If it fails, preserve the old file.
 267  * To do it, allocate a new widget, initialize it and, if the new file
 268  * was loaded, copy the data to the old widget.
 269  *
 270  * @return TRUE on success, FALSE on failure.
 271  */
 272 static inline gboolean
 273 edit_reload (WEdit * edit, const vfs_path_t * filename_vpath)
     /* [previous][next][first][last][top][bottom][index][help]  */
 274 {
 275     return edit_reload_line (edit, filename_vpath, 0);
 276 }
 277 
 278 #endif /* MC__EDIT_IMPL_H */

/* [previous][next][first][last][top][bottom][index][help]  */