global.c 47 KB
Newer Older
Chris Allegretta's avatar
Chris Allegretta committed
1
/* $Id$ */
Chris Allegretta's avatar
Chris Allegretta committed
2
3
4
/**************************************************************************
 *   global.c                                                             *
 *                                                                        *
5
 *   Copyright (C) 1999-2004 Chris Allegretta                             *
6
 *   Copyright (C) 2005-2006 David Lawrence Ramsey                        *
Chris Allegretta's avatar
Chris Allegretta committed
7
8
 *   This program is free software; you can redistribute it and/or modify *
 *   it under the terms of the GNU General Public License as published by *
9
 *   the Free Software Foundation; either version 2, or (at your option)  *
Chris Allegretta's avatar
Chris Allegretta committed
10
11
 *   any later version.                                                   *
 *                                                                        *
12
13
14
15
 *   This program is distributed in the hope that it will be useful, but  *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    *
 *   General Public License for more details.                             *
Chris Allegretta's avatar
Chris Allegretta committed
16
17
18
 *                                                                        *
 *   You should have received a copy of the GNU General Public License    *
 *   along with this program; if not, write to the Free Software          *
19
20
 *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA            *
 *   02110-1301, USA.                                                     *
Chris Allegretta's avatar
Chris Allegretta committed
21
22
23
24
25
 *                                                                        *
 **************************************************************************/

#include "proto.h"

Chris Allegretta's avatar
Chris Allegretta committed
26
/* Global variables */
27
#ifndef DISABLE_WRAPJUSTIFY
28
29
ssize_t fill = 0;
	/* The column where we will wrap lines. */
30
ssize_t wrap_at = -CHARS_FROM_EOL;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
	/* The position where we will wrap lines.  fill is equal to this
	 * if it's greater than zero, and equal to (COLS + this) if it
	 * isn't. */
#endif

char *last_search = NULL;
	/* The last string we searched for. */
char *last_replace = NULL;
	/* The last replacement string we searched for. */

long flags = 0;
	/* Our flag containing the states of all global options. */
WINDOW *topwin;
	/* The top portion of the window, where we display the version
	 * number of nano, the name of the current file, and whether the
	 * current file has been modified. */
WINDOW *edit;
	/* The middle portion of the window, i.e, the edit window, where
	 * we display the current file we're editing. */
WINDOW *bottomwin;
	/* The bottom portion of the window, where we display statusbar
	 * messages, the statusbar prompt, and a list of shortcuts. */
int editwinrows = 0;
	/* How many rows does the edit window take up? */

filestruct *cutbuffer = NULL;
	/* The buffer where we store cut text. */
58
#ifndef DISABLE_JUSTIFY
59
60
filestruct *jusbuffer = NULL;
	/* The buffer where we store unjustified text. */
61
#endif
62
63
64
partition *filepart = NULL;
	/* The partition where we store a portion of the current
	 * file. */
65
openfilestruct *openfile = NULL;
66
	/* The list of all open file buffers. */
67

68
69
70
71
72
73
#ifndef NANO_TINY
char *matchbrackets = NULL;
	/* The opening and closing brackets that can be found by bracket
	 * searches. */
#endif

74
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
75
76
77
78
79
char *whitespace = NULL;
	/* The characters used when displaying the first characters of
	 * tabs and spaces. */
int whitespace_len[2];
	/* The length of these characters. */
80
81
#endif

82
#ifndef DISABLE_JUSTIFY
83
84
85
86
87
88
89
char *punct = NULL;
	/* The closing punctuation that can end sentences. */
char *brackets = NULL;
	/* The closing brackets that can follow closing punctuation and
	 * can end sentences. */
char *quotestr = NULL;
	/* The quoting string.  The default value is set in main(). */
90
#ifdef HAVE_REGEX_H
91
92
93
94
95
96
regex_t quotereg;
	/* The compiled regular expression from the quoting string. */
int quoterc;
	/* Whether it actually compiled. */
char *quoteerr = NULL;
	/* The error message, if it didn't. */
97
#else
98
99
size_t quotelen;
	/* The length of the quoting string in bytes. */
Chris Allegretta's avatar
Chris Allegretta committed
100
#endif
101
102
#endif

103
104
char *answer = NULL;
	/* The answer string used in the statusbar prompt. */
Chris Allegretta's avatar
Chris Allegretta committed
105

106
107
108
ssize_t tabsize = -1;
	/* The width of a tab in spaces.  The default value is set in
	 * main(). */
109

110
111
112
113
#ifndef NANO_TINY
char *backup_dir = NULL;
	/* The directory where we store backup files. */
#endif
114
#ifndef DISABLE_OPERATINGDIR
115
116
117
118
119
char *operating_dir = NULL;
	/* The relative path to the operating directory, which we can't
	 * move outside of. */
char *full_operating_dir = NULL;
	/* The full path to it. */
120
121
#endif

122
#ifndef DISABLE_SPELLER
123
124
char *alt_speller = NULL;
	/* The command to use for the alternate spell checker. */
125
126
#endif

127
shortcut *main_list = NULL;
128
	/* The main shortcut list. */
129
shortcut *whereis_list = NULL;
130
	/* The "Search" shortcut list. */
131
shortcut *replace_list = NULL;
132
133
134
	/* The "Search (to replace)" shortcut list. */
shortcut *replace_list_2 = NULL;
	/* The "Replace with" shortcut list. */
135
shortcut *gotoline_list = NULL;
136
	/* The "Enter line number, column number" shortcut list. */
137
shortcut *writefile_list = NULL;
138
	/* The "File Name to Write" shortcut list. */
139
shortcut *insertfile_list = NULL;
140
141
142
143
144
	/* The "File to insert" shortcut list. */
#ifndef NANO_TINY
shortcut *extcmd_list = NULL;
	/* The "Command to execute" shortcut list. */
#endif
Chris Allegretta's avatar
Chris Allegretta committed
145
#ifndef DISABLE_HELP
146
shortcut *help_list = NULL;
147
	/* The help text shortcut list. */
Chris Allegretta's avatar
Chris Allegretta committed
148
149
#endif
#ifndef DISABLE_SPELLER
150
shortcut *spell_list = NULL;
151
	/* The internal spell checker shortcut list. */
Chris Allegretta's avatar
Chris Allegretta committed
152
#endif
153
#ifndef DISABLE_BROWSER
154
shortcut *browser_list = NULL;
155
	/* The file browser shortcut list. */
156
157
shortcut *whereis_file_list = NULL;
	/* The file browser "Search" shortcut list. */
158
shortcut *gotodir_list = NULL;
159
	/* The "Go To Directory" shortcut list. */
Chris Allegretta's avatar
Chris Allegretta committed
160
#endif
161

162
#ifdef ENABLE_COLOR
163
syntaxtype *syntaxes = NULL;
164
	/* The global list of color syntaxes. */
165
char *syntaxstr = NULL;
166
	/* The color syntax name specified on the command line. */
167
168
#endif

169
170
const shortcut *currshortcut;
	/* The current shortcut list we're using. */
171
#ifndef NANO_TINY
172
toggle *toggles = NULL;
173
	/* The global toggle list. */
174
#endif
Chris Allegretta's avatar
Chris Allegretta committed
175

176
#ifndef NANO_TINY
177
filestruct *search_history = NULL;
178
	/* The search string history list. */
179
filestruct *searchage = NULL;
180
	/* The top of the search string history list. */
181
filestruct *searchbot = NULL;
182
	/* The bottom of the search string history list. */
183
filestruct *replace_history = NULL;
184
	/* The replace string history list. */
185
filestruct *replaceage = NULL;
186
	/* The top of the replace string history list. */
187
filestruct *replacebot = NULL;
188
	/* The bottom of the replace string history list. */
189
190
#endif

191
/* Regular expressions */
192
#ifdef HAVE_REGEX_H
193
194
195
196
197
regex_t search_regexp;
	/* The compiled regular expression to use in searches. */
regmatch_t regmatches[10];
	/* The match positions for parenthetical subexpressions, 10
	 * maximum, used in regular expression searches. */
Chris Allegretta's avatar
Chris Allegretta committed
198
#endif
199

200
201
int reverse_attr = A_REVERSE;
	/* The curses attribute we use for reverse video. */
202
203
204
205
bool curses_ended = FALSE;
	/* Whether endwin() has ended curses mode and statusbar()
	 * should hence write to stderr instead of displaying on the
	 * statusbar. */
206

207
208
209
char *homedir = NULL;
		/* The user's home directory, from $HOME or
		 * /etc/passwd. */
210

