src/find.c: Micro fix for 'Skip hidden' shortcut
[kaloumi3.git] / edit / edit.h
blob3e5f5637e92f06b208fdb2039a4fc394766f9e92
1 /* edit.h - main include file
3 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
5 Authors: 1996, 1997 Paul Sheer
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, USA.
23 #ifndef MC_EDIT_H
24 #define MC_EDIT_H
26 #include <stdio.h>
28 #define N_menus 5
30 #define SEARCH_DIALOG_OPTION_NO_SCANF (1 << 0)
31 #define SEARCH_DIALOG_OPTION_NO_REGEX (1 << 1)
32 #define SEARCH_DIALOG_OPTION_NO_CASE (1 << 2)
33 #define SEARCH_DIALOG_OPTION_BACKWARDS (1 << 3)
34 #define SEARCH_DIALOG_OPTION_BOOKMARK (1 << 4)
36 #define EDIT_KEY_EMULATION_NORMAL 0
37 #define EDIT_KEY_EMULATION_EMACS 1
38 #define EDIT_KEY_EMULATION_USER 2
40 #define REDRAW_LINE (1 << 0)
41 #define REDRAW_LINE_ABOVE (1 << 1)
42 #define REDRAW_LINE_BELOW (1 << 2)
43 #define REDRAW_AFTER_CURSOR (1 << 3)
44 #define REDRAW_BEFORE_CURSOR (1 << 4)
45 #define REDRAW_PAGE (1 << 5)
46 #define REDRAW_IN_BOUNDS (1 << 6)
47 #define REDRAW_CHAR_ONLY (1 << 7)
48 #define REDRAW_COMPLETELY (1 << 8)
50 #define EDIT_TEXT_HORIZONTAL_OFFSET 0
51 #define EDIT_TEXT_VERTICAL_OFFSET 1
53 #define EDIT_RIGHT_EXTREME option_edit_right_extreme
54 #define EDIT_LEFT_EXTREME option_edit_left_extreme
55 #define EDIT_TOP_EXTREME option_edit_top_extreme
56 #define EDIT_BOTTOM_EXTREME option_edit_bottom_extreme
59 * The editor keeps data in two arrays of buffers.
60 * All buffers have the same size, which must be a power of 2.
63 /* Configurable: log2 of the buffer size in bytes */
64 #ifndef S_EDIT_BUF_SIZE
65 #define S_EDIT_BUF_SIZE 16
66 #endif
68 /* Size of the buffer */
69 #define EDIT_BUF_SIZE (((off_t) 1) << S_EDIT_BUF_SIZE)
71 /* Buffer mask (used to find cursor position relative to the buffer) */
72 #define M_EDIT_BUF_SIZE (EDIT_BUF_SIZE - 1)
75 * Configurable: Maximal allowed number of buffers in each buffer array.
76 * This number can be increased for systems with enough physical memory.
78 #ifndef MAXBUFF
79 #define MAXBUFF 1024
80 #endif
82 /* Maximal length of file that can be opened */
83 #define SIZE_LIMIT (EDIT_BUF_SIZE * (MAXBUFF - 2))
85 /* Initial size of the undo stack, in bytes */
86 #define START_STACK_SIZE 32
88 /* Some codes that may be pushed onto or returned from the undo stack */
89 #define CURS_LEFT 601
90 #define CURS_RIGHT 602
91 #define DELCHAR 603
92 #define BACKSPACE 604
93 #define STACK_BOTTOM 605
94 #define CURS_LEFT_LOTS 606
95 #define CURS_RIGHT_LOTS 607
96 #define COLUMN_ON 608
97 #define COLUMN_OFF 609
98 #define MARK_1 1000
99 #define MARK_2 700000000
100 #define KEY_PRESS 1400000000
102 /* Tabs spaces: (sofar only HALF_TAB_SIZE is used: */
103 #define TAB_SIZE option_tab_spacing
104 #define HALF_TAB_SIZE ((int) option_tab_spacing / 2)
106 struct macro {
107 short command;
108 short ch;
111 struct WEdit;
112 typedef struct WEdit WEdit;
113 struct Menu;
115 int edit_drop_hotkey_menu (WEdit *e, int key);
116 void edit_menu_cmd (WEdit *e);
117 struct WMenu *edit_init_menu (void);
118 void edit_done_menu (struct WMenu *wmenu);
119 void edit_reload_menu (void);
120 void menu_save_mode_cmd (void);
121 int edit_raw_key_query (const char *heading, const char *query, int cancel);
122 int edit_file (const char *_file, int line);
123 int edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch);
124 int edit_get_byte (WEdit * edit, long byte_index);
125 int edit_count_lines (WEdit * edit, long current, int upto);
126 long edit_move_forward (WEdit * edit, long current, int lines, long upto);
127 long edit_move_forward3 (WEdit * edit, long current, int cols, long upto);
128 long edit_move_backward (WEdit * edit, long current, int lines);
129 void edit_scroll_screen_over_cursor (WEdit * edit);
130 void edit_render_keypress (WEdit * edit);
131 void edit_scroll_upward (WEdit * edit, unsigned long i);
132 void edit_scroll_downward (WEdit * edit, int i);
133 void edit_scroll_right (WEdit * edit, int i);
134 void edit_scroll_left (WEdit * edit, int i);
135 void edit_move_up (WEdit * edit, unsigned long i, int scroll);
136 void edit_move_down (WEdit * edit, int i, int scroll);
137 void edit_move_to_prev_col (WEdit *edit, long p);
138 int edit_get_col (WEdit * edit);
139 long edit_bol (WEdit * edit, long current);
140 long edit_eol (WEdit * edit, long current);
141 void edit_update_curs_row (WEdit * edit);
142 void edit_update_curs_col (WEdit * edit);
143 void edit_find_bracket (WEdit * edit);
145 void edit_block_copy_cmd (WEdit * edit);
146 void edit_block_move_cmd (WEdit * edit);
147 int edit_block_delete_cmd (WEdit * edit);
148 void edit_delete_line (WEdit * edit);
150 int edit_delete (WEdit * edit);
151 void edit_insert (WEdit * edit, int c);
152 void edit_cursor_move (WEdit * edit, long increment);
153 void edit_push_action (WEdit * edit, long c, ...);
154 void edit_push_key_press (WEdit * edit);
155 void edit_insert_ahead (WEdit * edit, int c);
156 long edit_write_stream (WEdit * edit, FILE * f);
157 char *edit_get_write_filter (const char *writename, const char *filename);
158 int edit_save_confirm_cmd (WEdit * edit);
159 int edit_save_as_cmd (WEdit * edit);
160 WEdit *edit_init (WEdit *edit, int lines, int columns,
161 const char *filename, long line);
162 int edit_clean (WEdit * edit);
163 int edit_ok_to_exit (WEdit *edit);
164 int edit_renew (WEdit * edit);
165 int edit_new_cmd (WEdit * edit);
166 int edit_reload (WEdit *edit, const char *filename);
167 int edit_load_cmd (WEdit * edit);
168 void edit_mark_cmd (WEdit * edit, int unmark);
169 void edit_set_markers (WEdit * edit, long m1, long m2, int c1, int c2);
170 void edit_push_markers (WEdit * edit);
171 void edit_replace_cmd (WEdit * edit, int again);
172 void edit_search_cmd (WEdit * edit, int again);
173 void edit_complete_word_cmd (WEdit * edit);
174 int edit_save_block (WEdit * edit, const char *filename, long start, long finish);
175 int edit_save_block_cmd (WEdit * edit);
176 int edit_insert_file_cmd (WEdit * edit);
177 int edit_insert_file (WEdit * edit, const char *filename);
178 void edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block);
179 void freestrs (void);
180 void edit_refresh_cmd (WEdit * edit);
181 void edit_date_cmd (WEdit * edit);
182 void edit_goto_cmd (WEdit * edit);
183 int eval_marks (WEdit * edit, long *start_mark, long *end_mark);
184 void edit_status (WEdit * edit);
185 void edit_execute_key_command (WEdit *edit, int command,
186 int char_for_insertion);
187 void edit_update_screen (WEdit * edit);
188 int edit_print_string (WEdit * e, const char *s);
189 void edit_move_to_line (WEdit * e, long line);
190 void edit_move_display (WEdit * e, long line);
191 void edit_word_wrap (WEdit * edit);
192 int edit_sort_cmd (WEdit * edit);
193 int edit_ext_cmd (WEdit * edit);
194 void edit_help_cmd (WEdit * edit);
196 int edit_save_macro_cmd (WEdit * edit, struct macro macro[], int n);
197 int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k);
198 void edit_delete_macro_cmd (WEdit * edit);
200 int edit_copy_to_X_buf_cmd (WEdit * edit);
201 int edit_cut_to_X_buf_cmd (WEdit * edit);
202 void edit_paste_from_X_buf_cmd (WEdit * edit);
204 void edit_select_codepage_cmd (WEdit *edit);
205 void edit_insert_literal_cmd (WEdit *edit);
206 void edit_execute_macro_cmd (WEdit *edit);
207 void edit_begin_end_macro_cmd(WEdit *edit);
209 void edit_paste_from_history (WEdit *edit);
211 void edit_set_filename (WEdit *edit, const char *name);
213 void edit_load_syntax (WEdit * edit, char ***pnames, const char *type);
214 void edit_free_syntax_rules (WEdit * edit);
215 void edit_get_syntax_color (WEdit * edit, long byte_index, int *color);
218 void book_mark_insert (WEdit * edit, int line, int c);
219 int book_mark_query_color (WEdit * edit, int line, int c);
220 int book_mark_query_all (WEdit * edit, int line, int *c);
221 struct _book_mark *book_mark_find (WEdit * edit, int line);
222 int book_mark_clear (WEdit * edit, int line, int c);
223 void book_mark_flush (WEdit * edit, int c);
224 void book_mark_inc (WEdit * edit, int line);
225 void book_mark_dec (WEdit * edit, int line);
227 int line_is_blank (WEdit *edit, long line);
228 int edit_indent_width (WEdit *edit, long p);
229 void edit_insert_indent (WEdit *edit, int indent);
230 void edit_options_dialog (void);
231 void edit_syntax_dialog (void);
232 void edit_mail_dialog (WEdit *edit);
233 void format_paragraph (WEdit *edit, int force);
235 /* either command or char_for_insertion must be passed as -1 */
236 void edit_execute_cmd (WEdit *edit, int command, int char_for_insertion);
238 #define get_sys_error(s) (s)
240 #define edit_error_dialog(h,s) query_dialog (h, s, D_ERROR, 1, _("&Dismiss"))
242 #define edit_query_dialog2(h,t,a,b) query_dialog (h, t, D_NORMAL, 2, a, b)
243 #define edit_query_dialog3(h,t,a,b,c) query_dialog (h, t, D_NORMAL, 3, a, b, c)
245 #define color_palette(x) win->color[x].pixel
247 #define NUM_SELECTION_HISTORY 64
249 #ifndef MAX_PATH_LEN
250 #ifdef PATH_MAX
251 #define MAX_PATH_LEN PATH_MAX
252 #else
253 #define MAX_PATH_LEN 1024
254 #endif
255 #endif
258 what editor are we going to emulate? one of EDIT_KEY_EMULATION_NORMAL
259 or EDIT_KEY_EMULATION_EMACS
261 extern int edit_key_emulation;
263 extern WEdit *wedit;
264 struct WMenu;
265 extern struct WMenu *edit_menubar;
267 extern int option_word_wrap_line_length;
268 extern int option_typewriter_wrap;
269 extern int option_auto_para_formatting;
270 extern int option_tab_spacing;
271 extern int option_fill_tabs_with_spaces;
272 extern int option_return_does_auto_indent;
273 extern int option_backspace_through_tabs;
274 extern int option_fake_half_tabs;
276 typedef enum {
277 EDIT_QUICK_SAVE = 0,
278 EDIT_SAFE_SAVE,
279 EDIT_DO_BACKUP
280 } edit_save_mode_t;
282 extern int option_save_mode;
283 extern int option_save_position;
284 extern int option_max_undo;
285 extern int option_syntax_highlighting;
286 extern int option_auto_syntax;
287 extern char *option_syntax_type;
288 extern int editor_option_check_nl_at_eof;
290 extern int option_edit_right_extreme;
291 extern int option_edit_left_extreme;
292 extern int option_edit_top_extreme;
293 extern int option_edit_bottom_extreme;
295 extern const char *option_whole_chars_search;
296 extern char *option_backup_ext;
298 extern int edit_confirm_save;
299 extern int column_highlighting;
301 extern int visible_tabs;
302 extern int visible_tws;
304 /* File names */
305 #define EDIT_DIR ".mc" PATH_SEP_STR "cedit"
306 #define SYNTAX_FILE EDIT_DIR PATH_SEP_STR "Syntax"
307 #define CLIP_FILE EDIT_DIR PATH_SEP_STR "cooledit.clip"
308 #define MACRO_FILE EDIT_DIR PATH_SEP_STR "cooledit.macros"
309 #define BLOCK_FILE EDIT_DIR PATH_SEP_STR "cooledit.block"
310 #define TEMP_FILE EDIT_DIR PATH_SEP_STR "cooledit.temp"
312 #endif