Commit Graph

338 Commits

Author SHA1 Message Date
nhmall
ba00dc9066 sever extracolors from utf8map and ENHANCED_SYMBOLS
move the custom color data into its own field in the glyphmap
and disassociate it from the unicode/utf8 stuff.

move the glyphcache stuff during options processing and parsing
into new file glyphs.c and out of utf8map.c, and make it
general, and not part of ENHANCED_SYMBOLS.

Do the groundwork for allowing glyph color customizations to
work when any symset is loaded and not restrict it only to
the enhanced1 H_UTF8 symsets.

The customizations in effect are still affiliated with a particular
symset.

Also closes #1224, but the PR itself references a data structure
made obsolete by this commit. The curses comment from the PR was
added into the code.

The PR also made several suggestions, but only the first
one has been included in this commit (and no longer based on
the handler), that being:
"allow defining colors if other symbol handling modes are used
(possibly limited to the standard 16 colors)."

FredrIQ also wrote the following suggestions in PR#1224:

Something I was also contemplating, unrelated to implementation of this
support in curses, would be the ability for the following:

allow defining colors if other symbol handling modes are used (possibly limited to the standard 16 colors)
allow defining attributes (for example: glyph:G_pet_female_kitten:U+0066/red/underline)
allow specifying glyphs as wildcards for defining global color/attribute changes

Something I also want to see are keywords for "don't change the current defined data". If this
were to be added, you could for example do this:
OPTIONS=glyph:G_*_fox:U+0064/blue
OPTIONS=glyph:G_statue_*:basechar/gray/underline
for "make all foxes use a blue color, make all statues gray with underline" without needing
to specify the relevant character for every statue. This ("basechar", "basefg", etc)
should perhaps also be added for MENUCOLORS and statushilites, so that you can, for
example, underline all items being worn without needing to specify a bunch of
near-duplicate rules for combining BUC colors + underline worn items
as per #1064
2024-03-23 15:36:22 -04:00
nhmall
6619d10d90 ENHANCED_SYMBOLS: store all CLR_ colors specially
The 0x1000000 bit (NH_BASIC_COLOR bit) was used to mark
CLR_BLACK when storing it in u->ucolor. Now, all of the basic CLR_*
colors are stored that way.

The NH_BASIC_COLOR bit indicates that the value in u->ucolor is
not an rgb value, rather it is one of the 0-15 basic NetHack colors.
The window-ports need to strip the NH_BASIC_COLOR bit off before using
it for color changes.
2024-03-03 18:31:11 -05:00
Pasi Kallinen
53778ee507 Use single define for max message history
... instead of having every windowport define their own variant.
Affects tty, curses, X11, and Windows GUI.
2024-03-03 11:34:59 +02:00
RainRat
a3658f85ac fix typos 2024-02-28 20:15:56 -08:00
PatR
41a5565403 new 'showvers' option
Add options 'showvers' (boolean) and 'versinfo' (numeric mask) to
show nethack's version on the status lines during play.  It won't be
particularly interesting to ordinary players but should be useful
when making screenshots or video to be streamed, or for someone who
switches between git branches or between nethack and variants.

I worked on this several months back but it was combined with
unfinished changes to 'hitpointbar'.  I've separated it out so that
it can be put into use.  When enabled, one or more components of
"<name> <branch> <version>" will be shown right justified after
status conditions.  At present the default is "<branch>" if that is
available and overall status isn't 'released', or "<version>" if
'released' or if branch isn't available.  That might need some
refinement.

It works as intended for tty and curses, although some abbreviation
mechanism would be useful if/when the program resorts to abbreviating
status conditions to make things narrow enough to fit.

