abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/KeyEventHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/juloo.keyboard2/KeyEventHandler.java')
-rw-r--r--srcs/juloo.keyboard2/KeyEventHandler.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java
index fd283df..8691cda 100644
--- a/srcs/juloo.keyboard2/KeyEventHandler.java
+++ b/srcs/juloo.keyboard2/KeyEventHandler.java
@@ -129,7 +129,8 @@ public final class KeyEventHandler
public void suggestion_entered(String text)
{
String old = _typedword.get();
- replace_text_before_cursor(old.length(), text + " ");
+ int cur_rel = _typedword.cursor_relative();
+ replace_surrounding_text(old.length() + cur_rel, -cur_rel, text + " ");
last_replaced_word = old;
last_replacement_word_len = text.length() + 1;
}
@@ -256,13 +257,14 @@ public final class KeyEventHandler
clear_space_bar_state();
}
- void replace_text_before_cursor(int remove_length, String new_text)
+ void replace_surrounding_text(int remove_before, int remove_after,
+ String new_text)
{
InputConnection conn = _recv.getCurrentInputConnection();
if (conn == null)
return;
conn.beginBatchEdit();
- conn.deleteSurroundingText(remove_length, 0);
+ conn.deleteSurroundingText(remove_before, remove_after);
conn.commitText(new_text, 1);
conn.endBatchEdit();
}
@@ -540,7 +542,7 @@ public final class KeyEventHandler
{
if (last_replaced_word != null)
{
- replace_text_before_cursor(last_replacement_word_len,
+ replace_surrounding_text(last_replacement_word_len, 0,
last_replaced_word + " ");
last_replaced_word = null;
}