Compare commits

...

2693 Commits

Author SHA1 Message Date
Michael Grant
f53976a266 image: move basic fallback into image.c 2026-08-19 00:03:19 +01:00
Michael Grant
9c70c3351b sixel: preserve image aspect across client geometries
Scale SIXEL rasters uniformly when clients have different cell dimensions, while retaining the original logical cell canvas as blank padding.

Map crops using real cell boundaries so partial final cells are not stretched or compressed.
2026-08-18 22:59:39 +01:00
Michael Grant
7df1259bf3 build: rename image support option 2026-08-18 12:21:02 +01:00
Michael Grant
073dc4c3dd image: simplify geometry cleanup 2026-08-17 08:47:16 +01:00
Michael Grant
7bd1ba9cad sixel: preserve fractional raster extents 2026-08-10 15:12:47 +01:00
Michael Grant
fce3ac131a sixel: scale source raster bounds 2026-08-10 12:11:40 +01:00
Michael Grant
b30f9b23fa Change some names of things for clarity. 2026-08-09 22:14:27 +01:00
Michael Grant
7bd1a8572e Redraw SIXEL images before or after text depending on which was placed first in the cell. 2026-08-09 09:07:00 +01:00
Michael Grant
f1d7f7766d The implementation now distinguishes a newly placed image cell from one later overwritten by text. On a SIXEL terminal, damaged cells are omitted from image output; on Kitty they remain ordinary positional placements. 2026-08-09 09:06:26 +01:00
Michael Grant
958946e92b More cleanup of "histogram" name. 2026-08-08 10:49:13 +01:00
Michael Grant
f0216004ee Shorten image and SIXEL names 2026-08-08 10:40:56 +01:00
Michael Grant
07455f928d Avoid overflow in image cell size calculation 2026-08-08 10:33:54 +01:00
Michael Grant
c754b738c3 Move image cell drawing into image.c 2026-08-08 10:26:50 +01:00
Michael Grant
36900e144f Expose image backend flags 2026-08-08 10:21:30 +01:00
Michael Grant
cce975eb77 Move RB_GENERATE_STATIC to top of file. 2026-08-08 09:19:39 +01:00
Michael Grant
509ad56006 Do not enable sync for SIXEL 2026-08-08 09:14:07 +01:00
Michael Grant
d5ce3136c6 Comment sixel_from_image(). 2026-08-07 22:41:00 +01:00
Michael Grant
9fce2352c6 Add comments to image functions 2026-08-07 22:19:07 +01:00
Michael Grant
81af9c402a Add comments to image functions 2026-08-07 22:17:25 +01:00
Michael Grant
236d28674b Revert "Clear text beneath SIXEL image placements."
This reverts commit 3e3567b343.
2026-08-07 19:14:46 +01:00
Michael Grant
3e3567b343 Clear text beneath SIXEL image placements. 2026-08-07 16:39:52 +01:00
Michael Grant
88bd41265b Fix underlay bookkeeping bug. 2026-08-07 11:36:44 +01:00
Michael Grant
867c5d3c1f Dither alpha in SIXEL output 2026-08-07 11:23:17 +01:00
Michael Grant
3ee659c109 Revert "Clear text beneath graphical images"
This reverts commit fb589fd9f9.
2026-08-07 09:27:39 +01:00
Michael Grant
6eded1bc85 Use compact image references in grid cells 2026-08-06 22:34:59 +01:00
Michael Grant
ca4e4c03c5 Clear text beneath graphical images 2026-08-06 22:19:46 +01:00
Michael Grant
1c9fdd18d4 Simplify image support terminology 2026-08-06 16:17:21 +01:00
Michael Grant
02518f0e3c Use one image support switch 2026-08-06 14:27:07 +01:00
Michael Grant
d83ffb2f63 Make image types opaque 2026-08-06 12:42:25 +01:00
Michael Grant
9c7c777fd9 Keep SIXEL palettes across redraw spans 2026-08-06 11:30:23 +01:00
Michael Grant
718e281820 Fix SIXEL median-cut palette generation 2026-08-05 21:45:45 +01:00
Michael Grant
507ecd320a Revert "Removed unconditional Floyd–Steinberg dithering from image-sixel.c:1077. Kitty images now use the adaptive 256-colour median-cut palette with direct nearest-colour mapping."
This reverts commit 00ffe744b3.
2026-08-05 21:45:27 +01:00
Michael Grant
49be26557d Fix kitty image resize issue when the kitty image resized smaller than the image, the image was overflowing lines and banding. 2026-08-05 13:57:26 +01:00
Michael Grant
00ffe744b3 Removed unconditional Floyd–Steinberg dithering from image-sixel.c:1077. Kitty images now use the adaptive 256-colour median-cut palette with direct nearest-colour mapping. 2026-08-05 13:55:51 +01:00
Michael Grant
6820eceee5 Rename image damage functions to redraw 2026-08-03 13:14:04 +01:00
Michael Grant
c336f49585 Correct image copyrights 2026-08-03 12:56:12 +01:00
Michael Grant
aa2dd64873 Improve SIXEL colour quantization
Build an adaptive 256-colour palette with median cut instead of using a fixed colour cube. Apply Floyd-Steinberg error diffusion while mapping pixels to reduce banding and preserve image detail.
2026-08-03 12:21:54 +01:00
Michael Grant
832d2beb2d Preserve SIXEL pixel dimensions
Retain the padded canonical pixel canvas separately from the image content. Scale only the populated portion of partial edge cells so an image keeps its exact raster size on the originating terminal while retaining its cell footprint.
2026-08-03 12:14:49 +01:00
Michael Grant
08f0c0485b Correct SIXEL HLS colour conversion
Use the DEC hue origin and channel order, and round percentage and HLS conversions to the nearest byte value.
2026-08-03 12:08:28 +01:00
Michael Grant
c4bdd8eca1 Make sixel images grid resident
Replace screen-coordinate image placements with immutable pixel images referenced by ordinary grid cells. Draw visible marker runs through the redraw scene using per-client sixel or text backends so images follow history, copy mode, clipping and overwrites.
2026-08-03 11:56:25 +01:00
tmux update bot
31dccb6bc9 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Fix unzoomed width when scrollbars are hidden.
2026-07-30 04:22:52 +00:00
nicm
8dfb7d0294 Fix unzoomed width when scrollbars are hidden. 2026-07-30 04:22:51 +00:00
Nicholas Marriott
265fb7b4ea Test for vi keys and padding. 2026-07-29 21:18:38 +01:00
tmux update bot
fa38b36f1f Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Correctly skip padding at end of line, GitHub issue 5411.
2026-07-29 20:04:07 +00:00
nicm
44b8a40b8c Correctly skip padding at end of line, GitHub issue 5411. 2026-07-29 20:04:06 +00:00
tmux update bot
5cd5df1d33 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add a flag to turn off scrollbars for display-panes; GitHub issue 5440 from David Marte.
2026-07-29 17:41:02 +00:00
nicm
415d265728 Add a flag to turn off scrollbars for display-panes; GitHub issue 5440
from David Marte.
2026-07-29 17:41:01 +00:00
Nicholas Marriott
d6c37ce314 Note SIXEL at end of configure as well. 2026-07-29 11:11:05 +01:00
tmux update bot
c6d02d54d1 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Fix #1 -> #{1} in tmux1, from Rasmus Thystrup Karstensen.
2026-07-29 10:10:07 +00:00
nicm
6f41dac898 Fix #1 -> #{1} in tmux1, from Rasmus Thystrup Karstensen. 2026-07-29 10:10:06 +00:00
tmux update bot
5534f1ac32 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Store status position in new mouse event for menus so the position is correct later.
2026-07-28 15:09:08 +00:00
nicm
9f2c535909 Store status position in new mouse event for menus so the position is
correct later.
2026-07-28 15:09:07 +00:00
Nicholas Marriott
7cc0c11cde Add test for mouse menu position. 2026-07-28 14:18:18 +01:00
tmux update bot
31fe1ded5d Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Show hook count and time in customize mode.
2026-07-28 12:15:38 +00:00
nicm
6a13d61b48 Show hook count and time in customize mode. 2026-07-28 12:15:37 +00:00
Nicholas Marriott
9c402fa7b7 Test hook time in customize mode. 2026-07-28 11:36:03 +01:00
tmux update bot
a115ca68a5 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add a warning about shell metacharacters, from Nikolas Skarlatos.
2026-07-28 10:09:27 +00:00
nicm
a5ad1914b8 Add a warning about shell metacharacters, from Nikolas Skarlatos. 2026-07-28 10:09:26 +00:00
Nicholas Marriott
3c1b2969a8 Tests for hooks time and count. 2026-07-28 08:08:26 +01:00
tmux update bot
e2a5ea2e78 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Store count of how many times a hook is fired and the last time.
2026-07-28 04:30:35 +00:00
nicm
27ab96b284 Store count of how many times a hook is fired and the last time. 2026-07-28 04:30:34 +00:00
tmux update bot
00b5323d5c Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  When destroying pane, also close pipe and destroy its event. GitHub issue 5424.
2026-07-27 19:56:21 +00:00
nicm
f751d3f2c1 When destroying pane, also close pipe and destroy its event. GitHub
issue 5424.
2026-07-27 19:56:19 +00:00
Nicholas Marriott
9b97dadc01 Test for pipe-pane. 2026-07-27 15:26:43 +01:00
tmux update bot
8ca512b502 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add after-swap-window hook from basicalllymiloud at gmail dot com.
2026-07-27 14:00:20 +00:00
nicm
5269e14113 Add after-swap-window hook from basicalllymiloud at gmail dot com. 2026-07-27 14:00:18 +00:00
tmux update bot
ff214cf9a1 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Include \n and \t in shell special characters, from Nikolas Skarlatos.
2026-07-26 19:57:58 +00:00
nicm
d57d75deee Include \n and \t in shell special characters, from Nikolas Skarlatos. 2026-07-26 19:57:57 +00:00
tmux update bot
008a3f3f8b Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Do not try to write to clients which have died, GitHub issue 5431 from Stefan Ladstätter.
2026-07-26 16:16:39 +00:00
nicm
4cc45aa719 Do not try to write to clients which have died, GitHub issue 5431 from
Stefan Ladstätter.
2026-07-26 16:16:37 +00:00
Nicholas Marriott
0255981a54 Test run-shell if killed. 2026-07-26 16:08:58 +01:00
tmux update bot
0a92ff6e76 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Also set ntitles to 0 when creating screen in the first place.
  Reset title count when freeing titles, GitHub issue 5429 from Brett Smith.
  Do not loop forever if the combining character is too long, GitHub issue 5434 from me at qdrs dot dev.
2026-07-26 10:55:47 +00:00
nicm
3068ae06a8 Also set ntitles to 0 when creating screen in the first place. 2026-07-26 10:55:45 +00:00
nicm
55169f1275 Reset title count when freeing titles, GitHub issue 5429 from Brett
Smith.
2026-07-26 10:55:45 +00:00
nicm
afb95f3134 Do not loop forever if the combining character is too long, GitHub issue
5434 from me at qdrs dot dev.
2026-07-26 10:55:45 +00:00
Nicholas Marriott
10726b1b27 Title stack test. 2026-07-26 10:21:01 +01:00
Nicholas Marriott
0768795ce3 Test for overlong runs of combining characters, GitHub issue 5434. 2026-07-26 10:02:31 +01:00
tmux update bot
29bf7fe2f7 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Replace outside as well as empty cells with the border.
2026-07-24 11:46:46 +00:00
nicm
47f210a9d2 Replace outside as well as empty cells with the border. 2026-07-24 11:46:45 +00:00
Nicholas Marriott
e361982acf Fix some tests. 2026-07-24 09:49:32 +01:00
Nicholas Marriott
cc7eea1e34 Merge pull request #5423 from ilyagr/jemalloc-and-asan-mutually-exclusive
configure.ac: don't enable jemalloc if ASAN enabled on macOS, error if both enabled
2026-07-24 07:10:52 +01:00
Ilya Grigoriev
0ec289545a configure.ac: don't enable jemalloc if ASAN enabled on macOS, error if both enabled
ASAN and jemalloc both replace `malloc` with their version.

Previously, configuring with `--enable-asan` on macOS would enable both
jemalloc and ASAN. I'm not sure which one won, but seemed undesired.
2026-07-23 17:43:23 -07:00
tmux update bot
190b5bde16 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Extend fill-character to allow inside and outside to be separate and use a different default (filled characters rather than dots) for inside.
2026-07-23 11:33:53 +00:00
nicm
8862390c34 Extend fill-character to allow inside and outside to be separate and use
a different default (filled characters rather than dots) for inside.
2026-07-23 11:33:52 +00:00
Nicholas Marriott
c59230316b Update CHANGES. 2026-07-23 12:23:12 +01:00
Nicholas Marriott
a2f3bdb601 fill-character test bits. 2026-07-23 10:38:27 +01:00
Nicholas Marriott
689e6f8fac Add jemalloc to regress dependencies. 2026-07-23 09:30:16 +01:00
Nicholas Marriott
6049298140 Show what we have found during configure. 2026-07-23 09:26:57 +01:00
Nicholas Marriott
a10ed3233c Require jemalloc on macOS. 2026-07-23 09:26:42 +01:00
Nicholas Marriott
7568c19276 Log jemalloc version if in use. 2026-07-23 09:12:16 +01:00
Nicholas Marriott
fb88172346 Turn ASAN off again on macOS. 2026-07-23 08:59:49 +01:00
Nicholas Marriott
26bdd2b511 On macOS, look for utf8proc with no arguments and use it if provided. Only
require a flag if it is not available.
2026-07-23 08:59:04 +01:00
Nicholas Marriott
38feebb5d2 Show options tests. 2026-07-23 08:06:09 +01:00
tmux update bot
7428b0431a Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Switch show-options over to using a format and add -F.
  Add a menu on empty areas to allow a new pane to be created.
2026-07-22 22:06:21 +00:00
nicm
7277712ca8 Switch show-options over to using a format and add -F. 2026-07-22 22:06:20 +00:00
nicm
2a5389416a Add a menu on empty areas to allow a new pane to be created. 2026-07-22 22:06:20 +00:00
tmux update bot
597d04ed78 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Show user hooks correctly with show-hooks.
2026-07-22 20:06:33 +00:00
nicm
9625fe3b5f Show user hooks correctly with show-hooks. 2026-07-22 20:06:31 +00:00
Nicholas Marriott
09a2ea190d Update test. 2026-07-22 20:24:21 +01:00
Nicholas Marriott
18fc547b82 Update show hooks tests. 2026-07-22 19:58:55 +01:00
tmux update bot
242239b561 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add A modifier to cycle through a series of values, GitHub issue 5412 from Fernando Daciuk.
2026-07-22 15:11:40 +00:00
nicm
bd4ac02994 Add A modifier to cycle through a series of values, GitHub issue 5412
from Fernando Daciuk.
2026-07-22 15:11:38 +00:00
Nicholas Marriott
0868435e81 Add test for A: modifier, from Fernando Daciuk. 2026-07-22 14:17:22 +01:00
tmux update bot
7abb9af062 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Clip floating panes exactly at window edge, don't let the border creep into the first outside column.
  Invalidate scene when window is resized.
  Add a -C flag to new-pane to have a modal pane close when the mouse is clicked outside it, GitHub issue 5400.
2026-07-21 15:06:24 +00:00
nicm
a57b0f1282 Clip floating panes exactly at window edge, don't let the border creep
into the first outside column.
2026-07-21 15:06:22 +00:00
nicm
c59db2d007 Invalidate scene when window is resized. 2026-07-21 15:06:22 +00:00
nicm
8bf2a4e807 Add a -C flag to new-pane to have a modal pane close when the mouse is
clicked outside it, GitHub issue 5400.
2026-07-21 15:06:22 +00:00
Nicholas Marriott
2848a12562 Update tests for fix to floating panes at window edges. 2026-07-21 14:41:52 +01:00
tmux update bot
92f090c0c0 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  If drawing border but not actually on a border, use the default line style.
  Add copy-mode-current-line-style to set style for current line in copy mode, GitHub issue 5391 from Leo Henon.
2026-07-21 12:55:45 +00:00
nicm
9d583cad5a If drawing border but not actually on a border, use the default line
style.
2026-07-21 12:55:44 +00:00
nicm
abd2f3a9a5 Add copy-mode-current-line-style to set style for current line in copy
mode, GitHub issue 5391 from Leo Henon.
2026-07-21 12:55:44 +00:00
Nicholas Marriott
3e61e63851 Test for outside panes with no border. 2026-07-21 12:56:32 +01:00
tmux update bot
4d1cf62fb4 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Use correct cursor position for range end, GitHub issue 5414.
  Increase escape-time for tmux's own queries (refresh-client -l and window size) as well, GitHub issue 5388 from Jackson Edmonds.
2026-07-21 09:17:33 +00:00
nicm
0e2576a842 Use correct cursor position for range end, GitHub issue 5414. 2026-07-21 09:17:32 +00:00
nicm
418ddada23 Increase escape-time for tmux's own queries (refresh-client -l and
window size) as well, GitHub issue 5388 from Jackson Edmonds.
2026-07-21 09:17:32 +00:00
Nicholas Marriott
8aaae25e56 Fix a merge and add test bits. 2026-07-21 08:00:39 +01:00
Thomas Adam
5ed5e3606e Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Change cellused/size to 16 bits and time to 32 bits in grid_line and add the OSC 133 positions (size stays the same).
2026-07-20 18:17:19 +01:00
nicm
d13b69ece4 Change cellused/size to 16 bits and time to 32 bits in grid_line and add
the OSC 133 positions (size stays the same).
2026-07-20 14:44:19 +00:00
tmux update bot
88a91b9f83 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Correctly include status line in pane height.
2026-07-20 11:14:58 +00:00
nicm
efcfc55535 Correctly include status line in pane height. 2026-07-20 11:14:56 +00:00
tmux update bot
afb3e954bf Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Remove bits to disable removing empty lines since actually we want to do that - zoom added them in the first place.
2026-07-19 22:36:41 +00:00
nicm
aea209b142 Remove bits to disable removing empty lines since actually we want to do
that - zoom added them in the first place.
2026-07-19 22:36:40 +00:00
tmux update bot
8dd0e2129e Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Copy the home directory if it comes from getpwuid.
2026-07-19 20:33:37 +00:00
nicm
8024fab1f2 Copy the home directory if it comes from getpwuid. 2026-07-19 20:33:36 +00:00
Nicholas Marriott
c750c014b2 Extend test. 2026-07-19 20:58:20 +01:00
tmux update bot
1b179582e6 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add unzoomed width and height formats and use them for the sizes shown in panes mode, reported by tb@.
2026-07-19 19:57:33 +00:00
nicm
c766669b3b Add unzoomed width and height formats and use them for the sizes shown
in panes mode, reported by tb@.
2026-07-19 19:57:31 +00:00
tmux update bot
c45bf2e84d Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Guard x as well as y to avoid overflow, GitHub issue 5409 from Park Seongjae.
2026-07-19 18:29:04 +00:00
nicm
6ef280fb0f Guard x as well as y to avoid overflow, GitHub issue 5409 from Park
Seongjae.
2026-07-19 18:29:02 +00:00
Nicholas Marriott
2a2bce3dd4 Fix tty-keys.sh test. 2026-07-19 18:34:18 +01:00
tmux update bot
cad1c81c71 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Prevent display-panes from shifting the active pane scroll position by copying the screen from before zoom, also do not let resize consume blank lines.
2026-07-17 19:34:36 +00:00
nicm
496bfdce38 Prevent display-panes from shifting the active pane scroll position by
copying the screen from before zoom, also do not let resize consume
blank lines.
2026-07-17 19:34:34 +00:00
tmux update bot
bacc7952ad Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add some missing calls to invalidate scene.
2026-07-17 16:49:56 +00:00
nicm
377a810168 Add some missing calls to invalidate scene. 2026-07-17 16:49:55 +00:00
Nicholas Marriott
481d48b53b 3.8 changes. 2026-07-17 17:44:43 +01:00
tmux update bot
6dacc024f0 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Remove the active-pane flag for now, there are some gaps in how this works and I don't like it. May come back in a different form (maybe just for windows).
2026-07-17 14:08:10 +00:00
nicm
1ce000062a Remove the active-pane flag for now, there are some gaps in how this
works and I don't like it. May come back in a different form (maybe just
for windows).
2026-07-17 14:08:08 +00:00
Thomas Adam
5bd10a8c2a Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Move per-client window sizes into control.c since the only user is for control mode.
  Change %% to escape single quotes (%1 remains with no quoting and %% with double quotes) to avoid a single quote being able to terminate quoted sections of commands. Fixes unexpected behaviour with session names containing single quotes reported by Aliz Hammond.
2026-07-17 13:24:25 +01:00
nicm
2711780dff Move per-client window sizes into control.c since the only user is for
control mode.
2026-07-17 12:15:52 +00:00
nicm
a177d0f590 Change %% to escape single quotes (%1 remains with no quoting and %%
with double quotes) to avoid a single quote being able to terminate
quoted sections of commands. Fixes unexpected behaviour with session
names containing single quotes reported by Aliz Hammond.
2026-07-17 12:15:52 +00:00
tmux update bot
a8ad3c7d43 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Clear cfg_client if the client is destroyed to prevent UAF found by Ilya Grigoriev.
2026-07-17 09:00:53 +00:00
nicm
d5b1f3ad89 Clear cfg_client if the client is destroyed to prevent UAF found by Ilya
Grigoriev.
2026-07-17 09:00:52 +00:00
Nicholas Marriott
b46684427f Extend control client size test. 2026-07-17 09:37:50 +01:00
Nicholas Marriott
5cd43626ef cmd_template_replace test. 2026-07-17 09:29:59 +01:00
Nicholas Marriott
43092f8d54 Test for client lost during config file. 2026-07-17 09:13:33 +01:00
tmux update bot
e50545f451 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Fix uninitialized var for sscanf %n.
2026-07-16 16:43:22 +00:00
nicm
1d0d22df22 Fix uninitialized var for sscanf %n. 2026-07-16 16:43:21 +00:00
tmux update bot
f07ea87e20 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Do not redraw overlays unless actually asked to, GitHub issue 5398 from Noam Stolero.
2026-07-16 12:54:46 +00:00
nicm
824a07290f Do not redraw overlays unless actually asked to, GitHub issue 5398 from
Noam Stolero.
2026-07-16 12:54:45 +00:00
Nicholas Marriott
fba51526af Modal pane regression test. 2026-07-16 13:16:29 +01:00
tmux update bot
15746a1bc7 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Small section missed from previous.
  Add modal panes, created currently with new-pane -O. There is one modal pane per window and it must be a floating pane. These are intended to replace popups. Currently a modal pane will unzoom a zoomed window and rezoom it when it is closed (a bit like modes do), but this is planned to change when we get an always-on-top flag.
2026-07-15 15:53:06 +00:00
nicm
edefce8eb5 Small section missed from previous. 2026-07-15 15:53:04 +00:00
nicm
d98635e1bd Add modal panes, created currently with new-pane -O. There is one modal
pane per window and it must be a floating pane. These are intended to
replace popups. Currently a modal pane will unzoom a zoomed window and
rezoom it when it is closed (a bit like modes do), but this is planned
to change when we get an always-on-top flag.
2026-07-15 15:53:04 +00:00
tmux update bot
9459c7ca64 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Clear the "waiting for editor" area before writing so stray characters aren't visible from underneath.
2026-07-15 13:29:09 +00:00
nicm
75c874c55b Clear the "waiting for editor" area before writing so stray characters
aren't visible from underneath.
2026-07-15 13:29:08 +00:00
tmux update bot
10b2bb76f6 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add a mouse binding for empty areas of the window so C-Drag works on them as well.
2026-07-15 12:04:25 +00:00
nicm
cbb97b961c Add a mouse binding for empty areas of the window so C-Drag works on
them as well.
2026-07-15 12:04:24 +00:00
Nicholas Marriott
5350da0be3 Update test. 2026-07-15 11:38:49 +01:00
Nicholas Marriott
1c7ed8d9ad Remove README.ja from EXTRA_DIST. 2026-07-15 10:40:47 +01:00
Nicholas Marriott
8f2d25024a Remove README.ja which has not been updated since 2018 and is out of date. 2026-07-15 10:39:46 +01:00
tmux update bot
4e586ed0b8 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Switch menus also to be attached to the window instead of an overlay and drawn as part of the client's scene. This means removing the popup menu.
2026-07-14 22:13:52 +00:00
nicm
ad6832e697 Switch menus also to be attached to the window instead of an overlay and
drawn as part of the client's scene. This means removing the popup menu.
2026-07-14 22:13:51 +00:00
Nicholas Marriott
11496010c0 Update test outputs. 2026-07-14 22:15:08 +01:00
Nicholas Marriott
e54785ddd6 Add menu tests. 2026-07-14 22:09:52 +01:00
Thomas Adam
6546fa0982 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Convert display-panes away from an overlay and into a mode. This is another step on the road of getting rid of overlays altogether (they are full of special cases; popups and menus are to go also eventually). We lose some of the styling of borders but gain the ability to run display-panes in another pane (perhaps not hugely useful but one never knows). The -b flag goes away as no longer useful.
2026-07-14 21:20:22 +01:00
nicm
1a02c9957c Convert display-panes away from an overlay and into a mode. This is
another step on the road of getting rid of overlays altogether (they are
full of special cases; popups and menus are to go also eventually). We
lose some of the styling of borders but gain the ability to run
display-panes in another pane (perhaps not hugely useful but one never
knows). The -b flag goes away as no longer useful.
2026-07-14 19:57:30 +00:00
tmux update bot
145f8ef173 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Typos and doc fixes, from Ben Boeckel.
2026-07-14 17:24:20 +00:00
nicm
34a11db6ca Typos and doc fixes, from Ben Boeckel. 2026-07-14 17:24:18 +00:00
Nicholas Marriott
d705471aa5 Regression tests for display-panes changes. 2026-07-14 18:18:52 +01:00
tmux update bot
67f71fe4ac Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Handle padding and tab redraw correctly in copy mode.
2026-07-14 13:12:49 +00:00
nicm
a10252dad2 Handle padding and tab redraw correctly in copy mode. 2026-07-14 13:12:48 +00:00
tmux update bot
c9d6d4b601 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Do not clear lines when we are just going to overwrite them in copy mode.
2026-07-14 12:17:19 +00:00
nicm
f88189cd59 Do not clear lines when we are just going to overwrite them in copy mode. 2026-07-14 12:17:17 +00:00
Nicholas Marriott
c39d69f961 More copy mode tests. 2026-07-14 12:05:06 +01:00
Nicholas Marriott
cf110d9d1d Copy mode redraw test. 2026-07-14 10:07:51 +01:00
tmux update bot
ed4245a74d Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add e key to open editor to customize mode (like buffer mode) and a key to show only changed items.
2026-07-14 04:18:54 +00:00
nicm
09d5977263 Add e key to open editor to customize mode (like buffer mode) and a key
to show only changed items.
2026-07-14 04:18:52 +00:00
tmux update bot
42b3ea0d74 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Apply dragging change to scroll-down as well as scroll-up.
2026-07-13 22:40:19 +00:00
nicm
2a75cc2236 Apply dragging change to scroll-down as well as scroll-up. 2026-07-13 22:40:18 +00:00
Nicholas Marriott
df6ed20271 Add customize mode test. 2026-07-13 23:03:33 +01:00
tmux update bot
de7fdbe85d Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add environment to customize mode also
2026-07-13 21:54:09 +00:00
nicm
37da97fbe6 Add environment to customize mode also 2026-07-13 21:54:08 +00:00
Nicholas Marriott
f0f59bc2fd Fix a test. 2026-07-13 22:52:25 +01:00
Nicholas Marriott
9c65d349e8 Tweak times in tests. 2026-07-13 22:08:58 +01:00
Nicholas Marriott
2818069d5f Merge pull request #5389 from YayoRazo/fix/prompt-history-getline
fix(compat): drop fgetln compat shim, migrate prompt-history.c to getline
2026-07-13 21:25:10 +01:00
tmux update bot
2f0308ea4d Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Replace last use of fgetln with getline, GitHub issue 5389 from Yayo Razo.
  Add hooks to customize mode.
2026-07-13 20:22:00 +00:00
nicm
b1c347ee0c Replace last use of fgetln with getline, GitHub issue 5389 from Yayo Razo. 2026-07-13 20:21:59 +00:00
nicm
fba5083b58 Add hooks to customize mode. 2026-07-13 20:21:59 +00:00
Thomas Adam
9c9477ae76 Tweak previous; include SYNCING.md 2026-07-13 20:30:47 +01:00
Thomas Adam
e4dbd11d44 doc: rewrite SYNCING and reformat to markdown
Rewrite the SYNCING document to reflect that everything runs on Github.

Add examples on how to deal with merge conflicts.

Also reformat to markdown so any examples are more obvious in different
renderers.
2026-07-13 20:29:35 +01:00
Yayo Razo
c3e38b317d fix(compat): drop fgetln compat shim, migrate prompt-history.c to getline
Following up on the comment on #5365 - this drops fgetln from
prompt-history.c (its only remaining caller) in favor of getline, and
removes the fgetln compat shim entirely since nothing references it
anymore: the compat.h declaration, compat/fgetln.c itself, and its
entry in configure.ac's AC_REPLACE_FUNCS list.

fgetln doesn't null-terminate its returned buffer when the final line
in the file lacks a trailing newline, so the old loop had a second
branch to heap-copy and manually terminate that case. getline always
null-terminates regardless, so that branch goes away and the loop
becomes uniform.

Verified with a real build (ubuntu-24.04 container, same
--enable-utf8proc --enable-asan configure CI uses): crafted a history
file with a normal entry, a blank line, and a final entry with no
trailing newline at EOF (the exact case the removed branch existed
for), loaded it through a real ASan-built tmux via show-prompt-history,
all three entries came back correctly. Full regress suite is otherwise
clean against this change.
2026-07-13 13:03:58 -06:00
tmux update bot
f75ef5ca1c Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add keys and menu items for copy mode line numbers, and a menu item for auto refresh.
2026-07-13 18:59:03 +00:00
nicm
8fbbde7035 Add keys and menu items for copy mode line numbers, and a menu item for
auto refresh.
2026-07-13 18:59:02 +00:00
Nicholas Marriott
2dc05ae328 Add to alerts tests. 2026-07-13 19:52:27 +01:00
tmux update bot
511fe53846 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add new-pane -M to create a new pane from a mouse binding and bind to C-MouseDrag1Pane, removing the old ctrl-click-to-swap-pane binding.
2026-07-13 17:43:10 +00:00
nicm
658e087f7a Add new-pane -M to create a new pane from a mouse binding and bind to
C-MouseDrag1Pane, removing the old ctrl-click-to-swap-pane binding.
2026-07-13 17:43:09 +00:00
tmux update bot
dba85ee32e Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add pane-activity event.
2026-07-13 16:21:15 +00:00
nicm
b91086a5c8 Add pane-activity event. 2026-07-13 16:21:14 +00:00
Nicholas Marriott
4cd39ee33e new-pane mouse test. 2026-07-13 17:10:04 +01:00
tmux update bot
e3ef97b6b4 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  Add some additional simple events.
  fix window_copy_mouse_in_selection() indentation; ok nicm@
  Work out a single layout for the entire prompt so it can all be drawn together, fixes centered prompts. GitHub issue 5328.
  Allow drag on a selection to modify it, from Michael Grant.
  Make split-window inside a floating pane work more nicely and not immediately create an overlapping pane, from Dane Jensen.
  Set other cell when creating layout set, from Dane Jensen.
  Size comparison should be >= not >, from Yayo Razo.
  Remove worflow from master
2026-07-13 14:35:35 +00:00
nicm
e00a1a3e26 Add some additional simple events. 2026-07-13 14:35:33 +00:00
jsg
006cce5e4d fix window_copy_mouse_in_selection() indentation; ok nicm@ 2026-07-13 14:35:33 +00:00
nicm
4a06a1f296 Work out a single layout for the entire prompt so it can all be drawn
together, fixes centered prompts. GitHub issue 5328.
2026-07-13 14:35:33 +00:00
nicm
fe1b877410 Allow drag on a selection to modify it, from Michael Grant. 2026-07-13 14:35:33 +00:00
nicm
2b091d91d3 Make split-window inside a floating pane work more nicely and not
immediately create an overlapping pane, from Dane Jensen.
2026-07-13 14:35:33 +00:00
nicm
6d227a8479 Set other cell when creating layout set, from Dane Jensen. 2026-07-13 14:35:33 +00:00
nicm
447d804a3a Size comparison should be >= not >, from Yayo Razo. 2026-07-13 14:35:33 +00:00
Nicholas Marriott
687c6b9cc0 Regress for more hooks. 2026-07-13 13:57:31 +01:00
Nicholas Marriott
b2e2fe824d Add scroll regress. 2026-07-13 11:32:28 +01:00
Thomas Adam
1f6385e7bb build: remove openbsd sync job
This only needs to run from the openbsd-cutover repository and will no
longer be merged into thisd repo.
2026-07-13 11:03:46 +01:00
Thomas Adam
309119f659 Remove worflow from master 2026-07-13 10:54:27 +01:00
tmux update bot
884ae3f8da Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  build: run every fifteen minutes
2026-07-13 09:42:03 +00:00
Nicholas Marriott
d9b953d5c6 Create SECURITY.md 2026-07-13 10:29:28 +01:00
Nicholas Marriott
e0014bbc7c Add regress tests for events code. 2026-07-13 10:23:38 +01:00
Thomas Adam
d03de4986a build: run every fifteen minutes 2026-07-13 09:27:05 +01:00
Thomas Adam
6126988781 portable: add Makefile.am 2026-07-13 09:22:53 +01:00
Thomas Adam
25e2e1d671 Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master:
  build: don't exit
  build: always attempt portable merge
  build: capture openbsd-base before filtering
  build: fetch cutover master before merge
  Use _exit in child after fork, from Yayo Razo in GitHub issue 5376.
  Add missing calloc check and use fatal. Prompted by a similar change from Yayo Razo.
  actions: use published openbsd-git as base update
  github actions: automate updates
  Do not make pty fds blocking again until all the data has been consumed or control mode clients can get stuck, GitHub issue 5356 from Ben Maurer.
  Add formats and events for OSC 133 commmands, as well as a -T flag to set-hook -B to only fire when the format is true.
  Replace the notification system with events. Events can carry a payload of additional payload (to reduce problems with lifetime of objects) and are delivered to one or more event sinks. This is more powerful and reduces the complex dependencies between control mode and hooks. Events are now used for hooks, control mode notifications and for monitors (set-hook -B).
2026-07-13 09:22:25 +01:00
Thomas Adam
e6eb26518b build: don't exit 2026-07-13 09:13:28 +01:00
Thomas Adam
8b2bc1a384 build: always attempt portable merge 2026-07-13 09:10:24 +01:00
Thomas Adam
0ce72059e6 build: capture openbsd-base before filtering 2026-07-13 09:05:10 +01:00
Thomas Adam
f80d3f6123 build: fetch cutover master before merge 2026-07-13 09:00:47 +01:00
nicm
0925c9846b Use _exit in child after fork, from Yayo Razo in GitHub issue 5376. 2026-07-13 07:57:44 +00:00
nicm
3612a9a605 Add missing calloc check and use fatal. Prompted by a similar change
from Yayo Razo.
2026-07-13 07:57:44 +00:00
Thomas Adam
cc8e0f2f67 actions: use published openbsd-git as base update 2026-07-13 08:50:49 +01:00
Nicholas Marriott
a662981f10 Bump a time limit. 2026-07-13 07:08:05 +01:00
Nicholas Marriott
d77c9dc6aa Tweak BIDI test. 2026-07-12 23:18:47 +01:00
Nicholas Marriott
8ac3fcedca Do not reuse sockets so much to avoid problems with slow server shutdown. 2026-07-12 22:03:16 +01:00
Nicholas Marriott
ea236c12a6 Merge pull request #5382 from YayoRazo/fix/sixel-saved-images-uaf
fix(screen): free alternate-screen images on screen destroy
2026-07-12 21:40:02 +01:00
Nicholas Marriott
a53a0aa0b5 Merge pull request #5365 from YayoRazo/fix/getline-fgetln-overflow
fix(compat): guard buffer size multiplication in getline
2026-07-12 21:18:37 +01:00
Nicholas Marriott
5e3db12c07 No need for ASAN_OPTIONS. 2026-07-12 21:02:30 +01:00
Nicholas Marriott
4f981a2506 Turn on ASAN for macOS regress. 2026-07-12 20:59:11 +01:00
Thomas Adam
b602dc57b1 github actions: automate updates 2026-07-12 17:24:37 +01:00
Nicholas Marriott
330bedfb47 Build with ASAN on macOS by default. 2026-07-12 13:26:25 +01:00
Yayo Razo
3ff24a8eb4 fix(compat): guard buffer size multiplication in getline 2026-07-11 17:07:21 -06:00
Yayo Razo
28a1231100 fix(screen): free alternate-screen images on screen destroy 2026-07-11 15:53:08 -06:00
Nicholas Marriott
6fd9987632 Revert "Add formats and events for OSC 133 commmands, as well as a -T flag to"
This reverts commit f3c6b4f1a3.
2026-07-11 04:37:04 +01:00
Thomas Adam
8f27092756 Merge branch 'obsd-master' 2026-07-10 18:20:43 +01:00
Nicholas Marriott
e7fef1fd64 Test for wait exit, GitHub issue 5356 from Ben Maurer. 2026-07-10 16:45:58 +01:00
nicm
7f2b0ae16e Do not make pty fds blocking again until all the data has been consumed
or control mode clients can get stuck, GitHub issue 5356 from Ben Maurer.
2026-07-10 15:45:11 +00:00
nicm
0cc84b8cae Do not make pty fds blocking again until all the data has been consumed
or control mode clients can get stuck, GitHub issue 5356 from Ben Maurer.
2026-07-10 15:45:11 +00:00
Nicholas Marriott
1329473a4b Merge pull request #5358 from bmaurer/regress-control-client-exit
Add a regression test for output queued to exiting control clients
2026-07-10 16:39:04 +01:00
Thomas Adam
84cc6541f3 Merge branch 'obsd-master' 2026-07-10 16:30:07 +01:00
nicm
512255b9a7 Add formats and events for OSC 133 commmands, as well as a -T flag to
set-hook -B to only fire when the format is true.
2026-07-10 15:20:06 +00:00
nicm
f3c6b4f1a3 Add formats and events for OSC 133 commmands, as well as a -T flag to
set-hook -B to only fire when the format is true.
2026-07-10 15:20:06 +00:00
Ben Maurer
ad662d3926 Add a regression test for output queued to exiting control clients.
Checks that once a control client is marked for exit the server stops
queueing notifications for it (PR 5357). The client's output is drained only
slowly so a backlog holds the exit handshake open; the client is then
detached and the window renamed, and the %window-renamed notifications must
not appear in the client's output stream.
2026-07-10 07:54:21 -07:00
nicm
d29aa12117 Replace the notification system with events. Events can carry a payload of
additional payload (to reduce problems with lifetime of objects) and are
delivered to one or more event sinks. This is more powerful and reduces the
complex dependencies between control mode and hooks. Events are now used for
hooks, control mode notifications and for monitors (set-hook -B).

wait-for can now wait for an event to fire (-E flag, with -F to for filter),
with -v to print the payload, as well as listing (-l) waiting clients on an
event and forcing one to wake (-w).

A few additional hooks are also now available (pane-created, pane-resized, etc)
and some of the existing ones have additional format variables available.
2026-07-10 13:38:45 +00:00
Thomas Adam
ca6dd6ca92 Merge branch 'obsd-master' 2026-07-10 08:30:07 +01:00
nicm
1508bec957 Don't bother to send notifications to clients with CLIENT_EXIT, GitHub
issue 5357 from Ben Maurer.
2026-07-10 07:25:05 +00:00
nicm
bcc73e0db4 Change NOTHING (which means only redraw the indicator) to MOVE. And
redefine NOTHING as /actually/ nothing. Use it for commands which
actually make no change. Fixes flickering due to excessive redrawing of
indicator lines. Mostly from Michael Grant.
2026-07-10 07:13:05 +00:00
Nicholas Marriott
ec31f4566d Tweak test. 2026-07-09 09:39:44 +01:00
Thomas Adam
dfb2a9404f Merge branch 'obsd-master' 2026-07-09 09:30:06 +01:00
Thomas Adam
7ac0d6bead Merge branch 'obsd-master' 2026-07-09 09:00:06 +01:00
Nicholas Marriott
041b6a6bc7 Add test from xiaomublue at gmail dot com. 2026-07-09 08:56:06 +01:00
nicm
3a6c717bb8 Do not exit at bottom if a selection is in progress, GitHub issue 5349
from xiaomublue at gmail dot com.
2026-07-09 07:54:07 +00:00
Thomas Adam
ec74c46d1e Merge branch 'obsd-master' 2026-07-09 08:45:06 +01:00
nicm
161dbaf1ce Cancel pending resizes and resize immediately when entering alternate
screen, fixes flickering with scrollbars. GitHub issue 5351 from Michael
Grant.
2026-07-09 07:35:05 +00:00
nicm
e242da168b Clip the status line and menu against an open popup overlay, GitHub
issue 5350 from Noam Stolero.
2026-07-09 07:32:58 +00:00
nicm
dea309cf8d Allow empty name with new-window again, from Jacob Koziej. 2026-07-09 07:19:24 +00:00
Thomas Adam
ee3944c8fd Merge branch 'obsd-master' 2026-07-09 08:00:06 +01:00
nicm
1fefb80445 Add t/d for time difference in seconds. 2026-07-09 06:33:19 +00:00
Nicholas Marriott
f92cb43ce4 t/d test. 2026-07-08 12:36:19 +01:00
Thomas Adam
cd2ca9ec34 Merge branch 'obsd-master' 2026-07-08 12:15:06 +01:00
nicm
e37a2e54ab Fix regsub with anchor at start of pattern, GitHub issue 5341. 2026-07-08 11:04:51 +00:00
Thomas Adam
53f3b05001 Merge branch 'obsd-master' 2026-07-08 10:30:05 +01:00
nicm
8e76565c9c Keep all modes except cursor during redraw, GitHub issue 5337 from Ayman
Bagabas.
2026-07-08 09:23:10 +00:00
Nicholas Marriott
c830710e11 More sub tests. 2026-07-08 09:55:21 +01:00
Thomas Adam
0f354ac4e0 Merge branch 'obsd-master' 2026-07-08 09:30:06 +01:00
Nicholas Marriott
e601bfb362 Theme report test from Ayman Bagabas. 2026-07-08 09:22:55 +01:00
nicm
dac6514147 Report the terminal's own theme to panes rather than guessing from the
background. GitHub issue 5343 from Ayman Bagabas.
2026-07-08 08:21:53 +00:00
nicm
ac723bf2df Do not crash looking for next or previous session. GitHub issue 5344. 2026-07-08 08:15:49 +00:00
Thomas Adam
c8f6b54da7 Merge branch 'obsd-master' 2026-07-08 09:15:06 +01:00
Nicholas Marriott
27c26e88e5 detach-on-destroy next/previous tests. 2026-07-08 09:16:50 +01:00
Nicholas Marriott
e77d9ad043 -k/empty panes tests. 2026-07-08 09:07:48 +01:00
nicm
25060c3fa5 Fix empty argument to splitw/newp and add -k to copy-mode. 2026-07-08 08:07:42 +00:00
nicm
28c2005a2a Fix a typo (use right var), from Dane Jensen. 2026-07-08 07:55:17 +00:00
Thomas Adam
db115c6b97 Merge branch 'obsd-master' 2026-07-07 14:00:06 +01:00
nicm
7b02cb6d03 Fix . and ; bindings, reported by tb. 2026-07-07 12:30:36 +00:00
Thomas Adam
8beb17df0d Merge branch 'obsd-master' 2026-07-07 11:00:08 +01:00
nicm
76b693aa81 Add C-b g , and C-b g . for move and resize menus, also add to pane menu
(and fix to make them work).
2026-07-07 09:45:09 +00:00
Thomas Adam
d53f1b7458 Merge branch 'obsd-master' 2026-07-07 09:15:06 +01:00
nicm
7188391a22 Add a layout_geometry container struct, from Dane Jensen. 2026-07-07 08:07:26 +00:00
Thomas Adam
869170abd6 Merge branch 'obsd-master' 2026-07-07 09:00:07 +01:00
nicm
1ea574e4ca Set initial scrollbar state, from Michael Grant. 2026-07-07 07:47:03 +00:00
nicm
af35bcb64f Restore { and } to swap-pane and for floating panes and use a separate
key table accessed by g (short for "gove and/or gesize") for floating
panes. So "C-b g Up" moves the pane to top-centre, "C-b g M-Up" moves
and resizes it. This means we not only do not lose the surprisingly
popular { and } bindings, but we can have more than four keys for moving
and resizing panes.
2026-07-07 07:43:07 +00:00
Thomas Adam
55ce48c152 Merge branch 'obsd-master' 2026-07-06 23:00:06 +01:00
nicm
ff09914327 Could of minor tidy ups. 2026-07-06 21:44:26 +00:00
Nicholas Marriott
3946e24eff Add array test. 2026-07-06 18:13:25 +01:00
Thomas Adam
b07424224b Merge branch 'obsd-master' 2026-07-06 17:00:06 +01:00
nicm
d33d5b7de8 When sync is enabled, we need to mark the whole scroll region dirty if
there has been any scrolling. GitHub issue 5330.
2026-07-06 15:41:31 +00:00
Thomas Adam
9180356b13 Merge branch 'obsd-master' 2026-07-06 16:00:06 +01:00
nicm
20ef19b42f Add a key to change an array key in customize mode. 2026-07-06 14:40:57 +00:00
nicm
1117caaf09 Change array item keys to be strings instead of numbers which are
painful to work with.
2026-07-06 14:29:10 +00:00
Thomas Adam
e6505947ec Merge branch 'obsd-master' 2026-07-06 13:30:06 +01:00
nicm
79b83600af NOJOBS is a flag, use correct argument. 2026-07-06 12:10:18 +00:00
nicm
85e3ca5ae2 Check for width/height 0, based on change from Uzair Aftab. 2026-07-06 12:08:52 +00:00
Thomas Adam
e11af53819 Merge branch 'obsd-master' 2026-07-06 13:00:06 +01:00
Thomas Adam
0593cbeb84 Merge branch 'obsd-master' 2026-07-06 12:30:06 +01:00
nicm
d565fd3b54 Do not create zero size panes, from Uzair Aftab. 2026-07-06 11:28:39 +00:00
nicm
699b18414d Do not allow jobs in monitor formats. 2026-07-06 11:17:28 +00:00
Nicholas Marriott
eb82e8527a Shorten all socket names because macOS is stupid. 2026-07-06 11:50:58 +01:00
Nicholas Marriott
069201dd1a Regression test fixes. 2026-07-06 11:22:56 +01:00
Nicholas Marriott
37e4b3cdb6 Fix name. 2026-07-06 10:12:24 +01:00
Nicholas Marriott
501e8da925 Update some tests and improve Makefile. 2026-07-06 10:00:26 +01:00
Nicholas Marriott
6a6822b906 Shorten socket names. 2026-07-06 09:27:17 +01:00
Thomas Adam
e7c1361a10 Merge branch 'obsd-master' 2026-07-06 09:15:06 +01:00
nicm
913e503296 Unzoom before creating a floating pane (for now). 2026-07-06 07:57:45 +00:00
Nicholas Marriott
2c0f06782d Add alerts test. 2026-07-06 08:47:57 +01:00
Nicholas Marriott
fcce73af42 Add another test. 2026-07-05 22:14:48 +01:00
Nicholas Marriott
2b2963859b Add some hooks tests. 2026-07-05 21:56:52 +01:00
Thomas Adam
327c05307a Merge branch 'obsd-master' 2026-07-05 20:00:06 +01:00
nicm
3f065cf789 Add a window pane reference count. 2026-07-05 18:37:57 +00:00
Nicholas Marriott
dc1693d5a1 set-hook -R test. 2026-07-05 18:26:44 +01:00
Nicholas Marriott
29b2b7a875 Mouse on by default. 2026-07-05 15:50:54 +01:00
Thomas Adam
34af038fcc Merge branch 'obsd-master' 2026-07-05 15:01:36 +01:00
Nicholas Marriott
d422621eaa Change a couple of regress configs that are incorret and only work because of
differences in parse-only.
2026-07-05 14:36:47 +01:00
Thomas Adam
f556e4b6fc Merge branch 'obsd-master' 2026-07-05 12:00:06 +01:00
nicm
2fdcb64a79 Add a define for whether mouse is enabled by default (still off). 2026-07-05 10:49:05 +00:00
nicm
468c2942a3 Apply tree mode selection style to the entire line. 2026-07-05 10:28:02 +00:00
Nicholas Marriott
df56ba95fc Update regress for monitor. 2026-07-05 10:21:44 +01:00
Nicholas Marriott
bd39ce0d49 Extend tests. 2026-07-05 10:20:15 +01:00
Thomas Adam
5068e4149a Merge branch 'obsd-master' 2026-07-05 09:30:06 +01:00
nicm
de024e04d7 Add set-hook -B install a subscription like in control mode.
Subscriptions are formats which are checked once a second and if changed
invoke a hook. show-hooks -B lists.
2026-07-05 08:24:00 +00:00
Nicholas Marriott
7ff972773a Bump some times. 2026-07-05 09:06:19 +01:00
Nicholas Marriott
9634538106 Fix test. 2026-07-05 08:17:32 +01:00
Thomas Adam
5356c62ead Merge branch 'obsd-master' 2026-07-04 23:30:06 +01:00
Thomas Adam
9af9226ff9 Merge branch 'obsd-master' 2026-07-04 23:15:06 +01:00
Nicholas Marriott
92028ed6e2 Add a few more tests. 2026-07-04 23:09:16 +01:00
nicm
7a8f8f5a74 Do not use stale pointers in modes. 2026-07-04 22:09:06 +00:00
nicm
415885ecb9 Infer the terminal theme from the background colour correctly, if theme
reporting is not supported.
2026-07-04 22:06:45 +00:00
Thomas Adam
7b833d07d9 Merge branch 'obsd-master' 2026-07-04 21:30:06 +01:00
Nicholas Marriott
2f58804717 Add some basic choose mode tests. 2026-07-04 21:18:48 +01:00
nicm
b05f0abeeb Do not ignore filter when >1 pane. GitHub issue 5326. 2026-07-04 20:17:53 +00:00
Thomas Adam
2d75f79217 Merge branch 'obsd-master' 2026-07-04 20:15:06 +01:00
nicm
898a91903a Add some missing checks which make new pane positions off, from Dane
Jensen.
2026-07-04 18:54:18 +00:00
Nicholas Marriott
6e9574c715 Linux arm64 fails. 2026-07-04 19:40:28 +01:00
Nicholas Marriott
2efd2d4970 Enable macOS regress. 2026-07-04 19:25:39 +01:00
Nicholas Marriott
219dc7f99e Locale breaks tests. 2026-07-04 19:13:53 +01:00
Nicholas Marriott
1b4015226f Use correct counts for this test also. 2026-07-04 19:01:48 +01:00
Nicholas Marriott
0f77d9b30a Fix lengths in test. 2026-07-04 18:52:53 +01:00
Nicholas Marriott
a19b961427 Fix test. 2026-07-04 18:37:53 +01:00
Nicholas Marriott
646637f53a Add control subs test. 2026-07-04 17:18:33 +01:00
Thomas Adam
21e91cfa00 portable: add monitor.c 2026-07-04 17:07:31 +01:00
Thomas Adam
f32b65ac4a Merge branch 'obsd-master' 2026-07-04 17:06:56 +01:00
Nicholas Marriott
a02e25ba01 Do not invoke clear check on respawn. 2026-07-04 17:00:28 +01:00
nicm
c5a7309966 Dirty ED 2 correctly, GiHub issue 5322 from git at twilligon dot com. 2026-07-04 08:34:16 +00:00
Nicholas Marriott
1d7021130d Set ASAN_OPTIONS in regress Makefile. 2026-07-04 09:15:32 +01:00
nicm
8e03310afe Move monitor stuff out of control.c into its own file for reuse. 2026-07-03 22:58:23 +00:00
Thomas Adam
31b0b0c99e Merge branch 'obsd-master' 2026-07-03 20:00:06 +01:00
Thomas Adam
90492aa26d Merge branch 'obsd-master' 2026-07-03 19:30:06 +01:00
nicm
d512a65d4c Add O and V loops in formats for options and environment. 2026-07-03 18:28:57 +00:00
nicm
4378a17fbe Add floating panes key bindings and menu options, from Dane Jensen. 2026-07-03 18:14:45 +00:00
Thomas Adam
8e8fa3d10b Merge branch 'obsd-master' 2026-07-03 19:00:06 +01:00
nicm
b5a6d9bcab Fix some spelling and indentation. 2026-07-03 17:43:14 +00:00
Thomas Adam
929e6b5c9b Merge branch 'obsd-master' 2026-07-03 17:30:06 +01:00
Nicholas Marriott
44304bf9e4 Add pane_start_command_list to tests. 2026-07-03 17:10:51 +01:00
nicm
e03a937c71 Add a quoted pane_start_command_list which does not lose argument
information.
2026-07-03 16:10:25 +00:00
nicm
820067826a Add -E to new-window and respawn-pane and respawn-window to create empty
panes.
2026-07-03 16:09:49 +00:00
Thomas Adam
4a6ac5e209 Merge branch 'obsd-master' 2026-07-03 17:00:06 +01:00
Nicholas Marriott
29f0939a5b Update tests for -E. 2026-07-03 17:01:16 +01:00
Nicholas Marriott
310d0e93d6 Pane sort tests. 2026-07-03 16:37:47 +01:00
nicm
6967f54774 Add additional pane sort orders. 2026-07-03 15:35:51 +00:00
Thomas Adam
8d67f8af24 Merge branch 'obsd-master' 2026-07-03 16:30:06 +01:00
Thomas Adam
0148ad5820 Merge branch 'obsd-master' 2026-07-03 16:15:06 +01:00
nicm
e1fc6b31ee Add manual width and height window formats. 2026-07-03 15:10:07 +00:00
Nicholas Marriott
47b90a4e03 Add single quote test. 2026-07-03 15:48:07 +01:00
nicm
cceca5a158 Add single quote operator. 2026-07-03 14:48:07 +00:00
Thomas Adam
88932f2d09 Merge branch 'obsd-master' 2026-07-03 12:15:06 +01:00
Nicholas Marriott
89a59d4df5 Bump version. 2026-07-03 11:50:24 +01:00
nicm
fa2c9f4551 Allow join-pane to tile floating panes, from Dane Jensen. 2026-07-03 10:47:32 +00:00
Nicholas Marriott
f645f0abe8 A few more tests. 2026-07-03 07:13:31 +01:00
Thomas Adam
f0ec51e78d Merge branch 'obsd-master' 2026-07-03 00:00:06 +01:00
nicm
2b8c3c1362 Enable swap-pane on floating panes again but not -U/-D. From Dane
Jensen.
2026-07-02 22:31:25 +00:00
Nicholas Marriott
dbb70b394e Fix test. 2026-07-02 23:28:15 +01:00
Nicholas Marriott
abcf8dca3a Put ASAN_OPTIONS in the right place. 2026-07-02 23:18:50 +01:00
Nicholas Marriott
351bef58a3 Undo last. 2026-07-02 23:06:55 +01:00
Thomas Adam
8d877421cf Merge branch 'obsd-master' 2026-07-02 23:00:06 +01:00
Nicholas Marriott
f592be00fa Do not require debug for ASAN. 2026-07-02 23:01:19 +01:00
Nicholas Marriott
352b1173c8 Fix. 2026-07-02 22:59:23 +01:00
Nicholas Marriott
bf0eee35f9 Fix. 2026-07-02 22:57:55 +01:00
Nicholas Marriott
228c9c9277 Tweak. 2026-07-02 22:57:14 +01:00
Nicholas Marriott
fa2a3b679a Use ASAN in tests. 2026-07-02 22:56:07 +01:00
Nicholas Marriott
d718b0eac7 More test fixes. 2026-07-02 22:53:53 +01:00
nicm
93039db58c Use message-style as default for message-format again. GitHub issue 5315. 2026-07-02 21:45:36 +00:00
nicm
6ebef7450a Do not double free or leak pane on failure, from Uzair Aftab in GitHub
issue 5316.
2026-07-02 21:40:05 +00:00
Nicholas Marriott
a82e09d1a3 Test fixes. 2026-07-02 22:12:14 +01:00
Thomas Adam
63a8af0e15 Merge branch 'obsd-master' 2026-07-02 12:00:06 +01:00
nicm
6b9b6c0b0b Copy UTF-8 data correctly. 2026-07-02 10:34:14 +00:00
Nicholas Marriott
390805d8b9 Make output nicer for tests. 2026-07-02 10:46:32 +01:00
Nicholas Marriott
70f37ef815 No vis.h in portable. 2026-07-02 10:28:48 +01:00
Nicholas Marriott
b6fca55447 Add tests for input path. 2026-07-02 10:26:25 +01:00
Thomas Adam
e22c56f02f Merge branch 'obsd-master' 2026-07-02 10:15:06 +01:00
Nicholas Marriott
01c86e64b7 No x flag. 2026-07-02 10:17:04 +01:00
Thomas Adam
ca81c36383 Merge branch 'obsd-master' 2026-07-02 10:00:06 +01:00
Nicholas Marriott
a9a04c7bc0 Targets tests. 2026-07-02 10:03:00 +01:00
nicm
0a81f4d742 Add a raw grid output to capture-pane for debugging and regression
tests.
2026-07-02 08:51:05 +00:00
nicm
0ad5035457 Do not crash if no client. 2026-07-02 08:47:25 +00:00
Nicholas Marriott
d626cef6de Environment tests. 2026-07-02 09:01:49 +01:00
Nicholas Marriott
7713cbebd2 Add options tests. 2026-07-02 08:15:22 +01:00
Nicholas Marriott
baf16f0419 Format tests. 2026-07-02 07:36:26 +01:00
Nicholas Marriott
9dcc2da348 Add format modifiers test. 2026-07-02 07:36:26 +01:00
Thomas Adam
f50a38de23 Merge branch 'obsd-master' 2026-07-01 22:15:06 +01:00
nicm
3ef51a469c move-pane needs -D. 2026-07-01 20:53:38 +00:00
Thomas Adam
d5688bf165 Merge branch 'obsd-master' 2026-07-01 21:30:06 +01:00
nicm
8dc9e24c74 Revert previous, it is not the right change. 2026-07-01 20:26:39 +00:00
nicm
735bbf9da7 Disable time expansion if expanding an inner format or more %s are
needed.
2026-07-01 20:18:05 +00:00
Nicholas Marriott
6ad86ebdf1 Merge branch 'release_3.7b' 2026-07-01 20:06:23 +01:00
Nicholas Marriott
3d58e04c93 no point in having stuff i cannot test 2026-07-01 19:05:24 +01:00
Nicholas Marriott
9fb67a2cdd Missing \. 2026-07-01 19:00:37 +01:00
Nicholas Marriott
d9d12c5c43 More tweaks. 2026-07-01 18:59:34 +01:00
Nicholas Marriott
728ad24d4a utf8proc. 2026-07-01 18:55:28 +01:00
Nicholas Marriott
5b37471db7 Spaces. 2026-07-01 18:53:37 +01:00
Nicholas Marriott
c41e98be3c yaml is poo. 2026-07-01 18:53:16 +01:00
Nicholas Marriott
35f429cb6d macOS too. 2026-07-01 18:52:47 +01:00
Nicholas Marriott
85fc0ea57c Add a test for regress. 2026-07-01 18:43:59 +01:00
Nicholas Marriott
6f588402c3 Remove a char which differs between platforms. 2026-07-01 18:43:01 +01:00
Nicholas Marriott
fada35478b Colours changed in tests. 2026-07-01 18:30:55 +01:00
Nicholas Marriott
bd5d7a8a7a Update prompt test. 2026-07-01 18:15:40 +01:00
Nicholas Marriott
8108356978 Update names test. 2026-07-01 18:02:45 +01:00
Nicholas Marriott
5e32eddb8c Fix up merge. 2026-07-01 18:00:15 +01:00
Thomas Adam
1818b6ac16 Merge branch 'obsd-master' 2026-07-01 17:52:07 +01:00
Nicholas Marriott
e802909de0 Fix so that the end of a synchronized update again triggers a redraw. 2026-07-01 17:49:40 +01:00
nicm
824ef37f5f Change layout sets to build the layout using the new mechanics, from
Dane Jensen.
2026-07-01 16:43:14 +00:00
nicm
565db46a19 Instead of fully redrawing the pane when sync ends, only redraw lines
that have been changed.
2026-07-01 15:44:13 +00:00
Thomas Adam
87aa44f4bc Merge branch 'obsd-master' 2026-07-01 14:30:07 +01:00
nicm
e9396e59d9 Add a couple of format c/f and c/b to emit colours. 2026-07-01 13:12:17 +00:00
Thomas Adam
002ac977f8 Merge branch 'obsd-master' 2026-07-01 09:15:07 +01:00
nicm
724f85d275 Do not draw to tty if PANE_REDRAW has been set since it is just going to
be replaced.
2026-07-01 07:48:48 +00:00
Thomas Adam
b3fa1c0b9c Merge branch 'obsd-master' 2026-07-01 07:30:06 +01:00
nicm
e69950a9ca Add overline for ghostty also, GitHub issue 5309. 2026-07-01 06:17:58 +00:00
Thomas Adam
41b4743eba Merge branch 'obsd-master' 2026-07-01 00:00:06 +01:00
nicm
1e9a16a748 And some other indentation. 2026-06-30 22:48:12 +00:00
nicm
74a5069c0a Fix some indentation. 2026-06-30 22:44:21 +00:00
Thomas Adam
8d470017bc Merge branch 'obsd-master' 2026-06-30 22:00:06 +01:00
Nicholas Marriott
928c7a9771 More checks for macOS. 2026-06-30 21:28:28 +01:00
nicm
eda7e563d0 Change a malloc to calloc. 2026-06-30 20:27:36 +00:00
Thomas Adam
90fc51542f Merge branch 'obsd-master' 2026-06-30 11:30:06 +01:00
nicm
f8674cc993 Add default features for Ghostty, GitHub issue 5305 from Glib Shpychka. 2026-06-30 10:07:05 +00:00
Thomas Adam
843adbf454 Merge branch 'obsd-master' 2026-06-30 10:30:06 +01:00
nicm
abefc3f705 Redraw when sync stops again (accidentally turned off), from Japin Li in
GitHub issue 5304.
2026-06-30 09:20:43 +00:00
Thomas Adam
dddd7b44c8 Merge branch 'obsd-master' 2026-06-30 08:15:06 +01:00
Nicholas Marriott
25c874c489 Merge branch 'release_3.7a' 2026-06-30 07:46:06 +01:00
Nicholas Marriott
0e418b62d2 Remove C-r from help. 2026-06-30 07:44:51 +01:00
nicm
a97f643bd3 Remove C-r from help since it does not in fact exist. 2026-06-30 06:44:46 +00:00
Nicholas Marriott
78a2145a47 Update CHANGES. 2026-06-30 07:42:25 +01:00
Nicholas Marriott
dbe50934b1 Add caching of scrollbar options to 3.7a branch. 2026-06-30 07:41:02 +01:00
Thomas Adam
543d104f85 Merge branch 'obsd-master' 2026-06-29 20:15:07 +01:00
nicm
e06207c914 Cache scrollbar options in window to avoid a slow lookup when working
out visible ranges.
2026-06-29 19:03:34 +00:00
nicm
166267c87a Allow :. in names again, forbidding them is overly pernickety. Only
forbid invalid UTF-8 and #(.
2026-06-29 19:53:42 +01:00
Thomas Adam
91e0737b8a Merge branch 'obsd-master' 2026-06-29 19:30:07 +01:00
nicm
65a032b205 Allow :. in names again, forbidding them is overly pernickety. Only
forbid invalid UTF-8 and #(.
2026-06-29 18:17:28 +00:00
Thomas Adam
80c7dcdbd7 Merge branch 'obsd-master' 2026-06-29 18:30:06 +01:00
nicm
bcd54d12d8 Add link=/nolink to styles to specific a hyperlink. GitHub issue 4280
from Moritz Angermann.
2026-06-29 17:08:52 +00:00
Thomas Adam
726e19a886 Merge branch 'obsd-master' 2026-06-29 18:00:06 +01:00
nicm
95719e342d Limit hyperlink URIs to 1024 bytes which seems enough and allows us not
to have to worry about gigantic URIs in styles, part of a change from
Moritz Angermann.
2026-06-29 16:44:06 +00:00
nicm
132a63d1da Allow empty window and session names. 2026-06-29 17:36:40 +01:00
Thomas Adam
822f700b15 Merge branch 'obsd-master' 2026-06-29 17:30:06 +01:00
nicm
5df51a06f5 Allow empty window and session names. 2026-06-29 16:20:45 +00:00
Nicholas Marriott
ad74c5ed7f Add additional grid consistency checks for macOS. 2026-06-29 10:20:38 +01: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
nicm
4e612612dc Only forbid #( in names and titles (styles are #[ and are useful). 2026-06-29 08:11:08 +01:00
Thomas Adam
705fbf92ee Merge branch 'obsd-master' 2026-06-28 21:49:05 +01:00
Nicholas Marriott
2dc704abb6 Always set SIXEL aspect ratio to 1:1, GitHub issue 5291 from James Holderness. 2026-06-28 17:01:52 +01:00
Nicholas Marriott
6c2ef75681 Bump version. 2026-06-28 16:54:51 +01:00
nicm
96899dc527 Only forbid #( in names and titles (styles are #[ and are useful). 2026-06-28 15:53:18 +00:00
Your Name
b0db912bde Update check-names test. 2026-06-28 16:52:28 +01:00
nicm
7cd33ce0dd Set view name immediately when entering mode. 2026-06-27 12:37:36 +00:00
nicm
e0dd40f812 Clear lines before writing in copy mode to avoid leaving stray text when
new line is shorter than old.
2026-06-27 12:27:43 +00:00
nicm
79f0f97495 Make split-window create a new floating pane if used in a floating pane,
rather than just complaining. Also improve documentation. From Dane
Jensen.
2026-06-27 10:23:14 +00:00
nicm
5e0b0a2aa3 Pulled code out of layout_split_pane for reuse and added
layout_insert_tile. From Dane Jensen.
2026-06-27 10:21:26 +00:00
nicm
e24969b422 Add a helper to swap a node into the place of a leaf, from Dane Jensen. 2026-06-27 10:18:32 +00:00
nicm
dd02989e88 Invalidate scene when changing window Z index, from Dane Jensen. 2026-06-27 10:16:15 +00:00
nicm
7383c04205 Preseve prompt flags across line clear, from Aung Myo Kyaw. 2026-06-27 10:05:38 +00:00
Nicholas Marriott
84291b021f Fix check so as to not use NULL name. 2026-06-27 10:58:39 +01:00
Thomas Adam
91e30f4f22 Merge branch 'obsd-master' 2026-06-26 21:15:06 +01:00
nicm
5be44a6c03 Use linked sessions not active. 2026-06-26 19:53:47 +00:00
Thomas Adam
8cc20a5618 Merge branch 'obsd-master' 2026-06-26 19:00:06 +01:00
Nicholas Marriott
81f88f8517 Add a missing {. 2026-06-26 18:55:59 +01:00
Nicholas Marriott
4eafb27b89 tmux 3.7. 2026-06-26 18:50:58 +01:00
Nicholas Marriott
4fc4644652 Tweak. 2026-06-26 18:50:42 +01:00
nicm
c0f213b056 Add info modes to tree mode like for clients. 2026-06-26 17:43:15 +00:00
Nicholas Marriott
a2915cfdef Fuzzy test. 2026-06-26 16:09:55 +01:00
Thomas Adam
4b921f3821 Merge branch 'obsd-master' 2026-06-26 15:56:03 +01:00
nicm
575f84ce0f Add switch-mode a fast switcher with fuzzy searching, bound to Tab (for
windows) or BTab (S-Tab, for sessions) by default.
2026-06-26 14:40:30 +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
445677dc00 Merge branch 'obsd-master' 2026-06-26 14:15:06 +01:00
Thomas Adam
da27529d91 Merge branch 'obsd-master' 2026-06-26 14:00:06 +01:00
nicm
f59921ce18 Use underscore for current in status line. 2026-06-26 12:52:36 +00:00
nicm
ec3c65122f message-command-style should be inverse of message-style. 2026-06-26 12:41:08 +00:00
Thomas Adam
9fa5e81836 Merge branch 'obsd-master' 2026-06-26 13:15:06 +01:00
nicm
4869a5165a Add tree-mode-selection-style to continue the process of moving away
from mode-style.
2026-06-26 12:06:17 +00:00
Thomas Adam
30e84ff687 Merge branch 'obsd-master' 2026-06-26 13:00:09 +01:00
nicm
73fd01c986 Some colour fixes and tweaks (marked pane, cursor colours now work). 2026-06-26 11:36:22 +00:00
Thomas Adam
3729af7438 Merge branch 'obsd-master' 2026-06-26 12:00:06 +01:00
Nicholas Marriott
1e5aef279a Update tests for colour/position changes. 2026-06-26 11:37:36 +01:00
nicm
19db019e0c Do not force theme colours to default when capturing. 2026-06-26 10:29:38 +00:00
Nicholas Marriott
666464d7a9 Add X11 colours script. 2026-06-26 11:28:15 +01:00
Thomas Adam
391f880d07 Merge branch 'obsd-master' 2026-06-26 11:15:06 +01:00
nicm
d0bf3bf06d Add ability to float a tiled pane to break-pane, from Dane Jensen. 2026-06-26 10:02:01 +00:00
Thomas Adam
edb027e910 Merge branch 'obsd-master' 2026-06-26 11:00:07 +01:00
nicm
dd2fef6673 Do not count arguments starting - as optional arguments, makes old
resize-pane syntax work. GitHub issue 5275, based on a changed from Dane
Jensen.
2026-06-26 09:54:56 +00:00
nicm
8e79c4a03d Bump style buffer to 1024, GitHub issue 5279 from Moritz Angermann. 2026-06-26 09:38:44 +00:00
Thomas Adam
19d70a85fc Merge branch 'obsd-master' 2026-06-26 09:30:07 +01:00
nicm
f5e9bcc1fc Another couple of bits look nicer in grey. 2026-06-26 08:19:44 +00:00
nicm
3631f81236 Apply better colours to various builtin bits in modes. 2026-06-26 08:10:48 +00:00
Thomas Adam
1e6f64d5c9 Merge branch 'obsd-master' 2026-06-26 01:00:06 +01:00
nicm
569e9d932f Make the default colours more conservative, its really the greys that
matter.
2026-06-25 23:48:20 +00:00
Thomas Adam
6a7f4a1894 Merge branch 'obsd-master' 2026-06-26 00:30:07 +01:00
nicm
8c55a388cd Add nicer dark and light colour sets (themes) used on terminals with 256
or more colours. Currently based these on emacs but they could change.
Terminals with fewer colours use the ANSI colours. A new "theme" option
overrides the detected theme (set to "terminal" to go back to ANSI
colours).
2026-06-25 23:17:25 +00:00
Thomas Adam
d176f1f89c Merge branch 'obsd-master' 2026-06-25 18:30:06 +01:00
nicm
2d0845860a Fix scrollbar with a format colour. 2026-06-25 17:17:25 +00:00
Thomas Adam
5ae701aab5 Merge branch 'obsd-master' 2026-06-25 18:00:06 +01:00
nicm
0d016195ac Expand colours as formats like styles. 2026-06-25 16:32:42 +00:00
Thomas Adam
fc2de240d2 Merge branch 'obsd-master' 2026-06-25 15:30:06 +01:00
nicm
7c1ef6a387 Format variable for client colours. 2026-06-25 14:27:58 +00:00
Thomas Adam
0b538b6f2a Merge branch 'obsd-master' 2026-06-25 13:29:53 +01:00
Your Name
3d26aa0dfb Prompt regress (will not pass yet). 2026-06-25 12:40:49 +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
Nicholas Marriott
e5fb88fb85 Merge pull request #5273 from daneofmanythings/floating-geometry-regression-test
test(master): Added regression test for floating pane geometry.
2026-06-25 10:23:01 +01:00
Thomas Adam
787234eff4 Merge branch 'obsd-master' 2026-06-24 23:00:06 +01:00
nicm
6b1219b370 Ignore mouse when help is open. 2026-06-24 21:47:06 +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
Dane Jensen
6935dee976 Added regression test for floating pane geometry and how it interacts
with pane borders.
2026-06-24 13:48:17 -07:00
Thomas Adam
12473bb6d3 Merge branch 'obsd-master' 2026-06-24 12:15:06 +01:00
nicm
280a962328 Replace two-value prompt_mode enum with a flag. 2026-06-24 11:05:58 +00:00
nicm
37633ff957 Add some enums for prompt return values to make them a bit less confusing. 2026-06-24 10:55:39 +00:00
Thomas Adam
1c2fc8c3c4 Merge branch 'obsd-master' 2026-06-24 10:15:06 +01:00
Thomas Adam
d3adecd819 Merge branch 'obsd-master' 2026-06-24 10:00:06 +01:00
nicm
0a71af41be Handle different borders in move-pane, from Dane Jensen. 2026-06-24 08:52:15 +00:00
nicm
8fb484da37 Remove target completion which never worked very well, leave only
command completion.
2026-06-24 08:35:46 +00:00
Nicholas Marriott
6e6a434a2d Remove no longer needed test bits. 2026-06-24 09:24:18 +01:00
Thomas Adam
f23ea9e977 Merge branch 'obsd-master' 2026-06-24 01:15:06 +01:00
nicm
55cfdbaa3f Remove fuzzy match operator again for now, this will be done differently. 2026-06-23 23:53:06 +00:00
nicm
1b5a07a740 Rename prompt-input to match the usual format names. 2026-06-23 23:52:39 +00:00
Thomas Adam
00b0af7021 Merge branch 'obsd-master' 2026-06-23 22:15:06 +01:00
nicm
89027bd22c Fix MOVE flag handling and remove key code (not actually needed). 2026-06-23 21:00:20 +00:00
Thomas Adam
ff8de1a106 Merge branch 'obsd-master' 2026-06-23 22:00:05 +01:00
nicm
0c5e6770df Turn off preview if no draw callback and add a function to move to top. 2026-06-23 20:30:10 +00:00
Thomas Adam
c2ad33a04c Merge branch 'obsd-master' 2026-06-23 21:15:06 +01:00
nicm
c0a5e10313 Use flags for input callback instead of a single int done so the
callback can be told about cursor movement in an incremental prompt.
2026-06-23 20:07:58 +00:00
Nicholas Marriott
1c394b8606 Tweak the test. 2026-06-23 20:31:42 +01:00
Nicholas Marriott
505d557fbb Fix SIXEL, from Marc Haesen. 2026-06-23 15:48:02 +01: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
Thomas Adam
c25cb107bb Merge branch 'obsd-master' 2026-06-23 10:30:05 +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
nicm
3ec115115d Do not leak error message, use it instead. From Dane Jensen. 2026-06-23 09:13:30 +00:00
Thomas Adam
09c91b8931 Merge branch 'obsd-master' 2026-06-23 10:00:05 +01:00
Nicholas Marriott
de1940065a Update test. 2026-06-23 10:01:01 +01:00
nicm
748ef8b2ae Extend match to do multiple terms. 2026-06-23 08:35:28 +00:00
Thomas Adam
2ecf0a9053 Merge branch 'obsd-master' 2026-06-23 09:30:05 +01:00
nicm
b82048eb18 Add c key to clear filter. 2026-06-23 08:20:15 +00:00
Nicholas Marriott
9d58ff97fe Update format test. 2026-06-23 09:14:13 +01:00
Nicholas Marriott
51b787e449 Fix SIXEL build. 2026-06-23 09:06:43 +01:00
Nicholas Marriott
7654b518f1 Add to .gitignore. 2026-06-23 08:36:07 +01:00
nicm
e7f414416f Set check callback for menus so they aren't overwritten by sync. 2026-06-23 08:35:09 +01:00
Thomas Adam
52877c9af1 Merge branch 'obsd-master' 2026-06-23 07:35:51 +01:00
nicm
265f22be49 Make cursor movement exit incremental prompt (more like emacs). 2026-06-22 19:43:22 +00:00
nicm
2a26c738bd Add z modifier to m operator for fuzzy match. 2026-06-22 19:39:01 +00:00
nicm
02b37b3c69 Fix scrollbar pad to work even if not set in style. 2026-06-22 13:57:33 +00:00
nicm
d8370864f3 Memory leak from someone in GitHub issue 5259. 2026-06-22 12:39:56 +00:00
Nicholas Marriott
ffe48f00e3 Tests for screen-redraw.c (not all passing right now). 2026-06-22 12:09:44 +01:00
nicm
49dff83a00 Set check callback for menus so they aren't overwritten by sync. 2026-06-22 10:17:08 +00: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
06ee890db3 Merge branch 'obsd-master' 2026-06-22 09:30:06 +01:00
nicm
e680420c89 Place floating cells meaningfully into the layouts, from Dane Jensen. 2026-06-22 08:10:16 +00:00
Thomas Adam
357ee692bd Merge branch 'obsd-master' 2026-06-21 19:00:05 +01:00
nicm
347baa6f3e Do not walk off end or beginning of menu item list if every item is
disabled, GitHub issue 5255 from aizumusheer2 at gmail dot com.
2026-06-21 17:43:47 +00:00
Thomas Adam
cc922de758 Merge branch 'obsd-master' 2026-06-20 10:15:05 +01:00
Thomas Adam
dbca906ef5 Merge branch 'obsd-master' 2026-06-20 10:00:05 +01:00
nicm
1fc4dcb76f Error if key is unknown rather than just carry on, GitHub issue 5248. 2026-06-20 08:51:28 +00:00
nicm
dcd7d1c8e6 Fix {} keys in tmux.1, pointed out by tb. 2026-06-20 08:46:08 +00:00
Thomas Adam
72e768ef14 Merge branch 'obsd-master' 2026-06-19 20:00:06 +01:00
nicm
047f61aad6 popup_write can be deleted now also. 2026-06-19 18:41:36 +00:00
nicm
d04b1ffca5 Use a floating pane for the buffer mode editor instead of a popup. 2026-06-19 18:37:10 +00:00
nicm
c93e2f2332 Do not loop forever if a pane ends up with borders the wrong way round. 2026-06-19 18:28:18 +00:00
Thomas Adam
e7c29d0ceb Merge branch 'obsd-master' 2026-06-19 19:00:05 +01:00
nicm
6c46358be8 Draw help directly instead of using a popup. 2026-06-19 17:37:26 +00:00
Thomas Adam
b0ff8af9ac Merge branch 'obsd-master' 2026-06-19 17:30:05 +01:00
nicm
624db256c6 Add a loop_index variable and use it to show last used 5 sessions on the
session menu instead of next/previous.
2026-06-19 16:25:43 +00:00
Thomas Adam
cfb15d158e Merge branch 'obsd-master' 2026-06-19 17:15:05 +01:00
Thomas Adam
34c7881ddd Merge branch 'obsd-master' 2026-06-19 17:00:05 +01:00
nicm
f06d930445 Correctly report theme changes to panes, based on a fix from someone in
GitHub issue 5246.
2026-06-19 16:00:03 +00:00
nicm
b29f5688bd Make default M-C-Up/Down bound to prompt movement commands in copy mode. 2026-06-19 15:28:26 +00:00
Thomas Adam
333e2f266a Merge branch 'obsd-master' 2026-06-19 12:00:07 +01:00
Nicholas Marriott
af94399473 Add some more bits to test. 2026-06-19 11:50:29 +01:00
Nicholas Marriott
3d35f26031 Add a test for tty_draw_line. 2026-06-19 11:43:43 +01:00
nicm
b1c72ec48c Use a helper and skip some setup for empty cells. 2026-06-19 10:38:29 +00:00
Thomas Adam
8dee34459b Merge branch 'obsd-master' 2026-06-19 11:15:06 +01:00
nicm
e7f649e40a Tidy up a bit in tty_draw_line. 2026-06-19 09:56:53 +00:00
Thomas Adam
5843fbc6ee Merge branch 'obsd-master' 2026-06-19 09:30:06 +01:00
Nicholas Marriott
c8eca3a69d Add command-alias.sh test, from tanushnry at gmail dot com. 2026-06-19 09:29:41 +01:00
Nicholas Marriott
12fdcea8b8 Get use of raster attributes in the right order, from aizumusheer2 at gmail dot
com in GitHub issue 5225.
2026-06-19 09:24:48 +01:00
nicm
035447b08f Do not dereference the current window if it is NULL (can be if the
notification fires after session is destroyed). GitHub issue 5244 from
Ben Maurer.
2026-06-19 08:21:55 +00:00
Thomas Adam
55b2e748e7 Merge branch 'obsd-master' 2026-06-18 13:15:05 +01:00
Thomas Adam
3246331876 Merge branch 'obsd-master' 2026-06-18 13:00:05 +01:00
Nicholas Marriott
6d9fbb0e97 Update regress for format changes. 2026-06-18 12:55:13 +01:00
nicm
14fc4a06a6 Unescape arguments before passing to format_expand1 so that escaping :s
etc actually works.
2026-06-18 11:54:37 +00:00
nicm
cba4ba9cdc Check time periodically in loops rather than every one. 2026-06-18 11:45:08 +00:00
Thomas Adam
937d99150c Merge branch 'obsd-master' 2026-06-18 12:15:05 +01:00
nicm
0a6c846091 Use evbuffer for building S, W, L lists, also add an xmemdup helper
instead of misusing asprintf.
2026-06-18 10:56:22 +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
f242182840 Merge branch 'obsd-master' 2026-06-18 10:30:05 +01:00
Thomas Adam
f5871369cc Merge branch 'obsd-master' 2026-06-18 10:15:06 +01:00
nicm
b1b184cdb8 Add functions to work out cell neighbours, and to remove a tiled cell.
From Dane Jensen.
2026-06-18 09:11:24 +00:00
nicm
1a6de01210 Check the panes again if deferred redraw to make sure the flag is always
set. Also add a helper for the loop.
2026-06-18 08:56:07 +00:00
Thomas Adam
1dd2589a42 Merge branch 'obsd-master' 2026-06-17 14:30:05 +01:00
nicm
3485e1c089 Tidy up server_client_check_redraw. Get rid of the bitmask tracking
panes which want redraw for deferred clients - if they are deferred then
they can just have a full redraw instead. Also return earlier if no
redraw is actually needed, and improve the comments.
2026-06-17 13:22:48 +00:00
Thomas Adam
6f7965e4f1 Merge branch 'obsd-master' 2026-06-17 14:00:05 +01:00
nicm
1ba8fa6f04 Fix shifts to 1ULL and check scrollbar even if pane is not being redrawn. 2026-06-17 12:32:54 +00:00
Thomas Adam
6eb67fcc5f Merge branch 'obsd-master' 2026-06-17 09:15:05 +01:00
nicm
3b8e25fef4 Initialize wname so it we are not freeing garbage if it is not used. 2026-06-17 09:11:00 +01:00
nicm
64e83caf04 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-17 09:10:55 +01:00
Thomas Adam
a8abea8247 Merge branch 'obsd-master' 2026-06-17 09:00:07 +01:00
nicm
d4defd943a Add -M to move-pane and default bindings for M-drag. From Michael Grant. 2026-06-17 07:52:21 +00:00
nicm
eafd2bed5d FIx a couple of minor errors in use of layout_cell_is_tiled. 2026-06-17 07:43:55 +00:00
Thomas Adam
6549765930 Makefile: add window-visible.c 2026-06-16 12:55:41 +01:00
Thomas Adam
6cb2233cd2 Merge branch 'obsd-master' 2026-06-16 12:55:00 +01:00
nicm
9ad75e1dc3 Rename the visible ranges functions since they really relate to windows
and put them nto a new file.
2026-06-16 10:47:35 +00:00
nicm
762e503978 Allow rectangle selection to extend past end of current line to behave
the same as vi with virtualedit=block set. From Mark Kelly in GitHub
issue 5227.
2026-06-16 11:11:47 +01:00
Thomas Adam
bec0f7d975 Merge branch 'obsd-master' 2026-06-16 11:00:05 +01:00
nicm
4b772fd783 Allow rectangle selection to extend past end of current line to behave
the same as vi with virtualedit=block set. From Mark Kelly in GitHub
issue 5227.
2026-06-16 09:28:17 +00:00
Nicholas Marriott
c809aea278 Fix a merge problem. 2026-06-16 10:24:06 +01:00
Nicholas Marriott
1596f9c9f5 Bump version again. 2026-06-16 10:22:51 +01:00
nicm
2f28d9a168 Fix resizing floating pane with a left scrollbar, from Michael Grant. 2026-06-16 10:22:12 +01:00
Nicholas Marriott
baac29debc Prefer libtinfow if it is available, GitHub issue 5224 from Lars Wendler. 2026-06-16 10:21:12 +01:00
nicm
2c4df765c5 Fix missing border when drawing floating panes. From Michael Grant. 2026-06-16 10:21:09 +01:00
Thomas Adam
1d026b921c Merge branch 'obsd-master' 2026-06-16 10:15:14 +01:00
nicm
fcbb6a7384 Initialize wname so it we are not freeing garbage if it is not used. 2026-06-16 09:00:25 +00:00
nicm
bdc01f44de Fix resizing floating pane with a left scrollbar, from Michael Grant. 2026-06-16 08:57:07 +00:00
nicm
d2c23773ff Fix missing border when drawing floating panes. From Michael Grant. 2026-06-16 08:53:14 +00:00
Nicholas Marriott
38dc3ec0da Prefer libtinfow if it is available, GitHub issue 5224 from Lars Wendler. 2026-06-16 09:48:04 +01:00
Thomas Adam
c03acc9572 Merge branch 'obsd-master' 2026-06-16 08:15:07 +01:00
nicm
30e133d36a Fix default window check in break-pane, from Dane Jensen. 2026-06-16 07:07:49 +00:00
nicm
0890df5891 Add layout_cell_is_tiled and layout_cell_has_tiled_child helper
functions, from Dane Jensen.
2026-06-16 07:06:32 +00:00
Thomas Adam
d223a49d18 Merge branch 'obsd-master' 2026-06-16 06:15:05 +01:00
jsg
26285e183e botton -> bottom 2026-06-16 05:01:56 +00:00
Thomas Adam
408e9f1481 Merge branch 'obsd-master' 2026-06-15 23:00:06 +01:00
Nicholas Marriott
7c8344930b Add a test for names. 2026-06-15 22:47:39 +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
2d9afa6348 Use correct x position when drawing clipped line. 2026-06-15 18:39:43 +01:00
nicm
bae5c14941 Tidy up screen_redraw_get_visible_ranges by using a couple of
temporaries for start and end of range.
2026-06-15 18:39:28 +01:00
nicm
9cf8de099c Convert cursor position back to pane coordinates for tty_cmd_cell. 2026-06-15 18:39:23 +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
c156e597dc Merge branch 'obsd-master' 2026-06-15 16:15:07 +01:00
nicm
bb750b07bc If the client is blocked, defer the redraw because it may end up
partially discarded leading to redraw artifacts.
2026-06-15 15:05:12 +00:00
nicm
0e6fe5a097 Convert cursor position back to pane coordinates for tty_cmd_cell. 2026-06-15 14:56:30 +00:00
Thomas Adam
13de7cafb2 Merge branch 'obsd-master' 2026-06-15 13:30:08 +01:00
nicm
057b688fc7 Tidy up screen_redraw_get_visible_ranges by using a couple of
temporaries for start and end of range.
2026-06-15 12:07:49 +00:00
Thomas Adam
45bb3e7ffc Merge branch 'obsd-master' 2026-06-15 13:00:05 +01:00
nicm
8ced9c332c Use correct x position when drawing clipped line. 2026-06-15 11:45:51 +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
nicm
f98aaf544d When redrawing a whole pane line, fall into tty_draw_line for any
characters that are not plain ASCII. Fixes redraw issues with partial
tabs and other wide characters when a pane is partly outside the window.
2026-06-15 09:07:23 +01:00
nicm
78afc24736 Fix various errors in redrawing:
- Fix the active pane colour when only two panes and scrollbars enabled.

- Clip left and right scrollbars the same for floating panes.

- Do not subtract scrollbar width twice when working out width of status
  line.

- Check if a character is inside a visible range correctly (do not
  include the next position outside the range).
2026-06-15 09:06:58 +01:00
nicm
83e4534387 Skip floating panes when working out the top or bottom cell. Fixes
missing bottom status pane status line when floating panes exist.
2026-06-15 09:06:55 +01:00
Thomas Adam
aed9018807 Merge branch 'obsd-master' 2026-06-15 09:00:05 +01:00
nicm
97b5f22a70 When redrawing a whole pane line, fall into tty_draw_line for any
characters that are not plain ASCII. Fixes redraw issues with partial
tabs and other wide characters when a pane is partly outside the window.
2026-06-15 07:40:45 +00:00
Thomas Adam
748dab2f38 Merge branch 'obsd-master' 2026-06-14 22:15:05 +01:00
Thomas Adam
3c11129b04 Merge branch 'obsd-master' 2026-06-14 22:00:05 +01:00
nicm
6e0e343f23 Fix various errors in redrawing:
- Fix the active pane colour when only two panes and scrollbars enabled.

- Clip left and right scrollbars the same for floating panes.

- Do not subtract scrollbar width twice when working out width of status
  line.

- Check if a character is inside a visible range correctly (do not
  include the next position outside the range).
2026-06-14 20:53:20 +00:00
nicm
cc27470cb6 Skip floating panes when working out the top or bottom cell. Fixes
missing bottom status pane status line when floating panes exist.
2026-06-14 20:37:57 +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
863923472a Merge branch 'obsd-master' 2026-06-14 20:15:07 +01:00
nicm
778a15b64a Take account of borders when resizing floating panes. 2026-06-14 18:59:15 +00:00
Thomas Adam
5eaf5570c4 Merge branch 'obsd-master' 2026-06-14 10:00:06 +01:00
Nicholas Marriott
cbe0f1f1e9 Another const from Jere Viikari. 2026-06-14 09:50:50 +01:00
nicm
97472e374f Return early if connect construct cell, reported by Jere Viikari. 2026-06-14 08:47:44 +00:00
Thomas Adam
7a28aa0dd7 Merge branch 'obsd-master' 2026-06-13 22:00:06 +01:00
nicm
b1054ac227 With mode-keys vi, keep cursor in the same position relative to the text
when scrolling. GitHub issue 5216 from Arseniy Simonov.
2026-06-13 20:39:11 +00:00
Thomas Adam
1618b98533 Merge branch 'obsd-master' 2026-06-13 21:15:06 +01:00
nicm
5b6ed54817 Add some missing const, from Jere Viikari. 2026-06-13 20:07:30 +00:00
nicm
d23a2b7e97 Skip floating cells when moving to previous cell for resize of tiled cells. 2026-06-13 20:03:10 +00:00
nicm
ab92b27226 Make the resize keys always change right and bottom borders for floating
panes which is more intuitive.
2026-06-13 19:57:44 +00:00
Thomas Adam
eb6efdf17a Merge branch 'obsd-master' 2026-06-13 20:00:06 +01:00
nicm
b182791052 Tidy up error messages from split-window. 2026-06-13 18:30:16 +00:00
Thomas Adam
97a7f174ce Merge branch 'obsd-master' 2026-06-13 19:15:06 +01:00
nicm
654758e622 Add move-pane -z to move a pane to a particular the z-index. 2026-06-13 18:06:01 +00:00
Thomas Adam
c8887a5846 Merge branch 'obsd-master' 2026-06-13 19:00:06 +01:00
nicm
56779f9542 Add Z index positions to move-pane -P. 2026-06-13 17:43:20 +00:00
Thomas Adam
f474838e22 Merge branch 'obsd-master' 2026-06-13 18:30:06 +01:00
nicm
19393e13db Add -P to move-pane to move a floating pane to a specific place
(top-left, bottom-right). Get rid of the not-so-useful default { and }
swap-pane bindings and use the keys instead for moving to top-left,
top-right and add M-{ and M-} for bottom-left, bottom-right.
2026-06-13 17:12:02 +00:00
Thomas Adam
301b10de8d Merge branch 'obsd-master' 2026-06-13 17:30:06 +01:00
nicm
aa2fd3a151 Add flags to move-pane to move floating panes around (-U, -D, -L, -R
similar to resize-pane; -X, -Y similar to new-pane).
2026-06-13 16:16:18 +00:00
Thomas Adam
2dd604949f Merge branch 'obsd-master' 2026-06-13 14:15:06 +01:00
nicm
ec481ac82a Missed this one as well. 2026-06-13 13:07:12 +00:00
nicm
7afee45635 Use correct name for activity time. 2026-06-13 13:06:12 +00:00
Thomas Adam
385d18590a Merge branch 'obsd-master' 2026-06-13 13:00:06 +01:00
nicm
bc9252f6e3 Remove some stray code from an old floating panes implementation, from
Dane Jensen.
2026-06-13 11:37:46 +00:00
Thomas Adam
6c76f2a7c7 Merge branch 'obsd-master' 2026-06-13 12:00:06 +01:00
nicm
bf187170b1 Extend client mode so the preview can be changed to a view with a
summary of the client terminal and its features, intended to make
troubleshooting easier. "choose-client -i" or the "i" key in the mode.
2026-06-13 10:32:54 +00:00
Thomas Adam
14837e8e0f Merge branch 'obsd-master' 2026-06-13 10:30:06 +01:00
nicm
b44cdf1006 Add an I format modifier to get some bits of information about a client
(terminal features, capabilities and environment).
2026-06-13 09:17:29 +00:00
Thomas Adam
5d73f90133 Merge branch 'obsd-master' 2026-06-13 10:15:06 +01:00
nicm
34a6a9d3a1 Change relative time for now to only work in the past and not show a
sign which is more useful. Also tidy up some minor style nits.
2026-06-13 08:59:52 +00:00
Thomas Adam
f92a4e611b Merge branch 'obsd-master' 2026-06-12 14:30:06 +01:00
jsg
b3deb9ec86 fix tty_draw_line() indentation; ok nicm@ 2026-06-12 13:16:36 +00:00
nicm
dabaae1534 Make buffer creation time sort oldest first like it used to, but change
windows to match sessions and panes as newest first.
2026-06-12 10:19:05 +01:00
Nicholas Marriott
a92653f2b2 base -> bash from tanushnry at gmail dot com. 2026-06-12 10:18:44 +01:00
Thomas Adam
29cdab650b Merge branch 'obsd-master' 2026-06-12 00:15:06 +01:00
nicm
574a4eccb5 Make buffer creation time sort oldest first like it used to, but change
windows to match sessions and panes as newest first.
2026-06-11 23:01:31 +00:00
Thomas Adam
42c0641daf Merge branch 'obsd-master' 2026-06-11 21:15:06 +01:00
nicm
11b6e7844a When MODE_SYNC is on, all terminal updates need to deferred, not just
scrolling. Check the flag before each one. GitHub issue 4983.
2026-06-11 19:50:23 +00:00
Thomas Adam
f1b67152af Merge branch 'obsd-master' 2026-06-11 20:30:06 +01:00
nicm
b6be437bab Change send-keys -K to insert keys in the right place in the queue, like
we already do for key bindings. GitHub issue 3476.
2026-06-11 19:13:34 +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
dc22196394 Merge branch 'obsd-master' 2026-06-11 11:30:06 +01:00
nicm
3ea458b9dc Add support for floating panes to resize-pane, from Dane Jensen. 2026-06-11 10:16:19 +00:00
Thomas Adam
86128a7f06 Merge branch 'obsd-master' 2026-06-11 09:15:09 +01:00
nicm
de60750506 Hide Swap Marked also since floating panes cannot be swapped yet. 2026-06-11 07:52:17 +00:00
Thomas Adam
f07ac3068b Merge branch 'obsd-master' 2026-06-10 20:00:06 +01:00
nicm
7ec94fda08 Make list-keys only use a message if -1 is given, otherwise behave like
other commands (stdout or mode).
2026-06-10 18:32:33 +00:00
Thomas Adam
9231c80cd8 Merge branch 'obsd-master' 2026-06-10 17:15:07 +01:00
nicm
4702e58ee5 Fix text to refer to status-keys not mode-keys, GitHub issue 5191. 2026-06-10 16:08:03 +00: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
cd26f29fb8 Merge branch 'obsd-master' 2026-06-10 16:15:11 +01:00
Thomas Adam
9c350af582 Merge branch 'obsd-master' 2026-06-10 16:00:11 +01:00
nicm
c019b3dad9 Use correct size when calculating status line right trim. GitHub issue
5098 from Aung Myo Kyaw.
2026-06-10 14:51:20 +00:00
nicm
8cb4aabb8b Replace refresh-from-pane in copy mode with a way to automatically
update as pane content changes. This is toggled by pressing r. GitHub
issue 5165 from Barrett Ruth.
2026-06-10 14:29:08 +00:00
Thomas Adam
7ad8b3366d Merge branch 'obsd-master' 2026-06-10 15:15:08 +01:00
nicm
c6c8f77bc0 While grouped sessions are being killed, it can leave session which are
not really useful as targets (no active pane or current window) in the
tree. Make cmd_find_best_session skip these. GitHub issue 5167.
2026-06-10 14:06:45 +00:00
Nicholas Marriott
f415a70c0b Merge two SIXEL blocks. 2026-06-10 14:17:10 +01:00
Thomas Adam
da31d94c2a Merge branch 'obsd-master' 2026-06-10 08:50:17 +01:00
nicm
5c0db5a293 Preserve the original text in the first line for display-panes. 2026-06-09 21:31:16 +00:00
nicm
d533d7c97c Add a context for cell/palette/hyperlinks when drawing to tty to avoid
passing so much in parameters.
2026-06-09 21:22:22 +00:00
Thomas Adam
490802099d Merge branch 'obsd-master' 2026-06-09 14:15:07 +01:00
nicm
34dd42dc7f Use name as marker for failure not type (which must be set to be in the error). 2026-06-09 12:58:40 +00:00
nicm
b374868750 Add missing headers. 2026-06-09 12:57:40 +00:00
nicm
538688486e Clarify -a for kill-window, kill-session. 2026-06-09 12:51:57 +00:00
Thomas Adam
27111bd76d Merge branch 'obsd-master' 2026-06-09 13:30:06 +01:00
nicm
4a3f380fd2 Add -f for filter with -a to kill-pane, kill-window, kill-session.
GitHub issue 4782.
2026-06-09 12:24:59 +00:00
nicm
cc87db74c7 Two fixes for RI codepoints. Firstly, do not combine more than two of
them - previously we were ending up with four codepoints in one cell
which tmux believed to be width 2, but terminals considered width 4.
Secondly, invalidate cursor position before redrawing the cell when the
second codepoint is received, terminals vary in how they manage
backspace and cursor movement across these characters, so it is better
to use absolute rather than relative positioning. GitHub issue 4853.
2026-06-09 13:20:14 +01:00
Thomas Adam
4ec7e66e90 Merge branch 'obsd-master' 2026-06-09 13:15:06 +01:00
nicm
a42e425d44 Two fixes for RI codepoints. Firstly, do not combine more than two of
them - previously we were ending up with four codepoints in one cell
which tmux believed to be width 2, but terminals considered width 4.
Secondly, invalidate cursor position before redrawing the cell when the
second codepoint is received, terminals vary in how they manage
backspace and cursor movement across these characters, so it is better
to use absolute rather than relative positioning. GitHub issue 4853.
2026-06-09 11:49:36 +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
Nicholas Marriott
aa1f0653e9 Bump version to 3.7-rc2. 2026-06-09 09:47:18 +01:00
Thomas Adam
97156f3382 Merge branch 'obsd-master' 2026-06-09 09:30:06 +01:00
nicm
8771b6051f 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-09 09:12:21 +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
6f683da2e9 Merge branch 'obsd-master' 2026-06-08 23:00:06 +01:00
nicm
a6a06c5aa6 Fix squash-groups skipping every session, GitHub issue 5180 from Bryce
Miller.
2026-06-08 21:46:19 +00:00
nicm
4d1ab1ba2a Allow ACLs to use groups as well as users, GitHub issue 4917. 2026-06-08 21:38:19 +00:00
Thomas Adam
d7a6a8e35b Merge branch 'obsd-master' 2026-06-08 22:30:06 +01:00
nicm
bf2e078ecf Add a relative time option for time formatting, GitHub issue 5009. 2026-06-08 21:19:52 +00:00
Thomas Adam
a25ce36925 Merge branch 'obsd-master' 2026-06-08 22:15:06 +01:00
nicm
a0f4038df2 Add a -h flag to choose-tree and choose-client to hide the pane
containing the mode, intended for use with floating panes. From Michael
Grant, GitHub issue 5177.
2026-06-08 21:01:33 +00:00
Thomas Adam
7d8c1ae295 Merge branch 'obsd-master' 2026-06-08 22:00:07 +01:00
nicm
df7c2e605b Add -T to new-pane to set the title; GitHub issue 5176 from Michael Grant. 2026-06-08 20:44:57 +00:00
nicm
ea51cdb3f2 Add display-panes-format to change the top-of-pane text shown with
display-panes.
2026-06-08 20:42:39 +00:00
nicm
fe986a52d6 When entering or leaving the alternate screen, discard any pending
resizes. Improves flicking with scrollbars and programs that leave and
enter the alternate screen on every WINCH like nano. GitHub issue 4772.

Cvs: ----------------------------------------------------------------------
2026-06-08 20:41:21 +00: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
Nicholas Marriott
bbd4768bb6 3.7-rc version. 2026-06-08 21:08:37 +01:00
Thomas Adam
cb237b5193 Merge branch 'obsd-master' 2026-06-08 16:30:06 +01:00
nicm
85d72b9952 Return immediately if the list is empty in mode_tree_key instead of
crashing, from Bryce Miller in GitHub issue 5170.
2026-06-08 15:16:21 +00:00
Thomas Adam
a04c33c42d Merge branch 'obsd-master' 2026-06-07 21:15:06 +01:00
nicm
529afada82 Move checking of whether the cursor is visible inside the if so that it
always hits the calculation of the oy offset when the status line is at
the top. From Michael Grant.
2026-06-07 20:05:16 +00:00
nicm
a532f4868f Add -H flag to capture-pane to show hyperlinks. 2026-06-07 20:03:02 +00:00
Thomas Adam
e1d37c37b5 Merge branch 'obsd-master' 2026-06-07 17:30:06 +01:00
nicm
ae5e0e8c05 Add -L to show line numbers with capture-pane and -F to show line flags. 2026-06-07 16:23:05 +00:00
Nicholas Marriott
bbea0ef439 Update copy mode vi test, from Max Vim. 2026-06-07 17:22:14 +01:00
Nicholas Marriott
a134c43f4d Update test result. 2026-06-07 16:15:32 +01:00
Nicholas Marriott
e0ebae4481 Fix a couple of tests and add -f/dev/null to them all. 2026-06-07 16:11:38 +01:00
Thomas Adam
1fbc51b69f Merge branch 'obsd-master' 2026-06-07 16:00:06 +01:00
nicm
42f3e7f7ce Clear entire lines when removing from history or freeing. 2026-06-07 14:41:27 +00:00
Thomas Adam
e163cbacec Merge branch 'obsd-master' 2026-06-07 15:30:06 +01:00
Nicholas Marriott
0ec6870902 Add to CHANGES. 2026-06-07 15:24:53 +01:00
Thomas Adam
55421ede70 Merge branch 'obsd-master' 2026-06-07 15:15:06 +01:00
nicm
3acd247f5d Redraw entire session when making a new pane. 2026-06-07 14:11:20 +00:00
Thomas Adam
59151704b4 Merge branch 'obsd-master' 2026-06-07 15:00:06 +01:00
nicm
343ee5ece1 Add -g flag to kill-session to kill all sessions in a group, GitHub
issue 5157 from github at jiku dot jp.
2026-06-07 13:51:42 +00:00
nicm
0256ee77c2 Add some additional environment variables needed for Wayland, from
shbernal dot 01 at gmail dot com.
2026-06-07 13:37:39 +00:00
Thomas Adam
72f5415fc8 Merge branch 'obsd-master' 2026-06-07 14:30:06 +01:00
nicm
ef8e9df02f Tweak previous. 2026-06-07 13:29:16 +00:00
nicm
306ee0eddb Add -E to split-window to explicitly make an empty pane rather than
requiring an empty command.
2026-06-07 13:15:28 +00:00
Nicholas Marriott
3d9e6bf454 Update CHANGES for 3.7. 2026-06-07 12:01:09 +01:00
Thomas Adam
0fc6cb4099 Merge branch 'obsd-master' 2026-06-07 11:15:06 +01:00
nicm
5744021ac9 Allow floating panes to be created partially off the window, based on a
change from Michael Grant.
2026-06-07 09:54:25 +00:00
Thomas Adam
54be05e5e4 Merge branch 'obsd-master' 2026-06-07 09:30:06 +01:00
nicm
c9e22ab67b Enable floating panes. These are panes which sit above the layout
("tiled panes") like popups but unlike popups are not modal and behave
like panes (so the same escape sequence support). Floating panes are
created with the "new-pane" command, bound to * by default.

Currently floating panes can only be moved and resized using the mouse.
The default second status line (if "status-format" is set to 2) has
changed to show a list of panes.

This is the first step and many obvious features are not yet complete
(notably the ability to swap floating panes, resize them using
resize-pane, change them between floating and tiles, and restore custom
layouts with floating panes).

Mostly written by Michael Grant with help from Dane Jensen.
2026-06-07 08:25:59 +00:00
nicm
4063f968c6 Do not allow swapping floating panes for the moment. 2026-06-07 08:22:58 +00:00
Thomas Adam
8388c53a47 Merge branch 'obsd-master' 2026-06-06 19:00:06 +01:00
nicm
3a72f3beb8 Use correct X position for visible range checks in
screen_write_fast_copy, GitHub issue 5164 from Barrett Ruth.
2026-06-06 17:35:30 +00:00
nicm
35709a30ee Change so that floating panes are always part of the root layout. From
Dane Jensen.
2026-06-06 17:30:48 +00:00
Thomas Adam
f9a683cf39 Merge branch 'obsd-master' 2026-06-05 09:15:07 +01:00
nicm
d7a2b52da8 Add a way to quote for command arguments and use for key in list-keys,
GitHub issue 5153.
2026-06-05 08:04:03 +00:00
Thomas Adam
f43adc364a Merge branch 'obsd-master' 2026-06-04 10:45:09 +01:00
nicm
6beebbe074 Fix scrollbar drag position when window is taller than tty, from Michael
Grant.
2026-06-04 09:24:03 +00:00
Thomas Adam
019f8eb278 Merge branch 'obsd-master' 2026-06-03 21:30:06 +01:00
nicm
580f9ced08 Change run-shell expansion to just be #{1} etc not #1 which interferes
with colours.
2026-06-03 20:18:49 +00:00
nicm
642cc15b99 Change so panes scroll when the cursor is at the top instead of halfway
down, from Michael Grant.
2026-06-03 20:16:14 +00:00
Thomas Adam
cfeade6055 Merge branch 'obsd-master' 2026-06-02 21:00:06 +01:00
nicm
390207cdf1 Use new layout functions for join-pane also, from Dane Jensen. 2026-06-02 19:31:36 +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
5368ee32dd github: update lock-threads to v6
Use the latest release of lock-threads.
2026-06-02 16:26:13 +01: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
0759030ee8 Merge branch 'obsd-master' 2026-06-02 08:30:06 +01:00
nicm
35f4c8b333 Fix border colour bug in the floating panes branch where inactive
floating pane borders incorrectly use the active colour at intersections
with tiled pane borders. From Michael Grant.
2026-06-02 07:11:49 +00:00
Thomas Adam
97ac32f536 Merge branch 'obsd-master' 2026-06-01 21:30:06 +01:00
Thomas Adam
2f3ef88dbf Merge branch 'obsd-master' 2026-06-01 21:15:06 +01:00
nicm
9725a0b9bf Remove the actual LAYOUT_FLOATING enum member. 2026-06-01 20:10:01 +00:00
nicm
b368e89bea Remove LAYOUT_FLOATING and disable custom layouts with floating panes
for now, from Dane Jensen.
2026-06-01 20:09:26 +00:00
nicm
3269833caa Fix vertical position of scrollbar having wrong vertical offset when
status-position top, from Michael Grant.
2026-06-01 20:00:25 +00:00
nicm
922f7d1645 Fix resize of floating panes with pane-border-status top, from Michael
Grant.
2026-06-01 19:59:04 +00:00
nicm
a1873fef61 Only set saved_layout_cell if creating a new cell, avoids crash when
respawning pane. Reported by Mingjie Shen in GitHubb issue 5143.
2026-06-01 19:56:26 +00:00
Thomas Adam
0eff3b6b97 Merge branch 'obsd-master' 2026-06-01 19:30:06 +01:00
nicm
f6557d1ea2 Add a Z sort order in tree mode. 2026-06-01 18:19:51 +00:00
Thomas Adam
718eb2b4cc Merge branch 'obsd-master' 2026-06-01 19:15:06 +01:00
nicm
cd6c01e42b Mark floating panes in tree mode. 2026-06-01 18:00:20 +00:00
Thomas Adam
0b773dd792 Merge branch 'obsd-master' 2026-06-01 15:15:06 +01:00
nicm
b68ab3a4b4 Add pane_x, y, z format variables and show in list-panes. 2026-06-01 14:01:09 +00:00
Thomas Adam
d8c9f88fe7 Merge branch 'obsd-master' 2026-06-01 15:00:06 +01:00
Nicholas Marriott
f6398ba51c Add some more DECRQM responses, from Ayman Bagabas in GitHub issue 5118. 2026-06-01 14:30:33 +01:00
nicm
67dbf01eeb Add some more DECRQM responses, from Ayman Bagabas in GitHub issue 5118. 2026-06-01 13:28:49 +00:00
Thomas Adam
7c71064b64 Merge branch 'obsd-master' 2026-06-01 12:15:06 +01:00
nicm
4d91ff8d8d Do not try to use pane if there isn't one when redrawing wide characters,
GitHub issues 5145 and 5139.
2026-06-01 10:53:28 +00:00
Thomas Adam
e778f7f805 Merge branch 'obsd-master' 2026-06-01 09:45:06 +01:00
nicm
3bff7a9e62 Allow run-shell arguments after a shell command to be expanded as #1, #2
and so on. From Rasmus Thystrup Karstensen in GitHub issue 5121.
2026-06-01 08:27:37 +00:00
Thomas Adam
705c2ac55a Merge branch 'obsd-master' 2026-05-31 23:00:06 +01:00
Thomas Adam
3f3d65e452 Merge branch 'obsd-master' 2026-05-31 22:30:06 +01:00
nicm
a9721ea268 Only draw visible parts of numbers for display-panes. 2026-05-31 21:29:41 +00:00
nicm
d876bb8cf3 When pane-border-indicators is set to "both" or "arrows", only draw
arrows on the active floating pane and no other floating panes. Also
there is no need to loop in screen_redraw_cell_border if only checking
one pane.
2026-05-31 21:08:23 +00:00
Thomas Adam
b17dcc6773 Merge branch 'obsd-master' 2026-05-31 22:00:06 +01:00
nicm
e3ee2b327b Move back to starting position when pane is outside the window at all. 2026-05-31 20:41:07 +00:00
Thomas Adam
74b91d6dec Merge branch 'obsd-master' 2026-05-30 17:45:06 +01:00
nicm
7a3b7ae812 Return empty ranges if line is below window. 2026-05-30 16:10:13 +00:00
Thomas Adam
35df67c893 Merge branch 'obsd-master' 2026-05-30 12:30:06 +01:00
nicm
290303e64f Missed this file from previous. 2026-05-30 11:20:03 +00:00
nicm
f8ab7a5158 Handle ranges for panes which are outside the window to the left. 2026-05-30 11:19:39 +00:00
Thomas Adam
decaaf4b55 Merge branch 'obsd-master' 2026-05-30 11:15:06 +01:00
nicm
b9d228c72f Do not crash when a pane offset is negative. 2026-05-30 09:48:30 +00:00
Thomas Adam
11e48c3fa9 Merge branch 'obsd-master' 2026-05-30 10:15:06 +01:00
nicm
c40302a7ff Check if the range is invalid using start,end rather than length since
it will never be negative.
2026-05-30 08:58:29 +00:00
Thomas Adam
964e22cfef Merge branch 'obsd-master' 2026-05-29 17:15:06 +01:00
nicm
55db69e3b2 Correct offsets for redrawing entire line here too. 2026-05-29 15:51:03 +00:00
Thomas Adam
99b08ecde5 Merge branch 'obsd-master' 2026-05-29 09:15:06 +01:00
nicm
4ecf93487e Use correct X position for redrawing wide characters. 2026-05-29 07:49:01 +00:00
Nicholas Marriott
f066933418 Uninstall the man page too. 2026-05-28 15:20:04 +01:00
Thomas Adam
481d8299ca Merge branch 'obsd-master' 2026-05-28 12:45:06 +01:00
nicm
3b19536df9 Swap panes on z-index list as well. 2026-05-28 11:17:35 +00:00
Thomas Adam
2212157b61 Merge branch 'obsd-master' 2026-05-28 12:00:07 +01:00
nicm
7ebeed1ae7 Do not try to use last pane if there isn't one. 2026-05-28 10:45:17 +00:00
nicm
7769097915 Hide menu options that do not work for floating panes. 2026-05-28 10:34:38 +00:00
Thomas Adam
595b0cb471 Merge branch 'obsd-master' 2026-05-28 10:00:08 +01:00
nicm
c50c3629e6 Use the correct ranges when a pane is covered by a popup in tty_draw_pane. 2026-05-28 08:43:57 +00:00
Thomas Adam
887b6f4da7 Merge branch 'obsd-master' 2026-05-28 09:15:07 +01:00
nicm
9c6cfcd2e9 Obscured check should not be true if pane is same size as window. 2026-05-28 07:58:45 +00:00
Thomas Adam
658c7d1dbf Merge branch 'obsd-master' 2026-05-28 08:45:08 +01:00
nicm
ecfe6e4e7a Check visible ranges for collected cell output. 2026-05-28 07:23:52 +00:00
Thomas Adam
f53c4e7525 Merge branch 'obsd-master' 2026-05-27 22:15:06 +01:00
Nicholas Marriott
3690c64e88 Use -g -ggdb for debug. 2026-05-27 22:07:57 +01:00
Thomas Adam
c489f786b6 Merge branch 'obsd-master' 2026-05-27 22:00:06 +01:00
nicm
5c40cc43b2 Bring in the single-cell redraw parts for floating panes. 2026-05-27 20:57:53 +00:00
nicm
54ae850322 Do not adjust end position when removing partial padding, it does not
change.
2026-05-27 20:47:23 +00:00
Thomas Adam
a9b9d2f6d3 Merge branch 'obsd-master' 2026-05-27 21:00:08 +01:00
nicm
f00f92e7e3 Check visible ranges when copying screens. 2026-05-27 19:43:46 +00:00
nicm
bbe26df83d Add an accessor function needed for floating panes. 2026-05-27 19:36:04 +00:00
Thomas Adam
daf9988b3a Merge branch 'obsd-master' 2026-05-27 20:15:06 +01:00
nicm
ee67452772 Add window-pane-status-format options and adjust the default second
status line to show panes, also change how window-style is checked now
it is a pane option.
2026-05-27 18:57:10 +00:00
Thomas Adam
781364f7f9 Merge branch 'obsd-master' 2026-05-27 17:45:06 +01:00
nicm
84d016ddcf Floating panes clearing bits. 2026-05-27 16:25:01 +00:00
Nicholas Marriott
0241fdac1a Remove extra declaration. 2026-05-27 16:52:09 +01:00
Thomas Adam
d62bae442b Merge branch 'obsd-master' 2026-05-27 16:46:04 +01:00
nicm
9cc8947a43 Cache border and active border style separately, fixes problem reported
by Marcel Partap in GitHub issue 5125.
2026-05-27 13:41:20 +00:00
nicm
bff68fa079 Remove reference to an option that hasn't been added yet. 2026-05-27 12:52:47 +00:00
nicm
00c59041ea Bring in some more floating panes changes - obscured panes need to be
handled specially in screen_write_* rather than dropping into the client
redraw (tty.c).
2026-05-27 11:54:28 +00:00
Thomas Adam
a77b81f0e5 Merge branch 'obsd-master' 2026-05-27 08:15:06 +01:00
jsg
f839588c69 fix sort_get_clients() indentation; ok nicm@ 2026-05-27 07:05:20 +00:00
nicm
27d719cd4d Check error result correctly (*cause not cause), pointed out by jsg. 2026-05-27 07:01:36 +00:00
Thomas Adam
7a15dc6772 Merge branch 'obsd-master' 2026-05-25 16:15:06 +01:00
nicm
bfd7f468ce pane_zoomed_flag went missing somewhere in tmux.1, put it back. 2026-05-25 14:53:09 +00:00
Thomas Adam
cca1e77f95 Merge branch 'obsd-master' 2026-05-25 09:15:07 +01:00
nicm
cc81287665 More of floating panes redraw path, still mostly using flags which are never set. 2026-05-25 08:07:48 +00:00
nicm
ca95153b45 Preserve flags when creating new cells, from Brian Youngs. 2026-05-25 07:55:46 +00:00
Nicholas Marriott
eb330a6df6 Restore SIXEL bit. 2026-05-24 10:05:41 +01:00
Thomas Adam
b498979d4d Merge branch 'obsd-master' 2026-05-24 10:00:06 +01:00
nicm
f047b3f8e7 Do not crash when freeing layout cell, reported by Jere Viikari. 2026-05-24 08:40:43 +00:00
Thomas Adam
c67787536b Merge branch 'obsd-master' 2026-05-23 18:00:06 +01:00
nicm
3cfc96d4de Add missing argument to %unlinked-window-renamed, reported by Andrew
Grangaard.
2026-05-23 16:43:04 +00:00
Thomas Adam
91a8c66537 Merge branch 'obsd-master' 2026-05-23 08:45:06 +01:00
nicm
5c3a4746b7 Some code tidying up. 2026-05-23 07:22:50 +00:00
Nicholas Marriott
b8e0004ff2 Fix missing arguments. 2026-05-22 18:33:04 +01:00
Thomas Adam
4e0aabd8a7 Merge branch 'obsd-master' 2026-05-22 16:54:06 +01:00
nicm
143a177055 Tighten up read-only checks on attach-session, detach-client and
switch-client so that a user should be able to only detach their own
client. Reported by John Walker.
2026-05-22 15:22:43 +00:00
nicm
d45a9cad8c Work out if a pane is obscured by another one when drawing. 2026-05-22 11:55:43 +00:00
Nicholas Marriott
285a3b7522 Fix up SIXEL with recent changes. 2026-05-22 12:44:08 +01:00
Thomas Adam
d4255818c4 Merge branch 'obsd-master' 2026-05-22 12:01:06 +01:00
Thomas Adam
f714f3ee78 Merge branch 'obsd-master' 2026-05-22 10:28:51 +01:00
nicm
36bc351557 Use a union for the data passed around in tty_ctx instead of void *. 2026-05-22 09:21:32 +00:00
nicm
d5ee330d20 Tidy up a load of different flags and special values in the tty_ctx into
a single bitmask.
2026-05-22 09:05:16 +00:00
Thomas Adam
634e9d6213 Merge branch 'obsd-master' 2026-05-21 12:01:06 +01:00
nicm
9aa9a92f72 Pane resizing code for floating panes, mostly by Michael Grant. 2026-05-21 07:28:51 +00:00
Nicholas Marriott
8c51c0fdbd Merge tag '3.6b'
3.6b
2026-05-20 12:53:07 +01:00
Thomas Adam
24e4a545a2 Merge branch 'obsd-master' 2026-05-20 12:19:23 +01:00
Nicholas Marriott
c5fb5e8bb0 Update CHANGES. 2026-05-20 12:17:30 +01:00
Nicholas Marriott
b8434182c9 Track which list (images or saved_images) each image is on so they can be
removed from the correct list when the total image count is reached. Fixes
crash reported by xlabai at tencent dot com.
2026-05-20 12:15:34 +01:00
Nicholas Marriott
e1f942f26a Add a define for max images and bump to 20 for the moment. 2026-05-20 12:14:22 +01:00
Thomas Adam
91b85efabb Merge branch 'obsd-master' 2026-05-20 12:01:06 +01:00
nicm
0057905ca0 Increase escape delay if the buffer contains a partial paste end, fixes
issues with at least Windows Terminal. From jing dot empty at gmail.com
GitHub issue 5088.
2026-05-20 10:56:46 +00:00
nicm
572e26deb8 Some more trivial floating panes bits. 2026-05-20 08:54:40 +00:00
Thomas Adam
caff9a135f Merge branch 'obsd-master' 2026-05-20 08:47:44 +01:00
nicm
ce24b92758 Floating panes full redraw code, by Michael Grant. 2026-05-19 13:12:45 +00:00
nicm
f5a086ac98 Some more easy floating panes bits. 2026-05-19 12:16:25 +00:00
Thomas Adam
cb1025e0e8 Merge branch 'obsd-master' 2026-05-19 12:25:31 +01:00
nicm
a46cdb8bbc More (currently disabled) bits for creating floating panes, from Michael
Grant and Dane Jensen.
2026-05-19 10:26:03 +00:00
nicm
34e2035bad More bits for pane Z index tracking from floating panes, mostly by
Michael Grant.
2026-05-19 09:48:14 +00:00
Thomas Adam
a9ba7b8ecb Merge branch 'obsd-master' 2026-05-18 09:38:02 +01:00
nicm
962d647993 Remove some leftover debug code. 2026-05-17 16:02:33 +00:00
nicm
a8520ba59e Bring over some of layout and positioning code for floating panes, by
Michael Grant.
2026-05-17 16:01:42 +00:00
nicm
f12d7b4e67 When mode-keys is set to vi, do not allow the cursor to go into the
invisible extra cell to the right of the visible text. This is closer to
what vi(1) does. From Max Vim in GitHub issue 5070.
2026-05-17 13:12:21 +00:00
nicm
bbea6e6375 Add a five second limit on pasting for terminals which mysteriously lose
the end sequence if the paste is too big (that is, Terminal.app).
Reported by Garri Djavadyan in GitHub issue 4527.
2026-05-17 13:01:04 +00:00
nicm
b24b8424b1 Switch to use backing grid not copy mode's grid for copy line, GitHub
issue 4995.
2026-05-17 12:38:04 +00:00
nicm
35bd1a4c02 Do not include unattached clients on sorted list, fixes crash reported
by Marcel Partap.
2026-05-17 11:17:16 +00:00
nicm
818352c3cd Add some more explanatory text about targets, GitHub issue 4850. 2026-05-17 11:12:07 +00:00
nicm
742efe989f Report file open errors more sensibly, reported by Meriel Luna
Mittelbach in GitHub issue 5081.
2026-05-17 10:54:01 +00:00
nicm
4cea1c7189 Add new-pane command, currently this is equivalent to split-window but
it will have minor differences for floating panes in future. Also add
-R/-s/-S/-k/-m flags to control border and style and behaviour, like
popups. GitHub issue 5027 from Dane Jensen.
2026-05-17 10:44:53 +00:00
Nicholas Marriott
18ddda48d2 More. 2026-05-16 12:18:41 +01:00
Nicholas Marriott
5651519f5d Try to make Copilot shut up. 2026-05-16 12:07:09 +01:00
nicm
281e8ff766 Fix a couple of bugs in tty_draw_line: do not loop forever if orphan
padding appears, or if a wide character is trimmed at the right of the
region. Much help with testing from qingliu at alauda dot io in GitHub
issue 5024.
2026-05-13 13:12:23 +00:00
nicm
dbc0710bc9 Update supported features for Foot, from Meriel Luna Mittelbach in
GutHub issue 5079.
2026-05-13 10:24:57 +00:00
nicm
8f28f31b78 Do not crash if set progress bar with no pane, from Dane Jensen. 2026-05-13 08:25:05 +00:00
Thomas Adam
3f651d9fa9 Merge branch 'obsd-master' 2026-05-12 16:01:08 +01:00
nicm
18fced7e7f Make pane offsets signed, needed for floating panes. 2026-05-12 12:05:41 +00:00
Thomas Adam
f1f0158741 Merge branch 'obsd-master' 2026-05-12 12:01:11 +01:00
nicm
3d6c542e34 Turn off the "is this a paste" guessing if the terminal supports bracket
pasting instead, GitHub issue 5031.
2026-05-12 10:28:09 +00:00
Nicholas Marriott
c3036116de Update test output. 2026-05-12 10:38:29 +01:00
nicm
9e3653a612 Check FIONREAD for all panes not just piped panes, fixes issues with
tests, GitHub issue 4807.
2026-05-12 09:37:25 +00:00
nicm
27a00d1bfd Fix infinite loop due to underflow when redrawing scrollbar, from Pavel
Lavrukhin in GitHub issue 4932.
2026-05-12 09:32:49 +00:00
nicm
800837ff3f Fix control mode teardown ordering for queued pane output, GitHub issue
5064 from Aaron Campbell.
2026-05-12 09:27:28 +00:00
Nicholas Marriott
bfbfb6dbf3 Avoid overshooting Sixel height in sixel_parse_write, GitHub issue 5071 from
nincsnevem662 at gmail dot com.
2026-05-11 12:00:06 +01:00
Thomas Adam
8fb1b1d412 Merge branch 'obsd-master' 2026-05-08 12:01:09 +01:00
nicm
af98467d0d Do not cache format for status line because it stores various pointers
that might be stale, instead cache the cmd_find_state and rebuild the
formats every time they are needed. Reported by Marcel Partap in GitHub
isue 5065.
2026-05-08 06:57:38 +00:00
Thomas Adam
f9d50d580c Merge branch 'obsd-master' 2026-05-07 12:01:08 +01:00
nicm
496805476e Require layout prefix to be 5 characters, GitHub issue 5067 from
cglosner at gmail dot com.
2026-05-07 09:21:05 +00:00
nicm
962e565591 Add Emacs-style recentre-top-bottom, GitHub issue 5053 from sinyax75 at
gmail dot com.
2026-05-07 09:15:44 +00:00
Thomas Adam
862625a4bf Merge branch 'obsd-master' 2026-05-06 16:01:09 +01:00
nicm
2d8aade74b Add time limit to a couple of other loops. 2026-05-06 13:43:38 +00:00
Nicholas Marriott
2aad2cfc53 Add a configure flag for ASAN. 2026-05-06 08:23:45 +01:00
Thomas Adam
ad94405dac Merge branch 'obsd-master' 2026-05-05 16:01:08 +01:00
nicm
518fcf7e03 Do not sanitize title when popping it from stack, also add a limit to
number of pushed titles.
2026-05-05 13:18:46 +00:00
nicm
1fbd00e1e8 Add missing flags to screen_mode_to_string and do not write before
before if any are missed, second bit from qingliu at alauda dot io.
2026-05-05 12:06:52 +00:00
nicm
cae229cadc Discard queued data and clear offsets when turning pane off to prevent
later read of data that has been removed. From Aaron Campbell in GitHub
issue 5054.
2026-05-05 12:02:12 +00:00
Thomas Adam
9d3dcdbc38 Merge branch 'obsd-master' 2026-05-03 20:01:09 +01:00
nicm
d52fabce72 Allow the indicator in tree mode to be customized by two new options:
tree-mode-preview-format and tree-mode-preview-style.
2026-05-03 15:02:48 +00:00
nicm
637d4c3083 Fix control client hang on exit after toggling no-output, GitHub issue
5049 from Aaron Campbell.
2026-05-03 15:01:21 +00:00
nicm
1e96d9a87f Do not check for NULL after dereferencing, from alexarama at yahoo dot
com in GitHub issue 5051.
2026-05-03 14:57:09 +00:00
nicm
49172b256c Free working stuff when R formats fail. 2026-05-03 14:55:43 +00:00
Thomas Adam
9a94f48663 Merge branch 'obsd-master' 2026-05-01 16:01:09 +01:00
nicm
2e9c6c2586 Add some checks on line size to avoid underflow, from san65384 at gmail
dot com in GitHub issue 4955.
2026-05-01 11:56:41 +00:00
Thomas Adam
92522473b0 Merge branch 'obsd-master' 2026-05-01 12:01:08 +01:00
nicm
56200ca044 Do not leak cached last result from control subs, from Aaron Campbell in
GitHub issue 5047.
2026-05-01 09:59:42 +00:00
nicm
524f283cc6 Add support for line numbers in copy mode. A new copy-mode-line-numbers
option has the following modes: off, default (tmux's normal line
numbering where 0 is the top visible line), absolute (first line in
history is 1), relative (relative to the cursor) and hybrid (current
line is absolute, others relative). Also adds
copy-mode-line-number-style and copy-mode-current-line-number-style to
set the style of the line numbers. When copy mode is entered with the
mouse, line numbers stay off.

From Leo Henon in GitHub issue 5025.
2026-05-01 09:44:42 +00:00
nicm
a2acf0f7cf Check time inside repeat (R:) loop as well. 2026-05-01 09:34:05 +00:00
Thomas Adam
d85f1b942d Merge branch 'obsd-master' 2026-04-28 16:01:08 +01:00
Thomas Adam
8da41bdc2b Merge branch 'obsd-master' 2026-04-28 12:01:08 +01:00
nicm
4a926e489b Make C-[ have the same bindings as Escape for terminals with extended
keys where they are different, GitHub issue 5035 from Eric NICOLAS.
2026-04-28 10:01:07 +00:00
nicm
746dd91e86 Sanitize paste buffer names in paste_set and paste_rename, GitHub issue
5032 from Barrett Ruth.
2026-04-28 08:52:37 +00:00
nicm
763dec881a Do not leak socketpair fds in pipe-pane when fork fails. From Barrett
Ruth.
2026-04-28 08:47:55 +00:00
nicm
2a5715fad5 Do not deref NULL job in window_copy_pipe_run when job_run fails. From
Barrett Ruth in GitHub issue 5036.
2026-04-28 08:35:21 +00:00
nicm
ec58272b95 Do not hang run-shell when job_run fails, from Barrett Ruth in GitHub
issue 5037.
2026-04-28 08:34:15 +00:00
nicm
f90d3af403 Fix -p for for join-pane, from Dane Jensen. 2026-04-28 08:32:44 +00:00
Thomas Adam
c2659401b0 Merge branch 'obsd-master' 2026-04-27 16:01:09 +01:00
nicm
9840d4a4a3 Add a limit on maximum length of environment variable assignment in
configuration files.
2026-04-27 12:31:11 +00:00
Nicholas Marriott
fc6d94a9f8 Track which list (images or saved_images) each image is on so they can be
removed from the correct list when the total image count is reached. Fixes
crash reported by xlabai at tencent dot com.
2026-04-27 13:09:07 +01:00
Nicholas Marriott
61a7be0eab Turn off regular expressions when fuzzing because there are cases that take too
much time or memory that cannot be fixed.
2026-04-26 21:19:16 +01:00
Thomas Adam
e4a439aa0c Merge branch 'obsd-master' 2026-04-26 21:12:23 +01:00
nicm
b844cafb9c No need to stravis the window name twice. 2026-04-24 10:08:52 +00:00
nicm
1d9522a7a6 Kill client rather than fatalx on bad file handling messages, reported
by Tim Zheng.
2026-04-23 12:36:15 +00:00
nicm
ffe80579df Redraw correctly when a popup is present above pane borders, GitHub
issue 4997 from Manuel Einfalt.
2026-04-23 11:29:23 +00:00
Thomas Adam
bcd17cf99a Merge branch 'obsd-master' 2026-04-23 11:58:17 +01:00
nicm
bc15723f7f Add feature for progress bar and pass to outside terminal, GitHu issue
4972 from Eric Dorland.
2026-04-22 07:25:17 +00:00
nicm
7a0cc03532 Translate keypad keys to text in prompt input. From Barrett Ruth in
GitHub issue 4996.
2026-04-22 07:15:34 +00:00
nicm
d36f6783c7 Add a couple of controls (kill, zoom) to default pane-status-format.
Will be more to come with floating panes. From Dane Jensen in GitHub
issue 4981.
2026-04-22 07:13:26 +00:00
nicm
d339ab51eb Sanitize pane titles and window and session names more consistently and
strictly, prevents C0 characters and other nonvisible characters causing
problems. Reported (with a different fix) by Chris Monardo in GitHub
issue 4999.
2026-04-22 07:10:16 +00:00
nicm
fee70031f6 Make clock visible on terminals without colours, from Manuel Einfalt in
GitHub issue 5001.
2026-04-22 07:05:59 +00:00
nicm
303edb71bd Add a fairly low time limit to format evaluation to stop absurdly nested
formats from making tmux appear to hang.
2026-04-22 07:05:03 +00:00
nicm
314f0ae964 Do not leak hyperlinks in copy mode, from Barrett Ruth in GitHub issue
5020.
2026-04-22 07:03:06 +00:00
nicm
0835980ef1 Remove no longer accurate statement from tmux.1, reported by dkuettel at
gmail dot com.
2026-04-22 06:58:59 +00:00
nicm
baf55e4616 Add a default set of features for WezTerm. 2026-04-22 06:57:08 +00:00
Nicholas Marriott
dd62c2f946 Do not need to create a new window each time for input-keys.sh test. 2026-04-15 16:21:35 +01:00
Thomas Adam
638cecf43c Merge branch 'obsd-master' 2026-04-14 16:01:08 +01:00
nicm
a97cfe513d Do not leak old time format if it is replaced in same format. 2026-04-14 11:25:41 +00:00
Thomas Adam
9de3c0495f Merge branch 'obsd-master' 2026-04-14 12:01:08 +01:00
nicm
67e6f8245b If job_run fails, do not crash but instead free the popup. 2026-04-14 08:39:10 +00:00
nicm
31c93c483a Another check for partially initialized control client, from Matt
Koscica in GitHub issue 5004.
2026-04-14 08:32:30 +00:00
nicm
86d4d5689c Add detach to default session menu, suggested by Przemyslaw Sztoch. 2026-04-14 07:35:17 +00:00
nicm
663e82bc19 Fix key binding conflict in session menu, from Dane Jensen. 2026-04-14 07:28:57 +00:00
nicm
51109e3f72 Include window bits for pane notifications, GitHub issue 5007 from Saul
Nogueras.
2026-04-14 07:26:45 +00:00
nicm
a11363e9e7 Limit precision to 100 to stop silly formats from running out of memory,
reported by z1281552865 at gmail dot com.
2026-04-14 07:24:23 +00:00
nicm
cc57913d7a Add WAYLAND_DISPLAY to default update-environment, GitHub issue 4965 from
wgh at torlan dot ru.
2026-04-14 07:16:02 +00:00
Thomas Adam
057d169492 Merge branch 'obsd-master' 2026-04-13 12:01:08 +01:00
nicm
e5a2a25faf Do not notify clients if not fully initialized, from Ben Maurer in
GitHub issue 4980.
2026-04-13 09:35:20 +00:00
nicm
147521b757 Add -C flag to command-prompt to match display-message -C (do not freeze
panes). From Barrett Ruth in GitHub issue 4978.
2026-04-13 09:33:09 +00:00
Thomas Adam
31d77e29b6 Merge branch 'obsd-master' 2026-04-05 20:01:08 +01:00
nicm
4b0ff07bcb When a cell is cleared after having been moved, we cannot reuse its
extended data, because that may still be in use. Add a flag to
grid_clear_cell to indicate this. Fixes irritating problems with ICH
(CSI @) mostly visible in emacs.
2026-04-05 15:43:17 +00:00
Thomas Adam
0ee18d4421 Merge branch 'obsd-master' 2026-04-05 16:01:08 +01:00
nicm
21da45e5c3 Add extkeys feature to tmux itself so nested tmux works, GitHub issue 4960. 2026-04-05 14:29:04 +00:00
nicm
d5ed967f58 Set less crazy limits (than INT_MAX) for pad and trim, makes ossfuzz happier. 2026-04-05 13:24:02 +00:00
Thomas Adam
42dafcc62a Merge branch 'obsd-master' 2026-04-04 20:01:11 +01:00
nicm
cad282ebb7 Cache user from getpwuid because it can be very expensive on some
platforms. From Ben Maurer in GitHub issue 4973.
2026-04-04 17:13:07 +00:00
nicm
7f2ac9c871 Add remain-on-exit key to keep pane around until a key is pressed, from
Michael Grant.
2026-04-04 17:00:33 +00:00
nicm
87aaff5fae Bring some new formats from the floating panes work: pane_zoomed_flag,
pane_flags, pane_floating_flag. By Michael Grant.
2026-04-04 16:40:27 +00:00
Thomas Adam
b411010237 Merge branch 'obsd-master' 2026-04-04 16:01:09 +01:00
nicm
d2d86ac360 Document control ranges, from Dane Jensen. 2026-04-04 11:48:00 +00:00
nicm
a827725a8d Set up default and last cell before clearing padding, reported by
someone on GitHub.
2026-04-04 11:39:49 +00:00
nicm
3badbc50e0 Do not read off end of buffer if it ends in \ when expanding \c, found
by ossfuzz.
2026-04-04 11:32:05 +00:00
nicm
cd60de443e Clamp width to terminal width, also change calculation of end of screen
(it is OK to be outside the screen). Fixes problem reported by Dane
Jensen in GitHub issue 4969.
2026-04-04 11:20:01 +00:00
Nicholas Marriott
95e40115a2 Don't just resize buffer once, repeat until it is big enough. Also use
reallocarray. Reported by tuannguyenduc228 at gmail dot com.
2026-04-04 12:11:25 +01:00
Thomas Adam
66c324d7ef Merge branch 'obsd-master' 2026-04-03 16:01:08 +01:00
nicm
6b056eb53f Add some new mouse ranges called "control0" to "control9", will be used
for controls on floating panes, from Dane Jensen, with some bits from
Michael Grant.
2026-04-03 10:13:20 +00:00
Thomas Adam
8cfdcf9a6f Merge branch 'obsd-master' 2026-04-03 11:04:15 +01:00
nicm
0917cd7010 Missed a line from previous. 2026-04-03 09:18:24 +00:00
nicm
bdd78ce38e Handle OSC 9;4 progress bar sequence and store in format variables, from
Eric Dorland in GitHub issue 4954.
2026-04-03 09:14:27 +00:00
nicm
7497db6e37 Increase b64_pton buffer to allow for Base64 without padding, from
Michal Majchrowicz.
2026-04-03 08:23:10 +00:00
Thomas Adam
43e2942fa0 Merge branch 'obsd-master' 2026-04-02 16:01:08 +01:00
Thomas Adam
51bc2f3b76 Merge branch 'obsd-master' 2026-04-02 12:01:08 +01:00
nicm
483683c197 Do not leak command in list-keys, reported by tb@. Also tidy up some
function names while here.
2026-04-02 09:58:14 +00:00
nicm
c95d341220 Do not leak trimmed string when expanding, found by ossfuzz. 2026-04-02 09:35:46 +00:00
nicm
be2c6f3b5e Use INT_MIN + 1 as strtonum lower limits in formats so -ve works, found
by ossfuzz.
2026-04-02 09:28:22 +00:00
nicm
2d5736f297 Limit argc to between 0 and 1000 to prevent fatal from MSG_COMMAND, from
Michal Majchrowicz.
2026-04-02 09:11:39 +00:00
nicm
1a51193899 Handle empty regular expression in substitution, found by ossfuzz. 2026-04-02 08:45:35 +00:00
nicm
8b51abef08 Check for \0 after skipping # not before in format_expand1, from ossfuzz. 2026-04-02 08:37:14 +00:00
nicm
cbb49e8c84 Fix NULL dereference in sort.c, from Dane Jensen. 2026-04-02 08:01:47 +00:00
Thomas Adam
dc12da4573 Merge branch 'obsd-master' 2026-04-01 12:01:08 +01:00
nicm
7af58f74b0 Fixed missing drag end detection and mouse button detection with
modifiers. From Dane Jensen, reported by Joseph Tyson and Mark Kelly.
2026-04-01 08:10:02 +00:00
Thomas Adam
1081876810 Merge branch 'obsd-master' 2026-03-31 16:01:08 +01:00
nicm
2ff0dd3fef Reorganize structure of key_code so that it can be built directly by
bitshifts rather than a load of huge switches, from Dane Jensen in
GitHub issue 4953.
2026-03-31 11:46:43 +00:00
Thomas Adam
a30fc69f86 Merge branch 'obsd-master' 2026-03-30 12:01:08 +01:00
nicm
022b5cf193 When in copy mode with a large scroll offset and the window is resized
so that history shrinks, data->oy can exceed screen_hsize causing an
unsigned integer underflow in the py computation. Clamp data->oy in
window_copy_resize and window_copy_cmd_refresh_from_pane before the
subtraction. From futpib at gmail dot com in GitHub issue 4958.
2026-03-30 09:23:40 +00:00
Nicholas Marriott
7620c03b72 Add new fuzzers for command parsing, formats and styles, from David Korczynski
in GitHub issue 4957.
2026-03-30 10:20:16 +01:00
Thomas Adam
6324dae114 Merge branch 'obsd-master' 2026-03-27 12:01:10 +00:00
nicm
e0237c6b8c Ql -> Fl, from arza at arza dot us in GitHub issue 4949. 2026-03-27 08:41:54 +00:00
nicm
1cf3e02bfb Add a format flag for bracket paste, from George Nachman in GitHub issue
4951.
2026-03-27 08:40:26 +00:00
Thomas Adam
6ca5405db9 Merge branch 'obsd-master' 2026-03-25 12:01:07 +00:00
Nicholas Marriott
fa31f2a3eb Do not really need both. 2026-03-25 10:39:03 +00:00
Nicholas Marriott
d03f9454b9 Make COPYING the same. 2026-03-25 10:38:03 +00:00
Nicholas Marriott
616fb1cbcf Add a LICENSE file to see if it makes GitHub happy. 2026-03-25 10:26:15 +00:00
nicm
b7d1e6257c Use \- for hyphens in tmux.1 to cause newer groff versions to render
them correctly (ASCII hyphen rather than Unicode) which aids copy and
paste. From Keith Thompson in GitHub issue 4948.
2026-03-25 10:08:50 +00:00
Thomas Adam
b101ffaed6 Merge branch 'obsd-master' 2026-03-23 12:01:10 +00:00
nicm
f7dad4f38f Check lastgc is not NULL before using it, GitHub issue 4935 from Pavel
Lavrukhin.
2026-03-23 09:05:59 +00:00
nicm
b88c08f860 Fix a NULL dereference and use after free, GitHub issue 4936 from Pavel
Lavrukhin.
2026-03-23 09:03:43 +00:00
Nicholas Marriott
cc47f4d1c2 Use window options for cursor-style to avoid crash when no pane, from
Arden Packeer in GitHub issue 4942.
2026-03-23 09:00:42 +00:00
nicm
3909d7e92f Use window options for cursor-style to avoid crash when no pane, from
Arden Packeer in GitHub issue 4942.
2026-03-23 08:58:39 +00:00
nicm
d70edfa0a0 Fix issue where popup window gets overwritten by background updates,
from Conor Taylor in GitHub issue 4920.
2026-03-23 08:48:32 +00:00
nicm
d22ab85b84 Protect against overflow when scrollbar is off screen, from san65384 at
gmail dot com in GitHub issue 4933.
2026-03-23 08:45:30 +00:00
Thomas Adam
5c30b145df Merge branch 'obsd-master' 2026-03-18 12:01:09 +00:00
nicm
e446cba6a9 Copy hyperlinks when redrawing popup so they do not vanish, from Antoine
Gaudreau Simard in GitHub issue 4925.
2026-03-18 08:49:27 +00:00
Nicholas Marriott
8a0b4e0d8c Work around systemd killing panes early during system shutdown by creating
dependencies from the panes to the service which started tmux, GitHub issue
4926 from Dmitry Torokhov.
2026-03-18 08:46:16 +00:00
nicm
02a9cdff57 Fix buffer to both for get-clipboard, from Seth Girvan. 2026-03-18 08:41:20 +00:00
nicm
f516f8a1d4 Allow codepoint-widths to accept ranges, from san65384 at gmail dot com
in GitHub issue 4930.
2026-03-18 08:38:54 +00:00
Thomas Adam
bef4865d91 Merge branch 'obsd-master' 2026-03-12 16:01:08 +00:00
nicm
fd62f419ac Add a short builtin help text for each mode accessible with C-h,
based on code from Patrick Motard in GitHub issue 4751.
2026-03-12 12:40:40 +00:00
Thomas Adam
7fa6f320ed Merge branch 'obsd-master' 2026-03-12 12:01:09 +00:00
nicm
19f3fb131b Draw message as one format, allowing prompts and messages to occupy only
a portion of the status bar, overlaying the normal status content rather
than replacing the entire line. A new message-format option now controls
the entire message (like status-format). From Conor Taylor in GitHub
issue 4861.
2026-03-12 07:25:13 +00:00
nicm
551e8fcd24 Fix comparison of menu keys, reported by Vladimir Bauer in GitHub issue
4891.
2026-03-12 07:15:26 +00:00
Thomas Adam
04b4952f0e Merge branch 'obsd-master' 2026-03-09 20:01:07 +00:00
Thomas Adam
0d77555c97 Merge branch 'obsd-master' 2026-03-09 16:01:09 +00:00
nicm
67141fb4bb Add next/previous variables for windows in W: loop, from Conor Taylor in
GitHub issue 4856.
2026-03-09 15:46:01 +00:00
tb
2efa762c2b tmux: move block assigning to prefix a bit down to avoid a small leak
ok nicm
2026-03-09 14:37:26 +00:00
Nicholas Marriott
6c2dd193cf Fix memory leak in sixel_parse() on error path, from Renaud Allard in GitHub
issue 4916.
2026-03-09 14:34:58 +00:00
nicm
881bec958e Fix server crash when control client session is destroyed, from Renaud
Allard in GitHub issue 4916.
2026-03-09 14:33:55 +00:00
nicm
8899c751e5 Check for NULL value in tilde expansion before dereferencing, from
Renaud Allard in GitHub issue 4916.
2026-03-09 14:31:41 +00:00
Thomas Adam
d0caf0a322 Merge branch 'obsd-master' 2026-03-06 12:01:08 +00:00
tb
91b5108eae tmux: don't leak menu if the tty is too small to display it
ok nicm
2026-03-06 08:19:22 +00:00
nicm
2c7f73f9c4 Do not use recallocarray because the stored size may have changed during
reflow so may not match what it expects, fixes crash reported by Caspar
Schutijser.
2026-03-06 08:09:58 +00:00
Thomas Adam
5310592967 Merge branch 'obsd-master' 2026-03-06 04:01:09 +00:00
nicm
41bddae907 Fix incorrect condition for creating client name, from Vlad Apostol in
GitHub issue 4911.
2026-03-05 22:50:14 +00:00
Thomas Adam
d9d2b2f1ee Merge branch 'obsd-master' 2026-03-05 12:01:09 +00:00
nicm
1e208abd93 Add pane_pipe_pid with pipe fd and call setpgid to make it easier to kill. 2026-03-05 09:22:08 +00:00
Thomas Adam
d32088b58a Merge branch 'obsd-master' 2026-03-04 12:01:09 +00:00
nicm
6d37cc94a7 Make -c work with new-session -A, from Jody Frankowski in GitHub issue
4906.
2026-03-04 08:16:47 +00:00
nicm
55722a7ed7 Another memory leak, from Huihui Huang. 2026-03-04 08:15:24 +00:00
tb
d2fa20a390 tmux: use VIS_NOSLASH to avoid annoying double escaping on paste
from nicm
2026-03-04 07:19:32 +00:00
tb
bcbad050d4 tmux: tc can be NULL, so check before deref to avoid crashing the server
ok nicm
2026-03-04 07:17:01 +00:00
Thomas Adam
27698c468b Merge branch 'obsd-master' 2026-03-03 16:01:09 +00:00
nicm
49bb43047d Allow copy mode to work for readonly clients, except for copy commands,
from Dane Jensen.
2026-03-03 12:26:14 +00:00
nicm
77ce0a837d Check window is not NULL, from Chema Gonzalez in GitHub issue 4908. 2026-03-03 12:24:18 +00:00
Thomas Adam
bbbfa8f360 Merge branch 'obsd-master' 2026-03-02 12:01:09 +00:00
Nicholas Marriott
d781d2eaa1 Add regression test from Ilya Grigoriev, GitHub issue 4818. 2026-03-02 09:32:45 +00:00
nicm
f33b14bda6 Revert r1.343 for the moment since it breaks behaviour (#() in
status-left) that we need to keep.
2026-03-02 08:48:57 +00:00
nicm
e603549563 Do not leak active/all strings in format_loop_windows; from Huihui Huang
in GitHub issue 4898.
2026-03-02 08:41:43 +00:00
nicm
e80e0c761a Fix incorrect placement of It Xo, from Dane Jensen. 2026-03-02 08:39:44 +00:00
nicm
9e804202b6 Fix memory leak, from Emmanuel Ugwu in GitHub issue 4900. 2026-03-02 08:38:23 +00:00
Thomas Adam
0c678b1e1a mailcap: update entry for Thomas Adam 2026-03-01 17:01:08 +00:00
Thomas Adam
4cb29deb93 Merge branch 'obsd-master' 2026-02-27 12:01:08 +00:00
nicm
5413953d30 Validate -O flags, from Dane Jensen in GitHub issue 4889. 2026-02-27 08:25:12 +00:00
nicm
50e51b4513 Fix memory leak, from Chris Lewis, reported by Huihui Huang. 2026-02-27 08:23:02 +00:00
Thomas Adam
ee0647aba6 Merge branch 'obsd-master' 2026-02-26 16:01:09 +00:00
Nicholas Marriott
35be70f1f0 Add DECRPM test from David Turnbull. 2026-02-26 11:32:15 +00:00
nicm
dbb23d2182 Do not free buffer after adding to paste (since it now owns it). 2026-02-26 11:01:48 +00:00
Nicholas Marriott
478eaea982 Update base64 compat. 2026-02-26 10:55:41 +00:00
Thomas Adam
0800e51d41 Merge branch 'obsd-master' 2026-02-26 10:18:15 +00:00
nicm
5ff385f8a9 Tweak previous to reset cursor again as well. 2026-02-25 07:59:45 +00:00
nicm
5b3c642195 Pass paste buffer through vis(3) when pasting to prevent buffers
containing for example the bracket end sequence causing issues. -S flag
disables. Reported by Mason Davis.
2026-02-25 07:53:41 +00:00
nicm
bd6e201926 Do not expand #() in E: and T:, from Mason Davis. 2026-02-24 18:06:41 +00:00
Nicholas Marriott
08779aa2a3 Fix breakage in fuzzer, from David Korczynski, GitHub issue 4871. 2026-02-24 08:27:59 +00:00
nicm
09bd686327 Add sorting (-O flag) and a custom format (-F) to list-keys, from Dane
Jensen in GitHub issue 4845.
2026-02-24 08:20:52 +00:00
nicm
9316476a73 Add commands to turn exit on scroll on, off, toggle. From xcdnlgd at
hotmail dot com in GitHub issue 4884.
2026-02-24 08:00:43 +00:00
nicm
00946007d8 Respond to DECRQM 2026, from David Turnbull in GitHub issue 4887. 2026-02-24 07:50:27 +00:00
Thomas Adam
bc47bc7c22 Merge branch 'obsd-master' 2026-02-23 12:01:08 +00:00
Thomas Adam
dc693601f4 Merge branch 'obsd-master' 2026-02-23 10:01:08 +00:00
nicm
f1f9c63cdb Free history entries properly, from Huihui Huang in GitHub issue 4870. 2026-02-23 09:12:57 +00:00
nicm
0cc4f0fd76 Use buffer size for b64_pton, from someone in GitHub issue 4882. 2026-02-23 09:08:07 +00:00
nicm
0dc1b5adfb Do not leak list on failure, reported by Huihui Huang. 2026-02-23 08:58:40 +00:00
nicm
a76e6eca6b Another memory leak from Huihui Huang. 2026-02-23 08:54:56 +00:00
nicm
8c7278b53a Memory leaks in cmd_display_menu, from Huihui Huang. 2026-02-23 08:50:00 +00:00
nicm
50a3b4c777 Free format on -a, reported by Huihui Huang. 2026-02-23 08:46:57 +00:00
nicm
3094ca1da5 Fix memory leaks, reported by Huihui Huang in GitHub issue 4872. 2026-02-23 08:45:27 +00:00
nicm
23ad10c849 Set cell to default when off screen to avoid crash when logging it. 2026-02-23 08:29:30 +00:00
Thomas Adam
c9fb989a31 Merge branch 'obsd-master' 2026-02-23 08:11:38 +00:00
Nicholas Marriott
8356578a54 Update tmux bash completion file link in README, from Hyun Seungmin. 2026-02-20 08:43:35 +00:00
nicm
0310404155 Reuse the same extended slot when clearing non-RGB cells as well. From
Michael K Darling in GitHub issue 4865.
2026-02-20 08:41:23 +00:00
nicm
03f8690f9c Pass which clipboard is set through to the terminal, from Axel Lindskog
in GitHub issue 4858.
2026-02-18 09:10:31 +00:00
Thomas Adam
4cc3de4f84 Merge branch 'obsd-master' 2026-02-17 08:51:05 +00:00
nicm
fedd4440f0 Reuse extended entry when clearing RGB cell, to prevent memory growth
when cells are repeatedly cleared (they are only compacted when scrolled
off screen). From Michael K Darling in GitHub issue 4862.
2026-02-17 07:42:58 +00:00
nicm
55cedc24fa Format layout change string once per window in control notify, from
Conor Taylor in GitHub issue 4848.
2026-02-16 08:45:38 +00:00
nicm
c9162837a0 Pull format allocation outside of loop for control subs, from Conor
Taylor in GitHub issue 4848.
2026-02-16 08:42:57 +00:00
nicm
f218463976 grid_peek_cell can return NULL, so check for it. From Conor Taylor in
GitHub issue 4848.
2026-02-16 08:02:04 +00:00
nicm
1f0c54f7ea Initialize bufname, reported by Mark Kelly. 2026-02-15 17:43:26 +00:00
Thomas Adam
d3522c328c Merge branch 'obsd-master' 2026-02-12 11:10:01 +00:00
nicm
7e50eb0e83 Make paste_get_top return a copy of the buffer name which is more
sensible and avoids a double free pointed out by DongHan Kim.
2026-02-11 08:30:37 +00:00
nicm
5b455abecc Do not write before buffer when parsing empty clipboard or palette
replies, or try to allocate zero bytes with an empty clipboard sequence.
Reported by DongHan Kim.
2026-02-11 08:23:21 +00:00
nicm
7d41761e84 Fix clients_calculate_size for manual type when window is NULL. From
Elias Oenal in GitHub issue 4849.
2026-02-10 10:02:11 +00:00
nicm
25f6d8b1e9 Implement some obvious missing sort orders, from Dane Jensen in GitHub
issue 4813.
2026-02-10 09:55:53 +00:00
nicm
5a33616e65 Check for no window when updating clients, GitHub issue 4851. 2026-02-10 09:00:30 +00:00
nicm
1cf17b06ae Batch printable output in control mode, from Conor Taylor in GitHub issue 4848. 2026-02-10 08:40:03 +00:00
nicm
aa03706ed0 Remove redundant call to tty_attributes, from Conor Taylor in GitHub
issue 4848.
2026-02-10 08:34:43 +00:00
nicm
d8794e2b30 Check log level before log_debug in tty_draw_line, from Conor Taylor in
GitHub issue 4848.
2026-02-10 08:31:45 +00:00
nicm
b7939eb266 Don't call event_add again if the event is already pending, from Conor
Taylor in GitHub issue 4848.
2026-02-10 08:30:21 +00:00
nicm
19b9a34c48 Only loop over clients if table actually found, from Conor Taylor in
GitHub issue 4848.
2026-02-10 08:28:53 +00:00
nicm
f016e08153 Fix wrong TAILQ member in input_cancel_requests from Conor Taylor in
GitHub issue 4848.
2026-02-10 08:27:17 +00:00
nicm
7b1c503086 Clear search counts when clearing marks in case of repeated search,
reported by Daniel Pereira in GitHub issue 4817.
2026-02-06 10:28:42 +00:00
nicm
5865001e4a Also check PANE_STATUSREADY for pane_dead format to match
pane_dead_status. GitHub issue 4841 from Joshua Pollack.
2026-02-06 10:23:26 +00:00
nicm
62944da74b Make OSC 52 work in popups, from gogongxt at 163 dot com in GitHub issue
4797.
2026-02-03 09:07:44 +00:00
nicm
588013bb44 Refresh copy mode when style changes, from Josh Cooper in GitHub issue 4830. 2026-02-03 08:53:58 +00:00
Thomas Adam
615c27c117 Merge branch 'obsd-master' 2026-02-02 19:06:25 +00:00
nicm
3c3d9ce3a9 Break sorting out into a common file so formats and modes use the same
code. Also add -O for sorting to the list commands. From Dane Jensen in
GitHub issue 4813.
2026-02-02 10:08:30 +00:00
nicm
66011fe48b Do not treat cells as empty unless the background colour stays the same.
Fixes invisible clock in clock mode, reported by tb@.
2026-01-29 09:08:19 +00:00
Thomas Adam
d7f59eccaf Merge branch 'obsd-master' 2026-01-28 17:25:42 +00:00
Thomas Adam
e652213855 Merge branch 'obsd-master' 2026-01-23 10:50:55 +00:00
nicm
f70150a663 Replace overlay_ranges with visible_ranges which can hold more than
three ranges (will be needed for floating panes); move the visible
ranges checks outside of tty_draw_line and rewrite it to fix issues with
partially-obscured wide characters. With Michael Grant.
2026-01-23 10:45:53 +00:00
Nicholas Marriott
fe52f76913 Fiddle with some more warnings. 2026-01-22 15:02:42 +00:00
Nicholas Marriott
0d9c3c895c Stick the pragmas outside the function (make GCC 4 happier) and under __GNUC__. 2026-01-22 14:29:29 +00:00
Nicholas Marriott
6525bb7cef Line length/style nits. 2026-01-22 14:16:39 +00:00
Michael Grant
0790e74f84 Fix strftime warning in gcc. 2026-01-22 14:11:00 +00:00
nicm
195a9cfd88 When history-limit is changed, apply to existing panes, not just new
ones. GitHub issue 4705.
2026-01-22 08:55:01 +00:00
nicm
ecbf8d76d0 Reevaluate menu and popup styles on each draw to allow them to change
when options change, from Josh Cooper in GitHub issues 4828 and 4829.
2026-01-22 07:52:24 +00:00
nicm
818745a605 Set PANE_STYLECHANGED when user options change, from Josh Cooper in
GitHub issue 4825.
2026-01-22 07:42:30 +00:00
nicm
26aacd0e32 Handle theme keys earlier so they are processed even if a popup is open.
From Josh Cooper in GitHub issue 4827.
2026-01-22 07:39:35 +00:00
nicm
8e06739e26 Fix window-size=latest not resizing on switch-client in session groups.
From Ilya Grigoriev in GitHub issue 4818.
2026-01-20 22:50:08 +00:00
nicm
ab1f2ef71c Add a function to convert a screen to a string, from Michael Grant. 2026-01-20 16:32:05 +00:00
Nicholas Marriott
d2e09cb259 Add a --enable-optimizations configure flag. 2026-01-20 15:42:22 +00:00
Thomas Adam
bf8ea85bd7 Merge branch 'obsd-master' 2026-01-19 10:01:08 +00:00
nicm
9c0aeaff40 Now the copy mode indicator can be changed, we need to redraw it when
the cursor is moved. GitHub issue 4774.
2026-01-19 08:20:51 +00:00
Thomas Adam
95b4bb51c6 Merge branch 'obsd-master' 2026-01-14 22:01:08 +00:00
nicm
1e5f93b7b6 Add -e flag to command-prompt to close if empty, from Dane Jensen in
GitHub issue 4812.
2026-01-14 19:43:43 +00:00
Nicholas Marriott
b89d46bb00 Add a regression test from Ilya Grigoriev. 2026-01-13 20:29:21 +00:00
Thomas Adam
97d61131df Merge branch 'obsd-master' 2026-01-12 10:01:08 +00:00
nicm
5721767921 Correctly draw indicators when pane-border-indicators is set to both.
Reported by Ilya Grigoriev in GitHub issue 4780.
2026-01-12 07:50:16 +00:00
nicm
a443531280 Remember last pane or type of location for double and triple clicks and
correctly handle it changes between first and second or second and
third. GitHub issue 4795 from Shaobo Song.
2026-01-12 07:48:36 +00:00
Thomas Adam
ad083677c5 Merge branch 'obsd-master' 2026-01-11 14:01:08 +00:00
nicm
426467856d Add paste to the default pane menu, GitHub issue 4763. 2026-01-11 11:48:46 +00:00
Thomas Adam
844042744e Merge branch 'obsd-master' 2026-01-09 18:01:07 +00:00
nicm
65b3a95be8 Removing padding needs to go through screen_write_collect_trim or there
may end up multiple items covering the same region.
2026-01-09 15:04:00 +00:00
Thomas Adam
ca95950148 Merge branch 'obsd-master' 2026-01-08 14:01:08 +00:00
nicm
6234d79852 Do not set manual size if no window. 2026-01-08 12:05:02 +00:00
Thomas Adam
a5d8b92012 Merge branch 'obsd-master' 2026-01-08 10:01:08 +00:00
nicm
890cfc6dc3 Copy palette responses before processing them since they are not strings. 2026-01-08 07:54:23 +00:00
Thomas Adam
0e6fc2e88b Merge branch 'obsd-master' 2026-01-07 22:01:07 +00:00
nicm
c8ccd420be Reduce request timeout to 500 milliseconds to match the extended
escape-time, and discard palette requests if receiving a reply for a
different index.
2026-01-07 20:16:32 +00:00
nicm
ff4f6b9066 Extend escape timeout if there are active forwarded requests not just
tmux's own requests. GitHub issue 4793.
2026-01-07 20:03:34 +00:00
Thomas Adam
7cffa2de78 Merge branch 'obsd-master' 2026-01-07 20:01:09 +00:00
nicm
e2afaaea75 Correct redrawing of wide characters when overwritten. Reported by Jake
Stewart in GitHub issue 4737.
2026-01-07 18:29:15 +00:00
Thomas Adam
75d3974c12 Merge branch 'obsd-master' 2026-01-07 10:01:08 +00:00
nicm
583f12ea71 Work out the default command from the queue in case it has been set from
the config file, GitHub issue 4791.
2026-01-07 08:16:20 +00:00
Thomas Adam
3de7a8ad8d Merge branch 'obsd-master' 2026-01-06 22:01:07 +00:00
nicm
f6c9052082 If cannot find a terminator for palette responses, treat as a partial
key not complete. GitHub issue 4749.
2026-01-06 20:09:42 +00:00
nicm
f226804149 Do not send theme unless it has changed, and do not send immediately
when updates are enabled. GitHub issue 5787.
2026-01-06 20:05:57 +00:00
Thomas Adam
cf94486e32 Merge branch 'obsd-master' 2026-01-06 16:01:07 +00:00
nicm
035a2f35d4 Clear trimmed lines after moving, from Antony Raj in GitHub issue 4790. 2026-01-06 14:33:05 +00:00
Thomas Adam
9b7732eac4 Merge branch 'obsd-master' 2026-01-06 12:01:07 +00:00
nicm
5f9dac8abc Do not use ;;s in list-keys output as it is confusing and cannot be
parsed on input, from Patrick Motard in GitHub issue 4750.
2026-01-06 10:17:29 +00:00
nicm
ccd4dd7ff2 Do not log theme if pane is NULL. 2026-01-06 09:11:15 +00:00
Thomas Adam
77417b7cbe Merge branch 'obsd-master' 2026-01-05 10:01:08 +00:00
nicm
6a7cd79a63 Redraw pane borders when entering or leaving alternate screen, from Mike
Jonkmans in GitHub issue 4788.
2026-01-05 08:32:19 +00:00
nicm
baa3b51b3e Do not use client if there isn't one, GitHub issue 4789. 2026-01-05 08:30:30 +00:00
Thomas Adam
abeba4910c Merge branch 'obsd-master' 2026-01-04 10:01:08 +00:00
Nicholas Marriott
356d0aedbd Remove an unused declaration (from OpenBSD, same change also sent by Mike
Jonkmans).
2026-01-04 08:41:38 +00:00
nicm
45f23f3a59 Minor tidying of cmd_list_print from Pavel Roskin. 2026-01-04 08:38:26 +00:00
nicm
6ef7375ade Add some missing logging bits for themes. 2026-01-04 08:05:14 +00:00
Thomas Adam
00030aabf7 Merge branch 'obsd-master' 2025-12-25 20:01:08 +00:00
nicm
f72832cc08 Add focus-follows-mouse option, from Barry Wasdell in GitHub issue 4771. 2025-12-25 18:07:00 +00:00
nicm
b5c33ca2b7 Add selection_mode format variable for copy mode, from Mike Jonkmans in
GitHub issue 4773.
2025-12-25 18:05:15 +00:00
Thomas Adam
d607399850 Merge branch 'obsd-master' 2025-12-22 10:01:08 +00:00
nicm
d005803934 Add prompt-command-cursor-style, from Joshua Cooper in GitHub issue 4765. 2025-12-22 08:41:01 +00:00
nicm
a22ec275b4 With status-keys vi, move the cursor left by one when pressing Escape to
enter command mode, like vi. GitHub issue 4767 from Joshua Cooper.
2025-12-22 08:39:35 +00:00
nicm
188f963fe0 Add {current}/{active} for -t for current window or active pane, from
Manuel Einfalt in GitHub issue 4766.
2025-12-22 08:35:04 +00:00
Thomas Adam
9c5df33325 Merge branch 'obsd-master' 2025-12-19 10:01:07 +00:00
nicm
74f60951cc Do not leak items if not using them because of synchronized update. 2025-12-19 08:46:25 +00:00
Nicholas Marriott
54202fcaad Check image size against available screen size properly, GitHub issue 4739. 2025-12-18 13:44:17 +00:00
Nicholas Marriott
fe645c5bcc Fix image scrolling at exact screen height, and add more logging for images. 2025-12-18 09:05:37 +00:00
Thomas Adam
86c15d7ae9 Merge branch 'obsd-master' 2025-12-17 14:01:08 +00:00
Thomas Adam
3c36d5e433 Merge branch 'obsd-master' 2025-12-17 12:01:07 +00:00
nicm
1c7e164c22 Add support for applications to use synchronized output mode (DECSET
2026) to prevent screen tearing during rapid updates. When an
application sends SM ?2026, tmux buffers output until RM ?2026 is received
or a 1-second timeout expires.

From Chris Lloyd with the assistance of Claude Code, GitHub issue 4744.
2025-12-17 11:49:29 +00:00
nicm
ce7eb22e3a Do not have a default prompt cursor colour because some terminals
(urxvt, st) do not support the reset sequence. GitHub issue 4759.
2025-12-17 10:20:21 +00:00
Thomas Adam
739a97140f Merge branch 'obsd-master' 2025-12-17 10:01:07 +00:00
nicm
99ed397e9c Make clock mode seconds synchronized to the second, GitHub issue 4760
from Joao Pedro.
2025-12-17 08:38:12 +00:00
Thomas Adam
d2c7668bc2 Merge branch 'obsd-master' 2025-12-16 00:01:08 +00:00
nicm
7abf3e8bdf Note that switch-client only changes the key table for one key, pointed
out by Jeenu Viswambharan.
2025-12-15 21:21:25 +00:00
Thomas Adam
506b4db762 Merge branch 'obsd-master' 2025-12-15 15:19:29 +00:00
bket
21c27fdcae Simplify argument move using TAILQ_CONCAT()
Replace the manual loop moving each argument from cmd->arguments to
last->arguments with a single TAILQ_CONCAT() call. This makes the code
clearer and more efficient, while preserving identical behavior.

OK nicm@
2025-12-11 04:17:17 +00:00
nicm
672e89a640 Add a scroll-to-mouse command for copy mode to scroll to the mouse
position and bind to the scrollbar, brings the scrollbar keys into line
with the other mouse keys. From Michael Grant, GitHub issue 4731.
2025-12-10 21:24:43 +00:00
Nicholas Marriott
4b810ae493 Add a define for max images and bump to 20 for the moment. 2025-12-09 08:46:00 +00:00
nicm
52e2a7d990 Fix key code for M-BSpace, GitHub issue 4717. 2025-12-09 08:13:59 +00:00
Nicholas Marriott
2e5e9c0298 Fix calculation of scaled SIXEL size, from nincsnevem662 at gmail dot com in
GitHub issue 4739.
2025-12-08 21:41:30 +00:00
nicm
afa05ae15e Use correct style for bottom line when pane status line is on, GitHub
issue 4732.
2025-12-08 21:32:50 +00:00
nicm
f58b8d0d6a Setting working directory after fork means there is a race with
pane_current_path (especially on platforms with systemd which have to
take time to do some additional faffing around). To avoid this, change
it before fork and back in the parent afterwards. GitHub issue 4719.
2025-12-08 08:04:35 +00:00
Nicholas Marriott
5c73d3878d FIx combine test again... 2025-12-07 22:11:45 +00:00
Nicholas Marriott
ef0a7e328c Merge branch 'tmux-3.6a' 2025-12-05 06:20:32 +00:00
Nicholas Marriott
cc117b5048 Update CHANGES. 2025-12-05 05:39:46 +00:00
nicm
faebe7a70a Do not read over buffer if format is a single #, and do not loop forever
if UTF-8 is unfinished in a format. Reported by Giorgi Kobakhia im
GitHub issue 4735.
2025-12-05 05:38:05 +00:00
nicm
01962e25dc Allow drag in alternate screen again, GitHub issue 4743 reported by Brad
King.
2025-12-05 05:37:57 +00:00
nicm
ff207eb583 Fix y offset of mouse if status at top. GitHub issue 4738 from Michael
Grant.
2025-12-05 05:37:48 +00:00
Thomas Adam
8e922ab690 Merge branch 'obsd-master' 2025-12-05 02:01:07 +00:00
Thomas Adam
1a3db6b65e Merge branch 'obsd-master' 2025-12-05 00:01:08 +00:00
nicm
987e05ff31 Allow drag in alternate screen again, GitHub issue 4743 reported by Brad
King.
2025-12-04 22:50:34 +00:00
Nicholas Marriott
2fc123cf4a Update CHANGES. 2025-12-04 20:54:44 +00:00
nicm
3b57077d01 Add a missing skin tone, from Jake Stewart in GitHub issue 4736. 2025-12-04 20:53:01 +00:00
nicm
33c1ba1549 Allow characters to be combined in either order, reported by Jake
Stewart in GitHub issue 4726.
2025-12-04 20:52:55 +00:00
nicm
bd16b22dac Do not read over buffer if format is a single #, and do not loop forever
if UTF-8 is unfinished in a format. Reported by Giorgi Kobakhia im
GitHub issue 4735.
2025-12-04 20:49:57 +00:00
Thomas Adam
0929d8ddfa Merge branch 'obsd-master' 2025-12-04 16:01:08 +00:00
nicm
9d6c69ebde Fix y offset of mouse if status at top. GitHub issue 4738 from Michael
Grant.
2025-12-04 14:45:32 +00:00
Thomas Adam
1bcd360dfe Merge branch 'obsd-master' 2025-12-04 08:01:07 +00:00
nicm
1f2210a3ce Add a missing skin tone, from Jake Stewart in GitHub issue 4736. 2025-12-04 06:04:21 +00:00
nicm
2fe1378d3a Allow characters to be combined in either order, reported by Jake
Stewart in GitHub issue 4726.
2025-12-04 06:02:27 +00:00
Thomas Adam
796539c60b Merge branch 'obsd-master' 2025-12-03 10:01:09 +00:00
Thomas Adam
700936b2ad Merge branch 'obsd-master' 2025-12-03 08:01:07 +00:00
nicm
a28dbe3a59 Improve code readability in colour_palette_get and colour_palette_set.
GitHub issue 4730 from Pavel Roskin.
2025-12-03 07:41:38 +00:00
nicm
820df0f551 Add check that the pane is not in alternate screen mode when in
copy-mode. From Michael Grant in GitHub issue 4728.
2025-12-03 07:38:46 +00:00
nicm
ee9cf1bbaa Fix the size caluation for left-right windows used to spread out cells
horizontally evenly. From Michael Grant in GitHub issue 4724.
2025-12-03 07:35:32 +00:00
Nicholas Marriott
52917abe21 Update CHANGES. 2025-12-02 14:26:30 +00:00
nicm
a40f98df0a Change noattr to be an explicit attribute in the style so that it works
correctly and does not delete attributes set in the style itself, GitHub
issue 4713.
2025-12-02 14:25:05 +00:00
nicm
2c78a5aceb Add horizontal border case to server_client_check_mouse_in_pane to fix
mouse resizing. GitHub issue 4720 from Michael Grant, reported by
someone in GitHub issue 4715.
2025-12-02 14:24:57 +00:00
Thomas Adam
02a8e3fd34 Merge branch 'obsd-master' 2025-12-02 10:01:08 +00:00
nicm
322adfbdde Add a get-clipboard option which when enabled (the default is off) uses
the same mechanism as palette requests to request clipboard from the
terminal and forward to the requesting pane. Remove the now-redundant
forward-to-pane ability from "refresh-client -l". GitHub issue 4275.
2025-12-02 08:20:32 +00:00
Thomas Adam
194d0a0e25 Merge branch 'obsd-master' 2025-12-01 10:01:08 +00:00
Nicholas Marriott
b2d6ebaa10 Fix combine-test.result, GitHub issue 4717. 2025-12-01 08:22:12 +00:00
Nicholas Marriott
bfecbb0685 Fix combine-test.result, GitHub issue 4717. 2025-12-01 08:21:04 +00:00
nicm
e4c552f5a5 Change noattr to be an explicit attribute in the style so that it works
correctly and does not delete attributes set in the style itself, GitHub
issue 4713.
2025-12-01 08:14:29 +00:00
nicm
04f32073c0 Add horizontal border case to server_client_check_mouse_in_pane to fix
mouse resizing. GitHub issue 4720 from Michael Grant, reported by
someone in GitHub issue 4715.
2025-12-01 08:04:26 +00:00
Thomas Adam
e9afd2bb5e Merge branch 'obsd-master' 2025-11-28 12:01:09 +00:00
nicm
55d660a548 Do not remove TERM etc for commands run from config file, reported by
Dennis Eriksen.
2025-11-28 09:42:48 +00:00
nicm
dfaf47d97c session_index was never actually implemented, remove from man page. 2025-11-28 09:14:17 +00:00
Nicholas Marriott
640e1a7643 Update CHANGES. 2025-11-27 07:26:09 +00:00
nicm
2a0b078e15 Place cursor on correct line if message-line is not 0, reported by
Alexis Hildebrandt.
2025-11-27 07:24:50 +00:00
nicm
0af04295f3 Newer libevents do not allow event_del on a zero'd event. 2025-11-27 07:24:47 +00:00
Thomas Adam
3542bfa5b8 Merge branch 'obsd-master' 2025-11-26 22:01:08 +00:00
nicm
e3a54ed0f4 Newer libevents do not allow event_del on a zero'd event. 2025-11-26 19:02:03 +00:00
Nicholas Marriott
ec4b5b52af Version and CHANGES. 2025-11-26 19:00:17 +00:00
nicm
a0dfef3b04 Place cursor on correct line if message-line is not 0, reported by
Alexis Hildebrandt.
2025-11-26 18:57:18 +00:00
Nicholas Marriott
6db6a30ab5 Need signal.h for utempter, from Yasuhiro Kimura. 2025-11-26 18:43:11 +00:00
Nicholas Marriott
bfa2f73335 Need signal.h for utempter, from Yasuhiro Kimura. 2025-11-26 10:41:17 +00:00
Nicholas Marriott
1decccace7 Update version. 2025-11-26 08:44:41 +00:00
Nicholas Marriott
ee53d49059 Merge branch 'tmux-3.6' 2025-11-26 08:44:18 +00:00
Nicholas Marriott
0dac7fe434 Add to CHANGES. 2025-11-26 08:34:33 +00:00
nicm
a6690032ad Add seconds options for clock mode, from augustus7613 dot mail at pm dot
me in GitHub issue 4697.
2025-11-26 08:33:32 +00:00
Thomas Adam
f949f9a23a Merge branch 'obsd-master' 2025-11-26 00:01:08 +00:00
Nicholas Marriott
00cef3e6be Add to CHANGES. 2025-11-25 22:07:09 +00:00
Nicholas Marriott
3f4a8713c9 Merge branch 'master' into tmux-3.6 2025-11-25 22:06:41 +00:00
Thomas Adam
7c188aec3c Merge branch 'obsd-master' 2025-11-25 22:01:08 +00:00
nicm
f0dec832b8 Add seconds options for clock mode, from augustus7613 dot mail at pm dot
me in GitHub issue 4697.
2025-11-25 21:24:27 +00:00
Nicholas Marriott
ca74fa1db0 Update version and CHANGES. 2025-11-25 21:21:59 +00:00
Nicholas Marriott
987986631d Merge tag '3.5a'
tmux 3.5a.
2025-11-25 20:42:10 +00:00
nicm
1d89233047 Add a resize callback for menus so that they are correctly moved on
resize. From m-einfalt at gmx dot de in GitHub issue 4696.
2025-11-25 20:27:23 +00:00
Thomas Adam
348f16093c Merge branch 'obsd-master' 2025-11-18 10:01:07 +00:00
nicm
2a3ec87887 Make -v to source-file pass through to subsequent source-file commands,
GitHub issue 4216.
2025-11-18 08:42:09 +00:00
nicm
b52dcff745 Allow show-messages to work without a client. 2025-11-18 08:37:54 +00:00
Thomas Adam
f372112a8d Merge branch 'obsd-master' 2025-11-14 10:01:08 +00:00
nicm
72117debf7 Send matching terminator on queued requests, reported by Henry Qin. 2025-11-14 07:55:23 +00:00
Thomas Adam
2f3c71595b Merge branch 'obsd-master' 2025-11-13 16:01:07 +00:00
nicm
113aaf37fc When copying a line from one screen to another, stop only when both
source and target are beyond the allocated line length. Fixes problems
with trailing spaces on pane-border-format. GitHub issue 4688 from
Dmitry Ryabkov.
2025-11-13 13:08:44 +00:00
Nicholas Marriott
768042d29d Fix build afte merge, from Vladimir Lomov. 2025-11-13 07:18:53 +00:00
Thomas Adam
db274f9c39 Merge branch 'obsd-master' 2025-11-12 21:26:29 +00:00
nicm
66279c124e Make requests to the external terminal one queue instead of one by type,
and include any other requests as well so that ordering is maintained.
2025-11-12 20:41:06 +00:00
Thomas Adam
b335419505 Merge branch 'obsd-master' 2025-11-12 16:01:09 +00:00
nicm
3c9e10139f If display-popup is used inside a popup, modify that popup. From
m-einfalt at gmx dot de in GitHub issue 4678.
2025-11-12 13:47:51 +00:00
Thomas Adam
34898c89cd Merge branch 'obsd-master' 2025-11-12 10:01:08 +00:00
nicm
40600eebfa Do not send theme updates to panes that have exited, GitHub issue 4671. 2025-11-12 08:06:33 +00:00
nicm
12497ecade Convert all keys for backspace, not just A-Z. 2025-11-12 07:54:52 +00:00
nicm
9e21f426c0 Add a command to explcitly set the selection mode in copy mode, GitHub
issue 3842.
2025-11-12 07:53:22 +00:00
Nicholas Marriott
c77d49f67e Save and restore images in alternate screen, GitHub issue 3732. 2025-11-12 07:49:17 +00:00
Thomas Adam
33cfe8b809 Merge branch 'obsd-master' 2025-11-07 14:01:08 +00:00
jsg
0d0ef5d0d2 correct test for COLORTERM containing 256
found with smatch, ok nicm@
2025-11-07 12:43:47 +00:00
Nicholas Marriott
d65bac979d Do not try to allocate zero size colours, GitHub issue 4674. 2025-11-07 12:36:07 +00:00
jsg
c1667bd85e consistently use tabs for indentation
found with smatch, ok nicm@
2025-11-07 12:30:36 +00:00
Thomas Adam
815f7ecffb Merge branch 'obsd-master' 2025-11-03 12:01:06 +00:00
Thomas Adam
44c0443983 Merge branch 'obsd-master' 2025-11-03 09:57:35 +00:00
nicm
3051076dd1 Ignore Hangul filler character. There doesn't seem to be much agreement
on what to do with this but ignoring it seems rightand does improve
things. GitHub issue 3998.
2025-11-03 09:27:06 +00:00
nicm
d90b414223 Handle regional indicators and emoji modifiers in a better way, GitHub
issue 3998.
2025-11-01 16:44:24 +00:00
nicm
8cb2805eb7 Handle ~ correctly when loading a file, GitHub issue 3518. 2025-11-01 16:42:59 +00:00
nicm
e5ab5995db Fix now-incorrect text about {}s. 2025-10-31 09:00:26 +00:00
nicm
e774b89062 Preserve marked pane with swap-window and move-window, GitHub issue 3443. 2025-10-30 13:52:08 +00:00
nicm
29db8ac36e Set and check COLORTERM as a hint for RGB colour. 2025-10-30 11:52:25 +00:00
Thomas Adam
be2d4aa434 Merge branch 'obsd-master' 2025-10-30 10:01:07 +00:00
nicm
1e61e52400 If tmux receives a palette request (OSC 4) in a pane and the palette
entry has not been set, send a request to the most recently used client
and forward any response instead. Based on change from Tim Culverhouse
in GitHub issue 4665.
2025-10-30 07:41:19 +00:00
Thomas Adam
4bdfbfa854 Merge branch 'obsd-master' 2025-10-29 12:01:07 +00:00
nicm
2c08960f4e Add -l flag to command-prompt to disable splitting into multiple prompts,
GitHub issue 4483.
2025-10-29 09:37:36 +00:00
nicm
1a419609e3 Don't enter copy mode on mouse wheel in alternate screen, GitHub issue 3705. 2025-10-29 09:33:20 +00:00
Nicholas Marriott
f812b8d304 Cast to avoid warnings on 32-bit architectures. GitHub issue 4597. 2025-10-29 08:49:16 +00:00
Thomas Adam
ff6eefd7c7 Merge branch 'obsd-master' 2025-10-28 18:01:08 +00:00
nicm
0c5abfefd3 Add commands to centre the cursor in copy mode, from m-einfalt at gmx
dot de in GitHub issue 4662.
2025-10-28 16:36:52 +00:00
Thomas Adam
e560a09db0 Merge branch 'obsd-master' 2025-10-28 15:16:58 +00:00
nicm
9bf8ca5856 Support case insensitive search in modes in the same way as copy mode
(like emacs, so all-lowercase means case insensitive). GitHub issue
4396.
2025-10-28 14:21:06 +00:00
Thomas Adam
410abb5afb Merge branch 'obsd-master' 2025-10-28 14:01:08 +00:00
Thomas Adam
482aa937b1 Merge branch 'obsd-master' 2025-10-28 12:01:07 +00:00
nicm
b4ba6e49af Do not realpath() everything since it is pointless and breaks symlinks.
GitHub issue 4427.
2025-10-28 10:51:30 +00:00
Thomas Adam
010394ab63 Merge branch 'obsd-master' 2025-10-28 10:01:07 +00:00
nicm
7cbb96528c Do not try to reflow if line is NULL. 2025-10-28 09:01:12 +00:00
nicm
aa420cd54a Tweak error messages so that file name isn't modified when we capitalize
the first letter, from Pavel Roskin in GitHub issue 4666.
2025-10-28 07:32:26 +00:00
Thomas Adam
d5302ec327 Merge branch 'obsd-master' 2025-10-27 22:01:08 +00:00
nicm
f31a2d229c Do not play games with lines for view mode output since it stops them
wrapping, GitHub issue 4462.
2025-10-27 20:31:40 +00:00
Thomas Adam
35ad72e56f Merge branch 'obsd-master' 2025-10-20 10:01:07 +01:00
nicm
f501817154 Fix the logic of the no-detached case for detach-on-destroy option - a
previous change made it so that even in the no-detached case, tmux would
always re-attach to a session, even if there weren't any detached ones.
From Martin Louazel in GitHub issue 4649.
2025-10-20 07:28:38 +00:00
Thomas Adam
449f255f3e Merge branch 'obsd-master' 2025-10-13 10:01:08 +01:00
nicm
21d890e6df Add buffer_full format variable, from Mohammad AlSaleh in GitHub issue
4630.
2025-10-13 07:29:53 +00:00
nicm
feb3b90596 Check allow-set-title for APC as well. 2025-10-13 07:19:08 +00:00
Nicholas Marriott
0ff2676a25 Implement getdtablecount(3) for Darwin, from Chip Davis in GitHub issue 4636. 2025-10-06 11:13:53 +01:00
Thomas Adam
3e28777ecb Merge branch 'obsd-master' 2025-09-12 12:01:09 +01:00
nicm
7516f8e94f Check the right flags member, reported by someone in GitHub issue 4634. 2025-09-12 08:46:29 +00:00
Thomas Adam
ac574b6782 Merge branch 'obsd-master' 2025-09-09 12:01:09 +01:00
nicm
50dafd6187 Remove some unnecessary assignments. 2025-09-09 08:49:22 +00:00
Thomas Adam
d4f129b513 Merge branch 'obsd-master' 2025-09-08 14:01:08 +01:00
Nicholas Marriott
9a72317c4f Check for vlock earlier to neaten output. 2025-09-08 12:27:26 +01:00
nicm
b21b1ee9af Don't try to change directory if it is NULL. 2025-09-08 11:21:56 +00:00
nicm
c62fe6dac8 The client can be NULL, fixes -v in config file. 2025-09-08 11:21:29 +00:00
Thomas Adam
9dc136f445 Merge branch 'obsd-master' 2025-09-08 12:01:10 +01:00
Thomas Adam
418bf148e0 Merge branch 'obsd-master' 2025-09-08 10:01:08 +01:00
jsg
408721ae37 correct indentation, no functional change
found with smatch, ok nicm@
2025-09-08 08:23:19 +00:00
Nicholas Marriott
b1b6850fa9 Add test for control mode, from Sergei Nizovtsev. 2025-09-08 08:31:23 +01:00
nicm
d73196750f Change so that source-file errors are reported correctly in control
mode, from Sergei Nizovtsev in GitHub issue 4626.
2025-09-08 07:30:15 +00:00
Thomas Adam
093754db3f Merge branch 'obsd-master' 2025-09-07 18:01:08 +01:00
nicm
7cc15969ff Quote cwd for glob in a way that actually works, from Pavel Roskin in
GitHub issue 4623.
2025-09-07 14:17:25 +00:00
nicm
b53cf70262 Introduce a new window option: tiled-layout-max-columns. It configures
the maximum number of columns in the tiled layout. The default value is
0 which means no limit and makes the change backward-compatible. From
vkadlcik at redhat dot com.
2025-09-07 14:03:18 +00:00
Nicholas Marriott
1dadd6c9ae Do not force SIXEL images to a multiple of 6 lines. From nincsnevem662 at gmail
dot com in GitHub issue 4622.
2025-09-07 14:55:18 +01:00
Nicholas Marriott
a7a94cb86f Fix OOB access in sixel_print by ensuring that the number of chunks actually
matches the highest color used on the image, even if not defined as a color
register. From nincsnevem662 at gmail dot com in GitHub issue 4621.
2025-09-07 14:53:08 +01:00
Thomas Adam
3d6954f0f0 Merge branch 'obsd-master' 2025-09-05 10:01:08 +01:00
nicm
267efefdfa Restore default blinking state when restoring default cursor style, from
Andrea Alberti.
2025-09-05 06:15:48 +00:00
Thomas Adam
6a3170386e Merge branch 'obsd-master' 2025-09-02 18:36:44 +01:00
nicm
4d83eef756 Add support for DECRQSS SP q (report cursor style), DECRQM ?12 (report
cursor blink state) and DECRQM ?2004, ?1004, ?1006 (report mouse state).

From Andrea Alberti in GitHub issue 4618.
2025-09-02 15:15:12 +00:00
Thomas Adam
44b7a2d1f9 Merge branch 'obsd-master' 2025-09-02 16:01:08 +01:00
nicm
c32570c602 Set PWD for jobs as well as panes. 2025-09-02 13:39:14 +00:00
Thomas Adam
9702ef3f91 Merge branch 'obsd-master' 2025-09-02 02:01:07 +01:00
Thomas Adam
b2194ac549 Merge branch 'obsd-master' 2025-09-02 00:01:08 +01:00
nicm
b5413dacc7 Delete timer before adding it again. 2025-09-01 22:11:23 +00:00
nicm
aa33757e45 Fix missing argument from OSC 4 reply, from someone in GitHub issue 4596. 2025-09-01 21:44:37 +00:00
Thomas Adam
a0065bea04 Merge branch 'obsd-master' 2025-09-01 12:01:08 +01:00
nicm
5c89d835a6 Add -k flag to display-popup which allows any key to dismiss the popup
once the command has exited. From Meriel Luna Mittelbach in GitHub issue
4612.
2025-09-01 08:03:07 +00:00
nicm
cfb906a0ce Increase the escape delay when waiting for an RGB response no matter
when it is triggered (they can also be sent on resize). GitHub issue
4569.
2025-09-01 07:58:09 +00:00
nicm
af36d7c430 Ensure break-pane -P prints when only one pane is left. From Chaoyi Yin
in GitHub issue 4615.
2025-09-01 07:53:49 +00:00
Nicholas Marriott
0c9165fc71 Give another bit to the first component of SIXEL colours to fix the HLS color
space which uses 360 degrees in its first component. From nincsnevem662 at
gmail dot com in GitHub issue 4616.
2025-09-01 08:31:57 +01:00
Thomas Adam
fa63088dce Merge branch 'obsd-master' 2025-08-26 10:01:07 +01:00
nicm
0b7235c5f0 Correctly calculate lines to clear for deletions, from Pavel Roskin. 2025-08-26 07:17:51 +00:00
nicm
ca0f0419e6 input_stop_utf8 can move the cursor, so it is now wrong to store the
cursor position before calling it. Problem found by Jayakrishna
Vadayath.
2025-08-26 07:15:00 +00:00
nicm
3520e833a4 Be more robust against misbehaving clients, prompted by deraadt based on
a report from sai02 at student dot ubc dot ca.
2025-08-26 07:00:22 +00:00
Nicholas Marriott
bb4866047a Fix build. 2025-08-22 12:58:19 +01:00
Thomas Adam
2070731af1 Merge branch 'obsd-master' 2025-08-22 12:01:08 +01:00
Thomas Adam
a5909b450c Merge branch 'obsd-master' 2025-08-22 10:01:08 +01:00
nicm
94bafa5aaf A couple of memory leaks from someone in GitHub issue 4590. 2025-08-22 07:48:23 +00:00
nicm
7325da3052 Extend pane lookup special case for switch-client to mouse target ("=")
so that it works for panes on status line.
2025-08-22 07:42:51 +00:00
nicm
e6d275b371 Do not leak label if it is too long, GitHub issue 4591. 2025-08-22 07:39:40 +00:00
Thomas Adam
f4c0fe2ede Merge branch 'obsd-master' 2025-08-22 08:37:26 +01:00
nicm
12452f4427 Do not double free argv from MSG_COMMAND if it is too long, reported by
sai02 at student dot ubc dot ca via deraadt. ok deraadt
2025-08-22 07:26:25 +00:00
nicm
1370791734 Add a nicer default second and third status line, from Michael Grant in
GitHub 4490.
2025-08-14 07:15:40 +00:00
nicm
0646814235 Add some NULL checks, GitHub issue 4586. 2025-08-14 06:49:53 +00:00
nicm
84775130a0 Add pane-border-lines value to use spaces for pane borders, from lukas
dot 23022005 at gmail dot com in GitHub issue 4587.
2025-08-14 06:44:50 +00:00
nicm
4ce893ebc0 Do not leak opened file, from lg65438805 at gmail dot com in GitHub
issue 4577.
2025-08-14 06:37:29 +00:00
nicm
3ae0d560be Replace invalid UTF-8 with the placeholder instead of ignoring them
(this is what most terminals do), GitHub issue 4514.
2025-08-12 12:33:05 +00:00
nicm
06c84dba59 Fix PageDown in menus, from Pavel Roskin in GitHub issue 4581. 2025-08-12 12:29:58 +00:00
nicm
d90e7623c6 Free command on failure, GitHub issue 4578. 2025-08-12 12:26:09 +00:00
Thomas Adam
b13005e802 Merge branch 'obsd-master' 2025-08-04 16:01:07 +01:00
nicm
05b2893b9f Do not leak buffer if not used, reported by someone in GitHub issue
4575.
2025-08-04 13:22:10 +00:00
nicm
1bf2023ed4 Flush scrolling when wrapping so UTF-8 in last position draws correctly,
GitHub issue 4518.
2025-08-04 13:16:13 +00:00
Thomas Adam
6f9bcb7fee Merge branch 'obsd-master' 2025-08-01 12:01:08 +01:00
nicm
6d94909c08 Do not leak on failure, GitHub 4565. 2025-08-01 09:05:51 +00:00
Nicholas Marriott
86153fbba9 Add UTF-8 regress test. 2025-08-01 09:45:18 +01:00
nicm
4f38af01e0 Fix reverse documentation of display-popup -s and -S, from Ricardo Signes. 2025-08-01 08:17:27 +00:00
Thomas Adam
a6588d6918 Merge branch 'obsd-master' 2025-07-22 10:01:08 +01:00
Nicholas Marriott
720d1e831d The AIX functions hang on 7300-01-01-2246 according to GitHub issue 4400.
Remove them.
2025-07-22 09:09:56 +01:00
nicm
206f492401 Fix incorrect handling of Korean Hangul Jamo characters. GitHub issue
4546 from Roy Jung.
2025-07-22 07:42:52 +00:00
Nicholas Marriott
fa5f3cef3d Send SIGCHLD after utempter_remove_record as well. GitHub issue 4559. 2025-07-20 19:59:11 +01:00
Thomas Adam
c70d0a6a69 Merge branch 'obsd-master' 2025-07-19 22:01:08 +01:00
nicm
6549aaf393 yyerror should be void. 2025-07-19 19:30:37 +00:00
nicm
6378c87d15 Only accept DA and DA2 when they end in 'c', stops them being confused
with theme responses.. GitHub issue 4561.
2025-07-19 19:20:10 +00:00
Thomas Adam
4a0eff1296 Merge branch 'obsd-master' 2025-07-19 00:01:08 +01:00
nicm
9c07903ae9 Correctly remove overwritten wide characters at column 1. 2025-07-18 20:44:13 +00:00
Thomas Adam
32b7b3a6f7 Merge branch 'obsd-master' 2025-07-17 14:01:08 +01:00
nicm
041bbf8bdf Allow uppercase letters in gray/grey color names, GitHub issue 4560 from
Pavel Roskin.
2025-07-17 11:39:23 +00:00
Nicholas Marriott
701f6b4b2f Update use-this-issue-template.md 2025-07-17 10:59:53 +01:00
Nicholas Marriott
bddd019a04 Update use-this-issue-template.md 2025-07-17 10:58:28 +01:00
Thomas Adam
865117a05f Merge branch 'obsd-master' 2025-07-13 10:01:08 +01:00
nicm
e6bac234db Increase delay for foreground and background queries as well as device
attributes, GitHub issue 4541.
2025-07-13 06:32:34 +00:00
Nicholas Marriott
9f1fac9142 Use MAC_OS_X_VERSION_MIN_REQUIRED. From Sevan Janiyan, GitHub issue 4550. 2025-07-13 07:26:35 +01:00
nicm
9831175a2d Use window index not ID for sorting, reported by naru at naruaway dot
com in GitHub issue 4551.
2025-07-13 06:16:28 +00:00
Thomas Adam
7e43953937 Merge branch 'obsd-master' 2025-07-02 12:01:08 +01:00
nicm
28481e984b Add sorting to W, P, L operators as well, and add some new session
format variables. From Michael Grant in GitHub issue 4516.
2025-07-02 08:13:09 +00:00
Thomas Adam
30e4f119d3 Merge branch 'obsd-master' 2025-07-01 12:01:08 +01:00
jsg
01da87c112 new sentence, new line 2025-07-01 08:54:50 +00:00
Nicholas Marriott
e7f15d09be Missed a header. 2025-06-24 15:04:24 +01:00
Nicholas Marriott
cbb3c4bfed Update imsg from OpenBSD. 2025-06-24 15:02:16 +01:00
Thomas Adam
d24993aeab Merge branch 'obsd-master' 2025-06-24 14:01:08 +01:00
nicm
d858ad1179 Detect support for OSC 52 using the device attributes report. Some
terminals are using this to indicate that they support copying to the
clipboard with XTerm's OSC 52 sequence. From James Holderness in GitHub
issue 4539.
2025-06-24 10:57:35 +00:00
Thomas Adam
96244dd727 Merge branch 'obsd-master' 2025-06-20 18:01:08 +01:00
Thomas Adam
b38b5d3df2 Merge branch 'obsd-master' 2025-06-20 16:01:08 +01:00
nicm
ad3e6ff054 Add noattr and use in mode-style to allow whether attributes are ignored
or used to be configured. GitHub issue 4498.
2025-06-20 14:54:33 +00:00
nicm
522652913f Add S: to list sessions with modifiers for sorting, from Michael Grant. 2025-06-20 13:31:59 +00:00
Thomas Adam
43e88c892d Merge branch 'obsd-master' 2025-06-16 02:01:07 +01:00
nicm
d82d9468b4 Expand mode-style with E: so # is correctly processed, GitHub issue
4533.
2025-06-15 22:24:51 +00:00
nicm
d7f75ac985 Do not replace SHELL when using /bin/sh. From someone in GitHub issue 4528. 2025-06-15 21:57:58 +00:00
Thomas Adam
1dbceaa790 Merge branch 'obsd-master' 2025-05-28 14:01:08 +01:00
nicm
77ca59acac Add missing theme hooks, from Eric NICOLAS in GitHub issue 4519. 2025-05-28 09:53:57 +00:00
Thomas Adam
7be0613657 Merge branch 'obsd-master' 2025-05-22 12:01:07 +01:00
Thomas Adam
b9ad9186fe Merge branch 'obsd-master' 2025-05-22 10:01:08 +01:00
nicm
3f4b154b70 Bump UTF8_SIZE to the maximum 32 because there are some crazy long UTF-8
sequences out there (GitHub issue 4506). This should not significantly
increase typical memory consumption because we only store each Unicode
character once in the shared cache.
2025-05-22 08:01:29 +00:00
Nicholas Marriott
ff73c95547 New bash completion URL, from David Mandelberg. 2025-05-22 08:52:10 +01:00
Nicholas Marriott
aa0d05f676 Typos, from someone in GitHub issue 4511. 2025-05-22 08:51:14 +01:00
nicm
545832e9fa Typo, from someone in GitHub issue 4511. 2025-05-22 07:49:24 +00:00
nicm
a0ac2a5d63 When there are more than two horizontal windows and the active window is
in not on an edge, correctly highlight both its left and right borders.
GitHub issue 4513 from Michael Grant.
2025-05-22 07:46:38 +00:00
nicm
833c7fbf6d Add a set-default style attribute which replaces the current default
colours and attributes completely, useful at the start of compound
format strings (like status-format) to set the default colours for all
the following options.
2025-05-22 07:43:38 +00:00
Thomas Adam
faf2a44890 Merge branch 'obsd-master' 2025-05-12 14:01:10 +01:00
Thomas Adam
d194ceb604 Merge branch 'obsd-master' 2025-05-12 12:01:10 +01:00
nicm
37a2c98d3d Expand prompts when they are used rather than ahead of time, so the
input can be used as part of the format.
2025-05-12 10:34:13 +00:00
nicm
79b02998a6 Add R format modifier to repeat an argument. 2025-05-12 10:26:19 +00:00
nicm
1ce1e7ef27 Add -E to run-shell to forward stderr as well as stdout, from github at
jyn dot dev in GitHub issue 4246.
2025-05-12 10:16:42 +00:00
nicm
7499d925da Do not downgrade styled underscores to standard underscore if the
terminal does not support them, this matches what would happen if the
application tried to use them on a terminal without support.
2025-05-12 09:50:00 +00:00
nicm
367f17a4ff Preserve colours in selection if the option style is default, GitHub
issue 4498.
2025-05-12 09:17:42 +00:00
Thomas Adam
3d2b26dcfe Merge branch 'obsd-master' 2025-05-01 10:01:11 +01:00
nicm
6106a0f2c4 Add an option variation-selector-always-wide to instruct tmux not to
always interpret VS16 as a wide character and assume the terminal does
likewise. This is behaviour seen in a number of newer terminals' Unicode
14 support but not in older terminals; it seems to be a little
contentious and is currently difficult to detect.

Probably in the long run tmux should pick a behaviour, look at a (new)
terminfo(5) capability to tell it what the terminal will do, and emulate
as required, but at this point I'm not sure that is worth it for
something where support is mixed, seems to be in flux, and that mostly
only matters for emojis.

GitHub issues 3923 and 4475 and others before that.
2025-05-01 07:12:00 +00:00
nicm
1926c1b683 Don't map 256 to white-on-white either, and tidy code a bit. 2025-05-01 06:59:32 +00:00
Nicholas Marriott
6cc1a607fc optarg should be "extern char *" not "extern const char *". 2025-05-01 07:53:02 +01:00
Nicholas Marriott
1905afb3d8 tmux has its own warnx so there is no need for logit (and this gets rid of a
warning).
2025-04-29 17:39:56 +01:00
Nicholas Marriott
345a45083d Run the regress/style-trim.sh test in a plain Bash session, from Koichi Murase. 2025-04-29 17:29:32 +01:00
Nicholas Marriott
3a3babf597 Use printf not echo, from Koichi Murase. 2025-04-28 14:51:27 +01:00
Nicholas Marriott
f367e3a6c8 Switch to getopt_long from OpenSSH, from Koichi Murase in GitHub issue 4492. 2025-04-28 09:02:15 +01:00
Nicholas Marriott
f2283b0cb5 Fix some regress tests. 2025-04-28 08:57:29 +01:00
Nicholas Marriott
26081ac125 Create config.yml 2025-04-28 07:27:57 +01:00
Thomas Adam
36fba4cc54 Merge branch 'obsd-master' 2025-04-25 16:01:08 +01:00
Thomas Adam
58b4286edb Merge branch 'obsd-master' 2025-04-25 14:01:10 +01:00
nicm
b0b6a6f665 Revert change to handle command parsing failures in the client because
it breaks aliases.
2025-04-25 12:25:32 +00:00
nicm
63e5989f53 Remove a stray period, reported by David Mandelberg. 2025-04-25 11:39:39 +00:00
Nicholas Marriott
9da5707d3e Add a run-shell output test. 2025-04-25 12:06:51 +01:00
Thomas Adam
55292b72d1 Merge branch 'obsd-master' 2025-04-25 12:01:09 +01:00
Nicholas Marriott
06b1ad6241 Tests for boolean expressions from David Mandelberg. 2025-04-25 09:28:57 +01:00
nicm
1efe41b9b9 Add more features for boolean expressions in formats: 1) extend && and
|| to support arbitrarily many arguments and 2) add ! and !! for not and
not-not.
2025-04-25 08:28:21 +00:00
Nicholas Marriott
1198eed632 Currently the DCS dispatcher detects Sixel sequences based entirely on the
final character of the sequence, ignoring any intermediates. This means that
other DCS sequences with a q final (like DECRQSS), can be mistakenly
interpreted as Sixel. Add a check to make sure there are no intermediates
before dispatching potential Sixel sequences. From James Holderness in GitHub
issue 4488.
2025-04-25 08:26:26 +01:00
Thomas Adam
0772fe822a Merge branch 'obsd-master' 2025-04-24 12:01:10 +01:00
nicm
f53fac1b56 Do not add a trailing / if there is nothing to follow it, Johannes
Altmanninger in GitHub issue 4472.
2025-04-24 08:55:40 +00:00
nicm
68f2ac9296 Fix examples with too many backslashes, pointed out by David Mandelberg. 2025-04-24 08:54:40 +00:00
Thomas Adam
b4f8340f16 Merge branch 'obsd-master' 2025-04-22 16:01:12 +01:00
nicm
d2f73c17d5 Add calls to layout_fix_panes after a pane swap to fix case if one of
the panes is in alternate screen mode and had a scrollbar. From Michael
Grant in GitHub issue 4481.
2025-04-22 12:36:03 +00:00
nicm
5db914b745 Add notes to menu keys, from someone in GitHub issue 4478. 2025-04-22 12:34:56 +00:00
nicm
cd3d2910ee Fix description of pane_in_mode, from Julian Prein in GitHub issue 4469. 2025-04-22 12:33:35 +00:00
Nicholas Marriott
de7653f5a4 Update format tests for #? changes, from David Mandelberg. 2025-04-22 13:23:33 +01:00
nicm
b905039ed2 Improve #? conditional expression in formats:
1) add support for else if, so
   #{?cond1,value1,#{?cond2,value2,else-value}} can be changed to
   #{?cond1,value1,cond2,value2,else-value};

2) add default empty string if there's no else value, so
   #{?cond1,value1,} can be changed to #{?cond1,value1}.

From David Mandelberg in GitHub issue 4451.
2025-04-22 12:23:26 +00:00
Nicholas Marriott
f0a85d0469 Move cgroup dbus requests to the child to avoid a race where a spawned child
that quickly forks will have only the parent process moved to the newly created
cgroup. From Daniel De Graaf, GitHub issue 4435.
2025-04-14 07:27:02 +01:00
Thomas Adam
ac2779f4d8 Merge branch 'obsd-master' 2025-04-09 10:01:12 +01:00
nicm
68ffe65499 Fix documentation around optional arguments. This includes:
- Syncing between the usage string in code and in the man page.
- Adding optional arguments that were not mentioned (such as
  shell-command arguments).
- Adding square brackets around arguments that are actually optional.

From Julian Prein (julian at druck dot dev) in GitHub issue 4419.
2025-04-09 07:03:04 +00:00
nicm
3e14e7c48b Formats can use environment variables, from David Mandelberg. 2025-04-09 06:51:31 +00:00
nicm
b526e678b5 Make some usages more consistent and add -h to show usage, GitHub issue
4455 from David Mandelberg.
2025-04-09 06:27:43 +00:00
Thomas Adam
d3c39375d5 Merge branch 'obsd-master' 2025-04-03 14:01:10 +01:00
nicm
a7991dcbad Fix padding for word function as well, GitHub issue 4425. 2025-04-03 11:52:25 +00:00
nicm
47dff97834 Use backing grid for word in copy mode for wrapped flags, from someone
in GitHub issue 4447.
2025-04-03 11:51:27 +00:00
Thomas Adam
2905395695 Merge branch 'obsd-master' 2025-04-02 12:01:13 +01:00
nicm
4bf38da4d4 Only align panes and windows, not sessions, from David Mandelberg in
GitHub issue 4444.
2025-04-02 09:31:00 +00:00
nicm
9b37b9285e Popup window should not be draggable while mouse still pressed, and do
not try to work out theme if no pane. From Michael Grant in GitHub issue
4330.
2025-04-02 09:12:05 +00:00
Thomas Adam
dfdced2ab1 Merge branch 'obsd-master' 2025-03-31 00:01:10 +01:00
Nicholas Marriott
c2a95a372f Add a note about closed issues, from David Mandelberg. 2025-03-30 23:04:22 +01:00
nicm
ef923d28ff Do not try to trigger theme changed if session is NULL. 2025-03-30 22:01:55 +00:00
nicm
53b0e0bc02 Missing space, from David Mandelberg. 2025-03-30 21:47:01 +00:00
Thomas Adam
096c4b3e63 Merge branch 'obsd-master' 2025-03-28 20:01:10 +00:00
Thomas Adam
b8189d6ee3 Merge branch 'obsd-master' 2025-03-28 18:01:11 +00:00
nicm
f41dc91357 Only copy the key string not two bytes extra, found by David Mandelberg. 2025-03-28 17:15:25 +00:00
nicm
ef0c12ad9e Fix read of uninitialized memory for jobs with JOB_PTY flag. From David
Mandelberg.
2025-03-28 17:03:49 +00:00
Thomas Adam
9e1f110db0 Merge branch 'obsd-master' 2025-03-24 22:01:11 +00:00
nicm
483b2b3edb Correctly skip wide characters in hyperlinks, from someone in GitHub
issue 4425.
2025-03-24 20:17:24 +00:00
nicm
34a35b0f09 Expand formats with the pane modifier in tree mode so that #() doesn't
always use the same value. From Michael Grant in GitHub issues 4412 and
4420.
2025-03-24 20:13:03 +00:00
nicm
aca3ffb30a Add default-client-command to set the command used is tmux is run
without a command (the default stays new-session). From David Mandelberg
in GitHub issue 4422.
2025-03-24 20:01:03 +00:00
Thomas Adam
c3c4524def Merge branch 'obsd-master' 2025-03-21 16:01:11 +00:00
nicm
f101762d1b Fix mouse_hyperlink format in copy mode. From someone in GitHub issue
4418.
2025-03-21 14:04:26 +00:00
nicm
a541be3951 Add S-Up and S-Down to move windows in tree mode. From David Mandelberg
in GitHub issue 4415.
2025-03-21 13:36:42 +00:00
nicm
b7d640e764 Add some additional cursor format variables. From shiro at usagi dot io
in GitHub issue 4414.
2025-03-21 13:26:39 +00:00
Thomas Adam
969f6a60c3 portable: SYNCING: correct tmux-openbsd
The tmux-openbsd repository is called tmux-obsd.

Noticed via Github issue #4419
2025-03-21 12:46:06 +00:00
Thomas Adam
6703cb85d9 Merge branch 'obsd-master' 2025-03-21 04:01:10 +00:00
jsg
111e16e772 remove prototypes for removed functions 2025-03-21 02:10:42 +00:00
Thomas Adam
3eb93383a3 Merge branch 'obsd-master' 2025-03-17 22:01:10 +00:00
nicm
817b621d20 If there is an active query, set escape time temporarily to a higher
value (the old default - 500). Some Windows terminals are very slow to
respond, or the network may be slow. From github at jyn dot dev.
2025-03-17 20:43:29 +00:00
nicm
5eb30c1543 Handle padding cells correctly for regular expression searching, GitHub issue 4399 from
github at jyn dot dev.
2025-03-17 20:33:20 +00:00
Thomas Adam
d4b8635f50 Merge branch 'obsd-master' 2025-03-11 10:01:12 +00:00
nicm
4e4fe3eb39 Cleanup window_get_active_at function. GitHub issue 4401 from Michael
Grant.
2025-03-11 08:14:26 +00:00
Thomas Adam
882fb4d295 Merge branch 'obsd-master' 2025-03-04 10:01:15 +00:00
nicm
eaf70c955b Add mode 2031 support to automatically report dark or light theme. tmux
will guess the theme from the background colour on terminals which do
not themselves support the escape sequence. Written by Jonathan
Slenders, GitHub issue 4353.
2025-03-04 08:45:04 +00:00
nicm
3543d79048 Free fill character string if it cannot be used, GitHub issue 4394. 2025-03-04 08:03:19 +00:00
Thomas Adam
94783addfc Merge branch 'obsd-master' 2025-02-26 10:01:14 +00:00
nicm
91c0de60b4 Also need the implied meta paste keys in the list for output. 2025-02-26 09:02:00 +00:00
nicm
21f7db4c4d Do not allow meta prefix on paste start and end sequences, GitHub issue 4387. 2025-02-26 08:55:27 +00:00
nicm
f224d61f37 Document the use of ';' as a modifier separator, from Matt Liggett in
GitHub issue 4384.
2025-02-26 07:50:36 +00:00
nicm
d938ab5dd7 If command parsing fails in the client, report the error rather than
trying to send the command to the server. GitHub issue 4372 from Nikola
Tadic.
2025-02-26 07:47:46 +00:00
nicm
9a8f46e554 Fix colouring of pane border when scrollbars are enabled, GitHub issue
4378 from Michael Grant.
2025-02-26 07:42:52 +00:00
nicm
27ee0c9c3b Add the width of the scrollbars to the calculation of the width of the
window panes when finding the adjacent panes, GitHub issue 4370 from
Michael Grant.
2025-02-26 07:39:50 +00:00
Thomas Adam
251a87e2d2 Merge branch 'obsd-master' 2025-02-20 16:01:14 +00:00
nicm
084e6ee9ec Add a -M flag to capture-pane to use the copy mode screen, GitHub issue
4358.
2025-02-20 13:39:58 +00:00
nicm
18331e39bf Reset overlay_resize pointer when clearing overlay. 2025-02-20 13:32:07 +00:00
Nicholas Marriott
250c88efdc Add .swp, from Nikola Tadic. 2025-02-20 13:31:07 +00:00
Thomas Adam
9a377485be Merge branch 'obsd-master' 2025-02-13 18:01:08 +00:00
nicm
47a56c11f2 Add a note about C-r and C-s behaviour, GitHub issue 4309.
Also add a missing word, from jmc@.
2025-02-13 16:31:25 +00:00
Nicholas Marriott
c4b9716873 Look for imsg_add not _init now. 2025-02-13 16:24:33 +00:00
Thomas Adam
ec119b2f9e Merge branch 'obsd-master' 2025-02-10 10:01:11 +00:00
nicm
5d1a6acc84 Align index numbers in trees, from David Mandelberg, GitHub issue 4360. 2025-02-10 08:18:23 +00:00
nicm
80eb460fc9 Add display-message -C flag to update pane while message is displayed,
GitHub issue 4363 from Vitaly Ostrosablin.
2025-02-10 08:14:32 +00:00
Thomas Adam
ef68debc8d Merge branch 'obsd-master' 2025-01-27 12:01:13 +00:00
nicm
4c12ac9fb8 Make list-commands command show only one command if an argument is
given, from Ilya Grigoriev in GitHub issue 4352.
2025-01-27 09:16:05 +00:00
nicm
244bb726e2 Add some missing spaces, from Ilya Grigoriev. 2025-01-27 09:05:22 +00:00
Nicholas Marriott
6ab268c7bb Remove old issue template. 2025-01-20 13:06:03 +00:00
Nicholas Marriott
0c9f8ff189 Update issue templates 2025-01-20 13:02:24 +00:00
Nicholas Marriott
dd7d04be95 Update issue templates 2025-01-20 13:00:07 +00:00
Thomas Adam
58392d29da Merge branch 'obsd-master' 2025-01-17 18:01:08 +00:00
nicm
9260f5dc96 Do not update focus on client's without a session. 2025-01-17 15:53:01 +00:00
Thomas Adam
62a6c16b43 Merge branch 'obsd-master' 2025-01-13 12:01:11 +00:00
nicm
31e8d4676a Count line numbers correctly inside strings, reported by Pedro Navarro
in GitHub issue 4325.
2025-01-13 08:58:34 +00:00
Thomas Adam
d3cbe00f78 Merge branch 'obsd-master' 2025-01-12 16:01:11 +00:00
nicm
97fe3563fa Do not crash if moving popup that has exited to a pane, from Michael
Grant in GitHub issue 4312.
2025-01-12 14:36:28 +00:00
nicm
37ad1e2f6d Map bright black (colour 8) to white (7) if the background is black on
terminals with only eight colours so the text is not invisible. From
Dmytro Bagrii in GitHub issue 4322.
2025-01-12 14:20:49 +00:00
Thomas Adam
00894d188d Merge branch 'obsd-master' 2025-01-02 12:01:10 +00:00
nicm
2a5eba7899 Check backspace against VERASE earlier before it is translated to an
internal key and do not go through the mapping on output. Fixes problems
reported by Ben Price in GitHub issue 4284 and by tb@.
2025-01-02 10:34:45 +00:00
Thomas Adam
bf30492d57 Merge branch 'obsd-master' 2025-01-01 18:01:10 +00:00
nicm
e00853ee82 Add an option allowing users to override the width of individual Unicode
codepoints (overriding tmux's default list).
2025-01-01 15:17:36 +00:00
Thomas Adam
e75f3a0060 Merge branch 'obsd-master' 2024-12-20 10:01:10 +00:00
nicm
eece41547e Only map S-Tag in mode 2, not mode 1. GitHub issue 4304. 2024-12-20 07:10:51 +00:00
Thomas Adam
c311202b73 Merge branch 'obsd-master' 2024-12-17 10:01:11 +00:00
nicm
e149d29803 Assign excess space more evenly when spreading out cells, from Torbjorn
Lonnemark.
2024-12-17 08:40:24 +00:00
Thomas Adam
190ddda572 Merge branch 'obsd-master' 2024-12-16 12:01:12 +00:00
Thomas Adam
6b470c5222 Merge branch 'obsd-master' 2024-12-16 10:01:11 +00:00
nicm
6b32d195e8 Add a nesting limit to source-file, from Fadi Afani in GitHub issue
4223.
2024-12-16 09:13:09 +00:00
nicm
bec6ce54c1 Memory leak, GitHub issue 4298. 2024-12-16 08:54:34 +00:00
nicm
106d1c3538 Missing main-vertical-mirrored from layout list, from charlotte at
lottia dot net.
2024-12-16 08:51:41 +00:00
Thomas Adam
ae8f2208c9 Merge branch 'obsd-master' 2024-12-06 12:01:11 +00:00
nicm
5c3cf2f08b Preserve modifiers on backspace. 2024-12-06 09:07:40 +00:00
nicm
102f34090d Do not write bracketed paste keys themselves if the pane has not asked
for them.
2024-12-06 09:06:56 +00:00
Thomas Adam
99790c90aa Merge branch 'obsd-master' 2024-12-04 22:01:08 +00:00
nicm
6d792e4123 Fix backspace option for new key format, GitHub issue 4284. 2024-12-04 19:11:15 +00:00
Thomas Adam
98e322d5a5 Merge branch 'obsd-master' 2024-12-03 14:01:12 +00:00
jmc
01edce40f3 M-1 to M-7 for 7 preset layouts; from bunkmate
ok nicm
2024-12-03 11:18:34 +00:00
Thomas Adam
0549f87ccc Merge branch 'obsd-master' 2024-11-28 10:01:11 +00:00
nicm
72cd0eac29 Add extended keys flag for foot terminal. 2024-11-28 08:49:14 +00:00
Thomas Adam
f0c68533c4 Merge branch 'obsd-master' 2024-11-27 12:01:08 +00:00
Nicholas Marriott
9e4a9c51cc Use evbuffer_readline if readln is not available. It doesn't work properly but
at least it builds.
2024-11-27 10:37:45 +00:00
Nicholas Marriott
6874ec0dcc Remove endian.h. 2024-11-27 10:31:51 +00:00
Nicholas Marriott
252f41818e Update imsg and remove workaround. 2024-11-27 10:30:52 +00:00
nicm
d361f21065 Do not check for latest client in callback since the type may be latest
but with no window, fixes new-session -x and -y with another attached
client. GitHub issue 4268.
2024-11-27 10:12:20 +00:00
nicm
feb090abb3 Do not stop drag on double or triple click, GitHub issue 4272. 2024-11-27 10:10:20 +00:00
Thomas Adam
db771ec6e3 Merge branch 'obsd-master' 2024-11-26 18:01:10 +00:00
nicm
6f7db82b18 Add copy-mode-position-style and copy-mode-selection-style for copy
mode (they default to mode-style as before).
2024-11-26 15:52:41 +00:00
nicm
67cc7f6dc6 Enter is now sent from single prompt as \r not empty string. 2024-11-26 15:51:48 +00:00
Thomas Adam
db978db271 Merge branch 'obsd-master' 2024-11-25 14:01:12 +00:00
nicm
363f35f076 Do not try to terminate an empty buffer. 2024-11-25 12:32:24 +00:00
Thomas Adam
49b7276f2a Merge branch 'obsd-master' 2024-11-25 10:01:11 +00:00
nicm
f57131e11b Use cursor style from global options instead of default for popups, from
Alexander Arch.
2024-11-25 08:36:46 +00:00
nicm
420af9e108 Do not rely on window reference count for linked formats because they
are also used for notifications, GitHub issue 4258.
2024-11-25 08:34:01 +00:00
Thomas Adam
ceaf9b7452 Merge branch 'obsd-master' 2024-11-22 14:01:11 +00:00
nicm
5fd45b3892 Do not strvis output to terminal from commands. 2024-11-22 12:58:05 +00:00
nicm
64d82d5988 Document command prompt escape sequence, from Von Welch. 2024-11-22 12:36:13 +00:00
Nicholas Marriott
0f308bd18f imsg no longer associates file descriptors with the imsg they were sent with,
work around this for the moment (it is not clear if this is intentional).
2024-11-22 09:58:47 +00:00
Nicholas Marriott
1365f1ce52 Add an __unused. 2024-11-22 08:07:21 +00:00
Nicholas Marriott
7fc4e54efe And arpa/inet.h needs to stay... 2024-11-22 08:06:30 +00:00
Nicholas Marriott
c98c08c232 Need to remove endian.h as well. 2024-11-22 08:05:02 +00:00
Nicholas Marriott
990c724bd8 Bring in updated imsg. 2024-11-22 08:03:55 +00:00
Thomas Adam
b82c7b40b0 Merge branch 'obsd-master' 2024-11-21 16:01:11 +00:00
claudio
70299c6646 Convert sbin and usr.bin to check for imsgbuf_init failure and add
imsgbuf_allow_fdpass where needed.

OK tb@
2024-11-21 13:35:20 +00:00
Thomas Adam
ea6c5053c8 Merge branch 'obsd-master' 2024-11-21 10:01:09 +00:00
nicm
3f4fd45d5c Fix save-buffer documentation - it writes to stdout. From Ilya Grigoriev. 2024-11-21 07:37:21 +00:00
nicm
7c7e88253e When the mouse clicked on the border between two horizontal panes, the
location was not being set properly. Pulled the checking of this into
separate function for clarity. Fixes dragging on horizontal pane border.
From Michael Grant.
2024-11-21 07:34:38 +00:00
Thomas Adam
bb94a5437d Merge branch 'obsd-master' 2024-11-21 00:01:13 +00:00
nicm
273f9b2027 Fix word navigation on lines with tabs, from Alexander Arch. 2024-11-20 20:54:02 +00:00
Nicholas Marriott
b6d0b4be30 Define SD_ID128_UUID_FORMAT_STR if missing, from Marc Reisner. 2024-11-19 17:55:12 +00:00
Thomas Adam
2dce45f427 Merge branch 'obsd-master' 2024-11-18 10:01:12 +00:00
nicm
a3ede3106a Check all %if in the list when deciding whether to process an
assignment, not just the most recent.
2024-11-18 08:29:35 +00:00
Thomas Adam
dd9722184b Merge branch 'obsd-master' 2024-11-16 18:01:08 +00:00
nicm
a854e36f2b Do not call layout_fix_panes if wp is NULL (that is, a popup). 2024-11-16 16:49:50 +00:00
Thomas Adam
be594ff8a4 Merge branch 'obsd-master' 2024-11-15 16:01:11 +00:00
nicm
c66628e52b Add no-detach-on-destroy client option (useful for control mode
clients). From laur dot aliste at gmail dot com, GitHub issue 4242.
2024-11-15 14:09:04 +00:00
nicm
350a151ee4 Add two new style parameters, width and pad, which apply to scrollbars.
From Michael Grant, GitHub issue 4241.
2024-11-15 13:12:20 +00:00
Thomas Adam
d35458e3fe Merge branch 'obsd-master' 2024-11-15 10:01:11 +00:00
nicm
d6883c0266 Turn off scrollbar when pane is in alternate screen, from Michael Grant,
GitHub issue 4231.
2024-11-15 09:01:16 +00:00
Thomas Adam
563ed05353 Merge branch 'obsd-master' 2024-11-12 12:01:10 +00:00
nicm
f527412d9b Tidy up loop, from Alexander Arch. 2024-11-12 10:06:35 +00:00
nicm
713cacab1e Mouse support on the scrollbars, from Michael Grant. 2024-11-12 09:32:56 +00:00
Thomas Adam
846f813565 Merge branch 'obsd-master' 2024-11-11 10:01:08 +00:00
nicm
c26d71d3e9 Add an option to control the input buffer size, from Ken Lau. 2024-11-11 08:41:05 +00:00
Thomas Adam
c8677d3272 Merge branch 'obsd-master' 2024-11-08 10:01:08 +00:00
nicm
596ea62dc3 Some fixes for searching for tabs, from Alexander Arch. 2024-11-08 08:51:36 +00:00
Thomas Adam
1fe30bb2e8 Merge branch 'obsd-master' 2024-11-06 20:33:45 +00:00
nicm
809d659e64 Xr to Ic, from jmc. 2024-11-05 21:07:19 +00:00
nicm
09f4e43189 Add support for a scrollbar at the side of each pane. New options
pane-scrollbars turn them on or off, pane-scrollbars-position sets the
position (left or right), and pane-scrollbars-style to set the colours.
Mouse support will come later. From Michael Grant in GitHub issue 4221.
2024-11-05 09:41:17 +00:00
Thomas Adam
679bbdcf8f Merge branch 'obsd-master' 2024-11-04 10:01:09 +00:00
nicm
a0c79aa87b Do not make padding cells extended (there can be a lot of them), from
Alexander Arch .
2024-11-04 08:52:13 +00:00
Nicholas Marriott
46f3846659 Add -Wno-macro-redefined for macOS. 2024-10-31 12:57:40 +00:00
Thomas Adam
bbc3cc558c Merge branch 'obsd-master' 2024-10-28 10:01:08 +00:00
nicm
c8bd42de16 Match tab cells when searching, from Alexander Arch in GitHub issue
4201.
2024-10-28 08:16:51 +00:00
nicm
62e15e905b Treat tabs as a word separator, from Alexander Arch in GitHub issue
4201.
2024-10-28 08:16:06 +00:00
nicm
125a7b9177 Fix issues in the command prompt: set PROMPT_QUOTENEXT after quoting
than before, meaning that accidentally scrolling the mouse wheel doesn't
break quoting; and move the cursor correctly over wide characters. From
Alexander Arch in GitHub issue 4212.
2024-10-28 08:11:59 +00:00
Thomas Adam
895044c52b Merge branch 'obsd-master' 2024-10-25 22:01:10 +01:00
nicm
40c01c2d37 Allow tabs even on terminals without UTF-8, reported by jmc. 2024-10-25 19:36:38 +00:00
Thomas Adam
911d768b71 Merge branch 'obsd-master' 2024-10-25 18:01:11 +01:00
nicm
71a503e40c Allow control characters to be entered at the command prompt prefixed
with with C-v, from  Alexander Arch in GitHub issue 4206.
2024-10-25 15:32:51 +00:00
nicm
487b0ee124 Do not attempt to search for zero length strings, from Alexander Arch in
GitHub issue 4209.
2024-10-25 15:19:15 +00:00
nicm
eaec0a48f4 Do not stop stop at first padding in format_grid_line and handle tabs. 2024-10-25 15:13:10 +00:00
nicm
fdbc6cdea5 Flag tabs if possible in the grid cell so they can be preserved on
copying and capture-pane. From Alexander Arch in GitHub issue 4201.
2024-10-25 15:00:18 +00:00
Thomas Adam
9623ec3ee4 Merge branch 'obsd-master' 2024-10-25 10:01:07 +01:00
nicm
63582c154c Add a helper function for cell data comparison, from Alexander Arch. 2024-10-25 07:57:49 +00:00
Thomas Adam
914815e70f Merge branch 'obsd-master' 2024-10-21 16:01:07 +01:00
nicm
354926a956 Bump up the maximum for repeat-time (some people want it to be
effectively infinite).
2024-10-21 12:42:06 +00:00
nicm
df303770ea Add function to get current offset from copy mode, from Michael Grant. 2024-10-21 12:39:49 +00:00
Thomas Adam
a269c33a54 Merge branch 'obsd-master' 2024-10-21 10:01:08 +01:00
nicm
eb04f9314b Adjust how Ctrl and Meta keys are sent to use standard representation if
available in mode 1, from Stanislav Kljuhhin, GitHub issue 4188.
2024-10-21 07:38:06 +00:00
Thomas Adam
a9d0461839 Merge branch 'obsd-master' 2024-10-17 20:01:07 +01:00
nicm
71aa4fe767 Switch pane-colors and cursor-style options to be in alphabetical order,
from Teubel Gyorgy, GitHub issue 4191.
2024-10-17 17:22:01 +00:00
nicm
cfd3c02306 Allow attributes in menu style, from Japin Li in GitHub issue 4194. 2024-10-17 17:10:41 +00:00
Thomas Adam
35104059ed Merge branch 'obsd-master' 2024-10-15 00:01:10 +01:00
nicm
934035db71 Set ACS flag for REP. Reported by Romain Francoise, GitHub issue 4182. 2024-10-14 20:26:45 +00:00
Nicholas Marriott
8ff65230e1 Optimize sixel_print. Previously, the algorithm scanned each pixel several
times; once to find out which colors are active, and then once for every single
active color to actually construct the output string.

Now it constructs the compressed sixel patterns in the first pass (now x * 12
iters), so we can reduce the second pass (the really expensive part, at active
colors * x * 6 iters) to just appending these to the output buffer.

From nincsnevem662 at gmail dot com in GitHub issue 4184.
2024-10-14 11:05:59 +01:00
Thomas Adam
cb00e869ea Merge branch 'obsd-master' 2024-10-12 12:01:09 +01:00
nicm
f8b56fdc3f Call realpath on the source file to match -f on the command line, GitHub
issue 4180.
2024-10-12 08:20:32 +00:00
nicm
2d8b6fcf23 Do not rename a buffer to itself, GitHub issue 4181. 2024-10-12 08:13:52 +00:00
Nicholas Marriott
6ddee22f81 Portable tmux needs to check ENABLE_SIXEL. 2024-10-10 12:07:29 +01:00
Thomas Adam
66c738bc10 Merge branch 'obsd-master' 2024-10-10 12:01:08 +01:00
nicm
bcc47add38 Add a sixel_support format variable which is 1 if SIXEL is supported
(always 0 on OpenBSD), requested by Misaki Masa in GitHub issue 4177
2024-10-10 10:41:33 +00:00
Thomas Adam
d326c51d79 Merge branch 'obsd-master' 2024-10-08 12:01:09 +01:00
nicm
940fdf7ed0 Draw pane status line on the correct line when at the bottom, fixes
issues if the window size is smaller than the entire terminal. GitHub
issue 3943.
2024-10-08 09:40:50 +00:00
Thomas Adam
4f5d6d97d3 Merge branch 'obsd-master' 2024-10-08 10:01:08 +01:00
nicm
00412b570b Put the prompt cursor attributes into the status line screen and use
that rather than updating the current screen (since there might not be
one).
2024-10-08 06:29:44 +00:00
Thomas Adam
6a35b8ad07 Merge branch 'obsd-master' 2024-10-07 16:01:08 +01:00
nicm
735082b7c2 Add prompt-cursor-colour and prompt-cursor-style to set the style of the
cursor in the command prompt and remove the emulated cursor, from
Alexander Arch in GitHub issue 4170.
2024-10-07 12:58:36 +00:00
Thomas Adam
5b7bdc82c8 Merge branch 'obsd-master' 2024-10-07 12:01:08 +01:00
nicm
a3dea81b49 Add initial-repeat-time option to allow the first repeat time to be
increased and later reduced, from David le Blanc in GitHub issue 4164.
2024-10-07 08:50:47 +00:00
Thomas Adam
486221f206 Merge branch 'obsd-master' 2024-10-06 12:01:07 +01:00
nicm
9528d7470b Try to stay near the same line in modes if the current one is removed. 2024-10-06 09:30:22 +00:00
Thomas Adam
933d6b90ed Merge branch 'obsd-master' 2024-10-05 16:01:07 +01:00
nicm
a869693405 Send focus events to pane when entering or leaving popup, GitHub issue
3991.
2024-10-05 12:10:16 +00:00
Nicholas Marriott
549c35b061 Update regression tests. 2024-10-05 07:01:16 +01:00
Nicholas Marriott
42959db0a4 Update CHANGES. 2024-10-05 07:00:22 +01:00
Thomas Adam
114977dd25 Merge branch 'obsd-master' 2024-10-05 04:01:08 +01:00
Thomas Adam
aba8ffbe7b Merge branch 'obsd-master' 2024-10-05 02:01:07 +01:00
nicm
455a2b3705 Remove some debugging left behind. 2024-10-05 00:35:35 +00:00
nicm
e0638c48cd Add copy-mode-position-format to configure the position indicator. 2024-10-05 00:32:55 +00:00
nicm
41f6b691e3 Document missing window-layout-changed hook. 2024-10-04 22:36:11 +00:00
Nicholas Marriott
0f30fa34e3 Add install step. 2024-10-04 23:29:36 +01:00
Thomas Adam
e486f5ffdc Merge branch 'obsd-master' 2024-10-04 22:01:09 +01:00
nicm
5a68730e2f Add -y flag to disable confirmation prompts in modes, GitHub issue 4152. 2024-10-04 19:16:13 +00:00
Nicholas Marriott
7997fd3152 Missing define. 2024-10-04 18:59:53 +01:00
nicm
048db82041 Do not translate BSpace as Unicode, GitHub issue 4156. 2024-10-04 18:45:36 +01:00
Thomas Adam
16b44d2a5b Merge branch 'obsd-master' 2024-10-04 18:01:07 +01:00
nicm
34775fc235 Do not translate BSpace as Unicode, GitHub issue 4156. 2024-10-04 14:55:17 +00:00
Thomas Adam
f2fd8c854a Merge branch 'obsd-master' 2024-10-04 10:01:08 +01:00
nicm
9f2a853d87 Rework of copy mode commands ("send-keys -X") to parse the arguments so
that flags may be detected propertly rather than just looking for
strings ("-O" and so on). Also add -C and -P flags to the copy commands:
-C prevents the commands from sending the text to the clipboard and -P
prevents them from adding the text as a paste buffer.

Note some of the default key bindings change to add "--" and any similar
custom key bindings using "send-keys -X" may need a similar change.

GitHub issue 4153.
2024-10-04 07:03:08 +00:00
Nicholas Marriott
7a78cdf78c Three SIXEL improvements from nincsnevem662 at gmail dot com in GitHub issue
4149:

- Pass P2 on the received image through when forwarding the image to the
  outside terminal to preserve transparency;

- Preserve raster attribute dimensions which may be smaller than the actual
  image (used to crop out parts of the image to work around the limitation that
  rows must come in groups of six);

- To avoid collapsing empty sixel lines, no longer ignore duplicate "-" new
  line specifiers.
2024-10-04 07:49:07 +01:00
nicm
356887bca2 Improve fix for shifted keys so it works for all the keys it should,
Stanislav Kljuhhin in GitHub issue 4146.
2024-10-03 08:14:32 +01:00
Thomas Adam
2df15ad08c Merge branch 'obsd-master' 2024-10-03 08:01:07 +01:00
nicm
780a87be9a Improve fix for shifted keys so it works for all the keys it should,
Stanislav Kljuhhin in GitHub issue 4146.
2024-10-03 05:41:59 +00:00
Nicholas Marriott
1e303b6a9d Bypass permission check for Cygwin, based on a different change by Yuya Adachi
via Rafael Kitover; GitHub issue 4148.
2024-10-02 14:04:06 +01:00
Thomas Adam
8d2aee34ab Merge branch 'obsd-master' 2024-10-02 14:01:10 +01:00
nicm
05116cefe6 Add MSYSTEM to default update-environment. 2024-10-02 11:51:15 +00:00
nicm
ce4be58eef Add a define for the socket permissions check so it can be overridden
more easily (for Cgywin).
2024-10-02 11:48:16 +00:00
Nicholas Marriott
8d6eb4be40 Set client stdout file descriptor also for Cgywin, from Michael Wild via Rafael
Kitover in GitHub issue 4148.
2024-10-02 12:16:24 +01:00
nicm
834ec91b44 Report shifted keys like S-A as A not as S-A in mode 1 extended keys,
from Stanislav Kljuhhin.
2024-10-02 11:06:53 +01:00
Thomas Adam
38c38f1c64 Merge branch 'obsd-master' 2024-10-02 10:01:08 +01:00
nicm
ddf6af79e3 Report shifted keys like S-A as A not as S-A in mode 1 extended keys,
from Stanislav Kljuhhin.
2024-10-02 08:06:45 +00:00
Thomas Adam
826ba515be Merge branch 'obsd-master' 2024-10-01 14:01:08 +01:00
Nicholas Marriott
729bded8bf Fix up regression tests. 2024-10-01 13:40:42 +01:00
nicm
b95a06d2d4 Add a way to make the preview larger in tree mode, GitHub issue 4124. 2024-10-01 10:10:29 +00:00
Thomas Adam
157d748949 Merge branch 'obsd-master' 2024-10-01 10:01:10 +01:00
nicm
1c1f4c1219 Use global cursor style and colour options for modes instead of default,
GitHub issue 4117.
2024-10-01 08:01:19 +00:00
nicm
17bab32794 Change pasting to bypass the output key processing entirely and write
what was originally received. Fixes problems with pasted text being
interpreted as extended keys reported by Mark Kelly.
2024-10-01 06:15:47 +00:00
Nicholas Marriott
868ddf5d38 3.5a bits. 2024-09-30 13:09:50 +01:00
nicm
a1b7a3bcb3 Only use default-shell for popups, return to /bin/sh for run-shell,
if-shell and #() - these have been documented as using /bin/sh for a
long time and scripts rely on it. Pointed out by Gregory Pakosz.
2024-09-30 13:07:46 +01:00
nicm
cbd419c483 Fix grey colour, from Magnus Gross. 2024-09-30 13:06:55 +01:00
Thomas Adam
25b1cc1e8e Merge branch 'obsd-master' 2024-09-30 12:01:11 +01:00
nicm
89adec0ca5 On some Windows terminals, if TIOCWINSZ does not return xpixel and
ypixel (they are zero), if this is the case then try the query escape
sequences. From Dmitry Galchinsky in GitHub issue 4099.
2024-09-30 08:10:20 +00:00
nicm
f95d055e04 Only use default-shell for popups, return to /bin/sh for run-shell,
if-shell and #() - these have been documented as using /bin/sh for a
long time and scripts rely on it. Pointed out by Gregory Pakosz.
2024-09-30 07:54:51 +00:00
Thomas Adam
7b148f7b5b Merge branch 'obsd-master' 2024-09-29 22:01:09 +01:00
nicm
9bd039d1bc Fix grey colour, from Magnus Gross. 2024-09-29 20:05:42 +00:00
Nicholas Marriott
7c30056d96 Bump to 3.6. 2024-09-27 08:58:00 +01:00
Nicholas Marriott
ac44566c9c tmux 3.5. 2024-09-27 08:56:39 +01:00
Thomas Adam
64f1076d97 Merge branch 'obsd-master' 2024-09-17 00:01:09 +01:00
nicm
489c69f5ed Add copy mode commands which were missed when descriptions were added,
from Julian Prein, GitHub issue 4121.
2024-09-16 20:46:58 +00:00
nicm
f897049935 Change the behaviour of extended-keys always slightly so that
applications can still enter mode 2 if they want, they just cannot turn
extended keys off entirely. From Stanislav Kljuhhin.
2024-09-16 20:38:48 +00:00
nicm
d8b66110f7 Add a prefix timeout option, from Conor Taylor in GitHub issue 4108. 2024-09-16 20:28:22 +00:00
Nicholas Marriott
8b1a3bb2e5 Only default --enable-debug if the user has not turned it off, from Ken Lau. 2024-09-16 21:19:43 +01:00
Thomas Adam
37771a5a8d Merge branch 'obsd-master' 2024-09-11 22:01:10 +01:00
nicm
3a8a31d8d2 Mouse move keys are not useful as key bindings because we do not turn
them on unless the application requests them. Ignore them so they do not
cause the prefix to be canceled, GitHub issue 4111.
2024-09-11 19:12:33 +00:00
Nicholas Marriott
c36ffcbe56 Typo from Bastian Venthur. 2024-09-06 13:09:43 +01:00
Thomas Adam
3d8ead8a97 Merge branch 'obsd-master' 2024-08-28 10:27:21 +01:00
nicm
141cd78407 Display hyperlinks in copy mode and add copy_cursor_hyperlink format to
get the hyperlink under the cursor.
2024-08-27 07:49:07 +00:00
nicm
d0c8124661 Add search_count and search_count_partial formats in copy mode, GitHub
issue 4091.
2024-08-27 07:31:26 +00:00
nicm
2917bc5274 Do not reset mouse pane if clicked on status line, it may have been set
by a range.
2024-08-27 07:25:27 +00:00
nicm
2d1e93447e Use strtonum instead of atoi. 2024-08-26 13:02:15 +00:00
nicm
31b6c9356c C-h should not be treated specially and represented internally as \b but
as C-h like the other Ctrl keys. Backspace is already handled separately
if it VERASE.
2024-08-26 07:45:05 +00:00
nicm
9e2a7c28f5 Pass the screen_redraw_ctx struct into more functions instead of
individual arguments (for example for the pane status), from Michael
Grant.
2024-08-26 07:34:40 +00:00
nicm
73b2277af8 Client flags was changed to uint64_t a while ago, fix a few cases where
it is still int (do not matter now but will with some new flags). From
Michael Grant.
2024-08-26 07:30:46 +00:00
nicm
a84c109604 Add window_pane_mode helper function to tell if a pane is in copy mode,
from Michael Grant.
2024-08-26 07:14:40 +00:00
nicm
4823acca8f Add copy-mode -d flag to scroll a page down if in copy mode already,
from Michael Grant.
2024-08-26 07:09:34 +00:00
Thomas Adam
34807388b0 Merge branch 'obsd-master' 2024-08-23 16:01:10 +01:00
nicm
08be883297 Ignore internal function keys if they have not got an entry in the key
table.
2024-08-23 13:25:39 +00:00
Thomas Adam
13bd0e46db Merge branch 'obsd-master' 2024-08-23 14:01:08 +01:00
nicm
6e9a914014 Check for exact match for layout name before looking for a prefix match. 2024-08-23 10:19:06 +00:00
Thomas Adam
7990e5fa8f Merge branch 'obsd-master' 2024-08-22 12:01:07 +01:00
nicm
4860a58d07 Clear overlay when command prompt is entered. Also fix some spacing in
man page pointed out by jmc.
2024-08-22 09:05:51 +00:00
Thomas Adam
99af9f23bd Merge branch 'obsd-master' 2024-08-22 08:01:08 +01:00
nicm
9ebbe2cca7 Short Ctrl keys like ^A need to be converted to lowercase so they end up
as 'a'|KEYC_CTRL to match the new internal representation. Problem
reported by naddy@.
2024-08-22 05:39:55 +00:00
Thomas Adam
692bae9ea6 Merge branch 'obsd-master' 2024-08-21 08:01:09 +01:00
nicm
a6645c4de4 Mention that load- and save-buffer can use stdin, from Ramon Fischer. 2024-08-21 05:06:45 +00:00
nicm
06292baadc Add mirrored versions of the main-horizontal and main-vertical layouts where
the main pane is bottom or right instead of top or left, from Sherwyn Sen.
2024-08-21 05:03:13 +00:00
nicm
ceda0a68ae C-Space and Meta keys should not be translated in mode 1 extended keys. 2024-08-21 04:55:57 +00:00
nicm
4fa90c9acf Set the default for extended-keys back to off because it appears emacs turns
the keys on but does not correctly handle them except in xterm (!). Also fix so
that off takes effect as expected.
2024-08-21 04:37:42 +00:00
nicm
c7e61a01e5 Revamp extended keys support to more closely match xterm and support
mode 2 as well as mode 1. From Stanislav Kljuhhin (GitHub issue 4038).

This changes tmux to always request mode 2 from parent terminal, change
to an unambiguous internal representation of keys, and adds an option
(extended-keys-format) to control the format similar to the xterm(1)
formatOtherKeys resource.
2024-08-21 04:17:09 +00:00
Thomas Adam
963e824f5f Merge branch 'obsd-master' 2024-08-19 12:01:09 +01:00
nicm
de6bce057a Allow REP to work with Unicode characters, GitHub issue 3687. 2024-08-19 08:31:36 +00:00
nicm
937ba1d8dd Both terminators \007 and \033\\ leave the index pointing to the final
character of the terminator, so correct the size calculation to always
add one. GitHub issue 4082.
2024-08-19 08:29:16 +00:00
Thomas Adam
651891c3bd Merge branch 'obsd-master' 2024-08-04 12:01:09 +01:00
nicm
4008e2ff6d Make a little effort to treate CRLF as LF in config files. GitHub issue
3720.
2024-08-04 09:42:23 +00:00
nicm
b88130d24b The Linux console has some bugs with bright colours. It seems likely
that it is emulating them by setting a bright (or bold) flag; however,
when the colour is changed from a bright colour (say SGR 96) to a
non-bright (say SGR 36), the flag is not reset, so the new colour
remains as bright. SGR 39 (default colour) also does not reset, so you
end up with the bright default colour. Work around this by sending SGR 0
when switching away from a bright colour, and disable AX for TERM=linux.
Also make the check for AX simpler and do not check for the op
capability is not actually used. GitHub issue 3976.
2024-08-04 09:35:30 +00:00
nicm
fc7ee7efc7 -l should be before -r, pointed out by jmc a while ago. 2024-08-04 09:01:18 +00:00
Nicholas Marriott
d0eb3fe543 Use terminal-features instead of terminal-overrides to enable truecolor support
in example_tmux.conf, from Simon Hengel.
2024-08-04 09:59:18 +01:00
Nicholas Marriott
2ac0faf119 If built with systemd, remove some environment variables it uses. From Ciprian
Dorin Craciun, GitHub issue 4035.
2024-08-04 09:58:13 +01:00
Nicholas Marriott
775789fbd5 Rename header guards on compat/queue.h to avoid it conflicting if the system
header is included first. This matters on some platforms (macOS) where queue.h
is old. From Saagar Jha in GitHub issue 4041.
2024-08-04 09:57:26 +01:00
nicm
7b6fbe7262 Adjust the logic when deleting last buffer to better preserve the
selection: if selecting the element below the deleted one fails (because
as the last one), select the one above it instead. From Daniel Mueller,
GitHub issue 4043.
2024-08-04 08:53:43 +00:00
Thomas Adam
109d2bda1a Merge branch 'obsd-master' 2024-07-22 18:01:09 +01:00
nicm
ddd4e57c65 Expand full array option values if no index is provided, GitHub issue
4051.
2024-07-22 15:27:42 +00:00
Nicholas Marriott
3c2621b41b Support building with jemalloc memory allocator, from Romain Francoise. 2024-07-15 11:25:15 +01:00
Nicholas Marriott
5039be657c utf8proc bits for utf8_fromwc. 2024-07-12 14:30:56 +01:00
Thomas Adam
d02254f754 Merge branch 'obsd-master' 2024-07-12 14:01:09 +01:00
nicm
aa1353947e UTF-8 keys now contain the internal representation and not the Unicode
codepoint, so convert extended keys properly. From Stanislav Kljuhhin.
2024-07-12 11:21:18 +00:00
Nicholas Marriott
171004dfd0 Use mdoc on Illumos which uses mandoc, from Andy Fiddaman. 2024-07-08 10:57:32 +01:00
Thomas Adam
c773fe89e7 Merge branch 'obsd-master' 2024-06-24 12:01:10 +01:00
nicm
093b5a5518 Add a way (refresh-client -r) for control mode clients to provide OSC 10
and 11 responses to tmux so they can set the default foreground and
background colours, from George Nachman in GitHub issue 4014.
2024-06-24 08:30:50 +00:00
nicm
db1665868f Check the underline style colour against the correct default value again
(it was changed from 0 to 8), from Romain Francoise.
2024-06-24 08:11:46 +00:00
Thomas Adam
c07e856d24 Merge branch 'obsd-master' 2024-05-24 16:01:08 +01:00
nicm
692ce59bce Do not escape $ unless DQ is set, that is the only case where we need to
escape it.
2024-05-24 12:41:24 +00:00
nicm
9e7c1aee48 Add N to search backwards in tree modes, from Fadi Afani in GitHub issue
3982.
2024-05-24 12:39:06 +00:00
Thomas Adam
4c2eedca5a Merge branch 'obsd-master' 2024-05-19 06:01:09 +01:00
jsg
ac6c1e9589 remove prototype with no matching function 2024-05-19 03:27:58 +00:00
Thomas Adam
0903790b00 Merge branch 'obsd-master' 2024-05-18 12:01:09 +01:00
jsg
03de52653e remove prototypes with no matching function; ok nicm@ 2024-05-18 08:51:26 +00:00
jsg
da06719309 remove externs with no matching var; ok nicm@ 2024-05-18 08:50:11 +00:00
Thomas Adam
fc84097379 Merge branch 'obsd-master' 2024-05-15 14:01:09 +01:00
Thomas Adam
4fd725c6e1 Merge branch 'obsd-master' 2024-05-15 12:01:10 +01:00
nicm
d39dcea30a Use default-shell for command prompt #() and popups as well 2024-05-15 09:59:12 +00:00
nicm
bfd65398a9 Fix memory leaks reported by Lu Ming Yin. 2024-05-15 08:39:30 +00:00
Thomas Adam
452d987e0e Merge branch 'obsd-master' 2024-05-14 14:01:10 +01:00
Thomas Adam
8ef899f315 Merge branch 'obsd-master' 2024-05-14 12:01:09 +01:00
nicm
a18d1146aa Add missing time.h to tty.c (from Ismail Donmez), also remove some stray
spaces.
2024-05-14 10:11:09 +00:00
nicm
5b5004e5ac Revert part of the change for GitHub issue 3675 because it does not work
correctly, it was intended to skip lines that are already being searched
as part of a previous wrapped line but in fact is skipping all lines
except the last in wrapped lines.

Also revert the search-wrapped-lines option (I didn't realize it was
intended to work around this).
2024-05-14 09:32:37 +00:00
Thomas Adam
6ff8f8fbf9 Merge branch 'obsd-master' 2024-05-14 10:01:10 +01:00
nicm
c9616700ca Add a command-error hook when a command fails, from Hugh Davenport in
GitHub issue 3973.
2024-05-14 07:52:19 +00:00
nicm
4c928dce74 Add an option to disable unwrapping lines for searching, from
meanderingprogrammer at gmail dot com, GitHub issue 3975.
2024-05-14 07:40:39 +00:00
nicm
fb37d52dde Restore previous behaviour or writing to stdout if available. 2024-05-14 07:33:01 +00:00
Thomas Adam
363d9c401e Merge branch 'obsd-master' 2024-05-13 14:01:10 +01:00
nicm
8643ece345 Fix memory leak, from Fadi Afani. 2024-05-13 11:45:05 +00:00
Nicholas Marriott
9ba433e521 Use printf not echo -e, from Joyce Lin. 2024-05-13 12:42:14 +01:00
Nicholas Marriott
3823fa2c57 Send SIGHUP since some programs ignore SIGTERM, from Eduardo Grajeda in GitHub
issue 3958.
2024-04-30 12:38:58 +01:00
Thomas Adam
0a8571b6fe Merge branch 'obsd-master' 2024-04-23 16:09:50 +01:00
jsg
ea9f416c99 correct indentation; no functional change
ok tb@
2024-04-23 13:34:51 +00:00
Thomas Adam
036d8993e6 Merge branch 'obsd-master' 2024-04-15 12:01:11 +01:00
nicm
e8530c9fee Fixes for memory leaks reported by Lu Ming Yin, fixes from Howard Chu. 2024-04-15 08:19:55 +00:00
Nicholas Marriott
dd4c0109a9 Missing headers for Android, from Biswapriyo Nath. 2024-04-15 09:07:41 +01:00
Thomas Adam
43530d4397 Merge branch 'obsd-master' 2024-04-10 10:01:13 +01:00
nicm
553d4cba79 Add an option allow-set-title to forbid applications from changing the
pane title, from someone in GitHub issue 3930.
2024-04-10 07:36:25 +00:00
nicm
c62a9ca16b Correct handling of mouse up events (don't ignore all but the last
released button), and always process down event for double click. From
Rudy Dellomas III in GitHub issue 3919.
2024-04-10 07:29:15 +00:00
nicm
424f13fe13 Do not get muddled and crash if focusing a pane that is exiting,
reported by Saul Nogueras in GitHub issue 3776.
2024-04-10 07:15:21 +00:00
Thomas Adam
4bb6da75ba Merge branch 'obsd-master' 2024-04-05 02:01:09 +01:00
nicm
a28175dbfd Pick newest session as documented, not oldest, from Magnus Gross. 2024-04-04 22:44:40 +00:00
Thomas Adam
fc204bb5e5 Merge branch 'obsd-master' 2024-03-26 12:01:11 +00:00
nicm
6207a45139 Fix selection present check, reported by M Kelly. 2024-03-26 10:20:20 +00:00
Thomas Adam
3c3643f580 Merge branch 'obsd-master' 2024-03-21 14:01:10 +00:00
nicm
89c1c43ef9 Write padding character into the right position. 2024-03-21 12:10:57 +00:00
nicm
2e9d7ebf15 Reduce escape-time default to 10 milliseconds, 500 is far too long for
modern terminals and networks. Case made by Kurtis Rader in GitHub issue
3844.
2024-03-21 11:53:11 +00:00
nicm
d8ddeec7db Add -M to always turn mouse on in a menu, GitHub issue 3779. 2024-03-21 11:51:32 +00:00
nicm
6f0254e6a8 Look for feature code 21 for DECSLRM and 28 for DECFRA in the device
attributes and also accept level 1 (there is no hardware with this but
some emulators may use it). Pointed out by James Holderness.
2024-03-21 11:47:55 +00:00
Nicholas Marriott
aa17f0e0c1 Fix crash if SIXEL colour register is invalid and remove SIXEL images before
reflow to avoid a different crash, from Anindya Mukherjee.
2024-03-21 11:37:09 +00:00
nicm
0ae8b681b2 Use -p for default paste-buffer command in buffer mode, it will only do
anything if the application asked for it. From Gregory Anders.
2024-03-21 11:32:49 +00:00
nicm
6c0067c103 Do not notify window-layout-changed if the window is about to be
destroyed (since it may have been freed by the time the notify happens),
from Romain Francoise in GitHub issue 3860.
2024-03-21 11:30:42 +00:00
nicm
5458cb2850 Revert detach-client part of last, did not intend this to go in. 2024-03-21 11:27:18 +00:00
nicm
0c374868ca Do not consider a selection present if it is empty, from Michael Grant
(GitHub issue 3869). Also a typo fix from GitHub issue 3877.
2024-03-21 11:26:28 +00:00
Nicholas Marriott
bf5d3f2e26 Typo, GitHub issue 3877. 2024-03-21 11:19:59 +00:00
Nicholas Marriott
d5ef837f63 Remove duplicate .tmux.conf mention, from Valentin Rylenko. 2024-03-21 11:18:49 +00:00
Thomas Adam
b79e28b2c3 Merge branch 'obsd-master' 2024-03-13 14:01:09 +00:00
nicm
8ffd5458ff Make the attach-session description clearer - do not mention creating a
client which is not important, explicitly say the session must exist,
and mention new-session and new-session -A. Prompted by Theo.
2024-03-13 11:25:50 +00:00
Thomas Adam
b54e1fc4f7 Merge branch 'obsd-master' 2024-03-07 00:01:10 +00:00
Nicholas Marriott
bdb6321229 Update lock.yml. 2024-03-06 21:45:26 +00:00
nicm
bd29a48b56 Check for the right flag to fix split-window -p, from Bryan Childs. 2024-03-06 21:32:39 +00:00
Nicholas Marriott
f3f1c3db58 Add missing headers, from Marvin Schmidt. 2024-03-06 21:29:28 +00:00
Nicholas Marriott
608d113486 next-3.5 2024-02-13 10:20:18 +00:00
Nicholas Marriott
9ae69c3795 3.4. 2024-02-13 10:17:07 +00:00
Thomas Adam
0960862950 Merge branch 'obsd-master' 2024-02-13 10:01:10 +00:00
Nicholas Marriott
44ad25b367 Update CHANGES. 2024-02-13 09:12:08 +00:00
nicm
40b97b1715 Add two new values for the destroy-unattached option to destroy sessions
only if they are not members of sessions groups, from Mark Huang, GitHub
issue 3806.
2024-02-13 08:10:23 +00:00
nicm
4bdb855020 Do not allow paste into panes which have exited, from Romain Francoise
in GitHub issue 3830.
2024-02-13 08:03:50 +00:00
Thomas Adam
ea7136fb83 Merge branch 'obsd-master' 2024-01-22 18:01:09 +00:00
nicm
428f8a9b28 Increase buffer size to avoid truncating styles, GitHub issue 3809 from
Ricardo Bittencourt.
2024-01-22 16:34:46 +00:00
Nicholas Marriott
84faada25b Remove existing defines. 2024-01-17 10:59:07 +00:00
Nicholas Marriott
55d0abad89 Need htonll and ntohll. 2024-01-17 10:57:32 +00:00
Nicholas Marriott
7d91b4b90b htobe is not portable. 2024-01-17 09:47:35 +00:00
Nicholas Marriott
66369416fc Update imsg. 2024-01-17 09:41:53 +00:00
Thomas Adam
001e26d0bb Merge branch 'obsd-master' 2024-01-16 14:01:09 +00:00
claudio
2e39d698d2 Use imsg_get_fd() instead of direct access to imsg.fd
The change in proc.c can be further simplified once imsg_free() takes
care of unclaimed file descriptors.

OK nicm@
2024-01-16 13:09:11 +00:00
Thomas Adam
e809c2ec35 Merge branch 'obsd-master' 2024-01-03 19:17:10 +00:00
Nicholas Marriott
4266d3efc8 Assignment should be inside SIXEL. 2023-12-28 03:12:27 +00:00
nicm
40a20bc8ae Only wrap pattern in *s if using a regular expression. 2023-12-27 20:42:01 +00:00
nicm
f7bf7e9671 Remove flags from the prefix before comparing with the received key so
that modifier keys with flags work correctly, GitHub issue 3764.
2023-12-27 20:23:59 +00:00
nicm
008ecd4592 groff apparently generates broken output for some common characters in
mdoc, so escaped versions have to be used instead. From Alexis
Hildebrandt in GitHub issue 3762.
2023-12-27 20:20:50 +00:00
nicm
73a2b12088 Always initialize screen mode, GitHub issue 3750 from Ding Fei. 2023-12-27 20:17:13 +00:00
Nicholas Marriott
605bf21ff2 Do not use NULL window, GitHub issue 3747. 2023-12-27 20:15:57 +00:00
nicm
f028445407 Correctly handle window ops with no pane, GitHub issue 3747. 2023-12-27 20:13:35 +00:00
Thomas Adam
bdf8e614af Merge branch 'obsd-master' 2023-11-14 22:01:09 +00:00
nicm
4dea352dee Don't strdup NULL filename. 2023-11-14 20:01:11 +00:00
Thomas Adam
151875d144 Merge branch 'obsd-master' 2023-11-14 18:01:10 +00:00
nicm
88fd1f00b8 Handle NULL client (in config file) when showing a status message; also
copy the file when processing if-shell since it may be freed. GitHub
issue 3746.
2023-11-14 15:59:49 +00:00
nicm
1a14d6d2e1 Use SM 2026 for Sync which is more widely supported now. 2023-11-14 15:38:33 +00:00
Thomas Adam
381c00a74e Merge branch 'obsd-master' 2023-11-02 22:58:45 +00:00
nicm
5aadee6df4 next-prompt can have 1 argument. 2023-11-02 10:38:14 +00:00
Nicholas Marriott
a5545dbc9f Allow attributes to have only two parameters, from Tim Culverhouse. 2023-11-01 10:37:41 +00:00
nicm
fdf465925e Do not allow combined UTF-8 characters that are too long, GitHub issue
3729.
2023-10-30 16:05:30 +00:00
nicm
36e1ac6556 Unzoom window at start of destroy so it doesn't happen later (when
destroying panes) after the layout has been freed, GitHub issue 3717.
2023-10-23 08:12:00 +00:00
nicm
ffa376edf7 Switch to tiparm_s (added in ncurses 6.4-20230424) instead of tparm,
which allows ncurses to validate the capabilities correctly.
2023-10-17 09:55:32 +00:00
Thomas Adam
b777780720 Merge branch 'obsd-master' 2023-09-19 12:01:11 +01:00
nicm
347cd0b5f8 Fix a couple of mouse mode flag names. 2023-09-19 08:35:44 +00:00
Nicholas Marriott
0ca28b362e Add combined character test. 2023-09-19 09:29:20 +01:00
Nicholas Marriott
51b80b985e Restore utf8proc code. 2023-09-19 09:29:04 +01:00
Nicholas Marriott
789a98982e Reply to SMGRAPHICS. 2023-09-19 09:27:59 +01:00
Thomas Adam
b202a2f1b5 Merge branch 'obsd-master' 2023-09-17 21:03:06 +01:00
nicm
7e79108f8a Remove next- and previous-prompt added in error. GitHub issue 3696. 2023-09-16 16:18:29 +00:00
nicm
f09cde2542 Change UTF-8 combining to inspect the previous character at the cursor
position rather than keeping the last character from the input stream,
this is how most terminals work and fixes problems with displaying these
characters in vim. GitHub issue 3600.
2023-09-15 15:49:05 +00:00
Thomas Adam
9f9156c030 Merge branch 'obsd-master' 2023-09-15 10:01:11 +01:00
nicm
d394293ba5 Add -t to source-file, GitHub issue 3473. 2023-09-15 06:31:49 +00:00
Thomas Adam
c57a09269b Merge branch 'obsd-master' 2023-09-14 16:01:10 +01:00
nicm
8191c58737 Reset combine flag only if text is actually processed. 2023-09-14 13:01:35 +00:00
Thomas Adam
f68d35c529 Merge branch 'obsd-master' 2023-09-08 10:01:10 +01:00
nicm
c02bc4dbe9 On second thoughts, do check DA2 for DECFRA and DECSLRM since that will
catch terminals that say they are VT520 even if we can't use DA1
(because of VTE).
2023-09-08 07:05:06 +00:00
nicm
4872811ba7 Use DECSLRM and DECFRA only at level 4 rather than checking the terminal
id.
2023-09-08 06:52:31 +00:00
Nicholas Marriott
1a1290f30b Only remove images if reverse index actually scrolls. 2023-09-07 22:02:11 +01:00
Nicholas Marriott
7be7ca7195 Shut autoconf up. 2023-09-07 18:24:28 +01:00
Thomas Adam
32197fa52d Merge branch 'obsd-master' 2023-09-07 14:01:11 +01:00
nicm
9653a52a6a Use DECSLRM and DECFRA on terminals pretending to be VT520 or VT525 as
well as VT420.
2023-09-07 10:21:46 +00:00
Thomas Adam
d60c8942ce Merge branch 'obsd-master' 2023-09-07 10:01:10 +01:00
nicm
c99f9e92e0 Accept 65 for VT525 as well. 2023-09-07 07:19:21 +00:00
Thomas Adam
e26356607e Merge branch 'obsd-master' 2023-09-04 10:01:10 +01:00
nicm
43e5e80343 Skip wrapped lines in top level search loop because they will be
combined in the inner loop (in window_copy_search_rl_regex and the
others), avoids searching the same text multiple times. Also add a line
length limit for regex searches. GitHub issue 3675.
2023-09-04 08:01:43 +00:00
Thomas Adam
1742138f05 Merge branch 'obsd-master' 2023-09-02 22:01:09 +01:00
nicm
c767d62329 Request terminal colours again on SIGWINCH but at most once every 30
seconds, GitHub issue 3582.
2023-09-02 20:03:10 +00:00
Thomas Adam
7ad29b9831 Merge branch 'obsd-master' 2023-09-02 12:01:09 +01:00
nicm
d209fe9b1e Setulc only does RGB colour so add Setulc1 to do non-RGB colours, GitHub
issue 3627.
2023-09-02 09:17:23 +00:00
nicm
c5542637d7 Set visited flag on last windows when linking session. 2023-09-02 08:38:37 +00:00
Thomas Adam
e7c829fc67 Merge branch 'obsd-master' 2023-09-01 20:01:10 +01:00
nicm
579829eef2 Only compare the actual size of the UTF-8 character, not all of it. 2023-09-01 18:43:54 +00:00
Nicholas Marriott
3aa20f6e75 Use %05X not %08X. 2023-09-01 19:37:27 +01:00
nicm
f78279bb2e Add missing -T to getopt string. 2023-09-01 16:40:38 +00:00
Thomas Adam
a99d7c6314 makefile: fixup bad merge 2023-09-01 17:13:55 +01:00
Thomas Adam
cf1ed67fcc Merge branch 'obsd-master' 2023-09-01 17:09:41 +01:00
Thomas Adam
1aec420465 Merge branch 'obsd-master' 2023-09-01 17:06:27 +01:00
nicm
16e4b39359 Clear combine flag when a non-UTF-8 set of characters is encountered. 2023-09-01 16:01:54 +00:00
nicm
9456258ccc Rewrite combined character handling to be more consistent and to support
newer Unicode combined characters (which we have to "know" are combined
since they are not width zero). GitHub issue 3600.
2023-09-01 14:29:11 +00:00
nicm
c41d59f232 Expand name before looking for window with -S, GitHub issue 3670. 2023-09-01 14:24:46 +00:00
Nicholas Marriott
d682ef88e6 Bump width and height to 10000. 2023-09-01 14:54:27 +01:00
nicm
c1e6e54e6e Add detach-on-destroy previous and next, mostly from Alexis Hildebrandt. 2023-09-01 13:48:54 +00:00
Nicholas Marriott
62f657845e Fix merge error, from Jakub Łukasiewicz. 2023-08-26 20:57:44 +01:00
Thomas Adam
a9841a6d1e portable: fixup merge 2023-08-23 20:55:23 +01:00
Thomas Adam
70ecf17f85 Merge branch 'obsd-master' 2023-08-23 20:37:42 +01:00
nicm
71d453f169 Add -c to run-shell to set working directory, from someone in GitHub
issue 3661.
2023-08-23 08:40:25 +00:00
Nicholas Marriott
071849f82f Improve logging of SIXEL parsing errors. 2023-08-23 09:30:20 +01:00
nicm
52084b2948 Log what input_dcs_dispatch does with the input data. 2023-08-23 08:30:07 +00:00
Nicholas Marriott
dfbc6b1888 Merge SIXEL branch.
Squashed commit of the following:

commit 6ebc3feb4671d9b25b3db99d3c16b2323b8e3d02
Author: topcat001 <anindya49@hotmail.com>
Date:   Sun Aug 20 16:09:51 2023 -0700

    Remove redundant {}.

commit 6f013fce39602c259a5be2d690d548c73e51cccc
Author: topcat001 <anindya49@hotmail.com>
Date:   Sun Aug 20 16:02:15 2023 -0700

    Revert "Do not defer redraw if it is just the status line (will need to do more here I"

    This reverts commit 0a15bbf3f1.

commit e6322b4196d73c975ba2e73633e6de9c46779059
Author: topcat001 <anindya49@hotmail.com>
Date:   Sun Aug 20 15:46:59 2023 -0700

    Fix placeholder label and clean up.

commit 5896ac52a1f72056a75480b3e1ada328f239df9b
Merge: ad982330 e3a8b843
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Fri Aug 18 17:00:03 2023 +0100

    Merge branch 'master' into sixel

commit ad98233066b72547aee7fa0c87838847ee7f1ece
Author: topcat001 <anindya49@hotmail.com>
Date:   Tue Aug 15 13:57:08 2023 -0700

    Better text placeholder.

commit 312d83252c27fc4d09d09d121bf7573336e3cdca
Merge: 14b8b524 3d93b0c5
Author: topcat001 <anindya49@hotmail.com>
Date:   Tue Aug 15 13:39:22 2023 -0700

    Merge remote-tracking branch 'origin/master' into sixel

commit 14b8b524523a7d5a4e42f7dfa346905c604c91e2
Merge: 4baf7642 fda39377
Author: topcat001 <anindya49@hotmail.com>
Date:   Sat Jul 22 17:29:10 2023 -0700

    Merge branch 'master' into sixel

commit 4baf76422fadb216bf27b47645b52da3379e7dea
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Wed Jun 21 07:43:53 2023 +0100

    Both files can go on one line.

commit 4c92acf6ff24dde37ad41cd168ea2d3bcefb8567
Author: topcat001 <anindya49@hotmail.com>
Date:   Sat Jun 17 17:53:01 2023 -0700

    Merge topcat001/tmux/sixel.

commit 6794facc82e98f8448c192913cf62fe6e10fde63
Merge: 7b85f5ad f41c536f
Author: topcat001 <anindya49@hotmail.com>
Date:   Sat Jun 17 17:21:02 2023 -0700

    Merge remote-tracking branch 'origin/master' into sixel

commit 7b85f5adf9a5094db580ca98e4d2231d8d5b5a4f
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Jun 8 12:55:03 2023 +0100

    Do not require passthrough for SIXEL.

commit a6ee55e0925cac35d011c188db2da0421fc09be1
Merge: 6da391f4 fe385b18
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Jun 8 12:19:55 2023 +0100

    Merge branch 'master' into sixel

commit 6da391f460414ed3dde23e5ab6ca3fe8e988ce51
Merge: 0d71e585 0eb5d254
Author: topcat001 <anindya49@hotmail.com>
Date:   Sat May 20 17:05:55 2023 -0700

    Merge branch 'master' into sixel

commit 0d71e5853ffe797f90b815ac3af25ac0ad92ab07
Merge: 64368a1a fbe6fe7f
Author: topcat001 <anindya49@hotmail.com>
Date:   Sat Apr 29 17:32:07 2023 -0700

    Merge branch 'master' into sixel

commit 64368a1a63f04fb877b57e4286c9a2e1efe966c9
Merge: c630a56a 22eb0334
Author: topcat001 <anindya49@hotmail.com>
Date:   Thu Mar 30 14:21:09 2023 -0700

    Merge branch 'master' into sixel

commit c630a56a621b9761eed558cbd566a36cb09adf8f
Merge: 34c96c4c aaa043a2
Author: topcat001 <anindya49@hotmail.com>
Date:   Thu Nov 10 18:53:01 2022 -0800

    Merge branch 'master' into sixel

commit 34c96c4c4a33f86b49c8a53dc48b2b817db24e95
Merge: 2a1e16a2 50f4e0fa
Author: topcat001 <anindya49@hotmail.com>
Date:   Sat Nov 5 18:05:36 2022 -0700

    Merge branch 'master' into sixel

commit 2a1e16a24dc75741c66f5d72fa5bf26b73507993
Merge: a82f14c7 d001a94d
Author: topcat001 <anindya49@hotmail.com>
Date:   Thu Oct 27 16:01:35 2022 -0700

    Merge branch 'master' into sixel

commit a82f14c7b2
Merge: 742c0634 f7b30ed3
Author: topcat001 <anindya49@hotmail.com>
Date:   Sun Aug 28 13:43:07 2022 -0700

    Merge branch 'master' into sixel

commit 742c063473
Merge: 906c92a5 87b248f3
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Fri Apr 1 10:14:15 2022 +0100

    Merge branch 'master' into sixel

commit 906c92a5f4
Merge: 6680a024 138ffc7c
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Wed Dec 8 10:37:33 2021 +0000

    Merge branch 'master' into sixel

commit 6680a024be
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Oct 7 13:59:08 2021 +0100

    Fix build.

commit ebd2c58593
Merge: 90dc0519 fed7b29c
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Oct 7 13:19:48 2021 +0100

    Merge branch 'master' into sixel

commit 90dc05191c
Merge: a282439f 4694afbe
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Feb 20 20:37:32 2020 +0000

    Merge branch 'master' into sixel

commit a282439fcb
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Jan 30 09:12:53 2020 +0000

    Add missing declarations.

commit 3a741aacd1
Merge: 40ad0107 339832b9
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Jan 30 09:11:01 2020 +0000

    Merge branch 'sixel-passthrough' into sixel

commit 339832b92c
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Jan 30 09:04:51 2020 +0000

    Bad merge.

commit 92ed9fc0b2
Merge: 5bb07548 32be954b
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Jan 30 09:03:38 2020 +0000

    Merge branch 'master' into sixel-passthrough

commit 40ad01073d
Merge: dd3c72f1 61b075a2
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Sun Jan 12 20:03:41 2020 +0000

    Merge branch 'master' into sixel

commit 5bb075487f
Merge: 7c033a74 54efe337
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Wed Dec 18 20:24:42 2019 +0000

    Merge branch 'master' into sixel-passthrough

commit dd3c72f132
Merge: 1a0e5fe9 54efe337
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Wed Dec 18 20:24:26 2019 +0000

    Merge branch 'master' into sixel

commit 1a0e5fe933
Merge: cf071ffe 15d7e564
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Tue Dec 10 16:34:11 2019 +0000

    Merge branch 'master' into sixel

commit cf071ffecd
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Mon Dec 9 15:41:56 2019 +0000

    Remove images when reflow happens.

commit 2006b7a563
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Dec 5 09:27:15 2019 +0000

    More invalidation of images.

commit b642eac450
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Dec 5 09:11:24 2019 +0000

    Redraw and scroll images and part of invalidating them.

commit 7566e37a46
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Dec 5 08:51:24 2019 +0000

    Call sixel_scale with the right number of arguments.

commit 62c0280b23
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Dec 5 08:48:58 2019 +0000

    Correctly remove when not visible.

commit 86c5098a88
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Dec 5 08:32:25 2019 +0000

    Add helpers to scroll image up and a flag to copy the colours.

commit 49f2f0a8f1
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Dec 5 00:02:55 2019 +0000

    Store images, currently at most 10.

commit 3aebcc6709
Merge: 146ee3f6 92ecd611
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Wed Dec 4 19:27:16 2019 +0000

    Merge branch 'master' into sixel

commit 7c033a74e2
Merge: 0a15bbf3 92ecd611
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Wed Dec 4 12:41:09 2019 +0000

    Merge branch 'master' into sixel-passthrough

commit 146ee3f6f8
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Sat Nov 30 09:47:53 2019 +0000

    Don't write image as text yet.

commit 0a15bbf3f1
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Sat Nov 30 09:15:35 2019 +0000

    Do not defer redraw if it is just the status line (will need to do more here I
    think).

commit a5b1e20941
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Nov 28 14:20:22 2019 +0000

    Add a flag to disable blocking while sending a SIXEL image (turned off when the
    buffer hits 0 size).

commit 968382aa6a
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Nov 28 12:35:18 2019 +0000

    Pass through SIXEL DCS sequences (treat similarly to the passthrough escape
    sequence) if it appears the terminal outside supports them.

commit b1904c9b8d
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Sat Nov 30 09:17:18 2019 +0000

    Store SIXELs as a box for the moment.

commit 5d8dbcdf3d
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Sat Nov 30 09:15:35 2019 +0000

    Do not defer redraw if it is just the status line (will need to do more here I
    think).

commit 0c999a402e
Merge: 28961dd5 866b053f
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Fri Nov 29 18:54:09 2019 +0000

    Merge branch 'master' into sixel

commit 28961dd5a3
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Nov 28 14:24:57 2019 +0000

    Add an image.

commit d2e3f3c1cc
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Nov 28 14:20:22 2019 +0000

    Add a flag to disable blocking while sending a SIXEL image (turned off when the
    buffer hits 0 size).

commit e01df67ca1
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Nov 28 13:21:40 2019 +0000

    Crop and scale images as needed when drawing them.

commit e24acc0b5c
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Nov 28 12:38:02 2019 +0000

    Simple SIXEL parse and modify API.

commit b34111b3da
Author: Nicholas Marriott <nicholas.marriott@gmail.com>
Date:   Thu Nov 28 12:35:18 2019 +0000

    Pass through SIXEL DCS sequences (treat similarly to the passthrough escape
    sequence) if it appears the terminal outside supports them.
2023-08-22 08:43:35 +01:00
Thomas Adam
e3a8b8434c Merge branch 'obsd-master' 2023-08-17 18:01:09 +01:00
nicm
8636848e63 Add a session, pane and user mouse range types for the status line and
add format variables for mouse_status_line and mouse_status_range so
they can be associated with different commands in the key bindings.
GitHub issue 3652.
2023-08-17 14:10:28 +00:00
Thomas Adam
3d93b0c52e Merge branch 'obsd-master' 2023-08-15 12:01:09 +01:00
nicm
d9942c769e Add meta bindings for status line menus as well as the existing pane one
for terminals which steal the mouse menu button.
2023-08-15 09:51:48 +00:00
Thomas Adam
6a45e6c256 Merge branch 'obsd-master' 2023-08-15 10:01:09 +01:00
nicm
b770a429c6 Add an option menu-selected-style to configure the currently selected
menu item, from Alexis Hildebrandt.
2023-08-15 07:01:47 +00:00
Thomas Adam
11e69f6025 Merge branch 'obsd-master' 2023-08-11 20:01:09 +01:00
nicm
57837bbf67 Do not crash if in buffer mode and the last buffer is deleted using the
command.
2023-08-11 17:09:00 +00:00
Thomas Adam
4c60afde78 Merge branch 'obsd-master' 2023-08-08 12:01:10 +01:00
Thomas Adam
ed689cd54e Merge branch 'obsd-master' 2023-08-08 10:01:11 +01:00
nicm
7a44984069 Add flag to next-prompt/previous-prompt to go to command output instead,
from Magnus Gross.
2023-08-08 08:21:29 +00:00
nicm
dee72ed41f Add options and flags for menu styles similar to those existing for
popups, from Alexis Hildebrandt. GitHub issue 3650.
2023-08-08 08:08:47 +00:00
nicm
1071ef8fc5 Extend the menu drawing function to support custom characters and
styles, from Alexis Hildebrandt.
2023-08-08 07:41:04 +00:00
nicm
2b535bc173 Fix a couple of rounded border characters, from Alexis Hildebrandt. 2023-08-08 07:19:48 +00:00
Thomas Adam
b791f00bf1 Merge branch 'obsd-master' 2023-08-07 14:01:12 +01:00
Thomas Adam
3e82ad5340 Merge branch 'obsd-master' 2023-08-07 12:01:10 +01:00
nicm
7b1030293c Free title earlier, from Alexis Hildebrandt. 2023-08-07 10:52:00 +00:00
nicm
a5fd80bbc3 Trim can generate strings longer than the original if there are many #s,
so create a bigger buffer. Reported by Robert Morris.
2023-08-07 10:04:29 +00:00
Thomas Adam
fda3937734 Merge branch 'obsd-master' 2023-07-19 16:01:09 +01:00
nicm
b13c230749 Correct visited flag when the last window list is rebuilt by renumbering
windows, appears to fix hang reported by Mark Kelly.
2023-07-19 13:03:36 +00:00
Thomas Adam
715f39a53a Merge branch 'obsd-master' 2023-07-14 22:01:10 +01:00
nicm
2f74e811f1 Set extended keys flag again after reset, from Eric T Johnson. 2023-07-14 19:32:59 +00:00
Thomas Adam
828efc7bcf Merge branch 'obsd-master' 2023-07-13 18:01:10 +01:00
nicm
84936b832f Use 8 for underscore colour defaults instead of 0 which is less
confusing, and fix writing tge default colour. GitHub issue 3627.
2023-07-13 06:03:48 +00:00
Thomas Adam
c8494dff7b Merge branch 'obsd-master' 2023-07-11 20:01:10 +01:00
nicm
8fcc212e7a Remove Ns and Li and change Nm to Ic, suggested by jmc. 2023-07-11 16:09:09 +00:00
Thomas Adam
0e281530cb Merge branch 'obsd-master' 2023-07-11 10:01:10 +01:00
nicm
efded95ed7 Add descriptions of copy mode commands, from Michael Bianco. 2023-07-11 07:34:23 +00:00
Thomas Adam
18870913c5 Merge branch 'obsd-master' 2023-07-10 14:01:12 +01:00
nicm
63b7282377 It should no longer be necessary to ignore SIGCHLD because it is now
blocked around daemon(), and doing so causes trouble with newer libevent
(it cannot restore the original handler). Reported by Azat Khuzhin in
GitHub issue 3626.
2023-07-10 12:00:08 +00:00
Thomas Adam
269dab4b3e Merge branch 'obsd-master' 2023-07-10 12:01:12 +01:00
nicm
4ece43a029 Loop around waitpid in client, from Azat Khuzhin. 2023-07-10 09:35:46 +00:00
nicm
8b3e2eab5a Use a stack for last panes line windows, from Thomas Bertschinger in
GitHub issue 3588.
2023-07-10 09:24:53 +00:00
Thomas Adam
e4c4ceb286 Merge branch 'obsd-master' 2023-07-10 02:01:11 +01:00
nicm
b7e22d00b4 Call closefrom after removing signals because newer libevent doesn't
like its signal fd being closed Azat Khuzhin.
2023-07-09 22:54:52 +00:00
Thomas Adam
1a11c972ae Merge branch 'obsd-master' 2023-07-03 20:01:12 +01:00
nicm
43b841f188 Add support for marking lines with a shell prompt based on the OSC 133
extension, from Munif Tanjim in GitHub issue 3596.
2023-07-03 16:47:43 +00:00
Thomas Adam
f9b0460840 Merge branch 'obsd-master' 2023-07-03 14:01:10 +01:00
Thomas Adam
659d876cd5 Merge branch 'obsd-master' 2023-07-03 12:01:09 +01:00
nicm
ac43186dff Do not risk writing over the end of the buffer when it ends in #
(because strchr \0 will be non-NULL), reported by Robert Morris in
GitHub issue 3610.
2023-07-03 10:48:26 +00:00
nicm
e79fb214f8 Another warning fix for GCC from Thomas Klausner. 2023-07-03 08:37:14 +00:00
Thomas Adam
9cf58d1a52 Merge branch 'obsd-master' 2023-07-01 02:01:10 +01:00
nicm
a2a02fd7d7 Change a few types to fix warnings, from Thomas Klausner. 2023-06-30 21:55:08 +00:00
Thomas Adam
237ee6f231 Merge branch 'obsd-master' 2023-06-30 16:01:10 +01:00
nicm
4e57894e85 Get rid of some warnings with GCC 10, from Thomas Klausner. 2023-06-30 13:19:32 +00:00
Nicholas Marriott
8c9fbbf4f3 Add libterminfo for NetBSD, from Thomas Klausner. 2023-06-29 15:31:32 +01:00
Thomas Adam
3f3d61bd58 Merge branch 'obsd-master' 2023-06-26 12:01:09 +01:00
Thomas Adam
80d4f4afc6 Merge branch 'obsd-master' 2023-06-26 10:01:10 +01:00
nicm
2546216019 When exiting alternate screen, there is no need to reflow when going
back to old size since the contents will be overwritten. GitHub issue
3510.
2023-06-26 08:14:19 +00:00
nicm
ff8882a24f Add "us" to styles for underscore colour, GitHub issue 3589. 2023-06-26 07:17:40 +00:00
Thomas Adam
ffe2410639 Merge branch 'obsd-master' 2023-06-25 20:01:09 +01:00
nicm
9e14c1f88d SGR 0 should not end hyperlink, reported by Lucas Trzesniewski. 2023-06-25 15:53:07 +00:00
Thomas Adam
29a5dfc7c0 Merge branch 'obsd-master' 2023-06-21 08:01:08 +01:00
nicm
645bf8b3ab Check fdopen return value, from Christian Menges. 2023-06-21 06:28:18 +00:00
Thomas Adam
f41c536ff3 Merge branch 'obsd-master' 2023-06-08 14:01:09 +01:00
nicm
bdd05bdbd3 Fix mismatch between function prototype and definition, from Anindya
Mukherjee.
2023-06-08 11:17:28 +00:00
Nicholas Marriott
fe385b180f Try utf8proc with pkg-config, from Alex Wu. 2023-06-08 09:10:43 +01:00
Thomas Adam
0eb5d25453 Merge branch 'obsd-master' 2023-05-19 10:01:09 +01:00
nicm
1d98394b41 Add format for server_sessions, from Magnus Gross. 2023-05-19 07:46:34 +00:00
Thomas Adam
149d9cc851 Merge branch 'obsd-master' 2023-05-08 12:01:09 +01:00
tb
204d8f31d7 Reorder struct grid_cell_entry
On aarch64 with llvm 15, the new -Wunaligned-access emits noise on every
one of tmux's source files. This avoids this warning by moving a u_char
to the end of the struct. This does not change the size of the struct on
any architecture.

ok nicm
2023-05-08 10:03:39 +00:00
Thomas Adam
fbe6fe7f55 Merge branch 'obsd-master' 2023-04-28 12:52:21 +01:00
Nicholas Marriott
168eab11a7 Cast both strings for tparm. 2023-04-28 07:23:53 +01:00
nicm
41b318ac7c Add options to change the confirm key and default behaviour of
confirm-before. From Elias Assaf in GitHub issue 3548; prompted by an
earlier change from Yutaro Yoshii in GitHub issue 3496.
2023-04-28 06:12:27 +00:00
nicm
bf636d9575 Do not fatal if tparm fails, instead just log it (not working sequences
are better than exiting).
2023-04-28 05:59:35 +00:00
Nicholas Marriott
39d41d0810 Use ncurses' new tparm_s function (added in 6.4-20230424) instead of tparm so
it does not object to string arguments in capabilities it doesn't already know.
2023-04-28 06:44:40 +01:00
Thomas Adam
9d8131c190 Merge branch 'obsd-master' 2023-04-27 19:16:08 +01:00
Nicholas Marriott
0ff991b25f Set default lock command to vlock on Linux if present at build time, from Josh
Boyer in GitHub issue 3527.
2023-04-25 17:23:32 +01:00
Nicholas Marriott
15c70e562c Include NCURSES_VERSION_PATCH in the log. 2023-04-25 16:48:49 +01:00
nicm
8f34504736 Tidy tparm wrapper functions to have more obvious names and check tparm
return value.
2023-04-25 09:31:50 +00:00
nicm
551e0c36d9 Invalidate cached tty state after changing features since they may
change what the terminal can do and need mouse sequences or similar to
be sent again, GitHub issue 3513.
2023-04-25 09:24:44 +00:00
nicm
48eba4c195 Ignore the user keys range when checking if a key is Unicode. 2023-04-17 18:22:24 +00:00
nicm
9f605178c3 It seems silly to use progname for version, just always say tmux. 2023-04-17 18:00:19 +00:00
nicm
bcafe51378 Make the check if printing is allowed the same as writing which is less
confusing.
2023-04-17 17:58:35 +00:00
nicm
280fe77edd Discard mouse sequences that have the right form but actually are
invalid (for example have column zero rather than one).
2023-04-17 17:57:35 +00:00
Nicholas Marriott
b9524f5b72 Add support for spawning panes in separate cgroups with systemd and a configure
flag to disable. From Eric T Johnson yut23 AT gvljohnsons DOT com in GitHub
issue 3514.
2023-04-03 08:54:06 +01:00
nicm
a2018b2c3f Clarify text for new -A slightly, GitHub issue 3508. 2023-04-03 07:39:37 +00:00
nicm
c21af7e446 Add a format to show if there are unseen changes while in a mode, from
Dan Aloni in GitHub issue 3498.
2023-03-27 08:47:57 +00:00
nicm
d73078838d For passthrough, don't write to clients attached to different sessions,
based on a fix from Sergei Grechanik.
2023-03-27 08:31:32 +00:00
Thomas Adam
22eb0334c3 Merge branch 'obsd-master' 2023-03-15 22:01:09 +00:00
nicm
a9ac614691 Do not leak screen in popups, GitHub issue 3492. 2023-03-15 19:23:22 +00:00
Thomas Adam
1d0f68dee9 Merge branch 'obsd-master' 2023-03-15 10:01:10 +00:00
nicm
ac4bb89d43 Fix command prompt not to always append argument but only if there has
actually been expansion. GitHub issue 3493.
2023-03-15 08:15:39 +00:00
Thomas Adam
b55f34029a Merge branch 'obsd-master' 2023-02-10 16:01:10 +00:00
nicm
907f58cc3c Fix cursor position after zero width space, GitHub issue 3469. 2023-02-10 14:01:43 +00:00
Thomas Adam
023b0f76c3 Merge branch 'obsd-master' 2023-02-07 14:01:11 +00:00
Thomas Adam
ddaeebc213 Merge branch 'obsd-master' 2023-02-07 12:01:13 +00:00
nicm
1262e685b8 Remove old buffer when renaming rather than complaining, GitHub issue
3467 from Jean-Philippe Paradis.
2023-02-07 10:56:04 +00:00
nicm
0bd78b42c0 Add an L modifier like P, W, S to loop over clients. Also fix some long
lines in tmux(1).
2023-02-07 10:21:01 +00:00
Thomas Adam
4a0126f7fb Merge branch 'obsd-master' 2023-02-06 12:01:12 +00:00
nicm
7acc8d703d Add -f to list-clients like the other list commands, from Andy Walker in
GitHub issue 3449.
2023-02-06 09:20:30 +00:00
Thomas Adam
77118f3a9f portable: remove vis.h
This is included portably across different systems.
2023-02-06 01:55:02 +00:00
Thomas Adam
e25926d3c4 Merge branch 'obsd-master' 2023-02-06 00:01:11 +00:00
nicm
0cb75f1332 Do not allow multiple line separators in a row. 2023-02-05 21:26:48 +00:00
nicm
93b1b78150 Extend display-message to work for control clients. GitHub issue 3449. 2023-02-05 21:15:32 +00:00
Thomas Adam
493922dc4b Merge branch 'obsd-master' 2023-02-02 12:01:11 +00:00
nicm
f10854cfc5 Add a missing error message which causes an invalid layout name to crash. 2023-02-02 09:24:59 +00:00
nicm
993e7a937f Tweak note for D key binding, from Clark Wang. 2023-02-02 09:06:44 +00:00
Thomas Adam
f5af3cfb21 Merge branch 'obsd-master' 2023-01-23 12:01:11 +00:00
nicm
e7e112fbd0 Too many \s in example, GitHub issue 3445. 2023-01-23 09:33:51 +00:00
Thomas Adam
c42087c789 Merge branch 'obsd-master' 2023-01-21 00:01:11 +00:00
nicm
3aa458ea63 Add a flag to display-menu to select the manu item chosen first, GitHub
issue 3442.
2023-01-20 21:36:00 +00:00
Thomas Adam
c4a6f403bb Merge branch 'obsd-master' 2023-01-17 12:01:09 +00:00
nicm
9789ea3fb4 Support -1 without -N for list-keys. 2023-01-17 10:40:51 +00:00
Thomas Adam
f416ae1c12 Merge branch 'obsd-master' 2023-01-17 10:01:09 +00:00
nicm
d578cf8d3f Update palette when moving a pane, GitHub issue 3437. 2023-01-17 06:50:55 +00:00
Thomas Adam
789cb91f31 Merge branch 'obsd-master' 2023-01-16 14:01:10 +00:00
nicm
eb1f8d70a7 Mark keys sent by command and skip paste handling for them. 2023-01-16 11:26:14 +00:00
Thomas Adam
42895efac3 Merge branch 'obsd-master' 2023-01-12 22:01:09 +00:00
nicm
483cc77c1c Have tmux recognise pasted texts wrapped in bracket paste sequences,
rather than only forwarding them to the program inside. From Andrew
Onyshchuk in GitHub issue 3431.
2023-01-12 18:49:11 +00:00
Thomas Adam
9b1ea8b16d Merge branch 'obsd-master' 2023-01-09 16:01:11 +00:00
nicm
b41892622d Fix behaviour with \007 (used the wrong tree for last change). 2023-01-09 14:12:41 +00:00
Thomas Adam
9051220243 Merge branch 'obsd-master' 2023-01-09 10:01:09 +00:00
nicm
c0031f8b85 Accept \007 as terminator to OSC 10 or 11. 2023-01-09 07:57:14 +00:00
Thomas Adam
c1a30ed995 Merge branch 'obsd-master' 2023-01-09 02:01:10 +00:00
nicm
565de3f54b Fix parsing of optional arguments so that and accept a - starting an
argument.
2023-01-08 23:34:46 +00:00
Thomas Adam
153ae758c9 portable: fixup merge with utf8.c 2023-01-08 23:27:54 +00:00
Thomas Adam
5086377f30 Merge branch 'obsd-master' 2023-01-08 23:26:09 +00:00
nicm
7c0789d2d2 Have client return 1 if process is interrupted to an input pane. 2023-01-08 22:17:04 +00:00
Nicholas Marriott
2a32565e0c Restore code to handle wcwidth failure so that unknown codepoints still
do the most likely right thing. GitHub issue 3427, patch based on an
diff from Jesse Luehrs in GitHub issue 3003.
2023-01-08 22:15:38 +00:00
nicm
7ced0a03d2 Restore code to handle wcwidth failure so that unknown codepoints still
do the most likely right thing. GitHub issue 3427, patch based on an
diff from Jesse Luehrs in GitHub issue 3003.
2023-01-08 22:15:30 +00:00
nicm
cb51942669 Quotes are now required in select-layout example. 2023-01-08 21:00:01 +00:00
Nicholas Marriott
093fb53773 Missing #endif. 2023-01-06 11:38:41 +00:00
Thomas Adam
21e00e4635 Merge branch 'obsd-master' 2023-01-06 09:02:00 +00:00
nicm
09afc6c8ee If a pane is killed, cancel reading from the file. GitHub issue 3422. 2023-01-06 07:09:27 +00:00
nicm
a41a927441 Query the client terminal for foreground and background colours and if
OSC 10 or 11 is received but no colour has been set inside tmux, return
the colour from the first attached client (probably most people will
have all light or or all dark terminals).
2023-01-03 11:43:24 +00:00
jmc
3fe01ff09c spelling fixes; from paul tagliamonte
amendments to his diff are noted on tech
2022-12-26 19:16:03 +00:00
kn
b5ab4d2c13 Denote multiple arguments with 'arg ...' not 'args'
A few programs used the plural in their synopsis which doesn't read as
clear as the obvious triple-dot notation.

mdoc(7) .Ar defaults to "file ..." if no arguments are given and consistent
use of 'arg ...' matches that behaviour.

Cleanup a few markups of the same argument so the text keeps reading
naturally;  omit unhelpful parts like 'if optional arguments are given,
they are passed along' for tools like time(1) and timeout(1) that obviously
execute commands with whatever arguments where given -- just like doas(1)
which doesn't mention arguments in its DESCRIPTION in the first place.

For expr(1) the difference between 'expressions' and 'expression ...' is
crucial, as arguments must be passed as individual words.

Feedback millert jmc schwarze deraadt
OK jmc
2022-12-22 19:53:23 +00:00
nicm
4d79d463ef Allow send-keys without a client again, reported by Stefan Hagen. 2022-12-19 07:30:10 +00:00
nicm
7cb48fc40b Do not escape tabs in output (iTerm2 needs them). GitHub issue 3414. 2022-12-16 08:22:05 +00:00
nicm
8bd17bff49 Make U+FE0F VARIATION SELECTOR-16 change the width from 1 to 2. GitHub
issue 3409.
2022-12-16 08:19:58 +00:00
nicm
3b3f42053a Add send-keys -K to handle keys directly as if typed (so look up in key
table). GitHub issue 3361.
2022-12-16 08:13:40 +00:00
Nicholas Marriott
70ff8cfe1e No vis.h in portable. 2022-12-07 12:30:36 +00:00
Thomas Adam
6249a4b866 Merge branch 'obsd-master' 2022-12-07 12:01:09 +00:00
nicm
7e497c7f23 Process escape sequences in show-buffer, GitHub issue 3401. 2022-12-07 09:44:44 +00:00
Thomas Adam
1536b7e206 Merge branch 'obsd-master' 2022-11-11 10:01:09 +00:00
Nicholas Marriott
e46d0632a5 Add key regression tests from Aaron Jensen. 2022-11-11 08:47:55 +00:00
nicm
20da167377 Tweak previous to set and log the feature instead of just setting the
flag.
2022-11-11 08:44:11 +00:00
nicm
fe475bd856 Parse primary device attributes as well as secondary and add a SIXEL
flag (not used yet), from Anindya Mukherjee.
2022-11-11 08:37:55 +00:00
nicm
079f48e8a6 Document alternative delimiters for substitution, from Jim Wisniewski. 2022-11-11 08:27:17 +00:00
Thomas Adam
aaa043a20f Merge branch 'obsd-master' 2022-11-11 02:01:10 +00:00
jmc
48f41e4a41 - sort options; from josiah frentsos
ok nicm

- add -N to SYNOPSIS

- sort usage()
2022-11-10 22:58:39 +00:00
Thomas Adam
6fb80527f3 Merge branch 'obsd-master' 2022-11-08 12:01:11 +00:00
nicm
f86eba2129 Fix C-S-Tab without extended keys, from Aaron Jensen. 2022-11-08 10:04:31 +00:00
Thomas Adam
50f4e0fac9 Merge branch 'obsd-master' 2022-11-04 10:01:10 +00:00
nicm
77c135349a Unescape the string for the literal operator (l:) so special characters
work.
2022-11-04 08:03:23 +00:00
Thomas Adam
c449512be4 Merge branch 'obsd-master' 2022-11-03 10:01:11 +00:00
nicm
17290b9121 If there are no buffers, reset mode as soon as any key pressed. Fixes
crash reported by Gaoyang Zhang in GitHub issue 3373.
2022-11-03 08:41:53 +00:00
nicm
3be369522b Add a -l flag to display-message to disable format expansion, from Aaron
Jensen. GitHub issue 3372.
2022-11-03 08:33:57 +00:00
Thomas Adam
dbfbd8a195 Merge branch 'obsd-master' 2022-11-02 08:01:11 +00:00
nicm
9614f51560 Instead of always setting the extended flag, set it only when searching.
Allows send-keys to work. From Aaron Jensen.
2022-11-02 07:36:07 +00:00
Thomas Adam
36896f6dd0 Merge branch 'obsd-master' 2022-11-01 12:01:10 +00:00
nicm
2d08235987 Add modified Tab key sequences, from Aaron Jensen, GitHub issue 3368. 2022-11-01 09:54:13 +00:00
nicm
2291045116 Use active pane in target window not current window for +/-. GitHub
issue 3370.
2022-11-01 09:46:14 +00:00
Thomas Adam
9dd1f442c5 Merge branch 'obsd-master' 2022-10-28 16:01:10 +01:00
nicm
8edece2cdb Add paste-buffer-deleted notification and fix name of paste-buffer-changed. 2022-10-28 13:00:02 +00:00
Thomas Adam
d001a94d7b Merge branch 'obsd-master' 2022-10-25 22:01:10 +01:00
nicm
c2580cfe24 Initialize context before testing it. 2022-10-25 17:53:31 +00:00
Thomas Adam
dafd6f462f Merge branch 'obsd-master' 2022-10-25 12:01:10 +01:00
nicm
2111142cf1 Fix a memory leak, from Japin Li in GitHub issue 3358. 2022-10-25 09:12:05 +00:00
nicm
0fc961b22e Do not fire redraw callback if NULL. 2022-10-25 09:04:49 +00:00
Nicholas Marriott
5ce34add77 Do not attempt to connect to the socket as a client if systemd is active, from
Julien Moutinho in GitHub issue 3345.
2022-10-18 15:58:06 +01:00
Thomas Adam
934f357149 Merge branch 'obsd-master' 2022-10-17 14:01:10 +01:00
nicm
ff2766b024 Preserve marked pane when renumbering windows. 2022-10-17 10:59:42 +00:00
Thomas Adam
9ef854f5a9 Merge branch 'obsd-master' 2022-09-28 12:01:09 +01:00
nicm
a10452be2d Add scroll-top and scroll-bottom commands to scroll so cursor is at top
or bottom. From Anindya Mukherjee, GitHub issue 3334.
2022-09-28 07:59:50 +00:00
nicm
9cc8e40aa0 Add a -T flag to capture-pane to stop at the last used cell instead of
the full width. Restore the previous behaviour by making it default to
off unless -J is used (the only time it matters). Fixes mosh unit tests;
GitHub issue 3339.
2022-09-28 07:55:29 +00:00
Thomas Adam
f49f92737f Merge branch 'obsd-master' 2022-09-22 17:10:38 +01:00
Nicholas Marriott
19344ec890 Add headers and fix type, from Marvin Schmidt. GitHub issue 3332. 2022-09-19 07:03:17 +01:00
nicm
a2cc601c3d Don't use options from pane if pane is NULL. 2022-09-12 12:02:17 +00:00
nicm
9ab1ba36cd Use correct option name. 2022-09-10 17:01:33 +00:00
nicm
f03c3ca6c3 Add message-line option to control where message and prompt go, from
Varun Kumar E in GitHub issue 3324.
2022-09-09 11:02:23 +00:00
Nicholas Marriott
0a0ded3268 Regress typos. 2022-09-07 07:28:26 +01:00
Thomas Adam
6da520c5a1 Merge branch 'obsd-master' 2022-08-31 12:01:10 +01:00
nicm
68dc9af9ac Fix window size report, from Vincent Bernat. 2022-08-31 08:07:05 +00:00
Thomas Adam
f7b30ed3d4 Merge branch 'obsd-master' 2022-08-24 10:01:13 +01:00
nicm
e867528209 Check for NULL returns from bufferevent_new. 2022-08-24 07:22:30 +00:00
Thomas Adam
038dfb27a8 Merge branch 'obsd-master' 2022-08-23 12:01:10 +01:00
nicm
416c27c995 Add scroll-middle copy mode command to make cursor line in the middle,
from Varun Kumar E in GitHub issue 3307.
2022-08-23 08:14:19 +00:00
Nicholas Marriott
19344efa78 Fix fallback implementaion of getpeereid, from Pino Toscano. 2022-08-22 08:21:42 +01:00
Thomas Adam
9c34aad21c Merge branch 'obsd-master' 2022-08-15 13:54:47 +01:00
nicm
7c2dcd7238 Notify when a paste buffer is deleted, GitHub issue 3302 from George
Nachman.
2022-08-15 09:10:34 +00:00
nicm
03149bf7f6 Add a Nobr terminfo capability to tell tmux the terminal does not use
bright colours for bold (makes a difference to how tmux applies palette
differences). From Damien Tardy-Panis in GitHub issue 3301.
2022-08-15 08:54:03 +00:00
nicm
497021d0db Add some const, from Markus F X J Oberhumer. 2022-08-15 08:41:13 +00:00
nicm
cfdc5b62ad Don't stop at first match when updating environment. 2022-08-15 08:37:03 +00:00
Thomas Adam
9b08e5139b Merge branch 'obsd-master' 2022-08-11 12:01:10 +01:00
nicm
e139f977b1 vi(1) Home/End bindings, from Markus F X J Oberhumer. 2022-08-11 09:11:26 +00:00
Thomas Adam
9abf5d9fe5 Merge branch 'obsd-master' 2022-08-10 18:01:11 +01:00
nicm
273577ba0a Fix check of home directory (&& not ||), from Markus F X J Oberhumer,
GitHub issue 3297.
2022-08-10 14:03:59 +00:00
Thomas Adam
e15058e60f Merge branch 'obsd-master' 2022-08-04 16:01:09 +01:00
nicm
de5cd54124 Change g and G to go to top and bottom of menu, GitHub issue 3286. 2022-08-04 12:06:09 +00:00
Thomas Adam
c6cf09450a Merge branch 'obsd-master' 2022-08-03 16:01:11 +01:00
nicm
c6e7568471 Do not crash when searching for .* with extremely long lines. Reported
by Torbjorn Lonnemark, GitHub issue 3272.
2022-08-03 13:27:48 +00:00
Thomas Adam
7b8ececd8d Merge branch 'obsd-master' 2022-08-02 14:01:09 +01:00
nicm
42ba6c1b22 Add a third state "all" to allow-passthrough to work even in invisible
panes, from Sergei Grechanik in GitHub issue 3274.
2022-08-02 11:09:26 +00:00
Thomas Adam
9a2fdf8fd4 Merge branch 'obsd-master' 2022-08-02 12:01:09 +01:00
Nicholas Marriott
00812c9053 Check for $YACC, from Wei Shih in GitHub issue 3267. 2022-08-02 11:52:09 +01:00
nicm
33c59100ae Fix validation of missing percentage arguments. 2022-08-02 09:23:34 +00:00
nicm
36d904011a -u is no longer equivalent to -TUTF-8 so don't say it is. 2022-08-02 08:57:01 +00:00
Thomas Adam
9d9445a48e Merge branch 'obsd-master' 2022-07-22 10:01:10 +01:00
nicm
a8da24771c Clear marks when the search string changes. From Anindya Mukherjee,
GitHub issue 3255.
2022-07-22 07:14:07 +00:00
Thomas Adam
ab1d18d00f Merge branch 'obsd-master' 2022-07-19 10:01:08 +01:00
nicm
ee431d482a Do not ignore the "off" flag when checking if a pane should be stopped,
GitHub issue 3250.
2022-07-19 07:10:13 +00:00
Nicholas Marriott
e06c09889c Add permissions for workflow, GitHub issue 3202. 2022-07-19 07:54:11 +01:00
nicm
86dfbda0e4 Process modifiers as bits rather than using a switch, from Koichi Murase. 2022-07-19 06:51:31 +00:00
Nicholas Marriott
697cebb4c1 Include curses properly for hyperlinks ifdef, from chrysn at fsfe dot org. 2022-07-19 07:48:48 +01:00
nicm
3c65475561 Fix memory leak, from Gabriel Souza Franco. 2022-07-19 06:46:57 +00:00
Thomas Adam
dc6bc0e95a Merge branch 'obsd-master' 2022-07-06 12:01:09 +01:00
Thomas Adam
b130e951cc Merge branch 'obsd-master' 2022-07-06 10:01:10 +01:00
Nicholas Marriott
9e19f132f2 Errors are now displayed on attach so use control mode to test
instead.
2022-07-06 09:54:53 +01:00
nicm
1afe22086f Show config errors on attach if they were not shown when the session
was created.
2022-07-06 08:40:52 +00:00
Nicholas Marriott
8e8b9865d1 Add hyperlink test, from Jeff Chiang. 2022-07-06 09:33:30 +01:00
nicm
a39827a85c Remove debugging code. 2022-07-06 08:32:28 +00:00
nicm
9e03df5500 Defer reading from control client until the command line command has
completed.
2022-07-06 08:31:59 +00:00
nicm
dd602eaa61 Mention whether time is creation/activity for sort orders. 2022-07-06 07:51:37 +00:00
nicm
d0d2c39dec Support hyperlinks with capture-pane -e and add a mouse_hyperlink
format, GitHub issue 3247 from Jeff Chiang.
2022-07-06 07:36:36 +00:00
Thomas Adam
57fec74966 Merge branch 'obsd-master' 2022-07-04 12:01:10 +01:00
nicm
9360e0ef32 Sort panes by index not by ID, GitHub issue 3249. 2022-07-04 08:39:45 +00:00
Nicholas Marriott
f08c019d41 Do not set Hls for hyperlinks on ncurses older than 5.9 (for example macOS). 2022-06-30 16:46:26 +01:00
Thomas Adam
c3af8f6b16 hyperlinks: remove vis.h
Not used on Linux.
2022-06-30 16:44:43 +01:00
Thomas Adam
01c4919f5f Merge branch 'obsd-master' 2022-06-30 16:37:18 +01:00
nicm
cdacc12ce3 Add support for OSC 8 hyperlinks (a VTE extension now supported by other
terminals such as iTerm2). Originally written by me then extended and
completed by first Will Noble and later Jeff Chiang. GitHub issues 911,
2621, 2890, 3240.
2022-06-30 09:55:53 +00:00
Thomas Adam
d8c527a5f9 Merge branch 'obsd-master' 2022-06-27 12:01:09 +01:00
nicm
b22edcf3a5 Tweak previous - find end of style correctly. 2022-06-27 09:16:54 +00:00
nicm
786cff8db9 Do not expand single character format aliases inside #[] since they
interfere with colours. GitHub issue 3239 from Magnus Gross.
2022-06-27 09:14:49 +00:00
Thomas Adam
b63afaea61 Merge branch 'obsd-master' 2022-06-21 12:01:09 +01:00
nicm
9c89f7c2af Store time lines are scrolled into history and display in copy mode. 2022-06-21 09:30:01 +00:00
Thomas Adam
d46870ede5 Merge branch 'obsd-master' 2022-06-20 12:01:09 +01:00
nicm
a888ce9963 Do not display configuration file errors in a pane when in control mode,
instead report them with a %config-error notification. GitHub issue 3193.
2022-06-20 07:59:37 +00:00
Thomas Adam
8ff3091d16 Merge branch 'obsd-master' 2022-06-17 10:01:10 +01:00
nicm
d9f84854ac Check cursor options when a pane is created, not just when they are changed. 2022-06-17 07:28:05 +00:00
Thomas Adam
89fe2680a9 Merge branch 'obsd-master' 2022-06-16 16:01:08 +01:00
nicm
7cee982f90 Keep cursor on selected item on menu (useful for blind people), GitHub
issue 3225.
2022-06-16 13:27:39 +00:00
Nicholas Marriott
42358cc521 Typos from Bastian Venthur. 2022-06-15 08:01:50 +01:00
Thomas Adam
06869ff22f Merge branch 'obsd-master' 2022-06-14 10:01:08 +01:00
nicm
616bde08ac kf* terminfo capabilities are poorly defined and rxvt uses them in a
different way from xterm, so add a feature flag for rxvt to make tmux
ignore the capabilities and instead rely on its builtin definitions.
2022-06-14 07:29:00 +00:00
Thomas Adam
6d0828b81c Merge branch 'obsd-master' 2022-06-11 20:01:09 +01:00
nicm
42ddf02ffc Fix size of flags output buffer. 2022-06-11 16:59:33 +00:00
Thomas Adam
56390e0a39 Merge branch 'obsd-master' 2022-06-10 16:01:11 +01:00
nicm
18a5835aff Ignore OSC if the first argument is not properly terminated. 2022-06-10 11:55:30 +00:00
Nicholas Marriott
67960dcc9a Merge tag '3.3a'
3.3a
2022-06-09 13:07:18 +01:00
Nicholas Marriott
0b355ae811 3.3a. 2022-06-09 12:30:50 +01:00
Nicholas Marriott
6a9bb2a622 Remove extra definition of getpeereid. From Eric N Vander Weele in GitHub issue
3209.
2022-06-09 12:28:38 +01:00
nicm
988e59cf3e Do not attempt to use client in config file (it will be NULL), GitHub
issue 3206.
2022-06-09 12:28:34 +01:00
nicm
30e06e9d85 Do not unintentionally turn off all mouse mode when button is also present. 2022-06-09 12:28:22 +01:00
Thomas Adam
810daefdd1 Merge branch 'obsd-master' 2022-06-09 12:01:09 +01:00
nicm
ccc9dc3bb4 If an application gives the first parameter to OSC 52, validate and pass
on to outside terminal. GitHub issue 3192.
2022-06-09 09:12:55 +00:00
Thomas Adam
be2eb57d62 Merge branch 'obsd-master' 2022-06-07 14:01:09 +01:00
nicm
c07d582e24 Expand arguments to some commands where it makes sense, GitHub issue
3204 from Anindya Mukherjee.
2022-06-07 10:02:19 +00:00
Thomas Adam
afb3a5fe71 Merge branch 'obsd-master' 2022-06-04 10:01:09 +01:00
nicm
020c403dff When picking a buffer because one isn't specified by the user, ignore
named buffers. GitHub issue 3212 from David le Blanc.
2022-06-04 07:42:07 +00:00
Thomas Adam
e77e11ec6b Merge branch 'obsd-master' 2022-06-03 12:01:09 +01:00
nicm
3edda3c5e7 Do not unintentionally turn off all mouse mode when button is also present. 2022-06-03 08:09:16 +00:00
Thomas Adam
1184dc08d4 Merge branch 'obsd-master' 2022-06-03 00:01:08 +01:00
nicm
18838fbc87 Do not attempt to use client in config file (it will be NULL), GitHub
issue 3206.
2022-06-02 21:19:32 +00:00
Nicholas Marriott
be2617036f Remove extra definition of getpeereid. From Eric N Vander Weele in GitHub issue
3209.
2022-06-02 21:45:53 +01:00
nicm
0f6227f46b When deleting or renaming a buffer and a buffer name is specified,
complain if the buffer doesn't exist instead of silently deleting or
renaming the most recent buffer. GitHub issue 3205.
2022-06-02 20:41:21 +00:00
Thomas Adam
c1ac007576 Merge branch 'obsd-master' 2022-06-01 18:01:08 +01:00
nicm
201a8d8e7e If escape-time is 0, force to 1 instead - not waiting at all is asking
for problems on some platforms.
2022-06-01 15:43:22 +00:00
Nicholas Marriott
b566cd57bf Now back to 3.4. 2022-06-01 08:50:54 +01:00
Nicholas Marriott
87fe00e8b4 Update CHANGES. 2022-06-01 08:37:14 +01:00
Nicholas Marriott
ced83792b1 Set version to 3.3. 2022-06-01 08:28:32 +01:00
Thomas Adam
42f6d11a6b Merge branch 'obsd-master' 2022-05-31 20:01:10 +01:00
nicm
74fb959f6d Add a missing space. 2022-05-31 16:13:43 +00:00
Thomas Adam
9daaf01730 Merge branch 'obsd-master' 2022-05-31 14:01:09 +01:00
nicm
86a184b288 Trim menu item text correctly, GitHub issue 3197. 2022-05-31 10:22:42 +00:00
Thomas Adam
af596c0828 Merge branch 'obsd-master' 2022-05-30 16:28:27 +01:00
nicm
58c8ea1209 Remove duplicates from completion list, GitHub issue 3178. 2022-05-30 13:07:46 +00:00
nicm
2f2bb82f5f Add pane_start_path to match start_command. 2022-05-30 13:07:06 +00:00
nicm
6a5d210e55 Set PWD so shells have a hint about the real path (this was done before
but lost in a merge). GitHub issue 3186.
2022-05-30 13:06:41 +00:00
nicm
384f0ee269 Fix property name from Sergei Dyshel, and a typo from imcusg at gmail
dot com.
2022-05-30 13:06:10 +00:00
nicm
006a529db1 Check if args_strtonum argument is NULL or not a string, from Anindya
Mukherjee.
2022-05-30 13:04:24 +00:00
nicm
af1496b300 Do not allow pipe-pane on dead panes, from Anindya Mukherjee, GitHub
issue 3174.
2022-05-30 13:03:46 +00:00
nicm
2b60ff588e If a mouse position was above the maximum supported by the normal mouse
protocol (223), tmux was allowing it to wrap around. However, since tmux
was not correctly handling this on input, other programs also do not
handle it correctly, and the alternative SGR mouse mode is now
widespread, this seems unnecessary, so remove this feature. Also define
some constants to make it clearer what the numbers mean. Mostly from
Leonid S Usov in GitHub issue 3165.
2022-05-30 13:02:55 +00:00
nicm
cd89000c1d Add a way for lines added to copy mode to be passed through the parser
to handle escape sequences and use it for run-shell, GitHub issue 3156.
2022-05-30 13:00:18 +00:00
nicm
20b0b38cf4 iTerm2 has OSC 7, from Gregory Anders. 2022-05-30 12:57:31 +00:00
nicm
0a8f356c72 Spacing/style nits. 2022-05-30 12:55:25 +00:00
nicm
af611815ea Emit window-layout-changed on swap-pane, from George Nachman. 2022-05-30 12:54:09 +00:00
nicm
4ae2c64657 Better error reporting when applying custom layouts. 2022-05-30 12:52:02 +00:00
nicm
cd692b5a68 Add an ACL list for users connecting to the tmux socket. Users may be
forbidden from attaching, forced to attach read-only, or allowed to
attach read-write. A new command, server-access, configures the list.
tmux gets the user using getpeereid(3) of the client socket. Users must
still configure file system permissions manually. From Dallas Lyons and
others.
2022-05-30 12:48:57 +00:00
Nicholas Marriott
bf33e807b6 Fix property name, from Sergei Dyshel. 2022-05-30 08:43:06 +01:00
Nicholas Marriott
cf7e1c94df Remove duplicates from completion list, GitHub issue 3178. 2022-05-20 09:00:37 +01:00
Nicholas Marriott
1b28b2b51d Add pane_start_path to match start_command. 2022-05-20 08:49:05 +01:00
Nicholas Marriott
95baa32383 Set PWD so shells have a hint about the real path (this was done before but
lost in a merge). GitHub issue 3186.
2022-05-20 08:33:57 +01:00
Nicholas Marriott
ead75c2d51 Typos, from imcusg at gmail dot com. 2022-05-14 20:16:46 +01:00
Nicholas Marriott
2cad9a6af8 Check if args_strtonum argument is NULL or not a string, from Anindya
Mukherjee.
2022-05-14 20:13:52 +01:00
Nicholas Marriott
3b7dae9a53 Do not allow pipe-pane on dead panes, from Anindya Mukherjee, GitHub issue
3174.
2022-05-02 10:47:08 +01:00
Thomas Adam
5ed64657d8 Merge branch 'obsd-master' 2022-05-01 22:33:38 +01:00
Nicholas Marriott
c6b51cea92 If a mouse position was above the maximum supported by the normal mouse
protocol (223), tmux was allowing it to wrap around. However, since tmux was
not correctly handling this on input, other programs also do not handle it
correctly, and the alternative SGR mouse mode is now widespread, this seems
unnecessary, so remove this feature. Also define some constants to make it
clearer what the numbers mean. Mostly from Leonid S Usov in GitHub issue 3165.
2022-04-27 11:34:08 +01:00
Nicholas Marriott
58d1a206c6 Add a way for lines added to copy mode to be passed through the parser to
handle escape sequences and use it for run-shell, GitHub issue 3156.
2022-04-18 11:47:14 +01:00
Nicholas Marriott
e0c982c5ad iTerm2 has OSC 7, from Gregory Anders. 2022-04-15 12:45:43 +01:00
nicm
d4423dca19 Fix clearphist alias, from Jacqueline Jolicoeur via jmc@. 2022-04-14 06:59:29 +00:00
Nicholas Marriott
8bcd392ee7 On platforms with no way to get peer UID, use getuid(), also fix some failure
checks.
2022-04-06 16:47:59 +01:00
Nicholas Marriott
3a6d82b7c8 Some style nits. 2022-04-06 16:39:46 +01:00
Nicholas Marriott
0c84a20d2f Emit window-layout-changed on swap-pane, from George Nachman. 2022-04-06 14:43:12 +01:00
Nicholas Marriott
996e54763c Better error reporting when applying custom layouts. 2022-04-06 14:41:44 +01:00
Nicholas Marriott
18105c8ecb Do not send focus sequences when focus is enabled or disabled by the
application if it is turned off. GitHub issue 3142.
2022-04-06 14:30:37 +01:00
Nicholas Marriott
d6306b634e Add an ACL list for users connecting to the tmux socket. Users may be forbidden
from attaching, forced to attach read-only, or allowed to attach read-write. A
new command, server-access, configures the list. tmux gets the user using
getpeereid(3) of the client socket. Users must still configure file system
permissions manually.
2022-04-06 14:28:50 +01:00
Nicholas Marriott
6e9a9d265e Fix version. 2022-04-06 14:26:19 +01:00
Nicholas Marriott
36648f2668 Merge remote-tracking branch 'origin/3.3-rc' 2022-04-06 14:25:57 +01:00
Nicholas Marriott
7f86cab1d2 Merge tag '3.3-rc'
3.3-rc
2022-04-06 14:24:33 +01:00
Nicholas Marriott
39b1e96b45 Add to CHANGES. 2022-04-06 14:24:17 +01:00
nicm
1e9c3b3c63 Preserve CRLF flag when respawning. 2022-04-06 14:19:52 +01:00
naddy
fc6580574e man pages: add missing commas between subordinate and main clauses
jmc@ dislikes a comma before "then" in a conditional, so leave those
untouched.

ok jmc@
2022-04-06 14:19:52 +01:00
nicm
2df7bc14fa Capture up to used size not available size for each line. 2022-04-06 14:19:52 +01:00
nicm
880abd0ec2 Report error if creating socket fails with -D. 2022-04-06 14:19:52 +01:00
Nicholas Marriott
1c69a91c25 Add support for systemd socket activation (where systemd creates the Unix
domain socket for tmux rather than tmux creating it). Build with
--enable-systemd. From Julien Moutinho in GitHub issue 3119.
2022-04-06 14:19:52 +01:00
nicm
98de5784a0 Fix exit message if creating socket fails. 2022-04-06 14:19:51 +01:00
nicm
d4eda7f9e5 Add unit (milliseconds) to escape-time, show unset colours as "none"
rather than "invalid" and don't show the same text twice for user
options in customize mode.
2022-04-06 14:19:51 +01:00
nicm
89a0046ad3 Add a capability for OSC 7 and use it similarly to how the title is set
(and controlled by the same set-titles option). GitHub issue 3127.
2022-04-06 14:19:51 +01:00
nicm
60a0a904e0 Check scroll-on-clear for ED also. 2022-04-06 14:19:51 +01:00
nicm
c0508c9321 Add an option (scroll-on-clear) to control if tmux scrolls into history
on clear, from Robert Lange in GitHub issue 3121.
2022-04-06 14:19:51 +01:00
nicm
fe44b105e4 Add an option to set the character used for unused areas of the
terminal, GitHub issue 3110.
2022-04-06 14:19:51 +01:00
nicm
ad7113e0db With -f use percentages of window size not pane size, GitHub issue 2866. 2022-04-06 14:19:51 +01:00
nicm
23e613fcf5 Fix user hooks (which are strings not arrays). 2022-04-06 14:19:51 +01:00
nicm
98b92c0525 Add remain-on-exit-format to set text shown when pane is dead. 2022-04-06 14:19:51 +01:00
nicm
57f331438a Add argument to refresh-client -l to forward clipboard to a pane. GitHub
issue 3068.
2022-04-06 14:19:51 +01:00
nicm
8aed444201 Add formats for client and server UID and user (for multiuser setups). 2022-04-06 14:19:50 +01:00
Nicholas Marriott
f97d784f17 Use getpeerucred if available (not tested). 2022-04-06 14:19:50 +01:00
Nicholas Marriott
759f949654 Need a declaration for getpeereid also. 2022-04-06 14:19:50 +01:00
Nicholas Marriott
f1d8724198 Add getpeerid compat. 2022-04-06 14:19:50 +01:00
Nicholas Marriott
367ee79df0 Remove unnecessary declarations. 2022-04-06 14:19:50 +01:00
nicm
d5a84de842 Pass client when adding menu item, GitHub issue 3103. 2022-04-06 14:19:50 +01:00
nicm
355ced93cc Allow optional arguments. 2022-04-06 14:19:50 +01:00
nicm
bc0bd8213d Don't convert codes for special keys (Tab, Enter, Escape). 2022-04-06 14:19:50 +01:00
topcat001
141a823ea4 Use PATH_MAX instead of MAXPATHLEN. 2022-04-06 14:19:50 +01:00
nicm
42e7959336 Exit on SIGHUP before attach also, GitHub issue 3084. 2022-04-06 14:19:50 +01:00
nicm
9947f7416a Map control keys back to an ASCII uppercase letter when passing them on
as extended keys.
2022-04-06 14:19:50 +01:00
deraadt
c030d6fe36 MAXCOMLEN is no longer needed in these programs, so remove the annotation
from sys/param.h include lines, or remove the include lines entirely if
it this was the least requirement.
ok millert
2022-04-06 14:19:50 +01:00
nicm
046530878b Do not attempt to update focus (and crash) when there is no previous window. 2022-04-06 14:19:50 +01:00
nicm
a26ebccd42 Add next_session_id format with the next session ID, GitHub issue 3078. 2022-04-06 14:19:50 +01:00
nicm
92a26a8b8c Initialize copy_width before adjusting it, GitHub issue 3079. 2022-04-06 14:19:50 +01:00
nicm
f74a98cd07 Use correct size for screen when popup is created without borders. 2022-04-06 14:19:50 +01:00
nicm
4893edd5d6 Add a window-resized hook which is fired when the window is actually
resized which may be later than the client resize, GitHub issue 2995.
2022-04-06 14:19:49 +01:00
nicm
6a0a783c26 Support more mouse buttons when the terminal sends them, GitHub issue
3055.
2022-04-06 14:19:49 +01:00
Nicholas Marriott
7f40c5b647 No not allow static linking on macOS. 2022-04-06 14:19:49 +01:00
nicm
eabbc80b75 Add an option (default off) to control the passthrough escape sequence.
Like set-clipboard and allow-rename it is safer to forbid this by
default.
2022-04-06 14:19:49 +01:00
nicm
190b88fcab Do not create a buffer from an OSC 52 response if we have not sent a
query.
2022-04-06 14:19:49 +01:00
nicm
2adbe3ec16 Do not return error with -q, GitHub issue 3065. 2022-04-06 14:19:49 +01:00
nicm
9efa419955 Use ACS for pane border indicators so they work with different line
types, from Thomas Adam.
2022-04-06 14:19:49 +01:00
nicm
921be61930 Adjust size given to resize-pane for pane status line, GitHub issue
3050.
2022-04-06 14:19:49 +01:00
Thomas Adam
b0ff446727 Merge branch 'obsd-master' into master 2022-04-01 14:01:11 +01:00
nicm
65c0af76fb Preserve CRLF flag when respawning. 2022-04-01 10:11:59 +00:00
Thomas Adam
87b248f3e8 Merge branch 'obsd-master' into master 2022-03-31 20:01:11 +01:00
naddy
2d9f4ca9a1 man pages: add missing commas between subordinate and main clauses
jmc@ dislikes a comma before "then" in a conditional, so leave those
untouched.

ok jmc@
2022-03-31 17:27:27 +00:00
Thomas Adam
fc82f2525c Merge branch 'obsd-master' into master 2022-03-30 10:01:11 +01:00
nicm
ded695504f Capture up to used size not available size for each line. 2022-03-30 07:05:26 +00:00
Thomas Adam
ac16f2c641 Merge branch 'obsd-master' into master 2022-03-28 10:01:11 +01:00
Nicholas Marriott
fc7f1e7acb Add support for systemd socket activation (where systemd creates the Unix
domain socket for tmux rather than tmux creating it). Build with
--enable-systemd. From Julien Moutinho in GitHub issue 3119.
2022-03-28 08:42:13 +01:00
nicm
207b1bc385 Report error if creating socket fails with -D. 2022-03-28 07:40:57 +00:00
Thomas Adam
d26a4ea463 Merge branch 'obsd-master' into master 2022-03-25 08:01:10 +00:00
nicm
422fcd294a Fix exit message if creating socket fails. 2022-03-25 06:14:42 +00:00
Thomas Adam
b638886716 Merge branch 'obsd-master' into master 2022-03-24 14:01:11 +00:00
nicm
938130bc69 Add unit (milliseconds) to escape-time, show unset colours as "none"
rather than "invalid" and don't show the same text twice for user
options in customize mode.
2022-03-24 12:07:25 +00:00
Thomas Adam
5e491e7947 Merge branch 'obsd-master' into master 2022-03-24 12:01:11 +00:00
nicm
792d13af49 Add a capability for OSC 7 and use it similarly to how the title is set
(and controlled by the same set-titles option). GitHub issue 3127.
2022-03-24 09:05:57 +00:00
Thomas Adam
964deae422 Merge branch 'obsd-master' into master 2022-03-17 16:01:11 +00:00
nicm
6a1706a62f Check scroll-on-clear for ED also. 2022-03-17 13:39:13 +00:00
nicm
10d689e735 Add an option (scroll-on-clear) to control if tmux scrolls into history
on clear, from Robert Lange in GitHub issue 3121.
2022-03-17 11:35:37 +00:00
Thomas Adam
5d4c3ef762 Merge branch 'obsd-master' into master 2022-03-16 20:01:10 +00:00
nicm
e6e737ac0b Add an option to set the character used for unused areas of the
terminal, GitHub issue 3110.
2022-03-16 17:00:17 +00:00
Thomas Adam
ee3f1d25d5 Merge branch 'obsd-master' into master 2022-03-09 00:01:12 +00:00
nicm
bfbe972225 With -f use percentages of window size not pane size, GitHub issue 2866. 2022-03-08 22:14:25 +00:00
nicm
cf217fa618 Fix user hooks (which are strings not arrays). 2022-03-08 21:58:37 +00:00
Thomas Adam
25337ac102 Merge branch 'obsd-master' into master 2022-03-08 20:01:11 +00:00
nicm
a3d920930b Add remain-on-exit-format to set text shown when pane is dead. 2022-03-08 18:31:46 +00:00
Thomas Adam
2fb6089e81 Merge branch 'obsd-master' into master 2022-03-08 14:01:11 +00:00
nicm
ad9b805983 Add argument to refresh-client -l to forward clipboard to a pane. GitHub
issue 3068.
2022-03-08 12:01:19 +00:00
Nicholas Marriott
04952f15df Use getpeerucred if available (not tested). 2022-03-08 11:35:06 +00:00
nicm
98cd8e4cad Add formats for client and server UID and user (for multiuser setups). 2022-03-08 11:28:40 +00:00
Nicholas Marriott
9ed1226a66 Need a declaration for getpeereid also. 2022-03-08 11:04:15 +00:00
Nicholas Marriott
afd9b68d10 Add getpeerid compat. 2022-03-08 11:02:17 +00:00
Nicholas Marriott
54d2249716 Remove unnecessary declarations. 2022-03-07 15:21:39 +00:00
Thomas Adam
7eff2fe780 Merge branch 'obsd-master' into master 2022-03-07 14:01:11 +00:00
nicm
a731b1a916 Pass client when adding menu item, GitHub issue 3103. 2022-03-07 11:52:09 +00:00
Thomas Adam
f84f1c0cfe Merge branch 'obsd-master' into master 2022-03-03 10:01:09 +00:00
nicm
7d4224f207 Allow optional arguments. 2022-03-03 08:24:12 +00:00
Thomas Adam
bf14bf6259 Merge branch 'obsd-master' into master 2022-03-01 18:01:10 +00:00
nicm
f39a71aaad Don't convert codes for special keys (Tab, Enter, Escape). 2022-03-01 15:20:22 +00:00
Anindya Mukherjee
cd9a81e242 Merge pull request #3093 from topcat001/pathfix
Use PATH_MAX instead of MAXPATHLEN.
2022-02-28 13:16:23 -08:00
topcat001
047c011a15 Use PATH_MAX instead of MAXPATHLEN. 2022-02-28 13:11:28 -08:00
Thomas Adam
649685ff6d Merge branch 'obsd-master' into master 2022-02-28 12:01:10 +00:00
Thomas Adam
2750195709 Merge branch 'obsd-master' into master 2022-02-28 10:01:11 +00:00
nicm
2da096d828 Exit on SIGHUP before attach also, GitHub issue 3084. 2022-02-28 09:34:57 +00:00
nicm
2e59ff2db9 Map control keys back to an ASCII uppercase letter when passing them on
as extended keys.
2022-02-28 09:24:22 +00:00
Thomas Adam
60688afe9c Merge branch 'obsd-master' into master 2022-02-22 20:01:11 +00:00
deraadt
e8d6d53a7b MAXCOMLEN is no longer needed in these programs, so remove the annotation
from sys/param.h include lines, or remove the include lines entirely if
it this was the least requirement.
ok millert
2022-02-22 17:35:01 +00:00
Thomas Adam
dc0746946e Merge branch 'obsd-master' into master 2022-02-22 16:01:11 +00:00
Thomas Adam
2be5488693 Merge branch 'obsd-master' into master 2022-02-22 14:01:10 +00:00
nicm
d54b18ca2b Do not attempt to update focus (and crash) when there is no previous window. 2022-02-22 13:31:18 +00:00
nicm
fa71e9a079 Add next_session_id format with the next session ID, GitHub issue 3078. 2022-02-22 11:10:41 +00:00
nicm
0fd01f8873 Initialize copy_width before adjusting it, GitHub issue 3079. 2022-02-22 11:07:25 +00:00
nicm
a9b880921d Use correct size for screen when popup is created without borders. 2022-02-22 11:01:57 +00:00
Thomas Adam
88d9a8fc05 Merge branch 'obsd-master' into master 2022-02-17 12:01:10 +00:00
nicm
818b2176ef Add a window-resized hook which is fired when the window is actually
resized which may be later than the client resize, GitHub issue 2995.
2022-02-17 09:58:47 +00:00
Thomas Adam
722f395e61 Merge branch 'obsd-master' into master 2022-02-16 22:01:11 +00:00
nicm
0027ee13a0 Support more mouse buttons when the terminal sends them, GitHub issue
3055.
2022-02-16 18:55:05 +00:00
Nicholas Marriott
c7c7e875a0 No not allow static linking on macOS. 2022-02-16 12:26:23 +00:00
Thomas Adam
85ef73591d Merge branch 'obsd-master' into master 2022-02-15 16:01:11 +00:00
nicm
5076beb009 Add an option (default off) to control the passthrough escape sequence.
Like set-clipboard and allow-rename it is safer to forbid this by
default.
2022-02-15 13:11:29 +00:00
nicm
f85208602d Do not create a buffer from an OSC 52 response if we have not sent a
query.
2022-02-15 13:03:02 +00:00
Thomas Adam
df681390a6 Merge branch 'obsd-master' into master 2022-02-14 10:01:11 +00:00
nicm
040164555a Do not return error with -q, GitHub issue 3065. 2022-02-14 09:10:48 +00:00
Thomas Adam
c67abcf818 Merge branch 'obsd-master' into master 2022-02-04 14:01:09 +00:00
nicm
07e2d88c20 Use ACS for pane border indicators so they work with different line
types, from Thomas Adam.
2022-02-04 11:57:22 +00:00
Thomas Adam
784d6a3929 Merge branch 'obsd-master' into master 2022-02-03 14:01:11 +00:00
Nicholas Marriott
53ee4f0334 Merge branch 'master' into 3.3-rc 2022-02-03 12:50:49 +00:00
Thomas Adam
c0598e2515 Merge branch 'obsd-master' into master 2022-02-03 12:01:10 +00:00
nicm
3276f0c184 Adjust size given to resize-pane for pane status line, GitHub issue
3050.
2022-02-03 11:06:11 +00:00
nicm
948d2fad0a Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.
2022-02-03 10:07:11 +00:00
Thomas Adam
1fdec20b0d Merge branch 'obsd-master' into master 2022-02-03 10:01:10 +00:00
Thomas Adam
375f6c90b0 Merge branch 'obsd-master' into master 2022-02-03 08:01:12 +00:00
Nicholas Marriott
b46abeb34d 3.3-rc. 2022-02-03 07:50:35 +00:00
Nicholas Marriott
57396b55a2 Update CHANGES. 2022-02-03 07:50:06 +00:00
nicm
c401c91ad9 Update focus when active pane changes after pane destroyed. 2022-02-03 07:38:17 +00:00
nicm
5080acc127 Add a key in copy mode to toggle position indicator. 2022-02-03 07:26:43 +00:00
Thomas Adam
a5cf7a9b39 Merge branch 'obsd-master' into master 2022-02-01 20:01:13 +00:00
nicm
97900d0442 A menu must be shown on a client, so always give the client when adding
the items. Also fix mode menus.
2022-02-01 18:12:20 +00:00
Thomas Adam
a4f336a91a Merge branch 'obsd-master' into master 2022-02-01 16:01:11 +00:00
nicm
7e34645fcb Add option to show arrows for active pane indicator, GitHub issue 3022
from Marcel Partap.
2022-02-01 14:46:41 +00:00
Thomas Adam
1b7afd5129 Merge branch 'obsd-master' into master 2022-02-01 14:01:11 +00:00
nicm
7a4ba6d4a5 Mention that if-shell and #() use /bin/sh. 2022-02-01 12:05:42 +00:00
nicm
770d28b8c5 Do not overflow width when not enough space. 2022-02-01 11:52:08 +00:00
Thomas Adam
6c0397f497 Merge branch 'obsd-master' into master 2022-01-17 12:01:10 +00:00
nicm
a6b361e775 Do not try to strdup NULL, from seL4 at disroot dot org in GitHub issue
3038.
2022-01-17 10:40:03 +00:00
Thomas Adam
28b6237c62 Merge branch 'obsd-master' into master 2022-01-06 10:01:12 +00:00
Nicholas Marriott
e5e4df7a22 Mention alternate config files, from Daniel Augusto in GitHub issue 3023. 2022-01-06 08:23:42 +00:00
nicm
b2b94dcba7 Ignore windows without a size set (may be used for pane only), from
Anindya Mukherjee.
2022-01-06 08:20:00 +00:00
Thomas Adam
080079c55a Merge branch 'obsd-master' into master 2021-12-31 14:01:10 +00:00
nicm
e6e3c75ed7 Try to turn on less-capable mouse modes when turning on more-capable, to
increase the chances we get something even if the terminal doesn't support
the one we really want. GitHub issue 3020.
2021-12-31 11:35:49 +00:00
Thomas Adam
47923bd5f6 Merge branch 'obsd-master' into master 2021-12-21 18:01:10 +00:00
nicm
9aad945f7e Support underscore style with capture-pane -e, GitHub issue 2928. 2021-12-21 14:57:28 +00:00
Thomas Adam
9c82ff1778 Merge branch 'obsd-master' into master 2021-12-21 14:01:09 +00:00
nicm
ff64aafeab ARM's Morello CHERI architecture does not support pointers in packed
structures, so remove the packed attribute on struct grid_line and
reorder the members to eliminate unnecessary padding. From Jessica
Clarke in GitHub issue 3012.
2021-12-21 13:07:53 +00:00
Thomas Adam
ba9b9367d5 Merge branch 'obsd-master' into master 2021-12-20 10:01:13 +00:00
nicm
e4856de8bf Do not crash on a zero size character. 2021-12-20 09:02:12 +00:00
Thomas Adam
70d330a353 Merge branch 'obsd-master' into master 2021-12-13 12:01:10 +00:00
nicm
c6149adf55 Make pane-border-format a pane option, GitHub issue 2999. 2021-12-13 09:42:20 +00:00
Thomas Adam
5c5712be5c Merge branch 'obsd-master' into master 2021-12-10 16:01:11 +00:00
Thomas Adam
8941dbe482 Merge branch 'obsd-master' into master 2021-12-10 14:01:10 +00:00
nicm
9c1633a865 Missed unlinked control notifications, GitHub issue 2996. 2021-12-10 12:51:11 +00:00
nicm
1f9aad2bb4 Mention XParseColor(3) for the cursor colour escape sequence. 2021-12-10 12:45:32 +00:00
nicm
db3aabcc34 Add a NOBLOCK flag rather than adding amount to wait for when
dealing with potentially-long sequences. GitHub issue 3001.
2021-12-10 12:42:37 +00:00
Thomas Adam
138ffc7cb6 Merge branch 'obsd-master' into master 2021-12-07 09:52:59 +00:00
nicm
d721fb2a9f Respond to OSC 4 query. 2021-12-07 07:28:44 +00:00
deraadt
7532a5cf95 sys/signal.h (or some master include) must happen before sys/proc.h, which
is not standalone.
This problem is being hidden by a sys/param.h which cannot be deleted yet.
2021-12-07 00:40:03 +00:00
deraadt
71c3234dc7 Use PATH_MAX (the standard name) rather than MAXPATHLEN (from BSD sys/param.h) 2021-12-07 00:38:42 +00:00
Nicholas Marriott
ef676e1202 Remove fallback for wcwidth failure, GitHub issue 3003. 2021-12-06 10:17:34 +00:00
nicm
ecac73f664 Fix g/G keys to be in line with copy mode. 2021-12-06 10:10:52 +00:00
nicm
8fccbbb026 Do not dereference NULL window when resizing client, GitHub issue 2982. 2021-12-06 10:08:42 +00:00
nicm
333cf6429a Bump response timer to three seconds, GitHub issue 2984. 2021-11-29 11:05:28 +00:00
nicm
add03dfb8d Fix user option lookup ordering. 2021-11-29 11:01:51 +00:00
nicm
b55f0ac6b9 Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.
2021-11-15 10:58:13 +00:00
nicm
cb8a0d83fb If automatic-rename is off, allow the escape sequence to set an empty
window name, GitHub issue 2964.
2021-11-11 09:31:16 +00:00
nicm
630c592ef8 If trimming menu item text, show key if it would take up less than a
quarter of the space; from Alexis Hildebrandt.

Also new sentence, new line in tmux.1, from jmc.
2021-11-11 09:22:33 +00:00
Nicholas Marriott
10b3cd17fa OS X -> macOS, from J Lewis Muir. 2021-11-11 09:18:04 +00:00
kn
8f1cc0e9fa Fix mandoc HTML rendering for command aliases
Replace hand-rolled parentheses with the proper mdoc(7) macro,
otherwise the closing ")" ends up inside the command description.

Reported by Josh Rickmar, thanks!
2021-11-04 13:15:13 +00:00
Thomas Adam
77fc7ac3be Merge branch 'obsd-master' into master 2021-11-03 16:01:14 +00:00
nicm
57100376cc Add a cursor-style option, from Alexis Hildebrandt in GitHub issue 2960. 2021-11-03 13:37:17 +00:00
Thomas Adam
1fc0d1b74f Merge branch 'obsd-master' into master 2021-11-02 14:01:11 +00:00
nicm
200b6536e1 fatalx on unknown enum members in a couple of places, from Ben Boeckel. 2021-11-02 10:57:04 +00:00
Thomas Adam
7d330c19e8 Merge branch 'obsd-master' into master 2021-11-01 12:01:12 +00:00
Thomas Adam
774903f6c4 Merge branch 'obsd-master' into master 2021-11-01 10:01:13 +00:00
nicm
8d2286b769 Add a cursor-colour option, from Alexis Hildebrandt in GitHub issue
2959.
2021-11-01 09:34:49 +00:00
nicm
4fe5aa99fb Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.
2021-11-01 07:48:04 +00:00
Nicholas Marriott
c76904343a Spelling, from someone in GitHub issue 2958. 2021-10-29 08:37:06 +01:00
Thomas Adam
60cacdffea Merge branch 'obsd-master' into master 2021-10-28 22:01:13 +01:00
nicm
4acad43013 Do not force the cursor to move if it is in the automargin space at EOL
and that is where we want it to be, GitHub issue 2956.
2021-10-28 18:57:06 +00:00
nicm
49d33a4282 Allow detach even if suspend flag set, GitHub issue 2932. 2021-10-28 18:54:33 +00:00
nicm
76f5d3364c Expand command as a format, GitHub issue 2920. 2021-10-28 18:39:15 +00:00
Thomas Adam
c77924bb56 Merge branch 'obsd-master' into master 2021-10-26 16:01:11 +01:00
nicm
9695114230 Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.
2021-10-26 12:29:41 +00:00
nicm
5745bd27fd Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.
2021-10-26 12:22:23 +00:00
Thomas Adam
6f46f71d58 Merge branch 'obsd-master' into master 2021-10-26 00:01:13 +01:00
nicm
197a116f5a Add a way to force a colour to RGB and a format to display it. 2021-10-25 21:21:16 +00:00
nicm
eb82ad5216 Missing Pp, from Alexis Hildebrandt. 2021-10-25 20:32:42 +00:00
Thomas Adam
3934d9b24d Merge branch 'obsd-master' into master 2021-10-25 12:01:11 +01:00
nicm
ef46eb91a5 Add -s and -S to display-popup to set popup and border style, from
Alexis Hildebrandt in GitHub issue 2931.
2021-10-25 09:38:36 +00:00
nicm
0cca695d6e Instead of setting the popup default colours in the draw callback, set
it up in popup_display and follow the same routine as panes in the draw
and init_ctx callbacks - use the palette if the option value is default.
Allows application-set fg and bg to work in panes again.
2021-10-25 09:22:17 +00:00
Thomas Adam
619d934d7b Merge branch 'obsd-master' into master 2021-10-25 00:01:11 +01:00
deraadt
9b4148b12c For open/openat, if the flags parameter does not contain O_CREAT, the
3rd (variadic) mode_t parameter is irrelevant.  Many developers in the past
have passed mode_t (0, 044, 0644, or such), which might lead future people
to copy this broken idiom, and perhaps even believe this parameter has some
meaning or implication or application. Delete them all.
This comes out of a conversation where tb@ noticed that a strange (but
intentional) pledge behaviour is to always knock-out high-bits from
mode_t on a number of system calls as a safety factor, and his bewilderment
that this appeared to be happening against valid modes (at least visually),
but no sorry, they are all irrelevant junk.  They could all be 0xdeafbeef.
ok millert
2021-10-24 21:24:17 +00:00
Thomas Adam
5071b82c77 Merge branch 'obsd-master' into master 2021-10-22 20:01:11 +01:00
nicm
8235957eaa Remove key and trim text if menu cannot fit in available space, based on
a change from Alexis Hildebrandt.
2021-10-22 17:12:50 +00:00
Thomas Adam
be2413292f Merge branch 'obsd-master' into master 2021-10-21 12:01:10 +01:00
nicm
289ac55ebd Correctly adjust the end pointer for a two character terminator before
decoding OSC 52 response, from Daniel Ekloef in GitHub issue 2942.
2021-10-21 08:36:51 +00:00
nicm
7bd9cdf6fc Show error if user option doesn't exist, GitHub issue 2938. 2021-10-21 08:23:48 +00:00
Thomas Adam
1bf2f811ea Merge branch 'obsd-master' into master 2021-10-20 14:01:15 +01:00
nicm
acba07629e Remove a TODO comment. 2021-10-20 09:52:27 +00:00
nicm
8a9bfd0cdd Add -T to set a popup title, from Alexis Hildebrandt in GitHub issue 2941. 2021-10-20 09:50:40 +00:00
Thomas Adam
65bb36d6bd Merge branch 'obsd-master' into master 2021-10-19 16:01:12 +01:00
nicm
f26b8c57ff Same as -N, don't send if 0 arguments and -R. 2021-10-19 12:51:43 +00:00
Thomas Adam
9e986d6a96 Merge branch 'obsd-master' into master 2021-10-18 12:01:12 +01:00
nicm
51ff77d47b Fix menu width containing disabled items, from Alexis Hildebrandt in
GitHub issue 2935.
2021-10-18 09:48:35 +00:00
nicm
2c188ee0c5 Spacing fixes from Alexis Hildebrandt. 2021-10-18 09:15:56 +00:00
nicm
cc27a43c40 Remove duplicate options, spotted by Ricky Cintron. 2021-10-18 09:09:46 +00:00
Thomas Adam
c57df2bb73 Merge branch 'obsd-master' into master 2021-10-15 14:01:13 +01:00
nicm
537302f2c1 Do not send any key if -N flag is given even if no other arguments,
fixes problem with repeat in copy mode reported by tb@.
2021-10-15 10:39:22 +00:00
Thomas Adam
264fe7fc2a Merge branch 'obsd-master' into master 2021-10-14 16:01:20 +01:00
nicm
add20637f2 Add popup-border-lines option to set popup line style, from Alexis
Hildebrandt, GitHub issue 2930.
2021-10-14 13:19:01 +00:00
Thomas Adam
ee9885a40c Merge branch 'obsd-master' into master 2021-10-14 12:01:12 +01:00
nicm
d0ab1a837a When checking ranges in tty_cmd_cells, cannot use the tty cursor
position and tty_cursor because it may be at the final invisible cursor
position on automargin terminals. The text to be drawn is confined to
the pane, so use the pane cursor position for the checks instead. Fix
from Anindya Mukherjee, redraw problem reported by naddy@.
2021-10-14 09:54:51 +00:00
Thomas Adam
fb23df679b Merge branch 'obsd-master' into master 2021-10-13 14:01:16 +01:00
nicm
837ca176d1 Add popup-style and popup-border-style options, from Alexis Hildebrandt
in GitHub issue 2927.
2021-10-13 09:28:36 +00:00
Thomas Adam
aff2a473ec Merge branch 'obsd-master' into master 2021-10-11 16:01:13 +01:00
nicm
b8581ec80e Make positions hidden by overlays range-based rather than character-based,
from Anindya Mukherjee.
2021-10-11 13:27:50 +00:00
Thomas Adam
af82106fae Merge branch 'obsd-master' into master 2021-10-11 14:01:13 +01:00
nicm
759efe1b33 Add -e flag to set environment for popup, from Alexis Hildebrandt in
GitHub issue 2924.
2021-10-11 10:55:30 +00:00
Thomas Adam
7ca863c5af Merge branch 'obsd-master' into master 2021-10-08 18:01:11 +01:00
jmc
7800a431ea remove extra .El; 2021-10-08 14:14:31 +00:00
Thomas Adam
bf0f694f91 Merge branch 'obsd-master' into master 2021-10-08 10:01:12 +01:00
kn
50a77f4417 Add tags for command aliases
Make ":tnew" work, i.e. bring the reader to the definition of the full
"new-window" command aliased as "new" just like ":tnew-window" would.

OK nicm
2021-10-08 06:37:39 +00:00
Thomas Adam
fed7b29c7e Merge branch 'obsd-master' into master 2021-10-07 10:01:10 +01:00
nicm
5f63181ed5 Add a missing El, from Alexis Hildebrandt in GitHub issue 2918. 2021-10-07 07:53:31 +00:00
nicm
9574496333 Handle splitw -I correctly when used from an attached client, GitHub
issue 2917.
2021-10-07 07:52:13 +00:00
Thomas Adam
5374417428 Merge branch 'obsd-master' into master 2021-10-06 12:01:10 +01:00
nicm
5359b76619 Do not reset cursor to default if it has never been changed, fixes
problem reported by naddy.
2021-10-06 10:33:12 +00:00
Thomas Adam
c8802c776a Merge branch 'obsd-master' into master 2021-10-06 00:01:12 +01:00
nicm
da05d05824 Fix some warnings. 2021-10-05 20:15:16 +00:00
Thomas Adam
d8996a1c1d Merge branch 'obsd-master' into master 2021-10-05 20:01:11 +01:00
nicm
e06a4e041c Set mouse_x and mouse_y on the status line, GitHub issue 2913. 2021-10-05 17:23:13 +00:00
Thomas Adam
479c9563c7 Merge branch 'obsd-master' into master 2021-10-05 16:01:13 +01:00
nicm
9f6164a05c Make send-keys without any arguments send the key it is bound to (if
any). GitHub issue 2904.
2021-10-05 12:49:37 +00:00
nicm
9b1fdb291e Separate "very visible" flag from blinking flag, it should not affect
DECSCUSR. GitHub issue 2891.
2021-10-05 12:46:02 +00:00
nicm
3d5a02bf45 Do not try to use NULL time values. 2021-10-05 12:45:02 +00:00
Thomas Adam
bf595a0cb0 Merge branch 'obsd-master' into master 2021-09-27 22:01:10 +01:00
nicm
68c8905859 Do not call recalculate_sizes while clearing a client session because it
needs to loop over the clients, instead do it after all clients are
cleared. Fixes a crash reported by martijn@ when a session with multiple
clients attached is destroyed, but there are other sessions so tmux does
not entirely exit. ok deraadt
2021-09-27 19:12:00 +00:00
Thomas Adam
03f9963f3d Merge branch 'obsd-master' into master 2021-09-22 18:01:10 +01:00
nicm
257e9ba69a Fix command prompt with multiple prompts (add the result onto the list
again as we go along). ok deraadt
2021-09-22 15:21:44 +00:00
Nicholas Marriott
9c77a5b9f0 Remove duplicate. 2021-09-21 10:03:38 +01:00
Nicholas Marriott
b2482535d0 Crosscompiling defaults from Romain Francoise. 2021-09-21 09:54:50 +01:00
Nicholas Marriott
097a792f9d Update obsolete autoconf macros, from "kylo252" GitHub issue 2900. 2021-09-21 09:53:44 +01:00
Thomas Adam
25df71b90d Merge branch 'obsd-master' into master 2021-09-17 10:01:10 +01:00
nicm
c4b969ca62 Do not destroy sessions twice, GitHub issue 2889. 2021-09-17 07:20:49 +00:00
Thomas Adam
409e121cac Merge branch 'obsd-master' into master 2021-09-16 10:01:11 +01:00
nicm
3c3d371f99 Fix run-shell -d with no command, GitHub issue 2885. 2021-09-16 06:39:22 +00:00
Nicholas Marriott
8554b80b8b Merge tag '3.3-rc'
3.3-rc
2021-09-15 14:08:15 +01:00
Nicholas Marriott
3be44313aa Next is 3.4. 2021-09-15 14:07:42 +01:00
Nicholas Marriott
ed280e14c8 Missing header. 2021-09-15 14:03:19 +01:00
Nicholas Marriott
86d505af46 3.3-rc. 2021-09-15 13:42:50 +01:00
Nicholas Marriott
7186ab25c9 Those were already there... 2021-09-15 13:40:51 +01:00
Nicholas Marriott
a049ebd6f7 And more CHANGES. 2021-09-15 13:37:39 +01:00
Nicholas Marriott
adb620c4e4 Update CHANGES. 2021-09-15 13:35:08 +01:00
Thomas Adam
2b9830f0e7 Merge branch 'obsd-master' into master 2021-09-15 10:01:10 +01:00
nicm
a19cac5c46 For the moment, restore if-shell and run-shell to parsing at the last
moment (when the shell command completes) rather than when first
invoked, GitHub issue 2872.
2021-09-15 07:38:30 +00:00
Nicholas Marriott
ddcf5b801a Mention FAQ, from Illia Bobyr. 2021-09-13 07:57:37 +01:00
Thomas Adam
b28fffc0f7 Merge branch 'obsd-master' into master 2021-09-10 18:01:11 +01:00
nicm
e6b40cb339 Do fatal/fatalx a different way so the compiler trick to avoid warnings
becomes unnecessary, prompted by theo.
2021-09-10 15:03:18 +00:00
nicm
33ac7a346e Get rid of the last two warnings by turning them off around the problem
statements, if the compiler supports it.
2021-09-10 14:22:24 +00:00
Nicholas Marriott
3b10392bfc Icons, from someone on GitHub in issue 2870. 2021-09-10 15:00:58 +01:00
Thomas Adam
3358c9a8f1 Merge branch 'obsd-master' into master 2021-09-10 12:01:10 +01:00
nicm
5cdc1bdd32 Disable aliases inside aliases for the moment. 2021-09-10 08:52:46 +00:00
Thomas Adam
31a6e5eff4 Merge branch 'obsd-master' into master 2021-09-10 02:01:12 +01:00
nicm
768fb9080f Keep -? as usage. 2021-09-09 21:55:03 +00:00
Thomas Adam
42b0be4cfd Merge branch 'obsd-master' into master 2021-09-09 22:01:11 +01:00
nicm
a0b39dba31 Turn on both button and all mouse modes for menus since some terminals
only support the former.
2021-09-09 19:37:17 +00:00
Thomas Adam
732288c489 Merge branch 'obsd-master' into master 2021-09-09 16:01:09 +01:00
nicm
34312fd6ee Expand argument to run-shell again. 2021-09-09 13:38:32 +00:00
Thomas Adam
cf5e1bb80a Merge branch 'obsd-master' into master 2021-09-09 10:01:10 +01:00
nicm
5a4b2fd68c Fix parsing of aliases again (GitHub issue 2842), also make argument
parsing a bit simpler and fix the names of some client flags.
2021-09-09 06:57:48 +00:00
Thomas Adam
d776c9acfc Merge branch 'obsd-master' into master 2021-09-02 10:01:09 +01:00
nicm
329c2c2a91 Change copying arguments to that flags without arguments are inserted
correctly and empty arguments lists do not crash. Fixes crash reported
by & ok mpi@.
2021-09-02 07:11:03 +00:00
Nicholas Marriott
d62aee506b Regress conf from https://raw.githubusercontent.com/lacygoill/config/master/.config/tmux/tmux.conf. 2021-08-30 08:24:43 +01:00
Nicholas Marriott
388f0fe973 Update CHANGES. 2021-08-30 08:17:38 +01:00
Thomas Adam
609baea95e Merge branch 'obsd-master' into master 2021-08-27 20:01:11 +01:00
nicm
daec63e5e6 Replace %% in command lists (by copying them) for template arguments ,
this means they can be used with {} as well. Also make argument
processing from an existing vector preserve commands. GitHub issue 2858.
2021-08-27 17:25:55 +00:00
nicm
fd756a150b Allow control mode clients to set a hard limit on the window width and
height, GitHub issue 2594.
2021-08-27 17:15:57 +00:00
Thomas Adam
c6375a0d40 Merge branch 'obsd-master' into master 2021-08-25 12:01:11 +01:00
nicm
24636be42b Improve some logging. 2021-08-25 10:18:01 +00:00
nicm
f4f8d3b5ed Ignore client creating session when working out size if it is a control
client.
2021-08-25 10:15:15 +00:00
Nicholas Marriott
6616b42b2c Fix test. 2021-08-25 10:24:33 +01:00
nicm
a3c6057b51 bind-key needs to allow commands for any argument for the moment. 2021-08-25 09:18:08 +00:00
Thomas Adam
c7266ca78d Merge branch 'obsd-master' into master 2021-08-25 10:01:10 +01:00
nicm
03d173cbd8 Validate command argument types (string or command list) and give more
useful error messages.
2021-08-25 08:51:55 +00:00
nicm
c6d6af4903 setupterm needs char * not const char * on some platforms. 2021-08-25 07:37:20 +00:00
Nicholas Marriott
6ac09aa47c Disable a couple of warnings on macOS. 2021-08-25 08:36:51 +01:00
nicm
a252fadf8a Fix up some printflike attributes. 2021-08-25 07:09:30 +00:00
nicm
78da5a3756 Start inputs as NULL so not freeing random stack garbage, GitHub issue 2852. 2021-08-25 06:36:05 +00:00
Thomas Adam
7fe3588e49 Merge branch 'obsd-master' into master 2021-08-23 20:01:09 +01:00
nicm
841ce74b43 args_make_commands_now needs to take an extra reference to the returned
command list since it will be freed already.
2021-08-23 17:05:43 +00:00
Thomas Adam
95a374d7d2 Merge branch 'obsd-master' into master 2021-08-23 16:06:46 +01:00
nicm
210e71edf3 Move command argument parsing common functions and don't bother to parse
again if given a command rather than a string.
2021-08-23 12:33:55 +00:00
nicm
03b83a5a34 Key bindings steal a reference to the command instead of adding their
own, it was correct not to add a reference when parsing, but the
bind-key then needs to add one.
2021-08-23 11:48:21 +00:00
nicm
1f0c0914c7 Revert one of previous, for some reason it is being freed. 2021-08-23 11:08:26 +00:00
nicm
4a753dbefc Fix a few memory leaks. 2021-08-23 11:04:21 +00:00
nicm
3ed37a2079 Limit width and height to tty correctly, GitHub issue 2843. 2021-08-23 08:17:41 +00:00
Thomas Adam
1dec1ca146 Merge branch 'obsd-master' into master 2021-08-22 18:01:18 +01:00
Nicholas Marriott
bc71e233d9 Fix style regress test. 2021-08-22 16:33:57 +01:00
nicm
2e9bafaf14 Fix handling of leading #s when working out width. 2021-08-22 15:33:14 +00:00
Thomas Adam
03054598df Merge branch 'obsd-master' into master 2021-08-22 16:01:19 +01:00
nicm
72d905f32c Do not double free expanded path in source-file, also remove some
unnecessary assignments.
2021-08-22 13:48:29 +00:00
nicm
c0048d6d20 Insert alias in the right place, GitHub issue 2842. 2021-08-22 13:00:28 +00:00
Thomas Adam
324f87cf14 Merge branch 'obsd-master' into master 2021-08-22 12:08:05 +01:00
nicm
0084cbef5a Free value properly. 2021-08-21 20:57:52 +00:00
nicm
069f5925af Preserve argument type in command and convert to string on demand. 2021-08-21 20:46:43 +00:00
Thomas Adam
921991c98d Merge branch 'obsd-master' into master 2021-08-21 20:01:22 +01:00
nicm
326d2ef234 Pass typed arguments out of the parser into the arguments list and let
it convert them into strings.
2021-08-21 18:39:07 +00:00
nicm
63b6eec278 Use new syntax for default key bindings. 2021-08-21 17:41:19 +00:00
nicm
5241dae87d Stop caring about empty commands, just treat as a null command. 2021-08-21 17:25:32 +00:00
Thomas Adam
4d3367e965 Merge branch 'obsd-master' into master 2021-08-21 16:01:26 +01:00
nicm
68cacaec68 Remove some members of struct cmd which are no longer used. 2021-08-21 14:10:08 +00:00
nicm
c286fbdcd7 Preserve command group when moving temporary list to current list being
buit.
2021-08-21 14:06:17 +00:00
Thomas Adam
62036121fa Merge branch 'obsd-master' into master 2021-08-21 12:01:41 +01:00
nicm
110ba767e5 Rename a member to match what it will be in future. 2021-08-21 10:28:05 +00:00
nicm
08e6360f23 Add args parsing callback for some future work, currently unused. 2021-08-21 10:22:38 +00:00
nicm
d371764d02 Wrap command argument definitions in their own struct. 2021-08-21 08:44:59 +00:00
Thomas Adam
b0da0cee4d Merge branch 'obsd-master' into master 2021-08-20 22:01:46 +01:00
nicm
d589be6c65 A couple more spacing fixes. 2021-08-20 20:08:30 +00:00
nicm
caa8703a23 Spacing tweaks. 2021-08-20 20:04:22 +00:00
nicm
5f32b7d961 Hide struct args behind a couple of accessor functions. 2021-08-20 19:50:16 +00:00
nicm
de94a344f6 Add a couple of const and fix some warnings. 2021-08-20 19:34:51 +00:00
nicm
c76b28de24 Remove some unnecessary blank lines. 2021-08-20 19:08:36 +00:00
Thomas Adam
944fde7c57 Merge branch 'obsd-master' into master 2021-08-20 20:01:27 +01:00
nicm
90dd474c3e Expose args_value struct (will be needed soon) and add some missing frees. 2021-08-20 18:59:53 +00:00
nicm
6cbc83c6a6 Add a way to create an empty arguments set. 2021-08-20 17:53:54 +00:00
nicm
e463e8622d Remove stray spaces after function names. 2021-08-20 17:50:42 +00:00
nicm
01b13de655 Fill colour palette correctly from option for new panes, GitHub issue
2831.
2021-08-20 17:36:03 +00:00
Nicholas Marriott
41822ef782 Regress fixes. 2021-08-20 18:20:49 +01:00
Nicholas Marriott
5ed5b11b45 Add zeraphel complex binding to regress. 2021-08-20 14:34:44 +01:00
Thomas Adam
84955e3d62 Merge branch 'obsd-master' into master 2021-08-20 12:01:15 +01:00
nicm
f984446d19 Actually parse contents of {} as a command and then convert to a string
instead of just copying arguments around as strings.
2021-08-20 09:06:26 +00:00
Thomas Adam
0f02fecd95 Merge branch 'obsd-master' into master 2021-08-20 10:01:21 +01:00
Nicholas Marriott
28d26fca35 Update a regress conf for new syntax. 2021-08-20 07:58:44 +01:00
Nicholas Marriott
3676779156 Fix format test for new behaviour. 2021-08-20 07:58:44 +01:00
nicm
3177d7b617 Add a helper function for actually parsing the command. 2021-08-20 06:30:57 +00:00
Thomas Adam
551bafc18d Merge branch 'obsd-master' into master 2021-08-18 20:01:17 +01:00
nicm
5413a73ded Need to flatten arguments for aliases. 2021-08-18 15:16:33 +00:00
Thomas Adam
c587ad027f Merge branch 'obsd-master' into master 2021-08-18 12:01:19 +01:00
nicm
82836c7394 Push the conversion of {} to string up out of the parser and into the
command builder.
2021-08-18 10:15:08 +00:00
Thomas Adam
a8be47f0f4 Merge branch 'obsd-master' into master 2021-08-17 22:01:18 +01:00
nicm
5fdea440ce Treat a pane that has died the same as no pane when sending data to
control mode clients, GitHub issue 2828.
2021-08-17 20:17:21 +00:00
nicm
66aaa9e484 Fix pipe-pane usage. 2021-08-17 19:37:55 +00:00
nicm
2b0d798982 Do not block with incremental command prompt. 2021-08-17 19:26:42 +00:00
Thomas Adam
bacae4b4ad Merge branch 'obsd-master' into master 2021-08-17 18:01:16 +01:00
nicm
4f62aadc93 Set the right session if detach-on-destroy is off. 2021-08-17 16:19:00 +00:00
Thomas Adam
7869ec87e0 Merge branch 'obsd-master' into master 2021-08-17 14:01:16 +01:00
nicm
de9697b456 calloc for confirm-before data since the item needs to start NULL. 2021-08-17 11:20:13 +00:00
Thomas Adam
0dad8dd982 Merge branch 'obsd-master' into master 2021-08-17 10:01:19 +01:00
nicm
41ababdf6c Be more sophisticated about enabling synchronized updates when there is
an overlay and treat it like the active pane (use for commands which
move the cursor only). When there is an overlay also use it for all
panes and not just the active pane. GitHub issue 2826.
2021-08-17 08:44:52 +00:00
nicm
1a7eb6ca90 Revert previous; this is not how it should work. 2021-08-17 08:22:44 +00:00
nicm
158f0e8c41 Start sync before drawing popup. 2021-08-17 07:14:33 +00:00
Nicholas Marriott
f2d4a1f022 Needs fcntl.h. 2021-08-16 13:51:55 +01:00
Nicholas Marriott
21ce1e04fe Fuzzer needs some other bits it seems. 2021-08-14 22:30:20 +01:00
Nicholas Marriott
c1be1b351d Minor cleanups, GitHub issue 2824. 2021-08-14 18:39:56 +01:00
Thomas Adam
22e5fc02c3 Merge branch 'obsd-master' into master 2021-08-14 18:01:17 +01:00
nicm
30786abe0e Some other missing palette NULL checks, from oss-fuzz. 2021-08-14 16:26:29 +00:00
Thomas Adam
3f8954b11b Merge branch 'obsd-master' into master 2021-08-14 16:01:17 +01:00
nicm
befe7cb1c5 Do not use NULL palette when clearing. 2021-08-14 14:00:07 +00:00
Thomas Adam
65a539c02e Merge branch 'obsd-master' into master 2021-08-14 10:01:18 +01:00
nicm
4cc6db7281 Missing argument specifier for -c. 2021-08-14 08:06:37 +00:00
Thomas Adam
79f075bf1b Merge branch 'obsd-master' into master 2021-08-14 01:35:27 +01:00
Thomas Adam
54773d23b5 Merge branch 'obsd-master' into master 2021-08-14 01:34:54 +01:00
nicm
7d7d7c9605 Tweak how mouse works on popup: only Meta alone resizes or moves, not
Meta with other modifiers; button 2 on the left or top border opens
menu, right or bottom resizes; button 1 on any border moves.
2021-08-13 23:05:40 +00:00
nicm
63aa968642 Check callback needs to only return 0 (text should be suppressed) if
menu returns 0, otherwise it should check the popup also.
2021-08-13 20:04:45 +00:00
nicm
7a0cec5ecf Fill in some other bits on new panes. 2021-08-13 19:55:11 +00:00
nicm
2588c3e52e Add menu options to convert a popup into a pane. 2021-08-13 19:27:25 +00:00
nicm
92615b534a Adjust overlay check callback before drawing data from pty. 2021-08-13 19:25:24 +00:00
nicm
7789639b5d Add a menu when a popup is present (mouse only for now). 2021-08-13 18:54:54 +00:00
nicm
614611a8bd Add -B flag to remove border from popup. 2021-08-13 17:03:29 +00:00
Nicholas Marriott
4c07367bfe Fix fuzzer wrapper. 2021-08-13 13:45:45 +01:00
nicm
13a0da205b Break message type stuff out into its own header. 2021-08-13 07:37:58 +00:00
nicm
2bb0b9d6c5 Change focus to be driven by events rather than walking all panes at end
of event loop, this way the ordering of in and out can be enforced.
GitHub issue 2808.
2021-08-13 06:52:51 +00:00
nicm
a2b8506917 Set return code for confirm-before and make command-prompt also block,
GitHub issue 2822.
2021-08-13 06:50:42 +00:00
Thomas Adam
f725f9bc8a Merge branch 'obsd-master' into master 2021-08-13 00:01:19 +01:00
Thomas Adam
94d96c6179 Merge branch 'obsd-master' into master 2021-08-12 22:01:22 +01:00
nicm
e2f6f58fe5 Make newline a style delimiter as well so they can cross multiple lines
for readability.
2021-08-12 20:46:30 +00:00
nicm
db9195463d Now that styles can contain formats, they need to be expanded when
inserted into the status line.
2021-08-12 20:44:49 +00:00
nicm
6feb8f6505 Use COLOUR_DEFAULT not hardcoded 8. 2021-08-12 20:09:34 +00:00
nicm
9b00472820 Evaluate styles with the pane variables. 2021-08-12 19:47:05 +00:00
Thomas Adam
9d7b1960c2 Merge branch 'obsd-master' into master 2021-08-12 14:01:18 +01:00
nicm
5d451551b6 Restore saved cursor position after a ZWJ rather than recalculating it. 2021-08-12 11:35:53 +00:00
Thomas Adam
fada3eb932 Merge branch 'obsd-master' into master 2021-08-12 10:01:22 +01:00
nicm
26773ea9ef Do not dereference pane when it is NULL, fixes a crash when creating a
hook from the config, GitHub issue 2820.
2021-08-12 08:10:20 +00:00
nicm
163908fe8a Move hook format setup earlier and add a hook_client, GitHub issue 2809. 2021-08-12 08:05:11 +00:00
Thomas Adam
44ada9cd67 Merge branch 'obsd-master' into master 2021-08-12 00:01:26 +01:00
nicm
7eea3d7ab8 Break the colour palette into a struct rather than just a single array
and use that to support the OSC palette-setting sequences in popups.
Also add a pane-colours array option to specify the defaults. GitHub
issue 2815.
2021-08-11 20:49:55 +00:00
nicm
01fd4b997e Add pipe variants of the line copy commands. While here make the command
list less unreadable. GitHub issue 2813.
2021-08-11 20:35:46 +00:00
Thomas Adam
e9d49161e0 Merge branch 'obsd-master' into master 2021-08-11 12:01:20 +01:00
nicm
9013600074 Return to applying pane-border-style to the area outside panes, GitHub
issue 2816.
2021-08-11 09:05:21 +00:00
Thomas Adam
7a06b92061 Merge branch 'obsd-master' into master 2021-08-11 10:01:20 +01:00
nicm
338ec859a4 Make confirm-before optionally block the invoking client like run-shell,
GitHub issue 2819.
2021-08-11 08:40:58 +00:00
nicm
f6755c6f2c OSC 52 can be long enough to make tmux think the output buffer is too
big, so treat it as a redraw. GitHub issue 2814.
2021-08-11 07:51:31 +00:00
Nicholas Marriott
705411ea5c Tweak comment about logs. 2021-08-10 08:14:14 +01:00
Thomas Adam
9d80ec6cc9 Merge branch 'obsd-master' into master 2021-08-09 16:01:35 +01:00
nicm
be5988457f Change copy-line and copy-end-of-line not to cancel and add -and-cancel
variants, like the other copy commands. GitHub issue 2799.
2021-08-09 13:08:08 +00:00
Thomas Adam
33e332428c Merge branch 'obsd-master' into master 2021-08-06 12:01:24 +01:00
nicm
24cd6851f6 Add basic support for zero width joiners, GitHub issues 1605 and 2784. 2021-08-06 09:34:09 +00:00
nicm
19812b2d29 Add client focus hooks. 2021-08-06 09:19:02 +00:00
Thomas Adam
4bccff9556 Merge branch 'obsd-master' into master 2021-08-06 10:01:17 +01:00
nicm
ef5602a590 Another minor fix - do not draw positions that are under the popup with
spaces, from Anindya Mukherjee. Also a typo fix from Linus Arver.
2021-08-06 07:32:21 +00:00
Thomas Adam
acd70ea643 Merge branch 'obsd-master' into master 2021-08-06 06:01:18 +01:00
nicm
950d3c5bbc Tweak previous not to replace complete characters with spaces. 2021-08-06 03:29:15 +00:00
nicm
97b5962ab1 Correctly draw wide characters that are partially obscured. 2021-08-06 03:13:05 +00:00
Thomas Adam
e3fa6cd96c Merge branch 'obsd-master' into master 2021-08-05 12:01:19 +01:00
nicm
93cc8df692 Do not freeze output in panes when a popup is open, let them continue to
redraw. From Anindya Mukherjee .
2021-08-05 09:43:51 +00:00
Thomas Adam
4b88872c85 Merge branch 'obsd-master' into master 2021-08-04 10:01:25 +01:00
Nicholas Marriott
c063831df5 Do not configure on macOS without the user making a choice about utf8proc. 2021-08-04 09:49:08 +01:00
nicm
42490f4750 Add a client-active hook, from ncfavier in GitHub issue 2803. 2021-08-04 08:07:19 +00:00
Thomas Adam
63f9f3113c Merge branch 'obsd-master' into master 2021-07-28 10:01:19 +01:00
nicm
e37aa45681 Make window-linked and window-unlinked window options, GitHub issue
2790.
2021-07-28 07:06:54 +00:00
Thomas Adam
7cbf4c9027 Merge branch 'obsd-master' into master 2021-07-21 10:01:24 +01:00
nicm
78ec057916 Do not add height twice when calculating popup_mouse_top, from M Kelly. 2021-07-21 08:09:43 +00:00
nicm
f0e02387b2 Do not close popups on resize, instead adjust them to fit, from Anindya
Mukherjee.
2021-07-21 08:06:36 +00:00
Thomas Adam
e3ff887d2a Merge branch 'obsd-master' into master 2021-07-14 12:01:21 +01:00
Nicholas Marriott
0ea6cdca90 Need all of the TAILQ bits. 2021-07-14 11:09:28 +01:00
Nicholas Marriott
d723466df2 Pick default-terminal from the first of tmux-256color, tmux, screen-256color,
screen that is available on the build system.
2021-07-14 11:03:19 +01:00
nicm
732c72c98e Move default value for TERM into tmux.h. 2021-07-14 08:56:00 +00:00
Thomas Adam
bb4bc8caf4 Merge branch 'obsd-master' into master 2021-07-14 00:01:21 +01:00
nicm
38c5788232 Give #() commands a one second grace period where the output is empty
before telling the user they aren't doing anything. GitHub issue 2774.
2021-07-13 22:09:29 +00:00
Thomas Adam
7496e70bd7 Merge branch 'obsd-master' into master 2021-07-13 12:01:19 +01:00
nicm
df3fe2aa72 Only use client for sizing when not detached, GitHub issue 2772. 2021-07-13 10:38:57 +00:00
Thomas Adam
c1d5dda62e Merge branch 'obsd-master' into master 2021-07-08 14:01:21 +01:00
nicm
51915b9b0a Fix mouse_word format now word-separators has no space and position of
menu if too close to the bottom.
2021-07-08 11:14:53 +00:00
Thomas Adam
ed575182e3 Merge branch 'obsd-master' into master 2021-07-06 10:01:22 +01:00
nicm
32f2d9d089 Improve error reporting when the tmux /tmp directory cannot be created
or used, GitHub issue 2765 from Uwe Kleine-Koenig.
2021-07-06 08:26:00 +00:00
nicm
35c2958ae4 Forbid empty session names, GitHub issue 2758. 2021-07-06 08:18:38 +00:00
Nicholas Marriott
b1a8c0fe02 Fix crosscompiling, Marco A L Barbosa. 2021-06-22 12:16:48 +01:00
Thomas Adam
3dfb77416f Merge branch 'obsd-master' into master 2021-06-18 09:52:47 +01:00
nicm
1d4296f17f Mention %1 under choose-tree also. 2021-06-18 07:46:54 +00:00
nicm
a83fb8127a Minor fixes to option descriptions. 2021-06-16 11:57:04 +00:00
nicm
9f3874e5c7 Pass Ctrl keys through as is when given as hex, GitHub issue 2724. 2021-06-16 08:37:58 +00:00
Nicholas Marriott
87521214d3 Fix incorrect option name, from Gregory Pakosz. 2021-06-15 09:44:56 +01:00
Nicholas Marriott
6a8d848a3e Once a day. 2021-06-11 08:30:51 +01:00
jmc
0d0683c28a fix some formatting errors; 2021-06-10 13:12:31 +00:00
Nicholas Marriott
96ad8280b2 Tweak. 2021-06-10 13:05:22 +01:00
Nicholas Marriott
0490707671 Move lock.yml. 2021-06-10 09:56:35 +01:00
Nicholas Marriott
ac98385e55 Merge branch '3.2a' 2021-06-10 09:26:38 +01:00
Nicholas Marriott
57aaad2ddb Update CHANGES. 2021-06-10 09:25:50 +01:00
Nicholas Marriott
d25738b61e Update CHANGES. 2021-06-10 09:16:14 +01:00
nicm
a35c897f0f Do not clear region based on current cursor position, this is not
necessary anymore and causes problems, GitHub issue 2735.
2021-06-10 07:59:31 +00:00
nicm
1e879ef458 Feature for the mouse since FreeBSD termcap does not have kmous. 2021-06-10 07:59:08 +00:00
nicm
43514f4af6 Fix rectangle selection, from Anindya Mukherjee, GitHub issue 2709. 2021-06-10 07:58:42 +00:00
nicm
8d75542986 Bump FORMAT_LOOOP_LIMIT and add a log message when hit, GitHub issue 2715. 2021-06-10 07:58:08 +00:00
nicm
3a5b576399 Fix <= operator. 2021-06-10 07:57:06 +00:00
nicm
77b1290698 More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.
2021-06-10 07:56:47 +00:00
nicm
77bd6b9ec3 Do not use NULL client when source-file finishes, GitHub issue 2707. 2021-06-10 07:53:19 +00:00
nicm
1bbdd2aba2 Add -F for command-prompt and use it to fix "Rename" on the window menu,
GitHub issue 2699.
2021-06-10 07:52:56 +00:00
nicm
73bf358f6d Do not expand the file given with -f so it can contain :s. 2021-06-10 07:52:29 +00:00
nicm
f706a7e236 Remove old shift function keys which interfere with xterm keys now.
GitHub issue 2696.
2021-06-10 07:52:07 +00:00
nicm
cfc7c9cf24 Fire check callback after cleaning up event so it does not get stuck,
from Jeongho Jang in GitHub issue 2695.
2021-06-10 07:51:43 +00:00
nicm
866117636e Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.
2021-06-10 07:50:03 +00:00
nicm
6c659494f5 Fix warnings, from Jan Tache in GitHub issue 2692. 2021-06-10 07:45:43 +00:00
nicm
02a6b39db7 Improve logging of screen mode changes. 2021-06-10 07:43:44 +00:00
nicm
f02a6c34e0 Move "special" keys into the Unicode PUA rather than making them top bit
set, some compilers do not allow enums that are larger than int. GitHub
issue 2673.
2021-06-10 07:38:28 +00:00
nicm
f9f97c8145 Change cursor style handling so tmux understands which sequences contain
blinking and sets the flag appropriately, means that it works whether
cnorm disables blinking or not. GitHub issue 2682.
2021-06-10 07:36:47 +00:00
nicm
84e22168a5 Change resize timers and flags into one timer and a queue which is
simpler and fixes problems with vim when resized multiple times. GitHub
issue 2677.
2021-06-10 07:33:41 +00:00
nicm
b573dbba90 Do not count client (and crash) if no window. 2021-06-10 07:29:45 +00:00
nicm
0c5cbbbf5c Three changes to fix problems with xterm in VT340 mode, reported by
Thomas Sattler.

1) Do not include the DECSLRM or DECFRA features for xterm; they will be
   added instead if secondary DA responds as VT420 (this happens
   already).

2) Set or reset the individual flags after terminal-overrides is
   applied, so the user can properly disable them.

3) Add a capability for DECFRA ("Rect").
2021-06-10 07:28:45 +00:00
nicm
9f38a8807c Include current client in size calculation for new sessions, GitHub
issue 2662.
2021-06-10 07:24:45 +00:00
nicm
64c276c23b Add an "always" value to the extended-keys option to always forward
these keys to applications inside tmux.
2021-06-10 07:24:10 +00:00
nicm
1ee231956c back-to-indentation fixes, from Anindya Mukherjee. 2021-06-10 07:22:37 +00:00
nicm
788f56b40a Fix display-menu -xR, from Alexis Hildebrandt. 2021-06-10 07:22:06 +00:00
nicm
c46a607dc1 Adjust latest client when a client detaches, GitHub issue 2657. 2021-06-10 07:21:46 +00:00
nicm
e5106bfb96 Add another couple of keys needed for extended keys, GitHub issue 2658.
Handle modifier 9 as Meta, GitHub issue 2647.
2021-06-10 07:21:09 +00:00
Nicholas Marriott
747423be67 Fix empty format strings, from Jean-Philippe Menil. 2021-06-10 08:08:31 +01:00
Nicholas Marriott
607e6b1c33 Do not clear region based on current cursor position, this is not necessary
anymore and causes problems, GitHub issue 2735.
2021-06-09 14:46:24 +01:00
Nicholas Marriott
7a236869ba Feature for the mouse since FreeBSD termcap does not have kmous. 2021-06-08 10:49:40 +01:00
Nicholas Marriott
9ea971dc04 Fix rectangle selection, from Anindya Mukherjee, GitHub issue 2709. 2021-05-19 09:05:53 +01:00
Nicholas Marriott
5f7ff732fa Bump FORMAT_LOOOP_LIMIT and add a log message when hit, GitHub issue 2715. 2021-05-19 09:04:45 +01:00
Nicholas Marriott
83024f57a6 Er, fix it properly. 2021-05-17 06:59:29 +01:00
Nicholas Marriott
01ba6a23f2 Fix <= operator. 2021-05-17 06:58:45 +01:00
Nicholas Marriott
022d0210c5 More accurate vi(1) word navigation in copy mode and on the status line. This
changes the meaning of the word-separators option - setting it to the empty
string is equivalent to the previous behavior. From Will Noble in GitHub issue
2693.
2021-05-13 08:49:58 +01:00
Nicholas Marriott
f03b27c72b Do not use NULL client when source-file finishes, GitHub issue 2707. 2021-05-12 07:08:58 +01:00
Nicholas Marriott
4ca6b42c24 Add -F for command-prompt and use it to fix "Rename" on the window menu, GitHub
issue 2699.
2021-05-10 07:52:30 +01:00
Nicholas Marriott
bde3829131 Do not expand the file given with -f so it can contain :s. 2021-05-10 07:51:30 +01:00
Nicholas Marriott
d00d682069 Looks like evports on SunOS are broken also, disable them. GitHub issue 2702. 2021-05-10 07:42:35 +01:00
Nicholas Marriott
f2951bd4a5 Remove old shift function keys which interfere with xterm keys now. GitHub
issue 2696.
2021-05-05 07:23:23 +01:00
Nicholas Marriott
8da4573088 Fire check callback after cleaning up event so it does not get stuck, from
Jeongho Jang in GitHub issue 2695.
2021-05-03 10:49:51 +01:00
Nicholas Marriott
c03b57465b Add different command historys for different types of prompts ("command",
"search" etc). From Anindya Mukherjee.
2021-05-03 07:39:32 +01:00
Nicholas Marriott
40467726e3 Fix warnings, from Jan Tache in GitHub issue 2692. 2021-05-03 06:39:17 +01:00
Nicholas Marriott
2e7ec8c0b9 Improve logging of screen mode changes. 2021-04-30 20:14:10 +01:00
Nicholas Marriott
32c97a7f2f Ctrl keys are < 0x7f, not Unicode. 2021-04-28 20:20:53 +01:00
Nicholas Marriott
e2d01795d2 Move "special" keys into the Unicode PUA rather than making them high a top bit
set, some compilers cannot handle enums that are larger than int. GitHub issue
2673.
2021-04-28 09:18:04 +01:00
Nicholas Marriott
589d3eb48f Change cursor style handling so tmux understands which sequences contain
blinking and sets the flag appropriately, means that it works whether cnorm
disables blinking or not. GitHub issue 2682.
2021-04-28 09:17:13 +01:00
Nicholas Marriott
cf6034da92 Change resize timers and flags into one timer and a queue to fix problems with
vim when resized multiple times. GitHub issue 2677.
2021-04-28 09:16:30 +01:00
Nicholas Marriott
ce8c56cc97 Mention S- for Shift, GitHub issue 2683. 2021-04-27 08:29:54 +01:00
Nicholas Marriott
43c292fa91 Revert "Revert "Add crosscompiling fallbacks, from Hasso Tepper.""
This reverts commit dda3bf896b.
2021-04-23 17:18:51 +01:00
Nicholas Marriott
cb9a0627f0 Do not count client if no window. 2021-04-23 13:41:49 +01:00
Nicholas Marriott
7a6446ac17 Three changes to fix problems with xterm in VT340 mode, reported by Thomas
Sattler.

1) Do not include the DECSLRM or DECFRA features for xterm; they will be added
   instead if secondary DA responds as VT420 (this happens already).

2) Set or reset the individual flags after terminal-overrides is applied, so
   the user can properly disable them.

3) Add a capability for DECFRA ("Rect").
2021-04-22 09:01:22 +01:00
Nicholas Marriott
cd6af4a52e Include current client in size calcultion for new sessions, GitHub issue 2662. 2021-04-21 09:47:03 +01:00
Nicholas Marriott
8363c6af2e Add an "always" value to the extended-keys option to always forward these keys
to applications inside tmux.
2021-04-21 09:32:48 +01:00
Nicholas Marriott
6c2bf0e221 Minor CHANGES and tmux.1 fixed, from Daniel Hahler, GitHub issue 2664. 2021-04-20 06:37:01 +01:00
Nicholas Marriott
88575a27e2 Add another couple of keys needed for extended keys, GitHub issue 2658. 2021-04-20 06:35:54 +01:00
Nicholas Marriott
3a892228f4 Use = not ==, from Leonardo Taccari. 2021-04-18 08:48:03 +01:00
Nicholas Marriott
5fa8e5e13f back-to-indentation fixes, from Anindya Mukherjee. 2021-04-18 08:47:11 +01:00
Nicholas Marriott
73cf767a35 Fix display-menu -xR, from Alexis Hildebrandt. 2021-04-16 12:12:50 +01:00
Nicholas Marriott
b2588eed03 Apple have broken strtonum so check it works, from Teubel Gyorgy. 2021-04-16 12:07:54 +01:00
Nicholas Marriott
9af78c8e69 Adjust latest client when a client detaches, GitHub issue 2657. 2021-04-16 11:59:08 +01:00
Nicholas Marriott
dda3bf896b Revert "Add crosscompiling fallbacks, from Hasso Tepper."
This reverts commit bb6242675a.
2021-04-15 16:10:31 +01:00
Nicholas Marriott
98650658a7 Handle modifier 9 as Meta, GitHub issue 2647. 2021-04-15 08:22:36 +01:00
Thomas Adam
6f6b7f8261 Merge branch 'obsd-master' into master 2021-04-15 08:01:23 +01:00
Nicholas Marriott
bb6242675a Add crosscompiling fallbacks, from Hasso Tepper. 2021-04-15 06:46:11 +01:00
nicm
33f9b08bbb %begin now has three arguments, not two. GitHubs issue 2646. 2021-04-15 05:38:11 +00:00
Thomas Adam
e88d48f804 Merge branch 'obsd-master' into master 2021-04-13 18:01:17 +01:00
nicm
dfcc9f8cbc Include modifiers when looking up an individual key. 2021-04-13 16:00:47 +00:00
Thomas Adam
16f1c5f0a1 Merge branch 'obsd-master' into master 2021-04-13 14:01:21 +01:00
nicm
bbb3509bc5 Change how extended ctrl keys are processed to fix C-S-Tab and C-;. 2021-04-13 12:26:34 +00:00
Nicholas Marriott
c5c2871d22 Merge branch '3.2-rc' 2021-04-13 08:46:21 +01:00
Thomas Adam
90614dfe05 Merge branch 'obsd-master' into master 2021-04-13 08:01:22 +01:00
nicm
ff860e5fe4 Move mode set/reset after sync so cursor doesn't flicker, from Avi
Halachmi.
2021-04-13 05:25:05 +00:00
nicm
715835510b Handle C-Tab correctly with extended keys, GitHub issue 2642. 2021-04-13 05:23:34 +00:00
463 changed files with 77037 additions and 14889 deletions

View File

@@ -29,7 +29,7 @@ uname -sp && tmux -V && echo $TERM
Also include: Also include:
- Your platform (Linux, OS X, or whatever). - Your platform (Linux, macOS, or whatever).
- A brief description of the problem with steps to reproduce. - A brief description of the problem with steps to reproduce.
@@ -37,7 +37,8 @@ Also include:
- Your terminal, and `$TERM` inside and outside of tmux. - Your terminal, and `$TERM` inside and outside of tmux.
- Logs from tmux (see below). - Logs from tmux (see below). Please attach logs to the issue directly rather
than using a download site or pastebin. Put in a zip file if necessary.
- At most one or two screenshots, if helpful. - At most one or two screenshots, if helpful.
@@ -62,7 +63,7 @@ tmux -vv -Ltest -f/dev/null new
Or if you need your configuration: Or if you need your configuration:
~~~base ~~~bash
tmux kill-server tmux kill-server
tmux -vv new tmux -vv new
~~~ ~~~
@@ -76,3 +77,8 @@ The log files are:
- `tmux-out*.log`: output log file. - `tmux-out*.log`: output log file.
Please attach the log files to your issue. Please attach the log files to your issue.
## What does it mean if an issue is closed?
All it means is that work on the issue is not planned for the near future. See
the issue's comments to find out if contributions would be welcome.

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1 @@
blank_issues_enabled: false

View File

@@ -1,3 +1,12 @@
---
name: Use this issue template
about: Please read https://github.com/tmux/tmux/blob/master/.github/CONTRIBUTING.md
title: ''
labels: ''
assignees: ''
---
### Issue description ### Issue description
Please read https://github.com/tmux/tmux/blob/master/.github/CONTRIBUTING.md Please read https://github.com/tmux/tmux/blob/master/.github/CONTRIBUTING.md
@@ -14,9 +23,11 @@ built from the latest code in Git.
### Required information ### Required information
Please provide the following information: Please provide the following information. These are **required**. Note that bug reports without logs may be ignored or closed without comment.
* tmux version (`tmux -V`). * tmux version (`tmux -V`).
* Platform (`uname -sp`). * Platform (`uname -sp`).
* $TERM inside and outside of tmux (`echo $TERM`). * Terminal in use (xterm, rxvt, etc).
* $TERM *inside* tmux (`echo $TERM`).
* $TERM *outside* tmux (`echo $TERM`).
* Logs from tmux (`tmux kill-server; tmux -vv new`). * Logs from tmux (`tmux kill-server; tmux -vv new`).

4
.github/README.md vendored
View File

@@ -4,7 +4,7 @@ tmux is a terminal multiplexer: it enables a number of terminals to be created,
accessed, and controlled from a single screen. tmux may be detached from a accessed, and controlled from a single screen. tmux may be detached from a
screen and continue running in the background, then later reattached. screen and continue running in the background, then later reattached.
This release runs on OpenBSD, FreeBSD, NetBSD, Linux, OS X and Solaris. This release runs on OpenBSD, FreeBSD, NetBSD, Linux, macOS and Solaris.
## Dependencies ## Dependencies
@@ -79,7 +79,7 @@ A small example configuration is in `example_tmux.conf`.
And a bash(1) completion file at: And a bash(1) completion file at:
https://github.com/imomaliev/tmux-bash-completion https://github.com/scop/bash-completion/blob/main/completions-core/tmux.bash
For debugging, run tmux with `-v` or `-vv` to generate server and client log For debugging, run tmux with `-v` or `-vv` to generate server and client log
files in the current directory. files in the current directory.

11
.github/copilot-instructions.md vendored Normal file
View File

@@ -0,0 +1,11 @@
For pull request code reviews in this repository, do not leave any review comments under any circumstances.
If asked to review a pull request, produce no comments.
Do not comment on pull requests in this repository.
For pull request code reviews in this repository, do not leave a pull request overview.
Do not leave inline review comments.
If asked to review a pull request, provide no summary, no overview, and no code comments.

10
.github/lock.yml vendored
View File

@@ -1,10 +0,0 @@
daysUntilLock: 30
skipCreatedBefore: false
exemptLabels: []
lockLabel: false
lockComment: >
This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.
setLockReason: false
#only: issues

34
.github/workflows/lock.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
name: 'Lock Threads'
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
issues: write
pull-requests: write
discussions: write
concurrency:
group: lock-threads
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v6
with:
github-token: ${{ github.token }}
issue-inactive-days: '30'
issue-comment: >
This issue has been automatically locked since there
has not been any recent activity after it was closed.
pr-inactive-days: '60'
pr-comment: >
This pull request has been automatically locked since there
has not been any recent activity after it was closed.
discussion-inactive-days: '60'
discussion-comment: >
This discussion has been automatically locked since there
has not been any recent activity after it was closed.

87
.github/workflows/regress.yml vendored Normal file
View File

@@ -0,0 +1,87 @@
name: 'Run Tests'
on:
workflow_dispatch:
schedule:
- cron: '33 3 * * *'
permissions:
contents: read
concurrency:
group: tmux-tests
cancel-in-progress: true
jobs:
regress:
name: ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- name: ubuntu-24.04-x64
runner: ubuntu-24.04
make: make
configure: --enable-utf8proc --enable-asan
#- name: ubuntu-24.04-arm64
# runner: ubuntu-24.04-arm
# make: make
# configure: --enable-utf8proc --enable-asan
- name: macos-26-arm64
runner: macos-26
make: gmake
configure: --enable-utf8proc --enable-asan
steps:
- name: checkout
uses: actions/checkout@v4
- name: dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
autoconf \
automake \
bison \
build-essential \
libevent-dev \
libncurses-dev \
libutf8proc-dev \
pkg-config
- name: dependencies
if: runner.os == 'macOS'
run: |
brew install \
autoconf \
automake \
bison \
libevent \
jemalloc \
make \
ncurses \
utf8proc \
pkg-config
- name: build
run: |
sh autogen.sh
./configure ${{ matrix.configure }}
${{ matrix.make }} -j"$(getconf _NPROCESSORS_ONLN)"
- name: test
run: |
cd regress
${{ matrix.make }}
- name: logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: regress-logs-${{ matrix.name }}
path: regress/logs/*.log
if-no-files-found: ignore

38
.gitignore vendored
View File

@@ -1,23 +1,27 @@
*.o
*~
*.diff
*.patch
*.core *.core
core *.dSYM
tags *.diff
*.o
*.patch
*.swp
*~
.deps/ .deps/
compat/.dirstamp .dirstamp
aclocal.m4 .serena/
autom4te.cache/ AGENTS.md
config.log
config.status
etc/
tmux
Makefile Makefile
Makefile.in Makefile.in
configure aclocal.m4
tmux.1.* autom4te.cache/
*.dSYM
cmd-parse.c cmd-parse.c
compat/.dirstamp
config.log
config.status
configure
core
etc/
fuzz/*-fuzzer fuzz/*-fuzzer
.dirstamp regress/logs/
tags
tmux
tmux.1.*

View File

@@ -29,6 +29,7 @@ Ted Unangst <tedu@openbsd.org> tedu <tedu>
Theo de Raadt <deraadt@openbsd.org> Theo Deraadt <deraadt@openbsd.org> Theo de Raadt <deraadt@openbsd.org> Theo Deraadt <deraadt@openbsd.org>
Theo de Raadt <deraadt@openbsd.org> deraadt <deraadt> Theo de Raadt <deraadt@openbsd.org> deraadt <deraadt>
Thomas Adam <thomas@xteddy.org> Thomas <thomas@xteddy.org> Thomas Adam <thomas@xteddy.org> Thomas <thomas@xteddy.org>
Thomas Adam <thomas@xteddy.org> Thomas Adam <thomas.adam22@gmail.com>
Thomas Adam <thomas@xteddy.org> Thomas Adam <thomas.adam@smoothwall.net> Thomas Adam <thomas@xteddy.org> Thomas Adam <thomas.adam@smoothwall.net>
Thomas Adam <thomas@xteddy.org> n6tadam <n6tadam@xteddy.org> Thomas Adam <thomas@xteddy.org> n6tadam <n6tadam@xteddy.org>
Tim van der Molen <tim@openbsd.org> tim <tim> Tim van der Molen <tim@openbsd.org> tim <tim>

1150
CHANGES

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,4 @@
THIS IS FOR INFORMATION ONLY, CODE IS UNDER THE LICENCE AT THE TOP OF ITS FILE. Copyright (c) Various Authors
The README, CHANGES, FAQ and TODO files are licensed under the ISC license. All
other files have a license and copyright notice at their start, typically:
Copyright (c) <author>
Permission to use, copy, modify, and distribute this software for any Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above

View File

@@ -1,37 +1,52 @@
# Makefile.am
# Obvious program stuff. # Obvious program stuff.
bin_PROGRAMS = tmux bin_PROGRAMS = tmux
CLEANFILES = tmux.1.mdoc tmux.1.man cmd-parse.c CLEANFILES = tmux.1.mdoc tmux.1.man cmd-parse.c
# Distribution tarball options. # Distribution tarball options.
EXTRA_DIST = \ EXTRA_DIST = \
CHANGES README README.ja COPYING example_tmux.conf \ CHANGES README COPYING example_tmux.conf \
osdep-*.c mdoc2man.awk tmux.1 osdep-*.c mdoc2man.awk tmux.1
dist_EXTRA_tmux_SOURCES = compat/*.[ch] dist_EXTRA_tmux_SOURCES = compat/*.[ch]
# Preprocessor flags. # Preprocessor flags.
AM_CPPFLAGS += @XOPEN_DEFINES@ \ AM_CPPFLAGS += @XOPEN_DEFINES@ \
-DTMUX_VERSION='"@VERSION@"' \ -DTMUX_VERSION='"@VERSION@"' \
-DTMUX_CONF='"$(sysconfdir)/tmux.conf:~/.tmux.conf:$$XDG_CONFIG_HOME/tmux/tmux.conf:~/.config/tmux/tmux.conf"' -DTMUX_CONF='"$(sysconfdir)/tmux.conf:~/.tmux.conf:$$XDG_CONFIG_HOME/tmux/tmux.conf:~/.config/tmux/tmux.conf"' \
-DTMUX_LOCK_CMD='"@DEFAULT_LOCK_CMD@"' \
-DTMUX_TERM='"@DEFAULT_TERM@"' \
-DTMUX_MOUSE=1
# Additional object files. # Additional object files.
LDADD = $(LIBOBJS) LDADD = $(LIBOBJS)
# Set flags for gcc. # Set flags for gcc.
if IS_GCC if IS_GCC
AM_CFLAGS += -std=gnu99 -O2 AM_CFLAGS += -std=gnu99
if IS_OPTIMIZED
AM_CFLAGS += -O2
else
AM_CFLAGS += -O0
endif
if IS_DEBUG if IS_DEBUG
AM_CFLAGS += -g AM_CFLAGS += -g3 -ggdb
AM_CFLAGS += -Wno-long-long -Wall -W -Wformat=2 AM_CFLAGS += -Wno-long-long -Wall -W -Wformat=2 -Wno-use-after-free
AM_CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations AM_CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
AM_CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare AM_CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare
AM_CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align AM_CFLAGS += -Wundef -Wbad-function-cast -Winline -Wno-cast-align
AM_CFLAGS += -Wdeclaration-after-statement -Wno-pointer-sign -Wno-attributes AM_CFLAGS += -Wdeclaration-after-statement -Wno-pointer-sign -Wno-attributes
AM_CFLAGS += -Wno-unused-result -Wno-format-y2k AM_CFLAGS += -Wno-unused-result -Wno-format-y2k -Wno-unknown-warning-option
AM_CFLAGS += -Wno-maybe-uninitialized
if IS_DARWIN
AM_CFLAGS += -Wno-deprecated-declarations -Wno-macro-redefined
endif
AM_CPPFLAGS += -DDEBUG AM_CPPFLAGS += -DDEBUG
endif endif
AM_CPPFLAGS += -iquote. AM_CPPFLAGS += -iquote.
if IS_ASAN
AM_CPPFLAGS += -DASAN
AM_CFLAGS += -fsanitize=address -fno-omit-frame-pointer
AM_LDFLAGS += -fsanitize=address
endif
endif endif
# Set flags for Solaris. # Set flags for Solaris.
@@ -63,6 +78,11 @@ if IS_HAIKU
AM_CPPFLAGS += -D_BSD_SOURCE AM_CPPFLAGS += -D_BSD_SOURCE
endif endif
# Set flags for Cygwin.
if IS_CYGWIN
AM_CPPFLAGS += -DTMUX_SOCK_PERM=0
endif
# List of sources. # List of sources.
dist_tmux_SOURCES = \ dist_tmux_SOURCES = \
alerts.c \ alerts.c \
@@ -81,7 +101,6 @@ dist_tmux_SOURCES = \
cmd-detach-client.c \ cmd-detach-client.c \
cmd-display-menu.c \ cmd-display-menu.c \
cmd-display-message.c \ cmd-display-message.c \
cmd-display-panes.c \
cmd-find-window.c \ cmd-find-window.c \
cmd-find.c \ cmd-find.c \
cmd-if-shell.c \ cmd-if-shell.c \
@@ -92,6 +111,7 @@ dist_tmux_SOURCES = \
cmd-kill-window.c \ cmd-kill-window.c \
cmd-list-buffers.c \ cmd-list-buffers.c \
cmd-list-clients.c \ cmd-list-clients.c \
cmd-list-commands.c \
cmd-list-keys.c \ cmd-list-keys.c \
cmd-list-panes.c \ cmd-list-panes.c \
cmd-list-sessions.c \ cmd-list-sessions.c \
@@ -119,12 +139,14 @@ dist_tmux_SOURCES = \
cmd-select-pane.c \ cmd-select-pane.c \
cmd-select-window.c \ cmd-select-window.c \
cmd-send-keys.c \ cmd-send-keys.c \
cmd-server-access.c \
cmd-set-buffer.c \ cmd-set-buffer.c \
cmd-set-environment.c \ cmd-set-environment.c \
cmd-set-option.c \ cmd-set-option.c \
cmd-show-environment.c \ cmd-show-environment.c \
cmd-show-messages.c \ cmd-show-messages.c \
cmd-show-options.c \ cmd-show-options.c \
cmd-show-prompt-history.c \
cmd-source-file.c \ cmd-source-file.c \
cmd-split-window.c \ cmd-split-window.c \
cmd-swap-pane.c \ cmd-swap-pane.c \
@@ -138,12 +160,17 @@ dist_tmux_SOURCES = \
control-notify.c \ control-notify.c \
control.c \ control.c \
environ.c \ environ.c \
events-payload.c \
events.c \
file.c \ file.c \
format.c \
format-draw.c \ format-draw.c \
format.c \
fuzzy.c \
grid-reader.c \ grid-reader.c \
grid-view.c \ grid-view.c \
grid.c \ grid.c \
hooks.c \
hyperlinks.c \
input-keys.c \ input-keys.c \
input.c \ input.c \
job.c \ job.c \
@@ -155,39 +182,50 @@ dist_tmux_SOURCES = \
log.c \ log.c \
menu.c \ menu.c \
mode-tree.c \ mode-tree.c \
monitor.c \
names.c \ names.c \
notify.c \
options-table.c \ options-table.c \
options.c \ options.c \
paste.c \ paste.c \
popup.c \ popup.c \
proc.c \ proc.c \
prompt-history.c \
prompt.c \
regsub.c \ regsub.c \
resize.c \ resize.c \
screen-redraw.c \ screen-redraw.c \
screen-write.c \ screen-write.c \
screen.c \ screen.c \
server-acl.c \
server-client.c \ server-client.c \
server-fn.c \ server-fn.c \
server.c \ server.c \
session.c \ session.c \
sort.c \
spawn.c \ spawn.c \
status.c \ status.c \
style.c \ style.c \
tmux-protocol.h \
tmux.c \ tmux.c \
tmux.h \ tmux.h \
tty-acs.c \ tty-acs.c \
tty-draw.c \
tty-features.c \ tty-features.c \
tty-keys.c \ tty-keys.c \
tty-term.c \ tty-term.c \
tty.c \ tty.c \
utf8-combined.c \
utf8.c \ utf8.c \
window-border.c \
window-buffer.c \ window-buffer.c \
window-client.c \ window-client.c \
window-clock.c \ window-clock.c \
window-copy.c \ window-copy.c \
window-customize.c \ window-customize.c \
window-panes.c \
window-switch.c \
window-tree.c \ window-tree.c \
window-visible.c \
window.c \ window.c \
xmalloc.c \ xmalloc.c \
xmalloc.h xmalloc.h
@@ -198,15 +236,36 @@ if NEED_FORKPTY
nodist_tmux_SOURCES += compat/forkpty-@PLATFORM@.c nodist_tmux_SOURCES += compat/forkpty-@PLATFORM@.c
endif endif
# Add compat file for systemd.
if HAVE_SYSTEMD
nodist_tmux_SOURCES += compat/systemd.c
endif
# Add compat file for utf8proc. # Add compat file for utf8proc.
if HAVE_UTF8PROC if HAVE_UTF8PROC
nodist_tmux_SOURCES += compat/utf8proc.c nodist_tmux_SOURCES += compat/utf8proc.c
endif endif
# Enable image support.
if ENABLE_IMAGES
dist_tmux_SOURCES += image.c image-sixel.c
endif
# Add bits for fuzzing if enabled.
if NEED_FUZZING if NEED_FUZZING
check_PROGRAMS = fuzz/input-fuzzer check_PROGRAMS = \
fuzz/input-fuzzer \
fuzz/cmd-parse-fuzzer \
fuzz/format-fuzzer \
fuzz/style-fuzzer
fuzz_input_fuzzer_LDFLAGS = $(FUZZING_LIBS) fuzz_input_fuzzer_LDFLAGS = $(FUZZING_LIBS)
fuzz_input_fuzzer_LDADD = $(LDADD) $(tmux_OBJECTS) fuzz_input_fuzzer_LDADD = $(LDADD) $(tmux_OBJECTS)
fuzz_cmd_parse_fuzzer_LDFLAGS = $(FUZZING_LIBS)
fuzz_cmd_parse_fuzzer_LDADD = $(LDADD) $(tmux_OBJECTS)
fuzz_format_fuzzer_LDFLAGS = $(FUZZING_LIBS)
fuzz_format_fuzzer_LDADD = $(LDADD) $(tmux_OBJECTS)
fuzz_style_fuzzer_LDFLAGS = $(FUZZING_LIBS)
fuzz_style_fuzzer_LDADD = $(LDADD) $(tmux_OBJECTS)
endif endif
# Install tmux.1 in the right format. # Install tmux.1 in the right format.
@@ -221,3 +280,7 @@ install-exec-hook:
$(mkdir_p) $(DESTDIR)$(mandir)/man1 $(mkdir_p) $(DESTDIR)$(mandir)/man1
$(INSTALL_DATA) $(srcdir)/tmux.1.@MANFORMAT@ \ $(INSTALL_DATA) $(srcdir)/tmux.1.@MANFORMAT@ \
$(DESTDIR)$(mandir)/man1/tmux.1 $(DESTDIR)$(mandir)/man1/tmux.1
# And uninstall it.
uninstall-hook:
rm -f $(DESTDIR)$(mandir)/man1/tmux.1

13
README
View File

@@ -4,7 +4,7 @@ tmux is a terminal multiplexer: it enables a number of terminals to be created,
accessed, and controlled from a single screen. tmux may be detached from a accessed, and controlled from a single screen. tmux may be detached from a
screen and continue running in the background, then later reattached. screen and continue running in the background, then later reattached.
This release runs on OpenBSD, FreeBSD, NetBSD, Linux, OS X and Solaris. This release runs on OpenBSD, FreeBSD, NetBSD, Linux, macOS and Solaris.
* Dependencies * Dependencies
@@ -36,6 +36,7 @@ autoconf, automake and pkg-config:
$ cd tmux $ cd tmux
$ sh autogen.sh $ sh autogen.sh
$ ./configure && make $ ./configure && make
$ sudo make install
* Contributing * Contributing
@@ -55,9 +56,17 @@ source tree with:
A small example configuration is in example_tmux.conf. A small example configuration is in example_tmux.conf.
Other documentation is available in the wiki:
https://github.com/tmux/tmux/wiki
Also see the tmux FAQ at:
https://github.com/tmux/tmux/wiki/FAQ
A bash(1) completion file is at: A bash(1) completion file is at:
https://github.com/imomaliev/tmux-bash-completion https://github.com/scop/bash-completion/blob/main/completions/tmux
For debugging, run tmux with -v and -vv to generate server and client log files For debugging, run tmux with -v and -vv to generate server and client log files
in the current directory. in the current directory.

View File

@@ -1,62 +0,0 @@
tmuxへようこそ!
tmuxはターミナルマルチプレクサーです。複数のターミナルを一つのスクリーン内に作成し、操作することができます。
バックグラウンドで処理を実行中に一度スクリーンから離れて後から復帰することも可能です。
OpenBSD、FreeBSD、NetBSD、Linux、OS X、Solarisで実行できます。
tmuxはlibevent 2.x.に依存します。 下記からダウンロードしてください。
http://libevent.org
また、ncursesも必要です。こちらからどうぞ。
http://invisible-island.net/ncurses/
tarballでのtmuxのビルドとインストール方法。
$ ./configure && make
$ sudo make install
tmuxはutmp(5)をアップデートするためにutempterを使うことができます。もしインストール済みであればオプション「--enable-utempter」をつけて実行してください。
リポジトリから最新バージョンを手に入れるためには下記を実行。
$ git clone https://github.com/tmux/tmux.git
$ cd tmux
$ sh autogen.sh
$ ./configure && make
(ビルドのためにはlibevent、ncurses libraries、headersに加えて、C compiler、make、autoconf、automake、pkg-configが必要です。)
詳しい情報はhttp://git-scm.comをご覧ください。修正はメール<tmux-users@googlegroups.com>宛、もしくはhttps://github.com/tmux/tmux/issuesにて受け付けています。
tmuxのドキュメントについてはtmux.1マニュアルをご覧ください。こちらのコマンドで参照可能です。
$ nroff -mdoc tmux.1|less
サンプル設定は本リポジトリのexample_tmux.confに
また、bash-completionファイルは下記にあります。
https://github.com/imomaliev/tmux-bash-completion
「-v」や「-vv」を指定することでデバッグモードでの起動が可能です。カレントディレクトリにサーバーやクライアントのログファイルが生成されます。
議論やバグレポート用のメーリングリストにはこちらから参加可能です。
https://groups.google.com/forum/#!forum/tmux-users
gitコミットについての連絡先
https://groups.google.com/forum/#!forum/tmux-git
購読は<tmux-users+subscribe@googlegroups.com>までメールをお願いします。
バグレポートや機能追加(特にコードへの貢献)は大歓迎です。こちらにご連絡ください。
tmux-users@googlegroups.com
本ファイル、CHANGES、 FAQ、SYNCINGそしてTODOはISC licenseで保護されています。
その他のファイルのライセンスや著作権については、ファイルの上部に明記されています。
-- Nicholas Marriott <nicholas.marriott@gmail.com>

1
SECURITY.md Normal file
View File

@@ -0,0 +1 @@
Please report security issues to nicholas.marriott@gmail.com.

173
SYNCING
View File

@@ -1,173 +0,0 @@
Preamble
========
Tmux portable relies on repositories "tmux" and "tmux-openbsd".
Here's a description of them:
* "tmux" is the portable version, the one which contains code for other
operating systems, and autotools, etc., which isn't found or needed in the
OpenBSD base system.
* "tmux-openbsd" is the version of tmux in OpenBSD base system which provides
the basis of the portable tmux version.
Note: The "tmux-openbsd" repository is actually handled by "git cvsimport"
running at 15 minute intervals, so a commit made to OpenBSD's tmux CVS
repository will take at least that long to appear in this git repository.
(It might take longer, depending on the CVS mirror used to import the
OpenBSD code).
If you've never used git before, git tracks meta-data about the committer
and the author, as part of a commit, hence:
% git config [--global] user.name "Your name"
% git config [--global] user.email "you@yourdomain.com"
Note that, if you already have this in the global ~/.gitconfig option, then
this will be used. Setting this per-repository would involve not using the
"--global" flag above. If you wish to use the same credentials always,
pass the "--global" option, as shown.
This is a one-off operation once the repository has been cloned, assuming
this information has ever been set before.
Cloning repositories
====================
This involves having both tmux and tmux-openbsd cloned, as in:
% cd /some/where/useful
% git clone https://github.com/tmux/tmux.git
% git clone https://github.com/ThomasAdam/tmux-openbsd.git
Note that you do not need additional checkouts to manage the sync -- an
existing clone of either repositories will suffice. So if you already have
these checkouts existing, skip that.
Adding in git-remotes
=====================
Because the portable "tmux" git repository and the "tmux-openbsd"
repository do not inherently share any history between each other, the
history has been faked between them. This "faking of history" is something
which has to be told to git for the purposes of comparing the "tmux" and
"tmux-openbsd" repositories for syncing. To do this, we must reference the
clone of the "tmux-openbsd" repository from the "tmux" repository, as
shown by the following command:
% cd /path/to/tmux
% git remote add obsd-tmux file:///path/to/tmux-openbsd
So that now, the remote "obsd-tmux" can be used to reference branches and
commits from the "tmux-openbsd" repository, but from the context of the
portable "tmux" repository, which makes sense because it's the "tmux"
repository which will have the updates applied to them.
Fetching updates
================
To ensure the latest commits from "tmux-openbsd" can be found from within
"tmux", we have to ensure the "master" branch from "tmux-openbsd" is
up-to-date first, and then reference that update in "tmux", as in:
% cd /path/to/tmux-openbsd
% git checkout master
% git pull
Then back in "tmux":
% cd /path/to/tmux
% git fetch obsd-tmux
Creating the necessary branches
===============================
Now that "tmux" can see commits and branches from "tmux-openbsd" by way
of the remote name "obsd-tmux", we can now create the master branch from
"tmux-openbsd" in the "tmux" repository:
% git checkout -b obsd-master obsd-tmux/master
Adding in the fake history points
=================================
To tie both the "master" branch from "tmux" and the "obsd-master"
branch from "tmux-openbsd" together, the fake history points added to the
"tmux" repository need to be added. To do this, we must add an
additional refspec line, as in:
% cd /path/to/tmux
% git config --add remote.origin.fetch '+refs/replace/*:refs/replace/*'
% git fetch origin
Performing the Sync
===================
Make sure the "master" branch is checked out:
% git checkout master
The following will show commits on OpenBSD not yet synched with "tmux":
% git log master..obsd-master
From there, merge the result in, fixing up any conflicts which might arise.
% git merge obsd-master
Then ensure things look correct by BUILDING the result of that sync:
% make clean && ./autogen.sh && ./configure && make
Compare the git merge result with what's on origin/master -- that is, check
which commits you're about to push:
% git log origin/master..master
And if happy:
% git push origin master
Keeping an eye on libutil in OpenBSD
====================================
A lot of the compat/ code in tmux comes from libutil, especially imsg.
Sometimes the API can change, etc., which might cause interesting problems
trying to run the portable version of tmux. It's worth checking
periodically for any changes to libutil in OpenBSD and syncing those files
to compat/ as and when appropriate.
Release tmux for next version
=============================
1. Update and commit README and CHANGES. The former should be checked for
anything outdated and updated with a list of things that might break
upgrades and the latter should mention all the major changes since
the last version.
2. Make sure configure.ac has the new version number.
3. Tag with:
% git tag -a 2.X
Where "2.X" is the next version.
Push the tag out with:
% git push --tags
4. Build the tarball with 'make dist'.
5. Check the tarball. If it's good, go here to select the tag just pushed:
https://github.com/tmux/tmux/tags
Click the "Add release notes", upload the tarball and add a link in the
description field to the CHANGES file.
6. Clone the tmux.github.io repository, and change the RELEASE version in the
Makefile. Commit it, and run 'make' to replace %%RELEASE%%. Push the
result out.
7. Change version back to master in configure.ac.

234
SYNCING.md Normal file
View File

@@ -0,0 +1,234 @@
# Preamble
tmux portable is maintained from two repositories:
* `tmux` is the portable repository. It contains the portability layer,
autotools build files, regression tests, documentation, and code needed for
platforms outside OpenBSD.
* `tmux-openbsd-cutover` is the OpenBSD tmux import repository. Its `master`
branch is the OpenBSD tmux history after the OpenBSD Git cutover. Portable
merges this branch when importing OpenBSD changes.
To create the commits in the tmux-openbsd-cutover repo, the source repo is the
Github mirror of OpenBSD's src repo:
```text
https://github.com/openbsd/src.git
```
The update automation filters the OpenBSD source tree to `usr.bin/tmux/`,
publishes that filtered history as `openbsd-git` in the cutover repository,
cherry-picks new filtered commits onto cutover `master`, then merges cutover
`master` into portable `master`.
If you've never used git before, configure your identity before committing:
```sh
git config [--global] user.name "Your name"
git config [--global] user.email "you@yourdomain.com"
```
# Repository layout
The usual local layout is:
```sh
cd /some/where/useful
git clone https://github.com/tmux/tmux.git tmux-portable
git clone https://github.com/ThomasAdam/tmux-obsd.git tmux-openbsd-cutover
```
The exact directory names do not matter, but the examples below use:
```text
/path/to/tmux-portable
/path/to/tmux-openbsd-cutover
```
The cutover repository has three important branches:
* `master` is the branch portable consumes. It should contain tmux source
only, not automation files.
* `openbsd-git` is the raw filtered OpenBSD tmux branch generated from
OpenBSD src `master`.
* `automation` is an orphan branch containing the GitHub Actions workflow. It
is separate so that workflow files are not merged into portable.
# Adding the OpenBSD remote to portable
In the portable repository, add the cutover repository as a remote:
```sh
cd /path/to/tmux-portable
git remote add tmux-openbsd /path/to/tmux-openbsd-cutover
git config remote.tmux-openbsd.tagOpt --no-tags
```
If the remote already exists, update it instead:
```sh
git remote set-url tmux-openbsd /path/to/tmux-openbsd-cutover
git config remote.tmux-openbsd.tagOpt --no-tags
```
Fetch the cutover master branch explicitly:
```sh
git fetch --no-tags tmux-openbsd master:refs/remotes/tmux-openbsd/master
```
# Automated syncing
The normal sync is performed by the GitHub Actions workflow in the
`automation` branch of the cutover repository. That workflow:
1. Fetches or clones OpenBSD src using a blobless clone.
2. Filters `usr.bin/tmux/` into a local `tmux-openbsd` branch.
3. Updates `tmux-openbsd-cutover/openbsd-git`.
4. Cherry-picks new `openbsd-git` commits onto cutover `master`.
5. Merges cutover `master` into portable `master`.
6. Pushes the changed repositories.
The workflow deliberately runs from the orphan `automation` branch but checks
out cutover `master` as the branch to update. This keeps `.github/` out of
cutover `master`, so portable does not import workflow files when it merges
OpenBSD changes.
# Manual portable merge
If the workflow fails while merging into portable, do the merge locally and
push the result.
Start from an up-to-date portable master:
```sh
cd /path/to/tmux-portable
git fetch origin
git checkout master
git pull --ff-only origin master
```
Fetch the cutover branch:
```sh
git remote add tmux-openbsd /path/to/tmux-openbsd-cutover 2>/dev/null || true
git config remote.tmux-openbsd.tagOpt --no-tags
git fetch --no-tags tmux-openbsd master:refs/remotes/tmux-openbsd/master
```
Merge it:
```sh
git merge --no-ff --log refs/remotes/tmux-openbsd/master
```
Resolve conflicts by deciding whether portable or OpenBSD owns the file.
Useful commands:
```sh
git checkout --ours path/to/file
git add path/to/file
```
This keeps the portable version of a conflicted file.
```sh
git checkout --theirs path/to/file
git add path/to/file
```
This takes the OpenBSD/cutover version of a conflicted file.
Before committing, inspect the result:
```sh
git status
git diff --check
git diff --cached --stat
```
Then finish and publish:
```sh
git commit
git push origin master
```
If the merge attempt is wrong, abort it:
```sh
git merge --abort
```
After pushing a manually resolved merge, rerun the workflow. It should either
no-op or continue from the now-merged portable state.
# Manual cutover update
Normally this is handled by the workflow. If it must be done manually, update
`openbsd-git` in the cutover repository from a filtered OpenBSD src checkout,
then cherry-pick the new filtered commits onto cutover `master`.
The important range is:
```text
origin/openbsd-git..openbsd-git
```
where `origin/openbsd-git` is the previously published filtered OpenBSD tmux
branch and `openbsd-git` is the newly generated filtered branch.
In the cutover repository:
```sh
cd /path/to/tmux-openbsd-cutover
git checkout master
git cherry-pick origin/openbsd-git..openbsd-git
git push origin master openbsd-git
```
Do not put workflow files on cutover `master`; keep them on the orphan
`automation` branch.
# Keeping an eye on libutil in OpenBSD
A lot of the `compat/` code in tmux comes from OpenBSD libraries, especially
imsg. Sometimes APIs change in OpenBSD in ways that require corresponding
portable changes. It is worth checking periodically for relevant OpenBSD
libutil changes and syncing those files into `compat/` as appropriate.
# Release tmux for next version
1. Update and commit README and CHANGES. The former should be checked for
anything outdated and updated with a list of things that might break
upgrades and the latter should mention all the major changes since the last
version.
2. Make sure `configure.ac` has the new version number.
3. Tag with:
```sh
% git tag -a 2.X
```
Where `2.X` is the next version.
Push the tag out with:
```sh
% git push --tags
```
4. Build the tarball with `make dist`.
5. Check the tarball. If it is good, go here to select the tag just pushed:
```text
https://github.com/tmux/tmux/tags
```
Click "Add release notes", upload the tarball and add a link in the
description field to the CHANGES file.
6. Clone the tmux.github.io repository, and change the RELEASE version in the
Makefile. Commit it, and run `make` to replace `%%RELEASE%%`. Push the
result out.
7. Change version back to master in `configure.ac`.

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: alerts.c,v 1.35 2026/07/10 13:38:45 nicm Exp $ */
/* /*
* Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -205,7 +205,7 @@ alerts_check_bell(struct window *w)
} }
if (!alerts_action_applies(wl, "bell-action")) if (!alerts_action_applies(wl, "bell-action"))
continue; continue;
notify_winlink("alert-bell", wl); events_fire_winlink("alert-bell", wl);
if (s->flags & SESSION_ALERTED) if (s->flags & SESSION_ALERTED)
continue; continue;
@@ -241,7 +241,7 @@ alerts_check_activity(struct window *w)
} }
if (!alerts_action_applies(wl, "activity-action")) if (!alerts_action_applies(wl, "activity-action"))
continue; continue;
notify_winlink("alert-activity", wl); events_fire_winlink("alert-activity", wl);
if (s->flags & SESSION_ALERTED) if (s->flags & SESSION_ALERTED)
continue; continue;
@@ -277,7 +277,7 @@ alerts_check_silence(struct window *w)
} }
if (!alerts_action_applies(wl, "silence-action")) if (!alerts_action_applies(wl, "silence-action"))
continue; continue;
notify_winlink("alert-silence", wl); events_fire_winlink("alert-silence", wl);
if (s->flags & SESSION_ALERTED) if (s->flags & SESSION_ALERTED)
continue; continue;
@@ -315,11 +315,11 @@ alerts_set_message(struct winlink *wl, const char *type, const char *option)
if (visual == VISUAL_OFF) if (visual == VISUAL_OFF)
continue; continue;
if (c->session->curw == wl) { if (c->session->curw == wl) {
status_message_set(c, -1, 1, 0, "%s in current window", status_message_set(c, -1, 1, 0, 0,
type); "%s in current window", type);
} else { } else {
status_message_set(c, -1, 1, 0, "%s in window %d", type, status_message_set(c, -1, 1, 0, 0,
wl->idx); "%s in window %d", type, wl->idx);
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: attributes.c,v 1.13 2026/07/02 08:51:05 nicm Exp $ */
/* /*
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org> * Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
@@ -31,7 +31,7 @@ attributes_tostring(int attr)
if (attr == 0) if (attr == 0)
return ("none"); return ("none");
len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s", len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
(attr & GRID_ATTR_CHARSET) ? "acs," : "", (attr & GRID_ATTR_CHARSET) ? "acs," : "",
(attr & GRID_ATTR_BRIGHT) ? "bright," : "", (attr & GRID_ATTR_BRIGHT) ? "bright," : "",
(attr & GRID_ATTR_DIM) ? "dim," : "", (attr & GRID_ATTR_DIM) ? "dim," : "",
@@ -45,7 +45,8 @@ attributes_tostring(int attr)
(attr & GRID_ATTR_UNDERSCORE_3) ? "curly-underscore," : "", (attr & GRID_ATTR_UNDERSCORE_3) ? "curly-underscore," : "",
(attr & GRID_ATTR_UNDERSCORE_4) ? "dotted-underscore," : "", (attr & GRID_ATTR_UNDERSCORE_4) ? "dotted-underscore," : "",
(attr & GRID_ATTR_UNDERSCORE_5) ? "dashed-underscore," : "", (attr & GRID_ATTR_UNDERSCORE_5) ? "dashed-underscore," : "",
(attr & GRID_ATTR_OVERLINE) ? "overline," : ""); (attr & GRID_ATTR_OVERLINE) ? "overline," : "",
(attr & GRID_ATTR_NOATTR) ? "noattr," : "");
if (len > 0) if (len > 0)
buf[len - 1] = '\0'; buf[len - 1] = '\0';

68
cfg.c
View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cfg.c,v 1.90 2026/07/14 17:17:17 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -51,13 +51,12 @@ cfg_done(__unused struct cmdq_item *item, __unused void *data)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
cfg_finished = 1; cfg_finished = 1;
if (!RB_EMPTY(&sessions)) cfg_show_causes(NULL);
cfg_show_causes(RB_MIN(sessions, &sessions));
if (cfg_item != NULL) if (cfg_item != NULL)
cmdq_continue(cfg_item); cmdq_continue(cfg_item);
status_prompt_load_history(); prompt_load_history();
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
@@ -67,6 +66,7 @@ start_cfg(void)
{ {
struct client *c; struct client *c;
u_int i; u_int i;
int flags = 0;
/* /*
* Configuration files are loaded without a client, so commands are run * Configuration files are loaded without a client, so commands are run
@@ -84,19 +84,17 @@ start_cfg(void)
cmdq_append(c, cfg_item); cmdq_append(c, cfg_item);
} }
for (i = 0; i < cfg_nfiles; i++) { if (cfg_quiet)
if (cfg_quiet) flags = CMD_PARSE_QUIET;
load_cfg(cfg_files[i], c, NULL, CMD_PARSE_QUIET, NULL); for (i = 0; i < cfg_nfiles; i++)
else load_cfg(cfg_files[i], c, NULL, NULL, flags, NULL);
load_cfg(cfg_files[i], c, NULL, 0, NULL);
}
cmdq_append(NULL, cmdq_get_callback(cfg_done, NULL)); cmdq_append(NULL, cmdq_get_callback(cfg_done, NULL));
} }
int int
load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags, load_cfg(const char *path, struct client *c, struct cmdq_item *item,
struct cmdq_item **new_item) struct cmd_find_state *current, int flags, struct cmdq_item **new_item)
{ {
FILE *f; FILE *f;
struct cmd_parse_input pi; struct cmd_parse_input pi;
@@ -124,8 +122,6 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
pr = cmd_parse_from_file(f, &pi); pr = cmd_parse_from_file(f, &pi);
fclose(f); fclose(f);
if (pr->status == CMD_PARSE_EMPTY)
return (0);
if (pr->status == CMD_PARSE_ERROR) { if (pr->status == CMD_PARSE_ERROR) {
cfg_add_cause("%s", pr->error); cfg_add_cause("%s", pr->error);
free(pr->error); free(pr->error);
@@ -137,7 +133,7 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
} }
if (item != NULL) if (item != NULL)
state = cmdq_copy_state(cmdq_get_state(item)); state = cmdq_copy_state(cmdq_get_state(item), current);
else else
state = cmdq_new_state(NULL, NULL, 0); state = cmdq_new_state(NULL, NULL, 0);
cmdq_add_format(state, "current_file", "%s", pi.file); cmdq_add_format(state, "current_file", "%s", pi.file);
@@ -157,8 +153,8 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
int int
load_cfg_from_buffer(const void *buf, size_t len, const char *path, load_cfg_from_buffer(const void *buf, size_t len, const char *path,
struct client *c, struct cmdq_item *item, int flags, struct client *c, struct cmdq_item *item, struct cmd_find_state *current,
struct cmdq_item **new_item) int flags, struct cmdq_item **new_item)
{ {
struct cmd_parse_input pi; struct cmd_parse_input pi;
struct cmd_parse_result *pr; struct cmd_parse_result *pr;
@@ -178,8 +174,6 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,
pi.c = c; pi.c = c;
pr = cmd_parse_from_buffer(buf, len, &pi); pr = cmd_parse_from_buffer(buf, len, &pi);
if (pr->status == CMD_PARSE_EMPTY)
return (0);
if (pr->status == CMD_PARSE_ERROR) { if (pr->status == CMD_PARSE_ERROR) {
cfg_add_cause("%s", pr->error); cfg_add_cause("%s", pr->error);
free(pr->error); free(pr->error);
@@ -191,7 +185,7 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,
} }
if (item != NULL) if (item != NULL)
state = cmdq_copy_state(cmdq_get_state(item)); state = cmdq_copy_state(cmdq_get_state(item), current);
else else
state = cmdq_new_state(NULL, NULL, 0); state = cmdq_new_state(NULL, NULL, 0);
cmdq_add_format(state, "current_file", "%s", pi.file); cmdq_add_format(state, "current_file", "%s", pi.file);
@@ -227,10 +221,14 @@ cfg_add_cause(const char *fmt, ...)
void void
cfg_print_causes(struct cmdq_item *item) cfg_print_causes(struct cmdq_item *item)
{ {
u_int i; struct client *c = cmdq_get_client(item);
u_int i;
for (i = 0; i < cfg_ncauses; i++) { for (i = 0; i < cfg_ncauses; i++) {
cmdq_print(item, "%s", cfg_causes[i]); if (c != NULL && (c->flags & CLIENT_CONTROL))
control_write(c, "%%config-error %s", cfg_causes[i]);
else
cmdq_print(item, "%s", cfg_causes[i]);
free(cfg_causes[i]); free(cfg_causes[i]);
} }
@@ -242,22 +240,42 @@ cfg_print_causes(struct cmdq_item *item)
void void
cfg_show_causes(struct session *s) cfg_show_causes(struct session *s)
{ {
struct client *c = TAILQ_FIRST(&clients);
struct window_pane *wp; struct window_pane *wp;
struct window_mode_entry *wme; struct window_mode_entry *wme;
u_int i; u_int i;
if (s == NULL || cfg_ncauses == 0) if (cfg_ncauses == 0)
return;
if (c != NULL && (c->flags & CLIENT_CONTROL)) {
for (i = 0; i < cfg_ncauses; i++) {
control_write(c, "%%config-error %s", cfg_causes[i]);
free(cfg_causes[i]);
}
goto out;
}
if (s == NULL) {
if (c != NULL && c->session != NULL)
s = c->session;
else
s = RB_MIN(sessions, &sessions);
}
if (s == NULL || s->attached == 0) /* wait for an attached session */
return; return;
wp = s->curw->window->active; wp = s->curw->window->active;
wme = TAILQ_FIRST(&wp->modes); wme = TAILQ_FIRST(&wp->modes);
if (wme == NULL || wme->mode != &window_view_mode) if (wme == NULL || wme->mode != &window_view_mode)
window_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL); window_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL,
NULL);
for (i = 0; i < cfg_ncauses; i++) { for (i = 0; i < cfg_ncauses; i++) {
window_copy_add(wp, "%s", cfg_causes[i]); window_copy_add(wp, 0, "%s", cfg_causes[i]);
free(cfg_causes[i]); free(cfg_causes[i]);
} }
out:
free(cfg_causes); free(cfg_causes);
cfg_causes = NULL; cfg_causes = NULL;
cfg_ncauses = 0; cfg_ncauses = 0;

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: client.c,v 1.166 2026/07/10 15:45:11 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -239,13 +239,10 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
pid_t ppid; pid_t ppid;
enum msgtype msg; enum msgtype msg;
struct termios tio, saved_tio; struct termios tio, saved_tio;
size_t size, linesize = 0; size_t size;
ssize_t linelen; char **caps = NULL, *cause;
char *line = NULL, **caps = NULL, *cause;
u_int ncaps = 0; u_int ncaps = 0;
struct args_value *values;
/* Ignore SIGCHLD now or daemon() in the server will leave a zombie. */
signal(SIGCHLD, SIG_IGN);
/* Set up the initial command. */ /* Set up the initial command. */
if (shell_command != NULL) { if (shell_command != NULL) {
@@ -258,17 +255,20 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
msg = MSG_COMMAND; msg = MSG_COMMAND;
/* /*
* It sucks parsing the command string twice (in client and * It's annoying parsing the command string twice (in client
* later in server) but it is necessary to get the start server * and later in server) but it is necessary to get the start
* flag. * server flag.
*/ */
pr = cmd_parse_from_arguments(argc, argv, NULL); values = args_from_vector(argc, argv);
pr = cmd_parse_from_arguments(values, argc, NULL);
if (pr->status == CMD_PARSE_SUCCESS) { if (pr->status == CMD_PARSE_SUCCESS) {
if (cmd_list_any_have(pr->cmdlist, CMD_STARTSERVER)) if (cmd_list_any_have(pr->cmdlist, CMD_STARTSERVER))
flags |= CLIENT_STARTSERVER; flags |= CLIENT_STARTSERVER;
cmd_list_free(pr->cmdlist); cmd_list_free(pr->cmdlist);
} else } else
free(pr->error); free(pr->error);
args_free_values(values, argc);
free(values);
} }
/* Create client process structure (starts logging). */ /* Create client process structure (starts logging). */
@@ -280,6 +280,12 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
log_debug("flags are %#llx", (unsigned long long)client_flags); log_debug("flags are %#llx", (unsigned long long)client_flags);
/* Initialize the client socket and start the server. */ /* Initialize the client socket and start the server. */
#ifdef HAVE_SYSTEMD
if (systemd_activated()) {
/* socket-based activation, do not even try to be a client. */
fd = server_start(client_proc, flags, base, 0, NULL);
} else
#endif
fd = client_connect(base, socket_path, client_flags); fd = client_connect(base, socket_path, client_flags);
if (fd == -1) { if (fd == -1) {
if (errno == ECONNREFUSED) { if (errno == ECONNREFUSED) {
@@ -357,6 +363,7 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
/* Send identify messages. */ /* Send identify messages. */
client_send_identify(ttynam, termname, caps, ncaps, cwd, feat); client_send_identify(ttynam, termname, caps, ncaps, cwd, feat);
tty_term_free_list(caps, ncaps); tty_term_free_list(caps, ncaps);
proc_flush_peer(client_peer);
/* Send first command. */ /* Send first command. */
if (msg == MSG_COMMAND) { if (msg == MSG_COMMAND) {
@@ -399,11 +406,6 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
client_exec(client_execshell, client_execcmd); client_exec(client_execshell, client_execcmd);
} }
/* Restore streams to blocking. */
setblocking(STDIN_FILENO, 1);
setblocking(STDOUT_FILENO, 1);
setblocking(STDERR_FILENO, 1);
/* Print the exit message, if any, and exit. */ /* Print the exit message, if any, and exit. */
if (client_attached) { if (client_attached) {
if (client_exitreason != CLIENT_EXIT_NONE) if (client_exitreason != CLIENT_EXIT_NONE)
@@ -418,15 +420,8 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
else else
printf("%%exit\n"); printf("%%exit\n");
fflush(stdout); fflush(stdout);
if (client_flags & CLIENT_CONTROL_WAITEXIT) { if (client_flags & CLIENT_CONTROL_WAITEXIT)
setvbuf(stdin, NULL, _IOLBF, 0); control_wait_exit(STDIN_FILENO);
for (;;) {
linelen = getline(&line, &linesize, stdin);
if (linelen <= 1)
break;
}
free(line);
}
if (client_flags & CLIENT_CONTROLCONTROL) { if (client_flags & CLIENT_CONTROLCONTROL) {
printf("\033\\"); printf("\033\\");
fflush(stdout); fflush(stdout);
@@ -434,6 +429,12 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
} }
} else if (client_exitreason != CLIENT_EXIT_NONE) } else if (client_exitreason != CLIENT_EXIT_NONE)
fprintf(stderr, "%s\n", client_exit_message()); fprintf(stderr, "%s\n", client_exit_message());
/* Restore the streams to blocking. */
setblocking(STDIN_FILENO, 1);
setblocking(STDOUT_FILENO, 1);
setblocking(STDERR_FILENO, 1);
return (client_exitval); return (client_exitval);
} }
@@ -444,11 +445,12 @@ client_send_identify(const char *ttynam, const char *termname, char **caps,
{ {
char **ss; char **ss;
size_t sslen; size_t sslen;
int fd, flags = client_flags; int fd;
uint64_t flags = client_flags;
pid_t pid; pid_t pid;
u_int i; u_int i;
proc_send(client_peer, MSG_IDENTIFY_FLAGS, -1, &flags, sizeof flags); proc_send(client_peer, MSG_IDENTIFY_LONGFLAGS, -1, &flags, sizeof flags);
proc_send(client_peer, MSG_IDENTIFY_LONGFLAGS, -1, &client_flags, proc_send(client_peer, MSG_IDENTIFY_LONGFLAGS, -1, &client_flags,
sizeof client_flags); sizeof client_flags);
@@ -489,20 +491,10 @@ client_send_identify(const char *ttynam, const char *termname, char **caps,
static __dead void static __dead void
client_exec(const char *shell, const char *shellcmd) client_exec(const char *shell, const char *shellcmd)
{ {
const char *name, *ptr; char *argv0;
char *argv0;
log_debug("shell %s, command %s", shell, shellcmd); log_debug("shell %s, command %s", shell, shellcmd);
argv0 = shell_argv0(shell, !!(client_flags & CLIENT_LOGIN));
ptr = strrchr(shell, '/');
if (ptr != NULL && *(ptr + 1) != '\0')
name = ptr + 1;
else
name = shell;
if (client_flags & CLIENT_LOGIN)
xasprintf(&argv0, "-%s", name);
else
xasprintf(&argv0, "%s", name);
setenv("SHELL", shell, 1); setenv("SHELL", shell, 1);
proc_clear_signals(client_proc, 1); proc_clear_signals(client_proc, 1);
@@ -522,12 +514,23 @@ client_signal(int sig)
{ {
struct sigaction sigact; struct sigaction sigact;
int status; int status;
pid_t pid;
log_debug("%s: %s", __func__, strsignal(sig)); log_debug("%s: %s", __func__, strsignal(sig));
if (sig == SIGCHLD) if (sig == SIGCHLD) {
waitpid(WAIT_ANY, &status, WNOHANG); for (;;) {
else if (!client_attached) { pid = waitpid(WAIT_ANY, &status, WNOHANG);
if (sig == SIGTERM) if (pid == 0)
break;
if (pid == -1) {
if (errno == ECHILD)
break;
log_debug("waitpid failed: %s",
strerror(errno));
}
}
} else if (!client_attached) {
if (sig == SIGTERM || sig == SIGHUP)
proc_exit(client_proc); proc_exit(client_proc);
} else { } else {
switch (sig) { switch (sig) {
@@ -689,6 +692,9 @@ client_dispatch_wait(struct imsg *imsg)
!(client_flags & CLIENT_CONTROL), client_file_check_cb, !(client_flags & CLIENT_CONTROL), client_file_check_cb,
NULL); NULL);
break; break;
case MSG_READ_CANCEL:
file_read_cancel(&client_files, imsg);
break;
case MSG_WRITE_OPEN: case MSG_WRITE_OPEN:
file_write_open(&client_files, client_peer, imsg, 1, file_write_open(&client_files, client_peer, imsg, 1,
!(client_flags & CLIENT_CONTROL), client_file_check_cb, !(client_flags & CLIENT_CONTROL), client_file_check_cb,

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-attach-session.c,v 1.91 2026/07/10 13:38:45 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -37,13 +37,13 @@ const struct cmd_entry cmd_attach_session_entry = {
.name = "attach-session", .name = "attach-session",
.alias = "attach", .alias = "attach",
.args = { "c:dEf:rt:x", 0, 0 }, .args = { "c:dEf:rt:x", 0, 0, NULL },
.usage = "[-dErx] [-c working-directory] [-f flags] " .usage = "[-dErx] [-c working-directory] [-f flags] "
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
/* -t is special */ /* -t is special */
.flags = CMD_STARTSERVER, .flags = CMD_STARTSERVER|CMD_READONLY,
.exec = cmd_attach_session_exec .exec = cmd_attach_session_exec
}; };
@@ -61,6 +61,7 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
struct window_pane *wp; struct window_pane *wp;
char *cwd, *cause; char *cwd, *cause;
enum msgtype msgtype; enum msgtype msgtype;
uid_t uid;
if (RB_EMPTY(&sessions)) { if (RB_EMPTY(&sessions)) {
cmdq_error(item, "no sessions"); cmdq_error(item, "no sessions");
@@ -69,6 +70,7 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
if (c == NULL) if (c == NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (server_client_check_nested(c)) { if (server_client_check_nested(c)) {
cmdq_error(item, "sessions should be nested with care, " cmdq_error(item, "sessions should be nested with care, "
"unset $TMUX to force"); "unset $TMUX to force");
@@ -105,8 +107,16 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
} }
if (fflag) if (fflag)
server_client_set_flags(c, fflag); server_client_set_flags(c, fflag);
if (rflag) if (rflag) {
if (c->flags & CLIENT_READONLY) {
uid = proc_get_peer_uid(c->peer);
if (uid != getuid()) {
cmdq_error(item, "client is read-only");
return (CMD_RETURN_ERROR);
}
}
c->flags |= (CLIENT_READONLY|CLIENT_IGNORESIZE); c->flags |= (CLIENT_READONLY|CLIENT_IGNORESIZE);
}
c->last_session = c->session; c->last_session = c->session;
if (c->session != NULL) { if (c->session != NULL) {
@@ -124,17 +134,9 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
if (!Eflag) if (!Eflag)
environ_update(s->options, c->environ, s->environ); environ_update(s->options, c->environ, s->environ);
c->session = s; server_client_set_session(c, s);
if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT) if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT)
server_client_set_key_table(c, NULL); server_client_set_key_table(c, NULL);
tty_update_client_offset(c);
status_timer_start(c);
notify_client("client-session-changed", c);
session_update_activity(s, NULL);
gettimeofday(&s->last_attached_time, NULL);
server_redraw_client(c);
s->curw->flags &= ~WINLINK_ALERTFLAGS;
s->curw->window->latest = c;
} else { } else {
if (server_client_open(c, &cause) != 0) { if (server_client_open(c, &cause) != 0) {
cmdq_error(item, "open terminal failed: %s", cause); cmdq_error(item, "open terminal failed: %s", cause);
@@ -156,25 +158,17 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
if (!Eflag) if (!Eflag)
environ_update(s->options, c->environ, s->environ); environ_update(s->options, c->environ, s->environ);
c->session = s; server_client_set_session(c, s);
server_client_set_key_table(c, NULL); server_client_set_key_table(c, NULL);
tty_update_client_offset(c);
status_timer_start(c);
notify_client("client-session-changed", c);
session_update_activity(s, NULL);
gettimeofday(&s->last_attached_time, NULL);
server_redraw_client(c);
s->curw->flags &= ~WINLINK_ALERTFLAGS;
s->curw->window->latest = c;
if (~c->flags & CLIENT_CONTROL) if (~c->flags & CLIENT_CONTROL)
proc_send(c->peer, MSG_READY, -1, NULL, 0); proc_send(c->peer, MSG_READY, -1, NULL, 0);
notify_client("client-attached", c); events_fire_client("client-attached", c);
c->flags |= CLIENT_ATTACHED; c->flags |= CLIENT_ATTACHED;
} }
recalculate_sizes();
alerts_check_session(s); if (cfg_finished)
server_update_socket(); cfg_show_causes(s);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-bind-key.c,v 1.47 2025/04/09 07:03:04 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -27,20 +27,30 @@
* Bind a key to a command. * Bind a key to a command.
*/ */
static enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmdq_item *); static enum args_parse_type cmd_bind_key_args_parse(struct args *, u_int,
char **);
static enum cmd_retval cmd_bind_key_exec(struct cmd *,
struct cmdq_item *);
const struct cmd_entry cmd_bind_key_entry = { const struct cmd_entry cmd_bind_key_entry = {
.name = "bind-key", .name = "bind-key",
.alias = "bind", .alias = "bind",
.args = { "nrN:T:", 1, -1 }, .args = { "nrN:T:", 1, -1, cmd_bind_key_args_parse },
.usage = "[-nr] [-T key-table] [-N note] key " .usage = "[-nr] [-T key-table] [-N note] key "
"[command [arguments]]", "[command [argument ...]]",
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
.exec = cmd_bind_key_exec .exec = cmd_bind_key_exec
}; };
static enum args_parse_type
cmd_bind_key_args_parse(__unused struct args *args, __unused u_int idx,
__unused char **cause)
{
return (ARGS_PARSE_COMMANDS_OR_STRING);
}
static enum cmd_retval static enum cmd_retval
cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item) cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
{ {
@@ -48,12 +58,13 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
key_code key; key_code key;
const char *tablename, *note = args_get(args, 'N'); const char *tablename, *note = args_get(args, 'N');
struct cmd_parse_result *pr; struct cmd_parse_result *pr;
char **argv = args->argv; int repeat;
int argc = args->argc, repeat; struct args_value *value;
u_int count = args_count(args);
key = key_string_lookup_string(argv[0]); key = key_string_lookup_string(args_string(args, 0));
if (key == KEYC_NONE || key == KEYC_UNKNOWN) { if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
cmdq_error(item, "unknown key: %s", argv[0]); cmdq_error(item, "unknown key: %s", args_string(args, 0));
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
@@ -65,24 +76,32 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
tablename = "prefix"; tablename = "prefix";
repeat = args_has(args, 'r'); repeat = args_has(args, 'r');
if (argc != 1) { if (count == 1) {
if (argc == 2)
pr = cmd_parse_from_string(argv[1], NULL);
else
pr = cmd_parse_from_arguments(argc - 1, argv + 1, NULL);
switch (pr->status) {
case CMD_PARSE_EMPTY:
cmdq_error(item, "empty command");
return (CMD_RETURN_ERROR);
case CMD_PARSE_ERROR:
cmdq_error(item, "%s", pr->error);
free(pr->error);
return (CMD_RETURN_ERROR);
case CMD_PARSE_SUCCESS:
break;
}
key_bindings_add(tablename, key, note, repeat, pr->cmdlist);
} else
key_bindings_add(tablename, key, note, repeat, NULL); key_bindings_add(tablename, key, note, repeat, NULL);
return (CMD_RETURN_NORMAL);
}
value = args_value(args, 1);
if (count == 2 && value->type == ARGS_COMMANDS) {
key_bindings_add(tablename, key, note, repeat, value->cmdlist);
value->cmdlist->references++;
return (CMD_RETURN_NORMAL);
}
if (count == 2)
pr = cmd_parse_from_string(args_string(args, 1), NULL);
else {
pr = cmd_parse_from_arguments(args_values(args) + 1, count - 1,
NULL);
}
switch (pr->status) {
case CMD_PARSE_ERROR:
cmdq_error(item, "%s", pr->error);
free(pr->error);
return (CMD_RETURN_ERROR);
case CMD_PARSE_SUCCESS:
break;
}
key_bindings_add(tablename, key, note, repeat, pr->cmdlist);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-break-pane.c,v 1.75 2026/07/23 09:38:27 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -34,9 +34,10 @@ const struct cmd_entry cmd_break_pane_entry = {
.name = "break-pane", .name = "break-pane",
.alias = "breakp", .alias = "breakp",
.args = { "abdPF:n:s:t:", 0, 0 }, .args = { "abdPF:n:s:t:Wx:X:y:Y:", 0, 0, NULL },
.usage = "[-abdP] [-F format] [-n window-name] [-s src-pane] " .usage = "[-abdPW] [-F format] [-n window-name] [-s src-pane] "
"[-t dst-window]", "[-t dst-window] [-x width] [-y height] [-X x-position] "
"[-Y y-position]",
.source = { 's', CMD_FIND_PANE, 0 }, .source = { 's', CMD_FIND_PANE, 0 },
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX }, .target = { 't', CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX },
@@ -45,6 +46,46 @@ const struct cmd_entry cmd_break_pane_entry = {
.exec = cmd_break_pane_exec .exec = cmd_break_pane_exec
}; };
static enum cmd_retval
cmd_break_pane_float(struct cmdq_item *item, struct args *args,
struct window *w, struct window_pane *wp)
{
struct layout_cell *lc = wp->layout_cell;
char *cause = NULL;
enum pane_lines lines = window_get_pane_lines(w);
struct layout_geometry *fg = &lc->fg;
if (window_pane_is_floating(wp)) {
cmdq_error(item, "pane is already floating");
return (CMD_RETURN_ERROR);
}
if (w->flags & WINDOW_ZOOMED) {
cmdq_error(item, "can't float a pane while window is zoomed");
return (CMD_RETURN_ERROR);
}
if (layout_floating_args_parse(item, args, lines, w, fg, &cause) != 0) {
cmdq_error(item, "failed to float pane: %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
layout_remove_tile(w, lc);
layout_set_size(lc, fg->sx, fg->sy, fg->xoff, fg->yoff);
lc->flags |= LAYOUT_CELL_FLOATING;
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
if (!args_has(args, 'd'))
window_set_active_pane(w, wp, 1);
layout_fix_offsets(w);
layout_fix_panes(w, NULL);
events_fire_window("window-layout-changed", w);
server_redraw_window(w);
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval static enum cmd_retval
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
@@ -57,10 +98,23 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
struct session *src_s = source->s; struct session *src_s = source->s;
struct session *dst_s = target->s; struct session *dst_s = target->s;
struct window_pane *wp = source->wp; struct window_pane *wp = source->wp;
struct window *w = wl->window; struct window *w = wl->window, *old_w = w;
char *name, *cause, *cp; char *cause, *cp;
int idx = target->idx, before; int idx = target->idx, before, old_idx = wl->idx;
const char *template; const char *template, *name = args_get(args, 'n');
if (wp == w->modal) {
cmdq_error(item, "pane is modal");
return (CMD_RETURN_ERROR);
}
if (args_has(args, 'W'))
return (cmd_break_pane_float(item, args, w, wp));
if (name != NULL && !check_name(name)) {
cmdq_error(item, "invalid window name: %s", name);
return (CMD_RETURN_ERROR);
}
before = args_has(args, 'b'); before = args_has(args, 'b');
if (args_has(args, 'a') || before) { if (args_has(args, 'a') || before) {
@@ -73,19 +127,23 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
} }
server_unzoom_window(w); server_unzoom_window(w);
if (window_count_panes(w) == 1) { if (window_count_panes(w, 1) == 1) {
if (server_link_window(src_s, wl, dst_s, idx, 0, if (server_link_window(src_s, wl, dst_s, idx, 0,
!args_has(args, 'd'), &cause) != 0) { !args_has(args, 'd'), &cause) != 0) {
cmdq_error(item, "%s", cause); cmdq_error(item, "%s", cause);
free(cause); free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
if (args_has(args, 'n')) { if (name != NULL) {
window_set_name(w, args_get(args, 'n')); window_set_name(w, name, 0);
options_set_number(w->options, "automatic-rename", 0); options_set_number(w->options, "automatic-rename", 0);
} }
server_unlink_window(src_s, wl); server_unlink_window(src_s, wl);
return (CMD_RETURN_NORMAL); wl = winlink_find_by_window(&dst_s->windows, w);
if (wl == NULL)
return (CMD_RETURN_ERROR);
window_fire_pane_moved(wp, old_w, old_idx, w, wl->idx);
goto out;
} }
if (idx != -1 && winlink_find_by_index(&dst_s->windows, idx) != NULL) { if (idx != -1 && winlink_find_by_index(&dst_s->windows, idx) != NULL) {
cmdq_error(item, "index in use: %d", idx); cmdq_error(item, "index in use: %d", idx);
@@ -93,32 +151,39 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
} }
TAILQ_REMOVE(&w->panes, wp, entry); TAILQ_REMOVE(&w->panes, wp, entry);
TAILQ_REMOVE(&w->z_index, wp, zentry);
server_client_remove_pane(wp); server_client_remove_pane(wp);
window_lost_pane(w, wp); window_lost_pane(w, wp);
layout_close_pane(wp); layout_close_pane(wp);
w = wp->window = window_create(w->sx, w->sy, w->xpixel, w->ypixel); w = wp->window = window_create(w->sx, w->sy, w->xpixel, w->ypixel);
window_add_ref(w, __func__);
options_set_parent(wp->options, w->options); options_set_parent(wp->options, w->options);
wp->flags |= PANE_STYLECHANGED; wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
TAILQ_INSERT_HEAD(&w->panes, wp, entry); TAILQ_INSERT_HEAD(&w->panes, wp, entry);
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
w->active = wp; w->active = wp;
w->latest = tc; w->latest = tc;
if (!args_has(args, 'n')) { free(w->name);
name = default_window_name(w); if (name == NULL)
window_set_name(w, name); w->name = default_window_name(w);
free(name); else {
} else { w->name = clean_name(name, 0);
window_set_name(w, args_get(args, 'n'));
options_set_number(w->options, "automatic-rename", 0); options_set_number(w->options, "automatic-rename", 0);
} }
window_set_fill_cells(w);
layout_init(w, wp); layout_init(w, wp);
wp->flags |= PANE_CHANGED; wp->flags |= PANE_CHANGED;
colour_palette_from_option(&wp->palette, wp->options);
if (idx == -1) if (idx == -1)
idx = -1 - options_get_number(dst_s->options, "base-index"); idx = -1 - options_get_number(dst_s->options, "base-index");
wl = session_attach(dst_s, w, idx, &cause); /* can't fail */ wl = session_attach(dst_s, w, idx, &cause); /* can't fail */
window_remove_ref(w, __func__);
events_fire_window("window-created", w);
window_fire_pane_moved(wp, old_w, old_idx, w, wl->idx);
if (!args_has(args, 'd')) { if (!args_has(args, 'd')) {
session_select(dst_s, wl->idx); session_select(dst_s, wl->idx);
cmd_find_from_session(current, dst_s, 0); cmd_find_from_session(current, dst_s, 0);
@@ -131,6 +196,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
if (src_s != dst_s) if (src_s != dst_s)
server_status_session_group(dst_s); server_status_session_group(dst_s);
out:
if (args_has(args, 'P')) { if (args_has(args, 'P')) {
if ((template = args_get(args, 'F')) == NULL) if ((template = args_get(args, 'F')) == NULL)
template = BREAK_PANE_TEMPLATE; template = BREAK_PANE_TEMPLATE;

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-capture-pane.c,v 1.68 2026/07/20 11:16:33 nicm Exp $ */
/* /*
* Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net> * Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net>
@@ -29,18 +29,21 @@
static enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmdq_item *); static enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmdq_item *);
static char *cmd_capture_pane_append(char *, size_t *, char *, size_t); static char *cmd_capture_pane_append(char *, size_t *, const char *,
size_t);
static char *cmd_capture_pane_pending(struct args *, struct window_pane *, static char *cmd_capture_pane_pending(struct args *, struct window_pane *,
size_t *); size_t *);
static char *cmd_capture_pane_history(struct args *, struct cmdq_item *, static char *cmd_capture_pane_history(struct args *, struct cmdq_item *,
struct window_pane *, size_t *); struct window_pane *, size_t *);
static char *cmd_capture_pane_hyperlinks(struct grid *, struct screen *,
u_int, u_int *, u_int *, size_t *);
const struct cmd_entry cmd_capture_pane_entry = { const struct cmd_entry cmd_capture_pane_entry = {
.name = "capture-pane", .name = "capture-pane",
.alias = "capturep", .alias = "capturep",
.args = { "ab:CeE:JNpPqS:t:", 0, 0 }, .args = { "ab:CeE:FHJLMNpPqRS:Tt:", 0, 0, NULL },
.usage = "[-aCeJNpPq] " CMD_BUFFER_USAGE " [-E end-line] " .usage = "[-aCeFHJLMNpPqRT] " CMD_BUFFER_USAGE " [-E end-line] "
"[-S start-line] " CMD_TARGET_PANE_USAGE, "[-S start-line] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -53,8 +56,8 @@ const struct cmd_entry cmd_clear_history_entry = {
.name = "clear-history", .name = "clear-history",
.alias = "clearhist", .alias = "clearhist",
.args = { "t:", 0, 0 }, .args = { "Ht:", 0, 0, NULL },
.usage = CMD_TARGET_PANE_USAGE, .usage = "[-H] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -63,7 +66,8 @@ const struct cmd_entry cmd_clear_history_entry = {
}; };
static char * static char *
cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen) cmd_capture_pane_append(char *buf, size_t *len, const char *line,
size_t linelen)
{ {
buf = xrealloc(buf, *len + linelen + 1); buf = xrealloc(buf, *len + linelen + 1);
memcpy(buf + *len, line, linelen); memcpy(buf + *len, line, linelen);
@@ -71,6 +75,108 @@ cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen)
return (buf); return (buf);
} }
static char *
cmd_capture_pane_cell(struct screen *s, u_int xx, u_int yy)
{
struct grid *gd = s->grid;
struct hyperlinks *hl = s->hyperlinks;
struct grid_cell gc;
char *line, *data, *link, *linkid, *f, *b, *u;
char c[UTF8_SIZE + 1];
const char *uri, *iid;
u_int flags;
grid_get_cell(gd, xx, yy, &gc);
memcpy(c, gc.data.data, gc.data.size);
c[gc.data.size] = '\0';
utf8_stravis(&data, c, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL);
if (gc.link != 0 && hyperlinks_get(hl, gc.link, &uri, &iid, NULL)) {
xasprintf(&link, "%s", uri);
if (iid != NULL && *iid != '\0')
xasprintf(&linkid, "%s", iid);
else
xasprintf(&linkid, "NONE");
} else {
xasprintf(&link, "NONE");
xasprintf(&linkid, "NONE");
}
flags = gc.flags;
if (gc.fg & COLOUR_FLAG_256)
flags |= GRID_FLAG_FG256;
if (gc.bg & COLOUR_FLAG_256)
flags |= GRID_FLAG_BG256;
xasprintf(&f, "%s[%x]", colour_tostring(gc.fg), gc.fg);
xasprintf(&b, "%s[%x]", colour_tostring(gc.bg), gc.bg);
xasprintf(&u, "%s[%x]", colour_tostring(gc.us), gc.us);
xasprintf(&line, "\t\tC %u,%u data=(%u,%u,%s) flags=%s[%x] "
"attr=%s[%x] fg=%s bg=%s us=%s link=%s linkid=%s\n",
yy, xx, gc.data.width, gc.data.size, data,
grid_cell_flags_string(flags), flags,
grid_cell_attr_string(gc.attr), gc.attr, f, b, u, link, linkid);
free(f);
free(b);
free(u);
free(link);
free(linkid);
free(data);
return (line);
}
static char *
cmd_capture_pane_grid(struct window_pane *wp, size_t *len)
{
struct screen *s = &wp->base;
struct grid *gd = s->grid;
struct grid_line *gl;
struct osc133_data *od;
char *buf = xstrdup(""), *line;
char p[11];
u_int yy, xx, total = gd->hsize + gd->sy;
xasprintf(&line, "G %ux%u (%u/%u)\n", gd->sx, gd->sy, gd->hsize,
gd->hlimit);
buf = cmd_capture_pane_append(buf, len, line, strlen(line));
free(line);
for (yy = 0; yy < total; yy++) {
gl = grid_get_line(gd, yy);
if (yy < gd->hsize)
snprintf(p, sizeof p, "-");
else
snprintf(p, sizeof p, "%u", yy - gd->hsize);
od = &gl->osc133_data;
if (gl->flags & GRID_LINE_OSC133_FLAGS) {
xasprintf(&line, "\tL %u (%s) flags=%s[%x] "
"%u/%u osc133=%u,%u,%u,%u,%u\n", yy, p,
grid_line_flags_string(gl->flags), gl->flags,
gl->cellused, gl->cellsize, od->prompt_col,
od->cmd_col, od->out_start_col,
od->out_end_col, od->exit_status);
} else {
xasprintf(&line, "\tL %u (%s) flags=%s[%x] "
"%u/%u\n", yy, p,
grid_line_flags_string(gl->flags), gl->flags,
gl->cellused, gl->cellsize);
}
buf = cmd_capture_pane_append(buf, len, line, strlen(line));
free(line);
for (xx = 0; xx < gd->sx; xx++) {
line = cmd_capture_pane_cell(s, xx, yy);
buf = cmd_capture_pane_append(buf, len, line,
strlen(line));
free(line);
}
}
return (buf);
}
static char * static char *
cmd_capture_pane_pending(struct args *args, struct window_pane *wp, cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
size_t *len) size_t *len)
@@ -103,18 +209,62 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
return (buf); return (buf);
} }
static char *
cmd_capture_pane_hyperlinks(struct grid *gd, struct screen *s, u_int py,
u_int *links, u_int *nlinks, size_t *len)
{
const struct grid_line *gl = grid_peek_line(gd, py);
struct grid_cell gc;
const char *uri;
char *line = xstrdup("");
u_int i, j;
*len = 0;
if (s->hyperlinks == NULL || (~gl->flags & GRID_LINE_HYPERLINK))
return (line);
for (i = 0; i < gl->cellused; i++) {
grid_get_cell(gd, i, py, &gc);
if (gc.link == 0)
continue;
for (j = 0; j < *nlinks; j++) {
if (links[j] == gc.link)
break;
}
if (j != *nlinks)
continue;
if (!hyperlinks_get(s->hyperlinks, gc.link, &uri, NULL, NULL))
continue;
if (*nlinks == gd->sx)
break;
links[(*nlinks)++] = gc.link;
if (*len != 0)
line = cmd_capture_pane_append(line, len, " ", 1);
line = cmd_capture_pane_append(line, len, uri, strlen(uri));
}
return (line);
}
static char * static char *
cmd_capture_pane_history(struct args *args, struct cmdq_item *item, cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
struct window_pane *wp, size_t *len) struct window_pane *wp, size_t *len)
{ {
struct grid *gd; struct grid *gd;
const struct grid_line *gl; const struct grid_line *gl;
struct grid_cell *gc = NULL; struct screen *s;
int n, with_codes, escape_c0, join_lines, no_trim; struct grid_cell *gc = NULL;
u_int i, sx, top, bottom, tmp; struct window_mode_entry *wme;
char *cause, *buf, *line; int n, join_lines, number_lines, flags = 0;
const char *Sflag, *Eflag; int show_flags, hyperlinks;
size_t linelen; u_int *links = NULL, nlinks = 0;
u_int i, sx, top, bottom, tmp;
char *cause, *buf = NULL, *line, b[64], *cp;
const char *Sflag, *Eflag;
size_t linelen;
sx = screen_size_x(&wp->base); sx = screen_size_x(&wp->base);
if (args_has(args, 'a')) { if (args_has(args, 'a')) {
@@ -126,18 +276,31 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
} }
return (xstrdup("")); return (xstrdup(""));
} }
} else s = &wp->base;
} else if (args_has(args, 'M')) {
wme = TAILQ_FIRST(&wp->modes);
if (wme != NULL && wme->mode->get_screen != NULL) {
s = wme->mode->get_screen (wme);
gd = s->grid;
} else {
s = &wp->base;
gd = wp->base.grid;
}
} else {
s = &wp->base;
gd = wp->base.grid; gd = wp->base.grid;
}
Sflag = args_get(args, 'S'); Sflag = args_get(args, 'S');
if (Sflag != NULL && strcmp(Sflag, "-") == 0) if (Sflag != NULL && strcmp(Sflag, "-") == 0)
top = 0; top = 0;
else { else {
n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause); n = args_strtonum_and_expand(args, 'S', INT_MIN, SHRT_MAX,
item, &cause);
if (cause != NULL) { if (cause != NULL) {
top = gd->hsize; top = gd->hsize;
free(cause); free(cause);
} else if (n < 0 && (u_int) -n > gd->hsize) } else if (n < 0 && (u_int)-n > gd->hsize)
top = 0; top = 0;
else else
top = gd->hsize + n; top = gd->hsize + n;
@@ -149,11 +312,12 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
if (Eflag != NULL && strcmp(Eflag, "-") == 0) if (Eflag != NULL && strcmp(Eflag, "-") == 0)
bottom = gd->hsize + gd->sy - 1; bottom = gd->hsize + gd->sy - 1;
else { else {
n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause); n = args_strtonum_and_expand(args, 'E', INT_MIN, SHRT_MAX,
item, &cause);
if (cause != NULL) { if (cause != NULL) {
bottom = gd->hsize + gd->sy - 1; bottom = gd->hsize + gd->sy - 1;
free(cause); free(cause);
} else if (n < 0 && (u_int) -n > gd->hsize) } else if (n < 0 && (u_int)-n > gd->hsize)
bottom = 0; bottom = 0;
else else
bottom = gd->hsize + n; bottom = gd->hsize + n;
@@ -167,17 +331,66 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
top = tmp; top = tmp;
} }
with_codes = args_has(args, 'e');
escape_c0 = args_has(args, 'C');
join_lines = args_has(args, 'J'); join_lines = args_has(args, 'J');
no_trim = args_has(args, 'N'); if (args_has(args, 'e'))
flags |= GRID_STRING_WITH_SEQUENCES;
if (args_has(args, 'C'))
flags |= GRID_STRING_ESCAPE_SEQUENCES;
if (!join_lines && !args_has(args, 'T'))
flags |= GRID_STRING_EMPTY_CELLS;
if (!join_lines && !args_has(args, 'N'))
flags |= GRID_STRING_TRIM_SPACES;
number_lines = args_has(args, 'L');
show_flags = args_has(args, 'F');
hyperlinks = args_has(args, 'H');
if (hyperlinks)
links = xreallocarray(NULL, gd->sx, sizeof *links);
buf = NULL;
for (i = top; i <= bottom; i++) { for (i = top; i <= bottom; i++) {
line = grid_string_cells(gd, 0, i, sx, &gc, with_codes, if (hyperlinks) {
escape_c0, !join_lines && !no_trim); line = cmd_capture_pane_hyperlinks(gd, s, i, links,
linelen = strlen(line); &nlinks, &linelen);
} else {
line = grid_string_cells(gd, 0, i, sx, &gc, flags, s);
linelen = strlen(line);
}
if (hyperlinks && linelen == 0) {
free(line);
continue;
}
if (number_lines) {
if (i >= gd->hsize)
n = i - gd->hsize;
else
n = (int)i - (int)gd->hsize;
n = snprintf(b, sizeof b, "%d ", n);
if (n >= 0)
buf = cmd_capture_pane_append(buf, len, b, n);
}
if (show_flags) {
cp = b;
*cp = '\0';
gl = grid_peek_line(gd, i);
if (gl->flags & GRID_LINE_DEAD)
*cp++ = 'D';
if (gl->flags & GRID_LINE_HYPERLINK)
*cp++ = 'H';
if (gl->flags & GRID_LINE_START_OUTPUT)
*cp++ = 'O';
if (gl->flags & GRID_LINE_START_PROMPT)
*cp++ = 'P';
if (gl->flags & GRID_LINE_WRAPPED)
*cp++ = 'W';
if (gl->flags & GRID_LINE_EXTENDED)
*cp++ = 'X';
if (b == cp)
*cp++ = '-';
*cp++ = ' ';
*cp = '\0';
buf = cmd_capture_pane_append(buf, len, b, strlen (b));
}
buf = cmd_capture_pane_append(buf, len, line, linelen); buf = cmd_capture_pane_append(buf, len, line, linelen);
gl = grid_peek_line(gd, i); gl = grid_peek_line(gd, i);
@@ -186,6 +399,9 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
free(line); free(line);
} }
free(links);
if (buf == NULL)
buf = xstrdup("");
return (buf); return (buf);
} }
@@ -202,11 +418,16 @@ cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
if (cmd_get_entry(self) == &cmd_clear_history_entry) { if (cmd_get_entry(self) == &cmd_clear_history_entry) {
window_pane_reset_mode_all(wp); window_pane_reset_mode_all(wp);
grid_clear_history(wp->base.grid); grid_clear_history(wp->base.grid);
if (args_has(args, 'H'))
screen_reset_hyperlinks(wp->screen);
server_redraw_window(wp->window);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
len = 0; len = 0;
if (args_has(args, 'P')) if (args_has(args, 'R'))
buf = cmd_capture_pane_grid(wp, &len);
else if (args_has(args, 'P') && !args_has(args, 'H'))
buf = cmd_capture_pane_pending(args, wp, &len); buf = cmd_capture_pane_pending(args, wp, &len);
else else
buf = cmd_capture_pane_history(args, item, wp, &len); buf = cmd_capture_pane_history(args, item, wp, &len);
@@ -226,8 +447,8 @@ cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
} }
file_print_buffer(c, buf, len); file_print_buffer(c, buf, len);
file_print(c, "\n"); file_print(c, "\n");
free(buf);
} }
free(buf);
} else { } else {
bufname = NULL; bufname = NULL;
if (args_has(args, 'b')) if (args_has(args, 'b'))

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-choose-tree.c,v 1.58 2026/07/14 17:17:17 nicm Exp $ */
/* /*
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.org> * Copyright (c) 2012 Thomas Adam <thomas@xteddy.org>
@@ -24,14 +24,17 @@
* Enter a mode. * Enter a mode.
*/ */
static enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmdq_item *); static enum args_parse_type cmd_choose_tree_args_parse(struct args *args,
u_int idx, char **cause);
static enum cmd_retval cmd_choose_tree_exec(struct cmd *,
struct cmdq_item *);
const struct cmd_entry cmd_choose_tree_entry = { const struct cmd_entry cmd_choose_tree_entry = {
.name = "choose-tree", .name = "choose-tree",
.alias = NULL, .alias = NULL,
.args = { "F:f:GK:NO:rst:wZ", 0, 1 }, .args = { "F:f:GhK:kNO:rst:wyZ", 0, 1, cmd_choose_tree_args_parse },
.usage = "[-GNrswZ] [-F format] [-f filter] [-K key-format] " .usage = "[-GhkNrswZ] [-F format] [-f filter] [-K key-format] "
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]", "[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -44,8 +47,8 @@ const struct cmd_entry cmd_choose_client_entry = {
.name = "choose-client", .name = "choose-client",
.alias = NULL, .alias = NULL,
.args = { "F:f:K:NO:rt:Z", 0, 1 }, .args = { "F:f:hiK:kNO:rt:yZ", 0, 1, cmd_choose_tree_args_parse },
.usage = "[-NrZ] [-F format] [-f filter] [-K key-format] " .usage = "[-hikNrZ] [-F format] [-f filter] [-K key-format] "
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]", "[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -58,8 +61,8 @@ const struct cmd_entry cmd_choose_buffer_entry = {
.name = "choose-buffer", .name = "choose-buffer",
.alias = NULL, .alias = NULL,
.args = { "F:f:K:NO:rt:Z", 0, 1 }, .args = { "F:f:K:kNO:rt:yZ", 0, 1, cmd_choose_tree_args_parse },
.usage = "[-NrZ] [-F format] [-f filter] [-K key-format] " .usage = "[-kNrZ] [-F format] [-f filter] [-K key-format] "
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]", "[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -72,8 +75,8 @@ const struct cmd_entry cmd_customize_mode_entry = {
.name = "customize-mode", .name = "customize-mode",
.alias = NULL, .alias = NULL,
.args = { "F:f:Nt:Z", 0, 0 }, .args = { "F:f:kNt:yZ", 0, 0, NULL },
.usage = "[-NZ] [-F format] [-f filter] " CMD_TARGET_PANE_USAGE, .usage = "[-kNZ] [-F format] [-f filter] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -81,6 +84,41 @@ const struct cmd_entry cmd_customize_mode_entry = {
.exec = cmd_choose_tree_exec .exec = cmd_choose_tree_exec
}; };
const struct cmd_entry cmd_switch_mode_entry = {
.name = "switch-mode",
.alias = NULL,
.args = { "F:kst:wZ", 0, 1, cmd_choose_tree_args_parse },
.usage = "[-kswZ] [-F format] " CMD_TARGET_PANE_USAGE " [command]",
.target = { 't', CMD_FIND_PANE, 0 },
.flags = 0,
.exec = cmd_choose_tree_exec
};
const struct cmd_entry cmd_display_panes_entry = {
.name = "display-panes",
.alias = "displayp",
.args = { "d:kNs:t:Z", 0, 1, cmd_choose_tree_args_parse },
.usage = "[-kNZ] [-d duration] [-s source-window] "
CMD_TARGET_PANE_USAGE " [template]",
.source = { 's', CMD_FIND_WINDOW, 0 },
.target = { 't', CMD_FIND_PANE, 0 },
.flags = CMD_AFTERHOOK,
.exec = cmd_choose_tree_exec
};
static enum args_parse_type
cmd_choose_tree_args_parse(__unused struct args *args, __unused u_int idx,
__unused char **cause)
{
return (ARGS_PARSE_COMMANDS_OR_STRING);
}
static enum cmd_retval static enum cmd_retval
cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item) cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
{ {
@@ -88,9 +126,16 @@ cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
const struct window_mode *mode; const struct window_mode *mode;
enum sort_order order;
order = sort_order_from_string(args_get(args, 'O'));
if (order == SORT_END && args_has(args, 'O')) {
cmdq_error(item, "invalid sort order");
return (CMD_RETURN_ERROR);
}
if (cmd_get_entry(self) == &cmd_choose_buffer_entry) { if (cmd_get_entry(self) == &cmd_choose_buffer_entry) {
if (paste_get_top(NULL) == NULL) if (paste_is_empty())
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
mode = &window_buffer_mode; mode = &window_buffer_mode;
} else if (cmd_get_entry(self) == &cmd_choose_client_entry) { } else if (cmd_get_entry(self) == &cmd_choose_client_entry) {
@@ -99,9 +144,13 @@ cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
mode = &window_client_mode; mode = &window_client_mode;
} else if (cmd_get_entry(self) == &cmd_customize_mode_entry) } else if (cmd_get_entry(self) == &cmd_customize_mode_entry)
mode = &window_customize_mode; mode = &window_customize_mode;
else if (cmd_get_entry(self) == &cmd_switch_mode_entry)
mode = &window_switch_mode;
else if (cmd_get_entry(self) == &cmd_display_panes_entry)
mode = &window_panes_mode;
else else
mode = &window_tree_mode; mode = &window_tree_mode;
window_pane_set_mode(wp, NULL, mode, target, args); window_pane_set_mode(wp, NULL, mode, item, target, args);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-command-prompt.c,v 1.75 2026/06/25 11:39:11 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -29,91 +29,141 @@
* Prompt for command in client. * Prompt for command in client.
*/ */
static enum cmd_retval cmd_command_prompt_exec(struct cmd *, static enum args_parse_type cmd_command_prompt_args_parse(struct args *,
struct cmdq_item *); u_int, char **);
static enum cmd_retval cmd_command_prompt_exec(struct cmd *,
struct cmdq_item *);
static int cmd_command_prompt_callback(struct client *, void *, static enum prompt_result cmd_command_prompt_callback(struct client *, void *,
const char *, int); const char *, enum prompt_key_result);
static void cmd_command_prompt_free(void *); static void cmd_command_prompt_free(void *);
const struct cmd_entry cmd_command_prompt_entry = { const struct cmd_entry cmd_command_prompt_entry = {
.name = "command-prompt", .name = "command-prompt",
.alias = NULL, .alias = NULL,
.args = { "1kiI:Np:Tt:W", 0, 1 }, .args = { "1CbeFiklI:NPp:t:T:", 0, 1, cmd_command_prompt_args_parse },
.usage = "[-1kiNTW] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " " .usage = "[-1CbeFiklNP] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE
"[template]", " [-T prompt-type] [template]",
.flags = CMD_CLIENT_TFLAG, .flags = CMD_CLIENT_TFLAG,
.exec = cmd_command_prompt_exec .exec = cmd_command_prompt_exec
}; };
struct cmd_command_prompt_cdata { struct cmd_command_prompt_prompt {
int flags; char *input;
char *prompt;
char *inputs;
char *next_input;
char *prompts;
char *next_prompt;
char *template;
int idx;
}; };
struct cmd_command_prompt_cdata {
struct cmdq_item *item;
struct args_command_state *state;
int flags;
enum prompt_type prompt_type;
struct window_pane *wp;
struct cmd_command_prompt_prompt *prompts;
u_int count;
u_int current;
int argc;
char **argv;
};
static enum args_parse_type
cmd_command_prompt_args_parse(__unused struct args *args, __unused u_int idx,
__unused char **cause)
{
return (ARGS_PARSE_COMMANDS_OR_STRING);
}
static enum cmd_retval static enum cmd_retval
cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item) cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
const char *inputs, *prompts; const char *type, *s, *input;
struct cmd_command_prompt_cdata *cdata; struct cmd_command_prompt_cdata *cdata;
char *prompt, *ptr, *input = NULL; char *tmp, *prompts, *prompt, *next_prompt;
size_t n; char *inputs = NULL, *next_input;
struct window_pane *wp = target->wp;
u_int count = args_count(args);
int wait = !args_has(args, 'b'), space = 1;
int pane = args_has(args, 'P');
if (tc->prompt_string != NULL) if (pane) {
if (wp == NULL || window_pane_has_prompt(wp))
return (CMD_RETURN_NORMAL);
} else if (tc->prompt != NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (args_has(args, 'i'))
wait = 0;
cdata = xcalloc(1, sizeof *cdata); cdata = xcalloc(1, sizeof *cdata);
if (wait)
cdata->item = item;
if (pane)
cdata->wp = wp;
cdata->state = args_make_commands_prepare(self, item, 0, "%1", wait,
args_has(args, 'F'));
cdata->inputs = NULL; if ((s = args_get(args, 'p')) == NULL) {
cdata->next_input = NULL; if (count != 0) {
tmp = args_make_commands_get_command(cdata->state);
cdata->prompts = NULL; xasprintf(&prompts, "(%s)", tmp);
cdata->next_prompt = NULL; free(tmp);
} else {
cdata->template = NULL; prompts = xstrdup(":");
cdata->idx = 1; space = 0;
}
if (args->argc != 0) next_prompt = prompts;
cdata->template = xstrdup(args->argv[0]);
else
cdata->template = xstrdup("%1");
if ((prompts = args_get(args, 'p')) != NULL)
cdata->prompts = xstrdup(prompts);
else if (args->argc != 0) {
n = strcspn(cdata->template, " ,");
xasprintf(&cdata->prompts, "(%.*s) ", (int) n, cdata->template);
} else } else
cdata->prompts = xstrdup(":"); next_prompt = prompts = xstrdup(s);
if ((s = args_get(args, 'I')) != NULL)
/* Get first prompt. */ next_input = inputs = xstrdup(s);
cdata->next_prompt = cdata->prompts;
ptr = strsep(&cdata->next_prompt, ",");
if (prompts == NULL)
prompt = xstrdup(ptr);
else else
xasprintf(&prompt, "%s ", ptr); next_input = NULL;
if (args_has(args, 'l')) {
cdata->prompts = xcalloc(1, sizeof *cdata->prompts);
cdata->prompts[0].prompt = prompts;
cdata->prompts[0].input = inputs;
cdata->count = 1;
} else {
while ((prompt = strsep(&next_prompt, ",")) != NULL) {
cdata->prompts = xreallocarray(cdata->prompts,
cdata->count + 1, sizeof *cdata->prompts);
if (!space)
tmp = xstrdup(prompt);
else
xasprintf(&tmp, "%s ", prompt);
cdata->prompts[cdata->count].prompt = tmp;
/* Get initial prompt input. */ if (next_input != NULL) {
if ((inputs = args_get(args, 'I')) != NULL) { input = strsep(&next_input, ",");
cdata->inputs = xstrdup(inputs); if (input == NULL)
cdata->next_input = cdata->inputs; input = "";
input = strsep(&cdata->next_input, ","); } else
input = "";
cdata->prompts[cdata->count].input = xstrdup(input);
cdata->count++;
}
free(inputs);
free(prompts);
} }
if ((type = args_get(args, 'T')) != NULL) {
cdata->prompt_type = prompt_type(type);
if (cdata->prompt_type == PROMPT_TYPE_INVALID) {
cmdq_error(item, "unknown type: %s", type);
cmd_command_prompt_free(cdata);
return (CMD_RETURN_ERROR);
}
} else
cdata->prompt_type = PROMPT_TYPE_COMMAND;
if (args_has(args, '1')) if (args_has(args, '1'))
cdata->flags |= PROMPT_SINGLE; cdata->flags |= PROMPT_SINGLE;
else if (args_has(args, 'N')) else if (args_has(args, 'N'))
@@ -122,72 +172,115 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
cdata->flags |= PROMPT_INCREMENTAL; cdata->flags |= PROMPT_INCREMENTAL;
else if (args_has(args, 'k')) else if (args_has(args, 'k'))
cdata->flags |= PROMPT_KEY; cdata->flags |= PROMPT_KEY;
else if (args_has(args, 'W')) else if (args_has(args, 'e'))
cdata->flags |= PROMPT_WINDOW; cdata->flags |= PROMPT_BSPACE_EXIT;
else if (args_has(args, 'T')) if (args_has(args, 'C'))
cdata->flags |= PROMPT_TARGET; cdata->flags |= PROMPT_NOFREEZE;
status_prompt_set(tc, target, prompt, input, if (pane) {
cmd_command_prompt_callback, cmd_command_prompt_free, cdata, cdata->flags |= PROMPT_ISPANE;
cdata->flags); window_pane_set_prompt(wp, tc, target, cdata->prompts[0].prompt,
free(prompt); cdata->prompts[0].input, cmd_command_prompt_callback,
cmd_command_prompt_free, cdata, cdata->flags,
cdata->prompt_type);
} else {
status_prompt_set(tc, target, cdata->prompts[0].prompt,
cdata->prompts[0].input, cmd_command_prompt_callback,
cmd_command_prompt_free, cdata, cdata->flags,
cdata->prompt_type);
}
return (CMD_RETURN_NORMAL); if (!wait)
return (CMD_RETURN_NORMAL);
return (CMD_RETURN_WAIT);
} }
static int static enum prompt_result
cmd_command_prompt_callback(struct client *c, void *data, const char *s, cmd_command_prompt_callback(struct client *c, void *data, const char *s,
int done) enum prompt_key_result key)
{ {
struct cmd_command_prompt_cdata *cdata = data; struct cmd_command_prompt_cdata *cdata = data;
char *new_template, *prompt, *ptr, *error; char *error;
char *input = NULL; struct cmdq_item *item = cdata->item, *new_item;
enum cmd_parse_status status; struct cmd_list *cmdlist;
struct cmd_command_prompt_prompt *prompt;
int argc = 0;
char **argv = NULL;
if (s == NULL) if (s == NULL || key == PROMPT_KEY_MOVE)
return (0); goto out;
if (done && (cdata->flags & PROMPT_INCREMENTAL))
return (0);
new_template = cmd_template_replace(cdata->template, s, cdata->idx); if (key == PROMPT_KEY_CLOSE) {
if (done) { if (cdata->flags & PROMPT_INCREMENTAL)
free(cdata->template); goto out;
cdata->template = new_template; cmd_append_argv(&cdata->argc, &cdata->argv, s);
if (++cdata->current != cdata->count) {
prompt = &cdata->prompts[cdata->current];
if (cdata->wp != NULL) {
window_pane_update_prompt(cdata->wp,
prompt->prompt, prompt->input);
} else
status_prompt_update(c, prompt->prompt,
prompt->input);
return (PROMPT_CONTINUE);
}
} }
/* argc = cdata->argc;
* Check if there are more prompts; if so, get its respective input argv = cmd_copy_argv(cdata->argc, cdata->argv);
* and update the prompt data. if (key != PROMPT_KEY_CLOSE)
*/ cmd_append_argv(&argc, &argv, s);
if (done && (ptr = strsep(&cdata->next_prompt, ",")) != NULL) { else {
xasprintf(&prompt, "%s ", ptr); cmd_free_argv(cdata->argc, cdata->argv);
input = strsep(&cdata->next_input, ","); cdata->argc = argc;
status_prompt_update(c, prompt, input); cdata->argv = cmd_copy_argv(argc, argv);
free(prompt);
cdata->idx++;
return (1);
} }
status = cmd_parse_and_append(new_template, NULL, c, NULL, &error); cmdlist = args_make_commands(cdata->state, argc, argv, &error);
if (status == CMD_PARSE_ERROR) { if (cmdlist == NULL) {
cmdq_append(c, cmdq_get_error(error)); cmdq_append(c, cmdq_get_error(error));
free(error); free(error);
} else if (item == NULL) {
new_item = cmdq_get_command(cmdlist, NULL);
cmdq_append(c, new_item);
} else {
new_item = cmdq_get_command(cmdlist, cmdq_get_state(item));
cmdq_insert_after(item, new_item);
} }
cmd_free_argv(argc, argv);
if (!done) /*
free(new_template); * An incremental prompt fires its callback on every edit but must stay
if (c->prompt_inputcb != cmd_command_prompt_callback) * open for further typing; only an explicit close (handled above) ends
return (1); * it.
return (0); */
if (cdata->flags & PROMPT_INCREMENTAL)
return (PROMPT_CONTINUE);
out:
if (item != NULL) {
cdata->item = NULL;
cmdq_continue(item);
}
return (PROMPT_CLOSE);
} }
static void static void
cmd_command_prompt_free(void *data) cmd_command_prompt_free(void *data)
{ {
struct cmd_command_prompt_cdata *cdata = data; struct cmd_command_prompt_cdata *cdata = data;
u_int i;
free(cdata->inputs); if (cdata->item != NULL) {
cmdq_continue(cdata->item);
cdata->item = NULL;
}
for (i = 0; i < cdata->count; i++) {
free(cdata->prompts[i].prompt);
free(cdata->prompts[i].input);
}
free(cdata->prompts); free(cdata->prompts);
free(cdata->template); cmd_free_argv(cdata->argc, cdata->argv);
args_make_commands_free(cdata->state);
free(cdata); free(cdata);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-confirm-before.c,v 1.61 2026/06/24 10:55:39 nicm Exp $ */
/* /*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -28,28 +28,41 @@
* Asks for confirmation before executing a command. * Asks for confirmation before executing a command.
*/ */
static enum cmd_retval cmd_confirm_before_exec(struct cmd *, static enum args_parse_type cmd_confirm_before_args_parse(struct args *,
struct cmdq_item *); u_int, char **);
static enum cmd_retval cmd_confirm_before_exec(struct cmd *,
struct cmdq_item *);
static int cmd_confirm_before_callback(struct client *, void *, static enum prompt_result cmd_confirm_before_callback(struct client *, void *,
const char *, int); const char *, enum prompt_key_result);
static void cmd_confirm_before_free(void *); static void cmd_confirm_before_free(void *);
const struct cmd_entry cmd_confirm_before_entry = { const struct cmd_entry cmd_confirm_before_entry = {
.name = "confirm-before", .name = "confirm-before",
.alias = "confirm", .alias = "confirm",
.args = { "p:t:", 1, 1 }, .args = { "bc:p:t:y", 1, 1, cmd_confirm_before_args_parse },
.usage = "[-p prompt] " CMD_TARGET_CLIENT_USAGE " command", .usage = "[-by] [-c confirm-key] [-p prompt] " CMD_TARGET_CLIENT_USAGE
" command",
.flags = CMD_CLIENT_TFLAG, .flags = CMD_CLIENT_TFLAG,
.exec = cmd_confirm_before_exec .exec = cmd_confirm_before_exec
}; };
struct cmd_confirm_before_data { struct cmd_confirm_before_data {
char *cmd; struct cmdq_item *item;
struct cmd_list *cmdlist;
u_char confirm_key;
int default_yes;
}; };
static enum args_parse_type
cmd_confirm_before_args_parse(__unused struct args *args, __unused u_int idx,
__unused char **cause)
{
return (ARGS_PARSE_COMMANDS_OR_STRING);
}
static enum cmd_retval static enum cmd_retval
cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item) cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
{ {
@@ -57,52 +70,88 @@ cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_confirm_before_data *cdata; struct cmd_confirm_before_data *cdata;
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
char *cmd, *copy, *new_prompt, *ptr; char *new_prompt;
const char *prompt; const char *confirm_key, *prompt, *cmd;
int wait = !args_has(args, 'b');
cdata = xcalloc(1, sizeof *cdata);
cdata->cmdlist = args_make_commands_now(self, item, 0, 1);
if (cdata->cmdlist == NULL) {
free(cdata);
return (CMD_RETURN_ERROR);
}
if (wait)
cdata->item = item;
cdata->default_yes = args_has(args, 'y');
if ((confirm_key = args_get(args, 'c')) != NULL) {
if (confirm_key[1] == '\0' &&
confirm_key[0] > 31 &&
confirm_key[0] < 127)
cdata->confirm_key = confirm_key[0];
else {
cmdq_error(item, "invalid confirm key");
cmd_list_free(cdata->cmdlist);
free(cdata);
return (CMD_RETURN_ERROR);
}
}
else
cdata->confirm_key = 'y';
if ((prompt = args_get(args, 'p')) != NULL) if ((prompt = args_get(args, 'p')) != NULL)
xasprintf(&new_prompt, "%s ", prompt); xasprintf(&new_prompt, "%s ", prompt);
else { else {
ptr = copy = xstrdup(args->argv[0]); cmd = cmd_get_entry(cmd_list_first(cdata->cmdlist))->name;
cmd = strsep(&ptr, " \t"); xasprintf(&new_prompt, "Confirm '%s'? (%c/n) ", cmd,
xasprintf(&new_prompt, "Confirm '%s'? (y/n) ", cmd); cdata->confirm_key);
free(copy);
} }
cdata = xmalloc(sizeof *cdata);
cdata->cmd = xstrdup(args->argv[0]);
status_prompt_set(tc, target, new_prompt, NULL, status_prompt_set(tc, target, new_prompt, NULL,
cmd_confirm_before_callback, cmd_confirm_before_free, cdata, cmd_confirm_before_callback, cmd_confirm_before_free, cdata,
PROMPT_SINGLE); PROMPT_SINGLE, PROMPT_TYPE_COMMAND);
free(new_prompt); free(new_prompt);
return (CMD_RETURN_NORMAL);
if (!wait)
return (CMD_RETURN_NORMAL);
return (CMD_RETURN_WAIT);
} }
static int static enum prompt_result
cmd_confirm_before_callback(struct client *c, void *data, const char *s, cmd_confirm_before_callback(struct client *c, void *data, const char *s,
__unused int done) __unused enum prompt_key_result key)
{ {
struct cmd_confirm_before_data *cdata = data; struct cmd_confirm_before_data *cdata = data;
char *error; struct cmdq_item *item = cdata->item, *new_item;
enum cmd_parse_status status; int retcode = 1;
if (c->flags & CLIENT_DEAD) if (c->flags & CLIENT_DEAD)
return (0); goto out;
if (s == NULL || *s == '\0') if (s == NULL)
return (0); goto out;
if (tolower((u_char)s[0]) != 'y' || s[1] != '\0') if (s[0] != cdata->confirm_key && (s[0] != '\r' || !cdata->default_yes))
return (0); goto out;
retcode = 0;
status = cmd_parse_and_append(cdata->cmd, NULL, c, NULL, &error); if (item == NULL) {
if (status == CMD_PARSE_ERROR) { new_item = cmdq_get_command(cdata->cmdlist, NULL);
cmdq_append(c, cmdq_get_error(error)); cmdq_append(c, new_item);
free(error); } else {
new_item = cmdq_get_command(cdata->cmdlist,
cmdq_get_state(item));
cmdq_insert_after(item, new_item);
} }
return (0); out:
if (item != NULL) {
if (cmdq_get_client(item) != NULL &&
cmdq_get_client(item)->session == NULL)
cmdq_get_client(item)->retval = retcode;
cmdq_continue(item);
}
return (PROMPT_CLOSE);
} }
static void static void
@@ -110,6 +159,6 @@ cmd_confirm_before_free(void *data)
{ {
struct cmd_confirm_before_data *cdata = data; struct cmd_confirm_before_data *cdata = data;
free(cdata->cmd); cmd_list_free(cdata->cmdlist);
free(cdata); free(cdata);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-copy-mode.c,v 1.54 2026/07/14 17:17:17 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -30,13 +30,13 @@ const struct cmd_entry cmd_copy_mode_entry = {
.name = "copy-mode", .name = "copy-mode",
.alias = NULL, .alias = NULL,
.args = { "eHMs:t:uq", 0, 0 }, .args = { "dekHMqSs:t:u", 0, 0, NULL },
.usage = "[-eHMuq] [-s src-pane] " CMD_TARGET_PANE_USAGE, .usage = "[-dekHMqSu] [-s src-pane] " CMD_TARGET_PANE_USAGE,
.source = { 's', CMD_FIND_PANE, 0 }, .source = { 's', CMD_FIND_PANE, 0 },
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK|CMD_READONLY,
.exec = cmd_copy_mode_exec .exec = cmd_copy_mode_exec
}; };
@@ -44,7 +44,7 @@ const struct cmd_entry cmd_clock_mode_entry = {
.name = "clock-mode", .name = "clock-mode",
.alias = NULL, .alias = NULL,
.args = { "t:", 0, 0 }, .args = { "t:", 0, 0, NULL },
.usage = CMD_TARGET_PANE_USAGE, .usage = CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -63,6 +63,8 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
struct client *c = cmdq_get_client(item); struct client *c = cmdq_get_client(item);
struct session *s; struct session *s;
struct window_pane *wp = target->wp, *swp; struct window_pane *wp = target->wp, *swp;
u_int tty_ox, tty_oy, tty_sx, tty_sy;
int line_numbers;
if (args_has(args, 'q')) { if (args_has(args, 'q')) {
window_pane_reset_mode_all(wp); window_pane_reset_mode_all(wp);
@@ -77,7 +79,8 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
} }
if (cmd_get_entry(self) == &cmd_clock_mode_entry) { if (cmd_get_entry(self) == &cmd_clock_mode_entry) {
window_pane_set_mode(wp, NULL, &window_clock_mode, NULL, NULL); window_pane_set_mode(wp, NULL, &window_clock_mode, item, NULL,
NULL);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
@@ -85,12 +88,26 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
swp = source->wp; swp = source->wp;
else else
swp = wp; swp = wp;
if (!window_pane_set_mode(wp, swp, &window_copy_mode, NULL, args)) { line_numbers = 1;
if (event != NULL && KEYC_IS_MOUSE(event->key))
line_numbers = 0;
if (!window_pane_set_mode(wp, swp, &window_copy_mode, item, NULL,
args)) {
window_copy_set_line_numbers(wp, line_numbers);
if (args_has(args, 'M')) if (args_has(args, 'M'))
window_copy_start_drag(c, &event->m); window_copy_start_drag(c, &event->m);
} } else
window_copy_set_line_numbers(wp, line_numbers);
if (args_has(args, 'u')) if (args_has(args, 'u'))
window_copy_pageup(wp, 0); window_copy_pageup(wp, 0);
if (args_has(args, 'd'))
window_copy_pagedown(wp, 0, args_has(args, 'e'));
if (args_has(args, 'S')) {
tty_window_offset(&c->tty, &tty_ox, &tty_oy, &tty_sx, &tty_sy);
window_copy_scroll(wp, c->tty.mouse_slider_mpos, event->m.y,
tty_oy, args_has(args, 'e'));
return (CMD_RETURN_NORMAL);
}
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-detach-client.c,v 1.39 2026/05/22 15:22:43 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_detach_client_entry = {
.name = "detach-client", .name = "detach-client",
.alias = "detach", .alias = "detach",
.args = { "aE:s:t:P", 0, 0 }, .args = { "aE:s:t:P", 0, 0, NULL },
.usage = "[-aP] [-E shell-command] " .usage = "[-aP] [-E shell-command] "
"[-s target-session] " CMD_TARGET_CLIENT_USAGE, "[-s target-session] " CMD_TARGET_CLIENT_USAGE,
@@ -47,7 +47,7 @@ const struct cmd_entry cmd_suspend_client_entry = {
.name = "suspend-client", .name = "suspend-client",
.alias = "suspendc", .alias = "suspendc",
.args = { "t:", 0, 0 }, .args = { "t:", 0, 0, NULL },
.usage = CMD_TARGET_CLIENT_USAGE, .usage = CMD_TARGET_CLIENT_USAGE,
.flags = CMD_CLIENT_TFLAG, .flags = CMD_CLIENT_TFLAG,
@@ -59,6 +59,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *source = cmdq_get_source(item); struct cmd_find_state *source = cmdq_get_source(item);
struct client *c = cmdq_get_client(item);
struct client *tc = cmdq_get_target_client(item), *loop; struct client *tc = cmdq_get_target_client(item), *loop;
struct session *s; struct session *s;
enum msgtype msgtype; enum msgtype msgtype;
@@ -69,6 +70,13 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (c->flags & CLIENT_READONLY) {
if (args_has(args, 's') || args_has(args, 'a') || c != tc) {
cmdq_error(item, "client is read-only");
return (CMD_RETURN_ERROR);
}
}
if (args_has(args, 'P')) if (args_has(args, 'P'))
msgtype = MSG_DETACHKILL; msgtype = MSG_DETACHKILL;
else else

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-display-menu.c,v 1.52 2026/07/14 19:07:03 nicm Exp $ */
/* /*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -27,18 +27,22 @@
* Display a menu on a client. * Display a menu on a client.
*/ */
static enum cmd_retval cmd_display_menu_exec(struct cmd *, static enum args_parse_type cmd_display_menu_args_parse(struct args *,
struct cmdq_item *); u_int, char **);
static enum cmd_retval cmd_display_popup_exec(struct cmd *, static enum cmd_retval cmd_display_menu_exec(struct cmd *,
struct cmdq_item *); struct cmdq_item *);
static enum cmd_retval cmd_display_popup_exec(struct cmd *,
struct cmdq_item *);
const struct cmd_entry cmd_display_menu_entry = { const struct cmd_entry cmd_display_menu_entry = {
.name = "display-menu", .name = "display-menu",
.alias = "menu", .alias = "menu",
.args = { "c:t:OT:x:y:", 1, -1 }, .args = { "b:c:C:H:s:S:MOt:T:x:y:", 1, -1, cmd_display_menu_args_parse },
.usage = "[-O] [-c target-client] " CMD_TARGET_PANE_USAGE " [-T title] " .usage = "[-MO] [-b border-lines] [-c target-client] "
"[-x position] [-y position] name key command ...", "[-C starting-choice] [-H selected-style] [-s style] "
"[-S border-style] " CMD_TARGET_PANE_USAGE " [-T title] "
"[-x position] [-y position] name [key] [command] ...",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -50,10 +54,12 @@ const struct cmd_entry cmd_display_popup_entry = {
.name = "display-popup", .name = "display-popup",
.alias = "popup", .alias = "popup",
.args = { "Cc:d:Eh:t:w:x:y:", 0, -1 }, .args = { "Bb:Cc:d:e:Eh:kNs:S:t:T:w:x:y:", 0, -1, NULL },
.usage = "[-CE] [-c target-client] [-d start-directory] [-h height] " .usage = "[-BCEkN] [-b border-lines] [-c target-client] "
CMD_TARGET_PANE_USAGE " [-w width] " "[-d start-directory] [-e environment] [-h height] "
"[-x position] [-y position] [command]", "[-s style] [-S border-style] " CMD_TARGET_PANE_USAGE
" [-T title] [-w width] [-x position] [-y position] "
"[shell-command [argument ...]]",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -61,8 +67,32 @@ const struct cmd_entry cmd_display_popup_entry = {
.exec = cmd_display_popup_exec .exec = cmd_display_popup_exec
}; };
static enum args_parse_type
cmd_display_menu_args_parse(struct args *args, u_int idx, __unused char **cause)
{
u_int i = 0;
enum args_parse_type type = ARGS_PARSE_STRING;
for (;;) {
type = ARGS_PARSE_STRING;
if (i == idx)
break;
if (*args_string(args, i++) == '\0')
continue;
type = ARGS_PARSE_STRING;
if (i++ == idx)
break;
type = ARGS_PARSE_COMMANDS_OR_STRING;
if (i++ == idx)
break;
}
return (type);
}
static int static int
cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item, cmd_display_menu_get_popup_pos(struct client *tc, struct cmdq_item *item,
struct args *args, u_int *px, u_int *py, u_int w, u_int h) struct args *args, u_int *px, u_int *py, u_int w, u_int h)
{ {
struct tty *tty = &tc->tty; struct tty *tty = &tc->tty;
@@ -96,6 +126,10 @@ cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
format_add(ft, "popup_mouse_y", "%u", event->m.y); format_add(ft, "popup_mouse_y", "%u", event->m.y);
} }
/* Position of the previous menu, for -x/-y L. */
format_add(ft, "popup_last_x", "%u", target->w->menu_last_px);
format_add(ft, "popup_last_y", "%u", target->w->menu_last_py + h);
/* /*
* If there are any status lines, add this window position and the * If there are any status lines, add this window position and the
* status line position. * status line position.
@@ -120,8 +154,6 @@ cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
if (sr != NULL) if (sr != NULL)
break; break;
} }
if (line == lines)
ranges = &tc->status.entries[0].ranges;
if (sr != NULL) { if (sr != NULL) {
format_add(ft, "popup_window_status_line_x", "%u", format_add(ft, "popup_window_status_line_x", "%u",
@@ -174,8 +206,8 @@ cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
} else } else
format_add(ft, "popup_mouse_centre_y", "%ld", n); format_add(ft, "popup_mouse_centre_y", "%ld", n);
n = (long)event->m.y + h; n = (long)event->m.y + h;
if (n + h >= tty->sy) if (n >= tty->sy)
format_add(ft, "popup_mouse_top", "%u", tty->sy - h); format_add(ft, "popup_mouse_top", "%u", tty->sy - 1);
else else
format_add(ft, "popup_mouse_top", "%ld", n); format_add(ft, "popup_mouse_top", "%ld", n);
n = event->m.y - h; n = event->m.y - h;
@@ -210,6 +242,8 @@ cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
xp = "#{popup_pane_left}"; xp = "#{popup_pane_left}";
else if (strcmp(xp, "M") == 0) else if (strcmp(xp, "M") == 0)
xp = "#{popup_mouse_centre_x}"; xp = "#{popup_mouse_centre_x}";
else if (strcmp(xp, "L") == 0)
xp = "#{popup_last_x}";
else if (strcmp(xp, "W") == 0) else if (strcmp(xp, "W") == 0)
xp = "#{popup_window_status_line_x}"; xp = "#{popup_window_status_line_x}";
p = format_expand(ft, xp); p = format_expand(ft, xp);
@@ -219,7 +253,7 @@ cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
else if (n < 0) else if (n < 0)
n = 0; n = 0;
*px = n; *px = n;
log_debug("%s: -x: %s = %s = %u", __func__, xp, p, *px); log_debug("%s: -x: %s = %s = %u (-w %u)", __func__, xp, p, *px, w);
free(p); free(p);
/* Expand vertical position */ /* Expand vertical position */
@@ -230,6 +264,8 @@ cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
yp = "#{popup_pane_bottom}"; yp = "#{popup_pane_bottom}";
else if (strcmp(yp, "M") == 0) else if (strcmp(yp, "M") == 0)
yp = "#{popup_mouse_top}"; yp = "#{popup_mouse_top}";
else if (strcmp(yp, "L") == 0)
yp = "#{popup_last_y}";
else if (strcmp(yp, "S") == 0) else if (strcmp(yp, "S") == 0)
yp = "#{popup_status_line_y}"; yp = "#{popup_status_line_y}";
else if (strcmp(yp, "W") == 0) else if (strcmp(yp, "W") == 0)
@@ -245,9 +281,188 @@ cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
else if (n < 0) else if (n < 0)
n = 0; n = 0;
*py = n; *py = n;
log_debug("%s: -y: %s = %s = %u", __func__, yp, p, *py); log_debug("%s: -y: %s = %s = %u (-h %u)", __func__, yp, p, *py, h);
free(p); free(p);
format_free(ft);
return (1);
}
static int
cmd_display_menu_get_menu_pos(struct client *tc, struct cmdq_item *item,
struct args *args, u_int *px, u_int *py, u_int w, u_int h)
{
struct cmd_find_state *target = cmdq_get_target(item);
struct key_event *event = cmdq_get_event(item);
struct session *s = tc->session;
struct winlink *wl = target->wl;
struct window *window = target->w;
struct window_pane *wp = target->wp;
struct style_ranges *ranges = NULL;
struct style_range *sr = NULL;
const char *xp, *yp;
char *p;
u_int line, ox, oy, sx, sy, lines, position;
long n, max_x, max_y, mouse_x = 0, mouse_y = 0;
struct format_tree *ft;
max_x = window->sx > w ? window->sx - w : 0;
max_y = window->sy > h ? window->sy - h : 0;
tty_window_offset(&tc->tty, &ox, &oy, &sx, &sy);
ft = format_create_from_target(item);
if (event->m.valid) {
mouse_x = event->m.x + ox;
if (event->m.statusat == 0) {
if (event->m.y >= event->m.statuslines)
mouse_y = event->m.y - event->m.statuslines + oy;
else
mouse_y = oy;
} else if (event->m.statusat > 0 &&
event->m.y >= (u_int)event->m.statusat) {
mouse_y = oy + sy - 1;
} else
mouse_y = event->m.y + oy;
format_add(ft, "popup_mouse_x", "%ld", mouse_x);
format_add(ft, "popup_mouse_y", "%ld", mouse_y);
}
format_add(ft, "popup_last_x", "%u", window->menu_last_px);
format_add(ft, "popup_last_y", "%u", window->menu_last_py + h);
lines = status_line_size(tc);
position = options_get_number(s->options, "status-position");
if (status_at_line(tc) != -1 && lines != 0) {
for (line = 0; line < lines; line++) {
ranges = &tc->status.entries[line].ranges;
TAILQ_FOREACH(sr, ranges, entry) {
if (sr->type != STYLE_RANGE_WINDOW)
continue;
if (sr->argument == (u_int)wl->idx)
break;
}
if (sr != NULL)
break;
}
if (sr != NULL) {
format_add(ft, "popup_window_status_line_x", "%u",
sr->start + ox);
if (position == 0) {
format_add(ft, "popup_window_status_line_y",
"%u", h);
} else {
format_add(ft, "popup_window_status_line_y",
"%u", window->sy);
}
}
if (position == 0)
format_add(ft, "popup_status_line_y", "%u", h);
else
format_add(ft, "popup_status_line_y", "%u", window->sy);
}
format_add(ft, "popup_width", "%u", w);
format_add(ft, "popup_height", "%u", h);
n = ((long)window->sx - 1) / 2 - w / 2;
if (n < 0)
format_add(ft, "popup_centre_x", "%u", 0);
else
format_add(ft, "popup_centre_x", "%ld", n);
n = ((long)window->sy - 1) / 2 + h / 2;
if (n >= window->sy)
format_add(ft, "popup_centre_y", "%ld", max_y);
else
format_add(ft, "popup_centre_y", "%ld", n);
if (event->m.valid) {
n = mouse_x - w / 2;
if (n < 0)
format_add(ft, "popup_mouse_centre_x", "%u", 0);
else
format_add(ft, "popup_mouse_centre_x", "%ld", n);
n = mouse_y - h / 2;
if (n + h >= window->sy)
format_add(ft, "popup_mouse_centre_y", "%ld", max_y);
else
format_add(ft, "popup_mouse_centre_y", "%ld", n);
n = mouse_y + h;
if (n >= window->sy)
format_add(ft, "popup_mouse_top", "%u", window->sy - 1);
else
format_add(ft, "popup_mouse_top", "%ld", n);
n = mouse_y - h;
if (n < 0)
format_add(ft, "popup_mouse_bottom", "%u", 0);
else
format_add(ft, "popup_mouse_bottom", "%ld", n);
}
n = wp->yoff + h;
if (n >= window->sy)
format_add(ft, "popup_pane_top", "%ld", max_y);
else
format_add(ft, "popup_pane_top", "%ld", n);
format_add(ft, "popup_pane_bottom", "%u", wp->yoff + wp->sy);
format_add(ft, "popup_pane_left", "%u", wp->xoff);
n = (long)wp->xoff + wp->sx - w;
if (n < 0)
format_add(ft, "popup_pane_right", "%u", 0);
else
format_add(ft, "popup_pane_right", "%ld", n);
xp = args_get(args, 'x');
if (xp == NULL || strcmp(xp, "C") == 0)
xp = "#{popup_centre_x}";
else if (strcmp(xp, "R") == 0)
xp = "#{popup_pane_right}";
else if (strcmp(xp, "P") == 0)
xp = "#{popup_pane_left}";
else if (strcmp(xp, "M") == 0)
xp = "#{popup_mouse_centre_x}";
else if (strcmp(xp, "L") == 0)
xp = "#{popup_last_x}";
else if (strcmp(xp, "W") == 0)
xp = "#{popup_window_status_line_x}";
p = format_expand(ft, xp);
n = strtol(p, NULL, 10);
if (n < 0)
n = 0;
if (n > max_x)
n = max_x;
*px = n;
log_debug("%s: -x: %s = %s = %u (-w %u)", __func__, xp, p, *px, w);
free(p);
yp = args_get(args, 'y');
if (yp == NULL || strcmp(yp, "C") == 0)
yp = "#{popup_centre_y}";
else if (strcmp(yp, "P") == 0)
yp = "#{popup_pane_bottom}";
else if (strcmp(yp, "M") == 0)
yp = "#{popup_mouse_top}";
else if (strcmp(yp, "L") == 0)
yp = "#{popup_last_y}";
else if (strcmp(yp, "S") == 0)
yp = "#{popup_status_line_y}";
else if (strcmp(yp, "W") == 0)
yp = "#{popup_window_status_line_y}";
p = format_expand(ft, yp);
n = strtol(p, NULL, 10);
if (n < h)
n = 0;
else
n -= h;
if (n < 0)
n = 0;
if (n > max_y)
n = max_y;
*py = n;
log_debug("%s: -y: %s = %s = %u (-h %u)", __func__, yp, p, *py, h);
free(p);
format_free(ft);
return (1); return (1);
} }
@@ -260,64 +475,94 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct menu *menu = NULL; struct menu *menu = NULL;
struct menu_item menu_item; struct menu_item menu_item;
const char *key; const char *key, *name, *value;
char *title, *name; const char *style = args_get(args, 's');
int flags = 0, i; const char *border_style = args_get(args, 'S');
u_int px, py; const char *selected_style = args_get(args, 'H');
enum box_lines lines = BOX_LINES_DEFAULT;
char *title, *cause = NULL;
int flags = 0, starting_choice = 0;
u_int px, py, i, count = args_count(args);
struct options *o = target->s->curw->window->options;
struct options_entry *oe;
if (tc->overlay_draw != NULL) if (args_has(args, 'C')) {
return (CMD_RETURN_NORMAL); if (strcmp(args_get(args, 'C'), "-") == 0)
starting_choice = -1;
else {
starting_choice = args_strtonum(args, 'C', 0, UINT_MAX,
&cause);
if (cause != NULL) {
cmdq_error(item, "starting choice %s", cause);
goto fail;
}
}
}
if (args_has(args, 'T')) if (args_has(args, 'T'))
title = format_single_from_target(item, args_get(args, 'T')); title = format_single_from_target(item, args_get(args, 'T'));
else else
title = xstrdup(""); title = xstrdup("");
menu = menu_create(title); menu = menu_create(title);
free(title);
for (i = 0; i != args->argc; /* nothing */) { for (i = 0; i != count; /* nothing */) {
name = args->argv[i++]; name = args_string(args, i++);
if (*name == '\0') { if (*name == '\0') {
menu_add_item(menu, NULL, item, tc, target); menu_add_item(menu, NULL, item, tc, target);
continue; continue;
} }
if (args->argc - i < 2) { if (count - i < 2) {
cmdq_error(item, "not enough arguments"); cmdq_error(item, "not enough arguments");
free(title); goto fail;
menu_free(menu);
return (CMD_RETURN_ERROR);
} }
key = args->argv[i++]; key = args_string(args, i++);
menu_item.name = name; menu_item.name = name;
menu_item.key = key_string_lookup_string(key); menu_item.key = key_string_lookup_string(key);
menu_item.command = args->argv[i++]; menu_item.command = args_string(args, i++);
menu_add_item(menu, &menu_item, item, tc, target); menu_add_item(menu, &menu_item, item, tc, target);
} }
free(title);
if (menu == NULL) { if (menu == NULL) {
cmdq_error(item, "invalid menu arguments"); cmdq_error(item, "invalid menu arguments");
return (CMD_RETURN_ERROR); goto fail;
} }
if (menu->count == 0) { if (menu->count == 0)
menu_free(menu); goto out;
return (CMD_RETURN_NORMAL); if (!cmd_display_menu_get_menu_pos(tc, item, args, &px, &py,
} menu->width + 4, menu->count + 2))
if (!cmd_display_menu_get_position(tc, item, args, &px, &py, goto out;
menu->width + 4, menu->count + 2)) {
menu_free(menu); value = args_get(args, 'b');
return (CMD_RETURN_NORMAL); if (value != NULL) {
oe = options_get(o, "menu-border-lines");
lines = options_find_choice(options_table_entry(oe), value,
&cause);
if (lines == -1) {
cmdq_error(item, "menu-border-lines %s", cause);
goto fail;
}
} }
if (args_has(args, 'O')) if (args_has(args, 'O'))
flags |= MENU_STAYOPEN; flags |= MENU_STAYOPEN;
if (!event->m.valid) if (!event->m.valid && !args_has(args, 'M'))
flags |= MENU_NOMOUSE; flags |= MENU_NOMOUSE;
if (menu_display(menu, flags, item, px, py, tc, target, NULL, if (menu_display(menu, flags, starting_choice, item, px, py, tc, lines,
NULL) != 0) style, selected_style, border_style, target, NULL, NULL) != 0)
return (CMD_RETURN_NORMAL); goto out;
return (CMD_RETURN_WAIT); return (CMD_RETURN_NORMAL);
out:
menu_free(menu);
return (CMD_RETURN_NORMAL);
fail:
free(cause);
menu_free(menu);
return (CMD_RETURN_ERROR);
} }
static enum cmd_retval static enum cmd_retval
@@ -328,70 +573,145 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
struct session *s = target->s; struct session *s = target->s;
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct tty *tty = &tc->tty; struct tty *tty = &tc->tty;
const char *value, *shell[] = { NULL, NULL }; const char *value, *shell, *shellcmd = NULL;
const char *shellcmd = NULL; const char *style = args_get(args, 's');
char *cwd, *cause, **argv = args->argv; const char *border_style = args_get(args, 'S');
int flags = 0, argc = args->argc; char *cwd = NULL, *cause = NULL, **argv = NULL;
u_int px, py, w, h; char *title = NULL;
int modify = popup_present(tc);
int flags = -1, argc = 0;
enum box_lines lines = BOX_LINES_DEFAULT;
u_int px, py, w, h, count = args_count(args);
struct args_value *av;
struct environ *env = NULL;
struct options *o = s->curw->window->options;
struct options_entry *oe;
if (args_has(args, 'C')) { if (args_has(args, 'C')) {
server_client_clear_overlay(tc); server_client_clear_overlay(tc);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (tc->overlay_draw != NULL) if (!modify && tc->overlay_draw != NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
h = tty->sy / 2; if (!modify) {
if (args_has(args, 'h')) { h = tty->sy / 2;
h = args_percentage(args, 'h', 1, tty->sy, tty->sy, &cause); if (args_has(args, 'h')) {
if (cause != NULL) { h = args_percentage(args, 'h', 1, tty->sy, tty->sy,
cmdq_error(item, "height %s", cause); &cause);
free(cause); if (cause != NULL) {
return (CMD_RETURN_ERROR); cmdq_error(item, "height %s", cause);
goto fail;
}
}
w = tty->sx / 2;
if (args_has(args, 'w')) {
w = args_percentage(args, 'w', 1, tty->sx, tty->sx,
&cause);
if (cause != NULL) {
cmdq_error(item, "width %s", cause);
goto fail;
}
}
if (w > tty->sx)
w = tty->sx;
if (h > tty->sy)
h = tty->sy;
if (!cmd_display_menu_get_popup_pos(tc, item, args, &px, &py,
w, h))
goto out;
value = args_get(args, 'd');
if (value != NULL)
cwd = format_single_from_target(item, value);
else
cwd = xstrdup(server_client_get_cwd(tc, s));
if (count == 0) {
shellcmd = options_get_string(s->options,
"default-command");
} else if (count == 1)
shellcmd = args_string(args, 0);
if (count <= 1 && (shellcmd == NULL || *shellcmd == '\0')) {
shellcmd = NULL;
shell = options_get_string(s->options, "default-shell");
if (!checkshell(shell))
shell = _PATH_BSHELL;
cmd_append_argv(&argc, &argv, shell);
} else
args_to_vector(args, &argc, &argv);
if (args_has(args, 'e') >= 1) {
env = environ_create();
av = args_first_value(args, 'e');
while (av != NULL) {
environ_put(env, av->string, 0);
av = args_next_value(av);
}
} }
} }
w = tty->sx / 2; value = args_get(args, 'b');
if (args_has(args, 'w')) { if (args_has(args, 'B'))
w = args_percentage(args, 'w', 1, tty->sx, tty->sx, &cause); lines = BOX_LINES_NONE;
else if (value != NULL) {
oe = options_get(o, "popup-border-lines");
lines = options_find_choice(options_table_entry(oe), value,
&cause);
if (cause != NULL) { if (cause != NULL) {
cmdq_error(item, "width %s", cause); cmdq_error(item, "popup-border-lines %s", cause);
free(cause); goto fail;
return (CMD_RETURN_ERROR);
} }
} }
if (w > tty->sx - 1) if (args_has(args, 'T'))
w = tty->sx - 1; title = format_single_from_target(item, args_get(args, 'T'));
if (h > tty->sy - 1)
h = tty->sy - 1;
if (!cmd_display_menu_get_position(tc, item, args, &px, &py, w, h))
return (CMD_RETURN_NORMAL);
value = args_get(args, 'd');
if (value != NULL)
cwd = format_single_from_target(item, value);
else else
cwd = xstrdup(server_client_get_cwd(tc, s)); title = xstrdup("");
if (argc == 0)
shellcmd = options_get_string(s->options, "default-command"); if (args_has(args, 'N') || !modify)
else if (argc == 1) flags = 0;
shellcmd = argv[0]; if (args_has(args, 'E') > 1) {
if (argc <= 1 && (shellcmd == NULL || *shellcmd == '\0')) { if (flags == -1)
shellcmd = NULL; flags = 0;
shell[0] = options_get_string(s->options, "default-shell"); flags |= POPUP_CLOSEEXITZERO;
if (!checkshell(shell[0])) } else if (args_has(args, 'E')) {
shell[0] = _PATH_BSHELL; if (flags == -1)
argc = 1; flags = 0;
argv = (char**)shell; flags |= POPUP_CLOSEEXIT;
}
if (args_has(args, 'k')) {
if (flags == -1)
flags = 0;
flags |= POPUP_CLOSEANYKEY;
} }
if (args_has(args, 'E') > 1) if (modify) {
flags |= POPUP_CLOSEEXITZERO; popup_modify(tc, title, style, border_style, lines, flags);
else if (args_has(args, 'E')) goto out;
flags |= POPUP_CLOSEEXIT; }
if (popup_display(flags, item, px, py, w, h, shellcmd, argc, argv, cwd, if (popup_display(flags, lines, item, px, py, w, h, env, shellcmd, argc,
tc, s, NULL, NULL) != 0) argv, cwd, title, tc, s, style, border_style, NULL, NULL) != 0)
return (CMD_RETURN_NORMAL); goto out;
environ_free(env);
free(cwd);
free(title);
cmd_free_argv(argc, argv);
return (CMD_RETURN_WAIT); return (CMD_RETURN_WAIT);
out:
cmd_free_argv(argc, argv);
environ_free(env);
free(cwd);
free(title);
return (CMD_RETURN_NORMAL);
fail:
free(cause);
cmd_free_argv(argc, argv);
environ_free(env);
free(cwd);
free(title);
return (CMD_RETURN_ERROR);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-display-message.c,v 1.65 2026/02/23 08:46:57 nicm Exp $ */
/* /*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -39,8 +39,8 @@ const struct cmd_entry cmd_display_message_entry = {
.name = "display-message", .name = "display-message",
.alias = "display", .alias = "display",
.args = { "acd:INpt:F:v", 0, 1 }, .args = { "aCc:d:lINpt:F:v", 0, 1, NULL },
.usage = "[-aINpv] [-c target-client] [-d delay] [-F format] " .usage = "[-aCIlNpv] [-c target-client] [-d delay] [-F format] "
CMD_TARGET_PANE_USAGE " [message]", CMD_TARGET_PANE_USAGE " [message]",
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
@@ -68,22 +68,28 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
const char *template; const char *template;
char *msg, *cause; char *msg, *cause;
int delay = -1; int delay = -1, flags, Nflag = args_has(args, 'N');
int Cflag = args_has(args, 'C');
struct format_tree *ft; struct format_tree *ft;
int flags; u_int count = args_count(args);
struct evbuffer *evb;
if (args_has(args, 'I')) { if (args_has(args, 'I')) {
if (wp == NULL) if (wp == NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (window_pane_start_input(wp, item, &cause) != 0) { switch (window_pane_start_input(wp, item, &cause)) {
case -1:
cmdq_error(item, "%s", cause); cmdq_error(item, "%s", cause);
free(cause); free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
case 1:
return (CMD_RETURN_NORMAL);
case 0:
return (CMD_RETURN_WAIT);
} }
return (CMD_RETURN_WAIT);
} }
if (args_has(args, 'F') && args->argc != 0) { if (args_has(args, 'F') && count != 0) {
cmdq_error(item, "only one of -F or argument must be given"); cmdq_error(item, "only one of -F or argument must be given");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
@@ -97,9 +103,10 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
} }
} }
template = args_get(args, 'F'); if (count != 0)
if (args->argc != 0) template = args_string(args, 0);
template = args->argv[0]; else
template = args_get(args, 'F');
if (template == NULL) if (template == NULL)
template = DISPLAY_MESSAGE_TEMPLATE; template = DISPLAY_MESSAGE_TEMPLATE;
@@ -124,21 +131,30 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
if (args_has(args, 'a')) { if (args_has(args, 'a')) {
format_each(ft, cmd_display_message_each, item); format_each(ft, cmd_display_message_each, item);
format_free(ft);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
msg = format_expand_time(ft, template); if (args_has(args, 'l'))
msg = xstrdup(template);
else
msg = format_expand_time(ft, template);
if (cmdq_get_client(item) == NULL) if (cmdq_get_client(item) == NULL)
cmdq_error(item, "%s", msg); cmdq_error(item, "%s", msg);
else if (args_has(args, 'p')) else if (args_has(args, 'p'))
cmdq_print(item, "%s", msg); cmdq_print(item, "%s", msg);
else if (tc != NULL) { else if (tc != NULL && (tc->flags & CLIENT_CONTROL)) {
status_message_set(tc, delay, 0, args_has(args, 'N'), "%s", evb = evbuffer_new();
msg); if (evb == NULL)
} fatalx("out of memory");
evbuffer_add_printf(evb, "%%message %s", msg);
server_client_print(tc, 0, evb);
evbuffer_free(evb);
} else if (tc != NULL)
status_message_set(tc, delay, 0, Nflag, Cflag, "%s", msg);
free(msg); free(msg);
format_free(ft); format_free(ft);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,300 +0,0 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include "tmux.h"
/*
* Display panes on a client.
*/
static enum cmd_retval cmd_display_panes_exec(struct cmd *,
struct cmdq_item *);
const struct cmd_entry cmd_display_panes_entry = {
.name = "display-panes",
.alias = "displayp",
.args = { "bd:Nt:", 0, 1 },
.usage = "[-bN] [-d duration] " CMD_TARGET_CLIENT_USAGE " [template]",
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG,
.exec = cmd_display_panes_exec
};
struct cmd_display_panes_data {
struct cmdq_item *item;
char *command;
};
static void
cmd_display_panes_draw_pane(struct screen_redraw_ctx *ctx,
struct window_pane *wp)
{
struct client *c = ctx->c;
struct tty *tty = &c->tty;
struct session *s = c->session;
struct options *oo = s->options;
struct window *w = wp->window;
struct grid_cell fgc, bgc;
u_int pane, idx, px, py, i, j, xoff, yoff, sx, sy;
int colour, active_colour;
char buf[16], lbuf[16], rbuf[16], *ptr;
size_t len, llen, rlen;
if (wp->xoff + wp->sx <= ctx->ox ||
wp->xoff >= ctx->ox + ctx->sx ||
wp->yoff + wp->sy <= ctx->oy ||
wp->yoff >= ctx->oy + ctx->sy)
return;
if (wp->xoff >= ctx->ox && wp->xoff + wp->sx <= ctx->ox + ctx->sx) {
/* All visible. */
xoff = wp->xoff - ctx->ox;
sx = wp->sx;
} else if (wp->xoff < ctx->ox &&
wp->xoff + wp->sx > ctx->ox + ctx->sx) {
/* Both left and right not visible. */
xoff = 0;
sx = ctx->sx;
} else if (wp->xoff < ctx->ox) {
/* Left not visible. */
xoff = 0;
sx = wp->sx - (ctx->ox - wp->xoff);
} else {
/* Right not visible. */
xoff = wp->xoff - ctx->ox;
sx = wp->sx - xoff;
}
if (wp->yoff >= ctx->oy && wp->yoff + wp->sy <= ctx->oy + ctx->sy) {
/* All visible. */
yoff = wp->yoff - ctx->oy;
sy = wp->sy;
} else if (wp->yoff < ctx->oy &&
wp->yoff + wp->sy > ctx->oy + ctx->sy) {
/* Both top and bottom not visible. */
yoff = 0;
sy = ctx->sy;
} else if (wp->yoff < ctx->oy) {
/* Top not visible. */
yoff = 0;
sy = wp->sy - (ctx->oy - wp->yoff);
} else {
/* Bottom not visible. */
yoff = wp->yoff - ctx->oy;
sy = wp->sy - yoff;
}
if (ctx->statustop)
yoff += ctx->statuslines;
px = sx / 2;
py = sy / 2;
if (window_pane_index(wp, &pane) != 0)
fatalx("index not found");
len = xsnprintf(buf, sizeof buf, "%u", pane);
if (sx < len)
return;
colour = options_get_number(oo, "display-panes-colour");
active_colour = options_get_number(oo, "display-panes-active-colour");
memcpy(&fgc, &grid_default_cell, sizeof fgc);
memcpy(&bgc, &grid_default_cell, sizeof bgc);
if (w->active == wp) {
fgc.fg = active_colour;
bgc.bg = active_colour;
} else {
fgc.fg = colour;
bgc.bg = colour;
}
rlen = xsnprintf(rbuf, sizeof rbuf, "%ux%u", wp->sx, wp->sy);
if (pane > 9 && pane < 35)
llen = xsnprintf(lbuf, sizeof lbuf, "%c", 'a' + (pane - 10));
else
llen = 0;
if (sx < len * 6 || sy < 5) {
tty_attributes(tty, &fgc, &grid_default_cell, NULL);
if (sx >= len + llen + 1) {
len += llen + 1;
tty_cursor(tty, xoff + px - len / 2, yoff + py);
tty_putn(tty, buf, len, len);
tty_putn(tty, " ", 1, 1);
tty_putn(tty, lbuf, llen, llen);
} else {
tty_cursor(tty, xoff + px - len / 2, yoff + py);
tty_putn(tty, buf, len, len);
}
goto out;
}
px -= len * 3;
py -= 2;
tty_attributes(tty, &bgc, &grid_default_cell, NULL);
for (ptr = buf; *ptr != '\0'; ptr++) {
if (*ptr < '0' || *ptr > '9')
continue;
idx = *ptr - '0';
for (j = 0; j < 5; j++) {
for (i = px; i < px + 5; i++) {
tty_cursor(tty, xoff + i, yoff + py + j);
if (window_clock_table[idx][j][i - px])
tty_putc(tty, ' ');
}
}
px += 6;
}
if (sy <= 6)
goto out;
tty_attributes(tty, &fgc, &grid_default_cell, NULL);
if (rlen != 0 && sx >= rlen) {
tty_cursor(tty, xoff + sx - rlen, yoff);
tty_putn(tty, rbuf, rlen, rlen);
}
if (llen != 0) {
tty_cursor(tty, xoff + sx / 2 + len * 3 - llen - 1,
yoff + py + 5);
tty_putn(tty, lbuf, llen, llen);
}
out:
tty_cursor(tty, 0, 0);
}
static void
cmd_display_panes_draw(struct client *c, struct screen_redraw_ctx *ctx)
{
struct window *w = c->session->curw->window;
struct window_pane *wp;
log_debug("%s: %s @%u", __func__, c->name, w->id);
TAILQ_FOREACH(wp, &w->panes, entry) {
if (window_pane_visible(wp))
cmd_display_panes_draw_pane(ctx, wp);
}
}
static void
cmd_display_panes_free(struct client *c)
{
struct cmd_display_panes_data *cdata = c->overlay_data;
if (cdata->item != NULL)
cmdq_continue(cdata->item);
free(cdata->command);
free(cdata);
}
static int
cmd_display_panes_key(struct client *c, struct key_event *event)
{
struct cmd_display_panes_data *cdata = c->overlay_data;
char *cmd, *expanded, *error;
struct window *w = c->session->curw->window;
struct window_pane *wp;
enum cmd_parse_status status;
u_int index;
key_code key;
if (event->key >= '0' && event->key <= '9')
index = event->key - '0';
else if ((event->key & KEYC_MASK_MODIFIERS) == 0) {
key = (event->key & KEYC_MASK_KEY);
if (key >= 'a' && key <= 'z')
index = 10 + (key - 'a');
else
return (-1);
} else
return (-1);
wp = window_pane_at_index(w, index);
if (wp == NULL)
return (1);
window_unzoom(w);
xasprintf(&expanded, "%%%u", wp->id);
cmd = cmd_template_replace(cdata->command, expanded, 1);
status = cmd_parse_and_append(cmd, NULL, c, NULL, &error);
if (status == CMD_PARSE_ERROR) {
cmdq_append(c, cmdq_get_error(error));
free(error);
}
free(cmd);
free(expanded);
return (1);
}
static enum cmd_retval
cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
struct client *tc = cmdq_get_target_client(item);
struct session *s = tc->session;
u_int delay;
char *cause;
struct cmd_display_panes_data *cdata;
if (tc->overlay_draw != NULL)
return (CMD_RETURN_NORMAL);
if (args_has(args, 'd')) {
delay = args_strtonum(args, 'd', 0, UINT_MAX, &cause);
if (cause != NULL) {
cmdq_error(item, "delay %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
} else
delay = options_get_number(s->options, "display-panes-time");
cdata = xmalloc(sizeof *cdata);
if (args->argc != 0)
cdata->command = xstrdup(args->argv[0]);
else
cdata->command = xstrdup("select-pane -t '%%'");
if (args_has(args, 'b'))
cdata->item = NULL;
else
cdata->item = item;
if (args_has(args, 'N')) {
server_client_set_overlay(tc, delay, NULL, NULL,
cmd_display_panes_draw, NULL, cmd_display_panes_free,
cdata);
} else {
server_client_set_overlay(tc, delay, NULL, NULL,
cmd_display_panes_draw, cmd_display_panes_key,
cmd_display_panes_free, cdata);
}
if (args_has(args, 'b'))
return (CMD_RETURN_NORMAL);
return (CMD_RETURN_WAIT);
}

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-find-window.c,v 1.57 2026/07/14 17:17:17 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -32,7 +32,7 @@ const struct cmd_entry cmd_find_window_entry = {
.name = "find-window", .name = "find-window",
.alias = "findw", .alias = "findw",
.args = { "CiNrt:TZ", 1, 1 }, .args = { "CiNrt:TZ", 1, 1, NULL },
.usage = "[-CiNrTZ] " CMD_TARGET_PANE_USAGE " match-string", .usage = "[-CiNrTZ] " CMD_TARGET_PANE_USAGE " match-string",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -47,14 +47,17 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self), *new_args; struct args *args = cmd_get_args(self), *new_args;
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
const char *s = args->argv[0], *suffix = ""; const char *s = args_string(args, 0), *suffix = "";
char *filter, *argv = { NULL }; const char *star = "*";
struct args_value *filter;
int C, N, T; int C, N, T;
C = args_has(args, 'C'); C = args_has(args, 'C');
N = args_has(args, 'N'); N = args_has(args, 'N');
T = args_has(args, 'T'); T = args_has(args, 'T');
if (args_has(args, 'r'))
star = "";
if (args_has(args, 'r') && args_has(args, 'i')) if (args_has(args, 'r') && args_has(args, 'i'))
suffix = "/ri"; suffix = "/ri";
else if (args_has(args, 'r')) else if (args_has(args, 'r'))
@@ -65,41 +68,50 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
if (!C && !N && !T) if (!C && !N && !T)
C = N = T = 1; C = N = T = 1;
filter = xcalloc(1, sizeof *filter);
filter->type = ARGS_STRING;
if (C && N && T) { if (C && N && T) {
xasprintf(&filter, xasprintf(&filter->string,
"#{||:" "#{||:"
"#{C%s:%s},#{||:#{m%s:*%s*,#{window_name}}," "#{C%s:%s},#{||:#{m%s:%s%s%s,#{window_name}},"
"#{m%s:*%s*,#{pane_title}}}}", "#{m%s:%s%s%s,#{pane_title}}}}",
suffix, s, suffix, s, suffix, s); suffix, s, suffix, star, s, star, suffix, star, s, star);
} else if (C && N) { } else if (C && N) {
xasprintf(&filter, xasprintf(&filter->string,
"#{||:#{C%s:%s},#{m%s:*%s*,#{window_name}}}", "#{||:#{C%s:%s},#{m%s:%s%s%s,#{window_name}}}",
suffix, s, suffix, s); suffix, s, suffix, star, s, star);
} else if (C && T) { } else if (C && T) {
xasprintf(&filter, xasprintf(&filter->string,
"#{||:#{C%s:%s},#{m%s:*%s*,#{pane_title}}}", "#{||:#{C%s:%s},#{m%s:%s%s%s,#{pane_title}}}",
suffix, s, suffix, s); suffix, s, suffix, star, s, star);
} else if (N && T) { } else if (N && T) {
xasprintf(&filter, xasprintf(&filter->string,
"#{||:#{m%s:*%s*,#{window_name}}," "#{||:#{m%s:%s%s%s,#{window_name}},"
"#{m%s:*%s*,#{pane_title}}}", "#{m%s:%s%s%s,#{pane_title}}}",
suffix, s, suffix, s); suffix, star, s, star, suffix, star, s, star);
} else if (C) } else if (C) {
xasprintf(&filter, "#{C%s:%s}", suffix, s); xasprintf(&filter->string,
else if (N) "#{C%s:%s}",
xasprintf(&filter, "#{m%s:*%s*,#{window_name}}", suffix, s); suffix, s);
else } else if (N) {
xasprintf(&filter, "#{m%s:*%s*,#{pane_title}}", suffix, s); xasprintf(&filter->string,
"#{m%s:%s%s%s,#{window_name}}",
suffix, star, s, star);
} else {
xasprintf(&filter->string,
"#{m%s:%s%s%s,#{pane_title}}",
suffix, star, s, star);
}
new_args = args_parse("", 1, &argv); new_args = args_create();
if (args_has(args, 'Z')) if (args_has(args, 'Z'))
args_set(new_args, 'Z', NULL); args_set(new_args, 'Z', NULL, 0);
args_set(new_args, 'f', filter); args_set(new_args, 'f', filter, 0);
window_pane_set_mode(wp, NULL, &window_tree_mode, target, new_args);
window_pane_set_mode(wp, NULL, &window_tree_mode, item, target,
new_args);
args_free(new_args); args_free(new_args);
free(filter);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-find.c,v 1.87 2026/07/17 12:42:51 nicm Exp $ */
/* /*
* Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -147,6 +147,18 @@ cmd_find_session_better(struct session *s, struct session *than, int flags)
return (timercmp(&s->activity_time, &than->activity_time, >)); return (timercmp(&s->activity_time, &than->activity_time, >));
} }
/* Can this session be usefully targeted? */
static int
cmd_find_session_valid(struct session *s)
{
if (!session_alive(s) ||
s->curw == NULL ||
s->curw->window == NULL ||
s->curw->window->active == NULL)
return (0);
return (1);
}
/* Find best session from a list, or all if list is NULL. */ /* Find best session from a list, or all if list is NULL. */
static struct session * static struct session *
cmd_find_best_session(struct session **slist, u_int ssize, int flags) cmd_find_best_session(struct session **slist, u_int ssize, int flags)
@@ -159,11 +171,15 @@ cmd_find_best_session(struct session **slist, u_int ssize, int flags)
s = NULL; s = NULL;
if (slist != NULL) { if (slist != NULL) {
for (i = 0; i < ssize; i++) { for (i = 0; i < ssize; i++) {
if (!cmd_find_session_valid(slist[i]))
continue;
if (cmd_find_session_better(slist[i], s, flags)) if (cmd_find_session_better(slist[i], s, flags))
s = slist[i]; s = slist[i];
} }
} else { } else {
RB_FOREACH(s_loop, sessions, &sessions) { RB_FOREACH(s_loop, sessions, &sessions) {
if (!cmd_find_session_valid(s_loop))
continue;
if (cmd_find_session_better(s_loop, s, flags)) if (cmd_find_session_better(s_loop, s, flags))
s = s_loop; s = s_loop;
} }
@@ -582,27 +598,27 @@ cmd_find_get_pane_with_window(struct cmd_find_state *fs, const char *pane)
/* Try special characters. */ /* Try special characters. */
if (strcmp(pane, "!") == 0) { if (strcmp(pane, "!") == 0) {
fs->wp = fs->w->last; fs->wp = TAILQ_FIRST(&fs->w->last_panes);
if (fs->wp == NULL) if (fs->wp == NULL)
return (-1); return (-1);
return (0); return (0);
} else if (strcmp(pane, "{up-of}") == 0) { } else if (strcmp(pane, "{up-of}") == 0) {
fs->wp = window_pane_find_up(fs->current->wp); fs->wp = window_pane_find_up(fs->w->active);
if (fs->wp == NULL) if (fs->wp == NULL)
return (-1); return (-1);
return (0); return (0);
} else if (strcmp(pane, "{down-of}") == 0) { } else if (strcmp(pane, "{down-of}") == 0) {
fs->wp = window_pane_find_down(fs->current->wp); fs->wp = window_pane_find_down(fs->w->active);
if (fs->wp == NULL) if (fs->wp == NULL)
return (-1); return (-1);
return (0); return (0);
} else if (strcmp(pane, "{left-of}") == 0) { } else if (strcmp(pane, "{left-of}") == 0) {
fs->wp = window_pane_find_left(fs->current->wp); fs->wp = window_pane_find_left(fs->w->active);
if (fs->wp == NULL) if (fs->wp == NULL)
return (-1); return (-1);
return (0); return (0);
} else if (strcmp(pane, "{right-of}") == 0) { } else if (strcmp(pane, "{right-of}") == 0) {
fs->wp = window_pane_find_right(fs->current->wp); fs->wp = window_pane_find_right(fs->w->active);
if (fs->wp == NULL) if (fs->wp == NULL)
return (-1); return (-1);
return (0); return (0);
@@ -614,7 +630,7 @@ cmd_find_get_pane_with_window(struct cmd_find_state *fs, const char *pane)
n = strtonum(pane + 1, 1, INT_MAX, NULL); n = strtonum(pane + 1, 1, INT_MAX, NULL);
else else
n = 1; n = 1;
wp = fs->current->wp; wp = fs->w->active;
if (pane[0] == '+') if (pane[0] == '+')
fs->wp = window_pane_next_by_number(fs->w, wp, n); fs->wp = window_pane_next_by_number(fs->w, wp, n);
else else
@@ -868,7 +884,7 @@ cmd_find_from_client(struct cmd_find_state *fs, struct client *c, int flags)
if (c->session != NULL) { if (c->session != NULL) {
cmd_find_clear_state(fs, flags); cmd_find_clear_state(fs, flags);
fs->wp = server_client_get_pane(c); fs->wp = c->session->curw->window->active;
if (fs->wp == NULL) { if (fs->wp == NULL) {
cmd_find_from_session(fs, c->session, flags); cmd_find_from_session(fs, c->session, flags);
return (0); return (0);
@@ -924,6 +940,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
const char *target, enum cmd_find_type type, int flags) const char *target, enum cmd_find_type type, int flags)
{ {
struct mouse_event *m; struct mouse_event *m;
struct client *c;
struct cmd_find_state current; struct cmd_find_state current;
char *colon, *period, *copy = NULL, tmp[256]; char *colon, *period, *copy = NULL, tmp[256];
const char *session, *window, *pane, *s; const char *session, *window, *pane, *s;
@@ -990,6 +1007,20 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
if (target == NULL || *target == '\0') if (target == NULL || *target == '\0')
goto current; goto current;
if (strcmp(target, "@") == 0 ||
strcmp(target, "{active}") == 0 ||
strcmp(target, "{current}") == 0) {
c = cmdq_get_client(item);
if (c == NULL || c->session == NULL) {
cmdq_error(item, "no current client");
goto error;
}
fs->wl = c->session->curw;
fs->wp = c->session->curw->window->active;
fs->w = c->session->curw->window;
goto found;
}
/* Mouse target is a plain = or {mouse}. */ /* Mouse target is a plain = or {mouse}. */
if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) { if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) {
m = &cmdq_get_event(item)->m; m = &cmdq_get_event(item)->m;

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-if-shell.c,v 1.86 2025/08/01 09:05:51 nicm Exp $ */
/* /*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -20,6 +20,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -29,16 +30,19 @@
* Executes a tmux command if a shell command returns true or false. * Executes a tmux command if a shell command returns true or false.
*/ */
static enum cmd_retval cmd_if_shell_exec(struct cmd *, struct cmdq_item *); static enum args_parse_type cmd_if_shell_args_parse(struct args *, u_int,
char **);
static enum cmd_retval cmd_if_shell_exec(struct cmd *,
struct cmdq_item *);
static void cmd_if_shell_callback(struct job *); static void cmd_if_shell_callback(struct job *);
static void cmd_if_shell_free(void *); static void cmd_if_shell_free(void *);
const struct cmd_entry cmd_if_shell_entry = { const struct cmd_entry cmd_if_shell_entry = {
.name = "if-shell", .name = "if-shell",
.alias = "if", .alias = "if",
.args = { "bFt:", 2, 3 }, .args = { "bFt:", 2, 3, cmd_if_shell_args_parse },
.usage = "[-bF] " CMD_TARGET_PANE_USAGE " shell-command command " .usage = "[-bF] " CMD_TARGET_PANE_USAGE " shell-command command "
"[command]", "[command]",
@@ -49,97 +53,83 @@ const struct cmd_entry cmd_if_shell_entry = {
}; };
struct cmd_if_shell_data { struct cmd_if_shell_data {
struct cmd_parse_input input; struct args_command_state *cmd_if;
struct args_command_state *cmd_else;
char *cmd_if; struct client *client;
char *cmd_else; struct cmdq_item *item;
struct client *client;
struct cmdq_item *item;
}; };
static enum args_parse_type
cmd_if_shell_args_parse(__unused struct args *args, u_int idx,
__unused char **cause)
{
if (idx == 1 || idx == 2)
return (ARGS_PARSE_COMMANDS_OR_STRING);
return (ARGS_PARSE_STRING);
}
static enum cmd_retval static enum cmd_retval
cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item) cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct cmdq_state *state = cmdq_get_state(item);
struct cmd_if_shell_data *cdata; struct cmd_if_shell_data *cdata;
char *shellcmd, *cmd, *error; struct cmdq_item *new_item;
const char *file; char *shellcmd;
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct session *s = target->s; struct session *s = target->s;
struct cmd_parse_input pi; struct cmd_list *cmdlist;
enum cmd_parse_status status; u_int count = args_count(args);
int wait = !args_has(args, 'b');
shellcmd = format_single_from_target(item, args->argv[0]); shellcmd = format_single_from_target(item, args_string(args, 0));
if (args_has(args, 'F')) { if (args_has(args, 'F')) {
if (*shellcmd != '0' && *shellcmd != '\0') if (*shellcmd != '0' && *shellcmd != '\0')
cmd = args->argv[1]; cmdlist = args_make_commands_now(self, item, 1, 0);
else if (args->argc == 3) else if (count == 3)
cmd = args->argv[2]; cmdlist = args_make_commands_now(self, item, 2, 0);
else else {
cmd = NULL; free(shellcmd);
free(shellcmd);
if (cmd == NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
memset(&pi, 0, sizeof pi);
cmd_get_source(self, &pi.file, &pi.line);
pi.item = item;
pi.c = tc;
cmd_find_copy_state(&pi.fs, target);
status = cmd_parse_and_insert(cmd, &pi, item, state, &error);
if (status == CMD_PARSE_ERROR) {
cmdq_error(item, "%s", error);
free(error);
return (CMD_RETURN_ERROR);
} }
free(shellcmd);
if (cmdlist == NULL)
return (CMD_RETURN_ERROR);
new_item = cmdq_get_command(cmdlist, cmdq_get_state(item));
cmdq_insert_after(item, new_item);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
cdata = xcalloc(1, sizeof *cdata); cdata = xcalloc(1, sizeof *cdata);
cdata->cmd_if = xstrdup(args->argv[1]); cdata->cmd_if = args_make_commands_prepare(self, item, 1, NULL, wait,
if (args->argc == 3) 0);
cdata->cmd_else = xstrdup(args->argv[2]); if (count == 3) {
else cdata->cmd_else = args_make_commands_prepare(self, item, 2,
cdata->cmd_else = NULL; NULL, wait, 0);
}
if (!args_has(args, 'b')) if (wait) {
cdata->client = cmdq_get_client(item); cdata->client = cmdq_get_client(item);
else cdata->item = item;
} else
cdata->client = tc; cdata->client = tc;
if (cdata->client != NULL) if (cdata->client != NULL)
cdata->client->references++; cdata->client->references++;
if (!args_has(args, 'b')) if (job_run(shellcmd, 0, NULL, NULL, s,
cdata->item = item;
else
cdata->item = NULL;
memset(&cdata->input, 0, sizeof cdata->input);
cmd_get_source(self, &file, &cdata->input.line);
if (file != NULL)
cdata->input.file = xstrdup(file);
cdata->input.c = tc;
if (cdata->input.c != NULL)
cdata->input.c->references++;
cmd_find_copy_state(&cdata->input.fs, target);
if (job_run(shellcmd, 0, NULL, s,
server_client_get_cwd(cmdq_get_client(item), s), NULL, server_client_get_cwd(cmdq_get_client(item), s), NULL,
cmd_if_shell_callback, cmd_if_shell_free, cdata, 0, -1, cmd_if_shell_callback, cmd_if_shell_free, cdata, 0, -1,
-1) == NULL) { -1) == NULL) {
cmdq_error(item, "failed to run command: %s", shellcmd); cmdq_error(item, "failed to run command: %s", shellcmd);
free(shellcmd); free(shellcmd);
free(cdata); cmd_if_shell_free(cdata);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
free(shellcmd); free(shellcmd);
if (args_has(args, 'b')) if (!wait)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
return (CMD_RETURN_WAIT); return (CMD_RETURN_WAIT);
} }
@@ -149,45 +139,34 @@ cmd_if_shell_callback(struct job *job)
{ {
struct cmd_if_shell_data *cdata = job_get_data(job); struct cmd_if_shell_data *cdata = job_get_data(job);
struct client *c = cdata->client; struct client *c = cdata->client;
struct cmdq_item *new_item = NULL; struct cmdq_item *item = cdata->item, *new_item;
struct cmdq_state *new_state = NULL; struct args_command_state *state;
char *cmd; struct cmd_list *cmdlist;
char *error;
int status; int status;
struct cmd_parse_result *pr;
status = job_get_status(job); status = job_get_status(job);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
cmd = cdata->cmd_else; state = cdata->cmd_else;
else else
cmd = cdata->cmd_if; state = cdata->cmd_if;
if (cmd == NULL) if (state == NULL)
goto out; goto out;
pr = cmd_parse_from_string(cmd, &cdata->input); cmdlist = args_make_commands(state, 0, NULL, &error);
switch (pr->status) { if (cmdlist == NULL) {
case CMD_PARSE_EMPTY: if (cdata->item == NULL) {
break; *error = toupper((u_char)*error);
case CMD_PARSE_ERROR: status_message_set(c, -1, 1, 0, 0, "%s", error);
if (cdata->item != NULL) } else
cmdq_error(cdata->item, "%s", pr->error); cmdq_error(cdata->item, "%s", error);
free(pr->error); free(error);
break; } else if (item == NULL) {
case CMD_PARSE_SUCCESS: new_item = cmdq_get_command(cmdlist, NULL);
if (cdata->item == NULL) cmdq_append(c, new_item);
new_state = cmdq_new_state(NULL, NULL, 0); } else {
else new_item = cmdq_get_command(cmdlist, cmdq_get_state(item));
new_state = cmdq_get_state(cdata->item); cmdq_insert_after(item, new_item);
new_item = cmdq_get_command(pr->cmdlist, new_state);
if (cdata->item == NULL)
cmdq_free_state(new_state);
cmd_list_free(pr->cmdlist);
break;
}
if (new_item != NULL) {
if (cdata->item == NULL)
cmdq_append(c, new_item);
else
cmdq_insert_after(cdata->item, new_item);
} }
out: out:
@@ -203,12 +182,9 @@ cmd_if_shell_free(void *data)
if (cdata->client != NULL) if (cdata->client != NULL)
server_client_unref(cdata->client); server_client_unref(cdata->client);
free(cdata->cmd_else); if (cdata->cmd_else != NULL)
free(cdata->cmd_if); args_make_commands_free(cdata->cmd_else);
args_make_commands_free(cdata->cmd_if);
if (cdata->input.c != NULL)
server_client_unref(cdata->input.c);
free((void *)cdata->input.file);
free(cdata); free(cdata);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-join-pane.c,v 1.73 2026/07/17 15:24:30 nicm Exp $ */
/* /*
* Copyright (c) 2011 George Nachman <tmux@georgester.com> * Copyright (c) 2011 George Nachman <tmux@georgester.com>
@@ -30,12 +30,15 @@
*/ */
static enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmdq_item *); static enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmdq_item *);
static enum cmd_retval cmd_join_pane_mouse_update(struct cmdq_item *);
static void cmd_join_pane_mouse_move(struct client *,
struct mouse_event *);
const struct cmd_entry cmd_join_pane_entry = { const struct cmd_entry cmd_join_pane_entry = {
.name = "join-pane", .name = "join-pane",
.alias = "joinp", .alias = "joinp",
.args = { "bdfhvp:l:s:t:", 0, 0 }, .args = { "bdfhvp:l:s:t:", 0, 0, NULL },
.usage = "[-bdfhv] [-l size] " CMD_SRCDST_PANE_USAGE, .usage = "[-bdfhv] [-l size] " CMD_SRCDST_PANE_USAGE,
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED }, .source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
@@ -49,8 +52,10 @@ const struct cmd_entry cmd_move_pane_entry = {
.name = "move-pane", .name = "move-pane",
.alias = "movep", .alias = "movep",
.args = { "bdfhvp:l:s:t:", 0, 0 }, .args = { "bdD::fhMvl:L::P:R::s:t:U::X:Y:z:", 0, 0, NULL },
.usage = "[-bdfhv] [-l size] " CMD_SRCDST_PANE_USAGE, .usage = "[-bdfhMv] [-D lines] [-l size] [-L columns] [-P position] "
"[-R columns] " CMD_SRCDST_PANE_USAGE " [-U lines] "
"[-X x-position] [-Y y-position] [-z z-index]",
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED }, .source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -59,6 +64,348 @@ const struct cmd_entry cmd_move_pane_entry = {
.exec = cmd_join_pane_exec .exec = cmd_join_pane_exec
}; };
static enum cmd_retval
cmd_join_pane_place(struct cmdq_item *item, struct winlink *wl,
struct window_pane *wp, const char *position)
{
struct window *w = wl->window;
struct layout_cell *lc = wp->layout_cell;
struct window_pane *owp;
int wx = w->sx, wy = w->sy;
int px = lc->g.sx, py = lc->g.sy;
int xoff = lc->g.xoff, yoff = lc->g.yoff;
int border = 1;
if (window_pane_get_pane_lines(wp) == PANE_LINES_NONE)
border = 0;
if (strcmp(position, "top-left") == 0) {
xoff = border;
yoff = border;
} else if (strcmp(position, "top-centre") == 0 ||
strcmp(position, "top-center") == 0) {
xoff = (wx - px) / 2;
yoff = border;
} else if (strcmp(position, "top-right") == 0) {
xoff = wx - px - border;
yoff = border;
} else if (strcmp(position, "centre-left") == 0 ||
strcmp(position, "center-left") == 0) {
xoff = border;
yoff = (wy - py) / 2;
} else if (strcmp(position, "centre") == 0 ||
strcmp(position, "center") == 0) {
xoff = (wx - px) / 2;
yoff = (wy - py) / 2;
} else if (strcmp(position, "centre-right") == 0 ||
strcmp(position, "center-right") == 0) {
xoff = wx - px - border;
yoff = (wy - py) / 2;
} else if (strcmp(position, "bottom-left") == 0) {
xoff = border;
yoff = wy - py - border;
} else if (strcmp(position, "bottom-centre") == 0 ||
strcmp(position, "bottom-center") == 0) {
xoff = (wx - px) / 2;
yoff = wy - py - border;
} else if (strcmp(position, "bottom-right") == 0) {
xoff = wx - px - border;
yoff = wy - py - border;
} else if (strcmp(position, "top-left-centre") == 0 ||
strcmp(position, "top-left-center") == 0) {
xoff = wx / 4 - px / 2;
yoff = wy / 4 - py / 2;
} else if (strcmp(position, "top-right-centre") == 0 ||
strcmp(position, "top-right-center") == 0) {
xoff = (3 * wx) / 4 - px / 2;
yoff = wy / 4 - py / 2;
} else if (strcmp(position, "bottom-left-centre") == 0 ||
strcmp(position, "bottom-left-center") == 0) {
xoff = wx / 4 - px / 2;
yoff = (3 * wy) / 4 - py / 2;
} else if (strcmp(position, "bottom-right-centre") == 0 ||
strcmp(position, "bottom-right-center") == 0) {
xoff = (3 * wx) / 4 - px / 2;
yoff = (3 * wy) / 4 - py / 2;
} else if (strcmp(position, "front") == 0) {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
} else if (strcmp(position, "back") == 0) {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_FOREACH(owp, &w->z_index, zentry) {
if (!window_pane_is_floating(owp))
break;
}
if (owp != NULL)
TAILQ_INSERT_BEFORE(owp, wp, zentry);
else
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
} else if (strcmp(position, "forward") == 0) {
owp = TAILQ_PREV(wp, window_panes_zindex, zentry);
if (owp != NULL) {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_BEFORE(owp, wp, zentry);
}
} else if (strcmp(position, "backward") == 0) {
owp = TAILQ_NEXT(wp, zentry);
if (owp != NULL && window_pane_is_floating(owp)) {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_AFTER(&w->z_index, owp, wp, zentry);
}
} else if (strcmp(position, "forward-loop") == 0) {
owp = TAILQ_PREV(wp, window_panes_zindex, zentry);
TAILQ_REMOVE(&w->z_index, wp, zentry);
if (owp != NULL)
TAILQ_INSERT_BEFORE(owp, wp, zentry);
else {
TAILQ_FOREACH(owp, &w->z_index, zentry) {
if (!window_pane_is_floating(owp))
break;
}
if (owp != NULL)
TAILQ_INSERT_BEFORE(owp, wp, zentry);
else
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
}
} else if (strcmp(position, "backward-loop") == 0) {
owp = TAILQ_NEXT(wp, zentry);
if (owp != NULL && window_pane_is_floating(owp)) {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_AFTER(&w->z_index, owp, wp, zentry);
} else {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
}
} else {
cmdq_error(item, "unknown position: %s", position);
return (CMD_RETURN_ERROR);
}
if (xoff != lc->g.xoff || yoff != lc->g.yoff) {
lc->g.xoff = xoff;
lc->g.yoff = yoff;
layout_fix_panes(w, NULL);
}
redraw_invalidate_scene(w);
events_fire_window("window-layout-changed", w);
server_redraw_window(w);
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_join_pane_move(struct cmdq_item *item, struct args *args,
struct winlink *wl, struct window_pane *wp)
{
struct window *w = wl->window;
struct layout_cell *lc = wp->layout_cell;
const char *errstr, *argval;
const char flags[] = { 'U', 'D', 'L', 'R' };
char *cause = NULL, flag;
int xoff = lc->g.xoff, yoff = lc->g.yoff, adjust;
u_int i;
enum pane_lines lines = window_pane_get_pane_lines(wp);
if (args_has(args, 'X')) {
xoff = args_percentage_and_expand(args, 'X', -(int)w->sx,
w->sx, w->sx, item, &cause);
if (cause != NULL) {
cmdq_error(item, "position %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
if (lines != PANE_LINES_NONE)
xoff += 1;
}
if (args_has(args, 'Y')) {
yoff = args_percentage_and_expand(args, 'Y', -(int)w->sy,
w->sy, w->sy, item, &cause);
if (cause != NULL) {
cmdq_error(item, "position %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
if (lines != PANE_LINES_NONE)
yoff += 1;
}
for (i = 0; i < nitems(flags); i++) {
flag = flags[i];
if (!args_has(args, flag))
continue;
argval = args_get(args, flag);
if (argval == NULL)
argval = "1";
adjust = strtonum(argval, INT_MIN, INT_MAX, &errstr);
if (errstr != NULL) {
cmdq_error(item, "offset %s", errstr);
return (CMD_RETURN_ERROR);
}
if (flag == 'U')
yoff -= adjust;
else if (flag == 'D')
yoff += adjust;
else if (flag == 'L')
xoff -= adjust;
else
xoff += adjust;
}
if (xoff != lc->g.xoff || yoff != lc->g.yoff) {
lc->g.xoff = xoff;
lc->g.yoff = yoff;
layout_fix_panes(w, NULL);
events_fire_window("window-layout-changed", w);
server_redraw_window(w);
}
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_join_pane_mouse_update(struct cmdq_item *item)
{
struct cmd_find_state *target = cmdq_get_target(item);
struct key_event *event = cmdq_get_event(item);
struct client *c = cmdq_get_client(item);
struct session *s = target->s;
struct winlink *wl;
struct window *w;
struct window_pane *wp;
if (!event->m.valid)
return (CMD_RETURN_NORMAL);
wp = cmd_mouse_pane(&event->m, &s, &wl);
if (wp == NULL || c == NULL || c->session != s)
return (CMD_RETURN_NORMAL);
if (!window_pane_is_floating(wp))
return (CMD_RETURN_NORMAL);
w = wl->window;
window_redraw_active_switch(w, wp);
window_set_active_pane(w, wp, 1);
c->tty.mouse_drag_update = cmd_join_pane_mouse_move;
cmd_join_pane_mouse_move(c, &event->m);
return (CMD_RETURN_NORMAL);
}
static void
cmd_join_pane_mouse_move(struct client *c, struct mouse_event *m)
{
struct winlink *wl;
struct window *w;
struct window_pane *wp;
struct layout_cell *lc;
int y, ly, x, lx;
wp = cmd_mouse_pane(m, NULL, &wl);
if (wp == NULL) {
c->tty.mouse_drag_update = NULL;
return;
}
w = wl->window;
lc = wp->layout_cell;
y = m->y + m->oy; x = m->x + m->ox;
if (m->statusat == 0 && y >= (int)m->statuslines)
y -= m->statuslines;
else if (m->statusat > 0 && y >= m->statusat)
y = m->statusat - 1;
ly = m->ly + m->oy; lx = m->lx + m->ox;
if (m->statusat == 0 && ly >= (int)m->statuslines)
ly -= m->statuslines;
else if (m->statusat > 0 && ly >= m->statusat)
ly = m->statusat - 1;
if (x != lx || y != ly) {
lc->g.xoff += x - lx;
lc->g.yoff += y - ly;
layout_fix_panes(w, NULL);
server_redraw_window(w);
server_redraw_window_borders(w);
}
}
static enum cmd_retval
cmd_join_pane_zindex(struct cmdq_item *item, struct winlink *wl,
struct window_pane *wp, const char *s)
{
struct window *w = wl->window;
struct window_pane *owp;
const char *errstr;
u_int n, z;
z = strtonum(s, 0, UINT_MAX, &errstr);
if (errstr != NULL) {
cmdq_error(item, "z-index %s", errstr);
return (CMD_RETURN_ERROR);
}
TAILQ_REMOVE(&w->z_index, wp, zentry);
n = 0;
TAILQ_FOREACH(owp, &w->z_index, zentry) {
if (!window_pane_is_floating(owp))
break;
if (n >= z)
break;
n++;
}
if (owp != NULL)
TAILQ_INSERT_BEFORE(owp, wp, zentry);
else
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
redraw_invalidate_scene(w);
events_fire_window("window-layout-changed", w);
server_redraw_window(w);
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_join_pane_tile(struct cmdq_item *item, struct args *args, struct window *w,
struct window_pane *wp)
{
struct layout_cell *lc = wp->layout_cell;
if (!window_pane_is_floating(wp)) {
cmdq_error(item, "pane is not floating");
return (CMD_RETURN_ERROR);
}
if (w->flags & WINDOW_ZOOMED) {
cmdq_error(item, "can't tile a pane while window is zoomed");
return (CMD_RETURN_ERROR);
}
lc->fg.sx = lc->g.sx;
lc->fg.sy = lc->g.sy;
lc->fg.xoff = lc->g.xoff;
lc->fg.yoff = lc->g.yoff;
if (layout_insert_tile(w, lc) != 0) {
cmdq_error(item, "no space for a new pane");
return (CMD_RETURN_ERROR);
}
lc->flags &= ~LAYOUT_CELL_FLOATING;
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
if (!args_has(args, 'd'))
window_set_active_pane(w, wp, 1);
layout_fix_offsets(w);
layout_fix_panes(w, NULL);
redraw_invalidate_scene(w);
events_fire_window("window-layout-changed", w);
server_redraw_window(w);
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval static enum cmd_retval
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
@@ -70,10 +417,9 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
struct winlink *src_wl, *dst_wl; struct winlink *src_wl, *dst_wl;
struct window *src_w, *dst_w; struct window *src_w, *dst_w;
struct window_pane *src_wp, *dst_wp; struct window_pane *src_wp, *dst_wp;
const char *s;
char *cause = NULL; char *cause = NULL;
int size, percentage, dst_idx; int flags = 0, dst_idx;
int flags;
enum layout_type type;
struct layout_cell *lc; struct layout_cell *lc;
dst_s = target->s; dst_s = target->s;
@@ -81,55 +427,63 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
dst_wp = target->wp; dst_wp = target->wp;
dst_w = dst_wl->window; dst_w = dst_wl->window;
dst_idx = dst_wl->idx; dst_idx = dst_wl->idx;
server_unzoom_window(dst_w);
if (cmd_get_entry(self) == &cmd_move_pane_entry) {
if (args_has(args, 'M'))
return (cmd_join_pane_mouse_update(item));
if (!window_pane_is_floating(dst_wp)) {
cmdq_error(item, "pane is not floating");
return (CMD_RETURN_ERROR);
}
if ((s = args_get(args, 'P')) != NULL) {
server_unzoom_window(dst_w);
return (cmd_join_pane_place(item, dst_wl, dst_wp, s));
}
if ((s = args_get(args, 'z')) != NULL) {
server_unzoom_window(dst_w);
return (cmd_join_pane_zindex(item, dst_wl, dst_wp, s));
}
if (args_has(args, 'X') ||
args_has(args, 'Y') ||
args_has(args, 'U') ||
args_has(args, 'D') ||
args_has(args, 'L') ||
args_has(args, 'R')) {
server_unzoom_window(dst_w);
return (cmd_join_pane_move(item, args, dst_wl, dst_wp));
}
}
src_wl = source->wl; src_wl = source->wl;
src_wp = source->wp; src_wp = source->wp;
src_w = src_wl->window; src_w = src_wl->window;
if (src_wp == src_w->modal || dst_wp == dst_w->modal) {
cmdq_error(item, "pane is modal");
return (CMD_RETURN_ERROR);
}
server_unzoom_window(dst_w);
server_unzoom_window(src_w); server_unzoom_window(src_w);
if (src_wp == dst_wp) { if (src_wp == dst_wp) {
if (window_pane_is_floating(src_wp))
return (cmd_join_pane_tile(item, args, src_w, src_wp));
cmdq_error(item, "source and target panes must be different"); cmdq_error(item, "source and target panes must be different");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
type = LAYOUT_TOPBOTTOM;
if (args_has(args, 'h')) if (args_has(args, 'h'))
type = LAYOUT_LEFTRIGHT; flags |= SPAWN_HORIZONTAL;
size = -1;
if (args_has(args, 'l')) {
if (type == LAYOUT_TOPBOTTOM) {
size = args_percentage(args, 'l', 0, INT_MAX,
dst_wp->sy, &cause);
} else {
size = args_percentage(args, 'l', 0, INT_MAX,
dst_wp->sx, &cause);
}
} else if (args_has(args, 'p')) {
percentage = args_strtonum(args, 'p', 0, 100, &cause);
if (cause == NULL) {
if (type == LAYOUT_TOPBOTTOM)
size = (dst_wp->sy * percentage) / 100;
else
size = (dst_wp->sx * percentage) / 100;
}
}
if (cause != NULL) {
cmdq_error(item, "size %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
flags = 0;
if (args_has(args, 'b')) if (args_has(args, 'b'))
flags |= SPAWN_BEFORE; flags |= SPAWN_BEFORE;
if (args_has(args, 'f')) if (args_has(args, 'f'))
flags |= SPAWN_FULLSIZE; flags |= SPAWN_FULLSIZE;
lc = layout_split_pane(dst_wp, type, size, flags); lc = layout_get_tiled_cell(item, args, dst_w, dst_wp, flags, &cause);
if (lc == NULL) { if (cause != NULL) {
cmdq_error(item, "create pane failed: pane too small"); cmdq_error(item, "size or position %s", cause);
free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
@@ -138,15 +492,20 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
server_client_remove_pane(src_wp); server_client_remove_pane(src_wp);
window_lost_pane(src_w, src_wp); window_lost_pane(src_w, src_wp);
TAILQ_REMOVE(&src_w->panes, src_wp, entry); TAILQ_REMOVE(&src_w->panes, src_wp, entry);
TAILQ_REMOVE(&src_w->z_index, src_wp, zentry);
src_wp->window = dst_w; src_wp->window = dst_w;
options_set_parent(src_wp->options, dst_w->options); options_set_parent(src_wp->options, dst_w->options);
src_wp->flags |= PANE_STYLECHANGED; src_wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
if (flags & SPAWN_BEFORE) if (flags & SPAWN_BEFORE) {
TAILQ_INSERT_BEFORE(dst_wp, src_wp, entry); TAILQ_INSERT_BEFORE(dst_wp, src_wp, entry);
else TAILQ_INSERT_BEFORE(dst_wp, src_wp, zentry);
} else {
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry); TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
TAILQ_INSERT_AFTER(&dst_w->z_index, dst_wp, src_wp, zentry);
}
layout_assign_pane(lc, src_wp, 0); layout_assign_pane(lc, src_wp, 0);
colour_palette_from_option(&src_wp->palette, src_wp->options);
recalculate_sizes(); recalculate_sizes();
@@ -161,11 +520,12 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
} else } else
server_status_session(dst_s); server_status_session(dst_s);
if (window_count_panes(src_w) == 0) window_fire_pane_moved(src_wp, src_w, src_wl->idx, dst_w, dst_idx);
if (window_count_panes(src_w, 1) == 0)
server_kill_window(src_w, 1); server_kill_window(src_w, 1);
else else
notify_window("window-layout-changed", src_w); events_fire_window("window-layout-changed", src_w);
notify_window("window-layout-changed", dst_w); events_fire_window("window-layout-changed", dst_w);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-kill-pane.c,v 1.34 2026/06/09 21:22:22 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -27,13 +27,17 @@
*/ */
static enum cmd_retval cmd_kill_pane_exec(struct cmd *, struct cmdq_item *); static enum cmd_retval cmd_kill_pane_exec(struct cmd *, struct cmdq_item *);
static enum cmd_retval cmd_kill_pane_all(struct cmdq_item *, const char *);
static int cmd_kill_pane_filter(struct cmdq_item *,
struct session *, struct winlink *,
struct window_pane *, const char *);
const struct cmd_entry cmd_kill_pane_entry = { const struct cmd_entry cmd_kill_pane_entry = {
.name = "kill-pane", .name = "kill-pane",
.alias = "killp", .alias = "killp",
.args = { "at:", 0, 0 }, .args = { "af:t:", 0, 0, NULL },
.usage = "[-a] " CMD_TARGET_PANE_USAGE, .usage = "[-a] [-f filter] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -46,22 +50,66 @@ cmd_kill_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl; struct window_pane *wp = target->wp;
struct window_pane *loopwp, *tmpwp, *wp = target->wp; const char *filter = args_get(args, 'f');
if (args_has(args, 'a')) { if (filter != NULL && !args_has(args, 'a')) {
server_unzoom_window(wl->window); cmdq_error(item, "-f only valid with -a");
TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) { return (CMD_RETURN_ERROR);
if (loopwp == wp)
continue;
server_client_remove_pane(loopwp);
layout_close_pane(loopwp);
window_remove_pane(wl->window, loopwp);
}
server_redraw_window(wl->window);
return (CMD_RETURN_NORMAL);
} }
if (args_has(args, 'a'))
return (cmd_kill_pane_all(item, filter));
if (wp == NULL) {
cmdq_error(item, "no active pane to kill");
return (CMD_RETURN_ERROR);
}
server_kill_pane(wp); server_kill_pane(wp);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
static enum cmd_retval
cmd_kill_pane_all(struct cmdq_item *item, const char *filter)
{
struct cmd_find_state *target = cmdq_get_target(item);
struct session *s = target->s;
struct winlink *wl = target->wl;
struct window_pane *wp = target->wp;
struct window_pane *loopwp, *tmpwp;
server_unzoom_window(wl->window);
TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) {
if (loopwp == wp)
continue;
if (!cmd_kill_pane_filter(item, s, wl, loopwp, filter))
continue;
server_client_remove_pane(loopwp);
layout_close_pane(loopwp);
window_remove_pane(wl->window, loopwp);
}
server_redraw_window(wl->window);
return (CMD_RETURN_NORMAL);
}
static int
cmd_kill_pane_filter(struct cmdq_item *item, struct session *s,
struct winlink *wl, struct window_pane *wp, const char *filter)
{
struct format_tree *ft;
char *expanded;
int flag;
if (filter == NULL)
return (1);
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_defaults(ft, NULL, s, wl, wp);
expanded = format_expand(ft, filter);
flag = format_true(expanded);
free(expanded);
format_free(ft);
return (flag);
}

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-kill-server.c,v 1.20 2021/08/21 10:22:39 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_kill_server_entry = {
.name = "kill-server", .name = "kill-server",
.alias = NULL, .alias = NULL,
.args = { "", 0, 0 }, .args = { "", 0, 0, NULL },
.usage = "", .usage = "",
.flags = 0, .flags = 0,
@@ -44,7 +44,7 @@ const struct cmd_entry cmd_start_server_entry = {
.name = "start-server", .name = "start-server",
.alias = "start", .alias = "start",
.args = { "", 0, 0 }, .args = { "", 0, 0, NULL },
.usage = "", .usage = "",
.flags = CMD_STARTSERVER, .flags = CMD_STARTSERVER,

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-kill-session.c,v 1.31 2026/06/09 12:57:40 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -18,6 +18,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h>
#include "tmux.h" #include "tmux.h"
/* /*
@@ -28,13 +30,16 @@
*/ */
static enum cmd_retval cmd_kill_session_exec(struct cmd *, struct cmdq_item *); static enum cmd_retval cmd_kill_session_exec(struct cmd *, struct cmdq_item *);
static enum cmd_retval cmd_kill_session_all(struct cmdq_item *, const char *);
static int cmd_kill_session_filter(struct cmdq_item *,
struct session *, const char *);
const struct cmd_entry cmd_kill_session_entry = { const struct cmd_entry cmd_kill_session_entry = {
.name = "kill-session", .name = "kill-session",
.alias = NULL, .alias = NULL,
.args = { "aCt:", 0, 0 }, .args = { "aCgf:t:", 0, 0, NULL },
.usage = "[-aC] " CMD_TARGET_SESSION_USAGE, .usage = "[-aCg] [-f filter] " CMD_TARGET_SESSION_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 }, .target = { 't', CMD_FIND_SESSION, 0 },
@@ -48,7 +53,14 @@ cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct session *s = target->s, *sloop, *stmp; struct session *s = target->s, *sloop, *stmp;
struct session_group *sg;
struct winlink *wl; struct winlink *wl;
const char *filter = args_get(args, 'f');
if (filter != NULL && (!args_has(args, 'a') || args_has(args, 'C'))) {
cmdq_error(item, "-f only valid with -a");
return (CMD_RETURN_ERROR);
}
if (args_has(args, 'C')) { if (args_has(args, 'C')) {
RB_FOREACH(wl, winlinks, &s->windows) { RB_FOREACH(wl, winlinks, &s->windows) {
@@ -56,12 +68,13 @@ cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
wl->flags &= ~WINLINK_ALERTFLAGS; wl->flags &= ~WINLINK_ALERTFLAGS;
} }
server_redraw_session(s); server_redraw_session(s);
} else if (args_has(args, 'a')) { } else if (args_has(args, 'a'))
RB_FOREACH_SAFE(sloop, sessions, &sessions, stmp) { return (cmd_kill_session_all(item, filter));
if (sloop != s) { else if (args_has(args, 'g') &&
server_destroy_session(sloop); (sg = session_group_contains(s)) != NULL) {
session_destroy(sloop, 1, __func__); TAILQ_FOREACH_SAFE(sloop, &sg->sessions, gentry, stmp) {
} server_destroy_session(sloop);
session_destroy(sloop, 1, __func__);
} }
} else { } else {
server_destroy_session(s); server_destroy_session(s);
@@ -69,3 +82,42 @@ cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
} }
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
static enum cmd_retval
cmd_kill_session_all(struct cmdq_item *item, const char *filter)
{
struct session *s = cmdq_get_target(item)->s;
struct session *sloop, *stmp;
RB_FOREACH_SAFE(sloop, sessions, &sessions, stmp) {
if (sloop == s)
continue;
if (!cmd_kill_session_filter(item, sloop, filter))
continue;
server_destroy_session(sloop);
session_destroy(sloop, 1, __func__);
}
return (CMD_RETURN_NORMAL);
}
static int
cmd_kill_session_filter(struct cmdq_item *item, struct session *s,
const char *filter)
{
struct format_tree *ft;
char *expanded;
int flag;
if (filter == NULL)
return (1);
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_defaults(ft, NULL, s, NULL, NULL);
expanded = format_expand(ft, filter);
flag = format_true(expanded);
free(expanded);
format_free(ft);
return (flag);
}

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-kill-window.c,v 1.30 2026/06/09 12:57:40 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -18,6 +18,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h>
#include "tmux.h" #include "tmux.h"
/* /*
@@ -25,13 +27,16 @@
*/ */
static enum cmd_retval cmd_kill_window_exec(struct cmd *, struct cmdq_item *); static enum cmd_retval cmd_kill_window_exec(struct cmd *, struct cmdq_item *);
static enum cmd_retval cmd_kill_window_all(struct cmdq_item *, const char *);
static int cmd_kill_window_filter(struct cmdq_item *,
struct session *, struct winlink *, const char *);
const struct cmd_entry cmd_kill_window_entry = { const struct cmd_entry cmd_kill_window_entry = {
.name = "kill-window", .name = "kill-window",
.alias = "killw", .alias = "killw",
.args = { "at:", 0, 0 }, .args = { "af:t:", 0, 0, NULL },
.usage = "[-a] " CMD_TARGET_WINDOW_USAGE, .usage = "[-a] [-f filter] " CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
@@ -43,7 +48,7 @@ const struct cmd_entry cmd_unlink_window_entry = {
.name = "unlink-window", .name = "unlink-window",
.alias = "unlinkw", .alias = "unlinkw",
.args = { "kt:", 0, 0 }, .args = { "kt:", 0, 0, NULL },
.usage = "[-k] " CMD_TARGET_WINDOW_USAGE, .usage = "[-k] " CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
@@ -57,10 +62,15 @@ cmd_kill_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl, *loop; struct winlink *wl = target->wl;
struct window *w = wl->window; struct window *w = wl->window;
struct session *s = target->s; struct session *s = target->s;
u_int found; const char *filter = args_get(args, 'f');
if (filter != NULL && !args_has(args, 'a')) {
cmdq_error(item, "-f only valid with -a");
return (CMD_RETURN_ERROR);
}
if (cmd_get_entry(self) == &cmd_unlink_window_entry) { if (cmd_get_entry(self) == &cmd_unlink_window_entry) {
if (!args_has(args, 'k') && !session_is_linked(s, w)) { if (!args_has(args, 'k') && !session_is_linked(s, w)) {
@@ -72,39 +82,76 @@ cmd_kill_window_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(args, 'a')) { if (args_has(args, 'a'))
if (RB_PREV(winlinks, &s->windows, wl) == NULL && return (cmd_kill_window_all(item, filter));
RB_NEXT(winlinks, &s->windows, wl) == NULL)
return (CMD_RETURN_NORMAL);
/* Kill all windows except the current one. */
do {
found = 0;
RB_FOREACH(loop, winlinks, &s->windows) {
if (loop->window != wl->window) {
server_kill_window(loop->window, 0);
found++;
break;
}
}
} while (found != 0);
/*
* If the current window appears in the session more than once,
* kill it as well.
*/
found = 0;
RB_FOREACH(loop, winlinks, &s->windows) {
if (loop->window == wl->window)
found++;
}
if (found > 1)
server_kill_window(wl->window, 0);
server_renumber_all();
return (CMD_RETURN_NORMAL);
}
server_kill_window(wl->window, 1); server_kill_window(wl->window, 1);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
static enum cmd_retval
cmd_kill_window_all(struct cmdq_item *item, const char *filter)
{
struct cmd_find_state *target = cmdq_get_target(item);
struct session *s = target->s;
struct winlink *wl = target->wl;
struct winlink *loop;
u_int found, kill_current;
if (RB_PREV(winlinks, &s->windows, wl) == NULL &&
RB_NEXT(winlinks, &s->windows, wl) == NULL)
return (CMD_RETURN_NORMAL);
/* Kill all windows except the current one. */
do {
found = 0;
RB_FOREACH(loop, winlinks, &s->windows) {
if (loop->window != wl->window &&
cmd_kill_window_filter(item, s, loop, filter)) {
server_kill_window(loop->window, 0);
found++;
break;
}
}
} while (found != 0);
/*
* If the current window appears in the session more than once, kill it
* as well if it matches the filter.
*/
found = kill_current = 0;
RB_FOREACH(loop, winlinks, &s->windows) {
if (loop->window == wl->window) {
found++;
if (cmd_kill_window_filter(item, s, loop, filter))
kill_current = 1;
}
}
if (kill_current && found > 1)
server_kill_window(wl->window, 0);
server_renumber_all();
return (CMD_RETURN_NORMAL);
}
static int
cmd_kill_window_filter(struct cmdq_item *item, struct session *s,
struct winlink *wl, const char *filter)
{
struct format_tree *ft;
char *expanded;
int flag;
if (filter == NULL)
return (1);
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_defaults(ft, NULL, s, wl, NULL);
expanded = format_expand(ft, filter);
flag = format_true(expanded);
free(expanded);
format_free(ft);
return (flag);
}

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-list-buffers.c,v 1.41 2026/02/27 08:25:12 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -36,8 +36,8 @@ const struct cmd_entry cmd_list_buffers_entry = {
.name = "list-buffers", .name = "list-buffers",
.alias = "lsb", .alias = "lsb",
.args = { "F:f:", 0, 0 }, .args = { "F:f:O:r", 0, 0, NULL },
.usage = "[-F format] [-f filter]", .usage = "[-F format] [-f filter] [-O order]",
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
.exec = cmd_list_buffers_exec .exec = cmd_list_buffers_exec
@@ -46,21 +46,30 @@ const struct cmd_entry cmd_list_buffers_entry = {
static enum cmd_retval static enum cmd_retval
cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item) cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct paste_buffer *pb; struct paste_buffer **l;
struct format_tree *ft; struct format_tree *ft;
const char *template, *filter; const char *template, *filter;
char *line, *expanded; char *line, *expanded;
int flag; int flag;
u_int i, n;
struct sort_criteria sort_crit;
if ((template = args_get(args, 'F')) == NULL) if ((template = args_get(args, 'F')) == NULL)
template = LIST_BUFFERS_TEMPLATE; template = LIST_BUFFERS_TEMPLATE;
filter = args_get(args, 'f'); filter = args_get(args, 'f');
pb = NULL; sort_crit.order = sort_order_from_string(args_get(args, 'O'));
while ((pb = paste_walk(pb)) != NULL) { if (sort_crit.order == SORT_END && args_has(args, 'O')) {
cmdq_error(item, "invalid sort order");
return (CMD_RETURN_ERROR);
}
sort_crit.reversed = args_has(args, 'r');
l = sort_get_buffers(&n, &sort_crit);
for (i = 0; i < n; i++) {
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_defaults_paste_buffer(ft, pb); format_defaults_paste_buffer(ft, l[i]);
if (filter != NULL) { if (filter != NULL) {
expanded = format_expand(ft, filter); expanded = format_expand(ft, filter);

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-list-clients.c,v 1.42 2026/02/27 08:25:12 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -31,6 +31,8 @@
#define LIST_CLIENTS_TEMPLATE \ #define LIST_CLIENTS_TEMPLATE \
"#{client_name}: #{session_name} " \ "#{client_name}: #{session_name} " \
"[#{client_width}x#{client_height} #{client_termname}] " \ "[#{client_width}x#{client_height} #{client_termname}] " \
"#{?#{!=:#{client_uid},#{uid}}," \
"[user #{?client_user,#{client_user},#{client_uid},}] ,}" \
"#{?client_flags,(,}#{client_flags}#{?client_flags,),}" "#{?client_flags,(,}#{client_flags}#{?client_flags,),}"
static enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmdq_item *); static enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmdq_item *);
@@ -39,8 +41,8 @@ const struct cmd_entry cmd_list_clients_entry = {
.name = "list-clients", .name = "list-clients",
.alias = "lsc", .alias = "lsc",
.args = { "F:t:", 0, 0 }, .args = { "F:f:O:rt:", 0, 0, NULL },
.usage = "[-F format] " CMD_TARGET_SESSION_USAGE, .usage = "[-F format] [-f filter] [-O order]" CMD_TARGET_SESSION_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 }, .target = { 't', CMD_FIND_SESSION, 0 },
@@ -51,14 +53,16 @@ const struct cmd_entry cmd_list_clients_entry = {
static enum cmd_retval static enum cmd_retval
cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item) cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct client *c; struct client **l;
struct session *s; struct session *s;
struct format_tree *ft; struct format_tree *ft;
const char *template; const char *template, *filter;
u_int idx; u_int i, n;
char *line; char *line, *expanded;
int flag;
struct sort_criteria sort_crit;
if (args_has(args, 't')) if (args_has(args, 't'))
s = target->s; s = target->s;
@@ -67,23 +71,37 @@ cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
if ((template = args_get(args, 'F')) == NULL) if ((template = args_get(args, 'F')) == NULL)
template = LIST_CLIENTS_TEMPLATE; template = LIST_CLIENTS_TEMPLATE;
filter = args_get(args, 'f');
idx = 0; sort_crit.order = sort_order_from_string(args_get(args, 'O'));
TAILQ_FOREACH(c, &clients, entry) { if (sort_crit.order == SORT_END && args_has(args, 'O')) {
if (c->session == NULL || (s != NULL && s != c->session)) cmdq_error(item, "invalid sort order");
return (CMD_RETURN_ERROR);
}
sort_crit.reversed = args_has(args, 'r');
l = sort_get_clients(&n, &sort_crit);
for (i = 0; i < n; i++) {
if (l[i]->session == NULL || (s != NULL && s != l[i]->session))
continue; continue;
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", idx); format_add(ft, "line", "%u", i);
format_defaults(ft, c, NULL, NULL, NULL); format_defaults(ft, l[i], NULL, NULL, NULL);
line = format_expand(ft, template); if (filter != NULL) {
cmdq_print(item, "%s", line); expanded = format_expand(ft, filter);
free(line); flag = format_true(expanded);
free(expanded);
} else
flag = 1;
if (flag) {
line = format_expand(ft, template);
cmdq_print(item, "%s", line);
free(line);
}
format_free(ft); format_free(ft);
idx++;
} }
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);

107
cmd-list-commands.c Normal file
View File

@@ -0,0 +1,107 @@
/* $OpenBSD: cmd-list-commands.c,v 1.15 2026/02/24 08:22:13 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include "tmux.h"
/*
* List all commands.
*/
#define LIST_COMMANDS_TEMPLATE \
"#{command_list_name}" \
"#{?command_list_alias, (#{command_list_alias}),} " \
"#{command_list_usage}"
static enum cmd_retval cmd_list_commands(struct cmd *, struct cmdq_item *);
const struct cmd_entry cmd_list_commands_entry = {
.name = "list-commands",
.alias = "lscm",
.args = { "F:", 0, 1, NULL },
.usage = "[-F format] [command]",
.flags = CMD_STARTSERVER|CMD_AFTERHOOK,
.exec = cmd_list_commands
};
static void
cmd_list_single_command(const struct cmd_entry *entry, struct format_tree *ft,
const char *template, struct cmdq_item *item)
{
const char *s;
char *line;
format_add(ft, "command_list_name", "%s", entry->name);
if (entry->alias != NULL)
s = entry->alias;
else
s = "";
format_add(ft, "command_list_alias", "%s", s);
if (entry->usage != NULL)
s = entry->usage;
else
s = "";
format_add(ft, "command_list_usage", "%s", s);
line = format_expand(ft, template);
if (*line != '\0')
cmdq_print(item, "%s", line);
free(line);
}
static enum cmd_retval
cmd_list_commands(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
const struct cmd_entry **entryp;
const struct cmd_entry *entry;
struct format_tree *ft;
const char *template, *command;
char *cause;
if ((template = args_get(args, 'F')) == NULL)
template = LIST_COMMANDS_TEMPLATE;
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_defaults(ft, NULL, NULL, NULL, NULL);
command = args_string(args, 0);
if (command == NULL) {
for (entryp = cmd_table; *entryp != NULL; entryp++)
cmd_list_single_command(*entryp, ft, template, item);
} else {
entry = cmd_find(command, &cause);
if (entry != NULL)
cmd_list_single_command(entry, ft, template, item);
else {
cmdq_error(item, "%s", cause);
free(cause);
format_free(ft);
return (CMD_RETURN_ERROR);
}
}
format_free(ft);
return (CMD_RETURN_NORMAL);
}

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-list-keys.c,v 1.78 2026/07/01 13:12:17 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -27,341 +27,232 @@
* List key bindings. * List key bindings.
*/ */
static enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmdq_item *); #define LIST_KEYS_TEMPLATE \
"#{?notes_only," \
"#{key_prefix} " \
"#{p|#{key_string_width}:key_string} " \
"#{?key_note,#{key_note},#{key_command}}" \
"," \
"bind-key #{?key_has_repeat,#{?key_repeat,-r, },} " \
"-T #{p|#{key_table_width}:key_table} " \
"#{p|#{key_string_width}:#{q|a:key_string}} " \
"#{key_command}}"
static enum cmd_retval cmd_list_keys_commands(struct cmd *, static enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmdq_item *);
struct cmdq_item *);
const struct cmd_entry cmd_list_keys_entry = { const struct cmd_entry cmd_list_keys_entry = {
.name = "list-keys", .name = "list-keys",
.alias = "lsk", .alias = "lsk",
.args = { "1aNP:T:", 0, 1 }, .args = { "1aF:NO:P:rT:", 0, 1, NULL },
.usage = "[-1aN] [-P prefix-string] [-T key-table] [key]", .usage = "[-1aNr] [-F format] [-O order] [-P prefix-string]"
"[-T key-table] [key]",
.flags = CMD_STARTSERVER|CMD_AFTERHOOK, .flags = CMD_STARTSERVER|CMD_AFTERHOOK,
.exec = cmd_list_keys_exec .exec = cmd_list_keys_exec
}; };
const struct cmd_entry cmd_list_commands_entry = { static char *
.name = "list-commands", cmd_list_keys_get_prefix(struct args *args)
.alias = "lscm", {
key_code prefix;
.args = { "F:", 0, 1 }, if (args_has(args, 'P'))
.usage = "[-F format] [command]", return (xstrdup(args_get(args, 'P')));
.flags = CMD_STARTSERVER|CMD_AFTERHOOK, prefix = options_get_number(global_s_options, "prefix");
.exec = cmd_list_keys_exec if (prefix == KEYC_NONE)
}; return (xstrdup(""));
return (xstrdup(key_string_lookup_key(prefix, 0)));
}
static u_int static u_int
cmd_list_keys_get_width(const char *tablename, key_code only) cmd_list_keys_get_width(struct key_binding **l, u_int n)
{ {
struct key_table *table; u_int i, width, keywidth = 0;
struct key_binding *bd;
u_int width, keywidth = 0;
table = key_bindings_get_table(tablename, 0); for (i = 0; i < n; i++) {
if (table == NULL) width = utf8_cstrwidth(key_string_lookup_key(l[i]->key, 0));
return (0);
bd = key_bindings_first(table);
while (bd != NULL) {
if ((only != KEYC_UNKNOWN && bd->key != only) ||
KEYC_IS_MOUSE(bd->key) ||
bd->note == NULL ||
*bd->note == '\0') {
bd = key_bindings_next(table, bd);
continue;
}
width = utf8_cstrwidth(key_string_lookup_key(bd->key, 0));
if (width > keywidth) if (width > keywidth)
keywidth = width; keywidth = width;
bd = key_bindings_next(table, bd);
} }
return (keywidth); return (keywidth);
} }
static int static u_int
cmd_list_keys_print_notes(struct cmdq_item *item, struct args *args, cmd_list_keys_get_table_width(struct key_binding **l, u_int n)
const char *tablename, u_int keywidth, key_code only, const char *prefix)
{ {
struct client *tc = cmdq_get_target_client(item); u_int i, width, tablewidth = 0;
struct key_table *table;
struct key_binding *bd;
const char *key;
char *tmp, *note;
int found = 0;
table = key_bindings_get_table(tablename, 0); for (i = 0; i < n; i++) {
if (table == NULL) width = utf8_cstrwidth(l[i]->tablename);
return (0); if (width > tablewidth)
bd = key_bindings_first(table); tablewidth = width;
while (bd != NULL) {
if ((only != KEYC_UNKNOWN && bd->key != only) ||
KEYC_IS_MOUSE(bd->key) ||
((bd->note == NULL || *bd->note == '\0') &&
!args_has(args, 'a'))) {
bd = key_bindings_next(table, bd);
continue;
}
found = 1;
key = key_string_lookup_key(bd->key, 0);
if (bd->note == NULL || *bd->note == '\0')
note = cmd_list_print(bd->cmdlist, 1);
else
note = xstrdup(bd->note);
tmp = utf8_padcstr(key, keywidth + 1);
if (args_has(args, '1') && tc != NULL) {
status_message_set(tc, -1, 1, 0, "%s%s%s", prefix, tmp,
note);
} else
cmdq_print(item, "%s%s%s", prefix, tmp, note);
free(tmp);
free(note);
if (args_has(args, '1'))
break;
bd = key_bindings_next(table, bd);
} }
return (found); return (tablewidth);
} }
static char * static struct key_binding **
cmd_list_keys_get_prefix(struct args *args, key_code *prefix) cmd_list_keys_get_root_and_prefix(u_int *n, struct sort_criteria *sort_crit)
{
const char *tables[] = { "prefix", "root" };
struct key_table *t;
struct key_binding **lt;
u_int i, ltsz, len = 0, offset = 0;
static struct key_binding **l = NULL;
static u_int lsz = 0;
for (i = 0; i < nitems(tables); i++) {
t = key_bindings_get_table(tables[i], 0);
lt = sort_get_key_bindings_table(t, &ltsz, sort_crit);
len += ltsz;
if (lsz <= len) {
lsz = len + 100;
l = xreallocarray(l, lsz, sizeof *l);
}
memcpy(l + offset, lt, ltsz * sizeof *l);
offset += ltsz;
}
*n = len;
return (l);
}
static void
cmd_list_keys_filter_key_list(int filter_notes, int filter_key, key_code only,
struct key_binding **l, u_int *n)
{
key_code key;
u_int i, j = 0;
for (i = 0; i < *n; i++) {
key = l[i]->key & (KEYC_MASK_KEY|KEYC_MASK_MODIFIERS);
if (filter_key && only != key)
continue;
if (filter_notes && l[i]->note == NULL)
continue;
l[j++] = l[i];
}
*n = j;
}
static void
cmd_list_keys_format_add_key_binding(struct format_tree *ft,
const struct key_binding *bd, const char *prefix)
{ {
char *s; char *s;
*prefix = options_get_number(global_s_options, "prefix"); if (bd->flags & KEY_BINDING_REPEAT)
if (!args_has(args, 'P')) { format_add(ft, "key_repeat", "1");
if (*prefix != KEYC_NONE) else
xasprintf(&s, "%s ", key_string_lookup_key(*prefix, 0)); format_add(ft, "key_repeat", "0");
else
s = xstrdup(""); if (bd->note != NULL)
} else format_add(ft, "key_note", "%s", bd->note);
s = xstrdup(args_get(args, 'P')); else
return (s); format_add(ft, "key_note", "%s", "");
format_add(ft, "key_prefix", "%s", prefix);
format_add(ft, "key_table", "%s", bd->tablename);
format_add(ft, "key_string", "%s", key_string_lookup_key(bd->key, 0));
s = cmd_list_print(bd->cmdlist, CMD_LIST_PRINT_ESCAPED|
CMD_LIST_PRINT_NO_GROUPS);
format_add(ft, "key_command", "%s", s);
free(s);
} }
static enum cmd_retval static enum cmd_retval
cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item) cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct key_table *table; struct client *tc = cmdq_get_target_client(item);
struct key_binding *bd; struct format_tree *ft;
const char *tablename, *r; struct key_table *table = NULL;
char *key, *cp, *tmp, *start, *empty; struct key_binding **l;
key_code prefix, only = KEYC_UNKNOWN; key_code only = KEYC_UNKNOWN;
int repeat, width, tablewidth, keywidth, found = 0; const char *template, *tablename, *keystr;
size_t tmpsize, tmpused, cplen; char *line;
char *prefix = NULL;
u_int i, n;
int single, notes_only, filter_notes, filter_key;
struct sort_criteria sort_crit;
if (cmd_get_entry(self) == &cmd_list_commands_entry) if ((keystr = args_string(args, 0)) != NULL) {
return (cmd_list_keys_commands(self, item)); only = key_string_lookup_string(keystr);
if (args->argc != 0) {
only = key_string_lookup_string(args->argv[0]);
if (only == KEYC_UNKNOWN) { if (only == KEYC_UNKNOWN) {
cmdq_error(item, "invalid key: %s", args->argv[0]); cmdq_error(item, "invalid key: %s", keystr);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
only &= (KEYC_MASK_KEY|KEYC_MASK_MODIFIERS); only &= (KEYC_MASK_KEY|KEYC_MASK_MODIFIERS);
} }
tablename = args_get(args, 'T'); sort_crit.order = sort_order_from_string(args_get(args, 'O'));
if (tablename != NULL && key_bindings_get_table(tablename, 0) == NULL) { if (sort_crit.order == SORT_END && args_has(args, 'O')) {
cmdq_error(item, "table %s doesn't exist", tablename); cmdq_error(item, "invalid sort order");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
sort_crit.reversed = args_has(args, 'r');
if (args_has(args, 'N')) { if ((tablename = args_get(args, 'T')) != NULL) {
if (tablename == NULL) { table = key_bindings_get_table(tablename, 0);
start = cmd_list_keys_get_prefix(args, &prefix); if (table == NULL) {
keywidth = cmd_list_keys_get_width("root", only); cmdq_error(item, "table %s doesn't exist", tablename);
if (prefix != KEYC_NONE) { return (CMD_RETURN_ERROR);
width = cmd_list_keys_get_width("prefix", only);
if (width == 0)
prefix = KEYC_NONE;
else if (width > keywidth)
keywidth = width;
}
empty = utf8_padcstr("", utf8_cstrwidth(start));
found = cmd_list_keys_print_notes(item, args, "root",
keywidth, only, empty);
if (prefix != KEYC_NONE) {
if (cmd_list_keys_print_notes(item, args,
"prefix", keywidth, only, start))
found = 1;
}
free(empty);
} else {
if (args_has(args, 'P'))
start = xstrdup(args_get(args, 'P'));
else
start = xstrdup("");
keywidth = cmd_list_keys_get_width(tablename, only);
found = cmd_list_keys_print_notes(item, args, tablename,
keywidth, only, start);
} }
free(start);
goto out;
} }
repeat = 0; prefix = cmd_list_keys_get_prefix(args);
tablewidth = keywidth = 0; single = args_has(args, '1');
table = key_bindings_first_table (); notes_only = args_has(args, 'N');
while (table != NULL) {
if (tablename != NULL && strcmp(table->name, tablename) != 0) {
table = key_bindings_next_table(table);
continue;
}
bd = key_bindings_first(table);
while (bd != NULL) {
if (only != KEYC_UNKNOWN && bd->key != only) {
bd = key_bindings_next(table, bd);
continue;
}
key = args_escape(key_string_lookup_key(bd->key, 0));
if (bd->flags & KEY_BINDING_REPEAT) if ((template = args_get(args, 'F')) == NULL)
repeat = 1; template = LIST_KEYS_TEMPLATE;
width = utf8_cstrwidth(table->name); if (table)
if (width > tablewidth) l = sort_get_key_bindings_table(table, &n, &sort_crit);
tablewidth = width; else if (notes_only)
width = utf8_cstrwidth(key); l = cmd_list_keys_get_root_and_prefix(&n, &sort_crit);
if (width > keywidth) else
keywidth = width; l = sort_get_key_bindings(&n, &sort_crit);
free(key); filter_notes = notes_only && !args_has(args, 'a');
bd = key_bindings_next(table, bd); filter_key = only != KEYC_UNKNOWN;
} if (filter_notes || filter_key) {
table = key_bindings_next_table(table); cmd_list_keys_filter_key_list(filter_notes, filter_key, only, l,
&n);
} }
if (filter_key && n == 0) {
tmpsize = 256; cmdq_error(item, "unknown key: %s", keystr);
tmp = xmalloc(tmpsize); free(prefix);
table = key_bindings_first_table ();
while (table != NULL) {
if (tablename != NULL && strcmp(table->name, tablename) != 0) {
table = key_bindings_next_table(table);
continue;
}
bd = key_bindings_first(table);
while (bd != NULL) {
if (only != KEYC_UNKNOWN && bd->key != only) {
bd = key_bindings_next(table, bd);
continue;
}
found = 1;
key = args_escape(key_string_lookup_key(bd->key, 0));
if (!repeat)
r = "";
else if (bd->flags & KEY_BINDING_REPEAT)
r = "-r ";
else
r = " ";
tmpused = xsnprintf(tmp, tmpsize, "%s-T ", r);
cp = utf8_padcstr(table->name, tablewidth);
cplen = strlen(cp) + 1;
while (tmpused + cplen + 1 >= tmpsize) {
tmpsize *= 2;
tmp = xrealloc(tmp, tmpsize);
}
strlcat(tmp, cp, tmpsize);
tmpused = strlcat(tmp, " ", tmpsize);
free(cp);
cp = utf8_padcstr(key, keywidth);
cplen = strlen(cp) + 1;
while (tmpused + cplen + 1 >= tmpsize) {
tmpsize *= 2;
tmp = xrealloc(tmp, tmpsize);
}
strlcat(tmp, cp, tmpsize);
tmpused = strlcat(tmp, " ", tmpsize);
free(cp);
cp = cmd_list_print(bd->cmdlist, 1);
cplen = strlen(cp);
while (tmpused + cplen + 1 >= tmpsize) {
tmpsize *= 2;
tmp = xrealloc(tmp, tmpsize);
}
strlcat(tmp, cp, tmpsize);
free(cp);
cmdq_print(item, "bind-key %s", tmp);
free(key);
bd = key_bindings_next(table, bd);
}
table = key_bindings_next_table(table);
}
free(tmp);
out:
if (only != KEYC_UNKNOWN && !found) {
cmdq_error(item, "unknown key: %s", args->argv[0]);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
return (CMD_RETURN_NORMAL); if (single && n > 1)
} n = 1;
static enum cmd_retval
cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
const struct cmd_entry **entryp;
const struct cmd_entry *entry;
struct format_tree *ft;
const char *template, *s, *command = NULL;
char *line;
if (args->argc != 0)
command = args->argv[0];
if ((template = args_get(args, 'F')) == NULL) {
template = "#{command_list_name}"
"#{?command_list_alias, (#{command_list_alias}),} "
"#{command_list_usage}";
}
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_defaults(ft, NULL, NULL, NULL, NULL); format_defaults(ft, tc, NULL, NULL, NULL);
format_add(ft, "notes_only", "%d", notes_only);
for (entryp = cmd_table; *entryp != NULL; entryp++) { format_add(ft, "key_has_repeat", "%d", key_bindings_has_repeat(l, n));
entry = *entryp; format_add(ft, "key_string_width", "%u", cmd_list_keys_get_width(l, n));
if (command != NULL && format_add(ft, "key_table_width", "%u",
(strcmp(entry->name, command) != 0 && cmd_list_keys_get_table_width(l, n));
(entry->alias == NULL || for (i = 0; i < n; i++) {
strcmp(entry->alias, command) != 0))) cmd_list_keys_format_add_key_binding(ft, l[i], prefix);
continue;
format_add(ft, "command_list_name", "%s", entry->name);
if (entry->alias != NULL)
s = entry->alias;
else
s = "";
format_add(ft, "command_list_alias", "%s", s);
if (entry->usage != NULL)
s = entry->usage;
else
s = "";
format_add(ft, "command_list_usage", "%s", s);
line = format_expand(ft, template); line = format_expand(ft, template);
if (*line != '\0') if (single && tc != NULL && (~tc->flags & CLIENT_CONTROL))
status_message_set(tc, -1, 1, 0, 0, "%s", line);
else if (*line != '\0')
cmdq_print(item, "%s", line); cmdq_print(item, "%s", line);
free(line); free(line);
}
if (single)
break;
}
format_free(ft); format_free(ft);
free(prefix);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-list-panes.c,v 1.40 2026/06/01 14:01:09 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -38,8 +38,9 @@ const struct cmd_entry cmd_list_panes_entry = {
.name = "list-panes", .name = "list-panes",
.alias = "lsp", .alias = "lsp",
.args = { "asF:f:t:", 0, 0 }, .args = { "aF:f:O:rst:", 0, 0, NULL },
.usage = "[-as] [-F format] [-f filter] " CMD_TARGET_WINDOW_USAGE, .usage = "[-asr] [-F format] [-f filter] [-O order]"
CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
@@ -54,6 +55,13 @@ cmd_list_panes_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct session *s = target->s; struct session *s = target->s;
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
enum sort_order order;
order = sort_order_from_string(args_get(args, 'O'));
if (order == SORT_END && args_has(args, 'O')) {
cmdq_error(item, "invalid sort order");
return (CMD_RETURN_ERROR);
}
if (args_has(args, 'a')) if (args_has(args, 'a'))
cmd_list_panes_server(self, item); cmd_list_panes_server(self, item);
@@ -89,34 +97,41 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
struct cmdq_item *item, int type) struct cmdq_item *item, int type)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct window_pane *wp; struct window_pane *wp, **l;
u_int n; u_int i, n;
struct format_tree *ft; struct format_tree *ft;
const char *template, *filter; const char *template, *filter;
char *line, *expanded; char *line, *expanded;
int flag; int flag;
struct sort_criteria sort_crit;
template = args_get(args, 'F'); template = args_get(args, 'F');
if (template == NULL) { if (template == NULL) {
switch (type) { switch (type) {
case 0: case 0:
template = "#{pane_index}: " template = "#{pane_index}: "
"[#{pane_width}x#{pane_height}] [history " "[#{pane_width}x#{pane_height}"
"#{?pane_floating_flag, "
"#{pane_x}#,#{pane_y}#,#{pane_z}}] [history "
"#{history_size}/#{history_limit}, " "#{history_size}/#{history_limit}, "
"#{history_bytes} bytes] #{pane_id}" "#{history_bytes} bytes] #{pane_id}"
"#{?pane_active, (active),}#{?pane_dead, (dead),}"; "#{?pane_active, (active),}#{?pane_dead, (dead),}";
break; break;
case 1: case 1:
template = "#{window_index}.#{pane_index}: " template = "#{window_index}.#{pane_index}: "
"[#{pane_width}x#{pane_height}] [history " "[#{pane_width}x#{pane_height}"
"#{?pane_floating_flag, "
"#{pane_x}#,#{pane_y}#,#{pane_z}}] [history "
"#{history_size}/#{history_limit}, " "#{history_size}/#{history_limit}, "
"#{history_bytes} bytes] #{pane_id}" "#{history_bytes} bytes] #{pane_id}"
"#{?pane_active, (active),}#{?pane_dead, (dead),}"; "#{?pane_active, (active),}#{?pane_dead, (dead),}";
break; break;
case 2: case 2:
template = "#{session_name}:#{window_index}." template = "#{session_name}:#{window_index}."
"#{pane_index}: [#{pane_width}x#{pane_height}] " "#{pane_index}: [#{pane_width}x#{pane_height}"
"[history #{history_size}/#{history_limit}, " "#{?pane_floating_flag, "
"#{pane_x}#,#{pane_y}#,#{pane_z}}] [history "
"#{history_size}/#{history_limit}, "
"#{history_bytes} bytes] #{pane_id}" "#{history_bytes} bytes] #{pane_id}"
"#{?pane_active, (active),}#{?pane_dead, (dead),}"; "#{?pane_active, (active),}#{?pane_dead, (dead),}";
break; break;
@@ -124,8 +139,12 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
} }
filter = args_get(args, 'f'); filter = args_get(args, 'f');
n = 0; sort_crit.order = sort_order_from_string(args_get(args, 'O'));
TAILQ_FOREACH(wp, &wl->window->panes, entry) { sort_crit.reversed = args_has(args, 'r');
l = sort_get_panes_window(wl->window, &n, &sort_crit);
for (i = 0; i < n; i++) {
wp = l[i];
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", n); format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, wl, wp); format_defaults(ft, NULL, s, wl, wp);
@@ -143,6 +162,5 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
} }
format_free(ft); format_free(ft);
n++;
} }
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-list-sessions.c,v 1.36 2026/02/27 08:25:12 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -42,8 +42,8 @@ const struct cmd_entry cmd_list_sessions_entry = {
.name = "list-sessions", .name = "list-sessions",
.alias = "ls", .alias = "ls",
.args = { "F:f:", 0, 0 }, .args = { "F:f:O:r", 0, 0, NULL },
.usage = "[-F format] [-f filter]", .usage = "[-r] [-F format] [-f filter] [-O order]",
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
.exec = cmd_list_sessions_exec .exec = cmd_list_sessions_exec
@@ -52,23 +52,31 @@ const struct cmd_entry cmd_list_sessions_entry = {
static enum cmd_retval static enum cmd_retval
cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item) cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct session *s; struct session **l;
u_int n; u_int n, i;
struct format_tree *ft; struct format_tree *ft;
const char *template, *filter; const char *template, *filter;
char *line, *expanded; char *line, *expanded;
int flag; int flag;
struct sort_criteria sort_crit;
if ((template = args_get(args, 'F')) == NULL) if ((template = args_get(args, 'F')) == NULL)
template = LIST_SESSIONS_TEMPLATE; template = LIST_SESSIONS_TEMPLATE;
filter = args_get(args, 'f'); filter = args_get(args, 'f');
n = 0; sort_crit.order = sort_order_from_string(args_get(args, 'O'));
RB_FOREACH(s, sessions, &sessions) { if (sort_crit.order == SORT_END && args_has(args, 'O')) {
cmdq_error(item, "invalid sort order");
return (CMD_RETURN_ERROR);
}
sort_crit.reversed = args_has(args, 'r');
l = sort_get_sessions(&n, &sort_crit);
for (i = 0; i < n; i++) {
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", n); format_add(ft, "line", "%u", i);
format_defaults(ft, NULL, s, NULL, NULL); format_defaults(ft, NULL, l[i], NULL, NULL);
if (filter != NULL) { if (filter != NULL) {
expanded = format_expand(ft, filter); expanded = format_expand(ft, filter);
@@ -83,7 +91,6 @@ cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
} }
format_free(ft); format_free(ft);
n++;
} }
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-list-windows.c,v 1.50 2026/02/27 08:25:12 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -41,16 +41,13 @@
static enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmdq_item *); static enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmdq_item *);
static void cmd_list_windows_server(struct cmd *, struct cmdq_item *);
static void cmd_list_windows_session(struct cmd *, struct session *,
struct cmdq_item *, int);
const struct cmd_entry cmd_list_windows_entry = { const struct cmd_entry cmd_list_windows_entry = {
.name = "list-windows", .name = "list-windows",
.alias = "lsw", .alias = "lsw",
.args = { "F:f:at:", 0, 0 }, .args = { "aF:f:O:rt:", 0, 0, NULL },
.usage = "[-a] [-F format] [-f filter] " CMD_TARGET_SESSION_USAGE, .usage = "[-ar] [-F format] [-f filter] [-O order]"
CMD_TARGET_SESSION_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 }, .target = { 't', CMD_FIND_SESSION, 0 },
@@ -63,51 +60,38 @@ cmd_list_windows_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl, **l;
if (args_has(args, 'a')) struct session *s;
cmd_list_windows_server(self, item); u_int i, n;
else
cmd_list_windows_session(self, target->s, item, 0);
return (CMD_RETURN_NORMAL);
}
static void
cmd_list_windows_server(struct cmd *self, struct cmdq_item *item)
{
struct session *s;
RB_FOREACH(s, sessions, &sessions)
cmd_list_windows_session(self, s, item, 1);
}
static void
cmd_list_windows_session(struct cmd *self, struct session *s,
struct cmdq_item *item, int type)
{
struct args *args = cmd_get_args(self);
struct winlink *wl;
u_int n;
struct format_tree *ft; struct format_tree *ft;
const char *template, *filter; const char *template, *filter;
char *line, *expanded; char *line, *expanded;
int flag; int flag;
struct sort_criteria sort_crit;
template = args_get(args, 'F'); template = args_get(args, 'F');
if (template == NULL) {
switch (type) {
case 0:
template = LIST_WINDOWS_TEMPLATE;
break;
case 1:
template = LIST_WINDOWS_WITH_SESSION_TEMPLATE;
break;
}
}
filter = args_get(args, 'f'); filter = args_get(args, 'f');
n = 0; sort_crit.order = sort_order_from_string(args_get(args, 'O'));
RB_FOREACH(wl, winlinks, &s->windows) { if (sort_crit.order == SORT_END && args_has(args, 'O')) {
cmdq_error(item, "invalid sort order");
return (CMD_RETURN_ERROR);
}
sort_crit.reversed = args_has(args, 'r');
if (args_has(args, 'a')) {
l = sort_get_winlinks(&n, &sort_crit);
if (template == NULL)
template = LIST_WINDOWS_WITH_SESSION_TEMPLATE;
} else {
l = sort_get_winlinks_session(target->s, &n, &sort_crit);
if (template == NULL)
template = LIST_WINDOWS_TEMPLATE;
}
for (i = 0; i < n; i++) {
wl = l[i];
s = wl->session;
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", n); format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, wl, NULL); format_defaults(ft, NULL, s, wl, NULL);
@@ -125,6 +109,7 @@ cmd_list_windows_session(struct cmd *self, struct session *s,
} }
format_free(ft); format_free(ft);
n++;
} }
return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-load-buffer.c,v 1.66 2025/10/28 07:32:26 nicm Exp $ */
/* /*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -37,7 +37,7 @@ const struct cmd_entry cmd_load_buffer_entry = {
.name = "load-buffer", .name = "load-buffer",
.alias = "loadb", .alias = "loadb",
.args = { "b:t:w", 1, 1 }, .args = { "b:t:w", 1, 1, NULL },
.usage = CMD_BUFFER_USAGE " " CMD_TARGET_CLIENT_USAGE " path", .usage = CMD_BUFFER_USAGE " " CMD_TARGET_CLIENT_USAGE " path",
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG|CMD_CLIENT_CANFAIL, .flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG|CMD_CLIENT_CANFAIL,
@@ -66,7 +66,7 @@ cmd_load_buffer_done(__unused struct client *c, const char *path, int error,
return; return;
if (error != 0) if (error != 0)
cmdq_error(item, "%s: %s", path, strerror(error)); cmdq_error(item, "%s: %s", strerror(error), path);
else if (bsize != 0) { else if (bsize != 0) {
copy = xmalloc(bsize); copy = xmalloc(bsize);
memcpy(copy, bdata, bsize); memcpy(copy, bdata, bsize);
@@ -77,7 +77,7 @@ cmd_load_buffer_done(__unused struct client *c, const char *path, int error,
} else if (tc != NULL && } else if (tc != NULL &&
tc->session != NULL && tc->session != NULL &&
(~tc->flags & CLIENT_DEAD)) (~tc->flags & CLIENT_DEAD))
tty_set_selection(&tc->tty, copy, bsize); tty_set_selection(&tc->tty, "", copy, bsize);
if (tc != NULL) if (tc != NULL)
server_client_unref(tc); server_client_unref(tc);
} }
@@ -105,7 +105,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
cdata->client->references++; cdata->client->references++;
} }
path = format_single_from_target(item, args->argv[0]); path = format_single_from_target(item, args_string(args, 0));
file_read(cmdq_get_client(item), path, cmd_load_buffer_done, cdata); file_read(cmdq_get_client(item), path, cmd_load_buffer_done, cdata);
free(path); free(path);

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-lock-server.c,v 1.31 2021/08/21 10:22:39 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -30,7 +30,7 @@ const struct cmd_entry cmd_lock_server_entry = {
.name = "lock-server", .name = "lock-server",
.alias = "lock", .alias = "lock",
.args = { "", 0, 0 }, .args = { "", 0, 0, NULL },
.usage = "", .usage = "",
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_lock_session_entry = {
.name = "lock-session", .name = "lock-session",
.alias = "locks", .alias = "locks",
.args = { "t:", 0, 0 }, .args = { "t:", 0, 0, NULL },
.usage = CMD_TARGET_SESSION_USAGE, .usage = CMD_TARGET_SESSION_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 }, .target = { 't', CMD_FIND_SESSION, 0 },
@@ -54,7 +54,7 @@ const struct cmd_entry cmd_lock_client_entry = {
.name = "lock-client", .name = "lock-client",
.alias = "lockc", .alias = "lockc",
.args = { "t:", 0, 0 }, .args = { "t:", 0, 0, NULL },
.usage = CMD_TARGET_CLIENT_USAGE, .usage = CMD_TARGET_CLIENT_USAGE,
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG, .flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG,

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-move-window.c,v 1.34 2021/08/21 10:22:39 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -32,7 +32,7 @@ const struct cmd_entry cmd_move_window_entry = {
.name = "move-window", .name = "move-window",
.alias = "movew", .alias = "movew",
.args = { "abdkrs:t:", 0, 0 }, .args = { "abdkrs:t:", 0, 0, NULL },
.usage = "[-abdkr] " CMD_SRCDST_WINDOW_USAGE, .usage = "[-abdkr] " CMD_SRCDST_WINDOW_USAGE,
.source = { 's', CMD_FIND_WINDOW, 0 }, .source = { 's', CMD_FIND_WINDOW, 0 },
@@ -46,7 +46,7 @@ const struct cmd_entry cmd_link_window_entry = {
.name = "link-window", .name = "link-window",
.alias = "linkw", .alias = "linkw",
.args = { "abdks:t:", 0, 0 }, .args = { "abdks:t:", 0, 0, NULL },
.usage = "[-abdk] " CMD_SRCDST_WINDOW_USAGE, .usage = "[-abdk] " CMD_SRCDST_WINDOW_USAGE,
.source = { 's', CMD_FIND_WINDOW, 0 }, .source = { 's', CMD_FIND_WINDOW, 0 },

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-new-session.c,v 1.152 2026/07/10 13:38:45 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -39,10 +39,11 @@ const struct cmd_entry cmd_new_session_entry = {
.name = "new-session", .name = "new-session",
.alias = "new", .alias = "new",
.args = { "Ac:dDe:EF:f:n:Ps:t:x:Xy:", 0, -1 }, .args = { "Ac:dDe:EF:f:n:Ps:t:x:Xy:", 0, -1, NULL },
.usage = "[-AdDEPX] [-c start-directory] [-e environment] [-F format] " .usage = "[-AdDEPX] [-c start-directory] [-e environment] [-F format] "
"[-f flags] [-n window-name] [-s session-name] " "[-f flags] [-n window-name] [-s session-name] "
CMD_TARGET_SESSION_USAGE " [-x width] [-y height] [command]", CMD_TARGET_SESSION_USAGE " [-x width] [-y height] "
"[shell-command [argument ...]]",
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
@@ -54,7 +55,7 @@ const struct cmd_entry cmd_has_session_entry = {
.name = "has-session", .name = "has-session",
.alias = "has", .alias = "has",
.args = { "t:", 0, 0 }, .args = { "t:", 0, 0, NULL },
.usage = CMD_TARGET_SESSION_USAGE, .usage = CMD_TARGET_SESSION_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 }, .target = { 't', CMD_FIND_SESSION, 0 },
@@ -75,15 +76,15 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
struct options *oo; struct options *oo;
struct termios tio, *tiop; struct termios tio, *tiop;
struct session_group *sg = NULL; struct session_group *sg = NULL;
const char *errstr, *template, *group, *tmp, *add; const char *errstr, *template, *group, *tmp;
char *cause, *cwd = NULL, *cp, *newname = NULL; char *cause, *cwd = NULL, *cp, *ename;
char *name, *prefix = NULL; char *wname = NULL, *sname = NULL, *prefix = NULL;
int detached, already_attached, is_control = 0; int detached, already_attached, is_control = 0;
u_int sx, sy, dsx, dsy; u_int sx, sy, dsx, dsy, count = args_count(args);
struct spawn_context sc; struct spawn_context sc = { 0 };
enum cmd_retval retval; enum cmd_retval retval;
struct cmd_find_state fs; struct cmd_find_state fs;
struct args_value *value; struct args_value *av;
if (cmd_get_entry(self) == &cmd_has_session_entry) { if (cmd_get_entry(self) == &cmd_has_session_entry) {
/* /*
@@ -93,32 +94,48 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) { if (args_has(args, 't') && (count != 0 || args_has(args, 'n'))) {
cmdq_error(item, "command or window name given with target"); cmdq_error(item, "command or window name given with target");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
tmp = args_get(args, 's'); if ((tmp = args_get(args, 'n')) != NULL) {
if (tmp != NULL) { ename = format_single(item, tmp, c, NULL, NULL, NULL);
name = format_single(item, tmp, c, NULL, NULL, NULL); if (!check_name(ename)) {
newname = session_check_name(name); cmdq_error(item, "invalid window name: %s", ename);
free(name); free(ename);
return (CMD_RETURN_ERROR);
}
wname = clean_name(ename, 0);
free(ename);
}
if ((tmp = args_get(args, 's')) != NULL) {
ename = format_single(item, tmp, c, NULL, NULL, NULL);
if (!check_name(ename)) {
cmdq_error(item, "invalid session name: %s", ename);
free(ename);
goto fail;
}
sname = clean_name(ename, 0);
free(ename);
} }
if (args_has(args, 'A')) { if (args_has(args, 'A')) {
if (newname != NULL) if (sname != NULL)
as = session_find(newname); as = session_find(sname);
else else
as = target->s; as = target->s;
if (as != NULL) { if (as != NULL) {
retval = cmd_attach_session(item, as->name, retval = cmd_attach_session(item, as->name,
args_has(args, 'D'), args_has(args, 'X'), 0, NULL, args_has(args, 'D'), args_has(args, 'X'), 0,
args_has(args, 'E'), args_get(args, 'f')); args_get(args, 'c'), args_has(args, 'E'),
free(newname); args_get(args, 'f'));
free(wname);
free(sname);
return (retval); return (retval);
} }
} }
if (newname != NULL && session_find(newname) != NULL) { if (sname != NULL && session_find(sname) != NULL) {
cmdq_error(item, "duplicate session: %s", newname); cmdq_error(item, "duplicate session: %s", sname);
goto fail; goto fail;
} }
@@ -134,8 +151,14 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
prefix = xstrdup(sg->name); prefix = xstrdup(sg->name);
else if (groupwith != NULL) else if (groupwith != NULL)
prefix = xstrdup(groupwith->name); prefix = xstrdup(groupwith->name);
else else {
prefix = session_check_name(group); if (!check_name(group)) {
cmdq_error(item,
"invalid session group name: %s", group);
goto fail;
}
prefix = clean_name(group, 0);
}
} }
/* Set -d if no client. */ /* Set -d if no client. */
@@ -258,22 +281,21 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
env = environ_create(); env = environ_create();
if (c != NULL && !args_has(args, 'E')) if (c != NULL && !args_has(args, 'E'))
environ_update(global_s_options, c->environ, env); environ_update(global_s_options, c->environ, env);
add = args_first_value(args, 'e', &value); av = args_first_value(args, 'e');
while (add != NULL) { while (av != NULL) {
environ_put(env, add, 0); environ_put(env, av->string, 0);
add = args_next_value(&value); av = args_next_value(av);
} }
s = session_create(prefix, newname, cwd, env, oo, tiop); s = session_create(prefix, sname, cwd, env, oo, tiop);
/* Spawn the initial window. */ /* Spawn the initial window. */
memset(&sc, 0, sizeof sc);
sc.item = item; sc.item = item;
sc.s = s; sc.s = s;
sc.tc = c; if (!detached)
sc.tc = c;
sc.name = args_get(args, 'n'); sc.name = wname;
sc.argc = args->argc; args_to_vector(args, &sc.argc, &sc.argv);
sc.argv = args->argv;
sc.idx = -1; sc.idx = -1;
sc.cwd = args_get(args, 'c'); sc.cwd = args_get(args, 'c');
@@ -303,7 +325,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
session_group_synchronize_to(s); session_group_synchronize_to(s);
session_select(s, RB_MIN(winlinks, &s->windows)->idx); session_select(s, RB_MIN(winlinks, &s->windows)->idx);
} }
notify_session("session-created", s); events_fire_session("session-created", s);
/* /*
* Set the client to the new session. If a command client exists, it is * Set the client to the new session. If a command client exists, it is
@@ -317,25 +339,10 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
proc_send(c->peer, MSG_READY, -1, NULL, 0); proc_send(c->peer, MSG_READY, -1, NULL, 0);
} else if (c->session != NULL) } else if (c->session != NULL)
c->last_session = c->session; c->last_session = c->session;
c->session = s; server_client_set_session(c, s);
if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT) if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT)
server_client_set_key_table(c, NULL); server_client_set_key_table(c, NULL);
tty_update_client_offset(c);
status_timer_start(c);
notify_client("client-session-changed", c);
session_update_activity(s, NULL);
gettimeofday(&s->last_attached_time, NULL);
server_redraw_client(c);
} }
recalculate_sizes();
server_update_socket();
/*
* If there are still configuration file errors to display, put the new
* session's current window into more mode and display them now.
*/
if (cfg_finished)
cfg_show_causes(s);
/* Print if requested. */ /* Print if requested. */
if (args_has(args, 'P')) { if (args_has(args, 'P')) {
@@ -354,14 +361,23 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
cmd_find_from_session(&fs, s, 0); cmd_find_from_session(&fs, s, 0);
cmdq_insert_hook(s, item, &fs, "after-new-session"); cmdq_insert_hook(s, item, &fs, "after-new-session");
if (cfg_finished)
cfg_show_causes(s);
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
free(cwd); free(cwd);
free(newname); free(wname);
free(sname);
free(prefix); free(prefix);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
fail: fail:
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
free(cwd); free(cwd);
free(newname); free(wname);
free(sname);
free(prefix); free(prefix);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-new-window.c,v 1.103 2026/07/08 08:07:42 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -38,9 +38,10 @@ const struct cmd_entry cmd_new_window_entry = {
.name = "new-window", .name = "new-window",
.alias = "neww", .alias = "neww",
.args = { "abc:de:F:kn:PSt:", 0, -1 }, .args = { "abc:de:EF:kn:PSt:", 0, -1, NULL },
.usage = "[-abdkPS] [-c start-directory] [-e environment] [-F format] " .usage = "[-abdEkPS] [-c start-directory] [-e environment] [-F format] "
"[-n window-name] " CMD_TARGET_WINDOW_USAGE " [command]", "[-n window-name] " CMD_TARGET_WINDOW_USAGE
" [shell-command [argument ...]]",
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX }, .target = { 't', CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX },
@@ -55,34 +56,55 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
struct client *c = cmdq_get_client(item); struct client *c = cmdq_get_client(item);
struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *current = cmdq_get_current(item);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct spawn_context sc; struct spawn_context sc = { 0 };
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct session *s = target->s; struct session *s = target->s;
struct winlink *wl = target->wl; struct winlink *wl = target->wl, *new_wl = NULL;
int idx = target->idx, before; int idx = target->idx, before, count = args_count(args);
struct winlink *new_wl = NULL; char *cause = NULL, *cp, *expanded, *wname = NULL;
char *cause = NULL, *cp; const char *template, *name;
const char *template, *add, *name;
struct cmd_find_state fs; struct cmd_find_state fs;
struct args_value *value; struct args_value *av;
if (args_has(args, 'E') &&
count != 0 &&
(count != 1 || *args_string(args, 0) != '\0')) {
cmdq_error(item, "command cannot be given for empty pane");
return (CMD_RETURN_ERROR);
}
/* /*
* If -S and -n are given and -t is not and a single window with this * If -S and -n are given and -t is not and a single window with this
* name already exists, select it. * name already exists, select it.
*/ */
name = args_get(args, 'n'); name = args_get(args, 'n');
if (args_has(args, 'S') && name != NULL && target->idx == -1) { if (name != NULL) {
expanded = format_single(item, name, c, s, NULL, NULL);
if (!check_name(expanded)) {
cmdq_error(item, "invalid window name: %s", expanded);
free(expanded);
return (CMD_RETURN_ERROR);
}
wname = clean_name(expanded, 0);
free(expanded);
}
if (args_has(args, 'S') && wname != NULL && target->idx == -1) {
expanded = format_single(item, wname, c, s, NULL, NULL);
RB_FOREACH(wl, winlinks, &s->windows) { RB_FOREACH(wl, winlinks, &s->windows) {
if (strcmp(wl->window->name, name) != 0) if (strcmp(wl->window->name, expanded) != 0)
continue; continue;
if (new_wl == NULL) { if (new_wl == NULL) {
new_wl = wl; new_wl = wl;
continue; continue;
} }
cmdq_error(item, "multiple windows named %s", name); cmdq_error(item, "multiple windows named %s", wname);
free(wname);
free(expanded);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
free(expanded);
if (new_wl != NULL) { if (new_wl != NULL) {
free(wname);
if (args_has(args, 'd')) if (args_has(args, 'd'))
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (session_set_current(s, new_wl) == 0) if (session_set_current(s, new_wl) == 0)
@@ -94,7 +116,6 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
} }
} }
before = args_has(args, 'b'); before = args_has(args, 'b');
if (args_has(args, 'a') || before) { if (args_has(args, 'a') || before) {
idx = winlink_shuffle_up(s, wl, before); idx = winlink_shuffle_up(s, wl, before);
@@ -102,26 +123,26 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
idx = target->idx; idx = target->idx;
} }
memset(&sc, 0, sizeof sc);
sc.item = item; sc.item = item;
sc.s = s; sc.s = s;
sc.tc = tc; sc.tc = tc;
sc.name = args_get(args, 'n'); sc.name = wname;
sc.argc = args->argc; args_to_vector(args, &sc.argc, &sc.argv);
sc.argv = args->argv;
sc.environ = environ_create(); sc.environ = environ_create();
add = args_first_value(args, 'e', &value); av = args_first_value(args, 'e');
while (add != NULL) { while (av != NULL) {
environ_put(sc.environ, add, 0); environ_put(sc.environ, av->string, 0);
add = args_next_value(&value); av = args_next_value(av);
} }
sc.idx = idx; sc.idx = idx;
sc.cwd = args_get(args, 'c'); sc.cwd = args_get(args, 'c');
sc.flags = 0; sc.flags = 0;
if (args_has(args, 'E') || (count == 1 && *args_string(args, 0) == '\0'))
sc.flags |= SPAWN_EMPTY;
if (args_has(args, 'd')) if (args_has(args, 'd'))
sc.flags |= SPAWN_DETACHED; sc.flags |= SPAWN_DETACHED;
if (args_has(args, 'k')) if (args_has(args, 'k'))
@@ -130,7 +151,7 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
if ((new_wl = spawn_window(&sc, &cause)) == NULL) { if ((new_wl = spawn_window(&sc, &cause)) == NULL) {
cmdq_error(item, "create window failed: %s", cause); cmdq_error(item, "create window failed: %s", cause);
free(cause); free(cause);
return (CMD_RETURN_ERROR); goto fail;
} }
if (!args_has(args, 'd') || new_wl == s->curw) { if (!args_has(args, 'd') || new_wl == s->curw) {
cmd_find_from_winlink(current, new_wl, 0); cmd_find_from_winlink(current, new_wl, 0);
@@ -150,6 +171,16 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
cmd_find_from_winlink(&fs, new_wl, 0); cmd_find_from_winlink(&fs, new_wl, 0);
cmdq_insert_hook(s, item, &fs, "after-new-window"); cmdq_insert_hook(s, item, &fs, "after-new-window");
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ); environ_free(sc.environ);
free(wname);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
fail:
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ);
free(wname);
return (CMD_RETURN_ERROR);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-parse.y,v 1.58 2026/04/27 12:31:11 nicm Exp $ */
/* /*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -32,23 +32,39 @@
static int yylex(void); static int yylex(void);
static int yyparse(void); static int yyparse(void);
static int printflike(1,2) yyerror(const char *, ...); static void printflike(1,2) yyerror(const char *, ...);
static char *yylex_token(int); static char *yylex_token(int);
static char *yylex_format(void); static char *yylex_format(void);
#define CMD_PARSE_MAX_ENVIRON_LEN 16384
struct cmd_parse_scope { struct cmd_parse_scope {
int flag; int flag;
TAILQ_ENTRY (cmd_parse_scope) entry; TAILQ_ENTRY (cmd_parse_scope) entry;
}; };
enum cmd_parse_argument_type {
CMD_PARSE_STRING,
CMD_PARSE_COMMANDS,
CMD_PARSE_PARSED_COMMANDS
};
struct cmd_parse_argument {
enum cmd_parse_argument_type type;
char *string;
struct cmd_parse_commands *commands;
struct cmd_list *cmdlist;
TAILQ_ENTRY(cmd_parse_argument) entry;
};
TAILQ_HEAD(cmd_parse_arguments, cmd_parse_argument);
struct cmd_parse_command { struct cmd_parse_command {
u_int line; u_int line;
struct cmd_parse_arguments arguments;
int argc; TAILQ_ENTRY(cmd_parse_command) entry;
char **argv;
TAILQ_ENTRY(cmd_parse_command) entry;
}; };
TAILQ_HEAD(cmd_parse_commands, cmd_parse_command); TAILQ_HEAD(cmd_parse_commands, cmd_parse_command);
@@ -77,8 +93,9 @@ static char *cmd_parse_get_error(const char *, u_int, const char *);
static void cmd_parse_free_command(struct cmd_parse_command *); static void cmd_parse_free_command(struct cmd_parse_command *);
static struct cmd_parse_commands *cmd_parse_new_commands(void); static struct cmd_parse_commands *cmd_parse_new_commands(void);
static void cmd_parse_free_commands(struct cmd_parse_commands *); static void cmd_parse_free_commands(struct cmd_parse_commands *);
static char *cmd_parse_commands_to_string(struct cmd_parse_commands *); static void cmd_parse_build_commands(struct cmd_parse_commands *,
static void cmd_parse_print_commands(struct cmd_parse_input *, u_int, struct cmd_parse_input *, struct cmd_parse_result *);
static void cmd_parse_print_commands(struct cmd_parse_input *,
struct cmd_list *); struct cmd_list *);
%} %}
@@ -86,10 +103,8 @@ static void cmd_parse_print_commands(struct cmd_parse_input *, u_int,
%union %union
{ {
char *token; char *token;
struct { struct cmd_parse_arguments *arguments;
int argc; struct cmd_parse_argument *argument;
char **argv;
} arguments;
int flag; int flag;
struct { struct {
int flag; int flag;
@@ -107,8 +122,9 @@ static void cmd_parse_print_commands(struct cmd_parse_input *, u_int,
%token ENDIF %token ENDIF
%token <token> FORMAT TOKEN EQUALS %token <token> FORMAT TOKEN EQUALS
%type <token> argument expanded format %type <token> expanded format
%type <arguments> arguments %type <arguments> arguments
%type <argument> argument
%type <flag> if_open if_elif %type <flag> if_open if_elif
%type <elif> elif elif1 %type <elif> elif elif1
%type <commands> argument_statements statements statement %type <commands> argument_statements statements statement
@@ -209,9 +225,20 @@ assignment : EQUALS
{ {
struct cmd_parse_state *ps = &parse_state; struct cmd_parse_state *ps = &parse_state;
int flags = ps->input->flags; int flags = ps->input->flags;
int flag = 1;
struct cmd_parse_scope *scope;
if ((~flags & CMD_PARSE_PARSEONLY) && if (ps->scope != NULL) {
(ps->scope == NULL || ps->scope->flag)) flag = ps->scope->flag;
TAILQ_FOREACH(scope, &ps->stack, entry)
flag = flag && scope->flag;
}
if (strlen($1) > CMD_PARSE_MAX_ENVIRON_LEN) {
yyerror("environment variable is too long");
YYABORT;
}
if ((~flags & CMD_PARSE_PARSEONLY) && flag)
environ_put(global_environ, $1, 0); environ_put(global_environ, $1, 0);
free($1); free($1);
} }
@@ -220,9 +247,20 @@ hidden_assignment : HIDDEN EQUALS
{ {
struct cmd_parse_state *ps = &parse_state; struct cmd_parse_state *ps = &parse_state;
int flags = ps->input->flags; int flags = ps->input->flags;
int flag = 1;
struct cmd_parse_scope *scope;
if ((~flags & CMD_PARSE_PARSEONLY) && if (ps->scope != NULL) {
(ps->scope == NULL || ps->scope->flag)) flag = ps->scope->flag;
TAILQ_FOREACH(scope, &ps->stack, entry)
flag = flag && scope->flag;
}
if (strlen($2) > CMD_PARSE_MAX_ENVIRON_LEN) {
yyerror("environment variable is too long");
YYABORT;
}
if ((~flags & CMD_PARSE_PARSEONLY) && flag)
environ_put(global_environ, $2, ENVIRON_HIDDEN); environ_put(global_environ, $2, ENVIRON_HIDDEN);
free($2); free($2);
} }
@@ -360,7 +398,7 @@ commands : command
struct cmd_parse_state *ps = &parse_state; struct cmd_parse_state *ps = &parse_state;
$$ = cmd_parse_new_commands(); $$ = cmd_parse_new_commands();
if ($1->argc != 0 && if (!TAILQ_EMPTY(&$1->arguments) &&
(ps->scope == NULL || ps->scope->flag)) (ps->scope == NULL || ps->scope->flag))
TAILQ_INSERT_TAIL($$, $1, entry); TAILQ_INSERT_TAIL($$, $1, entry);
else else
@@ -380,7 +418,7 @@ commands : command
{ {
struct cmd_parse_state *ps = &parse_state; struct cmd_parse_state *ps = &parse_state;
if ($3->argc != 0 && if (!TAILQ_EMPTY(&$3->arguments) &&
(ps->scope == NULL || ps->scope->flag)) { (ps->scope == NULL || ps->scope->flag)) {
$$ = $1; $$ = $1;
TAILQ_INSERT_TAIL($$, $3, entry); TAILQ_INSERT_TAIL($$, $3, entry);
@@ -401,27 +439,38 @@ command : assignment
$$ = xcalloc(1, sizeof *$$); $$ = xcalloc(1, sizeof *$$);
$$->line = ps->input->line; $$->line = ps->input->line;
TAILQ_INIT(&$$->arguments);
} }
| optional_assignment TOKEN | optional_assignment TOKEN
{ {
struct cmd_parse_state *ps = &parse_state; struct cmd_parse_state *ps = &parse_state;
struct cmd_parse_argument *arg;
$$ = xcalloc(1, sizeof *$$); $$ = xcalloc(1, sizeof *$$);
$$->line = ps->input->line; $$->line = ps->input->line;
TAILQ_INIT(&$$->arguments);
cmd_prepend_argv(&$$->argc, &$$->argv, $2); arg = xcalloc(1, sizeof *arg);
arg->type = CMD_PARSE_STRING;
arg->string = $2;
TAILQ_INSERT_HEAD(&$$->arguments, arg, entry);
} }
| optional_assignment TOKEN arguments | optional_assignment TOKEN arguments
{ {
struct cmd_parse_state *ps = &parse_state; struct cmd_parse_state *ps = &parse_state;
struct cmd_parse_argument *arg;
$$ = xcalloc(1, sizeof *$$); $$ = xcalloc(1, sizeof *$$);
$$->line = ps->input->line; $$->line = ps->input->line;
TAILQ_INIT(&$$->arguments);
$$->argc = $3.argc; TAILQ_CONCAT(&$$->arguments, $3, entry);
$$->argv = $3.argv; free($3);
cmd_prepend_argv(&$$->argc, &$$->argv, $2);
arg = xcalloc(1, sizeof *arg);
arg->type = CMD_PARSE_STRING;
arg->string = $2;
TAILQ_INSERT_HEAD(&$$->arguments, arg, entry);
} }
condition1 : if_open commands if_close condition1 : if_open commands if_close
@@ -505,30 +554,34 @@ elif1 : if_elif commands
arguments : argument arguments : argument
{ {
$$.argc = 1; $$ = xcalloc(1, sizeof *$$);
$$.argv = xreallocarray(NULL, 1, sizeof *$$.argv); TAILQ_INIT($$);
$$.argv[0] = $1; TAILQ_INSERT_HEAD($$, $1, entry);
} }
| argument arguments | argument arguments
{ {
cmd_prepend_argv(&$2.argc, &$2.argv, $1); TAILQ_INSERT_HEAD($2, $1, entry);
free($1);
$$ = $2; $$ = $2;
} }
argument : TOKEN argument : TOKEN
{ {
$$ = $1; $$ = xcalloc(1, sizeof *$$);
$$->type = CMD_PARSE_STRING;
$$->string = $1;
} }
| EQUALS | EQUALS
{ {
$$ = $1; $$ = xcalloc(1, sizeof *$$);
$$->type = CMD_PARSE_STRING;
$$->string = $1;
} }
| '{' argument_statements | '{' argument_statements
{ {
$$ = cmd_parse_commands_to_string($2); $$ = xcalloc(1, sizeof *$$);
cmd_parse_free_commands($2); $$->type = CMD_PARSE_COMMANDS;
$$->commands = $2;
} }
argument_statements : statement '}' argument_statements : statement '}'
@@ -552,30 +605,57 @@ cmd_parse_get_error(const char *file, u_int line, const char *error)
if (file == NULL) if (file == NULL)
s = xstrdup(error); s = xstrdup(error);
else else
xasprintf (&s, "%s:%u: %s", file, line, error); xasprintf(&s, "%s:%u: %s", file, line, error);
return (s); return (s);
} }
static void static void
cmd_parse_print_commands(struct cmd_parse_input *pi, u_int line, cmd_parse_print_commands(struct cmd_parse_input *pi, struct cmd_list *cmdlist)
struct cmd_list *cmdlist)
{ {
char *s; char *s;
if (pi->item != NULL && (pi->flags & CMD_PARSE_VERBOSE)) { if (pi->item == NULL || (~pi->flags & CMD_PARSE_VERBOSE))
s = cmd_list_print(cmdlist, 0); return;
if (pi->file != NULL) s = cmd_list_print(cmdlist, 0);
cmdq_print(pi->item, "%s:%u: %s", pi->file, line, s); if (pi->file != NULL)
else cmdq_print(pi->item, "%s:%u: %s", pi->file, pi->line, s);
cmdq_print(pi->item, "%u: %s", line, s); else
free(s); cmdq_print(pi->item, "%u: %s", pi->line, s);
free(s);
}
static void
cmd_parse_free_argument(struct cmd_parse_argument *arg)
{
switch (arg->type) {
case CMD_PARSE_STRING:
free(arg->string);
break;
case CMD_PARSE_COMMANDS:
cmd_parse_free_commands(arg->commands);
break;
case CMD_PARSE_PARSED_COMMANDS:
cmd_list_free(arg->cmdlist);
break;
}
free(arg);
}
static void
cmd_parse_free_arguments(struct cmd_parse_arguments *args)
{
struct cmd_parse_argument *arg, *arg1;
TAILQ_FOREACH_SAFE(arg, args, entry, arg1) {
TAILQ_REMOVE(args, arg, entry);
cmd_parse_free_argument(arg);
} }
} }
static void static void
cmd_parse_free_command(struct cmd_parse_command *cmd) cmd_parse_free_command(struct cmd_parse_command *cmd)
{ {
cmd_free_argv(cmd->argc, cmd->argv); cmd_parse_free_arguments(&cmd->arguments);
free(cmd); free(cmd);
} }
@@ -585,7 +665,7 @@ cmd_parse_new_commands(void)
struct cmd_parse_commands *cmds; struct cmd_parse_commands *cmds;
cmds = xmalloc(sizeof *cmds); cmds = xmalloc(sizeof *cmds);
TAILQ_INIT (cmds); TAILQ_INIT(cmds);
return (cmds); return (cmds);
} }
@@ -601,30 +681,6 @@ cmd_parse_free_commands(struct cmd_parse_commands *cmds)
free(cmds); free(cmds);
} }
static char *
cmd_parse_commands_to_string(struct cmd_parse_commands *cmds)
{
struct cmd_parse_command *cmd;
char *string = NULL, *s, *line;
TAILQ_FOREACH(cmd, cmds, entry) {
line = cmd_stringify_argv(cmd->argc, cmd->argv);
if (string == NULL)
s = line;
else {
xasprintf(&s, "%s ; %s", s, line);
free(line);
}
free(string);
string = s;
}
if (string == NULL)
string = xstrdup("");
log_debug("%s: %s", __func__, string);
return (string);
}
static struct cmd_parse_commands * static struct cmd_parse_commands *
cmd_parse_run_parser(char **cause) cmd_parse_run_parser(char **cause)
{ {
@@ -674,72 +730,167 @@ cmd_parse_do_buffer(const char *buf, size_t len, struct cmd_parse_input *pi,
return (cmd_parse_run_parser(cause)); return (cmd_parse_run_parser(cause));
} }
static struct cmd_parse_result * static void
cmd_parse_build_commands(struct cmd_parse_commands *cmds, cmd_parse_log_commands(struct cmd_parse_commands *cmds, const char *prefix)
struct cmd_parse_input *pi)
{ {
static struct cmd_parse_result pr; struct cmd_parse_command *cmd;
struct cmd_parse_commands *cmds2; struct cmd_parse_argument *arg;
struct cmd_parse_command *cmd, *cmd2, *next, *next2, *after; u_int i, j;
u_int line = UINT_MAX; char *s;
int i;
struct cmd_list *cmdlist = NULL, *result; i = 0;
TAILQ_FOREACH(cmd, cmds, entry) {
j = 0;
TAILQ_FOREACH(arg, &cmd->arguments, entry) {
switch (arg->type) {
case CMD_PARSE_STRING:
log_debug("%s %u:%u: %s", prefix, i, j,
arg->string);
break;
case CMD_PARSE_COMMANDS:
xasprintf(&s, "%s %u:%u", prefix, i, j);
cmd_parse_log_commands(arg->commands, s);
free(s);
break;
case CMD_PARSE_PARSED_COMMANDS:
s = cmd_list_print(arg->cmdlist, 0);
log_debug("%s %u:%u: %s", prefix, i, j, s);
free(s);
break;
}
j++;
}
i++;
}
}
static int
cmd_parse_expand_alias(struct cmd_parse_command *cmd,
struct cmd_parse_input *pi, struct cmd_parse_result *pr)
{
struct cmd_parse_argument *first;
struct cmd_parse_commands *cmds;
struct cmd_parse_command *last;
char *alias, *name, *cause;
if (pi->flags & CMD_PARSE_NOALIAS)
return (0);
memset(pr, 0, sizeof *pr);
first = TAILQ_FIRST(&cmd->arguments);
if (first == NULL || first->type != CMD_PARSE_STRING) {
pr->status = CMD_PARSE_SUCCESS;
pr->cmdlist = cmd_list_new();
return (1);
}
name = first->string;
alias = cmd_get_alias(name);
if (alias == NULL)
return (0);
log_debug("%s: %u alias %s = %s", __func__, pi->line, name, alias);
cmds = cmd_parse_do_buffer(alias, strlen(alias), pi, &cause);
free(alias);
if (cmds == NULL) {
pr->status = CMD_PARSE_ERROR;
pr->error = cause;
return (1);
}
last = TAILQ_LAST(cmds, cmd_parse_commands);
if (last == NULL) {
pr->status = CMD_PARSE_SUCCESS;
pr->cmdlist = cmd_list_new();
return (1);
}
TAILQ_REMOVE(&cmd->arguments, first, entry);
cmd_parse_free_argument(first);
TAILQ_CONCAT(&last->arguments, &cmd->arguments, entry);
cmd_parse_log_commands(cmds, __func__);
pi->flags |= CMD_PARSE_NOALIAS;
cmd_parse_build_commands(cmds, pi, pr);
pi->flags &= ~CMD_PARSE_NOALIAS;
return (1);
}
static void
cmd_parse_build_command(struct cmd_parse_command *cmd,
struct cmd_parse_input *pi, struct cmd_parse_result *pr)
{
struct cmd_parse_argument *arg;
struct cmd *add; struct cmd *add;
char *name, *alias, *cause, *s; char *cause;
struct args_value *values = NULL;
u_int count = 0, idx;
memset(pr, 0, sizeof *pr);
if (cmd_parse_expand_alias(cmd, pi, pr))
return;
TAILQ_FOREACH(arg, &cmd->arguments, entry) {
values = xrecallocarray(values, count, count + 1,
sizeof *values);
switch (arg->type) {
case CMD_PARSE_STRING:
values[count].type = ARGS_STRING;
values[count].string = xstrdup(arg->string);
break;
case CMD_PARSE_COMMANDS:
cmd_parse_build_commands(arg->commands, pi, pr);
if (pr->status != CMD_PARSE_SUCCESS)
goto out;
values[count].type = ARGS_COMMANDS;
values[count].cmdlist = pr->cmdlist;
break;
case CMD_PARSE_PARSED_COMMANDS:
values[count].type = ARGS_COMMANDS;
values[count].cmdlist = arg->cmdlist;
values[count].cmdlist->references++;
break;
}
count++;
}
add = cmd_parse(values, count, pi->file, pi->line, pi->flags, &cause);
if (add == NULL) {
pr->status = CMD_PARSE_ERROR;
pr->error = cmd_parse_get_error(pi->file, pi->line, cause);
free(cause);
goto out;
}
pr->status = CMD_PARSE_SUCCESS;
pr->cmdlist = cmd_list_new();
cmd_list_append(pr->cmdlist, add);
out:
for (idx = 0; idx < count; idx++)
args_free_value(&values[idx]);
free(values);
}
static void
cmd_parse_build_commands(struct cmd_parse_commands *cmds,
struct cmd_parse_input *pi, struct cmd_parse_result *pr)
{
struct cmd_parse_command *cmd;
u_int line = UINT_MAX;
struct cmd_list *current = NULL, *result;
char *s;
memset(pr, 0, sizeof *pr);
/* Check for an empty list. */ /* Check for an empty list. */
if (TAILQ_EMPTY(cmds)) { if (TAILQ_EMPTY(cmds)) {
cmd_parse_free_commands(cmds); pr->status = CMD_PARSE_SUCCESS;
pr.status = CMD_PARSE_EMPTY; pr->cmdlist = cmd_list_new();
return (&pr); return;
}
/*
* Walk the commands and expand any aliases. Each alias is parsed
* individually to a new command list, any trailing arguments appended
* to the last command, and all commands inserted into the original
* command list.
*/
TAILQ_FOREACH_SAFE(cmd, cmds, entry, next) {
name = cmd->argv[0];
alias = cmd_get_alias(name);
if (alias == NULL)
continue;
line = cmd->line;
log_debug("%s: %u %s = %s", __func__, line, name, alias);
pi->line = line;
cmds2 = cmd_parse_do_buffer(alias, strlen(alias), pi, &cause);
free(alias);
if (cmds2 == NULL) {
pr.status = CMD_PARSE_ERROR;
pr.error = cause;
goto out;
}
cmd2 = TAILQ_LAST(cmds2, cmd_parse_commands);
if (cmd2 == NULL) {
TAILQ_REMOVE(cmds, cmd, entry);
cmd_parse_free_command(cmd);
continue;
}
for (i = 1; i < cmd->argc; i++)
cmd_append_argv(&cmd2->argc, &cmd2->argv, cmd->argv[i]);
after = cmd;
TAILQ_FOREACH_SAFE(cmd2, cmds2, entry, next2) {
cmd2->line = line;
TAILQ_REMOVE(cmds2, cmd2, entry);
TAILQ_INSERT_AFTER(cmds, after, cmd2, entry);
after = cmd2;
}
cmd_parse_free_commands(cmds2);
TAILQ_REMOVE(cmds, cmd, entry);
cmd_parse_free_command(cmd);
} }
cmd_parse_log_commands(cmds, __func__);
/* /*
* Parse each command into a command list. Create a new command list * Parse each command into a command list. Create a new command list
@@ -749,49 +900,39 @@ cmd_parse_build_commands(struct cmd_parse_commands *cmds,
*/ */
result = cmd_list_new(); result = cmd_list_new();
TAILQ_FOREACH(cmd, cmds, entry) { TAILQ_FOREACH(cmd, cmds, entry) {
name = cmd->argv[0]; if (((~pi->flags & CMD_PARSE_ONEGROUP) && cmd->line != line)) {
log_debug("%s: %u %s", __func__, cmd->line, name); if (current != NULL) {
cmd_log_argv(cmd->argc, cmd->argv, __func__); cmd_parse_print_commands(pi, current);
cmd_list_move(result, current);
if (cmdlist == NULL || cmd_list_free(current);
((~pi->flags & CMD_PARSE_ONEGROUP) && cmd->line != line)) {
if (cmdlist != NULL) {
cmd_parse_print_commands(pi, line, cmdlist);
cmd_list_move(result, cmdlist);
cmd_list_free(cmdlist);
} }
cmdlist = cmd_list_new(); current = cmd_list_new();
} }
line = cmd->line; if (current == NULL)
current = cmd_list_new();
line = pi->line = cmd->line;
add = cmd_parse(cmd->argc, cmd->argv, pi->file, line, &cause); cmd_parse_build_command(cmd, pi, pr);
if (add == NULL) { if (pr->status != CMD_PARSE_SUCCESS) {
cmd_list_free(result); cmd_list_free(result);
pr.status = CMD_PARSE_ERROR; cmd_list_free(current);
pr.error = cmd_parse_get_error(pi->file, line, cause); return;
free(cause);
cmd_list_free(cmdlist);
goto out;
} }
cmd_list_append(cmdlist, add); cmd_list_append_all(current, pr->cmdlist);
cmd_list_free(pr->cmdlist);
} }
if (cmdlist != NULL) { if (current != NULL) {
cmd_parse_print_commands(pi, line, cmdlist); cmd_parse_print_commands(pi, current);
cmd_list_move(result, cmdlist); cmd_list_move(result, current);
cmd_list_free(cmdlist); cmd_list_free(current);
} }
s = cmd_list_print(result, 0); s = cmd_list_print(result, 0);
log_debug("%s: %s", __func__, s); log_debug("%s: %s", __func__, s);
free(s); free(s);
pr.status = CMD_PARSE_SUCCESS; pr->status = CMD_PARSE_SUCCESS;
pr.cmdlist = result; pr->cmdlist = result;
out:
cmd_parse_free_commands(cmds);
return (&pr);
} }
struct cmd_parse_result * struct cmd_parse_result *
@@ -814,7 +955,10 @@ cmd_parse_from_file(FILE *f, struct cmd_parse_input *pi)
pr.error = cause; pr.error = cause;
return (&pr); return (&pr);
} }
return (cmd_parse_build_commands(cmds, pi)); cmd_parse_build_commands(cmds, pi, &pr);
cmd_parse_free_commands(cmds);
return (&pr);
} }
struct cmd_parse_result * struct cmd_parse_result *
@@ -845,8 +989,6 @@ cmd_parse_and_insert(const char *s, struct cmd_parse_input *pi,
pr = cmd_parse_from_string(s, pi); pr = cmd_parse_from_string(s, pi);
switch (pr->status) { switch (pr->status) {
case CMD_PARSE_EMPTY:
break;
case CMD_PARSE_ERROR: case CMD_PARSE_ERROR:
if (error != NULL) if (error != NULL)
*error = pr->error; *error = pr->error;
@@ -871,8 +1013,6 @@ cmd_parse_and_append(const char *s, struct cmd_parse_input *pi,
pr = cmd_parse_from_string(s, pi); pr = cmd_parse_from_string(s, pi);
switch (pr->status) { switch (pr->status) {
case CMD_PARSE_EMPTY:
break;
case CMD_PARSE_ERROR: case CMD_PARSE_ERROR:
if (error != NULL) if (error != NULL)
*error = pr->error; *error = pr->error;
@@ -903,9 +1043,8 @@ cmd_parse_from_buffer(const void *buf, size_t len, struct cmd_parse_input *pi)
memset(&pr, 0, sizeof pr); memset(&pr, 0, sizeof pr);
if (len == 0) { if (len == 0) {
pr.status = CMD_PARSE_EMPTY; pr.status = CMD_PARSE_SUCCESS;
pr.cmdlist = NULL; pr.cmdlist = cmd_list_new();
pr.error = NULL;
return (&pr); return (&pr);
} }
@@ -915,18 +1054,24 @@ cmd_parse_from_buffer(const void *buf, size_t len, struct cmd_parse_input *pi)
pr.error = cause; pr.error = cause;
return (&pr); return (&pr);
} }
return (cmd_parse_build_commands(cmds, pi)); cmd_parse_build_commands(cmds, pi, &pr);
cmd_parse_free_commands(cmds);
return (&pr);
} }
struct cmd_parse_result * struct cmd_parse_result *
cmd_parse_from_arguments(int argc, char **argv, struct cmd_parse_input *pi) cmd_parse_from_arguments(struct args_value *values, u_int count,
struct cmd_parse_input *pi)
{ {
struct cmd_parse_input input; static struct cmd_parse_result pr;
struct cmd_parse_commands *cmds; struct cmd_parse_input input;
struct cmd_parse_command *cmd; struct cmd_parse_commands *cmds;
char **copy, **new_argv; struct cmd_parse_command *cmd;
size_t size; struct cmd_parse_argument *arg;
int i, last, new_argc; u_int i;
char *copy;
size_t size;
int end;
/* /*
* The commands are already split up into arguments, so just separate * The commands are already split up into arguments, so just separate
@@ -937,65 +1082,59 @@ cmd_parse_from_arguments(int argc, char **argv, struct cmd_parse_input *pi)
memset(&input, 0, sizeof input); memset(&input, 0, sizeof input);
pi = &input; pi = &input;
} }
cmd_log_argv(argc, argv, "%s", __func__); memset(&pr, 0, sizeof pr);
cmds = cmd_parse_new_commands(); cmds = cmd_parse_new_commands();
copy = cmd_copy_argv(argc, argv);
last = 0; cmd = xcalloc(1, sizeof *cmd);
for (i = 0; i < argc; i++) { cmd->line = pi->line;
size = strlen(copy[i]); TAILQ_INIT(&cmd->arguments);
if (size == 0 || copy[i][size - 1] != ';')
continue;
copy[i][--size] = '\0';
if (size > 0 && copy[i][size - 1] == '\\') {
copy[i][size - 1] = ';';
continue;
}
new_argc = i - last;
new_argv = copy + last;
if (size != 0)
new_argc++;
if (new_argc != 0) {
cmd_log_argv(new_argc, new_argv, "%s: at %u", __func__,
i);
for (i = 0; i < count; i++) {
end = 0;
if (values[i].type == ARGS_STRING) {
copy = xstrdup(values[i].string);
size = strlen(copy);
if (size != 0 && copy[size - 1] == ';') {
copy[--size] = '\0';
if (size > 0 && copy[size - 1] == '\\')
copy[size - 1] = ';';
else
end = 1;
}
if (!end || size != 0) {
arg = xcalloc(1, sizeof *arg);
arg->type = CMD_PARSE_STRING;
arg->string = copy;
TAILQ_INSERT_TAIL(&cmd->arguments, arg, entry);
} else
free(copy);
} else if (values[i].type == ARGS_COMMANDS) {
arg = xcalloc(1, sizeof *arg);
arg->type = CMD_PARSE_PARSED_COMMANDS;
arg->cmdlist = values[i].cmdlist;
arg->cmdlist->references++;
TAILQ_INSERT_TAIL(&cmd->arguments, arg, entry);
} else
fatalx("unknown argument type");
if (end) {
TAILQ_INSERT_TAIL(cmds, cmd, entry);
cmd = xcalloc(1, sizeof *cmd); cmd = xcalloc(1, sizeof *cmd);
cmd->line = pi->line; cmd->line = pi->line;
TAILQ_INIT(&cmd->arguments);
cmd->argc = new_argc;
cmd->argv = cmd_copy_argv(new_argc, new_argv);
TAILQ_INSERT_TAIL(cmds, cmd, entry);
}
last = i + 1;
}
if (last != argc) {
new_argv = copy + last;
new_argc = argc - last;
if (new_argc != 0) {
cmd_log_argv(new_argc, new_argv, "%s: at %u", __func__,
last);
cmd = xcalloc(1, sizeof *cmd);
cmd->line = pi->line;
cmd->argc = new_argc;
cmd->argv = cmd_copy_argv(new_argc, new_argv);
TAILQ_INSERT_TAIL(cmds, cmd, entry);
} }
} }
if (!TAILQ_EMPTY(&cmd->arguments))
TAILQ_INSERT_TAIL(cmds, cmd, entry);
else
free(cmd);
cmd_free_argv(argc, copy); cmd_parse_build_commands(cmds, pi, &pr);
return (cmd_parse_build_commands(cmds, pi)); cmd_parse_free_commands(cmds);
return (&pr);
} }
static int printflike(1, 2) static void printflike(1, 2)
yyerror(const char *fmt, ...) yyerror(const char *fmt, ...)
{ {
struct cmd_parse_state *ps = &parse_state; struct cmd_parse_state *ps = &parse_state;
@@ -1004,7 +1143,7 @@ yyerror(const char *fmt, ...)
char *error; char *error;
if (ps->error != NULL) if (ps->error != NULL)
return (0); return;
va_start(ap, fmt); va_start(ap, fmt);
xvasprintf(&error, fmt, ap); xvasprintf(&error, fmt, ap);
@@ -1012,7 +1151,6 @@ yyerror(const char *fmt, ...)
ps->error = cmd_parse_get_error(pi->file, pi->line, error); ps->error = cmd_parse_get_error(pi->file, pi->line, error);
free(error); free(error);
return (0);
} }
static int static int
@@ -1155,6 +1293,16 @@ yylex(void)
continue; continue;
} }
if (ch == '\r') {
/*
* Treat \r\n as \n.
*/
ch = yylex_getc();
if (ch != '\n') {
yylex_ungetc(ch);
ch = '\r';
}
}
if (ch == '\n') { if (ch == '\n') {
/* /*
* End of line. Update the line number. * End of line. Update the line number.
@@ -1309,7 +1457,7 @@ yylex_token_escape(char **buf, size_t *len)
if (o3 >= '0' && o3 <= '7') { if (o3 >= '0' && o3 <= '7') {
ch = 64 * (ch - '0') + ch = 64 * (ch - '0') +
8 * (o2 - '0') + 8 * (o2 - '0') +
(o3 - '0'); (o3 - '0');
yylex_append1(buf, len, ch); yylex_append1(buf, len, ch);
return (1); return (1);
} }
@@ -1466,7 +1614,9 @@ yylex_token_tilde(char **buf, size_t *len)
if (*name == '\0') { if (*name == '\0') {
envent = environ_find(global_environ, "HOME"); envent = environ_find(global_environ, "HOME");
if (envent != NULL && *envent->value != '\0') if (envent != NULL &&
envent->value != NULL &&
*envent->value != '\0')
home = envent->value; home = envent->value;
else if ((pw = getpwuid(getuid())) != NULL) else if ((pw = getpwuid(getuid())) != NULL)
home = pw->pw_dir; home = pw->pw_dir;
@@ -1485,6 +1635,7 @@ yylex_token_tilde(char **buf, size_t *len)
static char * static char *
yylex_token(int ch) yylex_token(int ch)
{ {
struct cmd_parse_state *ps = &parse_state;
char *buf; char *buf;
size_t len; size_t len;
enum { START, enum { START,
@@ -1497,13 +1648,34 @@ yylex_token(int ch)
for (;;) { for (;;) {
/* EOF or \n are always the end of the token. */ /* EOF or \n are always the end of the token. */
if (ch == EOF || (state == NONE && ch == '\n')) if (ch == EOF) {
log_debug("%s: end at EOF", __func__);
break; break;
}
if (state == NONE && ch == '\r') {
ch = yylex_getc();
if (ch != '\n') {
yylex_ungetc(ch);
ch = '\r';
}
}
if (ch == '\n') {
if (state == NONE) {
log_debug("%s: end at EOL", __func__);
break;
}
ps->input->line++;
}
/* Whitespace or ; or } ends a token unless inside quotes. */ /* Whitespace or ; or } ends a token unless inside quotes. */
if ((ch == ' ' || ch == '\t' || ch == ';' || ch == '}') && if (state == NONE && (ch == ' ' || ch == '\t')) {
state == NONE) log_debug("%s: end at WS", __func__);
break; break;
}
if (state == NONE && (ch == ';' || ch == '}')) {
log_debug("%s: end at %c", __func__, ch);
break;
}
/* /*
* Spaces and comments inside quotes after \n are removed but * Spaces and comments inside quotes after \n are removed but

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-paste-buffer.c,v 1.44 2026/03/04 07:19:32 tb Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,8 +33,8 @@ const struct cmd_entry cmd_paste_buffer_entry = {
.name = "paste-buffer", .name = "paste-buffer",
.alias = "pasteb", .alias = "pasteb",
.args = { "db:prs:t:", 0, 0 }, .args = { "db:prSs:t:", 0, 0, NULL },
.usage = "[-dpr] [-s separator] " CMD_BUFFER_USAGE " " .usage = "[-dprS] [-s separator] " CMD_BUFFER_USAGE " "
CMD_TARGET_PANE_USAGE, CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -43,6 +43,17 @@ const struct cmd_entry cmd_paste_buffer_entry = {
.exec = cmd_paste_buffer_exec .exec = cmd_paste_buffer_exec
}; };
static void
cmd_paste_buffer_paste(struct window_pane *wp, const char *buf, size_t len)
{
char *cp;
size_t n;
n = utf8_stravisx(&cp, buf, len, VIS_SAFE|VIS_NOSLASH);
bufferevent_write(wp->event, cp, n);
free(cp);
}
static enum cmd_retval static enum cmd_retval
cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item) cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item)
{ {
@@ -51,9 +62,14 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item)
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
struct paste_buffer *pb; struct paste_buffer *pb;
const char *sepstr, *bufname, *bufdata, *bufend, *line; const char *sepstr, *bufname, *bufdata, *bufend, *line;
size_t seplen, bufsize; size_t seplen, bufsize, len;
int bracket = args_has(args, 'p'); int bracket = args_has(args, 'p');
if (window_pane_exited(wp)) {
cmdq_error(item, "target pane has exited");
return (CMD_RETURN_ERROR);
}
bufname = NULL; bufname = NULL;
if (args_has(args, 'b')) if (args_has(args, 'b'))
bufname = args_get(args, 'b'); bufname = args_get(args, 'b');
@@ -88,14 +104,22 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item)
line = memchr(bufdata, '\n', bufend - bufdata); line = memchr(bufdata, '\n', bufend - bufdata);
if (line == NULL) if (line == NULL)
break; break;
len = line - bufdata;
bufferevent_write(wp->event, bufdata, line - bufdata); if (args_has(args, 'S'))
bufferevent_write(wp->event, bufdata, len);
else
cmd_paste_buffer_paste(wp, bufdata, len);
bufferevent_write(wp->event, sepstr, seplen); bufferevent_write(wp->event, sepstr, seplen);
bufdata = line + 1; bufdata = line + 1;
} }
if (bufdata != bufend) if (bufdata != bufend) {
bufferevent_write(wp->event, bufdata, bufend - bufdata); len = bufend - bufdata;
if (args_has(args, 'S'))
bufferevent_write(wp->event, bufdata, len);
else
cmd_paste_buffer_paste(wp, bufdata, len);
}
if (bracket && (wp->screen->mode & MODE_BRACKETPASTE)) if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
bufferevent_write(wp->event, "\033[201~", 6); bufferevent_write(wp->event, "\033[201~", 6);

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-pipe-pane.c,v 1.64 2026/07/27 14:25:46 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -43,8 +43,8 @@ const struct cmd_entry cmd_pipe_pane_entry = {
.name = "pipe-pane", .name = "pipe-pane",
.alias = "pipep", .alias = "pipep",
.args = { "IOot:", 0, 1 }, .args = { "IOot:", 0, 1, NULL },
.usage = "[-IOo] " CMD_TARGET_PANE_USAGE " [command]", .usage = "[-IOo] " CMD_TARGET_PANE_USAGE " [shell-command]",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -67,6 +67,12 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
struct format_tree *ft; struct format_tree *ft;
sigset_t set, oldset; sigset_t set, oldset;
/* Do nothing if pane is dead. */
if (window_pane_exited(wp)) {
cmdq_error(item, "target pane has exited");
return (CMD_RETURN_ERROR);
}
/* Destroy the old pipe. */ /* Destroy the old pipe. */
old_fd = wp->pipe_fd; old_fd = wp->pipe_fd;
if (wp->pipe_fd != -1) { if (wp->pipe_fd != -1) {
@@ -81,7 +87,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
} }
/* If no pipe command, that is enough. */ /* If no pipe command, that is enough. */
if (args->argc == 0 || *args->argv[0] == '\0') if (args_count(args) == 0 || *args_string(args, 0) == '\0')
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
/* /*
@@ -111,17 +117,19 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
/* Expand the command. */ /* Expand the command. */
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_defaults(ft, tc, s, wl, wp); format_defaults(ft, tc, s, wl, wp);
cmd = format_expand_time(ft, args->argv[0]); cmd = format_expand_time(ft, args_string(args, 0));
format_free(ft); format_free(ft);
/* Fork the child. */ /* Fork the child. */
sigfillset(&set); sigfillset(&set);
sigprocmask(SIG_BLOCK, &set, &oldset); sigprocmask(SIG_BLOCK, &set, &oldset);
switch (fork()) { switch ((wp->pipe_pid = fork())) {
case -1: case -1:
sigprocmask(SIG_SETMASK, &oldset, NULL); sigprocmask(SIG_SETMASK, &oldset, NULL);
cmdq_error(item, "fork error: %s", strerror(errno)); cmdq_error(item, "fork error: %s", strerror(errno));
close(pipe_fd[0]);
close(pipe_fd[1]);
free(cmd); free(cmd);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
case 0: case 0:
@@ -130,7 +138,10 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
sigprocmask(SIG_SETMASK, &oldset, NULL); sigprocmask(SIG_SETMASK, &oldset, NULL);
close(pipe_fd[0]); close(pipe_fd[0]);
null_fd = open(_PATH_DEVNULL, O_WRONLY, 0); if (setpgid(0, 0) == -1)
_exit(1);
null_fd = open(_PATH_DEVNULL, O_WRONLY);
if (out) { if (out) {
if (dup2(pipe_fd[1], STDIN_FILENO) == -1) if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
_exit(1); _exit(1);
@@ -183,9 +194,13 @@ static void
cmd_pipe_pane_read_callback(__unused struct bufferevent *bufev, void *data) cmd_pipe_pane_read_callback(__unused struct bufferevent *bufev, void *data)
{ {
struct window_pane *wp = data; struct window_pane *wp = data;
struct evbuffer *evb = wp->pipe_event->input; struct evbuffer *evb;
size_t available; size_t available;
if (wp->pipe_event == NULL)
return;
evb = wp->pipe_event->input;
available = EVBUFFER_LENGTH(evb); available = EVBUFFER_LENGTH(evb);
log_debug("%%%u pipe read %zu", wp->id, available); log_debug("%%%u pipe read %zu", wp->id, available);

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-queue.c,v 1.121 2026/07/14 17:17:17 nicm Exp $ */
/* /*
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -19,9 +19,11 @@
#include <sys/types.h> #include <sys/types.h>
#include <ctype.h> #include <ctype.h>
#include <pwd.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h>
#include "tmux.h" #include "tmux.h"
@@ -124,7 +126,7 @@ cmdq_new(void)
{ {
struct cmdq_list *queue; struct cmdq_list *queue;
queue = xcalloc (1, sizeof *queue); queue = xcalloc(1, sizeof *queue);
TAILQ_INIT (&queue->list); TAILQ_INIT (&queue->list);
return (queue); return (queue);
} }
@@ -145,6 +147,13 @@ cmdq_get_name(struct cmdq_item *item)
return (item->name); return (item->name);
} }
/* Get item command. */
struct cmd *
cmdq_get_cmd(struct cmdq_item *item)
{
return (item->cmd);
}
/* Get item client. */ /* Get item client. */
struct client * struct client *
cmdq_get_client(struct cmdq_item *item) cmdq_get_client(struct cmdq_item *item)
@@ -234,8 +243,10 @@ cmdq_link_state(struct cmdq_state *state)
/* Make a copy of a state. */ /* Make a copy of a state. */
struct cmdq_state * struct cmdq_state *
cmdq_copy_state(struct cmdq_state *state) cmdq_copy_state(struct cmdq_state *state, struct cmd_find_state *current)
{ {
if (current != NULL)
return (cmdq_new_state(current, &state->event, state->flags));
return (cmdq_new_state(&state->current, &state->event, state->flags)); return (cmdq_new_state(&state->current, &state->event, state->flags));
} }
@@ -269,6 +280,15 @@ cmdq_add_format(struct cmdq_state *state, const char *key, const char *fmt, ...)
free(value); free(value);
} }
/* Add formats to command queue. */
void
cmdq_add_formats(struct cmdq_state *state, struct format_tree *ft)
{
if (state->formats == NULL)
state->formats = format_create(NULL, NULL, FORMAT_NONE, 0);
format_merge(state->formats, ft);
}
/* Merge formats from item. */ /* Merge formats from item. */
void void
cmdq_merge_formats(struct cmdq_item *item, struct format_tree *ft) cmdq_merge_formats(struct cmdq_item *item, struct format_tree *ft)
@@ -337,95 +357,61 @@ cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item)
/* Insert a hook. */ /* Insert a hook. */
void void
cmdq_insert_hook(struct session *s, struct cmdq_item *item, cmdq_insert_hook(__unused struct session *s, struct cmdq_item *item,
struct cmd_find_state *current, const char *fmt, ...) struct cmd_find_state *current, const char *fmt, ...)
{ {
struct cmdq_state *state = item->state;
struct cmd *cmd = item->cmd; struct cmd *cmd = item->cmd;
struct args *args = cmd_get_args(cmd); struct args *args = cmd_get_args(cmd);
struct args_entry *entryp; struct args_entry *ae;
struct args_value *valuep; struct args_value *av;
struct options *oo; struct event_payload *ep;
va_list ap; va_list ap;
char *name, tmp[32], flag, *arguments; char *name, tmp[32], flag, *arguments;
int i; u_int i;
const char *value; const char *value;
struct cmdq_item *new_item;
struct cmdq_state *new_state;
struct options_entry *o;
struct options_array_item *a;
struct cmd_list *cmdlist;
if (item->state->flags & CMDQ_STATE_NOHOOKS) if (item->state->flags & CMDQ_STATE_NOHOOKS)
return; return;
if (s == NULL)
oo = global_s_options;
else
oo = s->options;
va_start(ap, fmt); va_start(ap, fmt);
xvasprintf(&name, fmt, ap); xvasprintf(&name, fmt, ap);
va_end(ap); va_end(ap);
o = options_get(oo, name); ep = event_payload_create();
if (o == NULL) { if (current != NULL)
free(name); event_payload_set_target(ep, current);
return; event_payload_set_pointer(ep, "_cmdq_item", item, NULL, NULL);
}
log_debug("running hook %s (parent %p)", name, item);
/*
* The hooks get a new state because they should not update the current
* target or formats for any subsequent commands.
*/
new_state = cmdq_new_state(current, &state->event, CMDQ_STATE_NOHOOKS);
cmdq_add_format(new_state, "hook", "%s", name);
arguments = args_print(args); arguments = args_print(args);
cmdq_add_format(new_state, "hook_arguments", "%s", arguments); event_payload_set_string(ep, "arguments", "%s", arguments);
free(arguments); free(arguments);
for (i = 0; i < args->argc; i++) { for (i = 0; i < args_count(args); i++) {
xsnprintf(tmp, sizeof tmp, "hook_argument_%d", i); xsnprintf(tmp, sizeof tmp, "argument_%u", i);
cmdq_add_format(new_state, tmp, "%s", args->argv[i]); event_payload_set_string(ep, tmp, "%s", args_string(args, i));
} }
flag = args_first(args, &entryp); flag = args_first(args, &ae);
while (flag != 0) { while (flag != 0) {
value = args_get(args, flag); value = args_get(args, flag);
if (value == NULL) { xsnprintf(tmp, sizeof tmp, "flag_%c", flag);
xsnprintf(tmp, sizeof tmp, "hook_flag_%c", flag); if (value == NULL)
cmdq_add_format(new_state, tmp, "1"); event_payload_set_string(ep, tmp, "1");
} else { else
xsnprintf(tmp, sizeof tmp, "hook_flag_%c", flag); event_payload_set_string(ep, tmp, "%s", value);
cmdq_add_format(new_state, tmp, "%s", value);
}
i = 0; i = 0;
value = args_first_value(args, flag, &valuep); av = args_first_value(args, flag);
while (value != NULL) { while (av != NULL) {
xsnprintf(tmp, sizeof tmp, "hook_flag_%c_%d", flag, i); xsnprintf(tmp, sizeof tmp, "flag_%c_%u", flag, i);
cmdq_add_format(new_state, tmp, "%s", value); event_payload_set_string(ep, tmp, "%s", av->string);
i++; i++;
value = args_next_value(&valuep); av = args_next_value(av);
} }
flag = args_next(&entryp); flag = args_next(&ae);
} }
a = options_array_first(o); events_fire(name, ep);
while (a != NULL) {
cmdlist = options_array_item_value(a)->cmdlist;
if (cmdlist != NULL) {
new_item = cmdq_get_command(cmdlist, new_state);
if (item != NULL)
item = cmdq_insert_after(item, new_item);
else
item = cmdq_append(NULL, new_item);
}
a = options_array_next(a);
}
cmdq_free_state(new_state);
free(name); free(name);
} }
@@ -469,6 +455,13 @@ cmdq_remove_group(struct cmdq_item *item)
} }
} }
/* Empty command callback. */
static enum cmd_retval
cmdq_empty_command(__unused struct cmdq_item *item, __unused void *data)
{
return (CMD_RETURN_NORMAL);
}
/* Get a command for the command queue. */ /* Get a command for the command queue. */
struct cmdq_item * struct cmdq_item *
cmdq_get_command(struct cmd_list *cmdlist, struct cmdq_state *state) cmdq_get_command(struct cmd_list *cmdlist, struct cmdq_state *state)
@@ -478,12 +471,14 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmdq_state *state)
const struct cmd_entry *entry; const struct cmd_entry *entry;
int created = 0; int created = 0;
if ((cmd = cmd_list_first(cmdlist)) == NULL)
return (cmdq_get_callback(cmdq_empty_command, NULL));
if (state == NULL) { if (state == NULL) {
state = cmdq_new_state(NULL, NULL, 0); state = cmdq_new_state(NULL, NULL, 0);
created = 1; created = 1;
} }
cmd = cmd_list_first(cmdlist);
while (cmd != NULL) { while (cmd != NULL) {
entry = cmd_get_entry(cmd); entry = cmd_get_entry(cmd);
@@ -540,17 +535,31 @@ cmdq_add_message(struct cmdq_item *item)
{ {
struct client *c = item->client; struct client *c = item->client;
struct cmdq_state *state = item->state; struct cmdq_state *state = item->state;
const char *name, *key; const char *key;
char *tmp; char *tmp;
uid_t uid;
struct passwd *pw;
char *user = NULL;
tmp = cmd_print(item->cmd); tmp = cmd_print(item->cmd);
if (c != NULL) { if (c != NULL) {
name = c->name; uid = proc_get_peer_uid(c->peer);
if (uid != (uid_t)-1 && uid != getuid()) {
if ((pw = getpwuid(uid)) != NULL)
xasprintf(&user, "[%s]", pw->pw_name);
else
user = xstrdup("[unknown]");
} else
user = xstrdup("");
if (c->session != NULL && state->event.key != KEYC_NONE) { if (c->session != NULL && state->event.key != KEYC_NONE) {
key = key_string_lookup_key(state->event.key, 0); key = key_string_lookup_key(state->event.key, 0);
server_add_message("%s key %s: %s", name, key, tmp); server_add_message("%s%s key %s: %s", c->name, user,
} else key, tmp);
server_add_message("%s command: %s", name, tmp); } else {
server_add_message("%s%s command: %s", c->name, user,
tmp);
}
free(user);
} else } else
server_add_message("command: %s", tmp); server_add_message("command: %s", tmp);
free(tmp); free(tmp);
@@ -628,9 +637,18 @@ cmdq_fire_command(struct cmdq_item *item)
out: out:
item->client = saved; item->client = saved;
if (retval == CMD_RETURN_ERROR) if (retval == CMD_RETURN_ERROR) {
fsp = NULL;
if (cmd_find_valid_state(&item->target))
fsp = &item->target;
else if (cmd_find_valid_state(&item->state->current))
fsp = &item->state->current;
else if (cmd_find_from_client(&fs, item->client, 0) == 0)
fsp = &fs;
cmdq_insert_hook(fsp != NULL ? fsp->s : NULL, item, fsp,
"command-error");
cmdq_guard(item, "error", flags); cmdq_guard(item, "error", flags);
else } else
cmdq_guard(item, "end", flags); cmdq_guard(item, "end", flags);
return (retval); return (retval);
} }
@@ -769,10 +787,10 @@ cmdq_running(struct client *c)
struct cmdq_list *queue = cmdq_get(c); struct cmdq_list *queue = cmdq_get(c);
if (queue->item == NULL) if (queue->item == NULL)
return (NULL); return (NULL);
if (queue->item->flags & CMDQ_WAITING) if (queue->item->flags & CMDQ_WAITING)
return (NULL); return (NULL);
return (queue->item); return (queue->item);
} }
/* Print a guard line. */ /* Print a guard line. */
@@ -787,45 +805,30 @@ cmdq_guard(struct cmdq_item *item, const char *guard, int flags)
control_write(c, "%%%s %ld %u %d", guard, t, number, flags); control_write(c, "%%%s %ld %u %d", guard, t, number, flags);
} }
/* Show message from command. */
void
cmdq_print_data(struct cmdq_item *item, struct evbuffer *evb)
{
server_client_print(item->client, 1, evb);
}
/* Show message from command. */ /* Show message from command. */
void void
cmdq_print(struct cmdq_item *item, const char *fmt, ...) cmdq_print(struct cmdq_item *item, const char *fmt, ...)
{ {
struct client *c = item->client; va_list ap;
struct window_pane *wp; struct evbuffer *evb;
struct window_mode_entry *wme;
va_list ap; evb = evbuffer_new();
char *tmp, *msg; if (evb == NULL)
fatalx("out of memory");
va_start(ap, fmt); va_start(ap, fmt);
xvasprintf(&msg, fmt, ap); evbuffer_add_vprintf(evb, fmt, ap);
va_end(ap); va_end(ap);
log_debug("%s: %s", __func__, msg); cmdq_print_data(item, evb);
evbuffer_free(evb);
if (c == NULL)
/* nothing */;
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
if (~c->flags & CLIENT_UTF8) {
tmp = msg;
msg = utf8_sanitize(tmp);
free(tmp);
}
if (c->flags & CLIENT_CONTROL)
control_write(c, "%s", msg);
else
file_print(c, "%s\n", msg);
} else {
wp = server_client_get_pane(c);
wme = TAILQ_FIRST(&wp->modes);
if (wme == NULL || wme->mode != &window_view_mode) {
window_pane_set_mode(wp, NULL, &window_view_mode, NULL,
NULL);
}
window_copy_add(wp, "%s", msg);
}
free(msg);
} }
/* Show error from command. */ /* Show error from command. */
@@ -862,7 +865,7 @@ cmdq_error(struct cmdq_item *item, const char *fmt, ...)
c->retval = 1; c->retval = 1;
} else { } else {
*msg = toupper((u_char) *msg); *msg = toupper((u_char) *msg);
status_message_set(c, -1, 1, 0, "%s", msg); status_message_set(c, -1, 1, 0, 0, "%s", msg);
} }
free(msg); free(msg);

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-refresh-client.c,v 1.55 2026/07/17 08:37:29 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -34,9 +34,10 @@ const struct cmd_entry cmd_refresh_client_entry = {
.name = "refresh-client", .name = "refresh-client",
.alias = "refresh", .alias = "refresh",
.args = { "A:B:cC:Df:F:lLRSt:U", 0, 1 }, .args = { "A:B:cC:Df:r:F:lLRSt:U", 0, 1, NULL },
.usage = "[-cDlLRSU] [-A pane:state] [-B name:what:format] " .usage = "[-cDlLRSU] [-A pane:state] [-B name:what:format] "
"[-C XxY] [-f flags] " CMD_TARGET_CLIENT_USAGE " [adjustment]", "[-C XxY] [-f flags] [-r pane:report] " CMD_TARGET_CLIENT_USAGE
" [adjustment]",
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG, .flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG,
.exec = cmd_refresh_client_exec .exec = cmd_refresh_client_exec
@@ -45,36 +46,62 @@ const struct cmd_entry cmd_refresh_client_entry = {
static void static void
cmd_refresh_client_update_subscription(struct client *tc, const char *value) cmd_refresh_client_update_subscription(struct client *tc, const char *value)
{ {
char *copy, *split, *name, *what; char *name, *format;
enum control_sub_type subtype; enum monitor_type type;
int subid = -1; int id;
copy = name = xstrdup(value); if (monitor_parse(value, &name, &type, &id, &format) != 0) {
if ((split = strchr(copy, ':')) == NULL) { control_remove_sub(tc, value);
control_remove_sub(tc, copy); return;
goto out;
} }
*split++ = '\0'; control_add_sub(tc, name, type, id, format);
free(name);
free(format);
}
what = split; static enum cmd_retval
if ((split = strchr(what, ':')) == NULL) cmd_refresh_client_control_client_size(struct cmd *self, struct cmdq_item *item)
goto out; {
*split++ = '\0'; struct args *args = cmd_get_args(self);
struct client *tc = cmdq_get_target_client(item);
const char *size = args_get(args, 'C');
u_int w, x, y;
if (strcmp(what, "%*") == 0) if (sscanf(size, "@%u:%ux%u", &w, &x, &y) == 3) {
subtype = CONTROL_SUB_ALL_PANES; if (x < WINDOW_MINIMUM || x > WINDOW_MAXIMUM ||
else if (sscanf(what, "%%%d", &subid) == 1 && subid >= 0) y < WINDOW_MINIMUM || y > WINDOW_MAXIMUM) {
subtype = CONTROL_SUB_PANE; cmdq_error(item, "size too small or too big");
else if (strcmp(what, "@*") == 0) return (CMD_RETURN_ERROR);
subtype = CONTROL_SUB_ALL_WINDOWS; }
else if (sscanf(what, "@%d", &subid) == 1 && subid >= 0) log_debug("%s: client %s window @%u: size %ux%u", __func__,
subtype = CONTROL_SUB_WINDOW; tc->name, w, x, y);
else control_set_window_size(tc, w, x, y);
subtype = CONTROL_SUB_SESSION; tc->flags |= CLIENT_WINDOWSIZECHANGED;
control_add_sub(tc, name, subtype, subid, split); recalculate_sizes_now(1);
return (CMD_RETURN_NORMAL);
}
if (sscanf(size, "@%u:", &w) == 1) {
log_debug("%s: client %s window @%u: no size", __func__,
tc->name, w);
control_clear_window_size(tc, w);
recalculate_sizes_now(1);
return (CMD_RETURN_NORMAL);
}
out: if (sscanf(size, "%u,%u", &x, &y) != 2 &&
free(copy); sscanf(size, "%ux%u", &x, &y) != 2) {
cmdq_error(item, "bad size argument");
return (CMD_RETURN_ERROR);
}
if (x < WINDOW_MINIMUM || x > WINDOW_MAXIMUM ||
y < WINDOW_MINIMUM || y > WINDOW_MAXIMUM) {
cmdq_error(item, "size too small or too big");
return (CMD_RETURN_ERROR);
}
tty_set_size(&tc->tty, x, y, 0, 0);
tc->flags |= CLIENT_SIZECHANGED;
recalculate_sizes_now(1);
return (CMD_RETURN_NORMAL);
} }
static void static void
@@ -110,6 +137,41 @@ out:
free(copy); free(copy);
} }
static void
cmd_refresh_report(struct tty *tty, const char *value)
{
struct window_pane *wp;
u_int pane;
int fg, bg;
size_t size = 0;
char *copy, *split;
if (*value != '%')
return;
copy = xstrdup(value);
if ((split = strchr(copy, ':')) == NULL)
goto out;
*split++ = '\0';
if (sscanf(copy, "%%%u", &pane) != 1)
goto out;
wp = window_pane_find_by_id(pane);
if (wp == NULL)
goto out;
fg = wp->control_fg;
bg = wp->control_bg;
if (tty_keys_colours(tty, split, strlen(split), &size, &fg, &bg) == 0) {
if (bg != wp->control_bg)
wp->flags |= PANE_THEMECHANGED;
wp->control_fg = fg;
wp->control_bg = bg;
}
out:
free(copy);
}
static enum cmd_retval static enum cmd_retval
cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item) cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
{ {
@@ -117,8 +179,8 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct tty *tty = &tc->tty; struct tty *tty = &tc->tty;
struct window *w; struct window *w;
const char *size, *errstr, *value; const char *errstr;
u_int x, y, adjust; u_int adjust;
struct args_value *av; struct args_value *av;
if (args_has(args, 'c') || if (args_has(args, 'c') ||
@@ -127,10 +189,11 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
args_has(args, 'U') || args_has(args, 'U') ||
args_has(args, 'D')) args_has(args, 'D'))
{ {
if (args->argc == 0) if (args_count(args) == 0)
adjust = 1; adjust = 1;
else { else {
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr); adjust = strtonum(args_string(args, 0), 1, INT_MAX,
&errstr);
if (errstr != NULL) { if (errstr != NULL) {
cmdq_error(item, "adjustment %s", errstr); cmdq_error(item, "adjustment %s", errstr);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
@@ -172,7 +235,7 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
} }
if (args_has(args, 'l')) { if (args_has(args, 'l')) {
tty_putcode_ptr2(&tc->tty, TTYC_MS, "", "?"); tty_clipboard_query(&tc->tty);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
@@ -180,45 +243,33 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
server_client_set_flags(tc, args_get(args, 'F')); server_client_set_flags(tc, args_get(args, 'F'));
if (args_has(args, 'f')) if (args_has(args, 'f'))
server_client_set_flags(tc, args_get(args, 'f')); server_client_set_flags(tc, args_get(args, 'f'));
if (args_has(args, 'r'))
cmd_refresh_report(tty, args_get(args, 'r'));
if (args_has(args, 'A')) { if (args_has(args, 'A')) {
if (~tc->flags & CLIENT_CONTROL) if (~tc->flags & CLIENT_CONTROL)
goto not_control_client; goto not_control_client;
value = args_first_value(args, 'A', &av); av = args_first_value(args, 'A');
while (value != NULL) { while (av != NULL) {
cmd_refresh_client_update_offset(tc, value); cmd_refresh_client_update_offset(tc, av->string);
value = args_next_value(&av); av = args_next_value(av);
} }
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(args, 'B')) { if (args_has(args, 'B')) {
if (~tc->flags & CLIENT_CONTROL) if (~tc->flags & CLIENT_CONTROL)
goto not_control_client; goto not_control_client;
value = args_first_value(args, 'B', &av); av = args_first_value(args, 'B');
while (value != NULL) { while (av != NULL) {
cmd_refresh_client_update_subscription(tc, value); cmd_refresh_client_update_subscription(tc, av->string);
value = args_next_value(&av); av = args_next_value(av);
} }
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(args, 'C')) { if (args_has(args, 'C')) {
if (~tc->flags & CLIENT_CONTROL) if (~tc->flags & CLIENT_CONTROL)
goto not_control_client; goto not_control_client;
size = args_get(args, 'C'); return (cmd_refresh_client_control_client_size(self, item));
if (sscanf(size, "%u,%u", &x, &y) != 2 &&
sscanf(size, "%ux%u", &x, &y) != 2) {
cmdq_error(item, "bad size argument");
return (CMD_RETURN_ERROR);
}
if (x < WINDOW_MINIMUM || x > WINDOW_MAXIMUM ||
y < WINDOW_MINIMUM || y > WINDOW_MAXIMUM) {
cmdq_error(item, "size too small or too big");
return (CMD_RETURN_ERROR);
}
tty_set_size(&tc->tty, x, y, 0, 0);
tc->flags |= CLIENT_SIZECHANGED;
recalculate_sizes_now(1);
return (CMD_RETURN_NORMAL);
} }
if (args_has(args, 'S')) { if (args_has(args, 'S')) {

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-rename-session.c,v 1.39 2026/07/10 13:38:45 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -34,7 +34,7 @@ const struct cmd_entry cmd_rename_session_entry = {
.name = "rename-session", .name = "rename-session",
.alias = "rename", .alias = "rename",
.args = { "t:", 1, 1 }, .args = { "t:", 1, 1, NULL },
.usage = CMD_TARGET_SESSION_USAGE " new-name", .usage = CMD_TARGET_SESSION_USAGE " new-name",
.target = { 't', CMD_FIND_SESSION, 0 }, .target = { 't', CMD_FIND_SESSION, 0 },
@@ -49,10 +49,17 @@ cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct session *s = target->s; struct session *s = target->s;
struct event_payload *ep;
struct cmd_find_state fs;
char *newname, *tmp; char *newname, *tmp;
tmp = format_single_from_target(item, args->argv[0]); tmp = format_single_from_target(item, args_string(args, 0));
newname = session_check_name(tmp); if (!check_name(tmp)) {
cmdq_error(item, "invalid session name: %s", tmp);
free(tmp);
return (CMD_RETURN_ERROR);
}
newname = clean_name(tmp, 0);
free(tmp); free(tmp);
if (strcmp(newname, s->name) == 0) { if (strcmp(newname, s->name) == 0) {
free(newname); free(newname);
@@ -64,13 +71,20 @@ cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
ep = event_payload_create();
cmd_find_from_session(&fs, s, 0);
event_payload_set_target(ep, &fs);
event_payload_set_session(ep, "session", s);
event_payload_set_string(ep, "old_name", "%s", s->name);
event_payload_set_string(ep, "new_name", "%s", newname);
RB_REMOVE(sessions, &sessions, s); RB_REMOVE(sessions, &sessions, s);
free(s->name); free(s->name);
s->name = newname; s->name = newname;
RB_INSERT(sessions, &sessions, s); RB_INSERT(sessions, &sessions, s);
server_status_session(s); server_status_session(s);
notify_session("session-renamed", s); events_fire("session-renamed", ep);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-rename-window.c,v 1.30 2026/06/29 18:17:28 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_rename_window_entry = {
.name = "rename-window", .name = "rename-window",
.alias = "renamew", .alias = "renamew",
.args = { "t:", 1, 1 }, .args = { "t:", 1, 1, NULL },
.usage = CMD_TARGET_WINDOW_USAGE " new-name", .usage = CMD_TARGET_WINDOW_USAGE " new-name",
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
@@ -48,15 +48,21 @@ cmd_rename_window_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
char *newname; char *name;
newname = format_single_from_target(item, args->argv[0]); name = format_single_from_target(item, args_string(args, 0));
window_set_name(wl->window, newname); if (!check_name(name)) {
cmdq_error(item, "invalid window name: %s", name);
free(name);
return (CMD_RETURN_ERROR);
}
window_set_name(wl->window, name, 0);
options_set_number(wl->window->options, "automatic-rename", 0); options_set_number(wl->window->options, "automatic-rename", 0);
free(name);
server_redraw_window_borders(wl->window); server_redraw_window_borders(wl->window);
server_status_window(wl->window); server_status_window(wl->window);
free(newname);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-resize-pane.c,v 1.67 2026/07/10 13:38:45 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -18,6 +18,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -29,16 +30,20 @@
static enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmdq_item *); static enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmdq_item *);
static void cmd_resize_pane_mouse_update(struct client *, static enum cmd_retval cmd_resize_pane_mouse_update(struct cmd *,
struct mouse_event *); struct cmdq_item *);
static void cmd_resize_pane_mouse_resize_move_floating(
struct client *, struct mouse_event *);
static void cmd_resize_pane_mouse_resize_tiled(struct client *,
struct mouse_event *);
const struct cmd_entry cmd_resize_pane_entry = { const struct cmd_entry cmd_resize_pane_entry = {
.name = "resize-pane", .name = "resize-pane",
.alias = "resizep", .alias = "resizep",
.args = { "DLMRTt:Ux:y:Z", 0, 1 }, .args = { "D::L::MR::Tt:U::x:y:Z", 0, 1, NULL },
.usage = "[-DLMRTUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " " .usage = "[-MTZ] [-D lines] [-L columns] [-R columns] [-U lines] "
"[adjustment]", "[-x width] [-y height] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -51,23 +56,23 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct key_event *event = cmdq_get_event(item);
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
struct window *w = wl->window; struct window *w = wl->window;
struct client *c = cmdq_get_client(item); struct layout_cell *lc = wp->layout_cell;
struct session *s = target->s; enum layout_type type;
const char *errstr; const char *errstr, *argval;
char *cause; const char flags[4] = { 'U', 'D', 'L', 'R' };
u_int adjust; char *cause = NULL, flag;
int x, y; int adjust, x, y, status, opposite = 0;
long unsigned i;
struct grid *gd = wp->base.grid; struct grid *gd = wp->base.grid;
if (args_has(args, 'T')) { if (args_has(args, 'T')) {
if (!TAILQ_EMPTY(&wp->modes)) if (!TAILQ_EMPTY(&wp->modes))
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
adjust = screen_size_y(&wp->base) - 1 - wp->base.cy; adjust = screen_size_y(&wp->base) - 1 - wp->base.cy;
if (adjust > gd->hsize) if (adjust > (int)gd->hsize)
adjust = gd->hsize; adjust = gd->hsize;
grid_remove_history(gd, adjust); grid_remove_history(gd, adjust);
wp->base.cy += adjust; wp->base.cy += adjust;
@@ -75,19 +80,12 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(args, 'M')) { if (args_has(args, 'M'))
if (!event->m.valid || cmd_mouse_window(&event->m, &s) == NULL) return (cmd_resize_pane_mouse_update(self, item));
return (CMD_RETURN_NORMAL);
if (c == NULL || c->session != s)
return (CMD_RETURN_NORMAL);
c->tty.mouse_drag_update = cmd_resize_pane_mouse_update;
cmd_resize_pane_mouse_update(c, &event->m);
return (CMD_RETURN_NORMAL);
}
if (args_has(args, 'Z')) { if (args_has(args, 'Z')) {
if (w->flags & WINDOW_ZOOMED) if (w->flags & WINDOW_ZOOMED)
window_unzoom(w); window_unzoom(w, 1);
else else
window_zoom(wp); window_zoom(wp);
server_redraw_window(w); server_redraw_window(w);
@@ -95,55 +93,271 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
} }
server_unzoom_window(w); server_unzoom_window(w);
if (args->argc == 0)
adjust = 1;
else {
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
if (errstr != NULL) {
cmdq_error(item, "adjustment %s", errstr);
return (CMD_RETURN_ERROR);
}
}
if (args_has(args, 'x')) { if (args_has(args, 'x')) {
x = args_percentage(args, 'x', 0, INT_MAX, w->sx, &cause); x = args_percentage(args, 'x', 0, PANE_MAXIMUM, w->sx, &cause);
if (cause != NULL) { if (cause != NULL) {
cmdq_error(item, "width %s", cause); cmdq_error(item, "width %s", cause);
free(cause); free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
layout_resize_pane_to(wp, LAYOUT_LEFTRIGHT, x); if (window_pane_is_floating(wp)) {
if (layout_resize_floating_pane_to(wp, LAYOUT_LEFTRIGHT,
x, &cause) != 0) {
cmdq_error(item, "size %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
} else
layout_resize_pane_to(wp, LAYOUT_LEFTRIGHT, x);
} }
if (args_has(args, 'y')) { if (args_has(args, 'y')) {
y = args_percentage(args, 'y', 0, INT_MAX, w->sy, &cause); y = args_percentage(args, 'y', 0, PANE_MAXIMUM, w->sy, &cause);
if (cause != NULL) { if (cause != NULL) {
cmdq_error(item, "height %s", cause); cmdq_error(item, "height %s", cause);
free(cause); free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y); status = window_get_pane_status(w);
switch (status) {
case PANE_STATUS_TOP:
if (y != INT_MAX && wp->yoff == 1)
y++;
break;
case PANE_STATUS_BOTTOM:
if (y != INT_MAX && wp->yoff + wp->sy == w->sy - 1)
y++;
break;
}
if (window_pane_is_floating(wp)) {
if (layout_resize_floating_pane_to(wp, LAYOUT_TOPBOTTOM,
y, &cause) != 0) {
cmdq_error(item, "size %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
} else
layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y);
} }
if (args_has(args, 'L')) for (i = 0; i < nitems(flags); i++) {
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust, 1); flag = flags[i];
else if (args_has(args, 'R')) if (!args_has(args, flag))
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust, 1); continue;
else if (args_has(args, 'U'))
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust, 1); argval = args_get(args, flag);
else if (args_has(args, 'D')) if (argval == NULL) {
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust, 1); if (args_count(args) == 0)
server_redraw_window(wl->window); argval = "1";
else
argval = args_string(args, 0);
}
adjust = strtonum(argval, INT_MIN, INT_MAX, &errstr);
if (errstr != NULL) {
cmdq_error(item, "adjustment %s", errstr);
return (CMD_RETURN_ERROR);
}
type = LAYOUT_TOPBOTTOM;
if (flag == 'L' || flag == 'R')
type = LAYOUT_LEFTRIGHT;
if (window_pane_is_floating(wp)) {
if (flag == 'L' || flag == 'U')
opposite = 1;
if (layout_resize_floating_pane(wp, type, adjust,
opposite, &cause) != 0) {
cmdq_error(item, "adjustment %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
} else {
if (flag == 'L' || flag == 'U')
adjust = -adjust;
layout_resize_pane(wp, type, adjust, 1);
}
}
if (lc->parent != NULL)
layout_fix_offsets(w);
layout_fix_panes(w, NULL);
events_fire_window("window-layout-changed", w);
server_redraw_window(w);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
static enum cmd_retval
cmd_resize_pane_mouse_update(__unused struct cmd *self, struct cmdq_item *item)
{
struct cmd_find_state *target = cmdq_get_target(item);
struct key_event *event = cmdq_get_event(item);
struct window_pane *wp = target->wp;
struct winlink *wl = target->wl;
struct window *w = wl->window;
struct client *c = cmdq_get_client(item);
struct session *s = target->s;
if (!event->m.valid)
return (CMD_RETURN_NORMAL);
wp = cmd_mouse_pane(&event->m, &s, NULL);
if (wp == NULL || c == NULL || c->session != s)
return (CMD_RETURN_NORMAL);
if (!window_pane_is_floating(wp)) {
c->tty.mouse_drag_update = cmd_resize_pane_mouse_resize_tiled;
cmd_resize_pane_mouse_resize_tiled(c, &event->m);
return (CMD_RETURN_NORMAL);
}
window_redraw_active_switch(w, wp);
window_set_active_pane(w, wp, 1);
c->tty.mouse_drag_update = cmd_resize_pane_mouse_resize_move_floating;
cmd_resize_pane_mouse_resize_move_floating(c, &event->m);
return (CMD_RETURN_NORMAL);
}
/*
* Resizes or moves the pane by dragging. Resize a floating pane by dragging
* the borders or corners. Grabbing an edge only resizes that axis (special
* case). Moves the pane if dragging the top border. Since characters are
* generally rectangular, to make it easier to grab the corner, the character
* next to the corner is also considered the corner.
*/
static void static void
cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m) cmd_resize_pane_mouse_resize_move_floating(struct client *c,
struct mouse_event *m)
{
struct winlink *wl;
struct window *w;
struct window_pane *wp;
struct layout_cell *lc;
int y, ly, x, lx, sx, sy, new_sx, new_sy;
int left, right;
int new_xoff, new_yoff, resizes = 0;
wp = cmd_mouse_pane(m, NULL, &wl);
if (wp == NULL) {
c->tty.mouse_drag_update = NULL;
return;
}
w = wl->window;
lc = wp->layout_cell;
sx = wp->sx;
sy = wp->sy;
left = wp->xoff - 1;
right = wp->xoff + sx;
if (window_pane_scrollbar_reserve(wp) &&
w->sb_pos == PANE_SCROLLBARS_LEFT) {
left -= wp->scrollbar_style.width + wp->scrollbar_style.pad;
} else if (window_pane_scrollbar_reserve(wp) &&
w->sb_pos == PANE_SCROLLBARS_RIGHT) {
right += wp->scrollbar_style.width + wp->scrollbar_style.pad;
}
y = m->y + m->oy; x = m->x + m->ox;
if (m->statusat == 0 && y >= (int)m->statuslines)
y -= m->statuslines;
else if (m->statusat > 0 && y >= m->statusat)
y = m->statusat - 1;
ly = m->ly + m->oy; lx = m->lx + m->ox;
if (m->statusat == 0 && ly >= (int)m->statuslines)
ly -= m->statuslines;
else if (m->statusat > 0 && ly >= m->statusat)
ly = m->statusat - 1;
if ((lx == left || lx == left + 1) && ly == wp->yoff - 1) {
/* Top left corner. */
new_sx = lc->g.sx + (lx - x);
if (new_sx < PANE_MINIMUM)
new_sx = PANE_MINIMUM;
new_sy = lc->g.sy + (ly - y);
if (new_sy < PANE_MINIMUM)
new_sy = PANE_MINIMUM;
new_xoff = x + 1; /* because mouse is on border at xoff - 1 */
new_yoff = y + 1;
layout_set_size(lc, new_sx, new_sy, new_xoff, new_yoff);
resizes++;
} else if ((lx == right + 1 || lx == right) &&
ly == wp->yoff - 1) {
/* Top right corner. */
new_sx = x - lc->g.xoff;
if (new_sx < PANE_MINIMUM)
new_sx = PANE_MINIMUM;
new_sy = lc->g.sy + (ly - y);
if (new_sy < PANE_MINIMUM)
new_sy = PANE_MINIMUM;
new_yoff = y + 1;
layout_set_size(lc, new_sx, new_sy, lc->g.xoff, new_yoff);
resizes++;
} else if ((lx == left || lx == left + 1) &&
ly == wp->yoff + sy) {
/* Bottom left corner. */
new_sx = lc->g.sx + (lx - x);
if (new_sx < PANE_MINIMUM)
new_sx = PANE_MINIMUM;
new_sy = y - lc->g.yoff;
if (new_sy < PANE_MINIMUM)
return;
new_xoff = x + 1;
layout_set_size(lc, new_sx, new_sy, new_xoff, lc->g.yoff);
resizes++;
} else if ((lx == right + 1 || lx == right) &&
ly == wp->yoff + sy) {
/* Bottom right corner. */
new_sx = x - lc->g.xoff;
if (new_sx < PANE_MINIMUM)
new_sx = PANE_MINIMUM;
new_sy = y - lc->g.yoff;
if (new_sy < PANE_MINIMUM)
new_sy = PANE_MINIMUM;
layout_set_size(lc, new_sx, new_sy, lc->g.xoff, lc->g.yoff);
resizes++;
} else if (lx == right) {
/* Right border. */
new_sx = x - lc->g.xoff;
if (new_sx < PANE_MINIMUM)
return;
layout_set_size(lc, new_sx, lc->g.sy, lc->g.xoff, lc->g.yoff);
resizes++;
} else if (lx == left) {
/* Left border. */
new_sx = lc->g.sx + (lx - x);
if (new_sx < PANE_MINIMUM)
return;
new_xoff = x + 1;
layout_set_size(lc, new_sx, lc->g.sy, new_xoff, lc->g.yoff);
resizes++;
} else if (ly == wp->yoff + sy) {
/* Bottom border. */
new_sy = y - lc->g.yoff;
if (new_sy < PANE_MINIMUM)
return;
layout_set_size(lc, lc->g.sx, new_sy, lc->g.xoff, lc->g.yoff);
resizes++;
} else if (ly == wp->yoff - 1) {
/* Top border (move instead of resize). */
new_xoff = lc->g.xoff + (x - lx);
new_yoff = y + 1;
layout_set_size(lc, lc->g.sx, lc->g.sy, new_xoff, new_yoff);
resizes++;
}
if (resizes != 0) {
layout_fix_panes(w, NULL);
server_redraw_window(w);
server_redraw_window_borders(w);
}
}
static void
cmd_resize_pane_mouse_resize_tiled(struct client *c, struct mouse_event *m)
{ {
struct winlink *wl; struct winlink *wl;
struct window *w; struct window *w;
u_int y, ly, x, lx; u_int y, ly, x, lx;
static const int offsets[][2] = { static const int offsets[][2] = {
{ 0, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 }, { 0, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 },
}; };
struct layout_cell *cells[nitems(offsets)], *lc; struct layout_cell *cells[nitems(offsets)], *lc;

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-resize-window.c,v 1.10 2023/06/30 13:19:32 nicm Exp $ */
/* /*
* Copyright (c) 2018 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2018 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_resize_window_entry = {
.name = "resize-window", .name = "resize-window",
.alias = "resizew", .alias = "resizew",
.args = { "aADLRt:Ux:y:", 0, 1 }, .args = { "aADLRt:Ux:y:", 0, 1, NULL },
.usage = "[-aADLRU] [-x width] [-y height] " CMD_TARGET_WINDOW_USAGE " " .usage = "[-aADLRU] [-x width] [-y height] " CMD_TARGET_WINDOW_USAGE " "
"[adjustment]", "[adjustment]",
@@ -53,13 +53,12 @@ cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item)
struct session *s = target->s; struct session *s = target->s;
const char *errstr; const char *errstr;
char *cause; char *cause;
u_int adjust, sx, sy; u_int adjust, sx, sy, xpixel = 0, ypixel = 0;
int xpixel = -1, ypixel = -1;
if (args->argc == 0) if (args_count(args) == 0)
adjust = 1; adjust = 1;
else { else {
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr); adjust = strtonum(args_string(args, 0), 1, INT_MAX, &errstr);
if (errstr != NULL) { if (errstr != NULL) {
cmdq_error(item, "adjustment %s", errstr); cmdq_error(item, "adjustment %s", errstr);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
@@ -108,7 +107,9 @@ cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item)
} }
options_set_number(w->options, "window-size", WINDOW_SIZE_MANUAL); options_set_number(w->options, "window-size", WINDOW_SIZE_MANUAL);
resize_window(w, sx, sy, xpixel, ypixel); w->manual_sx = sx;
w->manual_sy = sy;
recalculate_size(w, 1);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-respawn-pane.c,v 1.40 2026/07/03 16:09:49 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -34,9 +34,9 @@ const struct cmd_entry cmd_respawn_pane_entry = {
.name = "respawn-pane", .name = "respawn-pane",
.alias = "respawnp", .alias = "respawnp",
.args = { "c:e:kt:", 0, -1 }, .args = { "c:e:Ekt:", 0, -1, NULL },
.usage = "[-k] [-c start-directory] [-e environment] " .usage = "[-Ek] [-c start-directory] [-e environment] "
CMD_TARGET_PANE_USAGE " [command]", CMD_TARGET_PANE_USAGE " [shell-command [argument ...]]",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -49,43 +49,43 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct spawn_context sc; struct spawn_context sc = { 0 };
struct session *s = target->s; struct session *s = target->s;
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
char *cause = NULL; char *cause = NULL;
const char *add; struct args_value *av;
struct args_value *value;
memset(&sc, 0, sizeof sc);
sc.item = item; sc.item = item;
sc.s = s; sc.s = s;
sc.wl = wl; sc.wl = wl;
sc.wp0 = wp; sc.wp0 = wp;
sc.lc = NULL;
sc.name = NULL; args_to_vector(args, &sc.argc, &sc.argv);
sc.argc = args->argc;
sc.argv = args->argv;
sc.environ = environ_create(); sc.environ = environ_create();
add = args_first_value(args, 'e', &value); av = args_first_value(args, 'e');
while (add != NULL) { while (av != NULL) {
environ_put(sc.environ, add, 0); environ_put(sc.environ, av->string, 0);
add = args_next_value(&value); av = args_next_value(av);
} }
sc.idx = -1; sc.idx = -1;
sc.cwd = args_get(args, 'c'); sc.cwd = args_get(args, 'c');
sc.flags = SPAWN_RESPAWN; sc.flags = SPAWN_RESPAWN;
if (args_has(args, 'E'))
sc.flags |= SPAWN_EMPTY;
if (args_has(args, 'k')) if (args_has(args, 'k'))
sc.flags |= SPAWN_KILL; sc.flags |= SPAWN_KILL;
if (spawn_pane(&sc, &cause) == NULL) { if (spawn_pane(&sc, &cause) == NULL) {
cmdq_error(item, "respawn pane failed: %s", cause); cmdq_error(item, "respawn pane failed: %s", cause);
free(cause); free(cause);
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
@@ -93,6 +93,8 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
server_redraw_window_borders(wp->window); server_redraw_window_borders(wp->window);
server_status_window(wp->window); server_status_window(wp->window);
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ); environ_free(sc.environ);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-respawn-window.c,v 1.51 2026/07/03 16:09:49 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -34,9 +34,9 @@ const struct cmd_entry cmd_respawn_window_entry = {
.name = "respawn-window", .name = "respawn-window",
.alias = "respawnw", .alias = "respawnw",
.args = { "c:e:kt:", 0, -1 }, .args = { "c:e:Ekt:", 0, -1, NULL },
.usage = "[-k] [-c start-directory] [-e environment] " .usage = "[-Ek] [-c start-directory] [-e environment] "
CMD_TARGET_WINDOW_USAGE " [command]", CMD_TARGET_WINDOW_USAGE " [shell-command [argument ...]]",
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
@@ -49,46 +49,49 @@ cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct spawn_context sc; struct spawn_context sc = { 0 };
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct session *s = target->s; struct session *s = target->s;
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
char *cause = NULL; char *cause = NULL;
const char *add; struct args_value *av;
struct args_value *value;
memset(&sc, 0, sizeof sc);
sc.item = item; sc.item = item;
sc.s = s; sc.s = s;
sc.wl = wl; sc.wl = wl;
sc.tc = tc; sc.tc = tc;
sc.name = NULL; args_to_vector(args, &sc.argc, &sc.argv);
sc.argc = args->argc;
sc.argv = args->argv;
sc.environ = environ_create(); sc.environ = environ_create();
add = args_first_value(args, 'e', &value); av = args_first_value(args, 'e');
while (add != NULL) { while (av != NULL) {
environ_put(sc.environ, add, 0); environ_put(sc.environ, av->string, 0);
add = args_next_value(&value); av = args_next_value(av);
} }
sc.idx = -1; sc.idx = -1;
sc.cwd = args_get(args, 'c'); sc.cwd = args_get(args, 'c');
sc.flags = SPAWN_RESPAWN; sc.flags = SPAWN_RESPAWN;
if (args_has(args, 'E'))
sc.flags |= SPAWN_EMPTY;
if (args_has(args, 'k')) if (args_has(args, 'k'))
sc.flags |= SPAWN_KILL; sc.flags |= SPAWN_KILL;
if (spawn_window(&sc, &cause) == NULL) { if (spawn_window(&sc, &cause) == NULL) {
cmdq_error(item, "respawn window failed: %s", cause); cmdq_error(item, "respawn window failed: %s", cause);
free(cause); free(cause);
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
server_redraw_window(wl->window); server_redraw_window(wl->window);
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ); environ_free(sc.environ);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-rotate-window.c,v 1.34 2026/06/22 08:47:45 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -31,7 +31,7 @@ const struct cmd_entry cmd_rotate_window_entry = {
.name = "rotate-window", .name = "rotate-window",
.alias = "rotatew", .alias = "rotatew",
.args = { "Dt:UZ", 0, 0 }, .args = { "Dt:UZ", 0, 0, NULL },
.usage = "[-DUZ] " CMD_TARGET_WINDOW_USAGE, .usage = "[-DUZ] " CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
@@ -109,6 +109,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
window_set_active_pane(w, wp, 1); window_set_active_pane(w, wp, 1);
cmd_find_from_winlink_pane(current, wl, wp, 0); cmd_find_from_winlink_pane(current, wl, wp, 0);
window_pop_zoom(w); window_pop_zoom(w);
redraw_invalidate_scene(w);
server_redraw_window(w); server_redraw_window(w);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-run-shell.c,v 1.93 2026/07/17 12:42:51 nicm Exp $ */
/* /*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -30,7 +30,10 @@
* Runs a command without a window. * Runs a command without a window.
*/ */
static enum cmd_retval cmd_run_shell_exec(struct cmd *, struct cmdq_item *); static enum args_parse_type cmd_run_shell_args_parse(struct args *, u_int,
char **);
static enum cmd_retval cmd_run_shell_exec(struct cmd *,
struct cmdq_item *);
static void cmd_run_shell_timer(int, short, void *); static void cmd_run_shell_timer(int, short, void *);
static void cmd_run_shell_callback(struct job *); static void cmd_run_shell_callback(struct job *);
@@ -41,8 +44,9 @@ const struct cmd_entry cmd_run_shell_entry = {
.name = "run-shell", .name = "run-shell",
.alias = "run", .alias = "run",
.args = { "bd:Ct:", 0, 1 }, .args = { "bd:Ct:Es:c:", 0, -1, cmd_run_shell_args_parse },
.usage = "[-bC] [-d delay] " CMD_TARGET_PANE_USAGE " [shell-command]", .usage = "[-bCE] [-c start-directory] [-d delay] " CMD_TARGET_PANE_USAGE
" [shell-command [argument ...]]",
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
@@ -51,18 +55,26 @@ const struct cmd_entry cmd_run_shell_entry = {
}; };
struct cmd_run_shell_data { struct cmd_run_shell_data {
struct client *client; struct client *client;
char *cmd; char *cmd;
int shell; struct args_command_state *state;
char *cwd; char *cwd;
struct cmdq_item *item; struct cmdq_item *item;
struct session *s; struct session *s;
int wp_id; int wp_id;
struct event timer; struct event timer;
int flags; int flags;
struct cmd_parse_input pi;
}; };
static enum args_parse_type
cmd_run_shell_args_parse(struct args *args, __unused u_int idx,
__unused char **cause)
{
if (args_has(args, 'C'))
return (ARGS_PARSE_COMMANDS_OR_STRING);
return (ARGS_PARSE_STRING);
}
static void static void
cmd_run_shell_print(struct job *job, const char *msg) cmd_run_shell_print(struct job *job, const char *msg)
{ {
@@ -78,17 +90,19 @@ cmd_run_shell_print(struct job *job, const char *msg)
cmdq_print(cdata->item, "%s", msg); cmdq_print(cdata->item, "%s", msg);
return; return;
} }
if (cmd_find_from_nothing(&fs, 0) != 0) if (cdata->client != NULL && cdata->client->session != NULL)
return; wp = cdata->client->session->curw->window->active;
wp = fs.wp; if (wp == NULL && cmd_find_from_nothing(&fs, 0) == 0)
wp = fs.wp;
if (wp == NULL) if (wp == NULL)
return; return;
} }
wme = TAILQ_FIRST(&wp->modes); wme = TAILQ_FIRST(&wp->modes);
if (wme == NULL || wme->mode != &window_view_mode) if (wme == NULL || wme->mode != &window_view_mode)
window_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL); window_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL,
window_copy_add(wp, "%s", msg); NULL);
window_copy_add(wp, 1, "%s", msg);
} }
static enum cmd_retval static enum cmd_retval
@@ -97,13 +111,16 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct cmd_run_shell_data *cdata; struct cmd_run_shell_data *cdata;
struct client *c = cmdq_get_client(item);
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct session *s = target->s; struct session *s = target->s;
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
const char *delay; const char *delay, *cmd;
struct format_tree *ft;
double d; double d;
struct timeval tv; struct timeval tv;
char *end; char *end, key[16];
u_int i;
int wait = !args_has(args, 'b'); int wait = !args_has(args, 'b');
if ((delay = args_get(args, 'd')) != NULL) { if ((delay = args_get(args, 'd')) != NULL) {
@@ -112,21 +129,24 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "invalid delay time: %s", delay); cmdq_error(item, "invalid delay time: %s", delay);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
} else if (args->argc == 0) } else if (args_count(args) == 0)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
cdata = xcalloc(1, sizeof *cdata); cdata = xcalloc(1, sizeof *cdata);
if (args->argc != 0) if (!args_has(args, 'C')) {
cdata->cmd = format_single_from_target(item, args->argv[0]); cmd = args_string(args, 0);
if (cmd != NULL) {
cdata->shell = !args_has(args, 'C'); ft = format_create_from_target(item);
if (!cdata->shell) { for (i = 1; i < args_count(args); i++) {
memset(&cdata->pi, 0, sizeof cdata->pi); xsnprintf(key, sizeof key, "%u", i);
cmd_get_source(self, &cdata->pi.file, &cdata->pi.line); format_add(ft, key, "%s", args_string(args, i));
if (wait) }
cdata->pi.item = item; cdata->cmd = format_expand(ft, cmd);
cdata->pi.c = tc; format_free(ft);
cmd_find_copy_state(&cdata->pi.fs, target); }
} else {
cdata->state = args_make_commands_prepare(self, item, 0, NULL,
wait, 1);
} }
if (args_has(args, 't') && wp != NULL) if (args_has(args, 't') && wp != NULL)
@@ -135,7 +155,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
cdata->wp_id = -1; cdata->wp_id = -1;
if (wait) { if (wait) {
cdata->client = cmdq_get_client(item); cdata->client = c;
cdata->item = item; cdata->item = item;
} else { } else {
cdata->client = tc; cdata->client = tc;
@@ -143,8 +163,13 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
} }
if (cdata->client != NULL) if (cdata->client != NULL)
cdata->client->references++; cdata->client->references++;
if (args_has(args, 'c'))
cdata->cwd = xstrdup(args_get(args, 'c'));
else
cdata->cwd = xstrdup(server_client_get_cwd(c, s));
cdata->cwd = xstrdup(server_client_get_cwd(cmdq_get_client(item), s)); if (args_has(args, 'E'))
cdata->flags |= JOB_SHOWSTDERR;
cdata->s = s; cdata->s = s;
if (s != NULL) if (s != NULL)
@@ -170,34 +195,47 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg)
struct cmd_run_shell_data *cdata = arg; struct cmd_run_shell_data *cdata = arg;
struct client *c = cdata->client; struct client *c = cdata->client;
const char *cmd = cdata->cmd; const char *cmd = cdata->cmd;
struct cmdq_item *item = cdata->item, *new_item;
struct cmd_list *cmdlist;
char *error; char *error;
struct cmdq_item *item = cdata->item;
enum cmd_parse_status status;
if (cmd != NULL && cdata->shell) { if (cdata->state == NULL) {
if (job_run(cmd, 0, NULL, cdata->s, cdata->cwd, NULL, if (cmd == NULL) {
cmd_run_shell_callback, cmd_run_shell_free, cdata, if (cdata->item != NULL)
cdata->flags, -1, -1) == NULL) cmdq_continue(cdata->item);
cmd_run_shell_free(cdata); cmd_run_shell_free(cdata);
return;
}
if (job_run(cmd, 0, NULL, NULL, cdata->s, cdata->cwd, NULL,
cmd_run_shell_callback, cmd_run_shell_free, cdata,
cdata->flags, -1, -1) == NULL) {
if (cdata->item == NULL)
status_message_set(c, -1, 1, 0, 0,
"failed to run command: %s", cmd);
else {
cmdq_error(cdata->item,
"failed to run command: %s", cmd);
cmdq_continue(cdata->item);
}
cmd_run_shell_free(cdata);
}
return; return;
} }
if (cmd != NULL) { cmdlist = args_make_commands(cdata->state, 0, NULL, &error);
if (item != NULL) { if (cmdlist == NULL) {
status = cmd_parse_and_insert(cmd, &cdata->pi, item, if (cdata->item == NULL) {
cmdq_get_state(item), &error); *error = toupper((u_char)*error);
} else { status_message_set(c, -1, 1, 0, 0, "%s", error);
status = cmd_parse_and_append(cmd, &cdata->pi, c, NULL, } else
&error); cmdq_error(cdata->item, "%s", error);
} free(error);
if (status == CMD_PARSE_ERROR) { } else if (item == NULL) {
if (cdata->item == NULL) { new_item = cmdq_get_command(cmdlist, NULL);
*error = toupper((u_char)*error); cmdq_append(c, new_item);
status_message_set(c, -1, 1, 0, "%s", error); } else {
} else new_item = cmdq_get_command(cmdlist, cmdq_get_state(item));
cmdq_error(cdata->item, "%s", error); cmdq_insert_after(item, new_item);
free(error);
}
} }
if (cdata->item != NULL) if (cdata->item != NULL)
@@ -216,7 +254,8 @@ cmd_run_shell_callback(struct job *job)
int retcode, status; int retcode, status;
do { do {
if ((line = evbuffer_readline(event->input)) != NULL) { line = evbuffer_readln(event->input, NULL, EVBUFFER_EOL_LF);
if (line != NULL) {
cmd_run_shell_print(job, line); cmd_run_shell_print(job, line);
free(line); free(line);
} }
@@ -265,6 +304,8 @@ cmd_run_shell_free(void *data)
session_remove_ref(cdata->s, __func__); session_remove_ref(cdata->s, __func__);
if (cdata->client != NULL) if (cdata->client != NULL)
server_client_unref(cdata->client); server_client_unref(cdata->client);
if (cdata->state != NULL)
args_make_commands_free(cdata->state);
free(cdata->cwd); free(cdata->cwd);
free(cdata->cmd); free(cdata->cmd);
free(cdata); free(cdata);

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-save-buffer.c,v 1.57 2025/10/28 07:32:26 nicm Exp $ */
/* /*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -37,7 +37,7 @@ const struct cmd_entry cmd_save_buffer_entry = {
.name = "save-buffer", .name = "save-buffer",
.alias = "saveb", .alias = "saveb",
.args = { "ab:", 1, 1 }, .args = { "ab:", 1, 1, NULL },
.usage = "[-a] " CMD_BUFFER_USAGE " path", .usage = "[-a] " CMD_BUFFER_USAGE " path",
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
@@ -48,7 +48,7 @@ const struct cmd_entry cmd_show_buffer_entry = {
.name = "show-buffer", .name = "show-buffer",
.alias = "showb", .alias = "showb",
.args = { "b:", 0, 0 }, .args = { "b:", 0, 0, NULL },
.usage = CMD_BUFFER_USAGE, .usage = CMD_BUFFER_USAGE,
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
@@ -65,7 +65,7 @@ cmd_save_buffer_done(__unused struct client *c, const char *path, int error,
return; return;
if (error != 0) if (error != 0)
cmdq_error(item, "%s: %s", path, strerror(error)); cmdq_error(item, "%s: %s", strerror(error), path);
cmdq_continue(item); cmdq_continue(item);
} }
@@ -78,7 +78,8 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
int flags; int flags;
const char *bufname = args_get(args, 'b'), *bufdata; const char *bufname = args_get(args, 'b'), *bufdata;
size_t bufsize; size_t bufsize;
char *path, *tmp; char *path;
struct evbuffer *evb;
if (bufname == NULL) { if (bufname == NULL) {
if ((pb = paste_get_top(NULL)) == NULL) { if ((pb = paste_get_top(NULL)) == NULL) {
@@ -96,15 +97,17 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
if (cmd_get_entry(self) == &cmd_show_buffer_entry) { if (cmd_get_entry(self) == &cmd_show_buffer_entry) {
if (c->session != NULL || (c->flags & CLIENT_CONTROL)) { if (c->session != NULL || (c->flags & CLIENT_CONTROL)) {
utf8_stravisx(&tmp, bufdata, bufsize, evb = evbuffer_new();
VIS_OCTAL|VIS_CSTYLE|VIS_TAB); if (evb == NULL)
cmdq_print(item, "%s", tmp); fatalx("out of memory");
free(tmp); evbuffer_add(evb, bufdata, bufsize);
cmdq_print_data(item, evb);
evbuffer_free(evb);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
path = xstrdup("-"); path = xstrdup("-");
} else } else
path = format_single_from_target(item, args->argv[0]); path = format_single_from_target(item, args_string(args, 0));
if (args_has(args, 'a')) if (args_has(args, 'a'))
flags = O_APPEND; flags = O_APPEND;
else else

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-select-layout.c,v 1.43 2026/07/10 13:38:45 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_select_layout_entry = {
.name = "select-layout", .name = "select-layout",
.alias = "selectl", .alias = "selectl",
.args = { "Enopt:", 0, 1 }, .args = { "Enopt:", 0, 1, NULL },
.usage = "[-Enop] " CMD_TARGET_PANE_USAGE " [layout-name]", .usage = "[-Enop] " CMD_TARGET_PANE_USAGE " [layout-name]",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -46,7 +46,7 @@ const struct cmd_entry cmd_next_layout_entry = {
.name = "next-layout", .name = "next-layout",
.alias = "nextl", .alias = "nextl",
.args = { "t:", 0, 0 }, .args = { "t:", 0, 0, NULL },
.usage = CMD_TARGET_WINDOW_USAGE, .usage = CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
@@ -59,7 +59,7 @@ const struct cmd_entry cmd_previous_layout_entry = {
.name = "previous-layout", .name = "previous-layout",
.alias = "prevl", .alias = "prevl",
.args = { "t:", 0, 0 }, .args = { "t:", 0, 0, NULL },
.usage = CMD_TARGET_WINDOW_USAGE, .usage = CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
@@ -77,7 +77,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
struct window *w = wl->window; struct window *w = wl->window;
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
const char *layoutname; const char *layoutname;
char *oldlayout; char *oldlayout, *cause;
int next, previous, layout; int next, previous, layout;
server_unzoom_window(w); server_unzoom_window(w);
@@ -90,7 +90,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
previous = 1; previous = 1;
oldlayout = w->old_layout; oldlayout = w->old_layout;
w->old_layout = layout_dump(w->layout_root); w->old_layout = layout_dump(w, w->layout_root);
if (next || previous) { if (next || previous) {
if (next) if (next)
@@ -105,27 +105,28 @@ cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
goto changed; goto changed;
} }
if (args_count(args) != 0)
layoutname = args_string(args, 0);
else if (args_has(args, 'o'))
layoutname = oldlayout;
else
layoutname = NULL;
if (!args_has(args, 'o')) { if (!args_has(args, 'o')) {
if (args->argc == 0) if (layoutname == NULL)
layout = w->lastlayout; layout = w->lastlayout;
else else
layout = layout_set_lookup(args->argv[0]); layout = layout_set_lookup(layoutname);
if (layout != -1) { if (layout != -1) {
layout_set_select(w, layout); layout_set_select(w, layout);
goto changed; goto changed;
} }
} }
if (args->argc != 0)
layoutname = args->argv[0];
else if (args_has(args, 'o'))
layoutname = oldlayout;
else
layoutname = NULL;
if (layoutname != NULL) { if (layoutname != NULL) {
if (layout_parse(w, layoutname) == -1) { if (layout_parse(w, layoutname, &cause) == -1) {
cmdq_error(item, "can't set layout: %s", layoutname); cmdq_error(item, "%s: %s", cause, layoutname);
free(cause);
goto error; goto error;
} }
goto changed; goto changed;
@@ -138,7 +139,7 @@ changed:
free(oldlayout); free(oldlayout);
recalculate_sizes(); recalculate_sizes();
server_redraw_window(w); server_redraw_window(w);
notify_window("window-layout-changed", w); events_fire_window("window-layout-changed", w);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
error: error:

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-select-pane.c,v 1.77 2026/07/17 12:42:51 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_select_pane_entry = {
.name = "select-pane", .name = "select-pane",
.alias = "selectp", .alias = "selectp",
.args = { "DdegLlMmP:RT:t:UZ", 0, 0 }, /* -P and -g deprecated */ .args = { "DdegLlMmP:RT:t:UZ", 0, 0, NULL }, /* -P and -g deprecated */
.usage = "[-DdeLlMmRUZ] [-T title] " CMD_TARGET_PANE_USAGE, .usage = "[-DdeLlMmRUZ] [-T title] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -46,7 +46,7 @@ const struct cmd_entry cmd_last_pane_entry = {
.name = "last-pane", .name = "last-pane",
.alias = "lastp", .alias = "lastp",
.args = { "det:Z", 0, 0 }, .args = { "det:Z", 0, 0, NULL },
.usage = "[-deZ] " CMD_TARGET_WINDOW_USAGE, .usage = "[-deZ] " CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
@@ -80,6 +80,69 @@ cmd_select_pane_redraw(struct window *w)
} }
} }
static enum cmd_retval
cmd_select_pane_marked_pane(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct event_payload *ep;
struct cmd_find_state fs;
struct winlink *wl = target->wl;
struct window_pane *wp = target->wp, *lwp = NULL, *mwp;
struct session *s = target->s;
if (args_has(args, 'm') && !window_pane_is_visible(wp))
return (CMD_RETURN_NORMAL);
if (server_check_marked())
lwp = marked_pane.wp;
if (args_has(args, 'M') || server_is_marked(s, wl, wp))
server_clear_marked();
else
server_set_marked(s, wl, wp);
mwp = marked_pane.wp;
ep = event_payload_create();
if (mwp != NULL)
cmd_find_from_pane(&fs, mwp, 0);
else if (lwp != NULL)
cmd_find_from_pane(&fs, lwp, 0);
else
cmd_find_from_pane(&fs, wp, 0);
event_payload_set_target(ep, &fs);
if (mwp != NULL) {
event_payload_set_pane(ep, "pane", mwp);
event_payload_set_pane(ep, "new_pane", mwp);
event_payload_set_window(ep, "window", mwp->window);
} else if (lwp != NULL) {
event_payload_set_pane(ep, "pane", lwp);
event_payload_set_window(ep, "window", lwp->window);
} else {
event_payload_set_pane(ep, "pane", wp);
event_payload_set_window(ep, "window", wp->window);
}
if (lwp != NULL)
event_payload_set_pane(ep, "old_pane", lwp);
event_payload_set_int(ep, "marked", mwp != NULL);
events_fire("marked-pane-changed", ep);
if (lwp != NULL) {
lwp->flags |= (PANE_REDRAW|PANE_STYLECHANGED|PANE_THEMECHANGED);
server_redraw_window_borders(lwp->window);
server_status_window(lwp->window);
}
if (mwp != NULL) {
mwp->flags |= (PANE_REDRAW|PANE_STYLECHANGED|PANE_THEMECHANGED);
server_redraw_window_borders(mwp->window);
server_status_window(mwp->window);
}
if (window_pane_is_floating(wp)) {
window_redraw_active_switch(wp->window, wp);
window_set_active_pane(wp->window, wp, 1);
}
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval static enum cmd_retval
cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
@@ -87,19 +150,24 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
const struct cmd_entry *entry = cmd_get_entry(self); const struct cmd_entry *entry = cmd_get_entry(self);
struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *current = cmdq_get_current(item);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmdq_get_client(item); struct event_payload *ep;
struct cmd_find_state fs;
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
struct window *w = wl->window; struct window *w = wl->window;
struct session *s = target->s; struct session *s = target->s;
struct window_pane *wp = target->wp, *activewp, *lastwp, *markedwp; struct window_pane *wp = target->wp, *lastwp;
struct options *oo = wp->options; struct options *oo = wp->options;
char *title; char *title;
const char *style; const char *style;
struct options_entry *o; struct options_entry *o;
if (entry == &cmd_last_pane_entry || args_has(args, 'l')) { if (entry == &cmd_last_pane_entry || args_has(args, 'l')) {
lastwp = w->last; /*
if (lastwp == NULL && window_count_panes(w) == 2) { * Check for no last pane found in case the other pane was
* spawned without being visited (for example split-window -d).
*/
lastwp = TAILQ_FIRST(&w->last_panes);
if (lastwp == NULL && window_count_panes(w, 1) == 2) {
lastwp = TAILQ_PREV(w->active, window_panes, entry); lastwp = TAILQ_PREV(w->active, window_panes, entry);
if (lastwp == NULL) if (lastwp == NULL)
lastwp = TAILQ_NEXT(w->active, entry); lastwp = TAILQ_NEXT(w->active, entry);
@@ -130,30 +198,8 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(args, 'm') || args_has(args, 'M')) { if (args_has(args, 'm') || args_has(args, 'M'))
if (args_has(args, 'm') && !window_pane_visible(wp)) return (cmd_select_pane_marked_pane(self, item));
return (CMD_RETURN_NORMAL);
if (server_check_marked())
lastwp = marked_pane.wp;
else
lastwp = NULL;
if (args_has(args, 'M') || server_is_marked(s, wl, wp))
server_clear_marked();
else
server_set_marked(s, wl, wp);
markedwp = marked_pane.wp;
if (lastwp != NULL) {
server_redraw_window_borders(lastwp->window);
server_status_window(lastwp->window);
}
if (markedwp != NULL) {
server_redraw_window_borders(markedwp->window);
server_status_window(markedwp->window);
}
return (CMD_RETURN_NORMAL);
}
style = args_get(args, 'P'); style = args_get(args, 'P');
if (style != NULL) { if (style != NULL) {
@@ -163,7 +209,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
options_set_string(oo, "window-active-style", 0, "%s", style); options_set_string(oo, "window-active-style", 0, "%s", style);
wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED); wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED|PANE_THEMECHANGED);
} }
if (args_has(args, 'g')) { if (args_has(args, 'g')) {
cmdq_print(item, "%s", options_get_string(oo, "window-style")); cmdq_print(item, "%s", options_get_string(oo, "window-style"));
@@ -205,8 +251,14 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
if (args_has(args, 'T')) { if (args_has(args, 'T')) {
title = format_single_from_target(item, args_get(args, 'T')); title = format_single_from_target(item, args_get(args, 'T'));
if (screen_set_title(&wp->base, title)) { if (screen_set_title(&wp->base, title, 0)) {
notify_pane("pane-title-changed", wp); ep = event_payload_create();
cmd_find_from_pane(&fs, wp, 0);
event_payload_set_target(ep, &fs);
event_payload_set_pane(ep, "pane", wp);
event_payload_set_window(ep, "window", wp->window);
event_payload_set_string(ep, "new_title", "%s", title);
events_fire("pane-title-changed", ep);
server_redraw_window_borders(wp->window); server_redraw_window_borders(wp->window);
server_status_window(wp->window); server_status_window(wp->window);
} }
@@ -214,18 +266,12 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (c != NULL && c->session != NULL && (c->flags & CLIENT_ACTIVEPANE)) if (wp == w->active)
activewp = server_client_get_pane(c);
else
activewp = w->active;
if (wp == activewp)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (window_push_zoom(w, 0, args_has(args, 'Z'))) if (window_push_zoom(w, 0, args_has(args, 'Z')))
server_redraw_window(w); server_redraw_window(w);
window_redraw_active_switch(w, wp); window_redraw_active_switch(w, wp);
if (c != NULL && c->session != NULL && (c->flags & CLIENT_ACTIVEPANE)) if (window_set_active_pane(w, wp, 1))
server_client_set_pane(c, wp);
else if (window_set_active_pane(w, wp, 1))
cmd_find_from_winlink_pane(current, wl, wp, 0); cmd_find_from_winlink_pane(current, wl, wp, 0);
cmdq_insert_hook(s, item, current, "after-select-pane"); cmdq_insert_hook(s, item, current, "after-select-pane");
cmd_select_pane_redraw(w); cmd_select_pane_redraw(w);

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-select-window.c,v 1.30 2021/08/21 10:22:39 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_select_window_entry = {
.name = "select-window", .name = "select-window",
.alias = "selectw", .alias = "selectw",
.args = { "lnpTt:", 0, 0 }, .args = { "lnpTt:", 0, 0, NULL },
.usage = "[-lnpT] " CMD_TARGET_WINDOW_USAGE, .usage = "[-lnpT] " CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
@@ -46,7 +46,7 @@ const struct cmd_entry cmd_next_window_entry = {
.name = "next-window", .name = "next-window",
.alias = "next", .alias = "next",
.args = { "at:", 0, 0 }, .args = { "at:", 0, 0, NULL },
.usage = "[-a] " CMD_TARGET_SESSION_USAGE, .usage = "[-a] " CMD_TARGET_SESSION_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 }, .target = { 't', CMD_FIND_SESSION, 0 },
@@ -59,7 +59,7 @@ const struct cmd_entry cmd_previous_window_entry = {
.name = "previous-window", .name = "previous-window",
.alias = "prev", .alias = "prev",
.args = { "at:", 0, 0 }, .args = { "at:", 0, 0, NULL },
.usage = "[-a] " CMD_TARGET_SESSION_USAGE, .usage = "[-a] " CMD_TARGET_SESSION_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 }, .target = { 't', CMD_FIND_SESSION, 0 },
@@ -72,7 +72,7 @@ const struct cmd_entry cmd_last_window_entry = {
.name = "last-window", .name = "last-window",
.alias = "last", .alias = "last",
.args = { "t:", 0, 0 }, .args = { "t:", 0, 0, NULL },
.usage = CMD_TARGET_SESSION_USAGE, .usage = CMD_TARGET_SESSION_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 }, .target = { 't', CMD_FIND_SESSION, 0 },

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-send-keys.c,v 1.81 2026/06/11 19:13:34 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,13 +33,14 @@ const struct cmd_entry cmd_send_keys_entry = {
.name = "send-keys", .name = "send-keys",
.alias = "send", .alias = "send",
.args = { "FHlMN:Rt:X", 0, -1 }, .args = { "c:FHKlMN:Rt:X", 0, -1, NULL },
.usage = "[-FHlMRX] [-N repeat-count] " CMD_TARGET_PANE_USAGE .usage = "[-FHKlMRX] [-c target-client] [-N repeat-count] "
" key ...", CMD_TARGET_PANE_USAGE " [key ...]",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK|CMD_CLIENT_CFLAG|CMD_CLIENT_CANFAIL|
CMD_READONLY,
.exec = cmd_send_keys_exec .exec = cmd_send_keys_exec
}; };
@@ -47,7 +48,7 @@ const struct cmd_entry cmd_send_prefix_entry = {
.name = "send-prefix", .name = "send-prefix",
.alias = NULL, .alias = NULL,
.args = { "2t:", 0, 0 }, .args = { "2t:", 0, 0, NULL },
.usage = "[-2] " CMD_TARGET_PANE_USAGE, .usage = "[-2] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -58,7 +59,7 @@ const struct cmd_entry cmd_send_prefix_entry = {
static struct cmdq_item * static struct cmdq_item *
cmd_send_keys_inject_key(struct cmdq_item *item, struct cmdq_item *after, cmd_send_keys_inject_key(struct cmdq_item *item, struct cmdq_item *after,
key_code key) struct args *args, key_code key)
{ {
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
@@ -66,8 +67,29 @@ cmd_send_keys_inject_key(struct cmdq_item *item, struct cmdq_item *after,
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
struct window_mode_entry *wme; struct window_mode_entry *wme;
struct key_table *table; struct key_table *table = NULL;
struct key_binding *bd; struct key_binding *bd;
struct key_event *event;
struct cmdq_item *new_after = after;
if (args_has(args, 'K')) {
if (tc == NULL)
return (item);
event = xcalloc(1, sizeof *event);
event->key = key|KEYC_SENT;
memset(&event->m, 0, sizeof event->m);
if (after == NULL) {
if (server_client_handle_key(tc, event) != 0)
return (item);
} else {
if (server_client_handle_key_after(tc, event, after,
&new_after) != 0)
return (new_after);
}
free(event->buf);
free(event);
return (item);
}
wme = TAILQ_FIRST(&wp->modes); wme = TAILQ_FIRST(&wp->modes);
if (wme == NULL || wme->mode->key_table == NULL) { if (wme == NULL || wme->mode->key_table == NULL) {
@@ -90,7 +112,7 @@ static struct cmdq_item *
cmd_send_keys_inject_string(struct cmdq_item *item, struct cmdq_item *after, cmd_send_keys_inject_string(struct cmdq_item *item, struct cmdq_item *after,
struct args *args, int i) struct args *args, int i)
{ {
const char *s = args->argv[i]; const char *s = args_string(args, i);
struct utf8_data *ud, *loop; struct utf8_data *ud, *loop;
utf8_char uc; utf8_char uc;
key_code key; key_code key;
@@ -102,14 +124,16 @@ cmd_send_keys_inject_string(struct cmdq_item *item, struct cmdq_item *after,
n = strtol(s, &endptr, 16); n = strtol(s, &endptr, 16);
if (*s =='\0' || n < 0 || n > 0xff || *endptr != '\0') if (*s =='\0' || n < 0 || n > 0xff || *endptr != '\0')
return (item); return (item);
return (cmd_send_keys_inject_key(item, after, KEYC_LITERAL|n)); return (cmd_send_keys_inject_key(item, after, args,
KEYC_LITERAL|n));
} }
literal = args_has(args, 'l'); literal = args_has(args, 'l');
if (!literal) { if (!literal) {
key = key_string_lookup_string(s); key = key_string_lookup_string(s);
if (key != KEYC_NONE && key != KEYC_UNKNOWN) { if (key != KEYC_NONE && key != KEYC_UNKNOWN) {
after = cmd_send_keys_inject_key(item, after, key); after = cmd_send_keys_inject_key(item, after, args,
key);
if (after != NULL) if (after != NULL)
return (after); return (after);
} }
@@ -125,7 +149,8 @@ cmd_send_keys_inject_string(struct cmdq_item *item, struct cmdq_item *after,
continue; continue;
key = uc; key = uc;
} }
after = cmd_send_keys_inject_key(item, after, key); after = cmd_send_keys_inject_key(item, after, args,
key);
} }
free(ud); free(ud);
} }
@@ -145,19 +170,25 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
struct mouse_event *m = &event->m; struct mouse_event *m = &event->m;
struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes); struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes);
struct cmdq_item *after = item; struct cmdq_item *after = item;
int i;
key_code key; key_code key;
u_int np = 1; u_int i, np = 1;
u_int count = args_count(args);
char *cause = NULL; char *cause = NULL;
if (tc != NULL && tc->flags & CLIENT_READONLY && !args_has(args, 'X')) {
cmdq_error(item, "client is read-only");
return (CMD_RETURN_ERROR);
}
if (args_has(args, 'N')) { if (args_has(args, 'N')) {
np = args_strtonum(args, 'N', 1, UINT_MAX, &cause); np = args_strtonum_and_expand(args, 'N', 1, UINT_MAX, item,
&cause);
if (cause != NULL) { if (cause != NULL) {
cmdq_error(item, "repeat count %s", cause); cmdq_error(item, "repeat count %s", cause);
free(cause); free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
if (wme != NULL && (args_has(args, 'X') || args->argc == 0)) { if (wme != NULL && (args_has(args, 'X') || count == 0)) {
if (wme->mode->command == NULL) { if (wme->mode->command == NULL) {
cmdq_error(item, "not in a mode"); cmdq_error(item, "not in a mode");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
@@ -192,17 +223,28 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
key = options_get_number(s->options, "prefix2"); key = options_get_number(s->options, "prefix2");
else else
key = options_get_number(s->options, "prefix"); key = options_get_number(s->options, "prefix");
cmd_send_keys_inject_key(item, item, key); cmd_send_keys_inject_key(item, item, args, key);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(args, 'R')) { if (args_has(args, 'R')) {
window_pane_reset_palette(wp); colour_palette_clear(&wp->palette);
input_reset(wp->ictx, 1); input_reset(wp->ictx, 1);
wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED|PANE_REDRAW);
}
if (count == 0) {
if (args_has(args, 'N') || args_has(args, 'R'))
return (CMD_RETURN_NORMAL);
after = args_has(args, 'K') ? item : NULL;
for (; np != 0; np--)
after = cmd_send_keys_inject_key(item, after, args,
event->key);
return (CMD_RETURN_NORMAL);
} }
for (; np != 0; np--) { for (; np != 0; np--) {
for (i = 0; i < args->argc; i++) { for (i = 0; i < count; i++) {
after = cmd_send_keys_inject_string(item, after, args, after = cmd_send_keys_inject_string(item, after, args,
i); i);
} }

152
cmd-server-access.c Normal file
View File

@@ -0,0 +1,152 @@
/* $OpenBSD: cmd-server-access.c,v 1.6 2026/06/09 12:58:40 nicm Exp $ */
/*
* Copyright (c) 2021 Dallas Lyons <dallasdlyons@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/stat.h>
#include <sys/types.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "tmux.h"
/*
* Controls access to session.
*/
static enum cmd_retval cmd_server_access_exec(struct cmd *, struct cmdq_item *);
const struct cmd_entry cmd_server_access_entry = {
.name = "server-access",
.alias = NULL,
.args = { "adglrw", 0, 1, NULL },
.usage = "[-adglrw] " CMD_TARGET_PANE_USAGE " [user|group]",
.flags = CMD_CLIENT_CANFAIL,
.exec = cmd_server_access_exec
};
static enum cmd_retval
cmd_server_access_deny(struct cmdq_item *item, id_t id, int flags,
const char *type, const char *name)
{
if (!server_acl_find(id, flags)) {
cmdq_error(item, "%s %s not found", type, name);
return (CMD_RETURN_ERROR);
}
server_acl_deny(id, flags);
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_server_access_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
struct client *c = cmdq_get_target_client(item);
char *arg;
const char *name = NULL, *type;
struct passwd *pw;
struct group *gr;
id_t id;
int flags = 0;
if (args_has(args, 'l')) {
server_acl_display(item);
return (CMD_RETURN_NORMAL);
}
if (args_count(args) == 0) {
cmdq_error(item, "missing user or group argument");
return (CMD_RETURN_ERROR);
}
arg = format_single(item, args_string(args, 0), c, NULL, NULL, NULL);
if (args_has(args, 'g')) {
type = "group";
if ((gr = getgrnam(arg)) != NULL) {
id = gr->gr_gid;
name = gr->gr_name;
flags |= SERVER_ACL_IS_GROUP;
}
} else {
type = "user";
if ((pw = getpwnam(arg)) != NULL) {
id = pw->pw_uid;
name = pw->pw_name;
}
}
if (name == NULL) {
cmdq_error(item, "unknown %s: %s", type, arg);
free(arg);
return (CMD_RETURN_ERROR);
}
free(arg);
if ((~flags & SERVER_ACL_IS_GROUP) && (id == 0 || id == getuid())) {
cmdq_error(item, "%s owns the server, can't change access",
name);
return (CMD_RETURN_ERROR);
}
if (args_has(args, 'a') && args_has(args, 'd')) {
cmdq_error(item, "-a and -d cannot be used together");
return (CMD_RETURN_ERROR);
}
if (args_has(args, 'w') && args_has(args, 'r')) {
cmdq_error(item, "-r and -w cannot be used together");
return (CMD_RETURN_ERROR);
}
if (args_has(args, 'd'))
return (cmd_server_access_deny(item, id, flags, type, name));
if (args_has(args, 'a')) {
if (server_acl_find(id, flags)) {
cmdq_error(item, "%s %s is already added", type, name);
return (CMD_RETURN_ERROR);
}
server_acl_allow(id, flags);
/* Do not return - allow -r or -w with -a. */
} else if (args_has(args, 'r') || args_has(args, 'w')) {
/* -r or -w implies -a if the entry does not exist. */
if (!server_acl_find(id, flags))
server_acl_allow(id, flags);
}
if (args_has(args, 'w')) {
if (!server_acl_find(id, flags)) {
cmdq_error(item, "%s %s not found", type, name);
return (CMD_RETURN_ERROR);
}
server_acl_allow_write(id, flags);
return (CMD_RETURN_NORMAL);
}
if (args_has(args, 'r')) {
if (!server_acl_find(id, flags)) {
cmdq_error(item, "%s %s not found", type, name);
return (CMD_RETURN_ERROR);
}
server_acl_deny_write(id, flags);
return (CMD_RETURN_NORMAL);
}
return (CMD_RETURN_NORMAL);
}

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-set-buffer.c,v 1.37 2026/02/15 17:43:26 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,9 +33,9 @@ const struct cmd_entry cmd_set_buffer_entry = {
.name = "set-buffer", .name = "set-buffer",
.alias = "setb", .alias = "setb",
.args = { "ab:t:n:w", 0, 1 }, .args = { "ab:t:n:w", 0, 1, NULL },
.usage = "[-aw] " CMD_BUFFER_USAGE " [-n new-buffer-name] " .usage = "[-aw] " CMD_BUFFER_USAGE " [-n new-buffer-name] "
CMD_TARGET_CLIENT_USAGE " data", CMD_TARGET_CLIENT_USAGE " [data]",
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG|CMD_CLIENT_CANFAIL, .flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG|CMD_CLIENT_CANFAIL,
.exec = cmd_set_buffer_exec .exec = cmd_set_buffer_exec
@@ -45,7 +45,7 @@ const struct cmd_entry cmd_delete_buffer_entry = {
.name = "delete-buffer", .name = "delete-buffer",
.alias = "deleteb", .alias = "deleteb",
.args = { "b:", 0, 0 }, .args = { "b:", 0, 0, NULL },
.usage = CMD_BUFFER_USAGE, .usage = CMD_BUFFER_USAGE,
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
@@ -57,53 +57,59 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct paste_buffer *pb; struct paste_buffer *pb = NULL;
char *bufdata, *cause; char *bufname = NULL, *bufdata = NULL, *cause = NULL;
const char *bufname, *olddata; const char *olddata;
size_t bufsize, newsize; size_t bufsize = 0, newsize;
bufname = args_get(args, 'b'); if (args_get(args, 'b') != NULL) {
if (bufname == NULL) bufname = xstrdup(args_get(args, 'b'));
pb = NULL;
else
pb = paste_get_name(bufname); pb = paste_get_name(bufname);
}
if (cmd_get_entry(self) == &cmd_delete_buffer_entry) { if (cmd_get_entry(self) == &cmd_delete_buffer_entry) {
if (pb == NULL) if (pb == NULL) {
if (bufname != NULL) {
cmdq_error(item, "unknown buffer: %s", bufname);
goto fail;
}
pb = paste_get_top(&bufname); pb = paste_get_top(&bufname);
}
if (pb == NULL) { if (pb == NULL) {
cmdq_error(item, "no buffer"); cmdq_error(item, "no buffer");
return (CMD_RETURN_ERROR); goto fail;
} }
paste_free(pb); paste_free(pb);
free(bufname);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(args, 'n')) { if (args_has(args, 'n')) {
if (pb == NULL) if (pb == NULL) {
if (bufname != NULL) {
cmdq_error(item, "unknown buffer: %s", bufname);
goto fail;
}
pb = paste_get_top(&bufname); pb = paste_get_top(&bufname);
}
if (pb == NULL) { if (pb == NULL) {
cmdq_error(item, "no buffer"); cmdq_error(item, "no buffer");
return (CMD_RETURN_ERROR); goto fail;
} }
if (paste_rename(bufname, args_get(args, 'n'), &cause) != 0) { if (paste_rename(bufname, args_get(args, 'n'), &cause) != 0) {
cmdq_error(item, "%s", cause); cmdq_error(item, "%s", cause);
free(cause); goto fail;
return (CMD_RETURN_ERROR);
} }
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args->argc != 1) { if (args_count(args) != 1) {
cmdq_error(item, "no data specified"); cmdq_error(item, "no data specified");
return (CMD_RETURN_ERROR); goto fail;
} }
if ((newsize = strlen(args->argv[0])) == 0) if ((newsize = strlen(args_string(args, 0))) == 0)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
bufsize = 0;
bufdata = NULL;
if (args_has(args, 'a') && pb != NULL) { if (args_has(args, 'a') && pb != NULL) {
olddata = paste_buffer_data(pb, &bufsize); olddata = paste_buffer_data(pb, &bufsize);
bufdata = xmalloc(bufsize); bufdata = xmalloc(bufsize);
@@ -111,17 +117,21 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
} }
bufdata = xrealloc(bufdata, bufsize + newsize); bufdata = xrealloc(bufdata, bufsize + newsize);
memcpy(bufdata + bufsize, args->argv[0], newsize); memcpy(bufdata + bufsize, args_string(args, 0), newsize);
bufsize += newsize; bufsize += newsize;
if (paste_set(bufdata, bufsize, bufname, &cause) != 0) { if (paste_set(bufdata, bufsize, bufname, &cause) != 0) {
cmdq_error(item, "%s", cause); cmdq_error(item, "%s", cause);
free(bufdata); goto fail;
free(cause);
return (CMD_RETURN_ERROR);
} }
if (args_has(args, 'w') && tc != NULL) if (args_has(args, 'w') && tc != NULL)
tty_set_selection(&tc->tty, bufdata, bufsize); tty_set_selection(&tc->tty, "", bufdata, bufsize);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
fail:
free(bufdata);
free(bufname);
free(cause);
return (CMD_RETURN_ERROR);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-set-environment.c,v 1.29 2025/04/09 06:27:43 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -34,8 +34,8 @@ const struct cmd_entry cmd_set_environment_entry = {
.name = "set-environment", .name = "set-environment",
.alias = "setenv", .alias = "setenv",
.args = { "Fhgrt:u", 1, 2 }, .args = { "Fhgrt:u", 1, 2, NULL },
.usage = "[-Fhgru] " CMD_TARGET_SESSION_USAGE " name [value]", .usage = "[-Fhgru] " CMD_TARGET_SESSION_USAGE " variable [value]",
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
@@ -49,11 +49,11 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct environ *env; struct environ *env;
const char *name, *value, *tflag; const char *name = args_string(args, 0), *value;
char *expand = NULL; const char *tflag;
char *expanded = NULL;
enum cmd_retval retval = CMD_RETURN_NORMAL; enum cmd_retval retval = CMD_RETURN_NORMAL;
name = args->argv[0];
if (*name == '\0') { if (*name == '\0') {
cmdq_error(item, "empty variable name"); cmdq_error(item, "empty variable name");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
@@ -63,13 +63,14 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
if (args->argc < 2) if (args_count(args) < 2)
value = NULL; value = NULL;
else if (args_has(args, 'F'))
value = expand = format_single_from_target(item, args->argv[1]);
else else
value = args->argv[1]; value = args_string(args, 1);
if (value != NULL && args_has(args, 'F')) {
expanded = format_single_from_target(item, value);
value = expanded;
}
if (args_has(args, 'g')) if (args_has(args, 'g'))
env = global_environ; env = global_environ;
else { else {
@@ -113,6 +114,6 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
} }
out: out:
free(expand); free(expanded);
return (retval); return (retval);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-set-option.c,v 1.146 2026/07/10 15:20:06 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -27,13 +27,20 @@
* Set an option. * Set an option.
*/ */
static enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmdq_item *); static enum args_parse_type cmd_set_option_args_parse(struct args *,
u_int, char **);
static enum cmd_retval cmd_set_option_exec(struct cmd *,
struct cmdq_item *);
static enum cmd_retval cmd_set_hook_event_exec(struct cmd *,
struct cmdq_item *);
static enum cmd_retval cmd_set_hook_monitor_exec(struct cmdq_item *,
struct args *, int);
const struct cmd_entry cmd_set_option_entry = { const struct cmd_entry cmd_set_option_entry = {
.name = "set-option", .name = "set-option",
.alias = "set", .alias = "set",
.args = { "aFgopqst:uUw", 1, 2 }, .args = { "aFgopqst:uUw", 1, 2, cmd_set_option_args_parse },
.usage = "[-aFgopqsuUw] " CMD_TARGET_PANE_USAGE " option [value]", .usage = "[-aFgopqsuUw] " CMD_TARGET_PANE_USAGE " option [value]",
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
@@ -46,7 +53,7 @@ const struct cmd_entry cmd_set_window_option_entry = {
.name = "set-window-option", .name = "set-window-option",
.alias = "setw", .alias = "setw",
.args = { "aFgoqt:u", 1, 2 }, .args = { "aFgoqt:u", 1, 2, cmd_set_option_args_parse },
.usage = "[-aFgoqu] " CMD_TARGET_WINDOW_USAGE " option [value]", .usage = "[-aFgoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
@@ -59,8 +66,9 @@ const struct cmd_entry cmd_set_hook_entry = {
.name = "set-hook", .name = "set-hook",
.alias = NULL, .alias = NULL,
.args = { "agpRt:uw", 1, 2 }, .args = { "agpERTt:uB:w", 0, 2, cmd_set_option_args_parse },
.usage = "[-agpRuw] " CMD_TARGET_PANE_USAGE " hook [command]", .usage = "[-agpERTuw] [-B name:what:format] " CMD_TARGET_PANE_USAGE " "
"[hook] [command]",
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
@@ -68,6 +76,153 @@ const struct cmd_entry cmd_set_hook_entry = {
.exec = cmd_set_option_exec .exec = cmd_set_option_exec
}; };
static enum args_parse_type
cmd_set_option_args_parse(struct args *args, u_int idx,
__unused char **cause)
{
if (args_has(args, 'B'))
return (ARGS_PARSE_COMMANDS_OR_STRING);
if (idx == 1)
return (ARGS_PARSE_COMMANDS_OR_STRING);
return (ARGS_PARSE_STRING);
}
static enum cmd_retval
cmd_set_hook_event_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct event_payload *ep;
struct client *c;
char *argument;
if (args_count(args) == 0) {
cmdq_error(item, "missing argument");
return (CMD_RETURN_ERROR);
}
if (args_count(args) != 1) {
cmdq_error(item, "too many arguments");
return (CMD_RETURN_ERROR);
}
argument = format_single_from_target(item, args_string(args, 0));
if (*argument != '@') {
cmdq_error(item, "event name must start with @");
free(argument);
return (CMD_RETURN_ERROR);
}
ep = event_payload_create();
event_payload_set_target(ep, target);
c = cmdq_get_client(item);
if (c != NULL)
event_payload_set_client(ep, "client", c);
if (target->s != NULL)
event_payload_set_session(ep, "session", target->s);
if (target->w != NULL)
event_payload_set_window(ep, "window", target->w);
if (target->wl != NULL)
event_payload_set_int(ep, "window_index", target->wl->idx);
else if (target->idx != -1)
event_payload_set_int(ep, "window_index", target->idx);
if (target->wp != NULL)
event_payload_set_pane(ep, "pane", target->wp);
events_fire(argument, ep);
free(argument);
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_set_hook_monitor_exec(struct cmdq_item *item, struct args *args, int window)
{
struct cmd_find_state *target = cmdq_get_target(item), fs;
struct options *oo;
struct options_entry *o;
struct session *s = NULL;
char *cause = NULL, *name = NULL, *format = NULL;
char *expanded = NULL, *newvalue = NULL;
const char *value, *old;
enum monitor_type type;
int id, scope, flags = 0;
if (args_count(args) > 1) {
cmdq_error(item, "too many arguments");
return (CMD_RETURN_ERROR);
}
value = args_get(args, 'B');
if (args_has(args, 'u')) {
if (monitor_parse(value, &name, &type, &id, &format) != 0)
name = xstrdup(value);
free(format);
format = NULL;
} else {
if (monitor_parse(value, &name, &type, &id, &format) != 0) {
cmdq_error(item, "invalid subscription: %s", value);
return (CMD_RETURN_ERROR);
}
}
if (*name != '@') {
cmdq_error(item, "monitor hook name must start with @");
goto fail;
}
scope = options_scope_from_name(args, window, name, target, &oo,
&cause);
if (scope == OPTIONS_TABLE_NONE) {
cmdq_error(item, "%s", cause);
free(cause);
goto fail;
}
cmd_find_copy_state(&fs, target);
if (args_has(args, 'u')) {
hooks_monitor_remove(oo, name);
goto out;
}
if (args_count(args) != 0) {
value = args_string(args, 0);
if (args_has(args, 'F')) {
expanded = format_single_from_target(item, value);
value = expanded;
}
o = options_get_only(oo, name);
if (!args_has(args, 'o') || o == NULL) {
if (args_has(args, 'a') && o != NULL) {
old = options_get_string(oo, name);
xasprintf(&newvalue, "%s%s", old, value);
value = newvalue;
}
options_set_string(oo, name, 0, "%s", value);
options_push_changes(name);
}
}
if (oo != global_options &&
oo != global_s_options &&
oo != global_w_options)
s = target->s;
if (args_has(args, 'T'))
flags |= MONITOR_NOTIFY_TRUE;
hooks_monitor_add(item, oo, name, type, id, format, flags, &fs, s);
out:
free(newvalue);
free(expanded);
free(name);
free(format);
return (CMD_RETURN_NORMAL);
fail:
free(newvalue);
free(expanded);
free(name);
free(format);
return (CMD_RETURN_ERROR);
}
static enum cmd_retval static enum cmd_retval
cmd_set_option_exec(struct cmd *self, struct cmdq_item *item) cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
{ {
@@ -77,24 +232,34 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
struct window_pane *loop; struct window_pane *loop;
struct options *oo; struct options *oo;
struct options_entry *parent, *o, *po; struct options_entry *parent, *o, *po;
char *name, *argument, *value = NULL, *cause; char *name, *argument, *cause;
int window, idx, already, error, ambiguous; char *expanded = NULL, *array_key = NULL;
const char *value;
int window, already, error, ambiguous;
int scope; int scope;
window = (cmd_get_entry(self) == &cmd_set_window_option_entry); window = (cmd_get_entry(self) == &cmd_set_window_option_entry);
if (cmd_get_entry(self) == &cmd_set_hook_entry && args_has(args, 'E'))
return (cmd_set_hook_event_exec(self, item));
if (cmd_get_entry(self) == &cmd_set_hook_entry && args_has(args, 'B'))
return (cmd_set_hook_monitor_exec(item, args, window));
if (args_count(args) == 0) {
cmdq_error(item, "missing argument");
return (CMD_RETURN_ERROR);
}
/* Expand argument. */ /* Expand argument. */
argument = format_single_from_target(item, args->argv[0]); argument = format_single_from_target(item, args_string(args, 0));
/* If set-hook -R, fire the hook straight away. */ /* If set-hook -R, fire the hook straight away. */
if (cmd_get_entry(self) == &cmd_set_hook_entry && args_has(args, 'R')) { if (cmd_get_entry(self) == &cmd_set_hook_entry && args_has(args, 'R')) {
notify_hook(item, argument); hooks_run(item, argument);
free(argument); free(argument);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
/* Parse option name and index. */ /* Parse option name and array key. */
name = options_match(argument, &idx, &ambiguous); name = options_match(argument, &array_key, &ambiguous);
if (name == NULL) { if (name == NULL) {
if (args_has(args, 'q')) if (args_has(args, 'q'))
goto out; goto out;
@@ -104,12 +269,14 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "invalid option: %s", argument); cmdq_error(item, "invalid option: %s", argument);
goto fail; goto fail;
} }
if (args->argc < 2) if (args_count(args) < 2)
value = NULL; value = NULL;
else if (args_has(args, 'F'))
value = format_single_from_target(item, args->argv[1]);
else else
value = xstrdup(args->argv[1]); value = args_string(args, 1);
if (value != NULL && args_has(args, 'F')) {
expanded = format_single_from_target(item, value);
value = expanded;
}
/* Get the scope and table for the option .*/ /* Get the scope and table for the option .*/
scope = options_scope_from_name(args, window, name, target, &oo, scope = options_scope_from_name(args, window, name, target, &oo,
@@ -124,21 +291,23 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
o = options_get_only(oo, name); o = options_get_only(oo, name);
parent = options_get(oo, name); parent = options_get(oo, name);
/* Check that array options and indexes match up. */ /* Check that array options and keys match up. */
if (idx != -1 && (*name == '@' || !options_is_array(parent))) { if (array_key != NULL && (*name == '@' || !options_is_array(parent))) {
cmdq_error(item, "not an array: %s", argument); cmdq_error(item, "not an array: %s", argument);
goto fail; goto fail;
} }
/* With -o, check this option is not already set. */ /* With -o, check this option is not already set. */
if (!args_has(args, 'u') && args_has(args, 'o')) { if (!args_has(args, 'u') && args_has(args, 'o')) {
if (idx == -1) if (array_key == NULL)
already = (o != NULL); already = (o != NULL);
else { else {
if (o == NULL) if (o == NULL)
already = 0; already = 0;
else if (options_array_get(o, array_key) != NULL)
already = 1;
else else
already = (options_array_get(o, idx) != NULL); already = 0;
} }
if (already) { if (already) {
if (args_has(args, 'q')) if (args_has(args, 'q'))
@@ -154,7 +323,8 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
po = options_get_only(loop->options, name); po = options_get_only(loop->options, name);
if (po == NULL) if (po == NULL)
continue; continue;
if (options_remove_or_default(po, idx, &cause) != 0) { if (options_remove_or_default(po, array_key,
&cause) != 0) {
cmdq_error(item, "%s", cause); cmdq_error(item, "%s", cause);
free(cause); free(cause);
goto fail; goto fail;
@@ -164,7 +334,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
if (args_has(args, 'u') || args_has(args, 'U')) { if (args_has(args, 'u') || args_has(args, 'U')) {
if (o == NULL) if (o == NULL)
goto out; goto out;
if (options_remove_or_default(o, idx, &cause) != 0) { if (options_remove_or_default(o, array_key, &cause) != 0) {
cmdq_error(item, "%s", cause); cmdq_error(item, "%s", cause);
free(cause); free(cause);
goto fail; goto fail;
@@ -175,7 +345,9 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
goto fail; goto fail;
} }
options_set_string(oo, name, append, "%s", value); options_set_string(oo, name, append, "%s", value);
} else if (idx == -1 && !options_is_array(parent)) { if (cmd_get_entry(self) == &cmd_set_hook_entry)
hooks_add_event(name);
} else if (array_key == NULL && !options_is_array(parent)) {
error = options_from_string(oo, options_table_entry(parent), error = options_from_string(oo, options_table_entry(parent),
options_table_entry(parent)->name, value, options_table_entry(parent)->name, value,
args_has(args, 'a'), &cause); args_has(args, 'a'), &cause);
@@ -191,7 +363,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
} }
if (o == NULL) if (o == NULL)
o = options_empty(oo, options_table_entry(parent)); o = options_empty(oo, options_table_entry(parent));
if (idx == -1) { if (array_key == NULL) {
if (!append) if (!append)
options_array_clear(o); options_array_clear(o);
if (options_array_assign(o, value, &cause) != 0) { if (options_array_assign(o, value, &cause) != 0) {
@@ -199,7 +371,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
free(cause); free(cause);
goto fail; goto fail;
} }
} else if (options_array_set(o, idx, value, append, } else if (options_array_set(o, array_key, value, append,
&cause) != 0) { &cause) != 0) {
cmdq_error(item, "%s", cause); cmdq_error(item, "%s", cause);
free(cause); free(cause);
@@ -211,13 +383,15 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
out: out:
free(argument); free(argument);
free(value); free(expanded);
free(name); free(name);
free(array_key);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
fail: fail:
free(argument); free(argument);
free(value); free(expanded);
free(name); free(name);
free(array_key);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-show-environment.c,v 1.29 2025/04/09 06:27:43 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -38,8 +38,8 @@ const struct cmd_entry cmd_show_environment_entry = {
.name = "show-environment", .name = "show-environment",
.alias = "showenv", .alias = "showenv",
.args = { "hgst:", 0, 1 }, .args = { "hgst:", 0, 1, NULL },
.usage = "[-hgs] " CMD_TARGET_SESSION_USAGE " [name]", .usage = "[-hgs] " CMD_TARGET_SESSION_USAGE " [variable]",
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
@@ -101,7 +101,7 @@ cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct environ *env; struct environ *env;
struct environ_entry *envent; struct environ_entry *envent;
const char *tflag; const char *tflag, *name = args_string(args, 0);
if ((tflag = args_get(args, 't')) != NULL) { if ((tflag = args_get(args, 't')) != NULL) {
if (target->s == NULL) { if (target->s == NULL) {
@@ -124,10 +124,10 @@ cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
env = target->s->environ; env = target->s->environ;
} }
if (args->argc != 0) { if (name != NULL) {
envent = environ_find(env, args->argv[0]); envent = environ_find(env, name);
if (envent == NULL) { if (envent == NULL) {
cmdq_error(item, "unknown variable: %s", args->argv[0]); cmdq_error(item, "unknown variable: %s", name);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
cmd_show_environment_print(self, item, envent); cmd_show_environment_print(self, item, envent);

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-show-messages.c,v 1.37 2025/11/18 08:37:54 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -38,10 +38,10 @@ const struct cmd_entry cmd_show_messages_entry = {
.name = "show-messages", .name = "show-messages",
.alias = "showmsgs", .alias = "showmsgs",
.args = { "JTt:", 0, 0 }, .args = { "JTt:", 0, 0, NULL },
.usage = "[-JT] " CMD_TARGET_CLIENT_USAGE, .usage = "[-JT] " CMD_TARGET_CLIENT_USAGE,
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG, .flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG|CMD_CLIENT_CANFAIL,
.exec = cmd_show_messages_exec .exec = cmd_show_messages_exec
}; };
@@ -55,7 +55,7 @@ cmd_show_messages_terminals(struct cmd *self, struct cmdq_item *item, int blank)
n = 0; n = 0;
LIST_FOREACH(term, &tty_terms, entry) { LIST_FOREACH(term, &tty_terms, entry) {
if (args_has(args, 't') && term != tc->tty.term) if (args_has(args, 't') && tc != NULL && term != tc->tty.term)
continue; continue;
if (blank) { if (blank) {
cmdq_print(item, "%s", ""); cmdq_print(item, "%s", "");

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-show-options.c,v 1.76 2026/07/27 19:15:58 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -27,10 +27,23 @@
* Show options. * Show options.
*/ */
#define SHOW_OPTIONS_TEMPLATE \
"#{?option_value_only," \
"#{option_value}," \
"#{option_name}#{?option_has_array_key," \
"[#{option_array_key}],}" \
"#{?option_is_parent,*,}" \
"#{?option_has_value, " \
"#{?option_is_string,#{q/a:option_value},#{option_value}},}}"
#define SHOW_HOOKS_MONITOR_TEMPLATE \
"#{option_name}:#{hook_monitor_target}:#{hook_monitor_format}"
static enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmdq_item *); static enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmdq_item *);
static void cmd_show_options_print(struct cmd *, struct cmdq_item *, static void cmd_show_options_print(struct cmd *, struct cmdq_item *,
struct options_entry *, int, int); struct options_entry *, const char *, int);
static void cmd_show_hooks_print_monitor(struct cmd *,
struct cmdq_item *, struct options_entry *);
static enum cmd_retval cmd_show_options_all(struct cmd *, struct cmdq_item *, static enum cmd_retval cmd_show_options_all(struct cmd *, struct cmdq_item *,
int, struct options *); int, struct options *);
@@ -38,8 +51,8 @@ const struct cmd_entry cmd_show_options_entry = {
.name = "show-options", .name = "show-options",
.alias = "show", .alias = "show",
.args = { "AgHpqst:vw", 0, 1 }, .args = { "AgF:Hpqst:vw", 0, 1, NULL },
.usage = "[-AgHpqsvw] " CMD_TARGET_PANE_USAGE " [option]", .usage = "[-AgHpqsvw] [-F format] " CMD_TARGET_PANE_USAGE " [option]",
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
@@ -51,8 +64,8 @@ const struct cmd_entry cmd_show_window_options_entry = {
.name = "show-window-options", .name = "show-window-options",
.alias = "showw", .alias = "showw",
.args = { "gvt:", 0, 1 }, .args = { "F:gvt:", 0, 1, NULL },
.usage = "[-gv] " CMD_TARGET_WINDOW_USAGE " [option]", .usage = "[-gv] [-F format] " CMD_TARGET_WINDOW_USAGE " [option]",
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
@@ -64,8 +77,8 @@ const struct cmd_entry cmd_show_hooks_entry = {
.name = "show-hooks", .name = "show-hooks",
.alias = NULL, .alias = NULL,
.args = { "gpt:w", 0, 1 }, .args = { "BF:gpt:w", 0, 1, NULL },
.usage = "[-gpw] " CMD_TARGET_PANE_USAGE, .usage = "[-Bgpw] [-F format] " CMD_TARGET_PANE_USAGE " [hook]",
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
@@ -80,12 +93,13 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct options *oo; struct options *oo;
char *argument, *name = NULL, *cause; char *argument, *name = NULL, *cause;
int window, idx, ambiguous, parent, scope; char *array_key = NULL;
int window, ambiguous, parent, print_parent, scope;
struct options_entry *o; struct options_entry *o;
window = (cmd_get_entry(self) == &cmd_show_window_options_entry); window = (cmd_get_entry(self) == &cmd_show_window_options_entry);
if (args->argc == 0) { if (args_count(args) == 0) {
scope = options_scope_from_flags(args, window, target, &oo, scope = options_scope_from_flags(args, window, target, &oo,
&cause); &cause);
if (scope == OPTIONS_TABLE_NONE) { if (scope == OPTIONS_TABLE_NONE) {
@@ -95,14 +109,23 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
free(cause); free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
if (cmd_get_entry(self) == &cmd_show_hooks_entry &&
args_has(args, 'B')) {
o = options_first(oo);
while (o != NULL) {
cmd_show_hooks_print_monitor(self, item, o);
o = options_next(o);
}
return (CMD_RETURN_NORMAL);
}
return (cmd_show_options_all(self, item, scope, oo)); return (cmd_show_options_all(self, item, scope, oo));
} }
argument = format_single_from_target(item, args->argv[0]); argument = format_single_from_target(item, args_string(args, 0));
name = options_match(argument, &idx, &ambiguous); name = options_match(argument, &array_key, &ambiguous);
if (name == NULL) { if (name == NULL) {
if (args_has(args, 'q')) if (args_has(args, 'q'))
goto fail; goto out;
if (ambiguous) if (ambiguous)
cmdq_error(item, "ambiguous option: %s", argument); cmdq_error(item, "ambiguous option: %s", argument);
else else
@@ -113,7 +136,7 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
&cause); &cause);
if (scope == OPTIONS_TABLE_NONE) { if (scope == OPTIONS_TABLE_NONE) {
if (args_has(args, 'q')) if (args_has(args, 'q'))
goto fail; goto out;
cmdq_error(item, "%s", cause); cmdq_error(item, "%s", cause);
free(cause); free(cause);
goto fail; goto fail;
@@ -124,68 +147,193 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
parent = 1; parent = 1;
} else } else
parent = 0; parent = 0;
if (o != NULL) if (o != NULL) {
cmd_show_options_print(self, item, o, idx, parent); if (cmd_get_entry(self) == &cmd_show_hooks_entry &&
args_has(args, 'B'))
cmd_show_hooks_print_monitor(self, item, o);
else {
print_parent = parent;
if (array_key == NULL && options_is_array(o) &&
options_array_first(o) == NULL) {
print_parent = 0;
}
cmd_show_options_print(self, item, o, array_key,
print_parent);
}
} else if (*name == '@') {
if (args_has(args, 'q'))
goto out;
cmdq_error(item, "invalid option: %s", argument);
goto fail;
}
out:
free(name); free(name);
free(array_key);
free(argument); free(argument);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
fail: fail:
free(name); free(name);
free(array_key);
free(argument); free(argument);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
static void static void
cmd_show_options_print(struct cmd *self, struct cmdq_item *item, cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
struct options_entry *o, int idx, int parent) struct options_entry *o, const char *array_key, int parent)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct options_array_item *a; struct options_array_item *a;
const char *name = options_name(o); struct format_tree *ft;
char *value, *tmp = NULL, *escaped; const char *name = options_name(o);
const char *template = args_get(args, 'F');
char *value, *line;
struct timeval tv = { 0 };
u_int fire_count;
time_t fire_time;
int is_hook = 0, is_user = 0;
int has_value = 1;
const struct options_table_entry *oe = options_table_entry(o);
if (idx != -1) { if (array_key != NULL)
xasprintf(&tmp, "%s[%d]", name, idx); value = options_to_string(o, array_key, 0);
name = tmp; else if (options_is_array(o)) {
} else { a = options_array_first(o);
if (options_is_array(o)) { if (a != NULL) {
a = options_array_first(o);
if (a == NULL) {
if (!args_has(args, 'v'))
cmdq_print(item, "%s", name);
return;
}
while (a != NULL) { while (a != NULL) {
idx = options_array_item_index(a); array_key = options_array_item_key(a);
cmd_show_options_print(self, item, o, idx, cmd_show_options_print(self, item, o, array_key,
parent); parent);
a = options_array_next(a); a = options_array_next(a);
} }
return; return;
} }
} if (template == NULL && args_has(args, 'v'))
return;
value = xstrdup("");
has_value = 0;
} else
value = options_to_string(o, NULL, 0);
value = options_to_string(o, idx, 0); if (template == NULL)
if (args_has(args, 'v')) template = SHOW_OPTIONS_TEMPLATE;
cmdq_print(item, "%s", value);
else if (options_is_string(o)) { if (oe != NULL && (oe->flags & OPTIONS_TABLE_IS_HOOK))
escaped = args_escape(value); is_hook = 1;
if (parent) else if (oe == NULL)
cmdq_print(item, "%s* %s", name, escaped); is_user = 1;
else
cmdq_print(item, "%s %s", name, escaped); ft = format_create_from_target(item);
free(escaped); format_add(ft, "option_name", "%s", name);
format_add(ft, "option_value", "%s", value);
format_add(ft, "option_value_only", "%d", args_has(args, 'v'));
format_add(ft, "option_is_parent", "%d", parent);
format_add(ft, "option_is_array", "%d", options_is_array(o));
format_add(ft, "option_is_string", "%d", options_is_string(o));
format_add(ft, "option_is_hook", "%d", is_hook);
format_add(ft, "option_is_user", "%d", is_user);
format_add(ft, "option_has_value", "%d", has_value);
if (cmd_get_entry(self) == &cmd_show_hooks_entry) {
fire_count = options_get_fire_count(o);
format_add(ft, "hook_fire_count", "%u", fire_count);
fire_time = options_get_fire_time(o);
if (fire_time != 0) {
tv.tv_sec = fire_time;
format_add_tv(ft, "hook_fire_time", &tv);
}
}
if (array_key != NULL) {
format_add(ft, "option_array_key", "%s", array_key);
format_add(ft, "option_has_array_key", "1");
} else { } else {
if (parent) format_add(ft, "option_array_key", "%s", "");
cmdq_print(item, "%s* %s", name, value); format_add(ft, "option_has_array_key", "0");
else
cmdq_print(item, "%s %s", name, value);
} }
free(value); line = format_expand(ft, template);
format_free(ft);
free(tmp); cmdq_print(item, "%s", line);
free(line);
free(value);
}
static void
cmd_show_hooks_print_monitor(struct cmd *self, struct cmdq_item *item,
struct options_entry *o)
{
struct args *args = cmd_get_args(self);
struct format_tree *ft;
enum monitor_type type;
const char *template = args_get(args, 'F'), *format;
char *value, *target, *line;
struct timeval tv = { 0 };
u_int fire_count;
time_t fire_time;
int id;
value = hooks_monitor_to_string(o);
if (value == NULL)
return;
if (!hooks_monitor_get(o, &type, &id, &format)) {
free(value);
return;
}
if (template == NULL)
template = SHOW_HOOKS_MONITOR_TEMPLATE;
switch (type) {
case MONITOR_SESSION:
target = xstrdup("");
break;
case MONITOR_PANE:
xasprintf(&target, "%%%d", id);
break;
case MONITOR_ALL_PANES:
target = xstrdup("%*");
break;
case MONITOR_WINDOW:
xasprintf(&target, "@%d", id);
break;
case MONITOR_ALL_WINDOWS:
target = xstrdup("@*");
break;
}
ft = format_create_from_target(item);
format_add(ft, "option_name", "%s", options_name(o));
format_add(ft, "option_value", "%s", value);
format_add(ft, "option_value_only", "%d", 0);
format_add(ft, "option_is_parent", "%d", 0);
format_add(ft, "option_is_array", "%d", 0);
format_add(ft, "option_is_string", "%d", 1);
format_add(ft, "option_is_hook", "%d", 1);
format_add(ft, "option_is_user", "%d", 1);
format_add(ft, "option_has_value", "%d", 1);
format_add(ft, "option_array_key", "%s", "");
format_add(ft, "option_has_array_key", "0");
format_add(ft, "hook_monitor_target", "%s", target);
format_add(ft, "hook_monitor_format", "%s", format);
fire_count = hooks_monitor_get_fire_count(o);
format_add(ft, "hook_fire_count", "%u", fire_count);
fire_time = hooks_monitor_get_fire_time(o);
if (fire_time != 0) {
tv.tv_sec = fire_time;
format_add_tv(ft, "hook_fire_time", &tv);
}
line = format_expand(ft, template);
format_free(ft);
cmdq_print(item, "%s", line);
free(line);
free(target);
free(value);
} }
static enum cmd_retval static enum cmd_retval
@@ -195,18 +343,29 @@ cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope,
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
const struct options_table_entry *oe; const struct options_table_entry *oe;
struct options_entry *o; struct options_entry *o;
struct options_array_item *a;
const char *name; const char *name;
u_int idx; int parent, is_user_hook;
int parent;
if (cmd_get_entry(self) != &cmd_show_hooks_entry) { o = options_first(oo);
o = options_first(oo); while (o != NULL) {
while (o != NULL) { if (options_table_entry(o) == NULL) {
if (options_table_entry(o) == NULL) name = options_name(o);
cmd_show_options_print(self, item, o, -1, 0); is_user_hook = 0;
o = options_next(o); if (*name == '@') {
if (hooks_is_event(name) ||
options_get_monitor_data(o) != NULL) {
is_user_hook = 1;
}
}
if (cmd_get_entry(self) != &cmd_show_hooks_entry) {
if (!is_user_hook || args_has(args, 'H')) {
cmd_show_options_print(self, item, o,
NULL, 0);
}
} else if (is_user_hook)
cmd_show_options_print(self, item, o, NULL, 0);
} }
o = options_next(o);
} }
for (oe = options_table; oe->name != NULL; oe++) { for (oe = options_table; oe->name != NULL; oe++) {
if (~oe->scope & scope) if (~oe->scope & scope)
@@ -230,24 +389,7 @@ cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope,
} else } else
parent = 0; parent = 0;
if (!options_is_array(o)) cmd_show_options_print(self, item, o, NULL, parent);
cmd_show_options_print(self, item, o, -1, parent);
else if ((a = options_array_first(o)) == NULL) {
if (!args_has(args, 'v')) {
name = options_name(o);
if (parent)
cmdq_print(item, "%s*", name);
else
cmdq_print(item, "%s", name);
}
} else {
while (a != NULL) {
idx = options_array_item_index(a);
cmd_show_options_print(self, item, o, idx,
parent);
a = options_array_next(a);
}
}
} }
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

101
cmd-show-prompt-history.c Normal file
View File

@@ -0,0 +1,101 @@
/* $OpenBSD: cmd-show-prompt-history.c,v 1.5 2026/06/25 11:39:11 nicm Exp $ */
/*
* Copyright (c) 2021 Anindya Mukherjee <anindya49@hotmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "tmux.h"
#include <stdlib.h>
/*
* Show or clear prompt history.
*/
static enum cmd_retval cmd_show_prompt_history_exec(struct cmd *,
struct cmdq_item *);
const struct cmd_entry cmd_show_prompt_history_entry = {
.name = "show-prompt-history",
.alias = "showphist",
.args = { "T:", 0, 0, NULL },
.usage = "[-T prompt-type]",
.flags = CMD_AFTERHOOK,
.exec = cmd_show_prompt_history_exec
};
const struct cmd_entry cmd_clear_prompt_history_entry = {
.name = "clear-prompt-history",
.alias = "clearphist",
.args = { "T:", 0, 0, NULL },
.usage = "[-T prompt-type]",
.flags = CMD_AFTERHOOK,
.exec = cmd_show_prompt_history_exec
};
static enum cmd_retval
cmd_show_prompt_history_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
const char *typestr = args_get(args, 'T');
enum prompt_type type;
u_int t, h;
const char *v;
if (cmd_get_entry(self) == &cmd_clear_prompt_history_entry) {
if (typestr == NULL) {
for (t = 0; t < PROMPT_NTYPES; t++)
prompt_history_clear(t);
} else {
type = prompt_type(typestr);
if (type == PROMPT_TYPE_INVALID) {
cmdq_error(item, "invalid type: %s", typestr);
return (CMD_RETURN_ERROR);
}
prompt_history_clear(type);
}
return (CMD_RETURN_NORMAL);
}
if (typestr == NULL) {
for (t = 0; t < PROMPT_NTYPES; t++) {
typestr = prompt_type_string(t);
cmdq_print(item, "History for %s:\n", typestr);
for (h = 0; h < prompt_history_size(t); h++) {
v = prompt_history_get(t, h);
cmdq_print(item, "%d: %s", h + 1, v);
}
cmdq_print(item, "%s", "");
}
} else {
type = prompt_type(typestr);
if (type == PROMPT_TYPE_INVALID) {
cmdq_error(item, "invalid type: %s", typestr);
return (CMD_RETURN_ERROR);
}
cmdq_print(item, "History for %s:\n", prompt_type_string(type));
for (h = 0; h < prompt_history_size(type); h++) {
v = prompt_history_get(type, h);
cmdq_print(item, "%d: %s", h + 1, v);
}
cmdq_print(item, "%s", "");
}
return (CMD_RETURN_NORMAL);
}

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-source-file.c,v 1.62 2025/11/18 08:42:09 nicm Exp $ */
/* /*
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org> * Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
@@ -18,6 +18,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <ctype.h>
#include <errno.h> #include <errno.h>
#include <glob.h> #include <glob.h>
#include <stdlib.h> #include <stdlib.h>
@@ -29,14 +30,19 @@
* Sources a configuration file. * Sources a configuration file.
*/ */
#define CMD_SOURCE_FILE_DEPTH_LIMIT 50
static u_int cmd_source_file_depth;
static enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmdq_item *); static enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmdq_item *);
const struct cmd_entry cmd_source_file_entry = { const struct cmd_entry cmd_source_file_entry = {
.name = "source-file", .name = "source-file",
.alias = "source", .alias = "source",
.args = { "Fnqv", 1, -1 }, .args = { "t:Fnqv", 1, -1, NULL },
.usage = "[-Fnqv] path ...", .usage = "[-Fnqv] " CMD_TARGET_PANE_USAGE " path ...",
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
.flags = 0, .flags = 0,
.exec = cmd_source_file_exec .exec = cmd_source_file_exec
@@ -57,6 +63,16 @@ struct cmd_source_file_data {
static enum cmd_retval static enum cmd_retval
cmd_source_file_complete_cb(struct cmdq_item *item, __unused void *data) cmd_source_file_complete_cb(struct cmdq_item *item, __unused void *data)
{ {
struct client *c = cmdq_get_client(item);
if (c == NULL) {
cmd_source_file_depth--;
log_debug("%s: depth now %u", __func__, cmd_source_file_depth);
} else {
c->source_file_depth--;
log_debug("%s: depth now %u", __func__, c->source_file_depth);
}
cfg_print_causes(item); cfg_print_causes(item);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
@@ -65,6 +81,7 @@ static void
cmd_source_file_complete(struct client *c, struct cmd_source_file_data *cdata) cmd_source_file_complete(struct client *c, struct cmd_source_file_data *cdata)
{ {
struct cmdq_item *new_item; struct cmdq_item *new_item;
u_int i;
if (cfg_finished) { if (cfg_finished) {
if (cdata->retval == CMD_RETURN_ERROR && if (cdata->retval == CMD_RETURN_ERROR &&
@@ -75,6 +92,8 @@ cmd_source_file_complete(struct client *c, struct cmd_source_file_data *cdata)
cmdq_insert_after(cdata->after, new_item); cmdq_insert_after(cdata->after, new_item);
} }
for (i = 0; i < cdata->nfiles; i++)
free(cdata->files[i]);
free(cdata->files); free(cdata->files);
free(cdata); free(cdata);
} }
@@ -89,15 +108,16 @@ cmd_source_file_done(struct client *c, const char *path, int error,
size_t bsize = EVBUFFER_LENGTH(buffer); size_t bsize = EVBUFFER_LENGTH(buffer);
u_int n; u_int n;
struct cmdq_item *new_item; struct cmdq_item *new_item;
struct cmd_find_state *target = cmdq_get_target(item);
if (!closed) if (!closed)
return; return;
if (error != 0) if (error != 0)
cmdq_error(item, "%s: %s", path, strerror(error)); cmdq_error(item, "%s: %s", strerror(error), path);
else if (bsize != 0) { else if (bsize != 0) {
if (load_cfg_from_buffer(bdata, bsize, path, c, cdata->after, if (load_cfg_from_buffer(bdata, bsize, path, c, cdata->after,
cdata->flags, &new_item) < 0) target, cdata->flags, &new_item) < 0)
cdata->retval = CMD_RETURN_ERROR; cdata->retval = CMD_RETURN_ERROR;
else if (new_item != NULL) else if (new_item != NULL)
cdata->after = new_item; cdata->after = new_item;
@@ -121,6 +141,21 @@ cmd_source_file_add(struct cmd_source_file_data *cdata, const char *path)
cdata->files[cdata->nfiles++] = xstrdup(path); cdata->files[cdata->nfiles++] = xstrdup(path);
} }
static char *
cmd_source_file_quote_for_glob(const char *path)
{
char *quoted = xmalloc(2 * strlen(path) + 1), *q = quoted;
const char *p = path;
while (*p != '\0') {
if ((u_char)*p < 128 && !isalnum((u_char)*p) && *p != '/')
*q++ = '\\';
*q++ = *p++;
}
*q = '\0';
return (quoted);
}
static enum cmd_retval static enum cmd_retval
cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
{ {
@@ -128,11 +163,27 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_source_file_data *cdata; struct cmd_source_file_data *cdata;
struct client *c = cmdq_get_client(item); struct client *c = cmdq_get_client(item);
enum cmd_retval retval = CMD_RETURN_NORMAL; enum cmd_retval retval = CMD_RETURN_NORMAL;
char *pattern, *cwd, *expand = NULL; char *pattern, *cwd, *expanded = NULL;
const char *path, *error; const char *path, *error;
glob_t g; glob_t g;
int i, result; int result, parse_flags;
u_int j; u_int i, j;
if (c == NULL) {
if (cmd_source_file_depth >= CMD_SOURCE_FILE_DEPTH_LIMIT) {
cmdq_error(item, "too many nested files");
return (CMD_RETURN_ERROR);
}
cmd_source_file_depth++;
log_debug("%s: depth now %u", __func__, cmd_source_file_depth);
} else {
if (c->source_file_depth >= CMD_SOURCE_FILE_DEPTH_LIMIT) {
cmdq_error(item, "too many nested files");
return (CMD_RETURN_ERROR);
}
c->source_file_depth++;
log_debug("%s: depth now %u", __func__, c->source_file_depth);
}
cdata = xcalloc(1, sizeof *cdata); cdata = xcalloc(1, sizeof *cdata);
cdata->item = item; cdata->item = item;
@@ -141,18 +192,21 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
cdata->flags |= CMD_PARSE_QUIET; cdata->flags |= CMD_PARSE_QUIET;
if (args_has(args, 'n')) if (args_has(args, 'n'))
cdata->flags |= CMD_PARSE_PARSEONLY; cdata->flags |= CMD_PARSE_PARSEONLY;
if (args_has(args, 'v')) if (c == NULL || ~c->flags & CLIENT_CONTROL) {
cdata->flags |= CMD_PARSE_VERBOSE; parse_flags = cmd_get_parse_flags(self);
if (args_has(args, 'v') || (parse_flags & CMD_PARSE_VERBOSE))
cdata->flags |= CMD_PARSE_VERBOSE;
}
utf8_stravis(&cwd, server_client_get_cwd(c, NULL), VIS_GLOB); cwd = cmd_source_file_quote_for_glob(server_client_get_cwd(c, NULL));
for (i = 0; i < args->argc; i++) { for (i = 0; i < args_count(args); i++) {
path = args_string(args, i);
if (args_has(args, 'F')) { if (args_has(args, 'F')) {
free(expand); free(expanded);
expand = format_single_from_target(item, args->argv[i]); expanded = format_single_from_target(item, path);
path = expand; path = expanded;
} else }
path = args->argv[i];
if (strcmp(path, "-") == 0) { if (strcmp(path, "-") == 0) {
cmd_source_file_add(cdata, "-"); cmd_source_file_add(cdata, "-");
continue; continue;
@@ -173,18 +227,20 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
error = strerror(ENOMEM); error = strerror(ENOMEM);
else else
error = strerror(EINVAL); error = strerror(EINVAL);
cmdq_error(item, "%s: %s", path, error); cmdq_error(item, "%s: %s", error, path);
retval = CMD_RETURN_ERROR; retval = CMD_RETURN_ERROR;
} }
globfree(&g);
free(pattern); free(pattern);
continue; continue;
} }
free(expand);
free(pattern); free(pattern);
for (j = 0; j < g.gl_pathc; j++) for (j = 0; j < g.gl_pathc; j++)
cmd_source_file_add(cdata, g.gl_pathv[j]); cmd_source_file_add(cdata, g.gl_pathv[j]);
globfree(&g);
} }
free(expanded);
cdata->after = item; cdata->after = item;
cdata->retval = retval; cdata->retval = retval;

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-split-window.c,v 1.146 2026/07/21 12:28:43 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -27,21 +27,44 @@
#include "tmux.h" #include "tmux.h"
/* /*
* Split a window (add a new pane). * Create a new pane.
*/ */
#define SPLIT_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}" #define SPLIT_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
static enum cmd_retval cmd_split_window_exec(struct cmd *, static enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmdq_item *);
struct cmdq_item *); static void cmd_split_window_mouse_resize(struct client *,
struct mouse_event *);
const struct cmd_entry cmd_new_pane_entry = {
.name = "new-pane",
.alias = "newp",
.args = { "bB:Cc:de:EfF:hIkl:LMm:Op:PR:s:S:t:T:vWx:X:y:Y:Z", 0, -1, NULL },
.usage = "[-bCdefhIklMOPvWZ] [-B border-lines] "
"[-c start-directory] [-e environment] "
"[-F format] [-l size] [-m message] [-p percentage] "
"[-s style] [-S active-border-style] "
"[-R inactive-border-style] [-T title] [-x width] [-y height] "
"[-X x-position] [-Y y-position] " CMD_TARGET_PANE_USAGE " "
"[shell-command [argument ...]]",
.target = { 't', CMD_FIND_PANE, 0 },
.flags = 0,
.exec = cmd_split_window_exec
};
const struct cmd_entry cmd_split_window_entry = { const struct cmd_entry cmd_split_window_entry = {
.name = "split-window", .name = "split-window",
.alias = "splitw", .alias = "splitw",
.args = { "bc:de:fF:hIl:p:Pt:vZ", 0, -1 }, .args = { "bB:c:de:EfF:hIkl:m:p:PR:s:S:t:T:vWZ", 0, -1, NULL },
.usage = "[-bdefhIPvZ] [-c start-directory] [-e environment] " .usage = "[-bdefhIklPvWZ] [-B border-lines] [-c start-directory] "
"[-F format] [-l size] " CMD_TARGET_PANE_USAGE " [command]", "[-e environment] [-F format] [-l size] [-m message] "
"[-p percentage] [-s style] [-S active-border-style] "
"[-R inactive-border-style] [-T title] "
CMD_TARGET_PANE_USAGE " [shell-command [argument ...]]",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -55,79 +78,99 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *current = cmdq_get_current(item);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct spawn_context sc; struct spawn_context sc = { 0 };
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct session *s = target->s; struct session *s = target->s;
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
struct window_pane *wp = target->wp, *new_wp; struct window *w = wl->window;
enum layout_type type; struct window_pane *wp = target->wp, *new_wp = NULL;
struct layout_cell *lc; struct layout_cell *lc = NULL;
struct event_payload *ep;
struct cmd_find_state fs; struct cmd_find_state fs;
int size, percentage, flags, input; struct key_event *event = cmdq_get_event(item);
const char *template, *add, *errstr, *p; int input, empty, is_floating, flags = 0;
char *cause, *cp, *copy; const char *template, *style, *value;
size_t plen; char *cause = NULL, *cp, *title;
struct args_value *value; const struct options_table_entry *oe;
struct args_value *av;
enum pane_lines lines;
u_int count = args_count(args);
if (args_has(args, 'h')) if (cmd_get_entry(self) == &cmd_new_pane_entry)
type = LAYOUT_LEFTRIGHT; is_floating = !args_has(args, 'L');
else else {
type = LAYOUT_TOPBOTTOM; is_floating = window_pane_is_floating(wp);
if ((p = args_get(args, 'l')) != NULL) { flags |= SPAWN_SPLIT;
plen = strlen(p); }
if (p[plen - 1] == '%') {
copy = xstrdup(p); if (args_has(args, 'O')) {
copy[plen - 1] = '\0'; if (!is_floating) {
percentage = strtonum(copy, 0, INT_MAX, &errstr); cmdq_error(item, "modal pane must be floating");
free(copy);
if (errstr != NULL) {
cmdq_error(item, "percentage %s", errstr);
return (CMD_RETURN_ERROR);
}
if (type == LAYOUT_TOPBOTTOM)
size = (wp->sy * percentage) / 100;
else
size = (wp->sx * percentage) / 100;
} else {
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
if (cause != NULL) {
cmdq_error(item, "lines %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
}
} else if (args_has(args, 'p')) {
percentage = args_strtonum(args, 'p', 0, INT_MAX, &cause);
if (cause != NULL) {
cmdq_error(item, "create pane failed: -p %s", cause);
free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
if (type == LAYOUT_TOPBOTTOM) if (w->modal != NULL) {
size = (wp->sy * percentage) / 100; cmdq_error(item, "window already has a modal pane");
else return (CMD_RETURN_ERROR);
size = (wp->sx * percentage) / 100; }
} else }
size = -1;
window_push_zoom(wp->window, 1, args_has(args, 'Z')); if (args_has(args, 'M') && is_floating) {
input = (args_has(args, 'I') && args->argc == 0); if (event == NULL || !event->m.valid || tc == NULL)
return (CMD_RETURN_NORMAL);
}
flags = 0; if (is_floating)
flags |= SPAWN_FLOATING;
if (args_has(args, 'h'))
flags |= SPAWN_HORIZONTAL;
if (args_has(args, 'b')) if (args_has(args, 'b'))
flags |= SPAWN_BEFORE; flags |= SPAWN_BEFORE;
if (args_has(args, 'f')) if (args_has(args, 'f'))
flags |= SPAWN_FULLSIZE; flags |= SPAWN_FULLSIZE;
if (input || (args->argc == 1 && *args->argv[0] == '\0')) if (args_has(args, 'd'))
flags |= SPAWN_DETACHED;
if (args_has(args, 'Z'))
flags |= SPAWN_ZOOM;
if (args_has(args, 'O'))
flags |= SPAWN_MODAL;
input = args_has(args, 'I');
if (input || (count == 1 && *args_string(args, 0) == '\0'))
empty = 1;
else
empty = args_has(args, 'E');
if (empty &&
count != 0 &&
(count != 1 || *args_string(args, 0) != '\0')) {
cmdq_error(item, "command cannot be given for empty pane");
return (CMD_RETURN_ERROR);
}
if (empty)
flags |= SPAWN_EMPTY; flags |= SPAWN_EMPTY;
lc = layout_split_pane(wp, type, size, flags); if ((value = args_get(args, 'B')) == NULL)
if (lc == NULL) { lines = window_get_pane_lines(w);
cmdq_error(item, "no space for new pane"); else {
oe = options_search("pane-border-lines");
lines = options_find_choice(oe, value, &cause);
if (cause != NULL) {
cmdq_error(item, "pane-border-lines %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
}
if (flags & SPAWN_FLOATING) {
lc = layout_get_floating_cell(item, args, lines, w, wp, flags,
&cause);
} else
lc = layout_get_tiled_cell(item, args, w, wp, flags, &cause);
if (cause != NULL) {
cmdq_error(item, "%s", cause);
free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
memset(&sc, 0, sizeof sc);
sc.item = item; sc.item = item;
sc.s = s; sc.s = s;
sc.wl = wl; sc.wl = wl;
@@ -135,44 +178,109 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
sc.wp0 = wp; sc.wp0 = wp;
sc.lc = lc; sc.lc = lc;
sc.name = NULL; args_to_vector(args, &sc.argc, &sc.argv);
sc.argc = args->argc;
sc.argv = args->argv;
sc.environ = environ_create(); sc.environ = environ_create();
add = args_first_value(args, 'e', &value); av = args_first_value(args, 'e');
while (add != NULL) { while (av != NULL) {
environ_put(sc.environ, add, 0); environ_put(sc.environ, av->string, 0);
add = args_next_value(&value); av = args_next_value(av);
} }
sc.idx = -1; sc.idx = -1;
sc.cwd = args_get(args, 'c'); sc.cwd = args_get(args, 'c');
sc.flags = flags; sc.flags = flags;
if (args_has(args, 'd'))
sc.flags |= SPAWN_DETACHED;
if (args_has(args, 'Z'))
sc.flags |= SPAWN_ZOOM;
if ((new_wp = spawn_pane(&sc, &cause)) == NULL) { if ((new_wp = spawn_pane(&sc, &cause)) == NULL) {
cmdq_error(item, "create pane failed: %s", cause); cmdq_error(item, "create pane failed: %s", cause);
free(cause); free(cause);
return (CMD_RETURN_ERROR); /*
* spawn_pane has already torn the half-built pane down (its
* fork-failure path removes the pane and destroys the layout
* cell), so new_wp is NULL and there is nothing for fail to do.
*/
goto fail;
} }
if (input && window_pane_start_input(new_wp, item, &cause) != 0) { if (args_has(args, 'C') && args_has(args, 'O'))
server_client_remove_pane(new_wp); new_wp->flags |= PANE_CLOSEONCLICK;
layout_close_pane(new_wp);
window_remove_pane(wp->window, new_wp); style = args_get(args, 's');
cmdq_error(item, "%s", cause); if (style != NULL) {
free(cause); if (options_set_string(new_wp->options, "window-style", 0,
return (CMD_RETURN_ERROR); "%s", style) == NULL) {
cmdq_error(item, "bad style: %s", style);
goto fail;
}
options_set_string(new_wp->options, "window-active-style", 0,
"%s", style);
new_wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED|
PANE_THEMECHANGED);
} }
if (!args_has(args, 'd')) style = args_get(args, 'S');
if (style != NULL) {
if (options_set_string(new_wp->options,
"pane-active-border-style", 0, "%s", style) == NULL) {
cmdq_error(item, "bad active border style: %s", style);
goto fail;
}
}
style = args_get(args, 'R');
if (style != NULL) {
if (options_set_string(new_wp->options, "pane-border-style", 0,
"%s", style) == NULL) {
cmdq_error(item, "bad inactive border style: %s",
style);
goto fail;
}
}
if (args_has(args, 'B'))
options_set_number(new_wp->options, "pane-border-lines", lines);
if (args_has(args, 'k') || args_has(args, 'm')) {
options_set_number(new_wp->options, "remain-on-exit", 3);
if (args_has(args, 'm')) {
options_set_string(new_wp->options,
"remain-on-exit-format", 0, "%s",
args_get(args, 'm'));
}
}
if (args_has(args, 'T')) {
title = format_single_from_target(item, args_get(args, 'T'));
screen_set_title(&new_wp->base, title, 0);
ep = event_payload_create();
cmd_find_from_pane(&fs, new_wp, 0);
event_payload_set_target(ep, &fs);
event_payload_set_pane(ep, "pane", new_wp);
event_payload_set_window(ep, "window", new_wp->window);
event_payload_set_string(ep, "new_title", "%s", title);
events_fire("pane-title-changed", ep);
free(title);
}
if (input) {
switch (window_pane_start_input(new_wp, item, &cause)) {
case -1:
cmdq_error(item, "%s", cause);
free(cause);
goto fail;
case 1:
input = 0;
break;
}
}
if (~flags & SPAWN_DETACHED)
cmd_find_from_winlink_pane(current, wl, new_wp, 0); cmd_find_from_winlink_pane(current, wl, new_wp, 0);
window_pop_zoom(wp->window);
server_redraw_window(wp->window); if ((~flags & SPAWN_FLOATING) && !args_has(args, 'O')) {
server_status_session(s); window_pop_zoom(wp->window);
server_redraw_window(wp->window);
}
server_redraw_session(s);
if (args_has(args, 'M') && is_floating) {
tc->tty.mouse_last_pane = new_wp->id;
tc->tty.mouse_drag_update = cmd_split_window_mouse_resize;
cmd_split_window_mouse_resize(tc, &event->m);
}
if (args_has(args, 'P')) { if (args_has(args, 'P')) {
if ((template = args_get(args, 'F')) == NULL) if ((template = args_get(args, 'F')) == NULL)
@@ -185,8 +293,110 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
cmd_find_from_winlink_pane(&fs, wl, new_wp, 0); cmd_find_from_winlink_pane(&fs, wl, new_wp, 0);
cmdq_insert_hook(s, item, &fs, "after-split-window"); cmdq_insert_hook(s, item, &fs, "after-split-window");
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ); environ_free(sc.environ);
if (input) if (input)
return (CMD_RETURN_WAIT); return (CMD_RETURN_WAIT);
if (args_has(args, 'W')) {
/*
* With -W, block this command queue item until the pane's
* command exits; window_pane_wait_finish will be called to
* continue it.
*/
new_wp->wait_item = item;
return (CMD_RETURN_WAIT);
}
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
fail:
/*
* If the pane was spawned before we failed, tear it down here; this
* also destroys its layout cell. spawn_pane's own failure path has
* already done this, so new_wp is NULL in that case.
*/
if (new_wp != NULL) {
server_client_remove_pane(new_wp);
if (!is_floating)
layout_close_pane(new_wp);
window_remove_pane(wp->window, new_wp);
} else if (args_has(args, 'O'))
window_pop_modal_zoom(wp->window);
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ);
return (CMD_RETURN_ERROR);
}
static void
cmd_split_window_mouse_resize(struct client *c, struct mouse_event *m)
{
struct window_pane *wp;
struct window *w;
struct layout_cell *lc;
enum pane_lines lines;
u_int sx, sy;
int x, y, xoff, yoff, border;
if (c->tty.mouse_last_pane == -1)
return;
wp = window_pane_find_by_id(c->tty.mouse_last_pane);
if (wp == NULL || !window_pane_is_floating(wp)) {
c->tty.mouse_drag_update = NULL;
return;
}
w = wp->window;
lc = wp->layout_cell;
x = m->x + m->ox;
y = m->y + m->oy;
if (m->statusat == 0 && y >= (int)m->statuslines)
y -= m->statuslines;
else if (m->statusat > 0 && y >= m->statusat)
y = m->statusat - 1;
lines = window_pane_get_pane_lines(wp);
border = (lines != PANE_LINES_NONE);
if (x >= (int)c->tty.mouse_drag_x) {
xoff = c->tty.mouse_drag_x + border;
sx = x - c->tty.mouse_drag_x + 1;
} else {
sx = c->tty.mouse_drag_x - x + 1;
xoff = c->tty.mouse_drag_x - sx + 1;
if (border)
xoff++;
}
if (y >= (int)c->tty.mouse_drag_y) {
yoff = c->tty.mouse_drag_y + border;
sy = y - c->tty.mouse_drag_y + 1;
} else {
sy = c->tty.mouse_drag_y - y + 1;
yoff = c->tty.mouse_drag_y - sy + 1;
if (border)
yoff++;
}
if (border) {
if (sx <= 2)
sx = PANE_MINIMUM;
else
sx -= 2;
if (sy <= 2)
sy = PANE_MINIMUM;
else
sy -= 2;
}
if (sx < PANE_MINIMUM)
sx = PANE_MINIMUM;
if (sy < PANE_MINIMUM)
sy = PANE_MINIMUM;
layout_set_size(lc, sx, sy, xoff, yoff);
layout_fix_panes(w, NULL);
server_redraw_window(w);
server_redraw_window_borders(w);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-swap-pane.c,v 1.55 2026/07/15 13:02:33 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -32,7 +32,7 @@ const struct cmd_entry cmd_swap_pane_entry = {
.name = "swap-pane", .name = "swap-pane",
.alias = "swapp", .alias = "swapp",
.args = { "dDs:t:UZ", 0, 0 }, .args = { "dDs:t:UZ", 0, 0, NULL },
.usage = "[-dDUZ] " CMD_SRCDST_PANE_USAGE, .usage = "[-dDUZ] " CMD_SRCDST_PANE_USAGE,
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED }, .source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
@@ -42,6 +42,22 @@ const struct cmd_entry cmd_swap_pane_entry = {
.exec = cmd_swap_pane_exec .exec = cmd_swap_pane_exec
}; };
static struct window_pane *
cmd_swap_pane_next_tiled_pane(struct window_pane *wp)
{
while (wp != NULL && !layout_cell_is_tiled(wp->layout_cell))
wp = TAILQ_NEXT(wp, entry);
return (wp);
}
static struct window_pane *
cmd_swap_pane_prev_tiled_pane(struct window_pane *wp)
{
while (wp != NULL && !layout_cell_is_tiled(wp->layout_cell))
wp = TAILQ_PREV(wp, window_panes, entry);
return (wp);
}
static enum cmd_retval static enum cmd_retval
cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
@@ -52,25 +68,47 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
struct window_pane *tmp_wp, *src_wp, *dst_wp; struct window_pane *tmp_wp, *src_wp, *dst_wp;
struct layout_cell *src_lc, *dst_lc; struct layout_cell *src_lc, *dst_lc;
u_int sx, sy, xoff, yoff; u_int sx, sy, xoff, yoff;
int src_idx, dst_idx;
dst_w = target->wl->window; dst_w = target->wl->window;
dst_wp = target->wp; dst_wp = target->wp;
dst_idx = target->wl->idx;
src_w = source->wl->window; src_w = source->wl->window;
src_wp = source->wp; src_wp = source->wp;
src_idx = source->wl->idx;
if (src_wp == src_w->modal || dst_wp == dst_w->modal) {
cmdq_error(item, "pane is modal");
return (CMD_RETURN_ERROR);
}
if (window_push_zoom(dst_w, 0, args_has(args, 'Z'))) if (window_push_zoom(dst_w, 0, args_has(args, 'Z')))
server_redraw_window(dst_w); server_redraw_window(dst_w);
if (args_has(args, 'D')) { if (args_has(args, 'D')) {
if (window_pane_is_floating(dst_wp)) {
cmdq_error(item, "cannot swap down on floating pane");
return (CMD_RETURN_ERROR);
}
src_w = dst_w; src_w = dst_w;
src_wp = TAILQ_NEXT(dst_wp, entry); src_wp = TAILQ_NEXT(dst_wp, entry);
if (src_wp == NULL) src_wp = cmd_swap_pane_next_tiled_pane(src_wp);
if (src_wp == NULL) {
src_wp = TAILQ_FIRST(&dst_w->panes); src_wp = TAILQ_FIRST(&dst_w->panes);
src_wp = cmd_swap_pane_next_tiled_pane(src_wp);
}
} else if (args_has(args, 'U')) { } else if (args_has(args, 'U')) {
if (window_pane_is_floating(dst_wp)) {
cmdq_error(item, "cannot swap up on floating pane");
return (CMD_RETURN_ERROR);
}
src_w = dst_w; src_w = dst_w;
src_wp = TAILQ_PREV(dst_wp, window_panes, entry); src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
if (src_wp == NULL) src_wp = cmd_swap_pane_prev_tiled_pane(src_wp);
if (src_wp == NULL) {
src_wp = TAILQ_LAST(&dst_w->panes, window_panes); src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
src_wp = cmd_swap_pane_prev_tiled_pane(src_wp);
}
} }
if (src_w != dst_w && window_push_zoom(src_w, 0, args_has(args, 'Z'))) if (src_w != dst_w && window_push_zoom(src_w, 0, args_has(args, 'Z')))
@@ -92,6 +130,16 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
else else
TAILQ_INSERT_AFTER(&dst_w->panes, tmp_wp, src_wp, entry); TAILQ_INSERT_AFTER(&dst_w->panes, tmp_wp, src_wp, entry);
tmp_wp = TAILQ_PREV(dst_wp, window_panes, zentry);
TAILQ_REMOVE(&dst_w->z_index, dst_wp, zentry);
TAILQ_REPLACE(&src_w->z_index, src_wp, dst_wp, zentry);
if (tmp_wp == src_wp)
tmp_wp = dst_wp;
if (tmp_wp == NULL)
TAILQ_INSERT_HEAD(&dst_w->z_index, src_wp, zentry);
else
TAILQ_INSERT_AFTER(&dst_w->z_index, tmp_wp, src_wp, zentry);
src_lc = src_wp->layout_cell; src_lc = src_wp->layout_cell;
dst_lc = dst_wp->layout_cell; dst_lc = dst_wp->layout_cell;
src_lc->wp = dst_wp; src_lc->wp = dst_wp;
@@ -101,10 +149,10 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
src_wp->window = dst_w; src_wp->window = dst_w;
options_set_parent(src_wp->options, dst_w->options); options_set_parent(src_wp->options, dst_w->options);
src_wp->flags |= PANE_STYLECHANGED; src_wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
dst_wp->window = src_w; dst_wp->window = src_w;
options_set_parent(dst_wp->options, src_w->options); options_set_parent(dst_wp->options, src_w->options);
dst_wp->flags |= PANE_STYLECHANGED; dst_wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
sx = src_wp->sx; sy = src_wp->sy; sx = src_wp->sx; sy = src_wp->sy;
xoff = src_wp->xoff; yoff = src_wp->yoff; xoff = src_wp->xoff; yoff = src_wp->yoff;
@@ -128,14 +176,26 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
window_set_active_pane(dst_w, src_wp, 1); window_set_active_pane(dst_w, src_wp, 1);
} }
if (src_w != dst_w) { if (src_w != dst_w) {
if (src_w->last == src_wp) window_pane_stack_remove(&src_w->last_panes, src_wp);
src_w->last = NULL; window_pane_stack_remove(&dst_w->last_panes, dst_wp);
if (dst_w->last == dst_wp) colour_palette_from_option(&src_wp->palette, src_wp->options);
dst_w->last = NULL; colour_palette_from_option(&dst_wp->palette, dst_wp->options);
layout_fix_panes(src_w, NULL);
redraw_invalidate_scene(src_w);
server_redraw_window(src_w);
} }
server_redraw_window(src_w); layout_fix_panes(dst_w, NULL);
redraw_invalidate_scene(dst_w);
server_redraw_window(dst_w); server_redraw_window(dst_w);
if (src_w != dst_w) {
window_fire_pane_moved(src_wp, src_w, src_idx, dst_w, dst_idx);
window_fire_pane_moved(dst_wp, dst_w, dst_idx, src_w, src_idx);
}
events_fire_window("window-layout-changed", src_w);
if (src_w != dst_w)
events_fire_window("window-layout-changed", dst_w);
out: out:
if (window_pop_zoom(src_w)) if (window_pop_zoom(src_w))
server_redraw_window(src_w); server_redraw_window(src_w);

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-swap-window.c,v 1.30 2026/07/27 08:03:01 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -32,13 +32,13 @@ const struct cmd_entry cmd_swap_window_entry = {
.name = "swap-window", .name = "swap-window",
.alias = "swapw", .alias = "swapw",
.args = { "ds:t:", 0, 0 }, .args = { "ds:t:", 0, 0, NULL },
.usage = "[-d] " CMD_SRCDST_WINDOW_USAGE, .usage = "[-d] " CMD_SRCDST_WINDOW_USAGE,
.source = { 's', CMD_FIND_WINDOW, CMD_FIND_DEFAULT_MARKED }, .source = { 's', CMD_FIND_WINDOW, CMD_FIND_DEFAULT_MARKED },
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
.flags = 0, .flags = CMD_AFTERHOOK,
.exec = cmd_swap_window_exec .exec = cmd_swap_window_exec
}; };
@@ -77,6 +77,8 @@ cmd_swap_window_exec(struct cmd *self, struct cmdq_item *item)
wl_src->window = w_dst; wl_src->window = w_dst;
TAILQ_INSERT_TAIL(&w_dst->winlinks, wl_src, wentry); TAILQ_INSERT_TAIL(&w_dst->winlinks, wl_src, wentry);
if (marked_pane.wl == wl_src)
marked_pane.wl = wl_dst;
if (args_has(args, 'd')) { if (args_has(args, 'd')) {
session_select(dst, wl_dst->idx); session_select(dst, wl_dst->idx);
if (src != dst) if (src != dst)

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-switch-client.c,v 1.74 2026/05/22 15:22:43 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -20,6 +20,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include "tmux.h" #include "tmux.h"
@@ -34,9 +35,9 @@ const struct cmd_entry cmd_switch_client_entry = {
.name = "switch-client", .name = "switch-client",
.alias = "switchc", .alias = "switchc",
.args = { "lc:EFnpt:rT:Z", 0, 0 }, .args = { "c:EFlnO:pt:rT:Z", 0, 0, NULL },
.usage = "[-ElnprZ] [-c target-client] [-t target-session] " .usage = "[-ElnprZ] [-c target-client] [-t target-session] "
"[-T key-table]", "[-T key-table] [-O order]",
/* -t is special */ /* -t is special */
@@ -53,6 +54,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
const char *tflag = args_get(args, 't'); const char *tflag = args_get(args, 't');
enum cmd_find_type type; enum cmd_find_type type;
int flags; int flags;
struct client *c = cmdq_get_client(item);
struct client *tc = cmdq_get_target_client(item); struct client *tc = cmdq_get_target_client(item);
struct session *s; struct session *s;
struct winlink *wl; struct winlink *wl;
@@ -60,8 +62,11 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
struct window_pane *wp; struct window_pane *wp;
const char *tablename; const char *tablename;
struct key_table *table; struct key_table *table;
struct sort_criteria sort_crit;
uid_t uid;
if (tflag != NULL && tflag[strcspn(tflag, ":.%")] != '\0') { if (tflag != NULL &&
(tflag[strcspn(tflag, ":.%")] != '\0' || strcmp(tflag, "=") == 0)) {
type = CMD_FIND_PANE; type = CMD_FIND_PANE;
flags = 0; flags = 0;
} else { } else {
@@ -75,6 +80,13 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
wp = target.wp; wp = target.wp;
if (args_has(args, 'r')) { if (args_has(args, 'r')) {
if (tc->flags & CLIENT_READONLY) {
uid = proc_get_peer_uid(c->peer);
if (uid != getuid()) {
cmdq_error(item, "client is read-only");
return (CMD_RETURN_ERROR);
}
}
if (tc->flags & CLIENT_READONLY) if (tc->flags & CLIENT_READONLY)
tc->flags &= ~(CLIENT_READONLY|CLIENT_IGNORESIZE); tc->flags &= ~(CLIENT_READONLY|CLIENT_IGNORESIZE);
else else
@@ -94,13 +106,22 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
sort_crit.order = sort_order_from_string(args_get(args, 'O'));
if (sort_crit.order == SORT_END && args_has(args, 'O')) {
cmdq_error(item, "invalid sort order");
return (CMD_RETURN_ERROR);
}
sort_crit.reversed = args_has(args, 'r');
if (args_has(args, 'n')) { if (args_has(args, 'n')) {
if ((s = session_next_session(tc->session)) == NULL) { s = session_next_session(tc->session, &sort_crit);
if (s == NULL) {
cmdq_error(item, "can't find next session"); cmdq_error(item, "can't find next session");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
} else if (args_has(args, 'p')) { } else if (args_has(args, 'p')) {
if ((s = session_previous_session(tc->session)) == NULL) { s = session_previous_session(tc->session, &sort_crit);
if (s == NULL) {
cmdq_error(item, "can't find previous session"); cmdq_error(item, "can't find previous session");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
@@ -134,23 +155,9 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
if (!args_has(args, 'E')) if (!args_has(args, 'E'))
environ_update(s->options, tc->environ, s->environ); environ_update(s->options, tc->environ, s->environ);
if (tc->session != NULL && tc->session != s) server_client_set_session(tc, s);
tc->last_session = tc->session;
tc->session = s;
if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT) if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT)
server_client_set_key_table(tc, NULL); server_client_set_key_table(tc, NULL);
tty_update_client_offset(tc);
status_timer_start(tc);
notify_client("client-session-changed", tc);
session_update_activity(s, NULL);
gettimeofday(&s->last_attached_time, NULL);
server_check_unattached();
server_redraw_client(tc);
s->curw->flags &= ~WINLINK_ALERTFLAGS;
s->curw->window->latest = tc;
recalculate_sizes();
alerts_check_session(s);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-unbind-key.c,v 1.34 2021/08/21 10:22:39 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -32,7 +32,7 @@ const struct cmd_entry cmd_unbind_key_entry = {
.name = "unbind-key", .name = "unbind-key",
.alias = "unbind", .alias = "unbind",
.args = { "anqT:", 0, 1 }, .args = { "anqT:", 0, 1, NULL },
.usage = "[-anq] [-T key-table] key", .usage = "[-anq] [-T key-table] key",
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
@@ -44,11 +44,11 @@ cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
key_code key; key_code key;
const char *tablename; const char *tablename, *keystr = args_string(args, 0);
int quiet = args_has(args, 'q'); int quiet = args_has(args, 'q');
if (args_has(args, 'a')) { if (args_has(args, 'a')) {
if (args->argc != 0) { if (keystr != NULL) {
if (!quiet) if (!quiet)
cmdq_error(item, "key given with -a"); cmdq_error(item, "key given with -a");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
@@ -73,16 +73,16 @@ cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args->argc != 1) { if (keystr == NULL) {
if (!quiet) if (!quiet)
cmdq_error(item, "missing key"); cmdq_error(item, "missing key");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
key = key_string_lookup_string(args->argv[0]); key = key_string_lookup_string(keystr);
if (key == KEYC_NONE || key == KEYC_UNKNOWN) { if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
if (!quiet) if (!quiet)
cmdq_error(item, "unknown key: %s", args->argv[0]); cmdq_error(item, "unknown key: %s", keystr);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd-wait-for.c,v 1.23 2026/07/10 13:38:45 nicm Exp $ */
/* /*
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -34,8 +34,8 @@ const struct cmd_entry cmd_wait_for_entry = {
.name = "wait-for", .name = "wait-for",
.alias = "wait", .alias = "wait",
.args = { "LSU", 1, 1 }, .args = { "EF:LSUlvw:", 1, 1, NULL },
.usage = "[-L|-S|-U] channel", .usage = "[-ELSUlv] [-F format] [-w waiter] name",
.flags = 0, .flags = 0,
.exec = cmd_wait_for_exec .exec = cmd_wait_for_exec
@@ -46,6 +46,17 @@ struct wait_item {
TAILQ_ENTRY(wait_item) entry; TAILQ_ENTRY(wait_item) entry;
}; };
struct wait_event_item {
struct cmdq_item *item;
struct events_sink *sink;
char *name;
char *filter;
int verbose;
TAILQ_ENTRY(wait_event_item) entry;
};
static TAILQ_HEAD(, wait_event_item) wait_event_items =
TAILQ_HEAD_INITIALIZER(wait_event_items);
struct wait_channel { struct wait_channel {
const char *name; const char *name;
int locked; int locked;
@@ -76,9 +87,28 @@ static enum cmd_retval cmd_wait_for_lock(struct cmdq_item *, const char *,
struct wait_channel *); struct wait_channel *);
static enum cmd_retval cmd_wait_for_unlock(struct cmdq_item *, const char *, static enum cmd_retval cmd_wait_for_unlock(struct cmdq_item *, const char *,
struct wait_channel *); struct wait_channel *);
static enum cmd_retval cmd_wait_for_event(struct cmdq_item *, const char *,
struct args *);
static void cmd_wait_for_event_cb(const char *,
struct event_payload *, void *);
static void cmd_wait_for_event_free(struct wait_event_item *);
static enum cmd_retval cmd_wait_for_event_list(struct cmdq_item *,
const char *);
static enum cmd_retval cmd_wait_for_event_wake(struct cmdq_item *,
const char *, struct args *);
static enum cmd_retval cmd_wait_for_list(struct cmdq_item *,
struct wait_channel *);
static enum cmd_retval cmd_wait_for_wake(struct cmdq_item *, const char *,
struct args *, struct wait_channel *);
static struct wait_channel *cmd_wait_for_add(const char *); static struct wait_channel *cmd_wait_for_add(const char *);
static void cmd_wait_for_remove(struct wait_channel *); static void cmd_wait_for_remove(struct wait_channel *);
static void cmd_wait_for_remove_empty(
struct wait_channel *);
static const char *cmd_wait_for_item_client_name(
struct cmdq_item *);
static const char *cmd_wait_for_client_name(
struct wait_event_item *);
static struct wait_channel * static struct wait_channel *
cmd_wait_for_add(const char *name) cmd_wait_for_add(const char *name)
@@ -117,16 +147,53 @@ cmd_wait_for_remove(struct wait_channel *wc)
free(wc); free(wc);
} }
static void
cmd_wait_for_remove_empty(struct wait_channel *wc)
{
if (wc->locked || wc->woken)
return;
if (!TAILQ_EMPTY(&wc->waiters) || !TAILQ_EMPTY(&wc->lockers))
return;
log_debug("remove empty wait channel %s", wc->name);
RB_REMOVE(wait_channels, &wait_channels, wc);
free((void *)wc->name);
free(wc);
}
static const char *
cmd_wait_for_item_client_name(struct cmdq_item *item)
{
struct client *c = cmdq_get_client(item);
if (c == NULL || c->name == NULL)
return ("");
return (c->name);
}
static const char *
cmd_wait_for_client_name(struct wait_event_item *wei)
{
return (cmd_wait_for_item_client_name(wei->item));
}
static enum cmd_retval static enum cmd_retval
cmd_wait_for_exec(struct cmd *self, struct cmdq_item *item) cmd_wait_for_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
const char *name = args->argv[0]; const char *name = args_string(args, 0);
struct wait_channel *wc, wc0; struct wait_channel *wc, find = { .name = name };
wc0.name = name; if (args_has(args, 'E'))
wc = RB_FIND(wait_channels, &wait_channels, &wc0); return (cmd_wait_for_event(item, name, args));
wc = RB_FIND(wait_channels, &wait_channels, &find);
if (args_has(args, 'l'))
return (cmd_wait_for_list(item, wc));
if (args_has(args, 'w'))
return (cmd_wait_for_wake(item, name, args, wc));
if (args_has(args, 'S')) if (args_has(args, 'S'))
return (cmd_wait_for_signal(item, name, wc)); return (cmd_wait_for_signal(item, name, wc));
if (args_has(args, 'L')) if (args_has(args, 'L'))
@@ -136,6 +203,179 @@ cmd_wait_for_exec(struct cmd *self, struct cmdq_item *item)
return (cmd_wait_for_wait(item, name, wc)); return (cmd_wait_for_wait(item, name, wc));
} }
static void
cmd_wait_for_event_print(struct wait_event_item *wei, struct event_payload *ep)
{
struct event_payload_item *epi;
const char *key;
char *value;
epi = event_payload_first(ep);
while (epi != NULL) {
key = event_payload_item_name(epi);
if (*key != '_') {
value = event_payload_item_print(epi);
cmdq_print(wei->item, "%s=%s", key, value);
free(value);
}
epi = event_payload_next(epi);
}
}
static void
cmd_wait_for_event_cb(__unused const char *name, struct event_payload *ep,
void *item_data)
{
struct wait_event_item *wei = item_data;
struct format_tree *ft;
char *expanded;
int flag;
if (wei->verbose)
cmd_wait_for_event_print(wei, ep);
if (wei->filter != NULL) {
ft = format_create(cmdq_get_client(wei->item), wei->item,
FORMAT_NONE, FORMAT_NOJOBS);
event_payload_add_formats(ep, ft, NULL);
expanded = format_expand(ft, wei->filter);
flag = format_true(expanded);
free(expanded);
format_free(ft);
if (!flag)
return;
}
TAILQ_REMOVE(&wait_event_items, wei, entry);
cmdq_continue(wei->item);
cmd_wait_for_event_free(wei);
}
static void
cmd_wait_for_event_free(struct wait_event_item *wei)
{
events_remove_sink(wei->sink);
free(wei->name);
free(wei->filter);
free(wei);
}
static enum cmd_retval
cmd_wait_for_event(struct cmdq_item *item, const char *name, struct args *args)
{
struct wait_event_item *wei;
const char *filter = args_get(args, 'F');
if (!hooks_valid_event_name(name)) {
cmdq_error(item, "invalid event: %s", name);
return (CMD_RETURN_ERROR);
}
if (args_has(args, 'l'))
return (cmd_wait_for_event_list(item, name));
if (args_has(args, 'w'))
return (cmd_wait_for_event_wake(item, name, args));
if (cmdq_get_client(item) == NULL) {
cmdq_error(item, "not able to wait");
return (CMD_RETURN_ERROR);
}
wei = xcalloc(1, sizeof *wei);
wei->item = item;
wei->name = xstrdup(name);
wei->filter = (filter != NULL ? xstrdup(filter) : NULL);
wei->verbose = args_has(args, 'v');
wei->sink = events_add_sink(name, cmd_wait_for_event_cb, wei);
TAILQ_INSERT_TAIL(&wait_event_items, wei, entry);
return (CMD_RETURN_WAIT);
}
static enum cmd_retval
cmd_wait_for_event_list(struct cmdq_item *item, const char *name)
{
struct wait_event_item *wei;
TAILQ_FOREACH(wei, &wait_event_items, entry) {
if (strcmp(wei->name, name) == 0)
cmdq_print(item, "%s", cmd_wait_for_client_name(wei));
}
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_wait_for_event_wake(struct cmdq_item *item, const char *name,
struct args *args)
{
struct wait_event_item *wei, *wei1;
const char *client_name = args_get(args, 'w');
TAILQ_FOREACH_SAFE(wei, &wait_event_items, entry, wei1) {
if (strcmp(wei->name, name) != 0)
continue;
if (strcmp(cmd_wait_for_client_name(wei), client_name) != 0)
continue;
TAILQ_REMOVE(&wait_event_items, wei, entry);
cmdq_continue(wei->item);
cmd_wait_for_event_free(wei);
return (CMD_RETURN_NORMAL);
}
cmdq_error(item, "waiter %s not found", client_name);
return (CMD_RETURN_ERROR);
}
static enum cmd_retval
cmd_wait_for_list(struct cmdq_item *item, struct wait_channel *wc)
{
struct wait_item *wi;
if (wc == NULL)
return (CMD_RETURN_NORMAL);
TAILQ_FOREACH(wi, &wc->waiters, entry)
cmdq_print(item, "%s", cmd_wait_for_item_client_name(wi->item));
TAILQ_FOREACH(wi, &wc->lockers, entry)
cmdq_print(item, "%s", cmd_wait_for_item_client_name(wi->item));
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_wait_for_wake(__unused struct cmdq_item *item, const char *name,
struct args *args, struct wait_channel *wc)
{
struct wait_item *wi, *wi1;
const char *client_name = args_get(args, 'w');
if (wc != NULL) {
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
name = cmd_wait_for_item_client_name(wi->item);
if (strcmp(name, client_name) != 0)
continue;
cmdq_continue(wi->item);
TAILQ_REMOVE(&wc->waiters, wi, entry);
free(wi);
cmd_wait_for_remove_empty(wc);
return (CMD_RETURN_NORMAL);
}
TAILQ_FOREACH_SAFE(wi, &wc->lockers, entry, wi1) {
name = cmd_wait_for_item_client_name(wi->item);
if (strcmp(name, client_name) != 0)
continue;
cmdq_continue(wi->item);
TAILQ_REMOVE(&wc->lockers, wi, entry);
free(wi);
cmd_wait_for_remove_empty(wc);
return (CMD_RETURN_NORMAL);
}
}
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval static enum cmd_retval
cmd_wait_for_signal(__unused struct cmdq_item *item, const char *name, cmd_wait_for_signal(__unused struct cmdq_item *item, const char *name,
struct wait_channel *wc) struct wait_channel *wc)
@@ -245,6 +485,13 @@ cmd_wait_for_flush(void)
{ {
struct wait_channel *wc, *wc1; struct wait_channel *wc, *wc1;
struct wait_item *wi, *wi1; struct wait_item *wi, *wi1;
struct wait_event_item *wei, *wei1;
TAILQ_FOREACH_SAFE(wei, &wait_event_items, entry, wei1) {
TAILQ_REMOVE(&wait_event_items, wei, entry);
cmdq_continue(wei->item);
cmd_wait_for_event_free(wei);
}
RB_FOREACH_SAFE(wc, wait_channels, &wait_channels, wc1) { RB_FOREACH_SAFE(wc, wait_channels, &wait_channels, wc1) {
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) { TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {

230
cmd.c
View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: cmd.c,v 1.189 2026/07/17 08:29:34 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -35,6 +35,7 @@ extern const struct cmd_entry cmd_choose_buffer_entry;
extern const struct cmd_entry cmd_choose_client_entry; extern const struct cmd_entry cmd_choose_client_entry;
extern const struct cmd_entry cmd_choose_tree_entry; extern const struct cmd_entry cmd_choose_tree_entry;
extern const struct cmd_entry cmd_clear_history_entry; extern const struct cmd_entry cmd_clear_history_entry;
extern const struct cmd_entry cmd_clear_prompt_history_entry;
extern const struct cmd_entry cmd_clock_mode_entry; extern const struct cmd_entry cmd_clock_mode_entry;
extern const struct cmd_entry cmd_command_prompt_entry; extern const struct cmd_entry cmd_command_prompt_entry;
extern const struct cmd_entry cmd_confirm_before_entry; extern const struct cmd_entry cmd_confirm_before_entry;
@@ -46,7 +47,6 @@ extern const struct cmd_entry cmd_display_menu_entry;
extern const struct cmd_entry cmd_display_message_entry; extern const struct cmd_entry cmd_display_message_entry;
extern const struct cmd_entry cmd_display_popup_entry; extern const struct cmd_entry cmd_display_popup_entry;
extern const struct cmd_entry cmd_display_panes_entry; extern const struct cmd_entry cmd_display_panes_entry;
extern const struct cmd_entry cmd_down_pane_entry;
extern const struct cmd_entry cmd_find_window_entry; extern const struct cmd_entry cmd_find_window_entry;
extern const struct cmd_entry cmd_has_session_entry; extern const struct cmd_entry cmd_has_session_entry;
extern const struct cmd_entry cmd_if_shell_entry; extern const struct cmd_entry cmd_if_shell_entry;
@@ -71,6 +71,7 @@ extern const struct cmd_entry cmd_lock_server_entry;
extern const struct cmd_entry cmd_lock_session_entry; extern const struct cmd_entry cmd_lock_session_entry;
extern const struct cmd_entry cmd_move_pane_entry; extern const struct cmd_entry cmd_move_pane_entry;
extern const struct cmd_entry cmd_move_window_entry; extern const struct cmd_entry cmd_move_window_entry;
extern const struct cmd_entry cmd_new_pane_entry;
extern const struct cmd_entry cmd_new_session_entry; extern const struct cmd_entry cmd_new_session_entry;
extern const struct cmd_entry cmd_new_window_entry; extern const struct cmd_entry cmd_new_window_entry;
extern const struct cmd_entry cmd_next_layout_entry; extern const struct cmd_entry cmd_next_layout_entry;
@@ -94,6 +95,7 @@ extern const struct cmd_entry cmd_select_pane_entry;
extern const struct cmd_entry cmd_select_window_entry; extern const struct cmd_entry cmd_select_window_entry;
extern const struct cmd_entry cmd_send_keys_entry; extern const struct cmd_entry cmd_send_keys_entry;
extern const struct cmd_entry cmd_send_prefix_entry; extern const struct cmd_entry cmd_send_prefix_entry;
extern const struct cmd_entry cmd_server_access_entry;
extern const struct cmd_entry cmd_set_buffer_entry; extern const struct cmd_entry cmd_set_buffer_entry;
extern const struct cmd_entry cmd_set_environment_entry; extern const struct cmd_entry cmd_set_environment_entry;
extern const struct cmd_entry cmd_set_hook_entry; extern const struct cmd_entry cmd_set_hook_entry;
@@ -104,6 +106,7 @@ extern const struct cmd_entry cmd_show_environment_entry;
extern const struct cmd_entry cmd_show_hooks_entry; extern const struct cmd_entry cmd_show_hooks_entry;
extern const struct cmd_entry cmd_show_messages_entry; extern const struct cmd_entry cmd_show_messages_entry;
extern const struct cmd_entry cmd_show_options_entry; extern const struct cmd_entry cmd_show_options_entry;
extern const struct cmd_entry cmd_show_prompt_history_entry;
extern const struct cmd_entry cmd_show_window_options_entry; extern const struct cmd_entry cmd_show_window_options_entry;
extern const struct cmd_entry cmd_source_file_entry; extern const struct cmd_entry cmd_source_file_entry;
extern const struct cmd_entry cmd_split_window_entry; extern const struct cmd_entry cmd_split_window_entry;
@@ -112,9 +115,9 @@ extern const struct cmd_entry cmd_suspend_client_entry;
extern const struct cmd_entry cmd_swap_pane_entry; extern const struct cmd_entry cmd_swap_pane_entry;
extern const struct cmd_entry cmd_swap_window_entry; extern const struct cmd_entry cmd_swap_window_entry;
extern const struct cmd_entry cmd_switch_client_entry; extern const struct cmd_entry cmd_switch_client_entry;
extern const struct cmd_entry cmd_switch_mode_entry;
extern const struct cmd_entry cmd_unbind_key_entry; extern const struct cmd_entry cmd_unbind_key_entry;
extern const struct cmd_entry cmd_unlink_window_entry; extern const struct cmd_entry cmd_unlink_window_entry;
extern const struct cmd_entry cmd_up_pane_entry;
extern const struct cmd_entry cmd_wait_for_entry; extern const struct cmd_entry cmd_wait_for_entry;
const struct cmd_entry *cmd_table[] = { const struct cmd_entry *cmd_table[] = {
@@ -126,6 +129,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_choose_client_entry, &cmd_choose_client_entry,
&cmd_choose_tree_entry, &cmd_choose_tree_entry,
&cmd_clear_history_entry, &cmd_clear_history_entry,
&cmd_clear_prompt_history_entry,
&cmd_clock_mode_entry, &cmd_clock_mode_entry,
&cmd_command_prompt_entry, &cmd_command_prompt_entry,
&cmd_confirm_before_entry, &cmd_confirm_before_entry,
@@ -161,6 +165,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_lock_session_entry, &cmd_lock_session_entry,
&cmd_move_pane_entry, &cmd_move_pane_entry,
&cmd_move_window_entry, &cmd_move_window_entry,
&cmd_new_pane_entry,
&cmd_new_session_entry, &cmd_new_session_entry,
&cmd_new_window_entry, &cmd_new_window_entry,
&cmd_next_layout_entry, &cmd_next_layout_entry,
@@ -184,6 +189,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_select_window_entry, &cmd_select_window_entry,
&cmd_send_keys_entry, &cmd_send_keys_entry,
&cmd_send_prefix_entry, &cmd_send_prefix_entry,
&cmd_server_access_entry,
&cmd_set_buffer_entry, &cmd_set_buffer_entry,
&cmd_set_environment_entry, &cmd_set_environment_entry,
&cmd_set_hook_entry, &cmd_set_hook_entry,
@@ -194,6 +200,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_show_hooks_entry, &cmd_show_hooks_entry,
&cmd_show_messages_entry, &cmd_show_messages_entry,
&cmd_show_options_entry, &cmd_show_options_entry,
&cmd_show_prompt_history_entry,
&cmd_show_window_options_entry, &cmd_show_window_options_entry,
&cmd_source_file_entry, &cmd_source_file_entry,
&cmd_split_window_entry, &cmd_split_window_entry,
@@ -202,6 +209,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_swap_pane_entry, &cmd_swap_pane_entry,
&cmd_swap_window_entry, &cmd_swap_window_entry,
&cmd_switch_client_entry, &cmd_switch_client_entry,
&cmd_switch_mode_entry,
&cmd_unbind_key_entry, &cmd_unbind_key_entry,
&cmd_unlink_window_entry, &cmd_unlink_window_entry,
&cmd_wait_for_entry, &cmd_wait_for_entry,
@@ -216,10 +224,7 @@ struct cmd {
char *file; char *file;
u_int line; u_int line;
int parse_flags;
char *alias;
int argc;
char **argv;
TAILQ_ENTRY(cmd) qentry; TAILQ_ENTRY(cmd) qentry;
}; };
@@ -247,7 +252,7 @@ cmd_log_argv(int argc, char **argv, const char *fmt, ...)
/* Prepend to an argument vector. */ /* Prepend to an argument vector. */
void void
cmd_prepend_argv(int *argc, char ***argv, char *arg) cmd_prepend_argv(int *argc, char ***argv, const char *arg)
{ {
char **new_argv; char **new_argv;
int i; int i;
@@ -264,7 +269,7 @@ cmd_prepend_argv(int *argc, char ***argv, char *arg)
/* Append to an argument vector. */ /* Append to an argument vector. */
void void
cmd_append_argv(int *argc, char ***argv, char *arg) cmd_append_argv(int *argc, char ***argv, const char *arg)
{ {
*argv = xreallocarray(*argv, (*argc) + 1, sizeof **argv); *argv = xreallocarray(*argv, (*argc) + 1, sizeof **argv);
(*argv)[(*argc)++] = xstrdup(arg); (*argv)[(*argc)++] = xstrdup(arg);
@@ -302,6 +307,8 @@ cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv)
if (argc == 0) if (argc == 0)
return (0); return (0);
if (argc < 0 || argc > 1000)
return (-1);
*argv = xcalloc(argc, sizeof **argv); *argv = xcalloc(argc, sizeof **argv);
buf[len - 1] = '\0'; buf[len - 1] = '\0';
@@ -412,6 +419,13 @@ cmd_get_source(struct cmd *cmd, const char **file, u_int *line)
*line = cmd->line; *line = cmd->line;
} }
/* Get parse flags for command. */
int
cmd_get_parse_flags(struct cmd *cmd)
{
return (cmd->parse_flags);
}
/* Look for an alias for a command. */ /* Look for an alias for a command. */
char * char *
cmd_get_alias(const char *name) cmd_get_alias(const char *name)
@@ -444,7 +458,7 @@ cmd_get_alias(const char *name)
} }
/* Look up a command entry by name. */ /* Look up a command entry by name. */
static const struct cmd_entry * const struct cmd_entry *
cmd_find(const char *name, char **cause) cmd_find(const char *name, char **cause)
{ {
const struct cmd_entry **loop, *entry, *found = NULL; const struct cmd_entry **loop, *entry, *found = NULL;
@@ -495,66 +509,72 @@ ambiguous:
/* Parse a single command from an argument vector. */ /* Parse a single command from an argument vector. */
struct cmd * struct cmd *
cmd_parse(int argc, char **argv, const char *file, u_int line, char **cause) cmd_parse(struct args_value *values, u_int count, const char *file, u_int line,
int parse_flags, char **cause)
{ {
const struct cmd_entry *entry; const struct cmd_entry *entry;
const char *name;
struct cmd *cmd; struct cmd *cmd;
struct args *args; struct args *args;
char *error = NULL;
if (argc == 0) { if (count == 0 || values[0].type != ARGS_STRING) {
xasprintf(cause, "no command"); xasprintf(cause, "no command");
return (NULL); return (NULL);
} }
name = argv[0]; entry = cmd_find(values[0].string, cause);
entry = cmd_find(name, cause);
if (entry == NULL) if (entry == NULL)
return (NULL); return (NULL);
cmd_log_argv(argc, argv, "%s: %s", __func__, entry->name);
args = args_parse(entry->args.template, argc, argv); args = args_parse(&entry->args, values, count, &error);
if (args == NULL) if (args == NULL && error == NULL) {
goto usage; xasprintf(cause, "usage: %s %s", entry->name, entry->usage);
if (entry->args.lower != -1 && args->argc < entry->args.lower) return (NULL);
goto usage; }
if (entry->args.upper != -1 && args->argc > entry->args.upper) if (args == NULL) {
goto usage; xasprintf(cause, "command %s: %s", entry->name, error);
free(error);
return (NULL);
}
cmd = xcalloc(1, sizeof *cmd); cmd = xcalloc(1, sizeof *cmd);
cmd->entry = entry; cmd->entry = entry;
cmd->args = args; cmd->args = args;
cmd->parse_flags = parse_flags;
if (file != NULL) if (file != NULL)
cmd->file = xstrdup(file); cmd->file = xstrdup(file);
cmd->line = line; cmd->line = line;
cmd->alias = NULL;
cmd->argc = argc;
cmd->argv = cmd_copy_argv(argc, argv);
return (cmd); return (cmd);
usage:
if (args != NULL)
args_free(args);
xasprintf(cause, "usage: %s %s", entry->name, entry->usage);
return (NULL);
} }
/* Free a command. */ /* Free a command. */
void void
cmd_free(struct cmd *cmd) cmd_free(struct cmd *cmd)
{ {
free(cmd->alias);
cmd_free_argv(cmd->argc, cmd->argv);
free(cmd->file); free(cmd->file);
args_free(cmd->args); args_free(cmd->args);
free(cmd); free(cmd);
} }
/* Copy a command. */
struct cmd *
cmd_copy(struct cmd *cmd, int argc, char **argv)
{
struct cmd *new_cmd;
new_cmd = xcalloc(1, sizeof *new_cmd);
new_cmd->entry = cmd->entry;
new_cmd->args = args_copy(cmd->args, argc, argv);
if (cmd->file != NULL)
new_cmd->file = xstrdup(cmd->file);
new_cmd->line = cmd->line;
return (new_cmd);
}
/* Get a command as a string. */ /* Get a command as a string. */
char * char *
cmd_print(struct cmd *cmd) cmd_print(struct cmd *cmd)
@@ -593,7 +613,18 @@ cmd_list_append(struct cmd_list *cmdlist, struct cmd *cmd)
TAILQ_INSERT_TAIL(cmdlist->list, cmd, qentry); TAILQ_INSERT_TAIL(cmdlist->list, cmd, qentry);
} }
/* Move all commands from one command list to another */ /* Append all commands from one list to another. */
void
cmd_list_append_all(struct cmd_list *cmdlist, struct cmd_list *from)
{
struct cmd *cmd;
TAILQ_FOREACH(cmd, from->list, qentry)
cmd->group = cmdlist->group;
TAILQ_CONCAT(cmdlist->list, from->list, qentry);
}
/* Move all commands from one command list to another. */
void void
cmd_list_move(struct cmd_list *cmdlist, struct cmd_list *from) cmd_list_move(struct cmd_list *cmdlist, struct cmd_list *from)
{ {
@@ -618,13 +649,49 @@ cmd_list_free(struct cmd_list *cmdlist)
free(cmdlist); free(cmdlist);
} }
/* Copy a command list, expanding %s in arguments. */
struct cmd_list *
cmd_list_copy(const struct cmd_list *cmdlist, int argc, char **argv)
{
struct cmd *cmd;
struct cmd_list *new_cmdlist;
struct cmd *new_cmd;
u_int group = cmdlist->group;
char *s;
s = cmd_list_print(cmdlist, 0);
log_debug("%s: %s", __func__, s);
free(s);
new_cmdlist = cmd_list_new();
TAILQ_FOREACH(cmd, cmdlist->list, qentry) {
if (cmd->group != group) {
new_cmdlist->group = cmd_list_next_group++;
group = cmd->group;
}
new_cmd = cmd_copy(cmd, argc, argv);
cmd_list_append(new_cmdlist, new_cmd);
}
s = cmd_list_print(new_cmdlist, 0);
log_debug("%s: %s", __func__, s);
free(s);
return (new_cmdlist);
}
/* Get a command list as a string. */ /* Get a command list as a string. */
char * char *
cmd_list_print(struct cmd_list *cmdlist, int escaped) cmd_list_print(const struct cmd_list *cmdlist, int flags)
{ {
struct cmd *cmd, *next; struct cmd *cmd, *next;
char *buf, *this; char *buf, *this;
size_t len; size_t len;
const char *separator;
int escaped = flags & CMD_LIST_PRINT_ESCAPED;
int no_groups = flags & CMD_LIST_PRINT_NO_GROUPS;
const char *single_separator = escaped ? " \\; " : " ; ";
const char *double_separator = escaped ? " \\;\\; " : " ;; ";
len = 1; len = 1;
buf = xcalloc(1, len); buf = xcalloc(1, len);
@@ -639,17 +706,11 @@ cmd_list_print(struct cmd_list *cmdlist, int escaped)
next = TAILQ_NEXT(cmd, qentry); next = TAILQ_NEXT(cmd, qentry);
if (next != NULL) { if (next != NULL) {
if (cmd->group != next->group) { if (!no_groups && cmd->group != next->group)
if (escaped) separator = double_separator;
strlcat(buf, " \\;\\; ", len); else
else separator = single_separator;
strlcat(buf, " ;; ", len); strlcat(buf, separator, len);
} else {
if (escaped)
strlcat(buf, " \\; ", len);
else
strlcat(buf, " ; ", len);
}
} }
free(this); free(this);
@@ -717,9 +778,9 @@ cmd_mouse_at(struct window_pane *wp, struct mouse_event *m, u_int *xp,
if (m->statusat == 0 && y >= m->statuslines) if (m->statusat == 0 && y >= m->statuslines)
y -= m->statuslines; y -= m->statuslines;
if (x < wp->xoff || x >= wp->xoff + wp->sx) if ((int)x < wp->xoff || (int)x >= wp->xoff + (int)wp->sx)
return (-1); return (-1);
if (y < wp->yoff || y >= wp->yoff + wp->sy) if ((int)y < wp->yoff || (int)y >= wp->yoff + (int)wp->sy)
return (-1); return (-1);
if (xp != NULL) if (xp != NULL)
@@ -763,9 +824,15 @@ cmd_mouse_pane(struct mouse_event *m, struct session **sp,
if ((wl = cmd_mouse_window(m, sp)) == NULL) if ((wl = cmd_mouse_window(m, sp)) == NULL)
return (NULL); return (NULL);
if ((wp = window_pane_find_by_id(m->wp)) == NULL) if (m->wp == -1)
return (NULL); wp = wl->window->active;
if (!window_has_pane(wl->window, wp)) else {
if ((wp = window_pane_find_by_id(m->wp)) == NULL)
return (NULL);
if (!window_has_pane(wl->window, wp))
return (NULL);
}
if (wl->window->modal != NULL && wp != wl->window->modal)
return (NULL); return (NULL);
if (wlp != NULL) if (wlp != NULL)
@@ -773,14 +840,19 @@ cmd_mouse_pane(struct mouse_event *m, struct session **sp,
return (wp); return (wp);
} }
/* Replace the first %% or %idx in template by s. */ /*
* Replace the first %% or any %idx in template by s. %% is intended for use in
* single quotes, so ' is escaped. %%% and %idx% are for double quotes, so a
* list of special characters is escaped. %idx is left unescaped.
*/
char * char *
cmd_template_replace(const char *template, const char *s, int idx) cmd_template_replace(const char *template, const char *s, int idx)
{ {
char ch, *buf; char ch, *buf;
const char *ptr, *cp, quote[] = "\"\\$;~"; const char *ptr, *cp, dquote[] = "\"\\$;~";
int replaced, quoted; int replaced;
size_t len; size_t len, slen;
enum { NQ, SQ, DQ } quote;
if (strchr(template, '%') == NULL) if (strchr(template, '%') == NULL)
return (xstrdup(template)); return (xstrdup(template));
@@ -794,30 +866,52 @@ cmd_template_replace(const char *template, const char *s, int idx)
while (*ptr != '\0') { while (*ptr != '\0') {
switch (ch = *ptr++) { switch (ch = *ptr++) {
case '%': case '%':
if (*ptr < '1' || *ptr > '9' || *ptr - '0' != idx) { if (*ptr >= '1' && *ptr <= '9' && *ptr - '0' == idx) {
ptr++;
quote = NQ;
if (*ptr == '%') {
quote = DQ;
ptr++;
}
} else {
if (*ptr != '%' || replaced) if (*ptr != '%' || replaced)
break; break;
replaced = 1; replaced = 1;
}
ptr++;
quoted = (*ptr == '%');
if (quoted)
ptr++; ptr++;
quote = SQ;
if (*ptr == '%') {
quote = DQ;
ptr++;
}
}
buf = xrealloc(buf, len + (strlen(s) * 3) + 1); slen = strlen(s);
if (slen >= SIZE_MAX / 4 ||
len > SIZE_MAX - (slen * 4) - 1)
fatalx("argument too long");
buf = xrealloc(buf, len + (slen * 4) + 1);
for (cp = s; *cp != '\0'; cp++) { for (cp = s; *cp != '\0'; cp++) {
if (quoted && strchr(quote, *cp) != NULL) if (quote == SQ && *cp == '\'') {
buf[len++] = '\'';
buf[len++] = '\\';
buf[len++] = '\'';
buf[len++] = '\'';
continue;
}
if (quote == DQ && strchr(dquote, *cp) != NULL)
buf[len++] = '\\'; buf[len++] = '\\';
buf[len++] = *cp; buf[len++] = *cp;
} }
buf[len] = '\0'; buf[len] = '\0';
continue; continue;
} }
if (len > SIZE_MAX - 2)
fatalx("argument too long");
buf = xrealloc(buf, len + 2); buf = xrealloc(buf, len + 2);
buf[len++] = ch; buf[len++] = ch;
buf[len] = '\0'; buf[len] = '\0';
} }
log_debug("%s: %s -> %s", __func__, template, buf);
return (buf); return (buf);
} }

389
colour.c
View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */ /* $OpenBSD: colour.c,v 1.35 2026/07/06 14:29:10 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -26,6 +26,85 @@
#include "tmux.h" #include "tmux.h"
/* Theme colour slots and their server options. */
static const struct {
const char *name;
const char *dark_option;
const char *light_option;
int terminal_colour;
} colour_theme_table[] = {
{ "themeblack",
"dark-theme-black",
"light-theme-black",
0
},
{ "themewhite",
"dark-theme-white",
"light-theme-white",
7
},
{ "themelightgrey",
"dark-theme-light-grey",
"light-theme-light-grey",
7
},
{ "themedarkgrey",
"dark-theme-dark-grey",
"light-theme-dark-grey",
0
},
{ "themegreen",
"dark-theme-green",
"light-theme-green",
2
},
{ "themeyellow",
"dark-theme-yellow",
"light-theme-yellow",
3
},
{ "themered",
"dark-theme-red",
"light-theme-red",
1
},
{ "themeblue",
"dark-theme-blue",
"light-theme-blue",
4
},
{ "themecyan",
"dark-theme-cyan",
"light-theme-cyan",
6
},
{ "thememagenta",
"dark-theme-magenta",
"light-theme-magenta",
5
}
};
/* Get theme colour option. */
const char *
colour_theme_option(u_int n, enum client_theme theme)
{
if (n >= nitems(colour_theme_table))
return (NULL);
if (theme == THEME_LIGHT)
return (colour_theme_table[n].light_option);
return (colour_theme_table[n].dark_option);
}
/* Get theme terminal colour. */
int
colour_theme_terminal_colour(u_int n)
{
if (n >= nitems(colour_theme_table))
return (8);
return (colour_theme_table[n].terminal_colour);
}
static int static int
colour_dist_sq(int R, int G, int B, int r, int g, int b) colour_dist_sq(int R, int G, int B, int r, int g, int b)
{ {
@@ -105,6 +184,43 @@ colour_split_rgb(int c, u_char *r, u_char *g, u_char *b)
*b = c & 0xff; *b = c & 0xff;
} }
/* Force colour to RGB if not already. */
int
colour_force_rgb(int c)
{
if (c & COLOUR_FLAG_RGB)
return (c);
if (c & COLOUR_FLAG_256)
return (colour_256toRGB(c));
if (c >= 0 && c <= 7)
return (colour_256toRGB(c));
if (c >= 90 && c <= 97)
return (colour_256toRGB(8 + c - 90));
return (-1);
}
/* Dim colour by a percentage. */
int
colour_dim(int c, u_int dim)
{
u_char r, g, b;
if (dim == 0 || COLOUR_DEFAULT(c) || (c & COLOUR_FLAG_THEME))
return (c);
if (dim >= 100)
return (colour_join_rgb(0, 0, 0));
c = colour_force_rgb(c);
if (c == -1)
return (-1);
colour_split_rgb(c, &r, &g, &b);
r = (r * (100 - dim)) / 100;
g = (g * (100 - dim)) / 100;
b = (b * (100 - dim)) / 100;
return (colour_join_rgb(r, g, b));
}
/* Convert colour to a string. */ /* Convert colour to a string. */
const char * const char *
colour_tostring(int c) colour_tostring(int c)
@@ -113,7 +229,14 @@ colour_tostring(int c)
u_char r, g, b; u_char r, g, b;
if (c == -1) if (c == -1)
return ("none");
if (c & COLOUR_FLAG_THEME) {
c &= 0xff;
if (c >= 0 && (u_int)c < nitems(colour_theme_table))
return (colour_theme_table[c].name);
return ("invalid"); return ("invalid");
}
if (c & COLOUR_FLAG_RGB) { if (c & COLOUR_FLAG_RGB) {
colour_split_rgb(c, &r, &g, &b); colour_split_rgb(c, &r, &g, &b);
@@ -167,6 +290,98 @@ colour_tostring(int c)
return ("invalid"); return ("invalid");
} }
/* Convert colour to an SGR escape sequence. */
const char *
colour_toescape(struct client *c, int colour, int bg)
{
static char s[32];
u_char r, g, b;
int n, flags = (TERM_256COLOURS|TERM_RGBCOLOURS);
u_int o = (bg ? 40 : 30);
if (c != NULL && (c->tty.flags & TTY_OPENED) && c->tty.term != NULL)
flags = c->tty.term->flags;
if (colour & COLOUR_FLAG_THEME) {
n = colour & 0xff;
if (c != NULL && (u_int)n < COLOUR_THEME_COUNT)
colour = c->theme_colours[n];
else
colour = colour_theme_terminal_colour(n);
}
if (colour == 8 || colour == 9) {
xsnprintf(s, sizeof s, "\033[%dm", o + 9);
return (s);
}
if ((~flags & TERM_RGBCOLOURS) & (colour & COLOUR_FLAG_RGB)) {
colour_split_rgb(colour, &r, &g, &b);
colour = colour_find_rgb(r, g, b);
}
if ((~flags & TERM_256COLOURS) & (colour & COLOUR_FLAG_256))
colour = colour_256to16(colour);
if (colour & COLOUR_FLAG_RGB) {
colour_split_rgb(colour, &r, &g, &b);
xsnprintf(s, sizeof s, "\033[%d;2;%u;%u;%um", o + 8, r, g, b);
return (s);
}
if (colour & COLOUR_FLAG_256) {
xsnprintf(s, sizeof s, "\033[%d;5;%um", o + 8, colour & 0xff);
return (s);
}
if (colour >= 0 && colour <= 7) {
xsnprintf(s, sizeof s, "\033[%dm", colour + o);
return (s);
}
if (colour >= 90 && colour <= 97) {
xsnprintf(s, sizeof s, "\033[%dm", colour + o - 30);
return (s);
}
return (NULL);
}
/* Convert background colour to theme. */
enum client_theme
colour_totheme(int c)
{
int r, g, b, brightness;
if (c == -1)
return (THEME_UNKNOWN);
if (c & COLOUR_FLAG_RGB) {
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
brightness = r + g + b;
if (brightness > 382)
return (THEME_LIGHT);
return (THEME_DARK);
}
if (c & COLOUR_FLAG_256)
return (colour_totheme(colour_256toRGB(c)));
switch (c) {
case 0:
case 90:
return (THEME_DARK);
case 7:
case 97:
return (THEME_LIGHT);
default:
if (c >= 0 && c <= 7)
return (colour_totheme(colour_256toRGB(c)));
if (c >= 90 && c <= 97)
return (colour_totheme(colour_256toRGB(8 + c - 90)));
break;
}
return (THEME_UNKNOWN);
}
/* Convert colour from string. */ /* Convert colour from string. */
int int
colour_fromstring(const char *s) colour_fromstring(const char *s)
@@ -175,6 +390,7 @@ colour_fromstring(const char *s)
const char *cp; const char *cp;
int n; int n;
u_char r, g, b; u_char r, g, b;
u_int i;
if (*s == '#' && strlen(s) == 7) { if (*s == '#' && strlen(s) == 7) {
for (cp = s + 1; isxdigit((u_char) *cp); cp++) for (cp = s + 1; isxdigit((u_char) *cp); cp++)
@@ -205,6 +421,11 @@ colour_fromstring(const char *s)
if (strcasecmp(s, "terminal") == 0) if (strcasecmp(s, "terminal") == 0)
return (9); return (9);
for (i = 0; i < nitems(colour_theme_table); i++) {
if (strcasecmp(s, colour_theme_table[i].name) == 0)
return (i|COLOUR_FLAG_THEME);
}
if (strcasecmp(s, "black") == 0 || strcmp(s, "0") == 0) if (strcasecmp(s, "black") == 0 || strcmp(s, "0") == 0)
return (0); return (0);
if (strcasecmp(s, "red") == 0 || strcmp(s, "1") == 0) if (strcasecmp(s, "red") == 0 || strcmp(s, "1") == 0)
@@ -927,13 +1148,18 @@ colour_byname(const char *name)
{ "yellow3", 0xcdcd00 }, { "yellow3", 0xcdcd00 },
{ "yellow4", 0x8b8b00 } { "yellow4", 0x8b8b00 }
}; };
u_int i; u_int i;
int c; int c;
const char *errstr;
if (strncmp(name, "grey", 4) == 0 || strncmp(name, "gray", 4) == 0) { if (strncasecmp(name, "grey", 4) == 0 ||
if (!isdigit((u_char)name[4])) strncasecmp(name, "gray", 4) == 0) {
if (name[4] == '\0')
return (0xbebebe|COLOUR_FLAG_RGB); return (0xbebebe|COLOUR_FLAG_RGB);
c = round(2.55 * atoi(name + 4)); c = strtonum(name + 4, 0, 100, &errstr);
if (errstr != NULL)
return (-1);
c = round(2.55 * c);
if (c < 0 || c > 255) if (c < 0 || c > 255)
return (-1); return (-1);
return (colour_join_rgb(c, c, c)); return (colour_join_rgb(c, c, c));
@@ -944,3 +1170,154 @@ colour_byname(const char *name)
} }
return (-1); return (-1);
} }
/* Parse colour from an X11 string. */
int
colour_parseX11(const char *p)
{
double c, m, y, k = 0;
u_int r, g, b;
size_t len = strlen(p);
int colour = -1;
char *copy;
if ((len == 12 && sscanf(p, "rgb:%02x/%02x/%02x", &r, &g, &b) == 3) ||
(len == 7 && sscanf(p, "#%02x%02x%02x", &r, &g, &b) == 3) ||
sscanf(p, "%d,%d,%d", &r, &g, &b) == 3)
colour = colour_join_rgb(r, g, b);
else if ((len == 18 &&
sscanf(p, "rgb:%04x/%04x/%04x", &r, &g, &b) == 3) ||
(len == 13 && sscanf(p, "#%04x%04x%04x", &r, &g, &b) == 3))
colour = colour_join_rgb(r >> 8, g >> 8, b >> 8);
else if ((sscanf(p, "cmyk:%lf/%lf/%lf/%lf", &c, &m, &y, &k) == 4 ||
sscanf(p, "cmy:%lf/%lf/%lf", &c, &m, &y) == 3) &&
c >= 0 && c <= 1 && m >= 0 && m <= 1 &&
y >= 0 && y <= 1 && k >= 0 && k <= 1) {
colour = colour_join_rgb(
(1 - c) * (1 - k) * 255,
(1 - m) * (1 - k) * 255,
(1 - y) * (1 - k) * 255);
} else {
while (len != 0 && *p == ' ') {
p++;
len--;
}
while (len != 0 && p[len - 1] == ' ')
len--;
copy = xstrndup(p, len);
colour = colour_byname(copy);
free(copy);
}
log_debug("%s: %s = %s", __func__, p, colour_tostring(colour));
return (colour);
}
/* Initialize palette. */
void
colour_palette_init(struct colour_palette *p)
{
p->fg = 8;
p->bg = 8;
p->palette = NULL;
p->default_palette = NULL;
}
/* Clear palette. */
void
colour_palette_clear(struct colour_palette *p)
{
if (p != NULL) {
p->fg = 8;
p->bg = 8;
free(p->palette);
p->palette = NULL;
}
}
/* Free a palette. */
void
colour_palette_free(struct colour_palette *p)
{
if (p != NULL) {
free(p->palette);
p->palette = NULL;
free(p->default_palette);
p->default_palette = NULL;
}
}
/* Get a colour from a palette. */
int
colour_palette_get(struct colour_palette *p, int n)
{
if (p == NULL)
return (-1);
if (n >= 90 && n <= 97)
n = 8 + n - 90;
else if (n & COLOUR_FLAG_256)
n &= ~COLOUR_FLAG_256;
else if (n >= 8)
return (-1);
if (p->palette != NULL && p->palette[n] != -1)
return (p->palette[n]);
if (p->default_palette != NULL && p->default_palette[n] != -1)
return (p->default_palette[n]);
return (-1);
}
/* Set a colour in a palette. */
int
colour_palette_set(struct colour_palette *p, int n, int c)
{
u_int i;
if (p == NULL || n < 0 || n > 255)
return (0);
if (c == -1 && p->palette == NULL)
return (0);
if (p->palette == NULL) {
p->palette = xcalloc(256, sizeof *p->palette);
for (i = 0; i < 256; i++)
p->palette[i] = -1;
}
p->palette[n] = c;
return (1);
}
/* Build palette defaults from an option. */
void
colour_palette_from_option(struct colour_palette *p, struct options *oo)
{
struct options_entry *o;
struct options_array_item *a;
union options_value *ov;
u_int i;
int c;
if (p == NULL)
return;
o = options_get(oo, "pane-colours");
if ((a = options_array_first(o)) == NULL) {
if (p->default_palette != NULL) {
free(p->default_palette);
p->default_palette = NULL;
}
return;
}
if (p->default_palette == NULL)
p->default_palette = xcalloc(256, sizeof *p->default_palette);
for (i = 0; i < 256; i++)
p->default_palette[i] = -1;
for (i = 0; i < 256; i++) {
ov = options_array_getv(o, "%u", i);
if (ov != NULL) {
c = ov->number;
p->default_palette[i] = c;
}
}
}

View File

@@ -38,6 +38,14 @@
#include <event2/bufferevent_compat.h> #include <event2/bufferevent_compat.h>
#else #else
#include <event.h> #include <event.h>
#ifndef EVBUFFER_EOL_LF
/*
* This doesn't really work because evbuffer_readline is broken, but gets us to
* build with very old (older than 1.4.14) libevent.
*/
#define EVBUFFER_EOL_LF
#define evbuffer_readln(a, b, c) evbuffer_readline(a)
#endif
#endif #endif
#ifdef HAVE_MALLOC_TRIM #ifdef HAVE_MALLOC_TRIM
@@ -289,6 +297,11 @@ void explicit_bzero(void *, size_t);
int getdtablecount(void); int getdtablecount(void);
#endif #endif
#ifndef HAVE_GETDTABLESIZE
/* getdtablesize.c */
int getdtablesize(void);
#endif
#ifndef HAVE_CLOSEFROM #ifndef HAVE_CLOSEFROM
/* closefrom.c */ /* closefrom.c */
void closefrom(int); void closefrom(int);
@@ -334,6 +347,23 @@ char *strndup(const char *, size_t);
void *memmem(const void *, size_t, const void *, size_t); void *memmem(const void *, size_t, const void *, size_t);
#endif #endif
#ifndef HAVE_HTONLL
/* htonll.c */
#undef htonll
uint64_t htonll(uint64_t);
#endif
#ifndef HAVE_NTOHLL
/* ntohll.c */
#undef ntohll
uint64_t ntohll(uint64_t);
#endif
#ifndef HAVE_GETPEEREID
/* getpeereid.c */
int getpeereid(int, uid_t *, gid_t *);
#endif
#ifndef HAVE_DAEMON #ifndef HAVE_DAEMON
/* daemon.c */ /* daemon.c */
int daemon(int, int); int daemon(int, int);
@@ -358,7 +388,7 @@ int clock_gettime(int, struct timespec *);
/* base64.c */ /* base64.c */
#undef b64_ntop #undef b64_ntop
#undef b64_pton #undef b64_pton
int b64_ntop(const char *, size_t, char *, size_t); int b64_ntop(const u_char *, size_t, char *, size_t);
int b64_pton(const char *, u_char *, size_t); int b64_pton(const char *, u_char *, size_t);
#endif #endif
@@ -380,11 +410,6 @@ int asprintf(char **, const char *, ...);
int vasprintf(char **, const char *, va_list); int vasprintf(char **, const char *, va_list);
#endif #endif
#ifndef HAVE_FGETLN
/* fgetln.c */
char *fgetln(FILE *, size_t *);
#endif
#ifndef HAVE_GETLINE #ifndef HAVE_GETLINE
/* getline.c */ /* getline.c */
ssize_t getline(char **, size_t *, FILE *); ssize_t getline(char **, size_t *, FILE *);
@@ -416,6 +441,13 @@ void *reallocarray(void *, size_t, size_t);
void *recallocarray(void *, size_t, size_t, size_t); void *recallocarray(void *, size_t, size_t, size_t);
#endif #endif
#ifdef HAVE_SYSTEMD
/* systemd.c */
int systemd_activated(void);
int systemd_create_socket(int, char **);
int systemd_move_to_new_cgroup(char **);
#endif
#ifdef HAVE_UTF8PROC #ifdef HAVE_UTF8PROC
/* utf8proc.c */ /* utf8proc.c */
int utf8proc_wcwidth(wchar_t); int utf8proc_wcwidth(wchar_t);
@@ -426,14 +458,17 @@ int utf8proc_wctomb(char *, wchar_t);
#ifdef NEED_FUZZING #ifdef NEED_FUZZING
/* tmux.c */ /* tmux.c */
#define main __weak main #define main __weak main
#define regcomp(preg, pattern, cflags) (0)
#define regexec(preg, string, nmatch, pmatch, eflags) (REG_NOMATCH)
#define regfree(preg) ((void)0)
#endif #endif
/* getopt.c */ /* getopt.c */
extern int BSDopterr; extern int BSDopterr;
extern int BSDoptind; extern int BSDoptind;
extern int BSDoptopt; extern int BSDoptopt;
extern int BSDoptreset; extern int BSDoptreset;
extern char *BSDoptarg; extern char *BSDoptarg;
int BSDgetopt(int, char *const *, const char *); int BSDgetopt(int, char *const *, const char *);
#define getopt(ac, av, o) BSDgetopt(ac, av, o) #define getopt(ac, av, o) BSDgetopt(ac, av, o)
#define opterr BSDopterr #define opterr BSDopterr

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: base64.c,v 1.8 2015/01/16 16:48:51 deraadt Exp $ */ /* $OpenBSD: base64.c,v 1.15 2021/10/25 14:41:09 jca Exp $ */
/* /*
* Copyright (c) 1996 by Internet Software Consortium. * Copyright (c) 1996 by Internet Software Consortium.
@@ -46,15 +46,15 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <arpa/nameser.h>
#include <ctype.h> #include <ctype.h>
#include <resolv.h> #include <resolv.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "compat.h"
static const char Base64[] = static const char Base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char Pad64 = '='; static const char Pad64 = '=';
@@ -107,9 +107,9 @@ static const char Pad64 = '=';
end of the data is performed using the '=' character. end of the data is performed using the '=' character.
Since all base64 input is an integral number of octets, only the Since all base64 input is an integral number of octets, only the
------------------------------------------------- -------------------------------------------------
following cases can arise: following cases can arise:
(1) the final quantum of encoding input is an integral (1) the final quantum of encoding input is an integral
multiple of 24 bits; here, the final unit of encoded multiple of 24 bits; here, the final unit of encoded
output will be an integral multiple of 4 characters output will be an integral multiple of 4 characters
@@ -123,15 +123,12 @@ static const char Pad64 = '=';
*/ */
int int
b64_ntop(src, srclength, target, targsize) b64_ntop(unsigned char const *src, size_t srclength, char *target,
u_char const *src; size_t targsize)
size_t srclength;
char *target;
size_t targsize;
{ {
size_t datalength = 0; size_t datalength = 0;
u_char input[3]; unsigned char input[3];
u_char output[4]; unsigned char output[4];
int i; int i;
while (2 < srclength) { while (2 < srclength) {
@@ -152,14 +149,14 @@ b64_ntop(src, srclength, target, targsize)
target[datalength++] = Base64[output[2]]; target[datalength++] = Base64[output[2]];
target[datalength++] = Base64[output[3]]; target[datalength++] = Base64[output[3]];
} }
/* Now we worry about padding. */ /* Now we worry about padding. */
if (0 != srclength) { if (0 != srclength) {
/* Get what's left. */ /* Get what's left. */
input[0] = input[1] = input[2] = '\0'; input[0] = input[1] = input[2] = '\0';
for (i = 0; i < srclength; i++) for (i = 0; i < srclength; i++)
input[i] = *src++; input[i] = *src++;
output[0] = input[0] >> 2; output[0] = input[0] >> 2;
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
@@ -187,13 +184,10 @@ b64_ntop(src, srclength, target, targsize)
*/ */
int int
b64_pton(src, target, targsize) b64_pton(char const *src, unsigned char *target, size_t targsize)
char const *src;
u_char *target;
size_t targsize;
{ {
int tarindex, state, ch; int tarindex, state, ch;
u_char nextbyte; unsigned char nextbyte;
char *pos; char *pos;
state = 0; state = 0;
@@ -207,7 +201,7 @@ b64_pton(src, target, targsize)
break; break;
pos = strchr(Base64, ch); pos = strchr(Base64, ch);
if (pos == 0) /* A non-base64 character. */ if (pos == 0) /* A non-base64 character. */
return (-1); return (-1);
switch (state) { switch (state) {

View File

@@ -27,7 +27,7 @@
#endif #endif
int int
clock_gettime(int clock, struct timespec *ts) clock_gettime(__unused int clock, struct timespec *ts)
{ {
struct timeval tv; struct timeval tv;

View File

@@ -49,12 +49,12 @@
#include <mach/mach.h> #include <mach/mach.h>
#include <Availability.h> #include <AvailabilityMacros.h>
#include <unistd.h> #include <unistd.h>
void daemon_darwin(void); void daemon_darwin(void);
#ifdef __MAC_10_10 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
extern kern_return_t bootstrap_look_up_per_user(mach_port_t, const char *, extern kern_return_t bootstrap_look_up_per_user(mach_port_t, const char *,
uid_t, mach_port_t *); uid_t, mach_port_t *);

View File

@@ -1,61 +0,0 @@
/*
* Copyright (c) 2015 Joerg Jung <jung@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* portable fgetln() version, NOT reentrant
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "compat.h"
char *
fgetln(FILE *fp, size_t *len)
{
static char *buf = NULL;
static size_t bufsz = 0;
size_t r = 0;
char *p;
int c, e;
if (!fp || !len) {
errno = EINVAL;
return NULL;
}
if (!buf) {
if (!(buf = calloc(1, BUFSIZ)))
return NULL;
bufsz = BUFSIZ;
}
while ((c = getc(fp)) != EOF) {
buf[r++] = c;
if (r == bufsz) {
if (!(p = reallocarray(buf, 2, bufsz))) {
e = errno;
free(buf);
errno = e;
buf = NULL, bufsz = 0;
return NULL;
}
buf = p, bufsz = 2 * bufsz;
}
if (c == '\n')
break;
}
return (*len = r) ? buf : NULL;
}

View File

@@ -18,13 +18,28 @@
#include <glob.h> #include <glob.h>
#include <unistd.h> #include <unistd.h>
#if defined(HAVE_LIBPROC_H)
#include <libproc.h>
#endif
#include "compat.h" #include "compat.h"
void fatal(const char *, ...); void fatal(const char *, ...);
void fatalx(const char *, ...); void fatalx(const char *, ...);
#ifdef HAVE_PROC_PID #if defined(HAVE_LIBPROC_H) && defined(HAVE_PROC_PIDINFO)
int
getdtablecount(void)
{
int sz;
pid_t pid = getpid();
sz = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0);
if (sz == -1)
return (0);
return (sz / PROC_PIDLISTFD_SIZE);
}
#elif defined(HAVE_PROC_PID)
int int
getdtablecount(void) getdtablecount(void)
{ {

View File

@@ -74,8 +74,14 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
} }
if (ptr + 2 >= eptr) { if (ptr + 2 >= eptr) {
char *nbuf; char *nbuf;
size_t nbufsiz = *bufsiz * 2; size_t nbufsiz;
ssize_t d = ptr - *buf; ssize_t d = ptr - *buf;
if (*bufsiz > SIZE_MAX / 2) {
errno = EOVERFLOW;
return -1;
}
nbufsiz = *bufsiz * 2;
if ((nbuf = realloc(*buf, nbufsiz)) == NULL) if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
return -1; return -1;
*buf = nbuf; *buf = nbuf;

View File

@@ -1,115 +0,0 @@
/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* OPENBSD ORIGINAL: lib/libc/stdlib/getopt.c */
#include "compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int BSDopterr = 1, /* if error message should be printed */
BSDoptind = 1, /* index into parent argv vector */
BSDoptopt, /* character checked for validity */
BSDoptreset; /* reset getopt */
char *BSDoptarg; /* argument associated with option */
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
/*
* getopt --
* Parse argc/argv argument vector.
*/
int
BSDgetopt(int nargc, char *const *nargv, const char *ostr)
{
static const char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
if (ostr == NULL)
return (-1);
if (BSDoptreset || !*place) { /* update scanning pointer */
BSDoptreset = 0;
if (BSDoptind >= nargc || *(place = nargv[BSDoptind]) != '-') {
place = EMSG;
return (-1);
}
if (place[1] && *++place == '-') { /* found "--" */
if (place[1])
return (BADCH);
++BSDoptind;
place = EMSG;
return (-1);
}
} /* option letter okay? */
if ((BSDoptopt = (int)*place++) == (int)':' ||
!(oli = strchr(ostr, BSDoptopt))) {
/*
* if the user didn't specify '-' as an option,
* assume it means -1.
*/
if (BSDoptopt == (int)'-')
return (-1);
if (!*place)
++BSDoptind;
if (BSDopterr && *ostr != ':')
(void)fprintf(stderr,
"%s: unknown option -- %c\n", getprogname(),
BSDoptopt);
return (BADCH);
}
if (*++oli != ':') { /* don't need argument */
BSDoptarg = NULL;
if (!*place)
++BSDoptind;
}
else { /* need an argument */
if (*place) /* no white space */
BSDoptarg = (char *)place;
else if (nargc <= ++BSDoptind) { /* no arg */
place = EMSG;
if (*ostr == ':')
return (BADARG);
if (BSDopterr)
(void)fprintf(stderr,
"%s: option requires an argument -- %c\n",
getprogname(), BSDoptopt);
return (BADCH);
}
else /* white space */
BSDoptarg = nargv[BSDoptind];
place = EMSG;
++BSDoptind;
}
return (BSDoptopt); /* dump back option letter */
}

577
compat/getopt_long.c Normal file
View File

@@ -0,0 +1,577 @@
/* This file is obtained from OpenSSH:
* Repository: https://github.com/openssh/openssh-portable
* Commit: b5b405fee7f3e79d44e2d2971a4b6b4cc53f112e
* File: /openbsd-compat/getopt_long.c */
/*
* Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Sponsored in part by the Defense Advanced Research Projects
* Agency (DARPA) and Air Force Research Laboratory, Air Force
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Dieter Baron and Thomas Klausner.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* OPENBSD ORIGINAL: lib/libc/stdlib/getopt_long.c */
#include "compat.h"
/* The following macro constants are taken from getopt.h of OpenSSH:
* Repository: https://github.com/openssh/openssh-portable
* Commit: b5b405fee7f3e79d44e2d2971a4b6b4cc53f112e
* File: /openbsd-compat/getopt.h
*
* ---- BEGIN - Copyright notice and license of getopt.h ----
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Dieter Baron and Thomas Klausner.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* ---- END ----
*/
#define no_argument 0
#define required_argument 1
#define optional_argument 2
#if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET)
#if 0
#include <err.h>
#include <getopt.h>
#endif
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
struct option {
/* name of long option */
const char *name;
/*
* one of no_argument, required_argument, and optional_argument:
* whether option takes an argument
*/
int has_arg;
/* if not NULL, set *flag to val when option found */
int *flag;
/* if flag not NULL, value to set *flag to; else return value */
int val;
};
int opterr = 1; /* if error message should be printed */
int optind = 1; /* index into parent argv vector */
int optopt = '?'; /* character checked for validity */
int optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#define PRINT_ERROR ((opterr) && (*options != ':'))
#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
/* return values */
#define BADCH (int)'?'
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1
#define EMSG (char *)""
static int getopt_internal(int, char * const *, const char *,
const struct option *, int *, int);
static int parse_long_options(char * const *, const char *,
const struct option *, int *, int);
static int gcd(int, int);
static void permute_args(int, int, int, char * const *);
static char *place = EMSG; /* option letter processing */
/* XXX: set optreset to 1 rather than these two */
static int nonopt_start = -1; /* first non option argument (for permute) */
static int nonopt_end = -1; /* first option after non options (for permute) */
/* Error messages */
static const char recargchar[] = "option requires an argument -- %c";
static const char recargstring[] = "option requires an argument -- %s";
static const char ambig[] = "ambiguous option -- %.*s";
static const char noarg[] = "option doesn't take an argument -- %.*s";
static const char illoptchar[] = "unknown option -- %c";
static const char illoptstring[] = "unknown option -- %s";
/*
* Compute the greatest common divisor of a and b.
*/
static int
gcd(int a, int b)
{
int c;
c = a % b;
while (c != 0) {
a = b;
b = c;
c = a % b;
}
return (b);
}
/*
* Exchange the block from nonopt_start to nonopt_end with the block
* from nonopt_end to opt_end (keeping the same order of arguments
* in each block).
*/
static void
permute_args(int panonopt_start, int panonopt_end, int opt_end,
char * const *nargv)
{
int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
char *swap;
/*
* compute lengths of blocks and number and size of cycles
*/
nnonopts = panonopt_end - panonopt_start;
nopts = opt_end - panonopt_end;
ncycle = gcd(nnonopts, nopts);
cyclelen = (opt_end - panonopt_start) / ncycle;
for (i = 0; i < ncycle; i++) {
cstart = panonopt_end+i;
pos = cstart;
for (j = 0; j < cyclelen; j++) {
if (pos >= panonopt_end)
pos -= nnonopts;
else
pos += nopts;
swap = nargv[pos];
/* LINTED const cast */
((char **) nargv)[pos] = nargv[cstart];
/* LINTED const cast */
((char **)nargv)[cstart] = swap;
}
}
}
/*
* parse_long_options --
* Parse long options in argc/argv argument vector.
* Returns -1 if short_too is set and the option does not match long_options.
*/
static int
parse_long_options(char * const *nargv, const char *options,
const struct option *long_options, int *idx, int short_too)
{
char *current_argv, *has_equal;
size_t current_argv_len;
int i, match;
current_argv = place;
match = -1;
optind++;
if ((has_equal = strchr(current_argv, '=')) != NULL) {
/* argument found (--option=arg) */
current_argv_len = has_equal - current_argv;
has_equal++;
} else
current_argv_len = strlen(current_argv);
for (i = 0; long_options[i].name; i++) {
/* find matching long option */
if (strncmp(current_argv, long_options[i].name,
current_argv_len))
continue;
if (strlen(long_options[i].name) == current_argv_len) {
/* exact match */
match = i;
break;
}
/*
* If this is a known short option, don't allow
* a partial match of a single character.
*/
if (short_too && current_argv_len == 1)
continue;
if (match == -1) /* partial match */
match = i;
else {
/* ambiguous abbreviation */
if (PRINT_ERROR)
warnx(ambig, (int)current_argv_len,
current_argv);
optopt = 0;
return (BADCH);
}
}
if (match != -1) { /* option found */
if (long_options[match].has_arg == no_argument
&& has_equal) {
if (PRINT_ERROR)
warnx(noarg, (int)current_argv_len,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
*/
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
return (BADARG);
}
if (long_options[match].has_arg == required_argument ||
long_options[match].has_arg == optional_argument) {
if (has_equal)
optarg = has_equal;
else if (long_options[match].has_arg ==
required_argument) {
/*
* optional argument doesn't use next nargv
*/
optarg = nargv[optind++];
}
}
if ((long_options[match].has_arg == required_argument)
&& (optarg == NULL)) {
/*
* Missing argument; leading ':' indicates no error
* should be generated.
*/
if (PRINT_ERROR)
warnx(recargstring,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
*/
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
--optind;
return (BADARG);
}
} else { /* unknown option */
if (short_too) {
--optind;
return (-1);
}
if (PRINT_ERROR)
warnx(illoptstring, current_argv);
optopt = 0;
return (BADCH);
}
if (idx)
*idx = match;
if (long_options[match].flag) {
*long_options[match].flag = long_options[match].val;
return (0);
} else
return (long_options[match].val);
}
/*
* getopt_internal --
* Parse argc/argv argument vector. Called by user level routines.
*/
static int
getopt_internal(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx, int flags)
{
const char *oli; /* option letter list index */
int optchar, short_too;
static int posixly_correct = -1;
if (options == NULL)
return (-1);
/*
* XXX Some GNU programs (like cvs) set optind to 0 instead of
* XXX using optreset. Work around this braindamage.
*/
if (optind == 0)
optind = optreset = 1;
/*
* Disable GNU extensions if POSIXLY_CORRECT is set or options
* string begins with a '+'.
*/
if (posixly_correct == -1 || optreset)
posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
if (*options == '-')
flags |= FLAG_ALLARGS;
else if (posixly_correct || *options == '+')
flags &= ~FLAG_PERMUTE;
if (*options == '+' || *options == '-')
options++;
optarg = NULL;
if (optreset)
nonopt_start = nonopt_end = -1;
start:
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc) { /* end of argument vector */
place = EMSG;
if (nonopt_end != -1) {
/* do permutation, if we have to */
permute_args(nonopt_start, nonopt_end,
optind, nargv);
optind -= nonopt_end - nonopt_start;
}
else if (nonopt_start != -1) {
/*
* If we skipped non-options, set optind
* to the first of them.
*/
optind = nonopt_start;
}
nonopt_start = nonopt_end = -1;
return (-1);
}
if (*(place = nargv[optind]) != '-' ||
(place[1] == '\0' && strchr(options, '-') == NULL)) {
place = EMSG; /* found non-option */
if (flags & FLAG_ALLARGS) {
/*
* GNU extension:
* return non-option as argument to option 1
*/
optarg = nargv[optind++];
return (INORDER);
}
if (!(flags & FLAG_PERMUTE)) {
/*
* If no permutation wanted, stop parsing
* at first non-option.
*/
return (-1);
}
/* do permutation */
if (nonopt_start == -1)
nonopt_start = optind;
else if (nonopt_end != -1) {
permute_args(nonopt_start, nonopt_end,
optind, nargv);
nonopt_start = optind -
(nonopt_end - nonopt_start);
nonopt_end = -1;
}
optind++;
/* process next argument */
goto start;
}
if (nonopt_start != -1 && nonopt_end == -1)
nonopt_end = optind;
/*
* If we have "-" do nothing, if "--" we are done.
*/
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
optind++;
place = EMSG;
/*
* We found an option (--), so if we skipped
* non-options, we have to permute.
*/
if (nonopt_end != -1) {
permute_args(nonopt_start, nonopt_end,
optind, nargv);
optind -= nonopt_end - nonopt_start;
}
nonopt_start = nonopt_end = -1;
return (-1);
}
}
/*
* Check long options if:
* 1) we were passed some
* 2) the arg is not just "-"
* 3) either the arg starts with -- we are getopt_long_only()
*/
if (long_options != NULL && place != nargv[optind] &&
(*place == '-' || (flags & FLAG_LONGONLY))) {
short_too = 0;
if (*place == '-')
place++; /* --foo long option */
else if (*place != ':' && strchr(options, *place) != NULL)
short_too = 1; /* could be short option too */
optchar = parse_long_options(nargv, options, long_options,
idx, short_too);
if (optchar != -1) {
place = EMSG;
return (optchar);
}
}
if ((optchar = (int)*place++) == (int)':' ||
(optchar == (int)'-' && *place != '\0') ||
(oli = strchr(options, optchar)) == NULL) {
/*
* If the user specified "-" and '-' isn't listed in
* options, return -1 (non-option) as per POSIX.
* Otherwise, it is an unknown option character (or ':').
*/
if (optchar == (int)'-' && *place == '\0')
return (-1);
if (!*place)
++optind;
if (PRINT_ERROR)
warnx(illoptchar, optchar);
optopt = optchar;
return (BADCH);
}
if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
/* -W long-option */
if (*place) /* no space */
/* NOTHING */;
else if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
} else /* white space */
place = nargv[optind];
optchar = parse_long_options(nargv, options, long_options,
idx, 0);
place = EMSG;
return (optchar);
}
if (*++oli != ':') { /* doesn't take argument */
if (!*place)
++optind;
} else { /* takes (optional) argument */
optarg = NULL;
if (*place) /* no white space */
optarg = place;
else if (oli[1] != ':') { /* arg not optional */
if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
} else
optarg = nargv[optind];
}
place = EMSG;
++optind;
}
/* dump back option letter */
return (optchar);
}
/*
* getopt --
* Parse argc/argv argument vector.
*
* [eventually this will replace the BSD getopt]
*/
int
getopt(int nargc, char * const *nargv, const char *options)
{
/*
* We don't pass FLAG_PERMUTE to getopt_internal() since
* the BSD getopt(3) (unlike GNU) has never done this.
*
* Furthermore, since many privileged programs call getopt()
* before dropping privileges it makes sense to keep things
* as simple (and bug-free) as possible.
*/
return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
}
#if 0
/*
* getopt_long --
* Parse argc/argv argument vector.
*/
int
getopt_long(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx)
{
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE));
}
/*
* getopt_long_only --
* Parse argc/argv argument vector.
*/
int
getopt_long_only(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx)
{
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE|FLAG_LONGONLY));
}
#endif
#endif /* !defined(HAVE_GETOPT) || !defined(HAVE_OPTRESET) */

57
compat/getpeereid.c Normal file
View File

@@ -0,0 +1,57 @@
/*
* Copyright (c) 2022 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <unistd.h>
#ifdef HAVE_UCRED_H
#include <ucred.h>
#endif
#include "compat.h"
int
getpeereid(int s, uid_t *uid, gid_t *gid)
{
#ifdef HAVE_SO_PEERCRED
struct ucred uc;
int len = sizeof uc;
if (getsockopt(s, SOL_SOCKET, SO_PEERCRED, &uc, &len) == -1)
return (-1);
*uid = uc.uid;
*gid = uc.gid;
return (0);
#elif defined(HAVE_GETPEERUCRED)
ucred_t *ucred = NULL;
if (getpeerucred(s, &ucred) == -1)
return (-1);
if ((*uid = ucred_geteuid(ucred)) == -1)
return (-1);
if ((*gid = ucred_getrgid(ucred)) == -1)
return (-1);
ucred_free(ucred);
return (0);
#else
*uid = geteuid();
*gid = getegid();
return (0);
#endif
}

Some files were not shown because too many files have changed in this diff Show More