2000-08-06 21:13:45 +00:00
|
|
|
/* $Id$ */
|
2000-06-06 05:53:49 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* nano.h *
|
|
|
|
* *
|
2009-12-02 03:36:22 +00:00
|
|
|
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
2014-04-30 20:18:26 +00:00
|
|
|
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
|
2000-06-06 05:53:49 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
2007-08-11 05:17:36 +00:00
|
|
|
* the Free Software Foundation; either version 3, or (at your option) *
|
2000-06-06 05:53:49 +00:00
|
|
|
* any later version. *
|
|
|
|
* *
|
2005-05-15 19:57:17 +00:00
|
|
|
* This program 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 *
|
|
|
|
* along with this program; if not, write to the Free Software *
|
2005-05-15 19:57:17 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
|
|
|
|
* 02110-1301, USA. *
|
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
|
|
|
#ifdef HAVE_STDARG_H
|
|
|
|
#include <stdarg.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)
|
|
|
|
|
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))]
|
2009-08-14 03:18:29 +00:00
|
|
|
#define FLAGMASK(flag) (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)
|
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
|
|
|
|
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 */
|
|
|
|
|
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>
|
|
|
|
#ifdef HAVE_REGEX_H
|
|
|
|
#include <regex.h>
|
|
|
|
#endif
|
2006-05-10 13:41:53 +00:00
|
|
|
#ifndef NANO_TINY
|
|
|
|
#include <setjmp.h>
|
|
|
|
#endif
|
2005-07-24 19:57:51 +00:00
|
|
|
#include <assert.h>
|
2000-06-06 05:53:49 +00:00
|
|
|
|
2005-07-04 04:22:30 +00:00
|
|
|
/* If no vsnprintf(), use the version from glib 2.x. */
|
2005-01-16 18:49:19 +00:00
|
|
|
#ifndef HAVE_VSNPRINTF
|
2005-07-04 04:22:30 +00:00
|
|
|
#include <glib.h>
|
2005-01-16 18:49:19 +00:00
|
|
|
#define vsnprintf g_vsnprintf
|
2000-06-06 05:53:49 +00:00
|
|
|
#endif
|
2003-03-11 03:50:40 +00:00
|
|
|
|
2005-06-12 17:48:46 +00:00
|
|
|
/* If no isblank(), iswblank(), strcasecmp(), strncasecmp(),
|
|
|
|
* strcasestr(), strnlen(), getdelim(), or getline(), use the versions
|
|
|
|
* we have. */
|
|
|
|
#ifndef HAVE_ISBLANK
|
|
|
|
#define isblank nisblank
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_ISWBLANK
|
|
|
|
#define iswblank niswblank
|
|
|
|
#endif
|
2005-03-20 07:24:49 +00:00
|
|
|
#ifndef HAVE_STRCASECMP
|
|
|
|
#define strcasecmp nstrcasecmp
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_STRNCASECMP
|
|
|
|
#define strncasecmp nstrncasecmp
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_STRCASESTR
|
|
|
|
#define strcasestr nstrcasestr
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_STRNLEN
|
|
|
|
#define strnlen nstrnlen
|
|
|
|
#endif
|
2004-08-17 05:23:38 +00:00
|
|
|
#ifndef HAVE_GETDELIM
|
|
|
|
#define getdelim ngetdelim
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_GETLINE
|
|
|
|
#define getline ngetline
|
|
|
|
#endif
|
|
|
|
|
2006-07-19 02:44:56 +00:00
|
|
|
/* If we aren't using ncurses with mouse support, turn the mouse support
|
|
|
|
* off, as it's useless then. */
|
2003-10-03 20:26:25 +00:00
|
|
|
#ifndef NCURSES_MOUSE_VERSION
|
|
|
|
#define DISABLE_MOUSE 1
|
|
|
|
#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;
|
|
|
|
|
2005-08-01 18:27:10 +00:00
|
|
|
typedef enum {
|
|
|
|
OVERWRITE, APPEND, PREPEND
|
|
|
|
} append_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 {
|
2005-07-16 22:47:12 +00:00
|
|
|
CENTER, NONE
|
2005-08-01 18:27:10 +00:00
|
|
|
} update_type;
|
2004-11-04 04:08:18 +00:00
|
|
|
|
2008-03-05 07:34:01 +00:00
|
|
|
typedef enum {
|
2011-02-26 14:22:37 +00:00
|
|
|
CONTROL, META, FKEY, RAWINPUT
|
2014-06-18 20:43:05 +00:00
|
|
|
} key_type;
|
2008-03-05 07:34:01 +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,
|
|
|
|
#endif
|
2014-06-18 20:11:52 +00:00
|
|
|
JOIN, PASTE, INSERT, ENTER, OTHER
|
2008-07-10 20:13:04 +00:00
|
|
|
} undo_type;
|
|
|
|
|
2014-05-10 19:15:04 +00:00
|
|
|
typedef struct color_pair {
|
|
|
|
int pairnum;
|
|
|
|
/* The color pair number used for this foreground color and
|
|
|
|
* background color. */
|
|
|
|
bool bright;
|
|
|
|
/* Is this color A_BOLD? */
|
|
|
|
} color_pair;
|
|
|
|
|
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? */
|
|
|
|
bool icase;
|
|
|
|
/* Is this regex string case insensitive? */
|
|
|
|
int pairnum;
|
|
|
|
/* The color pair number used for this foreground color and
|
|
|
|
* background color. */
|
|
|
|
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 {
|
2005-12-08 07:09:08 +00:00
|
|
|
char *ext_regex;
|
2014-05-12 13:52:50 +00:00
|
|
|
/* The regexstrings for the things that match this syntax. */
|
2005-12-08 07:09:08 +00:00
|
|
|
regex_t *ext;
|
2014-05-12 13:52:50 +00:00
|
|
|
/* The compiled regexes. */
|
2014-05-12 14:31:54 +00:00
|
|
|
struct regexlisttype *next;
|
2014-05-12 13:52:50 +00:00
|
|
|
/* Next set of regexes. */
|
2014-05-12 14:31:54 +00:00
|
|
|
} regexlisttype;
|
2005-07-13 20:18:46 +00:00
|
|
|
|
|
|
|
typedef struct syntaxtype {
|
2005-12-08 07:09:08 +00:00
|
|
|
char *desc;
|
|
|
|
/* 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. */
|
2005-12-08 07:09:08 +00:00
|
|
|
colortype *color;
|
|
|
|
/* The colors used in this syntax. */
|
2014-02-24 10:18:15 +00:00
|
|
|
char *linter;
|
2014-05-12 13:52:50 +00:00
|
|
|
/* The command to lint this type of file. */
|
2009-01-25 07:25:17 +00:00
|
|
|
int nmultis;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* How many multi-line 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;
|
|
|
|
|
|
|
|
|
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. */
|
2009-02-07 14:48:30 +00:00
|
|
|
#define CWTF (1<<6)
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Something else. */
|
2009-02-03 05:05:58 +00:00
|
|
|
|
2014-04-04 11:59:03 +00:00
|
|
|
#endif /* !DISABLE_COLOR */
|
2005-07-13 20:18:46 +00:00
|
|
|
|
2009-01-19 19:10:39 +00:00
|
|
|
|
|
|
|
/* Structure types. */
|
|
|
|
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
|
|
|
|
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. */
|
2008-07-14 07:18:22 +00:00
|
|
|
int xflags;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Some flag data we need. */
|
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
|
|
|
bool mark_set;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Was the marker set when we cut? */
|
2008-07-31 04:24:04 +00:00
|
|
|
ssize_t mark_begin_lineno;
|
|
|
|
/* copy copy copy */
|
2014-05-15 20:00:46 +00:00
|
|
|
size_t mark_begin_x;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Another shadow variable. */
|
2008-07-31 04:24:04 +00:00
|
|
|
struct undo *next;
|
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;
|
|
|
|
/* The current file's name. */
|
|
|
|
filestruct *fileage;
|
|
|
|
/* The current file's first line. */
|
|
|
|
filestruct *filebot;
|
|
|
|
/* The current file's last line. */
|
|
|
|
filestruct *edittop;
|
|
|
|
/* The current top of the edit window. */
|
|
|
|
filestruct *current;
|
|
|
|
/* The current file's current line. */
|
|
|
|
size_t totsize;
|
|
|
|
/* The current file's total number of characters. */
|
|
|
|
size_t current_x;
|
|
|
|
/* The current file's x-coordinate position. */
|
|
|
|
size_t placewewant;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* The current file's x position we would like. */
|
2005-12-08 07:09:08 +00:00
|
|
|
ssize_t current_y;
|
|
|
|
/* The current file's y-coordinate position. */
|
|
|
|
bool modified;
|
|
|
|
/* Whether the current file has been modified. */
|
2005-11-15 03:17:35 +00:00
|
|
|
#ifndef NANO_TINY
|
2005-12-08 07:09:08 +00:00
|
|
|
bool mark_set;
|
|
|
|
/* Whether the mark is on in the current file. */
|
|
|
|
filestruct *mark_begin;
|
|
|
|
/* The current file's beginning marked line, if any. */
|
|
|
|
size_t mark_begin_x;
|
|
|
|
/* The current file's beginning marked line's x-coordinate
|
|
|
|
* position, if any. */
|
|
|
|
file_format fmt;
|
|
|
|
/* The current file's format. */
|
|
|
|
struct stat *current_stat;
|
|
|
|
/* The current file's stat. */
|
2008-07-10 20:13:04 +00:00
|
|
|
undo *undotop;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* 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;
|
2013-01-01 03:24:39 +00:00
|
|
|
const 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;
|
|
|
|
/* The current file's associated colors. */
|
2001-07-11 02:08:33 +00:00
|
|
|
#endif
|
2005-07-08 20:09:16 +00:00
|
|
|
struct openfilestruct *next;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* Next node. */
|
2005-07-08 20:09:16 +00:00
|
|
|
struct openfilestruct *prev;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* Previous node. */
|
2005-07-08 20:09:16 +00:00
|
|
|
} openfilestruct;
|
2001-07-11 02:08:33 +00:00
|
|
|
|
2000-06-06 05:53:49 +00:00
|
|
|
typedef struct shortcut {
|
2006-04-22 19:45:26 +00:00
|
|
|
const char *desc;
|
|
|
|
/* The function's description, e.g. "Page Up". */
|
|
|
|
#ifndef DISABLE_HELP
|
|
|
|
const char *help;
|
|
|
|
/* The help file entry text for this function. */
|
|
|
|
bool blank_after;
|
|
|
|
/* Whether there should be a blank line after the help entry
|
|
|
|
* text for this function. */
|
2006-07-25 21:13:30 +00:00
|
|
|
#endif
|
2005-12-08 07:09:08 +00:00
|
|
|
bool viewok;
|
|
|
|
/* Is this function allowed when in view mode? */
|
|
|
|
void (*func)(void);
|
|
|
|
/* The function to call when we get this key. */
|
2003-12-24 03:33:09 +00:00
|
|
|
struct shortcut *next;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* Next shortcut. */
|
2000-06-06 05:53:49 +00:00
|
|
|
} shortcut;
|
|
|
|
|
2014-04-13 20:50:20 +00:00
|
|
|
#ifndef DISABLE_NANORC
|
2001-04-18 04:28:54 +00:00
|
|
|
typedef struct rcoption {
|
2002-09-13 18:14:04 +00:00
|
|
|
const char *name;
|
2005-12-08 07:09:08 +00:00
|
|
|
/* The name of the rcfile option. */
|
2004-07-07 15:20:52 +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 {
|
|
|
|
char *keystr;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* The shortcut key for a function, ASCII version. */
|
2014-06-18 20:43:05 +00:00
|
|
|
key_type type;
|
|
|
|
/* What kind of command key it is, for convenience later. */
|
2008-03-05 07:34:01 +00:00
|
|
|
int seq;
|
2014-04-16 09:32:53 +00:00
|
|
|
/* The actual sequence to check on the type is determined. */
|
2008-03-05 07:34:01 +00:00
|
|
|
int menu;
|
2014-04-16 09:32:53 +00:00
|
|
|
/* What list 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. */
|
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. */
|
2008-03-05 07:34:01 +00:00
|
|
|
bool execute;
|
|
|
|
/* Whether to execute the function in question or just return
|
2014-04-04 12:29:28 +00:00
|
|
|
* so the sequence can be caught by the calling code. */
|
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);
|
2014-04-04 12:29:28 +00:00
|
|
|
/* What function this is. */
|
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;
|
|
|
|
/* The function's description, e.g. "Page Up". */
|
|
|
|
#ifndef DISABLE_HELP
|
|
|
|
const char *help;
|
|
|
|
/* The help file entry text for this function. */
|
|
|
|
bool blank_after;
|
|
|
|
/* Whether there should be a blank line after the help entry
|
|
|
|
* text for this function. */
|
|
|
|
#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;
|
2014-04-04 12:29:28 +00:00
|
|
|
/* If this is a toggle, if nonzero what toggle to set. */
|
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;
|
|
|
|
|
2014-05-03 18:24:45 +00:00
|
|
|
/* The elements of the interface that can be colored differently. */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TITLE_BAR = 0,
|
|
|
|
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,
|
|
|
|
CONST_UPDATE,
|
|
|
|
NO_HELP,
|
|
|
|
NOFOLLOW_SYMLINKS,
|
|
|
|
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,
|
|
|
|
NOREAD_MODE
|
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)
|
2014-04-16 09:12:13 +00:00
|
|
|
/* This is an abbreviation for all menus except Help and YesNo. */
|
2014-04-16 09:32:53 +00:00
|
|
|
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MSPELL|MLINTER)
|
2008-03-05 07:34:01 +00:00
|
|
|
|
2005-05-22 04:16:36 +00:00
|
|
|
/* Control key sequences. Changing these would be very, very bad. */
|
2002-07-19 01:08:59 +00:00
|
|
|
#define NANO_CONTROL_SPACE 0
|
2000-06-06 05:53:49 +00:00
|
|
|
#define NANO_CONTROL_I 9
|
2003-08-17 02:48:43 +00:00
|
|
|
#define NANO_CONTROL_3 27
|
2000-06-06 05:53:49 +00:00
|
|
|
#define NANO_CONTROL_7 31
|
2003-08-17 02:48:43 +00:00
|
|
|
#define NANO_CONTROL_8 127
|
2000-06-06 05:53:49 +00:00
|
|
|
|
2008-07-14 07:18:22 +00:00
|
|
|
|
2014-04-21 12:31:52 +00:00
|
|
|
#ifndef NANO_TINY
|
2014-04-04 12:29:28 +00:00
|
|
|
/* Extra bits for the undo function. */
|
2011-02-07 14:45:56 +00:00
|
|
|
#define UNdel_del (1<<0)
|
2014-06-20 10:48:26 +00:00
|
|
|
#define UNdel_backspace (1<<1)
|
2014-06-14 14:08:28 +00:00
|
|
|
#define UNcut_marked_backwards (1<<2)
|
2014-05-25 19:41:49 +00:00
|
|
|
#define UNcut_cutline (1<<3)
|
2009-01-28 05:11:57 +00:00
|
|
|
#endif /* !NANO_TINY */
|
|
|
|
|
2004-07-01 18:59:52 +00:00
|
|
|
#define VIEW TRUE
|
|
|
|
#define NOVIEW FALSE
|
2000-06-06 05:53:49 +00:00
|
|
|
|
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 minimum editor window columns and rows required for nano to work
|
2005-10-26 23:14:59 +00:00
|
|
|
* correctly. */
|
|
|
|
#define MIN_EDITOR_COLS 4
|
2005-01-19 19:52:42 +00:00
|
|
|
#define MIN_EDITOR_ROWS 1
|
2003-02-10 02:43:48 +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
|
|
|
|
|
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
|
|
|
|
|
2002-07-29 23:46:38 +00:00
|
|
|
#endif /* !NANO_H */
|