Ticket #3836: maint - set default `--with-homedir` value to `.mc` instead of `yes`
[midnight-commander.git] / src / editor / editwidget.h
blob5e515f3e9d6199d65d966723b94ff8a25dafcaae
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"
12 #include "editbuffer.h"
14 /*** typedefs(not structures) and defined constants **********************************************/
16 #define N_LINE_CACHES 32
18 /*** enums ***************************************************************************************/
20 /**
21 enum for store the search conditions check results.
22 (if search condition have BOL(^) or EOL ($) regexp checial characters).
24 typedef enum
26 AT_START_LINE = (1 << 0),
27 AT_END_LINE = (1 << 1)
28 } edit_search_line_t;
30 /*** structures declarations (and typedefs of structures)*****************************************/
32 typedef struct edit_book_mark_t edit_book_mark_t;
33 struct edit_book_mark_t
35 long line; /* line number */
36 int c; /* color */
37 edit_book_mark_t *next;
38 edit_book_mark_t *prev;
41 typedef struct edit_syntax_rule_t edit_syntax_rule_t;
42 struct edit_syntax_rule_t
44 unsigned short keyword;
45 off_t end;
46 unsigned char context;
47 unsigned char _context;
48 unsigned char border;
52 * State of WEdit window
53 * MCEDIT_DRAG_NONE - window is in normal mode
54 * MCEDIT_DRAG_MOVE - window is being moved
55 * MCEDIT_DRAG_RESIZE - window is being resized
57 typedef enum
59 MCEDIT_DRAG_NONE = 0,
60 MCEDIT_DRAG_MOVE,
61 MCEDIT_DRAG_RESIZE
62 } mcedit_drag_state_t;
64 struct WEdit
66 Widget widget;
67 mcedit_drag_state_t drag_state;
68 int drag_state_start; /* save cursor position before window moving */
70 /* save location before move/resize or toggle to fullscreen */
71 int x_prev, y_prev;
72 int cols_prev, lines_prev;
74 vfs_path_t *filename_vpath; /* Name of the file */
75 vfs_path_t *dir_vpath; /* NULL if filename is absolute */
77 /* dynamic buffers and cursor position for editor: */
78 edit_buffer_t buffer;
80 #ifdef HAVE_CHARSET
81 /* multibyte support */
82 gboolean utf8; /* It's multibyte file codeset */
83 GIConv converter;
84 char charbuf[4 + 1];
85 int charpoint;
86 #endif
88 /* search handler */
89 mc_search_t *search;
90 int replace_mode;
91 /* is search conditions should be started from BOL(^) or ended with EOL($) */
92 edit_search_line_t search_line_type;
94 char *last_search_string; /* String that have been searched */
95 off_t search_start; /* First character to start searching from */
96 unsigned long found_len; /* Length of found string or 0 if none was found */
97 off_t found_start; /* the found word from a search - start position */
99 /* display information */
100 long start_display; /* First char displayed */
101 long start_col; /* First displayed column, negative */
102 long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
103 long curs_row; /* row position of cursor on the screen */
104 long curs_col; /* column position on screen */
105 long over_col; /* pos after '\n' */
106 int force; /* how much of the screen do we redraw? */
107 unsigned int overwrite:1; /* Overwrite on type mode (as opposed to insert) */
108 unsigned int modified:1; /* File has been modified and needs saving */
109 unsigned int loading_done:1; /* File has been loaded into the editor */
110 unsigned int locked:1; /* We hold lock on current file */
111 unsigned int delete_file:1; /* New file, needs to be deleted unless modified */
112 unsigned int highlight:1; /* There is a selected block */
113 unsigned int column_highlight:1;
114 unsigned int fullscreen:1; /* Is window fullscreen or not */
115 long prev_col; /* recent column position of the cursor - used when moving
116 up or down past lines that are shorter than the current line */
117 long start_line; /* line number of the top of the page */
119 /* file info */
120 off_t mark1; /* position of highlight start */
121 off_t mark2; /* position of highlight end */
122 off_t end_mark_curs; /* position of cursor after end of highlighting */
123 long column1; /* position of column highlight start */
124 long column2; /* position of column highlight end */
125 off_t bracket; /* position of a matching bracket */
126 off_t last_bracket; /* previous position of a matching bracket */
128 /* cache speedup for line lookups */
129 gboolean caches_valid;
130 long line_numbers[N_LINE_CACHES];
131 off_t line_offsets[N_LINE_CACHES];
133 edit_book_mark_t *book_mark;
134 GArray *serialized_bookmarks;
136 /* undo stack and pointers */
137 unsigned long undo_stack_pointer;
138 long *undo_stack;
139 unsigned long undo_stack_size;
140 unsigned long undo_stack_size_mask;
141 unsigned long undo_stack_bottom;
142 unsigned int undo_stack_disable:1; /* If not 0, don't save events in the undo stack */
144 unsigned long redo_stack_pointer;
145 long *redo_stack;
146 unsigned long redo_stack_size;
147 unsigned long redo_stack_size_mask;
148 unsigned long redo_stack_bottom;
149 unsigned int redo_stack_reset:1; /* If 1, need clear redo stack */
151 struct stat stat1; /* Result of mc_fstat() on the file */
152 unsigned int skip_detach_prompt:1; /* Do not prompt whether to detach a file anymore */
154 /* syntax higlighting */
155 GSList *syntax_marker;
156 GPtrArray *rules;
157 off_t last_get_rule;
158 edit_syntax_rule_t rule;
159 char *syntax_type; /* description of syntax highlighting type being used */
160 GTree *defines; /* List of defines */
161 gboolean is_case_insensitive; /* selects language case sensitivity */
163 /* line break */
164 LineBreaks lb;
165 gboolean extmod;
168 /*** global variables defined in .c file *********************************************************/
170 /*** declarations of public functions ************************************************************/
172 /*** inline functions ****************************************************************************/
173 #endif /* MC__EDIT_WIDGET_H */