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