Fixed exec_get_export_variables_ext test
[midnight-commander.git] / src / editor / editwidget.h
blobfaa1a9a52b7c0e7af9e00c07016f45dec3068a4e
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 typedef struct edit_book_mark_t edit_book_mark_t;
32 struct edit_book_mark_t
34 long line; /* line number */
35 int c; /* color */
36 edit_book_mark_t *next;
37 edit_book_mark_t *prev;
40 typedef struct edit_syntax_rule_t edit_syntax_rule_t;
41 struct edit_syntax_rule_t
43 unsigned short keyword;
44 off_t end;
45 unsigned char context;
46 unsigned char _context;
47 unsigned char border;
51 * State of WEdit window
52 * MCEDIT_DRAG_NORMAL - window is in normal mode
53 * MCEDIT_DRAG_MOVE - window is being moved
54 * MCEDIT_DRAG_RESIZE - window is being resized
56 typedef enum
58 MCEDIT_DRAG_NORMAL = 0,
59 MCEDIT_DRAG_MOVE,
60 MCEDIT_DRAG_RESIZE
61 } mcedit_drag_state_t;
63 struct WEdit
65 Widget widget;
66 mcedit_drag_state_t drag_state;
67 int drag_state_start; /* save cursor position before window moving */
69 /* save location before move/resize or toggle to fullscreen */
70 int x_prev, y_prev;
71 int cols_prev, lines_prev;
73 vfs_path_t *filename_vpath; /* Name of the file */
74 vfs_path_t *dir_vpath; /* NULL if filename is absolute */
76 /* dynamic buffers and cursor position for editor: */
77 off_t curs1; /* position of the cursor from the beginning of the file. */
78 off_t curs2; /* position from the end of the file */
79 unsigned char *buffers1[MAXBUFF + 1]; /* all data up to curs1 */
80 unsigned char *buffers2[MAXBUFF + 1]; /* all data from end of file down to curs2 */
82 #ifdef HAVE_CHARSET
83 /* multibyte support */
84 gboolean utf8; /* It's multibyte file codeset */
85 GIConv converter;
86 char charbuf[4 + 1];
87 int charpoint;
88 #endif
90 /* search handler */
91 mc_search_t *search;
92 int replace_mode;
93 /* is search conditions should be started from BOL(^) or ended with EOL($) */
94 edit_search_line_t search_line_type;
96 char *last_search_string; /* String that have been searched */
97 off_t search_start; /* First character to start searching from */
98 unsigned long found_len; /* Length of found string or 0 if none was found */
99 off_t found_start; /* the found word from a search - start position */
101 /* display information */
102 off_t last_byte; /* Last byte of file */
103 long start_display; /* First char displayed */
104 long start_col; /* First displayed column, negative */
105 long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
106 long curs_row; /* row position of cursor on the screen */
107 long curs_col; /* column position on screen */
108 long over_col; /* pos after '\n' */
109 int force; /* how much of the screen do we redraw? */
110 unsigned int overwrite:1; /* Overwrite on type mode (as opposed to insert) */
111 unsigned int modified:1; /* File has been modified and needs saving */
112 unsigned int loading_done:1; /* File has been loaded into the editor */
113 unsigned int locked:1; /* We hold lock on current file */
114 unsigned int delete_file:1; /* New file, needs to be deleted unless modified */
115 unsigned int highlight:1; /* There is a selected block */
116 unsigned int column_highlight:1;
117 unsigned int fullscreen:1; /* Is window fullscreen or not */
118 long prev_col; /* recent column position of the cursor - used when moving
119 up or down past lines that are shorter than the current line */
120 long curs_line; /* line number of the cursor. */
121 long start_line; /* line number of the top of the page */
123 /* file info */
124 long total_lines; /* total lines in the file */
125 off_t mark1; /* position of highlight start */
126 off_t mark2; /* position of highlight end */
127 off_t end_mark_curs; /* position of cursor after end of highlighting */
128 long column1; /* position of column highlight start */
129 long column2; /* position of column highlight end */
130 off_t bracket; /* position of a matching bracket */
132 /* cache speedup for line lookups */
133 gboolean caches_valid;
134 long line_numbers[N_LINE_CACHES];
135 off_t line_offsets[N_LINE_CACHES];
137 edit_book_mark_t *book_mark;
138 GArray *serialized_bookmarks;
140 /* undo stack and pointers */
141 unsigned long undo_stack_pointer;
142 long *undo_stack;
143 unsigned long undo_stack_size;
144 unsigned long undo_stack_size_mask;
145 unsigned long undo_stack_bottom;
146 unsigned int undo_stack_disable:1; /* If not 0, don't save events in the undo stack */
148 unsigned long redo_stack_pointer;
149 long *redo_stack;
150 unsigned long redo_stack_size;
151 unsigned long redo_stack_size_mask;
152 unsigned long redo_stack_bottom;
153 unsigned int redo_stack_reset:1; /* If 1, need clear redo stack */
155 struct stat stat1; /* Result of mc_fstat() on the file */
156 unsigned int skip_detach_prompt:1; /* Do not prompt whether to detach a file anymore */
158 /* syntax higlighting */
159 GSList *syntax_marker;
160 struct context_rule **rules;
161 off_t last_get_rule;
162 edit_syntax_rule_t rule;
163 char *syntax_type; /* description of syntax highlighting type being used */
164 GTree *defines; /* List of defines */
165 gboolean is_case_insensitive; /* selects language case sensitivity */
167 /* line break */
168 LineBreaks lb;
169 gboolean extmod;
171 char *labels[10];
174 /*** global variables defined in .c file *********************************************************/
176 /*** declarations of public functions ************************************************************/
178 /*** inline functions ****************************************************************************/
179 #endif /* MC__EDIT_WIDGET_H */