source: trunk/minix/include/curses.h@ 21

Last change on this file since 21 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 9.0 KB
Line 
1/* curses.h - defines macros and prototypes for curses */
2
3#ifndef _CURSES_H
4#define _CURSES_H
5
6#include <termios.h>
7#include <stdarg.h>
8#include <stdio.h>
9
10typedef int bool;
11
12#ifndef TRUE
13#define TRUE 1
14#endif
15#ifndef FALSE
16#define FALSE 0
17#endif
18#ifndef ERR
19#define ERR (-1) /* general error flag */
20#endif
21#ifndef OK
22#define OK 0 /* general OK flag */
23#endif
24
25/* Macros. */
26#define box(win,vc,hc) wbox(win,0,0,0,0,vc,hc)
27#define addch(ch) waddch(stdscr,ch)
28#define mvaddch(y,x,ch) (wmove(stdscr,y,x)==ERR?ERR:waddch(stdscr,ch))
29#define mvwaddch(win,y,x,ch) (wmove(win,y,x)==ERR?ERR:waddch(win,ch))
30#define getch() wgetch(stdscr)
31#define mvgetch(y,x) (wmove(stdscr,y,x)==ERR?ERR:wgetch(stdscr))
32#define mvwgetch(win,y,x) (wmove(win,y,x)==ERR?ERR:wgetch(win))
33#define addstr(str) waddstr(stdscr,str)
34#define mvaddstr(y,x,str) (wmove(stdscr,y,x)==ERR?ERR:waddstr(stdscr,str))
35#define mvwaddstr(win,y,x,str) (wmove(win,y,x)==ERR?ERR:waddstr(win,str))
36#define getstr(str) wgetstr(stdscr,str)
37#define mvgetstr(y,x,str) (wmove(stdscr,y,x)==ERR?ERR:wgetstr(stdscr,str))
38#define mvwgetstr(win,y,x,str) (wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
39#define move(y,x) wmove(stdscr,y,x)
40#define clear() wclear(stdscr)
41#define erase() werase(stdscr)
42#define clrtobot() wclrtobot(stdscr)
43#define mvclrtobot(y,x) (wmove(stdscr,y,x)==ERR?ERR:wclrtobot(stdscr))
44#define mvwclrtobot(win,y,x) (wmove(win,y,x)==ERR?ERR:wclrtobot(win))
45#define clrtoeol() wclrtoeol(stdscr)
46#define mvclrtoeol(y,x) (wmove(stdscr,y,x)==ERR?ERR:wclrtoeol(stdscr))
47#define mvwclrtoeol(win,y,x) (wmove(win,y,x)==ERR?ERR:wclrtoeol(win))
48#define insertln() winsertln(stdscr)
49#define mvinsertln(y,x) (wmove(stdscr,y,x)==ERR?ERR:winsertln(stdscr))
50#define mvwinsertln(win,y,x) (wmove(win,y,x)==ERR?ERR:winsertln(win))
51#define deleteln() wdeleteln(stdscr)
52#define mvdeleteln(y,x) (wmove(stdscr,y,x)==ERR?ERR:wdeleteln(stdscr))
53#define mvwdeleteln(win,y,x) (wmove(win,y,x)==ERR?ERR:wdeleteln(win))
54#define refresh() wrefresh(stdscr)
55#define inch() winch(stdscr)
56#define insch(ch) winsch(stdscr,ch)
57#define mvinsch(y,x,ch) (wmove(stdscr,y,x)==ERR?ERR:winsch(stdscr,ch))
58#define mvwinsch(win,y,x,ch) (wmove(win,y,x)==ERR?ERR:winsch(win,ch))
59#define delch() wdelch(stdscr)
60#define mvdelch(y,x) (wmove(stdscr,y,x)==ERR?ERR:wdelch(stdscr))
61#define mvwdelch(win,y,x) (wmove(win,y,x)==ERR?ERR:wdelch(win))
62#define standout() wstandout(stdscr)
63#define wstandout(win) ((win)->_attrs |= A_STANDOUT)
64#define standend() wstandend(stdscr)
65#define wstandend(win) ((win)->_attrs &= ~A_STANDOUT)
66#define attrset(attrs) wattrset(stdscr, attrs)
67#define wattrset(win, attrs) ((win)->_attrs = (attrs))
68#define attron(attrs) wattron(stdscr, attrs)
69#define wattron(win, attrs) ((win)->_attrs |= (attrs))
70#define attroff(attrs) wattroff(stdscr,attrs)
71#define wattroff(win, attrs) ((win)->_attrs &= ~(attrs))
72#define resetty() tcsetattr(1, TCSANOW, &_orig_tty)
73#define getyx(win,y,x) (y = (win)->_cury, x = (win)->_curx)
74
75/* Video attribute definitions. */
76#define A_BLINK 0x0100
77#define A_BLANK 0
78#define A_BOLD 0x0200
79#define A_DIM 0
80#define A_PROTECT 0
81#define A_REVERSE 0x0400
82#define A_STANDOUT 0x0800
83#define A_UNDERLINE 0x1000
84#define A_ALTCHARSET 0x2000
85
86/* Type declarations. */
87typedef struct {
88 int _cury; /* current pseudo-cursor */
89 int _curx;
90 int _maxy; /* max coordinates */
91 int _maxx;
92 int _begy; /* origin on screen */
93 int _begx;
94 int _flags; /* window properties */
95 int _attrs; /* attributes of written characters */
96 int _tabsize; /* tab character size */
97 bool _clear; /* causes clear at next refresh */
98 bool _leave; /* leaves cursor as it happens */
99 bool _scroll; /* allows window scrolling */
100 bool _nodelay; /* input character wait flag */
101 bool _keypad; /* flags keypad key mode active */
102 int **_line; /* pointer to line pointer array */
103 int *_minchng; /* First changed character in line */
104 int *_maxchng; /* Last changed character in line */
105 int _regtop; /* Top/bottom of scrolling region */
106 int _regbottom;
107} WINDOW;
108
109/* External variables */
110extern int LINES; /* terminal height */
111extern int COLS; /* terminal width */
112extern bool NONL; /* \n causes CR too ? */
113extern WINDOW *curscr; /* the current screen image */
114extern WINDOW *stdscr; /* the default screen window */
115extern struct termios _orig_tty, _tty;
116
117extern unsigned int ACS_ULCORNER; /* terminal dependent block grafic */
118extern unsigned int ACS_LLCORNER; /* charcters. Forget IBM, we are */
119extern unsigned int ACS_URCORNER; /* independent of their charset. :-) */
120extern unsigned int ACS_LRCORNER;
121extern unsigned int ACS_RTEE;
122extern unsigned int ACS_LTEE;
123extern unsigned int ACS_BTEE;
124extern unsigned int ACS_TTEE;
125extern unsigned int ACS_HLINE;
126extern unsigned int ACS_VLINE;
127extern unsigned int ACS_PLUS;
128extern unsigned int ACS_S1;
129extern unsigned int ACS_S9;
130extern unsigned int ACS_DIAMOND;
131extern unsigned int ACS_CKBOARD;
132extern unsigned int ACS_DEGREE;
133extern unsigned int ACS_PLMINUS;
134extern unsigned int ACS_BULLET;
135extern unsigned int ACS_LARROW;
136extern unsigned int ACS_RARROW;
137extern unsigned int ACS_DARROW;
138extern unsigned int ACS_UARROW;
139extern unsigned int ACS_BOARD;
140extern unsigned int ACS_LANTERN;
141extern unsigned int ACS_BLOCK;
142
143_PROTOTYPE( char *unctrl, (int _c) );
144_PROTOTYPE( int baudrate, (void));
145_PROTOTYPE( void beep, (void));
146_PROTOTYPE( void cbreak, (void));
147_PROTOTYPE( void clearok, (WINDOW *_win, bool _flag) );
148_PROTOTYPE( void clrscr, (void));
149_PROTOTYPE( void curs_set, (int _visibility) );
150_PROTOTYPE( void delwin, (WINDOW *_win) );
151_PROTOTYPE( void doupdate, (void));
152_PROTOTYPE( void echo, (void));
153_PROTOTYPE( int endwin, (void));
154_PROTOTYPE( int erasechar, (void));
155_PROTOTYPE( void fatal, (char *_s) );
156_PROTOTYPE( int fixterm, (void));
157_PROTOTYPE( void flash, (void));
158_PROTOTYPE( void gettmode, (void));
159_PROTOTYPE( void idlok, (WINDOW *_win, bool _flag) );
160_PROTOTYPE( WINDOW *initscr, (void));
161_PROTOTYPE( void keypad, (WINDOW *_win, bool _flag) );
162_PROTOTYPE( int killchar, (void));
163_PROTOTYPE( void leaveok, (WINDOW *_win, bool _flag) );
164_PROTOTYPE( char *longname, (void));
165_PROTOTYPE( void meta, (WINDOW *_win, bool _flag) );
166_PROTOTYPE( int mvcur, (int _oldy, int _oldx, int _newy, int _newx) );
167_PROTOTYPE( int mvinch, (int _y, int _x) );
168_PROTOTYPE( int mvprintw, (int _y, int _x, const char *_fmt, ...) );
169_PROTOTYPE( int mvscanw, (int _y, int _x, const char *_fmt, ...) );
170_PROTOTYPE( int mvwin, (WINDOW *_win, int _begy, int _begx) );
171_PROTOTYPE( int mvwinch, (WINDOW *_win, int _y, int _x) );
172_PROTOTYPE( int mvwprintw, (WINDOW *_win, int _y, int _x, const char *_fmt,
173 ...) );
174_PROTOTYPE( int mvwscanw, (WINDOW *_win, int _y, int _x, const char *_fmt,
175 ...) );
176_PROTOTYPE( WINDOW *newwin, (int _num_lines, int _num_cols, int _y, int _x));
177_PROTOTYPE( void nl, (void));
178_PROTOTYPE( void nocbreak, (void));
179_PROTOTYPE( void nodelay, (WINDOW *_win, bool _flag) );
180_PROTOTYPE( void noecho, (void));
181_PROTOTYPE( void nonl, (void));
182_PROTOTYPE( void noraw, (void));
183_PROTOTYPE( void outc, (int _c) );
184_PROTOTYPE( void overlay, (WINDOW *_win1, WINDOW *_win2) );
185_PROTOTYPE( void overwrite, (WINDOW *_win1, WINDOW *_win2) );
186_PROTOTYPE( void poscur, (int _r, int _c) );
187_PROTOTYPE( int printw, (const char *_fmt, ...) );
188_PROTOTYPE( void raw, (void));
189_PROTOTYPE( int resetterm, (void));
190_PROTOTYPE( int saveoldterm, (void));
191_PROTOTYPE( int saveterm, (void));
192_PROTOTYPE( int savetty, (void));
193_PROTOTYPE( int scanw, (const char *_fmt, ...) );
194_PROTOTYPE( void scroll, (WINDOW *_win) );
195_PROTOTYPE( void scrollok, (WINDOW *_win, bool _flag) );
196_PROTOTYPE( int setscrreg, (int _top, int _bottom) );
197_PROTOTYPE( int setterm, (char *_type) );
198_PROTOTYPE( int setupterm, (void));
199_PROTOTYPE( WINDOW *subwin, (WINDOW *_orig, int _nlines, int _ncols, int _y,
200 int _x));
201_PROTOTYPE( int tabsize, (int _ts) );
202_PROTOTYPE( void touchwin, (WINDOW *_win) );
203_PROTOTYPE( int waddch, (WINDOW *_win, int _c) );
204_PROTOTYPE( int waddstr, (WINDOW *_win, char *_str) );
205_PROTOTYPE( int wbox, (WINDOW *_win, int _ymin, int _xmin, int _ymax,
206 int _xmax, unsigned int _v, unsigned int _h) );
207_PROTOTYPE( void wclear, (WINDOW *_win) );
208_PROTOTYPE( int wclrtobot, (WINDOW *_win) );
209_PROTOTYPE( int wclrtoeol, (WINDOW *_win) );
210_PROTOTYPE( int wdelch, (WINDOW *_win) );
211_PROTOTYPE( int wdeleteln, (WINDOW *_win) );
212_PROTOTYPE( void werase, (WINDOW *_win) );
213_PROTOTYPE( int wgetch, (WINDOW *_win) );
214_PROTOTYPE( int wgetstr, (WINDOW *_win, char *_str) );
215_PROTOTYPE( int winch, (WINDOW *_win) );
216_PROTOTYPE( int winsch, (WINDOW *_win, int _c) );
217_PROTOTYPE( int winsertln, (WINDOW *_win) );
218_PROTOTYPE( int wmove, (WINDOW *_win, int _y, int _x) );
219_PROTOTYPE( void wnoutrefresh, (WINDOW *_win) );
220_PROTOTYPE( int wprintw, (WINDOW *_win, const char *_fmt, ...));
221_PROTOTYPE( void wrefresh, (WINDOW *_win) );
222_PROTOTYPE( int wscanw, (WINDOW *_win, const char *_fmt, ...));
223_PROTOTYPE( int wsetscrreg, (WINDOW *_win, int _top, int _bottom) );
224_PROTOTYPE( int wtabsize, (WINDOW *_win, int _ts) );
225
226#endif /* _CURSES_H */
Note: See TracBrowser for help on using the repository browser.