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: FrameworkDataGlobal data store for the framework
state: StateDefines the layout of items on screen
cursor: CursorStateThe 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
impl Framework
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clears self.history
Sourcepub fn push_history(&mut self)
pub fn push_history(&mut self)
Save current state
Sourcepub fn pop_history(&mut self) -> Option<FrameworkHistory>
pub fn pop_history(&mut self) -> Option<FrameworkHistory>
Removes the last history and returns it
Sourcepub fn revert_last_history(&mut self) -> Result<(), FrameworkError>
pub fn revert_last_history(&mut self) -> Result<(), FrameworkError>
Revert self to last save (if there is)
Sourcepub fn revert_history(&mut self, index: usize) -> Result<(), FrameworkError>
pub fn revert_history(&mut self, index: usize) -> Result<(), FrameworkError>
Revert self to history at index
Source§impl Framework
impl Framework
Sourcepub fn render_raw(
&mut self,
frame: &mut Frame<'_>,
chunks: &[Vec<Rect>],
selected: Option<(usize, usize)>,
hover: Option<(usize, usize)>,
popup_render: bool,
)
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
Sourcepub fn render_only(&mut self, frame: &mut Frame<'_>, x: usize, y: usize)
pub fn render_only(&mut self, frame: &mut Frame<'_>, x: usize, y: usize)
Render only one item
Sourcepub fn render_only_multiple(
&mut self,
frame: &mut Frame<'_>,
locations: &[(usize, usize)],
)
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)>
Sourcepub 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)>,
)
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
Sourcepub fn key_input(&mut self, key: KeyEvent) -> Result<(), Box<dyn Error>>
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
Sourcepub fn mouse_event(&mut self, col: u16, row: u16) -> bool
pub fn mouse_event(&mut self, col: u16, row: u16) -> bool
Handles when mouse is clicked
Sourcepub fn message(&mut self, data: HashMap<String, Box<dyn Any>>) -> bool
pub fn message(&mut self, data: HashMap<String, Box<dyn Any>>) -> bool
Send message to selected object, returns true if anything updated
pub fn load(&mut self) -> Result<(), Box<dyn Error>>
pub fn load_only(&mut self, x: usize, y: usize) -> Result<(), Box<dyn Error>>
pub fn load_only_multiple(&mut self, locations: &[(usize, usize)])
Source§impl Framework
impl Framework
Sourcepub fn split_clean(&mut self) -> (FrameworkClean<'_>, &mut State)
pub fn split_clean(&mut self) -> (FrameworkClean<'_>, &mut State)
Split Framework into FrameworkClean and &mut State
Source§impl Framework
impl Framework
Sourcepub fn move(
&mut self,
direction: FrameworkDirection,
) -> Result<(), FrameworkError>
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
Trait Implementations§
Source§impl From<FrameworkHistory> for Framework
impl From<FrameworkHistory> for Framework
Source§fn from(original: FrameworkHistory) -> Framework
fn from(original: FrameworkHistory) -> Framework
Auto Trait Implementations§
impl Freeze for Framework
impl !RefUnwindSafe for Framework
impl !Send for Framework
impl !Sync for Framework
impl Unpin for Framework
impl !UnwindSafe for Framework
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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