wip: edn minefield

This commit is contained in:
🪞👃🪞 2025-01-04 12:23:33 +01:00
parent 98d2107e4e
commit 6f51872856
7 changed files with 150 additions and 210 deletions

View file

@ -6,7 +6,6 @@ mod input; pub use self::input::*;
mod output; pub use self::output::*;
pub mod tui;
#[cfg(feature = "edn")] pub mod edn;
pub use std::error::Error;

View file

@ -125,7 +125,7 @@ impl<T: Content<Tui> + Handle<Tui> + Sized + 'static> TuiRun<T> for Arc<RwLock<T
},
_ => {
let exited = exited.clone();
if let Err(e) = state.write().unwrap().handle(&TuiIn { event, exited }) {
if let Err(e) = state.write().unwrap().handle(&TuiIn(exited, event)) {
panic!("{e}")
}
}

View file

@ -1,23 +1,15 @@
use crate::{*, tui::*};
pub use crossterm::event::Event;
use Event as CrosstermEvent;
#[derive(Debug, Clone)]
pub struct TuiIn {
pub(crate) exited: Arc<AtomicBool>,
pub(crate) event: Event,
}
pub struct TuiIn(pub Arc<AtomicBool>, pub CrosstermEvent);
impl Input<Tui> for TuiIn {
type Event = Event;
fn event (&self) -> &Event {
&self.event
}
fn is_done (&self) -> bool {
self.exited.fetch_and(true, Relaxed)
}
fn done (&self) {
self.exited.store(true, Relaxed);
}
fn event (&self) -> &CrosstermEvent { &self.1 }
fn is_done (&self) -> bool { self.0.fetch_and(true, Relaxed) }
fn done (&self) { self.0.store(true, Relaxed); }
}
/// Define a key