$ git diff xterm-389c diff --git a/charproc.c b/charproc.c index eef4233a..2a396fc3 100644 --- a/charproc.c +++ b/charproc.c @@ -1161,12 +1161,16 @@ reset_SGR_Foreground(XtermWidget xw) xw->sgr_38_xcolors = False; clrDirectFG(xw->flags); setExtendedFG(xw); + if (xw->sgr_background == 7) xw->sgr_background = -1; + clrDirectBG(xw->flags); + setExtendedBG(xw); } static void reset_SGR_Background(XtermWidget xw) { xw->sgr_background = -1; + UIntClr(xw->flags, INVERSE); clrDirectBG(xw->flags); setExtendedBG(xw); } @@ -4079,10 +4083,14 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) /* FALLTHRU */ case 37: if_OPT_ISO_COLORS(screen, { - xw->sgr_foreground = (op - 30); xw->sgr_38_xcolors = False; clrDirectFG(xw->flags); setExtendedFG(xw); + if (xw->sgr_background == -1) { + xw->sgr_background = 7; + clrDirectBG(xw->flags); + setExtendedBG(xw); + } }); break; case 38: @@ -4121,7 +4129,11 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) /* FALLTHRU */ case 47: if_OPT_ISO_COLORS(screen, { - xw->sgr_background = (op - 40); + if (op == 47) { + xw->sgr_background = (op - 40); + } else { + UIntSet(xw->flags, INVERSE); + } clrDirectBG(xw->flags); setExtendedBG(xw); }); @@ -4158,9 +4170,13 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) /* FALLTHRU */ case 97: if_OPT_AIX_COLORS(screen, { - xw->sgr_foreground = (op - 90 + 8); clrDirectFG(xw->flags); setExtendedFG(xw); + if (xw->sgr_background == -1) { + xw->sgr_background = 7; + clrDirectBG(xw->flags); + setExtendedBG(xw); + } }); break; case 100: @@ -4185,7 +4201,11 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) /* FALLTHRU */ case 107: if_OPT_AIX_COLORS(screen, { - xw->sgr_background = (op - 100 + 8); + if (op == 47) { + xw->sgr_background = (op - 40); + } else { + UIntSet(xw->flags, INVERSE); + } clrDirectBG(xw->flags); setExtendedBG(xw); }); diff --git a/colortest b/colortest new file mode 100755 index 00000000..edcabb34 --- /dev/null +++ b/colortest @@ -0,0 +1,22 @@ +#/bin/bash +for ((i = 0; i < 16 * 9; i++)); do + fg=$((i / 9)) + bg=$((i % 9)) + printf "test:%3d " $i + printf "fg:%2d bg:%2d " $fg $bg + if ((i % 2 == 1)); then + echo -n ' ' + fi + if test $fg -lt 8; then + echo -en "\e[3${fg}m" + else + echo -en "\e[1;3$((fg-8))m" + fi + if test $bg -lt 8; then + echo -en "\e[4${bg}m" + fi + printf "this is a test text __ <- underscore" + echo -e '\e[0m' +done + +echo -e 'brightwhite on white: \e[1;97m \e[47m blahblah __ blah \e[0m'