blob: e33fde0d9bdc79e5991493e4427bd10382d00457 [file] [log] [blame]
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001/* $Id$
2*/
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00003/**************************************************************************
4 * global.c *
5 * *
David Lawrence Ramseyd8a1d372007-10-11 05:01:32 +00006 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
7 * Free Software Foundation, Inc. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00008 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
David Lawrence Ramseyd0035b42007-08-11 05:17:36 +000010 * the Free Software Foundation; either version 3, or (at your option) *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000011 * any later version. *
12 * *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000013 * This program is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * General Public License for more details. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000017 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
21 * 02110-1301, USA. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000022 * *
23 **************************************************************************/
24
Chris Allegretta79a33bb2008-03-05 07:34:01 +000025#include <ctype.h>
26#include <strings.h>
27#include "assert.h"
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000028#include "proto.h"
29
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +000030/* Global variables. */
31#ifndef NANO_TINY
David Lawrence Ramsey1c5af642006-05-10 15:15:06 +000032sigjmp_buf jump_buf;
David Lawrence Ramseyb6fb6882006-11-27 07:28:52 +000033 /* Used to return to either main() or the unjustify routine in
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +000034 * do_justify() after a SIGWINCH. */
David Lawrence Ramsey1c5af642006-05-10 15:15:06 +000035bool jump_buf_main = FALSE;
36 /* Have we set jump_buf so that we return to main() after a
37 * SIGWINCH? */
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +000038#endif
39
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000040#ifndef DISABLE_WRAPJUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000041ssize_t fill = 0;
42 /* The column where we will wrap lines. */
David Lawrence Ramsey691698a2005-07-24 19:57:51 +000043ssize_t wrap_at = -CHARS_FROM_EOL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000044 /* The position where we will wrap lines. fill is equal to this
45 * if it's greater than zero, and equal to (COLS + this) if it
46 * isn't. */
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000047#endif
48
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000049char *last_search = NULL;
50 /* The last string we searched for. */
51char *last_replace = NULL;
52 /* The last replacement string we searched for. */
Chris Allegretta6df90f52002-07-19 01:08:59 +000053
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000054long flags = 0;
55 /* Our flag containing the states of all global options. */
56WINDOW *topwin;
57 /* The top portion of the window, where we display the version
58 * number of nano, the name of the current file, and whether the
59 * current file has been modified. */
60WINDOW *edit;
David Lawrence Ramseyb159f942006-07-28 17:06:27 +000061 /* The middle portion of the window, i.e. the edit window, where
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000062 * we display the current file we're editing. */
63WINDOW *bottomwin;
64 /* The bottom portion of the window, where we display statusbar
65 * messages, the statusbar prompt, and a list of shortcuts. */
66int editwinrows = 0;
67 /* How many rows does the edit window take up? */
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +000068
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000069filestruct *cutbuffer = NULL;
70 /* The buffer where we store cut text. */
David Lawrence Ramsey93c84052004-11-23 04:08:28 +000071#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000072filestruct *jusbuffer = NULL;
73 /* The buffer where we store unjustified text. */
David Lawrence Ramsey93c84052004-11-23 04:08:28 +000074#endif
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000075partition *filepart = NULL;
76 /* The partition where we store a portion of the current
77 * file. */
David Lawrence Ramsey64661ac2005-07-08 19:57:25 +000078openfilestruct *openfile = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000079 /* The list of all open file buffers. */
Chris Allegretta2d7893d2001-07-11 02:08:33 +000080
David Lawrence Ramseyd89617f2006-01-06 21:51:10 +000081#ifndef NANO_TINY
82char *matchbrackets = NULL;
83 /* The opening and closing brackets that can be found by bracket
84 * searches. */
85#endif
86
David Lawrence Ramseyebe34252005-11-15 03:17:35 +000087#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000088char *whitespace = NULL;
89 /* The characters used when displaying the first characters of
90 * tabs and spaces. */
91int whitespace_len[2];
92 /* The length of these characters. */
David Lawrence Ramsey89bb9372004-05-29 16:47:52 +000093#endif
94
Chris Allegrettae4f940d2002-03-03 22:36:36 +000095#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000096char *punct = NULL;
97 /* The closing punctuation that can end sentences. */
98char *brackets = NULL;
99 /* The closing brackets that can follow closing punctuation and
100 * can end sentences. */
101char *quotestr = NULL;
102 /* The quoting string. The default value is set in main(). */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000103#ifdef HAVE_REGEX_H
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000104regex_t quotereg;
105 /* The compiled regular expression from the quoting string. */
106int quoterc;
David Lawrence Ramsey88165642006-05-22 18:30:09 +0000107 /* Whether it was compiled successfully. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000108char *quoteerr = NULL;
109 /* The error message, if it didn't. */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000110#else
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000111size_t quotelen;
112 /* The length of the quoting string in bytes. */
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000113#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000114#endif
Chris Allegrettae4f940d2002-03-03 22:36:36 +0000115
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000116char *answer = NULL;
David Lawrence Ramsey6335fb52007-01-01 05:15:32 +0000117 /* The answer string used by the statusbar prompt. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000118
119ssize_t tabsize = -1;
120 /* The width of a tab in spaces. The default value is set in
121 * main(). */
122
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000123#ifndef NANO_TINY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000124char *backup_dir = NULL;
125 /* The directory where we store backup files. */
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000126#endif
Chris Allegrettae1f14522001-09-19 03:19:43 +0000127#ifndef DISABLE_OPERATINGDIR
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000128char *operating_dir = NULL;
129 /* The relative path to the operating directory, which we can't
130 * move outside of. */
131char *full_operating_dir = NULL;
132 /* The full path to it. */
Chris Allegrettae1f14522001-09-19 03:19:43 +0000133#endif
134
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000135#ifndef DISABLE_SPELLER
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000136char *alt_speller = NULL;
137 /* The command to use for the alternate spell checker. */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000138#endif
139
Chris Allegretta8ce24132001-04-30 11:28:46 +0000140#ifdef ENABLE_COLOR
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000141syntaxtype *syntaxes = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000142 /* The global list of color syntaxes. */
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000143char *syntaxstr = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000144 /* The color syntax name specified on the command line. */
Chris Allegretta8ce24132001-04-30 11:28:46 +0000145#endif
146
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000147const shortcut *currshortcut;
148 /* The current shortcut list we're using. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000149int currmenu;
150 /* The currently loaded menu */
151
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000152#ifndef NANO_TINY
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000153toggle *toggles = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000154 /* The global toggle list. */
Chris Allegrettaf0b26df2001-01-20 22:18:18 +0000155#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000156
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000157sc *sclist = NULL;
158 /* New shortcut key struct */
159subnfunc *allfuncs = NULL;
160 /* New struct for the function list */
161
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000162#ifndef NANO_TINY
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000163filestruct *search_history = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000164 /* The search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000165filestruct *searchage = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000166 /* The top of the search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000167filestruct *searchbot = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000168 /* The bottom of the search string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000169filestruct *replace_history = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000170 /* The replace string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000171filestruct *replaceage = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000172 /* The top of the replace string history list. */
David Lawrence Ramsey934f9682005-05-23 16:30:06 +0000173filestruct *replacebot = NULL;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000174 /* The bottom of the replace string history list. */
Chris Allegretta5beed502003-01-05 20:41:21 +0000175#endif
176
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +0000177/* Regular expressions. */
Chris Allegretta805c26d2000-09-06 13:39:17 +0000178#ifdef HAVE_REGEX_H
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000179regex_t search_regexp;
180 /* The compiled regular expression to use in searches. */
181regmatch_t regmatches[10];
182 /* The match positions for parenthetical subexpressions, 10
183 * maximum, used in regular expression searches. */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000184#endif
Chris Allegretta3533a342002-03-24 23:19:32 +0000185
David Lawrence Ramsey4d72de72006-04-12 15:27:40 +0000186int reverse_attr = A_REVERSE;
187 /* The curses attribute we use for reverse video. */
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000188
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000189char *homedir = NULL;
David Lawrence Ramseyc1c818e2006-05-14 18:22:01 +0000190 /* The user's home directory, from $HOME or /etc/passwd. */
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000191
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000192/* Return the number of entries in the shortcut list s for a given menu. */
193size_t length_of_list(int menu)
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000194{
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000195 subnfunc *f;
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000196 size_t i = 0;
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000197
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000198 for (f = allfuncs; f != NULL; f = f->next)
199 if ((f->menus & menu) != 0) {
200 i++;
201 }
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000202 return i;
203}
204
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000205/* Set type of function based on the string */
206function_type strtokeytype(char *str)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000207{
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000208 if (str[0] == 'M' || str[0] == 'm') {
209 return META;
210 } else if (str[0] == '^') {
211 return CONTROL;
212 } else if (str[0] == 'M' || str[0] == 'm') {
213 return FKEY;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000214 } else {
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000215 return RAW;
216 }
217}
218
219/* Add a string to the new function list strict.
220 Does not allow updates, yet anyway */
221void add_to_funcs(void *func, int menus, const char *desc, const char *help,
222 bool blank_after, bool viewok)
223{
224 subnfunc *f;
225
226 if (allfuncs == NULL) {
227 allfuncs = nmalloc(sizeof(subnfunc));
228 f = allfuncs;
229 } else {
230 for (f = allfuncs; f->next != NULL; f = f->next)
231 ;
232 f->next = (subnfunc *)nmalloc(sizeof(subnfunc));
233 f = f->next;
234 }
235 f->next = NULL;
236 f->scfunc = func;
237 f->menus = menus;
238 f->desc = desc;
239 f->viewok = viewok;
240#ifndef NANO_TINY
241 f->help = help;
242 f->blank_after = blank_after;
243#endif
244
245#ifdef DEBUG
246 fprintf(stderr, "Added func \"%s\"", f->desc);
247#endif
248}
249
250const sc *first_sc_for(int menu, void *func) {
251 const sc *s;
252
253 for (s = sclist; s != NULL; s = s->next) {
254 if ((s->menu & menu) && s->scfunc == func) {
255 return s;
256 }
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000257 }
258
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000259#ifdef DEBUG
260 fprintf(stderr, "Whoops, returning null given func %ld\n", (long) func);
David Lawrence Ramseybd28ee42006-07-25 21:13:30 +0000261#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000262 /* Otherwise... */
263 return NULL;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000264}
265
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000266
267/* Add a string to the new shortcut list implementation
268 Allows updates to existing entries in the list */
269void add_to_sclist(int menu, char *scstring, void *func, int toggle, int execute)
270{
271 sc *s;
272
273 if (sclist == NULL) {
274 sclist = nmalloc(sizeof(sc));
275 s = sclist;
276 s->next = NULL;
277 } else {
278 for (s = sclist; s->next != NULL; s = s->next)
279 if (s->menu == menu && s->keystr == scstring)
280 break;
281
282 if (s->menu != menu || s->keystr != scstring) { /* i.e. this is not a replace... */
283#ifdef DEBUG
284 fprintf(stderr, "No match found...\n");
285#endif
286 s->next = (sc *)nmalloc(sizeof(sc));
287 s = s->next;
288 s->next = NULL;
289 }
290 }
291
292 s->type = strtokeytype(scstring);
293 s->menu = menu;
294 s->toggle = toggle;
295 s->keystr = scstring;
296 s->scfunc = func;
297 s->execute = execute;
298 assign_keyinfo(s);
299
300#ifdef DEBUG
301 fprintf(stderr, "list val = %d\n", (int) s->menu);
302 fprintf(stderr, "Hey, set sequence to %d for shortcut \"%s\"\n", s->seq, scstring);
303#endif
304}
305
306/* Assign the info to the shortcut struct
307 Assumes keystr is already assigned, naturally */
308void assign_keyinfo(sc *s)
309{
310 if (s->type == CONTROL) {
311 assert(strlen(s->keystr) > 1);
312 s->seq = s->keystr[1] - 64;
313 } else if (s->type == META) {
314 assert(strlen(s->keystr) > 2);
315 s->seq = tolower((int) s->keystr[2]);
316 } else if (s->type == FKEY) {
317 assert(strlen(s->keystr) > 1);
318 s->seq = KEY_F0 + atoi(&s->keystr[1]);
319 } else /* raw */
320 s->seq = (int) s->keystr[0];
321}
322
323#ifdef DEBUG
324
325void print_sclist(void)
326{
327 sc *s;
328 const subnfunc *f;
329
330 for (s = sclist; s->next != NULL; s = s->next) {
331 f = sctofunc(s);
332 if (f)
333 fprintf(stderr, "Shortcut \"%s\", function: %s\n", s->keystr, f->desc);
334 else
335 fprintf(stderr, "Hmm, didnt find a func for \"%s\"\n", s->keystr);
336 }
337
338}
339#endif
340
341
342/* Stuff we need to make at least static here so we can access it below */
343const char *cancel_msg = N_("Cancel");
344
345#ifndef NANO_TINY
346const char *case_sens_msg = N_("Case Sens");
347const char *backwards_msg = N_("Backwards");
348#endif
349
350#ifdef HAVE_REGEX_H
351const char *regexp_msg = N_("Regexp");
352#endif
353
354/* Stuff we want to just stun out if we're in TINY mode */
355#ifdef NANO_TINY
356const char *nano_cancel_msg = "";
357const char *nano_exit_msg = "";
358const char *nano_writeout_msg = "";
359const char *nano_insert_msg = "";
360const char *nano_whereis_msg = "";
361const char *nano_prevpage_msg = "";
362const char *nano_nextpage_msg = "";
363const char *nano_cut_msg = "";
364const char *nano_uncut_msg = "";
365const char *nano_cursorpos_msg = "";
366const char *nano_lastline_msg = "";
367const char *nano_gotoline_msg = "";
368const char *nano_replace_msg = "";
369const char *nano_forward_msg = "";
370const char *nano_back_msg = "";
371const char *nano_prevline_msg = "";
372const char *nano_nextline_msg = "";
373const char *nano_home_msg = "";
374const char *nano_end_msg = "";
375const char *nano_verbatim_msg = "";
376const char *nano_tab_msg = "";
377const char *nano_enter_msg = "";
378const char *nano_delete_msg = "";
379const char *nano_backspace_msg = "";
380const char *nano_regexp_msg = "";
381const char *gototext_msg = "";
382const char *do_para_begin_void = "";
383const char *do_para_end_void = "";
384const char *case_sens_msg = "";
385const char *backwards_msg = "";
386const char *do_cut_till_end = "";
387const char *dos_format_msg = "";
388const char *mac_format_msg = "";
389const char *append_msg = "";
390const char *prepend_msg = "";
391const char *backup_file_msg = "";
392const char *to_files_msg = "";
393#else /* NANO_TINY */
394const char *prev_history_msg = N_("PrevHstory");
395/* TRANSLATORS: Try to keep this and previous strings at most 10
396 * characters. */
397const char *next_history_msg = N_("NextHstory");
398const char *replace_msg = N_("Replace");
399const char *no_replace_msg = N_("No Replace");
400const char *go_to_line_msg = N_("Go To Line");
401const char *gototext_msg = N_("Go To Text");
402#ifndef DISABLE_BROWSER
403/* TRANSLATORS: Try to keep this at most 16 characters. */
404const char *to_files_msg = N_("To Files");
405/* TRANSLATORS: Try to keep this at most 12 characters. */
406const char *first_file_msg = N_("First File");
407/* TRANSLATORS: Try to keep this at most 12 characters. */
408const char *last_file_msg = N_("Last File");
409#endif
410/* TRANSLATORS: Try to keep this at most 16 characters. */
411const char *dos_format_msg = N_("DOS Format");
412/* TRANSLATORS: Try to keep this at most 16 characters. */
413const char *mac_format_msg = N_("Mac Format");
414/* TRANSLATORS: Try to keep this at most 16 characters. */
415const char *append_msg = N_("Append");
416/* TRANSLATORS: Try to keep this at most 16 characters. */
417const char *prepend_msg = N_("Prepend");
418/* TRANSLATORS: Try to keep this at most 16 characters. */
419const char *backup_file_msg = N_("Backup File");
420
421#ifdef ENABLE_MULTIBUFFER
422/* TRANSLATORS: Try to keep this at most 16 characters. */
423const char *new_buffer_msg = N_("New Buffer");
424#endif
425
426#endif
427
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000428/* Initialize all shortcut lists. If unjustify is TRUE, replace the
429 * Uncut shortcut in the main shortcut list with UnJustify. */
David Lawrence Ramsey1f1ebb82004-11-11 21:50:01 +0000430void shortcut_init(bool unjustify)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000431{
David Lawrence Ramseyed467e52006-07-03 18:40:53 +0000432 /* TRANSLATORS: Try to keep this and following strings at most 10
433 * characters. */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000434 const char *get_help_msg = N_("Get Help");
435 const char *exit_msg = N_("Exit");
David Lawrence Ramseye38b8082006-03-30 07:03:04 +0000436 const char *whereis_msg = N_("Where Is");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000437 const char *prev_page_msg = N_("Prev Page");
438 const char *next_page_msg = N_("Next Page");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000439 /* TRANSLATORS: Try to keep this string at most 10 characters. */
440
David Lawrence Ramseye38b8082006-03-30 07:03:04 +0000441#ifndef NANO_TINY
David Lawrence Ramsey0ec909c2006-05-06 15:07:26 +0000442 /* TRANSLATORS: Try to keep this at most 12 characters. */
443 const char *whereis_next_msg = N_("WhereIs Next");
David Lawrence Ramseye38b8082006-03-30 07:03:04 +0000444#endif
David Lawrence Ramseyed467e52006-07-03 18:40:53 +0000445 /* TRANSLATORS: Try to keep this and following strings at most 10
446 * characters. */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000447 const char *first_line_msg = N_("First Line");
448 const char *last_line_msg = N_("Last Line");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000449#ifndef DISABLE_JUSTIFY
450 const char *beg_of_par_msg = N_("Beg of Par");
451 const char *end_of_par_msg = N_("End of Par");
452 const char *fulljstify_msg = N_("FullJstify");
453#endif
David Lawrence Ramsey81378762006-04-24 20:53:43 +0000454 const char *refresh_msg = N_("Refresh");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000455 const char *insert_file_msg = N_("Insert File");
456 const char *goto_dir_msg = N_("Go To Dir");
457 const char *ext_cmd_msg = N_("Execute Command");
458
Chris Allegrettadab017e2002-04-23 10:56:06 +0000459#ifndef DISABLE_HELP
David Lawrence Ramsey804e1072006-03-29 19:43:32 +0000460 const char *nano_cancel_msg = N_("Cancel the current function");
David Lawrence Ramsey57c9afb2006-04-14 20:21:45 +0000461 const char *nano_help_msg = N_("Display this help text");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000462 const char *nano_exit_msg =
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000463#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000464 N_("Close the current file buffer / Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000465#else
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000466 N_("Exit from nano")
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000467#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000468 ;
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000469 const char *nano_writeout_msg =
470 N_("Write the current file to disk");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000471 const char *nano_justify_msg = N_("Justify the current paragraph");
472 const char *nano_insert_msg =
473 N_("Insert another file into the current one");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000474 const char *nano_whereis_msg =
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000475 N_("Search for a string or a regular expression");
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000476 const char *nano_prevpage_msg = N_("Go to previous screen");
477 const char *nano_nextpage_msg = N_("Go to next screen");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000478 const char *nano_cut_msg =
479 N_("Cut the current line and store it in the cutbuffer");
480 const char *nano_uncut_msg =
481 N_("Uncut from the cutbuffer into the current line");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000482 const char *nano_cursorpos_msg =
David Lawrence Ramseyf50bd4b2006-04-14 20:15:44 +0000483 N_("Display the position of the cursor");
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000484 const char *nano_spell_msg =
485 N_("Invoke the spell checker, if available");
David Lawrence Ramseybe231d32006-05-21 21:37:21 +0000486 const char *nano_replace_msg =
487 N_("Replace a string or a regular expression");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000488 const char *nano_gotoline_msg = N_("Go to line and column number");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000489#ifndef NANO_TINY
David Lawrence Ramsey8381fdd2004-11-01 22:40:02 +0000490 const char *nano_mark_msg = N_("Mark text at the cursor position");
491 const char *nano_whereis_next_msg = N_("Repeat last search");
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000492 const char *nano_copy_msg =
493 N_("Copy the current line and store it in the cutbuffer");
David Lawrence Ramseyaee00d42006-07-05 18:42:22 +0000494 const char *nano_indent_msg = N_("Indent the current line");
495 const char *nano_unindent_msg = N_("Unindent the current line");
David Lawrence Ramsey4b4b6082004-11-01 22:54:40 +0000496#endif
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000497 const char *nano_forward_msg = N_("Go forward one character");
498 const char *nano_back_msg = N_("Go back one character");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000499#ifndef NANO_TINY
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000500 const char *nano_nextword_msg = N_("Go forward one word");
501 const char *nano_prevword_msg = N_("Go back one word");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000502#endif
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000503 const char *nano_prevline_msg = N_("Go to previous line");
504 const char *nano_nextline_msg = N_("Go to next line");
505 const char *nano_home_msg = N_("Go to beginning of current line");
506 const char *nano_end_msg = N_("Go to end of current line");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000507#ifndef DISABLE_JUSTIFY
508 const char *nano_parabegin_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000509 N_("Go to beginning of paragraph; then of previous paragraph");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000510 const char *nano_paraend_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000511 N_("Go just beyond end of paragraph; then of next paragraph");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000512#endif
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000513 const char *nano_firstline_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000514 N_("Go to the first line of the file");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000515 const char *nano_lastline_msg =
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000516 N_("Go to the last line of the file");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000517#ifndef NANO_TINY
David Lawrence Ramsey9f1db5d2007-02-01 13:40:59 +0000518 const char *nano_bracket_msg = N_("Go to the matching bracket");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000519 const char *nano_scrollup_msg =
520 N_("Scroll up one line without scrolling the cursor");
521 const char *nano_scrolldown_msg =
522 N_("Scroll down one line without scrolling the cursor");
523#endif
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000524#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +0000525 const char *nano_prevfile_msg =
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000526 N_("Switch to the previous file buffer");
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +0000527 const char *nano_nextfile_msg =
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000528 N_("Switch to the next file buffer");
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000529#endif
David Lawrence Ramsey40e05722006-04-23 19:21:12 +0000530 const char *nano_verbatim_msg =
David Lawrence Ramsey939d4232006-04-24 21:00:17 +0000531 N_("Insert the next keystroke verbatim");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000532 const char *nano_tab_msg =
David Lawrence Ramseybf784202006-04-29 13:59:04 +0000533 N_("Insert a tab at the cursor position");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000534 const char *nano_enter_msg =
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000535 N_("Insert a newline at the cursor position");
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000536 const char *nano_delete_msg =
537 N_("Delete the character under the cursor");
538 const char *nano_backspace_msg =
539 N_("Delete the character to the left of the cursor");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000540#ifndef NANO_TINY
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000541 const char *nano_cut_till_end_msg =
542 N_("Cut from the cursor position to the end of the file");
543#endif
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000544#ifndef DISABLE_JUSTIFY
545 const char *nano_fulljustify_msg = N_("Justify the entire file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000546#endif
David Lawrence Ramseyc5c52302005-11-15 23:45:29 +0000547#ifndef NANO_TINY
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000548 const char *nano_wordcount_msg =
549 N_("Count the number of words, lines, and characters");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000550#endif
David Lawrence Ramsey854a44a2006-04-24 21:14:55 +0000551 const char *nano_refresh_msg =
552 N_("Refresh (redraw) the current screen");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000553#ifndef NANO_TINY
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000554 const char *nano_case_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000555 N_("Toggle the case sensitivity of the search");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000556 const char *nano_reverse_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000557 N_("Reverse the direction of the search");
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000558#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000559#ifdef HAVE_REGEX_H
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000560 const char *nano_regexp_msg =
561 N_("Toggle the use of regular expressions");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000562#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000563#ifndef NANO_TINY
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000564 const char *nano_prev_history_msg =
David Lawrence Ramsey7b0531a2006-07-31 01:30:31 +0000565 N_("Recall the previous search/replace string");
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000566 const char *nano_next_history_msg =
David Lawrence Ramsey7b0531a2006-07-31 01:30:31 +0000567 N_("Recall the next search/replace string");
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000568#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000569#ifndef DISABLE_BROWSER
570 const char *nano_tofiles_msg = N_("Go to file browser");
571#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000572#ifndef NANO_TINY
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000573 const char *nano_dos_msg = N_("Toggle the use of DOS format");
574 const char *nano_mac_msg = N_("Toggle the use of Mac format");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000575#endif
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000576 const char *nano_append_msg = N_("Toggle appending");
577 const char *nano_prepend_msg = N_("Toggle prepending");
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000578#ifndef NANO_TINY
David Lawrence Ramsey9b108c22005-06-06 18:38:16 +0000579 const char *nano_backup_msg =
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000580 N_("Toggle backing up of the original file");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000581 const char *nano_execute_msg = N_("Execute external command");
582#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000583#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
David Lawrence Ramsey69e1ce52006-06-08 02:37:45 +0000584 const char *nano_multibuffer_msg =
585 N_("Toggle the use of a new buffer");
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000586#endif
587#ifndef DISABLE_BROWSER
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000588 const char *nano_exitbrowser_msg = N_("Exit from the file browser");
David Lawrence Ramseye38b8082006-03-30 07:03:04 +0000589 const char *nano_firstfile_msg =
590 N_("Go to the first file in the list");
591 const char *nano_lastfile_msg =
592 N_("Go to the last file in the list");
David Lawrence Ramseyc41d4282004-07-23 12:51:40 +0000593 const char *nano_gotodir_msg = N_("Go to directory");
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000594
Chris Allegretta2bef1822001-09-28 19:53:11 +0000595#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000596#endif /* !DISABLE_HELP */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000597
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000598#ifndef DISABLE_HELP
David Lawrence Ramseybd28ee42006-07-25 21:13:30 +0000599#define IFSCHELP(help, blank, nextvar) help, blank, nextvar
David Lawrence Ramseyea43a1d2004-03-02 22:52:57 +0000600#else
David Lawrence Ramseybd28ee42006-07-25 21:13:30 +0000601#define IFSCHELP(help, blank, nextvar) nextvar
Chris Allegrettadab017e2002-04-23 10:56:06 +0000602#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000603
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000604 while (allfuncs != NULL) {
605 subnfunc *f = allfuncs;
606 allfuncs = (allfuncs)->next;
607 free(f);
608 }
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000609
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000610#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000611 add_to_funcs(do_help_void, MALL, get_help_msg, nano_help_msg,
612 FALSE, VIEW);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000613#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000614
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000615 add_to_funcs((void *) cancel_msg,
616 (MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR),
617 cancel_msg, nano_cancel_msg, FALSE, VIEW);
618
619 add_to_funcs(do_exit, MMAIN,
Chris Allegretta355fbe52001-07-14 19:32:47 +0000620#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000621 /* TRANSLATORS: Try to keep this at most 10 characters. */
David Lawrence Ramsey017dde22006-03-24 05:28:03 +0000622 openfile != NULL && openfile != openfile->next ? N_("Close") :
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000623#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000624 exit_msg, nano_exit_msg, FALSE, VIEW);
625
626 add_to_funcs(do_exit, MBROWSER|MHELP, exit_msg, nano_exit_msg, FALSE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000627
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000628 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000629 add_to_funcs(do_writeout_void, MMAIN, N_("WriteOut"),
630 nano_writeout_msg, FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000631
David Lawrence Ramseya539fce2004-06-29 00:43:56 +0000632#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000633 /* TRANSLATORS: Try to keep this at most 10 characters. */
634 add_to_funcs(do_justify_void, MMAIN, N_("Justify"),
635 nano_justify_msg, TRUE, NOVIEW);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000636#endif
Chris Allegretta32da4562002-01-02 15:12:21 +0000637
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000638 /* We allow inserting files in view mode if multibuffers are
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000639 * available, so that we can view multiple files. If we're using
640 * restricted mode, inserting files is disabled, since it allows
641 * reading from or writing to files not specified on the command
642 * line. */
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000643 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000644 add_to_funcs(!ISSET(RESTRICTED) ? do_insertfile_void : nano_disabled_msg,
645 MMAIN, N_("Read File"), nano_insert_msg, FALSE,
Chris Allegretta32da4562002-01-02 15:12:21 +0000646#ifdef ENABLE_MULTIBUFFER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000647 VIEW);
Chris Allegretta32da4562002-01-02 15:12:21 +0000648#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000649 NOVIEW);
Chris Allegretta32da4562002-01-02 15:12:21 +0000650#endif
Chris Allegrettaaf6414a2001-02-11 19:05:05 +0000651
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000652 add_to_funcs(do_search, MMAIN, whereis_msg,
653 nano_whereis_msg, FALSE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000654
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000655 add_to_funcs(do_page_up, (MMAIN|MHELP|MBROWSER),
656 prev_page_msg, nano_prevpage_msg, FALSE, VIEW);
657 add_to_funcs(do_page_down, (MMAIN|MHELP|MBROWSER),
658 next_page_msg, nano_nextpage_msg, TRUE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000659
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000660 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000661 add_to_funcs(do_cut_text_void, MMAIN, N_("Cut Text"), nano_cut_msg,
662 FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000663
Chris Allegretta07798352000-11-27 22:58:23 +0000664 if (unjustify)
David Lawrence Ramseyed467e52006-07-03 18:40:53 +0000665 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000666 add_to_funcs(do_uncut_text, MMAIN, N_("UnJustify"), "",
667 FALSE, NOVIEW);
668
Chris Allegretta07798352000-11-27 22:58:23 +0000669 else
David Lawrence Ramseyed467e52006-07-03 18:40:53 +0000670 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000671 add_to_funcs(do_uncut_text, MMAIN, N_("UnCut Text"), nano_uncut_msg,
672 FALSE, NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000673
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000674 /* TRANSLATORS: Try to keep this at most 10 characters. */
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000675 add_to_funcs(do_cursorpos_void, MMAIN, N_("Cur Pos"), nano_cursorpos_msg,
676 FALSE, VIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000677
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000678 /* If we're using restricted mode, spell checking is disabled
679 * because it allows reading from or writing to files not specified
680 * on the command line. */
David Lawrence Ramseycde90392006-04-09 18:27:42 +0000681 /* TRANSLATORS: Try to keep this at most 10 characters. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000682#ifndef DISABLE_SPELLER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000683 if (!ISSET(RESTRICTED))
684 add_to_funcs(do_spell, MMAIN, N_("To Spell"), nano_spell_msg,
685 TRUE, NOVIEW);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000686#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000687
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000688 add_to_funcs(do_first_line,
689 (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP),
690 first_line_msg, first_line_msg, FALSE, VIEW);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000691
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000692 add_to_funcs(do_last_line,
693 (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP),
694 last_line_msg, nano_lastline_msg, TRUE, VIEW);
695
696
697 add_to_funcs(do_gotolinecolumn_void, (MMAIN|MWHEREIS),
698 go_to_line_msg, nano_gotoline_msg, FALSE, VIEW);
699
700 add_to_funcs(do_replace, (MMAIN|MWHEREIS), replace_msg, nano_replace_msg,
701
David Lawrence Ramseyf1e56272006-05-22 18:28:20 +0000702#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000703 FALSE,
David Lawrence Ramseyf1e56272006-05-22 18:28:20 +0000704#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000705 TRUE,
David Lawrence Ramseyf1e56272006-05-22 18:28:20 +0000706#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000707 NOVIEW);
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000708
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000709#ifndef NANO_TINY
David Lawrence Ramseyefb4b0a2006-04-19 14:09:01 +0000710
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000711 add_to_funcs(do_mark, MMAIN, N_("Mark Text"),
712 nano_mark_msg, FALSE, VIEW);
David Lawrence Ramseycf1879b2006-04-27 23:39:49 +0000713
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000714 add_to_funcs(do_research, (MMAIN|MBROWSER), whereis_next_msg,
715 nano_whereis_next_msg, TRUE, VIEW);
David Lawrence Ramseyf85001a2006-04-28 13:19:56 +0000716
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000717 add_to_funcs(do_copy_text, MMAIN, N_("Copy Text"),
718 nano_copy_msg, FALSE, NOVIEW);
David Lawrence Ramseyf85001a2006-04-28 13:19:56 +0000719
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000720 add_to_funcs(do_indent_void, MMAIN, N_("Indent Text"),
721 nano_indent_msg, FALSE, NOVIEW);
722
723 add_to_funcs(do_unindent, MMAIN, N_("Unindent Text"),
724 nano_unindent_msg, TRUE, NOVIEW);
725
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000726#endif
727
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000728
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000729 add_to_funcs(do_right, MMAIN, N_("Forward"), nano_forward_msg,
730 FALSE, VIEW);
731
732 add_to_funcs(do_left, MMAIN, N_("Back"), nano_back_msg,
733 FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000734
735#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000736 add_to_funcs(do_next_word_void, MMAIN, N_("Next Word"),
737 nano_nextword_msg, FALSE, VIEW);
David Lawrence Ramseyc5967552002-06-21 03:20:06 +0000738
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000739 add_to_funcs(do_prev_word_void, MMAIN, N_("Prev Word"),
740 nano_prevword_msg, FALSE, VIEW);
Chris Allegretta8d990b52001-09-22 22:14:25 +0000741#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000742
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000743 add_to_funcs(do_up_void, (MMAIN|MHELP), N_("Prev Line"),
744 nano_prevline_msg, FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000745
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000746 add_to_funcs(do_down_void, (MMAIN|MHELP), N_("Next Line"),
747 nano_nextline_msg, TRUE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000748
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000749 add_to_funcs(do_home, MMAIN, N_("Home"), nano_home_msg,
750 FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000751
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000752 add_to_funcs(do_end, MMAIN, N_("End"), nano_end_msg,
753 FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000754
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000755#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000756 add_to_funcs(do_para_begin_void, (MMAIN|MWHEREIS), beg_of_par_msg,
757 nano_parabegin_msg, FALSE, VIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000758
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000759 add_to_funcs(do_para_end_void, (MMAIN|MWHEREIS), end_of_par_msg,
760 nano_paraend_msg, FALSE, VIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000761#endif
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000762
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000763#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000764 add_to_funcs(do_find_bracket, MMAIN, _("Find Other Bracket"),
765 nano_bracket_msg, FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000766
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000767 add_to_funcs(do_scroll_up, MMAIN, N_("Scroll Up"),
768 nano_scrollup_msg, FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000769
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000770 add_to_funcs(do_scroll_down, MMAIN, N_("Scroll Down"),
771 nano_scrolldown_msg, FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000772#endif
David Lawrence Ramseydf453652006-04-21 02:05:09 +0000773
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000774#ifdef ENABLE_MULTIBUFFER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000775 add_to_funcs(switch_to_prev_buffer_void, MMAIN, _("Previous File"),
776 nano_prevfile_msg, FALSE, VIEW);
777 add_to_funcs(switch_to_next_buffer_void, MMAIN, N_("Next File"),
778 nano_nextfile_msg, TRUE, VIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000779#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +0000780
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000781 add_to_funcs(do_verbatim_input, MMAIN, N_("Verbatim Input"),
782 nano_verbatim_msg, FALSE, NOVIEW);
783 add_to_funcs(do_tab, MMAIN, N_("Tab"), nano_tab_msg,
784 FALSE, NOVIEW);
785 add_to_funcs(do_enter, MMAIN, N_("Enter"), nano_enter_msg,
786 FALSE, NOVIEW);
787 add_to_funcs(do_delete, MMAIN, N_("Delete"), nano_delete_msg,
788 FALSE, NOVIEW);
789 add_to_funcs(do_backspace, MMAIN, N_("Backspace"), nano_backspace_msg,
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000790#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000791 FALSE,
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000792#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000793 TRUE,
David Lawrence Ramseybf487982006-04-24 20:50:52 +0000794#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000795 VIEW);
David Lawrence Ramsey295d1722005-01-01 07:43:32 +0000796
David Lawrence Ramsey2ca23562006-04-23 19:15:15 +0000797#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000798 add_to_funcs(do_cut_till_end, MMAIN, N_("CutTillEnd"),
799 nano_cut_till_end_msg, TRUE, NOVIEW);
David Lawrence Ramsey2ca23562006-04-23 19:15:15 +0000800#endif
801
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000802 add_to_funcs(xon_complaint, MMAIN, "", "", FALSE, VIEW);
803 add_to_funcs(xoff_complaint, MMAIN, "", "", FALSE, VIEW);
804
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000805#ifndef DISABLE_JUSTIFY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000806 add_to_funcs(do_full_justify, (MMAIN|MWHEREIS), fulljstify_msg,
807 nano_fulljustify_msg, FALSE, NOVIEW);
David Lawrence Ramseydb6015c2004-09-11 21:41:13 +0000808#endif
809
David Lawrence Ramseyc5c52302005-11-15 23:45:29 +0000810#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000811 add_to_funcs(do_wordlinechar_count, MMAIN, N_("Word Count"),
812 nano_wordcount_msg, FALSE, VIEW);
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000813#endif
David Lawrence Ramseyefb4b0a2006-04-19 14:09:01 +0000814
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000815 add_to_funcs(total_refresh, (MMAIN|MHELP), refresh_msg, refresh_msg,
David Lawrence Ramsey03252d42006-04-22 20:00:23 +0000816#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000817 TRUE,
David Lawrence Ramsey03252d42006-04-22 20:00:23 +0000818#else
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000819 FALSE,
David Lawrence Ramsey03252d42006-04-22 20:00:23 +0000820#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000821 VIEW);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000822
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000823#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000824 add_to_funcs((void *) case_sens_msg,
825 (MWHEREIS|MREPLACE|MWHEREISFILE),
826 case_sens_msg, nano_case_msg, FALSE, VIEW);
Chris Allegretta658399a2001-06-14 02:54:22 +0000827
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000828 add_to_funcs((void *) backwards_msg,
829 (MWHEREIS|MREPLACE|MWHEREISFILE),
830 backwards_msg, nano_reverse_msg, FALSE, VIEW);
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000831#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000832
Chris Allegretta658399a2001-06-14 02:54:22 +0000833#ifdef HAVE_REGEX_H
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000834 add_to_funcs((void *) regexp_msg,
835 (MWHEREIS|MREPLACE|MWHEREISFILE),
836 regexp_msg, nano_regexp_msg, FALSE, VIEW);
Chris Allegretta658399a2001-06-14 02:54:22 +0000837#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000838
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000839#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000840 add_to_funcs((void *) prev_history_msg,
841 (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE),
842 prev_history_msg, nano_prev_history_msg, FALSE, VIEW);
David Lawrence Ramsey305d8892006-05-24 19:48:03 +0000843
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000844 add_to_funcs((void *) next_history_msg,
845 (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE),
846 next_history_msg, nano_next_history_msg, FALSE, VIEW);
David Lawrence Ramseyc10d8ff2005-06-03 20:51:39 +0000847#endif
David Lawrence Ramsey02085d72004-11-07 16:04:18 +0000848
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000849 add_to_funcs((void *) no_replace_msg, MREPLACE,
850 no_replace_msg, nano_whereis_msg, FALSE, VIEW);
Chris Allegretta5f36c372001-07-16 00:48:53 +0000851
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000852 add_to_funcs((void *) gototext_msg, MGOTOLINE,
853 gototext_msg, nano_whereis_msg, FALSE, VIEW);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000854
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000855#ifndef DISABLE_BROWSER
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000856 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000857 add_to_funcs((void *) to_files_msg,
858 (MGOTOLINE|MINSERTFILE),
859 to_files_msg, nano_tofiles_msg, FALSE, VIEW);
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000860#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000861
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000862#ifndef NANO_TINY
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000863 /* If we're using restricted mode, the DOS format, Mac format,
864 * append, prepend, and backup toggles are disabled. The first and
865 * second are useless since inserting files is disabled, the third
866 * and fourth are disabled because they allow writing to files not
867 * specified on the command line, and the fifth is useless since
868 * backups are disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000869 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000870 add_to_funcs((void *) dos_format_msg, MWRITEFILE,
871 dos_format_msg, nano_dos_msg, FALSE, NOVIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000872
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000873 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000874 add_to_funcs((void *) mac_format_msg, MWRITEFILE,
875 mac_format_msg, nano_mac_msg, FALSE, NOVIEW);
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000876
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000877 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000878 add_to_funcs((void *) append_msg, MWRITEFILE,
879 append_msg, nano_append_msg, FALSE, NOVIEW);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000880
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000881 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000882 add_to_funcs((void *) prepend_msg, MWRITEFILE,
883 prepend_msg, nano_prepend_msg, FALSE, NOVIEW);
Chris Allegretta0e9b7aa2002-04-16 03:15:47 +0000884
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000885 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000886 add_to_funcs((void *) backup_file_msg, MWRITEFILE,
887 backup_file_msg, nano_backup_msg, FALSE, NOVIEW);
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000888#endif
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000889
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000890#ifndef NANO_TINY
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000891 /* If we're using restricted mode, command execution is disabled.
892 * It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000893 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000894 add_to_funcs((void *) ext_cmd_msg, MINSERTFILE,
895 ext_cmd_msg, nano_execute_msg, FALSE, NOVIEW);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000896
Chris Allegrettaf7c68112002-09-03 22:58:40 +0000897#ifdef ENABLE_MULTIBUFFER
David Lawrence Ramsey32e3b882004-05-29 01:20:17 +0000898 /* If we're using restricted mode, the multibuffer toggle is
899 * disabled. It's useless since inserting files is disabled. */
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000900 if (!ISSET(RESTRICTED))
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000901 add_to_funcs((void *) new_buffer_msg, MWRITEFILE,
902 new_buffer_msg, nano_multibuffer_msg, FALSE, NOVIEW);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000903#endif
Chris Allegrettacc197ef2001-05-29 04:21:44 +0000904
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000905 add_to_funcs((void *) insert_file_msg, MEXTCMD,
906 insert_file_msg, nano_insert_msg, FALSE, VIEW);
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000907
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000908#ifdef ENABLE_MULTIBUFFER
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000909 add_to_funcs((void *) new_buffer_msg, MEXTCMD,
910 new_buffer_msg, nano_multibuffer_msg, FALSE, NOVIEW);
Chris Allegretta52c5a6e2002-03-21 05:07:28 +0000911#endif
David Lawrence Ramsey47e82b12004-09-28 22:21:46 +0000912#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000913
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000914#ifndef DISABLE_HELP
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000915 add_to_funcs((void *) refresh_msg, MHELP,
916 refresh_msg, nano_refresh_msg, FALSE, VIEW);
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000917#endif
918
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000919#ifndef DISABLE_BROWSER
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000920
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000921 add_to_funcs((void *) first_file_msg,
922 (MBROWSER|MWHEREISFILE),
923 first_file_msg, nano_firstfile_msg, FALSE, VIEW);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000924
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000925 add_to_funcs((void *) last_file_msg,
926 (MBROWSER|MWHEREISFILE),
927 last_file_msg, nano_lastfile_msg, FALSE, VIEW);
Chris Allegrettab3655b42001-10-22 03:15:31 +0000928
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000929 add_to_funcs((void *) goto_dir_msg, MBROWSER,
930 goto_dir_msg, nano_gotodir_msg, FALSE, VIEW);
David Lawrence Ramseye38b8082006-03-30 07:03:04 +0000931#endif
932
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000933 currmenu = MMAIN;
David Lawrence Ramsey35e97132005-01-08 06:04:19 +0000934
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000935#ifndef NANO_TINY
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000936 add_to_sclist(MALL, "^G", do_help_void, 0, TRUE);
937 add_to_sclist(MALL, "F1", do_help_void, 0, TRUE);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +0000938#endif
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000939 add_to_sclist(MMAIN, "^X", do_exit, 0, TRUE);
940 add_to_sclist(MMAIN, "F2", do_exit, 0, TRUE);
941 add_to_sclist(MHELP, "^X", do_exit, 0, TRUE);
942 add_to_sclist(MHELP, "F2", do_exit, 0, TRUE);
943 add_to_sclist(MMAIN, "^_", do_gotolinecolumn_void, 0, TRUE);
944 add_to_sclist(MMAIN, "F13", do_gotolinecolumn_void, 0, TRUE);
945 add_to_sclist(MMAIN, "^O", do_writeout_void, 0, TRUE);
946 add_to_sclist(MMAIN, "F3", do_writeout_void, 0, TRUE);
947#ifndef NANO_TINY
948 add_to_sclist(MMAIN, "^J", do_justify_void, 0, TRUE);
949 add_to_sclist(MMAIN, "F4", do_justify_void, 0, TRUE);
950#endif
951 add_to_sclist(MMAIN, "^R", do_insertfile_void, 0, TRUE);
952 add_to_sclist(MMAIN, "F5", do_insertfile_void, 0, TRUE);
953 add_to_sclist(MMAIN, "^W", do_search, 0, TRUE);
954 add_to_sclist(MMAIN, "F6", do_search, 0, TRUE);
955 add_to_sclist(MMAIN, "^Y", do_page_up, 0, TRUE);
956 add_to_sclist(MMAIN, "F7", do_page_up, 0, TRUE);
957 add_to_sclist(MMAIN, "^V", do_page_down, 0, TRUE);
958 add_to_sclist(MMAIN, "F8", do_page_down, 0, TRUE);
959 add_to_sclist(MMAIN, "^K", do_cut_text_void, 0, TRUE);
960 add_to_sclist(MMAIN, "F9", do_cut_text_void, 0, TRUE);
961 add_to_sclist(MMAIN, "^U", do_uncut_text, 0, TRUE);
962 add_to_sclist(MMAIN, "F10", do_uncut_text, 0, TRUE);
963 add_to_sclist(MMAIN, "^C", do_cursorpos_void, 0, TRUE);
964 add_to_sclist(MMAIN, "F11", do_cursorpos_void, 0, TRUE);
965#ifndef NANO_TINY
966 add_to_sclist(MMAIN, "^T", do_spell, 0, TRUE);
967 add_to_sclist(MMAIN, "F12", do_spell, 0, TRUE);
968#endif
969 add_to_sclist(MMAIN, "^_", do_gotolinecolumn_void, 0, TRUE);
970 add_to_sclist(MMAIN, "F13", do_gotolinecolumn_void, 0, TRUE);
971 add_to_sclist(MMAIN, "M-G", do_gotolinecolumn_void, 0, TRUE);
972 add_to_sclist(MMAIN, "^\\", do_replace, 0, TRUE);
973 add_to_sclist(MMAIN, "F14", do_replace, 0, TRUE);
974 add_to_sclist(MMAIN, "M-R", do_replace, 0, TRUE);
975 add_to_sclist(MWHEREIS, "^R", do_replace, 0, FALSE);
976 add_to_sclist(MREPLACE, "^R", (void *) no_replace_msg, 0, FALSE);
977 add_to_sclist(MWHEREIS, "^T", do_gotolinecolumn_void, 0, TRUE);
978#ifndef NANO_TINY
979 add_to_sclist(MMAIN, "^^", do_mark, 0, TRUE);
980 add_to_sclist(MMAIN, "F15", do_mark, 0, TRUE);
981 add_to_sclist(MMAIN, "M-A", do_mark, 0, TRUE);
982 add_to_sclist(MALL, "F16", do_research, 0, TRUE);
983 add_to_sclist(MALL, "M-W", do_research, 0, TRUE);
984 add_to_sclist(MMAIN, "M-^", do_copy_text, 0, TRUE);
985 add_to_sclist(MMAIN, "M-6", do_copy_text, 0, TRUE);
986 add_to_sclist(MMAIN, "M-}", do_indent_void, 0, TRUE);
987 add_to_sclist(MMAIN, "M-{", do_unindent, 0, TRUE);
988 add_to_sclist(MMAIN|MBROWSER|MHELP, "^F", do_right, 0, TRUE);
989 add_to_sclist(MMAIN|MBROWSER|MHELP, "^B", do_left, 0, TRUE);
990 add_to_sclist(MMAIN, "^Space", do_next_word_void, 0, TRUE);
991 add_to_sclist(MMAIN, "M-Space", do_prev_word_void, 0, TRUE);
992#endif
993 add_to_sclist(MALL, "^Q", xon_complaint, 0, TRUE);
994 add_to_sclist(MALL, "^X", xoff_complaint, 0, TRUE);
995 add_to_sclist(MALL, "^P", do_up_void, 0, TRUE);
996 add_to_sclist(MALL, "^N", do_down_void, 0, TRUE);
997 add_to_sclist(MALL, "^A", do_home, 0, TRUE);
998 add_to_sclist(MALL, "^E", do_end, 0, TRUE);
999 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1000 "^W", do_para_begin_void, 0, TRUE);
1001 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1002 "^O", do_para_end_void, 0, TRUE);
1003 add_to_sclist(MALL, "M-(", do_para_begin_void, 0, TRUE);
1004 add_to_sclist(MALL, "M-9", do_para_begin_void, 0, TRUE);
1005 add_to_sclist(MALL, "M-)", do_para_end_void, 0, TRUE);
1006 add_to_sclist(MALL, "M-0", do_para_end_void, 0, TRUE);
1007 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1008 "^Y", do_first_line, 0, TRUE);
1009 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1010 "^V", do_last_line, 0, TRUE);
1011
1012 add_to_sclist(MWHEREIS,
1013 "M-C", (void *) case_sens_msg, 0, FALSE);
1014 add_to_sclist(MREPLACE,
1015 "M-C", (void *) case_sens_msg, 0, FALSE);
1016 add_to_sclist(MREPLACE2,
1017 "M-C", (void *) case_sens_msg, 0, FALSE);
1018 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1019 "M-B", (void *) backwards_msg, 0, FALSE);
1020 add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
1021 "M-R", (void *) regexp_msg, 0, FALSE);
1022
1023 add_to_sclist(MMAIN, "M-\\", do_first_line, 0, TRUE);
1024 add_to_sclist(MMAIN, "M-|", do_first_line, 0, TRUE);
1025 add_to_sclist(MMAIN, "M-/", do_last_line, 0, TRUE);
1026 add_to_sclist(MMAIN, "M-?", do_last_line, 0, TRUE);
1027#ifndef NANO_TINY
1028 add_to_sclist(MMAIN, "M-[", do_find_bracket, 0, TRUE);
1029 add_to_sclist(MMAIN, "M--", do_scroll_up, 0, TRUE);
1030 add_to_sclist(MMAIN, "M-_", do_scroll_up, 0, TRUE);
1031 add_to_sclist(MMAIN, "M-+", do_scroll_down, 0, TRUE);
1032 add_to_sclist(MMAIN, "M-=", do_scroll_down, 0, TRUE);
1033#endif
1034
1035#ifdef ENABLE_MULTIBUFFER
1036 add_to_sclist(MMAIN, "M-<", switch_to_prev_buffer_void, 0, TRUE);
1037 add_to_sclist(MMAIN, "M-,", switch_to_prev_buffer_void, 0, TRUE);
1038 add_to_sclist(MMAIN, "M->", switch_to_next_buffer_void, 0, TRUE);
1039 add_to_sclist(MMAIN, "M-.", switch_to_next_buffer_void, 0, TRUE);
1040#endif
1041 add_to_sclist(MMAIN, "M-V", do_verbatim_input, 0, TRUE);
1042 add_to_sclist(MALL, "^I", do_tab, 0, TRUE);
1043 add_to_sclist(MALL, "^M", do_enter, 0, TRUE);
1044 add_to_sclist(MALL, "^D", do_delete, 0, TRUE);
1045 add_to_sclist(MALL, "^H", do_backspace, 0, TRUE);
1046 add_to_sclist(MALL, "M-T", do_cut_till_end, 0, TRUE);
1047#ifndef NANO_TINY
1048 add_to_sclist(MALL, "M-J", do_full_justify, 0, TRUE);
1049 add_to_sclist(MALL, "M-D", do_wordlinechar_count, 0, TRUE);
1050 add_to_sclist(MMAIN, "M-X", do_toggle, NO_HELP, TRUE);
1051 add_to_sclist(MMAIN, "M-C", do_toggle, CONST_UPDATE, TRUE);
1052 add_to_sclist(MMAIN, "M-O", do_toggle, MORE_SPACE, TRUE);
1053 add_to_sclist(MMAIN, "M-S", do_toggle, SMOOTH_SCROLL, TRUE);
1054 add_to_sclist(MMAIN, "M-P", do_toggle, WHITESPACE_DISPLAY, TRUE);
1055 add_to_sclist(MMAIN, "M-Y", do_toggle, NO_COLOR_SYNTAX, TRUE);
1056 add_to_sclist(MMAIN, "M-H", do_toggle, SMART_HOME, TRUE);
1057 add_to_sclist(MMAIN, "M-I", do_toggle, AUTOINDENT, TRUE);
1058 add_to_sclist(MMAIN, "M-K", do_toggle, CUT_TO_END, TRUE);
1059 add_to_sclist(MMAIN, "M-L", do_toggle, NO_WRAP, TRUE);
1060 add_to_sclist(MMAIN, "M-Q", do_toggle, TABS_TO_SPACES, TRUE);
1061 add_to_sclist(MMAIN, "M-B", do_toggle, BACKUP_FILE, TRUE);
1062 add_to_sclist(MMAIN, "M-F", do_toggle, MULTIBUFFER, TRUE);
1063 add_to_sclist(MMAIN, "M-M", do_toggle, USE_MOUSE, TRUE);
1064 add_to_sclist(MMAIN, "M-N", do_toggle, NO_CONVERT, TRUE);
1065 add_to_sclist(MMAIN, "M-Z", do_toggle, SUSPEND, TRUE);
1066#endif
1067 add_to_sclist((MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR),
1068 "^C", (void *) cancel_msg, 0, FALSE);
1069 add_to_sclist(MHELP, "^Y", do_page_up, 0, TRUE);
1070 add_to_sclist(MHELP, "F7", do_page_up, 0, TRUE);
1071 add_to_sclist(MHELP, "^V", do_page_down, 0, TRUE);
1072 add_to_sclist(MHELP, "F8", do_page_down, 0, TRUE);
1073 add_to_sclist(MHELP, "^X", do_exit, 0, TRUE);
1074 add_to_sclist(MHELP, "F2", do_exit, 0, TRUE);
1075 add_to_sclist(MWRITEFILE, "M-D", (void *) dos_format_msg, 0, FALSE);
1076 add_to_sclist(MWRITEFILE, "M-M", (void *) mac_format_msg, 0, FALSE);
1077 add_to_sclist(MWRITEFILE, "M-A", (void *) append_msg, 0, FALSE);
1078 add_to_sclist(MWRITEFILE, "M-P", (void *) prepend_msg, 0, FALSE);
1079 add_to_sclist(MWRITEFILE, "M-B", (void *) backup_file_msg, 0, FALSE);
1080 add_to_sclist(MWRITEFILE, "^T", (void *) to_files_msg, 0, FALSE);
1081 add_to_sclist(MINSERTFILE, "^T", (void *) to_files_msg, 0, FALSE);
1082 add_to_sclist(MINSERTFILE, "^X", (void *) ext_cmd_msg, 0, FALSE);
1083 add_to_sclist(MMAIN, "^L", total_refresh, 0, TRUE);
1084
1085#ifdef DEBUG
1086 print_sclist();
1087#endif
1088
Chris Allegrettadab017e2002-04-23 10:56:06 +00001089}
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001090
David Lawrence Ramseye6757b92006-04-19 13:36:56 +00001091/* Free the given shortcut. */
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001092void free_shortcutage(shortcut **shortcutage)
1093{
1094 assert(shortcutage != NULL);
David Lawrence Ramsey193b0e52005-06-06 18:41:17 +00001095
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001096 while (*shortcutage != NULL) {
1097 shortcut *ps = *shortcutage;
1098 *shortcutage = (*shortcutage)->next;
1099 free(ps);
1100 }
1101}
1102
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001103const subnfunc *sctofunc(sc *s)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001104{
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001105 subnfunc *f;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001106
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001107 for (f = allfuncs; f != NULL && s->scfunc != f->scfunc; f = f->next)
1108 ;
1109
1110 return f;
1111}
1112
1113#ifndef NANO_TINY
1114/* Now lets come up with a single (hopefully)
1115 function to get a string for each flag */
1116char *flagtostr(int flag)
1117{
1118 switch (flag) {
1119 case NO_HELP:
1120 return N_("Help mode");
1121 case CONST_UPDATE:
1122 return N_("Constant cursor position display");
1123 case MORE_SPACE:
1124 return N_("Use of one more line for editing");
1125 case SMOOTH_SCROLL:
1126 return N_("Smooth scrolling");
1127 case WHITESPACE_DISPLAY:
1128 return N_("Whitespace display");
1129 case NO_COLOR_SYNTAX:
1130 return N_("Color syntax highlighting");
1131 case SMART_HOME:
1132 return N_("Smart home key");
1133 case AUTOINDENT:
1134 return N_("Auto indent");
1135 case CUT_TO_END:
1136 return N_("Cut to end");
1137 case NO_WRAP:
1138 return N_("Long line wrapping");
1139 case TABS_TO_SPACES:
1140 return N_("Conversion of typed tabs to spaces");
1141 case BACKUP_FILE:
1142 return N_("Backup files");
1143 case MULTIBUFFER:
1144 return N_("Multiple file buffers");
1145 case USE_MOUSE:
1146 return N_("Mouse support");
1147 case NO_CONVERT:
1148 return N_("No conversion from DOS/Mac format");
1149 case SUSPEND:
1150 return N_("Suspension");
1151 default:
1152 return "?????";
1153 }
1154}
1155
1156/* Interpret the string given by the rc file and return a
1157 shortcut struct, complete with proper value for execute */
1158sc *strtosc(int menu, char *input)
1159{
1160 sc *s;
1161
1162 s = (sc *)nmalloc(sizeof(sc));
1163 s->execute = TRUE; /* overridden as needed below */
1164
1165 if (!strcasecmp(input, "help"))
1166 s->scfunc = do_help_void;
1167 else if (!strcasecmp(input, "cancel")) {
1168 s->scfunc = (void *) cancel_msg;
1169 s->execute = FALSE;
1170 } else if (!strcasecmp(input, "exit"))
1171 s->scfunc = do_exit;
1172 else if (!strcasecmp(input, "writeout"))
1173 s->scfunc = do_writeout_void;
1174 else if (!strcasecmp(input, "justify"))
1175 s->scfunc = do_justify_void;
1176 else if (!strcasecmp(input, "insert"))
1177 s->scfunc = do_insertfile_void;
1178 else if (!strcasecmp(input, "whereis"))
1179 s->scfunc = do_search;
1180 else if (!strcasecmp(input, "up"))
1181 s->scfunc = do_page_up;
1182 else if (!strcasecmp(input, "down"))
1183 s->scfunc = do_page_down;
1184 else if (!strcasecmp(input, "cut"))
1185 s->scfunc = do_cut_text_void;
1186 else if (!strcasecmp(input, "uncut"))
1187 s->scfunc = do_uncut_text;
1188 else if (!strcasecmp(input, "curpos") ||
1189 !strcasecmp(input, "cursorpos"))
1190 s->scfunc = do_cursorpos_void;
1191 else if (!strcasecmp(input, "firstline"))
1192 s->scfunc = do_first_line;
1193 else if (!strcasecmp(input, "lastline"))
1194 s->scfunc = do_last_line;
1195 else if (!strcasecmp(input, "gotoline"))
1196 s->scfunc = do_gotolinecolumn_void;
1197 else if (!strcasecmp(input, "replace"))
1198 s->scfunc = do_replace;
1199 else if (!strcasecmp(input, "mark"))
1200 s->scfunc = do_mark;
1201 else if (!strcasecmp(input, "searchagain") ||
1202 !strcasecmp(input, "research"))
1203 s->scfunc = do_research;
1204 else if (!strcasecmp(input, "copytext"))
1205 s->scfunc = do_copy_text;
1206 else if (!strcasecmp(input, "indent"))
1207 s->scfunc = do_indent_void;
1208 else if (!strcasecmp(input, "unindent"))
1209 s->scfunc = do_unindent;
1210 else if (!strcasecmp(input, "right") ||
1211 !strcasecmp(input, "forward"))
1212 s->scfunc = do_right;
1213 else if (!strcasecmp(input, "left") ||
1214 !strcasecmp(input, "back"))
1215 s->scfunc = do_left;
1216 else if (!strcasecmp(input, "nextword"))
1217 s->scfunc = do_next_word_void;
1218 else if (!strcasecmp(input, "prevword"))
1219 s->scfunc = do_prev_word_void;
1220 else if (!strcasecmp(input, "up") ||
1221 !strcasecmp(input, "prevline"))
1222 s->scfunc = do_up_void;
1223 else if (!strcasecmp(input, "down") ||
1224 !strcasecmp(input, "nextline"))
1225 s->scfunc = do_down_void;
1226 else if (!strcasecmp(input, "home"))
1227 s->scfunc = do_home;
1228 else if (!strcasecmp(input, "end"))
1229 s->scfunc = do_end;
1230 else if (!strcasecmp(input, "beginpara"))
1231 s->scfunc = do_para_begin_void;
1232 else if (!strcasecmp(input, "endpara"))
1233 s->scfunc = do_para_end_void;
1234 else if (!strcasecmp(input, "findbracket"))
1235 s->scfunc = do_find_bracket;
1236 else if (!strcasecmp(input, "scrollup"))
1237 s->scfunc = do_scroll_up;
1238 else if (!strcasecmp(input, "scrolldown"))
1239 s->scfunc = do_scroll_down;
1240#ifdef ENABLE_MULTIBUFFER
1241 else if (!strcasecmp(input, "prevbuf"))
1242 s->scfunc = switch_to_prev_buffer_void;
1243 else if (!strcasecmp(input, "nextbuf"))
1244 s->scfunc = switch_to_next_buffer_void;
1245#endif
1246 else if (!strcasecmp(input, "verbatim"))
1247 s->scfunc = do_verbatim_input;
1248 else if (!strcasecmp(input, "tab"))
1249 s->scfunc = do_tab;
1250 else if (!strcasecmp(input, "enter"))
1251 s->scfunc = do_enter;
1252 else if (!strcasecmp(input, "delete"))
1253 s->scfunc = do_delete;
1254 else if (!strcasecmp(input, "fulljustify"))
1255 s->scfunc = do_full_justify;
1256 else if (!strcasecmp(input, "wordcount"))
1257 s->scfunc = do_wordlinechar_count;
1258 else if (!strcasecmp(input, "refresh"))
1259 s->scfunc = total_refresh;
1260 else if (!strcasecmp(input, "casesens")) {
1261 s->scfunc = (void *) case_sens_msg;
1262 s->execute = FALSE;
1263 } else if (!strcasecmp(input, "regexp") ||
1264 !strcasecmp(input, "regex")) {
1265 s->scfunc = (void *) regexp_msg;
1266 s->execute = FALSE;
1267 } else if (!strcasecmp(input, "prevhistory")) {
1268 s->scfunc = (void *) prev_history_msg;
1269 s->execute = FALSE;
1270 } else if (!strcasecmp(input, "nexthistory")) {
1271 s->scfunc = (void *) next_history_msg;
1272 s->execute = FALSE;
1273 } else if (!strcasecmp(input, "dontreplace")) {
1274 s->scfunc = (void *) no_replace_msg;
1275 s->execute = FALSE;
1276 } else if (!strcasecmp(input, "gototext")) {
1277 s->scfunc = (void *) gototext_msg;
1278 s->execute = FALSE;
1279 } else if (!strcasecmp(input, "browser") ||
1280 !strcasecmp(input, "tofiles")) {
1281 s->scfunc = (void *) to_files_msg;
1282 s->execute = FALSE;
1283 } else if (!strcasecmp(input, "dosformat")) {
1284 s->scfunc = (void *) dos_format_msg;
1285 s->execute = FALSE;
1286 } else if (!strcasecmp(input, "macformat")) {
1287 s->scfunc = (void *) mac_format_msg;
1288 s->execute = FALSE;
1289 } else if (!strcasecmp(input, "append")) {
1290 s->scfunc = (void *) append_msg;
1291 s->execute = FALSE;
1292 } else if (!strcasecmp(input, "prepend")) {
1293 s->scfunc = (void *) prepend_msg;
1294 s->execute = FALSE;
1295 } else if (!strcasecmp(input, "backup")) {
1296 s->scfunc = (void *) backup_file_msg;
1297 s->execute = FALSE;
1298#ifdef ENABLE_MULTIBUFFER
1299 } else if (!strcasecmp(input, "newbuffer")) {
1300 s->scfunc = (void *) new_buffer_msg;
1301 s->execute = FALSE;
1302#endif
1303 } else if (!strcasecmp(input, "firstfile")) {
1304 s->scfunc = (void *) first_file_msg;
1305 s->execute = FALSE;
1306 } else if (!strcasecmp(input, "lastfile")) {
1307 s->scfunc = (void *) last_file_msg;
1308 s->execute = FALSE;
1309 } else if (!strcasecmp(input, "nohelp") ||
1310 !strcasecmp(input, "nohelp")) {
1311 s->scfunc = (void *) do_toggle;
1312 s->execute = FALSE;
1313 s->toggle = NO_HELP;
1314 } else if (!strcasecmp(input, "constupdate")) {
1315 s->scfunc = (void *) do_toggle;
1316 s->execute = FALSE;
1317 s->toggle = CONST_UPDATE;
1318 } else if (!strcasecmp(input, "morespace")) {
1319 s->scfunc = (void *) do_toggle;
1320 s->execute = FALSE;
1321 s->toggle = MORE_SPACE;
1322 } else if (!strcasecmp(input, "smoothscroll")) {
1323 s->scfunc = (void *) do_toggle;
1324 s->execute = FALSE;
1325 s->toggle = SMOOTH_SCROLL;
1326 } else if (!strcasecmp(input, "whitesplacedisplay")) {
1327 s->scfunc = (void *) do_toggle;
1328 s->execute = FALSE;
1329 s->toggle = WHITESPACE_DISPLAY;
1330 } else if (!strcasecmp(input, "nosyntax")) {
1331 s->scfunc = (void *) do_toggle;
1332 s->execute = FALSE;
1333 s->toggle = NO_COLOR_SYNTAX;
1334 } else if (!strcasecmp(input, "smarthome")) {
1335 s->scfunc = (void *) do_toggle;
1336 s->execute = FALSE;
1337 s->toggle = SMART_HOME;
1338 } else if (!strcasecmp(input, "autoindent")) {
1339 s->scfunc = (void *) do_toggle;
1340 s->execute = FALSE;
1341 s->toggle = AUTOINDENT;
1342 } else if (!strcasecmp(input, "cuttoend")) {
1343 s->scfunc = (void *) do_toggle;
1344 s->execute = FALSE;
1345 s->toggle = CUT_TO_END;
1346 } else if (!strcasecmp(input, "nowrap")) {
1347 s->scfunc = (void *) do_toggle;
1348 s->execute = FALSE;
1349 s->toggle = NO_WRAP;
1350 } else if (!strcasecmp(input, "tabstospaces")) {
1351 s->scfunc = (void *) do_toggle;
1352 s->execute = FALSE;
1353 s->toggle = TABS_TO_SPACES;
1354 } else if (!strcasecmp(input, "backupfile")) {
1355 s->scfunc = (void *) do_toggle;
1356 s->execute = FALSE;
1357 s->toggle = BACKUP_FILE;
1358 } else if (!strcasecmp(input, "mutlibuffer")) {
1359 s->scfunc = (void *) do_toggle;
1360 s->execute = FALSE;
1361 s->toggle = MULTIBUFFER;
1362 } else if (!strcasecmp(input, "mouse")) {
1363 s->scfunc = (void *) do_toggle;
1364 s->execute = FALSE;
1365 s->toggle = USE_MOUSE;
1366 } else if (!strcasecmp(input, "noconvert")) {
1367 s->scfunc = (void *) do_toggle;
1368 s->execute = FALSE;
1369 s->toggle = NO_CONVERT;
1370 } else if (!strcasecmp(input, "suspend")) {
1371 s->scfunc = (void *) do_toggle;
1372 s->execute = FALSE;
1373 s->toggle = SUSPEND;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001374 } else {
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001375 free(s);
1376 return NULL;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001377 }
1378
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001379 return s;
1380
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001381}
1382
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001383/* Same thing as abnove but for the menu */
1384int strtomenu(char *input)
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001385{
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001386 if (!strcasecmp(input, "all"))
1387 return MALL;
1388 else if (!strcasecmp(input, "main"))
1389 return MMAIN;
1390 else if (!strcasecmp(input, "search"))
1391 return MWHEREIS;
1392 else if (!strcasecmp(input, "replace"))
1393 return MREPLACE;
1394 else if (!strcasecmp(input, "replace2") ||
1395 !strcasecmp(input, "replacewith"))
1396 return MREPLACE2;
1397 else if (!strcasecmp(input, "gotoline"))
1398 return MGOTOLINE;
1399 else if (!strcasecmp(input, "writeout"))
1400 return MWRITEFILE;
1401 else if (!strcasecmp(input, "insert"))
1402 return MINSERTFILE;
1403 else if (!strcasecmp(input, "externalcmd") ||
1404 !strcasecmp(input, "extcmd"))
1405 return MEXTCMD;
1406 else if (!strcasecmp(input, "help"))
1407 return MHELP;
1408 else if (!strcasecmp(input, "spell"))
1409 return MSPELL;
1410 else if (!strcasecmp(input, "browser"))
1411 return MBROWSER;
1412 else if (!strcasecmp(input, "whereisfile"))
1413 return MWHEREISFILE;
1414 else if (!strcasecmp(input, "gotodir"))
1415 return MGOTODIR;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001416
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001417 return -1;
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001418}
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001419
1420
1421#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001422
David Lawrence Ramseye6757b92006-04-19 13:36:56 +00001423#ifdef DEBUG
1424/* This function is used to gracefully return all the memory we've used.
1425 * It should be called just before calling exit(). Practically, the
Chris Allegretta6232d662002-05-12 19:52:15 +00001426 * only effect is to cause a segmentation fault if the various data
1427 * structures got bolloxed earlier. Thus, we don't bother having this
Chris Allegretta6df90f52002-07-19 01:08:59 +00001428 * function unless debugging is turned on. */
Chris Allegretta6df90f52002-07-19 01:08:59 +00001429void thanks_for_all_the_fish(void)
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001430{
David Lawrence Ramsey576bf332004-07-12 03:10:30 +00001431 delwin(topwin);
1432 delwin(edit);
1433 delwin(bottomwin);
1434
Chris Allegretta7662c862003-01-13 01:35:15 +00001435#ifndef DISABLE_JUSTIFY
1436 if (quotestr != NULL)
1437 free(quotestr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001438#ifdef HAVE_REGEX_H
1439 regfree(&quotereg);
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001440 if (quoteerr != NULL)
1441 free(quoteerr);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +00001442#endif
Chris Allegretta7662c862003-01-13 01:35:15 +00001443#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001444#ifndef NANO_TINY
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +00001445 if (backup_dir != NULL)
1446 free(backup_dir);
1447#endif
Chris Allegretta2598c662002-03-28 01:59:34 +00001448#ifndef DISABLE_OPERATINGDIR
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001449 if (operating_dir != NULL)
1450 free(operating_dir);
1451 if (full_operating_dir != NULL)
1452 free(full_operating_dir);
1453#endif
1454 if (last_search != NULL)
1455 free(last_search);
1456 if (last_replace != NULL)
1457 free(last_replace);
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001458#ifndef DISABLE_SPELLER
1459 if (alt_speller != NULL)
1460 free(alt_speller);
1461#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001462 if (answer != NULL)
1463 free(answer);
1464 if (cutbuffer != NULL)
Chris Allegretta7662c862003-01-13 01:35:15 +00001465 free_filestruct(cutbuffer);
David Lawrence Ramsey93c84052004-11-23 04:08:28 +00001466#ifndef DISABLE_JUSTIFY
1467 if (jusbuffer != NULL)
1468 free_filestruct(jusbuffer);
1469#endif
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001470#ifndef NANO_TINY
David Lawrence Ramsey40e4acf2005-05-26 06:09:07 +00001471 /* Free the memory associated with each toggle. */
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001472 while (toggles != NULL) {
1473 toggle *t = toggles;
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001474
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001475 toggles = toggles->next;
1476 free(t);
1477 }
1478#endif
David Lawrence Ramsey5d8d0b12005-05-26 05:53:29 +00001479 /* Free the memory associated with each open file buffer. */
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +00001480 if (openfile != NULL)
David Lawrence Ramsey64661ac2005-07-08 19:57:25 +00001481 free_openfilestruct(openfile);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001482#ifdef ENABLE_COLOR
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001483 if (syntaxstr != NULL)
1484 free(syntaxstr);
Chris Allegretta6df90f52002-07-19 01:08:59 +00001485 while (syntaxes != NULL) {
1486 syntaxtype *bill = syntaxes;
1487
1488 free(syntaxes->desc);
1489 while (syntaxes->extensions != NULL) {
1490 exttype *bob = syntaxes->extensions;
1491
1492 syntaxes->extensions = bob->next;
David Lawrence Ramsey2385c1a2005-07-29 21:42:08 +00001493 free(bob->ext_regex);
David Lawrence Ramsey7fc0ada2005-08-29 18:52:06 +00001494 if (bob->ext != NULL) {
1495 regfree(bob->ext);
1496 free(bob->ext);
1497 }
Chris Allegretta6df90f52002-07-19 01:08:59 +00001498 free(bob);
1499 }
1500 while (syntaxes->color != NULL) {
1501 colortype *bob = syntaxes->color;
1502
1503 syntaxes->color = bob->next;
David Lawrence Ramsey2385c1a2005-07-29 21:42:08 +00001504 free(bob->start_regex);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001505 if (bob->start != NULL) {
1506 regfree(bob->start);
1507 free(bob->start);
1508 }
David Lawrence Ramseyd2361f02005-07-14 18:33:51 +00001509 if (bob->end_regex != NULL)
1510 free(bob->end_regex);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001511 if (bob->end != NULL) {
Chris Allegrettace452fb2003-02-03 02:56:44 +00001512 regfree(bob->end);
David Lawrence Ramseydb958022005-07-13 20:18:46 +00001513 free(bob->end);
1514 }
Chris Allegretta6df90f52002-07-19 01:08:59 +00001515 free(bob);
1516 }
1517 syntaxes = syntaxes->next;
1518 free(bill);
1519 }
1520#endif /* ENABLE_COLOR */
David Lawrence Ramseyebe34252005-11-15 03:17:35 +00001521#ifndef NANO_TINY
David Lawrence Ramsey40e4acf2005-05-26 06:09:07 +00001522 /* Free the search and replace history lists. */
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001523 if (searchage != NULL)
1524 free_filestruct(searchage);
1525 if (replaceage != NULL)
1526 free_filestruct(replaceage);
Chris Allegretta5beed502003-01-05 20:41:21 +00001527#endif
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001528#ifdef ENABLE_NANORC
David Lawrence Ramsey31b159c2005-05-26 05:17:13 +00001529 if (homedir != NULL)
1530 free(homedir);
David Lawrence Ramseya27bd652004-08-17 05:23:38 +00001531#endif
Chris Allegrettaf5de33a2002-02-27 04:14:16 +00001532}
Chris Allegretta6232d662002-05-12 19:52:15 +00001533#endif /* DEBUG */
Chris Allegretta79a33bb2008-03-05 07:34:01 +00001534