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 cursup<S>(content: S) -> TextView
pub fn cursup<S>(content: S) -> TextView
Convenient function to create a TextView by parsing the given content as cursup.
Shortcut for TextView::new(cursup::parse(content)).
§Examples
let view = TextView::cursup("/red+bold{warning}");Sourcepub fn new_with_content(content: TextContent) -> TextView
pub fn new_with_content(content: TextContent) -> TextView
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)
Use set_style() instead.
Sets the effect for the entire content.
Sourcepub fn effect(self, effect: Effect) -> TextView
👎Deprecated since 0.16.0: Use style() instead.
pub fn effect(self, effect: Effect) -> TextView
Use style() instead.
Sets the effect for the entire content.
Chainable variant.
Sourcepub fn style<S>(self, style: S) -> TextView
pub fn style<S>(self, style: S) -> TextView
Sets the style for the entire content.
Chainable variant.
Sourcepub fn no_wrap(self) -> TextView
pub fn no_wrap(self) -> TextView
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) -> TextView
pub fn content<S>(self, content: S) -> TextView
Replace the text in this view.
Chainable variant.
Sourcepub fn set_content<S>(&mut self, content: S)
pub fn set_content<S>(&mut self, content: S)
Replace the text in this view.
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.
Trait Implementations§
Source§impl View for TextView
impl View for TextView
Source§fn draw(&self, printer: &Printer<'_, '_>)
fn draw(&self, printer: &Printer<'_, '_>)
Source§fn needs_relayout(&self) -> bool
fn needs_relayout(&self) -> bool
Source§fn required_size(&mut self, size: XY<usize>) -> XY<usize>
fn required_size(&mut self, size: XY<usize>) -> XY<usize>
Source§fn layout(&mut self, size: XY<usize>)
fn layout(&mut self, size: XY<usize>)
Source§fn on_event(&mut self, _: Event) -> EventResult
fn on_event(&mut self, _: Event) -> EventResult
Source§fn call_on_any(
&mut self,
_: &Selector<'_>,
_: &mut dyn FnMut(&mut (dyn View + 'static)),
)
fn call_on_any( &mut self, _: &Selector<'_>, _: &mut dyn FnMut(&mut (dyn View + 'static)), )
Source§fn focus_view(&mut self, _: &Selector<'_>) -> Result<EventResult, ViewNotFound>
fn focus_view(&mut self, _: &Selector<'_>) -> Result<EventResult, ViewNotFound>
Source§fn take_focus(&mut self, source: Direction) -> Result<EventResult, CannotFocus>
fn take_focus(&mut self, source: Direction) -> Result<EventResult, CannotFocus>
Auto Trait Implementations§
impl !RefUnwindSafe for TextView
impl !UnwindSafe for TextView
impl Freeze for TextView
impl Send for TextView
impl Sync for TextView
impl Unpin for TextView
impl UnsafeUnpin for TextView
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Finder for Twhere
T: View,
impl<T> Finder for Twhere
T: View,
Source§fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
sel. Read moreSource§fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
sel. Read moreSource§fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
call_on with a view::Selector::Name.Source§impl<T> IntoBoxedView for Twhere
T: View,
impl<T> IntoBoxedView for Twhere
T: View,
Source§fn into_boxed_view(self) -> Box<dyn View>
fn into_boxed_view(self) -> Box<dyn View>
Box<View>.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Resizable for Twhere
T: View,
impl<T> Resizable for Twhere
T: View,
Source§fn resized(
self,
width: SizeConstraint,
height: SizeConstraint,
) -> ResizedView<Self>
fn resized( self, width: SizeConstraint, height: SizeConstraint, ) -> ResizedView<Self>
self in a ResizedView with the given size constraints.Source§fn fixed_size<S>(self, size: S) -> ResizedView<Self>
fn fixed_size<S>(self, size: S) -> ResizedView<Self>
self into a fixed-size ResizedView.Source§fn fixed_width(self, width: usize) -> ResizedView<Self>
fn fixed_width(self, width: usize) -> ResizedView<Self>
self into a fixed-width ResizedView.Source§fn fixed_height(self, height: usize) -> ResizedView<Self>
fn fixed_height(self, height: usize) -> ResizedView<Self>
self into a fixed-width ResizedView.Source§fn full_screen(self) -> ResizedView<Self>
fn full_screen(self) -> ResizedView<Self>
self into a full-screen ResizedView.Source§fn full_width(self) -> ResizedView<Self>
fn full_width(self) -> ResizedView<Self>
self into a full-width ResizedView.Source§fn full_height(self) -> ResizedView<Self>
fn full_height(self) -> ResizedView<Self>
self into a full-height ResizedView.Source§fn max_size<S>(self, size: S) -> ResizedView<Self>
fn max_size<S>(self, size: S) -> ResizedView<Self>
self into a limited-size ResizedView.Source§fn max_width(self, max_width: usize) -> ResizedView<Self>
fn max_width(self, max_width: usize) -> ResizedView<Self>
self into a limited-width ResizedView.Source§fn max_height(self, max_height: usize) -> ResizedView<Self>
fn max_height(self, max_height: usize) -> ResizedView<Self>
self into a limited-height ResizedView.Source§fn min_size<S>(self, size: S) -> ResizedView<Self>
fn min_size<S>(self, size: S) -> ResizedView<Self>
self into a ResizedView at least sized size.Source§fn min_width(self, min_width: usize) -> ResizedView<Self>
fn min_width(self, min_width: usize) -> ResizedView<Self>
self in a ResizedView at least min_width wide.Source§fn min_height(self, min_height: usize) -> ResizedView<Self>
fn min_height(self, min_height: usize) -> ResizedView<Self>
self in a ResizedView at least min_height tall.Source§impl<T> Scrollable for Twhere
T: View,
impl<T> Scrollable for Twhere
T: View,
Source§fn scrollable(self) -> ScrollView<Self>
fn scrollable(self) -> ScrollView<Self>
self in a ScrollView.