config: mouse bindings: add select-begin-block and select-row

This commit is contained in:
Daniel Eklöf 2020-08-11 10:17:19 +02:00
parent f14b49068a
commit 4d2bc54fa2
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 40 additions and 19 deletions

33
input.c
View file

@ -255,11 +255,22 @@ execute_binding(struct seat *seat, struct terminal *term,
}
case BIND_ACTION_SELECT_BEGIN:
selection_start(
term, seat->mouse.col, seat->mouse.row,
seat->kbd.ctrl ? SELECTION_BLOCK : SELECTION_NORMAL);
selection_start(term, seat->mouse.col, seat->mouse.row, SELECTION_NORMAL);
break;
case BIND_ACTION_SELECT_BEGIN_BLOCK:
selection_start(term, seat->mouse.col, seat->mouse.row, SELECTION_BLOCK);
break;
case BIND_ACTION_SELECT_EXTEND: {
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
if (selection_enabled(term, seat) && cursor_is_on_grid) {
selection_extend(
seat, term, seat->mouse.col, seat->mouse.row, serial);
}
break;
}
case BIND_ACTION_SELECT_WORD:
selection_mark_word(
seat, term, seat->mouse.col, seat->mouse.row, false, serial);
@ -270,14 +281,10 @@ execute_binding(struct seat *seat, struct terminal *term,
seat, term, seat->mouse.col, seat->mouse.row, true, serial);
break;
case BIND_ACTION_SELECT_EXTEND: {
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
if (selection_enabled(term, seat) && cursor_is_on_grid) {
selection_extend(
seat, term, seat->mouse.col, seat->mouse.row, serial);
}
case BIND_ACTION_SELECT_ROW:
selection_mark_row(seat, term, seat->mouse.row, serial);
break;
}
case BIND_ACTION_COUNT:
assert(false);
@ -1279,10 +1286,8 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
/* Update selection */
if (seat->mouse.button == BTN_LEFT || seat->mouse.button == BTN_RIGHT) {
if (cursor_is_on_new_cell || term->selection.end.row < 0)
selection_update(term, selection_col, selection_row);
}
if (cursor_is_on_new_cell || term->selection.end.row < 0)
selection_update(term, selection_col, selection_row);
/* Send mouse event to client application */
if (!term_mouse_grabbed(term, seat) &&