blob: 46db3fe884709b35b4e8cccd62380382e31ea18b [file] [log] [blame]
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001/* $Id$
2*/
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00003/**************************************************************************
4 * global.c *
5 * *
David Lawrence Ramseyd8a1d372007-10-11 05:01:32 +00006 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
7 * Free Software Foundation, Inc. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00008 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
David Lawrence Ramseyd0035b42007-08-11 05:17:36 +000010 * the Free Software Foundation; either version 3, or (at your option) *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000011 * any later version. *
12 * *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000013 * This program is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * General Public License for more details. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000017 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
21 * 02110-1301, USA. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000022 * *
23 **************************************************************************/
24
Chris Allegretta79a33bb2008-03-05 07:34:01 +000025#include <ctype.h>
Chris Allegrettaeb643142008-03-12 04:44:14 +000026#include <string.h>
Chris Allegretta79a33bb2008-03-05 07:34:01 +000027#include <strings.h>
28#include "assert.h"
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000029#include "proto.h"
30
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
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000055long flags = 0;
56 /* 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. */
David Lawrence Ramsey93c84052004-11-23 04:08:28 +000072#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000073filestruct *jusbuffer = NULL;
74 /* The buffer where we store unjustified text. */
David Lawrence Ramsey93c84052004-11-23 04:08:28 +000075#endif
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000076partition *filepart = NULL;
77 /* The partition where we store a portion of the current
78 * file. */
David Lawrence Ramsey64661ac2005-07-08 19:57:25 +000079openfilestruct *openfile = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000080 /* The list of all open file buffers. */
Chris Allegretta2d7893d2001-07-11 02:08:33 +000081
David Lawrence Ramseyd89617f2006-01-06 21:51:10 +000082#ifndef NANO_TINY
83char *matchbrackets = NULL;
84 /* The opening and closing brackets that can be found by bracket
85 * searches. */
86#endif
87
David Lawrence Ramseyebe34252005-11-15 03:17:35 +000088#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000089char *whitespace = NULL;
90 /* The characters used when displaying the first characters of
91 * tabs and spaces. */
92int whitespace_len[2];
93 /* The length of these characters. */
David Lawrence Ramsey89bb9372004-05-29 16:47:52 +000094#endif
95
Chris Allegrettae4f940d2002-03-03 22:36:36 +000096#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000097char *punct = NULL;
98 /* The closing punctuation that can end sentences. */
99char *brackets = NULL;
100 /* The closing brackets that can follow closing punctuation and
101 * can end sentences. */
102char *quotestr = NULL;
103 /* The quoting string. The default value is set in main(). */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000104#ifdef HAVE_REGEX_H
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000105regex_t quotereg;
106 /* The compiled regular expression from the quoting string. */
107int quoterc;
David Lawrence Ramsey88165642006-05-22 18:30:09 +0000108 /* Whether it was compiled successfully. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000109char *quoteerr = NULL;
110 /* The error message, if it didn't. */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000111#else
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000112size_t quotelen;
113 /* The length of the quoting string in bytes. */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000114#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000115#endif
Chris Allegrettae4f940d2002-03-03 22:36:36 +0000116
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000117char *answer = NULL;
David Lawrence Ramsey6335fb52007-01-01 05:15:32 +0000118 /* The answer string used by the statusbar prompt. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000119
120ssize_t tabsize = -1;
121 /* The width of a tab in spaces. The default value is set in
122 * main(). */
123
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000124#ifndef NANO_TINY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000125char *backup_dir = NULL;
126 /* The directory where we store backup files. */
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000127#endif
Chris Allegrettae1f14522001-09-19 03:19:43 +0000128#ifndef DISABLE_OPERATINGDIR
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000129char *operating_dir = NULL;
130 /* The relative path to the operating directory, which we can't
131 * move outside of. */
132char *full_operating_dir = NULL;
133 /* The full path to it. */
Chris Allegrettae1f14522001-09-19 03:19:43 +0000134#endif
135
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000136#ifndef DISABLE_SPELLER
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000137char *alt_speller = NULL;
138 /* The command to use for the alternate spell checker. */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000139#endif
140
Chris Allegretta8ce24132001-04-30 11:28:46 +0000141#ifdef ENABLE_COLOR
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000142syntaxtype *syntaxes = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000143 /* The global list of color syntaxes. */
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000144char *syntaxstr = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000145 /* The color syntax name specified on the command line. */
Chris Allegretta8ce24132001-04-30 11:28:46 +0000146#endif
147
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000148const shortcut *currshortcut;
149 /* The current shortcut list we're using. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000150int currmenu;
151 /* The currently loaded menu */
152
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000153#ifndef NANO_TINY
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000154toggle *toggles = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000155 /* The global toggle list. */
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000156#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000157
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000158sc *sclist = NULL;
159 /* New shortcut key struct */
160subnfunc *allfuncs = NULL;
161 /* New struct for the function list */
162
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000163#ifndef NANO_TINY
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000164filestruct *search_history = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000165 /* The search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000166filestruct *searchage = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000167 /* The top of the search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000168filestruct *searchbot = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000169 /* The bottom of the search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000170filestruct *replace_history = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000171 /* The replace string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000172filestruct *replaceage = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000173 /* The top of the replace string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000174filestruct *replacebot = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000175 /* The bottom of the replace string history list. */
Chris Allegretta5beed502003-01-05 20:41:21 +0000176#endif
177
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +0000178/* Regular expressions. */
Chris Allegretta805c26d2000-09-06 13:39:17 +0000179#ifdef HAVE_REGEX_H
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000180regex_t search_regexp;
181 /* The compiled regular expression to use in searches. */
182regmatch_t regmatches[10];
183 /* The match positions for parenthetical subexpressions, 10
184 * maximum, used in regular expression searches. */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000185#endif
Chris Allegretta3533a342002-03-24 23:19:32 +0000186
David Lawrence Ramsey4d72de72006-04-12 15:27:40 +0000187int reverse_attr = A_REVERSE;
188 /* The curses attribute we use for reverse video. */
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000189
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000190char *homedir = NULL;
David Lawrence Ramseyc1c818e2006-05-14 18:22:01 +0000191 /* The user's home directory, from $HOME or /etc/passwd. */
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000192
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000193/* Return the number of entries in the shortcut list s for a given menu. */
194size_t length_of_list(int menu)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000195{
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000196 subnfunc *f;
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000197 size_t i = 0;
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000198
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000199 for (f = allfuncs; f != NULL; f = f->next)
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000200 if ((f->menus & menu) != 0
201#ifndef DISABLE_HELP
202 && strlen(f->help) > 0
203#endif
204 ) {
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000205 i++;
206 }
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000207 return i;
208}
209
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000210/* Set type of function based on the string */
211function_type strtokeytype(char *str)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000212{
Chris Allegretta17436ce2008-03-11 03:03:53 +0000213 if (str[0] == 'M' || str[0] == 'm')
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000214 return META;
Chris Allegretta17436ce2008-03-11 03:03:53 +0000215 else if (str[0] == '^')
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000216 return CONTROL;
Chris Allegretta17436ce2008-03-11 03:03:53 +0000217 else if (str[0] == 'F' || str[0] == 'F')
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000218 return FKEY;
Chris Allegretta17436ce2008-03-11 03:03:53 +0000219 else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000220 return RAW;
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000221}
222
223/* Add a string to the new function list strict.
224 Does not allow updates, yet anyway */
225void add_to_funcs(void *func, int menus, const char *desc, const char *help,
226 bool blank_after, bool viewok)
227{
228 subnfunc *f;
229
230 if (allfuncs == NULL) {
231 allfuncs = nmalloc(sizeof(subnfunc));
232 f = allfuncs;
233 } else {
234 for (f = allfuncs; f->next != NULL; f = f->next)
235 ;
236 f->next = (subnfunc *)nmalloc(sizeof(subnfunc));
237 f = f->next;
238 }
239 f->next = NULL;
240 f->scfunc = func;
241 f->menus = menus;
242 f->desc = desc;
243 f->viewok = viewok;
244#ifndef NANO_TINY
245 f->help = help;
246 f->blank_after = blank_after;
247#endif
248
249#ifdef DEBUG
250 fprintf(stderr, "Added func \"%s\"", f->desc);
251#endif
252}
253
254const sc *first_sc_for(int menu, void *func) {
255 const sc *s;
Chris Allegrettab775c072008-03-09 05:07:37 +0000256 const sc *metasc = NULL;
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000257
258 for (s = sclist; s != NULL; s = s->next) {
259 if ((s->menu & menu) && s->scfunc == func) {
Chris Allegrettab775c072008-03-09 05:07:37 +0000260 /* try to use a meta sequence as a last resort. Otherwise
261 we will run into problems when we try and handle things like
262 the arrow keys, home, etc, if for some reason the user bound
263 them to a meta sequence first *shrug* */
264 if (s->type == META) {
265 metasc = s;
266 continue;
267 } /* otherwise it was something else, use it */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000268 return s;
269 }
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000270 }
271
Chris Allegrettab775c072008-03-09 05:07:37 +0000272 /* If we're here we may have found only meta sequences, if so use one */
273 if (metasc)
Chris Allegretta17436ce2008-03-11 03:03:53 +0000274 return metasc;
Chris Allegrettab775c072008-03-09 05:07:37 +0000275
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000276#ifdef DEBUG
Chris Allegrettae347efb2008-03-09 02:52:40 +0000277 fprintf(stderr, "Whoops, returning null given func %ld in menu %d\n", (long) func, menu);
David Lawrence Ramseybd28ee42006-07-25 21:13:30 +0000278#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000279 /* Otherwise... */
280 return NULL;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000281}
282
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000283
284/* Add a string to the new shortcut list implementation
285 Allows updates to existing entries in the list */
286void add_to_sclist(int menu, char *scstring, void *func, int toggle, int execute)
287{
288 sc *s;
289
290 if (sclist == NULL) {
291 sclist = nmalloc(sizeof(sc));
292 s = sclist;
293 s->next = NULL;
294 } else {
295 for (s = sclist; s->next != NULL; s = s->next)
296 if (s->menu == menu && s->keystr == scstring)
297 break;
298
299 if (s->menu != menu || s->keystr != scstring) { /* i.e. this is not a replace... */
300#ifdef DEBUG
301 fprintf(stderr, "No match found...\n");
302#endif
303 s->next = (sc *)nmalloc(sizeof(sc));
304 s = s->next;
305 s->next = NULL;
306 }
307 }
308
309 s->type = strtokeytype(scstring);
310 s->menu = menu;
311 s->toggle = toggle;
312 s->keystr = scstring;
313 s->scfunc = func;
314 s->execute = execute;
315 assign_keyinfo(s);
316
317#ifdef DEBUG
318 fprintf(stderr, "list val = %d\n", (int) s->menu);
319 fprintf(stderr, "Hey, set sequence to %d for shortcut \"%s\"\n", s->seq, scstring);
320#endif
321}
322
Chris Allegrettae347efb2008-03-09 02:52:40 +0000323/* Return the given menu's first shortcut sequence, or the default value
324 (2nd arg). Assumes currmenu for the menu to check*/
325int sc_seq_or (void *func, int defaultval)
326{
327 const sc *s = first_sc_for(currmenu, func);
328
329 if (s)
330 return s->seq;
331 /* else */
332 return defaultval;
333
334}
335
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000336/* Assign the info to the shortcut struct
337 Assumes keystr is already assigned, naturally */
338void assign_keyinfo(sc *s)
339{
340 if (s->type == CONTROL) {
341 assert(strlen(s->keystr) > 1);
342 s->seq = s->keystr[1] - 64;
343 } else if (s->type == META) {
344 assert(strlen(s->keystr) > 2);
345 s->seq = tolower((int) s->keystr[2]);
346 } else if (s->type == FKEY) {
347 assert(strlen(s->keystr) > 1);
348 s->seq = KEY_F0 + atoi(&s->keystr[1]);
349 } else /* raw */
350 s->seq = (int) s->keystr[0];
Chris Allegretta9b422202008-03-05 17:15:33 +0000351
352 /* Override some keys which don't bind as nicely as we'd like */
353 if (s->type == CONTROL && (!strcasecmp(&s->keystr[1], "space")))
354 s->seq = 0;
355 else if (s->type == META && (!strcasecmp(&s->keystr[2], "space")))
356 s->seq = (int) ' ';
Chris Allegretta17436ce2008-03-11 03:03:53 +0000357 else if (s->type == RAW && (!strcasecmp(s->keystr, "kup")))
358 s->seq = KEY_UP;
359 else if (s->type == RAW && (!strcasecmp(s->keystr, "kdown")))
360 s->seq = KEY_DOWN;
361 else if (s->type == RAW && (!strcasecmp(s->keystr, "kleft")))
362 s->seq = KEY_LEFT;
363 else if (s->type == RAW && (!strcasecmp(s->keystr, "kright")))
364 s->seq = KEY_RIGHT;
365 else if (s->type == RAW && (!strcasecmp(s->keystr, "kinsert")))
366 s->seq = KEY_IC;
367 else if (s->type == RAW && (!strcasecmp(s->keystr, "kdel")))
368 s->seq = KEY_DC;
Chris Allegrettaeb643142008-03-12 04:44:14 +0000369 else if (s->type == RAW && (!strcasecmp(s->keystr, "kbsp")))
370 s->seq = KEY_BACKSPACE;
371 else if (s->type == RAW && (!strcasecmp(s->keystr, "kenter")))
372 s->seq = KEY_ENTER;
Chris Allegretta17436ce2008-03-11 03:03:53 +0000373 else if (s->type == RAW && (!strcasecmp(s->keystr, "kpup")))
374 s->seq = KEY_PPAGE;
375 else if (s->type == RAW && (!strcasecmp(s->keystr, "kpdown")))
376 s->seq = KEY_NPAGE;
377#ifdef KEY_HOME
378 else if (s->type == RAW && (!strcasecmp(s->keystr, "khome")))
379 s->seq = KEY_HOME;
380#endif
381#ifdef KEY_END
382 else if (s->type == RAW && (!strcasecmp(s->keystr, "kend")))
383 s->seq = KEY_END;
384#endif
Chris Allegretta9b422202008-03-05 17:15:33 +0000385
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000386}
387
388#ifdef DEBUG
389
390void print_sclist(void)
391{
392 sc *s;
393 const subnfunc *f;
394
395 for (s = sclist; s->next != NULL; s = s->next) {
396 f = sctofunc(s);
397 if (f)
Chris Allegrettae347efb2008-03-09 02:52:40 +0000398 fprintf(stderr, "Shortcut \"%s\", function: %s, menus %d\n", s->keystr, f->desc, f->menus);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000399 else
400 fprintf(stderr, "Hmm, didnt find a func for \"%s\"\n", s->keystr);
401 }
402
403}
404#endif
405
406
407/* Stuff we need to make at least static here so we can access it below */
408const char *cancel_msg = N_("Cancel");
409
410#ifndef NANO_TINY
411const char *case_sens_msg = N_("Case Sens");
412const char *backwards_msg = N_("Backwards");
413#endif
414
415#ifdef HAVE_REGEX_H
416const char *regexp_msg = N_("Regexp");
417#endif
418
419/* Stuff we want to just stun out if we're in TINY mode */
420#ifdef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000421const char *gototext_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000422const char *do_para_begin_msg = "";
423const char *do_para_end_msg = "";
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000424const char *case_sens_msg = "";
425const char *backwards_msg = "";
426const char *do_cut_till_end = "";
427const char *dos_format_msg = "";
428const char *mac_format_msg = "";
429const char *append_msg = "";
430const char *prepend_msg = "";
431const char *backup_file_msg = "";
432const char *to_files_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000433const char *first_file_msg = "";
434const char *whereis_next_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000435const char *last_file_msg = "";
436const char *new_buffer_msg = "";
437const char *goto_dir_msg;
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000438const char *ext_cmd_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000439
440#else
Chris Allegrettad3659f82008-03-16 23:57:14 +0000441/* TRANSLATORS: Try to keep the following five strings at most 10
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000442 * characters. */
Chris Allegrettae347efb2008-03-09 02:52:40 +0000443const char *prev_history_msg = N_("PrevHstory");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000444const char *next_history_msg = N_("NextHstory");
445const char *replace_msg = N_("Replace");
446const char *no_replace_msg = N_("No Replace");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000447const char *gototext_msg = N_("Go To Text");
Chris Allegrettae347efb2008-03-09 02:52:40 +0000448/* TRANSLATORS: Try to keep this at most 12 characters. */
449const char *whereis_next_msg = N_("WhereIs Next");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000450#ifndef DISABLE_BROWSER
451/* TRANSLATORS: Try to keep this at most 16 characters. */
452const char *to_files_msg = N_("To Files");
453/* TRANSLATORS: Try to keep this at most 12 characters. */
454const char *first_file_msg = N_("First File");
455/* TRANSLATORS: Try to keep this at most 12 characters. */
456const char *last_file_msg = N_("Last File");
457#endif
458/* TRANSLATORS: Try to keep this at most 16 characters. */
459const char *dos_format_msg = N_("DOS Format");
460/* TRANSLATORS: Try to keep this at most 16 characters. */
461const char *mac_format_msg = N_("Mac Format");
462/* TRANSLATORS: Try to keep this at most 16 characters. */
463const char *append_msg = N_("Append");
464/* TRANSLATORS: Try to keep this at most 16 characters. */
465const char *prepend_msg = N_("Prepend");
466/* TRANSLATORS: Try to keep this at most 16 characters. */
467const char *backup_file_msg = N_("Backup File");
Chris Allegrettad3659f82008-03-16 23:57:14 +0000468/* TRANSLATORS: Try to keep this at most 16 characters. */
Chris Allegrettaeb643142008-03-12 04:44:14 +0000469const char *ext_cmd_msg = N_("Execute Command");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000470
471#ifdef ENABLE_MULTIBUFFER
472/* TRANSLATORS: Try to keep this at most 16 characters. */
473const char *new_buffer_msg = N_("New Buffer");
474#endif
Chris Allegrettae347efb2008-03-09 02:52:40 +0000475const char *goto_dir_msg = N_("Go To Dir");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000476
Chris Allegrettae347efb2008-03-09 02:52:40 +0000477#endif /* NANO_TINY */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000478
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000479/* Initialize all shortcut lists. If unjustify is TRUE, replace the
480 * Uncut shortcut in the main shortcut list with UnJustify. */
David Lawrence Ramsey1f1ebb82004-11-11 21:50:01 +0000481void shortcut_init(bool unjustify)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000482{
David Lawrence Ramseyed467e52006-07-03 18:40:53 +0000483 /* TRANSLATORS: Try to keep this and following strings at most 10
484 * characters. */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000485 const char *get_help_msg = N_("Get Help");
486 const char *exit_msg = N_("Exit");
David Lawrence Ramseye38b8082006-03-30 07:03:04 +0000487 const char *whereis_msg = N_("Where Is");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000488 const char *prev_page_msg = N_("Prev Page");
489 const char *next_page_msg = N_("Next Page");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000490 const char *first_line_msg = N_("First Line");
491 const char *last_line_msg = N_("Last Line");
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000492 const char *suspend_msg = N_("Suspend");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000493#ifndef DISABLE_JUSTIFY
494 const char *beg_of_par_msg = N_("Beg of Par");
495 const char *end_of_par_msg = N_("End of Par");
496 const char *fulljstify_msg = N_("FullJstify");
497#endif
David Lawrence Ramsey81378762006-04-24 20:53:43 +0000498 const char *refresh_msg = N_("Refresh");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000499 const char *insert_file_msg = N_("Insert File");
Chris Allegrettad3659f82008-03-16 23:57:14 +0000500 /* TRANSLATORS: Try to keep this and previous strings at most 10
501 * characters. */
Chris Allegrettae347efb2008-03-09 02:52:40 +0000502 const char *go_to_line_msg = N_("Go To Line");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000503
Chris Allegrettadab017e2002-04-23 10:56:06 +0000504#ifndef DISABLE_HELP
David Lawrence Ramsey804e1072006-03-29 19:43:32 +0000505 const char *nano_cancel_msg = N_("Cancel the current function");
David Lawrence Ramsey57c9afb2006-04-14 20:21:45 +0000506 const char *nano_help_msg = N_("Display this help text");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000507 const char *nano_exit_msg =
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000508#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000509 N_("Close the current file buffer / Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000510#else
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000511 N_("Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000512#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000513 ;
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000514 const char *nano_writeout_msg =
515 N_("Write the current file to disk");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000516 const char *nano_justify_msg = N_("Justify the current paragraph");
517 const char *nano_insert_msg =
518 N_("Insert another file into the current one");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000519 const char *nano_whereis_msg =
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000520 N_("Search for a string or a regular expression");
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000521 const char *nano_prevpage_msg = N_("Go to previous screen");
522 const char *nano_nextpage_msg = N_("Go to next screen");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000523 const char *nano_cut_msg =
524 N_("Cut the current line and store it in the cutbuffer");
525 const char *nano_uncut_msg =
526 N_("Uncut from the cutbuffer into the current line");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000527 const char *nano_cursorpos_msg =
David Lawrence Ramseyf50bd4b2006-04-14 20:15:44 +0000528 N_("Display the position of the cursor");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000529 const char *nano_spell_msg =
530 N_("Invoke the spell checker, if available");
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000531 const char *nano_replace_msg =
532 N_("Replace a string or a regular expression");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000533 const char *nano_gotoline_msg = N_("Go to line and column number");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000534#ifndef NANO_TINY
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000535 const char *nano_mark_msg = N_("Mark text at the cursor position");
536 const char *nano_whereis_next_msg = N_("Repeat last search");
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000537 const char *nano_copy_msg =
538 N_("Copy the current line and store it in the cutbuffer");
David Lawrence Ramseyaee00d42006-07-05 18:42:22 +0000539 const char *nano_indent_msg = N_("Indent the current line");
540 const char *nano_unindent_msg = N_("Unindent the current line");
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000541#endif
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000542 const char *nano_forward_msg = N_("Go forward one character");
543 const char *nano_back_msg = N_("Go back one character");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000544#ifndef NANO_TINY
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000545 const char *nano_nextword_msg = N_("Go forward one word");
546 const char *nano_prevword_msg = N_("Go back one word");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000547#endif
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000548 const char *nano_prevline_msg = N_("Go to previous line");
549 const char *nano_nextline_msg = N_("Go to next line");
550 const char *nano_home_msg = N_("Go to beginning of current line");
551 const char *nano_end_msg = N_("Go to end of current line");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000552#ifndef DISABLE_JUSTIFY
553 const char *nano_parabegin_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000554 N_("Go to beginning of paragraph; then of previous paragraph");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000555 const char *nano_paraend_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000556 N_("Go just beyond end of paragraph; then of next paragraph");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000557#endif
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000558 const char *nano_firstline_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000559 N_("Go to the first line of the file");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000560 const char *nano_lastline_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000561 N_("Go to the last line of the file");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000562#ifndef NANO_TINY
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000563 const char *nano_bracket_msg = N_("Go to the matching bracket");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000564 const char *nano_scrollup_msg =
565 N_("Scroll up one line without scrolling the cursor");
566 const char *nano_scrolldown_msg =
567 N_("Scroll down one line without scrolling the cursor");
568#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000569#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +0000570 const char *nano_prevfile_msg =
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000571 N_("Switch to the previous file buffer");
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +0000572 const char *nano_nextfile_msg =
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000573 N_("Switch to the next file buffer");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000574#endif
David Lawrence Ramsey40e05722006-04-23 19:21:12 +0000575 const char *nano_verbatim_msg =
David Lawrence Ramsey939d4232006-04-24 21:00:17 +0000576 N_("Insert the next keystroke verbatim");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000577 const char *nano_tab_msg =
David Lawrence Ramseybf784202006-04-29 13:59:04 +0000578 N_("Insert a tab at the cursor position");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000579 const char *nano_enter_msg =
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000580 N_("Insert a newline at the cursor position");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000581 const char *nano_delete_msg =
582 N_("Delete the character under the cursor");
583 const char *nano_backspace_msg =
584 N_("Delete the character to the left of the cursor");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000585#ifndef NANO_TINY
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000586 const char *nano_cut_till_end_msg =
587 N_("Cut from the cursor position to the end of the file");
588#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000589#ifndef DISABLE_JUSTIFY
590 const char *nano_fulljustify_msg = N_("Justify the entire file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000591#endif
David Lawrence Ramseyc5c52302005-11-15 23:45:29 +0000592#ifndef NANO_TINY
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000593 const char *nano_wordcount_msg =
594 N_("Count the number of words, lines, and characters");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000595#endif
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000596 const char *nano_refresh_msg =
597 N_("Refresh (redraw) the current screen");
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000598 const char *nano_suspend_msg =
599 N_("Suspend the editor (if suspend is enabled)");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000600#ifndef NANO_TINY
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000601 const char *nano_case_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000602 N_("Toggle the case sensitivity of the search");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000603 const char *nano_reverse_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000604 N_("Reverse the direction of the search");
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000605#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000606#ifdef HAVE_REGEX_H
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000607 const char *nano_regexp_msg =
608 N_("Toggle the use of regular expressions");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000609#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000610#ifndef NANO_TINY
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000611 const char *nano_prev_history_msg =
David Lawrence Ramsey7b0531a2006-07-31 01:30:31 +0000612 N_("Recall the previous search/replace string");
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000613 const char *nano_next_history_msg =
David Lawrence Ramsey7b0531a2006-07-31 01:30:31 +0000614 N_("Recall the next search/replace string");
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000615#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000616#ifndef DISABLE_BROWSER
617 const char *nano_tofiles_msg = N_("Go to file browser");
618#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000619#ifndef NANO_TINY
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000620 const char *nano_dos_msg = N_("Toggle the use of DOS format");
621 const char *nano_mac_msg = N_("Toggle the use of Mac format");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000622#endif
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000623 const char *nano_append_msg = N_("Toggle appending");
624 const char *nano_prepend_msg = N_("Toggle prepending");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000625#ifndef NANO_TINY
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000626 const char *nano_backup_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000627 N_("Toggle backing up of the original file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000628 const char *nano_execute_msg = N_("Execute external command");
629#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000630#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000631 const char *nano_multibuffer_msg =
632 N_("Toggle the use of a new buffer");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000633#endif
634#ifndef DISABLE_BROWSER
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000635 const char *nano_exitbrowser_msg = N_("Exit from the file browser");
David Lawrence Ramseye38b8082006-03-30 07:03:04 +0000636 const char *nano_firstfile_msg =
637 N_("Go to the first file in the list");
638 const char *nano_lastfile_msg =
639 N_("Go to the last file in the list");
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000640 const char *nano_gotodir_msg = N_("Go to directory");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000641
Chris Allegretta2bef1822001-09-28 19:53:11 +0000642#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000643#endif /* !DISABLE_HELP */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000644
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000645#ifndef DISABLE_HELP
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000646#define IFSCHELP(help) help
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000647#else
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000648#define IFSCHELP(help) ""
Chris Allegrettadab017e2002-04-23 10:56:06 +0000649#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000650
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000651 while (allfuncs != NULL) {
652 subnfunc *f = allfuncs;
653 allfuncs = (allfuncs)->next;
654 free(f);
655 }
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000656
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000657#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000658 add_to_funcs(do_help_void, MALL, get_help_msg, nano_help_msg,
659 FALSE, VIEW);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000660#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000661
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000662 add_to_funcs((void *) cancel_msg,
663 (MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000664 cancel_msg, IFSCHELP(nano_cancel_msg), FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000665
666 add_to_funcs(do_exit, MMAIN,
Chris Allegretta355fbe52001-07-14 19:32:47 +0000667#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000668 /* TRANSLATORS: Try to keep this at most 10 characters. */
David Lawrence Ramsey017dde22006-03-24 05:28:03 +0000669 openfile != NULL && openfile != openfile->next ? N_("Close") :
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000670#endif
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000671 exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000672
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000673 add_to_funcs(do_exit, MBROWSER|MHELP, exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000674
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000675 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000676 add_to_funcs(do_writeout_void, MMAIN, N_("WriteOut"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000677 IFSCHELP(nano_writeout_msg), FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000678
David Lawrence Ramseya539fce2004-06-29 00:43:56 +0000679#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000680 /* TRANSLATORS: Try to keep this at most 10 characters. */
681 add_to_funcs(do_justify_void, MMAIN, N_("Justify"),
682 nano_justify_msg, TRUE, NOVIEW);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000683#endif
Chris Allegretta32da4562002-01-02 15:12:21 +0000684
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000685 /* We allow inserting files in view mode if multibuffers are
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000686 * available, so that we can view multiple files. If we're using
687 * restricted mode, inserting files is disabled, since it allows
688 * reading from or writing to files not specified on the command
689 * line. */
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000690 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000691 add_to_funcs(!ISSET(RESTRICTED) ? do_insertfile_void : nano_disabled_msg,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000692 MMAIN, N_("Read File"), IFSCHELP(nano_insert_msg), FALSE,
Chris Allegretta32da4562002-01-02 15:12:21 +0000693#ifdef ENABLE_MULTIBUFFER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000694 VIEW);
Chris Allegretta32da4562002-01-02 15:12:21 +0000695#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000696 NOVIEW);
Chris Allegretta32da4562002-01-02 15:12:21 +0000697#endif
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000698
Chris Allegrettae347efb2008-03-09 02:52:40 +0000699 add_to_funcs(do_search, MMAIN|MBROWSER, whereis_msg,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000700 IFSCHELP(nano_whereis_msg), FALSE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000701
Chris Allegrettae347efb2008-03-09 02:52:40 +0000702 add_to_funcs(do_page_up, MMAIN|MHELP,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000703 prev_page_msg, IFSCHELP(nano_prevpage_msg), FALSE, VIEW);
Chris Allegrettae347efb2008-03-09 02:52:40 +0000704 add_to_funcs(do_page_down, MMAIN|MHELP,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000705 next_page_msg, IFSCHELP(nano_nextpage_msg), TRUE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000706
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000707 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000708 add_to_funcs(do_cut_text_void, MMAIN, N_("Cut Text"), IFSCHELP(nano_cut_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000709 FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000710
Chris Allegretta07798352000-11-27 22:58:23 +0000711 if (unjustify)
David Lawrence Ramseyed467e52006-07-03 18:40:53 +0000712 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000713 add_to_funcs(do_uncut_text, MMAIN, N_("UnJustify"), "",
714 FALSE, NOVIEW);
715
Chris Allegretta07798352000-11-27 22:58:23 +0000716 else
David Lawrence Ramseyed467e52006-07-03 18:40:53 +0000717 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000718 add_to_funcs(do_uncut_text, MMAIN, N_("UnCut Text"), IFSCHELP(nano_uncut_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000719 FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000720
Chris Allegrettae347efb2008-03-09 02:52:40 +0000721#ifndef NANO_TINY
Chris Allegretta0018d8e2008-03-13 08:23:52 +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 Ramseycde90392006-04-09 18:27:42 +0000729 /* TRANSLATORS: Try to keep this at most 10 characters. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000730#ifndef DISABLE_SPELLER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000731 if (!ISSET(RESTRICTED))
732 add_to_funcs(do_spell, MMAIN, N_("To Spell"), nano_spell_msg,
733 TRUE, NOVIEW);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000734#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000735
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000736 add_to_funcs(do_first_line,
737 (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP),
738 first_line_msg, first_line_msg, FALSE, VIEW);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000739
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000740 add_to_funcs(do_last_line,
741 (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
745 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 /* TRANSLATORS: Try to keep this at most 10 characters. */
749#ifdef NANO_TINY
Chris Allegretta0018d8e2008-03-13 08:23:52 +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 Allegretta0018d8e2008-03-13 08:23:52 +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 Allegretta79a33bb2008-03-05 07:34:01 +0000766 add_to_funcs(do_mark, MMAIN, N_("Mark Text"),
767 nano_mark_msg, FALSE, VIEW);
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000768
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000769 add_to_funcs(do_research, (MMAIN|MBROWSER), whereis_next_msg,
770 nano_whereis_next_msg, TRUE, VIEW);
David Lawrence Ramseyf85001a2006-04-28 13:19:56 +0000771
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000772 add_to_funcs(do_copy_text, MMAIN, N_("Copy Text"),
773 nano_copy_msg, FALSE, NOVIEW);
David Lawrence Ramseyf85001a2006-04-28 13:19:56 +0000774
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000775 add_to_funcs(do_indent_void, MMAIN, N_("Indent Text"),
776 nano_indent_msg, FALSE, NOVIEW);
777
778 add_to_funcs(do_unindent, MMAIN, N_("Unindent Text"),
779 nano_unindent_msg, TRUE, NOVIEW);
780
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000781#endif
782
Chris Allegrettae347efb2008-03-09 02:52:40 +0000783 add_to_funcs(do_page_up, MBROWSER,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000784 prev_page_msg, IFSCHELP(nano_prevpage_msg), FALSE, VIEW);
Chris Allegrettae347efb2008-03-09 02:52:40 +0000785 add_to_funcs(do_page_down, MBROWSER,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000786 next_page_msg, IFSCHELP(nano_nextpage_msg), TRUE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000787
Chris Allegrettae347efb2008-03-09 02:52:40 +0000788
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000789 add_to_funcs(do_right, (MMAIN|MBROWSER), N_("Forward"), IFSCHELP(nano_forward_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000790 FALSE, VIEW);
Chris Allegrettaeb643142008-03-12 04:44:14 +0000791 add_to_funcs(do_right, MALL, "", "", FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000792
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000793 add_to_funcs(do_left, (MMAIN|MBROWSER), N_("Back"), IFSCHELP(nano_back_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000794 FALSE, VIEW);
Chris Allegrettaeb643142008-03-12 04:44:14 +0000795 add_to_funcs(do_left, MALL, "", "", FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000796
797#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000798 add_to_funcs(do_next_word_void, MMAIN, N_("Next Word"),
799 nano_nextword_msg, FALSE, VIEW);
David Lawrence Ramseyc5967552002-06-21 03:20:06 +0000800
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000801 add_to_funcs(do_prev_word_void, MMAIN, N_("Prev Word"),
802 nano_prevword_msg, FALSE, VIEW);
Chris Allegretta8d990b52001-09-22 22:14:25 +0000803#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000804
Chris Allegrettae347efb2008-03-09 02:52:40 +0000805 add_to_funcs(do_up_void, (MMAIN|MHELP|MBROWSER), N_("Prev Line"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000806 IFSCHELP(nano_prevline_msg), FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000807
Chris Allegrettae347efb2008-03-09 02:52:40 +0000808 add_to_funcs(do_down_void, (MMAIN|MHELP|MBROWSER), N_("Next Line"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000809 IFSCHELP(nano_nextline_msg), TRUE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000810
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000811 add_to_funcs(do_home, MMAIN, N_("Home"), IFSCHELP(nano_home_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000812 FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000813
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000814 add_to_funcs(do_end, MMAIN, N_("End"), IFSCHELP(nano_end_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000815 FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000816
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000817#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000818 add_to_funcs(do_para_begin_void, (MMAIN|MWHEREIS), beg_of_par_msg,
819 nano_parabegin_msg, FALSE, VIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000820
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000821 add_to_funcs(do_para_end_void, (MMAIN|MWHEREIS), end_of_par_msg,
822 nano_paraend_msg, FALSE, VIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000823#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000824
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000825#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000826 add_to_funcs(do_find_bracket, MMAIN, _("Find Other Bracket"),
827 nano_bracket_msg, FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000828
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000829 add_to_funcs(do_scroll_up, MMAIN, N_("Scroll Up"),
830 nano_scrollup_msg, FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000831
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000832 add_to_funcs(do_scroll_down, MMAIN, N_("Scroll Down"),
833 nano_scrolldown_msg, FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000834#endif
David Lawrence Ramseydf453652006-04-21 02:05:09 +0000835
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000836#ifdef ENABLE_MULTIBUFFER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000837 add_to_funcs(switch_to_prev_buffer_void, MMAIN, _("Previous File"),
838 nano_prevfile_msg, FALSE, VIEW);
839 add_to_funcs(switch_to_next_buffer_void, MMAIN, N_("Next File"),
840 nano_nextfile_msg, TRUE, VIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000841#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +0000842
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000843 add_to_funcs(do_verbatim_input, MMAIN, N_("Verbatim Input"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000844 IFSCHELP(nano_verbatim_msg), FALSE, NOVIEW);
845 add_to_funcs(do_tab, MMAIN, N_("Tab"), IFSCHELP(nano_tab_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000846 FALSE, NOVIEW);
Chris Allegrettaeb643142008-03-12 04:44:14 +0000847 add_to_funcs(do_tab, MALL, "", "", FALSE, NOVIEW);
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000848 add_to_funcs(do_enter, MMAIN, N_("Enter"), IFSCHELP(nano_enter_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000849 FALSE, NOVIEW);
Chris Allegrettaeb643142008-03-12 04:44:14 +0000850 add_to_funcs(do_enter, MALL, "", "", FALSE, NOVIEW);
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000851 add_to_funcs(do_delete, MMAIN, N_("Delete"), IFSCHELP(nano_delete_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000852 FALSE, NOVIEW);
Chris Allegrettaeb643142008-03-12 04:44:14 +0000853 add_to_funcs(do_delete, MALL, "", "", FALSE, NOVIEW);
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000854 add_to_funcs(do_backspace, MMAIN, N_("Backspace"), IFSCHELP(nano_backspace_msg),
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000855#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000856 FALSE,
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000857#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000858 TRUE,
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000859#endif
Chris Allegrettaeb643142008-03-12 04:44:14 +0000860 NOVIEW);
861
862 add_to_funcs(do_backspace, MALL, "", "",
863#ifndef NANO_TINY
864 FALSE,
865#else
866 TRUE,
867#endif
868 NOVIEW);
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000869
David Lawrence Ramsey2ca23562006-04-23 19:15:15 +0000870#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000871 add_to_funcs(do_cut_till_end, MMAIN, N_("CutTillEnd"),
872 nano_cut_till_end_msg, TRUE, NOVIEW);
David Lawrence Ramsey2ca23562006-04-23 19:15:15 +0000873#endif
874
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000875 add_to_funcs(xon_complaint, MMAIN, "", "", FALSE, VIEW);
876 add_to_funcs(xoff_complaint, MMAIN, "", "", FALSE, VIEW);
877
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000878#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000879 add_to_funcs(do_full_justify, (MMAIN|MWHEREIS), fulljstify_msg,
880 nano_fulljustify_msg, FALSE, NOVIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000881#endif
882
David Lawrence Ramseyc5c52302005-11-15 23:45:29 +0000883#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000884 add_to_funcs(do_wordlinechar_count, MMAIN, N_("Word Count"),
885 nano_wordcount_msg, FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000886#endif
David Lawrence Ramseyefb4b0a2006-04-19 14:09:01 +0000887
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000888 add_to_funcs(total_refresh, (MMAIN|MHELP), refresh_msg,
889 IFSCHELP(nano_refresh_msg), FALSE, VIEW);
890
891 add_to_funcs(do_suspend_void, MMAIN, suspend_msg,
892 IFSCHELP(nano_suspend_msg), TRUE, VIEW);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000893
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000894#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000895 add_to_funcs((void *) case_sens_msg,
896 (MWHEREIS|MREPLACE|MWHEREISFILE),
897 case_sens_msg, nano_case_msg, FALSE, VIEW);
Chris Allegretta658399a2001-06-14 02:54:22 +0000898
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000899 add_to_funcs((void *) backwards_msg,
900 (MWHEREIS|MREPLACE|MWHEREISFILE),
901 backwards_msg, nano_reverse_msg, FALSE, VIEW);
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000902#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000903
Chris Allegretta658399a2001-06-14 02:54:22 +0000904#ifdef HAVE_REGEX_H
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000905 add_to_funcs((void *) regexp_msg,
906 (MWHEREIS|MREPLACE|MWHEREISFILE),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000907 regexp_msg, IFSCHELP(nano_regexp_msg), FALSE, VIEW);
Chris Allegretta658399a2001-06-14 02:54:22 +0000908#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000909
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000910#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000911 add_to_funcs((void *) prev_history_msg,
912 (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE),
913 prev_history_msg, nano_prev_history_msg, FALSE, VIEW);
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000914
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000915 add_to_funcs((void *) next_history_msg,
916 (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE),
917 next_history_msg, nano_next_history_msg, FALSE, VIEW);
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000918#endif
David Lawrence Ramsey02085d72004-11-07 16:04:18 +0000919
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000920 add_to_funcs((void *) no_replace_msg, MREPLACE,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000921 no_replace_msg, IFSCHELP(nano_whereis_msg), FALSE, VIEW);
Chris Allegretta5f36c372001-07-16 00:48:53 +0000922
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000923 add_to_funcs((void *) gototext_msg, MGOTOLINE,
Chris Allegretta10f868d2008-03-14 04:08:51 +0000924 gototext_msg, IFSCHELP(nano_whereis_msg), TRUE, VIEW);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000925
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000926#ifndef DISABLE_BROWSER
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000927 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000928 add_to_funcs((void *) to_files_msg,
929 (MGOTOLINE|MINSERTFILE),
930 to_files_msg, nano_tofiles_msg, FALSE, VIEW);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000931#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000932
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000933#ifndef NANO_TINY
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000934 /* If we're using restricted mode, the DOS format, Mac format,
935 * append, prepend, and backup toggles are disabled. The first and
936 * second are useless since inserting files is disabled, the third
937 * and fourth are disabled because they allow writing to files not
938 * specified on the command line, and the fifth is useless since
939 * backups are disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000940 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000941 add_to_funcs((void *) dos_format_msg, MWRITEFILE,
942 dos_format_msg, nano_dos_msg, FALSE, NOVIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000943
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000944 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000945 add_to_funcs((void *) mac_format_msg, MWRITEFILE,
946 mac_format_msg, nano_mac_msg, FALSE, NOVIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000947
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000948 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000949 add_to_funcs((void *) append_msg, MWRITEFILE,
950 append_msg, nano_append_msg, FALSE, NOVIEW);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000951
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000952 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000953 add_to_funcs((void *) prepend_msg, MWRITEFILE,
954 prepend_msg, nano_prepend_msg, FALSE, NOVIEW);
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000955
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000956 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000957 add_to_funcs((void *) backup_file_msg, MWRITEFILE,
958 backup_file_msg, nano_backup_msg, FALSE, NOVIEW);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000959#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000960
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000961#ifndef NANO_TINY
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000962 /* If we're using restricted mode, command execution is disabled.
963 * It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000964 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000965 add_to_funcs((void *) ext_cmd_msg, MINSERTFILE,
966 ext_cmd_msg, nano_execute_msg, FALSE, NOVIEW);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000967
Chris Allegrettaf7c68112002-09-03 22:58:40 +0000968#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000969 /* If we're using restricted mode, the multibuffer toggle is
970 * disabled. It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000971 if (!ISSET(RESTRICTED))
Chris Allegretta10f868d2008-03-14 04:08:51 +0000972 add_to_funcs((void *) new_buffer_msg, MINSERTFILE,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000973 new_buffer_msg, nano_multibuffer_msg, FALSE, NOVIEW);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000974#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000975
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000976 add_to_funcs((void *) insert_file_msg, MEXTCMD,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000977 insert_file_msg, IFSCHELP(nano_insert_msg), FALSE, VIEW);
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000978
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000979#ifdef ENABLE_MULTIBUFFER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000980 add_to_funcs((void *) new_buffer_msg, MEXTCMD,
981 new_buffer_msg, nano_multibuffer_msg, FALSE, NOVIEW);
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000982#endif
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000983#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000984
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000985#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000986 add_to_funcs((void *) refresh_msg, MHELP,
987 refresh_msg, nano_refresh_msg, FALSE, VIEW);
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000988#endif
989
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000990#ifndef DISABLE_BROWSER
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000991
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000992 add_to_funcs((void *) first_file_msg,
993 (MBROWSER|MWHEREISFILE),
994 first_file_msg, nano_firstfile_msg, FALSE, VIEW);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000995
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000996 add_to_funcs((void *) last_file_msg,
997 (MBROWSER|MWHEREISFILE),
998 last_file_msg, nano_lastfile_msg, FALSE, VIEW);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000999
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001000 add_to_funcs((void *) goto_dir_msg, MBROWSER,
1001 goto_dir_msg, nano_gotodir_msg, FALSE, VIEW);
David Lawrence Ramseye38b8082006-03-30 07:03:04 +00001002#endif
1003
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001004 currmenu = MMAIN;
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001005
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001006#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001007 add_to_sclist(MALL, "^G", do_help_void, 0, TRUE);
1008 add_to_sclist(MALL, "F1", do_help_void, 0, TRUE);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001009#endif
Chris Allegrettae347efb2008-03-09 02:52:40 +00001010 add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", do_exit, 0, TRUE);
1011 add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", do_exit, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001012 add_to_sclist(MMAIN, "^_", do_gotolinecolumn_void, 0, TRUE);
1013 add_to_sclist(MMAIN, "F13", do_gotolinecolumn_void, 0, TRUE);
1014 add_to_sclist(MMAIN, "^O", do_writeout_void, 0, TRUE);
1015 add_to_sclist(MMAIN, "F3", do_writeout_void, 0, TRUE);
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001016#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001017 add_to_sclist(MMAIN, "^J", do_justify_void, 0, TRUE);
1018 add_to_sclist(MMAIN, "F4", do_justify_void, 0, TRUE);
1019#endif
1020 add_to_sclist(MMAIN, "^R", do_insertfile_void, 0, TRUE);
1021 add_to_sclist(MMAIN, "F5", do_insertfile_void, 0, TRUE);
Chris Allegretta17436ce2008-03-11 03:03:53 +00001022 add_to_sclist(MMAIN, "kinsert", do_insertfile_void, 0, TRUE);
Chris Allegrettae347efb2008-03-09 02:52:40 +00001023 add_to_sclist(MMAIN|MBROWSER, "^W", do_search, 0, TRUE);
1024 add_to_sclist(MMAIN|MBROWSER, "F6", do_search, 0, TRUE);
Chris Allegretta17436ce2008-03-11 03:03:53 +00001025 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "^Y", do_page_up, 0, TRUE);
1026 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "F7", do_page_up, 0, TRUE);
1027 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "kpup", do_page_up, 0, TRUE);
1028 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "^V", do_page_down, 0, TRUE);
1029 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "F8", do_page_down, 0, TRUE);
1030 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "kpdown", do_page_down, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001031 add_to_sclist(MMAIN, "^K", do_cut_text_void, 0, TRUE);
1032 add_to_sclist(MMAIN, "F9", do_cut_text_void, 0, TRUE);
1033 add_to_sclist(MMAIN, "^U", do_uncut_text, 0, TRUE);
1034 add_to_sclist(MMAIN, "F10", do_uncut_text, 0, TRUE);
1035 add_to_sclist(MMAIN, "^C", do_cursorpos_void, 0, TRUE);
1036 add_to_sclist(MMAIN, "F11", do_cursorpos_void, 0, TRUE);
1037#ifndef NANO_TINY
1038 add_to_sclist(MMAIN, "^T", do_spell, 0, TRUE);
1039 add_to_sclist(MMAIN, "F12", do_spell, 0, TRUE);
1040#endif
1041 add_to_sclist(MMAIN, "^_", do_gotolinecolumn_void, 0, TRUE);
1042 add_to_sclist(MMAIN, "F13", do_gotolinecolumn_void, 0, TRUE);
1043 add_to_sclist(MMAIN, "M-G", do_gotolinecolumn_void, 0, TRUE);
1044 add_to_sclist(MMAIN, "^\\", do_replace, 0, TRUE);
1045 add_to_sclist(MMAIN, "F14", do_replace, 0, TRUE);
1046 add_to_sclist(MMAIN, "M-R", do_replace, 0, TRUE);
1047 add_to_sclist(MWHEREIS, "^R", do_replace, 0, FALSE);
1048 add_to_sclist(MREPLACE, "^R", (void *) no_replace_msg, 0, FALSE);
1049 add_to_sclist(MWHEREIS, "^T", do_gotolinecolumn_void, 0, TRUE);
1050#ifndef NANO_TINY
1051 add_to_sclist(MMAIN, "^^", do_mark, 0, TRUE);
1052 add_to_sclist(MMAIN, "F15", do_mark, 0, TRUE);
1053 add_to_sclist(MMAIN, "M-A", do_mark, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001054 add_to_sclist(MALL, "M-W", do_research, 0, TRUE);
Chris Allegrettae347efb2008-03-09 02:52:40 +00001055 add_to_sclist(MALL, "F16", do_research, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001056 add_to_sclist(MMAIN, "M-^", do_copy_text, 0, TRUE);
1057 add_to_sclist(MMAIN, "M-6", do_copy_text, 0, TRUE);
1058 add_to_sclist(MMAIN, "M-}", do_indent_void, 0, TRUE);
1059 add_to_sclist(MMAIN, "M-{", do_unindent, 0, TRUE);
Chris Allegrettaeb643142008-03-12 04:44:14 +00001060 add_to_sclist(MALL, "^F", do_right, 0, TRUE);
1061 add_to_sclist(MALL, "kright", do_right, 0, TRUE);
1062 add_to_sclist(MALL, "^B", do_left, 0, TRUE);
1063 add_to_sclist(MALL, "kleft", do_left, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001064 add_to_sclist(MMAIN, "^Space", do_next_word_void, 0, TRUE);
1065 add_to_sclist(MMAIN, "M-Space", do_prev_word_void, 0, TRUE);
1066#endif
Chris Allegrettaeb643142008-03-12 04:44:14 +00001067 add_to_sclist(MMAIN, "^Q", xon_complaint, 0, TRUE);
1068 add_to_sclist(MMAIN, "^S", xoff_complaint, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001069 add_to_sclist(MALL, "^P", do_up_void, 0, TRUE);
Chris Allegretta17436ce2008-03-11 03:03:53 +00001070 add_to_sclist(MALL, "kup", do_up_void, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001071 add_to_sclist(MALL, "^N", do_down_void, 0, TRUE);
Chris Allegretta17436ce2008-03-11 03:03:53 +00001072 add_to_sclist(MALL, "kdown", do_down_void, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001073 add_to_sclist(MALL, "^A", do_home, 0, TRUE);
Chris Allegretta17436ce2008-03-11 03:03:53 +00001074 add_to_sclist(MALL, "khome", do_home, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001075 add_to_sclist(MALL, "^E", do_end, 0, TRUE);
Chris Allegretta17436ce2008-03-11 03:03:53 +00001076 add_to_sclist(MALL, "kend", do_end, 0, TRUE);
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001077#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001078 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1079 "^W", do_para_begin_void, 0, TRUE);
1080 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1081 "^O", do_para_end_void, 0, TRUE);
1082 add_to_sclist(MALL, "M-(", do_para_begin_void, 0, TRUE);
1083 add_to_sclist(MALL, "M-9", do_para_begin_void, 0, TRUE);
1084 add_to_sclist(MALL, "M-)", do_para_end_void, 0, TRUE);
1085 add_to_sclist(MALL, "M-0", do_para_end_void, 0, TRUE);
Chris Allegrettae347efb2008-03-09 02:52:40 +00001086#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001087 add_to_sclist(MWHEREIS,
1088 "M-C", (void *) case_sens_msg, 0, FALSE);
1089 add_to_sclist(MREPLACE,
1090 "M-C", (void *) case_sens_msg, 0, FALSE);
1091 add_to_sclist(MREPLACE2,
1092 "M-C", (void *) case_sens_msg, 0, FALSE);
1093 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1094 "M-B", (void *) backwards_msg, 0, FALSE);
1095 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1096 "M-R", (void *) regexp_msg, 0, FALSE);
1097
1098 add_to_sclist(MMAIN, "M-\\", do_first_line, 0, TRUE);
1099 add_to_sclist(MMAIN, "M-|", do_first_line, 0, TRUE);
1100 add_to_sclist(MMAIN, "M-/", do_last_line, 0, TRUE);
1101 add_to_sclist(MMAIN, "M-?", do_last_line, 0, TRUE);
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001102 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP,
1103 "^Y", do_first_line, 0, TRUE);
1104 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP,
1105 "^V", do_last_line, 0, TRUE);
1106
Chris Allegrettae347efb2008-03-09 02:52:40 +00001107 add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", (void *) first_file_msg, 0, TRUE);
1108 add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", (void *) first_file_msg, 0, TRUE);
1109 add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", (void *) last_file_msg, 0, TRUE);
1110 add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", (void *) last_file_msg, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001111#ifndef NANO_TINY
1112 add_to_sclist(MMAIN, "M-[", do_find_bracket, 0, TRUE);
1113 add_to_sclist(MMAIN, "M--", do_scroll_up, 0, TRUE);
1114 add_to_sclist(MMAIN, "M-_", do_scroll_up, 0, TRUE);
1115 add_to_sclist(MMAIN, "M-+", do_scroll_down, 0, TRUE);
1116 add_to_sclist(MMAIN, "M-=", do_scroll_down, 0, TRUE);
1117#endif
1118
1119#ifdef ENABLE_MULTIBUFFER
1120 add_to_sclist(MMAIN, "M-<", switch_to_prev_buffer_void, 0, TRUE);
1121 add_to_sclist(MMAIN, "M-,", switch_to_prev_buffer_void, 0, TRUE);
1122 add_to_sclist(MMAIN, "M->", switch_to_next_buffer_void, 0, TRUE);
1123 add_to_sclist(MMAIN, "M-.", switch_to_next_buffer_void, 0, TRUE);
1124#endif
1125 add_to_sclist(MMAIN, "M-V", do_verbatim_input, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001126#ifndef NANO_TINY
Chris Allegrettae347efb2008-03-09 02:52:40 +00001127 add_to_sclist(MALL, "M-T", do_cut_till_end, 0, TRUE);
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001128#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001129 add_to_sclist(MALL, "M-J", do_full_justify, 0, TRUE);
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001130#endif
Chris Allegretta10f868d2008-03-14 04:08:51 +00001131 add_to_sclist(MMAIN, "M-D", do_wordlinechar_count, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001132 add_to_sclist(MMAIN, "M-X", do_toggle, NO_HELP, TRUE);
1133 add_to_sclist(MMAIN, "M-C", do_toggle, CONST_UPDATE, TRUE);
1134 add_to_sclist(MMAIN, "M-O", do_toggle, MORE_SPACE, TRUE);
1135 add_to_sclist(MMAIN, "M-S", do_toggle, SMOOTH_SCROLL, TRUE);
1136 add_to_sclist(MMAIN, "M-P", do_toggle, WHITESPACE_DISPLAY, TRUE);
1137 add_to_sclist(MMAIN, "M-Y", do_toggle, NO_COLOR_SYNTAX, TRUE);
1138 add_to_sclist(MMAIN, "M-H", do_toggle, SMART_HOME, TRUE);
1139 add_to_sclist(MMAIN, "M-I", do_toggle, AUTOINDENT, TRUE);
1140 add_to_sclist(MMAIN, "M-K", do_toggle, CUT_TO_END, TRUE);
1141 add_to_sclist(MMAIN, "M-L", do_toggle, NO_WRAP, TRUE);
1142 add_to_sclist(MMAIN, "M-Q", do_toggle, TABS_TO_SPACES, TRUE);
1143 add_to_sclist(MMAIN, "M-B", do_toggle, BACKUP_FILE, TRUE);
1144 add_to_sclist(MMAIN, "M-F", do_toggle, MULTIBUFFER, TRUE);
1145 add_to_sclist(MMAIN, "M-M", do_toggle, USE_MOUSE, TRUE);
1146 add_to_sclist(MMAIN, "M-N", do_toggle, NO_CONVERT, TRUE);
1147 add_to_sclist(MMAIN, "M-Z", do_toggle, SUSPEND, TRUE);
1148#endif
Chris Allegretta10f868d2008-03-14 04:08:51 +00001149 add_to_sclist(MGOTOLINE, "^T", (void *) gototext_msg, 0, FALSE);
1150 add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", (void *) new_buffer_msg, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001151 add_to_sclist((MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR),
1152 "^C", (void *) cancel_msg, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001153 add_to_sclist(MHELP, "^X", do_exit, 0, TRUE);
1154 add_to_sclist(MHELP, "F2", do_exit, 0, TRUE);
1155 add_to_sclist(MWRITEFILE, "M-D", (void *) dos_format_msg, 0, FALSE);
1156 add_to_sclist(MWRITEFILE, "M-M", (void *) mac_format_msg, 0, FALSE);
1157 add_to_sclist(MWRITEFILE, "M-A", (void *) append_msg, 0, FALSE);
1158 add_to_sclist(MWRITEFILE, "M-P", (void *) prepend_msg, 0, FALSE);
1159 add_to_sclist(MWRITEFILE, "M-B", (void *) backup_file_msg, 0, FALSE);
1160 add_to_sclist(MWRITEFILE, "^T", (void *) to_files_msg, 0, FALSE);
1161 add_to_sclist(MINSERTFILE, "^T", (void *) to_files_msg, 0, FALSE);
1162 add_to_sclist(MINSERTFILE, "^X", (void *) ext_cmd_msg, 0, FALSE);
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001163 add_to_sclist(MMAIN, "^Z", do_suspend_void, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001164 add_to_sclist(MMAIN, "^L", total_refresh, 0, TRUE);
Chris Allegretta10f868d2008-03-14 04:08:51 +00001165 add_to_sclist(MALL, "^I", do_tab, 0, TRUE);
1166 add_to_sclist(MALL, "^M", do_enter, 0, TRUE);
1167 add_to_sclist(MALL, "kenter", do_enter, 0, TRUE);
1168 add_to_sclist(MALL, "^D", do_delete, 0, TRUE);
1169 add_to_sclist(MALL, "kdel", do_delete, 0, TRUE);
1170 add_to_sclist(MALL, "^H", do_backspace, 0, TRUE);
1171 add_to_sclist(MALL, "kbsp", do_backspace, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001172
1173#ifdef DEBUG
1174 print_sclist();
1175#endif
1176
Chris Allegrettadab017e2002-04-23 10:56:06 +00001177}
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001178
David Lawrence Ramseye6757b92006-04-19 13:36:56 +00001179/* Free the given shortcut. */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001180void free_shortcutage(shortcut **shortcutage)
1181{
1182 assert(shortcutage != NULL);
David Lawrence Ramsey193b0e52005-06-06 18:41:17 +00001183
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001184 while (*shortcutage != NULL) {
1185 shortcut *ps = *shortcutage;
1186 *shortcutage = (*shortcutage)->next;
1187 free(ps);
1188 }
1189}
1190
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001191const subnfunc *sctofunc(sc *s)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001192{
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001193 subnfunc *f;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001194
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001195 for (f = allfuncs; f != NULL && s->scfunc != f->scfunc; f = f->next)
1196 ;
1197
1198 return f;
1199}
1200
1201#ifndef NANO_TINY
1202/* Now lets come up with a single (hopefully)
1203 function to get a string for each flag */
1204char *flagtostr(int flag)
1205{
1206 switch (flag) {
1207 case NO_HELP:
1208 return N_("Help mode");
1209 case CONST_UPDATE:
1210 return N_("Constant cursor position display");
1211 case MORE_SPACE:
1212 return N_("Use of one more line for editing");
1213 case SMOOTH_SCROLL:
1214 return N_("Smooth scrolling");
1215 case WHITESPACE_DISPLAY:
1216 return N_("Whitespace display");
1217 case NO_COLOR_SYNTAX:
1218 return N_("Color syntax highlighting");
1219 case SMART_HOME:
1220 return N_("Smart home key");
1221 case AUTOINDENT:
1222 return N_("Auto indent");
1223 case CUT_TO_END:
1224 return N_("Cut to end");
1225 case NO_WRAP:
1226 return N_("Long line wrapping");
1227 case TABS_TO_SPACES:
1228 return N_("Conversion of typed tabs to spaces");
1229 case BACKUP_FILE:
1230 return N_("Backup files");
1231 case MULTIBUFFER:
1232 return N_("Multiple file buffers");
1233 case USE_MOUSE:
1234 return N_("Mouse support");
1235 case NO_CONVERT:
1236 return N_("No conversion from DOS/Mac format");
1237 case SUSPEND:
1238 return N_("Suspension");
1239 default:
1240 return "?????";
1241 }
1242}
Chris Allegrettae347efb2008-03-09 02:52:40 +00001243#endif /* NANO_TINY */
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001244
1245/* Interpret the string given by the rc file and return a
1246 shortcut struct, complete with proper value for execute */
1247sc *strtosc(int menu, char *input)
1248{
1249 sc *s;
1250
1251 s = (sc *)nmalloc(sizeof(sc));
1252 s->execute = TRUE; /* overridden as needed below */
1253
Chris Allegrettae347efb2008-03-09 02:52:40 +00001254
1255#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001256 if (!strcasecmp(input, "help"))
1257 s->scfunc = do_help_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001258 else
1259#endif
1260 if (!strcasecmp(input, "cancel")) {
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001261 s->scfunc = (void *) cancel_msg;
1262 s->execute = FALSE;
1263 } else if (!strcasecmp(input, "exit"))
1264 s->scfunc = do_exit;
1265 else if (!strcasecmp(input, "writeout"))
1266 s->scfunc = do_writeout_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001267 else if (!strcasecmp(input, "insert"))
1268 s->scfunc = do_insertfile_void;
1269 else if (!strcasecmp(input, "whereis"))
1270 s->scfunc = do_search;
1271 else if (!strcasecmp(input, "up"))
Chris Allegretta17436ce2008-03-11 03:03:53 +00001272 s->scfunc = do_up_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001273 else if (!strcasecmp(input, "down"))
Chris Allegretta17436ce2008-03-11 03:03:53 +00001274 s->scfunc = do_down_void;
1275 else if (!strcasecmp(input, "pageup")
1276 || !strcasecmp(input, "prevpage"))
1277 s->scfunc = do_page_up;
1278 else if (!strcasecmp(input, "pagedown")
1279 || !strcasecmp(input, "nextpage"))
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001280 s->scfunc = do_page_down;
1281 else if (!strcasecmp(input, "cut"))
1282 s->scfunc = do_cut_text_void;
1283 else if (!strcasecmp(input, "uncut"))
1284 s->scfunc = do_uncut_text;
1285 else if (!strcasecmp(input, "curpos") ||
1286 !strcasecmp(input, "cursorpos"))
1287 s->scfunc = do_cursorpos_void;
1288 else if (!strcasecmp(input, "firstline"))
1289 s->scfunc = do_first_line;
1290 else if (!strcasecmp(input, "lastline"))
1291 s->scfunc = do_last_line;
1292 else if (!strcasecmp(input, "gotoline"))
1293 s->scfunc = do_gotolinecolumn_void;
1294 else if (!strcasecmp(input, "replace"))
1295 s->scfunc = do_replace;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001296#ifndef DISABLE_JUSTIFY
Chris Allegrettae347efb2008-03-09 02:52:40 +00001297 else if (!strcasecmp(input, "justify"))
1298 s->scfunc = do_justify_void;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001299 else if (!strcasecmp(input, "beginpara"))
1300 s->scfunc = do_para_begin_void;
1301 else if (!strcasecmp(input, "endpara"))
1302 s->scfunc = do_para_end_void;
1303 else if (!strcasecmp(input, "fulljustify"))
1304 s->scfunc = do_full_justify;
1305#endif
1306#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001307 else if (!strcasecmp(input, "mark"))
1308 s->scfunc = do_mark;
1309 else if (!strcasecmp(input, "searchagain") ||
1310 !strcasecmp(input, "research"))
1311 s->scfunc = do_research;
1312 else if (!strcasecmp(input, "copytext"))
1313 s->scfunc = do_copy_text;
1314 else if (!strcasecmp(input, "indent"))
1315 s->scfunc = do_indent_void;
1316 else if (!strcasecmp(input, "unindent"))
1317 s->scfunc = do_unindent;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001318 else if (!strcasecmp(input, "scrollup"))
1319 s->scfunc = do_scroll_up;
1320 else if (!strcasecmp(input, "scrolldown"))
1321 s->scfunc = do_scroll_down;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001322 else if (!strcasecmp(input, "nextword"))
1323 s->scfunc = do_next_word_void;
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001324 else if (!strcasecmp(input, "suspend"))
1325 s->scfunc = do_suspend_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001326 else if (!strcasecmp(input, "prevword"))
1327 s->scfunc = do_prev_word_void;
1328 else if (!strcasecmp(input, "findbracket"))
1329 s->scfunc = do_find_bracket;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001330 else if (!strcasecmp(input, "wordcount"))
1331 s->scfunc = do_wordlinechar_count;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001332 else if (!strcasecmp(input, "prevhistory")) {
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001333 s->scfunc = (void *) prev_history_msg;
1334 s->execute = FALSE;
1335 } else if (!strcasecmp(input, "nexthistory")) {
1336 s->scfunc = (void *) next_history_msg;
1337 s->execute = FALSE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001338 } else if (!strcasecmp(input, "nohelp") ||
1339 !strcasecmp(input, "nohelp")) {
1340 s->scfunc = (void *) do_toggle;
1341 s->execute = FALSE;
1342 s->toggle = NO_HELP;
1343 } else if (!strcasecmp(input, "constupdate")) {
1344 s->scfunc = (void *) do_toggle;
1345 s->execute = FALSE;
1346 s->toggle = CONST_UPDATE;
1347 } else if (!strcasecmp(input, "morespace")) {
1348 s->scfunc = (void *) do_toggle;
1349 s->execute = FALSE;
1350 s->toggle = MORE_SPACE;
1351 } else if (!strcasecmp(input, "smoothscroll")) {
1352 s->scfunc = (void *) do_toggle;
1353 s->execute = FALSE;
1354 s->toggle = SMOOTH_SCROLL;
Chris Allegrettad3659f82008-03-16 23:57:14 +00001355 } else if (!strcasecmp(input, "whitespacedisplay")) {
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001356 s->scfunc = (void *) do_toggle;
1357 s->execute = FALSE;
1358 s->toggle = WHITESPACE_DISPLAY;
1359 } else if (!strcasecmp(input, "nosyntax")) {
1360 s->scfunc = (void *) do_toggle;
1361 s->execute = FALSE;
1362 s->toggle = NO_COLOR_SYNTAX;
1363 } else if (!strcasecmp(input, "smarthome")) {
1364 s->scfunc = (void *) do_toggle;
1365 s->execute = FALSE;
1366 s->toggle = SMART_HOME;
1367 } else if (!strcasecmp(input, "autoindent")) {
1368 s->scfunc = (void *) do_toggle;
1369 s->execute = FALSE;
1370 s->toggle = AUTOINDENT;
1371 } else if (!strcasecmp(input, "cuttoend")) {
1372 s->scfunc = (void *) do_toggle;
1373 s->execute = FALSE;
1374 s->toggle = CUT_TO_END;
1375 } else if (!strcasecmp(input, "nowrap")) {
1376 s->scfunc = (void *) do_toggle;
1377 s->execute = FALSE;
1378 s->toggle = NO_WRAP;
1379 } else if (!strcasecmp(input, "tabstospaces")) {
1380 s->scfunc = (void *) do_toggle;
1381 s->execute = FALSE;
1382 s->toggle = TABS_TO_SPACES;
1383 } else if (!strcasecmp(input, "backupfile")) {
1384 s->scfunc = (void *) do_toggle;
1385 s->execute = FALSE;
1386 s->toggle = BACKUP_FILE;
1387 } else if (!strcasecmp(input, "mutlibuffer")) {
1388 s->scfunc = (void *) do_toggle;
1389 s->execute = FALSE;
1390 s->toggle = MULTIBUFFER;
1391 } else if (!strcasecmp(input, "mouse")) {
1392 s->scfunc = (void *) do_toggle;
1393 s->execute = FALSE;
1394 s->toggle = USE_MOUSE;
1395 } else if (!strcasecmp(input, "noconvert")) {
1396 s->scfunc = (void *) do_toggle;
1397 s->execute = FALSE;
1398 s->toggle = NO_CONVERT;
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001399 } else if (!strcasecmp(input, "suspendenable")) {
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001400 s->scfunc = (void *) do_toggle;
1401 s->execute = FALSE;
1402 s->toggle = SUSPEND;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001403 }
Chris Allegrettae347efb2008-03-09 02:52:40 +00001404#endif /* NANO_TINY */
1405 else if (!strcasecmp(input, "right") ||
1406 !strcasecmp(input, "forward"))
1407 s->scfunc = do_right;
1408 else if (!strcasecmp(input, "left") ||
1409 !strcasecmp(input, "back"))
1410 s->scfunc = do_left;
1411 else if (!strcasecmp(input, "up") ||
1412 !strcasecmp(input, "prevline"))
1413 s->scfunc = do_up_void;
1414 else if (!strcasecmp(input, "down") ||
1415 !strcasecmp(input, "nextline"))
1416 s->scfunc = do_down_void;
1417 else if (!strcasecmp(input, "home"))
1418 s->scfunc = do_home;
1419 else if (!strcasecmp(input, "end"))
1420 s->scfunc = do_end;
1421#ifdef ENABLE_MULTIBUFFER
1422 else if (!strcasecmp(input, "prevbuf"))
1423 s->scfunc = switch_to_prev_buffer_void;
1424 else if (!strcasecmp(input, "nextbuf"))
1425 s->scfunc = switch_to_next_buffer_void;
1426#endif
1427 else if (!strcasecmp(input, "verbatim"))
1428 s->scfunc = do_verbatim_input;
1429 else if (!strcasecmp(input, "tab"))
1430 s->scfunc = do_tab;
1431 else if (!strcasecmp(input, "enter"))
1432 s->scfunc = do_enter;
1433 else if (!strcasecmp(input, "delete"))
1434 s->scfunc = do_delete;
1435 else if (!strcasecmp(input, "refresh"))
1436 s->scfunc = total_refresh;
1437 else if (!strcasecmp(input, "casesens")) {
1438 s->scfunc = (void *) case_sens_msg;
1439 s->execute = FALSE;
1440 } else if (!strcasecmp(input, "regexp") ||
1441 !strcasecmp(input, "regex")) {
1442 s->scfunc = (void *) regexp_msg;
1443 s->execute = FALSE;
1444 } else if (!strcasecmp(input, "dontreplace")) {
1445 s->scfunc = (void *) no_replace_msg;
1446 s->execute = FALSE;
1447 } else if (!strcasecmp(input, "gototext")) {
1448 s->scfunc = (void *) gototext_msg;
1449 s->execute = FALSE;
1450 } else if (!strcasecmp(input, "browser") ||
1451 !strcasecmp(input, "tofiles")) {
1452 s->scfunc = (void *) to_files_msg;
1453 s->execute = FALSE;
1454 } else if (!strcasecmp(input, "dosformat")) {
1455 s->scfunc = (void *) dos_format_msg;
1456 s->execute = FALSE;
1457 } else if (!strcasecmp(input, "macformat")) {
1458 s->scfunc = (void *) mac_format_msg;
1459 s->execute = FALSE;
1460 } else if (!strcasecmp(input, "append")) {
1461 s->scfunc = (void *) append_msg;
1462 s->execute = FALSE;
1463 } else if (!strcasecmp(input, "prepend")) {
1464 s->scfunc = (void *) prepend_msg;
1465 s->execute = FALSE;
1466 } else if (!strcasecmp(input, "backup")) {
1467 s->scfunc = (void *) backup_file_msg;
1468 s->execute = FALSE;
1469#ifdef ENABLE_MULTIBUFFER
1470 } else if (!strcasecmp(input, "newbuffer")) {
1471 s->scfunc = (void *) new_buffer_msg;
1472 s->execute = FALSE;
1473#endif
1474 } else if (!strcasecmp(input, "firstfile")) {
1475 s->scfunc = (void *) first_file_msg;
1476 s->execute = FALSE;
1477 } else if (!strcasecmp(input, "lastfile")) {
1478 s->scfunc = (void *) last_file_msg;
1479 s->execute = FALSE;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001480 } else {
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001481 free(s);
1482 return NULL;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001483 }
1484
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001485 return s;
1486
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001487}
1488
Chris Allegrettae347efb2008-03-09 02:52:40 +00001489#ifdef ENABLE_NANORC
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001490/* Same thing as abnove but for the menu */
1491int strtomenu(char *input)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001492{
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001493 if (!strcasecmp(input, "all"))
1494 return MALL;
1495 else if (!strcasecmp(input, "main"))
1496 return MMAIN;
1497 else if (!strcasecmp(input, "search"))
1498 return MWHEREIS;
1499 else if (!strcasecmp(input, "replace"))
1500 return MREPLACE;
1501 else if (!strcasecmp(input, "replace2") ||
1502 !strcasecmp(input, "replacewith"))
1503 return MREPLACE2;
1504 else if (!strcasecmp(input, "gotoline"))
1505 return MGOTOLINE;
1506 else if (!strcasecmp(input, "writeout"))
1507 return MWRITEFILE;
1508 else if (!strcasecmp(input, "insert"))
1509 return MINSERTFILE;
1510 else if (!strcasecmp(input, "externalcmd") ||
1511 !strcasecmp(input, "extcmd"))
1512 return MEXTCMD;
1513 else if (!strcasecmp(input, "help"))
1514 return MHELP;
1515 else if (!strcasecmp(input, "spell"))
1516 return MSPELL;
1517 else if (!strcasecmp(input, "browser"))
1518 return MBROWSER;
1519 else if (!strcasecmp(input, "whereisfile"))
1520 return MWHEREISFILE;
1521 else if (!strcasecmp(input, "gotodir"))
1522 return MGOTODIR;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001523
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001524 return -1;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001525}
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001526#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001527
Chris Allegrettae347efb2008-03-09 02:52:40 +00001528
David Lawrence Ramseye6757b92006-04-19 13:36:56 +00001529#ifdef DEBUG
1530/* This function is used to gracefully return all the memory we've used.
1531 * It should be called just before calling exit(). Practically, the
Chris Allegretta6232d662002-05-12 19:52:15 +00001532 * only effect is to cause a segmentation fault if the various data
1533 * structures got bolloxed earlier. Thus, we don't bother having this
Chris Allegretta6df90f52002-07-19 01:08:59 +00001534 * function unless debugging is turned on. */
Chris Allegretta6df90f52002-07-19 01:08:59 +00001535void thanks_for_all_the_fish(void)
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001536{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001537 delwin(topwin);
1538 delwin(edit);
1539 delwin(bottomwin);
1540
Chris Allegretta7662c862003-01-13 01:35:15 +00001541#ifndef DISABLE_JUSTIFY
1542 if (quotestr != NULL)
1543 free(quotestr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001544#ifdef HAVE_REGEX_H
1545 regfree(&quotereg);
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001546 if (quoteerr != NULL)
1547 free(quoteerr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001548#endif
Chris Allegretta7662c862003-01-13 01:35:15 +00001549#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001550#ifndef NANO_TINY
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +00001551 if (backup_dir != NULL)
1552 free(backup_dir);
1553#endif
Chris Allegretta2598c662002-03-28 01:59:34 +00001554#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001555 if (operating_dir != NULL)
1556 free(operating_dir);
1557 if (full_operating_dir != NULL)
1558 free(full_operating_dir);
1559#endif
1560 if (last_search != NULL)
1561 free(last_search);
1562 if (last_replace != NULL)
1563 free(last_replace);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001564#ifndef DISABLE_SPELLER
1565 if (alt_speller != NULL)
1566 free(alt_speller);
1567#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001568 if (answer != NULL)
1569 free(answer);
1570 if (cutbuffer != NULL)
Chris Allegretta7662c862003-01-13 01:35:15 +00001571 free_filestruct(cutbuffer);
David Lawrence Ramsey93c84052004-11-23 04:08:28 +00001572#ifndef DISABLE_JUSTIFY
1573 if (jusbuffer != NULL)
1574 free_filestruct(jusbuffer);
1575#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001576#ifndef NANO_TINY
David Lawrence Ramsey40e4acf2005-05-26 06:09:07 +00001577 /* Free the memory associated with each toggle. */
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001578 while (toggles != NULL) {
1579 toggle *t = toggles;
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001580
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001581 toggles = toggles->next;
1582 free(t);
1583 }
1584#endif
David Lawrence Ramsey5d8d0b12005-05-26 05:53:29 +00001585 /* Free the memory associated with each open file buffer. */
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +00001586 if (openfile != NULL)
David Lawrence Ramsey64661ac2005-07-08 19:57:25 +00001587 free_openfilestruct(openfile);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001588#ifdef ENABLE_COLOR
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001589 if (syntaxstr != NULL)
1590 free(syntaxstr);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001591 while (syntaxes != NULL) {
1592 syntaxtype *bill = syntaxes;
1593
1594 free(syntaxes->desc);
1595 while (syntaxes->extensions != NULL) {
1596 exttype *bob = syntaxes->extensions;
1597
1598 syntaxes->extensions = bob->next;
David Lawrence Ramsey2385c1a2005-07-29 21:42:08 +00001599 free(bob->ext_regex);
David Lawrence Ramsey7fc0ada2005-08-29 18:52:06 +00001600 if (bob->ext != NULL) {
1601 regfree(bob->ext);
1602 free(bob->ext);
1603 }
Chris Allegretta6df90f52002-07-19 01:08:59 +00001604 free(bob);
1605 }
1606 while (syntaxes->color != NULL) {
1607 colortype *bob = syntaxes->color;
1608
1609 syntaxes->color = bob->next;
David Lawrence Ramsey2385c1a2005-07-29 21:42:08 +00001610 free(bob->start_regex);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001611 if (bob->start != NULL) {
1612 regfree(bob->start);
1613 free(bob->start);
1614 }
David Lawrence Ramseyd2361f02005-07-14 18:33:51 +00001615 if (bob->end_regex != NULL)
1616 free(bob->end_regex);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001617 if (bob->end != NULL) {
Chris Allegrettace452fb2003-02-03 02:56:44 +00001618 regfree(bob->end);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001619 free(bob->end);
1620 }
Chris Allegretta6df90f52002-07-19 01:08:59 +00001621 free(bob);
1622 }
1623 syntaxes = syntaxes->next;
1624 free(bill);
1625 }
1626#endif /* ENABLE_COLOR */
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001627#ifndef NANO_TINY
David Lawrence Ramsey40e4acf2005-05-26 06:09:07 +00001628 /* Free the search and replace history lists. */
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001629 if (searchage != NULL)
1630 free_filestruct(searchage);
1631 if (replaceage != NULL)
1632 free_filestruct(replaceage);
Chris Allegretta5beed502003-01-05 20:41:21 +00001633#endif
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001634#ifdef ENABLE_NANORC
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001635 if (homedir != NULL)
1636 free(homedir);
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001637#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001638}
Chris Allegretta6232d662002-05-12 19:52:15 +00001639#endif /* DEBUG */
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001640