ingwarsw / tinyfugue

TinyFugue - Rebirth
Other
58 stars 33 forks source link

Foreground color broken when background color specified #59

Closed dolandemort closed 1 year ago

dolandemort commented 2 years ago

When specifying a background color, any specified foreground color is improperly displayed. To reproduce, use:

/echo -aCblack,Cbgyellow test

The expected result is black font with yellow background, but the actual result is red font with yellow background.

erikarn commented 1 year ago

+1 i just noticed that!

erikarn commented 1 year ago

ah, here:

/ /echo -aCbgblue,BCred Foo!

doesn't work.

/ /echo -aBCred,Cbgblue Foo!

works!

erikarn commented 1 year ago

Ok, I figured out why.

It's because the BG colour flag overlaps with the FG colour variable itself.

diff --git a/src/tf.h b/src/tf.h
index d5bd672..a47d6d8 100644
--- a/src/tf.h
+++ b/src/tf.h
@@ -90,7 +90,8 @@ enum enum_attr {
     F_FGCOLOR     = 0x00000080,   /* flag */
 # define BGCOLORSHIFT 16
     F_BGCOLORMASK = 0x00ff0000,   /* 8 bits, interpreted as an integer */
-    F_BGCOLOR     = 0x00000100,   /* flag */
+    F_BGCOLOR     = 0x80000000,   /* flag (XXX) */
+//    F_BGCOLOR     = 0x00000100,   /* flag - this overlaps with the FG colour */
 #else
     /* inside the 16 low bits */
 # define FGCOLORSHIFT 8
cerise:src adrian$ 
erikarn commented 1 year ago

now, this is a bit terrible because I don't know if the high bit is used, it doesn't LOOK like it from a cursory glance, but that made echo work properly again.

erikarn commented 1 year ago

Pull request is here - https://github.com/ingwarsw/tinyfugue/pull/61