Ticket #1534 (cool cooledit)
[midnight-commander.git] / edit / edit-widget.h
blob506312c770d5eeef9ed10ef335e08142a03dfb9f
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"
14 #define MAX_MACRO_LENGTH 1024
15 #define N_LINE_CACHES 32
17 #define BOOK_MARK_COLOR ((25 << 8) | 5)
18 #define BOOK_MARK_FOUND_COLOR ((26 << 8) | 4)
20 struct _book_mark {
21 int line; /* line number */
22 int c; /* color */
23 struct _book_mark *next;
24 struct _book_mark *prev;
27 struct syntax_rule {
28 unsigned short keyword;
29 unsigned char end;
30 unsigned char context;
31 unsigned char _context;
32 unsigned char border;
35 typedef struct edit_key_map_type {
36 long key;
37 long command;
38 } edit_key_map_type;
40 struct WEdit {
41 Widget widget;
43 int num_widget_lines;
44 int num_widget_columns;
46 char *filename; /* Name of the file */
47 char *dir; /* NULL if filename is absolute */
49 /* dynamic buffers and cursor position for editor: */
50 long curs1; /* position of the cursor from the beginning of the file. */
51 long curs2; /* position from the end of the file */
52 unsigned char *buffers1[MAXBUFF + 1]; /* all data up to curs1 */
53 unsigned char *buffers2[MAXBUFF + 1]; /* all data from end of file down to curs2 */
55 /* UTF8 */
56 char charbuf[4 + 1];
57 int charpoint;
58 /* search variables */
59 mc_search_t *search;
61 unsigned int search_type;
62 int replace_mode;
63 int replace_backwards;
64 int replace_case;
65 int all_codepages;
67 long search_start; /* First character to start searching from */
68 int found_len; /* Length of found string or 0 if none was found */
69 long found_start; /* the found word from a search - start position */
71 /* display information */
72 long last_byte; /* Last byte of file */
73 long start_display; /* First char displayed */
74 long start_col; /* First displayed column, negative */
75 long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
76 long curs_row; /* row position of cursor on the screen */
77 long curs_col; /* column position on screen */
78 long over_col; /* pos after '\n' */
79 int force; /* how much of the screen do we redraw? */
80 unsigned int overwrite:1; /* Overwrite on type mode (as opposed to insert) */
81 unsigned int modified:1; /* File has been modified and needs saving */
82 unsigned int loading_done:1;/* File has been loaded into the editor */
83 unsigned int locked:1; /* We hold lock on current file */
84 unsigned int screen_modified:1; /* File has been changed since the last screen draw */
85 unsigned int delete_file:1; /* New file, needs to be deleted unless modified */
86 unsigned int highlight:1; /* There is a selected block */
87 unsigned int utf8:1; /* It's multibyte file codeset */
88 long prev_col; /* recent column position of the cursor - used when moving
89 up or down past lines that are shorter than the current line */
90 long curs_line; /* line number of the cursor. */
91 long start_line; /* line number of the top of the page */
93 /* file info */
94 long total_lines; /* total lines in the file */
95 long mark1; /* position of highlight start */
96 long mark2; /* position of highlight end */
97 int column1; /* position of column highlight start */
98 int column2; /* position of column highlight end */
99 long bracket; /* position of a matching bracket */
101 /* cache speedup for line lookups */
102 int caches_valid;
103 int line_numbers[N_LINE_CACHES];
104 long line_offsets[N_LINE_CACHES];
106 struct _book_mark *book_mark;
108 /* undo stack and pointers */
109 unsigned long stack_pointer;
110 long *undo_stack;
111 unsigned long stack_size;
112 unsigned long stack_size_mask;
113 unsigned long stack_bottom;
114 unsigned int stack_disable:1; /* If not 0, don't save events in the undo stack */
116 struct stat stat1; /* Result of mc_fstat() on the file */
117 unsigned int skip_detach_prompt:1; /* Do not prompt whether to detach a file anymore */
119 /* syntax higlighting */
120 struct _syntax_marker *syntax_marker;
121 struct context_rule **rules;
122 long last_get_rule;
123 struct syntax_rule rule;
124 char *syntax_type; /* description of syntax highlighting type being used */
125 GTree *defines; /* List of defines */
127 /* macro stuff */
128 int macro_i; /* index to macro[], -1 if not recording a macro */
129 int macro_depth; /* depth of the macro recursion */
130 struct macro macro[MAX_MACRO_LENGTH];
132 /* user map stuff */
133 const edit_key_map_type *user_map;
134 const edit_key_map_type *ext_map;
136 int extmod;
138 char *labels[10];
142 #endif /* MC_EDIT_WIDGET_H */