mirror of
https://github.com/tmate-io/tmate.git
synced 2025-01-22 13:58:44 +01:00
When a mouse drag is finished, fire a MouseUp key press, instead of doing the
drag end in code. From Stephen Coakley.
This commit is contained in:
parent
02753ba9ea
commit
95adc0e6ba
@ -347,6 +347,7 @@ const struct mode_key_entry mode_key_vi_copy[] = {
|
|||||||
{ KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP },
|
{ KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP },
|
||||||
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN },
|
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN },
|
||||||
{ KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION },
|
{ KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION },
|
||||||
|
{ KEYC_MOUSEUP1_PANE, 0, MODEKEYCOPY_COPYSELECTION },
|
||||||
|
|
||||||
{ 0, -1, 0 }
|
{ 0, -1, 0 }
|
||||||
};
|
};
|
||||||
@ -495,6 +496,7 @@ const struct mode_key_entry mode_key_emacs_copy[] = {
|
|||||||
{ KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP },
|
{ KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP },
|
||||||
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN },
|
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN },
|
||||||
{ KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION },
|
{ KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION },
|
||||||
|
{ KEYC_MOUSEUP1_PANE, 0, MODEKEYCOPY_COPYSELECTION },
|
||||||
|
|
||||||
{ 0, -1, 0 }
|
{ 0, -1, 0 }
|
||||||
};
|
};
|
||||||
|
@ -382,8 +382,42 @@ server_client_check_mouse(struct client *c)
|
|||||||
c->tty.mouse_drag_update = NULL;
|
c->tty.mouse_drag_update = NULL;
|
||||||
c->tty.mouse_drag_release = NULL;
|
c->tty.mouse_drag_release = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* End a mouse drag by passing a MouseUp key corresponding to
|
||||||
|
* the button that started the drag.
|
||||||
|
*/
|
||||||
|
switch (c->tty.mouse_drag_flag) {
|
||||||
|
case 1:
|
||||||
|
if (where == PANE)
|
||||||
|
key = KEYC_MOUSEUP1_PANE;
|
||||||
|
if (where == STATUS)
|
||||||
|
key = KEYC_MOUSEUP1_STATUS;
|
||||||
|
if (where == BORDER)
|
||||||
|
key = KEYC_MOUSEUP1_BORDER;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (where == PANE)
|
||||||
|
key = KEYC_MOUSEUP2_PANE;
|
||||||
|
if (where == STATUS)
|
||||||
|
key = KEYC_MOUSEUP2_STATUS;
|
||||||
|
if (where == BORDER)
|
||||||
|
key = KEYC_MOUSEUP2_BORDER;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (where == PANE)
|
||||||
|
key = KEYC_MOUSEUP3_PANE;
|
||||||
|
if (where == STATUS)
|
||||||
|
key = KEYC_MOUSEUP3_STATUS;
|
||||||
|
if (where == BORDER)
|
||||||
|
key = KEYC_MOUSEUP3_BORDER;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
key = KEYC_MOUSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
c->tty.mouse_drag_flag = 0;
|
c->tty.mouse_drag_flag = 0;
|
||||||
return (KEYC_MOUSE); /* not a key, but still may want to pass */
|
|
||||||
|
return (key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert to a key binding. */
|
/* Convert to a key binding. */
|
||||||
@ -423,7 +457,9 @@ server_client_check_mouse(struct client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c->tty.mouse_drag_flag = 1;
|
/* Begin a drag by setting the flag to nonzero, where the value
|
||||||
|
corresponds to the mouse button doing the dragging. */
|
||||||
|
c->tty.mouse_drag_flag = MOUSE_BUTTONS(b) + 1;
|
||||||
break;
|
break;
|
||||||
case WHEEL:
|
case WHEEL:
|
||||||
if (MOUSE_BUTTONS(b) == MOUSE_WHEEL_UP) {
|
if (MOUSE_BUTTONS(b) == MOUSE_WHEEL_UP) {
|
||||||
|
@ -2248,7 +2248,7 @@ window_copy_start_drag(struct client *c, struct mouse_event *m)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
c->tty.mouse_drag_update = window_copy_drag_update;
|
c->tty.mouse_drag_update = window_copy_drag_update;
|
||||||
c->tty.mouse_drag_release = window_copy_drag_release;
|
c->tty.mouse_drag_release = NULL; /* will fire MouseUp key */
|
||||||
|
|
||||||
window_copy_update_cursor(wp, x, y);
|
window_copy_update_cursor(wp, x, y);
|
||||||
window_copy_start_selection(wp);
|
window_copy_start_selection(wp);
|
||||||
@ -2275,16 +2275,3 @@ window_copy_drag_update(__unused struct client *c, struct mouse_event *m)
|
|||||||
if (window_copy_update_selection(wp, 1))
|
if (window_copy_update_selection(wp, 1))
|
||||||
window_copy_redraw_selection(wp, old_cy);
|
window_copy_redraw_selection(wp, old_cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
window_copy_drag_release(__unused struct client *c, struct mouse_event *m)
|
|
||||||
{
|
|
||||||
struct window_pane *wp;
|
|
||||||
|
|
||||||
wp = cmd_mouse_pane(m, NULL, NULL);
|
|
||||||
if (wp == NULL || wp->mode != &window_copy_mode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
window_copy_copy_selection(wp, NULL);
|
|
||||||
window_pane_reset_mode(wp);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user