editor: Support shift-left/right for selecting text

If the shift modifier is active then we don't make the cursor and the
anchor the same and as a result we develop a selection in the direction
that the arrow key gets pressed in.

https://bugs.freedesktop.org/show_bug.cgi?id=66802
dev
Rob Bradford 12 years ago committed by Kristian Høgsberg
parent bdeb5d224d
commit 7000283741
  1. 2
      clients/editor.c

@ -1141,6 +1141,7 @@ key_handler(struct window *window,
new_char = utf8_prev_char(entry->text, entry->text + entry->cursor); new_char = utf8_prev_char(entry->text, entry->text + entry->cursor);
if (new_char != NULL) { if (new_char != NULL) {
entry->cursor = new_char - entry->text; entry->cursor = new_char - entry->text;
if (!(input_get_modifiers(input) & MOD_SHIFT_MASK))
entry->anchor = entry->cursor; entry->anchor = entry->cursor;
widget_schedule_redraw(entry->widget); widget_schedule_redraw(entry->widget);
} }
@ -1151,6 +1152,7 @@ key_handler(struct window *window,
new_char = utf8_next_char(entry->text + entry->cursor); new_char = utf8_next_char(entry->text + entry->cursor);
if (new_char != NULL) { if (new_char != NULL) {
entry->cursor = new_char - entry->text; entry->cursor = new_char - entry->text;
if (!(input_get_modifiers(input) & MOD_SHIFT_MASK))
entry->anchor = entry->cursor; entry->anchor = entry->cursor;
widget_schedule_redraw(entry->widget); widget_schedule_redraw(entry->widget);
} }

Loading…
Cancel
Save