Annotation of 3BSD/cmd/ex/ex_vis.h, revision 1.1

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

unix.superglobalmegacorp.com

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