Migrate input handling to new bindings
This commit is contained in:
parent
202969c7a9
commit
9bc6931fae
18 changed files with 748 additions and 1222 deletions
|
|
@ -7,8 +7,10 @@ edition = { workspace = true }
|
|||
cove-macro = { path = "../cove-macro" }
|
||||
|
||||
crossterm = { workspace = true }
|
||||
parking_lot = {workspace = true}
|
||||
parking_lot = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_either = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
toss = {workspace = true}
|
||||
toss = { workspace = true }
|
||||
|
||||
edit = "0.1.4"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
mod keys;
|
||||
|
||||
use std::io;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub use cove_macro::KeyGroup;
|
||||
use crossterm::event::{Event, KeyEvent};
|
||||
use parking_lot::FairMutex;
|
||||
use toss::Terminal;
|
||||
use toss::{Frame, Terminal, WidthDb};
|
||||
|
||||
pub use crate::keys::*;
|
||||
|
||||
|
|
@ -53,4 +54,22 @@ impl<'a> InputEvent<'a> {
|
|||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn frame(&mut self) -> &mut Frame {
|
||||
self.terminal.frame()
|
||||
}
|
||||
|
||||
pub fn widthdb(&mut self) -> &mut WidthDb {
|
||||
self.terminal.widthdb()
|
||||
}
|
||||
|
||||
pub fn prompt(&mut self, initial_text: &str) -> io::Result<String> {
|
||||
let guard = self.crossterm_lock.lock();
|
||||
self.terminal.suspend().expect("failed to suspend");
|
||||
let content = edit::edit(initial_text);
|
||||
self.terminal.unsuspend().expect("fauled to unsuspend");
|
||||
drop(guard);
|
||||
|
||||
content
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue