2023-01-23 13:07:52 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-02-22 22:29:31 +02:00
|
|
|
#include <kernel/Font.h>
|
|
|
|
|
2023-01-23 13:07:52 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
class TerminalDriver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct Color
|
|
|
|
{
|
|
|
|
constexpr Color(uint32_t rgb)
|
|
|
|
: rgb(rgb)
|
|
|
|
{ }
|
|
|
|
constexpr Color(uint8_t r, uint8_t g, uint8_t b)
|
|
|
|
: rgb(((uint32_t)r << 16) | ((uint32_t)g << 8) | b)
|
|
|
|
{ }
|
|
|
|
uint8_t red() const { return (rgb >> 0x10) & 0xFF; }
|
|
|
|
uint8_t green() const { return (rgb >> 0x08) & 0xFF; }
|
|
|
|
uint8_t blue() const { return (rgb >> 0x00) & 0xFF; }
|
|
|
|
uint32_t rgb;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2023-02-23 01:22:50 +02:00
|
|
|
TerminalDriver() : m_font(MUST(Kernel::Font::prefs())) {}
|
2023-01-23 13:07:52 +02:00
|
|
|
virtual ~TerminalDriver() {}
|
2023-02-01 21:05:44 +02:00
|
|
|
virtual uint32_t width() const = 0;
|
|
|
|
virtual uint32_t height() const = 0;
|
2023-01-23 13:07:52 +02:00
|
|
|
|
2023-02-01 21:05:44 +02:00
|
|
|
virtual void putchar_at(uint16_t, uint32_t, uint32_t, Color, Color) = 0;
|
|
|
|
virtual void clear(Color) = 0;
|
2023-01-23 13:07:52 +02:00
|
|
|
|
2023-02-01 21:05:44 +02:00
|
|
|
virtual void set_cursor_position(uint32_t, uint32_t) = 0;
|
2023-02-22 22:29:31 +02:00
|
|
|
|
|
|
|
void set_font(const Kernel::Font& font) { m_font = font; };
|
|
|
|
const Kernel::Font& font() const { return m_font; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Kernel::Font m_font;
|
2023-01-23 13:07:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace TerminalColor
|
|
|
|
{
|
|
|
|
static constexpr TerminalDriver::Color BLACK = 0x000000;
|
|
|
|
static constexpr TerminalDriver::Color BLUE = 0x0000AA;
|
|
|
|
static constexpr TerminalDriver::Color GREEN = 0x00AA00;
|
|
|
|
static constexpr TerminalDriver::Color CYAN = 0x00AAAA;
|
|
|
|
static constexpr TerminalDriver::Color RED = 0xAA0000;
|
|
|
|
static constexpr TerminalDriver::Color MAGENTA = 0xAA00AA;
|
|
|
|
static constexpr TerminalDriver::Color YELLOW = 0xAA5500;
|
|
|
|
static constexpr TerminalDriver::Color WHITE = 0xAAAAAA;
|
|
|
|
|
|
|
|
static constexpr TerminalDriver::Color BRIGHT_BLACK = 0x555555;
|
|
|
|
static constexpr TerminalDriver::Color BRIGHT_BLUE = 0x5555FF;
|
|
|
|
static constexpr TerminalDriver::Color BRIGHT_GREEN = 0x55FF55;
|
|
|
|
static constexpr TerminalDriver::Color BRIGHT_CYAN = 0x55FFFF;
|
|
|
|
static constexpr TerminalDriver::Color BRIGHT_RED = 0xFF5555;
|
|
|
|
static constexpr TerminalDriver::Color BRIGHT_MAGENTA = 0xFF55FF;
|
|
|
|
static constexpr TerminalDriver::Color BRIGHT_YELLOW = 0xFFFF55;
|
|
|
|
static constexpr TerminalDriver::Color BRIGHT_WHITE = 0xFFFFFF;
|
|
|
|
}
|