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
This commit is contained in:
@@ -54,7 +54,8 @@
|
||||
#define DRAGON_SILVER CLR_BRIGHT_CYAN
|
||||
#define HI_ZAP CLR_BRIGHT_BLUE
|
||||
|
||||
#define NH_BASIC_COLOR 0x1000000
|
||||
#define NH_BASIC_COLOR 0x1000000
|
||||
#define COLORVAL(x) ((x) & 0xFFFFFF)
|
||||
|
||||
enum nhcolortype { no_color, nh_color, rgb_color };
|
||||
|
||||
|
||||
@@ -890,9 +890,8 @@ struct instance_globals_s {
|
||||
|
||||
/* symbols.c */
|
||||
struct symsetentry symset[NUM_GRAPHICS];
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
struct symset_customization sym_customizations[NUM_GRAPHICS + 1]; /* adds UNICODESET */
|
||||
#endif
|
||||
/* adds UNICODESET */
|
||||
struct symset_customization sym_customizations[NUM_GRAPHICS + 1][custom_count];
|
||||
nhsym showsyms[SYM_MAX]; /* symbols to be displayed */
|
||||
|
||||
/* files.c */
|
||||
|
||||
@@ -318,6 +318,11 @@ extern void free_menu_coloring(void);
|
||||
extern int count_menucolors(void);
|
||||
extern int32 check_enhanced_colors(char *) NONNULLARG1;
|
||||
extern const char *wc_color_name(int32) NONNULL;
|
||||
extern int32_t rgbstr_to_int32(const char *rgbstr);
|
||||
extern boolean closest_color(uint32_t lcolor, uint32_t *closecolor, int *clridx);
|
||||
extern int color_distance(uint32_t, uint32_t);
|
||||
extern boolean onlyhexdigits(const char *buf);
|
||||
extern uint32 get_nhcolor_from_256_index(int idx);
|
||||
|
||||
/* ### cmd.c ### */
|
||||
|
||||
@@ -1079,6 +1084,29 @@ extern void getpos_sethilite(void(*f)(boolean), boolean(*d)(coordxy,coordxy));
|
||||
extern boolean mapxy_valid(coordxy, coordxy);
|
||||
extern boolean gather_locs_interesting(coordxy, coordxy, int);
|
||||
|
||||
/* ### glyphs.c ### */
|
||||
|
||||
extern int glyphrep_to_custom_map_entries(const char *op,
|
||||
int *glyph) NONNULLPTRS;
|
||||
extern int add_custom_urep_entry(const char *symset_name, int glyphidx,
|
||||
uint32 utf32ch, const uint8 *utf8str,
|
||||
enum graphics_sets which_set) NONNULLARG1;
|
||||
extern int add_custom_nhcolor_entry(const char *customization_name,
|
||||
int glyphidx, uint32 nhcolor,
|
||||
enum graphics_sets which_set) NONNULLARG1;
|
||||
int set_map_nhcolor(glyph_map *gm, uint32 nhcolor) NONNULLARG1;
|
||||
extern int unicode_val(const char *);
|
||||
extern int glyphrep(const char *) NONNULLARG1;
|
||||
extern int match_glyph(char *) NONNULLARG1;
|
||||
extern void dump_all_glyphids(FILE *fp) NONNULLARG1;
|
||||
extern void fill_glyphid_cache(void);
|
||||
extern void free_glyphid_cache(void);
|
||||
extern boolean glyphid_cache_status(void);
|
||||
extern void apply_customizations(enum graphics_sets which_set);
|
||||
extern void purge_custom_entries(enum graphics_sets which_set);
|
||||
extern void purge_all_custom_entries(void);
|
||||
extern void dump_glyphids(void);
|
||||
|
||||
/* ### hack.c ### */
|
||||
|
||||
extern boolean is_valid_travelpt(coordxy, coordxy);
|
||||
@@ -1399,9 +1427,6 @@ extern void runtime_info_init(void);
|
||||
extern const char *do_runtime_info(int *) NO_NNARGS;
|
||||
extern void release_runtime_info(void);
|
||||
extern char *mdlib_version_string(char *, const char *) NONNULL NONNULLPTRS;
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
extern void dump_glyphids(void);
|
||||
#endif
|
||||
|
||||
/* ### mhitm.c ### */
|
||||
|
||||
@@ -3002,12 +3027,7 @@ extern const struct symparse *match_sym(char *) NONNULLARG1;
|
||||
extern void savedsym_free(void);
|
||||
extern void savedsym_strbuf(strbuf_t *) NONNULLARG1;
|
||||
extern boolean parsesymbols(char *, int) NONNULLARG1;
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
extern struct customization_detail *find_matching_symset_customiz(
|
||||
const char *symset_name, int custtype,
|
||||
enum graphics_sets which_set) NONNULLARG1;
|
||||
extern void apply_customizations_to_symset(enum graphics_sets which_set);
|
||||
#endif
|
||||
extern void clear_all_glyphmap_colors(void);
|
||||
|
||||
/* ### sys.c ### */
|
||||
|
||||
@@ -3353,21 +3373,10 @@ extern int hide_privileges(boolean);
|
||||
/* ### utf8map.c ### */
|
||||
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
extern int glyphrep(const char *) NONNULLARG1;
|
||||
extern char *mixed_to_utf8(char *buf, size_t bufsz, const char *str,
|
||||
int *) NONNULLARG1;
|
||||
extern int match_glyph(char *) NONNULLARG1;
|
||||
extern void dump_all_glyphids(FILE *fp) NONNULLARG1;
|
||||
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) NONNULLPTRS;
|
||||
void free_all_glyphmap_u(void);
|
||||
int add_custom_urep_entry(const char *symset_name, int glyphidx,
|
||||
uint32 utf32ch, const uint8 *utf8str, long ucolor,
|
||||
enum graphics_sets which_set) NONNULLARG1;
|
||||
int set_map_u(glyph_map *gm, uint32 utf32ch, const uint8 *utf8str,
|
||||
long ucolor) NONNULLPTRS;
|
||||
int set_map_u(glyph_map *gm, uint32 utf32ch, const uint8 *utf8str) NONNULLPTRS;
|
||||
#endif /* ENHANCED_SYMBOLS */
|
||||
|
||||
/* ### vault.c ### */
|
||||
|
||||
@@ -412,9 +412,7 @@ enum earlyarg {
|
||||
#ifndef NODUMPENUMS
|
||||
, ARG_DUMPENUMS
|
||||
#endif
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
, ARG_DUMPGLYPHIDS
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
, ARG_WINDOWS
|
||||
#endif
|
||||
|
||||
@@ -129,8 +129,8 @@ enum graphics_sets {
|
||||
UNICODESET = NUM_GRAPHICS
|
||||
};
|
||||
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
enum customization_types { custom_none, custom_symbols, custom_ureps };
|
||||
enum customization_types { custom_none, custom_symbols,
|
||||
custom_ureps, custom_nhcolor, custom_count };
|
||||
|
||||
struct custom_symbol {
|
||||
const struct symparse *symparse;
|
||||
@@ -140,9 +140,14 @@ struct custom_urep {
|
||||
int glyphidx;
|
||||
struct unicode_representation u;
|
||||
};
|
||||
struct custom_nhcolor {
|
||||
int glyphidx;
|
||||
uint32 nhcolor;
|
||||
};
|
||||
union customization_content {
|
||||
struct custom_symbol sym;
|
||||
struct custom_urep urep;
|
||||
struct custom_nhcolor ccolor;
|
||||
};
|
||||
struct customization_detail {
|
||||
union customization_content content;
|
||||
@@ -154,11 +159,10 @@ struct customization_detail {
|
||||
struct symset_customization {
|
||||
const char *customization_name;
|
||||
int count;
|
||||
int custtype;
|
||||
enum customization_types custtype;
|
||||
struct customization_detail *details;
|
||||
struct customization_detail *details_end;
|
||||
};
|
||||
#endif /* ENHANCED_SYMBOLS */
|
||||
|
||||
extern const struct symdef defsyms[MAXPCHARS + 1]; /* defaults */
|
||||
#define WARNCOUNT 6 /* number of different warning levels */
|
||||
|
||||
@@ -260,13 +260,13 @@ extern
|
||||
#define WC2_GUICOLOR 0x2000L /* 14 display colours outside map win */
|
||||
/* pline() can overload the display attributes argument passed to putstr()
|
||||
with one or more flags and at most one of bold/blink/inverse/&c */
|
||||
#define WC2_URGENT_MESG 0x4000L /* 15 putstr(WIN_MESSAGE) supports urgency
|
||||
* via non-display attribute flag */
|
||||
#define WC2_SUPPRESS_HIST 0x8000L /* 16 putstr(WIN_MESSAGE) supports history
|
||||
* suppression via non-disp attr */
|
||||
#define WC2_URGENT_MESG 0x4000L /* 15 putstr(WIN_MESSAGE) supports urgency
|
||||
* via non-display attribute flag */
|
||||
#define WC2_SUPPRESS_HIST 0x8000L /* 16 putstr(WIN_MESSAGE) supports history
|
||||
* suppression via non-disp attr */
|
||||
#define WC2_MENU_SHIFT 0x010000L /* 17 horizontal menu scrolling */
|
||||
#define WC2_U_UTF8STR 0x020000L /* 18 utf8str support */
|
||||
#define WC2_U_24BITCOLOR 0x040000L /* 19 24-bit color support available */
|
||||
#define WC2_EXTRACOLORS 0x040000L /* 19 color support beyond NH_BASIC_COLOR */
|
||||
/* 13 free bits */
|
||||
|
||||
#define ALIGN_LEFT 1
|
||||
|
||||
@@ -88,20 +88,21 @@ struct WinDesc {
|
||||
|
||||
/* descriptor for tty-based displays -- all the per-display data */
|
||||
struct DisplayDesc {
|
||||
short rows, cols; /* width and height of tty display */
|
||||
short curx, cury; /* current cursor position on the screen */
|
||||
int color; /* current color */
|
||||
uint32 framecolor; /* current background color */
|
||||
int attrs; /* attributes in effect */
|
||||
int toplin; /* flag for topl stuff */
|
||||
int rawprint; /* number of raw_printed lines since synch */
|
||||
int inmore; /* non-zero if more() is active */
|
||||
int inread; /* non-zero if reading a character */
|
||||
int intr; /* non-zero if inread was interrupted */
|
||||
winid lastwin; /* last window used for I/O */
|
||||
char dismiss_more; /* extra character accepted at --More-- */
|
||||
int topl_utf8; /* non-zero if utf8 in str */
|
||||
int mixed; /* we are processing mixed output */
|
||||
short rows, cols; /* width and height of tty display */
|
||||
short curx, cury; /* current cursor position on the screen */
|
||||
uint32 color; /* current color */
|
||||
uint32 colorflags; /* NH_BASIC_COLOR or 24-bit color */
|
||||
uint32 framecolor; /* current background color */
|
||||
int attrs; /* attributes in effect */
|
||||
int toplin; /* flag for topl stuff */
|
||||
int rawprint; /* number of raw_printed lines since synch */
|
||||
int inmore; /* non-zero if more() is active */
|
||||
int inread; /* non-zero if reading a character */
|
||||
int intr; /* non-zero if inread was interrupted */
|
||||
winid lastwin; /* last window used for I/O */
|
||||
char dismiss_more; /* extra character accepted at --More-- */
|
||||
int topl_utf8; /* non-zero if utf8 in str */
|
||||
int mixed; /* we are processing mixed output */
|
||||
};
|
||||
|
||||
#endif /* WINDOW_STRUCTS */
|
||||
@@ -188,10 +189,9 @@ extern void term_end_raw_bold(void);
|
||||
extern void term_end_color(void);
|
||||
extern void term_start_color(int color);
|
||||
extern void term_start_bgcolor(int color);
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
extern void term_start_24bitcolor(struct unicode_representation *);
|
||||
extern void term_end_24bitcolor(void); /* termcap.c, consoletty.c */
|
||||
#endif
|
||||
extern void term_start_extracolor(uint32 nhcolor);
|
||||
extern void term_end_extracolor(void); /* termcap.c, consoletty.c */
|
||||
extern void term_start_256color(int idx);
|
||||
|
||||
/* ### topl.c ### */
|
||||
|
||||
|
||||
@@ -76,8 +76,6 @@ struct classic_representation {
|
||||
};
|
||||
|
||||
struct unicode_representation {
|
||||
uint32 ucolor;
|
||||
uint16 u256coloridx;
|
||||
uint32 utf32ch;
|
||||
uint8 *utf8str;
|
||||
};
|
||||
@@ -85,6 +83,7 @@ struct unicode_representation {
|
||||
typedef struct glyph_map_entry {
|
||||
unsigned glyphflags;
|
||||
struct classic_representation sym;
|
||||
uint32 nhcolor;
|
||||
short int tileidx;
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
struct unicode_representation *u;
|
||||
|
||||
Reference in New Issue
Block a user