Fix: SE008 Problem: Finally got around to fixing the "Linux colour bug" properly. Debian has already got a patch for this which solves the immediate problem on Linux consoles (the status line gets coloured in whatever colour the last map glyph was written in). This patch should work on Linux consoles without breaking other machines. The basic problem is that NetHack assumes that HE==ME and so just uses HE to cancel all highlighting and colour. On the Linux console this isn't the case and so the colour isn't cancelled. Debian's patch makes the same assumption but uses ME instead which will fail if for example a terminal has HI/HE support but no ME defined. My patch still leaves another assumption; that ME cancels colours set with Sf/AF. You're supposed to use OP (Original Pair). I hesitate to make such a large change to the code with such limited facilites to test it when it appears that few if any people are likely to be affected. If it does prove to be a problem, it would be easy enough to do. The assumption is contained in the UNIX & TERMINFO version of init_hilite(). You will see that it uses Sf/AF for dim colours and a combination of MD and Sf/AF for bright colours. Hilights are cleared with ME. This could be changed to a combination of OP and ME. Compatible with: NetHack 3.2.2 Slash'EM 0.0.5E4 Author: J. Ali Harlow, ali@avrc.city.ac.uk Date: 31 Aug 1999 *** win/tty/termcap.c.orig Tue Aug 31 15:23:33 1999 --- win/tty/termcap.c Tue Aug 31 15:23:38 1999 *************** *** 42,54 **** STATIC_VAR char *HO, *CL, *CE, *UP, *XD, *BC, *SO, *SE, *TI, *TE; STATIC_VAR char *VS, *VE; #if 0 ! STATIC_VAR char *MR, *ME; STATIC_VAR char *MB, *MH; ! STATIC_VAR char *MD; /* may already be in use below */ #endif #ifdef TERMLIB # ifdef TEXTCOLOR ! STATIC_VAR char *MD; # endif STATIC_VAR int SG; #ifdef OVLB --- 42,54 ---- STATIC_VAR char *HO, *CL, *CE, *UP, *XD, *BC, *SO, *SE, *TI, *TE; STATIC_VAR char *VS, *VE; #if 0 ! STATIC_VAR char *MR; STATIC_VAR char *MB, *MH; ! STATIC_VAR char *MD, *ME; /* may already be in use below */ #endif #ifdef TERMLIB # ifdef TEXTCOLOR ! STATIC_VAR char *MD, *ME; # endif STATIC_VAR int SG; #ifdef OVLB *************** *** 65,70 **** --- 65,71 ---- # else char NEARDATA *hilites[CLR_MAX]; /* terminal escapes for the various colors */ # endif + char *hilite_end; /* [ALI] terminal escape to end colour */ #endif #ifdef OVLB *************** *** 184,189 **** --- 185,191 ---- Sprintf(hilites[i], "\033[0;3%dm", i); } } + hilite_end = "\033[0m"; # endif *wid = CO; *hgt = LI; *************** *** 309,314 **** --- 311,317 ---- CD = Tgetstr("cd"); # ifdef TEXTCOLOR MD = Tgetstr("md"); + ME = Tgetstr("me"); # endif # ifdef TEXTCOLOR # if defined(TOS) && defined(__GNUC__) *************** *** 417,422 **** --- 420,426 ---- Sprintf(hilites[c], "\033[0;3%dm", c); } } + hilite_end = "\033[0m"; } #endif /* PC9800 */ *************** *** 826,834 **** for (c = 0; c < SIZE(hilites); c++) hilites[c] = HI; hilites[CLR_GRAY] = hilites[NO_COLOR] = (char *)0; ! if (tgetnum("Co") < 8 || (setf = tgetstr("Sf", (char **)0)) == (char *)0) return; for (c = 0; c < CLR_MAX / 2; c++) { scratch = tparm(setf, ti_map[c]); --- 830,842 ---- for (c = 0; c < SIZE(hilites); c++) hilites[c] = HI; hilites[CLR_GRAY] = hilites[NO_COLOR] = (char *)0; + hilite_end = HE; ! if (tgetnum("Co") < 8) return; + if ((setf = tgetstr("Sf", (char **)0)) == (char *)0 + && (setf = tgetstr("AF", (char **)0)) == (char *)0) + return; for (c = 0; c < CLR_MAX / 2; c++) { scratch = tparm(setf, ti_map[c]); *************** *** 843,848 **** --- 851,857 ---- } } + hilite_end = ME; } # else /* UNIX && TERMINFO */ *************** *** 952,957 **** --- 961,967 ---- hilites[CLR_WHITE] = hilites[CLR_BLACK] = NOCOL; hilites[NO_COLOR] = hilites[CLR_GRAY]; } + hilite_end = HE; # else /* TOS */ *************** *** 960,965 **** --- 970,976 ---- for (c = 0; c < SIZE(hilites); c++) hilites[c] = HI; hilites[CLR_GRAY] = hilites[NO_COLOR] = (char *)0; + hilite_end = HE; analyze_seq(HI, &hi_foreg, &hi_backg); analyze_seq(HE, &foreg, &backg); *************** *** 1082,1088 **** void term_end_color() { ! xputs(HE); } --- 1093,1099 ---- void term_end_color() { ! xputs(hilite_end); }