Struct cursive_core::views::TextView
source · pub struct TextView { /* private fields */ }
Expand description
A simple view showing a fixed text.
Examples
let mut siv = Cursive::new();
siv.add_layer(TextView::new("Hello world!"));
Implementations§
source§impl TextView
impl TextView
sourcepub fn new<S>(content: S) -> Selfwhere
S: Into<StyledString>,
pub fn new<S>(content: S) -> Selfwhere
S: Into<StyledString>,
Creates a new TextView with the given content.
sourcepub fn new_with_content(content: TextContent) -> Self
pub fn new_with_content(content: TextContent) -> Self
Creates a new TextView using the given TextContent
.
If you kept a clone of the given content, you’ll be able to update it remotely.
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"));
sourcepub fn set_effect(&mut self, effect: Effect)
👎Deprecated since 0.16.0: Use set_style()
instead.
pub fn set_effect(&mut self, effect: Effect)
set_style()
instead.Sets the effect for the entire content.
sourcepub fn effect(self, effect: Effect) -> Self
👎Deprecated since 0.16.0: Use style()
instead.
pub fn effect(self, effect: Effect) -> Self
style()
instead.Sets the effect for the entire content.
Chainable variant.
sourcepub fn style<S: Into<Style>>(self, style: S) -> Self
pub fn style<S: Into<Style>>(self, style: S) -> Self
Sets the style for the entire content.
Chainable variant.
sourcepub fn no_wrap(self) -> Self
pub fn no_wrap(self) -> Self
Disables content wrap for this view.
This may be useful if you want horizontal scrolling.
sourcepub fn set_content_wrap(&mut self, wrap: bool)
pub fn set_content_wrap(&mut self, wrap: bool)
Controls content wrap for this view.
If true
(the default), text will wrap long lines when needed.
sourcepub fn content<S>(self, content: S) -> Selfwhere
S: Into<StyledString>,
pub fn content<S>(self, content: S) -> Selfwhere
S: Into<StyledString>,
Replace the text in this view.
Chainable variant.
sourcepub fn set_content<S>(&mut self, content: S)where
S: Into<StyledString>,
pub fn set_content<S>(&mut self, content: S)where
S: Into<StyledString>,
Replace the text in this view.
sourcepub fn append<S>(&mut self, content: S)where
S: Into<StyledString>,
pub fn append<S>(&mut 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 the current text in this view.
Returns a shared reference to the content, allowing content mutation.