blob: 14fa75c7dce8ffe5347c706ec11c440451ca0c3d [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)
Chris Allegretta9fc8d432000-07-07 01:49:52 +0000105#define USE_REGEXP (1<<14)
106#define REGEXP_COMPILED (1<<15)
Chris Allegretta627de192000-07-12 02:09:17 +0000107#define CUT_TO_END (1<<16)
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000108
109/* Control key sequences, chaning these would be very very bad */
110
111#define NANO_CONTROL_A 1
112#define NANO_CONTROL_B 2
113#define NANO_CONTROL_C 3
114#define NANO_CONTROL_D 4
115#define NANO_CONTROL_E 5
116#define NANO_CONTROL_F 6
117#define NANO_CONTROL_G 7
118#define NANO_CONTROL_H 8
119#define NANO_CONTROL_I 9
120#define NANO_CONTROL_J 10
121#define NANO_CONTROL_K 11
122#define NANO_CONTROL_L 12
123#define NANO_CONTROL_M 13
124#define NANO_CONTROL_N 14
125#define NANO_CONTROL_O 15
126#define NANO_CONTROL_P 16
127#define NANO_CONTROL_Q 17
128#define NANO_CONTROL_R 18
129#define NANO_CONTROL_S 19
130#define NANO_CONTROL_T 20
131#define NANO_CONTROL_U 21
132#define NANO_CONTROL_V 22
133#define NANO_CONTROL_W 23
134#define NANO_CONTROL_X 24
135#define NANO_CONTROL_Y 25
136#define NANO_CONTROL_Z 26
137
138#define NANO_CONTROL_4 28
139#define NANO_CONTROL_5 29
140#define NANO_CONTROL_6 30
141#define NANO_CONTROL_7 31
142
143#define NANO_ALT_A 'a'
144#define NANO_ALT_B 'b'
145#define NANO_ALT_C 'c'
146#define NANO_ALT_D 'd'
147#define NANO_ALT_E 'e'
148#define NANO_ALT_F 'f'
149#define NANO_ALT_G 'g'
150#define NANO_ALT_H 'h'
151#define NANO_ALT_I 'i'
152#define NANO_ALT_J 'j'
153#define NANO_ALT_K 'k'
154#define NANO_ALT_L 'l'
155#define NANO_ALT_M 'm'
156#define NANO_ALT_N 'n'
157#define NANO_ALT_O 'o'
158#define NANO_ALT_P 'p'
159#define NANO_ALT_Q 'q'
160#define NANO_ALT_R 'r'
161#define NANO_ALT_S 's'
162#define NANO_ALT_T 't'
163#define NANO_ALT_U 'u'
164#define NANO_ALT_V 'v'
165#define NANO_ALT_W 'w'
166#define NANO_ALT_X 'x'
167#define NANO_ALT_Y 'y'
168#define NANO_ALT_Z 'z'
169
170/* Some semi-changeable keybindings, dont play with unless you're sure you
171know what you're doing */
172
173#define NANO_INSERTFILE_KEY NANO_CONTROL_R
174#define NANO_INSERTFILE_FKEY KEY_F(5)
175#define NANO_EXIT_KEY NANO_CONTROL_X
176#define NANO_EXIT_FKEY KEY_F(2)
177#define NANO_WRITEOUT_KEY NANO_CONTROL_O
178#define NANO_WRITEOUT_FKEY KEY_F(3)
179#define NANO_GOTO_KEY NANO_CONTROL_7
180#define NANO_GOTO_FKEY KEY_F(13)
181#define NANO_ALT_GOTO_KEY NANO_ALT_G
182#define NANO_HELP_KEY NANO_CONTROL_G
183#define NANO_HELP_FKEY KEY_F(1)
184#define NANO_WHEREIS_KEY NANO_CONTROL_W
185#define NANO_WHEREIS_FKEY KEY_F(6)
186#define NANO_REPLACE_KEY NANO_CONTROL_4
187#define NANO_REPLACE_FKEY KEY_F(14)
188#define NANO_ALT_REPLACE_KEY NANO_ALT_R
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000189#define NANO_OTHERSEARCH_KEY NANO_CONTROL_R
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000190#define NANO_PREVPAGE_KEY NANO_CONTROL_Y
191#define NANO_PREVPAGE_FKEY KEY_F(7)
192#define NANO_NEXTPAGE_KEY NANO_CONTROL_V
193#define NANO_NEXTPAGE_FKEY KEY_F(8)
194#define NANO_CUT_KEY NANO_CONTROL_K
195#define NANO_CUT_FKEY KEY_F(9)
196#define NANO_UNCUT_KEY NANO_CONTROL_U
197#define NANO_UNCUT_FKEY KEY_F(10)
198#define NANO_CURSORPOS_KEY NANO_CONTROL_C
199#define NANO_CURSORPOS_FKEY KEY_F(11)
200#define NANO_SPELL_KEY NANO_CONTROL_T
201#define NANO_SPELL_FKEY KEY_F(12)
202#define NANO_FIRSTLINE_KEY NANO_PREVPAGE_KEY
203#define NANO_LASTLINE_KEY NANO_NEXTPAGE_KEY
204#define NANO_CANCEL_KEY NANO_CONTROL_C
205#define NANO_CASE_KEY NANO_CONTROL_A
206#define NANO_REFRESH_KEY NANO_CONTROL_L
207#define NANO_JUSTIFY_KEY NANO_CONTROL_J
208#define NANO_JUSTIFY_FKEY KEY_F(4)
209#define NANO_UP_KEY NANO_CONTROL_P
210#define NANO_DOWN_KEY NANO_CONTROL_N
211#define NANO_FORWARD_KEY NANO_CONTROL_F
212#define NANO_BACK_KEY NANO_CONTROL_B
213#define NANO_MARK_KEY NANO_CONTROL_6
214#define NANO_HOME_KEY NANO_CONTROL_A
215#define NANO_END_KEY NANO_CONTROL_E
216#define NANO_DELETE_KEY NANO_CONTROL_D
217#define NANO_BACKSPACE_KEY NANO_CONTROL_H
218#define NANO_TAB_KEY NANO_CONTROL_I
219#define NANO_SUSPEND_KEY NANO_CONTROL_Z
220#define NANO_ENTER_KEY NANO_CONTROL_M
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000221#define NANO_FROMSEARCHTOGOTO_KEY NANO_CONTROL_T
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000222
223#define MAIN_LIST_LEN 26
224#define MAIN_VISIBLE 12
Chris Allegretta8c2b40f2000-06-29 01:30:04 +0000225#define WHEREIS_LIST_LEN 6
226#define REPLACE_LIST_LEN 6
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000227#define GOTO_LIST_LEN 3
228#define WRITEFILE_LIST_LEN 1
229#define HELP_LIST_LEN 3
230#define SPELL_LIST_LEN 3
231
232#define VIEW 1
233#define NOVIEW 0
234
235#endif