diff --git a/README.asciidoc b/README.asciidoc index 2935c9191..33d226757 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -347,11 +347,12 @@ you want to enable/disable, see link:kitty/kitty.conf[kitty.conf] for examples. You can resize windows inside layouts. Press {sc_start_resizing_window} to enter resizing mode. Then use the `W/N` (Wider/Narrower) and `T/S` (Taller/Shorter) keys to change the window size. Press the `0` key to rest the -layout to default sizes. Any other key will exit resize mode. In a given -window layout only some operations may be possible for a particular window. For -example, in the Tall layout you can make the first window wider/narrower, but -not taller/shorter. Note that what you are resizing is actually not a window, -but a row/column in the layout, all windows in that row/column will be resized. +layout to default sizes. Press the `Ctrl` modifier to double the step size. Any +other key will exit resize mode. In a given window layout only some operations +may be possible for a particular window. For example, in the Tall layout you +can make the first window wider/narrower, but not taller/shorter. Note that +what you are resizing is actually not a window, but a row/column in the layout, +all windows in that row/column will be resized. Some layouts take options to control their behavior. For example, the `fat` and `tall` layouts accept the `bias` option to control how the available space is split up. To specify the diff --git a/kitty/boss.py b/kitty/boss.py index 1dfce4b59..4543023ac 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -19,8 +19,8 @@ from .constants import ( appname, config_dir, editor, set_boss, supports_primary_selection ) from .fast_data_types import ( - GLFW_KEY_0, GLFW_KEY_W, GLFW_KEY_N, GLFW_KEY_S, ChildMonitor, - create_os_window, current_os_window, destroy_global_data, + GLFW_KEY_0, GLFW_KEY_N, GLFW_KEY_S, GLFW_KEY_W, GLFW_MOD_CONTROL, + ChildMonitor, create_os_window, current_os_window, destroy_global_data, destroy_sprite_map, get_clipboard_string, glfw_post_empty_event, layout_sprite_map, mark_os_window_for_close, set_clipboard_string, set_dpi_from_os_window, set_in_sequence_mode, show_window, @@ -425,7 +425,9 @@ class Boss: tab.reset_window_sizes() return is_horizontal = key in (GLFW_KEY_W, GLFW_KEY_N) - increment = 0.05 + increment = self.opts.window_resize_step_cells if is_horizontal else self.opts.window_resize_step_lines + if mods == GLFW_MOD_CONTROL: + increment *= 2 if key in (GLFW_KEY_N, GLFW_KEY_S): increment *= -1 tab.resize_window_by(window_id, increment, is_horizontal) diff --git a/kitty/config.py b/kitty/config.py index e1241047b..90ddc9460 100644 --- a/kitty/config.py +++ b/kitty/config.py @@ -366,6 +366,8 @@ type_map = { 'kitty_mod': to_modifiers, 'clear_all_shortcuts': to_bool, 'clipboard_control': lambda x: frozenset(x.lower().split()), + 'window_resize_step_cells': int, + 'window_resize_step_lines': int, } for name in ( diff --git a/kitty/keys.c b/kitty/keys.c index b050048f1..36f821a6d 100644 --- a/kitty/keys.c +++ b/kitty/keys.c @@ -88,6 +88,7 @@ handle_resize_key(int key, int action, int mods) { call_boss(handle_resize_keypress, "iiKKK", key, mods, global_state.currently_resizing.os_window_id, global_state.currently_resizing.tab_id, global_state.currently_resizing.window_id); return true; } + if (key == GLFW_KEY_LEFT_CONTROL || key == GLFW_KEY_RIGHT_CONTROL) return true; return false; } diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 9df2db270..ef0139ecf 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -192,6 +192,12 @@ initial_window_height 400 # For a list of available layouts, see the README. enabled_layouts * +# The step size (in units of cell width/cell height) to use when resizing +# windows. The cells value is used for horizontal resizing and the lines value +# for vertical resizing. +window_resize_step_cells 2 +window_resize_step_lines 2 + # The width (in pts) of window borders. Will be rounded to the nearest number of pixels based on screen resolution. # Note that borders are displayed only when more than one window is visible. They are meant to separate multiple windows. window_border_width 1 diff --git a/kitty/layout.py b/kitty/layout.py index 033b23c9c..35508ca58 100644 --- a/kitty/layout.py +++ b/kitty/layout.py @@ -102,7 +102,13 @@ class Layout: def initialize_sub_class(self): pass - def apply_bias(self, idx, increment, num_windows, is_horizontal): + def bias_increment_for_cell(self, is_horizontal): + self._set_dimensions() + if is_horizontal: + return (cell_width + 1) / central.width + return (cell_height + 1) / central.height + + def apply_bias(self, idx, increment_as_percent, num_windows, is_horizontal): return False def remove_all_biases(self): @@ -235,10 +241,12 @@ class Layout: self.set_active_window_in_os_window(active_window_idx) return active_window_idx - def __call__(self, all_windows, active_window_idx): + def _set_dimensions(self): global central, cell_width, cell_height central, tab_bar, vw, vh, cell_width, cell_height = viewport_for_window(self.os_window_id) + def __call__(self, all_windows, active_window_idx): + self._set_dimensions() active_window = all_windows[active_window_idx] overlaid_windows, windows = process_overlaid_windows(all_windows) if overlaid_windows: diff --git a/kitty/tabs.py b/kitty/tabs.py index df47d79e3..becd60aab 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -164,7 +164,8 @@ class Tab: # {{{ self.relayout() def resize_window_by(self, window_id, increment, is_horizontal): - if self.current_layout.modify_size_of_window(self.windows, window_id, increment, is_horizontal): + increment_as_percent = self.current_layout.bias_increment_for_cell(is_horizontal) * increment + if self.current_layout.modify_size_of_window(self.windows, window_id, increment_as_percent, is_horizontal): self.relayout() else: ring_bell(self.os_window_id)