[−][src]Struct cursive::views::TextView
A simple view showing a fixed text.
Examples
let mut siv = Cursive::dummy(); siv.add_layer(TextView::new("Hello world!"));
Methods
impl TextView
[src]
pub fn new<S>(content: S) -> Self where
S: Into<StyledString>,
[src]
S: Into<StyledString>,
Creates a new TextView with the given content.
pub fn new_with_content(content: TextContent) -> Self
[src]
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!(view.get_content().source().contains("new"));
pub fn empty() -> Self
[src]
Creates a new empty TextView
.
pub fn set_effect(&mut self, effect: Effect)
[src]
Sets the effect for the entire content.
pub fn effect(self, effect: Effect) -> Self
[src]
Sets the effect for the entire content.
Chainable variant.
pub fn no_wrap(self) -> Self
[src]
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]
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]
Sets the horizontal alignment for this view.
pub fn v_align(self, v: VAlign) -> Self
[src]
Sets the vertical alignment for this view.
pub fn align(self, a: Align) -> Self
[src]
Sets the alignment for this view.
pub fn center(self) -> Self
[src]
Center the text horizontally and vertically inside the view.
pub fn content<S>(self, content: S) -> Self where
S: Into<StyledString>,
[src]
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]
S: Into<StyledString>,
Replace the text in this view.
pub fn append<S>(&mut self, content: S) where
S: Into<StyledString>,
[src]
S: Into<StyledString>,
Append content
to the end of a TextView
.
pub fn get_content(&self) -> TextContentRef
[src]
Returns the current text in this view.
pub fn get_shared_content(&mut self) -> TextContent
[src]
Returns a shared reference to the content, allowing content mutation.
Trait Implementations
impl View for TextView
[src]
fn draw(&self, printer: &Printer)
[src]
fn needs_relayout(&self) -> bool
[src]
fn required_size(&mut self, size: Vec2) -> Vec2
[src]
fn layout(&mut self, size: Vec2)
[src]
fn on_event(&mut self, _: Event) -> EventResult
[src]
Called when an event is received (key press, mouse event, ...). Read more
fn call_on_any<'a>(&mut self, _: &Selector, _: AnyCb<'a>)
[src]
Runs a closure on the view identified by the given selector. Read more
fn focus_view(&mut self, _: &Selector) -> Result<(), ()>
[src]
Moves the focus to the view identified by the given selector. Read more
fn take_focus(&mut self, source: Direction) -> bool
[src]
This view is offered focus. Will it take it? Read more
fn important_area(&self, view_size: Vec2) -> Rect
[src]
What part of the view is important and should be visible? Read more
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.