ignore high bytes in command strings
Meriel Luna Mittelbach 10 months ago
parent bc64790 · commit 9a36b7b
-rw-r--r--src/lib.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 4e4f60b..9c3a7be 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -604,7 +604,11 @@ impl TerminalInputParser {
pub fn parse_byte(&mut self, byte: u8) -> TerminalInput {
if byte >= 0x80 {
- if self.state != State::Ground {
+ if matches!(self.state, State::CommandString | State::CharacterString) {
+ self.ctl.bytes.push(byte);
+ return TerminalInput::Continue;
+ }
+ else if self.state != State::Ground {
self.state.poison();
return TerminalInput::Continue;
}
@@ -636,6 +640,11 @@ impl TerminalInputParser {
};
let is_bell = byte == b'\x07'; // \a
+
+ // if is_bell {
+ // dbg!(&self);
+ // }
+
if is_bell && (self.state == State::CommandString || self.state == State::CharacterString) {
state = State::FinishSequence;
}
@@ -725,11 +734,11 @@ mod tests {
#[test]
fn bendn() {
let mut t = super::TerminalInputParser::new();
- for &char in "\x1b]7;file://klunk/home/os/pattypan\x07\x1b]0;~/pattypan\x07\x1b[30m\x1b(B\x1b[m hi sartha"
+ for &char in "]0; fish in  pattypan \n[?2004h[>4;1m[=5u= no chars get through?"
.as_bytes()
{
use super::TerminalInput::*;
- dbg!(char as char, t.parse_byte(char));
+ println!("{char:?}, {:?}", t.parse_byte(char));
}
}
}