1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:27:35 +00:00

Start working on virtual consoles/TTYs.

This is a mess right now, but I'd rather commit as I go.
This commit is contained in:
Andreas Kling 2018-10-30 13:59:29 +01:00
parent bd2b5327d0
commit 68739dc43e
22 changed files with 611 additions and 344 deletions

View file

@ -4,6 +4,12 @@
#include <AK/Vector.h>
#include <VirtualFileSystem/CharacterDevice.h>
class ConsoleImplementation {
public:
virtual ~ConsoleImplementation();
virtual void onConsoleReceive(byte) = 0;
};
class Console final : public CharacterDevice {
public:
static Console& the() PURE;
@ -15,37 +21,11 @@ public:
virtual ssize_t read(byte* buffer, size_t size) override;
virtual ssize_t write(const byte* data, size_t size) override;
void setImplementation(ConsoleImplementation* implementation) { m_implementation = implementation; }
void putChar(char);
private:
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>&);
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<byte> m_parameters;
Vector<byte> m_intermediates;
ConsoleImplementation* m_implementation { nullptr };
};