global.c 45.4 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
	int metaval, int funcval, int miscval, bool view, void
227
	(*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
247
248
    s->metaval = metaval;
    s->funcval = funcval;
    s->miscval = miscval;
Chris Allegretta's avatar
Chris Allegretta committed
249
250
    s->viewok = view;
    s->func = func;
251
    s->next = NULL;
Chris Allegretta's avatar
Chris Allegretta committed
252
253
}

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

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
434
435
436
/* The following macro is to be used in calling sc_init_one().  The
 * point is that sc_init_one() takes 9 arguments, unless DISABLE_HELP is
 * defined, when the 4th one should not be there. */
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
437
#ifndef DISABLE_HELP
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
438
#define IFHELP(help, nextvar) help, nextvar
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
439
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
440
#define IFHELP(help, nextvar) nextvar
441
#endif
442

443
444
445
    free_shortcutage(&main_list);

    sc_init_one(&main_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
446
447
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
448
#ifndef DISABLE_HELP
449
	do_help_void
450
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
451
	nano_disabled_msg
452
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
453
	);
Chris Allegretta's avatar
Chris Allegretta committed
454

455
456
    sc_init_one(&main_list, NANO_EXIT_KEY,
#ifdef ENABLE_MULTIBUFFER
457
	/* TRANSLATORS: Try to keep this at most 10 characters. */
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
458
	openfile != NULL && openfile != openfile->next ? N_("Close") :
459
#endif
460
461
	exit_msg, IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
	NANO_NO_KEY, VIEW, do_exit);
Chris Allegretta's avatar
Chris Allegretta committed
462

463
    /* TRANSLATORS: Try to keep this at most 10 characters. */
464
465
466
    sc_init_one(&main_list, NANO_WRITEOUT_KEY, N_("WriteOut"),
	IFHELP(nano_writeout_msg, NANO_NO_KEY), NANO_WRITEOUT_FKEY,
	NANO_NO_KEY, NOVIEW, do_writeout_void);
Chris Allegretta's avatar
Chris Allegretta committed
467

468
    /* TRANSLATORS: Try to keep this at most 10 characters. */
