nano

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

commit 90f6342fd131401c05cee3c6d9fce652b9cf42ec
parent 84b187f6276859c11a7236839b41c76b5e3a11ea
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sat, 20 Jun 2020 12:09:31 +0200

tweaks: rename two header files, to be distinct and not an abbreviation

Diffstat:
Msrc/browser.c | 2+-
Msrc/chars.c | 2+-
Msrc/color.c | 2+-
Msrc/cut.c | 2+-
Asrc/definitions.h | 661+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/files.c | 2+-
Msrc/global.c | 2+-
Msrc/help.c | 2+-
Msrc/history.c | 2+-
Msrc/move.c | 2+-
Msrc/nano.c | 2+-
Dsrc/nano.h | 661-------------------------------------------------------------------------------
Msrc/prompt.c | 2+-
Dsrc/proto.h | 679-------------------------------------------------------------------------------
Asrc/prototypes.h | 679+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/rcfile.c | 2+-
Msrc/search.c | 2+-
Msrc/text.c | 2+-
Msrc/utils.c | 2+-
Msrc/winio.c | 2+-
20 files changed, 1356 insertions(+), 1356 deletions(-)

diff --git a/src/browser.c b/src/browser.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #ifdef ENABLE_BROWSER diff --git a/src/chars.c b/src/chars.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #include <ctype.h> #include <string.h> diff --git a/src/color.c b/src/color.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #ifdef ENABLE_COLOR diff --git a/src/cut.c b/src/cut.c @@ -20,7 +20,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #include <string.h> diff --git a/src/definitions.h b/src/definitions.h @@ -0,0 +1,661 @@ +/************************************************************************** + * definitions.h -- This file is part of GNU nano. * + * * + * Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. * + * Copyright (C) 2014-2017 Benno Schulenberg * + * * + * GNU nano is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published * + * by the Free Software Foundation, either version 3 of the License, * + * or (at your option) any later version. * + * * + * GNU nano is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty * + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see http://www.gnu.org/licenses/. * + * * + **************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef NEED_XOPEN_SOURCE_EXTENDED +#ifndef _XOPEN_SOURCE_EXTENDED +#define _XOPEN_SOURCE_EXTENDED 1 +#endif +#endif + +#ifdef __TANDEM +/* Tandem NonStop Kernel support. */ +#include <floss.h> +#define ROOT_UID 65535 +#else +#define ROOT_UID 0 +#endif + +#ifdef HAVE_LIMITS_H +#include <limits.h> +#endif + +#ifdef HAVE_SYS_PARAM_H +#include <sys/param.h> +#endif + +/* Suppress warnings for __attribute__((warn_unused_result)). */ +#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0) + +/* Macros for flags, indexing each bit in a small array. */ +#define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))] +#define FLAGMASK(flag) ((unsigned)1 << ((flag) % (sizeof(unsigned) * 8))) +#define SET(flag) FLAGS(flag) |= FLAGMASK(flag) +#define UNSET(flag) FLAGS(flag) &= ~FLAGMASK(flag) +#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0) +#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag) + +/* Macros for allocation of character strings. */ +#define charalloc(howmuch) (char *)nmalloc(howmuch) +#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, howmuch) + +/* In UTF-8 a character is at most six bytes long. */ +#ifdef ENABLE_UTF8 +#define MAXCHARLEN 6 +#else +#define MAXCHARLEN 1 +#endif + +/* Set a default value for PATH_MAX if there isn't one. */ +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + +#ifdef USE_SLANG +/* Slang support. */ +#include <slcurses.h> +/* Slang curses emulation brain damage, part 3: Slang doesn't define the + * curses equivalents of the Insert or Delete keys. */ +#define KEY_DC SL_KEY_DELETE +#define KEY_IC SL_KEY_IC +/* Ncurses support. */ +#elif defined(HAVE_NCURSESW_NCURSES_H) +#include <ncursesw/ncurses.h> +#elif defined(HAVE_NCURSES_H) +#include <ncurses.h> +#else +/* Curses support. */ +#include <curses.h> +#endif /* CURSES_H */ + +#if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR < 6) +#define USING_OLD_NCURSES yes +#endif + +#ifdef ENABLE_NLS +/* Native language support. */ +#ifdef HAVE_LIBINTL_H +#include <libintl.h> +#endif +#define _(string) gettext(string) +#define P_(singular, plural, number) ngettext(singular, plural, number) +#else +#define _(string) (string) +#define P_(singular, plural, number) (number == 1 ? singular : plural) +#endif +#define gettext_noop(string) (string) +#define N_(string) gettext_noop(string) + /* Mark a string that will be sent to gettext() later. */ + +#include <dirent.h> +#include <regex.h> +#include <signal.h> +#include <stdlib.h> +#include <sys/stat.h> + +/* If we aren't using an ncurses with mouse support, exclude any + * mouse routines, as they are useless then. */ +#ifndef NCURSES_MOUSE_VERSION +#undef ENABLE_MOUSE +#endif + +#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY) +#define ENABLED_WRAPORJUSTIFY 1 +#endif + +#define BACKWARD FALSE +#define FORWARD TRUE + +#define BLIND FALSE +#define VISIBLE TRUE + +#define JUSTFIND 0 +#define REPLACING 1 +#define INREGION 2 + +#ifdef ENABLE_COLOR +#define THE_DEFAULT -1 +#define BAD_COLOR -2 +#endif + +#define STANDARD_INPUT 0 + +/* Enumeration types. */ +typedef enum { + NIX_FILE, DOS_FILE, MAC_FILE +} format_type; + +typedef enum { + VACUUM, HUSH, NOTICE, MILD, ALERT +} message_type; + +typedef enum { + OVERWRITE, APPEND, PREPEND +} kind_of_writing_type; + +typedef enum { + SOFTMARK, HARDMARK +} mark_type; + +typedef enum { + CENTERING, FLOWING, STATIONARY +} update_type; + +/* The kinds of undo actions. ADD...REPLACE must come first. */ +typedef enum { + ADD, ENTER, BACK, DEL, JOIN, REPLACE, +#ifdef ENABLE_WRAPPING + SPLIT_BEGIN, SPLIT_END, +#endif + INDENT, UNINDENT, +#ifdef ENABLE_COMMENT + COMMENT, UNCOMMENT, PREFLIGHT, +#endif + ZAP, CUT, CUT_TO_EOF, COPY, PASTE, INSERT, + COUPLE_BEGIN, COUPLE_END, OTHER +} undo_type; + +/* Structure types. */ +#ifdef ENABLE_COLOR +typedef struct colortype { + short id; + /* An ordinal number (if this color combo is for a multiline regex). */ + short fg; + /* This combo's foreground color. */ + short bg; + /* This combo's background color. */ + short pairnum; + /* The pair number for this foreground/background color combination. */ + int attributes; + /* Pair number and brightness composed into ready-to-use attributes. */ + regex_t *start; + /* The compiled regular expression for 'start=', or the only one. */ + regex_t *end; + /* The compiled regular expression for 'end=', if any. */ + struct colortype *next; + /* Next color combination. */ +} colortype; + +typedef struct regexlisttype { + char *full_regex; + /* A regex string to match things that imply a certain syntax. */ + struct regexlisttype *next; + /* The next regex. */ +} regexlisttype; + +typedef struct augmentstruct { + char *filename; + /* The file where the syntax is extended. */ + ssize_t lineno; + /* The number of the line of the extendsyntax command. */ + char *data; + /* The text of the line. */ + struct augmentstruct *next; + /* Next node. */ +} augmentstruct; + +typedef struct syntaxtype { + char *name; + /* The name of this syntax. */ + char *filename; + /* File where the syntax is defined, or NULL if not an included file. */ + size_t lineno; + /* The line number where the 'syntax' command was found. */ + struct augmentstruct *augmentations; + /* List of extendsyntax commands to apply when loaded. */ + regexlisttype *extensions; + /* The list of extensions that this syntax applies to. */ + regexlisttype *headers; + /* The list of headerlines that this syntax applies to. */ + regexlisttype *magics; + /* The list of libmagic results that this syntax applies to. */ + char *linter; + /* The command with which to lint this type of file. */ + char *formatter; + /* The command with which to format/modify/arrange this type of file. */ + char *tab; + /* What the Tab key should produce; NULL for default behavior. */ +#ifdef ENABLE_COMMENT + char *comment; + /* The line comment prefix (and postfix) for this type of file. */ +#endif + colortype *color; + /* The colors and their regexes used in this syntax. */ + short nmultis; + /* How many multiline regex strings this syntax has. */ + struct syntaxtype *next; + /* Next syntax. */ +} syntaxtype; + +typedef struct lintstruct { + ssize_t lineno; + /* Line number of the error. */ + ssize_t colno; + /* Column # of the error. */ + char *msg; + /* Error message text. */ + char *filename; + /* Filename. */ + struct lintstruct *next; + /* Next error. */ + struct lintstruct *prev; + /* Previous error. */ +} lintstruct; + +/* Flags that indicate how a multiline regex applies to a line. */ +#define CNONE (1<<1) + /* Yay, regex doesn't apply to this line at all! */ +#define CBEGINBEFORE (1<<2) + /* Regex starts on an earlier line, ends on this one. */ +#define CENDAFTER (1<<3) + /* Regex starts on this line and ends on a later one. */ +#define CWHOLELINE (1<<4) + /* Whole line engulfed by the regex, start < me, end > me. */ +#define CSTARTENDHERE (1<<5) + /* Regex starts and ends within this line. */ +#define CWOULDBE (1<<6) + /* An unpaired start match on or before this line. */ +#endif /* ENABLE_COLOR */ + +/* More structure types. */ +typedef struct linestruct { + char *data; + /* The text of this line. */ + ssize_t lineno; + /* The number of this line. */ +#ifndef NANO_TINY + ssize_t extrarows; + /* The extra rows that this line occupies when softwrapping. */ +#endif + struct linestruct *next; + /* Next node. */ + struct linestruct *prev; + /* Previous node. */ +#ifdef ENABLE_COLOR + short *multidata; + /* Array of which multi-line regexes apply to this line. */ +#endif +#ifndef NANO_TINY + bool has_anchor; + /* Whether the user has placed an anchor at this line. */ +#endif +} linestruct; + +#ifndef NANO_TINY +typedef struct groupstruct { + ssize_t top_line; + /* First line of group. */ + ssize_t bottom_line; + /* Last line of group. */ + char **indentations; + /* String data used to restore the affected lines; one per line. */ + struct groupstruct *next; + /* The next group, if any. */ +} groupstruct; + +typedef struct undostruct { + undo_type type; + /* The operation type that this undo item is for. */ + int xflags; + /* Some flag data to mark certain corner cases. */ + ssize_t head_lineno; + /* The line number where the operation began or ended. */ + size_t head_x; + /* The x position where the operation began or ended. */ + char *strdata; + /* String data to help restore the affected line. */ + size_t wassize; + /* The file size before the action. */ + size_t newsize; + /* The file size after the action. */ + groupstruct *grouping; + /* Undo info specific to groups of lines. */ + linestruct *cutbuffer; + /* A copy of the cutbuffer. */ + ssize_t tail_lineno; + /* Mostly the line number of the current line; sometimes something else. */ + size_t tail_x; + /* The x position corresponding to the above line number. */ + struct undostruct *next; + /* A pointer to the undo item of the preceding action. */ +} undostruct; +#endif /* !NANO_TINY */ + +#ifdef ENABLE_HISTORIES +typedef struct poshiststruct { + char *filename; + /* The file. */ + ssize_t lineno; + /* Line number we left off on. */ + ssize_t xno; + /* The x position in the file we left off on. */ + struct poshiststruct *next; + /* The next item of position history. */ +} poshiststruct; +#endif + +typedef struct openfilestruct { + char *filename; + /* The file's name. */ + linestruct *filetop; + /* The file's first line. */ + linestruct *filebot; + /* The file's last line. */ + linestruct *edittop; + /* The current top of the edit window for this file. */ + linestruct *current; + /* The current line for this file. */ + size_t totsize; + /* The file's total number of characters. */ + size_t firstcolumn; + /* The starting column of the top line of the edit window. + * When not in softwrap mode, it's always zero. */ + size_t current_x; + /* The file's x-coordinate position. */ + size_t placewewant; + /* The file's x position we would like. */ + ssize_t current_y; + /* The file's y-coordinate position. */ + struct stat *statinfo; + /* The file's stat information from when it was opened or last saved. */ +#ifdef ENABLE_WRAPPING + linestruct *spillage_line; + /* The line for prepending stuff to during automatic hard-wrapping. */ +#endif +#ifndef NANO_TINY + linestruct *mark; + /* The line in the file where the mark is set; NULL if not set. */ + size_t mark_x; + /* The mark's x position in the above line. */ + mark_type kind_of_mark; + /* Whether it is a soft (with Shift) or a hard mark. */ + format_type fmt; + /* The file's format -- Unix or DOS or Mac. */ + char *lock_filename; + /* The path of the lockfile, if we created one. */ + undostruct *undotop; + /* The top of the undo list. */ + undostruct *current_undo; + /* The current (i.e. next) level of undo. */ + undostruct *last_saved; + /* The undo item at which the file was last saved. */ + undo_type last_action; + /* The type of the last action the user performed. */ +#endif + bool modified; + /* Whether the file has been modified. */ +#ifdef ENABLE_COLOR + syntaxtype *syntax; + /* The syntax that applies to this file, if any. */ +#endif +#ifdef ENABLE_MULTIBUFFER + struct openfilestruct *next; + /* The next open file, if any. */ + struct openfilestruct *prev; + /* The preceding open file, if any. */ +#endif +} openfilestruct; + +#ifdef ENABLE_NANORC +typedef struct rcoption { + const char *name; + /* The name of the rcfile option. */ + long flag; + /* The flag associated with it, if any. */ +} rcoption; +#endif + +typedef struct keystruct { + const char *keystr; + /* The string that describes the keystroke, like "^C" or "M-R". */ + int keycode; + /* The integer that, together with meta, identifies the keystroke. */ + int menus; + /* The menus in which this keystroke is bound. */ + void (*func)(void); + /* The function to which this keystroke is bound. */ +#ifndef NANO_TINY + int toggle; + /* If a toggle, what we're toggling. */ + int ordinal; + /* The how-manieth toggle this is, in order to be able to + * keep them in sequence. */ +#endif +#ifdef ENABLE_NANORC + char *expansion; + /* The string of keycodes to which this shortcut is expanded. */ +#endif + struct keystruct *next; + /* Next in the list. */ +} keystruct; + +typedef struct funcstruct { + void (*func)(void); + /* The actual function to call. */ + int menus; + /* In what menus this function applies. */ + const char *desc; + /* The function's short description, for example "Where Is". */ +#ifdef ENABLE_HELP + const char *help; + /* The help-screen text for this function. */ + bool blank_after; + /* Whether there should be a blank line after the help text + * for this function. */ +#endif + bool viewok; + /* Is this function allowed when in view mode? */ + long toggle; + /* If this is a toggle, which toggle to affect. */ + struct funcstruct *next; + /* Next item in the list. */ +} funcstruct; + +#ifdef ENABLE_WORDCOMPLETION +typedef struct completion_word { + char *word; + struct completion_word *next; +} completion_word; +#endif + +/* The elements of the interface that can be colored differently. */ +enum +{ + TITLE_BAR = 0, + LINE_NUMBER, + GUIDE_STRIPE, + SELECTED_TEXT, + STATUS_BAR, + ERROR_MESSAGE, + KEY_COMBO, + FUNCTION_TAG, + NUMBER_OF_ELEMENTS +}; + +/* Enumeration used in the flags array. See the definition of FLAGMASK. */ +enum +{ + DONTUSE, + CASE_SENSITIVE, + CONSTANT_SHOW, + NO_HELP, + SUSPENDABLE, + NO_WRAP, + AUTOINDENT, + VIEW_MODE, + USE_MOUSE, + USE_REGEXP, + SAVE_ON_EXIT, + CUT_FROM_CURSOR, + BACKWARDS_SEARCH, + MULTIBUFFER, + SMOOTH_SCROLL, + REBIND_DELETE, + RAW_SEQUENCES, + NO_CONVERT, + MAKE_BACKUP, + INSECURE_BACKUP, + NO_SYNTAX, + PRESERVE, + HISTORYLOG, + RESTRICTED, + SMART_HOME, + WHITESPACE_DISPLAY, + MORE_SPACE, + TABS_TO_SPACES, + QUICK_BLANK, + WORD_BOUNDS, + NO_NEWLINES, + BOLD_TEXT, + SOFTWRAP, + POSITIONLOG, + LOCKING, + NOREAD_MODE, + MAKE_IT_UNIX, + TRIM_BLANKS, + SHOW_CURSOR, + LINE_NUMBERS, + NO_PAUSES, + AT_BLANKS, + AFTER_ENDS, + LET_THEM_ZAP, + BREAK_LONG_LINES, + JUMPY_SCROLLING, + EMPTY_LINE, + INDICATOR +}; + +/* Flags for the menus in which a given function should be present. */ +#define MMAIN (1<<0) +#define MWHEREIS (1<<1) +#define MREPLACE (1<<2) +#define MREPLACEWITH (1<<3) +#define MGOTOLINE (1<<4) +#define MWRITEFILE (1<<5) +#define MINSERTFILE (1<<6) +#define MEXECUTE (1<<7) +#define MHELP (1<<8) +#define MSPELL (1<<9) +#define MBROWSER (1<<10) +#define MWHEREISFILE (1<<11) +#define MGOTODIR (1<<12) +#define MYESNO (1<<13) +#define MLINTER (1<<14) +#define MFINDINHELP (1<<15) +/* This is an abbreviation for all menus except Help and Browser and YesNo. */ +#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\ + MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER) +#ifndef NANO_TINY +#define MSOME MMOST|MBROWSER +#else +#define MSOME MMAIN|MBROWSER +#endif + +/* Basic control codes. */ +#define ESC_CODE 0x1B +#define DEL_CODE 0x7F + +/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */ +#define CONTROL_LEFT 0x401 +#define CONTROL_RIGHT 0x402 +#define CONTROL_UP 0x403 +#define CONTROL_DOWN 0x404 +#define CONTROL_HOME 0x405 +#define CONTROL_END 0x406 +#define CONTROL_DELETE 0x40D +#define SHIFT_CONTROL_LEFT 0x411 +#define SHIFT_CONTROL_RIGHT 0x412 +#define SHIFT_CONTROL_UP 0x413 +#define SHIFT_CONTROL_DOWN 0x414 +#define SHIFT_CONTROL_HOME 0x415 +#define SHIFT_CONTROL_END 0x416 +#define CONTROL_SHIFT_DELETE 0x41D +#define ALT_LEFT 0x421 +#define ALT_RIGHT 0x422 +#define ALT_UP 0x423 +#define ALT_DOWN 0x424 +#define ALT_PAGEUP 0x427 +#define ALT_PAGEDOWN 0x428 +#define ALT_INSERT 0x42C +#define ALT_DELETE 0x42D +#define SHIFT_ALT_LEFT 0x431 +#define SHIFT_ALT_RIGHT 0x432 +#define SHIFT_ALT_UP 0x433 +#define SHIFT_ALT_DOWN 0x434 +//#define SHIFT_LEFT 0x451 +//#define SHIFT_RIGHT 0x452 +#define SHIFT_UP 0x453 +#define SHIFT_DOWN 0x454 +#define SHIFT_HOME 0x455 +#define SHIFT_END 0x456 +#define SHIFT_PAGEUP 0x457 +#define SHIFT_PAGEDOWN 0x458 +#define SHIFT_DELETE 0x45D +#define SHIFT_TAB 0x45F + +/* A special keycode for when <Tab> is pressed while the mark is on. */ +#define INDENT_KEY 0x4F1 + +/* A special keycode to signal the beginning and end of a bracketed paste. */ +#define BRACKETED_PASTE_MARKER 0x4FB + +/* A special keycode for when a key produces an unknown escape sequence. */ +#define FOREIGN_SEQUENCE 0x4FC + +#ifdef USE_SLANG +#ifdef ENABLE_UTF8 +#define KEY_BAD 0xFF /* Clipped error code. */ +#endif +#define KEY_FLUSH 0x91 /* User-definable control code. */ +#else +#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */ +#endif + +#ifndef NANO_TINY +/* An imaginary key for when we get a SIGWINCH (window resize). */ +#define KEY_WINCH -2 + +/* Some extra flags for the undo function. */ +#define WAS_BACKSPACE_AT_EOF (1<<1) +#define WAS_WHOLE_LINE (1<<2) +#define INCLUDED_LAST_LINE (1<<3) +#define MARK_WAS_SET (1<<4) +#define CURSOR_WAS_AT_HEAD (1<<5) +#endif /* !NANO_TINY */ + +/* The default number of columns from end of line where wrapping occurs. */ +#define COLUMNS_FROM_EOL 8 + +/* The default width of a tab in spaces. */ +#define WIDTH_OF_TAB 8 + +/* The default comment character when a syntax does not specify any. */ +#define GENERAL_COMMENT_CHARACTER "#" + +/* The maximum number of search/replace history strings saved, not + * counting the blank lines at their ends. */ +#define MAX_SEARCH_HISTORY 100 + +/* The largest size_t number that doesn't have the high bit set. */ +#define HIGHEST_POSITIVE ((~(size_t)0) >> 1) diff --git a/src/files.c b/src/files.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #include <errno.h> #include <fcntl.h> diff --git a/src/global.c b/src/global.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #include <ctype.h> #include <string.h> diff --git a/src/help.c b/src/help.c @@ -20,7 +20,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #ifdef ENABLE_HELP diff --git a/src/history.c b/src/history.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #ifdef ENABLE_HISTORIES diff --git a/src/move.c b/src/move.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #include <string.h> diff --git a/src/nano.c b/src/nano.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #include "revision.h" #include <ctype.h> diff --git a/src/nano.h b/src/nano.h @@ -1,661 +0,0 @@ -/************************************************************************** - * nano.h -- This file is part of GNU nano. * - * * - * Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. * - * Copyright (C) 2014-2017 Benno Schulenberg * - * * - * GNU nano is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published * - * by the Free Software Foundation, either version 3 of the License, * - * or (at your option) any later version. * - * * - * GNU nano is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty * - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see http://www.gnu.org/licenses/. * - * * - **************************************************************************/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#ifdef NEED_XOPEN_SOURCE_EXTENDED -#ifndef _XOPEN_SOURCE_EXTENDED -#define _XOPEN_SOURCE_EXTENDED 1 -#endif -#endif - -#ifdef __TANDEM -/* Tandem NonStop Kernel support. */ -#include <floss.h> -#define ROOT_UID 65535 -#else -#define ROOT_UID 0 -#endif - -#ifdef HAVE_LIMITS_H -#include <limits.h> -#endif - -#ifdef HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif - -/* Suppress warnings for __attribute__((warn_unused_result)). */ -#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0) - -/* Macros for flags, indexing each bit in a small array. */ -#define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))] -#define FLAGMASK(flag) ((unsigned)1 << ((flag) % (sizeof(unsigned) * 8))) -#define SET(flag) FLAGS(flag) |= FLAGMASK(flag) -#define UNSET(flag) FLAGS(flag) &= ~FLAGMASK(flag) -#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0) -#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag) - -/* Macros for allocation of character strings. */ -#define charalloc(howmuch) (char *)nmalloc(howmuch) -#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, howmuch) - -/* In UTF-8 a character is at most six bytes long. */ -#ifdef ENABLE_UTF8 -#define MAXCHARLEN 6 -#else -#define MAXCHARLEN 1 -#endif - -/* Set a default value for PATH_MAX if there isn't one. */ -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif - -#ifdef USE_SLANG -/* Slang support. */ -#include <slcurses.h> -/* Slang curses emulation brain damage, part 3: Slang doesn't define the - * curses equivalents of the Insert or Delete keys. */ -#define KEY_DC SL_KEY_DELETE -#define KEY_IC SL_KEY_IC -/* Ncurses support. */ -#elif defined(HAVE_NCURSESW_NCURSES_H) -#include <ncursesw/ncurses.h> -#elif defined(HAVE_NCURSES_H) -#include <ncurses.h> -#else -/* Curses support. */ -#include <curses.h> -#endif /* CURSES_H */ - -#if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR < 6) -#define USING_OLD_NCURSES yes -#endif - -#ifdef ENABLE_NLS -/* Native language support. */ -#ifdef HAVE_LIBINTL_H -#include <libintl.h> -#endif -#define _(string) gettext(string) -#define P_(singular, plural, number) ngettext(singular, plural, number) -#else -#define _(string) (string) -#define P_(singular, plural, number) (number == 1 ? singular : plural) -#endif -#define gettext_noop(string) (string) -#define N_(string) gettext_noop(string) - /* Mark a string that will be sent to gettext() later. */ - -#include <dirent.h> -#include <regex.h> -#include <signal.h> -#include <stdlib.h> -#include <sys/stat.h> - -/* If we aren't using an ncurses with mouse support, exclude any - * mouse routines, as they are useless then. */ -#ifndef NCURSES_MOUSE_VERSION -#undef ENABLE_MOUSE -#endif - -#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY) -#define ENABLED_WRAPORJUSTIFY 1 -#endif - -#define BACKWARD FALSE -#define FORWARD TRUE - -#define BLIND FALSE -#define VISIBLE TRUE - -#define JUSTFIND 0 -#define REPLACING 1 -#define INREGION 2 - -#ifdef ENABLE_COLOR -#define THE_DEFAULT -1 -#define BAD_COLOR -2 -#endif - -#define STANDARD_INPUT 0 - -/* Enumeration types. */ -typedef enum { - NIX_FILE, DOS_FILE, MAC_FILE -} format_type; - -typedef enum { - VACUUM, HUSH, NOTICE, MILD, ALERT -} message_type; - -typedef enum { - OVERWRITE, APPEND, PREPEND -} kind_of_writing_type; - -typedef enum { - SOFTMARK, HARDMARK -} mark_type; - -typedef enum { - CENTERING, FLOWING, STATIONARY -} update_type; - -/* The kinds of undo actions. ADD...REPLACE must come first. */ -typedef enum { - ADD, ENTER, BACK, DEL, JOIN, REPLACE, -#ifdef ENABLE_WRAPPING - SPLIT_BEGIN, SPLIT_END, -#endif - INDENT, UNINDENT, -#ifdef ENABLE_COMMENT - COMMENT, UNCOMMENT, PREFLIGHT, -#endif - ZAP, CUT, CUT_TO_EOF, COPY, PASTE, INSERT, - COUPLE_BEGIN, COUPLE_END, OTHER -} undo_type; - -/* Structure types. */ -#ifdef ENABLE_COLOR -typedef struct colortype { - short id; - /* An ordinal number (if this color combo is for a multiline regex). */ - short fg; - /* This combo's foreground color. */ - short bg; - /* This combo's background color. */ - short pairnum; - /* The pair number for this foreground/background color combination. */ - int attributes; - /* Pair number and brightness composed into ready-to-use attributes. */ - regex_t *start; - /* The compiled regular expression for 'start=', or the only one. */ - regex_t *end; - /* The compiled regular expression for 'end=', if any. */ - struct colortype *next; - /* Next color combination. */ -} colortype; - -typedef struct regexlisttype { - char *full_regex; - /* A regex string to match things that imply a certain syntax. */ - struct regexlisttype *next; - /* The next regex. */ -} regexlisttype; - -typedef struct augmentstruct { - char *filename; - /* The file where the syntax is extended. */ - ssize_t lineno; - /* The number of the line of the extendsyntax command. */ - char *data; - /* The text of the line. */ - struct augmentstruct *next; - /* Next node. */ -} augmentstruct; - -typedef struct syntaxtype { - char *name; - /* The name of this syntax. */ - char *filename; - /* File where the syntax is defined, or NULL if not an included file. */ - size_t lineno; - /* The line number where the 'syntax' command was found. */ - struct augmentstruct *augmentations; - /* List of extendsyntax commands to apply when loaded. */ - regexlisttype *extensions; - /* The list of extensions that this syntax applies to. */ - regexlisttype *headers; - /* The list of headerlines that this syntax applies to. */ - regexlisttype *magics; - /* The list of libmagic results that this syntax applies to. */ - char *linter; - /* The command with which to lint this type of file. */ - char *formatter; - /* The command with which to format/modify/arrange this type of file. */ - char *tab; - /* What the Tab key should produce; NULL for default behavior. */ -#ifdef ENABLE_COMMENT - char *comment; - /* The line comment prefix (and postfix) for this type of file. */ -#endif - colortype *color; - /* The colors and their regexes used in this syntax. */ - short nmultis; - /* How many multiline regex strings this syntax has. */ - struct syntaxtype *next; - /* Next syntax. */ -} syntaxtype; - -typedef struct lintstruct { - ssize_t lineno; - /* Line number of the error. */ - ssize_t colno; - /* Column # of the error. */ - char *msg; - /* Error message text. */ - char *filename; - /* Filename. */ - struct lintstruct *next; - /* Next error. */ - struct lintstruct *prev; - /* Previous error. */ -} lintstruct; - -/* Flags that indicate how a multiline regex applies to a line. */ -#define CNONE (1<<1) - /* Yay, regex doesn't apply to this line at all! */ -#define CBEGINBEFORE (1<<2) - /* Regex starts on an earlier line, ends on this one. */ -#define CENDAFTER (1<<3) - /* Regex starts on this line and ends on a later one. */ -#define CWHOLELINE (1<<4) - /* Whole line engulfed by the regex, start < me, end > me. */ -#define CSTARTENDHERE (1<<5) - /* Regex starts and ends within this line. */ -#define CWOULDBE (1<<6) - /* An unpaired start match on or before this line. */ -#endif /* ENABLE_COLOR */ - -/* More structure types. */ -typedef struct linestruct { - char *data; - /* The text of this line. */ - ssize_t lineno; - /* The number of this line. */ -#ifndef NANO_TINY - ssize_t extrarows; - /* The extra rows that this line occupies when softwrapping. */ -#endif - struct linestruct *next; - /* Next node. */ - struct linestruct *prev; - /* Previous node. */ -#ifdef ENABLE_COLOR - short *multidata; - /* Array of which multi-line regexes apply to this line. */ -#endif -#ifndef NANO_TINY - bool has_anchor; - /* Whether the user has placed an anchor at this line. */ -#endif -} linestruct; - -#ifndef NANO_TINY -typedef struct groupstruct { - ssize_t top_line; - /* First line of group. */ - ssize_t bottom_line; - /* Last line of group. */ - char **indentations; - /* String data used to restore the affected lines; one per line. */ - struct groupstruct *next; - /* The next group, if any. */ -} groupstruct; - -typedef struct undostruct { - undo_type type; - /* The operation type that this undo item is for. */ - int xflags; - /* Some flag data to mark certain corner cases. */ - ssize_t head_lineno; - /* The line number where the operation began or ended. */ - size_t head_x; - /* The x position where the operation began or ended. */ - char *strdata; - /* String data to help restore the affected line. */ - size_t wassize; - /* The file size before the action. */ - size_t newsize; - /* The file size after the action. */ - groupstruct *grouping; - /* Undo info specific to groups of lines. */ - linestruct *cutbuffer; - /* A copy of the cutbuffer. */ - ssize_t tail_lineno; - /* Mostly the line number of the current line; sometimes something else. */ - size_t tail_x; - /* The x position corresponding to the above line number. */ - struct undostruct *next; - /* A pointer to the undo item of the preceding action. */ -} undostruct; -#endif /* !NANO_TINY */ - -#ifdef ENABLE_HISTORIES -typedef struct poshiststruct { - char *filename; - /* The file. */ - ssize_t lineno; - /* Line number we left off on. */ - ssize_t xno; - /* The x position in the file we left off on. */ - struct poshiststruct *next; - /* The next item of position history. */ -} poshiststruct; -#endif - -typedef struct openfilestruct { - char *filename; - /* The file's name. */ - linestruct *filetop; - /* The file's first line. */ - linestruct *filebot; - /* The file's last line. */ - linestruct *edittop; - /* The current top of the edit window for this file. */ - linestruct *current; - /* The current line for this file. */ - size_t totsize; - /* The file's total number of characters. */ - size_t firstcolumn; - /* The starting column of the top line of the edit window. - * When not in softwrap mode, it's always zero. */ - size_t current_x; - /* The file's x-coordinate position. */ - size_t placewewant; - /* The file's x position we would like. */ - ssize_t current_y; - /* The file's y-coordinate position. */ - struct stat *statinfo; - /* The file's stat information from when it was opened or last saved. */ -#ifdef ENABLE_WRAPPING - linestruct *spillage_line; - /* The line for prepending stuff to during automatic hard-wrapping. */ -#endif -#ifndef NANO_TINY - linestruct *mark; - /* The line in the file where the mark is set; NULL if not set. */ - size_t mark_x; - /* The mark's x position in the above line. */ - mark_type kind_of_mark; - /* Whether it is a soft (with Shift) or a hard mark. */ - format_type fmt; - /* The file's format -- Unix or DOS or Mac. */ - char *lock_filename; - /* The path of the lockfile, if we created one. */ - undostruct *undotop; - /* The top of the undo list. */ - undostruct *current_undo; - /* The current (i.e. next) level of undo. */ - undostruct *last_saved; - /* The undo item at which the file was last saved. */ - undo_type last_action; - /* The type of the last action the user performed. */ -#endif - bool modified; - /* Whether the file has been modified. */ -#ifdef ENABLE_COLOR - syntaxtype *syntax; - /* The syntax that applies to this file, if any. */ -#endif -#ifdef ENABLE_MULTIBUFFER - struct openfilestruct *next; - /* The next open file, if any. */ - struct openfilestruct *prev; - /* The preceding open file, if any. */ -#endif -} openfilestruct; - -#ifdef ENABLE_NANORC -typedef struct rcoption { - const char *name; - /* The name of the rcfile option. */ - long flag; - /* The flag associated with it, if any. */ -} rcoption; -#endif - -typedef struct keystruct { - const char *keystr; - /* The string that describes the keystroke, like "^C" or "M-R". */ - int keycode; - /* The integer that, together with meta, identifies the keystroke. */ - int menus; - /* The menus in which this keystroke is bound. */ - void (*func)(void); - /* The function to which this keystroke is bound. */ -#ifndef NANO_TINY - int toggle; - /* If a toggle, what we're toggling. */ - int ordinal; - /* The how-manieth toggle this is, in order to be able to - * keep them in sequence. */ -#endif -#ifdef ENABLE_NANORC - char *expansion; - /* The string of keycodes to which this shortcut is expanded. */ -#endif - struct keystruct *next; - /* Next in the list. */ -} keystruct; - -typedef struct funcstruct { - void (*func)(void); - /* The actual function to call. */ - int menus; - /* In what menus this function applies. */ - const char *desc; - /* The function's short description, for example "Where Is". */ -#ifdef ENABLE_HELP - const char *help; - /* The help-screen text for this function. */ - bool blank_after; - /* Whether there should be a blank line after the help text - * for this function. */ -#endif - bool viewok; - /* Is this function allowed when in view mode? */ - long toggle; - /* If this is a toggle, which toggle to affect. */ - struct funcstruct *next; - /* Next item in the list. */ -} funcstruct; - -#ifdef ENABLE_WORDCOMPLETION -typedef struct completion_word { - char *word; - struct completion_word *next; -} completion_word; -#endif - -/* The elements of the interface that can be colored differently. */ -enum -{ - TITLE_BAR = 0, - LINE_NUMBER, - GUIDE_STRIPE, - SELECTED_TEXT, - STATUS_BAR, - ERROR_MESSAGE, - KEY_COMBO, - FUNCTION_TAG, - NUMBER_OF_ELEMENTS -}; - -/* Enumeration used in the flags array. See the definition of FLAGMASK. */ -enum -{ - DONTUSE, - CASE_SENSITIVE, - CONSTANT_SHOW, - NO_HELP, - SUSPENDABLE, - NO_WRAP, - AUTOINDENT, - VIEW_MODE, - USE_MOUSE, - USE_REGEXP, - SAVE_ON_EXIT, - CUT_FROM_CURSOR, - BACKWARDS_SEARCH, - MULTIBUFFER, - SMOOTH_SCROLL, - REBIND_DELETE, - RAW_SEQUENCES, - NO_CONVERT, - MAKE_BACKUP, - INSECURE_BACKUP, - NO_SYNTAX, - PRESERVE, - HISTORYLOG, - RESTRICTED, - SMART_HOME, - WHITESPACE_DISPLAY, - MORE_SPACE, - TABS_TO_SPACES, - QUICK_BLANK, - WORD_BOUNDS, - NO_NEWLINES, - BOLD_TEXT, - SOFTWRAP, - POSITIONLOG, - LOCKING, - NOREAD_MODE, - MAKE_IT_UNIX, - TRIM_BLANKS, - SHOW_CURSOR, - LINE_NUMBERS, - NO_PAUSES, - AT_BLANKS, - AFTER_ENDS, - LET_THEM_ZAP, - BREAK_LONG_LINES, - JUMPY_SCROLLING, - EMPTY_LINE, - INDICATOR -}; - -/* Flags for the menus in which a given function should be present. */ -#define MMAIN (1<<0) -#define MWHEREIS (1<<1) -#define MREPLACE (1<<2) -#define MREPLACEWITH (1<<3) -#define MGOTOLINE (1<<4) -#define MWRITEFILE (1<<5) -#define MINSERTFILE (1<<6) -#define MEXECUTE (1<<7) -#define MHELP (1<<8) -#define MSPELL (1<<9) -#define MBROWSER (1<<10) -#define MWHEREISFILE (1<<11) -#define MGOTODIR (1<<12) -#define MYESNO (1<<13) -#define MLINTER (1<<14) -#define MFINDINHELP (1<<15) -/* This is an abbreviation for all menus except Help and Browser and YesNo. */ -#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\ - MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER) -#ifndef NANO_TINY -#define MSOME MMOST|MBROWSER -#else -#define MSOME MMAIN|MBROWSER -#endif - -/* Basic control codes. */ -#define ESC_CODE 0x1B -#define DEL_CODE 0x7F - -/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */ -#define CONTROL_LEFT 0x401 -#define CONTROL_RIGHT 0x402 -#define CONTROL_UP 0x403 -#define CONTROL_DOWN 0x404 -#define CONTROL_HOME 0x405 -#define CONTROL_END 0x406 -#define CONTROL_DELETE 0x40D -#define SHIFT_CONTROL_LEFT 0x411 -#define SHIFT_CONTROL_RIGHT 0x412 -#define SHIFT_CONTROL_UP 0x413 -#define SHIFT_CONTROL_DOWN 0x414 -#define SHIFT_CONTROL_HOME 0x415 -#define SHIFT_CONTROL_END 0x416 -#define CONTROL_SHIFT_DELETE 0x41D -#define ALT_LEFT 0x421 -#define ALT_RIGHT 0x422 -#define ALT_UP 0x423 -#define ALT_DOWN 0x424 -#define ALT_PAGEUP 0x427 -#define ALT_PAGEDOWN 0x428 -#define ALT_INSERT 0x42C -#define ALT_DELETE 0x42D -#define SHIFT_ALT_LEFT 0x431 -#define SHIFT_ALT_RIGHT 0x432 -#define SHIFT_ALT_UP 0x433 -#define SHIFT_ALT_DOWN 0x434 -//#define SHIFT_LEFT 0x451 -//#define SHIFT_RIGHT 0x452 -#define SHIFT_UP 0x453 -#define SHIFT_DOWN 0x454 -#define SHIFT_HOME 0x455 -#define SHIFT_END 0x456 -#define SHIFT_PAGEUP 0x457 -#define SHIFT_PAGEDOWN 0x458 -#define SHIFT_DELETE 0x45D -#define SHIFT_TAB 0x45F - -/* A special keycode for when <Tab> is pressed while the mark is on. */ -#define INDENT_KEY 0x4F1 - -/* A special keycode to signal the beginning and end of a bracketed paste. */ -#define BRACKETED_PASTE_MARKER 0x4FB - -/* A special keycode for when a key produces an unknown escape sequence. */ -#define FOREIGN_SEQUENCE 0x4FC - -#ifdef USE_SLANG -#ifdef ENABLE_UTF8 -#define KEY_BAD 0xFF /* Clipped error code. */ -#endif -#define KEY_FLUSH 0x91 /* User-definable control code. */ -#else -#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */ -#endif - -#ifndef NANO_TINY -/* An imaginary key for when we get a SIGWINCH (window resize). */ -#define KEY_WINCH -2 - -/* Some extra flags for the undo function. */ -#define WAS_BACKSPACE_AT_EOF (1<<1) -#define WAS_WHOLE_LINE (1<<2) -#define INCLUDED_LAST_LINE (1<<3) -#define MARK_WAS_SET (1<<4) -#define CURSOR_WAS_AT_HEAD (1<<5) -#endif /* !NANO_TINY */ - -/* The default number of columns from end of line where wrapping occurs. */ -#define COLUMNS_FROM_EOL 8 - -/* The default width of a tab in spaces. */ -#define WIDTH_OF_TAB 8 - -/* The default comment character when a syntax does not specify any. */ -#define GENERAL_COMMENT_CHARACTER "#" - -/* The maximum number of search/replace history strings saved, not - * counting the blank lines at their ends. */ -#define MAX_SEARCH_HISTORY 100 - -/* The largest size_t number that doesn't have the high bit set. */ -#define HIGHEST_POSITIVE ((~(size_t)0) >> 1) diff --git a/src/prompt.c b/src/prompt.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #include <string.h> diff --git a/src/proto.h b/src/proto.h @@ -1,679 +0,0 @@ -/************************************************************************** - * proto.h -- This file is part of GNU nano. * - * * - * Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. * - * * - * GNU nano is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published * - * by the Free Software Foundation, either version 3 of the License, * - * or (at your option) any later version. * - * * - * GNU nano is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty * - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see http://www.gnu.org/licenses/. * - * * - **************************************************************************/ - -#include "nano.h" - -/* All external variables. See global.c for their descriptions. */ - -#ifndef NANO_TINY -extern volatile sig_atomic_t the_window_resized; -#endif - -extern bool on_a_vt; -extern bool shifted_metas; - -extern bool meta_key; -extern bool shift_held; -extern bool mute_modifiers; -extern bool bracketed_paste; - -extern bool we_are_running; -extern bool more_than_one; - -extern bool ran_a_tool; - -extern bool inhelp; -extern char *title; - -extern bool focusing; - -extern bool as_an_at; - -extern bool control_C_was_pressed; - -extern bool suppress_cursorpos; - -extern message_type lastmessage; - -extern linestruct *pletion_line; - -extern bool also_the_last; - -extern char *answer; - -extern char *last_search; -extern int didfind; - -extern char *present_path; - -extern unsigned flags[4]; - -extern int controlleft, controlright; -extern int controlup, controldown; -extern int controlhome, controlend; -#ifndef NANO_TINY -extern int controldelete, controlshiftdelete; -extern int shiftleft, shiftright; -extern int shiftup, shiftdown; -extern int shiftcontrolleft, shiftcontrolright; -extern int shiftcontrolup, shiftcontroldown; -extern int shiftcontrolhome, shiftcontrolend; -extern int altleft, altright; -extern int altup, altdown; -extern int altpageup, altpagedown; -extern int altinsert, altdelete; -extern int shiftaltleft, shiftaltright; -extern int shiftaltup, shiftaltdown; -#endif - -#ifdef ENABLED_WRAPORJUSTIFY -extern ssize_t fill; -extern size_t wrap_at; -#endif - -extern WINDOW *topwin; -extern WINDOW *edit; -extern WINDOW *bottomwin; -extern int editwinrows; -extern int editwincols; -extern int margin; -extern int thebar; -#ifndef NANO_TINY -extern int *bardata; -extern ssize_t stripe_column; -#endif - -extern linestruct *cutbuffer; -extern linestruct *cutbottom; -extern bool keep_cutbuffer; - -extern openfilestruct *openfile; -#ifdef ENABLE_MULTIBUFFER -extern openfilestruct *startfile; -#endif - -#ifndef NANO_TINY -extern char *matchbrackets; -extern char *whitespace; -extern int whitelen[2]; -#endif - -extern const char *exit_tag; -extern const char *close_tag; -#ifdef ENABLE_JUSTIFY -extern char *punct; -extern char *brackets; -extern char *quotestr; -extern regex_t quotereg; -#endif - -extern char *word_chars; - -extern ssize_t tabsize; - -#ifndef NANO_TINY -extern char *backup_dir; -#endif -#ifdef ENABLE_OPERATINGDIR -extern char *operating_dir; -#endif - -#ifdef ENABLE_SPELLER -extern char *alt_speller; -#endif - -#ifdef ENABLE_COLOR -extern syntaxtype *syntaxes; -extern char *syntaxstr; -extern bool have_palette; -#endif - -extern bool refresh_needed; - -extern int currmenu; -extern keystruct *sclist; -extern funcstruct *allfuncs; -extern funcstruct *exitfunc; - -extern linestruct *search_history; -extern linestruct *replace_history; -extern linestruct *execute_history; -#ifdef ENABLE_HISTORIES -extern linestruct *searchtop; -extern linestruct *searchbot; -extern linestruct *replacetop; -extern linestruct *replacebot; -extern linestruct *executetop; -extern linestruct *executebot; -#endif - -extern regex_t search_regexp; -extern regmatch_t regmatches[10]; - -extern int hilite_attribute; -#ifdef ENABLE_COLOR -extern colortype *color_combo[NUMBER_OF_ELEMENTS]; -#endif -extern int interface_color_pair[NUMBER_OF_ELEMENTS]; - -extern char *homedir; -extern char *statedir; -#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES) -extern char *startup_problem; -#endif -#ifdef ENABLE_NANORC -extern char *custom_nanorc; -#endif - -extern bool spotlighted; -extern size_t light_from_col; -extern size_t light_to_col; - -typedef void (*functionptrtype)(void); - -/* Most functions in browser.c. */ -#ifdef ENABLE_BROWSER -char *do_browse_from(const char *inpath); -void read_the_list(const char *path, DIR *dir); -void browser_refresh(void); -void browser_select_dirname(const char *needle); -void do_filesearch(bool forwards); -void do_fileresearch(bool forwards); -void to_first_file(void); -void to_last_file(void); -char *strip_last_component(const char *path); -#endif - -/* Most functions in chars.c. */ -#ifdef ENABLE_UTF8 -void utf8_init(void); -bool using_utf8(void); -#endif -bool is_alpha_char(const char *c); -bool is_blank_char(const char *c); -bool is_cntrl_char(const char *c); -bool is_word_char(const char *c, bool allow_punct); -char control_mbrep(const char *c, bool isdata); -#ifdef ENABLE_UTF8 -int mbwidth(const char *c); -#endif -char *make_mbchar(long code, int *length); -int char_length(const char *pointer); -size_t mbstrlen(const char *pointer); -int collect_char(const char *string, char *thechar); -int advance_over(const char *string, size_t *column); -size_t step_left(const char *buf, size_t pos); -size_t step_right(const char *buf, size_t pos); -int mbstrcasecmp(const char *s1, const char *s2); -int mbstrncasecmp(const char *s1, const char *s2, size_t n); -char *mbstrcasestr(const char *haystack, const char *needle); -char *revstrstr(const char *haystack, const char *needle, const char *pointer); -char *mbrevstrcasestr(const char *haystack, const char *needle, const char *pointer); -#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY) -char *mbstrchr(const char *string, const char *chr); -#endif -#ifndef NANO_TINY -char *mbstrpbrk(const char *string, const char *accept); -char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer); -#endif -#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY)) -bool has_blank_char(const char *string); -#endif -bool white_string(const char *string); -#ifdef ENABLE_UTF8 -bool is_valid_unicode(wchar_t wc); -#endif - -/* Most functions in color.c. */ -#ifdef ENABLE_COLOR -void set_interface_colorpairs(void); -void prepare_palette(void); -void find_and_prime_applicable_syntax(void); -void set_up_multicache(linestruct *line); -void check_the_multis(linestruct *line); -void precalc_multicolorinfo(void); -#endif - -/* Most functions in cut.c. */ -void do_delete(void); -void do_backspace(void); -#ifndef NANO_TINY -void chop_previous_word(void); -void chop_next_word(void); -#endif -void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x); -void ingraft_buffer(linestruct *topline); -void copy_from_buffer(linestruct *somebuffer); -#ifndef NANO_TINY -void cut_marked_region(void); -#endif -void do_snip(bool marked, bool until_eof, bool append); -void cut_text(void); -#ifndef NANO_TINY -void cut_till_eof(void); -void zap_text(void); -void copy_marked_region(void); -void copy_text(void); -#endif -void paste_text(void); - -/* Most functions in files.c. */ -void make_new_buffer(void); -#ifndef NANO_TINY -bool delete_lockfile(const char *lockfilename); -#endif -void compute_the_extra_rows_per_line_from(linestruct *fromline); -bool open_buffer(const char *filename, bool new_one); -void set_modified(void); -void prepare_for_display(void); -#ifdef ENABLE_MULTIBUFFER -void mention_name_and_linecount(void); -void switch_to_prev_buffer(void); -void switch_to_next_buffer(void); -void close_buffer(void); -#endif -void read_file(FILE *f, int fd, const char *filename, bool undoable); -int open_file(const char *filename, bool new_one, FILE **f); -char *get_next_filename(const char *name, const char *suffix); -void do_insertfile_void(void); -#ifndef NANO_TINY -void do_execute(void); -#endif -char *get_full_path(const char *origpath); -char *safe_tempfile(FILE **stream); -#ifdef ENABLE_OPERATINGDIR -void init_operating_dir(void); -bool outside_of_confinement(const char *currpath, bool allow_tabcomp); -#endif -#ifndef NANO_TINY -void init_backup_dir(void); -#endif -int copy_file(FILE *inn, FILE *out, bool close_out); -bool write_file(const char *name, FILE *thefile, bool tmp, - kind_of_writing_type method, bool fullbuffer); -#ifndef NANO_TINY -bool write_marked_file(const char *name, FILE *stream, bool tmp, - kind_of_writing_type method); -#endif -int do_writeout(bool exiting, bool withprompt); -void do_writeout_void(void); -void do_savefile(void); -char *real_dir_from_tilde(const char *path); -#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER) -int diralphasort(const void *va, const void *vb); -#endif -#ifdef ENABLE_TABCOMP -char *input_tab(char *buf, size_t *place, bool *lastwastab, - void (*refresh_func)(void), bool *listed); -#endif - -/* Some functions in global.c. */ -const keystruct *first_sc_for(int menu, void (*func)(void)); -int the_code_for(void (*func)(void), int defaultval); -size_t shown_entries_for(int menu); -const keystruct *get_shortcut(int *keycode); -functionptrtype func_from_key(int *keycode); -#if defined(ENABLE_BROWSER) || defined(ENABLE_HELP) -functionptrtype interpret(int *keycode); -#endif -int keycode_from_string(const char *keystring); -void shortcut_init(void); -const char *flagtostr(int flag); - -/* Most functions in help.c. */ -#ifdef ENABLE_HELP -void wrap_help_text_into_buffer(void); -void help_init(void); -#endif -void do_help(void); - -/* Most functions in history.c. */ -#ifdef ENABLE_HISTORIES -void history_init(void); -void history_reset(const linestruct *list); -void update_history(linestruct **item, const char *text); -char *get_history_older(linestruct **h); -char *get_history_newer(linestruct **h); -void get_history_older_void(void); -void get_history_newer_void(void); -#ifdef ENABLE_TABCOMP -char *get_history_completion(linestruct **h, char *s, size_t len); -#endif -bool have_statedir(void); -void load_history(void); -void save_history(void); -void load_poshistory(void); -void update_poshistory(void); -bool has_old_position(const char *file, ssize_t *line, ssize_t *column); -#endif - -/* Most functions in move.c. */ -void to_first_line(void); -void to_last_line(void); -void do_page_up(void); -void do_page_down(void); -#ifdef ENABLE_JUSTIFY -void do_para_begin(linestruct **line); -void do_para_end(linestruct **line); -void to_para_begin(void); -void to_para_end(void); -#endif -void to_prev_block(void); -void to_next_block(void); -void do_prev_word(bool allow_punct); -bool do_next_word(bool after_ends, bool allow_punct); -void to_prev_word(void); -void to_next_word(void); -void do_home(void); -void do_end(void); -void do_up(void); -void do_down(void); -#if !defined(NANO_TINY) || defined(ENABLE_HELP) -void do_scroll_up(void); -void do_scroll_down(void); -#endif -void do_left(void); -void do_right(void); - -/* Most functions in nano.c. */ -linestruct *make_new_node(linestruct *prevnode); -void splice_node(linestruct *afterthis, linestruct *newnode); -void unlink_node(linestruct *line); -void delete_node(linestruct *line); -linestruct *copy_buffer(const linestruct *src); -void free_lines(linestruct *src); -void renumber_from(linestruct *line); -void print_view_warning(void); -bool in_restricted_mode(void); -#ifndef ENABLE_HELP -void say_there_is_no_help(void); -#endif -void finish(void); -void close_and_go(void); -void do_exit(void); -void die(const char *msg, ...); -void window_init(void); -void install_handler_for_Ctrl_C(void); -void restore_handler_for_Ctrl_C(void); -void reconnect_and_store_state(void); -RETSIGTYPE handle_hupterm(int signal); -#ifndef DEBUG -RETSIGTYPE handle_crash(int signal); -#endif -RETSIGTYPE do_suspend(int signal); -RETSIGTYPE do_continue(int signal); -#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) -void block_sigwinch(bool blockit); -#endif -#ifndef NANO_TINY -RETSIGTYPE handle_sigwinch(int signal); -void regenerate_screen(void); -void do_toggle(int flag); -#endif -void disable_kb_interrupt(void); -void enable_kb_interrupt(void); -void disable_flow_control(void); -void enable_flow_control(void); -void terminal_init(void); -#ifdef ENABLE_LINENUMBERS -void confirm_margin(void); -#endif -void unbound_key(int code); -bool okay_for_view(const keystruct *shortcut); -void inject(char *burst, size_t count); - -/* Most functions in prompt.c. */ -size_t get_statusbar_page_start(size_t base, size_t column); -void put_cursor_at_end_of_answer(void); -void add_or_remove_pipe_symbol_from_answer(void); -int do_prompt(bool allow_tabbing, int menu, const char *provided, - linestruct **history_list, void (*refresh_func)(void), const char *msg, ...); -int do_yesno_prompt(bool all, const char *msg); - -/* Most functions in rcfile.c. */ -#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES) -void display_rcfile_errors(void); -void jot_error(const char *msg, ...); -#endif -#ifdef ENABLE_NANORC -#ifdef ENABLE_COLOR -void parse_one_include(char *file, syntaxtype *syntax); -void grab_and_store(const char *kind, char *ptr, regexlisttype **storage); -bool parse_syntax_commands(char *keyword, char *ptr); -#endif -void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only); -void do_rcfiles(void); -#endif /* ENABLE_NANORC */ - -/* Most functions in search.c. */ -bool regexp_init(const char *regexp); -void tidy_up_after_search(void); -int findnextstr(const char *needle, bool whole_word_only, int modus, - size_t *match_len, bool skipone, const linestruct *begin, size_t begin_x); -void do_search(void); -void do_search_forward(void); -void do_search_backward(void); -void do_findprevious(void); -void do_findnext(void); -void not_found_msg(const char *str); -void go_looking(void); -ssize_t do_replace_loop(const char *needle, bool whole_word_only, - const linestruct *real_current, size_t *real_current_x); -void do_replace(void); -void ask_for_and_do_replacements(void); -void goto_line_posx(ssize_t line, size_t pos_x); -void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, - bool interactive); -void do_gotolinecolumn_void(void); -#ifndef NANO_TINY -void do_find_bracket(void); -void put_or_lift_anchor(void); -void to_prev_anchor(void); -void to_next_anchor(void); -#endif - -/* Most functions in text.c. */ -#ifndef NANO_TINY -void do_mark(void); -#endif -void do_tab(void); -#ifndef NANO_TINY -void do_indent(void); -void do_unindent(void); -#endif -#ifdef ENABLE_COMMENT -void do_comment(void); -#endif -void do_undo(void); -void do_redo(void); -void do_enter(void); -#ifndef NANO_TINY -void discard_until(const undostruct *thisitem); -void add_undo(undo_type action, const char *message); -void update_multiline_undo(ssize_t lineno, char *indentation); -void update_undo(undo_type action); -#endif /* !NANO_TINY */ -#ifdef ENABLE_WRAPPING -bool do_wrap(void); -#endif -#if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY) -ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl); -#endif -#if !defined(NANO_TINY) || defined(ENABLED_WRAPORJUSTIFY) -size_t indent_length(const char *line); -#endif -#ifdef ENABLE_JUSTIFY -size_t quote_length(const char *line); -bool begpar(const linestruct *const line, int depth); -bool inpar(const linestruct *const line); -void do_justify(bool full_justify); -void do_justify_void(void); -void do_full_justify(void); -#endif -#ifdef ENABLE_SPELLER -void do_spell(void); -#endif -#ifdef ENABLE_COLOR -void do_linter(void); -void do_formatter(void); -#endif -#ifndef NANO_TINY -void do_wordlinechar_count(void); -#endif -void do_verbatim_input(void); -void complete_a_word(void); - -/* All functions in utils.c. */ -void get_homedir(void); -const char *tail(const char *path); -char *concatenate(const char *path, const char *name); -#ifdef ENABLE_LINENUMBERS -int digits(ssize_t n); -#endif -bool parse_num(const char *str, ssize_t *result); -bool parse_line_column(const char *str, ssize_t *line, ssize_t *column); -void recode_NUL_to_LF(char *string, size_t length); -void recode_LF_to_NUL(char *string); -#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER) -void free_chararray(char **array, size_t len); -#endif -#ifdef ENABLE_SPELLER -bool is_separate_word(size_t position, size_t length, const char *buf); -#endif -const char *strstrwrapper(const char *haystack, const char *needle, - const char *start); -void *nmalloc(size_t howmuch); -void *nrealloc(void *ptr, size_t howmuch); -char *measured_copy(const char *string, size_t count); -char *mallocstrcpy(char *dest, const char *src); -char *copy_of(const char *string); -char *free_and_assign(char *dest, char *src); -size_t get_page_start(size_t column); -size_t xplustabs(void); -size_t actual_x(const char *text, size_t column); -size_t wideness(const char *text, size_t maxlen); -size_t breadth(const char *text); -void new_magicline(void); -#if !defined(NANO_TINY) || defined(ENABLE_HELP) -void remove_magicline(void); -#endif -#ifndef NANO_TINY -bool mark_is_before_cursor(void); -void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x); -void get_range(linestruct **top, linestruct **bot); -#endif -size_t number_of_characters_in(const linestruct *begin, const linestruct *end); -#ifndef NANO_TINY -linestruct *line_from_number(ssize_t number); -#endif - -/* Most functions in winio.c. */ -void record_macro(void); -void run_macro(void); -size_t get_key_buffer_len(void); -#ifdef ENABLE_NANORC -void implant(const char *string); -#endif -int parse_kbinput(WINDOW *win); -int get_kbinput(WINDOW *win, bool showcursor); -int get_byte_kbinput(int kbinput); -int get_control_kbinput(int kbinput); -char *get_verbatim_kbinput(WINDOW *win, size_t *count); -#ifdef ENABLE_MOUSE -int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts); -#endif -void blank_edit(void); -void blank_statusbar(void); -void wipe_statusbar(void); -void blank_bottombars(void); -void check_statusblank(void); -char *display_string(const char *buf, size_t column, size_t span, - bool isdata, bool isprompt); -void titlebar(const char *path); -void statusline(message_type importance, const char *msg, ...); -void statusbar(const char *msg); -void warn_and_briefly_pause(const char *msg); -void bottombars(int menu); -void post_one_key(const char *keystroke, const char *tag, int width); -void place_the_cursor(void); -int update_line(linestruct *line, size_t index); -#ifndef NANO_TINY -int update_softwrapped_line(linestruct *line); -#endif -bool line_needs_update(const size_t old_column, const size_t new_column); -int go_back_chunks(int nrows, linestruct **line, size_t *leftedge); -int go_forward_chunks(int nrows, linestruct **line, size_t *leftedge); -bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge); -void edit_scroll(bool direction); -#ifndef NANO_TINY -size_t get_softwrap_breakpoint(const char *text, size_t leftedge, - bool *end_of_line); -size_t get_chunk_and_edge(size_t column, linestruct *line, size_t *leftedge); -size_t chunk_for(size_t column, linestruct *line); -size_t leftedge_for(size_t column, linestruct *line); -size_t extra_chunks_in(linestruct *line); -void ensure_firstcolumn_is_aligned(void); -#endif -size_t actual_last_column(size_t leftedge, size_t column); -void edit_redraw(linestruct *old_current, update_type manner); -void edit_refresh(void); -void adjust_viewport(update_type manner); -void full_refresh(void); -void draw_all_subwindows(void); -void do_cursorpos(bool force); -void do_cursorpos_void(void); -void spotlight(size_t from_col, size_t to_col); -#ifndef NANO_TINY -void spotlight_softwrapped(size_t from_col, size_t to_col); -#endif -void do_suspend_void(void); -void disable_waiting(void); -void enable_waiting(void); -#ifdef ENABLE_EXTRA -void do_credits(void); -#endif - -/* These are just name definitions. */ -void case_sens_void(void); -void regexp_void(void); -void backwards_void(void); -void flip_replace(void); -void flip_goto(void); -#ifdef ENABLE_BROWSER -void to_files(void); -void goto_dir(void); -#endif -#ifndef NANO_TINY -void do_nothing(void); -void do_toggle_void(void); -void dos_format_void(void); -void mac_format_void(void); -void append_void(void); -void prepend_void(void); -void backup_file_void(void); -void flip_execute(void); -void flip_pipe(void); -void flip_convert(void); -#endif -#ifdef ENABLE_MULTIBUFFER -void flip_newbuffer(void); -#endif -void discard_buffer(void); -void do_cancel(void); diff --git a/src/prototypes.h b/src/prototypes.h @@ -0,0 +1,679 @@ +/************************************************************************** + * prototypes.h -- This file is part of GNU nano. * + * * + * Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. * + * * + * GNU nano is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published * + * by the Free Software Foundation, either version 3 of the License, * + * or (at your option) any later version. * + * * + * GNU nano is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty * + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see http://www.gnu.org/licenses/. * + * * + **************************************************************************/ + +#include "definitions.h" + +/* All external variables. See global.c for their descriptions. */ + +#ifndef NANO_TINY +extern volatile sig_atomic_t the_window_resized; +#endif + +extern bool on_a_vt; +extern bool shifted_metas; + +extern bool meta_key; +extern bool shift_held; +extern bool mute_modifiers; +extern bool bracketed_paste; + +extern bool we_are_running; +extern bool more_than_one; + +extern bool ran_a_tool; + +extern bool inhelp; +extern char *title; + +extern bool focusing; + +extern bool as_an_at; + +extern bool control_C_was_pressed; + +extern bool suppress_cursorpos; + +extern message_type lastmessage; + +extern linestruct *pletion_line; + +extern bool also_the_last; + +extern char *answer; + +extern char *last_search; +extern int didfind; + +extern char *present_path; + +extern unsigned flags[4]; + +extern int controlleft, controlright; +extern int controlup, controldown; +extern int controlhome, controlend; +#ifndef NANO_TINY +extern int controldelete, controlshiftdelete; +extern int shiftleft, shiftright; +extern int shiftup, shiftdown; +extern int shiftcontrolleft, shiftcontrolright; +extern int shiftcontrolup, shiftcontroldown; +extern int shiftcontrolhome, shiftcontrolend; +extern int altleft, altright; +extern int altup, altdown; +extern int altpageup, altpagedown; +extern int altinsert, altdelete; +extern int shiftaltleft, shiftaltright; +extern int shiftaltup, shiftaltdown; +#endif + +#ifdef ENABLED_WRAPORJUSTIFY +extern ssize_t fill; +extern size_t wrap_at; +#endif + +extern WINDOW *topwin; +extern WINDOW *edit; +extern WINDOW *bottomwin; +extern int editwinrows; +extern int editwincols; +extern int margin; +extern int thebar; +#ifndef NANO_TINY +extern int *bardata; +extern ssize_t stripe_column; +#endif + +extern linestruct *cutbuffer; +extern linestruct *cutbottom; +extern bool keep_cutbuffer; + +extern openfilestruct *openfile; +#ifdef ENABLE_MULTIBUFFER +extern openfilestruct *startfile; +#endif + +#ifndef NANO_TINY +extern char *matchbrackets; +extern char *whitespace; +extern int whitelen[2]; +#endif + +extern const char *exit_tag; +extern const char *close_tag; +#ifdef ENABLE_JUSTIFY +extern char *punct; +extern char *brackets; +extern char *quotestr; +extern regex_t quotereg; +#endif + +extern char *word_chars; + +extern ssize_t tabsize; + +#ifndef NANO_TINY +extern char *backup_dir; +#endif +#ifdef ENABLE_OPERATINGDIR +extern char *operating_dir; +#endif + +#ifdef ENABLE_SPELLER +extern char *alt_speller; +#endif + +#ifdef ENABLE_COLOR +extern syntaxtype *syntaxes; +extern char *syntaxstr; +extern bool have_palette; +#endif + +extern bool refresh_needed; + +extern int currmenu; +extern keystruct *sclist; +extern funcstruct *allfuncs; +extern funcstruct *exitfunc; + +extern linestruct *search_history; +extern linestruct *replace_history; +extern linestruct *execute_history; +#ifdef ENABLE_HISTORIES +extern linestruct *searchtop; +extern linestruct *searchbot; +extern linestruct *replacetop; +extern linestruct *replacebot; +extern linestruct *executetop; +extern linestruct *executebot; +#endif + +extern regex_t search_regexp; +extern regmatch_t regmatches[10]; + +extern int hilite_attribute; +#ifdef ENABLE_COLOR +extern colortype *color_combo[NUMBER_OF_ELEMENTS]; +#endif +extern int interface_color_pair[NUMBER_OF_ELEMENTS]; + +extern char *homedir; +extern char *statedir; +#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES) +extern char *startup_problem; +#endif +#ifdef ENABLE_NANORC +extern char *custom_nanorc; +#endif + +extern bool spotlighted; +extern size_t light_from_col; +extern size_t light_to_col; + +typedef void (*functionptrtype)(void); + +/* Most functions in browser.c. */ +#ifdef ENABLE_BROWSER +char *do_browse_from(const char *inpath); +void read_the_list(const char *path, DIR *dir); +void browser_refresh(void); +void browser_select_dirname(const char *needle); +void do_filesearch(bool forwards); +void do_fileresearch(bool forwards); +void to_first_file(void); +void to_last_file(void); +char *strip_last_component(const char *path); +#endif + +/* Most functions in chars.c. */ +#ifdef ENABLE_UTF8 +void utf8_init(void); +bool using_utf8(void); +#endif +bool is_alpha_char(const char *c); +bool is_blank_char(const char *c); +bool is_cntrl_char(const char *c); +bool is_word_char(const char *c, bool allow_punct); +char control_mbrep(const char *c, bool isdata); +#ifdef ENABLE_UTF8 +int mbwidth(const char *c); +#endif +char *make_mbchar(long code, int *length); +int char_length(const char *pointer); +size_t mbstrlen(const char *pointer); +int collect_char(const char *string, char *thechar); +int advance_over(const char *string, size_t *column); +size_t step_left(const char *buf, size_t pos); +size_t step_right(const char *buf, size_t pos); +int mbstrcasecmp(const char *s1, const char *s2); +int mbstrncasecmp(const char *s1, const char *s2, size_t n); +char *mbstrcasestr(const char *haystack, const char *needle); +char *revstrstr(const char *haystack, const char *needle, const char *pointer); +char *mbrevstrcasestr(const char *haystack, const char *needle, const char *pointer); +#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY) +char *mbstrchr(const char *string, const char *chr); +#endif +#ifndef NANO_TINY +char *mbstrpbrk(const char *string, const char *accept); +char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer); +#endif +#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY)) +bool has_blank_char(const char *string); +#endif +bool white_string(const char *string); +#ifdef ENABLE_UTF8 +bool is_valid_unicode(wchar_t wc); +#endif + +/* Most functions in color.c. */ +#ifdef ENABLE_COLOR +void set_interface_colorpairs(void); +void prepare_palette(void); +void find_and_prime_applicable_syntax(void); +void set_up_multicache(linestruct *line); +void check_the_multis(linestruct *line); +void precalc_multicolorinfo(void); +#endif + +/* Most functions in cut.c. */ +void do_delete(void); +void do_backspace(void); +#ifndef NANO_TINY +void chop_previous_word(void); +void chop_next_word(void); +#endif +void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x); +void ingraft_buffer(linestruct *topline); +void copy_from_buffer(linestruct *somebuffer); +#ifndef NANO_TINY +void cut_marked_region(void); +#endif +void do_snip(bool marked, bool until_eof, bool append); +void cut_text(void); +#ifndef NANO_TINY +void cut_till_eof(void); +void zap_text(void); +void copy_marked_region(void); +void copy_text(void); +#endif +void paste_text(void); + +/* Most functions in files.c. */ +void make_new_buffer(void); +#ifndef NANO_TINY +bool delete_lockfile(const char *lockfilename); +#endif +void compute_the_extra_rows_per_line_from(linestruct *fromline); +bool open_buffer(const char *filename, bool new_one); +void set_modified(void); +void prepare_for_display(void); +#ifdef ENABLE_MULTIBUFFER +void mention_name_and_linecount(void); +void switch_to_prev_buffer(void); +void switch_to_next_buffer(void); +void close_buffer(void); +#endif +void read_file(FILE *f, int fd, const char *filename, bool undoable); +int open_file(const char *filename, bool new_one, FILE **f); +char *get_next_filename(const char *name, const char *suffix); +void do_insertfile_void(void); +#ifndef NANO_TINY +void do_execute(void); +#endif +char *get_full_path(const char *origpath); +char *safe_tempfile(FILE **stream); +#ifdef ENABLE_OPERATINGDIR +void init_operating_dir(void); +bool outside_of_confinement(const char *currpath, bool allow_tabcomp); +#endif +#ifndef NANO_TINY +void init_backup_dir(void); +#endif +int copy_file(FILE *inn, FILE *out, bool close_out); +bool write_file(const char *name, FILE *thefile, bool tmp, + kind_of_writing_type method, bool fullbuffer); +#ifndef NANO_TINY +bool write_marked_file(const char *name, FILE *stream, bool tmp, + kind_of_writing_type method); +#endif +int do_writeout(bool exiting, bool withprompt); +void do_writeout_void(void); +void do_savefile(void); +char *real_dir_from_tilde(const char *path); +#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER) +int diralphasort(const void *va, const void *vb); +#endif +#ifdef ENABLE_TABCOMP +char *input_tab(char *buf, size_t *place, bool *lastwastab, + void (*refresh_func)(void), bool *listed); +#endif + +/* Some functions in global.c. */ +const keystruct *first_sc_for(int menu, void (*func)(void)); +int the_code_for(void (*func)(void), int defaultval); +size_t shown_entries_for(int menu); +const keystruct *get_shortcut(int *keycode); +functionptrtype func_from_key(int *keycode); +#if defined(ENABLE_BROWSER) || defined(ENABLE_HELP) +functionptrtype interpret(int *keycode); +#endif +int keycode_from_string(const char *keystring); +void shortcut_init(void); +const char *flagtostr(int flag); + +/* Most functions in help.c. */ +#ifdef ENABLE_HELP +void wrap_help_text_into_buffer(void); +void help_init(void); +#endif +void do_help(void); + +/* Most functions in history.c. */ +#ifdef ENABLE_HISTORIES +void history_init(void); +void history_reset(const linestruct *list); +void update_history(linestruct **item, const char *text); +char *get_history_older(linestruct **h); +char *get_history_newer(linestruct **h); +void get_history_older_void(void); +void get_history_newer_void(void); +#ifdef ENABLE_TABCOMP +char *get_history_completion(linestruct **h, char *s, size_t len); +#endif +bool have_statedir(void); +void load_history(void); +void save_history(void); +void load_poshistory(void); +void update_poshistory(void); +bool has_old_position(const char *file, ssize_t *line, ssize_t *column); +#endif + +/* Most functions in move.c. */ +void to_first_line(void); +void to_last_line(void); +void do_page_up(void); +void do_page_down(void); +#ifdef ENABLE_JUSTIFY +void do_para_begin(linestruct **line); +void do_para_end(linestruct **line); +void to_para_begin(void); +void to_para_end(void); +#endif +void to_prev_block(void); +void to_next_block(void); +void do_prev_word(bool allow_punct); +bool do_next_word(bool after_ends, bool allow_punct); +void to_prev_word(void); +void to_next_word(void); +void do_home(void); +void do_end(void); +void do_up(void); +void do_down(void); +#if !defined(NANO_TINY) || defined(ENABLE_HELP) +void do_scroll_up(void); +void do_scroll_down(void); +#endif +void do_left(void); +void do_right(void); + +/* Most functions in nano.c. */ +linestruct *make_new_node(linestruct *prevnode); +void splice_node(linestruct *afterthis, linestruct *newnode); +void unlink_node(linestruct *line); +void delete_node(linestruct *line); +linestruct *copy_buffer(const linestruct *src); +void free_lines(linestruct *src); +void renumber_from(linestruct *line); +void print_view_warning(void); +bool in_restricted_mode(void); +#ifndef ENABLE_HELP +void say_there_is_no_help(void); +#endif +void finish(void); +void close_and_go(void); +void do_exit(void); +void die(const char *msg, ...); +void window_init(void); +void install_handler_for_Ctrl_C(void); +void restore_handler_for_Ctrl_C(void); +void reconnect_and_store_state(void); +RETSIGTYPE handle_hupterm(int signal); +#ifndef DEBUG +RETSIGTYPE handle_crash(int signal); +#endif +RETSIGTYPE do_suspend(int signal); +RETSIGTYPE do_continue(int signal); +#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) +void block_sigwinch(bool blockit); +#endif +#ifndef NANO_TINY +RETSIGTYPE handle_sigwinch(int signal); +void regenerate_screen(void); +void do_toggle(int flag); +#endif +void disable_kb_interrupt(void); +void enable_kb_interrupt(void); +void disable_flow_control(void); +void enable_flow_control(void); +void terminal_init(void); +#ifdef ENABLE_LINENUMBERS +void confirm_margin(void); +#endif +void unbound_key(int code); +bool okay_for_view(const keystruct *shortcut); +void inject(char *burst, size_t count); + +/* Most functions in prompt.c. */ +size_t get_statusbar_page_start(size_t base, size_t column); +void put_cursor_at_end_of_answer(void); +void add_or_remove_pipe_symbol_from_answer(void); +int do_prompt(bool allow_tabbing, int menu, const char *provided, + linestruct **history_list, void (*refresh_func)(void), const char *msg, ...); +int do_yesno_prompt(bool all, const char *msg); + +/* Most functions in rcfile.c. */ +#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES) +void display_rcfile_errors(void); +void jot_error(const char *msg, ...); +#endif +#ifdef ENABLE_NANORC +#ifdef ENABLE_COLOR +void parse_one_include(char *file, syntaxtype *syntax); +void grab_and_store(const char *kind, char *ptr, regexlisttype **storage); +bool parse_syntax_commands(char *keyword, char *ptr); +#endif +void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only); +void do_rcfiles(void); +#endif /* ENABLE_NANORC */ + +/* Most functions in search.c. */ +bool regexp_init(const char *regexp); +void tidy_up_after_search(void); +int findnextstr(const char *needle, bool whole_word_only, int modus, + size_t *match_len, bool skipone, const linestruct *begin, size_t begin_x); +void do_search(void); +void do_search_forward(void); +void do_search_backward(void); +void do_findprevious(void); +void do_findnext(void); +void not_found_msg(const char *str); +void go_looking(void); +ssize_t do_replace_loop(const char *needle, bool whole_word_only, + const linestruct *real_current, size_t *real_current_x); +void do_replace(void); +void ask_for_and_do_replacements(void); +void goto_line_posx(ssize_t line, size_t pos_x); +void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, + bool interactive); +void do_gotolinecolumn_void(void); +#ifndef NANO_TINY +void do_find_bracket(void); +void put_or_lift_anchor(void); +void to_prev_anchor(void); +void to_next_anchor(void); +#endif + +/* Most functions in text.c. */ +#ifndef NANO_TINY +void do_mark(void); +#endif +void do_tab(void); +#ifndef NANO_TINY +void do_indent(void); +void do_unindent(void); +#endif +#ifdef ENABLE_COMMENT +void do_comment(void); +#endif +void do_undo(void); +void do_redo(void); +void do_enter(void); +#ifndef NANO_TINY +void discard_until(const undostruct *thisitem); +void add_undo(undo_type action, const char *message); +void update_multiline_undo(ssize_t lineno, char *indentation); +void update_undo(undo_type action); +#endif /* !NANO_TINY */ +#ifdef ENABLE_WRAPPING +bool do_wrap(void); +#endif +#if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY) +ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl); +#endif +#if !defined(NANO_TINY) || defined(ENABLED_WRAPORJUSTIFY) +size_t indent_length(const char *line); +#endif +#ifdef ENABLE_JUSTIFY +size_t quote_length(const char *line); +bool begpar(const linestruct *const line, int depth); +bool inpar(const linestruct *const line); +void do_justify(bool full_justify); +void do_justify_void(void); +void do_full_justify(void); +#endif +#ifdef ENABLE_SPELLER +void do_spell(void); +#endif +#ifdef ENABLE_COLOR +void do_linter(void); +void do_formatter(void); +#endif +#ifndef NANO_TINY +void do_wordlinechar_count(void); +#endif +void do_verbatim_input(void); +void complete_a_word(void); + +/* All functions in utils.c. */ +void get_homedir(void); +const char *tail(const char *path); +char *concatenate(const char *path, const char *name); +#ifdef ENABLE_LINENUMBERS +int digits(ssize_t n); +#endif +bool parse_num(const char *str, ssize_t *result); +bool parse_line_column(const char *str, ssize_t *line, ssize_t *column); +void recode_NUL_to_LF(char *string, size_t length); +void recode_LF_to_NUL(char *string); +#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER) +void free_chararray(char **array, size_t len); +#endif +#ifdef ENABLE_SPELLER +bool is_separate_word(size_t position, size_t length, const char *buf); +#endif +const char *strstrwrapper(const char *haystack, const char *needle, + const char *start); +void *nmalloc(size_t howmuch); +void *nrealloc(void *ptr, size_t howmuch); +char *measured_copy(const char *string, size_t count); +char *mallocstrcpy(char *dest, const char *src); +char *copy_of(const char *string); +char *free_and_assign(char *dest, char *src); +size_t get_page_start(size_t column); +size_t xplustabs(void); +size_t actual_x(const char *text, size_t column); +size_t wideness(const char *text, size_t maxlen); +size_t breadth(const char *text); +void new_magicline(void); +#if !defined(NANO_TINY) || defined(ENABLE_HELP) +void remove_magicline(void); +#endif +#ifndef NANO_TINY +bool mark_is_before_cursor(void); +void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x); +void get_range(linestruct **top, linestruct **bot); +#endif +size_t number_of_characters_in(const linestruct *begin, const linestruct *end); +#ifndef NANO_TINY +linestruct *line_from_number(ssize_t number); +#endif + +/* Most functions in winio.c. */ +void record_macro(void); +void run_macro(void); +size_t get_key_buffer_len(void); +#ifdef ENABLE_NANORC +void implant(const char *string); +#endif +int parse_kbinput(WINDOW *win); +int get_kbinput(WINDOW *win, bool showcursor); +int get_byte_kbinput(int kbinput); +int get_control_kbinput(int kbinput); +char *get_verbatim_kbinput(WINDOW *win, size_t *count); +#ifdef ENABLE_MOUSE +int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts); +#endif +void blank_edit(void); +void blank_statusbar(void); +void wipe_statusbar(void); +void blank_bottombars(void); +void check_statusblank(void); +char *display_string(const char *buf, size_t column, size_t span, + bool isdata, bool isprompt); +void titlebar(const char *path); +void statusline(message_type importance, const char *msg, ...); +void statusbar(const char *msg); +void warn_and_briefly_pause(const char *msg); +void bottombars(int menu); +void post_one_key(const char *keystroke, const char *tag, int width); +void place_the_cursor(void); +int update_line(linestruct *line, size_t index); +#ifndef NANO_TINY +int update_softwrapped_line(linestruct *line); +#endif +bool line_needs_update(const size_t old_column, const size_t new_column); +int go_back_chunks(int nrows, linestruct **line, size_t *leftedge); +int go_forward_chunks(int nrows, linestruct **line, size_t *leftedge); +bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge); +void edit_scroll(bool direction); +#ifndef NANO_TINY +size_t get_softwrap_breakpoint(const char *text, size_t leftedge, + bool *end_of_line); +size_t get_chunk_and_edge(size_t column, linestruct *line, size_t *leftedge); +size_t chunk_for(size_t column, linestruct *line); +size_t leftedge_for(size_t column, linestruct *line); +size_t extra_chunks_in(linestruct *line); +void ensure_firstcolumn_is_aligned(void); +#endif +size_t actual_last_column(size_t leftedge, size_t column); +void edit_redraw(linestruct *old_current, update_type manner); +void edit_refresh(void); +void adjust_viewport(update_type manner); +void full_refresh(void); +void draw_all_subwindows(void); +void do_cursorpos(bool force); +void do_cursorpos_void(void); +void spotlight(size_t from_col, size_t to_col); +#ifndef NANO_TINY +void spotlight_softwrapped(size_t from_col, size_t to_col); +#endif +void do_suspend_void(void); +void disable_waiting(void); +void enable_waiting(void); +#ifdef ENABLE_EXTRA +void do_credits(void); +#endif + +/* These are just name definitions. */ +void case_sens_void(void); +void regexp_void(void); +void backwards_void(void); +void flip_replace(void); +void flip_goto(void); +#ifdef ENABLE_BROWSER +void to_files(void); +void goto_dir(void); +#endif +#ifndef NANO_TINY +void do_nothing(void); +void do_toggle_void(void); +void dos_format_void(void); +void mac_format_void(void); +void append_void(void); +void prepend_void(void); +void backup_file_void(void); +void flip_execute(void); +void flip_pipe(void); +void flip_convert(void); +#endif +#ifdef ENABLE_MULTIBUFFER +void flip_newbuffer(void); +#endif +void discard_buffer(void); +void do_cancel(void); diff --git a/src/rcfile.c b/src/rcfile.c @@ -21,7 +21,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #ifdef ENABLE_NANORC diff --git a/src/search.c b/src/search.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #include <string.h> diff --git a/src/text.c b/src/text.c @@ -23,7 +23,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #include <errno.h> #include <fcntl.h> diff --git a/src/utils.c b/src/utils.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #include <errno.h> #ifdef HAVE_PWD_H diff --git a/src/winio.c b/src/winio.c @@ -19,7 +19,7 @@ * * **************************************************************************/ -#include "proto.h" +#include "prototypes.h" #include "revision.h" #include <ctype.h>