blob: b714c74470fc6afec54e1cc4b32036567e9a9afc [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 * *
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
Jordi Mallach55381aa2004-11-17 23:17:05 +000022#ifdef HAVE_CONFIG_H
23#include <config.h>
24#endif
Chris Allegretta6efda542001-04-28 18:03:52 +000025
Chris Allegretta1dd0bc92002-10-13 18:43:45 +000026#include <stdlib.h>
Chris Allegrettadab017e2002-04-23 10:56:06 +000027#include <assert.h>
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000028#include "proto.h"
David Lawrence Ramseyf21cd102002-06-13 00:40:19 +000029#include "nano.h"
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000030
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. */
81#endif
82
Chris Allegrettae4f940d2002-03-03 22:36:36 +000083#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey2c62b072004-05-29 16:38:57 +000084char *punct = NULL; /* Closing punctuation that can end
85 sentences. */
86char *brackets = NULL; /* Closing brackets that can follow
87 closing punctuation and can end
88 sentences. */
Chris Allegretta7662c862003-01-13 01:35:15 +000089char *quotestr = NULL; /* Quote string. The default value is
90 set in main(). */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +000091#ifdef HAVE_REGEX_H
92regex_t quotereg; /* Compiled quotestr regular expression. */
93int quoterc; /* Did it compile? */
94char *quoteerr = NULL; /* The error message. */
95#else
96size_t quotelen; /* strlen(quotestr) */
97#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +000098#endif
Chris Allegrettae4f940d2002-03-03 22:36:36 +000099
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000100#ifndef NANO_SMALL
101char *backup_dir = NULL; /* Backup directory. */
102#endif
103
Chris Allegretta6df90f52002-07-19 01:08:59 +0000104char *answer = NULL; /* Answer str to many questions */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000105int totlines = 0; /* Total number of lines in the file */
David Lawrence Ramsey23c44502005-01-27 20:49:07 +0000106size_t totsize = 0; /* Total number of characters in the
107 file */
David Lawrence Ramsey86e851b2004-07-28 20:46:25 +0000108size_t placewewant = 0; /* The column we'd like the cursor
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000109 to jump to when we go to the
110 next or previous line */
111
David Lawrence Ramsey49c3f242004-07-12 16:07:14 +0000112ssize_t tabsize = -1; /* Our internal tabsize variable. The
113 default value is set in main(). */
Chris Allegretta6d690a32000-08-03 22:51:21 +0000114
Chris Allegretta7662c862003-01-13 01:35:15 +0000115char *hblank = NULL; /* A horizontal blank line */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000116#ifndef DISABLE_HELP
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000117char *help_text; /* The text in the help window */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000118#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000119
120/* More stuff for the marker select */
121
Chris Allegretta7662c862003-01-13 01:35:15 +0000122#ifndef NANO_SMALL
David Lawrence Ramseyf28f50e2004-01-09 23:04:55 +0000123filestruct *mark_beginbuf; /* The begin marker buffer */
David Lawrence Ramsey687776b2004-10-30 01:16:08 +0000124size_t mark_beginx; /* X value in the string to start */
Chris Allegretta7662c862003-01-13 01:35:15 +0000125#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000126
Chris Allegrettae1f14522001-09-19 03:19:43 +0000127#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000128char *operating_dir = NULL; /* Operating directory, which we can't */
129char *full_operating_dir = NULL;/* go higher than */
Chris Allegrettae1f14522001-09-19 03:19:43 +0000130#endif
131
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000132#ifndef DISABLE_SPELLER
Chris Allegretta7c27be42002-05-05 23:03:54 +0000133char *alt_speller = NULL; /* Alternative spell command */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000134#endif
135
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000136shortcut *main_list = NULL;
137shortcut *whereis_list = NULL;
138shortcut *replace_list = NULL;
Chris Allegretta48b06702002-02-22 04:30:50 +0000139shortcut *replace_list_2 = NULL; /* 2nd half of replace dialog */
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000140shortcut *gotoline_list = NULL;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000141shortcut *writefile_list = NULL;
142shortcut *insertfile_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000143#ifndef DISABLE_HELP
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000144shortcut *help_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000145#endif
146#ifndef DISABLE_SPELLER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000147shortcut *spell_list = NULL;
Chris Allegretta7662c862003-01-13 01:35:15 +0000148#endif
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000149#ifndef NANO_SMALL
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000150shortcut *extcmd_list = NULL;
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000151#endif
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000152#ifndef DISABLE_BROWSER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000153shortcut *browser_list = NULL;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000154shortcut *gotodir_list = NULL;
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000155#endif
Chris Allegretta201f1d92003-02-05 02:51:19 +0000156
Chris Allegretta8ce24132001-04-30 11:28:46 +0000157#ifdef ENABLE_COLOR
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000158const colortype *colorstrings = NULL;
159syntaxtype *syntaxes = NULL;
160char *syntaxstr = NULL;
Chris Allegretta8ce24132001-04-30 11:28:46 +0000161#endif
162
Chris Allegretta6df90f52002-07-19 01:08:59 +0000163const shortcut *currshortcut; /* Current shortcut list we're using */
Chris Allegretta6b58acd2001-04-12 03:01:53 +0000164
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000165#ifndef NANO_SMALL
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000166toggle *toggles = NULL;
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000167#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000168
Chris Allegretta5beed502003-01-05 20:41:21 +0000169#ifndef NANO_SMALL
170historyheadtype search_history;
171historyheadtype replace_history;
172#endif
173
Chris Allegretta9fc8d432000-07-07 01:49:52 +0000174/* Regular expressions */
175
Chris Allegretta805c26d2000-09-06 13:39:17 +0000176#ifdef HAVE_REGEX_H
Chris Allegrettabd9e7c32000-10-26 01:44:42 +0000177regex_t search_regexp; /* Global to store compiled search regexp */
178regmatch_t regmatches[10]; /* Match positions for parenthetical
179 subexpressions, max of 10 */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000180#endif
Chris Allegretta3533a342002-03-24 23:19:32 +0000181
David Lawrence Ramsey82dc1c12004-08-12 03:27:54 +0000182bool curses_ended = FALSE; /* Indicates to statusbar() to simply
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000183 * write to stderr, since endwin() has
184 * ended curses mode. */
185
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000186#ifdef ENABLE_NANORC
187char *homedir = NULL; /* $HOME or from /etc/passwd. */
188#endif
189
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000190size_t length_of_list(const shortcut *s)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000191{
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000192 size_t i = 0;
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000193
Chris Allegrettadab017e2002-04-23 10:56:06 +0000194 for (; s != NULL; s = s->next)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000195 i++;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000196 return i;
197}
198
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000199/* Initialize a struct *without* our lovely braces =( */
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000200void sc_init_one(shortcut **shortcutage, int ctrlval, const char *desc,
Chris Allegrettadab017e2002-04-23 10:56:06 +0000201#ifndef DISABLE_HELP
Chris Allegrettaf717f982003-02-13 22:25:01 +0000202 const char *help,
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000203#endif
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000204 int metaval, int funcval, int miscval, bool view, void
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000205 (*func)(void))
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000206{
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000207 shortcut *s;
208
209 if (*shortcutage == NULL) {
David Lawrence Ramsey70047ee2003-06-14 20:41:34 +0000210 *shortcutage = (shortcut *)nmalloc(sizeof(shortcut));
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000211 s = *shortcutage;
212 } else {
213 for (s = *shortcutage; s->next != NULL; s = s->next)
214 ;
David Lawrence Ramsey70047ee2003-06-14 20:41:34 +0000215 s->next = (shortcut *)nmalloc(sizeof(shortcut));
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000216 s = s->next;
217 }
218
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000219 s->ctrlval = ctrlval;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000220 s->desc = _(desc);
Chris Allegrettadab017e2002-04-23 10:56:06 +0000221#ifndef DISABLE_HELP
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000222 s->help = _(help);
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000223#endif
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000224 s->metaval = metaval;
225 s->funcval = funcval;
226 s->miscval = miscval;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000227 s->viewok = view;
228 s->func = func;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000229 s->next = NULL;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000230}
231
David Lawrence Ramsey1f1ebb82004-11-11 21:50:01 +0000232void shortcut_init(bool unjustify)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000233{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000234 const char *get_help_msg = N_("Get Help");
235 const char *exit_msg = N_("Exit");
236 const char *prev_page_msg = N_("Prev Page");
237 const char *next_page_msg = N_("Next Page");
238 const char *replace_msg = N_("Replace");
239 const char *go_to_line_msg = N_("Go To Line");
240 const char *cancel_msg = N_("Cancel");
241 const char *first_line_msg = N_("First Line");
242 const char *last_line_msg = N_("Last Line");
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000243#ifndef NANO_SMALL
244 const char *cut_till_end_msg = N_("CutTillEnd");
245#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000246#ifndef DISABLE_JUSTIFY
247 const char *beg_of_par_msg = N_("Beg of Par");
248 const char *end_of_par_msg = N_("End of Par");
249 const char *fulljstify_msg = N_("FullJstify");
250#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000251#ifndef NANO_SMALL
252 const char *case_sens_msg = N_("Case Sens");
253 const char *direction_msg = N_("Direction");
254#ifdef HAVE_REGEX_H
255 const char *regexp_msg = N_("Regexp");
256#endif
257 const char *history_msg = N_("History");
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000258#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey04a8d1c2004-09-28 22:14:58 +0000259 const char *new_buffer_msg = N_("New Buffer");
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000260#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000261#endif /* !NANO_SMALL */
262#ifndef DISABLE_BROWSER
263 const char *to_files_msg = N_("To Files");
264#endif
265
Chris Allegrettadab017e2002-04-23 10:56:06 +0000266#ifndef DISABLE_HELP
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000267 const char *nano_help_msg = N_("Invoke the help menu");
268 const char *nano_exit_msg =
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000269#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000270 N_("Close currently loaded file/Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000271#else
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000272 N_("Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000273#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000274 ;
275 const char *nano_writeout_msg = N_("Write the current file to disk");
276 const char *nano_justify_msg = N_("Justify the current paragraph");
277 const char *nano_insert_msg =
278 N_("Insert another file into the current one");
279 const char *nano_whereis_msg = N_("Search for text within the editor");
280 const char *nano_prevpage_msg = N_("Move to the previous screen");
281 const char *nano_nextpage_msg = N_("Move to the next screen");
282 const char *nano_cut_msg =
283 N_("Cut the current line and store it in the cutbuffer");
284 const char *nano_uncut_msg =
285 N_("Uncut from the cutbuffer into the current line");
286 const char *nano_cursorpos_msg = N_("Show the position of the cursor");
287 const char *nano_spell_msg = N_("Invoke the spell checker, if available");
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000288 const char *nano_gotoline_msg = N_("Go to a specific line number");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000289 const char *nano_replace_msg = N_("Replace text within the editor");
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000290#ifndef NANO_SMALL
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000291 const char *nano_mark_msg = N_("Mark text at the cursor position");
292 const char *nano_whereis_next_msg = N_("Repeat last search");
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000293#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000294 const char *nano_prevline_msg = N_("Move to the previous line");
295 const char *nano_nextline_msg = N_("Move to the next line");
296 const char *nano_forward_msg = N_("Move forward one character");
297 const char *nano_back_msg = N_("Move back one character");
298 const char *nano_home_msg = N_("Move to the beginning of the current line");
299 const char *nano_end_msg = N_("Move to the end of the current line");
300 const char *nano_refresh_msg = N_("Refresh (redraw) the current screen");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000301 const char *nano_delete_msg = N_("Delete the character under the cursor");
302 const char *nano_backspace_msg =
303 N_("Delete the character to the left of the cursor");
David Lawrence Ramseye7c41682004-10-23 14:53:07 +0000304 const char *nano_tab_msg =
305 N_("Insert a tab character at the cursor position");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000306 const char *nano_enter_msg =
307 N_("Insert a carriage return at the cursor position");
David Lawrence Ramsey00d77982004-08-07 21:27:37 +0000308#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000309 const char *nano_nextword_msg = N_("Move forward one word");
310 const char *nano_prevword_msg = N_("Move backward one word");
David Lawrence Ramsey00d77982004-08-07 21:27:37 +0000311#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000312#ifndef DISABLE_JUSTIFY
313 const char *nano_parabegin_msg =
314 N_("Go to the beginning of the current paragraph");
315 const char *nano_paraend_msg =
316 N_("Go to the end of the current paragraph");
317#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000318#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000319 const char *nano_openprev_msg = N_("Switch to the previous file buffer");
320 const char *nano_opennext_msg = N_("Switch to the next file buffer");
321#endif
322 const char *nano_verbatim_msg = N_("Insert character(s) verbatim");
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000323#ifndef NANO_SMALL
324 const char *nano_cut_till_end_msg =
325 N_("Cut from the cursor position to the end of the file");
326#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000327#ifndef DISABLE_JUSTIFY
328 const char *nano_fulljustify_msg = N_("Justify the entire file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000329#endif
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000330#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000331 const char *nano_bracket_msg = N_("Find other bracket");
332#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000333 const char *nano_cancel_msg = N_("Cancel the current function");
334 const char *nano_firstline_msg = N_("Go to the first line of the file");
335 const char *nano_lastline_msg = N_("Go to the last line of the file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000336#ifndef NANO_SMALL
337 const char *nano_case_msg =
338 N_("Make the current search/replace case (in)sensitive");
339 const char *nano_reverse_msg =
340 N_("Make the current search/replace go backwards");
341#ifdef HAVE_REGEX_H
342 const char *nano_regexp_msg = N_("Use regular expressions");
343#endif
344 const char *nano_editstr_msg =
345 N_("Edit the previous search/replace strings");
346#endif /* !NANO_SMALL */
347
348#ifndef DISABLE_BROWSER
349 const char *nano_tofiles_msg = N_("Go to file browser");
350#endif
351#ifndef NANO_SMALL
352 const char *nano_dos_msg = N_("Write file out in DOS format");
353 const char *nano_mac_msg = N_("Write file out in Mac format");
354#endif
355 const char *nano_append_msg = N_("Append to the current file");
356 const char *nano_prepend_msg = N_("Prepend to the current file");
357#ifndef NANO_SMALL
358 const char *nano_backup_msg = N_("Back up original file when saving");
359 const char *nano_execute_msg = N_("Execute external command");
360#endif
361#if defined(ENABLE_MULTIBUFFER) && !defined(NANO_SMALL)
362 const char *nano_multibuffer_msg = N_("Insert into new buffer");
363#endif
364#ifndef DISABLE_BROWSER
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000365 const char *nano_exitbrowser_msg = N_("Exit from the file browser");
366 const char *nano_gotodir_msg = N_("Go to directory");
Chris Allegretta2bef1822001-09-28 19:53:11 +0000367#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000368#endif /* !DISABLE_HELP */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000369
David Lawrence Ramsey8e4adcd2004-05-20 03:29:33 +0000370/* The following macro is to be used in calling sc_init_one(). The
371 * point is that sc_init_one() takes 9 arguments, unless DISABLE_HELP is
372 * defined, when the 4th one should not be there. */
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000373#ifndef DISABLE_HELP
Chris Allegrettadab017e2002-04-23 10:56:06 +0000374# define IFHELP(help, nextvar) help, nextvar
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000375#else
376# define IFHELP(help, nextvar) nextvar
Chris Allegrettadab017e2002-04-23 10:56:06 +0000377#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000378
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000379 free_shortcutage(&main_list);
380
Jordi Mallachf9390af2003-08-05 19:31:12 +0000381 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000382 sc_init_one(&main_list, NANO_HELP_KEY, get_help_msg,
383 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
384 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000385#ifndef DISABLE_HELP
386 do_help
387#else
388 nano_disabled_msg
389#endif
390 );
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000391
David Lawrence Ramsey5b3dd0f2004-11-25 04:39:07 +0000392 /* Translators: try to keep this string under 10 characters long */
393 sc_init_one(&main_list, NANO_EXIT_KEY,
Chris Allegretta355fbe52001-07-14 19:32:47 +0000394#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey5b3dd0f2004-11-25 04:39:07 +0000395 open_files != NULL && open_files != open_files->next ?
396 N_("Close") :
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000397#endif
David Lawrence Ramsey5b3dd0f2004-11-25 04:39:07 +0000398 exit_msg, IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
399 NANO_NO_KEY, VIEW, do_exit);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000400
Jordi Mallachf9390af2003-08-05 19:31:12 +0000401 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000402 sc_init_one(&main_list, NANO_WRITEOUT_KEY, N_("WriteOut"),
403 IFHELP(nano_writeout_msg, NANO_NO_KEY), NANO_WRITEOUT_FKEY,
404 NANO_NO_KEY, NOVIEW, do_writeout_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000405
Jordi Mallachf9390af2003-08-05 19:31:12 +0000406 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000407 sc_init_one(&main_list, NANO_JUSTIFY_KEY, N_("Justify"),
408 IFHELP(nano_justify_msg, NANO_NO_KEY),
409 NANO_JUSTIFY_FKEY, NANO_NO_KEY, NOVIEW,
David Lawrence Ramseya539fce2004-06-29 00:43:56 +0000410#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey8d3e7f32004-05-13 17:28:03 +0000411 do_justify_void
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000412#else
413 nano_disabled_msg
414#endif
415 );
Chris Allegretta32da4562002-01-02 15:12:21 +0000416
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000417 /* We allow inserting files in view mode if multibuffers are
418 * available, so that we can view multiple files. */
419 /* If we're using restricted mode, inserting files is disabled since
420 * it allows reading from or writing to files not specified on the
421 * command line. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000422 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000423 sc_init_one(&main_list, NANO_INSERTFILE_KEY, N_("Read File"),
424 IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_INSERTFILE_FKEY,
425 NANO_NO_KEY,
Chris Allegretta32da4562002-01-02 15:12:21 +0000426#ifdef ENABLE_MULTIBUFFER
Chris Allegrettad8451932003-03-11 03:50:40 +0000427 VIEW
Chris Allegretta32da4562002-01-02 15:12:21 +0000428#else
Chris Allegrettad8451932003-03-11 03:50:40 +0000429 NOVIEW
Chris Allegretta32da4562002-01-02 15:12:21 +0000430#endif
David Lawrence Ramsey8001e272004-11-12 00:48:18 +0000431 , !ISSET(RESTRICTED) ? do_insertfile_void :
432 nano_disabled_msg);
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000433
Jordi Mallachf9390af2003-08-05 19:31:12 +0000434 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000435 sc_init_one(&main_list, NANO_WHEREIS_KEY, N_("Where Is"),
436 IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_WHEREIS_FKEY,
437 NANO_NO_KEY, VIEW, do_search);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000438
Jordi Mallachf9390af2003-08-05 19:31:12 +0000439 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000440 sc_init_one(&main_list, NANO_PREVPAGE_KEY, prev_page_msg,
441 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
442 NANO_NO_KEY, VIEW, do_page_up);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000443
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_NEXTPAGE_KEY, next_page_msg,
446 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
447 NANO_NO_KEY, VIEW, do_page_down);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000448
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_CUT_KEY, N_("Cut Text"),
451 IFHELP(nano_cut_msg, NANO_NO_KEY), NANO_CUT_FKEY,
452 NANO_NO_KEY, NOVIEW, do_cut_text);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000453
Chris Allegretta07798352000-11-27 22:58:23 +0000454 if (unjustify)
Jordi Mallachf9390af2003-08-05 19:31:12 +0000455 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000456 sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, N_("UnJustify"),
457 IFHELP(NULL, NANO_NO_KEY), NANO_UNJUSTIFY_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000458 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegretta07798352000-11-27 22:58:23 +0000459 else
Jordi Mallachf9390af2003-08-05 19:31:12 +0000460 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000461 sc_init_one(&main_list, NANO_UNCUT_KEY, N_("UnCut Txt"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000462 IFHELP(nano_uncut_msg, NANO_NO_KEY), NANO_UNCUT_FKEY,
463 NANO_NO_KEY, NOVIEW, do_uncut_text);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000464
Jordi Mallachf9390af2003-08-05 19:31:12 +0000465 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000466 sc_init_one(&main_list, NANO_CURSORPOS_KEY, N_("Cur Pos"),
467 IFHELP(nano_cursorpos_msg, NANO_NO_KEY), NANO_CURSORPOS_FKEY,
468 NANO_NO_KEY, VIEW, do_cursorpos_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000469
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000470 /* If we're using restricted mode, spell checking is disabled
471 * because it allows reading from or writing to files not specified
472 * on the command line. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000473 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000474 sc_init_one(&main_list, NANO_SPELL_KEY, N_("To Spell"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000475 IFHELP(nano_spell_msg, NANO_NO_KEY), NANO_SPELL_FKEY,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000476 NANO_NO_KEY, NOVIEW,
477#ifndef DISABLE_SPELLER
478 !ISSET(RESTRICTED) ? do_spell :
479#endif
480 nano_disabled_msg);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000481
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000482 sc_init_one(&main_list, NANO_GOTOLINE_KEY, go_to_line_msg,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000483 IFHELP(nano_gotoline_msg, NANO_GOTOLINE_ALTKEY),
484 NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW, do_gotoline_void);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000485
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000486 sc_init_one(&main_list, NANO_REPLACE_KEY, replace_msg,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000487 IFHELP(nano_replace_msg, NANO_ALT_REPLACE_KEY),
488 NANO_REPLACE_FKEY, NANO_NO_KEY, NOVIEW, do_replace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000489
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000490#ifndef NANO_SMALL
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000491 sc_init_one(&main_list, NANO_MARK_KEY, N_("Mark Text"),
492 IFHELP(nano_mark_msg, NANO_MARK_ALTKEY), NANO_MARK_FKEY,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000493 NANO_NO_KEY, NOVIEW, do_mark);
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000494
495 sc_init_one(&main_list, NANO_NO_KEY, N_("Where Is Next"),
496 IFHELP(nano_whereis_next_msg, NANO_WHEREIS_NEXT_KEY),
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000497 NANO_WHEREIS_NEXT_FKEY, NANO_NO_KEY, VIEW, do_research);
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000498#endif
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000499
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000500 sc_init_one(&main_list, NANO_PREVLINE_KEY, N_("Prev Line"),
501 IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
502 NANO_NO_KEY, VIEW, do_up);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000503
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000504 sc_init_one(&main_list, NANO_NEXTLINE_KEY, N_("Next Line"),
505 IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
506 NANO_NO_KEY, VIEW, do_down);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000507
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000508 sc_init_one(&main_list, NANO_FORWARD_KEY, N_("Forward"),
509 IFHELP(nano_forward_msg, NANO_NO_KEY), NANO_NO_KEY,
510 NANO_NO_KEY, VIEW, do_right_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000511
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000512 sc_init_one(&main_list, NANO_BACK_KEY, N_("Back"),
513 IFHELP(nano_back_msg, NANO_NO_KEY), NANO_NO_KEY,
514 NANO_NO_KEY, VIEW, do_left_void);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000515
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000516 sc_init_one(&main_list, NANO_HOME_KEY, N_("Home"),
517 IFHELP(nano_home_msg, NANO_NO_KEY), NANO_NO_KEY,
518 NANO_NO_KEY, VIEW, do_home);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000519
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000520 sc_init_one(&main_list, NANO_END_KEY, N_("End"),
521 IFHELP(nano_end_msg, NANO_NO_KEY), NANO_NO_KEY,
522 NANO_NO_KEY, VIEW, do_end);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000523
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000524 sc_init_one(&main_list, NANO_REFRESH_KEY, N_("Refresh"),
525 IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
526 NANO_NO_KEY, VIEW, total_refresh);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000527
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000528 sc_init_one(&main_list, NANO_DELETE_KEY, N_("Delete"),
529 IFHELP(nano_delete_msg, NANO_NO_KEY), NANO_NO_KEY,
530 NANO_NO_KEY, NOVIEW, do_delete);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000531
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000532 sc_init_one(&main_list, NANO_BACKSPACE_KEY, N_("Backspace"),
533 IFHELP(nano_backspace_msg, NANO_NO_KEY), NANO_NO_KEY,
534 NANO_NO_KEY, NOVIEW, do_backspace);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000535
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000536 sc_init_one(&main_list, NANO_TAB_KEY, N_("Tab"),
537 IFHELP(nano_tab_msg, NANO_NO_KEY), NANO_NO_KEY,
538 NANO_NO_KEY, NOVIEW, do_tab);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000539
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000540 sc_init_one(&main_list, NANO_ENTER_KEY, N_("Enter"),
541 IFHELP(nano_enter_msg, NANO_NO_KEY), NANO_NO_KEY,
542 NANO_NO_KEY, NOVIEW, do_enter);
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000543
David Lawrence Ramseyc5967552002-06-21 03:20:06 +0000544#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000545 sc_init_one(&main_list, NANO_NEXTWORD_KEY, N_("Next Word"),
546 IFHELP(nano_nextword_msg, NANO_NO_KEY), NANO_NO_KEY,
547 NANO_NO_KEY, VIEW, do_next_word);
David Lawrence Ramseyc5967552002-06-21 03:20:06 +0000548
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000549 sc_init_one(&main_list, NANO_NO_KEY, N_("Prev Word"),
550 IFHELP(nano_prevword_msg, NANO_PREVWORD_KEY), NANO_NO_KEY,
551 NANO_NO_KEY, VIEW, do_prev_word);
Chris Allegretta8d990b52001-09-22 22:14:25 +0000552#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000553
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000554#ifndef DISABLE_JUSTIFY
555 /* Translators: try to keep this string under 10 characters long */
556 sc_init_one(&main_list, NANO_NO_KEY, beg_of_par_msg,
557 IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
558 NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin);
559
560 /* Translators: try to keep this string under 10 characters long */
561 sc_init_one(&main_list, NANO_NO_KEY, end_of_par_msg,
562 IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
563 NANO_PARAEND_ALTKEY2, VIEW, do_para_end);
564#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000565
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000566#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000567 sc_init_one(&main_list, NANO_NO_KEY, N_("Previous File"),
568 IFHELP(nano_openprev_msg, NANO_OPENPREV_KEY), NANO_NO_KEY,
569 NANO_OPENPREV_ALTKEY, VIEW, open_prevfile_void);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000570
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000571 sc_init_one(&main_list, NANO_NO_KEY, N_("Next File"),
572 IFHELP(nano_opennext_msg, NANO_OPENNEXT_KEY), NANO_NO_KEY,
573 NANO_OPENNEXT_ALTKEY, VIEW, open_nextfile_void);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000574#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +0000575
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000576 sc_init_one(&main_list, NANO_NO_KEY, N_("Verbatim Input"),
577 IFHELP(nano_verbatim_msg, NANO_VERBATIM_KEY), NANO_NO_KEY,
578 NANO_NO_KEY, NOVIEW, do_verbatim_input);
579
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000580#ifndef NANO_SMALL
581 /* Translators: try to keep this string under 10 characters long */
582 sc_init_one(&main_list, NANO_NO_KEY, cut_till_end_msg,
583 IFHELP(nano_cut_till_end_msg, NANO_CUTTILLEND_ALTKEY),
584 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end);
585#endif
586
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000587#ifndef DISABLE_JUSTIFY
588 /* Translators: try to keep this string under 10 characters long */
589 sc_init_one(&main_list, NANO_NO_KEY, fulljstify_msg,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000590 IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY),
591 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000592#endif
593
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000594#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000595 sc_init_one(&main_list, NANO_NO_KEY, N_("Find Other Bracket"),
596 IFHELP(nano_bracket_msg, NANO_BRACKET_KEY), NANO_NO_KEY,
597 NANO_NO_KEY, VIEW, do_find_bracket);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000598#endif
599
Chris Allegrettadab017e2002-04-23 10:56:06 +0000600 free_shortcutage(&whereis_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000601
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000602 sc_init_one(&whereis_list, NANO_HELP_KEY, get_help_msg,
603 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
604 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000605#ifndef DISABLE_HELP
606 do_help
607#else
608 nano_disabled_msg
609#endif
610 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000611
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000612 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000613 sc_init_one(&whereis_list, NANO_CANCEL_KEY, cancel_msg,
614 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000615 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000616
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000617 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000618 sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, first_line_msg,
619 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
620 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000621
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000622 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000623 sc_init_one(&whereis_list, NANO_LASTLINE_KEY, last_line_msg,
624 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
625 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000626
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000627 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000628 sc_init_one(&whereis_list, NANO_TOOTHERSEARCH_KEY, replace_msg,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000629 IFHELP(nano_replace_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000630 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000631
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000632 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000633 sc_init_one(&whereis_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
634 IFHELP(nano_gotoline_msg, NANO_NO_KEY), NANO_GOTOLINE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000635 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000636
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000637#ifndef DISABLE_JUSTIFY
638 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000639 sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, beg_of_par_msg,
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000640 IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
641 NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000642
643 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000644 sc_init_one(&whereis_list, NANO_PARAEND_KEY, end_of_par_msg,
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000645 IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
646 NANO_PARAEND_ALTKEY2, VIEW, do_para_end);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000647#endif
648
Chris Allegretta5f36c372001-07-16 00:48:53 +0000649#ifndef NANO_SMALL
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000650 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000651 sc_init_one(&whereis_list, NANO_NO_KEY, case_sens_msg,
652 IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000653 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta658399a2001-06-14 02:54:22 +0000654
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000655 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000656 sc_init_one(&whereis_list, NANO_NO_KEY, direction_msg,
657 IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000658 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000659
Chris Allegretta658399a2001-06-14 02:54:22 +0000660#ifdef HAVE_REGEX_H
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000661 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000662 sc_init_one(&whereis_list, NANO_NO_KEY, regexp_msg,
663 IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000664 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta658399a2001-06-14 02:54:22 +0000665#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000666
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000667 /* Translators: try to keep this string under 10 characters long */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000668 sc_init_one(&whereis_list, NANO_HISTORY_KEY, history_msg,
669 IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000670 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000671
672 /* Translators: try to keep this string under 10 characters long */
673 sc_init_one(&whereis_list, NANO_CUTTILLEND_KEY, cut_till_end_msg,
674 IFHELP(nano_cut_till_end_msg, NANO_CUTTILLEND_ALTKEY),
675 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end);
David Lawrence Ramsey30412932004-11-23 20:42:35 +0000676#endif /* !NANO_SMALL */
David Lawrence Ramsey02085d72004-11-07 16:04:18 +0000677
678#ifndef DISABLE_JUSTIFY
679 /* Translators: try to keep this string under 10 characters long */
680 sc_init_one(&whereis_list, NANO_FULLJUSTIFY_KEY, fulljstify_msg,
681 IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY),
682 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
683#endif
Chris Allegretta5f36c372001-07-16 00:48:53 +0000684
Chris Allegrettadab017e2002-04-23 10:56:06 +0000685 free_shortcutage(&replace_list);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000686
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000687 sc_init_one(&replace_list, NANO_HELP_KEY, get_help_msg,
688 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
689 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000690#ifndef DISABLE_HELP
691 do_help
692#else
693 nano_disabled_msg
694#endif
695 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000696
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000697 sc_init_one(&replace_list, NANO_CANCEL_KEY, cancel_msg,
698 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000699 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta5f36c372001-07-16 00:48:53 +0000700
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000701 sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, first_line_msg,
702 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
703 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000704
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000705 sc_init_one(&replace_list, NANO_LASTLINE_KEY, last_line_msg,
706 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
707 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000708
Jordi Mallachf9390af2003-08-05 19:31:12 +0000709 /* Translators: try to keep this string under 12 characters long */
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000710 sc_init_one(&replace_list, NANO_TOOTHERSEARCH_KEY, N_("No Replace"),
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000711 IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000712 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000713
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000714 sc_init_one(&replace_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
715 IFHELP(nano_gotoline_msg, NANO_NO_KEY), NANO_GOTOLINE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000716 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000717
Chris Allegretta5f36c372001-07-16 00:48:53 +0000718#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000719 sc_init_one(&replace_list, NANO_NO_KEY, case_sens_msg,
720 IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000721 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta658399a2001-06-14 02:54:22 +0000722
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000723 sc_init_one(&replace_list, NANO_NO_KEY, direction_msg,
724 IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000725 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta105da332000-10-31 05:10:10 +0000726
Chris Allegretta658399a2001-06-14 02:54:22 +0000727#ifdef HAVE_REGEX_H
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000728 sc_init_one(&replace_list, NANO_NO_KEY, regexp_msg,
729 IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000730 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta658399a2001-06-14 02:54:22 +0000731#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000732
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000733 sc_init_one(&replace_list, NANO_HISTORY_KEY, history_msg,
734 IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000735 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000736#endif /* !NANO_SMALL */
Chris Allegretta5f36c372001-07-16 00:48:53 +0000737
Chris Allegrettadab017e2002-04-23 10:56:06 +0000738 free_shortcutage(&replace_list_2);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000739
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000740 sc_init_one(&replace_list_2, NANO_HELP_KEY, get_help_msg,
741 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
742 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000743#ifndef DISABLE_HELP
744 do_help
745#else
746 nano_disabled_msg
747#endif
748 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000749
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000750 sc_init_one(&replace_list_2, NANO_CANCEL_KEY, cancel_msg,
751 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000752 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta105da332000-10-31 05:10:10 +0000753
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000754 sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, first_line_msg,
755 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
756 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegretta105da332000-10-31 05:10:10 +0000757
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000758 sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, last_line_msg,
759 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
760 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegretta105da332000-10-31 05:10:10 +0000761
Chris Allegretta5beed502003-01-05 20:41:21 +0000762#ifndef NANO_SMALL
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000763 sc_init_one(&replace_list_2, NANO_HISTORY_KEY, history_msg,
764 IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000765 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta5beed502003-01-05 20:41:21 +0000766#endif
767
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000768 free_shortcutage(&gotoline_list);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000769
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000770 sc_init_one(&gotoline_list, NANO_HELP_KEY, get_help_msg,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000771 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
772 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000773#ifndef DISABLE_HELP
774 do_help
775#else
776 nano_disabled_msg
777#endif
778 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000779
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000780 sc_init_one(&gotoline_list, NANO_CANCEL_KEY, cancel_msg,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000781 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000782 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000783
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000784 sc_init_one(&gotoline_list, NANO_FIRSTLINE_KEY, first_line_msg,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000785 IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
786 NANO_NO_KEY, VIEW, do_first_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000787
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000788 sc_init_one(&gotoline_list, NANO_LASTLINE_KEY, last_line_msg,
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000789 IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
790 NANO_NO_KEY, VIEW, do_last_line);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000791
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000792 sc_init_one(&gotoline_list, NANO_TOOTHERWHEREIS_KEY,
793 N_("Go To Text"), IFHELP(nano_whereis_msg, NANO_NO_KEY),
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000794 NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000795
Chris Allegretta7662c862003-01-13 01:35:15 +0000796#ifndef DISABLE_HELP
Chris Allegrettadab017e2002-04-23 10:56:06 +0000797 free_shortcutage(&help_list);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000798
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000799 sc_init_one(&help_list, NANO_PREVPAGE_KEY, prev_page_msg,
800 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000801 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000802
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000803 sc_init_one(&help_list, NANO_NEXTPAGE_KEY, next_page_msg,
804 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000805 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramseybe265612004-05-29 20:38:08 +0000806
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000807 sc_init_one(&help_list, NANO_PREVLINE_KEY, N_("Prev Line"),
808 IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000809 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramseybe265612004-05-29 20:38:08 +0000810
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000811 sc_init_one(&help_list, NANO_NEXTLINE_KEY, N_("Next Line"),
812 IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
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_EXIT_KEY, exit_msg,
816 IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000817 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta7662c862003-01-13 01:35:15 +0000818#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000819
Chris Allegrettadab017e2002-04-23 10:56:06 +0000820 free_shortcutage(&writefile_list);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000821
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000822 sc_init_one(&writefile_list, NANO_HELP_KEY, get_help_msg,
823 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
824 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000825#ifndef DISABLE_HELP
826 do_help
827#else
828 nano_disabled_msg
829#endif
830 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000831
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000832 sc_init_one(&writefile_list, NANO_CANCEL_KEY, cancel_msg,
833 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000834 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000835
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000836#ifndef DISABLE_BROWSER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000837 /* If we're using restricted mode, the file browser is disabled.
838 * It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000839 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000840 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000841 sc_init_one(&writefile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000842 IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000843 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000844#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000845
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000846#ifndef NANO_SMALL
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000847 /* If we're using restricted mode, the DOS format, Mac format,
848 * append, prepend, and backup toggles are disabled. The first and
849 * second are useless since inserting files is disabled, the third
850 * and fourth are disabled because they allow writing to files not
851 * specified on the command line, and the fifth is useless since
852 * backups are disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000853 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000854 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000855 sc_init_one(&writefile_list, NANO_NO_KEY, N_("DOS Format"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000856 IFHELP(nano_dos_msg, TOGGLE_DOS_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000857 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000858
Jordi Mallachf9390af2003-08-05 19:31:12 +0000859 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000860 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000861 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Mac Format"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000862 IFHELP(nano_mac_msg, TOGGLE_MAC_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000863 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000864#endif
865
Jordi Mallachf9390af2003-08-05 19:31:12 +0000866 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000867 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000868 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Append"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000869 IFHELP(nano_append_msg, NANO_APPEND_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000870 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000871
Jordi Mallachf9390af2003-08-05 19:31:12 +0000872 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000873 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000874 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Prepend"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000875 IFHELP(nano_prepend_msg, NANO_PREPEND_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000876 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000877
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000878#ifndef NANO_SMALL
Jordi Mallachf9390af2003-08-05 19:31:12 +0000879 /* Translators: try to keep this string under 16 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000880 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000881 sc_init_one(&writefile_list, NANO_NO_KEY, N_("Backup File"),
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000882 IFHELP(nano_backup_msg, TOGGLE_BACKUP_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000883 NANO_NO_KEY, NOVIEW, NULL);
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +0000884#endif
885
Chris Allegrettadab017e2002-04-23 10:56:06 +0000886 free_shortcutage(&insertfile_list);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000887
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000888 sc_init_one(&insertfile_list, NANO_HELP_KEY, get_help_msg,
889 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
890 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000891#ifndef DISABLE_HELP
892 do_help
893#else
894 nano_disabled_msg
895#endif
896 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000897
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000898 sc_init_one(&insertfile_list, NANO_CANCEL_KEY, cancel_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000899 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000900 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000901
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000902#ifndef DISABLE_BROWSER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000903 /* If we're using restricted mode, the file browser is disabled.
904 * It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000905 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000906 sc_init_one(&insertfile_list, NANO_TOFILES_KEY, to_files_msg,
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000907 IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000908 NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000909#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000910
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000911#ifndef NANO_SMALL
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000912 /* If we're using restricted mode, command execution is disabled.
913 * It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000914 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000915 if (!ISSET(RESTRICTED))
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000916 sc_init_one(&insertfile_list, NANO_TOOTHERINSERT_KEY,
917 N_("Execute Command"), IFHELP(nano_execute_msg,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000918 NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000919
Chris Allegrettaf7c68112002-09-03 22:58:40 +0000920#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000921 /* If we're using restricted mode, the multibuffer toggle is
922 * disabled. It's useless since inserting files is disabled. */
Jordi Mallachf9390af2003-08-05 19:31:12 +0000923 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000924 if (!ISSET(RESTRICTED))
David Lawrence Ramsey04a8d1c2004-09-28 22:14:58 +0000925 sc_init_one(&insertfile_list, NANO_NO_KEY, new_buffer_msg,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000926 IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY),
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000927 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
Chris Allegrettaf7c68112002-09-03 22:58:40 +0000928#endif
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000929#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000930
Chris Allegretta7662c862003-01-13 01:35:15 +0000931#ifndef DISABLE_SPELLER
Chris Allegrettadab017e2002-04-23 10:56:06 +0000932 free_shortcutage(&spell_list);
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000933
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000934 sc_init_one(&spell_list, NANO_HELP_KEY, get_help_msg,
935 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
936 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000937#ifndef DISABLE_HELP
938 do_help
939#else
940 nano_disabled_msg
941#endif
942 );
Chris Allegrettab3655b42001-10-22 03:15:31 +0000943
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000944 sc_init_one(&spell_list, NANO_CANCEL_KEY, cancel_msg,
945 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000946 NANO_NO_KEY, VIEW, NULL);
Chris Allegretta7662c862003-01-13 01:35:15 +0000947#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000948
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000949#ifndef NANO_SMALL
Chris Allegrettadab017e2002-04-23 10:56:06 +0000950 free_shortcutage(&extcmd_list);
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000951
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000952 sc_init_one(&extcmd_list, NANO_HELP_KEY, get_help_msg,
953 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
954 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000955#ifndef DISABLE_HELP
956 do_help
957#else
958 nano_disabled_msg
959#endif
960 );
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000961
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000962 sc_init_one(&extcmd_list, NANO_CANCEL_KEY, cancel_msg,
963 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000964 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramsey04a8d1c2004-09-28 22:14:58 +0000965
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000966 sc_init_one(&extcmd_list, NANO_TOOTHERINSERT_KEY, N_("Insert File"),
967 IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000968 NANO_NO_KEY, VIEW, NULL);
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000969
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000970#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey04a8d1c2004-09-28 22:14:58 +0000971 sc_init_one(&extcmd_list, NANO_NO_KEY, new_buffer_msg,
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000972 IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY),
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000973 NANO_NO_KEY, NANO_NO_KEY, NOVIEW, NULL);
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000974#endif
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000975#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000976
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000977#ifndef DISABLE_BROWSER
Chris Allegrettadab017e2002-04-23 10:56:06 +0000978 free_shortcutage(&browser_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000979
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000980 sc_init_one(&browser_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 Allegrettab3655b42001-10-22 03:15:31 +0000989
David Lawrence Ramsey8037fe02004-07-23 12:30:40 +0000990 sc_init_one(&browser_list, NANO_EXIT_KEY, exit_msg,
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000991 IFHELP(nano_exitbrowser_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000992 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000993
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000994 sc_init_one(&browser_list, NANO_PREVPAGE_KEY, prev_page_msg,
995 IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000996 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000997
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000998 sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, next_page_msg,
999 IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001000 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaf4b96012001-01-03 07:11:47 +00001001
Jordi Mallachf9390af2003-08-05 19:31:12 +00001002 /* Translators: try to keep this string under 22 characters long */
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +00001003 sc_init_one(&browser_list, NANO_GOTOLINE_KEY, N_("Go To Dir"),
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +00001004 IFHELP(nano_gotodir_msg, NANO_GOTOLINE_ALTKEY),
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001005 NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW, NULL);
Rocco Corsi12f294c2001-04-14 06:50:24 +00001006
Chris Allegrettadab017e2002-04-23 10:56:06 +00001007 free_shortcutage(&gotodir_list);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001008
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001009 sc_init_one(&gotodir_list, NANO_HELP_KEY, get_help_msg,
1010 IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
1011 NANO_NO_KEY, VIEW,
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +00001012#ifndef DISABLE_HELP
1013 do_help
1014#else
1015 nano_disabled_msg
1016#endif
1017 );
Chris Allegrettaf4b96012001-01-03 07:11:47 +00001018
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001019 sc_init_one(&gotodir_list, NANO_CANCEL_KEY, cancel_msg,
1020 IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001021 NANO_NO_KEY, VIEW, NULL);
Chris Allegrettaf4b96012001-01-03 07:11:47 +00001022#endif
1023
Chris Allegrettaa8c22572002-02-15 19:17:02 +00001024 currshortcut = main_list;
David Lawrence Ramsey35e97132005-01-08 06:04:19 +00001025
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001026#ifndef NANO_SMALL
Chris Allegrettadab017e2002-04-23 10:56:06 +00001027 toggle_init();
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001028#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +00001029}
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001030
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001031/* Deallocate the given shortcut. */
1032void free_shortcutage(shortcut **shortcutage)
1033{
1034 assert(shortcutage != NULL);
1035 while (*shortcutage != NULL) {
1036 shortcut *ps = *shortcutage;
1037 *shortcutage = (*shortcutage)->next;
1038 free(ps);
1039 }
1040}
1041
1042#ifndef NANO_SMALL
1043/* Create one new toggle structure, at the end of the toggles linked
1044 * list. */
1045void toggle_init_one(int val, const char *desc, long flag)
1046{
1047 toggle *u;
1048
1049 if (toggles == NULL) {
David Lawrence Ramsey94b975c2004-07-20 12:57:34 +00001050 toggles = (toggle *)nmalloc(sizeof(toggle));
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001051 u = toggles;
1052 } else {
1053 for (u = toggles; u->next != NULL; u = u->next)
1054 ;
David Lawrence Ramsey94b975c2004-07-20 12:57:34 +00001055 u->next = (toggle *)nmalloc(sizeof(toggle));
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001056 u = u->next;
1057 }
1058
1059 u->val = val;
1060 u->desc = _(desc);
1061 u->flag = flag;
1062 u->next = NULL;
1063}
1064
1065void toggle_init(void)
1066{
1067 /* There is no need to reinitialize the toggles. They can't
1068 * change. */
1069 if (toggles != NULL)
1070 return;
1071
1072 toggle_init_one(TOGGLE_NOHELP_KEY, N_("Help mode"), NO_HELP);
1073#ifdef ENABLE_MULTIBUFFER
1074 /* If we're using restricted mode, the multibuffer toggle is
1075 * disabled. It's useless since inserting files is disabled. */
1076 if (!ISSET(RESTRICTED))
David Lawrence Ramsey637b8bb2005-01-17 05:06:55 +00001077 toggle_init_one(TOGGLE_MULTIBUFFER_KEY,
1078 N_("Multiple file buffers"), MULTIBUFFER);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001079#endif
1080 toggle_init_one(TOGGLE_CONST_KEY, N_("Constant cursor position"),
1081 CONSTUPDATE);
David Lawrence Ramsey637b8bb2005-01-17 05:06:55 +00001082 toggle_init_one(TOGGLE_AUTOINDENT_KEY, N_("Auto indent"),
1083 AUTOINDENT);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001084#ifndef DISABLE_WRAPPING
1085 toggle_init_one(TOGGLE_WRAP_KEY, N_("Auto line wrap"), NO_WRAP);
1086#endif
1087 toggle_init_one(TOGGLE_CUTTOEND_KEY, N_("Cut to end"), CUT_TO_END);
1088 /* If we're using restricted mode, the suspend toggle is disabled.
1089 * It's useless since suspending is disabled. */
1090 if (!ISSET(RESTRICTED))
1091 toggle_init_one(TOGGLE_SUSPEND_KEY, N_("Suspend"), SUSPEND);
1092#ifndef DISABLE_MOUSE
1093 toggle_init_one(TOGGLE_MOUSE_KEY, N_("Mouse support"), USE_MOUSE);
1094#endif
David Lawrence Ramsey74835712004-12-04 17:41:52 +00001095 /* If we're using restricted mode, the DOS/Mac conversion toggle is
1096 * disabled. It's useless since inserting files is disabled. */
1097 if (!ISSET(RESTRICTED))
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001098 toggle_init_one(TOGGLE_NOCONVERT_KEY,
1099 N_("No conversion from DOS/Mac format"), NO_CONVERT);
David Lawrence Ramsey74835712004-12-04 17:41:52 +00001100 /* If we're using restricted mode, the backup toggle is disabled.
1101 * It's useless since backups are disabled. */
1102 if (!ISSET(RESTRICTED))
David Lawrence Ramsey637b8bb2005-01-17 05:06:55 +00001103 toggle_init_one(TOGGLE_BACKUP_KEY, N_("Backup files"),
1104 BACKUP_FILE);
1105 toggle_init_one(TOGGLE_SMOOTH_KEY, N_("Smooth scrolling"),
1106 SMOOTHSCROLL);
1107 toggle_init_one(TOGGLE_SMARTHOME_KEY, N_("Smart home key"),
1108 SMART_HOME);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001109#ifdef ENABLE_COLOR
1110 toggle_init_one(TOGGLE_SYNTAX_KEY, N_("Color syntax highlighting"),
1111 COLOR_SYNTAX);
1112#endif
1113#ifdef ENABLE_NANORC
1114 toggle_init_one(TOGGLE_WHITESPACE_KEY, N_("Whitespace display"),
1115 WHITESPACE_DISPLAY);
1116#endif
David Lawrence Ramsey637b8bb2005-01-17 05:06:55 +00001117 toggle_init_one(TOGGLE_MORESPACE_KEY, N_("Use of more space for editing"),
1118 MORE_SPACE);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001119}
1120
1121#ifdef DEBUG
1122/* Deallocate all of the toggles. */
1123void free_toggles(void)
1124{
1125 while (toggles != NULL) {
1126 toggle *pt = toggles; /* Think "previous toggle". */
1127
1128 toggles = toggles->next;
1129 free(pt);
1130 }
1131}
1132#endif
1133#endif /* !NANO_SMALL */
1134
Chris Allegretta6232d662002-05-12 19:52:15 +00001135/* This function is called just before calling exit(). Practically, the
1136 * only effect is to cause a segmentation fault if the various data
1137 * structures got bolloxed earlier. Thus, we don't bother having this
Chris Allegretta6df90f52002-07-19 01:08:59 +00001138 * function unless debugging is turned on. */
Chris Allegretta6232d662002-05-12 19:52:15 +00001139#ifdef DEBUG
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001140/* Added by SPK for memory cleanup; gracefully return our malloc()s. */
Chris Allegretta6df90f52002-07-19 01:08:59 +00001141void thanks_for_all_the_fish(void)
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001142{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001143 delwin(topwin);
1144 delwin(edit);
1145 delwin(bottomwin);
1146
Chris Allegretta7662c862003-01-13 01:35:15 +00001147#ifndef DISABLE_JUSTIFY
1148 if (quotestr != NULL)
1149 free(quotestr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001150#ifdef HAVE_REGEX_H
1151 regfree(&quotereg);
1152 free(quoteerr);
1153#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
1210#ifndef NANO_SMALL
1211 free_toggles();
1212#endif
1213
1214#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaf2387fb2002-04-10 02:31:20 +00001215 if (open_files != NULL) {
Chris Allegretta6232d662002-05-12 19:52:15 +00001216 /* We free the memory associated with each open file. */
Chris Allegrettace452fb2003-02-03 02:56:44 +00001217 while (open_files->prev != NULL)
1218 open_files = open_files->prev;
Chris Allegretta6df90f52002-07-19 01:08:59 +00001219 free_openfilestruct(open_files);
Chris Allegrettace452fb2003-02-03 02:56:44 +00001220 }
Chris Allegrettaf2387fb2002-04-10 02:31:20 +00001221#else
Chris Allegrettace452fb2003-02-03 02:56:44 +00001222 free_filestruct(fileage);
Chris Allegrettaf2387fb2002-04-10 02:31:20 +00001223#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +00001224
1225#ifdef ENABLE_COLOR
1226 free(syntaxstr);
1227 while (syntaxes != NULL) {
1228 syntaxtype *bill = syntaxes;
1229
1230 free(syntaxes->desc);
1231 while (syntaxes->extensions != NULL) {
1232 exttype *bob = syntaxes->extensions;
1233
1234 syntaxes->extensions = bob->next;
Chris Allegretta7662c862003-01-13 01:35:15 +00001235 regfree(&bob->val);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001236 free(bob);
1237 }
1238 while (syntaxes->color != NULL) {
1239 colortype *bob = syntaxes->color;
1240
1241 syntaxes->color = bob->next;
Chris Allegretta7662c862003-01-13 01:35:15 +00001242 regfree(&bob->start);
1243 if (bob->end != NULL)
Chris Allegrettace452fb2003-02-03 02:56:44 +00001244 regfree(bob->end);
1245 free(bob->end);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001246 free(bob);
1247 }
1248 syntaxes = syntaxes->next;
1249 free(bill);
1250 }
1251#endif /* ENABLE_COLOR */
Chris Allegretta5beed502003-01-05 20:41:21 +00001252#ifndef NANO_SMALL
1253 /* free history lists */
1254 free_history(&search_history);
1255 free_history(&replace_history);
1256#endif
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001257#ifdef ENABLE_NANORC
1258 free(homedir);
1259#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001260}
Chris Allegretta6232d662002-05-12 19:52:15 +00001261#endif /* DEBUG */