Struct cursive::views::TextView [−][src]
pub struct TextView { /* fields omitted */ }
A simple view showing a fixed text.
Examples
let mut siv = Cursive::dummy(); siv.add_layer(TextView::new("Hello world!"));
Methods
impl TextView
[src]
impl TextView
pub fn new<S>(content: S) -> Self where
S: Into<StyledString>,
[src]
pub fn new<S>(content: S) -> Self where
S: Into<StyledString>,
Creates a new TextView with the given content.
pub fn new_with_content(content: TextContent) -> Self
[src]
pub fn new_with_content(content: TextContent) -> Self
Creates a new TextView using the given Arc<Mutex<String>>
.
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!(content.get_content().source().contains("new"));
pub fn empty() -> Self
[src]
pub fn empty() -> Self
Creates a new empty TextView
.
pub fn set_effect(&mut self, effect: Effect)
[src]
pub fn set_effect(&mut self, effect: Effect)
Sets the effect for the entire content.
pub fn effect(self, effect: Effect) -> Self
[src]
pub fn effect(self, effect: Effect) -> Self
Sets the effect for the entire content.
Chainable variant.
pub fn no_wrap(self) -> Self
[src]
pub fn no_wrap(self) -> Self
Disables content wrap for this view.
This may be useful if you want horizontal scrolling.
pub fn set_content_wrap(&mut self, wrap: bool)
[src]
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.
pub fn h_align(self, h: HAlign) -> Self
[src]
pub fn h_align(self, h: HAlign) -> Self
Sets the horizontal alignment for this view.
pub fn v_align(self, v: VAlign) -> Self
[src]
pub fn v_align(self, v: VAlign) -> Self
Sets the vertical alignment for this view.
pub fn align(self, a: Align) -> Self
[src]
pub fn align(self, a: Align) -> Self
Sets the alignment for this view.
pub fn center(self) -> Self
[src]
pub fn center(self) -> Self
Center the text horizontally and vertically inside the view.
pub fn content<S>(self, content: S) -> Self where
S: Into<StyledString>,
[src]
pub fn content<S>(self, content: S) -> Self where
S: Into<StyledString>,
Replace the text in this view.
Chainable variant.
pub fn set_content<S>(&mut self, content: S) where
S: Into<StyledString>,
[src]
pub fn set_content<S>(&mut self, content: S) where
S: Into<StyledString>,
Replace the text in this view.
pub fn append<S>(&mut self, content: S) where
S: Into<StyledString>,
[src]
pub fn append<S>(&mut self, content: S) where
S: Into<StyledString>,
Append content
to the end of a TextView
.
pub fn get_content(&self) -> TextContentRef
[src]
pub fn get_content(&self) -> TextContentRef
Returns the current text in this view.
Returns a shared reference to the content, allowing content mutation.
Trait Implementations
impl View for TextView
[src]
impl View for TextView
fn draw(&self, printer: &Printer)
[src]
fn draw(&self, printer: &Printer)
Draws the view with the given printer (includes bounds) and focus. Read more
fn needs_relayout(&self) -> bool
[src]
fn needs_relayout(&self) -> bool
Returns true
if the view content changed since last layout phase. Read more
fn required_size(&mut self, size: Vec2) -> Vec2
[src]
fn required_size(&mut self, size: Vec2) -> Vec2
Returns the minimum size the view requires with the given restrictions. Read more
fn layout(&mut self, size: Vec2)
[src]
fn layout(&mut self, size: Vec2)
Called once the size for this view has been decided. Read more
fn on_event(&mut self, Event) -> EventResult
[src]
fn on_event(&mut self, Event) -> EventResult
Called when an event is received (key press, mouse event, ...). Read more
fn call_on_any<'a>(&mut self, _: &Selector, _: AnyCb<'a>)
[src]
fn call_on_any<'a>(&mut self, _: &Selector, _: AnyCb<'a>)
Runs a closure on the view identified by the given selector. Read more
fn focus_view(&mut self, &Selector) -> Result<(), ()>
[src]
fn focus_view(&mut self, &Selector) -> Result<(), ()>
Moves the focus to the view identified by the given selector. Read more
fn take_focus(&mut self, source: Direction) -> bool
[src]
fn take_focus(&mut self, source: Direction) -> bool
This view is offered focus. Will it take it? Read more
fn important_area(&self, view_size: Vec2) -> Rect
[src]
fn important_area(&self, view_size: Vec2) -> Rect
What part of the view is important and should be visible? Read more