Commit Graph

1951 Commits

Author SHA1 Message Date
PatR
14b2330fd6 curses color cleanup
The color handling changes for curses left a set of variables
unused, so get rid of them.
2021-06-06 15:23:39 -07:00
PatR
41eecdf6b3 curses menu: support backspace/delete for counts
Have curses call the core get_count() routine instead rolling its
own so that backspace and delete are supported.  That part was
trivial to accomplish.  Unfortunately it brought the disappearing
menu phenomenon back so it became more complicated overall.
2021-06-06 05:54:53 -07:00
PatR
0280006d76 fix #K3357 - curses menu disappears
This fixes the disappearing menu, but not curses menu count entry
failing to honor backspace/delete.  Entering two or more digits
to get a "Count:12" message, followed by non-digit which removes
that, resulted in the menu for apply/loot in-out container operation
vanishing while it was still waiting for a choice.  (Typing a choice
blindly did work.)

The code intended to handle this.  I don't understand why refresh()
wasn't working.  Reordering stuff didn't help until I changed that
from refresh() to wrefresh(win).

The original Count:123 display was limited to 25 characters and
menus to half the main window, so they didn't overlap.  I made the
count display wider--because it is now also used for 'autodescribe'
feedback when moving the cursor around the map--so made something
that originally was impossible become possible.  One line of the
menu does get erased while "Count:" is displayed, but then gets put
back by the wrefresh().
2021-06-05 16:11:50 -07:00
Patric Mueller
5c15ca1002 curses: remove unnecessary special handling for dark gray
On terminals with at least 16 colors there should be no need for special
handling dark gray.

The curses code uses COLORS < 16, COLORS <= 16, COLORS > 16, or COLORS >= 16
at several places although I'm not sure if they are correct or which could
possibly be off-by-one errors.

But realistically in this case, we only need to distinguish between 8 color
terminals and terminals supporting more than 8 colors as this will mean the
terminal supports at least 256 colors.
2021-06-05 14:38:41 +02:00
Patric Mueller
6e7f1bc1f0 curses: don't change the terminal's default colors
The curses port changed some of the basic 8 terminal colors and all 8 bright
colors on terminals supporting changing colors.
2021-06-05 14:38:13 +02:00
nhmall
0a10bd632d change references from winnt to windows
rename sys/winnt to sys/windows
move vs (visual studio) folder out of win/win32 and into sys/windows
rename include/ntconf.h to include/windconf.h
rename winnt.c to windsys.c
place visual studio projects into individual subfolders.

This will hopefully resolve GitHub issue #484 as well.
2021-06-03 23:26:00 -04:00
nhmall
e69808987e support for build with current Lua version 5.4.3
On some platforms this may require:
	make spotless
	make fetch-lua

I did attempt to force a reminder message about the latter to
Makefile.top this time, and hope that works correctly for everyone.
2021-06-02 19:12:47 -04:00
Pasi Kallinen
967c7e5b0b Fix compile error on Windows
Fixes #508
2021-05-09 11:43:55 +03:00
PatR
22b320f441 fix github issue #499 - perm_invent menu_headings
Implementation of '|'/#perminv command for scrolling perm_invent
deliberately disabled menu_headings (video attribute for object
class separator lines) on the persistent inventory window under
curses.  I don't recall why (possibly because it isn't actually
a menu) but there's no compelling need to do that, so reinstate
heading attributes.

Fixes #499
2021-05-03 13:50:48 -07:00
PatR
a8388c8cb5 Qt extended command "rest"
When Qt's extended command selection dialog is set for all commands
or all normal mode commands, it displays the "#wait" command as
"wait (rest)".  Picking by mouse is straightforward; the extra text
on the button has no effect.  Picking by typing "#wa" will choose it;
there aren't any other choices matching that so the player never gets
as far as typing 'i'.  This change allows the player to type "#rest"
as an alternate way to choose it.  "#re" matches some other stuff
and the choice is left pending, adding 's' makes it unique but not
explicitly chosen (so still possible to back up), then adding 't'
chooses it.  The core never knows the difference.
2021-04-11 17:53:57 -07:00
PatR
506ce2081a Qt extended command selection
Simplify extended command selection under Qt by allowing the
autocomplete subset be one of the choices for its [filter].  That's
the same subset as X11 uses, where #q is unambiguous for #quit
instead of competing with #quaff and #quiver.

Unlike under X11, the player can use [filter] to switch to the full
command set and get access to a few commands which have no useable
key and aren't flagged to autocomplete.  (Mostly obscure wizard mode
commands but #exploremode is in that situation.)

