blob: f6826d7f468fb6d20aa91dbee6f7ebed2d732c2d [file] [log] [blame]
Chris Allegretta07fcc4c2008-07-10 20:13:04 +00001/* $Id$ */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00002/**************************************************************************
3 * global.c *
4 * *
David Lawrence Ramseyd8a1d372007-10-11 05:01:32 +00005 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
6 * Free Software Foundation, Inc. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00007 * 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 *
David Lawrence Ramseyd0035b42007-08-11 05:17:36 +00009 * the Free Software Foundation; either version 3, or (at your option) *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000010 * any later version. *
11 * *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000012 * 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. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000016 * *
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 *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
20 * 02110-1301, USA. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000021 * *
22 **************************************************************************/
23
Chris Allegrettaa855fa22008-07-12 02:13:22 +000024#include "proto.h"
25
Chris Allegretta79a33bb2008-03-05 07:34:01 +000026#include <ctype.h>
Chris Allegrettaeb643142008-03-12 04:44:14 +000027#include <string.h>
Chris Allegretta79a33bb2008-03-05 07:34:01 +000028#include <strings.h>
29#include "assert.h"
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000030
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +000031/* Global variables. */
32#ifndef NANO_TINY
David Lawrence Ramsey1c5af642006-05-10 15:15:06 +000033sigjmp_buf jump_buf;
David Lawrence Ramseyb6fb6882006-11-27 07:28:52 +000034 /* Used to return to either main() or the unjustify routine in
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +000035 * do_justify() after a SIGWINCH. */
David Lawrence Ramsey1c5af642006-05-10 15:15:06 +000036bool jump_buf_main = FALSE;
37 /* Have we set jump_buf so that we return to main() after a
38 * SIGWINCH? */
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +000039#endif
40
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000041#ifndef DISABLE_WRAPJUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000042ssize_t fill = 0;
43 /* The column where we will wrap lines. */
David Lawrence Ramsey691698a2005-07-24 19:57:51 +000044ssize_t wrap_at = -CHARS_FROM_EOL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000045 /* 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. */
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000048#endif
49
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000050char *last_search = NULL;
51 /* The last string we searched for. */
52char *last_replace = NULL;
53 /* The last replacement string we searched for. */
Chris Allegretta6df90f52002-07-19 01:08:59 +000054
Chris Allegrettaa48507d2009-08-14 03:18:29 +000055unsigned flags[4] = {0, 0, 0, 0};
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000056 /* Our flag containing the states of all global options. */
57WINDOW *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. */
61WINDOW *edit;
David Lawrence Ramseyb159f942006-07-28 17:06:27 +000062 /* The middle portion of the window, i.e. the edit window, where
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000063 * we display the current file we're editing. */
64WINDOW *bottomwin;
65 /* The bottom portion of the window, where we display statusbar
66 * messages, the statusbar prompt, and a list of shortcuts. */
67int editwinrows = 0;
68 /* How many rows does the edit window take up? */
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +000069
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000070filestruct *cutbuffer = NULL;
71 /* The buffer where we store cut text. */
Chris Allegretta12dc8ca2008-07-31 04:24:04 +000072filestruct *cutbottom = NULL;
David Lawrence Ramsey93c84052004-11-23 04:08:28 +000073#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000074filestruct *jusbuffer = NULL;
75 /* The buffer where we store unjustified text. */
David Lawrence Ramsey93c84052004-11-23 04:08:28 +000076#endif
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000077partition *filepart = NULL;
78 /* The partition where we store a portion of the current
79 * file. */
David Lawrence Ramsey64661ac2005-07-08 19:57:25 +000080openfilestruct *openfile = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000081 /* The list of all open file buffers. */
Chris Allegretta2d7893d2001-07-11 02:08:33 +000082
David Lawrence Ramseyd89617f2006-01-06 21:51:10 +000083#ifndef NANO_TINY
84char *matchbrackets = NULL;
85 /* The opening and closing brackets that can be found by bracket
86 * searches. */
87#endif
88
David Lawrence Ramseyebe34252005-11-15 03:17:35 +000089#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000090char *whitespace = NULL;
91 /* The characters used when displaying the first characters of
92 * tabs and spaces. */
93int whitespace_len[2];
94 /* The length of these characters. */
David Lawrence Ramsey89bb9372004-05-29 16:47:52 +000095#endif
96
Chris Allegrettae4f940d2002-03-03 22:36:36 +000097#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000098char *punct = NULL;
99 /* The closing punctuation that can end sentences. */
100char *brackets = NULL;
101 /* The closing brackets that can follow closing punctuation and
102 * can end sentences. */
103char *quotestr = NULL;
104 /* The quoting string. The default value is set in main(). */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000105#ifdef HAVE_REGEX_H
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000106regex_t quotereg;
107 /* The compiled regular expression from the quoting string. */
108int quoterc;
David Lawrence Ramsey88165642006-05-22 18:30:09 +0000109 /* Whether it was compiled successfully. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000110char *quoteerr = NULL;
111 /* The error message, if it didn't. */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000112#else
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000113size_t quotelen;
114 /* The length of the quoting string in bytes. */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000115#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000116#endif
Chris Allegrettae4f940d2002-03-03 22:36:36 +0000117
Chris Allegretta0dc26dc2009-01-24 22:40:41 +0000118bool nodelay_mode = FALSE;
119 /* Are we in nodelay mode (checking for a cancel wile doing something */
120
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000121char *answer = NULL;
David Lawrence Ramsey6335fb52007-01-01 05:15:32 +0000122 /* The answer string used by the statusbar prompt. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000123
124ssize_t tabsize = -1;
125 /* The width of a tab in spaces. The default value is set in
126 * main(). */
127
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000128#ifndef NANO_TINY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000129char *backup_dir = NULL;
130 /* The directory where we store backup files. */
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000131#endif
Chris Allegrettae1f14522001-09-19 03:19:43 +0000132#ifndef DISABLE_OPERATINGDIR
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000133char *operating_dir = NULL;
134 /* The relative path to the operating directory, which we can't
135 * move outside of. */
136char *full_operating_dir = NULL;
137 /* The full path to it. */
Chris Allegrettae1f14522001-09-19 03:19:43 +0000138#endif
139
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000140#ifndef DISABLE_SPELLER
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000141char *alt_speller = NULL;
142 /* The command to use for the alternate spell checker. */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000143#endif
144
Chris Allegretta8ce24132001-04-30 11:28:46 +0000145#ifdef ENABLE_COLOR
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000146syntaxtype *syntaxes = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000147 /* The global list of color syntaxes. */
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000148char *syntaxstr = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000149 /* The color syntax name specified on the command line. */
Chris Allegrettafd265af2009-02-06 03:41:02 +0000150
Chris Allegretta8ce24132001-04-30 11:28:46 +0000151#endif
152
Chris Allegrettafd265af2009-02-06 03:41:02 +0000153bool edit_refresh_needed = NULL;
154 /* Did a command mangle enough of the buffer refresh that we
155 should repaint the screen */
156
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000157const shortcut *currshortcut;
158 /* The current shortcut list we're using. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000159int currmenu;
160 /* The currently loaded menu */
161
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000162sc *sclist = NULL;
163 /* New shortcut key struct */
164subnfunc *allfuncs = NULL;
165 /* New struct for the function list */
166
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000167#ifndef NANO_TINY
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000168filestruct *search_history = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000169 /* The search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000170filestruct *searchage = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000171 /* The top of the search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000172filestruct *searchbot = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000173 /* The bottom of the search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000174filestruct *replace_history = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000175 /* The replace string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000176filestruct *replaceage = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000177 /* The top of the replace string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000178filestruct *replacebot = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000179 /* The bottom of the replace string history list. */
Chris Allegretta5beed502003-01-05 20:41:21 +0000180#endif
181
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +0000182/* Regular expressions. */
Chris Allegretta805c26d2000-09-06 13:39:17 +0000183#ifdef HAVE_REGEX_H
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000184regex_t search_regexp;
185 /* The compiled regular expression to use in searches. */
186regmatch_t regmatches[10];
187 /* The match positions for parenthetical subexpressions, 10
188 * maximum, used in regular expression searches. */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000189#endif
Chris Allegretta3533a342002-03-24 23:19:32 +0000190
David Lawrence Ramsey4d72de72006-04-12 15:27:40 +0000191int reverse_attr = A_REVERSE;
192 /* The curses attribute we use for reverse video. */
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000193
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000194char *homedir = NULL;
David Lawrence Ramseyc1c818e2006-05-14 18:22:01 +0000195 /* The user's home directory, from $HOME or /etc/passwd. */
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000196
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000197/* Return the number of entries in the shortcut list s for a given menu. */
198size_t length_of_list(int menu)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000199{
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000200 subnfunc *f;
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000201 size_t i = 0;
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000202
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000203 for (f = allfuncs; f != NULL; f = f->next)
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000204 if ((f->menus & menu) != 0
205#ifndef DISABLE_HELP
206 && strlen(f->help) > 0
207#endif
208 ) {
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000209 i++;
210 }
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000211 return i;
212}
213
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000214/* Set type of function based on the string */
215function_type strtokeytype(char *str)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000216{
Chris Allegretta17436ce2008-03-11 03:03:53 +0000217 if (str[0] == 'M' || str[0] == 'm')
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000218 return META;
Chris Allegretta17436ce2008-03-11 03:03:53 +0000219 else if (str[0] == '^')
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000220 return CONTROL;
Chris Allegretta17436ce2008-03-11 03:03:53 +0000221 else if (str[0] == 'F' || str[0] == 'F')
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000222 return FKEY;
Chris Allegretta17436ce2008-03-11 03:03:53 +0000223 else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000224 return RAW;
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000225}
226
227/* Add a string to the new function list strict.
228 Does not allow updates, yet anyway */
Chris Allegrettaa1171632009-01-19 19:10:39 +0000229void add_to_funcs(short func, int menus, const char *desc, const char *help,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000230 bool blank_after, bool viewok)
231{
232 subnfunc *f;
233
234 if (allfuncs == NULL) {
Chris Allegrettaf86fa862009-02-25 04:32:15 +0000235 allfuncs = (subnfunc *) nmalloc(sizeof(subnfunc));
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000236 f = allfuncs;
237 } else {
238 for (f = allfuncs; f->next != NULL; f = f->next)
239 ;
240 f->next = (subnfunc *)nmalloc(sizeof(subnfunc));
241 f = f->next;
242 }
243 f->next = NULL;
244 f->scfunc = func;
245 f->menus = menus;
246 f->desc = desc;
247 f->viewok = viewok;
Chris Allegretta1d778232008-08-30 21:00:00 +0000248#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000249 f->help = help;
250 f->blank_after = blank_after;
251#endif
252
253#ifdef DEBUG
254 fprintf(stderr, "Added func \"%s\"", f->desc);
255#endif
256}
257
Chris Allegrettaa1171632009-01-19 19:10:39 +0000258const sc *first_sc_for(int menu, short func) {
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000259 const sc *s;
Chris Allegrettab775c072008-03-09 05:07:37 +0000260 const sc *metasc = NULL;
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000261
262 for (s = sclist; s != NULL; s = s->next) {
263 if ((s->menu & menu) && s->scfunc == func) {
Chris Allegrettab775c072008-03-09 05:07:37 +0000264 /* try to use a meta sequence as a last resort. Otherwise
265 we will run into problems when we try and handle things like
266 the arrow keys, home, etc, if for some reason the user bound
267 them to a meta sequence first *shrug* */
268 if (s->type == META) {
269 metasc = s;
270 continue;
271 } /* otherwise it was something else, use it */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000272 return s;
273 }
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000274 }
275
Chris Allegrettab775c072008-03-09 05:07:37 +0000276 /* If we're here we may have found only meta sequences, if so use one */
277 if (metasc)
Chris Allegretta17436ce2008-03-11 03:03:53 +0000278 return metasc;
Chris Allegrettab775c072008-03-09 05:07:37 +0000279
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000280#ifdef DEBUG
Chris Allegrettae347efb2008-03-09 02:52:40 +0000281 fprintf(stderr, "Whoops, returning null given func %ld in menu %d\n", (long) func, menu);
David Lawrence Ramseybd28ee42006-07-25 21:13:30 +0000282#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000283 /* Otherwise... */
284 return NULL;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000285}
286
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000287
288/* Add a string to the new shortcut list implementation
289 Allows updates to existing entries in the list */
Chris Allegrettaa1171632009-01-19 19:10:39 +0000290void add_to_sclist(int menu, char *scstring, short func, int toggle, int execute)
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000291{
292 sc *s;
293
294 if (sclist == NULL) {
Chris Allegrettaf86fa862009-02-25 04:32:15 +0000295 sclist = (sc *) nmalloc(sizeof(sc));
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000296 s = sclist;
297 s->next = NULL;
298 } else {
299 for (s = sclist; s->next != NULL; s = s->next)
300 if (s->menu == menu && s->keystr == scstring)
301 break;
302
303 if (s->menu != menu || s->keystr != scstring) { /* i.e. this is not a replace... */
304#ifdef DEBUG
305 fprintf(stderr, "No match found...\n");
306#endif
307 s->next = (sc *)nmalloc(sizeof(sc));
308 s = s->next;
309 s->next = NULL;
310 }
311 }
312
313 s->type = strtokeytype(scstring);
314 s->menu = menu;
315 s->toggle = toggle;
316 s->keystr = scstring;
317 s->scfunc = func;
318 s->execute = execute;
319 assign_keyinfo(s);
320
321#ifdef DEBUG
322 fprintf(stderr, "list val = %d\n", (int) s->menu);
323 fprintf(stderr, "Hey, set sequence to %d for shortcut \"%s\"\n", s->seq, scstring);
324#endif
325}
326
Chris Allegrettae347efb2008-03-09 02:52:40 +0000327/* Return the given menu's first shortcut sequence, or the default value
328 (2nd arg). Assumes currmenu for the menu to check*/
Chris Allegrettaa1171632009-01-19 19:10:39 +0000329int sc_seq_or (short func, int defaultval)
Chris Allegrettae347efb2008-03-09 02:52:40 +0000330{
331 const sc *s = first_sc_for(currmenu, func);
332
333 if (s)
334 return s->seq;
335 /* else */
336 return defaultval;
337
338}
339
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000340/* Assign the info to the shortcut struct
341 Assumes keystr is already assigned, naturally */
342void assign_keyinfo(sc *s)
343{
344 if (s->type == CONTROL) {
345 assert(strlen(s->keystr) > 1);
346 s->seq = s->keystr[1] - 64;
347 } else if (s->type == META) {
348 assert(strlen(s->keystr) > 2);
349 s->seq = tolower((int) s->keystr[2]);
350 } else if (s->type == FKEY) {
351 assert(strlen(s->keystr) > 1);
352 s->seq = KEY_F0 + atoi(&s->keystr[1]);
353 } else /* raw */
354 s->seq = (int) s->keystr[0];
Chris Allegretta9b422202008-03-05 17:15:33 +0000355
356 /* Override some keys which don't bind as nicely as we'd like */
357 if (s->type == CONTROL && (!strcasecmp(&s->keystr[1], "space")))
358 s->seq = 0;
359 else if (s->type == META && (!strcasecmp(&s->keystr[2], "space")))
360 s->seq = (int) ' ';
Chris Allegretta17436ce2008-03-11 03:03:53 +0000361 else if (s->type == RAW && (!strcasecmp(s->keystr, "kup")))
362 s->seq = KEY_UP;
363 else if (s->type == RAW && (!strcasecmp(s->keystr, "kdown")))
364 s->seq = KEY_DOWN;
365 else if (s->type == RAW && (!strcasecmp(s->keystr, "kleft")))
366 s->seq = KEY_LEFT;
367 else if (s->type == RAW && (!strcasecmp(s->keystr, "kright")))
368 s->seq = KEY_RIGHT;
369 else if (s->type == RAW && (!strcasecmp(s->keystr, "kinsert")))
370 s->seq = KEY_IC;
371 else if (s->type == RAW && (!strcasecmp(s->keystr, "kdel")))
372 s->seq = KEY_DC;
Chris Allegrettaeb643142008-03-12 04:44:14 +0000373 else if (s->type == RAW && (!strcasecmp(s->keystr, "kbsp")))
374 s->seq = KEY_BACKSPACE;
375 else if (s->type == RAW && (!strcasecmp(s->keystr, "kenter")))
376 s->seq = KEY_ENTER;
Chris Allegretta17436ce2008-03-11 03:03:53 +0000377 else if (s->type == RAW && (!strcasecmp(s->keystr, "kpup")))
378 s->seq = KEY_PPAGE;
379 else if (s->type == RAW && (!strcasecmp(s->keystr, "kpdown")))
380 s->seq = KEY_NPAGE;
381#ifdef KEY_HOME
382 else if (s->type == RAW && (!strcasecmp(s->keystr, "khome")))
383 s->seq = KEY_HOME;
384#endif
385#ifdef KEY_END
386 else if (s->type == RAW && (!strcasecmp(s->keystr, "kend")))
387 s->seq = KEY_END;
388#endif
Chris Allegretta9b422202008-03-05 17:15:33 +0000389
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000390}
391
392#ifdef DEBUG
393
394void print_sclist(void)
395{
396 sc *s;
397 const subnfunc *f;
398
399 for (s = sclist; s->next != NULL; s = s->next) {
400 f = sctofunc(s);
401 if (f)
Chris Allegrettae347efb2008-03-09 02:52:40 +0000402 fprintf(stderr, "Shortcut \"%s\", function: %s, menus %d\n", s->keystr, f->desc, f->menus);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000403 else
404 fprintf(stderr, "Hmm, didnt find a func for \"%s\"\n", s->keystr);
405 }
406
407}
408#endif
409
410
411/* Stuff we need to make at least static here so we can access it below */
412const char *cancel_msg = N_("Cancel");
413
414#ifndef NANO_TINY
415const char *case_sens_msg = N_("Case Sens");
416const char *backwards_msg = N_("Backwards");
417#endif
418
419#ifdef HAVE_REGEX_H
420const char *regexp_msg = N_("Regexp");
421#endif
422
423/* Stuff we want to just stun out if we're in TINY mode */
424#ifdef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000425const char *gototext_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000426const char *do_para_begin_msg = "";
427const char *do_para_end_msg = "";
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000428const char *case_sens_msg = "";
429const char *backwards_msg = "";
430const char *do_cut_till_end = "";
431const char *dos_format_msg = "";
432const char *mac_format_msg = "";
433const char *append_msg = "";
434const char *prepend_msg = "";
435const char *backup_file_msg = "";
436const char *to_files_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000437const char *first_file_msg = "";
438const char *whereis_next_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000439const char *last_file_msg = "";
440const char *new_buffer_msg = "";
441const char *goto_dir_msg;
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000442const char *ext_cmd_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000443
444#else
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000445/* TRANSLATORS: Try to keep the next five strings at most 10 characters. */
Chris Allegrettae347efb2008-03-09 02:52:40 +0000446const char *prev_history_msg = N_("PrevHstory");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000447const char *next_history_msg = N_("NextHstory");
448const char *replace_msg = N_("Replace");
449const char *no_replace_msg = N_("No Replace");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000450const char *gototext_msg = N_("Go To Text");
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000451/* TRANSLATORS: Try to keep the next three strings at most 12 characters. */
Chris Allegrettae347efb2008-03-09 02:52:40 +0000452const char *whereis_next_msg = N_("WhereIs Next");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000453#ifndef DISABLE_BROWSER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000454const char *first_file_msg = N_("First File");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000455const char *last_file_msg = N_("Last File");
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000456/* TRANSLATORS: Try to keep the next nine strings at most 16 characters. */
457const char *to_files_msg = N_("To Files");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000458#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000459const char *dos_format_msg = N_("DOS Format");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000460const char *mac_format_msg = N_("Mac Format");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000461const char *append_msg = N_("Append");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000462const char *prepend_msg = N_("Prepend");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000463const char *backup_file_msg = N_("Backup File");
Chris Allegrettaeb643142008-03-12 04:44:14 +0000464const char *ext_cmd_msg = N_("Execute Command");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000465#ifdef ENABLE_MULTIBUFFER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000466const char *new_buffer_msg = N_("New Buffer");
467#endif
Chris Allegrettae347efb2008-03-09 02:52:40 +0000468const char *goto_dir_msg = N_("Go To Dir");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000469
Chris Allegrettae347efb2008-03-09 02:52:40 +0000470#endif /* NANO_TINY */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000471
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000472/* Initialize all shortcut lists. If unjustify is TRUE, replace the
473 * Uncut shortcut in the main shortcut list with UnJustify. */
David Lawrence Ramsey1f1ebb82004-11-11 21:50:01 +0000474void shortcut_init(bool unjustify)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000475{
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000476 /* TRANSLATORS: Try to keep the following strings at most 10 characters. */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000477 const char *get_help_msg = N_("Get Help");
478 const char *exit_msg = N_("Exit");
David Lawrence Ramseye38b8082006-03-30 07:03:04 +0000479 const char *whereis_msg = N_("Where Is");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000480 const char *prev_page_msg = N_("Prev Page");
481 const char *next_page_msg = N_("Next Page");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000482 const char *first_line_msg = N_("First Line");
483 const char *last_line_msg = N_("Last Line");
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000484 const char *suspend_msg = N_("Suspend");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000485#ifndef DISABLE_JUSTIFY
486 const char *beg_of_par_msg = N_("Beg of Par");
487 const char *end_of_par_msg = N_("End of Par");
488 const char *fulljstify_msg = N_("FullJstify");
489#endif
David Lawrence Ramsey81378762006-04-24 20:53:43 +0000490 const char *refresh_msg = N_("Refresh");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000491 const char *insert_file_msg = N_("Insert File");
Chris Allegrettae347efb2008-03-09 02:52:40 +0000492 const char *go_to_line_msg = N_("Go To Line");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000493
Chris Allegretta1d778232008-08-30 21:00:00 +0000494#ifndef DISABLE_JUSTIFY
495 const char *nano_justify_msg = N_("Justify the current paragraph");
496#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000497#ifndef DISABLE_HELP
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000498 /* TRANSLATORS: The next long series of strings are shortcut descriptions;
499 * they are best kept shorter than 56 characters, but may be longer. */
David Lawrence Ramsey804e1072006-03-29 19:43:32 +0000500 const char *nano_cancel_msg = N_("Cancel the current function");
David Lawrence Ramsey57c9afb2006-04-14 20:21:45 +0000501 const char *nano_help_msg = N_("Display this help text");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000502 const char *nano_exit_msg =
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000503#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000504 N_("Close the current file buffer / Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000505#else
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000506 N_("Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000507#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000508 ;
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000509 const char *nano_writeout_msg =
510 N_("Write the current file to disk");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000511 const char *nano_insert_msg =
512 N_("Insert another file into the current one");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000513 const char *nano_whereis_msg =
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000514 N_("Search for a string or a regular expression");
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000515 const char *nano_prevpage_msg = N_("Go to previous screen");
516 const char *nano_nextpage_msg = N_("Go to next screen");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000517 const char *nano_cut_msg =
518 N_("Cut the current line and store it in the cutbuffer");
519 const char *nano_uncut_msg =
520 N_("Uncut from the cutbuffer into the current line");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000521 const char *nano_cursorpos_msg =
David Lawrence Ramseyf50bd4b2006-04-14 20:15:44 +0000522 N_("Display the position of the cursor");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000523 const char *nano_spell_msg =
524 N_("Invoke the spell checker, if available");
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000525 const char *nano_replace_msg =
526 N_("Replace a string or a regular expression");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000527 const char *nano_gotoline_msg = N_("Go to line and column number");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000528#ifndef NANO_TINY
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000529 const char *nano_mark_msg = N_("Mark text at the cursor position");
530 const char *nano_whereis_next_msg = N_("Repeat last search");
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000531 const char *nano_copy_msg =
532 N_("Copy the current line and store it in the cutbuffer");
David Lawrence Ramseyaee00d42006-07-05 18:42:22 +0000533 const char *nano_indent_msg = N_("Indent the current line");
534 const char *nano_unindent_msg = N_("Unindent the current line");
Chris Allegretta07fcc4c2008-07-10 20:13:04 +0000535 const char *nano_undo_msg = N_("Undo the last operation");
536 const char *nano_redo_msg = N_("Redo the last undone operation");
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000537#endif
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000538 const char *nano_forward_msg = N_("Go forward one character");
539 const char *nano_back_msg = N_("Go back one character");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000540#ifndef NANO_TINY
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000541 const char *nano_nextword_msg = N_("Go forward one word");
542 const char *nano_prevword_msg = N_("Go back one word");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000543#endif
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000544 const char *nano_prevline_msg = N_("Go to previous line");
545 const char *nano_nextline_msg = N_("Go to next line");
546 const char *nano_home_msg = N_("Go to beginning of current line");
547 const char *nano_end_msg = N_("Go to end of current line");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000548#ifndef DISABLE_JUSTIFY
549 const char *nano_parabegin_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000550 N_("Go to beginning of paragraph; then of previous paragraph");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000551 const char *nano_paraend_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000552 N_("Go just beyond end of paragraph; then of next paragraph");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000553#endif
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000554 const char *nano_firstline_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000555 N_("Go to the first line of the file");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000556 const char *nano_lastline_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000557 N_("Go to the last line of the file");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000558#ifndef NANO_TINY
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000559 const char *nano_bracket_msg = N_("Go to the matching bracket");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000560 const char *nano_scrollup_msg =
561 N_("Scroll up one line without scrolling the cursor");
562 const char *nano_scrolldown_msg =
563 N_("Scroll down one line without scrolling the cursor");
564#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000565#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +0000566 const char *nano_prevfile_msg =
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000567 N_("Switch to the previous file buffer");
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +0000568 const char *nano_nextfile_msg =
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000569 N_("Switch to the next file buffer");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000570#endif
David Lawrence Ramsey40e05722006-04-23 19:21:12 +0000571 const char *nano_verbatim_msg =
David Lawrence Ramsey939d4232006-04-24 21:00:17 +0000572 N_("Insert the next keystroke verbatim");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000573 const char *nano_tab_msg =
David Lawrence Ramseybf784202006-04-29 13:59:04 +0000574 N_("Insert a tab at the cursor position");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000575 const char *nano_enter_msg =
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000576 N_("Insert a newline at the cursor position");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000577 const char *nano_delete_msg =
578 N_("Delete the character under the cursor");
579 const char *nano_backspace_msg =
580 N_("Delete the character to the left of the cursor");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000581#ifndef NANO_TINY
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000582 const char *nano_cut_till_end_msg =
583 N_("Cut from the cursor position to the end of the file");
584#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000585#ifndef DISABLE_JUSTIFY
586 const char *nano_fulljustify_msg = N_("Justify the entire file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000587#endif
David Lawrence Ramseyc5c52302005-11-15 23:45:29 +0000588#ifndef NANO_TINY
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000589 const char *nano_wordcount_msg =
590 N_("Count the number of words, lines, and characters");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000591#endif
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000592 const char *nano_refresh_msg =
593 N_("Refresh (redraw) the current screen");
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000594 const char *nano_suspend_msg =
595 N_("Suspend the editor (if suspend is enabled)");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000596#ifndef NANO_TINY
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000597 const char *nano_case_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000598 N_("Toggle the case sensitivity of the search");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000599 const char *nano_reverse_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000600 N_("Reverse the direction of the search");
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000601#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000602#ifdef HAVE_REGEX_H
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000603 const char *nano_regexp_msg =
604 N_("Toggle the use of regular expressions");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000605#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000606#ifndef NANO_TINY
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000607 const char *nano_prev_history_msg =
David Lawrence Ramsey7b0531a2006-07-31 01:30:31 +0000608 N_("Recall the previous search/replace string");
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000609 const char *nano_next_history_msg =
David Lawrence Ramsey7b0531a2006-07-31 01:30:31 +0000610 N_("Recall the next search/replace string");
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000611#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000612#ifndef DISABLE_BROWSER
613 const char *nano_tofiles_msg = N_("Go to file browser");
614#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000615#ifndef NANO_TINY
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000616 const char *nano_dos_msg = N_("Toggle the use of DOS format");
617 const char *nano_mac_msg = N_("Toggle the use of Mac format");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000618#endif
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000619 const char *nano_append_msg = N_("Toggle appending");
620 const char *nano_prepend_msg = N_("Toggle prepending");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000621#ifndef NANO_TINY
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000622 const char *nano_backup_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000623 N_("Toggle backing up of the original file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000624 const char *nano_execute_msg = N_("Execute external command");
625#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000626#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000627 const char *nano_multibuffer_msg =
628 N_("Toggle the use of a new buffer");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000629#endif
630#ifndef DISABLE_BROWSER
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000631 const char *nano_exitbrowser_msg = N_("Exit from the file browser");
David Lawrence Ramseye38b8082006-03-30 07:03:04 +0000632 const char *nano_firstfile_msg =
633 N_("Go to the first file in the list");
634 const char *nano_lastfile_msg =
635 N_("Go to the last file in the list");
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000636 const char *nano_gotodir_msg = N_("Go to directory");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000637
Chris Allegretta2bef1822001-09-28 19:53:11 +0000638#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000639#endif /* !DISABLE_HELP */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000640
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000641#ifndef DISABLE_HELP
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000642#define IFSCHELP(help) help
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000643#else
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000644#define IFSCHELP(help) ""
Chris Allegrettadab017e2002-04-23 10:56:06 +0000645#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000646
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000647 while (allfuncs != NULL) {
648 subnfunc *f = allfuncs;
649 allfuncs = (allfuncs)->next;
650 free(f);
651 }
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000652
Chris Allegrettaa1171632009-01-19 19:10:39 +0000653 add_to_funcs(DO_HELP_VOID, MALL, get_help_msg, IFSCHELP(nano_help_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000654 FALSE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000655
Chris Allegrettaa1171632009-01-19 19:10:39 +0000656 add_to_funcs( CANCEL_MSG,
Chris Allegrettacc593832008-03-19 02:32:48 +0000657 (MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR|MYESNO),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000658 cancel_msg, IFSCHELP(nano_cancel_msg), FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000659
Chris Allegrettaa1171632009-01-19 19:10:39 +0000660 add_to_funcs(DO_EXIT, MMAIN,
Chris Allegretta355fbe52001-07-14 19:32:47 +0000661#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000662 /* TRANSLATORS: Try to keep this at most 10 characters. */
David Lawrence Ramsey017dde22006-03-24 05:28:03 +0000663 openfile != NULL && openfile != openfile->next ? N_("Close") :
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000664#endif
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000665 exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000666
Chris Allegrettaa1171632009-01-19 19:10:39 +0000667 add_to_funcs(DO_EXIT, MHELP, exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW);
Chris Allegretta90ee8ee2008-03-20 04:45:55 +0000668
Chris Allegrettadcd19c92008-03-20 04:51:26 +0000669#ifndef DISABLE_BROWSER
Chris Allegrettaa1171632009-01-19 19:10:39 +0000670 add_to_funcs(DO_EXIT, MBROWSER, exit_msg, IFSCHELP(nano_exitbrowser_msg), FALSE, VIEW);
Chris Allegrettadcd19c92008-03-20 04:51:26 +0000671#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000672
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000673 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegrettaa1171632009-01-19 19:10:39 +0000674 add_to_funcs(DO_WRITEOUT_VOID, MMAIN, N_("WriteOut"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000675 IFSCHELP(nano_writeout_msg), FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000676
David Lawrence Ramseya539fce2004-06-29 00:43:56 +0000677#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000678 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegrettaa1171632009-01-19 19:10:39 +0000679 add_to_funcs(DO_JUSTIFY_VOID, MMAIN, N_("Justify"),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000680 nano_justify_msg, TRUE, NOVIEW);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000681#endif
Chris Allegretta32da4562002-01-02 15:12:21 +0000682
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000683 /* We allow inserting files in view mode if multibuffers are
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000684 * available, so that we can view multiple files. If we're using
685 * restricted mode, inserting files is disabled, since it allows
686 * reading from or writing to files not specified on the command
687 * line. */
Chris Allegrettaa1171632009-01-19 19:10:39 +0000688 add_to_funcs(!ISSET(RESTRICTED) ? DO_INSERTFILE_VOID : NANO_DISABLED_MSG,
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000689 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000690 MMAIN, N_("Read File"), IFSCHELP(nano_insert_msg), FALSE,
Chris Allegretta32da4562002-01-02 15:12:21 +0000691#ifdef ENABLE_MULTIBUFFER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000692 VIEW);
Chris Allegretta32da4562002-01-02 15:12:21 +0000693#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000694 NOVIEW);
Chris Allegretta32da4562002-01-02 15:12:21 +0000695#endif
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000696
Chris Allegrettaa1171632009-01-19 19:10:39 +0000697 add_to_funcs(DO_SEARCH, MMAIN|MBROWSER, whereis_msg,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000698 IFSCHELP(nano_whereis_msg), FALSE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000699
Chris Allegrettaa1171632009-01-19 19:10:39 +0000700 add_to_funcs(DO_PAGE_UP, MMAIN|MHELP,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000701 prev_page_msg, IFSCHELP(nano_prevpage_msg), FALSE, VIEW);
Chris Allegrettaa1171632009-01-19 19:10:39 +0000702 add_to_funcs(DO_PAGE_DOWN, MMAIN|MHELP,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000703 next_page_msg, IFSCHELP(nano_nextpage_msg), TRUE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000704
Chris Allegretta07fcc4c2008-07-10 20:13:04 +0000705
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000706 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegrettaa1171632009-01-19 19:10:39 +0000707 add_to_funcs(DO_CUT_TEXT_VOID, MMAIN, N_("Cut Text"), IFSCHELP(nano_cut_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000708 FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000709
Chris Allegretta07798352000-11-27 22:58:23 +0000710 if (unjustify)
David Lawrence Ramseyed467e52006-07-03 18:40:53 +0000711 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegrettaa1171632009-01-19 19:10:39 +0000712 add_to_funcs(DO_UNCUT_TEXT, MMAIN, N_("UnJustify"), "",
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000713 FALSE, NOVIEW);
714
Chris Allegretta07798352000-11-27 22:58:23 +0000715 else
David Lawrence Ramseyed467e52006-07-03 18:40:53 +0000716 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegrettaa1171632009-01-19 19:10:39 +0000717 add_to_funcs(DO_UNCUT_TEXT, MMAIN, N_("UnCut Text"), IFSCHELP(nano_uncut_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000718 FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000719
Chris Allegrettae347efb2008-03-09 02:52:40 +0000720#ifndef NANO_TINY
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000721 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegrettaa1171632009-01-19 19:10:39 +0000722 add_to_funcs(DO_CURSORPOS_VOID, MMAIN, N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000723 FALSE, VIEW);
Chris Allegrettae347efb2008-03-09 02:52:40 +0000724#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000725
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000726 /* If we're using restricted mode, spell checking is disabled
727 * because it allows reading from or writing to files not specified
728 * on the command line. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000729#ifndef DISABLE_SPELLER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000730 if (!ISSET(RESTRICTED))
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000731 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegrettaa1171632009-01-19 19:10:39 +0000732 add_to_funcs(DO_SPELL, MMAIN, N_("To Spell"), IFSCHELP(nano_spell_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000733 TRUE, NOVIEW);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000734#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000735
Chris Allegrettaa1171632009-01-19 19:10:39 +0000736 add_to_funcs(DO_FIRST_LINE,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000737 (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP),
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000738 first_line_msg, IFSCHELP(nano_firstline_msg), FALSE, VIEW);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000739
Chris Allegrettaa1171632009-01-19 19:10:39 +0000740 add_to_funcs(DO_LAST_LINE,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000741 (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000742 last_line_msg, IFSCHELP(nano_lastline_msg), TRUE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000743
744
Chris Allegrettaa1171632009-01-19 19:10:39 +0000745 add_to_funcs(DO_GOTOLINECOLUMN_VOID, (MMAIN|MWHEREIS),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000746 go_to_line_msg, IFSCHELP(nano_gotoline_msg), FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000747
Chris Allegrettae347efb2008-03-09 02:52:40 +0000748#ifdef NANO_TINY
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000749 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegrettaa1171632009-01-19 19:10:39 +0000750 add_to_funcs(DO_CURSORPOS_VOID, MMAIN, N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg),
Chris Allegrettae347efb2008-03-09 02:52:40 +0000751 FALSE, VIEW);
752#endif
753
754
Chris Allegrettaa1171632009-01-19 19:10:39 +0000755 add_to_funcs(DO_REPLACE, (MMAIN|MWHEREIS), replace_msg, IFSCHELP(nano_replace_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000756
David Lawrence Ramseyf1e56272006-05-22 18:28:20 +0000757#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000758 FALSE,
David Lawrence Ramseyf1e56272006-05-22 18:28:20 +0000759#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000760 TRUE,
David Lawrence Ramseyf1e56272006-05-22 18:28:20 +0000761#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000762 NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000763
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000764#ifndef NANO_TINY
David Lawrence Ramseyefb4b0a2006-04-19 14:09:01 +0000765
Chris Allegrettaa1171632009-01-19 19:10:39 +0000766 add_to_funcs(DO_MARK, MMAIN, N_("Mark Text"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000767 IFSCHELP(nano_mark_msg), FALSE, VIEW);
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000768
Chris Allegrettaa1171632009-01-19 19:10:39 +0000769 add_to_funcs(DO_RESEARCH, (MMAIN|MBROWSER), whereis_next_msg,
Chris Allegretta1d778232008-08-30 21:00:00 +0000770 IFSCHELP(nano_whereis_next_msg), TRUE, VIEW);
David Lawrence Ramseyf85001a2006-04-28 13:19:56 +0000771
Chris Allegrettaa1171632009-01-19 19:10:39 +0000772 add_to_funcs(DO_COPY_TEXT, MMAIN, N_("Copy Text"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000773 IFSCHELP(nano_copy_msg), FALSE, NOVIEW);
David Lawrence Ramseyf85001a2006-04-28 13:19:56 +0000774
Chris Allegrettaa1171632009-01-19 19:10:39 +0000775 add_to_funcs(DO_INDENT_VOID, MMAIN, N_("Indent Text"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000776 IFSCHELP(nano_indent_msg), FALSE, NOVIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000777
Chris Allegrettaa1171632009-01-19 19:10:39 +0000778 add_to_funcs(DO_UNINDENT, MMAIN, N_("Unindent Text"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000779 IFSCHELP(nano_unindent_msg), FALSE, NOVIEW);
Chris Allegretta07fcc4c2008-07-10 20:13:04 +0000780
Chris Allegrettaa48507d2009-08-14 03:18:29 +0000781 if (ISSET(UNDOABLE)) {
Chris Allegrettaad37e672009-07-12 03:36:58 +0000782 add_to_funcs(DO_UNDO, MMAIN, N_("Undo"),
783 IFSCHELP(nano_undo_msg), FALSE, NOVIEW);
Chris Allegretta07fcc4c2008-07-10 20:13:04 +0000784
Chris Allegrettaad37e672009-07-12 03:36:58 +0000785 add_to_funcs(DO_REDO, MMAIN, N_("Redo"),
786 IFSCHELP(nano_redo_msg), TRUE, NOVIEW);
787 }
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000788
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000789#endif
790
Chris Allegrettaa1171632009-01-19 19:10:39 +0000791 add_to_funcs(DO_PAGE_UP, MBROWSER,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000792 prev_page_msg, IFSCHELP(nano_prevpage_msg), FALSE, VIEW);
Chris Allegrettaa1171632009-01-19 19:10:39 +0000793 add_to_funcs(DO_PAGE_DOWN, MBROWSER,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000794 next_page_msg, IFSCHELP(nano_nextpage_msg), TRUE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000795
Chris Allegrettae347efb2008-03-09 02:52:40 +0000796
Chris Allegrettaa1171632009-01-19 19:10:39 +0000797 add_to_funcs(DO_RIGHT, (MMAIN|MBROWSER), N_("Forward"), IFSCHELP(nano_forward_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000798 FALSE, VIEW);
Chris Allegrettaa1171632009-01-19 19:10:39 +0000799 add_to_funcs(DO_RIGHT, MALL, "", "", FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000800
Chris Allegrettaa1171632009-01-19 19:10:39 +0000801 add_to_funcs(DO_LEFT, (MMAIN|MBROWSER), N_("Back"), IFSCHELP(nano_back_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000802 FALSE, VIEW);
Chris Allegrettaa1171632009-01-19 19:10:39 +0000803 add_to_funcs(DO_LEFT, MALL, "", "", FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000804
805#ifndef NANO_TINY
Chris Allegrettaa1171632009-01-19 19:10:39 +0000806 add_to_funcs(DO_NEXT_WORD_VOID, MMAIN, N_("Next Word"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000807 IFSCHELP(nano_nextword_msg), FALSE, VIEW);
David Lawrence Ramseyc5967552002-06-21 03:20:06 +0000808
Chris Allegrettaa1171632009-01-19 19:10:39 +0000809 add_to_funcs(DO_PREV_WORD_VOID, MMAIN, N_("Prev Word"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000810 IFSCHELP(nano_prevword_msg), FALSE, VIEW);
Chris Allegretta8d990b52001-09-22 22:14:25 +0000811#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000812
Chris Allegrettaa1171632009-01-19 19:10:39 +0000813 add_to_funcs(DO_UP_VOID, (MMAIN|MHELP|MBROWSER), N_("Prev Line"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000814 IFSCHELP(nano_prevline_msg), FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000815
Chris Allegrettaa1171632009-01-19 19:10:39 +0000816 add_to_funcs(DO_DOWN_VOID, (MMAIN|MHELP|MBROWSER), N_("Next Line"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000817 IFSCHELP(nano_nextline_msg), TRUE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000818
Chris Allegrettaa1171632009-01-19 19:10:39 +0000819 add_to_funcs(DO_HOME, MMAIN, N_("Home"), IFSCHELP(nano_home_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000820 FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000821
Chris Allegrettaa1171632009-01-19 19:10:39 +0000822 add_to_funcs(DO_END, MMAIN, N_("End"), IFSCHELP(nano_end_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000823 FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000824
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000825#ifndef DISABLE_JUSTIFY
Chris Allegrettaa1171632009-01-19 19:10:39 +0000826 add_to_funcs(DO_PARA_BEGIN_VOID, (MMAIN|MWHEREIS), beg_of_par_msg,
Chris Allegretta1d778232008-08-30 21:00:00 +0000827 IFSCHELP(nano_parabegin_msg), FALSE, VIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000828
Chris Allegrettaa1171632009-01-19 19:10:39 +0000829 add_to_funcs(DO_PARA_END_VOID, (MMAIN|MWHEREIS), end_of_par_msg,
Chris Allegretta1d778232008-08-30 21:00:00 +0000830 IFSCHELP(nano_paraend_msg), FALSE, VIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000831#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000832
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000833#ifndef NANO_TINY
Chris Allegrettaa1171632009-01-19 19:10:39 +0000834 add_to_funcs(DO_FIND_BRACKET, MMAIN, _("Find Other Bracket"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000835 IFSCHELP(nano_bracket_msg), FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000836
Chris Allegrettaa1171632009-01-19 19:10:39 +0000837 add_to_funcs(DO_SCROLL_UP, MMAIN, N_("Scroll Up"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000838 IFSCHELP(nano_scrollup_msg), FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000839
Chris Allegrettaa1171632009-01-19 19:10:39 +0000840 add_to_funcs(DO_SCROLL_DOWN, MMAIN, N_("Scroll Down"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000841 IFSCHELP(nano_scrolldown_msg), FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000842#endif
David Lawrence Ramseydf453652006-04-21 02:05:09 +0000843
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000844#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaa1171632009-01-19 19:10:39 +0000845 add_to_funcs(SWITCH_TO_PREV_BUFFER_VOID, MMAIN, _("Previous File"),
Chris Allegretta2cca4832008-03-31 06:25:14 +0000846 IFSCHELP(nano_prevfile_msg), FALSE, VIEW);
Chris Allegrettaa1171632009-01-19 19:10:39 +0000847 add_to_funcs(SWITCH_TO_NEXT_BUFFER_VOID, MMAIN, N_("Next File"),
Chris Allegretta2cca4832008-03-31 06:25:14 +0000848 IFSCHELP(nano_nextfile_msg), TRUE, VIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000849#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +0000850
Chris Allegrettaa1171632009-01-19 19:10:39 +0000851 add_to_funcs(DO_VERBATIM_INPUT, MMAIN, N_("Verbatim Input"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000852 IFSCHELP(nano_verbatim_msg), FALSE, NOVIEW);
Chris Allegrettaa1171632009-01-19 19:10:39 +0000853 add_to_funcs(DO_VERBATIM_INPUT, MWHEREIS|MREPLACE|MREPLACE2|MEXTCMD|MSPELL,
Chris Allegrettaaa17df02008-03-17 05:50:04 +0000854 "", "", FALSE, NOVIEW);
855
Chris Allegrettaa1171632009-01-19 19:10:39 +0000856 add_to_funcs(DO_TAB, MMAIN, N_("Tab"), IFSCHELP(nano_tab_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000857 FALSE, NOVIEW);
Chris Allegrettaa1171632009-01-19 19:10:39 +0000858 add_to_funcs(DO_TAB, MALL, "", "", FALSE, NOVIEW);
859 add_to_funcs(DO_ENTER, MMAIN, N_("Enter"), IFSCHELP(nano_enter_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000860 FALSE, NOVIEW);
Chris Allegrettaa1171632009-01-19 19:10:39 +0000861 add_to_funcs(DO_ENTER, MALL, "", "", FALSE, NOVIEW);
862 add_to_funcs(DO_DELETE, MMAIN, N_("Delete"), IFSCHELP(nano_delete_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000863 FALSE, NOVIEW);
Chris Allegrettaa1171632009-01-19 19:10:39 +0000864 add_to_funcs(DO_DELETE, MALL, "", "", FALSE, NOVIEW);
865 add_to_funcs(DO_BACKSPACE, MMAIN, N_("Backspace"), IFSCHELP(nano_backspace_msg),
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000866#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000867 FALSE,
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000868#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000869 TRUE,
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000870#endif
Chris Allegrettaeb643142008-03-12 04:44:14 +0000871 NOVIEW);
872
Chris Allegrettaa1171632009-01-19 19:10:39 +0000873 add_to_funcs(DO_BACKSPACE, MALL, "", "",
Chris Allegrettaeb643142008-03-12 04:44:14 +0000874#ifndef NANO_TINY
875 FALSE,
876#else
877 TRUE,
878#endif
879 NOVIEW);
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000880
David Lawrence Ramsey2ca23562006-04-23 19:15:15 +0000881#ifndef NANO_TINY
Chris Allegrettaa1171632009-01-19 19:10:39 +0000882 add_to_funcs(DO_CUT_TILL_END, MMAIN, N_("CutTillEnd"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000883 IFSCHELP(nano_cut_till_end_msg), TRUE, NOVIEW);
David Lawrence Ramsey2ca23562006-04-23 19:15:15 +0000884#endif
885
Chris Allegrettaa1171632009-01-19 19:10:39 +0000886 add_to_funcs(XON_COMPLAINT, MMAIN, "", "", FALSE, VIEW);
887 add_to_funcs(XOFF_COMPLAINT, MMAIN, "", "", FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000888
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000889#ifndef DISABLE_JUSTIFY
Chris Allegrettaa1171632009-01-19 19:10:39 +0000890 add_to_funcs(DO_FULL_JUSTIFY, (MMAIN|MWHEREIS), fulljstify_msg,
Chris Allegretta1d778232008-08-30 21:00:00 +0000891 IFSCHELP(nano_fulljustify_msg), FALSE, NOVIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000892#endif
893
David Lawrence Ramseyc5c52302005-11-15 23:45:29 +0000894#ifndef NANO_TINY
Chris Allegrettaa1171632009-01-19 19:10:39 +0000895 add_to_funcs(DO_WORDLINECHAR_COUNT, MMAIN, N_("Word Count"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000896 IFSCHELP(nano_wordcount_msg), FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000897#endif
David Lawrence Ramseyefb4b0a2006-04-19 14:09:01 +0000898
Chris Allegrettaa1171632009-01-19 19:10:39 +0000899 add_to_funcs(TOTAL_REFRESH, (MMAIN|MHELP), refresh_msg,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000900 IFSCHELP(nano_refresh_msg), FALSE, VIEW);
901
Chris Allegrettaa1171632009-01-19 19:10:39 +0000902 add_to_funcs(DO_SUSPEND_VOID, MMAIN, suspend_msg,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000903 IFSCHELP(nano_suspend_msg), TRUE, VIEW);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000904
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000905#ifndef NANO_TINY
Chris Allegrettaa1171632009-01-19 19:10:39 +0000906 add_to_funcs( CASE_SENS_MSG,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000907 (MWHEREIS|MREPLACE|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +0000908 case_sens_msg, IFSCHELP(nano_case_msg), FALSE, VIEW);
Chris Allegretta658399a2001-06-14 02:54:22 +0000909
Chris Allegrettaa1171632009-01-19 19:10:39 +0000910 add_to_funcs( BACKWARDS_MSG,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000911 (MWHEREIS|MREPLACE|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +0000912 backwards_msg, IFSCHELP(nano_reverse_msg), FALSE, VIEW);
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000913#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000914
Chris Allegretta658399a2001-06-14 02:54:22 +0000915#ifdef HAVE_REGEX_H
Chris Allegrettaa1171632009-01-19 19:10:39 +0000916 add_to_funcs( REGEXP_MSG,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000917 (MWHEREIS|MREPLACE|MWHEREISFILE),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000918 regexp_msg, IFSCHELP(nano_regexp_msg), FALSE, VIEW);
Chris Allegretta658399a2001-06-14 02:54:22 +0000919#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000920
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000921#ifndef NANO_TINY
Chris Allegrettaa1171632009-01-19 19:10:39 +0000922 add_to_funcs( PREV_HISTORY_MSG,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000923 (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +0000924 prev_history_msg, IFSCHELP(nano_prev_history_msg), FALSE, VIEW);
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000925
Chris Allegrettaa1171632009-01-19 19:10:39 +0000926 add_to_funcs( NEXT_HISTORY_MSG,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000927 (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +0000928 next_history_msg, IFSCHELP(nano_next_history_msg), FALSE, VIEW);
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000929#endif
David Lawrence Ramsey02085d72004-11-07 16:04:18 +0000930
Chris Allegrettaa1171632009-01-19 19:10:39 +0000931 add_to_funcs( NO_REPLACE_MSG, MREPLACE,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000932 no_replace_msg, IFSCHELP(nano_whereis_msg), FALSE, VIEW);
Chris Allegretta5f36c372001-07-16 00:48:53 +0000933
Chris Allegrettaa1171632009-01-19 19:10:39 +0000934 add_to_funcs( GOTOTEXT_MSG, MGOTOLINE,
Chris Allegretta10f868d2008-03-14 04:08:51 +0000935 gototext_msg, IFSCHELP(nano_whereis_msg), TRUE, VIEW);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000936
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000937#ifndef DISABLE_BROWSER
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000938 if (!ISSET(RESTRICTED))
Chris Allegrettaa1171632009-01-19 19:10:39 +0000939 add_to_funcs( TO_FILES_MSG,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000940 (MGOTOLINE|MINSERTFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +0000941 to_files_msg, IFSCHELP(nano_tofiles_msg), FALSE, VIEW);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000942#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000943
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000944#ifndef NANO_TINY
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000945 /* If we're using restricted mode, the DOS format, Mac format,
946 * append, prepend, and backup toggles are disabled. The first and
947 * second are useless since inserting files is disabled, the third
948 * and fourth are disabled because they allow writing to files not
949 * specified on the command line, and the fifth is useless since
950 * backups are disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000951 if (!ISSET(RESTRICTED))
Chris Allegrettaa1171632009-01-19 19:10:39 +0000952 add_to_funcs( DOS_FORMAT_MSG, MWRITEFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +0000953 dos_format_msg, IFSCHELP(nano_dos_msg), FALSE, NOVIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000954
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000955 if (!ISSET(RESTRICTED))
Chris Allegrettaa1171632009-01-19 19:10:39 +0000956 add_to_funcs( MAC_FORMAT_MSG, MWRITEFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +0000957 mac_format_msg, IFSCHELP(nano_mac_msg), FALSE, NOVIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000958
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000959 if (!ISSET(RESTRICTED))
Chris Allegrettaa1171632009-01-19 19:10:39 +0000960 add_to_funcs( APPEND_MSG, MWRITEFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +0000961 append_msg, IFSCHELP(nano_append_msg), FALSE, NOVIEW);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000962
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000963 if (!ISSET(RESTRICTED))
Chris Allegrettaa1171632009-01-19 19:10:39 +0000964 add_to_funcs( PREPEND_MSG, MWRITEFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +0000965 prepend_msg, IFSCHELP(nano_prepend_msg), FALSE, NOVIEW);
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000966
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000967 if (!ISSET(RESTRICTED))
Chris Allegrettaa1171632009-01-19 19:10:39 +0000968 add_to_funcs( BACKUP_FILE_MSG, MWRITEFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +0000969 backup_file_msg, IFSCHELP(nano_backup_msg), FALSE, NOVIEW);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000970#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000971
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000972#ifndef NANO_TINY
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000973 /* If we're using restricted mode, command execution is disabled.
974 * It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000975 if (!ISSET(RESTRICTED))
Chris Allegrettaa1171632009-01-19 19:10:39 +0000976 add_to_funcs( EXT_CMD_MSG, MINSERTFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +0000977 ext_cmd_msg, IFSCHELP(nano_execute_msg), FALSE, NOVIEW);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000978
Chris Allegrettaf7c68112002-09-03 22:58:40 +0000979#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000980 /* If we're using restricted mode, the multibuffer toggle is
981 * disabled. It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000982 if (!ISSET(RESTRICTED))
Chris Allegrettaa1171632009-01-19 19:10:39 +0000983 add_to_funcs( NEW_BUFFER_MSG, MINSERTFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +0000984 new_buffer_msg, IFSCHELP(nano_multibuffer_msg), FALSE, NOVIEW);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000985#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000986
Chris Allegrettaa1171632009-01-19 19:10:39 +0000987 add_to_funcs( INSERT_FILE_MSG, MEXTCMD,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000988 insert_file_msg, IFSCHELP(nano_insert_msg), FALSE, VIEW);
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000989
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000990#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaa1171632009-01-19 19:10:39 +0000991 add_to_funcs( NEW_BUFFER_MSG, MEXTCMD,
Chris Allegretta1d778232008-08-30 21:00:00 +0000992 new_buffer_msg, IFSCHELP(nano_multibuffer_msg), FALSE, NOVIEW);
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000993#endif
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000994#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000995
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000996#ifndef DISABLE_HELP
Chris Allegrettaa1171632009-01-19 19:10:39 +0000997 add_to_funcs( REFRESH_MSG, MHELP,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000998 refresh_msg, nano_refresh_msg, FALSE, VIEW);
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000999#endif
1000
Rocco Corsiaf5c3022001-01-12 07:51:05 +00001001#ifndef DISABLE_BROWSER
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001002
Chris Allegrettaa1171632009-01-19 19:10:39 +00001003 add_to_funcs( FIRST_FILE_MSG,
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001004 (MBROWSER|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +00001005 first_file_msg, IFSCHELP(nano_firstfile_msg), FALSE, VIEW);
Chris Allegrettab3655b42001-10-22 03:15:31 +00001006
Chris Allegrettaa1171632009-01-19 19:10:39 +00001007 add_to_funcs( LAST_FILE_MSG,
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001008 (MBROWSER|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +00001009 last_file_msg, IFSCHELP(nano_lastfile_msg), FALSE, VIEW);
Chris Allegrettab3655b42001-10-22 03:15:31 +00001010
Chris Allegrettaa1171632009-01-19 19:10:39 +00001011 add_to_funcs( GOTO_DIR_MSG, MBROWSER,
Chris Allegretta1d778232008-08-30 21:00:00 +00001012 goto_dir_msg, IFSCHELP(nano_gotodir_msg), FALSE, VIEW);
David Lawrence Ramseye38b8082006-03-30 07:03:04 +00001013#endif
1014
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001015 currmenu = MMAIN;
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001016
Chris Allegrettaa1171632009-01-19 19:10:39 +00001017 add_to_sclist(MALL, "^G", DO_HELP_VOID, 0, TRUE);
1018 add_to_sclist(MALL, "F1", DO_HELP_VOID, 0, TRUE);
1019 add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", DO_EXIT, 0, TRUE);
1020 add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", DO_EXIT, 0, TRUE);
1021 add_to_sclist(MMAIN, "^_", DO_GOTOLINECOLUMN_VOID, 0, TRUE);
1022 add_to_sclist(MMAIN, "F13", DO_GOTOLINECOLUMN_VOID, 0, TRUE);
1023 add_to_sclist(MMAIN, "^O", DO_WRITEOUT_VOID, 0, TRUE);
1024 add_to_sclist(MMAIN, "F3", DO_WRITEOUT_VOID, 0, TRUE);
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001025#ifndef DISABLE_JUSTIFY
Chris Allegrettaa1171632009-01-19 19:10:39 +00001026 add_to_sclist(MMAIN, "^J", DO_JUSTIFY_VOID, 0, TRUE);
1027 add_to_sclist(MMAIN, "F4", DO_JUSTIFY_VOID, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001028#endif
Chris Allegrettaa1171632009-01-19 19:10:39 +00001029 add_to_sclist(MMAIN, "^R", DO_INSERTFILE_VOID, 0, TRUE);
1030 add_to_sclist(MMAIN, "F5", DO_INSERTFILE_VOID, 0, TRUE);
1031 add_to_sclist(MMAIN, "kinsert", DO_INSERTFILE_VOID, 0, TRUE);
1032 add_to_sclist(MMAIN|MBROWSER, "^W", DO_SEARCH, 0, TRUE);
1033 add_to_sclist(MMAIN|MBROWSER, "F6", DO_SEARCH, 0, TRUE);
1034 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "^Y", DO_PAGE_UP, 0, TRUE);
1035 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "F7", DO_PAGE_UP, 0, TRUE);
1036 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "kpup", DO_PAGE_UP, 0, TRUE);
1037 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "^V", DO_PAGE_DOWN, 0, TRUE);
1038 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "F8", DO_PAGE_DOWN, 0, TRUE);
1039 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "kpdown", DO_PAGE_DOWN, 0, TRUE);
1040 add_to_sclist(MMAIN, "^K", DO_CUT_TEXT_VOID, 0, TRUE);
1041 add_to_sclist(MMAIN, "F9", DO_CUT_TEXT_VOID, 0, TRUE);
1042 add_to_sclist(MMAIN, "^U", DO_UNCUT_TEXT, 0, TRUE);
1043 add_to_sclist(MMAIN, "F10", DO_UNCUT_TEXT, 0, TRUE);
1044 add_to_sclist(MMAIN, "^C", DO_CURSORPOS_VOID, 0, TRUE);
1045 add_to_sclist(MMAIN, "F11", DO_CURSORPOS_VOID, 0, TRUE);
Chris Allegretta506af6f2008-05-31 22:49:55 +00001046#ifndef DISABLE_SPELLER
Chris Allegrettaa1171632009-01-19 19:10:39 +00001047 add_to_sclist(MMAIN, "^T", DO_SPELL, 0, TRUE);
1048 add_to_sclist(MMAIN, "F12", DO_SPELL, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001049#endif
Chris Allegrettaa1171632009-01-19 19:10:39 +00001050 add_to_sclist(MMAIN, "^_", DO_GOTOLINECOLUMN_VOID, 0, TRUE);
1051 add_to_sclist(MMAIN, "F13", DO_GOTOLINECOLUMN_VOID, 0, TRUE);
1052 add_to_sclist(MMAIN, "M-G", DO_GOTOLINECOLUMN_VOID, 0, TRUE);
1053 add_to_sclist(MMAIN, "^\\", DO_REPLACE, 0, TRUE);
1054 add_to_sclist(MMAIN, "F14", DO_REPLACE, 0, TRUE);
1055 add_to_sclist(MMAIN, "M-R", DO_REPLACE, 0, TRUE);
1056 add_to_sclist(MWHEREIS, "^R", DO_REPLACE, 0, FALSE);
1057 add_to_sclist(MREPLACE, "^R", NO_REPLACE_MSG, 0, FALSE);
1058 add_to_sclist(MWHEREIS, "^T", DO_GOTOLINECOLUMN_VOID, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001059#ifndef NANO_TINY
Chris Allegrettaa1171632009-01-19 19:10:39 +00001060 add_to_sclist(MMAIN, "^^", DO_MARK, 0, TRUE);
1061 add_to_sclist(MMAIN, "F15", DO_MARK, 0, TRUE);
1062 add_to_sclist(MMAIN, "M-A", DO_MARK, 0, TRUE);
1063 add_to_sclist(MALL, "M-W", DO_RESEARCH, 0, TRUE);
1064 add_to_sclist(MALL, "F16", DO_RESEARCH, 0, TRUE);
1065 add_to_sclist(MMAIN, "M-^", DO_COPY_TEXT, 0, TRUE);
1066 add_to_sclist(MMAIN, "M-6", DO_COPY_TEXT, 0, TRUE);
1067 add_to_sclist(MMAIN, "M-}", DO_INDENT_VOID, 0, TRUE);
1068 add_to_sclist(MMAIN, "M-{", DO_UNINDENT, 0, TRUE);
Chris Allegrettaa48507d2009-08-14 03:18:29 +00001069 if (ISSET(UNDOABLE)) {
Chris Allegrettaad37e672009-07-12 03:36:58 +00001070 add_to_sclist(MMAIN, "M-U", DO_UNDO, 0, TRUE);
1071 add_to_sclist(MMAIN, "M-E", DO_REDO, 0, TRUE);
1072 }
Chris Allegrettaa1171632009-01-19 19:10:39 +00001073 add_to_sclist(MALL, "^F", DO_RIGHT, 0, TRUE);
1074 add_to_sclist(MALL, "^B", DO_LEFT, 0, TRUE);
1075 add_to_sclist(MMAIN, "^Space", DO_NEXT_WORD_VOID, 0, TRUE);
1076 add_to_sclist(MMAIN, "M-Space", DO_PREV_WORD_VOID, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001077#endif
Chris Allegrettaa1171632009-01-19 19:10:39 +00001078 add_to_sclist(MALL, "kright", DO_RIGHT, 0, TRUE);
1079 add_to_sclist(MALL, "kleft", DO_LEFT, 0, TRUE);
1080 add_to_sclist(MMAIN, "^Q", XON_COMPLAINT, 0, TRUE);
1081 add_to_sclist(MMAIN, "^S", XOFF_COMPLAINT, 0, TRUE);
1082 add_to_sclist(MMAIN, "^P", DO_UP_VOID, 0, TRUE);
1083 add_to_sclist(MMAIN, "kup", DO_UP_VOID, 0, TRUE);
1084 add_to_sclist(MMAIN, "^N", DO_DOWN_VOID, 0, TRUE);
1085 add_to_sclist(MMAIN, "kdown", DO_DOWN_VOID, 0, TRUE);
1086 add_to_sclist(MALL, "^A", DO_HOME, 0, TRUE);
1087 add_to_sclist(MALL, "khome", DO_HOME, 0, TRUE);
1088 add_to_sclist(MALL, "^E", DO_END, 0, TRUE);
1089 add_to_sclist(MALL, "kend", DO_END, 0, TRUE);
Chris Allegretta1b6ed072008-06-03 08:09:05 +00001090#ifndef NANO_TINY
Chris Allegrettaa1171632009-01-19 19:10:39 +00001091 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "^P", PREV_HISTORY_MSG, 0, FALSE);
1092 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "kup", PREV_HISTORY_MSG, 0, FALSE);
1093 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "^N", NEXT_HISTORY_MSG, 0, FALSE);
1094 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "kdown", NEXT_HISTORY_MSG, 0, FALSE);
Chris Allegretta1b6ed072008-06-03 08:09:05 +00001095#endif
Chris Allegretta1347f222008-06-29 06:22:31 +00001096#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001097 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
Chris Allegrettaa1171632009-01-19 19:10:39 +00001098 "^W", DO_PARA_BEGIN_VOID, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001099 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
Chris Allegrettaa1171632009-01-19 19:10:39 +00001100 "^O", DO_PARA_END_VOID, 0, TRUE);
1101 add_to_sclist(MALL, "M-(", DO_PARA_BEGIN_VOID, 0, TRUE);
1102 add_to_sclist(MALL, "M-9", DO_PARA_BEGIN_VOID, 0, TRUE);
1103 add_to_sclist(MALL, "M-)", DO_PARA_END_VOID, 0, TRUE);
1104 add_to_sclist(MALL, "M-0", DO_PARA_END_VOID, 0, TRUE);
Chris Allegrettae347efb2008-03-09 02:52:40 +00001105#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001106 add_to_sclist(MWHEREIS,
Chris Allegrettaa1171632009-01-19 19:10:39 +00001107 "M-C", CASE_SENS_MSG, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001108 add_to_sclist(MREPLACE,
Chris Allegrettaa1171632009-01-19 19:10:39 +00001109 "M-C", CASE_SENS_MSG, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001110 add_to_sclist(MREPLACE2,
Chris Allegrettaa1171632009-01-19 19:10:39 +00001111 "M-C", CASE_SENS_MSG, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001112 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
Chris Allegrettaa1171632009-01-19 19:10:39 +00001113 "M-B", BACKWARDS_MSG, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001114 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
Chris Allegrettaa1171632009-01-19 19:10:39 +00001115 "M-R", REGEXP_MSG, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001116
Chris Allegrettaa1171632009-01-19 19:10:39 +00001117 add_to_sclist(MMAIN, "M-\\", DO_FIRST_LINE, 0, TRUE);
1118 add_to_sclist(MMAIN, "M-|", DO_FIRST_LINE, 0, TRUE);
1119 add_to_sclist(MMAIN, "M-/", DO_LAST_LINE, 0, TRUE);
1120 add_to_sclist(MMAIN, "M-?", DO_LAST_LINE, 0, TRUE);
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001121 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP,
Chris Allegrettaa1171632009-01-19 19:10:39 +00001122 "^Y", DO_FIRST_LINE, 0, TRUE);
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001123 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP,
Chris Allegrettaa1171632009-01-19 19:10:39 +00001124 "^V", DO_LAST_LINE, 0, TRUE);
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001125
Chris Allegrettaa1171632009-01-19 19:10:39 +00001126 add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", FIRST_FILE_MSG, 0, TRUE);
1127 add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", FIRST_FILE_MSG, 0, TRUE);
1128 add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", LAST_FILE_MSG, 0, TRUE);
1129 add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", LAST_FILE_MSG, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001130#ifndef NANO_TINY
Chris Allegrettaa1171632009-01-19 19:10:39 +00001131 add_to_sclist(MMAIN, "M-]", DO_FIND_BRACKET, 0, TRUE);
1132 add_to_sclist(MMAIN, "M--", DO_SCROLL_UP, 0, TRUE);
1133 add_to_sclist(MMAIN, "M-_", DO_SCROLL_UP, 0, TRUE);
1134 add_to_sclist(MMAIN, "M-+", DO_SCROLL_DOWN, 0, TRUE);
1135 add_to_sclist(MMAIN, "M-=", DO_SCROLL_DOWN, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001136#endif
1137
1138#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaa1171632009-01-19 19:10:39 +00001139 add_to_sclist(MMAIN, "M-<", SWITCH_TO_PREV_BUFFER_VOID, 0, TRUE);
1140 add_to_sclist(MMAIN, "M-,", SWITCH_TO_PREV_BUFFER_VOID, 0, TRUE);
1141 add_to_sclist(MMAIN, "M->", SWITCH_TO_NEXT_BUFFER_VOID, 0, TRUE);
1142 add_to_sclist(MMAIN, "M-.", SWITCH_TO_NEXT_BUFFER_VOID, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001143#endif
Chris Allegrettaa1171632009-01-19 19:10:39 +00001144 add_to_sclist(MALL, "M-V", DO_VERBATIM_INPUT, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001145#ifndef NANO_TINY
Chris Allegrettaa1171632009-01-19 19:10:39 +00001146 add_to_sclist(MALL, "M-T", DO_CUT_TILL_END, 0, TRUE);
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001147#ifndef DISABLE_JUSTIFY
Chris Allegrettaa1171632009-01-19 19:10:39 +00001148 add_to_sclist(MALL, "M-J", DO_FULL_JUSTIFY, 0, TRUE);
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001149#endif
Chris Allegrettaa1171632009-01-19 19:10:39 +00001150 add_to_sclist(MMAIN, "M-D", DO_WORDLINECHAR_COUNT, 0, TRUE);
1151 add_to_sclist(MMAIN, "M-X", DO_TOGGLE, NO_HELP, TRUE);
1152 add_to_sclist(MMAIN, "M-C", DO_TOGGLE, CONST_UPDATE, TRUE);
1153 add_to_sclist(MMAIN, "M-O", DO_TOGGLE, MORE_SPACE, TRUE);
1154 add_to_sclist(MMAIN, "M-S", DO_TOGGLE, SMOOTH_SCROLL, TRUE);
1155 add_to_sclist(MMAIN, "M-P", DO_TOGGLE, WHITESPACE_DISPLAY, TRUE);
1156 add_to_sclist(MMAIN, "M-Y", DO_TOGGLE, NO_COLOR_SYNTAX, TRUE);
1157 add_to_sclist(MMAIN, "M-H", DO_TOGGLE, SMART_HOME, TRUE);
1158 add_to_sclist(MMAIN, "M-I", DO_TOGGLE, AUTOINDENT, TRUE);
1159 add_to_sclist(MMAIN, "M-K", DO_TOGGLE, CUT_TO_END, TRUE);
1160 add_to_sclist(MMAIN, "M-L", DO_TOGGLE, NO_WRAP, TRUE);
1161 add_to_sclist(MMAIN, "M-Q", DO_TOGGLE, TABS_TO_SPACES, TRUE);
1162 add_to_sclist(MMAIN, "M-B", DO_TOGGLE, BACKUP_FILE, TRUE);
1163 add_to_sclist(MMAIN, "M-F", DO_TOGGLE, MULTIBUFFER, TRUE);
1164 add_to_sclist(MMAIN, "M-M", DO_TOGGLE, USE_MOUSE, TRUE);
1165 add_to_sclist(MMAIN, "M-N", DO_TOGGLE, NO_CONVERT, TRUE);
1166 add_to_sclist(MMAIN, "M-Z", DO_TOGGLE, SUSPEND, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001167#endif
Chris Allegrettaa1171632009-01-19 19:10:39 +00001168 add_to_sclist(MGOTOLINE, "^T", GOTOTEXT_MSG, 0, FALSE);
1169 add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", NEW_BUFFER_MSG, 0, FALSE);
Chris Allegrettacc593832008-03-19 02:32:48 +00001170 add_to_sclist((MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR|MYESNO),
Chris Allegrettaa1171632009-01-19 19:10:39 +00001171 "^C", CANCEL_MSG, 0, FALSE);
1172 add_to_sclist(MHELP, "^X", DO_EXIT, 0, TRUE);
1173 add_to_sclist(MHELP, "F2", DO_EXIT, 0, TRUE);
1174 add_to_sclist(MWRITEFILE, "M-D", DOS_FORMAT_MSG, 0, FALSE);
1175 add_to_sclist(MWRITEFILE, "M-M", MAC_FORMAT_MSG, 0, FALSE);
1176 add_to_sclist(MWRITEFILE, "M-A", APPEND_MSG, 0, FALSE);
1177 add_to_sclist(MWRITEFILE, "M-P", PREPEND_MSG, 0, FALSE);
1178 add_to_sclist(MWRITEFILE, "M-B", BACKUP_FILE_MSG, 0, FALSE);
1179 add_to_sclist(MWRITEFILE, "^T", TO_FILES_MSG, 0, FALSE);
1180 add_to_sclist(MINSERTFILE, "^T", TO_FILES_MSG, 0, FALSE);
1181 add_to_sclist(MINSERTFILE, "^X", EXT_CMD_MSG, 0, FALSE);
1182 add_to_sclist(MMAIN, "^Z", DO_SUSPEND_VOID, 0, FALSE);
1183 add_to_sclist(MMAIN, "^L", TOTAL_REFRESH, 0, TRUE);
1184 add_to_sclist(MALL, "^I", DO_TAB, 0, TRUE);
1185 add_to_sclist(MALL, "^M", DO_ENTER, 0, TRUE);
1186 add_to_sclist(MALL, "kenter", DO_ENTER, 0, TRUE);
1187 add_to_sclist(MALL, "^D", DO_DELETE, 0, TRUE);
1188 add_to_sclist(MALL, "kdel", DO_DELETE, 0, TRUE);
1189 add_to_sclist(MALL, "^H", DO_BACKSPACE, 0, TRUE);
1190 add_to_sclist(MALL, "kbsp", DO_BACKSPACE, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001191
1192#ifdef DEBUG
1193 print_sclist();
1194#endif
1195
Chris Allegrettadab017e2002-04-23 10:56:06 +00001196}
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001197
Chris Allegrettaa1171632009-01-19 19:10:39 +00001198/* Given a function alias, execute the proper
1199 function, and then me */
1200void iso_me_harder_funcmap(short func)
1201{
1202 if (func == TOTAL_REFRESH)
1203 total_refresh();
1204 else if (func == DO_HELP_VOID)
1205 do_help_void();
1206 else if (func == DO_SEARCH)
1207 do_search();
1208 else if (func == DO_PAGE_UP)
1209 do_page_up();
1210 else if (func == DO_PAGE_DOWN)
1211 do_page_down();
1212 else if (func == DO_UP_VOID)
1213 do_up_void();
1214 else if (func == DO_LEFT)
1215 do_left();
1216 else if (func == DO_DOWN_VOID)
1217 do_down_void();
1218 else if (func == DO_RIGHT)
1219 do_right();
1220 else if (func == DO_ENTER)
Chris Allegrettae061a0d2009-04-25 03:31:30 +00001221 do_enter(FALSE);
Chris Allegrettaa1171632009-01-19 19:10:39 +00001222 else if (func == DO_EXIT)
1223 do_exit();
1224 else if (func == DO_FIRST_LINE)
1225 do_first_line();
1226 else if (func == DO_LAST_LINE)
1227 do_last_line();
1228 else if (func == DO_BACKSPACE)
1229 do_backspace();
1230 else if (func == DO_DELETE)
1231 do_delete();
1232 else if (func == DO_TAB)
1233 do_tab();
1234 else if (func == DO_VERBATIM_INPUT)
1235 do_verbatim_input();
Chris Allegretta2d1bdd02009-01-28 05:11:57 +00001236#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaa1171632009-01-19 19:10:39 +00001237 else if (func == SWITCH_TO_NEXT_BUFFER_VOID)
1238 switch_to_next_buffer_void();
1239 else if (func == SWITCH_TO_PREV_BUFFER_VOID)
1240 switch_to_prev_buffer_void();
Chris Allegretta2d1bdd02009-01-28 05:11:57 +00001241#endif
Chris Allegrettaa1171632009-01-19 19:10:39 +00001242 else if (func == DO_END)
1243 do_end();
1244 else if (func == DO_HOME)
1245 do_home();
Chris Allegrettaa1171632009-01-19 19:10:39 +00001246 else if (func == DO_SUSPEND_VOID)
1247 do_suspend_void();
1248 else if (func == DO_WRITEOUT_VOID)
1249 do_writeout_void();
1250 else if (func == DO_INSERTFILE_VOID)
1251 do_insertfile_void();
1252 else if (func == DO_CUT_TEXT_VOID)
1253 do_cut_text_void();
1254 else if (func == DO_UNCUT_TEXT)
1255 do_uncut_text();
1256 else if (func == DO_CURSORPOS_VOID)
1257 do_cursorpos_void();
1258 else if (func == DO_GOTOLINECOLUMN_VOID)
1259 do_gotolinecolumn_void();
1260 else if (func == DO_REPLACE)
1261 do_replace();
Chris Allegretta2d1bdd02009-01-28 05:11:57 +00001262 else if (func == XOFF_COMPLAINT)
1263 xoff_complaint();
1264 else if (func == XON_COMPLAINT)
1265 xon_complaint();
1266 else if (func == DO_CUT_TEXT)
1267 do_cut_text_void();
1268#ifndef NANO_TINY
1269 else if (func == DO_CUT_TILL_END)
1270 do_cut_till_end();
1271 else if (func == DO_REDO)
1272 do_redo();
1273 else if (func == DO_UNDO)
1274 do_undo();
1275 else if (func == DO_WORDLINECHAR_COUNT)
1276 do_wordlinechar_count();
1277 else if (func == DO_FIND_BRACKET)
1278 do_find_bracket();
1279 else if (func == DO_PREV_WORD_VOID)
1280 do_prev_word_void();
Chris Allegretta30f278f2009-01-31 16:13:03 +00001281#ifndef DISABLE_JUSTIFY
Chris Allegrettaa1171632009-01-19 19:10:39 +00001282 else if (func == DO_JUSTIFY_VOID)
1283 do_justify_void();
1284 else if (func == DO_PARA_BEGIN_VOID)
1285 do_para_begin_void();
1286 else if (func == DO_PARA_END_VOID)
1287 do_para_end_void();
1288 else if (func == DO_FULL_JUSTIFY)
1289 do_full_justify();
Chris Allegretta30f278f2009-01-31 16:13:03 +00001290#endif
Chris Allegrettaa1171632009-01-19 19:10:39 +00001291 else if (func == DO_MARK)
1292 do_mark();
1293 else if (func == DO_RESEARCH)
1294 do_research();
1295 else if (func == DO_COPY_TEXT)
1296 do_copy_text();
1297 else if (func == DO_INDENT_VOID)
1298 do_indent_void();
1299 else if (func == DO_UNINDENT)
1300 do_unindent();
1301 else if (func == DO_SCROLL_UP)
1302 do_scroll_up();
1303 else if (func == DO_SCROLL_DOWN)
1304 do_scroll_down();
1305 else if (func == DO_NEXT_WORD_VOID)
1306 do_next_word_void();
Chris Allegretta2d1bdd02009-01-28 05:11:57 +00001307#ifndef DISABLE_SPELLER
Chris Allegrettaa1171632009-01-19 19:10:39 +00001308 else if (func == DO_SPELL)
1309 do_spell();
Chris Allegretta2d1bdd02009-01-28 05:11:57 +00001310#endif
Chris Allegrettaa1171632009-01-19 19:10:39 +00001311 else if (func == DO_NEXT_WORD)
1312 do_next_word_void();
1313 else if (func == DO_PREV_WORD)
1314 do_prev_word_void();
Chris Allegretta2d1bdd02009-01-28 05:11:57 +00001315#endif
Chris Allegrettaa1171632009-01-19 19:10:39 +00001316}
1317
1318
David Lawrence Ramseye6757b92006-04-19 13:36:56 +00001319/* Free the given shortcut. */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001320void free_shortcutage(shortcut **shortcutage)
1321{
1322 assert(shortcutage != NULL);
David Lawrence Ramsey193b0e52005-06-06 18:41:17 +00001323
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001324 while (*shortcutage != NULL) {
1325 shortcut *ps = *shortcutage;
1326 *shortcutage = (*shortcutage)->next;
1327 free(ps);
1328 }
1329}
1330
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001331const subnfunc *sctofunc(sc *s)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001332{
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001333 subnfunc *f;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001334
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001335 for (f = allfuncs; f != NULL && s->scfunc != f->scfunc; f = f->next)
1336 ;
1337
1338 return f;
1339}
1340
1341#ifndef NANO_TINY
1342/* Now lets come up with a single (hopefully)
1343 function to get a string for each flag */
1344char *flagtostr(int flag)
1345{
1346 switch (flag) {
1347 case NO_HELP:
1348 return N_("Help mode");
1349 case CONST_UPDATE:
1350 return N_("Constant cursor position display");
1351 case MORE_SPACE:
1352 return N_("Use of one more line for editing");
1353 case SMOOTH_SCROLL:
1354 return N_("Smooth scrolling");
1355 case WHITESPACE_DISPLAY:
1356 return N_("Whitespace display");
1357 case NO_COLOR_SYNTAX:
1358 return N_("Color syntax highlighting");
1359 case SMART_HOME:
1360 return N_("Smart home key");
1361 case AUTOINDENT:
1362 return N_("Auto indent");
1363 case CUT_TO_END:
1364 return N_("Cut to end");
1365 case NO_WRAP:
1366 return N_("Long line wrapping");
1367 case TABS_TO_SPACES:
1368 return N_("Conversion of typed tabs to spaces");
1369 case BACKUP_FILE:
1370 return N_("Backup files");
1371 case MULTIBUFFER:
1372 return N_("Multiple file buffers");
1373 case USE_MOUSE:
1374 return N_("Mouse support");
1375 case NO_CONVERT:
1376 return N_("No conversion from DOS/Mac format");
1377 case SUSPEND:
1378 return N_("Suspension");
1379 default:
1380 return "?????";
1381 }
1382}
Chris Allegrettae347efb2008-03-09 02:52:40 +00001383#endif /* NANO_TINY */
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001384
1385/* Interpret the string given by the rc file and return a
1386 shortcut struct, complete with proper value for execute */
1387sc *strtosc(int menu, char *input)
1388{
1389 sc *s;
1390
1391 s = (sc *)nmalloc(sizeof(sc));
1392 s->execute = TRUE; /* overridden as needed below */
1393
Chris Allegrettae347efb2008-03-09 02:52:40 +00001394
1395#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001396 if (!strcasecmp(input, "help"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001397 s->scfunc = DO_HELP_VOID;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001398 else
1399#endif
1400 if (!strcasecmp(input, "cancel")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001401 s->scfunc = CANCEL_MSG;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001402 s->execute = FALSE;
1403 } else if (!strcasecmp(input, "exit"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001404 s->scfunc = DO_EXIT;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001405 else if (!strcasecmp(input, "writeout"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001406 s->scfunc = DO_WRITEOUT_VOID;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001407 else if (!strcasecmp(input, "insert"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001408 s->scfunc = DO_INSERTFILE_VOID;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001409 else if (!strcasecmp(input, "whereis"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001410 s->scfunc = DO_SEARCH;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001411 else if (!strcasecmp(input, "up"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001412 s->scfunc = DO_UP_VOID;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001413 else if (!strcasecmp(input, "down"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001414 s->scfunc = DO_DOWN_VOID;
Chris Allegretta17436ce2008-03-11 03:03:53 +00001415 else if (!strcasecmp(input, "pageup")
1416 || !strcasecmp(input, "prevpage"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001417 s->scfunc = DO_PAGE_UP;
Chris Allegretta17436ce2008-03-11 03:03:53 +00001418 else if (!strcasecmp(input, "pagedown")
1419 || !strcasecmp(input, "nextpage"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001420 s->scfunc = DO_PAGE_DOWN;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001421 else if (!strcasecmp(input, "cut"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001422 s->scfunc = DO_CUT_TEXT_VOID;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001423 else if (!strcasecmp(input, "uncut"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001424 s->scfunc = DO_UNCUT_TEXT;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001425 else if (!strcasecmp(input, "curpos") ||
1426 !strcasecmp(input, "cursorpos"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001427 s->scfunc = DO_CURSORPOS_VOID;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001428 else if (!strcasecmp(input, "firstline"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001429 s->scfunc = DO_FIRST_LINE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001430 else if (!strcasecmp(input, "lastline"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001431 s->scfunc = DO_LAST_LINE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001432 else if (!strcasecmp(input, "gotoline"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001433 s->scfunc = DO_GOTOLINECOLUMN_VOID;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001434 else if (!strcasecmp(input, "replace"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001435 s->scfunc = DO_REPLACE;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001436#ifndef DISABLE_JUSTIFY
Chris Allegrettae347efb2008-03-09 02:52:40 +00001437 else if (!strcasecmp(input, "justify"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001438 s->scfunc = DO_JUSTIFY_VOID;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001439 else if (!strcasecmp(input, "beginpara"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001440 s->scfunc = DO_PARA_BEGIN_VOID;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001441 else if (!strcasecmp(input, "endpara"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001442 s->scfunc = DO_PARA_END_VOID;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001443 else if (!strcasecmp(input, "fulljustify"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001444 s->scfunc = DO_FULL_JUSTIFY;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001445#endif
1446#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001447 else if (!strcasecmp(input, "mark"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001448 s->scfunc = DO_MARK;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001449 else if (!strcasecmp(input, "searchagain") ||
1450 !strcasecmp(input, "research"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001451 s->scfunc = DO_RESEARCH;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001452 else if (!strcasecmp(input, "copytext"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001453 s->scfunc = DO_COPY_TEXT;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001454 else if (!strcasecmp(input, "indent"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001455 s->scfunc = DO_INDENT_VOID;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001456 else if (!strcasecmp(input, "unindent"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001457 s->scfunc = DO_UNINDENT;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001458 else if (!strcasecmp(input, "scrollup"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001459 s->scfunc = DO_SCROLL_UP;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001460 else if (!strcasecmp(input, "scrolldown"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001461 s->scfunc = DO_SCROLL_DOWN;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001462 else if (!strcasecmp(input, "nextword"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001463 s->scfunc = DO_NEXT_WORD_VOID;
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001464 else if (!strcasecmp(input, "suspend"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001465 s->scfunc = DO_SUSPEND_VOID;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001466 else if (!strcasecmp(input, "prevword"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001467 s->scfunc = DO_PREV_WORD_VOID;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001468 else if (!strcasecmp(input, "findbracket"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001469 s->scfunc = DO_FIND_BRACKET;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001470 else if (!strcasecmp(input, "wordcount"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001471 s->scfunc = DO_WORDLINECHAR_COUNT;
Chris Allegretta70859f42008-07-13 01:36:06 +00001472 else if (!strcasecmp(input, "undo"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001473 s->scfunc = DO_UNDO;
Chris Allegretta70859f42008-07-13 01:36:06 +00001474 else if (!strcasecmp(input, "redo"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001475 s->scfunc = DO_REDO;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001476 else if (!strcasecmp(input, "prevhistory")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001477 s->scfunc = PREV_HISTORY_MSG;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001478 s->execute = FALSE;
1479 } else if (!strcasecmp(input, "nexthistory")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001480 s->scfunc = NEXT_HISTORY_MSG;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001481 s->execute = FALSE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001482 } else if (!strcasecmp(input, "nohelp") ||
1483 !strcasecmp(input, "nohelp")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001484 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001485 s->execute = FALSE;
1486 s->toggle = NO_HELP;
1487 } else if (!strcasecmp(input, "constupdate")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001488 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001489 s->execute = FALSE;
1490 s->toggle = CONST_UPDATE;
1491 } else if (!strcasecmp(input, "morespace")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001492 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001493 s->execute = FALSE;
1494 s->toggle = MORE_SPACE;
1495 } else if (!strcasecmp(input, "smoothscroll")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001496 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001497 s->execute = FALSE;
1498 s->toggle = SMOOTH_SCROLL;
Chris Allegrettad3659f82008-03-16 23:57:14 +00001499 } else if (!strcasecmp(input, "whitespacedisplay")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001500 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001501 s->execute = FALSE;
1502 s->toggle = WHITESPACE_DISPLAY;
1503 } else if (!strcasecmp(input, "nosyntax")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001504 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001505 s->execute = FALSE;
1506 s->toggle = NO_COLOR_SYNTAX;
1507 } else if (!strcasecmp(input, "smarthome")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001508 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001509 s->execute = FALSE;
1510 s->toggle = SMART_HOME;
1511 } else if (!strcasecmp(input, "autoindent")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001512 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001513 s->execute = FALSE;
1514 s->toggle = AUTOINDENT;
1515 } else if (!strcasecmp(input, "cuttoend")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001516 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001517 s->execute = FALSE;
1518 s->toggle = CUT_TO_END;
1519 } else if (!strcasecmp(input, "nowrap")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001520 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001521 s->execute = FALSE;
1522 s->toggle = NO_WRAP;
1523 } else if (!strcasecmp(input, "tabstospaces")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001524 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001525 s->execute = FALSE;
1526 s->toggle = TABS_TO_SPACES;
1527 } else if (!strcasecmp(input, "backupfile")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001528 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001529 s->execute = FALSE;
1530 s->toggle = BACKUP_FILE;
1531 } else if (!strcasecmp(input, "mutlibuffer")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001532 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001533 s->execute = FALSE;
1534 s->toggle = MULTIBUFFER;
1535 } else if (!strcasecmp(input, "mouse")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001536 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001537 s->execute = FALSE;
1538 s->toggle = USE_MOUSE;
1539 } else if (!strcasecmp(input, "noconvert")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001540 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001541 s->execute = FALSE;
1542 s->toggle = NO_CONVERT;
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001543 } else if (!strcasecmp(input, "suspendenable")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001544 s->scfunc = DO_TOGGLE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001545 s->execute = FALSE;
1546 s->toggle = SUSPEND;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001547 }
Chris Allegrettae347efb2008-03-09 02:52:40 +00001548#endif /* NANO_TINY */
1549 else if (!strcasecmp(input, "right") ||
1550 !strcasecmp(input, "forward"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001551 s->scfunc = DO_RIGHT;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001552 else if (!strcasecmp(input, "left") ||
1553 !strcasecmp(input, "back"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001554 s->scfunc = DO_LEFT;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001555 else if (!strcasecmp(input, "up") ||
1556 !strcasecmp(input, "prevline"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001557 s->scfunc = DO_UP_VOID;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001558 else if (!strcasecmp(input, "down") ||
1559 !strcasecmp(input, "nextline"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001560 s->scfunc = DO_DOWN_VOID;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001561 else if (!strcasecmp(input, "home"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001562 s->scfunc = DO_HOME;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001563 else if (!strcasecmp(input, "end"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001564 s->scfunc = DO_END;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001565#ifdef ENABLE_MULTIBUFFER
1566 else if (!strcasecmp(input, "prevbuf"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001567 s->scfunc = SWITCH_TO_PREV_BUFFER_VOID;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001568 else if (!strcasecmp(input, "nextbuf"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001569 s->scfunc = SWITCH_TO_NEXT_BUFFER_VOID;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001570#endif
1571 else if (!strcasecmp(input, "verbatim"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001572 s->scfunc = DO_VERBATIM_INPUT;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001573 else if (!strcasecmp(input, "tab"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001574 s->scfunc = DO_TAB;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001575 else if (!strcasecmp(input, "enter"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001576 s->scfunc = DO_ENTER;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001577 else if (!strcasecmp(input, "delete"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001578 s->scfunc = DO_DELETE;
Chris Allegrettafa406942008-07-13 16:44:19 +00001579 else if (!strcasecmp(input, "backspace"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001580 s->scfunc = DO_BACKSPACE;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001581 else if (!strcasecmp(input, "refresh"))
Chris Allegrettaa1171632009-01-19 19:10:39 +00001582 s->scfunc = TOTAL_REFRESH;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001583 else if (!strcasecmp(input, "casesens")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001584 s->scfunc = CASE_SENS_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001585 s->execute = FALSE;
1586 } else if (!strcasecmp(input, "regexp") ||
1587 !strcasecmp(input, "regex")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001588 s->scfunc = REGEXP_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001589 s->execute = FALSE;
1590 } else if (!strcasecmp(input, "dontreplace")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001591 s->scfunc = NO_REPLACE_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001592 s->execute = FALSE;
1593 } else if (!strcasecmp(input, "gototext")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001594 s->scfunc = GOTOTEXT_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001595 s->execute = FALSE;
1596 } else if (!strcasecmp(input, "browser") ||
1597 !strcasecmp(input, "tofiles")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001598 s->scfunc = TO_FILES_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001599 s->execute = FALSE;
1600 } else if (!strcasecmp(input, "dosformat")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001601 s->scfunc = DOS_FORMAT_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001602 s->execute = FALSE;
1603 } else if (!strcasecmp(input, "macformat")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001604 s->scfunc = MAC_FORMAT_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001605 s->execute = FALSE;
1606 } else if (!strcasecmp(input, "append")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001607 s->scfunc = APPEND_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001608 s->execute = FALSE;
1609 } else if (!strcasecmp(input, "prepend")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001610 s->scfunc = PREPEND_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001611 s->execute = FALSE;
1612 } else if (!strcasecmp(input, "backup")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001613 s->scfunc = BACKUP_FILE_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001614 s->execute = FALSE;
1615#ifdef ENABLE_MULTIBUFFER
1616 } else if (!strcasecmp(input, "newbuffer")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001617 s->scfunc = NEW_BUFFER_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001618 s->execute = FALSE;
1619#endif
1620 } else if (!strcasecmp(input, "firstfile")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001621 s->scfunc = FIRST_FILE_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001622 s->execute = FALSE;
1623 } else if (!strcasecmp(input, "lastfile")) {
Chris Allegrettaa1171632009-01-19 19:10:39 +00001624 s->scfunc = LAST_FILE_MSG;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001625 s->execute = FALSE;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001626 } else {
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001627 free(s);
1628 return NULL;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001629 }
1630
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001631 return s;
1632
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001633}
1634
Chris Allegrettae347efb2008-03-09 02:52:40 +00001635#ifdef ENABLE_NANORC
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001636/* Same thing as abnove but for the menu */
1637int strtomenu(char *input)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001638{
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001639 if (!strcasecmp(input, "all"))
1640 return MALL;
1641 else if (!strcasecmp(input, "main"))
1642 return MMAIN;
1643 else if (!strcasecmp(input, "search"))
1644 return MWHEREIS;
1645 else if (!strcasecmp(input, "replace"))
1646 return MREPLACE;
1647 else if (!strcasecmp(input, "replace2") ||
1648 !strcasecmp(input, "replacewith"))
1649 return MREPLACE2;
1650 else if (!strcasecmp(input, "gotoline"))
1651 return MGOTOLINE;
1652 else if (!strcasecmp(input, "writeout"))
1653 return MWRITEFILE;
1654 else if (!strcasecmp(input, "insert"))
1655 return MINSERTFILE;
1656 else if (!strcasecmp(input, "externalcmd") ||
1657 !strcasecmp(input, "extcmd"))
1658 return MEXTCMD;
1659 else if (!strcasecmp(input, "help"))
1660 return MHELP;
1661 else if (!strcasecmp(input, "spell"))
1662 return MSPELL;
1663 else if (!strcasecmp(input, "browser"))
1664 return MBROWSER;
1665 else if (!strcasecmp(input, "whereisfile"))
1666 return MWHEREISFILE;
1667 else if (!strcasecmp(input, "gotodir"))
1668 return MGOTODIR;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001669
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001670 return -1;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001671}
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001672#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001673
Chris Allegrettae347efb2008-03-09 02:52:40 +00001674
David Lawrence Ramseye6757b92006-04-19 13:36:56 +00001675#ifdef DEBUG
1676/* This function is used to gracefully return all the memory we've used.
1677 * It should be called just before calling exit(). Practically, the
Chris Allegretta6232d662002-05-12 19:52:15 +00001678 * only effect is to cause a segmentation fault if the various data
1679 * structures got bolloxed earlier. Thus, we don't bother having this
Chris Allegretta6df90f52002-07-19 01:08:59 +00001680 * function unless debugging is turned on. */
Chris Allegretta6df90f52002-07-19 01:08:59 +00001681void thanks_for_all_the_fish(void)
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001682{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001683 delwin(topwin);
1684 delwin(edit);
1685 delwin(bottomwin);
1686
Chris Allegretta7662c862003-01-13 01:35:15 +00001687#ifndef DISABLE_JUSTIFY
1688 if (quotestr != NULL)
1689 free(quotestr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001690#ifdef HAVE_REGEX_H
1691 regfree(&quotereg);
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001692 if (quoteerr != NULL)
1693 free(quoteerr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001694#endif
Chris Allegretta7662c862003-01-13 01:35:15 +00001695#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001696#ifndef NANO_TINY
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +00001697 if (backup_dir != NULL)
1698 free(backup_dir);
1699#endif
Chris Allegretta2598c662002-03-28 01:59:34 +00001700#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001701 if (operating_dir != NULL)
1702 free(operating_dir);
1703 if (full_operating_dir != NULL)
1704 free(full_operating_dir);
1705#endif
1706 if (last_search != NULL)
1707 free(last_search);
1708 if (last_replace != NULL)
1709 free(last_replace);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001710#ifndef DISABLE_SPELLER
1711 if (alt_speller != NULL)
1712 free(alt_speller);
1713#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001714 if (answer != NULL)
1715 free(answer);
1716 if (cutbuffer != NULL)
Chris Allegretta7662c862003-01-13 01:35:15 +00001717 free_filestruct(cutbuffer);
David Lawrence Ramsey93c84052004-11-23 04:08:28 +00001718#ifndef DISABLE_JUSTIFY
1719 if (jusbuffer != NULL)
1720 free_filestruct(jusbuffer);
1721#endif
Chris Allegrettab71cf302009-02-16 23:06:09 +00001722#ifdef DEBUG
David Lawrence Ramsey5d8d0b12005-05-26 05:53:29 +00001723 /* Free the memory associated with each open file buffer. */
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +00001724 if (openfile != NULL)
David Lawrence Ramsey64661ac2005-07-08 19:57:25 +00001725 free_openfilestruct(openfile);
Chris Allegrettab71cf302009-02-16 23:06:09 +00001726#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +00001727#ifdef ENABLE_COLOR
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001728 if (syntaxstr != NULL)
1729 free(syntaxstr);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001730 while (syntaxes != NULL) {
1731 syntaxtype *bill = syntaxes;
1732
1733 free(syntaxes->desc);
1734 while (syntaxes->extensions != NULL) {
1735 exttype *bob = syntaxes->extensions;
1736
1737 syntaxes->extensions = bob->next;
David Lawrence Ramsey2385c1a2005-07-29 21:42:08 +00001738 free(bob->ext_regex);
David Lawrence Ramsey7fc0ada2005-08-29 18:52:06 +00001739 if (bob->ext != NULL) {
1740 regfree(bob->ext);
1741 free(bob->ext);
1742 }
Chris Allegretta6df90f52002-07-19 01:08:59 +00001743 free(bob);
1744 }
1745 while (syntaxes->color != NULL) {
1746 colortype *bob = syntaxes->color;
1747
1748 syntaxes->color = bob->next;
David Lawrence Ramsey2385c1a2005-07-29 21:42:08 +00001749 free(bob->start_regex);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001750 if (bob->start != NULL) {
1751 regfree(bob->start);
1752 free(bob->start);
1753 }
David Lawrence Ramseyd2361f02005-07-14 18:33:51 +00001754 if (bob->end_regex != NULL)
1755 free(bob->end_regex);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001756 if (bob->end != NULL) {
Chris Allegrettace452fb2003-02-03 02:56:44 +00001757 regfree(bob->end);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001758 free(bob->end);
1759 }
Chris Allegretta6df90f52002-07-19 01:08:59 +00001760 free(bob);
1761 }
1762 syntaxes = syntaxes->next;
1763 free(bill);
1764 }
1765#endif /* ENABLE_COLOR */
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001766#ifndef NANO_TINY
David Lawrence Ramsey40e4acf2005-05-26 06:09:07 +00001767 /* Free the search and replace history lists. */
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001768 if (searchage != NULL)
1769 free_filestruct(searchage);
1770 if (replaceage != NULL)
1771 free_filestruct(replaceage);
Chris Allegretta5beed502003-01-05 20:41:21 +00001772#endif
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001773#ifdef ENABLE_NANORC
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001774 if (homedir != NULL)
1775 free(homedir);
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001776#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001777}
Chris Allegretta6232d662002-05-12 19:52:15 +00001778#endif /* DEBUG */
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001779