Struct cursive::views::TextView
[−]
[src]
pub struct TextView { /* fields omitted */ }
A simple view showing a fixed text.
Examples
let mut siv = Cursive::new(); 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!(content.get_content().source().contains("new"));
pub fn empty() -> Self
[src]
Creates a new empty TextView
.
pub fn set_scrollable(&mut self, scrollable: bool)
[src]
Enable or disable the view's scrolling capabilities.
When disabled, the view will never attempt to scroll (and will always ask for the full height).
pub fn scrollable(self, scrollable: bool) -> Self
[src]
Enable or disable the view's scrolling capabilities.
When disabled, the view will never attempt to scroll (and will always ask for the full height).
Chainable variant.
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 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.
[src]
Returns a shared reference to the content, allowing content mutation.
pub fn set_scroll_strategy(&mut self, strategy: ScrollStrategy)
[src]
Defines the way scrolling is adjusted on content or size change.
The scroll strategy defines how the scrolling position is adjusted when the size of the view or the content change.
It is reset to ScrollStrategy::KeepRow
whenever the user scrolls
manually.
pub fn scroll_strategy(self, strategy: ScrollStrategy) -> Self
[src]
Defines the way scrolling is adjusted on content or size change.
Chainable variant.
pub fn scroll_up(&mut self, n: usize)
[src]
Scroll up by n
lines.
pub fn scroll_down(&mut self, n: usize)
[src]
Scroll down by n
lines.
pub fn scroll_bottom(&mut self)
[src]
Scroll to the bottom of the content.
pub fn scroll_top(&mut self)
[src]
Scroll to the top of the view.
Trait Implementations
impl View for TextView
[src]
fn draw(&self, printer: &Printer)
[src]
Draws the view with the given printer (includes bounds) and focus.
fn on_event(&mut self, event: Event) -> EventResult
[src]
Called when a key was pressed. Read more
fn needs_relayout(&self) -> bool
[src]
Returns true
if the view content changed since last layout phase. Read more
fn required_size(&mut self, size: Vec2) -> Vec2
[src]
Returns the minimum size the view requires with the given restrictions. Read more
fn take_focus(&mut self, _: Direction) -> bool
[src]
This view is offered focus. Will it take it? Read more
fn layout(&mut self, size: Vec2)
[src]
Called once the size for this view has been decided, Read more
fn call_on_any<'a>(&mut self, _: &Selector, _: Box<FnMut(&mut Any) + '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