Annotation of coherent/g/usr/bin/vi/curses.h, revision 1.1.1.1

1.1       root        1: /* curses.h */
                      2: 
                      3: /* Author:
                      4:  *     Steve Kirkendall
                      5:  *     14407 SW Teal Blvd. #C
                      6:  *     Beaverton, OR 97005
                      7:  *     [email protected]
                      8:  */
                      9: 
                     10: 
                     11: /* This is the header file for a small, fast, fake curses package */
                     12: 
                     13: /* termcap stuff */
                     14: extern char    *tgoto();
                     15: extern char    *tgetstr();
                     16: extern void    tputs();
                     17: 
                     18: #if MSDOS
                     19: /* BIOS interface used instead of termcap for MS-DOS */
                     20: extern int     vmode;
                     21: extern void    v_up();
                     22: extern void    v_cb();
                     23: extern void    v_cs();
                     24: extern void    v_ce();
                     25: extern void    v_cl();
                     26: extern void    v_cd();
                     27: extern void    v_al();
                     28: extern void    v_dl();
                     29: extern void    v_sr();
                     30: extern void    v_move();
                     31: #endif
                     32: 
                     33: /* faddch() is a function.  a pointer to it is passed to tputs() */
                     34: extern int     faddch();
                     35: 
                     36: /* data types */
                     37: #define WINDOW char
                     38: 
                     39: /* CONSTANTS & SYMBOLS */
                     40: #define TRUE           1
                     41: #define FALSE          0
                     42: #define A_NORMAL       0
                     43: #define A_STANDOUT     1
                     44: #define A_BOLD         2
                     45: #define A_UNDERLINE    3
                     46: #define A_ALTCHARSET   4
                     47: #define A_POPUP                5
                     48: #define A_VISIBLE      6
                     49: #define KBSIZ          4096
                     50: 
                     51: /* figure out how many function keys we need to allow. */
                     52: #ifndef NO_FKEY
                     53: # ifdef NO_SHIFT_FKEY
                     54: #  define      NFKEYS  10
                     55: # else
                     56: #  ifdef NO_CTRL_FKEY
                     57: #   define     NFKEYS  20
                     58: #  else
                     59: #   ifdef NO_ALT_FKEY
                     60: #    define    NFKEYS  30
                     61: #   else
                     62: #    define    NFKEYS  40
                     63: #   endif
                     64: #  endif
                     65: # endif
                     66: extern char    *FKEY[NFKEYS];  /* :k0=:...:k9=: codes sent by function keys */
                     67: #endif
                     68: 
                     69: /* extern variables, defined in curses.c */
                     70: extern char    *termtype;      /* name of terminal entry */
                     71: extern short   ospeed;         /* tty speed, eg B2400 */
                     72: #if OSK
                     73: extern char PC_;       /* Pad char */
                     74: extern char    *BC;    /* Backspace char string */
                     75: #else
                     76: extern char    PC;             /* Pad char */
                     77: #endif
                     78: extern WINDOW  *stdscr;        /* pointer into kbuf[] */
                     79: extern WINDOW  kbuf[KBSIZ];    /* a very large output buffer */
                     80: extern int     LINES;          /* :li#: number of rows */
                     81: extern int     COLS;           /* :co#: number of columns */
                     82: extern int     AM;             /* :am:  boolean: auto margins? */
                     83: extern int     PT;             /* :pt:  boolean: physical tabs? */
                     84: extern char    *VB;            /* :vb=: visible bell */
                     85: extern char    *UP;            /* :up=: move cursor up */
                     86: extern char    *SO;            /* :so=: standout start */
                     87: extern char    *SE;            /* :se=: standout end */
                     88: extern char    *US;            /* :us=: underline start */
                     89: extern char    *UE;            /* :ue=: underline end */
                     90: extern char    *MD;            /* :md=: bold start */
                     91: extern char    *ME;            /* :me=: bold end */
                     92: extern char    *AS;            /* :as=: alternate (italic) start */
                     93: extern char    *AE;            /* :ae=: alternate (italic) end */
                     94: #ifndef NO_VISIBLE
                     95: extern char    *MV;            /* :mv=: "visible" selection start */
                     96: #endif
                     97: extern char    *CM;            /* :cm=: cursor movement */
                     98: extern char    *CE;            /* :ce=: clear to end of line */
                     99: extern char    *CD;            /* :cd=: clear to end of screen */
                    100: extern char    *AL;            /* :al=: add a line */
                    101: extern char    *DL;            /* :dl=: delete a line */
                    102: #if OSK
                    103: extern char    *SR_;           /* :sr=: scroll reverse */
                    104: #else
                    105: extern char    *SR;            /* :sr=: scroll reverse */
                    106: #endif
                    107: extern char    *KU;            /* :ku=: sequence sent by up key */
                    108: extern char    *KD;            /* :kd=: sequence sent by down key */
                    109: extern char    *KL;            /* :kl=: sequence sent by left key */
                    110: extern char    *KR;            /* :kr=: sequence sent by right key */
                    111: extern char    *PU;            /* :PU=: key sequence sent by PgUp key */
                    112: extern char    *PD;            /* :PD=: key sequence sent by PgDn key */
                    113: extern char    *HM;            /* :HM=: key sequence sent by Home key */
                    114: extern char    *EN;            /* :EN=: key sequence sent by End key */
                    115: extern char    *KI;            /* :kI=: key sequence sent by Insert key */
                    116: extern char    *IM;            /* :im=: insert mode start */
                    117: extern char    *IC;            /* :ic=: insert following char */
                    118: extern char    *EI;            /* :ei=: insert mode end */
                    119: extern char    *DC;            /* :dc=: delete a character */
                    120: extern char    *TI;            /* :ti=: terminal init */       /* GB */
                    121: extern char    *TE;            /* :te=: terminal exit */       /* GB */
                    122: #ifndef NO_CURSORSHAPE
                    123: extern char    *CQ;            /* :cQ=: normal cursor */
                    124: extern char    *CX;            /* :cX=: cursor used for EX command/entry */
                    125: extern char    *CV;            /* :cV=: cursor used for VI command mode */
                    126: extern char    *CI;            /* :cI=: cursor used for VI input mode */
                    127: extern char    *CR;            /* :cR=: cursor used for VI replace mode */
                    128: #endif
                    129: extern char    *aend;          /* end an attribute -- either UE or ME */
                    130: extern char    ERASEKEY;       /* taken from the ioctl structure */
                    131: #ifndef NO_COLOR
                    132: extern char    SOcolor[];
                    133: extern char    SEcolor[];
                    134: extern char    UScolor[];
                    135: extern char    UEcolor[];
                    136: extern char    MDcolor[];
                    137: extern char    MEcolor[];
                    138: extern char    AScolor[];
                    139: extern char    AEcolor[];
                    140: # ifndef NO_POPUP
                    141: extern char    POPUPcolor[];
                    142: # endif
                    143: # ifndef NO_VISIBLE
                    144: extern char    VISIBLEcolor[];
                    145: # endif
                    146: extern char    normalcolor[];
                    147: #endif /* undef NO_COLOR */
                    148: 
                    149: /* Msdos-versions may use bios; others always termcap.
                    150:  * Will emit some 'code has no effect' warnings in unix.
                    151:  */
                    152:  
                    153: #if MSDOS
                    154: extern char o_pcbios[1];               /* BAH! */
                    155: #define        CHECKBIOS(x,y)  (*o_pcbios ? (x) : (y))
                    156: #define VOIDBIOS(x,y)  {if (*o_pcbios) {x;} else {y;}}
                    157: #else
                    158: #define        CHECKBIOS(x,y)  (y)
                    159: #define VOIDBIOS(x,y)  {y;}
                    160: #endif
                    161: 
                    162: #ifndef NO_COLOR
                    163: # define setcolor(m,a) CHECKBIOS(bioscolor(m,a), ansicolor(m,a))
                    164: # define fixcolor()    VOIDBIOS(;, tputs(normalcolor, 1, faddch))
                    165: # define quitcolor()   CHECKBIOS(biosquit(), ansiquit())
                    166: # define do_SO()       VOIDBIOS((vmode=A_STANDOUT), tputs(SOcolor, 1, faddch))
                    167: # define do_SE()       VOIDBIOS((vmode=A_NORMAL), tputs(SEcolor, 1, faddch))
                    168: # define do_US()       VOIDBIOS((vmode=A_UNDERLINE), tputs(UScolor, 1, faddch))
                    169: # define do_UE()       VOIDBIOS((vmode=A_NORMAL), tputs(UEcolor, 1, faddch))
                    170: # define do_MD()       VOIDBIOS((vmode=A_BOLD), tputs(MDcolor, 1, faddch))
                    171: # define do_ME()       VOIDBIOS((vmode=A_NORMAL), tputs(MEcolor, 1, faddch))
                    172: # define do_AS()       VOIDBIOS((vmode=A_ALTCHARSET), tputs(AScolor, 1, faddch))
                    173: # define do_AE()       VOIDBIOS((vmode=A_NORMAL), tputs(AEcolor, 1, faddch))
                    174: # define do_POPUP()    VOIDBIOS((vmode=A_POPUP), tputs(POPUPcolor, 1, faddch))
                    175: # define do_VISIBLE()  VOIDBIOS((vmode=A_VISIBLE), tputs(VISIBLEcolor, 1, faddch))
                    176: #else
                    177: # define do_SO()       VOIDBIOS((vmode=A_STANDOUT), tputs(SO, 1, faddch))
                    178: # define do_SE()       VOIDBIOS((vmode=A_NORMAL), tputs(SE, 1, faddch))
                    179: # define do_US()       VOIDBIOS((vmode=A_UNDERLINE), tputs(US, 1, faddch))
                    180: # define do_UE()       VOIDBIOS((vmode=A_NORMAL), tputs(UE, 1, faddch))
                    181: # define do_MD()       VOIDBIOS((vmode=A_BOLD), tputs(MD, 1, faddch))
                    182: # define do_ME()       VOIDBIOS((vmode=A_NORMAL), tputs(ME, 1, faddch))
                    183: # define do_AS()       VOIDBIOS((vmode=A_ALTCHARSET), tputs(AS, 1, faddch))
                    184: # define do_AE()       VOIDBIOS((vmode=A_NORMAL), tputs(AE, 1, faddch))
                    185: # define do_POPUP()    VOIDBIOS((vmode=A_POPUP), tputs(SO, 1, faddch))
                    186: # define do_VISIBLE()  VOIDBIOS((vmode=A_VISIBLE), tputs(MV, 1, faddch))
                    187: #endif
                    188: 
                    189: #define        do_VB()         VOIDBIOS(;, tputs(VB, 1, faddch))
                    190: #define        do_UP()         VOIDBIOS(v_up(), tputs(UP, 1, faddch))
                    191: #undef do_CM           /* move */
                    192: #define        do_CE()         VOIDBIOS(v_ce(), tputs(CE, 1, faddch))
                    193: #define        do_CD()         VOIDBIOS(v_cd(), tputs(CD, 1, faddch))
                    194: #define        do_AL()         VOIDBIOS(v_al(), tputs(AL, LINES, faddch))
                    195: #define        do_DL()         VOIDBIOS(v_dl(), tputs(DL, LINES, faddch))
                    196: #if OSK
                    197: #define        do_SR()         VOIDBIOS(v_sr(), tputs(SR_, 1, faddch))
                    198: #else
                    199: #define        do_SR()         VOIDBIOS(v_sr(), tputs(SR, 1, faddch))
                    200: #endif
                    201: #define        do_IM()         VOIDBIOS(;, tputs(IM, 1, faddch))
                    202: #define        do_IC()         VOIDBIOS(;, tputs(IC, 1, faddch))
                    203: #define        do_EI()         VOIDBIOS(;, tputs(EI, 1, faddch))
                    204: #define        do_DC()         VOIDBIOS(;, tputs(DC, COLS, faddch))
                    205: #define        do_TI()         VOIDBIOS(;, (void)ttywrite(TI, (unsigned)strlen(TI)))
                    206: #define        do_TE()         VOIDBIOS(;, (void)ttywrite(TE, (unsigned)strlen(TE)))
                    207: #ifndef NO_CURSORSHAPE
                    208: # define do_CQ()       VOIDBIOS(v_cs(), tputs(CQ, 1, faddch))
                    209: # define do_CX()       VOIDBIOS(v_cs(), tputs(CX, 1, faddch))
                    210: # define do_CV()       VOIDBIOS(v_cs(), tputs(CV, 1, faddch))
                    211: # define do_CI()       VOIDBIOS(v_cb(), tputs(CI, 1, faddch))
                    212: # define do_CR()       VOIDBIOS(v_cb(), tputs(CR, 1, faddch))
                    213: #endif
                    214: #ifndef NO_COLOR
                    215: # define do_aend()     VOIDBIOS((vmode=A_NORMAL), endcolor())
                    216: #else
                    217: # define do_aend()     VOIDBIOS((vmode=A_NORMAL), tputs(aend, 1, faddch))
                    218: #endif
                    219: 
                    220: #define        has_AM          CHECKBIOS(1, AM)
                    221: #define        has_PT          CHECKBIOS(0, PT)
                    222: #define        has_VB          CHECKBIOS((char *)0, VB)
                    223: #define        has_UP          CHECKBIOS((char *)1, UP)
                    224: #define        has_SO          CHECKBIOS((char)1, (*SO))
                    225: #define        has_SE          CHECKBIOS((char)1, (*SE))
                    226: #define        has_US          CHECKBIOS((char)1, (*US))
                    227: #define        has_UE          CHECKBIOS((char)1, (*UE))
                    228: #define        has_MD          CHECKBIOS((char)1, (*MD))
                    229: #define        has_ME          CHECKBIOS((char)1, (*ME))
                    230: #define        has_AS          CHECKBIOS((char)1, (*AS))
                    231: #define        has_AE          CHECKBIOS((char)1, (*AE))
                    232: #undef has_CM          /* cursor move: don't need */
                    233: #define        has_CB          CHECKBIOS(1, 0)
                    234: #define        has_CS          CHECKBIOS(1, 0)
                    235: #define        has_CE          CHECKBIOS((char *)1, CE)
                    236: #define        has_CD          CHECKBIOS((char *)1, CD)
                    237: #define        has_AL          CHECKBIOS((char *)1, AL)
                    238: #define        has_DL          CHECKBIOS((char *)1, DL)
                    239: #if OSK
                    240: #define        has_SR          CHECKBIOS((char *)1, SR_)
                    241: #else
                    242: #define        has_SR          CHECKBIOS((char *)1, SR)
                    243: #endif
                    244: #define        has_KU          KU
                    245: #define        has_KD          KD
                    246: #define        has_KL          KL
                    247: #define        has_KR          KR
                    248: #define has_HM         HM
                    249: #define has_EN         EN
                    250: #define has_PU         PU
                    251: #define has_PD         PD
                    252: #define has_KI         KI
                    253: #define        has_IM          CHECKBIOS((char)0, (*IM))
                    254: #define        has_IC          CHECKBIOS((char)0, (*IC))
                    255: #define        has_EI          CHECKBIOS((char)0, (*EI))
                    256: #define        has_DC          CHECKBIOS((char *)0, DC)
                    257: #define        has_TI          CHECKBIOS((char)0, (*TI))
                    258: #define        has_TE          CHECKBIOS((char)0, (*TE))
                    259: #ifndef NO_CURSORSHAPE
                    260: #define has_CQ         CHECKBIOS((char *)1, CQ)
                    261: #endif
                    262: 
                    263: /* (pseudo)-Curses-functions */
                    264: 
                    265: #ifdef lint
                    266: # define _addCR                VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : (stdscr[-1] = '\n')))
                    267: #else
                    268: # if OSK
                    269: #  define _addCR       VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\l') : (stdscr[-1] = stdscr[-1])))
                    270: # else
                    271: #  define _addCR       VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : 0))
                    272: # endif
                    273: #endif
                    274: 
                    275: #ifdef AZTEC_C
                    276: # define qaddch(ch)    CHECKBIOS(v_put(ch), (*stdscr = (ch), *stdscr++))
                    277: #else
                    278: #define qaddch(ch)     CHECKBIOS(v_put(ch), (*stdscr++ = (ch)))
                    279: #endif
                    280: 
                    281: #if OSK
                    282: #define addch(ch)      if (qaddch(ch) == '\n') qaddch('\l'); else
                    283: #else
                    284: #define addch(ch)      if (qaddch(ch) == '\n') qaddch('\r'); else
                    285: #endif
                    286: 
                    287: extern void initscr();
                    288: extern void endwin();
                    289: extern void suspend_curses();
                    290: extern void resume_curses();
                    291: extern void attrset();
                    292: extern void insch();
                    293: extern void qaddstr();
                    294: extern void wrefresh();
                    295: extern void wqrefresh();
                    296: #define addstr(str)    {qaddstr(str); _addCR;}
                    297: #define move(y,x)      VOIDBIOS(v_move(x,y), tputs(tgoto(CM, x, y), 1, faddch))
                    298: #define mvaddch(y,x,ch)        {move(y,x); addch(ch);}
                    299: #define refresh()      VOIDBIOS(;, wrefresh())
                    300: #define standout()     do_SO()
                    301: #define standend()     do_SE()
                    302: #define clrtoeol()     do_CE()
                    303: #define clrtobot()     do_CD()
                    304: #define insertln()     do_AL()
                    305: #define deleteln()     do_DL()
                    306: #define delch()                do_DC()
                    307: #define scrollok(w,b)
                    308: #define raw()
                    309: #define echo()
                    310: #define cbreak()
                    311: #define noraw()
                    312: #define noecho()
                    313: #define nocbreak()

unix.superglobalmegacorp.com

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