Changeset 183
- Timestamp:
- 06/10/07 19:18:15 (1 year ago)
- Files:
-
- trunk/src/main-gcu.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main-gcu.c
r155 r183 37 37 * Consider the use of "savetty()" and "resetty()". XXX XXX XXX 38 38 */ 39 40 41 39 #include "angband.h" 42 40 … … 54 52 #define term System_term 55 53 54 56 55 /* 57 56 * Include the proper "header" file 58 57 */ 59 58 #ifdef USE_NCURSES 60 # if defined(HAVE_STDBOOL_H)59 # ifdef HAVE_STDBOOL_H 61 60 # define NCURSES_ENABLE_STDBOOL_H 0 62 61 # endif … … 70 69 71 70 72 #ifdef HAVE_CAN_CHANGE_COLOR 73 74 /* 75 * Try redefining the colors at startup. 76 */ 77 #define REDEFINE_COLORS 78 71 #if !defined(HAVE_CAN_CHANGE_COLOR) && defined(PDCURSES) 72 # define HAVE_CAN_CHANGE_COLOR 79 73 #endif /* HAVE_CAN_CHANGE_COLOR */ 80 74 … … 101 95 */ 102 96 #ifdef USE_TPOSIX 103 /*# include <sys/ioctl.h>*/104 97 # include <termios.h> 105 98 #endif 106 99 107 /* 108 * OPTION: Use old BSD curses. 109 * 110 * Some versions of curses does things a bit differently. 111 * 112 * If you have an old BSD 4.4 version of curses that isn't 113 * XSI Curses standard compatible enable this. 114 */ 115 /* #define USE_OLD_CURSES */ 116 117 118 /* 119 * Turn on options that are available in modern curses. 120 */ 121 #if defined (USE_OLD_CURSES) 122 /* Nothing */ 123 #else 124 # define USE_GETCH 125 # define USE_CURS_SET 126 #endif 127 128 /* 129 * You might want to turn on some of the options below this line 130 * if you had to turn on USE_OLD_CURSES 131 */ 132 133 134 /* 135 * OPTION: Use "blocking getch() calls" in "main-gcu.c". 136 */ 137 /* #define USE_GETCH */ 138 139 /* 140 * OPTION: Use the "curs_set()" call in "main-gcu.c". 141 */ 142 /* #define USE_CURS_SET */ 143 144 145 146 /* 147 * OPTION: some machines lack "cbreak()" 148 * On these machines, we use an older definition 100 101 102 /* 103 * If you have errors relating to curs_set(), comment out the following line 104 */ 105 #define USE_CURS_SET 106 107 108 /* 109 * If you have errors with any of the functions mentioned below, try 110 * uncommenting the line it's mentioned on. 149 111 */ 150 112 /* #define cbreak() crmode() */ 151 152 153 /*154 * OPTION: some machines cannot handle "nonl()" and "nl()"155 * On these machines, we can simply ignore those commands.156 */157 113 /* #define nonl() */ 158 114 /* #define nl() */ 159 115 160 116 117 161 118 /* 162 119 * Save the "normal" and "angband" terminal settings … … 166 123 167 124 static struct termios norm_termios; 168 169 125 static struct termios game_termios; 170 126 … … 175 131 * Information about a term 176 132 */ 177 typedef struct term_data term_data; 178 179 struct term_data 133 typedef struct term_data 180 134 { 181 135 term t; /* All term info */ 182 183 136 WINDOW *win; /* Pointer to the curses window */ 184 } ;137 } term_data; 185 138 186 139 /* Max number of windows on screen */ … … 190 143 static term_data data[MAX_TERM_DATA]; 191 144 192 193 /* 194 * Hack -- Number of initialized "term" structures 195 */ 145 /* Number of initialized "term" structures */ 196 146 static int active = 0; 147 197 148 198 149 … … 388 339 term_data *td = (term_data *)(t->data); 389 340 390 #ifdef USE_GETCH391 341 /* 392 342 * This is necessary to keep the first call to getch() … … 394 344 */ 395 345 wrefresh(stdscr); 396 #endif /* USE_GETCH */397 346 398 347 /* Count init's, handle first */ … … 457 406 458 407 459 #ifdef USE_GETCH460 461 408 /* 462 409 * Process events, with optional wait … … 500 447 } 501 448 449 #ifdef KEY_DOWN 450 /* Handle arrow keys */ 451 switch (i) 452 { 453 case KEY_DOWN: i = ARROW_DOWN; break; 454 case KEY_UP: i = ARROW_UP; break; 455 case KEY_LEFT: i = ARROW_LEFT; break; 456 case KEY_RIGHT: i = ARROW_RIGHT; break; 457 } 458 #endif 459 502 460 /* Enqueue the keypress */ 503 461 Term_keypress(i); … … 507 465 } 508 466 509 #else /* USE_GETCH */510 511 /*512 * Process events (with optional wait)513 */514 static errr Term_xtra_gcu_event(int v)515 {516 int i, k;517 518 char buf[2];519 520 /* Wait */521 if (v)522 {523 /* Wait for one byte */524 i = read(0, buf, 1);525 526 /* Hack -- Handle bizarre "errors" */527 if ((i <= 0) && (errno != EINTR)) exit_game_panic();528 }529 530 /* Do not wait */531 else532 {533 /* Get the current flags for stdin */534 k = fcntl(0, F_GETFL, 0);535 536 /* Oops */537 if (k < 0) return (1);538 539 /* Tell stdin not to block */540 if (fcntl(0, F_SETFL, k | O_NONBLOCK) < 0) return (1);541 542 /* Read one byte, if possible */543 i = read(0, buf, 1);544 545 /* Replace the flags for stdin */546 if (fcntl(0, F_SETFL, k)) return (1);547 }548 549 /* Ignore "invalid" keys */550 if ((i != 1) || (!buf[0])) return (1);551 552 /* Enqueue the keypress */553 Term_keypress(buf[0]);554 555 /* Success */556 return (0);557 }558 559 #endif /* USE_GETCH */560 467 561 468 /* … … 847 754 (COLORS >= 8) && (COLOR_PAIRS >= 8)); 848 755 849 #ifdef REDEFINE_COLORS756 #ifdef HAVE_CAN_CHANGE_COLOR 850 757 851 758 /* Can we change colors? */ … … 916 823 /*** Low level preparation ***/ 917 824 918 #ifdef USE_GETCH919 920 825 /* Paranoia -- Assume no waiting */ 921 826 nodelay(stdscr, FALSE); 922 923 #endif924 827 925 828 /* Prepare */ … … 927 830 noecho(); 928 831 nonl(); 832 833 #ifdef PDCURSES 834 keypad(stdscr, TRUE); 835 #endif 929 836 930 837 /* Extract the game keymap */
