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
65
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 *editbot = NULL;	/* Same for the bottom */
filestruct *filebot = NULL;	/* Last node in the file struct */
filestruct *cutbuffer = NULL;	/* A place to store cut text */

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

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

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

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

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

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

/* More stuff for the marker select */

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

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

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

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

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

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

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

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

152
153
/* Regular expressions */

154
#ifdef HAVE_REGEX_H
155
156
157
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
158
#endif
159

160
161
162
163
164
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
165
int length_of_list(const shortcut *s)
166
167
{
    int i = 0;
168

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

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

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

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

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

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

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

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

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

253
    toggle_const_msg = _("Constant cursor position");
254
    toggle_autoindent_msg = _("Auto indent");
255
    toggle_suspend_msg = _("Suspend");
256
    toggle_nohelp_msg = _("Help mode");
257
#ifndef DISABLE_MOUSE
258
    toggle_mouse_msg = _("Mouse support");
259
#endif
260
    toggle_cuttoend_msg = _("Cut to end");
261
262
263
    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");
264
    toggle_backup_msg = _("Backing up file");
265
    toggle_smooth_msg = _("Smooth scrolling");
266
267
268
#ifdef ENABLE_COLOR
    toggle_syntax_msg = _("Color syntax highlighting");
#endif
Chris Allegretta's avatar
Chris Allegretta committed
269
#ifndef DISABLE_WRAPPING
270
    toggle_wrap_msg = _("Auto line wrap");
Chris Allegretta's avatar
Chris Allegretta committed
271
#endif
272
#ifdef ENABLE_MULTIBUFFER
273
    toggle_multibuffer_msg = _("Multiple file buffers");
274
275
#endif

276
277
278
279
    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
280
281
    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
282
#ifndef DISABLE_WRAPPING
283
    toggle_init_one(TOGGLE_WRAP_KEY, toggle_wrap_msg, NO_WRAP);
Chris Allegretta's avatar
Chris Allegretta committed
284
#endif
285
286
    toggle_init_one(TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, CUT_TO_END);
    toggle_init_one(TOGGLE_SUSPEND_KEY, toggle_suspend_msg, SUSPEND);
287
#ifndef DISABLE_MOUSE
288
    toggle_init_one(TOGGLE_MOUSE_KEY, toggle_mouse_msg, USE_MOUSE);
289
#endif
290
291
292
    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);
293
    toggle_init_one(TOGGLE_BACKUP_KEY, toggle_backup_msg, BACKUP_FILE);
294
    toggle_init_one(TOGGLE_SMOOTH_KEY, toggle_smooth_msg, SMOOTHSCROLL);
295
296
297
#ifdef ENABLE_COLOR
    toggle_init_one(TOGGLE_SYNTAX_KEY, toggle_syntax_msg, COLOR_SYNTAX);
#endif
298
}
299
300
301
302
303
304
305
306
307
308
309
310
311

#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
312
#endif /* !NANO_SMALL */
313
314

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

