Ticket #2877: code cleanup before 4.8.1.6 release.
[midnight-commander.git] / src / editor / editwidget.h
blob15758914ea756012402b15560e58f9eaa381d861
1 /** \file
2 * \brief Header: editor widget WEdit
3 */
5 #ifndef MC__EDIT_WIDGET_H
6 #define MC__EDIT_WIDGET_H
8 #include "lib/search.h" /* mc_search_t */
9 #include "lib/widget.h" /* Widget */
11 #include "edit-impl.h"
13 /*** typedefs(not structures) and defined constants **********************************************/
15 #define N_LINE_CACHES 32
17 /*** enums ***************************************************************************************/
19 /**
20 enum for store the search conditions check results.
21 (if search condition have BOL(^) or EOL ($) regexp checial characters).
23 typedef enum
25 AT_START_LINE = (1 << 0),
26 AT_END_LINE = (1 << 1)
27 } edit_search_line_t;
29 /*** structures declarations (and typedefs of structures)*****************************************/
31 struct _book_mark
33 long line; /* line number */
34 int c; /* color */
35 struct _book_mark *next;
36 struct _book_mark *prev;
39 struct syntax_rule
41 unsigned short keyword;
42 unsigned char end;
43 unsigned char context;
44 unsigned char _context;
45 unsigned char border;
48 struct WEdit
50 Widget widget;
52 vfs_path_t *filename_vpath; /* Name of the file */
53 vfs_path_t *dir_vpath; /* NULL if filename is absolute */
55 /* dynamic buffers and cursor position for editor: */
56 off_t curs1; /* position of the cursor from the beginning of the file. */
57 off_t curs2; /* position from the end of the file */
58 unsigned char *buffers1[MAXBUFF + 1]; /* all data up to curs1 */
59 unsigned char *buffers2[MAXBUFF + 1]; /* all data from end of file down to curs2 */
61 #ifdef HAVE_CHARSET
62 /* multibyte support */
63 gboolean utf8; /* It's multibyte file codeset */
64 GIConv converter;
65 char charbuf[4 + 1];
66 int charpoint;
67 #endif
69 /* search handler */
70 mc_search_t *search;
71 int replace_mode;
72 /* is search conditions should be started from BOL(^) or ended with EOL($) */
73 edit_search_line_t search_line_type;
75 char *last_search_string; /* String that have been searched */
76 off_t search_start; /* First character to start searching from */
77 unsigned long found_len; /* Length of found string or 0 if none was found */
78 off_t found_start; /* the found word from a search - start position */
80 /* display information */
81 off_t last_byte; /* Last byte of file */
82 long start_display; /* First char displayed */
83 long start_col; /* First displayed column, negative */
84 long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
85 long curs_row; /* row position of cursor on the screen */
86 long curs_col; /* column position on screen */
87 long over_col; /* pos after '\n' */
88 int force; /* how much of the screen do we redraw? */
89 unsigned int overwrite:1; /* Overwrite on type mode (as opposed to insert) */
90 unsigned int modified:1; /* File has been modified and needs saving */
91 unsigned int loading_done:1; /* File has been loaded into the editor */
92 unsigned int locked:1; /* We hold lock on current file */
93 unsigned int delete_file:1; /* New file, needs to be deleted unless modified */
94 unsigned int highlight:1; /* There is a selected block */
95 unsigned int column_highlight:1;
96 long prev_col; /* recent column position of the cursor - used when moving
97 up or down past lines that are shorter than the current line */
98 long curs_line; /* line number of the cursor. */
99 long start_line; /* line number of the top of the page */
101 /* file info */
102 long total_lines; /* total lines in the file */
103 off_t mark1; /* position of highlight start */
104 off_t mark2; /* position of highlight end */
105 off_t end_mark_curs; /* position of cursor after end of highlighting */
106 long column1; /* position of column highlight start */
107 long column2; /* position of column highlight end */
108 off_t bracket; /* position of a matching bracket */
110 /* cache speedup for line lookups */
111 gboolean caches_valid;
112 long line_numbers[N_LINE_CACHES];
113 off_t line_offsets[N_LINE_CACHES];
115 struct _book_mark *book_mark;
116 GArray *serialized_bookmarks;
118 /* undo stack and pointers */
119 unsigned long undo_stack_pointer;
120 long *undo_stack;
121 unsigned long undo_stack_size;
122 unsigned long undo_stack_size_mask;
123 unsigned long undo_stack_bottom;
124 unsigned int undo_stack_disable:1; /* If not 0, don't save events in the undo stack */
126 unsigned long redo_stack_pointer;
127 long *redo_stack;
128 unsigned long redo_stack_size;
129 unsigned long redo_stack_size_mask;
130 unsigned long redo_stack_bottom;
131 unsigned int redo_stack_reset:1; /* If 1, need clear redo stack */
133 struct stat stat1; /* Result of mc_fstat() on the file */
134 unsigned int skip_detach_prompt:1; /* Do not prompt whether to detach a file anymore */
136 /* syntax higlighting */
137 struct _syntax_marker *syntax_marker;
138 struct context_rule **rules;
139 long last_get_rule;
140 struct syntax_rule rule;
141 char *syntax_type; /* description of syntax highlighting type being used */
142 GTree *defines; /* List of defines */
143 gboolean is_case_insensitive; /* selects language case sensitivity */
145 /* line break */
146 LineBreaks lb;
147 gboolean extmod;
149 char *labels[10];
152 /*** global variables defined in .c file *********************************************************/
154 /*** declarations of public functions ************************************************************/
156 /*** inline functions ****************************************************************************/
157 #endif /* MC__EDIT_WIDGET_H */