fatui 0.1.0

a silly little framework for terminal user interfaces
Documentation
//! inputs from [i/o][crate::backend]
//!
//! by default, inputs are simple [`Event`]s --
//! they translate very directly to the raw inputs and outputs.
//! (but be sure to check the docs for the relevant `Backend` for caveats!)
//!
//! because they're so simple, though, they're usually hard to use.
//! much more commonly, you want to keep an [`InputState`],
//! to get [`StateEvent`]s.
//! something like this:
//!
//! ```rs
//! let mut backend =

use std::fmt;

use crate::pos::{X, Y};

pub use crossterm::event::{KeyCode, MouseButton};

mod event;
pub use event::Event;
mod state;
pub use state::{InputState, Keys, StateEvent};

/// types which can be passed around as `Input` to a [`Frame`][crate::Frame]
///
/// this is currently sealed, meaning it can only be implemented by types in this crate.
/// it may be unsealed in the future once a better abstraction is invented...
#[expect(private_bounds)] // for sealant trait
pub trait FrameInput: fmt::Debug + Clone + crate::Sealed {
	/// get the left and right inputs for when a frame is horizontally split
	fn split_h(self, mid: X) -> (Self, Self);
	/// get the top and bottom inputs for when a frame is vertically split
	fn split_v(self, mid: Y) -> (Self, Self);
}

/// for frames ontologically incapable of input
///
/// (this is really only useful in tests.)
#[derive(Clone, Copy, Debug)]
pub struct Nop;
crate::seal!(Nop);
impl FrameInput for Nop {
	fn split_h(self, _: X) -> (Self, Self) {
		(Self, Self)
	}
	fn split_v(self, _: Y) -> (Self, Self) {
		(Self, Self)
	}
}