|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1981 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that the above copyright notice and this paragraph are ! 7: * duplicated in all such forms and that any documentation, ! 8: * advertising materials, and other materials related to such ! 9: * distribution and use acknowledge that the software was developed ! 10: * by the University of California, Berkeley. The name of the ! 11: * University may not be used to endorse or promote products derived ! 12: * from this software without specific prior written permission. ! 13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 16: * ! 17: * @(#)curses.h 5.4 (Berkeley) 6/30/88 ! 18: */ ! 19: ! 20: # ifndef WINDOW ! 21: ! 22: # include <stdio.h> ! 23: # include <sgtty.h> ! 24: # include <unctrl.h> ! 25: ! 26: # define bool char ! 27: # define reg register ! 28: ! 29: # define TRUE (1) ! 30: # define FALSE (0) ! 31: # define ERR (0) ! 32: # define OK (1) ! 33: ! 34: # define _ENDLINE 001 ! 35: # define _FULLWIN 002 ! 36: # define _SCROLLWIN 004 ! 37: # define _FLUSH 010 ! 38: # define _FULLLINE 020 ! 39: # define _IDLINE 040 ! 40: # define _STANDOUT 0200 ! 41: # define _NOCHANGE -1 ! 42: ! 43: /* ! 44: * The COHERENT Tputs(s,n,f) macro attempts to ensure string output will be ! 45: * atomic by flushing the stdio output buffer in _need(s) if required. This ! 46: * should prevent the splitting of escape sequences by other terminal output, ! 47: * provided that the terminal drive guarantees atomicity of writes. ! 48: */ ! 49: #ifdef COHERENT ! 50: # define Tputs(s,n,f) (_need(s), tputs(s, n, f)) ! 51: #else ! 52: # define Tputs(s,n,f) tputs(s, n, f) ! 53: #endif ! 54: ! 55: # define _puts(s) Tputs(s, 0, _putchar) ! 56: ! 57: typedef struct sgttyb SGTTY; ! 58: typedef short chtype; /* Character + Attributes */ ! 59: ! 60: /* ! 61: * Capabilities from termcap. ! 62: */ ! 63: #define CS change_scroll_region ! 64: #define VE cursor_normal ! 65: #define VS cursor_visible ! 66: #define SO enter_standout_mode ! 67: #define US enter_underline_mode ! 68: #define VB flash_screen ! 69: #define K0 key_f0 ! 70: #define K1 key_f1 ! 71: #define K2 key_f2 ! 72: #define K3 key_f3 ! 73: #define K4 key_f4 ! 74: #define K5 key_f5 ! 75: #define K6 key_f6 ! 76: #define K7 key_f7 ! 77: #define K8 key_f8 ! 78: #define K9 key_f9 ! 79: #define KD key_down ! 80: #define KH key_home ! 81: #define KL key_left ! 82: #define KR key_right ! 83: #define KU key_up ! 84: ! 85: extern bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, ! 86: XB, XN, XT, XS, XX; ! 87: ! 88: extern char *AL, ! 89: *BC, *BT, ! 90: *CD, *CE, *CL, *CM, *CR, *CS, ! 91: *DC, *DL, *DM, *DO, ! 92: *ED, *EI, ! 93: *HO, ! 94: *IC, *IM, *IP, ! 95: *KE, *KS, ! 96: *LL, ! 97: *MA, ! 98: *ND, *NL, ! 99: *RC, ! 100: *SC, *SE, *SF, *SR, ! 101: *TA, *TE, *TI, ! 102: *UC, *UE, *UP, ! 103: *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, ! 104: *LEFT_PARM, *RIGHT_PARM; ! 105: extern char PC; ! 106: ! 107: /* ! 108: * System V Capabilities. ! 109: */ ! 110: extern bool prtr_silent, xon_xoff; ! 111: ! 112: extern char *bell, ! 113: *cursor_invisible, *cursor_normal, *cursor_visible, ! 114: *enter_am_mode, *enter_blink_mode, *enter_bold_mode, ! 115: *enter_delete_mode, *enter_dim_mode, *enter_protected_mode, ! 116: *enter_reverse_mode, *enter_secure_mode, ! 117: *enter_standout_mode, *enter_underline_mode, ! 118: *exit_am_mode, *exit_attribute_mode, ! 119: *flash_screen, ! 120: *init_1string, *init_2string, *init_3string, ! 121: *key_a1, *key_a3, ! 122: *key_b2, *key_backspace, *key_beg, *key_btab, ! 123: *key_c1, *key_c3, *key_cancel, *key_catab, *key_clear, ! 124: *key_close, *key_command, *key_copy, *key_create, *key_ctab, ! 125: *key_dc, *key_dl, *key_down, ! 126: *key_eic, *key_end, *key_enter, *key_eol, *key_eos, *key_exit, ! 127: *key_f0, *key_f1, *key_f2, *key_f3, *key_f4, ! 128: *key_f5, *key_f6, *key_f7, *key_f8, *key_f9, ! 129: *key_f10, *key_f11, *key_f12, *key_f13, *key_f14, ! 130: *key_f15, *key_f16, *key_f17, *key_f18, *key_f19, ! 131: *key_f20, *key_f21, *key_f22, *key_f23, *key_f24, ! 132: *key_f25, *key_f26, *key_f27, *key_f28, *key_f29, ! 133: *key_f30, *key_f31, *key_f32, *key_f33, *key_f34, ! 134: *key_f35, *key_f36, *key_f37, *key_f38, *key_f39, ! 135: *key_f40, *key_f41, *key_f42, *key_f43, *key_f44, ! 136: *key_f45, *key_f46, *key_f47, *key_f48, *key_f49, ! 137: *key_f50, *key_f51, *key_f52, *key_f53, *key_f54, ! 138: *key_f55, *key_f56, *key_f57, *key_f58, *key_f59, ! 139: *key_f60, *key_f61, *key_f62, *key_f63, ! 140: *key_find, ! 141: *key_help, *key_home, ! 142: *key_ic, *key_il, ! 143: *key_left, *key_ll, ! 144: *key_mark, *key_message, *key_move, ! 145: *key_next, *key_npage, ! 146: *key_open, *key_options, ! 147: *key_ppage, *key_previous, *key_print, ! 148: *key_redo, *key_reference, *key_refresh, *key_replace, ! 149: *key_restart, *key_resume, *key_right, ! 150: *key_save, *key_sbeg, *key_scancel, *key_scommand, *key_scopy, ! 151: *key_screate, *key_sdc, *key_sdl, *key_select, *key_send, ! 152: *key_seol, *key_sexit, *key_sf, *key_sfind, *key_shelp, ! 153: *key_shome, *key_sic, *key_sleft, *key_smessage, *key_smove, ! 154: *key_snext, *key_soptions, *key_sprevious, *key_sprint, ! 155: *key_sr, *key_sredo, *key_sreplace, *key_sright, *key_srsume, ! 156: *key_ssave, *key_ssuspend, *key_stab, *key_sundo, *key_suspend, ! 157: *key_undo, *key_up, ! 158: *prtr_off, *prtr_on, ! 159: *reset_1string, *reset_2string, *reset_3string, ! 160: *xoff_character, *xon_character; ! 161: ! 162: /* ! 163: * From the tty modes... ! 164: */ ! 165: extern bool GT, NONL, UPPERCASE, normtty, _pfast; ! 166: ! 167: struct _win_st { ! 168: short _cury, _curx; ! 169: short _maxy, _maxx; ! 170: short _begy, _begx; ! 171: short _flags; ! 172: short _attrs; ! 173: short _ch_off; ! 174: bool _clear; ! 175: bool _leave; ! 176: bool _scroll; ! 177: bool _use_keypad; /* 0=no, 1=yes, 2=yes/timeout */ ! 178: bool _nodelay; /* T=don't wait for tty input */ ! 179: char **_y; ! 180: short *_firstch; ! 181: short *_lastch; ! 182: struct _win_st *_nextp, *_orig; ! 183: }; ! 184: ! 185: # define WINDOW struct _win_st ! 186: ! 187: /* ! 188: * Translation table entry: Termcap field name into address of a boolean var. ! 189: */ ! 190: typedef struct tflgent_s { ! 191: char id[2]; /* termcap code */ ! 192: bool *bp; /* pointer to boolean var */ ! 193: } tflgent_t; ! 194: ! 195: /* ! 196: * Translation table entry: keyboard token into address of a string variable. ! 197: */ ! 198: typedef struct tkeyent_s { ! 199: short id; /* key code */ ! 200: char **cpp; /* pointer to var which in turn points to string */ ! 201: } tkeyent_t; ! 202: ! 203: /* ! 204: * Translation table entry: Termcap field name into address of a string var. ! 205: */ ! 206: typedef struct tstrent_s { ! 207: char id[2]; /* termcap code */ ! 208: char **cpp; /* pointer to var which in turn points to string */ ! 209: } tstrent_t; ! 210: ! 211: /* ! 212: * Types for System V compatibility. ! 213: */ ! 214: #define SCREEN char ! 215: ! 216: /* ! 217: * Default Translation Tables. ! 218: * End of table is signified by an id byte of 0. ! 219: */ ! 220: extern tflgent_t tflgtab[]; /* Default boolean translation table */ ! 221: extern tkeyent_t tkeytab[]; /* Default keyboard translation table */ ! 222: extern tstrent_t tstrtab[]; /* Default string translation table */ ! 223: extern tflgent_t * tflgmap; /* Current boolean translation table */ ! 224: extern tkeyent_t * tkeymap; /* Current keyboard translation table */ ! 225: extern tstrent_t * tstrmap; /* Current string translation table */ ! 226: ! 227: extern bool My_term, _echoit, _rawmode, _endwin; ! 228: ! 229: extern char *Def_term, ttytype[]; ! 230: ! 231: extern int LINES, COLS, _tty_ch, _res_flg; ! 232: extern int magic_cookie_glitch; ! 233: ! 234: extern SGTTY _tty; ! 235: ! 236: extern WINDOW *stdscr, *curscr; ! 237: ! 238: /* ! 239: * Define VOID to stop lint from generating "null effect" ! 240: * comments. ! 241: */ ! 242: # ifdef lint ! 243: int __void__; ! 244: # define VOID(x) (__void__ = (int) (x)) ! 245: # else ! 246: # define VOID(x) (x) ! 247: # endif ! 248: ! 249: /* ! 250: * psuedo functions for standard screen ! 251: */ ! 252: # define addch(ch) VOID(waddch(stdscr, ch)) ! 253: # define getch() VOID(wgetch(stdscr)) ! 254: # define addbytes(da,co) VOID(waddbytes(stdscr, da,co)) ! 255: # define addstr(str) VOID(waddbytes(stdscr, str, strlen(str))) ! 256: # define getstr(str) VOID(wgetstr(stdscr, str)) ! 257: # define move(y, x) VOID(wmove(stdscr, y, x)) ! 258: # define clear() VOID(wclear(stdscr)) ! 259: # define erase() VOID(werase(stdscr)) ! 260: # define clrtobot() VOID(wclrtobot(stdscr)) ! 261: # define clrtoeol() VOID(wclrtoeol(stdscr)) ! 262: # define insertln() VOID(winsertln(stdscr)) ! 263: # define deleteln() VOID(wdeleteln(stdscr)) ! 264: # define refresh() VOID(wrefresh(stdscr)) ! 265: # define inch() VOID(winch(stdscr)) ! 266: # define insch(c) VOID(winsch(stdscr,c)) ! 267: # define delch() VOID(wdelch(stdscr)) ! 268: # define standout() VOID(wstandout(stdscr)) ! 269: # define standend() VOID(wstandend(stdscr)) ! 270: # define attron(at) wattron(stdscr,at) ! 271: # define attroff(at) wattroff(stdscr,at) ! 272: # define attrset(at) wattrset(stdscr,at) ! 273: ! 274: /* ! 275: * mv functions ! 276: */ ! 277: #define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch)) ! 278: #define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win)) ! 279: #define mvwaddbytes(win,y,x,da,co) \ ! 280: VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,da,co)) ! 281: #define mvwaddstr(win,y,x,str) \ ! 282: VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,str,strlen(str))) ! 283: #define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str)) ! 284: #define mvwinch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : winch(win)) ! 285: #define mvwdelch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win)) ! 286: #define mvwinsch(win,y,x,c) VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c)) ! 287: #define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch) ! 288: #define mvgetch(y,x) mvwgetch(stdscr,y,x) ! 289: #define mvaddbytes(y,x,da,co) mvwaddbytes(stdscr,y,x,da,co) ! 290: #define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str) ! 291: #define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str) ! 292: #define mvinch(y,x) mvwinch(stdscr,y,x) ! 293: #define mvdelch(y,x) mvwdelch(stdscr,y,x) ! 294: #define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c) ! 295: ! 296: /* ! 297: * pseudo functions ! 298: */ ! 299: #define clearok(win,bf) (win->_clear = bf) ! 300: #define keypad(win,bf) (win->_use_keypad = bf) ! 301: #define leaveok(win,bf) (win->_leave = bf) ! 302: #define nodelay(win,bf) (win->_nodelay = bf) ! 303: #define scrollok(win,bf) (win->_scroll = bf) ! 304: #define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)) ! 305: #define getyx(win,y,x) y = win->_cury, x = win->_curx ! 306: #define winch(win) (win->_y[win->_cury][win->_curx] & 0177) ! 307: ! 308: #define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, stty(_tty_ch,&_tty)) ! 309: #define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty)) ! 310: #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, stty(_tty_ch,&_tty)) ! 311: #define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,stty(_tty_ch,&_tty)) ! 312: #define crmode() cbreak() /* backwards compatability */ ! 313: #define nocrmode() nocbreak() /* backwards compatability */ ! 314: #define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, stty(_tty_ch, &_tty)) ! 315: #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, stty(_tty_ch, &_tty)) ! 316: #define nl() (_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty)) ! 317: #define nonl() (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty)) ! 318: #define savetty() ((void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags) ! 319: #define resetty() (_tty.sg_flags = _res_flg, (void) stty(_tty_ch, &_tty)) ! 320: ! 321: #define erasechar() (_tty.sg_erase) ! 322: #define killchar() (_tty.sg_kill) ! 323: #define baudrate() (_tty.sg_ospeed) ! 324: ! 325: WINDOW *initscr(), *newwin(), *subwin(); ! 326: char *longname(), *getcap(); ! 327: ! 328: /* ! 329: * Various video attributes - A_STANDOUT is only sure bet. ! 330: */ ! 331: #define A_STANDOUT 0000200 ! 332: #define A_UNDERLINE 0000400 ! 333: #define A_REVERSE 0001000 ! 334: #define A_BLINK 0002000 ! 335: #define A_DIM 0004000 ! 336: #define A_BOLD 0010000 ! 337: ! 338: #define A_NORMAL 0000000 ! 339: #define A_ATTRIBUTES 0177600 /* Mask to extract video attributes */ ! 340: #define A_CHARTEXT 0000177 /* Mask to extract character value */ ! 341: ! 342: /* ! 343: * Funny "characters" enabled for various special function keys for input ! 344: */ ! 345: #define KEY_BREAK 0401 /* break key (unreliable) */ ! 346: #define KEY_DOWN 0402 /* The four arrow keys ... */ ! 347: #define KEY_UP 0403 ! 348: #define KEY_LEFT 0404 ! 349: #define KEY_RIGHT 0405 /* ... */ ! 350: #define KEY_HOME 0406 /* Home key (upward+left arrow) */ ! 351: #define KEY_BACKSPACE 0407 /* backspace (unreliable) */ ! 352: #define KEY_F0 0410 /* Function keys. Space for 64 */ ! 353: #define KEY_F(n) (KEY_F0+(n)) /* keys is reserved. */ ! 354: #define KEY_DL 0510 /* Delete line */ ! 355: #define KEY_IL 0511 /* Insert line */ ! 356: #define KEY_DC 0512 /* Delete character */ ! 357: #define KEY_IC 0513 /* Insert char or enter insert mode */ ! 358: #define KEY_EIC 0514 /* Exit insert char mode */ ! 359: #define KEY_CLEAR 0515 /* Clear screen */ ! 360: #define KEY_EOS 0516 /* Clear to end of screen */ ! 361: #define KEY_EOL 0517 /* Clear to end of line */ ! 362: #define KEY_SF 0520 /* Scroll 1 line forward */ ! 363: #define KEY_SR 0521 /* Scroll 1 line backwards (reverse) */ ! 364: #define KEY_NPAGE 0522 /* Next page */ ! 365: #define KEY_PPAGE 0523 /* Previous page */ ! 366: #define KEY_STAB 0524 /* Set tab */ ! 367: #define KEY_CTAB 0525 /* Clear tab */ ! 368: #define KEY_CATAB 0526 /* Clear all tabs */ ! 369: #define KEY_ENTER 0527 /* Enter or send (unreliable) */ ! 370: #define KEY_SRESET 0530 /* soft (partial) reset (unreliable) */ ! 371: #define KEY_RESET 0531 /* reset or hard reset (unreliable) */ ! 372: #define KEY_PRINT 0532 /* print or copy */ ! 373: #define KEY_LL 0533 /* home down or bottom (lower left) */ ! 374: /* The keypad is arranged like this: */ ! 375: /* a1 up a3 */ ! 376: /* left b2 right */ ! 377: /* c1 down c3 */ ! 378: #define KEY_A1 0534 /* upper left of keypad */ ! 379: #define KEY_A3 0535 /* upper right of keypad */ ! 380: #define KEY_B2 0536 /* center of keypad */ ! 381: #define KEY_C1 0537 /* lower left of keypad */ ! 382: #define KEY_C3 0540 /* lower right of keypad */ ! 383: #define KEY_BTAB 0541 /* back tab key */ ! 384: #define KEY_BEG 0542 /* beg(inning) key */ ! 385: #define KEY_CANCEL 0543 /* cancel key */ ! 386: #define KEY_CLOSE 0544 /* close key */ ! 387: #define KEY_COMMAND 0545 /* cmd (command) key */ ! 388: #define KEY_COPY 0546 /* copy key */ ! 389: #define KEY_CREATE 0547 /* create key */ ! 390: #define KEY_END 0550 /* end key */ ! 391: #define KEY_EXIT 0551 /* exit key */ ! 392: #define KEY_FIND 0552 /* find key */ ! 393: #define KEY_HELP 0553 /* help key */ ! 394: #define KEY_MARK 0554 /* mark key */ ! 395: #define KEY_MESSAGE 0555 /* message key */ ! 396: #define KEY_MOVE 0556 /* move key */ ! 397: #define KEY_NEXT 0557 /* next object key */ ! 398: #define KEY_OPEN 0560 /* open key */ ! 399: #define KEY_OPTIONS 0561 /* options key */ ! 400: #define KEY_PREVIOUS 0562 /* previous object key */ ! 401: #define KEY_REDO 0563 /* redo key */ ! 402: #define KEY_REFERENCE 0564 /* ref(erence) key */ ! 403: #define KEY_REFRESH 0565 /* refresh key */ ! 404: #define KEY_REPLACE 0566 /* replace key */ ! 405: #define KEY_RESTART 0567 /* restart key */ ! 406: #define KEY_RESUME 0570 /* resume key */ ! 407: #define KEY_SAVE 0571 /* save key */ ! 408: #define KEY_SBEG 0572 /* shifted beginning key */ ! 409: #define KEY_SCANCEL 0573 /* shifted cancel key */ ! 410: #define KEY_SCOMMAND 0574 /* shifted command key */ ! 411: #define KEY_SCOPY 0575 /* shifted copy key */ ! 412: #define KEY_SCREATE 0576 /* shifted create key */ ! 413: #define KEY_SDC 0577 /* shifted delete char key */ ! 414: #define KEY_SDL 0600 /* shifted delete line key */ ! 415: #define KEY_SELECT 0601 /* select key */ ! 416: #define KEY_SEND 0602 /* shifted end key */ ! 417: #define KEY_SEOL 0603 /* shifted clear line key */ ! 418: #define KEY_SEXIT 0604 /* shifted exit key */ ! 419: #define KEY_SFIND 0605 /* shifted find key */ ! 420: #define KEY_SHELP 0606 /* shifted help key */ ! 421: #define KEY_SHOME 0607 /* shifted home key */ ! 422: #define KEY_SIC 0610 /* shifted input key */ ! 423: #define KEY_SLEFT 0611 /* shifted left arrow key */ ! 424: #define KEY_SMESSAGE 0612 /* shifted message key */ ! 425: #define KEY_SMOVE 0613 /* shifted move key */ ! 426: #define KEY_SNEXT 0614 /* shifted next key */ ! 427: #define KEY_SOPTIONS 0615 /* shifted options key */ ! 428: #define KEY_SPREVIOUS 0616 /* shifted prev key */ ! 429: #define KEY_SPRINT 0617 /* shifted print key */ ! 430: #define KEY_SREDO 0620 /* shifted redo key */ ! 431: #define KEY_SREPLACE 0621 /* shifted replace key */ ! 432: #define KEY_SRIGHT 0622 /* shifted right-arrow key */ ! 433: #define KEY_SRSUME 0623 /* shifted resume key */ ! 434: #define KEY_SSAVE 0624 /* shifted save key */ ! 435: #define KEY_SSUSPEND 0625 /* shifted suspend key */ ! 436: #define KEY_SUNDO 0626 /* shifted undo key */ ! 437: #define KEY_SUSPEND 0627 /* suspend key */ ! 438: #define KEY_UNDO 0630 /* undo key */ ! 439: ! 440: # endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.