For X11, it works ok for fancy_status:True (the default, controlled
via NetHack.ad settings) but is messed up for tty-style status.  The
text is positioned correctly but there are gaps in it, making it
appear garbled, similar to what I saw when I tried and failed to
implement statuslines:3 for X11.  [It might be due to having empty
condition widgets be 1 pixel wide instead of being totally removed
but I don't think the situation is that simple.]

For Qt, if the text needs to be truncated in order to fit, the center
portion of the string will be shown, discarding parts from the left
and right.  That ought to discard from left and retain rightmost
portion instead.

For win32|mswin|Win GUI, no attempt to support it has been included.
Things should be ok when 'showvers' is left as False (the default)
but I don't know what will happen if that gets toggled to True.  At a
minimum, the version info won't be right justified.  The information,
or at least some of it, is displayed in the game window's title bar
so there isn't any pressing need to add it to status, but toggling
the option will need to behave sensibly if it doesn't already.
2024-02-28 11:47:16 -08:00
nhmall
b4f578495c more pointer style consistency 2024-02-20 13:04:32 -05:00
nhmall
688ac6ffbe remove register from variable declarations 2024-02-19 16:30:07 -05:00
nhkeni
3d3ce2369c Merge branch 'keni-wincw2' into NetHack-3.7
Lots of manually resolved conflicts.
2024-02-15 16:25:12 -05:00
nhkeni
dbe5c98dca add CRASHREPORT directly to browser
add CRASHREPORT for Windows
add ^P info to report (via DUMPLOG)

new options: crash_email, crash_name, crash_urlmax
new game command: #bugreport
new config option: CRASHREPORT_EXEC_NOSTDERR
new command line option: --bidshow

deleted helper scripts:
    NetHackCrashReport.Javascript
    nhcrashreport.lua

misc:
    update CRASHREPORTURL (will need to be updated before release)
    update bitrot in winchain
    winchain for Windows
    add missing synch_wait for NetHackW --showpaths
    add PANICTRACE (and CRASHREPORT) in mdlib.c:build_opts

missing:
    packaging (Windows needs the pdb file)
    no testing with MSVC command line build

port status:
    linux: working, but glibc's backtrace doesn't show static functions
    Windows VS: working.  pdb file is large - looking into options
    MacOS: working
    msdos: not supported
    VMS: not supported
    MSVC: planned, but not attempted
    MSYS2: working, but libbacktrace not showing symbols (yet?)
2024-02-06 18:33:59 -05:00
nhmall
b9bf956ec9 follow-up 2 for italic 2024-01-29 10:55:44 -05:00
nhmall
0dfe92ac61 more italic support
There might be some follow-ups to this.
2024-01-29 08:40:05 -05:00
nhmall
04082a2033 Remove TEXTCOLOR build option 2023-11-22 16:01:58 -05:00
nhmall
a82a897da3 avoid ctrl_nhwindow-related impossible
Remove the impossible(), so that new functionality can be added
incrementally without requiring every window-port to be visited up front.
2023-11-16 21:00:59 -05:00
nhmall
86067dcffd use ctrl_nhwindow() for menu prompt style
This implements the mechanics to use the ctrl_nhwindow() interface
capability to pass down a setting change from the core to the active
window port, without resorting to accessing a core global variable
from within the window port, and without altering the interface..

The passed setting is honored in the tty and curses window ports.

X11 and mswin receive and store the values, but no implementation
to change the menu prompt style is there yet.

Qt does not store the values or have an implementation.

The setting change is done in allmain.c immediately after
creating the WIN_INVEN window.
2023-11-16 00:10:06 -05:00
nhmall
4b79baa55b add_menu follow-up, part 2 of interface adjustment
Remove menu_color support from the window port side of the interface.
The window port just has to honor the color parameter that was added
to the add_menu() interface definition in June 2022 commit
2770223d10, and let the core-side of
the interface handle things.

To that end, this does the following:

Removes the #define of add_menu() from include/winprocs.h and add a
real core-side add_menu() function to windows.c which acts as a
trampoline to the window port win_add_menu() function, while providing
a single location to adjust the parameters passed to the window port
function. get_menu_coloring() is now called in there.

Moves get_menu_coloring() from options.c into windows.c and makes it
static.

Removes all the calls to get_menu_coloring() from the tty, Qt, X11,
curses, and win32 interfaces and adjusts their code to simply honor
the color parameter in add_menu, similar to what the menu_headings
change from earlier today did.
2023-11-13 12:56:38 -05:00
Pasi Kallinen
dd5ca5b058 Change menu_headings to accept color and attribute
Instead of just accepting an attribute, it's now possible to
use a color, or both color and attribute, for example:

OPTIONS=menu_headings:inverse
OPTIONS=menu_headings:red
OPTIONS=menu_headings:red&underline

Default is still just inverse.
This lets the player change the menu heading color without
needing to use menu colors for them.

Also makes it so the core uses NO_COLOR instead of 0, for all
the menu lines which don't have any prefedefined color.

Tested for tty, curses, x11, qt, and win32
2023-11-13 07:33:56 +02:00
PatR
8dfcdfe753 pull request #1114 - NetHack.ad remarks about XPM
Pull request from bernhardreiter:  NetHack.ad has a comment about
needing to use an external tool such as XV or PBMplus rather than
the NetHack.double_tile_size resource if nethack is built with the
USE_XPM configuration.  Add some more detail since using 'hints' when
setting up the Makefiles can define that behind the builder's back.

The extra detail won't be useful to players who obtain prebuilt
binaries that incorporate the X11 interface.  The comment in config.h
(see preceding pull request) won't be either, and maybe should be
moved to NetHack.ad where such users will be able to see it.

Fixes #1114.
2023-11-03 02:54:57 -07:00
Bernhard E. Reiter
3a14239be1 doc: add note that USE_XPM can be defined otherwise
* Add an additional hint to win/X11/NetHack.ad that `USE_XPM` can be defined outsite of `config.h` as it is the case with `hints/linux-x11`-
2023-11-03 02:49:01 -07:00
PatR
2476329b2c fix ^ as choice in / menu for tty and X11
It turned out that using '^' as a group accelerator (new behavior for
the 'whatis' command to view traps) already worked for curses and Qt.
Fix that for tty and X11.  I don't know the situation for WinGUI.

Offering any of the menu paging keystrokes as group accelerators
should be avoided if there's any chance that the menu will need more
that one page.  The menu for '/' is short though so losing "^ to go
back to first page" for it isn't an issue.
2023-10-14 17:24:39 -07:00
PatR
6636db94e7 corridor engravings in black and white
The default engraving-in-corridor character is the same as the default
corridor symbol (and also default lit corridor one), distinguished by
color.  Show it differently (in inverse vidoe, like lava vs water and
sink vs fountain) if color is Off.

It might be better to change the engraving-in-room symbol to be the
same as the room one so that they'll be more consistent with corridors;
color is probably sufficient without resorting to back-tick.  But this
update hasn't done that.
2023-09-12 01:34:47 -07:00
nhmall
f625d2efcf more tabs to spaces 2023-08-16 10:22:10 -04:00
nhmall
d4fb34bbb4 system.h 2023-04-23 12:29:02 -04:00
PatR
efd6b4081b build fixes for !TEXTCOLOR
Neither X11 nor Qt would compile with TEXTCOLOR disabled.  With this
they build and seem to work, but no promises, particularly for the
ENHANCED_SYMBOLS config.
2023-04-22 16:37:48 -07:00
nhmall
826ce951e7 get rid of NetHack macro conflict with curses routine delay_output() 2023-04-21 08:25:53 -04:00
PatR
8a0484321e add flags.silent handling to X11_nhbell() 2023-03-24 14:23:30 -07:00
nhmall
76e82d1312 fix remaining contrived issues re HANGUPHANDLING 2023-03-01 12:01:43 -05:00
nhmall
d1fda1773a fix a warning on Linux for X11 if -std=c99 2023-02-17 16:56:27 -05:00
PatR
a07098b206 X11_hangup()
I was looking at backporting an X11 build fix to 3.6 and decided
that the hangup handling wasn't correct if SAFERHANGUP is defined
(which it is by default).  It didn't attempt to perform a hangup
save.  Also, the handler might return when the X code calling it
expected it to not do so.

I don't know how to force a hangup within X11 so haven't tested
this properly.  It works fine when there's no hangup.  :-/
2023-02-10 15:19:13 -08:00
nhmall
3214335bb5 undefine X11_BUILD after hack.h or config.h
So as not to complicate any onefile efforts by leaving it defined.
2023-02-01 14:04:20 -05:00
nhmall
d4a111083a avoid some issues with c++ and X11 2023-02-01 10:41:04 -05:00
PatR
7c72c1f141 identifying via menu
From the newsgroup:  identifying by menu pops up multiple menus in
succession if the player picks fewer invent entries than are being
granted, but the second and subsequent ones could cover up the
message window and hide the feedback from prior ones.

If multiple popup menus are needed when identifying, issue --More--
before each menu after the first.  The code seemed to be trying to
do this already, but it should have used wait_synch() rather than
mark_synch(), or perhaps used display_nhwindow(WIN_MESSAGE, TRUE)
instead of either one of those.  For curses, both mark_synch() and
wait_synch() were no-ops.  Now they do something.  X11's behavior
wasn't right either; it seemed to be lagging one message behind
(something I had noticed recently and then forgotten about; I still
don't remember the context then so don't know whether this fixes
that earlier situation).
2023-01-09 23:34:32 -08:00
nhmall
32a030c8c6 introduce X11 support for coloring map frame 2023-01-01 20:04:27 -05:00
nhmall
02a48aa8cf split g into multiple structures
The consolidation of global variables from scattered source
files into decl.c and declared in decl.h was begun in 3.7.0.
Their placement in common files was done for centralized
initialization and potential re-initialization during a
"play again" scenario.

It wasn't really necessary for all of them to be housed in a
single huge structure to meet the "play again" requirement,
and the single huge structure has been a little unwieldy when
it comes to maintenance.

Following this commit, instead of one single extremely large structure
named 'g' to house all of the relocated global variables, they
are distributed into several ga through gz.

To make things easy for the developer, each variable is placed
into the struct corresponding to the starting letter of the variable.
That way, no lookup is required in order to know which struct houses
a particular variable, it is a simple match to the starting letter
for all the centralized global variables.

A global variable named 'amulets', would be found in ga.
    ga.amulets
     ^ ^
A global varable named 'move', would be found in gm.
    gm.moves
     ^ ^
A global variable named 'val_for_n_or_more' would be found in gv.
    gv.val_for_n_or_more
     ^ ^
A global variable named 'youmonst' would be found in gy.
    gy.youmonst
     ^ ^
2022-11-29 21:53:21 -05:00
PatR
d957d70d15 reset X11's "interface has been initialized" flag
Reset 'x_inited' after the various widgets have been released
during shutdown.

This might prevent the second panic ('X11_mark_synch()' during
emergency save) in the double panic reported in a later comment of
github issue #569.  It definitely doesn't address whatever caused
the first panic, nor the poor handling of missing fonts that was
apparently responsible for #569's initial report.
2022-11-13 13:12:19 -08:00
PatR
7caa6ab8c7 winX.c
Mostly reformatting, but also initialize all output arguments in
get_window_frame_extents() in case it makes an early return.
2022-11-13 12:43:34 -08:00
nhmall
993a82858b Merge branch 'old-software-compatibility' of https://github.com/chasonr/NetHack into NetHack-3.7 2022-11-05 19:30:20 -04:00
Ray Chason
0322ea9341 Some cleanup for non-ENHANCED_SYMBOLS build 2022-11-05 18:34:44 -04:00
Ray Chason
69d76ed4b6 Free the font structure when done
Also, adjust some comments about not supporting supplementary
characters.
2022-11-05 18:24:02 -04:00
Ray Chason
6754b85294 Set registry ISO10646 at run time
We don't know at compile time whether the X server even supports
Unicode. So take the configured map font, change the registry to
ISO10646 and try the resulting font string. Keep the configured
font if that doesn't work.
2022-11-05 11:56:21 -04:00
Ray Chason
0c7d42c739 Add Unicode, IBMgraphics and DECgraphics to X11 2022-11-05 00:40:04 -04:00
Ray Chason
940c37f13e Add Xlib.h
Gets us running on XFree86 3.3.5
2022-11-03 22:13:52 -04:00
Ray Chason
de32aa74c7 Use "magenta" for bright magenta
Older X servers don't understand "Fuchsia," and NetHack throws
impossibles as a result. The current Xorg defines "magenta" as the
same color as "Fuchsia," namely #FF00FF, and older X servers
understand "magenta."

The resulting X11 NetHack is known to work with XFree86 4.2.0.
The minimum version remains undetermined.
2022-11-03 19:35:41 -04:00
nhmall
99a93fe50b some C99 changes
Instead of using index() macro defined to strchr, use C99 strchr.
Instead of using rindex() macro defined to strrchr, use C99 strrchr.

If you want to try building on a platform that doesn't offer those
two functions, these are available:
    define NOT_C99       /* to make some non-C99 code available */
    define NEED_INDEX    /* to define a macro for index()  */
    define NEED_RINDX    /* to define a macro for rindex() */
2022-10-29 10:54:25 -04:00
nhmall
88f6df2d8b some tabs to spaces
cd src
    grep -P -n '\t' *.c | grep -v "1:"
    cd ../include
    grep -P -n '\t' *.h | grep -v "1:"
    cd ..

side note: win/Qt/*.cpp are full of tabs
2022-10-26 14:21:23 -04:00
PatR
eeb208b3a9 X11 getlin()'s prompt
Reissuing getlin() with a different prompt wasn't reliably resizing the
X11 prompt widget.  After a lot of hacking away at win/X11/dialogs.c I
eventually tried setting the response portion of the widget first and
got much better results, enough to throw away the tentative changes to
dialogs.c.

There's still a lot of room from improvement but I think it would need
to replace the ghostview prompting instead of trying to massage that.
2022-10-25 02:55:49 -07:00
Michael Meyer
44dcf95e04 Fix: X11 extcmd menu heap buffer overflow
Instead of allocating space for ((n + 1) * size) (to make room for all
entries plus terminator), it allocated space for (n * size + 1).
init_extended_commands_popup would therefore write past the end of the
memory allocated for command_list and command_indx when trying to store
their respective terminator entries.  This meant the X11 windowport
would crash when accessing the extended command menu, if NetHack had
been compiled with -fsanitize=address.

I also did some minor cleanup/refactoring to eliminate variables and
lines that were made redundant or useless by 9d64d13, which changed the
way the function worked and removed the need for things like tracking
indices in the source and destination arrays with separate variables.
2022-09-30 08:16:19 -07:00
PatR
f4210542f0 enc_stat[], hu_stat[]
The definition of enc_stat[] got changed by a pull request nearly a
year ago ('const char *enc_stat[]' -> 'const char *const enc_stat[]')
but the separate declarations for it weren't changed to match.

Make the same change for hu_stat[].  Not sure why the pull request
didn't include it since the old declaration and the usage are same.

The curses one is in code that isn't used.
2022-09-10 19:30:36 -07:00
nhmall
c548fff9e4 some spelling corrections
The pull request included some changes that were neither accidental nor
unintentional, so only a subset of the changes from pull request #869
submitted by klorpa were manually applied.

behaviour  -> behavior
speach     -> speech
knowlege   -> knowledge
incrments  -> increments
stethscope -> stethoscope
staiway    -> stairway
arifact    -> artifact
extracing  -> extracting

The uses of "iff" were left alone.

Close #869
2022-09-08 10:54:11 -04:00
nhmall
c0d636fe32 a couple of warnings
invent.c: In function 'getobj':
invent.c:1579:29: warning: 'cnt' may be used uninitialized [-Wmaybe-uninitialized]
 1579 |                 if (cnt < 1 || otmp->quan <= cnt)
      |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~
invent.c:1529:10: note: 'cnt' was declared here
 1529 |     long cnt;
      |          ^~~

../win/X11/winstat.c: In function 'update_fancy_status_field':
../win/X11/winstat.c:1920:28: warning: declaration of 'active' shadows a global declaration [-Wshadow]
 1920 |             static boolean active = FALSE;
      |                            ^~~~~~
In file included from ../include/hack.h:196,
                 from ../win/X11/winstat.c:36:
../include/wintype.h:180:5: note: shadowed declaration is here
  180 |     active           = 0x001,
      |     ^~~~~~
2022-08-13 09:09:10 -04:00
Pasi Kallinen
fd9745f9c6 Command repeating by using cmd queues
This replaces the old pushq/saveq arrays (which were used to save
the keys pressed by the user for repeating a previous command)
with a new command queue.  This means there's no hard-coded limit
to the saved keys, and it can repeat extended commands which are
not bound to any key.
2022-08-09 11:54:45 +03:00