Skip to content

[v0.4] Add split window layout tree #31

Description

@owainlewis

Goal: Add split-screen editing with a small owned layout tree.

Context: Cortex should support the Emacs-shaped split workflow before the embedded terminal pane.
Splits should show buffers in separate windows with independent point and scroll where needed.
This is the big visual/workflow step, so it should build on the buffer-list work rather than inventing a second model.

Proposed approach:

  • Introduce a window/layout tree with internal split nodes and leaf editor windows.
  • Each leaf window references a buffer and owns its own view state.
  • Render each leaf into its own rectangle through the existing renderer boundary.
  • Add commands for split-window-below, split-window-right, delete-window, delete-other-windows, and other-window.
  • Bind C-x 2, C-x 3, C-x 0, C-x 1, and C-x o.
  • Keep modeline/status treatment clear for focused and unfocused windows.
  • Preserve cursor placement in the focused window.

Acceptance criteria:

  • C-x 2 creates a horizontal split below the current window.
  • C-x 3 creates a vertical split to the right of the current window.
  • C-x o moves focus between windows.
  • C-x 0 deletes the focused window when more than one window exists.
  • C-x 1 deletes other windows and keeps the focused window.
  • Each window keeps its own point and scroll state.
  • Saving saves the buffer shown in the focused window.
  • Small terminal sizes and long lines do not panic.
  • Existing single-window behavior still works.

Verification:

  • Run cargo test.
  • Manually split vertically and horizontally, move focus, edit, save, close splits, and quit.
  • Manually check small terminal sizes if practical.
  • Manually confirm terminal cleanup after exit.

Out of scope:

  • Tabs.
  • Embedded terminal panes.
  • Arbitrary resize commands.
  • Mouse support.
  • Dragging split dividers.
  • Tree or sidebar UI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfactory-readyClear, focused, unblocked work an agent may implement

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions