|
|
1.1 root 1: /* 5/15/81 (Berkeley) @(#)curses.h 1.8 */
2: # ifndef WINDOW
3:
4: # include "stdio.h"
5:
6: #ifndef S3
7: # include "sgtty.h"
8: #else
9: #include "termio.h"
10: #endif
11:
12: # define bool char
13: # define reg register
14:
15: # define TRUE (1)
16: # define FALSE (0)
17: # define ERR (0)
18: # define OK (1)
19:
20: # define _SUBWIN 01
21: # define _ENDLINE 02
22: # define _FULLWIN 04
23: # define _SCROLLWIN 010
24: # define _FLUSH 020
25: # define _STANDOUT 0200
26: # define _NOCHANGE -1
27:
28: # define _puts(s) tputs(s, 0, _putchar);
29:
30: #ifndef S3
31: typedef struct sgttyb SGTTY;
32: #else
33: typedef struct termio TERMIO;
34: #endif
35:
36: /*
37: * Capabilities from termcap
38: */
39:
40: extern bool AM, BS, CA, DA, DB, EO, GT, HZ, IN, MI, MS, NC, OS, UL,
41: XN;
42: extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *DC, *DL, *DM, *DO,
43: *ED, *EI, *HO, *IC, *IM, *IP, *LL, *MA, *ND, *SE, *SF,
44: *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VE,
45: *VS, PC;
46:
47: /*
48: * From the tty modes...
49: */
50:
51: extern bool NONL, UPPERCASE, normtty, _pfast;
52:
53: struct _win_st {
54: short _cury, _curx;
55: short _maxy, _maxx;
56: short _begy, _begx;
57: short _flags;
58: bool _clear;
59: bool _leave;
60: bool _scroll;
61: char **_y;
62: short *_firstch;
63: short *_lastch;
64: };
65:
66: # define WINDOW struct _win_st
67:
68: extern bool My_term, _echoit, _rawmode, _endwin;
69:
70: extern char *Def_term, ttytype[];
71:
72: #ifndef S3
73: extern int LINES, COLS, _tty_ch, _res_flg;
74: #else
75: extern int LINES, COLS, _tty_ch;
76: extern TERMIO _res_flg ;
77: #endif
78:
79:
80: #ifndef S3
81: extern SGTTY _tty;
82: #else
83: extern TERMIO _tty;
84: #endif
85:
86: extern WINDOW *stdscr, *curscr;
87:
88: /*
89: * Define VOID to stop lint from generating "null effect"
90: * comments.
91: */
92: # ifdef lint
93: int __void__;
94: # define VOID(x) (__void__ = (int) (x))
95: # else
96: # define VOID(x) (x)
97: # endif
98:
99: /*
100: * psuedo functions for standard screen
101: */
102: # define addch(ch) VOID(waddch(stdscr, ch))
103: # define getch() VOID(wgetch(stdscr))
104: # define addstr(str) VOID(waddstr(stdscr, str))
105: # define getstr(str) VOID(wgetstr(stdscr, str))
106: # define move(y, x) VOID(wmove(stdscr, y, x))
107: # define clear() VOID(wclear(stdscr))
108: # define erase() VOID(werase(stdscr))
109: # define clrtobot() VOID(wclrtobot(stdscr))
110: # define clrtoeol() VOID(wclrtoeol(stdscr))
111: # define insertln() VOID(winsertln(stdscr))
112: # define deleteln() VOID(wdeleteln(stdscr))
113: # define refresh() VOID(wrefresh(stdscr))
114: # define inch() VOID(winch(stdscr))
115: # define insch(c) VOID(winsch(stdscr,c))
116: # define delch() VOID(wdelch(stdscr))
117: # define standout() VOID(wstandout(stdscr))
118: # define standend() VOID(wstandend(stdscr))
119:
120: /*
121: * mv functions
122: */
123: #define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
124: #define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
125: #define mvwaddstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
126: #define mvwgetstr(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win))
127: #define mvwinch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
128: #define mvwdelch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
129: #define mvwinsch(win,y,x,c) VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c))
130: #define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
131: #define mvgetch(y,x) mvwgetch(stdscr,y,x)
132: #define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
133: #define mvgetstr(y,x) mvwgetstr(stdscr,y,x)
134: #define mvinch(y,x) mvwinch(stdscr,y,x)
135: #define mvdelch(y,x) mvwdelch(stdscr,y,x)
136: #define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
137:
138: /*
139: * psuedo functions
140: */
141:
142: #define clearok(win,bf) (win->_clear = bf)
143: #define leaveok(win,bf) (win->_leave = bf)
144: #define scrollok(win,bf) (win->_scroll = bf)
145: #define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
146: #define getyx(win,y,x) y = win->_cury, x = win->_curx
147: #define winch(win) (win->_y[win->_cury][win->_curx])
148:
149: #ifndef S3
150: #define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, stty(_tty_ch,&_tty))
151: #define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty))
152: #define crmode() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, stty(_tty_ch,&_tty))
153: #define nocrmode() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,stty(_tty_ch,&_tty))
154: #define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, stty(_tty_ch, &_tty))
155: #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, stty(_tty_ch, &_tty))
156: #define nl() (_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty))
157: #define nonl() (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty))
158: #define savetty() (gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags)
159: #define resetty() (_tty.sg_flags = _res_flg, stty(_tty_ch, &_tty))
160: #else
161: #define raw() ( _tty.c_iflag &= ~(ICRNL|IUCLC), \
162: _tty.c_cflag |= CS8, \
163: _tty.c_cc[VEOF] = 1, \
164: _tty.c_cc[VEOL] = 1, \
165: _pfast = _rawmode = TRUE, \
166: ioctl(_tty_ch, TCSETA, &_tty) )
167:
168: #define noraw() ( _tty.c_oflag |= OPOST, \
169: _tty.c_iflag |= (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON|IXANY), \
170: _tty.c_lflag |= (ISIG|ICANON), \
171: _tty.c_cflag |= (CS7|PARENB), \
172: _tty.c_cflag &= ~(CSIZE), \
173: _tty.c_cc[VEOF] = CEOF, \
174: _tty.c_cc[VEOL] = CNUL, \
175: _rawmode = FALSE, \
176: _pfast = !(_tty.c_oflag&ONLCR), \
177: ioctl(_tty_ch, TCSETA, &_tty) )
178:
179: #define crmode() ( _tty.c_iflag = (IXON|BRKINT), \
180: _tty.c_oflag &= ~(OPOST), \
181: _tty.c_cflag &= ~(CSIZE|PARENB), \
182: _tty.c_cflag |= CS8, \
183: _tty.c_lflag &= ~(ICANON|XCASE), \
184: _tty.c_lflag |= ISIG, \
185: _tty.c_cc[VEOF] = 1, \
186: _tty.c_cc[VEOL] = 1, \
187: _rawmode = TRUE, \
188: ioctl(_tty_ch, TCSETA, &_tty) )
189:
190: #define nocrmode() ( noraw() )
191:
192: #define echo() ( _tty.c_cflag |= ECHO, \
193: _echoit = TRUE, \
194: ioctl(_tty_ch, TCSETA, &_tty) )
195:
196: #define noecho() ( _tty.c_cflag &= ~ECHO, \
197: _echoit = FALSE, \
198: ioctl(_tty_ch, TCSETA, &_tty) )
199:
200: #define nl() ( _tty.c_oflag |= OCRNL, \
201: _pfast = _rawmode, \
202: ioctl(_tty_ch, TCSETA, &_tty) )
203:
204: #define nonl() ( _tty.c_oflag &= ~OCRNL, \
205: _tty.c_oflag |= ONLCR, \
206: _pfast = TRUE, \
207: ioctl(_tty_ch, TCSETA, &_tty) )
208:
209: #define savetty() ( ioctl(_tty_ch, TCGETA, &_tty), \
210: _res_flg = _tty )
211:
212: #define resetty() ( _tty = _res_flg, \
213: ioctl(_tty_ch, TCSETA, &_tty) )
214: #endif
215:
216:
217: WINDOW *initscr(), *newwin(), *subwin();
218: char *longname(), *getcap();
219:
220: # endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.