325
void shortcut_init(int unjustify)
Chris Allegretta's avatar
Chris Allegretta committed
326
{
327
#ifndef DISABLE_HELP
328
329
330
331
332
333
334
    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 =
335
336
	"", *nano_spell_msg = "", *nano_prevline_msg =
	"", *nano_nextline_msg = "", *nano_forward_msg =
337
	"", *nano_back_msg = "", *nano_home_msg =
Chris Allegretta's avatar
Chris Allegretta committed
338
339
340
341
	"", *nano_end_msg = "", *nano_firstline_msg =
	"", *nano_lastline_msg = "", *nano_refresh_msg =
	"", *nano_mark_msg = "", *nano_delete_msg =
	"", *nano_backspace_msg = "", *nano_tab_msg =
342
343
344
345
346
347
348
349
350
351
	"", *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
352

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

Chris Allegretta's avatar
Chris Allegretta committed
361
362
    nano_help_msg = _("Invoke the help menu");
    nano_writeout_msg = _("Write the current file to disk");
363
#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
364
    nano_exit_msg = _("Close current file buffer/Exit from nano");
365
#else
Chris Allegretta's avatar
Chris Allegretta committed
366
    nano_exit_msg = _("Exit from nano");
367
#endif
368
    nano_goto_msg = _("Go to a specific line number");
Chris Allegretta's avatar
Chris Allegretta committed
369
    nano_justify_msg = _("Justify the current paragraph");
370
    nano_unjustify_msg = _("Unjustify after a justify");
Chris Allegretta's avatar
Chris Allegretta committed
371
372
373
    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");
374
    nano_whereis_next_msg = _("Repeat last search");
Chris Allegretta's avatar
Chris Allegretta committed
375
376
377
378
    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");
379
    nano_cursorpos_msg = _("Show the position of the cursor");
380
    nano_spell_msg = _("Invoke the spell checker, if available");
381
382
    nano_prevline_msg = _("Move to the previous line");
    nano_nextline_msg = _("Move to the next line");
Chris Allegretta's avatar
Chris Allegretta committed
383
384
385
386
387
388
389
390
391
392
393
394
395
    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");
396
397
398
399
    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
400
401
    nano_case_msg =
	_("Make the current search or replace case (in)sensitive");
Chris Allegretta's avatar
Chris Allegretta committed
402
    nano_tofiles_msg = _("Go to file browser");
403
    nano_execute_msg = _("Execute external command");
404
    nano_gotodir_msg = _("Go to directory");
Chris Allegretta's avatar
Chris Allegretta committed
405
    nano_cancel_msg = _("Cancel the current function");
406
    nano_append_msg = _("Append to the current file");
407
    nano_prepend_msg = _("Prepend to the current file");
408
    nano_reverse_msg = _("Search backwards");
409
410
    nano_dos_msg = _("Write file out in DOS format");
    nano_mac_msg = _("Write file out in Mac format");
411
    nano_backup_msg = _("Back up original file when saving");
412
    nano_editstr_msg = _("Edit the previous search/replace strings");
413
414
    nano_parabegin_msg = _("Go to the beginning of the current paragraph");
    nano_paraend_msg = _("Go to the end of the current paragraph");
415
#ifdef HAVE_REGEX_H
416
    nano_regexp_msg = _("Use regular expressions");
417
    nano_bracket_msg = _("Find other bracket");
418
#endif
419
#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
420
421
    nano_openprev_msg = _("Switch to previous file buffer");
    nano_opennext_msg = _("Switch to next file buffer");
422
    nano_multibuffer_msg = _("Toggle insert into new file buffer");
Chris Allegretta's avatar
Chris Allegretta committed
423
#endif
424
#endif /* !DISABLE_HELP */
Chris Allegretta's avatar
Chris Allegretta committed
425

426
    free_shortcutage(&main_list);
427

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

437
    /* Translators: try to keep this string under 10 characters long */
438
    sc_init_one(&main_list, NANO_HELP_KEY, _("Get Help"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
439
440
		IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
		NANO_NO_KEY, VIEW, do_help);
Chris Allegretta's avatar
Chris Allegretta committed
441

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

451
    /* Translators: try to keep this string under 10 characters long */
452
	sc_init_one(&main_list, NANO_EXIT_KEY, _("Exit"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
453
454
		IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
		NANO_NO_KEY, VIEW, do_exit);
Chris Allegretta's avatar
Chris Allegretta committed
455

456
    /* Translators: try to keep this string under 10 characters long */
457
    sc_init_one(&main_list, NANO_WRITEOUT_KEY, _("WriteOut"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
458
459
		IFHELP(nano_writeout_msg, NANO_NO_KEY), NANO_WRITEOUT_FKEY,
		NANO_NO_KEY, NOVIEW, do_writeout_void);
Chris Allegretta's avatar
Chris Allegretta committed
460

461
    /* Translators: try to keep this string under 10 characters long */
462
    sc_init_one(&main_list, NANO_JUSTIFY_KEY, _("Justify"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
463
464
		IFHELP(nano_justify_msg, NANO_NO_KEY),
		NANO_JUSTIFY_FKEY, NANO_NO_KEY, NOVIEW, do_justify);
465

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

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

483
    /* Translators: try to keep this string under 10 characters long */
484
    sc_init_one(&main_list, NANO_PREVPAGE_KEY, _("Prev Page"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
485
486
		IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
		NANO_NO_KEY, VIEW, do_page_up);
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_NEXTPAGE_KEY, _("Next Page"),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
490
491
		IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
		NANO_NO_KEY, VIEW, do_page_down);
Chris Allegretta's avatar
Chris Allegretta committed
492

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

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

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

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

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

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

527
528
    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
529
		NANO_NO_KEY, VIEW, do_up);
Chris Allegretta's avatar
Chris Allegretta committed
530

531
532
    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
533
		NANO_NO_KEY, VIEW, do_down);
Chris Allegretta's avatar
Chris Allegretta committed
534

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

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

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

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

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

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

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

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

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

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

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

David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
580
581
582
    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);
583
#endif
584

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

589
#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
590
591
592
    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);
593

David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
594
595
596
    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);
597
#endif
598

599
#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
600
601
602
    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);
603
604
#endif

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

609
    free_shortcutage(&whereis_list);
610

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

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

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

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

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

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

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

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

652
#ifndef NANO_SMALL
653
    /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
654
655
656
    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);
657

658
    /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
659
660
661
    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
662

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

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

677
#endif /* !NANO_SMALL */
678

679
    free_shortcutage(&replace_list);
680

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

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

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

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

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

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

706
#ifndef NANO_SMALL
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
707
708
709
    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);
710

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

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

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

726
    free_shortcutage(&replace_list_2);
727

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

797
#ifndef NANO_SMALL
798
    /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
799
800
801
    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);
802

803
    /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
804
805
806
    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);
807
808
#endif

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

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

819
#ifndef NANO_SMALL
820
    /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
821
822
823
    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);
824
825
#endif

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

830
    free_shortcutage(&insertfile_list);
831

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

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

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

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

852
#ifdef ENABLE_MULTIBUFFER
853
    /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
854
855
856
    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);
857
#endif
858
#endif
859

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

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

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

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

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

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

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

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

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

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

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

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

908
    free_shortcutage(&gotodir_list);
909

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

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

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

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

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

#ifndef NANO_SMALL
    free_toggles();
#endif

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

#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
1016
	    regfree(&bob->val);
Chris Allegretta's avatar
Chris Allegretta committed
1017
1018
1019
1020
1021
1022
	    free(bob);
	}
	while (syntaxes->color != NULL) {
	    colortype *bob = syntaxes->color;

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