In normal and explore modes, the [filter] button just toggles between
two sets of commands (all normal mode commands vs autocomplete normal
mode commands).  In wizard mode there are four choices and you might
need to click on [filter] up to three times to step through to the
target one among four sets (all commands, all normal mode commands,
autocomplete commands for both normal and wizard, full subset of just
the wizard mode commands).
2021-04-11 14:55:45 -07:00
PatR
4445e06d1c Qt text windows
For Qt, always render text windows with fixed width font instead
of switching from proportional to fixed when the text contains
any line(s) with four consecutive spaces.  That was really meant
for menu lines without selector letters which want to be lined
up under or over ones with such, and wasn't a very good heuristic
for text windows.

Most of the text files for the '?' command happen to have such
lines so are already being shown with fixed-width font.  data.base
entries were hit or miss; most have attribution lines indented by
four or more spaces but some don't, so display was inconsistent:
some were shown with fixed-width font and some with proportional.
2021-04-08 11:42:55 -07:00
Patric Mueller
921b7b955f Missed adjustment for the increased prefix length of the perm_invent window 2021-04-01 23:07:18 +02:00
Patric Mueller
2805a135a3 Indent items in perm_invent window
Add a space in front of items in the perm_invent window as in the inventory
window.
2021-04-01 21:57:10 +02:00
Patric Mueller
495aaf33f6 Fix menu headings using default text color
Rendering menu headings used the NetHack internal NO_COLOR macro which mapped
to dark gray instead of the default text color.

Fixes #480
2021-04-01 21:49:56 +02:00
PatR
b3d21fd337 X11 perm_invent positioning
Change the '|'/#perminv final positioning for X11 to be the same
as for curses:  finishing with <escape> leaves the current view,
with <return> resets to unscrolled.

Actually getting ESC and RET to the right place wasn't trivial;
down the rabbit hole and out the other side.  Using yn_function()
to get the #perminv keystrokes is less than ideal.  (curses also
started that way but switched to raw character input for this.)
2021-03-16 09:13:55 -07:00
PatR
23642b40d8 X11 persistent inventory horizontal scrolling
Enable a horizontal scrollbar for the perm_invent window so that
the '}' and '{' menu commands work for it.
2021-03-16 09:12:18 -07:00
PatR
d28952507a \#perminv comments
Fix a couple of comment typos and an instance of ambiguous wording.
2021-03-15 08:54:10 -07:00
PatR
f008319c5d curses perm_invent comment
Stripping article ("a ", "an ", "the ") off inventory items to
squeeze a little more info into truncated persistent inventory
was initially case insensitve.  That was removed because it isn't
needed but the comment still reflected it.
2021-03-15 01:05:19 -07:00
PatR
7463aa5a57 X11 #perminv typo/thinko
Copy+paste error.  Would matter if menus had horizontal scrollbars
but since they don't, it's academic.
2021-03-14 01:00:36 -08:00
PatR
946df19ea2 \#perminv, 2 of 2: implementation
Add new '|' command, aka #perminv, which allows the player to
send menu scrolling keystrokes to the persistent inventory window.

Implemented for X11, where its usefulness is limited, and for
curses, where it is more needed and also more fully functional.
The interface can either prompt for one keystroke, act upon it,
and return to normal play, or it can loop for multiple keystrokes
until player types <return> or <escape>.  X11 does the former if
the 'slow' application resource is False so that prompting uses
popups, and the latter when 'slow' is True where prompting is in
a fixed spot and doesn't end up causing the persistent inventory
window to be stacked behind the map window.  curses always does
the loop-until-done approach.  It also accepts up and down arrow
keys to scroll one line at a time.

Also adds two new menu scrolling commands, menu_shift_right (key
'}' by default) and menu_shift_left ('{') if wincap2 flags contain
WC2_MENU_SHIFT.  Shifting allows different substrings of too-long
lines to be seen.

For X11, neither works because their handling requires a horizontal
scrollbar and for some reason that escapes me our menus don't have
one of those.  If they did, shifts could work for all menus but a
shifted window would hide the selection letters.  So shifting would
be most usefully done as:  pan right, read more of any long lines,
immediately pan back to the left.

For curses, they only apply to the persistent inventory window.
Shift right redraws it with class headers and inventory letters
shown normally but the item descriptions omit their leftmost
portion, showing more text towards the end.  Shift left reverses
that and does nothing if the beginning is already in view.  Forward
and backward scrolling while shifted leave the shift in place.
2021-03-13 18:18:53 -08:00
PatR
dd49431296 \#perminv, 1 of 2: groundwork
Give the window-port side of *_update_inventory() an argument.
Calls in the core still omit that; invent.c's update_inventory()
is the only place that cares.
2021-03-13 18:17:00 -08:00
PatR
160344feaa scrollbar handling by X11
Looking up scrollbars did not work as intended.  The code wanted an
ancestor widget that had both horizontal and vertical scrollbars,
but menus either have none or just vertical.  The lookup code found
some top level widget and returned bad data.
2021-03-12 18:06:43 -08:00
PatR
015380fecf remove several obsolete C() and M() macros
The ones moved from cmd.c to global.h suffice.
2021-03-10 13:50:44 -08:00
PatR
cc855d6973 signal induced panictrace under curses
When panictrace feedback occurs due to catching a signal rather
than controlled panic, the backtrace is useless when running the
curses interface unless the terminal gets reset first.  Let's
just hope that the signal triggering a panictrace doesn't occur
while resetting the terminal.
2021-03-09 07:45:58 -08:00
PatR
a2046669f4 X11 menu handling
In a couple of places, call menu_popdown instead of duplicating
its contents.  I'm fairly sure that executing the is_active bit
that the duplications omitted is safe.

Several minor formatting bits are mixed in.
2021-02-26 17:06:40 -08:00
PatR
ed349cd5fe X11 yn_function() again
Widget widths should have type 'Dimension' rather than plain 'int'.

Perform a couple of things once during popup widget creation rather
than every time it gets popped up.
2021-02-22 01:10:14 -08:00
PatR
8195334d65 X11 popup yn_function resizing
When X11_yn_function() re-uses a popup widget to issue a prompt
and get the player's response, make it resize properly.  I'm not
sure why the old hack for that apparently worked for some folks
and not for me, or why this does work for me.  At least it does.

Also, make the minimum popup width be 25 characters so that
really short prompts don't result in tiny popups.  Since the
popup appears at whatever spot the pointer happens to be sitting,
it isn't always immediately noticeable when the player is using
the keyboard rather than the pointer.
2021-02-21 17:30:09 -08:00
PatR
316a9a1809 X11 getline refinement
X11_getlin() echoing its prompt and response to message window
truncates combined value to maximum allowed pline (rather than
having pline truncate it).  But it was truncating the response
as if the prompt was maximum allowed length instead of its actual
length, so possibly hiding some of the user's text unnecessarily.
2021-02-20 16:25:12 -08:00
PatR
a32002eb88 X11 getline: log prompt and response
After player has responded to a getline prompt, echo the prompt
and the line of text response to the message window.  Uses pline()
so also gets put into core's message history for dumplog.
2021-02-19 15:38:31 -08:00
PatR
2cedfc9696 X11 update
More issues.  The incorrectly rendered map after panning is one
I haven't seen before.  Normally I only have a clipped map if I
force double size tiles rather and hadn't noticed this behavior
for that case, so manually resizing--and/or the scrollbars which
get added when that occurs--may be what triggers it.
2021-02-19 14:11:32 -08:00
PatR
31b0847bd7 X11's yn_function() echoing its response
X11_yn_function() issues a pline() to put the prompt and player's
response into the message window.  Change it to use visctrl() to
make sure that the response character is ledgible when something
like the '&' command allows an arbitrary answer.

This patch adds a leading space and two extra trailing spaces
to the prompt when it's being issued via popup, but that hasn't
affected the issue mentioned next....

The popup prompting when the 'slow' resource is False doesn't
always resize properly.  I saw both too wide and too narrow
[What do you want to throw? [abc] ]b
[       In what direction?        ]
and
[Really quit? [yn] (n) ]y
[Dump core? [ynq] (q) ]n   (size seemed right, but hard to tell)
[Do you want your posses]  (might have shown one more letter;
                            resize doodad in window's bottom right
                            corner on OSX oscures the rightmost
                            column--which is ordinarily a space)
The truncated one did accept responses.  If I answered 'n' then
the next question was truncated too, but for 'y' (plus ensuing
feedback) it would be sized correctly for the question after that.

To be clear:  the popup width issue was present before this change
and is still present after it.  The code already has a hack that's
intended to deal with this but it doesn't do the job for me.
2021-02-15 19:09:00 -08:00
PatR
8fff588ab3 X11 persistent inventory again: initial display
If 'perm_invent' is preset in player's options, have X11 show the
persistent inventory window from the start instead of waiting for
an 'i' command.  moveloop() prolog needed a tweak do deal with it
cleanly.

