|
|
|
@ -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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|