done some cleanup...
[midnight-commander.git] / edit / edit-widget.h
blob22ac6b956fab193635f88a8147e1678693951ec1
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 Widget widget;
41 #define from_here num_widget_lines
42 int num_widget_lines;
43 int num_widget_columns;
45 int have_frame;
47 char *filename; /* Name of the file */
48 char *dir; /* current directory */
50 /* dynamic buffers and cursor position for editor: */
51 long curs1; /*position of the cursor from the beginning of the file. */
52 long curs2; /*position from the end of the file */
53 unsigned char *buffers1[MAXBUFF + 1]; /*all data up to curs1 */
54 unsigned char *buffers2[MAXBUFF + 1]; /*all data from end of file down to curs2 */
56 /* search variables */
57 long search_start; /* First character to start searching from */
58 int found_len; /* Length of found string or 0 if none was found */
59 long found_start; /* the found word from a search - start position */
61 /* display information */
62 long last_byte; /* Last byte of file */
63 long start_display; /* First char displayed */
64 long start_col; /* First displayed column, negative */
65 long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
66 long curs_row; /*row position of cursor on the screen */
67 long curs_col; /*column position on screen */
68 int force; /* how much of the screen do we redraw? */
69 unsigned char overwrite;
70 unsigned char modified; /*has the file been changed?: 1 if char inserted or
71 deleted at all since last load or save */
72 unsigned char screen_modified; /* has the file been changed since the last screen draw? */
73 int delete_file; /* has the file been created in edit_load_file? Delete
74 it at end of editing when it hasn't been modified
75 or saved */
76 unsigned char highlight;
77 long prev_col; /*recent column position of the cursor - used when moving
78 up or down past lines that are shorter than the current line */
79 long curs_line; /*line number of the cursor. */
80 long start_line; /*line nummber of the top of the page */
82 /* file info */
83 long total_lines; /*total lines in the file */
84 long mark1; /*position of highlight start */
85 long mark2; /*position of highlight end */
86 int column1; /*position of column highlight start */
87 int column2; /*position of column highlight end */
88 long bracket; /*position of a matching bracket */
90 /* cache speedup for line lookups */
91 #define N_LINE_CACHES 32
92 int caches_valid;
93 int line_numbers[N_LINE_CACHES];
94 long line_offsets[N_LINE_CACHES];
96 struct _book_mark *book_mark;
98 /* undo stack and pointers */
99 unsigned long stack_pointer;
100 long *undo_stack;
101 unsigned long stack_size;
102 unsigned long stack_size_mask;
103 unsigned long stack_bottom;
104 struct stat stat1;
106 /* syntax higlighting */
107 struct _syntax_marker *syntax_marker;
108 struct context_rule **rules;
109 long last_get_rule;
110 struct syntax_rule rule;
111 char *syntax_type; /* description of syntax highlighting type being used */
112 int explicit_syntax; /* have we forced the syntax hi. type in spite of the filename? */
114 int to_here; /* dummy marker */
117 /* macro stuff */
118 int macro_i; /* -1 if not recording index to macro[] otherwise */
119 struct macro macro[MAX_MACRO_LENGTH];
122 typedef struct editor_widget WEdit;
124 #define EDIT_DIR PATH_SEP_STR ".mc" PATH_SEP_STR "cedit"
125 #define SYNTAX_FILE EDIT_DIR PATH_SEP_STR "Syntax"
126 #define CLIP_FILE EDIT_DIR PATH_SEP_STR "cooledit.clip"
127 #define MACRO_FILE EDIT_DIR PATH_SEP_STR "cooledit.macros"
128 #define BLOCK_FILE EDIT_DIR PATH_SEP_STR "cooledit.block"
129 #define TEMP_FILE EDIT_DIR PATH_SEP_STR "cooledit.temp"
131 #endif /* !__EDIT_WIDGET_H */