mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-21 10:30:48 +08:00
lib: Fix text view cursor update
This commit is contained in:
@@ -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),
|
||||
|
||||
+13
-2
@@ -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::<TextViewProps>())
|
||||
.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
|
||||
|
||||
Reference in New Issue
Block a user