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

Function curses_block

win/curses/cursmesg.c:299–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299int
300curses_block(
301 boolean noscroll) /* noscroll - blocking because of MSGTYPE=STOP/ALERT
302 * else blocking because window is full, so need to
303 * scroll after */
304{
305 static const char resp[] = " \r\n\033"; /* space, enter, esc */
306 static int prev_x = -1, prev_y = -1, blink = 0;
307 int height, width, moreattr, oldcrsr, ret = 0,
308 brdroffset = curses_window_has_border(MESSAGE_WIN) ? 1 : 0;
309 WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
310
311 curses_get_window_size(MESSAGE_WIN, &height, &width);
312 if (mx - brdroffset > width - 3) { /* -3: room for ">>_" */
313 if (my - brdroffset < height - 1)
314 ++my, mx = brdroffset;
315 else
316 mx = width - 3 + brdroffset;
317 }
318 /* if ">>" (--More--) is being rendered at the same spot as before,
319 toggle attributes so that the first '>' starts blinking if it wasn't
320 or stops blinking if it was */
321 if (mx == prev_x && my == prev_y) {
322 blink = 1 - blink;
323 } else {
324 prev_x = mx, prev_y = my;
325 blink = 0;
326 }
327 moreattr = !iflags.wc2_guicolor ? (int) A_REVERSE : NONE;
328 curses_toggle_color_attr(win, MORECOLOR, moreattr, ON);
329 curses_set_wid_colors(MESSAGE_WIN, NULL);
330 if (blink) {
331 wattron(win, A_BLINK);
332 mvwprintw(win, my, mx, ">"), mx += 1;
333 wattroff(win, A_BLINK);
334 waddstr(win, ">"), mx += 1;
335 } else {
336 mvwprintw(win, my, mx, ">>"), mx += 2;
337 }
338 curses_toggle_color_attr(win, MORECOLOR, moreattr, OFF);
339 curses_set_wid_colors(MESSAGE_WIN, NULL);
340 wrefresh(win);
341
342 /* cancel mesg suppression; all messages will have had chance to be read */
343 curses_got_input();
344
345 oldcrsr = curs_set(1);
346 do {
347 if (iflags.debug_fuzzer)
348 ret = '\n';
349 else
350 ret = curses_read_char();
351 if (ret == ERR)
352 iflags.term_gone = 1;
353 if (ret == ERR || ret == '\0')
354 ret = '\n';
355 /* msgtype=stop should require space/enter rather than any key,
356 as we want to prevent YASD from direction keys. */

Callers 2

curses_moreFunction · 0.85
curses_display_nhwindowFunction · 0.85

Calls 9

curses_window_has_borderFunction · 0.85
curses_get_nhwinFunction · 0.85
curses_get_window_sizeFunction · 0.85
curses_toggle_color_attrFunction · 0.85
curses_set_wid_colorsFunction · 0.85
curses_got_inputFunction · 0.85
curses_read_charFunction · 0.85
scroll_windowFunction · 0.85

Tested by

no test coverage detected