211
/* Return the number of entries in the shortcut list s. */
212
size_t length_of_list(const shortcut *s)
213
{
214
    size_t i = 0;
215

216
    for (; s != NULL; s = s->next)
217
218
219
220
	i++;
    return i;
}

221
/* Add a new shortcut to the end of the shortcut list. */
222
void sc_init_one(shortcut **shortcutage, int ctrlval, const char *desc,
223
#ifndef DISABLE_HELP
224
	const char *help,
225
#endif
226
227
	bool blank_after, int metaval, int funcval, int miscval, bool
	view, void (*func)(void))
Chris Allegretta's avatar
Chris Allegretta committed
228
{
229
230
231
    shortcut *s;

    if (*shortcutage == NULL) {
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
232
	*shortcutage = (shortcut *)nmalloc(sizeof(shortcut));
233
234
235
236
	s = *shortcutage;
    } else {
	for (s = *shortcutage; s->next != NULL; s = s->next)
	    ;
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
237
	s->next = (shortcut *)nmalloc(sizeof(shortcut));
238
239
240
	s = s->next; 
    }

241
    s->ctrlval = ctrlval;
242
    s->desc = (desc == NULL) ? "" : _(desc);
243
#ifndef DISABLE_HELP
244
    s->help = (help == NULL) ? "" : _(help);
245
#endif
246
    s->blank_after = blank_after;
247
248
249
    s->metaval = metaval;
    s->funcval = funcval;
    s->miscval = miscval;
Chris Allegretta's avatar
Chris Allegretta committed
250
251
    s->viewok = view;
    s->func = func;
252
    s->next = NULL;
Chris Allegretta's avatar
Chris Allegretta committed
253
254
}

255
256
/* Initialize all shortcut lists.  If unjustify is TRUE, replace the
 * Uncut shortcut in the main shortcut list with UnJustify. */
