mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:17:45 +00:00
LibVT: Add incremental UTF-8 parsing to the terminal input handler
Instead of relying on the GUI code to handle UTF-8, we now process and parse the incoming data into 32-bit codepoints ourselves. This means that you can now show emojis in the terminal and they will only take up one character cell each. :^)
This commit is contained in:
parent
06f3eb0ecd
commit
b8498dc55e
2 changed files with 70 additions and 14 deletions
|
@ -101,6 +101,8 @@ public:
|
|||
private:
|
||||
typedef Vector<unsigned, 4> ParamVector;
|
||||
|
||||
void on_codepoint(u32);
|
||||
|
||||
void scroll_up();
|
||||
void scroll_down();
|
||||
void newline();
|
||||
|
@ -171,7 +173,7 @@ private:
|
|||
void execute_xterm_command();
|
||||
void execute_hashtag(u8);
|
||||
|
||||
enum EscapeState {
|
||||
enum ParserState {
|
||||
Normal,
|
||||
GotEscape,
|
||||
ExpectParameter,
|
||||
|
@ -180,9 +182,13 @@ private:
|
|||
ExpectHashtagDigit,
|
||||
ExpectXtermParameter,
|
||||
ExpectStringTerminator,
|
||||
UTF8Needs3Bytes,
|
||||
UTF8Needs2Bytes,
|
||||
UTF8Needs1Byte,
|
||||
};
|
||||
|
||||
EscapeState m_parser_state { Normal };
|
||||
ParserState m_parser_state { Normal };
|
||||
u32 m_parser_codepoint { 0 };
|
||||
Vector<u8> m_parameters;
|
||||
Vector<u8> m_intermediates;
|
||||
Vector<u8> m_xterm_parameters;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue