global.c 35 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                             *
Chris Allegretta's avatar
Chris Allegretta committed
6
7
 *   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 *
8
 *   the Free Software Foundation; either version 2, or (at your option)  *
Chris Allegretta's avatar
Chris Allegretta committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *   any later version.                                                   *
 *                                                                        *
 *   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.                         *
 *                                                                        *
 *   You should have received a copy of the GNU General Public License    *
 *   along with this program; if not, write to the Free Software          *
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.            *
 *                                                                        *
 **************************************************************************/

#include "config.h"
23

24
#include <stdlib.h>
25
#include <assert.h>
26
#include <sys/stat.h>
Chris Allegretta's avatar
Chris Allegretta committed
27
#include "proto.h"
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
28
#include "nano.h"
Chris Allegretta's avatar
Chris Allegretta committed
29

Chris Allegretta's avatar
Chris Allegretta committed
30
/* Global variables */
31

32
#ifndef DISABLE_WRAPJUSTIFY
Chris Allegretta's avatar
Chris Allegretta committed
33
34
/* wrap_at might be set in rcfile.c or nano.c */
int wrap_at = -CHARS_FROM_EOL;/* Right justified fill value, allows resize */
35
36
#endif

Chris Allegretta's avatar
Chris Allegretta committed
37
38
39
char *last_search = NULL;	/* Last string we searched for */
char *last_replace = NULL;	/* Last replacement string */
int search_last_line;		/* Is this the last search line? */
Chris Allegretta's avatar
Chris Allegretta committed
40
int search_offscreen;		/* Search lines not displayed */
Chris Allegretta's avatar
Chris Allegretta committed
41

42
int flags = 0;			/* Our new flag containing many options */
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
43
WINDOW *edit;			/* The file portion of the editor */
Chris Allegretta's avatar
Chris Allegretta committed
44
45
WINDOW *topwin;			/* Top line of screen */
WINDOW *bottomwin;		/* Bottom buffer */
Chris Allegretta's avatar
Chris Allegretta committed
46
char *filename = NULL;		/* Name of the file */
47
48
49
50
51

#ifndef NANO_SMALL
struct stat originalfilestat;	/* Stat for the file as we loaded it */
#endif

Chris Allegretta's avatar
Chris Allegretta committed
52
53
54
55
56
57
58
59
60
61
62
63
64
int editwinrows = 0;		/* How many rows long is the edit
				   window? */
filestruct *current;		/* Current buffer pointer */
int current_x = 0, current_y = 0;	/* Current position of X and Y in
					   the editor - relative to edit
					   window (0,0) */
filestruct *fileage = NULL;	/* Our file buffer */
filestruct *edittop = NULL;	/* Pointer to the top of the edit
				   buffer with respect to the
				   file struct */
filestruct *filebot = NULL;	/* Last node in the file struct */
filestruct *cutbuffer = NULL;	/* A place to store cut text */

65
#ifdef ENABLE_MULTIBUFFER
66
openfilestruct *open_files = NULL;	/* The list of open files */
67
68
#endif

69
#ifndef DISABLE_JUSTIFY
Chris Allegretta's avatar
Chris Allegretta committed
70
71
char *quotestr = NULL;		/* Quote string.  The default value is
				   set in main(). */
Chris Allegretta's avatar
Chris Allegretta committed
72
#endif
73

74
75
76
77
#ifndef NANO_SMALL
char *backup_dir = NULL;	/* Backup directory. */
#endif

78
79
int resetstatuspos;		/* Hack for resetting the status bar 
				   cursor position */
Chris Allegretta's avatar
Chris Allegretta committed
80
char *answer = NULL;		/* Answer str to many questions */
Chris Allegretta's avatar
Chris Allegretta committed
81
int totlines = 0;		/* Total number of lines in the file */
82
long totsize = 0;		/* Total number of bytes in the file */
83
int placewewant = 0;		/* The column we'd like the cursor
Chris Allegretta's avatar
Chris Allegretta committed
84
85
86
				   to jump to when we go to the
				   next or previous line */

Chris Allegretta's avatar
Chris Allegretta committed
87
88
int tabsize = -1;		/* Our internal tabsize variable.  The
				   default value 8 is set in main(). */
89

Chris Allegretta's avatar
Chris Allegretta committed
90
char *hblank = NULL;		/* A horizontal blank line */
Chris Allegretta's avatar
Chris Allegretta committed
91
#ifndef DISABLE_HELP
Chris Allegretta's avatar
Chris Allegretta committed
92
char *help_text;		/* The text in the help window */
Chris Allegretta's avatar
Chris Allegretta committed
93
#endif
Chris Allegretta's avatar
Chris Allegretta committed
94
95
96

/* More stuff for the marker select */

Chris Allegretta's avatar
Chris Allegretta committed
97
#ifndef NANO_SMALL
98
filestruct *mark_beginbuf;	/* The begin marker buffer */
Chris Allegretta's avatar
Chris Allegretta committed
99
int mark_beginx;		/* X value in the string to start */
Chris Allegretta's avatar
Chris Allegretta committed
100
#endif
Chris Allegretta's avatar
Chris Allegretta committed
101

102
#ifndef DISABLE_OPERATINGDIR
103
104
char *operating_dir = NULL;	/* Operating directory, which we can't */
char *full_operating_dir = NULL;/* go higher than */
105
106
#endif

107
#ifndef DISABLE_SPELLER
108
char *alt_speller = NULL;		/* Alternative spell command */
109
110
#endif

111
112
113
shortcut *main_list = NULL;
shortcut *whereis_list = NULL;
shortcut *replace_list = NULL;
114
shortcut *replace_list_2 = NULL; 	/* 2nd half of replace dialog */
115
116
117
shortcut *goto_list = NULL;
shortcut *writefile_list = NULL;
shortcut *insertfile_list = NULL;
Chris Allegretta's avatar
Chris Allegretta committed
118
#ifndef DISABLE_HELP
119
shortcut *help_list = NULL;
Chris Allegretta's avatar
Chris Allegretta committed
120
121
#endif
#ifndef DISABLE_SPELLER
122
shortcut *spell_list = NULL;
Chris Allegretta's avatar
Chris Allegretta committed
123
#endif
Chris Allegretta's avatar
Chris Allegretta committed
124
#ifndef NANO_SMALL
125
shortcut *extcmd_list = NULL;
Chris Allegretta's avatar
Chris Allegretta committed
126
#endif
127
#ifndef DISABLE_BROWSER
128
shortcut *browser_list = NULL;
129
shortcut *gotodir_list = NULL;
Chris Allegretta's avatar
Chris Allegretta committed
130
#endif
131

