1 /* $Header: /src/pub/tcsh/ed.h,v 3.31 2001/02/19 23:30:44 kim Exp $ */
3 * ed.h: Editor declarations and globals
6 * Copyright (c) 1980, 1991 The Regents of the University of California.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 # define EXTERN extern
44 #define TABSIZE 8 /* usually 8 spaces/tab */
45 #define MAXMACROLEVELS 10 /* max number of nested kbd macros */
48 # define NT_NUM_KEYS 256
49 #endif /* WINNT_NATIVE */
51 /****************************************************************************/
52 /* stuff for the different states returned by the character editor routines */
53 /****************************************************************************/
55 #define CCRETVAL char /* size needed for the different char editor */
58 #define KEYCMD unsigned char /* size needed to index into CcFuncTbl */
59 /* Must be unsigned */
61 typedef CCRETVAL(*PFCmd) __P((int)); /* pointer to function returning CCRETVAL */
63 struct KeyFuncs { /* for the "bind" shell command */
64 char *name; /* function name for bind command */
65 int func; /* function numeric value */
66 char *desc; /* description of function */
69 extern PFCmd CcFuncTbl[]; /* table of available commands */
70 extern KEYCMD CcKeyMap[]; /* keymap table, each index into above tbl */
71 extern KEYCMD CcAltMap[]; /* Alt keymap table */
72 extern KEYCMD CcEmacsMap[]; /* keymap table for Emacs default bindings */
73 extern KEYCMD CcViCmdMap[]; /* for Vi command mode defaults */
74 extern struct KeyFuncs FuncNames[]; /* string names vs. CcFuncTbl indices */
76 extern KEYCMD NumFuns; /* number of KEYCMDs in above table */
78 #define CC_ERROR 100 /* there should NOT be 100 different... */
79 #define CC_FATAL 101 /* fatal error: inconsistant, must
85 #define CC_LIST_CHOICES 4
86 #define CC_LIST_GLOB 5
87 #define CC_EXPAND_GLOB 6
92 #define CC_CORRECT_L 13
94 #define CC_EXPAND_VARS 15
95 #define CC_NORMALIZE_PATH 16
96 #define CC_LIST_ALL 17
97 #define CC_COMPLETE_ALL 18
98 #define CC_COMPLETE_FWD 19
99 #define CC_COMPLETE_BACK 20
100 #define CC_NORMALIZE_COMMAND 21
107 typedef union Xmapval { /* value passed to the Xkey routines */
112 #define XK_NOD -1 /* Internal tree node */
113 #define XK_CMD 0 /* X-key was an editor command */
114 #define XK_STR 1 /* X-key was a string macro */
115 #define XK_EXE 2 /* X-key was a unix command */
117 /****************************/
118 /* Editor state and buffers */
119 /****************************/
121 EXTERN KEYCMD *CurrentKeyMap; /* current command key map */
122 EXTERN int inputmode; /* insert, replace, replace1 mode */
123 EXTERN Char GettingInput; /* true if getting an input line (mostly) */
124 EXTERN Char NeedsRedraw; /* for editor and twenex error messages */
125 EXTERN Char InputBuf[INBUFSIZE]; /* the real input data */
126 EXTERN Char *LastChar, *Cursor; /* point to the next open space */
127 EXTERN Char *InputLim; /* limit of size of InputBuf */
128 EXTERN Char MetaNext; /* flags for ^V and ^[ functions */
129 EXTERN Char AltKeyMap; /* Using alternative command map (for vi mode) */
130 EXTERN Char VImode; /* true if running in vi mode (PWP 6-27-88) */
131 EXTERN Char *Mark; /* the emacs "mark" (dot is Cursor) */
132 EXTERN Char DoingArg; /* true if we have an argument */
133 EXTERN int Argument; /* "universal" argument value */
134 EXTERN KEYCMD LastCmd; /* previous command executed */
135 EXTERN CStr *KillRing; /* kill ring */
136 EXTERN int KillRingMax; /* max length of kill ring */
137 EXTERN int KillRingLen; /* current length of kill ring */
138 EXTERN int KillPos; /* points to next kill */
139 EXTERN int YankPos; /* points to next yank */
141 EXTERN Char UndoBuf[INBUFSIZE];
142 EXTERN Char *UndoPtr;
144 EXTERN int UndoAction;
146 EXTERN Char HistBuf[INBUFSIZE]; /* history buffer */
147 EXTERN Char *LastHist; /* points to end of history buffer */
148 EXTERN int Hist_num; /* what point up the history we are at now. */
149 EXTERN Char WhichBuf[INBUFSIZE]; /* buffer for which command */
150 EXTERN Char *LastWhich; /* points to end of which buffer */
151 EXTERN Char *CursWhich; /* points to the cursor point in which buf */
152 EXTERN int HistWhich; /* Hist_num is saved in this */
153 EXTERN char Expand; /* true if we are expanding a line */
154 extern Char HistLit; /* true if history lines are shown literal */
155 EXTERN Char CurrentHistLit; /* Literal status of current show history line */
158 * These are truly extern
162 EXTERN Char *KeyMacro[MAXMACROLEVELS];
164 EXTERN Char **Display; /* display buffer seed vector */
165 EXTERN int CursorV, /* real cursor vertical (line) */
166 CursorH, /* real cursor horisontal (column) */
167 TermV, /* number of real screen lines
168 * (sizeof(DisplayBuf) / width */
169 TermH; /* screen width */
170 EXTERN Char **Vdisplay; /* new buffer */
172 /* Variables that describe terminal ability */
173 EXTERN int T_Lines, T_Cols; /* Rows and Cols of the terminal */
174 EXTERN Char T_CanIns; /* true if I can insert characters */
175 EXTERN Char T_CanDel; /* dito for delete characters */
176 EXTERN Char T_Tabs; /* true if tty interface is passing tabs */
177 EXTERN Char T_Margin;
178 #define MARGIN_AUTO 1 /* term has auto margins */
179 #define MARGIN_MAGIC 2 /* concept glitch */
180 EXTERN speed_t T_Speed; /* Tty input Baud rate */
181 EXTERN Char T_CanCEOL; /* true if we can clear to end of line */
182 EXTERN Char T_CanUP; /* true if this term can do reverse linefeen */
183 EXTERN Char T_HasMeta; /* true if we have a meta key */
185 /* note the extra characters in the Strchr() call in this macro */
186 #define isword(c) (Isalpha(c)||Isdigit(c)||Strchr(word_chars,c))
187 #define min(x,y) (((x)<(y))?(x):(y))
188 #define max(x,y) (((x)>(y))?(x):(y))
191 * Terminal dependend data structures
196 #else /* !WINNT_NATIVE */
197 # if defined(POSIX) || defined(TERMIO)
206 # endif /* TIOCGETP */
209 # endif /* TIOCGETC */
211 struct ttypagestat d_pc;
212 # endif /* TIOCGPAGE */
215 # endif /* TIOCLGET */
216 # endif /* POSIX || TERMIO */
218 struct ltchars d_ltc;
219 # endif /* TIOCGLTC */
220 #endif /* WINNT_NATIVE */
223 #define MODE_INSERT 0
224 #define MODE_REPLACE 1
225 #define MODE_REPLACE_1 2
227 #define EX_IO 0 /* while we are executing */
228 #define ED_IO 1 /* while we are editing */
229 #define TS_IO 2 /* new mode from terminal */
230 #define QU_IO 2 /* used only for quoted chars */
231 #define NN_IO 3 /* The number of entries */
233 #if defined(POSIX) || defined(TERMIO)
250 } ttyperm_t[NN_IO][M_NN];
252 extern ttyperm_t ttylist;
253 #include "ed.decls.h"