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: StringPrompt is printed at the beginning of each line
placeholder: StringPlaceholder is the text displayed when the user hasn’t entered anything yet
show_line_numbers: boolShowLineNumbers, if enabled, causes line numbers to be printed after the prompt
end_of_buffer_character: charEndOfBufferCharacter is displayed at the end of the input
key_map: TextareaKeyMapKey bindings recognized by the widget.
focused_style: TextareaStyleStyle used when the textarea is focused.
blurred_style: TextareaStyleStyle used when the textarea is blurred.
cursor: ModelEmbedded cursor model for caret rendering and blinking.
char_limit: usizeCharLimit is the maximum number of characters this input element will accept
max_height: usizeMaxHeight is the maximum height of the text area in rows
max_width: usizeMaxWidth is the maximum width of the text area in columns
Implementations§
Source§impl Model
impl Model
Sourcepub fn set_value(&mut self, s: impl Into<String>)
pub fn set_value(&mut self, s: impl Into<String>)
Set the value of the text input - port of Go’s SetValue
Sourcepub fn insert_string(&mut self, s: impl Into<String>)
pub fn insert_string(&mut self, s: impl Into<String>)
Insert a string at the cursor position - port of Go’s InsertString
Sourcepub fn insert_rune(&mut self, r: char)
pub fn insert_rune(&mut self, r: char)
Insert a rune at the cursor position - port of Go’s InsertRune
Sourcepub fn length(&self) -> usize
pub fn length(&self) -> usize
Length returns the number of characters currently in the text input - port of Go’s Length()
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
LineCount returns the number of lines currently in the text input - port of Go’s LineCount()
Sourcepub fn focused(&self) -> bool
pub fn focused(&self) -> bool
Focused returns the focus state on the model - port of Go’s Focused()
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset sets the input to its default state with no input - port of Go’s Reset()
Sourcepub fn height(&self) -> usize
pub fn height(&self) -> usize
Height returns the current height of the textarea - port of Go’s Height()
Sourcepub fn set_width(&mut self, w: usize)
pub fn set_width(&mut self, w: usize)
SetWidth sets the width of the textarea - port of Go’s SetWidth()
Sourcepub fn set_height(&mut self, h: usize)
pub fn set_height(&mut self, h: usize)
SetHeight sets the height of the textarea - port of Go’s SetHeight()
Sourcepub fn set_prompt_func(
&mut self,
prompt_width: usize,
func: fn(usize) -> String,
)
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
Sourcepub fn set_cursor(&mut self, col: usize)
pub fn set_cursor(&mut self, col: usize)
SetCursor moves the cursor to the given position - port of Go’s SetCursor()
Sourcepub fn cursor_start(&mut self)
pub fn cursor_start(&mut self)
CursorStart moves the cursor to the start of the input field - port of Go’s CursorStart()
Sourcepub fn cursor_end(&mut self)
pub fn cursor_end(&mut self)
CursorEnd moves the cursor to the end of the input field - port of Go’s CursorEnd()
Sourcepub fn cursor_down(&mut self)
pub fn cursor_down(&mut self)
CursorDown moves the cursor down by one line - port of Go’s CursorDown()
Sourcepub fn move_to_begin(&mut self)
pub fn move_to_begin(&mut self)
Move to the beginning of input - port of Go’s moveToBegin()
Sourcepub fn move_to_end(&mut self)
pub fn move_to_end(&mut self)
Move to the end of input - port of Go’s moveToEnd()
Sourcepub fn line_info(&mut self) -> LineInfo
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
Sourcepub fn delete_before_cursor(&mut self)
pub fn delete_before_cursor(&mut self)
Delete before cursor - port of Go’s deleteBeforeCursor()
Sourcepub fn delete_after_cursor(&mut self)
pub fn delete_after_cursor(&mut self)
Delete after cursor - port of Go’s deleteAfterCursor()
Sourcepub fn delete_character_backward(&mut self)
pub fn delete_character_backward(&mut self)
Delete character backward - port of Go’s deleteCharacterBackward()
Sourcepub fn delete_character_forward(&mut self)
pub fn delete_character_forward(&mut self)
Delete character forward - port of Go’s deleteCharacterForward()
Sourcepub fn delete_word_backward(&mut self)
pub fn delete_word_backward(&mut self)
Delete word backward - port of Go’s deleteWordLeft()
Sourcepub fn delete_word_forward(&mut self)
pub fn delete_word_forward(&mut self)
Delete word forward - port of Go’s deleteWordRight()
Sourcepub fn insert_newline(&mut self)
pub fn insert_newline(&mut self)
Insert newline - port of Go’s InsertNewline()
Sourcepub fn character_left(&mut self, inside_line: bool)
pub fn character_left(&mut self, inside_line: bool)
Move cursor one character left - port of Go’s characterLeft()
Sourcepub fn character_right(&mut self)
pub fn character_right(&mut self)
Move cursor one character right - port of Go’s characterRight()
Sourcepub fn word_right(&mut self)
pub fn word_right(&mut self)
Move cursor one word right - port of Go’s wordRight()
Sourcepub fn uppercase_right(&mut self)
pub fn uppercase_right(&mut self)
Transform word to uppercase - port of Go’s uppercaseRight()
Sourcepub fn lowercase_right(&mut self)
pub fn lowercase_right(&mut self)
Transform word to lowercase - port of Go’s lowercaseRight()
Sourcepub fn capitalize_right(&mut self)
pub fn capitalize_right(&mut self)
Transform word to title case - port of Go’s capitalizeRight()
Sourcepub fn transpose_left(&mut self)
pub fn transpose_left(&mut self)
Transpose characters - port of Go’s transposeLeft()
Sourcepub fn scroll_down(&mut self, lines: usize)
pub fn scroll_down(&mut self, lines: usize)
Scroll viewport down by n lines - for testing viewport functionality
Sourcepub fn scroll_up(&mut self, lines: usize)
pub fn scroll_up(&mut self, lines: usize)
Scroll viewport up by n lines - for testing viewport functionality
Sourcepub fn cursor_line_number(&mut self) -> usize
pub fn cursor_line_number(&mut self) -> usize
Get cursor line number for display - port of Go’s cursorLineNumber()
Sourcepub fn update(&mut self, msg: Option<Msg>) -> Option<Cmd>
pub fn update(&mut self, msg: Option<Msg>) -> Option<Cmd>
Update handles incoming messages and updates the textarea state - port of Go’s Update()
Sourcepub fn copy_to_clipboard(&self, text: &str) -> Result<(), String>
pub fn copy_to_clipboard(&self, text: &str) -> Result<(), String>
Copy text to system clipboard
Sourcepub fn copy_selection(&self) -> Result<(), String>
pub fn copy_selection(&self) -> Result<(), String>
Copy current selection to clipboard (if selection is implemented)
Sourcepub fn cut_selection(&mut self) -> Result<(), String>
pub fn cut_selection(&mut self) -> Result<(), String>
Cut current selection to clipboard (if selection is implemented)
Trait Implementations§
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 Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
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) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more