From 61319ed7dcf21d065d19357ec2ff43402d0ef295 Mon Sep 17 00:00:00 2001 From: ChangeCaps <42285338+ChangeCaps@users.noreply.github.com> Date: Sun, 15 Sep 2024 06:41:26 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20ChangeCa?= =?UTF-8?q?ps/ori@a617b5abefa309c8d10362d966e552b3138d8917=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ori/core/view/trait.View.html | 2 +- ori/core/views/struct.TextInput.html | 10 ++--- ori/prelude/struct.TextInput.html | 10 ++--- ori/prelude/trait.View.html | 2 +- ori_core/view/trait.View.html | 2 +- ori_core/views/struct.TextInput.html | 8 ++-- src/ori_core/views/text_input.rs.html | 54 ++++++++++++++++++++++++++- 7 files changed, 69 insertions(+), 19 deletions(-) diff --git a/ori/core/view/trait.View.html b/ori/core/view/trait.View.html index be0ede7f4..7a026f2a1 100644 --- a/ori/core/view/trait.View.html +++ b/ori/core/view/trait.View.html @@ -199,7 +199,7 @@ state: &mut <Result<V, E> as View<T>>::State, cx: &mut DrawCx<'_, '_>, data: &mut T, -)

Implementors§

source§

impl<T> View<T> for Checkbox

source§

impl<T> View<T> for ColorPicker<T>

§

type State = ColorPickerState

source§

impl<T> View<T> for Image

§

type State = ()

source§

impl<T> View<T> for Painter<T>

§

type State = ()

source§

impl<T> View<T> for Slider<T>

source§

impl<T> View<T> for Text

§

type State = TextState

source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

source§

impl<T, H, V> View<T> for Collapsing<T, H, V>
where +)

Implementors§

source§

impl<T> View<T> for Checkbox

source§

impl<T> View<T> for ColorPicker<T>

§

type State = ColorPickerState

source§

impl<T> View<T> for Image

§

type State = ()

source§

impl<T> View<T> for Painter<T>

§

type State = ()

source§

impl<T> View<T> for Slider<T>

source§

impl<T> View<T> for Text

§

type State = TextState

source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

source§

impl<T, H, V> View<T> for Collapsing<T, H, V>
where H: View<T>, V: View<T>,

§

type State = CollapsingState<T, H, V>

source§

impl<T, S, V> View<T> for WithState<T, S, V>
where V: View<(T, S)>,

§

type State = (Pod<V>, S, State<(T, S), V>)

source§

impl<T, U, V> View<T> for Focus<T, U, V>
where diff --git a/ori/core/views/struct.TextInput.html b/ori/core/views/struct.TextInput.html index f14e6c746..c46fc5a14 100644 --- a/ori/core/views/struct.TextInput.html +++ b/ori/core/views/struct.TextInput.html @@ -86,29 +86,29 @@ self, on_submit: impl FnMut(&mut EventCx<'_, '_>, &mut T, String) + 'static, ) -> TextInput<T>

Set the callback that is called when the input is submitted.

-

Trait Implementations§

source§

impl<T> Default for TextInput<T>

source§

fn default() -> TextInput<T>

Returns the “default value” for a type. Read more
source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

The state of the view, see top-level documentation for more information.
source§

