Commit graph

40 commits

Author SHA1 Message Date
白鸽
2faf4b051c Splits: Resize adjacent regions consistently when dragging dividers 2026-09-22 17:09:21 +08:00
Kovid Goyal
65b02b21f4
Splits: Fix issues with proportional sizing
Fixes found while reviewing #10471:

- A window squeezed to zero size (by maximize or an extreme bias) was
  indistinguishable from a removed one, so closing an unrelated window
  handed its share to windows in sub-trees that lost nothing. Track
  survivors separately from the numeric weight.

- Pruning a batch of windows gave a different layout than closing them
  one by one, since a perpendicular sub-tree stops being perpendicular
  once removals collapse it. Apply the policy one window at a time.

- Windows reconciled by do_layout(), rather than split off an existing
  window, bypassed the policy entirely. Route them through it too.

Also fix two pre-existing bugs on the same code paths:

- collapse_redundant_pairs() collapsed top down, so a pair whose
  children only became empty during the recursion was never
  re-examined and was left in the tree, consuming its share of the
  space.

- do_layout() kept using a stale pairs root when removing windows
  collapsed the tree, so windows added in the same relayout were
  attached to the discarded root and vanished for a frame.
2026-09-16 10:47:59 +05:30
Kovid Goyal
791614ce93 Merge branch 'splits-proportional' of https://github.com/xiaobai050/kitty
# Conflicts:
#	kitty_tests/layout.py
2026-09-16 09:23:31 +05:30
白鸽
82085561a0 Splits: Preserve perpendicular shares on batch removal 2026-09-14 20:07:57 +08:00
白鸽
cced6bb355 Splits: Add optional proportional sizing 2026-09-14 19:17:53 +08:00
白鸽
d3d3f1735d Splits: Resize the correct divider in nested layouts 2026-09-14 19:17:51 +08:00
NightWatcher
376e72ded8 Add configurable rounded window borders 2026-08-29 22:30:04 +08:00
Kovid Goyal
cb4cefee5a
misc layout code robustness fixes 2026-08-05 21:04:30 +05:30
Chance Zibolski
1b81045008 Save the layout state of every layout a tab has used to sessions
save_as_session recorded only the state of the tab's active layout, so the state
of any layout the tab had been toggled away from was lost. Toggling a splits tab
to the stack layout and saving discarded the splits tree entirely, because Stack
has no layout_state() of its own, and switching back to splits after restoring
rebuilt the tree from scratch along the default axis.

The session file also carried no last_used_layout, so _last_used_layout was None
after a restore and toggle_layout <current layout> silently did nothing, since it
delegates to last_used_layout() which returns early when unset. The key that
produced the stack layout no longer undid it.

Tab now keeps the layouts it has used, by name, and writes their state plus
last_used_layout into the existing set_layout_state JSON rather than adding new
session commands. Older versions of kitty ignore unknown keys in that dict but
abort on unknown commands, so nesting keeps session files readable by them.

Restoring the state of a layout that is not being made current must not reorder
the window list, since only the current layout determines window order, hence
apply_to_window_list. Splits.set_layout_state also has to accept state for a
layout whose tree is still empty, which is the case for a layout that has not
laid out any windows yet.

Fixes #10320
2026-08-05 07:53:47 -07:00
Kovid Goyal
7f0b072f0d
autoformat 2026-08-05 05:32:56 +05:30
copilot-swe-agent[bot]
a31f9e52f2
Refactor kitty_tests: move __init__.py code to base.py, update all imports 2026-08-05 05:32:54 +05:30
Kovid Goyal
11c2ccf00f
Add tests for splits layout serialization 2026-06-10 07:41:02 +05:30
Mark Stuart
852fc4a662 Add equalize action and equalize_on_close option to Splits layout
Adds an `equalize` layout action that redistributes split sizes so each
window receives a proportional share of space along each axis.

Also adds an `equalize_on_close` layout option that automatically
equalizes splits whenever a window is closed, keeping the remaining
windows balanced without requiring an explicit key binding.

These two features compose well. For example, to keep splits balanced
at all times - equalizing on every open and close:

    enabled_layouts splits:equalize_on_close=true
    map ctrl+' combine : launch --location=hsplit --cwd=current : layout_action equalize
    map ctrl+/ combine : launch --location=vsplit --cwd=current : layout_action equalize

