selection: adjust start point when the selection changes direction

Without this, the initial cell will always be selected, regardless of
how the selection is moved to the left or right.

With this patch, the initial cell will only be selected while the
selection is being made in the original direction. Changing direction
of the selection moves the start point to next/previous character.
This commit is contained in:
Daniel Eklöf 2020-08-12 18:50:49 +02:00
parent 156cce6ef6
commit 8808dd28f2
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 41 additions and 0 deletions

View file

@ -181,6 +181,7 @@ enum mouse_reporting {
enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BAR };
enum selection_kind { SELECTION_NONE, SELECTION_NORMAL, SELECTION_BLOCK };
enum selection_direction {SELECTION_UNDIR, SELECTION_LEFT, SELECTION_RIGHT};
struct ptmx_buffer {
void *data;
@ -306,6 +307,7 @@ struct terminal {
struct {
enum selection_kind kind;
enum selection_direction direction;
struct coord start;
struct coord end;
} selection;