Splits layout: Allow setting the bias of the current split using layout_action bias

Fixes #8222
This commit is contained in:
Kovid Goyal
2025-01-17 08:37:07 +05:30
parent 0ecbc2b786
commit c600451bb8
3 changed files with 25 additions and 0 deletions

View File

@@ -84,6 +84,12 @@ consumption to do the same tasks.
Detailed list of changes
-------------------------------------
0.39.1 [future]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Splits layout: Allow setting the bias of the current split using ``layout_action bias`` (:iss:`8222`)
0.39.0 [2025-01-16]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -179,6 +179,12 @@ define a few extra key bindings in :file:`kitty.conf`::
map ctrl+up neighboring_window up
map ctrl+down neighboring_window down
# Set the bias of the split containing the currently focused window. The
# currently focused window will take up the specified percent of its parent
# window's size.
map ctrl+. layout_action bias 80
Windows can be resized using :ref:`window_resizing`. You can swap the windows
in a split using the ``rotate`` action with an argument of ``180`` and rotate
and swap with an argument of ``270``.

View File

@@ -288,6 +288,10 @@ class Pair:
geom = window_geometry_from_layouts(xl, yl)
self.apply_window_geometry(self.two, geom, id_window_map, layout_object)
def set_bias(self, window_id: int, bias: int) -> None:
b = max(0, min(bias, 100)) / 100
self.bias = b if window_id == self.one else (1. - b)
def modify_size_of_child(self, which: int, increment: float, is_horizontal: bool, layout_object: 'Splits') -> bool:
if is_horizontal == self.horizontal and not self.is_redundant:
if which == 2:
@@ -642,6 +646,15 @@ class Splits(Layout):
new_root.two = wg.id
self.pairs_root = new_root
return True
elif action_name == 'bias':
args = args or ('50',)
bias = int(args[0])
wg = all_windows.active_group
if wg is not None:
pair = self.pairs_root.pair_for_window(wg.id)
if pair is not None:
pair.set_bias(wg.id, bias)
return True
return None