some patches and configuration for st terminal emulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

st-bright-bold-text.patch 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. --- a/config.def.h
  2. +++ b/config.def.h
  3. @@ -114,9 +114,10 @@ static const char *colorname[] = {
  4. /*
  5. * Default colors (colorname index)
  6. - * foreground, background, cursor, reverse cursor
  7. + * foreground, default color for bold text, background, cursor, reverse cursor
  8. */
  9. unsigned int defaultfg = 7;
  10. +unsigned int defaultbd = 15;
  11. unsigned int defaultbg = 0;
  12. static unsigned int defaultcs = 256;
  13. static unsigned int defaultrcs = 257;
  14. diff --git a/st.c b/st.c
  15. index ede7ae6..6e3fabe 100644
  16. --- a/st.c
  17. +++ b/st.c
  18. @@ -1351,6 +1351,7 @@ tsetattr(int *attr, int l)
  19. for (i = 0; i < l; i++) {
  20. switch (attr[i]) {
  21. case 0:
  22. + term.c.attr.colored = 0;
  23. term.c.attr.mode &= ~(
  24. ATTR_BOLD |
  25. ATTR_FAINT |
  26. @@ -1365,6 +1366,8 @@ tsetattr(int *attr, int l)
  27. break;
  28. case 1:
  29. term.c.attr.mode |= ATTR_BOLD;
  30. + if (!term.c.attr.colored)
  31. + term.c.attr.fg = defaultbd;
  32. break;
  33. case 2:
  34. term.c.attr.mode |= ATTR_FAINT;
  35. @@ -1391,6 +1395,8 @@ tsetattr(int *attr, int l)
  36. break;
  37. case 22:
  38. term.c.attr.mode &= ~(ATTR_BOLD | ATTR_FAINT);
  39. + if (!term.c.attr.colored)
  40. + term.c.attr.fg = defaultfg;
  41. break;
  42. case 23:
  43. term.c.attr.mode &= ~ATTR_ITALIC;
  44. @@ -1411,11 +1416,17 @@ tsetattr(int *attr, int l)
  45. term.c.attr.mode &= ~ATTR_STRUCK;
  46. break;
  47. case 38:
  48. - if ((idx = tdefcolor(attr, &i, l)) >= 0)
  49. + if ((idx = tdefcolor(attr, &i, l)) >= 0) {
  50. + term.c.attr.colored = 1;
  51. term.c.attr.fg = idx;
  52. + }
  53. break;
  54. case 39:
  55. - term.c.attr.fg = defaultfg;
  56. + term.c.attr.colored = 0;
  57. + if (term.c.attr.mode & ATTR_BOLD)
  58. + term.c.attr.fg = defaultbd;
  59. + else
  60. + term.c.attr.fg = defaultfg;
  61. break;
  62. case 48:
  63. if ((idx = tdefcolor(attr, &i, l)) >= 0)
  64. @@ -1426,10 +1437,12 @@ tsetattr(int *attr, int l)
  65. break;
  66. default:
  67. if (BETWEEN(attr[i], 30, 37)) {
  68. + term.c.attr.colored = 1;
  69. term.c.attr.fg = attr[i] - 30;
  70. } else if (BETWEEN(attr[i], 40, 47)) {
  71. term.c.attr.bg = attr[i] - 40;
  72. } else if (BETWEEN(attr[i], 90, 97)) {
  73. + term.c.attr.colored = 1;
  74. term.c.attr.fg = attr[i] - 90 + 8;
  75. } else if (BETWEEN(attr[i], 100, 107)) {
  76. term.c.attr.bg = attr[i] - 100 + 8;
  77. diff --git a/st.h b/st.h
  78. index 4da3051..06de8ac 100644
  79. --- a/st.h
  80. +++ b/st.h
  81. @@ -65,6 +65,7 @@ typedef struct {
  82. ushort mode; /* attribute flags */
  83. uint32_t fg; /* foreground */
  84. uint32_t bg; /* background */
  85. + int colored; /* tell if the text color set explicitly */
  86. } Glyph;
  87. typedef Glyph *Line;
  88. @@ -119,4 +120,5 @@ extern int allowaltscreen;
  89. extern char *termname;
  90. extern unsigned int tabspaces;
  91. extern unsigned int defaultfg;
  92. +extern unsigned int defaultbd;
  93. extern unsigned int defaultbg;