fn build( +

Trait Implementations§

source§

impl<T> Default for TextInput<T>

source§

fn default() -> TextInput<T>

Returns the “default value” for a type. Read more
source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

The state of the view, see top-level documentation for more information.
source§

fn build( &mut self, cx: &mut BuildCx<'_, '_>, _data: &mut T, -) -> <TextInput<T> as View<T>>::State

Build the view state, see top-level documentation for more information.
source§

fn rebuild( +) -> <TextInput<T> as View<T>>::State

Build the view state, see top-level documentation for more information.
source§

fn rebuild( &mut self, state: &mut <TextInput<T> as View<T>>::State, cx: &mut RebuildCx<'_, '_>, _data: &mut T, old: &TextInput<T>, -)

Rebuild the view state, see top-level documentation for more information.
source§

fn event( +)

Rebuild the view state, see top-level documentation for more information.
source§

fn event( &mut self, state: &mut <TextInput<T> as View<T>>::State, cx: &mut EventCx<'_, '_>, data: &mut T, event: &Event, -)

Handle an event, see top-level documentation for more information.
source§

fn layout( +)

Handle an event, see top-level documentation for more information.
source§

fn layout( &mut self, state: &mut <TextInput<T> as View<T>>::State, cx: &mut LayoutCx<'_, '_>, _data: &mut T, space: Space, -) -> Size

Layout the view, see top-level documentation for more information.
source§

fn draw( +) -> Size

Layout the view, see top-level documentation for more information.
source§

fn draw( &mut self, state: &mut <TextInput<T> as View<T>>::State, cx: &mut DrawCx<'_, '_>, diff --git a/ori/prelude/struct.TextInput.html b/ori/prelude/struct.TextInput.html index 0d571fdf0..de5d021ce 100644 --- a/ori/prelude/struct.TextInput.html +++ b/ori/prelude/struct.TextInput.html @@ -86,29 +86,29 @@ self, on_submit: impl FnMut(&mut EventCx<'_, '_>, &mut T, String) + 'static, ) -> TextInput<T>

Set the callback that is called when the input is submitted.

-

Trait Implementations§

source§

impl<T> Default for TextInput<T>

source§

fn default() -> TextInput<T>

Returns the “default value” for a type. Read more
source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

The state of the view, see top-level documentation for more information.
source§

fn build( +

Trait Implementations§

source§

impl<T> Default for TextInput<T>

source§

fn default() -> TextInput<T>

Returns the “default value” for a type. Read more
source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

The state of the view, see top-level documentation for more information.
source§

fn build( &mut self, cx: &mut BuildCx<'_, '_>, _data: &mut T, -) -> <TextInput<T> as View<T>>::State

Build the view state, see top-level documentation for more information.
source§

fn rebuild( +) -> <TextInput<T> as View<T>>::State

Build the view state, see top-level documentation for more information.
source§

fn rebuild( &mut self, state: &mut <TextInput<T> as View<T>>::State, cx: &mut RebuildCx<'_, '_>, _data: &mut T, old: &TextInput<T>, -)

Rebuild the view state, see top-level documentation for more information.
source§

fn event( +)

Rebuild the view state, see top-level documentation for more information.
source§

fn event( &mut self, state: &mut <TextInput<T> as View<T>>::State, cx: &mut EventCx<'_, '_>, data: &mut T, event: &Event, -)

Handle an event, see top-level documentation for more information.
source§

fn layout( +)

Handle an event, see top-level documentation for more information.
source§

fn layout( &mut self, state: &mut <TextInput<T> as View<T>>::State, cx: &mut LayoutCx<'_, '_>, _data: &mut T, space: Space, -) -> Size

Layout the view, see top-level documentation for more information.
source§

fn draw( +) -> Size

Layout the view, see top-level documentation for more information.
source§

fn draw( &mut self, state: &mut <TextInput<T> as View<T>>::State, cx: &mut DrawCx<'_, '_>, diff --git a/ori/prelude/trait.View.html b/ori/prelude/trait.View.html index 266a7a3f2..bc8994164 100644 --- a/ori/prelude/trait.View.html +++ b/ori/prelude/trait.View.html @@ -199,7 +199,7 @@ state: &mut <Result<V, E> as View<T>>::State, cx: &mut DrawCx<'_, '_>, data: &mut T, -)

Implementors§

source§

impl<T> View<T> for Checkbox

source§

impl<T> View<T> for ColorPicker<T>

§

type State = ColorPickerState

source§

impl<T> View<T> for Image

§

type State = ()

source§

impl<T> View<T> for Painter<T>

§

type State = ()

source§

impl<T> View<T> for Slider<T>

source§

impl<T> View<T> for Text

§

type State = TextState

source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

source§

impl<T, H, V> View<T> for Collapsing<T, H, V>
where +)

Implementors§

source§

impl<T> View<T> for Checkbox

source§

impl<T> View<T> for ColorPicker<T>

§

type State = ColorPickerState

source§

impl<T> View<T> for Image

§

type State = ()

source§

impl<T> View<T> for Painter<T>

§

type State = ()

source§

impl<T> View<T> for Slider<T>

source§

impl<T> View<T> for Text

§

type State = TextState

source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

source§

impl<T, H, V> View<T> for Collapsing<T, H, V>
where H: View<T>, V: View<T>,

§

type State = CollapsingState<T, H, V>

source§

impl<T, S, V> View<T> for WithState<T, S, V>
where V: View<(T, S)>,

§

type State = (Pod<V>, S, State<(T, S), V>)

source§

impl<T, U, V> View<T> for Focus<T, U, V>
where diff --git a/ori_core/view/trait.View.html b/ori_core/view/trait.View.html index 76a2c86dc..dfa8cf8e6 100644 --- a/ori_core/view/trait.View.html +++ b/ori_core/view/trait.View.html @@ -156,7 +156,7 @@ state: &mut Self::State, cx: &mut DrawCx<'_, '_>, data: &mut T, -)

Implementors§

source§

impl<T> View<T> for Image

§

type State = ()

source§

impl<T> View<T> for Checkbox

source§

impl<T> View<T> for ColorPicker<T>

§

type State = ColorPickerState

source§

impl<T> View<T> for Painter<T>

§

type State = ()

source§

impl<T> View<T> for Slider<T>

source§

impl<T> View<T> for Text

§

type State = TextState

source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

source§

impl<T> View<T> for BoxedView<T>

§

type State = Box<dyn Any>

source§

impl<T, H: View<T>, V: View<T>> View<T> for Collapsing<T, H, V>

§

type State = CollapsingState<T, H, V>

source§

impl<T, S, V: View<(T, S)>> View<T> for WithState<T, S, V>

§

type State = (Pod<V>, S, State<(T, S), V>)

source§

impl<T, U, V: View<U>> View<T> for Focus<T, U, V>

§

type State = <V as View<U>>::State

source§

impl<T, V, F> View<T> for Clickable<T, V, F>
where +)

