mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:27:35 +00:00
Start working on a graphical Terminal program.
This commit is contained in:
parent
b673c1a77d
commit
6d8043767e
8 changed files with 601 additions and 4 deletions
70
Terminal/Terminal.h
Normal file
70
Terminal/Terminal.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <Widgets/GraphicsBitmap.h>
|
||||
|
||||
|
||||
class Terminal {
|
||||
public:
|
||||
Terminal();
|
||||
~Terminal();
|
||||
|
||||
void create_window();
|
||||
void paint();
|
||||
void on_char(byte);
|
||||
|
||||
private:
|
||||
void scroll_up();
|
||||
void set_cursor(unsigned row, unsigned column);
|
||||
void put_character_at(unsigned row, unsigned column, byte ch);
|
||||
|
||||
void escape$A(const Vector<unsigned>&);
|
||||
void escape$D(const Vector<unsigned>&);
|
||||
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>&);
|
||||
|
||||
void clear();
|
||||
|
||||
void set_size(word columns, word rows);
|
||||
word columns() const { return m_columns; }
|
||||
word rows() const { return m_rows; }
|
||||
|
||||
void inject_string_at(word row, word column, const String&);
|
||||
|
||||
byte* m_buffer { nullptr };
|
||||
|
||||
word m_columns { 0 };
|
||||
word m_rows { 0 };
|
||||
|
||||
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 };
|
||||
|
||||
void execute_escape_sequence(byte final);
|
||||
|
||||
enum EscapeState {
|
||||
Normal,
|
||||
ExpectBracket,
|
||||
ExpectParameter,
|
||||
ExpectIntermediate,
|
||||
ExpectFinal,
|
||||
};
|
||||
EscapeState m_escape_state { Normal };
|
||||
Vector<byte> m_parameters;
|
||||
Vector<byte> m_intermediates;
|
||||
byte* m_horizontal_tabs { nullptr };
|
||||
bool m_belling { false };
|
||||
|
||||
int m_window_id { 0 };
|
||||
RetainPtr<GraphicsBitmap> m_backing;
|
||||
|
||||
int m_pixel_width { 0 };
|
||||
int m_pixel_height { 0 };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue