2000-06-06 05:53:49 +00:00
|
|
|
/**************************************************************************
|
2016-08-29 15:10:49 +00:00
|
|
|
* nano.h -- This file is part of GNU nano. *
|
2000-06-06 05:53:49 +00:00
|
|
|
* *
|
2018-01-24 09:13:28 +00:00
|
|
|
* Copyright (C) 1999-2011, 2013-2018 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
|
|
|
* *
|
|
|
|
**************************************************************************/
|
|
|
|
|
2004-02-27 03:06:28 +00:00
|
|
|
#ifndef NANO_H
|
|
|
|
#define NANO_H 1
|
|
|
|
|
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
|
|
|
|
#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>
|
|
|
|
#define NANO_ROOT_UID 65535
|
|
|
|
#else
|
|
|
|
#define NANO_ROOT_UID 0
|
|
|
|
#endif
|
|
|
|
|
2000-06-06 05:53:49 +00:00
|
|
|
#ifdef HAVE_LIMITS_H
|
|
|
|
#include <limits.h>
|
|
|
|
#endif
|
|
|
|
|
2006-06-06 18:41:58 +00:00
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
|
2014-05-13 21:11:59 +00:00
|
|
|
/* Suppress warnings for __attribute__((warn_unused_result)). */
|
2009-12-02 03:24:18 +00:00
|
|
|
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
|
2016-04-30 15:31:43 +00:00
|
|
|
|
2014-05-15 13:11:55 +00:00
|
|
|
/* Macros for flags, indexing each bit in a small array. */
|
|
|
|
#define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))]
|
2016-07-22 13:35:22 +00:00
|
|
|
#define FLAGMASK(flag) ((unsigned)1 << ((flag) % (sizeof(unsigned) * 8)))
|
2009-08-14 03:18:29 +00:00
|
|
|
#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)
|
2000-06-06 05:53:49 +00:00
|
|
|
|
2007-01-01 05:15:32 +00:00
|
|
|
/* Macros for character allocation and more. */
|
2003-01-13 01:35:15 +00:00
|
|
|
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
|
2003-01-30 00:57:33 +00:00
|
|
|
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char))
|
2003-09-16 01:16:49 +00:00
|
|
|
#define charmove(dest, src, n) memmove(dest, src, (n) * sizeof(char))
|
2005-06-12 15:24:36 +00:00
|
|
|
#define charset(dest, src, n) memset(dest, src, (n) * sizeof(char))
|
2004-09-18 22:02:21 +00:00
|
|
|
|
2017-03-30 19:56:31 +00:00
|
|
|
/* In UTF-8 a character is at most six bytes long. */
|
|
|
|
#ifdef ENABLE_UTF8
|
|
|
|
#define MAXCHARLEN 6
|
|
|
|
#else
|
|
|
|
#define MAXCHARLEN 1
|
|
|
|
#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
|
2005-03-26 04:42:28 +00:00
|
|
|
#define PATH_MAX 4096
|
2002-06-28 22:45:14 +00:00
|
|
|
#endif
|
2000-06-06 05:53:49 +00:00
|
|
|
|
2007-12-18 15:55:48 +00:00
|
|
|
#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
|
2005-12-08 07:09:08 +00:00
|
|
|
/* Ncurses support. */
|
2013-01-10 03:29:59 +00:00
|
|
|
#elif defined(HAVE_NCURSESW_NCURSES_H)
|
|
|
|
#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
|
|
|
|
/* Curses support. */
|
2003-09-10 20:08:00 +00:00
|
|
|
#include <curses.h>
|
2000-06-06 05:53:49 +00:00
|
|
|
#endif /* CURSES_H */
|
|
|
|
|
2016-07-12 19:05:09 +00:00
|
|
|
#if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR < 6)
|
|
|
|
#define USING_OLD_NCURSES yes
|
|
|
|
#endif
|
|
|
|
|
2002-10-17 02:19:31 +00:00
|
|
|
#ifdef ENABLE_NLS
|
2006-05-14 18:22:01 +00:00
|
|
|
/* Native language support. */
|
2005-01-17 05:06:55 +00:00
|
|
|
#ifdef HAVE_LIBINTL_H
|
|
|
|
#include <libintl.h>
|
|
|
|
#endif
|
|
|
|
#define _(string) gettext(string)
|
|
|
|
#define P_(singular, plural, number) ngettext(singular, plural, number)
|
2002-10-17 02:19:31 +00:00
|
|
|
#else
|
2005-01-17 05:06:55 +00:00
|
|
|
#define _(string) (string)
|
|
|
|
#define P_(singular, plural, number) (number == 1 ? singular : plural)
|
2000-06-06 05:53:49 +00:00
|
|
|
#endif
|
2004-07-12 03:10:30 +00:00
|
|
|
#define gettext_noop(string) (string)
|
|
|
|
#define N_(string) gettext_noop(string)
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Mark a string that will be sent to gettext() later. */
|
2000-06-06 05:53:49 +00:00
|
|
|
|
2004-12-23 17:43:27 +00:00
|
|
|
#include <stddef.h>
|
2005-07-24 19:57:51 +00:00
|
|
|
#include <stdlib.h>
|
2002-06-28 22:45:14 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2005-07-24 19:57:51 +00:00
|
|
|
#include <dirent.h>
|
|
|
|
#include <regex.h>
|
2015-05-28 13:02:29 +00:00
|
|
|
#include <signal.h>
|
2005-07-24 19:57:51 +00:00
|
|
|
#include <assert.h>
|
2000-06-06 05:53:49 +00:00
|
|
|
|
2017-05-01 18:45:07 +00:00
|
|
|
/* If we aren't using an ncurses with mouse support, exclude any
|
|
|
|
* 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)
|
|
|
|
#define ENABLED_WRAPORJUSTIFY 1
|
2006-07-18 18:16:30 +00:00
|
|
|
#endif
|
2001-05-21 12:56:25 +00:00
|
|
|
|
2017-08-31 20:14:06 +00:00
|
|
|
#define BACKWARD FALSE
|
|
|
|
#define FORWARD TRUE
|
|
|
|
|
2017-09-20 20:20:18 +00:00
|
|
|
#define BLIND FALSE
|
|
|
|
#define VISIBLE TRUE
|
|
|
|
|
2017-10-26 17:15:11 +00:00
|
|
|
#define JUSTFIND 0
|
|
|
|
#define REPLACING 1
|
|
|
|
#define INREGION 2
|
|
|
|
|
2018-04-01 07:49:58 +00:00
|
|
|
#ifdef ENABLE_COLOR
|
|
|
|
#define USE_THE_DEFAULT -1
|
|
|
|
#define BAD_COLOR -2
|
|
|
|
#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
|
2004-11-04 04:08:18 +00:00
|
|
|
} file_format;
|
|
|
|
|
2016-05-19 18:43:08 +00:00
|
|
|
typedef enum {
|
2017-12-29 18:27:33 +00:00
|
|
|
HUSH, 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
|
|
|
|
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
|
2018-05-17 10:10:06 +00:00
|
|
|
CUT, CUT_TO_EOF, PASTE, INSERT, COUPLE_BEGIN, COUPLE_END, OTHER
|
2008-07-10 20:13:04 +00:00
|
|
|
} undo_type;
|
|
|
|
|
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 {
|
2017-12-29 18:27:33 +00:00
|
|
|
short fg;
|
|
|
|
/* This syntax's foreground color. */
|
|
|
|
short bg;
|
|
|
|
/* This syntax's background color. */
|
|
|
|
bool bright;
|
|
|
|
/* Is this color A_BOLD? */
|
|
|
|
int pairnum;
|
|
|
|
/* The color pair number used for this foreground color and
|
|
|
|
* background color. */
|
|
|
|
int attributes;
|
|
|
|
/* Pair number and brightness composed into ready-to-use attributes. */
|
|
|
|
int rex_flags;
|
|
|
|
/* The regex compilation flags (with or without REG_ICASE). */
|
|
|
|
char *start_regex;
|
|
|
|
/* The start (or all) of the regex string. */
|
|
|
|
regex_t *start;
|
|
|
|
/* The compiled start (or all) of the regex string. */
|
|
|
|
char *end_regex;
|
|
|
|
/* The end (if any) of the regex string. */
|
|
|
|
regex_t *end;
|
|
|
|
/* The compiled end (if any) of the regex string. */
|
|
|
|
struct colortype *next;
|
|
|
|
/* Next set of colors. */
|
|
|
|
int id;
|
|
|
|
/* Basic id for assigning to lines later. */
|
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
|
|
|
|
|
|
|
typedef struct syntaxtype {
|
2017-12-29 18:27:33 +00:00
|
|
|
char *name;
|
|
|
|
/* The name of this syntax. */
|
|
|
|
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;
|
2017-12-29 20:35:14 +00:00
|
|
|
/* The formatting command (for programming languages mainly). */
|
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. */
|
|
|
|
int nmultis;
|
|
|
|
/* 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;
|
|
|
|
|
2015-06-18 19:07:56 +00:00
|
|
|
/* Flags that indicate how a multiline regex applies to a line. */
|
2017-12-29 20:35:14 +00:00
|
|
|
#define CNONE (1<<1)
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Yay, regex doesn't apply to this line at all! */
|
2017-12-29 20:35:14 +00:00
|
|
|
#define CBEGINBEFORE (1<<2)
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Regex starts on an earlier line, ends on this one. */
|
2017-12-29 20:35:14 +00:00
|
|
|
#define CENDAFTER (1<<3)
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Regex starts on this line and ends on a later one. */
|
2017-12-29 20:35:14 +00:00
|
|
|
#define CWHOLELINE (1<<4)
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Whole line engulfed by the regex, start < me, end > me. */
|
2017-12-29 20:35:14 +00:00
|
|
|
#define CSTARTENDHERE (1<<5)
|
2017-12-29 18:27:33 +00:00
|
|
|
/* Regex starts and ends within this line. */
|
2017-12-29 20:35:14 +00:00
|
|
|
#define CWOULDBE (1<<6)
|
2017-12-29 18:27:33 +00:00
|
|
|
/* An unpaired start match on or before this line. */
|
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. */
|
2009-01-19 19:10:39 +00:00
|
|
|
typedef struct filestruct {
|
2017-12-29 18:27:33 +00:00
|
|
|
char *data;
|
|
|
|
/* The text of this line. */
|
|
|
|
ssize_t lineno;
|
|
|
|
/* The number of this line. */
|
|
|
|
struct filestruct *next;
|
|
|
|
/* Next node. */
|
|
|
|
struct filestruct *prev;
|
|
|
|
/* 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
|
|
|
|
} filestruct;
|
|
|
|
|
|
|
|
typedef struct partition {
|
2017-12-29 18:27:33 +00:00
|
|
|
filestruct *fileage;
|
|
|
|
/* The top line of this portion of the file. */
|
|
|
|
filestruct *top_prev;
|
|
|
|
/* The line before the top line of this portion of the file. */
|
|
|
|
char *top_data;
|
|
|
|
/* The text before the beginning of the top line of this portion
|
|
|
|
* of the file. */
|
|
|
|
filestruct *filebot;
|
|
|
|
/* The bottom line of this portion of the file. */
|
|
|
|
filestruct *bot_next;
|
|
|
|
/* The line after the bottom line of this portion of the
|
|
|
|
* file. */
|
|
|
|
char *bot_data;
|
|
|
|
/* The text after the end of the bottom line of this portion of
|
|
|
|
* the file. */
|
2009-01-19 19:10:39 +00:00
|
|
|
} partition;
|
|
|
|
|
2008-07-10 20:13:04 +00:00
|
|
|
#ifndef NANO_TINY
|
2016-05-25 20:13:50 +00:00
|
|
|
typedef struct undo_group {
|
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. */
|
|
|
|
struct undo_group *next;
|
2016-05-25 20:13:50 +00:00
|
|
|
} undo_group;
|
|
|
|
|
2008-07-10 20:13:04 +00:00
|
|
|
typedef struct undo {
|
2017-12-29 18:27:33 +00:00
|
|
|
ssize_t lineno;
|
|
|
|
undo_type type;
|
|
|
|
/* What type of undo this was. */
|
|
|
|
size_t begin;
|
|
|
|
/* Where did this action begin or end. */
|
|
|
|
char *strdata;
|
|
|
|
/* String type data we will use for copying the affected line back. */
|
|
|
|
size_t wassize;
|
|
|
|
/* The file size before the action. */
|
|
|
|
size_t newsize;
|
|
|
|
/* The file size after the action. */
|
|
|
|
int xflags;
|
|
|
|
/* Some flag data we need. */
|
|
|
|
undo_group *grouping;
|
|
|
|
/* Undo info specific to groups of lines. */
|
|
|
|
|
|
|
|
/* Cut-specific stuff we need. */
|
|
|
|
filestruct *cutbuffer;
|
|
|
|
/* Copy of the cutbuffer. */
|
|
|
|
filestruct *cutbottom;
|
|
|
|
/* Copy of cutbottom. */
|
|
|
|
ssize_t mark_begin_lineno;
|
|
|
|
/* Mostly the line number of the current line; sometimes something else. */
|
|
|
|
size_t mark_begin_x;
|
|
|
|
/* The x position corresponding to the above line number. */
|
|
|
|
struct undo *next;
|
|
|
|
/* A pointer to the undo item of the preceding action. */
|
2008-07-10 20:13:04 +00:00
|
|
|
} undo;
|
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;
|
|
|
|
/* The file. */
|
|
|
|
ssize_t lineno;
|
|
|
|
/* Line number we left off on. */
|
|
|
|
ssize_t xno;
|
|
|
|
/* x position in the file we left off on. */
|
|
|
|
struct poshiststruct *next;
|
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. */
|
|
|
|
filestruct *fileage;
|
|
|
|
/* The file's first line. */
|
|
|
|
filestruct *filebot;
|
|
|
|
/* The file's last line. */
|
|
|
|
filestruct *edittop;
|
|
|
|
/* The current top of the edit window for this file. */
|
|
|
|
filestruct *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. */
|
|
|
|
bool modified;
|
|
|
|
/* Whether the file has been modified. */
|
|
|
|
struct stat *current_stat;
|
|
|
|
/* The file's current stat information. */
|
2005-11-15 03:17:35 +00:00
|
|
|
#ifndef NANO_TINY
|
2017-12-29 18:27:33 +00:00
|
|
|
filestruct *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. */
|
|
|
|
file_format fmt;
|
|
|
|
/* The file's format -- Unix or DOS or Mac or mixed. */
|
|
|
|
undo *undotop;
|
|
|
|
/* The top of the undo list. */
|
|
|
|
undo *current_undo;
|
|
|
|
/* The current (i.e. next) level of undo. */
|
|
|
|
undo *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. */
|
|
|
|
char *lock_filename;
|
|
|
|
/* The path of the lockfile, if we created one. */
|
2005-07-13 20:18:46 +00:00
|
|
|
#endif
|
2017-11-01 18:45:33 +00:00
|
|
|
#ifdef ENABLE_COLOR
|
2017-12-29 18:27:33 +00:00
|
|
|
syntaxtype *syntax;
|
|
|
|
/* The syntax struct for this file, if any. */
|
|
|
|
colortype *colorstrings;
|
|
|
|
/* The file's associated colors. */
|
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
|
|
|
|
2008-03-05 07:34:01 +00:00
|
|
|
typedef struct sc {
|
2017-12-29 18:27:33 +00:00
|
|
|
const char *keystr;
|
|
|
|
/* The string that describes a keystroke, like "^C" or "M-R". */
|
|
|
|
bool meta;
|
|
|
|
/* Whether this is a Meta keystroke. */
|
|
|
|
int keycode;
|
|
|
|
/* The integer that, together with meta, identifies the keystroke. */
|
|
|
|
int menus;
|
|
|
|
/* Which menus this applies to. */
|
2018-02-24 18:31:11 +00:00
|
|
|
void (*func)(void);
|
2017-12-29 18:27:33 +00:00
|
|
|
/* The function we're going to run. */
|
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
|
2017-12-29 18:27:33 +00:00
|
|
|
struct sc *next;
|
|
|
|
/* Next in the list. */
|
2008-03-05 07:34:01 +00:00
|
|
|
} sc;
|
|
|
|
|
|
|
|
typedef struct subnfunc {
|
2018-02-24 18:31:11 +00:00
|
|
|
void (*func)(void);
|
2017-12-29 18:27:33 +00:00
|
|
|
/* 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". */
|
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? */
|
|
|
|
long toggle;
|
|
|
|
/* If this is a toggle, which toggle to affect. */
|
|
|
|
struct subnfunc *next;
|
|
|
|
/* Next item in the list. */
|
2008-03-05 07:34:01 +00:00
|
|
|
} subnfunc;
|
|
|
|
|
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
|
|
|
|
|
2014-05-03 18:24:45 +00:00
|
|
|
/* The elements of the interface that can be colored differently. */
|
|
|
|
enum
|
|
|
|
{
|
2017-12-29 18:27:33 +00:00
|
|
|
TITLE_BAR = 0,
|
|
|
|
LINE_NUMBER,
|
|
|
|
SELECTED_TEXT,
|
|
|
|
STATUS_BAR,
|
2018-02-20 08:50:54 +00:00
|
|
|
ERROR_MESSAGE,
|
2017-12-29 18:27:33 +00:00
|
|
|
KEY_COMBO,
|
|
|
|
FUNCTION_TAG,
|
|
|
|
NUMBER_OF_ELEMENTS
|
2014-05-03 18:24:45 +00:00
|
|
|
};
|
2008-03-05 07:34:01 +00:00
|
|
|
|
2014-05-15 13:11:55 +00:00
|
|
|
/* Enumeration used in the flags array. See the definition of FLAGMASK. */
|
2009-08-14 03:18:29 +00:00
|
|
|
enum
|
|
|
|
{
|
2017-12-29 18:27:33 +00:00
|
|
|
DONTUSE,
|
|
|
|
CASE_SENSITIVE,
|
|
|
|
CONSTANT_SHOW,
|
|
|
|
NO_HELP,
|
|
|
|
SUSPEND,
|
|
|
|
NO_WRAP,
|
|
|
|
AUTOINDENT,
|
|
|
|
VIEW_MODE,
|
|
|
|
USE_MOUSE,
|
|
|
|
USE_REGEXP,
|
|
|
|
TEMP_FILE,
|
|
|
|
CUT_FROM_CURSOR,
|
|
|
|
BACKWARDS_SEARCH,
|
|
|
|
MULTIBUFFER,
|
|
|
|
SMOOTH_SCROLL,
|
|
|
|
REBIND_DELETE,
|
|
|
|
REBIND_KEYPAD,
|
|
|
|
NO_CONVERT,
|
|
|
|
BACKUP_FILE,
|
|
|
|
INSECURE_BACKUP,
|
|
|
|
NO_COLOR_SYNTAX,
|
|
|
|
PRESERVE,
|
|
|
|
HISTORYLOG,
|
|
|
|
RESTRICTED,
|
|
|
|
SMART_HOME,
|
|
|
|
WHITESPACE_DISPLAY,
|
|
|
|
MORE_SPACE,
|
|
|
|
TABS_TO_SPACES,
|
|
|
|
QUICK_BLANK,
|
|
|
|
WORD_BOUNDS,
|
|
|
|
NO_NEWLINES,
|
|
|
|
BOLD_TEXT,
|
|
|
|
QUIET,
|
|
|
|
SOFTWRAP,
|
|
|
|
POS_HISTORY,
|
|
|
|
LOCKING,
|
|
|
|
NOREAD_MODE,
|
|
|
|
MAKE_IT_UNIX,
|
|
|
|
TRIM_BLANKS,
|
|
|
|
SHOW_CURSOR,
|
|
|
|
LINE_NUMBERS,
|
|
|
|
NO_PAUSES,
|
2018-04-30 20:10:27 +00:00
|
|
|
AT_BLANKS,
|
|
|
|
AFTER_ENDS
|
2009-08-14 03:18:29 +00:00
|
|
|
};
|
2000-06-06 05:53:49 +00:00
|
|
|
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Flags for the menus in which a given function should be present. */
|
2017-12-29 20:35:14 +00:00
|
|
|
#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 MEXTCMD (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)
|
2014-04-16 09:12:13 +00:00
|
|
|
/* This is an abbreviation for all menus except Help and YesNo. */
|
2015-11-02 10:40:06 +00:00
|
|
|
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
|
2017-12-29 20:35:14 +00:00
|
|
|
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
|
2017-06-04 09:05:08 +00:00
|
|
|
#ifndef NANO_TINY
|
|
|
|
#define MSOME MMOST
|
|
|
|
#else
|
|
|
|
#define MSOME MMAIN|MBROWSER
|
|
|
|
#endif
|
2008-03-05 07:34:01 +00:00
|
|
|
|
2016-08-01 10:56:05 +00:00
|
|
|
/* Basic control codes. */
|
|
|
|
#define TAB_CODE 0x09
|
|
|
|
#define ESC_CODE 0x1B
|
|
|
|
#define DEL_CODE 0x7F
|
2000-06-06 05:53:49 +00:00
|
|
|
|
2015-11-23 08:52:23 +00:00
|
|
|
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
|
|
|
|
#define CONTROL_LEFT 0x401
|
|
|
|
#define CONTROL_RIGHT 0x402
|
2016-06-25 13:16:52 +00:00
|
|
|
#define CONTROL_UP 0x403
|
|
|
|
#define CONTROL_DOWN 0x404
|
2017-08-14 08:42:09 +00:00
|
|
|
#define CONTROL_HOME 0x405
|
|
|
|
#define CONTROL_END 0x406
|
|
|
|
#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 ALT_LEFT 0x421
|
|
|
|
#define ALT_RIGHT 0x422
|
|
|
|
#define ALT_UP 0x423
|
|
|
|
#define ALT_DOWN 0x424
|
|
|
|
#define SHIFT_ALT_LEFT 0x431
|
|
|
|
#define SHIFT_ALT_RIGHT 0x432
|
|
|
|
#define SHIFT_ALT_UP 0x433
|
|
|
|
#define SHIFT_ALT_DOWN 0x434
|
|
|
|
#define SHIFT_HOME 0x455
|
|
|
|
#define SHIFT_END 0x456
|
|
|
|
#define SHIFT_PAGEUP 0x457
|
|
|
|
#define SHIFT_PAGEDOWN 0x458
|
2017-12-12 20:43:03 +00:00
|
|
|
#define SHIFT_TAB 0x45F
|
2008-07-14 07:18:22 +00:00
|
|
|
|
2017-07-16 11:14:16 +00:00
|
|
|
#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
|
|
|
|
|
2014-04-21 12:31:52 +00:00
|
|
|
#ifndef NANO_TINY
|
2015-05-28 13:02:29 +00:00
|
|
|
/* An imaginary key for when we get a SIGWINCH (window resize). */
|
|
|
|
#define KEY_WINCH -2
|
|
|
|
|
2015-06-27 09:27:19 +00:00
|
|
|
/* Some extra flags for the undo function. */
|
2017-12-29 20:35:14 +00:00
|
|
|
#define WAS_FINAL_BACKSPACE (1<<1)
|
|
|
|
#define WAS_WHOLE_LINE (1<<2)
|
|
|
|
#define WAS_FINAL_LINE (1<<3)
|
|
|
|
#define MARK_WAS_SET (1<<4)
|
|
|
|
#define WAS_MARKED_FORWARD (1<<5)
|
2009-01-28 05:11:57 +00:00
|
|
|
#endif /* !NANO_TINY */
|
|
|
|
|
2006-05-10 13:41:53 +00:00
|
|
|
/* The maximum number of entries displayed in the main shortcut list. */
|
2014-03-16 16:58:18 +00:00
|
|
|
#define MAIN_VISIBLE (((COLS + 40) / 20) * 2)
|
2006-05-10 13:41:53 +00:00
|
|
|
|
2005-12-08 07:09:08 +00:00
|
|
|
/* The default number of characters from the end of the line where
|
|
|
|
* wrapping occurs. */
|
2001-01-14 05:18:27 +00:00
|
|
|
#define CHARS_FROM_EOL 8
|
|
|
|
|
2005-12-08 07:09:08 +00:00
|
|
|
/* The default width of a tab in spaces. */
|
2004-09-05 21:40:31 +00:00
|
|
|
#define WIDTH_OF_TAB 8
|
|
|
|
|
2017-07-02 06:46:59 +00:00
|
|
|
/* The default comment character when a syntax does not specify any. */
|
|
|
|
#define GENERAL_COMMENT_CHARACTER "#"
|
|
|
|
|
2005-12-08 07:09:08 +00:00
|
|
|
/* The maximum number of search/replace history strings saved, not
|
|
|
|
* counting the blank lines at their ends. */
|
2003-01-05 20:41:21 +00:00
|
|
|
#define MAX_SEARCH_HISTORY 100
|
2003-01-13 01:35:15 +00:00
|
|
|
|
2006-03-19 19:25:29 +00:00
|
|
|
/* The maximum number of bytes buffered at one time. */
|
2005-04-19 21:47:01 +00:00
|
|
|
#define MAX_BUF_SIZE 128
|
|
|
|
|
2016-06-01 19:29:44 +00:00
|
|
|
/* The largest size_t number that doesn't have the high bit set. */
|
|
|
|
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
|
|
|
|
|
2002-07-29 23:46:38 +00:00
|
|
|
#endif /* !NANO_H */
|