Struct cursive_core::views::TextArea
source · pub struct TextArea { /* private fields */ }
Expand description
Multi-lines text editor.
A TextArea
will attempt to grow vertically and horizontally
dependent on the content. Wrap it in a ResizedView
to
constrain its size.
Examples
use cursive_core::traits::{Nameable, Resizable};
use cursive_core::views::TextArea;
let text_area = TextArea::new()
.content("Write description here...")
.with_name("text_area")
.fixed_width(30)
.min_height(5);
Implementations§
source§impl TextArea
impl TextArea
sourcepub fn get_content(&self) -> &str
pub fn get_content(&self) -> &str
Retrieves the content of the view.
sourcepub fn cursor(&self) -> usize
pub fn cursor(&self) -> usize
Returns the position of the cursor in the content string.
This is a byte index.
sourcepub fn set_cursor(&mut self, cursor: usize)
pub fn set_cursor(&mut self, cursor: usize)
Moves the cursor to the given position.
Panics
This method panics if cursor
is not the beginning of a character in
the content string.
sourcepub fn set_content<S: Into<String>>(&mut self, content: S)
pub fn set_content<S: Into<String>>(&mut self, content: S)
Sets the content of the view.
sourcepub fn content<S: Into<String>>(self, content: S) -> Self
pub fn content<S: Into<String>>(self, content: S) -> Self
Sets the content of the view.
Chainable variant.
sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true
if this view is enabled.
Trait Implementations§
source§impl View for TextArea
impl View for TextArea
source§fn required_size(&mut self, constraint: Vec2) -> Vec2
fn required_size(&mut self, constraint: Vec2) -> Vec2
Returns the minimum size the view requires with the given restrictions. Read more
source§fn draw(&self, printer: &Printer<'_, '_>)
fn draw(&self, printer: &Printer<'_, '_>)
Draws the view with the given printer (includes bounds) and focus. Read more
source§fn on_event(&mut self, event: Event) -> EventResult
fn on_event(&mut self, event: Event) -> EventResult
Called when an event is received (key press, mouse event, …). Read more
source§fn take_focus(&mut self, _: Direction) -> Result<EventResult, CannotFocus>
fn take_focus(&mut self, _: Direction) -> Result<EventResult, CannotFocus>
Attempt to give this view the focus. Read more
source§fn layout(&mut self, size: Vec2)
fn layout(&mut self, size: Vec2)
Called once the size for this view has been decided. Read more
source§fn important_area(&self, _: Vec2) -> Rect
fn important_area(&self, _: Vec2) -> Rect
What part of the view is important and should be visible? Read more
source§fn needs_relayout(&self) -> bool
fn needs_relayout(&self) -> bool
source§fn call_on_any<'a>(&mut self, _: &Selector<'_>, _: AnyCb<'a>)
fn call_on_any<'a>(&mut self, _: &Selector<'_>, _: AnyCb<'a>)
Runs a closure on the view identified by the given selector. Read more
source§fn focus_view(&mut self, _: &Selector<'_>) -> Result<EventResult, ViewNotFound>
fn focus_view(&mut self, _: &Selector<'_>) -> Result<EventResult, ViewNotFound>
Moves the focus to the view identified by the given selector. Read more