12using namespace MaxOS::common;
13using namespace MaxOS::drivers;
14using namespace MaxOS::drivers::console;
16Console::Console() =
default;
18Console::~Console() =
default;
89 return ConsoleColour::Green;
100 return ConsoleColour::Green;
135 for(
size_t i = 0; i <
string.length(); i++)
161 for(
int y = top; y < top +
height - 1; y++)
232 : m_console(console),
252 : m_console(console),
267ConsoleArea::~ConsoleArea() =
default;
297 if(x >= m_width || y >= m_height)
315 if(x >= m_width || y >= m_height)
333 if(x >= m_width || y >= m_height)
351 if(x >= m_width || y >= m_height)
368 if(x >= m_width || y >= m_height)
369 return ConsoleColour::LightGrey;
386 if(x >= m_width || y >= m_height)
387 return ConsoleColour::Black;
398 m_console->
scroll_up(m_left, m_top, m_width, m_height);
425 : m_console(console) {
429ConsoleStream::~ConsoleStream() =
default;
441 if(m_cursor_x >= m_console->
width() && c !=
'\n') {
447 if(c ==
'\033') is_ansi =
true;
454 if(++m_cursor_y >= m_console->
height()) {
458 m_cursor_y = m_console->
height() - 1;
482 spaces = 8 - (m_cursor_x % 8);
500 if(c ==
'm') is_ansi =
false;
void write(string string_to_write) override
Writes a string to the output stream.
virtual void line_feed()
Writes a newline to the output stream.
Stores the left, top, width and height of a rectangle.
char get_character(uint16_t x, uint16_t y) override
Return the character at the given coordinates if the coordinates are within the console area.
ConsoleArea(Console *console, uint16_t left, uint16_t top, uint16_t width, uint16_t height)
Construct a new Console Area object.
common::ConsoleColour get_foreground_color(uint16_t x, uint16_t y) override
Return the foreground color of the character at the given coordinates if the coordinates are within t...
void set_background_color(uint16_t x, uint16_t y, common::ConsoleColour background) override
Change the background color of a character on the console area if the coordinates are within the area...
uint16_t height() override
Return the height of the console area.
void scroll_up() override
Scroll the console area up by 1 line.
void put_character(uint16_t x, uint16_t y, char c) override
Place a character on the console area if the coordinates are within the area.
void set_foreground_color(uint16_t x, uint16_t y, common::ConsoleColour foreground) override
Change the foreground color of a character on the console area if the coordinates are within the area...
common::ConsoleColour get_background_color(uint16_t x, uint16_t y) override
Return the background color of the character at the given coordinates if the coordinates are within t...
uint16_t width() override
Return the width of the console area.
ConsoleStream(Console *)
Construct a new Console Stream object.
void write_char(char c) override
write a character to the console stream
void set_cursor(uint16_t x, uint16_t y)
Set the m_position of the cursor.
Abstract class for a console, allows for the printing of characters and strings with colours.
virtual void set_foreground_color(uint16_t x, uint16_t y, common::ConsoleColour foreground)
Set the foreground color of a character on the console.
virtual common::ConsoleColour get_background_color(uint16_t x, uint16_t y)
Get the background color of a character on the console.
virtual void scroll_up()
Scroll the entire console up by 1 line.
virtual char get_character(uint16_t x, uint16_t y)
Get the character at a given coordinate on the console.
virtual uint16_t height()
Get the height of the console in characters.
virtual void put_string(uint16_t x, uint16_t y, string s, common::ConsoleColour foreground=common::ConsoleColour::LightGrey, common::ConsoleColour background=common::ConsoleColour::Black)
Put a string on the console.
virtual void put_character(uint16_t x, uint16_t y, char c)
Put a character on the console.
virtual void invert_colors(uint16_t x, uint16_t y)
Invert the colors of a character on the console.
virtual uint16_t width()
Get the width of the console in characters.
virtual common::ConsoleColour get_foreground_color(uint16_t x, uint16_t y)
Get the background color of a character on the console.
virtual void set_background_color(uint16_t x, uint16_t y, common::ConsoleColour background)
Set the background color of a character on the console.
ConsoleColour
Enumeration of console colour codes.
Defines a Console class for handling text-based console output with colour support.