ENHANCED_SYMBOLS

A new feature, enabled by default to maximize testing, but one which can
be disabled by commenting it out in config.h

With this, some additional information is added to the glyphmap entries
in a new optional substructure called u with these fields:
    ucolor          RGB color for use with truecolor terminals/platforms.
                    A ucolor value of zero means "not set." The actual
                    rgb value of 0 has the 0x1000000 bit set.
    u256coloridx    256 color index value for use with 256 color
                    terminals, the closest color match to ucolor.
    utf8str         Custom representation via utf-8 string (can be null).

There is a new symset included in the symbols file, called enhanced1.

Some initial code has been added to parse individual
OPTIONS=glyph:glyphid/R-G-B entries in the config file.

The glyphid can, in theory, either be an individual glyph (G_* glyphid)
for a single glyph, or it can be an existing symbol S_ value
(monster, object, or cmap symbol) to store the custom representation for
all the glyphs that match that symbol.

Examples:
   OPTIONS=glyph:G_fountain/U+03A8/0-150-255

(Your platform/terminal font needs to be able to include/display the
character, of course.)

The NetHack core code does parsing and storing the customized
entries, and adding them to the glyphmap data structure.

Any window port can utilize the additional information in the glyphinfo
that is passed to them, once code is added to do so.

Also, consolidate some symbol-related code into symbols.c, and remove it from
files.c and options.c
This commit is contained in:
nhmall
2022-05-07 10:25:13 -04:00
parent 132e1d433a
commit cb0c21e91d
50 changed files with 3072 additions and 1242 deletions

View File

@@ -1047,6 +1047,9 @@ extern void nh_snprintf(const char *func, int line, char *str, size_t size,
extern int FITSint_(long long, const char *, int);
#define FITSuint(x) FITSuint_(x, __func__, __LINE__)
extern unsigned FITSuint_(unsigned long long, const char *, int);
#ifdef ENHANCED_SYMBOLS
extern int unicodeval_to_utf8str(int, uint8 *, size_t);
#endif
/* ### insight.c ### */
@@ -1281,6 +1284,9 @@ extern int buzzmu(struct monst *, struct attack *);
extern void runtime_info_init(void);
extern const char *do_runtime_info(int *);
extern void release_runtime_info(void);
#ifdef ENHANCED_SYMBOLS
extern void dump_glyphids(void);
#endif
/* ### mhitm.c ### */
@@ -1828,6 +1834,10 @@ extern void synch_cursor(void);
extern void nethack_enter_consoletty(void);
extern void consoletty_exit(void);
extern int set_keyhandling_via_option(void);
#ifdef ENHANCED_SYMBOLS
extern void tty_utf8graphics_fixup(void);
extern void tty_ibmgraphics_fixup(void);
#endif /* ENHANCED_SYMBOLS */
#endif /* WIN32 */
/* ### o_init.c ### */
@@ -1947,10 +1957,6 @@ extern void set_wc2_option_mod_status(unsigned long, int);
extern void set_option_mod_status(const char *, int);
extern int add_autopickup_exception(const char *);
extern void free_autopickup_exceptions(void);
extern int load_symset(const char *, int);
extern void free_symsets(void);
extern boolean parsesymbols(char *, int);
extern struct symparse *match_sym(char *);
extern void set_playmode(void);
extern int sym_val(const char *);
extern int query_color(const char *);
@@ -2623,11 +2629,25 @@ extern void init_rogue_symbols(void);
extern void init_ov_primary_symbols(void);
extern void init_ov_rogue_symbols(void);
extern void clear_symsetentry(int, boolean);
extern void update_primary_symset(struct symparse *, int);
extern void update_rogue_symset(struct symparse *, int);
extern void update_ov_primary_symset(struct symparse *, int);
extern void update_ov_rogue_symset(struct symparse *, int);
extern void update_primary_symset(const struct symparse *, int);
extern void update_rogue_symset(const struct symparse *, int);
extern void update_ov_primary_symset(const struct symparse *, int);
extern void update_ov_rogue_symset(const struct symparse *, int);
extern nhsym get_othersym(int, int);
extern boolean symset_is_compatible(enum symset_handling_types, unsigned long);
extern void set_symhandling(char *handling, int which_set);
extern boolean proc_symset_line(char *);
extern int do_symset(boolean);
extern int load_symset(const char *, int);
extern void free_symsets(void);
extern const struct symparse *match_sym(char *);
extern boolean parsesymbols(char *, int);
#ifdef ENHANCED_SYMBOLS
extern struct customization_detail *find_matching_symset_customization(
const char *symset_name, int custtype,
enum graphics_sets which_set);
extern void apply_customizations_to_symset(enum graphics_sets which_set);
#endif
/* ### sys.c ### */
@@ -2910,6 +2930,9 @@ extern void setftty(void);
extern void intron(void);
extern void introff(void);
extern void error (const char *, ...) PRINTF_F(1, 2);
#ifdef ENHANCED_SYMBOLS
extern void tty_utf8graphics_fixup(void);
#endif
#endif /* UNIX || __BEOS__ */
/* ### unixunix.c ### */
@@ -2939,6 +2962,24 @@ extern int hide_privileges(boolean);
#endif
#endif /* UNIX */
/* ### utf8map.c ### */
#ifdef ENHANCED_SYMBOLS
extern int glyphrep(const char *);
extern char *mixed_to_utf8(char *buf, size_t bufsz, const char *str, int *);
extern int match_glyph(char *);
extern void dump_all_glyphids(FILE *fp);
extern void fill_glyphid_cache(void);
extern void free_glyphid_cache(void);
extern boolean glyphid_cache_status(void);
extern int glyphrep_to_custom_map_entries(const char *op, int *glyph);
void free_all_glyphmap_u(void);
int add_custom_urep_entry(const char *symset_name, int glyphidx,
const uint8 *utf8str, long ucolor,
enum graphics_sets which_set);
int set_map_u(glyph_map *gm, const uint8 *utf8str, long ucolor);
#endif /* ENHANCED_SYMBOLS */
/* ### vault.c ### */
extern void newegd(struct monst *);
@@ -3191,6 +3232,7 @@ extern int has_color(int);
extern int glyph2ttychar(int);
extern int glyph2symidx(int);
extern char *encglyph(int);
extern int decode_glyph(const char *str, int *glyph_ptr);
extern char *decode_mixed(char *, const char *);
extern void genl_putmixed(winid, int, const char *);
extern boolean menuitem_invert_test(int, unsigned, boolean);