1 /****************************************************************************** 2 * 3 * NSSDC/CDF Header file for `windows'. 4 * 5 * Version 4.0, 14-Nov-97, Hughes STX. 6 * 7 * Modification history 8 * 9 * V1.0 29-Jan-91, H Leckner Original vesion (for CDF V2.0). 10 * V1.1 1-Oct-91, J Love Modified for IRIX 4.0 port. 11 * V1.2 15-Oct-91, H Leckner Changed for IBM-RS6000 (AIX) port 12 * V2.0 30-Apr-92, H Leckner IBM PC port. CDF V2.2. 13 * V3.0 30-Nov-93, J Love CDF V2.4. Generalized for all platforms. 14 * Included `kb_def.h'. 15 * V3.0a 6-Apr-94, J Love Solaris using Gnu C compiler. 16 * V3.1 25-Oct-94, J Love CDF V2.5. 17 * V3.1a 23-Jan-95, J Love IRIX 6.x (64-bit). 18 * V3.1b 16-Mar-95, J Love `EncodeKeyDefinitions' prototype moved here. 19 * V3.2 6-Apr-95, J Love POSIX. 20 * V3.2a 18-Apr-95, J Love More POSIX. 21 * V3.2b 13-Jun-95, J Love Linux. 22 * V3.3 15-Jun-95, J Love `key_waiting'. 23 * V3.3a 31-Aug-95, J Love CDFexport-related changes. 24 * V3.3b 18-Sep-95, J Love Macintosh event handling. 25 * V3.4 3-Oct-96, J Love CDF V2.6. 26 * V3.4a 2-Sep-97, J Love Special keys for AIX. 27 * V4.0 14-Nov-97, J Love Windows NT/Visual C++. 28 * V4.1 2-May-01, M Liu Special keys for CYGWIN. 29 * V4.2 11-Jul-05, M Liu Added MingW port for PC. 30 * 31 ******************************************************************************/ 32 33 #if !defined(WINDOZh_INCLUDEd__) 34 #define WINDOZh_INCLUDEd__ 35 36 /****************************************************************************** 37 * Include files. 38 ******************************************************************************/ 39 40 #include "cdftools.h" 41 42 /****************************************************************************** 43 * Which type of screen management is being used? 44 ******************************************************************************/ 45 46 #if defined(vms) 47 # define SMGui 48 #endif 49 50 #if defined(unix) || defined(dos) || defined(posixSHELL) 51 # define CURSESui 52 #endif 53 54 #if defined(mac) || defined(win32) 55 # define COWui /* Curses On Windows... */ 56 #endif 57 58 /****************************************************************************** 59 * Include files. Because some `curses.h' files define TRUE and FALSE without 60 * first checking to see if they are already defined and because some compilers 61 * complain when that happens, we will save those definitions, undefine them, 62 * include `curses.h', and then restore the definitions if `curses.h' did not 63 * define them. 64 ******************************************************************************/ 65 66 67 #if defined(CURSESui) 68 # define TRUEx TRUE 69 # undef TRUE 70 # define FALSEx FALSE 71 # undef FALSE 72 # if defined(ultrix) 73 # include <cursesX.h> 74 # else 75 # if defined(linux) || defined(__QNX__) 76 # include <ncurses.h> 77 # else 78 # include <curses.h> 79 # endif 80 # endif 81 # if !defined(TRUE) 82 # define TRUE TRUEx 83 # endif 84 # if !defined(FALSE) 85 # define FALSE FALSEx 86 # endif 87 #endif 88 89 #if defined(SMGui) 90 # include <smg$routines.h> 91 #endif 92 93 /****************************************************************************** 94 * `typedef's. 95 ******************************************************************************/ 96 97 #if defined(dos) 98 typedef int chtype; 99 #endif 100 101 /****************************************************************************** 102 * Windows NT. 103 ******************************************************************************/ 104 105 #define NUMfsiROWS 24 106 #define NUMfsiCOLS 80 107 108 /****************************************************************************** 109 * For some reason the `curses.h' file on some Solaris 2.2 machines does not 110 * seem to know that it is a System V implementation. For that reason, `strchr' 111 * and `strrchr' are defined to `index' and `rindex', respectively (for what 112 * the maintainers of Curses say are portability reasons). This is bad since 113 * `index' and `rindex' do not exist in the C run-time library on them there 114 * machines. To be safe, we'll undefine `strchr' and `strrchr' everywhere since 115 * we always want to reference those names. 116 ******************************************************************************/ 117 118 #if defined(strchr) 119 # undef strchr 120 #endif 121 122 #if defined(strrchr) 123 # undef strrchr 124 #endif 125 126 /****************************************************************************** 127 * Curses function availability/reliability. 128 * 1. `werase' doesn't seem to work on Ultrix, OSF/1, and AIX. 129 * 2. `getmaxyx', `getbegyx', and `curs_set' aren't available on Ultrix, 130 * OSF/1, AIX, or HP-UX. 131 * 3. `curs_set' seems to be available under the POSIX Shell but there is 132 * no function prototype. 133 ******************************************************************************/ 134 135 #if defined(CURSESui) 136 # if defined(ultrix) || defined(alphaosf) || defined(AIX) 137 # define WERASEworks 0 138 # else 139 # define WERASEworks 1 140 # endif 141 # if defined(ultrix) || defined(alphaosf) || defined(AIX) || defined(hpux) 142 # define GETMAXavail 0 143 # define GETBEGavail 0 144 # else 145 # define GETMAXavail 1 146 # define GETBEGavail 1 147 # endif 148 # if defined(ultrix) || defined(alphaosf) || defined(AIX) || defined(hpux) || defined(posixSHELL) 149 # define CURS_SETavail 0 150 # else 151 # define CURS_SETavail 1 152 # endif 153 #endif 154 155 /****************************************************************************** 156 * Line drawing characters (for those machines on which they are not already 157 * defined or don't seem to work). 158 ******************************************************************************/ 159 160 #if defined(CURSESui) 161 # if defined(posixSHELL) 162 # define ACS_LLCORNER ACS_BLCORNER 163 # define ACS_LRCORNER ACS_BRCORNER 164 # endif 165 # if defined(ultrix) || defined(AIX) || defined(hpux) 166 # define problemACS 167 # endif 168 # if defined(alphaosf) || defined(IRIX64bit) || defined(SOLARIS64) || \ 169 defined(posixSHELL) || defined(__QNX__) || \ 170 defined(__CYGWIN__) || defined(__MINGW32__) 171 # define problemACS 172 # undef ACS_VLINE 173 # undef ACS_HLINE 174 # undef ACS_TTEE 175 # undef ACS_BTEE 176 # undef ACS_LTEE 177 # undef ACS_RTEE 178 # undef ACS_ULCORNER 179 # undef ACS_URCORNER 180 # undef ACS_LLCORNER 181 # undef ACS_LRCORNER 182 # undef ACS_PLUS 183 # endif 184 # if defined(problemACS) 185 # if defined(ACS_VLINE) 186 # undef ACS_VLINE 187 # endif 188 # define ACS_VLINE '|' 189 # if defined(ACS_HLINE) 190 # undef ACS_HLINE 191 # endif 192 # define ACS_HLINE '-' 193 # if defined(ACS_TTEE) 194 # undef ACS_TTEE 195 # endif 196 # define ACS_TTEE '+' 197 # if defined(ACS_BTEE) 198 # undef ACS_BTEE 199 # endif 200 # define ACS_BTEE '+' 201 # if defined(ACS_LTEE) 202 # undef ACS_LTEE 203 # endif 204 # define ACS_LTEE '+' 205 # if defined(ACS_RTEE) 206 # undef ACS_RTEE 207 # endif 208 # define ACS_RTEE '+' 209 # if defined(ACS_ULCORNER) 210 # undef ACS_ULCORNER 211 # endif 212 # define ACS_ULCORNER '+' 213 # if defined(ACS_URCORNER) 214 # undef ACS_URCORNER 215 # endif 216 # define ACS_URCORNER '+' 217 # if defined(ACS_LLCORNER) 218 # undef ACS_LLCORNER 219 # endif 220 # define ACS_LLCORNER '+' 221 # if defined(ACS_LRCORNER) 222 # undef ACS_LRCORNER 223 # endif 224 # define ACS_LRCORNER '+' 225 # if defined(ACS_PLUS) 226 # undef ACS_PLUS 227 # endif 228 # define ACS_PLUS '+' 229 # undef problemACS 230 # endif 231 # if defined(dos) 232 # define ACS_PLUS 0305 233 # define ACS_TTEE 0302 234 # define ACS_BTEE 0301 235 # define ACS_LTEE 0303 236 # define ACS_RTEE 0264 237 # define ACS_HLINE 0304 238 # define ACS_VLINE 0263 239 # define ACS_ULCORNER 0332 240 # define ACS_URCORNER 0277 241 # define ACS_LRCORNER 0331 242 # define ACS_LLCORNER 0300 243 # endif 244 #endif 245 246 #if defined(COWui) 247 # if defined(mac) 248 # define ACS_PLUS ((char) 0xF0) 249 # define ACS_TTEE ((char) 0xF1) 250 # define ACS_BTEE ((char) 0xF2) 251 # define ACS_LTEE ((char) 0xF3) 252 # define ACS_RTEE ((char) 0xF4) 253 # define ACS_HLINE ((char) 0xF5) 254 # define ACS_VLINE ((char) 0xF6) 255 # define ACS_ULCORNER ((char) 0xF7) 256 # define ACS_URCORNER ((char) 0xF8) 257 # define ACS_LRCORNER ((char) 0xF9) 258 # define ACS_LLCORNER ((char) 0xFA) 259 # endif 260 # if defined(win32) 261 # define ACS_PLUS ((char) 0xF0) 262 # define ACS_TTEE ((char) 0xF1) 263 # define ACS_BTEE ((char) 0xF2) 264 # define ACS_LTEE ((char) 0xF3) 265 # define ACS_RTEE ((char) 0xF4) 266 # define ACS_HLINE ((char) 0xF5) 267 # define ACS_VLINE ((char) 0xF6) 268 # define ACS_ULCORNER ((char) 0xF7) 269 # define ACS_URCORNER ((char) 0xF8) 270 # define ACS_LRCORNER ((char) 0xF9) 271 # define ACS_LLCORNER ((char) 0xFA) 272 # endif 273 #endif 274 275 /****************************************************************************** 276 * Special keys which have to be mapped to other keys. 277 ******************************************************************************/ 278 279 #if defined(sgi) 280 # define SGI_CONSOLE_RETURN 343 281 #endif 282 283 #if defined(posixSHELL) 284 # define POSIX_SHELL_DELETE 263 285 #endif 286 287 #if defined(hpux) 288 # define HPUX_DELETE 263 289 #endif 290 291 #if defined(AIX) 292 # define AIX_RETURN KEY_ENTER 293 # define AIX_DELETE KEY_BACKSPACE 294 #endif 295 296 #if defined(__CYGWIN__) 297 # define CYGWIN_DELETE 263 298 #endif 299 300 #if defined(__MINGW32__) 301 # define MINGW32_DELETE 263 302 #endif 303 304 /****************************************************************************** 305 * LINEdrawingCHAR. 306 * If the ACS_* definitions are changed, this macro may also have to be changed. 307 ******************************************************************************/ 308 309 #if defined(COWui) 310 # define LINEdrawingCHAR(chr) \ 311 ((uChar) ACS_PLUS <= (uChar) chr && (uChar) chr <= (uChar) ACS_LLCORNER) 312 #endif 313 314 /****************************************************************************** 315 * Attributes. 316 ******************************************************************************/ 317 318 #define REVERSEbit 1 319 #define BOLDbit 0 320 #define BLINKINGbit 4 321 322 /****************************************************************************** 323 * Reset levels. 324 ******************************************************************************/ 325 326 #define HARD_ 2 327 #define SOFT_ 1 328 #define UPDATE_ 0 329 330 /****************************************************************************** 331 * StatusOk (macro) [and StatusBad]. 332 ******************************************************************************/ 333 334 #if defined(SMGui) 335 # define StatusOk(status) ((status & 1 == 1) ? TRUE : FALSE) 336 #endif 337 338 #if defined(CURSESui) 339 # define StatusOk(status) ((status != ERR) ? TRUE : FALSE) 340 #endif 341 342 #define StatusBad !StatusOk 343 344 /****************************************************************************** 345 * Windowing structures. 346 ******************************************************************************/ 347 348 #if defined(COWui) 349 typedef struct COWvdStruct { /* COW "virtual display" structure. */ 350 short nRows; /* Number of rows in this window. */ 351 short nCols; /* Number of columns in this window. */ 352 short atRowN; /* Row number on pasteboard at which upper 353 left character position of this window 354 is located. */ 355 short atColN; /* Column number on pasteboard at which upper 356 left character position of this window 357 is located. */ 358 char *chars; /* Characters currently in this window. The 359 upper left character is first and the lower 360 right character is last. */ 361 char *attrs; /* Attributes for each corresponding 362 character. */ 363 } COWvd; 364 #endif 365 366 #if defined(SMGui) 367 typedef uLong LocalId; /* SMG virtual display identifier. */ 368 #endif 369 #if defined(CURSESui) 370 typedef WINDOW *LocalId; /* Pointer to Curses window. */ 371 #endif 372 #if defined(COWui) 373 typedef COWvd *LocalId; /* Pointer to COW "virtual display" 374 structure. */ 375 #endif 376 377 typedef struct WINDstruct { 378 LocalId id; /* "Window" identifier for windowing system 379 being used. */ 380 Logical pasted; /* TRUE: window is pasted (visible). */ 381 Logical bordered; /* TRUE: border around window. */ 382 struct WINDstruct *next; /* Next window on linked list. */ 383 } WIND; 384 385 /****************************************************************************** 386 * WINDOWid. 387 * Window identifier. Called a window in CURSES and on COW system (Macintosh 388 * and Windows). Called a virtual display in SMG. 389 ******************************************************************************/ 390 391 typedef WIND *WINDOWid; 392 393 /****************************************************************************** 394 * Keys. 395 ******************************************************************************/ 396 397 #define KB_0 '0' 398 #define KB_1 '1' 399 #define KB_2 '2' 400 #define KB_3 '3' 401 #define KB_4 '4' 402 #define KB_5 '5' 403 #define KB_6 '6' 404 #define KB_7 '7' 405 #define KB_8 '8' 406 #define KB_9 '9' 407 408 #define KB_a 'a' 409 #define KB_b 'b' 410 #define KB_c 'c' 411 #define KB_d 'd' 412 #define KB_e 'e' 413 #define KB_f 'f' 414 #define KB_g 'g' 415 #define KB_h 'h' 416 #define KB_i 'i' 417 #define KB_j 'j' 418 #define KB_k 'k' 419 #define KB_l 'l' 420 #define KB_m 'm' 421 #define KB_n 'n' 422 #define KB_o 'o' 423 #define KB_p 'p' 424 #define KB_q 'q' 425 #define KB_r 'r' 426 #define KB_s 's' 427 #define KB_t 't' 428 #define KB_u 'u' 429 #define KB_v 'v' 430 #define KB_w 'w' 431 #define KB_x 'x' 432 #define KB_y 'y' 433 #define KB_z 'z' 434 435 #define KB_A 'A' 436 #define KB_B 'B' 437 #define KB_C 'C' 438 #define KB_D 'D' 439 #define KB_E 'E' 440 #define KB_F 'F' 441 #define KB_G 'G' 442 #define KB_H 'H' 443 #define KB_I 'I' 444 #define KB_J 'J' 445 #define KB_K 'K' 446 #define KB_L 'L' 447 #define KB_M 'M' 448 #define KB_N 'N' 449 #define KB_O 'O' 450 #define KB_P 'P' 451 #define KB_Q 'Q' 452 #define KB_R 'R' 453 #define KB_S 'S' 454 #define KB_T 'T' 455 #define KB_U 'U' 456 #define KB_V 'V' 457 #define KB_W 'W' 458 #define KB_X 'X' 459 #define KB_Y 'Y' 460 #define KB_Z 'Z' 461 462 #define KB_PLUS '+' 463 #define KB_MINUS '-' 464 465 #define KB_CTRL_at 0 /* At sign (@). The NUL character. */ 466 #define KB_CTRL_A 1 467 #define KB_CTRL_B 2 468 #define KB_CTRL_C 3 469 #define KB_CTRL_D 4 470 #define KB_CTRL_E 5 471 #define KB_CTRL_F 6 472 #define KB_CTRL_G 7 473 #define KB_CTRL_H 8 474 #define KB_CTRL_I 9 475 #define KB_CTRL_J 10 476 #define KB_CTRL_K 11 477 #define KB_CTRL_L 12 478 #define KB_CTRL_M 13 479 #define KB_CTRL_N 14 480 #define KB_CTRL_O 15 481 #define KB_CTRL_P 16 482 #define KB_CTRL_Q 17 483 #define KB_CTRL_R 18 484 #define KB_CTRL_S 19 485 #define KB_CTRL_T 20 486 #define KB_CTRL_U 21 487 #define KB_CTRL_V 22 488 #define KB_CTRL_W 23 489 #define KB_CTRL_X 24 490 #define KB_CTRL_Y 25 491 #define KB_CTRL_Z 26 492 #define KB_ESCAPE 27 /* Left bracket ([). */ 493 #define KB_CTRL_28 28 /* Back slash (\). */ 494 #define KB_CTRL_29 29 /* Right bracket (]). */ 495 #define KB_CTRL_30 30 /* Circumflex accent (^). */ 496 #define KB_CTRL_31 31 /* Underscore (_). */ 497 498 #define KB_TAB KB_CTRL_I 499 #define KB_RETURN KB_CTRL_M 500 501 #if defined(dos) || defined(mac) || defined(win32) 502 # define KB_DELETE KB_CTRL_H 503 #else 504 # define KB_DELETE 127 505 #endif 506 507 #if defined(CURSESui) 508 # define KB_UPARROW KEY_UP 509 # define KB_DOWNARROW KEY_DOWN 510 # define KB_LEFTARROW KEY_LEFT 511 # define KB_RIGHTARROW KEY_RIGHT 512 #endif 513 514 #if defined(SMGui) 515 # define KB_UPARROW 0422 516 # define KB_DOWNARROW 0423 517 # define KB_LEFTARROW 0424 518 # define KB_RIGHTARROW 0425 519 #endif 520 521 #if defined(COWui) 522 # define KB_UPARROW KB_CTRL_30 523 # define KB_DOWNARROW KB_CTRL_31 524 # define KB_LEFTARROW KB_CTRL_28 525 # define KB_RIGHTARROW KB_CTRL_29 526 #endif 527 528 /****************************************************************************** 529 * Renditions (video attributes), cursor modes, border modes, etc. 530 ******************************************************************************/ 531 532 #define NORMAL 0 533 #define BOLD 1 534 #define REVERSE 2 535 #define REVERSE1 4 /* Different from REVERSE only on IBM PC. */ 536 #define REVERSE2 8 /* Different from REVERSE only on IBM PC. */ 537 #define BLINKING 16 538 #define BLACK 32 /* For erasing windows on IBM PC. */ 539 540 #define BORDER TRUE 541 #define NOBORDER FALSE 542 543 #define CURSORon TRUE 544 #define CURSORoff FALSE 545 546 #define ERASE TRUE 547 #define NOERASE FALSE 548 549 #define PASSTHRUri 1 550 #define TOUPPERri 2 551 #define TOLOWERri 3 552 553 /****************************************************************************** 554 * Function prototypes. 555 ******************************************************************************/ 556 557 int begin_pasteboard_update PROTOARGs((void)); 558 int change_rendition PROTOARGs((WINDOWid, int, int, int, int, int)); 559 int create_pasteboard PROTOARGs((void)); 560 int create_virtual_display PROTOARGs((int, int, WINDOWid *, int, int)); 561 int delete_pasteboard PROTOARGs((int)); 562 int delete_virtual_display PROTOARGs((WINDOWid)); 563 int draw_horizontal_line PROTOARGs((WINDOWid, int, int, int, int, Logical)); 564 int draw_vertical_line PROTOARGs((WINDOWid, int, int, int, int, Logical)); 565 int draw_rectangle PROTOARGs((WINDOWid, int, int, int, int, int)); 566 int end_pasteboard_update PROTOARGs((void)); 567 int erase_display PROTOARGs((WINDOWid, int, int, int, int)); 568 int input_field PROTOARGs((WINDOWid, char *, int, int, int, int *, int *, 569 int, int, int, int, int, int)); 570 int inq_cursor_mode PROTOARGs((int *)); 571 int label_border PROTOARGs((WINDOWid, char *, int)); 572 int paste_virtual_display PROTOARGs((WINDOWid, int, int)); 573 int put_chars PROTOARGs((WINDOWid, char *, int, int, int, int, int)); 574 int read_display PROTOARGs((WINDOWid, int, char *)); 575 #if defined(CURSESui) 576 int read_input PROTOARGs((WINDOWid, int *, int, Logical)); 577 #else 578 int read_input PROTOARGs((int *, int, Logical)); 579 #endif 580 int repaint_screen PROTOARGs((void)); 581 int repaste_virtual_display PROTOARGs((WINDOWid, int, int)); 582 int ring_bell PROTOARGs((void)); 583 int set_cursor_abs PROTOARGs((WINDOWid, int, int)); 584 int set_cursor_mode PROTOARGs((int)); 585 int unpaste_virtual_display PROTOARGs((WINDOWid)); 586 int zzzzz PROTOARGs((double)); 587 588 void EncodeKeyDefinitions VARPROTOARGs((int nLines, char **lineS, ...)); 589 590 /*****************************************************************************/ 591 592 #endif 593