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

[Win32] Honour the background colour #82

Open
gvanem opened this issue Oct 31, 2024 · 0 comments
Open

[Win32] Honour the background colour #82

gvanem opened this issue Oct 31, 2024 · 0 comments

Comments

@gvanem
Copy link

gvanem commented Oct 31, 2024

Hello, my 1st issue.

I have setup my console terminal (TCC from JPsoft) to use blue background on Win-10.
Running both examples programs, the colours look awful:
acutest-c-example-1

With a little patch to acutest_colored_printf_(), it could look a bit nicer:
acutest-c-example-2

Here is my patch:

--- a/include/acutest.h 2024-10-31 11:23:21
+++ b/include/acutest.h 2024-10-31 11:29:49
@@ -628,8 +628,10 @@
             case ACUTEST_COLOR_YELLOW_INTENSIVE_:   attr = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; break;
             default:                                attr = 0; break;
         }
-        if(attr != 0)
+        if(attr != 0) {
+            attr |= (info.wAttributes & ~7);  /* mask in the default background colour */
             SetConsoleTextAttribute(h, attr);
+        }
         n = printf("%s", buffer);
         SetConsoleTextAttribute(h, info.wAttributes);
         return n;

Another option would be to detect if ANSI-sequences are supported:

DWORD mode = 0;
GetConsoleMode (h, &mode);
bool okay = (mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING);

if okay set colours as for ACUTEST_UNIX_.

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

1 participant