http://bugs.winehq.org/show_bug.cgi?id=60210 Bug ID: 60210 Summary: conhost: set_tty_attr() uses "\x1b[m" to reset foreground color to 7, inadvertently wiping the background color Product: Wine Version: 9.0 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@list.winehq.org Reporter: unxed@mail.ru Target Milestone: --- Distribution: --- In programs/conhost/conhost.c, set_tty_attr() is responsible for converting Win32 CHAR_INFO color attributes to ANSI escape sequences for tty output: if ((attr & 0x0f) != (console->tty_attr & 0x0f)) { if ((attr & 0x0f) != 7) { ... sprintf(buf, "\x1b[%um", n); tty_write( console, buf, strlen(buf) ); } else tty_write( console, "\x1b[m", 3 ); } When a console cell transitions from a colored foreground (e.g. 0x001B: Cyan on Blue background) to default Light Gray text on the same non-black background (0x0017: Light Gray on Blue background): 1. ((attr & 0x0f) != (console->tty_attr & 0x0f)) evaluates to true (7 != 11). 2. The 'else' branch executes and sends "\x1b[m". 3. In ANSI terminal emulation, "\x1b[m" (SGR 0) resets ALL attributes, including the background color (resetting it to terminal default / black). 4. Next, the background check: if ((attr & 0xf0) != (console->tty_attr & 0xf0) && attr != 7) evaluates to false because both the current cell and console->tty_attr have (attr & 0xf0) == BACKGROUND_BLUE (0x10). 5. As a result, conhost does not re-emit the background escape sequence (e.g. "\x1b[44m"). 6. console->tty_attr is updated to 0x0017. Result: The terminal background is reset to black by "\x1b[m", while conhost's internal state tracker believes the terminal is still using BACKGROUND_BLUE. All subsequent cells with attribute 0x0017 are rendered on a black background instead of the requested blue background. Expected behavior: To reset only the foreground color without corrupting the background, conhost should emit "\x1b[39m" (default foreground color) instead of "\x1b[m", or force a background re-emission if (attr & 0xf0) != 0. Original report: https://github.com/unxed/f4/issues/536 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.