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

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
425
426
427
/* 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
428
#ifndef DISABLE_HELP
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
429
#define IFHELP(help, nextvar) help, nextvar
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
430
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
431
#define IFHELP(help, nextvar) nextvar
432
#endif
433

434
435
    free_shortcutage(&main_list);

436
    /* Translators: try to keep this string under 10 characters long. */
437
    sc_init_one(&main_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
438
439
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
440
#ifndef DISABLE_HELP
441
	do_help_void
442
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
443
	nano_disabled_msg
444
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
445
	);
Chris Allegretta's avatar
Chris Allegretta committed
446

447
    /* Translators: try to keep this string under 10 characters long. */
448
449
    sc_init_one(&main_list, NANO_EXIT_KEY,
#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
450
	openfile != NULL && openfile != openfile->next ? N_("Close") :
451
#endif
452
453
	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
454

455
    /* Translators: try to keep this string under 10 characters long. */
456
457
458
    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
459

460
    /* Translators: try to keep this string under 10 characters long. */
461
    sc_init_one(&main_list, NANO_JUSTIFY_KEY, N_("Justify"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
462
463
	IFHELP(nano_justify_msg, NANO_NO_KEY), NANO_JUSTIFY_FKEY,
	NANO_NO_KEY, NOVIEW,
464
#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
465
	do_justify_void
466
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
467
	nano_disabled_msg
468
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
469
	);
470

471
    /* We allow inserting files in view mode if multibuffers are
472
473
474
475
476
477
     * 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. */

    /* Translators: try to keep this string under 10 characters long. */
478
479
480
    sc_init_one(&main_list, NANO_INSERTFILE_KEY, N_("Read File"),
	IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_INSERTFILE_FKEY,
	NANO_NO_KEY,
481
#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
482
	VIEW
483
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
484
	NOVIEW
485
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
486
	, !ISSET(RESTRICTED) ? do_insertfile_void : nano_disabled_msg);
Chris Allegretta's avatar
Chris Allegretta committed
487

488
    /* Translators: try to keep this string under 10 characters long. */
489
    sc_init_one(&main_list, NANO_WHEREIS_KEY, whereis_msg,
490
491
	IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_WHEREIS_FKEY,
	NANO_NO_KEY, VIEW, do_search);
Chris Allegretta's avatar
Chris Allegretta committed
492

493
    /* Translators: try to keep this string under 10 characters long. */
494
495
496
    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
497

498
    /* Translators: try to keep this string under 10 characters long. */
499
500
501
    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
502

503
    /* Translators: try to keep this string under 10 characters long. */
504
    sc_init_one(&main_list, NANO_CUT_KEY, N_("Cut Text"),
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
505
506
	IFHELP(nano_cut_msg, NANO_NO_KEY), NANO_CUT_FKEY, NANO_NO_KEY,
	NOVIEW, do_cut_text);
Chris Allegretta's avatar
Chris Allegretta committed
507

508
    if (unjustify)
509
    /* Translators: try to keep this string under 10 characters long. */
510
511
	sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, N_("UnJustify"),
		IFHELP(NULL, NANO_NO_KEY), NANO_UNJUSTIFY_FKEY,
512
		NANO_NO_KEY, NOVIEW, NULL);
513
    else
514
    /* Translators: try to keep this string under 10 characters long. */
515
	sc_init_one(&main_list, NANO_UNCUT_KEY, N_("UnCut Txt"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
516
517
		IFHELP(nano_uncut_msg, NANO_NO_KEY), NANO_UNCUT_FKEY,
		NANO_NO_KEY, NOVIEW, do_uncut_text);
Chris Allegretta's avatar
Chris Allegretta committed
518

519
    /* Translators: try to keep this string under 10 characters long. */
520
521
522
    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
523

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

536
    sc_init_one(&main_list, NANO_GOTOLINE_KEY, go_to_line_msg,
537
	IFHELP(nano_gotoline_msg, NANO_GOTOLINE_ALTKEY),
538
539
	NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW,
	do_gotolinecolumn_void);
540

541
    sc_init_one(&main_list, NANO_REPLACE_KEY, replace_msg,
542
543
	IFHELP(nano_replace_msg, NANO_ALT_REPLACE_KEY),
	NANO_REPLACE_FKEY, NANO_NO_KEY, NOVIEW, do_replace);
Chris Allegretta's avatar
Chris Allegretta committed
544

545
#ifndef NANO_TINY
546
547
    sc_init_one(&main_list, NANO_MARK_KEY, N_("Mark Text"),
	IFHELP(nano_mark_msg, NANO_MARK_ALTKEY), NANO_MARK_FKEY,
548
	NANO_NO_KEY, VIEW, do_mark);
549

550
551
    /* Translators: try to keep this string under 16 characters long. */
    sc_init_one(&main_list, NANO_NO_KEY, whereis_next_msg,
552
	IFHELP(nano_whereis_next_msg, NANO_WHEREIS_NEXT_KEY),
553
	NANO_WHEREIS_NEXT_FKEY, NANO_NO_KEY, VIEW, do_research);
554
555
#endif

556
557
558
    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
559

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

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

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

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

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

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

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

588
589
590
    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
591

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

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

600
#ifndef NANO_TINY
601
602
    sc_init_one(&main_list, NANO_NEXTWORD_KEY, N_("Next Word"),
	IFHELP(nano_nextword_msg, NANO_NO_KEY), NANO_NO_KEY,
603
	NANO_NO_KEY, VIEW, do_next_word_void);
604

605
606
    sc_init_one(&main_list, NANO_NO_KEY, N_("Prev Word"),
	IFHELP(nano_prevword_msg, NANO_PREVWORD_KEY), NANO_NO_KEY,
607
	NANO_NO_KEY, VIEW, do_prev_word_void);
608
609
610

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

613
614
615
    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);
616

617
618
619
    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);
