config.def.h | 8 ++++++++ st.c | 32 +++++++++++++++++++------------- diff --git a/config.def.h b/config.def.h index 75abefbb248cc0e8131c2aa470e30b20f3d7e3d6..693bdbd9a1e18e80d4399aeef8d4728ba90c7f86 100644 --- a/config.def.h +++ b/config.def.h @@ -62,6 +62,14 @@ static unsigned int defaultbg = 0; static unsigned int defaultcs = 256; static unsigned int defaultucs = 257; +/* + * Colors used, when the specific fg == defaultfg. So in reverse mode this + * will reverse too. Another logic would only make the simple feature too + * complex. + */ +static unsigned int defaultitalic = 11; +static unsigned int defaultunderline = 7; + /* Internal shortcuts. */ #define MODKEY Mod1Mask diff --git a/st.c b/st.c index 599685cc92a0bd2a54df092ecbd4966a1523a4db..8b1fc562be94f913df5f0df1b205ea74b8e82310 100644 --- a/st.c +++ b/st.c @@ -2711,12 +2711,28 @@ FcResult fcres; FcPattern *fcpattern, *fontpattern; FcFontSet *fcsets[] = { NULL }; FcCharSet *fccharset; - Colour *fg = &dc.col[base.fg], *bg = &dc.col[base.bg], - *temp, revfg, revbg; + Colour *fg, *bg, *temp, revfg, revbg; XRenderColor colfg, colbg; frcflags = FRC_NORMAL; + if(base.mode & ATTR_ITALIC) { + if(base.fg == defaultfg) + base.fg = defaultitalic; + font = &dc.ifont; + frcflags = FRC_ITALIC; + } else if((base.mode & ATTR_ITALIC) && (base.mode & ATTR_BOLD)) { + if(base.fg == defaultfg) + base.fg = defaultitalic; + font = &dc.ibfont; + frcflags = FRC_ITALICBOLD; + } else if(base.mode & ATTR_UNDERLINE) { + if(base.fg == defaultfg) + base.fg = defaultunderline; + } + fg = &dc.col[base.fg]; + bg = &dc.col[base.bg]; + if(base.mode & ATTR_BOLD) { if(BETWEEN(base.fg, 0, 7)) { /* basic system colors */ @@ -2736,15 +2752,6 @@ * 252 - 255 – brightest colors in greyscale */ font = &dc.bfont; frcflags = FRC_BOLD; - } - - if(base.mode & ATTR_ITALIC) { - font = &dc.ifont; - frcflags = FRC_ITALIC; - } - if((base.mode & ATTR_ITALIC) && (base.mode & ATTR_BOLD)) { - font = &dc.ibfont; - frcflags = FRC_ITALICBOLD; } if(IS_SET(MODE_REVERSE)) { @@ -2873,8 +2880,7 @@ fontpattern = FcFontSetMatch(0, fcsets, FcTrue, fcpattern, &fcres); /* - * Overwrite or create the new cache entry - * entry. + * Overwrite or create the new cache entry. */ frccur++; frclen++;