blob: 648d9a0e3e1a1679e574e112d39c5c8b51807d07 [file] [log] [blame]
Chris Allegretta11b00112000-08-06 21:13:45 +00001/* $Id$ */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00002/**************************************************************************
3 * nano.h *
4 * *
David Lawrence Ramseyd8a1d372007-10-11 05:01:32 +00005 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
6 * Free Software Foundation, Inc. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00007 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
David Lawrence Ramseyd0035b42007-08-11 05:17:36 +00009 * the Free Software Foundation; either version 3, or (at your option) *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000010 * any later version. *
11 * *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000012 * This program is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15 * General Public License for more details. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000016 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
David Lawrence Ramsey6e925cf2005-05-15 19:57:17 +000019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
20 * 02110-1301, USA. *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000021 * *
22 **************************************************************************/
23
David Lawrence Ramsey24ae56c2004-02-27 03:06:28 +000024#ifndef NANO_H
25#define NANO_H 1
26
David Lawrence Ramseye527e452005-04-15 18:07:26 +000027#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
30
David Lawrence Ramseya619ae62004-03-04 06:33:52 +000031#ifdef __TANDEM
David Lawrence Ramsey0a4b7372006-07-18 18:28:10 +000032/* Tandem NonStop Kernel support. */
David Lawrence Ramseya619ae62004-03-04 06:33:52 +000033#include <floss.h>
34#define NANO_ROOT_UID 65535
35#else
36#define NANO_ROOT_UID 0
37#endif
38
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000039#ifdef HAVE_LIMITS_H
40#include <limits.h>
41#endif
42
David Lawrence Ramsey96dce262006-06-06 18:41:58 +000043#ifdef HAVE_SYS_PARAM_H
44#include <sys/param.h>
45#endif
46
David Lawrence Ramsey01e13ea2005-06-21 04:16:12 +000047/* Macros for flags. */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000048#define SET(bit) flags |= bit
49#define UNSET(bit) flags &= ~bit
David Lawrence Ramseyd91ab6e2003-09-07 23:57:24 +000050#define ISSET(bit) ((flags & bit) != 0)
Chris Allegretta658399a2001-06-14 02:54:22 +000051#define TOGGLE(bit) flags ^= bit
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000052
David Lawrence Ramsey6335fb52007-01-01 05:15:32 +000053/* Macros for character allocation and more. */
Chris Allegretta7662c862003-01-13 01:35:15 +000054#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
Chris Allegrettaf80a59c2003-01-30 00:57:33 +000055#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char))
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +000056#define charmove(dest, src, n) memmove(dest, src, (n) * sizeof(char))
David Lawrence Ramsey3db0dc32005-06-12 15:24:36 +000057#define charset(dest, src, n) memset(dest, src, (n) * sizeof(char))
David Lawrence Ramseyd08348b2004-09-18 22:02:21 +000058
David Lawrence Ramsey092af142005-06-08 01:35:10 +000059/* Set a default value for PATH_MAX if there isn't one. */
David Lawrence Ramsey3e0c8a62004-11-04 04:08:18 +000060#ifndef PATH_MAX
David Lawrence Ramsey6e0ed3c2005-03-26 04:42:28 +000061#define PATH_MAX 4096
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +000062#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000063
David Lawrence Ramseyf78bc852007-12-18 15:55:48 +000064#ifdef USE_SLANG
65/* Slang support. */
66#include <slcurses.h>
67/* Slang curses emulation brain damage, part 3: Slang doesn't define the
68 * curses equivalents of the Insert or Delete keys. */
69#define KEY_DC SL_KEY_DELETE
70#define KEY_IC SL_KEY_IC
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000071/* Ncurses support. */
David Lawrence Ramseyf78bc852007-12-18 15:55:48 +000072#elif defined(HAVE_NCURSES_H)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000073#include <ncurses.h>
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +000074#else
75/* Curses support. */
David Lawrence Ramseyc97acfb2003-09-10 20:08:00 +000076#include <curses.h>
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000077#endif /* CURSES_H */
78
David Lawrence Ramsey2ab03f62002-10-17 02:19:31 +000079#ifdef ENABLE_NLS
David Lawrence Ramseyc1c818e2006-05-14 18:22:01 +000080/* Native language support. */
David Lawrence Ramsey637b8bb2005-01-17 05:06:55 +000081#ifdef HAVE_LIBINTL_H
82#include <libintl.h>
83#endif
84#define _(string) gettext(string)
85#define P_(singular, plural, number) ngettext(singular, plural, number)
David Lawrence Ramsey2ab03f62002-10-17 02:19:31 +000086#else
David Lawrence Ramsey637b8bb2005-01-17 05:06:55 +000087#define _(string) (string)
88#define P_(singular, plural, number) (number == 1 ? singular : plural)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000089#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +000090#define gettext_noop(string) (string)
91#define N_(string) gettext_noop(string)
David Lawrence Ramseyafbcf682005-03-21 06:33:41 +000092 /* Mark a string that will be sent to gettext() later. */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000093
David Lawrence Ramseyfc693212004-12-23 17:43:27 +000094#include <stddef.h>
David Lawrence Ramsey691698a2005-07-24 19:57:51 +000095#include <stdlib.h>
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +000096#include <sys/types.h>
97#include <sys/stat.h>
David Lawrence Ramsey691698a2005-07-24 19:57:51 +000098#include <dirent.h>
99#ifdef HAVE_REGEX_H
100#include <regex.h>
101#endif
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +0000102#ifndef NANO_TINY
103#include <setjmp.h>
104#endif
David Lawrence Ramsey691698a2005-07-24 19:57:51 +0000105#include <assert.h>
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000106
David Lawrence Ramseyda50e732005-07-04 04:22:30 +0000107/* If no vsnprintf(), use the version from glib 2.x. */
David Lawrence Ramsey3a1fc8f2005-01-16 18:49:19 +0000108#ifndef HAVE_VSNPRINTF
David Lawrence Ramseyda50e732005-07-04 04:22:30 +0000109#include <glib.h>
David Lawrence Ramsey3a1fc8f2005-01-16 18:49:19 +0000110#define vsnprintf g_vsnprintf
111#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000112
David Lawrence Ramseyd8640482005-06-12 17:48:46 +0000113/* If no isblank(), iswblank(), strcasecmp(), strncasecmp(),
114 * strcasestr(), strnlen(), getdelim(), or getline(), use the versions
115 * we have. */
116#ifndef HAVE_ISBLANK
117#define isblank nisblank
118#endif
119#ifndef HAVE_ISWBLANK
120#define iswblank niswblank
121#endif
David Lawrence Ramseyadc30a82005-03-20 07:24:49 +0000122#ifndef HAVE_STRCASECMP
123#define strcasecmp nstrcasecmp
124#endif
125#ifndef HAVE_STRNCASECMP
126#define strncasecmp nstrncasecmp
127#endif
128#ifndef HAVE_STRCASESTR
129#define strcasestr nstrcasestr
130#endif
131#ifndef HAVE_STRNLEN
132#define strnlen nstrnlen
133#endif
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000134#ifndef HAVE_GETDELIM
135#define getdelim ngetdelim
136#endif
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000137#ifndef HAVE_GETLINE
138#define getline ngetline
139#endif
140
David Lawrence Ramsey6e308c02006-07-19 02:44:56 +0000141/* If we aren't using ncurses with mouse support, turn the mouse support
142 * off, as it's useless then. */
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +0000143#ifndef NCURSES_MOUSE_VERSION
144#define DISABLE_MOUSE 1
145#endif
David Lawrence Ramsey935594b2006-07-18 18:16:30 +0000146
David Lawrence Ramsey32a3ce42006-07-18 18:25:56 +0000147#if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY)
148#define DISABLE_WRAPJUSTIFY 1
David Lawrence Ramsey935594b2006-07-18 18:16:30 +0000149#endif
Chris Allegretta6fe61492001-05-21 12:56:25 +0000150
David Lawrence Ramsey3e0c8a62004-11-04 04:08:18 +0000151/* Enumeration types. */
152typedef enum {
153 NIX_FILE, DOS_FILE, MAC_FILE
154} file_format;
155
156typedef enum {
David Lawrence Ramseybf0e47d2005-08-01 18:27:10 +0000157 OVERWRITE, APPEND, PREPEND
158} append_type;
159
160typedef enum {
David Lawrence Ramsey6ff22e72006-07-19 00:14:52 +0000161 UP_DIR, DOWN_DIR
David Lawrence Ramseybf0e47d2005-08-01 18:27:10 +0000162} scroll_dir;
David Lawrence Ramsey3e0c8a62004-11-04 04:08:18 +0000163
164typedef enum {
David Lawrence Ramsey5b44f372005-07-16 22:47:12 +0000165 CENTER, NONE
David Lawrence Ramseybf0e47d2005-08-01 18:27:10 +0000166} update_type;
David Lawrence Ramsey3e0c8a62004-11-04 04:08:18 +0000167
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000168typedef enum {
169 CONTROL, META, FKEY, RAW
170} function_type;
171
David Lawrence Ramsey82138502003-12-24 08:03:54 +0000172/* Structure types. */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000173typedef struct filestruct {
174 char *data;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000175 /* The text of this line. */
176 ssize_t lineno;
177 /* The number of this line. */
178 struct filestruct *next;
179 /* Next node. */
180 struct filestruct *prev;
181 /* Previous node. */
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000182} filestruct;
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000183
David Lawrence Ramseye99494f2005-07-20 21:08:38 +0000184typedef struct partition {
185 filestruct *fileage;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000186 /* The top line of this portion of the file. */
David Lawrence Ramseye99494f2005-07-20 21:08:38 +0000187 filestruct *top_prev;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000188 /* The line before the top line of this portion of the file. */
David Lawrence Ramseye99494f2005-07-20 21:08:38 +0000189 char *top_data;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000190 /* The text before the beginning of the top line of this portion
191 * of the file. */
David Lawrence Ramseye99494f2005-07-20 21:08:38 +0000192 filestruct *filebot;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000193 /* The bottom line of this portion of the file. */
David Lawrence Ramseye99494f2005-07-20 21:08:38 +0000194 filestruct *bot_next;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000195 /* The line after the bottom line of this portion of the
196 * file. */
David Lawrence Ramseye99494f2005-07-20 21:08:38 +0000197 char *bot_data;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000198 /* The text after the end of the bottom line of this portion of
199 * the file. */
David Lawrence Ramseye99494f2005-07-20 21:08:38 +0000200} partition;
201
David Lawrence Ramseydb958022005-07-13 20:18:46 +0000202#ifdef ENABLE_COLOR
203typedef struct colortype {
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000204 short fg;
205 /* This syntax's foreground color. */
206 short bg;
207 /* This syntax's background color. */
208 bool bright;
209 /* Is this color A_BOLD? */
210 bool icase;
211 /* Is this regex string case insensitive? */
212 int pairnum;
213 /* The color pair number used for this foreground color and
214 * background color. */
215 char *start_regex;
216 /* The start (or all) of the regex string. */
217 regex_t *start;
218 /* The compiled start (or all) of the regex string. */
219 char *end_regex;
220 /* The end (if any) of the regex string. */
221 regex_t *end;
222 /* The compiled end (if any) of the regex string. */
David Lawrence Ramseydb958022005-07-13 20:18:46 +0000223 struct colortype *next;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000224 /* Next set of colors. */
David Lawrence Ramseydb958022005-07-13 20:18:46 +0000225} colortype;
226
227typedef struct exttype {
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000228 char *ext_regex;
229 /* The extensions that match this syntax. */
230 regex_t *ext;
231 /* The compiled extensions that match this syntax. */
David Lawrence Ramseydb958022005-07-13 20:18:46 +0000232 struct exttype *next;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000233 /* Next set of extensions. */
David Lawrence Ramseydb958022005-07-13 20:18:46 +0000234} exttype;
235
236typedef struct syntaxtype {
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000237 char *desc;
238 /* The name of this syntax. */
239 exttype *extensions;
240 /* The list of extensions that this syntax applies to. */
241 colortype *color;
242 /* The colors used in this syntax. */
David Lawrence Ramseydb958022005-07-13 20:18:46 +0000243 struct syntaxtype *next;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000244 /* Next syntax. */
David Lawrence Ramseydb958022005-07-13 20:18:46 +0000245} syntaxtype;
246#endif /* ENABLE_COLOR */
247
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000248typedef struct openfilestruct {
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000249 char *filename;
250 /* The current file's name. */
251 filestruct *fileage;
252 /* The current file's first line. */
253 filestruct *filebot;
254 /* The current file's last line. */
255 filestruct *edittop;
256 /* The current top of the edit window. */
257 filestruct *current;
258 /* The current file's current line. */
259 size_t totsize;
260 /* The current file's total number of characters. */
261 size_t current_x;
262 /* The current file's x-coordinate position. */
263 size_t placewewant;
264 /* The current file's place we want. */
265 ssize_t current_y;
266 /* The current file's y-coordinate position. */
267 bool modified;
268 /* Whether the current file has been modified. */
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000269#ifndef NANO_TINY
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000270 bool mark_set;
271 /* Whether the mark is on in the current file. */
272 filestruct *mark_begin;
273 /* The current file's beginning marked line, if any. */
274 size_t mark_begin_x;
275 /* The current file's beginning marked line's x-coordinate
276 * position, if any. */
277 file_format fmt;
278 /* The current file's format. */
279 struct stat *current_stat;
280 /* The current file's stat. */
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000281#endif
David Lawrence Ramseydb958022005-07-13 20:18:46 +0000282#ifdef ENABLE_COLOR
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000283 colortype *colorstrings;
284 /* The current file's associated colors. */
David Lawrence Ramseydb958022005-07-13 20:18:46 +0000285#endif
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +0000286 struct openfilestruct *next;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000287 /* Next node. */
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +0000288 struct openfilestruct *prev;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000289 /* Previous node. */
David Lawrence Ramsey6ad59cd2005-07-08 20:09:16 +0000290} openfilestruct;
Chris Allegretta2d7893d2001-07-11 02:08:33 +0000291
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000292typedef struct shortcut {
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000293 const char *desc;
294 /* The function's description, e.g. "Page Up". */
295#ifndef DISABLE_HELP
296 const char *help;
297 /* The help file entry text for this function. */
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000298 bool blank_after;
299 /* Whether there should be a blank line after the help entry
300 * text for this function. */
David Lawrence Ramseybd28ee42006-07-25 21:13:30 +0000301#endif
302 /* Note: Key values that aren't used should be set to
303 * NANO_NO_KEY. */
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000304 int ctrlval;
305 /* The special sentinel key or control key we want bound, if
306 * any. */
307 int metaval;
308 /* The meta key we want bound, if any. */
309 int funcval;
310 /* The function key we want bound, if any. */
311 int miscval;
312 /* The other meta key we want bound, if any. */
313 bool viewok;
314 /* Is this function allowed when in view mode? */
315 void (*func)(void);
316 /* The function to call when we get this key. */
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000317 struct shortcut *next;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000318 /* Next shortcut. */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000319} shortcut;
320
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000321#ifndef NANO_TINY
Chris Allegretta756f2202000-09-01 13:32:47 +0000322typedef struct toggle {
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000323 int val;
324 /* The sequence to toggle the key. We should only need one. */
325 const char *desc;
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000326 /* The description of the toggle, e.g. "Cut to end"; we'll
327 * append Enabled or Disabled to it. */
David Lawrence Ramseybd28ee42006-07-25 21:13:30 +0000328#ifndef DISABLE_HELP
David Lawrence Ramsey1df3e2d2006-04-22 19:45:26 +0000329 bool blank_after;
330 /* Whether there should be a blank line after the description of
331 * the toggle. */
David Lawrence Ramseybd28ee42006-07-25 21:13:30 +0000332#endif
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000333 long flag;
334 /* Which flag actually gets toggled. */
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000335 struct toggle *next;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000336 /* Next toggle. */
Chris Allegretta756f2202000-09-01 13:32:47 +0000337} toggle;
David Lawrence Ramsey6d9aa082004-11-03 14:58:04 +0000338#endif
Chris Allegretta756f2202000-09-01 13:32:47 +0000339
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000340#ifdef ENABLE_NANORC
341typedef struct rcoption {
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000342 const char *name;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000343 /* The name of the rcfile option. */
David Lawrence Ramseyec721c82004-07-07 15:20:52 +0000344 long flag;
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000345 /* The flag associated with it, if any. */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000346} rcoption;
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000347
David Lawrence Ramsey6d9aa082004-11-03 14:58:04 +0000348#endif
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000349
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000350typedef struct sc {
351 char *keystr;
352 /* The shortcut key for a function, ASCII version */
353 function_type type;
354 /* What kind of function key is it for convenience later */
355 int seq;
356 /* The actual sequence to check on the the type is determined */
357 int menu;
358 /* What list does this apply to */
359 void (*scfunc)(void);
360 /* The function we're going to run */
361 int toggle;
362 /* If a toggle, what we're toggling */
363 bool execute;
364 /* Whether to execute the function in question or just return
365 so the sequence can be caught by the calling code */
366 struct sc *next;
367 /* Next in the list */
368} sc;
369
370typedef struct subnfunc {
371 void (*scfunc)(void);
372 /* What function is this */
373 int menus;
374 /* In what menus does this function applu */
375 const char *desc;
376 /* The function's description, e.g. "Page Up". */
377#ifndef DISABLE_HELP
378 const char *help;
379 /* The help file entry text for this function. */
380 bool blank_after;
381 /* Whether there should be a blank line after the help entry
382 * text for this function. */
383#endif
384 bool viewok;
385 /* Is this function allowed when in view mode? */
386 long toggle;
387 /* If this is a toggle, if nonzero what toggle to set */
388 struct subnfunc *next;
389 /* next item in the list */
390} subnfunc;
391
392
David Lawrence Ramsey0f476b92005-05-22 04:16:36 +0000393/* Bitwise flags so that we can save space (or, more correctly, not
394 * waste it). */
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000395#define CASE_SENSITIVE (1<<0)
396#define CONST_UPDATE (1<<1)
397#define NO_HELP (1<<2)
398#define NOFOLLOW_SYMLINKS (1<<3)
399#define SUSPEND (1<<4)
400#define NO_WRAP (1<<5)
401#define AUTOINDENT (1<<6)
402#define VIEW_MODE (1<<7)
403#define USE_MOUSE (1<<8)
404#define USE_REGEXP (1<<9)
405#define TEMP_FILE (1<<10)
406#define CUT_TO_END (1<<11)
407#define BACKWARDS_SEARCH (1<<12)
408#define MULTIBUFFER (1<<13)
409#define SMOOTH_SCROLL (1<<14)
410#define REBIND_DELETE (1<<15)
411#define REBIND_KEYPAD (1<<16)
412#define NO_CONVERT (1<<17)
413#define BACKUP_FILE (1<<18)
414#define NO_COLOR_SYNTAX (1<<19)
415#define PRESERVE (1<<20)
416#define HISTORYLOG (1<<21)
417#define RESTRICTED (1<<22)
418#define SMART_HOME (1<<23)
419#define WHITESPACE_DISPLAY (1<<24)
420#define MORE_SPACE (1<<25)
421#define TABS_TO_SPACES (1<<26)
422#define QUICK_BLANK (1<<27)
423#define WORD_BOUNDS (1<<28)
424#define NO_NEWLINES (1<<29)
425#define BOLD_TEXT (1<<30)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000426
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000427/* Flags for which menus in which a given function should be present */
428#define MMAIN (1<<0)
429#define MWHEREIS (1<<1)
430#define MREPLACE (1<<2)
431#define MREPLACE2 (1<<3)
432#define MGOTOLINE (1<<4)
433#define MWRITEFILE (1<<5)
434#define MINSERTFILE (1<<6)
435#define MEXTCMD (1<<7)
436#define MHELP (1<<8)
437#define MSPELL (1<<9)
438#define MBROWSER (1<<10)
439#define MWHEREISFILE (1<<11)
440#define MGOTODIR (1<<12)
Chris Allegrettacc593832008-03-19 02:32:48 +0000441#define MYESNO (1<<13)
Chris Allegretta79a33bb2008-03-05 07:34:01 +0000442/* This really isnt all but close enough */
443#define MALL (MMAIN|MWHEREIS|MREPLACE|MREPLACE2|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MSPELL|MBROWSER|MWHEREISFILE|MGOTODIR|MHELP)
444
David Lawrence Ramsey0f476b92005-05-22 04:16:36 +0000445/* Control key sequences. Changing these would be very, very bad. */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000446#define NANO_CONTROL_SPACE 0
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000447#define NANO_CONTROL_A 1
448#define NANO_CONTROL_B 2
449#define NANO_CONTROL_C 3
450#define NANO_CONTROL_D 4
451#define NANO_CONTROL_E 5
452#define NANO_CONTROL_F 6
453#define NANO_CONTROL_G 7
454#define NANO_CONTROL_H 8
455#define NANO_CONTROL_I 9
456#define NANO_CONTROL_J 10
457#define NANO_CONTROL_K 11
458#define NANO_CONTROL_L 12
459#define NANO_CONTROL_M 13
460#define NANO_CONTROL_N 14
461#define NANO_CONTROL_O 15
462#define NANO_CONTROL_P 16
463#define NANO_CONTROL_Q 17
464#define NANO_CONTROL_R 18
465#define NANO_CONTROL_S 19
466#define NANO_CONTROL_T 20
467#define NANO_CONTROL_U 21
468#define NANO_CONTROL_V 22
469#define NANO_CONTROL_W 23
470#define NANO_CONTROL_X 24
471#define NANO_CONTROL_Y 25
472#define NANO_CONTROL_Z 26
David Lawrence Ramsey4d7c2602003-08-17 02:48:43 +0000473#define NANO_CONTROL_3 27
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000474#define NANO_CONTROL_4 28
475#define NANO_CONTROL_5 29
476#define NANO_CONTROL_6 30
477#define NANO_CONTROL_7 31
David Lawrence Ramsey4d7c2602003-08-17 02:48:43 +0000478#define NANO_CONTROL_8 127
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000479
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +0000480/* Meta key sequences. */
David Lawrence Ramsey292f7ef2006-11-21 04:15:04 +0000481#define NANO_META_SPACE ' '
482#define NANO_META_LPARENTHESIS '('
483#define NANO_META_RPARENTHESIS ')'
484#define NANO_META_PLUS '+'
485#define NANO_META_COMMA ','
486#define NANO_META_MINUS '-'
487#define NANO_META_PERIOD '.'
488#define NANO_META_SLASH '/'
489#define NANO_META_0 '0'
490#define NANO_META_6 '6'
491#define NANO_META_9 '9'
492#define NANO_META_LCARET '<'
493#define NANO_META_EQUALS '='
494#define NANO_META_RCARET '>'
495#define NANO_META_QUESTION '?'
496#define NANO_META_BACKSLASH '\\'
497#define NANO_META_RBRACKET ']'
498#define NANO_META_CARET '^'
499#define NANO_META_UNDERSCORE '_'
500#define NANO_META_A 'a'
501#define NANO_META_B 'b'
502#define NANO_META_C 'c'
503#define NANO_META_D 'd'
504#define NANO_META_E 'e'
505#define NANO_META_F 'f'
506#define NANO_META_G 'g'
507#define NANO_META_H 'h'
508#define NANO_META_I 'i'
509#define NANO_META_J 'j'
510#define NANO_META_K 'k'
511#define NANO_META_L 'l'
512#define NANO_META_M 'm'
513#define NANO_META_N 'n'
514#define NANO_META_O 'o'
515#define NANO_META_P 'p'
516#define NANO_META_Q 'q'
517#define NANO_META_R 'r'
518#define NANO_META_S 's'
519#define NANO_META_T 't'
520#define NANO_META_U 'u'
521#define NANO_META_V 'v'
522#define NANO_META_W 'w'
523#define NANO_META_X 'x'
524#define NANO_META_Y 'y'
525#define NANO_META_Z 'z'
526#define NANO_META_LCURLYBRACKET '{'
527#define NANO_META_PIPE '|'
528#define NANO_META_RCURLYBRACKET '}'
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000529
David Lawrence Ramsey82138502003-12-24 08:03:54 +0000530/* Some semi-changeable keybindings; don't play with these unless you're
David Lawrence Ramsey0a258082004-04-23 18:02:37 +0000531 * sure you know what you're doing. Assume ERR is defined as -1. */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000532
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000533/* No key at all. */
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000534#define NANO_NO_KEY -2
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000535
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000536/* Normal keys. */
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000537#define NANO_XON_KEY NANO_CONTROL_Q
538#define NANO_XOFF_KEY NANO_CONTROL_S
539#define NANO_CANCEL_KEY NANO_CONTROL_C
540#define NANO_EXIT_KEY NANO_CONTROL_X
541#define NANO_EXIT_FKEY KEY_F(2)
542#define NANO_INSERTFILE_KEY NANO_CONTROL_R
543#define NANO_INSERTFILE_FKEY KEY_F(5)
544#define NANO_TOOTHERINSERT_KEY NANO_CONTROL_X
545#define NANO_WRITEOUT_KEY NANO_CONTROL_O
546#define NANO_WRITEOUT_FKEY KEY_F(3)
547#define NANO_GOTOLINE_KEY NANO_CONTROL_7
548#define NANO_GOTOLINE_FKEY KEY_F(13)
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000549#define NANO_GOTOLINE_METAKEY NANO_META_G
David Lawrence Ramsey0ec909c2006-05-06 15:07:26 +0000550#define NANO_GOTODIR_KEY NANO_CONTROL_7
551#define NANO_GOTODIR_FKEY KEY_F(13)
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000552#define NANO_GOTODIR_METAKEY NANO_META_G
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000553#define NANO_TOGOTOLINE_KEY NANO_CONTROL_T
554#define NANO_HELP_KEY NANO_CONTROL_G
555#define NANO_HELP_FKEY KEY_F(1)
556#define NANO_WHEREIS_KEY NANO_CONTROL_W
557#define NANO_WHEREIS_FKEY KEY_F(6)
David Lawrence Ramsey292f7ef2006-11-21 04:15:04 +0000558#define NANO_WHEREIS_NEXT_KEY NANO_META_W
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000559#define NANO_WHEREIS_NEXT_FKEY KEY_F(16)
560#define NANO_TOOTHERWHEREIS_KEY NANO_CONTROL_T
David Lawrence Ramsey292f7ef2006-11-21 04:15:04 +0000561#define NANO_REGEXP_KEY NANO_META_R
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000562#define NANO_REPLACE_KEY NANO_CONTROL_4
563#define NANO_REPLACE_FKEY KEY_F(14)
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000564#define NANO_REPLACE_METAKEY NANO_META_R
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000565#define NANO_TOOTHERSEARCH_KEY NANO_CONTROL_R
566#define NANO_PREVPAGE_KEY NANO_CONTROL_Y
567#define NANO_PREVPAGE_FKEY KEY_F(7)
568#define NANO_NEXTPAGE_KEY NANO_CONTROL_V
569#define NANO_NEXTPAGE_FKEY KEY_F(8)
570#define NANO_CUT_KEY NANO_CONTROL_K
571#define NANO_CUT_FKEY KEY_F(9)
David Lawrence Ramsey292f7ef2006-11-21 04:15:04 +0000572#define NANO_COPY_KEY NANO_META_CARET
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000573#define NANO_COPY_METAKEY NANO_META_6
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000574#define NANO_UNCUT_KEY NANO_CONTROL_U
575#define NANO_UNCUT_FKEY KEY_F(10)
576#define NANO_CURSORPOS_KEY NANO_CONTROL_C
577#define NANO_CURSORPOS_FKEY KEY_F(11)
578#define NANO_SPELL_KEY NANO_CONTROL_T
579#define NANO_SPELL_FKEY KEY_F(12)
580#define NANO_FIRSTLINE_KEY NANO_PREVPAGE_KEY
581#define NANO_FIRSTLINE_FKEY NANO_PREVPAGE_FKEY
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000582#define NANO_FIRSTLINE_METAKEY NANO_META_BACKSLASH
583#define NANO_FIRSTLINE_METAKEY2 NANO_META_PIPE
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000584#define NANO_FIRSTFILE_KEY NANO_FIRSTLINE_KEY
585#define NANO_FIRSTFILE_FKEY NANO_FIRSTLINE_FKEY
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000586#define NANO_FIRSTFILE_METAKEY NANO_FIRSTLINE_METAKEY
587#define NANO_FIRSTFILE_METAKEY2 NANO_FIRSTLINE_METAKEY2
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000588#define NANO_LASTLINE_KEY NANO_NEXTPAGE_KEY
589#define NANO_LASTLINE_FKEY NANO_NEXTPAGE_FKEY
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000590#define NANO_LASTLINE_METAKEY NANO_META_SLASH
591#define NANO_LASTLINE_METAKEY2 NANO_META_QUESTION
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000592#define NANO_LASTFILE_KEY NANO_LASTLINE_KEY
593#define NANO_LASTFILE_FKEY NANO_LASTLINE_FKEY
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000594#define NANO_LASTFILE_METAKEY NANO_LASTLINE_METAKEY
595#define NANO_LASTFILE_METAKEY2 NANO_LASTLINE_METAKEY2
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000596#define NANO_REFRESH_KEY NANO_CONTROL_L
597#define NANO_JUSTIFY_KEY NANO_CONTROL_J
598#define NANO_JUSTIFY_FKEY KEY_F(4)
599#define NANO_UNJUSTIFY_KEY NANO_UNCUT_KEY
600#define NANO_UNJUSTIFY_FKEY NANO_UNCUT_FKEY
601#define NANO_PREVLINE_KEY NANO_CONTROL_P
602#define NANO_NEXTLINE_KEY NANO_CONTROL_N
603#define NANO_FORWARD_KEY NANO_CONTROL_F
604#define NANO_BACK_KEY NANO_CONTROL_B
605#define NANO_MARK_KEY NANO_CONTROL_6
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000606#define NANO_MARK_METAKEY NANO_META_A
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000607#define NANO_MARK_FKEY KEY_F(15)
608#define NANO_HOME_KEY NANO_CONTROL_A
609#define NANO_END_KEY NANO_CONTROL_E
610#define NANO_DELETE_KEY NANO_CONTROL_D
611#define NANO_BACKSPACE_KEY NANO_CONTROL_H
612#define NANO_TAB_KEY NANO_CONTROL_I
David Lawrence Ramsey292f7ef2006-11-21 04:15:04 +0000613#define NANO_INDENT_KEY NANO_META_RCURLYBRACKET
614#define NANO_UNINDENT_KEY NANO_META_LCURLYBRACKET
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000615#define NANO_SUSPEND_KEY NANO_CONTROL_Z
616#define NANO_ENTER_KEY NANO_CONTROL_M
617#define NANO_TOFILES_KEY NANO_CONTROL_T
David Lawrence Ramsey292f7ef2006-11-21 04:15:04 +0000618#define NANO_APPEND_KEY NANO_META_A
619#define NANO_PREPEND_KEY NANO_META_P
620#define NANO_PREVFILE_KEY NANO_META_LCARET
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000621#define NANO_PREVFILE_METAKEY NANO_META_COMMA
David Lawrence Ramsey292f7ef2006-11-21 04:15:04 +0000622#define NANO_NEXTFILE_KEY NANO_META_RCARET
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000623#define NANO_NEXTFILE_METAKEY NANO_META_PERIOD
David Lawrence Ramsey292f7ef2006-11-21 04:15:04 +0000624#define NANO_BRACKET_KEY NANO_META_RBRACKET
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000625#define NANO_NEXTWORD_KEY NANO_CONTROL_SPACE
David Lawrence Ramsey292f7ef2006-11-21 04:15:04 +0000626#define NANO_PREVWORD_KEY NANO_META_SPACE
627#define NANO_WORDCOUNT_KEY NANO_META_D
628#define NANO_SCROLLUP_KEY NANO_META_MINUS
629#define NANO_SCROLLDOWN_KEY NANO_META_PLUS
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000630#define NANO_SCROLLUP_METAKEY NANO_META_UNDERSCORE
631#define NANO_SCROLLDOWN_METAKEY NANO_META_EQUALS
632#define NANO_CUTTILLEND_METAKEY NANO_META_T
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000633#define NANO_PARABEGIN_KEY NANO_CONTROL_W
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000634#define NANO_PARABEGIN_METAKEY NANO_META_LPARENTHESIS
635#define NANO_PARABEGIN_METAKEY2 NANO_META_9
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000636#define NANO_PARAEND_KEY NANO_CONTROL_O
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000637#define NANO_PARAEND_METAKEY NANO_META_RPARENTHESIS
638#define NANO_PARAEND_METAKEY2 NANO_META_0
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000639#define NANO_FULLJUSTIFY_KEY NANO_CONTROL_U
David Lawrence Ramsey5a8182e2006-11-21 04:20:53 +0000640#define NANO_FULLJUSTIFY_METAKEY NANO_META_J
David Lawrence Ramsey292f7ef2006-11-21 04:15:04 +0000641#define NANO_VERBATIM_KEY NANO_META_V
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000642
David Lawrence Ramseye313f5b2006-04-20 22:29:02 +0000643/* Toggles do not exist if NANO_TINY is defined. */
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000644#ifndef NANO_TINY
David Lawrence Ramseye313f5b2006-04-20 22:29:02 +0000645
646/* No toggle at all. */
David Lawrence Ramsey58fabec2006-04-26 17:39:41 +0000647#define TOGGLE_NO_KEY -2
David Lawrence Ramseye313f5b2006-04-20 22:29:02 +0000648
649/* Normal toggles. */
David Lawrence Ramsey292f7ef2006-11-21 04:15:04 +0000650#define TOGGLE_NOHELP_KEY NANO_META_X
651#define TOGGLE_CONST_KEY NANO_META_C
652#define TOGGLE_MORESPACE_KEY NANO_META_O
653#define TOGGLE_SMOOTH_KEY NANO_META_S
654#define TOGGLE_WHITESPACE_KEY NANO_META_P
655#define TOGGLE_SYNTAX_KEY NANO_META_Y
656#define TOGGLE_SMARTHOME_KEY NANO_META_H
657#define TOGGLE_AUTOINDENT_KEY NANO_META_I
658#define TOGGLE_CUTTOEND_KEY NANO_META_K
659#define TOGGLE_WRAP_KEY NANO_META_L
660#define TOGGLE_TABSTOSPACES_KEY NANO_META_Q
661#define TOGGLE_BACKUP_KEY NANO_META_B
662#define TOGGLE_MULTIBUFFER_KEY NANO_META_F
663#define TOGGLE_MOUSE_KEY NANO_META_M
664#define TOGGLE_NOCONVERT_KEY NANO_META_N
665#define TOGGLE_SUSPEND_KEY NANO_META_Z
666#define TOGGLE_CASE_KEY NANO_META_C
667#define TOGGLE_BACKWARDS_KEY NANO_META_B
668#define TOGGLE_DOS_KEY NANO_META_D
669#define TOGGLE_MAC_KEY NANO_META_M
David Lawrence Ramseyebe34252005-11-15 03:17:35 +0000670#endif /* !NANO_TINY */
Chris Allegretta658399a2001-06-14 02:54:22 +0000671
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000672#define VIEW TRUE
673#define NOVIEW FALSE
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000674
David Lawrence Ramseyfc0f8f82006-05-10 13:41:53 +0000675/* The maximum number of entries displayed in the main shortcut list. */
676#define MAIN_VISIBLE 12
677
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000678/* The minimum editor window columns and rows required for nano to work
David Lawrence Ramsey3d12f0f2005-10-26 23:14:59 +0000679 * correctly. */
680#define MIN_EDITOR_COLS 4
David Lawrence Ramsey50406662005-01-19 19:52:42 +0000681#define MIN_EDITOR_ROWS 1
Chris Allegrettaf8f2d582003-02-10 02:43:48 +0000682
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000683/* The default number of characters from the end of the line where
684 * wrapping occurs. */
Chris Allegrettae61e8302001-01-14 05:18:27 +0000685#define CHARS_FROM_EOL 8
686
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000687/* The default width of a tab in spaces. */
David Lawrence Ramsey02517e02004-09-05 21:40:31 +0000688#define WIDTH_OF_TAB 8
689
David Lawrence Ramsey6d6a36c2005-12-08 07:09:08 +0000690/* The maximum number of search/replace history strings saved, not
691 * counting the blank lines at their ends. */
Chris Allegretta5beed502003-01-05 20:41:21 +0000692#define MAX_SEARCH_HISTORY 100
Chris Allegretta7662c862003-01-13 01:35:15 +0000693
David Lawrence Ramsey91493252006-03-19 19:25:29 +0000694/* The maximum number of bytes buffered at one time. */
David Lawrence Ramsey5b2f17e2005-04-19 21:47:01 +0000695#define MAX_BUF_SIZE 128
696
Chris Allegrettad865da12002-07-29 23:46:38 +0000697#endif /* !NANO_H */