From 1783dcdb35a5c482ca6de2351a0f9c6321bdf786 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 11 Jan 2025 16:00:08 +0100 Subject: Refactor: Restrict sliders to new 'Slider' key kind Setting 'slider="true"' on a key is no longer enough to make a slider, the key must also be of kind 'Slider'. Only the KeyValue that started sliding is now considered, they can be generated with negative values. This allows keys that don't have the complementary cursor movement key on the opposite direction. This will help implement other kind of sliders as well as up/down sliders. --- srcs/juloo.keyboard2/KeyEventHandler.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'srcs/juloo.keyboard2/KeyEventHandler.java') diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index 0a8cd65..45db719 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -99,7 +99,7 @@ public final class KeyEventHandler case Compose_pending: _recv.set_compose_pending(true); break; - case Cursor_move: move_cursor(key.getCursorMove()); break; + case Slider: handle_slider(key.getSlider(), key.getSliderRepeat()); break; case Complex: send_complex_key(key.getComplexKind(), key.getComplex()); break; } update_meta_state(old_mods); @@ -262,6 +262,15 @@ public final class KeyEventHandler return conn.getExtractedText(_move_cursor_req, 0); } + void handle_slider(KeyValue.Slider s, int repeatition) + { + switch (s) + { + case Cursor_left: move_cursor(-repeatition); break; + case Cursor_right: move_cursor(repeatition); break; + } + } + /** Move the cursor right or left, if possible without sending key events. Unlike arrow keys, the selection is not removed even if shift is not on. Falls back to sending arrow keys events if the editor do not support -- cgit v1.2.3