30 Commits

Author SHA1 Message Date
Kovid Goyal
3d369f8632 Cleanup handling of drag_overlay_mode 2026-03-28 13:26:56 +05:30
mcrmck
d1b8df6975 Fix mypy error: remove narrowing ClassVar[Literal] annotations from layout subclasses
Horizontal extends Vertical, and Fat extends Tall. Declaring
drag_overlay_mode with a narrower Literal type in the subclass
conflicts with the parent's declared type, causing mypy error
"Incompatible types in assignment". Since the base Layout class already
declares the full union type, subclasses only need a bare assignment.

Also removes now-unused ClassVar and Literal imports from vertical.py,
tall.py, and grid.py.
2026-03-27 02:17:59 -04:00
mcrmck
a368a90e37 Add directional drag-and-drop inserts for Vertical, Horizontal, Tall, Fat, Grid
Previously, body drops in all non-Splits layouts showed a full-window overlay
and performed a positional swap. This adds proper top/bottom or left/right
half-window overlays and true before/after insertion for the five layouts
Kovid identified.

Architecture:

- New `drag_overlay_mode` ClassVar on Layout ('full'|'axis_y'|'axis_x'|'free')
  controls both overlay display and valid direction axis. Layout subclasses set
  one line; tabs.py and boss.py dispatch on this attribute instead of hasattr.

- New `insert_window_group_next_to(target_group_id, after)` on WindowList
  performs a positional insert (not swap) by popping the active group and
  inserting it before or after the target.

- New base `insert_window_next_to` on Layout uses insert_window_group_next_to
  for axis_x/axis_y layouts and falls back to swap for 'full' (Stack).
  Splits overrides this with its existing tree-based implementation.

- `_insert_window_in_direction` in boss.py collapses from a 7-line hasattr
  branch to a single layout.insert_window_next_to() call.

Direction constraints:
  Vertical, Tall, Grid -> top/bottom (axis_y)
  Horizontal, Fat      -> left/right (axis_x)
  Splits               -> 4-way free (unchanged)
  Stack                -> full-window swap (unchanged)
2026-03-27 02:08:41 -04:00
Kovid Goyal
ad560715a6 Track border rect orientation explicitly 2026-03-02 21:34:48 +05:30
Kovid Goyal
69b9993804 Fix border directionality in grid layout 2026-03-02 11:28:52 +05:30
Kovid Goyal
6b54c201e5 Track window ids on border rects
More robust. Splits layout still needs work.
2026-03-02 08:31:36 +05:30
Kovid Goyal
e49d940621 kitten @ ls: Also output the neighbors for every window 2025-11-16 21:01:55 +05:30
Kovid Goyal
f925327755 Fix de-serialization of some layouts
Forgot that JSON converts dict keys to strings. Sigh.
2025-08-20 08:10:29 +05:30
Kovid Goyal
1665b06d59 Implement set_layout_state for a few remaining layouts 2025-08-04 16:02:19 +05:30
Kovid Goyal
d548a6fcf4 rename typing module to avoid conflicts with stdlib typing 2025-04-28 09:20:10 +05:30
Kovid Goyal
da1626090a Update codebase to Python 3.10 using pyupgrade 2025-02-03 10:56:50 +05:30
Kovid Goyal
5ab484cac2 Implement --bias for the grid layout 2024-07-20 13:11:06 +05:30
Kovid Goyal
92385f6db7 Make function re-useable and simplify bias docs a bit 2024-07-20 12:44:46 +05:30
Johannes Wüller
7c8660a694 Extend placement_stragegy options
placement_strategy previously only accepted 'center' and 'top-left', but
others are potentially useful too. I personally like 'bottom-left'. The
new set of accepted values mirrors the window_logo_position option.
2024-05-08 16:33:04 +02:00
Kovid Goyal
7fe5d7b58f Replace isort with ruff 2023-01-09 16:47:42 +05:30
Kovid Goyal
2e8ef66496 Another mypy update another round of spurious errors 2022-11-08 17:17:40 +05:30
Kovid Goyal
c40ef01445 Fix resizing window that is extra tall/wide because of left-over cells not working reliably
Fixes #4913
2022-04-08 15:41:53 +05:30
pagedown
f1b6fb397b Remove redundant variable assignment 2022-01-01 21:28:55 +08:00
Kovid Goyal
4494ddd8ff mypy: Turn on return value checks
Its a shame GvR is married to "return None"
https://github.com/python/mypy/issues/7511
2021-10-26 22:39:14 +05:30
Kovid Goyal
6546c1da9b run pyupgrade to upgrade the codebase to python3.6 2021-10-21 12:43:55 +05:30
Kovid Goyal
518057489c Also output layout state in kitty @ ls 2021-04-17 12:11:56 +05:30
Kovid Goyal
027c5a57f1 Work on porting kittens to use new key infrastructure
Also move type definitions into their own module
2021-01-16 20:52:14 +05:30
Kovid Goyal
31d9f663fc Simplify border drawing code 2020-08-30 14:05:43 +05:30
Kovid Goyal
f01c0945da Fix mypy failing 2020-08-29 18:08:32 +05:30
Kovid Goyal
7074f9f776 Grid layout: Improve rendering of borders when using minimal borders 2020-08-29 15:53:14 +05:30
Juho Peltonen
ea30c84240 Fix grid layout neighbors
Grid layout can have multiple neighbors in one side when either current
column or neighboring column is special.
2020-07-11 23:52:37 +03:00
Kovid Goyal
39b2bf963c Port the splits layout to the new groups API 2020-05-12 22:43:54 +05:30
Kovid Goyal
70ccc1cf6d Port Grid layout to new groups API 2020-05-12 22:43:54 +05:30
Kovid Goyal
01c0e8da93 Tall and Fat layouts ported to new groups API 2020-05-12 22:43:54 +05:30
Kovid Goyal
50d9718c68 Start work on refactoring management of windows 2020-05-12 22:43:53 +05:30