From 687d88f4f767190d2d60fe104a140381b6652d18 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 3 Sep 2023 23:38:55 +0200 Subject: Per-script numpad The numeric layout and the optional right hand side numpad are modified to show the digits belonging to the script used in the current layout. The numpads are still defined as it was before. The digits are changed in `modify_numpad` if needed. --- srcs/juloo.keyboard2/Config.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'srcs/juloo.keyboard2/Config.java') diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 8900656..30be772 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -242,7 +242,7 @@ final class Config } }); if (show_numpad) - kw = kw.addNumPad(modify_numpad(KeyboardData.num_pad)); + kw = kw.addNumPad(modify_numpad(KeyboardData.num_pad, kw.script)); if (number_row) kw = kw.addNumberRow(); if (extra_keys.size() > 0) @@ -253,9 +253,10 @@ final class Config /** * Handle the numpad layout. */ - public KeyboardData modify_numpad(KeyboardData kw) + public KeyboardData modify_numpad(KeyboardData kw, String script) { final KeyValue action_key = action_key(); + final KeyModifier.Map_char map_digit = KeyModifier.modify_numpad_script(script); return kw.mapKeys(new KeyboardData.MapKeyValues() { public KeyValue apply(KeyValue key, boolean localized) { @@ -277,11 +278,15 @@ final class Config } break; case Char: - char a = key.getChar(), b = a; + char prev_c = key.getChar(); + char c = prev_c; if (inverse_numpad) - b = inverse_numpad_char(a); - if (a != b) - return key.withChar(b); + c = inverse_numpad_char(c); + String modified = map_digit.apply(c); + if (modified != null) // Was modified by script + return key.withSymbol(modified); + if (prev_c != c) // Was inverted + return key.withChar(c); break; } return key; -- cgit v1.2.3