|
|
1.1 root 1: /*********************************************************************
2: * COPYRIGHT NOTICE *
3: **********************************************************************
4: * This software is copyright (C) 1982 by Pavel Curtis *
5: * *
6: * Permission is granted to reproduce and distribute *
7: * this file by any means so long as no fee is charged *
8: * above a nominal handling fee and so long as this *
9: * notice is always included in the copies. *
10: * *
11: * Other rights are reserved except as explicitly granted *
12: * by written permission of the author. *
13: * Pavel Curtis *
14: * Computer Science Dept. *
15: * 405 Upson Hall *
16: * Cornell University *
17: * Ithaca, NY 14853 *
18: * *
19: * Ph- (607) 256-4934 *
20: * *
21: * Pavel.Cornell@Udel-Relay (ARPAnet) *
22: * decvax!cornell!pavel (UUCPnet) *
23: *********************************************************************/
24:
25: #ifndef WINDOW
26:
27: #define USE_TERMIO
28:
29: #define bool char
30:
31: typedef unsigned long chtype;
32:
33: #ifndef TRUE
34: # define TRUE (1)
35: # define FALSE (0)
36: #endif
37:
38: #define ERR (0)
39: #define OK (1)
40:
41: #define _SUBWIN 01
42: #define _ENDLINE 02
43: #define _FULLWIN 04
44: #define _SCROLLWIN 010
45:
46: #define _NOCHANGE -1
47:
48: #include "terminfo.h"
49:
50: struct _win_st {
51: short _cury, _curx;
52: short _maxy, _maxx;
53: short _begy, _begx;
54: short _flags;
55: chtype _attrs;
56: bool _clear;
57: bool _leave;
58: bool _scroll;
59: bool _idlok;
60: bool _use_keypad; /* 0=no, 1=yes, 2=yes/timeout */
61: bool _use_meta; /* T=use the meta key */
62: bool _nodelay; /* T=don't wait for tty input */
63: chtype **_line;
64: short *_firstchar; /* First changed character in the line */
65: short *_lastchar; /* Last changed character in the line */
66: short *_numchngd; /* Number of changes made in the line */
67: short _regtop; /* Top and bottom of scrolling region */
68: short _regbottom;
69: };
70:
71: #define WINDOW struct _win_st
72:
73: extern WINDOW *stdscr, *curscr;
74:
75: extern int LINES, COLS, COLORS, COLOR_PAIRS;
76: extern short pair, f, b, color, r, g, b;
77:
78: WINDOW *initscr(), *newwin(), *subwin();
79: char *longname();
80: struct screen *newterm(), *set_term();
81:
82: /*
83: * pseudo functions
84: */
85:
86: #define getyx(win,y,x) (y = (win)->_cury, x = (win)->_curx)
87:
88: #define inch() winch(stdscr)
89: #define standout() wstandout(stdscr)
90: #define standend() wstandend(stdscr)
91: #define attron(at) wattron(stdscr,at)
92: #define attroff(at) wattroff(stdscr,at)
93: #define attrset(at) wattrset(stdscr,at)
94:
95: #define winch(win) ((win)->_line[(win)->_cury][(win)->_curx])
96: #define wstandout(win) (wattrset(win,A_STANDOUT))
97: #define wstandend(win) (wattrset(win,A_NORMAL))
98: #define wattron(win,at) ((win)->_attrs |= (at))
99: #define wattroff(win,at) ((win)->_attrs &= ~(at))
100: #define wattrset(win,at) ((win)->_attrs = (at))
101:
102: #ifndef MINICURSES
103: /*
104: * pseudo functions for standard screen
105: */
106: # define addch(ch) waddch(stdscr, ch)
107: # define getch() wgetch(stdscr)
108: # define addstr(str) waddstr(stdscr, str)
109: # define getstr(str) wgetstr(stdscr, str)
110: # define move(y, x) wmove(stdscr, y, x)
111: # define clear() wclear(stdscr)
112: # define erase() werase(stdscr)
113: # define clrtobot() wclrtobot(stdscr)
114: # define clrtoeol() wclrtoeol(stdscr)
115: # define insertln() winsertln(stdscr)
116: # define deleteln() wdeleteln(stdscr)
117: # define refresh() wrefresh(stdscr)
118: # define insch(c) winsch(stdscr,c)
119: # define delch() wdelch(stdscr)
120: # define setscrreg(t,b) wsetscrreg(stdscr,t,b)
121: /*
122: * mv functions
123: */
124: # define mvwaddch(win,y,x,ch) (wmove(win,y,x) == ERR ? ERR : waddch(win,ch))
125: # define mvwgetch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wgetch(win))
126: # define mvwaddstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR \
127: : waddstr(win,str))
128: # define mvwgetstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : wgetstr(win,str))
129: # define mvwinch(win,y,x) (wmove(win,y,x) == ERR ? ERR : winch(win))
130: # define mvwdelch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wdelch(win))
131: # define mvwinsch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : winsch(win,c))
132: # define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
133: # define mvgetch(y,x) mvwgetch(stdscr,y,x)
134: # define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
135: # define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
136: # define mvinch(y,x) mvwinch(stdscr,y,x)
137: # define mvdelch(y,x) mvwdelch(stdscr,y,x)
138: # define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
139:
140: #else MINICURSES
141:
142: # define addch m_addch
143: # define addstr m_addstr
144: # define erase m_erase
145: # define clear m_clear
146: # define refresh m_refresh
147: # define initscr m_initscr
148: # define newterm m_newterm
149: # define mvaddch(y,x,ch) (move(y,x) == ERR ? ERR : addch(ch))
150: # define mvaddstr(y,x,str) (move(y,x) == ERR ? ERR : addstr(str))
151:
152: /*
153: * These functions don't exist in minicurses, so we define them
154: * to nonexistent functions to help the user catch the error.
155: */
156: # define box no_box
157: # define clrtobot no_clrtobot
158: # define clrtoeol no_clrtoeol
159: # define delch no_delch
160: # define deleteln no_deleteln
161: # define delwin no_delwin
162: # define getch no_getch
163: # define getstr no_getstr
164: # define insch no_insch
165: # define insertln no_insertln
166: # define longname no_longname
167: # define mvprintw no_mvprintw
168: # define mvscanw no_mvscanw
169: # define mvwin no_mvwin
170: # define mvwprintw no_mvwprintw
171: # define mvwscanw no_mvwscanw
172: # define newwin no_newwin
173: # define overlay no_overlay
174: # define overwrite no_overwrite
175: # define printw no_printw
176: # define putp no_putp
177: # define scanw no_scanw
178: # define scroll no_scroll
179: # define setscrreg no_setscrreg
180: # define subwin no_subwin
181: # define touchwin no_touchwin
182: # define tstp no_tstp
183: # define vidattr no_vidattr
184: # define waddch no_waddch
185: # define waddstr no_waddstr
186: # define wclear no_wclear
187: # define wclrtobot no_wclrtobot
188: # define wclrtoeol no_wclrtoeol
189: # define wdelch no_wdelch
190: # define wdeleteln no_wdeleteln
191: # define werase no_werase
192: # define wgetch no_wgetch
193: # define wgetstr no_wgetstr
194: # define winsch no_winsch
195: # define winsertln no_winsertln
196: # define wmove no_wmove
197: # define wprintw no_wprintw
198: # define wrefresh no_wrefresh
199: # define wscanw no_wscanw
200: # define wsetscrreg no_wsetscrreg
201:
202: /* mv functions that aren't valid */
203: # define mvdelch no_mvwdelch
204: # define mvgetch no_mvwgetch
205: # define mvgetstr no_mvwgetstr
206: # define mvinch no_mvwinch
207: # define mvinsch no_mvwinsch
208: # define mvwaddch no_mvwaddch
209: # define mvwaddstr no_mvaddstr
210: # define mvwdelch no_mvwdelch
211: # define mvwgetch no_mvwgetch
212: # define mvwgetstr no_mvwgetstr
213: # define mvwinch no_mvwinch
214: # define mvwinsch no_mvwinsch
215:
216: #endif MINICURSES
217:
218: #ifndef MINICURSES
219: /* Funny "characters" enabled for various special function keys for input */
220: #define KEY_BREAK 0401 /* break key (unreliable) */
221: #define KEY_DOWN 0402 /* The four arrow keys ... */
222: #define KEY_UP 0403
223: #define KEY_LEFT 0404
224: #define KEY_RIGHT 0405 /* ... */
225: #define KEY_HOME 0406 /* Home key (upward+left arrow) */
226: #define KEY_BACKSPACE 0407 /* backspace (unreliable) */
227: #define KEY_F0 0410 /* Function keys. Space for 64 */
228: #define KEY_F(n) (KEY_F0+(n)) /* keys is reserved. */
229: #define KEY_DL 0510 /* Delete line */
230: #define KEY_IL 0511 /* Insert line */
231: #define KEY_DC 0512 /* Delete character */
232: #define KEY_IC 0513 /* Insert char or enter insert mode */
233: #define KEY_EIC 0514 /* Exit insert char mode */
234: #define KEY_CLEAR 0515 /* Clear screen */
235: #define KEY_EOS 0516 /* Clear to end of screen */
236: #define KEY_EOL 0517 /* Clear to end of line */
237: #define KEY_SF 0520 /* Scroll 1 line forward */
238: #define KEY_SR 0521 /* Scroll 1 line backwards (reverse) */
239: #define KEY_NPAGE 0522 /* Next page */
240: #define KEY_PPAGE 0523 /* Previous page */
241: #define KEY_STAB 0524 /* Set tab */
242: #define KEY_CTAB 0525 /* Clear tab */
243: #define KEY_CATAB 0526 /* Clear all tabs */
244: #define KEY_ENTER 0527 /* Enter or send (unreliable) */
245: #define KEY_SRESET 0530 /* soft (partial) reset (unreliable) */
246: #define KEY_RESET 0531 /* reset or hard reset (unreliable) */
247: #define KEY_PRINT 0532 /* print or copy */
248: #define KEY_LL 0533 /* home down or bottom (lower left) */
249:
250: #endif MINICURSES
251:
252: #endif WINDOW
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.