1 /* $NetBSD: curses.h,v 1.90 2007/07/11 18:44:46 jdc Exp $ */ 2 3 /* 4 * Copyright (c) 1981, 1993, 1994 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the University nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * @(#)curses.h 8.5 (Berkeley) 4/29/95 32 * 33 * Modified by Ruibiao Qiu <ruibiao@arl.wustl.edu,ruibiao@gmail.com> 2005 34 * to add wide character support 35 * - Add complex character structure (cchar_t) 36 * - Add definitions of wide character routines 37 * - Add KEY_CODE_YES 38 */ 39 40 #ifndef _CURSES_H_ 41 #define _CURSES_H_ 42 43 #include <sys/types.h> 44 #include <sys/cdefs.h> 45 #include <wchar.h> 46 47 #include <stdio.h> 48 #include <stdbool.h> 49 #include <termcap.h> 50 51 /* 52 * attr_t must be the same size as wchar_t (see <wchar.h>) to avoid padding 53 * in __LDATA. 54 */ 55 typedef wchar_t chtype; 56 typedef wchar_t attr_t; 57 58 #ifdef HAVE_WCHAR 59 /* 60 * The complex character structure required by the X/Open reference to be used in 61 * functions such as in_wchstr(). It includes a string of up to 8 wide characters 62 * and its length, an attribute, and a color-pair. 63 */ 64 #define CURSES_CCHAR_MAX 8 65 #define CCHARW_MAX 5 66 typedef struct { 67 attr_t attributes; /* character attributes */ 68 unsigned elements; /* number of wide char in vals[] */ 69 wchar_t vals[CURSES_CCHAR_MAX]; /* wide chars including non-spacing */ 70 } cchar_t; 71 #else 72 typedef chtype cchar_t; 73 #endif /* HAVE_WCHAR */ 74 75 #ifndef TRUE 76 #define TRUE (/*CONSTCOND*/1) 77 #endif 78 #ifndef FALSE 79 #define FALSE (/*CONSTCOND*/0) 80 #endif 81 82 #ifndef _CURSES_PRIVATE 83 84 #define _puts(s) tputs(s, 0, __cputchar) 85 #define _putchar(c) __cputchar(c) 86 87 /* Old-style terminal modes access. */ 88 #define crmode() cbreak() 89 #define nocrmode() nocbreak() 90 #define ospeed baudrate() 91 #endif /* _CURSES_PRIVATE */ 92 93 94 /* symbols for values returned by getch in keypad mode */ 95 #define KEY_MIN 0x101 /* minimum extended key value */ 96 #define KEY_BREAK 0x101 /* break key */ 97 #define KEY_DOWN 0x102 /* down arrow */ 98 #define KEY_UP 0x103 /* up arrow */ 99 #define KEY_LEFT 0x104 /* left arrow */ 100 #define KEY_RIGHT 0x105 /* right arrow*/ 101 #define KEY_HOME 0x106 /* home key */ 102 #define KEY_BACKSPACE 0x107 /* Backspace */ 103 104 /* First function key (block of 64 follow) */ 105 #define KEY_F0 0x108 106 /* Function defining other function key values*/ 107 #define KEY_F(n) (KEY_F0+(n)) 108 109 #define KEY_DL 0x148 /* Delete Line */ 110 #define KEY_IL 0x149 /* Insert Line*/ 111 #define KEY_DC 0x14A /* Delete Character */ 112 #define KEY_IC 0x14B /* Insert Character */ 113 #define KEY_EIC 0x14C /* Exit Insert Char mode */ 114 #define KEY_CLEAR 0x14D /* Clear screen */ 115 #define KEY_EOS 0x14E /* Clear to end of screen */ 116 #define KEY_EOL 0x14F /* Clear to end of line */ 117 #define KEY_SF 0x150 /* Scroll one line forward */ 118 #define KEY_SR 0x151 /* Scroll one line back */ 119 #define KEY_NPAGE 0x152 /* Next Page */ 120 #define KEY_PPAGE 0x153 /* Prev Page */ 121 #define KEY_STAB 0x154 /* Set Tab */ 122 #define KEY_CTAB 0x155 /* Clear Tab */ 123 #define KEY_CATAB 0x156 /* Clear All Tabs */ 124 #define KEY_ENTER 0x157 /* Enter or Send */ 125 #define KEY_SRESET 0x158 /* Soft Reset */ 126 #define KEY_RESET 0x159 /* Hard Reset */ 127 #define KEY_PRINT 0x15A /* Print */ 128 #define KEY_LL 0x15B /* Home Down */ 129 130 /* 131 * "Keypad" keys arranged like this: 132 * 133 * A1 up A3 134 * left B2 right 135 * C1 down C3 136 * 137 */ 138 #define KEY_A1 0x15C /* Keypad upper left */ 139 #define KEY_A3 0x15D /* Keypad upper right */ 140 #define KEY_B2 0x15E /* Keypad centre key */ 141 #define KEY_C1 0x15F /* Keypad lower left */ 142 #define KEY_C3 0x160 /* Keypad lower right */ 143 144 #define KEY_BTAB 0x161 /* Back Tab */ 145 #define KEY_BEG 0x162 /* Begin key */ 146 #define KEY_CANCEL 0x163 /* Cancel key */ 147 #define KEY_CLOSE 0x164 /* Close Key */ 148 #define KEY_COMMAND 0x165 /* Command Key */ 149 #define KEY_COPY 0x166 /* Copy key */ 150 #define KEY_CREATE 0x167 /* Create key */ 151 #define KEY_END 0x168 /* End key */ 152 #define KEY_EXIT 0x169 /* Exit key */ 153 #define KEY_FIND 0x16A /* Find key */ 154 #define KEY_HELP 0x16B /* Help key */ 155 #define KEY_MARK 0x16C /* Mark key */ 156 #define KEY_MESSAGE 0x16D /* Message key */ 157 #define KEY_MOVE 0x16E /* Move key */ 158 #define KEY_NEXT 0x16F /* Next Object key */ 159 #define KEY_OPEN 0x170 /* Open key */ 160 #define KEY_OPTIONS 0x171 /* Options key */ 161 #define KEY_PREVIOUS 0x172 /* Previous Object key */ 162 #define KEY_REDO 0x173 /* Redo key */ 163 #define KEY_REFERENCE 0x174 /* Ref Key */ 164 #define KEY_REFRESH 0x175 /* Refresh key */ 165 #define KEY_REPLACE 0x176 /* Replace key */ 166 #define KEY_RESTART 0x177 /* Restart key */ 167 #define KEY_RESUME 0x178 /* Resume key */ 168 #define KEY_SAVE 0x179 /* Save key */ 169 #define KEY_SBEG 0x17A /* Shift begin key */ 170 #define KEY_SCANCEL 0x17B /* Shift Cancel key */ 171 #define KEY_SCOMMAND 0x17C /* Shift Command key */ 172 #define KEY_SCOPY 0x17D /* Shift Copy key */ 173 #define KEY_SCREATE 0x17E /* Shift Create key */ 174 #define KEY_SDC 0x17F /* Shift Delete Character */ 175 #define KEY_SDL 0x180 /* Shift Delete Line */ 176 #define KEY_SELECT 0x181 /* Select key */ 177 #define KEY_SEND 0x182 /* Send key */ 178 #define KEY_SEOL 0x183 /* Shift Clear Line key */ 179 #define KEY_SEXIT 0x184 /* Shift Exit key */ 180 #define KEY_SFIND 0x185 /* Shift Find key */ 181 #define KEY_SHELP 0x186 /* Shift Help key */ 182 #define KEY_SHOME 0x187 /* Shift Home key */ 183 #define KEY_SIC 0x188 /* Shift Input key */ 184 #define KEY_SLEFT 0x189 /* Shift Left Arrow key */ 185 #define KEY_SMESSAGE 0x18A /* Shift Message key */ 186 #define KEY_SMOVE 0x18B /* Shift Move key */ 187 #define KEY_SNEXT 0x18C /* Shift Next key */ 188 #define KEY_SOPTIONS 0x18D /* Shift Options key */ 189 #define KEY_SPREVIOUS 0x18E /* Shift Previous key */ 190 #define KEY_SPRINT 0x18F /* Shift Print key */ 191 #define KEY_SREDO 0x190 /* Shift Redo key */ 192 #define KEY_SREPLACE 0x191 /* Shift Replace key */ 193 #define KEY_SRIGHT 0x192 /* Shift Right Arrow key */ 194 #define KEY_SRSUME 0x193 /* Shift Resume key */ 195 #define KEY_SSAVE 0x194 /* Shift Save key */ 196 #define KEY_SSUSPEND 0x195 /* Shift Suspend key */ 197 #define KEY_SUNDO 0x196 /* Shift Undo key */ 198 #define KEY_SUSPEND 0x197 /* Suspend key */ 199 #define KEY_UNDO 0x198 /* Undo key */ 200 #define KEY_MOUSE 0x199 /* Mouse event has occurred */ 201 #define KEY_RESIZE 0x200 /* Resize event has occurred */ 202 #define KEY_MAX 0x240 /* maximum extended key value */ 203 #define KEY_CODE_YES 0x241 /* A function key pressed */ 204 205 #include <unctrl.h> 206 207 /* 208 * A window an array of __LINE structures pointed to by the 'lines' pointer. 209 * A line is an array of __LDATA structures pointed to by the 'line' pointer. 210 */ 211 212 /* 213 * Definitions for characters and attributes in __LDATA 214 */ 215 #define __CHARTEXT 0x000000ff /* bits for 8-bit characters */ 216 #define __NORMAL 0x00000000 /* Added characters are normal. */ 217 #define __STANDOUT 0x00000100 /* Added characters are standout. */ 218 #define __UNDERSCORE 0x00000200 /* Added characters are underscored. */ 219 #define __REVERSE 0x00000400 /* Added characters are reverse 220 video. */ 221 #define __BLINK 0x00000800 /* Added characters are blinking. */ 222 #define __DIM 0x00001000 /* Added characters are dim. */ 223 #define __BOLD 0x00002000 /* Added characters are bold. */ 224 #define __BLANK 0x00004000 /* Added characters are blanked. */ 225 #define __PROTECT 0x00008000 /* Added characters are protected. */ 226 #define __ALTCHARSET 0x00010000 /* Added characters are ACS */ 227 #define __COLOR 0x03fe0000 /* Color bits */ 228 #define __ATTRIBUTES 0x03ffff00 /* All 8-bit attribute bits */ 229 230 typedef struct __ldata __LDATA; 231 typedef struct __line __LINE; 232 typedef struct __window WINDOW; 233 typedef struct __screen SCREEN; 234 235 /* 236 * Attribute definitions 237 */ 238 #define A_NORMAL __NORMAL 239 #define A_STANDOUT __STANDOUT 240 #define A_UNDERLINE __UNDERSCORE 241 #define A_REVERSE __REVERSE 242 #define A_BLINK __BLINK 243 #define A_DIM __DIM 244 #define A_BOLD __BOLD 245 #define A_BLANK __BLANK 246 #define A_PROTECT __PROTECT 247 #define A_ALTCHARSET __ALTCHARSET 248 #define A_ATTRIBUTES __ATTRIBUTES 249 #define A_CHARTEXT __CHARTEXT 250 #define A_COLOR __COLOR 251 252 #ifdef HAVE_WCHAR 253 #define WA_ATTRIBUTES 0x03ffffff /* Wide character attributes mask */ 254 #define WA_ALTCHARSET __ALTCHARSET /* Alternate character set */ 255 #define WA_BLINK __BLINK /* Blinking */ 256 #define WA_BOLD __BOLD /* Extra bright or bold */ 257 #define WA_DIM __DIM /* Half bright */ 258 #define WA_PROTECT __PROTECT /* Protected */ 259 #define WA_REVERSE __REVERSE /* Reverse video */ 260 #define WA_STANDOUT __STANDOUT /* Best highlighting mode */ 261 #define WA_UNDERLINE __UNDERSCORE /* Underlining */ 262 #define WA_INVIS 0x00000001 /* Invisible */ 263 #define WA_LOW 0x00000002 /* Low highlight */ 264 #define WA_TOP 0x00000004 /* Top highlight */ 265 #define WA_HORIZONTAL 0x00000008 /* Horizontal highlight */ 266 #define WA_VERTICAL 0x00000010 /* Vertical highlight */ 267 #define WA_LEFT 0x00000020 /* Left highlight */ 268 #define WA_RIGHT 0x00000040 /* Right highlight */ 269 #endif /* HAVE_WCHAR */ 270 271 /* 272 * Alternate character set definitions 273 */ 274 275 #define NUM_ACS 128 276 277 extern chtype _acs_char[NUM_ACS]; 278 #ifdef __cplusplus 279 #define __UC_CAST(a) static_cast<unsigned char>(a) 280 #else 281 #define __UC_CAST(a) (unsigned char)(a) 282 #endif 283 284 /* Standard definitions */ 285 #define ACS_RARROW _acs_char[__UC_CAST('+')] 286 #define ACS_LARROW _acs_char[__UC_CAST(',')] 287 #define ACS_UARROW _acs_char[__UC_CAST('-')] 288 #define ACS_DARROW _acs_char[__UC_CAST('.')] 289 #define ACS_BLOCK _acs_char[__UC_CAST('0')] 290 #define ACS_DIAMOND _acs_char[__UC_CAST('`')] 291 #define ACS_CKBOARD _acs_char[__UC_CAST('a')] 292 #define ACS_DEGREE _acs_char[__UC_CAST('f')] 293 #define ACS_PLMINUS _acs_char[__UC_CAST('g')] 294 #define ACS_BOARD _acs_char[__UC_CAST('h')] 295 #define ACS_LANTERN _acs_char[__UC_CAST('i')] 296 #define ACS_LRCORNER _acs_char[__UC_CAST('j')] 297 #define ACS_URCORNER _acs_char[__UC_CAST('k')] 298 #define ACS_ULCORNER _acs_char[__UC_CAST('l')] 299 #define ACS_LLCORNER _acs_char[__UC_CAST('m')] 300 #define ACS_PLUS _acs_char[__UC_CAST('n')] 301 #define ACS_HLINE _acs_char[__UC_CAST('q')] 302 #define ACS_S1 _acs_char[__UC_CAST('o')] 303 #define ACS_S9 _acs_char[__UC_CAST('s')] 304 #define ACS_LTEE _acs_char[__UC_CAST('t')] 305 #define ACS_RTEE _acs_char[__UC_CAST('u')] 306 #define ACS_BTEE _acs_char[__UC_CAST('v')] 307 #define ACS_TTEE _acs_char[__UC_CAST('w')] 308 #define ACS_VLINE _acs_char[__UC_CAST('x')] 309 #define ACS_BULLET _acs_char[__UC_CAST('~')] 310 311 /* Extensions */ 312 #define ACS_S3 _acs_char[__UC_CAST('p')] 313 #define ACS_S7 _acs_char[__UC_CAST('r')] 314 #define ACS_LEQUAL _acs_char[__UC_CAST('y')] 315 #define ACS_GEQUAL _acs_char[__UC_CAST('z')] 316 #define ACS_PI _acs_char[__UC_CAST('{')] 317 #define ACS_NEQUAL _acs_char[__UC_CAST('|')] 318 #define ACS_STERLING _acs_char[__UC_CAST('}')] 319 320 #ifdef HAVE_WCHAR 321 extern cchar_t _wacs_char[NUM_ACS]; 322 323 #define WACS_RARROW _wacs_char[(unsigned char)'+'].vals[0] 324 #define WACS_LARROW _wacs_char[(unsigned char)','].vals[0] 325 #define WACS_UARROW _wacs_char[(unsigned char)'-'].vals[0] 326 #define WACS_DARROW _wacs_char[(unsigned char)'.'].vals[0] 327 #define WACS_BLOCK _wacs_char[(unsigned char)'0'].vals[0] 328 #define WACS_DIAMOND _wacs_char[(unsigned char)'`'].vals[0] 329 #define WACS_CKBOARD _wacs_char[(unsigned char)'a'].vals[0] 330 #define WACS_DEGREE _wacs_char[(unsigned char)'f'].vals[0] 331 #define WACS_PLMINUS _wacs_char[(unsigned char)'g'].vals[0] 332 #define WACS_BOARD _wacs_char[(unsigned char)'h'].vals[0] 333 #define WACS_LANTERN _wacs_char[(unsigned char)'i'].vals[0] 334 #define WACS_LRCORNER _wacs_char[(unsigned char)'j'].vals[0] 335 #define WACS_URCORNER _wacs_char[(unsigned char)'k'].vals[0] 336 #define WACS_ULCORNER _wacs_char[(unsigned char)'l'].vals[0] 337 #define WACS_LLCORNER _wacs_char[(unsigned char)'m'].vals[0] 338 #define WACS_PLUS _wacs_char[(unsigned char)'n'].vals[0] 339 #define WACS_HLINE _wacs_char[(unsigned char)'q'].vals[0] 340 #define WACS_S1 _wacs_char[(unsigned char)'o'].vals[0] 341 #define WACS_S9 _wacs_char[(unsigned char)'s'].vals[0] 342 #define WACS_LTEE _wacs_char[(unsigned char)'t'].vals[0] 343 #define WACS_RTEE _wacs_char[(unsigned char)'u'].vals[0] 344 #define WACS_BTEE _wacs_char[(unsigned char)'v'].vals[0] 345 #define WACS_TTEE _wacs_char[(unsigned char)'w'].vals[0] 346 #define WACS_VLINE _wacs_char[(unsigned char)'x'].vals[0] 347 #define WACS_BULLET _wacs_char[(unsigned char)'~'].vals[0] 348 #define WACS_S3 _wacs_char[(unsigned char)'p'].vals[0] 349 #define WACS_S7 _wacs_char[(unsigned char)'r'].vals[0] 350 #define WACS_LEQUAL _wacs_char[(unsigned char)'y'].vals[0] 351 #define WACS_GEQUAL _wacs_char[(unsigned char)'z'].vals[0] 352 #define WACS_PI _wacs_char[(unsigned char)'{'].vals[0] 353 #define WACS_NEQUAL _wacs_char[(unsigned char)'|'].vals[0] 354 #define WACS_STERLING _wacs_char[(unsigned char)'}'].vals[0] 355 #endif /* HAVE_WCHAR */ 356 357 /* System V compatibility */ 358 #define ACS_SBBS ACS_LRCORNER 359 #define ACS_BBSS ACS_URCORNER 360 #define ACS_BSSB ACS_ULCORNER 361 #define ACS_SSBB ACS_LLCORNER 362 #define ACS_SSSS ACS_PLUS 363 #define ACS_BSBS ACS_HLINE 364 #define ACS_SSSB ACS_LTEE 365 #define ACS_SBSS ACS_RTEE 366 #define ACS_SSBS ACS_BTEE 367 #define ACS_BSSS ACS_TTEE 368 #define ACS_SBSB ACS_VLINE 369 #define _acs_map _acs_char 370 371 /* 372 * Color definitions (ANSI color numbers) 373 */ 374 375 #define COLOR_BLACK 0x00 376 #define COLOR_RED 0x01 377 #define COLOR_GREEN 0x02 378 #define COLOR_YELLOW 0x03 379 #define COLOR_BLUE 0x04 380 #define COLOR_MAGENTA 0x05 381 #define COLOR_CYAN 0x06 382 #define COLOR_WHITE 0x07 383 384 #ifdef __cplusplus 385 #define __UINT32_CAST(a) static_cast<u_int32_t>(a) 386 #else 387 #define __UINT32_CAST(a) (u_int32_t)(a) 388 #endif 389 #define COLOR_PAIR(n) (((__UINT32_CAST(n)) << 17) & A_COLOR) 390 #define PAIR_NUMBER(n) (((__UINT32_CAST(n)) & A_COLOR) >> 17) 391 392 /* Curses external declarations. */ 393 extern WINDOW *curscr; /* Current screen. */ 394 extern WINDOW *stdscr; /* Standard screen. */ 395 396 extern int __tcaction; /* If terminal hardware set. */ 397 398 extern int COLS; /* Columns on the screen. */ 399 extern int LINES; /* Lines on the screen. */ 400 extern int COLORS; /* Max colors on the screen. */ 401 extern int COLOR_PAIRS; /* Max color pairs on the screen. */ 402 403 extern int ESCDELAY; /* Delay between keys in esc seq's. */ 404 405 #define ERR (-1) /* Error return. */ 406 #define OK (0) /* Success return. */ 407 408 /* 409 * The following have, traditionally, been macros but X/Open say they 410 * need to be functions. Keep the old macros for debugging. 411 */ 412 #ifdef _CURSES_USE_MACROS 413 /* Standard screen pseudo functions. */ 414 #define addbytes(s, n) __waddbytes(stdscr, s, n, 0) 415 #define addch(ch) waddch(stdscr, ch) 416 #define addchnstr(s) waddchnstr(stdscr, s, n) 417 #define addchstr(s) waddchnstr(stdscr, s, -1) 418 #define addnstr(s, n) waddnstr(stdscr, s, n) 419 #define addstr(s) waddnstr(stdscr, s, -1) 420 #define attr_get(a, p, o) wattr_get(stdscr, a, p, o) 421 #define attr_off(a, o) wattr_off(stdscr, a, o) 422 #define attr_on(a, o) wattr_on(stdscr, a, o) 423 #define attr_set(a, p, o) wattr_set(stdscr, a, p, o) 424 #define attroff(attr) wattroff(stdscr, attr) 425 #define attron(attr) wattron(stdscr, attr) 426 #define attrset(attr) wattrset(stdscr, attr) 427 #define bkgd(ch) wbkgd(stdscr, ch) 428 #define bkgdset(ch) wbkgdset(stdscr, ch) 429 #define border(l, r, t, b, tl, tr, bl, br) \ 430 wborder(stdscr, l, r, t, b, tl, tr, bl, br) 431 #define clear() wclear(stdscr) 432 #define clrtobot() wclrtobot(stdscr) 433 #define clrtoeol() wclrtoeol(stdscr) 434 #define color_set(c, o) wcolor_set(stdscr, c, o) 435 #define delch() wdelch(stdscr) 436 #define deleteln() wdeleteln(stdscr) 437 #define echochar(c) wechochar(stdscr, c) 438 #define erase() werase(stdscr) 439 #define getch() wgetch(stdscr) 440 #define getnstr(s, n) wgetnstr(stdscr, s, n) 441 #define getstr(s) wgetstr(stdscr, s) 442 #define inch() winch(stdscr) 443 #define inchnstr(c) winchnstr(stdscr, c) 444 #define inchstr(c) winchstr(stdscr, c) 445 #define innstr(s, n) winnstr(stdscr, s, n) 446 #define insch(ch) winsch(stdscr, ch) 447 #define insdelln(n) winsdelln(stdscr, n) 448 #define insertln() winsertln(stdscr) 449 #define instr(s) winstr(stdscr, s) 450 #define move(y, x) wmove(stdscr, y, x) 451 #define refresh() wrefresh(stdscr) 452 #define scrl(n) wscrl(stdscr, n) 453 #define setscrreg(t, b) wsetscrreg(stdscr, t, b) 454 #define standend() wstandend(stdscr) 455 #define standout() wstandout(stdscr) 456 #define timeout(delay) wtimeout(stdscr, delay) 457 #define underscore() wunderscore(stdscr) 458 #define underend() wunderend(stdscr) 459 #define waddbytes(w, s, n) __waddbytes(w, s, n, 0) 460 #define waddstr(w, s) waddnstr(w, s, -1) 461 462 /* Standard screen plus movement pseudo functions. */ 463 #define mvaddbytes(y, x, s, n) mvwaddbytes(stdscr, y, x, s, n) 464 #define mvaddch(y, x, ch) mvwaddch(stdscr, y, x, ch) 465 #define mvaddchnstr(y, x, s, n) mvwaddchnstr(stdscr, y, x, s, n) 466 #define mvaddchstr(y, x, s) mvwaddchstr(stdscr, y, x, s) 467 #define mvaddnstr(y, x, s, n) mvwaddnstr(stdscr, y, x, s, n) 468 #define mvaddstr(y, x, s) mvwaddstr(stdscr, y, x, s) 469 #define mvdelch(y, x) mvwdelch(stdscr, y, x) 470 #define mvgetch(y, x) mvwgetch(stdscr, y, x) 471 #define mvgetnstr(y, x, s) mvwgetnstr(stdscr, y, x, s, n) 472 #define mvgetstr(y, x, s) mvwgetstr(stdscr, y, x, s) 473 #define mvinch(y, x) mvwinch(stdscr, y, x) 474 #define mvinchnstr(y, x, c, n) mvwinchnstr(stdscr, y, x, c, n) 475 #define mvinchstr(y, x, c) mvwinchstr(stdscr, y, x, c) 476 #define mvinnstr(y, x, s, n) mvwinnstr(stdscr, y, x, s, n) 477 #define mvinsch(y, x, c) mvwinsch(stdscr, y, x, c) 478 #define mvinstr(y, x, s) mvwinstr(stdscr, y, x, s) 479 #define mvwaddbytes(w, y, x, s, n) \ 480 (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, n, 0)) 481 #define mvwaddch(w, y, x, ch) \ 482 (wmove(w, y, x) == ERR ? ERR : waddch(w, ch)) 483 #define mvwaddchnstr(w, y, x, s, n) \ 484 (wmove(w, y, x) == ERR ? ERR : waddchnstr(w, s, n)) 485 #define mvwaddchstr(w, y, x, s) \ 486 (wmove(w, y, x) == ERR ? ERR : waddchnstr(w, s, -1)) 487 #define mvwaddnstr(w, y, x, s, n) \ 488 (wmove(w, y, x) == ERR ? ERR : waddnstr(w, s, n)) 489 #define mvwaddstr(w, y, x, s) \ 490 (wmove(w, y, x) == ERR ? ERR : waddnstr(w, s, -1)) 491 #define mvwdelch(w, y, x) \ 492 (wmove(w, y, x) == ERR ? ERR : wdelch(w)) 493 #define mvwgetch(w, y, x) \ 494 (wmove(w, y, x) == ERR ? ERR : wgetch(w)) 495 #define mvwgetnstr(w, y, x, s, n) \ 496 (wmove(w, y, x) == ERR ? ERR : wgetnstr(w, s, n)) 497 #define mvwgetstr(w, y, x, s) \ 498 (wmove(w, y, x) == ERR ? ERR : wgetstr(w, s)) 499 #define mvwinch(w, y, x) \ 500 (wmove(w, y, x) == ERR ? ERR : winch(w)) 501 #define mvwinchnstr(w, y, x, c, n) \ 502 (wmove(w, y, x) == ERR ? ERR : winchnstr(w, c, n)) 503 #define mvwinchstr(w, y, x, s) \ 504 (wmove(w, y, x) == ERR ? ERR : winchstr(w, c)) 505 #define mvwinnstr(w, y, x, s, n) \ 506 (wmove(w, y, x) == ERR ? ERR : winnstr(w, s, n)) 507 #define mvwinsch(w, y, x, c) \ 508 (wmove(w, y, x) == ERR ? ERR : winsch(w, c)) 509 #define mvwinstr(w, y, x, s) \ 510 (wmove(w, y, x) == ERR ? ERR : winstr(w, s)) 511 512 /* Miscellaneous. */ 513 #define noqiflush() intrflush(stdscr, FALSE) 514 #define qiflush() intrflush(stdscr, TRUE) 515 516 #else 517 /* Use functions not macros... */ 518 __BEGIN_DECLS 519 int addbytes(const char *, int); 520 int addch(chtype); 521 int addchnstr(const chtype *, int); 522 int addchstr(const chtype *); 523 int addnstr(const char *, int); 524 int addstr(const char *); 525 int attr_get(attr_t *, short *, void *); 526 int attr_off(attr_t, void *); 527 int attr_on(attr_t, void *); 528 int attr_set(attr_t, short, void *); 529 int attroff(int); 530 int attron(int); 531 int attrset(int); 532 int bkgd(chtype); 533 void bkgdset(chtype); 534 int border(chtype, chtype, chtype, chtype, 535 chtype, chtype, chtype, chtype); 536 int clear(void); 537 int clrtobot(void); 538 int clrtoeol(void); 539 int color_set(short, void *); 540 int delch(void); 541 int deleteln(void); 542 int echochar(const chtype); 543 int erase(void); 544 int getch(void); 545 int getnstr(char *, int); 546 int getstr(char *); 547 chtype inch(void); 548 int inchnstr(chtype *, int); 549 int inchstr(chtype *); 550 int innstr(char *, int); 551 int insch(chtype); 552 int insdelln(int); 553 int insertln(void); 554 int instr(char *); 555 int move(int, int); 556 int refresh(void); 557 int scrl(int); 558 int setscrreg(int, int); 559 int standend(void); 560 int standout(void); 561 void timeout(int); 562 int underscore(void); 563 int underend(void); 564 int waddbytes(WINDOW *, const char *, int); 565 int waddstr(WINDOW *, const char *); 566 567 /* Standard screen plus movement functions. */ 568 int mvaddbytes(int, int, const char *, int); 569 int mvaddch(int, int, chtype); 570 int mvaddchnstr(int, int, const chtype *, int); 571 int mvaddchstr(int, int, const chtype *); 572 int mvaddnstr(int, int, const char *, int); 573 int mvaddstr(int, int, const char *); 574 int mvdelch(int, int); 575 int mvgetch(int, int); 576 int mvgetnstr(int, int, char *, int); 577 int mvgetstr(int, int, char *); 578 chtype mvinch(int, int); 579 int mvinchnstr(int, int, chtype *, int); 580 int mvinchstr(int, int, chtype *); 581 int mvinnstr(int, int, char *, int); 582 int mvinsch(int, int, chtype); 583 int mvinstr(int, int, char *); 584 585 int mvwaddbytes(WINDOW *, int, int, const char *, int); 586 int mvwaddch(WINDOW *, int, int, chtype); 587 int mvwaddchnstr(WINDOW *, int, int, const chtype *, int); 588 int mvwaddchstr(WINDOW *, int, int, const chtype *); 589 int mvwaddnstr(WINDOW *, int, int, const char *, int); 590 int mvwaddstr(WINDOW *, int, int, const char *); 591 int mvwdelch(WINDOW *, int, int); 592 int mvwgetch(WINDOW *, int, int); 593 int mvwgetnstr(WINDOW *, int, int, char *, int); 594 int mvwgetstr(WINDOW *, int, int, char *); 595 chtype mvwinch(WINDOW *, int, int); 596 int mvwinsch(WINDOW *, int, int, chtype); 597 __END_DECLS 598 #endif /* _CURSES_USE_MACROS */ 599 600 #define getyx(w, y, x) (y) = getcury(w), (x) = getcurx(w) 601 #define getbegyx(w, y, x) (y) = getbegy(w), (x) = getbegx(w) 602 #define getmaxyx(w, y, x) (y) = getmaxy(w), (x) = getmaxx(w) 603 #define getparyx(w, y, x) (y) = getpary(w), (x) = getparx(w) 604 605 /* Public function prototypes. */ 606 __BEGIN_DECLS 607 int assume_default_colors(short, short); 608 int baudrate(void); 609 int beep(void); 610 int box(WINDOW *, chtype, chtype); 611 bool can_change_color(void); 612 int cbreak(void); 613 int clearok(WINDOW *, bool); 614 int color_content(short, short *, short *, short *); 615 int copywin(const WINDOW *, WINDOW *, int, int, int, int, int, int, int); 616 int curs_set(int); 617 int def_prog_mode(void); 618 int def_shell_mode(void); 619 int define_key(char *, int); 620 int delay_output(int); 621 void delscreen(SCREEN *); 622 int delwin(WINDOW *); 623 WINDOW *derwin(WINDOW *, int, int, int, int); 624 WINDOW *dupwin(WINDOW *); 625 int doupdate(void); 626 int echo(void); 627 int endwin(void); 628 char erasechar(void); 629 int flash(void); 630 int flushinp(void); 631 int flushok(WINDOW *, bool); 632 char *fullname(const char *, char *); 633 chtype getattrs(WINDOW *); 634 chtype getbkgd(WINDOW *); 635 char *getcap(char *); 636 int getcury(WINDOW *); 637 int getcurx(WINDOW *); 638 int getbegy(WINDOW *); 639 int getbegx(WINDOW *); 640 int getmaxy(WINDOW *); 641 int getmaxx(WINDOW *); 642 int getpary(WINDOW *); 643 int getparx(WINDOW *); 644 int gettmode(void); 645 int halfdelay(int); 646 bool has_colors(void); 647 bool has_ic(void); 648 bool has_il(void); 649 int hline(chtype, int); 650 int idcok(WINDOW *, bool); 651 int idlok(WINDOW *, bool); 652 int init_color(short, short, short, short); 653 int init_pair(short, short, short); 654 WINDOW *initscr(void); 655 int intrflush(WINDOW *, bool); 656 bool isendwin(void); 657 bool is_linetouched(WINDOW *, int); 658 bool is_wintouched(WINDOW *); 659 int keyok(int, bool); 660 void keypad(WINDOW *, bool); 661 char *keyname(int); 662 char killchar(void); 663 int leaveok(WINDOW *, bool); 664 char *longname(void); 665 int meta(WINDOW *, bool); 666 int mvcur(int, int, int, int); 667 int mvderwin(WINDOW *, int, int); 668 int mvhline(int, int, chtype, int); 669 int mvprintw(int, int, const char *, ...) 670 __attribute__((__format__(__printf__, 3, 4))); 671 int mvscanw(int, int, const char *, ...) 672 __attribute__((__format__(__scanf__, 3, 4))); 673 int mvvline(int, int, chtype, int); 674 int mvwhline(WINDOW *, int, int, chtype, int); 675 int mvwvline(WINDOW *, int, int, chtype, int); 676 int mvwin(WINDOW *, int, int); 677 int mvwinchnstr(WINDOW *, int, int, chtype *, int); 678 int mvwinchstr(WINDOW *, int, int, chtype *); 679 int mvwinnstr(WINDOW *, int, int, char *, int); 680 int mvwinstr(WINDOW *, int, int, char *); 681 int mvwprintw(WINDOW *, int, int, const char *, ...) 682 __attribute__((__format__(__printf__, 4, 5))); 683 int mvwscanw(WINDOW *, int, int, const char *, ...) 684 __attribute__((__format__(__scanf__, 4, 5))); 685 int napms(int); 686 WINDOW *newpad(int, int); 687 SCREEN *newterm(char *, FILE *, FILE *); 688 WINDOW *newwin(int, int, int, int); 689 int nl(void); 690 attr_t no_color_video(void); 691 int nocbreak(void); 692 int nodelay(WINDOW *, bool); 693 int noecho(void); 694 int nonl(void); 695 void noqiflush(void); 696 int noraw(void); 697 int notimeout(WINDOW *, bool); 698 int overlay(const WINDOW *, WINDOW *); 699 int overwrite(const WINDOW *, WINDOW *); 700 int pair_content(short, short *, short *); 701 int pechochar(WINDOW *, const chtype); 702 int pnoutrefresh(WINDOW *, int, int, int, int, int, int); 703 int prefresh(WINDOW *, int, int, int, int, int, int); 704 int printw(const char *, ...) 705 __attribute__((__format__(__printf__, 1, 2))); 706 void qiflush(void); 707 int raw(void); 708 int redrawwin(WINDOW *); 709 int reset_prog_mode(void); 710 int reset_shell_mode(void); 711 int resetty(void); 712 int resizeterm(int, int); 713 int savetty(void); 714 int scanw(const char *, ...) 715 __attribute__((__format__(__scanf__, 1, 2))); 716 int scroll(WINDOW *); 717 int scrollok(WINDOW *, bool); 718 int setterm(char *); 719 SCREEN *set_term(SCREEN *); 720 int start_color(void); 721 WINDOW *subpad(WINDOW *, int, int, int, int); 722 WINDOW *subwin(WINDOW *, int, int, int, int); 723 int touchline(WINDOW *, int, int); 724 int touchoverlap(WINDOW *, WINDOW *); 725 int touchwin(WINDOW *); 726 int ungetch(int); 727 int untouchwin(WINDOW *); 728 int use_default_colors(void); 729 int vline(chtype, int); 730 int vwprintw(WINDOW *, const char *, _BSD_VA_LIST_) 731 __attribute__((__format__(__printf__, 2, 0))); 732 int vwscanw(WINDOW *, const char *, _BSD_VA_LIST_) 733 __attribute__((__format__(__scanf__, 2, 0))); 734 int waddch(WINDOW *, chtype); 735 int waddchnstr(WINDOW *, const chtype *, int); 736 int waddchstr(WINDOW *, const chtype *); 737 int waddnstr(WINDOW *, const char *, int); 738 int wattr_get(WINDOW *, attr_t *, short *, void *); 739 int wattr_off(WINDOW *, attr_t, void *); 740 int wattr_on(WINDOW *, attr_t, void *); 741 int wattr_set(WINDOW *, attr_t, short, void *); 742 int wattroff(WINDOW *, int); 743 int wattron(WINDOW *, int); 744 int wattrset(WINDOW *, int); 745 int wbkgd(WINDOW *, chtype); 746 void wbkgdset(WINDOW *, chtype); 747 int wborder(WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype, 748 chtype, chtype); 749 int wclear(WINDOW *); 750 int wclrtobot(WINDOW *); 751 int wclrtoeol(WINDOW *); 752 int wcolor_set(WINDOW *, short, void *); 753 int wdelch(WINDOW *); 754 int wdeleteln(WINDOW *); 755 int wechochar(WINDOW *, const chtype); 756 int werase(WINDOW *); 757 int wgetch(WINDOW *); 758 int wgetnstr(WINDOW *, char *, int); 759 int wgetstr(WINDOW *, char *); 760 int whline(WINDOW *, chtype, int); 761 chtype winch(WINDOW *); 762 int winchnstr(WINDOW *, chtype *, int); 763 int winchstr(WINDOW *, chtype *); 764 int winnstr(WINDOW *, char *, int); 765 int winsch(WINDOW *, chtype); 766 int winsdelln(WINDOW *, int); 767 int winsertln(WINDOW *); 768 int winstr(WINDOW *, char *); 769 int wmove(WINDOW *, int, int); 770 int wnoutrefresh(WINDOW *); 771 int wprintw(WINDOW *, const char *, ...) 772 __attribute__((__format__(__printf__, 2, 3))); 773 int wredrawln(WINDOW *, int, int); 774 int wrefresh(WINDOW *); 775 int wresize(WINDOW *, int, int); 776 int wscanw(WINDOW *, const char *, ...) 777 __attribute__((__format__(__scanf__, 2, 3))); 778 int wscrl(WINDOW *, int); 779 int wsetscrreg(WINDOW *, int, int); 780 int wstandend(WINDOW *); 781 int wstandout(WINDOW *); 782 void wtimeout(WINDOW *, int); 783 int wtouchln(WINDOW *, int, int, int); 784 int wunderend(WINDOW *); 785 int wunderscore(WINDOW *); 786 int wvline(WINDOW *, chtype, int); 787 788 int insnstr(const char *, int); 789 int insstr(const char *); 790 int mvinsnstr(int, int, const char *, int); 791 int mvinsstr(int, int, const char *); 792 int mvwinsnstr(WINDOW *, int, int, const char *, int); 793 int mvwinsstr(WINDOW *, int, int, const char *); 794 int winsnstr(WINDOW *, const char *, int); 795 int winsstr(WINDOW *, const char *); 796 797 /* wide character support routines */ 798 /* return ERR when HAVE_WCHAR is not defined */ 799 /* add */ 800 int add_wch(const cchar_t *); 801 int wadd_wch(WINDOW *, const cchar_t *); 802 int mvadd_wch(int, int, const cchar_t *); 803 int mvwadd_wch(WINDOW *, int, int, const cchar_t *); 804 805 int add_wchnstr(const cchar_t *, int); 806 int add_wchstr(const cchar_t *); 807 int wadd_wchnstr(WINDOW *, const cchar_t *, int); 808 int wadd_wchstr(WINDOW *, const cchar_t *); 809 int mvadd_wchnstr(int, int, const cchar_t *, int); 810 int mvadd_wchstr(int, int, const cchar_t *); 811 int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int); 812 int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *); 813 814 int addnwstr(const wchar_t *, int); 815 int addwstr(const wchar_t *); 816 int mvaddnwstr(int, int x, const wchar_t *, int); 817 int mvaddwstr(int, int x, const wchar_t *); 818 int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int); 819 int mvwaddwstr(WINDOW *, int, int, const wchar_t *); 820 int waddnwstr(WINDOW *, const wchar_t *, int); 821 int waddwstr(WINDOW *, const wchar_t *); 822 823 int echo_wchar(const cchar_t *); 824 int wecho_wchar(WINDOW *, const cchar_t *); 825 int pecho_wchar(WINDOW *, const cchar_t *); 826 827 /* insert */ 828 int ins_wch(const cchar_t *); 829 int wins_wch(WINDOW *, const cchar_t *); 830 int mvins_wch(int, int, const cchar_t *); 831 int mvwins_wch(WINDOW *, int, int, const cchar_t *); 832 833 int ins_nwstr(const wchar_t *, int); 834 int ins_wstr(const wchar_t *); 835 int mvins_nwstr(int, int, const wchar_t *, int); 836 int mvins_wstr(int, int, const wchar_t *); 837 int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int); 838 int mvwins_wstr(WINDOW *, int, int, const wchar_t *); 839 int wins_nwstr(WINDOW *, const wchar_t *, int); 840 int wins_wstr(WINDOW *, const wchar_t *); 841 842 /* input */ 843 int get_wch(wint_t *); 844 int unget_wch(const wchar_t); 845 int mvget_wch(int, int, wint_t *); 846 int mvwget_wch(WINDOW *, int, int, wint_t *); 847 int wget_wch(WINDOW *, wint_t *); 848 849 int getn_wstr(wchar_t *, int); 850 int get_wstr(wchar_t *); 851 int mvgetn_wstr(int, int, wchar_t *, int); 852 int mvget_wstr(int, int, wchar_t *); 853 int mvwgetn_wstr(WINDOW *, int, int, wchar_t *, int); 854 int mvwget_wstr(WINDOW *, int, int, wchar_t *); 855 int wgetn_wstr(WINDOW *, wchar_t *, int); 856 int wget_wstr(WINDOW *, wchar_t *); 857 858 int in_wch(cchar_t *); 859 int mvin_wch(int, int, cchar_t *); 860 int mvwin_wch(WINDOW *, int, int, cchar_t *); 861 int win_wch(WINDOW *, cchar_t *); 862 863 int in_wchnstr(cchar_t *, int); 864 int in_wchstr(cchar_t *); 865 int mvin_wchnstr(int, int, cchar_t *, int); 866 int mvin_wchstr(int, int, cchar_t *); 867 int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int); 868 int mvwin_wchstr(WINDOW *, int, int, cchar_t *); 869 int win_wchnstr(WINDOW *, cchar_t *, int); 870 int win_wchstr(WINDOW *, cchar_t *); 871 872 int innwstr(wchar_t *, int); 873 int inwstr(wchar_t *); 874 int mvinnwstr(int, int, wchar_t *, int); 875 int mvinwstr(int, int, wchar_t *); 876 int mvwinnwstr(WINDOW *, int, int, wchar_t *, int); 877 int mvwinwstr(WINDOW *, int, int, wchar_t *); 878 int winnwstr(WINDOW *, wchar_t *, int); 879 int winwstr(WINDOW *, wchar_t *); 880 881 /* cchar handlgin */ 882 int setcchar(cchar_t *, const wchar_t *, const attr_t, short, const void *); 883 int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *); 884 885 /* misc */ 886 char *key_name( wchar_t ); 887 int border_set(const cchar_t *, const cchar_t *, const cchar_t *, 888 const cchar_t *, const cchar_t *, const cchar_t *, 889 const cchar_t *, const cchar_t *); 890 int wborder_set(WINDOW *, const cchar_t *, const cchar_t *, 891 const cchar_t *, const cchar_t *, const cchar_t *, 892 const cchar_t *, const cchar_t *, const cchar_t *); 893 int box_set(WINDOW *, const cchar_t *, const cchar_t *); 894 int erasewchar(wchar_t *); 895 int killwchar(wchar_t *); 896 int hline_set(const cchar_t *, int); 897 int mvhline_set(int, int, const cchar_t *, int); 898 int mvvline_set(int, int, const cchar_t *, int); 899 int mvwhline_set(WINDOW *, int, int, const cchar_t *, int); 900 int mvwvline_set(WINDOW *, int, int, const cchar_t *, int); 901 int vline_set(const cchar_t *, int); 902 int whline_set(WINDOW *, const cchar_t *, int); 903 int wvline_set(WINDOW *, const cchar_t *, int); 904 int bkgrnd(const cchar_t *); 905 void bkgrndset(const cchar_t *); 906 int getbkgrnd(cchar_t *); 907 int wbkgrnd(WINDOW *, const cchar_t *); 908 void wbkgrndset(WINDOW *, const cchar_t *); 909 int wgetbkgrnd(WINDOW *, cchar_t *); 910 911 /* Private functions that are needed for user programs prototypes. */ 912 int __cputchar(int); 913 int __waddbytes(WINDOW *, const char *, int, attr_t); 914 #ifdef HAVE_WCHAR 915 int __cputwchar( wchar_t ); 916 #endif /* HAVE_WCHAR */ 917 __END_DECLS 918 919 #endif /* !_CURSES_H_ */ 920