469
    sc_init_one(&main_list, NANO_JUSTIFY_KEY, N_("Justify"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
470
471
	IFHELP(nano_justify_msg, NANO_NO_KEY), NANO_JUSTIFY_FKEY,
	NANO_NO_KEY, NOVIEW,
472
#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
473
	do_justify_void
474
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
475
	nano_disabled_msg
476
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
477
	);
478

479
    /* We allow inserting files in view mode if multibuffers are
480
481
482
483
484
     * 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. */

485
    /* TRANSLATORS: Try to keep this at most 10 characters. */
486
487
488
    sc_init_one(&main_list, NANO_INSERTFILE_KEY, N_("Read File"),
	IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_INSERTFILE_FKEY,
	NANO_NO_KEY,
489
#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
490
	VIEW
491
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
492
	NOVIEW
493
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
494
	, !ISSET(RESTRICTED) ? do_insertfile_void : nano_disabled_msg);
Chris Allegretta's avatar
Chris Allegretta committed
495

496
    sc_init_one(&main_list, NANO_WHEREIS_KEY, whereis_msg,
497
498
	IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_WHEREIS_FKEY,
	NANO_NO_KEY, VIEW, do_search);
Chris Allegretta's avatar
Chris Allegretta committed
499

500
501
502
    sc_init_one(&main_list, NANO_PREVPAGE_KEY, prev_page_msg,
	IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
	NANO_NO_KEY, VIEW, do_page_up);
Chris Allegretta's avatar
Chris Allegretta committed
503

504
505
506
    sc_init_one(&main_list, NANO_NEXTPAGE_KEY, next_page_msg,
	IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
	NANO_NO_KEY, VIEW, do_page_down);
Chris Allegretta's avatar
Chris Allegretta committed
507

508
    /* TRANSLATORS: Try to keep this at most 10 characters. */
509
    sc_init_one(&main_list, NANO_CUT_KEY, N_("Cut Text"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
510
511
	IFHELP(nano_cut_msg, NANO_NO_KEY), NANO_CUT_FKEY, NANO_NO_KEY,
	NOVIEW, do_cut_text);
Chris Allegretta's avatar
Chris Allegretta committed
512

513
    if (unjustify)
514
    /* TRANSLATORS: Try to keep this at most 10 characters. */
515
516
	sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, N_("UnJustify"),
		IFHELP(NULL, NANO_NO_KEY), NANO_UNJUSTIFY_FKEY,
517
		NANO_NO_KEY, NOVIEW, NULL);
518
    else
519
    /* TRANSLATORS: Try to keep this at most 10 characters. */
520
	sc_init_one(&main_list, NANO_UNCUT_KEY, N_("UnCut Txt"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
521
522
		IFHELP(nano_uncut_msg, NANO_NO_KEY), NANO_UNCUT_FKEY,
		NANO_NO_KEY, NOVIEW, do_uncut_text);
Chris Allegretta's avatar
Chris Allegretta committed
523

524
    /* TRANSLATORS: Try to keep this at most 10 characters. */
525
526
527
    sc_init_one(&main_list, NANO_CURSORPOS_KEY, N_("Cur Pos"),
	IFHELP(nano_cursorpos_msg, NANO_NO_KEY), NANO_CURSORPOS_FKEY,
	NANO_NO_KEY, VIEW, do_cursorpos_void);
Chris Allegretta's avatar
Chris Allegretta committed
528

529
530
531
    /* 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. */
532
    /* TRANSLATORS: Try to keep this at most 10 characters. */
533
    sc_init_one(&main_list, NANO_SPELL_KEY, N_("To Spell"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
534
535
	IFHELP(nano_spell_msg, NANO_NO_KEY), NANO_SPELL_FKEY,
	NANO_NO_KEY, NOVIEW,
536
#ifndef DISABLE_SPELLER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
537
	!ISSET(RESTRICTED) ? do_spell :
538
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
539
	nano_disabled_msg);
540

541
    sc_init_one(&main_list, NANO_GOTOLINE_KEY, go_to_line_msg,
542
	IFHELP(nano_gotoline_msg, NANO_GOTOLINE_ALTKEY),
543
544
	NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW,
	do_gotolinecolumn_void);
545

546
    sc_init_one(&main_list, NANO_REPLACE_KEY, replace_msg,
547
548
	IFHELP(nano_replace_msg, NANO_ALT_REPLACE_KEY),
	NANO_REPLACE_FKEY, NANO_NO_KEY, NOVIEW, do_replace);
Chris Allegretta's avatar
Chris Allegretta committed
549

550
#ifndef NANO_TINY
551
    /* TRANSLATORS: Try to keep this at most 16 characters. */
552
553
    sc_init_one(&main_list, NANO_MARK_KEY, N_("Mark Text"),
	IFHELP(nano_mark_msg, NANO_MARK_ALTKEY), NANO_MARK_FKEY,
554
	NANO_NO_KEY, VIEW, do_mark);
555

556
    sc_init_one(&main_list, NANO_NO_KEY, whereis_next_msg,
557
	IFHELP(nano_whereis_next_msg, NANO_WHEREIS_NEXT_KEY),
558
	NANO_WHEREIS_NEXT_FKEY, NANO_NO_KEY, VIEW, do_research);
559
560
#endif

561
562
563
564
565
566
567
568
#ifndef DISABLE_HELP
    /* This entry is blank, in order to make the help text easier to
     * read. */
    sc_init_one(&main_list, NANO_NO_KEY, NULL,
	IFHELP(NULL, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY, VIEW,
	NULL);
#endif

569
570
571
    sc_init_one(&main_list, NANO_PREVLINE_KEY, N_("Prev Line"),
	IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_up);
Chris Allegretta's avatar
Chris Allegretta committed
572

573
574
575
    sc_init_one(&main_list, NANO_NEXTLINE_KEY, N_("Next Line"),
	IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_down);
Chris Allegretta's avatar
Chris Allegretta committed
576

577
    sc_init_one(&main_list, NANO_FORWARD_KEY, N_("Forward"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
578
579
	IFHELP(nano_forward_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, do_right);
Chris Allegretta's avatar
Chris Allegretta committed
580

581
    sc_init_one(&main_list, NANO_BACK_KEY, N_("Back"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
582
583
	IFHELP(nano_back_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, do_left);
Chris Allegretta's avatar
Chris Allegretta committed
584

585
    sc_init_one(&main_list, NANO_HOME_KEY, N_("Home"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
586
587
	IFHELP(nano_home_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, do_home);
Chris Allegretta's avatar
Chris Allegretta committed
588

589
    sc_init_one(&main_list, NANO_END_KEY, N_("End"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
590
591
	IFHELP(nano_end_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, do_end);
Chris Allegretta's avatar
Chris Allegretta committed
592

593
    sc_init_one(&main_list, NANO_DELETE_KEY, N_("Delete"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
594
595
	IFHELP(nano_delete_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	NOVIEW, do_delete);
Chris Allegretta's avatar
Chris Allegretta committed
596

597
598
599
    sc_init_one(&main_list, NANO_BACKSPACE_KEY, N_("Backspace"),
	IFHELP(nano_backspace_msg, NANO_NO_KEY), NANO_NO_KEY,
	NANO_NO_KEY, NOVIEW, do_backspace);
Chris Allegretta's avatar
Chris Allegretta committed
600

601
    sc_init_one(&main_list, NANO_TAB_KEY, N_("Tab"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
602
603
	IFHELP(nano_tab_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	NOVIEW, do_tab);
Chris Allegretta's avatar
Chris Allegretta committed
604

605
    sc_init_one(&main_list, NANO_ENTER_KEY, N_("Enter"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
606
607
	IFHELP(nano_enter_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	NOVIEW, do_enter);
608

609
610
611
612
    sc_init_one(&main_list, NANO_REFRESH_KEY, refresh_msg,
	IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, total_refresh);

613
614
615
616
617
618
619
620
#ifndef DISABLE_HELP
    /* This entry is blank, in order to make the help text easier to
     * read. */
    sc_init_one(&main_list, NANO_NO_KEY, NULL,
	IFHELP(NULL, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY, VIEW,
	NULL);
#endif

621
#ifndef NANO_TINY
622
623
    sc_init_one(&main_list, NANO_NEXTWORD_KEY, N_("Next Word"),
	IFHELP(nano_nextword_msg, NANO_NO_KEY), NANO_NO_KEY,
624
	NANO_NO_KEY, VIEW, do_next_word_void);
625

626
627
    sc_init_one(&main_list, NANO_NO_KEY, N_("Prev Word"),
	IFHELP(nano_prevword_msg, NANO_PREVWORD_KEY), NANO_NO_KEY,
628
	NANO_NO_KEY, VIEW, do_prev_word_void);
629
630
631

    sc_init_one(&main_list, NANO_NO_KEY, N_("Word Count"),
	IFHELP(nano_wordcount_msg, NANO_WORDCOUNT_KEY), NANO_NO_KEY,
632
	NANO_NO_KEY, VIEW, do_wordlinechar_count);
633

634
635
636
    sc_init_one(&main_list, NANO_NO_KEY, N_("Scroll Up"),
	IFHELP(nano_scrollup_msg, NANO_SCROLLUP_KEY), NANO_NO_KEY,
	NANO_SCROLLUP_ALTKEY, VIEW, do_scroll_up);
637

638
639
640
    sc_init_one(&main_list, NANO_NO_KEY, N_("Scroll Down"),
	IFHELP(nano_scrolldown_msg, NANO_SCROLLDOWN_KEY), NANO_NO_KEY,
	NANO_SCROLLDOWN_ALTKEY, VIEW, do_scroll_down);
641
#endif
642

643
644
645
#ifndef DISABLE_JUSTIFY
    sc_init_one(&main_list, NANO_NO_KEY, beg_of_par_msg,
	IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
646
	NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
647
648
649

    sc_init_one(&main_list, NANO_NO_KEY, end_of_par_msg,
	IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
650
	NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
651
#endif
652

653
654
655
656
657
658
659
660
    sc_init_one(&main_list, NANO_NO_KEY, first_line_msg,
	IFHELP(nano_firstline_msg, NANO_FIRSTLINE_ALTKEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_first_line);

    sc_init_one(&main_list, NANO_NO_KEY, last_line_msg,
	IFHELP(nano_lastline_msg, NANO_LASTLINE_ALTKEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_last_line);

661
#ifdef ENABLE_MULTIBUFFER
662
    sc_init_one(&main_list, NANO_NO_KEY, N_("Previous File"),
663
664
	IFHELP(nano_prevfile_msg, NANO_PREVFILE_KEY), NANO_NO_KEY,
	NANO_PREVFILE_ALTKEY, VIEW, switch_to_prev_buffer_void);
665

666
    sc_init_one(&main_list, NANO_NO_KEY, N_("Next File"),
667
668
	IFHELP(nano_nextfile_msg, NANO_NEXTFILE_KEY), NANO_NO_KEY,
	NANO_NEXTFILE_ALTKEY, VIEW, switch_to_next_buffer_void);
669
#endif
670

671
672
673
674
    sc_init_one(&main_list, NANO_NO_KEY, N_("Verbatim Input"),
	IFHELP(nano_verbatim_msg, NANO_VERBATIM_KEY), NANO_NO_KEY,
	NANO_NO_KEY, NOVIEW, do_verbatim_input);

675
#ifndef NANO_TINY
676
677
678
679
680
    sc_init_one(&main_list, NANO_NO_KEY, cut_till_end_msg,
	IFHELP(nano_cut_till_end_msg, NANO_CUTTILLEND_ALTKEY),
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end);
#endif

681
682
#ifndef DISABLE_JUSTIFY
    sc_init_one(&main_list, NANO_NO_KEY, fulljstify_msg,
683
684
	IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY),
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
685
686
#endif

687
#ifndef NANO_TINY
688
689
690
    sc_init_one(&main_list, NANO_NO_KEY, N_("Find Other Bracket"),
	IFHELP(nano_bracket_msg, NANO_BRACKET_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_find_bracket);
691
692
693
694
695
696
697
698
699

#ifndef DISABLE_HELP
    /* This entry is blank, in order to make the help text easier to
     * read.  It's at the end of the list in order to separate the
     * shortcut keys from the toggles. */
    sc_init_one(&main_list, NANO_NO_KEY, NULL,
	IFHELP(NULL, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY, VIEW,
	NULL);
#endif
700
701
#endif

702
    free_shortcutage(&whereis_list);
703

704
    sc_init_one(&whereis_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
705
706
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
707
#ifndef DISABLE_HELP
708
	do_help_void
709
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
710
	nano_disabled_msg
711
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
712
	);
713

714
    sc_init_one(&whereis_list, NANO_CANCEL_KEY, cancel_msg,
715
716
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
717

718
    sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, first_line_msg,
719
720
	IFHELP(nano_firstline_msg, NANO_FIRSTLINE_ALTKEY),
	NANO_FIRSTLINE_FKEY, NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
721

722
    sc_init_one(&whereis_list, NANO_LASTLINE_KEY, last_line_msg,
723
724
	IFHELP(nano_lastline_msg, NANO_LASTLINE_ALTKEY),
	NANO_LASTLINE_FKEY, NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
725

726
    sc_init_one(&whereis_list, NANO_TOOTHERSEARCH_KEY, replace_msg,
727
	IFHELP(nano_replace_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
728
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
729

730
731
    sc_init_one(&whereis_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
	IFHELP(nano_gotoline_msg, NANO_NO_KEY), NANO_GOTOLINE_FKEY,
732
	NANO_NO_KEY, VIEW, NULL);
733

734
#ifndef DISABLE_JUSTIFY
735
    sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, beg_of_par_msg,
736
	IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
737
	NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
738

739
    sc_init_one(&whereis_list, NANO_PARAEND_KEY, end_of_par_msg,
740
	IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
741
	NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
742
743
#endif

744
#ifndef NANO_TINY
745
746
    sc_init_one(&whereis_list, NANO_NO_KEY, case_sens_msg,
	IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
747
	NANO_NO_KEY, VIEW, NULL);
748

749
    sc_init_one(&whereis_list, NANO_NO_KEY, backwards_msg,
750
	IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
751
	NANO_NO_KEY, VIEW, NULL);
752
#endif
Chris Allegretta's avatar
Chris Allegretta committed
753

754
#ifdef HAVE_REGEX_H
755
    sc_init_one(&whereis_list, NANO_NO_KEY, regexp_msg,
756
	IFHELP(nano_regexp_msg, NANO_REGEXP_KEY), NANO_NO_KEY,
757
	NANO_NO_KEY, VIEW, NULL);
758
#endif
759

760
#ifndef NANO_TINY
761
    sc_init_one(&whereis_list, NANO_PREVLINE_KEY, history_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
762
763
	IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
764
765
766
767

    sc_init_one(&whereis_list, NANO_CUTTILLEND_KEY, cut_till_end_msg,
	IFHELP(nano_cut_till_end_msg, NANO_CUTTILLEND_ALTKEY),
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end);
768
#endif
769
770
771
772
773
774

#ifndef DISABLE_JUSTIFY
    sc_init_one(&whereis_list, NANO_FULLJUSTIFY_KEY, fulljstify_msg,
	IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY),
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
#endif
775

776
    free_shortcutage(&replace_list);
777

778
    sc_init_one(&replace_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
779
780
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
781
#ifndef DISABLE_HELP
782
	do_help_void
783
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
784
	nano_disabled_msg
785
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
786
	);
787

788
    sc_init_one(&replace_list, NANO_CANCEL_KEY, cancel_msg,
789
790
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
791

792
    sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, first_line_msg,
793
794
	IFHELP(nano_firstline_msg, NANO_FIRSTLINE_ALTKEY),
	NANO_FIRSTLINE_FKEY, NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
795

796
    sc_init_one(&replace_list, NANO_LASTLINE_KEY, last_line_msg,
797
798
	IFHELP(nano_lastline_msg, NANO_LASTLINE_ALTKEY),
	NANO_LASTLINE_FKEY, NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
799

800
    /* TRANSLATORS: Try to keep this at most 12 characters. */
801
    sc_init_one(&replace_list, NANO_TOOTHERSEARCH_KEY, N_("No Replace"),
802
	IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
803
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
804

805
806
    sc_init_one(&replace_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
	IFHELP(nano_gotoline_msg, NANO_NO_KEY), NANO_GOTOLINE_FKEY,
807
	NANO_NO_KEY, VIEW, NULL);
808

809
#ifndef NANO_TINY
810
811
    sc_init_one(&replace_list, NANO_NO_KEY, case_sens_msg,
	IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
812
	NANO_NO_KEY, VIEW, NULL);
813

814
    sc_init_one(&replace_list, NANO_NO_KEY, backwards_msg,
815
	IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
816
	NANO_NO_KEY, VIEW, NULL);
817
#endif
818

819
#ifdef HAVE_REGEX_H
820
    sc_init_one(&replace_list, NANO_NO_KEY, regexp_msg,
821
	IFHELP(nano_regexp_msg, NANO_REGEXP_KEY), NANO_NO_KEY,
822
	NANO_NO_KEY, VIEW, NULL);
823
#endif
824

825
#ifndef NANO_TINY
826
    sc_init_one(&replace_list, NANO_PREVLINE_KEY, history_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
827
828
	IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
829
#endif
830

831
    free_shortcutage(&replace_list_2);
832

833
    sc_init_one(&replace_list_2, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
834
835
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
836
#ifndef DISABLE_HELP
837
	do_help_void
838
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
839
	nano_disabled_msg
840
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
841
	);
842

843
    sc_init_one(&replace_list_2, NANO_CANCEL_KEY, cancel_msg,
844
845
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
846

847
    sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, first_line_msg,
848
849
	IFHELP(nano_firstline_msg, NANO_FIRSTLINE_ALTKEY),
	NANO_FIRSTLINE_FKEY, NANO_NO_KEY, VIEW, do_first_line);
850

851
    sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, last_line_msg,
852
853
	IFHELP(nano_lastline_msg, NANO_LASTLINE_ALTKEY),
	NANO_LASTLINE_FKEY, NANO_NO_KEY, VIEW, do_last_line);
854

855
#ifndef NANO_TINY
856
    sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, history_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
857
858
	IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
859
860
#endif

861
    free_shortcutage(&gotoline_list);
Chris Allegretta's avatar
Chris Allegretta committed
862

863
    sc_init_one(&gotoline_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
864
865
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
866
#ifndef DISABLE_HELP
867
	do_help_void
868
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
869
	nano_disabled_msg
870
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
871
	);
872

873
    sc_init_one(&gotoline_list, NANO_CANCEL_KEY, cancel_msg,
874
875
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
876

877
    sc_init_one(&gotoline_list, NANO_FIRSTLINE_KEY, first_line_msg,
878
879
	IFHELP(nano_firstline_msg, NANO_FIRSTLINE_ALTKEY),
	NANO_FIRSTLINE_FKEY, NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
880

881
    sc_init_one(&gotoline_list, NANO_LASTLINE_KEY, last_line_msg,
882
883
	IFHELP(nano_lastline_msg, NANO_LASTLINE_ALTKEY),
	NANO_LASTLINE_FKEY, NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
884

885
886
    sc_init_one(&gotoline_list, NANO_TOOTHERWHEREIS_KEY,
	N_("Go To Text"), IFHELP(nano_whereis_msg, NANO_NO_KEY),
887
	NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL);
888

889
    free_shortcutage(&writefile_list);
Chris Allegretta's avatar
Chris Allegretta committed
890

891
    sc_init_one(&writefile_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
892
893
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
894
#ifndef DISABLE_HELP
895
	do_help_void
896
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
897
	nano_disabled_msg
898
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
899
	);
900

901
    sc_init_one(&writefile_list, NANO_CANCEL_KEY, cancel_msg,
902
903
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
904

905
#ifndef DISABLE_BROWSER
906
907
    /* If we're using restricted mode, the file browser is disabled.
     * It's useless since inserting files is disabled. */
908

909
    if (!ISSET(RESTRICTED))
910
	sc_init_one(&writefile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
911
		IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
912
		NANO_NO_KEY, NOVIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
913
#endif
Chris Allegretta's avatar
Chris Allegretta committed
914

915
#ifndef NANO_TINY
916
917
918
919
920
921
    /* 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. */
922

923
    if (!ISSET(RESTRICTED))
924
	/* TRANSLATORS: Try to keep this at most 16 characters. */
925
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("DOS Format"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
926
		IFHELP(nano_dos_msg, TOGGLE_DOS_KEY), NANO_NO_KEY,
927
		NANO_NO_KEY, NOVIEW, NULL);
928

929
    if (!ISSET(RESTRICTED))
930
	/* TRANSLATORS: Try to keep this at most 16 characters. */
931
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Mac Format"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
932
		IFHELP(nano_mac_msg, TOGGLE_MAC_KEY), NANO_NO_KEY,
933
		NANO_NO_KEY, NOVIEW, NULL);
934
935
#endif

936
    if (!ISSET(RESTRICTED))
937
	/* TRANSLATORS: Try to keep this at most 16 characters. */
938
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Append"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
939
		IFHELP(nano_append_msg, NANO_APPEND_KEY), NANO_NO_KEY,
940
		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_("Prepend"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
945
		IFHELP(nano_prepend_msg, NANO_PREPEND_KEY), NANO_NO_KEY,
946
		NANO_NO_KEY, NOVIEW, NULL);
947

948
#ifndef NANO_TINY
949
    if (!ISSET(RESTRICTED))
950
	/* TRANSLATORS: Try to keep this at most 16 characters. */
951
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Backup File"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
952
		IFHELP(nano_backup_msg, TOGGLE_BACKUP_KEY), NANO_NO_KEY,
953
		NANO_NO_KEY, NOVIEW, NULL);
954
955
#endif

956
    free_shortcutage(&insertfile_list);
957

958
    sc_init_one(&insertfile_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
959
960
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
961
#ifndef DISABLE_HELP
962
	do_help_void
963
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
964
	nano_disabled_msg
965
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
966
	);
967

968
    sc_init_one(&insertfile_list, NANO_CANCEL_KEY, cancel_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
969
970
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
971

972
#ifndef DISABLE_BROWSER
973
974
    /* If we're using restricted mode, the file browser is disabled.
     * It's useless since inserting files is disabled. */
975
    if (!ISSET(RESTRICTED))
976
	sc_init_one(&insertfile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
977
		IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
978
		NANO_NO_KEY, NOVIEW, NULL);
979
#endif
980

981
#ifndef NANO_TINY
982
983
    /* If we're using restricted mode, command execution is disabled.
     * It's useless since inserting files is disabled. */
984

985
    if (!ISSET(RESTRICTED))
986
	sc_init_one(&insertfile_list, NANO_TOOTHERINSERT_KEY,
987
		/* TRANSLATORS: Try to keep this at most 22 characters. */
988
		N_("Execute Command"), IFHELP(nano_execute_msg,
989
		NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
990

991
#ifdef ENABLE_MULTIBUFFER
992
993
    /* If we're using restricted mode, the multibuffer toggle is
     * disabled.  It's useless since inserting files is disabled. */
994

995
    if (!ISSET(RESTRICTED))
996
	sc_init_one(&insertfile_list, NANO_NO_KEY, new_buffer_msg,
997
		IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY),
998
		NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
999
#endif
1000
#endif
1001

1002
#ifndef NANO_TINY
1003
    free_shortcutage(&extcmd_list);
Chris Allegretta's avatar
Chris Allegretta committed
1004

1005
    sc_init_one(&extcmd_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1006
1007
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
1008
#ifndef DISABLE_HELP
1009
	do_help_void
1010
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1011
	nano_disabled_msg
1012
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1013
	);
1014

1015
    sc_init_one(&extcmd_list, NANO_CANCEL_KEY, cancel_msg,
1016
1017
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
1018

1019
1020
    sc_init_one(&extcmd_list, NANO_TOOTHERINSERT_KEY, N_("Insert File"),
	IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_NO_KEY,
1021
	NANO_NO_KEY, VIEW, NULL);
1022

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1023
#ifdef ENABLE_MULTIBUFFER
1024
    sc_init_one(&extcmd_list, NANO_NO_KEY, new_buffer_msg,
1025
	IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY),
1026
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
1027
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1028
#endif
1029

1030
1031
1032
1033
#ifndef DISABLE_HELP
    free_shortcutage(&help_list);

    sc_init_one(&help_list, NANO_REFRESH_KEY, refresh_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1034
1035
	IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
1036
1037

    sc_init_one(&help_list, NANO_EXIT_KEY, exit_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1038
1039
	IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY, NANO_NO_KEY,
	VIEW, NULL);
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061

    sc_init_one(&help_list, NANO_PREVPAGE_KEY, prev_page_msg,
	IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
	NANO_NO_KEY, VIEW, NULL);

    sc_init_one(&help_list, NANO_NEXTPAGE_KEY, next_page_msg,
	IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
	NANO_NO_KEY, VIEW, NULL);

    sc_init_one(&help_list, NANO_PREVLINE_KEY, N_("Prev Line"),
	IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);

    sc_init_one(&help_list, NANO_NEXTLINE_KEY, N_("Next Line"),
	IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
#endif

#ifndef DISABLE_SPELLER
    free_shortcutage(&spell_list);

    sc_init_one(&spell_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1062
1063
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
1064
#ifndef DISABLE_HELP
1065
	do_help_void
1066
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1067
	nano_disabled_msg
1068
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1069
	);
1070
1071

    sc_init_one(&spell_list, NANO_CANCEL_KEY, cancel_msg,
1072
1073
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
1074
1075
#endif

1076
#ifndef DISABLE_BROWSER
1077
    free_shortcutage(&browser_list);
1078

1079
    sc_init_one(&browser_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1080
1081
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW, NULL);
1082

1083
    sc_init_one(&browser_list, NANO_EXIT_KEY, exit_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1084
	IFHELP(nano_exitbrowser_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
1085
	NANO_NO_KEY, VIEW, NULL);
1086

1087
1088
    sc_init_one(&browser_list, NANO_PREVPAGE_KEY, prev_page_msg,
	IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
1089
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1090

1091
1092
    sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, next_page_msg,
	IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
1093
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1094

1095
1096
1097
1098
1099
1100
1101
1102
    sc_init_one(&browser_list, NANO_WHEREIS_KEY, whereis_msg,
	IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);

    sc_init_one(&browser_list, NANO_NO_KEY, whereis_next_msg,
	IFHELP(nano_whereis_next_msg, NANO_WHEREIS_NEXT_KEY),
	NANO_WHEREIS_NEXT_FKEY, NANO_NO_KEY, VIEW, NULL);

1103
    /* TRANSLATORS: Try to keep this at most 22 characters. */
1104
    sc_init_one(&browser_list, NANO_GOTOLINE_KEY, N_("Go To Dir"),
1105
	IFHELP(nano_gotodir_msg, NANO_GOTOLINE_ALTKEY),
1106
	NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW, NULL);
Rocco Corsi's avatar
   
Rocco Corsi committed
1107

1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
    free_shortcutage(&whereis_file_list);

    sc_init_one(&whereis_file_list, NANO_HELP_KEY, get_help_msg,
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
#ifndef DISABLE_HELP
	do_browser_help
#else
	nano_disabled_msg
#endif
	);

    sc_init_one(&whereis_file_list, NANO_CANCEL_KEY, cancel_msg,
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);

    sc_init_one(&whereis_file_list, NANO_FIRSTFILE_KEY, first_file_msg,
1125
1126
	IFHELP(nano_firstfile_msg, NANO_FIRSTFILE_ALTKEY),
	NANO_FIRSTFILE_FKEY, NANO_NO_KEY, VIEW, do_first_file);
1127
1128

    sc_init_one(&whereis_file_list, NANO_LASTFILE_KEY, last_file_msg,
1129
1130
	IFHELP(nano_lastfile_msg, NANO_LASTFILE_ALTKEY),
	NANO_LASTFILE_FKEY, NANO_NO_KEY, VIEW, do_last_file);
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153

#ifndef NANO_SMALL
    sc_init_one(&whereis_file_list, NANO_NO_KEY, case_sens_msg,
	IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);

    sc_init_one(&whereis_file_list, NANO_NO_KEY, backwards_msg,
	IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
#endif

#ifdef HAVE_REGEX_H
    sc_init_one(&whereis_file_list, NANO_NO_KEY, regexp_msg,
	IFHELP(nano_regexp_msg, NANO_REGEXP_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, NULL);
#endif

#ifndef NANO_SMALL
    sc_init_one(&whereis_file_list, NANO_PREVLINE_KEY, history_msg,
	IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
#endif

1154
    free_shortcutage(&gotodir_list);
1155

1156
    sc_init_one(&gotodir_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1157
1158
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
1159
#ifndef DISABLE_HELP
1160
	do_help_void
1161
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1162
	nano_disabled_msg
1163
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1164
	);
Chris Allegretta's avatar
Chris Allegretta committed
1165

1166
    sc_init_one(&gotodir_list, NANO_CANCEL_KEY, cancel_msg,
1167
1168
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1169
1170
#endif

1171
    currshortcut = main_list;
1172

1173
#ifndef NANO_TINY
1174
    toggle_init();
1175
#endif
1176
}
1177

1178
/* Free the given shortcut. */
1179
1180
1181
void free_shortcutage(shortcut **shortcutage)
{
    assert(shortcutage != NULL);
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1182

1183
1184
1185
1186
1187
1188
1189
    while (*shortcutage != NULL) {
	shortcut *ps = *shortcutage;
	*shortcutage = (*shortcutage)->next;
	free(ps);
    }
}

1190
#ifndef NANO_TINY
1191
/* Add a new toggle to the end of the global toggle list. */
1192
1193
1194
1195
1196
void toggle_init_one(int val, const char *desc, long flag)
{
    toggle *u;

    if (toggles == NULL) {
1197
	toggles = (toggle *)nmalloc(sizeof(toggle));
1198
1199
1200
1201
	u = toggles;
    } else {
	for (u = toggles; u->next != NULL; u = u->next)
	    ;
1202
	u->next = (toggle *)nmalloc(sizeof(toggle));
1203
1204
1205
1206
	u = u->next;
    }

    u->val = val;
1207
    u->desc = (desc == NULL) ? "" : _(desc);
1208
1209
1210
1211
    u->flag = flag;
    u->next = NULL;
}

1212
/* Initialize the global toggle list. */
1213
1214
1215
1216
1217
1218
1219
1220
void toggle_init(void)
{
    /* There is no need to reinitialize the toggles.  They can't
     * change. */
    if (toggles != NULL)
	return;

    toggle_init_one(TOGGLE_NOHELP_KEY, N_("Help mode"), NO_HELP);
1221

1222
1223
    toggle_init_one(TOGGLE_CONST_KEY,
	N_("Constant cursor position display"), CONST_UPDATE);
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233

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

    toggle_init_one(TOGGLE_SMOOTH_KEY, N_("Smooth scrolling"),
	SMOOTH_SCROLL);

#ifdef ENABLE_NANORC
    toggle_init_one(TOGGLE_WHITESPACE_KEY, N_("Whitespace display"),
	WHITESPACE_DISPLAY);
1234
#endif
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250

#ifdef ENABLE_COLOR
    toggle_init_one(TOGGLE_SYNTAX_KEY, N_("Color syntax highlighting"),
	NO_COLOR_SYNTAX);
#endif

    /* This entry is blank, in order to make the help text easier to
     * read. */
    toggle_init_one(TOGGLE_NO_KEY, NULL, 0);

    toggle_init_one(TOGGLE_SMARTHOME_KEY, N_("Smart home key"),
	SMART_HOME);

    toggle_init_one(TOGGLE_AUTOINDENT_KEY, N_("Auto indent"),
	AUTOINDENT);

1251
    toggle_init_one(TOGGLE_CUTTOEND_KEY, N_("Cut to end"), CUT_TO_END);
1252

1253
#ifndef DISABLE_WRAPPING
1254
1255
    toggle_init_one(TOGGLE_WRAP_KEY, N_("Long line wrapping"),
	NO_WRAP);
1256
#endif
1257

1258
1259
    toggle_init_one(TOGGLE_TABSTOSPACES_KEY,
	N_("Conversion of typed tabs to spaces"), TABS_TO_SPACES);
1260
1261
1262
1263
1264

    /* This entry is blank, in order to make the help text easier to
     * read. */
    toggle_init_one(TOGGLE_NO_KEY, NULL, 0);

1265
1266
1267
    /* If we're using restricted mode, the backup toggle is disabled.
     * It's useless since backups are disabled. */
    if (!ISSET(RESTRICTED))
1268
1269
	toggle_init_one(TOGGLE_BACKUP_KEY, N_("Backup files"),
		BACKUP_FILE);
1270
1271
1272
1273
1274
1275
1276

#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,
		N_("Multiple file buffers"), MULTIBUFFER);
1277
#endif
1278

1279
1280
1281
1282
#ifndef DISABLE_MOUSE
    toggle_init_one(TOGGLE_MOUSE_KEY, N_("Mouse support"), USE_MOUSE);
#endif

1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
    /* 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,
		N_("No conversion from DOS/Mac format"), NO_CONVERT);

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

1296
1297
1298
#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
1299
1300
 * 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
1301
1302
 * function unless debugging is turned on. */
void thanks_for_all_the_fish(void)
1303
{
1304
1305
1306
1307
    delwin(topwin);
    delwin(edit);
    delwin(bottomwin);

Chris Allegretta's avatar
Chris Allegretta committed
1308
1309
1310
#ifndef DISABLE_JUSTIFY
    if (quotestr != NULL)
	free(quotestr);
1311
1312
#ifdef HAVE_REGEX_H
    regfree(&quotereg);
1313
1314
    if (quoteerr != NULL)
	free(quoteerr);
1315
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1316
#endif
1317
#ifndef NANO_TINY
1318
1319
1320
    if (backup_dir != NULL)
        free(backup_dir);
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1321
#ifndef DISABLE_OPERATINGDIR
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
    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);
1334
#endif
1335
1336
1337
    if (answer != NULL)
	free(answer);
    if (cutbuffer != NULL)
Chris Allegretta's avatar
Chris Allegretta committed
1338
	free_filestruct(cutbuffer);
1339
1340
1341
1342
#ifndef DISABLE_JUSTIFY
    if (jusbuffer != NULL)
	free_filestruct(jusbuffer);
#endif
1343
1344
1345
1346
    free_shortcutage(&main_list);
    free_shortcutage(&whereis_list);
    free_shortcutage(&replace_list);
    free_shortcutage(&replace_list_2);
1347
    free_shortcutage(&gotoline_list);
1348
1349
    free_shortcutage(&writefile_list);
    free_shortcutage(&insertfile_list);
1350
1351
1352
#ifndef NANO_TINY
    free_shortcutage(&extcmd_list);
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1353
#ifndef DISABLE_HELP
Chris Allegretta's avatar
Chris Allegretta committed
1354
    free_shortcutage(&help_list);
Chris Allegretta's avatar
Chris Allegretta committed
1355
1356
#endif
#ifndef DISABLE_SPELLER
1357
    free_shortcutage(&spell_list);
Chris Allegretta's avatar
Chris Allegretta committed
1358
#endif
1359
1360
#ifndef DISABLE_BROWSER
    free_shortcutage(&browser_list);
Chris Allegretta's avatar
Chris Allegretta committed
1361
    free_shortcutage(&gotodir_list);
1362
#endif
1363
#ifndef NANO_TINY
1364
    /* Free the memory associated with each toggle. */
1365
1366
    while (toggles != NULL) {
	toggle *t = toggles;
1367

1368
1369
1370
1371
	toggles = toggles->next;
	free(t);
    }
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1372
    /* Free the memory associated with each open file buffer. */
1373
    if (openfile != NULL)
1374
	free_openfilestruct(openfile);
Chris Allegretta's avatar
Chris Allegretta committed
1375
#ifdef ENABLE_COLOR
1376
1377
    if (syntaxstr != NULL)
	free(syntaxstr);
Chris Allegretta's avatar
Chris Allegretta committed
1378
1379
1380
1381
1382
1383
1384
1385
    while (syntaxes != NULL) {
	syntaxtype *bill = syntaxes;

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

	    syntaxes->extensions = bob->next;
1386
	    free(bob->ext_regex);
1387
1388
1389
1390
	    if (bob->ext != NULL) {
		regfree(bob->ext);
		free(bob->ext);
	    }
Chris Allegretta's avatar
Chris Allegretta committed
1391
1392
1393
1394
1395
1396
	    free(bob);
	}
	while (syntaxes->color != NULL) {
	    colortype *bob = syntaxes->color;

	    syntaxes->color = bob->next;
1397
	    free(bob->start_regex);
1398
1399
1400
1401
	    if (bob->start != NULL) {
		regfree(bob->start);
		free(bob->start);
	    }
1402
1403
	    if (bob->end_regex != NULL)
		free(bob->end_regex);
1404
	    if (bob->end != NULL) {
1405
		regfree(bob->end);
1406
1407
		free(bob->end);
	    }
Chris Allegretta's avatar
Chris Allegretta committed
1408
1409
1410
1411
1412
1413
	    free(bob);
	}
	syntaxes = syntaxes->next;
	free(bill);
    }
#endif /* ENABLE_COLOR */
1414
#ifndef NANO_TINY
1415
    /* Free the search and replace history lists. */
1416
1417
1418
1419
    if (searchage != NULL)
	free_filestruct(searchage);
    if (replaceage != NULL)
	free_filestruct(replaceage);
1420
#endif
1421
#ifdef ENABLE_NANORC
1422
1423
    if (homedir != NULL)
	free(homedir);
1424
#endif
1425
}
1426
#endif /* DEBUG */