Skip to content

[Win32] Honour the background colour #82

@gvanem

Description

@gvanem

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_.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions