nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

definitions.h (18880B)


      1 /**************************************************************************
      2  *   definitions.h  --  This file is part of GNU nano.                    *
      3  *                                                                        *
      4  *   Copyright (C) 1999-2011, 2013-2025 Free Software Foundation, Inc.    *
      5  *   Copyright (C) 2014-2017 Benno Schulenberg                            *
      6  *                                                                        *
      7  *   GNU nano is free software: you can redistribute it and/or modify     *
      8  *   it under the terms of the GNU General Public License as published    *
      9  *   by the Free Software Foundation, either version 3 of the License,    *
     10  *   or (at your option) any later version.                               *
     11  *                                                                        *
     12  *   GNU nano is distributed in the hope that it will be useful,          *
     13  *   but WITHOUT ANY WARRANTY; without even the implied warranty          *
     14  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.              *
     15  *   See the GNU General Public License for more details.                 *
     16  *                                                                        *
     17  *   You should have received a copy of the GNU General Public License    *
     18  *   along with this program.  If not, see https://gnu.org/licenses/.     *
     19  *                                                                        *
     20  **************************************************************************/
     21 
     22 #ifdef HAVE_CONFIG_H
     23 #include <config.h>
     24 #endif
     25 
     26 #ifdef NEED_XOPEN_SOURCE_EXTENDED
     27 #ifndef _XOPEN_SOURCE_EXTENDED
     28 #define _XOPEN_SOURCE_EXTENDED  1
     29 #endif
     30 #endif
     31 
     32 #if defined(__HAIKU__) && !defined(_DEFAULT_SOURCE)
     33 #define _DEFAULT_SOURCE  1
     34 #endif
     35 
     36 #ifdef __TANDEM
     37 /* Tandem NonStop Kernel support. */
     38 #include <floss.h>
     39 #define ROOT_UID  65535
     40 #else
     41 #define ROOT_UID  0
     42 #endif
     43 
     44 #ifdef HAVE_LIMITS_H
     45 #include <limits.h>
     46 #endif
     47 
     48 /* Set a default value for PATH_MAX if there isn't one. */
     49 #ifndef PATH_MAX
     50 #define PATH_MAX  4096
     51 #endif
     52 
     53 #ifdef HAVE_SYS_PARAM_H
     54 #include <sys/param.h>
     55 #endif
     56 
     57 #include <dirent.h>
     58 #include <regex.h>
     59 #include <signal.h>
     60 #include <stdlib.h>
     61 #include <sys/stat.h>
     62 
     63 #ifdef HAVE_NCURSES_H
     64 #include <ncurses.h>
     65 #else
     66 #include <curses.h>
     67 #endif
     68 
     69 /* Native language support. */
     70 #ifdef ENABLE_NLS
     71 #ifdef HAVE_LIBINTL_H
     72 #include <libintl.h>
     73 #endif
     74 #define _(string)  gettext(string)
     75 #define P_(singular, plural, number)  ngettext(singular, plural, number)
     76 #else
     77 #define _(string)  (string)
     78 #define P_(singular, plural, number)  (number == 1 ? singular : plural)
     79 #endif
     80 /* For marking a string on which gettext() will be called later. */
     81 #define gettext_noop(string)  (string)
     82 #define N_(string)  gettext_noop(string)
     83 
     84 /* If we aren't using an ncurses with mouse support, then
     85  * exclude the mouse routines, as they are useless then. */
     86 #ifndef NCURSES_MOUSE_VERSION
     87 #undef ENABLE_MOUSE
     88 #endif
     89 
     90 #if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY)
     91 #define ENABLED_WRAPORJUSTIFY  1
     92 #endif
     93 
     94 /* Suppress warnings for __attribute__((warn_unused_result)). */
     95 #define IGNORE_CALL_RESULT(call)  do { if (call) {} } while(0)
     96 
     97 /* Macros for flags, indexing each bit in a small array. */
     98 #define FLAGS(flag)  flags[((flag) / (sizeof(unsigned) * 8))]
     99 #define FLAGMASK(flag)  ((unsigned)1 << ((flag) % (sizeof(unsigned) * 8)))
    100 #define SET(flag)  FLAGS(flag) |= FLAGMASK(flag)
    101 #define UNSET(flag)  FLAGS(flag) &= ~FLAGMASK(flag)
    102 #define ISSET(flag)  ((FLAGS(flag) & FLAGMASK(flag)) != 0)
    103 #define TOGGLE(flag)  FLAGS(flag) ^= FLAGMASK(flag)
    104 
    105 #define BACKWARD  FALSE
    106 #define FORWARD  TRUE
    107 
    108 #define YESORNO  FALSE
    109 #define YESORALLORNO  TRUE
    110 
    111 #define YES      1
    112 #define ALL      2
    113 #define NO       0
    114 #define CANCEL  -1
    115 
    116 #define BLIND  FALSE
    117 #define VISIBLE  TRUE
    118 
    119 #define JUSTFIND   0
    120 #define REPLACING  1
    121 #define INREGION   2
    122 
    123 #define NORMAL  TRUE
    124 #define SPECIAL  FALSE
    125 #define TEMPORARY  FALSE
    126 
    127 #define ANNOTATE  TRUE
    128 #define NONOTES  FALSE
    129 
    130 #define PRUNE_DUPLICATE  TRUE
    131 #define IGNORE_DUPLICATES  FALSE
    132 
    133 #ifdef ENABLE_UTF8
    134 /* In UTF-8 a valid character is at most four bytes long. */
    135 #define MAXCHARLEN  4
    136 #else
    137 #define MAXCHARLEN  1
    138 #endif
    139 
    140 /* The default width of a tab in spaces. */
    141 #define WIDTH_OF_TAB  8
    142 
    143 /* The default number of columns from end of line where wrapping occurs. */
    144 #define COLUMNS_FROM_EOL  8
    145 
    146 /* The default comment character when a syntax does not specify any. */
    147 #define GENERAL_COMMENT_CHARACTER  "#"
    148 
    149 /* The maximum number of search/replace history strings saved. */
    150 #define MAX_SEARCH_HISTORY  100
    151 
    152 /* The largest size_t number that doesn't have the high bit set. */
    153 #define HIGHEST_POSITIVE  ((~(size_t)0) >> 1)
    154 
    155 #ifdef ENABLE_COLOR
    156 #define THE_DEFAULT  -1
    157 #define BAD_COLOR  -2
    158 
    159 /* Flags for indicating how a multiline regex pair apply to a line. */
    160 #define NOTHING      (1<<1)
    161 		/* The start/end regexes don't cover this line at all. */
    162 #define STARTSHERE   (1<<2)
    163 		/* The start regex matches on this line, the end regex on a later one. */
    164 #define WHOLELINE    (1<<3)
    165 		/* The start regex matches on an earlier line, the end regex on a later one. */
    166 #define ENDSHERE     (1<<4)
    167 		/* The start regex matches on an earlier line, the end regex on this one. */
    168 #define JUSTONTHIS   (1<<5)
    169 		/* Both the start and end regexes match within this line. */
    170 #endif
    171 
    172 /* Basic control codes. */
    173 #define ESC_CODE  0x1B
    174 #define DEL_CODE  0x7F
    175 
    176 /* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
    177 #define CONTROL_LEFT    0x401
    178 #define CONTROL_RIGHT   0x402
    179 #define CONTROL_UP      0x403
    180 #define CONTROL_DOWN    0x404
    181 #define CONTROL_HOME    0x405
    182 #define CONTROL_END     0x406
    183 #define CONTROL_DELETE  0x40D
    184 #define SHIFT_CONTROL_LEFT    0x411
    185 #define SHIFT_CONTROL_RIGHT   0x412
    186 #define SHIFT_CONTROL_UP      0x413
    187 #define SHIFT_CONTROL_DOWN    0x414
    188 #define SHIFT_CONTROL_HOME    0x415
    189 #define SHIFT_CONTROL_END     0x416
    190 #define CONTROL_SHIFT_DELETE  0x41D
    191 #define ALT_LEFT      0x421
    192 #define ALT_RIGHT     0x422
    193 #define ALT_UP        0x423
    194 #define ALT_DOWN      0x424
    195 #define ALT_HOME      0x425
    196 #define ALT_END       0x426
    197 #define ALT_PAGEUP    0x427
    198 #define ALT_PAGEDOWN  0x428
    199 #define ALT_INSERT    0x42C
    200 #define ALT_DELETE    0x42D
    201 #define SHIFT_ALT_LEFT   0x431
    202 #define SHIFT_ALT_RIGHT  0x432
    203 #define SHIFT_ALT_UP     0x433
    204 #define SHIFT_ALT_DOWN   0x434
    205 #define SHIFT_UP        0x453
    206 #define SHIFT_DOWN      0x454
    207 #define SHIFT_HOME      0x455
    208 #define SHIFT_END       0x456
    209 #define SHIFT_PAGEUP    0x457
    210 #define SHIFT_PAGEDOWN  0x458
    211 #define SHIFT_DELETE    0x45D
    212 #define SHIFT_TAB       0x45F
    213 
    214 #define FOCUS_IN   0x491
    215 #define FOCUS_OUT  0x499
    216 
    217 /* Custom keycodes for signaling the start and end of a bracketed paste. */
    218 #define START_OF_PASTE  0x4B5
    219 #define END_OF_PASTE    0x4BE
    220 
    221 /* Special keycodes for when a string bind has been partially implanted
    222  * or has an unpaired opening brace, or when a function in a string bind
    223  * needs execution or a specified function name is invalid. */
    224 #define MORE_PLANTS        0x4EA
    225 #define MISSING_BRACE      0x4EB
    226 #define PLANTED_A_COMMAND  0x4EC
    227 #define NO_SUCH_FUNCTION   0x4EF
    228 
    229 #ifndef NANO_TINY
    230 /* A special keycode for Ctrl + the central key on the numeric keypad. */
    231 #define KEY_CENTER  0x4F0
    232 
    233 /* A special keycode for when we get a SIGWINCH (a window resize). */
    234 #define THE_WINDOW_RESIZED  0x4F7
    235 #endif
    236 
    237 /* A special keycode for when a key produces an unknown escape sequence. */
    238 #define FOREIGN_SEQUENCE  0x4FC
    239 
    240 /* A special keycode for plugging into the input stream after a suspension. */
    241 #define KEY_FRESH  0x4FE
    242 
    243 #ifndef NANO_TINY
    244 /* Some extra flags for the undo function. */
    245 #define WAS_BACKSPACE_AT_EOF  (1<<1)
    246 #define WAS_WHOLE_LINE        (1<<2)
    247 #define INCLUDED_LAST_LINE    (1<<3)
    248 #define MARK_WAS_SET          (1<<4)
    249 #define CURSOR_WAS_AT_HEAD    (1<<5)
    250 #define HAD_ANCHOR_AT_START   (1<<6)
    251 #endif /* !NANO_TINY */
    252 
    253 /* Identifiers for the different menus. */
    254 #define MMAIN          (1<<0)
    255 #define MWHEREIS       (1<<1)
    256 #define MREPLACE       (1<<2)
    257 #define MREPLACEWITH   (1<<3)
    258 #define MGOTOLINE      (1<<4)
    259 #define MWRITEFILE     (1<<5)
    260 #define MINSERTFILE    (1<<6)
    261 #define MEXECUTE       (1<<7)
    262 #define MHELP          (1<<8)
    263 #define MSPELL         (1<<9)
    264 #define MBROWSER      (1<<10)
    265 #define MWHEREISFILE  (1<<11)
    266 #define MGOTODIR      (1<<12)
    267 #define MYESNO        (1<<13)
    268 #define MLINTER       (1<<14)
    269 #define MFINDINHELP   (1<<15)
    270 /* This is an abbreviation for all menus except Help and Browser and YesNo. */
    271 #define MMOST  (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
    272                 MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
    273 #ifndef NANO_TINY
    274 #define MSOME  MMOST|MBROWSER
    275 #else
    276 #define MSOME  MMAIN|MBROWSER
    277 #endif
    278 
    279 /* Enumeration types. */
    280 typedef enum {
    281 	UNSPECIFIED, NIX_FILE, DOS_FILE, MAC_FILE
    282 } format_type;
    283 
    284 typedef enum {
    285 	VACUUM, HUSH, REMARK, INFO, NOTICE, AHEM, MILD, ALERT
    286 } message_type;
    287 
    288 typedef enum {
    289 	OVERWRITE, APPEND, PREPEND, EMERGENCY
    290 } kind_of_writing_type;
    291 
    292 typedef enum {
    293 	CENTERING, FLOWING, STATIONARY
    294 } update_type;
    295 
    296 /* The kinds of undo actions.  ADD...REPLACE must come first. */
    297 typedef enum {
    298 	ADD, ENTER, BACK, DEL, JOIN, REPLACE,
    299 #ifdef ENABLE_WRAPPING
    300 	SPLIT_BEGIN, SPLIT_END,
    301 #endif
    302 	INDENT, UNINDENT,
    303 #ifdef ENABLE_COMMENT
    304 	COMMENT, UNCOMMENT, PREFLIGHT,
    305 #endif
    306 	ZAP, CUT, CUT_TO_EOF, COPY, PASTE, INSERT,
    307 	COUPLE_BEGIN, COUPLE_END, OTHER
    308 } undo_type;
    309 
    310 /* The elements of the interface that can be colored differently. */
    311 enum {
    312 	TITLE_BAR = 0,
    313 	LINE_NUMBER,
    314 	GUIDE_STRIPE,
    315 	SCROLL_BAR,
    316 	SELECTED_TEXT,
    317 	SPOTLIGHTED,
    318 	MINI_INFOBAR,
    319 	PROMPT_BAR,
    320 	STATUS_BAR,
    321 	ERROR_MESSAGE,
    322 	KEY_COMBO,
    323 	FUNCTION_TAG,
    324 	NUMBER_OF_ELEMENTS
    325 };
    326 
    327 /* Enumeration used in the flags array.  See the definition of FLAGMASK. */
    328 enum {
    329 	DONTUSE = 0,
    330 	CASE_SENSITIVE,
    331 	CONSTANT_SHOW,
    332 	NO_HELP,
    333 	NO_WRAP,
    334 	AUTOINDENT,
    335 	VIEW_MODE,
    336 	USE_MOUSE,
    337 	USE_REGEXP,
    338 	SAVE_ON_EXIT,
    339 	CUT_FROM_CURSOR,
    340 	BACKWARDS_SEARCH,
    341 	MULTIBUFFER,
    342 	REBIND_DELETE,
    343 	RAW_SEQUENCES,
    344 	NO_CONVERT,
    345 	MAKE_BACKUP,
    346 	INSECURE_BACKUP,
    347 	NO_SYNTAX,
    348 	PRESERVE,
    349 	HISTORYLOG,
    350 	RESTRICTED,
    351 	SMART_HOME,
    352 	WHITESPACE_DISPLAY,
    353 	TABS_TO_SPACES,
    354 	QUICK_BLANK,
    355 	WORD_BOUNDS,
    356 	NO_NEWLINES,
    357 	BOLD_TEXT,
    358 	SOFTWRAP,
    359 	POSITIONLOG,
    360 	LOCKING,
    361 	NOREAD_MODE,
    362 	MAKE_IT_UNIX,
    363 	TRIM_BLANKS,
    364 	SHOW_CURSOR,
    365 	LINE_NUMBERS,
    366 	AT_BLANKS,
    367 	AFTER_ENDS,
    368 	LET_THEM_ZAP,
    369 	BREAK_LONG_LINES,
    370 	JUMPY_SCROLLING,
    371 	EMPTY_LINE,
    372 	INDICATOR,
    373 	BOOKSTYLE,
    374 	COLON_PARSING,
    375 	STATEFLAGS,
    376 	USE_MAGIC,
    377 	MINIBAR,
    378 	ZERO,
    379 	MODERN_BINDINGS
    380 };
    381 
    382 /* Structure types. */
    383 #ifdef ENABLE_COLOR
    384 typedef struct colortype {
    385 	short id;
    386 		/* An ordinal number (if this color combo is for a multiline regex). */
    387 	short fg;
    388 		/* This combo's foreground color. */
    389 	short bg;
    390 		/* This combo's background color. */
    391 	short pairnum;
    392 		/* The pair number for this foreground/background color combination. */
    393 	int attributes;
    394 		/* Pair number and brightness composed into ready-to-use attributes. */
    395 	regex_t *start;
    396 		/* The compiled regular expression for 'start=', or the only one. */
    397 	regex_t *end;
    398 		/* The compiled regular expression for 'end=', if any. */
    399 	struct colortype *next;
    400 		/* Next color combination. */
    401 } colortype;
    402 
    403 typedef struct regexlisttype {
    404 	regex_t *one_rgx;
    405 		/* A regex to match things that imply a certain syntax. */
    406 	struct regexlisttype *next;
    407 		/* The next regex. */
    408 } regexlisttype;
    409 
    410 typedef struct augmentstruct {
    411 	char *filename;
    412 		/* The file where the syntax is extended. */
    413 	ssize_t lineno;
    414 		/* The number of the line of the extendsyntax command. */
    415 	char *data;
    416 		/* The text of the line. */
    417 	struct augmentstruct *next;
    418 		/* Next node. */
    419 } augmentstruct;
    420 
    421 typedef struct syntaxtype {
    422 	char *name;
    423 		/* The name of this syntax. */
    424 	char *filename;
    425 		/* File where the syntax is defined, or NULL if not an included file. */
    426 	size_t lineno;
    427 		/* The line number where the 'syntax' command was found. */
    428 	augmentstruct *augmentations;
    429 		/* List of extendsyntax commands to apply when loaded. */
    430 	regexlisttype *extensions;
    431 		/* The list of extensions that this syntax applies to. */
    432 	regexlisttype *headers;
    433 		/* The list of headerlines that this syntax applies to. */
    434 	regexlisttype *magics;
    435 		/* The list of libmagic results that this syntax applies to. */
    436 	char *linter;
    437 		/* The command with which to lint this type of file. */
    438 	char *formatter;
    439 		/* The command with which to format/modify/arrange this type of file. */
    440 	char *tabstring;
    441 		/* What the Tab key should produce; NULL for default behavior. */
    442 #ifdef ENABLE_COMMENT
    443 	char *comment;
    444 		/* The line comment prefix (and postfix) for this type of file. */
    445 #endif
    446 	colortype *color;
    447 		/* The colors and their regexes used in this syntax. */
    448 	short multiscore;
    449 		/* How many multiline regex strings this syntax has. */
    450 	struct syntaxtype *next;
    451 		/* Next syntax. */
    452 } syntaxtype;
    453 
    454 typedef struct lintstruct {
    455 	ssize_t lineno;
    456 		/* Line number of the error. */
    457 	ssize_t colno;
    458 		/* Column # of the error. */
    459 	char *msg;
    460 		/* Error message text. */
    461 	char *filename;
    462 		/* Filename. */
    463 	struct lintstruct *next;
    464 		/* Next error. */
    465 	struct lintstruct *prev;
    466 		/* Previous error. */
    467 } lintstruct;
    468 #endif /* ENABLE_COLOR */
    469 
    470 /* More structure types. */
    471 typedef struct linestruct {
    472 	char *data;
    473 		/* The text of this line. */
    474 	ssize_t lineno;
    475 		/* The number of this line. */
    476 	struct linestruct *next;
    477 		/* Next node. */
    478 	struct linestruct *prev;
    479 		/* Previous node. */
    480 #ifdef ENABLE_COLOR
    481 	short *multidata;
    482 		/* Array of which multi-line regexes apply to this line. */
    483 #endif
    484 #ifndef NANO_TINY
    485 	bool has_anchor;
    486 		/* Whether the user has placed an anchor at this line. */
    487 #endif
    488 } linestruct;
    489 
    490 #ifndef NANO_TINY
    491 typedef struct groupstruct {
    492 	ssize_t top_line;
    493 		/* First line of group. */
    494 	ssize_t bottom_line;
    495 		/* Last line of group. */
    496 	char **indentations;
    497 		/* String data used to restore the affected lines; one per line. */
    498 	struct groupstruct *next;
    499 		/* The next group, if any. */
    500 } groupstruct;
    501 
    502 typedef struct undostruct {
    503 	undo_type type;
    504 		/* The operation type that this undo item is for. */
    505 	int xflags;
    506 		/* Some flag data to mark certain corner cases. */
    507 	ssize_t head_lineno;
    508 		/* The line number where the operation began or ended. */
    509 	size_t head_x;
    510 		/* The x position where the operation began or ended. */
    511 	char *strdata;
    512 		/* String data to help restore the affected line. */
    513 	size_t wassize;
    514 		/* The file size before the action. */
    515 	size_t newsize;
    516 		/* The file size after the action. */
    517 	groupstruct *grouping;
    518 		/* Undo info specific to groups of lines. */
    519 	linestruct *cutbuffer;
    520 		/* A copy of the cutbuffer. */
    521 	ssize_t tail_lineno;
    522 		/* Mostly the line number of the current line; sometimes something else. */
    523 	size_t tail_x;
    524 		/* The x position corresponding to the above line number. */
    525 	struct undostruct *next;
    526 		/* A pointer to the undo item of the preceding action. */
    527 } undostruct;
    528 #endif /* !NANO_TINY */
    529 
    530 #ifdef ENABLE_HISTORIES
    531 typedef struct poshiststruct {
    532 	char *filename;
    533 		/* The full path plus name of the file. */
    534 	ssize_t linenumber;
    535 		/* The line where the cursor was when we closed the file. */
    536 	ssize_t columnnumber;
    537 		/* The column where the cursor was. */
    538 	char *anchors;
    539 		/* The line numbers where anchors were placed, in string form. */
    540 	struct poshiststruct *next;
    541 		/* The next item of position history. */
    542 } poshiststruct;
    543 #endif
    544 
    545 typedef struct openfilestruct {
    546 	char *filename;
    547 		/* The file's name. */
    548 	linestruct *filetop;
    549 		/* The file's first line. */
    550 	linestruct *filebot;
    551 		/* The file's last line. */
    552 	linestruct *edittop;
    553 		/* The current top of the edit window for this file. */
    554 	linestruct *current;
    555 		/* The current line for this file. */
    556 	size_t totsize;
    557 		/* The file's total number of characters. */
    558 	size_t firstcolumn;
    559 		/* The starting column of the top line of the edit window.
    560 		 * When not in softwrap mode, it's always zero. */
    561 	size_t current_x;
    562 		/* The file's x-coordinate position. */
    563 	size_t placewewant;
    564 		/* The file's x position we would like. */
    565 	ssize_t cursor_row;
    566 		/* The row in the edit window that the cursor is on. */
    567 	struct stat *statinfo;
    568 		/* The file's stat information from when it was opened or last saved. */
    569 #ifdef ENABLE_WRAPPING
    570 	linestruct *spillage_line;
    571 		/* The line for prepending stuff to during automatic hard-wrapping. */
    572 #endif
    573 #ifndef NANO_TINY
    574 	linestruct *mark;
    575 		/* The line in the file where the mark is set; NULL if not set. */
    576 	size_t mark_x;
    577 		/* The mark's x position in the above line. */
    578 	bool softmark;
    579 		/* Whether a marked region was made by holding Shift. */
    580 	format_type fmt;
    581 		/* The file's format -- Unix or DOS or Mac. */
    582 	char *lock_filename;
    583 		/* The path of the lockfile, if we created one. */
    584 	undostruct *undotop;
    585 		/* The top of the undo list. */
    586 	undostruct *current_undo;
    587 		/* The current (i.e. next) level of undo. */
    588 	undostruct *last_saved;
    589 		/* The undo item at which the file was last saved. */
    590 	undo_type last_action;
    591 		/* The type of the last action the user performed. */
    592 #endif
    593 	bool modified;
    594 		/* Whether the file has been modified. */
    595 #ifdef ENABLE_COLOR
    596 	syntaxtype *syntax;
    597 		/* The syntax that applies to this file, if any. */
    598 #endif
    599 #ifdef ENABLE_MULTIBUFFER
    600 	char *errormessage;
    601 		/* The ALERT message (if any) that occurred when opening the file. */
    602 	struct openfilestruct *next;
    603 		/* The next open file, if any. */
    604 	struct openfilestruct *prev;
    605 		/* The preceding open file, if any. */
    606 #endif
    607 } openfilestruct;
    608 
    609 #ifdef ENABLE_NANORC
    610 typedef struct rcoption {
    611 	const char *name;
    612 		/* The name of the rcfile option. */
    613 	long flag;
    614 		/* The flag associated with it, if any. */
    615 } rcoption;
    616 #endif
    617 
    618 typedef struct keystruct {
    619 	const char *keystr;
    620 		/* The string that describes the keystroke, like "^C" or "M-R". */
    621 	int keycode;
    622 		/* The integer that, together with meta, identifies the keystroke. */
    623 	int menus;
    624 		/* The menus in which this keystroke is bound. */
    625 	void (*func)(void);
    626 		/* The function to which this keystroke is bound. */
    627 #ifndef NANO_TINY
    628 	int toggle;
    629 		/* If a toggle, what we're toggling. */
    630 	int ordinal;
    631 		/* The how-manieth toggle this is, in order to be able to
    632 		 * keep them in sequence. */
    633 #endif
    634 #ifdef ENABLE_NANORC
    635 	char *expansion;
    636 		/* The string of keycodes to which this shortcut is expanded. */
    637 #endif
    638 	struct keystruct *next;
    639 		/* Next in the list. */
    640 } keystruct;
    641 
    642 typedef struct funcstruct {
    643 	void (*func)(void);
    644 		/* The actual function to call. */
    645 	const char *tag;
    646 		/* The function's help-line label, for example "Where Is". */
    647 #ifdef ENABLE_HELP
    648 	const char *phrase;
    649 		/* The function's description for in the help viewer. */
    650 	bool blank_after;
    651 		/* Whether to distance this function from the next in the help viewer. */
    652 #endif
    653 	int menus;
    654 		/* In what menus this function applies. */
    655 	struct funcstruct *next;
    656 		/* Next item in the list. */
    657 } funcstruct;
    658 
    659 #ifdef ENABLE_WORDCOMPLETION
    660 typedef struct completionstruct {
    661 	char *word;
    662 	struct completionstruct *next;
    663 } completionstruct;
    664 #endif