Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreground color broken when background color specified #59

Closed
dolandemort opened this issue May 17, 2022 · 5 comments
Closed

Foreground color broken when background color specified #59

dolandemort opened this issue May 17, 2022 · 5 comments

Comments

@dolandemort
Copy link

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
Copy link
Contributor

erikarn commented Oct 5, 2022

+1 i just noticed that!

@erikarn
Copy link
Contributor

erikarn commented Oct 6, 2022

ah, here:

/ /echo -aCbgblue,BCred Foo!

doesn't work.

/ /echo -aBCred,Cbgblue Foo!

works!

@erikarn
Copy link
Contributor

erikarn commented Nov 3, 2022

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
Copy link
Contributor

erikarn commented Nov 3, 2022

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 pushed a commit to erikarn/tinyfugue that referenced this issue Nov 12, 2022
bg colours in 256 colour mode is using a flag bit that
overlaps with the fg colour byte.  Shift it to bit 31.
@erikarn
Copy link
Contributor

erikarn commented Nov 12, 2022

Pull request is here - #61

ingwarsw added a commit that referenced this issue Nov 16, 2022
Fix issue #59 - fg colour broken with using bg colours
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants