Skip to main content

Text

Struct Text 

Source
pub struct Text { /* private fields */ }
Expand description

A multi-line text area field.

The Text field is used for gathering longer-form user input. It wraps the bubbles textarea component and integrates it with the huh form system.

§Example

use huh::Text;

let text = Text::new()
    .key("bio")
    .title("Biography")
    .description("Tell us about yourself")
    .placeholder("Enter your bio...")
    .lines(5);

Implementations§

Source§

impl Text

Source

pub fn new() -> Self

Creates a new text area field.

Source

pub fn key(self, key: impl Into<String>) -> Self

Sets the field key.

Source

pub fn value(self, value: impl Into<String>) -> Self

Sets the initial value.

Source

pub fn title(self, title: impl Into<String>) -> Self

Sets the title.

Source

pub fn description(self, description: impl Into<String>) -> Self

Sets the description.

Source

pub fn placeholder(self, placeholder: impl Into<String>) -> Self

Sets the placeholder text.

Source

pub fn lines(self, lines: usize) -> Self

Sets the number of visible lines.

Source

pub fn char_limit(self, limit: usize) -> Self

Sets the character limit (0 = no limit).

Source

pub fn show_line_numbers(self, show: bool) -> Self

Sets whether to show line numbers.

Source

pub fn validate(self, validate: fn(&str) -> Option<String>) -> Self

Sets the validation function.

Source

pub fn get_string_value(&self) -> &str

Gets the current value.

Source

pub fn id(&self) -> usize

Returns the field ID.

Trait Implementations§

Source§

impl Default for Text

Source§

fn default() -> Self

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

impl Field for Text

Source§

fn get_key(&self) -> &str

Returns the field’s key.
Source§

fn get_value(&self) -> Box<dyn Any>

Returns the field’s value.
Source§

fn error(&self) -> Option<&str>

Returns the current validation error, if any.
Source§

fn init(&mut self) -> Option<Cmd>

Initializes the field.
Source§

fn update(&mut self, msg: &Message) -> Option<Cmd>

Updates the field with a message.
Source§

fn view(&self) -> String

Renders the field.
Source§

fn focus(&mut self) -> Option<Cmd>

Focuses the field.
Source§

fn blur(&mut self) -> Option<Cmd>

Blurs the field.
Source§

fn key_binds(&self) -> Vec<Binding>

Returns the help keybindings.
Source§

fn with_theme(&mut self, theme: &Theme)

Sets the theme.
Source§

fn with_keymap(&mut self, keymap: &KeyMap)

Sets the keymap.
Source§

fn with_width(&mut self, width: usize)

Sets the width.
Source§

fn with_height(&mut self, height: usize)

Sets the height.
Source§

fn with_position(&mut self, position: FieldPosition)

Sets the field position.
Source§

fn skip(&self) -> bool

Returns whether this field should be skipped.
Source§

fn zoom(&self) -> bool

Returns whether this field should zoom (take full height).

Auto Trait Implementations§

§

impl Freeze for Text

§

impl !RefUnwindSafe for Text

§

impl Send for Text

§

impl Sync for Text

§

impl Unpin for Text

§

impl !UnwindSafe for Text

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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more