diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index 6b40f0ec5..48a30298b 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -24,7 +24,7 @@ .ds vr "NetHack 3.6 .ds f0 "\*(vr .ds f1 -.ds f2 "October 16, 2018 +.ds f2 "November 27, 2018 . .\" A note on some special characters: .\" \(lq = left double quote @@ -3136,6 +3136,21 @@ Default \(oq,\(cq. .lp monpolycontrol Prompt for new form whenever any monster changes shape (default off). Debug mode only. +.lp mouse_support +Allow use of the mouse for input and travel. +Valid settings are: +.PS -1 +.PL "\ 0" +disabled +.PL "\ 1" +enabled and make OS adjustments to support mouse use in the game. +.PL "\ 2" +like 1 but does not make any OS adjustments +.PE +For backward compatibility, omitting a value is the same as specifying 1 +and negating +.op mouse_support +is the same as specifying 0. .lp msghistory The number of top line messages to keep (and be able to recall with \(oq\(haP\(cq) (default 20). @@ -3557,8 +3572,6 @@ in a window. If NetHack can, it should use a large font. .lp map_mode If NetHack can, it should display the map in the manner specified. -.lp mouse_support -Allow use of the mouse for input and travel. .lp player_selection If NetHack can, it should pop up dialog boxes, or use prompts for character selection. diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 1a194ea54..18c366a27 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -45,7 +45,7 @@ %.au \author{Original version - Eric S. Raymond\\ (Edited and expanded for 3.6 by Mike Stephenson and others)} -\date{October 16, 2018} +\date{November 27, 2018} \maketitle @@ -3445,6 +3445,26 @@ Default `,'. Prompt for new form whenever any monster changes shape (default off). Debug mode only. %.lp +\item[\ib{mouse\verb+_+support}] +Allow use of the mouse for input and travel. +Valid settings are: + +%.sd +%.si +\newlength{\mwidth} +\settowidth{\mwidth}{\tt -0} +\newcommand{\numbox}[1]{\makebox[\mwidth][r]{{\tt #1}}} +\numbox{0} --- disabled\\ +\numbox{1} --- enabled and make OS adjustment to support mouse use in the game\\ +\numbox{2} --- enabled like {\tt 1}, but does not make any OS adjustments\\ +%.ei +%.ed + +For backward compatibility, omitting a value is the same as specifying {\tt 1} +and negating +{\it mouse\verb+_+support\/} +is the same as specifying {\tt 0}. +%.lp \item[\ib{msghistory}] The number of top line messages to save (and be able to recall with `{\tt \^{}P}') (default 20). @@ -3487,37 +3507,6 @@ Start the character with no armor (default false). Persistent. \item[\ib{null}] Send padding nulls to the terminal (default on). Persistent. %.lp -\item[\ib{number\verb+_+pad}] -Use digit keys instead of letters to move (default 0 or off).\\ -Valid settings are: - -%.sd -%.si -\newlength{\mwidth} -\settowidth{\mwidth}{\tt -0} -\newcommand{\numbox}[1]{\makebox[\mwidth][r]{{\tt #1}}} -\numbox{0} --- move by letters; `{\tt yuhjklbn}'\\ -\numbox{1} --- move by numbers; digit `{\tt 5}' acts as `{\tt G}' movement prefix\\ -\numbox{2} --- like {\tt 1} but `{\tt 5}' works as `{\tt g}' prefix instead of as `{\tt G}'\\ -\numbox{3} --- by numbers using phone key layout; {\tt 123} above, {\tt 789} below\\ -\numbox{4} --- combines {\tt 3} with {\tt 2}; phone layout plus MS-DOS compatibility\\ -\numbox{-1} --- by letters but use `{\tt z}' to go northwest, `{\tt y}' to zap wands -%.ei -%.ed - -For backward compatibility, omitting a value is the same as specifying {\tt 1} -and negating -{\it number\verb+_+pad\/} -is the same as specifying {\tt 0}. -(Settings {\tt 2} and {\tt 4} are for compatibility with MS-DOS or old PC Hack; -in addition to the different behavior for `{\tt 5}', `{\tt Alt-5}' acts as `{\tt G}' -and `{\tt Alt-0}' acts as `{\tt I}'. -Setting {\tt -1} is to accommodate some QWERTZ keyboards which have the -location of the `{\tt y}' and `{\tt z}' keys swapped.) -When moving by numbers, to enter a count prefix for those commands -which accept one (such as ``{\tt 12s}'' to search twelve times), precede it -with the letter `{\tt n}' (``{\tt n12s}''). -%.lp \item[\ib{packorder}] Specify the order to list object types in (default ``\verb&")[%?+!=/(*`0_&''). The value of this option should be a string @@ -3940,9 +3929,6 @@ If {\it NetHack\/} can, it should use a large font. \item[\ib{map\verb+_+mode}] If {\it NetHack\/} can, it should display the map in the manner specified. %.lp -\item[\ib{mouse\verb+_+support}] -Allow use of the mouse for input and travel. -%.lp \item[\ib{player\verb+_+selection}] If {\it NetHack\/} can, it should pop up dialog boxes or use prompts for character selection. %.lp diff --git a/include/flag.h b/include/flag.h index b0be1a0f9..956de39f0 100644 --- a/include/flag.h +++ b/include/flag.h @@ -416,13 +416,13 @@ struct instance_flags { boolean wc_popup_dialog; /* put queries in pop up dialogs instead of * in the message window */ boolean wc_eight_bit_input; /* allow eight bit input */ - boolean wc_mouse_support; /* allow mouse support */ boolean wc2_fullscreen; /* run fullscreen */ boolean wc2_softkeyboard; /* use software keyboard */ boolean wc2_wraptext; /* wrap text */ boolean wc2_selectsaved; /* display a menu of user's saved games */ boolean wc2_darkgray; /* try to use dark-gray color for black glyphs */ boolean wc2_hitpointbar; /* show graphical bar representing hit points */ + int wc_mouse_support; /* allow mouse support */ int wc2_term_cols; /* terminal width, in characters */ int wc2_term_rows; /* terminal height, in characters */ int wc2_windowborders; /* display borders on NetHack windows */ diff --git a/src/options.c b/src/options.c index f2ad9a058..a698e20b8 100644 --- a/src/options.c +++ b/src/options.c @@ -166,11 +166,6 @@ static struct Bool_Opt { { "menu_overlay", (boolean *) 0, FALSE, SET_IN_FILE }, #endif { "monpolycontrol", &iflags.mon_polycontrol, FALSE, SET_IN_WIZGAME }, -#ifdef CURSES_GRAPHICS - { "mouse_support", &iflags.wc_mouse_support, FALSE, DISP_IN_GAME }, /*WC*/ -#else - { "mouse_support", &iflags.wc_mouse_support, TRUE, DISP_IN_GAME }, /*WC*/ -#endif #ifdef NEWS { "news", &iflags.news, TRUE, DISP_IN_GAME }, #else @@ -342,6 +337,7 @@ static struct Comp_Opt { #endif { "name", "your character's name (e.g., name:Merlin-W)", PL_NSIZ, DISP_IN_GAME }, + { "mouse_support", "game receives click info from mouse", 0, SET_IN_GAME }, { "number_pad", "use the number pad for movement", 1, SET_IN_GAME }, { "objects", "the symbols to use for objects", MAXOCLASSES, SET_IN_FILE }, { "packorder", "the inventory order of the items in your pack", @@ -2209,6 +2205,35 @@ boolean tinitial, tfrom_file; return retval; } + fullname = "mouse_support"; + if (match_optname(opts, fullname, 13, TRUE)) { + boolean compat = (strlen(opts) <= 13); + + if (duplicate) + complain_about_duplicate(opts, 1); + op = string_for_opt(opts, (compat || !initial)); + if (!op) { + if (compat || negated || initial) { + /* for backwards compatibility, "mouse_support" without a + value is a synonym for mouse_support:1 */ + iflags.wc_mouse_support = !negated; + } + } else if (negated) { + bad_negation(fullname, TRUE); + return FALSE; + } else { + int mode = atoi(op); + + if (mode < 0 || mode > 2 || (mode == 0 && *op != '0')) { + config_error_add("Illegal %s parameter '%s'", fullname, op); + return FALSE; + } else { /* mode > 0 */ + iflags.wc_mouse_support = mode; + } + } + return retval; + } + fullname = "number_pad"; if (match_optname(opts, fullname, 10, TRUE)) { boolean compat = (strlen(opts) <= 10); @@ -5496,6 +5521,25 @@ char *buf; #endif } else if (!strcmp(optname, "name")) { Sprintf(buf, "%s", plname); + } else if (!strcmp(optname, "mouse_support")) { +#ifdef WIN32 +#define MOUSEFIX1 ", QuickEdit off" +#define MOUSEFIX2 ", QuickEdit unchanged" +#else +#define MOUSEFIX1 ", O/S adjusted" +#define MOUSEFIX2 ", O/S unchanged" +#endif + int ms = iflags.wc_mouse_support; + static const char *mousemodes[] = { + "0=off", + "1=on" MOUSEFIX1, + "2=on" MOUSEFIX2, + }; + + if (ms >= 0 && ms < SIZE(mousemodes)); + Strcpy(buf, mousemodes[ms]); +#undef MOUSEFIX1 +#undef MOUSEFIX2 } else if (!strcmp(optname, "number_pad")) { static const char *numpadmodes[] = { "0=off", "1=on", "2=on, MSDOS compatible", diff --git a/sys/winnt/nttty.c b/sys/winnt/nttty.c index 5f5befc0c..579125867 100644 --- a/sys/winnt/nttty.c +++ b/sys/winnt/nttty.c @@ -87,6 +87,7 @@ static void NDECL(restore_original_console_font); /* Win32 Screen buffer,coordinate,console I/O information */ COORD ntcoord; INPUT_RECORD ir; +static boolean orig_QuickEdit; /* Support for changing console font if existing glyph widths are too wide */ @@ -311,8 +312,14 @@ const char *s; end_screen(); if (s) raw_print(s); - restore_original_console_font(); + if (orig_QuickEdit) { + DWORD cmode; + + GetConsoleMode(console.hConIn, &cmode); + cmode |= (ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS); + SetConsoleMode(console.hConIn, cmode); + } } /* called by init_nhwindows() and resume_nhwindows() */ @@ -864,12 +871,30 @@ standoutend() void toggle_mouse_support() { + static int qeinit = 0; DWORD cmode; + GetConsoleMode(console.hConIn, &cmode); - if (iflags.wc_mouse_support) - cmode |= ENABLE_MOUSE_INPUT; - else - cmode &= ~ENABLE_MOUSE_INPUT; + if (!qeinit) { + qeinit = 1; + orig_QuickEdit = ((cmode & ENABLE_QUICK_EDIT_MODE) != 0); + } + switch(iflags.wc_mouse_support) { + case 2: + cmode |= ENABLE_MOUSE_INPUT; + break; + case 1: + cmode |= ENABLE_MOUSE_INPUT; + cmode &= ~ENABLE_QUICK_EDIT_MODE; + cmode |= ENABLE_EXTENDED_FLAGS; + break; + case 0: + /*FALLTHRU*/ + default: + cmode &= ~ENABLE_MOUSE_INPUT; + if (orig_QuickEdit) + cmode |= (ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS); + } SetConsoleMode(console.hConIn, cmode); } #endif