|
|
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 provided
6: * that: (1) source distributions retain this entire copyright notice and
7: * comment, and (2) distributions including binaries display the following
8: * acknowledgement: ``This product includes software developed by the
9: * University of California, Berkeley and its contributors'' in the
10: * documentation or other materials provided with the distribution and in
11: * all advertising materials mentioning features or use of this software.
12: * Neither the name of the University nor the names of its contributors may
13: * be used to endorse or promote products derived from this software without
14: * specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
16: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: *
19: * @(#)curses.h 5.9 (Berkeley) 7/1/90
20: */
21:
22: #ifndef WINDOW
23:
24: #include <stdio.h>
25:
26: #define USE_OLD_TTY
27: #include <sys/ioctl.h>
28: #undef USE_OLD_TTY
29:
30: #define bool char
31: #define reg register
32:
33: #define TRUE (1)
34: #define FALSE (0)
35: #define ERR (0)
36: #define OK (1)
37:
38: #define _ENDLINE 001
39: #define _FULLWIN 002
40: #define _SCROLLWIN 004
41: #define _FLUSH 010
42: #define _FULLLINE 020
43: #define _IDLINE 040
44: #define _STANDOUT 0200
45: #define _NOCHANGE -1
46:
47: #define _puts(s) tputs(s, 0, _putchar)
48:
49: typedef struct sgttyb SGTTY;
50:
51: /*
52: * Capabilities from termcap
53: */
54:
55: extern bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
56: XB, XN, XT, XS, XX;
57: extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
58: *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
59: *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
60: *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
61: *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
62: *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
63: *LEFT_PARM, *RIGHT_PARM;
64: extern char PC;
65:
66: /*
67: * From the tty modes...
68: */
69:
70: extern bool GT, NONL, UPPERCASE, normtty, _pfast;
71:
72: struct _win_st {
73: short _cury, _curx;
74: short _maxy, _maxx;
75: short _begy, _begx;
76: short _flags;
77: short _ch_off;
78: bool _clear;
79: bool _leave;
80: bool _scroll;
81: char **_y;
82: short *_firstch;
83: short *_lastch;
84: struct _win_st *_nextp, *_orig;
85: };
86:
87: #define WINDOW struct _win_st
88:
89: extern bool My_term, _echoit, _rawmode, _endwin;
90:
91: extern char *Def_term, ttytype[];
92:
93: extern int LINES, COLS, _tty_ch, _res_flg;
94:
95: extern SGTTY _tty;
96:
97: extern WINDOW *stdscr, *curscr;
98:
99: /*
100: * Define VOID to stop lint from generating "null effect"
101: * comments.
102: */
103: #ifdef lint
104: int __void__;
105: #define VOID(x) (__void__ = (int) (x))
106: #else
107: #define VOID(x) (x)
108: #endif
109:
110: /*
111: * psuedo functions for standard screen
112: */
113: #define addch(ch) VOID(waddch(stdscr, ch))
114: #define getch() VOID(wgetch(stdscr))
115: #define addbytes(da,co) VOID(waddbytes(stdscr, da,co))
116: #define addstr(str) VOID(waddbytes(stdscr, str, strlen(str)))
117: #define getstr(str) VOID(wgetstr(stdscr, str))
118: #define move(y, x) VOID(wmove(stdscr, y, x))
119: #define clear() VOID(wclear(stdscr))
120: #define erase() VOID(werase(stdscr))
121: #define clrtobot() VOID(wclrtobot(stdscr))
122: #define clrtoeol() VOID(wclrtoeol(stdscr))
123: #define insertln() VOID(winsertln(stdscr))
124: #define deleteln() VOID(wdeleteln(stdscr))
125: #define refresh() VOID(wrefresh(stdscr))
126: #define inch() VOID(winch(stdscr))
127: #define insch(c) VOID(winsch(stdscr,c))
128: #define delch() VOID(wdelch(stdscr))
129: #define standout() VOID(wstandout(stdscr))
130: #define standend() VOID(wstandend(stdscr))
131:
132: /*
133: * mv functions
134: */
135: #define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
136: #define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
137: #define mvwaddbytes(win,y,x,da,co) \
138: VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,da,co))
139: #define mvwaddstr(win,y,x,str) \
140: VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,str,strlen(str)))
141: #define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
142: #define mvwinch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
143: #define mvwdelch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
144: #define mvwinsch(win,y,x,c) VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c))
145: #define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
146: #define mvgetch(y,x) mvwgetch(stdscr,y,x)
147: #define mvaddbytes(y,x,da,co) mvwaddbytes(stdscr,y,x,da,co)
148: #define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
149: #define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
150: #define mvinch(y,x) mvwinch(stdscr,y,x)
151: #define mvdelch(y,x) mvwdelch(stdscr,y,x)
152: #define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
153:
154: /*
155: * psuedo functions
156: */
157:
158: #define clearok(win,bf) (win->_clear = bf)
159: #define leaveok(win,bf) (win->_leave = bf)
160: #define scrollok(win,bf) (win->_scroll = bf)
161: #define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
162: #define getyx(win,y,x) y = win->_cury, x = win->_curx
163: #define winch(win) (win->_y[win->_cury][win->_curx] & 0177)
164:
165: #define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, \
166: ioctl(_tty_ch, TIOCSETP, &_tty))
167: #define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,\
168: _pfast=!(_tty.sg_flags&CRMOD),ioctl(_tty_ch, TIOCSETP, &_tty))
169: #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, \
170: ioctl(_tty_ch, TIOCSETP, &_tty))
171: #define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE, \
172: ioctl(_tty_ch, TIOCSETP, &_tty))
173: #define crmode() cbreak() /* backwards compatability */
174: #define nocrmode() nocbreak() /* backwards compatability */
175: #define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, \
176: ioctl(_tty_ch, TIOCSETP, &_tty))
177: #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, \
178: ioctl(_tty_ch, TIOCSETP, &_tty))
179: #define nl() (_tty.sg_flags |= CRMOD,_pfast = _rawmode, \
180: ioctl(_tty_ch, TIOCSETP, &_tty))
181: #define nonl() (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, \
182: ioctl(_tty_ch, TIOCSETP, &_tty))
183: #define savetty() ((void) ioctl(_tty_ch, TIOCGETP, &_tty), \
184: _res_flg = _tty.sg_flags)
185: #define resetty() (_tty.sg_flags = _res_flg, \
186: _echoit = ((_res_flg & ECHO) == ECHO), \
187: _rawmode = ((_res_flg & (CBREAK|RAW)) != 0), \
188: _pfast = ((_res_flg & CRMOD) ? _rawmode : TRUE), \
189: (void) ioctl(_tty_ch, TIOCSETP, &_tty))
190:
191: #define erasechar() (_tty.sg_erase)
192: #define killchar() (_tty.sg_kill)
193: #define baudrate() (_tty.sg_ospeed)
194:
195: WINDOW *initscr(), *newwin(), *subwin();
196: char *longname(), *getcap();
197:
198: /*
199: * Used to be in unctrl.h.
200: */
201: #define unctrl(c) _unctrl[(c) & 0177]
202: extern char *_unctrl[];
203: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.