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
|
|
|
* *
|
2017-04-09 10:09:23 +00:00
|
|
|
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
|
2016-08-29 13:14:18 +00:00
|
|
|
* Copyright (C) 2014, 2015, 2016 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
|
|
|
|
|
2009-03-01 00:50:19 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
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)
|
2005-03-21 06:33:41 +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
|
|
|
|
2006-07-18 18:25:56 +00:00
|
|
|
#if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY)
|
|
|
|
#define DISABLE_WRAPJUSTIFY 1
|
2006-07-18 18:16:30 +00:00
|
|
|
#endif
|
2001-05-21 12:56:25 +00:00
|
|
|
|
2004-11-04 04:08:18 +00:00
|
|
|
/* Enumeration types. */
|
|
|
|
typedef enum {
|
|
|
|
NIX_FILE, DOS_FILE, MAC_FILE
|
|
|
|
} file_format;
|
|
|
|
|
2016-05-19 18:43:08 +00:00
|
|
|
typedef enum {
|
|
|
|
HUSH, MILD, ALERT
|
|
|
|
} message_type;
|
|
|
|
|
2005-08-01 18:27:10 +00:00
|
|
|
typedef enum {
|
|
|
|
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 {
|
|
|
|
SOFTMARK, HARDMARK
|
|
|
|
} mark_type;
|
|
|
|
|
2004-11-04 04:08:18 +00:00
|
|
|
typedef enum {
|
2014-06-23 18:20:12 +00:00
|
|
|
UPWARD, DOWNWARD
|
2005-08-01 18:27:10 +00:00
|
|
|
} scroll_dir;
|
2004-11-04 04:08:18 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2016-04-07 11:58:51 +00:00
|
|
|
CENTERING, FLOWING, STATIONARY
|
2005-08-01 18:27:10 +00:00
|
|
|
} update_type;
|
2004-11-04 04:08:18 +00:00
|
|
|
|
2008-07-10 20:13:04 +00:00
|
|
|
typedef enum {
|
2014-06-09 10:35:44 +00:00
|
|
|
ADD, DEL, BACK, CUT, CUT_EOF, REPLACE,
|
|
|
|
#ifndef DISABLE_WRAPPING
|
|
|
|
SPLIT_BEGIN, SPLIT_END,
|
2016-05-25 20:13:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef DISABLE_COMMENT
|
|
|
|
COMMENT, UNCOMMENT, PREFLIGHT,
|
2014-06-09 10:35:44 +00:00
|
|
|
#endif
|
2014-06-18 20:11:52 +00:00
|
|
|
JOIN, PASTE, INSERT, ENTER, OTHER
|
2008-07-10 20:13:04 +00:00
|
|
|
} undo_type;
|
|
|
|
|
2015-06-18 19:07:56 +00:00
|
|
|
/* Structure types. */
|
2014-04-04 11:59:03 +00:00
|
|
|
#ifndef DISABLE_COLOR
|
2005-07-13 20:18:46 +00:00
|
|
|
typedef struct colortype {
|
2013-03-17 22:09:38 +00:00
|
|
|
short fg;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* This syntax's foreground color. */
|
2013-03-17 22:09:38 +00:00
|
|
|
short bg;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* 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. */
|
2016-07-17 13:29:07 +00:00
|
|
|
int attributes;
|
|
|
|
/* Pair number and brightness composed into ready-to-use attributes. */
|
2016-03-13 19:37:21 +00:00
|
|
|
int rex_flags;
|
|
|
|
/* The regex compilation flags (with or without REG_ICASE). */
|
2005-12-08 07:09:08 +00:00
|
|
|
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. */
|
2005-07-13 20:18:46 +00:00
|
|
|
struct colortype *next;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* Next set of colors. */
|
2014-04-14 09:57:06 +00:00
|
|
|
int id;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* 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 {
|
2016-02-26 20:09:29 +00:00
|
|
|
char *full_regex;
|
|
|
|
/* A regex string to match things that imply a certain syntax. */
|
2014-05-12 14:31:54 +00:00
|
|
|
struct regexlisttype *next;
|
2016-02-26 20:19:13 +00:00
|
|
|
/* The next regex. */
|
2014-05-12 14:31:54 +00:00
|
|
|
} regexlisttype;
|
2005-07-13 20:18:46 +00:00
|
|
|
|
|
|
|
typedef struct syntaxtype {
|
2016-02-29 09:17:03 +00:00
|
|
|
char *name;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* The name of this syntax. */
|
2014-05-12 14:31:54 +00:00
|
|
|
regexlisttype *extensions;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* The list of extensions that this syntax applies to. */
|
2014-05-12 14:31:54 +00:00
|
|
|
regexlisttype *headers;
|
2014-05-12 13:52:50 +00:00
|
|
|
/* The list of headerlines that this syntax applies to. */
|
2014-05-12 14:31:54 +00:00
|
|
|
regexlisttype *magics;
|
2014-05-12 13:52:50 +00:00
|
|
|
/* The list of libmagic results that this syntax applies to. */
|
2014-02-24 10:18:15 +00:00
|
|
|
char *linter;
|
2016-02-29 10:54:48 +00:00
|
|
|
/* The command with which to lint this type of file. */
|
2015-01-03 07:24:17 +00:00
|
|
|
char *formatter;
|
2016-02-29 10:54:48 +00:00
|
|
|
/* The formatting command (for programming languages mainly). */
|
2016-05-25 20:13:50 +00:00
|
|
|
char *comment;
|
|
|
|
/* The line comment prefix (and postfix) for this type of file. */
|
2016-02-29 10:54:48 +00:00
|
|
|
colortype *color;
|
|
|
|
/* The colors and their regexes used in this syntax. */
|
2009-01-25 07:25:17 +00:00
|
|
|
int nmultis;
|
2016-02-29 10:54:48 +00:00
|
|
|
/* How many multiline regex strings this syntax has. */
|
2005-07-13 20:18:46 +00:00
|
|
|
struct syntaxtype *next;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* 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 {
|
|
|
|
ssize_t lineno;
|
|
|
|
/* Line number of the error. */
|
|
|
|
ssize_t colno;
|
|
|
|
/* Column # of the error. */
|
|
|
|
char *msg;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Error message text. */
|
2014-02-24 10:18:15 +00:00
|
|
|
char *filename;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Filename. */
|
2014-02-24 10:18:15 +00:00
|
|
|
struct lintstruct *next;
|
|
|
|
/* Next error. */
|
|
|
|
struct lintstruct *prev;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* 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. */
|
2014-03-17 21:36:37 +00:00
|
|
|
#define CNONE (1<<1)
|
2009-02-03 05:05:58 +00:00
|
|
|
/* Yay, regex doesn't apply to this line at all! */
|
2014-03-17 21:36:37 +00:00
|
|
|
#define CBEGINBEFORE (1<<2)
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Regex starts on an earlier line, ends on this one. */
|
2014-03-17 21:36:37 +00:00
|
|
|
#define CENDAFTER (1<<3)
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Regex starts on this line and ends on a later one. */
|
2014-03-17 21:36:37 +00:00
|
|
|
#define CWHOLELINE (1<<4)
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Whole line engulfed by the regex, start < me, end > me. */
|
2014-03-17 21:36:37 +00:00
|
|
|
#define CSTARTENDHERE (1<<5)
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Regex starts and ends within this line. */
|
2017-02-12 21:34:31 +00:00
|
|
|
#define CWOULDBE (1<<6)
|
|
|
|
/* An unpaired start match on or before this line. */
|
2014-04-04 11:59:03 +00:00
|
|
|
#endif /* !DISABLE_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 {
|
|
|
|
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. */
|
2014-04-04 11:59:03 +00:00
|
|
|
#ifndef DISABLE_COLOR
|
2014-04-04 12:29:28 +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 {
|
|
|
|
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. */
|
|
|
|
} partition;
|
|
|
|
|
2008-07-10 20:13:04 +00:00
|
|
|
#ifndef NANO_TINY
|
2016-05-25 20:13:50 +00:00
|
|
|
typedef struct undo_group {
|
|
|
|
ssize_t top_line;
|
|
|
|
/* First line of group. */
|
|
|
|
ssize_t bottom_line;
|
|
|
|
/* Last line of group. */
|
|
|
|
struct undo_group *next;
|
|
|
|
} undo_group;
|
|
|
|
|
2008-07-10 20:13:04 +00:00
|
|
|
typedef struct undo {
|
2008-07-31 04:24:04 +00:00
|
|
|
ssize_t lineno;
|
2008-07-10 20:13:04 +00:00
|
|
|
undo_type type;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* What type of undo this was. */
|
2014-05-15 20:00:46 +00:00
|
|
|
size_t begin;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Where did this action begin or end. */
|
2008-07-10 20:13:04 +00:00
|
|
|
char *strdata;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* String type data we will use for copying the affected line back. */
|
2015-11-30 16:21:51 +00:00
|
|
|
size_t wassize;
|
|
|
|
/* The file size before the action. */
|
|
|
|
size_t newsize;
|
|
|
|
/* The file size after the action. */
|
2008-07-14 07:18:22 +00:00
|
|
|
int xflags;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Some flag data we need. */
|
2016-05-25 20:13:50 +00:00
|
|
|
undo_group *grouping;
|
|
|
|
/* Undo info specific to groups of lines. */
|
2008-07-31 04:24:04 +00:00
|
|
|
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Cut-specific stuff we need. */
|
2008-07-31 04:24:04 +00:00
|
|
|
filestruct *cutbuffer;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Copy of the cutbuffer. */
|
2008-07-31 04:24:04 +00:00
|
|
|
filestruct *cutbottom;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Copy of cutbottom. */
|
2008-07-31 04:24:04 +00:00
|
|
|
ssize_t mark_begin_lineno;
|
2016-06-07 09:52:57 +00:00
|
|
|
/* Mostly the line number of the current line; sometimes something else. */
|
2014-05-15 20:00:46 +00:00
|
|
|
size_t mark_begin_x;
|
2016-06-07 09:52:57 +00:00
|
|
|
/* The x position corresponding to the above line number. */
|
2008-07-31 04:24:04 +00:00
|
|
|
struct undo *next;
|
2016-06-07 09:52:57 +00:00
|
|
|
/* 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
|
|
|
|
2014-06-19 20:05:24 +00:00
|
|
|
#ifndef DISABLE_HISTORIES
|
2011-02-16 06:52:30 +00:00
|
|
|
typedef struct poshiststruct {
|
|
|
|
char *filename;
|
2014-04-16 09:32:53 +00:00
|
|
|
/* The file. */
|
2011-02-16 06:52:30 +00:00
|
|
|
ssize_t lineno;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Line number we left off on. */
|
2011-02-16 06:52:30 +00:00
|
|
|
ssize_t xno;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* x position in the file we left off on. */
|
2011-02-16 06:52:30 +00:00
|
|
|
struct poshiststruct *next;
|
|
|
|
} 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 {
|
2005-12-08 07:09:08 +00:00
|
|
|
char *filename;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The file's name. */
|
2005-12-08 07:09:08 +00:00
|
|
|
filestruct *fileage;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The file's first line. */
|
2005-12-08 07:09:08 +00:00
|
|
|
filestruct *filebot;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The file's last line. */
|
2005-12-08 07:09:08 +00:00
|
|
|
filestruct *edittop;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The current top of the edit window for this file. */
|
2005-12-08 07:09:08 +00:00
|
|
|
filestruct *current;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The current line for this file. */
|
2005-12-08 07:09:08 +00:00
|
|
|
size_t totsize;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The file's total number of characters. */
|
2017-01-21 16:54:47 +00:00
|
|
|
size_t firstcolumn;
|
|
|
|
/* The starting column of the top line of the edit window.
|
|
|
|
* When not in softwrap mode, it's always zero. */
|
2005-12-08 07:09:08 +00:00
|
|
|
size_t current_x;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The file's x-coordinate position. */
|
2005-12-08 07:09:08 +00:00
|
|
|
size_t placewewant;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The file's x position we would like. */
|
2005-12-08 07:09:08 +00:00
|
|
|
ssize_t current_y;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The file's y-coordinate position. */
|
2005-12-08 07:09:08 +00:00
|
|
|
bool modified;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* Whether the file has been modified. */
|
2016-08-02 15:26:25 +00:00
|
|
|
struct stat *current_stat;
|
|
|
|
/* The file's current stat information. */
|
2005-11-15 03:17:35 +00:00
|
|
|
#ifndef NANO_TINY
|
2005-12-08 07:09:08 +00:00
|
|
|
bool mark_set;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* Whether the mark is on in this file. */
|
2005-12-08 07:09:08 +00:00
|
|
|
filestruct *mark_begin;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The file's line where the mark is, if any. */
|
2005-12-08 07:09:08 +00:00
|
|
|
size_t mark_begin_x;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The file's mark's x-coordinate position, if any. */
|
2016-04-24 09:28:28 +00:00
|
|
|
mark_type kind_of_mark;
|
|
|
|
/* Whether this is a soft or a hard mark. */
|
2005-12-08 07:09:08 +00:00
|
|
|
file_format fmt;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The file's format. */
|
2008-07-10 20:13:04 +00:00
|
|
|
undo *undotop;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The top of the undo list. */
|
2008-07-10 20:13:04 +00:00
|
|
|
undo *current_undo;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* The current (i.e. next) level of undo. */
|
2008-07-10 20:13:04 +00:00
|
|
|
undo_type last_action;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The type of the last action the user performed. */
|
2015-07-10 15:54:06 +00:00
|
|
|
char *lock_filename;
|
2014-04-16 09:32:53 +00:00
|
|
|
/* The path of the lockfile, if we created one. */
|
2005-07-13 20:18:46 +00:00
|
|
|
#endif
|
2014-04-04 11:59:03 +00:00
|
|
|
#ifndef DISABLE_COLOR
|
2009-01-25 07:25:17 +00:00
|
|
|
syntaxtype *syntax;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* The syntax struct for this file, if any. */
|
2005-12-08 07:09:08 +00:00
|
|
|
colortype *colorstrings;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The file's associated colors. */
|
2001-07-11 02:08:33 +00:00
|
|
|
#endif
|
2005-07-08 20:09:16 +00:00
|
|
|
struct openfilestruct *next;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The next open file, if any. */
|
2005-07-08 20:09:16 +00:00
|
|
|
struct openfilestruct *prev;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The preceding open file, if any. */
|
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 {
|
2016-05-30 07:09:36 +00:00
|
|
|
const char *name;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* The name of the rcfile option. */
|
2016-05-30 07:09:36 +00:00
|
|
|
long flag;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* 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 {
|
2016-07-30 10:44:23 +00:00
|
|
|
const char *keystr;
|
2016-07-24 19:49:07 +00:00
|
|
|
/* The string that describes a keystroke, like "^C" or "M-R". */
|
2016-07-23 12:42:40 +00:00
|
|
|
bool meta;
|
|
|
|
/* Whether this is a Meta keystroke. */
|
2016-07-24 19:49:07 +00:00
|
|
|
int keycode;
|
|
|
|
/* The integer that, together with meta, identifies the keystroke. */
|
2015-07-15 20:13:05 +00:00
|
|
|
int menus;
|
|
|
|
/* Which menus this applies to. */
|
2011-02-07 14:45:56 +00:00
|
|
|
void (*scfunc)(void);
|
2014-04-16 09:32:53 +00:00
|
|
|
/* The function we're going to run. */
|
2016-09-01 07:36:47 +00:00
|
|
|
#ifndef NANO_TINY
|
2008-03-05 07:34:01 +00:00
|
|
|
int toggle;
|
2014-04-16 09:32:53 +00:00
|
|
|
/* If a toggle, what we're toggling. */
|
2015-07-06 17:51:17 +00:00
|
|
|
int ordinal;
|
|
|
|
/* The how-manieth toggle this is, in order to be able to
|
|
|
|
* keep them in sequence. */
|
2016-09-01 07:36:47 +00:00
|
|
|
#endif
|
2008-03-05 07:34:01 +00:00
|
|
|
struct sc *next;
|
2014-04-16 09:32:53 +00:00
|
|
|
/* Next in the list. */
|
2008-03-05 07:34:01 +00:00
|
|
|
} sc;
|
|
|
|
|
|
|
|
typedef struct subnfunc {
|
2011-02-07 14:45:56 +00:00
|
|
|
void (*scfunc)(void);
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The actual function to call. */
|
2008-03-05 07:34:01 +00:00
|
|
|
int menus;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* In what menus this function applies. */
|
2008-03-05 07:34:01 +00:00
|
|
|
const char *desc;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The function's short description, for example "Where Is". */
|
2017-04-25 15:51:45 +00:00
|
|
|
#ifdef ENABLE_HELP
|
2008-03-05 07:34:01 +00:00
|
|
|
const char *help;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* The help-screen text for this function. */
|
2008-03-05 07:34:01 +00:00
|
|
|
bool blank_after;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* Whether there should be a blank line after the help text
|
|
|
|
* for this function. */
|
2008-03-05 07:34:01 +00:00
|
|
|
#endif
|
|
|
|
bool viewok;
|
2014-04-16 09:32:53 +00:00
|
|
|
/* Is this function allowed when in view mode? */
|
2008-03-05 07:34:01 +00:00
|
|
|
long toggle;
|
2015-11-02 10:40:06 +00:00
|
|
|
/* If this is a toggle, which toggle to affect. */
|
2008-03-05 07:34:01 +00:00
|
|
|
struct subnfunc *next;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* 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 {
|
|
|
|
char *word;
|
|
|
|
struct completion_word *next;
|
|
|
|
} completion_word;
|
|
|
|
#endif
|
|
|
|
|
2014-05-03 18:24:45 +00:00
|
|
|
/* The elements of the interface that can be colored differently. */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TITLE_BAR = 0,
|
2016-10-20 08:07:48 +00:00
|
|
|
LINE_NUMBER,
|
2014-05-03 18:24:45 +00:00
|
|
|
STATUS_BAR,
|
|
|
|
KEY_COMBO,
|
|
|
|
FUNCTION_TAG,
|
|
|
|
NUMBER_OF_ELEMENTS
|
|
|
|
};
|
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
|
|
|
|
{
|
2009-11-07 16:56:17 +00:00
|
|
|
DONTUSE,
|
2009-08-14 03:18:29 +00:00
|
|
|
CASE_SENSITIVE,
|
2017-04-17 09:51:48 +00:00
|
|
|
CONSTANT_SHOW,
|
2009-08-14 03:18:29 +00:00
|
|
|
NO_HELP,
|
|
|
|
SUSPEND,
|
|
|
|
NO_WRAP,
|
|
|
|
AUTOINDENT,
|
|
|
|
VIEW_MODE,
|
|
|
|
USE_MOUSE,
|
|
|
|
USE_REGEXP,
|
|
|
|
TEMP_FILE,
|
|
|
|
CUT_TO_END,
|
|
|
|
BACKWARDS_SEARCH,
|
|
|
|
MULTIBUFFER,
|
|
|
|
SMOOTH_SCROLL,
|
|
|
|
REBIND_DELETE,
|
|
|
|
REBIND_KEYPAD,
|
|
|
|
NO_CONVERT,
|
|
|
|
BACKUP_FILE,
|
2010-06-21 03:10:10 +00:00
|
|
|
INSECURE_BACKUP,
|
2009-08-14 03:18:29 +00:00
|
|
|
NO_COLOR_SYNTAX,
|
|
|
|
PRESERVE,
|
|
|
|
HISTORYLOG,
|
|
|
|
RESTRICTED,
|
|
|
|
SMART_HOME,
|
|
|
|
WHITESPACE_DISPLAY,
|
|
|
|
MORE_SPACE,
|
|
|
|
TABS_TO_SPACES,
|
|
|
|
QUICK_BLANK,
|
|
|
|
WORD_BOUNDS,
|
|
|
|
NO_NEWLINES,
|
|
|
|
BOLD_TEXT,
|
|
|
|
QUIET,
|
2011-02-16 06:52:30 +00:00
|
|
|
SOFTWRAP,
|
2013-01-01 03:24:39 +00:00
|
|
|
POS_HISTORY,
|
2014-04-08 18:59:30 +00:00
|
|
|
LOCKING,
|
2015-08-04 18:49:57 +00:00
|
|
|
NOREAD_MODE,
|
2016-02-22 15:10:32 +00:00
|
|
|
MAKE_IT_UNIX,
|
2016-09-11 07:41:09 +00:00
|
|
|
JUSTIFY_TRIM,
|
2016-10-20 08:44:29 +00:00
|
|
|
SHOW_CURSOR,
|
2017-03-06 21:07:57 +00:00
|
|
|
LINE_NUMBERS,
|
|
|
|
NO_PAUSES
|
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. */
|
2014-04-16 09:32:53 +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)
|
2017-04-22 16:27:01 +00:00
|
|
|
#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-04-22 16:27:01 +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-04-05 09:22:35 +00:00
|
|
|
#define CONTROL_HOME 0x411
|
|
|
|
#define CONTROL_END 0x412
|
2016-04-24 09:28:28 +00:00
|
|
|
#define SHIFT_CONTROL_LEFT 0x405
|
|
|
|
#define SHIFT_CONTROL_RIGHT 0x406
|
|
|
|
#define SHIFT_CONTROL_UP 0x407
|
|
|
|
#define SHIFT_CONTROL_DOWN 0x408
|
2017-04-05 09:22:35 +00:00
|
|
|
#define SHIFT_CONTROL_HOME 0x413
|
|
|
|
#define SHIFT_CONTROL_END 0x414
|
2016-04-24 09:28:28 +00:00
|
|
|
#define SHIFT_ALT_LEFT 0x409
|
|
|
|
#define SHIFT_ALT_RIGHT 0x40a
|
|
|
|
#define SHIFT_ALT_UP 0x40b
|
|
|
|
#define SHIFT_ALT_DOWN 0x40c
|
|
|
|
#define SHIFT_PAGEUP 0x40d
|
|
|
|
#define SHIFT_PAGEDOWN 0x40e
|
2016-08-30 08:11:29 +00:00
|
|
|
#define SHIFT_HOME 0x40f
|
|
|
|
#define SHIFT_END 0x410
|
2008-07-14 07:18:22 +00:00
|
|
|
|
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. */
|
|
|
|
#define WAS_FINAL_BACKSPACE (1<<1)
|
2016-06-07 09:52:57 +00:00
|
|
|
#define WAS_WHOLE_LINE (1<<2)
|
|
|
|
/* The flags for the mark need to be the highest. */
|
|
|
|
#define MARK_WAS_SET (1<<3)
|
|
|
|
#define WAS_MARKED_FORWARD (1<<4)
|
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 */
|