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