A standalone key binding for manual rebalancing is also supported:

    map ctrl+shift+e layout_action equalize
2026-05-29 20:02:42 +01:00
copilot-swe-agent[bot]
4d55d30614
Enhance regression test with additional geometry validity assertions
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/3b0c9eab-24ba-4934-a941-be477477cee4

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-05-01 15:05:34 +00:00
copilot-swe-agent[bot]
20185fc317
Fix display corruption when maximizing horizontal split with window_padding_width >= 4 (issue #9946)
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/3b0c9eab-24ba-4934-a941-be477477cee4

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-05-01 15:04:46 +00:00
Kovid Goyal
e9dcc4393f
... 2026-04-19 21:05:14 +05:30
copilot-swe-agent[bot]
96d10e51a0
Fix drag resize direction bugs and add comprehensive tests
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/12198e55-3901-439b-9fba-9b5f5b470416

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-01 03:48:49 +00:00
copilot-swe-agent[bot]
551acca0e4
Implement maximize layout action for splits layout
Fixes #9629
Fixes #9630
2026-03-09 15:27:54 +05:30
Kovid Goyal
e49d940621
kitten @ ls: Also output the neighbors for every window 2025-11-16 21:01:55 +05:30
Kovid Goyal
26ea343f95
Fix failing tests 2025-10-22 13:21:53 +05:30
Jackie Li
6a2ee9253b
set_options() in layout tests 2025-10-14 19:43:07 +01:00
Kovid Goyal
e6c1597834
Start work on multiple hardware cursors 2025-08-24 20:14:14 +05:30
Kovid Goyal
77292a16d6
Make shebangs consistent
Follow PEP 0394 and use /usr/bin/env python so that the python in the
users venv is respected. Not that the kitty python files are meant to be
executed standalone anyway, but, whatever.

Fixes #6810
2023-11-11 08:32:05 +05:30
Kovid Goyal
4b997a961c
A new option single_window_padding_width to use a different padding when only a single window is visible
Fixes #6734
2023-10-20 08:37:45 +05:30
Kovid Goyal
7fe5d7b58f
Replace isort with ruff 2023-01-09 16:47:42 +05:30
Kovid Goyal
6546c1da9b
run pyupgrade to upgrade the codebase to python3.6 2021-10-21 12:43:55 +05:30
Kovid Goyal
0163bf3edb
Fix enter/tab/backspace not being reported in all keys mode 2021-01-16 20:52:15 +05:30
Juho Peltonen
1decae2938 Change splits layout neighbors to only include real neighbors 2020-07-11 21:35:29 +03:00
Kovid Goyal
cdd943ded4
Port layout tests to new API 2020-05-12 22:43:55 +05:30
Kovid Goyal
c69b8870d2
Allow individually setting margins and padding for each edge (left, right, top, bottom) 2020-04-19 09:36:26 +05:30
Kovid Goyal
a08efa1fc5
Fix failing test 2020-04-17 19:57:37 +05:30
Kovid Goyal
917559f883
more typing work 2020-03-13 16:13:26 +05:30
Kovid Goyal
86174c81c8
Some tests for splits layout 2020-01-30 20:30:52 +05:30
Kovid Goyal
2f7bdc274d
Fix failing test 2020-01-15 11:48:13 +05:30
Kovid Goyal
e8121b39ec
Add newer layout classes to tests 2020-01-15 08:14:45 +05:30
Luflosi
a792c94ccf
Use python3 shebang for all python scripts
Fixes #1624.
Use python3 shebang for all python scripts as python still defaults to python2 on many systems.
2019-05-20 14:44:24 +02:00
Kovid Goyal
e35c3cc913
Add an option single_window_margin_width to allow different margins when only a single window is visible in the layout
Fixes #688
2018-06-29 09:56:05 +05:30
Kovid Goyal
22159c5eb4
Fix mockup for testing 2018-05-16 16:43:39 +05:30
Kovid Goyal
647b95631f
Add tests for layout operations with an overlay window 2018-02-04 11:28:13 +05:30
Kovid Goyal
aa518b2520
Add tests for basic layout operations 2018-02-04 11:28:13 +05:30