st-patches/st-bright-bold-text.patch

74 lines
2.1 KiB
Diff

--- a/config.def.h
+++ b/config.def.h
@@ -114,9 +114,10 @@ static const char *colorname[] = {
/*
* Default colors (colorname index)
- * foreground, background, cursor, reverse cursor
+ * foreground, default color for bold text, background, cursor, reverse cursor
*/
unsigned int defaultfg = 7;
+unsigned int defaultbd = 7;
unsigned int defaultbg = 0;
static unsigned int defaultcs = 256;
static unsigned int defaultrcs = 257;
--- a/st.c
+++ b/st.c
@@ -1378,9 +1378,12 @@ tsetattr(int *attr, int l)
ATTR_STRUCK );
term.c.attr.fg = defaultfg;
term.c.attr.bg = defaultbg;
+ term.c.attr.colored = 0;
break;
case 1:
term.c.attr.mode |= ATTR_BOLD;
+ if (!term.c.attr.colored)
+ term.c.attr.fg = defaultbd;
break;
case 2:
term.c.attr.mode |= ATTR_FAINT;
@@ -1427,11 +1430,14 @@ tsetattr(int *attr, int l)
term.c.attr.mode &= ~ATTR_STRUCK;
break;
case 38:
- if ((idx = tdefcolor(attr, &i, l)) >= 0)
+ if ((idx = tdefcolor(attr, &i, l)) >= 0) {
term.c.attr.fg = idx;
+ term.c.attr.colored = 1;
+ }
break;
case 39:
term.c.attr.fg = defaultfg;
+ term.c.attr.colored = 0;
break;
case 48:
if ((idx = tdefcolor(attr, &i, l)) >= 0)
@@ -1443,10 +1449,12 @@ tsetattr(int *attr, int l)
default:
if (BETWEEN(attr[i], 30, 37)) {
term.c.attr.fg = attr[i] - 30;
+ term.c.attr.colored = 1;
} else if (BETWEEN(attr[i], 40, 47)) {
term.c.attr.bg = attr[i] - 40;
} else if (BETWEEN(attr[i], 90, 97)) {
term.c.attr.fg = attr[i] - 90 + 8;
+ term.c.attr.colored = 1;
} else if (BETWEEN(attr[i], 100, 107)) {
term.c.attr.bg = attr[i] - 100 + 8;
} else {
--- a/st.h
+++ b/st.h
@@ -65,6 +65,7 @@ typedef struct {
ushort mode; /* attribute flags */
uint32_t fg; /* foreground */
uint32_t bg; /* background */
+ int colored; /* tell if the text color set explicitly */
} Glyph;
typedef Glyph *Line;
@@ -119,4 +120,5 @@ extern int allowaltscreen;
extern char *termname;
extern unsigned int tabspaces;
extern unsigned int defaultfg;
+extern unsigned int defaultbd;
extern unsigned int defaultbg;