1: /* $Header: /home/hyperion/mu/christos/src/sys/tcsh-6.00/RCS/ed.h,v 3.0 1991/07/04 21:49:28 christos Exp $ */ 2: /* 3: * ed.h: Editor declarations and globals 4: */ 5: /*- 6: * Copyright (c) 1980, 1991 The Regents of the University of California. 7: * All rights reserved. 8: * 9: * Redistribution and use in source and binary forms, with or without 10: * modification, are permitted provided that the following conditions 11: * are met: 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. 24: * 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 35: * SUCH DAMAGE. 36: */ 37: #ifndef _h_ed 38: #define _h_ed 39: 40: #ifndef EXTERN 41: #define EXTERN extern 42: #endif 43: 44: #define TABSIZE 8 /* usually 8 spaces/tab */ 45: #ifdef pdp11 /* jpn: save space */ 46: #define INBUFSIZ (BUFSIZ / 2) /* size of input buffer */ 47: #else 48: #define INBUFSIZ BUFSIZ /* size of input buffer */ 49: #endif /* pdp11 */ 50: #define MAXMACROLEVELS 10 /* max number of nested kbd macros */ 51: 52: extern int errno; 53: 54: /****************************************************************************/ 55: /* stuff for the different states returned by the character editor routines */ 56: /****************************************************************************/ 57: 58: #define CCRETVAL char /* size needed for the different char editor */ 59: /* return values */ 60: 61: #define KEYCMD unsigned char /* size needed to index into CcFuncTbl */ 62: /* Must be unsigned */ 63: 64: typedef CCRETVAL(*PFCmd) (); /* pointer to function returning CCRETVAL */ 65: 66: struct KeyFuncs { /* for the "bind" shell command */ 67: char *name; /* function name for bind command */ 68: int func; /* function numeric value */ 69: #ifdef LONGFUNCS 70: char *description; /* description of function */ 71: #endif 72: }; 73: 74: extern PFCmd CcFuncTbl[]; /* table of available commands */ 75: extern KEYCMD CcKeyMap[]; /* keymap table, each index into above tbl */ 76: extern KEYCMD CcAltMap[]; /* Alt keymap table */ 77: extern KEYCMD CcEmacsMap[]; /* keymap table for Emacs default bindings */ 78: extern KEYCMD CcViMap[]; /* keymap table for Vi input mode defaults */ 79: extern KEYCMD CcViCmdMap[]; /* for Vi command mode defaults */ 80: extern struct KeyFuncs FuncNames[]; /* string names vs. CcFuncTbl indices */ 81: 82: EXTERN KEYCMD NumFuns; /* number of KEYCMDs in above table */ 83: 84: #define CC_ERROR 100 /* there should NOT be 100 different... */ 85: #define CC_FATAL 101 /* fatal error: inconsistant, must 86: * reset */ 87: #define CC_NORM 0 88: #define CC_NEWLINE 1 89: #define CC_EOF 2 90: #define CC_COMPLETE 3 91: #define CC_LIST_CHOICES 4 92: #define CC_LIST_GLOB 5 93: #define CC_EXPAND_GLOB 6 94: #define CC_HELPME 9 95: #define CC_CORRECT 10 96: #define CC_WHICH 11 97: #define CC_ARGHACK 12 98: #define CC_CORRECT_L 13 99: #define CC_REFRESH 14 100: #define CC_EXPAND_VARS 15 101: 102: /*************************/ 103: /* tty state */ 104: /*************************/ 105: 106: 107: #ifndef POSIX 108: #ifdef TERMIO 109: EXTERN struct termio nio; 110: EXTERN struct termio xio; 111: EXTERN struct termio testio; 112: 113: #if defined(OREO) || defined(hpux) || defined(_IBMR2) 114: EXTERN struct ltchars nlc; 115: EXTERN struct ltchars xlc; 116: EXTERN struct ltchars testlc; 117: 118: #endif /* OREO || hpux || _IBMR2 */ 119: 120: #else /* GSTTY */ 121: EXTERN struct sgttyb nb; /* original setup tty bits */ 122: EXTERN struct tchars ntc; 123: EXTERN struct ltchars nlc; 124: EXTERN int nlb; 125: 126: EXTERN struct sgttyb xb; /* running setup tty bits */ 127: EXTERN struct tchars xtc; 128: EXTERN struct ltchars xlc; 129: EXTERN int xlb; 130: 131: EXTERN struct sgttyb testsgb; /* running setup tty bits */ 132: EXTERN int testnlb; /* test local mode word */ 133: EXTERN struct tchars testtc; 134: EXTERN struct ltchars testlc; 135: 136: #ifdef TIOCGPAGE 137: EXTERN struct ttypagestat npc; 138: EXTERN struct ttypagestat xpc; 139: EXTERN struct ttypagestat testpc; 140: 141: #endif /* TIOCGPAGE */ 142: 143: #endif /* TERMIO */ 144: #else /* POSIX */ 145: EXTERN struct termios nio; 146: EXTERN struct termios xio; 147: EXTERN struct termios testio; 148: 149: #if defined(hpux) 150: EXTERN struct ltchars nlc; 151: EXTERN struct ltchars xlc; 152: EXTERN struct ltchars testlc; 153: 154: #endif /* hpux */ 155: #endif /* POSIX */ 156: 157: 158: 159: /****************************/ 160: /* Editor state and buffers */ 161: /****************************/ 162: 163: EXTERN KEYCMD *Cur_KeyMap; /* current command key map */ 164: EXTERN int replacemode; /* true if in overwrite mode */ 165: EXTERN Char GettingInput; /* true if getting an input line (mostly) */ 166: EXTERN Char NeedsRedraw; /* for editor and twenex error messages */ 167: EXTERN Char InputBuf[INBUFSIZ]; /* the real input data */ 168: EXTERN Char *LastChar, *Cursor; /* point to the next open space */ 169: EXTERN Char *InputLim; /* limit of size of InputBuf */ 170: EXTERN Char MetaNext; /* flags for ^V and ^[ functions */ 171: EXTERN Char AltKeyMap; /* Using alternative command map (for vi mode) */ 172: EXTERN Char VImode; /* true if running in vi mode (PWP 6-27-88) */ 173: EXTERN Char *Mark; /* the emacs "mark" (dot is Cursor) */ 174: EXTERN Char DoingArg; /* true if we have an argument */ 175: EXTERN int Argument; /* "universal" argument value */ 176: EXTERN KEYCMD LastCmd; /* previous command executed */ 177: EXTERN Char KillBuf[INBUFSIZ]; /* kill buffer */ 178: EXTERN Char *LastKill; /* points to end of kill buffer */ 179: EXTERN Char HistBuf[INBUFSIZ]; /* history buffer */ 180: EXTERN Char *LastHist; /* points to end of history buffer */ 181: EXTERN int Hist_num; /* what point up the history we are at now. */ 182: EXTERN Char WhichBuf[INBUFSIZ]; /* buffer for which command */ 183: EXTERN Char *LastWhich; /* points to end of which buffer */ 184: EXTERN Char *CursWhich; /* points to the cursor point in which buf */ 185: EXTERN int HistWhich; /* Hist_num is saved in this */ 186: EXTERN Char *SearchPrompt; /* points to string that holds search prompt */ 187: EXTERN Char DoingSearch; /* true if we are doing a history search */ 188: EXTERN char Expand; /* true if we are expanding a line */ 189: EXTERN Char HistLit; /* true if history lines are shown literal */ 190: EXTERN Char Cur_HistLit; /* Literal status of current show history line */ 191: 192: /* 193: * These are truly extern 194: */ 195: extern Char PromptBuf[]; 196: extern short SHIN, SHOUT; 197: extern int MacroLvl; 198: 199: EXTERN Char *KeyMacro[MAXMACROLEVELS]; 200: 201: EXTERN Char **Display; /* display buffer seed vector */ 202: EXTERN int CursorV, /* real cursor vertical (line) */ 203: CursorH, /* real cursor horisontal (column) */ 204: TermV, /* number of real screen lines 205: * (sizeof(DisplayBuf) / width */ 206: TermH; /* screen width */ 207: EXTERN Char **Vdisplay; /* new buffer */ 208: 209: /* Variables that describe terminal ability */ 210: EXTERN int T_Lines, T_Cols; /* Rows and Cols of the terminal */ 211: EXTERN Char T_CanIns; /* true if I can insert characters */ 212: EXTERN Char T_CanDel; /* dito for delete characters */ 213: EXTERN Char T_Tabs; /* true if tty interface is passing tabs */ 214: EXTERN speed_t T_Speed; /* Tty input Baud rate */ 215: EXTERN Char T_CanCEOL; /* true if we can clear to end of line */ 216: EXTERN Char T_CanUP; /* true if this term can do reverse linefeen */ 217: EXTERN Char T_HasMeta; /* true if we have a meta key */ 218: 219: /* note the extra characters in the index() call in this macro */ 220: #define isword(c) (Isalpha(c)||Isdigit(c)||Strchr(word_chars,c)) 221: #define min(x,y) (((x)<(y))?(x):(y)) 222: #define max(x,y) (((x)>(y))?(x):(y)) 223: 224: #include "ed.decls.h" 225: 226: #endif /* _h_ed */