| 205 | /* Get a single character response from the player, such as a y/n prompt */ |
| 206 | |
| 207 | int |
| 208 | curses_character_input_dialog( |
| 209 | const char *prompt, |
| 210 | const char *choices, |
| 211 | char def) |
| 212 | { |
| 213 | WINDOW *askwin = NULL; |
| 214 | #ifdef PDCURSES |
| 215 | WINDOW *message_window; |
| 216 | #endif |
| 217 | int answer, count, maxwidth, map_height, map_width; |
| 218 | char *linestr; |
| 219 | char askstr[BUFSZ + QBUFSZ]; |
| 220 | char choicestr[QBUFSZ]; |
| 221 | int prompt_width; |
| 222 | int prompt_height = 1; |
| 223 | boolean any_choice = FALSE; |
| 224 | boolean accept_count = FALSE; |
| 225 | |
| 226 | /* if messages were being suppressed for the remainder of the turn, |
| 227 | re-activate them now that input is being requested */ |
| 228 | curses_got_input(); |
| 229 | |
| 230 | if (svm.moves > 0) { |
| 231 | curses_get_window_size(MAP_WIN, &map_height, &map_width); |
| 232 | } else { |
| 233 | map_height = term_rows; |
| 234 | map_width = term_cols; |
| 235 | } |
| 236 | |
| 237 | #ifdef PDCURSES |
| 238 | message_window = curses_get_nhwin(MESSAGE_WIN); |
| 239 | #endif |
| 240 | maxwidth = map_width - 2; |
| 241 | |
| 242 | if (choices != NULL) { |
| 243 | for (count = 0; choices[count] != '\0'; count++) { |
| 244 | if (choices[count] == '#') { /* Accept a count */ |
| 245 | accept_count = TRUE; |
| 246 | } |
| 247 | } |
| 248 | choicestr[0] = ' '; |
| 249 | choicestr[1] = '['; |
| 250 | for (count = 0; choices[count] != '\0'; count++) { |
| 251 | if (choices[count] == '\033') { /* Escape */ |
| 252 | break; |
| 253 | } |
| 254 | choicestr[count + 2] = choices[count]; |
| 255 | } |
| 256 | choicestr[count + 2] = ']'; |
| 257 | if ((def >= 'A' && def <= 'Z') || (def >= 'a' && def <= 'z')) { |
| 258 | choicestr[count + 3] = ' '; |
| 259 | choicestr[count + 4] = '('; |
| 260 | choicestr[count + 5] = def; |
| 261 | choicestr[count + 6] = ')'; |
| 262 | choicestr[count + 7] = '\0'; |
| 263 | } else { /* No usable default choice */ |
| 264 |
no test coverage detected