mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
LibVT: Tweak input parsing related names
This commit is contained in:
parent
c4edc4c550
commit
06f3eb0ecd
3 changed files with 23 additions and 24 deletions
|
@ -41,7 +41,6 @@ Terminal::~Terminal()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Terminal::clear()
|
void Terminal::clear()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < rows(); ++i)
|
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
|
#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);
|
dbgprintf("Terminal::on_char: %b (%c), fg=%u, bg=%u\n", ch, ch, m_current_attribute.foreground_color, m_current_attribute.background_color);
|
||||||
#endif
|
#endif
|
||||||
switch (m_escape_state) {
|
switch (m_parser_state) {
|
||||||
case GotEscape:
|
case GotEscape:
|
||||||
if (ch == '[') {
|
if (ch == '[') {
|
||||||
m_escape_state = ExpectParameter;
|
m_parser_state = ExpectParameter;
|
||||||
} else if (ch == '(') {
|
} else if (ch == '(') {
|
||||||
m_swallow_current = true;
|
m_swallow_current = true;
|
||||||
m_escape_state = ExpectParameter;
|
m_parser_state = ExpectParameter;
|
||||||
} else if (ch == ']') {
|
} else if (ch == ']') {
|
||||||
m_escape_state = ExpectXtermParameter;
|
m_parser_state = ExpectXtermParameter;
|
||||||
m_xterm_parameters.clear_with_capacity();
|
m_xterm_parameters.clear_with_capacity();
|
||||||
} else if (ch == '#') {
|
} else if (ch == '#') {
|
||||||
m_escape_state = ExpectHashtagDigit;
|
m_parser_state = ExpectHashtagDigit;
|
||||||
} else if (ch == 'D') {
|
} else if (ch == 'D') {
|
||||||
IND();
|
IND();
|
||||||
m_escape_state = Normal;
|
m_parser_state = Normal;
|
||||||
return;
|
return;
|
||||||
} else if (ch == 'M') {
|
} else if (ch == 'M') {
|
||||||
RI();
|
RI();
|
||||||
m_escape_state = Normal;
|
m_parser_state = Normal;
|
||||||
return;
|
return;
|
||||||
} else if (ch == 'E') {
|
} else if (ch == 'E') {
|
||||||
NEL();
|
NEL();
|
||||||
m_escape_state = Normal;
|
m_parser_state = Normal;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
dbg() << "Unexpected character in GotEscape '" << (char)ch << "'";
|
dbg() << "Unexpected character in GotEscape '" << (char)ch << "'";
|
||||||
m_escape_state = Normal;
|
m_parser_state = Normal;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case ExpectHashtagDigit:
|
case ExpectHashtagDigit:
|
||||||
if (ch >= '0' && ch <= '9') {
|
if (ch >= '0' && ch <= '9') {
|
||||||
execute_hashtag(ch);
|
execute_hashtag(ch);
|
||||||
m_escape_state = Normal;
|
m_parser_state = Normal;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case ExpectXtermParameter:
|
case ExpectXtermParameter:
|
||||||
if (ch == 27) {
|
if (ch == 27) {
|
||||||
m_escape_state = ExpectStringTerminator;
|
m_parser_state = ExpectStringTerminator;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ch == 7) {
|
if (ch == 7) {
|
||||||
execute_xterm_command();
|
execute_xterm_command();
|
||||||
m_escape_state = Normal;
|
m_parser_state = Normal;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_xterm_parameters.append(ch);
|
m_xterm_parameters.append(ch);
|
||||||
|
@ -862,31 +861,31 @@ void Terminal::on_char(u8 ch)
|
||||||
execute_xterm_command();
|
execute_xterm_command();
|
||||||
else
|
else
|
||||||
dbg() << "Unexpected string terminator: " << String::format("%02x", ch);
|
dbg() << "Unexpected string terminator: " << String::format("%02x", ch);
|
||||||
m_escape_state = Normal;
|
m_parser_state = Normal;
|
||||||
return;
|
return;
|
||||||
case ExpectParameter:
|
case ExpectParameter:
|
||||||
if (is_valid_parameter_character(ch)) {
|
if (is_valid_parameter_character(ch)) {
|
||||||
m_parameters.append(ch);
|
m_parameters.append(ch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_escape_state = ExpectIntermediate;
|
m_parser_state = ExpectIntermediate;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case ExpectIntermediate:
|
case ExpectIntermediate:
|
||||||
if (is_valid_intermediate_character(ch)) {
|
if (is_valid_intermediate_character(ch)) {
|
||||||
m_intermediates.append(ch);
|
m_intermediates.append(ch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_escape_state = ExpectFinal;
|
m_parser_state = ExpectFinal;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case ExpectFinal:
|
case ExpectFinal:
|
||||||
if (is_valid_final_character(ch)) {
|
if (is_valid_final_character(ch)) {
|
||||||
m_escape_state = Normal;
|
m_parser_state = Normal;
|
||||||
if (!m_swallow_current)
|
if (!m_swallow_current)
|
||||||
execute_escape_sequence(ch);
|
execute_escape_sequence(ch);
|
||||||
m_swallow_current = false;
|
m_swallow_current = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_escape_state = Normal;
|
m_parser_state = Normal;
|
||||||
m_swallow_current = false;
|
m_swallow_current = false;
|
||||||
return;
|
return;
|
||||||
case Normal:
|
case Normal:
|
||||||
|
@ -897,7 +896,7 @@ void Terminal::on_char(u8 ch)
|
||||||
case '\0':
|
case '\0':
|
||||||
return;
|
return;
|
||||||
case '\033':
|
case '\033':
|
||||||
m_escape_state = GotEscape;
|
m_parser_state = GotEscape;
|
||||||
m_swallow_current = false;
|
m_swallow_current = false;
|
||||||
return;
|
return;
|
||||||
case 8: // Backspace
|
case 8: // Backspace
|
||||||
|
@ -947,7 +946,7 @@ void Terminal::on_char(u8 ch)
|
||||||
void Terminal::inject_string(const StringView& str)
|
void Terminal::inject_string(const StringView& str)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < str.length(); ++i)
|
for (size_t i = 0; i < str.length(); ++i)
|
||||||
on_char(str[i]);
|
on_input(str[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Terminal::emit_string(const StringView& string)
|
void Terminal::emit_string(const StringView& string)
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
bool m_need_full_flush { false };
|
bool m_need_full_flush { false };
|
||||||
|
|
||||||
void invalidate_cursor();
|
void invalidate_cursor();
|
||||||
void on_char(u8);
|
void on_input(u8);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void set_size(u16 columns, u16 rows);
|
void set_size(u16 columns, u16 rows);
|
||||||
|
@ -182,7 +182,7 @@ private:
|
||||||
ExpectStringTerminator,
|
ExpectStringTerminator,
|
||||||
};
|
};
|
||||||
|
|
||||||
EscapeState m_escape_state { Normal };
|
EscapeState m_parser_state { Normal };
|
||||||
Vector<u8> m_parameters;
|
Vector<u8> m_parameters;
|
||||||
Vector<u8> m_intermediates;
|
Vector<u8> m_intermediates;
|
||||||
Vector<u8> m_xterm_parameters;
|
Vector<u8> m_xterm_parameters;
|
||||||
|
|
|
@ -82,7 +82,7 @@ void TerminalWidget::set_pty_master_fd(int fd)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (ssize_t i = 0; i < nread; ++i)
|
for (ssize_t i = 0; i < nread; ++i)
|
||||||
m_terminal.on_char(buffer[i]);
|
m_terminal.on_input(buffer[i]);
|
||||||
flush_dirty_lines();
|
flush_dirty_lines();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue