Add EoT handling

master
itycodes 7 hours ago
parent bff732e688
commit b2d211a7dc

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

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

Loading…
Cancel
Save