- Add an option :opt:terminal_select_modifiers to control which modifiers are used to override mouse selection

Fixes #1774
This commit is contained in:
Kovid Goyal 2019-07-03 10:50:07 +05:30
parent 6866cd0fb8
commit 1e172caea3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 14 additions and 6 deletions

View File

@ -12,11 +12,11 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Allow passing a ``!neighbor`` argument to the new_window mapping to open a - Allow passing a ``!neighbor`` argument to the new_window mapping to open a
new window next to the active window (:iss:`1746`) new window next to the active window (:iss:`1746`)
- Fix an out of bounds read causing a crash when selecting text with the mouse
in the alternate screen mode (:iss:`1578`)
- Document the kitty remote control protocol (:iss:`1646`) - Document the kitty remote control protocol (:iss:`1646`)
- Add an option :opt:`terminal_select_modifiers` to control which
modifiers are used to override mouse selection (:iss:`1774`)
- When piping data to a child in the pipe command do it in a thread so as not - When piping data to a child in the pipe command do it in a thread so as not
to block the UI (:iss:`1708`) to block the UI (:iss:`1708`)
@ -35,6 +35,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- macOS: Fix finding fallback font for private use unicode symbols not working - macOS: Fix finding fallback font for private use unicode symbols not working
reliably (:iss:`1650`) reliably (:iss:`1650`)
- Fix an out of bounds read causing a crash when selecting text with the mouse
in the alternate screen mode (:iss:`1578`)
0.14.2 [2019-06-09] 0.14.2 [2019-06-09]
--------------------- ---------------------

View File

@ -456,6 +456,9 @@ o('rectangle_select_modifiers', 'ctrl+alt', option_type=to_modifiers, long_text=
The modifiers to use rectangular selection (i.e. to select text in a The modifiers to use rectangular selection (i.e. to select text in a
rectangular block with the mouse)''')) rectangular block with the mouse)'''))
o('terminal_select_modifiers', 'shift', option_type=to_modifiers, long_text=_('''
The modifiers to override mouse selection even when a terminal application has grabbed the mouse'''))
o('select_by_word_characters', ':@-./_~?&=%+#', long_text=_(''' o('select_by_word_characters', ':@-./_~?&=%+#', long_text=_('''
Characters considered part of a word when double clicking. In addition to these characters Characters considered part of a word when double clicking. In addition to these characters
any character that is marked as an alpha-numeric character in the unicode any character that is marked as an alpha-numeric character in the unicode

View File

@ -170,7 +170,7 @@ update_drag(bool from_button, Window *w, bool is_release, int modifiers) {
} }
else { else {
global_state.active_drag_in_window = w->id; global_state.active_drag_in_window = w->id;
screen_start_selection(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y, modifiers == (int)OPT(rectangle_select_modifiers) || modifiers == ((int)OPT(rectangle_select_modifiers) | GLFW_MOD_SHIFT), EXTEND_CELL); screen_start_selection(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y, modifiers == (int)OPT(rectangle_select_modifiers) || modifiers == ((int)OPT(rectangle_select_modifiers) | (int)OPT(terminal_select_modifiers)), EXTEND_CELL);
} }
} else if (screen->selection.in_progress) { } else if (screen->selection.in_progress) {
screen_update_selection(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y, false); screen_update_selection(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y, false);
@ -283,7 +283,7 @@ HANDLER(handle_move_event) {
bool handle_in_kitty = ( bool handle_in_kitty = (
(screen->modes.mouse_tracking_mode == ANY_MODE || (screen->modes.mouse_tracking_mode == ANY_MODE ||
(screen->modes.mouse_tracking_mode == MOTION_MODE && button >= 0)) && (screen->modes.mouse_tracking_mode == MOTION_MODE && button >= 0)) &&
!(global_state.callback_os_window->is_key_pressed[GLFW_KEY_LEFT_SHIFT] || global_state.callback_os_window->is_key_pressed[GLFW_KEY_RIGHT_SHIFT]) (modifiers & OPT(terminal_select_modifiers))
) ? false : true; ) ? false : true;
if (handle_in_kitty) { if (handle_in_kitty) {
if (screen->selection.in_progress && button == GLFW_MOUSE_BUTTON_LEFT) { if (screen->selection.in_progress && button == GLFW_MOUSE_BUTTON_LEFT) {
@ -378,7 +378,7 @@ HANDLER(handle_button_event) {
Screen *screen = w->render_data.screen; Screen *screen = w->render_data.screen;
if (!screen) return; if (!screen) return;
bool handle_in_kitty = ( bool handle_in_kitty = (
modifiers == GLFW_MOD_SHIFT || modifiers == ((int)OPT(rectangle_select_modifiers) | GLFW_MOD_SHIFT) || modifiers == (int)OPT(terminal_select_modifiers) || modifiers == ((int)OPT(rectangle_select_modifiers) | (int)OPT(terminal_select_modifiers)) ||
screen->modes.mouse_tracking_mode == 0 || screen->modes.mouse_tracking_mode == 0 ||
button == GLFW_MOUSE_BUTTON_MIDDLE || button == GLFW_MOUSE_BUTTON_MIDDLE ||
(modifiers == (int)OPT(open_url_modifiers) && button == GLFW_MOUSE_BUTTON_LEFT) (modifiers == (int)OPT(open_url_modifiers) && button == GLFW_MOUSE_BUTTON_LEFT)

View File

@ -384,6 +384,7 @@ PYWRAP1(set_options) {
S(touch_scroll_multiplier, PyFloat_AsDouble); S(touch_scroll_multiplier, PyFloat_AsDouble);
S(open_url_modifiers, convert_mods); S(open_url_modifiers, convert_mods);
S(rectangle_select_modifiers, convert_mods); S(rectangle_select_modifiers, convert_mods);
S(terminal_select_modifiers, convert_mods);
S(click_interval, PyFloat_AsDouble); S(click_interval, PyFloat_AsDouble);
S(resize_debounce_time, PyFloat_AsDouble); S(resize_debounce_time, PyFloat_AsDouble);
S(url_color, color_as_int); S(url_color, color_as_int);

View File

@ -19,6 +19,7 @@ typedef struct {
CursorShape cursor_shape; CursorShape cursor_shape;
unsigned int open_url_modifiers; unsigned int open_url_modifiers;
unsigned int rectangle_select_modifiers; unsigned int rectangle_select_modifiers;
unsigned int terminal_select_modifiers;
unsigned int url_style; unsigned int url_style;
unsigned int scrollback_pager_history_size; unsigned int scrollback_pager_history_size;
char_type select_by_word_characters[256]; size_t select_by_word_characters_count; char_type select_by_word_characters[256]; size_t select_by_word_characters_count;