pub struct TextArea {
pub err: Option<String>,
pub prompt: String,
pub placeholder: String,
pub show_line_numbers: bool,
pub end_of_buffer_character: char,
pub key_map: KeyMap,
pub focused_style: Styles,
pub blurred_style: Styles,
pub cursor: Cursor,
pub char_limit: usize,
pub max_height: usize,
pub max_width: usize,
/* private fields */
}Expand description
Multi-line text area model.
Fields§
§err: Option<String>Current error.
prompt: StringPrompt string (displayed at start of each line).
placeholder: StringPlaceholder text.
show_line_numbers: boolWhether to show line numbers.
end_of_buffer_character: charEnd of buffer character.
key_map: KeyMapKey bindings.
focused_style: StylesStyle for focused state.
blurred_style: StylesStyle for blurred state.
cursor: CursorCursor model.
char_limit: usizeCharacter limit (0 = no limit).
max_height: usizeMaximum height in rows.
max_width: usizeMaximum width in columns.
Implementations§
Source§impl TextArea
impl TextArea
Sourcepub fn insert_string(&mut self, s: &str)
pub fn insert_string(&mut self, s: &str)
Inserts a string at the cursor position.
Sourcepub fn insert_rune(&mut self, r: char)
pub fn insert_rune(&mut self, r: char)
Inserts a single character at the cursor position.
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Returns the number of lines.
Sourcepub fn cursor_col(&self) -> usize
pub fn cursor_col(&self) -> usize
Returns the current cursor column (0-indexed, in characters).
Sourcepub fn cursor_pos(&self) -> (usize, usize)
pub fn cursor_pos(&self) -> (usize, usize)
Returns the current cursor position (row, col) in character indices.
Sourcepub fn cursor_byte_offset(&self) -> usize
pub fn cursor_byte_offset(&self) -> usize
Returns the cursor position as a byte offset into the string returned by Self::value.
Sourcepub fn set_cursor_byte_offset(&mut self, offset: usize)
pub fn set_cursor_byte_offset(&mut self, offset: usize)
Sets the cursor position based on a byte offset into the string returned by Self::value.
If the offset points to the newline separator between lines, the cursor is placed at the end of the preceding line. Offsets beyond the end of the buffer clamp to the end.
Sourcepub fn cursor_down(&mut self)
pub fn cursor_down(&mut self)
Moves cursor down one line.
Sourcepub fn set_cursor_col(&mut self, col: usize)
pub fn set_cursor_col(&mut self, col: usize)
Sets cursor column position.
Sourcepub fn cursor_start(&mut self)
pub fn cursor_start(&mut self)
Moves cursor to start of line.
Sourcepub fn cursor_end(&mut self)
pub fn cursor_end(&mut self)
Moves cursor to end of line.
Sourcepub fn cursor_left(&mut self)
pub fn cursor_left(&mut self)
Moves cursor left one character.
Sourcepub fn cursor_right(&mut self)
pub fn cursor_right(&mut self)
Moves cursor right one character.
Sourcepub fn set_height(&mut self, h: usize)
pub fn set_height(&mut self, h: usize)
Sets the height of the textarea.