pub struct Input { /* private fields */ }Implementations§
Source§impl Input
impl Input
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"
pub fn new() -> Self
Sourcepub fn template() -> SourceKind
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
impl Component for Input
type Message = ()
type State = InputState
fn on_key( &mut self, key: KeyEvent, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )
fn on_blur( &mut self, _: &mut Self::State, _: Children<'_, '_>, context: Context<'_, '_, Self::State>, )
fn on_focus( &mut self, _: &mut Self::State, _: Children<'_, '_>, context: Context<'_, '_, Self::State>, )
const TICKS: bool = true
fn on_mount( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )
fn on_unmount( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )
fn on_mouse( &mut self, mouse: MouseEvent, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )
fn on_tick( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, dt: Duration, )
fn on_message( &mut self, message: Self::Message, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )
fn on_resize( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )
fn on_event( &mut self, event: &mut UserEvent<'_>, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )
fn accept_focus(&self) -> bool
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> AnyComponent for Twhere
T: Component + 'static,
impl<T> AnyComponent for Twhere
T: Component + 'static,
fn any_event( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, event: Event, ) -> Event
fn any_accept_focus(&self) -> bool
fn any_ticks(&self) -> bool
fn any_message( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, message: Box<dyn Any>, )
fn any_focus( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, )
fn any_blur( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, )
fn any_tick( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, dt: Duration, )
fn any_resize( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, )
fn any_component_event( &mut self, children: Children<'_, '_>, ctx: AnyComponentContext<'_, '_>, event: &mut UserEvent<'_>, )
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
Mutably borrows from an owned value. Read more