2018-10-30 09:59:29 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "TTY.h"
|
|
|
|
|
#include "Keyboard.h"
|
|
|
|
|
#include "Console.h"
|
|
|
|
|
|
|
|
|
|
class VirtualConsole final : public TTY, public KeyboardClient, public ConsoleImplementation {
|
2018-10-31 19:19:15 -03:00
|
|
|
AK_MAKE_ETERNAL
|
2018-10-30 09:59:29 -03:00
|
|
|
public:
|
|
|
|
|
enum InitialContents { Cleared, AdoptCurrentVGABuffer };
|
|
|
|
|
|
|
|
|
|
VirtualConsole(unsigned index, InitialContents = Cleared);
|
|
|
|
|
virtual ~VirtualConsole() override;
|
|
|
|
|
|
2018-11-01 10:09:21 -03:00
|
|
|
static void switch_to(unsigned);
|
2018-10-30 09:59:29 -03:00
|
|
|
static void initialize();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// ^KeyboardClient
|
2018-12-02 21:39:25 -02:00
|
|
|
virtual void on_key_pressed(Keyboard::Key) override;
|
2018-10-30 09:59:29 -03:00
|
|
|
|
|
|
|
|
// ^ConsoleImplementation
|
2018-12-02 21:39:25 -02:00
|
|
|
virtual void on_sysconsole_receive(byte) override;
|
2018-10-30 09:59:29 -03:00
|
|
|
|
2018-10-30 11:33:37 -03:00
|
|
|
// ^TTY
|
2018-12-02 21:39:25 -02:00
|
|
|
virtual void on_tty_write(const byte*, size_t) override;
|
|
|
|
|
virtual String tty_name() const override;
|
2018-10-30 11:33:37 -03:00
|
|
|
|
2018-11-01 10:09:21 -03:00
|
|
|
void set_active(bool);
|
2018-11-16 17:18:58 -02:00
|
|
|
void on_char(byte);
|
2018-10-30 09:59:29 -03:00
|
|
|
|
2018-11-10 13:25:59 -02:00
|
|
|
void get_vga_cursor(byte& row, byte& column);
|
|
|
|
|
void flush_vga_cursor();
|
|
|
|
|
|
2018-10-30 09:59:29 -03:00
|
|
|
byte* m_buffer;
|
|
|
|
|
unsigned m_index;
|
|
|
|
|
bool m_active { false };
|
|
|
|
|
|
2018-11-01 10:09:21 -03:00
|
|
|
void scroll_up();
|
|
|
|
|
void set_cursor(unsigned row, unsigned column);
|
|
|
|
|
void put_character_at(unsigned row, unsigned column, byte ch);
|
2018-10-30 11:33:37 -03:00
|
|
|
|
2018-11-11 12:36:40 -02:00
|
|
|
void escape$A(const Vector<unsigned>&);
|
2018-12-06 22:19:02 -02:00
|
|
|
void escape$D(const Vector<unsigned>&);
|
2018-10-30 09:59:29 -03:00
|
|
|
void escape$H(const Vector<unsigned>&);
|
|
|
|
|
void escape$J(const Vector<unsigned>&);
|
|
|
|
|
void escape$m(const Vector<unsigned>&);
|
|
|
|
|
void escape$s(const Vector<unsigned>&);
|
|
|
|
|
void escape$u(const Vector<unsigned>&);
|
|
|
|
|
|
2018-11-09 21:56:10 -02:00
|
|
|
void clear();
|
|
|
|
|
|
2018-11-01 10:09:21 -03:00
|
|
|
byte m_cursor_row { 0 };
|
|
|
|
|
byte m_cursor_column { 0 };
|
|
|
|
|
byte m_saved_cursor_row { 0 };
|
|
|
|
|
byte m_saved_cursor_column { 0 };
|
|
|
|
|
byte m_current_attribute { 0x07 };
|
2018-10-30 09:59:29 -03:00
|
|
|
|
2018-11-09 18:18:03 -02:00
|
|
|
void clear_vga_row(word row);
|
|
|
|
|
void set_vga_start_row(word row);
|
|
|
|
|
word m_vga_start_row { 0 };
|
|
|
|
|
word m_current_vga_start_address { 0 };
|
|
|
|
|
byte* m_current_vga_window { nullptr };
|
|
|
|
|
|
2018-11-01 10:09:21 -03:00
|
|
|
void execute_escape_sequence(byte final);
|
2018-10-30 09:59:29 -03:00
|
|
|
|
|
|
|
|
enum EscapeState {
|
|
|
|
|
Normal,
|
|
|
|
|
ExpectBracket,
|
|
|
|
|
ExpectParameter,
|
|
|
|
|
ExpectIntermediate,
|
|
|
|
|
ExpectFinal,
|
|
|
|
|
};
|
2018-11-01 10:09:21 -03:00
|
|
|
EscapeState m_escape_state { Normal };
|
2018-10-30 09:59:29 -03:00
|
|
|
Vector<byte> m_parameters;
|
|
|
|
|
Vector<byte> m_intermediates;
|
2018-12-06 21:17:23 -02:00
|
|
|
byte* m_horizontal_tabs { nullptr };
|
2018-10-30 09:59:29 -03:00
|
|
|
};
|