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
|
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`
|
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
|
(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
|
layout to default sizes. Press the `Ctrl` modifier to double the step size. Any
|
||||||
window layout only some operations may be possible for a particular window. For
|
other key will exit resize mode. In a given window layout only some operations
|
||||||
example, in the Tall layout you can make the first window wider/narrower, but
|
may be possible for a particular window. For example, in the Tall layout you
|
||||||
not taller/shorter. Note that what you are resizing is actually not a window,
|
can make the first window wider/narrower, but not taller/shorter. Note that
|
||||||
but a row/column in the layout, all windows in that row/column will be resized.
|
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`
|
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
|
layouts accept the `bias` option to control how the available space is split up. To specify the
|
||||||
|
|||||||
@ -19,8 +19,8 @@ from .constants import (
|
|||||||
appname, config_dir, editor, set_boss, supports_primary_selection
|
appname, config_dir, editor, set_boss, supports_primary_selection
|
||||||
)
|
)
|
||||||
from .fast_data_types import (
|
from .fast_data_types import (
|
||||||
GLFW_KEY_0, GLFW_KEY_W, GLFW_KEY_N, GLFW_KEY_S, ChildMonitor,
|
GLFW_KEY_0, GLFW_KEY_N, GLFW_KEY_S, GLFW_KEY_W, GLFW_MOD_CONTROL,
|
||||||
create_os_window, current_os_window, destroy_global_data,
|
ChildMonitor, create_os_window, current_os_window, destroy_global_data,
|
||||||
destroy_sprite_map, get_clipboard_string, glfw_post_empty_event,
|
destroy_sprite_map, get_clipboard_string, glfw_post_empty_event,
|
||||||
layout_sprite_map, mark_os_window_for_close, set_clipboard_string,
|
layout_sprite_map, mark_os_window_for_close, set_clipboard_string,
|
||||||
set_dpi_from_os_window, set_in_sequence_mode, show_window,
|
set_dpi_from_os_window, set_in_sequence_mode, show_window,
|
||||||
@ -425,7 +425,9 @@ class Boss:
|
|||||||
tab.reset_window_sizes()
|
tab.reset_window_sizes()
|
||||||
return
|
return
|
||||||
is_horizontal = key in (GLFW_KEY_W, GLFW_KEY_N)
|
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):
|
if key in (GLFW_KEY_N, GLFW_KEY_S):
|
||||||
increment *= -1
|
increment *= -1
|
||||||
tab.resize_window_by(window_id, increment, is_horizontal)
|
tab.resize_window_by(window_id, increment, is_horizontal)
|
||||||
|
|||||||
@ -366,6 +366,8 @@ type_map = {
|
|||||||
'kitty_mod': to_modifiers,
|
'kitty_mod': to_modifiers,
|
||||||
'clear_all_shortcuts': to_bool,
|
'clear_all_shortcuts': to_bool,
|
||||||
'clipboard_control': lambda x: frozenset(x.lower().split()),
|
'clipboard_control': lambda x: frozenset(x.lower().split()),
|
||||||
|
'window_resize_step_cells': int,
|
||||||
|
'window_resize_step_lines': int,
|
||||||
}
|
}
|
||||||
|
|
||||||
for name in (
|
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);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (key == GLFW_KEY_LEFT_CONTROL || key == GLFW_KEY_RIGHT_CONTROL) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -192,6 +192,12 @@ initial_window_height 400
|
|||||||
# For a list of available layouts, see the README.
|
# For a list of available layouts, see the README.
|
||||||
enabled_layouts *
|
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.
|
# 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.
|
# Note that borders are displayed only when more than one window is visible. They are meant to separate multiple windows.
|
||||||
window_border_width 1
|
window_border_width 1
|
||||||
|
|||||||
@ -102,7 +102,13 @@ class Layout:
|
|||||||
def initialize_sub_class(self):
|
def initialize_sub_class(self):
|
||||||
pass
|
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
|
return False
|
||||||
|
|
||||||
def remove_all_biases(self):
|
def remove_all_biases(self):
|
||||||
@ -235,10 +241,12 @@ class Layout:
|
|||||||
self.set_active_window_in_os_window(active_window_idx)
|
self.set_active_window_in_os_window(active_window_idx)
|
||||||
return 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
|
global central, cell_width, cell_height
|
||||||
central, tab_bar, vw, vh, cell_width, cell_height = viewport_for_window(self.os_window_id)
|
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]
|
active_window = all_windows[active_window_idx]
|
||||||
overlaid_windows, windows = process_overlaid_windows(all_windows)
|
overlaid_windows, windows = process_overlaid_windows(all_windows)
|
||||||
if overlaid_windows:
|
if overlaid_windows:
|
||||||
|
|||||||
@ -164,7 +164,8 @@ class Tab: # {{{
|
|||||||
self.relayout()
|
self.relayout()
|
||||||
|
|
||||||
def resize_window_by(self, window_id, increment, is_horizontal):
|
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()
|
self.relayout()
|
||||||
else:
|
else:
|
||||||
ring_bell(self.os_window_id)
|
ring_bell(self.os_window_id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user