blob: b0eea24fe7c8b2973a1f5bbc1421aeb423d6ed8c [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 Ramseyc13b7f02005-01-01 07:28:15 +00005 * Copyright (C) 1999-2005 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 * *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000011 * This program is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * General Public License for more details. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000015 * *
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 *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
19 * 02110-1301, USA. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000020 * *
21 **************************************************************************/
22
Jordi Mallach55381aa2004-11-17 23:17:05 +000023#ifdef HAVE_CONFIG_H
24#include <config.h>
25#endif
Chris Allegretta6efda542001-04-28 18:03:52 +000026
Chris Allegretta1dd0bc92002-10-13 18:43:45 +000027#include <stdlib.h>
Chris Allegrettadab017e2002-04-23 10:56:06 +000028#include <assert.h>
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000029#include "proto.h"
30
Chris Allegretta7662c862003-01-13 01:35:15 +000031/* Global variables */
Chris Allegretta48b06702002-02-22 04:30:50 +000032
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000033#ifndef DISABLE_WRAPJUSTIFY
David Lawrence Ramsey49c3f242004-07-12 16:07:14 +000034/* wrap_at might be set in rcfile.c or nano.c. */
35ssize_t wrap_at = -CHARS_FROM_EOL; /* Right justified fill value,
36 allows resize */
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000037#endif
38
Chris Allegretta6df90f52002-07-19 01:08:59 +000039char *last_search = NULL; /* Last string we searched for */
40char *last_replace = NULL; /* Last replacement string */
41int search_last_line; /* Is this the last search line? */
42
David Lawrence Ramsey23c44502005-01-27 20:49:07 +000043unsigned long flags = 0; /* Our flag containing many options */
David Lawrence Ramsey637b8bb2005-01-17 05:06:55 +000044WINDOW *topwin; /* Top buffer */
David Lawrence Ramseyf21cd102002-06-13 00:40:19 +000045WINDOW *edit; /* The file portion of the editor */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000046WINDOW *bottomwin; /* Bottom buffer */
Chris Allegretta1a6e9042000-12-14 13:56:28 +000047char *filename = NULL; /* Name of the file */
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +000048
49#ifndef NANO_SMALL
50struct stat originalfilestat; /* Stat for the file as we loaded it */
51#endif
52
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000053int editwinrows = 0; /* How many rows long is the edit
54 window? */
55filestruct *current; /* Current buffer pointer */
David Lawrence Ramsey7a97e182004-10-30 01:03:15 +000056size_t current_x = 0; /* Current x-coordinate in the edit
57 window */
58int current_y = 0; /* Current y-coordinate in the edit
59 window */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000060filestruct *fileage = NULL; /* Our file buffer */
61filestruct *edittop = NULL; /* Pointer to the top of the edit
62 buffer with respect to the
63 file struct */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000064filestruct *filebot = NULL; /* Last node in the file struct */
65filestruct *cutbuffer = NULL; /* A place to store cut text */
David Lawrence Ramsey93c84052004-11-23 04:08:28 +000066#ifndef DISABLE_JUSTIFY
67filestruct *jusbuffer = NULL; /* A place to store unjustified text */
68#endif
David Lawrence Ramsey40bdb682004-11-03 22:03:41 +000069partition *filepart = NULL; /* A place to store a portion of the
70 file struct */
David Lawrence Ramsey40bdb682004-11-03 22:03:41 +000071
Chris Allegretta355fbe52001-07-14 19:32:47 +000072#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey3ece0b92004-12-01 15:11:27 +000073openfilestruct *open_files = NULL; /* The list of open file
74 buffers */
Chris Allegretta2d7893d2001-07-11 02:08:33 +000075#endif
76
David Lawrence Ramsey89bb9372004-05-29 16:47:52 +000077#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
78char *whitespace = NULL; /* Characters used when displaying
79 the first characters of tabs and
80 spaces. */
David Lawrence Ramsey6e60db62005-03-10 22:52:21 +000081int whitespace_len[2]; /* The length of the characters. */
David Lawrence Ramsey89bb9372004-05-29 16:47:52 +000082#endif
83
Chris Allegrettae4f940d2002-03-03 22:36:36 +000084#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey2c62b072004-05-29 16:38:57 +000085char *punct = NULL; /* Closing punctuation that can end
86 sentences. */
87char *brackets = NULL; /* Closing brackets that can follow
88 closing punctuation and can end
89 sentences. */
Chris Allegretta7662c862003-01-13 01:35:15 +000090char *quotestr = NULL; /* Quote string. The default value is
91 set in main(). */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +000092#ifdef HAVE_REGEX_H
93regex_t quotereg; /* Compiled quotestr regular expression. */
94int quoterc; /* Did it compile? */
95char *quoteerr = NULL; /* The error message. */
96#else
97size_t quotelen; /* strlen(quotestr) */
98#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +000099#endif
Chris Allegrettae4f940d2002-03-03 22:36:36 +0000100
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000101#ifndef NANO_SMALL
102char *backup_dir = NULL; /* Backup directory. */
103#endif
104
Chris Allegretta6df90f52002-07-19 01:08:59 +0000105char *answer = NULL; /* Answer str to many questions */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000106int totlines = 0; /* Total number of lines in the file */
David Lawrence Ramsey23c44502005-01-27 20:49:07 +0000107size_t totsize = 0; /* Total number of characters in the
108 file */
David Lawrence Ramsey86e851b2004-07-28 20:46:25 +0000109size_t placewewant = 0; /* The column we'd like the cursor
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000110 to jump to when we go to the
111 next or previous line */
112
David Lawrence Ramsey49c3f242004-07-12 16:07:14 +0000113ssize_t tabsize = -1; /* Our internal tabsize variable. The
114 default value is set in main(). */
Chris Allegretta6d690a32000-08-03 22:51:21 +0000115
Chris Allegretta7662c862003-01-13 01:35:15 +0000116char *hblank = NULL; /* A horizontal blank line */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000117#ifndef DISABLE_HELP
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000118char *help_text; /* The text in the help window */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000119#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000120
121/* More stuff for the marker select */
122
Chris Allegretta7662c862003-01-13 01:35:15 +0000123#ifndef NANO_SMALL
David Lawrence Ramseyf28f50e2004-01-09 23:04:55 +0000124filestruct *mark_beginbuf; /* The begin marker buffer */
David Lawrence Ramsey687776b2004-10-30 01:16:08 +0000125size_t mark_beginx; /* X value in the string to start */
Chris Allegretta7662c862003-01-13 01:35:15 +0000126#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000127
Chris Allegrettae1f14522001-09-19 03:19:43 +0000128#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000129char *operating_dir = NULL; /* Operating directory, which we can't */
130char *full_operating_dir = NULL;/* go higher than */
Chris Allegrettae1f14522001-09-19 03:19:43 +0000131#endif
132
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000133#ifndef DISABLE_SPELLER
Chris Allegretta7c27be42002-05-05 23:03:54 +0000134char *alt_speller = NULL; /* Alternative spell command */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000135#endif
136
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000137shortcut *main_list = NULL;
138shortcut *whereis_list = NULL;
139shortcut *replace_list = NULL;
Chris Allegretta48b06702002-02-22 04:30:50 +0000140shortcut *replace_list_2 = NULL; /* 2nd half of replace dialog */
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000141shortcut *gotoline_list = NULL;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000142shortcut *writefile_list = NULL;
143shortcut *insertfile_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000144#ifndef DISABLE_HELP
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000145shortcut *help_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000146#endif
147#ifndef DISABLE_SPELLER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000148shortcut *spell_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000149#endif
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000150#ifndef NANO_SMALL
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000151shortcut *extcmd_list = NULL;
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000152#endif
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000153#ifndef DISABLE_BROWSER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000154shortcut *browser_list = NULL;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000155shortcut *gotodir_list = NULL;
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000156#endif
Chris Allegretta201f1d92003-02-05 02:51:19 +0000157
Chris Allegretta8ce24132001-04-30 11:28:46 +0000158#ifdef ENABLE_COLOR
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000159const colortype *colorstrings = NULL;
160syntaxtype *syntaxes = NULL;
161char *syntaxstr = NULL;
Chris Allegretta8ce24132001-04-30 11:28:46 +0000162#endif
163
Chris Allegretta6df90f52002-07-19 01:08:59 +0000164const shortcut *currshortcut; /* Current shortcut list we're using */
Chris Allegretta6b58acd2001-04-12 03:01:53 +0000165
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000166#ifndef NANO_SMALL
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000167toggle *toggles = NULL;
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000168#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000169
David Lawrence Ramsey1addd602005-06-03 19:28:30 +0000170#ifndef NANO_SMALL
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000171filestruct *search_history = NULL;
172filestruct *searchage = NULL;
173filestruct *searchbot = NULL;
174filestruct *replace_history = NULL;
175filestruct *replaceage = NULL;
176filestruct *replacebot = NULL;
Chris Allegretta5beed502003-01-05 20:41:21 +0000177#endif
178
Chris Allegretta9fc8d432000-07-07 01:49:52 +0000179/* Regular expressions */
Chris Allegretta805c26d2000-09-06 13:39:17 +0000180#ifdef HAVE_REGEX_H
Chris Allegrettabd9e7c32000-10-26 01:44:42 +0000181regex_t search_regexp; /* Global to store compiled search regexp */
182regmatch_t regmatches[10]; /* Match positions for parenthetical
183 subexpressions, max of 10 */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000184#endif
Chris Allegretta3533a342002-03-24 23:19:32 +0000185
David Lawrence Ramsey82dc1c12004-08-12 03:27:54 +0000186bool curses_ended = FALSE; /* Indicates to statusbar() to simply
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000187 * write to stderr, since endwin() has
188 * ended curses mode. */
189
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000190char *homedir = NULL; /* $HOME or from /etc/passwd. */
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000191
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000192size_t length_of_list(const shortcut *s)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000193{
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000194 size_t i = 0;
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000195
Chris Allegrettadab017e2002-04-23 10:56:06 +0000196 for (; s != NULL; s = s->next)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000197 i++;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000198 return i;
199}
200
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000201/* Initialize a struct *without* our lovely braces =( */
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000202void sc_init_one(shortcut **shortcutage, int ctrlval, const char *desc,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000203#ifndef DISABLE_HELP
Chris Allegrettaf717f982003-02-13 22:25:01 +0000204 const char *help,
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000205#endif
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000206 int metaval, int funcval, int miscval, bool view, void
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000207 (*func)(void))
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000208{
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000209 shortcut *s;
210
211 if (*shortcutage == NULL) {
David Lawrence Ramsey70047ee2003-06-14 20:41:34 +0000212 *shortcutage = (shortcut *)nmalloc(sizeof(shortcut));
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000213 s = *shortcutage;
214 } else {
215 for (s = *shortcutage; s->next != NULL; s = s->next)
216 ;
David Lawrence Ramsey70047ee2003-06-14 20:41:34 +0000217 s->next = (shortcut *)nmalloc(sizeof(shortcut));
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000218 s = s->next;
219 }
220
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000221 s->ctrlval = ctrlval;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000222 s->desc = _(desc);
Chris Allegrettadab017e2002-04-23 10:56:06 +0000223#ifndef DISABLE_HELP
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000224 s->help = _(help);
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000225#endif
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000226 s->metaval = metaval;
227 s->funcval = funcval;
228 s->miscval = miscval;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000229 s->viewok = view;
230 s->func = func;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000231 s->next = NULL;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000232}
233
David Lawrence Ramsey1f1ebb82004-11-11 21:50:01 +0000234void shortcut_init(bool unjustify)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000235{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000236 const char *get_help_msg = N_("Get Help");
237 const char *exit_msg = N_("Exit");
238 const char *prev_page_msg = N_("Prev Page");
239 const char *next_page_msg = N_("Next Page");
240 const char *replace_msg = N_("Replace");
241 const char *go_to_line_msg = N_("Go To Line");
242 const char *cancel_msg = N_("Cancel");
243 const char *first_line_msg = N_("First Line");
244 const char *last_line_msg = N_("Last Line");
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000245#ifndef NANO_SMALL
246 const char *cut_till_end_msg = N_("CutTillEnd");
247#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000248#ifndef DISABLE_JUSTIFY
249 const char *beg_of_par_msg = N_("Beg of Par");
250 const char *end_of_par_msg = N_("End of Par");
251 const char *fulljstify_msg = N_("FullJstify");
252#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000253#ifndef NANO_SMALL
254 const char *case_sens_msg = N_("Case Sens");
255 const char *direction_msg = N_("Direction");
256#ifdef HAVE_REGEX_H
257 const char *regexp_msg = N_("Regexp");
258#endif
David Lawrence Ramsey5e73eec2005-05-03 20:57:13 +0000259 const char *history_msg = N_("History");
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000260#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey04a8d1c2004-09-28 22:14:58 +0000261 const char *new_buffer_msg = N_("New Buffer");
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000262#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000263#endif /* !NANO_SMALL */
264#ifndef DISABLE_BROWSER
265 const char *to_files_msg = N_("To Files");
266#endif
267
Chris Allegrettadab017e2002-04-23 10:56:06 +0000268#ifndef DISABLE_HELP
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000269 const char *nano_help_msg = N_("Invoke the help menu");
270 const char *nano_exit_msg =
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000271#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000272 N_("Close currently loaded file/Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000273#else
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000274 N_("Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000275#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000276 ;
277 const char *nano_writeout_msg = N_("Write the current file to disk");
278 const char *nano_justify_msg = N_("Justify the current paragraph");
279 const char *nano_insert_msg =
280 N_("Insert another file into the current one");
281 const char *nano_whereis_msg = N_("Search for text within the editor");
282 const char *nano_prevpage_msg = N_("Move to the previous screen");
283 const char *nano_nextpage_msg = N_("Move to the next screen");
284 const char *nano_cut_msg =
285 N_("Cut the current line and store it in the cutbuffer");
286 const char *nano_uncut_msg =
287 N_("Uncut from the cutbuffer into the current line");
288 const char *nano_cursorpos_msg = N_("Show the position of the cursor");
289 const char *nano_spell_msg = N_("Invoke the spell checker, if available");
David Lawrence Ramseyd3d37432005-05-17 21:49:19 +0000290 const char *nano_gotoline_msg =
291 N_("Go to a specific line number and column number");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000292 const char *nano_replace_msg = N_("Replace text within the editor");
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000293#ifndef NANO_SMALL
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000294 const char *nano_mark_msg = N_("Mark text at the cursor position");
295 const char *nano_whereis_next_msg = N_("Repeat last search");
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000296#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000297 const char *nano_prevline_msg = N_("Move to the previous line");
298 const char *nano_nextline_msg = N_("Move to the next line");
299 const char *nano_forward_msg = N_("Move forward one character");
300 const char *nano_back_msg = N_("Move back one character");
301 const char *nano_home_msg = N_("Move to the beginning of the current line");
302 const char *nano_end_msg = N_("Move to the end of the current line");
303 const char *nano_refresh_msg = N_("Refresh (redraw) the current screen");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000304 const char *nano_delete_msg = N_("Delete the character under the cursor");
305 const char *nano_backspace_msg =
306 N_("Delete the character to the left of the cursor");
David Lawrence Ramseye7c41682004-10-23 14:53:07 +0000307 const char *nano_tab_msg =
308 N_("Insert a tab character at the cursor position");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000309 const char *nano_enter_msg =
310 N_("Insert a carriage return at the cursor position");
David Lawrence Ramsey00d77982004-08-07 21:27:37 +0000311#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000312 const char *nano_nextword_msg = N_("Move forward one word");
313 const char *nano_prevword_msg = N_("Move backward one word");
David Lawrence Ramsey00d77982004-08-07 21:27:37 +0000314#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000315#ifndef DISABLE_JUSTIFY
316 const char *nano_parabegin_msg =
317 N_("Go to the beginning of the current paragraph");
318 const char *nano_paraend_msg =
319 N_("Go to the end of the current paragraph");
320#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000321#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000322 const char *nano_openprev_msg = N_("Switch to the previous file buffer");
323 const char *nano_opennext_msg = N_("Switch to the next file buffer");
324#endif
325 const char *nano_verbatim_msg = N_("Insert character(s) verbatim");
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000326#ifndef NANO_SMALL
327 const char *nano_cut_till_end_msg =
328 N_("Cut from the cursor position to the end of the file");
329#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000330#ifndef DISABLE_JUSTIFY
331 const char *nano_fulljustify_msg = N_("Justify the entire file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000332#endif
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000333#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000334 const char *nano_bracket_msg = N_("Find other bracket");
335#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000336 const char *nano_cancel_msg = N_("Cancel the current function");
337 const char *nano_firstline_msg = N_("Go to the first line of the file");
338 const char *nano_lastline_msg = N_("Go to the last line of the file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000339#ifndef NANO_SMALL
340 const char *nano_case_msg =
341 N_("Make the current search/replace case (in)sensitive");
342 const char *nano_reverse_msg =
343 N_("Make the current search/replace go backwards");
344#ifdef HAVE_REGEX_H
345 const char *nano_regexp_msg = N_("Use regular expressions");
346#endif
David Lawrence Ramsey5e73eec2005-05-03 20:57:13 +0000347 const char *nano_history_msg =
348 N_("Edit the previous search/replace strings");
David Lawrence Ramsey8e156742005-06-03 19:11:27 +0000349#endif /* !NANO_SMALL */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000350
351#ifndef DISABLE_BROWSER
352 const char *nano_tofiles_msg = N_("Go to file browser");
353#endif
354#ifndef NANO_SMALL
355 const char *nano_dos_msg = N_("Write file out in DOS format");
356 const char *nano_mac_msg = N_("Write file out in Mac format");
357#endif
358 const char *nano_append_msg = N_("Append to the current file");
359 const char *nano_prepend_msg = N_("Prepend to the current file");
360#ifndef NANO_SMALL
361 const char *nano_backup_msg = N_("Back up original file when saving");
362 const char *nano_execute_msg = N_("Execute external command");
363#endif
David Lawrence Ramseyad96aff2005-02-22 23:22:37 +0000364#if !defined(NANO_SMALL) && defined(ENABLE_MULTIBUFFER)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000365 const char *nano_multibuffer_msg = N_("Insert into new buffer");
366#endif
367#ifndef DISABLE_BROWSER
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000368 const char *nano_exitbrowser_msg = N_("Exit from the file browser");
369 const char *nano_gotodir_msg = N_("Go to directory");
Chris Allegretta2bef1822001-09-28 19:53:11 +0000370#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000371#endif /* !DISABLE_HELP */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000372
David Lawrence Ramsey8e4adcd2004-05-20 03:29:33 +0000373/* The following macro is to be used in calling sc_init_one(). The
374 * point is that sc_init_one() takes 9 arguments, unless DISABLE_HELP is
375 * defined, when the 4th one should not be there. */
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000376#ifndef DISABLE_HELP
David Lawrence Ramseyeb509222005-03-22 04:50:11 +0000377#define IFHELP(help, nextvar) help, nextvar
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000378#else
David Lawrence Ramseyeb509222005-03-22 04:50:11 +0000379#define IFHELP(help, nextvar) nextvar
Chris Allegrettadab017e2002-04-23 10:56:06 +0000380#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000381
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000382 free_shortcutage(&main_list);
383
Jordi Mallachf9390af2003-08-05 19:31:12 +0000384 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000385 sc_init_one(&main_list, NANO_HELP_KEY, get_help_msg,
386 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
387 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000388#ifndef DISABLE_HELP
389 do_help
390#else
391 nano_disabled_msg
392#endif
393 );
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000394
David Lawrence Ramsey5b3dd0f2004-11-25 04:39:07 +0000395 /* Translators: try to keep this string under 10 characters long */
396 sc_init_one(&main_list, NANO_EXIT_KEY,
Chris Allegretta355fbe52001-07-14 19:32:47 +0000397#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey5b3dd0f2004-11-25 04:39:07 +0000398 open_files != NULL && open_files != open_files->next ?
399 N_("Close") :
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000400#endif
David Lawrence Ramsey5b3dd0f2004-11-25 04:39:07 +0000401 exit_msg, IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
402 NANO_NO_KEY, VIEW, do_exit);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000403
Jordi Mallachf9390af2003-08-05 19:31:12 +0000404 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000405 sc_init_one(&main_list, NANO_WRITEOUT_KEY, N_("WriteOut"),
406 IFHELP(nano_writeout_msg, NANO_NO_KEY), NANO_WRITEOUT_FKEY,
407 NANO_NO_KEY, NOVIEW, do_writeout_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000408
Jordi Mallachf9390af2003-08-05 19:31:12 +0000409 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000410 sc_init_one(&main_list, NANO_JUSTIFY_KEY, N_("Justify"),
411 IFHELP(nano_justify_msg, NANO_NO_KEY),
412 NANO_JUSTIFY_FKEY, NANO_NO_KEY, NOVIEW,
David Lawrence Ramseya539fce2004-06-29 00:43:56 +0000413#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey8d3e7f32004-05-13 17:28:03 +0000414 do_justify_void
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000415#else
416 nano_disabled_msg
417#endif
418 );
Chris Allegretta32da4562002-01-02 15:12:21 +0000419
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000420 /* We allow inserting files in view mode if multibuffers are
421 * available, so that we can view multiple files. */
422 /* If we're using restricted mode, inserting files is disabled since
423 * it allows reading from or writing to files not specified on the
424 * command line. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000425 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000426 sc_init_one(&main_list, NANO_INSERTFILE_KEY, N_("Read File"),
427 IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_INSERTFILE_FKEY,
428 NANO_NO_KEY,
Chris Allegretta32da4562002-01-02 15:12:21 +0000429#ifdef ENABLE_MULTIBUFFER
Chris Allegrettad8451932003-03-11 03:50:40 +0000430 VIEW
Chris Allegretta32da4562002-01-02 15:12:21 +0000431#else
Chris Allegrettad8451932003-03-11 03:50:40 +0000432 NOVIEW
Chris Allegretta32da4562002-01-02 15:12:21 +0000433#endif
David Lawrence Ramsey8001e272004-11-12 00:48:18 +0000434 , !ISSET(RESTRICTED) ? do_insertfile_void :
435 nano_disabled_msg);
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000436
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_WHEREIS_KEY, N_("Where Is"),
439 IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_WHEREIS_FKEY,
440 NANO_NO_KEY, VIEW, do_search);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000441
Jordi Mallachf9390af2003-08-05 19:31:12 +0000442 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000443 sc_init_one(&main_list, NANO_PREVPAGE_KEY, prev_page_msg,
444 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
445 NANO_NO_KEY, VIEW, do_page_up);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000446
Jordi Mallachf9390af2003-08-05 19:31:12 +0000447 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000448 sc_init_one(&main_list, NANO_NEXTPAGE_KEY, next_page_msg,
449 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
450 NANO_NO_KEY, VIEW, do_page_down);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000451
Jordi Mallachf9390af2003-08-05 19:31:12 +0000452 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000453 sc_init_one(&main_list, NANO_CUT_KEY, N_("Cut Text"),
454 IFHELP(nano_cut_msg, NANO_NO_KEY), NANO_CUT_FKEY,
455 NANO_NO_KEY, NOVIEW, do_cut_text);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000456
Chris Allegretta07798352000-11-27 22:58:23 +0000457 if (unjustify)
Jordi Mallachf9390af2003-08-05 19:31:12 +0000458 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000459 sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, N_("UnJustify"),
460 IFHELP(NULL, NANO_NO_KEY), NANO_UNJUSTIFY_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000461 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegretta07798352000-11-27 22:58:23 +0000462 else
Jordi Mallachf9390af2003-08-05 19:31:12 +0000463 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000464 sc_init_one(&main_list, NANO_UNCUT_KEY, N_("UnCut Txt"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000465 IFHELP(nano_uncut_msg, NANO_NO_KEY), NANO_UNCUT_FKEY,
466 NANO_NO_KEY, NOVIEW, do_uncut_text);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000467
Jordi Mallachf9390af2003-08-05 19:31:12 +0000468 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000469 sc_init_one(&main_list, NANO_CURSORPOS_KEY, N_("Cur Pos"),
470 IFHELP(nano_cursorpos_msg, NANO_NO_KEY), NANO_CURSORPOS_FKEY,
471 NANO_NO_KEY, VIEW, do_cursorpos_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000472
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000473 /* If we're using restricted mode, spell checking is disabled
474 * because it allows reading from or writing to files not specified
475 * on the command line. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000476 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000477 sc_init_one(&main_list, NANO_SPELL_KEY, N_("To Spell"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000478 IFHELP(nano_spell_msg, NANO_NO_KEY), NANO_SPELL_FKEY,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000479 NANO_NO_KEY, NOVIEW,
480#ifndef DISABLE_SPELLER
481 !ISSET(RESTRICTED) ? do_spell :
482#endif
483 nano_disabled_msg);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000484
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000485 sc_init_one(&main_list, NANO_GOTOLINE_KEY, go_to_line_msg,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000486 IFHELP(nano_gotoline_msg, NANO_GOTOLINE_ALTKEY),
David Lawrence Ramsey9245f972005-05-17 18:06:26 +0000487 NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW,
488 do_gotolinecolumn_void);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000489
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000490 sc_init_one(&main_list, NANO_REPLACE_KEY, replace_msg,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000491 IFHELP(nano_replace_msg, NANO_ALT_REPLACE_KEY),
492 NANO_REPLACE_FKEY, NANO_NO_KEY, NOVIEW, do_replace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000493
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000494#ifndef NANO_SMALL
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000495 sc_init_one(&main_list, NANO_MARK_KEY, N_("Mark Text"),
496 IFHELP(nano_mark_msg, NANO_MARK_ALTKEY), NANO_MARK_FKEY,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000497 NANO_NO_KEY, NOVIEW, do_mark);
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000498
499 sc_init_one(&main_list, NANO_NO_KEY, N_("Where Is Next"),
500 IFHELP(nano_whereis_next_msg, NANO_WHEREIS_NEXT_KEY),
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000501 NANO_WHEREIS_NEXT_FKEY, NANO_NO_KEY, VIEW, do_research);
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000502#endif
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000503
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000504 sc_init_one(&main_list, NANO_PREVLINE_KEY, N_("Prev Line"),
505 IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
506 NANO_NO_KEY, VIEW, do_up);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000507
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000508 sc_init_one(&main_list, NANO_NEXTLINE_KEY, N_("Next Line"),
509 IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
510 NANO_NO_KEY, VIEW, do_down);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000511
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000512 sc_init_one(&main_list, NANO_FORWARD_KEY, N_("Forward"),
513 IFHELP(nano_forward_msg, NANO_NO_KEY), NANO_NO_KEY,
514 NANO_NO_KEY, VIEW, do_right_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000515
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000516 sc_init_one(&main_list, NANO_BACK_KEY, N_("Back"),
517 IFHELP(nano_back_msg, NANO_NO_KEY), NANO_NO_KEY,
518 NANO_NO_KEY, VIEW, do_left_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000519
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000520 sc_init_one(&main_list, NANO_HOME_KEY, N_("Home"),
521 IFHELP(nano_home_msg, NANO_NO_KEY), NANO_NO_KEY,
522 NANO_NO_KEY, VIEW, do_home);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000523
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000524 sc_init_one(&main_list, NANO_END_KEY, N_("End"),
525 IFHELP(nano_end_msg, NANO_NO_KEY), NANO_NO_KEY,
526 NANO_NO_KEY, VIEW, do_end);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000527
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000528 sc_init_one(&main_list, NANO_REFRESH_KEY, N_("Refresh"),
529 IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
530 NANO_NO_KEY, VIEW, total_refresh);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000531
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000532 sc_init_one(&main_list, NANO_DELETE_KEY, N_("Delete"),
533 IFHELP(nano_delete_msg, NANO_NO_KEY), NANO_NO_KEY,
534 NANO_NO_KEY, NOVIEW, do_delete);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000535
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000536 sc_init_one(&main_list, NANO_BACKSPACE_KEY, N_("Backspace"),
537 IFHELP(nano_backspace_msg, NANO_NO_KEY), NANO_NO_KEY,
538 NANO_NO_KEY, NOVIEW, do_backspace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000539
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000540 sc_init_one(&main_list, NANO_TAB_KEY, N_("Tab"),
541 IFHELP(nano_tab_msg, NANO_NO_KEY), NANO_NO_KEY,
542 NANO_NO_KEY, NOVIEW, do_tab);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000543
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000544 sc_init_one(&main_list, NANO_ENTER_KEY, N_("Enter"),
545 IFHELP(nano_enter_msg, NANO_NO_KEY), NANO_NO_KEY,
546 NANO_NO_KEY, NOVIEW, do_enter);
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000547
David Lawrence Ramseyc5967552002-06-21 03:20:06 +0000548#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000549 sc_init_one(&main_list, NANO_NEXTWORD_KEY, N_("Next Word"),
550 IFHELP(nano_nextword_msg, NANO_NO_KEY), NANO_NO_KEY,
551 NANO_NO_KEY, VIEW, do_next_word);
David Lawrence Ramseyc5967552002-06-21 03:20:06 +0000552
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000553 sc_init_one(&main_list, NANO_NO_KEY, N_("Prev Word"),
554 IFHELP(nano_prevword_msg, NANO_PREVWORD_KEY), NANO_NO_KEY,
555 NANO_NO_KEY, VIEW, do_prev_word);
Chris Allegretta8d990b52001-09-22 22:14:25 +0000556#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000557
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000558#ifndef DISABLE_JUSTIFY
559 /* Translators: try to keep this string under 10 characters long */
560 sc_init_one(&main_list, NANO_NO_KEY, beg_of_par_msg,
561 IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
David Lawrence Ramseyff4a4872005-03-13 21:12:25 +0000562 NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000563
564 /* Translators: try to keep this string under 10 characters long */
565 sc_init_one(&main_list, NANO_NO_KEY, end_of_par_msg,
566 IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
David Lawrence Ramseyff4a4872005-03-13 21:12:25 +0000567 NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000568#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000569
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000570#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000571 sc_init_one(&main_list, NANO_NO_KEY, N_("Previous File"),
572 IFHELP(nano_openprev_msg, NANO_OPENPREV_KEY), NANO_NO_KEY,
573 NANO_OPENPREV_ALTKEY, VIEW, open_prevfile_void);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000574
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000575 sc_init_one(&main_list, NANO_NO_KEY, N_("Next File"),
576 IFHELP(nano_opennext_msg, NANO_OPENNEXT_KEY), NANO_NO_KEY,
577 NANO_OPENNEXT_ALTKEY, VIEW, open_nextfile_void);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000578#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +0000579
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000580 sc_init_one(&main_list, NANO_NO_KEY, N_("Verbatim Input"),
581 IFHELP(nano_verbatim_msg, NANO_VERBATIM_KEY), NANO_NO_KEY,
582 NANO_NO_KEY, NOVIEW, do_verbatim_input);
583
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000584#ifndef NANO_SMALL
585 /* Translators: try to keep this string under 10 characters long */
586 sc_init_one(&main_list, NANO_NO_KEY, cut_till_end_msg,
587 IFHELP(nano_cut_till_end_msg, NANO_CUTTILLEND_ALTKEY),
588 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end);
589#endif
590
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000591#ifndef DISABLE_JUSTIFY
592 /* Translators: try to keep this string under 10 characters long */
593 sc_init_one(&main_list, NANO_NO_KEY, fulljstify_msg,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000594 IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY),
595 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000596#endif
597
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000598#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000599 sc_init_one(&main_list, NANO_NO_KEY, N_("Find Other Bracket"),
600 IFHELP(nano_bracket_msg, NANO_BRACKET_KEY), NANO_NO_KEY,
601 NANO_NO_KEY, VIEW, do_find_bracket);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000602#endif
603
Chris Allegrettadab017e2002-04-23 10:56:06 +0000604 free_shortcutage(&whereis_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000605
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000606 sc_init_one(&whereis_list, NANO_HELP_KEY, get_help_msg,
607 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
608 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000609#ifndef DISABLE_HELP
610 do_help
611#else
612 nano_disabled_msg
613#endif
614 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000615
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000616 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000617 sc_init_one(&whereis_list, NANO_CANCEL_KEY, cancel_msg,
618 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000619 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000620
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000621 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000622 sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, first_line_msg,
623 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
624 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000625
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000626 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000627 sc_init_one(&whereis_list, NANO_LASTLINE_KEY, last_line_msg,
628 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
629 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000630
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000631 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000632 sc_init_one(&whereis_list, NANO_TOOTHERSEARCH_KEY, replace_msg,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000633 IFHELP(nano_replace_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000634 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000635
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000636 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000637 sc_init_one(&whereis_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
638 IFHELP(nano_gotoline_msg, NANO_NO_KEY), NANO_GOTOLINE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000639 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000640
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000641#ifndef DISABLE_JUSTIFY
642 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000643 sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, beg_of_par_msg,
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000644 IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
David Lawrence Ramseyff4a4872005-03-13 21:12:25 +0000645 NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000646
647 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000648 sc_init_one(&whereis_list, NANO_PARAEND_KEY, end_of_par_msg,
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000649 IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
David Lawrence Ramseyff4a4872005-03-13 21:12:25 +0000650 NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000651#endif
652
Chris Allegretta5f36c372001-07-16 00:48:53 +0000653#ifndef NANO_SMALL
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, case_sens_msg,
656 IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000657 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta658399a2001-06-14 02:54:22 +0000658
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000659 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000660 sc_init_one(&whereis_list, NANO_NO_KEY, direction_msg,
661 IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000662 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000663
Chris Allegretta658399a2001-06-14 02:54:22 +0000664#ifdef HAVE_REGEX_H
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000665 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000666 sc_init_one(&whereis_list, NANO_NO_KEY, regexp_msg,
667 IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000668 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta658399a2001-06-14 02:54:22 +0000669#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000670
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000671 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey5e73eec2005-05-03 20:57:13 +0000672 sc_init_one(&whereis_list, NANO_PREVLINE_KEY, history_msg,
673 IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000674 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000675
676 /* Translators: try to keep this string under 10 characters long */
677 sc_init_one(&whereis_list, NANO_CUTTILLEND_KEY, cut_till_end_msg,
678 IFHELP(nano_cut_till_end_msg, NANO_CUTTILLEND_ALTKEY),
679 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end);
David Lawrence Ramsey30412932004-11-23 20:42:35 +0000680#endif /* !NANO_SMALL */
David Lawrence Ramsey02085d72004-11-07 16:04:18 +0000681
682#ifndef DISABLE_JUSTIFY
683 /* Translators: try to keep this string under 10 characters long */
684 sc_init_one(&whereis_list, NANO_FULLJUSTIFY_KEY, fulljstify_msg,
685 IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY),
686 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
687#endif
Chris Allegretta5f36c372001-07-16 00:48:53 +0000688
Chris Allegrettadab017e2002-04-23 10:56:06 +0000689 free_shortcutage(&replace_list);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000690
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000691 sc_init_one(&replace_list, NANO_HELP_KEY, get_help_msg,
692 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
693 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000694#ifndef DISABLE_HELP
695 do_help
696#else
697 nano_disabled_msg
698#endif
699 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000700
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000701 sc_init_one(&replace_list, NANO_CANCEL_KEY, cancel_msg,
702 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000703 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta5f36c372001-07-16 00:48:53 +0000704
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000705 sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, first_line_msg,
706 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
707 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000708
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000709 sc_init_one(&replace_list, NANO_LASTLINE_KEY, last_line_msg,
710 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
711 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000712
David Lawrence Ramsey5e73eec2005-05-03 20:57:13 +0000713 /* Translators: try to keep this string under 12 characters long */
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000714 sc_init_one(&replace_list, NANO_TOOTHERSEARCH_KEY, N_("No Replace"),
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000715 IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000716 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000717
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000718 sc_init_one(&replace_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
719 IFHELP(nano_gotoline_msg, NANO_NO_KEY), NANO_GOTOLINE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000720 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000721
Chris Allegretta5f36c372001-07-16 00:48:53 +0000722#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000723 sc_init_one(&replace_list, NANO_NO_KEY, case_sens_msg,
724 IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000725 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta658399a2001-06-14 02:54:22 +0000726
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000727 sc_init_one(&replace_list, NANO_NO_KEY, direction_msg,
728 IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000729 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta105da332000-10-31 05:10:10 +0000730
Chris Allegretta658399a2001-06-14 02:54:22 +0000731#ifdef HAVE_REGEX_H
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000732 sc_init_one(&replace_list, NANO_NO_KEY, regexp_msg,
733 IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000734 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta658399a2001-06-14 02:54:22 +0000735#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000736
David Lawrence Ramsey5e73eec2005-05-03 20:57:13 +0000737 sc_init_one(&replace_list, NANO_PREVLINE_KEY, history_msg,
738 IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000739 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000740#endif /* !NANO_SMALL */
Chris Allegretta5f36c372001-07-16 00:48:53 +0000741
Chris Allegrettadab017e2002-04-23 10:56:06 +0000742 free_shortcutage(&replace_list_2);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000743
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000744 sc_init_one(&replace_list_2, NANO_HELP_KEY, get_help_msg,
745 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
746 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000747#ifndef DISABLE_HELP
748 do_help
749#else
750 nano_disabled_msg
751#endif
752 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000753
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000754 sc_init_one(&replace_list_2, NANO_CANCEL_KEY, cancel_msg,
755 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000756 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta105da332000-10-31 05:10:10 +0000757
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000758 sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, first_line_msg,
759 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
760 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta105da332000-10-31 05:10:10 +0000761
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000762 sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, last_line_msg,
763 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
764 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta105da332000-10-31 05:10:10 +0000765
David Lawrence Ramsey1addd602005-06-03 19:28:30 +0000766#ifndef NANO_SMALL
David Lawrence Ramsey5e73eec2005-05-03 20:57:13 +0000767 sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, history_msg,
768 IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000769 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta5beed502003-01-05 20:41:21 +0000770#endif
771
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000772 free_shortcutage(&gotoline_list);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000773
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000774 sc_init_one(&gotoline_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000775 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
776 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000777#ifndef DISABLE_HELP
778 do_help
779#else
780 nano_disabled_msg
781#endif
782 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000783
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000784 sc_init_one(&gotoline_list, NANO_CANCEL_KEY, cancel_msg,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000785 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000786 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000787
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000788 sc_init_one(&gotoline_list, NANO_FIRSTLINE_KEY, first_line_msg,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000789 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
790 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000791
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000792 sc_init_one(&gotoline_list, NANO_LASTLINE_KEY, last_line_msg,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000793 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
794 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000795
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000796 sc_init_one(&gotoline_list, NANO_TOOTHERWHEREIS_KEY,
797 N_("Go To Text"), IFHELP(nano_whereis_msg, NANO_NO_KEY),
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000798 NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000799
Chris Allegretta7662c862003-01-13 01:35:15 +0000800#ifndef DISABLE_HELP
Chris Allegrettadab017e2002-04-23 10:56:06 +0000801 free_shortcutage(&help_list);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000802
David Lawrence Ramsey64393302005-04-25 21:48:22 +0000803 sc_init_one(&help_list, NANO_REFRESH_KEY, N_("Refresh"),
804 IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
805 NANO_NO_KEY, VIEW, NULL);
806
807 sc_init_one(&help_list, NANO_EXIT_KEY, exit_msg,
808 IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
809 NANO_NO_KEY, VIEW, NULL);
810
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000811 sc_init_one(&help_list, NANO_PREVPAGE_KEY, prev_page_msg,
812 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000813 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000814
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000815 sc_init_one(&help_list, NANO_NEXTPAGE_KEY, next_page_msg,
816 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000817 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramseybe265612004-05-29 20:38:08 +0000818
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000819 sc_init_one(&help_list, NANO_PREVLINE_KEY, N_("Prev Line"),
820 IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000821 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramseybe265612004-05-29 20:38:08 +0000822
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000823 sc_init_one(&help_list, NANO_NEXTLINE_KEY, N_("Next Line"),
824 IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000825 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta7662c862003-01-13 01:35:15 +0000826#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000827
Chris Allegrettadab017e2002-04-23 10:56:06 +0000828 free_shortcutage(&writefile_list);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000829
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000830 sc_init_one(&writefile_list, NANO_HELP_KEY, get_help_msg,
831 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
832 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000833#ifndef DISABLE_HELP
834 do_help
835#else
836 nano_disabled_msg
837#endif
838 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000839
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000840 sc_init_one(&writefile_list, NANO_CANCEL_KEY, cancel_msg,
841 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000842 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000843
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000844#ifndef DISABLE_BROWSER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000845 /* If we're using restricted mode, the file browser is disabled.
846 * It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000847 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000848 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000849 sc_init_one(&writefile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000850 IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000851 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000852#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000853
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000854#ifndef NANO_SMALL
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000855 /* If we're using restricted mode, the DOS format, Mac format,
856 * append, prepend, and backup toggles are disabled. The first and
857 * second are useless since inserting files is disabled, the third
858 * and fourth are disabled because they allow writing to files not
859 * specified on the command line, and the fifth is useless since
860 * backups are disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000861 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000862 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000863 sc_init_one(&writefile_list, NANO_NO_KEY, N_("DOS Format"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000864 IFHELP(nano_dos_msg, TOGGLE_DOS_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000865 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000866
Jordi Mallachf9390af2003-08-05 19:31:12 +0000867 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000868 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000869 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Mac Format"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000870 IFHELP(nano_mac_msg, TOGGLE_MAC_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000871 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000872#endif
873
Jordi Mallachf9390af2003-08-05 19:31:12 +0000874 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000875 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000876 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Append"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000877 IFHELP(nano_append_msg, NANO_APPEND_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000878 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000879
Jordi Mallachf9390af2003-08-05 19:31:12 +0000880 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000881 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000882 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Prepend"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000883 IFHELP(nano_prepend_msg, NANO_PREPEND_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000884 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000885
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000886#ifndef NANO_SMALL
Jordi Mallachf9390af2003-08-05 19:31:12 +0000887 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000888 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000889 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Backup File"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000890 IFHELP(nano_backup_msg, TOGGLE_BACKUP_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000891 NANO_NO_KEY, NOVIEW, NULL);
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000892#endif
893
Chris Allegrettadab017e2002-04-23 10:56:06 +0000894 free_shortcutage(&insertfile_list);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000895
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000896 sc_init_one(&insertfile_list, NANO_HELP_KEY, get_help_msg,
897 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
898 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000899#ifndef DISABLE_HELP
900 do_help
901#else
902 nano_disabled_msg
903#endif
904 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000905
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000906 sc_init_one(&insertfile_list, NANO_CANCEL_KEY, cancel_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000907 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000908 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000909
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000910#ifndef DISABLE_BROWSER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000911 /* If we're using restricted mode, the file browser is disabled.
912 * It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000913 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000914 sc_init_one(&insertfile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000915 IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000916 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000917#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000918
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000919#ifndef NANO_SMALL
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000920 /* If we're using restricted mode, command execution is disabled.
921 * It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000922 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000923 if (!ISSET(RESTRICTED))
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000924 sc_init_one(&insertfile_list, NANO_TOOTHERINSERT_KEY,
925 N_("Execute Command"), IFHELP(nano_execute_msg,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000926 NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000927
Chris Allegrettaf7c68112002-09-03 22:58:40 +0000928#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000929 /* If we're using restricted mode, the multibuffer toggle is
930 * disabled. It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000931 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000932 if (!ISSET(RESTRICTED))
David Lawrence Ramsey04a8d1c2004-09-28 22:14:58 +0000933 sc_init_one(&insertfile_list, NANO_NO_KEY, new_buffer_msg,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000934 IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY),
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000935 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettaf7c68112002-09-03 22:58:40 +0000936#endif
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000937#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000938
Chris Allegretta7662c862003-01-13 01:35:15 +0000939#ifndef DISABLE_SPELLER
Chris Allegrettadab017e2002-04-23 10:56:06 +0000940 free_shortcutage(&spell_list);
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000941
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000942 sc_init_one(&spell_list, NANO_HELP_KEY, get_help_msg,
943 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
944 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000945#ifndef DISABLE_HELP
946 do_help
947#else
948 nano_disabled_msg
949#endif
950 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000951
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000952 sc_init_one(&spell_list, NANO_CANCEL_KEY, cancel_msg,
953 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000954 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta7662c862003-01-13 01:35:15 +0000955#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000956
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000957#ifndef NANO_SMALL
Chris Allegrettadab017e2002-04-23 10:56:06 +0000958 free_shortcutage(&extcmd_list);
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000959
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000960 sc_init_one(&extcmd_list, NANO_HELP_KEY, get_help_msg,
961 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
962 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000963#ifndef DISABLE_HELP
964 do_help
965#else
966 nano_disabled_msg
967#endif
968 );
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000969
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000970 sc_init_one(&extcmd_list, NANO_CANCEL_KEY, cancel_msg,
971 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000972 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramsey04a8d1c2004-09-28 22:14:58 +0000973
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000974 sc_init_one(&extcmd_list, NANO_TOOTHERINSERT_KEY, N_("Insert File"),
975 IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000976 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000977
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000978#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey04a8d1c2004-09-28 22:14:58 +0000979 sc_init_one(&extcmd_list, NANO_NO_KEY, new_buffer_msg,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000980 IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY),
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000981 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000982#endif
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000983#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000984
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000985#ifndef DISABLE_BROWSER
Chris Allegrettadab017e2002-04-23 10:56:06 +0000986 free_shortcutage(&browser_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000987
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000988 sc_init_one(&browser_list, NANO_HELP_KEY, get_help_msg,
989 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
990 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000991#ifndef DISABLE_HELP
992 do_help
993#else
994 nano_disabled_msg
995#endif
996 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000997
David Lawrence Ramsey8037fe02004-07-23 12:30:40 +0000998 sc_init_one(&browser_list, NANO_EXIT_KEY, exit_msg,
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000999 IFHELP(nano_exitbrowser_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001000 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettab3655b42001-10-22 03:15:31 +00001001
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001002 sc_init_one(&browser_list, NANO_PREVPAGE_KEY, prev_page_msg,
1003 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001004 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaf4b96012001-01-03 07:11:47 +00001005
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001006 sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, next_page_msg,
1007 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001008 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaf4b96012001-01-03 07:11:47 +00001009
David Lawrence Ramseyb349c802005-03-17 19:10:29 +00001010 sc_init_one(&browser_list, NANO_REFRESH_KEY, N_("Refresh"),
1011 IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
1012 NANO_NO_KEY, VIEW, NULL);
1013
Jordi Mallachf9390af2003-08-05 19:31:12 +00001014 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +00001015 sc_init_one(&browser_list, NANO_GOTOLINE_KEY, N_("Go To Dir"),
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +00001016 IFHELP(nano_gotodir_msg, NANO_GOTOLINE_ALTKEY),
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001017 NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW, NULL);
Rocco Corsi12f294c2001-04-14 06:50:24 +00001018
Chris Allegrettadab017e2002-04-23 10:56:06 +00001019 free_shortcutage(&gotodir_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001020
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001021 sc_init_one(&gotodir_list, NANO_HELP_KEY, get_help_msg,
1022 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
1023 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +00001024#ifndef DISABLE_HELP
1025 do_help
1026#else
1027 nano_disabled_msg
1028#endif
1029 );
Chris Allegrettaf4b96012001-01-03 07:11:47 +00001030
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001031 sc_init_one(&gotodir_list, NANO_CANCEL_KEY, cancel_msg,
1032 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001033 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaf4b96012001-01-03 07:11:47 +00001034#endif
1035
Chris Allegrettaa8c22572002-02-15 19:17:02 +00001036 currshortcut = main_list;
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001037
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001038#ifndef NANO_SMALL
Chris Allegrettadab017e2002-04-23 10:56:06 +00001039 toggle_init();
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001040#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +00001041}
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001042
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001043/* Deallocate the given shortcut. */
1044void free_shortcutage(shortcut **shortcutage)
1045{
1046 assert(shortcutage != NULL);
1047 while (*shortcutage != NULL) {
1048 shortcut *ps = *shortcutage;
1049 *shortcutage = (*shortcutage)->next;
1050 free(ps);
1051 }
1052}
1053
1054#ifndef NANO_SMALL
1055/* Create one new toggle structure, at the end of the toggles linked
1056 * list. */
1057void toggle_init_one(int val, const char *desc, long flag)
1058{
1059 toggle *u;
1060
1061 if (toggles == NULL) {
David Lawrence Ramsey94b975c2004-07-20 12:57:34 +00001062 toggles = (toggle *)nmalloc(sizeof(toggle));
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001063 u = toggles;
1064 } else {
1065 for (u = toggles; u->next != NULL; u = u->next)
1066 ;
David Lawrence Ramsey94b975c2004-07-20 12:57:34 +00001067 u->next = (toggle *)nmalloc(sizeof(toggle));
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001068 u = u->next;
1069 }
1070
1071 u->val = val;
1072 u->desc = _(desc);
1073 u->flag = flag;
1074 u->next = NULL;
1075}
1076
1077void toggle_init(void)
1078{
1079 /* There is no need to reinitialize the toggles. They can't
1080 * change. */
1081 if (toggles != NULL)
1082 return;
1083
1084 toggle_init_one(TOGGLE_NOHELP_KEY, N_("Help mode"), NO_HELP);
1085#ifdef ENABLE_MULTIBUFFER
1086 /* If we're using restricted mode, the multibuffer toggle is
1087 * disabled. It's useless since inserting files is disabled. */
1088 if (!ISSET(RESTRICTED))
David Lawrence Ramsey637b8bb2005-01-17 05:06:55 +00001089 toggle_init_one(TOGGLE_MULTIBUFFER_KEY,
1090 N_("Multiple file buffers"), MULTIBUFFER);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001091#endif
1092 toggle_init_one(TOGGLE_CONST_KEY, N_("Constant cursor position"),
1093 CONSTUPDATE);
David Lawrence Ramsey637b8bb2005-01-17 05:06:55 +00001094 toggle_init_one(TOGGLE_AUTOINDENT_KEY, N_("Auto indent"),
1095 AUTOINDENT);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001096#ifndef DISABLE_WRAPPING
1097 toggle_init_one(TOGGLE_WRAP_KEY, N_("Auto line wrap"), NO_WRAP);
1098#endif
1099 toggle_init_one(TOGGLE_CUTTOEND_KEY, N_("Cut to end"), CUT_TO_END);
1100 /* If we're using restricted mode, the suspend toggle is disabled.
1101 * It's useless since suspending is disabled. */
1102 if (!ISSET(RESTRICTED))
1103 toggle_init_one(TOGGLE_SUSPEND_KEY, N_("Suspend"), SUSPEND);
1104#ifndef DISABLE_MOUSE
1105 toggle_init_one(TOGGLE_MOUSE_KEY, N_("Mouse support"), USE_MOUSE);
1106#endif
David Lawrence Ramsey74835712004-12-04 17:41:52 +00001107 /* If we're using restricted mode, the DOS/Mac conversion toggle is
1108 * disabled. It's useless since inserting files is disabled. */
1109 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001110 toggle_init_one(TOGGLE_NOCONVERT_KEY,
1111 N_("No conversion from DOS/Mac format"), NO_CONVERT);
David Lawrence Ramsey74835712004-12-04 17:41:52 +00001112 /* If we're using restricted mode, the backup toggle is disabled.
1113 * It's useless since backups are disabled. */
1114 if (!ISSET(RESTRICTED))
David Lawrence Ramsey637b8bb2005-01-17 05:06:55 +00001115 toggle_init_one(TOGGLE_BACKUP_KEY, N_("Backup files"),
1116 BACKUP_FILE);
1117 toggle_init_one(TOGGLE_SMOOTH_KEY, N_("Smooth scrolling"),
1118 SMOOTHSCROLL);
1119 toggle_init_one(TOGGLE_SMARTHOME_KEY, N_("Smart home key"),
1120 SMART_HOME);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001121#ifdef ENABLE_COLOR
1122 toggle_init_one(TOGGLE_SYNTAX_KEY, N_("Color syntax highlighting"),
David Lawrence Ramsey202d3c22005-03-10 20:55:11 +00001123 NO_COLOR_SYNTAX);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001124#endif
1125#ifdef ENABLE_NANORC
1126 toggle_init_one(TOGGLE_WHITESPACE_KEY, N_("Whitespace display"),
1127 WHITESPACE_DISPLAY);
1128#endif
David Lawrence Ramsey637b8bb2005-01-17 05:06:55 +00001129 toggle_init_one(TOGGLE_MORESPACE_KEY, N_("Use of more space for editing"),
1130 MORE_SPACE);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001131}
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001132#endif /* !NANO_SMALL */
1133
Chris Allegretta6232d662002-05-12 19:52:15 +00001134/* This function is called just before calling exit(). Practically, the
1135 * only effect is to cause a segmentation fault if the various data
1136 * structures got bolloxed earlier. Thus, we don't bother having this
Chris Allegretta6df90f52002-07-19 01:08:59 +00001137 * function unless debugging is turned on. */
Chris Allegretta6232d662002-05-12 19:52:15 +00001138#ifdef DEBUG
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001139/* Added by SPK for memory cleanup; gracefully return our malloc()s. */
Chris Allegretta6df90f52002-07-19 01:08:59 +00001140void thanks_for_all_the_fish(void)
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001141{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001142 delwin(topwin);
1143 delwin(edit);
1144 delwin(bottomwin);
1145
Chris Allegretta7662c862003-01-13 01:35:15 +00001146#ifndef DISABLE_JUSTIFY
1147 if (quotestr != NULL)
1148 free(quotestr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001149#ifdef HAVE_REGEX_H
1150 regfree(&quotereg);
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001151 if (quoteerr != NULL)
1152 free(quoteerr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001153#endif
Chris Allegretta7662c862003-01-13 01:35:15 +00001154#endif
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +00001155#ifndef NANO_SMALL
1156 if (backup_dir != NULL)
1157 free(backup_dir);
1158#endif
Chris Allegretta2598c662002-03-28 01:59:34 +00001159#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001160 if (operating_dir != NULL)
1161 free(operating_dir);
1162 if (full_operating_dir != NULL)
1163 free(full_operating_dir);
1164#endif
1165 if (last_search != NULL)
1166 free(last_search);
1167 if (last_replace != NULL)
1168 free(last_replace);
1169 if (hblank != NULL)
1170 free(hblank);
1171#ifndef DISABLE_SPELLER
1172 if (alt_speller != NULL)
1173 free(alt_speller);
1174#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +00001175#ifndef DISABLE_HELP
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001176 if (help_text != NULL)
1177 free(help_text);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +00001178#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001179 if (filename != NULL)
1180 free(filename);
1181 if (answer != NULL)
1182 free(answer);
1183 if (cutbuffer != NULL)
Chris Allegretta7662c862003-01-13 01:35:15 +00001184 free_filestruct(cutbuffer);
David Lawrence Ramsey93c84052004-11-23 04:08:28 +00001185#ifndef DISABLE_JUSTIFY
1186 if (jusbuffer != NULL)
1187 free_filestruct(jusbuffer);
1188#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001189 free_shortcutage(&main_list);
1190 free_shortcutage(&whereis_list);
1191 free_shortcutage(&replace_list);
1192 free_shortcutage(&replace_list_2);
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +00001193 free_shortcutage(&gotoline_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001194 free_shortcutage(&writefile_list);
1195 free_shortcutage(&insertfile_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001196#ifndef DISABLE_HELP
Chris Allegretta6df90f52002-07-19 01:08:59 +00001197 free_shortcutage(&help_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001198#endif
1199#ifndef DISABLE_SPELLER
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001200 free_shortcutage(&spell_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001201#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +00001202#ifndef NANO_SMALL
1203 free_shortcutage(&extcmd_list);
1204#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001205#ifndef DISABLE_BROWSER
1206 free_shortcutage(&browser_list);
Chris Allegretta7662c862003-01-13 01:35:15 +00001207 free_shortcutage(&gotodir_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001208#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001209#ifndef NANO_SMALL
David Lawrence Ramsey40e4acf2005-05-26 06:09:07 +00001210 /* Free the memory associated with each toggle. */
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001211 while (toggles != NULL) {
1212 toggle *t = toggles;
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001213
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001214 toggles = toggles->next;
1215 free(t);
1216 }
1217#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001218#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey5d8d0b12005-05-26 05:53:29 +00001219 /* Free the memory associated with each open file buffer. */
David Lawrence Ramsey40e4acf2005-05-26 06:09:07 +00001220 if (open_files != NULL) {
1221 /* Make sure open_files->fileage is up to date, in case we've
1222 * cut the top line of the file. */
1223 open_files->fileage = fileage;
1224
Chris Allegretta6df90f52002-07-19 01:08:59 +00001225 free_openfilestruct(open_files);
David Lawrence Ramsey40e4acf2005-05-26 06:09:07 +00001226 }
Chris Allegrettaf2387fb2002-04-10 02:31:20 +00001227#else
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001228 if (fileage != NULL)
1229 free_filestruct(fileage);
Chris Allegrettaf2387fb2002-04-10 02:31:20 +00001230#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +00001231#ifdef ENABLE_COLOR
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001232 if (syntaxstr != NULL)
1233 free(syntaxstr);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001234 while (syntaxes != NULL) {
1235 syntaxtype *bill = syntaxes;
1236
1237 free(syntaxes->desc);
1238 while (syntaxes->extensions != NULL) {
1239 exttype *bob = syntaxes->extensions;
1240
1241 syntaxes->extensions = bob->next;
Chris Allegretta7662c862003-01-13 01:35:15 +00001242 regfree(&bob->val);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001243 free(bob);
1244 }
1245 while (syntaxes->color != NULL) {
1246 colortype *bob = syntaxes->color;
1247
1248 syntaxes->color = bob->next;
Chris Allegretta7662c862003-01-13 01:35:15 +00001249 regfree(&bob->start);
1250 if (bob->end != NULL)
Chris Allegrettace452fb2003-02-03 02:56:44 +00001251 regfree(bob->end);
1252 free(bob->end);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001253 free(bob);
1254 }
1255 syntaxes = syntaxes->next;
1256 free(bill);
1257 }
1258#endif /* ENABLE_COLOR */
Chris Allegretta5beed502003-01-05 20:41:21 +00001259#ifndef NANO_SMALL
David Lawrence Ramsey40e4acf2005-05-26 06:09:07 +00001260 /* Free the search and replace history lists. */
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001261 if (searchage != NULL)
1262 free_filestruct(searchage);
1263 if (replaceage != NULL)
1264 free_filestruct(replaceage);
Chris Allegretta5beed502003-01-05 20:41:21 +00001265#endif
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001266#ifdef ENABLE_NANORC
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001267 if (homedir != NULL)
1268 free(homedir);
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001269#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001270}
Chris Allegretta6232d662002-05-12 19:52:15 +00001271#endif /* DEBUG */