[PATCH 15/18] editor: Add support for backspace keysym events

Jan Arne Petersen jpetersen at openismus.com
Wed Jan 16 12:26:52 PST 2013


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

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

diff --git a/clients/editor.c b/clients/editor.c
index 462c400..2909109 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -304,6 +304,24 @@ text_model_keysym(void *data,
 		return;
 	}
 
+	if (key == XKB_KEY_BackSpace) {
+		const char *start, *end;
+
+		text_entry_commit_and_reset(entry);
+
+		start = utf8_prev_char(entry->text, entry->text + entry->cursor);
+
+		if (start == NULL)
+			return;
+
+		end = utf8_end_char(entry->text + entry->cursor);
+		text_entry_delete_text(entry,
+				       start - entry->text,
+				       end - start);
+
+		return;
+	}
+
 	switch (key) {
 		case XKB_KEY_Tab:
 			key_label = "Tab";
-- 
1.8.1



More information about the wayland-devel mailing list