Struct termimad::InputField

source ·
pub struct InputField {
    pub password_mode: bool,
    /* private fields */
}
Expand description

A simple input field, managing its cursor position and either handling the events you give it or being managed through direct manipulation functions (put_char, del_char_left, etc.).

To create a multiline input_field (otherwise called a textarea) you should set an area with a height of more than 1 and allow newline to be created on keyboard with new_line_on.

Fields§

§password_mode: bool

when true, the display will have stars instead of the normal chars

Implementations§

define a key which will be interpreted as a new line.

You may define several ones. If you set none, the input field will stay monoline unless you manage key events yourself to insert new lines.

Beware that keys like Ctrl-Enter and Shift-Enter are usually received by TUI applications as simple Enter.

Example:

use termimad::*;
let mut textarea = InputField::new(Area::new(5, 5, 20, 10));
textarea.new_line_on(InputField::ALT_ENTER);

Change the area x, y and width, but not the height.

Makes most sense for monoline inputs

return the current scrolling state on both axis

Tell the input to be or not focused

Write the given string in place of the selection, or insert the string if there’s no wide selection.

This is the usual behavior for pasting a string.

tell whether the content of the input is equal to the argument

change the content to the new one and put the cursor at the end if the content is different from the previous one.

put a char at cursor position (and increment this position).

Insert the string on cursor point, as if it was typed

apply an event being a key

This function handles a few events like deleting a char, or going to the start (home key) or end (end key) of the input. If you want to totally handle events, you may call function like put_char and del_char_left directly.

apply an event being a key without modifier.

You don’t usually call this function but the more general apply_event. This one is useful when you manage events mostly yourselves.

Apply a simple left click event

Apply a mouse event

apply the event to change the state (content, cursor)

Return true when the event was used.

apply the event to change the state (content, cursor, focus)

Return true when the event was used.

Render the input field on screen.

All rendering must be explicitely called, no rendering is done on functions changing the state.

w is typically either stderr or stdout. This function doesn’t flush by itself (useful to avoid flickering)

render the input field on stdout

Trait Implementations§

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

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.