132
#ifdef ENABLE_COLOR
133
134
135
const colortype *colorstrings = NULL;
syntaxtype *syntaxes = NULL;
char *syntaxstr = NULL;
136
137
#endif

138
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
Chris Allegretta's avatar
Chris Allegretta committed
139
const shortcut *currshortcut;	/* Current shortcut list we're using */
140
#endif
141

142
#ifndef NANO_SMALL
143
toggle *toggles = NULL;
144
#endif
Chris Allegretta's avatar
Chris Allegretta committed
145

146
147
148
149
150
#ifndef NANO_SMALL
historyheadtype search_history;
historyheadtype replace_history;
#endif

151
152
/* Regular expressions */

153
#ifdef HAVE_REGEX_H
154
155
156
regex_t search_regexp;		/* Global to store compiled search regexp */
regmatch_t regmatches[10];	/* Match positions for parenthetical
				   subexpressions, max of 10 */
Chris Allegretta's avatar
Chris Allegretta committed
157
#endif
158

159
160
161
162
163
int curses_ended = FALSE;	/* Indicates to statusbar() to simply
				 * write to stderr, since endwin() has
				 * ended curses mode. */


David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
164
int length_of_list(const shortcut *s)
165
166
{
    int i = 0;
167

168
    for (; s != NULL; s = s->next)
169
170
171
172
	i++;
    return i;
}

Chris Allegretta's avatar
Chris Allegretta committed
173
/* Initialize a struct *without* our lovely braces =( */
174
void sc_init_one(shortcut **shortcutage, int key, const char *desc,
175
#ifndef DISABLE_HELP
176
	const char *help,
177
#endif
178
	int meta, int func_key, int misc, int view, int (*func) (void))
Chris Allegretta's avatar
Chris Allegretta committed
179
{
180
181
182
    shortcut *s;

    if (*shortcutage == NULL) {
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
183
	*shortcutage = (shortcut *)nmalloc(sizeof(shortcut));
184
185
186
187
	s = *shortcutage;
    } else {
	for (s = *shortcutage; s->next != NULL; s = s->next)
	    ;
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
188
	s->next = (shortcut *)nmalloc(sizeof(shortcut));
189
190
191
	s = s->next; 
    }

Chris Allegretta's avatar
Chris Allegretta committed
192
193
    s->val = key;
    s->desc = desc;
194
#ifndef DISABLE_HELP
Chris Allegretta's avatar
Chris Allegretta committed
195
    s->help = help;
196
#endif
197
    s->metaval = meta;
198
199
    s->func_key = func_key;
    s->misc = misc;
Chris Allegretta's avatar
Chris Allegretta committed
200
201
    s->viewok = view;
    s->func = func;
202
    s->next = NULL;
Chris Allegretta's avatar
Chris Allegretta committed
203
204
}

205
#ifndef NANO_SMALL
206
207
/* Create one new toggle structure, at the end of the toggles
 * linked list. */
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
208
void toggle_init_one(int val, const char *desc, int flag)
209
{
210
211
212
    toggle *u;

    if (toggles == NULL) {
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
213
	toggles = (toggle *)nmalloc(sizeof(toggle));
214
215
216
217
	u = toggles;
    } else {
	for (u = toggles; u->next != NULL; u = u->next)
	    ;
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
218
	u->next = (toggle *)nmalloc(sizeof(toggle));
219
220
221
222
223
224
225
	u = u->next;
    }

    u->val = val;
    u->desc = desc;
    u->flag = flag;
    u->next = NULL;
226
227
}

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
228
void toggle_init(void)
229
230
{
    char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg,
231
	*toggle_nohelp_msg, *toggle_cuttoend_msg,
232
233
	*toggle_noconvert_msg, *toggle_dos_msg, *toggle_mac_msg,
	*toggle_backup_msg, *toggle_smooth_msg;
234
#ifndef DISABLE_MOUSE
235
236
    char *toggle_mouse_msg;
#endif
Chris Allegretta's avatar
Chris Allegretta committed
237
238
239
#ifndef DISABLE_WRAPPING
    char *toggle_wrap_msg;
#endif
240
#ifdef ENABLE_MULTIBUFFER
241
    char *toggle_multibuffer_msg;
242
#endif
243
244
245
#ifdef ENABLE_COLOR
    char *toggle_syntax_msg;
#endif
246

247
    /* There is no need to reinitialize the toggles.  They can't
Chris Allegretta's avatar
Chris Allegretta committed
248
       change. */
249
250
251
    if (toggles != NULL)
	return;

252
    toggle_const_msg = _("Constant cursor position");
253
    toggle_autoindent_msg = _("Auto indent");
254
    toggle_suspend_msg = _("Suspend");
255
    toggle_nohelp_msg = _("Help mode");
256
#ifndef DISABLE_MOUSE
257
    toggle_mouse_msg = _("Mouse support");
258
#endif
259
    toggle_cuttoend_msg = _("Cut to end");
260
261
262
    toggle_noconvert_msg = _("No conversion from DOS/Mac format");
    toggle_dos_msg = _("Writing file in DOS format");
    toggle_mac_msg = _("Writing file in Mac format");
263
    toggle_backup_msg = _("Backing up file");
264
    toggle_smooth_msg = _("Smooth scrolling");
265
266
267
#ifdef ENABLE_COLOR
    toggle_syntax_msg = _("Color syntax highlighting");
#endif
Chris Allegretta's avatar
Chris Allegretta committed
268
#ifndef DISABLE_WRAPPING
269
    toggle_wrap_msg = _("Auto line wrap");
Chris Allegretta's avatar
Chris Allegretta committed
270
#endif
271
#ifdef ENABLE_MULTIBUFFER
272
    toggle_multibuffer_msg = _("Multiple file buffers");
273
274
#endif

275
276
277
278
    toggle_init_one(TOGGLE_NOHELP_KEY, toggle_nohelp_msg, NO_HELP);
#ifdef ENABLE_MULTIBUFFER
    toggle_init_one(TOGGLE_MULTIBUFFER_KEY, toggle_multibuffer_msg, MULTIBUFFER);
#endif
279
280
    toggle_init_one(TOGGLE_CONST_KEY, toggle_const_msg, CONSTUPDATE);
    toggle_init_one(TOGGLE_AUTOINDENT_KEY, toggle_autoindent_msg, AUTOINDENT);
Chris Allegretta's avatar
Chris Allegretta committed
281
#ifndef DISABLE_WRAPPING
282
    toggle_init_one(TOGGLE_WRAP_KEY, toggle_wrap_msg, NO_WRAP);
Chris Allegretta's avatar
Chris Allegretta committed
283
#endif
284
285
    toggle_init_one(TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, CUT_TO_END);
    toggle_init_one(TOGGLE_SUSPEND_KEY, toggle_suspend_msg, SUSPEND);
286
#ifndef DISABLE_MOUSE
287
    toggle_init_one(TOGGLE_MOUSE_KEY, toggle_mouse_msg, USE_MOUSE);
288
#endif
289
290
291
    toggle_init_one(TOGGLE_NOCONVERT_KEY, toggle_noconvert_msg, NO_CONVERT);
    toggle_init_one(TOGGLE_DOS_KEY, toggle_dos_msg, DOS_FILE);
    toggle_init_one(TOGGLE_MAC_KEY, toggle_mac_msg, MAC_FILE);
292
    toggle_init_one(TOGGLE_BACKUP_KEY, toggle_backup_msg, BACKUP_FILE);
293
    toggle_init_one(TOGGLE_SMOOTH_KEY, toggle_smooth_msg, SMOOTHSCROLL);
294
295
296
#ifdef ENABLE_COLOR
    toggle_init_one(TOGGLE_SYNTAX_KEY, toggle_syntax_msg, COLOR_SYNTAX);
#endif
297
}
298
299
300
301
302
303
304
305
306
307
308
309
310

