Commit Graph

762 Commits

Author SHA1 Message Date
Michael Grant
fbaa3cb565 Merge branch 'master' into 5211-fix-select-layout-list-windows 2026-06-29 19:26:12 +02:00
Michael Grant
64db144425 Update select-layout and list-windows to work with new layouts,
floating panes, and use a more modern serialization format.

  ## Serialization

  layout-custom.c now emits a canonical current format with:

  - Pane syntax: %pane-id,z-index:geometry[:flags]
  - Semicolons between child cells.
  - X-style geometry: WxH+X+Y
  - Every pane represented inside layout_root, including floating panes.
  - No legacy <...> floating-pane wrapper.
  - Z-index serialized for tiled and floating panes.
  - Flags:
      - f: floating
      - h: hidden
      - z: zoomed

  - Hidden panes use their saved restoration geometry.
  - Single-pane windows serialize as a pane root cell.

  window_layout and list-windows continue emitting a four-digit checksum.

  ## Geometry

  Current layouts accept:

  - +N: absolute positive offset
  - ++N: equivalent to +N
  - +-N: absolute negative offset
  - -N: right/bottom-relative offset for floating panes
  - Omitted offsets: +0+0
  - One offset: second defaults to +0

  Relative offsets are resolved immediately. Output always contains canonical absolute
  coordinates.

  Widths and heights are restricted to 1..PANE_MAXIMUM; offsets and resolved offsets are
  restricted to -PANE_MAXIMUM..PANE_MAXIMUM.

  ## Checksums and whitespace

  - The outer checksum is optional on input for current and legacy layouts.
  - If supplied, it must be correct.
  - Output still includes it.
  - Checksums cover all non-whitespace layout text.
  - Whitespace and newlines may be inserted between tokens.
  - Optional nested checksums are accepted and validated but not emitted.

  ## Legacy compatibility

  Legacy comma-separated layouts remain accepted:

  WxH,x,y{cell,cell,...}
  WxH,x,y,pane-id

  Additional compatibility behavior includes:

  - The reported e6db,113x28,... layout works and resizes existing panes correctly.
  - Older inconsistent root dimensions are corrected safely.
  - Legacy layouts with surplus cells continue pruning cells until the target pane count
    matches.

  - Legacy panes remain assigned in tree order.
  - Legacy input is re-emitted in the current canonical format.

  Mixed legacy/current syntax is rejected.

  ## Pane matching and counts

  For current layouts:

  - Pane IDs must be unique.
  - With matching pane counts:
      - An exact ID set maps panes by identity.
      - A completely disjoint ID set maps panes in tree order.
      - A partial ID match is rejected as ambiguous.

  - If the target has fewer panes:
      - Cells are removed from the end of the tree.
      - Remaining z-indexes are compacted while preserving order.
      - Existing panes are assigned in tree order.
      - No panes are killed or created.

  - A target with more panes than layout cells is rejected.

  Layouts are therefore snapshots that rearrange existing panes and windows, not complete
  session-restoration data.

  ## Validation and safety

  Parsing now constructs and validates a temporary tree before replacing the active layout:

  - Maximum input length: 8192 bytes.
  - Maximum nesting depth: 64.
  - Checked signed and unsigned numeric parsing.
  - Dimension and offset bounds.
  - Container size consistency.
  - Exact trailing-input checks.
  - Unique, contiguous z-indexes starting at zero.
  - Floating panes must precede tiled panes in z-order.
  - Unknown and duplicate flags are rejected.
  - Hidden and zoomed flags cannot be combined.
  - Only one pane may be zoomed.
  - Relative positioning is accepted only for floating panes.
  - Overflow-safe size aggregation.

  Invalid single-window layouts are validated before the window is unzoomed. Multi-window
  layouts are all validated before any window is changed.

  ## Multi-window layouts

  cmd-select-layout.c accepts:

  @window-id:layout[@window-id:layout...]

  Records may be adjacent or separated by whitespace/newlines. Unknown and duplicate window IDs
  are rejected.

  This allows direct reuse of:

  tmux list-windows -F '#{window_id}:#{window_layout}'

  ## Supporting runtime changes

  - tmux.h adds parsed pane IDs, z-indexes, hidden/zoomed/relative cell flags, and
    layout_validate.

  - layout.c initializes parsed metadata safely.
  - window.c treats hidden cells, including saved cells, as non-visible.

  ## Documentation

  tmux.1 now documents:

  - Current and legacy grammars.
  - Geometry and flags.
  - Z-index and pane-ID rules.
  - Optional checksums.
  - Multi-window wrappers.
  - Pane-count pruning.
  - Snapshot versus session-restoration semantics.

  The authoritative description is under select-layout; list-windows and list-panes reference
  it.

  ## Tests

  Added regress/layout-custom.sh covering serialization, compatibility, validation, geometry,
  IDs, pruning, flags, zoom, checksums, whitespace, and multi-window application.

  Updated regress/control-client-sanity.sh for canonical output.

  Verified:

  - Debug build
  - Layout regression
  - Floating-pane geometry regression
  - Control-client regression
  - Man-page rendering
  - git diff --check
