Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 1 | /************************************************************************** |
Benno Schulenberg | 514cd9a | 2016-08-29 17:10:49 +0200 | [diff] [blame] | 2 | * nano.h -- This file is part of GNU nano. * |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 3 | * * |
Chris Allegretta | 8a07a96 | 2009-12-02 03:36:22 +0000 | [diff] [blame] | 4 | * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, * |
Benno Schulenberg | 7a9f4a4 | 2014-04-30 20:18:26 +0000 | [diff] [blame] | 5 | * 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. * |
Benno Schulenberg | 406e524 | 2016-08-29 15:14:18 +0200 | [diff] [blame] | 6 | * Copyright (C) 2014, 2015, 2016 Benno Schulenberg * |
Benno Schulenberg | 57d1755 | 2016-09-03 12:14:08 +0200 | [diff] [blame] | 7 | * * |
Benno Schulenberg | 514cd9a | 2016-08-29 17:10:49 +0200 | [diff] [blame] | 8 | * GNU nano is free software: you can redistribute it and/or modify * |
| 9 | * it under the terms of the GNU General Public License as published * |
| 10 | * by the Free Software Foundation, either version 3 of the License, * |
| 11 | * or (at your option) any later version. * |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 12 | * * |
Benno Schulenberg | 514cd9a | 2016-08-29 17:10:49 +0200 | [diff] [blame] | 13 | * GNU nano is distributed in the hope that it will be useful, * |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty * |
| 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
| 16 | * See the GNU 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 * |
Benno Schulenberg | 514cd9a | 2016-08-29 17:10:49 +0200 | [diff] [blame] | 19 | * along with this program. If not, see http://www.gnu.org/licenses/. * |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 20 | * * |
| 21 | **************************************************************************/ |
| 22 | |
David Lawrence Ramsey | 24ae56c | 2004-02-27 03:06:28 +0000 | [diff] [blame] | 23 | #ifndef NANO_H |
| 24 | #define NANO_H 1 |
| 25 | |
David Lawrence Ramsey | e527e45 | 2005-04-15 18:07:26 +0000 | [diff] [blame] | 26 | #ifdef HAVE_CONFIG_H |
| 27 | #include <config.h> |
| 28 | #endif |
| 29 | |
Chris Allegretta | 5a3464b | 2009-03-01 00:50:19 +0000 | [diff] [blame] | 30 | #ifdef NEED_XOPEN_SOURCE_EXTENDED |
| 31 | #ifndef _XOPEN_SOURCE_EXTENDED |
| 32 | #define _XOPEN_SOURCE_EXTENDED 1 |
Benno Schulenberg | 492e9f6 | 2014-06-20 10:48:26 +0000 | [diff] [blame] | 33 | #endif |
| 34 | #endif |
Chris Allegretta | 5a3464b | 2009-03-01 00:50:19 +0000 | [diff] [blame] | 35 | |
David Lawrence Ramsey | a619ae6 | 2004-03-04 06:33:52 +0000 | [diff] [blame] | 36 | #ifdef __TANDEM |
David Lawrence Ramsey | 0a4b737 | 2006-07-18 18:28:10 +0000 | [diff] [blame] | 37 | /* Tandem NonStop Kernel support. */ |
David Lawrence Ramsey | a619ae6 | 2004-03-04 06:33:52 +0000 | [diff] [blame] | 38 | #include <floss.h> |
| 39 | #define NANO_ROOT_UID 65535 |
| 40 | #else |
| 41 | #define NANO_ROOT_UID 0 |
| 42 | #endif |
| 43 | |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 44 | #ifdef HAVE_LIMITS_H |
| 45 | #include <limits.h> |
| 46 | #endif |
| 47 | |
David Lawrence Ramsey | 96dce26 | 2006-06-06 18:41:58 +0000 | [diff] [blame] | 48 | #ifdef HAVE_SYS_PARAM_H |
| 49 | #include <sys/param.h> |
| 50 | #endif |
| 51 | |
Chris Allegretta | 5a3464b | 2009-03-01 00:50:19 +0000 | [diff] [blame] | 52 | #ifdef HAVE_STDARG_H |
| 53 | #include <stdarg.h> |
| 54 | #endif |
| 55 | |
Benno Schulenberg | 044e4d2 | 2014-05-13 21:11:59 +0000 | [diff] [blame] | 56 | /* Suppress warnings for __attribute__((warn_unused_result)). */ |
Chris Allegretta | a97cb81 | 2009-12-02 03:24:18 +0000 | [diff] [blame] | 57 | #define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0) |
| 58 | |
Benno Schulenberg | eb91ad5 | 2014-05-15 13:11:55 +0000 | [diff] [blame] | 59 | /* Macros for flags, indexing each bit in a small array. */ |
| 60 | #define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))] |
Benno Schulenberg | 04b9b9c | 2016-07-22 15:35:22 +0200 | [diff] [blame] | 61 | #define FLAGMASK(flag) ((unsigned)1 << ((flag) % (sizeof(unsigned) * 8))) |
Chris Allegretta | a48507d | 2009-08-14 03:18:29 +0000 | [diff] [blame] | 62 | #define SET(flag) FLAGS(flag) |= FLAGMASK(flag) |
| 63 | #define UNSET(flag) FLAGS(flag) &= ~FLAGMASK(flag) |
| 64 | #define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0) |
| 65 | #define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag) |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 66 | |
David Lawrence Ramsey | 6335fb5 | 2007-01-01 05:15:32 +0000 | [diff] [blame] | 67 | /* Macros for character allocation and more. */ |
Chris Allegretta | 7662c86 | 2003-01-13 01:35:15 +0000 | [diff] [blame] | 68 | #define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char)) |
Chris Allegretta | f80a59c | 2003-01-30 00:57:33 +0000 | [diff] [blame] | 69 | #define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char)) |
David Lawrence Ramsey | 5ffbec5 | 2003-09-16 01:16:49 +0000 | [diff] [blame] | 70 | #define charmove(dest, src, n) memmove(dest, src, (n) * sizeof(char)) |
David Lawrence Ramsey | 3db0dc3 | 2005-06-12 15:24:36 +0000 | [diff] [blame] | 71 | #define charset(dest, src, n) memset(dest, src, (n) * sizeof(char)) |
David Lawrence Ramsey | d08348b | 2004-09-18 22:02:21 +0000 | [diff] [blame] | 72 | |
David Lawrence Ramsey | 092af14 | 2005-06-08 01:35:10 +0000 | [diff] [blame] | 73 | /* Set a default value for PATH_MAX if there isn't one. */ |
David Lawrence Ramsey | 3e0c8a6 | 2004-11-04 04:08:18 +0000 | [diff] [blame] | 74 | #ifndef PATH_MAX |
David Lawrence Ramsey | 6e0ed3c | 2005-03-26 04:42:28 +0000 | [diff] [blame] | 75 | #define PATH_MAX 4096 |
David Lawrence Ramsey | 5db0cdc | 2002-06-28 22:45:14 +0000 | [diff] [blame] | 76 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 77 | |
David Lawrence Ramsey | f78bc85 | 2007-12-18 15:55:48 +0000 | [diff] [blame] | 78 | #ifdef USE_SLANG |
| 79 | /* Slang support. */ |
| 80 | #include <slcurses.h> |
| 81 | /* Slang curses emulation brain damage, part 3: Slang doesn't define the |
| 82 | * curses equivalents of the Insert or Delete keys. */ |
| 83 | #define KEY_DC SL_KEY_DELETE |
| 84 | #define KEY_IC SL_KEY_IC |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 85 | /* Ncurses support. */ |
Chris Allegretta | 2e4228f | 2013-01-10 03:29:59 +0000 | [diff] [blame] | 86 | #elif defined(HAVE_NCURSESW_NCURSES_H) |
| 87 | #include <ncursesw/ncurses.h> |
David Lawrence Ramsey | f78bc85 | 2007-12-18 15:55:48 +0000 | [diff] [blame] | 88 | #elif defined(HAVE_NCURSES_H) |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 89 | #include <ncurses.h> |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 90 | #else |
| 91 | /* Curses support. */ |
David Lawrence Ramsey | c97acfb | 2003-09-10 20:08:00 +0000 | [diff] [blame] | 92 | #include <curses.h> |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 93 | #endif /* CURSES_H */ |
| 94 | |
Benno Schulenberg | 8c7a385 | 2016-07-12 21:05:09 +0200 | [diff] [blame] | 95 | #if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR < 6) |
| 96 | #define USING_OLD_NCURSES yes |
| 97 | #endif |
| 98 | |
David Lawrence Ramsey | 2ab03f6 | 2002-10-17 02:19:31 +0000 | [diff] [blame] | 99 | #ifdef ENABLE_NLS |
David Lawrence Ramsey | c1c818e | 2006-05-14 18:22:01 +0000 | [diff] [blame] | 100 | /* Native language support. */ |
David Lawrence Ramsey | 637b8bb | 2005-01-17 05:06:55 +0000 | [diff] [blame] | 101 | #ifdef HAVE_LIBINTL_H |
| 102 | #include <libintl.h> |
| 103 | #endif |
| 104 | #define _(string) gettext(string) |
| 105 | #define P_(singular, plural, number) ngettext(singular, plural, number) |
David Lawrence Ramsey | 2ab03f6 | 2002-10-17 02:19:31 +0000 | [diff] [blame] | 106 | #else |
David Lawrence Ramsey | 637b8bb | 2005-01-17 05:06:55 +0000 | [diff] [blame] | 107 | #define _(string) (string) |
| 108 | #define P_(singular, plural, number) (number == 1 ? singular : plural) |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 109 | #endif |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 110 | #define gettext_noop(string) (string) |
| 111 | #define N_(string) gettext_noop(string) |
David Lawrence Ramsey | afbcf68 | 2005-03-21 06:33:41 +0000 | [diff] [blame] | 112 | /* Mark a string that will be sent to gettext() later. */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 113 | |
David Lawrence Ramsey | fc69321 | 2004-12-23 17:43:27 +0000 | [diff] [blame] | 114 | #include <stddef.h> |
Rashed Abdel-Tawab | c511262 | 2015-10-18 16:56:55 +0000 | [diff] [blame] | 115 | #include <stdio.h> |
David Lawrence Ramsey | 691698a | 2005-07-24 19:57:51 +0000 | [diff] [blame] | 116 | #include <stdlib.h> |
David Lawrence Ramsey | 5db0cdc | 2002-06-28 22:45:14 +0000 | [diff] [blame] | 117 | #include <sys/types.h> |
| 118 | #include <sys/stat.h> |
David Lawrence Ramsey | 691698a | 2005-07-24 19:57:51 +0000 | [diff] [blame] | 119 | #include <dirent.h> |
| 120 | #ifdef HAVE_REGEX_H |
| 121 | #include <regex.h> |
| 122 | #endif |
Benno Schulenberg | 75d64e6 | 2015-05-28 13:02:29 +0000 | [diff] [blame] | 123 | #include <signal.h> |
David Lawrence Ramsey | 691698a | 2005-07-24 19:57:51 +0000 | [diff] [blame] | 124 | #include <assert.h> |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 125 | |
David Lawrence Ramsey | da50e73 | 2005-07-04 04:22:30 +0000 | [diff] [blame] | 126 | /* If no vsnprintf(), use the version from glib 2.x. */ |
David Lawrence Ramsey | 3a1fc8f | 2005-01-16 18:49:19 +0000 | [diff] [blame] | 127 | #ifndef HAVE_VSNPRINTF |
David Lawrence Ramsey | da50e73 | 2005-07-04 04:22:30 +0000 | [diff] [blame] | 128 | #include <glib.h> |
David Lawrence Ramsey | 3a1fc8f | 2005-01-16 18:49:19 +0000 | [diff] [blame] | 129 | #define vsnprintf g_vsnprintf |
| 130 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 131 | |
David Lawrence Ramsey | d864048 | 2005-06-12 17:48:46 +0000 | [diff] [blame] | 132 | /* If no isblank(), iswblank(), strcasecmp(), strncasecmp(), |
| 133 | * strcasestr(), strnlen(), getdelim(), or getline(), use the versions |
| 134 | * we have. */ |
| 135 | #ifndef HAVE_ISBLANK |
| 136 | #define isblank nisblank |
| 137 | #endif |
| 138 | #ifndef HAVE_ISWBLANK |
| 139 | #define iswblank niswblank |
| 140 | #endif |
David Lawrence Ramsey | adc30a8 | 2005-03-20 07:24:49 +0000 | [diff] [blame] | 141 | #ifndef HAVE_STRCASECMP |
| 142 | #define strcasecmp nstrcasecmp |
| 143 | #endif |
| 144 | #ifndef HAVE_STRNCASECMP |
| 145 | #define strncasecmp nstrncasecmp |
| 146 | #endif |
| 147 | #ifndef HAVE_STRCASESTR |
| 148 | #define strcasestr nstrcasestr |
| 149 | #endif |
| 150 | #ifndef HAVE_STRNLEN |
| 151 | #define strnlen nstrnlen |
| 152 | #endif |
David Lawrence Ramsey | a27bd65 | 2004-08-17 05:23:38 +0000 | [diff] [blame] | 153 | #ifndef HAVE_GETDELIM |
| 154 | #define getdelim ngetdelim |
| 155 | #endif |
David Lawrence Ramsey | a27bd65 | 2004-08-17 05:23:38 +0000 | [diff] [blame] | 156 | #ifndef HAVE_GETLINE |
| 157 | #define getline ngetline |
| 158 | #endif |
| 159 | |
David Lawrence Ramsey | 6e308c0 | 2006-07-19 02:44:56 +0000 | [diff] [blame] | 160 | /* If we aren't using ncurses with mouse support, turn the mouse support |
| 161 | * off, as it's useless then. */ |
David Lawrence Ramsey | f5b256b | 2003-10-03 20:26:25 +0000 | [diff] [blame] | 162 | #ifndef NCURSES_MOUSE_VERSION |
| 163 | #define DISABLE_MOUSE 1 |
| 164 | #endif |
David Lawrence Ramsey | 935594b | 2006-07-18 18:16:30 +0000 | [diff] [blame] | 165 | |
David Lawrence Ramsey | 32a3ce4 | 2006-07-18 18:25:56 +0000 | [diff] [blame] | 166 | #if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY) |
| 167 | #define DISABLE_WRAPJUSTIFY 1 |
David Lawrence Ramsey | 935594b | 2006-07-18 18:16:30 +0000 | [diff] [blame] | 168 | #endif |
Chris Allegretta | 6fe6149 | 2001-05-21 12:56:25 +0000 | [diff] [blame] | 169 | |
David Lawrence Ramsey | 3e0c8a6 | 2004-11-04 04:08:18 +0000 | [diff] [blame] | 170 | /* Enumeration types. */ |
| 171 | typedef enum { |
| 172 | NIX_FILE, DOS_FILE, MAC_FILE |
| 173 | } file_format; |
| 174 | |
| 175 | typedef enum { |
Benno Schulenberg | c8f530a | 2016-05-19 20:43:08 +0200 | [diff] [blame] | 176 | HUSH, MILD, ALERT |
| 177 | } message_type; |
| 178 | |
| 179 | typedef enum { |
David Lawrence Ramsey | bf0e47d | 2005-08-01 18:27:10 +0000 | [diff] [blame] | 180 | OVERWRITE, APPEND, PREPEND |
Benno Schulenberg | c2a0c78 | 2016-07-15 12:59:59 +0200 | [diff] [blame] | 181 | } kind_of_writing_type; |
David Lawrence Ramsey | bf0e47d | 2005-08-01 18:27:10 +0000 | [diff] [blame] | 182 | |
| 183 | typedef enum { |
Benno Schulenberg | 382c9d7 | 2016-04-24 11:28:28 +0200 | [diff] [blame] | 184 | SOFTMARK, HARDMARK |
| 185 | } mark_type; |
| 186 | |
| 187 | typedef enum { |
Benno Schulenberg | ce0ea44 | 2014-06-23 18:20:12 +0000 | [diff] [blame] | 188 | UPWARD, DOWNWARD |
David Lawrence Ramsey | bf0e47d | 2005-08-01 18:27:10 +0000 | [diff] [blame] | 189 | } scroll_dir; |
David Lawrence Ramsey | 3e0c8a6 | 2004-11-04 04:08:18 +0000 | [diff] [blame] | 190 | |
| 191 | typedef enum { |
Benno Schulenberg | cb17732 | 2016-04-07 13:58:51 +0200 | [diff] [blame] | 192 | CENTERING, FLOWING, STATIONARY |
David Lawrence Ramsey | bf0e47d | 2005-08-01 18:27:10 +0000 | [diff] [blame] | 193 | } update_type; |
David Lawrence Ramsey | 3e0c8a6 | 2004-11-04 04:08:18 +0000 | [diff] [blame] | 194 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 195 | typedef enum { |
Benno Schulenberg | c35eb5a | 2014-06-09 10:35:44 +0000 | [diff] [blame] | 196 | ADD, DEL, BACK, CUT, CUT_EOF, REPLACE, |
| 197 | #ifndef DISABLE_WRAPPING |
| 198 | SPLIT_BEGIN, SPLIT_END, |
| 199 | #endif |
Mike Scalora | 6a2032f | 2016-05-25 22:13:50 +0200 | [diff] [blame] | 200 | #ifndef DISABLE_COMMENT |
| 201 | COMMENT, UNCOMMENT, PREFLIGHT, |
| 202 | #endif |
Benno Schulenberg | 45fe2ad | 2014-06-18 20:11:52 +0000 | [diff] [blame] | 203 | JOIN, PASTE, INSERT, ENTER, OTHER |
Chris Allegretta | 07fcc4c | 2008-07-10 20:13:04 +0000 | [diff] [blame] | 204 | } undo_type; |
| 205 | |
Benno Schulenberg | 0255537 | 2015-06-18 19:07:56 +0000 | [diff] [blame] | 206 | /* Structure types. */ |
Benno Schulenberg | 0038992 | 2014-04-04 11:59:03 +0000 | [diff] [blame] | 207 | #ifndef DISABLE_COLOR |
David Lawrence Ramsey | db95802 | 2005-07-13 20:18:46 +0000 | [diff] [blame] | 208 | typedef struct colortype { |
Chris Allegretta | 22c83ec | 2013-03-17 22:09:38 +0000 | [diff] [blame] | 209 | short fg; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 210 | /* This syntax's foreground color. */ |
Chris Allegretta | 22c83ec | 2013-03-17 22:09:38 +0000 | [diff] [blame] | 211 | short bg; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 212 | /* This syntax's background color. */ |
| 213 | bool bright; |
| 214 | /* Is this color A_BOLD? */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 215 | int pairnum; |
| 216 | /* The color pair number used for this foreground color and |
| 217 | * background color. */ |
Rishabh Dave | 4c566c7 | 2016-07-17 18:59:07 +0530 | [diff] [blame] | 218 | int attributes; |
| 219 | /* Pair number and brightness composed into ready-to-use attributes. */ |
Benno Schulenberg | 6ed6462 | 2016-03-13 19:37:21 +0000 | [diff] [blame] | 220 | int rex_flags; |
| 221 | /* The regex compilation flags (with or without REG_ICASE). */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 222 | char *start_regex; |
| 223 | /* The start (or all) of the regex string. */ |
| 224 | regex_t *start; |
| 225 | /* The compiled start (or all) of the regex string. */ |
| 226 | char *end_regex; |
| 227 | /* The end (if any) of the regex string. */ |
| 228 | regex_t *end; |
| 229 | /* The compiled end (if any) of the regex string. */ |
David Lawrence Ramsey | db95802 | 2005-07-13 20:18:46 +0000 | [diff] [blame] | 230 | struct colortype *next; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 231 | /* Next set of colors. */ |
Benno Schulenberg | 8f61511 | 2014-04-14 09:57:06 +0000 | [diff] [blame] | 232 | int id; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 233 | /* Basic id for assigning to lines later. */ |
David Lawrence Ramsey | db95802 | 2005-07-13 20:18:46 +0000 | [diff] [blame] | 234 | } colortype; |
| 235 | |
Benno Schulenberg | 1d5134d | 2014-05-12 14:31:54 +0000 | [diff] [blame] | 236 | typedef struct regexlisttype { |
Benno Schulenberg | 3522751 | 2016-02-26 20:09:29 +0000 | [diff] [blame] | 237 | char *full_regex; |
| 238 | /* A regex string to match things that imply a certain syntax. */ |
Benno Schulenberg | 1d5134d | 2014-05-12 14:31:54 +0000 | [diff] [blame] | 239 | struct regexlisttype *next; |
Benno Schulenberg | 07441ad | 2016-02-26 20:19:13 +0000 | [diff] [blame] | 240 | /* The next regex. */ |
Benno Schulenberg | 1d5134d | 2014-05-12 14:31:54 +0000 | [diff] [blame] | 241 | } regexlisttype; |
David Lawrence Ramsey | db95802 | 2005-07-13 20:18:46 +0000 | [diff] [blame] | 242 | |
| 243 | typedef struct syntaxtype { |
Benno Schulenberg | a24aee4 | 2016-02-29 09:17:03 +0000 | [diff] [blame] | 244 | char *name; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 245 | /* The name of this syntax. */ |
Benno Schulenberg | 1d5134d | 2014-05-12 14:31:54 +0000 | [diff] [blame] | 246 | regexlisttype *extensions; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 247 | /* The list of extensions that this syntax applies to. */ |
Benno Schulenberg | 1d5134d | 2014-05-12 14:31:54 +0000 | [diff] [blame] | 248 | regexlisttype *headers; |
Benno Schulenberg | cf4f80d | 2014-05-12 13:52:50 +0000 | [diff] [blame] | 249 | /* The list of headerlines that this syntax applies to. */ |
Benno Schulenberg | 1d5134d | 2014-05-12 14:31:54 +0000 | [diff] [blame] | 250 | regexlisttype *magics; |
Benno Schulenberg | cf4f80d | 2014-05-12 13:52:50 +0000 | [diff] [blame] | 251 | /* The list of libmagic results that this syntax applies to. */ |
Chris Allegretta | 5575bfa | 2014-02-24 10:18:15 +0000 | [diff] [blame] | 252 | char *linter; |
Benno Schulenberg | 773fc44 | 2016-02-29 10:54:48 +0000 | [diff] [blame] | 253 | /* The command with which to lint this type of file. */ |
Chris Allegretta | 4b3f277 | 2015-01-03 07:24:17 +0000 | [diff] [blame] | 254 | char *formatter; |
Benno Schulenberg | 773fc44 | 2016-02-29 10:54:48 +0000 | [diff] [blame] | 255 | /* The formatting command (for programming languages mainly). */ |
Mike Scalora | 6a2032f | 2016-05-25 22:13:50 +0200 | [diff] [blame] | 256 | char *comment; |
| 257 | /* The line comment prefix (and postfix) for this type of file. */ |
Benno Schulenberg | 773fc44 | 2016-02-29 10:54:48 +0000 | [diff] [blame] | 258 | colortype *color; |
| 259 | /* The colors and their regexes used in this syntax. */ |
Chris Allegretta | d47d8cd | 2009-01-25 07:25:17 +0000 | [diff] [blame] | 260 | int nmultis; |
Benno Schulenberg | 773fc44 | 2016-02-29 10:54:48 +0000 | [diff] [blame] | 261 | /* How many multiline regex strings this syntax has. */ |
David Lawrence Ramsey | db95802 | 2005-07-13 20:18:46 +0000 | [diff] [blame] | 262 | struct syntaxtype *next; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 263 | /* Next syntax. */ |
David Lawrence Ramsey | db95802 | 2005-07-13 20:18:46 +0000 | [diff] [blame] | 264 | } syntaxtype; |
Chris Allegretta | 364763f | 2009-02-03 05:05:58 +0000 | [diff] [blame] | 265 | |
Chris Allegretta | 5575bfa | 2014-02-24 10:18:15 +0000 | [diff] [blame] | 266 | typedef struct lintstruct { |
| 267 | ssize_t lineno; |
| 268 | /* Line number of the error. */ |
| 269 | ssize_t colno; |
| 270 | /* Column # of the error. */ |
| 271 | char *msg; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 272 | /* Error message text. */ |
Chris Allegretta | 5575bfa | 2014-02-24 10:18:15 +0000 | [diff] [blame] | 273 | char *filename; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 274 | /* Filename. */ |
Chris Allegretta | 5575bfa | 2014-02-24 10:18:15 +0000 | [diff] [blame] | 275 | struct lintstruct *next; |
| 276 | /* Next error. */ |
| 277 | struct lintstruct *prev; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 278 | /* Previous error. */ |
Chris Allegretta | 5575bfa | 2014-02-24 10:18:15 +0000 | [diff] [blame] | 279 | } lintstruct; |
| 280 | |
Benno Schulenberg | 0255537 | 2015-06-18 19:07:56 +0000 | [diff] [blame] | 281 | /* Flags that indicate how a multiline regex applies to a line. */ |
Benno Schulenberg | a65ef42 | 2014-03-17 21:36:37 +0000 | [diff] [blame] | 282 | #define CNONE (1<<1) |
Chris Allegretta | 364763f | 2009-02-03 05:05:58 +0000 | [diff] [blame] | 283 | /* Yay, regex doesn't apply to this line at all! */ |
Benno Schulenberg | a65ef42 | 2014-03-17 21:36:37 +0000 | [diff] [blame] | 284 | #define CBEGINBEFORE (1<<2) |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 285 | /* Regex starts on an earlier line, ends on this one. */ |
Benno Schulenberg | a65ef42 | 2014-03-17 21:36:37 +0000 | [diff] [blame] | 286 | #define CENDAFTER (1<<3) |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 287 | /* Regex starts on this line and ends on a later one. */ |
Benno Schulenberg | a65ef42 | 2014-03-17 21:36:37 +0000 | [diff] [blame] | 288 | #define CWHOLELINE (1<<4) |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 289 | /* Whole line engulfed by the regex, start < me, end > me. */ |
Benno Schulenberg | a65ef42 | 2014-03-17 21:36:37 +0000 | [diff] [blame] | 290 | #define CSTARTENDHERE (1<<5) |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 291 | /* Regex starts and ends within this line. */ |
Benno Schulenberg | 7ef5c53 | 2017-02-12 22:34:31 +0100 | [diff] [blame] | 292 | #define CWOULDBE (1<<6) |
| 293 | /* An unpaired start match on or before this line. */ |
Benno Schulenberg | 0038992 | 2014-04-04 11:59:03 +0000 | [diff] [blame] | 294 | #endif /* !DISABLE_COLOR */ |
David Lawrence Ramsey | db95802 | 2005-07-13 20:18:46 +0000 | [diff] [blame] | 295 | |
Benno Schulenberg | 0255537 | 2015-06-18 19:07:56 +0000 | [diff] [blame] | 296 | /* More structure types. */ |
Chris Allegretta | a117163 | 2009-01-19 19:10:39 +0000 | [diff] [blame] | 297 | typedef struct filestruct { |
| 298 | char *data; |
| 299 | /* The text of this line. */ |
| 300 | ssize_t lineno; |
| 301 | /* The number of this line. */ |
| 302 | struct filestruct *next; |
| 303 | /* Next node. */ |
| 304 | struct filestruct *prev; |
| 305 | /* Previous node. */ |
Benno Schulenberg | 0038992 | 2014-04-04 11:59:03 +0000 | [diff] [blame] | 306 | #ifndef DISABLE_COLOR |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 307 | short *multidata; |
| 308 | /* Array of which multi-line regexes apply to this line. */ |
Chris Allegretta | a117163 | 2009-01-19 19:10:39 +0000 | [diff] [blame] | 309 | #endif |
| 310 | } filestruct; |
| 311 | |
| 312 | typedef struct partition { |
| 313 | filestruct *fileage; |
| 314 | /* The top line of this portion of the file. */ |
| 315 | filestruct *top_prev; |
| 316 | /* The line before the top line of this portion of the file. */ |
| 317 | char *top_data; |
| 318 | /* The text before the beginning of the top line of this portion |
| 319 | * of the file. */ |
| 320 | filestruct *filebot; |
| 321 | /* The bottom line of this portion of the file. */ |
| 322 | filestruct *bot_next; |
| 323 | /* The line after the bottom line of this portion of the |
| 324 | * file. */ |
| 325 | char *bot_data; |
| 326 | /* The text after the end of the bottom line of this portion of |
| 327 | * the file. */ |
| 328 | } partition; |
| 329 | |
Chris Allegretta | 07fcc4c | 2008-07-10 20:13:04 +0000 | [diff] [blame] | 330 | #ifndef NANO_TINY |
Mike Scalora | 6a2032f | 2016-05-25 22:13:50 +0200 | [diff] [blame] | 331 | typedef struct undo_group { |
| 332 | ssize_t top_line; |
| 333 | /* First line of group. */ |
| 334 | ssize_t bottom_line; |
| 335 | /* Last line of group. */ |
| 336 | struct undo_group *next; |
| 337 | } undo_group; |
| 338 | |
Chris Allegretta | 07fcc4c | 2008-07-10 20:13:04 +0000 | [diff] [blame] | 339 | typedef struct undo { |
Chris Allegretta | 12dc8ca | 2008-07-31 04:24:04 +0000 | [diff] [blame] | 340 | ssize_t lineno; |
Chris Allegretta | 07fcc4c | 2008-07-10 20:13:04 +0000 | [diff] [blame] | 341 | undo_type type; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 342 | /* What type of undo this was. */ |
Benno Schulenberg | 6081546 | 2014-05-15 20:00:46 +0000 | [diff] [blame] | 343 | size_t begin; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 344 | /* Where did this action begin or end. */ |
Chris Allegretta | 07fcc4c | 2008-07-10 20:13:04 +0000 | [diff] [blame] | 345 | char *strdata; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 346 | /* String type data we will use for copying the affected line back. */ |
Benno Schulenberg | 66e2141 | 2015-11-30 16:21:51 +0000 | [diff] [blame] | 347 | size_t wassize; |
| 348 | /* The file size before the action. */ |
| 349 | size_t newsize; |
| 350 | /* The file size after the action. */ |
Chris Allegretta | 0b499d4 | 2008-07-14 07:18:22 +0000 | [diff] [blame] | 351 | int xflags; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 352 | /* Some flag data we need. */ |
Mike Scalora | 6a2032f | 2016-05-25 22:13:50 +0200 | [diff] [blame] | 353 | undo_group *grouping; |
| 354 | /* Undo info specific to groups of lines. */ |
Chris Allegretta | 12dc8ca | 2008-07-31 04:24:04 +0000 | [diff] [blame] | 355 | |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 356 | /* Cut-specific stuff we need. */ |
Chris Allegretta | 12dc8ca | 2008-07-31 04:24:04 +0000 | [diff] [blame] | 357 | filestruct *cutbuffer; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 358 | /* Copy of the cutbuffer. */ |
Chris Allegretta | 12dc8ca | 2008-07-31 04:24:04 +0000 | [diff] [blame] | 359 | filestruct *cutbottom; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 360 | /* Copy of cutbottom. */ |
Chris Allegretta | 12dc8ca | 2008-07-31 04:24:04 +0000 | [diff] [blame] | 361 | ssize_t mark_begin_lineno; |
Benno Schulenberg | 83b89a4 | 2016-06-07 11:52:57 +0200 | [diff] [blame] | 362 | /* Mostly the line number of the current line; sometimes something else. */ |
Benno Schulenberg | 6081546 | 2014-05-15 20:00:46 +0000 | [diff] [blame] | 363 | size_t mark_begin_x; |
Benno Schulenberg | 83b89a4 | 2016-06-07 11:52:57 +0200 | [diff] [blame] | 364 | /* The x position corresponding to the above line number. */ |
Chris Allegretta | 12dc8ca | 2008-07-31 04:24:04 +0000 | [diff] [blame] | 365 | struct undo *next; |
Benno Schulenberg | 83b89a4 | 2016-06-07 11:52:57 +0200 | [diff] [blame] | 366 | /* A pointer to the undo item of the preceding action. */ |
Chris Allegretta | 07fcc4c | 2008-07-10 20:13:04 +0000 | [diff] [blame] | 367 | } undo; |
Benno Schulenberg | b341f29 | 2014-06-19 20:05:24 +0000 | [diff] [blame] | 368 | #endif /* !NANO_TINY */ |
Chris Allegretta | 12dc8ca | 2008-07-31 04:24:04 +0000 | [diff] [blame] | 369 | |
Benno Schulenberg | b341f29 | 2014-06-19 20:05:24 +0000 | [diff] [blame] | 370 | #ifndef DISABLE_HISTORIES |
Chris Allegretta | 9bfda91 | 2011-02-16 06:52:30 +0000 | [diff] [blame] | 371 | typedef struct poshiststruct { |
| 372 | char *filename; |
Benno Schulenberg | 5df7c0d | 2014-04-16 09:32:53 +0000 | [diff] [blame] | 373 | /* The file. */ |
Chris Allegretta | 9bfda91 | 2011-02-16 06:52:30 +0000 | [diff] [blame] | 374 | ssize_t lineno; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 375 | /* Line number we left off on. */ |
Chris Allegretta | 9bfda91 | 2011-02-16 06:52:30 +0000 | [diff] [blame] | 376 | ssize_t xno; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 377 | /* x position in the file we left off on. */ |
Chris Allegretta | 9bfda91 | 2011-02-16 06:52:30 +0000 | [diff] [blame] | 378 | struct poshiststruct *next; |
| 379 | } poshiststruct; |
Benno Schulenberg | b341f29 | 2014-06-19 20:05:24 +0000 | [diff] [blame] | 380 | #endif |
Chris Allegretta | 12dc8ca | 2008-07-31 04:24:04 +0000 | [diff] [blame] | 381 | |
Chris Allegretta | f2387fb | 2002-04-10 02:31:20 +0000 | [diff] [blame] | 382 | typedef struct openfilestruct { |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 383 | char *filename; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 384 | /* The file's name. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 385 | filestruct *fileage; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 386 | /* The file's first line. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 387 | filestruct *filebot; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 388 | /* The file's last line. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 389 | filestruct *edittop; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 390 | /* The current top of the edit window for this file. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 391 | filestruct *current; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 392 | /* The current line for this file. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 393 | size_t totsize; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 394 | /* The file's total number of characters. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 395 | size_t current_x; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 396 | /* The file's x-coordinate position. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 397 | size_t placewewant; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 398 | /* The file's x position we would like. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 399 | ssize_t current_y; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 400 | /* The file's y-coordinate position. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 401 | bool modified; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 402 | /* Whether the file has been modified. */ |
Benno Schulenberg | f6dd0ad | 2016-08-02 17:26:25 +0200 | [diff] [blame] | 403 | struct stat *current_stat; |
| 404 | /* The file's current stat information. */ |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 405 | #ifndef NANO_TINY |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 406 | bool mark_set; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 407 | /* Whether the mark is on in this file. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 408 | filestruct *mark_begin; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 409 | /* The file's line where the mark is, if any. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 410 | size_t mark_begin_x; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 411 | /* The file's mark's x-coordinate position, if any. */ |
Benno Schulenberg | 382c9d7 | 2016-04-24 11:28:28 +0200 | [diff] [blame] | 412 | mark_type kind_of_mark; |
| 413 | /* Whether this is a soft or a hard mark. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 414 | file_format fmt; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 415 | /* The file's format. */ |
Chris Allegretta | 07fcc4c | 2008-07-10 20:13:04 +0000 | [diff] [blame] | 416 | undo *undotop; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 417 | /* The top of the undo list. */ |
Chris Allegretta | 07fcc4c | 2008-07-10 20:13:04 +0000 | [diff] [blame] | 418 | undo *current_undo; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 419 | /* The current (i.e. next) level of undo. */ |
Chris Allegretta | 07fcc4c | 2008-07-10 20:13:04 +0000 | [diff] [blame] | 420 | undo_type last_action; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 421 | /* The type of the last action the user performed. */ |
Benno Schulenberg | 9fcde23 | 2015-07-10 15:54:06 +0000 | [diff] [blame] | 422 | char *lock_filename; |
Benno Schulenberg | 5df7c0d | 2014-04-16 09:32:53 +0000 | [diff] [blame] | 423 | /* The path of the lockfile, if we created one. */ |
Chris Allegretta | 2d7893d | 2001-07-11 02:08:33 +0000 | [diff] [blame] | 424 | #endif |
Benno Schulenberg | 0038992 | 2014-04-04 11:59:03 +0000 | [diff] [blame] | 425 | #ifndef DISABLE_COLOR |
Chris Allegretta | d47d8cd | 2009-01-25 07:25:17 +0000 | [diff] [blame] | 426 | syntaxtype *syntax; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 427 | /* The syntax struct for this file, if any. */ |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 428 | colortype *colorstrings; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 429 | /* The file's associated colors. */ |
David Lawrence Ramsey | db95802 | 2005-07-13 20:18:46 +0000 | [diff] [blame] | 430 | #endif |
David Lawrence Ramsey | 6ad59cd | 2005-07-08 20:09:16 +0000 | [diff] [blame] | 431 | struct openfilestruct *next; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 432 | /* The next open file, if any. */ |
David Lawrence Ramsey | 6ad59cd | 2005-07-08 20:09:16 +0000 | [diff] [blame] | 433 | struct openfilestruct *prev; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 434 | /* The preceding open file, if any. */ |
David Lawrence Ramsey | 6ad59cd | 2005-07-08 20:09:16 +0000 | [diff] [blame] | 435 | } openfilestruct; |
Chris Allegretta | 2d7893d | 2001-07-11 02:08:33 +0000 | [diff] [blame] | 436 | |
Benno Schulenberg | eea0908 | 2014-04-13 20:50:20 +0000 | [diff] [blame] | 437 | #ifndef DISABLE_NANORC |
Chris Allegretta | 8d8e012 | 2001-04-18 04:28:54 +0000 | [diff] [blame] | 438 | typedef struct rcoption { |
Benno Schulenberg | 17cf833 | 2016-05-30 09:09:36 +0200 | [diff] [blame] | 439 | const char *name; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 440 | /* The name of the rcfile option. */ |
Benno Schulenberg | 17cf833 | 2016-05-30 09:09:36 +0200 | [diff] [blame] | 441 | long flag; |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 442 | /* The flag associated with it, if any. */ |
Chris Allegretta | 8d8e012 | 2001-04-18 04:28:54 +0000 | [diff] [blame] | 443 | } rcoption; |
David Lawrence Ramsey | 6d9aa08 | 2004-11-03 14:58:04 +0000 | [diff] [blame] | 444 | #endif |
Chris Allegretta | 8d8e012 | 2001-04-18 04:28:54 +0000 | [diff] [blame] | 445 | |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 446 | typedef struct sc { |
Benno Schulenberg | 3930a69 | 2016-07-30 12:44:23 +0200 | [diff] [blame] | 447 | const char *keystr; |
Benno Schulenberg | 1c9ab8b | 2016-07-24 21:49:07 +0200 | [diff] [blame] | 448 | /* The string that describes a keystroke, like "^C" or "M-R". */ |
Benno Schulenberg | e295070 | 2016-07-23 14:42:40 +0200 | [diff] [blame] | 449 | bool meta; |
| 450 | /* Whether this is a Meta keystroke. */ |
Benno Schulenberg | 1c9ab8b | 2016-07-24 21:49:07 +0200 | [diff] [blame] | 451 | int keycode; |
| 452 | /* The integer that, together with meta, identifies the keystroke. */ |
Benno Schulenberg | 1f866c2 | 2015-07-15 20:13:05 +0000 | [diff] [blame] | 453 | int menus; |
| 454 | /* Which menus this applies to. */ |
Chris Allegretta | 637daa8 | 2011-02-07 14:45:56 +0000 | [diff] [blame] | 455 | void (*scfunc)(void); |
Benno Schulenberg | 5df7c0d | 2014-04-16 09:32:53 +0000 | [diff] [blame] | 456 | /* The function we're going to run. */ |
Benno Schulenberg | 7b7d2bf | 2016-09-01 09:36:47 +0200 | [diff] [blame] | 457 | #ifndef NANO_TINY |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 458 | int toggle; |
Benno Schulenberg | 5df7c0d | 2014-04-16 09:32:53 +0000 | [diff] [blame] | 459 | /* If a toggle, what we're toggling. */ |
Benno Schulenberg | 5ac6a87 | 2015-07-06 17:51:17 +0000 | [diff] [blame] | 460 | int ordinal; |
| 461 | /* The how-manieth toggle this is, in order to be able to |
| 462 | * keep them in sequence. */ |
Benno Schulenberg | 7b7d2bf | 2016-09-01 09:36:47 +0200 | [diff] [blame] | 463 | #endif |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 464 | struct sc *next; |
Benno Schulenberg | 5df7c0d | 2014-04-16 09:32:53 +0000 | [diff] [blame] | 465 | /* Next in the list. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 466 | } sc; |
| 467 | |
| 468 | typedef struct subnfunc { |
Chris Allegretta | 637daa8 | 2011-02-07 14:45:56 +0000 | [diff] [blame] | 469 | void (*scfunc)(void); |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 470 | /* The actual function to call. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 471 | int menus; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 472 | /* In what menus this function applies. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 473 | const char *desc; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 474 | /* The function's short description, for example "Where Is". */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 475 | #ifndef DISABLE_HELP |
| 476 | const char *help; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 477 | /* The help-screen text for this function. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 478 | bool blank_after; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 479 | /* Whether there should be a blank line after the help text |
| 480 | * for this function. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 481 | #endif |
| 482 | bool viewok; |
Benno Schulenberg | 5df7c0d | 2014-04-16 09:32:53 +0000 | [diff] [blame] | 483 | /* Is this function allowed when in view mode? */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 484 | long toggle; |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 485 | /* If this is a toggle, which toggle to affect. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 486 | struct subnfunc *next; |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 487 | /* Next item in the list. */ |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 488 | } subnfunc; |
| 489 | |
Benno Schulenberg | 68a0314 | 2016-12-07 13:10:40 +0100 | [diff] [blame] | 490 | #ifdef ENABLE_WORDCOMPLETION |
Sumedh Pendurkar | dca4ab5 | 2016-12-07 09:43:47 +0530 | [diff] [blame] | 491 | typedef struct completion_word { |
| 492 | char *word; |
| 493 | struct completion_word *next; |
| 494 | } completion_word; |
| 495 | #endif |
| 496 | |
Benno Schulenberg | 1663994 | 2014-05-03 18:24:45 +0000 | [diff] [blame] | 497 | /* The elements of the interface that can be colored differently. */ |
| 498 | enum |
| 499 | { |
| 500 | TITLE_BAR = 0, |
Benno Schulenberg | de2aa4f | 2016-10-20 10:07:48 +0200 | [diff] [blame] | 501 | LINE_NUMBER, |
Benno Schulenberg | 1663994 | 2014-05-03 18:24:45 +0000 | [diff] [blame] | 502 | STATUS_BAR, |
| 503 | KEY_COMBO, |
| 504 | FUNCTION_TAG, |
| 505 | NUMBER_OF_ELEMENTS |
| 506 | }; |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 507 | |
Benno Schulenberg | eb91ad5 | 2014-05-15 13:11:55 +0000 | [diff] [blame] | 508 | /* Enumeration used in the flags array. See the definition of FLAGMASK. */ |
Chris Allegretta | a48507d | 2009-08-14 03:18:29 +0000 | [diff] [blame] | 509 | enum |
| 510 | { |
Chris Allegretta | 795be59 | 2009-11-07 16:56:17 +0000 | [diff] [blame] | 511 | DONTUSE, |
Chris Allegretta | a48507d | 2009-08-14 03:18:29 +0000 | [diff] [blame] | 512 | CASE_SENSITIVE, |
| 513 | CONST_UPDATE, |
| 514 | NO_HELP, |
Chris Allegretta | a48507d | 2009-08-14 03:18:29 +0000 | [diff] [blame] | 515 | SUSPEND, |
| 516 | NO_WRAP, |
| 517 | AUTOINDENT, |
| 518 | VIEW_MODE, |
| 519 | USE_MOUSE, |
| 520 | USE_REGEXP, |
| 521 | TEMP_FILE, |
| 522 | CUT_TO_END, |
| 523 | BACKWARDS_SEARCH, |
| 524 | MULTIBUFFER, |
| 525 | SMOOTH_SCROLL, |
| 526 | REBIND_DELETE, |
| 527 | REBIND_KEYPAD, |
| 528 | NO_CONVERT, |
| 529 | BACKUP_FILE, |
Chris Allegretta | 0acca27 | 2010-06-21 03:10:10 +0000 | [diff] [blame] | 530 | INSECURE_BACKUP, |
Chris Allegretta | a48507d | 2009-08-14 03:18:29 +0000 | [diff] [blame] | 531 | NO_COLOR_SYNTAX, |
| 532 | PRESERVE, |
| 533 | HISTORYLOG, |
| 534 | RESTRICTED, |
| 535 | SMART_HOME, |
| 536 | WHITESPACE_DISPLAY, |
| 537 | MORE_SPACE, |
| 538 | TABS_TO_SPACES, |
| 539 | QUICK_BLANK, |
| 540 | WORD_BOUNDS, |
| 541 | NO_NEWLINES, |
| 542 | BOLD_TEXT, |
| 543 | QUIET, |
Chris Allegretta | 9bfda91 | 2011-02-16 06:52:30 +0000 | [diff] [blame] | 544 | SOFTWRAP, |
Chris Allegretta | bf88d27 | 2013-01-01 03:24:39 +0000 | [diff] [blame] | 545 | POS_HISTORY, |
Benno Schulenberg | db7064b | 2014-04-08 18:59:30 +0000 | [diff] [blame] | 546 | LOCKING, |
Benno Schulenberg | 70cbbda | 2015-08-04 18:49:57 +0000 | [diff] [blame] | 547 | NOREAD_MODE, |
Chris Allegretta | 6a0ae5a | 2016-02-22 15:10:32 +0000 | [diff] [blame] | 548 | MAKE_IT_UNIX, |
Benno Schulenberg | b92d35d | 2016-09-11 09:41:09 +0200 | [diff] [blame] | 549 | JUSTIFY_TRIM, |
Faissal Bensefia | de95ca6 | 2016-10-20 09:44:29 +0100 | [diff] [blame] | 550 | SHOW_CURSOR, |
| 551 | LINE_NUMBERS |
Chris Allegretta | a48507d | 2009-08-14 03:18:29 +0000 | [diff] [blame] | 552 | }; |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 553 | |
Benno Schulenberg | 817707e | 2014-04-04 12:29:28 +0000 | [diff] [blame] | 554 | /* Flags for the menus in which a given function should be present. */ |
Benno Schulenberg | 5df7c0d | 2014-04-16 09:32:53 +0000 | [diff] [blame] | 555 | #define MMAIN (1<<0) |
| 556 | #define MWHEREIS (1<<1) |
| 557 | #define MREPLACE (1<<2) |
| 558 | #define MREPLACEWITH (1<<3) |
| 559 | #define MGOTOLINE (1<<4) |
| 560 | #define MWRITEFILE (1<<5) |
| 561 | #define MINSERTFILE (1<<6) |
| 562 | #define MEXTCMD (1<<7) |
| 563 | #define MHELP (1<<8) |
| 564 | #define MSPELL (1<<9) |
| 565 | #define MBROWSER (1<<10) |
| 566 | #define MWHEREISFILE (1<<11) |
| 567 | #define MGOTODIR (1<<12) |
| 568 | #define MYESNO (1<<13) |
| 569 | #define MLINTER (1<<14) |
Benno Schulenberg | 4c9573d | 2014-04-16 09:12:13 +0000 | [diff] [blame] | 570 | /* This is an abbreviation for all menus except Help and YesNo. */ |
Benno Schulenberg | bf84e59 | 2015-11-02 10:40:06 +0000 | [diff] [blame] | 571 | #define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\ |
| 572 | MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MSPELL|MLINTER) |
Chris Allegretta | 79a33bb | 2008-03-05 07:34:01 +0000 | [diff] [blame] | 573 | |
Benno Schulenberg | 90a9036 | 2016-08-01 12:56:05 +0200 | [diff] [blame] | 574 | /* Basic control codes. */ |
| 575 | #define TAB_CODE 0x09 |
| 576 | #define ESC_CODE 0x1B |
| 577 | #define DEL_CODE 0x7F |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 578 | |
Benno Schulenberg | f08d79d | 2015-11-23 08:52:23 +0000 | [diff] [blame] | 579 | /* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */ |
| 580 | #define CONTROL_LEFT 0x401 |
| 581 | #define CONTROL_RIGHT 0x402 |
Benno Schulenberg | c6dbcf9 | 2016-06-25 15:16:52 +0200 | [diff] [blame] | 582 | #define CONTROL_UP 0x403 |
| 583 | #define CONTROL_DOWN 0x404 |
Benno Schulenberg | 382c9d7 | 2016-04-24 11:28:28 +0200 | [diff] [blame] | 584 | #define SHIFT_CONTROL_LEFT 0x405 |
| 585 | #define SHIFT_CONTROL_RIGHT 0x406 |
| 586 | #define SHIFT_CONTROL_UP 0x407 |
| 587 | #define SHIFT_CONTROL_DOWN 0x408 |
| 588 | #define SHIFT_ALT_LEFT 0x409 |
| 589 | #define SHIFT_ALT_RIGHT 0x40a |
| 590 | #define SHIFT_ALT_UP 0x40b |
| 591 | #define SHIFT_ALT_DOWN 0x40c |
| 592 | #define SHIFT_PAGEUP 0x40d |
| 593 | #define SHIFT_PAGEDOWN 0x40e |
Benno Schulenberg | 272a953 | 2016-08-30 10:11:29 +0200 | [diff] [blame] | 594 | #define SHIFT_HOME 0x40f |
| 595 | #define SHIFT_END 0x410 |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 596 | |
David Lawrence Ramsey | ebe3425 | 2005-11-15 03:17:35 +0000 | [diff] [blame] | 597 | #ifndef NANO_TINY |
Benno Schulenberg | 75d64e6 | 2015-05-28 13:02:29 +0000 | [diff] [blame] | 598 | /* An imaginary key for when we get a SIGWINCH (window resize). */ |
| 599 | #define KEY_WINCH -2 |
| 600 | |
Benno Schulenberg | f0bb503 | 2015-06-27 09:27:19 +0000 | [diff] [blame] | 601 | /* Some extra flags for the undo function. */ |
| 602 | #define WAS_FINAL_BACKSPACE (1<<1) |
Benno Schulenberg | 83b89a4 | 2016-06-07 11:52:57 +0200 | [diff] [blame] | 603 | #define WAS_WHOLE_LINE (1<<2) |
| 604 | /* The flags for the mark need to be the highest. */ |
| 605 | #define MARK_WAS_SET (1<<3) |
| 606 | #define WAS_MARKED_FORWARD (1<<4) |
Chris Allegretta | 2d1bdd0 | 2009-01-28 05:11:57 +0000 | [diff] [blame] | 607 | #endif /* !NANO_TINY */ |
| 608 | |
David Lawrence Ramsey | fc0f8f8 | 2006-05-10 13:41:53 +0000 | [diff] [blame] | 609 | /* The maximum number of entries displayed in the main shortcut list. */ |
Benno Schulenberg | 8977c4b | 2014-03-16 16:58:18 +0000 | [diff] [blame] | 610 | #define MAIN_VISIBLE (((COLS + 40) / 20) * 2) |
David Lawrence Ramsey | fc0f8f8 | 2006-05-10 13:41:53 +0000 | [diff] [blame] | 611 | |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 612 | /* The default number of characters from the end of the line where |
| 613 | * wrapping occurs. */ |
Chris Allegretta | e61e830 | 2001-01-14 05:18:27 +0000 | [diff] [blame] | 614 | #define CHARS_FROM_EOL 8 |
| 615 | |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 616 | /* The default width of a tab in spaces. */ |
David Lawrence Ramsey | 02517e0 | 2004-09-05 21:40:31 +0000 | [diff] [blame] | 617 | #define WIDTH_OF_TAB 8 |
| 618 | |
David Lawrence Ramsey | 6d6a36c | 2005-12-08 07:09:08 +0000 | [diff] [blame] | 619 | /* The maximum number of search/replace history strings saved, not |
| 620 | * counting the blank lines at their ends. */ |
Chris Allegretta | 5beed50 | 2003-01-05 20:41:21 +0000 | [diff] [blame] | 621 | #define MAX_SEARCH_HISTORY 100 |
Chris Allegretta | 7662c86 | 2003-01-13 01:35:15 +0000 | [diff] [blame] | 622 | |
David Lawrence Ramsey | 9149325 | 2006-03-19 19:25:29 +0000 | [diff] [blame] | 623 | /* The maximum number of bytes buffered at one time. */ |
David Lawrence Ramsey | 5b2f17e | 2005-04-19 21:47:01 +0000 | [diff] [blame] | 624 | #define MAX_BUF_SIZE 128 |
| 625 | |
Benno Schulenberg | 660584c | 2016-06-01 21:29:44 +0200 | [diff] [blame] | 626 | /* The largest size_t number that doesn't have the high bit set. */ |
| 627 | #define HIGHEST_POSITIVE ((~(size_t)0) >> 1) |
| 628 | |
Chris Allegretta | d865da1 | 2002-07-29 23:46:38 +0000 | [diff] [blame] | 629 | #endif /* !NANO_H */ |