Skip to content

Commit 9c19e88

Browse files
committed
Allow extending selections by dragging with right button pressed
Fixes #2445
1 parent 7329bd4 commit 9c19e88

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
7171

7272
- Fix selection not updating properly while scrolling (:iss:`2442`)
7373

74+
- Allow extending selections by dragging with right button pressed
75+
(:iss:`2445`)
76+
7477
- Workaround for bug in less that causes colors to reset at wrapped lines
7578
(:iss:`2381`)
7679

kitty/mouse.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ drag_scroll(Window *w, OSWindow *frame) {
217217
}
218218

219219
static inline void
220-
extend_selection(Window *w) {
220+
extend_selection(Window *w, bool ended) {
221221
Screen *screen = w->render_data.screen;
222222
if (screen_has_selection(screen)) {
223-
screen_update_selection(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y, w->mouse_pos.in_left_half_of_cell, true, false);
223+
screen_update_selection(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y, w->mouse_pos.in_left_half_of_cell, ended, false);
224224
}
225225
}
226226

@@ -304,7 +304,7 @@ detect_url(Screen *screen, unsigned int x, unsigned int y) {
304304
static inline void
305305
handle_mouse_movement_in_kitty(Window *w, int button, bool mouse_cell_changed) {
306306
Screen *screen = w->render_data.screen;
307-
if (screen->selection.in_progress && button == GLFW_MOUSE_BUTTON_LEFT) {
307+
if (screen->selection.in_progress && (button == GLFW_MOUSE_BUTTON_LEFT || button == GLFW_MOUSE_BUTTON_RIGHT)) {
308308
monotonic_t now = monotonic();
309309
if ((now - w->last_drag_scroll_at) >= ms_to_monotonic_t(20ll) || mouse_cell_changed) {
310310
update_drag(false, w, false, 0);
@@ -427,7 +427,7 @@ handle_button_event_in_kitty(Window *w, int button, int modifiers, bool is_relea
427427
if (is_release) { call_boss(paste_from_selection, NULL); return; }
428428
break;
429429
case GLFW_MOUSE_BUTTON_RIGHT:
430-
if (is_release) { extend_selection(w); }
430+
extend_selection(w, is_release);
431431
break;
432432
}
433433
}

kitty/screen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,7 @@ screen_mark_url(Screen *self, index_type start_x, index_type start_y, index_type
22172217

22182218
void
22192219
screen_update_selection(Screen *self, index_type x, index_type y, bool in_left_half_of_cell, bool ended, bool start_extended_selection) {
2220-
if (ended) self->selection.in_progress = false;
2220+
self->selection.in_progress = !ended;
22212221
self->selection.input_current.x = x; self->selection.input_current.y = y;
22222222
self->selection.input_current.in_left_half_of_cell = in_left_half_of_cell;
22232223
self->selection.end_scrolled_by = self->scrolled_by;

0 commit comments

Comments
 (0)