blob: a7a46ca7ca6a7d2a2b7ce603e89915709bfff6de [file] [log] [blame]
Chris Allegretta07fcc4c2008-07-10 20:13:04 +00001/* $Id$ */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00002/**************************************************************************
3 * global.c *
4 * *
Chris Allegretta8a07a962009-12-02 03:36:22 +00005 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
6 * 2008, 2009 Free Software Foundation, Inc. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00007 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
David Lawrence Ramseyd0035b42007-08-11 05:17:36 +00009 * the Free Software Foundation; either version 3, or (at your option) *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000010 * any later version. *
11 * *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000012 * This program is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15 * General Public License for more details. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000016 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
20 * 02110-1301, USA. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000021 * *
22 **************************************************************************/
23
Chris Allegrettaa855fa22008-07-12 02:13:22 +000024#include "proto.h"
25
Chris Allegretta79a33bb2008-03-05 07:34:01 +000026#include <ctype.h>
Chris Allegrettaeb643142008-03-12 04:44:14 +000027#include <string.h>
Chris Allegretta79a33bb2008-03-05 07:34:01 +000028#include <strings.h>
29#include "assert.h"
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000030
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +000031/* Global variables. */
32#ifndef NANO_TINY
David Lawrence Ramsey1c5af642006-05-10 15:15:06 +000033sigjmp_buf jump_buf;
David Lawrence Ramseyb6fb6882006-11-27 07:28:52 +000034 /* Used to return to either main() or the unjustify routine in
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +000035 * do_justify() after a SIGWINCH. */
David Lawrence Ramsey1c5af642006-05-10 15:15:06 +000036bool jump_buf_main = FALSE;
37 /* Have we set jump_buf so that we return to main() after a
38 * SIGWINCH? */
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +000039#endif
40
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000041#ifndef DISABLE_WRAPJUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000042ssize_t fill = 0;
43 /* The column where we will wrap lines. */
David Lawrence Ramsey691698a2005-07-24 19:57:51 +000044ssize_t wrap_at = -CHARS_FROM_EOL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000045 /* The position where we will wrap lines. fill is equal to this
46 * if it's greater than zero, and equal to (COLS + this) if it
47 * isn't. */
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000048#endif
49
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000050char *last_search = NULL;
51 /* The last string we searched for. */
52char *last_replace = NULL;
53 /* The last replacement string we searched for. */
Chris Allegretta6df90f52002-07-19 01:08:59 +000054
Chris Allegrettaa48507d2009-08-14 03:18:29 +000055unsigned flags[4] = {0, 0, 0, 0};
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000056 /* Our flag containing the states of all global options. */
57WINDOW *topwin;
58 /* The top portion of the window, where we display the version
59 * number of nano, the name of the current file, and whether the
60 * current file has been modified. */
61WINDOW *edit;
David Lawrence Ramseyb159f942006-07-28 17:06:27 +000062 /* The middle portion of the window, i.e. the edit window, where
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000063 * we display the current file we're editing. */
64WINDOW *bottomwin;
65 /* The bottom portion of the window, where we display statusbar
66 * messages, the statusbar prompt, and a list of shortcuts. */
67int editwinrows = 0;
68 /* How many rows does the edit window take up? */
Chris Allegretta8c1edd12009-11-16 04:28:40 +000069int maxrows = 0;
Benno Schulenberg7f873932014-02-25 21:27:22 +000070 /* How many usable lines there are (due to soft wrapping). */
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +000071
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000072filestruct *cutbuffer = NULL;
73 /* The buffer where we store cut text. */
Chris Allegretta12dc8ca2008-07-31 04:24:04 +000074filestruct *cutbottom = NULL;
David Lawrence Ramsey93c84052004-11-23 04:08:28 +000075#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000076filestruct *jusbuffer = NULL;
77 /* The buffer where we store unjustified text. */
David Lawrence Ramsey93c84052004-11-23 04:08:28 +000078#endif
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000079partition *filepart = NULL;
80 /* The partition where we store a portion of the current
81 * file. */
David Lawrence Ramsey64661ac2005-07-08 19:57:25 +000082openfilestruct *openfile = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000083 /* The list of all open file buffers. */
Chris Allegretta2d7893d2001-07-11 02:08:33 +000084
David Lawrence Ramseyd89617f2006-01-06 21:51:10 +000085#ifndef NANO_TINY
86char *matchbrackets = NULL;
87 /* The opening and closing brackets that can be found by bracket
88 * searches. */
89#endif
90
David Lawrence Ramseyebe34252005-11-15 03:17:35 +000091#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000092char *whitespace = NULL;
93 /* The characters used when displaying the first characters of
94 * tabs and spaces. */
95int whitespace_len[2];
96 /* The length of these characters. */
David Lawrence Ramsey89bb9372004-05-29 16:47:52 +000097#endif
98
Chris Allegrettae4f940d2002-03-03 22:36:36 +000099#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000100char *punct = NULL;
101 /* The closing punctuation that can end sentences. */
102char *brackets = NULL;
103 /* The closing brackets that can follow closing punctuation and
104 * can end sentences. */
105char *quotestr = NULL;
106 /* The quoting string. The default value is set in main(). */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000107#ifdef HAVE_REGEX_H
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000108regex_t quotereg;
109 /* The compiled regular expression from the quoting string. */
110int quoterc;
David Lawrence Ramsey88165642006-05-22 18:30:09 +0000111 /* Whether it was compiled successfully. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000112char *quoteerr = NULL;
113 /* The error message, if it didn't. */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000114#else
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000115size_t quotelen;
116 /* The length of the quoting string in bytes. */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000117#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000118#endif
Chris Allegrettae4f940d2002-03-03 22:36:36 +0000119
Chris Allegretta0dc26dc2009-01-24 22:40:41 +0000120bool nodelay_mode = FALSE;
121 /* Are we in nodelay mode (checking for a cancel wile doing something */
122
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000123char *answer = NULL;
David Lawrence Ramsey6335fb52007-01-01 05:15:32 +0000124 /* The answer string used by the statusbar prompt. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000125
126ssize_t tabsize = -1;
127 /* The width of a tab in spaces. The default value is set in
128 * main(). */
129
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000130#ifndef NANO_TINY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000131char *backup_dir = NULL;
132 /* The directory where we store backup files. */
Chris Allegrettabf88d272013-01-01 03:24:39 +0000133
Chris Allegretta3116d2f2013-01-03 04:36:39 +0000134const char *locking_prefix = ".";
Chris Allegrettabf88d272013-01-01 03:24:39 +0000135 /* Prefix of how to store the vim-style lock file */
Chris Allegretta3116d2f2013-01-03 04:36:39 +0000136const char *locking_suffix = ".swp";
Chris Allegrettabf88d272013-01-01 03:24:39 +0000137 /* Suffix of the vim-style lock file */
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000138#endif
Chris Allegrettae1f14522001-09-19 03:19:43 +0000139#ifndef DISABLE_OPERATINGDIR
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000140char *operating_dir = NULL;
141 /* The relative path to the operating directory, which we can't
142 * move outside of. */
143char *full_operating_dir = NULL;
144 /* The full path to it. */
Chris Allegrettae1f14522001-09-19 03:19:43 +0000145#endif
146
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000147#ifndef DISABLE_SPELLER
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000148char *alt_speller = NULL;
149 /* The command to use for the alternate spell checker. */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000150#endif
151
Chris Allegretta8ce24132001-04-30 11:28:46 +0000152#ifdef ENABLE_COLOR
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000153syntaxtype *syntaxes = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000154 /* The global list of color syntaxes. */
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000155char *syntaxstr = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000156 /* The color syntax name specified on the command line. */
Chris Allegrettafd265af2009-02-06 03:41:02 +0000157
Chris Allegretta8ce24132001-04-30 11:28:46 +0000158#endif
159
Chris Allegretta637daa82011-02-07 14:45:56 +0000160bool edit_refresh_needed = 0;
Chris Allegretta2ad1de02012-12-30 19:20:10 +0000161 /* Did a command mangle enough of the buffer refresh that we
Benno Schulenberg7f873932014-02-25 21:27:22 +0000162 * should repaint the screen? */
Chris Allegrettafd265af2009-02-06 03:41:02 +0000163
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000164const shortcut *currshortcut;
165 /* The current shortcut list we're using. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000166int currmenu;
Benno Schulenberg7f873932014-02-25 21:27:22 +0000167 /* The currently loaded menu. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000168
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000169sc *sclist = NULL;
Benno Schulenberg7f873932014-02-25 21:27:22 +0000170 /* New shortcut key struct. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000171subnfunc *allfuncs = NULL;
Benno Schulenberg7f873932014-02-25 21:27:22 +0000172 /* New struct for the function list. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000173
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000174#ifndef NANO_TINY
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000175filestruct *search_history = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000176 /* The search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000177filestruct *searchage = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000178 /* The top of the search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000179filestruct *searchbot = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000180 /* The bottom of the search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000181filestruct *replace_history = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000182 /* The replace string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000183filestruct *replaceage = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000184 /* The top of the replace string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000185filestruct *replacebot = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000186 /* The bottom of the replace string history list. */
Chris Allegretta9bfda912011-02-16 06:52:30 +0000187poshiststruct *poshistory;
Benno Schulenberg7f873932014-02-25 21:27:22 +0000188 /* The cursor position history list. */
Chris Allegretta5beed502003-01-05 20:41:21 +0000189#endif
190
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +0000191/* Regular expressions. */
Chris Allegretta805c26d2000-09-06 13:39:17 +0000192#ifdef HAVE_REGEX_H
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000193regex_t search_regexp;
194 /* The compiled regular expression to use in searches. */
195regmatch_t regmatches[10];
196 /* The match positions for parenthetical subexpressions, 10
197 * maximum, used in regular expression searches. */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000198#endif
Chris Allegretta3533a342002-03-24 23:19:32 +0000199
David Lawrence Ramsey4d72de72006-04-12 15:27:40 +0000200int reverse_attr = A_REVERSE;
201 /* The curses attribute we use for reverse video. */
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000202
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000203char *homedir = NULL;
David Lawrence Ramseyc1c818e2006-05-14 18:22:01 +0000204 /* The user's home directory, from $HOME or /etc/passwd. */
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000205
Benno Schulenberg7f873932014-02-25 21:27:22 +0000206/* Return the number of entries in the shortcut list for a given menu. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000207size_t length_of_list(int menu)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000208{
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000209 subnfunc *f;
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000210 size_t i = 0;
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000211
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000212 for (f = allfuncs; f != NULL; f = f->next)
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000213 if ((f->menus & menu) != 0
214#ifndef DISABLE_HELP
215 && strlen(f->help) > 0
216#endif
217 ) {
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000218 i++;
219 }
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000220 return i;
221}
222
Benno Schulenberg7f873932014-02-25 21:27:22 +0000223/* Just throw this here. */
Chris Allegretta637daa82011-02-07 14:45:56 +0000224void case_sens_void(void)
225{
226}
227void regexp_void(void)
228{
229}
230void gototext_void(void)
231{
232}
233void to_files_void(void)
234{
235}
236void dos_format_void(void)
237{
238}
239void mac_format_void(void)
240{
241}
242void append_void(void)
243{
244}
245void prepend_void(void)
246{
247}
248void backup_file_void(void)
249{
250}
251void new_buffer_void(void)
252{
253}
254void backwards_void(void)
255{
256}
257void goto_dir_void(void)
258{
259}
260void no_replace_void(void)
261{
262}
263void ext_cmd_void(void)
264{
265}
266
Benno Schulenberg7f873932014-02-25 21:27:22 +0000267/* Set type of function based on the string. */
Chris Allegretta5a018f02009-11-29 06:13:22 +0000268function_type strtokeytype(const char *str)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000269{
Chris Allegretta17436ce2008-03-11 03:03:53 +0000270 if (str[0] == 'M' || str[0] == 'm')
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000271 return META;
Chris Allegretta17436ce2008-03-11 03:03:53 +0000272 else if (str[0] == '^')
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000273 return CONTROL;
Chris Allegretta18b10922014-01-01 22:21:38 +0000274 else if (str[0] == 'F' || str[0] == 'f')
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000275 return FKEY;
Chris Allegretta17436ce2008-03-11 03:03:53 +0000276 else
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000277 return RAWINPUT;
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000278}
279
Benno Schulenberg7f873932014-02-25 21:27:22 +0000280/* Add a string to the new function list struct.
281 * Does not allow updates, not yet anyway. */
Chris Allegretta637daa82011-02-07 14:45:56 +0000282void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *help,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000283 bool blank_after, bool viewok)
284{
285 subnfunc *f;
286
287 if (allfuncs == NULL) {
Chris Allegrettaf86fa862009-02-25 04:32:15 +0000288 allfuncs = (subnfunc *) nmalloc(sizeof(subnfunc));
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000289 f = allfuncs;
290 } else {
291 for (f = allfuncs; f->next != NULL; f = f->next)
292 ;
293 f->next = (subnfunc *)nmalloc(sizeof(subnfunc));
294 f = f->next;
295 }
296 f->next = NULL;
297 f->scfunc = func;
298 f->menus = menus;
299 f->desc = desc;
300 f->viewok = viewok;
Chris Allegretta1d778232008-08-30 21:00:00 +0000301#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000302 f->help = help;
303 f->blank_after = blank_after;
304#endif
305
306#ifdef DEBUG
307 fprintf(stderr, "Added func \"%s\"", f->desc);
308#endif
309}
310
Chris Allegrettabf406ff2013-06-14 02:44:54 +0000311const sc *first_sc_for(int menu, void (*func)(void))
312{
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000313 const sc *s;
Chris Allegrettabf406ff2013-06-14 02:44:54 +0000314 const sc *fkeysc = NULL;
Chris Allegrettab775c072008-03-09 05:07:37 +0000315 const sc *metasc = NULL;
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000316
317 for (s = sclist; s != NULL; s = s->next) {
318 if ((s->menu & menu) && s->scfunc == func) {
Chris Allegrettabf406ff2013-06-14 02:44:54 +0000319 /* Try to use function keys and meta sequences as last
320 * resorts. Otherwise, we will run into problems when we
321 * try and handle things like the arrow keys, Home, etc., if
322 * for some reason the user bound them to a function key or
323 * meta sequence first *shrug*. */
324 if (s->type == FKEY) {
325 if (!fkeysc)
326 fkeysc = s;
Chris Allegrettab775c072008-03-09 05:07:37 +0000327 continue;
Chris Allegrettabf406ff2013-06-14 02:44:54 +0000328 } else if (s->type == META) {
329 if (!metasc)
330 metasc = s;
331 continue;
332 }
333
334 /* Otherwise, it was something else, so use it. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000335 return s;
336 }
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000337 }
338
Chris Allegrettabf406ff2013-06-14 02:44:54 +0000339 /* If we're here, we may have found only function keys or meta
340 * sequences. If so, use one, with the same priority as in the
341 * help browser: function keys come first, unless meta sequences are
342 * available, in which case meta sequences come first. */
343 if (fkeysc && !metasc)
344 return fkeysc;
345 else if (metasc)
Chris Allegretta17436ce2008-03-11 03:03:53 +0000346 return metasc;
Chris Allegrettab775c072008-03-09 05:07:37 +0000347
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000348#ifdef DEBUG
Chris Allegrettae347efb2008-03-09 02:52:40 +0000349 fprintf(stderr, "Whoops, returning null given func %ld in menu %d\n", (long) func, menu);
David Lawrence Ramseybd28ee42006-07-25 21:13:30 +0000350#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000351 /* Otherwise... */
352 return NULL;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000353}
354
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000355
Benno Schulenberg7f873932014-02-25 21:27:22 +0000356/* Add a string to the new shortcut list implementation.
357 * Allows updates to existing entries in the list. */
Chris Allegretta637daa82011-02-07 14:45:56 +0000358void add_to_sclist(int menu, const char *scstring, void (*func)(void), int toggle, int execute)
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000359{
360 sc *s;
361
362 if (sclist == NULL) {
Chris Allegrettaf86fa862009-02-25 04:32:15 +0000363 sclist = (sc *) nmalloc(sizeof(sc));
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000364 s = sclist;
365 s->next = NULL;
366 } else {
367 for (s = sclist; s->next != NULL; s = s->next)
368 if (s->menu == menu && s->keystr == scstring)
369 break;
370
371 if (s->menu != menu || s->keystr != scstring) { /* i.e. this is not a replace... */
372#ifdef DEBUG
373 fprintf(stderr, "No match found...\n");
374#endif
375 s->next = (sc *)nmalloc(sizeof(sc));
376 s = s->next;
377 s->next = NULL;
378 }
379 }
380
381 s->type = strtokeytype(scstring);
382 s->menu = menu;
383 s->toggle = toggle;
Chris Allegretta5a018f02009-11-29 06:13:22 +0000384 s->keystr = (char *) scstring;
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000385 s->scfunc = func;
386 s->execute = execute;
387 assign_keyinfo(s);
388
389#ifdef DEBUG
390 fprintf(stderr, "list val = %d\n", (int) s->menu);
391 fprintf(stderr, "Hey, set sequence to %d for shortcut \"%s\"\n", s->seq, scstring);
392#endif
393}
394
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000395
Benno Schulenberg7f873932014-02-25 21:27:22 +0000396/* Assign one menu's shortcuts to another function. */
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000397void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void))
398{
399 sc *s;
400
401 if (sclist == NULL)
402 return;
403
404 for (s = sclist; s->next != NULL; s = s->next)
405 if (s->scfunc == oldfunc) {
406 s->scfunc = newfunc;
407 }
408}
409
410
Chris Allegrettae347efb2008-03-09 02:52:40 +0000411/* Return the given menu's first shortcut sequence, or the default value
Benno Schulenberg7f873932014-02-25 21:27:22 +0000412 * (2nd arg). Assumes currmenu for the menu to check. */
Chris Allegretta2ad1de02012-12-30 19:20:10 +0000413int sc_seq_or (void (*func)(void), int defaultval)
Chris Allegrettae347efb2008-03-09 02:52:40 +0000414{
415 const sc *s = first_sc_for(currmenu, func);
416
417 if (s)
418 return s->seq;
419 /* else */
420 return defaultval;
421
422}
423
Benno Schulenberg7f873932014-02-25 21:27:22 +0000424/* Assign the info to the shortcut struct.
425 * Assumes keystr is already assigned, naturally. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000426void assign_keyinfo(sc *s)
427{
428 if (s->type == CONTROL) {
429 assert(strlen(s->keystr) > 1);
430 s->seq = s->keystr[1] - 64;
431 } else if (s->type == META) {
432 assert(strlen(s->keystr) > 2);
433 s->seq = tolower((int) s->keystr[2]);
434 } else if (s->type == FKEY) {
435 assert(strlen(s->keystr) > 1);
436 s->seq = KEY_F0 + atoi(&s->keystr[1]);
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000437 } else /* RAWINPUT */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000438 s->seq = (int) s->keystr[0];
Chris Allegretta9b422202008-03-05 17:15:33 +0000439
Benno Schulenberg7f873932014-02-25 21:27:22 +0000440 /* Override some keys which don't bind as nicely as we'd like. */
Chris Allegretta9b422202008-03-05 17:15:33 +0000441 if (s->type == CONTROL && (!strcasecmp(&s->keystr[1], "space")))
442 s->seq = 0;
443 else if (s->type == META && (!strcasecmp(&s->keystr[2], "space")))
444 s->seq = (int) ' ';
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000445 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "kup")))
Chris Allegretta17436ce2008-03-11 03:03:53 +0000446 s->seq = KEY_UP;
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000447 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "kdown")))
Chris Allegretta17436ce2008-03-11 03:03:53 +0000448 s->seq = KEY_DOWN;
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000449 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "kleft")))
Chris Allegretta17436ce2008-03-11 03:03:53 +0000450 s->seq = KEY_LEFT;
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000451 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "kright")))
Chris Allegretta17436ce2008-03-11 03:03:53 +0000452 s->seq = KEY_RIGHT;
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000453 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "kinsert")))
Chris Allegretta17436ce2008-03-11 03:03:53 +0000454 s->seq = KEY_IC;
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000455 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "kdel")))
Chris Allegretta17436ce2008-03-11 03:03:53 +0000456 s->seq = KEY_DC;
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000457 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "kbsp")))
Chris Allegrettaeb643142008-03-12 04:44:14 +0000458 s->seq = KEY_BACKSPACE;
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000459 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "kenter")))
Chris Allegrettaeb643142008-03-12 04:44:14 +0000460 s->seq = KEY_ENTER;
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000461 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "kpup")))
Chris Allegretta17436ce2008-03-11 03:03:53 +0000462 s->seq = KEY_PPAGE;
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000463 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "kpdown")))
Chris Allegretta17436ce2008-03-11 03:03:53 +0000464 s->seq = KEY_NPAGE;
465#ifdef KEY_HOME
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000466 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "khome")))
Chris Allegretta17436ce2008-03-11 03:03:53 +0000467 s->seq = KEY_HOME;
468#endif
469#ifdef KEY_END
Chris Allegretta3bd12e32011-02-26 14:22:37 +0000470 else if (s->type == RAWINPUT && (!strcasecmp(s->keystr, "kend")))
Chris Allegretta17436ce2008-03-11 03:03:53 +0000471 s->seq = KEY_END;
472#endif
Chris Allegretta9b422202008-03-05 17:15:33 +0000473
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000474}
475
476#ifdef DEBUG
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000477void print_sclist(void)
478{
479 sc *s;
480 const subnfunc *f;
481
482 for (s = sclist; s->next != NULL; s = s->next) {
483 f = sctofunc(s);
484 if (f)
Chris Allegrettae347efb2008-03-09 02:52:40 +0000485 fprintf(stderr, "Shortcut \"%s\", function: %s, menus %d\n", s->keystr, f->desc, f->menus);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000486 else
487 fprintf(stderr, "Hmm, didnt find a func for \"%s\"\n", s->keystr);
488 }
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000489}
490#endif
491
492
Benno Schulenberg7f873932014-02-25 21:27:22 +0000493/* Stuff we need to make at least static here so we can access it below. */
494/* TRANSLATORS: Try to keep the next six strings at most 10 characters. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000495const char *cancel_msg = N_("Cancel");
Chris Allegrettab43f6912009-11-29 06:24:10 +0000496const char *replace_msg = N_("Replace");
497const char *no_replace_msg = N_("No Replace");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000498
499#ifndef NANO_TINY
500const char *case_sens_msg = N_("Case Sens");
501const char *backwards_msg = N_("Backwards");
502#endif
503
504#ifdef HAVE_REGEX_H
505const char *regexp_msg = N_("Regexp");
506#endif
507
Benno Schulenberg7f873932014-02-25 21:27:22 +0000508/* Stuff we want to just stun out if we're in TINY mode. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000509#ifdef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000510const char *gototext_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000511const char *do_para_begin_msg = "";
512const char *do_para_end_msg = "";
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000513const char *case_sens_msg = "";
514const char *backwards_msg = "";
515const char *do_cut_till_end = "";
516const char *dos_format_msg = "";
517const char *mac_format_msg = "";
518const char *append_msg = "";
519const char *prepend_msg = "";
520const char *backup_file_msg = "";
521const char *to_files_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000522const char *first_file_msg = "";
523const char *whereis_next_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000524const char *last_file_msg = "";
525const char *new_buffer_msg = "";
526const char *goto_dir_msg;
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000527const char *ext_cmd_msg = "";
Chris Allegrettae347efb2008-03-09 02:52:40 +0000528
529#else
Benno Schulenberg7f873932014-02-25 21:27:22 +0000530/* TRANSLATORS: Try to keep the next three strings at most 10 characters. */
Chris Allegrettae347efb2008-03-09 02:52:40 +0000531const char *prev_history_msg = N_("PrevHstory");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000532const char *next_history_msg = N_("NextHstory");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000533const char *gototext_msg = N_("Go To Text");
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000534/* TRANSLATORS: Try to keep the next three strings at most 12 characters. */
Chris Allegrettae347efb2008-03-09 02:52:40 +0000535const char *whereis_next_msg = N_("WhereIs Next");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000536#ifndef DISABLE_BROWSER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000537const char *first_file_msg = N_("First File");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000538const char *last_file_msg = N_("Last File");
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000539/* TRANSLATORS: Try to keep the next nine strings at most 16 characters. */
540const char *to_files_msg = N_("To Files");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000541#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000542const char *dos_format_msg = N_("DOS Format");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000543const char *mac_format_msg = N_("Mac Format");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000544const char *append_msg = N_("Append");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000545const char *prepend_msg = N_("Prepend");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000546const char *backup_file_msg = N_("Backup File");
Chris Allegrettaeb643142008-03-12 04:44:14 +0000547const char *ext_cmd_msg = N_("Execute Command");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000548#ifdef ENABLE_MULTIBUFFER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000549const char *new_buffer_msg = N_("New Buffer");
550#endif
Chris Allegrettae347efb2008-03-09 02:52:40 +0000551const char *goto_dir_msg = N_("Go To Dir");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000552
Chris Allegrettae347efb2008-03-09 02:52:40 +0000553#endif /* NANO_TINY */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000554
Benno Schulenberg7f873932014-02-25 21:27:22 +0000555/* Initialize all shortcut lists. If unjustify is TRUE, replace
556 * the Uncut shortcut in the main shortcut list with UnJustify. */
David Lawrence Ramsey1f1ebb82004-11-11 21:50:01 +0000557void shortcut_init(bool unjustify)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000558{
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000559 /* TRANSLATORS: Try to keep the following strings at most 10 characters. */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000560 const char *get_help_msg = N_("Get Help");
561 const char *exit_msg = N_("Exit");
David Lawrence Ramseye38b8082006-03-30 07:03:04 +0000562 const char *whereis_msg = N_("Where Is");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000563 const char *prev_page_msg = N_("Prev Page");
564 const char *next_page_msg = N_("Next Page");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000565 const char *first_line_msg = N_("First Line");
566 const char *last_line_msg = N_("Last Line");
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000567 const char *suspend_msg = N_("Suspend");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000568#ifndef DISABLE_JUSTIFY
569 const char *beg_of_par_msg = N_("Beg of Par");
570 const char *end_of_par_msg = N_("End of Par");
571 const char *fulljstify_msg = N_("FullJstify");
572#endif
David Lawrence Ramsey81378762006-04-24 20:53:43 +0000573 const char *refresh_msg = N_("Refresh");
Chris Allegrettab43f6912009-11-29 06:24:10 +0000574#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000575 const char *insert_file_msg = N_("Insert File");
Chris Allegrettab43f6912009-11-29 06:24:10 +0000576#endif
Chris Allegrettae347efb2008-03-09 02:52:40 +0000577 const char *go_to_line_msg = N_("Go To Line");
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000578 const char *spell_msg = N_("To Spell");
579#ifdef ENABLE_COLOR
580 const char *lint_msg = N_("To Linter");
581 const char *nano_lint_msg =
582 N_("Invoke the linter, if available");
583 const char *prev_lint_msg = N_("Prev Lint Msg");
584 const char *next_lint_msg = N_("Next Lint Msg");
585#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000586
Chris Allegretta1d778232008-08-30 21:00:00 +0000587#ifndef DISABLE_JUSTIFY
Benno Schulenberg7f873932014-02-25 21:27:22 +0000588 /* TRANSLATORS: The next long series of strings are shortcut descriptions;
589 * they are best kept shorter than 56 characters, but may be longer. */
Chris Allegretta1d778232008-08-30 21:00:00 +0000590 const char *nano_justify_msg = N_("Justify the current paragraph");
591#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000592#ifndef DISABLE_HELP
David Lawrence Ramsey804e1072006-03-29 19:43:32 +0000593 const char *nano_cancel_msg = N_("Cancel the current function");
David Lawrence Ramsey57c9afb2006-04-14 20:21:45 +0000594 const char *nano_help_msg = N_("Display this help text");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000595 const char *nano_exit_msg =
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000596#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000597 N_("Close the current file buffer / Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000598#else
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000599 N_("Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000600#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000601 ;
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000602 const char *nano_writeout_msg =
603 N_("Write the current file to disk");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000604 const char *nano_insert_msg =
605 N_("Insert another file into the current one");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000606 const char *nano_whereis_msg =
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000607 N_("Search for a string or a regular expression");
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000608 const char *nano_prevpage_msg = N_("Go to previous screen");
609 const char *nano_nextpage_msg = N_("Go to next screen");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000610 const char *nano_cut_msg =
611 N_("Cut the current line and store it in the cutbuffer");
612 const char *nano_uncut_msg =
613 N_("Uncut from the cutbuffer into the current line");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000614 const char *nano_cursorpos_msg =
David Lawrence Ramseyf50bd4b2006-04-14 20:15:44 +0000615 N_("Display the position of the cursor");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000616 const char *nano_spell_msg =
617 N_("Invoke the spell checker, if available");
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000618 const char *nano_replace_msg =
619 N_("Replace a string or a regular expression");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000620 const char *nano_gotoline_msg = N_("Go to line and column number");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000621#ifndef NANO_TINY
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000622 const char *nano_mark_msg = N_("Mark text at the cursor position");
623 const char *nano_whereis_next_msg = N_("Repeat last search");
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000624 const char *nano_copy_msg =
625 N_("Copy the current line and store it in the cutbuffer");
David Lawrence Ramseyaee00d42006-07-05 18:42:22 +0000626 const char *nano_indent_msg = N_("Indent the current line");
627 const char *nano_unindent_msg = N_("Unindent the current line");
Chris Allegretta07fcc4c2008-07-10 20:13:04 +0000628 const char *nano_undo_msg = N_("Undo the last operation");
629 const char *nano_redo_msg = N_("Redo the last undone operation");
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000630#endif
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000631 const char *nano_forward_msg = N_("Go forward one character");
632 const char *nano_back_msg = N_("Go back one character");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000633#ifndef NANO_TINY
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000634 const char *nano_nextword_msg = N_("Go forward one word");
635 const char *nano_prevword_msg = N_("Go back one word");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000636#endif
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000637 const char *nano_prevline_msg = N_("Go to previous line");
638 const char *nano_nextline_msg = N_("Go to next line");
639 const char *nano_home_msg = N_("Go to beginning of current line");
640 const char *nano_end_msg = N_("Go to end of current line");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000641#ifndef DISABLE_JUSTIFY
642 const char *nano_parabegin_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000643 N_("Go to beginning of paragraph; then of previous paragraph");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000644 const char *nano_paraend_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000645 N_("Go just beyond end of paragraph; then of next paragraph");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000646#endif
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000647 const char *nano_firstline_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000648 N_("Go to the first line of the file");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000649 const char *nano_lastline_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000650 N_("Go to the last line of the file");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000651#ifndef NANO_TINY
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000652 const char *nano_bracket_msg = N_("Go to the matching bracket");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000653 const char *nano_scrollup_msg =
654 N_("Scroll up one line without scrolling the cursor");
655 const char *nano_scrolldown_msg =
656 N_("Scroll down one line without scrolling the cursor");
657#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000658#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +0000659 const char *nano_prevfile_msg =
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000660 N_("Switch to the previous file buffer");
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +0000661 const char *nano_nextfile_msg =
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000662 N_("Switch to the next file buffer");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000663#endif
David Lawrence Ramsey40e05722006-04-23 19:21:12 +0000664 const char *nano_verbatim_msg =
David Lawrence Ramsey939d4232006-04-24 21:00:17 +0000665 N_("Insert the next keystroke verbatim");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000666 const char *nano_tab_msg =
David Lawrence Ramseybf784202006-04-29 13:59:04 +0000667 N_("Insert a tab at the cursor position");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000668 const char *nano_enter_msg =
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000669 N_("Insert a newline at the cursor position");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000670 const char *nano_delete_msg =
671 N_("Delete the character under the cursor");
672 const char *nano_backspace_msg =
673 N_("Delete the character to the left of the cursor");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000674#ifndef NANO_TINY
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000675 const char *nano_cut_till_end_msg =
676 N_("Cut from the cursor position to the end of the file");
677#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000678#ifndef DISABLE_JUSTIFY
679 const char *nano_fulljustify_msg = N_("Justify the entire file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000680#endif
David Lawrence Ramseyc5c52302005-11-15 23:45:29 +0000681#ifndef NANO_TINY
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000682 const char *nano_wordcount_msg =
683 N_("Count the number of words, lines, and characters");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000684#endif
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000685 const char *nano_refresh_msg =
686 N_("Refresh (redraw) the current screen");
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000687 const char *nano_suspend_msg =
688 N_("Suspend the editor (if suspend is enabled)");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000689#ifndef NANO_TINY
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000690 const char *nano_case_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000691 N_("Toggle the case sensitivity of the search");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000692 const char *nano_reverse_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000693 N_("Reverse the direction of the search");
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000694#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000695#ifdef HAVE_REGEX_H
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000696 const char *nano_regexp_msg =
697 N_("Toggle the use of regular expressions");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000698#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000699#ifndef NANO_TINY
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000700 const char *nano_prev_history_msg =
David Lawrence Ramsey7b0531a2006-07-31 01:30:31 +0000701 N_("Recall the previous search/replace string");
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000702 const char *nano_next_history_msg =
David Lawrence Ramsey7b0531a2006-07-31 01:30:31 +0000703 N_("Recall the next search/replace string");
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000704#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000705#ifndef DISABLE_BROWSER
706 const char *nano_tofiles_msg = N_("Go to file browser");
707#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000708#ifndef NANO_TINY
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000709 const char *nano_dos_msg = N_("Toggle the use of DOS format");
710 const char *nano_mac_msg = N_("Toggle the use of Mac format");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000711#endif
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000712 const char *nano_append_msg = N_("Toggle appending");
713 const char *nano_prepend_msg = N_("Toggle prepending");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000714#ifndef NANO_TINY
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000715 const char *nano_backup_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000716 N_("Toggle backing up of the original file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000717 const char *nano_execute_msg = N_("Execute external command");
718#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000719#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000720 const char *nano_multibuffer_msg =
721 N_("Toggle the use of a new buffer");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000722#endif
723#ifndef DISABLE_BROWSER
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000724 const char *nano_exitbrowser_msg = N_("Exit from the file browser");
David Lawrence Ramseye38b8082006-03-30 07:03:04 +0000725 const char *nano_firstfile_msg =
726 N_("Go to the first file in the list");
727 const char *nano_lastfile_msg =
728 N_("Go to the last file in the list");
Chris Allegretta8d41fb82009-12-23 05:03:09 +0000729 const char *nano_forwardfile_msg = N_("Go to the next file in the list");
730 const char *nano_backfile_msg = N_("Go to the previous file in the list");
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000731 const char *nano_gotodir_msg = N_("Go to directory");
Chris Allegretta2bef1822001-09-28 19:53:11 +0000732#endif
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000733#ifdef ENABLE_COLOR
734 const char *nano_prevlint_msg = N_("Go to previous linter msg");
735 const char *nano_nextlint_msg = N_("Go to next linter msg");
736#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000737#endif /* !DISABLE_HELP */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000738
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000739#ifndef DISABLE_HELP
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000740#define IFSCHELP(help) help
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000741#else
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000742#define IFSCHELP(help) ""
Chris Allegrettadab017e2002-04-23 10:56:06 +0000743#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000744
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000745 while (allfuncs != NULL) {
746 subnfunc *f = allfuncs;
747 allfuncs = (allfuncs)->next;
748 free(f);
749 }
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000750
Chris Allegretta637daa82011-02-07 14:45:56 +0000751 add_to_funcs(do_help_void,
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000752 (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MBROWSER|MWHEREISFILE|MGOTODIR|MLINTER),
Chris Allegrettab27b3a12009-12-04 04:29:55 +0000753 get_help_msg, IFSCHELP(nano_help_msg), FALSE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000754
Chris Allegretta637daa82011-02-07 14:45:56 +0000755 add_to_funcs( do_cancel,
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000756 (MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR|MYESNO|MLINTER),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000757 cancel_msg, IFSCHELP(nano_cancel_msg), FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000758
Chris Allegretta637daa82011-02-07 14:45:56 +0000759 add_to_funcs(do_exit, MMAIN,
Chris Allegretta355fbe52001-07-14 19:32:47 +0000760#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000761 /* TRANSLATORS: Try to keep this at most 10 characters. */
David Lawrence Ramsey017dde22006-03-24 05:28:03 +0000762 openfile != NULL && openfile != openfile->next ? N_("Close") :
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000763#endif
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000764 exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000765
Chris Allegrettadcd19c92008-03-20 04:51:26 +0000766#ifndef DISABLE_BROWSER
Chris Allegretta637daa82011-02-07 14:45:56 +0000767 add_to_funcs(do_exit, MBROWSER, exit_msg, IFSCHELP(nano_exitbrowser_msg), FALSE, VIEW);
Chris Allegrettadcd19c92008-03-20 04:51:26 +0000768#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000769
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000770 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta637daa82011-02-07 14:45:56 +0000771 add_to_funcs(do_writeout_void, MMAIN, N_("WriteOut"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000772 IFSCHELP(nano_writeout_msg), FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000773
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000774 /* We allow inserting files in view mode if multibuffers are
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000775 * available, so that we can view multiple files. If we're using
776 * restricted mode, inserting files is disabled, since it allows
777 * reading from or writing to files not specified on the command
778 * line. */
Chris Allegrettaab538642010-11-12 06:22:12 +0000779
Chris Allegretta637daa82011-02-07 14:45:56 +0000780 add_to_funcs(do_insertfile_void,
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000781 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000782 MMAIN, N_("Read File"), IFSCHELP(nano_insert_msg), FALSE,
Chris Allegretta32da4562002-01-02 15:12:21 +0000783#ifdef ENABLE_MULTIBUFFER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000784 VIEW);
Chris Allegretta32da4562002-01-02 15:12:21 +0000785#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000786 NOVIEW);
Chris Allegretta32da4562002-01-02 15:12:21 +0000787#endif
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000788
Chris Allegretta637daa82011-02-07 14:45:56 +0000789 add_to_funcs(do_search, MMAIN|MBROWSER, whereis_msg,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000790 IFSCHELP(nano_whereis_msg), FALSE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000791
Benno Schulenbergcae7aea2014-02-26 20:37:40 +0000792 add_to_funcs(do_research, MBROWSER, whereis_next_msg,
793 IFSCHELP(nano_whereis_next_msg), TRUE, VIEW);
794
795#ifndef DISABLE_JUSTIFY
796 /* TRANSLATORS: Try to keep this at most 10 characters. */
797 add_to_funcs(do_justify_void, MMAIN, N_("Justify"),
798 nano_justify_msg, TRUE, NOVIEW);
799#endif
800
Chris Allegretta637daa82011-02-07 14:45:56 +0000801 add_to_funcs(do_page_up, MMAIN|MHELP|MBROWSER,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000802 prev_page_msg, IFSCHELP(nano_prevpage_msg), FALSE, VIEW);
Chris Allegretta637daa82011-02-07 14:45:56 +0000803 add_to_funcs(do_page_down, MMAIN|MHELP|MBROWSER,
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000804 next_page_msg, IFSCHELP(nano_nextpage_msg), TRUE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000805
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000806#ifdef ENABLE_COLOR
807 add_to_funcs(do_page_up, MLINTER,
808 prev_lint_msg, IFSCHELP(nano_prevlint_msg), FALSE, VIEW);
809 add_to_funcs(do_page_down, MLINTER,
810 next_lint_msg, IFSCHELP(nano_nextlint_msg), FALSE, VIEW);
811#endif
Chris Allegretta07fcc4c2008-07-10 20:13:04 +0000812
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000813 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta637daa82011-02-07 14:45:56 +0000814 add_to_funcs(do_cut_text_void, MMAIN, N_("Cut Text"), IFSCHELP(nano_cut_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000815 FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000816
Chris Allegretta07798352000-11-27 22:58:23 +0000817 if (unjustify)
David Lawrence Ramseyed467e52006-07-03 18:40:53 +0000818 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta637daa82011-02-07 14:45:56 +0000819 add_to_funcs(do_uncut_text, MMAIN, N_("UnJustify"), "",
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000820 FALSE, NOVIEW);
Chris Allegretta07798352000-11-27 22:58:23 +0000821 else
David Lawrence Ramseyed467e52006-07-03 18:40:53 +0000822 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta637daa82011-02-07 14:45:56 +0000823 add_to_funcs(do_uncut_text, MMAIN, N_("UnCut Text"), IFSCHELP(nano_uncut_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000824 FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000825
Chris Allegrettae347efb2008-03-09 02:52:40 +0000826#ifndef NANO_TINY
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000827 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta637daa82011-02-07 14:45:56 +0000828 add_to_funcs(do_cursorpos_void, MMAIN, N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000829 FALSE, VIEW);
Chris Allegrettae347efb2008-03-09 02:52:40 +0000830#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000831
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000832 /* If we're using restricted mode, spell checking is disabled
833 * because it allows reading from or writing to files not specified
834 * on the command line. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000835#ifndef DISABLE_SPELLER
Chris Allegrettaab538642010-11-12 06:22:12 +0000836 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000837 add_to_funcs(do_spell, MMAIN, spell_msg, IFSCHELP(nano_spell_msg),
Chris Allegrettaab538642010-11-12 06:22:12 +0000838 TRUE, NOVIEW);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000839#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000840
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000841#ifdef ENABLE_COLOR
842 add_to_funcs(do_linter, MMAIN, lint_msg, IFSCHELP(nano_lint_msg),
843 TRUE, NOVIEW);
844#endif
845
Chris Allegretta637daa82011-02-07 14:45:56 +0000846 add_to_funcs(do_first_line,
Chris Allegrettaa97cb812009-12-02 03:24:18 +0000847 (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE),
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000848 first_line_msg, IFSCHELP(nano_firstline_msg), FALSE, VIEW);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000849
Chris Allegretta637daa82011-02-07 14:45:56 +0000850 add_to_funcs(do_last_line,
Chris Allegrettaa97cb812009-12-02 03:24:18 +0000851 (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000852 last_line_msg, IFSCHELP(nano_lastline_msg), TRUE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000853
Chris Allegretta637daa82011-02-07 14:45:56 +0000854 add_to_funcs(do_gotolinecolumn_void, (MMAIN|MWHEREIS),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000855 go_to_line_msg, IFSCHELP(nano_gotoline_msg), FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000856
Chris Allegrettae347efb2008-03-09 02:52:40 +0000857#ifdef NANO_TINY
Chris Allegretta1fb25fd2008-03-18 03:06:27 +0000858 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta637daa82011-02-07 14:45:56 +0000859 add_to_funcs(do_cursorpos_void, MMAIN, N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg),
Chris Allegrettae347efb2008-03-09 02:52:40 +0000860 FALSE, VIEW);
861#endif
862
Chris Allegretta637daa82011-02-07 14:45:56 +0000863 add_to_funcs(do_replace, (MMAIN|MWHEREIS), replace_msg, IFSCHELP(nano_replace_msg),
David Lawrence Ramseyf1e56272006-05-22 18:28:20 +0000864#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000865 FALSE,
David Lawrence Ramseyf1e56272006-05-22 18:28:20 +0000866#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000867 TRUE,
David Lawrence Ramseyf1e56272006-05-22 18:28:20 +0000868#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000869 NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000870
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000871#ifndef NANO_TINY
Chris Allegretta2ad1de02012-12-30 19:20:10 +0000872 add_to_funcs(do_mark, MMAIN, N_("Mark Text"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000873 IFSCHELP(nano_mark_msg), FALSE, VIEW);
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000874
Benno Schulenbergcae7aea2014-02-26 20:37:40 +0000875 add_to_funcs(do_research, MMAIN, whereis_next_msg,
Chris Allegretta1d778232008-08-30 21:00:00 +0000876 IFSCHELP(nano_whereis_next_msg), TRUE, VIEW);
David Lawrence Ramseyf85001a2006-04-28 13:19:56 +0000877
Chris Allegretta637daa82011-02-07 14:45:56 +0000878 add_to_funcs(do_copy_text, MMAIN, N_("Copy Text"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000879 IFSCHELP(nano_copy_msg), FALSE, NOVIEW);
David Lawrence Ramseyf85001a2006-04-28 13:19:56 +0000880
Chris Allegretta637daa82011-02-07 14:45:56 +0000881 add_to_funcs(do_indent_void, MMAIN, N_("Indent Text"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000882 IFSCHELP(nano_indent_msg), FALSE, NOVIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000883
Chris Allegretta637daa82011-02-07 14:45:56 +0000884 add_to_funcs(do_unindent, MMAIN, N_("Unindent Text"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000885 IFSCHELP(nano_unindent_msg), FALSE, NOVIEW);
Chris Allegretta07fcc4c2008-07-10 20:13:04 +0000886
Chris Allegrettaa48507d2009-08-14 03:18:29 +0000887 if (ISSET(UNDOABLE)) {
Chris Allegretta637daa82011-02-07 14:45:56 +0000888 add_to_funcs(do_undo, MMAIN, N_("Undo"),
Chris Allegrettaad37e672009-07-12 03:36:58 +0000889 IFSCHELP(nano_undo_msg), FALSE, NOVIEW);
Chris Allegretta07fcc4c2008-07-10 20:13:04 +0000890
Chris Allegretta637daa82011-02-07 14:45:56 +0000891 add_to_funcs(do_redo, MMAIN, N_("Redo"),
Chris Allegrettaad37e672009-07-12 03:36:58 +0000892 IFSCHELP(nano_redo_msg), TRUE, NOVIEW);
893 }
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000894#endif
895
Chris Allegretta637daa82011-02-07 14:45:56 +0000896 add_to_funcs(do_right, MMAIN, N_("Forward"), IFSCHELP(nano_forward_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000897 FALSE, VIEW);
Chris Allegretta8d41fb82009-12-23 05:03:09 +0000898
899#ifndef DISABLE_BROWSER
Chris Allegretta637daa82011-02-07 14:45:56 +0000900 add_to_funcs(do_right, MBROWSER, N_("Forward"), IFSCHELP(nano_forwardfile_msg),
Chris Allegretta8d41fb82009-12-23 05:03:09 +0000901 FALSE, VIEW);
902#endif
903
Chris Allegretta637daa82011-02-07 14:45:56 +0000904 add_to_funcs(do_right, MALL, "", "", FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000905
Chris Allegretta637daa82011-02-07 14:45:56 +0000906 add_to_funcs(do_left, MMAIN, N_("Back"), IFSCHELP(nano_back_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000907 FALSE, VIEW);
Chris Allegretta8d41fb82009-12-23 05:03:09 +0000908
909#ifndef DISABLE_BROWSER
Chris Allegretta637daa82011-02-07 14:45:56 +0000910 add_to_funcs(do_left, MBROWSER, N_("Back"), IFSCHELP(nano_backfile_msg),
Chris Allegretta8d41fb82009-12-23 05:03:09 +0000911 FALSE, VIEW);
912#endif
913
Chris Allegretta637daa82011-02-07 14:45:56 +0000914 add_to_funcs(do_left, MALL, "", "", FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000915
916#ifndef NANO_TINY
Chris Allegretta637daa82011-02-07 14:45:56 +0000917 add_to_funcs(do_prev_word_void, MMAIN, N_("Prev Word"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000918 IFSCHELP(nano_prevword_msg), FALSE, VIEW);
Benno Schulenbergbe5ab4e2014-02-25 21:30:12 +0000919
920 add_to_funcs(do_next_word_void, MMAIN, N_("Next Word"),
921 IFSCHELP(nano_nextword_msg), FALSE, VIEW);
Chris Allegretta8d990b52001-09-22 22:14:25 +0000922#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000923
Chris Allegretta637daa82011-02-07 14:45:56 +0000924 add_to_funcs(do_up_void, (MMAIN|MHELP|MBROWSER), N_("Prev Line"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000925 IFSCHELP(nano_prevline_msg), FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000926
Chris Allegretta637daa82011-02-07 14:45:56 +0000927 add_to_funcs(do_down_void, (MMAIN|MHELP|MBROWSER), N_("Next Line"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000928 IFSCHELP(nano_nextline_msg), TRUE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000929
Chris Allegretta637daa82011-02-07 14:45:56 +0000930 add_to_funcs(do_home, MMAIN, N_("Home"), IFSCHELP(nano_home_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000931 FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000932
Chris Allegretta637daa82011-02-07 14:45:56 +0000933 add_to_funcs(do_end, MMAIN, N_("End"), IFSCHELP(nano_end_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000934 FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000935
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000936#ifndef DISABLE_JUSTIFY
Chris Allegretta637daa82011-02-07 14:45:56 +0000937 add_to_funcs(do_para_begin_void, (MMAIN|MWHEREIS), beg_of_par_msg,
Chris Allegretta1d778232008-08-30 21:00:00 +0000938 IFSCHELP(nano_parabegin_msg), FALSE, VIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000939
Chris Allegretta637daa82011-02-07 14:45:56 +0000940 add_to_funcs(do_para_end_void, (MMAIN|MWHEREIS), end_of_par_msg,
Chris Allegretta1d778232008-08-30 21:00:00 +0000941 IFSCHELP(nano_paraend_msg), FALSE, VIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000942#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000943
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000944#ifndef NANO_TINY
Chris Allegretta637daa82011-02-07 14:45:56 +0000945 add_to_funcs(do_find_bracket, MMAIN, _("Find Other Bracket"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000946 IFSCHELP(nano_bracket_msg), FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000947
Chris Allegretta637daa82011-02-07 14:45:56 +0000948 add_to_funcs(do_scroll_up, MMAIN, N_("Scroll Up"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000949 IFSCHELP(nano_scrollup_msg), FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000950
Chris Allegretta637daa82011-02-07 14:45:56 +0000951 add_to_funcs(do_scroll_down, MMAIN, N_("Scroll Down"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000952 IFSCHELP(nano_scrolldown_msg), FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000953#endif
David Lawrence Ramseydf453652006-04-21 02:05:09 +0000954
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000955#ifdef ENABLE_MULTIBUFFER
Chris Allegretta637daa82011-02-07 14:45:56 +0000956 add_to_funcs(switch_to_prev_buffer_void, MMAIN, _("Previous File"),
Chris Allegretta2cca4832008-03-31 06:25:14 +0000957 IFSCHELP(nano_prevfile_msg), FALSE, VIEW);
Chris Allegretta637daa82011-02-07 14:45:56 +0000958 add_to_funcs(switch_to_next_buffer_void, MMAIN, N_("Next File"),
Chris Allegretta2cca4832008-03-31 06:25:14 +0000959 IFSCHELP(nano_nextfile_msg), TRUE, VIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000960#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +0000961
Chris Allegretta637daa82011-02-07 14:45:56 +0000962 add_to_funcs(do_verbatim_input, MMAIN, N_("Verbatim Input"),
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000963 IFSCHELP(nano_verbatim_msg), FALSE, NOVIEW);
Chris Allegretta637daa82011-02-07 14:45:56 +0000964 add_to_funcs(do_verbatim_input, MWHEREIS|MREPLACE|MREPLACE2|MEXTCMD|MSPELL,
Chris Allegrettaaa17df02008-03-17 05:50:04 +0000965 "", "", FALSE, NOVIEW);
966
Chris Allegretta637daa82011-02-07 14:45:56 +0000967 add_to_funcs(do_tab, MMAIN, N_("Tab"), IFSCHELP(nano_tab_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000968 FALSE, NOVIEW);
Chris Allegretta637daa82011-02-07 14:45:56 +0000969 add_to_funcs(do_tab, MALL, "", "", FALSE, NOVIEW);
970 add_to_funcs(do_enter_void, MMAIN, N_("Enter"), IFSCHELP(nano_enter_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000971 FALSE, NOVIEW);
Chris Allegretta637daa82011-02-07 14:45:56 +0000972 add_to_funcs(do_enter_void, MALL, "", "", FALSE, NOVIEW);
973 add_to_funcs(do_delete, MMAIN, N_("Delete"), IFSCHELP(nano_delete_msg),
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000974 FALSE, NOVIEW);
Chris Allegretta637daa82011-02-07 14:45:56 +0000975 add_to_funcs(do_delete, MALL, "", "", FALSE, NOVIEW);
976 add_to_funcs(do_backspace, MMAIN, N_("Backspace"), IFSCHELP(nano_backspace_msg),
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000977#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000978 FALSE,
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000979#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000980 TRUE,
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000981#endif
Chris Allegrettaeb643142008-03-12 04:44:14 +0000982 NOVIEW);
983
Chris Allegretta637daa82011-02-07 14:45:56 +0000984 add_to_funcs(do_backspace, MALL, "", "",
Chris Allegrettaeb643142008-03-12 04:44:14 +0000985#ifndef NANO_TINY
986 FALSE,
987#else
988 TRUE,
989#endif
990 NOVIEW);
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000991
David Lawrence Ramsey2ca23562006-04-23 19:15:15 +0000992#ifndef NANO_TINY
Chris Allegretta637daa82011-02-07 14:45:56 +0000993 add_to_funcs(do_cut_till_end, MMAIN, N_("CutTillEnd"),
Chris Allegretta1d778232008-08-30 21:00:00 +0000994 IFSCHELP(nano_cut_till_end_msg), TRUE, NOVIEW);
David Lawrence Ramsey2ca23562006-04-23 19:15:15 +0000995#endif
996
Chris Allegretta637daa82011-02-07 14:45:56 +0000997 add_to_funcs(xon_complaint, MMAIN, "", "", FALSE, VIEW);
998 add_to_funcs(xoff_complaint, MMAIN, "", "", FALSE, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000999
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +00001000#ifndef DISABLE_JUSTIFY
Chris Allegretta637daa82011-02-07 14:45:56 +00001001 add_to_funcs(do_full_justify, (MMAIN|MWHEREIS), fulljstify_msg,
Chris Allegretta1d778232008-08-30 21:00:00 +00001002 IFSCHELP(nano_fulljustify_msg), FALSE, NOVIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +00001003#endif
1004
David Lawrence Ramseyc5c52302005-11-15 23:45:29 +00001005#ifndef NANO_TINY
Chris Allegretta637daa82011-02-07 14:45:56 +00001006 add_to_funcs(do_wordlinechar_count, MMAIN, N_("Word Count"),
Chris Allegretta1d778232008-08-30 21:00:00 +00001007 IFSCHELP(nano_wordcount_msg), FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +00001008#endif
David Lawrence Ramseyefb4b0a2006-04-19 14:09:01 +00001009
Chris Allegretta2ad1de02012-12-30 19:20:10 +00001010 add_to_funcs(total_refresh, (MMAIN|MHELP), refresh_msg,
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001011 IFSCHELP(nano_refresh_msg), FALSE, VIEW);
1012
Chris Allegretta637daa82011-02-07 14:45:56 +00001013 add_to_funcs(do_suspend_void, MMAIN, suspend_msg,
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001014 IFSCHELP(nano_suspend_msg), TRUE, VIEW);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +00001015
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001016#ifndef NANO_TINY
Chris Allegretta637daa82011-02-07 14:45:56 +00001017 add_to_funcs(case_sens_void,
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001018 (MWHEREIS|MREPLACE|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +00001019 case_sens_msg, IFSCHELP(nano_case_msg), FALSE, VIEW);
Chris Allegretta658399a2001-06-14 02:54:22 +00001020
Chris Allegretta637daa82011-02-07 14:45:56 +00001021 add_to_funcs(backwards_void,
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001022 (MWHEREIS|MREPLACE|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +00001023 backwards_msg, IFSCHELP(nano_reverse_msg), FALSE, VIEW);
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +00001024#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00001025
Chris Allegretta658399a2001-06-14 02:54:22 +00001026#ifdef HAVE_REGEX_H
Chris Allegretta637daa82011-02-07 14:45:56 +00001027 add_to_funcs(regexp_void,
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001028 (MWHEREIS|MREPLACE|MWHEREISFILE),
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001029 regexp_msg, IFSCHELP(nano_regexp_msg), FALSE, VIEW);
Chris Allegretta658399a2001-06-14 02:54:22 +00001030#endif
Chris Allegretta5beed502003-01-05 20:41:21 +00001031
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001032#ifndef NANO_TINY
Chris Allegretta637daa82011-02-07 14:45:56 +00001033 add_to_funcs(get_history_older_void,
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001034 (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +00001035 prev_history_msg, IFSCHELP(nano_prev_history_msg), FALSE, VIEW);
David Lawrence Ramsey305d8892006-05-24 19:48:03 +00001036
Chris Allegretta637daa82011-02-07 14:45:56 +00001037 add_to_funcs(get_history_newer_void,
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001038 (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +00001039 next_history_msg, IFSCHELP(nano_next_history_msg), FALSE, VIEW);
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +00001040#endif
David Lawrence Ramsey02085d72004-11-07 16:04:18 +00001041
Chris Allegretta637daa82011-02-07 14:45:56 +00001042 add_to_funcs(no_replace_void, MREPLACE,
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001043 no_replace_msg, IFSCHELP(nano_whereis_msg), FALSE, VIEW);
Chris Allegretta5f36c372001-07-16 00:48:53 +00001044
Chris Allegretta637daa82011-02-07 14:45:56 +00001045 add_to_funcs(gototext_void, MGOTOLINE,
Chris Allegretta10f868d2008-03-14 04:08:51 +00001046 gototext_msg, IFSCHELP(nano_whereis_msg), TRUE, VIEW);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001047
Rocco Corsiaf5c3022001-01-12 07:51:05 +00001048#ifndef DISABLE_BROWSER
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +00001049 if (!ISSET(RESTRICTED))
Chris Allegretta637daa82011-02-07 14:45:56 +00001050 add_to_funcs(to_files_void,
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001051 (MGOTOLINE|MINSERTFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +00001052 to_files_msg, IFSCHELP(nano_tofiles_msg), FALSE, VIEW);
Chris Allegrettaf4b96012001-01-03 07:11:47 +00001053#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00001054
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001055#ifndef NANO_TINY
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +00001056 /* If we're using restricted mode, the DOS format, Mac format,
1057 * append, prepend, and backup toggles are disabled. The first and
1058 * second are useless since inserting files is disabled, the third
1059 * and fourth are disabled because they allow writing to files not
1060 * specified on the command line, and the fifth is useless since
1061 * backups are disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +00001062 if (!ISSET(RESTRICTED))
Chris Allegretta637daa82011-02-07 14:45:56 +00001063 add_to_funcs(dos_format_void, MWRITEFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +00001064 dos_format_msg, IFSCHELP(nano_dos_msg), FALSE, NOVIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +00001065
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +00001066 if (!ISSET(RESTRICTED))
Chris Allegretta637daa82011-02-07 14:45:56 +00001067 add_to_funcs(mac_format_void, MWRITEFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +00001068 mac_format_msg, IFSCHELP(nano_mac_msg), FALSE, NOVIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +00001069
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +00001070 if (!ISSET(RESTRICTED))
Chris Allegretta637daa82011-02-07 14:45:56 +00001071 add_to_funcs( append_void, MWRITEFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +00001072 append_msg, IFSCHELP(nano_append_msg), FALSE, NOVIEW);
Chris Allegrettacc197ef2001-05-29 04:21:44 +00001073
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +00001074 if (!ISSET(RESTRICTED))
Chris Allegretta637daa82011-02-07 14:45:56 +00001075 add_to_funcs( prepend_void, MWRITEFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +00001076 prepend_msg, IFSCHELP(nano_prepend_msg), FALSE, NOVIEW);
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +00001077
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +00001078 if (!ISSET(RESTRICTED))
Chris Allegretta637daa82011-02-07 14:45:56 +00001079 add_to_funcs( backup_file_void, MWRITEFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +00001080 backup_file_msg, IFSCHELP(nano_backup_msg), FALSE, NOVIEW);
Chris Allegrettacc197ef2001-05-29 04:21:44 +00001081#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +00001082
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001083#ifndef NANO_TINY
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +00001084 /* If we're using restricted mode, command execution is disabled.
1085 * It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +00001086 if (!ISSET(RESTRICTED))
Chris Allegretta637daa82011-02-07 14:45:56 +00001087 add_to_funcs( ext_cmd_void, MINSERTFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +00001088 ext_cmd_msg, IFSCHELP(nano_execute_msg), FALSE, NOVIEW);
David Lawrence Ramseya593f532003-11-28 19:47:42 +00001089
Chris Allegrettaf7c68112002-09-03 22:58:40 +00001090#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +00001091 /* If we're using restricted mode, the multibuffer toggle is
1092 * disabled. It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +00001093 if (!ISSET(RESTRICTED))
Chris Allegretta637daa82011-02-07 14:45:56 +00001094 add_to_funcs( new_buffer_void, MINSERTFILE,
Chris Allegretta1d778232008-08-30 21:00:00 +00001095 new_buffer_msg, IFSCHELP(nano_multibuffer_msg), FALSE, NOVIEW);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +00001096#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +00001097
Chris Allegretta637daa82011-02-07 14:45:56 +00001098 add_to_funcs( do_insertfile_void, MEXTCMD,
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001099 insert_file_msg, IFSCHELP(nano_insert_msg), FALSE, VIEW);
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +00001100
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +00001101#ifdef ENABLE_MULTIBUFFER
Benno Schulenberg7f873932014-02-25 21:27:22 +00001102 add_to_funcs( new_buffer_void, MEXTCMD,
Chris Allegretta1d778232008-08-30 21:00:00 +00001103 new_buffer_msg, IFSCHELP(nano_multibuffer_msg), FALSE, NOVIEW);
Chris Allegretta52c5a6e2002-03-21 05:07:28 +00001104#endif
Benno Schulenberg7f873932014-02-25 21:27:22 +00001105#endif /* NANO_TINY */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00001106
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +00001107#ifndef DISABLE_HELP
Chris Allegretta637daa82011-02-07 14:45:56 +00001108 add_to_funcs(edit_refresh, MHELP,
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001109 refresh_msg, nano_refresh_msg, FALSE, VIEW);
Chris Allegrettab27b3a12009-12-04 04:29:55 +00001110
Chris Allegretta637daa82011-02-07 14:45:56 +00001111 add_to_funcs(do_exit, MHELP, exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW);
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +00001112#endif
1113
Rocco Corsiaf5c3022001-01-12 07:51:05 +00001114#ifndef DISABLE_BROWSER
Chris Allegretta637daa82011-02-07 14:45:56 +00001115 add_to_funcs(do_first_file,
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001116 (MBROWSER|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +00001117 first_file_msg, IFSCHELP(nano_firstfile_msg), FALSE, VIEW);
Chris Allegrettab3655b42001-10-22 03:15:31 +00001118
Chris Allegretta637daa82011-02-07 14:45:56 +00001119 add_to_funcs(do_last_file,
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001120 (MBROWSER|MWHEREISFILE),
Chris Allegretta1d778232008-08-30 21:00:00 +00001121 last_file_msg, IFSCHELP(nano_lastfile_msg), FALSE, VIEW);
Chris Allegrettab3655b42001-10-22 03:15:31 +00001122
Chris Allegretta637daa82011-02-07 14:45:56 +00001123 add_to_funcs(goto_dir_void, MBROWSER,
Chris Allegretta1d778232008-08-30 21:00:00 +00001124 goto_dir_msg, IFSCHELP(nano_gotodir_msg), FALSE, VIEW);
David Lawrence Ramseye38b8082006-03-30 07:03:04 +00001125#endif
1126
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001127 currmenu = MMAIN;
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001128
Chris Allegretta5575bfa2014-02-24 10:18:15 +00001129 while (sclist != NULL) {
1130 sc *s = sclist;
1131 sclist = (s)->next;
1132 free(s);
1133 }
1134
1135 add_to_sclist(MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MBROWSER|MWHEREISFILE|MGOTODIR|MLINTER,
Chris Allegretta637daa82011-02-07 14:45:56 +00001136 "^G", do_help_void, 0, TRUE);
Chris Allegretta5575bfa2014-02-24 10:18:15 +00001137 add_to_sclist(MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MBROWSER|MWHEREISFILE|MGOTODIR|MLINTER,
Chris Allegretta637daa82011-02-07 14:45:56 +00001138 "F1", do_help_void, 0, TRUE);
1139 add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", do_exit, 0, TRUE);
1140 add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", do_exit, 0, TRUE);
1141 add_to_sclist(MMAIN, "^_", do_gotolinecolumn_void, 0, TRUE);
1142 add_to_sclist(MMAIN, "F13", do_gotolinecolumn_void, 0, TRUE);
1143 add_to_sclist(MMAIN, "M-G", do_gotolinecolumn_void, 0, TRUE);
1144 add_to_sclist(MMAIN, "^O", do_writeout_void, 0, TRUE);
1145 add_to_sclist(MMAIN, "F3", do_writeout_void, 0, TRUE);
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001146#ifndef DISABLE_JUSTIFY
Chris Allegretta637daa82011-02-07 14:45:56 +00001147 add_to_sclist(MMAIN, "^J", do_justify_void, 0, TRUE);
1148 add_to_sclist(MMAIN, "F4", do_justify_void, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001149#endif
Chris Allegretta637daa82011-02-07 14:45:56 +00001150 add_to_sclist(MMAIN, "^R", do_insertfile_void, 0, TRUE);
1151 add_to_sclist(MMAIN, "F5", do_insertfile_void, 0, TRUE);
1152 add_to_sclist(MMAIN, "kinsert", do_insertfile_void, 0, TRUE);
1153 add_to_sclist(MMAIN|MBROWSER, "^W", do_search, 0, TRUE);
1154 add_to_sclist(MMAIN|MBROWSER, "F6", do_search, 0, TRUE);
Chris Allegretta5575bfa2014-02-24 10:18:15 +00001155 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "^Y", do_page_up, 0, TRUE);
1156 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "F7", do_page_up, 0, TRUE);
1157 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "kpup", do_page_up, 0, TRUE);
1158 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "^V", do_page_down, 0, TRUE);
1159 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "F8", do_page_down, 0, TRUE);
1160 add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "kpdown", do_page_down, 0, TRUE);
Chris Allegretta637daa82011-02-07 14:45:56 +00001161 add_to_sclist(MMAIN, "^K", do_cut_text_void, 0, TRUE);
1162 add_to_sclist(MMAIN, "F9", do_cut_text_void, 0, TRUE);
1163 add_to_sclist(MMAIN, "^U", do_uncut_text, 0, TRUE);
1164 add_to_sclist(MMAIN, "F10", do_uncut_text, 0, TRUE);
1165 add_to_sclist(MMAIN, "^C", do_cursorpos_void, 0, TRUE);
1166 add_to_sclist(MMAIN, "F11", do_cursorpos_void, 0, TRUE);
Chris Allegretta506af6f2008-05-31 22:49:55 +00001167#ifndef DISABLE_SPELLER
Chris Allegretta637daa82011-02-07 14:45:56 +00001168 add_to_sclist(MMAIN, "^T", do_spell, 0, TRUE);
1169 add_to_sclist(MMAIN, "F12", do_spell, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001170#endif
Chris Allegretta637daa82011-02-07 14:45:56 +00001171 add_to_sclist(MMAIN, "^\\", do_replace, 0, TRUE);
1172 add_to_sclist(MMAIN, "F14", do_replace, 0, TRUE);
1173 add_to_sclist(MMAIN, "M-R", do_replace, 0, TRUE);
1174 add_to_sclist(MWHEREIS, "^R", do_replace, 0, FALSE);
1175 add_to_sclist(MREPLACE, "^R", no_replace_void, 0, FALSE);
1176 add_to_sclist(MWHEREIS, "^T", do_gotolinecolumn_void, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001177#ifndef NANO_TINY
Chris Allegretta637daa82011-02-07 14:45:56 +00001178 add_to_sclist(MMAIN, "^^", do_mark, 0, TRUE);
1179 add_to_sclist(MMAIN, "F15", do_mark, 0, TRUE);
1180 add_to_sclist(MMAIN, "M-A", do_mark, 0, TRUE);
1181 add_to_sclist(MMAIN|MBROWSER, "M-W", do_research, 0, TRUE);
1182 add_to_sclist(MMAIN|MBROWSER, "F16", do_research, 0, TRUE);
1183 add_to_sclist(MMAIN, "M-^", do_copy_text, 0, TRUE);
1184 add_to_sclist(MMAIN, "M-6", do_copy_text, 0, TRUE);
1185 add_to_sclist(MMAIN, "M-}", do_indent_void, 0, TRUE);
1186 add_to_sclist(MMAIN, "M-{", do_unindent, 0, TRUE);
Chris Allegrettaa48507d2009-08-14 03:18:29 +00001187 if (ISSET(UNDOABLE)) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001188 add_to_sclist(MMAIN, "M-U", do_undo, 0, TRUE);
1189 add_to_sclist(MMAIN, "M-E", do_redo, 0, TRUE);
Chris Allegrettaad37e672009-07-12 03:36:58 +00001190 }
Chris Allegretta637daa82011-02-07 14:45:56 +00001191 add_to_sclist(MALL, "^F", do_right, 0, TRUE);
1192 add_to_sclist(MALL, "^B", do_left, 0, TRUE);
1193 add_to_sclist(MMAIN, "^Space", do_next_word_void, 0, TRUE);
1194 add_to_sclist(MMAIN, "M-Space", do_prev_word_void, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001195#endif
Chris Allegretta637daa82011-02-07 14:45:56 +00001196 add_to_sclist(MALL, "kright", do_right, 0, TRUE);
1197 add_to_sclist(MALL, "kleft", do_left, 0, TRUE);
1198 add_to_sclist(MMAIN, "^Q", xon_complaint, 0, TRUE);
1199 add_to_sclist(MMAIN, "^S", xoff_complaint, 0, TRUE);
1200 add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", do_up_void, 0, TRUE);
1201 add_to_sclist(MMAIN|MHELP|MBROWSER, "kup", do_up_void, 0, TRUE);
1202 add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", do_down_void, 0, TRUE);
1203 add_to_sclist(MMAIN|MHELP|MBROWSER, "kdown", do_down_void, 0, TRUE);
1204 add_to_sclist(MALL, "^A", do_home, 0, TRUE);
1205 add_to_sclist(MALL, "khome", do_home, 0, TRUE);
1206 add_to_sclist(MALL, "^E", do_end, 0, TRUE);
1207 add_to_sclist(MALL, "kend", do_end, 0, TRUE);
Chris Allegretta1b6ed072008-06-03 08:09:05 +00001208#ifndef NANO_TINY
Chris Allegretta637daa82011-02-07 14:45:56 +00001209 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "^P", get_history_older_void, 0, FALSE);
1210 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "kup", get_history_older_void, 0, FALSE);
1211 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "^N", get_history_newer_void, 0, FALSE);
1212 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "kdown", get_history_newer_void, 0, FALSE);
Chris Allegretta1b6ed072008-06-03 08:09:05 +00001213#endif
Chris Allegretta1347f222008-06-29 06:22:31 +00001214#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001215 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
Chris Allegretta637daa82011-02-07 14:45:56 +00001216 "^W", do_para_begin_void, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001217 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
Chris Allegretta637daa82011-02-07 14:45:56 +00001218 "^O", do_para_end_void, 0, TRUE);
1219 add_to_sclist(MALL, "M-(", do_para_begin_void, 0, TRUE);
1220 add_to_sclist(MALL, "M-9", do_para_begin_void, 0, TRUE);
1221 add_to_sclist(MALL, "M-)", do_para_end_void, 0, TRUE);
1222 add_to_sclist(MALL, "M-0", do_para_end_void, 0, TRUE);
Chris Allegrettae347efb2008-03-09 02:52:40 +00001223#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001224 add_to_sclist(MWHEREIS,
Chris Allegretta637daa82011-02-07 14:45:56 +00001225 "M-C", case_sens_void, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001226 add_to_sclist(MREPLACE,
Chris Allegretta637daa82011-02-07 14:45:56 +00001227 "M-C", case_sens_void, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001228 add_to_sclist(MREPLACE2,
Chris Allegretta637daa82011-02-07 14:45:56 +00001229 "M-C", case_sens_void, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001230 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
Chris Allegretta637daa82011-02-07 14:45:56 +00001231 "M-B", backwards_void, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001232 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
Chris Allegretta637daa82011-02-07 14:45:56 +00001233 "M-R", regexp_void, 0, FALSE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001234
Chris Allegretta637daa82011-02-07 14:45:56 +00001235 add_to_sclist(MMAIN, "M-\\", do_first_line, 0, TRUE);
1236 add_to_sclist(MMAIN, "M-|", do_first_line, 0, TRUE);
1237 add_to_sclist(MMAIN, "M-/", do_last_line, 0, TRUE);
1238 add_to_sclist(MMAIN, "M-?", do_last_line, 0, TRUE);
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001239 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP,
Chris Allegretta637daa82011-02-07 14:45:56 +00001240 "^Y", do_first_line, 0, TRUE);
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001241 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP,
Chris Allegretta637daa82011-02-07 14:45:56 +00001242 "^V", do_last_line, 0, TRUE);
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001243
Chris Allegretta637daa82011-02-07 14:45:56 +00001244#ifndef DISABLE_BROWSER
1245 add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", do_first_file, 0, TRUE);
1246 add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", do_first_file, 0, TRUE);
1247 add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", do_last_file, 0, TRUE);
1248 add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", do_last_file, 0, TRUE);
1249#endif
1250 add_to_sclist(MBROWSER|MWHEREISFILE, "^_", goto_dir_void, 0, TRUE);
1251 add_to_sclist(MBROWSER|MWHEREISFILE, "F13", goto_dir_void, 0, TRUE);
1252 add_to_sclist(MBROWSER|MWHEREISFILE, "M-G", goto_dir_void, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001253#ifndef NANO_TINY
Chris Allegretta637daa82011-02-07 14:45:56 +00001254 add_to_sclist(MMAIN, "M-]", do_find_bracket, 0, TRUE);
1255 add_to_sclist(MMAIN, "M--", do_scroll_up, 0, TRUE);
1256 add_to_sclist(MMAIN, "M-_", do_scroll_up, 0, TRUE);
1257 add_to_sclist(MMAIN, "M-+", do_scroll_down, 0, TRUE);
1258 add_to_sclist(MMAIN, "M-=", do_scroll_down, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001259#endif
1260
1261#ifdef ENABLE_MULTIBUFFER
Chris Allegretta637daa82011-02-07 14:45:56 +00001262 add_to_sclist(MMAIN, "M-<", switch_to_prev_buffer_void, 0, TRUE);
1263 add_to_sclist(MMAIN, "M-,", switch_to_prev_buffer_void, 0, TRUE);
1264 add_to_sclist(MMAIN, "M->", switch_to_next_buffer_void, 0, TRUE);
1265 add_to_sclist(MMAIN, "M-.", switch_to_next_buffer_void, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001266#endif
Chris Allegretta637daa82011-02-07 14:45:56 +00001267 add_to_sclist(MALL, "M-V", do_verbatim_input, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001268#ifndef NANO_TINY
Chris Allegretta637daa82011-02-07 14:45:56 +00001269 add_to_sclist(MALL, "M-T", do_cut_till_end, 0, TRUE);
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001270#ifndef DISABLE_JUSTIFY
Chris Allegretta637daa82011-02-07 14:45:56 +00001271 add_to_sclist(MALL, "M-J", do_full_justify, 0, TRUE);
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001272#endif
Chris Allegretta637daa82011-02-07 14:45:56 +00001273 add_to_sclist(MMAIN, "M-D", do_wordlinechar_count, 0, TRUE);
1274 add_to_sclist(MMAIN, "M-X", do_toggle_void, NO_HELP, TRUE);
1275 add_to_sclist(MMAIN, "M-C", do_toggle_void, CONST_UPDATE, TRUE);
1276 add_to_sclist(MMAIN, "M-O", do_toggle_void, MORE_SPACE, TRUE);
1277 add_to_sclist(MMAIN, "M-S", do_toggle_void, SMOOTH_SCROLL, TRUE);
1278 add_to_sclist(MMAIN, "M-P", do_toggle_void, WHITESPACE_DISPLAY, TRUE);
1279 add_to_sclist(MMAIN, "M-Y", do_toggle_void, NO_COLOR_SYNTAX, TRUE);
1280 add_to_sclist(MMAIN, "M-H", do_toggle_void, SMART_HOME, TRUE);
1281 add_to_sclist(MMAIN, "M-I", do_toggle_void, AUTOINDENT, TRUE);
1282 add_to_sclist(MMAIN, "M-K", do_toggle_void, CUT_TO_END, TRUE);
1283 add_to_sclist(MMAIN, "M-L", do_toggle_void, NO_WRAP, TRUE);
1284 add_to_sclist(MMAIN, "M-Q", do_toggle_void, TABS_TO_SPACES, TRUE);
1285 add_to_sclist(MMAIN, "M-B", do_toggle_void, BACKUP_FILE, TRUE);
1286 add_to_sclist(MMAIN, "M-F", do_toggle_void, MULTIBUFFER, TRUE);
1287 add_to_sclist(MMAIN, "M-M", do_toggle_void, USE_MOUSE, TRUE);
1288 add_to_sclist(MMAIN, "M-N", do_toggle_void, NO_CONVERT, TRUE);
1289 add_to_sclist(MMAIN, "M-Z", do_toggle_void, SUSPEND, TRUE);
1290 add_to_sclist(MMAIN, "M-$", do_toggle_void, SOFTWRAP, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001291#endif
Benno Schulenbergdb906ea2014-02-25 21:45:55 +00001292 add_to_sclist(MHELP|MBROWSER, "^C", do_exit, 0, TRUE);
1293 add_to_sclist(MHELP, "^G", do_exit, 0, TRUE);
Chris Allegretta637daa82011-02-07 14:45:56 +00001294 add_to_sclist(MGOTOLINE, "^T", gototext_void, 0, FALSE);
1295 add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", new_buffer_void, 0, FALSE);
Chris Allegretta5575bfa2014-02-24 10:18:15 +00001296 add_to_sclist((MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR|MYESNO|MLINTER),
Chris Allegretta637daa82011-02-07 14:45:56 +00001297 "^C", do_cancel, 0, FALSE);
Chris Allegretta637daa82011-02-07 14:45:56 +00001298 add_to_sclist(MWRITEFILE, "M-D", dos_format_void, 0, FALSE);
1299 add_to_sclist(MWRITEFILE, "M-M", mac_format_void, 0, FALSE);
1300 add_to_sclist(MWRITEFILE, "M-A", append_void, 0, FALSE);
1301 add_to_sclist(MWRITEFILE, "M-P", prepend_void, 0, FALSE);
1302 add_to_sclist(MWRITEFILE, "M-B", backup_file_void, 0, FALSE);
1303 add_to_sclist(MWRITEFILE, "^T", to_files_void, 0, FALSE);
1304 add_to_sclist(MINSERTFILE, "^T", to_files_void, 0, FALSE);
1305 add_to_sclist(MINSERTFILE, "^X", ext_cmd_void, 0, FALSE);
1306 add_to_sclist(MMAIN, "^Z", do_suspend_void, 0, FALSE);
1307 add_to_sclist(MMAIN, "^L", total_refresh, 0, TRUE);
1308 add_to_sclist(MALL, "^I", do_tab, 0, TRUE);
1309 add_to_sclist(MALL, "^M", do_enter_void, 0, TRUE);
1310 add_to_sclist(MALL, "kenter", do_enter_void, 0, TRUE);
1311 add_to_sclist(MALL, "^D", do_delete, 0, TRUE);
1312 add_to_sclist(MALL, "kdel", do_delete, 0, TRUE);
1313 add_to_sclist(MALL, "^H", do_backspace, 0, TRUE);
1314 add_to_sclist(MALL, "kbsp", do_backspace, 0, TRUE);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001315
1316#ifdef DEBUG
1317 print_sclist();
1318#endif
1319
Chris Allegrettadab017e2002-04-23 10:56:06 +00001320}
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001321
Chris Allegretta5575bfa2014-02-24 10:18:15 +00001322#ifdef ENABLE_COLOR
1323void set_lint_shortcuts(void)
1324{
1325#ifndef DISABLE_SPELLER
1326 replace_scs_for(do_spell, do_linter);
1327#endif
1328}
1329
1330void set_spell_shortcuts(void)
1331{
1332#ifndef DISABLE_SPELLER
1333 replace_scs_for(do_linter, do_spell);
1334#endif
1335}
1336#endif
1337
1338
David Lawrence Ramseye6757b92006-04-19 13:36:56 +00001339/* Free the given shortcut. */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001340void free_shortcutage(shortcut **shortcutage)
1341{
1342 assert(shortcutage != NULL);
David Lawrence Ramsey193b0e52005-06-06 18:41:17 +00001343
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001344 while (*shortcutage != NULL) {
1345 shortcut *ps = *shortcutage;
1346 *shortcutage = (*shortcutage)->next;
1347 free(ps);
1348 }
1349}
1350
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001351const subnfunc *sctofunc(sc *s)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001352{
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001353 subnfunc *f;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001354
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001355 for (f = allfuncs; f != NULL && s->scfunc != f->scfunc; f = f->next)
1356 ;
1357
1358 return f;
1359}
1360
1361#ifndef NANO_TINY
Benno Schulenberg7f873932014-02-25 21:27:22 +00001362/* Now let's come up with a single (hopefully)
1363 * function to get a string for each flag. */
Chris Allegretta5a018f02009-11-29 06:13:22 +00001364const char *flagtostr(int flag)
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001365{
1366 switch (flag) {
1367 case NO_HELP:
1368 return N_("Help mode");
1369 case CONST_UPDATE:
1370 return N_("Constant cursor position display");
1371 case MORE_SPACE:
1372 return N_("Use of one more line for editing");
1373 case SMOOTH_SCROLL:
1374 return N_("Smooth scrolling");
1375 case WHITESPACE_DISPLAY:
1376 return N_("Whitespace display");
1377 case NO_COLOR_SYNTAX:
1378 return N_("Color syntax highlighting");
1379 case SMART_HOME:
1380 return N_("Smart home key");
1381 case AUTOINDENT:
1382 return N_("Auto indent");
1383 case CUT_TO_END:
1384 return N_("Cut to end");
1385 case NO_WRAP:
1386 return N_("Long line wrapping");
1387 case TABS_TO_SPACES:
1388 return N_("Conversion of typed tabs to spaces");
1389 case BACKUP_FILE:
1390 return N_("Backup files");
1391 case MULTIBUFFER:
1392 return N_("Multiple file buffers");
1393 case USE_MOUSE:
1394 return N_("Mouse support");
1395 case NO_CONVERT:
1396 return N_("No conversion from DOS/Mac format");
1397 case SUSPEND:
1398 return N_("Suspension");
Chris Allegretta05417a22009-08-17 07:52:10 +00001399 case SOFTWRAP:
1400 return N_("Soft line wrapping");
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001401 default:
1402 return "?????";
1403 }
1404}
Chris Allegrettae347efb2008-03-09 02:52:40 +00001405#endif /* NANO_TINY */
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001406
1407/* Interpret the string given by the rc file and return a
Benno Schulenberg7f873932014-02-25 21:27:22 +00001408 * shortcut struct, complete with proper value for execute. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001409sc *strtosc(int menu, char *input)
1410{
1411 sc *s;
1412
1413 s = (sc *)nmalloc(sizeof(sc));
1414 s->execute = TRUE; /* overridden as needed below */
1415
Chris Allegrettae347efb2008-03-09 02:52:40 +00001416
1417#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001418 if (!strcasecmp(input, "help"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001419 s->scfunc = do_help_void;
1420 else
Chris Allegrettae347efb2008-03-09 02:52:40 +00001421#endif
1422 if (!strcasecmp(input, "cancel")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001423 s->scfunc = do_cancel;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001424 s->execute = FALSE;
1425 } else if (!strcasecmp(input, "exit"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001426 s->scfunc = do_exit;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001427 else if (!strcasecmp(input, "writeout"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001428 s->scfunc = do_writeout_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001429 else if (!strcasecmp(input, "insert"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001430 s->scfunc = do_insertfile_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001431 else if (!strcasecmp(input, "whereis"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001432 s->scfunc = do_search;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001433 else if (!strcasecmp(input, "up"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001434 s->scfunc = do_up_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001435 else if (!strcasecmp(input, "down"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001436 s->scfunc = do_down_void;
Chris Allegretta17436ce2008-03-11 03:03:53 +00001437 else if (!strcasecmp(input, "pageup")
1438 || !strcasecmp(input, "prevpage"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001439 s->scfunc = do_page_up;
Chris Allegretta17436ce2008-03-11 03:03:53 +00001440 else if (!strcasecmp(input, "pagedown")
1441 || !strcasecmp(input, "nextpage"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001442 s->scfunc = do_page_down;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001443 else if (!strcasecmp(input, "cut"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001444 s->scfunc = do_cut_text_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001445 else if (!strcasecmp(input, "uncut"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001446 s->scfunc = do_uncut_text;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001447 else if (!strcasecmp(input, "curpos") ||
1448 !strcasecmp(input, "cursorpos"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001449 s->scfunc = do_cursorpos_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001450 else if (!strcasecmp(input, "firstline"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001451 s->scfunc = do_first_line;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001452 else if (!strcasecmp(input, "lastline"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001453 s->scfunc = do_last_line;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001454 else if (!strcasecmp(input, "gotoline"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001455 s->scfunc = do_gotolinecolumn_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001456 else if (!strcasecmp(input, "replace"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001457 s->scfunc = do_replace;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001458#ifndef DISABLE_JUSTIFY
Chris Allegrettae347efb2008-03-09 02:52:40 +00001459 else if (!strcasecmp(input, "justify"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001460 s->scfunc = do_justify_void;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001461 else if (!strcasecmp(input, "beginpara"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001462 s->scfunc = do_para_begin_void;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001463 else if (!strcasecmp(input, "endpara"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001464 s->scfunc = do_para_end_void;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001465 else if (!strcasecmp(input, "fulljustify"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001466 s->scfunc = do_full_justify;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001467#endif
1468#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001469 else if (!strcasecmp(input, "mark"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001470 s->scfunc = do_mark;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001471 else if (!strcasecmp(input, "searchagain") ||
1472 !strcasecmp(input, "research"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001473 s->scfunc = do_research;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001474 else if (!strcasecmp(input, "copytext"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001475 s->scfunc = do_copy_text;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001476 else if (!strcasecmp(input, "indent"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001477 s->scfunc = do_indent_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001478 else if (!strcasecmp(input, "unindent"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001479 s->scfunc = do_unindent;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001480 else if (!strcasecmp(input, "scrollup"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001481 s->scfunc = do_scroll_up;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001482 else if (!strcasecmp(input, "scrolldown"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001483 s->scfunc = do_scroll_down;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001484 else if (!strcasecmp(input, "nextword"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001485 s->scfunc = do_next_word_void;
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001486 else if (!strcasecmp(input, "suspend"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001487 s->scfunc = do_suspend_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001488 else if (!strcasecmp(input, "prevword"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001489 s->scfunc = do_prev_word_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001490 else if (!strcasecmp(input, "findbracket"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001491 s->scfunc = do_find_bracket;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001492 else if (!strcasecmp(input, "wordcount"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001493 s->scfunc = do_wordlinechar_count;
Chris Allegretta70859f42008-07-13 01:36:06 +00001494 else if (!strcasecmp(input, "undo"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001495 s->scfunc = do_undo;
Chris Allegretta70859f42008-07-13 01:36:06 +00001496 else if (!strcasecmp(input, "redo"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001497 s->scfunc = do_redo;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001498 else if (!strcasecmp(input, "prevhistory")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001499 s->scfunc = get_history_older_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001500 s->execute = FALSE;
1501 } else if (!strcasecmp(input, "nexthistory")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001502 s->scfunc = get_history_newer_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001503 s->execute = FALSE;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001504 } else if (!strcasecmp(input, "nohelp") ||
1505 !strcasecmp(input, "nohelp")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001506 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001507 s->execute = FALSE;
1508 s->toggle = NO_HELP;
1509 } else if (!strcasecmp(input, "constupdate")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001510 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001511 s->execute = FALSE;
1512 s->toggle = CONST_UPDATE;
1513 } else if (!strcasecmp(input, "morespace")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001514 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001515 s->execute = FALSE;
1516 s->toggle = MORE_SPACE;
1517 } else if (!strcasecmp(input, "smoothscroll")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001518 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001519 s->execute = FALSE;
1520 s->toggle = SMOOTH_SCROLL;
Chris Allegrettad3659f82008-03-16 23:57:14 +00001521 } else if (!strcasecmp(input, "whitespacedisplay")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001522 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001523 s->execute = FALSE;
1524 s->toggle = WHITESPACE_DISPLAY;
1525 } else if (!strcasecmp(input, "nosyntax")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001526 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001527 s->execute = FALSE;
1528 s->toggle = NO_COLOR_SYNTAX;
1529 } else if (!strcasecmp(input, "smarthome")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001530 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001531 s->execute = FALSE;
1532 s->toggle = SMART_HOME;
1533 } else if (!strcasecmp(input, "autoindent")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001534 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001535 s->execute = FALSE;
1536 s->toggle = AUTOINDENT;
1537 } else if (!strcasecmp(input, "cuttoend")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001538 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001539 s->execute = FALSE;
1540 s->toggle = CUT_TO_END;
1541 } else if (!strcasecmp(input, "nowrap")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001542 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001543 s->execute = FALSE;
1544 s->toggle = NO_WRAP;
1545 } else if (!strcasecmp(input, "tabstospaces")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001546 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001547 s->execute = FALSE;
1548 s->toggle = TABS_TO_SPACES;
1549 } else if (!strcasecmp(input, "backupfile")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001550 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001551 s->execute = FALSE;
1552 s->toggle = BACKUP_FILE;
1553 } else if (!strcasecmp(input, "mutlibuffer")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001554 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001555 s->execute = FALSE;
1556 s->toggle = MULTIBUFFER;
1557 } else if (!strcasecmp(input, "mouse")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001558 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001559 s->execute = FALSE;
1560 s->toggle = USE_MOUSE;
1561 } else if (!strcasecmp(input, "noconvert")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001562 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001563 s->execute = FALSE;
1564 s->toggle = NO_CONVERT;
Chris Allegretta0018d8e2008-03-13 08:23:52 +00001565 } else if (!strcasecmp(input, "suspendenable")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001566 s->scfunc = do_toggle_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001567 s->execute = FALSE;
1568 s->toggle = SUSPEND;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001569 }
Chris Allegrettae347efb2008-03-09 02:52:40 +00001570#endif /* NANO_TINY */
1571 else if (!strcasecmp(input, "right") ||
1572 !strcasecmp(input, "forward"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001573 s->scfunc = do_right;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001574 else if (!strcasecmp(input, "left") ||
1575 !strcasecmp(input, "back"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001576 s->scfunc = do_left;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001577 else if (!strcasecmp(input, "up") ||
1578 !strcasecmp(input, "prevline"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001579 s->scfunc = do_up_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001580 else if (!strcasecmp(input, "down") ||
1581 !strcasecmp(input, "nextline"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001582 s->scfunc = do_down_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001583 else if (!strcasecmp(input, "home"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001584 s->scfunc = do_home;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001585 else if (!strcasecmp(input, "end"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001586 s->scfunc = do_end;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001587#ifdef ENABLE_MULTIBUFFER
1588 else if (!strcasecmp(input, "prevbuf"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001589 s->scfunc = switch_to_prev_buffer_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001590 else if (!strcasecmp(input, "nextbuf"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001591 s->scfunc = switch_to_next_buffer_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001592#endif
1593 else if (!strcasecmp(input, "verbatim"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001594 s->scfunc = do_verbatim_input;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001595 else if (!strcasecmp(input, "tab"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001596 s->scfunc = do_tab;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001597 else if (!strcasecmp(input, "enter"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001598 s->scfunc = do_enter_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001599 else if (!strcasecmp(input, "delete"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001600 s->scfunc = do_delete;
Chris Allegrettafa406942008-07-13 16:44:19 +00001601 else if (!strcasecmp(input, "backspace"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001602 s->scfunc = do_backspace;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001603 else if (!strcasecmp(input, "refresh"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001604 s->scfunc = total_refresh;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001605 else if (!strcasecmp(input, "casesens")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001606 s->scfunc = case_sens_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001607 s->execute = FALSE;
1608 } else if (!strcasecmp(input, "regexp") ||
1609 !strcasecmp(input, "regex")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001610 s->scfunc = regexp_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001611 s->execute = FALSE;
1612 } else if (!strcasecmp(input, "dontreplace")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001613 s->scfunc = no_replace_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001614 s->execute = FALSE;
1615 } else if (!strcasecmp(input, "gototext")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001616 s->scfunc = gototext_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001617 s->execute = FALSE;
1618 } else if (!strcasecmp(input, "browser") ||
1619 !strcasecmp(input, "tofiles")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001620 s->scfunc = to_files_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001621 s->execute = FALSE;
1622 } else if (!strcasecmp(input, "dosformat")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001623 s->scfunc = dos_format_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001624 s->execute = FALSE;
1625 } else if (!strcasecmp(input, "macformat")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001626 s->scfunc = mac_format_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001627 s->execute = FALSE;
1628 } else if (!strcasecmp(input, "append")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001629 s->scfunc = append_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001630 s->execute = FALSE;
1631 } else if (!strcasecmp(input, "prepend")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001632 s->scfunc = prepend_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001633 s->execute = FALSE;
1634 } else if (!strcasecmp(input, "backup")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001635 s->scfunc = backup_file_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001636 s->execute = FALSE;
1637#ifdef ENABLE_MULTIBUFFER
1638 } else if (!strcasecmp(input, "newbuffer")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001639 s->scfunc = new_buffer_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001640 s->execute = FALSE;
1641#endif
Chris Allegretta637daa82011-02-07 14:45:56 +00001642#ifndef DISABLE_BROWSER
Chris Allegrettae347efb2008-03-09 02:52:40 +00001643 } else if (!strcasecmp(input, "firstfile")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001644 s->scfunc = do_first_file;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001645 s->execute = FALSE;
1646 } else if (!strcasecmp(input, "lastfile")) {
Chris Allegretta637daa82011-02-07 14:45:56 +00001647 s->scfunc = do_last_file;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001648 s->execute = FALSE;
Chris Allegretta637daa82011-02-07 14:45:56 +00001649#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001650 } else {
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001651 free(s);
1652 return NULL;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001653 }
1654
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001655 return s;
1656
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001657}
1658
Chris Allegrettae347efb2008-03-09 02:52:40 +00001659#ifdef ENABLE_NANORC
Benno Schulenberg7f873932014-02-25 21:27:22 +00001660/* Same thing as above but for the menu. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001661int strtomenu(char *input)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001662{
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001663 if (!strcasecmp(input, "all"))
1664 return MALL;
1665 else if (!strcasecmp(input, "main"))
1666 return MMAIN;
1667 else if (!strcasecmp(input, "search"))
1668 return MWHEREIS;
1669 else if (!strcasecmp(input, "replace"))
1670 return MREPLACE;
1671 else if (!strcasecmp(input, "replace2") ||
1672 !strcasecmp(input, "replacewith"))
1673 return MREPLACE2;
1674 else if (!strcasecmp(input, "gotoline"))
1675 return MGOTOLINE;
1676 else if (!strcasecmp(input, "writeout"))
1677 return MWRITEFILE;
1678 else if (!strcasecmp(input, "insert"))
1679 return MINSERTFILE;
1680 else if (!strcasecmp(input, "externalcmd") ||
1681 !strcasecmp(input, "extcmd"))
1682 return MEXTCMD;
1683 else if (!strcasecmp(input, "help"))
1684 return MHELP;
1685 else if (!strcasecmp(input, "spell"))
1686 return MSPELL;
1687 else if (!strcasecmp(input, "browser"))
1688 return MBROWSER;
1689 else if (!strcasecmp(input, "whereisfile"))
1690 return MWHEREISFILE;
1691 else if (!strcasecmp(input, "gotodir"))
1692 return MGOTODIR;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001693
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001694 return -1;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001695}
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001696#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001697
Chris Allegrettae347efb2008-03-09 02:52:40 +00001698
David Lawrence Ramseye6757b92006-04-19 13:36:56 +00001699#ifdef DEBUG
1700/* This function is used to gracefully return all the memory we've used.
1701 * It should be called just before calling exit(). Practically, the
Chris Allegretta6232d662002-05-12 19:52:15 +00001702 * only effect is to cause a segmentation fault if the various data
1703 * structures got bolloxed earlier. Thus, we don't bother having this
Chris Allegretta6df90f52002-07-19 01:08:59 +00001704 * function unless debugging is turned on. */
Chris Allegretta6df90f52002-07-19 01:08:59 +00001705void thanks_for_all_the_fish(void)
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001706{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001707 delwin(topwin);
1708 delwin(edit);
1709 delwin(bottomwin);
1710
Chris Allegretta7662c862003-01-13 01:35:15 +00001711#ifndef DISABLE_JUSTIFY
1712 if (quotestr != NULL)
1713 free(quotestr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001714#ifdef HAVE_REGEX_H
1715 regfree(&quotereg);
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001716 if (quoteerr != NULL)
1717 free(quoteerr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001718#endif
Chris Allegretta7662c862003-01-13 01:35:15 +00001719#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001720#ifndef NANO_TINY
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +00001721 if (backup_dir != NULL)
1722 free(backup_dir);
1723#endif
Chris Allegretta2598c662002-03-28 01:59:34 +00001724#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001725 if (operating_dir != NULL)
1726 free(operating_dir);
1727 if (full_operating_dir != NULL)
1728 free(full_operating_dir);
1729#endif
1730 if (last_search != NULL)
1731 free(last_search);
1732 if (last_replace != NULL)
1733 free(last_replace);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001734#ifndef DISABLE_SPELLER
1735 if (alt_speller != NULL)
1736 free(alt_speller);
1737#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001738 if (answer != NULL)
1739 free(answer);
1740 if (cutbuffer != NULL)
Chris Allegretta7662c862003-01-13 01:35:15 +00001741 free_filestruct(cutbuffer);
David Lawrence Ramsey93c84052004-11-23 04:08:28 +00001742#ifndef DISABLE_JUSTIFY
1743 if (jusbuffer != NULL)
1744 free_filestruct(jusbuffer);
1745#endif
Chris Allegrettab71cf302009-02-16 23:06:09 +00001746#ifdef DEBUG
David Lawrence Ramsey5d8d0b12005-05-26 05:53:29 +00001747 /* Free the memory associated with each open file buffer. */
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +00001748 if (openfile != NULL)
David Lawrence Ramsey64661ac2005-07-08 19:57:25 +00001749 free_openfilestruct(openfile);
Chris Allegrettab71cf302009-02-16 23:06:09 +00001750#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +00001751#ifdef ENABLE_COLOR
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001752 if (syntaxstr != NULL)
1753 free(syntaxstr);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001754 while (syntaxes != NULL) {
1755 syntaxtype *bill = syntaxes;
1756
1757 free(syntaxes->desc);
1758 while (syntaxes->extensions != NULL) {
1759 exttype *bob = syntaxes->extensions;
1760
1761 syntaxes->extensions = bob->next;
David Lawrence Ramsey2385c1a2005-07-29 21:42:08 +00001762 free(bob->ext_regex);
David Lawrence Ramsey7fc0ada2005-08-29 18:52:06 +00001763 if (bob->ext != NULL) {
1764 regfree(bob->ext);
1765 free(bob->ext);
1766 }
Chris Allegretta6df90f52002-07-19 01:08:59 +00001767 free(bob);
1768 }
1769 while (syntaxes->color != NULL) {
1770 colortype *bob = syntaxes->color;
1771
1772 syntaxes->color = bob->next;
David Lawrence Ramsey2385c1a2005-07-29 21:42:08 +00001773 free(bob->start_regex);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001774 if (bob->start != NULL) {
1775 regfree(bob->start);
1776 free(bob->start);
1777 }
David Lawrence Ramseyd2361f02005-07-14 18:33:51 +00001778 if (bob->end_regex != NULL)
1779 free(bob->end_regex);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001780 if (bob->end != NULL) {
Chris Allegrettace452fb2003-02-03 02:56:44 +00001781 regfree(bob->end);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001782 free(bob->end);
1783 }
Chris Allegretta6df90f52002-07-19 01:08:59 +00001784 free(bob);
1785 }
1786 syntaxes = syntaxes->next;
1787 free(bill);
1788 }
1789#endif /* ENABLE_COLOR */
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001790#ifndef NANO_TINY
David Lawrence Ramsey40e4acf2005-05-26 06:09:07 +00001791 /* Free the search and replace history lists. */
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001792 if (searchage != NULL)
1793 free_filestruct(searchage);
1794 if (replaceage != NULL)
1795 free_filestruct(replaceage);
Chris Allegretta5beed502003-01-05 20:41:21 +00001796#endif
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001797#ifdef ENABLE_NANORC
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001798 if (homedir != NULL)
1799 free(homedir);
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001800#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001801}
Chris Allegretta637daa82011-02-07 14:45:56 +00001802
Chris Allegretta6232d662002-05-12 19:52:15 +00001803#endif /* DEBUG */