1: /* Copyright (c) 1979 Regents of the University of California */
   2: /*
   3:  * Ex version 2
   4:  * Mark Horton, UCB
   5:  * Bill Joy UCB
   6:  *
   7:  * Open and visual mode definitions.
   8:  *
   9:  * There are actually 4 major states in open/visual modes.  These
  10:  * are visual, crt open (where the cursor can move about the screen and
  11:  * the screen can scroll and be erased), one line open (on dumb glass-crt's
  12:  * like the adm3), and hardcopy open (for everything else).
  13:  *
  14:  * The basic state is given by bastate, and the current state by state,
  15:  * since we can be in pseudo-hardcopy mode if we are on an adm3 and the
  16:  * line is longer than 80.
  17:  */
  18: 
  19: #ifdef OPENCODE
  20: short   bastate;
  21: short   state;
  22: #endif
  23: 
  24: #define VISUAL      0
  25: #define CRTOPEN     1
  26: #define ONEOPEN     2
  27: #define HARDOPEN    3
  28: 
  29: /*
  30:  * The screen in visual and crtopen is of varying size; the basic
  31:  * window has top basWTOP and basWLINES lines are thereby implied.
  32:  * The current window (which may have grown from the basic size)
  33:  * has top WTOP and WLINES lines.  The top line of the window is WTOP,
  34:  * and the bottom line WBOT.  The line WECHO is used for messages,
  35:  * search strings and the like.  If WBOT==WECHO then we are in ONEOPEN
  36:  * or HARDOPEN and there is no way back to the line we were on if we
  37:  * go to WECHO (i.e. we will have to scroll before we go there, and
  38:  * we can't get back).  There are WCOLS columns per line.
  39:  * If WBOT!=WECHO then WECHO will be the last line on the screen
  40:  * and WBOT is the line before it.
  41:  */
  42: short   basWTOP;
  43: short   basWLINES;
  44: short   WTOP;
  45: short   WBOT;
  46: short   WLINES;
  47: short   WCOLS;
  48: short   WECHO;
  49: 
  50: /*
  51:  * When we are dealing with the echo area we consider the window
  52:  * to be "split" and set the variable splitw.  Otherwise, moving
  53:  * off the bottom of the screen into WECHO causes a screen rollup.
  54:  */
  55: bool    splitw;
  56: 
  57: /*
  58:  * Information about each line currently on the screen includes
  59:  * the y coordinate associated with the line, the printing depth
  60:  * of the line (0 indicates unknown), and a mask which indicates
  61:  * whether the line is "unclean", i.e. whether we should check
  62:  * to make sure the line is displayed correctly at the next
  63:  * appropriate juncture.
  64:  */
  65: struct vlinfo {
  66:     char    vliny;      /* Y coordinate */
  67:     char    vdepth;     /* Depth of displayed line */
  68:     short   vflags;     /* Is line potentially dirty ? */
  69: } 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: short   vcline;
  97: 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: char    *vtube[TUBELINES];
 108: 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: char    *cursor;
 119: char    *wcursor;
 120: 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: short   vundkind;   /* Which kind of undo - from above */
 137: char    *vutmp;     /* Prev line image when "VCHNG" */
 138: 
 139: /*
 140:  * For U undo's the line is grabbed by "vmove" after it first appears
 141:  * on that line.  The "vUNDdot" which specifies which line has been
 142:  * saved is selectively cleared when changes involving other lines
 143:  * are made, i.e. after a 'J' join.  This is because a 'JU' would
 144:  * lose completely the text of the line just joined on.
 145:  */
 146: char    *vUNDcurs;  /* Cursor just before 'U' */
 147: line    *vUNDdot;   /* The line address of line saved in vUNDsav */
 148: line    vUNDsav;    /* Grabbed initial "*dot" */
 149: 
 150: #define killU()     vUNDdot = NOLINE
 151: 
 152: /*
 153:  * There are a number of cases where special behaviour is needed
 154:  * from deeply nested routines.  This is accomplished by setting
 155:  * the bits of hold, which acts to change the state of the general
 156:  * visual editing behaviour in specific ways.
 157:  *
 158:  * HOLDAT prevents the clreol (clear to end of line) routines from
 159:  * putting out @'s or ~'s on empty lines.
 160:  *
 161:  * HOLDDOL prevents the reopen routine from putting a '$' at the
 162:  * end of a reopened line in list mode (for hardcopy mode, e.g.).
 163:  *
 164:  * HOLDROL prevents spurious blank lines when scrolling in hardcopy
 165:  * open mode.
 166:  *
 167:  * HOLDQIK prevents the fake insert mode during repeated commands.
 168:  *
 169:  * HOLDPUPD prevents updating of the physical screen image when
 170:  * mucking around while in insert mode.
 171:  *
 172:  * HOLDECH prevents clearing of the echo area while rolling the screen
 173:  * backwards (e.g.) in deference to the clearing of the area at the
 174:  * end of the scroll (1 time instead of n times).  The fact that this
 175:  * is actually needed is recorded in heldech, which says that a clear
 176:  * of the echo area was actually held off.
 177:  */
 178: short   hold;
 179: short   holdupd;        /* Hold off update when echo line is too long */
 180: 
 181: #define HOLDAT      1
 182: #define HOLDDOL     2
 183: #define HOLDROL     4
 184: #define HOLDQIK     8
 185: #define HOLDPUPD    16
 186: #define HOLDECH     32
 187: #define HOLDWIG     64
 188: 
 189: /*
 190:  * Miscellaneous variables
 191:  */
 192: short   CDCNT;          /* Count of ^D's in insert on this line */
 193: char    DEL[VBSIZE];        /* Last deleted text */
 194: bool    HADUP;          /* This insert line started with ^ then ^D */
 195: bool    HADZERO;        /* This insert line started with 0 then ^D */
 196: char    INS[VBSIZE];        /* Last inserted text */
 197: short   Vlines;         /* Number of file lines "before" vi command */
 198: short   Xcnt;           /* External variable holding last cmd's count */
 199: bool    Xhadcnt;        /* Last command had explicit count? */
 200: short   ZERO;
 201: short   dir;            /* Direction for search (+1 or -1) */
 202: short   doomed;         /* Disply chars right of cursor to be killed */
 203: bool    gobblebl;       /* Wrapmargin space generated nl, eat a space */
 204: bool    hadcnt;         /* (Almost) internal to vmain() */
 205: bool    heldech;        /* We owe a clear of echo area */
 206: bool    insmode;        /* Are in character insert mode */
 207: char    lastcmd[5];     /* Chars in last command */
 208: short   lastcnt;        /* Count for last command */
 209: char    *lastcp;        /* Save current command here to repeat */
 210: bool    lasthad;        /* Last command had a count? */
 211: short   lastvgk;        /* Previous input key, if not from keyboard */
 212: short   lastreg;        /* Register with last command */
 213: char    *ncols['z'-'a'+2];  /* Cursor positions of marks */
 214: char    *notenam;       /* Name to be noted with change count */
 215: char    *notesgn;       /* Change count from last command */
 216: char    op;         /* Operation of current command */
 217: short   Peekkey;        /* Peek ahead key */
 218: bool    rubble;         /* Line is filthy (in hardcopy open), redraw! */
 219: short   vSCROLL;        /* Number lines to scroll on ^D/^U */
 220: char    *vglobp;        /* Untyped input (e.g. repeat insert text) */
 221: char    vmacbuf[VBSIZE];    /* Text of visual macro, hence nonnestable */
 222: char    *vmacp;         /* Like vglobp but for visual macros */
 223: char    *vmcurs;        /* Cursor for restore after undo d), e.g. */
 224: short   vmovcol;        /* Column to try to keep on arrow keys */
 225: bool    vmoving;        /* Are trying to keep vmovcol */
 226: char    vreg;           /* Register for this command */
 227: short   wdkind;         /* Liberal/conservative words? */
 228: char    workcmd[5];     /* Temporary for lastcmd */
 229: 
 230: 
 231: /*
 232:  * Macros
 233:  */
 234: #define INF     30000
 235: #define LASTLINE    LINE(vcnt)
 236: #define OVERBUF     QUOTE
 237: #define beep        obeep
 238: #define cindent()   ((outline - vlinfo[vcline].vliny) * WCOLS + outcol)
 239: #define vputp(cp, cnt)  tputs(cp, cnt, vputch)
 240: #define vputc(c)    putch(c)
 241: 
 242: /*
 243:  * Function types
 244:  */
 245: int beep();
 246: int qcount();
 247: int vchange();
 248: int vdelete();
 249: int vgrabit();
 250: int vinschar();
 251: int vmove();
 252: int vputchar();
 253: int vshift();
 254: int vyankit();

