Kernel: Add per terminal palette for TerminalDriver
This allows better color approximation on text mode and in future will allow user to possibly change the palette
This commit is contained in:
parent
4d840a8d9a
commit
cc7c1ad30d
|
@ -27,9 +27,10 @@ namespace Kernel
|
||||||
const LibFont::Font& font() const override { return m_font; };
|
const LibFont::Font& font() const override { return m_font; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FramebufferTerminalDriver(BAN::RefPtr<FramebufferDevice> framebuffer_device)
|
FramebufferTerminalDriver(BAN::RefPtr<FramebufferDevice> framebuffer_device, const Palette& palette)
|
||||||
: m_framebuffer_device(framebuffer_device)
|
: TerminalDriver(palette)
|
||||||
{ }
|
, m_framebuffer_device(framebuffer_device)
|
||||||
|
{}
|
||||||
|
|
||||||
void read_cursor();
|
void read_cursor();
|
||||||
void show_cursor(bool use_data);
|
void show_cursor(bool use_data);
|
||||||
|
@ -42,7 +43,7 @@ namespace Kernel
|
||||||
uint32_t m_cursor_y { 0 };
|
uint32_t m_cursor_y { 0 };
|
||||||
bool m_cursor_shown { true };
|
bool m_cursor_shown { true };
|
||||||
BAN::Vector<uint32_t> m_cursor_data;
|
BAN::Vector<uint32_t> m_cursor_data;
|
||||||
static constexpr Color m_cursor_color = TerminalColor::BRIGHT_WHITE;
|
static constexpr Color m_cursor_color = TerminalColor::WHITE;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,20 +12,28 @@ namespace Kernel
|
||||||
public:
|
public:
|
||||||
struct Color
|
struct Color
|
||||||
{
|
{
|
||||||
|
constexpr Color()
|
||||||
|
: rgb(0)
|
||||||
|
{ }
|
||||||
constexpr Color(uint32_t rgb)
|
constexpr Color(uint32_t rgb)
|
||||||
: rgb(rgb)
|
: rgb(rgb)
|
||||||
{ }
|
{ }
|
||||||
constexpr Color(uint8_t r, uint8_t g, uint8_t b)
|
constexpr Color(uint8_t r, uint8_t g, uint8_t b)
|
||||||
: rgb(((uint32_t)r << 16) | ((uint32_t)g << 8) | b)
|
: rgb(((uint32_t)r << 16) | ((uint32_t)g << 8) | b)
|
||||||
{ }
|
{ }
|
||||||
uint8_t red() const { return (rgb >> 0x10) & 0xFF; }
|
constexpr uint8_t red() const { return (rgb >> 0x10) & 0xFF; }
|
||||||
uint8_t green() const { return (rgb >> 0x08) & 0xFF; }
|
constexpr uint8_t green() const { return (rgb >> 0x08) & 0xFF; }
|
||||||
uint8_t blue() const { return (rgb >> 0x00) & 0xFF; }
|
constexpr uint8_t blue() const { return (rgb >> 0x00) & 0xFF; }
|
||||||
uint32_t rgb;
|
uint32_t rgb;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using Palette = BAN::Array<Color, 16>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BAN::ErrorOr<void> initialize_from_boot_info();
|
static BAN::ErrorOr<void> initialize_from_boot_info();
|
||||||
|
TerminalDriver(const Palette& palette)
|
||||||
|
: m_palette(palette)
|
||||||
|
{}
|
||||||
virtual ~TerminalDriver() {}
|
virtual ~TerminalDriver() {}
|
||||||
virtual uint32_t width() const = 0;
|
virtual uint32_t width() const = 0;
|
||||||
virtual uint32_t height() const = 0;
|
virtual uint32_t height() const = 0;
|
||||||
|
@ -40,29 +48,19 @@ namespace Kernel
|
||||||
virtual bool has_font() const { return false; }
|
virtual bool has_font() const { return false; }
|
||||||
virtual BAN::ErrorOr<void> set_font(LibFont::Font&&) { return BAN::Error::from_errno(EINVAL); }
|
virtual BAN::ErrorOr<void> set_font(LibFont::Font&&) { return BAN::Error::from_errno(EINVAL); }
|
||||||
virtual const LibFont::Font& font() const { ASSERT_NOT_REACHED(); }
|
virtual const LibFont::Font& font() const { ASSERT_NOT_REACHED(); }
|
||||||
|
|
||||||
|
const Palette& palette() const { return m_palette; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Palette m_palette;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern BAN::RefPtr<TerminalDriver> g_terminal_driver;
|
extern BAN::RefPtr<TerminalDriver> g_terminal_driver;
|
||||||
|
|
||||||
namespace TerminalColor
|
namespace TerminalColor
|
||||||
{
|
{
|
||||||
static constexpr TerminalDriver::Color BLACK = 0x000000;
|
constexpr TerminalDriver::Color BLACK = 0x000000;
|
||||||
static constexpr TerminalDriver::Color RED = 0xFF0000;
|
constexpr TerminalDriver::Color WHITE = 0xFFFFFF;
|
||||||
static constexpr TerminalDriver::Color GREEN = 0x00FF00;
|
|
||||||
static constexpr TerminalDriver::Color YELLOW = 0xFFFF00;
|
|
||||||
static constexpr TerminalDriver::Color BLUE = 0x0000FF;
|
|
||||||
static constexpr TerminalDriver::Color MAGENTA = 0xFF00FF;
|
|
||||||
static constexpr TerminalDriver::Color CYAN = 0x00FFFF;
|
|
||||||
static constexpr TerminalDriver::Color WHITE = 0xBFBFBF;
|
|
||||||
|
|
||||||
static constexpr TerminalDriver::Color BRIGHT_BLACK = 0x3F3F3F;
|
|
||||||
static constexpr TerminalDriver::Color BRIGHT_RED = 0xFF7F7F;
|
|
||||||
static constexpr TerminalDriver::Color BRIGHT_GREEN = 0x7FFF7F;
|
|
||||||
static constexpr TerminalDriver::Color BRIGHT_YELLOW = 0xFFFF7F;
|
|
||||||
static constexpr TerminalDriver::Color BRIGHT_BLUE = 0x7F7FFF;
|
|
||||||
static constexpr TerminalDriver::Color BRIGHT_MAGENTA = 0xFF7FFF;
|
|
||||||
static constexpr TerminalDriver::Color BRIGHT_CYAN = 0x7FFFFF;
|
|
||||||
static constexpr TerminalDriver::Color BRIGHT_WHITE = 0xFFFFFF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,9 @@ namespace Kernel
|
||||||
void set_cursor_position(uint32_t, uint32_t) override;
|
void set_cursor_position(uint32_t, uint32_t) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextModeTerminalDriver(paddr_t paddr, uint32_t width, uint32_t height, uint32_t pitch)
|
TextModeTerminalDriver(paddr_t paddr, uint32_t width, uint32_t height, uint32_t pitch, const Palette& palette)
|
||||||
: m_paddr(paddr)
|
: TerminalDriver(palette)
|
||||||
|
, m_paddr(paddr)
|
||||||
, m_width(width)
|
, m_width(width)
|
||||||
, m_height(height)
|
, m_height(height)
|
||||||
, m_pitch(pitch)
|
, m_pitch(pitch)
|
||||||
|
@ -36,7 +37,7 @@ namespace Kernel
|
||||||
const uint32_t m_height;
|
const uint32_t m_height;
|
||||||
const uint32_t m_pitch;
|
const uint32_t m_pitch;
|
||||||
vaddr_t m_vaddr { 0 };
|
vaddr_t m_vaddr { 0 };
|
||||||
static constexpr Color s_cursor_color = TerminalColor::BRIGHT_WHITE;
|
static constexpr Color s_cursor_color = TerminalColor::WHITE;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@ namespace Kernel
|
||||||
|
|
||||||
class VirtualTTY : public TTY
|
class VirtualTTY : public TTY
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
using Palette = TerminalDriver::Palette;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BAN::ErrorOr<BAN::RefPtr<VirtualTTY>> create(BAN::RefPtr<TerminalDriver>);
|
static BAN::ErrorOr<BAN::RefPtr<VirtualTTY>> create(BAN::RefPtr<TerminalDriver>);
|
||||||
|
|
||||||
|
@ -60,14 +63,16 @@ namespace Kernel
|
||||||
|
|
||||||
struct Cell
|
struct Cell
|
||||||
{
|
{
|
||||||
TerminalDriver::Color foreground { TerminalColor::BRIGHT_WHITE };
|
TerminalDriver::Color foreground;
|
||||||
TerminalDriver::Color background { TerminalColor::BLACK };
|
TerminalDriver::Color background;
|
||||||
uint32_t codepoint { ' ' };
|
uint32_t codepoint { ' ' };
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BAN::String m_name;
|
BAN::String m_name;
|
||||||
|
|
||||||
|
BAN::RefPtr<TerminalDriver> m_terminal_driver;
|
||||||
|
|
||||||
State m_state { State::Normal };
|
State m_state { State::Normal };
|
||||||
AnsiState m_ansi_state { };
|
AnsiState m_ansi_state { };
|
||||||
UTF8State m_utf8_state { };
|
UTF8State m_utf8_state { };
|
||||||
|
@ -84,11 +89,11 @@ 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 };
|
const Palette& m_palette;
|
||||||
TerminalDriver::Color m_background { TerminalColor::BLACK };
|
|
||||||
bool m_colors_inverted { false };
|
|
||||||
|
|
||||||
BAN::RefPtr<TerminalDriver> m_terminal_driver;
|
TerminalDriver::Color m_foreground;
|
||||||
|
TerminalDriver::Color m_background;
|
||||||
|
bool m_colors_inverted { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace Debug
|
||||||
{
|
{
|
||||||
if (!isprint(ch))
|
if (!isprint(ch))
|
||||||
ch = '?';
|
ch = '?';
|
||||||
g_terminal_driver->putchar_at(ch, col, row, TerminalColor::BRIGHT_WHITE, TerminalColor::BLACK);
|
g_terminal_driver->putchar_at(ch, col, row, TerminalColor::WHITE, TerminalColor::BLACK);
|
||||||
|
|
||||||
col++;
|
col++;
|
||||||
if (col >= g_terminal_driver->width())
|
if (col >= g_terminal_driver->width())
|
||||||
|
@ -121,9 +121,9 @@ namespace Debug
|
||||||
{
|
{
|
||||||
for (uint32_t i = col; i < g_terminal_driver->width(); i++)
|
for (uint32_t i = col; i < g_terminal_driver->width(); i++)
|
||||||
{
|
{
|
||||||
g_terminal_driver->putchar_at(' ', i, row, TerminalColor::BRIGHT_WHITE, TerminalColor::BLACK);
|
g_terminal_driver->putchar_at(' ', i, row, TerminalColor::WHITE, TerminalColor::BLACK);
|
||||||
if (row + 1 < g_terminal_driver->height())
|
if (row + 1 < g_terminal_driver->height())
|
||||||
g_terminal_driver->putchar_at(' ', i, row + 1, TerminalColor::BRIGHT_WHITE, TerminalColor::BLACK);
|
g_terminal_driver->putchar_at(' ', i, row + 1, TerminalColor::WHITE, TerminalColor::BLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,7 +360,7 @@ namespace Kernel
|
||||||
[&x, y](char ch)
|
[&x, y](char ch)
|
||||||
{
|
{
|
||||||
if (x < g_terminal_driver->width() && y < g_terminal_driver->height())
|
if (x < g_terminal_driver->width() && y < g_terminal_driver->height())
|
||||||
g_terminal_driver->putchar_at(ch, x++, y, TerminalColor::BRIGHT_WHITE, TerminalColor::BLACK);
|
g_terminal_driver->putchar_at(ch, x++, y, TerminalColor::WHITE, TerminalColor::BLACK);
|
||||||
};
|
};
|
||||||
|
|
||||||
BAN::Formatter::print(proc_putc, "CPU { 2}: { 3}.{3}%", current_id(), load_x1000 / 1000, load_x1000 % 1000);
|
BAN::Formatter::print(proc_putc, "CPU { 2}: { 3}.{3}%", current_id(), load_x1000 / 1000, load_x1000 % 1000);
|
||||||
|
|
|
@ -3,15 +3,38 @@
|
||||||
namespace Kernel
|
namespace Kernel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
static consteval TerminalDriver::Palette default_palette()
|
||||||
|
{
|
||||||
|
TerminalDriver::Palette palette;
|
||||||
|
palette[ 0] = 0x000000;
|
||||||
|
palette[ 1] = 0xFF0000;
|
||||||
|
palette[ 2] = 0x00FF00;
|
||||||
|
palette[ 3] = 0xFFFF00;
|
||||||
|
palette[ 4] = 0x0000FF;
|
||||||
|
palette[ 5] = 0xFF00FF;
|
||||||
|
palette[ 6] = 0x00FFFF;
|
||||||
|
palette[ 7] = 0xBFBFBF;
|
||||||
|
palette[ 8] = 0x3F3F3F;
|
||||||
|
palette[ 9] = 0xFF7F7F;
|
||||||
|
palette[10] = 0x7FFF7F;
|
||||||
|
palette[11] = 0xFFFF7F;
|
||||||
|
palette[12] = 0x7F7FFF;
|
||||||
|
palette[13] = 0xFF7FFF;
|
||||||
|
palette[14] = 0x7FFFFF;
|
||||||
|
palette[15] = 0xFFFFFF;
|
||||||
|
return palette;
|
||||||
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<BAN::RefPtr<FramebufferTerminalDriver>> FramebufferTerminalDriver::create(BAN::RefPtr<FramebufferDevice> framebuffer_device)
|
BAN::ErrorOr<BAN::RefPtr<FramebufferTerminalDriver>> FramebufferTerminalDriver::create(BAN::RefPtr<FramebufferDevice> framebuffer_device)
|
||||||
{
|
{
|
||||||
auto* driver_ptr = new FramebufferTerminalDriver(framebuffer_device);
|
auto* driver_ptr = new FramebufferTerminalDriver(framebuffer_device, default_palette());
|
||||||
if (driver_ptr == nullptr)
|
if (driver_ptr == nullptr)
|
||||||
return BAN::Error::from_errno(ENOMEM);
|
return BAN::Error::from_errno(ENOMEM);
|
||||||
auto driver = BAN::RefPtr<FramebufferTerminalDriver>::adopt(driver_ptr);
|
auto driver = BAN::RefPtr<FramebufferTerminalDriver>::adopt(driver_ptr);
|
||||||
TRY(driver->set_font(BAN::move(TRY(LibFont::Font::prefs()))));
|
TRY(driver->set_font(BAN::move(TRY(LibFont::Font::prefs()))));
|
||||||
driver->set_cursor_position(0, 0);
|
driver->set_cursor_position(0, 0);
|
||||||
driver->clear(TerminalColor::BLACK);
|
driver->clear(driver->m_palette[0]);
|
||||||
return driver;
|
return driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +83,9 @@ namespace Kernel
|
||||||
for (uint32_t x = 0; x < m_framebuffer_device->width(); x++)
|
for (uint32_t x = 0; x < m_framebuffer_device->width(); x++)
|
||||||
m_framebuffer_device->set_pixel(x, y, color.rgb);
|
m_framebuffer_device->set_pixel(x, y, color.rgb);
|
||||||
m_framebuffer_device->sync_pixels_full();
|
m_framebuffer_device->sync_pixels_full();
|
||||||
|
|
||||||
|
if (m_cursor_shown)
|
||||||
|
show_cursor(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramebufferTerminalDriver::read_cursor()
|
void FramebufferTerminalDriver::read_cursor()
|
||||||
|
|
|
@ -7,36 +7,39 @@
|
||||||
namespace Kernel
|
namespace Kernel
|
||||||
{
|
{
|
||||||
|
|
||||||
static constexpr TerminalDriver::Color s_palette[] {
|
static consteval TerminalDriver::Palette default_palette()
|
||||||
TerminalColor::BLACK,
|
{
|
||||||
TerminalColor::BLUE,
|
TerminalDriver::Palette palette;
|
||||||
TerminalColor::GREEN,
|
palette[ 0] = 0x000000;
|
||||||
TerminalColor::CYAN,
|
palette[ 1] = 0x0000AA;
|
||||||
TerminalColor::RED,
|
palette[ 2] = 0x00AA00;
|
||||||
TerminalColor::MAGENTA,
|
palette[ 3] = 0x00AAAA;
|
||||||
TerminalColor::YELLOW,
|
palette[ 4] = 0xAA0000;
|
||||||
TerminalColor::WHITE,
|
palette[ 5] = 0xAA00AA;
|
||||||
TerminalColor::BRIGHT_BLACK,
|
palette[ 6] = 0xAA5500;
|
||||||
TerminalColor::BRIGHT_BLUE,
|
palette[ 7] = 0xAAAAAA;
|
||||||
TerminalColor::BRIGHT_GREEN,
|
palette[ 8] = 0x555555;
|
||||||
TerminalColor::BRIGHT_CYAN,
|
palette[ 9] = 0x5555FF;
|
||||||
TerminalColor::BRIGHT_RED,
|
palette[10] = 0x55FF55;
|
||||||
TerminalColor::BRIGHT_MAGENTA,
|
palette[11] = 0x55FFFF;
|
||||||
TerminalColor::BRIGHT_YELLOW,
|
palette[12] = 0xFF5555;
|
||||||
TerminalColor::BRIGHT_WHITE,
|
palette[13] = 0xFF55FF;
|
||||||
};
|
palette[14] = 0xFFFF55;
|
||||||
|
palette[15] = 0xFFFFFF;
|
||||||
|
return palette;
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr uint8_t color_to_text_mode_color(TerminalDriver::Color color)
|
static constexpr uint8_t color_to_text_mode_color(TerminalDriver::Color color)
|
||||||
{
|
{
|
||||||
uint32_t min_diff = BAN::numeric_limits<uint32_t>::max();
|
uint32_t min_diff = BAN::numeric_limits<uint32_t>::max();
|
||||||
uint8_t closest = 0;
|
uint8_t closest = 0;
|
||||||
|
|
||||||
static_assert(sizeof(s_palette) / sizeof(*s_palette) == 16);
|
static_assert(default_palette().size() == 16);
|
||||||
for (size_t i = 0; i < 16; i++)
|
for (size_t i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
const auto rdiff = color.red() - s_palette[i].red();
|
const auto rdiff = color.red() - default_palette()[i].red();
|
||||||
const auto gdiff = color.green() - s_palette[i].green();
|
const auto gdiff = color.green() - default_palette()[i].green();
|
||||||
const auto bdiff = color.blue() - s_palette[i].blue();
|
const auto bdiff = color.blue() - default_palette()[i].blue();
|
||||||
const uint32_t diff = rdiff*rdiff + gdiff*gdiff + bdiff*bdiff;
|
const uint32_t diff = rdiff*rdiff + gdiff*gdiff + bdiff*bdiff;
|
||||||
if (diff >= min_diff)
|
if (diff >= min_diff)
|
||||||
continue;
|
continue;
|
||||||
|
@ -56,7 +59,8 @@ namespace Kernel
|
||||||
g_boot_info.framebuffer.address,
|
g_boot_info.framebuffer.address,
|
||||||
g_boot_info.framebuffer.width,
|
g_boot_info.framebuffer.width,
|
||||||
g_boot_info.framebuffer.height,
|
g_boot_info.framebuffer.height,
|
||||||
g_boot_info.framebuffer.pitch
|
g_boot_info.framebuffer.pitch,
|
||||||
|
default_palette()
|
||||||
);
|
);
|
||||||
if (driver_ptr == nullptr)
|
if (driver_ptr == nullptr)
|
||||||
return BAN::Error::from_errno(ENOMEM);
|
return BAN::Error::from_errno(ENOMEM);
|
||||||
|
@ -83,7 +87,7 @@ namespace Kernel
|
||||||
m_vaddr = vaddr + (m_paddr % PAGE_SIZE);
|
m_vaddr = vaddr + (m_paddr % PAGE_SIZE);
|
||||||
|
|
||||||
set_cursor_position(0, 0);
|
set_cursor_position(0, 0);
|
||||||
clear(TerminalColor::BLACK);
|
clear(m_palette[0]);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -114,7 +118,7 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
for (uint32_t y = 0; y < m_height; y++)
|
for (uint32_t y = 0; y < m_height; y++)
|
||||||
for (uint32_t x = 0; x < m_width; x++)
|
for (uint32_t x = 0; x < m_width; x++)
|
||||||
putchar_at(' ', x, y, TerminalColor::BRIGHT_WHITE, color);
|
putchar_at(' ', x, y, color, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextModeTerminalDriver::set_cursor_shown(bool shown)
|
void TextModeTerminalDriver::set_cursor_shown(bool shown)
|
||||||
|
|
|
@ -39,6 +39,9 @@ namespace Kernel
|
||||||
: TTY(0600, 0, 0)
|
: TTY(0600, 0, 0)
|
||||||
, m_name(MUST(BAN::String::formatted("tty{}", s_next_tty_number++)))
|
, m_name(MUST(BAN::String::formatted("tty{}", s_next_tty_number++)))
|
||||||
, m_terminal_driver(driver)
|
, m_terminal_driver(driver)
|
||||||
|
, m_palette(driver->palette())
|
||||||
|
, m_foreground(m_palette[15])
|
||||||
|
, m_background(m_palette[0])
|
||||||
{
|
{
|
||||||
m_width = m_terminal_driver->width();
|
m_width = m_terminal_driver->width();
|
||||||
m_height = m_terminal_driver->height();
|
m_height = m_terminal_driver->height();
|
||||||
|
@ -95,10 +98,11 @@ namespace Kernel
|
||||||
void VirtualTTY::reset_ansi()
|
void VirtualTTY::reset_ansi()
|
||||||
{
|
{
|
||||||
ASSERT(m_write_lock.current_processor_has_lock());
|
ASSERT(m_write_lock.current_processor_has_lock());
|
||||||
m_ansi_state.index = 0;
|
m_ansi_state = {
|
||||||
m_ansi_state.nums[0] = -1;
|
.nums = { -1, -1, -1, -1, -1 },
|
||||||
m_ansi_state.nums[1] = -1;
|
.index = 0,
|
||||||
m_ansi_state.question = false;
|
.question = false,
|
||||||
|
};
|
||||||
m_state = State::Normal;
|
m_state = State::Normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,49 +112,29 @@ namespace Kernel
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
m_foreground = TerminalColor::BRIGHT_WHITE;
|
m_foreground = m_palette[15];
|
||||||
m_background = TerminalColor::BLACK;
|
m_background = m_palette[0];
|
||||||
m_colors_inverted = false;
|
m_colors_inverted = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7: m_colors_inverted = true; break;
|
case 7: m_colors_inverted = true; break;
|
||||||
case 27: m_colors_inverted = false; break;
|
case 27: m_colors_inverted = false; break;
|
||||||
|
|
||||||
case 30: m_foreground = TerminalColor::BLACK; break;
|
case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37:
|
||||||
case 31: m_foreground = TerminalColor::RED; break;
|
m_foreground = m_palette[ch - 30];
|
||||||
case 32: m_foreground = TerminalColor::GREEN; break;
|
break;
|
||||||
case 33: m_foreground = TerminalColor::YELLOW; break;
|
|
||||||
case 34: m_foreground = TerminalColor::BLUE; break;
|
|
||||||
case 35: m_foreground = TerminalColor::MAGENTA; break;
|
|
||||||
case 36: m_foreground = TerminalColor::CYAN; break;
|
|
||||||
case 37: m_foreground = TerminalColor::WHITE; break;
|
|
||||||
|
|
||||||
case 40: m_background = TerminalColor::BLACK; break;
|
case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47:
|
||||||
case 41: m_background = TerminalColor::RED; break;
|
m_background = m_palette[ch - 40];
|
||||||
case 42: m_background = TerminalColor::GREEN; break;
|
break;
|
||||||
case 43: m_background = TerminalColor::YELLOW; break;
|
|
||||||
case 44: m_background = TerminalColor::BLUE; break;
|
|
||||||
case 45: m_background = TerminalColor::MAGENTA; break;
|
|
||||||
case 46: m_background = TerminalColor::CYAN; break;
|
|
||||||
case 47: m_background = TerminalColor::WHITE; break;
|
|
||||||
|
|
||||||
case 90: m_foreground = TerminalColor::BRIGHT_BLACK; break;
|
case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97:
|
||||||
case 91: m_foreground = TerminalColor::BRIGHT_RED; break;
|
m_foreground = m_palette[ch - 90 + 8];
|
||||||
case 92: m_foreground = TerminalColor::BRIGHT_GREEN; break;
|
break;
|
||||||
case 93: m_foreground = TerminalColor::BRIGHT_YELLOW; break;
|
|
||||||
case 94: m_foreground = TerminalColor::BRIGHT_BLUE; break;
|
|
||||||
case 95: m_foreground = TerminalColor::BRIGHT_MAGENTA; break;
|
|
||||||
case 96: m_foreground = TerminalColor::BRIGHT_CYAN; break;
|
|
||||||
case 97: m_foreground = TerminalColor::BRIGHT_WHITE; break;
|
|
||||||
|
|
||||||
case 100: m_background = TerminalColor::BRIGHT_BLACK; break;
|
case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107:
|
||||||
case 101: m_background = TerminalColor::BRIGHT_RED; break;
|
m_background = m_palette[ch - 100 + 8];
|
||||||
case 102: m_background = TerminalColor::BRIGHT_GREEN; break;
|
break;
|
||||||
case 103: m_background = TerminalColor::BRIGHT_YELLOW; break;
|
|
||||||
case 104: m_background = TerminalColor::BRIGHT_BLUE; break;
|
|
||||||
case 105: m_background = TerminalColor::BRIGHT_MAGENTA; break;
|
|
||||||
case 106: m_background = TerminalColor::BRIGHT_CYAN; break;
|
|
||||||
case 107: m_background = TerminalColor::BRIGHT_WHITE; break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue