abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/suggestions/Suggestions.java
diff options
context:
space:
mode:
authorJules Aguillon2026-02-19 00:37:42 +0100
committerGitHub2026-02-19 00:37:42 +0100
commitdf3594bd53c71d06f6e103f6782bb26b970beac4 (patch)
treec998211c06617baadd821a1a9bee03a66f1b51ee /srcs/juloo.keyboard2/suggestions/Suggestions.java
parentebf80415d8034d853bd79ba7cfb578db67862529 (diff)
downloadunexpected-keyboard-df3594bd53c71d06f6e103f6782bb26b970beac4.tar.gz
unexpected-keyboard-df3594bd53c71d06f6e103f6782bb26b970beac4.zip
Autocomplete on space bar and undo on delete (#1179)
* Refactor: Implement the space key as an editing action The space key is no longer a CHAR key but now an EDITING key. This allows changing the behavior of the space bar while allowing custom layout users to define a key outputing a space as before. KeyModifier and ComposeKey are updated to treat the space key as before. * Enter the best suggestion when the space bar is pressed * Refactor: Implement backspace as an editing action * Undo suggestion when delete is pressed The delete key (backspace internally) undoes the suggestion if the last action done was entering the suggestion with either the space bar or the candidates view. * Add an option to enable space bar autocomplete This option is off by default. Undoing a completion with backspace works in any case. * Refactor: Track selection emptyness in CurrentlyTypedWord This removes an expensive RPC call.
Diffstat (limited to 'srcs/juloo.keyboard2/suggestions/Suggestions.java')
-rw-r--r--srcs/juloo.keyboard2/suggestions/Suggestions.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/srcs/juloo.keyboard2/suggestions/Suggestions.java b/srcs/juloo.keyboard2/suggestions/Suggestions.java
index 998d40d..89ed86e 100644
--- a/srcs/juloo.keyboard2/suggestions/Suggestions.java
+++ b/srcs/juloo.keyboard2/suggestions/Suggestions.java
@@ -13,6 +13,10 @@ public final class Suggestions
Callback _callback;
Config _config;
+ /** The suggestion displayed at the center of the candidates view and entered
+ by the space bar. */
+ public String best_suggestion = null;
+
public Suggestions(Callback c, Config conf)
{
_callback = c;
@@ -24,7 +28,7 @@ public final class Suggestions
Cdict dict = _config.current_dictionary;
if (word.length() < 2 || dict == null)
{
- _callback.set_suggestions(NO_SUGGESTIONS);
+ set_suggestions(NO_SUGGESTIONS);
}
else
{
@@ -42,10 +46,16 @@ public final class Suggestions
if (dist.length > j && i < 3)
suggestions[i++] = dict.word(dist[j]);
}
- _callback.set_suggestions(Arrays.asList(suggestions));
+ set_suggestions(Arrays.asList(suggestions));
}
}
+ void set_suggestions(List<String> ws)
+ {
+ _callback.set_suggestions(ws);
+ best_suggestion = (ws.size() > 0) ? ws.get(0) : null;
+ }
+
static final List<String> NO_SUGGESTIONS = Arrays.asList();
public static interface Callback