Defined variables

CDCNT defined in line 192; used 5 times
Vlines defined in line 197; used 3 times
bastate defined in line 20; used 8 times
dir defined in line 201; used 38 times
holdupd defined in line 179; used 12 times
lastcmd defined in line 207; used 4 times
lastcnt defined in line 208; used 3 times
lastvgk defined in line 211; used 4 times
notesgn defined in line 215; used 4 times
vSCROLL defined in line 219; used 6 times
vUNDcurs defined in line 146; used 2 times
vlinfo defined in line 69; used 17 times
vmacbuf defined in line 221; never used
vmacp defined in line 222; used 1 times
vmcurs defined in line 223; used 4 times
vmovcol defined in line 224; used 6 times
vtube0 defined in line 108; used 16 times
wcursor defined in line 119; used 160 times
wdkind defined in line 227; used 5 times

Defined struct's

vlinfo defined in line 65; used 12 times

Defined macros

FLAGS defined in line 73; used 7 times
HOLDDOL defined in line 182; used 2 times
HOLDPUPD defined in line 185; used 5 times
HOLDWIG defined in line 187; used 4 times
INF defined in line 234; used 1 times
LASTLINE defined in line 235; used 6 times
VCAPU defined in line 132; used 3 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 238; used 8 times
vlcopy defined in line 87; used 4 times
vputc defined in line 240; used 8 times

Usage of this include

Last modified: 1980-09-13
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1221
Valid CSS Valid XHTML 1.0 Strict