blob: 2d8522714faef183ab25d33c235e5f7338771dbd [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(). */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +000083#ifdef HAVE_REGEX_H
84regex_t quotereg; /* Compiled quotestr regular expression. */
85int quoterc; /* Did it compile? */
86char *quoteerr = NULL; /* The error message. */
87#else
88size_t quotelen; /* strlen(quotestr) */
89#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +000090#endif
Chris Allegrettae4f940d2002-03-03 22:36:36 +000091
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +000092#ifndef NANO_SMALL
93char *backup_dir = NULL; /* Backup directory. */
94#endif
95
David Lawrence Ramsey9b6e4762004-09-28 15:58:56 +000096bool resetstatuspos; /* Hack for resetting the status bar
Chris Allegretta65f075d2003-02-13 03:03:49 +000097 cursor position */
Chris Allegretta6df90f52002-07-19 01:08:59 +000098char *answer = NULL; /* Answer str to many questions */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000099int totlines = 0; /* Total number of lines in the file */
Chris Allegrettab3655b42001-10-22 03:15:31 +0000100long totsize = 0; /* Total number of bytes in the file */
David Lawrence Ramsey86e851b2004-07-28 20:46:25 +0000101size_t placewewant = 0; /* The column we'd like the cursor
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000102 to jump to when we go to the
103 next or previous line */
104
David Lawrence Ramsey49c3f242004-07-12 16:07:14 +0000105ssize_t tabsize = -1; /* Our internal tabsize variable. The
106 default value is set in main(). */
Chris Allegretta6d690a32000-08-03 22:51:21 +0000107
Chris Allegretta7662c862003-01-13 01:35:15 +0000108char *hblank = NULL; /* A horizontal blank line */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000109#ifndef DISABLE_HELP
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000110char *help_text; /* The text in the help window */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000111#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000112
113/* More stuff for the marker select */
114
Chris Allegretta7662c862003-01-13 01:35:15 +0000115#ifndef NANO_SMALL
David Lawrence Ramseyf28f50e2004-01-09 23:04:55 +0000116filestruct *mark_beginbuf; /* The begin marker buffer */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000117int mark_beginx; /* X value in the string to start */
Chris Allegretta7662c862003-01-13 01:35:15 +0000118#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000119
Chris Allegrettae1f14522001-09-19 03:19:43 +0000120#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000121char *operating_dir = NULL; /* Operating directory, which we can't */
122char *full_operating_dir = NULL;/* go higher than */
Chris Allegrettae1f14522001-09-19 03:19:43 +0000123#endif
124
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000125#ifndef DISABLE_SPELLER
Chris Allegretta7c27be42002-05-05 23:03:54 +0000126char *alt_speller = NULL; /* Alternative spell command */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000127#endif
128
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000129shortcut *main_list = NULL;
130shortcut *whereis_list = NULL;
131shortcut *replace_list = NULL;
Chris Allegretta48b06702002-02-22 04:30:50 +0000132shortcut *replace_list_2 = NULL; /* 2nd half of replace dialog */
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000133shortcut *goto_list = NULL;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000134shortcut *writefile_list = NULL;
135shortcut *insertfile_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000136#ifndef DISABLE_HELP
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000137shortcut *help_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000138#endif
139#ifndef DISABLE_SPELLER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000140shortcut *spell_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000141#endif
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000142#ifndef NANO_SMALL
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000143shortcut *extcmd_list = NULL;
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000144#endif
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000145#ifndef DISABLE_BROWSER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000146shortcut *browser_list = NULL;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000147shortcut *gotodir_list = NULL;
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000148#endif
Chris Allegretta201f1d92003-02-05 02:51:19 +0000149
Chris Allegretta8ce24132001-04-30 11:28:46 +0000150#ifdef ENABLE_COLOR
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000151const colortype *colorstrings = NULL;
152syntaxtype *syntaxes = NULL;
153char *syntaxstr = NULL;
Chris Allegretta8ce24132001-04-30 11:28:46 +0000154#endif
155
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +0000156#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
Chris Allegretta6df90f52002-07-19 01:08:59 +0000157const shortcut *currshortcut; /* Current shortcut list we're using */
Chris Allegretta6fe61492001-05-21 12:56:25 +0000158#endif
Chris Allegretta6b58acd2001-04-12 03:01:53 +0000159
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000160#ifndef NANO_SMALL
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000161toggle *toggles = NULL;
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000162#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000163
Chris Allegretta5beed502003-01-05 20:41:21 +0000164#ifndef NANO_SMALL
165historyheadtype search_history;
166historyheadtype replace_history;
167#endif
168
Chris Allegretta9fc8d432000-07-07 01:49:52 +0000169/* Regular expressions */
170
Chris Allegretta805c26d2000-09-06 13:39:17 +0000171#ifdef HAVE_REGEX_H
Chris Allegrettabd9e7c32000-10-26 01:44:42 +0000172regex_t search_regexp; /* Global to store compiled search regexp */
173regmatch_t regmatches[10]; /* Match positions for parenthetical
174 subexpressions, max of 10 */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000175#endif
Chris Allegretta3533a342002-03-24 23:19:32 +0000176
David Lawrence Ramsey82dc1c12004-08-12 03:27:54 +0000177bool curses_ended = FALSE; /* Indicates to statusbar() to simply
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000178 * write to stderr, since endwin() has
179 * ended curses mode. */
180
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000181#ifdef ENABLE_NANORC
182char *homedir = NULL; /* $HOME or from /etc/passwd. */
183#endif
184
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000185size_t length_of_list(const shortcut *s)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000186{
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000187 size_t i = 0;
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000188
Chris Allegrettadab017e2002-04-23 10:56:06 +0000189 for (; s != NULL; s = s->next)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000190 i++;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000191 return i;
192}
193
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000194/* Initialize a struct *without* our lovely braces =( */
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000195void sc_init_one(shortcut **shortcutage, int ctrlval, const char *desc,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000196#ifndef DISABLE_HELP
Chris Allegrettaf717f982003-02-13 22:25:01 +0000197 const char *help,
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000198#endif
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000199 int metaval, int funcval, int miscval, int view, void
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000200 (*func)(void))
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000201{
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000202 shortcut *s;
203
204 if (*shortcutage == NULL) {
David Lawrence Ramsey70047ee2003-06-14 20:41:34 +0000205 *shortcutage = (shortcut *)nmalloc(sizeof(shortcut));
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000206 s = *shortcutage;
207 } else {
208 for (s = *shortcutage; s->next != NULL; s = s->next)
209 ;
David Lawrence Ramsey70047ee2003-06-14 20:41:34 +0000210 s->next = (shortcut *)nmalloc(sizeof(shortcut));
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000211 s = s->next;
212 }
213
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000214 s->ctrlval = ctrlval;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000215 s->desc = _(desc);
Chris Allegrettadab017e2002-04-23 10:56:06 +0000216#ifndef DISABLE_HELP
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000217 s->help = _(help);
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000218#endif
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000219 s->metaval = metaval;
220 s->funcval = funcval;
221 s->miscval = miscval;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000222 s->viewok = view;
223 s->func = func;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000224 s->next = NULL;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000225}
226
Chris Allegretta07798352000-11-27 22:58:23 +0000227void shortcut_init(int unjustify)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000228{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000229 const char *get_help_msg = N_("Get Help");
230 const char *exit_msg = N_("Exit");
231 const char *prev_page_msg = N_("Prev Page");
232 const char *next_page_msg = N_("Next Page");
233 const char *replace_msg = N_("Replace");
234 const char *go_to_line_msg = N_("Go To Line");
235 const char *cancel_msg = N_("Cancel");
236 const char *first_line_msg = N_("First Line");
237 const char *last_line_msg = N_("Last Line");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000238#ifndef DISABLE_JUSTIFY
239 const char *beg_of_par_msg = N_("Beg of Par");
240 const char *end_of_par_msg = N_("End of Par");
241 const char *fulljstify_msg = N_("FullJstify");
242#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000243#ifndef NANO_SMALL
244 const char *case_sens_msg = N_("Case Sens");
245 const char *direction_msg = N_("Direction");
246#ifdef HAVE_REGEX_H
247 const char *regexp_msg = N_("Regexp");
248#endif
249 const char *history_msg = N_("History");
David Lawrence Ramsey04a8d1c2004-09-28 22:14:58 +0000250 const char *new_buffer_msg = N_("New Buffer");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000251#endif /* !NANO_SMALL */
252#ifndef DISABLE_BROWSER
253 const char *to_files_msg = N_("To Files");
254#endif
255
Chris Allegrettadab017e2002-04-23 10:56:06 +0000256#ifndef DISABLE_HELP
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000257 const char *nano_help_msg = N_("Invoke the help menu");
258 const char *nano_exit_msg =
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000259#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000260 N_("Close currently loaded file/Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000261#else
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000262 N_("Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000263#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000264 ;
265 const char *nano_writeout_msg = N_("Write the current file to disk");
266 const char *nano_justify_msg = N_("Justify the current paragraph");
267 const char *nano_insert_msg =
268 N_("Insert another file into the current one");
269 const char *nano_whereis_msg = N_("Search for text within the editor");
270 const char *nano_prevpage_msg = N_("Move to the previous screen");
271 const char *nano_nextpage_msg = N_("Move to the next screen");
272 const char *nano_cut_msg =
273 N_("Cut the current line and store it in the cutbuffer");
274 const char *nano_uncut_msg =
275 N_("Uncut from the cutbuffer into the current line");
276 const char *nano_cursorpos_msg = N_("Show the position of the cursor");
277 const char *nano_spell_msg = N_("Invoke the spell checker, if available");
278 const char *nano_goto_msg = N_("Go to a specific line number");
279 const char *nano_replace_msg = N_("Replace text within the editor");
280 const char *nano_prevline_msg = N_("Move to the previous line");
281 const char *nano_nextline_msg = N_("Move to the next line");
282 const char *nano_forward_msg = N_("Move forward one character");
283 const char *nano_back_msg = N_("Move back one character");
284 const char *nano_home_msg = N_("Move to the beginning of the current line");
285 const char *nano_end_msg = N_("Move to the end of the current line");
286 const char *nano_refresh_msg = N_("Refresh (redraw) the current screen");
287 const char *nano_mark_msg = N_("Mark text at the current cursor location");
288 const char *nano_delete_msg = N_("Delete the character under the cursor");
289 const char *nano_backspace_msg =
290 N_("Delete the character to the left of the cursor");
291 const char *nano_tab_msg = N_("Insert a tab character");
292 const char *nano_enter_msg =
293 N_("Insert a carriage return at the cursor position");
David Lawrence Ramsey00d77982004-08-07 21:27:37 +0000294#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000295 const char *nano_nextword_msg = N_("Move forward one word");
296 const char *nano_prevword_msg = N_("Move backward one word");
David Lawrence Ramsey00d77982004-08-07 21:27:37 +0000297#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000298#ifndef DISABLE_JUSTIFY
299 const char *nano_parabegin_msg =
300 N_("Go to the beginning of the current paragraph");
301 const char *nano_paraend_msg =
302 N_("Go to the end of the current paragraph");
303#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000304#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000305 const char *nano_openprev_msg = N_("Switch to the previous file buffer");
306 const char *nano_opennext_msg = N_("Switch to the next file buffer");
307#endif
308 const char *nano_verbatim_msg = N_("Insert character(s) verbatim");
309#ifndef DISABLE_JUSTIFY
310 const char *nano_fulljustify_msg = N_("Justify the entire file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000311#endif
David Lawrence Ramsey00d77982004-08-07 21:27:37 +0000312#ifndef NANO_SMALL
313#ifdef HAVE_REGEX_H
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000314 const char *nano_bracket_msg = N_("Find other bracket");
315#endif
316 const char *nano_whereis_next_msg = N_("Repeat last search");
David Lawrence Ramsey00d77982004-08-07 21:27:37 +0000317#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000318 const char *nano_cancel_msg = N_("Cancel the current function");
319 const char *nano_firstline_msg = N_("Go to the first line of the file");
320 const char *nano_lastline_msg = N_("Go to the last line of the file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000321#ifndef NANO_SMALL
322 const char *nano_case_msg =
323 N_("Make the current search/replace case (in)sensitive");
324 const char *nano_reverse_msg =
325 N_("Make the current search/replace go backwards");
326#ifdef HAVE_REGEX_H
327 const char *nano_regexp_msg = N_("Use regular expressions");
328#endif
329 const char *nano_editstr_msg =
330 N_("Edit the previous search/replace strings");
331#endif /* !NANO_SMALL */
332
333#ifndef DISABLE_BROWSER
334 const char *nano_tofiles_msg = N_("Go to file browser");
335#endif
336#ifndef NANO_SMALL
337 const char *nano_dos_msg = N_("Write file out in DOS format");
338 const char *nano_mac_msg = N_("Write file out in Mac format");
339#endif
340 const char *nano_append_msg = N_("Append to the current file");
341 const char *nano_prepend_msg = N_("Prepend to the current file");
342#ifndef NANO_SMALL
343 const char *nano_backup_msg = N_("Back up original file when saving");
344 const char *nano_execute_msg = N_("Execute external command");
345#endif
346#if defined(ENABLE_MULTIBUFFER) && !defined(NANO_SMALL)
347 const char *nano_multibuffer_msg = N_("Insert into new buffer");
348#endif
349#ifndef DISABLE_BROWSER
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000350 const char *nano_exitbrowser_msg = N_("Exit from the file browser");
351 const char *nano_gotodir_msg = N_("Go to directory");
Chris Allegretta2bef1822001-09-28 19:53:11 +0000352#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000353#endif /* !DISABLE_HELP */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000354
David Lawrence Ramsey8e4adcd2004-05-20 03:29:33 +0000355/* The following macro is to be used in calling sc_init_one(). The
356 * point is that sc_init_one() takes 9 arguments, unless DISABLE_HELP is
357 * defined, when the 4th one should not be there. */
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000358#ifndef DISABLE_HELP
Chris Allegrettadab017e2002-04-23 10:56:06 +0000359# define IFHELP(help, nextvar) help, nextvar
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000360#else
361# define IFHELP(help, nextvar) nextvar
Chris Allegrettadab017e2002-04-23 10:56:06 +0000362#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000363
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000364 free_shortcutage(&main_list);
365
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_HELP_KEY, get_help_msg,
368 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
369 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000370#ifndef DISABLE_HELP
371 do_help
372#else
373 nano_disabled_msg
374#endif
375 );
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000376
Chris Allegretta355fbe52001-07-14 19:32:47 +0000377#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey02517e02004-09-05 21:40:31 +0000378 if (open_files != NULL && (open_files->prev != NULL ||
379 open_files->next != NULL))
Jordi Mallachf9390af2003-08-05 19:31:12 +0000380 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000381 sc_init_one(&main_list, NANO_EXIT_KEY, N_("Close"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000382 IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
383 NANO_NO_KEY, VIEW, do_exit);
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000384 else
385#endif
Jordi Mallachf9390af2003-08-05 19:31:12 +0000386 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000387 sc_init_one(&main_list, NANO_EXIT_KEY, exit_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000388 IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
389 NANO_NO_KEY, VIEW, do_exit);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000390
Jordi Mallachf9390af2003-08-05 19:31:12 +0000391 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000392 sc_init_one(&main_list, NANO_WRITEOUT_KEY, N_("WriteOut"),
393 IFHELP(nano_writeout_msg, NANO_NO_KEY), NANO_WRITEOUT_FKEY,
394 NANO_NO_KEY, NOVIEW, do_writeout_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000395
Jordi Mallachf9390af2003-08-05 19:31:12 +0000396 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000397 sc_init_one(&main_list, NANO_JUSTIFY_KEY, N_("Justify"),
398 IFHELP(nano_justify_msg, NANO_NO_KEY),
399 NANO_JUSTIFY_FKEY, NANO_NO_KEY, NOVIEW,
David Lawrence Ramseya539fce2004-06-29 00:43:56 +0000400#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey8d3e7f32004-05-13 17:28:03 +0000401 do_justify_void
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000402#else
403 nano_disabled_msg
404#endif
405 );
Chris Allegretta32da4562002-01-02 15:12:21 +0000406
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000407 /* We allow inserting files in view mode if multibuffers are
408 * available, so that we can view multiple files. */
409 /* If we're using restricted mode, inserting files is disabled since
410 * it allows reading from or writing to files not specified on the
411 * command line. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000412 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000413 sc_init_one(&main_list, NANO_INSERTFILE_KEY, N_("Read File"),
414 IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_INSERTFILE_FKEY,
415 NANO_NO_KEY,
Chris Allegretta32da4562002-01-02 15:12:21 +0000416#ifdef ENABLE_MULTIBUFFER
Chris Allegrettad8451932003-03-11 03:50:40 +0000417 VIEW
Chris Allegretta32da4562002-01-02 15:12:21 +0000418#else
Chris Allegrettad8451932003-03-11 03:50:40 +0000419 NOVIEW
Chris Allegretta32da4562002-01-02 15:12:21 +0000420#endif
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000421 , !ISSET(RESTRICTED) ? do_insertfile_void : nano_disabled_msg);
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000422
Jordi Mallachf9390af2003-08-05 19:31:12 +0000423 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000424 sc_init_one(&main_list, NANO_WHEREIS_KEY, N_("Where Is"),
425 IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_WHEREIS_FKEY,
426 NANO_NO_KEY, VIEW, do_search);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000427
Jordi Mallachf9390af2003-08-05 19:31:12 +0000428 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000429 sc_init_one(&main_list, NANO_PREVPAGE_KEY, prev_page_msg,
430 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
431 NANO_NO_KEY, VIEW, do_page_up);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000432
Jordi Mallachf9390af2003-08-05 19:31:12 +0000433 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000434 sc_init_one(&main_list, NANO_NEXTPAGE_KEY, next_page_msg,
435 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
436 NANO_NO_KEY, VIEW, do_page_down);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000437
Jordi Mallachf9390af2003-08-05 19:31:12 +0000438 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000439 sc_init_one(&main_list, NANO_CUT_KEY, N_("Cut Text"),
440 IFHELP(nano_cut_msg, NANO_NO_KEY), NANO_CUT_FKEY,
441 NANO_NO_KEY, NOVIEW, do_cut_text);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000442
Chris Allegretta07798352000-11-27 22:58:23 +0000443 if (unjustify)
Jordi Mallachf9390af2003-08-05 19:31:12 +0000444 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000445 sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, N_("UnJustify"),
446 IFHELP(NULL, NANO_NO_KEY), NANO_UNJUSTIFY_FKEY,
David Lawrence Ramseyba7b1682004-02-29 20:07:14 +0000447 NANO_NO_KEY, NOVIEW, 0);
Chris Allegretta07798352000-11-27 22:58:23 +0000448 else
Jordi Mallachf9390af2003-08-05 19:31:12 +0000449 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000450 sc_init_one(&main_list, NANO_UNCUT_KEY, N_("UnCut Txt"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000451 IFHELP(nano_uncut_msg, NANO_NO_KEY), NANO_UNCUT_FKEY,
452 NANO_NO_KEY, NOVIEW, do_uncut_text);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000453
Jordi Mallachf9390af2003-08-05 19:31:12 +0000454 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000455 sc_init_one(&main_list, NANO_CURSORPOS_KEY, N_("Cur Pos"),
456 IFHELP(nano_cursorpos_msg, NANO_NO_KEY), NANO_CURSORPOS_FKEY,
457 NANO_NO_KEY, VIEW, do_cursorpos_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000458
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000459 /* If we're using restricted mode, spell checking is disabled
460 * because it allows reading from or writing to files not specified
461 * on the command line. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000462 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000463 sc_init_one(&main_list, NANO_SPELL_KEY, N_("To Spell"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000464 IFHELP(nano_spell_msg, NANO_NO_KEY), NANO_SPELL_FKEY,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000465 NANO_NO_KEY, NOVIEW,
466#ifndef DISABLE_SPELLER
467 !ISSET(RESTRICTED) ? do_spell :
468#endif
469 nano_disabled_msg);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000470
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000471 sc_init_one(&main_list, NANO_GOTO_KEY, go_to_line_msg,
472 IFHELP(nano_goto_msg, NANO_ALT_GOTO_KEY), NANO_GOTO_FKEY,
473 NANO_NO_KEY, VIEW, do_gotoline_void);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000474
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000475 sc_init_one(&main_list, NANO_REPLACE_KEY, replace_msg,
476 IFHELP(nano_replace_msg, NANO_ALT_REPLACE_KEY), NANO_REPLACE_FKEY,
477 NANO_NO_KEY, NOVIEW, do_replace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000478
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000479 sc_init_one(&main_list, NANO_PREVLINE_KEY, N_("Prev Line"),
480 IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
481 NANO_NO_KEY, VIEW, do_up);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000482
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000483 sc_init_one(&main_list, NANO_NEXTLINE_KEY, N_("Next Line"),
484 IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
485 NANO_NO_KEY, VIEW, do_down);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000486
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000487 sc_init_one(&main_list, NANO_FORWARD_KEY, N_("Forward"),
488 IFHELP(nano_forward_msg, NANO_NO_KEY), NANO_NO_KEY,
489 NANO_NO_KEY, VIEW, do_right_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000490
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000491 sc_init_one(&main_list, NANO_BACK_KEY, N_("Back"),
492 IFHELP(nano_back_msg, NANO_NO_KEY), NANO_NO_KEY,
493 NANO_NO_KEY, VIEW, do_left_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000494
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000495 sc_init_one(&main_list, NANO_HOME_KEY, N_("Home"),
496 IFHELP(nano_home_msg, NANO_NO_KEY), NANO_NO_KEY,
497 NANO_NO_KEY, VIEW, do_home);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000498
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000499 sc_init_one(&main_list, NANO_END_KEY, N_("End"),
500 IFHELP(nano_end_msg, NANO_NO_KEY), NANO_NO_KEY,
501 NANO_NO_KEY, VIEW, do_end);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000502
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000503 sc_init_one(&main_list, NANO_REFRESH_KEY, N_("Refresh"),
504 IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
505 NANO_NO_KEY, VIEW, total_refresh);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000506
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000507 sc_init_one(&main_list, NANO_MARK_KEY, N_("Mark Text"),
508 IFHELP(nano_mark_msg, NANO_ALT_MARK_KEY),
509 NANO_NO_KEY, NANO_NO_KEY, NOVIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000510#ifndef NANO_SMALL
511 do_mark
512#else
513 nano_disabled_msg
514#endif
515 );
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000516
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000517 sc_init_one(&main_list, NANO_DELETE_KEY, N_("Delete"),
518 IFHELP(nano_delete_msg, NANO_NO_KEY), NANO_NO_KEY,
519 NANO_NO_KEY, NOVIEW, do_delete);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000520
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000521 sc_init_one(&main_list, NANO_BACKSPACE_KEY, N_("Backspace"),
522 IFHELP(nano_backspace_msg, NANO_NO_KEY), NANO_NO_KEY,
523 NANO_NO_KEY, NOVIEW, do_backspace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000524
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000525 sc_init_one(&main_list, NANO_TAB_KEY, N_("Tab"),
526 IFHELP(nano_tab_msg, NANO_NO_KEY), NANO_NO_KEY,
527 NANO_NO_KEY, NOVIEW, do_tab);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000528
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000529 sc_init_one(&main_list, NANO_ENTER_KEY, N_("Enter"),
530 IFHELP(nano_enter_msg, NANO_NO_KEY), NANO_NO_KEY,
531 NANO_NO_KEY, NOVIEW, do_enter);
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000532
David Lawrence Ramseyc5967552002-06-21 03:20:06 +0000533#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000534 sc_init_one(&main_list, NANO_NEXTWORD_KEY, N_("Next Word"),
535 IFHELP(nano_nextword_msg, NANO_NO_KEY), NANO_NO_KEY,
536 NANO_NO_KEY, VIEW, do_next_word);
David Lawrence Ramseyc5967552002-06-21 03:20:06 +0000537
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000538 sc_init_one(&main_list, NANO_NO_KEY, N_("Prev Word"),
539 IFHELP(nano_prevword_msg, NANO_PREVWORD_KEY), NANO_NO_KEY,
540 NANO_NO_KEY, VIEW, do_prev_word);
Chris Allegretta8d990b52001-09-22 22:14:25 +0000541#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000542
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000543#ifndef DISABLE_JUSTIFY
544 /* Translators: try to keep this string under 10 characters long */
545 sc_init_one(&main_list, NANO_NO_KEY, beg_of_par_msg,
546 IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
547 NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin);
548
549 /* Translators: try to keep this string under 10 characters long */
550 sc_init_one(&main_list, NANO_NO_KEY, end_of_par_msg,
551 IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
552 NANO_PARAEND_ALTKEY2, VIEW, do_para_end);
553#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000554
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000555#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000556 sc_init_one(&main_list, NANO_NO_KEY, N_("Previous File"),
557 IFHELP(nano_openprev_msg, NANO_OPENPREV_KEY), NANO_NO_KEY,
558 NANO_OPENPREV_ALTKEY, VIEW, open_prevfile_void);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000559
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000560 sc_init_one(&main_list, NANO_NO_KEY, N_("Next File"),
561 IFHELP(nano_opennext_msg, NANO_OPENNEXT_KEY), NANO_NO_KEY,
562 NANO_OPENNEXT_ALTKEY, VIEW, open_nextfile_void);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000563#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +0000564
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000565 sc_init_one(&main_list, NANO_NO_KEY, N_("Verbatim Input"),
566 IFHELP(nano_verbatim_msg, NANO_VERBATIM_KEY), NANO_NO_KEY,
567 NANO_NO_KEY, NOVIEW, do_verbatim_input);
568
569#ifndef DISABLE_JUSTIFY
570 /* Translators: try to keep this string under 10 characters long */
571 sc_init_one(&main_list, NANO_NO_KEY, fulljstify_msg,
572 IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY), NANO_NO_KEY,
573 NANO_NO_KEY, NOVIEW, do_full_justify);
574#endif
575
David Lawrence Ramsey5aa39832004-05-05 21:36:50 +0000576#ifndef NANO_SMALL
577#ifdef HAVE_REGEX_H
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000578 sc_init_one(&main_list, NANO_NO_KEY, N_("Find Other Bracket"),
579 IFHELP(nano_bracket_msg, NANO_BRACKET_KEY), NANO_NO_KEY,
580 NANO_NO_KEY, VIEW, do_find_bracket);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000581#endif
582
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000583 sc_init_one(&main_list, NANO_NO_KEY, N_("Where Is Next"),
584 IFHELP(nano_whereis_next_msg, NANO_WHEREIS_NEXT_KEY),
585 NANO_NO_KEY, NANO_NO_KEY, VIEW, do_research);
David Lawrence Ramsey5aa39832004-05-05 21:36:50 +0000586#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000587
Chris Allegrettadab017e2002-04-23 10:56:06 +0000588 free_shortcutage(&whereis_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000589
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000590 sc_init_one(&whereis_list, NANO_HELP_KEY, get_help_msg,
591 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
592 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000593#ifndef DISABLE_HELP
594 do_help
595#else
596 nano_disabled_msg
597#endif
598 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000599
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000600 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000601 sc_init_one(&whereis_list, NANO_CANCEL_KEY, cancel_msg,
602 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
603 NANO_NO_KEY, VIEW, 0);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000604
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000605 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000606 sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, first_line_msg,
607 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
608 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000609
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_LASTLINE_KEY, last_line_msg,
612 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
613 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000614
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000615 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000616 sc_init_one(&whereis_list, NANO_OTHERSEARCH_KEY, replace_msg,
617 IFHELP(nano_replace_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
618 NANO_NO_KEY, VIEW, do_replace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000619
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000620 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000621 sc_init_one(&whereis_list, NANO_FROMSEARCHTOGOTO_KEY, go_to_line_msg,
622 IFHELP(nano_goto_msg, NANO_NO_KEY), NANO_GOTO_FKEY,
623 NANO_NO_KEY, VIEW, do_gotoline_void);
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000624
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000625#ifndef DISABLE_JUSTIFY
626 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000627 sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, beg_of_par_msg,
David Lawrence Ramsey9bab9ff2004-09-28 16:51:08 +0000628 IFHELP(nano_parabegin_msg, NANO_NO_KEY), NANO_NO_KEY,
629 NANO_NO_KEY, VIEW, do_para_begin);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000630
631 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000632 sc_init_one(&whereis_list, NANO_PARAEND_KEY, end_of_par_msg,
David Lawrence Ramsey9bab9ff2004-09-28 16:51:08 +0000633 IFHELP(nano_paraend_msg, NANO_NO_KEY), NANO_NO_KEY,
634 NANO_NO_KEY, VIEW, do_para_end);
David Lawrence Ramsey8d3e7f32004-05-13 17:28:03 +0000635
636 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000637 sc_init_one(&whereis_list, NANO_FULLJUSTIFY_KEY, fulljstify_msg,
David Lawrence Ramsey9bab9ff2004-09-28 16:51:08 +0000638 IFHELP(nano_fulljustify_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000639 NANO_NO_KEY, NOVIEW, do_full_justify);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000640#endif
641
Chris Allegretta5f36c372001-07-16 00:48:53 +0000642#ifndef NANO_SMALL
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000643 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000644 sc_init_one(&whereis_list, NANO_NO_KEY, case_sens_msg,
645 IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
646 NANO_NO_KEY, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000647
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000648 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000649 sc_init_one(&whereis_list, NANO_NO_KEY, direction_msg,
650 IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
651 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000652
Chris Allegretta658399a2001-06-14 02:54:22 +0000653#ifdef HAVE_REGEX_H
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000654 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000655 sc_init_one(&whereis_list, NANO_NO_KEY, regexp_msg,
656 IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
657 NANO_NO_KEY, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000658#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000659
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000660 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000661 sc_init_one(&whereis_list, NANO_HISTORY_KEY, history_msg,
662 IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
663 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000664#endif /* !NANO_SMALL */
Chris Allegretta5f36c372001-07-16 00:48:53 +0000665
Chris Allegrettadab017e2002-04-23 10:56:06 +0000666 free_shortcutage(&replace_list);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000667
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000668 sc_init_one(&replace_list, NANO_HELP_KEY, get_help_msg,
669 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
670 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000671#ifndef DISABLE_HELP
672 do_help
673#else
674 nano_disabled_msg
675#endif
676 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000677
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000678 sc_init_one(&replace_list, NANO_CANCEL_KEY, cancel_msg,
679 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
680 NANO_NO_KEY, VIEW, 0);
Chris Allegretta5f36c372001-07-16 00:48:53 +0000681
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000682 sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, first_line_msg,
683 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
684 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000685
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000686 sc_init_one(&replace_list, NANO_LASTLINE_KEY, last_line_msg,
687 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
688 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000689
Jordi Mallachf9390af2003-08-05 19:31:12 +0000690 /* Translators: try to keep this string under 12 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000691 sc_init_one(&replace_list, NANO_OTHERSEARCH_KEY, N_("No Replace"),
692 IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
693 NANO_NO_KEY, VIEW, do_search);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000694
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000695 sc_init_one(&replace_list, NANO_FROMSEARCHTOGOTO_KEY, go_to_line_msg,
696 IFHELP(nano_goto_msg, NANO_NO_KEY), NANO_GOTO_FKEY,
697 NANO_NO_KEY, VIEW, do_gotoline_void);
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000698
Chris Allegretta5f36c372001-07-16 00:48:53 +0000699#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000700 sc_init_one(&replace_list, NANO_NO_KEY, case_sens_msg,
701 IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
702 NANO_NO_KEY, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000703
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000704 sc_init_one(&replace_list, NANO_NO_KEY, direction_msg,
705 IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
706 NANO_NO_KEY, VIEW, 0);
Chris Allegretta105da332000-10-31 05:10:10 +0000707
Chris Allegretta658399a2001-06-14 02:54:22 +0000708#ifdef HAVE_REGEX_H
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000709 sc_init_one(&replace_list, NANO_NO_KEY, regexp_msg,
710 IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
711 NANO_NO_KEY, VIEW, 0);
Chris Allegretta658399a2001-06-14 02:54:22 +0000712#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000713
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000714 sc_init_one(&replace_list, NANO_HISTORY_KEY, history_msg,
715 IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
716 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000717#endif /* !NANO_SMALL */
Chris Allegretta5f36c372001-07-16 00:48:53 +0000718
Chris Allegrettadab017e2002-04-23 10:56:06 +0000719 free_shortcutage(&replace_list_2);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000720
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000721 sc_init_one(&replace_list_2, NANO_HELP_KEY, get_help_msg,
722 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
723 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000724#ifndef DISABLE_HELP
725 do_help
726#else
727 nano_disabled_msg
728#endif
729 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000730
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000731 sc_init_one(&replace_list_2, NANO_CANCEL_KEY, cancel_msg,
732 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
733 NANO_NO_KEY, VIEW, 0);
Chris Allegretta105da332000-10-31 05:10:10 +0000734
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000735 sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, first_line_msg,
736 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
737 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta105da332000-10-31 05:10:10 +0000738
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000739 sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, last_line_msg,
740 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
741 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta105da332000-10-31 05:10:10 +0000742
Chris Allegretta5beed502003-01-05 20:41:21 +0000743#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000744 sc_init_one(&replace_list_2, NANO_HISTORY_KEY, history_msg,
745 IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
746 NANO_NO_KEY, VIEW, 0);
Chris Allegretta5beed502003-01-05 20:41:21 +0000747#endif
748
Chris Allegrettadab017e2002-04-23 10:56:06 +0000749 free_shortcutage(&goto_list);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000750
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000751 sc_init_one(&goto_list, NANO_HELP_KEY, get_help_msg,
752 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
753 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000754#ifndef DISABLE_HELP
755 do_help
756#else
757 nano_disabled_msg
758#endif
759 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000760
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000761 sc_init_one(&goto_list, NANO_CANCEL_KEY, cancel_msg,
762 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
763 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000764
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000765 sc_init_one(&goto_list, NANO_FIRSTLINE_KEY, first_line_msg,
766 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
767 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000768
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000769 sc_init_one(&goto_list, NANO_LASTLINE_KEY, last_line_msg,
770 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
771 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000772
Chris Allegretta7662c862003-01-13 01:35:15 +0000773#ifndef DISABLE_HELP
Chris Allegrettadab017e2002-04-23 10:56:06 +0000774 free_shortcutage(&help_list);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000775
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000776 sc_init_one(&help_list, NANO_PREVPAGE_KEY, prev_page_msg,
777 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
778 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000779
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000780 sc_init_one(&help_list, NANO_NEXTPAGE_KEY, next_page_msg,
781 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
782 NANO_NO_KEY, VIEW, 0);
David Lawrence Ramseybe265612004-05-29 20:38:08 +0000783
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000784 sc_init_one(&help_list, NANO_PREVLINE_KEY, N_("Prev Line"),
785 IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
786 NANO_NO_KEY, VIEW, 0);
David Lawrence Ramseybe265612004-05-29 20:38:08 +0000787
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000788 sc_init_one(&help_list, NANO_NEXTLINE_KEY, N_("Next Line"),
789 IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
790 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000791
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000792 sc_init_one(&help_list, NANO_EXIT_KEY, exit_msg,
793 IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
794 NANO_NO_KEY, VIEW, 0);
Chris Allegretta7662c862003-01-13 01:35:15 +0000795#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000796
Chris Allegrettadab017e2002-04-23 10:56:06 +0000797 free_shortcutage(&writefile_list);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000798
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000799 sc_init_one(&writefile_list, NANO_HELP_KEY, get_help_msg,
800 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
801 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000802#ifndef DISABLE_HELP
803 do_help
804#else
805 nano_disabled_msg
806#endif
807 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000808
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000809 sc_init_one(&writefile_list, NANO_CANCEL_KEY, cancel_msg,
810 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
811 NANO_NO_KEY, VIEW, 0);
812
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000813#ifndef DISABLE_BROWSER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000814 /* If we're using restricted mode, the file browser is disabled.
815 * It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000816 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000817 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000818 sc_init_one(&writefile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000819 IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
820 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000821#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000822
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000823#ifndef NANO_SMALL
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000824 /* If we're using restricted mode, the DOS format, Mac format,
825 * append, prepend, and backup toggles are disabled. The first and
826 * second are useless since inserting files is disabled, the third
827 * and fourth are disabled because they allow writing to files not
828 * specified on the command line, and the fifth is useless since
829 * backups are disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000830 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000831 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000832 sc_init_one(&writefile_list, NANO_NO_KEY, N_("DOS Format"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000833 IFHELP(nano_dos_msg, TOGGLE_DOS_KEY), NANO_NO_KEY,
834 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000835
Jordi Mallachf9390af2003-08-05 19:31:12 +0000836 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000837 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000838 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Mac Format"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000839 IFHELP(nano_mac_msg, TOGGLE_MAC_KEY), NANO_NO_KEY,
840 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000841#endif
842
Jordi Mallachf9390af2003-08-05 19:31:12 +0000843 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000844 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000845 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Append"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000846 IFHELP(nano_append_msg, NANO_APPEND_KEY), NANO_NO_KEY,
847 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000848
Jordi Mallachf9390af2003-08-05 19:31:12 +0000849 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000850 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000851 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Prepend"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000852 IFHELP(nano_prepend_msg, NANO_PREPEND_KEY), NANO_NO_KEY,
853 NANO_NO_KEY, NOVIEW, 0);
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000854
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000855#ifndef NANO_SMALL
Jordi Mallachf9390af2003-08-05 19:31:12 +0000856 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000857 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000858 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Backup File"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000859 IFHELP(nano_backup_msg, TOGGLE_BACKUP_KEY), NANO_NO_KEY,
860 NANO_NO_KEY, NOVIEW, 0);
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000861#endif
862
Chris Allegrettadab017e2002-04-23 10:56:06 +0000863 free_shortcutage(&insertfile_list);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000864
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000865 sc_init_one(&insertfile_list, NANO_HELP_KEY, get_help_msg,
866 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
867 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000868#ifndef DISABLE_HELP
869 do_help
870#else
871 nano_disabled_msg
872#endif
873 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000874
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000875 sc_init_one(&insertfile_list, NANO_CANCEL_KEY, cancel_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000876 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
877 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000878
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000879#ifndef DISABLE_BROWSER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000880 /* If we're using restricted mode, the file browser is disabled.
881 * It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000882 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000883 sc_init_one(&insertfile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000884 IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
885 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000886#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000887
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000888#ifndef NANO_SMALL
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000889 /* If we're using restricted mode, command execution is disabled.
890 * It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000891 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000892 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000893 sc_init_one(&insertfile_list, NANO_EXTCMD_KEY, N_("Execute Command"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000894 IFHELP(nano_execute_msg, NANO_NO_KEY), NANO_NO_KEY,
895 NANO_NO_KEY, NOVIEW, 0);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000896
Chris Allegrettaf7c68112002-09-03 22:58:40 +0000897#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000898 /* If we're using restricted mode, the multibuffer toggle is
899 * disabled. It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000900 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000901 if (!ISSET(RESTRICTED))
David Lawrence Ramsey04a8d1c2004-09-28 22:14:58 +0000902 sc_init_one(&insertfile_list, NANO_NO_KEY, new_buffer_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000903 IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY), NANO_NO_KEY,
904 NANO_NO_KEY, NOVIEW, 0);
Chris Allegrettaf7c68112002-09-03 22:58:40 +0000905#endif
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000906#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000907
Chris Allegretta7662c862003-01-13 01:35:15 +0000908#ifndef DISABLE_SPELLER
Chris Allegrettadab017e2002-04-23 10:56:06 +0000909 free_shortcutage(&spell_list);
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000910
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000911 sc_init_one(&spell_list, NANO_HELP_KEY, get_help_msg,
912 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
913 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000914#ifndef DISABLE_HELP
915 do_help
916#else
917 nano_disabled_msg
918#endif
919 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000920
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000921 sc_init_one(&spell_list, NANO_CANCEL_KEY, cancel_msg,
922 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
923 NANO_NO_KEY, VIEW, 0);
Chris Allegretta7662c862003-01-13 01:35:15 +0000924#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000925
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000926#ifndef NANO_SMALL
Chris Allegrettadab017e2002-04-23 10:56:06 +0000927 free_shortcutage(&extcmd_list);
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000928
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000929 sc_init_one(&extcmd_list, NANO_HELP_KEY, get_help_msg,
930 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
931 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000932#ifndef DISABLE_HELP
933 do_help
934#else
935 nano_disabled_msg
936#endif
937 );
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000938
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000939 sc_init_one(&extcmd_list, NANO_CANCEL_KEY, cancel_msg,
940 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
941 NANO_NO_KEY, VIEW, 0);
David Lawrence Ramsey04a8d1c2004-09-28 22:14:58 +0000942
943 sc_init_one(&extcmd_list, NANO_NO_KEY, new_buffer_msg,
944 IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY), NANO_NO_KEY,
945 NANO_NO_KEY, NOVIEW, 0);
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000946#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000947
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000948#ifndef DISABLE_BROWSER
Chris Allegrettadab017e2002-04-23 10:56:06 +0000949 free_shortcutage(&browser_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000950
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000951 sc_init_one(&browser_list, NANO_HELP_KEY, get_help_msg,
952 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
953 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000954#ifndef DISABLE_HELP
955 do_help
956#else
957 nano_disabled_msg
958#endif
959 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000960
David Lawrence Ramsey8037fe02004-07-23 12:30:40 +0000961 sc_init_one(&browser_list, NANO_EXIT_KEY, exit_msg,
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000962 IFHELP(nano_exitbrowser_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000963 NANO_NO_KEY, VIEW, 0);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000964
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000965 sc_init_one(&browser_list, NANO_PREVPAGE_KEY, prev_page_msg,
966 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
967 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000968
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000969 sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, next_page_msg,
970 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
971 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000972
Jordi Mallachf9390af2003-08-05 19:31:12 +0000973 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000974 sc_init_one(&browser_list, NANO_GOTO_KEY, N_("Go To Dir"),
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000975 IFHELP(nano_gotodir_msg, NANO_ALT_GOTO_KEY), NANO_GOTO_FKEY,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000976 NANO_NO_KEY, VIEW, 0);
Rocco Corsi12f294c2001-04-14 06:50:24 +0000977
Chris Allegrettadab017e2002-04-23 10:56:06 +0000978 free_shortcutage(&gotodir_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000979
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000980 sc_init_one(&gotodir_list, NANO_HELP_KEY, get_help_msg,
981 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
982 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000983#ifndef DISABLE_HELP
984 do_help
985#else
986 nano_disabled_msg
987#endif
988 );
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000989
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000990 sc_init_one(&gotodir_list, NANO_CANCEL_KEY, cancel_msg,
991 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
992 NANO_NO_KEY, VIEW, 0);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000993#endif
994
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +0000995#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000996 currshortcut = main_list;
997#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000998#ifndef NANO_SMALL
Chris Allegrettadab017e2002-04-23 10:56:06 +0000999 toggle_init();
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001000#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +00001001}
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001002
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001003/* Deallocate the given shortcut. */
1004void free_shortcutage(shortcut **shortcutage)
1005{
1006 assert(shortcutage != NULL);
1007 while (*shortcutage != NULL) {
1008 shortcut *ps = *shortcutage;
1009 *shortcutage = (*shortcutage)->next;
1010 free(ps);
1011 }
1012}
1013
1014#ifndef NANO_SMALL
1015/* Create one new toggle structure, at the end of the toggles linked
1016 * list. */
1017void toggle_init_one(int val, const char *desc, long flag)
1018{
1019 toggle *u;
1020
1021 if (toggles == NULL) {
David Lawrence Ramsey94b975c2004-07-20 12:57:34 +00001022 toggles = (toggle *)nmalloc(sizeof(toggle));
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001023 u = toggles;
1024 } else {
1025 for (u = toggles; u->next != NULL; u = u->next)
1026 ;
David Lawrence Ramsey94b975c2004-07-20 12:57:34 +00001027 u->next = (toggle *)nmalloc(sizeof(toggle));
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001028 u = u->next;
1029 }
1030
1031 u->val = val;
1032 u->desc = _(desc);
1033 u->flag = flag;
1034 u->next = NULL;
1035}
1036
1037void toggle_init(void)
1038{
1039 /* There is no need to reinitialize the toggles. They can't
1040 * change. */
1041 if (toggles != NULL)
1042 return;
1043
1044 toggle_init_one(TOGGLE_NOHELP_KEY, N_("Help mode"), NO_HELP);
1045#ifdef ENABLE_MULTIBUFFER
1046 /* If we're using restricted mode, the multibuffer toggle is
1047 * disabled. It's useless since inserting files is disabled. */
1048 if (!ISSET(RESTRICTED))
1049 toggle_init_one(TOGGLE_MULTIBUFFER_KEY, N_("Multiple file buffers"),
1050 MULTIBUFFER);
1051#endif
1052 toggle_init_one(TOGGLE_CONST_KEY, N_("Constant cursor position"),
1053 CONSTUPDATE);
1054 toggle_init_one(TOGGLE_AUTOINDENT_KEY, N_("Auto indent"), AUTOINDENT);
1055#ifndef DISABLE_WRAPPING
1056 toggle_init_one(TOGGLE_WRAP_KEY, N_("Auto line wrap"), NO_WRAP);
1057#endif
1058 toggle_init_one(TOGGLE_CUTTOEND_KEY, N_("Cut to end"), CUT_TO_END);
1059 /* If we're using restricted mode, the suspend toggle is disabled.
1060 * It's useless since suspending is disabled. */
1061 if (!ISSET(RESTRICTED))
1062 toggle_init_one(TOGGLE_SUSPEND_KEY, N_("Suspend"), SUSPEND);
1063#ifndef DISABLE_MOUSE
1064 toggle_init_one(TOGGLE_MOUSE_KEY, N_("Mouse support"), USE_MOUSE);
1065#endif
1066 /* If we're using restricted mode, the no-conversion, DOS format,
1067 * Mac format, and backup toggles are disabled. The first, second,
1068 * and third are useless since inserting files is disabled, and the
1069 * fourth is useless since backups are disabled. */
1070 if (!ISSET(RESTRICTED)) {
1071 toggle_init_one(TOGGLE_NOCONVERT_KEY,
1072 N_("No conversion from DOS/Mac format"), NO_CONVERT);
1073 toggle_init_one(TOGGLE_DOS_KEY, N_("Writing file in DOS format"),
1074 DOS_FILE);
1075 toggle_init_one(TOGGLE_MAC_KEY, N_("Writing file in Mac format"),
1076 MAC_FILE);
David Lawrence Ramseyfb8bf402004-07-13 17:43:08 +00001077 toggle_init_one(TOGGLE_BACKUP_KEY, N_("Backup files"), BACKUP_FILE);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001078 }
1079 toggle_init_one(TOGGLE_SMOOTH_KEY, N_("Smooth scrolling"), SMOOTHSCROLL);
1080 toggle_init_one(TOGGLE_SMARTHOME_KEY, N_("Smart home key"), SMART_HOME);
1081#ifdef ENABLE_COLOR
1082 toggle_init_one(TOGGLE_SYNTAX_KEY, N_("Color syntax highlighting"),
1083 COLOR_SYNTAX);
1084#endif
1085#ifdef ENABLE_NANORC
1086 toggle_init_one(TOGGLE_WHITESPACE_KEY, N_("Whitespace display"),
1087 WHITESPACE_DISPLAY);
1088#endif
1089}
1090
1091#ifdef DEBUG
1092/* Deallocate all of the toggles. */
1093void free_toggles(void)
1094{
1095 while (toggles != NULL) {
1096 toggle *pt = toggles; /* Think "previous toggle". */
1097
1098 toggles = toggles->next;
1099 free(pt);
1100 }
1101}
1102#endif
1103#endif /* !NANO_SMALL */
1104
Chris Allegretta6232d662002-05-12 19:52:15 +00001105/* This function is called just before calling exit(). Practically, the
1106 * only effect is to cause a segmentation fault if the various data
1107 * structures got bolloxed earlier. Thus, we don't bother having this
Chris Allegretta6df90f52002-07-19 01:08:59 +00001108 * function unless debugging is turned on. */
Chris Allegretta6232d662002-05-12 19:52:15 +00001109#ifdef DEBUG
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001110/* Added by SPK for memory cleanup; gracefully return our malloc()s. */
Chris Allegretta6df90f52002-07-19 01:08:59 +00001111void thanks_for_all_the_fish(void)
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001112{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001113 delwin(topwin);
1114 delwin(edit);
1115 delwin(bottomwin);
1116
Chris Allegretta7662c862003-01-13 01:35:15 +00001117#ifndef DISABLE_JUSTIFY
1118 if (quotestr != NULL)
1119 free(quotestr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001120#ifdef HAVE_REGEX_H
1121 regfree(&quotereg);
1122 free(quoteerr);
1123#endif
Chris Allegretta7662c862003-01-13 01:35:15 +00001124#endif
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +00001125#ifndef NANO_SMALL
1126 if (backup_dir != NULL)
1127 free(backup_dir);
1128#endif
Chris Allegretta2598c662002-03-28 01:59:34 +00001129#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001130 if (operating_dir != NULL)
1131 free(operating_dir);
1132 if (full_operating_dir != NULL)
1133 free(full_operating_dir);
1134#endif
1135 if (last_search != NULL)
1136 free(last_search);
1137 if (last_replace != NULL)
1138 free(last_replace);
1139 if (hblank != NULL)
1140 free(hblank);
1141#ifndef DISABLE_SPELLER
1142 if (alt_speller != NULL)
1143 free(alt_speller);
1144#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +00001145#ifndef DISABLE_HELP
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001146 if (help_text != NULL)
1147 free(help_text);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +00001148#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001149 if (filename != NULL)
1150 free(filename);
1151 if (answer != NULL)
1152 free(answer);
1153 if (cutbuffer != NULL)
Chris Allegretta7662c862003-01-13 01:35:15 +00001154 free_filestruct(cutbuffer);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001155
1156 free_shortcutage(&main_list);
1157 free_shortcutage(&whereis_list);
1158 free_shortcutage(&replace_list);
1159 free_shortcutage(&replace_list_2);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001160 free_shortcutage(&goto_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001161 free_shortcutage(&writefile_list);
1162 free_shortcutage(&insertfile_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001163#ifndef DISABLE_HELP
Chris Allegretta6df90f52002-07-19 01:08:59 +00001164 free_shortcutage(&help_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001165#endif
1166#ifndef DISABLE_SPELLER
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001167 free_shortcutage(&spell_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001168#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +00001169#ifndef NANO_SMALL
1170 free_shortcutage(&extcmd_list);
1171#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001172#ifndef DISABLE_BROWSER
1173 free_shortcutage(&browser_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001174 free_shortcutage(&gotodir_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001175#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001176
1177#ifndef NANO_SMALL
1178 free_toggles();
1179#endif
1180
1181#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaf2387fb2002-04-10 02:31:20 +00001182 if (open_files != NULL) {
Chris Allegretta6232d662002-05-12 19:52:15 +00001183 /* We free the memory associated with each open file. */
Chris Allegrettace452fb2003-02-03 02:56:44 +00001184 while (open_files->prev != NULL)
1185 open_files = open_files->prev;
Chris Allegretta6df90f52002-07-19 01:08:59 +00001186 free_openfilestruct(open_files);
Chris Allegrettace452fb2003-02-03 02:56:44 +00001187 }
Chris Allegrettaf2387fb2002-04-10 02:31:20 +00001188#else
Chris Allegrettace452fb2003-02-03 02:56:44 +00001189 free_filestruct(fileage);
Chris Allegrettaf2387fb2002-04-10 02:31:20 +00001190#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +00001191
1192#ifdef ENABLE_COLOR
1193 free(syntaxstr);
1194 while (syntaxes != NULL) {
1195 syntaxtype *bill = syntaxes;
1196
1197 free(syntaxes->desc);
1198 while (syntaxes->extensions != NULL) {
1199 exttype *bob = syntaxes->extensions;
1200
1201 syntaxes->extensions = bob->next;
Chris Allegretta7662c862003-01-13 01:35:15 +00001202 regfree(&bob->val);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001203 free(bob);
1204 }
1205 while (syntaxes->color != NULL) {
1206 colortype *bob = syntaxes->color;
1207
1208 syntaxes->color = bob->next;
Chris Allegretta7662c862003-01-13 01:35:15 +00001209 regfree(&bob->start);
1210 if (bob->end != NULL)
Chris Allegrettace452fb2003-02-03 02:56:44 +00001211 regfree(bob->end);
1212 free(bob->end);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001213 free(bob);
1214 }
1215 syntaxes = syntaxes->next;
1216 free(bill);
1217 }
1218#endif /* ENABLE_COLOR */
Chris Allegretta5beed502003-01-05 20:41:21 +00001219#ifndef NANO_SMALL
1220 /* free history lists */
1221 free_history(&search_history);
1222 free_history(&replace_history);
1223#endif
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001224#ifdef ENABLE_NANORC
1225 free(homedir);
1226#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001227}
Chris Allegretta6232d662002-05-12 19:52:15 +00001228#endif /* DEBUG */