Framework

Struct Framework 

Source
pub struct Framework {
    pub selectables: Vec<Vec<(usize, usize)>>,
    pub data: FrameworkData,
    pub state: State,
    pub cursor: CursorState,
    pub history: Vec<FrameworkHistory>,
    pub frame_area: Option<Rect>,
}
Expand description

Struct for a declarative TUI framework

Copy & paste examples can be found here

Fields§

§selectables: Vec<Vec<(usize, usize)>>

Selectable items, auto generated when state is set with new() or set_state()

§data: FrameworkData

Global data store for the framework

§state: State

Defines the layout of items on screen

§cursor: CursorState

The state and position of cursor

§history: Vec<FrameworkHistory>

Stores saved states

§frame_area: Option<Rect>

Stores the area of the previous frame

Implementations§

Source§

impl Framework

Source

pub fn clear_history(&mut self)

Clears self.history

Source

pub fn push_history(&mut self)

Save current state

Source

pub fn pop_history(&mut self) -> Option<FrameworkHistory>

Removes the last history and returns it

Source

pub fn revert_last_history(&mut self) -> Result<(), FrameworkError>

Revert self to last save (if there is)

Source

pub fn revert_history(&mut self, index: usize) -> Result<(), FrameworkError>

Revert self to history at index

Source§

impl Framework

Source

pub fn is_selected(&self) -> bool

Source

pub fn is_hover(&self) -> bool

Source

pub fn is_none(&self) -> bool

Source§

impl Framework

Source

pub fn new(state: State) -> Self

Create a new Framework struct

Source

pub fn set_state(&mut self, state: State)

Set self.state and also update self.selectables

Source

pub fn render(&mut self, frame: &mut Frame<'_>)

Render every item to screen

Source

pub fn render_raw( &mut self, frame: &mut Frame<'_>, chunks: &[Vec<Rect>], selected: Option<(usize, usize)>, hover: Option<(usize, usize)>, popup_render: bool, )

Render to screen with more controls

Source

pub fn render_only(&mut self, frame: &mut Frame<'_>, x: usize, y: usize)

Render only one item

Source

pub fn render_only_multiple( &mut self, frame: &mut Frame<'_>, locations: &[(usize, usize)], )

Render multiple items

Location is in a format of Vec<(x, y)>

Source

pub fn render_only_raw( &mut self, frame: &mut Frame<'_>, x: usize, y: usize, chunk: Rect, popup_render: bool, selected: Option<(usize, usize)>, hover: Option<(usize, usize)>, )

Render only with more controls

Source

pub fn key_input(&mut self, key: KeyEvent) -> Result<(), Box<dyn Error>>

Send key input to selected object, returns an Err(()) when no objct is selected

Source

pub fn mouse_event(&mut self, col: u16, row: u16) -> bool

Handles when mouse is clicked

Source

pub fn message(&mut self, data: HashMap<String, Box<dyn Any>>) -> bool

Send message to selected object, returns true if anything updated

Source

pub fn load(&mut self) -> Result<(), Box<dyn Error>>

Source

pub fn load_only(&mut self, x: usize, y: usize) -> Result<(), Box<dyn Error>>

Source

pub fn load_only_multiple(&mut self, locations: &[(usize, usize)])

Source§

impl Framework

Source

pub fn split_clean(&mut self) -> (FrameworkClean<'_>, &mut State)

Split Framework into FrameworkClean and &mut State

Source§

impl Framework

Source

pub fn move( &mut self, direction: FrameworkDirection, ) -> Result<(), FrameworkError>

Move cursor in corresponding direction, will return an Err(E) if something is selected and the cursor is not free to move around

Source

pub fn select(&mut self) -> Result<(), Box<dyn Error>>

Select the hovering item

Source

pub fn deselect(&mut self) -> Result<(), Box<dyn Error>>

Deselect the hovering item

Trait Implementations§

Source§

impl Clone for Framework

Source§

fn clone(&self) -> Framework

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> From<&'a mut Framework> for (FrameworkClean<'a>, &'a mut State)

Source§

fn from(original: &'a mut Framework) -> (FrameworkClean<'a>, &'a mut State)

Converts to this type from the input type.
Source§

impl From<FrameworkHistory> for Framework

Source§

fn from(original: FrameworkHistory) -> Framework

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneAny for T
where T: Any + Clone,

Source§

fn clone_any(&self) -> Box<dyn CloneAny>

Source§

fn clone_any_send(&self) -> Box<dyn CloneAny + Send>
where T: Send,

Source§

fn clone_any_sync(&self) -> Box<dyn CloneAny + Sync>
where T: Sync,

Source§

fn clone_any_send_sync(&self) -> Box<dyn CloneAny + Send + Sync>
where T: Send + Sync,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnsafeAny for T
where T: Any,