few changes
This commit is contained in:
@@ -19,18 +19,6 @@ pub fn flush() -> crate::Result<()> {
|
||||
std::io::stdout().flush()
|
||||
}
|
||||
|
||||
pub fn init() -> crate::Result<()> {
|
||||
crossterm::terminal::enable_raw_mode()?;
|
||||
clear()?;
|
||||
hide_cursor()
|
||||
}
|
||||
|
||||
pub fn end() -> crate::Result<()> {
|
||||
crossterm::terminal::disable_raw_mode()?;
|
||||
clear()?;
|
||||
show_cursor()
|
||||
}
|
||||
|
||||
pub fn str_size(s: &str) -> (u16, u16) {
|
||||
let mut height = 1;
|
||||
let mut max_width = 0;
|
||||
@@ -50,25 +38,3 @@ pub fn str_size(s: &str) -> (u16, u16) {
|
||||
|
||||
(max_width, height)
|
||||
}
|
||||
|
||||
pub enum Event {
|
||||
Key(crossterm::event::KeyEvent),
|
||||
Resize(u16, u16),
|
||||
Mouse(crossterm::event::MouseEvent),
|
||||
Paste(String),
|
||||
FocusGained,
|
||||
FocusLost,
|
||||
}
|
||||
|
||||
pub fn read() -> crate::Result<Event> {
|
||||
let event = crossterm::event::read()?;
|
||||
|
||||
Ok(match event {
|
||||
crossterm::event::Event::Key(k) => Event::Key(k),
|
||||
crossterm::event::Event::Resize(w, h) => Event::Resize(w, h),
|
||||
crossterm::event::Event::FocusGained => Event::FocusGained,
|
||||
crossterm::event::Event::FocusLost => Event::FocusLost,
|
||||
crossterm::event::Event::Mouse(m) => Event::Mouse(m),
|
||||
crossterm::event::Event::Paste(p) => Event::Paste(p),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user