Remove the 'slider="true"' attribute

Whether a key behaves as a slider is now purely defined by the key
values present on it.
This commit is contained in:
Jules Aguillon 2025-01-11 16:30:36 +01:00
parent 1783dcdb35
commit ddd2eebb0e
8 changed files with 13 additions and 20 deletions

View File

@ -93,7 +93,6 @@ The following optional properties define the effects of swipes:
You can define a swipe only once with either compass-point or numeric notation. Unexpected Keyboard automatically puts a small legend in that direction from the center of the key. You can define a swipe only once with either compass-point or numeric notation. Unexpected Keyboard automatically puts a small legend in that direction from the center of the key.
* `slider`: If `slider="true"`, and the key also has `w` and `e` properties, then the key tracks horizontal finger motion precisely and sends the `w` and `e` keystrokes repeatedly. In built-in layouts, this makes the space bar send left and right characters as the user slides on the space bar.
* `anticircle`: The key value to send when doing an anti-clockwise gesture on the key. * `anticircle`: The key value to send when doing an anti-clockwise gesture on the key.
### Layout ### Layout

View File

@ -66,8 +66,8 @@ Value | Meaning
These keys perform editing on the text without sending keys that the app can interpret differently or ignore. These keys perform editing on the text without sending keys that the app can interpret differently or ignore.
Value | Meaning Value | Meaning
:----------------- | :------ :----------------- | :------
`cursor_left` | Moves the cursor position to the left directly, without sending a `left` key event. `cursor_left` | Moves the cursor to the left with the slider gesture.
`cursor_right` | Moves the cursor position to the right directly, without sending a `right` key event. `cursor_right` | Moves the cursor to the right with the slider gesture.
## Other modifiers and diacritics ## Other modifiers and diacritics
Value | Meaning Value | Meaning

View File

@ -2,7 +2,7 @@
<row height="0.95"> <row height="0.95">
<key width="1.7" key0="ctrl" key1="loc switch_greekmath" key2="loc meta" key3="loc switch_clipboard" key4="switch_numeric"/> <key width="1.7" key0="ctrl" key1="loc switch_greekmath" key2="loc meta" key3="loc switch_clipboard" key4="switch_numeric"/>
<key width="1.1" key0="fn" key1="loc alt" key2="loc change_method" key3="switch_emoji" key4="config"/> <key width="1.1" key0="fn" key1="loc alt" key2="loc change_method" key3="switch_emoji" key4="config"/>
<key width="4.4" key0="space" key7="switch_forward" key8="switch_backward" key5="cursor_left" key6="cursor_right" slider="true"/> <key width="4.4" key0="space" key7="switch_forward" key8="switch_backward" key5="cursor_left" key6="cursor_right"/>
<key width="1.1" key0="loc compose" key7="up" key6="right" key5="left" key8="down" key1="loc home" key2="loc page_up" key3="loc end" key4="loc page_down"/> <key width="1.1" key0="loc compose" key7="up" key6="right" key5="left" key8="down" key1="loc home" key2="loc page_up" key3="loc end" key4="loc page_down"/>
<key width="1.7" key0="enter" key1="loc voice_typing" key2="action"/> <key width="1.7" key0="enter" key1="loc voice_typing" key2="action"/>
</row> </row>

View File

@ -3,7 +3,7 @@
<keyboard bottom_row="false"> <keyboard bottom_row="false">
<row height="0.95"> <row height="0.95">
<key key0="switch_back_clipboard"/> <key key0="switch_back_clipboard"/>
<key width="3" key0="space" key5="cursor_left" key6="cursor_right" slider="true"/> <key width="3" key0="space" key5="cursor_left" key6="cursor_right"/>
<key key0="backspace" key2="delete"/> <key key0="backspace" key2="delete"/>
<key key0="enter" key2="action"/> <key key0="enter" key2="action"/>
</row> </row>

View File

@ -3,7 +3,7 @@
<keyboard bottom_row="false"> <keyboard bottom_row="false">
<row height="0.95"> <row height="0.95">
<key key0="switch_back_emoji"/> <key key0="switch_back_emoji"/>
<key width="3" key0="space" key5="cursor_left" key6="cursor_right" slider="true"/> <key width="3" key0="space" key5="cursor_left" key6="cursor_right"/>
<key key0="backspace" key2="delete"/> <key key0="backspace" key2="delete"/>
<key key0="enter" key2="action"/> <key key0="enter" key2="action"/>
</row> </row>

View File

@ -401,9 +401,6 @@ public final class KeyboardData
public final float width; public final float width;
/** Extra empty space on the left of the key. */ /** Extra empty space on the left of the key. */
public final float shift; public final float shift;
/** Keys 2 and 3 are repeated as the finger moves laterally on the key.
Used for the left and right arrow keys on the space bar. */
public final boolean slider;
/** String printed on the keys. It has no other effect. */ /** String printed on the keys. It has no other effect. */
public final String indication; public final String indication;
@ -411,14 +408,13 @@ public final class KeyboardData
public static final int F_LOC = 1; public static final int F_LOC = 1;
public static final int ALL_FLAGS = F_LOC; public static final int ALL_FLAGS = F_LOC;
protected Key(KeyValue[] ks, KeyValue antic, int f, float w, float s, boolean sl, String i) protected Key(KeyValue[] ks, KeyValue antic, int f, float w, float s, String i)
{ {
keys = ks; keys = ks;
anticircle = antic; anticircle = antic;
keysflags = f; keysflags = f;
width = Math.max(w, 0f); width = Math.max(w, 0f);
shift = Math.max(s, 0f); shift = Math.max(s, 0f);
slider = sl;
indication = i; indication = i;
} }
@ -487,11 +483,10 @@ public final class KeyboardData
KeyValue anticircle = parse_nonloc_key_attr(parser, "anticircle"); KeyValue anticircle = parse_nonloc_key_attr(parser, "anticircle");
float width = attribute_float(parser, "width", 1f); float width = attribute_float(parser, "width", 1f);
float shift = attribute_float(parser, "shift", 0.f); float shift = attribute_float(parser, "shift", 0.f);
boolean slider = attribute_bool(parser, "slider", false);
String indication = parser.getAttributeValue(null, "indication"); String indication = parser.getAttributeValue(null, "indication");
while (parser.next() != XmlPullParser.END_TAG) while (parser.next() != XmlPullParser.END_TAG)
continue; continue;
return new Key(ks, anticircle, keysflags, width, shift, slider, indication); return new Key(ks, anticircle, keysflags, width, shift, indication);
} }
/** Whether key at [index] as [flag]. */ /** Whether key at [index] as [flag]. */
@ -503,8 +498,7 @@ public final class KeyboardData
/** New key with the width multiplied by 's'. */ /** New key with the width multiplied by 's'. */
public Key scaleWidth(float s) public Key scaleWidth(float s)
{ {
return new Key(keys, anticircle, keysflags, width * s, shift, slider, return new Key(keys, anticircle, keysflags, width * s, shift, indication);
indication);
} }
public void getKeys(Map<KeyValue, KeyPos> dst, int row, int col) public void getKeys(Map<KeyValue, KeyPos> dst, int row, int col)
@ -525,12 +519,12 @@ public final class KeyboardData
for (int j = 0; j < keys.length; j++) ks[j] = keys[j]; for (int j = 0; j < keys.length; j++) ks[j] = keys[j];
ks[i] = kv; ks[i] = kv;
int flags = (keysflags & ~(ALL_FLAGS << i)); int flags = (keysflags & ~(ALL_FLAGS << i));
return new Key(ks, anticircle, flags, width, shift, slider, indication); return new Key(ks, anticircle, flags, width, shift, indication);
} }
public Key withShift(float s) public Key withShift(float s)
{ {
return new Key(keys, anticircle, keysflags, width, s, slider, indication); return new Key(keys, anticircle, keysflags, width, s, indication);
} }
public boolean hasValue(KeyValue kv) public boolean hasValue(KeyValue kv)
@ -556,7 +550,7 @@ public final class KeyboardData
for (int i = 0; i < ks.length; i++) for (int i = 0; i < ks.length; i++)
if (k.keys[i] != null) if (k.keys[i] != null)
ks[i] = apply(k.keys[i], k.keyHasFlag(i, Key.F_LOC)); ks[i] = apply(k.keys[i], k.keyHasFlag(i, Key.F_LOC));
return new Key(ks, k.anticircle, k.keysflags, k.width, k.shift, k.slider, k.indication); return new Key(ks, k.anticircle, k.keysflags, k.width, k.shift, k.indication);
} }
} }

View File

@ -295,7 +295,7 @@ public final class Pointers implements Handler.Callback
ptr.value = new_value; ptr.value = new_value;
ptr.flags = pointer_flags_of_kv(new_value); ptr.flags = pointer_flags_of_kv(new_value);
// Start sliding mode // Start sliding mode
if (ptr.key.slider && new_value.getKind() == KeyValue.Kind.Slider) if (new_value.getKind() == KeyValue.Kind.Slider)
startSliding(ptr, x, (dx < 0 ? -1 : 1), new_value); startSliding(ptr, x, (dx < 0 ? -1 : 1), new_value);
_handler.onPointerDown(new_value, true); _handler.onPointerDown(new_value, true);
} }

View File

@ -43,7 +43,7 @@
<row height="0.95"> <row height="0.95">
<key width="1.7" key0="ctrl" key1="loc switch_greekmath" key2="loc meta" key4="switch_numeric"/> <key width="1.7" key0="ctrl" key1="loc switch_greekmath" key2="loc meta" key4="switch_numeric"/>
<key width="1.1" key0="fn" key1="loc alt" key2="loc change_method" key3="switch_emoji" key4="config"/> <key width="1.1" key0="fn" key1="loc alt" key2="loc change_method" key3="switch_emoji" key4="config"/>
<key width="4.4" key0="space" key7="switch_forward" key8="switch_backward" key5="cursor_left" key6="cursor_right" slider="true"/> <key width="4.4" key0="space" key7="switch_forward" key8="switch_backward" key5="cursor_left" key6="cursor_right"/>
<key width="1.1" key0="loc compose" key7="up" key6="right" key5="left" key8="down" key1="loc home" key2="loc page_up" key3="loc end" key4="loc page_down"/> <key width="1.1" key0="loc compose" key7="up" key6="right" key5="left" key8="down" key1="loc home" key2="loc page_up" key3="loc end" key4="loc page_down"/>
<key key0="j" key4=";"/> <key key0="j" key4=";"/>
<key width="1.7" key0="enter" key1="loc voice_typing" key2="action"/> <key width="1.7" key0="enter" key1="loc voice_typing" key2="action"/>