Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1 | /* $Id$ |
| 2 | */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 3 | /************************************************************************** |
| 4 | * global.c * |
| 5 | * * |
David Lawrence Ramsey | d8a1d37 | 2007-10-11 05:01:32 +0000 | [diff] [blame] | 6 | * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 * |
| 7 | * Free Software Foundation, Inc. * |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 8 | * 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 Ramsey | d0035b4 | 2007-08-11 05:17:36 +0000 | [diff] [blame] | 10 | * the Free Software Foundation; either version 3, or (at your option) * |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 11 | * any later version. * |
| 12 | * * |
David Lawrence Ramsey | 6e925cf | 2005-05-15 19:57:17 +0000 | [diff] [blame] | 13 | * 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 Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 17 | * * |
| 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 Ramsey | 6e925cf | 2005-05-15 19:57:17 +0000 | [diff] [blame] | 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * |
| 21 | * 02110-1301, USA. * |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 22 | * * |
| 23 | **************************************************************************/ |
| 24 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 25 | #include <ctype.h> |
Chris Allegretta | eb64314 | 2008-03-12 04:44:14 +0000 | [diff] [blame] | 26 | #include <string.h> |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 27 | #include <strings.h> |
| 28 | #include "assert.h" |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 29 | #include "proto.h" |
| 30 | |
David Lawrence Ramsey | fc0f8f8 | 2006-05-10 13:41:53 +0000 | [diff] [blame] | 31 | /* Global variables. */ |
| 32 | #ifndef NANO_TINY |
David Lawrence Ramsey | 1c5af64 | 2006-05-10 15:15:06 +0000 | [diff] [blame] | 33 | sigjmp_buf jump_buf; |
David Lawrence Ramsey | b6fb688 | 2006-11-27 07:28:52 +0000 | [diff] [blame] | 34 | /* Used to return to either main() or the unjustify routine in |
David Lawrence Ramsey | fc0f8f8 | 2006-05-10 13:41:53 +0000 | [diff] [blame] | 35 | * do_justify() after a SIGWINCH. */ |
David Lawrence Ramsey | 1c5af64 | 2006-05-10 15:15:06 +0000 | [diff] [blame] | 36 | bool jump_buf_main = FALSE; |
| 37 | /* Have we set jump_buf so that we return to main() after a |
| 38 | * SIGWINCH? */ |
David Lawrence Ramsey | fc0f8f8 | 2006-05-10 13:41:53 +0000 | [diff] [blame] | 39 | #endif |
| 40 | |
David Lawrence Ramsey | f5b256b | 2003-10-03 20:26:25 +0000 | [diff] [blame] | 41 | #ifndef DISABLE_WRAPJUSTIFY |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 42 | ssize_t fill = 0; |
| 43 | /* The column where we will wrap lines. */ |
David Lawrence Ramsey | 691698a | 2005-07-24 19:57:51 +0000 | [diff] [blame] | 44 | ssize_t wrap_at = -CHARS_FROM_EOL; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 45 | /* The position where we will wrap lines. fill is equal to this |
| 46 | * if it's greater than zero, and equal to (COLS + this) if it |
| 47 | * isn't. */ |
David Lawrence Ramsey | f5b256b | 2003-10-03 20:26:25 +0000 | [diff] [blame] | 48 | #endif |
| 49 | |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 50 | char *last_search = NULL; |
| 51 | /* The last string we searched for. */ |
| 52 | char *last_replace = NULL; |
| 53 | /* The last replacement string we searched for. */ |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 54 | |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 55 | long flags = 0; |
| 56 | /* Our flag containing the states of all global options. */ |
| 57 | WINDOW *topwin; |
| 58 | /* The top portion of the window, where we display the version |
| 59 | * number of nano, the name of the current file, and whether the |
| 60 | * current file has been modified. */ |
| 61 | WINDOW *edit; |
David Lawrence Ramsey | b159f94 | 2006-07-28 17:06:27 +0000 | [diff] [blame] | 62 | /* The middle portion of the window, i.e. the edit window, where |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 63 | * we display the current file we're editing. */ |
| 64 | WINDOW *bottomwin; |
| 65 | /* The bottom portion of the window, where we display statusbar |
| 66 | * messages, the statusbar prompt, and a list of shortcuts. */ |
| 67 | int editwinrows = 0; |
| 68 | /* How many rows does the edit window take up? */ |
David Lawrence Ramsey | 5db0cdc | 2002-06-28 22:45:14 +0000 | [diff] [blame] | 69 | |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 70 | filestruct *cutbuffer = NULL; |
| 71 | /* The buffer where we store cut text. */ |
David Lawrence Ramsey | 93c8405 | 2004-11-23 04:08:28 +0000 | [diff] [blame] | 72 | #ifndef DISABLE_JUSTIFY |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 73 | filestruct *jusbuffer = NULL; |
| 74 | /* The buffer where we store unjustified text. */ |
David Lawrence Ramsey | 93c8405 | 2004-11-23 04:08:28 +0000 | [diff] [blame] | 75 | #endif |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 76 | partition *filepart = NULL; |
| 77 | /* The partition where we store a portion of the current |
| 78 | * file. */ |
David Lawrence Ramsey | 64661ac | 2005-07-08 19:57:25 +0000 | [diff] [blame] | 79 | openfilestruct *openfile = NULL; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 80 | /* The list of all open file buffers. */ |
Chris Allegretta | 2d7893d | 2001-07-11 02:08:33 +0000 | [diff] [blame] | 81 | |
David Lawrence Ramsey | d89617f | 2006-01-06 21:51:10 +0000 | [diff] [blame] | 82 | #ifndef NANO_TINY |
| 83 | char *matchbrackets = NULL; |
| 84 | /* The opening and closing brackets that can be found by bracket |
| 85 | * searches. */ |
| 86 | #endif |
| 87 | |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 88 | #if !defined(NANO_TINY) && defined(ENABLE_NANORC) |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 89 | char *whitespace = NULL; |
| 90 | /* The characters used when displaying the first characters of |
| 91 | * tabs and spaces. */ |
| 92 | int whitespace_len[2]; |
| 93 | /* The length of these characters. */ |
David Lawrence Ramsey | 89bb937 | 2004-05-29 16:47:52 +0000 | [diff] [blame] | 94 | #endif |
| 95 | |
Chris Allegretta | e4f940d | 2002-03-03 22:36:36 +0000 | [diff] [blame] | 96 | #ifndef DISABLE_JUSTIFY |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 97 | char *punct = NULL; |
| 98 | /* The closing punctuation that can end sentences. */ |
| 99 | char *brackets = NULL; |
| 100 | /* The closing brackets that can follow closing punctuation and |
| 101 | * can end sentences. */ |
| 102 | char *quotestr = NULL; |
| 103 | /* The quoting string. The default value is set in main(). */ |
David Lawrence Ramsey | 819c7f0 | 2004-07-30 03:54:34 +0000 | [diff] [blame] | 104 | #ifdef HAVE_REGEX_H |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 105 | regex_t quotereg; |
| 106 | /* The compiled regular expression from the quoting string. */ |
| 107 | int quoterc; |
David Lawrence Ramsey | 8816564 | 2006-05-22 18:30:09 +0000 | [diff] [blame] | 108 | /* Whether it was compiled successfully. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 109 | char *quoteerr = NULL; |
| 110 | /* The error message, if it didn't. */ |
David Lawrence Ramsey | 819c7f0 | 2004-07-30 03:54:34 +0000 | [diff] [blame] | 111 | #else |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 112 | size_t quotelen; |
| 113 | /* The length of the quoting string in bytes. */ |
David Lawrence Ramsey | 819c7f0 | 2004-07-30 03:54:34 +0000 | [diff] [blame] | 114 | #endif |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 115 | #endif |
Chris Allegretta | e4f940d | 2002-03-03 22:36:36 +0000 | [diff] [blame] | 116 | |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 117 | char *answer = NULL; |
David Lawrence Ramsey | 6335fb5 | 2007-01-01 05:15:32 +0000 | [diff] [blame] | 118 | /* The answer string used by the statusbar prompt. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 119 | |
| 120 | ssize_t tabsize = -1; |
| 121 | /* The width of a tab in spaces. The default value is set in |
| 122 | * main(). */ |
| 123 | |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 124 | #ifndef NANO_TINY |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 125 | char *backup_dir = NULL; |
| 126 | /* The directory where we store backup files. */ |
David Lawrence Ramsey | 04e42a6 | 2004-02-28 16:24:31 +0000 | [diff] [blame] | 127 | #endif |
Chris Allegretta | e1f1452 | 2001-09-19 03:19:43 +0000 | [diff] [blame] | 128 | #ifndef DISABLE_OPERATINGDIR |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 129 | char *operating_dir = NULL; |
| 130 | /* The relative path to the operating directory, which we can't |
| 131 | * move outside of. */ |
| 132 | char *full_operating_dir = NULL; |
| 133 | /* The full path to it. */ |
Chris Allegretta | e1f1452 | 2001-09-19 03:19:43 +0000 | [diff] [blame] | 134 | #endif |
| 135 | |
Chris Allegretta | 8d8e012 | 2001-04-18 04:28:54 +0000 | [diff] [blame] | 136 | #ifndef DISABLE_SPELLER |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 137 | char *alt_speller = NULL; |
| 138 | /* The command to use for the alternate spell checker. */ |
Chris Allegretta | 8d8e012 | 2001-04-18 04:28:54 +0000 | [diff] [blame] | 139 | #endif |
| 140 | |
Chris Allegretta | 8ce2413 | 2001-04-30 11:28:46 +0000 | [diff] [blame] | 141 | #ifdef ENABLE_COLOR |
David Lawrence Ramsey | 9b13ff3 | 2002-12-22 16:30:00 +0000 | [diff] [blame] | 142 | syntaxtype *syntaxes = NULL; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 143 | /* The global list of color syntaxes. */ |
David Lawrence Ramsey | 9b13ff3 | 2002-12-22 16:30:00 +0000 | [diff] [blame] | 144 | char *syntaxstr = NULL; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 145 | /* The color syntax name specified on the command line. */ |
Chris Allegretta | 8ce2413 | 2001-04-30 11:28:46 +0000 | [diff] [blame] | 146 | #endif |
| 147 | |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 148 | const shortcut *currshortcut; |
| 149 | /* The current shortcut list we're using. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 150 | int currmenu; |
| 151 | /* The currently loaded menu */ |
| 152 | |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 153 | #ifndef NANO_TINY |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 154 | toggle *toggles = NULL; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 155 | /* The global toggle list. */ |
Chris Allegretta | f0b26df | 2001-01-20 22:18:18 +0000 | [diff] [blame] | 156 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 157 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 158 | sc *sclist = NULL; |
| 159 | /* New shortcut key struct */ |
| 160 | subnfunc *allfuncs = NULL; |
| 161 | /* New struct for the function list */ |
| 162 | |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 163 | #ifndef NANO_TINY |
David Lawrence Ramsey | 934f968 | 2005-05-23 16:30:06 +0000 | [diff] [blame] | 164 | filestruct *search_history = NULL; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 165 | /* The search string history list. */ |
David Lawrence Ramsey | 934f968 | 2005-05-23 16:30:06 +0000 | [diff] [blame] | 166 | filestruct *searchage = NULL; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 167 | /* The top of the search string history list. */ |
David Lawrence Ramsey | 934f968 | 2005-05-23 16:30:06 +0000 | [diff] [blame] | 168 | filestruct *searchbot = NULL; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 169 | /* The bottom of the search string history list. */ |
David Lawrence Ramsey | 934f968 | 2005-05-23 16:30:06 +0000 | [diff] [blame] | 170 | filestruct *replace_history = NULL; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 171 | /* The replace string history list. */ |
David Lawrence Ramsey | 934f968 | 2005-05-23 16:30:06 +0000 | [diff] [blame] | 172 | filestruct *replaceage = NULL; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 173 | /* The top of the replace string history list. */ |
David Lawrence Ramsey | 934f968 | 2005-05-23 16:30:06 +0000 | [diff] [blame] | 174 | filestruct *replacebot = NULL; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 175 | /* The bottom of the replace string history list. */ |
Chris Allegretta | 5beed50 | 2003-01-05 20:41:21 +0000 | [diff] [blame] | 176 | #endif |
| 177 | |
David Lawrence Ramsey | fc0f8f8 | 2006-05-10 13:41:53 +0000 | [diff] [blame] | 178 | /* Regular expressions. */ |
Chris Allegretta | 805c26d | 2000-09-06 13:39:17 +0000 | [diff] [blame] | 179 | #ifdef HAVE_REGEX_H |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 180 | regex_t search_regexp; |
| 181 | /* The compiled regular expression to use in searches. */ |
| 182 | regmatch_t regmatches[10]; |
| 183 | /* The match positions for parenthetical subexpressions, 10 |
| 184 | * maximum, used in regular expression searches. */ |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 185 | #endif |
Chris Allegretta | 3533a34 | 2002-03-24 23:19:32 +0000 | [diff] [blame] | 186 | |
David Lawrence Ramsey | 4d72de7 | 2006-04-12 15:27:40 +0000 | [diff] [blame] | 187 | int reverse_attr = A_REVERSE; |
| 188 | /* The curses attribute we use for reverse video. */ |
Chris Allegretta | a0d8997 | 2003-02-03 03:32:08 +0000 | [diff] [blame] | 189 | |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 190 | char *homedir = NULL; |
David Lawrence Ramsey | c1c818e | 2006-05-14 18:22:01 +0000 | [diff] [blame] | 191 | /* The user's home directory, from $HOME or /etc/passwd. */ |
David Lawrence Ramsey | a27bd65 | 2004-08-17 05:23:38 +0000 | [diff] [blame] | 192 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 193 | /* Return the number of entries in the shortcut list s for a given menu. */ |
| 194 | size_t length_of_list(int menu) |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 195 | { |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 196 | subnfunc *f; |
David Lawrence Ramsey | ebd0d7c | 2004-07-01 18:59:52 +0000 | [diff] [blame] | 197 | size_t i = 0; |
David Lawrence Ramsey | e21adfa | 2002-09-13 18:14:04 +0000 | [diff] [blame] | 198 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 199 | for (f = allfuncs; f != NULL; f = f->next) |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 200 | if ((f->menus & menu) != 0 |
| 201 | #ifndef DISABLE_HELP |
| 202 | && strlen(f->help) > 0 |
| 203 | #endif |
| 204 | ) { |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 205 | i++; |
| 206 | } |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 207 | return i; |
| 208 | } |
| 209 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 210 | /* Set type of function based on the string */ |
| 211 | function_type strtokeytype(char *str) |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 212 | { |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 213 | if (str[0] == 'M' || str[0] == 'm') |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 214 | return META; |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 215 | else if (str[0] == '^') |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 216 | return CONTROL; |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 217 | else if (str[0] == 'F' || str[0] == 'F') |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 218 | return FKEY; |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 219 | else |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 220 | return RAW; |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | /* Add a string to the new function list strict. |
| 224 | Does not allow updates, yet anyway */ |
| 225 | void add_to_funcs(void *func, int menus, const char *desc, const char *help, |
| 226 | bool blank_after, bool viewok) |
| 227 | { |
| 228 | subnfunc *f; |
| 229 | |
| 230 | if (allfuncs == NULL) { |
| 231 | allfuncs = nmalloc(sizeof(subnfunc)); |
| 232 | f = allfuncs; |
| 233 | } else { |
| 234 | for (f = allfuncs; f->next != NULL; f = f->next) |
| 235 | ; |
| 236 | f->next = (subnfunc *)nmalloc(sizeof(subnfunc)); |
| 237 | f = f->next; |
| 238 | } |
| 239 | f->next = NULL; |
| 240 | f->scfunc = func; |
| 241 | f->menus = menus; |
| 242 | f->desc = desc; |
| 243 | f->viewok = viewok; |
| 244 | #ifndef NANO_TINY |
| 245 | f->help = help; |
| 246 | f->blank_after = blank_after; |
| 247 | #endif |
| 248 | |
| 249 | #ifdef DEBUG |
| 250 | fprintf(stderr, "Added func \"%s\"", f->desc); |
| 251 | #endif |
| 252 | } |
| 253 | |
| 254 | const sc *first_sc_for(int menu, void *func) { |
| 255 | const sc *s; |
Chris Allegretta | b775c07 | 2008-03-09 05:07:37 +0000 | [diff] [blame] | 256 | const sc *metasc = NULL; |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 257 | |
| 258 | for (s = sclist; s != NULL; s = s->next) { |
| 259 | if ((s->menu & menu) && s->scfunc == func) { |
Chris Allegretta | b775c07 | 2008-03-09 05:07:37 +0000 | [diff] [blame] | 260 | /* try to use a meta sequence as a last resort. Otherwise |
| 261 | we will run into problems when we try and handle things like |
| 262 | the arrow keys, home, etc, if for some reason the user bound |
| 263 | them to a meta sequence first *shrug* */ |
| 264 | if (s->type == META) { |
| 265 | metasc = s; |
| 266 | continue; |
| 267 | } /* otherwise it was something else, use it */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 268 | return s; |
| 269 | } |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 270 | } |
| 271 | |
Chris Allegretta | b775c07 | 2008-03-09 05:07:37 +0000 | [diff] [blame] | 272 | /* If we're here we may have found only meta sequences, if so use one */ |
| 273 | if (metasc) |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 274 | return metasc; |
Chris Allegretta | b775c07 | 2008-03-09 05:07:37 +0000 | [diff] [blame] | 275 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 276 | #ifdef DEBUG |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 277 | fprintf(stderr, "Whoops, returning null given func %ld in menu %d\n", (long) func, menu); |
David Lawrence Ramsey | bd28ee4 | 2006-07-25 21:13:30 +0000 | [diff] [blame] | 278 | #endif |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 279 | /* Otherwise... */ |
| 280 | return NULL; |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 283 | |
| 284 | /* Add a string to the new shortcut list implementation |
| 285 | Allows updates to existing entries in the list */ |
| 286 | void add_to_sclist(int menu, char *scstring, void *func, int toggle, int execute) |
| 287 | { |
| 288 | sc *s; |
| 289 | |
| 290 | if (sclist == NULL) { |
| 291 | sclist = nmalloc(sizeof(sc)); |
| 292 | s = sclist; |
| 293 | s->next = NULL; |
| 294 | } else { |
| 295 | for (s = sclist; s->next != NULL; s = s->next) |
| 296 | if (s->menu == menu && s->keystr == scstring) |
| 297 | break; |
| 298 | |
| 299 | if (s->menu != menu || s->keystr != scstring) { /* i.e. this is not a replace... */ |
| 300 | #ifdef DEBUG |
| 301 | fprintf(stderr, "No match found...\n"); |
| 302 | #endif |
| 303 | s->next = (sc *)nmalloc(sizeof(sc)); |
| 304 | s = s->next; |
| 305 | s->next = NULL; |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | s->type = strtokeytype(scstring); |
| 310 | s->menu = menu; |
| 311 | s->toggle = toggle; |
| 312 | s->keystr = scstring; |
| 313 | s->scfunc = func; |
| 314 | s->execute = execute; |
| 315 | assign_keyinfo(s); |
| 316 | |
| 317 | #ifdef DEBUG |
| 318 | fprintf(stderr, "list val = %d\n", (int) s->menu); |
| 319 | fprintf(stderr, "Hey, set sequence to %d for shortcut \"%s\"\n", s->seq, scstring); |
| 320 | #endif |
| 321 | } |
| 322 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 323 | /* Return the given menu's first shortcut sequence, or the default value |
| 324 | (2nd arg). Assumes currmenu for the menu to check*/ |
| 325 | int sc_seq_or (void *func, int defaultval) |
| 326 | { |
| 327 | const sc *s = first_sc_for(currmenu, func); |
| 328 | |
| 329 | if (s) |
| 330 | return s->seq; |
| 331 | /* else */ |
| 332 | return defaultval; |
| 333 | |
| 334 | } |
| 335 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 336 | /* Assign the info to the shortcut struct |
| 337 | Assumes keystr is already assigned, naturally */ |
| 338 | void assign_keyinfo(sc *s) |
| 339 | { |
| 340 | if (s->type == CONTROL) { |
| 341 | assert(strlen(s->keystr) > 1); |
| 342 | s->seq = s->keystr[1] - 64; |
| 343 | } else if (s->type == META) { |
| 344 | assert(strlen(s->keystr) > 2); |
| 345 | s->seq = tolower((int) s->keystr[2]); |
| 346 | } else if (s->type == FKEY) { |
| 347 | assert(strlen(s->keystr) > 1); |
| 348 | s->seq = KEY_F0 + atoi(&s->keystr[1]); |
| 349 | } else /* raw */ |
| 350 | s->seq = (int) s->keystr[0]; |
Chris Allegretta | 9b42220 | 2008-03-05 17:15:33 +0000 | [diff] [blame] | 351 | |
| 352 | /* Override some keys which don't bind as nicely as we'd like */ |
| 353 | if (s->type == CONTROL && (!strcasecmp(&s->keystr[1], "space"))) |
| 354 | s->seq = 0; |
| 355 | else if (s->type == META && (!strcasecmp(&s->keystr[2], "space"))) |
| 356 | s->seq = (int) ' '; |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 357 | else if (s->type == RAW && (!strcasecmp(s->keystr, "kup"))) |
| 358 | s->seq = KEY_UP; |
| 359 | else if (s->type == RAW && (!strcasecmp(s->keystr, "kdown"))) |
| 360 | s->seq = KEY_DOWN; |
| 361 | else if (s->type == RAW && (!strcasecmp(s->keystr, "kleft"))) |
| 362 | s->seq = KEY_LEFT; |
| 363 | else if (s->type == RAW && (!strcasecmp(s->keystr, "kright"))) |
| 364 | s->seq = KEY_RIGHT; |
| 365 | else if (s->type == RAW && (!strcasecmp(s->keystr, "kinsert"))) |
| 366 | s->seq = KEY_IC; |
| 367 | else if (s->type == RAW && (!strcasecmp(s->keystr, "kdel"))) |
| 368 | s->seq = KEY_DC; |
Chris Allegretta | eb64314 | 2008-03-12 04:44:14 +0000 | [diff] [blame] | 369 | else if (s->type == RAW && (!strcasecmp(s->keystr, "kbsp"))) |
| 370 | s->seq = KEY_BACKSPACE; |
| 371 | else if (s->type == RAW && (!strcasecmp(s->keystr, "kenter"))) |
| 372 | s->seq = KEY_ENTER; |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 373 | else if (s->type == RAW && (!strcasecmp(s->keystr, "kpup"))) |
| 374 | s->seq = KEY_PPAGE; |
| 375 | else if (s->type == RAW && (!strcasecmp(s->keystr, "kpdown"))) |
| 376 | s->seq = KEY_NPAGE; |
| 377 | #ifdef KEY_HOME |
| 378 | else if (s->type == RAW && (!strcasecmp(s->keystr, "khome"))) |
| 379 | s->seq = KEY_HOME; |
| 380 | #endif |
| 381 | #ifdef KEY_END |
| 382 | else if (s->type == RAW && (!strcasecmp(s->keystr, "kend"))) |
| 383 | s->seq = KEY_END; |
| 384 | #endif |
Chris Allegretta | 9b42220 | 2008-03-05 17:15:33 +0000 | [diff] [blame] | 385 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | #ifdef DEBUG |
| 389 | |
| 390 | void print_sclist(void) |
| 391 | { |
| 392 | sc *s; |
| 393 | const subnfunc *f; |
| 394 | |
| 395 | for (s = sclist; s->next != NULL; s = s->next) { |
| 396 | f = sctofunc(s); |
| 397 | if (f) |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 398 | fprintf(stderr, "Shortcut \"%s\", function: %s, menus %d\n", s->keystr, f->desc, f->menus); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 399 | else |
| 400 | fprintf(stderr, "Hmm, didnt find a func for \"%s\"\n", s->keystr); |
| 401 | } |
| 402 | |
| 403 | } |
| 404 | #endif |
| 405 | |
| 406 | |
| 407 | /* Stuff we need to make at least static here so we can access it below */ |
| 408 | const char *cancel_msg = N_("Cancel"); |
| 409 | |
| 410 | #ifndef NANO_TINY |
| 411 | const char *case_sens_msg = N_("Case Sens"); |
| 412 | const char *backwards_msg = N_("Backwards"); |
| 413 | #endif |
| 414 | |
| 415 | #ifdef HAVE_REGEX_H |
| 416 | const char *regexp_msg = N_("Regexp"); |
| 417 | #endif |
| 418 | |
| 419 | /* Stuff we want to just stun out if we're in TINY mode */ |
| 420 | #ifdef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 421 | const char *gototext_msg = ""; |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 422 | const char *do_para_begin_msg = ""; |
| 423 | const char *do_para_end_msg = ""; |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 424 | const char *case_sens_msg = ""; |
| 425 | const char *backwards_msg = ""; |
| 426 | const char *do_cut_till_end = ""; |
| 427 | const char *dos_format_msg = ""; |
| 428 | const char *mac_format_msg = ""; |
| 429 | const char *append_msg = ""; |
| 430 | const char *prepend_msg = ""; |
| 431 | const char *backup_file_msg = ""; |
| 432 | const char *to_files_msg = ""; |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 433 | const char *first_file_msg = ""; |
| 434 | const char *whereis_next_msg = ""; |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 435 | const char *last_file_msg = ""; |
| 436 | const char *new_buffer_msg = ""; |
| 437 | const char *goto_dir_msg; |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 438 | const char *ext_cmd_msg = ""; |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 439 | |
| 440 | #else |
Chris Allegretta | 1fb25fd | 2008-03-18 03:06:27 +0000 | [diff] [blame] | 441 | /* TRANSLATORS: Try to keep the next five strings at most 10 characters. */ |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 442 | const char *prev_history_msg = N_("PrevHstory"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 443 | const char *next_history_msg = N_("NextHstory"); |
| 444 | const char *replace_msg = N_("Replace"); |
| 445 | const char *no_replace_msg = N_("No Replace"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 446 | const char *gototext_msg = N_("Go To Text"); |
Chris Allegretta | 1fb25fd | 2008-03-18 03:06:27 +0000 | [diff] [blame] | 447 | /* TRANSLATORS: Try to keep the next three strings at most 12 characters. */ |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 448 | const char *whereis_next_msg = N_("WhereIs Next"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 449 | #ifndef DISABLE_BROWSER |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 450 | const char *first_file_msg = N_("First File"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 451 | const char *last_file_msg = N_("Last File"); |
Chris Allegretta | 1fb25fd | 2008-03-18 03:06:27 +0000 | [diff] [blame] | 452 | /* TRANSLATORS: Try to keep the next nine strings at most 16 characters. */ |
| 453 | const char *to_files_msg = N_("To Files"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 454 | #endif |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 455 | const char *dos_format_msg = N_("DOS Format"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 456 | const char *mac_format_msg = N_("Mac Format"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 457 | const char *append_msg = N_("Append"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 458 | const char *prepend_msg = N_("Prepend"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 459 | const char *backup_file_msg = N_("Backup File"); |
Chris Allegretta | eb64314 | 2008-03-12 04:44:14 +0000 | [diff] [blame] | 460 | const char *ext_cmd_msg = N_("Execute Command"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 461 | #ifdef ENABLE_MULTIBUFFER |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 462 | const char *new_buffer_msg = N_("New Buffer"); |
| 463 | #endif |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 464 | const char *goto_dir_msg = N_("Go To Dir"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 465 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 466 | #endif /* NANO_TINY */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 467 | |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 468 | /* Initialize all shortcut lists. If unjustify is TRUE, replace the |
| 469 | * Uncut shortcut in the main shortcut list with UnJustify. */ |
David Lawrence Ramsey | 1f1ebb8 | 2004-11-11 21:50:01 +0000 | [diff] [blame] | 470 | void shortcut_init(bool unjustify) |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 471 | { |
Chris Allegretta | 1fb25fd | 2008-03-18 03:06:27 +0000 | [diff] [blame] | 472 | /* TRANSLATORS: Try to keep the following strings at most 10 characters. */ |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 473 | const char *get_help_msg = N_("Get Help"); |
| 474 | const char *exit_msg = N_("Exit"); |
David Lawrence Ramsey | e38b808 | 2006-03-30 07:03:04 +0000 | [diff] [blame] | 475 | const char *whereis_msg = N_("Where Is"); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 476 | const char *prev_page_msg = N_("Prev Page"); |
| 477 | const char *next_page_msg = N_("Next Page"); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 478 | const char *first_line_msg = N_("First Line"); |
| 479 | const char *last_line_msg = N_("Last Line"); |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 480 | const char *suspend_msg = N_("Suspend"); |
David Lawrence Ramsey | db6015c | 2004-09-11 21:41:13 +0000 | [diff] [blame] | 481 | #ifndef DISABLE_JUSTIFY |
| 482 | const char *beg_of_par_msg = N_("Beg of Par"); |
| 483 | const char *end_of_par_msg = N_("End of Par"); |
| 484 | const char *fulljstify_msg = N_("FullJstify"); |
| 485 | #endif |
David Lawrence Ramsey | 8137876 | 2006-04-24 20:53:43 +0000 | [diff] [blame] | 486 | const char *refresh_msg = N_("Refresh"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 487 | const char *insert_file_msg = N_("Insert File"); |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 488 | const char *go_to_line_msg = N_("Go To Line"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 489 | |
Chris Allegretta | dab017e | 2002-04-23 10:56:06 +0000 | [diff] [blame] | 490 | #ifndef DISABLE_HELP |
Chris Allegretta | 1fb25fd | 2008-03-18 03:06:27 +0000 | [diff] [blame] | 491 | /* TRANSLATORS: The next long series of strings are shortcut descriptions; |
| 492 | * they are best kept shorter than 56 characters, but may be longer. */ |
David Lawrence Ramsey | 804e107 | 2006-03-29 19:43:32 +0000 | [diff] [blame] | 493 | const char *nano_cancel_msg = N_("Cancel the current function"); |
David Lawrence Ramsey | 57c9afb | 2006-04-14 20:21:45 +0000 | [diff] [blame] | 494 | const char *nano_help_msg = N_("Display this help text"); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 495 | const char *nano_exit_msg = |
Chris Allegretta | 7162e3d | 2002-04-06 05:02:14 +0000 | [diff] [blame] | 496 | #ifdef ENABLE_MULTIBUFFER |
David Lawrence Ramsey | be231d3 | 2006-05-21 21:37:21 +0000 | [diff] [blame] | 497 | N_("Close the current file buffer / Exit from nano") |
Chris Allegretta | 2d7893d | 2001-07-11 02:08:33 +0000 | [diff] [blame] | 498 | #else |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 499 | N_("Exit from nano") |
Chris Allegretta | 2d7893d | 2001-07-11 02:08:33 +0000 | [diff] [blame] | 500 | #endif |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 501 | ; |
David Lawrence Ramsey | 9b108c2 | 2005-06-06 18:38:16 +0000 | [diff] [blame] | 502 | const char *nano_writeout_msg = |
| 503 | N_("Write the current file to disk"); |
Chris Allegretta | 90ee8ee | 2008-03-20 04:45:55 +0000 | [diff] [blame] | 504 | #ifndef DISABLE_JUSTIFY |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 505 | const char *nano_justify_msg = N_("Justify the current paragraph"); |
Chris Allegretta | 90ee8ee | 2008-03-20 04:45:55 +0000 | [diff] [blame] | 506 | #endif |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 507 | const char *nano_insert_msg = |
| 508 | N_("Insert another file into the current one"); |
David Lawrence Ramsey | 9b108c2 | 2005-06-06 18:38:16 +0000 | [diff] [blame] | 509 | const char *nano_whereis_msg = |
David Lawrence Ramsey | be231d3 | 2006-05-21 21:37:21 +0000 | [diff] [blame] | 510 | N_("Search for a string or a regular expression"); |
David Lawrence Ramsey | 9f1db5d | 2007-02-01 13:40:59 +0000 | [diff] [blame] | 511 | const char *nano_prevpage_msg = N_("Go to previous screen"); |
| 512 | const char *nano_nextpage_msg = N_("Go to next screen"); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 513 | const char *nano_cut_msg = |
| 514 | N_("Cut the current line and store it in the cutbuffer"); |
| 515 | const char *nano_uncut_msg = |
| 516 | N_("Uncut from the cutbuffer into the current line"); |
David Lawrence Ramsey | 9b108c2 | 2005-06-06 18:38:16 +0000 | [diff] [blame] | 517 | const char *nano_cursorpos_msg = |
David Lawrence Ramsey | f50bd4b | 2006-04-14 20:15:44 +0000 | [diff] [blame] | 518 | N_("Display the position of the cursor"); |
David Lawrence Ramsey | 9b108c2 | 2005-06-06 18:38:16 +0000 | [diff] [blame] | 519 | const char *nano_spell_msg = |
| 520 | N_("Invoke the spell checker, if available"); |
David Lawrence Ramsey | be231d3 | 2006-05-21 21:37:21 +0000 | [diff] [blame] | 521 | const char *nano_replace_msg = |
| 522 | N_("Replace a string or a regular expression"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 523 | const char *nano_gotoline_msg = N_("Go to line and column number"); |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 524 | #ifndef NANO_TINY |
David Lawrence Ramsey | 8381fdd | 2004-11-01 22:40:02 +0000 | [diff] [blame] | 525 | const char *nano_mark_msg = N_("Mark text at the cursor position"); |
| 526 | const char *nano_whereis_next_msg = N_("Repeat last search"); |
David Lawrence Ramsey | cf1879b | 2006-04-27 23:39:49 +0000 | [diff] [blame] | 527 | const char *nano_copy_msg = |
| 528 | N_("Copy the current line and store it in the cutbuffer"); |
David Lawrence Ramsey | aee00d4 | 2006-07-05 18:42:22 +0000 | [diff] [blame] | 529 | const char *nano_indent_msg = N_("Indent the current line"); |
| 530 | const char *nano_unindent_msg = N_("Unindent the current line"); |
David Lawrence Ramsey | 4b4b608 | 2004-11-01 22:54:40 +0000 | [diff] [blame] | 531 | #endif |
David Lawrence Ramsey | 9f1db5d | 2007-02-01 13:40:59 +0000 | [diff] [blame] | 532 | const char *nano_forward_msg = N_("Go forward one character"); |
| 533 | const char *nano_back_msg = N_("Go back one character"); |
David Lawrence Ramsey | 854a44a | 2006-04-24 21:14:55 +0000 | [diff] [blame] | 534 | #ifndef NANO_TINY |
David Lawrence Ramsey | 9f1db5d | 2007-02-01 13:40:59 +0000 | [diff] [blame] | 535 | const char *nano_nextword_msg = N_("Go forward one word"); |
| 536 | const char *nano_prevword_msg = N_("Go back one word"); |
David Lawrence Ramsey | 854a44a | 2006-04-24 21:14:55 +0000 | [diff] [blame] | 537 | #endif |
David Lawrence Ramsey | 9f1db5d | 2007-02-01 13:40:59 +0000 | [diff] [blame] | 538 | const char *nano_prevline_msg = N_("Go to previous line"); |
| 539 | const char *nano_nextline_msg = N_("Go to next line"); |
| 540 | const char *nano_home_msg = N_("Go to beginning of current line"); |
| 541 | const char *nano_end_msg = N_("Go to end of current line"); |
David Lawrence Ramsey | db6015c | 2004-09-11 21:41:13 +0000 | [diff] [blame] | 542 | #ifndef DISABLE_JUSTIFY |
| 543 | const char *nano_parabegin_msg = |
David Lawrence Ramsey | 9f1db5d | 2007-02-01 13:40:59 +0000 | [diff] [blame] | 544 | N_("Go to beginning of paragraph; then of previous paragraph"); |
David Lawrence Ramsey | db6015c | 2004-09-11 21:41:13 +0000 | [diff] [blame] | 545 | const char *nano_paraend_msg = |
David Lawrence Ramsey | 9f1db5d | 2007-02-01 13:40:59 +0000 | [diff] [blame] | 546 | N_("Go just beyond end of paragraph; then of next paragraph"); |
David Lawrence Ramsey | db6015c | 2004-09-11 21:41:13 +0000 | [diff] [blame] | 547 | #endif |
David Lawrence Ramsey | 854a44a | 2006-04-24 21:14:55 +0000 | [diff] [blame] | 548 | const char *nano_firstline_msg = |
David Lawrence Ramsey | 9f1db5d | 2007-02-01 13:40:59 +0000 | [diff] [blame] | 549 | N_("Go to the first line of the file"); |
David Lawrence Ramsey | 854a44a | 2006-04-24 21:14:55 +0000 | [diff] [blame] | 550 | const char *nano_lastline_msg = |
David Lawrence Ramsey | 9f1db5d | 2007-02-01 13:40:59 +0000 | [diff] [blame] | 551 | N_("Go to the last line of the file"); |
David Lawrence Ramsey | 854a44a | 2006-04-24 21:14:55 +0000 | [diff] [blame] | 552 | #ifndef NANO_TINY |
David Lawrence Ramsey | 9f1db5d | 2007-02-01 13:40:59 +0000 | [diff] [blame] | 553 | const char *nano_bracket_msg = N_("Go to the matching bracket"); |
David Lawrence Ramsey | 854a44a | 2006-04-24 21:14:55 +0000 | [diff] [blame] | 554 | const char *nano_scrollup_msg = |
| 555 | N_("Scroll up one line without scrolling the cursor"); |
| 556 | const char *nano_scrolldown_msg = |
| 557 | N_("Scroll down one line without scrolling the cursor"); |
| 558 | #endif |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 559 | #ifdef ENABLE_MULTIBUFFER |
David Lawrence Ramsey | 6ad59cd | 2005-07-08 20:09:16 +0000 | [diff] [blame] | 560 | const char *nano_prevfile_msg = |
David Lawrence Ramsey | 9b108c2 | 2005-06-06 18:38:16 +0000 | [diff] [blame] | 561 | N_("Switch to the previous file buffer"); |
David Lawrence Ramsey | 6ad59cd | 2005-07-08 20:09:16 +0000 | [diff] [blame] | 562 | const char *nano_nextfile_msg = |
David Lawrence Ramsey | 9b108c2 | 2005-06-06 18:38:16 +0000 | [diff] [blame] | 563 | N_("Switch to the next file buffer"); |
David Lawrence Ramsey | db6015c | 2004-09-11 21:41:13 +0000 | [diff] [blame] | 564 | #endif |
David Lawrence Ramsey | 40e0572 | 2006-04-23 19:21:12 +0000 | [diff] [blame] | 565 | const char *nano_verbatim_msg = |
David Lawrence Ramsey | 939d423 | 2006-04-24 21:00:17 +0000 | [diff] [blame] | 566 | N_("Insert the next keystroke verbatim"); |
David Lawrence Ramsey | 854a44a | 2006-04-24 21:14:55 +0000 | [diff] [blame] | 567 | const char *nano_tab_msg = |
David Lawrence Ramsey | bf78420 | 2006-04-29 13:59:04 +0000 | [diff] [blame] | 568 | N_("Insert a tab at the cursor position"); |
David Lawrence Ramsey | 854a44a | 2006-04-24 21:14:55 +0000 | [diff] [blame] | 569 | const char *nano_enter_msg = |
David Lawrence Ramsey | cf1879b | 2006-04-27 23:39:49 +0000 | [diff] [blame] | 570 | N_("Insert a newline at the cursor position"); |
David Lawrence Ramsey | 854a44a | 2006-04-24 21:14:55 +0000 | [diff] [blame] | 571 | const char *nano_delete_msg = |
| 572 | N_("Delete the character under the cursor"); |
| 573 | const char *nano_backspace_msg = |
| 574 | N_("Delete the character to the left of the cursor"); |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 575 | #ifndef NANO_TINY |
David Lawrence Ramsey | 295d172 | 2005-01-01 07:43:32 +0000 | [diff] [blame] | 576 | const char *nano_cut_till_end_msg = |
| 577 | N_("Cut from the cursor position to the end of the file"); |
| 578 | #endif |
David Lawrence Ramsey | db6015c | 2004-09-11 21:41:13 +0000 | [diff] [blame] | 579 | #ifndef DISABLE_JUSTIFY |
| 580 | const char *nano_fulljustify_msg = N_("Justify the entire file"); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 581 | #endif |
David Lawrence Ramsey | c5c5230 | 2005-11-15 23:45:29 +0000 | [diff] [blame] | 582 | #ifndef NANO_TINY |
David Lawrence Ramsey | 854a44a | 2006-04-24 21:14:55 +0000 | [diff] [blame] | 583 | const char *nano_wordcount_msg = |
| 584 | N_("Count the number of words, lines, and characters"); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 585 | #endif |
David Lawrence Ramsey | 854a44a | 2006-04-24 21:14:55 +0000 | [diff] [blame] | 586 | const char *nano_refresh_msg = |
| 587 | N_("Refresh (redraw) the current screen"); |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 588 | const char *nano_suspend_msg = |
| 589 | N_("Suspend the editor (if suspend is enabled)"); |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 590 | #ifndef NANO_TINY |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 591 | const char *nano_case_msg = |
David Lawrence Ramsey | 69e1ce5 | 2006-06-08 02:37:45 +0000 | [diff] [blame] | 592 | N_("Toggle the case sensitivity of the search"); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 593 | const char *nano_reverse_msg = |
David Lawrence Ramsey | 69e1ce5 | 2006-06-08 02:37:45 +0000 | [diff] [blame] | 594 | N_("Reverse the direction of the search"); |
David Lawrence Ramsey | c10d8ff | 2005-06-03 20:51:39 +0000 | [diff] [blame] | 595 | #endif |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 596 | #ifdef HAVE_REGEX_H |
David Lawrence Ramsey | 69e1ce5 | 2006-06-08 02:37:45 +0000 | [diff] [blame] | 597 | const char *nano_regexp_msg = |
| 598 | N_("Toggle the use of regular expressions"); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 599 | #endif |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 600 | #ifndef NANO_TINY |
David Lawrence Ramsey | 305d889 | 2006-05-24 19:48:03 +0000 | [diff] [blame] | 601 | const char *nano_prev_history_msg = |
David Lawrence Ramsey | 7b0531a | 2006-07-31 01:30:31 +0000 | [diff] [blame] | 602 | N_("Recall the previous search/replace string"); |
David Lawrence Ramsey | 305d889 | 2006-05-24 19:48:03 +0000 | [diff] [blame] | 603 | const char *nano_next_history_msg = |
David Lawrence Ramsey | 7b0531a | 2006-07-31 01:30:31 +0000 | [diff] [blame] | 604 | N_("Recall the next search/replace string"); |
David Lawrence Ramsey | c10d8ff | 2005-06-03 20:51:39 +0000 | [diff] [blame] | 605 | #endif |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 606 | #ifndef DISABLE_BROWSER |
| 607 | const char *nano_tofiles_msg = N_("Go to file browser"); |
| 608 | #endif |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 609 | #ifndef NANO_TINY |
David Lawrence Ramsey | 69e1ce5 | 2006-06-08 02:37:45 +0000 | [diff] [blame] | 610 | const char *nano_dos_msg = N_("Toggle the use of DOS format"); |
| 611 | const char *nano_mac_msg = N_("Toggle the use of Mac format"); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 612 | #endif |
David Lawrence Ramsey | 69e1ce5 | 2006-06-08 02:37:45 +0000 | [diff] [blame] | 613 | const char *nano_append_msg = N_("Toggle appending"); |
| 614 | const char *nano_prepend_msg = N_("Toggle prepending"); |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 615 | #ifndef NANO_TINY |
David Lawrence Ramsey | 9b108c2 | 2005-06-06 18:38:16 +0000 | [diff] [blame] | 616 | const char *nano_backup_msg = |
David Lawrence Ramsey | 69e1ce5 | 2006-06-08 02:37:45 +0000 | [diff] [blame] | 617 | N_("Toggle backing up of the original file"); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 618 | const char *nano_execute_msg = N_("Execute external command"); |
| 619 | #endif |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 620 | #if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER) |
David Lawrence Ramsey | 69e1ce5 | 2006-06-08 02:37:45 +0000 | [diff] [blame] | 621 | const char *nano_multibuffer_msg = |
| 622 | N_("Toggle the use of a new buffer"); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 623 | #endif |
| 624 | #ifndef DISABLE_BROWSER |
David Lawrence Ramsey | c41d428 | 2004-07-23 12:51:40 +0000 | [diff] [blame] | 625 | const char *nano_exitbrowser_msg = N_("Exit from the file browser"); |
David Lawrence Ramsey | e38b808 | 2006-03-30 07:03:04 +0000 | [diff] [blame] | 626 | const char *nano_firstfile_msg = |
| 627 | N_("Go to the first file in the list"); |
| 628 | const char *nano_lastfile_msg = |
| 629 | N_("Go to the last file in the list"); |
David Lawrence Ramsey | c41d428 | 2004-07-23 12:51:40 +0000 | [diff] [blame] | 630 | const char *nano_gotodir_msg = N_("Go to directory"); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 631 | |
Chris Allegretta | 2bef182 | 2001-09-28 19:53:11 +0000 | [diff] [blame] | 632 | #endif |
Chris Allegretta | dab017e | 2002-04-23 10:56:06 +0000 | [diff] [blame] | 633 | #endif /* !DISABLE_HELP */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 634 | |
David Lawrence Ramsey | ea43a1d | 2004-03-02 22:52:57 +0000 | [diff] [blame] | 635 | #ifndef DISABLE_HELP |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 636 | #define IFSCHELP(help) help |
David Lawrence Ramsey | ea43a1d | 2004-03-02 22:52:57 +0000 | [diff] [blame] | 637 | #else |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 638 | #define IFSCHELP(help) "" |
Chris Allegretta | dab017e | 2002-04-23 10:56:06 +0000 | [diff] [blame] | 639 | #endif |
David Lawrence Ramsey | a593f53 | 2003-11-28 19:47:42 +0000 | [diff] [blame] | 640 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 641 | while (allfuncs != NULL) { |
| 642 | subnfunc *f = allfuncs; |
| 643 | allfuncs = (allfuncs)->next; |
| 644 | free(f); |
| 645 | } |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 646 | |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 647 | #ifndef DISABLE_HELP |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 648 | add_to_funcs(do_help_void, MALL, get_help_msg, nano_help_msg, |
| 649 | FALSE, VIEW); |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 650 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 651 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 652 | add_to_funcs((void *) cancel_msg, |
Chris Allegretta | cc59383 | 2008-03-19 02:32:48 +0000 | [diff] [blame] | 653 | (MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR|MYESNO), |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 654 | cancel_msg, IFSCHELP(nano_cancel_msg), FALSE, VIEW); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 655 | |
| 656 | add_to_funcs(do_exit, MMAIN, |
Chris Allegretta | 355fbe5 | 2001-07-14 19:32:47 +0000 | [diff] [blame] | 657 | #ifdef ENABLE_MULTIBUFFER |
David Lawrence Ramsey | cde9039 | 2006-04-09 18:27:42 +0000 | [diff] [blame] | 658 | /* TRANSLATORS: Try to keep this at most 10 characters. */ |
David Lawrence Ramsey | 017dde2 | 2006-03-24 05:28:03 +0000 | [diff] [blame] | 659 | openfile != NULL && openfile != openfile->next ? N_("Close") : |
Chris Allegretta | 2d7893d | 2001-07-11 02:08:33 +0000 | [diff] [blame] | 660 | #endif |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 661 | exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 662 | |
Chris Allegretta | 90ee8ee | 2008-03-20 04:45:55 +0000 | [diff] [blame] | 663 | add_to_funcs(do_exit, MHELP, exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW); |
| 664 | |
Chris Allegretta | dcd19c9 | 2008-03-20 04:51:26 +0000 | [diff] [blame] | 665 | #ifndef DISABLE_BROWSER |
Chris Allegretta | 90ee8ee | 2008-03-20 04:45:55 +0000 | [diff] [blame] | 666 | add_to_funcs(do_exit, MBROWSER, exit_msg, IFSCHELP(nano_exitbrowser_msg), FALSE, VIEW); |
Chris Allegretta | dcd19c9 | 2008-03-20 04:51:26 +0000 | [diff] [blame] | 667 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 668 | |
David Lawrence Ramsey | cde9039 | 2006-04-09 18:27:42 +0000 | [diff] [blame] | 669 | /* TRANSLATORS: Try to keep this at most 10 characters. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 670 | add_to_funcs(do_writeout_void, MMAIN, N_("WriteOut"), |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 671 | IFSCHELP(nano_writeout_msg), FALSE, NOVIEW); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 672 | |
David Lawrence Ramsey | a539fce | 2004-06-29 00:43:56 +0000 | [diff] [blame] | 673 | #ifndef DISABLE_JUSTIFY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 674 | /* TRANSLATORS: Try to keep this at most 10 characters. */ |
| 675 | add_to_funcs(do_justify_void, MMAIN, N_("Justify"), |
| 676 | nano_justify_msg, TRUE, NOVIEW); |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 677 | #endif |
Chris Allegretta | 32da456 | 2002-01-02 15:12:21 +0000 | [diff] [blame] | 678 | |
David Lawrence Ramsey | 32e3b88 | 2004-05-29 01:20:17 +0000 | [diff] [blame] | 679 | /* We allow inserting files in view mode if multibuffers are |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 680 | * available, so that we can view multiple files. If we're using |
| 681 | * restricted mode, inserting files is disabled, since it allows |
| 682 | * reading from or writing to files not specified on the command |
| 683 | * line. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 684 | add_to_funcs(!ISSET(RESTRICTED) ? do_insertfile_void : nano_disabled_msg, |
Chris Allegretta | 1fb25fd | 2008-03-18 03:06:27 +0000 | [diff] [blame] | 685 | /* TRANSLATORS: Try to keep this at most 10 characters. */ |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 686 | MMAIN, N_("Read File"), IFSCHELP(nano_insert_msg), FALSE, |
Chris Allegretta | 32da456 | 2002-01-02 15:12:21 +0000 | [diff] [blame] | 687 | #ifdef ENABLE_MULTIBUFFER |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 688 | VIEW); |
Chris Allegretta | 32da456 | 2002-01-02 15:12:21 +0000 | [diff] [blame] | 689 | #else |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 690 | NOVIEW); |
Chris Allegretta | 32da456 | 2002-01-02 15:12:21 +0000 | [diff] [blame] | 691 | #endif |
Chris Allegretta | af6414a | 2001-02-11 19:05:05 +0000 | [diff] [blame] | 692 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 693 | add_to_funcs(do_search, MMAIN|MBROWSER, whereis_msg, |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 694 | IFSCHELP(nano_whereis_msg), FALSE, VIEW); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 695 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 696 | add_to_funcs(do_page_up, MMAIN|MHELP, |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 697 | prev_page_msg, IFSCHELP(nano_prevpage_msg), FALSE, VIEW); |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 698 | add_to_funcs(do_page_down, MMAIN|MHELP, |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 699 | next_page_msg, IFSCHELP(nano_nextpage_msg), TRUE, VIEW); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 700 | |
David Lawrence Ramsey | cde9039 | 2006-04-09 18:27:42 +0000 | [diff] [blame] | 701 | /* TRANSLATORS: Try to keep this at most 10 characters. */ |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 702 | add_to_funcs(do_cut_text_void, MMAIN, N_("Cut Text"), IFSCHELP(nano_cut_msg), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 703 | FALSE, NOVIEW); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 704 | |
Chris Allegretta | 0779835 | 2000-11-27 22:58:23 +0000 | [diff] [blame] | 705 | if (unjustify) |
David Lawrence Ramsey | ed467e5 | 2006-07-03 18:40:53 +0000 | [diff] [blame] | 706 | /* TRANSLATORS: Try to keep this at most 10 characters. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 707 | add_to_funcs(do_uncut_text, MMAIN, N_("UnJustify"), "", |
| 708 | FALSE, NOVIEW); |
| 709 | |
Chris Allegretta | 0779835 | 2000-11-27 22:58:23 +0000 | [diff] [blame] | 710 | else |
David Lawrence Ramsey | ed467e5 | 2006-07-03 18:40:53 +0000 | [diff] [blame] | 711 | /* TRANSLATORS: Try to keep this at most 10 characters. */ |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 712 | add_to_funcs(do_uncut_text, MMAIN, N_("UnCut Text"), IFSCHELP(nano_uncut_msg), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 713 | FALSE, NOVIEW); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 714 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 715 | #ifndef NANO_TINY |
Chris Allegretta | 1fb25fd | 2008-03-18 03:06:27 +0000 | [diff] [blame] | 716 | /* TRANSLATORS: Try to keep this at most 10 characters. */ |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 717 | add_to_funcs(do_cursorpos_void, MMAIN, N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 718 | FALSE, VIEW); |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 719 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 720 | |
David Lawrence Ramsey | 32e3b88 | 2004-05-29 01:20:17 +0000 | [diff] [blame] | 721 | /* If we're using restricted mode, spell checking is disabled |
| 722 | * because it allows reading from or writing to files not specified |
| 723 | * on the command line. */ |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 724 | #ifndef DISABLE_SPELLER |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 725 | if (!ISSET(RESTRICTED)) |
Chris Allegretta | 1fb25fd | 2008-03-18 03:06:27 +0000 | [diff] [blame] | 726 | /* TRANSLATORS: Try to keep this at most 10 characters. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 727 | add_to_funcs(do_spell, MMAIN, N_("To Spell"), nano_spell_msg, |
| 728 | TRUE, NOVIEW); |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 729 | #endif |
David Lawrence Ramsey | a593f53 | 2003-11-28 19:47:42 +0000 | [diff] [blame] | 730 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 731 | add_to_funcs(do_first_line, |
| 732 | (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP), |
Chris Allegretta | 1fb25fd | 2008-03-18 03:06:27 +0000 | [diff] [blame] | 733 | first_line_msg, IFSCHELP(nano_firstline_msg), FALSE, VIEW); |
David Lawrence Ramsey | a593f53 | 2003-11-28 19:47:42 +0000 | [diff] [blame] | 734 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 735 | add_to_funcs(do_last_line, |
| 736 | (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP), |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 737 | last_line_msg, IFSCHELP(nano_lastline_msg), TRUE, VIEW); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 738 | |
| 739 | |
| 740 | add_to_funcs(do_gotolinecolumn_void, (MMAIN|MWHEREIS), |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 741 | go_to_line_msg, IFSCHELP(nano_gotoline_msg), FALSE, VIEW); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 742 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 743 | #ifdef NANO_TINY |
Chris Allegretta | 1fb25fd | 2008-03-18 03:06:27 +0000 | [diff] [blame] | 744 | /* TRANSLATORS: Try to keep this at most 10 characters. */ |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 745 | add_to_funcs(do_cursorpos_void, MMAIN, N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg), |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 746 | FALSE, VIEW); |
| 747 | #endif |
| 748 | |
| 749 | |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 750 | add_to_funcs(do_replace, (MMAIN|MWHEREIS), replace_msg, IFSCHELP(nano_replace_msg), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 751 | |
David Lawrence Ramsey | f1e5627 | 2006-05-22 18:28:20 +0000 | [diff] [blame] | 752 | #ifndef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 753 | FALSE, |
David Lawrence Ramsey | f1e5627 | 2006-05-22 18:28:20 +0000 | [diff] [blame] | 754 | #else |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 755 | TRUE, |
David Lawrence Ramsey | f1e5627 | 2006-05-22 18:28:20 +0000 | [diff] [blame] | 756 | #endif |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 757 | NOVIEW); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 758 | |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 759 | #ifndef NANO_TINY |
David Lawrence Ramsey | efb4b0a | 2006-04-19 14:09:01 +0000 | [diff] [blame] | 760 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 761 | add_to_funcs(do_mark, MMAIN, N_("Mark Text"), |
| 762 | nano_mark_msg, FALSE, VIEW); |
David Lawrence Ramsey | cf1879b | 2006-04-27 23:39:49 +0000 | [diff] [blame] | 763 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 764 | add_to_funcs(do_research, (MMAIN|MBROWSER), whereis_next_msg, |
| 765 | nano_whereis_next_msg, TRUE, VIEW); |
David Lawrence Ramsey | f85001a | 2006-04-28 13:19:56 +0000 | [diff] [blame] | 766 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 767 | add_to_funcs(do_copy_text, MMAIN, N_("Copy Text"), |
| 768 | nano_copy_msg, FALSE, NOVIEW); |
David Lawrence Ramsey | f85001a | 2006-04-28 13:19:56 +0000 | [diff] [blame] | 769 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 770 | add_to_funcs(do_indent_void, MMAIN, N_("Indent Text"), |
| 771 | nano_indent_msg, FALSE, NOVIEW); |
| 772 | |
| 773 | add_to_funcs(do_unindent, MMAIN, N_("Unindent Text"), |
| 774 | nano_unindent_msg, TRUE, NOVIEW); |
| 775 | |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 776 | #endif |
| 777 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 778 | add_to_funcs(do_page_up, MBROWSER, |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 779 | prev_page_msg, IFSCHELP(nano_prevpage_msg), FALSE, VIEW); |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 780 | add_to_funcs(do_page_down, MBROWSER, |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 781 | next_page_msg, IFSCHELP(nano_nextpage_msg), TRUE, VIEW); |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 782 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 783 | |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 784 | add_to_funcs(do_right, (MMAIN|MBROWSER), N_("Forward"), IFSCHELP(nano_forward_msg), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 785 | FALSE, VIEW); |
Chris Allegretta | eb64314 | 2008-03-12 04:44:14 +0000 | [diff] [blame] | 786 | add_to_funcs(do_right, MALL, "", "", FALSE, VIEW); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 787 | |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 788 | add_to_funcs(do_left, (MMAIN|MBROWSER), N_("Back"), IFSCHELP(nano_back_msg), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 789 | FALSE, VIEW); |
Chris Allegretta | eb64314 | 2008-03-12 04:44:14 +0000 | [diff] [blame] | 790 | add_to_funcs(do_left, MALL, "", "", FALSE, VIEW); |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 791 | |
| 792 | #ifndef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 793 | add_to_funcs(do_next_word_void, MMAIN, N_("Next Word"), |
| 794 | nano_nextword_msg, FALSE, VIEW); |
David Lawrence Ramsey | c596755 | 2002-06-21 03:20:06 +0000 | [diff] [blame] | 795 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 796 | add_to_funcs(do_prev_word_void, MMAIN, N_("Prev Word"), |
| 797 | nano_prevword_msg, FALSE, VIEW); |
Chris Allegretta | 8d990b5 | 2001-09-22 22:14:25 +0000 | [diff] [blame] | 798 | #endif |
David Lawrence Ramsey | e049706 | 2003-08-23 21:11:06 +0000 | [diff] [blame] | 799 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 800 | add_to_funcs(do_up_void, (MMAIN|MHELP|MBROWSER), N_("Prev Line"), |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 801 | IFSCHELP(nano_prevline_msg), FALSE, VIEW); |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 802 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 803 | add_to_funcs(do_down_void, (MMAIN|MHELP|MBROWSER), N_("Next Line"), |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 804 | IFSCHELP(nano_nextline_msg), TRUE, VIEW); |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 805 | |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 806 | add_to_funcs(do_home, MMAIN, N_("Home"), IFSCHELP(nano_home_msg), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 807 | FALSE, VIEW); |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 808 | |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 809 | add_to_funcs(do_end, MMAIN, N_("End"), IFSCHELP(nano_end_msg), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 810 | FALSE, VIEW); |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 811 | |
David Lawrence Ramsey | db6015c | 2004-09-11 21:41:13 +0000 | [diff] [blame] | 812 | #ifndef DISABLE_JUSTIFY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 813 | add_to_funcs(do_para_begin_void, (MMAIN|MWHEREIS), beg_of_par_msg, |
| 814 | nano_parabegin_msg, FALSE, VIEW); |
David Lawrence Ramsey | db6015c | 2004-09-11 21:41:13 +0000 | [diff] [blame] | 815 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 816 | add_to_funcs(do_para_end_void, (MMAIN|MWHEREIS), end_of_par_msg, |
| 817 | nano_paraend_msg, FALSE, VIEW); |
David Lawrence Ramsey | db6015c | 2004-09-11 21:41:13 +0000 | [diff] [blame] | 818 | #endif |
David Lawrence Ramsey | e049706 | 2003-08-23 21:11:06 +0000 | [diff] [blame] | 819 | |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 820 | #ifndef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 821 | add_to_funcs(do_find_bracket, MMAIN, _("Find Other Bracket"), |
| 822 | nano_bracket_msg, FALSE, VIEW); |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 823 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 824 | add_to_funcs(do_scroll_up, MMAIN, N_("Scroll Up"), |
| 825 | nano_scrollup_msg, FALSE, VIEW); |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 826 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 827 | add_to_funcs(do_scroll_down, MMAIN, N_("Scroll Down"), |
| 828 | nano_scrolldown_msg, FALSE, VIEW); |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 829 | #endif |
David Lawrence Ramsey | df45365 | 2006-04-21 02:05:09 +0000 | [diff] [blame] | 830 | |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 831 | #ifdef ENABLE_MULTIBUFFER |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 832 | add_to_funcs(switch_to_prev_buffer_void, MMAIN, _("Previous File"), |
Chris Allegretta | 2cca483 | 2008-03-31 06:25:14 +0000 | [diff] [blame^] | 833 | IFSCHELP(nano_prevfile_msg), FALSE, VIEW); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 834 | add_to_funcs(switch_to_next_buffer_void, MMAIN, N_("Next File"), |
Chris Allegretta | 2cca483 | 2008-03-31 06:25:14 +0000 | [diff] [blame^] | 835 | IFSCHELP(nano_nextfile_msg), TRUE, VIEW); |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 836 | #endif |
Chris Allegretta | b3655b4 | 2001-10-22 03:15:31 +0000 | [diff] [blame] | 837 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 838 | add_to_funcs(do_verbatim_input, MMAIN, N_("Verbatim Input"), |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 839 | IFSCHELP(nano_verbatim_msg), FALSE, NOVIEW); |
Chris Allegretta | aa17df0 | 2008-03-17 05:50:04 +0000 | [diff] [blame] | 840 | add_to_funcs(do_verbatim_input, MWHEREIS|MREPLACE|MREPLACE2|MEXTCMD|MSPELL, |
| 841 | "", "", FALSE, NOVIEW); |
| 842 | |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 843 | add_to_funcs(do_tab, MMAIN, N_("Tab"), IFSCHELP(nano_tab_msg), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 844 | FALSE, NOVIEW); |
Chris Allegretta | eb64314 | 2008-03-12 04:44:14 +0000 | [diff] [blame] | 845 | add_to_funcs(do_tab, MALL, "", "", FALSE, NOVIEW); |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 846 | add_to_funcs(do_enter, MMAIN, N_("Enter"), IFSCHELP(nano_enter_msg), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 847 | FALSE, NOVIEW); |
Chris Allegretta | eb64314 | 2008-03-12 04:44:14 +0000 | [diff] [blame] | 848 | add_to_funcs(do_enter, MALL, "", "", FALSE, NOVIEW); |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 849 | add_to_funcs(do_delete, MMAIN, N_("Delete"), IFSCHELP(nano_delete_msg), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 850 | FALSE, NOVIEW); |
Chris Allegretta | eb64314 | 2008-03-12 04:44:14 +0000 | [diff] [blame] | 851 | add_to_funcs(do_delete, MALL, "", "", FALSE, NOVIEW); |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 852 | add_to_funcs(do_backspace, MMAIN, N_("Backspace"), IFSCHELP(nano_backspace_msg), |
David Lawrence Ramsey | bf48798 | 2006-04-24 20:50:52 +0000 | [diff] [blame] | 853 | #ifndef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 854 | FALSE, |
David Lawrence Ramsey | bf48798 | 2006-04-24 20:50:52 +0000 | [diff] [blame] | 855 | #else |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 856 | TRUE, |
David Lawrence Ramsey | bf48798 | 2006-04-24 20:50:52 +0000 | [diff] [blame] | 857 | #endif |
Chris Allegretta | eb64314 | 2008-03-12 04:44:14 +0000 | [diff] [blame] | 858 | NOVIEW); |
| 859 | |
| 860 | add_to_funcs(do_backspace, MALL, "", "", |
| 861 | #ifndef NANO_TINY |
| 862 | FALSE, |
| 863 | #else |
| 864 | TRUE, |
| 865 | #endif |
| 866 | NOVIEW); |
David Lawrence Ramsey | 295d172 | 2005-01-01 07:43:32 +0000 | [diff] [blame] | 867 | |
David Lawrence Ramsey | 2ca2356 | 2006-04-23 19:15:15 +0000 | [diff] [blame] | 868 | #ifndef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 869 | add_to_funcs(do_cut_till_end, MMAIN, N_("CutTillEnd"), |
| 870 | nano_cut_till_end_msg, TRUE, NOVIEW); |
David Lawrence Ramsey | 2ca2356 | 2006-04-23 19:15:15 +0000 | [diff] [blame] | 871 | #endif |
| 872 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 873 | add_to_funcs(xon_complaint, MMAIN, "", "", FALSE, VIEW); |
| 874 | add_to_funcs(xoff_complaint, MMAIN, "", "", FALSE, VIEW); |
| 875 | |
David Lawrence Ramsey | db6015c | 2004-09-11 21:41:13 +0000 | [diff] [blame] | 876 | #ifndef DISABLE_JUSTIFY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 877 | add_to_funcs(do_full_justify, (MMAIN|MWHEREIS), fulljstify_msg, |
| 878 | nano_fulljustify_msg, FALSE, NOVIEW); |
David Lawrence Ramsey | db6015c | 2004-09-11 21:41:13 +0000 | [diff] [blame] | 879 | #endif |
| 880 | |
David Lawrence Ramsey | c5c5230 | 2005-11-15 23:45:29 +0000 | [diff] [blame] | 881 | #ifndef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 882 | add_to_funcs(do_wordlinechar_count, MMAIN, N_("Word Count"), |
| 883 | nano_wordcount_msg, FALSE, VIEW); |
David Lawrence Ramsey | 1df3e2d | 2006-04-22 19:45:26 +0000 | [diff] [blame] | 884 | #endif |
David Lawrence Ramsey | efb4b0a | 2006-04-19 14:09:01 +0000 | [diff] [blame] | 885 | |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 886 | add_to_funcs(total_refresh, (MMAIN|MHELP), refresh_msg, |
| 887 | IFSCHELP(nano_refresh_msg), FALSE, VIEW); |
| 888 | |
| 889 | add_to_funcs(do_suspend_void, MMAIN, suspend_msg, |
| 890 | IFSCHELP(nano_suspend_msg), TRUE, VIEW); |
David Lawrence Ramsey | 8faf305 | 2003-09-04 20:25:29 +0000 | [diff] [blame] | 891 | |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 892 | #ifndef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 893 | add_to_funcs((void *) case_sens_msg, |
| 894 | (MWHEREIS|MREPLACE|MWHEREISFILE), |
| 895 | case_sens_msg, nano_case_msg, FALSE, VIEW); |
Chris Allegretta | 658399a | 2001-06-14 02:54:22 +0000 | [diff] [blame] | 896 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 897 | add_to_funcs((void *) backwards_msg, |
| 898 | (MWHEREIS|MREPLACE|MWHEREISFILE), |
| 899 | backwards_msg, nano_reverse_msg, FALSE, VIEW); |
David Lawrence Ramsey | c10d8ff | 2005-06-03 20:51:39 +0000 | [diff] [blame] | 900 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 901 | |
Chris Allegretta | 658399a | 2001-06-14 02:54:22 +0000 | [diff] [blame] | 902 | #ifdef HAVE_REGEX_H |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 903 | add_to_funcs((void *) regexp_msg, |
| 904 | (MWHEREIS|MREPLACE|MWHEREISFILE), |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 905 | regexp_msg, IFSCHELP(nano_regexp_msg), FALSE, VIEW); |
Chris Allegretta | 658399a | 2001-06-14 02:54:22 +0000 | [diff] [blame] | 906 | #endif |
Chris Allegretta | 5beed50 | 2003-01-05 20:41:21 +0000 | [diff] [blame] | 907 | |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 908 | #ifndef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 909 | add_to_funcs((void *) prev_history_msg, |
| 910 | (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE), |
| 911 | prev_history_msg, nano_prev_history_msg, FALSE, VIEW); |
David Lawrence Ramsey | 305d889 | 2006-05-24 19:48:03 +0000 | [diff] [blame] | 912 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 913 | add_to_funcs((void *) next_history_msg, |
| 914 | (MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE), |
| 915 | next_history_msg, nano_next_history_msg, FALSE, VIEW); |
David Lawrence Ramsey | c10d8ff | 2005-06-03 20:51:39 +0000 | [diff] [blame] | 916 | #endif |
David Lawrence Ramsey | 02085d7 | 2004-11-07 16:04:18 +0000 | [diff] [blame] | 917 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 918 | add_to_funcs((void *) no_replace_msg, MREPLACE, |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 919 | no_replace_msg, IFSCHELP(nano_whereis_msg), FALSE, VIEW); |
Chris Allegretta | 5f36c37 | 2001-07-16 00:48:53 +0000 | [diff] [blame] | 920 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 921 | add_to_funcs((void *) gototext_msg, MGOTOLINE, |
Chris Allegretta | 10f868d | 2008-03-14 04:08:51 +0000 | [diff] [blame] | 922 | gototext_msg, IFSCHELP(nano_whereis_msg), TRUE, VIEW); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 923 | |
Rocco Corsi | af5c302 | 2001-01-12 07:51:05 +0000 | [diff] [blame] | 924 | #ifndef DISABLE_BROWSER |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 925 | if (!ISSET(RESTRICTED)) |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 926 | add_to_funcs((void *) to_files_msg, |
| 927 | (MGOTOLINE|MINSERTFILE), |
| 928 | to_files_msg, nano_tofiles_msg, FALSE, VIEW); |
Chris Allegretta | f4b9601 | 2001-01-03 07:11:47 +0000 | [diff] [blame] | 929 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 930 | |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 931 | #ifndef NANO_TINY |
David Lawrence Ramsey | 32e3b88 | 2004-05-29 01:20:17 +0000 | [diff] [blame] | 932 | /* If we're using restricted mode, the DOS format, Mac format, |
| 933 | * append, prepend, and backup toggles are disabled. The first and |
| 934 | * second are useless since inserting files is disabled, the third |
| 935 | * and fourth are disabled because they allow writing to files not |
| 936 | * specified on the command line, and the fifth is useless since |
| 937 | * backups are disabled. */ |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 938 | if (!ISSET(RESTRICTED)) |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 939 | add_to_funcs((void *) dos_format_msg, MWRITEFILE, |
| 940 | dos_format_msg, nano_dos_msg, FALSE, NOVIEW); |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 941 | |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 942 | if (!ISSET(RESTRICTED)) |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 943 | add_to_funcs((void *) mac_format_msg, MWRITEFILE, |
| 944 | mac_format_msg, nano_mac_msg, FALSE, NOVIEW); |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 945 | |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 946 | if (!ISSET(RESTRICTED)) |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 947 | add_to_funcs((void *) append_msg, MWRITEFILE, |
| 948 | append_msg, nano_append_msg, FALSE, NOVIEW); |
Chris Allegretta | cc197ef | 2001-05-29 04:21:44 +0000 | [diff] [blame] | 949 | |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 950 | if (!ISSET(RESTRICTED)) |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 951 | add_to_funcs((void *) prepend_msg, MWRITEFILE, |
| 952 | prepend_msg, nano_prepend_msg, FALSE, NOVIEW); |
Chris Allegretta | 0e9b7aa | 2002-04-16 03:15:47 +0000 | [diff] [blame] | 953 | |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 954 | if (!ISSET(RESTRICTED)) |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 955 | add_to_funcs((void *) backup_file_msg, MWRITEFILE, |
| 956 | backup_file_msg, nano_backup_msg, FALSE, NOVIEW); |
Chris Allegretta | cc197ef | 2001-05-29 04:21:44 +0000 | [diff] [blame] | 957 | #endif |
David Lawrence Ramsey | a593f53 | 2003-11-28 19:47:42 +0000 | [diff] [blame] | 958 | |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 959 | #ifndef NANO_TINY |
David Lawrence Ramsey | 32e3b88 | 2004-05-29 01:20:17 +0000 | [diff] [blame] | 960 | /* If we're using restricted mode, command execution is disabled. |
| 961 | * It's useless since inserting files is disabled. */ |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 962 | if (!ISSET(RESTRICTED)) |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 963 | add_to_funcs((void *) ext_cmd_msg, MINSERTFILE, |
| 964 | ext_cmd_msg, nano_execute_msg, FALSE, NOVIEW); |
David Lawrence Ramsey | a593f53 | 2003-11-28 19:47:42 +0000 | [diff] [blame] | 965 | |
Chris Allegretta | f7c6811 | 2002-09-03 22:58:40 +0000 | [diff] [blame] | 966 | #ifdef ENABLE_MULTIBUFFER |
David Lawrence Ramsey | 32e3b88 | 2004-05-29 01:20:17 +0000 | [diff] [blame] | 967 | /* If we're using restricted mode, the multibuffer toggle is |
| 968 | * disabled. It's useless since inserting files is disabled. */ |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 969 | if (!ISSET(RESTRICTED)) |
Chris Allegretta | 10f868d | 2008-03-14 04:08:51 +0000 | [diff] [blame] | 970 | add_to_funcs((void *) new_buffer_msg, MINSERTFILE, |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 971 | new_buffer_msg, nano_multibuffer_msg, FALSE, NOVIEW); |
David Lawrence Ramsey | e21adfa | 2002-09-13 18:14:04 +0000 | [diff] [blame] | 972 | #endif |
Chris Allegretta | cc197ef | 2001-05-29 04:21:44 +0000 | [diff] [blame] | 973 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 974 | add_to_funcs((void *) insert_file_msg, MEXTCMD, |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 975 | insert_file_msg, IFSCHELP(nano_insert_msg), FALSE, VIEW); |
David Lawrence Ramsey | e5d8f32 | 2004-09-30 22:07:21 +0000 | [diff] [blame] | 976 | |
David Lawrence Ramsey | 47e82b1 | 2004-09-28 22:21:46 +0000 | [diff] [blame] | 977 | #ifdef ENABLE_MULTIBUFFER |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 978 | add_to_funcs((void *) new_buffer_msg, MEXTCMD, |
| 979 | new_buffer_msg, nano_multibuffer_msg, FALSE, NOVIEW); |
Chris Allegretta | 52c5a6e | 2002-03-21 05:07:28 +0000 | [diff] [blame] | 980 | #endif |
David Lawrence Ramsey | 47e82b1 | 2004-09-28 22:21:46 +0000 | [diff] [blame] | 981 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 982 | |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 983 | #ifndef DISABLE_HELP |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 984 | add_to_funcs((void *) refresh_msg, MHELP, |
| 985 | refresh_msg, nano_refresh_msg, FALSE, VIEW); |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 986 | #endif |
| 987 | |
Rocco Corsi | af5c302 | 2001-01-12 07:51:05 +0000 | [diff] [blame] | 988 | #ifndef DISABLE_BROWSER |
Chris Allegretta | f5de33a | 2002-02-27 04:14:16 +0000 | [diff] [blame] | 989 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 990 | add_to_funcs((void *) first_file_msg, |
| 991 | (MBROWSER|MWHEREISFILE), |
| 992 | first_file_msg, nano_firstfile_msg, FALSE, VIEW); |
Chris Allegretta | b3655b4 | 2001-10-22 03:15:31 +0000 | [diff] [blame] | 993 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 994 | add_to_funcs((void *) last_file_msg, |
| 995 | (MBROWSER|MWHEREISFILE), |
| 996 | last_file_msg, nano_lastfile_msg, FALSE, VIEW); |
Chris Allegretta | b3655b4 | 2001-10-22 03:15:31 +0000 | [diff] [blame] | 997 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 998 | add_to_funcs((void *) goto_dir_msg, MBROWSER, |
| 999 | goto_dir_msg, nano_gotodir_msg, FALSE, VIEW); |
David Lawrence Ramsey | e38b808 | 2006-03-30 07:03:04 +0000 | [diff] [blame] | 1000 | #endif |
| 1001 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1002 | currmenu = MMAIN; |
David Lawrence Ramsey | 35e9713 | 2005-01-08 06:04:19 +0000 | [diff] [blame] | 1003 | |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 1004 | #ifndef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1005 | add_to_sclist(MALL, "^G", do_help_void, 0, TRUE); |
| 1006 | add_to_sclist(MALL, "F1", do_help_void, 0, TRUE); |
Chris Allegretta | f5de33a | 2002-02-27 04:14:16 +0000 | [diff] [blame] | 1007 | #endif |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1008 | add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", do_exit, 0, TRUE); |
| 1009 | add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", do_exit, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1010 | add_to_sclist(MMAIN, "^_", do_gotolinecolumn_void, 0, TRUE); |
| 1011 | add_to_sclist(MMAIN, "F13", do_gotolinecolumn_void, 0, TRUE); |
| 1012 | add_to_sclist(MMAIN, "^O", do_writeout_void, 0, TRUE); |
| 1013 | add_to_sclist(MMAIN, "F3", do_writeout_void, 0, TRUE); |
Chris Allegretta | c656e9d | 2008-03-16 12:55:41 +0000 | [diff] [blame] | 1014 | #ifndef DISABLE_JUSTIFY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1015 | add_to_sclist(MMAIN, "^J", do_justify_void, 0, TRUE); |
| 1016 | add_to_sclist(MMAIN, "F4", do_justify_void, 0, TRUE); |
| 1017 | #endif |
| 1018 | add_to_sclist(MMAIN, "^R", do_insertfile_void, 0, TRUE); |
| 1019 | add_to_sclist(MMAIN, "F5", do_insertfile_void, 0, TRUE); |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 1020 | add_to_sclist(MMAIN, "kinsert", do_insertfile_void, 0, TRUE); |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1021 | add_to_sclist(MMAIN|MBROWSER, "^W", do_search, 0, TRUE); |
| 1022 | add_to_sclist(MMAIN|MBROWSER, "F6", do_search, 0, TRUE); |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 1023 | add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "^Y", do_page_up, 0, TRUE); |
| 1024 | add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "F7", do_page_up, 0, TRUE); |
| 1025 | add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "kpup", do_page_up, 0, TRUE); |
| 1026 | add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "^V", do_page_down, 0, TRUE); |
| 1027 | add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "F8", do_page_down, 0, TRUE); |
| 1028 | add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE, "kpdown", do_page_down, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1029 | add_to_sclist(MMAIN, "^K", do_cut_text_void, 0, TRUE); |
| 1030 | add_to_sclist(MMAIN, "F9", do_cut_text_void, 0, TRUE); |
| 1031 | add_to_sclist(MMAIN, "^U", do_uncut_text, 0, TRUE); |
| 1032 | add_to_sclist(MMAIN, "F10", do_uncut_text, 0, TRUE); |
| 1033 | add_to_sclist(MMAIN, "^C", do_cursorpos_void, 0, TRUE); |
| 1034 | add_to_sclist(MMAIN, "F11", do_cursorpos_void, 0, TRUE); |
| 1035 | #ifndef NANO_TINY |
| 1036 | add_to_sclist(MMAIN, "^T", do_spell, 0, TRUE); |
| 1037 | add_to_sclist(MMAIN, "F12", do_spell, 0, TRUE); |
| 1038 | #endif |
| 1039 | add_to_sclist(MMAIN, "^_", do_gotolinecolumn_void, 0, TRUE); |
| 1040 | add_to_sclist(MMAIN, "F13", do_gotolinecolumn_void, 0, TRUE); |
| 1041 | add_to_sclist(MMAIN, "M-G", do_gotolinecolumn_void, 0, TRUE); |
| 1042 | add_to_sclist(MMAIN, "^\\", do_replace, 0, TRUE); |
| 1043 | add_to_sclist(MMAIN, "F14", do_replace, 0, TRUE); |
| 1044 | add_to_sclist(MMAIN, "M-R", do_replace, 0, TRUE); |
| 1045 | add_to_sclist(MWHEREIS, "^R", do_replace, 0, FALSE); |
| 1046 | add_to_sclist(MREPLACE, "^R", (void *) no_replace_msg, 0, FALSE); |
| 1047 | add_to_sclist(MWHEREIS, "^T", do_gotolinecolumn_void, 0, TRUE); |
| 1048 | #ifndef NANO_TINY |
| 1049 | add_to_sclist(MMAIN, "^^", do_mark, 0, TRUE); |
| 1050 | add_to_sclist(MMAIN, "F15", do_mark, 0, TRUE); |
| 1051 | add_to_sclist(MMAIN, "M-A", do_mark, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1052 | add_to_sclist(MALL, "M-W", do_research, 0, TRUE); |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1053 | add_to_sclist(MALL, "F16", do_research, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1054 | add_to_sclist(MMAIN, "M-^", do_copy_text, 0, TRUE); |
| 1055 | add_to_sclist(MMAIN, "M-6", do_copy_text, 0, TRUE); |
| 1056 | add_to_sclist(MMAIN, "M-}", do_indent_void, 0, TRUE); |
| 1057 | add_to_sclist(MMAIN, "M-{", do_unindent, 0, TRUE); |
Chris Allegretta | eb64314 | 2008-03-12 04:44:14 +0000 | [diff] [blame] | 1058 | add_to_sclist(MALL, "^F", do_right, 0, TRUE); |
| 1059 | add_to_sclist(MALL, "kright", do_right, 0, TRUE); |
| 1060 | add_to_sclist(MALL, "^B", do_left, 0, TRUE); |
| 1061 | add_to_sclist(MALL, "kleft", do_left, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1062 | add_to_sclist(MMAIN, "^Space", do_next_word_void, 0, TRUE); |
| 1063 | add_to_sclist(MMAIN, "M-Space", do_prev_word_void, 0, TRUE); |
| 1064 | #endif |
Chris Allegretta | eb64314 | 2008-03-12 04:44:14 +0000 | [diff] [blame] | 1065 | add_to_sclist(MMAIN, "^Q", xon_complaint, 0, TRUE); |
| 1066 | add_to_sclist(MMAIN, "^S", xoff_complaint, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1067 | add_to_sclist(MALL, "^P", do_up_void, 0, TRUE); |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 1068 | add_to_sclist(MALL, "kup", do_up_void, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1069 | add_to_sclist(MALL, "^N", do_down_void, 0, TRUE); |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 1070 | add_to_sclist(MALL, "kdown", do_down_void, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1071 | add_to_sclist(MALL, "^A", do_home, 0, TRUE); |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 1072 | add_to_sclist(MALL, "khome", do_home, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1073 | add_to_sclist(MALL, "^E", do_end, 0, TRUE); |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 1074 | add_to_sclist(MALL, "kend", do_end, 0, TRUE); |
Chris Allegretta | c656e9d | 2008-03-16 12:55:41 +0000 | [diff] [blame] | 1075 | #ifndef DISABLE_JUSTIFY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1076 | add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2, |
| 1077 | "^W", do_para_begin_void, 0, TRUE); |
| 1078 | add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2, |
| 1079 | "^O", do_para_end_void, 0, TRUE); |
| 1080 | add_to_sclist(MALL, "M-(", do_para_begin_void, 0, TRUE); |
| 1081 | add_to_sclist(MALL, "M-9", do_para_begin_void, 0, TRUE); |
| 1082 | add_to_sclist(MALL, "M-)", do_para_end_void, 0, TRUE); |
| 1083 | add_to_sclist(MALL, "M-0", do_para_end_void, 0, TRUE); |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1084 | #endif |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1085 | add_to_sclist(MWHEREIS, |
| 1086 | "M-C", (void *) case_sens_msg, 0, FALSE); |
| 1087 | add_to_sclist(MREPLACE, |
| 1088 | "M-C", (void *) case_sens_msg, 0, FALSE); |
| 1089 | add_to_sclist(MREPLACE2, |
| 1090 | "M-C", (void *) case_sens_msg, 0, FALSE); |
| 1091 | add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2, |
| 1092 | "M-B", (void *) backwards_msg, 0, FALSE); |
| 1093 | add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2, |
| 1094 | "M-R", (void *) regexp_msg, 0, FALSE); |
| 1095 | |
| 1096 | add_to_sclist(MMAIN, "M-\\", do_first_line, 0, TRUE); |
| 1097 | add_to_sclist(MMAIN, "M-|", do_first_line, 0, TRUE); |
| 1098 | add_to_sclist(MMAIN, "M-/", do_last_line, 0, TRUE); |
| 1099 | add_to_sclist(MMAIN, "M-?", do_last_line, 0, TRUE); |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 1100 | add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP, |
| 1101 | "^Y", do_first_line, 0, TRUE); |
| 1102 | add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MHELP, |
| 1103 | "^V", do_last_line, 0, TRUE); |
| 1104 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1105 | add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", (void *) first_file_msg, 0, TRUE); |
| 1106 | add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", (void *) first_file_msg, 0, TRUE); |
| 1107 | add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", (void *) last_file_msg, 0, TRUE); |
| 1108 | add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", (void *) last_file_msg, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1109 | #ifndef NANO_TINY |
Chris Allegretta | 2ea0b8f | 2008-03-20 04:57:46 +0000 | [diff] [blame] | 1110 | add_to_sclist(MMAIN, "M-]", do_find_bracket, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1111 | add_to_sclist(MMAIN, "M--", do_scroll_up, 0, TRUE); |
| 1112 | add_to_sclist(MMAIN, "M-_", do_scroll_up, 0, TRUE); |
| 1113 | add_to_sclist(MMAIN, "M-+", do_scroll_down, 0, TRUE); |
| 1114 | add_to_sclist(MMAIN, "M-=", do_scroll_down, 0, TRUE); |
| 1115 | #endif |
| 1116 | |
| 1117 | #ifdef ENABLE_MULTIBUFFER |
| 1118 | add_to_sclist(MMAIN, "M-<", switch_to_prev_buffer_void, 0, TRUE); |
| 1119 | add_to_sclist(MMAIN, "M-,", switch_to_prev_buffer_void, 0, TRUE); |
| 1120 | add_to_sclist(MMAIN, "M->", switch_to_next_buffer_void, 0, TRUE); |
| 1121 | add_to_sclist(MMAIN, "M-.", switch_to_next_buffer_void, 0, TRUE); |
| 1122 | #endif |
Chris Allegretta | aa17df0 | 2008-03-17 05:50:04 +0000 | [diff] [blame] | 1123 | add_to_sclist(MALL, "M-V", do_verbatim_input, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1124 | #ifndef NANO_TINY |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1125 | add_to_sclist(MALL, "M-T", do_cut_till_end, 0, TRUE); |
Chris Allegretta | c656e9d | 2008-03-16 12:55:41 +0000 | [diff] [blame] | 1126 | #ifndef DISABLE_JUSTIFY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1127 | add_to_sclist(MALL, "M-J", do_full_justify, 0, TRUE); |
Chris Allegretta | c656e9d | 2008-03-16 12:55:41 +0000 | [diff] [blame] | 1128 | #endif |
Chris Allegretta | 10f868d | 2008-03-14 04:08:51 +0000 | [diff] [blame] | 1129 | add_to_sclist(MMAIN, "M-D", do_wordlinechar_count, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1130 | add_to_sclist(MMAIN, "M-X", do_toggle, NO_HELP, TRUE); |
| 1131 | add_to_sclist(MMAIN, "M-C", do_toggle, CONST_UPDATE, TRUE); |
| 1132 | add_to_sclist(MMAIN, "M-O", do_toggle, MORE_SPACE, TRUE); |
| 1133 | add_to_sclist(MMAIN, "M-S", do_toggle, SMOOTH_SCROLL, TRUE); |
| 1134 | add_to_sclist(MMAIN, "M-P", do_toggle, WHITESPACE_DISPLAY, TRUE); |
| 1135 | add_to_sclist(MMAIN, "M-Y", do_toggle, NO_COLOR_SYNTAX, TRUE); |
| 1136 | add_to_sclist(MMAIN, "M-H", do_toggle, SMART_HOME, TRUE); |
| 1137 | add_to_sclist(MMAIN, "M-I", do_toggle, AUTOINDENT, TRUE); |
| 1138 | add_to_sclist(MMAIN, "M-K", do_toggle, CUT_TO_END, TRUE); |
| 1139 | add_to_sclist(MMAIN, "M-L", do_toggle, NO_WRAP, TRUE); |
| 1140 | add_to_sclist(MMAIN, "M-Q", do_toggle, TABS_TO_SPACES, TRUE); |
| 1141 | add_to_sclist(MMAIN, "M-B", do_toggle, BACKUP_FILE, TRUE); |
| 1142 | add_to_sclist(MMAIN, "M-F", do_toggle, MULTIBUFFER, TRUE); |
| 1143 | add_to_sclist(MMAIN, "M-M", do_toggle, USE_MOUSE, TRUE); |
| 1144 | add_to_sclist(MMAIN, "M-N", do_toggle, NO_CONVERT, TRUE); |
| 1145 | add_to_sclist(MMAIN, "M-Z", do_toggle, SUSPEND, TRUE); |
| 1146 | #endif |
Chris Allegretta | 10f868d | 2008-03-14 04:08:51 +0000 | [diff] [blame] | 1147 | add_to_sclist(MGOTOLINE, "^T", (void *) gototext_msg, 0, FALSE); |
| 1148 | add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", (void *) new_buffer_msg, 0, FALSE); |
Chris Allegretta | cc59383 | 2008-03-19 02:32:48 +0000 | [diff] [blame] | 1149 | add_to_sclist((MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MWHEREISFILE|MGOTODIR|MYESNO), |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1150 | "^C", (void *) cancel_msg, 0, FALSE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1151 | add_to_sclist(MHELP, "^X", do_exit, 0, TRUE); |
| 1152 | add_to_sclist(MHELP, "F2", do_exit, 0, TRUE); |
| 1153 | add_to_sclist(MWRITEFILE, "M-D", (void *) dos_format_msg, 0, FALSE); |
| 1154 | add_to_sclist(MWRITEFILE, "M-M", (void *) mac_format_msg, 0, FALSE); |
| 1155 | add_to_sclist(MWRITEFILE, "M-A", (void *) append_msg, 0, FALSE); |
| 1156 | add_to_sclist(MWRITEFILE, "M-P", (void *) prepend_msg, 0, FALSE); |
| 1157 | add_to_sclist(MWRITEFILE, "M-B", (void *) backup_file_msg, 0, FALSE); |
| 1158 | add_to_sclist(MWRITEFILE, "^T", (void *) to_files_msg, 0, FALSE); |
| 1159 | add_to_sclist(MINSERTFILE, "^T", (void *) to_files_msg, 0, FALSE); |
| 1160 | add_to_sclist(MINSERTFILE, "^X", (void *) ext_cmd_msg, 0, FALSE); |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 1161 | add_to_sclist(MMAIN, "^Z", do_suspend_void, 0, FALSE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1162 | add_to_sclist(MMAIN, "^L", total_refresh, 0, TRUE); |
Chris Allegretta | 10f868d | 2008-03-14 04:08:51 +0000 | [diff] [blame] | 1163 | add_to_sclist(MALL, "^I", do_tab, 0, TRUE); |
| 1164 | add_to_sclist(MALL, "^M", do_enter, 0, TRUE); |
| 1165 | add_to_sclist(MALL, "kenter", do_enter, 0, TRUE); |
| 1166 | add_to_sclist(MALL, "^D", do_delete, 0, TRUE); |
| 1167 | add_to_sclist(MALL, "kdel", do_delete, 0, TRUE); |
| 1168 | add_to_sclist(MALL, "^H", do_backspace, 0, TRUE); |
| 1169 | add_to_sclist(MALL, "kbsp", do_backspace, 0, TRUE); |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1170 | |
| 1171 | #ifdef DEBUG |
| 1172 | print_sclist(); |
| 1173 | #endif |
| 1174 | |
Chris Allegretta | dab017e | 2002-04-23 10:56:06 +0000 | [diff] [blame] | 1175 | } |
Chris Allegretta | f5de33a | 2002-02-27 04:14:16 +0000 | [diff] [blame] | 1176 | |
David Lawrence Ramsey | e6757b9 | 2006-04-19 13:36:56 +0000 | [diff] [blame] | 1177 | /* Free the given shortcut. */ |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1178 | void free_shortcutage(shortcut **shortcutage) |
| 1179 | { |
| 1180 | assert(shortcutage != NULL); |
David Lawrence Ramsey | 193b0e5 | 2005-06-06 18:41:17 +0000 | [diff] [blame] | 1181 | |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1182 | while (*shortcutage != NULL) { |
| 1183 | shortcut *ps = *shortcutage; |
| 1184 | *shortcutage = (*shortcutage)->next; |
| 1185 | free(ps); |
| 1186 | } |
| 1187 | } |
| 1188 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1189 | const subnfunc *sctofunc(sc *s) |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1190 | { |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1191 | subnfunc *f; |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1192 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1193 | for (f = allfuncs; f != NULL && s->scfunc != f->scfunc; f = f->next) |
| 1194 | ; |
| 1195 | |
| 1196 | return f; |
| 1197 | } |
| 1198 | |
| 1199 | #ifndef NANO_TINY |
| 1200 | /* Now lets come up with a single (hopefully) |
| 1201 | function to get a string for each flag */ |
| 1202 | char *flagtostr(int flag) |
| 1203 | { |
| 1204 | switch (flag) { |
| 1205 | case NO_HELP: |
| 1206 | return N_("Help mode"); |
| 1207 | case CONST_UPDATE: |
| 1208 | return N_("Constant cursor position display"); |
| 1209 | case MORE_SPACE: |
| 1210 | return N_("Use of one more line for editing"); |
| 1211 | case SMOOTH_SCROLL: |
| 1212 | return N_("Smooth scrolling"); |
| 1213 | case WHITESPACE_DISPLAY: |
| 1214 | return N_("Whitespace display"); |
| 1215 | case NO_COLOR_SYNTAX: |
| 1216 | return N_("Color syntax highlighting"); |
| 1217 | case SMART_HOME: |
| 1218 | return N_("Smart home key"); |
| 1219 | case AUTOINDENT: |
| 1220 | return N_("Auto indent"); |
| 1221 | case CUT_TO_END: |
| 1222 | return N_("Cut to end"); |
| 1223 | case NO_WRAP: |
| 1224 | return N_("Long line wrapping"); |
| 1225 | case TABS_TO_SPACES: |
| 1226 | return N_("Conversion of typed tabs to spaces"); |
| 1227 | case BACKUP_FILE: |
| 1228 | return N_("Backup files"); |
| 1229 | case MULTIBUFFER: |
| 1230 | return N_("Multiple file buffers"); |
| 1231 | case USE_MOUSE: |
| 1232 | return N_("Mouse support"); |
| 1233 | case NO_CONVERT: |
| 1234 | return N_("No conversion from DOS/Mac format"); |
| 1235 | case SUSPEND: |
| 1236 | return N_("Suspension"); |
| 1237 | default: |
| 1238 | return "?????"; |
| 1239 | } |
| 1240 | } |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1241 | #endif /* NANO_TINY */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1242 | |
| 1243 | /* Interpret the string given by the rc file and return a |
| 1244 | shortcut struct, complete with proper value for execute */ |
| 1245 | sc *strtosc(int menu, char *input) |
| 1246 | { |
| 1247 | sc *s; |
| 1248 | |
| 1249 | s = (sc *)nmalloc(sizeof(sc)); |
| 1250 | s->execute = TRUE; /* overridden as needed below */ |
| 1251 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1252 | |
| 1253 | #ifndef DISABLE_HELP |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1254 | if (!strcasecmp(input, "help")) |
| 1255 | s->scfunc = do_help_void; |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1256 | else |
| 1257 | #endif |
| 1258 | if (!strcasecmp(input, "cancel")) { |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1259 | s->scfunc = (void *) cancel_msg; |
| 1260 | s->execute = FALSE; |
| 1261 | } else if (!strcasecmp(input, "exit")) |
| 1262 | s->scfunc = do_exit; |
| 1263 | else if (!strcasecmp(input, "writeout")) |
| 1264 | s->scfunc = do_writeout_void; |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1265 | else if (!strcasecmp(input, "insert")) |
| 1266 | s->scfunc = do_insertfile_void; |
| 1267 | else if (!strcasecmp(input, "whereis")) |
| 1268 | s->scfunc = do_search; |
| 1269 | else if (!strcasecmp(input, "up")) |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 1270 | s->scfunc = do_up_void; |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1271 | else if (!strcasecmp(input, "down")) |
Chris Allegretta | 17436ce | 2008-03-11 03:03:53 +0000 | [diff] [blame] | 1272 | s->scfunc = do_down_void; |
| 1273 | else if (!strcasecmp(input, "pageup") |
| 1274 | || !strcasecmp(input, "prevpage")) |
| 1275 | s->scfunc = do_page_up; |
| 1276 | else if (!strcasecmp(input, "pagedown") |
| 1277 | || !strcasecmp(input, "nextpage")) |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1278 | s->scfunc = do_page_down; |
| 1279 | else if (!strcasecmp(input, "cut")) |
| 1280 | s->scfunc = do_cut_text_void; |
| 1281 | else if (!strcasecmp(input, "uncut")) |
| 1282 | s->scfunc = do_uncut_text; |
| 1283 | else if (!strcasecmp(input, "curpos") || |
| 1284 | !strcasecmp(input, "cursorpos")) |
| 1285 | s->scfunc = do_cursorpos_void; |
| 1286 | else if (!strcasecmp(input, "firstline")) |
| 1287 | s->scfunc = do_first_line; |
| 1288 | else if (!strcasecmp(input, "lastline")) |
| 1289 | s->scfunc = do_last_line; |
| 1290 | else if (!strcasecmp(input, "gotoline")) |
| 1291 | s->scfunc = do_gotolinecolumn_void; |
| 1292 | else if (!strcasecmp(input, "replace")) |
| 1293 | s->scfunc = do_replace; |
Chris Allegretta | c656e9d | 2008-03-16 12:55:41 +0000 | [diff] [blame] | 1294 | #ifndef DISABLE_JUSTIFY |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1295 | else if (!strcasecmp(input, "justify")) |
| 1296 | s->scfunc = do_justify_void; |
Chris Allegretta | c656e9d | 2008-03-16 12:55:41 +0000 | [diff] [blame] | 1297 | else if (!strcasecmp(input, "beginpara")) |
| 1298 | s->scfunc = do_para_begin_void; |
| 1299 | else if (!strcasecmp(input, "endpara")) |
| 1300 | s->scfunc = do_para_end_void; |
| 1301 | else if (!strcasecmp(input, "fulljustify")) |
| 1302 | s->scfunc = do_full_justify; |
| 1303 | #endif |
| 1304 | #ifndef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1305 | else if (!strcasecmp(input, "mark")) |
| 1306 | s->scfunc = do_mark; |
| 1307 | else if (!strcasecmp(input, "searchagain") || |
| 1308 | !strcasecmp(input, "research")) |
| 1309 | s->scfunc = do_research; |
| 1310 | else if (!strcasecmp(input, "copytext")) |
| 1311 | s->scfunc = do_copy_text; |
| 1312 | else if (!strcasecmp(input, "indent")) |
| 1313 | s->scfunc = do_indent_void; |
| 1314 | else if (!strcasecmp(input, "unindent")) |
| 1315 | s->scfunc = do_unindent; |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1316 | else if (!strcasecmp(input, "scrollup")) |
| 1317 | s->scfunc = do_scroll_up; |
| 1318 | else if (!strcasecmp(input, "scrolldown")) |
| 1319 | s->scfunc = do_scroll_down; |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1320 | else if (!strcasecmp(input, "nextword")) |
| 1321 | s->scfunc = do_next_word_void; |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 1322 | else if (!strcasecmp(input, "suspend")) |
| 1323 | s->scfunc = do_suspend_void; |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1324 | else if (!strcasecmp(input, "prevword")) |
| 1325 | s->scfunc = do_prev_word_void; |
| 1326 | else if (!strcasecmp(input, "findbracket")) |
| 1327 | s->scfunc = do_find_bracket; |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1328 | else if (!strcasecmp(input, "wordcount")) |
| 1329 | s->scfunc = do_wordlinechar_count; |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1330 | else if (!strcasecmp(input, "prevhistory")) { |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1331 | s->scfunc = (void *) prev_history_msg; |
| 1332 | s->execute = FALSE; |
| 1333 | } else if (!strcasecmp(input, "nexthistory")) { |
| 1334 | s->scfunc = (void *) next_history_msg; |
| 1335 | s->execute = FALSE; |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1336 | } else if (!strcasecmp(input, "nohelp") || |
| 1337 | !strcasecmp(input, "nohelp")) { |
| 1338 | s->scfunc = (void *) do_toggle; |
| 1339 | s->execute = FALSE; |
| 1340 | s->toggle = NO_HELP; |
| 1341 | } else if (!strcasecmp(input, "constupdate")) { |
| 1342 | s->scfunc = (void *) do_toggle; |
| 1343 | s->execute = FALSE; |
| 1344 | s->toggle = CONST_UPDATE; |
| 1345 | } else if (!strcasecmp(input, "morespace")) { |
| 1346 | s->scfunc = (void *) do_toggle; |
| 1347 | s->execute = FALSE; |
| 1348 | s->toggle = MORE_SPACE; |
| 1349 | } else if (!strcasecmp(input, "smoothscroll")) { |
| 1350 | s->scfunc = (void *) do_toggle; |
| 1351 | s->execute = FALSE; |
| 1352 | s->toggle = SMOOTH_SCROLL; |
Chris Allegretta | d3659f8 | 2008-03-16 23:57:14 +0000 | [diff] [blame] | 1353 | } else if (!strcasecmp(input, "whitespacedisplay")) { |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1354 | s->scfunc = (void *) do_toggle; |
| 1355 | s->execute = FALSE; |
| 1356 | s->toggle = WHITESPACE_DISPLAY; |
| 1357 | } else if (!strcasecmp(input, "nosyntax")) { |
| 1358 | s->scfunc = (void *) do_toggle; |
| 1359 | s->execute = FALSE; |
| 1360 | s->toggle = NO_COLOR_SYNTAX; |
| 1361 | } else if (!strcasecmp(input, "smarthome")) { |
| 1362 | s->scfunc = (void *) do_toggle; |
| 1363 | s->execute = FALSE; |
| 1364 | s->toggle = SMART_HOME; |
| 1365 | } else if (!strcasecmp(input, "autoindent")) { |
| 1366 | s->scfunc = (void *) do_toggle; |
| 1367 | s->execute = FALSE; |
| 1368 | s->toggle = AUTOINDENT; |
| 1369 | } else if (!strcasecmp(input, "cuttoend")) { |
| 1370 | s->scfunc = (void *) do_toggle; |
| 1371 | s->execute = FALSE; |
| 1372 | s->toggle = CUT_TO_END; |
| 1373 | } else if (!strcasecmp(input, "nowrap")) { |
| 1374 | s->scfunc = (void *) do_toggle; |
| 1375 | s->execute = FALSE; |
| 1376 | s->toggle = NO_WRAP; |
| 1377 | } else if (!strcasecmp(input, "tabstospaces")) { |
| 1378 | s->scfunc = (void *) do_toggle; |
| 1379 | s->execute = FALSE; |
| 1380 | s->toggle = TABS_TO_SPACES; |
| 1381 | } else if (!strcasecmp(input, "backupfile")) { |
| 1382 | s->scfunc = (void *) do_toggle; |
| 1383 | s->execute = FALSE; |
| 1384 | s->toggle = BACKUP_FILE; |
| 1385 | } else if (!strcasecmp(input, "mutlibuffer")) { |
| 1386 | s->scfunc = (void *) do_toggle; |
| 1387 | s->execute = FALSE; |
| 1388 | s->toggle = MULTIBUFFER; |
| 1389 | } else if (!strcasecmp(input, "mouse")) { |
| 1390 | s->scfunc = (void *) do_toggle; |
| 1391 | s->execute = FALSE; |
| 1392 | s->toggle = USE_MOUSE; |
| 1393 | } else if (!strcasecmp(input, "noconvert")) { |
| 1394 | s->scfunc = (void *) do_toggle; |
| 1395 | s->execute = FALSE; |
| 1396 | s->toggle = NO_CONVERT; |
Chris Allegretta | 0018d8e | 2008-03-13 08:23:52 +0000 | [diff] [blame] | 1397 | } else if (!strcasecmp(input, "suspendenable")) { |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1398 | s->scfunc = (void *) do_toggle; |
| 1399 | s->execute = FALSE; |
| 1400 | s->toggle = SUSPEND; |
Chris Allegretta | c656e9d | 2008-03-16 12:55:41 +0000 | [diff] [blame] | 1401 | } |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1402 | #endif /* NANO_TINY */ |
| 1403 | else if (!strcasecmp(input, "right") || |
| 1404 | !strcasecmp(input, "forward")) |
| 1405 | s->scfunc = do_right; |
| 1406 | else if (!strcasecmp(input, "left") || |
| 1407 | !strcasecmp(input, "back")) |
| 1408 | s->scfunc = do_left; |
| 1409 | else if (!strcasecmp(input, "up") || |
| 1410 | !strcasecmp(input, "prevline")) |
| 1411 | s->scfunc = do_up_void; |
| 1412 | else if (!strcasecmp(input, "down") || |
| 1413 | !strcasecmp(input, "nextline")) |
| 1414 | s->scfunc = do_down_void; |
| 1415 | else if (!strcasecmp(input, "home")) |
| 1416 | s->scfunc = do_home; |
| 1417 | else if (!strcasecmp(input, "end")) |
| 1418 | s->scfunc = do_end; |
| 1419 | #ifdef ENABLE_MULTIBUFFER |
| 1420 | else if (!strcasecmp(input, "prevbuf")) |
| 1421 | s->scfunc = switch_to_prev_buffer_void; |
| 1422 | else if (!strcasecmp(input, "nextbuf")) |
| 1423 | s->scfunc = switch_to_next_buffer_void; |
| 1424 | #endif |
| 1425 | else if (!strcasecmp(input, "verbatim")) |
| 1426 | s->scfunc = do_verbatim_input; |
| 1427 | else if (!strcasecmp(input, "tab")) |
| 1428 | s->scfunc = do_tab; |
| 1429 | else if (!strcasecmp(input, "enter")) |
| 1430 | s->scfunc = do_enter; |
| 1431 | else if (!strcasecmp(input, "delete")) |
| 1432 | s->scfunc = do_delete; |
| 1433 | else if (!strcasecmp(input, "refresh")) |
| 1434 | s->scfunc = total_refresh; |
| 1435 | else if (!strcasecmp(input, "casesens")) { |
| 1436 | s->scfunc = (void *) case_sens_msg; |
| 1437 | s->execute = FALSE; |
| 1438 | } else if (!strcasecmp(input, "regexp") || |
| 1439 | !strcasecmp(input, "regex")) { |
| 1440 | s->scfunc = (void *) regexp_msg; |
| 1441 | s->execute = FALSE; |
| 1442 | } else if (!strcasecmp(input, "dontreplace")) { |
| 1443 | s->scfunc = (void *) no_replace_msg; |
| 1444 | s->execute = FALSE; |
| 1445 | } else if (!strcasecmp(input, "gototext")) { |
| 1446 | s->scfunc = (void *) gototext_msg; |
| 1447 | s->execute = FALSE; |
| 1448 | } else if (!strcasecmp(input, "browser") || |
| 1449 | !strcasecmp(input, "tofiles")) { |
| 1450 | s->scfunc = (void *) to_files_msg; |
| 1451 | s->execute = FALSE; |
| 1452 | } else if (!strcasecmp(input, "dosformat")) { |
| 1453 | s->scfunc = (void *) dos_format_msg; |
| 1454 | s->execute = FALSE; |
| 1455 | } else if (!strcasecmp(input, "macformat")) { |
| 1456 | s->scfunc = (void *) mac_format_msg; |
| 1457 | s->execute = FALSE; |
| 1458 | } else if (!strcasecmp(input, "append")) { |
| 1459 | s->scfunc = (void *) append_msg; |
| 1460 | s->execute = FALSE; |
| 1461 | } else if (!strcasecmp(input, "prepend")) { |
| 1462 | s->scfunc = (void *) prepend_msg; |
| 1463 | s->execute = FALSE; |
| 1464 | } else if (!strcasecmp(input, "backup")) { |
| 1465 | s->scfunc = (void *) backup_file_msg; |
| 1466 | s->execute = FALSE; |
| 1467 | #ifdef ENABLE_MULTIBUFFER |
| 1468 | } else if (!strcasecmp(input, "newbuffer")) { |
| 1469 | s->scfunc = (void *) new_buffer_msg; |
| 1470 | s->execute = FALSE; |
| 1471 | #endif |
| 1472 | } else if (!strcasecmp(input, "firstfile")) { |
| 1473 | s->scfunc = (void *) first_file_msg; |
| 1474 | s->execute = FALSE; |
| 1475 | } else if (!strcasecmp(input, "lastfile")) { |
| 1476 | s->scfunc = (void *) last_file_msg; |
| 1477 | s->execute = FALSE; |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1478 | } else { |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1479 | free(s); |
| 1480 | return NULL; |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1481 | } |
| 1482 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1483 | return s; |
| 1484 | |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1485 | } |
| 1486 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1487 | #ifdef ENABLE_NANORC |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1488 | /* Same thing as abnove but for the menu */ |
| 1489 | int strtomenu(char *input) |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1490 | { |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1491 | if (!strcasecmp(input, "all")) |
| 1492 | return MALL; |
| 1493 | else if (!strcasecmp(input, "main")) |
| 1494 | return MMAIN; |
| 1495 | else if (!strcasecmp(input, "search")) |
| 1496 | return MWHEREIS; |
| 1497 | else if (!strcasecmp(input, "replace")) |
| 1498 | return MREPLACE; |
| 1499 | else if (!strcasecmp(input, "replace2") || |
| 1500 | !strcasecmp(input, "replacewith")) |
| 1501 | return MREPLACE2; |
| 1502 | else if (!strcasecmp(input, "gotoline")) |
| 1503 | return MGOTOLINE; |
| 1504 | else if (!strcasecmp(input, "writeout")) |
| 1505 | return MWRITEFILE; |
| 1506 | else if (!strcasecmp(input, "insert")) |
| 1507 | return MINSERTFILE; |
| 1508 | else if (!strcasecmp(input, "externalcmd") || |
| 1509 | !strcasecmp(input, "extcmd")) |
| 1510 | return MEXTCMD; |
| 1511 | else if (!strcasecmp(input, "help")) |
| 1512 | return MHELP; |
| 1513 | else if (!strcasecmp(input, "spell")) |
| 1514 | return MSPELL; |
| 1515 | else if (!strcasecmp(input, "browser")) |
| 1516 | return MBROWSER; |
| 1517 | else if (!strcasecmp(input, "whereisfile")) |
| 1518 | return MWHEREISFILE; |
| 1519 | else if (!strcasecmp(input, "gotodir")) |
| 1520 | return MGOTODIR; |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1521 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1522 | return -1; |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1523 | } |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1524 | #endif |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1525 | |
Chris Allegretta | e347efb | 2008-03-09 02:52:40 +0000 | [diff] [blame] | 1526 | |
David Lawrence Ramsey | e6757b9 | 2006-04-19 13:36:56 +0000 | [diff] [blame] | 1527 | #ifdef DEBUG |
| 1528 | /* This function is used to gracefully return all the memory we've used. |
| 1529 | * It should be called just before calling exit(). Practically, the |
Chris Allegretta | 6232d66 | 2002-05-12 19:52:15 +0000 | [diff] [blame] | 1530 | * only effect is to cause a segmentation fault if the various data |
| 1531 | * structures got bolloxed earlier. Thus, we don't bother having this |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 1532 | * function unless debugging is turned on. */ |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 1533 | void thanks_for_all_the_fish(void) |
Chris Allegretta | f5de33a | 2002-02-27 04:14:16 +0000 | [diff] [blame] | 1534 | { |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 1535 | delwin(topwin); |
| 1536 | delwin(edit); |
| 1537 | delwin(bottomwin); |
| 1538 | |
Chris Allegretta | 7662c86 | 2003-01-13 01:35:15 +0000 | [diff] [blame] | 1539 | #ifndef DISABLE_JUSTIFY |
| 1540 | if (quotestr != NULL) |
| 1541 | free(quotestr); |
David Lawrence Ramsey | 819c7f0 | 2004-07-30 03:54:34 +0000 | [diff] [blame] | 1542 | #ifdef HAVE_REGEX_H |
| 1543 | regfree("ereg); |
David Lawrence Ramsey | 31b159c | 2005-05-26 05:17:13 +0000 | [diff] [blame] | 1544 | if (quoteerr != NULL) |
| 1545 | free(quoteerr); |
David Lawrence Ramsey | 819c7f0 | 2004-07-30 03:54:34 +0000 | [diff] [blame] | 1546 | #endif |
Chris Allegretta | 7662c86 | 2003-01-13 01:35:15 +0000 | [diff] [blame] | 1547 | #endif |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 1548 | #ifndef NANO_TINY |
David Lawrence Ramsey | 04e42a6 | 2004-02-28 16:24:31 +0000 | [diff] [blame] | 1549 | if (backup_dir != NULL) |
| 1550 | free(backup_dir); |
| 1551 | #endif |
Chris Allegretta | 2598c66 | 2002-03-28 01:59:34 +0000 | [diff] [blame] | 1552 | #ifndef DISABLE_OPERATINGDIR |
Chris Allegretta | f5de33a | 2002-02-27 04:14:16 +0000 | [diff] [blame] | 1553 | if (operating_dir != NULL) |
| 1554 | free(operating_dir); |
| 1555 | if (full_operating_dir != NULL) |
| 1556 | free(full_operating_dir); |
| 1557 | #endif |
| 1558 | if (last_search != NULL) |
| 1559 | free(last_search); |
| 1560 | if (last_replace != NULL) |
| 1561 | free(last_replace); |
Chris Allegretta | f5de33a | 2002-02-27 04:14:16 +0000 | [diff] [blame] | 1562 | #ifndef DISABLE_SPELLER |
| 1563 | if (alt_speller != NULL) |
| 1564 | free(alt_speller); |
| 1565 | #endif |
Chris Allegretta | f5de33a | 2002-02-27 04:14:16 +0000 | [diff] [blame] | 1566 | if (answer != NULL) |
| 1567 | free(answer); |
| 1568 | if (cutbuffer != NULL) |
Chris Allegretta | 7662c86 | 2003-01-13 01:35:15 +0000 | [diff] [blame] | 1569 | free_filestruct(cutbuffer); |
David Lawrence Ramsey | 93c8405 | 2004-11-23 04:08:28 +0000 | [diff] [blame] | 1570 | #ifndef DISABLE_JUSTIFY |
| 1571 | if (jusbuffer != NULL) |
| 1572 | free_filestruct(jusbuffer); |
| 1573 | #endif |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 1574 | #ifndef NANO_TINY |
David Lawrence Ramsey | 40e4acf | 2005-05-26 06:09:07 +0000 | [diff] [blame] | 1575 | /* Free the memory associated with each toggle. */ |
David Lawrence Ramsey | 31b159c | 2005-05-26 05:17:13 +0000 | [diff] [blame] | 1576 | while (toggles != NULL) { |
| 1577 | toggle *t = toggles; |
Chris Allegretta | f5de33a | 2002-02-27 04:14:16 +0000 | [diff] [blame] | 1578 | |
David Lawrence Ramsey | 31b159c | 2005-05-26 05:17:13 +0000 | [diff] [blame] | 1579 | toggles = toggles->next; |
| 1580 | free(t); |
| 1581 | } |
| 1582 | #endif |
David Lawrence Ramsey | 5d8d0b1 | 2005-05-26 05:53:29 +0000 | [diff] [blame] | 1583 | /* Free the memory associated with each open file buffer. */ |
David Lawrence Ramsey | 6ad59cd | 2005-07-08 20:09:16 +0000 | [diff] [blame] | 1584 | if (openfile != NULL) |
David Lawrence Ramsey | 64661ac | 2005-07-08 19:57:25 +0000 | [diff] [blame] | 1585 | free_openfilestruct(openfile); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 1586 | #ifdef ENABLE_COLOR |
David Lawrence Ramsey | 31b159c | 2005-05-26 05:17:13 +0000 | [diff] [blame] | 1587 | if (syntaxstr != NULL) |
| 1588 | free(syntaxstr); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 1589 | while (syntaxes != NULL) { |
| 1590 | syntaxtype *bill = syntaxes; |
| 1591 | |
| 1592 | free(syntaxes->desc); |
| 1593 | while (syntaxes->extensions != NULL) { |
| 1594 | exttype *bob = syntaxes->extensions; |
| 1595 | |
| 1596 | syntaxes->extensions = bob->next; |
David Lawrence Ramsey | 2385c1a | 2005-07-29 21:42:08 +0000 | [diff] [blame] | 1597 | free(bob->ext_regex); |
David Lawrence Ramsey | 7fc0ada | 2005-08-29 18:52:06 +0000 | [diff] [blame] | 1598 | if (bob->ext != NULL) { |
| 1599 | regfree(bob->ext); |
| 1600 | free(bob->ext); |
| 1601 | } |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 1602 | free(bob); |
| 1603 | } |
| 1604 | while (syntaxes->color != NULL) { |
| 1605 | colortype *bob = syntaxes->color; |
| 1606 | |
| 1607 | syntaxes->color = bob->next; |
David Lawrence Ramsey | 2385c1a | 2005-07-29 21:42:08 +0000 | [diff] [blame] | 1608 | free(bob->start_regex); |
David Lawrence Ramsey | db95802 | 2005-07-13 20:18:46 +0000 | [diff] [blame] | 1609 | if (bob->start != NULL) { |
| 1610 | regfree(bob->start); |
| 1611 | free(bob->start); |
| 1612 | } |
David Lawrence Ramsey | d2361f0 | 2005-07-14 18:33:51 +0000 | [diff] [blame] | 1613 | if (bob->end_regex != NULL) |
| 1614 | free(bob->end_regex); |
David Lawrence Ramsey | db95802 | 2005-07-13 20:18:46 +0000 | [diff] [blame] | 1615 | if (bob->end != NULL) { |
Chris Allegretta | ce452fb | 2003-02-03 02:56:44 +0000 | [diff] [blame] | 1616 | regfree(bob->end); |
David Lawrence Ramsey | db95802 | 2005-07-13 20:18:46 +0000 | [diff] [blame] | 1617 | free(bob->end); |
| 1618 | } |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 1619 | free(bob); |
| 1620 | } |
| 1621 | syntaxes = syntaxes->next; |
| 1622 | free(bill); |
| 1623 | } |
| 1624 | #endif /* ENABLE_COLOR */ |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 1625 | #ifndef NANO_TINY |
David Lawrence Ramsey | 40e4acf | 2005-05-26 06:09:07 +0000 | [diff] [blame] | 1626 | /* Free the search and replace history lists. */ |
David Lawrence Ramsey | 31b159c | 2005-05-26 05:17:13 +0000 | [diff] [blame] | 1627 | if (searchage != NULL) |
| 1628 | free_filestruct(searchage); |
| 1629 | if (replaceage != NULL) |
| 1630 | free_filestruct(replaceage); |
Chris Allegretta | 5beed50 | 2003-01-05 20:41:21 +0000 | [diff] [blame] | 1631 | #endif |
David Lawrence Ramsey | a27bd65 | 2004-08-17 05:23:38 +0000 | [diff] [blame] | 1632 | #ifdef ENABLE_NANORC |
David Lawrence Ramsey | 31b159c | 2005-05-26 05:17:13 +0000 | [diff] [blame] | 1633 | if (homedir != NULL) |
| 1634 | free(homedir); |
David Lawrence Ramsey | a27bd65 | 2004-08-17 05:23:38 +0000 | [diff] [blame] | 1635 | #endif |
Chris Allegretta | f5de33a | 2002-02-27 04:14:16 +0000 | [diff] [blame] | 1636 | } |
Chris Allegretta | 6232d66 | 2002-05-12 19:52:15 +0000 | [diff] [blame] | 1637 | #endif /* DEBUG */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 1638 | |