use tui_scrollview::ScrollViewState;
use super::ScrollService;
#[derive(Debug)]
pub struct ScrollState
{
pub(crate) scrollview: ScrollViewState,
pub(crate) text: Option<String>,
}
impl std::default::Default for ScrollState
{
fn default() -> Self
{
Self::new()
}
}
impl ScrollState
{
pub fn new() -> Self
{
Self {
scrollview: ScrollViewState::new(),
text: None,
}
}
pub fn update_from(
&mut self,
service: &mut ScrollService,
)
{
self.text = service
.text
.clone();
}
pub fn with_text<S>(
mut self,
text: S,
) -> Self
where
S: AsRef<str>,
{
self.text = Some(
text.as_ref()
.to_string(),
);
self
}
}