Model

Struct Model 

Source
pub struct Model {
    pub err: Option<String>,
    pub prompt: String,
    pub placeholder: String,
    pub show_line_numbers: bool,
    pub end_of_buffer_character: char,
    pub key_map: TextareaKeyMap,
    pub focused_style: TextareaStyle,
    pub blurred_style: TextareaStyle,
    pub cursor: Model,
    pub char_limit: usize,
    pub max_height: usize,
    pub max_width: usize,
    /* private fields */
}
Expand description

Model is the Bubble Tea model for this text area element. Direct port from Go’s Model struct with all fields preserved

Fields§

§err: Option<String>

Optional error string surfaced by the component.

§prompt: String

Prompt is printed at the beginning of each line

§placeholder: String

Placeholder is the text displayed when the user hasn’t entered anything yet

§show_line_numbers: bool

ShowLineNumbers, if enabled, causes line numbers to be printed after the prompt

§end_of_buffer_character: char

EndOfBufferCharacter is displayed at the end of the input

§key_map: TextareaKeyMap

Key bindings recognized by the widget.

§focused_style: TextareaStyle

Style used when the textarea is focused.

§blurred_style: TextareaStyle

Style used when the textarea is blurred.

§cursor: Model

Embedded cursor model for caret rendering and blinking.

§char_limit: usize

CharLimit is the maximum number of characters this input element will accept

§max_height: usize

MaxHeight is the maximum height of the text area in rows

§max_width: usize

MaxWidth is the maximum width of the text area in columns

Implementations§

Source§

impl Model

Source

pub fn new() -> Self

Create a new textarea model with default settings - port of Go’s New()

Source

pub fn set_value(&mut self, s: impl Into<String>)

Set the value of the text input - port of Go’s SetValue

Source

pub fn insert_string(&mut self, s: impl Into<String>)

Insert a string at the cursor position - port of Go’s InsertString

Source

pub fn insert_rune(&mut self, r: char)

Insert a rune at the cursor position - port of Go’s InsertRune

Source

pub fn value(&self) -> String

Get the current value as a string - port of Go’s Value()

Source

pub fn length(&self) -> usize

Length returns the number of characters currently in the text input - port of Go’s Length()

Source

pub fn line_count(&self) -> usize

LineCount returns the number of lines currently in the text input - port of Go’s LineCount()

Source

pub fn line(&self) -> usize

Line returns the line position - port of Go’s Line()

Source

pub fn focused(&self) -> bool

Focused returns the focus state on the model - port of Go’s Focused()

Source

pub fn reset(&mut self)

Reset sets the input to its default state with no input - port of Go’s Reset()

Source

pub fn width(&self) -> usize

Width returns the width of the textarea - port of Go’s Width()

Source

pub fn height(&self) -> usize

Height returns the current height of the textarea - port of Go’s Height()

Source

pub fn set_width(&mut self, w: usize)

SetWidth sets the width of the textarea - port of Go’s SetWidth()

Source

pub fn set_height(&mut self, h: usize)

SetHeight sets the height of the textarea - port of Go’s SetHeight()

Source

pub fn set_prompt_func( &mut self, prompt_width: usize, func: fn(usize) -> String, )

SetPromptFunc supersedes the Prompt field and sets a dynamic prompt instead Port of Go’s SetPromptFunc

Source

pub fn set_cursor(&mut self, col: usize)

SetCursor moves the cursor to the given position - port of Go’s SetCursor()

Source

pub fn cursor_start(&mut self)

CursorStart moves the cursor to the start of the input field - port of Go’s CursorStart()

Source

pub fn cursor_end(&mut self)

CursorEnd moves the cursor to the end of the input field - port of Go’s CursorEnd()

Source

pub fn cursor_down(&mut self)

CursorDown moves the cursor down by one line - port of Go’s CursorDown()

Source

pub fn cursor_up(&mut self)

CursorUp moves the cursor up by one line - port of Go’s CursorUp()

Source

pub fn move_to_begin(&mut self)

Move to the beginning of input - port of Go’s moveToBegin()

Source

pub fn move_to_end(&mut self)

Move to the end of input - port of Go’s moveToEnd()

Source

pub fn line_info(&mut self) -> LineInfo

LineInfo returns line information for the current cursor position Port of Go’s LineInfo() - enhanced with better wrapped line handling

Source

pub fn delete_before_cursor(&mut self)

Delete before cursor - port of Go’s deleteBeforeCursor()

Source

pub fn delete_after_cursor(&mut self)

Delete after cursor - port of Go’s deleteAfterCursor()

Source

pub fn delete_character_backward(&mut self)

Delete character backward - port of Go’s deleteCharacterBackward()

Source

pub fn delete_character_forward(&mut self)

Delete character forward - port of Go’s deleteCharacterForward()

Source

pub fn delete_word_backward(&mut self)

Delete word backward - port of Go’s deleteWordLeft()

Source

pub fn delete_word_forward(&mut self)

Delete word forward - port of Go’s deleteWordRight()

Source

pub fn insert_newline(&mut self)

Insert newline - port of Go’s InsertNewline()

Source

pub fn character_left(&mut self, inside_line: bool)

Move cursor one character left - port of Go’s characterLeft()

Source

pub fn character_right(&mut self)

Move cursor one character right - port of Go’s characterRight()

Source

pub fn word_left(&mut self)

Move cursor one word left - port of Go’s wordLeft()

Source

pub fn word_right(&mut self)

Move cursor one word right - port of Go’s wordRight()

Source

pub fn uppercase_right(&mut self)

Transform word to uppercase - port of Go’s uppercaseRight()

Source

pub fn lowercase_right(&mut self)

Transform word to lowercase - port of Go’s lowercaseRight()

Source

pub fn capitalize_right(&mut self)

Transform word to title case - port of Go’s capitalizeRight()

Source

pub fn transpose_left(&mut self)

Transpose characters - port of Go’s transposeLeft()

Source

pub fn view(&mut self) -> String

View renders the text area - port of Go’s View()

Source

pub fn scroll_down(&mut self, lines: usize)

Scroll viewport down by n lines - for testing viewport functionality

Source

pub fn scroll_up(&mut self, lines: usize)

Scroll viewport up by n lines - for testing viewport functionality

Source

pub fn cursor_line_number(&mut self) -> usize

Get cursor line number for display - port of Go’s cursorLineNumber()

Source

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

Update handles incoming messages and updates the textarea state - port of Go’s Update()

Source

pub fn copy_to_clipboard(&self, text: &str) -> Result<(), String>

Copy text to system clipboard

Source

pub fn copy_selection(&self) -> Result<(), String>

Copy current selection to clipboard (if selection is implemented)

Source

pub fn cut_selection(&mut self) -> Result<(), String>

Cut current selection to clipboard (if selection is implemented)

Trait Implementations§

Source§

impl Component for Model

Focus sets the focus state on the model - port of Go’s Focus()

Source§

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

Sets the component to focused state. Read more
Source§

fn blur(&mut self)

Sets the component to blurred (unfocused) state. Read more
Source§

fn focused(&self) -> bool

Returns the current focus state of the component. Read more
Source§

impl Debug for Model

Source§

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

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

impl Default for Model

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for Model

§

impl !RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl !UnwindSafe for Model

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
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> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
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, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.