257
void shortcut_init(bool unjustify)
258
{
259
    /* TRANSLATORS: Try to keep this and following strings at most 10 characters. */
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
260
    const char *cancel_msg = N_("Cancel");
261
262
    const char *get_help_msg = N_("Get Help");
    const char *exit_msg = N_("Exit");
263
    const char *whereis_msg = N_("Where Is");
264
265
266
    const char *prev_page_msg = N_("Prev Page");
    const char *next_page_msg = N_("Next Page");
    const char *go_to_line_msg = N_("Go To Line");
267
    /* TRANSLATORS: Try to keep this and previous strings at most 10 characters. */
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
268
    const char *replace_msg = N_("Replace");
269
#ifndef NANO_TINY
270
    /* TRANSLATORS: Try to keep this at most 16 characters. */
271
272
    const char *whereis_next_msg = N_("Where Is Next");
#endif
273
    /* TRANSLATORS: Try to keep this and following strings at most 10 characters. */
274
275
    const char *first_line_msg = N_("First Line");
    const char *last_line_msg = N_("Last Line");
276
#ifndef NANO_TINY
277
278
    const char *cut_till_end_msg = N_("CutTillEnd");
#endif
279
280
281
282
283
#ifndef DISABLE_JUSTIFY
    const char *beg_of_par_msg = N_("Beg of Par");
    const char *end_of_par_msg = N_("End of Par");
    const char *fulljstify_msg = N_("FullJstify");
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
284
    const char *refresh_msg = N_("Refresh");
285
#ifndef NANO_TINY
286
    const char *case_sens_msg = N_("Case Sens");
287
    const char *backwards_msg = N_("Backwards");
288
#endif
289
290
#ifdef HAVE_REGEX_H
    const char *regexp_msg = N_("Regexp");
291
#endif
292
#ifndef NANO_TINY
293
    /* TRANSLATORS: Try to keep this and previous strings at most 10 characters. */
294
    const char *history_msg = N_("History");
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
295
#ifdef ENABLE_MULTIBUFFER
296
    /* TRANSLATORS: Try to keep this at most 16 characters. */
297
    const char *new_buffer_msg = N_("New Buffer");
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
298
#endif
299
#endif
300
#ifndef DISABLE_BROWSER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
301
    /* TRANSLATORS: Try to keep this and following strings at most 16 characters. */
302
    const char *to_files_msg = N_("To Files");
303
    const char *first_file_msg = N_("First File");
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
304
    /* TRANSLATORS: Try to keep this and previous strings at most 16 characters. */
305
    const char *last_file_msg = N_("Last File");
306
#endif
307
#ifndef DISABLE_HELP
308
    const char *nano_cancel_msg = N_("Cancel the current function");
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
309
    const char *nano_help_msg = N_("Display this help text");
310
    const char *nano_exit_msg =
311
#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
312
	N_("Close the current file buffer/Exit from nano")
313
314
315
316
#else
   	N_("Exit from nano")
#endif
	;
317
318
    const char *nano_writeout_msg =
	N_("Write the current file to disk");
319
320
321
    const char *nano_justify_msg = N_("Justify the current paragraph");
    const char *nano_insert_msg =
	N_("Insert another file into the current one");
322
323
    const char *nano_whereis_msg =
	N_("Search for text within the editor");
324
325
326
327
328
329
    const char *nano_prevpage_msg = N_("Move to the previous screen");
    const char *nano_nextpage_msg = N_("Move to the next screen");
    const char *nano_cut_msg =
	N_("Cut the current line and store it in the cutbuffer");
    const char *nano_uncut_msg =
	N_("Uncut from the cutbuffer into the current line");
330
    const char *nano_cursorpos_msg =
331
	N_("Display the position of the cursor");
332
333
    const char *nano_spell_msg =
	N_("Invoke the spell checker, if available");
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
334
    const char *nano_gotoline_msg = N_("Go to line and column number");
335
    const char *nano_replace_msg = N_("Replace text within the editor");
336
#ifndef NANO_TINY
337
338
    const char *nano_mark_msg = N_("Mark text at the cursor position");
    const char *nano_whereis_next_msg = N_("Repeat last search");
339
340
    const char *nano_copy_msg =
	N_("Copy the current line and store it in the cutbuffer");
341
342
    const char *nano_indentmarked_msg = N_("Indent marked text");
    const char *nano_unindentmarked_msg = N_("Unindent marked text");
343
#endif
344
345
    const char *nano_forward_msg = N_("Move forward one character");
    const char *nano_back_msg = N_("Move back one character");
346
#ifndef NANO_TINY
347
348
    const char *nano_nextword_msg = N_("Move forward one word");
    const char *nano_prevword_msg = N_("Move backward one word");
349
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
350
351
352
353
354
355
    const char *nano_prevline_msg = N_("Move to the previous line");
    const char *nano_nextline_msg = N_("Move to the next line");
    const char *nano_home_msg =
	N_("Move to the beginning of the current line");
    const char *nano_end_msg =
	N_("Move to the end of the current line");
356
357
#ifndef DISABLE_JUSTIFY
    const char *nano_parabegin_msg =
358
	N_("Move to the beginning of the current paragraph");
359
    const char *nano_paraend_msg =
360
	N_("Move to the end of the current paragraph");
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
361
362
363
364
365
366
367
368
369
370
371
#endif
    const char *nano_firstline_msg =
	N_("Move to the first line of the file");
    const char *nano_lastline_msg =
	N_("Move to the last line of the file");
#ifndef NANO_TINY
    const char *nano_bracket_msg = N_("Move to the matching bracket");
    const char *nano_scrollup_msg =
	N_("Scroll up one line without scrolling the cursor");
    const char *nano_scrolldown_msg =
	N_("Scroll down one line without scrolling the cursor");
372
#endif
373
#ifdef ENABLE_MULTIBUFFER
374
    const char *nano_prevfile_msg =
375
	N_("Switch to the previous file buffer");
376
    const char *nano_nextfile_msg =
377
	N_("Switch to the next file buffer");
378
#endif
379
    const char *nano_verbatim_msg =
380
	N_("Insert the next keystroke verbatim");
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
381
    const char *nano_tab_msg =
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
382
	N_("Insert a tab at the cursor position");
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
383
    const char *nano_enter_msg =
384
	N_("Insert a newline at the cursor position");
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
385
386
387
388
    const char *nano_delete_msg =
	N_("Delete the character under the cursor");
    const char *nano_backspace_msg =
	N_("Delete the character to the left of the cursor");
389
#ifndef NANO_TINY
390
391
392
    const char *nano_cut_till_end_msg =
	N_("Cut from the cursor position to the end of the file");
#endif
393
394
#ifndef DISABLE_JUSTIFY
    const char *nano_fulljustify_msg = N_("Justify the entire file");
395
#endif
396
#ifndef NANO_TINY
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
397
398
    const char *nano_wordcount_msg =
	N_("Count the number of words, lines, and characters");
399
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
400
401
    const char *nano_refresh_msg =
	N_("Refresh (redraw) the current screen");
402
#ifndef NANO_TINY
403
404
405
406
    const char *nano_case_msg =
	N_("Make the current search/replace case (in)sensitive");
    const char *nano_reverse_msg =
	N_("Make the current search/replace go backwards");
407
#endif
408
409
#ifdef HAVE_REGEX_H
    const char *nano_regexp_msg = N_("Use regular expressions");
410
#endif
411
#ifndef NANO_TINY
412
413
    const char *nano_history_msg =
	N_("Edit the previous search/replace strings");
414
#endif
415
416
#ifndef DISABLE_BROWSER
    const char *nano_tofiles_msg = N_("Go to file browser");
Chris Allegretta's avatar
Chris Allegretta committed
417
#endif
418
#ifndef NANO_TINY
419
420
    const char *nano_dos_msg = N_("Write file out in DOS format");
    const char *nano_mac_msg = N_("Write file out in Mac format");
421
#endif
422
423
    const char *nano_append_msg = N_("Append to the current file");
    const char *nano_prepend_msg = N_("Prepend to the current file");
424
#ifndef NANO_TINY
425
426
    const char *nano_backup_msg =
	N_("Back up original file when saving");
427
    const char *nano_execute_msg = N_("Execute external command");
428
#endif
429
#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
430
431
432
    const char *nano_multibuffer_msg = N_("Insert into new buffer");
#endif
#ifndef DISABLE_BROWSER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
433
    const char *nano_exitbrowser_msg = N_("Exit from the file browser");
434
435
436
437
    const char *nano_firstfile_msg =
	N_("Go to the first file in the list");
    const char *nano_lastfile_msg =
	N_("Go to the last file in the list");
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
438
    const char *nano_gotodir_msg = N_("Go to directory");
Chris Allegretta's avatar
Chris Allegretta committed
439
#endif
440
#endif /* !DISABLE_HELP */
Chris Allegretta's avatar
Chris Allegretta committed
441

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
442
/* The following macro is to be used in calling sc_init_one().  The
443
444
 * point is that sc_init_one() takes 10 arguments, unless DISABLE_HELP
 * is defined, when the 4th one should not be there. */
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
445
#ifndef DISABLE_HELP
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
446
#define IFHELP(help, nextvar) help, nextvar
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
447
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
448
#define IFHELP(help, nextvar) nextvar
449
#endif
450

451
452
453
    free_shortcutage(&main_list);

    sc_init_one(&main_list, NANO_HELP_KEY, get_help_msg,
454
455
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW,
456
#ifndef DISABLE_HELP
457
	do_help_void
458
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
459
	nano_disabled_msg
460
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
461
	);
Chris Allegretta's avatar
Chris Allegretta committed
462

463
464
    sc_init_one(&main_list, NANO_EXIT_KEY,
#ifdef ENABLE_MULTIBUFFER
465
	/* TRANSLATORS: Try to keep this at most 10 characters. */
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
466
	openfile != NULL && openfile != openfile->next ? N_("Close") :
467
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
468
	exit_msg, IFHELP(nano_exit_msg, FALSE), NANO_NO_KEY,
469
	NANO_EXIT_FKEY, NANO_NO_KEY, VIEW, do_exit);
Chris Allegretta's avatar
Chris Allegretta committed
470

471
    /* TRANSLATORS: Try to keep this at most 10 characters. */
472
    sc_init_one(&main_list, NANO_WRITEOUT_KEY, N_("WriteOut"),
473
474
	IFHELP(nano_writeout_msg, FALSE), NANO_NO_KEY,
	NANO_WRITEOUT_FKEY, NANO_NO_KEY, NOVIEW, do_writeout_void);
Chris Allegretta's avatar
Chris Allegretta committed
475

476
    /* TRANSLATORS: Try to keep this at most 10 characters. */
477
    sc_init_one(&main_list, NANO_JUSTIFY_KEY, N_("Justify"),
478
	IFHELP(nano_justify_msg, TRUE), NANO_NO_KEY, NANO_JUSTIFY_FKEY,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
479
	NANO_NO_KEY, NOVIEW,
480
#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
481
	do_justify_void
482
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
483
	nano_disabled_msg
484
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
485
	);
486

487
    /* We allow inserting files in view mode if multibuffers are
488
489
490
491
492
     * available, so that we can view multiple files.  If we're using
     * restricted mode, inserting files is disabled, since it allows
     * reading from or writing to files not specified on the command
     * line. */

493
    /* TRANSLATORS: Try to keep this at most 10 characters. */
494
    sc_init_one(&main_list, NANO_INSERTFILE_KEY, N_("Read File"),
495
496
	IFHELP(nano_insert_msg, FALSE), NANO_NO_KEY,
	NANO_INSERTFILE_FKEY, NANO_NO_KEY,
497
#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
498
	VIEW
499
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
500
	NOVIEW
501
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
502
	, !ISSET(RESTRICTED) ? do_insertfile_void : nano_disabled_msg);
Chris Allegretta's avatar
Chris Allegretta committed
503

504
    sc_init_one(&main_list, NANO_WHEREIS_KEY, whereis_msg,
505
	IFHELP(nano_whereis_msg, FALSE), NANO_NO_KEY, NANO_WHEREIS_FKEY,
506
	NANO_NO_KEY, VIEW, do_search);
Chris Allegretta's avatar
Chris Allegretta committed
507

508
    sc_init_one(&main_list, NANO_PREVPAGE_KEY, prev_page_msg,
509
510
	IFHELP(nano_prevpage_msg, FALSE), NANO_NO_KEY,
	NANO_PREVPAGE_FKEY, NANO_NO_KEY, VIEW, do_page_up);
Chris Allegretta's avatar
Chris Allegretta committed
511

512
    sc_init_one(&main_list, NANO_NEXTPAGE_KEY, next_page_msg,
513
514
	IFHELP(nano_nextpage_msg, TRUE), NANO_NO_KEY,
	NANO_NEXTPAGE_FKEY, NANO_NO_KEY, VIEW, do_page_down);
Chris Allegretta's avatar
Chris Allegretta committed
515

516
    /* TRANSLATORS: Try to keep this at most 10 characters. */
517
    sc_init_one(&main_list, NANO_CUT_KEY, N_("Cut Text"),
518
	IFHELP(nano_cut_msg, FALSE), NANO_NO_KEY, NANO_CUT_FKEY,
519
	NANO_NO_KEY, NOVIEW, do_cut_text_void);
Chris Allegretta's avatar
Chris Allegretta committed
520

521
    if (unjustify)
522
    /* TRANSLATORS: Try to keep this at most 10 characters. */
523
	sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, N_("UnJustify"),
524
		IFHELP(NULL, FALSE), NANO_NO_KEY, NANO_UNJUSTIFY_FKEY,
525
		NANO_NO_KEY, NOVIEW, NULL);
526
    else
527
    /* TRANSLATORS: Try to keep this at most 10 characters. */
528
	sc_init_one(&main_list, NANO_UNCUT_KEY, N_("UnCut Txt"),
529
530
		IFHELP(nano_uncut_msg, FALSE), NANO_NO_KEY,
		NANO_UNCUT_FKEY, NANO_NO_KEY, NOVIEW, do_uncut_text);
Chris Allegretta's avatar
Chris Allegretta committed
531

532
    /* TRANSLATORS: Try to keep this at most 10 characters. */
533
    sc_init_one(&main_list, NANO_CURSORPOS_KEY, N_("Cur Pos"),
534
535
	IFHELP(nano_cursorpos_msg, FALSE), NANO_NO_KEY,
	NANO_CURSORPOS_FKEY, NANO_NO_KEY, VIEW, do_cursorpos_void);
Chris Allegretta's avatar
Chris Allegretta committed
536

537
538
539
    /* If we're using restricted mode, spell checking is disabled
     * because it allows reading from or writing to files not specified
     * on the command line. */
540
    /* TRANSLATORS: Try to keep this at most 10 characters. */
541
    sc_init_one(&main_list, NANO_SPELL_KEY, N_("To Spell"),
542
	IFHELP(nano_spell_msg, TRUE), NANO_NO_KEY, NANO_SPELL_FKEY,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
543
	NANO_NO_KEY, NOVIEW,
544
#ifndef DISABLE_SPELLER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
545
	!ISSET(RESTRICTED) ? do_spell :
546
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
547
	nano_disabled_msg);
548

