summaryrefslogtreecommitdiff
path: root/Widgets/TerminalWidget.h
blob: ba77c5d10aa82f7ef8e98a3cd44514d1e2cf533b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#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; }
    
private:
    CharacterWithAttributes& at(unsigned row, unsigned column);

    virtual void onPaint(PaintEvent&) override;
    void onReceive(const ByteBuffer&);
    void onReceive(byte);

    unsigned m_columns { 80 };
    unsigned m_rows { 25 };

    unsigned m_cursorRow { 0 };
    unsigned m_cursorColumn { 0 };

    CharacterWithAttributes* m_screen { nullptr };
};