diff options
| author | Jules Aguillon | 2023-09-24 16:35:24 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2023-09-24 16:35:24 +0200 |
| commit | d5cbcb37e315a62b9e61873937bc4b38e4d0f5a7 (patch) | |
| tree | b5d2fe17f0a212fe3de18aa5392847508125a8a9 /srcs/juloo.keyboard2/KeyboardData.java | |
| parent | 66b1bdc9c90e1f29ecec096286136b527ec6b8ed (diff) | |
| download | unexpected-keyboard-d5cbcb37e315a62b9e61873937bc4b38e4d0f5a7.tar.gz unexpected-keyboard-d5cbcb37e315a62b9e61873937bc4b38e4d0f5a7.zip | |
Preferred position for locale `extra_keys`
`method.xml` is now able to specify a preferred position for each extra
keys in term of an other key to which it should be placed nearby.
It's implemented for French as an example.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyboardData.java')
| -rw-r--r-- | srcs/juloo.keyboard2/KeyboardData.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index 94c1384..8ecd053 100644 --- a/srcs/juloo.keyboard2/KeyboardData.java +++ b/srcs/juloo.keyboard2/KeyboardData.java @@ -58,6 +58,13 @@ class KeyboardData [rows]. Returns [false] if it couldn't be placed. */ boolean add_key_to_preferred_pos(List<Row> rows, KeyValue kv, PreferredPos pos) { + if (pos.next_to != null) + { + KeyPos next_to_pos = getKeys().get(pos.next_to); + if (next_to_pos != null + && add_key_to_pos(rows, kv, next_to_pos.with_dir(-1))) + return true; + } for (KeyPos p : pos.positions) if (add_key_to_pos(rows, kv, p)) return true; @@ -521,6 +528,11 @@ class KeyboardData col = c; dir = d; } + + public KeyPos with_dir(int d) + { + return new KeyPos(row, col, d); + } } /** See [addExtraKeys()]. */ @@ -529,6 +541,10 @@ class KeyboardData public static final PreferredPos DEFAULT; public static final PreferredPos ANYWHERE; + /** Prefer the free position on the same keyboard key as the specified key. + Considered before [positions]. Might be [null]. */ + public KeyValue next_to = null; + /** Array of positions to try in order. The special value [-1] as [row], [col] or [dir] means that the field is unspecified. Every possible values are tried for unspecified fields. Unspecified fields are @@ -537,6 +553,12 @@ class KeyboardData public PreferredPos() {} + public PreferredPos(PreferredPos src) + { + next_to = src.next_to; + positions = src.positions; + } + static final KeyPos[] ANYWHERE_POSITIONS = new KeyPos[]{ new KeyPos(-1, -1, -1) }; |