549
550
551
552
    sc_init_one(&main_list, NANO_GOTOLINE_KEY, go_to_line_msg,
	IFHELP(nano_gotoline_msg, FALSE), NANO_GOTOLINE_ALTKEY,
	NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW,
	do_gotolinecolumn_void);
553

554
    sc_init_one(&main_list, NANO_REPLACE_KEY, replace_msg,
555
	IFHELP(nano_replace_msg, FALSE), NANO_ALT_REPLACE_KEY,
556
	NANO_REPLACE_FKEY, NANO_NO_KEY, NOVIEW, do_replace);
Chris Allegretta's avatar
Chris Allegretta committed
557

558
#ifndef NANO_TINY
559
    /* TRANSLATORS: Try to keep this at most 16 characters. */
560
    sc_init_one(&main_list, NANO_MARK_KEY, N_("Mark Text"),
561
	IFHELP(nano_mark_msg, FALSE), NANO_MARK_ALTKEY, NANO_MARK_FKEY,
562
	NANO_NO_KEY, VIEW, do_mark);
563

564
565
566
    sc_init_one(&main_list, NANO_NO_KEY, whereis_next_msg,
	IFHELP(nano_whereis_next_msg, TRUE), NANO_WHEREIS_NEXT_KEY,
	NANO_WHEREIS_NEXT_FKEY, NANO_NO_KEY, VIEW, do_research);
567
568

    sc_init_one(&main_list, NANO_NO_KEY, N_("Copy Text"),
569
	IFHELP(nano_copy_msg, FALSE), NANO_COPY_KEY, NANO_NO_KEY,
570
	NANO_COPY_ALTKEY, NOVIEW, do_copy_text);
571
572
573
574
575
576
577
578
579
580

    sc_init_one(&main_list, NANO_NO_KEY, N_("Indent Text"),
	IFHELP(nano_indentmarked_msg, FALSE), NANO_INDENTMARKED_KEY,
	NANO_NO_KEY, NANO_INDENTMARKED_ALTKEY, NOVIEW,
	do_indent_marked_void);

    sc_init_one(&main_list, NANO_NO_KEY, N_("Unindent Text"),
	IFHELP(nano_unindentmarked_msg, TRUE), NANO_UNINDENTMARKED_KEY,
	NANO_NO_KEY, NANO_UNINDENTMARKED_ALTKEY, NOVIEW,
	do_unindent_marked_void);
581
582
#endif

