Splits layout: A new value for :option:launch --location to auto-select the split axis when splitting existing windows.

This commit is contained in:
Kovid Goyal 2022-02-22 22:36:50 +05:30
parent 7a2a849a97
commit 31a5965b01
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 24 additions and 12 deletions

View File

@ -87,6 +87,9 @@ Detailed list of changes
- macOS: Add a new service ``Open with kitty`` to open file types that are not
recognized by the system (:pull:`4641`)
- Splits layout: A new value for :option:`launch --location` to auto-select the split axis when splitting existing windows.
Wide windows are split side-by-side and tall windows are split one-above-the-other
- Fix a regression in the previous release that broke :opt:`active_tab_foreground` (:iss:`4620`)
- Fix :ac:`show_last_command_output` not working when the output is stored

View File

@ -138,6 +138,11 @@ define a few extra key bindings in :file:`kitty.conf`::
# the two windows are placed side by side
map F6 launch --location=vsplit
# Create a new window splitting the space used by the existing one so that
# the two windows are placed side by side if the existing window is wide or
# one above the other if the existing window is tall.
map F4 launch --location=split
# Rotate the current split, chaging its split axis from vertical to
# horizontal or vice versa
map F7 layout_action rotate

View File

@ -102,16 +102,17 @@ kitty remote control feature with :code:`kitty @launch --copy-env`.
--location
type=choices
default=default
choices=first,after,before,neighbor,last,vsplit,hsplit,default
choices=first,after,before,neighbor,last,vsplit,hsplit,split,default
Where to place the newly created window when it is added to a tab which
already has existing windows in it. :code:`after` and :code:`before` place the new
window before or after the active window. :code:`neighbor` is a synonym for :code:`after`.
Also applies to creating a new tab, where the value of :code:`after`
will cause the new tab to be placed next to the current tab instead of at the end.
The values of :code:`vsplit` and :code:`hsplit` are only used by the :code:`splits`
layout and control if the new window is placed in a vertical or horizontal split
with the currently active window. The default is to place the window in a
layout dependent manner, typically, after the currently active window.
The values of :code:`vsplit`, :code:`hsplit` and :code:`split` are only used by the
:code:`splits` layout and control if the new window is placed in a vertical,
horizontal or automatic split with the currently active window. The default is
to place the window in a layout dependent manner, typically, after the
currently active window.
--allow-remote-control

View File

@ -450,12 +450,11 @@ class Splits(Layout):
) -> None:
horizontal = self.default_axis_is_horizontal
after = True
if location is not None:
if location == 'vsplit':
horizontal = True
elif location == 'hsplit':
horizontal = False
if location in ('before', 'first'):
elif location in ('before', 'first'):
after = False
aw = all_windows.active_window
if aw is not None:
@ -464,6 +463,10 @@ class Splits(Layout):
group_id = ag.id
pair = self.pairs_root.pair_for_window(group_id)
if pair is not None:
if location == 'split':
wwidth = aw.geometry.right - aw.geometry.left
wheight = aw.geometry.bottom - aw.geometry.top
horizontal = wwidth >= wheight
target_group = all_windows.add_window(window, next_to=aw, before=not after)
pair.split_and_add(group_id, target_group.id, horizontal, after)
return