Add Nano tool - user-friendly text editor
[tomato.git] / release / src / router / nano / src / global.c
blobae14a49fa024be886e6ab4d10a011b3ff2cfefbf
1 /* $Id: global.c 4520 2010-11-12 06:23:14Z astyanax $ */
2 /**************************************************************************
3 * global.c *
4 * *
5 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
6 * 2008, 2009 Free Software Foundation, Inc. *
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 3, or (at your option) *
10 * any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15 * General Public License for more details. *
16 * *
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 St, Fifth Floor, Boston, MA *
20 * 02110-1301, USA. *
21 * *
22 **************************************************************************/
24 #include "proto.h"
26 #include <ctype.h>
27 #include <string.h>
28 #include <strings.h>
29 #include "assert.h"
31 /* Global variables. */
32 #ifndef NANO_TINY
33 sigjmp_buf jump_buf;
34 /* Used to return to either main() or the unjustify routine in
35 * do_justify() after a SIGWINCH. */
36 bool jump_buf_main = FALSE;
37 /* Have we set jump_buf so that we return to main() after a
38 * SIGWINCH? */
39 #endif
41 #ifndef DISABLE_WRAPJUSTIFY
42 ssize_t fill = 0;
43 /* The column where we will wrap lines. */
44 ssize_t wrap_at = -CHARS_FROM_EOL;
45 /* The position where we will wrap lines. fill is equal to this
46 * if it's greater than zero, and equal to (COLS + this) if it
47 * isn't. */
48 #endif
50 char *last_search = NULL;
51 /* The last string we searched for. */
52 char *last_replace = NULL;
53 /* The last replacement string we searched for. */
55 unsigned flags[4] = {0, 0, 0, 0};
56 /* Our flag containing the states of all global options. */
57 WINDOW *topwin;
58 /* The top portion of the window, where we display the version
59 * number of nano, the name of the current file, and whether the
60 * current file has been modified. */
61 WINDOW *edit;
62 /* The middle portion of the window, i.e. the edit window, where
63 * we display the current file we're editing. */
64 WINDOW *bottomwin;
65 /* The bottom portion of the window, where we display statusbar
66 * messages, the statusbar prompt, and a list of shortcuts. */
67 int editwinrows = 0;
68 /* How many rows does the edit window take up? */
69 int maxrows = 0;
70 /* How many usable lines are there (due to soft wrapping) */
72 filestruct *cutbuffer = NULL;
73 /* The buffer where we store cut text. */
74 filestruct *cutbottom = NULL;
75 #ifndef DISABLE_JUSTIFY
76 filestruct *jusbuffer = NULL;
77 /* The buffer where we store unjustified text. */
78 #endif
79 partition *filepart = NULL;
80 /* The partition where we store a portion of the current
81 * file. */
82 openfilestruct *openfile = NULL;
83 /* The list of all open file buffers. */
85 #ifndef NANO_TINY
86 char *matchbrackets = NULL;
87 /* The opening and closing brackets that can be found by bracket
88 * searches. */
89 #endif
91 #if !defined(NANO_TINY) && defined(ENABLE_NANORC)
92 char *whitespace = NULL;
93 /* The characters used when displaying the first characters of
94 * tabs and spaces. */
95 int whitespace_len[2];
96 /* The length of these characters. */
97 #endif
99 #ifndef DISABLE_JUSTIFY
100 char *punct = NULL;
101 /* The closing punctuation that can end sentences. */
102 char *brackets = NULL;
103 /* The closing brackets that can follow closing punctuation and
104 * can end sentences. */
105 char *quotestr = NULL;
106 /* The quoting string. The default value is set in main(). */
107 #ifdef HAVE_REGEX_H
108 regex_t quotereg;
109 /* The compiled regular expression from the quoting string. */
110 int quoterc;
111 /* Whether it was compiled successfully. */
112 char *quoteerr = NULL;
113 /* The error message, if it didn't. */
114 #else
115 size_t quotelen;
116 /* The length of the quoting string in bytes. */
117 #endif
118 #endif
120 bool nodelay_mode = FALSE;
121 /* Are we in nodelay mode (checking for a cancel wile doing something */
123 char *answer = NULL;
124 /* The answer string used by the statusbar prompt. */
126 ssize_t tabsize = -1;
127 /* The width of a tab in spaces. The default value is set in
128 * main(). */
130 #ifndef NANO_TINY
131 char *backup_dir = NULL;
132 /* The directory where we store backup files. */
133 #endif
134 #ifndef DISABLE_OPERATINGDIR
135 char *operating_dir = NULL;
136 /* The relative path to the operating directory, which we can't
137 * move outside of. */
138 char *full_operating_dir = NULL;
139 /* The full path to it. */
140 #endif
142 #ifndef DISABLE_SPELLER
143 char *alt_speller = NULL;
144 /* The command to use for the alternate spell checker. */
145 #endif
147 #ifdef ENABLE_COLOR
148 syntaxtype *syntaxes = NULL;
149 /* The global list of color syntaxes. */
150 char *syntaxstr = NULL;
151 /* The color syntax name specified on the command line. */
153 #endif
155 bool edit_refresh_needed = NULL;
156 /* Did a command mangle enough of the buffer refresh that we
157 should repaint the screen */
159 const shortcut *currshortcut;
160 /* The current shortcut list we're using. */
161 int currmenu;
162 /* The currently loaded menu */
164 sc *sclist = NULL;
165 /* New shortcut key struct */
166 subnfunc *allfuncs = NULL;
167 /* New struct for the function list */
169 #ifndef NANO_TINY
170 filestruct *search_history = NULL;
171 /* The search string history list. */
172 filestruct *searchage = NULL;
173 /* The top of the search string history list. */
174 filestruct *searchbot = NULL;
175 /* The bottom of the search string history list. */
176 filestruct *replace_history = NULL;
177 /* The replace string history list. */
178 filestruct *replaceage = NULL;
179 /* The top of the replace string history list. */
180 filestruct *replacebot = NULL;
181 /* The bottom of the replace string history list. */
182 #endif
184 /* Regular expressions. */
185 #ifdef HAVE_REGEX_H
186 regex_t search_regexp;
187 /* The compiled regular expression to use in searches. */
188 regmatch_t regmatches[10];
189 /* The match positions for parenthetical subexpressions, 10
190 * maximum, used in regular expression searches. */
191 #endif
193 int reverse_attr = A_REVERSE;
194 /* The curses attribute we use for reverse video. */
196 char *homedir = NULL;
197 /* The user's home directory, from $HOME or /etc/passwd. */
199 /* Return the number of entries in the shortcut list s for a given menu. */
200 size_t length_of_list(int menu)
202 subnfunc *f;
203 size_t i = 0;
205 for (f = allfuncs; f != NULL; f = f->next)
206 if ((f->menus & menu) != 0
207 #ifndef DISABLE_HELP
208 && strlen(f->help) > 0
209 #endif
211 i++;
213 return i;
216 /* Set type of function based on the string */
217 function_type strtokeytype(const char *str)
219 if (str[0] == 'M' || str[0] == 'm')
220 return META;
221 else if (str[0] == '^')
222 return CONTROL;
223 else if (str[0] == 'F' || str[0] == 'F')
224 return FKEY;
225 else
226 return RAW;
229 /* Add a string to the new function list strict.
230 Does not allow updates, yet anyway */
231 void add_to_funcs(short func, int menus, const char *desc, const char *help,
232 bool blank_after, bool viewok)
234 subnfunc *f;
236 if (allfuncs == NULL) {
237 allfuncs = (subnfunc *) nmalloc(sizeof(subnfunc));
238 f = allfuncs;
239 } else {
240 for (f = allfuncs; f->next != NULL; f = f->next)
242 f->next = (subnfunc *)nmalloc(sizeof(subnfunc));
243 f = f->next;
245 f->next = NULL;
246 f->scfunc = func;
247 f->menus = menus;
248 f->desc = desc;
249 f->viewok = viewok;
250 #ifndef DISABLE_HELP
251 f->help = help;
252 f->blank_after = blank_after;
253 #endif
255 #ifdef DEBUG
256 fprintf(stderr, "Added func \"%s\"", f->desc);
257 #endif
260 const sc *first_sc_for(int menu, short func) {
261 const sc *s;
262 const sc *metasc = NULL;
264 for (s = sclist; s != NULL; s = s->next) {
265 if ((s->menu & menu) && s->scfunc == func) {
266 /* try to use a meta sequence as a last resort. Otherwise
267 we will run into problems when we try and handle things like
268 the arrow keys, home, etc, if for some reason the user bound
269 them to a meta sequence first *shrug* */
270 if (s->type == META) {
271 metasc = s;
272 continue;
273 } /* otherwise it was something else, use it */
274 return s;
278 /* If we're here we may have found only meta sequences, if so use one */
279 if (metasc)
280 return metasc;
282 #ifdef DEBUG
283 fprintf(stderr, "Whoops, returning null given func %ld in menu %d\n", (long) func, menu);
284 #endif
285 /* Otherwise... */
286 return NULL;
290 /* Add a string to the new shortcut list implementation
291 Allows updates to existing entries in the list */
292 void add_to_sclist(int menu, const char *scstring, short func, int toggle, int execute)
294 sc *s;
296 if (sclist == NULL) {
297 sclist = (sc *) nmalloc(sizeof(sc));
298 s = sclist;
299 s->next = NULL;
300 } else {
301 for (s = sclist; s->next != NULL; s = s->next)
302 if (s->menu == menu && s->keystr == scstring)
303 break;
305 if (s->menu != menu || s->keystr != scstring) { /* i.e. this is not a replace... */
306 #ifdef DEBUG
307 fprintf(stderr, "No match found...\n");
308 #endif
309 s->next = (sc *)nmalloc(sizeof(sc));
310 s = s->next;
311 s->next = NULL;
315 s->type = strtokeytype(scstring);
316 s->menu = menu;
317 s->toggle = toggle;
318 s->keystr = (char *) scstring;
319 s->scfunc = func;
320 s->execute = execute;
321 assign_keyinfo(s);
323 #ifdef DEBUG
324 fprintf(stderr, "list val = %d\n", (int) s->menu);
325 fprintf(stderr, "Hey, set sequence to %d for shortcut \"%s\"\n", s->seq, scstring);
326 #endif
329 /* Return the given menu's first shortcut sequence, or the default value
330 (2nd arg). Assumes currmenu for the menu to check*/
331 int sc_seq_or (short func, int defaultval)
333 const sc *s = first_sc_for(currmenu, func);
335 if (s)
336 return s->seq;
337 /* else */
338 return defaultval;
342 /* Assign the info to the shortcut struct
343 Assumes keystr is already assigned, naturally */
344 void assign_keyinfo(sc *s)
346 if (s->type == CONTROL) {
347 assert(strlen(s->keystr) > 1);
348 s->seq = s->keystr[1] - 64;
349 } else if (s->type == META) {
350 assert(strlen(s->keystr) > 2);
351 s->seq = tolower((int) s->keystr[2]);
352 } else if (s->type == FKEY) {
353 assert(strlen(s->keystr) > 1);
354 s->seq = KEY_F0 + atoi(&s->keystr[1]);
355 } else /* raw */
356 s->seq = (int) s->keystr[0];
358 /* Override some keys which don't bind as nicely as we'd like */
359 if (s->type == CONTROL && (!strcasecmp(&s->keystr[1], "space")))
360 s->seq = 0;
361 else if (s->type == META && (!strcasecmp(&s->keystr[2], "space")))
362 s->seq = (int) ' ';
363 else if (s->type == RAW && (!strcasecmp(s->keystr, "kup")))
364 s->seq = KEY_UP;
365 else if (s->type == RAW && (!strcasecmp(s->keystr, "kdown")))
366 s->seq = KEY_DOWN;
367 else if (s->type == RAW && (!strcasecmp(s->keystr, "kleft")))
368 s->seq = KEY_LEFT;
369 else if (s->type == RAW && (!strcasecmp(s->keystr, "kright")))
370 s->seq = KEY_RIGHT;
371 else if (s->type == RAW && (!strcasecmp(s->keystr, "kinsert")))
372 s->seq = KEY_IC;
373 else if (s->type == RAW && (!strcasecmp(s->keystr, "kdel")))
374 s->seq = KEY_DC;
375 else if (s->type == RAW && (!strcasecmp(s->keystr, "kbsp")))
376 s->seq = KEY_BACKSPACE;
377 else if (s->type == RAW && (!strcasecmp(s->keystr, "kenter")))
378 s->seq = KEY_ENTER;
379 else if (s->type == RAW && (!strcasecmp(s->keystr, "kpup")))
380 s->seq = KEY_PPAGE;
381 else if (s->type == RAW && (!strcasecmp(s->keystr, "kpdown")))
382 s->seq = KEY_NPAGE;
383 #ifdef KEY_HOME
384 else if (s->type == RAW && (!strcasecmp(s->keystr, "khome")))
385 s->seq = KEY_HOME;
386 #endif
387 #ifdef KEY_END
388 else if (s->type == RAW && (!strcasecmp(s->keystr, "kend")))
389 s->seq = KEY_END;
390 #endif
394 #ifdef DEBUG
396 void print_sclist(void)
398 sc *s;
399 const subnfunc *f;
401 for (s = sclist; s->next != NULL; s = s->next) {
402 f = sctofunc(s);
403 if (f)
404 fprintf(stderr, "Shortcut \"%s\", function: %s, menus %d\n", s->keystr, f->desc, f->menus);
405 else
406 fprintf(stderr, "Hmm, didnt find a func for \"%s\"\n", s->keystr);
410 #endif
413 /* Stuff we need to make at least static here so we can access it below */
414 /* TRANSLATORS: Try to keep the next five strings at most 10 characters. */
415 const char *cancel_msg = N_("Cancel");
416 const char *replace_msg = N_("Replace");
417 const char *no_replace_msg = N_("No Replace");
419 #ifndef NANO_TINY
420 const char *case_sens_msg = N_("Case Sens");
421 const char *backwards_msg = N_("Backwards");
422 #endif
424 #ifdef HAVE_REGEX_H
425 const char *regexp_msg = N_("Regexp");
426 #endif
428 /* Stuff we want to just stun out if we're in TINY mode */
429 #ifdef NANO_TINY
430 const char *gototext_msg = "";
431 const char *do_para_begin_msg = "";
432 const char *do_para_end_msg = "";
433 const char *case_sens_msg = "";
434 const char *backwards_msg = "";
435 const char *do_cut_till_end = "";
436 const char *dos_format_msg = "";
437 const char *mac_format_msg = "";
438 const char *append_msg = "";
439 const char *prepend_msg = "";
440 const char *backup_file_msg = "";
441 const char *to_files_msg = "";
442 const char *first_file_msg = "";
443 const char *whereis_next_msg = "";
444 const char *last_file_msg = "";
445 const char *new_buffer_msg = "";
446 const char *goto_dir_msg;
447 const char *ext_cmd_msg = "";
449 #else
450 /* TRANSLATORS: Try to keep the next five strings at most 10 characters. */
451 const char *prev_history_msg = N_("PrevHstory");
452 const char *next_history_msg = N_("NextHstory");
453 const char *gototext_msg = N_("Go To Text");
454 /* TRANSLATORS: Try to keep the next three strings at most 12 characters. */
455 const char *whereis_next_msg = N_("WhereIs Next");
456 #ifndef DISABLE_BROWSER
457 const char *first_file_msg = N_("First File");
458 const char *last_file_msg = N_("Last File");
459 /* TRANSLATORS: Try to keep the next nine strings at most 16 characters. */
460 const char *to_files_msg = N_("To Files");
461 #endif
462 const char *dos_format_msg = N_("DOS Format");
463 const char *mac_format_msg = N_("Mac Format");
464 const char *append_msg = N_("Append");
465 const char *prepend_msg = N_("Prepend");
466 const char *backup_file_msg = N_("Backup File");
467 const char *ext_cmd_msg = N_("Execute Command");
468 #ifdef ENABLE_MULTIBUFFER
469 const char *new_buffer_msg = N_("New Buffer");
470 #endif
471 const char *goto_dir_msg = N_("Go To Dir");
473 #endif /* NANO_TINY */
475 /* Initialize all shortcut lists. If unjustify is TRUE, replace the
476 * Uncut shortcut in the main shortcut list with UnJustify. */
477 void shortcut_init(bool unjustify)
479 /* TRANSLATORS: Try to keep the following strings at most 10 characters. */
480 const char *get_help_msg = N_("Get Help");
481 const char *exit_msg = N_("Exit");
482 const char *whereis_msg = N_("Where Is");
483 const char *prev_page_msg = N_("Prev Page");
484 const char *next_page_msg = N_("Next Page");
485 const char *first_line_msg = N_("First Line");
486 const char *last_line_msg = N_("Last Line");
487 const char *suspend_msg = N_("Suspend");
488 #ifndef DISABLE_JUSTIFY
489 const char *beg_of_par_msg = N_("Beg of Par");
490 const char *end_of_par_msg = N_("End of Par");
491 const char *fulljstify_msg = N_("FullJstify");
492 #endif
493 const char *refresh_msg = N_("Refresh");
494 #ifndef NANO_TINY
495 const char *insert_file_msg = N_("Insert File");
496 #endif
497 const char *go_to_line_msg = N_("Go To Line");
499 #ifndef DISABLE_JUSTIFY
500 const char *nano_justify_msg = N_("Justify the current paragraph");
501 #endif
502 #ifndef DISABLE_HELP
503 /* TRANSLATORS: The next long series of strings are shortcut descriptions;
504 * they are best kept shorter than 56 characters, but may be longer. */
505 const char *nano_cancel_msg = N_("Cancel the current function");
506 const char *nano_help_msg = N_("Display this help text");
507 const char *nano_exit_msg =
508 #ifdef ENABLE_MULTIBUFFER
509 N_("Close the current file buffer / Exit from nano")
510 #else
511 N_("Exit from nano")
512 #endif
514 const char *nano_writeout_msg =
515 N_("Write the current file to disk");
516 const char *nano_insert_msg =
517 N_("Insert another file into the current one");
518 const char *nano_whereis_msg =
519 N_("Search for a string or a regular expression");
520 const char *nano_prevpage_msg = N_("Go to previous screen");
521 const char *nano_nextpage_msg = N_("Go to next screen");
522 const char *nano_cut_msg =
523 N_("Cut the current line and store it in the cutbuffer");
524 const char *nano_uncut_msg =
525 N_("Uncut from the cutbuffer into the current line");
526 const char *nano_cursorpos_msg =
527 N_("Display the position of the cursor");
528 const char *nano_spell_msg =
529 N_("Invoke the spell checker, if available");
530 const char *nano_replace_msg =
531 N_("Replace a string or a regular expression");
532 const char *nano_gotoline_msg = N_("Go to line and column number");
533 #ifndef NANO_TINY
534 const char *nano_mark_msg = N_("Mark text at the cursor position");
535 const char *nano_whereis_next_msg = N_("Repeat last search");
536 const char *nano_copy_msg =
537 N_("Copy the current line and store it in the cutbuffer");
538 const char *nano_indent_msg = N_("Indent the current line");
539 const char *nano_unindent_msg = N_("Unindent the current line");
540 const char *nano_undo_msg = N_("Undo the last operation");
541 const char *nano_redo_msg = N_("Redo the last undone operation");
542 #endif
543 const char *nano_forward_msg = N_("Go forward one character");
544 const char *nano_back_msg = N_("Go back one character");
545 #ifndef NANO_TINY
546 const char *nano_nextword_msg = N_("Go forward one word");
547 const char *nano_prevword_msg = N_("Go back one word");
548 #endif
549 const char *nano_prevline_msg = N_("Go to previous line");
550 const char *nano_nextline_msg = N_("Go to next line");
551 const char *nano_home_msg = N_("Go to beginning of current line");
552 const char *nano_end_msg = N_("Go to end of current line");
553 #ifndef DISABLE_JUSTIFY
554 const char *nano_parabegin_msg =
555 N_("Go to beginning of paragraph; then of previous paragraph");
556 const char *nano_paraend_msg =
557 N_("Go just beyond end of paragraph; then of next paragraph");
558 #endif
559 const char *nano_firstline_msg =
560 N_("Go to the first line of the file");
561 const char *nano_lastline_msg =
562 N_("Go to the last line of the file");
563 #ifndef NANO_TINY
564 const char *nano_bracket_msg = N_("Go to the matching bracket");
565 const char *nano_scrollup_msg =
566 N_("Scroll up one line without scrolling the cursor");
567 const char *nano_scrolldown_msg =
568 N_("Scroll down one line without scrolling the cursor");
569 #endif
570 #ifdef ENABLE_MULTIBUFFER
571 const char *nano_prevfile_msg =
572 N_("Switch to the previous file buffer");
573 const char *nano_nextfile_msg =
574 N_("Switch to the next file buffer");
575 #endif
576 const char *nano_verbatim_msg =
577 N_("Insert the next keystroke verbatim");
578 const char *nano_tab_msg =
579 N_("Insert a tab at the cursor position");
580 const char *nano_enter_msg =
581 N_("Insert a newline at the cursor position");
582 const char *nano_delete_msg =
583 N_("Delete the character under the cursor");
584 const char *nano_backspace_msg =
585 N_("Delete the character to the left of the cursor");
586 #ifndef NANO_TINY
587 const char *nano_cut_till_end_msg =
588 N_("Cut from the cursor position to the end of the file");
589 #endif
590 #ifndef DISABLE_JUSTIFY
591 const char *nano_fulljustify_msg = N_("Justify the entire file");
592 #endif
593 #ifndef NANO_TINY
594 const char *nano_wordcount_msg =
595 N_("Count the number of words, lines, and characters");
596 #endif
597 const char *nano_refresh_msg =
598 N_("Refresh (redraw) the current screen");
599 const char *nano_suspend_msg =
600 N_("Suspend the editor (if suspend is enabled)");
601 #ifndef NANO_TINY
602 const char *nano_case_msg =
603 N_("Toggle the case sensitivity of the search");
604 const char *nano_reverse_msg =
605 N_("Reverse the direction of the search");
606 #endif
607 #ifdef HAVE_REGEX_H
608 const char *nano_regexp_msg =
609 N_("Toggle the use of regular expressions");
610 #endif
611 #ifndef NANO_TINY
612 const char *nano_prev_history_msg =
613 N_("Recall the previous search/replace string");
614 const char *nano_next_history_msg =
615 N_("Recall the next search/replace string");
616 #endif
617 #ifndef DISABLE_BROWSER
618 const char *nano_tofiles_msg = N_("Go to file browser");
619 #endif
620 #ifndef NANO_TINY
621 const char *nano_dos_msg = N_("Toggle the use of DOS format");
622 const char *nano_mac_msg = N_("Toggle the use of Mac format");
623 #endif
624 const char *nano_append_msg = N_("Toggle appending");
625 const char *nano_prepend_msg = N_("Toggle prepending");
626 #ifndef NANO_TINY
627 const char *nano_backup_msg =
628 N_("Toggle backing up of the original file");
629 const char *nano_execute_msg = N_("Execute external command");
630 #endif
631 #if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
632 const char *nano_multibuffer_msg =
633 N_("Toggle the use of a new buffer");
634 #endif
635 #ifndef DISABLE_BROWSER
636 const char *nano_exitbrowser_msg = N_("Exit from the file browser");
637 const char *nano_firstfile_msg =
638 N_("Go to the first file in the list");
639 const char *nano_lastfile_msg =
640 N_("Go to the last file in the list");
641 const char *nano_forwardfile_msg = N_("Go to the next file in the list");
642 const char *nano_backfile_msg = N_("Go to the previous file in the list");
643 const char *nano_gotodir_msg = N_("Go to directory");
644 #endif
645 #endif /* !DISABLE_HELP */
647 #ifndef DISABLE_HELP
648 #define IFSCHELP(help) help
649 #else
650 #define IFSCHELP(help) ""
651 #endif
653 while (allfuncs != NULL) {
654 subnfunc *f = allfuncs;
655 allfuncs = (allfuncs)->next;
656 free(f);
659 add_to_funcs(DO_HELP_VOID,
660 (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MBROWSER|MWHEREISFILE|MGOTODIR),
661 get_help_msg, IFSCHELP(nano_help_msg), FALSE, VIEW);
663 add_to_funcs( CANCEL_MSG,
664 (MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR|MYESNO),
665 cancel_msg, IFSCHELP(nano_cancel_msg), FALSE, VIEW);
667 add_to_funcs(DO_EXIT, MMAIN,
668 #ifdef ENABLE_MULTIBUFFER
669 /* TRANSLATORS: Try to keep this at most 10 characters. */
670 openfile != NULL && openfile != openfile->next ? N_("Close") :
671 #endif
672 exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW);
674 #ifndef DISABLE_BROWSER
675 add_to_funcs(DO_EXIT, MBROWSER, exit_msg, IFSCHELP(nano_exitbrowser_msg), FALSE, VIEW);
676 #endif
678 /* TRANSLATORS: Try to keep this at most 10 characters. */
679 add_to_funcs(DO_WRITEOUT_VOID, MMAIN, N_("WriteOut"),
680 IFSCHELP(nano_writeout_msg), FALSE, NOVIEW);
682 #ifndef DISABLE_JUSTIFY
683 /* TRANSLATORS: Try to keep this at most 10 characters. */
684 add_to_funcs(DO_JUSTIFY_VOID, MMAIN, N_("Justify"),
685 nano_justify_msg, TRUE, NOVIEW);
686 #endif
688 /* We allow inserting files in view mode if multibuffers are
689 * available, so that we can view multiple files. If we're using
690 * restricted mode, inserting files is disabled, since it allows
691 * reading from or writing to files not specified on the command
692 * line. */
694 add_to_funcs(DO_INSERTFILE_VOID,
695 /* TRANSLATORS: Try to keep this at most 10 characters. */
696 MMAIN, N_("Read File"), IFSCHELP(nano_insert_msg), FALSE,
697 #ifdef ENABLE_MULTIBUFFER
698 VIEW);
699 #else
700 NOVIEW);
701 #endif
703 add_to_funcs(DO_SEARCH, MMAIN|MBROWSER, whereis_msg,
704 IFSCHELP(nano_whereis_msg), FALSE, VIEW);
706 add_to_funcs(DO_PAGE_UP, MMAIN|MHELP|MBROWSER,
707 prev_page_msg, IFSCHELP(nano_prevpage_msg), FALSE, VIEW);
708 add_to_funcs(DO_PAGE_DOWN, MMAIN|MHELP|MBROWSER,
709 next_page_msg, IFSCHELP(nano_nextpage_msg), TRUE, VIEW);
712 /* TRANSLATORS: Try to keep this at most 10 characters. */
713 add_to_funcs(DO_CUT_TEXT_VOID, MMAIN, N_("Cut Text"), IFSCHELP(nano_cut_msg),
714 FALSE, NOVIEW);
716 if (unjustify)
717 /* TRANSLATORS: Try to keep this at most 10 characters. */
718 add_to_funcs(DO_UNCUT_TEXT, MMAIN, N_("UnJustify"), "",
719 FALSE, NOVIEW);
721 else
722 /* TRANSLATORS: Try to keep this at most 10 characters. */
723 add_to_funcs(DO_UNCUT_TEXT, MMAIN, N_("UnCut Text"), IFSCHELP(nano_uncut_msg),
724 FALSE, NOVIEW);
726 #ifndef NANO_TINY
727 /* TRANSLATORS: Try to keep this at most 10 characters. */
728 add_to_funcs(DO_CURSORPOS_VOID, MMAIN, N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg),
729 FALSE, VIEW);
730 #endif
732 /* If we're using restricted mode, spell checking is disabled
733 * because it allows reading from or writing to files not specified
734 * on the command line. */
735 #ifndef DISABLE_SPELLER
736 /* TRANSLATORS: Try to keep this at most 10 characters. */
737 add_to_funcs(DO_SPELL, MMAIN, N_("To Spell"), IFSCHELP(nano_spell_msg),
738 TRUE, NOVIEW);
739 #endif
741 add_to_funcs(DO_FIRST_LINE,
742 (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE),
743 first_line_msg, IFSCHELP(nano_firstline_msg), FALSE, VIEW);
745 add_to_funcs(DO_LAST_LINE,
746 (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE),
747 last_line_msg, IFSCHELP(nano_lastline_msg), TRUE, VIEW);
750 add_to_funcs(DO_GOTOLINECOLUMN_VOID, (MMAIN|MWHEREIS),
751 go_to_line_msg, IFSCHELP(nano_gotoline_msg), FALSE, VIEW);
753 #ifdef NANO_TINY
754 /* TRANSLATORS: Try to keep this at most 10 characters. */
755 add_to_funcs(DO_CURSORPOS_VOID, MMAIN, N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg),
756 FALSE, VIEW);
757 #endif
760 add_to_funcs(DO_REPLACE, (MMAIN|MWHEREIS), replace_msg, IFSCHELP(nano_replace_msg),
762 #ifndef NANO_TINY
763 FALSE,
764 #else
765 TRUE,
766 #endif
767 NOVIEW);
769 #ifndef NANO_TINY
771 add_to_funcs(DO_MARK, MMAIN, N_("Mark Text"),
772 IFSCHELP(nano_mark_msg), FALSE, VIEW);
774 add_to_funcs(DO_RESEARCH, (MMAIN|MBROWSER), whereis_next_msg,
775 IFSCHELP(nano_whereis_next_msg), TRUE, VIEW);
777 add_to_funcs(DO_COPY_TEXT, MMAIN, N_("Copy Text"),
778 IFSCHELP(nano_copy_msg), FALSE, NOVIEW);
780 add_to_funcs(DO_INDENT_VOID, MMAIN, N_("Indent Text"),
781 IFSCHELP(nano_indent_msg), FALSE, NOVIEW);
783 add_to_funcs(DO_UNINDENT, MMAIN, N_("Unindent Text"),
784 IFSCHELP(nano_unindent_msg), FALSE, NOVIEW);
786 if (ISSET(UNDOABLE)) {
787 add_to_funcs(DO_UNDO, MMAIN, N_("Undo"),
788 IFSCHELP(nano_undo_msg), FALSE, NOVIEW);
790 add_to_funcs(DO_REDO, MMAIN, N_("Redo"),
791 IFSCHELP(nano_redo_msg), TRUE, NOVIEW);
794 #endif
796 add_to_funcs(DO_RIGHT, MMAIN, N_("Forward"), IFSCHELP(nano_forward_msg),
797 FALSE, VIEW);
799 #ifndef DISABLE_BROWSER
800 add_to_funcs(DO_RIGHT, MBROWSER, N_("Forward"), IFSCHELP(nano_forwardfile_msg),
801 FALSE, VIEW);
802 #endif
804 add_to_funcs(DO_RIGHT, MALL, "", "", FALSE, VIEW);
806 add_to_funcs(DO_LEFT, MMAIN, N_("Back"), IFSCHELP(nano_back_msg),
807 FALSE, VIEW);
809 #ifndef DISABLE_BROWSER
810 add_to_funcs(DO_LEFT, MBROWSER, N_("Back"), IFSCHELP(nano_backfile_msg),
811 FALSE, VIEW);
812 #endif
814 add_to_funcs(DO_LEFT, MALL, "", "", FALSE, VIEW);
816 #ifndef NANO_TINY
817 add_to_funcs(DO_NEXT_WORD_VOID, MMAIN, N_("Next Word"),
818 IFSCHELP(nano_nextword_msg), FALSE, VIEW);
820 add_to_funcs(DO_PREV_WORD_VOID, MMAIN, N_("Prev Word"),
821 IFSCHELP(nano_prevword_msg), FALSE, VIEW);
822 #endif
824 add_to_funcs(DO_UP_VOID, (MMAIN|MHELP|MBROWSER), N_("Prev Line"),
825 IFSCHELP(nano_prevline_msg), FALSE, VIEW);
827 add_to_funcs(DO_DOWN_VOID, (MMAIN|MHELP|MBROWSER), N_("Next Line"),
828 IFSCHELP(nano_nextline_msg), TRUE, VIEW);
830 add_to_funcs(DO_HOME, MMAIN, N_("Home"), IFSCHELP(nano_home_msg),
831 FALSE, VIEW);
833 add_to_funcs(DO_END, MMAIN, N_("End"), IFSCHELP(nano_end_msg),
834 FALSE, VIEW);
836 #ifndef DISABLE_JUSTIFY
837 add_to_funcs(DO_PARA_BEGIN_VOID, (MMAIN|MWHEREIS), beg_of_par_msg,
838 IFSCHELP(nano_parabegin_msg), FALSE, VIEW);
840 add_to_funcs(DO_PARA_END_VOID, (MMAIN|MWHEREIS), end_of_par_msg,
841 IFSCHELP(nano_paraend_msg), FALSE, VIEW);
842 #endif
844 #ifndef NANO_TINY
845 add_to_funcs(DO_FIND_BRACKET, MMAIN, _("Find Other Bracket"),
846 IFSCHELP(nano_bracket_msg), FALSE, VIEW);
848 add_to_funcs(DO_SCROLL_UP, MMAIN, N_("Scroll Up"),
849 IFSCHELP(nano_scrollup_msg), FALSE, VIEW);
851 add_to_funcs(DO_SCROLL_DOWN, MMAIN, N_("Scroll Down"),
852 IFSCHELP(nano_scrolldown_msg), FALSE, VIEW);
853 #endif
855 #ifdef ENABLE_MULTIBUFFER
856 add_to_funcs(SWITCH_TO_PREV_BUFFER_VOID, MMAIN, _("Previous File"),
857 IFSCHELP(nano_prevfile_msg), FALSE, VIEW);
858 add_to_funcs(SWITCH_TO_NEXT_BUFFER_VOID, MMAIN, N_("Next File"),
859 IFSCHELP(nano_nextfile_msg), TRUE, VIEW);
860 #endif
862 add_to_funcs(DO_VERBATIM_INPUT, MMAIN, N_("Verbatim Input"),
863 IFSCHELP(nano_verbatim_msg), FALSE, NOVIEW);
864 add_to_funcs(DO_VERBATIM_INPUT, MWHEREIS|MREPLACE|MREPLACE2|MEXTCMD|MSPELL,
865 "", "", FALSE, NOVIEW);
867 add_to_funcs(DO_TAB, MMAIN, N_("Tab"), IFSCHELP(nano_tab_msg),
868 FALSE, NOVIEW);
869 add_to_funcs(DO_TAB, MALL, "", "", FALSE, NOVIEW);
870 add_to_funcs(DO_ENTER, MMAIN, N_("Enter"), IFSCHELP(nano_enter_msg),
871 FALSE, NOVIEW);
872 add_to_funcs(DO_ENTER, MALL, "", "", FALSE, NOVIEW);
873 add_to_funcs(DO_DELETE, MMAIN, N_("Delete"), IFSCHELP(nano_delete_msg),
874 FALSE, NOVIEW);
875 add_to_funcs(DO_DELETE, MALL, "", "", FALSE, NOVIEW);
876 add_to_funcs(DO_BACKSPACE, MMAIN, N_("Backspace"), IFSCHELP(nano_backspace_msg),
877 #ifndef NANO_TINY
878 FALSE,
879 #else
880 TRUE,
881 #endif
882 NOVIEW);
884 add_to_funcs(DO_BACKSPACE, MALL, "", "",
885 #ifndef NANO_TINY
886 FALSE,
887 #else
888 TRUE,
889 #endif
890 NOVIEW);
892 #ifndef NANO_TINY
893 add_to_funcs(DO_CUT_TILL_END, MMAIN, N_("CutTillEnd"),
894 IFSCHELP(nano_cut_till_end_msg), TRUE, NOVIEW);
895 #endif
897 add_to_funcs(XON_COMPLAINT, MMAIN, "", "", FALSE, VIEW);
898 add_to_funcs(XOFF_COMPLAINT, MMAIN, "", "", FALSE, VIEW);
900 #ifndef DISABLE_JUSTIFY
901 add_to_funcs(DO_FULL_JUSTIFY, (MMAIN|MWHEREIS), fulljstify_msg,
902 IFSCHELP(nano_fulljustify_msg), FALSE, NOVIEW);
903 #endif
905 #ifndef NANO_TINY
906 add_to_funcs(DO_WORDLINECHAR_COUNT, MMAIN, N_("Word Count"),
907 IFSCHELP(nano_wordcount_msg), FALSE, VIEW);
908 #endif
910 add_to_funcs(TOTAL_REFRESH, (MMAIN|MHELP), refresh_msg,
911 IFSCHELP(nano_refresh_msg), FALSE, VIEW);
913 add_to_funcs(DO_SUSPEND_VOID, MMAIN, suspend_msg,
914 IFSCHELP(nano_suspend_msg), TRUE, VIEW);
916 #ifndef NANO_TINY
917 add_to_funcs( CASE_SENS_MSG,
918 (MWHEREIS|MREPLACE|MWHEREISFILE),
919 case_sens_msg, IFSCHELP(nano_case_msg), FALSE, VIEW);
921 add_to_funcs( BACKWARDS_MSG,
922 (MWHEREIS|MREPLACE|MWHEREISFILE),
923 backwards_msg, IFSCHELP(nano_reverse_msg), FALSE, VIEW);
924 #endif
926 #ifdef HAVE_REGEX_H
927 add_to_funcs( REGEXP_MSG,
928 (MWHEREIS|MREPLACE|MWHEREISFILE),
929 regexp_msg, IFSCHELP(nano_regexp_msg), FALSE, VIEW);
930 #endif
932 #ifndef NANO_TINY
933 add_to_funcs( PREV_HISTORY_MSG,
934 (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE),
935 prev_history_msg, IFSCHELP(nano_prev_history_msg), FALSE, VIEW);
937 add_to_funcs( NEXT_HISTORY_MSG,
938 (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE),
939 next_history_msg, IFSCHELP(nano_next_history_msg), FALSE, VIEW);
940 #endif
942 add_to_funcs( NO_REPLACE_MSG, MREPLACE,
943 no_replace_msg, IFSCHELP(nano_whereis_msg), FALSE, VIEW);
945 add_to_funcs( GOTOTEXT_MSG, MGOTOLINE,
946 gototext_msg, IFSCHELP(nano_whereis_msg), TRUE, VIEW);
948 #ifndef DISABLE_BROWSER
949 if (!ISSET(RESTRICTED))
950 add_to_funcs( TO_FILES_MSG,
951 (MGOTOLINE|MINSERTFILE),
952 to_files_msg, IFSCHELP(nano_tofiles_msg), FALSE, VIEW);
953 #endif
955 #ifndef NANO_TINY
956 /* If we're using restricted mode, the DOS format, Mac format,
957 * append, prepend, and backup toggles are disabled. The first and
958 * second are useless since inserting files is disabled, the third
959 * and fourth are disabled because they allow writing to files not
960 * specified on the command line, and the fifth is useless since
961 * backups are disabled. */
962 if (!ISSET(RESTRICTED))
963 add_to_funcs( DOS_FORMAT_MSG, MWRITEFILE,
964 dos_format_msg, IFSCHELP(nano_dos_msg), FALSE, NOVIEW);
966 if (!ISSET(RESTRICTED))
967 add_to_funcs( MAC_FORMAT_MSG, MWRITEFILE,
968 mac_format_msg, IFSCHELP(nano_mac_msg), FALSE, NOVIEW);
970 if (!ISSET(RESTRICTED))
971 add_to_funcs( APPEND_MSG, MWRITEFILE,
972 append_msg, IFSCHELP(nano_append_msg), FALSE, NOVIEW);
974 if (!ISSET(RESTRICTED))
975 add_to_funcs( PREPEND_MSG, MWRITEFILE,
976 prepend_msg, IFSCHELP(nano_prepend_msg), FALSE, NOVIEW);
978 if (!ISSET(RESTRICTED))
979 add_to_funcs( BACKUP_FILE_MSG, MWRITEFILE,
980 backup_file_msg, IFSCHELP(nano_backup_msg), FALSE, NOVIEW);
981 #endif
983 #ifndef NANO_TINY
984 /* If we're using restricted mode, command execution is disabled.
985 * It's useless since inserting files is disabled. */
986 if (!ISSET(RESTRICTED))
987 add_to_funcs( EXT_CMD_MSG, MINSERTFILE,
988 ext_cmd_msg, IFSCHELP(nano_execute_msg), FALSE, NOVIEW);
990 #ifdef ENABLE_MULTIBUFFER
991 /* If we're using restricted mode, the multibuffer toggle is
992 * disabled. It's useless since inserting files is disabled. */
993 if (!ISSET(RESTRICTED))
994 add_to_funcs( NEW_BUFFER_MSG, MINSERTFILE,
995 new_buffer_msg, IFSCHELP(nano_multibuffer_msg), FALSE, NOVIEW);
996 #endif
998 add_to_funcs( INSERT_FILE_MSG, MEXTCMD,
999 insert_file_msg, IFSCHELP(nano_insert_msg), FALSE, VIEW);
1001 #ifdef ENABLE_MULTIBUFFER
1002 add_to_funcs( NEW_BUFFER_MSG, MEXTCMD,
1003 new_buffer_msg, IFSCHELP(nano_multibuffer_msg), FALSE, NOVIEW);
1004 #endif
1005 #endif
1007 #ifndef DISABLE_HELP
1008 add_to_funcs( REFRESH_MSG, MHELP,
1009 refresh_msg, nano_refresh_msg, FALSE, VIEW);
1011 add_to_funcs(DO_EXIT, MHELP, exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW);
1014 #endif
1016 #ifndef DISABLE_BROWSER
1018 add_to_funcs( FIRST_FILE_MSG,
1019 (MBROWSER|MWHEREISFILE),
1020 first_file_msg, IFSCHELP(nano_firstfile_msg), FALSE, VIEW);
1022 add_to_funcs( LAST_FILE_MSG,
1023 (MBROWSER|MWHEREISFILE),
1024 last_file_msg, IFSCHELP(nano_lastfile_msg), FALSE, VIEW);
1026 add_to_funcs( GOTO_DIR_MSG, MBROWSER,
1027 goto_dir_msg, IFSCHELP(nano_gotodir_msg), FALSE, VIEW);
1028 #endif
1030 currmenu = MMAIN;
1032 add_to_sclist(MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MBROWSER|MWHEREISFILE|MGOTODIR,
1033 "^G", DO_HELP_VOID, 0, TRUE);
1034 add_to_sclist(MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MBROWSER|MWHEREISFILE|MGOTODIR,
1035 "F1", DO_HELP_VOID, 0, TRUE);
1036 add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", DO_EXIT, 0, TRUE);
1037 add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", DO_EXIT, 0, TRUE);
1038 add_to_sclist(MMAIN, "^_", DO_GOTOLINECOLUMN_VOID, 0, TRUE);
1039 add_to_sclist(MMAIN, "F13", DO_GOTOLINECOLUMN_VOID, 0, TRUE);
1040 add_to_sclist(MMAIN, "M-G", DO_GOTOLINECOLUMN_VOID, 0, TRUE);
1041 add_to_sclist(MMAIN, "^O", DO_WRITEOUT_VOID, 0, TRUE);
1042 add_to_sclist(MMAIN, "F3", DO_WRITEOUT_VOID, 0, TRUE);
1043 #ifndef DISABLE_JUSTIFY
1044 add_to_sclist(MMAIN, "^J", DO_JUSTIFY_VOID, 0, TRUE);
1045 add_to_sclist(MMAIN, "F4", DO_JUSTIFY_VOID, 0, TRUE);
1046 #endif
1047 add_to_sclist(MMAIN, "^R", DO_INSERTFILE_VOID, 0, TRUE);
1048 add_to_sclist(MMAIN, "F5", DO_INSERTFILE_VOID, 0, TRUE);
1049 add_to_sclist(MMAIN, "kinsert", DO_INSERTFILE_VOID, 0, TRUE);
1050 add_to_sclist(MMAIN|MBROWSER, "^W", DO_SEARCH, 0, TRUE);
1051 add_to_sclist(MMAIN|MBROWSER, "F6", DO_SEARCH, 0, TRUE);
1052 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "^Y", DO_PAGE_UP, 0, TRUE);
1053 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "F7", DO_PAGE_UP, 0, TRUE);
1054 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "kpup", DO_PAGE_UP, 0, TRUE);
1055 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "^V", DO_PAGE_DOWN, 0, TRUE);
1056 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "F8", DO_PAGE_DOWN, 0, TRUE);
1057 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "kpdown", DO_PAGE_DOWN, 0, TRUE);
1058 add_to_sclist(MMAIN, "^K", DO_CUT_TEXT_VOID, 0, TRUE);
1059 add_to_sclist(MMAIN, "F9", DO_CUT_TEXT_VOID, 0, TRUE);
1060 add_to_sclist(MMAIN, "^U", DO_UNCUT_TEXT, 0, TRUE);
1061 add_to_sclist(MMAIN, "F10", DO_UNCUT_TEXT, 0, TRUE);
1062 add_to_sclist(MMAIN, "^C", DO_CURSORPOS_VOID, 0, TRUE);
1063 add_to_sclist(MMAIN, "F11", DO_CURSORPOS_VOID, 0, TRUE);
1064 #ifndef DISABLE_SPELLER
1065 add_to_sclist(MMAIN, "^T", DO_SPELL, 0, TRUE);
1066 add_to_sclist(MMAIN, "F12", DO_SPELL, 0, TRUE);
1067 #endif
1068 add_to_sclist(MMAIN, "^\\", DO_REPLACE, 0, TRUE);
1069 add_to_sclist(MMAIN, "F14", DO_REPLACE, 0, TRUE);
1070 add_to_sclist(MMAIN, "M-R", DO_REPLACE, 0, TRUE);
1071 add_to_sclist(MWHEREIS, "^R", DO_REPLACE, 0, FALSE);
1072 add_to_sclist(MREPLACE, "^R", NO_REPLACE_MSG, 0, FALSE);
1073 add_to_sclist(MWHEREIS, "^T", DO_GOTOLINECOLUMN_VOID, 0, FALSE);
1074 #ifndef NANO_TINY
1075 add_to_sclist(MMAIN, "^^", DO_MARK, 0, TRUE);
1076 add_to_sclist(MMAIN, "F15", DO_MARK, 0, TRUE);
1077 add_to_sclist(MMAIN, "M-A", DO_MARK, 0, TRUE);
1078 add_to_sclist(MMAIN|MBROWSER, "M-W", DO_RESEARCH, 0, TRUE);
1079 add_to_sclist(MMAIN|MBROWSER, "F16", DO_RESEARCH, 0, TRUE);
1080 add_to_sclist(MMAIN, "M-^", DO_COPY_TEXT, 0, TRUE);
1081 add_to_sclist(MMAIN, "M-6", DO_COPY_TEXT, 0, TRUE);
1082 add_to_sclist(MMAIN, "M-}", DO_INDENT_VOID, 0, TRUE);
1083 add_to_sclist(MMAIN, "M-{", DO_UNINDENT, 0, TRUE);
1084 if (ISSET(UNDOABLE)) {
1085 add_to_sclist(MMAIN, "M-U", DO_UNDO, 0, TRUE);
1086 add_to_sclist(MMAIN, "M-E", DO_REDO, 0, TRUE);
1088 add_to_sclist(MALL, "^F", DO_RIGHT, 0, TRUE);
1089 add_to_sclist(MALL, "^B", DO_LEFT, 0, TRUE);
1090 add_to_sclist(MMAIN, "^Space", DO_NEXT_WORD_VOID, 0, TRUE);
1091 add_to_sclist(MMAIN, "M-Space", DO_PREV_WORD_VOID, 0, TRUE);
1092 #endif
1093 add_to_sclist(MALL, "kright", DO_RIGHT, 0, TRUE);
1094 add_to_sclist(MALL, "kleft", DO_LEFT, 0, TRUE);
1095 add_to_sclist(MMAIN, "^Q", XON_COMPLAINT, 0, TRUE);
1096 add_to_sclist(MMAIN, "^S", XOFF_COMPLAINT, 0, TRUE);
1097 add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", DO_UP_VOID, 0, TRUE);
1098 add_to_sclist(MMAIN|MHELP|MBROWSER, "kup", DO_UP_VOID, 0, TRUE);
1099 add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", DO_DOWN_VOID, 0, TRUE);
1100 add_to_sclist(MMAIN|MHELP|MBROWSER, "kdown", DO_DOWN_VOID, 0, TRUE);
1101 add_to_sclist(MALL, "^A", DO_HOME, 0, TRUE);
1102 add_to_sclist(MALL, "khome", DO_HOME, 0, TRUE);
1103 add_to_sclist(MALL, "^E", DO_END, 0, TRUE);
1104 add_to_sclist(MALL, "kend", DO_END, 0, TRUE);
1105 #ifndef NANO_TINY
1106 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "^P", PREV_HISTORY_MSG, 0, FALSE);
1107 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "kup", PREV_HISTORY_MSG, 0, FALSE);
1108 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "^N", NEXT_HISTORY_MSG, 0, FALSE);
1109 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "kdown", NEXT_HISTORY_MSG, 0, FALSE);
1110 #endif
1111 #ifndef DISABLE_JUSTIFY
1112 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1113 "^W", DO_PARA_BEGIN_VOID, 0, TRUE);
1114 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1115 "^O", DO_PARA_END_VOID, 0, TRUE);
1116 add_to_sclist(MALL, "M-(", DO_PARA_BEGIN_VOID, 0, TRUE);
1117 add_to_sclist(MALL, "M-9", DO_PARA_BEGIN_VOID, 0, TRUE);
1118 add_to_sclist(MALL, "M-)", DO_PARA_END_VOID, 0, TRUE);
1119 add_to_sclist(MALL, "M-0", DO_PARA_END_VOID, 0, TRUE);
1120 #endif
1121 add_to_sclist(MWHEREIS,
1122 "M-C", CASE_SENS_MSG, 0, FALSE);
1123 add_to_sclist(MREPLACE,
1124 "M-C", CASE_SENS_MSG, 0, FALSE);
1125 add_to_sclist(MREPLACE2,
1126 "M-C", CASE_SENS_MSG, 0, FALSE);
1127 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1128 "M-B", BACKWARDS_MSG, 0, FALSE);
1129 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1130 "M-R", REGEXP_MSG, 0, FALSE);
1132 add_to_sclist(MMAIN, "M-\\", DO_FIRST_LINE, 0, TRUE);
1133 add_to_sclist(MMAIN, "M-|", DO_FIRST_LINE, 0, TRUE);
1134 add_to_sclist(MMAIN, "M-/", DO_LAST_LINE, 0, TRUE);
1135 add_to_sclist(MMAIN, "M-?", DO_LAST_LINE, 0, TRUE);
1136 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP,
1137 "^Y", DO_FIRST_LINE, 0, TRUE);
1138 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP,
1139 "^V", DO_LAST_LINE, 0, TRUE);
1141 add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", FIRST_FILE_MSG, 0, TRUE);
1142 add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", FIRST_FILE_MSG, 0, TRUE);
1143 add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", LAST_FILE_MSG, 0, TRUE);
1144 add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", LAST_FILE_MSG, 0, TRUE);
1145 add_to_sclist(MBROWSER|MWHEREISFILE, "^_", GOTO_DIR_MSG, 0, TRUE);
1146 add_to_sclist(MBROWSER|MWHEREISFILE, "F13", GOTO_DIR_MSG, 0, TRUE);
1147 add_to_sclist(MBROWSER|MWHEREISFILE, "M-G", GOTO_DIR_MSG, 0, TRUE);
1148 #ifndef NANO_TINY
1149 add_to_sclist(MMAIN, "M-]", DO_FIND_BRACKET, 0, TRUE);
1150 add_to_sclist(MMAIN, "M--", DO_SCROLL_UP, 0, TRUE);
1151 add_to_sclist(MMAIN, "M-_", DO_SCROLL_UP, 0, TRUE);
1152 add_to_sclist(MMAIN, "M-+", DO_SCROLL_DOWN, 0, TRUE);
1153 add_to_sclist(MMAIN, "M-=", DO_SCROLL_DOWN, 0, TRUE);
1154 #endif
1156 #ifdef ENABLE_MULTIBUFFER
1157 add_to_sclist(MMAIN, "M-<", SWITCH_TO_PREV_BUFFER_VOID, 0, TRUE);
1158 add_to_sclist(MMAIN, "M-,", SWITCH_TO_PREV_BUFFER_VOID, 0, TRUE);
1159 add_to_sclist(MMAIN, "M->", SWITCH_TO_NEXT_BUFFER_VOID, 0, TRUE);
1160 add_to_sclist(MMAIN, "M-.", SWITCH_TO_NEXT_BUFFER_VOID, 0, TRUE);
1161 #endif
1162 add_to_sclist(MALL, "M-V", DO_VERBATIM_INPUT, 0, TRUE);
1163 #ifndef NANO_TINY
1164 add_to_sclist(MALL, "M-T", DO_CUT_TILL_END, 0, TRUE);
1165 #ifndef DISABLE_JUSTIFY
1166 add_to_sclist(MALL, "M-J", DO_FULL_JUSTIFY, 0, TRUE);
1167 #endif
1168 add_to_sclist(MMAIN, "M-D", DO_WORDLINECHAR_COUNT, 0, TRUE);
1169 add_to_sclist(MMAIN, "M-X", DO_TOGGLE, NO_HELP, TRUE);
1170 add_to_sclist(MMAIN, "M-C", DO_TOGGLE, CONST_UPDATE, TRUE);
1171 add_to_sclist(MMAIN, "M-O", DO_TOGGLE, MORE_SPACE, TRUE);
1172 add_to_sclist(MMAIN, "M-S", DO_TOGGLE, SMOOTH_SCROLL, TRUE);
1173 add_to_sclist(MMAIN, "M-P", DO_TOGGLE, WHITESPACE_DISPLAY, TRUE);
1174 add_to_sclist(MMAIN, "M-Y", DO_TOGGLE, NO_COLOR_SYNTAX, TRUE);
1175 add_to_sclist(MMAIN, "M-H", DO_TOGGLE, SMART_HOME, TRUE);
1176 add_to_sclist(MMAIN, "M-I", DO_TOGGLE, AUTOINDENT, TRUE);
1177 add_to_sclist(MMAIN, "M-K", DO_TOGGLE, CUT_TO_END, TRUE);
1178 add_to_sclist(MMAIN, "M-L", DO_TOGGLE, NO_WRAP, TRUE);
1179 add_to_sclist(MMAIN, "M-Q", DO_TOGGLE, TABS_TO_SPACES, TRUE);
1180 add_to_sclist(MMAIN, "M-B", DO_TOGGLE, BACKUP_FILE, TRUE);
1181 add_to_sclist(MMAIN, "M-F", DO_TOGGLE, MULTIBUFFER, TRUE);
1182 add_to_sclist(MMAIN, "M-M", DO_TOGGLE, USE_MOUSE, TRUE);
1183 add_to_sclist(MMAIN, "M-N", DO_TOGGLE, NO_CONVERT, TRUE);
1184 add_to_sclist(MMAIN, "M-Z", DO_TOGGLE, SUSPEND, TRUE);
1185 add_to_sclist(MMAIN, "M-$", DO_TOGGLE, SOFTWRAP, TRUE);
1186 #endif
1187 add_to_sclist(MGOTOLINE, "^T", GOTOTEXT_MSG, 0, FALSE);
1188 add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", NEW_BUFFER_MSG, 0, FALSE);
1189 add_to_sclist((MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR|MYESNO),
1190 "^C", CANCEL_MSG, 0, FALSE);
1191 add_to_sclist(MHELP, "^X", DO_EXIT, 0, TRUE);
1192 add_to_sclist(MHELP, "F2", DO_EXIT, 0, TRUE);
1193 add_to_sclist(MWRITEFILE, "M-D", DOS_FORMAT_MSG, 0, FALSE);
1194 add_to_sclist(MWRITEFILE, "M-M", MAC_FORMAT_MSG, 0, FALSE);
1195 add_to_sclist(MWRITEFILE, "M-A", APPEND_MSG, 0, FALSE);
1196 add_to_sclist(MWRITEFILE, "M-P", PREPEND_MSG, 0, FALSE);
1197 add_to_sclist(MWRITEFILE, "M-B", BACKUP_FILE_MSG, 0, FALSE);
1198 add_to_sclist(MWRITEFILE, "^T", TO_FILES_MSG, 0, FALSE);
1199 add_to_sclist(MINSERTFILE, "^T", TO_FILES_MSG, 0, FALSE);
1200 add_to_sclist(MINSERTFILE, "^X", EXT_CMD_MSG, 0, FALSE);
1201 add_to_sclist(MMAIN, "^Z", DO_SUSPEND_VOID, 0, FALSE);
1202 add_to_sclist(MMAIN, "^L", TOTAL_REFRESH, 0, TRUE);
1203 add_to_sclist(MALL, "^I", DO_TAB, 0, TRUE);
1204 add_to_sclist(MALL, "^M", DO_ENTER, 0, TRUE);
1205 add_to_sclist(MALL, "kenter", DO_ENTER, 0, TRUE);
1206 add_to_sclist(MALL, "^D", DO_DELETE, 0, TRUE);
1207 add_to_sclist(MALL, "kdel", DO_DELETE, 0, TRUE);
1208 add_to_sclist(MALL, "^H", DO_BACKSPACE, 0, TRUE);
1209 add_to_sclist(MALL, "kbsp", DO_BACKSPACE, 0, TRUE);
1211 #ifdef DEBUG
1212 print_sclist();
1213 #endif
1217 /* Given a function alias, execute the proper
1218 function, and then me */
1219 void iso_me_harder_funcmap(short func)
1221 if (func == TOTAL_REFRESH)
1222 total_refresh();
1223 else if (func == DO_HELP_VOID)
1224 do_help_void();
1225 else if (func == DO_SEARCH)
1226 do_search();
1227 else if (func == DO_PAGE_UP)
1228 do_page_up();
1229 else if (func == DO_PAGE_DOWN)
1230 do_page_down();
1231 else if (func == DO_UP_VOID)
1232 do_up_void();
1233 else if (func == DO_LEFT)
1234 do_left();
1235 else if (func == DO_DOWN_VOID)
1236 do_down_void();
1237 else if (func == DO_RIGHT)
1238 do_right();
1239 else if (func == DO_ENTER)
1240 do_enter(FALSE);
1241 else if (func == DO_EXIT)
1242 do_exit();
1243 else if (func == DO_FIRST_LINE)
1244 do_first_line();
1245 else if (func == DO_LAST_LINE)
1246 do_last_line();
1247 else if (func == DO_BACKSPACE)
1248 do_backspace();
1249 else if (func == DO_DELETE)
1250 do_delete();
1251 else if (func == DO_TAB)
1252 do_tab();
1253 else if (func == DO_VERBATIM_INPUT)
1254 do_verbatim_input();
1255 #ifdef ENABLE_MULTIBUFFER
1256 else if (func == SWITCH_TO_NEXT_BUFFER_VOID)
1257 switch_to_next_buffer_void();
1258 else if (func == SWITCH_TO_PREV_BUFFER_VOID)
1259 switch_to_prev_buffer_void();
1260 #endif
1261 else if (func == DO_END)
1262 do_end();
1263 else if (func == DO_HOME)
1264 do_home();
1265 else if (func == DO_SUSPEND_VOID)
1266 do_suspend_void();
1267 else if (func == DO_WRITEOUT_VOID)
1268 do_writeout_void();
1269 else if (func == DO_INSERTFILE_VOID)
1270 do_insertfile_void();
1271 else if (func == DO_CUT_TEXT_VOID)
1272 do_cut_text_void();
1273 else if (func == DO_UNCUT_TEXT)
1274 do_uncut_text();
1275 else if (func == DO_CURSORPOS_VOID)
1276 do_cursorpos_void();
1277 else if (func == DO_GOTOLINECOLUMN_VOID)
1278 do_gotolinecolumn_void();
1279 else if (func == DO_REPLACE)
1280 do_replace();
1281 else if (func == XOFF_COMPLAINT)
1282 xoff_complaint();
1283 else if (func == XON_COMPLAINT)
1284 xon_complaint();
1285 else if (func == DO_CUT_TEXT)
1286 do_cut_text_void();
1287 #ifndef NANO_TINY
1288 else if (func == DO_CUT_TILL_END)
1289 do_cut_till_end();
1290 else if (func == DO_REDO)
1291 do_redo();
1292 else if (func == DO_UNDO)
1293 do_undo();
1294 else if (func == DO_WORDLINECHAR_COUNT)
1295 do_wordlinechar_count();
1296 else if (func == DO_FIND_BRACKET)
1297 do_find_bracket();
1298 else if (func == DO_PREV_WORD_VOID)
1299 do_prev_word_void();
1300 #ifndef DISABLE_JUSTIFY
1301 else if (func == DO_JUSTIFY_VOID)
1302 do_justify_void();
1303 else if (func == DO_PARA_BEGIN_VOID)
1304 do_para_begin_void();
1305 else if (func == DO_PARA_END_VOID)
1306 do_para_end_void();
1307 else if (func == DO_FULL_JUSTIFY)
1308 do_full_justify();
1309 #endif
1310 else if (func == DO_MARK)
1311 do_mark();
1312 else if (func == DO_RESEARCH)
1313 do_research();
1314 else if (func == DO_COPY_TEXT)
1315 do_copy_text();
1316 else if (func == DO_INDENT_VOID)
1317 do_indent_void();
1318 else if (func == DO_UNINDENT)
1319 do_unindent();
1320 else if (func == DO_SCROLL_UP)
1321 do_scroll_up();
1322 else if (func == DO_SCROLL_DOWN)
1323 do_scroll_down();
1324 else if (func == DO_NEXT_WORD_VOID)
1325 do_next_word_void();
1326 #ifndef DISABLE_SPELLER
1327 else if (func == DO_SPELL)
1328 do_spell();
1329 #endif
1330 else if (func == DO_NEXT_WORD)
1331 do_next_word_void();
1332 else if (func == DO_PREV_WORD)
1333 do_prev_word_void();
1334 #endif
1338 /* Free the given shortcut. */
1339 void free_shortcutage(shortcut **shortcutage)
1341 assert(shortcutage != NULL);
1343 while (*shortcutage != NULL) {
1344 shortcut *ps = *shortcutage;
1345 *shortcutage = (*shortcutage)->next;
1346 free(ps);
1350 const subnfunc *sctofunc(sc *s)
1352 subnfunc *f;
1354 for (f = allfuncs; f != NULL && s->scfunc != f->scfunc; f = f->next)
1357 return f;
1360 #ifndef NANO_TINY
1361 /* Now lets come up with a single (hopefully)
1362 function to get a string for each flag */
1363 const char *flagtostr(int flag)
1365 switch (flag) {
1366 case NO_HELP:
1367 return N_("Help mode");
1368 case CONST_UPDATE:
1369 return N_("Constant cursor position display");
1370 case MORE_SPACE:
1371 return N_("Use of one more line for editing");
1372 case SMOOTH_SCROLL:
1373 return N_("Smooth scrolling");
1374 case WHITESPACE_DISPLAY:
1375 return N_("Whitespace display");
1376 case NO_COLOR_SYNTAX:
1377 return N_("Color syntax highlighting");
1378 case SMART_HOME:
1379 return N_("Smart home key");
1380 case AUTOINDENT:
1381 return N_("Auto indent");
1382 case CUT_TO_END:
1383 return N_("Cut to end");
1384 case NO_WRAP:
1385 return N_("Long line wrapping");
1386 case TABS_TO_SPACES:
1387 return N_("Conversion of typed tabs to spaces");
1388 case BACKUP_FILE:
1389 return N_("Backup files");
1390 case MULTIBUFFER:
1391 return N_("Multiple file buffers");
1392 case USE_MOUSE:
1393 return N_("Mouse support");
1394 case NO_CONVERT:
1395 return N_("No conversion from DOS/Mac format");
1396 case SUSPEND:
1397 return N_("Suspension");
1398 case SOFTWRAP:
1399 return N_("Soft line wrapping");
1400 default:
1401 return "?????";
1404 #endif /* NANO_TINY */
1406 /* Interpret the string given by the rc file and return a
1407 shortcut struct, complete with proper value for execute */
1408 sc *strtosc(int menu, char *input)
1410 sc *s;
1412 s = (sc *)nmalloc(sizeof(sc));
1413 s->execute = TRUE; /* overridden as needed below */
1416 #ifndef DISABLE_HELP
1417 if (!strcasecmp(input, "help"))
1418 s->scfunc = DO_HELP_VOID;
1419 else
1420 #endif
1421 if (!strcasecmp(input, "cancel")) {
1422 s->scfunc = CANCEL_MSG;
1423 s->execute = FALSE;
1424 } else if (!strcasecmp(input, "exit"))
1425 s->scfunc = DO_EXIT;
1426 else if (!strcasecmp(input, "writeout"))
1427 s->scfunc = DO_WRITEOUT_VOID;
1428 else if (!strcasecmp(input, "insert"))
1429 s->scfunc = DO_INSERTFILE_VOID;
1430 else if (!strcasecmp(input, "whereis"))
1431 s->scfunc = DO_SEARCH;
1432 else if (!strcasecmp(input, "up"))
1433 s->scfunc = DO_UP_VOID;
1434 else if (!strcasecmp(input, "down"))
1435 s->scfunc = DO_DOWN_VOID;
1436 else if (!strcasecmp(input, "pageup")
1437 || !strcasecmp(input, "prevpage"))
1438 s->scfunc = DO_PAGE_UP;
1439 else if (!strcasecmp(input, "pagedown")
1440 || !strcasecmp(input, "nextpage"))
1441 s->scfunc = DO_PAGE_DOWN;
1442 else if (!strcasecmp(input, "cut"))
1443 s->scfunc = DO_CUT_TEXT_VOID;
1444 else if (!strcasecmp(input, "uncut"))
1445 s->scfunc = DO_UNCUT_TEXT;
1446 else if (!strcasecmp(input, "curpos") ||
1447 !strcasecmp(input, "cursorpos"))
1448 s->scfunc = DO_CURSORPOS_VOID;
1449 else if (!strcasecmp(input, "firstline"))
1450 s->scfunc = DO_FIRST_LINE;
1451 else if (!strcasecmp(input, "lastline"))
1452 s->scfunc = DO_LAST_LINE;
1453 else if (!strcasecmp(input, "gotoline"))
1454 s->scfunc = DO_GOTOLINECOLUMN_VOID;
1455 else if (!strcasecmp(input, "replace"))
1456 s->scfunc = DO_REPLACE;
1457 #ifndef DISABLE_JUSTIFY
1458 else if (!strcasecmp(input, "justify"))
1459 s->scfunc = DO_JUSTIFY_VOID;
1460 else if (!strcasecmp(input, "beginpara"))
1461 s->scfunc = DO_PARA_BEGIN_VOID;
1462 else if (!strcasecmp(input, "endpara"))
1463 s->scfunc = DO_PARA_END_VOID;
1464 else if (!strcasecmp(input, "fulljustify"))
1465 s->scfunc = DO_FULL_JUSTIFY;
1466 #endif
1467 #ifndef NANO_TINY
1468 else if (!strcasecmp(input, "mark"))
1469 s->scfunc = DO_MARK;
1470 else if (!strcasecmp(input, "searchagain") ||
1471 !strcasecmp(input, "research"))
1472 s->scfunc = DO_RESEARCH;
1473 else if (!strcasecmp(input, "copytext"))
1474 s->scfunc = DO_COPY_TEXT;
1475 else if (!strcasecmp(input, "indent"))
1476 s->scfunc = DO_INDENT_VOID;
1477 else if (!strcasecmp(input, "unindent"))
1478 s->scfunc = DO_UNINDENT;
1479 else if (!strcasecmp(input, "scrollup"))
1480 s->scfunc = DO_SCROLL_UP;
1481 else if (!strcasecmp(input, "scrolldown"))
1482 s->scfunc = DO_SCROLL_DOWN;
1483 else if (!strcasecmp(input, "nextword"))
1484 s->scfunc = DO_NEXT_WORD_VOID;
1485 else if (!strcasecmp(input, "suspend"))
1486 s->scfunc = DO_SUSPEND_VOID;
1487 else if (!strcasecmp(input, "prevword"))
1488 s->scfunc = DO_PREV_WORD_VOID;
1489 else if (!strcasecmp(input, "findbracket"))
1490 s->scfunc = DO_FIND_BRACKET;
1491 else if (!strcasecmp(input, "wordcount"))
1492 s->scfunc = DO_WORDLINECHAR_COUNT;
1493 else if (!strcasecmp(input, "undo"))
1494 s->scfunc = DO_UNDO;
1495 else if (!strcasecmp(input, "redo"))
1496 s->scfunc = DO_REDO;
1497 else if (!strcasecmp(input, "prevhistory")) {
1498 s->scfunc = PREV_HISTORY_MSG;
1499 s->execute = FALSE;
1500 } else if (!strcasecmp(input, "nexthistory")) {
1501 s->scfunc = NEXT_HISTORY_MSG;
1502 s->execute = FALSE;
1503 } else if (!strcasecmp(input, "nohelp") ||
1504 !strcasecmp(input, "nohelp")) {
1505 s->scfunc = DO_TOGGLE;
1506 s->execute = FALSE;
1507 s->toggle = NO_HELP;
1508 } else if (!strcasecmp(input, "constupdate")) {
1509 s->scfunc = DO_TOGGLE;
1510 s->execute = FALSE;
1511 s->toggle = CONST_UPDATE;
1512 } else if (!strcasecmp(input, "morespace")) {
1513 s->scfunc = DO_TOGGLE;
1514 s->execute = FALSE;
1515 s->toggle = MORE_SPACE;
1516 } else if (!strcasecmp(input, "smoothscroll")) {
1517 s->scfunc = DO_TOGGLE;
1518 s->execute = FALSE;
1519 s->toggle = SMOOTH_SCROLL;
1520 } else if (!strcasecmp(input, "whitespacedisplay")) {
1521 s->scfunc = DO_TOGGLE;
1522 s->execute = FALSE;
1523 s->toggle = WHITESPACE_DISPLAY;
1524 } else if (!strcasecmp(input, "nosyntax")) {
1525 s->scfunc = DO_TOGGLE;
1526 s->execute = FALSE;
1527 s->toggle = NO_COLOR_SYNTAX;
1528 } else if (!strcasecmp(input, "smarthome")) {
1529 s->scfunc = DO_TOGGLE;
1530 s->execute = FALSE;
1531 s->toggle = SMART_HOME;
1532 } else if (!strcasecmp(input, "autoindent")) {
1533 s->scfunc = DO_TOGGLE;
1534 s->execute = FALSE;
1535 s->toggle = AUTOINDENT;
1536 } else if (!strcasecmp(input, "cuttoend")) {
1537 s->scfunc = DO_TOGGLE;
1538 s->execute = FALSE;
1539 s->toggle = CUT_TO_END;
1540 } else if (!strcasecmp(input, "nowrap")) {
1541 s->scfunc = DO_TOGGLE;
1542 s->execute = FALSE;
1543 s->toggle = NO_WRAP;
1544 } else if (!strcasecmp(input, "tabstospaces")) {
1545 s->scfunc = DO_TOGGLE;
1546 s->execute = FALSE;
1547 s->toggle = TABS_TO_SPACES;
1548 } else if (!strcasecmp(input, "backupfile")) {
1549 s->scfunc = DO_TOGGLE;
1550 s->execute = FALSE;
1551 s->toggle = BACKUP_FILE;
1552 } else if (!strcasecmp(input, "mutlibuffer")) {
1553 s->scfunc = DO_TOGGLE;
1554 s->execute = FALSE;
1555 s->toggle = MULTIBUFFER;
1556 } else if (!strcasecmp(input, "mouse")) {
1557 s->scfunc = DO_TOGGLE;
1558 s->execute = FALSE;
1559 s->toggle = USE_MOUSE;
1560 } else if (!strcasecmp(input, "noconvert")) {
1561 s->scfunc = DO_TOGGLE;
1562 s->execute = FALSE;
1563 s->toggle = NO_CONVERT;
1564 } else if (!strcasecmp(input, "suspendenable")) {
1565 s->scfunc = DO_TOGGLE;
1566 s->execute = FALSE;
1567 s->toggle = SUSPEND;
1569 #endif /* NANO_TINY */
1570 else if (!strcasecmp(input, "right") ||
1571 !strcasecmp(input, "forward"))
1572 s->scfunc = DO_RIGHT;
1573 else if (!strcasecmp(input, "left") ||
1574 !strcasecmp(input, "back"))
1575 s->scfunc = DO_LEFT;
1576 else if (!strcasecmp(input, "up") ||
1577 !strcasecmp(input, "prevline"))
1578 s->scfunc = DO_UP_VOID;
1579 else if (!strcasecmp(input, "down") ||
1580 !strcasecmp(input, "nextline"))
1581 s->scfunc = DO_DOWN_VOID;
1582 else if (!strcasecmp(input, "home"))
1583 s->scfunc = DO_HOME;
1584 else if (!strcasecmp(input, "end"))
1585 s->scfunc = DO_END;
1586 #ifdef ENABLE_MULTIBUFFER
1587 else if (!strcasecmp(input, "prevbuf"))
1588 s->scfunc = SWITCH_TO_PREV_BUFFER_VOID;
1589 else if (!strcasecmp(input, "nextbuf"))
1590 s->scfunc = SWITCH_TO_NEXT_BUFFER_VOID;
1591 #endif
1592 else if (!strcasecmp(input, "verbatim"))
1593 s->scfunc = DO_VERBATIM_INPUT;
1594 else if (!strcasecmp(input, "tab"))
1595 s->scfunc = DO_TAB;
1596 else if (!strcasecmp(input, "enter"))
1597 s->scfunc = DO_ENTER;
1598 else if (!strcasecmp(input, "delete"))
1599 s->scfunc = DO_DELETE;
1600 else if (!strcasecmp(input, "backspace"))
1601 s->scfunc = DO_BACKSPACE;
1602 else if (!strcasecmp(input, "refresh"))
1603 s->scfunc = TOTAL_REFRESH;
1604 else if (!strcasecmp(input, "casesens")) {
1605 s->scfunc = CASE_SENS_MSG;
1606 s->execute = FALSE;
1607 } else if (!strcasecmp(input, "regexp") ||
1608 !strcasecmp(input, "regex")) {
1609 s->scfunc = REGEXP_MSG;
1610 s->execute = FALSE;
1611 } else if (!strcasecmp(input, "dontreplace")) {
1612 s->scfunc = NO_REPLACE_MSG;
1613 s->execute = FALSE;
1614 } else if (!strcasecmp(input, "gototext")) {
1615 s->scfunc = GOTOTEXT_MSG;
1616 s->execute = FALSE;
1617 } else if (!strcasecmp(input, "browser") ||
1618 !strcasecmp(input, "tofiles")) {
1619 s->scfunc = TO_FILES_MSG;
1620 s->execute = FALSE;
1621 } else if (!strcasecmp(input, "dosformat")) {
1622 s->scfunc = DOS_FORMAT_MSG;
1623 s->execute = FALSE;
1624 } else if (!strcasecmp(input, "macformat")) {
1625 s->scfunc = MAC_FORMAT_MSG;
1626 s->execute = FALSE;
1627 } else if (!strcasecmp(input, "append")) {
1628 s->scfunc = APPEND_MSG;
1629 s->execute = FALSE;
1630 } else if (!strcasecmp(input, "prepend")) {
1631 s->scfunc = PREPEND_MSG;
1632 s->execute = FALSE;
1633 } else if (!strcasecmp(input, "backup")) {
1634 s->scfunc = BACKUP_FILE_MSG;
1635 s->execute = FALSE;
1636 #ifdef ENABLE_MULTIBUFFER
1637 } else if (!strcasecmp(input, "newbuffer")) {
1638 s->scfunc = NEW_BUFFER_MSG;
1639 s->execute = FALSE;
1640 #endif
1641 } else if (!strcasecmp(input, "firstfile")) {
1642 s->scfunc = FIRST_FILE_MSG;
1643 s->execute = FALSE;
1644 } else if (!strcasecmp(input, "lastfile")) {
1645 s->scfunc = LAST_FILE_MSG;
1646 s->execute = FALSE;
1647 } else {
1648 free(s);
1649 return NULL;
1652 return s;
1656 #ifdef ENABLE_NANORC
1657 /* Same thing as abnove but for the menu */
1658 int strtomenu(char *input)
1660 if (!strcasecmp(input, "all"))
1661 return MALL;
1662 else if (!strcasecmp(input, "main"))
1663 return MMAIN;
1664 else if (!strcasecmp(input, "search"))
1665 return MWHEREIS;
1666 else if (!strcasecmp(input, "replace"))
1667 return MREPLACE;
1668 else if (!strcasecmp(input, "replace2") ||
1669 !strcasecmp(input, "replacewith"))
1670 return MREPLACE2;
1671 else if (!strcasecmp(input, "gotoline"))
1672 return MGOTOLINE;
1673 else if (!strcasecmp(input, "writeout"))
1674 return MWRITEFILE;
1675 else if (!strcasecmp(input, "insert"))
1676 return MINSERTFILE;
1677 else if (!strcasecmp(input, "externalcmd") ||
1678 !strcasecmp(input, "extcmd"))
1679 return MEXTCMD;
1680 else if (!strcasecmp(input, "help"))
1681 return MHELP;
1682 else if (!strcasecmp(input, "spell"))
1683 return MSPELL;
1684 else if (!strcasecmp(input, "browser"))
1685 return MBROWSER;
1686 else if (!strcasecmp(input, "whereisfile"))
1687 return MWHEREISFILE;
1688 else if (!strcasecmp(input, "gotodir"))
1689 return MGOTODIR;
1691 return -1;
1693 #endif
1696 #ifdef DEBUG
1697 /* This function is used to gracefully return all the memory we've used.
1698 * It should be called just before calling exit(). Practically, the
1699 * only effect is to cause a segmentation fault if the various data
1700 * structures got bolloxed earlier. Thus, we don't bother having this
1701 * function unless debugging is turned on. */
1702 void thanks_for_all_the_fish(void)
1704 delwin(topwin);
1705 delwin(edit);
1706 delwin(bottomwin);
1708 #ifndef DISABLE_JUSTIFY
1709 if (quotestr != NULL)
1710 free(quotestr);
1711 #ifdef HAVE_REGEX_H
1712 regfree(&quotereg);
1713 if (quoteerr != NULL)
1714 free(quoteerr);
1715 #endif
1716 #endif
1717 #ifndef NANO_TINY
1718 if (backup_dir != NULL)
1719 free(backup_dir);
1720 #endif
1721 #ifndef DISABLE_OPERATINGDIR
1722 if (operating_dir != NULL)
1723 free(operating_dir);
1724 if (full_operating_dir != NULL)
1725 free(full_operating_dir);
1726 #endif
1727 if (last_search != NULL)
1728 free(last_search);
1729 if (last_replace != NULL)
1730 free(last_replace);
1731 #ifndef DISABLE_SPELLER
1732 if (alt_speller != NULL)
1733 free(alt_speller);
1734 #endif
1735 if (answer != NULL)
1736 free(answer);
1737 if (cutbuffer != NULL)
1738 free_filestruct(cutbuffer);
1739 #ifndef DISABLE_JUSTIFY
1740 if (jusbuffer != NULL)
1741 free_filestruct(jusbuffer);
1742 #endif
1743 #ifdef DEBUG
1744 /* Free the memory associated with each open file buffer. */
1745 if (openfile != NULL)
1746 free_openfilestruct(openfile);
1747 #endif
1748 #ifdef ENABLE_COLOR
1749 if (syntaxstr != NULL)
1750 free(syntaxstr);
1751 while (syntaxes != NULL) {
1752 syntaxtype *bill = syntaxes;
1754 free(syntaxes->desc);
1755 while (syntaxes->extensions != NULL) {
1756 exttype *bob = syntaxes->extensions;
1758 syntaxes->extensions = bob->next;
1759 free(bob->ext_regex);
1760 if (bob->ext != NULL) {
1761 regfree(bob->ext);
1762 free(bob->ext);
1764 free(bob);
1766 while (syntaxes->color != NULL) {
1767 colortype *bob = syntaxes->color;
1769 syntaxes->color = bob->next;
1770 free(bob->start_regex);
1771 if (bob->start != NULL) {
1772 regfree(bob->start);
1773 free(bob->start);
1775 if (bob->end_regex != NULL)
1776 free(bob->end_regex);
1777 if (bob->end != NULL) {
1778 regfree(bob->end);
1779 free(bob->end);
1781 free(bob);
1783 syntaxes = syntaxes->next;
1784 free(bill);
1786 #endif /* ENABLE_COLOR */
1787 #ifndef NANO_TINY
1788 /* Free the search and replace history lists. */
1789 if (searchage != NULL)
1790 free_filestruct(searchage);
1791 if (replaceage != NULL)
1792 free_filestruct(replaceage);
1793 #endif
1794 #ifdef ENABLE_NANORC
1795 if (homedir != NULL)
1796 free(homedir);
1797 #endif
1799 #endif /* DEBUG */