Annotation of coherent/d/usr/bin/elvis/curses.h, revision 1.1

1.1     ! root        1: /* curses.h */
        !             2: 
        !             3: /* Author:
        !             4:  *     Steve Kirkendall
        !             5:  *     16820 SW Tallac Way
        !             6:  *     Beaverton, OR 97006
        !             7:  *     [email protected], or ...uunet!tektronix!psueea!jove!kirkenda
        !             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: #if MSDOS
        !            48: #define KBSIZ          (10*1024)
        !            49: #else
        !            50: #define KBSIZ          (6*1024)
        !            51: #endif
        !            52: 
        !            53: /* extern variables, defined in curses.c */
        !            54: extern short   ospeed;         /* tty speed, eg B2400 */
        !            55: #if OSK
        !            56: extern char PC_;       /* Pad char */
        !            57: extern char    *BC;    /* Backspace char string */
        !            58: #else
        !            59: extern char    PC;             /* Pad char */
        !            60: #endif
        !            61: extern WINDOW  *stdscr;        /* pointer into kbuf[] */
        !            62: extern WINDOW  kbuf[KBSIZ];    /* a very large output buffer */
        !            63: extern int     LINES;          /* :li#: number of rows */
        !            64: extern int     COLS;           /* :co#: number of columns */
        !            65: extern int     AM;             /* :am:  boolean: auto margins? */
        !            66: extern int     PT;             /* :pt:  boolean: physical tabs? */
        !            67: extern char    *VB;            /* :vb=: visible bell */
        !            68: extern char    *UP;            /* :up=: move cursor up */
        !            69: extern char    *SO;            /* :so=: standout start */
        !            70: extern char    *SE;            /* :se=: standout end */
        !            71: extern char    *US;            /* :us=: underline start */
        !            72: extern char    *UE;            /* :ue=: underline end */
        !            73: extern char    *MD;            /* :md=: bold start */
        !            74: extern char    *ME;            /* :me=: bold end */
        !            75: extern char    *AS;            /* :as=: alternate (italic) start */
        !            76: extern char    *AE;            /* :ae=: alternate (italic) end */
        !            77: extern char    *CM;            /* :cm=: cursor movement */
        !            78: extern char    *CE;            /* :ce=: clear to end of line */
        !            79: extern char    *CD;            /* :cd=: clear to end of screen */
        !            80: extern char    *AL;            /* :al=: add a line */
        !            81: extern char    *DL;            /* :dl=: delete a line */
        !            82: #if OSK
        !            83: extern char    *SR_;           /* :sr=: scroll reverse */
        !            84: #else
        !            85: extern char    *SR;            /* :sr=: scroll reverse */
        !            86: #endif
        !            87: extern char    *KS;            /* :ks=: init string for cursor */
        !            88: extern char    *KE;            /* :ke=: restore string for cursor */
        !            89: extern char    *KU;            /* :ku=: sequence sent by up key */
        !            90: extern char    *KD;            /* :kd=: sequence sent by down key */
        !            91: extern char    *KL;            /* :kl=: sequence sent by left key */
        !            92: extern char    *KR;            /* :kr=: sequence sent by right key */
        !            93: extern char    *PU;            /* :PU=: key sequence sent by PgUp key */
        !            94: extern char    *PD;            /* :PD=: key sequence sent by PgDn key */
        !            95: extern char    *HM;            /* :HM=: key sequence sent by Home key */
        !            96: extern char    *EN;            /* :EN=: key sequence sent by End key */
        !            97: extern char    *IM;            /* :im=: insert mode start */
        !            98: extern char    *IC;            /* :ic=: insert following char */
        !            99: extern char    *EI;            /* :ei=: insert mode end */
        !           100: extern char    *DC;            /* :dc=: delete a character */
        !           101: extern char    *TI;            /* :ti=: terminal init */       /* GB */
        !           102: extern char    *TE;            /* :te=: terminal exit */       /* GB */
        !           103: #ifndef NO_CURSORSHAPE
        !           104: extern char    *CQ;            /* :cQ=: normal cursor */
        !           105: extern char    *CX;            /* :cX=: cursor used for EX command/entry */
        !           106: extern char    *CV;            /* :cV=: cursor used for VI command mode */
        !           107: extern char    *CI;            /* :cI=: cursor used for VI input mode */
        !           108: extern char    *CR;            /* :cR=: cursor used for VI replace mode */
        !           109: #endif
        !           110: extern char    *aend;          /* end an attribute -- either UE or ME */
        !           111: extern char    ERASEKEY;       /* taken from the ioctl structure */
        !           112: 
        !           113: /* Msdos-versions may use bios; others always termcap.
        !           114:  * Will emit some 'code has no effect' warnings in unix.
        !           115:  */
        !           116:  
        !           117: #if MSDOS
        !           118: extern char o_pcbios[1];               /* BAH! */
        !           119: #define        CHECKBIOS(x,y)  (*o_pcbios ? (x) : (y))
        !           120: #define VOIDBIOS(x,y)  {if (*o_pcbios) {x;} else {y;}}
        !           121: #else
        !           122: #define        CHECKBIOS(x,y)  (y)
        !           123: #define VOIDBIOS(x,y)  {y;}
        !           124: #endif
        !           125: 
        !           126: #define        do_VB()         VOIDBIOS(;, tputs(VB, 1, faddch))
        !           127: #define        do_UP()         VOIDBIOS(v_up(), tputs(UP, 1, faddch))
        !           128: #define        do_SO()         VOIDBIOS((vmode=A_STANDOUT), tputs(SO, 1, faddch))
        !           129: #define        do_SE()         VOIDBIOS((vmode=A_NORMAL), tputs(SE, 1, faddch))
        !           130: #define        do_US()         VOIDBIOS((vmode=A_UNDERLINE), tputs(US, 1, faddch))
        !           131: #define        do_UE()         VOIDBIOS((vmode=A_NORMAL), tputs(UE, 1, faddch))
        !           132: #define        do_MD()         VOIDBIOS((vmode=A_BOLD), tputs(MD, 1, faddch))
        !           133: #define        do_ME()         VOIDBIOS((vmode=A_NORMAL), tputs(ME, 1, faddch))
        !           134: #define        do_AS()         VOIDBIOS((vmode=A_ALTCHARSET), tputs(AS, 1, faddch))
        !           135: #define        do_AE()         VOIDBIOS((vmode=A_NORMAL), tputs(AE, 1, faddch))
        !           136: #undef do_CM           /* move */
        !           137: #define        do_CE()         VOIDBIOS(v_ce(), tputs(CE, 1, faddch))
        !           138: #define        do_CD()         VOIDBIOS(v_cd(), tputs(CD, 1, faddch))
        !           139: #define        do_AL()         VOIDBIOS(v_al(), tputs(AL, LINES, faddch))
        !           140: #define        do_DL()         VOIDBIOS(v_dl(), tputs(DL, LINES, faddch))
        !           141: #if OSK
        !           142: #define        do_SR()         VOIDBIOS(v_sr(), tputs(SR_, 1, faddch))
        !           143: #else
        !           144: #define        do_SR()         VOIDBIOS(v_sr(), tputs(SR, 1, faddch))
        !           145: #endif
        !           146: #define do_KS()                VOIDBIOS(1, tputs(KS, 1, faddch))
        !           147: #define do_KE()                VOIDBIOS(1, tputs(KE, 1, faddch))
        !           148: #define        do_IM()         VOIDBIOS(;, tputs(IM, 1, faddch))
        !           149: #define        do_IC()         VOIDBIOS(;, tputs(IC, 1, faddch))
        !           150: #define        do_EI()         VOIDBIOS(;, tputs(EI, 1, faddch))
        !           151: #define        do_DC()         VOIDBIOS(;, tputs(DC, COLS, faddch))
        !           152: #define        do_TI()         VOIDBIOS(;, (void)ttywrite(TI, (unsigned)strlen(TI)))
        !           153: #define        do_TE()         VOIDBIOS(;, (void)ttywrite(TE, (unsigned)strlen(TE)))
        !           154: #ifndef NO_CURSORSHAPE
        !           155: # define do_CQ()       VOIDBIOS(v_cs(), tputs(CQ, 1, faddch))
        !           156: # define do_CX()       VOIDBIOS(v_cs(), tputs(CX, 1, faddch))
        !           157: # define do_CV()       VOIDBIOS(v_cs(), tputs(CV, 1, faddch))
        !           158: # define do_CI()       VOIDBIOS(v_cb(), tputs(CI, 1, faddch))
        !           159: # define do_CR()       VOIDBIOS(v_cb(), tputs(CR, 1, faddch))
        !           160: #endif
        !           161: #define        do_aend()       VOIDBIOS((vmode=A_NORMAL), tputs(aend, 1, faddch))
        !           162: 
        !           163: #define        has_AM          CHECKBIOS(1, AM)
        !           164: #define        has_PT          CHECKBIOS(0, PT)
        !           165: #define        has_VB          CHECKBIOS((char *)0, VB)
        !           166: #define        has_UP          CHECKBIOS((char *)1, UP)
        !           167: #define        has_SO          CHECKBIOS((char)1, (*SO))
        !           168: #define        has_SE          CHECKBIOS((char)1, (*SE))
        !           169: #define        has_US          CHECKBIOS((char)1, (*US))
        !           170: #define        has_UE          CHECKBIOS((char)1, (*UE))
        !           171: #define        has_MD          CHECKBIOS((char)1, (*MD))
        !           172: #define        has_ME          CHECKBIOS((char)1, (*ME))
        !           173: #define        has_AS          CHECKBIOS((char)1, (*AS))
        !           174: #define        has_AE          CHECKBIOS((char)1, (*AE))
        !           175: #undef has_CM          /* cursor move: don't need */
        !           176: #define        has_CB          CHECKBIOS(1, 0)
        !           177: #define        has_CS          CHECKBIOS(1, 0)
        !           178: #define        has_CE          CHECKBIOS((char *)1, CE)
        !           179: #define        has_CD          CHECKBIOS((char *)1, CD)
        !           180: #define        has_AL          CHECKBIOS((char *)1, AL)
        !           181: #define        has_DL          CHECKBIOS((char *)1, DL)
        !           182: #if OSK
        !           183: #define        has_SR          CHECKBIOS((char *)1, SR_)
        !           184: #else
        !           185: #define        has_SR          CHECKBIOS((char *)1, SR)
        !           186: #endif
        !           187: #define has_KS         CHECKBIOS((char)1, (*KS))
        !           188: #define has_KE         CHECKBIOS((char)1, (*KE))
        !           189: #define        has_KU          CHECKBIOS("#H", KU)
        !           190: #define        has_KD          CHECKBIOS("#P", KD)
        !           191: #define        has_KL          CHECKBIOS("#K", KL)
        !           192: #define        has_KR          CHECKBIOS("#M", KR)
        !           193: #define has_HM         CHECKBIOS("#G", HM)
        !           194: #define has_EN         CHECKBIOS("#O", EN)
        !           195: #define has_PU         CHECKBIOS("#I", PU)
        !           196: #define has_PD         CHECKBIOS("#Q", PD)
        !           197: #define        has_IM          CHECKBIOS((char)0, (*IM))
        !           198: #define        has_IC          CHECKBIOS((char)0, (*IC))
        !           199: #define        has_EI          CHECKBIOS((char)0, (*EI))
        !           200: #define        has_DC          CHECKBIOS((char *)0, DC)
        !           201: #define        has_TI          CHECKBIOS((char)0, (*TI))
        !           202: #define        has_TE          CHECKBIOS((char)0, (*TE))
        !           203: #ifndef NO_CURSORSHAPE
        !           204: #define has_CQ         CHECKBIOS((char *)1, CQ)
        !           205: #endif
        !           206: 
        !           207: /* (pseudo)-Curses-functions */
        !           208: 
        !           209: #ifdef lint
        !           210: # define _addCR                VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : (stdscr[-1] = '\n')))
        !           211: #else
        !           212: # if OSK
        !           213: #  define _addCR               VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\l') : (stdscr[-1] = stdscr[-1])))
        !           214: # else
        !           215: # define _addCR                VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : 0))
        !           216: #endif
        !           217: #endif
        !           218: #define qaddch(ch)     CHECKBIOS(v_put(ch), (*stdscr++ = (ch)))
        !           219: #if OSK
        !           220: #define addch(ch)      if (qaddch(ch) == '\n') qaddch('\l'); else
        !           221: #else
        !           222: #define addch(ch)      if (qaddch(ch) == '\n') qaddch('\r'); else
        !           223: #endif
        !           224: 
        !           225: extern void initscr();
        !           226: extern void endwin();
        !           227: extern void suspend_curses();
        !           228: extern void resume_curses();
        !           229: extern void attrset();
        !           230: extern void insch();
        !           231: extern void qaddstr();
        !           232: #define addstr(str)    {qaddstr(str); _addCR;}
        !           233: #define move(y,x)      VOIDBIOS(v_move(x,y), \
        !           234:                                        tputs(tgoto(CM, x, y), 1, faddch))
        !           235: #define mvaddch(y,x,ch)        {move(y,x); addch(ch);}
        !           236: #define refresh()      VOIDBIOS(;, wrefresh(stdscr))
        !           237: #define wrefresh(w)    if ((w) != kbuf) VOIDBIOS((w) = kbuf, {ttywrite(kbuf, (unsigned)((w) - kbuf)); (w) = kbuf;}) else
        !           238: #define wqrefresh(w)   if ((w) - kbuf > 2000) VOIDBIOS((w) = kbuf, {ttywrite(kbuf, (unsigned)((w) - kbuf)); (w) = kbuf;}) else
        !           239: #define standout()     do_SO()
        !           240: #define standend()     do_SE()
        !           241: #define clrtoeol()     do_CE()
        !           242: #define clrtobot()     do_CD()
        !           243: #define insertln()     do_AL()
        !           244: #define deleteln()     do_DL()
        !           245: #define delch()                do_DC()
        !           246: #define scrollok(w,b)
        !           247: #define raw()
        !           248: #define echo()
        !           249: #define cbreak()
        !           250: #define noraw()
        !           251: #define noecho()
        !           252: #define nocbreak()

unix.superglobalmegacorp.com

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