From 1e172caea3c250b51f1e9ac02ab86bf789012c89 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 3 Jul 2019 10:50:07 +0530 Subject: [PATCH] - Add an option :opt:`terminal_select_modifiers` to control which modifiers are used to override mouse selection Fixes #1774 --- docs/changelog.rst | 9 ++++++--- kitty/config_data.py | 3 +++ kitty/mouse.c | 6 +++--- kitty/state.c | 1 + kitty/state.h | 1 + 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 97a78e9c0..7c296799c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -12,11 +12,11 @@ To update |kitty|, :doc:`follow the instructions `. - Allow passing a ``!neighbor`` argument to the new_window mapping to open a 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`) +- 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 to block the UI (:iss:`1708`) @@ -35,6 +35,9 @@ To update |kitty|, :doc:`follow the instructions `. - macOS: Fix finding fallback font for private use unicode symbols not working 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] --------------------- diff --git a/kitty/config_data.py b/kitty/config_data.py index 1720c8bd1..18c692b56 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -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 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=_(''' 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 diff --git a/kitty/mouse.c b/kitty/mouse.c index f6781445d..c6eb8704a 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -170,7 +170,7 @@ update_drag(bool from_button, Window *w, bool is_release, int modifiers) { } else { 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) { 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 = ( (screen->modes.mouse_tracking_mode == ANY_MODE || (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; if (handle_in_kitty) { if (screen->selection.in_progress && button == GLFW_MOUSE_BUTTON_LEFT) { @@ -378,7 +378,7 @@ HANDLER(handle_button_event) { Screen *screen = w->render_data.screen; if (!screen) return; 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 || button == GLFW_MOUSE_BUTTON_MIDDLE || (modifiers == (int)OPT(open_url_modifiers) && button == GLFW_MOUSE_BUTTON_LEFT) diff --git a/kitty/state.c b/kitty/state.c index 31e815628..83e6d5e87 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -384,6 +384,7 @@ PYWRAP1(set_options) { S(touch_scroll_multiplier, PyFloat_AsDouble); S(open_url_modifiers, convert_mods); S(rectangle_select_modifiers, convert_mods); + S(terminal_select_modifiers, convert_mods); S(click_interval, PyFloat_AsDouble); S(resize_debounce_time, PyFloat_AsDouble); S(url_color, color_as_int); diff --git a/kitty/state.h b/kitty/state.h index 617fc36c6..6e992b859 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -19,6 +19,7 @@ typedef struct { CursorShape cursor_shape; unsigned int open_url_modifiers; unsigned int rectangle_select_modifiers; + unsigned int terminal_select_modifiers; unsigned int url_style; unsigned int scrollback_pager_history_size; char_type select_by_word_characters[256]; size_t select_by_word_characters_count;