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:
@@ -1378,4 +1378,49 @@ FITSuint_(unsigned long long i, const char *file, int line){
|
||||
return (unsigned)i;
|
||||
}
|
||||
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
|
||||
/* Unicode routines */
|
||||
|
||||
int
|
||||
unicodeval_to_utf8str(int uval, uint8 *buffer, size_t bufsz)
|
||||
{
|
||||
// static uint8 buffer[7];
|
||||
uint8 *b = buffer;
|
||||
|
||||
if (bufsz < 5)
|
||||
return 0;
|
||||
/*
|
||||
* Binary Hex Comments
|
||||
* 0xxxxxxx 0x00..0x7F Only byte of a 1-byte character encoding
|
||||
* 10xxxxxx 0x80..0xBF Continuation byte : one of 1-3 bytes following
|
||||
* first 110xxxxx 0xC0..0xDF First byte of a 2-byte character encoding
|
||||
* 1110xxxx 0xE0..0xEF First byte of a 3-byte character encoding
|
||||
* 11110xxx 0xF0..0xF7 First byte of a 4-byte character encoding
|
||||
*/
|
||||
*b = '\0';
|
||||
if (uval < 0x80) {
|
||||
*b++ = uval;
|
||||
} else if (uval < 0x800) {
|
||||
*b++ = 192 + uval / 64;
|
||||
*b++ = 128 + uval % 64;
|
||||
} else if (uval - 0xd800u < 0x800) {
|
||||
return 0;
|
||||
} else if (uval < 0x10000) {
|
||||
*b++ = 224 + uval / 4096;
|
||||
*b++ = 128 + uval / 64 % 64;
|
||||
*b++ = 128 + uval % 64;
|
||||
} else if (uval < 0x110000) {
|
||||
*b++ = 240 + uval / 262144;
|
||||
*b++ = 128 + uval / 4096 % 64;
|
||||
*b++ = 128 + uval / 64 % 64;
|
||||
*b++ = 128 + uval % 64;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
*b = '\0'; /* NUL terminate */
|
||||
return 1;
|
||||
}
|
||||
#endif /* ENHANCED_SYMBOLS */
|
||||
|
||||
/*hacklib.c*/
|
||||
|
||||
Reference in New Issue
Block a user