tty and curses: support italic as text attribute

This commit is contained in:
Patric Mueller
2022-09-04 22:33:25 +02:00
parent 601dba5279
commit 8bf5654eed
5 changed files with 19 additions and 2 deletions

View File

@@ -1878,6 +1878,7 @@ X11: implement 'selectsaved', restore via menu of saved games
X11: echo getline prompt and response (wishes, applying names) to message
window and dumplog message history
X11: fix map expose area, no longer leaving black bars on the map
tty and curses: support italic as text attribute
NetHack Community Patches (or Variation) Included

View File

@@ -124,6 +124,7 @@ typedef struct gi {
#define ATR_NONE 0
#define ATR_BOLD 1
#define ATR_DIM 2
#define ATR_ITALIC 3
#define ATR_ULINE 4
#define ATR_BLINK 5
#define ATR_INVERSE 7

View File

@@ -6814,6 +6814,7 @@ static const struct attr_names {
{ "none", ATR_NONE },
{ "bold", ATR_BOLD },
{ "dim", ATR_DIM },
{ "italic", ATR_ITALIC },
{ "underline", ATR_ULINE },
{ "blink", ATR_BLINK },
{ "inverse", ATR_INVERSE },

View File

@@ -748,6 +748,9 @@ curses_convert_attr(int attr)
case ATR_INVERSE:
curses_attr = A_REVERSE;
break;
case ATR_ITALIC:
curses_attr = A_ITALIC;
break;
default:
curses_attr = A_NORMAL;
}

View File

@@ -36,6 +36,7 @@ struct tc_lcl_data tc_lcl_data = { 0, 0, 0, 0, 0, 0, 0, FALSE };
static char *HO, *CL, *CE, *UP, *XD, *BC, *SO, *SE, *TI, *TE;
static char *VS, *VE;
static char *ME, *MR, *MB, *MH, *MD;
static char *ZH, *ZR;
#ifdef TERMLIB
boolean dynamic_HIHE = FALSE;
@@ -256,6 +257,8 @@ tty_startup(int *wid, int *hgt)
SE = Tgetstr("se"); /* standout end */
nh_US = Tgetstr("us"); /* underline start */
nh_UE = Tgetstr("ue"); /* underline end */
ZH = Tgetstr("ZH"); /* italic start */
ZR = Tgetstr("ZR"); /* italic end */
SG = tgetnum("sg"); /* -1: not fnd; else # of spaces left by so */
if (!SO || !SE || (SG > 0))
SO = SE = nh_US = nh_UE = nullstr;
@@ -1320,6 +1323,10 @@ s_atr2str(int n)
if (MH && *MH)
return MH;
break;
case ATR_ITALIC:
if (ZH && *ZH)
return ZH;
break;
}
return nulstr;
}
@@ -1342,6 +1349,10 @@ e_atr2str(int n)
if (ME && *ME)
return ME;
break;
case ATR_ITALIC:
if (ZR && *ZR)
return ZR;
break;
}
return nulstr;
}
@@ -1440,7 +1451,7 @@ term_start_color(int color)
#define tcfmtstr256 "\033[38:5:%ldm"
#endif
#endif
static void emit24bit(long mcolor);
static void emit256(int u256coloridx);
@@ -1469,7 +1480,7 @@ term_start_24bitcolor(struct unicode_representation *urep)
{
if (urep && SYMHANDLING(H_UTF8)) {
/* color 0 has bit 0x1000000 set */
long mcolor = (urep->ucolor & 0xFFFFFF);
long mcolor = (urep->ucolor & 0xFFFFFF);
if (iflags.colorcount == 256)
emit256(urep->u256coloridx);
else