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

Defined variables

CDCNT defined in line 206; used 5 times
Vlines defined in line 211; used 3 times
bastate defined in line 20; used 8 times
dir defined in line 215; used 38 times
holdupd defined in line 193; used 12 times
lastcmd defined in line 221; used 4 times
lastcnt defined in line 222; used 3 times
lastvgk defined in line 225; used 4 times
notesgn defined in line 229; used 4 times
vSCROLL defined in line 233; used 6 times
vUNDcurs defined in line 160; used 2 times
vlinfo defined in line 69; used 17 times
vmacbuf defined in line 235; used 5 times
vmcurs defined in line 237; used 4 times
vmovcol defined in line 238; used 6 times
vtube0 defined in line 108; used 16 times
wcursor defined in line 119; used 161 times
wdkind defined in line 241; used 7 times

Defined struct's

vlinfo defined in line 64; used 14 times

Defined macros

FLAGS defined in line 73; used 7 times
HOLDDOL defined in line 196; used 2 times
HOLDPUPD defined in line 199; used 5 times
HOLDWIG defined in line 201; used 4 times
INF defined in line 248; used 1 times
LASTLINE defined in line 249; used 6 times
VCAPU defined in line 132; used 3 times
VC_MANYCHANGE defined in line 149; used 1 times
VC_NOCHANGE defined in line 147; used 1 times
VC_ONECHANGE defined in line 148; used 1 times
VDIRT defined in line 75; used 14 times
VMANYINS defined in line 134; used 1 times
VMCHNG defined in line 133; used 2 times
cindent defined in line 252; used 8 times
vlcopy defined in line 87; used 4 times
vputc defined in line 254; used 9 times

Usage of this include

Last modified: 1981-09-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1574
Valid CSS Valid XHTML 1.0 Strict