diff --git a/src/ui/widget.rs b/src/ui/widget.rs index 19a11940..d52334e0 100644 --- a/src/ui/widget.rs +++ b/src/ui/widget.rs @@ -61,6 +61,7 @@ impl From<&'static dyn Any> for ViewProps { /// A `ViewState` is the representation of a `View`s internal state. e.g. current /// table selection or contents of a text field. +#[derive(Debug)] pub enum ViewState { USize(usize), String(String), diff --git a/src/ui/widget/input.rs b/src/ui/widget/input.rs index 08615617..dc3ceb0d 100644 --- a/src/ui/widget/input.rs +++ b/src/ui/widget/input.rs @@ -283,7 +283,7 @@ where } /// The state of a `TextArea`. -#[derive(Clone, Default)] +#[derive(Clone, Default, Debug)] pub struct TextAreaState { /// Current vertical scroll position. pub scroll: usize, @@ -529,7 +529,7 @@ impl<'a, S, M> View for TextArea<'a, S, M> { } /// State of a `TextView`. -#[derive(Clone, Default)] +#[derive(Clone, Default, Debug)] pub struct TextViewState { /// Current vertical scroll position. pub scroll: usize, @@ -713,6 +713,17 @@ where None } + fn update(&mut self, props: Option<&ViewProps>, _state: &Self::State) { + let default = TextViewProps::default(); + let props = props + .and_then(|props| props.inner_ref::()) + .unwrap_or(&default); + + if props.cursor != self.state.cursor { + self.state.cursor = props.cursor; + } + } + fn render(&mut self, props: Option<&ViewProps>, render: RenderProps, frame: &mut Frame) { let default = TextViewProps::default(); let props = props