Commit | Line | Data |
---|---|---|
87c6fcf8 DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | * | |
6 | * @(#)curses.h 5.1 (Berkeley) %G% | |
7 | */ | |
8 | ||
7781fc01 | 9 | # ifndef WINDOW |
1b7ae9b8 KA |
10 | |
11 | # include <stdio.h> | |
12 | ||
13 | # include <sgtty.h> | |
14 | ||
e7f97876 KA |
15 | # define bool char |
16 | # define reg register | |
1b7ae9b8 KA |
17 | |
18 | # define TRUE (1) | |
19 | # define FALSE (0) | |
e7f97876 KA |
20 | # define ERR (0) |
21 | # define OK (1) | |
1b7ae9b8 | 22 | |
60d72089 KA |
23 | # define _ENDLINE 001 |
24 | # define _FULLWIN 002 | |
25 | # define _SCROLLWIN 004 | |
26 | # define _FLUSH 010 | |
f70d219c JB |
27 | # define _FULLLINE 020 |
28 | # define _IDLINE 040 | |
e7f97876 KA |
29 | # define _STANDOUT 0200 |
30 | # define _NOCHANGE -1 | |
1b7ae9b8 | 31 | |
f70d219c | 32 | # define _puts(s) tputs(s, 0, _putchar) |
1b7ae9b8 KA |
33 | |
34 | typedef struct sgttyb SGTTY; | |
35 | ||
1b7ae9b8 KA |
36 | /* |
37 | * Capabilities from termcap | |
38 | */ | |
39 | ||
f70d219c | 40 | extern bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, |
2b6e3652 | 41 | XB, XN, XT, XS, XX; |
f70d219c JB |
42 | extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, |
43 | *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, | |
44 | *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, | |
45 | *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, | |
46 | *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, | |
47 | *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, | |
48 | *LEFT_PARM, *RIGHT_PARM; | |
49 | extern char PC; | |
1b7ae9b8 KA |
50 | |
51 | /* | |
52 | * From the tty modes... | |
53 | */ | |
1b7ae9b8 | 54 | |
f70d219c | 55 | extern bool GT, NONL, UPPERCASE, normtty, _pfast; |
e7f97876 KA |
56 | |
57 | struct _win_st { | |
60d72089 KA |
58 | short _cury, _curx; |
59 | short _maxy, _maxx; | |
60 | short _begy, _begx; | |
61 | short _flags; | |
f70d219c | 62 | short _ch_off; |
60d72089 KA |
63 | bool _clear; |
64 | bool _leave; | |
65 | bool _scroll; | |
66 | char **_y; | |
67 | short *_firstch; | |
68 | short *_lastch; | |
69 | struct _win_st *_nextp, *_orig; | |
1b7ae9b8 KA |
70 | }; |
71 | ||
e7f97876 | 72 | # define WINDOW struct _win_st |
1b7ae9b8 | 73 | |
e7f97876 | 74 | extern bool My_term, _echoit, _rawmode, _endwin; |
1b7ae9b8 | 75 | |
e7f97876 | 76 | extern char *Def_term, ttytype[]; |
1b7ae9b8 | 77 | |
e7f97876 | 78 | extern int LINES, COLS, _tty_ch, _res_flg; |
1b7ae9b8 | 79 | |
f5cca68f | 80 | extern SGTTY _tty; |
1b7ae9b8 | 81 | |
f5cca68f | 82 | extern WINDOW *stdscr, *curscr; |
1b7ae9b8 KA |
83 | |
84 | /* | |
85 | * Define VOID to stop lint from generating "null effect" | |
86 | * comments. | |
87 | */ | |
88 | # ifdef lint | |
e7f97876 | 89 | int __void__; |
1b7ae9b8 KA |
90 | # define VOID(x) (__void__ = (int) (x)) |
91 | # else | |
92 | # define VOID(x) (x) | |
93 | # endif | |
94 | ||
1b7ae9b8 KA |
95 | /* |
96 | * psuedo functions for standard screen | |
97 | */ | |
98 | # define addch(ch) VOID(waddch(stdscr, ch)) | |
99 | # define getch() VOID(wgetch(stdscr)) | |
100 | # define addstr(str) VOID(waddstr(stdscr, str)) | |
101 | # define getstr(str) VOID(wgetstr(stdscr, str)) | |
102 | # define move(y, x) VOID(wmove(stdscr, y, x)) | |
103 | # define clear() VOID(wclear(stdscr)) | |
104 | # define erase() VOID(werase(stdscr)) | |
105 | # define clrtobot() VOID(wclrtobot(stdscr)) | |
106 | # define clrtoeol() VOID(wclrtoeol(stdscr)) | |
107 | # define insertln() VOID(winsertln(stdscr)) | |
108 | # define deleteln() VOID(wdeleteln(stdscr)) | |
109 | # define refresh() VOID(wrefresh(stdscr)) | |
110 | # define inch() VOID(winch(stdscr)) | |
ca10091d | 111 | # define insch(c) VOID(winsch(stdscr,c)) |
6a1aa6bb | 112 | # define delch() VOID(wdelch(stdscr)) |
1b7ae9b8 KA |
113 | # define standout() VOID(wstandout(stdscr)) |
114 | # define standend() VOID(wstandend(stdscr)) | |
115 | ||
116 | /* | |
117 | * mv functions | |
118 | */ | |
119 | #define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch)) | |
120 | #define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win)) | |
121 | #define mvwaddstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str)) | |
6dd2bba9 | 122 | #define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str)) |
1b7ae9b8 | 123 | #define mvwinch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : winch(win)) |
6a1aa6bb | 124 | #define mvwdelch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win)) |
ca10091d | 125 | #define mvwinsch(win,y,x,c) VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c)) |
1b7ae9b8 KA |
126 | #define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch) |
127 | #define mvgetch(y,x) mvwgetch(stdscr,y,x) | |
128 | #define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str) | |
6dd2bba9 | 129 | #define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str) |
85957a31 | 130 | #define mvinch(y,x) mvwinch(stdscr,y,x) |
6a1aa6bb | 131 | #define mvdelch(y,x) mvwdelch(stdscr,y,x) |
ca10091d | 132 | #define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c) |
1b7ae9b8 KA |
133 | |
134 | /* | |
135 | * psuedo functions | |
136 | */ | |
137 | ||
138 | #define clearok(win,bf) (win->_clear = bf) | |
139 | #define leaveok(win,bf) (win->_leave = bf) | |
140 | #define scrollok(win,bf) (win->_scroll = bf) | |
141 | #define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)) | |
142 | #define getyx(win,y,x) y = win->_cury, x = win->_curx | |
34318855 | 143 | #define winch(win) (win->_y[win->_cury][win->_curx] & 0177) |
1b7ae9b8 KA |
144 | |
145 | #define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, stty(_tty_ch,&_tty)) | |
146 | #define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty)) | |
f70d219c JB |
147 | #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, stty(_tty_ch,&_tty)) |
148 | #define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,stty(_tty_ch,&_tty)) | |
149 | #define crmode() cbreak() /* backwards compatability */ | |
150 | #define nocrmode() nocbreak() /* backwards compatability */ | |
1b7ae9b8 KA |
151 | #define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, stty(_tty_ch, &_tty)) |
152 | #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, stty(_tty_ch, &_tty)) | |
153 | #define nl() (_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty)) | |
154 | #define nonl() (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty)) | |
f70d219c JB |
155 | #define savetty() ((void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags) |
156 | #define resetty() (_tty.sg_flags = _res_flg, (void) stty(_tty_ch, &_tty)) | |
157 | ||
158 | #define erasechar() (_tty.sg_erase) | |
159 | #define killchar() (_tty.sg_kill) | |
160 | #define baudrate() (_tty.sg_ospeed) | |
1b7ae9b8 KA |
161 | |
162 | WINDOW *initscr(), *newwin(), *subwin(); | |
d037dc33 | 163 | char *longname(), *getcap(); |
7781fc01 | 164 | |
7e8a00f3 SL |
165 | /* |
166 | * Used to be in unctrl.h. | |
167 | */ | |
168 | #define unctrl(c) _unctrl[(c) & 0177] | |
74ac3b5d | 169 | extern char *_unctrl[]; |
7781fc01 | 170 | # endif |