Implementors§

source§

impl<T> View<T> for Image

§

type State = ()

source§

impl<T> View<T> for Checkbox

source§

impl<T> View<T> for ColorPicker<T>

§

type State = ColorPickerState

source§

impl<T> View<T> for Painter<T>

§

type State = ()

source§

impl<T> View<T> for Slider<T>

source§

impl<T> View<T> for Text

§

type State = TextState

source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

source§

impl<T> View<T> for BoxedView<T>

§

type State = Box<dyn Any>

source§

impl<T, H: View<T>, V: View<T>> View<T> for Collapsing<T, H, V>

§

type State = CollapsingState<T, H, V>

source§

impl<T, S, V: View<(T, S)>> View<T> for WithState<T, S, V>

§

type State = (Pod<V>, S, State<(T, S), V>)

source§

impl<T, U, V: View<U>> View<T> for Focus<T, U, V>

§

type State = <V as View<U>>::State

source§

impl<T, V, F> View<T> for Clickable<T, V, F>
where V: View<T>, F: FnMut(&mut EventCx<'_, '_>, &mut T) + 'static,

§

type State = State<T, V>

source§

impl<T, V, F> View<T> for Suspense<V, F>
where V: View<T>, diff --git a/ori_core/views/struct.TextInput.html b/ori_core/views/struct.TextInput.html index b2d406cbd..370ff853a 100644 --- a/ori_core/views/struct.TextInput.html +++ b/ori_core/views/struct.TextInput.html @@ -74,25 +74,25 @@ self, on_submit: impl FnMut(&mut EventCx<'_, '_>, &mut T, String) + 'static, ) -> Self

Set the callback that is called when the input is submitted.

-

