[PATCH] Refactor xdraws()

From: FRIGN <dev_AT_frign.de>
Date: Sat, 7 Jun 2014 17:16:27 +0200

Simplify the logic and unify the brightening of colors for bold text
by increasing base.fg instead of directly setting fg.
This allows putting the bold-logic above the truecolor-checks, which
automatically fall back to desired behaviour.
---
 st.c | 35 +++++++++++------------------------
 1 file changed, 11 insertions(+), 24 deletions(-)
diff --git a/st.c b/st.c
index 3681776..ba0bf72 100644
--- a/st.c
+++ b/st.c
_AT_@ -3117,13 +3117,17 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 	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;
+		font = (base.mode & ATTR_BOLD)? &dc.ibfont : &dc.ifont;
+		frcflags = (base.mode & ATTR_BOLD)? FRC_ITALICBOLD : FRC_ITALIC;
+	} else if(base.mode & ATTR_BOLD) {
+		/*
+		 * change basic system colors [0-7]
+		 * to bright system colors [8-15]
+		 */
+		if(BETWEEN(base.fg, 0, 7))
+			base.fg += 8;
+		font = &dc.bfont;
+		frcflags = FRC_BOLD;
 	} else if(base.mode & ATTR_UNDERLINE) {
 		if(base.fg == defaultfg)
 			base.fg = defaultunderline;
_AT_@ -3151,23 +3155,6 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 		bg = &dc.col[base.bg];
 	}
 
-	if(base.mode & ATTR_BOLD) {
-		/*
-		 * change basic system colors [0-7]
-		 * to bright system colors [8-15]
-		 */
-		if(BETWEEN(base.fg, 0, 7))
-			fg = &dc.col[base.fg + 8];
-
-		if(base.mode & ATTR_ITALIC) {
-			font = &dc.ibfont;
-			frcflags = FRC_ITALICBOLD;
-		} else {
-			font = &dc.bfont;
-			frcflags = FRC_BOLD;
-		}
-	}
-
 	if(IS_SET(MODE_REVERSE)) {
 		if(fg == &dc.col[defaultfg]) {
 			fg = &dc.col[defaultbg];
-- 
1.8.5.5
--Multipart=_Sat__7_Jun_2014_17_21_15_+0200_xFlJbNujmz.131WR--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Sat Jun 07 2014 - 18:48:03 CEST