diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-16 19:24:24 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-16 19:30:46 +0200 |
commit | 06f3eb0ecd0f5eba7767a214fae5ee50f544b146 (patch) | |
tree | 7d2de5bfecdf14d2ad44f851b12d0fa362f07b9a /Libraries/LibVT | |
parent | c4edc4c550bc6ec3f8ce452426efd31d872fd71f (diff) | |
download | serenity-06f3eb0ecd0f5eba7767a214fae5ee50f544b146.zip |
LibVT: Tweak input parsing related names
Diffstat (limited to 'Libraries/LibVT')
-rw-r--r-- | Libraries/LibVT/Terminal.cpp | 41 | ||||
-rw-r--r-- | Libraries/LibVT/Terminal.h | 4 | ||||
-rw-r--r-- | Libraries/LibVT/TerminalWidget.cpp | 2 |
3 files changed, 23 insertions, 24 deletions
diff --git a/Libraries/LibVT/Terminal.cpp b/Libraries/LibVT/Terminal.cpp index ca0f08781e..3e495c8416 100644 --- a/Libraries/LibVT/Terminal.cpp +++ b/Libraries/LibVT/Terminal.cpp @@ -41,7 +41,6 @@ Terminal::~Terminal() { } - void Terminal::clear() { for (size_t i = 0; i < rows(); ++i) @@ -805,54 +804,54 @@ void Terminal::DSR(const ParamVector& params) } } -void Terminal::on_char(u8 ch) +void Terminal::on_input(u8 ch) { #ifdef TERMINAL_DEBUG dbgprintf("Terminal::on_char: %b (%c), fg=%u, bg=%u\n", ch, ch, m_current_attribute.foreground_color, m_current_attribute.background_color); #endif - switch (m_escape_state) { + switch (m_parser_state) { case GotEscape: if (ch == '[') { - m_escape_state = ExpectParameter; + m_parser_state = ExpectParameter; } else if (ch == '(') { m_swallow_current = true; - m_escape_state = ExpectParameter; + m_parser_state = ExpectParameter; } else if (ch == ']') { - m_escape_state = ExpectXtermParameter; + m_parser_state = ExpectXtermParameter; m_xterm_parameters.clear_with_capacity(); } else if (ch == '#') { - m_escape_state = ExpectHashtagDigit; + m_parser_state = ExpectHashtagDigit; } else if (ch == 'D') { IND(); - m_escape_state = Normal; + m_parser_state = Normal; return; } else if (ch == 'M') { RI(); - m_escape_state = Normal; + m_parser_state = Normal; return; } else if (ch == 'E') { NEL(); - m_escape_state = Normal; + m_parser_state = Normal; return; } else { dbg() << "Unexpected character in GotEscape '" << (char)ch << "'"; - m_escape_state = Normal; + m_parser_state = Normal; } return; case ExpectHashtagDigit: if (ch >= '0' && ch <= '9') { execute_hashtag(ch); - m_escape_state = Normal; + m_parser_state = Normal; } return; case ExpectXtermParameter: if (ch == 27) { - m_escape_state = ExpectStringTerminator; + m_parser_state = ExpectStringTerminator; return; } if (ch == 7) { execute_xterm_command(); - m_escape_state = Normal; + m_parser_state = Normal; return; } m_xterm_parameters.append(ch); @@ -862,31 +861,31 @@ void Terminal::on_char(u8 ch) execute_xterm_command(); else dbg() << "Unexpected string terminator: " << String::format("%02x", ch); - m_escape_state = Normal; + m_parser_state = Normal; return; case ExpectParameter: if (is_valid_parameter_character(ch)) { m_parameters.append(ch); return; } - m_escape_state = ExpectIntermediate; + m_parser_state = ExpectIntermediate; [[fallthrough]]; case ExpectIntermediate: if (is_valid_intermediate_character(ch)) { m_intermediates.append(ch); return; } - m_escape_state = ExpectFinal; + m_parser_state = ExpectFinal; [[fallthrough]]; case ExpectFinal: if (is_valid_final_character(ch)) { - m_escape_state = Normal; + m_parser_state = Normal; if (!m_swallow_current) execute_escape_sequence(ch); m_swallow_current = false; return; } - m_escape_state = Normal; + m_parser_state = Normal; m_swallow_current = false; return; case Normal: @@ -897,7 +896,7 @@ void Terminal::on_char(u8 ch) case '\0': return; case '\033': - m_escape_state = GotEscape; + m_parser_state = GotEscape; m_swallow_current = false; return; case 8: // Backspace @@ -947,7 +946,7 @@ void Terminal::on_char(u8 ch) void Terminal::inject_string(const StringView& str) { for (size_t i = 0; i < str.length(); ++i) - on_char(str[i]); + on_input(str[i]); } void Terminal::emit_string(const StringView& string) diff --git a/Libraries/LibVT/Terminal.h b/Libraries/LibVT/Terminal.h index ce3c4201d3..0ac38ec5a0 100644 --- a/Libraries/LibVT/Terminal.h +++ b/Libraries/LibVT/Terminal.h @@ -54,7 +54,7 @@ public: bool m_need_full_flush { false }; void invalidate_cursor(); - void on_char(u8); + void on_input(u8); void clear(); void set_size(u16 columns, u16 rows); @@ -182,7 +182,7 @@ private: ExpectStringTerminator, }; - EscapeState m_escape_state { Normal }; + EscapeState m_parser_state { Normal }; Vector<u8> m_parameters; Vector<u8> m_intermediates; Vector<u8> m_xterm_parameters; diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp index dd0af50c04..eec83c415b 100644 --- a/Libraries/LibVT/TerminalWidget.cpp +++ b/Libraries/LibVT/TerminalWidget.cpp @@ -82,7 +82,7 @@ void TerminalWidget::set_pty_master_fd(int fd) return; } for (ssize_t i = 0; i < nread; ++i) - m_terminal.on_char(buffer[i]); + m_terminal.on_input(buffer[i]); flush_dirty_lines(); }; } |