diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-15 04:30:55 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-15 04:30:55 +0100 |
commit | 6d8043767ed3b7441ff7f2db4ea7ae47937cdad6 (patch) | |
tree | 46addd238ade4830278a56968b0022bab4bd63f1 /Terminal/Terminal.h | |
parent | b673c1a77d0af50ddb57d3b82f56141059150007 (diff) | |
download | serenity-6d8043767ed3b7441ff7f2db4ea7ae47937cdad6.zip |
Start working on a graphical Terminal program.
Diffstat (limited to 'Terminal/Terminal.h')
-rw-r--r-- | Terminal/Terminal.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/Terminal/Terminal.h b/Terminal/Terminal.h new file mode 100644 index 0000000000..8f4ef4aa4b --- /dev/null +++ b/Terminal/Terminal.h @@ -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 }; +}; |