blob: 690dfc6bc892f3426d0de2557be429cb628aa574 [file] [log] [blame]
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00001/**************************************************************************
Benno Schulenberg57d17552016-09-03 12:14:08 +02002 * global.c -- This file is part of GNU nano. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00003 * *
Chris Allegretta8a07a962009-12-02 03:36:22 +00004 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
Benno Schulenberg7a9f4a42014-04-30 20:18:26 +00005 * 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
Benno Schulenberg406e5242016-08-29 15:14:18 +02006 * Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
7 * *
Benno Schulenberg514cd9a2016-08-29 17:10:49 +02008 * GNU nano is free software: you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published *
10 * by the Free Software Foundation, either version 3 of the License, *
11 * or (at your option) any later version. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000012 * *
Benno Schulenberg514cd9a2016-08-29 17:10:49 +020013 * GNU nano is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty *
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
16 * See the GNU General Public License for more details. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000017 * *
18 * You should have received a copy of the GNU General Public License *
Benno Schulenberg514cd9a2016-08-29 17:10:49 +020019 * along with this program. If not, see http://www.gnu.org/licenses/. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000020 * *
21 **************************************************************************/
22
Chris Allegrettaa855fa22008-07-12 02:13:22 +000023#include "proto.h"
24
Chris Allegretta79a33bb2008-03-05 07:34:01 +000025#include <ctype.h>
Chris Allegrettaeb643142008-03-12 04:44:14 +000026#include <string.h>
Chris Allegretta79a33bb2008-03-05 07:34:01 +000027#include <strings.h>
28#include "assert.h"
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000029
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +000030/* Global variables. */
31#ifndef NANO_TINY
Benno Schulenbergb77e6bd2016-12-14 20:37:03 +010032volatile sig_atomic_t the_window_resized = FALSE;
33 /* Set to TRUE by the handler whenever a SIGWINCH occurs. */
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +000034#endif
35
Benno Schulenberg08cd1972016-09-08 21:00:51 +020036#ifdef __linux__
Benno Schulenberg290d2782016-07-29 09:15:07 +020037bool console;
38 /* Whether we're running on a Linux VC (TRUE) or under X (FALSE). */
Benno Schulenberg928a24c2016-08-11 12:37:11 +020039#endif
40
Benno Schulenberg7e5324d2014-06-30 18:04:33 +000041bool meta_key;
42 /* Whether the current keystroke is a Meta key. */
Benno Schulenberg382c9d72016-04-24 11:28:28 +020043bool shift_held;
44 /* Whether Shift was being held together with a movement key. */
Benno Schulenberg318ed6b2016-04-12 10:24:57 +020045bool focusing = TRUE;
Benno Schulenberg07e199f2015-03-28 17:01:46 +000046 /* Whether an update of the edit window should center the cursor. */
Benno Schulenbergc8f530a2016-05-19 20:43:08 +020047
Benno Schulenbergeef7d102016-12-20 19:27:41 +010048bool as_an_at = TRUE;
49 /* Whether a 0x0A byte should be shown as a ^@ instead of a ^J. */
50
Faissal Bensefiade95ca62016-10-20 09:44:29 +010051int margin = 0;
52 /* The amount of space reserved at the left for line numbers. */
53int editwincols = -1;
54 /* The number of usable columns in the edit window: COLS - margin. */
Faissal Bensefiade95ca62016-10-20 09:44:29 +010055
Benno Schulenbergc8f530a2016-05-19 20:43:08 +020056message_type lastmessage = HUSH;
57 /* Messages of type HUSH should not overwrite type MILD nor ALERT. */
Benno Schulenberg7e5324d2014-06-30 18:04:33 +000058
Sumedh Pendurkardca4ab52016-12-07 09:43:47 +053059filestruct *pletion_line = NULL;
60 /* The line where the last completion was found, if any. */
Sumedh Pendurkardca4ab52016-12-07 09:43:47 +053061
Benno Schulenbergc6615062016-08-16 10:49:55 +020062int controlleft, controlright, controlup, controldown;
Benno Schulenberg08cd1972016-09-08 21:00:51 +020063#ifndef NANO_TINY
Benno Schulenberg382c9d72016-04-24 11:28:28 +020064int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
65int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
Benno Schulenbergf08d79d2015-11-23 08:52:23 +000066#endif
67
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000068#ifndef DISABLE_WRAPJUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000069ssize_t fill = 0;
70 /* The column where we will wrap lines. */
David Lawrence Ramsey691698a2005-07-24 19:57:51 +000071ssize_t wrap_at = -CHARS_FROM_EOL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000072 /* The position where we will wrap lines. fill is equal to this
73 * if it's greater than zero, and equal to (COLS + this) if it
74 * isn't. */
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000075#endif
76
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000077char *last_search = NULL;
78 /* The last string we searched for. */
Chris Allegretta6df90f52002-07-19 01:08:59 +000079
Benno Schulenberge2556272016-04-30 21:22:16 +020080char *present_path = NULL;
81 /* The current browser directory when trying to do tab completion. */
82
Chris Allegrettaa48507d2009-08-14 03:18:29 +000083unsigned flags[4] = {0, 0, 0, 0};
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000084 /* Our flag containing the states of all global options. */
85WINDOW *topwin;
86 /* The top portion of the window, where we display the version
87 * number of nano, the name of the current file, and whether the
88 * current file has been modified. */
89WINDOW *edit;
David Lawrence Ramseyb159f942006-07-28 17:06:27 +000090 /* The middle portion of the window, i.e. the edit window, where
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000091 * we display the current file we're editing. */
92WINDOW *bottomwin;
93 /* The bottom portion of the window, where we display statusbar
94 * messages, the statusbar prompt, and a list of shortcuts. */
95int editwinrows = 0;
96 /* How many rows does the edit window take up? */
Benno Schulenberg0208ae72017-01-12 17:33:46 +010097int maxlines = 0;
98 /* How many file lines can be shown (due to soft wrapping). */
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +000099
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000100filestruct *cutbuffer = NULL;
101 /* The buffer where we store cut text. */
Chris Allegretta12dc8ca2008-07-31 04:24:04 +0000102filestruct *cutbottom = NULL;
Benno Schulenberg57d17552016-09-03 12:14:08 +0200103 /* The last line in the cutbuffer. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000104partition *filepart = NULL;
Benno Schulenberg57d17552016-09-03 12:14:08 +0200105 /* The "partition" where we store a portion of the current file. */
David Lawrence Ramsey64661ac2005-07-08 19:57:25 +0000106openfilestruct *openfile = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000107 /* The list of all open file buffers. */
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000108
David Lawrence Ramseyd89617f2006-01-06 21:51:10 +0000109#ifndef NANO_TINY
110char *matchbrackets = NULL;
111 /* The opening and closing brackets that can be found by bracket
112 * searches. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000113char *whitespace = NULL;
Benno Schulenberg90798fb2015-08-09 16:05:50 +0000114 /* The characters used when visibly showing tabs and spaces. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000115int whitespace_len[2];
Benno Schulenberg90798fb2015-08-09 16:05:50 +0000116 /* The length in bytes of these characters. */
David Lawrence Ramsey89bb9372004-05-29 16:47:52 +0000117#endif
118
Chris Allegrettae4f940d2002-03-03 22:36:36 +0000119#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000120char *punct = NULL;
121 /* The closing punctuation that can end sentences. */
122char *brackets = NULL;
123 /* The closing brackets that can follow closing punctuation and
124 * can end sentences. */
125char *quotestr = NULL;
126 /* The quoting string. The default value is set in main(). */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000127#ifdef HAVE_REGEX_H
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000128regex_t quotereg;
129 /* The compiled regular expression from the quoting string. */
130int quoterc;
David Lawrence Ramsey88165642006-05-22 18:30:09 +0000131 /* Whether it was compiled successfully. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000132char *quoteerr = NULL;
133 /* The error message, if it didn't. */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000134#else
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000135size_t quotelen;
136 /* The length of the quoting string in bytes. */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000137#endif
Benno Schulenberg57d17552016-09-03 12:14:08 +0200138#endif /* !DISABLE_JUSTIFY */
Chris Allegrettae4f940d2002-03-03 22:36:36 +0000139
Benno Schulenberg6f129922016-06-30 18:02:45 +0200140char *word_chars = NULL;
141 /* Nonalphanumeric characters that also form words. */
142
Chris Allegretta0dc26dc2009-01-24 22:40:41 +0000143bool nodelay_mode = FALSE;
Benno Schulenberg71c9a522014-05-13 20:14:01 +0000144 /* Are we checking for a cancel wile doing something? */
Chris Allegretta0dc26dc2009-01-24 22:40:41 +0000145
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000146char *answer = NULL;
David Lawrence Ramsey6335fb52007-01-01 05:15:32 +0000147 /* The answer string used by the statusbar prompt. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000148
149ssize_t tabsize = -1;
Benno Schulenberg57d17552016-09-03 12:14:08 +0200150 /* The width of a tab in spaces. The default is set in main(). */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000151
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000152#ifndef NANO_TINY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000153char *backup_dir = NULL;
154 /* The directory where we store backup files. */
Chris Allegrettabf88d272013-01-01 03:24:39 +0000155
Chris Allegretta3116d2f2013-01-03 04:36:39 +0000156const char *locking_prefix = ".";
Benno Schulenberg0b6d6f42015-03-27 13:46:50 +0000157 /* Prefix of how to store the vim-style lock file. */
Chris Allegretta3116d2f2013-01-03 04:36:39 +0000158const char *locking_suffix = ".swp";
Benno Schulenberg0b6d6f42015-03-27 13:46:50 +0000159 /* Suffix of the vim-style lock file. */
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000160#endif
Chris Allegrettae1f14522001-09-19 03:19:43 +0000161#ifndef DISABLE_OPERATINGDIR
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000162char *operating_dir = NULL;
163 /* The relative path to the operating directory, which we can't
164 * move outside of. */
165char *full_operating_dir = NULL;
166 /* The full path to it. */
Chris Allegrettae1f14522001-09-19 03:19:43 +0000167#endif
168
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000169#ifndef DISABLE_SPELLER
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000170char *alt_speller = NULL;
171 /* The command to use for the alternate spell checker. */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000172#endif
173
Benno Schulenberg00389922014-04-04 11:59:03 +0000174#ifndef DISABLE_COLOR
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000175syntaxtype *syntaxes = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000176 /* The global list of color syntaxes. */
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000177char *syntaxstr = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000178 /* The color syntax name specified on the command line. */
Chris Allegretta8ce24132001-04-30 11:28:46 +0000179#endif
180
Benno Schulenberg53f4a9f2016-04-25 21:14:18 +0200181bool refresh_needed = FALSE;
182 /* Did a command mangle enough of the buffer that we should
183 * repaint the screen? */
Chris Allegrettafd265af2009-02-06 03:41:02 +0000184
Benno Schulenberg9106cc82016-05-08 12:01:33 +0200185int currmenu = MMOST;
186 /* The currently active menu, initialized to a dummy value. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000187sc *sclist = NULL;
Benno Schulenberg57d17552016-09-03 12:14:08 +0200188 /* The start of the shortcuts list. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000189subnfunc *allfuncs = NULL;
Benno Schulenberg57d17552016-09-03 12:14:08 +0200190 /* The start of the functions list. */
Benno Schulenberg20b1e922014-04-26 18:41:43 +0000191subnfunc *tailfunc;
Benno Schulenberg57d17552016-09-03 12:14:08 +0200192 /* The last function in the list. */
Benno Schulenberg11d76442014-04-26 19:01:18 +0000193subnfunc *exitfunc;
Benno Schulenberg57d17552016-09-03 12:14:08 +0200194 /* A pointer to the special Exit/Close item. */
Benno Schulenbergbc6e9aa2014-04-07 09:02:22 +0000195subnfunc *uncutfunc;
Benno Schulenberg57d17552016-09-03 12:14:08 +0200196 /* A pointer to the special Uncut/Unjustify item. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000197
Benno Schulenbergb341f292014-06-19 20:05:24 +0000198#ifndef DISABLE_HISTORIES
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000199filestruct *search_history = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000200 /* The search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000201filestruct *searchage = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000202 /* The top of the search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000203filestruct *searchbot = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000204 /* The bottom of the search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000205filestruct *replace_history = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000206 /* The replace string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000207filestruct *replaceage = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000208 /* The top of the replace string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000209filestruct *replacebot = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000210 /* The bottom of the replace string history list. */
Benno Schulenbergdeb271d2016-01-12 19:20:40 +0000211poshiststruct *position_history = NULL;
Benno Schulenberg7f873932014-02-25 21:27:22 +0000212 /* The cursor position history list. */
Chris Allegretta5beed502003-01-05 20:41:21 +0000213#endif
214
Chris Allegretta805c26d2000-09-06 13:39:17 +0000215#ifdef HAVE_REGEX_H
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000216regex_t search_regexp;
217 /* The compiled regular expression to use in searches. */
218regmatch_t regmatches[10];
219 /* The match positions for parenthetical subexpressions, 10
220 * maximum, used in regular expression searches. */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000221#endif
Chris Allegretta3533a342002-03-24 23:19:32 +0000222
Benno Schulenbergc9700352014-05-04 08:53:06 +0000223int hilite_attribute = A_REVERSE;
Benno Schulenberg57d17552016-09-03 12:14:08 +0200224 /* The curses attribute we use to highlight something. */
Benno Schulenberg16639942014-05-03 18:24:45 +0000225#ifndef DISABLE_COLOR
226char* specified_color_combo[] = {};
227 /* The color combinations as specified in the rcfile. */
228#endif
Benno Schulenberg960e8482016-07-12 09:35:48 +0200229int interface_color_pair[] = {};
Benno Schulenberg16639942014-05-03 18:24:45 +0000230 /* The processed color pairs for the interface elements. */
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000231
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000232char *homedir = NULL;
David Lawrence Ramseyc1c818e2006-05-14 18:22:01 +0000233 /* The user's home directory, from $HOME or /etc/passwd. */
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000234
Benno Schulenberg57d17552016-09-03 12:14:08 +0200235
Benno Schulenberg7f873932014-02-25 21:27:22 +0000236/* Return the number of entries in the shortcut list for a given menu. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000237size_t length_of_list(int menu)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000238{
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000239 subnfunc *f;
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000240 size_t i = 0;
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000241
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000242 for (f = allfuncs; f != NULL; f = f->next)
Benno Schulenbergaeb49a82016-08-27 12:22:59 +0200243 if ((f->menus & menu) && first_sc_for(menu, f->scfunc) != NULL)
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000244 i++;
Benno Schulenbergaeb49a82016-08-27 12:22:59 +0200245
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000246 return i;
247}
248
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000249/* To make the functions and shortcuts lists clearer. */
250#define VIEW TRUE /* Is allowed in view mode. */
251#define NOVIEW FALSE
252#define BLANKAFTER TRUE /* A blank line after this one. */
253#define TOGETHER FALSE
254
Benno Schulenberg7f873932014-02-25 21:27:22 +0000255/* Just throw this here. */
Chris Allegretta637daa82011-02-07 14:45:56 +0000256void case_sens_void(void)
257{
258}
259void regexp_void(void)
260{
261}
Benno Schulenbergd1238c02014-05-13 20:51:19 +0000262void backwards_void(void)
263{
264}
Chris Allegretta637daa82011-02-07 14:45:56 +0000265void gototext_void(void)
266{
267}
Benno Schulenbergd1238c02014-05-13 20:51:19 +0000268#ifndef DISABLE_BROWSER
Chris Allegretta637daa82011-02-07 14:45:56 +0000269void to_files_void(void)
270{
271}
Benno Schulenbergd1238c02014-05-13 20:51:19 +0000272void goto_dir_void(void)
273{
274}
275#endif
Chris Allegretta637daa82011-02-07 14:45:56 +0000276void dos_format_void(void)
277{
278}
279void mac_format_void(void)
280{
281}
282void append_void(void)
283{
284}
285void prepend_void(void)
286{
287}
288void backup_file_void(void)
289{
290}
Benno Schulenberg8cc63082015-12-23 16:34:44 +0000291void discard_buffer(void)
292{
293}
Chris Allegretta637daa82011-02-07 14:45:56 +0000294void new_buffer_void(void)
295{
296}
Benno Schulenberga0f66c02014-06-23 18:30:35 +0000297void flip_replace_void(void)
Chris Allegretta637daa82011-02-07 14:45:56 +0000298{
299}
Benno Schulenberg04a38da2014-06-04 19:15:16 +0000300void flip_execute_void(void)
Chris Allegretta637daa82011-02-07 14:45:56 +0000301{
302}
303
Benno Schulenberg80750632014-07-27 19:18:00 +0000304/* Add a function to the function list. */
Chris Allegretta637daa82011-02-07 14:45:56 +0000305void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *help,
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000306 bool blank_after, bool viewok)
307{
Benno Schulenberg1eb23d42014-06-04 16:30:11 +0000308 subnfunc *f = (subnfunc *)nmalloc(sizeof(subnfunc));
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000309
Benno Schulenberg20b1e922014-04-26 18:41:43 +0000310 if (allfuncs == NULL)
311 allfuncs = f;
312 else
313 tailfunc->next = f;
314 tailfunc = f;
315
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000316 f->next = NULL;
317 f->scfunc = func;
318 f->menus = menus;
319 f->desc = desc;
320 f->viewok = viewok;
Chris Allegretta1d778232008-08-30 21:00:00 +0000321#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000322 f->help = help;
323 f->blank_after = blank_after;
324#endif
325
326#ifdef DEBUG
Benno Schulenberg5c2b44a2014-04-15 20:01:19 +0000327 fprintf(stderr, "Added func %ld (%s) for menus %x\n", (long)func, f->desc, menus);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000328#endif
329}
330
Benno Schulenbergd23283e2014-07-27 19:13:46 +0000331/* Add a key combo to the shortcut list. */
Benno Schulenberg55878ef2016-10-15 17:55:19 +0200332void add_to_sclist(int menus, const char *scstring, const int keycode,
333 void (*func)(void), int toggle)
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000334{
Benno Schulenbergd23283e2014-07-27 19:13:46 +0000335 static sc *tailsc;
Benno Schulenberg7b7d2bf2016-09-01 09:36:47 +0200336#ifndef NANO_TINY
Benno Schulenberg5ac6a872015-07-06 17:51:17 +0000337 static int counter = 0;
Benno Schulenberg7b7d2bf2016-09-01 09:36:47 +0200338#endif
Benno Schulenbergd23283e2014-07-27 19:13:46 +0000339 sc *s = (sc *)nmalloc(sizeof(sc));
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000340
Benno Schulenbergd23283e2014-07-27 19:13:46 +0000341 /* Start the list, or tack on the next item. */
342 if (sclist == NULL)
343 sclist = s;
344 else
345 tailsc->next = s;
346 tailsc = s;
347 s->next = NULL;
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000348
Benno Schulenbergd23283e2014-07-27 19:13:46 +0000349 /* Fill in the data. */
Benno Schulenberg1f866c22015-07-15 20:13:05 +0000350 s->menus = menus;
Benno Schulenbergd23283e2014-07-27 19:13:46 +0000351 s->scfunc = func;
Benno Schulenberg7b7d2bf2016-09-01 09:36:47 +0200352#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000353 s->toggle = toggle;
Benno Schulenberg5ac6a872015-07-06 17:51:17 +0000354 if (toggle)
355 s->ordinal = ++counter;
Benno Schulenberg7b7d2bf2016-09-01 09:36:47 +0200356#endif
Benno Schulenberg55878ef2016-10-15 17:55:19 +0200357 assign_keyinfo(s, scstring, keycode);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000358
359#ifdef DEBUG
Benno Schulenberg1c9ab8b2016-07-24 21:49:07 +0200360 fprintf(stderr, "Setting keycode to %d for shortcut \"%s\" in menus %x\n", s->keycode, scstring, s->menus);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000361#endif
362}
363
Benno Schulenberg74541032014-05-13 20:20:51 +0000364/* Assign one function's shortcuts to another function. */
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000365void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void))
366{
367 sc *s;
368
Benno Schulenberg74541032014-05-13 20:20:51 +0000369 for (s = sclist; s != NULL; s = s->next)
Benno Schulenberg492e9f62014-06-20 10:48:26 +0000370 if (s->scfunc == oldfunc)
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000371 s->scfunc = newfunc;
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000372}
373
Benno Schulenbergdbb5e7c2014-07-27 19:23:41 +0000374/* Return the first shortcut in the list of shortcuts that
375 * matches the given func in the given menu. */
376const sc *first_sc_for(int menu, void (*func)(void))
377{
378 const sc *s;
379
380 for (s = sclist; s != NULL; s = s->next)
Benno Schulenberg1f866c22015-07-15 20:13:05 +0000381 if ((s->menus & menu) && s->scfunc == func)
Benno Schulenbergdbb5e7c2014-07-27 19:23:41 +0000382 return s;
383
384#ifdef DEBUG
385 fprintf(stderr, "Whoops, returning null given func %ld in menu %x\n", (long)func, menu);
386#endif
387 /* Otherwise... */
388 return NULL;
389}
390
Benno Schulenberga9b5a0e2016-12-22 12:02:11 +0100391/* Return the first keycode that is bound to the given function in the
392 * current menu, if any; otherwise, return the given default value. */
393int the_code_for(void (*func)(void), int defaultval)
Chris Allegrettae347efb2008-03-09 02:52:40 +0000394{
395 const sc *s = first_sc_for(currmenu, func);
396
Benno Schulenberga9b5a0e2016-12-22 12:02:11 +0100397 if (s == NULL)
398 return defaultval;
399
400 meta_key = s->meta;
401 return s->keycode;
Chris Allegrettae347efb2008-03-09 02:52:40 +0000402}
403
Benno Schulenberg3933a302014-07-02 08:47:09 +0000404/* Return a pointer to the function that is bound to the given key. */
405functionptrtype func_from_key(int *kbinput)
406{
407 const sc *s = get_shortcut(kbinput);
408
409 if (s)
410 return s->scfunc;
411 else
412 return NULL;
413}
414
Benno Schulenberge2950702016-07-23 14:42:40 +0200415/* Set the string and its corresponding keycode for the given shortcut s. */
Benno Schulenberg55878ef2016-10-15 17:55:19 +0200416void assign_keyinfo(sc *s, const char *keystring, const int keycode)
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000417{
Benno Schulenberg3930a692016-07-30 12:44:23 +0200418 s->keystr = keystring;
Benno Schulenberge2950702016-07-23 14:42:40 +0200419 s->meta = (keystring[0] == 'M');
Benno Schulenberg5b0ab8b2016-07-23 12:15:39 +0200420
Benno Schulenberg1c528db2016-07-25 09:33:43 +0200421 assert(strlen(keystring) > 1 && (!s->meta || strlen(keystring) > 2));
Chris Allegretta9b422202008-03-05 17:15:33 +0000422
Benno Schulenberg55878ef2016-10-15 17:55:19 +0200423 if (keycode)
424 s->keycode = keycode;
425 else if (keystring[0] == '^') {
Benno Schulenberg9322e1e2016-07-25 10:30:41 +0200426 if (strcasecmp(keystring, "^Space") == 0)
427 s->keycode = 0;
Benno Schulenbergfdee0df2016-10-11 10:50:04 +0200428 else
429 s->keycode = keystring[1] - 64;
Benno Schulenberg9322e1e2016-07-25 10:30:41 +0200430 } else if (s->meta) {
Benno Schulenberg9322e1e2016-07-25 10:30:41 +0200431 if (strcasecmp(keystring, "M-Space") == 0)
432 s->keycode = (int)' ';
Benno Schulenberg55878ef2016-10-15 17:55:19 +0200433 else
434 s->keycode = tolower((int)keystring[2]);
Benno Schulenberg9322e1e2016-07-25 10:30:41 +0200435 } else if (keystring[0] == 'F')
Benno Schulenberg3930a692016-07-30 12:44:23 +0200436 s->keycode = KEY_F0 + atoi(&keystring[1]);
Benno Schulenberg3930a692016-07-30 12:44:23 +0200437 else if (!strcasecmp(keystring, "Ins"))
Benno Schulenbergb70fe382016-07-25 10:27:02 +0200438 s->keycode = KEY_IC;
Benno Schulenberg3930a692016-07-30 12:44:23 +0200439 else if (!strcasecmp(keystring, "Del"))
Benno Schulenbergb70fe382016-07-25 10:27:02 +0200440 s->keycode = KEY_DC;
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000441}
442
443#ifdef DEBUG
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000444void print_sclist(void)
445{
446 sc *s;
447 const subnfunc *f;
448
Benno Schulenberga85b6da2014-03-26 10:57:11 +0000449 for (s = sclist; s != NULL; s = s->next) {
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000450 f = sctofunc(s);
Benno Schulenberga85b6da2014-03-26 10:57:11 +0000451 if (f)
Benno Schulenberg70d21672014-03-26 10:53:10 +0000452 fprintf(stderr, "Shortcut \"%s\", function: %s, menus %x\n", s->keystr, f->desc, f->menus);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000453 else
Benno Schulenbergd0dec312014-04-08 12:35:18 +0000454 fprintf(stderr, "Hmm, didn't find a func for \"%s\"\n", s->keystr);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000455 }
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000456}
457#endif
458
Benno Schulenbergb7f7df92015-07-30 19:51:08 +0000459/* These four tags are used elsewhere too, so they are global. */
460/* TRANSLATORS: Try to keep the next fifteen strings at most 10 characters. */
Benno Schulenberg11d76442014-04-26 19:01:18 +0000461const char *exit_tag = N_("Exit");
462const char *close_tag = N_("Close");
Benno Schulenbergbc6e9aa2014-04-07 09:02:22 +0000463const char *uncut_tag = N_("Uncut Text");
Benno Schulenberga3a69ee2016-01-17 16:25:31 +0000464#ifndef DISABLE_JUSTIFY
Benno Schulenbergbc6e9aa2014-04-07 09:02:22 +0000465const char *unjust_tag = N_("Unjustify");
466#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000467
Benno Schulenberga2dcd6e2014-04-07 09:24:10 +0000468/* Initialize the list of functions and the list of shortcuts. */
469void shortcut_init(void)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000470{
Benno Schulenbergb7f7df92015-07-30 19:51:08 +0000471 const char *read_file_tag = N_("Read File");
Benno Schulenberg9fc713b2014-04-22 10:18:48 +0000472 const char *whereis_tag = N_("Where Is");
Benno Schulenberg61758e92014-04-27 14:21:57 +0000473 const char *replace_tag = N_("Replace");
474 const char *gotoline_tag = N_("Go To Line");
Benno Schulenberg12da94c2014-04-22 10:02:55 +0000475 const char *prev_line_tag = N_("Prev Line");
476 const char *next_line_tag = N_("Next Line");
Benno Schulenbergcc65a422015-04-17 10:06:03 +0000477 const char *prev_page_tag = N_("Prev Page");
478 const char *next_page_tag = N_("Next Page");
Benno Schulenberg5f655da2014-04-27 15:26:25 +0000479#ifndef DISABLE_JUSTIFY
Benno Schulenbergb7f7df92015-07-30 19:51:08 +0000480 const char *justify_tag = N_("Justify");
Benno Schulenberg61758e92014-04-27 14:21:57 +0000481 const char *fulljustify_tag = N_("FullJstify");
Benno Schulenberg5f655da2014-04-27 15:26:25 +0000482#endif
Benno Schulenberg9fc713b2014-04-22 10:18:48 +0000483 const char *refresh_tag = N_("Refresh");
Benno Schulenbergb7f7df92015-07-30 19:51:08 +0000484 /* TRANSLATORS: Try to keep this string at most 12 characters. */
485 const char *whereis_next_tag = N_("WhereIs Next");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000486
Benno Schulenberg8c5f5042014-05-28 20:31:06 +0000487#ifndef DISABLE_HELP
Chris Allegretta1d778232008-08-30 21:00:00 +0000488#ifndef DISABLE_JUSTIFY
Benno Schulenberg7f873932014-02-25 21:27:22 +0000489 /* TRANSLATORS: The next long series of strings are shortcut descriptions;
490 * they are best kept shorter than 56 characters, but may be longer. */
Chris Allegretta1d778232008-08-30 21:00:00 +0000491 const char *nano_justify_msg = N_("Justify the current paragraph");
492#endif
David Lawrence Ramsey804e1072006-03-29 19:43:32 +0000493 const char *nano_cancel_msg = N_("Cancel the current function");
David Lawrence Ramsey57c9afb2006-04-14 20:21:45 +0000494 const char *nano_help_msg = N_("Display this help text");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000495 const char *nano_exit_msg =
Benno Schulenberg0636d7b2014-04-03 20:23:07 +0000496#ifndef DISABLE_MULTIBUFFER
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000497 N_("Close the current file buffer / Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000498#else
Benno Schulenberga65ef422014-03-17 21:36:37 +0000499 N_("Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000500#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000501 ;
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000502 const char *nano_writeout_msg =
503 N_("Write the current file to disk");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000504 const char *nano_insert_msg =
505 N_("Insert another file into the current one");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000506 const char *nano_whereis_msg =
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000507 N_("Search for a string or a regular expression");
Benno Schulenbergd1238c02014-05-13 20:51:19 +0000508#ifndef DISABLE_BROWSER
Benno Schulenberge21e9542016-05-02 09:34:23 +0200509 const char *nano_browser_whereis_msg = N_("Search for a string");
510 const char *nano_browser_refresh_msg = N_("Refresh the file list");
Benno Schulenberg36df5ce2016-05-12 10:10:04 +0200511 const char *nano_browser_lefthand_msg = N_("Go to lefthand column");
512 const char *nano_browser_righthand_msg = N_("Go to righthand column");
Benno Schulenbergd1238c02014-05-13 20:51:19 +0000513#endif
Benno Schulenberg63716122014-04-27 19:51:03 +0000514 const char *nano_prevpage_msg = N_("Go one screenful up");
515 const char *nano_nextpage_msg = N_("Go one screenful down");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000516 const char *nano_cut_msg =
517 N_("Cut the current line and store it in the cutbuffer");
518 const char *nano_uncut_msg =
519 N_("Uncut from the cutbuffer into the current line");
Benno Schulenberg022d32a2014-05-26 10:07:00 +0000520 const char *nano_cursorpos_msg = N_("Display the position of the cursor");
Benno Schulenbergb8b29ff2014-04-03 21:06:30 +0000521#ifndef DISABLE_SPELLER
Benno Schulenberg022d32a2014-05-26 10:07:00 +0000522 const char *nano_spell_msg = N_("Invoke the spell checker, if available");
Benno Schulenbergb8b29ff2014-04-03 21:06:30 +0000523#endif
Benno Schulenberg022d32a2014-05-26 10:07:00 +0000524 const char *nano_replace_msg = N_("Replace a string or a regular expression");
Benno Schulenbergf803ef52014-04-13 12:16:37 +0000525 const char *nano_gotoline_msg = N_("Go to line and column number");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000526#ifndef NANO_TINY
Benno Schulenberg4da24342014-04-27 15:20:57 +0000527 const char *nano_mark_msg = N_("Mark text starting from the cursor position");
528 const char *nano_whereis_next_msg = N_("Repeat the last search");
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000529 const char *nano_copy_msg =
530 N_("Copy the current line and store it in the cutbuffer");
David Lawrence Ramseyaee00d42006-07-05 18:42:22 +0000531 const char *nano_indent_msg = N_("Indent the current line");
532 const char *nano_unindent_msg = N_("Unindent the current line");
Chris Allegretta07fcc4c2008-07-10 20:13:04 +0000533 const char *nano_undo_msg = N_("Undo the last operation");
534 const char *nano_redo_msg = N_("Redo the last undone operation");
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000535#endif
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000536 const char *nano_back_msg = N_("Go back one character");
Benno Schulenberg5a5144b2016-02-05 12:01:02 +0000537 const char *nano_forward_msg = N_("Go forward one character");
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000538 const char *nano_prevword_msg = N_("Go back one word");
Benno Schulenberg5a5144b2016-02-05 12:01:02 +0000539 const char *nano_nextword_msg = N_("Go forward one word");
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000540 const char *nano_prevline_msg = N_("Go to previous line");
541 const char *nano_nextline_msg = N_("Go to next line");
542 const char *nano_home_msg = N_("Go to beginning of current line");
543 const char *nano_end_msg = N_("Go to end of current line");
Benno Schulenbergc6dbcf92016-06-25 15:16:52 +0200544 const char *nano_prevblock_msg = N_("Go to previous block of text");
545 const char *nano_nextblock_msg = N_("Go to next block of text");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000546#ifndef DISABLE_JUSTIFY
547 const char *nano_parabegin_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000548 N_("Go to beginning of paragraph; then of previous paragraph");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000549 const char *nano_paraend_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000550 N_("Go just beyond end of paragraph; then of next paragraph");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000551#endif
Benno Schulenberg022d32a2014-05-26 10:07:00 +0000552 const char *nano_firstline_msg = N_("Go to the first line of the file");
553 const char *nano_lastline_msg = N_("Go to the last line of the file");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000554#ifndef NANO_TINY
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000555 const char *nano_bracket_msg = N_("Go to the matching bracket");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000556 const char *nano_scrollup_msg =
557 N_("Scroll up one line without scrolling the cursor");
558 const char *nano_scrolldown_msg =
559 N_("Scroll down one line without scrolling the cursor");
560#endif
Benno Schulenberg0636d7b2014-04-03 20:23:07 +0000561#ifndef DISABLE_MULTIBUFFER
Benno Schulenberg022d32a2014-05-26 10:07:00 +0000562 const char *nano_prevfile_msg = N_("Switch to the previous file buffer");
563 const char *nano_nextfile_msg = N_("Switch to the next file buffer");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000564#endif
Benno Schulenberg022d32a2014-05-26 10:07:00 +0000565 const char *nano_verbatim_msg = N_("Insert the next keystroke verbatim");
566 const char *nano_tab_msg = N_("Insert a tab at the cursor position");
567 const char *nano_enter_msg = N_("Insert a newline at the cursor position");
568 const char *nano_delete_msg = N_("Delete the character under the cursor");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000569 const char *nano_backspace_msg =
570 N_("Delete the character to the left of the cursor");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000571#ifndef NANO_TINY
Benno Schulenbergb3e40512015-07-31 11:52:26 +0000572 const char *nano_cut_word_left_msg =
573 N_("Cut backward from cursor to word start");
574 const char *nano_cut_word_right_msg =
575 N_("Cut forward from cursor to next word start");
Benno Schulenberg95e77a92014-06-30 20:39:27 +0000576 const char *nano_cut_till_eof_msg =
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000577 N_("Cut from the cursor position to the end of the file");
578#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000579#ifndef DISABLE_JUSTIFY
580 const char *nano_fulljustify_msg = N_("Justify the entire file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000581#endif
David Lawrence Ramseyc5c52302005-11-15 23:45:29 +0000582#ifndef NANO_TINY
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000583 const char *nano_wordcount_msg =
584 N_("Count the number of words, lines, and characters");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000585#endif
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000586 const char *nano_refresh_msg =
587 N_("Refresh (redraw) the current screen");
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000588 const char *nano_suspend_msg =
Benno Schulenbergf7e88612015-07-26 09:29:42 +0000589 N_("Suspend the editor (if suspension is enabled)");
Benno Schulenberg68a03142016-12-07 13:10:40 +0100590#ifdef ENABLE_WORDCOMPLETION
591 const char *nano_completion_msg = N_("Try and complete the current word");
592#endif
Benno Schulenberg964c10d2016-12-07 19:56:27 +0100593#ifdef ENABLE_COMMENT
594 const char *nano_comment_msg =
595 N_("Comment/uncomment the current line or marked lines");
596#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000597#ifndef NANO_TINY
Benno Schulenbergee7b0952015-07-25 19:25:50 +0000598 const char *nano_savefile_msg = N_("Save file without prompting");
Benno Schulenberg4990f742015-07-26 09:23:24 +0000599 const char *nano_findprev_msg = N_("Search next occurrence backward");
600 const char *nano_findnext_msg = N_("Search next occurrence forward");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000601 const char *nano_case_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000602 N_("Toggle the case sensitivity of the search");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000603 const char *nano_reverse_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000604 N_("Reverse the direction of the search");
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000605#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000606#ifdef HAVE_REGEX_H
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000607 const char *nano_regexp_msg =
608 N_("Toggle the use of regular expressions");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000609#endif
Benno Schulenbergb341f292014-06-19 20:05:24 +0000610#ifndef DISABLE_HISTORIES
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000611 const char *nano_prev_history_msg =
David Lawrence Ramsey7b0531a2006-07-31 01:30:31 +0000612 N_("Recall the previous search/replace string");
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000613 const char *nano_next_history_msg =
David Lawrence Ramsey7b0531a2006-07-31 01:30:31 +0000614 N_("Recall the next search/replace string");
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000615#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000616#ifndef DISABLE_BROWSER
617 const char *nano_tofiles_msg = N_("Go to file browser");
618#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000619#ifndef NANO_TINY
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000620 const char *nano_dos_msg = N_("Toggle the use of DOS format");
621 const char *nano_mac_msg = N_("Toggle the use of Mac format");
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000622 const char *nano_append_msg = N_("Toggle appending");
623 const char *nano_prepend_msg = N_("Toggle prepending");
Benno Schulenberg022d32a2014-05-26 10:07:00 +0000624 const char *nano_backup_msg = N_("Toggle backing up of the original file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000625 const char *nano_execute_msg = N_("Execute external command");
626#endif
Benno Schulenberg8cc63082015-12-23 16:34:44 +0000627 const char *nano_discard_buffer_msg = N_("Close buffer without saving it");
Benno Schulenberg0636d7b2014-04-03 20:23:07 +0000628#ifndef DISABLE_MULTIBUFFER
Benno Schulenberg022d32a2014-05-26 10:07:00 +0000629 const char *nano_multibuffer_msg = N_("Toggle the use of a new buffer");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000630#endif
631#ifndef DISABLE_BROWSER
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000632 const char *nano_exitbrowser_msg = N_("Exit from the file browser");
Benno Schulenberg022d32a2014-05-26 10:07:00 +0000633 const char *nano_firstfile_msg = N_("Go to the first file in the list");
634 const char *nano_lastfile_msg = N_("Go to the last file in the list");
Chris Allegretta8d41fb82009-12-23 05:03:09 +0000635 const char *nano_backfile_msg = N_("Go to the previous file in the list");
Benno Schulenberg022d32a2014-05-26 10:07:00 +0000636 const char *nano_forwardfile_msg = N_("Go to the next file in the list");
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000637 const char *nano_gotodir_msg = N_("Go to directory");
Chris Allegretta2bef1822001-09-28 19:53:11 +0000638#endif
Benno Schulenberg00389922014-04-04 11:59:03 +0000639#ifndef DISABLE_COLOR
Benno Schulenberg91ee10a2014-03-27 21:35:18 +0000640 const char *nano_lint_msg = N_("Invoke the linter, if available");
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000641 const char *nano_prevlint_msg = N_("Go to previous linter msg");
642 const char *nano_nextlint_msg = N_("Go to next linter msg");
Benno Schulenberg14a9c8a2015-03-27 16:55:49 +0000643#ifndef DISABLE_SPELLER
Chris Allegretta4b3f2772015-01-03 07:24:17 +0000644 const char *nano_formatter_msg = N_("Invoke formatter, if available");
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000645#endif
Benno Schulenberg14a9c8a2015-03-27 16:55:49 +0000646#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000647#endif /* !DISABLE_HELP */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000648
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000649#ifndef DISABLE_HELP
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000650#define IFSCHELP(help) help
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000651#else
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000652#define IFSCHELP(help) ""
Chris Allegrettadab017e2002-04-23 10:56:06 +0000653#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000654
Benno Schulenbergf803ef52014-04-13 12:16:37 +0000655 /* Start populating the different menus with functions. */
656
Benno Schulenbergf6a3ab02014-04-16 09:55:16 +0000657 add_to_funcs(do_help_void, MMOST,
Benno Schulenbergc8b60ce2014-04-22 11:57:11 +0000658 /* TRANSLATORS: Try to keep the following strings at most 10 characters. */
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000659 N_("Get Help"), IFSCHELP(nano_help_msg), TOGETHER, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000660
Benno Schulenbergf6a3ab02014-04-16 09:55:16 +0000661 add_to_funcs(do_cancel, ((MMOST & ~MMAIN & ~MBROWSER) | MYESNO),
Benno Schulenberg338807a2016-05-05 13:27:07 +0200662 N_("Cancel"), IFSCHELP(nano_cancel_msg), BLANKAFTER, VIEW);
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000663
Chris Allegretta637daa82011-02-07 14:45:56 +0000664 add_to_funcs(do_exit, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000665 exit_tag, IFSCHELP(nano_exit_msg), TOGETHER, VIEW);
Benno Schulenberg11d76442014-04-26 19:01:18 +0000666 /* Remember the entry for Exit, to be able to replace it with Close. */
667 exitfunc = tailfunc;
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000668
Chris Allegrettadcd19c92008-03-20 04:51:26 +0000669#ifndef DISABLE_BROWSER
Benno Schulenbergf470c902014-05-28 21:02:39 +0000670 add_to_funcs(do_exit, MBROWSER,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000671 exit_tag, IFSCHELP(nano_exitbrowser_msg), TOGETHER, VIEW);
Chris Allegrettadcd19c92008-03-20 04:51:26 +0000672#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000673
Benno Schulenbergf470c902014-05-28 21:02:39 +0000674 add_to_funcs(do_writeout_void, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000675 N_("Write Out"), IFSCHELP(nano_writeout_msg), TOGETHER, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000676
Benno Schulenberg2ee18d62015-07-30 10:37:28 +0000677#ifndef DISABLE_JUSTIFY
678 if (!ISSET(RESTRICTED)) {
679#else
680 /* If we can't replace Insert with Justify, show Insert anyway, to
681 * keep the help items nicely paired also in restricted mode. */
682 if (TRUE) {
683#endif
Benno Schulenberg104ea6b2015-07-30 11:29:45 +0000684 add_to_funcs(do_insertfile_void, MMAIN,
685 read_file_tag, IFSCHELP(nano_insert_msg), BLANKAFTER,
Benno Schulenberg2ee18d62015-07-30 10:37:28 +0000686 /* We allow inserting files in view mode if multibuffer mode
687 * is switched on, so that we can view multiple files. */
Benno Schulenberg0636d7b2014-04-03 20:23:07 +0000688#ifndef DISABLE_MULTIBUFFER
Benno Schulenberg104ea6b2015-07-30 11:29:45 +0000689 VIEW);
Chris Allegretta32da4562002-01-02 15:12:21 +0000690#else
Benno Schulenberg104ea6b2015-07-30 11:29:45 +0000691 NOVIEW);
Chris Allegretta32da4562002-01-02 15:12:21 +0000692#endif
Benno Schulenberg2ee18d62015-07-30 10:37:28 +0000693 } else {
694#ifndef DISABLE_JUSTIFY
Benno Schulenberg104ea6b2015-07-30 11:29:45 +0000695 add_to_funcs(do_justify_void, MMAIN,
Benno Schulenbergb7f7df92015-07-30 19:51:08 +0000696 justify_tag, IFSCHELP(nano_justify_msg), BLANKAFTER, NOVIEW);
Benno Schulenberg2ee18d62015-07-30 10:37:28 +0000697#endif
698 }
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000699
Benno Schulenbergf470c902014-05-28 21:02:39 +0000700 add_to_funcs(do_search, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000701 whereis_tag, IFSCHELP(nano_whereis_msg), TOGETHER, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000702
Benno Schulenbergf470c902014-05-28 21:02:39 +0000703 add_to_funcs(do_replace, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000704 replace_tag, IFSCHELP(nano_replace_msg), TOGETHER, NOVIEW);
Benno Schulenberg63716122014-04-27 19:51:03 +0000705
706#ifndef DISABLE_BROWSER
Benno Schulenbergf470c902014-05-28 21:02:39 +0000707 add_to_funcs(do_search, MBROWSER,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000708 whereis_tag, IFSCHELP(nano_browser_whereis_msg), TOGETHER, VIEW);
Benno Schulenberg960a1202014-03-18 22:04:41 +0000709
Benno Schulenberg63716122014-04-27 19:51:03 +0000710 add_to_funcs(goto_dir_void, MBROWSER,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000711 N_("Go To Dir"), IFSCHELP(nano_gotodir_msg), BLANKAFTER, VIEW);
Benno Schulenbergcae7aea2014-02-26 20:37:40 +0000712#endif
713
Benno Schulenberg5c2b44a2014-04-15 20:01:19 +0000714#ifndef DISABLE_HELP
Benno Schulenberg12da94c2014-04-22 10:02:55 +0000715 /* The description ("x") and blank_after (0) are irrelevant,
716 * because the help viewer does not have a help text. */
Benno Schulenberg9fc713b2014-04-22 10:18:48 +0000717 add_to_funcs(do_exit, MHELP, exit_tag, "x", 0, VIEW);
Benno Schulenberg5c2b44a2014-04-15 20:01:19 +0000718
Benno Schulenberg9fc713b2014-04-22 10:18:48 +0000719 add_to_funcs(total_refresh, MHELP, refresh_tag, "x", 0, VIEW);
Benno Schulenberg12da94c2014-04-22 10:02:55 +0000720
721 add_to_funcs(do_up_void, MHELP, prev_line_tag, "x", 0, VIEW);
722 add_to_funcs(do_down_void, MHELP, next_line_tag, "x" , 0, VIEW);
Benno Schulenberg5c2b44a2014-04-15 20:01:19 +0000723#endif
724
Benno Schulenbergf470c902014-05-28 21:02:39 +0000725 add_to_funcs(do_cut_text_void, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000726 N_("Cut Text"), IFSCHELP(nano_cut_msg), TOGETHER, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000727
Benno Schulenbergf470c902014-05-28 21:02:39 +0000728 add_to_funcs(do_uncut_text, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000729 uncut_tag, IFSCHELP(nano_uncut_msg), BLANKAFTER, NOVIEW);
Benno Schulenbergbc6e9aa2014-04-07 09:02:22 +0000730 /* Remember the entry for Uncut, to be able to replace it with Unjustify. */
Benno Schulenberg20b1e922014-04-26 18:41:43 +0000731 uncutfunc = tailfunc;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000732
Benno Schulenberg104ea6b2015-07-30 11:29:45 +0000733 if (!ISSET(RESTRICTED)) {
Benno Schulenberg63716122014-04-27 19:51:03 +0000734#ifndef DISABLE_JUSTIFY
Benno Schulenberg104ea6b2015-07-30 11:29:45 +0000735 add_to_funcs(do_justify_void, MMAIN,
Benno Schulenbergb7f7df92015-07-30 19:51:08 +0000736 justify_tag, IFSCHELP(nano_justify_msg), TOGETHER, NOVIEW);
Chris Allegrettae347efb2008-03-09 02:52:40 +0000737#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000738
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000739#ifndef DISABLE_SPELLER
Benno Schulenberg104ea6b2015-07-30 11:29:45 +0000740 add_to_funcs(do_spell, MMAIN,
741 N_("To Spell"), IFSCHELP(nano_spell_msg), TOGETHER, NOVIEW);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000742#endif
Benno Schulenberg00389922014-04-04 11:59:03 +0000743#ifndef DISABLE_COLOR
Benno Schulenberg104ea6b2015-07-30 11:29:45 +0000744 add_to_funcs(do_linter, MMAIN,
745 N_("To Linter"), IFSCHELP(nano_lint_msg), TOGETHER, NOVIEW);
Benno Schulenberg14a9c8a2015-03-27 16:55:49 +0000746#ifndef DISABLE_SPELLER
Benno Schulenberg104ea6b2015-07-30 11:29:45 +0000747 add_to_funcs(do_formatter, MMAIN,
748 N_("Formatter"), IFSCHELP(nano_formatter_msg), BLANKAFTER, NOVIEW);
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000749#endif
Benno Schulenberg14a9c8a2015-03-27 16:55:49 +0000750#endif
Benno Schulenberg104ea6b2015-07-30 11:29:45 +0000751 }
Chris Allegretta5575bfa2014-02-24 10:18:15 +0000752
Benno Schulenbergfd6308d2016-09-03 13:41:02 +0200753 add_to_funcs(do_cursorpos_void, MMAIN,
754 N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg), TOGETHER, VIEW);
755
756#if (!defined(DISABLE_JUSTIFY) && (!defined(DISABLE_SPELLER) || !defined(DISABLE_COLOR)) || \
757 defined(DISABLE_JUSTIFY) && defined(DISABLE_SPELLER) && defined(DISABLE_COLOR))
758 /* Conditionally placing this one here or further on, to keep the
759 * help items nicely paired in most conditions. */
760 add_to_funcs(do_gotolinecolumn_void, MMAIN,
761 gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
762#endif
763
Benno Schulenbergb0957252014-07-01 16:24:01 +0000764 add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000765 N_("Case Sens"), IFSCHELP(nano_case_msg), TOGETHER, VIEW);
Benno Schulenberg61758e92014-04-27 14:21:57 +0000766#ifdef HAVE_REGEX_H
Benno Schulenbergb0957252014-07-01 16:24:01 +0000767 add_to_funcs(regexp_void, MWHEREIS|MREPLACE,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000768 N_("Regexp"), IFSCHELP(nano_regexp_msg), TOGETHER, VIEW);
Benno Schulenberg61758e92014-04-27 14:21:57 +0000769#endif
Benno Schulenbergb0957252014-07-01 16:24:01 +0000770 add_to_funcs(backwards_void, MWHEREIS|MREPLACE,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000771 N_("Backwards"), IFSCHELP(nano_reverse_msg), TOGETHER, VIEW);
Benno Schulenberg61758e92014-04-27 14:21:57 +0000772
Benno Schulenberga0f66c02014-06-23 18:30:35 +0000773 add_to_funcs(flip_replace_void, MWHEREIS,
Benno Schulenberg3d829862016-05-16 16:55:11 +0200774 replace_tag, IFSCHELP(nano_replace_msg), BLANKAFTER, VIEW);
Benno Schulenberg61758e92014-04-27 14:21:57 +0000775
Benno Schulenberga0f66c02014-06-23 18:30:35 +0000776 add_to_funcs(flip_replace_void, MREPLACE,
Benno Schulenberg3d829862016-05-16 16:55:11 +0200777 N_("No Replace"), IFSCHELP(nano_whereis_msg), BLANKAFTER, VIEW);
Benno Schulenberg61758e92014-04-27 14:21:57 +0000778
779#ifndef DISABLE_JUSTIFY
Benno Schulenbergf470c902014-05-28 21:02:39 +0000780 add_to_funcs(do_full_justify, MWHEREIS,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000781 fulljustify_tag, IFSCHELP(nano_fulljustify_msg), TOGETHER, NOVIEW);
Benno Schulenberg61758e92014-04-27 14:21:57 +0000782
Benno Schulenberg1dbebbc2016-09-03 13:32:49 +0200783 add_to_funcs(do_gotolinecolumn_void, MWHEREIS,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000784 gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
Benno Schulenberg0d5e7322014-05-27 12:17:49 +0000785#endif
Benno Schulenberg63716122014-04-27 19:51:03 +0000786
Benno Schulenbergcc65a422015-04-17 10:06:03 +0000787 add_to_funcs(do_page_up, MMAIN|MHELP,
788 prev_page_tag, IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
789 add_to_funcs(do_page_down, MMAIN|MHELP,
790 next_page_tag, IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
Benno Schulenberg61758e92014-04-27 14:21:57 +0000791
Benno Schulenbergf470c902014-05-28 21:02:39 +0000792 add_to_funcs(do_first_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000793 N_("First Line"), IFSCHELP(nano_firstline_msg), TOGETHER, VIEW);
Benno Schulenbergf470c902014-05-28 21:02:39 +0000794 add_to_funcs(do_last_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000795 N_("Last Line"), IFSCHELP(nano_lastline_msg), BLANKAFTER, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000796
Benno Schulenbergbc8bb7e2016-09-12 12:49:46 +0200797#ifndef NANO_TINY
Benno Schulenbergf470c902014-05-28 21:02:39 +0000798 add_to_funcs(do_research, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000799 whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
Benno Schulenberg4da24342014-04-27 15:20:57 +0000800
Benno Schulenbergf470c902014-05-28 21:02:39 +0000801 add_to_funcs(do_find_bracket, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000802 N_("To Bracket"), IFSCHELP(nano_bracket_msg), TOGETHER, VIEW);
Benno Schulenberg4da24342014-04-27 15:20:57 +0000803
Benno Schulenbergf470c902014-05-28 21:02:39 +0000804 add_to_funcs(do_mark, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000805 N_("Mark Text"), IFSCHELP(nano_mark_msg), TOGETHER, VIEW);
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000806
Benno Schulenbergf470c902014-05-28 21:02:39 +0000807 add_to_funcs(do_copy_text, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000808 N_("Copy Text"), IFSCHELP(nano_copy_msg), BLANKAFTER, NOVIEW);
David Lawrence Ramseyf85001a2006-04-28 13:19:56 +0000809
Benno Schulenbergf470c902014-05-28 21:02:39 +0000810 add_to_funcs(do_indent_void, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000811 N_("Indent Text"), IFSCHELP(nano_indent_msg), TOGETHER, NOVIEW);
Benno Schulenbergf470c902014-05-28 21:02:39 +0000812 add_to_funcs(do_unindent, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000813 N_("Unindent Text"), IFSCHELP(nano_unindent_msg), BLANKAFTER, NOVIEW);
Chris Allegretta07fcc4c2008-07-10 20:13:04 +0000814
Benno Schulenberg736fbf22014-06-13 15:20:26 +0000815 add_to_funcs(do_undo, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000816 N_("Undo"), IFSCHELP(nano_undo_msg), TOGETHER, NOVIEW);
Benno Schulenberg736fbf22014-06-13 15:20:26 +0000817 add_to_funcs(do_redo, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000818 N_("Redo"), IFSCHELP(nano_redo_msg), BLANKAFTER, NOVIEW);
Benno Schulenberge4c34c32014-03-17 14:15:57 +0000819#endif /* !NANO_TINY */
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000820
Benno Schulenbergf470c902014-05-28 21:02:39 +0000821 add_to_funcs(do_left, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000822 N_("Back"), IFSCHELP(nano_back_msg), TOGETHER, VIEW);
Benno Schulenbergf470c902014-05-28 21:02:39 +0000823 add_to_funcs(do_right, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000824 N_("Forward"), IFSCHELP(nano_forward_msg), TOGETHER, VIEW);
Chris Allegretta8d41fb82009-12-23 05:03:09 +0000825
826#ifndef DISABLE_BROWSER
Benno Schulenbergf470c902014-05-28 21:02:39 +0000827 add_to_funcs(do_left, MBROWSER,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000828 N_("Back"), IFSCHELP(nano_backfile_msg), TOGETHER, VIEW);
Benno Schulenbergf470c902014-05-28 21:02:39 +0000829 add_to_funcs(do_right, MBROWSER,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000830 N_("Forward"), IFSCHELP(nano_forwardfile_msg), TOGETHER, VIEW);
Chris Allegretta8d41fb82009-12-23 05:03:09 +0000831#endif
832
Benno Schulenbergf470c902014-05-28 21:02:39 +0000833 add_to_funcs(do_prev_word_void, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000834 N_("Prev Word"), IFSCHELP(nano_prevword_msg), TOGETHER, VIEW);
Benno Schulenbergf470c902014-05-28 21:02:39 +0000835 add_to_funcs(do_next_word_void, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000836 N_("Next Word"), IFSCHELP(nano_nextword_msg), TOGETHER, VIEW);
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000837
Benno Schulenbergf470c902014-05-28 21:02:39 +0000838 add_to_funcs(do_home, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000839 N_("Home"), IFSCHELP(nano_home_msg), TOGETHER, VIEW);
Benno Schulenbergf470c902014-05-28 21:02:39 +0000840 add_to_funcs(do_end, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000841 N_("End"), IFSCHELP(nano_end_msg), TOGETHER, VIEW);
Benno Schulenberg63716122014-04-27 19:51:03 +0000842
Benno Schulenbergf470c902014-05-28 21:02:39 +0000843 add_to_funcs(do_up_void, MMAIN|MBROWSER,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000844 prev_line_tag, IFSCHELP(nano_prevline_msg), TOGETHER, VIEW);
Benno Schulenbergf470c902014-05-28 21:02:39 +0000845 add_to_funcs(do_down_void, MMAIN|MBROWSER,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000846 next_line_tag, IFSCHELP(nano_nextline_msg), BLANKAFTER, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000847
Benno Schulenbergc6dbcf92016-06-25 15:16:52 +0200848 add_to_funcs(do_prev_block, MMAIN,
849 N_("Prev Block"), IFSCHELP(nano_prevblock_msg), TOGETHER, VIEW);
850 add_to_funcs(do_next_block, MMAIN,
851 N_("Next Block"), IFSCHELP(nano_nextblock_msg), TOGETHER, VIEW);
Benno Schulenbergc6dbcf92016-06-25 15:16:52 +0200852
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000853#ifndef DISABLE_JUSTIFY
Benno Schulenbergf470c902014-05-28 21:02:39 +0000854 add_to_funcs(do_para_begin_void, MMAIN|MWHEREIS,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000855 N_("Beg of Par"), IFSCHELP(nano_parabegin_msg), TOGETHER, VIEW);
Benno Schulenbergf470c902014-05-28 21:02:39 +0000856 add_to_funcs(do_para_end_void, MMAIN|MWHEREIS,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000857 N_("End of Par"), IFSCHELP(nano_paraend_msg), TOGETHER, VIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000858#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000859
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000860#ifndef NANO_TINY
Benno Schulenbergf470c902014-05-28 21:02:39 +0000861 add_to_funcs(do_scroll_up, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000862 N_("Scroll Up"), IFSCHELP(nano_scrollup_msg), TOGETHER, VIEW);
Benno Schulenbergf470c902014-05-28 21:02:39 +0000863 add_to_funcs(do_scroll_down, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000864 N_("Scroll Down"), IFSCHELP(nano_scrolldown_msg), BLANKAFTER, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000865#endif
David Lawrence Ramseydf453652006-04-21 02:05:09 +0000866
Benno Schulenberg0636d7b2014-04-03 20:23:07 +0000867#ifndef DISABLE_MULTIBUFFER
Benno Schulenbergf470c902014-05-28 21:02:39 +0000868 add_to_funcs(switch_to_prev_buffer_void, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000869 N_("Prev File"), IFSCHELP(nano_prevfile_msg), TOGETHER, VIEW);
Benno Schulenbergf470c902014-05-28 21:02:39 +0000870 add_to_funcs(switch_to_next_buffer_void, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000871 N_("Next File"), IFSCHELP(nano_nextfile_msg), BLANKAFTER, VIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000872#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +0000873
Benno Schulenberg1dbebbc2016-09-03 13:32:49 +0200874#if (defined(DISABLE_JUSTIFY) && (!defined(DISABLE_SPELLER) || !defined(DISABLE_COLOR)) || \
875 !defined(DISABLE_JUSTIFY) && defined(DISABLE_SPELLER) && defined(DISABLE_COLOR))
Benno Schulenberg71e452a2016-05-14 12:29:51 +0200876 add_to_funcs(do_gotolinecolumn_void, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000877 gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
Benno Schulenberg0d5e7322014-05-27 12:17:49 +0000878#endif
879
Benno Schulenbergbc8bb7e2016-09-12 12:49:46 +0200880#ifdef NANO_TINY
881 /* Place this one here only in the tiny version; otherwise further up. */
882 add_to_funcs(do_research, MMAIN,
883 whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
884#endif
885
Benno Schulenbergf470c902014-05-28 21:02:39 +0000886 add_to_funcs(do_verbatim_input, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000887 N_("Verbatim"), IFSCHELP(nano_verbatim_msg), TOGETHER, NOVIEW);
Chris Allegrettaaa17df02008-03-17 05:50:04 +0000888
Benno Schulenbergf470c902014-05-28 21:02:39 +0000889 add_to_funcs(do_tab, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000890 N_("Tab"), IFSCHELP(nano_tab_msg), TOGETHER, NOVIEW);
Benno Schulenbergbde996d2015-11-11 19:56:35 +0000891 add_to_funcs(do_enter, MMAIN,
Benno Schulenbergb3e40512015-07-31 11:52:26 +0000892 N_("Enter"), IFSCHELP(nano_enter_msg), BLANKAFTER, NOVIEW);
893
Benno Schulenbergf470c902014-05-28 21:02:39 +0000894 add_to_funcs(do_delete, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000895 N_("Delete"), IFSCHELP(nano_delete_msg), TOGETHER, NOVIEW);
Benno Schulenbergf470c902014-05-28 21:02:39 +0000896 add_to_funcs(do_backspace, MMAIN,
897 N_("Backspace"), IFSCHELP(nano_backspace_msg),
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000898#ifndef NANO_TINY
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000899 TOGETHER,
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000900#else
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000901 BLANKAFTER,
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000902#endif
Chris Allegrettaeb643142008-03-12 04:44:14 +0000903 NOVIEW);
904
David Lawrence Ramsey2ca23562006-04-23 19:15:15 +0000905#ifndef NANO_TINY
Benno Schulenbergb3e40512015-07-31 11:52:26 +0000906 add_to_funcs(do_cut_prev_word, MMAIN,
Benno Schulenbergcca22bb2016-02-05 12:27:54 +0000907 /* TRANSLATORS: The next two strings refer to cutting words. */
Benno Schulenbergb3e40512015-07-31 11:52:26 +0000908 N_("Cut Left"), IFSCHELP(nano_cut_word_left_msg), TOGETHER, NOVIEW);
909 add_to_funcs(do_cut_next_word, MMAIN,
910 N_("Cut Right"), IFSCHELP(nano_cut_word_right_msg), TOGETHER, NOVIEW);
Benno Schulenberg95e77a92014-06-30 20:39:27 +0000911 add_to_funcs(do_cut_till_eof, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000912 N_("CutTillEnd"), IFSCHELP(nano_cut_till_eof_msg), BLANKAFTER, NOVIEW);
David Lawrence Ramsey2ca23562006-04-23 19:15:15 +0000913#endif
914
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000915#ifndef DISABLE_JUSTIFY
Benno Schulenbergf470c902014-05-28 21:02:39 +0000916 add_to_funcs(do_full_justify, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000917 fulljustify_tag, IFSCHELP(nano_fulljustify_msg), TOGETHER, NOVIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000918#endif
919
David Lawrence Ramseyc5c52302005-11-15 23:45:29 +0000920#ifndef NANO_TINY
Benno Schulenbergf470c902014-05-28 21:02:39 +0000921 add_to_funcs(do_wordlinechar_count, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000922 N_("Word Count"), IFSCHELP(nano_wordcount_msg), TOGETHER, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000923#endif
David Lawrence Ramseyefb4b0a2006-04-19 14:09:01 +0000924
Benno Schulenbergf470c902014-05-28 21:02:39 +0000925 add_to_funcs(total_refresh, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000926 refresh_tag, IFSCHELP(nano_refresh_msg), TOGETHER, VIEW);
Chris Allegretta0018d8e2008-03-13 08:23:52 +0000927
Benno Schulenbergf470c902014-05-28 21:02:39 +0000928 add_to_funcs(do_suspend_void, MMAIN,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000929 N_("Suspend"), IFSCHELP(nano_suspend_msg), BLANKAFTER, VIEW);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000930
Benno Schulenberg68a03142016-12-07 13:10:40 +0100931#ifdef ENABLE_WORDCOMPLETION
932 add_to_funcs(complete_a_word, MMAIN,
933 N_("Complete"), IFSCHELP(nano_completion_msg), TOGETHER, NOVIEW);
934#endif
Mike Scalora6a2032f2016-05-25 22:13:50 +0200935#ifdef ENABLE_COMMENT
936 add_to_funcs(do_comment, MMAIN,
937 N_("Comment Lines"), IFSCHELP(nano_comment_msg), BLANKAFTER, NOVIEW);
938#endif
Benno Schulenbergee7b0952015-07-25 19:25:50 +0000939#ifndef NANO_TINY
940 add_to_funcs(do_savefile, MMAIN,
941 N_("Save"), IFSCHELP(nano_savefile_msg), BLANKAFTER, NOVIEW);
Benno Schulenberg4990f742015-07-26 09:23:24 +0000942
943 add_to_funcs(do_findprevious, MMAIN,
944 N_("Previous"), IFSCHELP(nano_findprev_msg), TOGETHER, VIEW);
945 add_to_funcs(do_findnext, MMAIN,
946 N_("Next"), IFSCHELP(nano_findnext_msg), BLANKAFTER, VIEW);
Benno Schulenbergee7b0952015-07-25 19:25:50 +0000947#endif
948
Benno Schulenbergb341f292014-06-19 20:05:24 +0000949#ifndef DISABLE_HISTORIES
Chris Allegretta637daa82011-02-07 14:45:56 +0000950 add_to_funcs(get_history_older_void,
Benno Schulenberge167afe2014-04-16 09:26:15 +0000951 (MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE),
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000952 N_("PrevHstory"), IFSCHELP(nano_prev_history_msg), TOGETHER, VIEW);
Chris Allegretta637daa82011-02-07 14:45:56 +0000953 add_to_funcs(get_history_newer_void,
Benno Schulenberge167afe2014-04-16 09:26:15 +0000954 (MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE),
Benno Schulenberg71e452a2016-05-14 12:29:51 +0200955 N_("NextHstory"), IFSCHELP(nano_next_history_msg), BLANKAFTER, VIEW);
956#endif
957
Benno Schulenberg1dbebbc2016-09-03 13:32:49 +0200958#ifdef DISABLE_JUSTIFY
Benno Schulenberg71e452a2016-05-14 12:29:51 +0200959 add_to_funcs(do_gotolinecolumn_void, MWHEREIS,
960 gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000961#endif
David Lawrence Ramsey02085d72004-11-07 16:04:18 +0000962
Chris Allegretta637daa82011-02-07 14:45:56 +0000963 add_to_funcs(gototext_void, MGOTOLINE,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000964 N_("Go To Text"), IFSCHELP(nano_whereis_msg), BLANKAFTER, VIEW);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000965
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000966#ifndef NANO_TINY
Benno Schulenbergcdcd3652016-05-17 11:33:21 +0200967 add_to_funcs(dos_format_void, MWRITEFILE,
Benno Schulenbergf8118462015-08-13 19:29:55 +0000968 N_("DOS Format"), IFSCHELP(nano_dos_msg), TOGETHER, NOVIEW);
Benno Schulenbergcdcd3652016-05-17 11:33:21 +0200969 add_to_funcs(mac_format_void, MWRITEFILE,
Benno Schulenbergf8118462015-08-13 19:29:55 +0000970 N_("Mac Format"), IFSCHELP(nano_mac_msg), TOGETHER, NOVIEW);
971
972 /* If we're using restricted mode, the Append, Prepend, and Backup toggles
973 * are disabled. The first and second are not useful as they only allow
974 * reduplicating the current file, and the third is not allowed as it
975 * would write to a file not specified on the command line. */
Benno Schulenberg91ee10a2014-03-27 21:35:18 +0000976 if (!ISSET(RESTRICTED)) {
Benno Schulenberg0b6d6f42015-03-27 13:46:50 +0000977 add_to_funcs(append_void, MWRITEFILE,
978 N_("Append"), IFSCHELP(nano_append_msg), TOGETHER, NOVIEW);
979 add_to_funcs(prepend_void, MWRITEFILE,
980 N_("Prepend"), IFSCHELP(nano_prepend_msg), TOGETHER, NOVIEW);
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000981
Benno Schulenberg0b6d6f42015-03-27 13:46:50 +0000982 add_to_funcs(backup_file_void, MWRITEFILE,
Benno Schulenberg338807a2016-05-05 13:27:07 +0200983 N_("Backup File"), IFSCHELP(nano_backup_msg), BLANKAFTER, NOVIEW);
Benno Schulenberg91ee10a2014-03-27 21:35:18 +0000984 }
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000985
Benno Schulenberg91ee10a2014-03-27 21:35:18 +0000986 /* If we're using restricted mode, file insertion is disabled, and
987 * thus command execution and the multibuffer toggle have no place. */
988 if (!ISSET(RESTRICTED)) {
Benno Schulenberg0b6d6f42015-03-27 13:46:50 +0000989 add_to_funcs(flip_execute_void, MINSERTFILE,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000990 N_("Execute Command"), IFSCHELP(nano_execute_msg), TOGETHER, NOVIEW);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000991
Benno Schulenberg0b6d6f42015-03-27 13:46:50 +0000992 add_to_funcs(flip_execute_void, MEXTCMD,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000993 read_file_tag, IFSCHELP(nano_insert_msg), TOGETHER, NOVIEW);
Benno Schulenbergff6b92c2014-05-28 15:35:00 +0000994
Benno Schulenberg0636d7b2014-04-03 20:23:07 +0000995#ifndef DISABLE_MULTIBUFFER
Benno Schulenberg91ee10a2014-03-27 21:35:18 +0000996 add_to_funcs(new_buffer_void, MINSERTFILE|MEXTCMD,
Benno Schulenberge6a4a642014-07-01 18:52:21 +0000997 N_("New Buffer"), IFSCHELP(nano_multibuffer_msg), TOGETHER, NOVIEW);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000998#endif
Benno Schulenberg91ee10a2014-03-27 21:35:18 +0000999 }
Benno Schulenberge4c34c32014-03-17 14:15:57 +00001000#endif /* !NANO_TINY */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00001001
Rocco Corsiaf5c3022001-01-12 07:51:05 +00001002#ifndef DISABLE_BROWSER
Benno Schulenberg63716122014-04-27 19:51:03 +00001003 if (!ISSET(RESTRICTED))
1004 add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE,
Benno Schulenberge6a4a642014-07-01 18:52:21 +00001005 N_("To Files"), IFSCHELP(nano_tofiles_msg), TOGETHER, VIEW);
Benno Schulenberg63716122014-04-27 19:51:03 +00001006
Benno Schulenbergcc65a422015-04-17 10:06:03 +00001007 add_to_funcs(do_page_up, MBROWSER,
1008 prev_page_tag, IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
1009 add_to_funcs(do_page_down, MBROWSER,
1010 next_page_tag, IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
1011
Benno Schulenberge34ac8e2014-03-17 12:15:23 +00001012 add_to_funcs(do_first_file, (MBROWSER|MWHEREISFILE),
Benno Schulenberge6a4a642014-07-01 18:52:21 +00001013 N_("First File"), IFSCHELP(nano_firstfile_msg), TOGETHER, VIEW);
Benno Schulenberge34ac8e2014-03-17 12:15:23 +00001014 add_to_funcs(do_last_file, (MBROWSER|MWHEREISFILE),
Benno Schulenbergcc65a422015-04-17 10:06:03 +00001015 N_("Last File"), IFSCHELP(nano_lastfile_msg), BLANKAFTER, VIEW);
Benno Schulenberg63716122014-04-27 19:51:03 +00001016#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +00001017
Benno Schulenberg8cc63082015-12-23 16:34:44 +00001018 add_to_funcs(discard_buffer, MWRITEFILE,
1019 N_("Discard buffer"), IFSCHELP(nano_discard_buffer_msg), BLANKAFTER, NOVIEW);
1020
Benno Schulenberg63716122014-04-27 19:51:03 +00001021#if !defined(NANO_TINY) && !defined(DISABLE_BROWSER)
Benno Schulenbergf470c902014-05-28 21:02:39 +00001022 add_to_funcs(do_research, MBROWSER,
Benno Schulenberge6a4a642014-07-01 18:52:21 +00001023 whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
Benno Schulenberg63716122014-04-27 19:51:03 +00001024#endif
Benno Schulenberge21e9542016-05-02 09:34:23 +02001025#ifndef DISABLE_BROWSER
1026 add_to_funcs(total_refresh, MBROWSER,
1027 refresh_tag, IFSCHELP(nano_browser_refresh_msg), BLANKAFTER, VIEW);
Benno Schulenbergeedec062016-05-17 12:48:47 +02001028#ifndef NANO_TINY
Benno Schulenberg36df5ce2016-05-12 10:10:04 +02001029 add_to_funcs(do_prev_word_void, MBROWSER,
1030 N_("Left Column"), IFSCHELP(nano_browser_lefthand_msg), TOGETHER, VIEW);
1031 add_to_funcs(do_next_word_void, MBROWSER,
1032 N_("Right Column"), IFSCHELP(nano_browser_righthand_msg), BLANKAFTER, VIEW);
Benno Schulenberge21e9542016-05-02 09:34:23 +02001033#endif
Benno Schulenbergeedec062016-05-17 12:48:47 +02001034#endif
Benno Schulenberg63716122014-04-27 19:51:03 +00001035
1036#ifndef DISABLE_COLOR
1037 add_to_funcs(do_page_up, MLINTER,
Benno Schulenbergcca22bb2016-02-05 12:27:54 +00001038 /* TRANSLATORS: Try to keep the next two strings at most 20 characters. */
Benno Schulenberge6a4a642014-07-01 18:52:21 +00001039 N_("Prev Lint Msg"), IFSCHELP(nano_prevlint_msg), TOGETHER, VIEW);
Benno Schulenberg63716122014-04-27 19:51:03 +00001040 add_to_funcs(do_page_down, MLINTER,
Benno Schulenberge6a4a642014-07-01 18:52:21 +00001041 N_("Next Lint Msg"), IFSCHELP(nano_nextlint_msg), TOGETHER, VIEW);
David Lawrence Ramseye38b8082006-03-30 07:03:04 +00001042#endif
1043
Benno Schulenbergf803ef52014-04-13 12:16:37 +00001044 /* Start associating key combos with functions in specific menus. */
1045
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001046 add_to_sclist(MMOST, "^G", 0, do_help_void, 0);
1047 add_to_sclist(MMOST, "F1", 0, do_help_void, 0);
1048 add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
1049 add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
1050 add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
1051 add_to_sclist(MMAIN, "F3", 0, do_writeout_void, 0);
1052 add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
1053 add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
1054 add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
1055 add_to_sclist(MMAIN|MBROWSER, "^W", 0, do_search, 0);
1056 add_to_sclist(MMAIN|MBROWSER, "F6", 0, do_search, 0);
1057 add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
1058 add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
1059 add_to_sclist(MMAIN, "F14", 0, do_replace, 0);
1060 add_to_sclist(MMOST, "^K", 0, do_cut_text_void, 0);
1061 add_to_sclist(MMOST, "F9", 0, do_cut_text_void, 0);
1062 add_to_sclist(MMAIN, "^U", 0, do_uncut_text, 0);
1063 add_to_sclist(MMAIN, "F10", 0, do_uncut_text, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001064#ifndef DISABLE_JUSTIFY
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001065 add_to_sclist(MMAIN, "^J", 0, do_justify_void, 0);
1066 add_to_sclist(MMAIN, "F4", 0, do_justify_void, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001067#endif
1068#ifndef DISABLE_SPELLER
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001069 add_to_sclist(MMAIN, "^T", 0, do_spell, 0);
1070 add_to_sclist(MMAIN, "F12", 0, do_spell, 0);
Benno Schulenberg387b2092014-05-09 15:14:29 +00001071#else
1072#ifndef DISABLE_COLOR
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001073 add_to_sclist(MMAIN, "^T", 0, do_linter, 0);
1074 add_to_sclist(MMAIN, "F12", 0, do_linter, 0);
Benno Schulenberg387b2092014-05-09 15:14:29 +00001075#endif
Benno Schulenberg523598a2014-05-03 19:19:31 +00001076#endif
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001077 add_to_sclist(MMAIN, "^C", 0, do_cursorpos_void, 0);
1078 add_to_sclist(MMAIN, "F11", 0, do_cursorpos_void, 0);
1079 add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
1080 add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0);
1081 add_to_sclist(MMAIN, "F13", 0, do_gotolinecolumn_void, 0);
1082 add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", 0, do_page_up, 0);
1083 add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, do_page_up, 0);
1084 add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
1085 add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", 0, do_page_down, 0);
1086 add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
1087 add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", KEY_NPAGE, do_page_down, 0);
1088 add_to_sclist(MMAIN|MHELP, "M-\\", 0, do_first_line, 0);
1089 add_to_sclist(MMAIN|MHELP, "M-|", 0, do_first_line, 0);
1090 add_to_sclist(MMAIN|MHELP, "M-/", 0, do_last_line, 0);
1091 add_to_sclist(MMAIN|MHELP, "M-?", 0, do_last_line, 0);
1092 add_to_sclist(MMAIN|MBROWSER, "M-W", 0, do_research, 0);
1093 add_to_sclist(MMAIN|MBROWSER, "F16", 0, do_research, 0);
Benno Schulenberg08cd1972016-09-08 21:00:51 +02001094#ifndef NANO_TINY
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001095 add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);
1096 add_to_sclist(MMAIN, "^^", 0, do_mark, 0);
1097 add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
1098 add_to_sclist(MMAIN, "F15", 0, do_mark, 0);
1099 add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
1100 add_to_sclist(MMAIN, "M-6", 0, do_copy_text, 0);
1101 add_to_sclist(MMAIN, "M-}", 0, do_indent_void, 0);
1102 add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
1103 add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
1104 add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
Benno Schulenberg68a03142016-12-07 13:10:40 +01001105#endif
1106#ifdef ENABLE_WORDCOMPLETION
Sumedh Pendurkardca4ab52016-12-07 09:43:47 +05301107 add_to_sclist(MMAIN, "^]", 0, complete_a_word, 0);
Benno Schulenbergc3e4a1f2014-03-17 11:47:49 +00001108#endif
Mike Scalora6a2032f2016-05-25 22:13:50 +02001109#ifdef ENABLE_COMMENT
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001110 add_to_sclist(MMAIN, "M-3", 0, do_comment, 0);
Mike Scalora6a2032f2016-05-25 22:13:50 +02001111#endif
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001112 add_to_sclist(MMOST, "^B", 0, do_left, 0);
1113 add_to_sclist(MMOST, "Left", KEY_LEFT, do_left, 0);
1114 add_to_sclist(MMOST, "^F", 0, do_right, 0);
1115 add_to_sclist(MMOST, "Right", KEY_RIGHT, do_right, 0);
Benno Schulenberg33bc8482016-10-29 10:19:28 +02001116#ifdef ENABLE_UTF8
Benno Schulenberg7a274d62016-10-12 12:21:44 +02001117 if (using_utf8()) {
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001118 add_to_sclist(MMOST, "^\xE2\x86\x90", CONTROL_LEFT, do_prev_word_void, 0);
1119 add_to_sclist(MMOST, "^\xE2\x86\x92", CONTROL_RIGHT, do_next_word_void, 0);
Benno Schulenberg33bc8482016-10-29 10:19:28 +02001120 } else
1121#endif
1122 {
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001123 add_to_sclist(MMOST, "^Left", CONTROL_LEFT, do_prev_word_void, 0);
1124 add_to_sclist(MMOST, "^Right", CONTROL_RIGHT, do_next_word_void, 0);
Benno Schulenberg7a274d62016-10-12 12:21:44 +02001125 }
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001126 add_to_sclist(MMOST, "M-Space", 0, do_prev_word_void, 0);
1127 add_to_sclist(MMOST, "^Space", 0, do_next_word_void, 0);
1128 add_to_sclist((MMOST & ~MBROWSER), "^A", 0, do_home, 0);
1129 add_to_sclist((MMOST & ~MBROWSER), "Home", KEY_HOME, do_home, 0);
1130 add_to_sclist((MMOST & ~MBROWSER), "^E", 0, do_end, 0);
1131 add_to_sclist((MMOST & ~MBROWSER), "End", KEY_END, do_end, 0);
1132 add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", 0, do_up_void, 0);
1133 add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", KEY_UP, do_up_void, 0);
1134 add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", 0, do_down_void, 0);
1135 add_to_sclist(MMAIN|MHELP|MBROWSER, "Down", KEY_DOWN, do_down_void, 0);
Benno Schulenberg33bc8482016-10-29 10:19:28 +02001136#ifdef ENABLE_UTF8
Benno Schulenberg7a274d62016-10-12 12:21:44 +02001137 if (using_utf8()) {
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001138 add_to_sclist(MMAIN, "^\xE2\x86\x91", CONTROL_UP, do_prev_block, 0);
1139 add_to_sclist(MMAIN, "^\xE2\x86\x93", CONTROL_DOWN, do_next_block, 0);
Benno Schulenberg33bc8482016-10-29 10:19:28 +02001140 } else
1141#endif
1142 {
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001143 add_to_sclist(MMAIN, "^Up", CONTROL_UP, do_prev_block, 0);
1144 add_to_sclist(MMAIN, "^Down", CONTROL_DOWN, do_next_block, 0);
Benno Schulenberg7a274d62016-10-12 12:21:44 +02001145 }
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001146 add_to_sclist(MMAIN, "M-7", 0, do_prev_block, 0);
1147 add_to_sclist(MMAIN, "M-8", 0, do_next_block, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001148#ifndef DISABLE_JUSTIFY
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001149 add_to_sclist(MMAIN, "M-(", 0, do_para_begin_void, 0);
1150 add_to_sclist(MMAIN, "M-9", 0, do_para_begin_void, 0);
1151 add_to_sclist(MMAIN, "M-)", 0, do_para_end_void, 0);
1152 add_to_sclist(MMAIN, "M-0", 0, do_para_end_void, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001153#endif
1154#ifndef NANO_TINY
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001155 add_to_sclist(MMAIN, "M--", 0, do_scroll_up, 0);
1156 add_to_sclist(MMAIN, "M-_", 0, do_scroll_up, 0);
1157 add_to_sclist(MMAIN, "M-+", 0, do_scroll_down, 0);
1158 add_to_sclist(MMAIN, "M-=", 0, do_scroll_down, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001159#endif
1160#ifndef DISABLE_MULTIBUFFER
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001161 add_to_sclist(MMAIN, "M-<", 0, switch_to_prev_buffer_void, 0);
1162 add_to_sclist(MMAIN, "M-,", 0, switch_to_prev_buffer_void, 0);
1163 add_to_sclist(MMAIN, "M->", 0, switch_to_next_buffer_void, 0);
1164 add_to_sclist(MMAIN, "M-.", 0, switch_to_next_buffer_void, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001165#endif
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001166 add_to_sclist(MMOST, "M-V", 0, do_verbatim_input, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001167#ifndef NANO_TINY
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001168 add_to_sclist(MMAIN, "M-T", 0, do_cut_till_eof, 0);
1169 add_to_sclist(MMAIN, "M-D", 0, do_wordlinechar_count, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001170#endif
1171#ifndef DISABLE_JUSTIFY
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001172 add_to_sclist(MMAIN|MWHEREIS, "M-J", 0, do_full_justify, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001173#endif
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001174 add_to_sclist(MMAIN|MHELP, "^L", 0, total_refresh, 0);
1175 add_to_sclist(MMAIN, "^Z", 0, do_suspend_void, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001176
1177#ifndef NANO_TINY
Benno Schulenberga6804b52014-05-09 20:33:49 +00001178 /* Group of "Appearance" toggles. */
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001179 add_to_sclist(MMAIN, "M-X", 0, do_toggle_void, NO_HELP);
1180 add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONST_UPDATE);
1181 add_to_sclist(MMAIN, "M-O", 0, do_toggle_void, MORE_SPACE);
1182 add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SMOOTH_SCROLL);
1183 add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
Faissal Bensefiade95ca62016-10-20 09:44:29 +01001184#ifdef ENABLE_LINENUMBERS
1185 add_to_sclist(MMAIN, "M-#", 0, do_toggle_void, LINE_NUMBERS);
1186#endif
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001187 add_to_sclist(MMAIN, "M-P", 0, do_toggle_void, WHITESPACE_DISPLAY);
Benno Schulenbergd16f9af2014-05-09 12:20:20 +00001188#ifndef DISABLE_COLOR
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001189 add_to_sclist(MMAIN, "M-Y", 0, do_toggle_void, NO_COLOR_SYNTAX);
Benno Schulenbergd16f9af2014-05-09 12:20:20 +00001190#endif
Benno Schulenberg523598a2014-05-03 19:19:31 +00001191
Benno Schulenberga6804b52014-05-09 20:33:49 +00001192 /* Group of "Editing-behavior" toggles. */
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001193 add_to_sclist(MMAIN, "M-H", 0, do_toggle_void, SMART_HOME);
1194 add_to_sclist(MMAIN, "M-I", 0, do_toggle_void, AUTOINDENT);
1195 add_to_sclist(MMAIN, "M-K", 0, do_toggle_void, CUT_TO_END);
Benno Schulenbergd16f9af2014-05-09 12:20:20 +00001196#ifndef DISABLE_WRAPPING
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001197 add_to_sclist(MMAIN, "M-L", 0, do_toggle_void, NO_WRAP);
Benno Schulenbergd16f9af2014-05-09 12:20:20 +00001198#endif
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001199 add_to_sclist(MMAIN, "M-Q", 0, do_toggle_void, TABS_TO_SPACES);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001200
Benno Schulenberga6804b52014-05-09 20:33:49 +00001201 /* Group of "Peripheral-feature" toggles. */
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001202 add_to_sclist(MMAIN, "M-B", 0, do_toggle_void, BACKUP_FILE);
Benno Schulenbergd16f9af2014-05-09 12:20:20 +00001203#ifndef DISABLE_MULTIBUFFER
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001204 add_to_sclist(MMAIN, "M-F", 0, do_toggle_void, MULTIBUFFER);
Benno Schulenbergd16f9af2014-05-09 12:20:20 +00001205#endif
1206#ifndef DISABLE_MOUSE
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001207 add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
Benno Schulenbergd16f9af2014-05-09 12:20:20 +00001208#endif
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001209 add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, NO_CONVERT);
1210 add_to_sclist(MMAIN, "M-Z", 0, do_toggle_void, SUSPEND);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001211#endif /* !NANO_TINY */
1212
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001213 add_to_sclist(MMAIN, "^Q", 0, xon_complaint, 0);
1214 add_to_sclist(MMAIN, "^S", 0, xoff_complaint, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001215
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001216 add_to_sclist(((MMOST & ~MMAIN & ~MBROWSER) | MYESNO), "^C", 0, do_cancel, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001217
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001218 add_to_sclist(MWHEREIS|MREPLACE, "M-C", 0, case_sens_void, 0);
1219 add_to_sclist(MWHEREIS|MREPLACE, "M-R", 0, regexp_void, 0);
1220 add_to_sclist(MWHEREIS|MREPLACE, "M-B", 0, backwards_void, 0);
1221 add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace_void, 0);
1222 add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^Y", 0, do_first_line, 0);
1223 add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^V", 0, do_last_line, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001224#ifndef DISABLE_JUSTIFY
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001225 add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^W", 0, do_para_begin_void, 0);
1226 add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^O", 0, do_para_end_void, 0);
Benno Schulenberg523598a2014-05-03 19:19:31 +00001227#endif
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001228 add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0);
1229 add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0);
Benno Schulenbergb341f292014-06-19 20:05:24 +00001230#ifndef DISABLE_HISTORIES
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001231 add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^P", 0, get_history_older_void, 0);
1232 add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Up", KEY_UP, get_history_older_void, 0);
1233 add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^N", 0, get_history_newer_void, 0);
1234 add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Down", KEY_DOWN, get_history_newer_void, 0);
Chris Allegretta1b6ed072008-06-03 08:09:05 +00001235#endif
Chris Allegretta637daa82011-02-07 14:45:56 +00001236#ifndef DISABLE_BROWSER
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001237 add_to_sclist(MWHEREISFILE, "^Y", 0, do_first_file, 0);
1238 add_to_sclist(MWHEREISFILE, "^V", 0, do_last_file, 0);
1239 add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", 0, do_first_file, 0);
1240 add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, do_first_file, 0);
1241 add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", 0, do_last_file, 0);
1242 add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
1243 add_to_sclist(MBROWSER, "Home", KEY_HOME, do_first_file, 0);
1244 add_to_sclist(MBROWSER, "End", KEY_END, do_last_file, 0);
1245 add_to_sclist(MBROWSER, "^_", 0, goto_dir_void, 0);
1246 add_to_sclist(MBROWSER, "M-G", 0, goto_dir_void, 0);
1247 add_to_sclist(MBROWSER, "F13", 0, goto_dir_void, 0);
1248 add_to_sclist(MBROWSER, "^L", 0, total_refresh, 0);
Benno Schulenberge34ac8e2014-03-17 12:15:23 +00001249#endif
Benno Schulenberg8cc63082015-12-23 16:34:44 +00001250 if (ISSET(TEMP_FILE))
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001251 add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
1252 add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
1253 add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
Benno Schulenbergf8118462015-08-13 19:29:55 +00001254 if (!ISSET(RESTRICTED)) {
1255 /* Don't allow Appending, Prepending, nor Backups in restricted mode. */
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001256 add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
1257 add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
1258 add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
Benno Schulenbergd1238c02014-05-13 20:51:19 +00001259#ifndef DISABLE_BROWSER
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001260 add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
Benno Schulenbergd1238c02014-05-13 20:51:19 +00001261#endif
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001262 add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute_void, 0);
1263 add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, new_buffer_void, 0);
Benno Schulenbergf8118462015-08-13 19:29:55 +00001264 }
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001265 add_to_sclist(MHELP|MBROWSER, "^C", 0, do_exit, 0);
Benno Schulenberg4a23a172015-11-08 19:40:13 +00001266 /* Allow exiting from the file browser and the help viewer with
1267 * the same key as they were entered. */
1268#ifndef DISABLE_BROWSER
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001269 add_to_sclist(MBROWSER, "^T", 0, do_exit, 0);
Benno Schulenberg4a23a172015-11-08 19:40:13 +00001270#endif
Benno Schulenberg8c5f5042014-05-28 20:31:06 +00001271#ifndef DISABLE_HELP
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001272 add_to_sclist(MHELP, "^G", 0, do_exit, 0);
1273 add_to_sclist(MHELP, "Home", KEY_HOME, do_first_line, 0);
1274 add_to_sclist(MHELP, "End", KEY_END, do_last_line, 0);
Benno Schulenberg8c5f5042014-05-28 20:31:06 +00001275#endif
Benno Schulenberg55878ef2016-10-15 17:55:19 +02001276 add_to_sclist(MMOST, "^I", 0, do_tab, 0);
1277 add_to_sclist(MMOST, "Tab", TAB_CODE, do_tab, 0);
1278 add_to_sclist(MMOST, "^M", 0, do_enter, 0);
1279 add_to_sclist(MMOST, "Enter", KEY_ENTER, do_enter, 0);
1280 add_to_sclist(MMOST, "^D", 0, do_delete, 0);
1281 add_to_sclist(MMOST, "Del", 0, do_delete, 0);
1282 add_to_sclist(MMOST, "^H", 0, do_backspace, 0);
1283 add_to_sclist(MMOST, "Bsp", KEY_BACKSPACE, do_backspace, 0);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001284
1285#ifdef DEBUG
1286 print_sclist();
1287#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +00001288}
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001289
Benno Schulenberg00389922014-04-04 11:59:03 +00001290#ifndef DISABLE_COLOR
Chris Allegretta4b3f2772015-01-03 07:24:17 +00001291void set_lint_or_format_shortcuts(void)
Chris Allegretta5575bfa2014-02-24 10:18:15 +00001292{
1293#ifndef DISABLE_SPELLER
Chris Allegretta4b3f2772015-01-03 07:24:17 +00001294 if (openfile->syntax->formatter) {
1295 replace_scs_for(do_spell, do_formatter);
1296 replace_scs_for(do_linter, do_formatter);
1297 } else {
1298 replace_scs_for(do_spell, do_linter);
1299 replace_scs_for(do_formatter, do_linter);
1300 }
Chris Allegretta5575bfa2014-02-24 10:18:15 +00001301#endif
1302}
1303
1304void set_spell_shortcuts(void)
1305{
1306#ifndef DISABLE_SPELLER
Chris Allegretta4b3f2772015-01-03 07:24:17 +00001307 replace_scs_for(do_formatter, do_spell);
1308 replace_scs_for(do_linter, do_spell);
Chris Allegretta5575bfa2014-02-24 10:18:15 +00001309#endif
1310}
Benno Schulenberg34fbb1f2016-01-13 20:32:40 +00001311#endif /* !DISABLE_COLOR */
Chris Allegretta5575bfa2014-02-24 10:18:15 +00001312
Benno Schulenbergdd29c562016-01-04 09:52:43 +00001313const subnfunc *sctofunc(const sc *s)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001314{
Benno Schulenbergdd29c562016-01-04 09:52:43 +00001315 subnfunc *f = allfuncs;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001316
Benno Schulenbergdd29c562016-01-04 09:52:43 +00001317 while (f != NULL && f->scfunc != s->scfunc)
1318 f = f->next;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001319
1320 return f;
1321}
1322
1323#ifndef NANO_TINY
Benno Schulenbergd19be5a2014-04-08 18:38:45 +00001324/* Now let's come up with a single (hopefully) function to get a string
1325 * for each flag. */
Chris Allegretta5a018f02009-11-29 06:13:22 +00001326const char *flagtostr(int flag)
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001327{
Benno Schulenberg492e9f62014-06-20 10:48:26 +00001328 switch (flag) {
Benno Schulenberg0b6d6f42015-03-27 13:46:50 +00001329 case NO_HELP:
1330 /* TRANSLATORS: The next seventeen strings are toggle descriptions;
1331 * they are best kept shorter than 40 characters, but may be longer. */
1332 return N_("Help mode");
1333 case CONST_UPDATE:
1334 return N_("Constant cursor position display");
1335 case MORE_SPACE:
1336 return N_("Use of one more line for editing");
1337 case SMOOTH_SCROLL:
1338 return N_("Smooth scrolling");
1339 case SOFTWRAP:
1340 return N_("Soft wrapping of overlong lines");
1341 case WHITESPACE_DISPLAY:
1342 return N_("Whitespace display");
1343 case NO_COLOR_SYNTAX:
1344 return N_("Color syntax highlighting");
1345 case SMART_HOME:
1346 return N_("Smart home key");
1347 case AUTOINDENT:
1348 return N_("Auto indent");
1349 case CUT_TO_END:
1350 return N_("Cut to end");
1351 case NO_WRAP:
1352 return N_("Hard wrapping of overlong lines");
1353 case TABS_TO_SPACES:
1354 return N_("Conversion of typed tabs to spaces");
1355 case BACKUP_FILE:
1356 return N_("Backup files");
1357 case MULTIBUFFER:
Benno Schulenberg296152e2015-04-18 16:07:53 +00001358 return N_("Reading file into separate buffer");
Benno Schulenberg0b6d6f42015-03-27 13:46:50 +00001359 case USE_MOUSE:
1360 return N_("Mouse support");
1361 case NO_CONVERT:
1362 return N_("No conversion from DOS/Mac format");
1363 case SUSPEND:
1364 return N_("Suspension");
Faissal Bensefiade95ca62016-10-20 09:44:29 +01001365 case LINE_NUMBERS:
1366 return N_("Line numbering");
Benno Schulenberg0b6d6f42015-03-27 13:46:50 +00001367 default:
1368 return "?????";
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001369 }
1370}
Benno Schulenberge4c34c32014-03-17 14:15:57 +00001371#endif /* !NANO_TINY */
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001372
Benno Schulenberg353dd212014-05-25 19:47:46 +00001373#ifndef DISABLE_NANORC
Benno Schulenberg1f934e32014-04-13 11:56:08 +00001374/* Interpret a function string given in the rc file, and return a
Benno Schulenbergd4623f32014-06-28 14:42:18 +00001375 * shortcut struct with the corresponding function filled in. */
Benno Schulenberg539a4b42016-01-04 09:12:21 +00001376sc *strtosc(const char *input)
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001377{
Benno Schulenberg7b7d2bf2016-09-01 09:36:47 +02001378 sc *s = nmalloc(sizeof(sc));
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001379
Benno Schulenberg7b7d2bf2016-09-01 09:36:47 +02001380#ifndef NANO_TINY
Rishabh Dave1fd23542016-08-07 00:46:41 +05301381 s->toggle = 0;
Benno Schulenberg7b7d2bf2016-09-01 09:36:47 +02001382#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001383
Chris Allegrettae347efb2008-03-09 02:52:40 +00001384#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001385 if (!strcasecmp(input, "help"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001386 s->scfunc = do_help_void;
1387 else
Chris Allegrettae347efb2008-03-09 02:52:40 +00001388#endif
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001389 if (!strcasecmp(input, "cancel"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001390 s->scfunc = do_cancel;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001391 else if (!strcasecmp(input, "exit"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001392 s->scfunc = do_exit;
Benno Schulenberg8cc63082015-12-23 16:34:44 +00001393 else if (!strcasecmp(input, "discardbuffer"))
1394 s->scfunc = discard_buffer;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001395 else if (!strcasecmp(input, "writeout"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001396 s->scfunc = do_writeout_void;
Benno Schulenbergee7b0952015-07-25 19:25:50 +00001397#ifndef NANO_TINY
1398 else if (!strcasecmp(input, "savefile"))
1399 s->scfunc = do_savefile;
1400#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001401 else if (!strcasecmp(input, "insert"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001402 s->scfunc = do_insertfile_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001403 else if (!strcasecmp(input, "whereis"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001404 s->scfunc = do_search;
Benno Schulenberg618051c2014-04-26 20:16:17 +00001405 else if (!strcasecmp(input, "searchagain") ||
Benno Schulenberged9e5d72016-09-03 20:12:29 +02001406 !strcasecmp(input, "research")) /* Deprecated. Remove in 2018. */
Benno Schulenberg618051c2014-04-26 20:16:17 +00001407 s->scfunc = do_research;
Benno Schulenberg08cd1972016-09-08 21:00:51 +02001408#ifndef NANO_TINY
Benno Schulenberg4990f742015-07-26 09:23:24 +00001409 else if (!strcasecmp(input, "findprevious"))
1410 s->scfunc = do_findprevious;
1411 else if (!strcasecmp(input, "findnext"))
1412 s->scfunc = do_findnext;
Benno Schulenberg5f655da2014-04-27 15:26:25 +00001413#endif
Benno Schulenberg618051c2014-04-26 20:16:17 +00001414 else if (!strcasecmp(input, "replace"))
1415 s->scfunc = do_replace;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001416 else if (!strcasecmp(input, "cut"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001417 s->scfunc = do_cut_text_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001418 else if (!strcasecmp(input, "uncut"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001419 s->scfunc = do_uncut_text;
Benno Schulenberg5f655da2014-04-27 15:26:25 +00001420#ifndef NANO_TINY
Benno Schulenbergf8507bb2014-05-05 19:54:34 +00001421 else if (!strcasecmp(input, "cutrestoffile"))
Benno Schulenberg95e77a92014-06-30 20:39:27 +00001422 s->scfunc = do_cut_till_eof;
Benno Schulenberg5f655da2014-04-27 15:26:25 +00001423 else if (!strcasecmp(input, "copytext"))
1424 s->scfunc = do_copy_text;
Benno Schulenberg618051c2014-04-26 20:16:17 +00001425 else if (!strcasecmp(input, "mark"))
1426 s->scfunc = do_mark;
Benno Schulenberg387b2092014-05-09 15:14:29 +00001427#endif
1428#ifndef DISABLE_SPELLER
Benno Schulenberg301c4ef2014-04-26 19:33:11 +00001429 else if (!strcasecmp(input, "tospell") ||
1430 !strcasecmp(input, "speller"))
1431 s->scfunc = do_spell;
Benno Schulenberg5f655da2014-04-27 15:26:25 +00001432#endif
Benno Schulenberg52d7d5f2015-03-27 15:34:41 +00001433#ifndef DISABLE_COLOR
Benno Schulenbergb455fa32015-03-25 19:33:00 +00001434 else if (!strcasecmp(input, "linter"))
1435 s->scfunc = do_linter;
Benno Schulenberg52d7d5f2015-03-27 15:34:41 +00001436#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001437 else if (!strcasecmp(input, "curpos") ||
Benno Schulenberged9e5d72016-09-03 20:12:29 +02001438 !strcasecmp(input, "cursorpos")) /* Deprecated. Remove in 2018. */
Chris Allegretta637daa82011-02-07 14:45:56 +00001439 s->scfunc = do_cursorpos_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001440 else if (!strcasecmp(input, "gotoline"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001441 s->scfunc = do_gotolinecolumn_void;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001442#ifndef DISABLE_JUSTIFY
Chris Allegrettae347efb2008-03-09 02:52:40 +00001443 else if (!strcasecmp(input, "justify"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001444 s->scfunc = do_justify_void;
Benno Schulenberg618051c2014-04-26 20:16:17 +00001445 else if (!strcasecmp(input, "fulljustify"))
1446 s->scfunc = do_full_justify;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001447 else if (!strcasecmp(input, "beginpara"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001448 s->scfunc = do_para_begin_void;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001449 else if (!strcasecmp(input, "endpara"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001450 s->scfunc = do_para_end_void;
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001451#endif
Mike Scalora6a2032f2016-05-25 22:13:50 +02001452#ifdef ENABLE_COMMENT
1453 else if (!strcasecmp(input, "comment"))
1454 s->scfunc = do_comment;
1455#endif
Benno Schulenberg0e010802016-12-07 13:20:36 +01001456#ifdef ENABLE_WORDCOMPLETION
1457 else if (!strcasecmp(input, "complete"))
1458 s->scfunc = complete_a_word;
1459#endif
Chris Allegrettac656e9d2008-03-16 12:55:41 +00001460#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001461 else if (!strcasecmp(input, "indent"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001462 s->scfunc = do_indent_void;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001463 else if (!strcasecmp(input, "unindent"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001464 s->scfunc = do_unindent;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001465 else if (!strcasecmp(input, "scrollup"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001466 s->scfunc = do_scroll_up;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001467 else if (!strcasecmp(input, "scrolldown"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001468 s->scfunc = do_scroll_down;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001469 else if (!strcasecmp(input, "prevword"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001470 s->scfunc = do_prev_word_void;
Benno Schulenberg3064db22014-04-21 12:06:20 +00001471 else if (!strcasecmp(input, "nextword"))
1472 s->scfunc = do_next_word_void;
Benno Schulenbergb3e40512015-07-31 11:52:26 +00001473 else if (!strcasecmp(input, "cutwordleft"))
1474 s->scfunc = do_cut_prev_word;
1475 else if (!strcasecmp(input, "cutwordright"))
1476 s->scfunc = do_cut_next_word;
Benno Schulenbergc6dbcf92016-06-25 15:16:52 +02001477 else if (!strcasecmp(input, "prevblock"))
1478 s->scfunc = do_prev_block;
1479 else if (!strcasecmp(input, "nextblock"))
1480 s->scfunc = do_next_block;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001481 else if (!strcasecmp(input, "findbracket"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001482 s->scfunc = do_find_bracket;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001483 else if (!strcasecmp(input, "wordcount"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001484 s->scfunc = do_wordlinechar_count;
Chris Allegretta70859f42008-07-13 01:36:06 +00001485 else if (!strcasecmp(input, "undo"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001486 s->scfunc = do_undo;
Benno Schulenbergcf8a2962014-06-20 16:03:38 +00001487 else if (!strcasecmp(input, "redo"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001488 s->scfunc = do_redo;
Benno Schulenberg492e9f62014-06-20 10:48:26 +00001489#endif
Chris Allegrettae347efb2008-03-09 02:52:40 +00001490 else if (!strcasecmp(input, "left") ||
Benno Schulenberg3aea69d2014-02-28 20:08:59 +00001491 !strcasecmp(input, "back"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001492 s->scfunc = do_left;
Benno Schulenberg47be8c22014-04-22 19:07:32 +00001493 else if (!strcasecmp(input, "right") ||
1494 !strcasecmp(input, "forward"))
1495 s->scfunc = do_right;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001496 else if (!strcasecmp(input, "up") ||
Benno Schulenberg3aea69d2014-02-28 20:08:59 +00001497 !strcasecmp(input, "prevline"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001498 s->scfunc = do_up_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001499 else if (!strcasecmp(input, "down") ||
Benno Schulenberg3aea69d2014-02-28 20:08:59 +00001500 !strcasecmp(input, "nextline"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001501 s->scfunc = do_down_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001502 else if (!strcasecmp(input, "home"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001503 s->scfunc = do_home;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001504 else if (!strcasecmp(input, "end"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001505 s->scfunc = do_end;
Benno Schulenberg618051c2014-04-26 20:16:17 +00001506 else if (!strcasecmp(input, "pageup") ||
1507 !strcasecmp(input, "prevpage"))
1508 s->scfunc = do_page_up;
1509 else if (!strcasecmp(input, "pagedown") ||
1510 !strcasecmp(input, "nextpage"))
1511 s->scfunc = do_page_down;
1512 else if (!strcasecmp(input, "firstline"))
1513 s->scfunc = do_first_line;
1514 else if (!strcasecmp(input, "lastline"))
1515 s->scfunc = do_last_line;
Benno Schulenberg0636d7b2014-04-03 20:23:07 +00001516#ifndef DISABLE_MULTIBUFFER
Chris Allegrettae347efb2008-03-09 02:52:40 +00001517 else if (!strcasecmp(input, "prevbuf"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001518 s->scfunc = switch_to_prev_buffer_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001519 else if (!strcasecmp(input, "nextbuf"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001520 s->scfunc = switch_to_next_buffer_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001521#endif
1522 else if (!strcasecmp(input, "verbatim"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001523 s->scfunc = do_verbatim_input;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001524 else if (!strcasecmp(input, "tab"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001525 s->scfunc = do_tab;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001526 else if (!strcasecmp(input, "enter"))
Benno Schulenbergbde996d2015-11-11 19:56:35 +00001527 s->scfunc = do_enter;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001528 else if (!strcasecmp(input, "delete"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001529 s->scfunc = do_delete;
Chris Allegrettafa406942008-07-13 16:44:19 +00001530 else if (!strcasecmp(input, "backspace"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001531 s->scfunc = do_backspace;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001532 else if (!strcasecmp(input, "refresh"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001533 s->scfunc = total_refresh;
Benno Schulenberg5a393392014-05-27 12:38:32 +00001534 else if (!strcasecmp(input, "suspend"))
1535 s->scfunc = do_suspend_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001536 else if (!strcasecmp(input, "casesens"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001537 s->scfunc = case_sens_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001538 else if (!strcasecmp(input, "regexp") ||
Benno Schulenberged9e5d72016-09-03 20:12:29 +02001539 !strcasecmp(input, "regex")) /* Deprecated. Remove in 2018. */
Chris Allegretta637daa82011-02-07 14:45:56 +00001540 s->scfunc = regexp_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001541 else if (!strcasecmp(input, "backwards"))
Benno Schulenberg08465832014-05-04 12:20:51 +00001542 s->scfunc = backwards_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001543 else if (!strcasecmp(input, "flipreplace") ||
Benno Schulenberged9e5d72016-09-03 20:12:29 +02001544 !strcasecmp(input, "dontreplace")) /* Deprecated. Remove in 2018. */
Benno Schulenberga0f66c02014-06-23 18:30:35 +00001545 s->scfunc = flip_replace_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001546 else if (!strcasecmp(input, "gototext"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001547 s->scfunc = gototext_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001548#ifndef DISABLE_HISTORIES
1549 else if (!strcasecmp(input, "prevhistory"))
1550 s->scfunc = get_history_older_void;
1551 else if (!strcasecmp(input, "nexthistory"))
1552 s->scfunc = get_history_newer_void;
1553#endif
1554 else if (!strcasecmp(input, "dosformat"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001555 s->scfunc = dos_format_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001556 else if (!strcasecmp(input, "macformat"))
Benno Schulenberg492e9f62014-06-20 10:48:26 +00001557 s->scfunc = mac_format_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001558 else if (!strcasecmp(input, "append"))
Benno Schulenberg492e9f62014-06-20 10:48:26 +00001559 s->scfunc = append_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001560 else if (!strcasecmp(input, "prepend"))
Benno Schulenberg492e9f62014-06-20 10:48:26 +00001561 s->scfunc = prepend_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001562 else if (!strcasecmp(input, "backup"))
Benno Schulenberg492e9f62014-06-20 10:48:26 +00001563 s->scfunc = backup_file_void;
Benno Schulenberg04a38da2014-06-04 19:15:16 +00001564#ifndef ENABLE_TINY
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001565 else if (!strcasecmp(input, "flipexecute"))
Benno Schulenberg04a38da2014-06-04 19:15:16 +00001566 s->scfunc = flip_execute_void;
Benno Schulenberg04a38da2014-06-04 19:15:16 +00001567#endif
Benno Schulenberg0636d7b2014-04-03 20:23:07 +00001568#ifndef DISABLE_MULTIBUFFER
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001569 else if (!strcasecmp(input, "flipnewbuffer") ||
Benno Schulenberged9e5d72016-09-03 20:12:29 +02001570 !strcasecmp(input, "newbuffer")) /* Deprecated. Remove in 2018. */
Benno Schulenberg492e9f62014-06-20 10:48:26 +00001571 s->scfunc = new_buffer_void;
Chris Allegrettae347efb2008-03-09 02:52:40 +00001572#endif
Chris Allegretta637daa82011-02-07 14:45:56 +00001573#ifndef DISABLE_BROWSER
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001574 else if (!strcasecmp(input, "tofiles") ||
1575 !strcasecmp(input, "browser"))
Benno Schulenbergef162232014-06-23 20:03:25 +00001576 s->scfunc = to_files_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001577 else if (!strcasecmp(input, "gotodir"))
Benno Schulenbergef162232014-06-23 20:03:25 +00001578 s->scfunc = goto_dir_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001579 else if (!strcasecmp(input, "firstfile"))
Benno Schulenberg492e9f62014-06-20 10:48:26 +00001580 s->scfunc = do_first_file;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001581 else if (!strcasecmp(input, "lastfile"))
Chris Allegretta637daa82011-02-07 14:45:56 +00001582 s->scfunc = do_last_file;
Chris Allegretta637daa82011-02-07 14:45:56 +00001583#endif
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001584 else {
Benno Schulenberg57d17552016-09-03 12:14:08 +02001585#ifndef NANO_TINY
Benno Schulenberg0a1e56e2014-06-28 15:00:29 +00001586 s->scfunc = do_toggle_void;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001587 if (!strcasecmp(input, "nohelp"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001588 s->toggle = NO_HELP;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001589 else if (!strcasecmp(input, "constupdate"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001590 s->toggle = CONST_UPDATE;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001591 else if (!strcasecmp(input, "morespace"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001592 s->toggle = MORE_SPACE;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001593 else if (!strcasecmp(input, "smoothscroll"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001594 s->toggle = SMOOTH_SCROLL;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001595 else if (!strcasecmp(input, "softwrap"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001596 s->toggle = SOFTWRAP;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001597 else if (!strcasecmp(input, "whitespacedisplay"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001598 s->toggle = WHITESPACE_DISPLAY;
Benno Schulenberg0a1e56e2014-06-28 15:00:29 +00001599#ifndef DISABLE_COLOR
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001600 else if (!strcasecmp(input, "nosyntax"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001601 s->toggle = NO_COLOR_SYNTAX;
Benno Schulenberg0a1e56e2014-06-28 15:00:29 +00001602#endif
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001603 else if (!strcasecmp(input, "smarthome"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001604 s->toggle = SMART_HOME;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001605 else if (!strcasecmp(input, "autoindent"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001606 s->toggle = AUTOINDENT;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001607 else if (!strcasecmp(input, "cuttoend"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001608 s->toggle = CUT_TO_END;
Benno Schulenberg0a1e56e2014-06-28 15:00:29 +00001609#ifndef DISABLE_WRAPPING
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001610 else if (!strcasecmp(input, "nowrap"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001611 s->toggle = NO_WRAP;
Benno Schulenberg0a1e56e2014-06-28 15:00:29 +00001612#endif
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001613 else if (!strcasecmp(input, "tabstospaces"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001614 s->toggle = TABS_TO_SPACES;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001615 else if (!strcasecmp(input, "backupfile"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001616 s->toggle = BACKUP_FILE;
Benno Schulenberg0a1e56e2014-06-28 15:00:29 +00001617#ifndef DISABLE_MULTIBUFFER
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001618 else if (!strcasecmp(input, "multibuffer"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001619 s->toggle = MULTIBUFFER;
Benno Schulenberg0a1e56e2014-06-28 15:00:29 +00001620#endif
1621#ifndef DISABLE_MOUSE
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001622 else if (!strcasecmp(input, "mouse"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001623 s->toggle = USE_MOUSE;
Benno Schulenberg0a1e56e2014-06-28 15:00:29 +00001624#endif
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001625 else if (!strcasecmp(input, "noconvert"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001626 s->toggle = NO_CONVERT;
Benno Schulenbergd48d84a2014-06-28 15:34:10 +00001627 else if (!strcasecmp(input, "suspendenable"))
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001628 s->toggle = SUSPEND;
Benno Schulenberg57d17552016-09-03 12:14:08 +02001629 else
Benno Schulenberg0a1e56e2014-06-28 15:00:29 +00001630#endif /* !NANO_TINY */
Benno Schulenberg57d17552016-09-03 12:14:08 +02001631 {
Benno Schulenbergb71cf982014-06-28 15:22:41 +00001632 free(s);
1633 return NULL;
1634 }
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001635 }
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001636 return s;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001637}
1638
Benno Schulenberg353dd212014-05-25 19:47:46 +00001639/* Interpret a menu name and return the corresponding menu flag. */
Benno Schulenberg539a4b42016-01-04 09:12:21 +00001640int strtomenu(const char *input)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001641{
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001642 if (!strcasecmp(input, "all"))
Benno Schulenberg4c9573d2014-04-16 09:12:13 +00001643 return (MMOST|MHELP|MYESNO);
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001644 else if (!strcasecmp(input, "main"))
1645 return MMAIN;
1646 else if (!strcasecmp(input, "search"))
1647 return MWHEREIS;
1648 else if (!strcasecmp(input, "replace"))
1649 return MREPLACE;
Benno Schulenberged9e5d72016-09-03 20:12:29 +02001650 else if (!strcasecmp(input, "replace2") || /* Deprecated. Remove in 2018. */
Benno Schulenbergf803ef52014-04-13 12:16:37 +00001651 !strcasecmp(input, "replacewith"))
Benno Schulenberge167afe2014-04-16 09:26:15 +00001652 return MREPLACEWITH;
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001653 else if (!strcasecmp(input, "gotoline"))
1654 return MGOTOLINE;
1655 else if (!strcasecmp(input, "writeout"))
1656 return MWRITEFILE;
1657 else if (!strcasecmp(input, "insert"))
1658 return MINSERTFILE;
1659 else if (!strcasecmp(input, "externalcmd") ||
Benno Schulenbergf803ef52014-04-13 12:16:37 +00001660 !strcasecmp(input, "extcmd"))
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001661 return MEXTCMD;
Benno Schulenberg353dd212014-05-25 19:47:46 +00001662#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001663 else if (!strcasecmp(input, "help"))
1664 return MHELP;
Benno Schulenberg353dd212014-05-25 19:47:46 +00001665#endif
1666#ifndef DISABLE_SPELLER
Benno Schulenbergeae9f282015-03-25 16:20:45 +00001667 else if (!strcasecmp(input, "spell"))
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001668 return MSPELL;
Benno Schulenberg353dd212014-05-25 19:47:46 +00001669#endif
Benno Schulenberg3064db22014-04-21 12:06:20 +00001670 else if (!strcasecmp(input, "linter"))
1671 return MLINTER;
Benno Schulenberg353dd212014-05-25 19:47:46 +00001672#ifndef DISABLE_BROWSER
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001673 else if (!strcasecmp(input, "browser"))
1674 return MBROWSER;
1675 else if (!strcasecmp(input, "whereisfile"))
1676 return MWHEREISFILE;
1677 else if (!strcasecmp(input, "gotodir"))
1678 return MGOTODIR;
Benno Schulenberg353dd212014-05-25 19:47:46 +00001679#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001680 return -1;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001681}
Benno Schulenberg353dd212014-05-25 19:47:46 +00001682#endif /* !DISABLE_NANORC */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001683
Chris Allegrettae347efb2008-03-09 02:52:40 +00001684
David Lawrence Ramseye6757b92006-04-19 13:36:56 +00001685#ifdef DEBUG
1686/* This function is used to gracefully return all the memory we've used.
1687 * It should be called just before calling exit(). Practically, the
Chris Allegretta6232d662002-05-12 19:52:15 +00001688 * only effect is to cause a segmentation fault if the various data
1689 * structures got bolloxed earlier. Thus, we don't bother having this
Chris Allegretta6df90f52002-07-19 01:08:59 +00001690 * function unless debugging is turned on. */
Chris Allegretta6df90f52002-07-19 01:08:59 +00001691void thanks_for_all_the_fish(void)
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001692{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001693 delwin(topwin);
1694 delwin(edit);
1695 delwin(bottomwin);
1696
Benno Schulenberg6f129922016-06-30 18:02:45 +02001697 free(word_chars);
Chris Allegretta7662c862003-01-13 01:35:15 +00001698#ifndef DISABLE_JUSTIFY
Benno Schulenbergc32a58a2015-06-14 19:14:41 +00001699 free(quotestr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001700#ifdef HAVE_REGEX_H
1701 regfree(&quotereg);
Benno Schulenbergc32a58a2015-06-14 19:14:41 +00001702 free(quoteerr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001703#endif
Chris Allegretta7662c862003-01-13 01:35:15 +00001704#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001705#ifndef NANO_TINY
Benno Schulenbergc32a58a2015-06-14 19:14:41 +00001706 free(backup_dir);
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +00001707#endif
Chris Allegretta2598c662002-03-28 01:59:34 +00001708#ifndef DISABLE_OPERATINGDIR
Benno Schulenbergc32a58a2015-06-14 19:14:41 +00001709 free(operating_dir);
1710 free(full_operating_dir);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001711#endif
Benno Schulenbergc32a58a2015-06-14 19:14:41 +00001712 free(answer);
Benno Schulenberg1cf22d42015-04-21 18:42:11 +00001713 free(last_search);
Benno Schulenberge2556272016-04-30 21:22:16 +02001714 free(present_path);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001715#ifndef DISABLE_SPELLER
Benno Schulenbergc32a58a2015-06-14 19:14:41 +00001716 free(alt_speller);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001717#endif
Benno Schulenberg814a4222016-02-21 20:54:04 +00001718 free_filestruct(cutbuffer);
David Lawrence Ramsey5d8d0b12005-05-26 05:53:29 +00001719 /* Free the memory associated with each open file buffer. */
Benno Schulenbergf4f99542016-02-22 09:02:58 +00001720 while (openfile != openfile->next) {
1721 openfile = openfile->next;
1722 delete_opennode(openfile->prev);
1723 }
1724 delete_opennode(openfile);
Benno Schulenberg00389922014-04-04 11:59:03 +00001725#ifndef DISABLE_COLOR
Benno Schulenbergc32a58a2015-06-14 19:14:41 +00001726 free(syntaxstr);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001727 while (syntaxes != NULL) {
Benno Schulenberg8a244c62016-03-04 20:22:27 +00001728 syntaxtype *sint = syntaxes;
Chris Allegretta6df90f52002-07-19 01:08:59 +00001729 syntaxes = syntaxes->next;
Benno Schulenberg8a244c62016-03-04 20:22:27 +00001730
1731 free(sint->name);
1732 free(sint->linter);
1733 free(sint->formatter);
1734
1735 while (sint->extensions != NULL) {
1736 regexlisttype *item = sint->extensions;
1737 sint->extensions = sint->extensions->next;
1738 free(item->full_regex);
1739 free(item);
1740 }
1741 while (sint->headers != NULL) {
1742 regexlisttype *item = sint->headers;
1743 sint->headers = sint->headers->next;
1744 free(item->full_regex);
1745 free(item);
1746 }
1747 while (sint->magics != NULL) {
1748 regexlisttype *item = sint->magics;
1749 sint->magics = sint->magics->next;
1750 free(item->full_regex);
1751 free(item);
1752 }
1753
1754 while (sint->color != NULL) {
1755 colortype *ink = sint->color;
1756 sint->color = sint->color->next;
1757 free(ink->start_regex);
1758 if (ink->start != NULL) {
1759 regfree(ink->start);
1760 free(ink->start);
1761 }
1762 free(ink->end_regex);
1763 if (ink->end != NULL) {
1764 regfree(ink->end);
1765 free(ink->end);
1766 }
1767 free(ink);
1768 }
1769
1770 free(sint);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001771 }
Benno Schulenberg00389922014-04-04 11:59:03 +00001772#endif /* !DISABLE_COLOR */
Benno Schulenberg3f816ee2014-06-19 21:01:39 +00001773#ifndef DISABLE_HISTORIES
David Lawrence Ramsey40e4acf2005-05-26 06:09:07 +00001774 /* Free the search and replace history lists. */
Benno Schulenberg814a4222016-02-21 20:54:04 +00001775 free_filestruct(searchage);
1776 free_filestruct(replaceage);
Chris Allegretta5beed502003-01-05 20:41:21 +00001777#endif
Benno Schulenberg814a4222016-02-21 20:54:04 +00001778 /* Free the list of functions. */
Benno Schulenberg24bc59f2014-05-13 18:06:09 +00001779 while (allfuncs != NULL) {
Benno Schulenberg0b6d6f42015-03-27 13:46:50 +00001780 subnfunc *f = allfuncs;
1781 allfuncs = allfuncs->next;
1782 free(f);
Benno Schulenberg24bc59f2014-05-13 18:06:09 +00001783 }
Benno Schulenberg814a4222016-02-21 20:54:04 +00001784 /* Free the list of shortcuts. */
Benno Schulenberg24bc59f2014-05-13 18:06:09 +00001785 while (sclist != NULL) {
Benno Schulenberg0b6d6f42015-03-27 13:46:50 +00001786 sc *s = sclist;
1787 sclist = sclist->next;
1788 free(s);
Benno Schulenberg24bc59f2014-05-13 18:06:09 +00001789 }
Benno Schulenbergeea09082014-04-13 20:50:20 +00001790#ifndef DISABLE_NANORC
Benno Schulenbergc32a58a2015-06-14 19:14:41 +00001791 free(homedir);
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001792#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001793}
Chris Allegretta6232d662002-05-12 19:52:15 +00001794#endif /* DEBUG */