mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-08-16 18:10:32 +03:00
Make the resize step size configurable
This commit is contained in:
parent
cddfe425e1
commit
190612d507
@ -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
|
||||
|
@ -19,8 +19,8 @@
|
||||
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 @@ def handle_resize_keypress(self, key, mods, os_window_id, tab_id, window_id):
|
||||
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)
|
||||
|
@ -366,6 +366,8 @@ def url_style(x):
|
||||
'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 (
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -102,7 +102,13 @@ def __init__(self, os_window_id, tab_id, margin_width, padding_width, border_wid
|
||||
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 @@ def set_active_window(self, all_windows, active_window_idx):
|
||||
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:
|
||||
|
@ -164,7 +164,8 @@ def goto_layout(self, layout_name):
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user