my homework was late :-)
[midnight-commander.git] / gtkedit / edit-widget.h
blob21437288c90374ad65abe8d4bdb9cf477aa1b48b
1 #ifndef __EDIT_WIDGET_H
2 #define __EDIT_WIDGET_H
4 struct macro {
5 short command;
6 short ch;
7 };
9 struct syntax_rule {
10 unsigned short keyword;
11 unsigned char end;
12 unsigned char context;
13 unsigned char _context;
14 #define RULE_ON_LEFT_BORDER 1
15 #define RULE_ON_RIGHT_BORDER 2
16 unsigned char border;
19 /*there are a maximum of ... */
20 #define MAXBUFF 1024
21 #define MAX_MACRO_LENGTH 1024
23 struct _syntax_marker {
24 long offset;
25 struct syntax_rule rule;
26 struct _syntax_marker *next;
29 struct _book_mark {
30 int line; /* line number */
31 /* #define BOOK_MARK_COLOR ((0 << 8) | 26) */ /* black on white */
32 #define BOOK_MARK_COLOR ((25 << 8) | 5)
33 #define BOOK_MARK_FOUND_COLOR ((26 << 8) | 4)
34 int c; /* colour */
35 struct _book_mark *next;
36 struct _book_mark *prev;
39 struct editor_widget {
40 #ifdef MIDNIGHT
41 Widget widget;
42 #elif defined(GTK)
43 GtkEdit *widget;
44 #else
45 struct cool_widget *widget;
46 #endif
47 #define from_here num_widget_lines
48 int num_widget_lines;
49 int num_widget_columns;
51 #ifdef MIDNIGHT
52 int have_frame;
53 #else
54 int stopped;
55 #endif
57 char *filename; /* Name of the file */
58 char *dir; /* current directory */
60 /* dynamic buffers and cursor position for editor: */
61 long curs1; /*position of the cursor from the beginning of the file. */
62 long curs2; /*position from the end of the file */
63 unsigned char *buffers1[MAXBUFF + 1]; /*all data up to curs1 */
64 unsigned char *buffers2[MAXBUFF + 1]; /*all data from end of file down to curs2 */
66 /* search variables */
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 int force; /* how much of the screen do we redraw? */
79 unsigned char overwrite;
80 unsigned char modified; /*has the file been changed?: 1 if char inserted or
81 deleted at all since last load or save */
82 unsigned char screen_modified; /* has the file been changed since the last screen draw? */
83 #if defined(MIDNIGHT) || defined(GTK)
84 int delete_file; /* has the file been created in edit_load_file? Delete
85 it at end of editing when it hasn't been modified
86 or saved */
87 #endif
88 unsigned char highlight;
89 long prev_col; /*recent column position of the cursor - used when moving
90 up or down past lines that are shorter than the current line */
91 long curs_line; /*line number of the cursor. */
92 long start_line; /*line nummber of the top of the page */
94 /* file info */
95 long total_lines; /*total lines in the file */
96 long mark1; /*position of highlight start */
97 long mark2; /*position of highlight end */
98 int column1; /*position of column highlight start */
99 int column2; /*position of column highlight end */
100 long bracket; /*position of a matching bracket */
102 /* cache speedup for line lookups */
103 #define N_LINE_CACHES 32
104 int caches_valid;
105 int line_numbers[N_LINE_CACHES];
106 long line_offsets[N_LINE_CACHES];
108 struct _book_mark *book_mark;
110 /* undo stack and pointers */
111 unsigned long stack_pointer;
112 long *undo_stack;
113 unsigned long stack_size;
114 unsigned long stack_size_mask;
115 unsigned long stack_bottom;
116 struct stat stat;
118 /* syntax higlighting */
119 struct _syntax_marker *syntax_marker;
120 struct context_rule **rules;
121 long last_get_rule;
122 struct syntax_rule rule;
123 char *syntax_type; /* description of syntax highlighting type being used */
124 int explicit_syntax; /* have we forced the syntax hi. type in spite of the filename? */
126 int to_here; /* dummy marker */
129 /* macro stuff */
130 int macro_i; /* -1 if not recording index to macro[] otherwise */
131 struct macro macro[MAX_MACRO_LENGTH];
134 typedef struct editor_widget WEdit;
136 #define EDIT_DIR "/.cedit"
137 #define SYNTAX_FILE "/.cedit/Syntax"
138 #define CLIP_FILE "/.cedit/cooledit.clip"
139 #define MACRO_FILE "/.cedit/cooledit.macros"
140 #define BLOCK_FILE "/.cedit/cooledit.block"
141 #define ERROR_FILE "/.cedit/cooledit.error"
142 #define TEMP_FILE "/.cedit/cooledit.temp"
144 #endif