Require WC_PERM_INVENT in order to honor the perm_invent option.
X11 and curses already set that, tty and curses don't support it,
so only Windows GUI needed to be updated for it.
2021-02-14 00:57:34 -08:00
PatR
36179da82f X11 perm_invent: handle 'O' toggling off perm_invent
When persistent inventory window is up, remove it if 'perm_invent'
option gets set to False.  This has a side-effect of fixing the
end-of-game prompting problem it caused.
2021-02-13 19:17:20 -08:00
PatR
be9a2c2907 X11: persistent inventory issues and hack for OSX
This hack prevents the perm_invent window for X11 on OSX from
creeping every time it gets updated.  It is far from perfect and
at the very least ought be handled via user settable X resources
rather than hardcoded values, but it's as much effort as I'm likely
to spend.

Add a new file containing a list of issues that ought to be fixed.
The initial entries are things I noticed while experimenting with
perm_invent; there is lots of older stuff that could/should be
there too.  I'm not sure whether the first one is OSX-specific; the
others aren't.
2021-02-12 15:07:51 -08:00
PatR
73ad32abc9 recent X11 bit: X11_bail() doesn't return 2021-02-10 18:52:22 -08:00
PatR
33ee596d68 curses comment
Add a TODO item for curses status display that will probably
never get done.  Could apply to tty too.
2021-02-09 15:50:03 -08:00
PatR
71bb01c328 curses persistent inventory window tweak
Under curses interface, provide a way to get a little more space
for perm_invent without turning off windowborders entirely.

Possible 'windowborders' values:
 0 = no borders, max screen space available for useful info
 1 = full borders, two lines and two columns wasted for each window
 2 = contingent borders, show if screen is big enough, else hide
New:
 3 = as 1 except no borders for perm_invent window
 4 = as 2 except never borders for perm_invent window

3 and 4 let the map, message, and status windows have borders while
providing two extra lines and two extra columns on each line for
persistent inventory.  It's not much but better than nothing when
borders are enabled.
2021-02-08 16:34:29 -08:00
PatR
67d94d2930 partial fix for #K3262 - X11 perm_invent panic
Prevent the "X Error (bad Atom)" situation that causes an
"X Error" panic.

The issue isn't fixed.  This fails to implement the intended
functionality of having the X server remember the persistent
inventory window's location across games (until the next time
that the X server restarts).  Worse, on OSX the window creeps
each time it is updated (visually it seems to be moving down by
the height of the window's title bar).

That's not as bad as having it move to the pointer's location as
it did in 3.6.1, but prior to the commit which introduced this
code that had been fixed and it stayed put during the current
game, so more work is definitely needed.
2021-02-06 16:04:44 -08:00
nhmall
bf3c84a4ce wasm cross-compile bit 2021-02-05 19:16:49 -05:00
PatR
74213666bf curses: honor menu_next_page/&c option settings
tty and X11 honor the menu_xxx options.  Qt currently doesn't
support menu manipulation by keyboard.  curses does support that
but was only handling the default menu keys.
2021-02-05 01:04:48 -08:00
nhmall
d2f570154a another old-style-definition 2021-02-04 19:40:38 -05:00
Bart House
1efae34cc7 Disable warning 4774 for lua source files. 2021-02-04 11:28:41 -08:00
PatR
14cb015d72 Qt close-window handling
Handle the unused variable 'ok' differently.
2021-02-03 13:42:17 -08:00
nhmall
78532e3855 Qt follow-up bit 2021-02-03 15:36:00 -05:00
nhmall
44b16979cf unused-but-set-variable warning in qt_main.cpp
../win/Qt/qt_main.cpp: In member function ‘virtual void nethack_qt_::NetHackQtMainWindow::closeEvent(QCloseEvent*)’:
../win/Qt/qt_main.cpp:1377:9: warning: variable ‘ok’ set but not used [-Wunused-but-set-variable]
 1377 |     int ok = 0;
      |         ^~
2021-02-03 15:33:30 -05:00
nhmall
21ca9e1ec5 Qt setChecked() takes a boolean argument 2021-02-03 15:21:38 -05:00
nhmall
c5b74aee63 variable set but not used warning in qt_yndlg.cpp
../win/Qt/qt_yndlg.cpp: In member function ‘char nethack_qt_::NetHackQtYnDialog::Exec()’:
../win/Qt/qt_yndlg.cpp:80:9: warning: variable ‘ch_per_line’ set but not used [-Wunused-but-set-variable]
   80 |     int ch_per_line=6;
      |         ^~~~~~~~~~~
2021-02-03 12:56:55 -05:00
nhmall
8f3dc3b21b prevent a warning about a multi-line comment in qt_svsel.cpp 2021-02-03 12:51:26 -05:00
nhmall
24c829ecf7 wording fix 2021-02-03 09:42:59 -05:00