Annotation of 43BSDTahoe/ucb/ex/ex_vis.h, revision 1.1.1.1

1.1       root        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.5 (Berkeley) 3/9/87
                      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   ex_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   Peek_key;       /* Peek ahead key */
                    238: var    bool    rubble;         /* Line is filthy (in hardcopy open), redraw! */
                    239: var    int     ex_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();

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.