#pragma once #include #include #include class Console final : public CharacterDevice { public: static Console& the() PURE; Console(); virtual ~Console() override; virtual bool hasDataAvailableForRead() const override; virtual ssize_t read(byte* buffer, size_t size) override; virtual ssize_t write(const byte* data, size_t size) override; void putChar(char); private: void escape$H(const Vector&); void escape$J(const Vector&); void escape$m(const Vector&); void escape$s(const Vector&); void escape$u(const Vector&); const byte m_rows { 25 }; const byte m_columns { 80 }; byte m_cursorRow { 0 }; byte m_cursorColumn { 0 }; byte m_savedCursorRow { 0 }; byte m_savedCursorColumn { 0 }; byte m_currentAttribute { 0x07 }; void executeEscapeSequence(byte final); enum EscapeState { Normal, ExpectBracket, ExpectParameter, ExpectIntermediate, ExpectFinal, }; EscapeState m_escState { Normal }; Vector m_parameters; Vector m_intermediates; };