cool_rust_input

Trait CustomInput

Source
pub trait CustomInput {
    // Provided methods
    fn handle_key_press(
        &mut self,
        key: &Event,
        current_text: String,
    ) -> KeyPressResult { ... }
    fn before_draw_text(
        &mut self,
        terminal_size: (u16, u16),
        current_text: String,
    ) { ... }
    fn after_draw_text(
        &mut self,
        terminal_size: (u16, u16),
        current_text: String,
    ) { ... }
    fn get_offset(
        &mut self,
        terminal_size: (u16, u16),
        current_text: String,
    ) -> (u16, u16) { ... }
    fn get_size(
        &mut self,
        terminal_size: (u16, u16),
        current_text: String,
    ) -> (u16, u16) { ... }
}
Expand description

Trait that allows custom implementations / behaviour of an input

Provided Methods§

Source

fn handle_key_press( &mut self, key: &Event, current_text: String, ) -> KeyPressResult

Called before handling of every key press.

Source

fn before_draw_text(&mut self, terminal_size: (u16, u16), current_text: String)

Called before the user’s text input is drawn. Here you can ex. change color of the inputted text

Source

fn after_draw_text(&mut self, terminal_size: (u16, u16), current_text: String)

Called after the user’s text is drawn. Here you can ex. draw other text like information or a title of the document.

Source

fn get_offset( &mut self, terminal_size: (u16, u16), current_text: String, ) -> (u16, u16)

Called by the parent input to get the input area’s offset, I.e. where the user will start typing.

Source

fn get_size( &mut self, terminal_size: (u16, u16), current_text: String, ) -> (u16, u16)

Called by the parent input to get the input area’s size

Implementors§