Merge branch '1904_spec_bump_epoch'
[midnight-commander.git] / edit / edit-widget.h
blob0e908824bf81af9a357fff62026c637a6fd55929
2 /** \file
3 * \brief Header: editor widget WEdit
4 */
6 #ifndef MC_EDIT_WIDGET_H
7 #define MC_EDIT_WIDGET_H
9 #include "../src/dialog.h" /* Widget */
10 #include "../src/search/search.h" /* mc_search_t */
12 #include "edit-impl.h"
13 #include "../src/keybind.h"
15 #define MAX_MACRO_LENGTH 1024
16 #define N_LINE_CACHES 32
18 struct _book_mark {
19 int line; /* line number */
20 int c; /* color */
21 struct _book_mark *next;
22 struct _book_mark *prev;
25 struct syntax_rule {
26 unsigned short keyword;
27 unsigned char end;
28 unsigned char context;
29 unsigned char _context;
30 unsigned char border;
33 struct WEdit {
34 Widget widget;
36 int num_widget_lines;
37 int num_widget_columns;
39 char *filename; /* Name of the file */
40 char *dir; /* NULL if filename is absolute */
42 /* dynamic buffers and cursor position for editor: */
43 long curs1; /* position of the cursor from the beginning of the file. */
44 long curs2; /* position from the end of the file */
45 unsigned char *buffers1[MAXBUFF + 1]; /* all data up to curs1 */
46 unsigned char *buffers2[MAXBUFF + 1]; /* all data from end of file down to curs2 */
48 /* UTF8 */
49 char charbuf[4 + 1];
50 int charpoint;
51 /* search variables */
52 mc_search_t *search;
54 unsigned int search_type;
55 int replace_mode;
56 int replace_backwards;
57 int replace_case;
58 int only_in_selection;
59 int whole_words;
60 int all_codepages;
62 long search_start; /* First character to start searching from */
63 int found_len; /* Length of found string or 0 if none was found */
64 long found_start; /* the found word from a search - start position */
66 /* display information */
67 long last_byte; /* Last byte of file */
68 long start_display; /* First char displayed */
69 long start_col; /* First displayed column, negative */
70 long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
71 long curs_row; /* row position of cursor on the screen */
72 long curs_col; /* column position on screen */
73 long over_col; /* pos after '\n' */
74 int force; /* how much of the screen do we redraw? */
75 unsigned int overwrite:1; /* Overwrite on type mode (as opposed to insert) */
76 unsigned int modified:1; /* File has been modified and needs saving */
77 unsigned int loading_done:1;/* File has been loaded into the editor */
78 unsigned int locked:1; /* We hold lock on current file */
79 unsigned int screen_modified:1; /* File has been changed since the last screen draw */
80 unsigned int delete_file:1; /* New file, needs to be deleted unless modified */
81 unsigned int highlight:1; /* There is a selected block */
82 unsigned int utf8:1; /* It's multibyte file codeset */
83 long prev_col; /* recent column position of the cursor - used when moving
84 up or down past lines that are shorter than the current line */
85 long curs_line; /* line number of the cursor. */
86 long start_line; /* line number of the top of the page */
88 /* file info */
89 long total_lines; /* total lines in the file */
90 long mark1; /* position of highlight start */
91 long mark2; /* position of highlight end */
92 int column1; /* position of column highlight start */
93 int column2; /* position of column highlight end */
94 long bracket; /* position of a matching bracket */
96 /* cache speedup for line lookups */
97 int caches_valid;
98 int line_numbers[N_LINE_CACHES];
99 long line_offsets[N_LINE_CACHES];
101 struct _book_mark *book_mark;
103 /* undo stack and pointers */
104 unsigned long stack_pointer;
105 long *undo_stack;
106 unsigned long stack_size;
107 unsigned long stack_size_mask;
108 unsigned long stack_bottom;
109 unsigned int stack_disable:1; /* If not 0, don't save events in the undo stack */
111 struct stat stat1; /* Result of mc_fstat() on the file */
112 unsigned int skip_detach_prompt:1; /* Do not prompt whether to detach a file anymore */
114 /* syntax higlighting */
115 struct _syntax_marker *syntax_marker;
116 struct context_rule **rules;
117 long last_get_rule;
118 struct syntax_rule rule;
119 char *syntax_type; /* description of syntax highlighting type being used */
120 GTree *defines; /* List of defines */
122 /* macro stuff */
123 int macro_i; /* index to macro[], -1 if not recording a macro */
124 int macro_depth; /* depth of the macro recursion */
125 struct macro macro[MAX_MACRO_LENGTH];
127 /* user map stuff */
128 GIConv converter;
130 /* line break */
131 LineBreaks lb;
132 int extmod;
134 char *labels[10];
138 #endif /* MC_EDIT_WIDGET_H */