Struct cursive::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
sourceimpl TextContent
impl TextContent
sourcepub fn new<S>(content: S) -> TextContentwhere
S: Into<SpannedString<Style>>,
pub fn new<S>(content: S) -> TextContentwhere
S: Into<SpannedString<Style>>,
Creates a new text content around the given value.
Parses the given value.
sourceimpl TextContent
impl TextContent
sourcepub fn set_content<S>(&self, content: S)where
S: Into<SpannedString<Style>>,
pub fn set_content<S>(&self, content: S)where
S: Into<SpannedString<Style>>,
Replaces the content with the given value.
sourcepub fn append<S>(&self, content: S)where
S: Into<SpannedString<Style>>,
pub fn append<S>(&self, content: S)where
S: Into<SpannedString<Style>>,
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 SpannedString<Style>) -> O,
pub fn with_content<F, O>(&self, f: F) -> Owhere
F: FnOnce(&mut SpannedString<Style>) -> O,
Apply the given closure to the inner content, and bust the cache afterward.
Trait Implementations
sourceimpl Clone for TextContent
impl Clone for TextContent
sourcefn clone(&self) -> TextContent
fn clone(&self) -> TextContent
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for TextContent
impl Send for TextContent
impl Sync for TextContent
impl Unpin for TextContent
impl UnwindSafe for TextContent
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more