620
#endif
621

622
#ifndef DISABLE_JUSTIFY
623
    /* Translators: try to keep this string under 10 characters long. */
624
625
    sc_init_one(&main_list, NANO_NO_KEY, beg_of_par_msg,
	IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
626
	NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
627

628
    /* Translators: try to keep this string under 10 characters long. */
629
630
    sc_init_one(&main_list, NANO_NO_KEY, end_of_par_msg,
	IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
631
	NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
632
#endif
633

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

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

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

648
#ifndef NANO_TINY
649
    /* Translators: try to keep this string under 10 characters long. */
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
#ifndef DISABLE_JUSTIFY
656
    /* Translators: try to keep this string under 10 characters long. */
657
    sc_init_one(&main_list, NANO_NO_KEY, fulljstify_msg,
658
659
	IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY),
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
660
661
#endif

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

668
    free_shortcutage(&whereis_list);
669

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

680
    /* Translators: try to keep this string under 10 characters long. */
681
    sc_init_one(&whereis_list, NANO_CANCEL_KEY, cancel_msg,
682
683
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
684

685
    /* Translators: try to keep this string under 10 characters long. */
686
687
688
    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
689

690
    /* Translators: try to keep this string under 10 characters long. */
691
692
693
    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
694

695
    /* Translators: try to keep this string under 10 characters long. */
696
    sc_init_one(&whereis_list, NANO_TOOTHERSEARCH_KEY, replace_msg,
697
	IFHELP(nano_replace_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
698
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
699

700
    /* Translators: try to keep this string under 10 characters long. */
701
702
    sc_init_one(&whereis_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
	IFHELP(nano_gotoline_msg, NANO_NO_KEY), NANO_GOTOLINE_FKEY,
703
	NANO_NO_KEY, VIEW, NULL);
704

705
#ifndef DISABLE_JUSTIFY
706
    /* Translators: try to keep this string under 10 characters long. */
707
    sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, beg_of_par_msg,
708
	IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
709
	NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
710

711
    /* Translators: try to keep this string under 10 characters long. */
712
    sc_init_one(&whereis_list, NANO_PARAEND_KEY, end_of_par_msg,
713
	IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
714
	NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
715
716
#endif

717
#ifndef NANO_TINY
718
    /* Translators: try to keep this string under 10 characters long. */
719
720
    sc_init_one(&whereis_list, NANO_NO_KEY, case_sens_msg,
	IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
721
	NANO_NO_KEY, VIEW, NULL);
722

723
    /* Translators: try to keep this string under 10 characters long. */
724
    sc_init_one(&whereis_list, NANO_NO_KEY, backwards_msg,
725
	IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
726
	NANO_NO_KEY, VIEW, NULL);
727
#endif
Chris Allegretta's avatar
Chris Allegretta committed
728

729
#ifdef HAVE_REGEX_H
730
    /* Translators: try to keep this string under 10 characters long. */
731
    sc_init_one(&whereis_list, NANO_NO_KEY, regexp_msg,
732
	IFHELP(nano_regexp_msg, NANO_REGEXP_KEY), NANO_NO_KEY,
733
	NANO_NO_KEY, VIEW, NULL);
734
#endif
735

736
#ifndef NANO_TINY
737
    /* Translators: try to keep this string under 10 characters long. */
738
    sc_init_one(&whereis_list, NANO_PREVLINE_KEY, history_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
739
740
	IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
741

742
    /* Translators: try to keep this string under 10 characters long. */
743
744
745
    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);
746
#endif
747
748

#ifndef DISABLE_JUSTIFY
749
    /* Translators: try to keep this string under 10 characters long. */
750
751
752
753
    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
754

755
    free_shortcutage(&replace_list);
756

757
    sc_init_one(&replace_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
758
759
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
760
#ifndef DISABLE_HELP
761
	do_help_void
762
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
763
	nano_disabled_msg
764
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
765
	);
766

767
    sc_init_one(&replace_list, NANO_CANCEL_KEY, cancel_msg,
768
769
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
770

771
772
773
    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
774

775
776
777
    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
778

779
    /* Translators: try to keep this string under 12 characters long. */
780
    sc_init_one(&replace_list, NANO_TOOTHERSEARCH_KEY, N_("No Replace"),
781
	IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
782
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
783

784
785
    sc_init_one(&replace_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
	IFHELP(nano_gotoline_msg, NANO_NO_KEY), NANO_GOTOLINE_FKEY,
786
	NANO_NO_KEY, VIEW, NULL);
787

788
#ifndef NANO_TINY
789
790
    sc_init_one(&replace_list, NANO_NO_KEY, case_sens_msg,
	IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
791
	NANO_NO_KEY, VIEW, NULL);
792

793
    sc_init_one(&replace_list, NANO_NO_KEY, backwards_msg,
794
	IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
795
	NANO_NO_KEY, VIEW, NULL);
796
#endif
797

798
#ifdef HAVE_REGEX_H
799
    sc_init_one(&replace_list, NANO_NO_KEY, regexp_msg,
800
	IFHELP(nano_regexp_msg, NANO_REGEXP_KEY), NANO_NO_KEY,
801
	NANO_NO_KEY, VIEW, NULL);
802
#endif
803

804
#ifndef NANO_TINY
805
    sc_init_one(&replace_list, NANO_PREVLINE_KEY, history_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
806
807
	IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
808
#endif
809

810
    free_shortcutage(&replace_list_2);
811

812
    sc_init_one(&replace_list_2, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
813
814
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
815
#ifndef DISABLE_HELP
816
	do_help_void
817
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
818
	nano_disabled_msg
819
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
820
	);
821

822
    sc_init_one(&replace_list_2, NANO_CANCEL_KEY, cancel_msg,
823
824
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
825

826
827
828
    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);
829

830
831
832
    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);
833

834
#ifndef NANO_TINY
835
    sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, history_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
836
837
	IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
838
839
#endif

840
    free_shortcutage(&gotoline_list);
Chris Allegretta's avatar
Chris Allegretta committed
841

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

852
    sc_init_one(&gotoline_list, NANO_CANCEL_KEY, cancel_msg,
853
854
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
855

856
    sc_init_one(&gotoline_list, NANO_FIRSTLINE_KEY, first_line_msg,
857
858
	IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
859

860
    sc_init_one(&gotoline_list, NANO_LASTLINE_KEY, last_line_msg,
861
862
	IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
	NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
863

864
865
    sc_init_one(&gotoline_list, NANO_TOOTHERWHEREIS_KEY,
	N_("Go To Text"), IFHELP(nano_whereis_msg, NANO_NO_KEY),
866
	NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL);
867

868
    free_shortcutage(&writefile_list);
Chris Allegretta's avatar
Chris Allegretta committed
869

870
    sc_init_one(&writefile_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
871
872
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
873
#ifndef DISABLE_HELP
874
	do_help_void
875
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
876
	nano_disabled_msg
877
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
878
	);
879

880
    sc_init_one(&writefile_list, NANO_CANCEL_KEY, cancel_msg,
881
882
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
883

884
#ifndef DISABLE_BROWSER
885
886
    /* If we're using restricted mode, the file browser is disabled.
     * It's useless since inserting files is disabled. */
887
888

    /* Translators: try to keep this string under 16 characters long. */
889
    if (!ISSET(RESTRICTED))
890
	sc_init_one(&writefile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
891
		IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
892
		NANO_NO_KEY, NOVIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
893
#endif
Chris Allegretta's avatar
Chris Allegretta committed
894

895
#ifndef NANO_TINY
896
897
898
899
900
901
    /* 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. */
902
903

    /* Translators: try to keep this string under 16 characters long. */
904
    if (!ISSET(RESTRICTED))
905
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("DOS Format"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
906
		IFHELP(nano_dos_msg, TOGGLE_DOS_KEY), NANO_NO_KEY,
907
		NANO_NO_KEY, NOVIEW, NULL);
908

909
    /* Translators: try to keep this string under 16 characters long. */
910
    if (!ISSET(RESTRICTED))
911
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Mac Format"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
912
		IFHELP(nano_mac_msg, TOGGLE_MAC_KEY), NANO_NO_KEY,
913
		NANO_NO_KEY, NOVIEW, NULL);
914
915
#endif

916
    /* Translators: try to keep this string under 16 characters long. */
917
    if (!ISSET(RESTRICTED))
918
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Append"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
919
		IFHELP(nano_append_msg, NANO_APPEND_KEY), NANO_NO_KEY,
920
		NANO_NO_KEY, NOVIEW, NULL);
921

922
    /* Translators: try to keep this string under 16 characters long. */
923
    if (!ISSET(RESTRICTED))
924
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Prepend"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
925
		IFHELP(nano_prepend_msg, NANO_PREPEND_KEY), NANO_NO_KEY,
926
		NANO_NO_KEY, NOVIEW, NULL);
927

928
#ifndef NANO_TINY
929
    /* Translators: try to keep this string under 16 characters long. */
930
    if (!ISSET(RESTRICTED))
931
	sc_init_one(&writefile_list, NANO_NO_KEY, N_("Backup File"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
932
		IFHELP(nano_backup_msg, TOGGLE_BACKUP_KEY), NANO_NO_KEY,
933
		NANO_NO_KEY, NOVIEW, NULL);
934
935
#endif

936
    free_shortcutage(&insertfile_list);
937

938
    sc_init_one(&insertfile_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
939
940
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
941
#ifndef DISABLE_HELP
942
	do_help_void
943
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
944
	nano_disabled_msg
945
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
946
	);
947

948
    sc_init_one(&insertfile_list, NANO_CANCEL_KEY, cancel_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
949
950
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
951

952
#ifndef DISABLE_BROWSER
953
954
    /* If we're using restricted mode, the file browser is disabled.
     * It's useless since inserting files is disabled. */
955
    if (!ISSET(RESTRICTED))
956
	sc_init_one(&insertfile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
957
		IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
958
		NANO_NO_KEY, NOVIEW, NULL);
959
#endif
960

961
#ifndef NANO_TINY
962
963
    /* If we're using restricted mode, command execution is disabled.
     * It's useless since inserting files is disabled. */
964
965

    /* Translators: try to keep this string under 22 characters long. */
966
    if (!ISSET(RESTRICTED))
967
968
	sc_init_one(&insertfile_list, NANO_TOOTHERINSERT_KEY,
		N_("Execute Command"), IFHELP(nano_execute_msg,
969
		NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
970

971
#ifdef ENABLE_MULTIBUFFER
972
973
    /* If we're using restricted mode, the multibuffer toggle is
     * disabled.  It's useless since inserting files is disabled. */
974
975

    /* Translators: try to keep this string under 22 characters long. */
976
    if (!ISSET(RESTRICTED))
977
	sc_init_one(&insertfile_list, NANO_NO_KEY, new_buffer_msg,
978
		IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY),
979
		NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
980
#endif
981
#endif
982

983
#ifndef NANO_TINY
984
    free_shortcutage(&extcmd_list);
Chris Allegretta's avatar
Chris Allegretta committed
985

986
    sc_init_one(&extcmd_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
987
988
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
989
#ifndef DISABLE_HELP
990
	do_help_void
991
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
992
	nano_disabled_msg
993
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
994
	);
995

996
    sc_init_one(&extcmd_list, NANO_CANCEL_KEY, cancel_msg,
997
998
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
999

1000
1001
    sc_init_one(&extcmd_list, NANO_TOOTHERINSERT_KEY, N_("Insert File"),
	IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_NO_KEY,
1002
	NANO_NO_KEY, VIEW, NULL);
1003

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1004
#ifdef ENABLE_MULTIBUFFER
1005
    sc_init_one(&extcmd_list, NANO_NO_KEY, new_buffer_msg,
1006
	IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY),
1007
	NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
1008
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1009
#endif
1010

1011
1012
1013
1014
#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
1015
1016
	IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
1017
1018

    sc_init_one(&help_list, NANO_EXIT_KEY, exit_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1019
1020
	IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY, NANO_NO_KEY,
	VIEW, NULL);
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042

    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
1043
1044
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
1045
#ifndef DISABLE_HELP
1046
	do_help_void
1047
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1048
	nano_disabled_msg
1049
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1050
	);
1051
1052

    sc_init_one(&spell_list, NANO_CANCEL_KEY, cancel_msg,
1053
1054
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
1055
1056
#endif

1057
#ifndef DISABLE_BROWSER
1058
    free_shortcutage(&browser_list);
1059

1060
    sc_init_one(&browser_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1061
1062
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW, NULL);
1063

1064
    sc_init_one(&browser_list, NANO_EXIT_KEY, exit_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1065
	IFHELP(nano_exitbrowser_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
1066
	NANO_NO_KEY, VIEW, NULL);
1067

1068
1069
    sc_init_one(&browser_list, NANO_PREVPAGE_KEY, prev_page_msg,
	IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
1070
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1071

1072
1073
    sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, next_page_msg,
	IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
1074
	NANO_NO_KEY, VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1075

1076
1077
1078
1079
1080
1081
1082
1083
    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);

1084
    /* Translators: try to keep this string under 22 characters long. */
1085
    sc_init_one(&browser_list, NANO_GOTOLINE_KEY, N_("Go To Dir"),
1086
	IFHELP(nano_gotodir_msg, NANO_GOTOLINE_ALTKEY),
1087
	NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW, NULL);
Rocco Corsi's avatar
   
Rocco Corsi committed
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
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
    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

1135
    free_shortcutage(&gotodir_list);
1136

1137
    sc_init_one(&gotodir_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1138
1139
	IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
	VIEW,
1140
#ifndef DISABLE_HELP
1141
	do_help_void
1142
#else
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1143
	nano_disabled_msg
1144
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1145
	);
Chris Allegretta's avatar
Chris Allegretta committed
1146

1147
    sc_init_one(&gotodir_list, NANO_CANCEL_KEY, cancel_msg,
1148
1149
	IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
	VIEW, NULL);
Chris Allegretta's avatar
Chris Allegretta committed
1150
1151
#endif

1152
    currshortcut = main_list;
1153

1154
#ifndef NANO_TINY
1155
    toggle_init();
1156
#endif
1157
}
1158

1159
1160
1161
1162
/* Deallocate the given shortcut. */
void free_shortcutage(shortcut **shortcutage)
{
    assert(shortcutage != NULL);
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1163

1164
1165
1166
1167
1168
1169
1170
    while (*shortcutage != NULL) {
	shortcut *ps = *shortcutage;
	*shortcutage = (*shortcutage)->next;
	free(ps);
    }
}

1171
#ifndef NANO_TINY
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1172
/* Create a new toggle structure, at the end of the toggles linked
1173
1174
1175
1176
1177
1178
 * list. */
void toggle_init_one(int val, const char *desc, long flag)
{
    toggle *u;

    if (toggles == NULL) {
1179
	toggles = (toggle *)nmalloc(sizeof(toggle));
1180
1181
1182
1183
	u = toggles;
    } else {
	for (u = toggles; u->next != NULL; u = u->next)
	    ;
1184
	u->next = (toggle *)nmalloc(sizeof(toggle));
1185
1186
1187
1188
1189
1190
1191
1192
1193
	u = u->next;
    }

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

1194
/* Initialize the global toggle list. */
1195
1196
1197
1198
1199
1200
1201
1202
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);
1203
1204
    toggle_init_one(TOGGLE_MORESPACE_KEY,
	N_("Use of more space for editing"), MORE_SPACE);
1205
1206
1207
1208
#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))
1209
1210
	toggle_init_one(TOGGLE_MULTIBUFFER_KEY,
		N_("Multiple file buffers"), MULTIBUFFER);
1211
#endif
1212
    toggle_init_one(TOGGLE_CUTTOEND_KEY, N_("Cut to end"), CUT_TO_END);
1213
#ifndef DISABLE_WRAPPING
1214
1215
    toggle_init_one(TOGGLE_WRAP_KEY, N_("Long line wrapping"),
	NO_WRAP);
1216
#endif
1217
1218
1219
#ifndef DISABLE_MOUSE
    toggle_init_one(TOGGLE_MOUSE_KEY, N_("Mouse support"), USE_MOUSE);
#endif
1220
1221
1222
1223
    /* 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);
1224
1225
1226
1227
1228
1229
    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);
1230
1231
1232
    /* If we're using restricted mode, the DOS/Mac conversion toggle is
     * disabled.  It's useless since inserting files is disabled. */
    if (!ISSET(RESTRICTED))
1233
1234
	toggle_init_one(TOGGLE_NOCONVERT_KEY,
		N_("No conversion from DOS/Mac format"), NO_CONVERT);
1235
1236
1237
    /* If we're using restricted mode, the backup toggle is disabled.
     * It's useless since backups are disabled. */
    if (!ISSET(RESTRICTED))
1238
1239
1240
	toggle_init_one(TOGGLE_BACKUP_KEY, N_("Backup files"),
		BACKUP_FILE);
    toggle_init_one(TOGGLE_SMOOTH_KEY, N_("Smooth scrolling"),
1241
	SMOOTH_SCROLL);
1242
1243
    toggle_init_one(TOGGLE_SMARTHOME_KEY, N_("Smart home key"),
	SMART_HOME);
1244
1245
#ifdef ENABLE_COLOR
    toggle_init_one(TOGGLE_SYNTAX_KEY, N_("Color syntax highlighting"),
1246
	NO_COLOR_SYNTAX);
1247
1248
1249
1250
1251
1252
#endif
#ifdef ENABLE_NANORC
    toggle_init_one(TOGGLE_WHITESPACE_KEY, N_("Whitespace display"),
	WHITESPACE_DISPLAY);
#endif
}
1253
#endif /* !NANO_TINY */
1254

1255
1256
1257
/* 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
1258
 * function unless debugging is turned on. */
1259
#ifdef DEBUG
1260
/* Added by SPK for memory cleanup; gracefully return our malloc()s. */
Chris Allegretta's avatar
Chris Allegretta committed
1261
void thanks_for_all_the_fish(void)
1262
{
1263
1264
1265
1266
    delwin(topwin);
    delwin(edit);
    delwin(bottomwin);

Chris Allegretta's avatar
Chris Allegretta committed
1267
1268
1269
#ifndef DISABLE_JUSTIFY
    if (quotestr != NULL)
	free(quotestr);
1270
1271
#ifdef HAVE_REGEX_H
    regfree(&quotereg);
1272
1273
    if (quoteerr != NULL)
	free(quoteerr);
1274
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1275
#endif
1276
#ifndef NANO_TINY
1277
1278
1279
    if (backup_dir != NULL)
        free(backup_dir);
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1280
#ifndef DISABLE_OPERATINGDIR
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
    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);
1293
#endif
1294
1295
1296
    if (answer != NULL)
	free(answer);
    if (cutbuffer != NULL)
Chris Allegretta's avatar
Chris Allegretta committed
1297
	free_filestruct(cutbuffer);
1298
1299
1300
1301
#ifndef DISABLE_JUSTIFY
    if (jusbuffer != NULL)
	free_filestruct(jusbuffer);
#endif
1302
1303
1304
1305
    free_shortcutage(&main_list);
    free_shortcutage(&whereis_list);
    free_shortcutage(&replace_list);
    free_shortcutage(&replace_list_2);
1306
    free_shortcutage(&gotoline_list);
1307
1308
    free_shortcutage(&writefile_list);
    free_shortcutage(&insertfile_list);
1309
1310
1311
#ifndef NANO_TINY
    free_shortcutage(&extcmd_list);
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1312
#ifndef DISABLE_HELP
Chris Allegretta's avatar
Chris Allegretta committed
1313
    free_shortcutage(&help_list);
Chris Allegretta's avatar
Chris Allegretta committed
1314
1315
#endif
#ifndef DISABLE_SPELLER
1316
    free_shortcutage(&spell_list);
Chris Allegretta's avatar
Chris Allegretta committed
1317
#endif
1318
1319
#ifndef DISABLE_BROWSER
    free_shortcutage(&browser_list);
Chris Allegretta's avatar
Chris Allegretta committed
1320
    free_shortcutage(&gotodir_list);
1321
#endif
1322
#ifndef NANO_TINY
1323
    /* Free the memory associated with each toggle. */
1324
1325
    while (toggles != NULL) {
	toggle *t = toggles;
1326

1327
1328
1329
1330
	toggles = toggles->next;
	free(t);
    }
#endif
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1331
    /* Free the memory associated with each open file buffer. */
1332
    if (openfile != NULL)
1333
	free_openfilestruct(openfile);
Chris Allegretta's avatar
Chris Allegretta committed
1334
#ifdef ENABLE_COLOR
1335
1336
    if (syntaxstr != NULL)
	free(syntaxstr);
Chris Allegretta's avatar
Chris Allegretta committed
1337
1338
1339
1340
1341
1342
1343
1344
    while (syntaxes != NULL) {
	syntaxtype *bill = syntaxes;

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

	    syntaxes->extensions = bob->next;
1345
	    free(bob->ext_regex);
1346
1347
1348
1349
	    if (bob->ext != NULL) {
		regfree(bob->ext);
		free(bob->ext);
	    }
Chris Allegretta's avatar
Chris Allegretta committed
1350
1351
1352
1353
1354
1355
	    free(bob);
	}
	while (syntaxes->color != NULL) {
	    colortype *bob = syntaxes->color;

	    syntaxes->color = bob->next;
1356
	    free(bob->start_regex);
1357
1358
1359
1360
	    if (bob->start != NULL) {
		regfree(bob->start);
		free(bob->start);
	    }
1361
1362
	    if (bob->end_regex != NULL)
		free(bob->end_regex);
1363
	    if (bob->end != NULL) {
1364
		regfree(bob->end);
1365
1366
		free(bob->end);
	    }
Chris Allegretta's avatar
Chris Allegretta committed
1367
1368
1369
1370
1371
1372
	    free(bob);
	}
	syntaxes = syntaxes->next;
	free(bill);
    }
#endif /* ENABLE_COLOR */
1373
#ifndef NANO_TINY
1374
    /* Free the search and replace history lists. */
1375
1376
1377
1378
    if (searchage != NULL)
	free_filestruct(searchage);
    if (replaceage != NULL)
	free_filestruct(replaceage);
1379
#endif
1380
#ifdef ENABLE_NANORC
1381
1382
    if (homedir != NULL)
	free(homedir);
1383
#endif
1384
}
1385
#endif /* DEBUG */