2000-06-06 05:53:49 +00:00
|
|
|
/**************************************************************************
|
2020-06-20 10:09:31 +00:00
|
|
|
* definitions.h -- This file is part of GNU nano. *
|
2000-06-06 05:53:49 +00:00
|
|
|
* *
|
2020-01-15 10:42:38 +00:00
|
|
|
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
2017-11-12 09:42:29 +00:00
|
|
|
* Copyright (C) 2014-2017 Benno Schulenberg *
|
2016-09-03 10:14:08 +00:00
|
|
|
* *
|
2016-08-29 15:10:49 +00:00
|
|
|
* 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. *
|
2000-06-06 05:53:49 +00:00
|
|
|
* *
|
2016-08-29 15:10:49 +00:00
|
|
|
* 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. *
|
2000-06-06 05:53:49 +00:00
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
2016-08-29 15:10:49 +00:00
|
|
|
* along with this program. If not, see http://www.gnu.org/licenses/. *
|
2000-06-06 05:53:49 +00:00
|
|
|
* *
|
|
|
|
**************************************************************************/
|
|
|
|
|
2005-04-15 18:07:26 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2009-03-01 00:50:19 +00:00
|
|
|
#ifdef NEED_XOPEN_SOURCE_EXTENDED
|
|
|
|
#ifndef _XOPEN_SOURCE_EXTENDED
|
2020-05-29 16:45:14 +00:00
|
|
|
#define _XOPEN_SOURCE_EXTENDED 1
|
2014-06-20 10:48:26 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2009-03-01 00:50:19 +00:00
|
|
|
|
2004-03-04 06:33:52 +00:00
|
|
|
#ifdef __TANDEM
|
2006-07-18 18:28:10 +00:00
|
|
|
/* Tandem NonStop Kernel support. */
|
2004-03-04 06:33:52 +00:00
|
|
|
#include <floss.h>
|
2020-05-29 15:19:38 +00:00
|
|
|
#define ROOT_UID 65535
|
2004-03-04 06:33:52 +00:00
|
|
|
#else
|
2020-05-29 15:19:38 +00:00
|
|
|
#define ROOT_UID 0
|
2004-03-04 06:33:52 +00:00
|
|
|
#endif
|
|
|
|
|
2000-06-06 05:53:49 +00:00
|
|
|
#ifdef HAVE_LIMITS_H
|
|
|
|
#include <limits.h>
|
|
|
|
#endif
|
|
|
|
|
2005-06-08 01:35:10 +00:00
|
|
|
/* Set a default value for PATH_MAX if there isn't one. */
|
2004-11-04 04:08:18 +00:00
|
|
|
#ifndef PATH_MAX
|
2020-05-29 16:45:14 +00:00
|
|
|
#define PATH_MAX 4096
|
2002-06-28 22:45:14 +00:00
|
|
|
#endif
|
2000-06-06 05:53:49 +00:00
|
|
|
|
2020-12-06 10:49:37 +00:00
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <regex.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2020-12-05 11:12:11 +00:00
|
|
|
/* Prefer wide ncurses over normal ncurses over curses. */
|
2020-12-05 10:57:08 +00:00
|
|
|
#if defined(HAVE_NCURSESW_NCURSES_H)
|
2013-01-10 03:29:59 +00:00
|
|
|
#include <ncursesw/ncurses.h>
|
2007-12-18 15:55:48 +00:00
|
|
|
#elif defined(HAVE_NCURSES_H)
|
2000-06-06 05:53:49 +00:00
|
|
|
#include <ncurses.h>
|
2005-12-08 07:09:08 +00:00
|
|
|
#else
|
2003-09-10 20:08:00 +00:00
|
|
|
#include <curses.h>
|
2020-12-05 11:12:11 +00:00
|
|
|
#endif
|
2000-06-06 05:53:49 +00:00
|
|
|
|
2006-05-14 18:22:01 +00:00
|
|
|
/* Native language support. */
|
2020-12-06 10:49:37 +00:00
|
|
|
#ifdef ENABLE_NLS
|
2005-01-17 05:06:55 +00:00
|
|
|
#ifdef HAVE_LIBINTL_H
|
|
|
|
#include <libintl.h>
|
|
|
|
#endif
|
2020-05-29 16:45:14 +00:00
|
|
|
#define _(string) gettext(string)
|
|
|
|
#define P_(singular, plural, number) ngettext(singular, plural, number)
|
2002-10-17 02:19:31 +00:00
|
|
|
#else
|
2020-05-29 16:45:14 +00:00
|
|
|
#define _(string) (string)
|
|
|
|
#define P_(singular, plural, number) (number == 1 ? singular : plural)
|
2000-06-06 05:53:49 +00:00
|
|
|
#endif
|
2020-12-06 10:49:37 +00:00
|
|
|
/* For marking a string on which gettext() will be called later. */
|
2020-05-29 16:45:14 +00:00
|
|
|
#define gettext_noop(string) (string)
|
|
|
|
#define N_(string) gettext_noop(string)
|
2000-06-06 05:53:49 +00:00
|
|
|
|
2020-12-06 10:49:37 +00:00
|
|
|
/* If we aren't using an ncurses with mouse support, then
|
|
|
|
* exclude the mouse routines, as they are useless then. */
|
2003-10-03 20:26:25 +00:00
|
|
|
#ifndef NCURSES_MOUSE_VERSION
|
2017-05-01 18:45:07 +00:00
|
|
|
#undef ENABLE_MOUSE
|
2003-10-03 20:26:25 +00:00
|
|
|
#endif
|
2006-07-18 18:16:30 +00:00
|
|
|
|
2017-10-31 16:39:30 +00:00
|
|
|
#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY)
|
2020-05-29 16:45:14 +00:00
|
|
|
#define ENABLED_WRAPORJUSTIFY 1
|
2006-07-18 18:16:30 +00:00
|
|
|
#endif
|
2001-05-21 12:56:25 +00:00
|
|
|
|
2020-12-06 10:40:25 +00:00
|
|
|
/* 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)
|
|
|
|
|
2020-05-29 16:45:14 +00:00
|
|
|
#define BACKWARD FALSE
|
|
|
|
#define FORWARD TRUE
|
2017-08-31 20:14:06 +00:00
|
|
|
|
2020-05-29 16:45:14 +00:00
|
|
|
#define BLIND FALSE
|
|
|
|
#define VISIBLE TRUE
|
2017-09-20 20:20:18 +00:00
|
|
|
|
2020-05-29 16:45:14 +00:00
|
|
|
#define JUSTFIND 0
|
|
|
|
#define REPLACING 1
|
|
|
|
#define INREGION 2
|
2017-10-26 17:15:11 +00:00
|
|
|
|
2020-12-06 10:49:37 +00:00
|
|
|
/* In UTF-8 a character is at most six bytes long. */
|
|
|
|
#ifdef ENABLE_UTF8
|
|
|
|
#define MAXCHARLEN 6
|
|
|
|
#else
|
|
|
|
#define MAXCHARLEN 1
|
|
|
|
#endif
|
|
|
|
|
2020-12-06 11:30:52 +00:00
|
|
|
/* The default width of a tab in spaces. */
|
|
|
|
#define WIDTH_OF_TAB 8
|
|
|
|
|
|
|
|
/* The default number of columns from end of line where wrapping occurs. */
|
|
|
|
#define COLUMNS_FROM_EOL 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. */
|
|
|
|
#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)
|
|
|
|
|
2018-04-01 07:49:58 +00:00
|
|
|
#ifdef ENABLE_COLOR
|
2020-06-17 14:54:48 +00:00
|
|
|
#define THE_DEFAULT -1
|
2020-05-29 16:45:14 +00:00
|
|
|
#define BAD_COLOR -2
|
2020-12-06 10:40:25 +00:00
|
|
|
|
|
|
|
/* Flags for indicating how a multiline regex pair apply to a line. */
|
|
|
|
#define CNONE (1<<1)
|
|
|
|
/* The start/end regexes don't cover this line at all. */
|
|
|
|
#define CBEGINBEFORE (1<<2)
|
|
|
|
/* The start regex matches on an earlier line, the end regex on this one. */
|
|
|
|
#define CENDAFTER (1<<3)
|
|
|
|
/* The start regex matches on this line, the end regex on a later one. */
|
|
|
|
#define CWHOLELINE (1<<4)
|
|
|
|
/* The start regex matches on an earlier line, the end regex on a later one. */
|
|
|
|
#define CSTARTENDHERE (1<<5)
|
|
|
|
/* Both the start and end regexes match within this line. */
|
|
|
|
#define CWOULDBE (1<<6)
|
|
|
|
/* An unpaired start match is on or before this line. */
|
2018-04-01 07:49:58 +00:00
|
|
|
#endif
|
|
|
|
|
2020-12-06 11:30:52 +00:00
|
|
|
/* 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
|
|
|
|
|
|
|
|
/* A special keycode for plugging into the input stream after a suspension. */
|
|
|
|
#define KEY_FLUSH KEY_F0
|
|
|
|
|
|
|
|
#ifndef NANO_TINY
|
|
|
|
/* A special keycode for when we get a SIGWINCH (a 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 */
|
|
|
|
|
|
|
|
/* Identifiers for the different menus. */
|
|
|
|
#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
|
|
|
|
|
2004-11-04 04:08:18 +00:00
|
|
|
/* Enumeration types. */
|
|
|
|
typedef enum {
|
2017-12-29 18:27:33 +00:00
|
|
|
NIX_FILE, DOS_FILE, MAC_FILE
|
2019-10-02 15:09:22 +00:00
|
|
|
} format_type;
|
2004-11-04 04:08:18 +00:00
|
|
|
|
2016-05-19 18:43:08 +00:00
|
|
|
typedef enum {
|
2020-05-22 09:58:28 +00:00
|
|
|
VACUUM, HUSH, NOTICE, MILD, ALERT
|
2016-05-19 18:43:08 +00:00
|
|
|
} message_type;
|
|
|
|
|
2005-08-01 18:27:10 +00:00
|
|
|
typedef enum {
|
2017-12-29 18:27:33 +00:00
|
|
|
OVERWRITE, APPEND, PREPEND
|
2016-07-15 10:59:59 +00:00
|
|
|
} kind_of_writing_type;
|
2005-08-01 18:27:10 +00:00
|
|
|
|
2016-04-24 09:28:28 +00:00
|
|
|
typedef enum {
|
2017-12-29 18:27:33 +00:00
|
|
|
SOFTMARK, HARDMARK
|
2016-04-24 09:28:28 +00:00
|
|
|
} mark_type;
|
|
|
|
|
2004-11-04 04:08:18 +00:00
|
|
|
typedef enum {
|
2017-12-29 18:27:33 +00:00
|
|
|
CENTERING, FLOWING, STATIONARY
|
2005-08-01 18:27:10 +00:00
|
|
|
} update_type;
|
2004-11-04 04:08:18 +00:00
|
|
|
|
2020-12-06 11:30:52 +00:00
|
|
|
#ifndef NANO_TINY
|
2018-03-03 15:54:55 +00:00
|
|
|
/* The kinds of undo actions. ADD...REPLACE must come first. */
|
2008-07-10 20:13:04 +00:00
|
|
|
typedef enum {
|
tweaks: reshuffle the undo types into mostly the same order everywhere
First the two that add something (ADD, ENTER), then the three that
delete something (BACK, DEL, JOIN), and then the one that changes
something (REPLACE). Then the SPLITs, CUT, PASTE, and INSERT, and
then the INDENTs and COMMENTs, when they exist.
2018-03-05 09:05:07 +00:00
|
|
|
ADD, ENTER, BACK, DEL, JOIN, REPLACE,
|
2017-10-29 20:00:09 +00:00
|
|
|
#ifdef ENABLE_WRAPPING
|
2017-12-29 18:27:33 +00:00
|
|
|
SPLIT_BEGIN, SPLIT_END,
|
2016-05-25 20:13:50 +00:00
|
|
|
#endif
|
2017-12-29 18:27:33 +00:00
|
|
|
INDENT, UNINDENT,
|
2017-07-06 19:47:11 +00:00
|
|
|
#ifdef ENABLE_COMMENT
|
2017-12-29 18:27:33 +00:00
|
|
|
COMMENT, UNCOMMENT, PREFLIGHT,
|
2014-06-09 10:35:44 +00:00
|
|
|
#endif
|
2020-03-30 11:51:15 +00:00
|
|
|
ZAP, CUT, CUT_TO_EOF, COPY, PASTE, INSERT,
|
|
|
|
COUPLE_BEGIN, COUPLE_END, OTHER
|
2008-07-10 20:13:04 +00:00
|
|
|
} undo_type;
|
2020-12-06 11:30:52 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The elements of the interface that can be colored differently. */
|
|
|
|
enum {
|
|
|
|
TITLE_BAR = 0,
|
|
|
|
LINE_NUMBER,
|
|
|
|
GUIDE_STRIPE,
|
|
|
|
SCROLL_BAR,
|
|
|
|
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 = 0,
|
|
|
|
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,
|
|
|
|
BOOKSTYLE,
|
|
|
|
STATEFLAGS,
|
|
|
|
USE_MAGIC
|
|
|
|
};
|
2008-07-10 20:13:04 +00:00
|
|
|
|
2015-06-18 19:07:56 +00:00
|
|
|
/* Structure types. */
|
2017-11-01 18:45:33 +00:00
|
|
|
#ifdef ENABLE_COLOR
|
2005-07-13 20:18:46 +00:00
|
|
|
typedef struct colortype {
|
2020-03-02 18:36:10 +00:00
|
|
|
short id;
|
|
|
|
/* An ordinal number (if this color combo is for a multiline regex). */
|
2017-12-29 18:27:33 +00:00
|
|
|
short fg;
|
2020-03-02 18:36:10 +00:00
|
|
|
/* This combo's foreground color. */
|
2017-12-29 18:27:33 +00:00
|
|
|
short bg;
|
2020-03-02 18:36:10 +00:00
|
|
|
/* This combo's background color. */
|
2019-06-05 11:00:35 +00:00
|
|
|
short pairnum;
|
|
|
|
/* The pair number for this foreground/background color combination. */
|
2017-12-29 18:27:33 +00:00
|
|
|
int attributes;
|
|
|
|
/* Pair number and brightness composed into ready-to-use attributes. */
|
|
|
|
regex_t *start;
|
2019-06-05 11:00:35 +00:00
|
|
|
/* The compiled regular expression for 'start=', or the only one. */
|
2017-12-29 18:27:33 +00:00
|
|
|
regex_t *end;
|
2019-06-05 11:00:35 +00:00
|
|
|
/* The compiled regular expression for 'end=', if any. */
|
2017-12-29 18:27:33 +00:00
|
|
|
struct colortype *next;
|
2020-03-02 18:36:10 +00:00
|
|
|
/* Next color combination. */
|
2005-07-13 20:18:46 +00:00
|
|
|
} colortype;
|
|
|
|
|
2014-05-12 14:31:54 +00:00
|
|
|
typedef struct regexlisttype {
|
2017-12-29 18:27:33 +00:00
|
|
|
char *full_regex;
|
|
|
|
/* A regex string to match things that imply a certain syntax. */
|
|
|
|
struct regexlisttype *next;
|
|
|
|
/* The next regex. */
|
2014-05-12 14:31:54 +00:00
|
|
|
} regexlisttype;
|
2005-07-13 20:18:46 +00:00
|
|
|
|
2019-05-31 10:16:55 +00:00
|
|
|
typedef struct augmentstruct {
|
2019-05-14 00:01:59 +00:00
|
|
|
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. */
|
2019-05-31 10:16:55 +00:00
|
|
|
struct augmentstruct *next;
|
2019-05-14 00:01:59 +00:00
|
|
|
/* Next node. */
|
2019-05-31 10:16:55 +00:00
|
|
|
} augmentstruct;
|
2019-05-14 00:01:59 +00:00
|
|
|
|
2005-07-13 20:18:46 +00:00
|
|
|
typedef struct syntaxtype {
|
2017-12-29 18:27:33 +00:00
|
|
|
char *name;
|
|
|
|
/* The name of this syntax. */
|
2019-05-14 00:01:59 +00:00
|
|
|
char *filename;
|
|
|
|
/* File where the syntax is defined, or NULL if not an included file. */
|
2019-06-13 10:20:38 +00:00
|
|
|
size_t lineno;
|
|
|
|
/* The line number where the 'syntax' command was found. */
|
2020-12-06 11:30:52 +00:00
|
|
|
augmentstruct *augmentations;
|
2019-05-14 00:01:59 +00:00
|
|
|
/* List of extendsyntax commands to apply when loaded. */
|
2017-12-29 18:27:33 +00:00
|
|
|
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. */
|
2019-10-25 15:17:48 +00:00
|
|
|
char *formatter;
|
|
|
|
/* The command with which to format/modify/arrange this type of file. */
|
2018-10-29 19:40:55 +00:00
|
|
|
char *tab;
|
|
|
|
/* What the Tab key should produce; NULL for default behavior. */
|
2017-07-06 19:59:40 +00:00
|
|
|
#ifdef ENABLE_COMMENT
|
2017-12-29 18:27:33 +00:00
|
|
|
char *comment;
|
|
|
|
/* The line comment prefix (and postfix) for this type of file. */
|
2017-07-06 19:59:40 +00:00
|
|
|
#endif
|
2017-12-29 18:27:33 +00:00
|
|
|
colortype *color;
|
|
|
|
/* The colors and their regexes used in this syntax. */
|
2020-03-02 18:36:10 +00:00
|
|
|
short nmultis;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* How many multiline regex strings this syntax has. */
|
|
|
|
struct syntaxtype *next;
|
|
|
|
/* Next syntax. */
|
2005-07-13 20:18:46 +00:00
|
|
|
} syntaxtype;
|
2009-02-03 05:05:58 +00:00
|
|
|
|
2014-02-24 10:18:15 +00:00
|
|
|
typedef struct lintstruct {
|
2017-12-29 18:27:33 +00:00
|
|
|
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. */
|
2014-02-24 10:18:15 +00:00
|
|
|
} lintstruct;
|
2017-11-01 18:45:33 +00:00
|
|
|
#endif /* ENABLE_COLOR */
|
2005-07-13 20:18:46 +00:00
|
|
|
|
2015-06-18 19:07:56 +00:00
|
|
|
/* More structure types. */
|
2019-03-21 16:08:52 +00:00
|
|
|
typedef struct linestruct {
|
2017-12-29 18:27:33 +00:00
|
|
|
char *data;
|
|
|
|
/* The text of this line. */
|
|
|
|
ssize_t lineno;
|
|
|
|
/* The number of this line. */
|
2020-05-14 09:53:19 +00:00
|
|
|
#ifndef NANO_TINY
|
2020-06-06 16:57:17 +00:00
|
|
|
ssize_t extrarows;
|
|
|
|
/* The extra rows that this line occupies when softwrapping. */
|
2020-05-14 09:53:19 +00:00
|
|
|
#endif
|
2019-03-21 16:08:52 +00:00
|
|
|
struct linestruct *next;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Next node. */
|
2019-03-21 16:08:52 +00:00
|
|
|
struct linestruct *prev;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Previous node. */
|
2017-11-01 18:45:33 +00:00
|
|
|
#ifdef ENABLE_COLOR
|
2017-12-29 18:27:33 +00:00
|
|
|
short *multidata;
|
|
|
|
/* Array of which multi-line regexes apply to this line. */
|
2009-01-19 19:10:39 +00:00
|
|
|
#endif
|
new feature: bindable functions for toggling and jumping to "bookmarks"
With the 'bookmark' function, the user can place a bookmark on any
line in the buffer. Multiple lines can be bookmarked in this way.
With 'prevbookmark' and 'nextbookmark', the user can then easily
return to the bookmarked lines. The search for a bookmark wraps
around, as if start and end of buffer are connected.
[However, in this implementation, when a bookmarked line is deleted,
the bookmark is deleted too. This is undesirable. Also, when such
a deleted line is pasted elsewhere, the bookmark reappears with it,
and when pasted multiple times, the bookmark will be there as many
times. This is thoroughly undesirable. These behaviors will be
changed in a later commit.]
A bookmark is not yet visible in any way.
This fulfills https://savannah.gnu.org/bugs/?57577.
Requested-by: Ken Tyler <kent@werple.net.au>
Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-11-12 20:30:47 +00:00
|
|
|
#ifndef NANO_TINY
|
2020-04-06 15:42:29 +00:00
|
|
|
bool has_anchor;
|
|
|
|
/* Whether the user has placed an anchor at this line. */
|
new feature: bindable functions for toggling and jumping to "bookmarks"
With the 'bookmark' function, the user can place a bookmark on any
line in the buffer. Multiple lines can be bookmarked in this way.
With 'prevbookmark' and 'nextbookmark', the user can then easily
return to the bookmarked lines. The search for a bookmark wraps
around, as if start and end of buffer are connected.
[However, in this implementation, when a bookmarked line is deleted,
the bookmark is deleted too. This is undesirable. Also, when such
a deleted line is pasted elsewhere, the bookmark reappears with it,
and when pasted multiple times, the bookmark will be there as many
times. This is thoroughly undesirable. These behaviors will be
changed in a later commit.]
A bookmark is not yet visible in any way.
This fulfills https://savannah.gnu.org/bugs/?57577.
Requested-by: Ken Tyler <kent@werple.net.au>
Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-11-12 20:30:47 +00:00
|
|
|
#endif
|
2019-03-21 16:08:52 +00:00
|
|
|
} linestruct;
|
2009-01-19 19:10:39 +00:00
|
|
|
|
2008-07-10 20:13:04 +00:00
|
|
|
#ifndef NANO_TINY
|
2019-10-02 17:08:24 +00:00
|
|
|
typedef struct groupstruct {
|
2017-12-29 18:27:33 +00:00
|
|
|
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. */
|
2019-10-02 17:08:24 +00:00
|
|
|
struct groupstruct *next;
|
|
|
|
/* The next group, if any. */
|
|
|
|
} groupstruct;
|
2016-05-25 20:13:50 +00:00
|
|
|
|
2019-10-02 15:18:51 +00:00
|
|
|
typedef struct undostruct {
|
2017-12-29 18:27:33 +00:00
|
|
|
undo_type type;
|
2019-10-02 17:27:50 +00:00
|
|
|
/* The operation type that this undo item is for. */
|
|
|
|
int xflags;
|
|
|
|
/* Some flag data to mark certain corner cases. */
|
2020-02-25 15:47:50 +00:00
|
|
|
ssize_t head_lineno;
|
2019-10-02 17:27:50 +00:00
|
|
|
/* The line number where the operation began or ended. */
|
2020-02-25 15:47:50 +00:00
|
|
|
size_t head_x;
|
2019-10-02 17:27:50 +00:00
|
|
|
/* The x position where the operation began or ended. */
|
2017-12-29 18:27:33 +00:00
|
|
|
char *strdata;
|
2019-10-02 17:27:50 +00:00
|
|
|
/* String data to help restore the affected line. */
|
2017-12-29 18:27:33 +00:00
|
|
|
size_t wassize;
|
|
|
|
/* The file size before the action. */
|
|
|
|
size_t newsize;
|
|
|
|
/* The file size after the action. */
|
2019-10-02 17:08:24 +00:00
|
|
|
groupstruct *grouping;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Undo info specific to groups of lines. */
|
2019-03-21 16:08:52 +00:00
|
|
|
linestruct *cutbuffer;
|
2019-10-02 17:27:50 +00:00
|
|
|
/* A copy of the cutbuffer. */
|
2020-02-25 16:09:51 +00:00
|
|
|
ssize_t tail_lineno;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Mostly the line number of the current line; sometimes something else. */
|
2020-02-25 16:09:51 +00:00
|
|
|
size_t tail_x;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* The x position corresponding to the above line number. */
|
2019-10-02 15:18:51 +00:00
|
|
|
struct undostruct *next;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* A pointer to the undo item of the preceding action. */
|
2019-10-02 15:18:51 +00:00
|
|
|
} undostruct;
|
2014-06-19 20:05:24 +00:00
|
|
|
#endif /* !NANO_TINY */
|
2008-07-31 04:24:04 +00:00
|
|
|
|
2017-10-29 18:42:12 +00:00
|
|
|
#ifdef ENABLE_HISTORIES
|
2011-02-16 06:52:30 +00:00
|
|
|
typedef struct poshiststruct {
|
2017-12-29 18:27:33 +00:00
|
|
|
char *filename;
|
2020-09-22 08:12:43 +00:00
|
|
|
/* The full path plus name of the file. */
|
|
|
|
ssize_t linenumber;
|
|
|
|
/* The line where the cursor was when we closed the file. */
|
|
|
|
ssize_t columnnumber;
|
|
|
|
/* The column where the cursor was. */
|
2017-12-29 18:27:33 +00:00
|
|
|
struct poshiststruct *next;
|
2019-10-02 17:27:50 +00:00
|
|
|
/* The next item of position history. */
|
2011-02-16 06:52:30 +00:00
|
|
|
} poshiststruct;
|
2014-06-19 20:05:24 +00:00
|
|
|
#endif
|
2008-07-31 04:24:04 +00:00
|
|
|
|
2002-04-10 02:31:20 +00:00
|
|
|
typedef struct openfilestruct {
|
2017-12-29 18:27:33 +00:00
|
|
|
char *filename;
|
|
|
|
/* The file's name. */
|
2019-03-21 16:23:49 +00:00
|
|
|
linestruct *filetop;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* The file's first line. */
|
2019-03-21 16:08:52 +00:00
|
|
|
linestruct *filebot;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* The file's last line. */
|
2019-03-21 16:08:52 +00:00
|
|
|
linestruct *edittop;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* The current top of the edit window for this file. */
|
2019-03-21 16:08:52 +00:00
|
|
|
linestruct *current;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* 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. */
|
2020-05-28 12:31:15 +00:00
|
|
|
struct stat *statinfo;
|
|
|
|
/* The file's stat information from when it was opened or last saved. */
|
2019-04-21 15:31:29 +00:00
|
|
|
#ifdef ENABLE_WRAPPING
|
|
|
|
linestruct *spillage_line;
|
|
|
|
/* The line for prepending stuff to during automatic hard-wrapping. */
|
|
|
|
#endif
|
2005-11-15 03:17:35 +00:00
|
|
|
#ifndef NANO_TINY
|
2019-03-21 16:08:52 +00:00
|
|
|
linestruct *mark;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* 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. */
|
2019-10-02 15:09:22 +00:00
|
|
|
format_type fmt;
|
2020-05-12 15:17:28 +00:00
|
|
|
/* The file's format -- Unix or DOS or Mac. */
|
2019-10-02 17:27:50 +00:00
|
|
|
char *lock_filename;
|
|
|
|
/* The path of the lockfile, if we created one. */
|
2019-10-02 15:18:51 +00:00
|
|
|
undostruct *undotop;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* The top of the undo list. */
|
2019-10-02 15:18:51 +00:00
|
|
|
undostruct *current_undo;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* The current (i.e. next) level of undo. */
|
2019-10-02 15:18:51 +00:00
|
|
|
undostruct *last_saved;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* The undo item at which the file was last saved. */
|
|
|
|
undo_type last_action;
|
|
|
|
/* The type of the last action the user performed. */
|
2005-07-13 20:18:46 +00:00
|
|
|
#endif
|
2019-10-02 17:27:50 +00:00
|
|
|
bool modified;
|
|
|
|
/* Whether the file has been modified. */
|
2017-11-01 18:45:33 +00:00
|
|
|
#ifdef ENABLE_COLOR
|
2017-12-29 18:27:33 +00:00
|
|
|
syntaxtype *syntax;
|
2020-05-01 10:38:02 +00:00
|
|
|
/* The syntax that applies to this file, if any. */
|
2001-07-11 02:08:33 +00:00
|
|
|
#endif
|
2018-03-23 09:53:06 +00:00
|
|
|
#ifdef ENABLE_MULTIBUFFER
|
2017-12-29 18:27:33 +00:00
|
|
|
struct openfilestruct *next;
|
|
|
|
/* The next open file, if any. */
|
|
|
|
struct openfilestruct *prev;
|
|
|
|
/* The preceding open file, if any. */
|
2018-03-23 09:53:06 +00:00
|
|
|
#endif
|
2005-07-08 20:09:16 +00:00
|
|
|
} openfilestruct;
|
2001-07-11 02:08:33 +00:00
|
|
|
|
2017-05-08 17:42:44 +00:00
|
|
|
#ifdef ENABLE_NANORC
|
2001-04-18 04:28:54 +00:00
|
|
|
typedef struct rcoption {
|
2017-12-29 18:27:33 +00:00
|
|
|
const char *name;
|
|
|
|
/* The name of the rcfile option. */
|
|
|
|
long flag;
|
|
|
|
/* The flag associated with it, if any. */
|
2001-04-18 04:28:54 +00:00
|
|
|
} rcoption;
|
2004-11-03 14:58:04 +00:00
|
|
|
#endif
|
2001-04-18 04:28:54 +00:00
|
|
|
|
2019-04-03 15:34:05 +00:00
|
|
|
typedef struct keystruct {
|
2017-12-29 18:27:33 +00:00
|
|
|
const char *keystr;
|
2019-04-03 15:34:05 +00:00
|
|
|
/* The string that describes the keystroke, like "^C" or "M-R". */
|
2017-12-29 18:27:33 +00:00
|
|
|
int keycode;
|
|
|
|
/* The integer that, together with meta, identifies the keystroke. */
|
|
|
|
int menus;
|
2019-04-03 15:34:05 +00:00
|
|
|
/* The menus in which this keystroke is bound. */
|
2018-02-24 18:31:11 +00:00
|
|
|
void (*func)(void);
|
2019-04-03 15:34:05 +00:00
|
|
|
/* The function to which this keystroke is bound. */
|
2016-09-01 07:36:47 +00:00
|
|
|
#ifndef NANO_TINY
|
2017-12-29 18:27:33 +00:00
|
|
|
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. */
|
2018-02-14 16:47:08 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_NANORC
|
2018-01-20 12:01:43 +00:00
|
|
|
char *expansion;
|
|
|
|
/* The string of keycodes to which this shortcut is expanded. */
|
2016-09-01 07:36:47 +00:00
|
|
|
#endif
|
2019-04-03 15:34:05 +00:00
|
|
|
struct keystruct *next;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Next in the list. */
|
2019-04-03 15:34:05 +00:00
|
|
|
} keystruct;
|
2008-03-05 07:34:01 +00:00
|
|
|
|
2019-04-03 15:11:24 +00:00
|
|
|
typedef struct funcstruct {
|
2018-02-24 18:31:11 +00:00
|
|
|
void (*func)(void);
|
2017-12-29 18:27:33 +00:00
|
|
|
/* The actual function to call. */
|
|
|
|
const char *desc;
|
|
|
|
/* The function's short description, for example "Where Is". */
|
2017-04-25 15:51:45 +00:00
|
|
|
#ifdef ENABLE_HELP
|
2017-12-29 18:27:33 +00:00
|
|
|
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. */
|
2008-03-05 07:34:01 +00:00
|
|
|
#endif
|
2017-12-29 18:27:33 +00:00
|
|
|
bool viewok;
|
|
|
|
/* Is this function allowed when in view mode? */
|
2020-09-28 00:18:43 +00:00
|
|
|
int menus;
|
|
|
|
/* In what menus this function applies. */
|
2019-04-03 15:11:24 +00:00
|
|
|
struct funcstruct *next;
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Next item in the list. */
|
2019-04-03 15:11:24 +00:00
|
|
|
} funcstruct;
|
2008-03-05 07:34:01 +00:00
|
|
|
|
2016-12-07 12:10:40 +00:00
|
|
|
#ifdef ENABLE_WORDCOMPLETION
|
2016-12-07 04:13:47 +00:00
|
|
|
typedef struct completion_word {
|
2017-12-29 18:27:33 +00:00
|
|
|
char *word;
|
|
|
|
struct completion_word *next;
|
2016-12-07 04:13:47 +00:00
|
|
|
} completion_word;
|
|
|
|
#endif
|