Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/ie/edit.h
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1984-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* David Korn <[email protected]> *
18
* Pat Sullivan *
19
* *
20
***********************************************************************/
21
/*
22
* edit.h - common data structure for vi and emacs edit options
23
*
24
* David Korn
25
* AT&T Bell Laboratories
26
* Room 3C-526B
27
* Murray Hill, N. J. 07974
28
* Tel. x7975
29
*
30
*/
31
32
#ifndef KSHELL
33
# include <setjmp.h>
34
# include <signal.h>
35
# include <ctype.h>
36
#endif /* KSHELL */
37
#define LOOKAHEAD 80
38
#ifdef VENIX
39
# define READAHEAD 1
40
#else
41
# define READAHEAD LOOKAHEAD
42
#endif /* VENIX */
43
44
#ifdef MULTIBYTE
45
# ifndef ESS_MAXCHAR
46
# include "national.h"
47
# endif /* ESS_MAXCHAR */
48
# if ESS_MAXCHAR<=2
49
typedef unsigned short genchar;
50
# else
51
typedef long genchar;
52
# endif
53
# define CHARSIZE 2
54
#else
55
typedef char genchar;
56
# define CHARSIZE 1
57
#endif /* MULTIBYTE */
58
59
#define TABSIZE 8
60
#define PRSIZE 80
61
#define SEARCHSIZE 80
62
63
struct edit
64
{
65
int e_kill;
66
int e_erase;
67
int e_eof;
68
int e_fchar;
69
char e_plen; /* length of prompt string */
70
char e_crlf; /* zero if cannot return to beginning of line */
71
jmp_buf e_env;
72
int e_llimit; /* line length limit */
73
int e_hline; /* current history line number */
74
int e_hloff; /* line number offset for command */
75
int e_hismin; /* minimum history line number */
76
int e_hismax; /* maximum history line number */
77
int e_raw; /* set when in raw mode or alt mode */
78
int e_cur; /* current line position */
79
int e_eol; /* end-of-line position */
80
int e_pcur; /* current physical line position */
81
int e_peol; /* end of physical line position */
82
int e_mode; /* edit mode */
83
int e_index; /* index in look-ahead buffer */
84
int e_repeat;
85
int e_saved;
86
int e_fcol; /* first column */
87
int e_ucol; /* column for undo */
88
int e_addnl; /* set if new-line must be added */
89
int e_wsize; /* width of display window */
90
char *e_outbase; /* pointer to start of output buffer */
91
char *e_outptr; /* pointer to position in output buffer */
92
char *e_outlast; /* pointer to end of output buffer */
93
genchar *e_inbuf; /* pointer to input buffer */
94
char *e_prompt; /* pointer to buffer containing the prompt */
95
genchar *e_ubuf; /* pointer to the undo buffer */
96
genchar *e_killbuf; /* pointer to delete buffer */
97
char e_search[SEARCHSIZE]; /* search string */
98
genchar *e_Ubuf; /* temporary workspace buffer */
99
genchar *e_physbuf; /* temporary workspace buffer */
100
int e_lbuf[LOOKAHEAD];/* pointer to look-ahead buffer */
101
int e_fd; /* file descriptor */
102
int e_ttyspeed; /* line speed, also indicates tty parms are valid */
103
int *e_globals; /* global variables */
104
genchar *e_window; /* display window image */
105
char e_inmacro; /* processing macro expansion */
106
#ifndef KSHELL
107
char e_prbuff[PRSIZE]; /* prompt buffer */
108
#endif /* KSHELL */
109
};
110
111
#define FEMAX 50 /* maximum number of file matches for q_expand */
112
#undef MAXWINDOW
113
#define MAXWINDOW 160 /* maximum width window */
114
#define MINWINDOW 15 /* minimum width window */
115
#define DFLTWINDOW 80 /* default window width */
116
#define MAXPAT 100 /* maximum length for pattern word */
117
#define YES 1
118
#define NO 0
119
#define FAST 2
120
#define SLOW 1
121
#define RAWMODE 1
122
#define ALTMODE 2
123
#define DELETE '\177'
124
#define BELL '\7'
125
#define ESC 033
126
#define UEOF -2 /* user eof char synonym */
127
#define UERASE -3 /* user erase char synonym */
128
#define UINTR -4 /* user intr char synonym */
129
#define UKILL -5 /* user kill char synonym */
130
#define UQUIT -6 /* user quit char synonym */
131
132
#if ( 'a' == 97) /* ASCII? */
133
# define cntl(x) (x&037)
134
#else
135
# define cntl(c) (c=='D'?55:(c=='E'?45:(c=='F'?46:(c=='G'?'\a':(c=='H'?'\b': \
136
(c=='I'?'\t':(c=='J'?'\n':(c=='T'?60:(c=='U'?61:(c=='V'?50: \
137
(c=='W'?38:(c=='Z'?63:(c=='['?39:(c==']'?29: \
138
(c<'J'?c+1-'A':(c+10-'J'))))))))))))))))
139
#endif
140
141
#ifndef KSHELL
142
# define STRIP 0377
143
# define TO_PRINT 0100
144
# define GMACS 1
145
# define EMACS 2
146
# define VIRAW 4
147
# define EDITVI 8
148
# define NOHIST 16
149
# define EDITMASK 15
150
# define is_option(m) (opt_flag&(m))
151
extern char opt_flag;
152
# ifdef SYSCALL
153
# define read(fd,buff,n) syscall(3,fd,buff,n)
154
# else
155
# define read(fd,buff,n) rEAd(fd,buff,n)
156
# endif /* SYSCALL */
157
#endif /* KSHELL */
158
159
extern struct edit editb;
160
#ifdef PROTO
161
extern void ed_crlf(void);
162
extern void ed_putchar(int);
163
extern void ed_ringbell(void);
164
extern void ed_setup(int);
165
extern void ed_failed(char*,char*);
166
extern void ed_flush(void);
167
extern int ed_getchar(void);
168
extern int ed_virt_to_phys(genchar*,genchar*,int,int,int);
169
extern int ed_window(void);
170
extern void ed_ungetchar(int);
171
extern ssize_t rEAd(int, void*, size_t);
172
extern int vi_read(int, char*, unsigned);
173
extern int emacs_read(int, char*, unsigned);
174
# ifdef KSHELL
175
extern int ed_macro(int);
176
extern int ed_expand(char[],int*,int*,int);
177
# endif /* KSHELL */
178
#else
179
extern void ed_crlf();
180
extern void ed_putchar();
181
extern void ed_ringbell();
182
extern void ed_setup();
183
extern void ed_failed();
184
extern void ed_flush();
185
extern int ed_getchar();
186
extern int ed_virt_to_phys();
187
extern int ed_window();
188
extern void ed_ungetchar();
189
# ifdef KSHELL
190
extern int ed_macro();
191
extern int ed_expand();
192
# endif /* KSHELL */
193
#endif /* PROTO */
194
195
extern const char e_runvi[];
196
#ifndef KSHELL
197
extern const char e_version[];
198
#endif /* KSHELL */
199
200