MCPcopy Index your code
hub / github.com/NetHack/NetHack / optfn_msg_window

Function optfn_msg_window

src/options.c:2455–2520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2453}
2454
2455staticfn int
2456optfn_msg_window(
2457 int optidx, int req, boolean negated,
2458 char *opts, char *op)
2459{
2460 int retval = optn_ok;
2461#if PREV_MSGS
2462 int tmp;
2463#else
2464 nhUse(optidx);
2465 nhUse(negated);
2466 nhUse(op);
2467#endif
2468
2469 if (req == do_init) {
2470 return optn_ok;
2471 }
2472 if (req == do_set) {
2473 /* msg_window:single, combo, full or reversed */
2474
2475 /* allow option to be silently ignored by non-tty ports */
2476#if PREV_MSGS
2477 if (op == empty_optstr) {
2478 tmp = negated ? 's' : 'f';
2479 } else {
2480 if (negated) {
2481 bad_negation(allopt[optidx].name, TRUE);
2482 return optn_err;
2483 }
2484 tmp = lowc(*op);
2485 }
2486 switch (tmp) {
2487 case 's': /* single message history cycle (default if negated) */
2488 case 'c': /* combination: first two as singles, then full page */
2489 case 'f': /* full page (default if specified without argument) */
2490 case 'r': /* full page in reverse order (LIFO; default for curses) */
2491 iflags.prevmsg_window = (char) tmp;
2492 break;
2493 default:
2494 config_error_add("Unknown %s parameter '%s'", allopt[optidx].name,
2495 op);
2496 retval = optn_err;
2497 }
2498#endif
2499 return retval;
2500 }
2501 if (req == get_val || req == get_cnf_val) {
2502 opts[0] = '\0';
2503#if PREV_MSGS
2504 tmp = iflags.prevmsg_window;
2505 if (WINDOWPORT(curses)) {
2506 if (tmp == 's' || tmp == 'c')
2507 tmp = iflags.prevmsg_window = 'r';
2508 }
2509 Sprintf(opts, "%s", (tmp == 's') ? "single"
2510 : (tmp == 'c') ? "combination"
2511 : (tmp == 'f') ? "full"
2512 : "reversed");

Callers 1

handler_msg_windowFunction · 0.85

Calls 4

bad_negationFunction · 0.85
config_error_addFunction · 0.85
handler_msg_windowFunction · 0.85
lowcFunction · 0.70

Tested by

no test coverage detected