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

Function optfn_number_pad

src/options.c:2573–2645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2571}
2572
2573staticfn int
2574optfn_number_pad(
2575 int optidx, int req, boolean negated,
2576 char *opts, char *op)
2577{
2578 boolean compat;
2579
2580 if (req == do_init) {
2581 return optn_ok;
2582 }
2583 if (req == do_set) {
2584 compat = (strlen(opts) <= 10);
2585 op = string_for_opt(opts, (compat || !go.opt_initial));
2586 if (op == empty_optstr) {
2587 if (compat || negated || go.opt_initial) {
2588 /* for backwards compatibility, "number_pad" without a
2589 value is a synonym for number_pad:1 */
2590 iflags.num_pad = !negated;
2591 iflags.num_pad_mode = 0;
2592 }
2593 } else if (negated) {
2594 bad_negation(allopt[optidx].name, TRUE);
2595 return optn_err;
2596 } else {
2597 int mode = atoi(op);
2598
2599 if (mode < -1 || mode > 4 || (mode == 0 && *op != '0')) {
2600 config_error_add("Illegal %s parameter '%s'",
2601 allopt[optidx].name, op);
2602 return optn_err;
2603 } else if (mode <= 0) {
2604 iflags.num_pad = FALSE;
2605 /* German keyboard; y and z keys swapped */
2606 iflags.num_pad_mode = (mode < 0); /* 0 or 1 */
2607 } else { /* mode > 0 */
2608 iflags.num_pad = TRUE;
2609 iflags.num_pad_mode = 0;
2610 /* PC Hack / MSDOS compatibility */
2611 if (mode == 2 || mode == 4)
2612 iflags.num_pad_mode |= 1;
2613 /* phone keypad layout */
2614 if (mode == 3 || mode == 4)
2615 iflags.num_pad_mode |= 2;
2616 }
2617 }
2618 reset_commands(FALSE);
2619 number_pad(iflags.num_pad ? 1 : 0);
2620 return optn_ok;
2621 }
2622 if (req == get_val || req == get_cnf_val) {
2623 static const char *const numpadmodes[] = {
2624 "0=off", "1=on", "2=on, MSDOS compatible",
2625 "3=on, phone-style layout",
2626 "4=on, phone layout, MSDOS compatible",
2627 "-1=off, y & z swapped", /*[5]*/
2628 };
2629 int indx = gc.Cmd.num_pad
2630 ? (gc.Cmd.phone_layout ? (gc.Cmd.pcHack_compat ? 4 : 3)

Callers

nothing calls this directly

Calls 5

string_for_optFunction · 0.85
bad_negationFunction · 0.85
config_error_addFunction · 0.85
reset_commandsFunction · 0.85
handler_number_padFunction · 0.85

Tested by

no test coverage detected