583
    sc_init_one(&main_list, NANO_FORWARD_KEY, N_("Forward"),
584
585
	IFHELP(nano_forward_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_right);
Chris Allegretta's avatar
Chris Allegretta committed
586

587
    sc_init_one(&main_list, NANO_BACK_KEY, N_("Back"),
588
589
	IFHELP(nano_back_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_left);
590

591
#ifndef NANO_TINY
592
    sc_init_one(&main_list, NANO_NEXTWORD_KEY, N_("Next Word"),
593
	IFHELP(nano_nextword_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
594
	NANO_NO_KEY, VIEW, do_next_word_void);
595

596
    sc_init_one(&main_list, NANO_NO_KEY, N_("Prev Word"),
597
598
599
	IFHELP(nano_prevword_msg, FALSE), NANO_PREVWORD_KEY,
	NANO_NO_KEY, NANO_NO_KEY, VIEW, do_prev_word_void);
#endif
600

601
602
603
    sc_init_one(&main_list, NANO_PREVLINE_KEY, N_("Prev Line"),
	IFHELP(nano_prevline_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_up);
604

605
606
607
    sc_init_one(&main_list, NANO_NEXTLINE_KEY, N_("Next Line"),
	IFHELP(nano_nextline_msg, TRUE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_down);
608

609
610
611
612
613
    sc_init_one(&main_list, NANO_HOME_KEY, N_("Home"),
	IFHELP(nano_home_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_home);

    sc_init_one(&main_list, NANO_END_KEY, N_("End"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
614
	IFHELP(nano_end_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
615
	NANO_NO_KEY, VIEW, do_end);
616

617
618
#ifndef DISABLE_JUSTIFY
    sc_init_one(&main_list, NANO_NO_KEY, beg_of_par_msg,
619
620
	IFHELP(nano_parabegin_msg, FALSE), NANO_PARABEGIN_ALTKEY,
	NANO_NO_KEY, NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
621
622

    sc_init_one(&main_list, NANO_NO_KEY, end_of_par_msg,
623
624
	IFHELP(nano_paraend_msg, FALSE), NANO_PARAEND_ALTKEY,
	NANO_NO_KEY, NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
625
#endif
626

627
    sc_init_one(&main_list, NANO_NO_KEY, first_line_msg,
628
629
	IFHELP(nano_firstline_msg, FALSE), NANO_FIRSTLINE_ALTKEY,
	NANO_NO_KEY, NANO_FIRSTLINE_ALTKEY2, VIEW, do_first_line);
630
631

    sc_init_one(&main_list, NANO_NO_KEY, last_line_msg,
632
633
634
635
	IFHELP(nano_lastline_msg, TRUE), NANO_LASTLINE_ALTKEY,
	NANO_NO_KEY, NANO_LASTLINE_ALTKEY2, VIEW, do_last_line);

#ifndef NANO_TINY
636
637
638
    sc_init_one(&main_list, NANO_BRACKET_KEY, N_("Find Other Bracket"),
	IFHELP(nano_bracket_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_find_bracket);
639
640
641
642
643
644
645
646
647

    sc_init_one(&main_list, NANO_NO_KEY, N_("Scroll Up"),
	IFHELP(nano_scrollup_msg, FALSE), NANO_SCROLLUP_KEY,
	NANO_NO_KEY, NANO_SCROLLUP_ALTKEY, VIEW, do_scroll_up);

    sc_init_one(&main_list, NANO_NO_KEY, N_("Scroll Down"),
	IFHELP(nano_scrolldown_msg, TRUE), NANO_SCROLLDOWN_KEY,
	NANO_NO_KEY, NANO_SCROLLDOWN_ALTKEY, VIEW, do_scroll_down);
#endif
648

649
#ifdef ENABLE_MULTIBUFFER
650
    sc_init_one(&main_list, NANO_NO_KEY, N_("Previous File"),
651
652
653
	IFHELP(nano_prevfile_msg, FALSE), NANO_PREVFILE_KEY,
	NANO_NO_KEY, NANO_PREVFILE_ALTKEY, VIEW,
	switch_to_prev_buffer_void);
654

655
    sc_init_one(&main_list, NANO_NO_KEY, N_("Next File"),
656
	IFHELP(nano_nextfile_msg, TRUE), NANO_NEXTFILE_KEY, NANO_NO_KEY,
657
	NANO_NEXTFILE_ALTKEY, VIEW, switch_to_next_buffer_void);
658
#endif
659

660
    sc_init_one(&main_list, NANO_NO_KEY, N_("Verbatim Input"),
661
662
	IFHELP(nano_verbatim_msg, FALSE), NANO_VERBATIM_KEY,
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_verbatim_input);
663

664
665
666
667
668
669
670
671
672
673
674
675
    sc_init_one(&main_list, NANO_TAB_KEY, N_("Tab"),
	IFHELP(nano_tab_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, NOVIEW, do_tab);

    sc_init_one(&main_list, NANO_ENTER_KEY, N_("Enter"),
	IFHELP(nano_enter_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, NOVIEW, do_enter);

    sc_init_one(&main_list, NANO_DELETE_KEY, N_("Delete"),
	IFHELP(nano_delete_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, NOVIEW, do_delete);

676
677
678
679
680
681
682
    sc_init_one(&main_list, NANO_BACKSPACE_KEY, N_("Backspace")
#ifndef NANO_TINY
	, IFHELP(nano_backspace_msg, FALSE)
#else
	, IFHELP(nano_backspace_msg, TRUE)
#endif
	, NANO_NO_KEY, NANO_NO_KEY,
683
	NANO_NO_KEY, NOVIEW, do_backspace);
684

685
686
687
688
689
690
#ifndef NANO_TINY
    sc_init_one(&main_list, NANO_NO_KEY, cut_till_end_msg,
	IFHELP(nano_cut_till_end_msg, TRUE), NANO_CUTTILLEND_ALTKEY,
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end);
#endif

691
692
#ifndef DISABLE_JUSTIFY
    sc_init_one(&main_list, NANO_NO_KEY, fulljstify_msg,
693
	IFHELP(nano_fulljustify_msg, FALSE), NANO_FULLJUSTIFY_ALTKEY,
694
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
695
696
#endif

697
#ifndef NANO_TINY
698
699
700
    sc_init_one(&main_list, NANO_NO_KEY, N_("Word Count"),
	IFHELP(nano_wordcount_msg, FALSE), NANO_WORDCOUNT_KEY,
	NANO_NO_KEY, NANO_NO_KEY, VIEW, do_wordlinechar_count);
701
702
#endif

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
703
    sc_init_one(&main_list, NANO_REFRESH_KEY, refresh_msg
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
704
#ifndef NANO_TINY
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
705
	, IFHELP(nano_refresh_msg, TRUE)
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
706
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
707
	, IFHELP(nano_refresh_msg, FALSE)
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
708
709
#endif
	, NANO_NO_KEY, NANO_NO_KEY, NANO_NO_KEY, VIEW, total_refresh);
710

711
    free_shortcutage(&whereis_list);
712

713
    sc_init_one(&whereis_list, NANO_HELP_KEY, get_help_msg,
714
715
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW,
716
#ifndef DISABLE_HELP
717
	do_help_void
718
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
719
	nano_disabled_msg
720
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
721
	);
722

723
    sc_init_one(&whereis_list, NANO_CANCEL_KEY, cancel_msg,
724
725
	IFHELP(nano_cancel_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
726

727
    sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, first_line_msg,
728
	IFHELP(nano_firstline_msg, FALSE), NANO_FIRSTLINE_ALTKEY,
729
730
	NANO_FIRSTLINE_FKEY, NANO_FIRSTLINE_ALTKEY2, VIEW,
	do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
731

732
    sc_init_one(&whereis_list, NANO_LASTLINE_KEY, last_line_msg,
733
	IFHELP(nano_lastline_msg, FALSE), NANO_LASTLINE_ALTKEY,
734
	NANO_LASTLINE_FKEY, NANO_LASTLINE_ALTKEY2, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
735

736
    sc_init_one(&whereis_list, NANO_TOOTHERSEARCH_KEY, replace_msg,
737
	IFHELP(nano_replace_msg, FALSE), NANO_NO_KEY, NANO_REPLACE_FKEY,
738
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
739

740
    sc_init_one(&whereis_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
741
742
	IFHELP(nano_gotoline_msg, FALSE), NANO_NO_KEY,
	NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW, NULL);
743

744
#ifndef DISABLE_JUSTIFY
745
    sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, beg_of_par_msg,
746
747
	IFHELP(nano_parabegin_msg, FALSE), NANO_PARABEGIN_ALTKEY,
	NANO_NO_KEY, NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
748

749
    sc_init_one(&whereis_list, NANO_PARAEND_KEY, end_of_par_msg,
750
751
	IFHELP(nano_paraend_msg, FALSE), NANO_PARAEND_ALTKEY,
	NANO_NO_KEY, NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
752
753
#endif

754
#ifndef NANO_TINY
755
    sc_init_one(&whereis_list, NANO_NO_KEY, case_sens_msg,
756
	IFHELP(nano_case_msg, FALSE), TOGGLE_CASE_KEY, NANO_NO_KEY,
757
	NANO_NO_KEY, VIEW, NULL);
758

759
    sc_init_one(&whereis_list, NANO_NO_KEY, backwards_msg,
760
761
	IFHELP(nano_reverse_msg, FALSE), TOGGLE_BACKWARDS_KEY,
	NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL);
762
#endif
Chris Allegretta's avatar
Chris Allegretta committed
763

764
#ifdef HAVE_REGEX_H
765
    sc_init_one(&whereis_list, NANO_NO_KEY, regexp_msg,
766
	IFHELP(nano_regexp_msg, FALSE), NANO_REGEXP_KEY, NANO_NO_KEY,
767
	NANO_NO_KEY, VIEW, NULL);
768
#endif
769

770
#ifndef NANO_TINY
771
    sc_init_one(&whereis_list, NANO_PREVLINE_KEY, history_msg,
772
773
	IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
774
775

    sc_init_one(&whereis_list, NANO_CUTTILLEND_KEY, cut_till_end_msg,
776
	IFHELP(nano_cut_till_end_msg, FALSE), NANO_CUTTILLEND_ALTKEY,
777
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end);
778
#endif
779
780
781

#ifndef DISABLE_JUSTIFY
    sc_init_one(&whereis_list, NANO_FULLJUSTIFY_KEY, fulljstify_msg,
782
	IFHELP(nano_fulljustify_msg, FALSE), NANO_FULLJUSTIFY_ALTKEY,
783
784
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
#endif
785

786
    free_shortcutage(&replace_list);
787

788
    sc_init_one(&replace_list, NANO_HELP_KEY, get_help_msg,
789
790
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW,
791
#ifndef DISABLE_HELP
792
	do_help_void
793
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
794
	nano_disabled_msg
795
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
796
	);
797

798
    sc_init_one(&replace_list, NANO_CANCEL_KEY, cancel_msg,
799
800
	IFHELP(nano_cancel_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
801

802
    sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, first_line_msg,
803
	IFHELP(nano_firstline_msg, FALSE), NANO_FIRSTLINE_ALTKEY,
804
805
	NANO_FIRSTLINE_FKEY, NANO_FIRSTLINE_ALTKEY2, VIEW,
	do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
806

807
    sc_init_one(&replace_list, NANO_LASTLINE_KEY, last_line_msg,
808
	IFHELP(nano_lastline_msg, FALSE), NANO_LASTLINE_ALTKEY,
809
	NANO_LASTLINE_FKEY, NANO_LASTLINE_ALTKEY2, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
810

811
    /* TRANSLATORS: Try to keep this at most 12 characters. */
812
    sc_init_one(&replace_list, NANO_TOOTHERSEARCH_KEY, N_("No Replace"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
813
814
	IFHELP(nano_whereis_msg, FALSE), NANO_NO_KEY, NANO_REPLACE_FKEY,
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
815

816
    sc_init_one(&replace_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
817
818
	IFHELP(nano_gotoline_msg, FALSE), NANO_NO_KEY,
	NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW, NULL);
819

820
#ifndef NANO_TINY
821
    sc_init_one(&replace_list, NANO_NO_KEY, case_sens_msg,
822
	IFHELP(nano_case_msg, FALSE), TOGGLE_CASE_KEY, NANO_NO_KEY,
823
	NANO_NO_KEY, VIEW, NULL);
824

825
    sc_init_one(&replace_list, NANO_NO_KEY, backwards_msg,
826
827
	IFHELP(nano_reverse_msg, FALSE), TOGGLE_BACKWARDS_KEY,
	NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL);
828
#endif
829

830
#ifdef HAVE_REGEX_H
831
    sc_init_one(&replace_list, NANO_NO_KEY, regexp_msg,
832
	IFHELP(nano_regexp_msg, FALSE), NANO_REGEXP_KEY, NANO_NO_KEY,
833
	NANO_NO_KEY, VIEW, NULL);
834
#endif
835

836
#ifndef NANO_TINY
837
    sc_init_one(&replace_list, NANO_PREVLINE_KEY, history_msg,
838
839
	IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
840
#endif
841

842
    free_shortcutage(&replace_list_2);
843

844
    sc_init_one(&replace_list_2, NANO_HELP_KEY, get_help_msg,
845
846
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW,
847
#ifndef DISABLE_HELP
848
	do_help_void
849
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
850
	nano_disabled_msg
851
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
852
	);
853

854
    sc_init_one(&replace_list_2, NANO_CANCEL_KEY, cancel_msg,
855
856
	IFHELP(nano_cancel_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
857

858
    sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, first_line_msg,
859
	IFHELP(nano_firstline_msg, FALSE), NANO_FIRSTLINE_ALTKEY,
860
861
	NANO_FIRSTLINE_FKEY, NANO_FIRSTLINE_ALTKEY2, VIEW,
	do_first_line);
862

863
    sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, last_line_msg,
864
	IFHELP(nano_lastline_msg, FALSE), NANO_LASTLINE_ALTKEY,
865
	NANO_LASTLINE_FKEY, NANO_LASTLINE_ALTKEY2, VIEW, do_last_line);
866

867
#ifndef NANO_TINY
868
    sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, history_msg,
869
870
	IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
871
872
#endif

873
    free_shortcutage(&gotoline_list);
Chris Allegretta's avatar
Chris Allegretta committed
874

875
    sc_init_one(&gotoline_list, NANO_HELP_KEY, get_help_msg,
876
877
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW,
878
#ifndef DISABLE_HELP
879
	do_help_void
880
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
881
	nano_disabled_msg
882
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
883
	);
884

885
    sc_init_one(&gotoline_list, NANO_CANCEL_KEY, cancel_msg,
886
887
	IFHELP(nano_cancel_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
888

889
    sc_init_one(&gotoline_list, NANO_FIRSTLINE_KEY, first_line_msg,
890
	IFHELP(nano_firstline_msg, FALSE), NANO_FIRSTLINE_ALTKEY,
891
892
	NANO_FIRSTLINE_FKEY, NANO_FIRSTLINE_ALTKEY2, VIEW,
	do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
893

894
    sc_init_one(&gotoline_list, NANO_LASTLINE_KEY, last_line_msg,
895
	IFHELP(nano_lastline_msg, FALSE), NANO_LASTLINE_ALTKEY,
896
	NANO_LASTLINE_FKEY, NANO_LASTLINE_ALTKEY2, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
897

898
    sc_init_one(&gotoline_list, NANO_TOOTHERWHEREIS_KEY,
899
	N_("Go To Text"), IFHELP(nano_whereis_msg, FALSE), NANO_NO_KEY,
900
	NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL);
901

902
    free_shortcutage(&writefile_list);
Chris Allegretta's avatar
Chris Allegretta committed
903

904
    sc_init_one(&writefile_list, NANO_HELP_KEY, get_help_msg,
905
906
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW,
907
#ifndef DISABLE_HELP
908
	do_help_void
909
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
910
	nano_disabled_msg
911
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
912
	);
913

914
    sc_init_one(&writefile_list, NANO_CANCEL_KEY, cancel_msg,
915
916
	IFHELP(nano_cancel_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
917

918
#ifndef DISABLE_BROWSER
919
920
    /* If we're using restricted mode, the file browser is disabled.
     * It's useless since inserting files is disabled. */
921

922
    if (!ISSET(RESTRICTED))
923
	sc_init_one(&writefile_list, NANO_TOFILES_KEY, to_files_msg,
924
925
		IFHELP(nano_tofiles_msg, FALSE), NANO_NO_KEY,
		NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
926
#endif
Chris Allegretta's avatar
Chris Allegretta committed
927

928
#ifndef NANO_TINY
929
930
931
932
933
934
    /* If we're using restricted mode, the DOS format, Mac format,
     * append, prepend, and backup toggles are disabled.  The first and
     * second are useless since inserting files is disabled, the third
     * and fourth are disabled because they allow writing to files not
     * specified on the command line, and the fifth is useless since
     * backups are disabled. */
935

936
    if (!ISSET(RESTRICTED))
937
	/* TRANSLATORS: Try to keep this at most 16 characters. */
938
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("DOS Format"),
939
940
		IFHELP(nano_dos_msg, FALSE), TOGGLE_DOS_KEY,
		NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
941

942
    if (!ISSET(RESTRICTED))
943
	/* TRANSLATORS: Try to keep this at most 16 characters. */
944
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Mac Format"),
945
946
		IFHELP(nano_mac_msg, FALSE), TOGGLE_MAC_KEY,
		NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
947
948
#endif

949
    if (!ISSET(RESTRICTED))
950
	/* TRANSLATORS: Try to keep this at most 16 characters. */
951
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Append"),
952
953
		IFHELP(nano_append_msg, FALSE), NANO_APPEND_KEY,
		NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
954

955
    if (!ISSET(RESTRICTED))
956
	/* TRANSLATORS: Try to keep this at most 16 characters. */
957
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Prepend"),
958
959
		IFHELP(nano_prepend_msg, FALSE), NANO_PREPEND_KEY,
		NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
960

961
#ifndef NANO_TINY
962
    if (!ISSET(RESTRICTED))
963
	/* TRANSLATORS: Try to keep this at most 16 characters. */
964
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Backup File"),
965
966
		IFHELP(nano_backup_msg, FALSE), TOGGLE_BACKUP_KEY,
		NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
967
968
#endif

969
    free_shortcutage(&insertfile_list);
970

971
    sc_init_one(&insertfile_list, NANO_HELP_KEY, get_help_msg,
972
973
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW,
974
#ifndef DISABLE_HELP
975
	do_help_void
976
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
977
	nano_disabled_msg
978
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
979
	);
980

981
    sc_init_one(&insertfile_list, NANO_CANCEL_KEY, cancel_msg,
982
983
	IFHELP(nano_cancel_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
984

985
#ifndef DISABLE_BROWSER
986
987
    /* If we're using restricted mode, the file browser is disabled.
     * It's useless since inserting files is disabled. */
988
    if (!ISSET(RESTRICTED))
989
	sc_init_one(&insertfile_list, NANO_TOFILES_KEY, to_files_msg,
990
991
		IFHELP(nano_tofiles_msg, FALSE), NANO_NO_KEY,
		NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
992
#endif
993

994
#ifndef NANO_TINY
995
996
    /* If we're using restricted mode, command execution is disabled.
     * It's useless since inserting files is disabled. */
997

998
    if (!ISSET(RESTRICTED))
999
	sc_init_one(&insertfile_list, NANO_TOOTHERINSERT_KEY,
1000
		/* TRANSLATORS: Try to keep this at most 22 characters. */
1001
1002
		N_("Execute Command"), IFHELP(nano_execute_msg, FALSE),
		NANO_NO_KEY, NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
1003

1004
#ifdef ENABLE_MULTIBUFFER
1005
1006
    /* If we're using restricted mode, the multibuffer toggle is
     * disabled.  It's useless since inserting files is disabled. */
1007

1008
    if (!ISSET(RESTRICTED))
1009
	sc_init_one(&insertfile_list, NANO_NO_KEY, new_buffer_msg,
1010
1011
1012
		IFHELP(nano_multibuffer_msg, FALSE),
		TOGGLE_MULTIBUFFER_KEY, NANO_NO_KEY, NANO_NO_KEY,
		NOVIEW, NULL);
1013
#endif
1014
#endif
1015

1016
#ifndef NANO_TINY
1017
    free_shortcutage(&extcmd_list);
Chris Allegretta's avatar
Chris Allegretta committed
1018

1019
    sc_init_one(&extcmd_list, NANO_HELP_KEY, get_help_msg,
1020
1021
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW,
1022
#ifndef DISABLE_HELP
1023
	do_help_void
1024
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1025
	nano_disabled_msg
1026
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1027
	);
1028

1029
    sc_init_one(&extcmd_list, NANO_CANCEL_KEY, cancel_msg,
1030
1031
	IFHELP(nano_cancel_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
1032

1033
    sc_init_one(&extcmd_list, NANO_TOOTHERINSERT_KEY, N_("Insert File"),
1034
	IFHELP(nano_insert_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
1035
	NANO_NO_KEY, VIEW, NULL);
1036

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1037
#ifdef ENABLE_MULTIBUFFER
1038
    sc_init_one(&extcmd_list, NANO_NO_KEY, new_buffer_msg,
1039
	IFHELP(nano_multibuffer_msg, FALSE), TOGGLE_MULTIBUFFER_KEY,
1040
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
1041
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1042
#endif
1043

1044
1045
1046
1047
#ifndef DISABLE_HELP
    free_shortcutage(&help_list);

    sc_init_one(&help_list, NANO_REFRESH_KEY, refresh_msg,
1048
1049
	IFHELP(nano_refresh_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
1050
1051

    sc_init_one(&help_list, NANO_EXIT_KEY, exit_msg,
1052
1053
	IFHELP(nano_exit_msg, FALSE), NANO_NO_KEY, NANO_EXIT_FKEY,
	NANO_NO_KEY, VIEW, NULL);
1054
1055

    sc_init_one(&help_list, NANO_PREVPAGE_KEY, prev_page_msg,
1056
1057
	IFHELP(nano_prevpage_msg, FALSE), NANO_NO_KEY,
	NANO_PREVPAGE_FKEY, NANO_NO_KEY, VIEW, NULL);
1058
1059

    sc_init_one(&help_list, NANO_NEXTPAGE_KEY, next_page_msg,
1060
1061
	IFHELP(nano_nextpage_msg, FALSE), NANO_NO_KEY,
	NANO_NEXTPAGE_FKEY, NANO_NO_KEY, VIEW, NULL);
1062
1063

    sc_init_one(&help_list, NANO_PREVLINE_KEY, N_("Prev Line"),
1064
	IFHELP(nano_prevline_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
1065
1066
1067
	NANO_NO_KEY, VIEW, NULL);

    sc_init_one(&help_list, NANO_NEXTLINE_KEY, N_("Next Line"),
1068
	IFHELP(nano_nextline_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
1069
	NANO_NO_KEY, VIEW, NULL);
1070
1071
1072
1073
1074
1075
1076
1077

    sc_init_one(&help_list, NANO_NO_KEY, first_line_msg,
	IFHELP(nano_firstline_msg, FALSE), NANO_FIRSTLINE_ALTKEY,
	NANO_NO_KEY, NANO_FIRSTLINE_ALTKEY2, VIEW, NULL);

    sc_init_one(&help_list, NANO_NO_KEY, last_line_msg,
	IFHELP(nano_lastline_msg, TRUE), NANO_LASTLINE_ALTKEY,
	NANO_NO_KEY, NANO_LASTLINE_ALTKEY2, VIEW, NULL);
1078
1079
1080
1081
1082
1083
#endif

#ifndef DISABLE_SPELLER
    free_shortcutage(&spell_list);

    sc_init_one(&spell_list, NANO_HELP_KEY, get_help_msg,
1084
1085
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW,
1086
#ifndef DISABLE_HELP
1087
	do_help_void
1088
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1089
	nano_disabled_msg
1090
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1091
	);
1092
1093

    sc_init_one(&spell_list, NANO_CANCEL_KEY, cancel_msg,
1094
1095
	IFHELP(nano_cancel_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
1096
1097
#endif

1098
#ifndef DISABLE_BROWSER
1099
    free_shortcutage(&browser_list);
1100

1101
    sc_init_one(&browser_list, NANO_HELP_KEY, get_help_msg,
1102
1103
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW, NULL);
1104

1105
    sc_init_one(&browser_list, NANO_EXIT_KEY, exit_msg,
1106
1107
	IFHELP(nano_exitbrowser_msg, FALSE), NANO_NO_KEY,
	NANO_EXIT_FKEY, NANO_NO_KEY, VIEW, NULL);
1108

1109
    sc_init_one(&browser_list, NANO_PREVPAGE_KEY, prev_page_msg,
1110
1111
	IFHELP(nano_prevpage_msg, FALSE), NANO_NO_KEY,
	NANO_PREVPAGE_FKEY, NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1112

1113
    sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, next_page_msg,
1114
1115
	IFHELP(nano_nextpage_msg, FALSE), NANO_NO_KEY,
	NANO_NEXTPAGE_FKEY, NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1116

1117
    sc_init_one(&browser_list, NANO_WHEREIS_KEY, whereis_msg,
1118
1119
	IFHELP(nano_whereis_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
1120
1121

    sc_init_one(&browser_list, NANO_NO_KEY, whereis_next_msg,
1122
	IFHELP(nano_whereis_next_msg, FALSE), NANO_WHEREIS_NEXT_KEY,
1123
1124
	NANO_WHEREIS_NEXT_FKEY, NANO_NO_KEY, VIEW, NULL);

1125
    /* TRANSLATORS: Try to keep this at most 22 characters. */
1126
    sc_init_one(&browser_list, NANO_GOTOLINE_KEY, N_("Go To Dir"),
1127
	IFHELP(nano_gotodir_msg, FALSE), NANO_GOTOLINE_ALTKEY,
1128
	NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW, NULL);
Rocco Corsi's avatar
   
Rocco Corsi committed
1129

1130
1131
1132
    free_shortcutage(&whereis_file_list);

    sc_init_one(&whereis_file_list, NANO_HELP_KEY, get_help_msg,
1133
1134
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW,
1135
1136
1137
1138
1139
1140
1141
1142
#ifndef DISABLE_HELP
	do_browser_help
#else
	nano_disabled_msg
#endif
	);

    sc_init_one(&whereis_file_list, NANO_CANCEL_KEY, cancel_msg,
1143
1144
	IFHELP(nano_cancel_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
1145
1146

    sc_init_one(&whereis_file_list, NANO_FIRSTFILE_KEY, first_file_msg,
1147
	IFHELP(nano_firstfile_msg, FALSE), NANO_FIRSTFILE_ALTKEY,
1148
1149
	NANO_FIRSTFILE_FKEY, NANO_FIRSTFILE_ALTKEY2, VIEW,
	do_first_file);
1150
1151

    sc_init_one(&whereis_file_list, NANO_LASTFILE_KEY, last_file_msg,
1152
	IFHELP(nano_lastfile_msg, FALSE), NANO_LASTFILE_ALTKEY,
1153
	NANO_LASTFILE_FKEY, NANO_LASTFILE_ALTKEY2, VIEW, do_last_file);
1154
1155
1156

#ifndef NANO_SMALL
    sc_init_one(&whereis_file_list, NANO_NO_KEY, case_sens_msg,
1157
	IFHELP(nano_case_msg, FALSE), TOGGLE_CASE_KEY, NANO_NO_KEY,
1158
1159
1160
	NANO_NO_KEY, VIEW, NULL);

    sc_init_one(&whereis_file_list, NANO_NO_KEY, backwards_msg,
1161
1162
	IFHELP(nano_reverse_msg, FALSE), TOGGLE_BACKWARDS_KEY,
	NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL);
1163
1164
1165
1166
#endif

#ifdef HAVE_REGEX_H
    sc_init_one(&whereis_file_list, NANO_NO_KEY, regexp_msg,
1167
	IFHELP(nano_regexp_msg, FALSE), NANO_REGEXP_KEY, NANO_NO_KEY,
1168
1169
1170
1171
1172
	NANO_NO_KEY, VIEW, NULL);
#endif

#ifndef NANO_SMALL
    sc_init_one(&whereis_file_list, NANO_PREVLINE_KEY, history_msg,
1173
1174
	IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
1175
1176
#endif

1177
    free_shortcutage(&gotodir_list);
1178

1179
    sc_init_one(&gotodir_list, NANO_HELP_KEY, get_help_msg,
1180
1181
	IFHELP(nano_help_msg, FALSE), NANO_NO_KEY, NANO_HELP_FKEY,
	NANO_NO_KEY, VIEW,
1182
#ifndef DISABLE_HELP
1183
	do_help_void
1184
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1185
	nano_disabled_msg
1186
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1187
	);
Chris Allegretta's avatar
Chris Allegretta committed
1188

1189
    sc_init_one(&gotodir_list, NANO_CANCEL_KEY, cancel_msg,
1190
1191
	IFHELP(nano_cancel_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1192
1193
#endif

1194
    currshortcut = main_list;
1195

1196
#ifndef NANO_TINY
1197
    toggle_init();
1198
#endif
1199
}
1200

1201
/* Free the given shortcut. */
1202
1203
1204
void free_shortcutage(shortcut **shortcutage)
{
    assert(shortcutage != NULL);
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1205

1206
1207
1208
1209
1210
1211
1212
    while (*shortcutage != NULL) {
	shortcut *ps = *shortcutage;
	*shortcutage = (*shortcutage)->next;
	free(ps);
    }
}

1213
#ifndef NANO_TINY
1214
/* Add a new toggle to the end of the global toggle list. */
1215
1216
void toggle_init_one(int val, const char *desc, bool blank_after, long
	flag)
1217
1218
1219
1220
{
    toggle *u;

    if (toggles == NULL) {
1221
	toggles = (toggle *)nmalloc(sizeof(toggle));
1222
1223
1224
1225
	u = toggles;
    } else {
	for (u = toggles; u->next != NULL; u = u->next)
	    ;
1226
	u->next = (toggle *)nmalloc(sizeof(toggle));
1227
1228
1229
1230
	u = u->next;
    }

    u->val = val;
1231
    u->desc = (desc == NULL) ? "" : _(desc);
1232
    u->blank_after = blank_after;
1233
1234
1235
1236
    u->flag = flag;
    u->next = NULL;
}

1237
/* Initialize the global toggle list. */
1238
1239
1240
1241
1242
1243
1244
void toggle_init(void)
{
    /* There is no need to reinitialize the toggles.  They can't
     * change. */
    if (toggles != NULL)
	return;

1245
    toggle_init_one(TOGGLE_NOHELP_KEY, N_("Help mode"), FALSE, NO_HELP);
1246

1247
    toggle_init_one(TOGGLE_CONST_KEY,
1248
	N_("Constant cursor position display"), FALSE, CONST_UPDATE);
1249
1250

    toggle_init_one(TOGGLE_MORESPACE_KEY,
1251
	N_("Use of more space for editing"), FALSE, MORE_SPACE);
1252

1253
1254
1255
1256
1257
1258
1259
    toggle_init_one(TOGGLE_SMOOTH_KEY, N_("Smooth scrolling"),
#ifdef ENABLE_NANORC
	FALSE
#else
	TRUE
#endif
	, SMOOTH_SCROLL);
1260
1261
1262

#ifdef ENABLE_NANORC
    toggle_init_one(TOGGLE_WHITESPACE_KEY, N_("Whitespace display"),
1263
1264
1265
1266
1267
1268
#ifdef ENABLE_COLOR
	FALSE
#else
	TRUE
#endif
	, WHITESPACE_DISPLAY);
1269
#endif
1270
1271
1272

#ifdef ENABLE_COLOR
    toggle_init_one(TOGGLE_SYNTAX_KEY, N_("Color syntax highlighting"),
1273
	TRUE, NO_COLOR_SYNTAX);
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1274
#endif
1275

1276
    toggle_init_one(TOGGLE_SMARTHOME_KEY, N_("Smart home key"), FALSE,
1277
1278
	SMART_HOME);

1279
    toggle_init_one(TOGGLE_AUTOINDENT_KEY, N_("Auto indent"), FALSE,
1280
1281
	AUTOINDENT);

1282
1283
    toggle_init_one(TOGGLE_CUTTOEND_KEY, N_("Cut to end"), FALSE,
	CUT_TO_END);
1284

1285
#ifndef DISABLE_WRAPPING
1286
    toggle_init_one(TOGGLE_WRAP_KEY, N_("Long line wrapping"), FALSE,
1287
	NO_WRAP);
1288
#endif
1289

1290
    toggle_init_one(TOGGLE_TABSTOSPACES_KEY,
1291
1292
1293
1294
1295
1296
1297
	N_("Conversion of typed tabs to spaces"),
#if defined(ENABLE_MULTIBUFFER) || !defined(DISABLE_MOUSE)
	!ISSET(RESTRICTED) ? TRUE : FALSE
#else
	FALSE
#endif
	, TABS_TO_SPACES);
1298

1299
1300
1301
    /* If we're using restricted mode, the backup toggle is disabled.
     * It's useless since backups are disabled. */
    if (!ISSET(RESTRICTED))
1302
	toggle_init_one(TOGGLE_BACKUP_KEY, N_("Backup files"), FALSE,
1303
		BACKUP_FILE);
1304
1305
1306
1307
1308
1309

#ifdef ENABLE_MULTIBUFFER
    /* If we're using restricted mode, the multibuffer toggle is
     * disabled.  It's useless since inserting files is disabled. */
    if (!ISSET(RESTRICTED))
	toggle_init_one(TOGGLE_MULTIBUFFER_KEY,
1310
		N_("Multiple file buffers"), FALSE, MULTIBUFFER);
1311
#endif
1312

1313
#ifndef DISABLE_MOUSE
1314
1315
    toggle_init_one(TOGGLE_MOUSE_KEY, N_("Mouse support"), FALSE,
	USE_MOUSE);
1316
1317
#endif

1318
1319
1320
1321
    /* If we're using restricted mode, the DOS/Mac conversion toggle is
     * disabled.  It's useless since inserting files is disabled. */
    if (!ISSET(RESTRICTED))
	toggle_init_one(TOGGLE_NOCONVERT_KEY,
1322
1323
		N_("No conversion from DOS/Mac format"), FALSE,
		NO_CONVERT);
1324
1325
1326
1327

    /* If we're using restricted mode, the suspend toggle is disabled.
     * It's useless since suspending is disabled. */
    if (!ISSET(RESTRICTED))
1328
1329
	toggle_init_one(TOGGLE_SUSPEND_KEY, N_("Suspend"), FALSE,
	SUSPEND);
1330
}
1331
#endif /* !NANO_TINY */
1332

1333
1334
1335
#ifdef DEBUG
/* This function is used to gracefully return all the memory we've used.
 * It should be called just before calling exit().  Practically, the
1336
1337
 * only effect is to cause a segmentation fault if the various data
 * structures got bolloxed earlier.  Thus, we don't bother having this
Chris Allegretta's avatar
Chris Allegretta committed
1338
1339
 * function unless debugging is turned on. */
void thanks_for_all_the_fish(void)
1340
{
1341
1342
1343
1344
    delwin(topwin);
    delwin(edit);
    delwin(bottomwin);

Chris Allegretta's avatar
Chris Allegretta committed
1345
1346
1347
#ifndef DISABLE_JUSTIFY
    if (quotestr != NULL)
	free(quotestr);
1348
1349
#ifdef HAVE_REGEX_H
    regfree(&quotereg);
1350
1351
    if (quoteerr != NULL)
	free(quoteerr);
1352
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1353
#endif
1354
#ifndef NANO_TINY
1355
1356
1357
    if (backup_dir != NULL)
        free(backup_dir);
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1358
#ifndef DISABLE_OPERATINGDIR
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
    if (operating_dir != NULL)
	free(operating_dir);
    if (full_operating_dir != NULL)
	free(full_operating_dir);
#endif
    if (last_search != NULL)
	free(last_search);
    if (last_replace != NULL)
	free(last_replace);
#ifndef DISABLE_SPELLER
    if (alt_speller != NULL)
	free(alt_speller);
1371
#endif
1372
1373
1374
    if (answer != NULL)
	free(answer);
    if (cutbuffer != NULL)
Chris Allegretta's avatar
Chris Allegretta committed
1375
	free_filestruct(cutbuffer);
1376
1377
1378
1379
#ifndef DISABLE_JUSTIFY
    if (jusbuffer != NULL)
	free_filestruct(jusbuffer);
#endif
1380
1381
1382
1383
    free_shortcutage(&main_list);
    free_shortcutage(&whereis_list);
    free_shortcutage(&replace_list);
    free_shortcutage(&replace_list_2);
1384
    free_shortcutage(&gotoline_list);
1385
1386
    free_shortcutage(&writefile_list);
    free_shortcutage(&insertfile_list);
1387
1388
1389
#ifndef NANO_TINY
    free_shortcutage(&extcmd_list);
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1390
#ifndef DISABLE_HELP
Chris Allegretta's avatar
Chris Allegretta committed
1391
    free_shortcutage(&help_list);
Chris Allegretta's avatar
Chris Allegretta committed
1392
1393
#endif
#ifndef DISABLE_SPELLER
1394
    free_shortcutage(&spell_list);
Chris Allegretta's avatar
Chris Allegretta committed
1395
#endif
1396
1397
#ifndef DISABLE_BROWSER
    free_shortcutage(&browser_list);
Chris Allegretta's avatar
Chris Allegretta committed
1398
    free_shortcutage(&gotodir_list);
1399
#endif
1400
#ifndef NANO_TINY
1401
    /* Free the memory associated with each toggle. */
1402
1403
    while (toggles != NULL) {
	toggle *t = toggles;
1404

1405
1406
1407
1408
	toggles = toggles->next;
	free(t);
    }
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1409
    /* Free the memory associated with each open file buffer. */
1410
    if (openfile != NULL)
1411
	free_openfilestruct(openfile);
Chris Allegretta's avatar
Chris Allegretta committed
1412
#ifdef ENABLE_COLOR
1413
1414
    if (syntaxstr != NULL)
	free(syntaxstr);
Chris Allegretta's avatar
Chris Allegretta committed
1415
1416
1417
1418
1419
1420
1421
1422
    while (syntaxes != NULL) {
	syntaxtype *bill = syntaxes;

	free(syntaxes->desc);
	while (syntaxes->extensions != NULL) {
	    exttype *bob = syntaxes->extensions;

	    syntaxes->extensions = bob->next;
1423
	    free(bob->ext_regex);
1424
1425
1426
1427
	    if (bob->ext != NULL) {
		regfree(bob->ext);
		free(bob->ext);
	    }
Chris Allegretta's avatar
Chris Allegretta committed
1428
1429
1430
1431
1432
1433
	    free(bob);
	}
	while (syntaxes->color != NULL) {
	    colortype *bob = syntaxes->color;

	    syntaxes->color = bob->next;
1434
	    free(bob->start_regex);
1435
1436
1437
1438
	    if (bob->start != NULL) {
		regfree(bob->start);
		free(bob->start);
	    }
1439
1440
	    if (bob->end_regex != NULL)
		free(bob->end_regex);
1441
	    if (bob->end != NULL) {
1442
		regfree(bob->end);
1443
1444
		free(bob->end);
	    }
Chris Allegretta's avatar
Chris Allegretta committed
1445
1446
1447
1448
1449
1450
	    free(bob);
	}
	syntaxes = syntaxes->next;
	free(bill);
    }
#endif /* ENABLE_COLOR */
1451
#ifndef NANO_TINY
1452
    /* Free the search and replace history lists. */
1453
1454
1455
1456
    if (searchage != NULL)
	free_filestruct(searchage);
    if (replaceage != NULL)
	free_filestruct(replaceage);
1457
#endif
1458
#ifdef ENABLE_NANORC
1459
1460
    if (homedir != NULL)
	free(homedir);
1461
#endif
1462
}
1463
#endif /* DEBUG */