mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 09:15:57 +02:00
Splits layout: Allow setting the split_axis option to auto so that all new windows have their split axis chosen automatically unless explicitly specified in the launch command
Fixes #7887
This commit is contained in:
@@ -93,6 +93,8 @@ Detailed list of changes
|
||||
|
||||
- Remote control: Fix ``--match state:self`` not working (:disc:`7886`)
|
||||
|
||||
- Splits layout: Allow setting the ``split_axis`` option to ``auto`` so that all new windows have their split axis chosen automatically unless explicitly specified in the launch command (:iss:`7887`)
|
||||
|
||||
0.36.2 [2024-09-06]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -184,11 +184,13 @@ in a split using the ``rotate`` action with an argument of ``180`` and rotate
|
||||
and swap with an argument of ``270``.
|
||||
|
||||
This layout takes one option, ``split_axis`` that controls whether new windows
|
||||
are placed into vertical or horizontal splits when a :option:`--location <launch
|
||||
--location>` is not specified. A value of ``horizontal`` (same as
|
||||
``--location=vsplit``) means when a new split is created the two windows will be
|
||||
placed side by side and a value of ``vertical`` (same as ``--location=hsplit``)
|
||||
means the two windows will be placed one on top of the other. By default::
|
||||
are placed into vertical or horizontal splits when a :option:`--location
|
||||
<launch --location>` is not specified. A value of ``horizontal`` (same as
|
||||
``--location=vsplit``) means when a new split is created the two windows will
|
||||
be placed side by side and a value of ``vertical`` (same as
|
||||
``--location=hsplit``) means the two windows will be placed one on top of the
|
||||
other. A value of ``auto`` means the axis of the split is chosen automatically
|
||||
(same as ``--location=split``). By default::
|
||||
|
||||
enabled_layouts splits:split_axis=horizontal
|
||||
|
||||
|
||||
@@ -423,10 +423,14 @@ class Pair:
|
||||
|
||||
class SplitsLayoutOpts(LayoutOpts):
|
||||
|
||||
default_axis_is_horizontal: bool = True
|
||||
default_axis_is_horizontal: bool | None = True
|
||||
|
||||
def __init__(self, data: Dict[str, str]):
|
||||
self.default_axis_is_horizontal = data.get('split_axis', 'horizontal') == 'horizontal'
|
||||
q = data.get('split_axis', 'horizontal')
|
||||
if q == 'auto':
|
||||
self.default_axis_is_horizontal = None
|
||||
else:
|
||||
self.default_axis_is_horizontal = q == 'horizontal'
|
||||
|
||||
def serialized(self) -> Dict[str, Any]:
|
||||
return {'default_axis_is_horizontal': self.default_axis_is_horizontal}
|
||||
@@ -439,14 +443,17 @@ class Splits(Layout):
|
||||
no_minimal_window_borders = True
|
||||
|
||||
@property
|
||||
def default_axis_is_horizontal(self) -> bool:
|
||||
def default_axis_is_horizontal(self) -> bool | None:
|
||||
return self.layout_opts.default_axis_is_horizontal
|
||||
|
||||
@property
|
||||
def pairs_root(self) -> Pair:
|
||||
root: Optional[Pair] = getattr(self, '_pairs_root', None)
|
||||
if root is None:
|
||||
self._pairs_root = root = Pair(horizontal=self.default_axis_is_horizontal)
|
||||
horizontal = self.default_axis_is_horizontal
|
||||
if horizontal is None:
|
||||
horizontal = True
|
||||
self._pairs_root = root = Pair(horizontal=horizontal)
|
||||
return root
|
||||
|
||||
@pairs_root.setter
|
||||
@@ -508,7 +515,7 @@ class Splits(Layout):
|
||||
group_id = ag.id
|
||||
pair = self.pairs_root.pair_for_window(group_id)
|
||||
if pair is not None:
|
||||
if location == 'split':
|
||||
if location == 'split' or horizontal is None:
|
||||
wwidth = aw.geometry.right - aw.geometry.left
|
||||
wheight = aw.geometry.bottom - aw.geometry.top
|
||||
horizontal = wwidth >= wheight
|
||||
|
||||
Reference in New Issue
Block a user