From 60e17d5224db21cf4a25f566c25d33a282b3b8f4 Mon Sep 17 00:00:00 2001 From: Jo De Boeck Date: Sun, 24 Dec 2017 18:40:25 +0200 Subject: [PATCH] Make it possible to modify rectangle selection modifiers Signed-off-by: Jo De Boeck --- kitty/config.py | 5 +++-- kitty/kitty.conf | 3 +++ kitty/mouse.c | 2 +- kitty/state.c | 1 + kitty/state.h | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/kitty/config.py b/kitty/config.py index 8e427f399..8e4e2a301 100644 --- a/kitty/config.py +++ b/kitty/config.py @@ -195,7 +195,7 @@ def parse_send_text(val, keymap): return parse_key(key_str, keymap) -def to_open_url_modifiers(val): +def to_modifiers(val): return parse_mods(val.split('+')) @@ -264,7 +264,8 @@ type_map = { 'font_size_delta': positive_float, 'focus_follows_mouse': to_bool, 'cursor_shape': to_cursor_shape, - 'open_url_modifiers': to_open_url_modifiers, + 'open_url_modifiers': to_modifiers, + 'rectangle_select_modifiers': to_modifiers, 'repaint_delay': positive_int, 'input_delay': positive_int, 'window_border_width': positive_float, diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 8d86ed5e7..998aa12ea 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -66,6 +66,9 @@ selection_background #FFFACD url_color #0087BD url_style curly +# The modifiers to use rectangle selection +rectangle_select_modifiers ctrl+alt + # The cursor color cursor #cccccc diff --git a/kitty/mouse.c b/kitty/mouse.c index 25f51d8c9..a48748c6a 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -111,7 +111,7 @@ update_drag(bool from_button, Window *w, bool is_release, int modifiers) { Screen *screen = w->render_data.screen; if (from_button) { if (is_release) screen_update_selection(screen, w->mouse_cell_x, w->mouse_cell_y, true); - else screen_start_selection(screen, w->mouse_cell_x, w->mouse_cell_y, modifiers == (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); + else screen_start_selection(screen, w->mouse_cell_x, w->mouse_cell_y, modifiers == (int)OPT(rectangle_select_modifiers)); } else if (screen->selection.in_progress) { screen_update_selection(screen, w->mouse_cell_x, w->mouse_cell_y, false); call_boss(set_primary_selection, NULL); diff --git a/kitty/state.c b/kitty/state.c index 52d272ae6..9ca2001a1 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -317,6 +317,7 @@ PYWRAP1(set_options) { S(mouse_hide_wait, PyFloat_AsDouble); S(wheel_scroll_multiplier, PyFloat_AsDouble); S(open_url_modifiers, PyLong_AsUnsignedLong); + S(rectangle_select_modifiers, PyLong_AsUnsignedLong); S(click_interval, PyFloat_AsDouble); S(url_color, color_as_int); S(background, color_as_int); diff --git a/kitty/state.h b/kitty/state.h index ac2ce6a5c..28bac6d4d 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -15,6 +15,7 @@ typedef struct { bool enable_audio_bell; CursorShape cursor_shape; unsigned int open_url_modifiers; + unsigned int rectangle_select_modifiers; unsigned int url_style; char_type select_by_word_characters[256]; size_t select_by_word_characters_count; color_type url_color, background;