blob: e341f516fd62d44106dd540a98ef1b7bfed2835b [file] [log] [blame]
Chris Allegretta11b00112000-08-06 21:13:45 +00001/* $Id$ */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00002/**************************************************************************
3 * global.c *
4 * *
David Lawrence Ramseyf28f50e2004-01-09 23:04:55 +00005 * Copyright (C) 1999-2004 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 Allegretta1dd0bc92002-10-13 18:43:45 +000024#include <stdlib.h>
Chris Allegrettadab017e2002-04-23 10:56:06 +000025#include <assert.h>
Chris Allegretta6efda542001-04-28 18:03:52 +000026#include <sys/stat.h>
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000027#include "proto.h"
David Lawrence Ramseyf21cd102002-06-13 00:40:19 +000028#include "nano.h"
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000029
Chris Allegretta7662c862003-01-13 01:35:15 +000030/* Global variables */
Chris Allegretta48b06702002-02-22 04:30:50 +000031
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000032#ifndef DISABLE_WRAPJUSTIFY
David Lawrence Ramsey49c3f242004-07-12 16:07:14 +000033/* wrap_at might be set in rcfile.c or nano.c. */
34ssize_t wrap_at = -CHARS_FROM_EOL; /* Right justified fill value,
35 allows resize */
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000036#endif
37
Chris Allegretta6df90f52002-07-19 01:08:59 +000038char *last_search = NULL; /* Last string we searched for */
39char *last_replace = NULL; /* Last replacement string */
40int search_last_line; /* Is this the last search line? */
41
David Lawrence Ramseyedab0cc2004-07-03 03:09:12 +000042long flags = 0; /* Our flag containing many options */
David Lawrence Ramseyf21cd102002-06-13 00:40:19 +000043WINDOW *edit; /* The file portion of the editor */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000044WINDOW *topwin; /* Top line of screen */
45WINDOW *bottomwin; /* Bottom buffer */
Chris Allegretta1a6e9042000-12-14 13:56:28 +000046char *filename = NULL; /* Name of the file */
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +000047
48#ifndef NANO_SMALL
49struct stat originalfilestat; /* Stat for the file as we loaded it */
50#endif
51
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000052int editwinrows = 0; /* How many rows long is the edit
53 window? */
54filestruct *current; /* Current buffer pointer */
55int current_x = 0, current_y = 0; /* Current position of X and Y in
56 the editor - relative to edit
57 window (0,0) */
58filestruct *fileage = NULL; /* Our file buffer */
59filestruct *edittop = NULL; /* Pointer to the top of the edit
60 buffer with respect to the
61 file struct */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000062filestruct *filebot = NULL; /* Last node in the file struct */
63filestruct *cutbuffer = NULL; /* A place to store cut text */
64
Chris Allegretta355fbe52001-07-14 19:32:47 +000065#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaf2387fb2002-04-10 02:31:20 +000066openfilestruct *open_files = NULL; /* The list of open files */
Chris Allegretta2d7893d2001-07-11 02:08:33 +000067#endif
68
David Lawrence Ramsey89bb9372004-05-29 16:47:52 +000069#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
70char *whitespace = NULL; /* Characters used when displaying
71 the first characters of tabs and
72 spaces. */
73#endif
74
Chris Allegrettae4f940d2002-03-03 22:36:36 +000075#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey2c62b072004-05-29 16:38:57 +000076char *punct = NULL; /* Closing punctuation that can end
77 sentences. */
78char *brackets = NULL; /* Closing brackets that can follow
79 closing punctuation and can end
80 sentences. */
Chris Allegretta7662c862003-01-13 01:35:15 +000081char *quotestr = NULL; /* Quote string. The default value is
82 set in main(). */
Chris Allegretta6df90f52002-07-19 01:08:59 +000083#endif
Chris Allegrettae4f940d2002-03-03 22:36:36 +000084
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +000085#ifndef NANO_SMALL
86char *backup_dir = NULL; /* Backup directory. */
87#endif
88
Chris Allegretta65f075d2003-02-13 03:03:49 +000089int resetstatuspos; /* Hack for resetting the status bar
90 cursor position */
Chris Allegretta6df90f52002-07-19 01:08:59 +000091char *answer = NULL; /* Answer str to many questions */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000092int totlines = 0; /* Total number of lines in the file */
Chris Allegrettab3655b42001-10-22 03:15:31 +000093long totsize = 0; /* Total number of bytes in the file */
Chris Allegretta88520c92001-05-05 17:45:54 +000094int placewewant = 0; /* The column we'd like the cursor
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000095 to jump to when we go to the
96 next or previous line */
97
David Lawrence Ramsey49c3f242004-07-12 16:07:14 +000098ssize_t tabsize = -1; /* Our internal tabsize variable. The
99 default value is set in main(). */
Chris Allegretta6d690a32000-08-03 22:51:21 +0000100
Chris Allegretta7662c862003-01-13 01:35:15 +0000101char *hblank = NULL; /* A horizontal blank line */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000102#ifndef DISABLE_HELP
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000103char *help_text; /* The text in the help window */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000104#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000105
106/* More stuff for the marker select */
107
Chris Allegretta7662c862003-01-13 01:35:15 +0000108#ifndef NANO_SMALL
David Lawrence Ramseyf28f50e2004-01-09 23:04:55 +0000109filestruct *mark_beginbuf; /* The begin marker buffer */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000110int mark_beginx; /* X value in the string to start */
Chris Allegretta7662c862003-01-13 01:35:15 +0000111#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000112
Chris Allegrettae1f14522001-09-19 03:19:43 +0000113#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000114char *operating_dir = NULL; /* Operating directory, which we can't */
115char *full_operating_dir = NULL;/* go higher than */
Chris Allegrettae1f14522001-09-19 03:19:43 +0000116#endif
117
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000118#ifndef DISABLE_SPELLER
Chris Allegretta7c27be42002-05-05 23:03:54 +0000119char *alt_speller = NULL; /* Alternative spell command */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000120#endif
121
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000122shortcut *main_list = NULL;
123shortcut *whereis_list = NULL;
124shortcut *replace_list = NULL;
Chris Allegretta48b06702002-02-22 04:30:50 +0000125shortcut *replace_list_2 = NULL; /* 2nd half of replace dialog */
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000126shortcut *goto_list = NULL;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000127shortcut *writefile_list = NULL;
128shortcut *insertfile_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000129#ifndef DISABLE_HELP
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000130shortcut *help_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000131#endif
132#ifndef DISABLE_SPELLER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000133shortcut *spell_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000134#endif
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000135#ifndef NANO_SMALL
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000136shortcut *extcmd_list = NULL;
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000137#endif
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000138#ifndef DISABLE_BROWSER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000139shortcut *browser_list = NULL;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000140shortcut *gotodir_list = NULL;
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000141#endif
Chris Allegretta201f1d92003-02-05 02:51:19 +0000142
Chris Allegretta8ce24132001-04-30 11:28:46 +0000143#ifdef ENABLE_COLOR
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000144const colortype *colorstrings = NULL;
145syntaxtype *syntaxes = NULL;
146char *syntaxstr = NULL;
Chris Allegretta8ce24132001-04-30 11:28:46 +0000147#endif
148
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +0000149#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
Chris Allegretta6df90f52002-07-19 01:08:59 +0000150const shortcut *currshortcut; /* Current shortcut list we're using */
Chris Allegretta6fe61492001-05-21 12:56:25 +0000151#endif
Chris Allegretta6b58acd2001-04-12 03:01:53 +0000152
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000153#ifndef NANO_SMALL
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000154toggle *toggles = NULL;
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000155#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000156
Chris Allegretta5beed502003-01-05 20:41:21 +0000157#ifndef NANO_SMALL
158historyheadtype search_history;
159historyheadtype replace_history;
160#endif
161
Chris Allegretta9fc8d432000-07-07 01:49:52 +0000162/* Regular expressions */
163
Chris Allegretta805c26d2000-09-06 13:39:17 +0000164#ifdef HAVE_REGEX_H
Chris Allegrettabd9e7c32000-10-26 01:44:42 +0000165regex_t search_regexp; /* Global to store compiled search regexp */
166regmatch_t regmatches[10]; /* Match positions for parenthetical
167 subexpressions, max of 10 */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000168#endif
Chris Allegretta3533a342002-03-24 23:19:32 +0000169
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000170int curses_ended = FALSE; /* Indicates to statusbar() to simply
171 * write to stderr, since endwin() has
172 * ended curses mode. */
173
174
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000175size_t length_of_list(const shortcut *s)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000176{
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000177 size_t i = 0;
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000178
Chris Allegrettadab017e2002-04-23 10:56:06 +0000179 for (; s != NULL; s = s->next)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000180 i++;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000181 return i;
182}
183
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000184/* Initialize a struct *without* our lovely braces =( */
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000185void sc_init_one(shortcut **shortcutage, int ctrlval, const char *desc,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000186#ifndef DISABLE_HELP
Chris Allegrettaf717f982003-02-13 22:25:01 +0000187 const char *help,
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000188#endif
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000189 int metaval, int funcval, int miscval, int view, void
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000190 (*func)(void))
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000191{
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000192 shortcut *s;
193
194 if (*shortcutage == NULL) {
David Lawrence Ramsey70047ee2003-06-14 20:41:34 +0000195 *shortcutage = (shortcut *)nmalloc(sizeof(shortcut));
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000196 s = *shortcutage;
197 } else {
198 for (s = *shortcutage; s->next != NULL; s = s->next)
199 ;
David Lawrence Ramsey70047ee2003-06-14 20:41:34 +0000200 s->next = (shortcut *)nmalloc(sizeof(shortcut));
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000201 s = s->next;
202 }
203
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000204 s->ctrlval = ctrlval;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000205 s->desc = _(desc);
Chris Allegrettadab017e2002-04-23 10:56:06 +0000206#ifndef DISABLE_HELP
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000207 s->help = _(help);
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000208#endif
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000209 s->metaval = metaval;
210 s->funcval = funcval;
211 s->miscval = miscval;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000212 s->viewok = view;
213 s->func = func;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000214 s->next = NULL;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000215}
216
Chris Allegretta07798352000-11-27 22:58:23 +0000217void shortcut_init(int unjustify)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000218{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000219 const char *get_help_msg = N_("Get Help");
220 const char *exit_msg = N_("Exit");
221 const char *prev_page_msg = N_("Prev Page");
222 const char *next_page_msg = N_("Next Page");
223 const char *replace_msg = N_("Replace");
224 const char *go_to_line_msg = N_("Go To Line");
225 const char *cancel_msg = N_("Cancel");
226 const char *first_line_msg = N_("First Line");
227 const char *last_line_msg = N_("Last Line");
228#ifndef NANO_SMALL
229 const char *case_sens_msg = N_("Case Sens");
230 const char *direction_msg = N_("Direction");
231#ifdef HAVE_REGEX_H
232 const char *regexp_msg = N_("Regexp");
233#endif
234 const char *history_msg = N_("History");
235#endif /* !NANO_SMALL */
236#ifndef DISABLE_BROWSER
237 const char *to_files_msg = N_("To Files");
238#endif
239
Chris Allegrettadab017e2002-04-23 10:56:06 +0000240#ifndef DISABLE_HELP
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000241 const char *nano_help_msg = N_("Invoke the help menu");
242 const char *nano_exit_msg =
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000243#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000244 N_("Close currently loaded file/Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000245#else
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000246 N_("Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000247#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000248 ;
249 const char *nano_writeout_msg = N_("Write the current file to disk");
250 const char *nano_justify_msg = N_("Justify the current paragraph");
251 const char *nano_insert_msg =
252 N_("Insert another file into the current one");
253 const char *nano_whereis_msg = N_("Search for text within the editor");
254 const char *nano_prevpage_msg = N_("Move to the previous screen");
255 const char *nano_nextpage_msg = N_("Move to the next screen");
256 const char *nano_cut_msg =
257 N_("Cut the current line and store it in the cutbuffer");
258 const char *nano_uncut_msg =
259 N_("Uncut from the cutbuffer into the current line");
260 const char *nano_cursorpos_msg = N_("Show the position of the cursor");
261 const char *nano_spell_msg = N_("Invoke the spell checker, if available");
262 const char *nano_goto_msg = N_("Go to a specific line number");
263 const char *nano_replace_msg = N_("Replace text within the editor");
264 const char *nano_prevline_msg = N_("Move to the previous line");
265 const char *nano_nextline_msg = N_("Move to the next line");
266 const char *nano_forward_msg = N_("Move forward one character");
267 const char *nano_back_msg = N_("Move back one character");
268 const char *nano_home_msg = N_("Move to the beginning of the current line");
269 const char *nano_end_msg = N_("Move to the end of the current line");
270 const char *nano_refresh_msg = N_("Refresh (redraw) the current screen");
271 const char *nano_mark_msg = N_("Mark text at the current cursor location");
272 const char *nano_delete_msg = N_("Delete the character under the cursor");
273 const char *nano_backspace_msg =
274 N_("Delete the character to the left of the cursor");
275 const char *nano_tab_msg = N_("Insert a tab character");
276 const char *nano_enter_msg =
277 N_("Insert a carriage return at the cursor position");
278 const char *nano_nextword_msg = N_("Move forward one word");
279 const char *nano_prevword_msg = N_("Move backward one word");
280 const char *nano_verbatim_msg = N_("Insert character(s) verbatim");
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000281#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000282 const char *nano_openprev_msg = N_("Switch to previous file buffer");
283 const char *nano_opennext_msg = N_("Switch to next file buffer");
284#endif
285#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
286 const char *nano_bracket_msg = N_("Find other bracket");
287#endif
288 const char *nano_whereis_next_msg = N_("Repeat last search");
289 const char *nano_cancel_msg = N_("Cancel the current function");
290 const char *nano_firstline_msg = N_("Go to the first line of the file");
291 const char *nano_lastline_msg = N_("Go to the last line of the file");
292 const char *nano_parabegin_msg =
293 N_("Go to the beginning of the current paragraph");
294 const char *nano_paraend_msg =
295 N_("Go to the end of the current paragraph");
296 const char *nano_fulljustify_msg = N_("Justify the entire file");
297#ifndef NANO_SMALL
298 const char *nano_case_msg =
299 N_("Make the current search/replace case (in)sensitive");
300 const char *nano_reverse_msg =
301 N_("Make the current search/replace go backwards");
302#ifdef HAVE_REGEX_H
303 const char *nano_regexp_msg = N_("Use regular expressions");
304#endif
305 const char *nano_editstr_msg =
306 N_("Edit the previous search/replace strings");
307#endif /* !NANO_SMALL */
308
309#ifndef DISABLE_BROWSER
310 const char *nano_tofiles_msg = N_("Go to file browser");
311#endif
312#ifndef NANO_SMALL
313 const char *nano_dos_msg = N_("Write file out in DOS format");
314 const char *nano_mac_msg = N_("Write file out in Mac format");
315#endif
316 const char *nano_append_msg = N_("Append to the current file");
317 const char *nano_prepend_msg = N_("Prepend to the current file");
318#ifndef NANO_SMALL
319 const char *nano_backup_msg = N_("Back up original file when saving");
320 const char *nano_execute_msg = N_("Execute external command");
321#endif
322#if defined(ENABLE_MULTIBUFFER) && !defined(NANO_SMALL)
323 const char *nano_multibuffer_msg = N_("Insert into new buffer");
324#endif
325#ifndef DISABLE_BROWSER
326 const char *nano_gotodir_msg = N_("Go to directory");
Chris Allegretta2bef1822001-09-28 19:53:11 +0000327#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000328#endif /* !DISABLE_HELP */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000329
David Lawrence Ramsey8e4adcd2004-05-20 03:29:33 +0000330/* The following macro is to be used in calling sc_init_one(). The
331 * point is that sc_init_one() takes 9 arguments, unless DISABLE_HELP is
332 * defined, when the 4th one should not be there. */
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000333#ifndef DISABLE_HELP
Chris Allegrettadab017e2002-04-23 10:56:06 +0000334# define IFHELP(help, nextvar) help, nextvar
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000335#else
336# define IFHELP(help, nextvar) nextvar
Chris Allegrettadab017e2002-04-23 10:56:06 +0000337#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000338
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000339 free_shortcutage(&main_list);
340
Jordi Mallachf9390af2003-08-05 19:31:12 +0000341 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000342 sc_init_one(&main_list, NANO_HELP_KEY, get_help_msg,
343 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
344 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000345#ifndef DISABLE_HELP
346 do_help
347#else
348 nano_disabled_msg
349#endif
350 );
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000351
Chris Allegretta355fbe52001-07-14 19:32:47 +0000352#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000353 if (open_files != NULL && (open_files->prev != NULL || open_files->next != NULL))
Jordi Mallachf9390af2003-08-05 19:31:12 +0000354 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000355 sc_init_one(&main_list, NANO_EXIT_KEY, N_("Close"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000356 IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
357 NANO_NO_KEY, VIEW, do_exit);
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000358 else
359#endif
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000360
Jordi Mallachf9390af2003-08-05 19:31:12 +0000361 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000362 sc_init_one(&main_list, NANO_EXIT_KEY, exit_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000363 IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
364 NANO_NO_KEY, VIEW, do_exit);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000365
Jordi Mallachf9390af2003-08-05 19:31:12 +0000366 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000367 sc_init_one(&main_list, NANO_WRITEOUT_KEY, N_("WriteOut"),
368 IFHELP(nano_writeout_msg, NANO_NO_KEY), NANO_WRITEOUT_FKEY,
369 NANO_NO_KEY, NOVIEW, do_writeout_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000370
Jordi Mallachf9390af2003-08-05 19:31:12 +0000371 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000372 sc_init_one(&main_list, NANO_JUSTIFY_KEY, N_("Justify"),
373 IFHELP(nano_justify_msg, NANO_NO_KEY),
374 NANO_JUSTIFY_FKEY, NANO_NO_KEY, NOVIEW,
David Lawrence Ramseya539fce2004-06-29 00:43:56 +0000375#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey8d3e7f32004-05-13 17:28:03 +0000376 do_justify_void
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000377#else
378 nano_disabled_msg
379#endif
380 );
Chris Allegretta32da4562002-01-02 15:12:21 +0000381
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000382 /* We allow inserting files in view mode if multibuffers are
383 * available, so that we can view multiple files. */
384 /* If we're using restricted mode, inserting files is disabled since
385 * it allows reading from or writing to files not specified on the
386 * command line. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000387 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000388 sc_init_one(&main_list, NANO_INSERTFILE_KEY, N_("Read File"),
389 IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_INSERTFILE_FKEY,
390 NANO_NO_KEY,
Chris Allegretta32da4562002-01-02 15:12:21 +0000391#ifdef ENABLE_MULTIBUFFER
Chris Allegrettad8451932003-03-11 03:50:40 +0000392 VIEW
Chris Allegretta32da4562002-01-02 15:12:21 +0000393#else
Chris Allegrettad8451932003-03-11 03:50:40 +0000394 NOVIEW
Chris Allegretta32da4562002-01-02 15:12:21 +0000395#endif
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000396 , !ISSET(RESTRICTED) ? do_insertfile_void : nano_disabled_msg);
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000397
Jordi Mallachf9390af2003-08-05 19:31:12 +0000398 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000399 sc_init_one(&main_list, NANO_WHEREIS_KEY, N_("Where Is"),
400 IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_WHEREIS_FKEY,
401 NANO_NO_KEY, VIEW, do_search);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000402
Jordi Mallachf9390af2003-08-05 19:31:12 +0000403 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000404 sc_init_one(&main_list, NANO_PREVPAGE_KEY, prev_page_msg,
405 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
406 NANO_NO_KEY, VIEW, do_page_up);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000407
Jordi Mallachf9390af2003-08-05 19:31:12 +0000408 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000409 sc_init_one(&main_list, NANO_NEXTPAGE_KEY, next_page_msg,
410 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
411 NANO_NO_KEY, VIEW, do_page_down);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000412
Jordi Mallachf9390af2003-08-05 19:31:12 +0000413 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000414 sc_init_one(&main_list, NANO_CUT_KEY, N_("Cut Text"),
415 IFHELP(nano_cut_msg, NANO_NO_KEY), NANO_CUT_FKEY,
416 NANO_NO_KEY, NOVIEW, do_cut_text);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000417
Chris Allegretta07798352000-11-27 22:58:23 +0000418 if (unjustify)
Jordi Mallachf9390af2003-08-05 19:31:12 +0000419 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000420 sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, N_("UnJustify"),
421 IFHELP(NULL, NANO_NO_KEY), NANO_UNJUSTIFY_FKEY,
David Lawrence Ramseyba7b1682004-02-29 20:07:14 +0000422 NANO_NO_KEY, NOVIEW, 0);
Chris Allegretta07798352000-11-27 22:58:23 +0000423 else
Jordi Mallachf9390af2003-08-05 19:31:12 +0000424 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000425 sc_init_one(&main_list, NANO_UNCUT_KEY, N_("UnCut Txt"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000426 IFHELP(nano_uncut_msg, NANO_NO_KEY), NANO_UNCUT_FKEY,
427 NANO_NO_KEY, NOVIEW, do_uncut_text);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000428
Jordi Mallachf9390af2003-08-05 19:31:12 +0000429 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000430 sc_init_one(&main_list, NANO_CURSORPOS_KEY, N_("Cur Pos"),
431 IFHELP(nano_cursorpos_msg, NANO_NO_KEY), NANO_CURSORPOS_FKEY,
432 NANO_NO_KEY, VIEW, do_cursorpos_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000433
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000434 /* If we're using restricted mode, spell checking is disabled
435 * because it allows reading from or writing to files not specified
436 * on the command line. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000437 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000438 sc_init_one(&main_list, NANO_SPELL_KEY, N_("To Spell"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000439 IFHELP(nano_spell_msg, NANO_NO_KEY), NANO_SPELL_FKEY,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000440 NANO_NO_KEY, NOVIEW,
441#ifndef DISABLE_SPELLER
442 !ISSET(RESTRICTED) ? do_spell :
443#endif
444 nano_disabled_msg);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000445
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000446 sc_init_one(&main_list, NANO_GOTO_KEY, go_to_line_msg,
447 IFHELP(nano_goto_msg, NANO_ALT_GOTO_KEY), NANO_GOTO_FKEY,
448 NANO_NO_KEY, VIEW, do_gotoline_void);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000449
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000450 sc_init_one(&main_list, NANO_REPLACE_KEY, replace_msg,
451 IFHELP(nano_replace_msg, NANO_ALT_REPLACE_KEY), NANO_REPLACE_FKEY,
452 NANO_NO_KEY, NOVIEW, do_replace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000453
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000454 sc_init_one(&main_list, NANO_PREVLINE_KEY, N_("Prev Line"),
455 IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
456 NANO_NO_KEY, VIEW, do_up);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000457
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000458 sc_init_one(&main_list, NANO_NEXTLINE_KEY, N_("Next Line"),
459 IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
460 NANO_NO_KEY, VIEW, do_down);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000461
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000462 sc_init_one(&main_list, NANO_FORWARD_KEY, N_("Forward"),
463 IFHELP(nano_forward_msg, NANO_NO_KEY), NANO_NO_KEY,
464 NANO_NO_KEY, VIEW, do_right_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000465
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000466 sc_init_one(&main_list, NANO_BACK_KEY, N_("Back"),
467 IFHELP(nano_back_msg, NANO_NO_KEY), NANO_NO_KEY,
468 NANO_NO_KEY, VIEW, do_left_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000469
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000470 sc_init_one(&main_list, NANO_HOME_KEY, N_("Home"),
471 IFHELP(nano_home_msg, NANO_NO_KEY), NANO_NO_KEY,
472 NANO_NO_KEY, VIEW, do_home);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000473
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000474 sc_init_one(&main_list, NANO_END_KEY, N_("End"),
475 IFHELP(nano_end_msg, NANO_NO_KEY), NANO_NO_KEY,
476 NANO_NO_KEY, VIEW, do_end);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000477
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000478 sc_init_one(&main_list, NANO_REFRESH_KEY, N_("Refresh"),
479 IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
480 NANO_NO_KEY, VIEW, total_refresh);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000481
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000482 sc_init_one(&main_list, NANO_MARK_KEY, N_("Mark Text"),
483 IFHELP(nano_mark_msg, NANO_ALT_MARK_KEY),
484 NANO_NO_KEY, NANO_NO_KEY, NOVIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000485#ifndef NANO_SMALL
486 do_mark
487#else
488 nano_disabled_msg
489#endif
490 );
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000491
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000492 sc_init_one(&main_list, NANO_DELETE_KEY, N_("Delete"),
493 IFHELP(nano_delete_msg, NANO_NO_KEY), NANO_NO_KEY,
494 NANO_NO_KEY, NOVIEW, do_delete);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000495
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000496 sc_init_one(&main_list, NANO_BACKSPACE_KEY, N_("Backspace"),
497 IFHELP(nano_backspace_msg, NANO_NO_KEY), NANO_NO_KEY,
498 NANO_NO_KEY, NOVIEW, do_backspace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000499
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000500 sc_init_one(&main_list, NANO_TAB_KEY, N_("Tab"),
501 IFHELP(nano_tab_msg, NANO_NO_KEY), NANO_NO_KEY,
502 NANO_NO_KEY, NOVIEW, do_tab);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000503
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000504 sc_init_one(&main_list, NANO_ENTER_KEY, N_("Enter"),
505 IFHELP(nano_enter_msg, NANO_NO_KEY), NANO_NO_KEY,
506 NANO_NO_KEY, NOVIEW, do_enter);
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000507
David Lawrence Ramseyc5967552002-06-21 03:20:06 +0000508#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000509 sc_init_one(&main_list, NANO_NEXTWORD_KEY, N_("Next Word"),
510 IFHELP(nano_nextword_msg, NANO_NO_KEY), NANO_NO_KEY,
511 NANO_NO_KEY, VIEW, do_next_word);
David Lawrence Ramseyc5967552002-06-21 03:20:06 +0000512
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000513 sc_init_one(&main_list, NANO_NO_KEY, N_("Prev Word"),
514 IFHELP(nano_prevword_msg, NANO_PREVWORD_KEY), NANO_NO_KEY,
515 NANO_NO_KEY, VIEW, do_prev_word);
Chris Allegretta8d990b52001-09-22 22:14:25 +0000516#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000517
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000518 sc_init_one(&main_list, NANO_NO_KEY, N_("Verbatim Input"),
519 IFHELP(nano_verbatim_msg, NANO_VERBATIM_KEY), NANO_NO_KEY,
520 NANO_NO_KEY, NOVIEW, do_verbatim_input);
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000521
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000522#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000523 sc_init_one(&main_list, NANO_NO_KEY, N_("Previous File"),
524 IFHELP(nano_openprev_msg, NANO_OPENPREV_KEY), NANO_NO_KEY,
525 NANO_OPENPREV_ALTKEY, VIEW, open_prevfile_void);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000526
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000527 sc_init_one(&main_list, NANO_NO_KEY, N_("Next File"),
528 IFHELP(nano_opennext_msg, NANO_OPENNEXT_KEY), NANO_NO_KEY,
529 NANO_OPENNEXT_ALTKEY, VIEW, open_nextfile_void);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000530#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +0000531
David Lawrence Ramsey5aa39832004-05-05 21:36:50 +0000532#ifndef NANO_SMALL
533#ifdef HAVE_REGEX_H
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000534 sc_init_one(&main_list, NANO_NO_KEY, N_("Find Other Bracket"),
535 IFHELP(nano_bracket_msg, NANO_BRACKET_KEY), NANO_NO_KEY,
536 NANO_NO_KEY, VIEW, do_find_bracket);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000537#endif
538
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000539 sc_init_one(&main_list, NANO_NO_KEY, N_("Where Is Next"),
540 IFHELP(nano_whereis_next_msg, NANO_WHEREIS_NEXT_KEY),
541 NANO_NO_KEY, NANO_NO_KEY, VIEW, do_research);
David Lawrence Ramsey5aa39832004-05-05 21:36:50 +0000542#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000543
Chris Allegrettadab017e2002-04-23 10:56:06 +0000544 free_shortcutage(&whereis_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000545
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000546 sc_init_one(&whereis_list, NANO_HELP_KEY, get_help_msg,
547 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
548 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000549#ifndef DISABLE_HELP
550 do_help
551#else
552 nano_disabled_msg
553#endif
554 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000555
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000556 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000557 sc_init_one(&whereis_list, NANO_CANCEL_KEY, cancel_msg,
558 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
559 NANO_NO_KEY, VIEW, 0);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000560
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000561 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000562 sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, first_line_msg,
563 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
564 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000565
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000566 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000567 sc_init_one(&whereis_list, NANO_LASTLINE_KEY, last_line_msg,
568 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
569 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000570
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000571 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000572 sc_init_one(&whereis_list, NANO_OTHERSEARCH_KEY, replace_msg,
573 IFHELP(nano_replace_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
574 NANO_NO_KEY, VIEW, do_replace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000575
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000576 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000577 sc_init_one(&whereis_list, NANO_FROMSEARCHTOGOTO_KEY, go_to_line_msg,
578 IFHELP(nano_goto_msg, NANO_NO_KEY), NANO_GOTO_FKEY,
579 NANO_NO_KEY, VIEW, do_gotoline_void);
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000580
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000581#ifndef DISABLE_JUSTIFY
582 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000583 sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, N_("Beg of Par"),
584 IFHELP(nano_parabegin_msg, NANO_NO_KEY), NANO_NO_KEY,
585 NANO_NO_KEY, VIEW, do_para_begin);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000586
587 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000588 sc_init_one(&whereis_list, NANO_PARAEND_KEY, N_("End of Par"),
589 IFHELP(nano_paraend_msg, NANO_NO_KEY), NANO_NO_KEY,
590 NANO_NO_KEY, VIEW, do_para_end);
David Lawrence Ramsey8d3e7f32004-05-13 17:28:03 +0000591
592 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000593 sc_init_one(&whereis_list, NANO_FULLJUSTIFY_KEY, N_("FullJstify"),
594 IFHELP(nano_fulljustify_msg, NANO_NO_KEY), NANO_NO_KEY,
595 NANO_NO_KEY, NOVIEW, do_full_justify);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000596#endif
597
Chris Allegretta5f36c372001-07-16 00:48:53 +0000598#ifndef NANO_SMALL
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000599 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000600 sc_init_one(&whereis_list, NANO_NO_KEY, case_sens_msg,
601 IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
602 NANO_NO_KEY, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000603
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000604 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000605 sc_init_one(&whereis_list, NANO_NO_KEY, direction_msg,
606 IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
607 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000608
Chris Allegretta658399a2001-06-14 02:54:22 +0000609#ifdef HAVE_REGEX_H
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000610 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000611 sc_init_one(&whereis_list, NANO_NO_KEY, regexp_msg,
612 IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
613 NANO_NO_KEY, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000614#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000615
616#ifndef NANO_SMALL
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000617 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000618 sc_init_one(&whereis_list, NANO_HISTORY_KEY, history_msg,
619 IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
620 NANO_NO_KEY, VIEW, 0);
Chris Allegretta5beed502003-01-05 20:41:21 +0000621#endif
622
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000623#endif /* !NANO_SMALL */
Chris Allegretta5f36c372001-07-16 00:48:53 +0000624
Chris Allegrettadab017e2002-04-23 10:56:06 +0000625 free_shortcutage(&replace_list);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000626
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000627 sc_init_one(&replace_list, NANO_HELP_KEY, get_help_msg,
628 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
629 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000630#ifndef DISABLE_HELP
631 do_help
632#else
633 nano_disabled_msg
634#endif
635 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000636
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000637 sc_init_one(&replace_list, NANO_CANCEL_KEY, cancel_msg,
638 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
639 NANO_NO_KEY, VIEW, 0);
Chris Allegretta5f36c372001-07-16 00:48:53 +0000640
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000641 sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, first_line_msg,
642 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
643 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000644
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000645 sc_init_one(&replace_list, NANO_LASTLINE_KEY, last_line_msg,
646 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
647 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000648
Jordi Mallachf9390af2003-08-05 19:31:12 +0000649 /* Translators: try to keep this string under 12 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000650 sc_init_one(&replace_list, NANO_OTHERSEARCH_KEY, N_("No Replace"),
651 IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
652 NANO_NO_KEY, VIEW, do_search);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000653
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000654 sc_init_one(&replace_list, NANO_FROMSEARCHTOGOTO_KEY, go_to_line_msg,
655 IFHELP(nano_goto_msg, NANO_NO_KEY), NANO_GOTO_FKEY,
656 NANO_NO_KEY, VIEW, do_gotoline_void);
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000657
Chris Allegretta5f36c372001-07-16 00:48:53 +0000658#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000659 sc_init_one(&replace_list, NANO_NO_KEY, case_sens_msg,
660 IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
661 NANO_NO_KEY, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000662
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000663 sc_init_one(&replace_list, NANO_NO_KEY, direction_msg,
664 IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
665 NANO_NO_KEY, VIEW, 0);
Chris Allegretta105da332000-10-31 05:10:10 +0000666
Chris Allegretta658399a2001-06-14 02:54:22 +0000667#ifdef HAVE_REGEX_H
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000668 sc_init_one(&replace_list, NANO_NO_KEY, regexp_msg,
669 IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
670 NANO_NO_KEY, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000671#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000672
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000673 sc_init_one(&replace_list, NANO_HISTORY_KEY, history_msg,
674 IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
675 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000676#endif /* !NANO_SMALL */
Chris Allegretta5f36c372001-07-16 00:48:53 +0000677
Chris Allegrettadab017e2002-04-23 10:56:06 +0000678 free_shortcutage(&replace_list_2);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000679
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000680 sc_init_one(&replace_list_2, NANO_HELP_KEY, get_help_msg,
681 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
682 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000683#ifndef DISABLE_HELP
684 do_help
685#else
686 nano_disabled_msg
687#endif
688 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000689
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000690 sc_init_one(&replace_list_2, NANO_CANCEL_KEY, cancel_msg,
691 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
692 NANO_NO_KEY, VIEW, 0);
Chris Allegretta105da332000-10-31 05:10:10 +0000693
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000694 sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, first_line_msg,
695 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
696 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta105da332000-10-31 05:10:10 +0000697
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000698 sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, last_line_msg,
699 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
700 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta105da332000-10-31 05:10:10 +0000701
Chris Allegretta5beed502003-01-05 20:41:21 +0000702#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000703 sc_init_one(&replace_list_2, NANO_HISTORY_KEY, history_msg,
704 IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
705 NANO_NO_KEY, VIEW, 0);
Chris Allegretta5beed502003-01-05 20:41:21 +0000706#endif
707
Chris Allegrettadab017e2002-04-23 10:56:06 +0000708 free_shortcutage(&goto_list);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000709
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000710 sc_init_one(&goto_list, NANO_HELP_KEY, get_help_msg,
711 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
712 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000713#ifndef DISABLE_HELP
714 do_help
715#else
716 nano_disabled_msg
717#endif
718 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000719
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000720 sc_init_one(&goto_list, NANO_CANCEL_KEY, cancel_msg,
721 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
722 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000723
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000724 sc_init_one(&goto_list, NANO_FIRSTLINE_KEY, first_line_msg,
725 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
726 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000727
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000728 sc_init_one(&goto_list, NANO_LASTLINE_KEY, last_line_msg,
729 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
730 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000731
Chris Allegretta7662c862003-01-13 01:35:15 +0000732#ifndef DISABLE_HELP
Chris Allegrettadab017e2002-04-23 10:56:06 +0000733 free_shortcutage(&help_list);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000734
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000735 sc_init_one(&help_list, NANO_PREVPAGE_KEY, prev_page_msg,
736 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
737 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000738
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000739 sc_init_one(&help_list, NANO_NEXTPAGE_KEY, next_page_msg,
740 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
741 NANO_NO_KEY, VIEW, 0);
David Lawrence Ramseybe265612004-05-29 20:38:08 +0000742
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000743 sc_init_one(&help_list, NANO_PREVLINE_KEY, N_("Prev Line"),
744 IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
745 NANO_NO_KEY, VIEW, 0);
David Lawrence Ramseybe265612004-05-29 20:38:08 +0000746
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000747 sc_init_one(&help_list, NANO_NEXTLINE_KEY, N_("Next Line"),
748 IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
749 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000750
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000751 sc_init_one(&help_list, NANO_EXIT_KEY, exit_msg,
752 IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
753 NANO_NO_KEY, VIEW, 0);
Chris Allegretta7662c862003-01-13 01:35:15 +0000754#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000755
Chris Allegrettadab017e2002-04-23 10:56:06 +0000756 free_shortcutage(&writefile_list);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000757
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000758 sc_init_one(&writefile_list, NANO_HELP_KEY, get_help_msg,
759 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
760 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000761#ifndef DISABLE_HELP
762 do_help
763#else
764 nano_disabled_msg
765#endif
766 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000767
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000768 sc_init_one(&writefile_list, NANO_CANCEL_KEY, cancel_msg,
769 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
770 NANO_NO_KEY, VIEW, 0);
771
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000772#ifndef DISABLE_BROWSER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000773 /* If we're using restricted mode, the file browser is disabled.
774 * It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000775 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000776 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000777 sc_init_one(&writefile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000778 IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
779 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000780#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000781
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000782#ifndef NANO_SMALL
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000783 /* If we're using restricted mode, the DOS format, Mac format,
784 * append, prepend, and backup toggles are disabled. The first and
785 * second are useless since inserting files is disabled, the third
786 * and fourth are disabled because they allow writing to files not
787 * specified on the command line, and the fifth is useless since
788 * backups are disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000789 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000790 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000791 sc_init_one(&writefile_list, NANO_NO_KEY, N_("DOS Format"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000792 IFHELP(nano_dos_msg, TOGGLE_DOS_KEY), NANO_NO_KEY,
793 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000794
Jordi Mallachf9390af2003-08-05 19:31:12 +0000795 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000796 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000797 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Mac Format"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000798 IFHELP(nano_mac_msg, TOGGLE_MAC_KEY), NANO_NO_KEY,
799 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000800#endif
801
Jordi Mallachf9390af2003-08-05 19:31:12 +0000802 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000803 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000804 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Append"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000805 IFHELP(nano_append_msg, NANO_APPEND_KEY), NANO_NO_KEY,
806 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000807
Jordi Mallachf9390af2003-08-05 19:31:12 +0000808 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000809 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000810 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Prepend"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000811 IFHELP(nano_prepend_msg, NANO_PREPEND_KEY), NANO_NO_KEY,
812 NANO_NO_KEY, NOVIEW, 0);
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000813
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000814#ifndef NANO_SMALL
Jordi Mallachf9390af2003-08-05 19:31:12 +0000815 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000816 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000817 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Backup File"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000818 IFHELP(nano_backup_msg, TOGGLE_BACKUP_KEY), NANO_NO_KEY,
819 NANO_NO_KEY, NOVIEW, 0);
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000820#endif
821
Chris Allegrettadab017e2002-04-23 10:56:06 +0000822 free_shortcutage(&insertfile_list);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000823
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000824 sc_init_one(&insertfile_list, NANO_HELP_KEY, get_help_msg,
825 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
826 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000827#ifndef DISABLE_HELP
828 do_help
829#else
830 nano_disabled_msg
831#endif
832 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000833
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000834 sc_init_one(&insertfile_list, NANO_CANCEL_KEY, cancel_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000835 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
836 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000837
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000838#ifndef DISABLE_BROWSER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000839 /* If we're using restricted mode, the file browser is disabled.
840 * It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000841 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000842 sc_init_one(&insertfile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000843 IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
844 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000845#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000846
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000847#ifndef NANO_SMALL
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000848 /* If we're using restricted mode, command execution is disabled.
849 * It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000850 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000851 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000852 sc_init_one(&insertfile_list, NANO_EXTCMD_KEY, N_("Execute Command"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000853 IFHELP(nano_execute_msg, NANO_NO_KEY), NANO_NO_KEY,
854 NANO_NO_KEY, NOVIEW, 0);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000855
Chris Allegrettaf7c68112002-09-03 22:58:40 +0000856#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000857 /* If we're using restricted mode, the multibuffer toggle is
858 * disabled. It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000859 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000860 if (!ISSET(RESTRICTED))
861 sc_init_one(&insertfile_list, NANO_NO_KEY, _("New Buffer"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000862 IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY), NANO_NO_KEY,
863 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettaf7c68112002-09-03 22:58:40 +0000864#endif
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000865#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000866
Chris Allegretta7662c862003-01-13 01:35:15 +0000867#ifndef DISABLE_SPELLER
Chris Allegrettadab017e2002-04-23 10:56:06 +0000868 free_shortcutage(&spell_list);
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000869
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000870 sc_init_one(&spell_list, NANO_HELP_KEY, get_help_msg,
871 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
872 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000873#ifndef DISABLE_HELP
874 do_help
875#else
876 nano_disabled_msg
877#endif
878 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000879
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000880 sc_init_one(&spell_list, NANO_CANCEL_KEY, cancel_msg,
881 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
882 NANO_NO_KEY, VIEW, 0);
Chris Allegretta7662c862003-01-13 01:35:15 +0000883#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000884
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000885#ifndef NANO_SMALL
Chris Allegrettadab017e2002-04-23 10:56:06 +0000886 free_shortcutage(&extcmd_list);
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000887
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000888 sc_init_one(&extcmd_list, NANO_HELP_KEY, get_help_msg,
889 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
890 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000891#ifndef DISABLE_HELP
892 do_help
893#else
894 nano_disabled_msg
895#endif
896 );
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000897
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000898 sc_init_one(&extcmd_list, NANO_CANCEL_KEY, cancel_msg,
899 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
900 NANO_NO_KEY, VIEW, 0);
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000901#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000902
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000903#ifndef DISABLE_BROWSER
Chris Allegrettadab017e2002-04-23 10:56:06 +0000904 free_shortcutage(&browser_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000905
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000906 sc_init_one(&browser_list, NANO_HELP_KEY, get_help_msg,
907 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
908 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000909#ifndef DISABLE_HELP
910 do_help
911#else
912 nano_disabled_msg
913#endif
914 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000915
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000916 sc_init_one(&browser_list, NANO_CANCEL_KEY, cancel_msg,
917 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
918 NANO_NO_KEY, VIEW, 0);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000919
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000920 sc_init_one(&browser_list, NANO_PREVPAGE_KEY, prev_page_msg,
921 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
922 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000923
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000924 sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, next_page_msg,
925 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
926 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000927
Jordi Mallachf9390af2003-08-05 19:31:12 +0000928 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000929 sc_init_one(&browser_list, NANO_GOTO_KEY, N_("Go To Dir"),
930 IFHELP(nano_gotodir_msg, NANO_ALT_GOTO_KEY), NANO_GOTO_FKEY,
931 NANO_NO_KEY, VIEW, 0);
Rocco Corsi12f294c2001-04-14 06:50:24 +0000932
Chris Allegrettadab017e2002-04-23 10:56:06 +0000933 free_shortcutage(&gotodir_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000934
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000935 sc_init_one(&gotodir_list, NANO_HELP_KEY, get_help_msg,
936 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
937 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000938#ifndef DISABLE_HELP
939 do_help
940#else
941 nano_disabled_msg
942#endif
943 );
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000944
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000945 sc_init_one(&gotodir_list, NANO_CANCEL_KEY, cancel_msg,
946 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
947 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000948#endif
949
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +0000950#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000951 currshortcut = main_list;
952#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000953#ifndef NANO_SMALL
Chris Allegrettadab017e2002-04-23 10:56:06 +0000954 toggle_init();
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000955#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000956}
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000957
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000958/* Deallocate the given shortcut. */
959void free_shortcutage(shortcut **shortcutage)
960{
961 assert(shortcutage != NULL);
962 while (*shortcutage != NULL) {
963 shortcut *ps = *shortcutage;
964 *shortcutage = (*shortcutage)->next;
965 free(ps);
966 }
967}
968
969#ifndef NANO_SMALL
970/* Create one new toggle structure, at the end of the toggles linked
971 * list. */
972void toggle_init_one(int val, const char *desc, long flag)
973{
974 toggle *u;
975
976 if (toggles == NULL) {
David Lawrence Ramsey94b975c2004-07-20 12:57:34 +0000977 toggles = (toggle *)nmalloc(sizeof(toggle));
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000978 u = toggles;
979 } else {
980 for (u = toggles; u->next != NULL; u = u->next)
981 ;
David Lawrence Ramsey94b975c2004-07-20 12:57:34 +0000982 u->next = (toggle *)nmalloc(sizeof(toggle));
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000983 u = u->next;
984 }
985
986 u->val = val;
987 u->desc = _(desc);
988 u->flag = flag;
989 u->next = NULL;
990}
991
992void toggle_init(void)
993{
994 /* There is no need to reinitialize the toggles. They can't
995 * change. */
996 if (toggles != NULL)
997 return;
998
999 toggle_init_one(TOGGLE_NOHELP_KEY, N_("Help mode"), NO_HELP);
1000#ifdef ENABLE_MULTIBUFFER
1001 /* If we're using restricted mode, the multibuffer toggle is
1002 * disabled. It's useless since inserting files is disabled. */
1003 if (!ISSET(RESTRICTED))
1004 toggle_init_one(TOGGLE_MULTIBUFFER_KEY, N_("Multiple file buffers"),
1005 MULTIBUFFER);
1006#endif
1007 toggle_init_one(TOGGLE_CONST_KEY, N_("Constant cursor position"),
1008 CONSTUPDATE);
1009 toggle_init_one(TOGGLE_AUTOINDENT_KEY, N_("Auto indent"), AUTOINDENT);
1010#ifndef DISABLE_WRAPPING
1011 toggle_init_one(TOGGLE_WRAP_KEY, N_("Auto line wrap"), NO_WRAP);
1012#endif
1013 toggle_init_one(TOGGLE_CUTTOEND_KEY, N_("Cut to end"), CUT_TO_END);
1014 /* If we're using restricted mode, the suspend toggle is disabled.
1015 * It's useless since suspending is disabled. */
1016 if (!ISSET(RESTRICTED))
1017 toggle_init_one(TOGGLE_SUSPEND_KEY, N_("Suspend"), SUSPEND);
1018#ifndef DISABLE_MOUSE
1019 toggle_init_one(TOGGLE_MOUSE_KEY, N_("Mouse support"), USE_MOUSE);
1020#endif
1021 /* If we're using restricted mode, the no-conversion, DOS format,
1022 * Mac format, and backup toggles are disabled. The first, second,
1023 * and third are useless since inserting files is disabled, and the
1024 * fourth is useless since backups are disabled. */
1025 if (!ISSET(RESTRICTED)) {
1026 toggle_init_one(TOGGLE_NOCONVERT_KEY,
1027 N_("No conversion from DOS/Mac format"), NO_CONVERT);
1028 toggle_init_one(TOGGLE_DOS_KEY, N_("Writing file in DOS format"),
1029 DOS_FILE);
1030 toggle_init_one(TOGGLE_MAC_KEY, N_("Writing file in Mac format"),
1031 MAC_FILE);
David Lawrence Ramseyfb8bf402004-07-13 17:43:08 +00001032 toggle_init_one(TOGGLE_BACKUP_KEY, N_("Backup files"), BACKUP_FILE);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001033 }
1034 toggle_init_one(TOGGLE_SMOOTH_KEY, N_("Smooth scrolling"), SMOOTHSCROLL);
1035 toggle_init_one(TOGGLE_SMARTHOME_KEY, N_("Smart home key"), SMART_HOME);
1036#ifdef ENABLE_COLOR
1037 toggle_init_one(TOGGLE_SYNTAX_KEY, N_("Color syntax highlighting"),
1038 COLOR_SYNTAX);
1039#endif
1040#ifdef ENABLE_NANORC
1041 toggle_init_one(TOGGLE_WHITESPACE_KEY, N_("Whitespace display"),
1042 WHITESPACE_DISPLAY);
1043#endif
1044}
1045
1046#ifdef DEBUG
1047/* Deallocate all of the toggles. */
1048void free_toggles(void)
1049{
1050 while (toggles != NULL) {
1051 toggle *pt = toggles; /* Think "previous toggle". */
1052
1053 toggles = toggles->next;
1054 free(pt);
1055 }
1056}
1057#endif
1058#endif /* !NANO_SMALL */
1059
Chris Allegretta6232d662002-05-12 19:52:15 +00001060/* This function is called just before calling exit(). Practically, the
1061 * only effect is to cause a segmentation fault if the various data
1062 * structures got bolloxed earlier. Thus, we don't bother having this
Chris Allegretta6df90f52002-07-19 01:08:59 +00001063 * function unless debugging is turned on. */
Chris Allegretta6232d662002-05-12 19:52:15 +00001064#ifdef DEBUG
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001065/* Added by SPK for memory cleanup; gracefully return our malloc()s. */
Chris Allegretta6df90f52002-07-19 01:08:59 +00001066void thanks_for_all_the_fish(void)
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001067{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001068 delwin(topwin);
1069 delwin(edit);
1070 delwin(bottomwin);
1071
Chris Allegretta7662c862003-01-13 01:35:15 +00001072#ifndef DISABLE_JUSTIFY
1073 if (quotestr != NULL)
1074 free(quotestr);
1075#endif
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +00001076#ifndef NANO_SMALL
1077 if (backup_dir != NULL)
1078 free(backup_dir);
1079#endif
Chris Allegretta2598c662002-03-28 01:59:34 +00001080#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001081 if (operating_dir != NULL)
1082 free(operating_dir);
1083 if (full_operating_dir != NULL)
1084 free(full_operating_dir);
1085#endif
1086 if (last_search != NULL)
1087 free(last_search);
1088 if (last_replace != NULL)
1089 free(last_replace);
1090 if (hblank != NULL)
1091 free(hblank);
1092#ifndef DISABLE_SPELLER
1093 if (alt_speller != NULL)
1094 free(alt_speller);
1095#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +00001096#ifndef DISABLE_HELP
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001097 if (help_text != NULL)
1098 free(help_text);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +00001099#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001100 if (filename != NULL)
1101 free(filename);
1102 if (answer != NULL)
1103 free(answer);
1104 if (cutbuffer != NULL)
Chris Allegretta7662c862003-01-13 01:35:15 +00001105 free_filestruct(cutbuffer);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001106
1107 free_shortcutage(&main_list);
1108 free_shortcutage(&whereis_list);
1109 free_shortcutage(&replace_list);
1110 free_shortcutage(&replace_list_2);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001111 free_shortcutage(&goto_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001112 free_shortcutage(&writefile_list);
1113 free_shortcutage(&insertfile_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001114#ifndef DISABLE_HELP
Chris Allegretta6df90f52002-07-19 01:08:59 +00001115 free_shortcutage(&help_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001116#endif
1117#ifndef DISABLE_SPELLER
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001118 free_shortcutage(&spell_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001119#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +00001120#ifndef NANO_SMALL
1121 free_shortcutage(&extcmd_list);
1122#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001123#ifndef DISABLE_BROWSER
1124 free_shortcutage(&browser_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001125 free_shortcutage(&gotodir_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001126#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001127
1128#ifndef NANO_SMALL
1129 free_toggles();
1130#endif
1131
1132#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaf2387fb2002-04-10 02:31:20 +00001133 if (open_files != NULL) {
Chris Allegretta6232d662002-05-12 19:52:15 +00001134 /* We free the memory associated with each open file. */
Chris Allegrettace452fb2003-02-03 02:56:44 +00001135 while (open_files->prev != NULL)
1136 open_files = open_files->prev;
Chris Allegretta6df90f52002-07-19 01:08:59 +00001137 free_openfilestruct(open_files);
Chris Allegrettace452fb2003-02-03 02:56:44 +00001138 }
Chris Allegrettaf2387fb2002-04-10 02:31:20 +00001139#else
Chris Allegrettace452fb2003-02-03 02:56:44 +00001140 free_filestruct(fileage);
Chris Allegrettaf2387fb2002-04-10 02:31:20 +00001141#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +00001142
1143#ifdef ENABLE_COLOR
1144 free(syntaxstr);
1145 while (syntaxes != NULL) {
1146 syntaxtype *bill = syntaxes;
1147
1148 free(syntaxes->desc);
1149 while (syntaxes->extensions != NULL) {
1150 exttype *bob = syntaxes->extensions;
1151
1152 syntaxes->extensions = bob->next;
Chris Allegretta7662c862003-01-13 01:35:15 +00001153 regfree(&bob->val);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001154 free(bob);
1155 }
1156 while (syntaxes->color != NULL) {
1157 colortype *bob = syntaxes->color;
1158
1159 syntaxes->color = bob->next;
Chris Allegretta7662c862003-01-13 01:35:15 +00001160 regfree(&bob->start);
1161 if (bob->end != NULL)
Chris Allegrettace452fb2003-02-03 02:56:44 +00001162 regfree(bob->end);
1163 free(bob->end);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001164 free(bob);
1165 }
1166 syntaxes = syntaxes->next;
1167 free(bill);
1168 }
1169#endif /* ENABLE_COLOR */
Chris Allegretta5beed502003-01-05 20:41:21 +00001170#ifndef NANO_SMALL
1171 /* free history lists */
1172 free_history(&search_history);
1173 free_history(&replace_history);
1174#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001175}
Chris Allegretta6232d662002-05-12 19:52:15 +00001176#endif /* DEBUG */