editor: Properly adjust cursor on delete

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
Jan Arne Petersen 12 years ago committed by Kristian Høgsberg
parent a96953dffa
commit 9eaa8e51ca
  1. 11
      clients/editor.c

@ -837,16 +837,19 @@ text_entry_delete_text(struct text_entry *entry,
{ {
uint32_t l; uint32_t l;
if (entry->cursor > index)
entry->cursor -= length;
entry->anchor = entry->cursor;
l = strlen(entry->text + index + length); l = strlen(entry->text + index + length);
memmove(entry->text + index, memmove(entry->text + index,
entry->text + index + length, entry->text + index + length,
l + 1); 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); text_entry_update_layout(entry);
widget_schedule_redraw(entry->widget); widget_schedule_redraw(entry->widget);

Loading…
Cancel
Save