1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)ex_vis.h	7.4 (Berkeley) 5/31/85
   7:  */
   8: 
   9: /*
  10:  * Ex version 3
  11:  * Mark Horton, UCB
  12:  * Bill Joy UCB
  13:  *
  14:  * Open and visual mode definitions.
  15:  *
  16:  * There are actually 4 major states in open/visual modes.  These
  17:  * are visual, crt open (where the cursor can move about the screen and
  18:  * the screen can scroll and be erased), one line open (on dumb glass-crt's
  19:  * like the adm3), and hardcopy open (for everything else).
  20:  *
  21:  * The basic state is given by bastate, and the current state by state,
  22:  * since we can be in pseudo-hardcopy mode if we are on an adm3 and the
  23:  * line is longer than 80.
  24:  */
  25: 
  26: var short   bastate;
  27: var short   state;
  28: 
  29: #define VISUAL      0
  30: #define CRTOPEN     1
  31: #define ONEOPEN     2
  32: #define HARDOPEN    3
  33: 
  34: /*
  35:  * The screen in visual and crtopen is of varying size; the basic
  36:  * window has top basWTOP and basWLINES lines are thereby implied.
  37:  * The current window (which may have grown from the basic size)
  38:  * has top WTOP and WLINES lines.  The top line of the window is WTOP,
  39:  * and the bottom line WBOT.  The line WECHO is used for messages,
  40:  * search strings and the like.  If WBOT==WECHO then we are in ONEOPEN
  41:  * or HARDOPEN and there is no way back to the line we were on if we
  42:  * go to WECHO (i.e. we will have to scroll before we go there, and
  43:  * we can't get back).  There are WCOLS columns per line.
  44:  * If WBOT!=WECHO then WECHO will be the last line on the screen
  45:  * and WBOT is the line before it.
  46:  */
  47: var short   basWTOP;
  48: var short   basWLINES;
  49: var short   WTOP;
  50: var short   WBOT;
  51: var short   WLINES;
  52: var short   WCOLS;
  53: var short   WECHO;
  54: 
  55: /*
  56:  * When we are dealing with the echo area we consider the window
  57:  * to be "split" and set the variable splitw.  Otherwise, moving
  58:  * off the bottom of the screen into WECHO causes a screen rollup.
  59:  */
  60: var bool    splitw;
  61: 
  62: /*
  63:  * Information about each line currently on the screen includes
  64:  * the y coordinate associated with the line, the printing depth
  65:  * of the line (0 indicates unknown), and a mask which indicates
  66:  * whether the line is "unclean", i.e. whether we should check
  67:  * to make sure the line is displayed correctly at the next
  68:  * appropriate juncture.
  69:  */
  70: struct vlinfo {
  71:     short   vliny;      /* Y coordinate */  /* mjm: was char */
  72:     short   vdepth;     /* Depth of displayed line */ /*mjm: was char */
  73:     short   vflags;     /* Is line potentially dirty ? */
  74: };
  75: var struct vlinfo  vlinfo[TUBELINES + 2];
  76: 
  77: #define DEPTH(c)    (vlinfo[c].vdepth)
  78: #define LINE(c)     (vlinfo[c].vliny)
  79: #define FLAGS(c)    (vlinfo[c].vflags)
  80: 
  81: #define VDIRT   1
  82: 
  83: /*
  84:  * Hacks to copy vlinfo structures around
  85:  */
  86: #ifdef  V6
  87:     /* Kludge to make up for no structure assignment */
  88:     struct {
  89:         long    longi;
  90:     };
  91: #	define    vlcopy(i, j)    i.longi = j.longi
  92: #else
  93: #	define    vlcopy(i, j)    i = j;
  94: #endif
  95: 
  96: /*
  97:  * The current line on the screen is represented by vcline.
  98:  * There are vcnt lines on the screen, the last being "vcnt - 1".
  99:  * Vcline is intimately tied to the current value of dot,
 100:  * and when command mode is used as a subroutine fancy footwork occurs.
 101:  */
 102: var short   vcline;
 103: var short   vcnt;
 104: 
 105: /*
 106:  * To allow many optimizations on output, an exact image of the terminal
 107:  * screen is maintained in the space addressed by vtube0.  The vtube
 108:  * array indexes this space as lines, and is shuffled on scrolls, insert+delete
 109:  * lines and the like rather than (more expensively) shuffling the screen
 110:  * data itself.  It is also rearranged during insert mode across line
 111:  * boundaries to make incore work easier.
 112:  */
 113: var char    *vtube[TUBELINES];
 114: var char    *vtube0;
 115: 
 116: /*
 117:  * The current cursor position within the current line is kept in
 118:  * cursor.  The current line is kept in linebuf.  During insertions
 119:  * we use the auxiliary array genbuf as scratch area.
 120:  * The cursor wcursor and wdot are used in operations within/spanning
 121:  * lines to mark the other end of the affected area, or the target
 122:  * for a motion.
 123:  */
 124: var char    *cursor;
 125: var char    *wcursor;
 126: var line    *wdot;
 127: 
 128: /*
 129:  * Undo information is saved in a LBSIZE buffer at "vutmp" for changes
 130:  * within the current line, or as for command mode for multi-line changes
 131:  * or changes on lines no longer the current line.
 132:  * The change kind "VCAPU" is used immediately after a U undo to prevent
 133:  * two successive U undo's from destroying the previous state.
 134:  */
 135: #define VNONE   0
 136: #define VCHNG   1
 137: #define VMANY   2
 138: #define VCAPU   3
 139: #define VMCHNG  4
 140: #define VMANYINS 5
 141: 
 142: var short   vundkind;   /* Which kind of undo - from above */
 143: var char    *vutmp;     /* Prev line image when "VCHNG" */
 144: 
 145: /*
 146:  * State information for undoing of macros.  The basic idea is that
 147:  * if the macro does only 1 change or even none, we don't treat it
 148:  * specially.  If it does 2 or more changes we want to be able to
 149:  * undo it as a unit.  We remember how many changes have been made
 150:  * within the current macro.  (Remember macros can be nested.)
 151:  */
 152: #define VC_NOTINMAC 0   /* Not in a macro */
 153: #define VC_NOCHANGE 1   /* In a macro, no changes so far */
 154: #define VC_ONECHANGE    2   /* In a macro, one change so far */
 155: #define VC_MANYCHANGE   3   /* In a macro, at least 2 changes so far */
 156: 
 157: var short   vch_mac;    /* Change state - one of the above */
 158: 
 159: /*
 160:  * For U undo's the line is grabbed by "vmove" after it first appears
 161:  * on that line.  The "vUNDdot" which specifies which line has been
 162:  * saved is selectively cleared when changes involving other lines
 163:  * are made, i.e. after a 'J' join.  This is because a 'JU' would
 164:  * lose completely the text of the line just joined on.
 165:  */
 166: var char    *vUNDcurs;  /* Cursor just before 'U' */
 167: var line    *vUNDdot;   /* The line address of line saved in vUNDsav */
 168: var line    vUNDsav;    /* Grabbed initial "*dot" */
 169: 
 170: #define killU()     vUNDdot = NOLINE
 171: 
 172: /*
 173:  * There are a number of cases where special behaviour is needed
 174:  * from deeply nested routines.  This is accomplished by setting
 175:  * the bits of hold, which acts to change the state of the general
 176:  * visual editing behaviour in specific ways.
 177:  *
 178:  * HOLDAT prevents the clreol (clear to end of line) routines from
 179:  * putting out @'s or ~'s on empty lines.
 180:  *
 181:  * HOLDDOL prevents the reopen routine from putting a '$' at the
 182:  * end of a reopened line in list mode (for hardcopy mode, e.g.).
 183:  *
 184:  * HOLDROL prevents spurious blank lines when scrolling in hardcopy
 185:  * open mode.
 186:  *
 187:  * HOLDQIK prevents the fake insert mode during repeated commands.
 188:  *
 189:  * HOLDPUPD prevents updating of the physical screen image when
 190:  * mucking around while in insert mode.
 191:  *
 192:  * HOLDECH prevents clearing of the echo area while rolling the screen
 193:  * backwards (e.g.) in deference to the clearing of the area at the
 194:  * end of the scroll (1 time instead of n times).  The fact that this
 195:  * is actually needed is recorded in heldech, which says that a clear
 196:  * of the echo area was actually held off.
 197:  */
 198: var short   hold;
 199: var short   holdupd;    /* Hold off update when echo line is too long */
 200: 
 201: #define HOLDAT      1
 202: #define HOLDDOL     2
 203: #define HOLDROL     4
 204: #define HOLDQIK     8
 205: #define HOLDPUPD    16
 206: #define HOLDECH     32
 207: #define HOLDWIG     64
 208: 
 209: /*
 210:  * Miscellaneous variables
 211:  */
 212: var short   CDCNT;      /* Count of ^D's in insert on this line */
 213: var char    DEL[VBSIZE];    /* Last deleted text */
 214: var bool    HADUP;      /* This insert line started with ^ then ^D */
 215: var bool    HADZERO;    /* This insert line started with 0 then ^D */
 216: var char    INS[VBSIZE];    /* Last inserted text */
 217: var int Vlines;     /* Number of file lines "before" vi command */
 218: var int Xcnt;       /* External variable holding last cmd's count */
 219: var bool    Xhadcnt;    /* Last command had explicit count? */
 220: var short   ZERO;
 221: var short   dir;        /* Direction for search (+1 or -1) */
 222: var short   doomed;     /* Disply chars right of cursor to be killed */
 223: var bool    gobblebl;   /* Wrapmargin space generated nl, eat a space */
 224: var bool    hadcnt;     /* (Almost) internal to vmain() */
 225: var bool    heldech;    /* We owe a clear of echo area */
 226: var bool    insmode;    /* Are in character insert mode */
 227: var char    lastcmd[5]; /* Chars in last command */
 228: var int lastcnt;    /* Count for last command */
 229: var char    *lastcp;    /* Save current command here to repeat */
 230: var bool    lasthad;    /* Last command had a count? */
 231: var short   lastvgk;    /* Previous input key, if not from keyboard */
 232: var short   lastreg;    /* Register with last command */
 233: var char    *ncols['z'-'a'+2];  /* Cursor positions of marks */
 234: var char    *notenam;   /* Name to be noted with change count */
 235: var char    *notesgn;   /* Change count from last command */
 236: var char    op;     /* Operation of current command */
 237: var short   Peekkey;    /* Peek ahead key */
 238: var bool    rubble;     /* Line is filthy (in hardcopy open), redraw! */
 239: var int vSCROLL;    /* Number lines to scroll on ^D/^U */
 240: var char    *vglobp;    /* Untyped input (e.g. repeat insert text) */
 241: var char    vmacbuf[VBSIZE];   /* Text of visual macro, hence nonnestable */
 242: var char    *vmacp;     /* Like vglobp but for visual macros */
 243: var char    *vmcurs;    /* Cursor for restore after undo d), e.g. */
 244: var short   vmovcol;    /* Column to try to keep on arrow keys */
 245: var bool    vmoving;    /* Are trying to keep vmovcol */
 246: var short   vreg;       /* Reg for this command */   /* mjm: was char */
 247: var short   wdkind;     /* Liberal/conservative words? */
 248: var char    workcmd[5]; /* Temporary for lastcmd */
 249: 
 250: 
 251: /*
 252:  * Macros
 253:  */
 254: #define INF     30000
 255: #define LASTLINE    LINE(vcnt)
 256: #define OVERBUF     QUOTE
 257: #define beep        obeep
 258: #define cindent()   ((outline - vlinfo[vcline].vliny) * WCOLS + outcol)
 259: #define vputp(cp, cnt)  tputs(cp, cnt, vputch)
 260: #define vputc(c)    putch(c)
 261: 
 262: /*
 263:  * Function types
 264:  */
 265: int beep();
 266: int qcount();
 267: int vchange();
 268: int vdelete();
 269: int vgrabit();
 270: int vinschar();
 271: int vmove();
 272: int vputchar();
 273: int vshift();
 274: int vyankit();