2026-06-29 17:47:28 +02:00
Thomas Adam
d5284be91d Merge branch 'obsd-master' 2026-06-29 09:00:09 +01:00
nicm
c29b41e527 Make pane scrollbars able to auto-hide after a short timeout. This
replaces the previous "modal" behaviour where the pane would be resized,
which tended to make a mess. Instead, the scrollbar appears when
scrolling or when hovered over with the mouse and disappears a
(configurable) short period later. From Michael Grant.
2026-06-29 07:45:09 +00:00
Thomas Adam
705fbf92ee Merge branch 'obsd-master' 2026-06-28 21:49:05 +01:00
nicm
dd02989e88 Invalidate scene when changing window Z index, from Dane Jensen. 2026-06-27 10:16:15 +00:00
Thomas Adam
1048796003 Merge branch 'obsd-master' 2026-06-26 15:15:06 +01:00
nicm
973c4ab569 Drop mouse movement events rather than redrawing unnecessarily. 2026-06-26 13:58:00 +00:00
Thomas Adam
0b538b6f2a Merge branch 'obsd-master' 2026-06-25 13:29:53 +01:00
nicm
51d037e881 Major rework of prompts. The basic prompt mechanics (draw, editing, etc)
are now wrapped up in prompt*.c and do not depend on a client. These
functions are used to provide the original client prompt but also to
allow panes to have their own prompts, which works much much better for
floating panes. The mode prompts for both the tree modes and copy mode
are switched over to be per pane.

