From 8bf5654eedd039922f6d82a2cf21f22685335d78 Mon Sep 17 00:00:00 2001 From: Patric Mueller Date: Sun, 4 Sep 2022 22:33:25 +0200 Subject: [PATCH] tty and curses: support italic as text attribute --- doc/fixes3-7-0.txt | 1 + include/wintype.h | 1 + src/options.c | 1 + win/curses/cursmisc.c | 3 +++ win/tty/termcap.c | 15 +++++++++++++-- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index ba4dd8190..658364a35 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -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 diff --git a/include/wintype.h b/include/wintype.h index 420917dcf..1da4a060e 100644 --- a/include/wintype.h +++ b/include/wintype.h @@ -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 diff --git a/src/options.c b/src/options.c index 0029210ab..004b46d7f 100644 --- a/src/options.c +++ b/src/options.c @@ -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 }, diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index 5e7d67255..dc8447986 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -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; } diff --git a/win/tty/termcap.c b/win/tty/termcap.c index 4e78a854b..7aa325559 100644 --- a/win/tty/termcap.c +++ b/win/tty/termcap.c @@ -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