#ifdef DEBUG
/* Deallocate all of the toggles. */
void free_toggles(void)
{
    while (toggles != NULL) {
	toggle *pt = toggles;	/* Think "previous toggle" */

	toggles = toggles->next;
	free(pt);
    }
}
#endif
311
#endif /* !NANO_SMALL */
312
313

/* Deallocate the given shortcut. */
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
314
void free_shortcutage(shortcut **shortcutage)
315
316
{
    assert(shortcutage != NULL);
Chris Allegretta's avatar
Chris Allegretta committed
317
318
319
    while (*shortcutage != NULL) {
	shortcut *ps = *shortcutage;
	*shortcutage = (*shortcutage)->next;
320
321
	free(ps);
    }
322
323
}

324
void shortcut_init(int unjustify)
Chris Allegretta's avatar
Chris Allegretta committed
325
{
326
#ifndef DISABLE_HELP
327
328
329
330
331
332
333
    const char *nano_help_msg = "", *nano_writeout_msg =
	"", *nano_exit_msg = "", *nano_goto_msg =
	"", *nano_justify_msg = "", *nano_replace_msg =
	"", *nano_insert_msg = "", *nano_whereis_msg =
	"", *nano_whereis_next_msg = "", *nano_prevpage_msg =
	"", *nano_nextpage_msg = "", *nano_cut_msg =
	"", *nano_uncut_msg = "", *nano_cursorpos_msg =
334
335
	"", *nano_spell_msg = "", *nano_prevline_msg =
	"", *nano_nextline_msg = "", *nano_forward_msg =
336
	"", *nano_back_msg = "", *nano_home_msg =
Chris Allegretta's avatar
Chris Allegretta committed
337
338
339
340
	"", *nano_end_msg = "", *nano_firstline_msg =
	"", *nano_lastline_msg = "", *nano_refresh_msg =
	"", *nano_mark_msg = "", *nano_delete_msg =
	"", *nano_backspace_msg = "", *nano_tab_msg =
341
342
343
344
345
346
347
348
349
350
	"", *nano_enter_msg = "", *nano_prevword_msg =
	"", *nano_nextword_msg = "", *nano_verbatim_msg =
	"", *nano_cancel_msg = "", *nano_unjustify_msg =
	"", *nano_append_msg = "", *nano_prepend_msg =
	"", *nano_tofiles_msg = "", *nano_gotodir_msg =
	"", *nano_case_msg = "", *nano_reverse_msg =
	"", *nano_execute_msg = "", *nano_dos_msg =
	"", *nano_mac_msg = "", *nano_backup_msg =
	"", *nano_editstr_msg = "", *nano_parabegin_msg =
	"", *nano_paraend_msg = "";
Chris Allegretta's avatar
Chris Allegretta committed
351

Chris Allegretta's avatar
Chris Allegretta committed
352
#ifdef ENABLE_MULTIBUFFER
353
    const char *nano_openprev_msg = "", *nano_opennext_msg =
354
	"", *nano_multibuffer_msg = "";
Chris Allegretta's avatar
Chris Allegretta committed
355
#endif
356
#ifdef HAVE_REGEX_H
357
    const char *nano_regexp_msg = "", *nano_bracket_msg = "";
358
#endif
359

Chris Allegretta's avatar
Chris Allegretta committed
360
361
    nano_help_msg = _("Invoke the help menu");
    nano_writeout_msg = _("Write the current file to disk");
362
#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
363
    nano_exit_msg = _("Close current file buffer/Exit from nano");
364
#else
Chris Allegretta's avatar
Chris Allegretta committed
365
    nano_exit_msg = _("Exit from nano");
366
#endif
367
    nano_goto_msg = _("Go to a specific line number");
Chris Allegretta's avatar
Chris Allegretta committed
368
    nano_justify_msg = _("Justify the current paragraph");
369
    nano_unjustify_msg = _("Unjustify after a justify");
Chris Allegretta's avatar
Chris Allegretta committed
370
371
372
    nano_replace_msg = _("Replace text within the editor");
    nano_insert_msg = _("Insert another file into the current one");
    nano_whereis_msg = _("Search for text within the editor");
373
    nano_whereis_next_msg = _("Repeat last search");
Chris Allegretta's avatar
Chris Allegretta committed
374
375
376
377
    nano_prevpage_msg = _("Move to the previous screen");
    nano_nextpage_msg = _("Move to the next screen");
    nano_cut_msg = _("Cut the current line and store it in the cutbuffer");
    nano_uncut_msg = _("Uncut from the cutbuffer into the current line");
378
    nano_cursorpos_msg = _("Show the position of the cursor");
379
    nano_spell_msg = _("Invoke the spell checker, if available");
380
381
    nano_prevline_msg = _("Move to the previous line");
    nano_nextline_msg = _("Move to the next line");
Chris Allegretta's avatar
Chris Allegretta committed
382
383
384
385
386
387
388
389
390
391
392
393
394
    nano_forward_msg = _("Move forward one character");
    nano_back_msg = _("Move back one character");
    nano_home_msg = _("Move to the beginning of the current line");
    nano_end_msg = _("Move to the end of the current line");
    nano_firstline_msg = _("Go to the first line of the file");
    nano_lastline_msg = _("Go to the last line of the file");
    nano_refresh_msg = _("Refresh (redraw) the current screen");
    nano_mark_msg = _("Mark text at the current cursor location");
    nano_delete_msg = _("Delete the character under the cursor");
    nano_backspace_msg =
	_("Delete the character to the left of the cursor");
    nano_tab_msg = _("Insert a tab character");
    nano_enter_msg = _("Insert a carriage return at the cursor position");
395
396
397
398
    nano_prevword_msg = _("Move backward one word");
    nano_nextword_msg = _("Move forward one word");
    nano_verbatim_msg = _("Insert character(s) verbatim");
    nano_enter_msg = _("Insert a carriage return at the cursor position");
Chris Allegretta's avatar
Chris Allegretta committed
399
400
    nano_case_msg =
	_("Make the current search or replace case (in)sensitive");
Chris Allegretta's avatar
Chris Allegretta committed
401
    nano_tofiles_msg = _("Go to file browser");
402
    nano_execute_msg = _("Execute external command");
403
    nano_gotodir_msg = _("Go to directory");
Chris Allegretta's avatar
Chris Allegretta committed
404
    nano_cancel_msg = _("Cancel the current function");
405
    nano_append_msg = _("Append to the current file");
406
    nano_prepend_msg = _("Prepend to the current file");
407
    nano_reverse_msg = _("Search backwards");
408
409
    nano_dos_msg = _("Write file out in DOS format");
    nano_mac_msg = _("Write file out in Mac format");
410
    nano_backup_msg = _("Back up original file when saving");
411
    nano_editstr_msg = _("Edit the previous search/replace strings");
412
413
    nano_parabegin_msg = _("Go to the beginning of the current paragraph");
    nano_paraend_msg = _("Go to the end of the current paragraph");
414
#ifdef HAVE_REGEX_H
415
    nano_regexp_msg = _("Use regular expressions");
416
    nano_bracket_msg = _("Find other bracket");
417
#endif
418
#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
419
420
    nano_openprev_msg = _("Switch to previous file buffer");
    nano_opennext_msg = _("Switch to next file buffer");
421
    nano_multibuffer_msg = _("Toggle insert into new file buffer");
Chris Allegretta's avatar
Chris Allegretta committed
422
#endif
423
#endif /* !DISABLE_HELP */
Chris Allegretta's avatar
Chris Allegretta committed
424

425
    free_shortcutage(&main_list);
426

427
428
429
/* 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 fourth one should not be there. */
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
430
#ifndef DISABLE_HELP
431
#  define IFHELP(help, nextvar) help, nextvar
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
432
433
#else
#  define IFHELP(help, nextvar) nextvar
434
#endif
435

436
    /* Translators: try to keep this string under 10 characters long */
437
    sc_init_one(&main_list, NANO_HELP_KEY, _("Get Help"),
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, do_help);
Chris Allegretta's avatar
Chris Allegretta committed
440

441
#ifdef ENABLE_MULTIBUFFER
442
    if (open_files != NULL && (open_files->prev != NULL || open_files->next != NULL))
443
    /* Translators: try to keep this string under 10 characters long */
444
	sc_init_one(&main_list, NANO_EXIT_KEY, _("Close"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
445
446
		IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
		NANO_NO_KEY, VIEW, do_exit);
447
448
    else
#endif
449

450
    /* Translators: try to keep this string under 10 characters long */
451
	sc_init_one(&main_list, NANO_EXIT_KEY, _("Exit"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
452
453
		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
    sc_init_one(&main_list, NANO_WRITEOUT_KEY, _("WriteOut"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
457
458
		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, _("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, do_justify);
464

465
    /* this is so we can view multiple files */
466
    /* Translators: try to keep this string under 10 characters long */
467
    sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
468
469
		IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_INSERTFILE_FKEY,
		NANO_NO_KEY,
470
#ifdef ENABLE_MULTIBUFFER
471
		VIEW
472
#else
473
		NOVIEW
474
#endif
475
		, do_insertfile_void);
Chris Allegretta's avatar
Chris Allegretta committed
476

477
    /* Translators: try to keep this string under 10 characters long */
478
    sc_init_one(&main_list, NANO_WHEREIS_KEY, _("Where Is"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
479
480
		IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_WHEREIS_FKEY,
		NANO_NO_KEY, VIEW, do_search);
Chris Allegretta's avatar
Chris Allegretta committed
481

482
    /* Translators: try to keep this string under 10 characters long */
483
    sc_init_one(&main_list, NANO_PREVPAGE_KEY, _("Prev Page"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
484
485
		IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
		NANO_NO_KEY, VIEW, do_page_up);
Chris Allegretta's avatar
Chris Allegretta committed
486

487
    /* Translators: try to keep this string under 10 characters long */
488
    sc_init_one(&main_list, NANO_NEXTPAGE_KEY, _("Next Page"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
489
490
		IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
		NANO_NO_KEY, VIEW, do_page_down);
Chris Allegretta's avatar
Chris Allegretta committed
491

492
    /* Translators: try to keep this string under 10 characters long */
493
    sc_init_one(&main_list, NANO_CUT_KEY, _("Cut Text"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
494
495
		IFHELP(nano_cut_msg, NANO_NO_KEY), NANO_CUT_FKEY,
		NANO_NO_KEY, NOVIEW, do_cut_text);
Chris Allegretta's avatar
Chris Allegretta committed
496

497
    if (unjustify)
498
    /* Translators: try to keep this string under 10 characters long */
499
	sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, _("UnJustify"),
500
		IFHELP(nano_unjustify_msg, NANO_NO_KEY), NANO_UNJUSTIFY_FKEY,
501
		NANO_NO_KEY, NOVIEW, 0);
502
    else
503
    /* Translators: try to keep this string under 10 characters long */
504
	sc_init_one(&main_list, NANO_UNCUT_KEY, _("UnCut Txt"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
505
506
		IFHELP(nano_uncut_msg, NANO_NO_KEY), NANO_UNCUT_FKEY,
		NANO_NO_KEY, NOVIEW, do_uncut_text);
Chris Allegretta's avatar
Chris Allegretta committed
507

508
    /* Translators: try to keep this string under 10 characters long */
509
    sc_init_one(&main_list, NANO_CURSORPOS_KEY, _("Cur Pos"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
510
511
		IFHELP(nano_cursorpos_msg, NANO_NO_KEY), NANO_CURSORPOS_FKEY,
		NANO_NO_KEY, VIEW, do_cursorpos_void);
Chris Allegretta's avatar
Chris Allegretta committed
512

513
    /* Translators: try to keep this string under 10 characters long */
514
    sc_init_one(&main_list, NANO_SPELL_KEY, _("To Spell"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
515
516
		IFHELP(nano_spell_msg, NANO_NO_KEY), NANO_SPELL_FKEY,
		NANO_NO_KEY, NOVIEW, do_spell);
517
518

    sc_init_one(&main_list, NANO_GOTO_KEY, _("Go To Line"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
519
520
		IFHELP(nano_goto_msg, NANO_ALT_GOTO_KEY), NANO_GOTO_FKEY,
		NANO_NO_KEY, VIEW, do_gotoline_void);
521
522

    sc_init_one(&main_list, NANO_REPLACE_KEY, _("Replace"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
523
524
		IFHELP(nano_replace_msg, NANO_ALT_REPLACE_KEY), NANO_REPLACE_FKEY,
		NANO_NO_KEY, NOVIEW, do_replace);
Chris Allegretta's avatar
Chris Allegretta committed
525

526
527
    sc_init_one(&main_list, NANO_PREVLINE_KEY, _("Prev Line"),
		IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
528
		NANO_NO_KEY, VIEW, do_up);
Chris Allegretta's avatar
Chris Allegretta committed
529

530
531
    sc_init_one(&main_list, NANO_NEXTLINE_KEY, _("Next Line"),
		IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
532
		NANO_NO_KEY, VIEW, do_down);
Chris Allegretta's avatar
Chris Allegretta committed
533

534
    sc_init_one(&main_list, NANO_FORWARD_KEY, _("Forward"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
535
536
		IFHELP(nano_forward_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_right);
Chris Allegretta's avatar
Chris Allegretta committed
537

538
    sc_init_one(&main_list, NANO_BACK_KEY, _("Back"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
539
540
		IFHELP(nano_back_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_left);
Chris Allegretta's avatar
Chris Allegretta committed
541

542
    sc_init_one(&main_list, NANO_HOME_KEY, _("Home"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
543
544
		IFHELP(nano_home_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_home);
Chris Allegretta's avatar
Chris Allegretta committed
545

546
    sc_init_one(&main_list, NANO_END_KEY, _("End"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
547
548
		IFHELP(nano_end_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_end);
Chris Allegretta's avatar
Chris Allegretta committed
549

550
    sc_init_one(&main_list, NANO_REFRESH_KEY, _("Refresh"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
551
552
		IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, total_refresh);
Chris Allegretta's avatar
Chris Allegretta committed
553

554
    sc_init_one(&main_list, NANO_MARK_KEY, _("Mark Text"),
555
		IFHELP(nano_mark_msg, NANO_ALT_MARK_KEY),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
556
		NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_mark);
Chris Allegretta's avatar
Chris Allegretta committed
557

558
    sc_init_one(&main_list, NANO_DELETE_KEY, _("Delete"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
559
560
		IFHELP(nano_delete_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, do_delete);
Chris Allegretta's avatar
Chris Allegretta committed
561

562
    sc_init_one(&main_list, NANO_BACKSPACE_KEY, _("Backspace"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
563
564
		IFHELP(nano_backspace_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, do_backspace);
Chris Allegretta's avatar
Chris Allegretta committed
565

566
    sc_init_one(&main_list, NANO_TAB_KEY, _("Tab"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
567
568
		IFHELP(nano_tab_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, do_tab);
Chris Allegretta's avatar
Chris Allegretta committed
569

570
    sc_init_one(&main_list, NANO_ENTER_KEY, _("Enter"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
571
572
		IFHELP(nano_enter_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, do_enter);
573

574
575
#ifndef NANO_SMALL
    sc_init_one(&main_list, NANO_NEXTWORD_KEY, _("Next Word"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
576
577
		IFHELP(nano_nextword_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_next_word);
578

David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
579
580
581
    sc_init_one(&main_list, NANO_NO_KEY, _("Prev Word"),
		IFHELP(nano_prevword_msg, NANO_PREVWORD_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_prev_word);
582
#endif
583

David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
584
585
    sc_init_one(&main_list, NANO_NO_KEY, _("Verbatim Input"),
		IFHELP(nano_verbatim_msg, NANO_VERBATIM_KEY), NANO_NO_KEY,
586
		NANO_NO_KEY, NOVIEW, do_verbatim_input);
587

588
#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
589
590
591
    sc_init_one(&main_list, NANO_NO_KEY, _("Previous File"),
		IFHELP(nano_openprev_msg, NANO_OPENPREV_KEY), NANO_NO_KEY,
		NANO_OPENPREV_ALTKEY, VIEW, open_prevfile_void);
592

David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
593
594
595
    sc_init_one(&main_list, NANO_NO_KEY, _("Next File"),
		IFHELP(nano_opennext_msg, NANO_OPENNEXT_KEY), NANO_NO_KEY,
		NANO_OPENNEXT_ALTKEY, VIEW, open_nextfile_void);
596
#endif
597

598
#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
599
600
601
    sc_init_one(&main_list, NANO_NO_KEY, _("Find Other Bracket"),
		IFHELP(nano_bracket_msg, NANO_BRACKET_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_find_bracket);
602
603
#endif

David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
604
    sc_init_one(&main_list, NANO_NO_KEY, _("Where Is Next"),
605
		IFHELP(nano_whereis_next_msg, NANO_WHEREIS_NEXT_KEY),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
606
		NANO_NO_KEY, NANO_NO_KEY, VIEW, do_research);
607

608
    free_shortcutage(&whereis_list);
609

610
    sc_init_one(&whereis_list, NANO_HELP_KEY, _("Get Help"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
611
612
		IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
		NANO_NO_KEY, VIEW, do_help);
613

614
    /* Translators: try to keep this string under 10 characters long */
615
    sc_init_one(&whereis_list, NANO_CANCEL_KEY, _("Cancel"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
616
617
		IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
618

619
    /* Translators: try to keep this string under 10 characters long */
620
    sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, _("First Line"),
621
		IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
622
		NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
623

624
    /* Translators: try to keep this string under 10 characters long */
625
    sc_init_one(&whereis_list, NANO_LASTLINE_KEY, _("Last Line"),
626
		IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
627
		NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
628

629
    /* Translators: try to keep this string under 10 characters long */
630
    sc_init_one(&whereis_list, NANO_OTHERSEARCH_KEY, _("Replace"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
631
632
		IFHELP(nano_replace_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
		NANO_NO_KEY, VIEW, do_replace);
Chris Allegretta's avatar
Chris Allegretta committed
633

634
    /* Translators: try to keep this string under 10 characters long */
Chris Allegretta's avatar
Chris Allegretta committed
635
    sc_init_one(&whereis_list, NANO_FROMSEARCHTOGOTO_KEY, _("Go To Line"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
636
637
		IFHELP(nano_goto_msg, NANO_NO_KEY), NANO_GOTO_FKEY,
		NANO_NO_KEY, VIEW, do_gotoline_void);
638

639
640
641
#ifndef DISABLE_JUSTIFY
    /* Translators: try to keep this string under 10 characters long */
    sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, _("Beg of Par"),
642
		IFHELP(nano_parabegin_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
643
		NANO_NO_KEY, VIEW, do_para_begin);
644
645
646

    /* Translators: try to keep this string under 10 characters long */
    sc_init_one(&whereis_list, NANO_PARAEND_KEY, _("End of Par"),
647
		IFHELP(nano_paraend_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
648
		NANO_NO_KEY, VIEW, do_para_end);
649
650
#endif

651
#ifndef NANO_SMALL
652
    /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
653
654
655
    sc_init_one(&whereis_list, NANO_NO_KEY, _("Case Sens"),
		IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
656

657
    /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
658
659
660
    sc_init_one(&whereis_list, NANO_NO_KEY, _("Direction"),
		IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
Chris Allegretta's avatar
Chris Allegretta committed
661

662
#ifdef HAVE_REGEX_H
663
    /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
664
665
666
    sc_init_one(&whereis_list, NANO_NO_KEY, _("Regexp"),
		IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
667
#endif
668
669

#ifndef NANO_SMALL
670
    /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
671
672
673
    sc_init_one(&whereis_list, NANO_HISTORY_KEY, _("History"),
		IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
674
675
#endif

676
#endif /* !NANO_SMALL */
677

678
    free_shortcutage(&replace_list);
679

680
    sc_init_one(&replace_list, NANO_HELP_KEY, _("Get Help"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
681
682
		IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
		NANO_NO_KEY, VIEW, do_help);
683

684
    sc_init_one(&replace_list, NANO_CANCEL_KEY, _("Cancel"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
685
686
		IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
Chris Allegretta's avatar
Chris Allegretta committed
687

688
    sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, _("First Line"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
689
690
		IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
691

692
    sc_init_one(&replace_list, NANO_LASTLINE_KEY, _("Last Line"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
693
694
		IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
695

696
    /* Translators: try to keep this string under 12 characters long */
697
    sc_init_one(&replace_list, NANO_OTHERSEARCH_KEY, _("No Replace"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
698
699
		IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
		NANO_NO_KEY, VIEW, do_search);
Chris Allegretta's avatar
Chris Allegretta committed
700

701
    sc_init_one(&replace_list, NANO_FROMSEARCHTOGOTO_KEY, _("Go To Line"), 
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
702
703
		IFHELP(nano_goto_msg, NANO_NO_KEY), NANO_GOTO_FKEY,
		NANO_NO_KEY, VIEW, do_gotoline_void);
704

705
#ifndef NANO_SMALL
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
706
707
708
    sc_init_one(&replace_list, NANO_NO_KEY, _("Case Sens"),
		IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
709

David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
710
711
712
    sc_init_one(&replace_list, NANO_NO_KEY, _("Direction"),
		IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
713

714
#ifdef HAVE_REGEX_H
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
715
716
717
    sc_init_one(&replace_list, NANO_NO_KEY, _("Regexp"),
		IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
718
#endif
719

David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
720
721
    sc_init_one(&replace_list, NANO_HISTORY_KEY, _("History"),
		IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
722
		NANO_NO_KEY, VIEW, 0);
723
#endif /* !NANO_SMALL */
724

725
    free_shortcutage(&replace_list_2);
726

727
    sc_init_one(&replace_list_2, NANO_HELP_KEY, _("Get Help"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
728
729
		IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
		NANO_NO_KEY, VIEW, do_help);
730

731
    sc_init_one(&replace_list_2, NANO_CANCEL_KEY, _("Cancel"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
732
733
		IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
734

735
    sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, _("First Line"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
736
737
		IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_first_line);
738

739
    sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, _("Last Line"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
740
741
		IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_last_line);
742

743
#ifndef NANO_SMALL
744
    sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, _("History"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
745
		IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
746
		NANO_NO_KEY, VIEW, 0);
747
748
#endif

749
    free_shortcutage(&goto_list);
Chris Allegretta's avatar
Chris Allegretta committed
750

751
    sc_init_one(&goto_list, NANO_HELP_KEY, _("Get Help"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
752
753
		IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
		NANO_NO_KEY, VIEW, do_help);
754

755
    sc_init_one(&goto_list, NANO_CANCEL_KEY, _("Cancel"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
756
757
		IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
Chris Allegretta's avatar
Chris Allegretta committed
758

759
    sc_init_one(&goto_list, NANO_FIRSTLINE_KEY, _("First Line"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
760
761
		IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta's avatar
Chris Allegretta committed
762

763
    sc_init_one(&goto_list, NANO_LASTLINE_KEY, _("Last Line"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
764
765
		IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta's avatar
Chris Allegretta committed
766

Chris Allegretta's avatar
Chris Allegretta committed
767
#ifndef DISABLE_HELP
768
    free_shortcutage(&help_list);
Chris Allegretta's avatar
Chris Allegretta committed
769

770
    sc_init_one(&help_list, NANO_PREVPAGE_KEY, _("Prev Page"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
771
772
		IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
		NANO_NO_KEY, VIEW, do_page_up);
Chris Allegretta's avatar
Chris Allegretta committed
773

774
    sc_init_one(&help_list, NANO_NEXTPAGE_KEY, _("Next Page"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
775
776
		IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
		NANO_NO_KEY, VIEW, do_page_down);
Chris Allegretta's avatar
Chris Allegretta committed
777

778
    sc_init_one(&help_list, NANO_EXIT_KEY, _("Exit"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
779
780
		IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
		NANO_NO_KEY, VIEW, do_exit);
Chris Allegretta's avatar
Chris Allegretta committed
781
#endif
Chris Allegretta's avatar
Chris Allegretta committed
782

783
    free_shortcutage(&writefile_list);
Chris Allegretta's avatar
Chris Allegretta committed
784

785
    sc_init_one(&writefile_list, NANO_HELP_KEY, _("Get Help"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
786
787
		IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
		NANO_NO_KEY, VIEW, do_help);
788

789
#ifndef DISABLE_BROWSER
790
    /* Translators: try to keep this string under 16 characters long */
791
    sc_init_one(&writefile_list, NANO_TOFILES_KEY, _("To Files"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
792
793
		IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, 0);
Chris Allegretta's avatar
Chris Allegretta committed
794
#endif
Chris Allegretta's avatar
Chris Allegretta committed
795

796
#ifndef NANO_SMALL
797
    /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
798
799
800
    sc_init_one(&writefile_list, NANO_NO_KEY, _("DOS Format"),
		IFHELP(nano_dos_msg, TOGGLE_DOS_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, 0);
801

802
    /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
803
804
805
    sc_init_one(&writefile_list, NANO_NO_KEY, _("Mac Format"),
		IFHELP(nano_mac_msg, TOGGLE_MAC_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, 0);
806
807
#endif

808
    /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
809
810
811
    sc_init_one(&writefile_list, NANO_NO_KEY, _("Append"),
		IFHELP(nano_append_msg, NANO_APPEND_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, 0);
812

813
    /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
814
815
816
    sc_init_one(&writefile_list, NANO_NO_KEY, _("Prepend"),
		IFHELP(nano_prepend_msg, NANO_PREPEND_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, 0);
817

818
#ifndef NANO_SMALL
819
    /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
820
821
822
    sc_init_one(&writefile_list, NANO_NO_KEY, _("Backup File"),
		IFHELP(nano_backup_msg, TOGGLE_BACKUP_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, 0);
823
824
#endif

825
    sc_init_one(&writefile_list, NANO_CANCEL_KEY, _("Cancel"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
826
827
		IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
828

829
    free_shortcutage(&insertfile_list);
830

831
    sc_init_one(&insertfile_list, NANO_HELP_KEY, _("Get Help"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
832
833
		IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
		NANO_NO_KEY, VIEW, do_help);
834

835
    sc_init_one(&insertfile_list, NANO_CANCEL_KEY, _("Cancel"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
836
837
		IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
Chris Allegretta's avatar
Chris Allegretta committed
838

839
#ifndef DISABLE_BROWSER
840
    sc_init_one(&insertfile_list, NANO_TOFILES_KEY, _("To Files"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
841
842
		IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, 0);
843
#endif
844

845
#ifndef NANO_SMALL
846
    /* Translators: try to keep this string under 22 characters long */
847
    sc_init_one(&insertfile_list, NANO_EXTCMD_KEY, _("Execute Command"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
848
849
		IFHELP(nano_execute_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, 0);
850

851
#ifdef ENABLE_MULTIBUFFER
852
    /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
853
854
855
    sc_init_one(&insertfile_list, NANO_NO_KEY, _("New Buffer"),
		IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY), NANO_NO_KEY,
		NANO_NO_KEY, NOVIEW, 0);
856
#endif
857
#endif
858

Chris Allegretta's avatar
Chris Allegretta committed
859
#ifndef DISABLE_SPELLER
860
    free_shortcutage(&spell_list);
Chris Allegretta's avatar
Chris Allegretta committed
861

862
    sc_init_one(&spell_list, NANO_HELP_KEY, _("Get Help"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
863
864
		IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
		NANO_NO_KEY, VIEW, do_help);
865

866
    sc_init_one(&spell_list, NANO_CANCEL_KEY, _("Cancel"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
867
868
		IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
Chris Allegretta's avatar
Chris Allegretta committed
869
#endif
Chris Allegretta's avatar
Chris Allegretta committed
870

871
#ifndef NANO_SMALL
872
    free_shortcutage(&extcmd_list);
Chris Allegretta's avatar
Chris Allegretta committed
873

874
    sc_init_one(&extcmd_list, NANO_HELP_KEY, _("Get Help"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
875
876
		IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
		NANO_NO_KEY, VIEW, do_help);
877
878

    sc_init_one(&extcmd_list, NANO_CANCEL_KEY, _("Cancel"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
879
880
		IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
881
#endif
882

883
#ifndef DISABLE_BROWSER
884
    free_shortcutage(&browser_list);
885

886
    sc_init_one(&browser_list, NANO_HELP_KEY, _("Get Help"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
887
888
		IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
		NANO_NO_KEY, VIEW, do_help);
889

890
    sc_init_one(&browser_list, NANO_CANCEL_KEY, _("Cancel"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
891
892
		IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
893

894
    sc_init_one(&browser_list, NANO_PREVPAGE_KEY, _("Prev Page"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
895
896
		IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
		NANO_NO_KEY, VIEW, 0);
Chris Allegretta's avatar
Chris Allegretta committed
897

898
    sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, _("Next Page"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
899
900
		IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
		NANO_NO_KEY, VIEW, 0);
Chris Allegretta's avatar
Chris Allegretta committed
901

902
    /* Translators: try to keep this string under 22 characters long */
903
    sc_init_one(&browser_list, NANO_GOTO_KEY, _("Go To Dir"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
904
905
		IFHELP(nano_gotodir_msg, NANO_ALT_GOTO_KEY), NANO_GOTO_FKEY,
		NANO_NO_KEY, VIEW, 0);
Rocco Corsi's avatar
   
Rocco Corsi committed
906

907
    free_shortcutage(&gotodir_list);
908

909
    sc_init_one(&gotodir_list, NANO_HELP_KEY, _("Get Help"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
910
911
		IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
		NANO_NO_KEY, VIEW, do_help);
Chris Allegretta's avatar
Chris Allegretta committed
912

913
    sc_init_one(&gotodir_list, NANO_CANCEL_KEY, _("Cancel"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
914
915
		IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
		NANO_NO_KEY, VIEW, 0);
Chris Allegretta's avatar
Chris Allegretta committed
916
917
#endif

918
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
919
920
    currshortcut = main_list;
#endif
921
#ifndef NANO_SMALL
922
    toggle_init();
923
#endif
924
}
925

926
927
928
/* 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
929
 * function unless debugging is turned on. */
930
#ifdef DEBUG
931
/* added by SPK for memory cleanup, gracefully return our malloc()s */
Chris Allegretta's avatar
Chris Allegretta committed
932
void thanks_for_all_the_fish(void)
933
{
Chris Allegretta's avatar
Chris Allegretta committed
934
935
936
937
#ifndef DISABLE_JUSTIFY
    if (quotestr != NULL)
	free(quotestr);
#endif
938
939
940
941
#ifndef NANO_SMALL
    if (backup_dir != NULL)
        free(backup_dir);
#endif
Chris Allegretta's avatar
Chris Allegretta committed
942
#ifndef DISABLE_OPERATINGDIR
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
    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);
    if (hblank != NULL)
	free(hblank);
#ifndef DISABLE_SPELLER
    if (alt_speller != NULL)
	free(alt_speller);
#endif
958
#ifndef DISABLE_HELP
959
960
    if (help_text != NULL)
	free(help_text);
961
#endif
962
963
964
965
966
    if (filename != NULL)
	free(filename);
    if (answer != NULL)
	free(answer);
    if (cutbuffer != NULL)
Chris Allegretta's avatar
Chris Allegretta committed
967
	free_filestruct(cutbuffer);
968
969
970
971
972

    free_shortcutage(&main_list);
    free_shortcutage(&whereis_list);
    free_shortcutage(&replace_list);
    free_shortcutage(&replace_list_2);
Chris Allegretta's avatar
Chris Allegretta committed
973
    free_shortcutage(&goto_list);
974
975
    free_shortcutage(&writefile_list);
    free_shortcutage(&insertfile_list);
Chris Allegretta's avatar
Chris Allegretta committed
976
#ifndef DISABLE_HELP
Chris Allegretta's avatar
Chris Allegretta committed
977
    free_shortcutage(&help_list);
Chris Allegretta's avatar
Chris Allegretta committed
978
979
#endif
#ifndef DISABLE_SPELLER
980
    free_shortcutage(&spell_list);
Chris Allegretta's avatar
Chris Allegretta committed
981
#endif
Chris Allegretta's avatar
Chris Allegretta committed
982
983
984
#ifndef NANO_SMALL
    free_shortcutage(&extcmd_list);
#endif
985
986
#ifndef DISABLE_BROWSER
    free_shortcutage(&browser_list);
Chris Allegretta's avatar
Chris Allegretta committed
987
    free_shortcutage(&gotodir_list);
988
989
990
991
992
993
994
#endif

#ifndef NANO_SMALL
    free_toggles();
#endif

#ifdef ENABLE_MULTIBUFFER
995
    if (open_files != NULL) {
996
	/* We free the memory associated with each open file. */
997
998
	while (open_files->prev != NULL)
	    open_files = open_files->prev;
Chris Allegretta's avatar
Chris Allegretta committed
999
	free_openfilestruct(open_files);
1000
    }
1001
#else
1002
    free_filestruct(fileage);
1003
#endif
Chris Allegretta's avatar
Chris Allegretta committed
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014

#ifdef ENABLE_COLOR
    free(syntaxstr);
    while (syntaxes != NULL) {
	syntaxtype *bill = syntaxes;

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

	    syntaxes->extensions = bob->next;
Chris Allegretta's avatar
Chris Allegretta committed
1015
	    regfree(&bob->val);
Chris Allegretta's avatar
Chris Allegretta committed
1016
1017
1018
1019
1020
1021
	    free(bob);
	}
	while (syntaxes->color != NULL) {
	    colortype *bob = syntaxes->color;

	    syntaxes->color = bob->next;
Chris Allegretta's avatar
Chris Allegretta committed
1022
1023
	    regfree(&bob->start);
	    if (bob->end != NULL)
1024
1025
		regfree(bob->end);
	    free(bob->end);
Chris Allegretta's avatar
Chris Allegretta committed
1026
1027
1028
1029
1030
1031
	    free(bob);
	}
	syntaxes = syntaxes->next;
	free(bill);
    }
#endif /* ENABLE_COLOR */
1032
1033
1034
1035
1036
#ifndef NANO_SMALL
    /* free history lists */
    free_history(&search_history);
    free_history(&replace_history);
#endif
1037
}
1038
#endif /* DEBUG */