mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
![Andreas Kling](/assets/img/avatar_default.png)
There's some really hideous plumbing with globals going on here, but my priority right now is getting a basic VT100 terminal emulator working.
37 lines
844 B
C++
37 lines
844 B
C++
#pragma once
|
|
|
|
#include "Widget.h"
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
struct CharacterWithAttributes {
|
|
byte character;
|
|
byte attribute;
|
|
};
|
|
|
|
class TerminalWidget final : public Widget {
|
|
public:
|
|
explicit TerminalWidget(Widget* parent);
|
|
virtual ~TerminalWidget() override;
|
|
|
|
unsigned rows() const { return m_rows; }
|
|
unsigned columns() const { return m_columns; }
|
|
|
|
void onReceive(const ByteBuffer&);
|
|
void onReceive(byte);
|
|
|
|
private:
|
|
CharacterWithAttributes& at(unsigned row, unsigned column);
|
|
|
|
virtual void onPaint(PaintEvent&) override;
|
|
virtual void onKeyDown(KeyEvent&) override;
|
|
virtual void onKeyUp(KeyEvent&) override;
|
|
|
|
unsigned m_columns { 80 };
|
|
unsigned m_rows { 25 };
|
|
|
|
unsigned m_cursorRow { 0 };
|
|
unsigned m_cursorColumn { 0 };
|
|
|
|
CharacterWithAttributes* m_screen { nullptr };
|
|
};
|