Fix escape bytes as input bug in ANSI parser

There were several unrecognized escape codes that have arguments which
were being interpretted as input. Naturally, this caused state to be
corrupt. The escape codes are now handled by throwing away the bytes.
Consider this a TODO for later.
This commit is contained in:
Joe Wilm 2016-06-06 17:41:03 -07:00
parent cdea958e71
commit 263a4e8a2e
No known key found for this signature in database
GPG Key ID: 39B57C6972F518DA
1 changed files with 21 additions and 0 deletions

View File

@ -421,6 +421,9 @@ impl Parser {
},
State::Csi => {
self.csi(handler, c);
},
State::EscapeOther => {
self.other(handler, c);
}
}
}
@ -431,6 +434,18 @@ impl Parser {
handler.input(c);
}
fn other<H>(&mut self, handler: &mut H, c: char)
where H: Handler
{
if c == 0x07 as char || c == 0x18 as char || c == 0x1a as char ||
c == 0x1b as char || is_control_c1(c)
{
self.state = State::Base;
}
// TODO actually use these bytes. For now, we just throw them away.
}
/// Handle character following an ESC
///
/// TODO Handle `ST`, `'#'`, `'P'`, `'_'`, `'^'`, `']'`, `'k'`,
@ -458,6 +473,9 @@ impl Parser {
'c' => sequence_complete!(reset_state),
'7' => sequence_complete!(save_cursor_position),
'8' => sequence_complete!(restore_cursor_position),
'P' | '_' | '^' | ']' | 'k' | '(' => {
self.state = State::EscapeOther;
},
_ => {
self.state = State::Base;
err_println!("Unknown ESC 0x{:02x} {:?}", c as usize, c);
@ -1042,6 +1060,9 @@ enum State {
/// Parsing a CSI escape,
Csi,
/// Parsing non csi escape
EscapeOther,
}
impl Default for State {