blob: f5a6abc20003409e11a70fccfbc34c98f820fc83 [file] [log] [blame]
Chris Allegretta11b00112000-08-06 21:13:45 +00001/* $Id$ */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00002/**************************************************************************
3 * nano.h *
4 * *
5 * Copyright (C) 1999 Chris Allegretta *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 1, or (at your option) *
9 * any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
19 * *
20 **************************************************************************/
21
22#ifdef HAVE_MALLOC_H
23#include <malloc.h>
24#endif
25
26#ifdef HAVE_LIMITS_H
27#include <limits.h>
28#endif
29
30#ifndef NANO_H
31#define NANO_H 1
32
33/* Macros for the flags int... */
34#define SET(bit) flags |= bit
35#define UNSET(bit) flags &= ~bit
36#define ISSET(bit) (flags & bit)
37
38
39#ifdef USE_SLANG /* Slang support enabled */
40#include <slcurses.h>
41#define KEY_DC 0x113
42#elif defined(HAVE_NCURSES_H)
43#include <ncurses.h>
44#else /* Uh oh */
45#include <curses.h>
46#endif /* CURSES_H */
47
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000048#ifdef HAVE_LIBINTL_H
49#include <libintl.h>
50#endif
51
52#include "config.h"
53
54#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
55#include <glib.h>
56# ifndef HAVE_SNPRINTF
57# define snprintf g_snprintf
58# endif
59# ifndef HAVE_VSNPRINTF
60# define vsnprintf g_vsnprintf
61# endif
62#endif
63
64#define VERMSG "nano " VERSION
65
66/* Structure types */
67typedef struct filestruct {
68 char *data;
69 struct filestruct *next; /* Next node */
70 struct filestruct *prev; /* Previous node */
71 long lineno; /* The line number */
72} filestruct;
73
74typedef struct shortcut {
75 int val; /* Actual sequence that generates the keystroke */
76 int altval; /* Alt key # for this function, or 0 for none */
77 int misc1; /* Other int functions we want bound */
78 int misc2;
79 int viewok; /* is this function legal in view mode? */
80 int (*func) (void); /* Function to call when we catch this key */
81 char *desc; /* Description, e.g. "Page Up" */
82 char *help; /* Help file entry text */
83} shortcut;
84
Chris Allegretta756f2202000-09-01 13:32:47 +000085typedef struct toggle {
86 int val; /* Sequence to toggle the key. Should only need 1 */
87 char *desc; /* Description for when toggle is, uh, toggled,
88 e.g. "Pico Messages", we'll append Enabled or
89 Disabled */
90 int flag; /* What flag actually gets toggled */
91} toggle;
92
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000093/* Bitwise flags so we can save space (or more correctly, not waste it) */
94
95#define MODIFIED (1<<0)
96#define KEEP_CUTBUFFER (1<<1)
97#define CASE_SENSITIVE (1<<2)
98#define MARK_ISSET (1<<3)
99#define CONSTUPDATE (1<<4)
100#define NO_HELP (1<<5)
Chris Allegrettabf9a8cc2000-11-17 01:37:39 +0000101#define PICO_MODE (1<<6)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000102#define FOLLOW_SYMLINKS (1<<7)
103#define SUSPEND (1<<8)
104#define NO_WRAP (1<<9)
105#define AUTOINDENT (1<<10)
106#define SAMELINEWRAP (1<<11)
107#define VIEW_MODE (1<<12)
108#define USE_MOUSE (1<<13)
Chris Allegretta9fc8d432000-07-07 01:49:52 +0000109#define USE_REGEXP (1<<14)
110#define REGEXP_COMPILED (1<<15)
Chris Allegretta30885552000-07-14 01:20:12 +0000111#define TEMP_OPT (1<<16)
Chris Allegrettad8346ff2000-07-24 15:16:02 +0000112#define CUT_TO_END (1<<17)
Chris Allegretta756f2202000-09-01 13:32:47 +0000113#define DISABLE_CURPOS (1<<18)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000114
115/* Control key sequences, chaning these would be very very bad */
116
117#define NANO_CONTROL_A 1
118#define NANO_CONTROL_B 2
119#define NANO_CONTROL_C 3
120#define NANO_CONTROL_D 4
121#define NANO_CONTROL_E 5
122#define NANO_CONTROL_F 6
123#define NANO_CONTROL_G 7
124#define NANO_CONTROL_H 8
125#define NANO_CONTROL_I 9
126#define NANO_CONTROL_J 10
127#define NANO_CONTROL_K 11
128#define NANO_CONTROL_L 12
129#define NANO_CONTROL_M 13
130#define NANO_CONTROL_N 14
131#define NANO_CONTROL_O 15
132#define NANO_CONTROL_P 16
133#define NANO_CONTROL_Q 17
134#define NANO_CONTROL_R 18
135#define NANO_CONTROL_S 19
136#define NANO_CONTROL_T 20
137#define NANO_CONTROL_U 21
138#define NANO_CONTROL_V 22
139#define NANO_CONTROL_W 23
140#define NANO_CONTROL_X 24
141#define NANO_CONTROL_Y 25
142#define NANO_CONTROL_Z 26
143
144#define NANO_CONTROL_4 28
145#define NANO_CONTROL_5 29
146#define NANO_CONTROL_6 30
147#define NANO_CONTROL_7 31
148
149#define NANO_ALT_A 'a'
150#define NANO_ALT_B 'b'
151#define NANO_ALT_C 'c'
152#define NANO_ALT_D 'd'
153#define NANO_ALT_E 'e'
154#define NANO_ALT_F 'f'
155#define NANO_ALT_G 'g'
156#define NANO_ALT_H 'h'
157#define NANO_ALT_I 'i'
158#define NANO_ALT_J 'j'
159#define NANO_ALT_K 'k'
160#define NANO_ALT_L 'l'
161#define NANO_ALT_M 'm'
162#define NANO_ALT_N 'n'
163#define NANO_ALT_O 'o'
164#define NANO_ALT_P 'p'
165#define NANO_ALT_Q 'q'
166#define NANO_ALT_R 'r'
167#define NANO_ALT_S 's'
168#define NANO_ALT_T 't'
169#define NANO_ALT_U 'u'
170#define NANO_ALT_V 'v'
171#define NANO_ALT_W 'w'
172#define NANO_ALT_X 'x'
173#define NANO_ALT_Y 'y'
174#define NANO_ALT_Z 'z'
175
176/* Some semi-changeable keybindings, dont play with unless you're sure you
177know what you're doing */
178
179#define NANO_INSERTFILE_KEY NANO_CONTROL_R
180#define NANO_INSERTFILE_FKEY KEY_F(5)
181#define NANO_EXIT_KEY NANO_CONTROL_X
182#define NANO_EXIT_FKEY KEY_F(2)
183#define NANO_WRITEOUT_KEY NANO_CONTROL_O
184#define NANO_WRITEOUT_FKEY KEY_F(3)
185#define NANO_GOTO_KEY NANO_CONTROL_7
186#define NANO_GOTO_FKEY KEY_F(13)
187#define NANO_ALT_GOTO_KEY NANO_ALT_G
188#define NANO_HELP_KEY NANO_CONTROL_G
189#define NANO_HELP_FKEY KEY_F(1)
190#define NANO_WHEREIS_KEY NANO_CONTROL_W
191#define NANO_WHEREIS_FKEY KEY_F(6)
192#define NANO_REPLACE_KEY NANO_CONTROL_4
193#define NANO_REPLACE_FKEY KEY_F(14)
194#define NANO_ALT_REPLACE_KEY NANO_ALT_R
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000195#define NANO_OTHERSEARCH_KEY NANO_CONTROL_R
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000196#define NANO_PREVPAGE_KEY NANO_CONTROL_Y
197#define NANO_PREVPAGE_FKEY KEY_F(7)
198#define NANO_NEXTPAGE_KEY NANO_CONTROL_V
199#define NANO_NEXTPAGE_FKEY KEY_F(8)
200#define NANO_CUT_KEY NANO_CONTROL_K
201#define NANO_CUT_FKEY KEY_F(9)
202#define NANO_UNCUT_KEY NANO_CONTROL_U
203#define NANO_UNCUT_FKEY KEY_F(10)
204#define NANO_CURSORPOS_KEY NANO_CONTROL_C
205#define NANO_CURSORPOS_FKEY KEY_F(11)
206#define NANO_SPELL_KEY NANO_CONTROL_T
207#define NANO_SPELL_FKEY KEY_F(12)
208#define NANO_FIRSTLINE_KEY NANO_PREVPAGE_KEY
209#define NANO_LASTLINE_KEY NANO_NEXTPAGE_KEY
210#define NANO_CANCEL_KEY NANO_CONTROL_C
211#define NANO_CASE_KEY NANO_CONTROL_A
212#define NANO_REFRESH_KEY NANO_CONTROL_L
213#define NANO_JUSTIFY_KEY NANO_CONTROL_J
214#define NANO_JUSTIFY_FKEY KEY_F(4)
Chris Allegretta9149e612000-11-27 00:23:41 +0000215#define NANO_UNJUSTIFY_KEY NANO_CONTROL_U
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000216#define NANO_UP_KEY NANO_CONTROL_P
217#define NANO_DOWN_KEY NANO_CONTROL_N
218#define NANO_FORWARD_KEY NANO_CONTROL_F
219#define NANO_BACK_KEY NANO_CONTROL_B
220#define NANO_MARK_KEY NANO_CONTROL_6
221#define NANO_HOME_KEY NANO_CONTROL_A
222#define NANO_END_KEY NANO_CONTROL_E
223#define NANO_DELETE_KEY NANO_CONTROL_D
224#define NANO_BACKSPACE_KEY NANO_CONTROL_H
225#define NANO_TAB_KEY NANO_CONTROL_I
226#define NANO_SUSPEND_KEY NANO_CONTROL_Z
227#define NANO_ENTER_KEY NANO_CONTROL_M
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000228#define NANO_FROMSEARCHTOGOTO_KEY NANO_CONTROL_T
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000229
Chris Allegretta756f2202000-09-01 13:32:47 +0000230#define TOGGLE_CONST_KEY NANO_ALT_C
231#define TOGGLE_AUTOINDENT_KEY NANO_ALT_I
232#define TOGGLE_SUSPEND_KEY NANO_ALT_Z
233#define TOGGLE_NOHELP_KEY NANO_ALT_X
234#define TOGGLE_PICOMODE_KEY NANO_ALT_P
235#define TOGGLE_MOUSE_KEY NANO_ALT_M
236#define TOGGLE_CUTTOEND_KEY NANO_ALT_K
237#define TOGGLE_REGEXP_KEY NANO_ALT_E
238#define TOGGLE_WRAP_KEY NANO_ALT_W
239
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000240#define MAIN_LIST_LEN 26
241#define MAIN_VISIBLE 12
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000242#define WHEREIS_LIST_LEN 6
Chris Allegretta105da332000-10-31 05:10:10 +0000243#define REPLACE_LIST_LEN 6
Chris Allegretta4d29be12000-10-31 05:32:09 +0000244#define REPLACE_LIST_2_LEN 3
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000245#define GOTO_LIST_LEN 3
246#define WRITEFILE_LIST_LEN 1
247#define HELP_LIST_LEN 3
Chris Allegretta56b24b52000-11-29 23:57:20 +0000248#define SPELL_LIST_LEN 1
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000249
Chris Allegretta43932bd2000-09-06 14:08:37 +0000250#ifdef HAVE_REGEX_H
Chris Allegretta756f2202000-09-01 13:32:47 +0000251#define TOGGLE_LEN 9
252#else
Chris Allegretta805c26d2000-09-06 13:39:17 +0000253#define TOGGLE_LEN 8
Chris Allegretta756f2202000-09-01 13:32:47 +0000254#endif
255
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000256#define VIEW 1
257#define NOVIEW 0
258
Chris Allegretta234a34d2000-07-29 04:33:38 +0000259#define TOP 2
260#define CENTER 1
261#define BOTTOM 0
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000262#endif