Sync usage with man page.
[netbsd-mini2440.git] / gnu / lib / libg++ / g++-include / CursesW.h
blob7056db5dc5626a9e81788a64cbff3806138dd647
1 // This may look like C code, but it is really -*- C++ -*-
3 /*
4 Copyright (C) 1989 Free Software Foundation
5 written by Eric Newton (newton@rocky.oswego.edu)
7 This file is part of GNU CC.
9 GNU CC is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY. No author or distributor
11 accepts responsibility to anyone for the consequences of using it
12 or for whether it serves any particular purpose or works at all,
13 unless he says so in writing. Refer to the GNU CC General Public
14 License for full details.
16 Everyone is granted permission to copy, modify and redistribute
17 GNU CC, but only under the conditions described in the
18 GNU CC General Public License. A copy of this license is
19 supposed to have been given to you along with GNU CC so you
20 can know your rights and responsibilities. It should be in a
21 file named COPYING. Among other things, the copyright notice
22 and this notice must be preserved on all copies.
25 #ifndef _CursesWindow_h
26 #ifdef __GNUG__
27 #pragma once
28 #pragma interface
29 #endif
30 #define _CursesWindow_h
31 #ifdef __GNUG__
32 #pragma once
33 #pragma interface
34 #endif
36 #include <curses.h>
40 * C++ class for windows.
45 class CursesWindow
47 protected:
48 static int count; // count of all active windows:
49 // We rely on the c++ promise that
50 // all otherwise uninitialized
51 // static class vars are set to 0
53 WINDOW * w; // the curses WINDOW
55 int alloced; // true if we own the WINDOW
57 CursesWindow* par; // parent, if subwindow
58 CursesWindow* subwins; // head of subwindows list
59 CursesWindow* sib; // next subwindow of parent
61 void kill_subwindows(); // disable all subwindows
63 public:
64 CursesWindow(WINDOW* &window); // useful only for stdscr
66 CursesWindow(int lines, // number of lines
67 int cols, // number of columns
68 int begin_y, // line origin
69 int begin_x); // col origin
71 CursesWindow(CursesWindow& par, // parent window
72 int lines, // number of lines
73 int cols, // number of columns
74 int by, // absolute or relative
75 int bx, // origins:
76 char absrel = 'a'); // if `a', by & bx are
77 // absolute screen pos,
78 // else if `r', they are
79 // relative to par origin
80 ~CursesWindow();
82 // terminal status
83 int lines(); // number of lines on terminal, *not* window
84 int cols(); // number of cols on terminal, *not* window
86 // window status
87 int height(); // number of lines in this window
88 int width(); // number of cols in this window
89 int begx(); // smallest x coord in window
90 int begy(); // smallest y coord in window
91 int maxx(); // largest x coord in window
92 int maxy(); // largest x coord in window
94 // window positioning
95 int move(int y, int x);
97 // coordinate positioning
98 void getyx(int& y, int& x);
99 int mvcur(int sy, int ey, int sx, int ex);
101 // input
102 int getch();
103 int getstr(char * str);
104 int scanw(const char *, ...);
106 // input + positioning
107 int mvgetch(int y, int x);
108 int mvgetstr(int y, int x, char * str);
109 int mvscanw(int, int, const char*, ...);
111 // output
112 int addch(const char ch);
113 int addstr(const char * str);
114 int printw(const char * fmt, ...);
115 int inch();
116 int insch(char c);
117 int insertln();
119 // output + positioning
120 int mvaddch(int y, int x, char ch);
121 int mvaddstr(int y, int x, char * str);
122 int mvprintw(int y, int x, const char * fmt, ...);
123 int mvinch(int y, int x);
124 int mvinsch(int y, int x, char ch);
126 // borders
127 int box(char vert, char hor);
129 // erasure
130 int erase();
131 int clear();
132 int clearok(cbool bf);
133 int clrtobot();
134 int clrtoeol();
135 int delch();
136 int mvdelch(int y, int x);
137 int deleteln();
139 // screen control
140 int scroll();
141 int scrollok(cbool bf);
142 int touchwin();
143 int refresh();
144 int leaveok(cbool bf);
145 int flushok(cbool bf);
146 int standout();
147 int standend();
149 // multiple window control
150 int overlay(CursesWindow &win);
151 int overwrite(CursesWindow &win);
154 // traversal support
155 CursesWindow* child();
156 CursesWindow* sibling();
157 CursesWindow* parent();
160 #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
163 inline int CursesWindow::begx()
165 return w->_begx;
168 inline int CursesWindow::begy()
170 return w->_begy;
173 inline int CursesWindow::maxx()
175 return w->_maxx;
178 inline int CursesWindow::maxy()
180 return w->_maxy;
183 inline int CursesWindow::height()
185 return maxy() - begy() + 1;
188 inline int CursesWindow::width()
190 return maxx() - begx() + 1;
193 inline int CursesWindow::box(char vert, char hor)
195 return ::box(w, vert, hor);
198 inline int CursesWindow::overlay(CursesWindow &win)
200 return ::overlay(w, win.w);
203 inline int CursesWindow::overwrite(CursesWindow &win)
205 return ::overwrite(w, win.w);
208 inline int CursesWindow::scroll()
210 return ::scroll(w);
214 inline int CursesWindow::touchwin()
216 return ::touchwin(w);
219 inline int CursesWindow::addch(const char ch)
221 return ::waddch(w, ch);
224 inline int CursesWindow::addstr(const char * str)
226 return ::waddstr(w, str);
229 inline int CursesWindow::clear()
231 return ::wclear(w);
234 inline int CursesWindow::clrtobot()
236 return ::wclrtobot(w);
239 inline int CursesWindow::clrtoeol()
241 return ::wclrtoeol(w);
244 inline int CursesWindow::delch()
246 return ::wdelch(w);
249 inline int CursesWindow::deleteln()
251 return ::wdeleteln(w);
254 inline int CursesWindow::erase()
256 return ::werase(w);
259 inline int CursesWindow::getch()
261 return ::wgetch(w);
264 inline int CursesWindow::getstr(char * str)
266 return ::wgetstr(w, str);
269 inline int CursesWindow::inch()
271 return winch(w);
274 inline int CursesWindow::insch(char c)
276 return ::winsch(w, c);
279 inline int CursesWindow::insertln()
281 return ::winsertln(w);
284 inline int CursesWindow::move(int y, int x)
286 return ::wmove(w, y, x);
290 inline int CursesWindow::mvcur(int sy, int ey, int sx, int ex)
292 return ::mvcur(sy, ey, sx,ex);
295 inline int CursesWindow::mvaddch(int y, int x, char ch)
297 return (::wmove(w, y, x)==0) ? 0 : ::waddch(w, ch);
300 inline int CursesWindow::mvgetch(int y, int x)
302 return (::wmove(w, y, x)==0) ? 0 : ::wgetch(w);
305 inline int CursesWindow::mvaddstr(int y, int x, char * str)
307 return (::wmove(w, y, x)==0) ? 0 : ::waddstr(w, str);
310 inline int CursesWindow::mvgetstr(int y, int x, char * str)
312 return (::wmove(w, y, x)==0) ? 0 : ::wgetstr(w, str);
315 inline int CursesWindow::mvinch(int y, int x)
317 return (::wmove(w, y, x)==0) ? 0 : ::winch(w);
320 inline int CursesWindow::mvdelch(int y, int x)
322 return (::wmove(w, y, x)==0) ? 0 : ::wdelch(w);
325 inline int CursesWindow::mvinsch(int y, int x, char ch)
327 return (::wmove(w, y, x)==0) ? 0 : ::winsch(w, ch);
330 inline int CursesWindow::refresh()
332 return ::wrefresh(w);
335 inline int CursesWindow::clearok(cbool bf)
337 return ::clearok(w,bf);
340 inline int CursesWindow::leaveok(cbool bf)
342 return ::leaveok(w,bf);
345 inline int CursesWindow::scrollok(cbool bf)
347 return ::scrollok(w,bf);
350 inline int CursesWindow::flushok(cbool bf)
352 return ::flushok(w, bf);
355 inline void CursesWindow::getyx(int& y, int& x)
357 ::getyx(w, y, x);
360 inline int CursesWindow::standout()
362 return ::wstandout(w);
365 inline int CursesWindow::standend()
367 return ::wstandend(w);
370 inline int CursesWindow::lines()
372 return LINES;
375 inline int CursesWindow::cols()
377 return COLS;
380 inline CursesWindow* CursesWindow::child()
382 return subwins;
385 inline CursesWindow* CursesWindow::parent()
387 return par;
390 inline CursesWindow* CursesWindow::sibling()
392 return sib;
396 # endif
397 #endif