[][src]Struct cursive::views::TextView

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]

pub fn new<S>(content: S) -> Self where
    S: Into<StyledString>, 
[src]

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]

Replace the text in this view.

Chainable variant.

pub fn set_content<S>(&mut self, content: S) where
    S: Into<StyledString>, 
[src]

Replace the text in this view.

pub fn append<S>(&mut self, content: S) where
    S: Into<StyledString>, 
[src]

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 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> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T[src]