[PATCH 2/5] editor: Support deleting text in preedit_string

Jan Arne Petersen jpetersen at openismus.com
Thu May 30 04:57:02 PDT 2013


From: Jan Arne Petersen <jpetersen at openismus.com>

Delete text marked with wl_text_input::delete_surrounding_text on
preedit_string event. When text is explicitly marked with
delete_surrounding_text do not delete selected text.

Signed-off-by: Jan Arne Petersen <jpetersen at openismus.com>
---
 clients/editor.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/clients/editor.c b/clients/editor.c
index 03cdc12..16ede4f 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -146,12 +146,13 @@ text_input_commit_string(void *data,
 
 	text_entry_reset_preedit(entry);
 
-	text_entry_delete_selected_text(entry);
 
 	if (entry->pending_commit.delete_length) {
 		text_entry_delete_text(entry,
 				       entry->pending_commit.delete_index,
 				       entry->pending_commit.delete_length);
+	} else {
+		text_entry_delete_selected_text(entry);
 	}
 
 	text_entry_insert_at_cursor(entry, text,
@@ -172,7 +173,15 @@ text_input_preedit_string(void *data,
 {
 	struct text_entry *entry = data;
 
-	text_entry_delete_selected_text(entry);
+	if (entry->pending_commit.delete_length) {
+		text_entry_delete_text(entry,
+				       entry->pending_commit.delete_index,
+				       entry->pending_commit.delete_length);
+	} else {
+		text_entry_delete_selected_text(entry);
+	}
+	memset(&entry->pending_commit, 0, sizeof entry->pending_commit);
+
 	text_entry_set_preedit(entry, text, entry->preedit_info.cursor);
 	entry->preedit.commit = strdup(commit);
 	entry->preedit.attr_list = entry->preedit_info.attr_list;
-- 
1.8.1.4



More information about the wayland-devel mailing list