[PATCH 3/5] editor: Properly adjust cursor on delete

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


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

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

diff --git a/clients/editor.c b/clients/editor.c
index 16ede4f..35f6d08 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -837,16 +837,19 @@ text_entry_delete_text(struct text_entry *entry,
 {
 	uint32_t l;
 
-	if (entry->cursor > index)
-		entry->cursor -= length;
-
-	entry->anchor = entry->cursor;
 
 	l = strlen(entry->text + index + length);
 	memmove(entry->text + index,
 		entry->text + index + length,
 		l + 1);
 
+	if (entry->cursor > (index + length))
+		entry->cursor -= length;
+	else if (entry->cursor > index)
+		entry->cursor = index;
+
+	entry->anchor = entry->cursor;
+
 	text_entry_update_layout(entry);
 
 	widget_schedule_redraw(entry->widget);
-- 
1.8.1.4



More information about the wayland-devel mailing list