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 max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */ 94 long curs_row; /* row position of cursor on the screen */ 95 long curs_col; /* column position on screen */ 96 long over_col; /* pos after '\n' */ 97 int force; /* how much of the screen do we redraw? */ 98 unsigned int overwrite:1; /* Overwrite on type mode (as opposed to insert) */ 99 unsigned int modified:1; /* File has been modified and needs saving */ 100 unsigned int loading_done:1; /* File has been loaded into the editor */ 101 unsigned int locked:1; /* We hold lock on current file */ 102 unsigned int delete_file:1; /* New file, needs to be deleted unless modified */ 103 unsigned int highlight:1; /* There is a selected block */ 104 unsigned int column_highlight:1; 105 unsigned int fullscreen:1; /* Is window fullscreen or not */ 106 long prev_col; /* recent column position of the cursor - used when moving 107 up or down past lines that are shorter than the current line */ 108 long start_line; /* line number of the top of the page */ 109 110 /* file info */ 111 off_t mark1; /* position of highlight start */ 112 off_t mark2; /* position of highlight end */ 113 off_t end_mark_curs; /* position of cursor after end of highlighting */ 114 long column1; /* position of column highlight start */ 115 long column2; /* position of column highlight end */ 116 off_t bracket; /* position of a matching bracket */ 117 off_t last_bracket; /* previous position of a matching bracket */ 118 119 /* cache speedup for line lookups */ 120 gboolean caches_valid; 121 long line_numbers[N_LINE_CACHES]; 122 off_t line_offsets[N_LINE_CACHES]; 123 124 edit_book_mark_t *book_mark; 125 GArray *serialized_bookmarks; 126 127 /* undo stack and pointers */ 128 unsigned long undo_stack_pointer; 129 long *undo_stack; 130 unsigned long undo_stack_size; 131 unsigned long undo_stack_size_mask; 132 unsigned long undo_stack_bottom; 133 unsigned int undo_stack_disable:1; /* If not 0, don't save events in the undo stack */ 134 135 unsigned long redo_stack_pointer; 136 long *redo_stack; 137 unsigned long redo_stack_size; 138 unsigned long redo_stack_size_mask; 139 unsigned long redo_stack_bottom; 140 unsigned int redo_stack_reset:1; /* If 1, need clear redo stack */ 141 142 struct stat stat1; /* Result of mc_fstat() on the file */ 143 unsigned long attrs; /* Result of mc_fgetflags() on the file */ 144 gboolean attrs_ok; /* mc_fgetflags() == 0 */ 145 146 unsigned int skip_detach_prompt:1; /* Do not prompt whether to detach a file anymore */ 147 148 /* syntax highlighting */ 149 GSList *syntax_marker; 150 GPtrArray *rules; 151 off_t last_get_rule; 152 edit_syntax_rule_t rule; 153 char *syntax_type; /* description of syntax highlighting type being used */ 154 GTree *defines; /* List of defines */ 155 gboolean is_case_insensitive; /* selects language case sensitivity */ 156 157 /* line break */ 158 LineBreaks lb; 159 }; 160 161 /*** global variables defined in .c file *********************************************************/ 162 163 /*** declarations of public functions ************************************************************/ 164 165 /*** inline functions ****************************************************************************/ 166 #endif /* MC__EDIT_WIDGET_H */