blob: 501af2e58466834ee944ffafe333cde17782337e [file] [log] [blame]
Chris Allegretta11b00112000-08-06 21:13:45 +00001/* $Id$ */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00002/**************************************************************************
3 * global.c *
4 * *
Jordi Mallach8ae57892002-01-04 17:57:40 +00005 * Copyright (C) 1999-2002 Chris Allegretta *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00006 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
Chris Allegretta3a24f3f2001-10-24 11:33:54 +00008 * the Free Software Foundation; either version 2, or (at your option) *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00009 * any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
19 * *
20 **************************************************************************/
21
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000022#include "config.h"
Chris Allegretta6efda542001-04-28 18:03:52 +000023
Chris Allegrettadab017e2002-04-23 10:56:06 +000024#include <assert.h>
Chris Allegretta6efda542001-04-28 18:03:52 +000025#include <sys/stat.h>
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000026#include "nano.h"
27#include "proto.h"
28
29#ifndef NANO_SMALL
30#include <libintl.h>
31#define _(string) gettext(string)
32#else
33#define _(string) (string)
34#endif
35
36/*
37 * Global variables
38 */
Chris Allegretta48b06702002-02-22 04:30:50 +000039
Chris Allegretta88520c92001-05-05 17:45:54 +000040int flags = 0; /* Our new flag containing many options */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000041WINDOW *edit; /* The file portion of the editor */
42WINDOW *topwin; /* Top line of screen */
43WINDOW *bottomwin; /* Bottom buffer */
Chris Allegretta1a6e9042000-12-14 13:56:28 +000044char *filename = NULL; /* Name of the file */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000045int editwinrows = 0; /* How many rows long is the edit
46 window? */
47filestruct *current; /* Current buffer pointer */
48int current_x = 0, current_y = 0; /* Current position of X and Y in
49 the editor - relative to edit
50 window (0,0) */
51filestruct *fileage = NULL; /* Our file buffer */
52filestruct *edittop = NULL; /* Pointer to the top of the edit
53 buffer with respect to the
54 file struct */
55filestruct *editbot = NULL; /* Same for the bottom */
56filestruct *filebot = NULL; /* Last node in the file struct */
57filestruct *cutbuffer = NULL; /* A place to store cut text */
58
Chris Allegretta355fbe52001-07-14 19:32:47 +000059#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaf2387fb2002-04-10 02:31:20 +000060openfilestruct *open_files = NULL; /* The list of open files */
Chris Allegretta2d7893d2001-07-11 02:08:33 +000061#endif
62
Chris Allegrettae4f940d2002-03-03 22:36:36 +000063#ifndef DISABLE_JUSTIFY
64char *quotestr = "> "; /* Quote string */
65#endif
66
Chris Allegretta31925e42000-11-02 04:40:39 +000067char *answer = NULL; /* Answer str to many questions */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000068int totlines = 0; /* Total number of lines in the file */
Chris Allegrettab3655b42001-10-22 03:15:31 +000069long totsize = 0; /* Total number of bytes in the file */
Chris Allegretta88520c92001-05-05 17:45:54 +000070int placewewant = 0; /* The column we'd like the cursor
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000071 to jump to when we go to the
72 next or previous line */
73
Chris Allegretta6d690a32000-08-03 22:51:21 +000074int tabsize = 8; /* Our internal tabsize variable */
75
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000076char *hblank; /* A horizontal blank line */
77char *help_text; /* The text in the help window */
78
79/* More stuff for the marker select */
80
81filestruct *mark_beginbuf; /* the begin marker buffer */
82int mark_beginx; /* X value in the string to start */
83
Chris Allegrettae1f14522001-09-19 03:19:43 +000084#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +000085char *operating_dir = NULL; /* Operating directory, which we can't */
86char *full_operating_dir = NULL;/* go higher than */
Chris Allegrettae1f14522001-09-19 03:19:43 +000087#endif
88
Chris Allegretta8d8e0122001-04-18 04:28:54 +000089#ifndef DISABLE_SPELLER
90char *alt_speller; /* Alternative spell command */
91#endif
92
Chris Allegrettaa8c22572002-02-15 19:17:02 +000093shortcut *main_list = NULL;
94shortcut *whereis_list = NULL;
95shortcut *replace_list = NULL;
Chris Allegretta48b06702002-02-22 04:30:50 +000096shortcut *replace_list_2 = NULL; /* 2nd half of replace dialog */
Chris Allegrettaa8c22572002-02-15 19:17:02 +000097shortcut *goto_list = NULL;
98shortcut *gotodir_list = NULL;
99shortcut *writefile_list = NULL;
100shortcut *insertfile_list = NULL;
101shortcut *help_list = NULL;
102shortcut *spell_list = NULL;
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000103#ifndef NANO_SMALL
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000104shortcut *extcmd_list = NULL;
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000105#endif
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000106#ifndef DISABLE_BROWSER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000107shortcut *browser_list = NULL;
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000108#endif
109
Chris Allegretta8ce24132001-04-30 11:28:46 +0000110#ifdef ENABLE_COLOR
111 colorstruct colors[NUM_NCOLORS];
Chris Allegretta08893e02001-11-29 02:42:27 +0000112 colortype *colorstrings = NULL;
Chris Allegrettab6c5dc22002-05-04 03:47:33 +0000113 syntaxtype *syntaxes = NULL;
Chris Allegretta8ce24132001-04-30 11:28:46 +0000114#endif
115
Chris Allegretta8c8d3702001-10-28 05:00:39 +0000116#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined (DISABLE_HELP)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000117shortcut *currshortcut; /* Current shortcut list we're using */
Chris Allegretta6fe61492001-05-21 12:56:25 +0000118#endif
Chris Allegretta6b58acd2001-04-12 03:01:53 +0000119
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000120#ifndef NANO_SMALL
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000121toggle *toggles = NULL;
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000122#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000123
Chris Allegretta9fc8d432000-07-07 01:49:52 +0000124/* Regular expressions */
125
Chris Allegretta805c26d2000-09-06 13:39:17 +0000126#ifdef HAVE_REGEX_H
Chris Allegrettabd9e7c32000-10-26 01:44:42 +0000127regex_t search_regexp; /* Global to store compiled search regexp */
128regmatch_t regmatches[10]; /* Match positions for parenthetical
129 subexpressions, max of 10 */
Chris Allegretta3533a342002-03-24 23:19:32 +0000130#ifdef ENABLE_COLOR
131regex_t color_regexp; /* Global to store compiled search regexp */
Chris Allegretta373bc2f2002-03-24 23:20:32 +0000132regmatch_t colormatches[1]; /* Match positions for parenthetical */
Chris Allegrettab6c5dc22002-05-04 03:47:33 +0000133
134regex_t syntaxfile_regexp; /* Global to store compiled search regexp */
135regmatch_t synfilematches[1]; /* Match positions for parenthetical */
Chris Allegretta3533a342002-03-24 23:19:32 +0000136#endif /* ENABLE_COLOR */
137
Chris Allegretta805c26d2000-09-06 13:39:17 +0000138#endif
Chris Allegretta9fc8d432000-07-07 01:49:52 +0000139
Chris Allegrettadab017e2002-04-23 10:56:06 +0000140int length_of_list(const shortcut *s)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000141{
142 int i = 0;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000143
Chris Allegrettadab017e2002-04-23 10:56:06 +0000144 for (; s != NULL; s = s->next)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000145 i++;
146
147 return i;
148}
149
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000150/* Initialize a struct *without* our lovely braces =( */
Chris Allegrettadab017e2002-04-23 10:56:06 +0000151static void sc_init_one(shortcut **shortcutage, int key,
152 const char *desc,
153#ifndef DISABLE_HELP
154 const char *help,
155#endif /* !DISABLE_HELP */
156 int alt, int misc1, int misc2, int view,
157 int (*func) (void))
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000158{
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000159 shortcut *s;
160
161 if (*shortcutage == NULL) {
162 *shortcutage = nmalloc(sizeof(shortcut));
163 s = *shortcutage;
164 } else {
165 for (s = *shortcutage; s->next != NULL; s = s->next)
166 ;
167 s->next = nmalloc(sizeof(shortcut));
168 s = s->next;
169 }
170
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000171 s->val = key;
172 s->desc = desc;
Chris Allegrettadab017e2002-04-23 10:56:06 +0000173#ifndef DISABLE_HELP
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000174 s->help = help;
Chris Allegrettadab017e2002-04-23 10:56:06 +0000175#endif /* !DISABLE_HELP */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000176 s->altval = alt;
177 s->misc1 = misc1;
178 s->misc2 = misc2;
179 s->viewok = view;
180 s->func = func;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000181 s->next = NULL;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000182}
183
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000184#ifndef NANO_SMALL
Chris Allegrettadab017e2002-04-23 10:56:06 +0000185/* Create one new toggle structure, at the end of the toggles
186 * linked list. */
187static void toggle_init_one(int val, const char *desc, int flag)
Chris Allegretta756f2202000-09-01 13:32:47 +0000188{
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000189 toggle *u;
190
191 if (toggles == NULL) {
192 toggles = nmalloc(sizeof(toggle));
193 u = toggles;
194 } else {
195 for (u = toggles; u->next != NULL; u = u->next)
196 ;
197 u->next = nmalloc(sizeof(toggle));
198 u = u->next;
199 }
200
201 u->val = val;
202 u->desc = desc;
203 u->flag = flag;
204 u->next = NULL;
Chris Allegretta756f2202000-09-01 13:32:47 +0000205}
206
Chris Allegrettadab017e2002-04-23 10:56:06 +0000207/* Deallocate all of the toggles */
208static void free_toggles(void)
Chris Allegretta756f2202000-09-01 13:32:47 +0000209{
Chris Allegrettadab017e2002-04-23 10:56:06 +0000210 toggle *pt; /* Think "previous toggle" */
211
212 while (toggles != NULL) {
213 pt = toggles;
214 toggles = toggles->next;
215 free(pt);
216 }
217 toggles = NULL;
218}
219
220static void toggle_init(void)
221{
Chris Allegretta756f2202000-09-01 13:32:47 +0000222 char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg,
223 *toggle_nohelp_msg, *toggle_picomode_msg, *toggle_mouse_msg,
Chris Allegretta658399a2001-06-14 02:54:22 +0000224 *toggle_cuttoend_msg, *toggle_wrap_msg, *toggle_case_msg,
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000225 *toggle_backwards_msg, *toggle_noconvert_msg, *toggle_dos_msg,
226 *toggle_mac_msg, *toggle_smooth_msg;
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000227
Chris Allegrettad7934d42000-10-03 05:39:29 +0000228#ifdef HAVE_REGEX_H
Chris Allegrettabd9e7c32000-10-26 01:44:42 +0000229 char *toggle_regexp_msg;
Chris Allegrettad7934d42000-10-03 05:39:29 +0000230#endif
Chris Allegretta756f2202000-09-01 13:32:47 +0000231
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000232#ifdef ENABLE_MULTIBUFFER
233 char *toggle_load_msg;
234#endif
Chris Allegretta3e3ae942001-09-22 19:02:04 +0000235
Chris Allegretta756f2202000-09-01 13:32:47 +0000236 toggle_const_msg = _("Constant cursor position");
Chris Allegrettaf8163dc2000-09-03 01:06:40 +0000237 toggle_autoindent_msg = _("Auto indent");
Chris Allegretta756f2202000-09-01 13:32:47 +0000238 toggle_suspend_msg = _("Suspend");
Chris Allegrettaf0f63a82000-09-02 18:44:21 +0000239 toggle_nohelp_msg = _("Help mode");
Chris Allegrettabf9a8cc2000-11-17 01:37:39 +0000240 toggle_picomode_msg = _("Pico mode");
Chris Allegretta756f2202000-09-01 13:32:47 +0000241 toggle_mouse_msg = _("Mouse support");
242 toggle_cuttoend_msg = _("Cut to end");
Chris Allegretta8d990b52001-09-22 22:14:25 +0000243 toggle_backwards_msg = _("Backwards search");
244 toggle_case_msg = _("Case sensitive search");
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000245
246#ifdef HAVE_REGEX_H
247 toggle_regexp_msg = _("Regular expression search");
248#endif
249
250 toggle_noconvert_msg = _("No conversion from DOS/Mac format");
Chris Allegretta7004c282001-09-22 00:42:10 +0000251 toggle_dos_msg = _("Writing file in DOS format");
Chris Allegretta995177f2001-09-22 04:34:23 +0000252 toggle_mac_msg = _("Writing file in Mac format");
Chris Allegretta3e3ae942001-09-22 19:02:04 +0000253 toggle_smooth_msg = _("Smooth scrolling");
Chris Allegrettaf0f63a82000-09-02 18:44:21 +0000254 toggle_wrap_msg = _("Auto wrap");
Chris Allegretta756f2202000-09-01 13:32:47 +0000255
Chris Allegretta355fbe52001-07-14 19:32:47 +0000256#ifdef ENABLE_MULTIBUFFER
257 toggle_load_msg = _("Multiple file buffers");
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000258#endif
259
Chris Allegrettadab017e2002-04-23 10:56:06 +0000260 free_toggles();
261
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000262 toggle_init_one(TOGGLE_CONST_KEY, toggle_const_msg, CONSTUPDATE);
263 toggle_init_one(TOGGLE_AUTOINDENT_KEY, toggle_autoindent_msg, AUTOINDENT);
264 toggle_init_one(TOGGLE_SUSPEND_KEY, toggle_suspend_msg, SUSPEND);
265 toggle_init_one(TOGGLE_NOHELP_KEY, toggle_nohelp_msg, NO_HELP);
266 toggle_init_one(TOGGLE_PICOMODE_KEY, toggle_picomode_msg, PICO_MODE);
267 toggle_init_one(TOGGLE_WRAP_KEY, toggle_wrap_msg, NO_WRAP);
268 toggle_init_one(TOGGLE_MOUSE_KEY, toggle_mouse_msg, USE_MOUSE);
269 toggle_init_one(TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, CUT_TO_END);
270 toggle_init_one(TOGGLE_BACKWARDS_KEY, toggle_backwards_msg, REVERSE_SEARCH);
271 toggle_init_one(TOGGLE_CASE_KEY, toggle_case_msg, CASE_SENSITIVE);
Chris Allegretta805c26d2000-09-06 13:39:17 +0000272#ifdef HAVE_REGEX_H
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000273 toggle_init_one(TOGGLE_REGEXP_KEY, toggle_regexp_msg, USE_REGEXP);
Chris Allegretta756f2202000-09-01 13:32:47 +0000274#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000275#ifdef ENABLE_MULTIBUFFER
276 toggle_init_one(TOGGLE_LOAD_KEY, toggle_load_msg, MULTIBUFFER);
Chris Allegretta805c26d2000-09-06 13:39:17 +0000277#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000278 toggle_init_one(TOGGLE_NOCONVERT_KEY, toggle_noconvert_msg, NO_CONVERT);
279 toggle_init_one(TOGGLE_DOS_KEY, toggle_dos_msg, DOS_FILE);
280 toggle_init_one(TOGGLE_MAC_KEY, toggle_mac_msg, MAC_FILE);
281 toggle_init_one(TOGGLE_SMOOTH_KEY, toggle_smooth_msg, SMOOTHSCROLL);
Chris Allegrettadab017e2002-04-23 10:56:06 +0000282}
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000283#endif /* !NANO_SMALL */
Chris Allegrettadab017e2002-04-23 10:56:06 +0000284
285
286/* Deallocate the given shortcut. */
287static void free_shortcutage(shortcut **shortcutage)
288{
289 shortcut *s, *ps;
290
291 assert(shortcutage != NULL);
292 s = *shortcutage;
293 while (s != NULL) {
294 ps = s;
295 s = s->next;
296 free(ps);
297 }
298 *shortcutage = NULL;
Chris Allegretta756f2202000-09-01 13:32:47 +0000299}
300
Chris Allegretta07798352000-11-27 22:58:23 +0000301void shortcut_init(int unjustify)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000302{
Chris Allegrettadab017e2002-04-23 10:56:06 +0000303#ifndef DISABLE_HELP
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000304 char *nano_help_msg = "", *nano_writeout_msg = "", *nano_exit_msg = "",
305 *nano_goto_msg = "", *nano_justify_msg = "", *nano_replace_msg =
306 "", *nano_insert_msg = "", *nano_whereis_msg =
307 "", *nano_prevpage_msg = "", *nano_nextpage_msg =
308 "", *nano_cut_msg = "", *nano_uncut_msg = "", *nano_cursorpos_msg =
309 "", *nano_spell_msg = "", *nano_up_msg = "", *nano_down_msg =
310 "", *nano_forward_msg = "", *nano_back_msg = "", *nano_home_msg =
311 "", *nano_end_msg = "", *nano_firstline_msg =
312 "", *nano_lastline_msg = "", *nano_refresh_msg =
313 "", *nano_mark_msg = "", *nano_delete_msg =
314 "", *nano_backspace_msg = "", *nano_tab_msg =
Chris Allegretta5f36c372001-07-16 00:48:53 +0000315 "", *nano_enter_msg = "", *nano_cancel_msg =
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000316 "", *nano_unjustify_msg = "", *nano_append_msg =
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000317 "", *nano_prepend_msg = "";
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000318
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000319#ifdef ENABLE_MULTIBUFFER
320 char *nano_openprev_msg = "", *nano_opennext_msg = "";
321#endif
322
Chris Allegretta5f36c372001-07-16 00:48:53 +0000323 char *nano_tofiles_msg = "", *nano_gotodir_msg = "", *nano_case_msg =
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000324 "", *nano_reverse_msg = "", *nano_execute_msg = "";
Chris Allegretta6235a7d2002-02-27 04:38:32 +0000325 char *nano_dos_msg = "", *nano_mac_msg = "";
326
Chris Allegretta2bef1822001-09-28 19:53:11 +0000327#ifdef HAVE_REGEX_H
328 char *nano_regexp_msg = "", *nano_bracket_msg = "";
329#endif
Chris Allegretta6636dc32001-01-05 05:41:07 +0000330
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000331 nano_help_msg = _("Invoke the help menu");
332 nano_writeout_msg = _("Write the current file to disk");
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000333
Chris Allegretta355fbe52001-07-14 19:32:47 +0000334#ifdef ENABLE_MULTIBUFFER
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000335 nano_exit_msg = _("Close currently loaded file/Exit from nano");
336#else
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000337 nano_exit_msg = _("Exit from nano");
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000338#endif
339
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000340 nano_goto_msg = _("Goto a specific line number");
341 nano_justify_msg = _("Justify the current paragraph");
Chris Allegretta07798352000-11-27 22:58:23 +0000342 nano_unjustify_msg = _("Unjustify after a justify");
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000343 nano_replace_msg = _("Replace text within the editor");
344 nano_insert_msg = _("Insert another file into the current one");
345 nano_whereis_msg = _("Search for text within the editor");
346 nano_prevpage_msg = _("Move to the previous screen");
347 nano_nextpage_msg = _("Move to the next screen");
348 nano_cut_msg = _("Cut the current line and store it in the cutbuffer");
349 nano_uncut_msg = _("Uncut from the cutbuffer into the current line");
Chris Allegretta88520c92001-05-05 17:45:54 +0000350 nano_cursorpos_msg = _("Show the position of the cursor");
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000351 nano_spell_msg = _("Invoke the spell checker (if available)");
352 nano_up_msg = _("Move up one line");
353 nano_down_msg = _("Move down one line");
354 nano_forward_msg = _("Move forward one character");
355 nano_back_msg = _("Move back one character");
356 nano_home_msg = _("Move to the beginning of the current line");
357 nano_end_msg = _("Move to the end of the current line");
358 nano_firstline_msg = _("Go to the first line of the file");
359 nano_lastline_msg = _("Go to the last line of the file");
360 nano_refresh_msg = _("Refresh (redraw) the current screen");
361 nano_mark_msg = _("Mark text at the current cursor location");
362 nano_delete_msg = _("Delete the character under the cursor");
363 nano_backspace_msg =
364 _("Delete the character to the left of the cursor");
365 nano_tab_msg = _("Insert a tab character");
366 nano_enter_msg = _("Insert a carriage return at the cursor position");
367 nano_case_msg =
368 _("Make the current search or replace case (in)sensitive");
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000369 nano_tofiles_msg = _("Go to file browser");
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000370 nano_execute_msg = _("Execute external command");
Rocco Corsi12f294c2001-04-14 06:50:24 +0000371 nano_gotodir_msg = _("Goto Directory");
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000372 nano_cancel_msg = _("Cancel the current function");
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000373 nano_append_msg = _("Append to the current file");
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000374 nano_prepend_msg = _("Prepend to the current file");
Chris Allegretta8d990b52001-09-22 22:14:25 +0000375 nano_reverse_msg = _("Search backwards");
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000376 nano_dos_msg = _("Write file out in DOS format");
377 nano_mac_msg = _("Write file out in Mac format");
Chris Allegretta2bef1822001-09-28 19:53:11 +0000378#ifdef HAVE_REGEX_H
Chris Allegretta8d990b52001-09-22 22:14:25 +0000379 nano_regexp_msg = _("Use Regular expressions");
380 nano_bracket_msg = _("Find other bracket");
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000381#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000382#ifdef ENABLE_MULTIBUFFER
383 nano_openprev_msg = _("Open previously loaded file");
384 nano_opennext_msg = _("Open next loaded file");
Chris Allegretta2bef1822001-09-28 19:53:11 +0000385#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000386#endif /* !DISABLE_HELP */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000387
Chris Allegrettadab017e2002-04-23 10:56:06 +0000388 free_shortcutage(&main_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000389
Chris Allegrettadab017e2002-04-23 10:56:06 +0000390/* The following macro is to be used in calling sc_init_one. The point is
391 * that sc_init_one takes 9 arguments, unless DISABLE_HELP is defined,
392 * when the fourth one should not be there. */
393#ifdef DISABLE_HELP
394# define IFHELP(help, nextvar) nextvar
395#else
396# define IFHELP(help, nextvar) help, nextvar
397#endif
398
399 sc_init_one(&main_list, NANO_HELP_KEY, _("Get Help"),
400 IFHELP(nano_help_msg,) 0, NANO_HELP_FKEY, 0, VIEW,
401 do_help);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000402
Chris Allegretta355fbe52001-07-14 19:32:47 +0000403#ifdef ENABLE_MULTIBUFFER
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000404 if (open_files != NULL && (open_files->prev || open_files->next))
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000405 sc_init_one(&main_list, NANO_EXIT_KEY, _("Close"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000406 IFHELP(nano_exit_msg,) 0, NANO_EXIT_FKEY, 0, VIEW,
407 do_exit);
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000408 else
409#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000410 sc_init_one(&main_list, NANO_EXIT_KEY, _("Exit"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000411 IFHELP(nano_exit_msg,) 0, NANO_EXIT_FKEY, 0, VIEW,
412 do_exit);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000413
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000414 sc_init_one(&main_list, NANO_WRITEOUT_KEY, _("WriteOut"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000415 IFHELP(nano_writeout_msg,)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000416 0, NANO_WRITEOUT_FKEY, 0, NOVIEW, do_writeout_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000417
Chris Allegrettabf9a8cc2000-11-17 01:37:39 +0000418 if (ISSET(PICO_MODE))
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000419 sc_init_one(&main_list, NANO_JUSTIFY_KEY, _("Justify"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000420 IFHELP(nano_justify_msg,) 0, NANO_JUSTIFY_FKEY, 0,
Chris Allegretta16e41682000-09-11 22:33:54 +0000421 NOVIEW, do_justify);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000422 else
Chris Allegretta32da4562002-01-02 15:12:21 +0000423
424#ifdef ENABLE_MULTIBUFFER
425 /* this is so we can view multiple files */
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000426 sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000427 IFHELP(nano_insert_msg,)
Chris Allegretta32da4562002-01-02 15:12:21 +0000428 0, NANO_INSERTFILE_FKEY, 0, VIEW, do_insertfile_void);
429#else
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000430 sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000431 IFHELP(nano_insert_msg,)
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000432 0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
Chris Allegretta32da4562002-01-02 15:12:21 +0000433#endif
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000434
435 if (ISSET(PICO_MODE))
Chris Allegretta32da4562002-01-02 15:12:21 +0000436
437#ifdef ENABLE_MULTIBUFFER
438 /* this is so we can view multiple files */
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000439 sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000440 IFHELP(nano_insert_msg,)
Chris Allegretta32da4562002-01-02 15:12:21 +0000441 0, NANO_INSERTFILE_FKEY, 0, VIEW, do_insertfile_void);
442#else
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000443 sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000444 IFHELP(nano_insert_msg,)
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000445 0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
Chris Allegretta32da4562002-01-02 15:12:21 +0000446#endif
447
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000448 else
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000449 sc_init_one(&main_list, NANO_REPLACE_KEY, _("Replace"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000450 IFHELP(nano_replace_msg,)
Chris Allegrettaf7dee922002-01-07 16:43:25 +0000451 NANO_ALT_REPLACE_KEY, NANO_REPLACE_FKEY, 0, NOVIEW, do_replace);
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000452
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000453 sc_init_one(&main_list, NANO_WHEREIS_KEY, _("Where Is"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000454 IFHELP(nano_whereis_msg,)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000455 0, NANO_WHEREIS_FKEY, 0, VIEW, do_search);
456
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000457 sc_init_one(&main_list, NANO_PREVPAGE_KEY, _("Prev Page"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000458 IFHELP(nano_prevpage_msg,)
Chris Allegretta3e3ae942001-09-22 19:02:04 +0000459 0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, do_page_up);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000460
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000461 sc_init_one(&main_list, NANO_NEXTPAGE_KEY, _("Next Page"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000462 IFHELP(nano_nextpage_msg,)
Chris Allegretta3e3ae942001-09-22 19:02:04 +0000463 0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, do_page_down);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000464
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000465 sc_init_one(&main_list, NANO_CUT_KEY, _("Cut Text"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000466 IFHELP(nano_cut_msg,)
467 0, NANO_CUT_FKEY, 0, NOVIEW, do_cut_text);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000468
Chris Allegretta07798352000-11-27 22:58:23 +0000469 if (unjustify)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000470 sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, _("UnJustify"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000471 IFHELP(nano_unjustify_msg,)
472 0, 0, 0, NOVIEW, do_uncut_text);
Chris Allegretta07798352000-11-27 22:58:23 +0000473 else
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000474 sc_init_one(&main_list, NANO_UNCUT_KEY, _("UnCut Txt"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000475 IFHELP(nano_uncut_msg,)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000476 0, NANO_UNCUT_FKEY, 0, NOVIEW, do_uncut_text);
477
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000478 sc_init_one(&main_list, NANO_CURSORPOS_KEY, _("Cur Pos"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000479 IFHELP(nano_cursorpos_msg,)
Chris Allegretta2084acc2001-11-29 03:43:08 +0000480 0, NANO_CURSORPOS_FKEY, 0, VIEW, do_cursorpos_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000481
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000482 sc_init_one(&main_list, NANO_SPELL_KEY, _("To Spell"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000483 IFHELP(nano_spell_msg,)
484 0, NANO_SPELL_FKEY, 0, NOVIEW, do_spell);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000485
486
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000487 sc_init_one(&main_list, NANO_UP_KEY, _("Up"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000488 IFHELP(nano_up_msg,)
489 0, KEY_UP, 0, VIEW, do_up);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000490
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000491 sc_init_one(&main_list, NANO_DOWN_KEY, _("Down"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000492 IFHELP(nano_down_msg,)
493 0, KEY_DOWN, 0, VIEW, do_down);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000494
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000495 sc_init_one(&main_list, NANO_FORWARD_KEY, _("Forward"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000496 IFHELP(nano_forward_msg,)
497 0, KEY_RIGHT, 0, VIEW, do_right);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000498
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000499 sc_init_one(&main_list, NANO_BACK_KEY, _("Back"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000500 IFHELP(nano_back_msg,)
501 0, KEY_LEFT, 0, VIEW, do_left);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000502
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000503 sc_init_one(&main_list, NANO_HOME_KEY, _("Home"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000504 IFHELP(nano_home_msg,)
505 0, KEY_HOME, 362, VIEW, do_home);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000506
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000507 sc_init_one(&main_list, NANO_END_KEY, _("End"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000508 IFHELP(nano_end_msg,)
509 0, KEY_END, 385, VIEW, do_end);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000510
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000511 sc_init_one(&main_list, NANO_REFRESH_KEY, _("Refresh"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000512 IFHELP(nano_refresh_msg,)
513 0, 0, 0, VIEW, total_refresh);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000514
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000515 sc_init_one(&main_list, NANO_MARK_KEY, _("Mark Text"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000516 IFHELP(nano_mark_msg,)
517 NANO_ALT_MARK_KEY, 0, 0, NOVIEW, do_mark);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000518
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000519 sc_init_one(&main_list, NANO_DELETE_KEY, _("Delete"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000520 IFHELP(nano_delete_msg,) 0, KEY_DC,
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000521 NANO_CONTROL_D, NOVIEW, do_delete);
522
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000523 sc_init_one(&main_list, NANO_BACKSPACE_KEY, _("Backspace"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000524 IFHELP(nano_backspace_msg,) 0,
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000525 KEY_BACKSPACE, 127, NOVIEW, do_backspace);
526
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000527 sc_init_one(&main_list, NANO_TAB_KEY, _("Tab"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000528 IFHELP(nano_tab_msg,)
529 0, 0, 0, NOVIEW, do_tab);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000530
Chris Allegrettabf9a8cc2000-11-17 01:37:39 +0000531 if (ISSET(PICO_MODE))
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000532 sc_init_one(&main_list, NANO_REPLACE_KEY, _("Replace"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000533 IFHELP(nano_replace_msg,)
Chris Allegretta044d1b12002-01-08 00:33:32 +0000534 NANO_ALT_REPLACE_KEY, NANO_REPLACE_FKEY, 0, NOVIEW, do_replace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000535 else
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000536 sc_init_one(&main_list, NANO_JUSTIFY_KEY, _("Justify"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000537 IFHELP(nano_justify_msg,)
538 0, NANO_JUSTIFY_FKEY, 0, NOVIEW, do_justify);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000539
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000540 sc_init_one(&main_list, NANO_ENTER_KEY, _("Enter"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000541 IFHELP(nano_enter_msg,)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000542 0, KEY_ENTER, NANO_CONTROL_M, NOVIEW, do_enter_void);
543
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000544 sc_init_one(&main_list, NANO_GOTO_KEY, _("Goto Line"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000545 IFHELP(nano_goto_msg,)
Chris Allegrettaf7dee922002-01-07 16:43:25 +0000546 NANO_ALT_GOTO_KEY, NANO_GOTO_FKEY, 0, VIEW, do_gotoline_void);
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000547
Chris Allegretta8d990b52001-09-22 22:14:25 +0000548#if (!defined NANO_SMALL) && (defined HAVE_REGEX_H)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000549 sc_init_one(&main_list, -9, _("Find Other Bracket"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000550 IFHELP(nano_bracket_msg,)
Chris Allegretta8d990b52001-09-22 22:14:25 +0000551 NANO_BRACKET_KEY, 0, 0, VIEW, do_find_bracket);
552#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000553
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000554#ifdef ENABLE_MULTIBUFFER
555 sc_init_one(&main_list, -9, _("Previous File"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000556 IFHELP(nano_openprev_msg,)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000557 NANO_OPENPREV_KEY, 0, 0, VIEW, open_prevfile_void);
558 sc_init_one(&main_list, -9, _("Next File"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000559 IFHELP(nano_opennext_msg,)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000560 NANO_OPENNEXT_KEY, 0, 0, VIEW, open_nextfile_void);
561#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +0000562
Chris Allegrettadab017e2002-04-23 10:56:06 +0000563 free_shortcutage(&whereis_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000564
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000565 sc_init_one(&whereis_list, NANO_HELP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000566 _("Get Help"), IFHELP(nano_help_msg,)
567 0, 0, 0, VIEW, do_help);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000568
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000569 sc_init_one(&whereis_list, NANO_CANCEL_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000570 _("Cancel"), IFHELP(nano_cancel_msg,)
571 0, 0, 0, VIEW, 0);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000572
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000573 sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, _("First Line"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000574 IFHELP(nano_firstline_msg,)
575 0, 0, 0, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000576
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000577 sc_init_one(&whereis_list, NANO_LASTLINE_KEY, _("Last Line"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000578 IFHELP(nano_lastline_msg,)
579 0, 0, 0, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000580
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000581 sc_init_one(&whereis_list, NANO_OTHERSEARCH_KEY, _("Replace"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000582 IFHELP(nano_replace_msg,)
583 0, 0, 0, VIEW, do_replace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000584
Chris Allegrettadab017e2002-04-23 10:56:06 +0000585 sc_init_one(&whereis_list, NANO_FROMSEARCHTOGOTO_KEY, _("Goto Line"),
586 IFHELP(nano_goto_msg,)
587 0, 0, 0, VIEW, do_gotoline_void);
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000588
Chris Allegretta5f36c372001-07-16 00:48:53 +0000589#ifndef NANO_SMALL
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000590 sc_init_one(&whereis_list, TOGGLE_CASE_KEY, _("Case Sens"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000591 IFHELP(nano_case_msg,)
592 0, 0, 0, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000593
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000594 sc_init_one(&whereis_list, TOGGLE_BACKWARDS_KEY, _("Direction"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000595 IFHELP(nano_reverse_msg,)
596 0, 0, 0, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000597
Chris Allegretta658399a2001-06-14 02:54:22 +0000598#ifdef HAVE_REGEX_H
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000599 sc_init_one(&whereis_list, TOGGLE_REGEXP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000600 _("Regexp"), IFHELP(nano_regexp_msg,)
601 0, 0, 0, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000602#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000603#endif /* !NANO_SMALL */
Chris Allegretta5f36c372001-07-16 00:48:53 +0000604
Chris Allegrettadab017e2002-04-23 10:56:06 +0000605 free_shortcutage(&replace_list);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000606
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000607 sc_init_one(&replace_list, NANO_HELP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000608 _("Get Help"), IFHELP(nano_help_msg,)
609 0, 0, 0, VIEW, do_help);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000610
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000611 sc_init_one(&replace_list, NANO_CANCEL_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000612 _("Cancel"), IFHELP(nano_cancel_msg,)
613 0, 0, 0, VIEW, 0);
Chris Allegretta5f36c372001-07-16 00:48:53 +0000614
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000615 sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, _("First Line"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000616 IFHELP(nano_firstline_msg,)
617 0, 0, 0, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000618
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000619 sc_init_one(&replace_list, NANO_LASTLINE_KEY, _("Last Line"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000620 IFHELP(nano_lastline_msg,)
621 0, 0, 0, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000622
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000623 sc_init_one(&replace_list, NANO_OTHERSEARCH_KEY, _("No Replace"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000624 IFHELP(nano_whereis_msg,)
625 0, 0, 0, VIEW, do_search);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000626
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000627 sc_init_one(&replace_list, NANO_FROMSEARCHTOGOTO_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000628 _("Goto Line"), IFHELP(nano_goto_msg,)
629 0, 0, 0, VIEW, do_gotoline_void);
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000630
Chris Allegretta5f36c372001-07-16 00:48:53 +0000631#ifndef NANO_SMALL
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000632 sc_init_one(&replace_list, TOGGLE_CASE_KEY, _("Case Sens"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000633 IFHELP(nano_case_msg,)
634 0, 0, 0, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000635
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000636 sc_init_one(&replace_list, TOGGLE_BACKWARDS_KEY, _("Direction"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000637 IFHELP(nano_reverse_msg,)
638 0, 0, 0, VIEW, 0);
Chris Allegretta105da332000-10-31 05:10:10 +0000639
Chris Allegretta658399a2001-06-14 02:54:22 +0000640#ifdef HAVE_REGEX_H
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000641 sc_init_one(&replace_list, TOGGLE_REGEXP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000642 _("Regexp"), IFHELP(nano_regexp_msg,)
643 0, 0, 0, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000644#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000645#endif /* !NANO_SMALL */
Chris Allegretta5f36c372001-07-16 00:48:53 +0000646
Chris Allegrettadab017e2002-04-23 10:56:06 +0000647 free_shortcutage(&replace_list_2);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000648
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000649 sc_init_one(&replace_list_2, NANO_HELP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000650 _("Get Help"), IFHELP(nano_help_msg,)
651 0, 0, 0, VIEW, do_help);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000652
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000653 sc_init_one(&replace_list_2, NANO_CANCEL_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000654 _("Cancel"), IFHELP(nano_cancel_msg,)
655 0, 0, 0, VIEW, 0);
Chris Allegretta105da332000-10-31 05:10:10 +0000656
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000657 sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, _("First Line"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000658 IFHELP(nano_firstline_msg,)
659 0, 0, 0, VIEW, do_first_line);
Chris Allegretta105da332000-10-31 05:10:10 +0000660
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000661 sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, _("Last Line"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000662 IFHELP(nano_lastline_msg,)
663 0, 0, 0, VIEW, do_last_line);
Chris Allegretta105da332000-10-31 05:10:10 +0000664
Chris Allegrettadab017e2002-04-23 10:56:06 +0000665 free_shortcutage(&goto_list);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000666
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000667 sc_init_one(&goto_list, NANO_HELP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000668 _("Get Help"), IFHELP(nano_help_msg,)
669 0, 0, 0, VIEW, do_help);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000670
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000671 sc_init_one(&goto_list, NANO_CANCEL_KEY, _("Cancel"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000672 IFHELP(nano_cancel_msg,)
673 0, 0, 0, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000674
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000675 sc_init_one(&goto_list, NANO_FIRSTLINE_KEY, _("First Line"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000676 IFHELP(nano_firstline_msg,)
677 0, 0, 0, VIEW, &do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000678
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000679 sc_init_one(&goto_list, NANO_LASTLINE_KEY, _("Last Line"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000680 IFHELP(nano_lastline_msg,)
681 0, 0, 0, VIEW, &do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000682
Chris Allegrettadab017e2002-04-23 10:56:06 +0000683 free_shortcutage(&help_list);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000684
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000685 sc_init_one(&help_list, NANO_PREVPAGE_KEY, _("Prev Page"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000686 IFHELP(nano_prevpage_msg,)
Chris Allegretta3e3ae942001-09-22 19:02:04 +0000687 0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, do_page_up);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000688
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000689 sc_init_one(&help_list, NANO_NEXTPAGE_KEY, _("Next Page"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000690 IFHELP(nano_nextpage_msg,)
Chris Allegretta3e3ae942001-09-22 19:02:04 +0000691 0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, do_page_down);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000692
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000693 sc_init_one(&help_list, NANO_EXIT_KEY, _("Exit"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000694 IFHELP(nano_exit_msg,)
695 0, NANO_EXIT_FKEY, 0, VIEW, do_exit);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000696
Chris Allegrettadab017e2002-04-23 10:56:06 +0000697 free_shortcutage(&writefile_list);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000698
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000699 sc_init_one(&writefile_list, NANO_HELP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000700 _("Get Help"), IFHELP(nano_help_msg,)
701 0, 0, 0, VIEW, do_help);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000702
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000703#ifndef DISABLE_BROWSER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000704 sc_init_one(&writefile_list, NANO_TOFILES_KEY, _("To Files"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000705 IFHELP(nano_tofiles_msg,)
706 0, 0, 0, NOVIEW, 0);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000707#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000708
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000709#ifndef NANO_SMALL
710 sc_init_one(&writefile_list, TOGGLE_DOS_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000711 _("DOS Format"), IFHELP(nano_dos_msg,)
712 0, 0, 0, NOVIEW, 0);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000713
714 sc_init_one(&writefile_list, TOGGLE_MAC_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000715 _("Mac Format"), IFHELP(nano_mac_msg,)
716 0, 0, 0, NOVIEW, 0);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000717#endif
718
719 sc_init_one(&writefile_list,
720 NANO_APPEND_KEY, _("Append"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000721 IFHELP(nano_append_msg,)
722 0, 0, 0, NOVIEW, 0);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000723
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000724 sc_init_one(&writefile_list,
725 NANO_PREPEND_KEY, _("Prepend"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000726 IFHELP(nano_prepend_msg,)
727 0, 0, 0, NOVIEW, 0);
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000728
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000729 sc_init_one(&writefile_list, NANO_CANCEL_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000730 _("Cancel"), IFHELP(nano_cancel_msg,)
731 0, 0, 0, VIEW, 0);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000732
Chris Allegrettadab017e2002-04-23 10:56:06 +0000733 free_shortcutage(&insertfile_list);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000734
735 sc_init_one(&insertfile_list, NANO_HELP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000736 _("Get Help"), IFHELP(nano_help_msg,)
737 0, 0, 0, VIEW, do_help);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000738
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000739 sc_init_one(&insertfile_list, NANO_CANCEL_KEY, _("Cancel"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000740 IFHELP(nano_cancel_msg,)
741 0, 0, 0, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000742
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000743#ifndef DISABLE_BROWSER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000744 sc_init_one(&insertfile_list, NANO_TOFILES_KEY, _("To Files"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000745 IFHELP(nano_tofiles_msg,)
746 0, 0, 0, NOVIEW, 0);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000747#endif
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000748#ifndef NANO_SMALL
749 sc_init_one(&insertfile_list, NANO_EXTCMD_KEY, _("Execute Command"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000750 IFHELP(nano_execute_msg,)
751 0, 0, 0, NOVIEW, 0);
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000752#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000753
Chris Allegrettadab017e2002-04-23 10:56:06 +0000754 free_shortcutage(&spell_list);
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000755
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000756 sc_init_one(&spell_list, NANO_HELP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000757 _("Get Help"), IFHELP(nano_help_msg,)
758 0, 0, 0, VIEW, do_help);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000759
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000760 sc_init_one(&spell_list, NANO_CANCEL_KEY, _("Cancel"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000761 IFHELP(nano_cancel_msg,)
762 0, 0, 0, VIEW, 0);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000763
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000764#ifndef NANO_SMALL
Chris Allegrettadab017e2002-04-23 10:56:06 +0000765 free_shortcutage(&extcmd_list);
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000766
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000767 sc_init_one(&extcmd_list, NANO_HELP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000768 _("Get Help"), IFHELP(nano_help_msg,)
769 0, 0, 0, VIEW, do_help);
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000770
771 sc_init_one(&extcmd_list, NANO_CANCEL_KEY, _("Cancel"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000772 IFHELP(nano_cancel_msg,)
773 0, 0, 0, VIEW, 0);
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000774#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000775
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000776#ifndef DISABLE_BROWSER
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000777
Chris Allegrettadab017e2002-04-23 10:56:06 +0000778 free_shortcutage(&browser_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000779
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000780 sc_init_one(&browser_list, NANO_HELP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000781 _("Get Help"), IFHELP(nano_help_msg,)
782 0, 0, 0, VIEW, do_help);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000783
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000784 sc_init_one(&browser_list, NANO_EXIT_KEY, _("Exit"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000785 IFHELP(nano_exit_msg,)
786 0, NANO_EXIT_FKEY, 0, VIEW, 0);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000787
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000788 sc_init_one(&browser_list, NANO_PREVPAGE_KEY, _("Prev Page"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000789 IFHELP(nano_prevpage_msg,)
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000790 0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, 0);
791
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000792 sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, _("Next Page"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000793 IFHELP(nano_nextpage_msg,)
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000794 0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, 0);
795
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000796 sc_init_one(&browser_list, NANO_GOTO_KEY, _("Goto"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000797 IFHELP(nano_gotodir_msg,)
798 NANO_ALT_GOTO_KEY, NANO_GOTO_FKEY, 0, VIEW, 0);
Rocco Corsi12f294c2001-04-14 06:50:24 +0000799
Chris Allegrettadab017e2002-04-23 10:56:06 +0000800 free_shortcutage(&gotodir_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000801
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000802 sc_init_one(&gotodir_list, NANO_HELP_KEY,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000803 _("Get Help"), IFHELP(nano_help_msg,)
804 0, 0, 0, VIEW, do_help);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000805
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000806 sc_init_one(&gotodir_list, NANO_CANCEL_KEY, _("Cancel"),
Chris Allegrettadab017e2002-04-23 10:56:06 +0000807 IFHELP(nano_cancel_msg,)
808 0, 0, 0, VIEW, 0);
Rocco Corsi12f294c2001-04-14 06:50:24 +0000809
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000810#endif
811
812
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000813#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined (DISABLE_HELP)
814 currshortcut = main_list;
815#endif
816
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000817#ifndef NANO_SMALL
Chris Allegrettadab017e2002-04-23 10:56:06 +0000818 toggle_init();
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000819#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000820}
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000821
822/* added by SPK for memory cleanup, gracefully return our malloc()s */
823void thanks_for_all_the_fish(void)
824{
825#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000826 openfilestruct * current_open_file;
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000827#endif
828
Chris Allegretta2598c662002-03-28 01:59:34 +0000829#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000830 if (operating_dir != NULL)
831 free(operating_dir);
832 if (full_operating_dir != NULL)
833 free(full_operating_dir);
834#endif
835 if (last_search != NULL)
836 free(last_search);
837 if (last_replace != NULL)
838 free(last_replace);
839 if (hblank != NULL)
840 free(hblank);
841#ifndef DISABLE_SPELLER
842 if (alt_speller != NULL)
843 free(alt_speller);
844#endif
845 if (help_text != NULL)
846 free(help_text);
847 if (filename != NULL)
848 free(filename);
849 if (answer != NULL)
850 free(answer);
851 if (cutbuffer != NULL)
852 free_filestruct(cutbuffer);
853
854 free_shortcutage(&main_list);
855 free_shortcutage(&whereis_list);
856 free_shortcutage(&replace_list);
857 free_shortcutage(&replace_list_2);
858 free_shortcutage(&help_list);
859 free_shortcutage(&writefile_list);
860 free_shortcutage(&insertfile_list);
861 free_shortcutage(&spell_list);
862#ifndef DISABLE_BROWSER
863 free_shortcutage(&browser_list);
864#endif
865 free_shortcutage(&gotodir_list);
866 free_shortcutage(&goto_list);
867
868#ifndef NANO_SMALL
869 free_toggles();
870#endif
871
872#ifdef ENABLE_MULTIBUFFER
873/* Cleanup of Multibuffers . . .
874 Do not cleanup the current one, that is fileage . . . do the
875 rest of them though! (should be none if all went well) */
876 current_open_file = open_files;
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000877 if (open_files != NULL) {
878 while (open_files->prev != NULL)
879 open_files = open_files->prev;
880 while (open_files->next != NULL) {
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000881 /* cleanup of a multi buf . . . */
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000882 open_files = open_files->next;
883 if (open_files->prev != current_open_file)
884 free_openfilestruct(open_files->prev);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000885 }
886 /* cleanup of last multi buf . . . */
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000887 free_openfilestruct(open_files);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000888 }
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000889#else
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000890 /* starting the cleanup of fileage now . . . */
891
892 if (fileage != NULL)
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000893 free_filestruct(fileage);
894#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000895
896 /* that is all for now */
897
898}