Input

Struct Input 

Source
pub struct Input { /* private fields */ }

Implementations§

Source§

impl Input

Source

pub const TEMPLATE: &'static str = "container [min_width: 1, height: 1]\n zstack\n // Text\n padding [right: 0]\n overflow [axis: \"horz\"]\n if state.text\n text state.text\n else\n $children\n\n // Cursor\n position [left: state.screen_cursor]\n container [\n background: attributes.cursor_color_bg ? \"green\", \n foreground: attributes.cursor_color_fg ? \"black\", \n width: 1, \n height: 1,\n ]\n"

Source

pub fn new() -> Self

Source

pub fn template() -> SourceKind

Examples found in repository?
examples/input.rs (line 55)
42fn main() {
43    let doc = Document::new("@index");
44
45    let mut backend = TuiBackend::builder()
46        .enable_alt_screen()
47        .enable_raw_mode()
48        .hide_cursor()
49        .finish()
50        .unwrap();
51    backend.finalize();
52
53    let mut builder = Runtime::builder(doc, &backend);
54    builder
55        .default::<Input>("input", Input::template())
56        .unwrap();
57    builder
58        .default::<Index>("index", template_str().to_template())
59        .unwrap();
60    let res = builder.finish(&mut backend, |runtime, backend| runtime.run(backend));
61
62    if let Err(e) = res {
63        eprintln!("{e}");
64    }
65}

Trait Implementations§

Source§

impl Component for Input

Source§

type Message = ()

Source§

type State = InputState

Source§

fn on_key( &mut self, key: KeyEvent, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source§

fn on_blur( &mut self, _: &mut Self::State, _: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source§

fn on_focus( &mut self, _: &mut Self::State, _: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source§

const TICKS: bool = true

Source§

fn on_mount( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source§

fn on_unmount( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source§

fn on_mouse( &mut self, mouse: MouseEvent, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source§

fn on_tick( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, dt: Duration, )

Source§

fn on_message( &mut self, message: Self::Message, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source§

fn on_resize( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source§

fn on_event( &mut self, event: &mut UserEvent<'_>, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source§

fn accept_focus(&self) -> bool

Source§

impl Debug for Input

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Input

Source§

fn default() -> Input

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Input

§

impl RefUnwindSafe for Input

§

impl Send for Input

§

impl Sync for Input

§

impl Unpin for Input

§

impl UnwindSafe for Input

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> AnyComponent for T
where T: Component + 'static,

Source§

fn any_event( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, event: Event, ) -> Event

Source§

fn any_accept_focus(&self) -> bool

Source§

fn any_ticks(&self) -> bool

Source§

fn any_message( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, message: Box<dyn Any>, )

Source§

fn any_focus( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, )

Source§

fn any_blur( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, )

Source§

fn any_tick( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, dt: Duration, )

Source§

fn any_resize( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, )

Source§

fn any_component_event( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, event: &mut UserEvent<'_>, )

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> 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, 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.