Defined variables

CDCNT defined in line 212; used 5 times
DEL defined in line 213; used 8 times
INS defined in line 216; used 9 times
Vlines defined in line 217; used 3 times
WCOLS defined in line 52; used 70 times
Xcnt defined in line 218; used 5 times
ZERO defined in line 220; used 24 times
bastate defined in line 26; used 8 times
dir defined in line 221; used 38 times
doomed defined in line 222; used 47 times
holdupd defined in line 199; used 12 times
lastcmd defined in line 227; used 4 times
lastcnt defined in line 228; used 3 times
lastreg defined in line 232; used 7 times
lastvgk defined in line 231; used 4 times
notesgn defined in line 235; used 4 times
op defined in line 236; used 34 times
vSCROLL defined in line 239; used 6 times
vUNDcurs defined in line 166; used 2 times
vch_mac defined in line 157; used 8 times
vcline defined in line 102; used 146 times
vlinfo defined in line 75; used 17 times
vmacbuf defined in line 241; used 5 times
vmcurs defined in line 243; used 4 times
vmovcol defined in line 244; used 6 times
vtube0 defined in line 114; used 16 times
wcursor defined in line 125; used 163 times
wdkind defined in line 247; used 7 times
workcmd defined in line 248; used 5 times

Defined struct's

vlinfo defined in line 70; used 14 times

Defined macros

DEPTH defined in line 77; used 27 times
FLAGS defined in line 79; used 7 times
HOLDDOL defined in line 202; used 2 times
HOLDPUPD defined in line 205; used 5 times
HOLDWIG defined in line 207; used 4 times
INF defined in line 254; used 1 times
LASTLINE defined in line 255; used 6 times
LINE defined in line 78; used 52 times
OVERBUF defined in line 256; used 7 times
VCAPU defined in line 138; used 3 times
VC_MANYCHANGE defined in line 155; used 1 times
VC_NOCHANGE defined in line 153; used 1 times
VC_ONECHANGE defined in line 154; used 1 times
VDIRT defined in line 81; used 14 times
VMANYINS defined in line 140; used 1 times
VMCHNG defined in line 139; used 2 times
VNONE defined in line 135; used 3 times
cindent defined in line 258; used 8 times
vlcopy defined in line 93; used 4 times
vputc defined in line 260; used 9 times
vputp defined in line 259; used 34 times

Usage of this include

Last modified: 1985-06-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2077
Valid CSS Valid XHTML 1.0 Strict