pub struct TypingWidget<C> {
pub size_and_position: SizeAndPosition,
pub render_function: Option<Box<dyn Fn((u16, u16), (u16, u16), &[&str; 2], bool) -> Option<Vec<Span>>>>,
pub typed_text: String,
pub selected: bool,
pub cursor_pos: usize,
/* private fields */
}Expand description
A widget that renders static content using a provided closure (i.e.
a title box or description).
Suitable for content that doesn’t change frequently or in response to events.
TypingWidgetBuilder is the associated builder for creating instances of this widget.
The generic parameter C represents the application data type, which can be any type defined by the user.
Fields§
§size_and_position: SizeAndPositionConfiguration for the widget’s size and position, supporting both static and dynamic layouts.
render_function: Option<Box<dyn Fn((u16, u16), (u16, u16), &[&str; 2], bool) -> Option<Vec<Span>>>>Optional closure that generates the widget’s rendered content based on size and position.
typed_text: StringThe text that has been typed into the widget so far.
selected: boolIndicates whether the widget is currently selected (focused for input).
cursor_pos: usizeImplementations§
Source§impl<C> TypingWidget<C>
impl<C> TypingWidget<C>
Sourcepub fn new(
name: String,
size_and_position: SizeAndPosition,
render_function: Option<Box<dyn Fn((u16, u16), (u16, u16), &[&str; 2], bool) -> Option<Vec<Span>>>>,
depth: u16,
display_area: &Rect,
) -> Result<(TypingWidget<C>, Window), WidgetErr>
pub fn new( name: String, size_and_position: SizeAndPosition, render_function: Option<Box<dyn Fn((u16, u16), (u16, u16), &[&str; 2], bool) -> Option<Vec<Span>>>>, depth: u16, display_area: &Rect, ) -> Result<(TypingWidget<C>, Window), WidgetErr>
Creates a new TypingWidget and its associated window.
§Arguments
name- Unique identifier for the widgetsize_and_position- Configuration for size and positioningrender_function- Optional closure that renders content given size and positiondepth- Z-index for rendering orderdisplay_area- Current terminal area for initial size/position calculation
§Returns
Result containing the widget and window, or error if dimensions are invalid
When possible, an implementation of WidgetBuilder should be used instead, both for safety,
simplicity, and consistency.
Trait Implementations§
Source§impl<C> Widget<C> for TypingWidget<C>
Implementation of the methods for TypingWidget
impl<C> Widget<C> for TypingWidget<C>
Implementation of the methods for TypingWidget
Source§fn get_window_ref(&self) -> String
fn get_window_ref(&self) -> String
Returns the widget’s name as an identifier. The rendering backend relies
on String names instead of widgets.
Source§fn update_with_events(
&mut self,
data: &mut C,
app: &mut App<C>,
scene: &mut Scene<C>,
)
fn update_with_events( &mut self, data: &mut C, app: &mut App<C>, scene: &mut Scene<C>, )
Handles event updates. However, compared to the other widgets, this one doesn’t directly act to modify the widget, but rather to respond to changes in text input.
Source§fn update_render(&mut self, window: &mut Window, area: &Rect) -> bool
fn update_render(&mut self, window: &mut Window, area: &Rect) -> bool
Updates the widget’s rendering based on current size and position.
Called automatically during render passes.
If Some(render_closure) is provided, that closure will be called.
If the closure returns Some(Vec<Span>), then the rendered content will be set as such.
Source§fn get_children_indexes(&self) -> Vec<usize>
fn get_children_indexes(&self) -> Vec<usize>
Returns the indices of child widgets in the scene graph.
Source§fn add_child_index(&mut self, index: usize)
fn add_child_index(&mut self, index: usize)
Adds a child widget index to this widget.
Source§fn remove_child_index(&mut self, index: usize)
fn remove_child_index(&mut self, index: usize)
Removes a child widget index from this widget
Source§fn clear_children_indexes(&mut self)
fn clear_children_indexes(&mut self)
Clears all child widget indices from this widget
Source§fn get_parent_index(&self) -> Option<usize>
fn get_parent_index(&self) -> Option<usize>
Returns the parent widget index if one exists, otherwise None.
Source§fn set_parent_index(&mut self, index: Option<usize>)
fn set_parent_index(&mut self, index: Option<usize>)
Sets the parent widget index for this widget, or None for a root node.