Struct cursive_core::views::TextContent
source · pub struct TextContent { /* private fields */ }
Expand description
Provides access to the content of a TextView
.
Cloning this object will still point to the same content.
Examples
let mut content = TextContent::new("content");
let view = TextView::new_with_content(content.clone());
// Later, possibly in a different thread
content.set_content("new content");
assert!(view.get_content().source().contains("new"));
Implementations§
source§impl TextContent
impl TextContent
sourcepub fn new<S>(content: S) -> Selfwhere
S: Into<StyledString>,
pub fn new<S>(content: S) -> Selfwhere
S: Into<StyledString>,
Creates a new text content around the given value.
Parses the given value.
source§impl TextContent
impl TextContent
sourcepub fn set_content<S>(&self, content: S)where
S: Into<StyledString>,
pub fn set_content<S>(&self, content: S)where
S: Into<StyledString>,
Replaces the content with the given value.
sourcepub fn append<S>(&self, content: S)where
S: Into<StyledString>,
pub fn append<S>(&self, content: S)where
S: Into<StyledString>,
Append content
to the end of a TextView
.
sourcepub fn get_content(&self) -> TextContentRef
pub fn get_content(&self) -> TextContentRef
Returns a reference to the content.
This locks the data while the returned value is alive, so don’t keep it too long.
sourcepub fn with_content<F, O>(&self, f: F) -> Owhere
F: FnOnce(&mut StyledString) -> O,
pub fn with_content<F, O>(&self, f: F) -> Owhere
F: FnOnce(&mut StyledString) -> O,
Apply the given closure to the inner content, and bust the cache afterward.
Trait Implementations§
source§impl Clone for TextContent
impl Clone for TextContent
source§fn clone(&self) -> TextContent
fn clone(&self) -> TextContent
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more