Kernel: Fix ANSI SGR color invert

This commit is contained in:
Bananymous 2025-04-18 17:31:46 +03:00
parent 703c1a485c
commit 85505b0482
3 changed files with 10 additions and 8 deletions

View File

@ -69,8 +69,6 @@ namespace Kernel
void do_backspace(); void do_backspace();
protected: protected:
TerminalDriver::Color m_foreground { TerminalColor::BRIGHT_WHITE };
TerminalDriver::Color m_background { TerminalColor::BLACK };
termios m_termios; termios m_termios;
private: private:

View File

@ -84,6 +84,10 @@ namespace Kernel
uint32_t m_column { 0 }; uint32_t m_column { 0 };
Cell* m_buffer { nullptr }; Cell* m_buffer { nullptr };
TerminalDriver::Color m_foreground { TerminalColor::BRIGHT_WHITE };
TerminalDriver::Color m_background { TerminalColor::BLACK };
bool m_colors_inverted { false };
BAN::RefPtr<TerminalDriver> m_terminal_driver; BAN::RefPtr<TerminalDriver> m_terminal_driver;
}; };

View File

@ -110,11 +110,11 @@ namespace Kernel
case 0: case 0:
m_foreground = TerminalColor::BRIGHT_WHITE; m_foreground = TerminalColor::BRIGHT_WHITE;
m_background = TerminalColor::BLACK; m_background = TerminalColor::BLACK;
m_colors_inverted = false;
break; break;
case 7: case 7: m_colors_inverted = true; break;
BAN::swap(m_foreground, m_background); case 27: m_colors_inverted = false; break;
break;
case 30: m_foreground = TerminalColor::BLACK; break; case 30: m_foreground = TerminalColor::BLACK; break;
case 31: m_foreground = TerminalColor::RED; break; case 31: m_foreground = TerminalColor::RED; break;
@ -384,9 +384,9 @@ namespace Kernel
ASSERT(x < m_width && y < m_height); ASSERT(x < m_width && y < m_height);
auto& cell = m_buffer[y * m_width + x]; auto& cell = m_buffer[y * m_width + x];
cell.codepoint = codepoint; cell.codepoint = codepoint;
cell.foreground = m_foreground; cell.foreground = m_colors_inverted ? m_background : m_foreground;
cell.background = m_background; cell.background = m_colors_inverted ? m_foreground : m_background;
m_terminal_driver->putchar_at(codepoint, x, y, m_foreground, m_background); m_terminal_driver->putchar_at(codepoint, x, y, cell.foreground, cell.background);
} }
void VirtualTTY::putcodepoint(uint32_t codepoint) void VirtualTTY::putcodepoint(uint32_t codepoint)