couple of curses symbol handling bits

Primary and rogue symbols were being set to default if primary hadn't
been given a value, possibly clobbering rogue symbols if those had
been given a value.  Initialize them independenly.

Return early from curses_convert_glyph() if the value doesn't have
the 8th bit set since it now deals exclusively with DECgraphics
handling.  Force a sane value for returning early on rogue level.
This commit is contained in:
PatR
2019-10-17 05:07:03 -07:00
parent 3e368b9a51
commit 61b976e0d5
2 changed files with 28 additions and 17 deletions

View File

@@ -785,10 +785,11 @@ curses_init_options()
set_option_mod_status("eight_bit_tty", SET_IN_FILE);
/* If we don't have a symset defined, load the curses symset by default */
if (symset[PRIMARY].fallback) {
if (symset[PRIMARY].fallback)
load_symset("curses", PRIMARY);
if (symset[ROGUESET].fallback)
load_symset("default", ROGUESET);
}
#ifdef PDCURSES
/* PDCurses for SDL, win32 and OS/2 has the ability to set the
terminal size programatically. If the user does not specify a

View File

@@ -472,21 +472,29 @@ curses_convert_glyph(int ch, int glyph)
because 0x7f is effectively a control character (Rubout);
nethack ORs 0x80 to flag line drawing--that's stripped below */
static int decchars[33]; /* for chars 0x5f through 0x7f (95..127) */
int symbol;
/* FIXME? we don't support any special characters in roguesymset */
if (Is_rogue_level(&u.uz))
ch &= 0xff; /* 0..255 only */
if (!(ch & 0x80))
return ch; /* no conversion needed */
/* this conversion routine is only called for SYMHANDLING(H_DEC) and
we decline to support special graphics symbols on the rogue level */
if (Is_rogue_level(&u.uz)) {
/* attempting to use line drawing characters will end up being
rendered as lowercase gibberish */
ch &= ~0x80;
return ch;
}
symbol = glyph_to_cmap(glyph);
/* Curses has complete access to all characters that DECgraphics uses.
However, their character value isn't consistent between terminals
and implementations. For actual DEC terminals and faithful emulators,
line-drawing characters are specified as lowercase letters (mostly)
and a control code is sent to the terminal telling it to switch
character sets (that's how the tty interface handles them).
Curses remaps the characters instead. */
/*
* Curses has complete access to all characters that DECgraphics uses.
* However, their character value isn't consistent between terminals
* and implementations. For actual DEC terminals and faithful emulators,
* line-drawing characters are specified as lowercase letters (mostly)
* and a control code is sent to the terminal telling it to switch
* character sets (that's how the tty interface handles them).
* Curses remaps the characters instead.
*/
/* one-time initialization; some ACS_x aren't compile-time constant */
if (!decchars[0]) {
@@ -510,7 +518,7 @@ curses_convert_glyph(int ch, int glyph)
decchars[0x68 - 0x5f] = 'N'; /* [9] "NL" as one char (new line) */
decchars[0x69 - 0x5f] = 'V'; /* [10] "VT" as one (vertical tab) */
decchars[0x6a - 0x5f] = ACS_LRCORNER; /* lower right corner */
decchars[0x6b - 0x5f] = ACS_URCORNER; /* upper right corner */
decchars[0x6b - 0x5f] = ACS_URCORNER; /* upper right corner, 7-ish */
decchars[0x6c - 0x5f] = ACS_ULCORNER; /* upper left corner */
decchars[0x6d - 0x5f] = ACS_LLCORNER; /* lower left corner, 'L' */
/* [15] center cross, like big '+' sign */
@@ -554,7 +562,7 @@ curses_convert_glyph(int ch, int glyph)
/* high bit set means special handling */
if (ch & 0x80) {
int convindx;
int convindx, symbol;
ch &= ~0x80; /* force plain ASCII for last resort */
convindx = ch - 0x5f;
@@ -565,8 +573,10 @@ curses_convert_glyph(int ch, int glyph)
/* in case ACS_foo maps to 0 when current terminal is unable
to handle a particular character; if so, revert to default
rather than using DECgr value with high bit stripped */
if (!ch)
if (!ch) {
symbol = glyph_to_cmap(glyph);
ch = (int) defsyms[symbol].sym;
}
}
}