Add EoT handling

master
itycodes 6 hours ago
parent bff732e688
commit b2d211a7dc

@ -105,6 +105,10 @@ impl SequenceState {
self.out_buf.push(InputChar::Backspace);
Result::Ok(())
}
else if chr == 0x04 {
self.out_buf.push(InputChar::EoT);
Result::Ok(())
}
// Unrecognized
else {
Result::Err(AcceptError::Unimplemented(chr))

@ -1,6 +1,6 @@
#![allow(unused)]
use std::mem::MaybeUninit;
use std::{io::Read, mem::MaybeUninit};
use crate::reader::esc_parse::{InputChar, bell, hide_cursor, show_cursor};
@ -24,7 +24,8 @@ pub enum InitTTYError {
#[derive(Debug)]
pub enum ReadError {
EscapeError(esc_parse::AcceptError)
EscapeError(esc_parse::AcceptError),
Exited,
}
#[derive(Debug)]
@ -35,6 +36,7 @@ pub enum EditCommand {
CursorBack,
CursorForward,
DeleteBack,
Exit,
}
macro_rules! edit_cmd {
@ -145,6 +147,9 @@ impl ReaderState {
if chr == InputChar::Backspace {
return edit_cmd!(DeleteBack);
}
if chr == InputChar::EoT {
return edit_cmd!(Exit);
}
}
}
}
@ -197,7 +202,8 @@ impl ReaderState {
},
HistoryNext => {
self.history_front();
}
},
Exit => return Err(ReadError::Exited)
}
}
}

Loading…
Cancel
Save