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

Function optfn_mouse_support

src/options.c:2395–2453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2393}
2394
2395staticfn int
2396optfn_mouse_support(
2397 int optidx, int req, boolean negated,
2398 char *opts, char *op)
2399{
2400 boolean compat;
2401
2402 if (req == do_init) {
2403 return optn_ok;
2404 }
2405 if (req == do_set) {
2406 compat = (strlen(opts) <= 13);
2407 op = string_for_opt(opts, (compat || !go.opt_initial));
2408 if (op == empty_optstr) {
2409 if (compat || negated || go.opt_initial) {
2410 /* for backwards compatibility, "mouse_support" without a
2411 value is a synonym for mouse_support:1 */
2412 iflags.wc_mouse_support = !negated;
2413 }
2414 } else {
2415 int mode = atoi(op);
2416
2417 if (mode < 0 || mode > 2 || (mode == 0 && *op != '0')) {
2418 config_error_add("Illegal %s parameter '%s'",
2419 allopt[optidx].name, op);
2420 return optn_err;
2421 } else { /* mode >= 0 */
2422 iflags.wc_mouse_support = mode;
2423 }
2424 }
2425 return optn_ok;
2426 }
2427 if (req == get_val) {
2428#ifdef WIN32
2429#define MOUSEFIX1 ", QuickEdit off"
2430#define MOUSEFIX2 ", QuickEdit unchanged"
2431#else
2432#define MOUSEFIX1 ", O/S adjusted"
2433#define MOUSEFIX2 ", O/S unchanged"
2434#endif
2435 static const char *const mousemodes[][2] = {
2436 { "0=off", "" },
2437 { "1=on", MOUSEFIX1 },
2438 { "2=on", MOUSEFIX2 },
2439 };
2440#undef MOUSEFIX1
2441#undef MOUSEFIX2
2442 int ms = iflags.wc_mouse_support;
2443
2444 if (ms >= 0 && ms <= 2)
2445 Sprintf(opts, "%s%s", mousemodes[ms][0], mousemodes[ms][1]);
2446 return optn_ok;
2447 }
2448 if (req == get_cnf_val) {
2449 Sprintf(opts, "%i", iflags.wc_mouse_support);
2450 return optn_ok;
2451 }
2452 return optn_ok;

Callers

nothing calls this directly

Calls 2

string_for_optFunction · 0.85
config_error_addFunction · 0.85

Tested by

no test coverage detected