Trait Implementations§

source§

impl<T> Default for TextInput<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

The state of the view, see top-level documentation for more information.
source§

fn build(&mut self, cx: &mut BuildCx<'_, '_>, _data: &mut T) -> Self::State

Build the view state, see top-level documentation for more information.
source§

fn rebuild( +

Trait Implementations§

source§

impl<T> Default for TextInput<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T> View<T> for TextInput<T>

§

type State = TextInputState

The state of the view, see top-level documentation for more information.
source§

fn build(&mut self, cx: &mut BuildCx<'_, '_>, _data: &mut T) -> Self::State

Build the view state, see top-level documentation for more information.
source§

fn rebuild( &mut self, state: &mut Self::State, cx: &mut RebuildCx<'_, '_>, _data: &mut T, old: &Self, -)

Rebuild the view state, see top-level documentation for more information.
source§

fn event( +)

Rebuild the view state, see top-level documentation for more information.
source§

fn event( &mut self, state: &mut Self::State, cx: &mut EventCx<'_, '_>, data: &mut T, event: &Event, -)

Handle an event, see top-level documentation for more information.
source§

fn layout( +)

Handle an event, see top-level documentation for more information.
source§

fn layout( &mut self, state: &mut Self::State, cx: &mut LayoutCx<'_, '_>, _data: &mut T, space: Space, -) -> Size

Layout the view, see top-level documentation for more information.
source§

fn draw( +) -> Size

Layout the view, see top-level documentation for more information.
source§

fn draw( &mut self, state: &mut Self::State, cx: &mut DrawCx<'_, '_>, diff --git a/src/ori_core/views/text_input.rs.html b/src/ori_core/views/text_input.rs.html index 0d8202f44..fc1697c40 100644 --- a/src/ori_core/views/text_input.rs.html +++ b/src/ori_core/views/text_input.rs.html @@ -683,9 +683,34 @@ 683 684 685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710

use cosmic_text::{
     Action, Attrs, AttrsList, Buffer, BufferLine, BufferRef, Edit, Editor, LineEnding, Metrics,
-    Motion, Shaping,
+    Motion, Selection, Shaping,
 };
 use ori_macro::{example, Build, Styled};
 
@@ -928,6 +953,19 @@
         text
     }
 
+    fn ime(&self) -> Ime {
+        let selection = match self.editor.selection_bounds() {
+            Some((start, end)) => start.index..end.index,
+            None => self.editor.cursor().index..self.editor.cursor().index,
+        };
+
+        Ime {
+            text: self.text(),
+            selection,
+            compose: None,
+        }
+    }
+
     fn clear_text(&mut self) {
         self.buffer_mut().lines = vec![BufferLine::new(
             "",
@@ -1140,6 +1178,15 @@
                 }
 
                 if let Some(action) = delete_key(e) {
+                    // NOTE: this is a workaround for a bug where the editor can select nothing,
+                    // and will then delete the selection rather than the character at the cursor
+                    if let Some((start, end)) = state.editor.selection_bounds() {
+                        if start == end {
+                            state.editor.set_selection(Selection::None);
+                            state.editor.set_cursor(start);
+                        }
+                    }
+
                     state.editor.action(&mut cx.fonts().font_system, action);
                     cx.layout();
                     state.blink = 0.0;
@@ -1216,6 +1263,8 @@
                         state.editor.set_cursor(cosmic_text::Cursor::default());
                     }
                 }
+
+                cx.set_ime(Some(state.ime()));
             }
             Event::PointerPressed(e) => {
                 if !cx.is_hovered() {
@@ -1230,7 +1279,6 @@
                 }
 
                 cx.set_focused(true);
-                cx.set_ime(Some(Ime::default()));
                 cx.animate();
 
                 state.blink = 0.0;
@@ -1244,6 +1292,8 @@
                         y: local.y as i32,
                     },
                 );
+
+                cx.set_ime(Some(state.ime()));
             }
             Event::PointerReleased(_) => {
                 state.dragging = false;