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:
@@ -280,6 +280,15 @@
|
||||
*/
|
||||
/* #define NODUMPENUMS */
|
||||
|
||||
/*
|
||||
* ENHANCED_SYMBOLS
|
||||
* Support the enhanced display of symbols by utilizing utf8 and 24-bit
|
||||
* color sequences. Enabled by default, but it can be disabled by
|
||||
* commenting it out.
|
||||
*/
|
||||
|
||||
#define ENHANCED_SYMBOLS
|
||||
|
||||
/*
|
||||
* If COMPRESS is defined, it should contain the full path name of your
|
||||
* 'compress' program.
|
||||
|
||||
@@ -434,7 +434,10 @@ E const char *ARGV0;
|
||||
enum earlyarg {ARG_DEBUG, ARG_VERSION, ARG_SHOWPATHS
|
||||
#ifndef NODUMPENUMS
|
||||
, ARG_DUMPENUMS
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
, ARG_DUMPGLYPHIDS
|
||||
#endif
|
||||
#endif /* NODUMPENUMS */
|
||||
#ifdef WIN32
|
||||
,ARG_WINDOWS
|
||||
#endif
|
||||
@@ -679,6 +682,11 @@ struct _cmd_queue {
|
||||
struct _cmd_queue *next;
|
||||
};
|
||||
|
||||
struct enum_dump {
|
||||
int val;
|
||||
const char *nm;
|
||||
};
|
||||
|
||||
typedef long cmdcount_nht; /* Command counts */
|
||||
|
||||
/*
|
||||
@@ -888,8 +896,11 @@ struct instance_globals {
|
||||
struct rm nowhere;
|
||||
const char *gate_str;
|
||||
|
||||
/* drawing */
|
||||
/* symbols.c */
|
||||
struct symsetentry symset[NUM_GRAPHICS];
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
struct symset_customization sym_customizations[NUM_GRAPHICS + 1]; /* adds UNICODESET */
|
||||
#endif
|
||||
int currentgraphics;
|
||||
nhsym showsyms[SYM_MAX]; /* symbols to be displayed */
|
||||
nhsym primary_syms[SYM_MAX]; /* loaded primary symbols */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -237,6 +237,8 @@ struct instance_flags {
|
||||
int menuinvertmode; /* 0 = invert toggles every item;
|
||||
1 = invert skips 'all items' item */
|
||||
int menu_headings; /* ATR for menu headings */
|
||||
uint32_t colorcount; /* store how many colors terminal is capable of */
|
||||
boolean use_truecolor; /* force use of truecolor */
|
||||
#ifdef ALTMETA
|
||||
boolean altmeta; /* Alt-c sends ESC c rather than M-c */
|
||||
#endif
|
||||
@@ -389,7 +391,7 @@ struct instance_flags {
|
||||
Bitfield(save_uinwater, 1);
|
||||
Bitfield(save_uburied, 1);
|
||||
struct debug_flags debug;
|
||||
boolean windowtype_locked; /* windowtype can't change from configfile */
|
||||
boolean windowtype_locked; /* windowtype can't change from configfile */
|
||||
boolean windowtype_deferred; /* pick a windowport and store it in
|
||||
chosen_windowport[], but do not switch to
|
||||
it in the midst of options processing */
|
||||
|
||||
@@ -183,6 +183,7 @@ typedef struct {
|
||||
|
||||
#include "align.h"
|
||||
#include "dungeon.h"
|
||||
#include "wintype.h"
|
||||
#include "sym.h"
|
||||
#include "mkroom.h"
|
||||
|
||||
@@ -199,7 +200,6 @@ enum misc_arti_nums {
|
||||
|
||||
#include "objclass.h"
|
||||
#include "youprop.h"
|
||||
#include "wintype.h"
|
||||
#include "context.h"
|
||||
#include "rm.h"
|
||||
#include "botl.h"
|
||||
|
||||
@@ -218,6 +218,8 @@ opt_##a,
|
||||
&iflags.wc2_fullscreen)
|
||||
NHOPTC(gender, 8, opt_in, set_gameview, No, Yes, No, No, NoAlias,
|
||||
"your starting gender (male or female)")
|
||||
NHOPTC(glyph, 40, opt_in, set_in_game, No, Yes, Yes, No, NoAlias,
|
||||
"set representation of a glyph to a unicode value and color")
|
||||
NHOPTB(goldX, 0, opt_in, set_in_game, Off, Yes, No, No, NoAlias,
|
||||
&flags.goldX)
|
||||
NHOPTB(guicolor, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias,
|
||||
@@ -521,6 +523,8 @@ opt_##a,
|
||||
&iflags.wc2_darkgray)
|
||||
NHOPTB(use_inverse, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias,
|
||||
&iflags.wc_inverse)
|
||||
NHOPTB(use_truecolor, 0, opt_in, set_in_config, Off, Yes, No, No,
|
||||
"use_truecolour", &iflags.use_truecolor)
|
||||
NHOPTC(vary_msgcount, 20, opt_in, set_gameview, No, Yes, No, No, NoAlias,
|
||||
"show more old messages at a time")
|
||||
NHOPTB(verbose, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias,
|
||||
|
||||
@@ -25,7 +25,6 @@ enum mon_syms {
|
||||
};
|
||||
|
||||
#ifndef MAKEDEFS_C
|
||||
|
||||
/* Default characters for dungeon surroundings and furniture */
|
||||
enum cmap_symbols {
|
||||
#define PCHAR_S_ENUM
|
||||
@@ -34,6 +33,22 @@ enum cmap_symbols {
|
||||
MAXPCHARS
|
||||
};
|
||||
|
||||
/*
|
||||
* special symbol set handling types ( for invoking callbacks, etc.)
|
||||
* Must match the order of the known_handlers strings
|
||||
* in drawing.c
|
||||
*/
|
||||
|
||||
enum symset_handling_types {
|
||||
H_UNK = 0,
|
||||
H_IBM = 1,
|
||||
H_DEC = 2,
|
||||
H_CURS = 3,
|
||||
H_MAC = 4, /* obsolete; needed so that the listing of available
|
||||
* symsets by 'O' can skip it for !MAC_GRAPHICS_ENV */
|
||||
H_UTF8 = 5
|
||||
};
|
||||
|
||||
struct symdef {
|
||||
uchar sym;
|
||||
const char *explanation;
|
||||
@@ -51,7 +66,7 @@ enum symparse_range {
|
||||
};
|
||||
|
||||
struct symparse {
|
||||
unsigned range;
|
||||
enum symparse_range range;
|
||||
int idx;
|
||||
const char *name;
|
||||
};
|
||||
@@ -62,7 +77,7 @@ struct symsetentry {
|
||||
char *name; /* ptr to symset name */
|
||||
char *desc; /* ptr to description */
|
||||
int idx; /* an index value */
|
||||
int handling; /* known handlers value */
|
||||
enum symset_handling_types handling; /* known handlers value */
|
||||
Bitfield(nocolor, 1); /* don't use color if set */
|
||||
Bitfield(primary, 1); /* restricted for use as primary set */
|
||||
Bitfield(rogue, 1); /* restricted for use as rogue lev set */
|
||||
@@ -109,25 +124,41 @@ enum misc_symbols {
|
||||
*/
|
||||
#define DEFAULT_GRAPHICS 0 /* regular characters: '-', '+', &c */
|
||||
enum graphics_sets {
|
||||
PRIMARY = 0, /* primary graphics set */
|
||||
PRIMARYSET = 0, /* primary graphics set */
|
||||
ROGUESET = 1, /* rogue graphics set */
|
||||
NUM_GRAPHICS
|
||||
NUM_GRAPHICS,
|
||||
UNICODESET = NUM_GRAPHICS
|
||||
};
|
||||
|
||||
/*
|
||||
* special symbol set handling types ( for invoking callbacks, etc.)
|
||||
* Must match the order of the known_handlers strings
|
||||
* in drawing.c
|
||||
*/
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
enum customization_types { custom_none, custom_symbols, custom_ureps };
|
||||
|
||||
enum symset_handling_types {
|
||||
H_UNK = 0,
|
||||
H_IBM = 1,
|
||||
H_DEC = 2,
|
||||
H_CURS = 3,
|
||||
H_MAC = 4 /* obsolete; needed so that the listing of available
|
||||
* symsets by 'O' can skip it for !MAC_GRAPHICS_ENV */
|
||||
struct custom_symbol {
|
||||
const struct symparse *symparse;
|
||||
unsigned char val;
|
||||
};
|
||||
struct custom_urep {
|
||||
int glyphidx;
|
||||
struct unicode_representation u;
|
||||
};
|
||||
union customization_content {
|
||||
struct custom_symbol sym;
|
||||
struct custom_urep urep;
|
||||
};
|
||||
struct customization_detail {
|
||||
union customization_content content;
|
||||
struct customization_detail *next;
|
||||
};
|
||||
|
||||
|
||||
/* one set per symset_name */
|
||||
struct symset_customization {
|
||||
const char *customization_name;
|
||||
int count;
|
||||
int custtype;
|
||||
struct customization_detail *details;
|
||||
};
|
||||
#endif /* ENHANCED_SYMBOLS */
|
||||
|
||||
extern const struct symdef defsyms[MAXPCHARS]; /* defaults */
|
||||
#define WARNCOUNT 6 /* number of different warning levels */
|
||||
|
||||
@@ -127,8 +127,14 @@ extern void curses_refresh_nethack_windows(void);
|
||||
extern void curses_del_nhwin(winid wid);
|
||||
extern void curses_del_wid(winid wid);
|
||||
extern void curs_destroy_all_wins(void);
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
extern void curses_putch(winid wid, int x, int y, int ch,
|
||||
int color, int attrs);
|
||||
struct unicode_representation *u, int color,
|
||||
int attrs);
|
||||
#else
|
||||
extern void curses_putch(winid wid, int x, int y, int ch, int color,
|
||||
int attrs);
|
||||
#endif
|
||||
extern void curses_get_window_size(winid wid, int *height, int *width);
|
||||
extern boolean curses_window_has_border(winid wid);
|
||||
extern boolean curses_window_exists(winid wid);
|
||||
|
||||
@@ -231,8 +231,10 @@ extern
|
||||
* 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 */
|
||||
/* 15 free bits */
|
||||
#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 */
|
||||
/* 13 free bits */
|
||||
|
||||
#define ALIGN_LEFT 1
|
||||
#define ALIGN_RIGHT 2
|
||||
|
||||
@@ -78,6 +78,7 @@ struct DisplayDesc {
|
||||
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 */
|
||||
};
|
||||
|
||||
#endif /* WINDOW_STRUCTS */
|
||||
@@ -165,6 +166,10 @@ E void term_end_raw_bold(void);
|
||||
E void term_end_color(void);
|
||||
E void term_start_color(int color);
|
||||
#endif /* TEXTCOLOR */
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
extern void term_start_24bitcolor(struct unicode_representation *);
|
||||
extern void term_end_24bitcolor(void); /* termcap.c, consoletty.c */
|
||||
#endif
|
||||
|
||||
/* ### topl.c ### */
|
||||
|
||||
@@ -182,6 +187,11 @@ E void setclipped(void);
|
||||
E void docorner(int, int);
|
||||
E void end_glyphout(void);
|
||||
E void g_putch(int);
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
#if defined(WIN32) || defined(UNIX)
|
||||
E void g_pututf8(uint8 *);
|
||||
#endif
|
||||
#endif /* ENHANCED_SYMBOLS */
|
||||
E void win_tty_init(int);
|
||||
|
||||
/* external declarations */
|
||||
@@ -200,6 +210,7 @@ E void tty_dismiss_nhwindow(winid);
|
||||
E void tty_destroy_nhwindow(winid);
|
||||
E void tty_curs(winid, int, int);
|
||||
E void tty_putstr(winid, int, const char *);
|
||||
E void tty_putmixed(winid window, int attr, const char *str);
|
||||
E void tty_display_file(const char *, boolean);
|
||||
E void tty_start_menu(winid, unsigned long);
|
||||
E void tty_add_menu(winid, const glyph_info *, const ANY_P *, char, char,
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef WINTYPE_H
|
||||
#define WINTYPE_H
|
||||
|
||||
#include "integer.h"
|
||||
|
||||
typedef int winid; /* a window identifier */
|
||||
|
||||
/* generic parameter - must not be any larger than a pointer */
|
||||
@@ -60,15 +62,28 @@ typedef struct mi {
|
||||
} menu_item;
|
||||
#define MENU_ITEM_P struct mi
|
||||
|
||||
/* These would be in display.h if they weren't needed to define
|
||||
the windowproc interface for X11 which doesn't seem to include
|
||||
the main NetHack header files */
|
||||
/* These would be in sym.h and display.h if they weren't needed to
|
||||
define the windowproc interface for X11 which doesn't include
|
||||
most of the main NetHack header files */
|
||||
|
||||
typedef struct glyph_map_entry {
|
||||
struct classic_representation {
|
||||
int color;
|
||||
int symidx;
|
||||
};
|
||||
|
||||
struct unicode_representation {
|
||||
uint32 ucolor;
|
||||
uint16 u256coloridx;
|
||||
uint8 *utf8str;
|
||||
};
|
||||
|
||||
typedef struct glyph_map_entry {
|
||||
unsigned glyphflags;
|
||||
struct classic_representation sym;
|
||||
short int tileidx;
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
struct unicode_representation *u;
|
||||
#endif
|
||||
} glyph_map;
|
||||
|
||||
/* glyph plus additional info
|
||||
|
||||
Reference in New Issue
Block a user