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