/
bvi.h
312 lines (287 loc) · 7.73 KB
/
bvi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
/* BVI.H
*
* 1996-02-28 V 1.0.0
* 1999-01-21 V 1.1.0
* 1999-03-17 V 1.1.1
* 1999-07-01 V 1.2.0 beta
* 1999-08-21 V 1.2.0 final
* 2000-05-10 V 1.3.0 alpha
* 2000-10-24 V 1.3.0 final
* 2001-10-29 V 1.3.1
* 2003-07-04 V 1.3.2
*
* NOTE: Edit this file with tabstop=4 !
*
* Copyright 1996-2003 by Gerhard Buergmann
* gerhard@puon.at
*
* 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 the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* 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.
*
* See file COPYING for information on distribution conditions.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <signal.h>
#include <sys/stat.h>
#include <setjmp.h>
#if defined(__MSDOS__) && !defined(DJGPP)
# include "patchlev.h"
# include "dosconf.h"
#include "doscur.h"
#include <alloc.h>
#else
# include "patchlevel.h"
# include "config.h"
#if HAVE_NCURSES_H
#include <ncurses.h>
#else
#include <curses.h>
#endif
#endif
/* defines for filemode */
#define ERROR -1
#define REGULAR 0
#define NEW 1
#define DIRECTORY 2
#define CHARACTER_SPECIAL 3
#define BLOCK_SPECIAL 4
#define PARTIAL 5
/* regular expressions */
#define END 0
#define ONE 1
#define STAR 2
/* undo modes */
#define U_EDIT 1 /* undo o r R */
#define U_TRUNC 2 /* undo D */
#define U_INSERT 4 /* undo i */
#define U_DELETE 8 /* undo x */
#define U_BACK 16 /* undo X */
#define U_APPEND 32 /* undo P A */
#define U_TILDE 64 /* ~ */
#define S_GLOBAL 0x100
/* logic modes */
#define LSHIFT 1
#define RSHIFT 2
#define LROTATE 3
#define RROTATE 4
#define AND 5
#define OR 6
#define XOR 7
#define NEG 8
#define NOT 9
#define HEX 0
#define ASCII 1
#define FORWARD 0
#define BACKWARD 1
#define CR '\r'
#define NL '\n'
#define BS 8
#define ESC 27
#define SEARCH 0
#define BVICTRL(n) (n&0x1f)
#define CMDLNG(a,b) (len <= a && len >= b)
#ifndef NULL
# define NULL ((void *)0)
#endif
#ifndef TRUE
# define TRUE 1
# define FALSE 0
#endif
#if defined(__MSDOS__) && !defined(DJGPP)
# define ANSI
# define PTR char huge *
# define off_t long
#define DELIM '\\'
#define strncasecmp strnicmp
#define strcasecmp stricmp
# define memcpy d_memcpy
# define memmove d_memmove
#else
# define PTR char *
#define DELIM '/'
#endif
/* Define escape key */
#define KEY_ESC 27
#define MAXCMD 255
#define BUFFER 1024
#define BLK_COUNT 32 /* number of data blocks */
#define MARK_COUNT 64 /* number of markers */
#define SKIP_WHITE while(*cmd!='\0'&&isspace(*cmd))cmd++;
#ifdef DEBUG
extern FILE *debug_fp;
#endif
#ifndef HAVE_STRERROR
extern char *sys_errlist[];
#endif
struct KEYMAP_ {
unsigned int keycode;
char cmd[256];
};
struct BLOCK_ {
unsigned long pos_start;
unsigned long pos_end;
char name[64];
unsigned int hl_toggle; /* do we need highlight this block? */
unsigned short folding; /* do we need fold this block? */
unsigned int palette; /* pallete, which we are using for highlight this block */
};
struct MARKERS_ {
long address;
char marker; /* Usually we use '+' character, but can be another */
};
extern char *version;
extern char addr_form[];
extern char pattern[];
extern char rep_buf[];
extern int maxx, maxy, x, y;
extern int filemode, loc;
extern int edits, new;
extern int AnzAdd;
extern int COLUMNS_DATA, COLUMNS_HEX;
extern int addr_flag;
extern int ignore_case, magic;
extern int screen, status;
extern PTR mem;
extern PTR maxpos;
extern PTR pagepos;
extern PTR undo_start;
extern PTR current_start;
extern PTR curpos;
extern PTR current;
extern PTR start_addr;
extern PTR end_addr;
extern char *name, cmdstr[];
extern off_t filesize, memsize;
extern PTR markbuf[];
extern PTR last_motion;
extern off_t undo_count;
extern off_t yanked;
extern off_t undosize;
extern char *copyright, *notfound;
extern char *terminal;
extern char *undo_buf;
extern char *yank_buf;
extern int repl_count;
extern char string[];
extern char *shell;
extern char *poi;
extern int smode;
extern int again;
extern int block_flag;
extern off_t block_begin, block_end, block_size;
#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */
#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */
#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */
#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */
#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */
#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */
#endif
#if defined(__MSDOS__) && !defined(DJGPP)
void d_memcpy(PTR, PTR, off_t);
void d_memmove(PTR, PTR, off_t);
#endif
#ifdef ANSI
off_t alloc_buf(off_t, char **), yd_addr(void);
off_t range(int);
void do_dot(void), do_exit(void), do_shell(void), do_undo(void);
void do_tilde(off_t), trunc_cur(void);
void do_back(off_t, PTR), do_ins_chg(PTR, char *, int);
void do_mark(int, PTR), badcmd(char *), movebyte(void);
void docmdline(char *), do_over(PTR, off_t, PTR), do_put(PTR, off_t, PTR);
void jmpproc(int), printline(PTR, int);
void wmsg(char *);
int addfile(char *);
int bregexec(PTR, char *);
int chk_comm(int);
int doecmd(char *, int);
int do_append(int, char *), do_logic(int, char *);
int do_logic_block(int, char*, int);
int do_delete(off_t, PTR);
int doset(char *);
int do_substitution(int, char *, PTR, PTR);
int hexchar(void);
int outmsg(char *);
PTR searching(int, char *, PTR, PTR, int);
PTR wordsearch(PTR, char);
PTR backsearch(PTR, char);
PTR fsearch(PTR, PTR, char *);
PTR rsearch(PTR, PTR, char *);
PTR end_word(PTR);
PTR calc_addr(char **, PTR);
PTR do_ft(int, int);
char *patcpy(char *, char *, char);
void setpage(PTR), msg(char *), emsg(char *), smsg(char *);
int show_tools_window(int), hide_tools_window();
void printcolorline(int, int, int, char *);
void usage(void), bvi_init(char *), statpos(void), setcur(void);
void showparms(int), toggle(void), scrolldown(int), scrollup(int);
void fileinfo(char *);
void clearstr(void), clear_marks(void), repaint(void), new_screen(void);
void quit(void), sysemsg(char *), do_z(int), stuffin(char *);
off_t edit(int), load(char *);
off_t calc_size(char *);
int ascii_comp(char *, char *), hex_comp(char *, char *);
int cur_forw(int), cur_back(void);
int lineout(void), save(char *, PTR, PTR, int);
int at_least(char *, char *, int);
int vgetc(void), xpos(void), enlarge(off_t);
int getcmdstr(char *, int), read_rc(char *);
int wait_return(int);
char *substr(char *, size_t, size_t);
#else
int addfile();
off_t alloc_buf(), yd_addr();
off_t range();
off_t calc_size();
void do_mark(), badcmd(), movebyte();
void do_back(), do_ins_chg();
void jmpproc(), printline();
int chk_comm();
void docmdline(), do_over(), do_put();
int doecmd();
void do_dot(), do_exit(), do_shell(), do_undo();
void do_tilde(), trunc_cur();
int do_append(), do_logic(), do_logic_block();
int do_delete();
int doset();
int do_substitution();
int hexchar();
int outmsg();
PTR searching();
PTR wordsearch();
PTR backsearch();
int bregexec();
PTR fsearch();
PTR rsearch();
PTR end_word();
PTR calc_addr();
PTR do_ft();
char *patcpy();
void setpage(), msg(), emsg(), smsg(), wmsg();
int show_tools_window(), hide_tools_window();
void printcolorline();
void usage(), bvi_init(), statpos(), setcur();
void showparms(), toggle(), scrolldown(), scrollup();
void fileinfo();
void clearstr(), clear_marks(), new_screen(), repaint();
void quit(), sysemsg(), do_z(), stuffin();
off_t edit(), load();
int ascii_comp(), hex_comp();
int cur_forw(), cur_back();
int lineout(), save(), at_least(), read_rc();
int getcmdstr(), enlarge();
int vgetc(), xpos();
char *substr();
int wait_return();
#endif