global.c 43.7 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
202
203
bool curses_ended = FALSE;
	/* Whether endwin() has ended curses mode and statusbar()
	 * should hence write to stderr instead of displaying on the
	 * statusbar. */
204

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

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

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

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
219
220
/* Create a new shortcut structure, at the end of the shortcuts linked
 * list. */
221
void sc_init_one(shortcut **shortcutage, int ctrlval, const char *desc,
222
#ifndef DISABLE_HELP
223
	const char *help,
224
#endif
225
	int metaval, int funcval, int miscval, bool view, void
226
	(*func)(void))
Chris Allegretta's avatar
Chris Allegretta committed
227
{
228
229
230
    shortcut *s;

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

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

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

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
432
433
434
/* 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
435
#ifndef DISABLE_HELP
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
436
#define IFHELP(help, nextvar) help, nextvar
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
437
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
438
#define IFHELP(help, nextvar) nextvar
439
#endif
440

441
442
443
    free_shortcutage(&main_list);

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

453
454
    sc_init_one(&main_list, NANO_EXIT_KEY,
#ifdef ENABLE_MULTIBUFFER
455
	/* TRANSLATORS: Try to keep this at most 10 characters. */
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
456
	openfile != NULL && openfile != openfile->next ? N_("Close") :
457
#endif
458
459
	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
460

461
    /* TRANSLATORS: Try to keep this at most 10 characters. */
462
463
464
    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
465

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

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

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

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

498
499
500
    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
501

502
503
504
    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
505

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

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

522
    /* TRANSLATORS: Try to keep this at most 10 characters. */
523
524
525
    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
526

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

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

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

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

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

559
560
561
    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
562

563
564
565
    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
566

567
    sc_init_one(&main_list, NANO_FORWARD_KEY, N_("Forward"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
568
569
	IFHELP(nano_forward_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, do_right);
Chris Allegretta's avatar
Chris Allegretta committed
570

571
    sc_init_one(&main_list, NANO_BACK_KEY, N_("Back"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
572
573
	IFHELP(nano_back_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, do_left);
Chris Allegretta's avatar
Chris Allegretta committed
574

575
    sc_init_one(&main_list, NANO_HOME_KEY, N_("Home"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
576
577
	IFHELP(nano_home_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, do_home);
Chris Allegretta's avatar
Chris Allegretta committed
578

579
    sc_init_one(&main_list, NANO_END_KEY, N_("End"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
580
581
	IFHELP(nano_end_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, do_end);
Chris Allegretta's avatar
Chris Allegretta committed
582

583
    sc_init_one(&main_list, NANO_REFRESH_KEY, refresh_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
584
585
	IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, total_refresh);
Chris Allegretta's avatar
Chris Allegretta committed
586

587
    sc_init_one(&main_list, NANO_DELETE_KEY, N_("Delete"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
588
589
	IFHELP(nano_delete_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	NOVIEW, do_delete);
Chris Allegretta's avatar
Chris Allegretta committed
590

591
592
593
    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
594

595
    sc_init_one(&main_list, NANO_TAB_KEY, N_("Tab"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
596
597
	IFHELP(nano_tab_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	NOVIEW, do_tab);
Chris Allegretta's avatar
Chris Allegretta committed
598

599
    sc_init_one(&main_list, NANO_ENTER_KEY, N_("Enter"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
600
601
	IFHELP(nano_enter_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	NOVIEW, do_enter);
602

603
#ifndef NANO_TINY
604
605
    sc_init_one(&main_list, NANO_NEXTWORD_KEY, N_("Next Word"),
	IFHELP(nano_nextword_msg, NANO_NO_KEY), NANO_NO_KEY,
606
	NANO_NO_KEY, VIEW, do_next_word_void);
607

608
609
    sc_init_one(&main_list, NANO_NO_KEY, N_("Prev Word"),
	IFHELP(nano_prevword_msg, NANO_PREVWORD_KEY), NANO_NO_KEY,
610
	NANO_NO_KEY, VIEW, do_prev_word_void);
611
612
613

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

616
617
618
    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);
619

620
621
622
    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);
623
#endif
624

625
626
627
#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,
628
	NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
629
630
631

    sc_init_one(&main_list, NANO_NO_KEY, end_of_par_msg,
	IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
632
	NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
633
#endif
634

635
#ifdef ENABLE_MULTIBUFFER
636
    sc_init_one(&main_list, NANO_NO_KEY, N_("Previous File"),
637
638
	IFHELP(nano_prevfile_msg, NANO_PREVFILE_KEY), NANO_NO_KEY,
	NANO_PREVFILE_ALTKEY, VIEW, switch_to_prev_buffer_void);
639

640
    sc_init_one(&main_list, NANO_NO_KEY, N_("Next File"),
641
642
	IFHELP(nano_nextfile_msg, NANO_NEXTFILE_KEY), NANO_NO_KEY,
	NANO_NEXTFILE_ALTKEY, VIEW, switch_to_next_buffer_void);
643
#endif
644

645
646
647
648
    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);

649
#ifndef NANO_TINY
650
651
652
653
654
    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

655
656
#ifndef DISABLE_JUSTIFY
    sc_init_one(&main_list, NANO_NO_KEY, fulljstify_msg,
657
658
	IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY),
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
659
660
#endif

661
#ifndef NANO_TINY
662
663
664
    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);
665
666
#endif

667
    free_shortcutage(&whereis_list);
668

669
    sc_init_one(&whereis_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
670
671
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
672
#ifndef DISABLE_HELP
673
	do_help_void
674
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
675
	nano_disabled_msg
676
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
677
	);
678

679
    sc_init_one(&whereis_list, NANO_CANCEL_KEY, cancel_msg,
680
681
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
682

683
684
685
    sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, first_line_msg,
	IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
	NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
686

687
688
689
    sc_init_one(&whereis_list, NANO_LASTLINE_KEY, last_line_msg,
	IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
	NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
690

691
    sc_init_one(&whereis_list, NANO_TOOTHERSEARCH_KEY, replace_msg,
692
	IFHELP(nano_replace_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
693
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
694

695
696
    sc_init_one(&whereis_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
	IFHELP(nano_gotoline_msg, NANO_NO_KEY), NANO_GOTOLINE_FKEY,
697
	NANO_NO_KEY, VIEW, NULL);
698

699
#ifndef DISABLE_JUSTIFY
700
    sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, beg_of_par_msg,
701
	IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
702
	NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
703

704
    sc_init_one(&whereis_list, NANO_PARAEND_KEY, end_of_par_msg,
705
	IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
706
	NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
707
708
#endif

709
#ifndef NANO_TINY
710
711
    sc_init_one(&whereis_list, NANO_NO_KEY, case_sens_msg,
	IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
712
	NANO_NO_KEY, VIEW, NULL);
713

714
    sc_init_one(&whereis_list, NANO_NO_KEY, backwards_msg,
715
	IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
716
	NANO_NO_KEY, VIEW, NULL);
717
#endif
Chris Allegretta's avatar
Chris Allegretta committed
718

719
#ifdef HAVE_REGEX_H
720
    sc_init_one(&whereis_list, NANO_NO_KEY, regexp_msg,
721
	IFHELP(nano_regexp_msg, NANO_REGEXP_KEY), NANO_NO_KEY,
722
	NANO_NO_KEY, VIEW, NULL);
723
#endif
724

725
#ifndef NANO_TINY
726
    sc_init_one(&whereis_list, NANO_PREVLINE_KEY, history_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
727
728
	IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
729
730
731
732

    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);
733
#endif
734
735
736
737
738
739

#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
740

741
    free_shortcutage(&replace_list);
742

743
    sc_init_one(&replace_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
744
745
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
746
#ifndef DISABLE_HELP
747
	do_help_void
748
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
749
	nano_disabled_msg
750
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
751
	);
752

753
    sc_init_one(&replace_list, NANO_CANCEL_KEY, cancel_msg,
754
755
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
756

757
758
759
    sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, first_line_msg,
	IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
	NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
760

761
762
763
    sc_init_one(&replace_list, NANO_LASTLINE_KEY, last_line_msg,
	IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
	NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
764

765
    /* TRANSLATORS: Try to keep this at most 12 characters. */
766
    sc_init_one(&replace_list, NANO_TOOTHERSEARCH_KEY, N_("No Replace"),
767
	IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
768
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
769

770
771
    sc_init_one(&replace_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
	IFHELP(nano_gotoline_msg, NANO_NO_KEY), NANO_GOTOLINE_FKEY,
772
	NANO_NO_KEY, VIEW, NULL);
773

774
#ifndef NANO_TINY
775
776
    sc_init_one(&replace_list, NANO_NO_KEY, case_sens_msg,
	IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
777
	NANO_NO_KEY, VIEW, NULL);
778

779
    sc_init_one(&replace_list, NANO_NO_KEY, backwards_msg,
780
	IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
781
	NANO_NO_KEY, VIEW, NULL);
782
#endif
783

784
#ifdef HAVE_REGEX_H
785
    sc_init_one(&replace_list, NANO_NO_KEY, regexp_msg,
786
	IFHELP(nano_regexp_msg, NANO_REGEXP_KEY), NANO_NO_KEY,
787
	NANO_NO_KEY, VIEW, NULL);
788
#endif
789

790
#ifndef NANO_TINY
791
    sc_init_one(&replace_list, NANO_PREVLINE_KEY, history_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
792
793
	IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
794
#endif
795

796
    free_shortcutage(&replace_list_2);
797

798
    sc_init_one(&replace_list_2, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
799
800
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
801
#ifndef DISABLE_HELP
802
	do_help_void
803
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
804
	nano_disabled_msg
805
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
806
	);
807

808
    sc_init_one(&replace_list_2, NANO_CANCEL_KEY, cancel_msg,
809
810
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
811

812
813
814
    sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, first_line_msg,
	IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_first_line);
815

816
817
818
    sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, last_line_msg,
	IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_last_line);
819

820
#ifndef NANO_TINY
821
    sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, history_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
822
823
	IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
824
825
#endif

826
    free_shortcutage(&gotoline_list);
Chris Allegretta's avatar
Chris Allegretta committed
827

828
    sc_init_one(&gotoline_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
829
830
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
831
#ifndef DISABLE_HELP
832
	do_help_void
833
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
834
	nano_disabled_msg
835
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
836
	);
837

838
    sc_init_one(&gotoline_list, NANO_CANCEL_KEY, cancel_msg,
839
840
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
841

842
    sc_init_one(&gotoline_list, NANO_FIRSTLINE_KEY, first_line_msg,
843
844
	IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
845

846
    sc_init_one(&gotoline_list, NANO_LASTLINE_KEY, last_line_msg,
847
848
	IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
849

850
851
    sc_init_one(&gotoline_list, NANO_TOOTHERWHEREIS_KEY,
	N_("Go To Text"), IFHELP(nano_whereis_msg, NANO_NO_KEY),
852
	NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL);
853

854
    free_shortcutage(&writefile_list);
Chris Allegretta's avatar
Chris Allegretta committed
855

856
    sc_init_one(&writefile_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
857
858
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
859
#ifndef DISABLE_HELP
860
	do_help_void
861
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
862
	nano_disabled_msg
863
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
864
	);
865

866
    sc_init_one(&writefile_list, NANO_CANCEL_KEY, cancel_msg,
867
868
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
869

870
#ifndef DISABLE_BROWSER
871
872
    /* If we're using restricted mode, the file browser is disabled.
     * It's useless since inserting files is disabled. */
873

874
    if (!ISSET(RESTRICTED))
875
	sc_init_one(&writefile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
876
		IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
877
		NANO_NO_KEY, NOVIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
878
#endif
Chris Allegretta's avatar
Chris Allegretta committed
879

880
#ifndef NANO_TINY
881
882
883
884
885
886
    /* 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. */
887

888
    if (!ISSET(RESTRICTED))
889
	/* TRANSLATORS: Try to keep this at most 16 characters. */
890
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("DOS Format"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
891
		IFHELP(nano_dos_msg, TOGGLE_DOS_KEY), NANO_NO_KEY,
892
		NANO_NO_KEY, NOVIEW, NULL);
893

894
    if (!ISSET(RESTRICTED))
895
	/* TRANSLATORS: Try to keep this at most 16 characters. */
896
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Mac Format"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
897
		IFHELP(nano_mac_msg, TOGGLE_MAC_KEY), NANO_NO_KEY,
898
		NANO_NO_KEY, NOVIEW, NULL);
899
900
#endif

901
    if (!ISSET(RESTRICTED))
902
	/* TRANSLATORS: Try to keep this at most 16 characters. */
903
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Append"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
904
		IFHELP(nano_append_msg, NANO_APPEND_KEY), NANO_NO_KEY,
905
		NANO_NO_KEY, NOVIEW, NULL);
906

907
    if (!ISSET(RESTRICTED))
908
	/* TRANSLATORS: Try to keep this at most 16 characters. */
909
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Prepend"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
910
		IFHELP(nano_prepend_msg, NANO_PREPEND_KEY), NANO_NO_KEY,
911
		NANO_NO_KEY, NOVIEW, NULL);
912

913
#ifndef NANO_TINY
914
    if (!ISSET(RESTRICTED))
915
	/* TRANSLATORS: Try to keep this at most 16 characters. */
916
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Backup File"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
917
		IFHELP(nano_backup_msg, TOGGLE_BACKUP_KEY), NANO_NO_KEY,
918
		NANO_NO_KEY, NOVIEW, NULL);
919
920
#endif

921
    free_shortcutage(&insertfile_list);
922

923
    sc_init_one(&insertfile_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
924
925
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
926
#ifndef DISABLE_HELP
927
	do_help_void
928
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
929
	nano_disabled_msg
930
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
931
	);
932

933
    sc_init_one(&insertfile_list, NANO_CANCEL_KEY, cancel_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
934
935
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
936

937
#ifndef DISABLE_BROWSER
938
939
    /* If we're using restricted mode, the file browser is disabled.
     * It's useless since inserting files is disabled. */
940
    if (!ISSET(RESTRICTED))
941
	sc_init_one(&insertfile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
942
		IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
943
		NANO_NO_KEY, NOVIEW, NULL);
944
#endif
945

946
#ifndef NANO_TINY
947
948
    /* If we're using restricted mode, command execution is disabled.
     * It's useless since inserting files is disabled. */
949

950
    if (!ISSET(RESTRICTED))
951
	sc_init_one(&insertfile_list, NANO_TOOTHERINSERT_KEY,
952
		/* TRANSLATORS: Try to keep this at most 22 characters. */
953
		N_("Execute Command"), IFHELP(nano_execute_msg,
954
		NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
955

956
#ifdef ENABLE_MULTIBUFFER
957
958
    /* If we're using restricted mode, the multibuffer toggle is
     * disabled.  It's useless since inserting files is disabled. */
959

960
    if (!ISSET(RESTRICTED))
961
	sc_init_one(&insertfile_list, NANO_NO_KEY, new_buffer_msg,
962
		IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY),
963
		NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
964
#endif
965
#endif
966

967
#ifndef NANO_TINY
968
    free_shortcutage(&extcmd_list);
Chris Allegretta's avatar
Chris Allegretta committed
969

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

980
    sc_init_one(&extcmd_list, NANO_CANCEL_KEY, cancel_msg,
981
982
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
983

984
985
    sc_init_one(&extcmd_list, NANO_TOOTHERINSERT_KEY, N_("Insert File"),
	IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_NO_KEY,
986
	NANO_NO_KEY, VIEW, NULL);
987

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
988
#ifdef ENABLE_MULTIBUFFER
989
    sc_init_one(&extcmd_list, NANO_NO_KEY, new_buffer_msg,
990
	IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY),
991
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
992
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
993
#endif
994

995
996
997
998
#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
999
1000
	IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
1001
1002

    sc_init_one(&help_list, NANO_EXIT_KEY, exit_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1003
1004
	IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY, NANO_NO_KEY,
	VIEW, NULL);
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026

    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
1027
1028
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
1029
#ifndef DISABLE_HELP
1030
	do_help_void
1031
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1032
	nano_disabled_msg
1033
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1034
	);
1035
1036

    sc_init_one(&spell_list, NANO_CANCEL_KEY, cancel_msg,
1037
1038
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
1039
1040
#endif

1041
#ifndef DISABLE_BROWSER
1042
    free_shortcutage(&browser_list);
1043

1044
    sc_init_one(&browser_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1045
1046
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW, NULL);
1047

1048
    sc_init_one(&browser_list, NANO_EXIT_KEY, exit_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1049
	IFHELP(nano_exitbrowser_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
1050
	NANO_NO_KEY, VIEW, NULL);
1051

1052
1053
    sc_init_one(&browser_list, NANO_PREVPAGE_KEY, prev_page_msg,
	IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
1054
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1055

1056
1057
    sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, next_page_msg,
	IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
1058
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1059

1060
1061
1062
1063
1064
1065
1066
1067
    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);

1068
    /* TRANSLATORS: Try to keep this at most 22 characters. */
1069
    sc_init_one(&browser_list, NANO_GOTOLINE_KEY, N_("Go To Dir"),
1070
	IFHELP(nano_gotodir_msg, NANO_GOTOLINE_ALTKEY),
1071
	NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW, NULL);
Rocco Corsi's avatar
   
Rocco Corsi committed
1072

1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
    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,
	IFHELP(nano_firstfile_msg, NANO_NO_KEY), NANO_FIRSTFILE_FKEY,
	NANO_NO_KEY, VIEW, do_first_file);

    sc_init_one(&whereis_file_list, NANO_LASTFILE_KEY, last_file_msg,
	IFHELP(nano_lastfile_msg, NANO_NO_KEY), NANO_LASTFILE_FKEY,
	NANO_NO_KEY, VIEW, do_last_file);

#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

1119
    free_shortcutage(&gotodir_list);
1120

1121
    sc_init_one(&gotodir_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1122
1123
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
1124
#ifndef DISABLE_HELP
1125
	do_help_void
1126
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1127
	nano_disabled_msg
1128
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1129
	);
Chris Allegretta's avatar
Chris Allegretta committed
1130

1131
    sc_init_one(&gotodir_list, NANO_CANCEL_KEY, cancel_msg,
1132
1133
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1134
1135
#endif

1136
    currshortcut = main_list;
1137

1138
#ifndef NANO_TINY
1139
    toggle_init();
1140
#endif
1141
}
1142

1143
1144
1145
1146
/* Deallocate the given shortcut. */
void free_shortcutage(shortcut **shortcutage)
{
    assert(shortcutage != NULL);
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1147

1148
1149
1150
1151
1152
1153
1154
    while (*shortcutage != NULL) {
	shortcut *ps = *shortcutage;
	*shortcutage = (*shortcutage)->next;
	free(ps);
    }
}

1155
#ifndef NANO_TINY
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1156
/* Create a new toggle structure, at the end of the toggles linked
1157
1158
1159
1160
1161
1162
 * list. */
void toggle_init_one(int val, const char *desc, long flag)
{
    toggle *u;

    if (toggles == NULL) {
1163
	toggles = (toggle *)nmalloc(sizeof(toggle));
1164
1165
1166
1167
	u = toggles;
    } else {
	for (u = toggles; u->next != NULL; u = u->next)
	    ;
1168
	u->next = (toggle *)nmalloc(sizeof(toggle));
1169
1170
1171
1172
1173
1174
1175
1176
1177
	u = u->next;
    }

    u->val = val;
    u->desc = _(desc);
    u->flag = flag;
    u->next = NULL;
}

1178
/* Initialize the global toggle list. */
1179
1180
1181
1182
1183
1184
1185
1186
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);
1187
1188
    toggle_init_one(TOGGLE_MORESPACE_KEY,
	N_("Use of more space for editing"), MORE_SPACE);
1189
1190
1191
1192
#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))
1193
1194
	toggle_init_one(TOGGLE_MULTIBUFFER_KEY,
		N_("Multiple file buffers"), MULTIBUFFER);
1195
#endif
1196
    toggle_init_one(TOGGLE_CUTTOEND_KEY, N_("Cut to end"), CUT_TO_END);
1197
#ifndef DISABLE_WRAPPING
1198
1199
    toggle_init_one(TOGGLE_WRAP_KEY, N_("Long line wrapping"),
	NO_WRAP);
1200
#endif
1201
1202
1203
#ifndef DISABLE_MOUSE
    toggle_init_one(TOGGLE_MOUSE_KEY, N_("Mouse support"), USE_MOUSE);
#endif
1204
1205
1206
1207
    /* 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);
1208
1209
1210
1211
1212
1213
    toggle_init_one(TOGGLE_CONST_KEY,
	N_("Constant cursor position display"), CONST_UPDATE);
    toggle_init_one(TOGGLE_AUTOINDENT_KEY, N_("Auto indent"),
	AUTOINDENT);
    toggle_init_one(TOGGLE_TABSTOSPACES_KEY,
	N_("Conversion of typed tabs to spaces"), TABS_TO_SPACES);
1214
1215
1216
    /* If we're using restricted mode, the DOS/Mac conversion toggle is
     * disabled.  It's useless since inserting files is disabled. */
    if (!ISSET(RESTRICTED))
1217
1218
	toggle_init_one(TOGGLE_NOCONVERT_KEY,
		N_("No conversion from DOS/Mac format"), NO_CONVERT);
1219
1220
1221
    /* If we're using restricted mode, the backup toggle is disabled.
     * It's useless since backups are disabled. */
    if (!ISSET(RESTRICTED))
1222
1223
1224
	toggle_init_one(TOGGLE_BACKUP_KEY, N_("Backup files"),
		BACKUP_FILE);
    toggle_init_one(TOGGLE_SMOOTH_KEY, N_("Smooth scrolling"),
1225
	SMOOTH_SCROLL);
1226
1227
    toggle_init_one(TOGGLE_SMARTHOME_KEY, N_("Smart home key"),
	SMART_HOME);
1228
1229
#ifdef ENABLE_COLOR
    toggle_init_one(TOGGLE_SYNTAX_KEY, N_("Color syntax highlighting"),
1230
	NO_COLOR_SYNTAX);
1231
1232
1233
1234
1235
1236
#endif
#ifdef ENABLE_NANORC
    toggle_init_one(TOGGLE_WHITESPACE_KEY, N_("Whitespace display"),
	WHITESPACE_DISPLAY);
#endif
}
1237
#endif /* !NANO_TINY */
1238

1239
1240
1241
/* This function is called just before calling exit().  Practically, the
 * 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
1242
 * function unless debugging is turned on. */
1243
#ifdef DEBUG
1244
/* Added by SPK for memory cleanup; gracefully return our malloc()s. */
Chris Allegretta's avatar
Chris Allegretta committed
1245
void thanks_for_all_the_fish(void)
1246
{
1247
1248
1249
1250
    delwin(topwin);
    delwin(edit);
    delwin(bottomwin);

Chris Allegretta's avatar
Chris Allegretta committed
1251
1252
1253
#ifndef DISABLE_JUSTIFY
    if (quotestr != NULL)
	free(quotestr);
1254
1255
#ifdef HAVE_REGEX_H
    regfree(&quotereg);
1256
1257
    if (quoteerr != NULL)
	free(quoteerr);
1258
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1259
#endif
1260
#ifndef NANO_TINY
1261
1262
1263
    if (backup_dir != NULL)
        free(backup_dir);
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1264
#ifndef DISABLE_OPERATINGDIR
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
    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);
1277
#endif
1278
1279
1280
    if (answer != NULL)
	free(answer);
    if (cutbuffer != NULL)
Chris Allegretta's avatar
Chris Allegretta committed
1281
	free_filestruct(cutbuffer);
1282
1283
1284
1285
#ifndef DISABLE_JUSTIFY
    if (jusbuffer != NULL)
	free_filestruct(jusbuffer);
#endif
1286
1287
1288
1289
    free_shortcutage(&main_list);
    free_shortcutage(&whereis_list);
    free_shortcutage(&replace_list);
    free_shortcutage(&replace_list_2);
1290
    free_shortcutage(&gotoline_list);
1291
1292
    free_shortcutage(&writefile_list);
    free_shortcutage(&insertfile_list);
1293
1294
1295
#ifndef NANO_TINY
    free_shortcutage(&extcmd_list);
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1296
#ifndef DISABLE_HELP
Chris Allegretta's avatar
Chris Allegretta committed
1297
    free_shortcutage(&help_list);
Chris Allegretta's avatar
Chris Allegretta committed
1298
1299
#endif
#ifndef DISABLE_SPELLER
1300
    free_shortcutage(&spell_list);
Chris Allegretta's avatar
Chris Allegretta committed
1301
#endif
1302
1303
#ifndef DISABLE_BROWSER
    free_shortcutage(&browser_list);
Chris Allegretta's avatar
Chris Allegretta committed
1304
    free_shortcutage(&gotodir_list);
1305
#endif
1306
#ifndef NANO_TINY
1307
    /* Free the memory associated with each toggle. */
1308
1309
    while (toggles != NULL) {
	toggle *t = toggles;
1310

1311
1312
1313
1314
	toggles = toggles->next;
	free(t);
    }
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1315
    /* Free the memory associated with each open file buffer. */
1316
    if (openfile != NULL)
1317
	free_openfilestruct(openfile);
Chris Allegretta's avatar
Chris Allegretta committed
1318
#ifdef ENABLE_COLOR
1319
1320
    if (syntaxstr != NULL)
	free(syntaxstr);
Chris Allegretta's avatar
Chris Allegretta committed
1321
1322
1323
1324
1325
1326
1327
1328
    while (syntaxes != NULL) {
	syntaxtype *bill = syntaxes;

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

	    syntaxes->extensions = bob->next;
1329
	    free(bob->ext_regex);
1330
1331
1332
1333
	    if (bob->ext != NULL) {
		regfree(bob->ext);
		free(bob->ext);
	    }
Chris Allegretta's avatar
Chris Allegretta committed
1334
1335
1336
1337
1338
1339
	    free(bob);
	}
	while (syntaxes->color != NULL) {
	    colortype *bob = syntaxes->color;

	    syntaxes->color = bob->next;
1340
	    free(bob->start_regex);
1341
1342
1343
1344
	    if (bob->start != NULL) {
		regfree(bob->start);
		free(bob->start);
	    }
1345
1346
	    if (bob->end_regex != NULL)
		free(bob->end_regex);
1347
	    if (bob->end != NULL) {
1348
		regfree(bob->end);
1349
1350
		free(bob->end);
	    }
Chris Allegretta's avatar
Chris Allegretta committed
1351
1352
1353
1354
1355
1356
	    free(bob);
	}
	syntaxes = syntaxes->next;
	free(bill);
    }
#endif /* ENABLE_COLOR */
1357
#ifndef NANO_TINY
1358
    /* Free the search and replace history lists. */
1359
1360
1361
1362
    if (searchage != NULL)
	free_filestruct(searchage);
    if (replaceage != NULL)
	free_filestruct(replaceage);
1363
#endif
1364
#ifdef ENABLE_NANORC
1365
1366
    if (homedir != NULL)
	free(homedir);
1367
#endif
1368
}
1369
#endif /* DEBUG */