There are some visible changes (some of these may be changed if they
don't seem to be working well):

- Prompts in modes now appear in the bottom line, covering whatever
  content was there.

- command-prompt has a -P flag to open a pane prompt.

- Because they cover the content, the default style for prompts in modes
  now does not fill the entire line; the main command prompt stays the
  same.

- The old completion menu has gone, and completions are now shown after
  the text. Builtin aliases are no longer completed.

- Clicking the mouse on the prompt now moves the cursor or selects a
  completion.
2026-06-25 11:39:11 +00:00
Thomas Adam
ed48555bdd Merge branch 'obsd-master' 2026-06-24 22:30:06 +01:00
nicm
ba9faae8b6 Free modes rather than going through reset when pane is destroyed as the
reset path may try to destroy the pane again.
2026-06-24 21:10:05 +00:00
Thomas Adam
a63e429d22 Merge branch 'obsd-master' 2026-06-23 13:00:09 +01:00
nicm
de086f9848 Fix an infinite loop in customize mode when a filter does not match, and
tweak a tmux.1 example.
2026-06-23 11:29:27 +00:00
Thomas Adam
6643acb375 Merge branch 'obsd-master' 2026-06-23 11:00:09 +01:00
nicm
9dba08ac8b Allow -p more than 100%, and account for borders when sizing new panes.
From Dane Jensen.
2026-06-23 09:29:26 +00:00
Thomas Adam
52877c9af1 Merge branch 'obsd-master' 2026-06-23 07:35:51 +01:00
nicm
95afd7549c Rewrite screen-redraw.c to make it tidier and more maintainable. A scene
is generated and cached in the client: it holds positions and sizes of
panes, borders and so on. The scene is invalidated when a pane is moved
or resized or relevant option is changed. This scene is then drawn to
the client as needed and text and colours are filled in. With Michael
Grant.
2026-06-22 08:47:45 +00:00
Thomas Adam
72e768ef14 Merge branch 'obsd-master' 2026-06-19 20:00:06 +01:00
nicm
d04b1ffca5 Use a floating pane for the buffer mode editor instead of a popup. 2026-06-19 18:37:10 +00:00
Thomas Adam
c6b8ad6e7e Merge branch 'obsd-master' 2026-06-18 11:15:07 +01:00
nicm
d92a479d2f Add a dim= style attribute to dim the colours (as best as tmux is able
to). GitHub issue 4842.
2026-06-18 09:59:55 +00:00
Thomas Adam
408e9f1481 Merge branch 'obsd-master' 2026-06-15 23:00:06 +01:00
nicm
482e254a49 Rename window_pane_visible to match other functions, from Dane Jensen. 2026-06-15 21:47:01 +00:00
nicm
eb65331403 Be more strict about what names and titles we allow and reject them
immediately when possible, but allow # again for those directly set by
commands (but not escape sequences). From Barrett Ruth in GitHub issue
5175.
2026-06-15 21:41:39 +00:00
Thomas Adam
9031f59f7b Merge branch 'obsd-master' 2026-06-15 19:00:06 +01:00
nicm
b86bd1fcd0 Add pane-border-lines none like popups (-B to new-pane). 2026-06-15 17:34:25 +00:00
Thomas Adam
9fcd5ce03d Merge branch 'obsd-master' 2026-06-15 10:30:05 +01:00
nicm
a41e6e2ed2 Add -B to new-pane to select the floating pane border. 2026-06-15 09:21:40 +00:00
Thomas Adam
e54855ef88 Merge branch 'obsd-master' 2026-06-15 09:30:05 +01:00
nicm
7a18fa281d Add top-floating and bottom-floating to pane-border-status to show
status line only on floating panes.
2026-06-15 08:16:05 +00:00
Thomas Adam
fb527fa7db Merge branch 'obsd-master' 2026-06-14 21:00:05 +01:00
nicm
87976aa48e Add a helper to get pane-border-status for a window for some other
changes to come.
2026-06-14 19:31:37 +00:00
Thomas Adam
3d7f421809 Merge branch 'obsd-master' 2026-06-11 15:30:06 +01:00
nicm
fa6d33f742 Add a helper to free the list of pending resizes. 2026-06-11 14:19:59 +00:00
Thomas Adam
9231c80cd8 Merge branch 'obsd-master' 2026-06-10 17:15:07 +01:00
nicm
2719549cf2 Rename new-pane -B to -W since -B is best kept to match -B to
display-popup.
2026-06-10 16:03:14 +00:00
Thomas Adam
2179c3e420 Merge branch 'obsd-master' 2026-06-09 10:30:06 +01:00
nicm
d5c9196348 Add -B to new-pane/split-window to block until the command exits, like
run-shell -b.
2026-06-09 09:11:05 +00:00
Thomas Adam
97156f3382 Merge branch 'obsd-master' 2026-06-09 09:30:06 +01:00
nicm
27c58c764d Do not use NULL arguments, bug spotted by Dane Jensen. 2026-06-09 08:11:53 +00:00
Thomas Adam
1564584ba9 Merge branch 'obsd-master' 2026-06-09 00:15:06 +01:00
nicm
fd10db5a62 Fix mouse events on tiled pane status line - when panes share a border,
prefer the pane for which the border is the status line. With Dane
Jensen.
2026-06-08 23:06:21 +00:00
Thomas Adam
7d8c1ae295 Merge branch 'obsd-master' 2026-06-08 22:00:07 +01:00
nicm
34fd261a4f Add a -k flag to choose commands to kill the pane when the mode is
exited (useful with floating panes).
2026-06-08 20:38:54 +00:00
Thomas Adam
c97b2b95e6 Merge branch 'obsd-master' 2026-06-02 20:30:06 +01:00
nicm
a3bf632276 Move cell creation into layout.c, from Dane Jensen. 2026-06-02 19:25:06 +00:00
Thomas Adam
e89f02bd8f Merge branch 'obsd-master' 2026-06-02 09:30:06 +01:00
nicm
ae6a749d3a Move the PANE_FLOATING flag into the layout cell and add an accessor.
From Dane Jensen.
2026-06-02 08:13:50 +00:00
Thomas Adam
2f3ef88dbf Merge branch 'obsd-master' 2026-06-01 21:15:06 +01:00