MCPcopy Create free account
hub / github.com/NetHack/NetHack / curses_character_input_dialog

Function curses_character_input_dialog

win/curses/cursdial.c:207–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205/* Get a single character response from the player, such as a y/n prompt */
206
207int
208curses_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

Callers 2

curses_choose_characterFunction · 0.85
curses_yn_functionFunction · 0.85

Calls 15

curses_got_inputFunction · 0.85
curses_get_window_sizeFunction · 0.85
curses_get_nhwinFunction · 0.85
curses_num_linesFunction · 0.85
curses_create_windowFunction · 0.85
curses_break_strFunction · 0.85
curses_set_wid_colorsFunction · 0.85
customplineFunction · 0.85
curses_read_charFunction · 0.85
curses_convert_keysFunction · 0.85
digitFunction · 0.85
curses_get_countFunction · 0.85

Tested by

no test coverage detected