1 /** \file 2 * \brief Header: editor widget WEdit 3 */ 4 5 #ifndef MC__EDIT_WIDGET_H 6 #define MC__EDIT_WIDGET_H 7 8 #include <limits.h> /* MB_LEN_MAX */ 9 10 #include "lib/search.h" /* mc_search_t */ 11 #include "lib/widget.h" /* Widget */ 12 13 #include "edit-impl.h" 14 #include "editbuffer.h" 15 16 /*** typedefs(not structures) and defined constants **********************************************/ 17 18 #define N_LINE_CACHES 32 19 20 /*** enums ***************************************************************************************/ 21 22 /*** structures declarations (and typedefs of structures)*****************************************/ 23 24 typedef struct edit_book_mark_t edit_book_mark_t; 25 struct edit_book_mark_t 26 { 27 long line; /* line number */ 28 int c; /* color */ 29 edit_book_mark_t *next; 30 edit_book_mark_t *prev; 31 }; 32 33 typedef struct edit_syntax_rule_t edit_syntax_rule_t; 34 struct edit_syntax_rule_t 35 { 36 unsigned short keyword; 37 off_t end; 38 unsigned char context; 39 unsigned char _context; 40 unsigned char border; 41 }; 42 43 /* 44 * State of WEdit window 45 * MCEDIT_DRAG_NONE - window is in normal mode 46 * MCEDIT_DRAG_MOVE - window is being moved 47 * MCEDIT_DRAG_RESIZE - window is being resized 48 */ 49 typedef enum 50 { 51 MCEDIT_DRAG_NONE = 0, 52 MCEDIT_DRAG_MOVE, 53 MCEDIT_DRAG_RESIZE 54 } mcedit_drag_state_t; 55 56 struct WEdit 57 { 58 Widget widget; 59 mcedit_drag_state_t drag_state; 60 int drag_state_start; /* save cursor position before window moving */ 61 62 /* save location before move/resize or toggle to fullscreen */ 63 WRect loc_prev; 64 65 vfs_path_t *filename_vpath; /* Name of the file */ 66 vfs_path_t *dir_vpath; /* NULL if filename is absolute */ 67 68 /* dynamic buffers and cursor position for editor: */ 69 edit_buffer_t buffer; 70 71 #ifdef HAVE_CHARSET 72 /* multibyte support */ 73 gboolean utf8; /* It's multibyte file codeset */ 74 GIConv converter; 75 char charbuf[MB_LEN_MAX + 1]; 76 int charpoint; 77 #endif 78 79 /* search handler */ 80 mc_search_t *search; 81 int replace_mode; 82 /* whether search conditions should be started with BOL(^) or ended with EOL($) */ 83 mc_search_line_t search_line_type; 84 85 char *last_search_string; /* String that have been searched */ 86 off_t search_start; /* First character to start searching from */ 87 unsigned long found_len; /* Length of found string or 0 if none was found */ 88 off_t found_start; /* the found word from a search - start position */ 89 90 /* display information */ 91 long start_display; /* First char displayed */ 92 long start_col; /* First displayed column, negative */ 93 long curs_row; /* row position of cursor on the screen */ 94 long curs_col; /* column position on screen */ 95 long over_col; /* pos after '\n' */ 96 int force; /* how much of the screen do we redraw? */ 97 unsigned int overwrite:1; /* Overwrite on type mode (as opposed to insert) */ 98 unsigned int modified:1; /* File has been modified and needs saving */ 99 unsigned int loading_done:1; /* File has been loaded into the editor */ 100 unsigned int locked:1; /* We hold lock on current file */ 101 unsigned int delete_file:1; /* New file, needs to be deleted unless modified */ 102 unsigned int highlight:1; /* There is a selected block */ 103 unsigned int column_highlight:1; 104 unsigned int fullscreen:1; /* Is window fullscreen or not */ 105 long prev_col; /* recent column position of the cursor - used when moving 106 up or down past lines that are shorter than the current line */ 107 long start_line; /* line number of the top of the page */ 108 109 /* file info */ 110 off_t mark1; /* position of highlight start */ 111 off_t mark2; /* position of highlight end */ 112 off_t end_mark_curs; /* position of cursor after end of highlighting */ 113 long column1; /* position of column highlight start */ 114 long column2; /* position of column highlight end */ 115 off_t bracket; /* position of a matching bracket */ 116 off_t last_bracket; /* previous position of a matching bracket */ 117 118 /* cache speedup for line lookups */ 119 gboolean caches_valid; 120 long line_numbers[N_LINE_CACHES]; 121 off_t line_offsets[N_LINE_CACHES]; 122 123 edit_book_mark_t *book_mark; 124 GArray *serialized_bookmarks; 125 126 /* undo stack and pointers */ 127 unsigned long undo_stack_pointer; 128 long *undo_stack; 129 unsigned long undo_stack_size; 130 unsigned long undo_stack_size_mask; 131 unsigned long undo_stack_bottom; 132 unsigned int undo_stack_disable:1; /* If not 0, don't save events in the undo stack */ 133 134 unsigned long redo_stack_pointer; 135 long *redo_stack; 136 unsigned long redo_stack_size; 137 unsigned long redo_stack_size_mask; 138 unsigned long redo_stack_bottom; 139 unsigned int redo_stack_reset:1; /* If 1, need clear redo stack */ 140 141 struct stat stat1; /* Result of mc_fstat() on the file */ 142 unsigned long attrs; /* Result of mc_fgetflags() on the file */ 143 gboolean attrs_ok; /* mc_fgetflags() == 0 */ 144 145 unsigned int skip_detach_prompt:1; /* Do not prompt whether to detach a file anymore */ 146 147 /* syntax highlighting */ 148 GSList *syntax_marker; 149 GPtrArray *rules; 150 off_t last_get_rule; 151 edit_syntax_rule_t rule; 152 char *syntax_type; /* description of syntax highlighting type being used */ 153 GTree *defines; /* List of defines */ 154 gboolean is_case_insensitive; /* selects language case sensitivity */ 155 156 /* line break */ 157 LineBreaks lb; 158 }; 159 160 /*** global variables defined in .c file *********************************************************/ 161 162 /*** declarations of public functions ************************************************************/ 163 164 /*** inline functions ****************************************************************************/ 165 #endif /* MC__EDIT_WIDGET_H */