selection: wip: update selection row-wise when initial selection was by row

This commit is contained in:
Daniel Eklöf 2021-01-02 21:26:28 +01:00
parent 30de262d29
commit 55ecf29a36
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 24 additions and 3 deletions

View file

@ -497,7 +497,11 @@ selection_update(struct terminal *term, int col, int row)
} }
} }
if (term->selection.semantic == SELECTION_SEMANTIC_WORD) { switch (term->selection.semantic) {
case SELECTION_SEMANTIC_NONE:
break;
case SELECTION_SEMANTIC_WORD:
switch (term->selection.direction) { switch (term->selection.direction) {
case SELECTION_LEFT: case SELECTION_LEFT:
find_word_boundary_left(term, &new_end, false); find_word_boundary_left(term, &new_end, false);
@ -511,6 +515,23 @@ selection_update(struct terminal *term, int col, int row)
assert(false); assert(false);
break; break;
} }
break;
case SELECTION_SEMANTIC_ROW:
switch (term->selection.direction) {
case SELECTION_LEFT:
new_end.col = 0;
break;
case SELECTION_RIGHT:
new_end.col = term->cols - 1;
break;
case SELECTION_UNDIR:
assert(false);
break;
}
break;
} }
/* If an end point is in the middle of a multi-column character, /* If an end point is in the middle of a multi-column character,
@ -834,7 +855,7 @@ void
selection_mark_row( selection_mark_row(
struct seat *seat, struct terminal *term, int row, uint32_t serial) struct seat *seat, struct terminal *term, int row, uint32_t serial)
{ {
selection_start(term, 0, row, SELECTION_NORMAL, SELECTION_SEMANTIC_NONE); selection_start(term, 0, row, SELECTION_NORMAL, SELECTION_SEMANTIC_ROW);
selection_update(term, term->cols - 1, row); selection_update(term, term->cols - 1, row);
selection_finalize(seat, term, serial); selection_finalize(seat, term, serial);
} }

View file

@ -181,7 +181,7 @@ enum mouse_reporting {
enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BAR }; enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BAR };
enum selection_kind { SELECTION_NONE, SELECTION_NORMAL, SELECTION_BLOCK }; enum selection_kind { SELECTION_NONE, SELECTION_NORMAL, SELECTION_BLOCK };
enum selection_semantic { SELECTION_SEMANTIC_NONE, SELECTION_SEMANTIC_WORD}; enum selection_semantic { SELECTION_SEMANTIC_NONE, SELECTION_SEMANTIC_WORD, SELECTION_SEMANTIC_ROW};
enum selection_direction {SELECTION_UNDIR, SELECTION_LEFT, SELECTION_RIGHT}; enum selection_direction {SELECTION_UNDIR, SELECTION_LEFT, SELECTION_RIGHT};
enum selection_scroll_direction {SELECTION_SCROLL_NOT, SELECTION_SCROLL_UP, SELECTION_SCROLL_DOWN}; enum selection_scroll_direction {SELECTION_SCROLL_NOT, SELECTION_SCROLL_UP, SELECTION_SCROLL_DOWN};