mirror of
https://github.com/tmux/tmux.git
synced 2026-09-16 10:11:57 +00:00
Compare commits
2238 Commits
3.3
...
image-redr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b3d0946b4 | ||
|
|
588dc54753 | ||
|
|
ec9859b15f | ||
|
|
3f5f9cab90 | ||
|
|
33bbd60d98 | ||
|
|
48658fd659 | ||
|
|
30abbe36a8 | ||
|
|
62044f02df | ||
|
|
a18d4e0067 | ||
|
|
0f241b7447 | ||
|
|
efaa1fe31c | ||
|
|
1729bb8e8a | ||
|
|
9fdd04ae61 | ||
|
|
87a8bda023 | ||
|
|
d384557b63 | ||
|
|
534a4f81fc | ||
|
|
a0d3585c6c | ||
|
|
ec34ff52cc | ||
|
|
1962365106 | ||
|
|
0ac8138ce3 | ||
|
|
c41cad4c5f | ||
|
|
870dba6664 | ||
|
|
6ef98552da | ||
|
|
f466d6289e | ||
|
|
a4abd61663 | ||
|
|
b263d13df0 | ||
|
|
dadc6ef69f | ||
|
|
001b10f2b3 | ||
|
|
a5808bf868 | ||
|
|
e97c3d697d | ||
|
|
c6a59c29ae | ||
|
|
0ac7289c48 | ||
|
|
7dfd835c3f | ||
|
|
bbcccee9fc | ||
|
|
4819dc34df | ||
|
|
6535274d98 | ||
|
|
9a3b71ac64 | ||
|
|
4c9523c814 | ||
|
|
7e6c49b5a5 | ||
|
|
468259933f | ||
|
|
4380fceb2b | ||
|
|
08c237f0cb | ||
|
|
5d0d6c29b4 | ||
|
|
64cea48f91 | ||
|
|
bc998ede98 | ||
|
|
5c496c765a | ||
|
|
3cd6526d46 | ||
|
|
1dacc18ce0 | ||
|
|
851c5a933d | ||
|
|
10048f6579 | ||
|
|
e3f6c1849d | ||
|
|
a598b2a910 | ||
|
|
2ec1038ffd | ||
|
|
a8dfb979e6 | ||
|
|
fb589fd9f9 | ||
|
|
945152029d | ||
|
|
8536e26517 | ||
|
|
cbb1da66c3 | ||
|
|
35ab660042 | ||
|
|
01d5c9f420 | ||
|
|
40a485db9c | ||
|
|
641e75e6e2 | ||
|
|
a35871110f | ||
|
|
cdff709ab3 | ||
|
|
2788616b6f | ||
|
|
51f1c0de51 | ||
|
|
045a25c89a | ||
|
|
abfd8cee51 | ||
|
|
ccc90ea220 | ||
|
|
2e394bef11 | ||
|
|
4a9dbac435 | ||
|
|
6cb01394ed | ||
|
|
6b8d581135 | ||
|
|
ab591ae430 | ||
|
|
d60dbcf91c | ||
|
|
bd483a63cf | ||
|
|
d06eb0bc2b | ||
|
|
2a0e47fef0 | ||
|
|
d5dc0ba855 | ||
|
|
e56a042153 | ||
|
|
1995b5559d | ||
|
|
fe384e06bc | ||
|
|
0198ee9e51 | ||
|
|
72e705cbd6 | ||
|
|
d5afb67a81 | ||
|
|
3894397b07 | ||
|
|
36381f0884 | ||
|
|
5cd1976a4a | ||
|
|
3d07d479db | ||
|
|
c9ae3f6a02 | ||
|
|
d2322d0114 | ||
|
|
7a431ec7b9 | ||
|
|
114aa68082 | ||
|
|
f07a76d959 | ||
|
|
ca0d77855f | ||
|
|
cd3f577c85 | ||
|
|
9228f97d7d | ||
|
|
6db5175e4e | ||
|
|
fba5ece05c | ||
|
|
01a775a46c | ||
|
|
4918360ea1 | ||
|
|
433a5cf580 | ||
|
|
ff9b3e5cd7 | ||
|
|
9416ffe9bf | ||
|
|
748fb9ff1c | ||
|
|
cfab0590a4 | ||
|
|
a4b8d1c822 | ||
|
|
7748e525a4 | ||
|
|
01db040717 | ||
|
|
fc9270c943 | ||
|
|
94f6f3b125 | ||
|
|
da6812d15f | ||
|
|
fa8c5789a6 | ||
|
|
791752ffff | ||
|
|
fe938ea657 | ||
|
|
cce56fa19b | ||
|
|
f68aad1b41 | ||
|
|
7225365b29 | ||
|
|
d50902b14d | ||
|
|
4c04fc805e | ||
|
|
27f12454a1 | ||
|
|
fe5f775f76 | ||
|
|
4da7f897ea | ||
|
|
9a2060db06 | ||
|
|
f4a57f8b95 | ||
|
|
31dccb6bc9 | ||
|
|
8dfb7d0294 | ||
|
|
265fb7b4ea | ||
|
|
fa38b36f1f | ||
|
|
44b8a40b8c | ||
|
|
5cd5df1d33 | ||
|
|
415d265728 | ||
|
|
d6c37ce314 | ||
|
|
c6d02d54d1 | ||
|
|
6f41dac898 | ||
|
|
5534f1ac32 | ||
|
|
9f2c535909 | ||
|
|
7cc0c11cde | ||
|
|
31fe1ded5d | ||
|
|
6a13d61b48 | ||
|
|
9c402fa7b7 | ||
|
|
a115ca68a5 | ||
|
|
a5ad1914b8 | ||
|
|
3c1b2969a8 | ||
|
|
e2a5ea2e78 | ||
|
|
27ab96b284 | ||
|
|
00b5323d5c | ||
|
|
f751d3f2c1 | ||
|
|
9b97dadc01 | ||
|
|
8ca512b502 | ||
|
|
5269e14113 | ||
|
|
ff214cf9a1 | ||
|
|
d57d75deee | ||
|
|
008a3f3f8b | ||
|
|
4cc45aa719 | ||
|
|
0255981a54 | ||
|
|
0a92ff6e76 | ||
|
|
3068ae06a8 | ||
|
|
55169f1275 | ||
|
|
afb95f3134 | ||
|
|
10726b1b27 | ||
|
|
0768795ce3 | ||
|
|
29bf7fe2f7 | ||
|
|
47f210a9d2 | ||
|
|
e361982acf | ||
|
|
cc7eea1e34 | ||
|
|
0ec289545a | ||
|
|
190b5bde16 | ||
|
|
8862390c34 | ||
|
|
c59230316b | ||
|
|
a2f3bdb601 | ||
|
|
689e6f8fac | ||
|
|
6049298140 | ||
|
|
a10ed3233c | ||
|
|
7568c19276 | ||
|
|
fb88172346 | ||
|
|
26bdd2b511 | ||
|
|
38feebb5d2 | ||
|
|
7428b0431a | ||
|
|
7277712ca8 | ||
|
|
2a5389416a | ||
|
|
597d04ed78 | ||
|
|
9625fe3b5f | ||
|
|
09a2ea190d | ||
|
|
18fc547b82 | ||
|
|
242239b561 | ||
|
|
bd4ac02994 | ||
|
|
0868435e81 | ||
|
|
7abb9af062 | ||
|
|
a57b0f1282 | ||
|
|
c59db2d007 | ||
|
|
8bf2a4e807 | ||
|
|
2848a12562 | ||
|
|
92f090c0c0 | ||
|
|
9d583cad5a | ||
|
|
abd2f3a9a5 | ||
|
|
3e61e63851 | ||
|
|
4d1cf62fb4 | ||
|
|
0e2576a842 | ||
|
|
418ddada23 | ||
|
|
8aaae25e56 | ||
|
|
5ed5e3606e | ||
|
|
d13b69ece4 | ||
|
|
88a91b9f83 | ||
|
|
efcfc55535 | ||
|
|
afb3e954bf | ||
|
|
aea209b142 | ||
|
|
8dd0e2129e | ||
|
|
8024fab1f2 | ||
|
|
c750c014b2 | ||
|
|
1b179582e6 | ||
|
|
c766669b3b | ||
|
|
c45bf2e84d | ||
|
|
6ef280fb0f | ||
|
|
2a2bce3dd4 | ||
|
|
cad1c81c71 | ||
|
|
496bfdce38 | ||
|
|
bacc7952ad | ||
|
|
377a810168 | ||
|
|
481d48b53b | ||
|
|
6dacc024f0 | ||
|
|
1ce000062a | ||
|
|
5bd10a8c2a | ||
|
|
2711780dff | ||
|
|
a177d0f590 | ||
|
|
a8ad3c7d43 | ||
|
|
d5b1f3ad89 | ||
|
|
b46684427f | ||
|
|
5cd43626ef | ||
|
|
43092f8d54 | ||
|
|
e50545f451 | ||
|
|
1d0d22df22 | ||
|
|
f07ea87e20 | ||
|
|
824a07290f | ||
|
|
fba51526af | ||
|
|
15746a1bc7 | ||
|
|
edefce8eb5 | ||
|
|
d98635e1bd | ||
|
|
9459c7ca64 | ||
|
|
75c874c55b | ||
|
|
10b2bb76f6 | ||
|
|
cbb97b961c | ||
|
|
5350da0be3 | ||
|
|
1c7ed8d9ad | ||
|
|
8f2d25024a | ||
|
|
4e586ed0b8 | ||
|
|
ad6832e697 | ||
|
|
11496010c0 | ||
|
|
e54785ddd6 | ||
|
|
6546fa0982 | ||
|
|
1a02c9957c | ||
|
|
145f8ef173 | ||
|
|
34a11db6ca | ||
|
|
d705471aa5 | ||
|
|
67f71fe4ac | ||
|
|
a10252dad2 | ||
|
|
c9d6d4b601 | ||
|
|
f88189cd59 | ||
|
|
c39d69f961 | ||
|
|
cf110d9d1d | ||
|
|
ed4245a74d | ||
|
|
09d5977263 | ||
|
|
42b3ea0d74 | ||
|
|
2a75cc2236 | ||
|
|
df6ed20271 | ||
|
|
de7fdbe85d | ||
|
|
37da97fbe6 | ||
|
|
f0f59bc2fd | ||
|
|
9c65d349e8 | ||
|
|
2818069d5f | ||
|
|
2f0308ea4d | ||
|
|
b1c347ee0c | ||
|
|
fba5083b58 | ||
|
|
9c9477ae76 | ||
|
|
e4dbd11d44 | ||
|
|
c3e38b317d | ||
|
|
f75ef5ca1c | ||
|
|
8fbbde7035 | ||
|
|
2dc05ae328 | ||
|
|
511fe53846 | ||
|
|
658e087f7a | ||
|
|
dba85ee32e | ||
|
|
b91086a5c8 | ||
|
|
4cd39ee33e | ||
|
|
e3ef97b6b4 | ||
|
|
e00a1a3e26 | ||
|
|
006cce5e4d | ||
|
|
4a06a1f296 | ||
|
|
fe1b877410 | ||
|
|
2b091d91d3 | ||
|
|
6d227a8479 | ||
|
|
447d804a3a | ||
|
|
687c6b9cc0 | ||
|
|
b2e2fe824d | ||
|
|
1f6385e7bb | ||
|
|
309119f659 | ||
|
|
884ae3f8da | ||
|
|
d9b953d5c6 | ||
|
|
e0014bbc7c | ||
|
|
d03de4986a | ||
|
|
6126988781 | ||
|
|
25e2e1d671 | ||
|
|
e6eb26518b | ||
|
|
8b2bc1a384 | ||
|
|
0ce72059e6 | ||
|
|
f80d3f6123 | ||
|
|
0925c9846b | ||
|
|
3612a9a605 | ||
|
|
cc8e0f2f67 | ||
|
|
a662981f10 | ||
|
|
d77c9dc6aa | ||
|
|
8ac3fcedca | ||
|
|
ea236c12a6 | ||
|
|
a53a0aa0b5 | ||
|
|
5e3db12c07 | ||
|
|
4f981a2506 | ||
|
|
b602dc57b1 | ||
|
|
330bedfb47 | ||
|
|
3ff24a8eb4 | ||
|
|
28a1231100 | ||
|
|
6fd9987632 | ||
|
|
8f27092756 | ||
|
|
e7fef1fd64 | ||
|
|
7f2b0ae16e | ||
|
|
0cc84b8cae | ||
|
|
1329473a4b | ||
|
|
84cc6541f3 | ||
|
|
512255b9a7 | ||
|
|
f3c6b4f1a3 | ||
|
|
ad662d3926 | ||
|
|
d29aa12117 | ||
|
|
ca6dd6ca92 | ||
|
|
1508bec957 | ||
|
|
bcc73e0db4 | ||
|
|
ec31f4566d | ||
|
|
dfb2a9404f | ||
|
|
7ac0d6bead | ||
|
|
041b6a6bc7 | ||
|
|
3a6c717bb8 | ||
|
|
ec74c46d1e | ||
|
|
161dbaf1ce | ||
|
|
e242da168b | ||
|
|
dea309cf8d | ||
|
|
ee3944c8fd | ||
|
|
1fefb80445 | ||
|
|
f92cb43ce4 | ||
|
|
cd2ca9ec34 | ||
|
|
e37a2e54ab | ||
|
|
53f3b05001 | ||
|
|
8e76565c9c | ||
|
|
c830710e11 | ||
|
|
0f354ac4e0 | ||
|
|
e601bfb362 | ||
|
|
dac6514147 | ||
|
|
ac723bf2df | ||
|
|
c8f6b54da7 | ||
|
|
27c26e88e5 | ||
|
|
e77d9ad043 | ||
|
|
25060c3fa5 | ||
|
|
28c2005a2a | ||
|
|
db115c6b97 | ||
|
|
7b02cb6d03 | ||
|
|
8beb17df0d | ||
|
|
76b693aa81 | ||
|
|
d53f1b7458 | ||
|
|
7188391a22 | ||
|
|
869170abd6 | ||
|
|
1ea574e4ca | ||
|
|
af35bcb64f | ||
|
|
55ce48c152 | ||
|
|
ff09914327 | ||
|
|
3946e24eff | ||
|
|
b07424224b | ||
|
|
d33d5b7de8 | ||
|
|
9180356b13 | ||
|
|
20ef19b42f | ||
|
|
1117caaf09 | ||
|
|
e6505947ec | ||
|
|
79b83600af | ||
|
|
85e3ca5ae2 | ||
|
|
e11af53819 | ||
|
|
0593cbeb84 | ||
|
|
d565fd3b54 | ||
|
|
699b18414d | ||
|
|
eb82e8527a | ||
|
|
069201dd1a | ||
|
|
37e4b3cdb6 | ||
|
|
501e8da925 | ||
|
|
6a6822b906 | ||
|
|
e7c1361a10 | ||
|
|
913e503296 | ||
|
|
2c0f06782d | ||
|
|
fcce73af42 | ||
|
|
2b2963859b | ||
|
|
327c05307a | ||
|
|
3f065cf789 | ||
|
|
dc1693d5a1 | ||
|
|
29b2b7a875 | ||
|
|
34af038fcc | ||
|
|
d422621eaa | ||
|
|
f556e4b6fc | ||
|
|
2fdcb64a79 | ||
|
|
468c2942a3 | ||
|
|
df56ba95fc | ||
|
|
bd39ce0d49 | ||
|
|
5068e4149a | ||
|
|
de024e04d7 | ||
|
|
7ff972773a | ||
|
|
9634538106 | ||
|
|
5356c62ead | ||
|
|
9af9226ff9 | ||
|
|
92028ed6e2 | ||
|
|
7a8f8f5a74 | ||
|
|
415885ecb9 | ||
|
|
7b833d07d9 | ||
|
|
2f58804717 | ||
|
|
b05f0abeeb | ||
|
|
2d75f79217 | ||
|
|
898a91903a | ||
|
|
6e9574c715 | ||
|
|
2efd2d4970 | ||
|
|
219dc7f99e | ||
|
|
1b4015226f | ||
|
|
0f77d9b30a | ||
|
|
a19b961427 | ||
|
|
646637f53a | ||
|
|
21e91cfa00 | ||
|
|
f32b65ac4a | ||
|
|
a02e25ba01 | ||
|
|
c5a7309966 | ||
|
|
1d7021130d | ||
|
|
8e03310afe | ||
|
|
31b0b0c99e | ||
|
|
90492aa26d | ||
|
|
d512a65d4c | ||
|
|
4378a17fbe | ||
|
|
8e8fa3d10b | ||
|
|
b5a6d9bcab | ||
|
|
929e6b5c9b | ||
|
|
44304bf9e4 | ||
|
|
e03a937c71 | ||
|
|
820067826a | ||
|
|
4a6ac5e209 | ||
|
|
29f0939a5b | ||
|
|
310d0e93d6 | ||
|
|
6967f54774 | ||
|
|
8d67f8af24 | ||
|
|
0148ad5820 | ||
|
|
e1fc6b31ee | ||
|
|
47b90a4e03 | ||
|
|
cceca5a158 | ||
|
|
88932f2d09 | ||
|
|
89a59d4df5 | ||
|
|
fa2c9f4551 | ||
|
|
f645f0abe8 | ||
|
|
f0ec51e78d | ||
|
|
2b8c3c1362 | ||
|
|
dbb70b394e | ||
|
|
abcf8dca3a | ||
|
|
351bef58a3 | ||
|
|
8d877421cf | ||
|
|
f592be00fa | ||
|
|
352b1173c8 | ||
|
|
bf0eee35f9 | ||
|
|
228c9c9277 | ||
|
|
fa2a3b679a | ||
|
|
d718b0eac7 | ||
|
|
93039db58c | ||
|
|
6ebef7450a | ||
|
|
a82e09d1a3 | ||
|
|
63a8af0e15 | ||
|
|
6b9b6c0b0b | ||
|
|
390805d8b9 | ||
|
|
70f37ef815 | ||
|
|
b6fca55447 | ||
|
|
e22c56f02f | ||
|
|
01c86e64b7 | ||
|
|
ca81c36383 | ||
|
|
a9a04c7bc0 | ||
|
|
0a81f4d742 | ||
|
|
0ad5035457 | ||
|
|
d626cef6de | ||
|
|
7713cbebd2 | ||
|
|
baf16f0419 | ||
|
|
9dcc2da348 | ||
|
|
f50a38de23 | ||
|
|
3ef51a469c | ||
|
|
d5688bf165 | ||
|
|
8dc9e24c74 | ||
|
|
735bbf9da7 | ||
|
|
6ad86ebdf1 | ||
|
|
3d58e04c93 | ||
|
|
9fb67a2cdd | ||
|
|
d9d12c5c43 | ||
|
|
728ad24d4a | ||
|
|
5b37471db7 | ||
|
|
c41e98be3c | ||
|
|
35f429cb6d | ||
|
|
85fc0ea57c | ||
|
|
6f588402c3 | ||
|
|
fada35478b | ||
|
|
bd5d7a8a7a | ||
|
|
8108356978 | ||
|
|
5e32eddb8c | ||
|
|
1818b6ac16 | ||
|
|
e802909de0 | ||
|
|
824ef37f5f | ||
|
|
565db46a19 | ||
|
|
87aa44f4bc | ||
|
|
e9396e59d9 | ||
|
|
002ac977f8 | ||
|
|
724f85d275 | ||
|
|
b3fa1c0b9c | ||
|
|
e69950a9ca | ||
|
|
41b4743eba | ||
|
|
1e9a16a748 | ||
|
|
74a5069c0a | ||
|
|
8d470017bc | ||
|
|
928c7a9771 | ||
|
|
eda7e563d0 | ||
|
|
90fc51542f | ||
|
|
f8674cc993 | ||
|
|
843adbf454 | ||
|
|
abefc3f705 | ||
|
|
dddd7b44c8 | ||
|
|
25c874c489 | ||
|
|
0e418b62d2 | ||
|
|
a97f643bd3 | ||
|
|
78a2145a47 | ||
|
|
dbe50934b1 | ||
|
|
543d104f85 | ||
|
|
e06207c914 | ||
|
|
166267c87a | ||
|
|
91e0737b8a | ||
|
|
65a032b205 | ||
|
|
80c7dcdbd7 | ||
|
|
bcd54d12d8 | ||
|
|
726e19a886 | ||
|
|
95719e342d | ||
|
|
132a63d1da | ||
|
|
822f700b15 | ||
|
|
5df51a06f5 | ||
|
|
ad74c5ed7f | ||
|
|
d5284be91d | ||
|
|
c29b41e527 | ||
|
|
4e612612dc | ||
|
|
705fbf92ee | ||
|
|
2dc704abb6 | ||
|
|
6c2ef75681 | ||
|
|
96899dc527 | ||
|
|
b0db912bde | ||
|
|
7cd33ce0dd | ||
|
|
e0dd40f812 | ||
|
|
79f0f97495 | ||
|
|
5e0b0a2aa3 | ||
|
|
e24969b422 | ||
|
|
dd02989e88 | ||
|
|
7383c04205 | ||
|
|
84291b021f | ||
|
|
91e30f4f22 | ||
|
|
5be44a6c03 | ||
|
|
8cc20a5618 | ||
|
|
81f88f8517 | ||
|
|
4eafb27b89 | ||
|
|
4fc4644652 | ||
|
|
c0f213b056 | ||
|
|
a2915cfdef | ||
|
|
4b921f3821 | ||
|
|
575f84ce0f | ||
|
|
1048796003 | ||
|
|
973c4ab569 | ||
|
|
445677dc00 | ||
|
|
da27529d91 | ||
|
|
f59921ce18 | ||
|
|
ec3c65122f | ||
|
|
9fa5e81836 | ||
|
|
4869a5165a | ||
|
|
30e84ff687 | ||
|
|
73fd01c986 | ||
|
|
3729af7438 | ||
|
|
1e5aef279a | ||
|
|
19db019e0c | ||
|
|
666464d7a9 | ||
|
|
391f880d07 | ||
|
|
d0bf3bf06d | ||
|
|
edb027e910 | ||
|
|
dd2fef6673 | ||
|
|
8e79c4a03d | ||
|
|
19d70a85fc | ||
|
|
f5e9bcc1fc | ||
|
|
3631f81236 | ||
|
|
1e6f64d5c9 | ||
|
|
569e9d932f | ||
|
|
6a7f4a1894 | ||
|
|
8c55a388cd | ||
|
|
d176f1f89c | ||
|
|
2d0845860a | ||
|
|
5ae701aab5 | ||
|
|
0d016195ac | ||
|
|
fc2de240d2 | ||
|
|
7c1ef6a387 | ||
|
|
0b538b6f2a | ||
|
|
3d26aa0dfb | ||
|
|
51d037e881 | ||
|
|
e5fb88fb85 | ||
|
|
787234eff4 | ||
|
|
6b1219b370 | ||
|
|
ed48555bdd | ||
|
|
ba9faae8b6 | ||
|
|
6935dee976 | ||
|
|
12473bb6d3 | ||
|
|
280a962328 | ||
|
|
37633ff957 | ||
|
|
1c2fc8c3c4 | ||
|
|
d3adecd819 | ||
|
|
0a71af41be | ||
|
|
8fb484da37 | ||
|
|
6e6a434a2d | ||
|
|
f23ea9e977 | ||
|
|
55cfdbaa3f | ||
|
|
1b5a07a740 | ||
|
|
00b0af7021 | ||
|
|
89027bd22c | ||
|
|
ff8de1a106 | ||
|
|
0c5e6770df | ||
|
|
c2ad33a04c | ||
|
|
c0a5e10313 | ||
|
|
1c394b8606 | ||
|
|
505d557fbb | ||
|
|
a63e429d22 | ||
|
|
de086f9848 | ||
|
|
6643acb375 | ||
|
|
c25cb107bb | ||
|
|
9dba08ac8b | ||
|
|
3ec115115d | ||
|
|
09c91b8931 | ||
|
|
de1940065a | ||
|
|
748ef8b2ae | ||
|
|
2ecf0a9053 | ||
|
|
b82048eb18 | ||
|
|
9d58ff97fe | ||
|
|
51b787e449 | ||
|
|
7654b518f1 | ||
|
|
e7f414416f | ||
|
|
52877c9af1 | ||
|
|
265f22be49 | ||
|
|
2a26c738bd | ||
|
|
02b37b3c69 | ||
|
|
d8370864f3 | ||
|
|
ffe48f00e3 | ||
|
|
49dff83a00 | ||
|
|
95afd7549c | ||
|
|
06ee890db3 | ||
|
|
e680420c89 | ||
|
|
357ee692bd | ||
|
|
347baa6f3e | ||
|
|
cc922de758 | ||
|
|
dbca906ef5 | ||
|
|
1fc4dcb76f | ||
|
|
dcd7d1c8e6 | ||
|
|
72e768ef14 | ||
|
|
047f61aad6 | ||
|
|
d04b1ffca5 | ||
|
|
c93e2f2332 | ||
|
|
e7c29d0ceb | ||
|
|
6c46358be8 | ||
|
|
b0ff8af9ac | ||
|
|
624db256c6 | ||
|
|
cfb15d158e | ||
|
|
34c7881ddd | ||
|
|
f06d930445 | ||
|
|
b29f5688bd | ||
|
|
333e2f266a | ||
|
|
af94399473 | ||
|
|
3d35f26031 | ||
|
|
b1c72ec48c | ||
|
|
8dee34459b | ||
|
|
e7f649e40a | ||
|
|
5843fbc6ee | ||
|
|
c8eca3a69d | ||
|
|
12fdcea8b8 | ||
|
|
035447b08f | ||
|
|
55b2e748e7 | ||
|
|
3246331876 | ||
|
|
6d9fbb0e97 | ||
|
|
14fc4a06a6 | ||
|
|
cba4ba9cdc | ||
|
|
937d99150c | ||
|
|
0a6c846091 | ||
|
|
c6b8ad6e7e | ||
|
|
d92a479d2f | ||
|
|
f242182840 | ||
|
|
f5871369cc | ||
|
|
b1b184cdb8 | ||
|
|
1a6de01210 | ||
|
|
1dd2589a42 | ||
|
|
3485e1c089 | ||
|
|
6f7965e4f1 | ||
|
|
1ba8fa6f04 | ||
|
|
6eb67fcc5f | ||
|
|
3b8e25fef4 | ||
|
|
64e83caf04 | ||
|
|
a8abea8247 | ||
|
|
d4defd943a | ||
|
|
eafd2bed5d | ||
|
|
6549765930 | ||
|
|
6cb2233cd2 | ||
|
|
9ad75e1dc3 | ||
|
|
762e503978 | ||
|
|
bec0f7d975 | ||
|
|
4b772fd783 | ||
|
|
c809aea278 | ||
|
|
1596f9c9f5 | ||
|
|
2f28d9a168 | ||
|
|
baac29debc | ||
|
|
2c4df765c5 | ||
|
|
1d026b921c | ||
|
|
fcbb6a7384 | ||
|
|
bdc01f44de | ||
|
|
d2c23773ff | ||
|
|
38dc3ec0da | ||
|
|
c03acc9572 | ||
|
|
30e133d36a | ||
|
|
0890df5891 | ||
|
|
d223a49d18 | ||
|
|
26285e183e | ||
|
|
408e9f1481 | ||
|
|
7c8344930b | ||
|
|
482e254a49 | ||
|
|
eb65331403 | ||
|
|
9031f59f7b | ||
|
|
2d9afa6348 | ||
|
|
bae5c14941 | ||
|
|
9cf8de099c | ||
|
|
b86bd1fcd0 | ||
|
|
c156e597dc | ||
|
|
bb750b07bc | ||
|
|
0e6fe5a097 | ||
|
|
13de7cafb2 | ||
|
|
057b688fc7 | ||
|
|
45bb3e7ffc | ||
|
|
8ced9c332c | ||
|
|
9fcd5ce03d | ||
|
|
a41e6e2ed2 | ||
|
|
e54855ef88 | ||
|
|
7a18fa281d | ||
|
|
f98aaf544d | ||
|
|
78afc24736 | ||
|
|
83e4534387 | ||
|
|
aed9018807 | ||
|
|
97b5f22a70 | ||
|
|
748dab2f38 | ||
|
|
3c11129b04 | ||
|
|
6e0e343f23 | ||
|
|
cc27470cb6 | ||
|
|
fb527fa7db | ||
|
|
87976aa48e | ||
|
|
863923472a | ||
|
|
778a15b64a | ||
|
|
5eaf5570c4 | ||
|
|
cbe0f1f1e9 | ||
|
|
97472e374f | ||
|
|
7a28aa0dd7 | ||
|
|
b1054ac227 | ||
|
|
1618b98533 | ||
|
|
5b6ed54817 | ||
|
|
d23a2b7e97 | ||
|
|
ab92b27226 | ||
|
|
eb6efdf17a | ||
|
|
b182791052 | ||
|
|
97a7f174ce | ||
|
|
654758e622 | ||
|
|
c8887a5846 | ||
|
|
56779f9542 | ||
|
|
f474838e22 | ||
|
|
19393e13db | ||
|
|
301b10de8d | ||
|
|
aa2fd3a151 | ||
|
|
2dd604949f | ||
|
|
ec481ac82a | ||
|
|
7afee45635 | ||
|
|
385d18590a | ||
|
|
bc9252f6e3 | ||
|
|
6c76f2a7c7 | ||
|
|
bf187170b1 | ||
|
|
14837e8e0f | ||
|
|
b44cdf1006 | ||
|
|
5d73f90133 | ||
|
|
34a6a9d3a1 | ||
|
|
f92a4e611b | ||
|
|
b3deb9ec86 | ||
|
|
dabaae1534 | ||
|
|
a92653f2b2 | ||
|
|
29cdab650b | ||
|
|
574a4eccb5 | ||
|
|
42c0641daf | ||
|
|
11b6e7844a | ||
|
|
f1b67152af | ||
|
|
b6be437bab | ||
|
|
3d7f421809 | ||
|
|
fa6d33f742 | ||
|
|
dc22196394 | ||
|
|
3ea458b9dc | ||
|
|
86128a7f06 | ||
|
|
de60750506 | ||
|
|
f07ac3068b | ||
|
|
7ec94fda08 | ||
|
|
9231c80cd8 | ||
|
|
4702e58ee5 | ||
|
|
2719549cf2 | ||
|
|
cd26f29fb8 | ||
|
|
9c350af582 | ||
|
|
c019b3dad9 | ||
|
|
8cb4aabb8b | ||
|
|
7ad8b3366d | ||
|
|
c6c8f77bc0 | ||
|
|
f415a70c0b | ||
|
|
da31d94c2a | ||
|
|
5c0db5a293 | ||
|
|
d533d7c97c | ||
|
|
490802099d | ||
|
|
34dd42dc7f | ||
|
|
b374868750 | ||
|
|
538688486e | ||
|
|
27111bd76d | ||
|
|
4a3f380fd2 | ||
|
|
cc87db74c7 | ||
|
|
4ec7e66e90 | ||
|
|
a42e425d44 | ||
|
|
2179c3e420 | ||
|
|
d5c9196348 | ||
|
|
aa1f0653e9 | ||
|
|
97156f3382 | ||
|
|
8771b6051f | ||
|
|
27c58c764d | ||
|
|
1564584ba9 | ||
|
|
fd10db5a62 | ||
|
|
6f683da2e9 | ||
|
|
a6a06c5aa6 | ||
|
|
4d1ab1ba2a | ||
|
|
d7a6a8e35b | ||
|
|
bf2e078ecf | ||
|
|
a25ce36925 | ||
|
|
a0f4038df2 | ||
|
|
7d8c1ae295 | ||
|
|
df7c2e605b | ||
|
|
ea51cdb3f2 | ||
|
|
fe986a52d6 | ||
|
|
34fd261a4f | ||
|
|
bbd4768bb6 | ||
|
|
cb237b5193 | ||
|
|
85d72b9952 | ||
|
|
a04c33c42d | ||
|
|
529afada82 | ||
|
|
a532f4868f | ||
|
|
e1d37c37b5 | ||
|
|
ae5e0e8c05 | ||
|
|
bbea0ef439 | ||
|
|
a134c43f4d | ||
|
|
e0ebae4481 | ||
|
|
1fbc51b69f | ||
|
|
42f3e7f7ce | ||
|
|
e163cbacec | ||
|
|
0ec6870902 | ||
|
|
55421ede70 | ||
|
|
3acd247f5d | ||
|
|
59151704b4 | ||
|
|
343ee5ece1 | ||
|
|
0256ee77c2 | ||
|
|
72f5415fc8 | ||
|
|
ef8e9df02f | ||
|
|
306ee0eddb | ||
|
|
3d9e6bf454 | ||
|
|
0fc6cb4099 | ||
|
|
5744021ac9 | ||
|
|
54be05e5e4 | ||
|
|
c9e22ab67b | ||
|
|
4063f968c6 | ||
|
|
8388c53a47 | ||
|
|
3a72f3beb8 | ||
|
|
35709a30ee | ||
|
|
f9a683cf39 | ||
|
|
d7a2b52da8 | ||
|
|
f43adc364a | ||
|
|
6beebbe074 | ||
|
|
019f8eb278 | ||
|
|
580f9ced08 | ||
|
|
642cc15b99 | ||
|
|
cfeade6055 | ||
|
|
390207cdf1 | ||
|
|
c97b2b95e6 | ||
|
|
a3bf632276 | ||
|
|
5368ee32dd | ||
|
|
e89f02bd8f | ||
|
|
ae6a749d3a | ||
|
|
0759030ee8 | ||
|
|
35f4c8b333 | ||
|
|
97ac32f536 | ||
|
|
2f3ef88dbf | ||
|
|
9725a0b9bf | ||
|
|
b368e89bea | ||
|
|
3269833caa | ||
|
|
922f7d1645 | ||
|
|
a1873fef61 | ||
|
|
0eff3b6b97 | ||
|
|
f6557d1ea2 | ||
|
|
718eb2b4cc | ||
|
|
cd6c01e42b | ||
|
|
0b773dd792 | ||
|
|
b68ab3a4b4 | ||
|
|
d8c9f88fe7 | ||
|
|
f6398ba51c | ||
|
|
67dbf01eeb | ||
|
|
7c71064b64 | ||
|
|
4d91ff8d8d | ||
|
|
e778f7f805 | ||
|
|
3bff7a9e62 | ||
|
|
705c2ac55a | ||
|
|
3f3d65e452 | ||
|
|
a9721ea268 | ||
|
|
d876bb8cf3 | ||
|
|
b17dcc6773 | ||
|
|
e3ee2b327b | ||
|
|
74b91d6dec | ||
|
|
7a3b7ae812 | ||
|
|
35df67c893 | ||
|
|
290303e64f | ||
|
|
f8ab7a5158 | ||
|
|
decaaf4b55 | ||
|
|
b9d228c72f | ||
|
|
11e48c3fa9 | ||
|
|
c40302a7ff | ||
|
|
964e22cfef | ||
|
|
55db69e3b2 | ||
|
|
99b08ecde5 | ||
|
|
4ecf93487e | ||
|
|
f066933418 | ||
|
|
481d8299ca | ||
|
|
3b19536df9 | ||
|
|
2212157b61 | ||
|
|
7ebeed1ae7 | ||
|
|
7769097915 | ||
|
|
595b0cb471 | ||
|
|
c50c3629e6 | ||
|
|
887b6f4da7 | ||
|
|
9c6cfcd2e9 | ||
|
|
658c7d1dbf | ||
|
|
ecfe6e4e7a | ||
|
|
f53c4e7525 | ||
|
|
3690c64e88 | ||
|
|
c489f786b6 | ||
|
|
5c40cc43b2 | ||
|
|
54ae850322 | ||
|
|
a9b9d2f6d3 | ||
|
|
f00f92e7e3 | ||
|
|
bbe26df83d | ||
|
|
daf9988b3a | ||
|
|
ee67452772 | ||
|
|
781364f7f9 | ||
|
|
84d016ddcf | ||
|
|
0241fdac1a | ||
|
|
d62bae442b | ||
|
|
9cc8947a43 | ||
|
|
bff68fa079 | ||
|
|
00c59041ea | ||
|
|
a77b81f0e5 | ||
|
|
f839588c69 | ||
|
|
27d719cd4d | ||
|
|
7a15dc6772 | ||
|
|
bfd7f468ce | ||
|
|
cca1e77f95 | ||
|
|
cc81287665 | ||
|
|
ca95153b45 | ||
|
|
eb330a6df6 | ||
|
|
b498979d4d | ||
|
|
f047b3f8e7 | ||
|
|
c67787536b | ||
|
|
3cfc96d4de | ||
|
|
91a8c66537 | ||
|
|
5c3a4746b7 | ||
|
|
b8e0004ff2 | ||
|
|
4e0aabd8a7 | ||
|
|
143a177055 | ||
|
|
d45a9cad8c | ||
|
|
285a3b7522 | ||
|
|
d4255818c4 | ||
|
|
f714f3ee78 | ||
|
|
36bc351557 | ||
|
|
d5ee330d20 | ||
|
|
634e9d6213 | ||
|
|
9aa9a92f72 | ||
|
|
8c51c0fdbd | ||
|
|
24e4a545a2 | ||
|
|
c5fb5e8bb0 | ||
|
|
b8434182c9 | ||
|
|
e1f942f26a | ||
|
|
91b85efabb | ||
|
|
0057905ca0 | ||
|
|
572e26deb8 | ||
|
|
caff9a135f | ||
|
|
ce24b92758 | ||
|
|
f5a086ac98 | ||
|
|
cb1025e0e8 | ||
|
|
a46cdb8bbc | ||
|
|
34e2035bad | ||
|
|
a9ba7b8ecb | ||
|
|
962d647993 | ||
|
|
a8520ba59e | ||
|
|
f12d7b4e67 | ||
|
|
bbea6e6375 | ||
|
|
b24b8424b1 | ||
|
|
35bd1a4c02 | ||
|
|
818352c3cd | ||
|
|
742efe989f | ||
|
|
4cea1c7189 | ||
|
|
18ddda48d2 | ||
|
|
5651519f5d | ||
|
|
281e8ff766 | ||
|
|
dbc0710bc9 | ||
|
|
8f28f31b78 | ||
|
|
3f651d9fa9 | ||
|
|
18fced7e7f | ||
|
|
f1f0158741 | ||
|
|
3d6c542e34 | ||
|
|
c3036116de | ||
|
|
9e3653a612 | ||
|
|
27a00d1bfd | ||
|
|
800837ff3f | ||
|
|
bfbfb6dbf3 | ||
|
|
8fb1b1d412 | ||
|
|
af98467d0d | ||
|
|
f9d50d580c | ||
|
|
496805476e | ||
|
|
962e565591 | ||
|
|
862625a4bf | ||
|
|
2d8aade74b | ||
|
|
2aad2cfc53 | ||
|
|
ad94405dac | ||
|
|
518fcf7e03 | ||
|
|
1fbd00e1e8 | ||
|
|
cae229cadc | ||
|
|
9d3dcdbc38 | ||
|
|
d52fabce72 | ||
|
|
637d4c3083 | ||
|
|
1e96d9a87f | ||
|
|
49172b256c | ||
|
|
9a94f48663 | ||
|
|
2e9c6c2586 | ||
|
|
92522473b0 | ||
|
|
56200ca044 | ||
|
|
524f283cc6 | ||
|
|
a2acf0f7cf | ||
|
|
d85f1b942d | ||
|
|
8da41bdc2b | ||
|
|
4a926e489b | ||
|
|
746dd91e86 | ||
|
|
763dec881a | ||
|
|
2a5715fad5 | ||
|
|
ec58272b95 | ||
|
|
f90d3af403 | ||
|
|
c2659401b0 | ||
|
|
9840d4a4a3 | ||
|
|
fc6d94a9f8 | ||
|
|
61a7be0eab | ||
|
|
e4a439aa0c | ||
|
|
b844cafb9c | ||
|
|
1d9522a7a6 | ||
|
|
ffe80579df | ||
|
|
bcd17cf99a | ||
|
|
bc15723f7f | ||
|
|
7a0cc03532 | ||
|
|
d36f6783c7 | ||
|
|
d339ab51eb | ||
|
|
fee70031f6 | ||
|
|
303edb71bd | ||
|
|
314f0ae964 | ||
|
|
0835980ef1 | ||
|
|
baf55e4616 | ||
|
|
dd62c2f946 | ||
|
|
638cecf43c | ||
|
|
a97cfe513d | ||
|
|
9de3c0495f | ||
|
|
67e6f8245b | ||
|
|
31c93c483a | ||
|
|
86d4d5689c | ||
|
|
663e82bc19 | ||
|
|
51109e3f72 | ||
|
|
a11363e9e7 | ||
|
|
cc57913d7a | ||
|
|
057d169492 | ||
|
|
e5a2a25faf | ||
|
|
147521b757 | ||
|
|
31d77e29b6 | ||
|
|
4b0ff07bcb | ||
|
|
0ee18d4421 | ||
|
|
21da45e5c3 | ||
|
|
d5ed967f58 | ||
|
|
42dafcc62a | ||
|
|
cad282ebb7 | ||
|
|
7f2ac9c871 | ||
|
|
87aaff5fae | ||
|
|
b411010237 | ||
|
|
d2d86ac360 | ||
|
|
a827725a8d | ||
|
|
3badbc50e0 | ||
|
|
cd60de443e | ||
|
|
95e40115a2 | ||
|
|
66c324d7ef | ||
|
|
6b056eb53f | ||
|
|
8cfdcf9a6f | ||
|
|
0917cd7010 | ||
|
|
bdd78ce38e | ||
|
|
7497db6e37 | ||
|
|
43e2942fa0 | ||
|
|
51bc2f3b76 | ||
|
|
483683c197 | ||
|
|
c95d341220 | ||
|
|
be2c6f3b5e | ||
|
|
2d5736f297 | ||
|
|
1a51193899 | ||
|
|
8b51abef08 | ||
|
|
cbb49e8c84 | ||
|
|
dc12da4573 | ||
|
|
7af58f74b0 | ||
|
|
1081876810 | ||
|
|
2ff0dd3fef | ||
|
|
a30fc69f86 | ||
|
|
022b5cf193 | ||
|
|
7620c03b72 | ||
|
|
6324dae114 | ||
|
|
e0237c6b8c | ||
|
|
1cf3e02bfb | ||
|
|
6ca5405db9 | ||
|
|
fa31f2a3eb | ||
|
|
d03f9454b9 | ||
|
|
616fb1cbcf | ||
|
|
b7d1e6257c | ||
|
|
b101ffaed6 | ||
|
|
f7dad4f38f | ||
|
|
b88c08f860 | ||
|
|
cc47f4d1c2 | ||
|
|
3909d7e92f | ||
|
|
d70edfa0a0 | ||
|
|
d22ab85b84 | ||
|
|
5c30b145df | ||
|
|
e446cba6a9 | ||
|
|
8a0b4e0d8c | ||
|
|
02a9cdff57 | ||
|
|
f516f8a1d4 | ||
|
|
bef4865d91 | ||
|
|
fd62f419ac | ||
|
|
7fa6f320ed | ||
|
|
19f3fb131b | ||
|
|
551e8fcd24 | ||
|
|
04b4952f0e | ||
|
|
0d77555c97 | ||
|
|
67141fb4bb | ||
|
|
2efa762c2b | ||
|
|
6c2dd193cf | ||
|
|
881bec958e | ||
|
|
8899c751e5 | ||
|
|
d0caf0a322 | ||
|
|
91b5108eae | ||
|
|
2c7f73f9c4 | ||
|
|
5310592967 | ||
|
|
41bddae907 | ||
|
|
d9d2b2f1ee | ||
|
|
1e208abd93 | ||
|
|
d32088b58a | ||
|
|
6d37cc94a7 | ||
|
|
55722a7ed7 | ||
|
|
d2fa20a390 | ||
|
|
bcbad050d4 | ||
|
|
27698c468b | ||
|
|
49bb43047d | ||
|
|
77ce0a837d | ||
|
|
bbbfa8f360 | ||
|
|
d781d2eaa1 | ||
|
|
f33b14bda6 | ||
|
|
e603549563 | ||
|
|
e80e0c761a | ||
|
|
9e804202b6 | ||
|
|
0c678b1e1a | ||
|
|
4cb29deb93 | ||
|
|
5413953d30 | ||
|
|
50e51b4513 | ||
|
|
ee0647aba6 | ||
|
|
35be70f1f0 | ||
|
|
dbb23d2182 | ||
|
|
478eaea982 | ||
|
|
0800e51d41 | ||
|
|
5ff385f8a9 | ||
|
|
5b3c642195 | ||
|
|
bd6e201926 | ||
|
|
08779aa2a3 | ||
|
|
09bd686327 | ||
|
|
9316476a73 | ||
|
|
00946007d8 | ||
|
|
bc47bc7c22 | ||
|
|
dc693601f4 | ||
|
|
f1f9c63cdb | ||
|
|
0cc4f0fd76 | ||
|
|
0dc1b5adfb | ||
|
|
a76e6eca6b | ||
|
|
8c7278b53a | ||
|
|
50a3b4c777 | ||
|
|
3094ca1da5 | ||
|
|
23ad10c849 | ||
|
|
c9fb989a31 | ||
|
|
8356578a54 | ||
|
|
0310404155 | ||
|
|
03f8690f9c | ||
|
|
4cc3de4f84 | ||
|
|
fedd4440f0 | ||
|
|
55cedc24fa | ||
|
|
c9162837a0 | ||
|
|
f218463976 | ||
|
|
1f0c54f7ea | ||
|
|
d3522c328c | ||
|
|
7e50eb0e83 | ||
|
|
5b455abecc | ||
|
|
7d41761e84 | ||
|
|
25f6d8b1e9 | ||
|
|
5a33616e65 | ||
|
|
1cf17b06ae | ||
|
|
aa03706ed0 | ||
|
|
d8794e2b30 | ||
|
|
b7939eb266 | ||
|
|
19b9a34c48 | ||
|
|
f016e08153 | ||
|
|
7b1c503086 | ||
|
|
5865001e4a | ||
|
|
62944da74b | ||
|
|
588013bb44 | ||
|
|
615c27c117 | ||
|
|
3c3d9ce3a9 | ||
|
|
66011fe48b | ||
|
|
d7f59eccaf | ||
|
|
e652213855 | ||
|
|
f70150a663 | ||
|
|
fe52f76913 | ||
|
|
0d9c3c895c | ||
|
|
6525bb7cef | ||
|
|
0790e74f84 | ||
|
|
195a9cfd88 | ||
|
|
ecbf8d76d0 | ||
|
|
818745a605 | ||
|
|
26aacd0e32 | ||
|
|
8e06739e26 | ||
|
|
ab1f2ef71c | ||
|
|
d2e09cb259 | ||
|
|
bf8ea85bd7 | ||
|
|
9c0aeaff40 | ||
|
|
95b4bb51c6 | ||
|
|
1e5f93b7b6 | ||
|
|
b89d46bb00 | ||
|
|
97d61131df | ||
|
|
5721767921 | ||
|
|
a443531280 | ||
|
|
ad083677c5 | ||
|
|
426467856d | ||
|
|
844042744e | ||
|
|
65b3a95be8 | ||
|
|
ca95950148 | ||
|
|
6234d79852 | ||
|
|
a5d8b92012 | ||
|
|
890cfc6dc3 | ||
|
|
0e6fc2e88b | ||
|
|
c8ccd420be | ||
|
|
ff4f6b9066 | ||
|
|
7cffa2de78 | ||
|
|
e2afaaea75 | ||
|
|
75d3974c12 | ||
|
|
583f12ea71 | ||
|
|
3de7a8ad8d | ||
|
|
f6c9052082 | ||
|
|
f226804149 | ||
|
|
cf94486e32 | ||
|
|
035a2f35d4 | ||
|
|
9b7732eac4 | ||
|
|
5f9dac8abc | ||
|
|
ccd4dd7ff2 | ||
|
|
77417b7cbe | ||
|
|
6a7cd79a63 | ||
|
|
baa3b51b3e | ||
|
|
abeba4910c | ||
|
|
356d0aedbd | ||
|
|
45f23f3a59 | ||
|
|
6ef7375ade | ||
|
|
00030aabf7 | ||
|
|
f72832cc08 | ||
|
|
b5c33ca2b7 | ||
|
|
d607399850 | ||
|
|
d005803934 | ||
|
|
a22ec275b4 | ||
|
|
188f963fe0 | ||
|
|
9c5df33325 | ||
|
|
74f60951cc | ||
|
|
54202fcaad | ||
|
|
fe645c5bcc | ||
|
|
86c15d7ae9 | ||
|
|
3c36d5e433 | ||
|
|
1c7e164c22 | ||
|
|
ce7eb22e3a | ||
|
|
739a97140f | ||
|
|
99ed397e9c | ||
|
|
d2c7668bc2 | ||
|
|
7abf3e8bdf | ||
|
|
506b4db762 | ||
|
|
21c27fdcae | ||
|
|
672e89a640 | ||
|
|
4b810ae493 | ||
|
|
52e2a7d990 | ||
|
|
2e5e9c0298 | ||
|
|
afa05ae15e | ||
|
|
f58b8d0d6a | ||
|
|
5c73d3878d | ||
|
|
ef0a7e328c | ||
|
|
cc117b5048 | ||
|
|
faebe7a70a | ||
|
|
01962e25dc | ||
|
|
ff207eb583 | ||
|
|
8e922ab690 | ||
|
|
1a3db6b65e | ||
|
|
987e05ff31 | ||
|
|
2fc123cf4a | ||
|
|
3b57077d01 | ||
|
|
33c1ba1549 | ||
|
|
bd16b22dac | ||
|
|
0929d8ddfa | ||
|
|
9d6c69ebde | ||
|
|
1bcd360dfe | ||
|
|
1f2210a3ce | ||
|
|
2fe1378d3a | ||
|
|
796539c60b | ||
|
|
700936b2ad | ||
|
|
a28dbe3a59 | ||
|
|
820df0f551 | ||
|
|
ee9cf1bbaa | ||
|
|
52917abe21 | ||
|
|
a40f98df0a | ||
|
|
2c78a5aceb | ||
|
|
02a8e3fd34 | ||
|
|
322adfbdde | ||
|
|
194d0a0e25 | ||
|
|
b2d6ebaa10 | ||
|
|
bfecbb0685 | ||
|
|
e4c552f5a5 | ||
|
|
04f32073c0 | ||
|
|
e9afd2bb5e | ||
|
|
55d660a548 | ||
|
|
dfaf47d97c | ||
|
|
640e1a7643 | ||
|
|
2a0b078e15 | ||
|
|
0af04295f3 | ||
|
|
3542bfa5b8 | ||
|
|
e3a54ed0f4 | ||
|
|
ec4b5b52af | ||
|
|
a0dfef3b04 | ||
|
|
6db6a30ab5 | ||
|
|
bfa2f73335 | ||
|
|
1decccace7 | ||
|
|
ee53d49059 | ||
|
|
0dac7fe434 | ||
|
|
a6690032ad | ||
|
|
f949f9a23a | ||
|
|
00cef3e6be | ||
|
|
3f4a8713c9 | ||
|
|
7c188aec3c | ||
|
|
f0dec832b8 | ||
|
|
ca74fa1db0 | ||
|
|
987986631d | ||
|
|
1d89233047 | ||
|
|
348f16093c | ||
|
|
2a3ec87887 | ||
|
|
b52dcff745 | ||
|
|
f372112a8d | ||
|
|
72117debf7 | ||
|
|
2f3c71595b | ||
|
|
113aaf37fc | ||
|
|
768042d29d | ||
|
|
db274f9c39 | ||
|
|
66279c124e | ||
|
|
b335419505 | ||
|
|
3c9e10139f | ||
|
|
34898c89cd | ||
|
|
40600eebfa | ||
|
|
12497ecade | ||
|
|
9e21f426c0 | ||
|
|
c77d49f67e | ||
|
|
33cfe8b809 | ||
|
|
0d0ef5d0d2 | ||
|
|
d65bac979d | ||
|
|
c1667bd85e | ||
|
|
815f7ecffb | ||
|
|
44c0443983 | ||
|
|
3051076dd1 | ||
|
|
d90b414223 | ||
|
|
8cb2805eb7 | ||
|
|
e5ab5995db | ||
|
|
e774b89062 | ||
|
|
29db8ac36e | ||
|
|
be2d4aa434 | ||
|
|
1e61e52400 | ||
|
|
4bdfbfa854 | ||
|
|
2c08960f4e | ||
|
|
1a419609e3 | ||
|
|
f812b8d304 | ||
|
|
ff6eefd7c7 | ||
|
|
0c5abfefd3 | ||
|
|
e560a09db0 | ||
|
|
9bf8ca5856 | ||
|
|
410abb5afb | ||
|
|
482aa937b1 | ||
|
|
b4ba6e49af | ||
|
|
010394ab63 | ||
|
|
7cbb96528c | ||
|
|
aa420cd54a | ||
|
|
d5302ec327 | ||
|
|
f31a2d229c | ||
|
|
35ad72e56f | ||
|
|
f501817154 | ||
|
|
449f255f3e | ||
|
|
21d890e6df | ||
|
|
feb3b90596 | ||
|
|
0ff2676a25 | ||
|
|
3e28777ecb | ||
|
|
7516f8e94f | ||
|
|
ac574b6782 | ||
|
|
50dafd6187 | ||
|
|
d4f129b513 | ||
|
|
9a72317c4f | ||
|
|
b21b1ee9af | ||
|
|
c62fe6dac8 | ||
|
|
9dc136f445 | ||
|
|
418bf148e0 | ||
|
|
408721ae37 | ||
|
|
b1b6850fa9 | ||
|
|
d73196750f | ||
|
|
093754db3f | ||
|
|
7cc15969ff | ||
|
|
b53cf70262 | ||
|
|
1dadd6c9ae | ||
|
|
a7a94cb86f | ||
|
|
3d6954f0f0 | ||
|
|
267efefdfa | ||
|
|
6a3170386e | ||
|
|
4d83eef756 | ||
|
|
44b7a2d1f9 | ||
|
|
c32570c602 | ||
|
|
9702ef3f91 | ||
|
|
b2194ac549 | ||
|
|
b5413dacc7 | ||
|
|
aa33757e45 | ||
|
|
a0065bea04 | ||
|
|
5c89d835a6 | ||
|
|
cfb906a0ce | ||
|
|
af36d7c430 | ||
|
|
0c9165fc71 | ||
|
|
fa63088dce | ||
|
|
0b7235c5f0 | ||
|
|
ca0f0419e6 | ||
|
|
3520e833a4 | ||
|
|
bb4866047a | ||
|
|
2070731af1 | ||
|
|
a5909b450c | ||
|
|
94bafa5aaf | ||
|
|
7325da3052 | ||
|
|
e6d275b371 | ||
|
|
f4c0fe2ede | ||
|
|
12452f4427 | ||
|
|
1370791734 | ||
|
|
0646814235 | ||
|
|
84775130a0 | ||
|
|
4ce893ebc0 | ||
|
|
3ae0d560be | ||
|
|
06c84dba59 | ||
|
|
d90e7623c6 | ||
|
|
b13005e802 | ||
|
|
05b2893b9f | ||
|
|
1bf2023ed4 | ||
|
|
6f9bcb7fee | ||
|
|
6d94909c08 | ||
|
|
86153fbba9 | ||
|
|
4f38af01e0 | ||
|
|
a6588d6918 | ||
|
|
720d1e831d | ||
|
|
206f492401 | ||
|
|
fa5f3cef3d | ||
|
|
c70d0a6a69 | ||
|
|
6549aaf393 | ||
|
|
6378c87d15 | ||
|
|
4a0eff1296 | ||
|
|
9c07903ae9 | ||
|
|
32b7b3a6f7 | ||
|
|
041bbf8bdf | ||
|
|
701f6b4b2f | ||
|
|
bddd019a04 | ||
|
|
865117a05f | ||
|
|
e6bac234db | ||
|
|
9f1fac9142 | ||
|
|
9831175a2d | ||
|
|
7e43953937 | ||
|
|
28481e984b | ||
|
|
30e4f119d3 | ||
|
|
01da87c112 | ||
|
|
e7f15d09be | ||
|
|
cbb3c4bfed | ||
|
|
d24993aeab | ||
|
|
d858ad1179 | ||
|
|
96244dd727 | ||
|
|
b38b5d3df2 | ||
|
|
ad3e6ff054 | ||
|
|
522652913f | ||
|
|
43e88c892d | ||
|
|
d82d9468b4 | ||
|
|
d7f75ac985 | ||
|
|
1dbceaa790 | ||
|
|
77ca59acac | ||
|
|
7be0613657 | ||
|
|
b9ad9186fe | ||
|
|
3f4b154b70 | ||
|
|
ff73c95547 | ||
|
|
aa0d05f676 | ||
|
|
545832e9fa | ||
|
|
a0ac2a5d63 | ||
|
|
833c7fbf6d | ||
|
|
faf2a44890 | ||
|
|
d194ceb604 | ||
|
|
37a2c98d3d | ||
|
|
79b02998a6 | ||
|
|
1ce1e7ef27 | ||
|
|
7499d925da | ||
|
|
367f17a4ff | ||
|
|
3d2b26dcfe | ||
|
|
6106a0f2c4 | ||
|
|
1926c1b683 | ||
|
|
6cc1a607fc | ||
|
|
1905afb3d8 | ||
|
|
345a45083d | ||
|
|
3a3babf597 | ||
|
|
f367e3a6c8 | ||
|
|
f2283b0cb5 | ||
|
|
26081ac125 | ||
|
|
36fba4cc54 | ||
|
|
58b4286edb | ||
|
|
b0b6a6f665 | ||
|
|
63e5989f53 | ||
|
|
9da5707d3e | ||
|
|
55292b72d1 | ||
|
|
06b1ad6241 | ||
|
|
1efe41b9b9 | ||
|
|
1198eed632 | ||
|
|
0772fe822a | ||
|
|
f53fac1b56 | ||
|
|
68f2ac9296 | ||
|
|
b4f8340f16 | ||
|
|
d2f73c17d5 | ||
|
|
5db914b745 | ||
|
|
cd3d2910ee | ||
|
|
de7653f5a4 | ||
|
|
b905039ed2 | ||
|
|
f0a85d0469 | ||
|
|
ac2779f4d8 | ||
|
|
68ffe65499 | ||
|
|
3e14e7c48b | ||
|
|
b526e678b5 | ||
|
|
d3c39375d5 | ||
|
|
a7991dcbad | ||
|
|
47dff97834 | ||
|
|
2905395695 | ||
|
|
4bf38da4d4 | ||
|
|
9b37b9285e | ||
|
|
dfdced2ab1 | ||
|
|
c2a95a372f | ||
|
|
ef923d28ff | ||
|
|
53b0e0bc02 | ||
|
|
096c4b3e63 | ||
|
|
b8189d6ee3 | ||
|
|
f41dc91357 | ||
|
|
ef0c12ad9e | ||
|
|
9e1f110db0 | ||
|
|
483b2b3edb | ||
|
|
34a35b0f09 | ||
|
|
aca3ffb30a | ||
|
|
c3c4524def | ||
|
|
f101762d1b | ||
|
|
a541be3951 | ||
|
|
b7d640e764 | ||
|
|
969f6a60c3 | ||
|
|
6703cb85d9 | ||
|
|
111e16e772 | ||
|
|
3eb93383a3 | ||
|
|
817b621d20 | ||
|
|
5eb30c1543 | ||
|
|
d4b8635f50 | ||
|
|
4e4fe3eb39 | ||
|
|
882fb4d295 | ||
|
|
eaf70c955b | ||
|
|
3543d79048 | ||
|
|
94783addfc | ||
|
|
91c0de60b4 | ||
|
|
21f7db4c4d | ||
|
|
f224d61f37 | ||
|
|
d938ab5dd7 | ||
|
|
9a8f46e554 | ||
|
|
27ee0c9c3b | ||
|
|
251a87e2d2 | ||
|
|
084e6ee9ec | ||
|
|
18331e39bf | ||
|
|
250c88efdc | ||
|
|
9a377485be | ||
|
|
47a56c11f2 | ||
|
|
c4b9716873 | ||
|
|
ec119b2f9e | ||
|
|
5d1a6acc84 | ||
|
|
80eb460fc9 | ||
|
|
ef68debc8d | ||
|
|
4c12ac9fb8 | ||
|
|
244bb726e2 | ||
|
|
6ab268c7bb | ||
|
|
0c9f8ff189 | ||
|
|
dd7d04be95 | ||
|
|
58392d29da | ||
|
|
9260f5dc96 | ||
|
|
62a6c16b43 | ||
|
|
31e8d4676a | ||
|
|
d3cbe00f78 | ||
|
|
97fe3563fa | ||
|
|
37ad1e2f6d | ||
|
|
00894d188d | ||
|
|
2a5eba7899 | ||
|
|
bf30492d57 | ||
|
|
e00853ee82 | ||
|
|
e75f3a0060 | ||
|
|
eece41547e | ||
|
|
c311202b73 | ||
|
|
e149d29803 | ||
|
|
190ddda572 | ||
|
|
6b470c5222 | ||
|
|
6b32d195e8 | ||
|
|
bec6ce54c1 | ||
|
|
106d1c3538 | ||
|
|
ae8f2208c9 | ||
|
|
5c3cf2f08b | ||
|
|
102f34090d | ||
|
|
99790c90aa | ||
|
|
6d792e4123 | ||
|
|
98e322d5a5 | ||
|
|
01edce40f3 | ||
|
|
0549f87ccc | ||
|
|
72cd0eac29 | ||
|
|
f0c68533c4 | ||
|
|
9e4a9c51cc | ||
|
|
6874ec0dcc | ||
|
|
252f41818e | ||
|
|
d361f21065 | ||
|
|
feb090abb3 | ||
|
|
db771ec6e3 | ||
|
|
6f7db82b18 | ||
|
|
67cc7f6dc6 | ||
|
|
db978db271 | ||
|
|
363f35f076 | ||
|
|
49b7276f2a | ||
|
|
f57131e11b | ||
|
|
420af9e108 | ||
|
|
ceaf9b7452 | ||
|
|
5fd45b3892 | ||
|
|
64d82d5988 | ||
|
|
0f308bd18f | ||
|
|
1365f1ce52 | ||
|
|
7fc4e54efe | ||
|
|
c98c08c232 | ||
|
|
990c724bd8 | ||
|
|
b82c7b40b0 | ||
|
|
70299c6646 | ||
|
|
ea6c5053c8 | ||
|
|
3f4fd45d5c | ||
|
|
7c7e88253e | ||
|
|
bb94a5437d | ||
|
|
273f9b2027 | ||
|
|
b6d0b4be30 | ||
|
|
2dce45f427 | ||
|
|
a3ede3106a | ||
|
|
dd9722184b | ||
|
|
a854e36f2b | ||
|
|
be594ff8a4 | ||
|
|
c66628e52b | ||
|
|
350a151ee4 | ||
|
|
d35458e3fe | ||
|
|
d6883c0266 | ||
|
|
563ed05353 | ||
|
|
f527412d9b | ||
|
|
713cacab1e | ||
|
|
846f813565 | ||
|
|
c26d71d3e9 | ||
|
|
c8677d3272 | ||
|
|
596ea62dc3 | ||
|
|
1fe30bb2e8 | ||
|
|
809d659e64 | ||
|
|
09f4e43189 | ||
|
|
679bbdcf8f | ||
|
|
a0c79aa87b | ||
|
|
46f3846659 | ||
|
|
bbc3cc558c | ||
|
|
c8bd42de16 | ||
|
|
62e15e905b | ||
|
|
125a7b9177 | ||
|
|
895044c52b | ||
|
|
40c01c2d37 | ||
|
|
911d768b71 | ||
|
|
71a503e40c | ||
|
|
487b0ee124 | ||
|
|
eaec0a48f4 | ||
|
|
fdbc6cdea5 | ||
|
|
9623ec3ee4 | ||
|
|
63582c154c | ||
|
|
914815e70f | ||
|
|
354926a956 | ||
|
|
df303770ea | ||
|
|
a269c33a54 | ||
|
|
eb04f9314b | ||
|
|
a9d0461839 | ||
|
|
71aa4fe767 | ||
|
|
cfd3c02306 | ||
|
|
35104059ed | ||
|
|
934035db71 | ||
|
|
8ff65230e1 | ||
|
|
cb00e869ea | ||
|
|
f8b56fdc3f | ||
|
|
2d8b6fcf23 | ||
|
|
6ddee22f81 | ||
|
|
66c738bc10 | ||
|
|
bcc47add38 | ||
|
|
d326c51d79 | ||
|
|
940fdf7ed0 | ||
|
|
4f5d6d97d3 | ||
|
|
00412b570b | ||
|
|
6a35b8ad07 | ||
|
|
735082b7c2 | ||
|
|
5b7bdc82c8 | ||
|
|
a3dea81b49 | ||
|
|
486221f206 | ||
|
|
9528d7470b | ||
|
|
933d6b90ed | ||
|
|
a869693405 | ||
|
|
549c35b061 | ||
|
|
42959db0a4 | ||
|
|
114977dd25 | ||
|
|
aba8ffbe7b | ||
|
|
455a2b3705 | ||
|
|
e0638c48cd | ||
|
|
41f6b691e3 | ||
|
|
0f30fa34e3 | ||
|
|
e486f5ffdc | ||
|
|
5a68730e2f | ||
|
|
7997fd3152 | ||
|
|
048db82041 | ||
|
|
16b44d2a5b | ||
|
|
34775fc235 | ||
|
|
f2fd8c854a | ||
|
|
9f2a853d87 | ||
|
|
7a78cdf78c | ||
|
|
356887bca2 | ||
|
|
2df15ad08c | ||
|
|
780a87be9a | ||
|
|
1e303b6a9d | ||
|
|
8d2aee34ab | ||
|
|
05116cefe6 | ||
|
|
ce4be58eef | ||
|
|
8d6eb4be40 | ||
|
|
834ec91b44 | ||
|
|
38c38f1c64 | ||
|
|
ddf6af79e3 | ||
|
|
826ba515be | ||
|
|
729bded8bf | ||
|
|
b95a06d2d4 | ||
|
|
157d748949 | ||
|
|
1c1f4c1219 | ||
|
|
17bab32794 | ||
|
|
868ddf5d38 | ||
|
|
a1b7a3bcb3 | ||
|
|
cbd419c483 | ||
|
|
25b1cc1e8e | ||
|
|
89adec0ca5 | ||
|
|
f95d055e04 | ||
|
|
7b148f7b5b | ||
|
|
9bd039d1bc | ||
|
|
7c30056d96 | ||
|
|
ac44566c9c | ||
|
|
64f1076d97 | ||
|
|
489c69f5ed | ||
|
|
f897049935 | ||
|
|
d8b66110f7 | ||
|
|
8b1a3bb2e5 | ||
|
|
37771a5a8d | ||
|
|
3a8a31d8d2 | ||
|
|
c36ffcbe56 | ||
|
|
3d8ead8a97 | ||
|
|
141cd78407 | ||
|
|
d0c8124661 | ||
|
|
2917bc5274 | ||
|
|
2d1e93447e | ||
|
|
31b6c9356c | ||
|
|
9e2a7c28f5 | ||
|
|
73b2277af8 | ||
|
|
a84c109604 | ||
|
|
4823acca8f | ||
|
|
34807388b0 | ||
|
|
08be883297 | ||
|
|
13bd0e46db | ||
|
|
6e9a914014 | ||
|
|
7990e5fa8f | ||
|
|
4860a58d07 | ||
|
|
99af9f23bd | ||
|
|
9ebbe2cca7 | ||
|
|
692bae9ea6 | ||
|
|
a6645c4de4 | ||
|
|
06292baadc | ||
|
|
ceda0a68ae | ||
|
|
4fa90c9acf | ||
|
|
c7e61a01e5 | ||
|
|
963e824f5f | ||
|
|
de6bce057a | ||
|
|
937ba1d8dd | ||
|
|
651891c3bd | ||
|
|
4008e2ff6d | ||
|
|
b88130d24b | ||
|
|
fc7ee7efc7 | ||
|
|
d0eb3fe543 | ||
|
|
2ac0faf119 | ||
|
|
775789fbd5 | ||
|
|
7b6fbe7262 | ||
|
|
109d2bda1a | ||
|
|
ddd4e57c65 | ||
|
|
3c2621b41b | ||
|
|
5039be657c | ||
|
|
d02254f754 | ||
|
|
aa1353947e | ||
|
|
171004dfd0 | ||
|
|
c773fe89e7 | ||
|
|
093b5a5518 | ||
|
|
db1665868f | ||
|
|
c07e856d24 | ||
|
|
692ce59bce | ||
|
|
9e7c1aee48 | ||
|
|
4c2eedca5a | ||
|
|
ac6c1e9589 | ||
|
|
0903790b00 | ||
|
|
03de52653e | ||
|
|
da06719309 | ||
|
|
fc84097379 | ||
|
|
4fd725c6e1 | ||
|
|
d39dcea30a | ||
|
|
bfd65398a9 | ||
|
|
452d987e0e | ||
|
|
8ef899f315 | ||
|
|
a18d1146aa | ||
|
|
5b5004e5ac | ||
|
|
6ff8f8fbf9 | ||
|
|
c9616700ca | ||
|
|
4c928dce74 | ||
|
|
fb37d52dde | ||
|
|
363d9c401e | ||
|
|
8643ece345 | ||
|
|
9ba433e521 | ||
|
|
3823fa2c57 | ||
|
|
0a8571b6fe | ||
|
|
ea9f416c99 | ||
|
|
036d8993e6 | ||
|
|
e8530c9fee | ||
|
|
dd4c0109a9 | ||
|
|
43530d4397 | ||
|
|
553d4cba79 | ||
|
|
c62a9ca16b | ||
|
|
424f13fe13 | ||
|
|
4bb6da75ba | ||
|
|
a28175dbfd | ||
|
|
fc204bb5e5 | ||
|
|
6207a45139 | ||
|
|
3c3643f580 | ||
|
|
89c1c43ef9 | ||
|
|
2e9d7ebf15 | ||
|
|
d8ddeec7db | ||
|
|
6f0254e6a8 | ||
|
|
aa17f0e0c1 | ||
|
|
0ae8b681b2 | ||
|
|
6c0067c103 | ||
|
|
5458cb2850 | ||
|
|
0c374868ca | ||
|
|
bf5d3f2e26 | ||
|
|
d5ef837f63 | ||
|
|
b79e28b2c3 | ||
|
|
8ffd5458ff | ||
|
|
b54e1fc4f7 | ||
|
|
bdb6321229 | ||
|
|
bd29a48b56 | ||
|
|
f3f1c3db58 | ||
|
|
608d113486 | ||
|
|
9ae69c3795 | ||
|
|
0960862950 | ||
|
|
44ad25b367 | ||
|
|
40b97b1715 | ||
|
|
4bdb855020 | ||
|
|
ea7136fb83 | ||
|
|
428f8a9b28 | ||
|
|
84faada25b | ||
|
|
55d0abad89 | ||
|
|
7d91b4b90b | ||
|
|
66369416fc | ||
|
|
001e26d0bb | ||
|
|
2e39d698d2 | ||
|
|
e809c2ec35 | ||
|
|
4266d3efc8 | ||
|
|
40a20bc8ae | ||
|
|
f7bf7e9671 | ||
|
|
008ecd4592 | ||
|
|
73a2b12088 | ||
|
|
605bf21ff2 | ||
|
|
f028445407 | ||
|
|
bdf8e614af | ||
|
|
4dea352dee | ||
|
|
151875d144 | ||
|
|
88fd1f00b8 | ||
|
|
1a14d6d2e1 | ||
|
|
381c00a74e | ||
|
|
5aadee6df4 | ||
|
|
a5545dbc9f | ||
|
|
fdf465925e | ||
|
|
36e1ac6556 | ||
|
|
ffa376edf7 | ||
|
|
b777780720 | ||
|
|
347cd0b5f8 | ||
|
|
0ca28b362e | ||
|
|
51b80b985e | ||
|
|
789a98982e | ||
|
|
b202a2f1b5 | ||
|
|
7e79108f8a | ||
|
|
f09cde2542 | ||
|
|
9f9156c030 | ||
|
|
d394293ba5 | ||
|
|
c57a09269b | ||
|
|
8191c58737 | ||
|
|
f68d35c529 | ||
|
|
c02bc4dbe9 | ||
|
|
4872811ba7 | ||
|
|
1a1290f30b | ||
|
|
7be7ca7195 | ||
|
|
32197fa52d | ||
|
|
9653a52a6a | ||
|
|
d60c8942ce | ||
|
|
c99f9e92e0 | ||
|
|
e26356607e | ||
|
|
43e5e80343 | ||
|
|
1742138f05 | ||
|
|
c767d62329 | ||
|
|
7ad29b9831 | ||
|
|
d209fe9b1e | ||
|
|
c5542637d7 | ||
|
|
e7c829fc67 | ||
|
|
579829eef2 | ||
|
|
3aa20f6e75 | ||
|
|
f78279bb2e | ||
|
|
a99d7c6314 | ||
|
|
cf1ed67fcc | ||
|
|
1aec420465 | ||
|
|
16e4b39359 | ||
|
|
9456258ccc | ||
|
|
c41d59f232 | ||
|
|
d682ef88e6 | ||
|
|
c1e6e54e6e | ||
|
|
62f657845e | ||
|
|
a9841a6d1e | ||
|
|
70ecf17f85 | ||
|
|
71d453f169 | ||
|
|
071849f82f | ||
|
|
52084b2948 | ||
|
|
dfbc6b1888 | ||
|
|
e3a8b8434c | ||
|
|
8636848e63 | ||
|
|
3d93b0c52e | ||
|
|
d9942c769e | ||
|
|
6a45e6c256 | ||
|
|
b770a429c6 | ||
|
|
11e69f6025 | ||
|
|
57837bbf67 | ||
|
|
4c60afde78 | ||
|
|
ed689cd54e | ||
|
|
7a44984069 | ||
|
|
dee72ed41f | ||
|
|
1071ef8fc5 | ||
|
|
2b535bc173 | ||
|
|
b791f00bf1 | ||
|
|
3e82ad5340 | ||
|
|
7b1030293c | ||
|
|
a5fd80bbc3 | ||
|
|
fda3937734 | ||
|
|
b13c230749 | ||
|
|
715f39a53a | ||
|
|
2f74e811f1 | ||
|
|
828efc7bcf | ||
|
|
84936b832f | ||
|
|
c8494dff7b | ||
|
|
8fcc212e7a | ||
|
|
0e281530cb | ||
|
|
efded95ed7 | ||
|
|
18870913c5 | ||
|
|
63b7282377 | ||
|
|
269dab4b3e | ||
|
|
4ece43a029 | ||
|
|
8b3e2eab5a | ||
|
|
e4c4ceb286 | ||
|
|
b7e22d00b4 | ||
|
|
1a11c972ae | ||
|
|
43b841f188 | ||
|
|
f9b0460840 | ||
|
|
659d876cd5 | ||
|
|
ac43186dff | ||
|
|
e79fb214f8 | ||
|
|
9cf58d1a52 | ||
|
|
a2a02fd7d7 | ||
|
|
237ee6f231 | ||
|
|
4e57894e85 | ||
|
|
8c9fbbf4f3 | ||
|
|
3f3d61bd58 | ||
|
|
80d4f4afc6 | ||
|
|
2546216019 | ||
|
|
ff8882a24f | ||
|
|
ffe2410639 | ||
|
|
9e14c1f88d | ||
|
|
29a5dfc7c0 | ||
|
|
645bf8b3ab | ||
|
|
f41c536ff3 | ||
|
|
bdd05bdbd3 | ||
|
|
fe385b180f | ||
|
|
0eb5d25453 | ||
|
|
1d98394b41 | ||
|
|
149d9cc851 | ||
|
|
204d8f31d7 | ||
|
|
fbe6fe7f55 | ||
|
|
168eab11a7 | ||
|
|
41b318ac7c | ||
|
|
bf636d9575 | ||
|
|
39d41d0810 | ||
|
|
9d8131c190 | ||
|
|
0ff991b25f | ||
|
|
15c70e562c | ||
|
|
8f34504736 | ||
|
|
551e0c36d9 | ||
|
|
48eba4c195 | ||
|
|
9f605178c3 | ||
|
|
bcafe51378 | ||
|
|
280fe77edd | ||
|
|
b9524f5b72 | ||
|
|
a2018b2c3f | ||
|
|
c21af7e446 | ||
|
|
d73078838d | ||
|
|
22eb0334c3 | ||
|
|
a9ac614691 | ||
|
|
1d0f68dee9 | ||
|
|
ac4bb89d43 | ||
|
|
b55f34029a | ||
|
|
907f58cc3c | ||
|
|
023b0f76c3 | ||
|
|
ddaeebc213 | ||
|
|
1262e685b8 | ||
|
|
0bd78b42c0 | ||
|
|
4a0126f7fb | ||
|
|
7acc8d703d | ||
|
|
77118f3a9f | ||
|
|
e25926d3c4 | ||
|
|
0cb75f1332 | ||
|
|
93b1b78150 | ||
|
|
493922dc4b | ||
|
|
f10854cfc5 | ||
|
|
993e7a937f | ||
|
|
f5af3cfb21 | ||
|
|
e7e112fbd0 | ||
|
|
c42087c789 | ||
|
|
3aa458ea63 | ||
|
|
c4a6f403bb | ||
|
|
9789ea3fb4 | ||
|
|
f416ae1c12 | ||
|
|
d578cf8d3f | ||
|
|
789cb91f31 | ||
|
|
eb1f8d70a7 | ||
|
|
42895efac3 | ||
|
|
483cc77c1c | ||
|
|
9b1ea8b16d | ||
|
|
b41892622d | ||
|
|
9051220243 | ||
|
|
c0031f8b85 | ||
|
|
c1a30ed995 | ||
|
|
565de3f54b | ||
|
|
153ae758c9 | ||
|
|
5086377f30 | ||
|
|
7c0789d2d2 | ||
|
|
2a32565e0c | ||
|
|
7ced0a03d2 | ||
|
|
cb51942669 | ||
|
|
093fb53773 | ||
|
|
21e00e4635 | ||
|
|
09afc6c8ee | ||
|
|
a41a927441 | ||
|
|
3fe01ff09c | ||
|
|
b5ab4d2c13 | ||
|
|
4d79d463ef | ||
|
|
7cb48fc40b | ||
|
|
8bd17bff49 | ||
|
|
3b3f42053a | ||
|
|
70ff8cfe1e | ||
|
|
6249a4b866 | ||
|
|
7e497c7f23 | ||
|
|
1536b7e206 | ||
|
|
e46d0632a5 | ||
|
|
20da167377 | ||
|
|
fe475bd856 | ||
|
|
079f48e8a6 | ||
|
|
aaa043a20f | ||
|
|
48f41e4a41 | ||
|
|
6fb80527f3 | ||
|
|
f86eba2129 | ||
|
|
50f4e0fac9 | ||
|
|
77c135349a | ||
|
|
c449512be4 | ||
|
|
17290b9121 | ||
|
|
3be369522b | ||
|
|
dbfbd8a195 | ||
|
|
9614f51560 | ||
|
|
36896f6dd0 | ||
|
|
2d08235987 | ||
|
|
2291045116 | ||
|
|
9dd1f442c5 | ||
|
|
8edece2cdb | ||
|
|
d001a94d7b | ||
|
|
c2580cfe24 | ||
|
|
dafd6f462f | ||
|
|
2111142cf1 | ||
|
|
0fc961b22e | ||
|
|
5ce34add77 | ||
|
|
934f357149 | ||
|
|
ff2766b024 | ||
|
|
9ef854f5a9 | ||
|
|
a10452be2d | ||
|
|
9cc8e40aa0 | ||
|
|
f49f92737f | ||
|
|
19344ec890 | ||
|
|
a2cc601c3d | ||
|
|
9ab1ba36cd | ||
|
|
f03c3ca6c3 | ||
|
|
0a0ded3268 | ||
|
|
6da520c5a1 | ||
|
|
68dc9af9ac | ||
|
|
f7b30ed3d4 | ||
|
|
e867528209 | ||
|
|
038dfb27a8 | ||
|
|
416c27c995 | ||
|
|
19344efa78 | ||
|
|
9c34aad21c | ||
|
|
7c2dcd7238 | ||
|
|
03149bf7f6 | ||
|
|
497021d0db | ||
|
|
cfdc5b62ad | ||
|
|
9b08e5139b | ||
|
|
e139f977b1 | ||
|
|
9abf5d9fe5 | ||
|
|
273577ba0a | ||
|
|
e15058e60f | ||
|
|
de5cd54124 | ||
|
|
c6cf09450a | ||
|
|
c6e7568471 | ||
|
|
7b8ececd8d | ||
|
|
42ba6c1b22 | ||
|
|
9a2fdf8fd4 | ||
|
|
00812c9053 | ||
|
|
33c59100ae | ||
|
|
36d904011a | ||
|
|
9d9445a48e | ||
|
|
a8da24771c | ||
|
|
ab1d18d00f | ||
|
|
ee431d482a | ||
|
|
e06c09889c | ||
|
|
86dfbda0e4 | ||
|
|
697cebb4c1 | ||
|
|
3c65475561 | ||
|
|
dc6bc0e95a | ||
|
|
b130e951cc | ||
|
|
9e19f132f2 | ||
|
|
1afe22086f | ||
|
|
8e8b9865d1 | ||
|
|
a39827a85c | ||
|
|
9e03df5500 | ||
|
|
dd602eaa61 | ||
|
|
d0d2c39dec | ||
|
|
57fec74966 | ||
|
|
9360e0ef32 | ||
|
|
f08c019d41 | ||
|
|
c3af8f6b16 | ||
|
|
01c4919f5f | ||
|
|
cdacc12ce3 | ||
|
|
d8c527a5f9 | ||
|
|
b22edcf3a5 | ||
|
|
786cff8db9 | ||
|
|
b63afaea61 | ||
|
|
9c89f7c2af | ||
|
|
d46870ede5 | ||
|
|
a888ce9963 | ||
|
|
8ff3091d16 | ||
|
|
d9f84854ac | ||
|
|
89fe2680a9 | ||
|
|
7cee982f90 | ||
|
|
42358cc521 | ||
|
|
06869ff22f | ||
|
|
616bde08ac | ||
|
|
6d0828b81c | ||
|
|
42ddf02ffc | ||
|
|
56390e0a39 | ||
|
|
18a5835aff | ||
|
|
67960dcc9a | ||
|
|
0b355ae811 | ||
|
|
6a9bb2a622 | ||
|
|
988e59cf3e | ||
|
|
30e06e9d85 | ||
|
|
810daefdd1 | ||
|
|
ccc9dc3bb4 | ||
|
|
be2eb57d62 | ||
|
|
c07d582e24 | ||
|
|
afb3a5fe71 | ||
|
|
020c403dff | ||
|
|
e77e11ec6b | ||
|
|
3edda3c5e7 | ||
|
|
1184dc08d4 | ||
|
|
18838fbc87 | ||
|
|
be2617036f | ||
|
|
0f6227f46b | ||
|
|
c1ac007576 | ||
|
|
201a8d8e7e | ||
|
|
b566cd57bf |
7
.github/CONTRIBUTING.md
vendored
7
.github/CONTRIBUTING.md
vendored
@@ -63,7 +63,7 @@ tmux -vv -Ltest -f/dev/null new
|
||||
|
||||
Or if you need your configuration:
|
||||
|
||||
~~~base
|
||||
~~~bash
|
||||
tmux kill-server
|
||||
tmux -vv new
|
||||
~~~
|
||||
@@ -77,3 +77,8 @@ The log files are:
|
||||
- `tmux-out*.log`: output log file.
|
||||
|
||||
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
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
blank_issues_enabled: false
|
||||
@@ -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
|
||||
|
||||
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
|
||||
|
||||
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`).
|
||||
* 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`).
|
||||
2
.github/README.md
vendored
2
.github/README.md
vendored
@@ -79,7 +79,7 @@ A small example configuration is in `example_tmux.conf`.
|
||||
|
||||
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
|
||||
files in the current directory.
|
||||
|
||||
11
.github/copilot-instructions.md
vendored
Normal file
11
.github/copilot-instructions.md
vendored
Normal 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.
|
||||
28
.github/workflows/lock.yml
vendored
28
.github/workflows/lock.yml
vendored
@@ -3,21 +3,33 @@ name: 'Lock Threads'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
discussions: write
|
||||
|
||||
concurrency:
|
||||
group: lock-threads
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
action:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'tmux/tmux'
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v2
|
||||
- uses: dessant/lock-threads@v6
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
issue-lock-inactive-days: '30'
|
||||
pr-lock-inactive-days: '60'
|
||||
issue-lock-comment: >
|
||||
issue-inactive-days: '30'
|
||||
issue-comment: >
|
||||
This issue has been automatically locked since there
|
||||
has not been any recent activity after it was closed.
|
||||
Please open a new issue for related bugs.
|
||||
pr-lock-comment: >
|
||||
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.
|
||||
Please open a new issue for related bugs.
|
||||
discussion-inactive-days: '60'
|
||||
discussion-comment: >
|
||||
This discussion has been automatically locked since there
|
||||
has not been any recent activity after it was closed.
|
||||
|
||||
88
.github/workflows/regress.yml
vendored
Normal file
88
.github/workflows/regress.yml
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
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 }}
|
||||
if: github.repository == 'tmux/tmux'
|
||||
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
38
.gitignore
vendored
@@ -1,23 +1,27 @@
|
||||
*.o
|
||||
*~
|
||||
*.diff
|
||||
*.patch
|
||||
*.core
|
||||
core
|
||||
tags
|
||||
*.dSYM
|
||||
*.diff
|
||||
*.o
|
||||
*.patch
|
||||
*.swp
|
||||
*~
|
||||
.deps/
|
||||
compat/.dirstamp
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
config.log
|
||||
config.status
|
||||
etc/
|
||||
tmux
|
||||
.dirstamp
|
||||
.serena/
|
||||
AGENTS.md
|
||||
Makefile
|
||||
Makefile.in
|
||||
configure
|
||||
tmux.1.*
|
||||
*.dSYM
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
cmd-parse.c
|
||||
compat/.dirstamp
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
core
|
||||
etc/
|
||||
fuzz/*-fuzzer
|
||||
.dirstamp
|
||||
regress/logs/
|
||||
tags
|
||||
tmux
|
||||
tmux.1.*
|
||||
|
||||
1
.mailmap
1
.mailmap
@@ -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> deraadt <deraadt>
|
||||
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> n6tadam <n6tadam@xteddy.org>
|
||||
Tim van der Molen <tim@openbsd.org> tim <tim>
|
||||
|
||||
979
CHANGES
979
CHANGES
@@ -1,3 +1,978 @@
|
||||
CHANGES FROM 3.7c TO 3.8
|
||||
|
||||
* Many improvements to floating panes:
|
||||
|
||||
- new-pane and split-window can now set the title with -T and border lines
|
||||
with -B, and new-pane -W waits for the pane command to exit;
|
||||
|
||||
- dragging with Ctrl now creates a new floating pane;
|
||||
|
||||
- modal panes may be created with new-pane -O; a window can have one modal
|
||||
pane and it prevents interaction with the other panes while it is active.
|
||||
A modal pane is now used for the editor in buffer mode;
|
||||
|
||||
- move-pane and resize-pane can now move and resize floating panes, including
|
||||
mouse dragging;
|
||||
|
||||
- split-window in a floating pane creates a new floating pane that does not
|
||||
overlap the active pane, if possible;
|
||||
|
||||
- break-pane can float a tiled pane, join-pane can tile a floating pane, and
|
||||
swap-pane works with floating panes;
|
||||
|
||||
- choose-tree -h and choose-client -h hide the pane containing the mode, and
|
||||
-k for choose commands kills the pane when the mode exits, which is useful
|
||||
for modes in floating panes;
|
||||
|
||||
- pane-border-status has top-floating and bottom-floating, and there are new
|
||||
default bindings under C-b g for common move and resize operations;
|
||||
|
||||
- floating panes are unzoomed before creation to avoid a crash.
|
||||
|
||||
* Add support for themes and improve default colours:
|
||||
|
||||
- tmux now has builtin light and dark colour themes for terminals with 256 or
|
||||
more colours; a new theme option controls whether tmux detects the terminal
|
||||
theme, uses terminal colours, or forces light or dark (set to terminal for
|
||||
the old colours);
|
||||
|
||||
- styles can use new theme colour names such as themeblack, themewhite and
|
||||
themegreen, and colours in styles are expanded as formats;
|
||||
|
||||
- the terminal's own theme is reported to panes instead of being guessed from
|
||||
the background, and inferred more accurately when theme reporting is not
|
||||
supported (Ayman Bagabas, issue 5343);
|
||||
|
||||
- tree-mode-selection-style has been added, tree mode selection styling now
|
||||
covers the whole line, and built-in modes use improved theme colours.
|
||||
|
||||
* Improvements to customize mode:
|
||||
|
||||
- hooks and environment variables are now shown;
|
||||
|
||||
- e opens the selected value in an editor;
|
||||
|
||||
- C toggles showing only changed items;
|
||||
|
||||
- array item keys can now be changed.
|
||||
|
||||
* Hooks (and control mode notifications) are now handled internally by using
|
||||
events, each of which may carry keys and values as a payload. The control
|
||||
mode subscriptions mechanism has been extended to allow general-purpose
|
||||
"monitors" which check a format every second and trigger a hook when it
|
||||
changes or becomes true:
|
||||
|
||||
- set-hook -B adds a monitor hook using the same subscription syntax as
|
||||
refresh-client -B, and show-hooks -B lists them. -T runs the hook only when
|
||||
the format is true;
|
||||
|
||||
- wait-for -E waits for hooks, notifications or user events, and set-hook -E
|
||||
fires an event immediately;
|
||||
|
||||
- hooks have additional keys available. wait-for -v can be used to see the
|
||||
keys sent with a hook event;
|
||||
|
||||
- new hooks to cover areas including client create and destroy, pane
|
||||
activity, pane mode and prompt changes, pane movement and resizing, session
|
||||
group changes and window creation, close and zoom;
|
||||
|
||||
- OSC 133 escape sequences now trigger events: pane-command-started,
|
||||
pane-command-finished and pane-shell-prompt.
|
||||
|
||||
* Add switch-mode, a fast switcher bound by default to Tab for windows and BTab
|
||||
(S-Tab) for sessions.
|
||||
|
||||
* Pane scrollbars now support auto-hide. This replaces the previous modal
|
||||
behaviour where the pane was resized. With auto-hide, the scrollbar appears
|
||||
while scrolling or while hovered and disappears after pane-scrollbars-timeout
|
||||
(Michael Grant).
|
||||
|
||||
* Extend the fill-character option so both inside and outside the window can be
|
||||
changed.
|
||||
|
||||
* Change set-option and set-hooks to use formats and add a -F flag to each.
|
||||
|
||||
* Add a #{A/count:frames} modifier to show a series of frames as an animation
|
||||
in the status line (issue 5412 from Fernando Daciuk).
|
||||
|
||||
* Change command templates so %% is escaped for single quotes while %1 remains
|
||||
unquoted, preventing single quotes in session or target names from
|
||||
terminating quoted command sections (reported by Aliz Hammond).
|
||||
|
||||
* display-panes is now a mode rather than an overlay, and can be run inside
|
||||
another pane. The -b flag has been removed.
|
||||
|
||||
* Add new-window -E, respawn-pane -E and respawn-window -E as more convenient
|
||||
methods to create an empty pane (rather than using '' for the command).
|
||||
|
||||
* Menus now belong to the window, so appear on all clients.
|
||||
|
||||
* Dragging over an existing copy mode selection now adjusts it (Michael Grant).
|
||||
|
||||
* Rectangle selection in copy mode may extend past the end of the current line
|
||||
to match vi's virtualedit=block behaviour (Mark Kelly, issue 5227).
|
||||
|
||||
* With mode-keys set to vi, scrolling in copy mode now keeps the cursor in the
|
||||
same position relative to the text (Arseniy Simonov, issue 5216).
|
||||
|
||||
* Copy mode no longer exits at the bottom while a selection is in progress
|
||||
(issue 5349).
|
||||
|
||||
* Add style attributes for dimming colours (dim=) and for hyperlinks (link= and
|
||||
nolink) (issues 4842 and 4280 from Moritz Angermann).
|
||||
|
||||
* New format modifiers: O: loops over options, V: loops over environments,
|
||||
the I modifier reports client terminal information, t/d gives a time
|
||||
difference in seconds, c/f and c/b emit colours, and the m operator supports
|
||||
multiple terms and fuzzy matching.
|
||||
|
||||
* Add or improve format variables including client_colours,
|
||||
pane_start_command_list, window_manual_width, window_manual_height,
|
||||
pane_last_output_time, pane_modal_flag and window_modal_pane.
|
||||
|
||||
* Add additional pane sort orders, and a z sort order for choose-tree so
|
||||
floating panes can be sorted by z-index.
|
||||
|
||||
* Add -f filters to kill-pane -a, kill-window -a and kill-session -a (issue
|
||||
4782).
|
||||
|
||||
* Allow server ACLs to use groups as well as users (issue 4917).
|
||||
|
||||
* The mouse option now defaults to on.
|
||||
|
||||
* Fix send-keys -K so keys are inserted in the correct place in the input
|
||||
queue, like keys from key bindings (issue 3476).
|
||||
|
||||
* Fix control mode clients hanging on exit if pty data was still queued (Ben
|
||||
Maurer, issue 5356), and avoid sending notifications to clients which are
|
||||
already exiting (Ben Maurer, issue 5357).
|
||||
|
||||
* Fix grouped sessions sometimes being left as unusable command targets while
|
||||
they are being killed (Bryce Miller, issue 5180).
|
||||
|
||||
* Fix choose mode filtering when more than one pane exists (issue 5326), and
|
||||
fix an infinite loop in customize mode when a filter does not match.
|
||||
|
||||
* Fix regsub when the pattern is anchored at the start (issue 5341).
|
||||
|
||||
* Fix redraw issues around synchronized updates, copy mode, tabs, padding,
|
||||
status lines, menus, popups, wide characters and floating panes. This
|
||||
includes fixes for flicker with alternate screen applications and scrollbars
|
||||
(Michael Grant, issue 5351; Noam Stolero, issue 5350; Aung Myo Kyaw, issue
|
||||
5098).
|
||||
|
||||
* Do not crash looking for the next or previous session (issue 5344), or when
|
||||
no client is available.
|
||||
|
||||
CHANGES FROM 3.7b TO 3.7c
|
||||
|
||||
* Build with jemalloc on macOS to avoid what appears to be a bug in calloc
|
||||
(issue 5385).
|
||||
|
||||
* Fix scrollbar initial state so they appear on new windows (issue 5339).
|
||||
|
||||
* Check time periodically in loops rather than every one (issue 5367).
|
||||
|
||||
* Use message-style again as default for message-format.
|
||||
|
||||
* Unzoom before creating floating panes to avoid a crash.
|
||||
|
||||
CHANGES FROM 3.7a TO 3.7b
|
||||
|
||||
* Fix so that the end of a synchronized update again triggers a redraw.
|
||||
|
||||
CHANGES FROM 3.7 TO 3.7a
|
||||
|
||||
* Fix crash in break-pane when no name is provided.
|
||||
|
||||
* Scrollbar options are now cached rather than being looked up for every redraw
|
||||
(issue 5298).
|
||||
|
||||
* Only forbid #( in names, allow #[, empty names, : and .
|
||||
|
||||
CHANGES FROM 3.6b TO 3.7
|
||||
|
||||
* Add 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.
|
||||
|
||||
This is an early release of this feature and they are relatively limited.
|
||||
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. Many obvious features are not yet available for floating
|
||||
panes (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; testing and fixes
|
||||
from others.
|
||||
|
||||
* Allow run-shell arguments after a shell command to be expanded as #{1}, #{2}
|
||||
and so on (from Rasmus Thystrup Karstensen in issue 5121).
|
||||
|
||||
* Add -g to kill-session to kill all sessions in a session group (issue 5157
|
||||
from github at jiku dot jp).
|
||||
|
||||
* 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).
|
||||
|
||||
* 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 issue
|
||||
5088).
|
||||
|
||||
* 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 issue 5070).
|
||||
|
||||
* 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 issue 4527).
|
||||
|
||||
* Show file open errors more sensibly (reported by Meriel Luna Mittelbach in
|
||||
issue 5081).
|
||||
|
||||
* Update supported features list for Foot terminal (from Meriel Luna Mittelbach
|
||||
in issue 5079).
|
||||
|
||||
* Turn off the "is this a paste" guessing if the terminal supports bracket
|
||||
pasting instead (issue 5031).
|
||||
|
||||
* Check FIONREAD for all panes not just piped panes.
|
||||
|
||||
* Add emacs-style recentre-top-bottom command to copy mode (issue 5053 from
|
||||
sinyax75 at gmail dot com).
|
||||
|
||||
* Allow the indicator in tree mode to be customized by two new options:
|
||||
tree-mode-preview-format and tree-mode-preview-style.
|
||||
|
||||
* Fix control client hang on exit after toggling no-output (issue 5049 from
|
||||
Aaron Campbell). Also various other control mode fixes.
|
||||
|
||||
* Add support for line numbers in copy mode. There is a new
|
||||
copy-mode-line-numbers option which may be set to 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 issue 5025.
|
||||
|
||||
* Make C-[ have the same bindings as Escape for terminals with extended
|
||||
keys where they are different (issue 5035 from Eric Nicolas).
|
||||
|
||||
* Sanitize paste buffer names in paste_set and paste_rename (issue 5032 from
|
||||
Barrett Ruth).
|
||||
|
||||
* Do not hang in run-shell when job_run fails (from Barrett Ruth in issue
|
||||
5037).
|
||||
|
||||
* Add ability to forward progress bar to outside terminal (issue 4972
|
||||
from Eric Dorland).
|
||||
|
||||
* Translate keypad keys to text in prompt input (from Barrett Ruth in issue
|
||||
4996).
|
||||
|
||||
* Sanitize pane titles and window and session names more consistently and
|
||||
strictly, prevents C0 characters and other invisible characters causing
|
||||
problems (reported by Chris Monardo in issue 4999).
|
||||
|
||||
* Make clock visible on terminals without colours (from Manuel Einfalt in issue
|
||||
5001).
|
||||
|
||||
* Add detach to default session menu (suggested by Przemyslaw Sztoch).
|
||||
|
||||
* Include window format variables for pane notifications (issue 5007 from Saul
|
||||
Nogueras).
|
||||
|
||||
* Limit precision to 100 for formats to stop silly formats from running out of
|
||||
memory, reported by z1281552865 at gmail dot com. Also various other similar
|
||||
changes, mostly found by OSS-Fuzz.
|
||||
|
||||
* Add WAYLAND_DISPLAY to default update-environment (issue 4965). Also some
|
||||
additional XDG_* variables (issue 5169).
|
||||
|
||||
* Add -C flag to command-prompt to match display-message -C (do not freeze
|
||||
panes) (from Barrett Ruth in issue 4978).
|
||||
|
||||
* Cache user from getpwuid because it can be very expensive on some
|
||||
platforms (from Ben Maurer in issue 4973).
|
||||
|
||||
* Add remain-on-exit key to keep pane around until a key is pressed (from
|
||||
Michael Grant).
|
||||
|
||||
* Add some new mouse ranges called "control0" to "control9" and use to add some
|
||||
mouse controls to the pane state line (from Dane Jensen with some bits from
|
||||
Michael Grant).
|
||||
|
||||
* Handle OSC 9;4 progress bar sequence and store in format variables (from Eric
|
||||
Dorland in issue 4954).
|
||||
|
||||
* Correctly size buffer used for parsing clipboard sequences (from Michal
|
||||
Majchrowicz).
|
||||
|
||||
* Limit MSG_COMMAND argument to between 0 and 1000 to prevent a misbehaving
|
||||
client from crashing the server (from Michal Majchrowicz).
|
||||
|
||||
* Reorganize host keys are represented internally so they can be built more
|
||||
easily (from Dane Jensen in issue 4953).
|
||||
|
||||
* Add new fuzzers for command parsing, formats and styles (from David
|
||||
Korczynski in issue 4957). Also fix various issues shown from these.
|
||||
|
||||
* Add bracket_paste_flag format flag (from George Nachman in issue 4951).
|
||||
|
||||
* Use \- for hyphens in tmux.1 to cause newer groff versions to render them
|
||||
correctly (from Keith Thompson in issue 4948).
|
||||
|
||||
* Various minor code improvements and fixes from Pavel Lavrukhin (issue 4936
|
||||
and others).
|
||||
|
||||
* Use window options for cursor-style to avoid crash when no pane (from Arden
|
||||
Packeer in issue 4942).
|
||||
|
||||
* Fix issue where popup window gets overwritten by background updates (from
|
||||
Conor Taylor in issue 4920).
|
||||
|
||||
* Protect against overflow when scrollbar is off screen (from san65384 at gmail
|
||||
dot com in issue 4933).
|
||||
|
||||
* Copy hyperlinks when redrawing popup so they do not vanish (from Antoine
|
||||
Gaudreau Simard in issue 4925).
|
||||
|
||||
* Work around systemd killing panes early during system shutdown by creating
|
||||
dependencies from the panes to the service which started tmux (issue 4926
|
||||
from Dmitry Torokhov).
|
||||
|
||||
* Allow codepoint-widths to accept ranges (from san65384 at gmail dot com in
|
||||
issue 4930).
|
||||
|
||||
* Add a short builtin help text for each mode accessible with C-h (based on
|
||||
code from Patrick Motard in issue 4751).
|
||||
|
||||
* 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). The message-style option now need to
|
||||
include "fill" in order to cover the whole width (the default has
|
||||
"fill=yellow"). From Conor Taylor in issue 4861.
|
||||
|
||||
* Add next/previous variables for windows in W: loop (from Conor Taylor in
|
||||
issue 4856).
|
||||
|
||||
* Various bug and memory leak fixes from Renaud Allard (issue 4916).
|
||||
|
||||
* Add pane_pipe_pid with pipe file descriptor.
|
||||
|
||||
* Make -c work with new-session -A (from Jody Frankowski in issue 4906).
|
||||
|
||||
* Allow copy mode to work for readonly clients, except for copy commands (from
|
||||
Dane Jensen).
|
||||
|
||||
* Pass paste buffer through vis(3) when pasting to prevent buffers containing
|
||||
for example the bracket end sequence causing issues, a new -S flag disables
|
||||
(reported by Mason Davis).
|
||||
|
||||
* Add sorting (-O flag) and a custom format (-F) to list-keys (from Dane Jensen
|
||||
in issue 4845).
|
||||
|
||||
* Add scroll-exit-on, scroll-exit-off, scroll-exit-toggle commands to copy mode
|
||||
(from xcdnlgd at hotmail dot com in issue 4884).
|
||||
|
||||
* Respond to DECRQM 2026 (from David Turnbull in issue 4887) and various others
|
||||
(from Ayman Bagabas in issue 5118).
|
||||
|
||||
* Fix various memory leaks reported by Huihui Huang (issue 4872).
|
||||
|
||||
* Pass which clipboard is set through to the terminal (from Axel Lindskog in
|
||||
issue 4858).
|
||||
|
||||
* Reuse extended entry when clearing RGB cell, to prevent memory growth when
|
||||
cells are repeatedly cleared (from Michael K Darling in issue 4862).
|
||||
|
||||
* 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).
|
||||
|
||||
* Various bug fixes and code improvements from Conor Taylor (issue 4848).
|
||||
|
||||
* Clear search counts when clearing marks in case of repeated search (reported
|
||||
by Daniel Pereira in issue 4817).
|
||||
|
||||
* Make OSC 52 work in popups (from gogongxt at 163 dot com in issue 4797).
|
||||
|
||||
* Refresh copy mode when style changes (from Josh Cooper in issue 4830).
|
||||
|
||||
* Make sorting code common and add -O for sorting to the list commands (from
|
||||
Dane Jensen in issue 4813).
|
||||
|
||||
* Do not treat cells as empty unless the background colour stays the same,
|
||||
fixes invisible clock in clock mode (reported by Theo Buehler).
|
||||
|
||||
* When history-limit is changed, apply to existing panes, not just new
|
||||
ones (issue 4705).
|
||||
|
||||
* Reevaluate menu and popup styles on each draw to allow them to change when
|
||||
options change (from Josh Cooper in issues 4828 and 4829).
|
||||
|
||||
* Handle theme keys earlier so they are processed even if a popup is open (from
|
||||
Josh Cooper in issue 4827).
|
||||
|
||||
* Fix window-size=latest not resizing on switch-client in session groups (from
|
||||
Ilya Grigoriev in issue 4818).
|
||||
|
||||
* Add -e flag to command-prompt to close if empty (from Dane Jensen in issue
|
||||
4812).
|
||||
|
||||
* Correctly draw indicators when pane-border-indicators is set to both
|
||||
(reported by Ilya Grigoriev in issue 4780).
|
||||
|
||||
* 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
|
||||
(issue 4795 from Shaobo Song).
|
||||
|
||||
* Add paste to the default pane menu (issue 4763).
|
||||
|
||||
* Reduce request timeout to 500 milliseconds to match the extended escape-time,
|
||||
and discard palette requests if receiving a reply for a different index.
|
||||
|
||||
* Extend escape timeout if there are active forwarded requests not just
|
||||
tmux's own requests (issue 4793).
|
||||
|
||||
* Correct redrawing of wide characters when overwritten (reported by Jake
|
||||
Stewart in issue 4737).
|
||||
|
||||
* If cannot find a terminator for palette responses, treat as a partial key not
|
||||
complete (issue 4749).
|
||||
|
||||
* Do not send theme unless it has changed, and do not send immediately when
|
||||
updates are enabled (issue 5787).
|
||||
|
||||
* Do not use ;;s in list-keys output as it is confusing and cannot be
|
||||
parsed on input (from Patrick Motard in issue 4750).
|
||||
|
||||
* Redraw pane borders when entering or leaving alternate screen (from Mike
|
||||
Jonkmans in issue 4788).
|
||||
|
||||
* Add focus-follows-mouse option (from Barry Wasdell in issue 4771).
|
||||
|
||||
* Add selection_mode format variable for copy mode (from Mike Jonkmans in issue
|
||||
4773).
|
||||
|
||||
* Add prompt-command-cursor-style (from Joshua Cooper in issue 4765).
|
||||
|
||||
* With status-keys vi, move the cursor left by one when pressing Escape to
|
||||
enter command mode, like vi (issue 4767 from Joshua Cooper).
|
||||
|
||||
* Add {current}/{active} for -t for current window or active pane (from Manuel
|
||||
Einfalt, issue 4766).
|
||||
|
||||
* Add support for applications to use synchronized output mode (DECSET 2026) to
|
||||
prevent screen tearing during rapid updates (from Chris Lloyd in issue 4744).
|
||||
|
||||
* Do not set a default prompt cursor colour because some terminals (urxvt, st)
|
||||
do not support the reset sequence (issue 4759).
|
||||
|
||||
* 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 in issue 4731).
|
||||
|
||||
* Bump the maximum number of SIXEL images to 20.
|
||||
|
||||
* Fix key code for M-BSpace (issue 4717).
|
||||
|
||||
* Fix calculation of scaled SIXEL size (from nincsnevem662 at gmail dot com in
|
||||
issue 4739). Also various other fixes and improvements for SIXEL.
|
||||
|
||||
* Fix a race between fork and pane_current_path, most noticeable on systems
|
||||
where starting processes is slow (issue 4719).
|
||||
|
||||
* Fix mouse position calculation on scrollbar with pane status line at the top
|
||||
(issue 4738 from Michael Grant).
|
||||
|
||||
* Do not read outside buffer if format is a single #, and do not loop forever
|
||||
if UTF-8 is unfinished in a format (reported by Giorgi Kobakhia in issue
|
||||
4735).
|
||||
|
||||
* Add a missing skin tone character (from Jake Stewart in issue 4736).
|
||||
|
||||
* Allow UTF-8 characters to be combined in either order (reported by Jake
|
||||
Stewart in issue 4726).
|
||||
|
||||
* Do not show scrollbar when entering copy mode from a pane in the alternate
|
||||
screen (issue 4728 from Michael Grant).
|
||||
|
||||
* Fix the size calculation for left-right windows used to spread out cells
|
||||
horizontally evenly (from Michael Grant in issue 4724).
|
||||
|
||||
* Add a get-clipboard option which when enabled (the default is off) and a
|
||||
clipboard is requested from a pane, requests it from the terminal and
|
||||
forwards to the requesting pane; also remove the now-redundant
|
||||
forward-to-pane ability from "refresh-client -l" (issue 4275).
|
||||
|
||||
* Fix the noattr attribute in styles, used by the default mode-style (issue
|
||||
4713).
|
||||
|
||||
* Do not remove TERM for commands run from config file (regression reported by
|
||||
Dennis Eriksen).
|
||||
|
||||
* Add seconds options for clock mode (from augustus7613 dot mail at pm dot me,
|
||||
issue 4697; later improved by Joao Pedro in issue 4760).
|
||||
|
||||
CHANGES FROM 3.6a TO 3.6b
|
||||
|
||||
* Remove images from the correct list when they are removed while in the
|
||||
alternate screen (reported by xlabai at tencent dot com).
|
||||
|
||||
CHANGES FROM 3.6 TO 3.6a
|
||||
|
||||
* Fix a buffer overread and an infinite loop in format processing (reported by
|
||||
Giorgi Kobakhia, issue 4735).
|
||||
|
||||
* Allow drag in alternate screen again (issue 4743 reported by Brad King).
|
||||
|
||||
* Fix y offset of mouse if status at top (issue 4738 from Michael Grant).
|
||||
|
||||
* Add a missing skin tone (from Jake Stewart, issue 4736).
|
||||
|
||||
* Allow characters to be combined in either order (issue 4726, reported by Jake
|
||||
Stewart).
|
||||
|
||||
* Fix horizontal mouse resizing when pane status lines are on (from Michael
|
||||
Grant, issue 4720).
|
||||
|
||||
* Fix noattr so it does not delete attributes set in the style itself (issue
|
||||
4713).
|
||||
|
||||
* Newer libevents do not allow event_del on a zero'd event (issue 4706).
|
||||
|
||||
* Place cursor on correct line if message-line is not 0 (issue 4707).
|
||||
|
||||
* Fix compile error on FreeBSD (from Yasuhiro Kimura, issue 4701).
|
||||
|
||||
CHANGES FROM 3.5a TO 3.6
|
||||
|
||||
* Add seconds options for clock mode (issue 4697).
|
||||
|
||||
* Add a resize callback for menus so that they are correctly moved on resize
|
||||
(issue 4696).
|
||||
|
||||
* Make -v to source-file pass through to subsequent source-file commands (issue
|
||||
4216).
|
||||
|
||||
* If display-popup is used inside a popup, modify that popup (issue 4678).
|
||||
|
||||
* Add selection-mode command to expilcitly set the selection mode in copy mode
|
||||
(issue 3842).
|
||||
|
||||
* Save and restore images in alternate screen (issue 3732).
|
||||
|
||||
* Ignore Hangul filler character (issue 3998).
|
||||
|
||||
* Improve handling of regional indicators and emoji modifiers (issue 3998).
|
||||
|
||||
* Preserve marked pane with swap-window and move-window (issue 3443).
|
||||
|
||||
* Set and check COLORTERM as a hint for RGB colour.
|
||||
|
||||
* 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, issue
|
||||
4665).
|
||||
|
||||
* Add -l flag to command-prompt to disable splitting into multiple prompts
|
||||
(issue 4483).
|
||||
|
||||
* Don't enter copy mode on mouse wheel in alternate screen (issue 3705).
|
||||
|
||||
* Add commands to centre the cursor in copy mode (issue 4662).
|
||||
|
||||
* Support case insensitive search in modes in the same way as copy mode
|
||||
(like emacs, so all-lowercase means case insensitive) (issue 4396).
|
||||
|
||||
* Fix the logic of the no-detached case for the detach-on-destroy option (from
|
||||
Martin Louazel, issue 4649).
|
||||
|
||||
* Add buffer_full format variable (from Mohammad AlSaleh, issue 4630).
|
||||
|
||||
* Introduce a new window option, tiled-layout-max-columns, which configures the
|
||||
maximum number of columns in the tiled layout.
|
||||
|
||||
* Add support for DECRQSS SP q (report cursor style), DECRQM ?12 (report cursor
|
||||
blink state) and DECRQM ?2004, ?1004, ?1006 (report mouse state) ( rom
|
||||
Andrea Alberti, issue 4618).
|
||||
|
||||
* Fix missing argument from OSC 4 reply (issue 4596).
|
||||
|
||||
* Add -k flag to display-popup which allows any key to dismiss the popup once
|
||||
the command has exited (from Meriel Luna Mittelbach, issue 4612).
|
||||
|
||||
* Add nicer default second and third status lines (from Michael Grant, issue
|
||||
4490).
|
||||
|
||||
* Add a pane-border-lines "spaces" value to use spaces for pane borders (issue
|
||||
4587).
|
||||
|
||||
* Replace invalid UTF-8 characters with the placeholder instead of ignoring
|
||||
them (issue 4514).
|
||||
|
||||
* Fix incorrect handling of Korean Hangul Jamo characters (from Roy Jung, issue
|
||||
4546).
|
||||
|
||||
* Allow uppercase letters in gray/grey color names (from Pavel Roskin, issue
|
||||
4560).
|
||||
|
||||
* Add sorting to W, P, L loop operators (from Michael Grant, issue 4516).
|
||||
|
||||
* Detect support for OSC 52 using the device attributes report (from James
|
||||
Holderness, issue 4539).
|
||||
|
||||
* Add noattr for styles and use in mode-style to allow whether attributes are
|
||||
ignored or used to be configured (issue 4498).
|
||||
|
||||
* Add a set-default style attribute which replaces the current default colours
|
||||
and attributes completely.
|
||||
|
||||
* Add -E to run-shell to forward stderr as well as stdout (issue 4246).
|
||||
|
||||
* 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.
|
||||
|
||||
* Switch to getopt_long from OpenSSH (from Koichi Murase, issue 4492).
|
||||
|
||||
* 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
|
||||
(from David Mandelberg).
|
||||
|
||||
* Do not mistake other DCS sequences for SIXEL sequences (from James
|
||||
Holderness, issue 4488).
|
||||
|
||||
* Improve #? conditional expression in formats: add support for else if and
|
||||
default empty string if no else value (from David Mandelberg, issue 4451).
|
||||
|
||||
* Add default-client-command to set the command used if tmux is run without a
|
||||
command; the default stays new-session (from David Mandelberg, issue
|
||||
4422).
|
||||
|
||||
* Add S-Up and S-Down to move windows in tree mode (from David Mandelberg,
|
||||
issue 4415).
|
||||
|
||||
* 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 (from Jonathan Slenders, issue 4353).
|
||||
|
||||
* Add -M flag to capture-pane to use the copy mode screen (issue 4358).
|
||||
|
||||
* Align index numbers in trees (from David Mandelberg, issue 4360).
|
||||
|
||||
* Add display-message -C flag to update pane while message is displayed (from
|
||||
Vitaly Ostrosablin, issue 4363).
|
||||
|
||||
* Make list-commands command show only one command if an argument is given
|
||||
(from Ilya Grigoriev, issue 4352).
|
||||
|
||||
* Count line numbers correctly inside strings in configuration files (reported
|
||||
by Pedro Navarro, issue 4325).
|
||||
|
||||
* 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, issue 4322).
|
||||
|
||||
* New codepoint-widths option allowing users to override the width of
|
||||
individual Unicode codepoints.
|
||||
|
||||
* Add a nesting limit to source-file (from Fadi Afani, issue 4223).
|
||||
|
||||
* Add copy-mode-position-style and copy-mode-selection-style options for copy
|
||||
mode.
|
||||
|
||||
* Add no-detach-on-destroy client option (issue 4242).
|
||||
|
||||
* Add input-buffer-size option (from Ken Lau).
|
||||
|
||||
* 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 (from
|
||||
Michael Grant, issue 4221).
|
||||
|
||||
* Allow control characters to be entered at the command prompt by prefixing
|
||||
with C-v (from Alexander Arch, issue 4206).
|
||||
|
||||
* Do not attempt to search for zero length strings (from Alexander Arch, issue
|
||||
4209).
|
||||
|
||||
* Preserve tabs for copying and capture-pane (from Alexander Arch, issue
|
||||
4201).
|
||||
|
||||
* Increase the maximum for repeat-time.
|
||||
|
||||
* Adjust how Ctrl and Meta keys are sent to use standard representation if
|
||||
available in mode 1 (from Stanislav Kljuhhin, issue 4188).
|
||||
|
||||
* Allow attributes in menu style (from Japin Li, issue 4194).
|
||||
|
||||
* Add a sixel_support format variable which is 1 if SIXEL is supported, always
|
||||
0 on OpenBSD (requested by Misaki Masa, issue 4177).
|
||||
|
||||
* 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, issue 4170).
|
||||
|
||||
* Add initial-repeat-time option to allow the first repeat time to be increased
|
||||
and later reduced (from David le Blanc, issue 4164).
|
||||
|
||||
* Send focus events to pane when entering or leaving popup (issue 3991).
|
||||
|
||||
* Add copy-mode-position-format to configure the position indicator.
|
||||
|
||||
* Add -y flag to disable confirmation prompts in modes (issue 4152).
|
||||
|
||||
* Add -C and -P flags to the copy commands in copy mode: -C prevents the
|
||||
commands from sending the text to the clipboard and -P prevents them from
|
||||
adding the text as a paste buffer (issue 4153).
|
||||
|
||||
* Preserve transparency and raster attribute dimensions when sending a SIXEL
|
||||
image, and avoid collapsing empty lines (issue 4149).
|
||||
|
||||
* Bypass permission check for Cygwin (based on a change by Yuya Adachi via
|
||||
Rafael Kitover, issue 4148).
|
||||
|
||||
* Add MSYSTEM to default update-environment (for Cgywin).
|
||||
|
||||
* Set client stdout file descriptor also for Cgywin (from Michael Wild via Rafael
|
||||
Kitover, issue 4148).
|
||||
|
||||
* Use global cursor style and colour options for modes instead of default
|
||||
(issue 4117).
|
||||
|
||||
* Fix pasting so it does not interpret keys but instead copies the input
|
||||
without interpretation (reported by Mark Kelly).
|
||||
|
||||
* Try to query window pixel size from the outside terminal if the values
|
||||
returned by TIOCGWINSZ are zero (Dmitry Galchinsky, issue 4099).
|
||||
|
||||
CHANGES FROM 3.5 TO 3.5a
|
||||
|
||||
* Do not translate BSpace as Unicode with extended keys.
|
||||
|
||||
* Fix so that keys with Shift are represented correctly with extended keys.
|
||||
|
||||
* Revert to using /bin/sh for #() and run-shell and if-shell; the change to use
|
||||
default-shell only applies now to popups.
|
||||
|
||||
* Fix grey colour without a number suffix in styles.
|
||||
|
||||
CHANGES FROM 3.4 TO 3.5
|
||||
|
||||
* Revamp extended keys support to more closely match xterm and support mode 2
|
||||
as well as mode 1. This is a substantial change to key handling which changes
|
||||
tmux to always request mode 2 from parent terminal, changes 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.
|
||||
|
||||
* Clear an overlay (popup or menu) when command prompt is entered.
|
||||
|
||||
* Add copy-mode -d flag to scroll a page down if in copy mode already (matching
|
||||
-e).
|
||||
|
||||
* Display hyperlinks in copy mode and add copy_cursor_hyperlink format to get
|
||||
the hyperlink under the cursor.
|
||||
|
||||
* Add a prefix timeout option.
|
||||
|
||||
* 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
|
||||
|
||||
* Add search_count and search_count_partial formats in copy mode.
|
||||
|
||||
* Do not reset mouse pane if clicked on status line,
|
||||
|
||||
* Add mirrored versions of the main-horizontal and main-vertical layouts where
|
||||
the main pane is bottom or right instead of top or left.
|
||||
|
||||
* Allow REP to work with Unicode characters.
|
||||
|
||||
* Fix size calculation of terminators for clipboard escape sequences.
|
||||
|
||||
* Treat CRLF as LF in config files where it is easy to do so.
|
||||
|
||||
* The Linux console has some bugs with bright colours, so add some workarounds
|
||||
for it.
|
||||
|
||||
* If built with systemd, remove some environment variables it uses.
|
||||
|
||||
* 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.
|
||||
|
||||
* Add --enable-jemalloc to build with jemalloc memory allocator (since glibc
|
||||
malloc is so poor).
|
||||
|
||||
* 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.
|
||||
|
||||
* Add N to search backwards in tree modes.
|
||||
|
||||
* Use default-shell for command prompt, #() and popups.
|
||||
|
||||
* Revert part of a change intended to improve search performance by skipping
|
||||
parts of lines already searched, but which in fact skipped the ends of lines
|
||||
altogether.
|
||||
|
||||
* Add a command-error hook when a command fails.
|
||||
|
||||
* Add an option allow-set-title to forbid applications from changing the pane
|
||||
title.
|
||||
|
||||
* Correct handling of mouse up events (don't ignore all but the last released
|
||||
button), and always process down event for double click.
|
||||
|
||||
* Fix a crash if focusing a pane that is exiting.
|
||||
|
||||
* Pick newest session (as documented) when looking for next session for
|
||||
detach-on-destroy.
|
||||
|
||||
* Reduce default escape-time to 10 milliseconds.
|
||||
|
||||
* Add display-menu -M to always turn mouse on in a menu.
|
||||
|
||||
* Look for feature code 21 for DECSLRM and 28 for DECFRA in the device
|
||||
attributes and also accept level 1.
|
||||
|
||||
* Fix crash if built with SIXEL and the SIXEL colour register is invalid; also
|
||||
remove SIXEL images before reflow.
|
||||
|
||||
* Do not notify window-layout-changed if the window is about to be destroyed.
|
||||
|
||||
* Do not consider a selection present if it is empty for the selection_active
|
||||
and selection_present format variables.
|
||||
|
||||
* Fix split-window -p.
|
||||
|
||||
CHANGES FROM 3.3a TO 3.4
|
||||
|
||||
* Add options keep-last and keep-group to destroy-unattached to keep the last
|
||||
session whether in a group.
|
||||
|
||||
* Don't allow paste-buffer into dead panes.
|
||||
|
||||
* Add -t to source-file.
|
||||
|
||||
* Rewrite combined character handling to be more consistent and to support
|
||||
newer Unicode combined characters.
|
||||
|
||||
* Add basic support for SIXEL if built with --enable-sixel.
|
||||
|
||||
* 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.
|
||||
|
||||
* Add flag (-o) to next-prompt/previous-prompt to go to OSC 133 command output.
|
||||
|
||||
* Add options and flags for menu styles (menu-style, menu-border-style) similar
|
||||
to those existing for popups.
|
||||
|
||||
* Add support for marking lines with a shell prompt based on the OSC 133 extension.
|
||||
|
||||
* Check for libterminfo for NetBSD.
|
||||
|
||||
* Add "us" to styles for underscore colour.
|
||||
|
||||
* Add flags (-c and -y) to change the confirm key and default behaviour of
|
||||
confirm-before.
|
||||
|
||||
* Use ncurses' new tparm_s function (added in 6.4-20230424) instead of tparm so
|
||||
it does not object to string arguments in c apabilities it doesn't already
|
||||
know. Also ignore errors from tparm if using previous ncurses versions.
|
||||
|
||||
* Set default lock command to vlock on Linux if present at build time.
|
||||
|
||||
* Discard mouse sequences that have the right form but actually are invalid.
|
||||
|
||||
* Add support for spawning panes in separate cgroups with systemd and a
|
||||
configure flag (--disable-cgroups) to turn off.
|
||||
|
||||
* Add a format (pane_unseen_changes) to show if there are unseen changes while
|
||||
in a mode.
|
||||
|
||||
* Remove old buffer when renaming rather than complaining.
|
||||
|
||||
* Add an L modifier like P, W, S to loop over clients.
|
||||
|
||||
* Add -f to list-clients like the other list commands.
|
||||
|
||||
* Extend display-message to work for control clients.
|
||||
|
||||
* Add a flag to display-menu to select the manu item selected when the menu is
|
||||
open.
|
||||
|
||||
* Have tmux recognise pasted text wrapped in bracket paste sequences, rather
|
||||
than only forwarding them to the program inside.
|
||||
|
||||
* Have client return 1 if process is interrupted to an input pane.
|
||||
|
||||
* 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.
|
||||
|
||||
* Add send-keys -K to handle keys directly as if typed (so look up in key
|
||||
table).
|
||||
|
||||
* Process escape sequences in show-buffer.
|
||||
|
||||
* Add a -l flag to display-message to disable format expansion.
|
||||
|
||||
* Add paste-buffer-deleted notification and fix name of paste-buffer-changed.
|
||||
|
||||
* Do not attempt to connect to the socket as a client if systemd is active.
|
||||
|
||||
* Add scroll-top and scroll-bottom commands to scroll so cursor is at top or
|
||||
bottom.
|
||||
|
||||
* 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.
|
||||
|
||||
* Add message-line option to control where message and prompt go.
|
||||
|
||||
* Notification when a paste buffer is deleted.
|
||||
|
||||
* Add a Nobr terminfo(5) capability to tell tmux the terminal does not use bright
|
||||
colours for bold.
|
||||
|
||||
* Change g and G to go to top and bottom in menus.
|
||||
|
||||
* Add a third state "all" to allow-passthrough to work even in invisible panes.
|
||||
|
||||
* Add support for OSC 8 hyperlinks.
|
||||
|
||||
* Store the time lines are scrolled into history and display in copy mode.
|
||||
|
||||
* Add a %config-error reply to control mode for configuration file errors since
|
||||
reporting them in view mode is useless.
|
||||
|
||||
* A new feature flag (ignorefkeys) to ignore terminfo(5) function key
|
||||
definitions for rxvt.
|
||||
|
||||
* Pass through first argument to OSC 52 (which clipboards to set) if the
|
||||
application provides it.
|
||||
|
||||
* Expand arguments to send-keys, capture-pane, split-window, join-pane where it
|
||||
makes sense to do so.
|
||||
|
||||
* Ignore named buffers when choosing a buffer if one is not specified by the user.
|
||||
|
||||
CHANGES FROM 3.3 TO 3.3a
|
||||
|
||||
* Do not crash when run-shell produces output from a config file.
|
||||
|
||||
* Do not unintentionally turn off all mouse mode when button mode is also
|
||||
present.
|
||||
|
||||
CHANGES FROM 3.2a TO 3.3
|
||||
|
||||
* Add an ACL list for users connecting to the tmux socket. Users may be
|
||||
@@ -180,7 +1155,7 @@ CHANGES FROM 3.2 TO 3.2a
|
||||
* Do not expand the filename given to -f so it can contain colons.
|
||||
|
||||
* Fixes for problems with extended keys and modifiers, scroll region,
|
||||
source-file, crosscompiling, format modifiers and other minor issues.
|
||||
source-file, cross compiling, format modifiers and other minor issues.
|
||||
|
||||
CHANGES FROM 3.1c TO 3.2
|
||||
|
||||
@@ -1295,7 +2270,7 @@ Incompatible Changes
|
||||
|
||||
bind -Tcopy-mode C-r command-prompt -i -p'search up' "send -X search-backward-incremental '%%'"
|
||||
|
||||
There are also some new commmands available with send -X, such as
|
||||
There are also some new commands available with send -X, such as
|
||||
copy-pipe-and-cancel.
|
||||
* set-remain-on-exit has gone -- can be achieved with hooks instead.
|
||||
* Hooks: before hooks have been removed and only a selection of commands now
|
||||
|
||||
7
COPYING
7
COPYING
@@ -1,9 +1,4 @@
|
||||
THIS IS FOR INFORMATION ONLY, CODE IS UNDER THE LICENCE AT THE TOP OF ITS FILE.
|
||||
|
||||
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>
|
||||
Copyright (c) Various Authors
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
715
IMAGE-REDRAW-PLAN.md
Normal file
715
IMAGE-REDRAW-PLAN.md
Normal file
@@ -0,0 +1,715 @@
|
||||
# Image Redraw and Damage Plan
|
||||
|
||||
## Purpose
|
||||
|
||||
Make image redraws correct and efficient for tiled panes, floating panes,
|
||||
scrolling, copy-mode selection, pane borders, pane status lines, scrollbars,
|
||||
and clients using different output protocols.
|
||||
|
||||
The intended model is retained: the visible screen is a scene of horizontal
|
||||
cell spans. A change damages cell-aligned regions, and the compositor redraws
|
||||
only scene spans intersecting those regions.
|
||||
|
||||
Synchronized output may hide unavoidable intermediate terminal updates, but
|
||||
it must not be required for correctness.
|
||||
|
||||
## Current state and recovery point
|
||||
|
||||
The last clean, pushed commit on `4902-image-support` is:
|
||||
|
||||
```
|
||||
ec9859b1 sixel: preserve image aspect across client geometries
|
||||
```
|
||||
|
||||
That commit already contains the important persistent model:
|
||||
|
||||
- sparse image placements represented by spans attached to grid lines;
|
||||
- input-protocol semantics and placement ordering;
|
||||
- source coordinates for cropping placement spans;
|
||||
- movement, copying, duplication, and removal of image spans with grid data;
|
||||
- per-client output backends for Kitty, SIXEL, and fallback rendering; and
|
||||
- cached image/rendering data.
|
||||
|
||||
The current uncommitted changes touch eight files and mix several attempted
|
||||
optimizations. They are known to damage SIXEL in Mintty and cause unnecessary
|
||||
redraws with floating panes. Do not commit them as the solution.
|
||||
|
||||
Before discarding them, save one patch outside the branch for reference:
|
||||
|
||||
```
|
||||
git diff -- image.c regress/image-support.sh screen-redraw.c screen-write.c \
|
||||
server-client.c tmux.h tty.c window-copy.c \
|
||||
> /tmp/4902-image-redraw-experiment.patch
|
||||
```
|
||||
|
||||
Then restore those tracked files to `ec9859b1` before beginning the new work.
|
||||
Do this only after the user explicitly approves the rollback.
|
||||
|
||||
### Ideas worth retaining, but reimplementing separately
|
||||
|
||||
- Redraw damage should be restricted to scene-visible spans.
|
||||
- Image-related selection tests are useful.
|
||||
- Floating-pane and pane-status regression scenarios are useful.
|
||||
- Window chrome must be emitted after pane image/text composition whenever
|
||||
the same damaged region contains both.
|
||||
- A placement's complete canvas may need to be represented even where its
|
||||
pixels are transparent; visibility and alpha must then be tested while
|
||||
compositing rather than by losing the placement geometry.
|
||||
- Native scrolling should be selected according to the affected region and
|
||||
backend behaviour.
|
||||
|
||||
### Changes not worth retaining in their present form
|
||||
|
||||
- Promoting an obscured-pane update to `PANE_REDRAW` and then sometimes to
|
||||
`CLIENT_REDRAWWINDOW`.
|
||||
- Repairing images directly from individual `tty_cmd_*` text functions.
|
||||
- Separate ad-hoc redraw paths for images, selection, scrollbars, borders,
|
||||
and floating panes.
|
||||
- The current `TTY_CTX_IMAGE_SCROLL`, `TTY_CTX_PANE_FULL_WIDTH`, and
|
||||
`CLIENT_REDRAWSCROLLBARS` plumbing as a combined patch.
|
||||
- Assuming an unchanged pane-status string does not need physical redraw
|
||||
after some other drawing operation has covered its cells.
|
||||
|
||||
## Required invariants
|
||||
|
||||
These rules should be written down in code comments and enforced throughout
|
||||
the implementation.
|
||||
|
||||
1. **Input determines semantics.** Whether text removes an image layer, lies
|
||||
above it, or lies below it is determined by the protocol received from the
|
||||
application. It must not depend on whether the outer client uses Kitty,
|
||||
SIXEL, or fallback output.
|
||||
|
||||
2. **Output backends encode a scene.** An output backend may choose different
|
||||
escape sequences, caches, or cropping, but it must render the same logical
|
||||
result.
|
||||
|
||||
3. **One compositor owns repair.** No output path may independently erase and
|
||||
reconstruct image cells without going through the same scene ordering.
|
||||
|
||||
4. **Damage is regional.** Ordinary content changes do not become pane-wide
|
||||
or window-wide redraws. Full redraw remains appropriate for attachment,
|
||||
resize, geometry changes, terminal reset, or invalid scene geometry.
|
||||
|
||||
5. **Damage uses cell coordinates.** Pixel offsets are handled when an image
|
||||
backend maps the damaged cells to a source-pixel crop.
|
||||
|
||||
6. **Logical state changes before physical output.** Grid text and image spans
|
||||
are moved, removed, or inserted first. Rendering then reads the completed
|
||||
logical state.
|
||||
|
||||
7. **Chrome is part of composition.** Pane borders, pane status lines,
|
||||
scrollbars, menus, and floating panes must not be repaired independently in
|
||||
an order that allows image output to cover them afterward.
|
||||
|
||||
8. **No-image behaviour remains unchanged.** When a damaged region does not
|
||||
intersect image data or graphical overlays, existing fast text output and
|
||||
native scrolling should remain available.
|
||||
|
||||
## Established image semantics
|
||||
|
||||
The image semantics present at the `ec9859b1` recovery point are a
|
||||
compatibility requirement. They resulted from the review discussion in PR
|
||||
#5445, particularly the temporal-versus-positional model described in
|
||||
[Theory and Practice of Sprixels](https://nick-black.com/dankwiki/index.php?title=Theory_and_Practice_of_Sprixels#Transparency_and_z-ordering),
|
||||
and were accepted after commit `a4abd616`, which added the corresponding
|
||||
manual visual checks.
|
||||
|
||||
- SIXEL input is temporal. Transparent pixels preserve what existed when the
|
||||
SIXEL was emitted. A later text write annihilates the affected SIXEL cells;
|
||||
the SIXEL does not remain logically behind that text.
|
||||
- Kitty input is positional. Negative-z placements remain below the text plane;
|
||||
nonnegative placements remain above it. Text writes do not convert or remove
|
||||
Kitty placements merely because the output client uses SIXEL.
|
||||
- Overlapping placements remain separate ordered layers. Transparent pixels in
|
||||
an upper placement reveal retained lower placements or text.
|
||||
- Input protocol, z-index, and placement order determine the logical scene. The
|
||||
attached client's output protocol only determines how that scene is encoded.
|
||||
- Redraw, damage, scrolling, copy mode, and backend conversion must preserve
|
||||
these rules exactly.
|
||||
|
||||
The manual checks introduced by `a4abd616` and the corresponding regression
|
||||
cases are semantic compatibility tests, not merely visual diagnostics.
|
||||
|
||||
## Coordinate spaces
|
||||
|
||||
Keep conversions explicit. Do not pass ambiguous `x` and `y` values between
|
||||
layers.
|
||||
|
||||
- **Grid coordinates:** include history and belong to a pane's `struct grid`.
|
||||
- **Pane coordinates:** visible cells inside a pane.
|
||||
- **Window coordinates:** include pane offsets and floating-pane positions.
|
||||
- **Client scene coordinates:** window coordinates clipped by the client's
|
||||
viewport (`ox`, `oy`, `sx`, and `sy`).
|
||||
- **Terminal coordinates:** include the client status-line offset and any
|
||||
terminal viewport offset.
|
||||
- **Image source coordinates:** identify cell rows/columns within a placement;
|
||||
the backend maps these to source pixels using terminal cell geometry and
|
||||
placement pixel offsets.
|
||||
|
||||
Store damage in window coordinates. Translate and clip it separately for each
|
||||
client when drawing, because clients may have different viewports, status-line
|
||||
positions, cell geometries, and output backends.
|
||||
|
||||
## Compartmentalization
|
||||
|
||||
Keep image implementation details in the existing image files. The rest of
|
||||
tmux should know only that some scene cells require image-aware composition.
|
||||
|
||||
### `image.c`
|
||||
|
||||
Own all protocol-independent image state and composition policy:
|
||||
|
||||
- placements, spans, input protocol, z-index, serial ordering, and alpha;
|
||||
- applying input semantics when text overwrites image cells;
|
||||
- testing whether a grid rectangle intersects image placements;
|
||||
- mapping a damaged cell rectangle to ordered image fragments;
|
||||
- deciding which logical image layers are below or above the text plane;
|
||||
- generic backend dispatch; and
|
||||
- public image helpers used by the redraw subsystem.
|
||||
|
||||
### `image-sixel.c`
|
||||
|
||||
Own only SIXEL-specific output details:
|
||||
|
||||
- cached quantized/indexed representations;
|
||||
- mapping cell crops to pixel and six-pixel-band crops;
|
||||
- emitting SIXEL fragments;
|
||||
- alpha and palette encoding; and
|
||||
- backend-specific reset, erase, and scrolling capabilities.
|
||||
|
||||
### `image-kitty.c`
|
||||
|
||||
Own only Kitty-specific output details:
|
||||
|
||||
- client-side transmission and placement caches;
|
||||
- placement creation, clipping, movement, and deletion;
|
||||
- Kitty IDs and geometry; and
|
||||
- backend-specific reset and scrolling behaviour.
|
||||
|
||||
### Other tmux files
|
||||
|
||||
- `screen-redraw.c` owns scene construction, damage clipping, and the ordering
|
||||
of pane content versus window chrome. It calls generic `image.c` helpers and
|
||||
contains no Kitty or SIXEL protocol logic.
|
||||
- `screen-write.c` updates logical grid state and reports pane/window damage.
|
||||
It must not render image fragments or select an output backend.
|
||||
- `tty.c` owns terminal text and scrolling primitives. It receives an already
|
||||
selected native-scroll operation; it must not reconstruct image layers or
|
||||
call image repair after individual characters.
|
||||
- `server-client.c` schedules and drains per-client damage. It must not inspect
|
||||
image placements or output protocols.
|
||||
- `window-copy.c` reports copy-mode damage and copies logical image state using
|
||||
generic image helpers; it must not render images itself.
|
||||
- `tmux.h` exposes only the minimum generic structures and function prototypes
|
||||
required across those boundaries.
|
||||
|
||||
Prefer one generic call from `screen-redraw.c` into `image.c` over `ENABLE_IMAGES`
|
||||
branches scattered through tty commands. A build without image support should
|
||||
retain the existing redraw path with minimal conditional code.
|
||||
|
||||
## Damage representation
|
||||
|
||||
Add a small regional damage abstraction owned by the redraw subsystem. Do not
|
||||
add per-cell queues or enlarge `struct grid_cell`.
|
||||
|
||||
A damage entry needs:
|
||||
|
||||
```
|
||||
x, y, sx, sy window-cell rectangle
|
||||
reason content, scroll exposure, pane move, chrome, and so on
|
||||
```
|
||||
|
||||
The exact names should follow tmux style. A short list or dynamic array per
|
||||
client is sufficient. When a new rectangle is added:
|
||||
|
||||
- clip it to the window;
|
||||
- discard empty rectangles;
|
||||
- merge overlapping or directly adjacent rectangles where that does not make
|
||||
the result substantially larger;
|
||||
- cap the list at a modest number; above the cap, replace it with their union;
|
||||
- promote to a full redraw only if geometry is invalid or the union covers
|
||||
most of the client scene.
|
||||
|
||||
A shared window damage list must not be cleared after the first client draws.
|
||||
Either append translated window rectangles to every affected client, or give
|
||||
damage events monotonically increasing sequence numbers so each client can
|
||||
consume them independently. The simpler initial implementation is to append
|
||||
window-coordinate rectangles to each client currently displaying the window.
|
||||
|
||||
Suggested public operations are conceptually:
|
||||
|
||||
```
|
||||
redraw_damage_window(window, x, y, sx, sy, reason)
|
||||
redraw_damage_pane(window_pane, x, y, sx, sy, reason)
|
||||
redraw_damage_client(client, x, y, sx, sy, reason)
|
||||
```
|
||||
|
||||
Do not expose image-backend details through these calls.
|
||||
|
||||
## Regional scene composition
|
||||
|
||||
Extend `screen-redraw.c` so an existing `redraw_scene` can be drawn through a
|
||||
set of clipping rectangles.
|
||||
|
||||
For every damaged line:
|
||||
|
||||
1. Intersect the damage rectangle with that line's scene spans.
|
||||
2. Split only at damage boundaries; do not rebuild the complete scene.
|
||||
3. Draw intersecting pane content in logical layer order.
|
||||
4. Draw window chrome intersecting the same rectangle last.
|
||||
|
||||
For a pane span, the scene has already selected the topmost visible pane at
|
||||
that position. Composition inside that pane should then be explicit:
|
||||
|
||||
1. image placements below the text plane, such as negative Kitty z-indexes;
|
||||
2. the text plane, including the requested copy-mode style;
|
||||
3. surviving temporal SIXEL placements and images above the text plane;
|
||||
4. pane borders, pane status, scrollbars, menus, and other chrome.
|
||||
|
||||
The exact placement order is already represented by `struct image_placement`
|
||||
and its input protocol, z-index, and serial. Do not derive it from the client's
|
||||
output backend.
|
||||
|
||||
Only the topmost pane content is normally needed because panes are opaque.
|
||||
Underlying pane content is retained in its own grid and becomes visible when a
|
||||
floating pane moves, at which time the old floating-pane rectangle is damaged
|
||||
and recomposed.
|
||||
|
||||
### Image fragments
|
||||
|
||||
An `image_span` is placement metadata, not a separately stored bitmap. For an
|
||||
intersection, compute the corresponding source-cell rectangle and ask the
|
||||
backend to emit that crop from its cached rendering.
|
||||
|
||||
- Do not rerun quantization or dithering for every small damage rectangle.
|
||||
- SIXEL output operates in six-pixel vertical bands. Expand or clip the
|
||||
backend operation as required, then ensure any additionally touched cells
|
||||
are included in the same composition pass.
|
||||
- A transparent top image requires lower image layers to be drawn first.
|
||||
- Kitty placements may be deleted, clipped, or replaced only within the
|
||||
damaged placement region.
|
||||
|
||||
## Fast text writes
|
||||
|
||||
Do not route every ordinary character through a deferred full compositor.
|
||||
|
||||
For an application text write:
|
||||
|
||||
1. Apply input-protocol damage rules to the logical image spans. For example,
|
||||
text written after a SIXEL image removes the affected SIXEL coverage.
|
||||
2. Test whether the affected cells still intersect any image layer or scene
|
||||
overlay requiring composition.
|
||||
3. If not, retain the existing direct `tty_cmd_cell`/`tty_cmd_cells` path.
|
||||
4. If they do, suppress conflicting direct terminal repair and enqueue only
|
||||
those cells for regional composition.
|
||||
|
||||
This decision belongs above the backend-specific tty output functions. Avoid
|
||||
callbacks such as `image_draw_after_text()` from several `tty_cmd_*` functions;
|
||||
they reproduce ordering logic in multiple places.
|
||||
|
||||
## Selection and copy mode
|
||||
|
||||
Copy mode must not mutate the application's logical image placements.
|
||||
|
||||
- Treat selection as a temporary tmux UI style on the text plane.
|
||||
- Follow the chosen policy that selection highlighting does not overwrite
|
||||
image-covered cells.
|
||||
- Mouse motion should damage only cells whose selection state actually
|
||||
changed.
|
||||
- If changed selection cells do not intersect visible images, draw them using
|
||||
the normal text fast path.
|
||||
- If they intersect an image canvas, compose those cells once; do not erase a
|
||||
whole image or pane.
|
||||
- Entering or leaving copy mode should damage the visible pane rectangle once,
|
||||
not repeatedly for every unchanged mouse event.
|
||||
|
||||
Copy-mode image spans should be copied before its text view is composed, but
|
||||
this should be implemented through the same logical state and damage API, not
|
||||
through special tty repair calls.
|
||||
|
||||
## Floating panes
|
||||
|
||||
### Focus changes
|
||||
|
||||
Changing the active pane should damage only cells whose appearance changes:
|
||||
|
||||
- affected pane borders;
|
||||
- pane status cells whose style or contents change; and
|
||||
- any active-pane indicators.
|
||||
|
||||
It must not redraw pane interiors or retransmit unrelated SIXEL images.
|
||||
|
||||
### Moving or resizing a floating pane
|
||||
|
||||
For an old rectangle `A` and new rectangle `B`:
|
||||
|
||||
- invalidate the scene geometry;
|
||||
- damage `A union B` (represented as a few rectangles rather than necessarily
|
||||
one large bounding box);
|
||||
- rebuild the scene because pane ownership changed;
|
||||
- recompose only spans intersecting those rectangles.
|
||||
|
||||
The old rectangle restores tiled panes and any image fragments that were
|
||||
previously hidden. The new rectangle draws the floating pane and its chrome.
|
||||
Multiple overlapping floating panes follow their window z-order.
|
||||
|
||||
## Scrolling
|
||||
|
||||
Implement scrolling in three stages. Do not begin with the most complicated
|
||||
native-scroll optimization.
|
||||
|
||||
### Stage 1: correct regional redraw
|
||||
|
||||
1. Move grid text and image spans using the existing grid operations.
|
||||
2. Record the pane scroll rectangle and newly exposed rows.
|
||||
3. Recompose that rectangle from the completed logical scene.
|
||||
|
||||
This may still retransmit more image data than desired, but it establishes a
|
||||
correct regional baseline without pane- or window-wide redraws.
|
||||
|
||||
### Stage 2: native scrolling without obstructions
|
||||
|
||||
Use the terminal's native scroll operation only when:
|
||||
|
||||
- the backend/terminal is known to scroll its image pixels consistently;
|
||||
- the source and destination rectangle belong to the same visible pane;
|
||||
- no floating pane, menu, overlay, pane border/status, or reserved scrollbar
|
||||
intersects it;
|
||||
- required vertical and horizontal margins are available and reliable; and
|
||||
- existing BCE and terminal-size checks permit the operation.
|
||||
|
||||
After native scrolling, compose only newly exposed rows and any protocol-sized
|
||||
boundary expansion.
|
||||
|
||||
### Stage 3: mixed native scrolling around obstructions
|
||||
|
||||
Derive safe rectangles from visible scene spans:
|
||||
|
||||
- a destination cell is native-scrollable only when its source cell and
|
||||
destination cell are both visible parts of the same pane;
|
||||
- coalesce equal horizontal ranges across adjacent rows into rectangles;
|
||||
- native-scroll those maximal rectangles;
|
||||
- recompose cells crossing an obstruction boundary and newly exposed cells.
|
||||
|
||||
With one floating pane, left and right strips can often scroll over the full
|
||||
height. Above and below it, cells whose source crosses behind the floating pane
|
||||
must be recomposed rather than recovered from terminal pixels.
|
||||
|
||||
As a simpler optional strategy, native-scroll the full tiled-pane rectangle
|
||||
and recompose the floating pane's old/current rectangles afterward. This is
|
||||
correct if all disturbed cells are marked, but may visibly flash without
|
||||
synchronized output. Prefer safe-rectangle scrolling once correctness is
|
||||
established.
|
||||
|
||||
If rectangle decomposition becomes too fragmented, fall back to regional
|
||||
composition. It is an optimization, never a separate correctness path.
|
||||
|
||||
## Redraw scheduling
|
||||
|
||||
Do not turn queued regional damage into `CLIENT_REDRAWWINDOW` merely because
|
||||
the tty output buffer is nonempty. Preserve the damage list and process it
|
||||
after output drains.
|
||||
|
||||
Use full redraw only for:
|
||||
|
||||
- initial attachment;
|
||||
- client or terminal geometry changes;
|
||||
- a terminal reset or invalid backend cache;
|
||||
- layout/viewport changes where rebuilding and clipping regions is not yet
|
||||
safe; or
|
||||
- a damage union large enough that full redraw is cheaper.
|
||||
|
||||
Focus changes, selection changes, ordinary scrolling, and moving one floating
|
||||
pane should remain regional.
|
||||
|
||||
## Debugging instrumentation
|
||||
|
||||
Add temporary debug logging before optimizing:
|
||||
|
||||
- damage reason and window rectangle;
|
||||
- client clipping and coordinate translation;
|
||||
- scene generation used;
|
||||
- native-scroll rectangles selected;
|
||||
- spans recomposed in each layer phase; and
|
||||
- image fragments emitted by each backend.
|
||||
|
||||
The log should make it possible to answer, for every SIXEL retransmission,
|
||||
which damage rectangle required it. Remove excessively noisy instrumentation
|
||||
before the final commit or keep it behind normal verbose logging.
|
||||
|
||||
## Tests
|
||||
|
||||
Build the tests before each optimization and keep each test focused on one
|
||||
invariant.
|
||||
|
||||
### Automated regressions
|
||||
|
||||
1. **No-image baseline:** ordinary output, scrolling, copy mode, floating pane
|
||||
focus, borders, status lines, and scrollbars behave unchanged.
|
||||
2. **Focus only:** changing focus with a SIXEL elsewhere emits no SIXEL DCS and
|
||||
updates only the affected border/status cells.
|
||||
3. **Selection outside image:** emits no image output.
|
||||
4. **Selection crossing image:** the image remains intact during and after the
|
||||
drag; only changed non-image cells are highlighted.
|
||||
5. **Unobstructed scroll:** logical image spans move with text; where native
|
||||
scrolling is supported, no complete SIXEL retransmission occurs.
|
||||
6. **Scroll with floating pane:** both pane-status lines, borders, scrollbar,
|
||||
floating-pane contents, and visible image fragments remain correct.
|
||||
7. **Move floating pane:** old and new rectangles are restored; unrelated image
|
||||
regions are not emitted.
|
||||
8. **Multiple floating panes:** overlapping z-order remains correct while the
|
||||
top pane moves.
|
||||
9. **Transparent placement:** lower images/text show through correctly, and
|
||||
moving/selection does not treat transparency as absent placement geometry.
|
||||
10. **Cross-backend clients:** the same input scene produces equivalent results
|
||||
on Kitty, SIXEL, and fallback clients attached simultaneously.
|
||||
11. **Pane status top/bottom:** unchanged status contents are physically
|
||||
restored if their cells were damaged.
|
||||
12. **Scrollbar reserved/overlay:** scroll thumb and track remain present and
|
||||
images do not overwrite them.
|
||||
|
||||
Where possible, capture raw terminal output and assert both presence and
|
||||
absence of DCS/APC sequences. `capture-pane` alone cannot prove physical output
|
||||
ordering because it observes logical grid contents rather than terminal image
|
||||
pixels.
|
||||
|
||||
### Manual matrix
|
||||
|
||||
Test at least:
|
||||
|
||||
- Microsoft Terminal with SIXEL;
|
||||
- Mintty with SIXEL;
|
||||
- WezTerm with SIXEL;
|
||||
- Kitty with Kitty output;
|
||||
- a Kitty client attached to a session created from a SIXEL client and the
|
||||
reverse; and
|
||||
- a terminal without graphical image support.
|
||||
|
||||
For each, test scrolling by application output and mouse wheel, selecting text,
|
||||
entering/leaving copy mode, changing focus, opening/closing/moving a floating
|
||||
pane, pane status at top and bottom, and scrollbars.
|
||||
|
||||
## Implementation steps and commit boundaries
|
||||
|
||||
This must not be implemented as one monolithic change. Each numbered step is a
|
||||
separate commit, review, and testing gate. Do not begin the next step until the
|
||||
current step passes its focused tests. If a step exposes a pre-existing bug,
|
||||
record it before expanding the patch.
|
||||
|
||||
### Step 0: archive the experiment and recover the baseline
|
||||
|
||||
**Goal:** Begin development from known source rather than repairing the mixed
|
||||
experimental diff.
|
||||
|
||||
**Work:**
|
||||
|
||||
- Preserve the current diff and this plan on a clearly named WIP branch.
|
||||
- Return `4902-image-support` to clean commit `ec9859b1`.
|
||||
- Build with and without image support.
|
||||
- Run the existing image regression and ordinary tmux regression suite.
|
||||
|
||||
**Gate:** The branch is clean and existing behaviour is reproduced. No product
|
||||
code is changed in this step.
|
||||
|
||||
### Step 1: add focused regressions and tracing
|
||||
|
||||
**Goal:** Establish observable failures before changing redraw behaviour.
|
||||
|
||||
**Primary files:** `regress/image-support.sh`, temporary debug logging in
|
||||
`screen-redraw.c` if necessary.
|
||||
|
||||
**Work:** Add independent tests for focus-only changes, selection crossing an
|
||||
image, unobstructed scrolling, scrolling beneath a floating pane, moving a
|
||||
floating pane, both pane-status lines, and scrollbars. Raw terminal output must
|
||||
be used where a test needs to prove that SIXEL or Kitty data was or was not
|
||||
emitted.
|
||||
|
||||
**Gate:** Each test either passes on the baseline or has a documented expected
|
||||
failure. Tests must not depend on timing races or visual screenshots. The
|
||||
existing edge-case checks introduced by `a4abd616` must pass unchanged on the
|
||||
recovery baseline and establish the semantic compatibility result expected by
|
||||
later gates.
|
||||
|
||||
**Not included:** No redraw implementation changes.
|
||||
|
||||
### Step 2: introduce regional damage scheduling
|
||||
|
||||
**Goal:** Represent and preserve small window-coordinate damage rectangles
|
||||
without changing the rendered result.
|
||||
|
||||
**Primary files:** `screen-redraw.c`, `server-client.c`, minimal declarations in
|
||||
`tmux.h`.
|
||||
|
||||
**Work:** Add per-client damage storage, clipping, merging, a complexity cap,
|
||||
and verbose logging. Existing callers may initially convert the damage to the
|
||||
same redraw they used before. Pending tty output must retain the region rather
|
||||
than promote it automatically to a full-window redraw.
|
||||
|
||||
**Gate:** No-image and image output remain visually and byte-for-byte equivalent
|
||||
where practical. Unit-style tests verify rectangle clipping and merging.
|
||||
|
||||
**Not included:** No image-layer traversal, selection changes, floating-pane
|
||||
optimization, or native scrolling.
|
||||
|
||||
### Step 3: add a generic image-region composition API
|
||||
|
||||
**Goal:** Give the scene compositor one protocol-independent way to render the
|
||||
image layers intersecting a cell rectangle.
|
||||
|
||||
**Primary files:** `image.c`, `image-sixel.c`, `image-kitty.c`, with only generic
|
||||
prototypes in `tmux.h`.
|
||||
|
||||
**Work:**
|
||||
|
||||
- In `image.c`, intersect damage with placement spans and preserve logical
|
||||
input/z/serial order.
|
||||
- In `image-sixel.c`, emit a crop from cached quantized data and handle SIXEL
|
||||
band alignment.
|
||||
- In `image-kitty.c`, update/delete/place only the intersecting cached
|
||||
placements.
|
||||
- Define clearly separate below-text and above-text passes.
|
||||
|
||||
**Gate:** Rendering a whole image as adjacent damaged rectangles produces the
|
||||
same final scene as rendering it in one operation. Test transparent and
|
||||
overlapping placements on both output backends. The `a4abd616` semantic
|
||||
compatibility checks must continue to pass unchanged.
|
||||
|
||||
**Not included:** No changes to individual tty text commands and no native
|
||||
scroll optimization.
|
||||
|
||||
### Step 4: clip scene composition to damage rectangles
|
||||
|
||||
**Goal:** Make `screen-redraw.c` repaint only scene spans intersecting queued
|
||||
damage.
|
||||
|
||||
**Primary files:** `screen-redraw.c`; generic calls into `image.c`.
|
||||
|
||||
**Work:** For each damaged line, intersect existing redraw spans, compose the
|
||||
selected pane's below-text images, text, and above-text images, then draw
|
||||
intersecting chrome last. Full redraw continues to use the same compositor with
|
||||
a full-client damage rectangle.
|
||||
|
||||
**Gate:** Full and tiled panes redraw correctly; pane borders, pane status,
|
||||
scrollbars, menus, and images have deterministic output order. No floating-pane
|
||||
movement or scroll optimization is added yet.
|
||||
|
||||
### Step 5: route text and selection damage through the compositor
|
||||
|
||||
**Goal:** Repair only cells where text or copy-mode selection interacts with
|
||||
image layers.
|
||||
|
||||
**Primary files:** `screen-write.c`, `window-copy.c`, `screen-redraw.c`, and
|
||||
logical helpers in `image.c`.
|
||||
|
||||
**Work:** Apply input semantics to logical spans first. Preserve direct tty text
|
||||
output when no image placement intersects the cells. Otherwise enqueue those
|
||||
cells for composition. Selection changes damage only cells whose selection
|
||||
state changed and follow the policy of not overwriting image-covered cells.
|
||||
|
||||
**Gate:** Dragging selection across an image never damages it, entering/leaving
|
||||
copy mode restores the same scene, and selection outside images emits no image
|
||||
data. The `a4abd616` semantic compatibility checks must continue to pass
|
||||
unchanged.
|
||||
|
||||
**Not included:** Do not add image callbacks to `tty_cmd_cell`,
|
||||
`tty_cmd_cells`, or `tty_cmd_clearcharacter`.
|
||||
|
||||
### Step 6: make floating-pane changes regional
|
||||
|
||||
**Goal:** Focus, movement, resize, open, and close operations damage only the
|
||||
cells whose scene ownership or chrome changed.
|
||||
|
||||
**Primary files:** floating-pane/window code that reports geometry changes,
|
||||
plus `screen-redraw.c`. Image implementation remains in the image files.
|
||||
|
||||
**Work:** Focus changes enqueue border/status cells only. Movement and resize
|
||||
enqueue the old and new pane rectangles and invalidate scene geometry. Regional
|
||||
composition restores underlying panes/images in the old rectangle and draws
|
||||
the floating pane in the new rectangle.
|
||||
|
||||
**Gate:** Changing focus emits no unrelated SIXEL/APC. Moving a floating pane
|
||||
does not damage images, either pane-status line, borders, or scrollbars. Test
|
||||
one and multiple overlapping floating panes.
|
||||
|
||||
### Step 7: implement correct regional scrolling without native optimization
|
||||
|
||||
**Goal:** Establish correct scrolling using logical state plus regional
|
||||
composition.
|
||||
|
||||
**Primary files:** grid/image state helpers in `image.c`, damage reporting in
|
||||
`screen-write.c`, composition in `screen-redraw.c`.
|
||||
|
||||
**Work:** Move text and image spans first, then damage the scroll rectangle and
|
||||
compose it. Do not use special image repair from `tty.c`.
|
||||
|
||||
**Gate:** Application scrolling, mouse-wheel copy-mode scrolling, partial
|
||||
scroll regions, scrollbars, and scrolling beneath floating panes are correct on
|
||||
Kitty, Microsoft Terminal, Mintty, and WezTerm. This step may redraw more than
|
||||
the final optimized version, but must not redraw outside the scroll rectangle.
|
||||
The `a4abd616` semantic compatibility checks must continue to pass unchanged.
|
||||
|
||||
### Step 8: enable native scrolling for unobstructed rectangles
|
||||
|
||||
**Goal:** Avoid retransmitting image pixels when the terminal can safely move
|
||||
them.
|
||||
|
||||
**Primary files:** scroll planning in `screen-redraw.c`, generic backend
|
||||
capability in `image.c`, backend facts in `image-sixel.c` and `image-kitty.c`,
|
||||
terminal primitive execution in `tty.c`.
|
||||
|
||||
**Work:** Select native scrolling only when source/destination cells belong to
|
||||
the same unobstructed pane and terminal margins/backend behaviour permit it.
|
||||
Compose newly exposed rows afterward. Retain Step 7 as the fallback.
|
||||
|
||||
**Gate:** Raw output proves the native scroll is used and a complete image is
|
||||
not retransmitted. Final output must match Step 7 on every tested backend.
|
||||
|
||||
### Step 9: decompose scrolling around floating panes
|
||||
|
||||
**Goal:** Combine native scrolling of safe rectangles with composition of
|
||||
obstructed and boundary rectangles.
|
||||
|
||||
**Primary files:** scroll planning and scene-span traversal in
|
||||
`screen-redraw.c`; no new protocol logic outside the image files.
|
||||
|
||||
**Work:** Derive maximal rectangles where both source and destination are
|
||||
visible cells of the same pane, coalesce adjacent equal ranges, natively scroll
|
||||
them, and compose everything else. Enforce a fragmentation threshold that
|
||||
falls back to Step 7.
|
||||
|
||||
**Gate:** Scrolling beneath one or several floating panes produces the same
|
||||
final scene as Step 7, reduces emitted image data, and never loses pane status,
|
||||
borders, scrollbars, or images.
|
||||
|
||||
### Step 10: cleanup, performance checks, and full regression
|
||||
|
||||
**Goal:** Remove superseded paths only after all replacements are proven.
|
||||
|
||||
**Work:** Remove obsolete redraw helpers and flags introduced or made unused by
|
||||
the new path. Reduce temporary logging. Check memory growth, rectangle-list
|
||||
bounds, output byte counts, and behaviour without image support. Run the entire
|
||||
regression suite and the manual terminal matrix.
|
||||
|
||||
**Gate:** All completion criteria below are satisfied. Synchronized output may
|
||||
improve appearance, but disabling it does not alter final contents. The
|
||||
`a4abd616` semantic compatibility checks must continue to pass unchanged.
|
||||
|
||||
Do not squash these implementation steps during development. Keeping their
|
||||
boundaries visible makes it possible to bisect correctness and performance
|
||||
regressions. They can be reorganized later only after review.
|
||||
|
||||
## Completion criteria
|
||||
|
||||
The work is complete when:
|
||||
|
||||
- Mintty, Microsoft Terminal, WezTerm, and Kitty show no persistent damage;
|
||||
- focus and selection do not retransmit unrelated images;
|
||||
- floating-pane movement redraws only old/new affected regions;
|
||||
- scrolling preserves images, pane borders, both tiled and floating pane
|
||||
status lines, and scrollbars;
|
||||
- input semantics produce the same composition on every output backend;
|
||||
- no-image performance and behaviour remain unchanged;
|
||||
- full regression tests pass; and
|
||||
- synchronized output improves appearance but disabling it never changes the
|
||||
final screen contents.
|
||||
83
Makefile.am
83
Makefile.am
@@ -1,41 +1,53 @@
|
||||
# Makefile.am
|
||||
|
||||
# Obvious program stuff.
|
||||
bin_PROGRAMS = tmux
|
||||
CLEANFILES = tmux.1.mdoc tmux.1.man cmd-parse.c
|
||||
|
||||
# Distribution tarball options.
|
||||
EXTRA_DIST = \
|
||||
CHANGES README README.ja COPYING example_tmux.conf \
|
||||
osdep-*.c mdoc2man.awk tmux.1
|
||||
CHANGES README COPYING example_tmux.conf \
|
||||
osdep-*.c mdoc2man.awk tmux.1 \
|
||||
tools/generate-image-diacritics.sh
|
||||
dist_EXTRA_tmux_SOURCES = compat/*.[ch]
|
||||
|
||||
# Preprocessor flags.
|
||||
AM_CPPFLAGS += @XOPEN_DEFINES@ \
|
||||
-DTMUX_VERSION='"@VERSION@"' \
|
||||
-DTMUX_CONF='"$(sysconfdir)/tmux.conf:~/.tmux.conf:$$XDG_CONFIG_HOME/tmux/tmux.conf:~/.config/tmux/tmux.conf"' \
|
||||
-DTMUX_TERM='"@DEFAULT_TERM@"'
|
||||
-DTMUX_LOCK_CMD='"@DEFAULT_LOCK_CMD@"' \
|
||||
-DTMUX_TERM='"@DEFAULT_TERM@"' \
|
||||
-DTMUX_MOUSE=1
|
||||
|
||||
# Additional object files.
|
||||
LDADD = $(LIBOBJS)
|
||||
|
||||
# Set flags for 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
|
||||
AM_CFLAGS += -g
|
||||
AM_CFLAGS += -Wno-long-long -Wall -W -Wformat=2
|
||||
AM_CFLAGS += -g3 -ggdb
|
||||
AM_CFLAGS += -Wno-long-long -Wall -W -Wformat=2 -Wno-use-after-free
|
||||
AM_CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
|
||||
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 += -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-cast-align
|
||||
AM_CFLAGS += -Wno-deprecated-declarations -Wno-macro-redefined
|
||||
endif
|
||||
AM_CPPFLAGS += -DDEBUG
|
||||
endif
|
||||
AM_CPPFLAGS += -iquote.
|
||||
if IS_ASAN
|
||||
AM_CPPFLAGS += -DASAN
|
||||
AM_CFLAGS += -fsanitize=address -fno-omit-frame-pointer
|
||||
AM_LDFLAGS += -fsanitize=address
|
||||
endif
|
||||
endif
|
||||
|
||||
# Set flags for Solaris.
|
||||
@@ -67,6 +79,11 @@ if IS_HAIKU
|
||||
AM_CPPFLAGS += -D_BSD_SOURCE
|
||||
endif
|
||||
|
||||
# Set flags for Cygwin.
|
||||
if IS_CYGWIN
|
||||
AM_CPPFLAGS += -DTMUX_SOCK_PERM=0
|
||||
endif
|
||||
|
||||
# List of sources.
|
||||
dist_tmux_SOURCES = \
|
||||
alerts.c \
|
||||
@@ -85,7 +102,6 @@ dist_tmux_SOURCES = \
|
||||
cmd-detach-client.c \
|
||||
cmd-display-menu.c \
|
||||
cmd-display-message.c \
|
||||
cmd-display-panes.c \
|
||||
cmd-find-window.c \
|
||||
cmd-find.c \
|
||||
cmd-if-shell.c \
|
||||
@@ -96,6 +112,7 @@ dist_tmux_SOURCES = \
|
||||
cmd-kill-window.c \
|
||||
cmd-list-buffers.c \
|
||||
cmd-list-clients.c \
|
||||
cmd-list-commands.c \
|
||||
cmd-list-keys.c \
|
||||
cmd-list-panes.c \
|
||||
cmd-list-sessions.c \
|
||||
@@ -144,12 +161,17 @@ dist_tmux_SOURCES = \
|
||||
control-notify.c \
|
||||
control.c \
|
||||
environ.c \
|
||||
events-payload.c \
|
||||
events.c \
|
||||
file.c \
|
||||
format.c \
|
||||
format-draw.c \
|
||||
format.c \
|
||||
fuzzy.c \
|
||||
grid-reader.c \
|
||||
grid-view.c \
|
||||
grid.c \
|
||||
hooks.c \
|
||||
hyperlinks.c \
|
||||
input-keys.c \
|
||||
input.c \
|
||||
job.c \
|
||||
@@ -161,13 +183,15 @@ dist_tmux_SOURCES = \
|
||||
log.c \
|
||||
menu.c \
|
||||
mode-tree.c \
|
||||
monitor.c \
|
||||
names.c \
|
||||
notify.c \
|
||||
options-table.c \
|
||||
options.c \
|
||||
paste.c \
|
||||
popup.c \
|
||||
proc.c \
|
||||
prompt-history.c \
|
||||
prompt.c \
|
||||
regsub.c \
|
||||
resize.c \
|
||||
screen-redraw.c \
|
||||
@@ -178,24 +202,31 @@ dist_tmux_SOURCES = \
|
||||
server-fn.c \
|
||||
server.c \
|
||||
session.c \
|
||||
sort.c \
|
||||
spawn.c \
|
||||
status.c \
|
||||
style.c \
|
||||
tmux-protocol.h \
|
||||
tmux.c \
|
||||
tmux.h \
|
||||
tmux-protocol.h \
|
||||
tty-acs.c \
|
||||
tty-draw.c \
|
||||
tty-features.c \
|
||||
tty-keys.c \
|
||||
tty-term.c \
|
||||
tty.c \
|
||||
utf8-combined.c \
|
||||
utf8.c \
|
||||
window-border.c \
|
||||
window-buffer.c \
|
||||
window-client.c \
|
||||
window-clock.c \
|
||||
window-copy.c \
|
||||
window-customize.c \
|
||||
window-panes.c \
|
||||
window-switch.c \
|
||||
window-tree.c \
|
||||
window-visible.c \
|
||||
window.c \
|
||||
xmalloc.c \
|
||||
xmalloc.h
|
||||
@@ -216,10 +247,26 @@ if HAVE_UTF8PROC
|
||||
nodist_tmux_SOURCES += compat/utf8proc.c
|
||||
endif
|
||||
|
||||
# Enable image support.
|
||||
if ENABLE_IMAGES
|
||||
dist_tmux_SOURCES += image.c image-sixel.c image-kitty.c
|
||||
endif
|
||||
|
||||
# Add bits for fuzzing if enabled.
|
||||
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_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
|
||||
|
||||
# Install tmux.1 in the right format.
|
||||
@@ -234,3 +281,7 @@ install-exec-hook:
|
||||
$(mkdir_p) $(DESTDIR)$(mandir)/man1
|
||||
$(INSTALL_DATA) $(srcdir)/tmux.1.@MANFORMAT@ \
|
||||
$(DESTDIR)$(mandir)/man1/tmux.1
|
||||
|
||||
# And uninstall it.
|
||||
uninstall-hook:
|
||||
rm -f $(DESTDIR)$(mandir)/man1/tmux.1
|
||||
|
||||
3
README
3
README
@@ -36,6 +36,7 @@ autoconf, automake and pkg-config:
|
||||
$ cd tmux
|
||||
$ sh autogen.sh
|
||||
$ ./configure && make
|
||||
$ sudo make install
|
||||
|
||||
* Contributing
|
||||
|
||||
@@ -65,7 +66,7 @@ Also see the tmux FAQ 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
|
||||
in the current directory.
|
||||
|
||||
62
README.ja
62
README.ja
@@ -1,62 +0,0 @@
|
||||
tmuxへようこそ!
|
||||
|
||||
tmuxはターミナルマルチプレクサーです。複数のターミナルを一つのスクリーン内に作成し、操作することができます。
|
||||
バックグラウンドで処理を実行中に一度スクリーンから離れて後から復帰することも可能です。
|
||||
|
||||
OpenBSD、FreeBSD、NetBSD、Linux、macOS、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
1
SECURITY.md
Normal file
@@ -0,0 +1 @@
|
||||
Please report security issues to nicholas.marriott@gmail.com.
|
||||
173
SYNCING
173
SYNCING
@@ -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
234
SYNCING.md
Normal 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`.
|
||||
16
alerts.c
16
alerts.c
@@ -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>
|
||||
@@ -205,7 +205,7 @@ alerts_check_bell(struct window *w)
|
||||
}
|
||||
if (!alerts_action_applies(wl, "bell-action"))
|
||||
continue;
|
||||
notify_winlink("alert-bell", wl);
|
||||
events_fire_winlink("alert-bell", wl);
|
||||
|
||||
if (s->flags & SESSION_ALERTED)
|
||||
continue;
|
||||
@@ -241,7 +241,7 @@ alerts_check_activity(struct window *w)
|
||||
}
|
||||
if (!alerts_action_applies(wl, "activity-action"))
|
||||
continue;
|
||||
notify_winlink("alert-activity", wl);
|
||||
events_fire_winlink("alert-activity", wl);
|
||||
|
||||
if (s->flags & SESSION_ALERTED)
|
||||
continue;
|
||||
@@ -277,7 +277,7 @@ alerts_check_silence(struct window *w)
|
||||
}
|
||||
if (!alerts_action_applies(wl, "silence-action"))
|
||||
continue;
|
||||
notify_winlink("alert-silence", wl);
|
||||
events_fire_winlink("alert-silence", wl);
|
||||
|
||||
if (s->flags & SESSION_ALERTED)
|
||||
continue;
|
||||
@@ -315,11 +315,11 @@ alerts_set_message(struct winlink *wl, const char *type, const char *option)
|
||||
if (visual == VISUAL_OFF)
|
||||
continue;
|
||||
if (c->session->curw == wl) {
|
||||
status_message_set(c, -1, 1, 0, "%s in current window",
|
||||
type);
|
||||
status_message_set(c, -1, 1, 0, 0,
|
||||
"%s in current window", type);
|
||||
} else {
|
||||
status_message_set(c, -1, 1, 0, "%s in window %d", type,
|
||||
wl->idx);
|
||||
status_message_set(c, -1, 1, 0, 0,
|
||||
"%s in window %d", type, wl->idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
365
arguments.c
365
arguments.c
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD$ */
|
||||
/* $OpenBSD: arguments.c,v 1.66 2026/06/26 09:54:56 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
@@ -37,6 +37,10 @@ struct args_entry {
|
||||
u_char flag;
|
||||
struct args_values values;
|
||||
u_int count;
|
||||
|
||||
int flags;
|
||||
#define ARGS_ENTRY_OPTIONAL_VALUE 0x1
|
||||
|
||||
RB_ENTRY(args_entry) entry;
|
||||
};
|
||||
|
||||
@@ -94,6 +98,22 @@ args_copy_value(struct args_value *to, struct args_value *from)
|
||||
}
|
||||
}
|
||||
|
||||
/* Type to string. */
|
||||
static const char *
|
||||
args_type_to_string (enum args_type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case ARGS_NONE:
|
||||
return "NONE";
|
||||
case ARGS_STRING:
|
||||
return "STRING";
|
||||
case ARGS_COMMANDS:
|
||||
return "COMMANDS";
|
||||
}
|
||||
return "INVALID";
|
||||
}
|
||||
|
||||
/* Get value as string. */
|
||||
static const char *
|
||||
args_value_as_string(struct args_value *value)
|
||||
@@ -122,6 +142,115 @@ args_create(void)
|
||||
return (args);
|
||||
}
|
||||
|
||||
/* Parse a single flag. */
|
||||
static int
|
||||
args_parse_flag_argument(struct args_value *values, u_int count, char **cause,
|
||||
struct args *args, u_int *i, const char *string, int flag,
|
||||
int optional_argument)
|
||||
{
|
||||
struct args_value *argument, *new;
|
||||
const char *s, *as;
|
||||
|
||||
new = xcalloc(1, sizeof *new);
|
||||
if (*string != '\0') {
|
||||
new->type = ARGS_STRING;
|
||||
new->string = xstrdup(string);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (*i == count)
|
||||
argument = NULL;
|
||||
else {
|
||||
argument = &values[*i];
|
||||
if (argument->type != ARGS_STRING) {
|
||||
xasprintf(cause, "-%c argument must be a string", flag);
|
||||
args_free_value(new);
|
||||
free(new);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
if (argument == NULL) {
|
||||
args_free_value(new);
|
||||
free(new);
|
||||
if (optional_argument) {
|
||||
log_debug("%s: -%c (optional)", __func__, flag);
|
||||
args_set(args, flag, NULL, ARGS_ENTRY_OPTIONAL_VALUE);
|
||||
return (0); /* either - or end */
|
||||
}
|
||||
xasprintf(cause, "-%c expects an argument", flag);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (optional_argument && argument->type == ARGS_STRING) {
|
||||
as = argument->string;
|
||||
if (as[0] == '-' && (as[1] == '-' || isalpha((u_char)as[1]))) {
|
||||
args_free_value(new);
|
||||
free(new);
|
||||
log_debug("%s: -%c (optional)", __func__, flag);
|
||||
args_set(args, flag, NULL, ARGS_ENTRY_OPTIONAL_VALUE);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
args_copy_value(new, argument);
|
||||
(*i)++;
|
||||
|
||||
out:
|
||||
s = args_value_as_string(new);
|
||||
log_debug("%s: -%c = %s", __func__, flag, s);
|
||||
|
||||
args_set(args, flag, new, 0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Parse flags argument. */
|
||||
static int
|
||||
args_parse_flags(const struct args_parse *parse, struct args_value *values,
|
||||
u_int count, char **cause, struct args *args, u_int *i)
|
||||
{
|
||||
struct args_value *value;
|
||||
u_char flag;
|
||||
const char *found, *string;
|
||||
int optional_argument;
|
||||
|
||||
value = &values[*i];
|
||||
if (value->type != ARGS_STRING)
|
||||
return (1);
|
||||
|
||||
string = value->string;
|
||||
log_debug("%s: next %s", __func__, string);
|
||||
if (*string++ != '-' || *string == '\0')
|
||||
return (1);
|
||||
(*i)++;
|
||||
if (string[0] == '-' && string[1] == '\0')
|
||||
return (1);
|
||||
|
||||
for (;;) {
|
||||
flag = *string++;
|
||||
if (flag == '\0')
|
||||
return (0);
|
||||
if (flag == '?')
|
||||
return (-1);
|
||||
if (!isalnum(flag)) {
|
||||
xasprintf(cause, "invalid flag -%c", flag);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
found = strchr(parse->template, flag);
|
||||
if (found == NULL) {
|
||||
xasprintf(cause, "unknown flag -%c", flag);
|
||||
return (-1);
|
||||
}
|
||||
if (found[1] != ':') {
|
||||
log_debug("%s: -%c", __func__, flag);
|
||||
args_set(args, flag, NULL, 0);
|
||||
continue;
|
||||
}
|
||||
optional_argument = (found[2] == ':');
|
||||
return (args_parse_flag_argument(values, count, cause, args, i,
|
||||
string, flag, optional_argument));
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse arguments into a new argument set. */
|
||||
struct args *
|
||||
args_parse(const struct args_parse *parse, struct args_value *values,
|
||||
@@ -131,86 +260,21 @@ args_parse(const struct args_parse *parse, struct args_value *values,
|
||||
u_int i;
|
||||
enum args_parse_type type;
|
||||
struct args_value *value, *new;
|
||||
u_char flag;
|
||||
const char *found, *string, *s;
|
||||
int optional_argument;
|
||||
const char *s;
|
||||
int stop;
|
||||
|
||||
if (count == 0)
|
||||
return (args_create());
|
||||
|
||||
args = args_create();
|
||||
for (i = 1; i < count; /* nothing */) {
|
||||
value = &values[i];
|
||||
if (value->type != ARGS_STRING)
|
||||
break;
|
||||
|
||||
string = value->string;
|
||||
if (*string++ != '-' || *string == '\0')
|
||||
break;
|
||||
i++;
|
||||
if (string[0] == '-' && string[1] == '\0')
|
||||
break;
|
||||
|
||||
for (;;) {
|
||||
flag = *string++;
|
||||
if (flag == '\0')
|
||||
break;
|
||||
if (flag == '?') {
|
||||
args_free(args);
|
||||
return (NULL);
|
||||
}
|
||||
if (!isalnum(flag)) {
|
||||
xasprintf(cause, "invalid flag -%c", flag);
|
||||
args_free(args);
|
||||
return (NULL);
|
||||
}
|
||||
found = strchr(parse->template, flag);
|
||||
if (found == NULL) {
|
||||
xasprintf(cause, "unknown flag -%c", flag);
|
||||
args_free(args);
|
||||
return (NULL);
|
||||
}
|
||||
if (*++found != ':') {
|
||||
log_debug("%s: -%c", __func__, flag);
|
||||
args_set(args, flag, NULL);
|
||||
continue;
|
||||
}
|
||||
if (*found == ':') {
|
||||
optional_argument = 1;
|
||||
found++;
|
||||
}
|
||||
new = xcalloc(1, sizeof *new);
|
||||
if (*string != '\0') {
|
||||
new->type = ARGS_STRING;
|
||||
new->string = xstrdup(string);
|
||||
} else {
|
||||
if (i == count) {
|
||||
if (optional_argument) {
|
||||
log_debug("%s: -%c", __func__,
|
||||
flag);
|
||||
args_set(args, flag, NULL);
|
||||
continue;
|
||||
}
|
||||
xasprintf(cause,
|
||||
"-%c expects an argument",
|
||||
flag);
|
||||
args_free(args);
|
||||
return (NULL);
|
||||
}
|
||||
if (values[i].type != ARGS_STRING) {
|
||||
xasprintf(cause,
|
||||
"-%c argument must be a string",
|
||||
flag);
|
||||
args_free(args);
|
||||
return (NULL);
|
||||
}
|
||||
args_copy_value(new, &values[i++]);
|
||||
}
|
||||
s = args_value_as_string(new);
|
||||
log_debug("%s: -%c = %s", __func__, flag, s);
|
||||
args_set(args, flag, new);
|
||||
break;
|
||||
stop = args_parse_flags(parse, values, count, cause, args, &i);
|
||||
if (stop == -1) {
|
||||
args_free(args);
|
||||
return (NULL);
|
||||
}
|
||||
if (stop == 1)
|
||||
break;
|
||||
}
|
||||
log_debug("%s: flags end at %u of %u", __func__, i, count);
|
||||
if (i != count) {
|
||||
@@ -218,8 +282,8 @@ args_parse(const struct args_parse *parse, struct args_value *values,
|
||||
value = &values[i];
|
||||
|
||||
s = args_value_as_string(value);
|
||||
log_debug("%s: %u = %s (type %d)", __func__, i, s,
|
||||
value->type);
|
||||
log_debug("%s: %u = %s (type %s)", __func__, i, s,
|
||||
args_type_to_string (value->type));
|
||||
|
||||
if (parse->cb != NULL) {
|
||||
type = parse->cb(args, args->count, cause);
|
||||
@@ -323,13 +387,13 @@ args_copy(struct args *args, int argc, char **argv)
|
||||
RB_FOREACH(entry, args_tree, &args->tree) {
|
||||
if (TAILQ_EMPTY(&entry->values)) {
|
||||
for (i = 0; i < entry->count; i++)
|
||||
args_set(new_args, entry->flag, NULL);
|
||||
args_set(new_args, entry->flag, NULL, 0);
|
||||
continue;
|
||||
}
|
||||
TAILQ_FOREACH(value, &entry->values, entry) {
|
||||
new_value = xcalloc(1, sizeof *new_value);
|
||||
args_copy_copy_value(new_value, value, argc, argv);
|
||||
args_set(new_args, entry->flag, new_value);
|
||||
args_set(new_args, entry->flag, new_value, 0);
|
||||
}
|
||||
}
|
||||
if (args->count == 0)
|
||||
@@ -487,6 +551,7 @@ args_print(struct args *args)
|
||||
char *buf;
|
||||
u_int i, j;
|
||||
struct args_entry *entry;
|
||||
struct args_entry *last = NULL;
|
||||
struct args_value *value;
|
||||
|
||||
len = 1;
|
||||
@@ -494,6 +559,8 @@ args_print(struct args *args)
|
||||
|
||||
/* Process the flags first. */
|
||||
RB_FOREACH(entry, args_tree, &args->tree) {
|
||||
if (entry->flags & ARGS_ENTRY_OPTIONAL_VALUE)
|
||||
continue;
|
||||
if (!TAILQ_EMPTY(&entry->values))
|
||||
continue;
|
||||
|
||||
@@ -505,6 +572,16 @@ args_print(struct args *args)
|
||||
|
||||
/* Then the flags with arguments. */
|
||||
RB_FOREACH(entry, args_tree, &args->tree) {
|
||||
if (entry->flags & ARGS_ENTRY_OPTIONAL_VALUE) {
|
||||
if (*buf != '\0')
|
||||
args_print_add(&buf, &len, " -%c", entry->flag);
|
||||
else
|
||||
args_print_add(&buf, &len, "-%c", entry->flag);
|
||||
last = entry;
|
||||
continue;
|
||||
}
|
||||
if (TAILQ_EMPTY(&entry->values))
|
||||
continue;
|
||||
TAILQ_FOREACH(value, &entry->values, entry) {
|
||||
if (*buf != '\0')
|
||||
args_print_add(&buf, &len, " -%c", entry->flag);
|
||||
@@ -512,7 +589,10 @@ args_print(struct args *args)
|
||||
args_print_add(&buf, &len, "-%c", entry->flag);
|
||||
args_print_add_value(&buf, &len, value);
|
||||
}
|
||||
last = entry;
|
||||
}
|
||||
if (last && (last->flags & ARGS_ENTRY_OPTIONAL_VALUE))
|
||||
args_print_add(&buf, &len, " --");
|
||||
|
||||
/* And finally the argument vector. */
|
||||
for (i = 0; i < args->count; i++)
|
||||
@@ -582,7 +662,7 @@ args_has(struct args *args, u_char flag)
|
||||
|
||||
/* Set argument value in the arguments tree. */
|
||||
void
|
||||
args_set(struct args *args, u_char flag, struct args_value *value)
|
||||
args_set(struct args *args, u_char flag, struct args_value *value, int flags)
|
||||
{
|
||||
struct args_entry *entry;
|
||||
|
||||
@@ -591,12 +671,15 @@ args_set(struct args *args, u_char flag, struct args_value *value)
|
||||
entry = xcalloc(1, sizeof *entry);
|
||||
entry->flag = flag;
|
||||
entry->count = 1;
|
||||
entry->flags = flags;
|
||||
TAILQ_INIT(&entry->values);
|
||||
RB_INSERT(args_tree, &args->tree, entry);
|
||||
} else
|
||||
entry->count++;
|
||||
if (value != NULL && value->type != ARGS_NONE)
|
||||
TAILQ_INSERT_TAIL(&entry->values, value, entry);
|
||||
else
|
||||
free(value);
|
||||
}
|
||||
|
||||
/* Get argument value. Will be NULL if it isn't present. */
|
||||
@@ -696,6 +779,7 @@ args_make_commands_prepare(struct cmd *self, struct cmdq_item *item, u_int idx,
|
||||
struct args_value *value;
|
||||
struct args_command_state *state;
|
||||
const char *cmd;
|
||||
const char *file;
|
||||
|
||||
state = xcalloc(1, sizeof *state);
|
||||
|
||||
@@ -722,7 +806,9 @@ args_make_commands_prepare(struct cmd *self, struct cmdq_item *item, u_int idx,
|
||||
|
||||
if (wait)
|
||||
state->pi.item = item;
|
||||
cmd_get_source(self, &state->pi.file, &state->pi.line);
|
||||
cmd_get_source(self, &file, &state->pi.line);
|
||||
if (file != NULL)
|
||||
state->pi.file = xstrdup(file);
|
||||
state->pi.c = tc;
|
||||
if (state->pi.c != NULL)
|
||||
state->pi.c->references++;
|
||||
@@ -747,6 +833,8 @@ args_make_commands(struct args_command_state *state, int argc, char **argv,
|
||||
}
|
||||
|
||||
cmd = xstrdup(state->cmd);
|
||||
log_debug("%s: %s", __func__, cmd);
|
||||
cmd_log_argv(argc, argv, __func__);
|
||||
for (i = 0; i < argc; i++) {
|
||||
new_cmd = cmd_template_replace(cmd, argv[i], i + 1);
|
||||
log_debug("%s: %%%u %s: %s", __func__, i + 1, argv[i], new_cmd);
|
||||
@@ -775,6 +863,7 @@ args_make_commands_free(struct args_command_state *state)
|
||||
cmd_list_free(state->cmdlist);
|
||||
if (state->pi.c != NULL)
|
||||
server_client_unref(state->pi.c);
|
||||
free((void *)state->pi.file);
|
||||
free(state->cmd);
|
||||
free(state);
|
||||
}
|
||||
@@ -848,6 +937,41 @@ args_strtonum(struct args *args, u_char flag, long long minval,
|
||||
return (ll);
|
||||
}
|
||||
|
||||
/* Convert an argument value to a number, and expand formats. */
|
||||
long long
|
||||
args_strtonum_and_expand(struct args *args, u_char flag, long long minval,
|
||||
long long maxval, struct cmdq_item *item, char **cause)
|
||||
{
|
||||
const char *errstr;
|
||||
char *formatted;
|
||||
long long ll;
|
||||
struct args_entry *entry;
|
||||
struct args_value *value;
|
||||
|
||||
if ((entry = args_find(args, flag)) == NULL) {
|
||||
*cause = xstrdup("missing");
|
||||
return (0);
|
||||
}
|
||||
value = TAILQ_LAST(&entry->values, args_values);
|
||||
if (value == NULL ||
|
||||
value->type != ARGS_STRING ||
|
||||
value->string == NULL) {
|
||||
*cause = xstrdup("missing");
|
||||
return (0);
|
||||
}
|
||||
|
||||
formatted = format_single_from_target(item, value->string);
|
||||
ll = strtonum(formatted, minval, maxval, &errstr);
|
||||
free(formatted);
|
||||
if (errstr != NULL) {
|
||||
*cause = xstrdup(errstr);
|
||||
return (0);
|
||||
}
|
||||
|
||||
*cause = NULL;
|
||||
return (ll);
|
||||
}
|
||||
|
||||
/* Convert an argument to a number which may be a percentage. */
|
||||
long long
|
||||
args_percentage(struct args *args, u_char flag, long long minval,
|
||||
@@ -860,6 +984,10 @@ args_percentage(struct args *args, u_char flag, long long minval,
|
||||
*cause = xstrdup("missing");
|
||||
return (0);
|
||||
}
|
||||
if (TAILQ_EMPTY(&entry->values)) {
|
||||
*cause = xstrdup("empty");
|
||||
return (0);
|
||||
}
|
||||
value = TAILQ_LAST(&entry->values, args_values)->string;
|
||||
return (args_string_percentage(value, minval, maxval, curval, cause));
|
||||
}
|
||||
@@ -874,11 +1002,15 @@ args_string_percentage(const char *value, long long minval, long long maxval,
|
||||
size_t valuelen = strlen(value);
|
||||
char *copy;
|
||||
|
||||
if (valuelen == 0) {
|
||||
*cause = xstrdup("empty");
|
||||
return (0);
|
||||
}
|
||||
if (value[valuelen - 1] == '%') {
|
||||
copy = xstrdup(value);
|
||||
copy[valuelen - 1] = '\0';
|
||||
|
||||
ll = strtonum(copy, 0, 100, &errstr);
|
||||
ll = strtonum(copy, 0, 1000, &errstr);
|
||||
free(copy);
|
||||
if (errstr != NULL) {
|
||||
*cause = xstrdup(errstr);
|
||||
@@ -904,3 +1036,74 @@ args_string_percentage(const char *value, long long minval, long long maxval,
|
||||
*cause = NULL;
|
||||
return (ll);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an argument to a number which may be a percentage, and expand
|
||||
* formats.
|
||||
*/
|
||||
long long
|
||||
args_percentage_and_expand(struct args *args, u_char flag, long long minval,
|
||||
long long maxval, long long curval, struct cmdq_item *item, char **cause)
|
||||
{
|
||||
const char *value;
|
||||
struct args_entry *entry;
|
||||
|
||||
if ((entry = args_find(args, flag)) == NULL) {
|
||||
*cause = xstrdup("missing");
|
||||
return (0);
|
||||
}
|
||||
if (TAILQ_EMPTY(&entry->values)) {
|
||||
*cause = xstrdup("empty");
|
||||
return (0);
|
||||
}
|
||||
value = TAILQ_LAST(&entry->values, args_values)->string;
|
||||
return (args_string_percentage_and_expand(value, minval, maxval, curval,
|
||||
item, cause));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a string to a number which may be a percentage, and expand formats.
|
||||
*/
|
||||
long long
|
||||
args_string_percentage_and_expand(const char *value, long long minval,
|
||||
long long maxval, long long curval, struct cmdq_item *item, char **cause)
|
||||
{
|
||||
const char *errstr;
|
||||
long long ll;
|
||||
size_t valuelen = strlen(value);
|
||||
char *copy, *f;
|
||||
|
||||
if (value[valuelen - 1] == '%') {
|
||||
copy = xstrdup(value);
|
||||
copy[valuelen - 1] = '\0';
|
||||
|
||||
f = format_single_from_target(item, copy);
|
||||
ll = strtonum(f, 0, 1000, &errstr);
|
||||
free(f);
|
||||
free(copy);
|
||||
if (errstr != NULL) {
|
||||
*cause = xstrdup(errstr);
|
||||
return (0);
|
||||
}
|
||||
ll = (curval * ll) / 100;
|
||||
if (ll < minval) {
|
||||
*cause = xstrdup("too small");
|
||||
return (0);
|
||||
}
|
||||
if (ll > maxval) {
|
||||
*cause = xstrdup("too large");
|
||||
return (0);
|
||||
}
|
||||
} else {
|
||||
f = format_single_from_target(item, value);
|
||||
ll = strtonum(f, minval, maxval, &errstr);
|
||||
free(f);
|
||||
if (errstr != NULL) {
|
||||
*cause = xstrdup(errstr);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
*cause = NULL;
|
||||
return (ll);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -31,7 +31,7 @@ attributes_tostring(int attr)
|
||||
if (attr == 0)
|
||||
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_BRIGHT) ? "bright," : "",
|
||||
(attr & GRID_ATTR_DIM) ? "dim," : "",
|
||||
@@ -45,7 +45,8 @@ attributes_tostring(int attr)
|
||||
(attr & GRID_ATTR_UNDERSCORE_3) ? "curly-underscore," : "",
|
||||
(attr & GRID_ATTR_UNDERSCORE_4) ? "dotted-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)
|
||||
buf[len - 1] = '\0';
|
||||
|
||||
|
||||
68
cfg.c
68
cfg.c
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD$ */
|
||||
/* $OpenBSD: cfg.c,v 1.91 2026/08/03 13:38:42 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* 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);
|
||||
cfg_finished = 1;
|
||||
|
||||
if (!RB_EMPTY(&sessions))
|
||||
cfg_show_causes(RB_MIN(sessions, &sessions));
|
||||
cfg_show_causes(NULL);
|
||||
|
||||
if (cfg_item != NULL)
|
||||
cmdq_continue(cfg_item);
|
||||
|
||||
status_prompt_load_history();
|
||||
prompt_load_history();
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
@@ -67,6 +66,7 @@ start_cfg(void)
|
||||
{
|
||||
struct client *c;
|
||||
u_int i;
|
||||
int flags = 0;
|
||||
|
||||
/*
|
||||
* Configuration files are loaded without a client, so commands are run
|
||||
@@ -84,19 +84,17 @@ start_cfg(void)
|
||||
cmdq_append(c, cfg_item);
|
||||
}
|
||||
|
||||
for (i = 0; i < cfg_nfiles; i++) {
|
||||
if (cfg_quiet)
|
||||
load_cfg(cfg_files[i], c, NULL, CMD_PARSE_QUIET, NULL);
|
||||
else
|
||||
load_cfg(cfg_files[i], c, NULL, 0, NULL);
|
||||
}
|
||||
if (cfg_quiet)
|
||||
flags = CMD_PARSE_QUIET;
|
||||
for (i = 0; i < cfg_nfiles; i++)
|
||||
load_cfg(cfg_files[i], c, NULL, NULL, flags, NULL);
|
||||
|
||||
cmdq_append(NULL, cmdq_get_callback(cfg_done, NULL));
|
||||
}
|
||||
|
||||
int
|
||||
load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
|
||||
struct cmdq_item **new_item)
|
||||
load_cfg(const char *path, struct client *c, struct cmdq_item *item,
|
||||
struct cmd_find_state *current, int flags, struct cmdq_item **new_item)
|
||||
{
|
||||
FILE *f;
|
||||
struct cmd_parse_input pi;
|
||||
@@ -135,7 +133,7 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
|
||||
}
|
||||
|
||||
if (item != NULL)
|
||||
state = cmdq_copy_state(cmdq_get_state(item));
|
||||
state = cmdq_copy_state(cmdq_get_state(item), current);
|
||||
else
|
||||
state = cmdq_new_state(NULL, NULL, 0);
|
||||
cmdq_add_format(state, "current_file", "%s", pi.file);
|
||||
@@ -155,8 +153,8 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
|
||||
|
||||
int
|
||||
load_cfg_from_buffer(const void *buf, size_t len, const char *path,
|
||||
struct client *c, struct cmdq_item *item, int flags,
|
||||
struct cmdq_item **new_item)
|
||||
struct client *c, struct cmdq_item *item, struct cmd_find_state *current,
|
||||
int flags, struct cmdq_item **new_item)
|
||||
{
|
||||
struct cmd_parse_input pi;
|
||||
struct cmd_parse_result *pr;
|
||||
@@ -187,7 +185,7 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,
|
||||
}
|
||||
|
||||
if (item != NULL)
|
||||
state = cmdq_copy_state(cmdq_get_state(item));
|
||||
state = cmdq_copy_state(cmdq_get_state(item), current);
|
||||
else
|
||||
state = cmdq_new_state(NULL, NULL, 0);
|
||||
cmdq_add_format(state, "current_file", "%s", pi.file);
|
||||
@@ -223,11 +221,17 @@ cfg_add_cause(const char *fmt, ...)
|
||||
void
|
||||
cfg_print_causes(struct cmdq_item *item)
|
||||
{
|
||||
u_int i;
|
||||
struct client *c = cmdq_get_client(item);
|
||||
u_int i;
|
||||
char *cause;
|
||||
|
||||
for (i = 0; i < cfg_ncauses; i++) {
|
||||
cmdq_print(item, "%s", cfg_causes[i]);
|
||||
free(cfg_causes[i]);
|
||||
cause = cfg_causes[i];
|
||||
if (c != NULL && (c->flags & CLIENT_CONTROL))
|
||||
control_notify_write(c, "%%config-error %s", cause);
|
||||
else
|
||||
cmdq_print(item, "%s", cause);
|
||||
free(cause);
|
||||
}
|
||||
|
||||
free(cfg_causes);
|
||||
@@ -238,22 +242,44 @@ cfg_print_causes(struct cmdq_item *item)
|
||||
void
|
||||
cfg_show_causes(struct session *s)
|
||||
{
|
||||
struct client *c = TAILQ_FIRST(&clients);
|
||||
struct window_pane *wp;
|
||||
struct window_mode_entry *wme;
|
||||
u_int i;
|
||||
char *cause;
|
||||
|
||||
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++) {
|
||||
cause = cfg_causes[i];
|
||||
control_notify_write(c, "%%config-error %s", cause);
|
||||
free(cause);
|
||||
}
|
||||
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;
|
||||
wp = s->curw->window->active;
|
||||
|
||||
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_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL,
|
||||
NULL);
|
||||
for (i = 0; i < cfg_ncauses; i++) {
|
||||
window_copy_add(wp, 0, "%s", cfg_causes[i]);
|
||||
free(cfg_causes[i]);
|
||||
}
|
||||
|
||||
out:
|
||||
free(cfg_causes);
|
||||
cfg_causes = NULL;
|
||||
cfg_ncauses = 0;
|
||||
|
||||
79
client.c
79
client.c
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD$ */
|
||||
/* $OpenBSD: client.c,v 1.167 2026/08/17 07:56:56 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
@@ -239,15 +239,11 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
|
||||
pid_t ppid;
|
||||
enum msgtype msg;
|
||||
struct termios tio, saved_tio;
|
||||
size_t size, linesize = 0;
|
||||
ssize_t linelen;
|
||||
char *line = NULL, **caps = NULL, *cause;
|
||||
size_t size;
|
||||
char **caps = NULL, *cause;
|
||||
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. */
|
||||
if (shell_command != NULL) {
|
||||
msg = MSG_SHELL;
|
||||
@@ -280,10 +276,16 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
|
||||
proc_set_signals(client_proc, client_signal);
|
||||
|
||||
/* Save the flags. */
|
||||
client_flags = flags;
|
||||
client_flags = flags|CLIENT_WRITE_ACK;
|
||||
log_debug("flags are %#llx", (unsigned long long)client_flags);
|
||||
|
||||
/* 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);
|
||||
if (fd == -1) {
|
||||
if (errno == ECONNREFUSED) {
|
||||
@@ -404,11 +406,6 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
|
||||
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. */
|
||||
if (client_attached) {
|
||||
if (client_exitreason != CLIENT_EXIT_NONE)
|
||||
@@ -423,15 +420,8 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
|
||||
else
|
||||
printf("%%exit\n");
|
||||
fflush(stdout);
|
||||
if (client_flags & CLIENT_CONTROL_WAITEXIT) {
|
||||
setvbuf(stdin, NULL, _IOLBF, 0);
|
||||
for (;;) {
|
||||
linelen = getline(&line, &linesize, stdin);
|
||||
if (linelen <= 1)
|
||||
break;
|
||||
}
|
||||
free(line);
|
||||
}
|
||||
if (client_flags & CLIENT_CONTROL_WAITEXIT)
|
||||
control_wait_exit(STDIN_FILENO);
|
||||
if (client_flags & CLIENT_CONTROLCONTROL) {
|
||||
printf("\033\\");
|
||||
fflush(stdout);
|
||||
@@ -439,6 +429,12 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
|
||||
}
|
||||
} else if (client_exitreason != CLIENT_EXIT_NONE)
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -449,11 +445,12 @@ client_send_identify(const char *ttynam, const char *termname, char **caps,
|
||||
{
|
||||
char **ss;
|
||||
size_t sslen;
|
||||
int fd, flags = client_flags;
|
||||
int fd;
|
||||
uint64_t flags = client_flags;
|
||||
pid_t pid;
|
||||
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,
|
||||
sizeof client_flags);
|
||||
|
||||
@@ -494,20 +491,10 @@ client_send_identify(const char *ttynam, const char *termname, char **caps,
|
||||
static __dead void
|
||||
client_exec(const char *shell, const char *shellcmd)
|
||||
{
|
||||
const char *name, *ptr;
|
||||
char *argv0;
|
||||
char *argv0;
|
||||
|
||||
log_debug("shell %s, command %s", shell, shellcmd);
|
||||
|
||||
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);
|
||||
argv0 = shell_argv0(shell, !!(client_flags & CLIENT_LOGIN));
|
||||
setenv("SHELL", shell, 1);
|
||||
|
||||
proc_clear_signals(client_proc, 1);
|
||||
@@ -527,11 +514,22 @@ client_signal(int sig)
|
||||
{
|
||||
struct sigaction sigact;
|
||||
int status;
|
||||
pid_t pid;
|
||||
|
||||
log_debug("%s: %s", __func__, strsignal(sig));
|
||||
if (sig == SIGCHLD)
|
||||
waitpid(WAIT_ANY, &status, WNOHANG);
|
||||
else if (!client_attached) {
|
||||
if (sig == SIGCHLD) {
|
||||
for (;;) {
|
||||
pid = waitpid(WAIT_ANY, &status, WNOHANG);
|
||||
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);
|
||||
} else {
|
||||
@@ -694,6 +692,9 @@ client_dispatch_wait(struct imsg *imsg)
|
||||
!(client_flags & CLIENT_CONTROL), client_file_check_cb,
|
||||
NULL);
|
||||
break;
|
||||
case MSG_READ_CANCEL:
|
||||
file_read_cancel(&client_files, imsg);
|
||||
break;
|
||||
case MSG_WRITE_OPEN:
|
||||
file_write_open(&client_files, client_peer, imsg, 1,
|
||||
!(client_flags & CLIENT_CONTROL), client_file_check_cb,
|
||||
|
||||
@@ -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>
|
||||
@@ -61,6 +61,7 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
||||
struct window_pane *wp;
|
||||
char *cwd, *cause;
|
||||
enum msgtype msgtype;
|
||||
uid_t uid;
|
||||
|
||||
if (RB_EMPTY(&sessions)) {
|
||||
cmdq_error(item, "no sessions");
|
||||
@@ -106,8 +107,16 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
||||
}
|
||||
if (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->last_session = c->session;
|
||||
if (c->session != NULL) {
|
||||
@@ -154,10 +163,13 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
||||
|
||||
if (~c->flags & CLIENT_CONTROL)
|
||||
proc_send(c->peer, MSG_READY, -1, NULL, 0);
|
||||
notify_client("client-attached", c);
|
||||
events_fire_client("client-attached", c);
|
||||
c->flags |= CLIENT_ATTACHED;
|
||||
}
|
||||
|
||||
if (cfg_finished)
|
||||
cfg_show_causes(s);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -38,7 +38,7 @@ const struct cmd_entry cmd_bind_key_entry = {
|
||||
|
||||
.args = { "nrN:T:", 1, -1, cmd_bind_key_args_parse },
|
||||
.usage = "[-nr] [-T key-table] [-N note] key "
|
||||
"[command [arguments]]",
|
||||
"[command [argument ...]]",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_bind_key_exec
|
||||
|
||||
111
cmd-break-pane.c
111
cmd-break-pane.c
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD$ */
|
||||
/* $OpenBSD: cmd-break-pane.c,v 1.76 2026/08/17 07:04:45 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
@@ -34,9 +34,10 @@ const struct cmd_entry cmd_break_pane_entry = {
|
||||
.name = "break-pane",
|
||||
.alias = "breakp",
|
||||
|
||||
.args = { "abdPF:n:s:t:", 0, 0, NULL },
|
||||
.usage = "[-abdP] [-F format] [-n window-name] [-s src-pane] "
|
||||
"[-t dst-window]",
|
||||
.args = { "abdPF:n:s:t:Wx:X:y:Y:", 0, 0, NULL },
|
||||
.usage = "[-abdPW] [-F format] [-n window-name] [-s src-pane] "
|
||||
"[-t dst-window] [-x width] [-y height] [-X x-position] "
|
||||
"[-Y y-position]",
|
||||
|
||||
.source = { 's', CMD_FIND_PANE, 0 },
|
||||
.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
|
||||
};
|
||||
|
||||
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
|
||||
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 *dst_s = target->s;
|
||||
struct window_pane *wp = source->wp;
|
||||
struct window *w = wl->window;
|
||||
char *name, *cause, *cp;
|
||||
int idx = target->idx, before;
|
||||
const char *template;
|
||||
struct window *w = wl->window, *old_w = w;
|
||||
char *cause, *cp;
|
||||
int idx = target->idx, before, old_idx = wl->idx;
|
||||
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');
|
||||
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);
|
||||
|
||||
if (window_count_panes(w) == 1) {
|
||||
if (window_count_panes(w, 1) == 1) {
|
||||
if (server_link_window(src_s, wl, dst_s, idx, 0,
|
||||
!args_has(args, 'd'), &cause) != 0) {
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (args_has(args, 'n')) {
|
||||
window_set_name(w, args_get(args, 'n'));
|
||||
if (name != NULL) {
|
||||
window_set_name(w, name, 0);
|
||||
options_set_number(w->options, "automatic-rename", 0);
|
||||
}
|
||||
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) {
|
||||
cmdq_error(item, "index in use: %d", idx);
|
||||
@@ -93,32 +151,40 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
|
||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||
TAILQ_REMOVE(&w->z_index, wp, zentry);
|
||||
server_client_remove_pane(wp);
|
||||
window_lost_pane(w, wp);
|
||||
layout_close_pane(wp);
|
||||
|
||||
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);
|
||||
wp->flags |= PANE_STYLECHANGED;
|
||||
wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
|
||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
|
||||
w->active = wp;
|
||||
w->latest = tc;
|
||||
|
||||
if (!args_has(args, 'n')) {
|
||||
name = default_window_name(w);
|
||||
window_set_name(w, name);
|
||||
free(name);
|
||||
} else {
|
||||
window_set_name(w, args_get(args, 'n'));
|
||||
free(w->name);
|
||||
if (name == NULL)
|
||||
w->name = default_window_name(w);
|
||||
else {
|
||||
w->name = clean_name(name, 0);
|
||||
options_set_number(w->options, "automatic-rename", 0);
|
||||
}
|
||||
|
||||
layout_init(w, wp);
|
||||
wp->flags |= PANE_CHANGED;
|
||||
window_set_fill_cells(w);
|
||||
|
||||
if (idx == -1)
|
||||
idx = -1 - options_get_number(dst_s->options, "base-index");
|
||||
wl = session_attach(dst_s, w, idx, &cause); /* can't fail */
|
||||
|
||||
layout_init(w, wp);
|
||||
wp->flags |= PANE_CHANGED;
|
||||
colour_palette_from_option(&wp->palette, wp->options);
|
||||
|
||||
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')) {
|
||||
session_select(dst_s, wl->idx);
|
||||
cmd_find_from_session(current, dst_s, 0);
|
||||
@@ -131,6 +197,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (src_s != dst_s)
|
||||
server_status_session_group(dst_s);
|
||||
|
||||
out:
|
||||
if (args_has(args, 'P')) {
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = BREAK_PANE_TEMPLATE;
|
||||
|
||||
@@ -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>
|
||||
@@ -29,18 +29,21 @@
|
||||
|
||||
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 *,
|
||||
size_t *);
|
||||
static char *cmd_capture_pane_history(struct args *, struct cmdq_item *,
|
||||
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 = {
|
||||
.name = "capture-pane",
|
||||
.alias = "capturep",
|
||||
|
||||
.args = { "ab:CeE:JNpPqS:t:", 0, 0, NULL },
|
||||
.usage = "[-aCeJNpPq] " CMD_BUFFER_USAGE " [-E end-line] "
|
||||
.args = { "ab:CeE:FHJLMNpPqRS:Tt:", 0, 0, NULL },
|
||||
.usage = "[-aCeFHJLMNpPqRT] " CMD_BUFFER_USAGE " [-E end-line] "
|
||||
"[-S start-line] " CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
@@ -53,8 +56,8 @@ const struct cmd_entry cmd_clear_history_entry = {
|
||||
.name = "clear-history",
|
||||
.alias = "clearhist",
|
||||
|
||||
.args = { "t:", 0, 0, NULL },
|
||||
.usage = CMD_TARGET_PANE_USAGE,
|
||||
.args = { "Ht:", 0, 0, NULL },
|
||||
.usage = "[-H] " CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
@@ -63,7 +66,8 @@ const struct cmd_entry cmd_clear_history_entry = {
|
||||
};
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
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 *
|
||||
cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
||||
size_t *len)
|
||||
@@ -103,18 +209,62 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
||||
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 *
|
||||
cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
||||
struct window_pane *wp, size_t *len)
|
||||
{
|
||||
struct grid *gd;
|
||||
const struct grid_line *gl;
|
||||
struct grid_cell *gc = NULL;
|
||||
int n, with_codes, escape_c0, join_lines, no_trim;
|
||||
u_int i, sx, top, bottom, tmp;
|
||||
char *cause, *buf, *line;
|
||||
const char *Sflag, *Eflag;
|
||||
size_t linelen;
|
||||
struct grid *gd;
|
||||
const struct grid_line *gl;
|
||||
struct screen *s;
|
||||
struct grid_cell *gc = NULL;
|
||||
struct window_mode_entry *wme;
|
||||
int n, join_lines, number_lines, flags = 0;
|
||||
int show_flags, hyperlinks;
|
||||
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);
|
||||
if (args_has(args, 'a')) {
|
||||
@@ -126,18 +276,31 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Sflag = args_get(args, 'S');
|
||||
if (Sflag != NULL && strcmp(Sflag, "-") == 0)
|
||||
top = 0;
|
||||
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) {
|
||||
top = gd->hsize;
|
||||
free(cause);
|
||||
} else if (n < 0 && (u_int) -n > gd->hsize)
|
||||
} else if (n < 0 && (u_int)-n > gd->hsize)
|
||||
top = 0;
|
||||
else
|
||||
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)
|
||||
bottom = gd->hsize + gd->sy - 1;
|
||||
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) {
|
||||
bottom = gd->hsize + gd->sy - 1;
|
||||
free(cause);
|
||||
} else if (n < 0 && (u_int) -n > gd->hsize)
|
||||
} else if (n < 0 && (u_int)-n > gd->hsize)
|
||||
bottom = 0;
|
||||
else
|
||||
bottom = gd->hsize + n;
|
||||
@@ -167,17 +331,66 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
||||
top = tmp;
|
||||
}
|
||||
|
||||
with_codes = args_has(args, 'e');
|
||||
escape_c0 = args_has(args, 'C');
|
||||
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++) {
|
||||
line = grid_string_cells(gd, 0, i, sx, &gc, with_codes,
|
||||
escape_c0, !join_lines && !no_trim);
|
||||
linelen = strlen(line);
|
||||
if (hyperlinks) {
|
||||
line = cmd_capture_pane_hyperlinks(gd, s, i, links,
|
||||
&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);
|
||||
|
||||
gl = grid_peek_line(gd, i);
|
||||
@@ -186,6 +399,9 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
||||
|
||||
free(line);
|
||||
}
|
||||
free(links);
|
||||
if (buf == NULL)
|
||||
buf = xstrdup("");
|
||||
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) {
|
||||
window_pane_reset_mode_all(wp);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
else
|
||||
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(c, "\n");
|
||||
free(buf);
|
||||
}
|
||||
free(buf);
|
||||
} else {
|
||||
bufname = NULL;
|
||||
if (args_has(args, 'b'))
|
||||
|
||||
@@ -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>
|
||||
@@ -33,8 +33,8 @@ const struct cmd_entry cmd_choose_tree_entry = {
|
||||
.name = "choose-tree",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "F:f:GK:NO:rst:wZ", 0, 1, cmd_choose_tree_args_parse },
|
||||
.usage = "[-GNrswZ] [-F format] [-f filter] [-K key-format] "
|
||||
.args = { "F:f:GhK:kNO:rst:wyZ", 0, 1, cmd_choose_tree_args_parse },
|
||||
.usage = "[-GhkNrswZ] [-F format] [-f filter] [-K key-format] "
|
||||
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
@@ -47,8 +47,8 @@ const struct cmd_entry cmd_choose_client_entry = {
|
||||
.name = "choose-client",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "F:f:K:NO:rt:Z", 0, 1, cmd_choose_tree_args_parse },
|
||||
.usage = "[-NrZ] [-F format] [-f filter] [-K key-format] "
|
||||
.args = { "F:f:hiK:kNO:rt:yZ", 0, 1, cmd_choose_tree_args_parse },
|
||||
.usage = "[-hikNrZ] [-F format] [-f filter] [-K key-format] "
|
||||
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
@@ -61,8 +61,8 @@ const struct cmd_entry cmd_choose_buffer_entry = {
|
||||
.name = "choose-buffer",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "F:f:K:NO:rt:Z", 0, 1, cmd_choose_tree_args_parse },
|
||||
.usage = "[-NrZ] [-F format] [-f filter] [-K key-format] "
|
||||
.args = { "F:f:K:kNO:rt:yZ", 0, 1, cmd_choose_tree_args_parse },
|
||||
.usage = "[-kNrZ] [-F format] [-f filter] [-K key-format] "
|
||||
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
@@ -75,8 +75,8 @@ const struct cmd_entry cmd_customize_mode_entry = {
|
||||
.name = "customize-mode",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "F:f:Nt:Z", 0, 0, NULL },
|
||||
.usage = "[-NZ] [-F format] [-f filter] " CMD_TARGET_PANE_USAGE,
|
||||
.args = { "F:f:kNt:yZ", 0, 0, NULL },
|
||||
.usage = "[-kNZ] [-F format] [-f filter] " CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
@@ -84,6 +84,34 @@ const struct cmd_entry cmd_customize_mode_entry = {
|
||||
.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)
|
||||
@@ -98,9 +126,16 @@ cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct window_pane *wp = target->wp;
|
||||
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 (paste_get_top(NULL) == NULL)
|
||||
if (paste_is_empty())
|
||||
return (CMD_RETURN_NORMAL);
|
||||
mode = &window_buffer_mode;
|
||||
} else if (cmd_get_entry(self) == &cmd_choose_client_entry) {
|
||||
@@ -109,9 +144,13 @@ cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
|
||||
mode = &window_client_mode;
|
||||
} else if (cmd_get_entry(self) == &cmd_customize_mode_entry)
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -34,17 +34,17 @@ static enum args_parse_type cmd_command_prompt_args_parse(struct args *,
|
||||
static enum cmd_retval cmd_command_prompt_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
static int cmd_command_prompt_callback(struct client *, void *,
|
||||
const char *, int);
|
||||
static enum prompt_result cmd_command_prompt_callback(struct client *, void *,
|
||||
const char *, enum prompt_key_result);
|
||||
static void cmd_command_prompt_free(void *);
|
||||
|
||||
const struct cmd_entry cmd_command_prompt_entry = {
|
||||
.name = "command-prompt",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "1bFkiI:Np:t:T:", 0, 1, cmd_command_prompt_args_parse },
|
||||
.usage = "[-1bFkiN] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE
|
||||
" [-T type] [template]",
|
||||
.args = { "1CbeFiklI:NPp:t:T:", 0, 1, cmd_command_prompt_args_parse },
|
||||
.usage = "[-1CbeFiklNP] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE
|
||||
" [-T prompt-type] [template]",
|
||||
|
||||
.flags = CMD_CLIENT_TFLAG,
|
||||
.exec = cmd_command_prompt_exec
|
||||
@@ -62,6 +62,8 @@ struct cmd_command_prompt_cdata {
|
||||
int flags;
|
||||
enum prompt_type prompt_type;
|
||||
|
||||
struct window_pane *wp;
|
||||
|
||||
struct cmd_command_prompt_prompt *prompts;
|
||||
u_int count;
|
||||
u_int current;
|
||||
@@ -84,13 +86,18 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
const char *type, *s, *input;
|
||||
struct cmd_command_prompt_cdata *cdata;
|
||||
struct cmd_command_prompt_cdata *cdata;
|
||||
char *tmp, *prompts, *prompt, *next_prompt;
|
||||
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);
|
||||
if (args_has(args, 'i'))
|
||||
wait = 0;
|
||||
@@ -98,6 +105,8 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
|
||||
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'));
|
||||
|
||||
@@ -117,32 +126,39 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
|
||||
next_input = inputs = xstrdup(s);
|
||||
else
|
||||
next_input = NULL;
|
||||
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;
|
||||
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;
|
||||
|
||||
if (next_input != NULL) {
|
||||
input = strsep(&next_input, ",");
|
||||
if (input == NULL)
|
||||
if (next_input != NULL) {
|
||||
input = strsep(&next_input, ",");
|
||||
if (input == NULL)
|
||||
input = "";
|
||||
} else
|
||||
input = "";
|
||||
} else
|
||||
input = "";
|
||||
cdata->prompts[cdata->count].input = xstrdup(input);
|
||||
|
||||
cdata->count++;
|
||||
cdata->prompts[cdata->count].input = xstrdup(input);
|
||||
cdata->count++;
|
||||
}
|
||||
free(inputs);
|
||||
free(prompts);
|
||||
}
|
||||
free(inputs);
|
||||
free(prompts);
|
||||
|
||||
if ((type = args_get(args, 'T')) != NULL) {
|
||||
cdata->prompt_type = status_prompt_type(type);
|
||||
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
|
||||
@@ -156,18 +172,31 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
|
||||
cdata->flags |= PROMPT_INCREMENTAL;
|
||||
else if (args_has(args, 'k'))
|
||||
cdata->flags |= PROMPT_KEY;
|
||||
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);
|
||||
else if (args_has(args, 'e'))
|
||||
cdata->flags |= PROMPT_BSPACE_EXIT;
|
||||
if (args_has(args, 'C'))
|
||||
cdata->flags |= PROMPT_NOFREEZE;
|
||||
if (pane) {
|
||||
cdata->flags |= PROMPT_ISPANE;
|
||||
window_pane_set_prompt(wp, tc, target, cdata->prompts[0].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);
|
||||
}
|
||||
|
||||
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,
|
||||
int done)
|
||||
enum prompt_key_result key)
|
||||
{
|
||||
struct cmd_command_prompt_cdata *cdata = data;
|
||||
char *error;
|
||||
@@ -177,24 +206,31 @@ cmd_command_prompt_callback(struct client *c, void *data, const char *s,
|
||||
int argc = 0;
|
||||
char **argv = NULL;
|
||||
|
||||
if (s == NULL)
|
||||
if (s == NULL || key == PROMPT_KEY_MOVE)
|
||||
goto out;
|
||||
if (done) {
|
||||
|
||||
if (key == PROMPT_KEY_CLOSE) {
|
||||
if (cdata->flags & PROMPT_INCREMENTAL)
|
||||
goto out;
|
||||
|
||||
cmd_append_argv(&cdata->argc, &cdata->argv, s);
|
||||
if (++cdata->current != cdata->count) {
|
||||
prompt = &cdata->prompts[cdata->current];
|
||||
status_prompt_update(c, prompt->prompt, prompt->input);
|
||||
return (1);
|
||||
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;
|
||||
argv = cmd_copy_argv(cdata->argc, cdata->argv);
|
||||
cmd_append_argv(&argc, &argv, s);
|
||||
if (done) {
|
||||
if (key != PROMPT_KEY_CLOSE)
|
||||
cmd_append_argv(&argc, &argv, s);
|
||||
else {
|
||||
cmd_free_argv(cdata->argc, cdata->argv);
|
||||
cdata->argc = argc;
|
||||
cdata->argv = cmd_copy_argv(argc, argv);
|
||||
}
|
||||
@@ -212,21 +248,33 @@ cmd_command_prompt_callback(struct client *c, void *data, const char *s,
|
||||
}
|
||||
cmd_free_argv(argc, argv);
|
||||
|
||||
if (c->prompt_inputcb != cmd_command_prompt_callback)
|
||||
return (1);
|
||||
/*
|
||||
* An incremental prompt fires its callback on every edit but must stay
|
||||
* open for further typing; only an explicit close (handled above) ends
|
||||
* it.
|
||||
*/
|
||||
if (cdata->flags & PROMPT_INCREMENTAL)
|
||||
return (PROMPT_CONTINUE);
|
||||
|
||||
out:
|
||||
if (item != NULL)
|
||||
if (item != NULL) {
|
||||
cdata->item = NULL;
|
||||
cmdq_continue(item);
|
||||
return (0);
|
||||
}
|
||||
return (PROMPT_CLOSE);
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_command_prompt_free(void *data)
|
||||
{
|
||||
struct cmd_command_prompt_cdata *cdata = data;
|
||||
struct cmd_command_prompt_cdata *cdata = data;
|
||||
u_int i;
|
||||
|
||||
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);
|
||||
|
||||
@@ -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>
|
||||
@@ -33,16 +33,17 @@ static enum args_parse_type cmd_confirm_before_args_parse(struct args *,
|
||||
static enum cmd_retval cmd_confirm_before_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
static int cmd_confirm_before_callback(struct client *, void *,
|
||||
const char *, int);
|
||||
static enum prompt_result cmd_confirm_before_callback(struct client *, void *,
|
||||
const char *, enum prompt_key_result);
|
||||
static void cmd_confirm_before_free(void *);
|
||||
|
||||
const struct cmd_entry cmd_confirm_before_entry = {
|
||||
.name = "confirm-before",
|
||||
.alias = "confirm",
|
||||
|
||||
.args = { "bp:t:", 1, 1, cmd_confirm_before_args_parse },
|
||||
.usage = "[-b] [-p prompt] " CMD_TARGET_CLIENT_USAGE " command",
|
||||
.args = { "bc:p:t:y", 1, 1, cmd_confirm_before_args_parse },
|
||||
.usage = "[-by] [-c confirm-key] [-p prompt] " CMD_TARGET_CLIENT_USAGE
|
||||
" command",
|
||||
|
||||
.flags = CMD_CLIENT_TFLAG,
|
||||
.exec = cmd_confirm_before_exec
|
||||
@@ -51,6 +52,8 @@ const struct cmd_entry cmd_confirm_before_entry = {
|
||||
struct cmd_confirm_before_data {
|
||||
struct cmdq_item *item;
|
||||
struct cmd_list *cmdlist;
|
||||
u_char confirm_key;
|
||||
int default_yes;
|
||||
};
|
||||
|
||||
static enum args_parse_type
|
||||
@@ -68,22 +71,41 @@ cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
char *new_prompt;
|
||||
const char *prompt, *cmd;
|
||||
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)
|
||||
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)
|
||||
xasprintf(&new_prompt, "%s ", prompt);
|
||||
else {
|
||||
cmd = cmd_get_entry(cmd_list_first(cdata->cmdlist))->name;
|
||||
xasprintf(&new_prompt, "Confirm '%s'? (y/n) ", cmd);
|
||||
xasprintf(&new_prompt, "Confirm '%s'? (%c/n) ", cmd,
|
||||
cdata->confirm_key);
|
||||
}
|
||||
|
||||
status_prompt_set(tc, target, new_prompt, NULL,
|
||||
@@ -96,9 +118,9 @@ cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
|
||||
static int
|
||||
static enum prompt_result
|
||||
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 cmdq_item *item = cdata->item, *new_item;
|
||||
@@ -107,9 +129,9 @@ cmd_confirm_before_callback(struct client *c, void *data, const char *s,
|
||||
if (c->flags & CLIENT_DEAD)
|
||||
goto out;
|
||||
|
||||
if (s == NULL || *s == '\0')
|
||||
if (s == NULL)
|
||||
goto out;
|
||||
if (tolower((u_char)s[0]) != 'y' || s[1] != '\0')
|
||||
if (s[0] != cdata->confirm_key && (s[0] != '\r' || !cdata->default_yes))
|
||||
goto out;
|
||||
retcode = 0;
|
||||
|
||||
@@ -123,13 +145,13 @@ cmd_confirm_before_callback(struct client *c, void *data, const char *s,
|
||||
}
|
||||
|
||||
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 (0);
|
||||
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
|
||||
|
||||
@@ -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>
|
||||
@@ -30,13 +30,13 @@ const struct cmd_entry cmd_copy_mode_entry = {
|
||||
.name = "copy-mode",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "eHMs:t:uq", 0, 0, NULL },
|
||||
.usage = "[-eHMuq] [-s src-pane] " CMD_TARGET_PANE_USAGE,
|
||||
.args = { "dekHMqSs:t:u", 0, 0, NULL },
|
||||
.usage = "[-dekHMqSu] [-s src-pane] " CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.source = { 's', CMD_FIND_PANE, 0 },
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.flags = CMD_AFTERHOOK|CMD_READONLY,
|
||||
.exec = cmd_copy_mode_exec
|
||||
};
|
||||
|
||||
@@ -63,6 +63,8 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct client *c = cmdq_get_client(item);
|
||||
struct session *s;
|
||||
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')) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -85,12 +88,26 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
|
||||
swp = source->wp;
|
||||
else
|
||||
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'))
|
||||
window_copy_start_drag(c, &event->m);
|
||||
}
|
||||
} else
|
||||
window_copy_set_line_numbers(wp, line_numbers);
|
||||
if (args_has(args, 'u'))
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -59,6 +59,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
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 session *s;
|
||||
enum msgtype msgtype;
|
||||
@@ -69,6 +70,13 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
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'))
|
||||
msgtype = MSG_DETACHKILL;
|
||||
else
|
||||
|
||||
@@ -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>
|
||||
@@ -38,9 +38,11 @@ const struct cmd_entry cmd_display_menu_entry = {
|
||||
.name = "display-menu",
|
||||
.alias = "menu",
|
||||
|
||||
.args = { "c:t:OT:x:y:", 1, -1, cmd_display_menu_args_parse },
|
||||
.usage = "[-O] [-c target-client] " CMD_TARGET_PANE_USAGE " [-T title] "
|
||||
"[-x position] [-y position] name key command ...",
|
||||
.args = { "b:c:C:H:s:S:MOt:T:x:y:", 1, -1, cmd_display_menu_args_parse },
|
||||
.usage = "[-MO] [-b border-lines] [-c target-client] "
|
||||
"[-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 },
|
||||
|
||||
@@ -52,12 +54,12 @@ const struct cmd_entry cmd_display_popup_entry = {
|
||||
.name = "display-popup",
|
||||
.alias = "popup",
|
||||
|
||||
.args = { "Bb:Cc:d:e:Eh:s:S:t:T:w:x:y:", 0, -1, NULL },
|
||||
.usage = "[-BCE] [-b border-lines] [-c target-client] "
|
||||
.args = { "Bb:Cc:d:e:Eh:kNs:S:t:T:w:x:y:", 0, -1, NULL },
|
||||
.usage = "[-BCEkN] [-b border-lines] [-c target-client] "
|
||||
"[-d start-directory] [-e environment] [-h height] "
|
||||
"[-s style] [-S border-style] " CMD_TARGET_PANE_USAGE
|
||||
"[-T title] [-w width] [-x position] [-y position] "
|
||||
"[shell-command]",
|
||||
" [-T title] [-w width] [-x position] [-y position] "
|
||||
"[shell-command [argument ...]]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
@@ -90,7 +92,7 @@ cmd_display_menu_args_parse(struct args *args, u_int idx, __unused char **cause)
|
||||
}
|
||||
|
||||
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 tty *tty = &tc->tty;
|
||||
@@ -124,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);
|
||||
}
|
||||
|
||||
/* 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
|
||||
* status line position.
|
||||
@@ -236,6 +242,8 @@ cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
|
||||
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);
|
||||
@@ -256,6 +264,8 @@ cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
|
||||
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)
|
||||
@@ -274,6 +284,185 @@ cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
|
||||
log_debug("%s: -y: %s = %s = %u (-h %u)", __func__, yp, p, *py, h);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -286,19 +475,36 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct menu *menu = NULL;
|
||||
struct menu_item menu_item;
|
||||
const char *key, *name;
|
||||
char *title;
|
||||
int flags = 0;
|
||||
const char *key, *name, *value;
|
||||
const char *style = args_get(args, 's');
|
||||
const char *border_style = args_get(args, 'S');
|
||||
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)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
if (args_has(args, 'C')) {
|
||||
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'))
|
||||
title = format_single_from_target(item, args_get(args, 'T'));
|
||||
else
|
||||
title = xstrdup("");
|
||||
menu = menu_create(title);
|
||||
free(title);
|
||||
|
||||
for (i = 0; i != count; /* nothing */) {
|
||||
name = args_string(args, i++);
|
||||
@@ -309,9 +515,7 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
if (count - i < 2) {
|
||||
cmdq_error(item, "not enough arguments");
|
||||
free(title);
|
||||
menu_free(menu);
|
||||
return (CMD_RETURN_ERROR);
|
||||
goto fail;
|
||||
}
|
||||
key = args_string(args, i++);
|
||||
|
||||
@@ -321,29 +525,44 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
menu_add_item(menu, &menu_item, item, tc, target);
|
||||
}
|
||||
free(title);
|
||||
if (menu == NULL) {
|
||||
cmdq_error(item, "invalid menu arguments");
|
||||
return (CMD_RETURN_ERROR);
|
||||
goto fail;
|
||||
}
|
||||
if (menu->count == 0) {
|
||||
menu_free(menu);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
if (!cmd_display_menu_get_position(tc, item, args, &px, &py,
|
||||
menu->width + 4, menu->count + 2)) {
|
||||
menu_free(menu);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
if (menu->count == 0)
|
||||
goto out;
|
||||
if (!cmd_display_menu_get_menu_pos(tc, item, args, &px, &py,
|
||||
menu->width + 4, menu->count + 2))
|
||||
goto out;
|
||||
|
||||
value = args_get(args, 'b');
|
||||
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'))
|
||||
flags |= MENU_STAYOPEN;
|
||||
if (!event->m.valid)
|
||||
if (!event->m.valid && !args_has(args, 'M'))
|
||||
flags |= MENU_NOMOUSE;
|
||||
if (menu_display(menu, flags, item, px, py, tc, target, NULL,
|
||||
NULL) != 0)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
return (CMD_RETURN_WAIT);
|
||||
if (menu_display(menu, flags, starting_choice, item, px, py, tc, lines,
|
||||
style, selected_style, border_style, target, NULL, NULL) != 0)
|
||||
goto out;
|
||||
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
|
||||
@@ -357,8 +576,10 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
const char *value, *shell, *shellcmd = NULL;
|
||||
const char *style = args_get(args, 's');
|
||||
const char *border_style = args_get(args, 'S');
|
||||
char *cwd, *cause = NULL, **argv = NULL, *title;
|
||||
int flags = 0, argc = 0;
|
||||
char *cwd = NULL, *cause = NULL, **argv = NULL;
|
||||
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;
|
||||
@@ -370,36 +591,67 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
server_client_clear_overlay(tc);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
if (tc->overlay_draw != NULL)
|
||||
if (!modify && tc->overlay_draw != NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
h = tty->sy / 2;
|
||||
if (args_has(args, 'h')) {
|
||||
h = args_percentage(args, 'h', 1, tty->sy, tty->sy, &cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "height %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
if (!modify) {
|
||||
h = tty->sy / 2;
|
||||
if (args_has(args, 'h')) {
|
||||
h = args_percentage(args, 'h', 1, tty->sy, tty->sy,
|
||||
&cause);
|
||||
if (cause != NULL) {
|
||||
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;
|
||||
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);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
if (w > tty->sx)
|
||||
w = tty->sx;
|
||||
if (h > tty->sy)
|
||||
h = tty->sy;
|
||||
if (!cmd_display_menu_get_position(tc, item, args, &px, &py, w, h))
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
value = args_get(args, 'b');
|
||||
if (args_has(args, 'B'))
|
||||
lines = BOX_LINES_NONE;
|
||||
@@ -409,35 +661,7 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
&cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "popup-border-lines %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,21 +669,49 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
title = format_single_from_target(item, args_get(args, 'T'));
|
||||
else
|
||||
title = xstrdup("");
|
||||
if (args_has(args, 'E') > 1)
|
||||
|
||||
if (args_has(args, 'N') || !modify)
|
||||
flags = 0;
|
||||
if (args_has(args, 'E') > 1) {
|
||||
if (flags == -1)
|
||||
flags = 0;
|
||||
flags |= POPUP_CLOSEEXITZERO;
|
||||
else if (args_has(args, 'E'))
|
||||
} else if (args_has(args, 'E')) {
|
||||
if (flags == -1)
|
||||
flags = 0;
|
||||
flags |= POPUP_CLOSEEXIT;
|
||||
if (popup_display(flags, lines, item, px, py, w, h, env, shellcmd, argc,
|
||||
argv, cwd, title, tc, s, style, border_style, NULL, NULL) != 0) {
|
||||
cmd_free_argv(argc, argv);
|
||||
if (env != NULL)
|
||||
environ_free(env);
|
||||
free(title);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
if (env != NULL)
|
||||
environ_free(env);
|
||||
if (args_has(args, 'k')) {
|
||||
if (flags == -1)
|
||||
flags = 0;
|
||||
flags |= POPUP_CLOSEANYKEY;
|
||||
}
|
||||
|
||||
if (modify) {
|
||||
popup_modify(tc, title, style, border_style, lines, flags);
|
||||
goto out;
|
||||
}
|
||||
if (popup_display(flags, lines, item, px, py, w, h, env, shellcmd, argc,
|
||||
argv, cwd, title, tc, s, style, border_style, NULL, NULL) != 0)
|
||||
goto out;
|
||||
environ_free(env);
|
||||
free(cwd);
|
||||
free(title);
|
||||
cmd_free_argv(argc, argv);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -39,8 +39,8 @@ const struct cmd_entry cmd_display_message_entry = {
|
||||
.name = "display-message",
|
||||
.alias = "display",
|
||||
|
||||
.args = { "ac:d:INpt:F:v", 0, 1, NULL },
|
||||
.usage = "[-aINpv] [-c target-client] [-d delay] [-F format] "
|
||||
.args = { "aCc:d:lINpt:F:v", 0, 1, NULL },
|
||||
.usage = "[-aCIlNpv] [-c target-client] [-d delay] [-F format] "
|
||||
CMD_TARGET_PANE_USAGE " [message]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||
@@ -68,9 +68,11 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct window_pane *wp = target->wp;
|
||||
const char *template;
|
||||
char *msg, *cause;
|
||||
int delay = -1, flags;
|
||||
int delay = -1, flags, Nflag = args_has(args, 'N');
|
||||
int Cflag = args_has(args, 'C');
|
||||
struct format_tree *ft;
|
||||
u_int count = args_count(args);
|
||||
struct evbuffer *evb;
|
||||
|
||||
if (args_has(args, 'I')) {
|
||||
if (wp == NULL)
|
||||
@@ -129,21 +131,30 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
if (args_has(args, 'a')) {
|
||||
format_each(ft, cmd_display_message_each, item);
|
||||
format_free(ft);
|
||||
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)
|
||||
cmdq_error(item, "%s", msg);
|
||||
else if (args_has(args, 'p'))
|
||||
cmdq_print(item, "%s", msg);
|
||||
else if (tc != NULL) {
|
||||
status_message_set(tc, delay, 0, args_has(args, 'N'), "%s",
|
||||
msg);
|
||||
}
|
||||
else if (tc != NULL && (tc->flags & CLIENT_CONTROL)) {
|
||||
evb = evbuffer_new();
|
||||
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);
|
||||
|
||||
format_free(ft);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,312 +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 args_parse_type cmd_display_panes_args_parse(struct args *,
|
||||
u_int, char **);
|
||||
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, cmd_display_panes_args_parse },
|
||||
.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;
|
||||
struct args_command_state *state;
|
||||
};
|
||||
|
||||
static enum args_parse_type
|
||||
cmd_display_panes_args_parse(__unused struct args *args, __unused u_int idx,
|
||||
__unused char **cause)
|
||||
{
|
||||
return (ARGS_PARSE_COMMANDS_OR_STRING);
|
||||
}
|
||||
|
||||
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, __unused void *data,
|
||||
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(__unused struct client *c, void *data)
|
||||
{
|
||||
struct cmd_display_panes_data *cdata = data;
|
||||
|
||||
if (cdata->item != NULL)
|
||||
cmdq_continue(cdata->item);
|
||||
args_make_commands_free(cdata->state);
|
||||
free(cdata);
|
||||
}
|
||||
|
||||
static int
|
||||
cmd_display_panes_key(struct client *c, void *data, struct key_event *event)
|
||||
{
|
||||
struct cmd_display_panes_data *cdata = data;
|
||||
char *expanded, *error;
|
||||
struct cmdq_item *item = cdata->item, *new_item;
|
||||
struct cmd_list *cmdlist;
|
||||
struct window *w = c->session->curw->window;
|
||||
struct window_pane *wp;
|
||||
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);
|
||||
|
||||
cmdlist = args_make_commands(cdata->state, 1, &expanded, &error);
|
||||
if (cmdlist == NULL) {
|
||||
cmdq_append(c, cmdq_get_error(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);
|
||||
}
|
||||
|
||||
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;
|
||||
int wait = !args_has(args, 'b');
|
||||
|
||||
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 = xcalloc(1, sizeof *cdata);
|
||||
if (wait)
|
||||
cdata->item = item;
|
||||
cdata->state = args_make_commands_prepare(self, item, 0,
|
||||
"select-pane -t \"%%%\"", wait, 0);
|
||||
|
||||
if (args_has(args, 'N')) {
|
||||
server_client_set_overlay(tc, delay, NULL, NULL,
|
||||
cmd_display_panes_draw, NULL, cmd_display_panes_free, NULL,
|
||||
cdata);
|
||||
} else {
|
||||
server_client_set_overlay(tc, delay, NULL, NULL,
|
||||
cmd_display_panes_draw, cmd_display_panes_key,
|
||||
cmd_display_panes_free, NULL, cdata);
|
||||
}
|
||||
|
||||
if (!wait)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
@@ -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>
|
||||
@@ -48,6 +48,7 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct window_pane *wp = target->wp;
|
||||
const char *s = args_string(args, 0), *suffix = "";
|
||||
const char *star = "*";
|
||||
struct args_value *filter;
|
||||
int C, N, T;
|
||||
|
||||
@@ -55,6 +56,8 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
N = args_has(args, 'N');
|
||||
T = args_has(args, 'T');
|
||||
|
||||
if (args_has(args, 'r'))
|
||||
star = "";
|
||||
if (args_has(args, 'r') && args_has(args, 'i'))
|
||||
suffix = "/ri";
|
||||
else if (args_has(args, 'r'))
|
||||
@@ -71,42 +74,43 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (C && N && T) {
|
||||
xasprintf(&filter->string,
|
||||
"#{||:"
|
||||
"#{C%s:%s},#{||:#{m%s:*%s*,#{window_name}},"
|
||||
"#{m%s:*%s*,#{pane_title}}}}",
|
||||
suffix, s, suffix, s, suffix, s);
|
||||
"#{C%s:%s},#{||:#{m%s:%s%s%s,#{window_name}},"
|
||||
"#{m%s:%s%s%s,#{pane_title}}}}",
|
||||
suffix, s, suffix, star, s, star, suffix, star, s, star);
|
||||
} else if (C && N) {
|
||||
xasprintf(&filter->string,
|
||||
"#{||:#{C%s:%s},#{m%s:*%s*,#{window_name}}}",
|
||||
suffix, s, suffix, s);
|
||||
"#{||:#{C%s:%s},#{m%s:%s%s%s,#{window_name}}}",
|
||||
suffix, s, suffix, star, s, star);
|
||||
} else if (C && T) {
|
||||
xasprintf(&filter->string,
|
||||
"#{||:#{C%s:%s},#{m%s:*%s*,#{pane_title}}}",
|
||||
suffix, s, suffix, s);
|
||||
"#{||:#{C%s:%s},#{m%s:%s%s%s,#{pane_title}}}",
|
||||
suffix, s, suffix, star, s, star);
|
||||
} else if (N && T) {
|
||||
xasprintf(&filter->string,
|
||||
"#{||:#{m%s:*%s*,#{window_name}},"
|
||||
"#{m%s:*%s*,#{pane_title}}}",
|
||||
suffix, s, suffix, s);
|
||||
"#{||:#{m%s:%s%s%s,#{window_name}},"
|
||||
"#{m%s:%s%s%s,#{pane_title}}}",
|
||||
suffix, star, s, star, suffix, star, s, star);
|
||||
} else if (C) {
|
||||
xasprintf(&filter->string,
|
||||
"#{C%s:%s}",
|
||||
suffix, s);
|
||||
} else if (N) {
|
||||
xasprintf(&filter->string,
|
||||
"#{m%s:*%s*,#{window_name}}",
|
||||
suffix, s);
|
||||
"#{m%s:%s%s%s,#{window_name}}",
|
||||
suffix, star, s, star);
|
||||
} else {
|
||||
xasprintf(&filter->string,
|
||||
"#{m%s:*%s*,#{pane_title}}",
|
||||
suffix, s);
|
||||
"#{m%s:%s%s%s,#{pane_title}}",
|
||||
suffix, star, s, star);
|
||||
}
|
||||
|
||||
new_args = args_create();
|
||||
if (args_has(args, 'Z'))
|
||||
args_set(new_args, 'Z', NULL);
|
||||
args_set(new_args, 'f', filter);
|
||||
args_set(new_args, 'Z', NULL, 0);
|
||||
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);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
47
cmd-find.c
47
cmd-find.c
@@ -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>
|
||||
@@ -147,6 +147,18 @@ cmd_find_session_better(struct session *s, struct session *than, int flags)
|
||||
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. */
|
||||
static struct session *
|
||||
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;
|
||||
if (slist != NULL) {
|
||||
for (i = 0; i < ssize; i++) {
|
||||
if (!cmd_find_session_valid(slist[i]))
|
||||
continue;
|
||||
if (cmd_find_session_better(slist[i], s, flags))
|
||||
s = slist[i];
|
||||
}
|
||||
} else {
|
||||
RB_FOREACH(s_loop, sessions, &sessions) {
|
||||
if (!cmd_find_session_valid(s_loop))
|
||||
continue;
|
||||
if (cmd_find_session_better(s_loop, s, flags))
|
||||
s = s_loop;
|
||||
}
|
||||
@@ -582,27 +598,27 @@ cmd_find_get_pane_with_window(struct cmd_find_state *fs, const char *pane)
|
||||
|
||||
/* Try special characters. */
|
||||
if (strcmp(pane, "!") == 0) {
|
||||
fs->wp = fs->w->last;
|
||||
fs->wp = TAILQ_FIRST(&fs->w->last_panes);
|
||||
if (fs->wp == NULL)
|
||||
return (-1);
|
||||
return (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)
|
||||
return (-1);
|
||||
return (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)
|
||||
return (-1);
|
||||
return (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)
|
||||
return (-1);
|
||||
return (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)
|
||||
return (-1);
|
||||
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);
|
||||
else
|
||||
n = 1;
|
||||
wp = fs->current->wp;
|
||||
wp = fs->w->active;
|
||||
if (pane[0] == '+')
|
||||
fs->wp = window_pane_next_by_number(fs->w, wp, n);
|
||||
else
|
||||
@@ -868,7 +884,7 @@ cmd_find_from_client(struct cmd_find_state *fs, struct client *c, int flags)
|
||||
if (c->session != NULL) {
|
||||
cmd_find_clear_state(fs, flags);
|
||||
|
||||
fs->wp = server_client_get_pane(c);
|
||||
fs->wp = c->session->curw->window->active;
|
||||
if (fs->wp == NULL) {
|
||||
cmd_find_from_session(fs, c->session, flags);
|
||||
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)
|
||||
{
|
||||
struct mouse_event *m;
|
||||
struct client *c;
|
||||
struct cmd_find_state current;
|
||||
char *colon, *period, *copy = NULL, tmp[256];
|
||||
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')
|
||||
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}. */
|
||||
if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) {
|
||||
m = &cmdq_get_event(item)->m;
|
||||
|
||||
@@ -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>
|
||||
@@ -124,7 +124,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
-1) == NULL) {
|
||||
cmdq_error(item, "failed to run command: %s", shellcmd);
|
||||
free(shellcmd);
|
||||
free(cdata);
|
||||
cmd_if_shell_free(cdata);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
free(shellcmd);
|
||||
@@ -157,7 +157,7 @@ cmd_if_shell_callback(struct job *job)
|
||||
if (cmdlist == NULL) {
|
||||
if (cdata->item == NULL) {
|
||||
*error = toupper((u_char)*error);
|
||||
status_message_set(c, -1, 1, 0, "%s", error);
|
||||
status_message_set(c, -1, 1, 0, 0, "%s", error);
|
||||
} else
|
||||
cmdq_error(cdata->item, "%s", error);
|
||||
free(error);
|
||||
|
||||
446
cmd-join-pane.c
446
cmd-join-pane.c
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD$ */
|
||||
/* $OpenBSD: cmd-join-pane.c,v 1.74 2026/08/03 20:29:52 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011 George Nachman <tmux@georgester.com>
|
||||
@@ -30,6 +30,9 @@
|
||||
*/
|
||||
|
||||
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 = {
|
||||
.name = "join-pane",
|
||||
@@ -49,8 +52,10 @@ const struct cmd_entry cmd_move_pane_entry = {
|
||||
.name = "move-pane",
|
||||
.alias = "movep",
|
||||
|
||||
.args = { "bdfhvp:l:s:t:", 0, 0, NULL },
|
||||
.usage = "[-bdfhv] [-l size] " CMD_SRCDST_PANE_USAGE,
|
||||
.args = { "bdD::fhMvl:L::P:R::s:t:U::X:Y:z:", 0, 0, NULL },
|
||||
.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 },
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
@@ -59,6 +64,348 @@ const struct cmd_entry cmd_move_pane_entry = {
|
||||
.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
|
||||
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 window *src_w, *dst_w;
|
||||
struct window_pane *src_wp, *dst_wp;
|
||||
const char *s;
|
||||
char *cause = NULL;
|
||||
int size, percentage, dst_idx;
|
||||
int flags;
|
||||
enum layout_type type;
|
||||
int flags = 0, dst_idx;
|
||||
struct layout_cell *lc;
|
||||
|
||||
dst_s = target->s;
|
||||
@@ -81,55 +427,61 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
dst_wp = target->wp;
|
||||
dst_w = dst_wl->window;
|
||||
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 (args_has(args, 'P') ||
|
||||
args_has(args, 'z') ||
|
||||
args_has(args, 'X') ||
|
||||
args_has(args, 'Y') ||
|
||||
args_has(args, 'U') ||
|
||||
args_has(args, 'D') ||
|
||||
args_has(args, 'L') ||
|
||||
args_has(args, 'R')) {
|
||||
if (!window_pane_is_floating(dst_wp)) {
|
||||
cmdq_error(item, "pane is not floating");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
server_unzoom_window(dst_w);
|
||||
if ((s = args_get(args, 'P')) != NULL)
|
||||
return (cmd_join_pane_place(item, dst_wl, dst_wp, s));
|
||||
if ((s = args_get(args, 'z')) != NULL)
|
||||
return (cmd_join_pane_zindex(item, dst_wl, dst_wp, s));
|
||||
return (cmd_join_pane_move(item, args, dst_wl, dst_wp));
|
||||
}
|
||||
}
|
||||
|
||||
src_wl = source->wl;
|
||||
src_wp = source->wp;
|
||||
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);
|
||||
|
||||
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");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
type = LAYOUT_TOPBOTTOM;
|
||||
if (args_has(args, 'h'))
|
||||
type = LAYOUT_LEFTRIGHT;
|
||||
|
||||
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;
|
||||
flags |= SPAWN_HORIZONTAL;
|
||||
if (args_has(args, 'b'))
|
||||
flags |= SPAWN_BEFORE;
|
||||
if (args_has(args, 'f'))
|
||||
flags |= SPAWN_FULLSIZE;
|
||||
|
||||
lc = layout_split_pane(dst_wp, type, size, flags);
|
||||
if (lc == NULL) {
|
||||
cmdq_error(item, "create pane failed: pane too small");
|
||||
lc = layout_get_tiled_cell(item, args, dst_w, dst_wp, flags, &cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "size or position %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
@@ -138,15 +490,20 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
server_client_remove_pane(src_wp);
|
||||
window_lost_pane(src_w, src_wp);
|
||||
TAILQ_REMOVE(&src_w->panes, src_wp, entry);
|
||||
TAILQ_REMOVE(&src_w->z_index, src_wp, zentry);
|
||||
|
||||
src_wp->window = dst_w;
|
||||
options_set_parent(src_wp->options, dst_w->options);
|
||||
src_wp->flags |= PANE_STYLECHANGED;
|
||||
if (flags & SPAWN_BEFORE)
|
||||
src_wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
|
||||
if (flags & SPAWN_BEFORE) {
|
||||
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->z_index, dst_wp, src_wp, zentry);
|
||||
}
|
||||
layout_assign_pane(lc, src_wp, 0);
|
||||
colour_palette_from_option(&src_wp->palette, src_wp->options);
|
||||
|
||||
recalculate_sizes();
|
||||
|
||||
@@ -161,11 +518,12 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
} else
|
||||
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);
|
||||
else
|
||||
notify_window("window-layout-changed", src_w);
|
||||
notify_window("window-layout-changed", dst_w);
|
||||
events_fire_window("window-layout-changed", src_w);
|
||||
events_fire_window("window-layout-changed", dst_w);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -27,13 +27,17 @@
|
||||
*/
|
||||
|
||||
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 = {
|
||||
.name = "kill-pane",
|
||||
.alias = "killp",
|
||||
|
||||
.args = { "at:", 0, 0, NULL },
|
||||
.usage = "[-a] " CMD_TARGET_PANE_USAGE,
|
||||
.args = { "af:t:", 0, 0, NULL },
|
||||
.usage = "[-a] [-f filter] " CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.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 cmd_find_state *target = cmdq_get_target(item);
|
||||
struct winlink *wl = target->wl;
|
||||
struct window_pane *loopwp, *tmpwp, *wp = target->wp;
|
||||
struct window_pane *wp = target->wp;
|
||||
const char *filter = args_get(args, 'f');
|
||||
|
||||
if (args_has(args, 'a')) {
|
||||
server_unzoom_window(wl->window);
|
||||
TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) {
|
||||
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 (filter != NULL && !args_has(args, 'a')) {
|
||||
cmdq_error(item, "-f only valid with -a");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.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_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 = {
|
||||
.name = "kill-session",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "aCt:", 0, 0, NULL },
|
||||
.usage = "[-aC] " CMD_TARGET_SESSION_USAGE,
|
||||
.args = { "aCgf:t:", 0, 0, NULL },
|
||||
.usage = "[-aCg] [-f filter] " CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.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 cmd_find_state *target = cmdq_get_target(item);
|
||||
struct session *s = target->s, *sloop, *stmp;
|
||||
struct session_group *sg;
|
||||
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')) {
|
||||
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;
|
||||
}
|
||||
server_redraw_session(s);
|
||||
} else if (args_has(args, 'a')) {
|
||||
RB_FOREACH_SAFE(sloop, sessions, &sessions, stmp) {
|
||||
if (sloop != s) {
|
||||
server_destroy_session(sloop);
|
||||
session_destroy(sloop, 1, __func__);
|
||||
}
|
||||
} else if (args_has(args, 'a'))
|
||||
return (cmd_kill_session_all(item, filter));
|
||||
else if (args_has(args, 'g') &&
|
||||
(sg = session_group_contains(s)) != NULL) {
|
||||
TAILQ_FOREACH_SAFE(sloop, &sg->sessions, gentry, stmp) {
|
||||
server_destroy_session(sloop);
|
||||
session_destroy(sloop, 1, __func__);
|
||||
}
|
||||
} else {
|
||||
server_destroy_session(s);
|
||||
@@ -69,3 +82,42 @@ cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.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_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 = {
|
||||
.name = "kill-window",
|
||||
.alias = "killw",
|
||||
|
||||
.args = { "at:", 0, 0, NULL },
|
||||
.usage = "[-a] " CMD_TARGET_WINDOW_USAGE,
|
||||
.args = { "af:t:", 0, 0, NULL },
|
||||
.usage = "[-a] [-f filter] " CMD_TARGET_WINDOW_USAGE,
|
||||
|
||||
.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 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 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 (!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);
|
||||
}
|
||||
|
||||
if (args_has(args, 'a')) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
if (args_has(args, 'a'))
|
||||
return (cmd_kill_window_all(item, filter));
|
||||
|
||||
server_kill_window(wl->window, 1);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -36,8 +36,8 @@ const struct cmd_entry cmd_list_buffers_entry = {
|
||||
.name = "list-buffers",
|
||||
.alias = "lsb",
|
||||
|
||||
.args = { "F:f:", 0, 0, NULL },
|
||||
.usage = "[-F format] [-f filter]",
|
||||
.args = { "F:f:O:r", 0, 0, NULL },
|
||||
.usage = "[-F format] [-f filter] [-O order]",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_list_buffers_exec
|
||||
@@ -46,21 +46,30 @@ const struct cmd_entry cmd_list_buffers_entry = {
|
||||
static enum cmd_retval
|
||||
cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct paste_buffer *pb;
|
||||
struct format_tree *ft;
|
||||
const char *template, *filter;
|
||||
char *line, *expanded;
|
||||
int flag;
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct paste_buffer **l;
|
||||
struct format_tree *ft;
|
||||
const char *template, *filter;
|
||||
char *line, *expanded;
|
||||
int flag;
|
||||
u_int i, n;
|
||||
struct sort_criteria sort_crit;
|
||||
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = LIST_BUFFERS_TEMPLATE;
|
||||
filter = args_get(args, 'f');
|
||||
|
||||
pb = NULL;
|
||||
while ((pb = paste_walk(pb)) != NULL) {
|
||||
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');
|
||||
|
||||
l = sort_get_buffers(&n, &sort_crit);
|
||||
for (i = 0; i < n; i++) {
|
||||
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) {
|
||||
expanded = format_expand(ft, filter);
|
||||
|
||||
@@ -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>
|
||||
@@ -41,8 +41,8 @@ const struct cmd_entry cmd_list_clients_entry = {
|
||||
.name = "list-clients",
|
||||
.alias = "lsc",
|
||||
|
||||
.args = { "F:t:", 0, 0, NULL },
|
||||
.usage = "[-F format] " CMD_TARGET_SESSION_USAGE,
|
||||
.args = { "F:f:O:rt:", 0, 0, NULL },
|
||||
.usage = "[-F format] [-f filter] [-O order]" CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||
|
||||
@@ -53,14 +53,16 @@ const struct cmd_entry cmd_list_clients_entry = {
|
||||
static enum cmd_retval
|
||||
cmd_list_clients_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 client *c;
|
||||
struct session *s;
|
||||
struct format_tree *ft;
|
||||
const char *template;
|
||||
u_int idx;
|
||||
char *line;
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct client **l;
|
||||
struct session *s;
|
||||
struct format_tree *ft;
|
||||
const char *template, *filter;
|
||||
u_int i, n;
|
||||
char *line, *expanded;
|
||||
int flag;
|
||||
struct sort_criteria sort_crit;
|
||||
|
||||
if (args_has(args, 't'))
|
||||
s = target->s;
|
||||
@@ -69,23 +71,37 @@ cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = LIST_CLIENTS_TEMPLATE;
|
||||
filter = args_get(args, 'f');
|
||||
|
||||
idx = 0;
|
||||
TAILQ_FOREACH(c, &clients, entry) {
|
||||
if (c->session == NULL || (s != NULL && s != c->session))
|
||||
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');
|
||||
|
||||
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;
|
||||
|
||||
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
|
||||
format_add(ft, "line", "%u", idx);
|
||||
format_defaults(ft, c, NULL, NULL, NULL);
|
||||
format_add(ft, "line", "%u", i);
|
||||
format_defaults(ft, l[i], NULL, NULL, NULL);
|
||||
|
||||
line = format_expand(ft, template);
|
||||
cmdq_print(item, "%s", line);
|
||||
free(line);
|
||||
if (filter != NULL) {
|
||||
expanded = format_expand(ft, filter);
|
||||
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);
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
107
cmd-list-commands.c
Normal file
107
cmd-list-commands.c
Normal 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);
|
||||
}
|
||||
429
cmd-list-keys.c
429
cmd-list-keys.c
@@ -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>
|
||||
@@ -27,137 +27,157 @@
|
||||
* 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 *,
|
||||
struct cmdq_item *);
|
||||
static enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_list_keys_entry = {
|
||||
.name = "list-keys",
|
||||
.alias = "lsk",
|
||||
|
||||
.args = { "1aNP:T:", 0, 1, NULL },
|
||||
.usage = "[-1aN] [-P prefix-string] [-T key-table] [key]",
|
||||
.args = { "1aF:NO:P:rT:", 0, 1, NULL },
|
||||
.usage = "[-1aNr] [-F format] [-O order] [-P prefix-string]"
|
||||
"[-T key-table] [key]",
|
||||
|
||||
.flags = CMD_STARTSERVER|CMD_AFTERHOOK,
|
||||
.exec = cmd_list_keys_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_list_commands_entry = {
|
||||
.name = "list-commands",
|
||||
.alias = "lscm",
|
||||
static char *
|
||||
cmd_list_keys_get_prefix(struct args *args)
|
||||
{
|
||||
key_code prefix;
|
||||
|
||||
.args = { "F:", 0, 1, NULL },
|
||||
.usage = "[-F format] [command]",
|
||||
if (args_has(args, 'P'))
|
||||
return (xstrdup(args_get(args, 'P')));
|
||||
|
||||
.flags = CMD_STARTSERVER|CMD_AFTERHOOK,
|
||||
.exec = cmd_list_keys_exec
|
||||
};
|
||||
prefix = options_get_number(global_s_options, "prefix");
|
||||
if (prefix == KEYC_NONE)
|
||||
return (xstrdup(""));
|
||||
return (xstrdup(key_string_lookup_key(prefix, 0)));
|
||||
}
|
||||
|
||||
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;
|
||||
struct key_binding *bd;
|
||||
u_int width, keywidth = 0;
|
||||
u_int i, width, keywidth = 0;
|
||||
|
||||
table = key_bindings_get_table(tablename, 0);
|
||||
if (table == NULL)
|
||||
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));
|
||||
for (i = 0; i < n; i++) {
|
||||
width = utf8_cstrwidth(key_string_lookup_key(l[i]->key, 0));
|
||||
if (width > keywidth)
|
||||
keywidth = width;
|
||||
|
||||
bd = key_bindings_next(table, bd);
|
||||
}
|
||||
return (keywidth);
|
||||
}
|
||||
|
||||
static int
|
||||
cmd_list_keys_print_notes(struct cmdq_item *item, struct args *args,
|
||||
const char *tablename, u_int keywidth, key_code only, const char *prefix)
|
||||
static u_int
|
||||
cmd_list_keys_get_table_width(struct key_binding **l, u_int n)
|
||||
{
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct key_table *table;
|
||||
struct key_binding *bd;
|
||||
const char *key;
|
||||
char *tmp, *note;
|
||||
int found = 0;
|
||||
u_int i, width, tablewidth = 0;
|
||||
|
||||
table = key_bindings_get_table(tablename, 0);
|
||||
if (table == NULL)
|
||||
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') &&
|
||||
!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);
|
||||
for (i = 0; i < n; i++) {
|
||||
width = utf8_cstrwidth(l[i]->tablename);
|
||||
if (width > tablewidth)
|
||||
tablewidth = width;
|
||||
}
|
||||
return (found);
|
||||
return (tablewidth);
|
||||
}
|
||||
|
||||
static char *
|
||||
cmd_list_keys_get_prefix(struct args *args, key_code *prefix)
|
||||
static struct key_binding **
|
||||
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, <sz, 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;
|
||||
|
||||
*prefix = options_get_number(global_s_options, "prefix");
|
||||
if (!args_has(args, 'P')) {
|
||||
if (*prefix != KEYC_NONE)
|
||||
xasprintf(&s, "%s ", key_string_lookup_key(*prefix, 0));
|
||||
else
|
||||
s = xstrdup("");
|
||||
} else
|
||||
s = xstrdup(args_get(args, 'P'));
|
||||
return (s);
|
||||
if (bd->flags & KEY_BINDING_REPEAT)
|
||||
format_add(ft, "key_repeat", "1");
|
||||
else
|
||||
format_add(ft, "key_repeat", "0");
|
||||
|
||||
if (bd->note != NULL)
|
||||
format_add(ft, "key_note", "%s", bd->note);
|
||||
else
|
||||
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
|
||||
cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct key_table *table;
|
||||
struct key_binding *bd;
|
||||
const char *tablename, *r, *keystr;
|
||||
char *key, *cp, *tmp, *start, *empty;
|
||||
key_code prefix, only = KEYC_UNKNOWN;
|
||||
int repeat, width, tablewidth, keywidth, found = 0;
|
||||
size_t tmpsize, tmpused, cplen;
|
||||
|
||||
if (cmd_get_entry(self) == &cmd_list_commands_entry)
|
||||
return (cmd_list_keys_commands(self, item));
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct format_tree *ft;
|
||||
struct key_table *table = NULL;
|
||||
struct key_binding **l;
|
||||
key_code only = KEYC_UNKNOWN;
|
||||
const char *template, *tablename, *keystr;
|
||||
char *line;
|
||||
char *prefix = NULL;
|
||||
u_int i, n;
|
||||
int single, notes_only, filter_notes, filter_key;
|
||||
struct sort_criteria sort_crit;
|
||||
|
||||
if ((keystr = args_string(args, 0)) != NULL) {
|
||||
only = key_string_lookup_string(keystr);
|
||||
@@ -168,198 +188,71 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
only &= (KEYC_MASK_KEY|KEYC_MASK_MODIFIERS);
|
||||
}
|
||||
|
||||
tablename = args_get(args, 'T');
|
||||
if (tablename != NULL && key_bindings_get_table(tablename, 0) == NULL) {
|
||||
cmdq_error(item, "table %s doesn't exist", tablename);
|
||||
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 (tablename == NULL) {
|
||||
start = cmd_list_keys_get_prefix(args, &prefix);
|
||||
keywidth = cmd_list_keys_get_width("root", only);
|
||||
if (prefix != KEYC_NONE) {
|
||||
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);
|
||||
|
||||
if ((tablename = args_get(args, 'T')) != NULL) {
|
||||
table = key_bindings_get_table(tablename, 0);
|
||||
if (table == NULL) {
|
||||
cmdq_error(item, "table %s doesn't exist", tablename);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
free(start);
|
||||
goto out;
|
||||
}
|
||||
|
||||
repeat = 0;
|
||||
tablewidth = keywidth = 0;
|
||||
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;
|
||||
}
|
||||
key = args_escape(key_string_lookup_key(bd->key, 0));
|
||||
prefix = cmd_list_keys_get_prefix(args);
|
||||
single = args_has(args, '1');
|
||||
notes_only = args_has(args, 'N');
|
||||
|
||||
if (bd->flags & KEY_BINDING_REPEAT)
|
||||
repeat = 1;
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = LIST_KEYS_TEMPLATE;
|
||||
|
||||
width = utf8_cstrwidth(table->name);
|
||||
if (width > tablewidth)
|
||||
tablewidth = width;
|
||||
width = utf8_cstrwidth(key);
|
||||
if (width > keywidth)
|
||||
keywidth = width;
|
||||
if (table)
|
||||
l = sort_get_key_bindings_table(table, &n, &sort_crit);
|
||||
else if (notes_only)
|
||||
l = cmd_list_keys_get_root_and_prefix(&n, &sort_crit);
|
||||
else
|
||||
l = sort_get_key_bindings(&n, &sort_crit);
|
||||
|
||||
free(key);
|
||||
bd = key_bindings_next(table, bd);
|
||||
}
|
||||
table = key_bindings_next_table(table);
|
||||
filter_notes = notes_only && !args_has(args, 'a');
|
||||
filter_key = only != KEYC_UNKNOWN;
|
||||
if (filter_notes || filter_key) {
|
||||
cmd_list_keys_filter_key_list(filter_notes, filter_key, only, l,
|
||||
&n);
|
||||
}
|
||||
|
||||
tmpsize = 256;
|
||||
tmp = xmalloc(tmpsize);
|
||||
|
||||
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_string(args, 0));
|
||||
if (filter_key && n == 0) {
|
||||
cmdq_error(item, "unknown key: %s", keystr);
|
||||
free(prefix);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
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;
|
||||
char *line;
|
||||
|
||||
if ((template = args_get(args, 'F')) == NULL) {
|
||||
template = "#{command_list_name}"
|
||||
"#{?command_list_alias, (#{command_list_alias}),} "
|
||||
"#{command_list_usage}";
|
||||
}
|
||||
if (single && n > 1)
|
||||
n = 1;
|
||||
|
||||
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
|
||||
format_defaults(ft, NULL, NULL, NULL, NULL);
|
||||
|
||||
command = args_string(args, 0);
|
||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
||||
entry = *entryp;
|
||||
if (command != NULL &&
|
||||
(strcmp(entry->name, command) != 0 &&
|
||||
(entry->alias == NULL ||
|
||||
strcmp(entry->alias, command) != 0)))
|
||||
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);
|
||||
format_defaults(ft, tc, NULL, NULL, NULL);
|
||||
format_add(ft, "notes_only", "%d", notes_only);
|
||||
format_add(ft, "key_has_repeat", "%d", key_bindings_has_repeat(l, n));
|
||||
format_add(ft, "key_string_width", "%u", cmd_list_keys_get_width(l, n));
|
||||
format_add(ft, "key_table_width", "%u",
|
||||
cmd_list_keys_get_table_width(l, n));
|
||||
for (i = 0; i < n; i++) {
|
||||
cmd_list_keys_format_add_key_binding(ft, l[i], prefix);
|
||||
|
||||
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);
|
||||
free(line);
|
||||
}
|
||||
|
||||
if (single)
|
||||
break;
|
||||
}
|
||||
format_free(ft);
|
||||
free(prefix);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -38,8 +38,9 @@ const struct cmd_entry cmd_list_panes_entry = {
|
||||
.name = "list-panes",
|
||||
.alias = "lsp",
|
||||
|
||||
.args = { "asF:f:t:", 0, 0, NULL },
|
||||
.usage = "[-as] [-F format] [-f filter] " CMD_TARGET_WINDOW_USAGE,
|
||||
.args = { "aF:f:O:rst:", 0, 0, NULL },
|
||||
.usage = "[-asr] [-F format] [-f filter] [-O order]"
|
||||
CMD_TARGET_WINDOW_USAGE,
|
||||
|
||||
.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 session *s = target->s;
|
||||
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'))
|
||||
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 args *args = cmd_get_args(self);
|
||||
struct window_pane *wp;
|
||||
u_int n;
|
||||
struct window_pane *wp, **l;
|
||||
u_int i, n;
|
||||
struct format_tree *ft;
|
||||
const char *template, *filter;
|
||||
char *line, *expanded;
|
||||
int flag;
|
||||
struct sort_criteria sort_crit;
|
||||
|
||||
template = args_get(args, 'F');
|
||||
if (template == NULL) {
|
||||
switch (type) {
|
||||
case 0:
|
||||
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_bytes} bytes] #{pane_id}"
|
||||
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||
break;
|
||||
case 1:
|
||||
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_bytes} bytes] #{pane_id}"
|
||||
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||
break;
|
||||
case 2:
|
||||
template = "#{session_name}:#{window_index}."
|
||||
"#{pane_index}: [#{pane_width}x#{pane_height}] "
|
||||
"[history #{history_size}/#{history_limit}, "
|
||||
"#{pane_index}: [#{pane_width}x#{pane_height}"
|
||||
"#{?pane_floating_flag, "
|
||||
"#{pane_x}#,#{pane_y}#,#{pane_z}}] [history "
|
||||
"#{history_size}/#{history_limit}, "
|
||||
"#{history_bytes} bytes] #{pane_id}"
|
||||
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||
break;
|
||||
@@ -124,8 +139,12 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
|
||||
}
|
||||
filter = args_get(args, 'f');
|
||||
|
||||
n = 0;
|
||||
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||
sort_crit.order = sort_order_from_string(args_get(args, 'O'));
|
||||
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);
|
||||
format_add(ft, "line", "%u", n);
|
||||
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);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -42,8 +42,8 @@ const struct cmd_entry cmd_list_sessions_entry = {
|
||||
.name = "list-sessions",
|
||||
.alias = "ls",
|
||||
|
||||
.args = { "F:f:", 0, 0, NULL },
|
||||
.usage = "[-F format] [-f filter]",
|
||||
.args = { "F:f:O:r", 0, 0, NULL },
|
||||
.usage = "[-r] [-F format] [-f filter] [-O order]",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_list_sessions_exec
|
||||
@@ -52,23 +52,31 @@ const struct cmd_entry cmd_list_sessions_entry = {
|
||||
static enum cmd_retval
|
||||
cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct session *s;
|
||||
u_int n;
|
||||
struct format_tree *ft;
|
||||
const char *template, *filter;
|
||||
char *line, *expanded;
|
||||
int flag;
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct session **l;
|
||||
u_int n, i;
|
||||
struct format_tree *ft;
|
||||
const char *template, *filter;
|
||||
char *line, *expanded;
|
||||
int flag;
|
||||
struct sort_criteria sort_crit;
|
||||
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = LIST_SESSIONS_TEMPLATE;
|
||||
filter = args_get(args, 'f');
|
||||
|
||||
n = 0;
|
||||
RB_FOREACH(s, sessions, &sessions) {
|
||||
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');
|
||||
|
||||
l = sort_get_sessions(&n, &sort_crit);
|
||||
for (i = 0; i < n; i++) {
|
||||
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
|
||||
format_add(ft, "line", "%u", n);
|
||||
format_defaults(ft, NULL, s, NULL, NULL);
|
||||
format_add(ft, "line", "%u", i);
|
||||
format_defaults(ft, NULL, l[i], NULL, NULL);
|
||||
|
||||
if (filter != NULL) {
|
||||
expanded = format_expand(ft, filter);
|
||||
@@ -83,7 +91,6 @@ cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
|
||||
format_free(ft);
|
||||
n++;
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
@@ -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>
|
||||
@@ -41,16 +41,13 @@
|
||||
|
||||
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 = {
|
||||
.name = "list-windows",
|
||||
.alias = "lsw",
|
||||
|
||||
.args = { "F:f:at:", 0, 0, NULL },
|
||||
.usage = "[-a] [-F format] [-f filter] " CMD_TARGET_SESSION_USAGE,
|
||||
.args = { "aF:f:O:rt:", 0, 0, NULL },
|
||||
.usage = "[-ar] [-F format] [-f filter] [-O order]"
|
||||
CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.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 cmd_find_state *target = cmdq_get_target(item);
|
||||
|
||||
if (args_has(args, 'a'))
|
||||
cmd_list_windows_server(self, item);
|
||||
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 winlink *wl, **l;
|
||||
struct session *s;
|
||||
u_int i, n;
|
||||
struct format_tree *ft;
|
||||
const char *template, *filter;
|
||||
char *line, *expanded;
|
||||
int flag;
|
||||
struct sort_criteria sort_crit;
|
||||
|
||||
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');
|
||||
|
||||
n = 0;
|
||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||
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, '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);
|
||||
format_add(ft, "line", "%u", n);
|
||||
format_defaults(ft, NULL, s, wl, NULL);
|
||||
@@ -125,6 +109,7 @@ cmd_list_windows_session(struct cmd *self, struct session *s,
|
||||
}
|
||||
|
||||
format_free(ft);
|
||||
n++;
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -66,7 +66,7 @@ cmd_load_buffer_done(__unused struct client *c, const char *path, int error,
|
||||
return;
|
||||
|
||||
if (error != 0)
|
||||
cmdq_error(item, "%s: %s", path, strerror(error));
|
||||
cmdq_error(item, "%s: %s", strerror(error), path);
|
||||
else if (bsize != 0) {
|
||||
copy = xmalloc(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 &&
|
||||
tc->session != NULL &&
|
||||
(~tc->flags & CLIENT_DEAD))
|
||||
tty_set_selection(&tc->tty, copy, bsize);
|
||||
tty_set_selection(&tc->tty, "", copy, bsize);
|
||||
if (tc != NULL)
|
||||
server_client_unref(tc);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
@@ -43,7 +43,7 @@ const struct cmd_entry cmd_new_session_entry = {
|
||||
.usage = "[-AdDEPX] [-c start-directory] [-e environment] [-F format] "
|
||||
"[-f flags] [-n window-name] [-s session-name] "
|
||||
CMD_TARGET_SESSION_USAGE " [-x width] [-y height] "
|
||||
"[shell-command]",
|
||||
"[shell-command [argument ...]]",
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
||||
|
||||
@@ -77,8 +77,8 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct termios tio, *tiop;
|
||||
struct session_group *sg = NULL;
|
||||
const char *errstr, *template, *group, *tmp;
|
||||
char *cause, *cwd = NULL, *cp, *newname = NULL;
|
||||
char *name, *prefix = NULL;
|
||||
char *cause, *cwd = NULL, *cp, *ename;
|
||||
char *wname = NULL, *sname = NULL, *prefix = NULL;
|
||||
int detached, already_attached, is_control = 0;
|
||||
u_int sx, sy, dsx, dsy, count = args_count(args);
|
||||
struct spawn_context sc = { 0 };
|
||||
@@ -99,32 +99,43 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
tmp = args_get(args, 's');
|
||||
if (tmp != NULL) {
|
||||
name = format_single(item, tmp, c, NULL, NULL, NULL);
|
||||
newname = session_check_name(name);
|
||||
if (newname == NULL) {
|
||||
cmdq_error(item, "invalid session: %s", name);
|
||||
free(name);
|
||||
if ((tmp = args_get(args, 'n')) != NULL) {
|
||||
ename = format_single(item, tmp, c, NULL, NULL, NULL);
|
||||
if (!check_name(ename)) {
|
||||
cmdq_error(item, "invalid window name: %s", ename);
|
||||
free(ename);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
free(name);
|
||||
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 (newname != NULL)
|
||||
as = session_find(newname);
|
||||
if (sname != NULL)
|
||||
as = session_find(sname);
|
||||
else
|
||||
as = target->s;
|
||||
if (as != NULL) {
|
||||
retval = cmd_attach_session(item, as->name,
|
||||
args_has(args, 'D'), args_has(args, 'X'), 0, NULL,
|
||||
args_has(args, 'E'), args_get(args, 'f'));
|
||||
free(newname);
|
||||
args_has(args, 'D'), args_has(args, 'X'), 0,
|
||||
args_get(args, 'c'), args_has(args, 'E'),
|
||||
args_get(args, 'f'));
|
||||
free(wname);
|
||||
free(sname);
|
||||
return (retval);
|
||||
}
|
||||
}
|
||||
if (newname != NULL && session_find(newname) != NULL) {
|
||||
cmdq_error(item, "duplicate session: %s", newname);
|
||||
if (sname != NULL && session_find(sname) != NULL) {
|
||||
cmdq_error(item, "duplicate session: %s", sname);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -141,12 +152,12 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
else if (groupwith != NULL)
|
||||
prefix = xstrdup(groupwith->name);
|
||||
else {
|
||||
prefix = session_check_name(group);
|
||||
if (prefix == NULL) {
|
||||
cmdq_error(item, "invalid session group: %s",
|
||||
group);
|
||||
if (!check_name(group)) {
|
||||
cmdq_error(item,
|
||||
"invalid session group name: %s", group);
|
||||
goto fail;
|
||||
}
|
||||
prefix = clean_name(group, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +286,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
environ_put(env, av->string, 0);
|
||||
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. */
|
||||
sc.item = item;
|
||||
@@ -283,7 +294,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (!detached)
|
||||
sc.tc = c;
|
||||
|
||||
sc.name = args_get(args, 'n');
|
||||
sc.name = wname;
|
||||
args_to_vector(args, &sc.argc, &sc.argv);
|
||||
|
||||
sc.idx = -1;
|
||||
@@ -314,7 +325,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
session_group_synchronize_to(s);
|
||||
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
|
||||
@@ -333,13 +344,6 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
server_client_set_key_table(c, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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. */
|
||||
if (args_has(args, 'P')) {
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
@@ -357,10 +361,14 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
cmd_find_from_session(&fs, s, 0);
|
||||
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(newname);
|
||||
free(wname);
|
||||
free(sname);
|
||||
free(prefix);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
@@ -368,7 +376,8 @@ fail:
|
||||
if (sc.argv != NULL)
|
||||
cmd_free_argv(sc.argc, sc.argv);
|
||||
free(cwd);
|
||||
free(newname);
|
||||
free(wname);
|
||||
free(sname);
|
||||
free(prefix);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -38,9 +38,10 @@ const struct cmd_entry cmd_new_window_entry = {
|
||||
.name = "new-window",
|
||||
.alias = "neww",
|
||||
|
||||
.args = { "abc:de:F:kn:PSt:", 0, -1, NULL },
|
||||
.usage = "[-abdkPS] [-c start-directory] [-e environment] [-F format] "
|
||||
"[-n window-name] " CMD_TARGET_WINDOW_USAGE " [shell-command]",
|
||||
.args = { "abc:de:EF:kn:PSt:", 0, -1, NULL },
|
||||
.usage = "[-abdEkPS] [-c start-directory] [-e environment] [-F format] "
|
||||
"[-n window-name] " CMD_TARGET_WINDOW_USAGE
|
||||
" [shell-command [argument ...]]",
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX },
|
||||
|
||||
@@ -59,29 +60,51 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct session *s = target->s;
|
||||
struct winlink *wl = target->wl, *new_wl = NULL;
|
||||
int idx = target->idx, before;
|
||||
char *cause = NULL, *cp;
|
||||
int idx = target->idx, before, count = args_count(args);
|
||||
char *cause = NULL, *cp, *expanded, *wname = NULL;
|
||||
const char *template, *name;
|
||||
struct cmd_find_state fs;
|
||||
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
|
||||
* name already exists, select it.
|
||||
*/
|
||||
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) {
|
||||
if (strcmp(wl->window->name, name) != 0)
|
||||
if (strcmp(wl->window->name, expanded) != 0)
|
||||
continue;
|
||||
if (new_wl == NULL) {
|
||||
new_wl = wl;
|
||||
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);
|
||||
}
|
||||
free(expanded);
|
||||
if (new_wl != NULL) {
|
||||
free(wname);
|
||||
if (args_has(args, 'd'))
|
||||
return (CMD_RETURN_NORMAL);
|
||||
if (session_set_current(s, new_wl) == 0)
|
||||
@@ -104,7 +127,7 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
sc.s = s;
|
||||
sc.tc = tc;
|
||||
|
||||
sc.name = args_get(args, 'n');
|
||||
sc.name = wname;
|
||||
args_to_vector(args, &sc.argc, &sc.argv);
|
||||
sc.environ = environ_create();
|
||||
|
||||
@@ -118,6 +141,8 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
sc.cwd = args_get(args, 'c');
|
||||
|
||||
sc.flags = 0;
|
||||
if (args_has(args, 'E') || (count == 1 && *args_string(args, 0) == '\0'))
|
||||
sc.flags |= SPAWN_EMPTY;
|
||||
if (args_has(args, 'd'))
|
||||
sc.flags |= SPAWN_DETACHED;
|
||||
if (args_has(args, 'k'))
|
||||
@@ -126,10 +151,7 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if ((new_wl = spawn_window(&sc, &cause)) == NULL) {
|
||||
cmdq_error(item, "create window failed: %s", cause);
|
||||
free(cause);
|
||||
if (sc.argv != NULL)
|
||||
cmd_free_argv(sc.argc, sc.argv);
|
||||
environ_free(sc.environ);
|
||||
return (CMD_RETURN_ERROR);
|
||||
goto fail;
|
||||
}
|
||||
if (!args_has(args, 'd') || new_wl == s->curw) {
|
||||
cmd_find_from_winlink(current, new_wl, 0);
|
||||
@@ -152,5 +174,13 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (sc.argv != NULL)
|
||||
cmd_free_argv(sc.argc, sc.argv);
|
||||
environ_free(sc.environ);
|
||||
free(wname);
|
||||
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);
|
||||
}
|
||||
|
||||
95
cmd-parse.y
95
cmd-parse.y
@@ -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>
|
||||
@@ -32,11 +32,13 @@
|
||||
|
||||
static int yylex(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_format(void);
|
||||
|
||||
#define CMD_PARSE_MAX_ENVIRON_LEN 16384
|
||||
|
||||
struct cmd_parse_scope {
|
||||
int flag;
|
||||
TAILQ_ENTRY (cmd_parse_scope) entry;
|
||||
@@ -223,9 +225,20 @@ assignment : EQUALS
|
||||
{
|
||||
struct cmd_parse_state *ps = &parse_state;
|
||||
int flags = ps->input->flags;
|
||||
int flag = 1;
|
||||
struct cmd_parse_scope *scope;
|
||||
|
||||
if ((~flags & CMD_PARSE_PARSEONLY) &&
|
||||
(ps->scope == NULL || ps->scope->flag))
|
||||
if (ps->scope != NULL) {
|
||||
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);
|
||||
free($1);
|
||||
}
|
||||
@@ -234,9 +247,20 @@ hidden_assignment : HIDDEN EQUALS
|
||||
{
|
||||
struct cmd_parse_state *ps = &parse_state;
|
||||
int flags = ps->input->flags;
|
||||
int flag = 1;
|
||||
struct cmd_parse_scope *scope;
|
||||
|
||||
if ((~flags & CMD_PARSE_PARSEONLY) &&
|
||||
(ps->scope == NULL || ps->scope->flag))
|
||||
if (ps->scope != NULL) {
|
||||
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);
|
||||
free($2);
|
||||
}
|
||||
@@ -744,7 +768,7 @@ 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 *arg, *arg1, *first;
|
||||
struct cmd_parse_argument *first;
|
||||
struct cmd_parse_commands *cmds;
|
||||
struct cmd_parse_command *last;
|
||||
char *alias, *name, *cause;
|
||||
@@ -784,10 +808,7 @@ cmd_parse_expand_alias(struct cmd_parse_command *cmd,
|
||||
TAILQ_REMOVE(&cmd->arguments, first, entry);
|
||||
cmd_parse_free_argument(first);
|
||||
|
||||
TAILQ_FOREACH_SAFE(arg, &cmd->arguments, entry, arg1) {
|
||||
TAILQ_REMOVE(&cmd->arguments, arg, entry);
|
||||
TAILQ_INSERT_TAIL(&last->arguments, arg, entry);
|
||||
}
|
||||
TAILQ_CONCAT(&last->arguments, &cmd->arguments, entry);
|
||||
cmd_parse_log_commands(cmds, __func__);
|
||||
|
||||
pi->flags |= CMD_PARSE_NOALIAS;
|
||||
@@ -835,7 +856,7 @@ cmd_parse_build_command(struct cmd_parse_command *cmd,
|
||||
count++;
|
||||
}
|
||||
|
||||
add = cmd_parse(values, count, pi->file, pi->line, &cause);
|
||||
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);
|
||||
@@ -1086,7 +1107,8 @@ cmd_parse_from_arguments(struct args_value *values, u_int count,
|
||||
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;
|
||||
@@ -1112,7 +1134,7 @@ cmd_parse_from_arguments(struct args_value *values, u_int count,
|
||||
return (&pr);
|
||||
}
|
||||
|
||||
static int printflike(1, 2)
|
||||
static void printflike(1, 2)
|
||||
yyerror(const char *fmt, ...)
|
||||
{
|
||||
struct cmd_parse_state *ps = &parse_state;
|
||||
@@ -1121,7 +1143,7 @@ yyerror(const char *fmt, ...)
|
||||
char *error;
|
||||
|
||||
if (ps->error != NULL)
|
||||
return (0);
|
||||
return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
xvasprintf(&error, fmt, ap);
|
||||
@@ -1129,7 +1151,6 @@ yyerror(const char *fmt, ...)
|
||||
|
||||
ps->error = cmd_parse_get_error(pi->file, pi->line, error);
|
||||
free(error);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1272,6 +1293,16 @@ yylex(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '\r') {
|
||||
/*
|
||||
* Treat \r\n as \n.
|
||||
*/
|
||||
ch = yylex_getc();
|
||||
if (ch != '\n') {
|
||||
yylex_ungetc(ch);
|
||||
ch = '\r';
|
||||
}
|
||||
}
|
||||
if (ch == '\n') {
|
||||
/*
|
||||
* End of line. Update the line number.
|
||||
@@ -1583,7 +1614,9 @@ yylex_token_tilde(char **buf, size_t *len)
|
||||
|
||||
if (*name == '\0') {
|
||||
envent = environ_find(global_environ, "HOME");
|
||||
if (envent != NULL && *envent->value != '\0')
|
||||
if (envent != NULL &&
|
||||
envent->value != NULL &&
|
||||
*envent->value != '\0')
|
||||
home = envent->value;
|
||||
else if ((pw = getpwuid(getuid())) != NULL)
|
||||
home = pw->pw_dir;
|
||||
@@ -1602,6 +1635,7 @@ yylex_token_tilde(char **buf, size_t *len)
|
||||
static char *
|
||||
yylex_token(int ch)
|
||||
{
|
||||
struct cmd_parse_state *ps = &parse_state;
|
||||
char *buf;
|
||||
size_t len;
|
||||
enum { START,
|
||||
@@ -1614,13 +1648,34 @@ yylex_token(int ch)
|
||||
|
||||
for (;;) {
|
||||
/* 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;
|
||||
}
|
||||
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. */
|
||||
if ((ch == ' ' || ch == '\t' || ch == ';' || ch == '}') &&
|
||||
state == NONE)
|
||||
if (state == NONE && (ch == ' ' || ch == '\t')) {
|
||||
log_debug("%s: end at WS", __func__);
|
||||
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
|
||||
|
||||
@@ -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>
|
||||
@@ -33,8 +33,8 @@ const struct cmd_entry cmd_paste_buffer_entry = {
|
||||
.name = "paste-buffer",
|
||||
.alias = "pasteb",
|
||||
|
||||
.args = { "db:prs:t:", 0, 0, NULL },
|
||||
.usage = "[-dpr] [-s separator] " CMD_BUFFER_USAGE " "
|
||||
.args = { "db:prSs:t:", 0, 0, NULL },
|
||||
.usage = "[-dprS] [-s separator] " CMD_BUFFER_USAGE " "
|
||||
CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
@@ -43,6 +43,17 @@ const struct cmd_entry cmd_paste_buffer_entry = {
|
||||
.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
|
||||
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 paste_buffer *pb;
|
||||
const char *sepstr, *bufname, *bufdata, *bufend, *line;
|
||||
size_t seplen, bufsize;
|
||||
size_t seplen, bufsize, len;
|
||||
int bracket = args_has(args, 'p');
|
||||
|
||||
if (window_pane_exited(wp)) {
|
||||
cmdq_error(item, "target pane has exited");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
bufname = NULL;
|
||||
if (args_has(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);
|
||||
if (line == NULL)
|
||||
break;
|
||||
|
||||
bufferevent_write(wp->event, bufdata, line - bufdata);
|
||||
len = 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);
|
||||
|
||||
bufdata = line + 1;
|
||||
}
|
||||
if (bufdata != bufend)
|
||||
bufferevent_write(wp->event, bufdata, bufend - bufdata);
|
||||
if (bufdata != bufend) {
|
||||
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))
|
||||
bufferevent_write(wp->event, "\033[201~", 6);
|
||||
|
||||
@@ -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>
|
||||
@@ -68,7 +68,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
sigset_t set, oldset;
|
||||
|
||||
/* Do nothing if pane is dead. */
|
||||
if (wp->fd == -1 || (wp->flags & PANE_EXITED)) {
|
||||
if (window_pane_exited(wp)) {
|
||||
cmdq_error(item, "target pane has exited");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
@@ -123,11 +123,13 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
/* Fork the child. */
|
||||
sigfillset(&set);
|
||||
sigprocmask(SIG_BLOCK, &set, &oldset);
|
||||
switch (fork()) {
|
||||
switch ((wp->pipe_pid = fork())) {
|
||||
case -1:
|
||||
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||
cmdq_error(item, "fork error: %s", strerror(errno));
|
||||
|
||||
close(pipe_fd[0]);
|
||||
close(pipe_fd[1]);
|
||||
free(cmd);
|
||||
return (CMD_RETURN_ERROR);
|
||||
case 0:
|
||||
@@ -136,6 +138,9 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||
close(pipe_fd[0]);
|
||||
|
||||
if (setpgid(0, 0) == -1)
|
||||
_exit(1);
|
||||
|
||||
null_fd = open(_PATH_DEVNULL, O_WRONLY);
|
||||
if (out) {
|
||||
if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
|
||||
@@ -189,9 +194,13 @@ static void
|
||||
cmd_pipe_pane_read_callback(__unused struct bufferevent *bufev, void *data)
|
||||
{
|
||||
struct window_pane *wp = data;
|
||||
struct evbuffer *evb = wp->pipe_event->input;
|
||||
struct evbuffer *evb;
|
||||
size_t available;
|
||||
|
||||
if (wp->pipe_event == NULL)
|
||||
return;
|
||||
evb = wp->pipe_event->input;
|
||||
|
||||
available = EVBUFFER_LENGTH(evb);
|
||||
log_debug("%%%u pipe read %zu", wp->id, available);
|
||||
|
||||
|
||||
153
cmd-queue.c
153
cmd-queue.c
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD$ */
|
||||
/* $OpenBSD: cmd-queue.c,v 1.122 2026/08/03 13:38:42 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
@@ -147,6 +147,13 @@ cmdq_get_name(struct cmdq_item *item)
|
||||
return (item->name);
|
||||
}
|
||||
|
||||
/* Get item command. */
|
||||
struct cmd *
|
||||
cmdq_get_cmd(struct cmdq_item *item)
|
||||
{
|
||||
return (item->cmd);
|
||||
}
|
||||
|
||||
/* Get item client. */
|
||||
struct client *
|
||||
cmdq_get_client(struct cmdq_item *item)
|
||||
@@ -236,8 +243,10 @@ cmdq_link_state(struct cmdq_state *state)
|
||||
|
||||
/* Make a copy of a 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));
|
||||
}
|
||||
|
||||
@@ -348,74 +357,53 @@ cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item)
|
||||
|
||||
/* Insert a hook. */
|
||||
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 cmdq_state *state = item->state;
|
||||
struct cmd *cmd = item->cmd;
|
||||
struct args *args = cmd_get_args(cmd);
|
||||
struct args_entry *ae;
|
||||
struct args_value *av;
|
||||
struct options *oo;
|
||||
struct event_payload *ep;
|
||||
va_list ap;
|
||||
char *name, tmp[32], flag, *arguments;
|
||||
u_int i;
|
||||
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)
|
||||
return;
|
||||
if (s == NULL)
|
||||
oo = global_s_options;
|
||||
else
|
||||
oo = s->options;
|
||||
|
||||
va_start(ap, fmt);
|
||||
xvasprintf(&name, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
o = options_get(oo, name);
|
||||
if (o == NULL) {
|
||||
free(name);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
ep = event_payload_create();
|
||||
if (current != NULL)
|
||||
event_payload_set_target(ep, current);
|
||||
event_payload_set_pointer(ep, "_cmdq_item", item, NULL, NULL);
|
||||
|
||||
arguments = args_print(args);
|
||||
cmdq_add_format(new_state, "hook_arguments", "%s", arguments);
|
||||
event_payload_set_string(ep, "arguments", "%s", arguments);
|
||||
free(arguments);
|
||||
|
||||
for (i = 0; i < args_count(args); i++) {
|
||||
xsnprintf(tmp, sizeof tmp, "hook_argument_%d", i);
|
||||
cmdq_add_format(new_state, tmp, "%s", args_string(args, i));
|
||||
xsnprintf(tmp, sizeof tmp, "argument_%u", i);
|
||||
event_payload_set_string(ep, tmp, "%s", args_string(args, i));
|
||||
}
|
||||
flag = args_first(args, &ae);
|
||||
while (flag != 0) {
|
||||
value = args_get(args, flag);
|
||||
if (value == NULL) {
|
||||
xsnprintf(tmp, sizeof tmp, "hook_flag_%c", flag);
|
||||
cmdq_add_format(new_state, tmp, "1");
|
||||
} else {
|
||||
xsnprintf(tmp, sizeof tmp, "hook_flag_%c", flag);
|
||||
cmdq_add_format(new_state, tmp, "%s", value);
|
||||
}
|
||||
xsnprintf(tmp, sizeof tmp, "flag_%c", flag);
|
||||
if (value == NULL)
|
||||
event_payload_set_string(ep, tmp, "1");
|
||||
else
|
||||
event_payload_set_string(ep, tmp, "%s", value);
|
||||
|
||||
i = 0;
|
||||
av = args_first_value(args, flag);
|
||||
while (av != NULL) {
|
||||
xsnprintf(tmp, sizeof tmp, "hook_flag_%c_%d", flag, i);
|
||||
cmdq_add_format(new_state, tmp, "%s", av->string);
|
||||
xsnprintf(tmp, sizeof tmp, "flag_%c_%u", flag, i);
|
||||
event_payload_set_string(ep, tmp, "%s", av->string);
|
||||
i++;
|
||||
av = args_next_value(av);
|
||||
}
|
||||
@@ -423,20 +411,7 @@ cmdq_insert_hook(struct session *s, struct cmdq_item *item,
|
||||
flag = args_next(&ae);
|
||||
}
|
||||
|
||||
a = options_array_first(o);
|
||||
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);
|
||||
events_fire(name, ep);
|
||||
free(name);
|
||||
}
|
||||
|
||||
@@ -662,9 +637,18 @@ cmdq_fire_command(struct cmdq_item *item)
|
||||
|
||||
out:
|
||||
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);
|
||||
else
|
||||
} else
|
||||
cmdq_guard(item, "end", flags);
|
||||
return (retval);
|
||||
}
|
||||
@@ -803,10 +787,10 @@ cmdq_running(struct client *c)
|
||||
struct cmdq_list *queue = cmdq_get(c);
|
||||
|
||||
if (queue->item == NULL)
|
||||
return (NULL);
|
||||
if (queue->item->flags & CMDQ_WAITING)
|
||||
return (NULL);
|
||||
return (queue->item);
|
||||
return (NULL);
|
||||
if (queue->item->flags & CMDQ_WAITING)
|
||||
return (NULL);
|
||||
return (queue->item);
|
||||
}
|
||||
|
||||
/* Print a guard line. */
|
||||
@@ -818,48 +802,33 @@ cmdq_guard(struct cmdq_item *item, const char *guard, int flags)
|
||||
u_int number = item->number;
|
||||
|
||||
if (c != NULL && (c->flags & CLIENT_CONTROL))
|
||||
control_write(c, "%%%s %ld %u %d", guard, t, number, flags);
|
||||
control_write_guard(c, 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. */
|
||||
void
|
||||
cmdq_print(struct cmdq_item *item, const char *fmt, ...)
|
||||
{
|
||||
struct client *c = item->client;
|
||||
struct window_pane *wp;
|
||||
struct window_mode_entry *wme;
|
||||
va_list ap;
|
||||
char *tmp, *msg;
|
||||
va_list ap;
|
||||
struct evbuffer *evb;
|
||||
|
||||
evb = evbuffer_new();
|
||||
if (evb == NULL)
|
||||
fatalx("out of memory");
|
||||
|
||||
va_start(ap, fmt);
|
||||
xvasprintf(&msg, fmt, ap);
|
||||
evbuffer_add_vprintf(evb, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
log_debug("%s: %s", __func__, msg);
|
||||
|
||||
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, 0, "%s", msg);
|
||||
}
|
||||
|
||||
free(msg);
|
||||
cmdq_print_data(item, evb);
|
||||
evbuffer_free(evb);
|
||||
}
|
||||
|
||||
/* Show error from command. */
|
||||
@@ -896,7 +865,7 @@ cmdq_error(struct cmdq_item *item, const char *fmt, ...)
|
||||
c->retval = 1;
|
||||
} else {
|
||||
*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);
|
||||
|
||||
@@ -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>
|
||||
@@ -34,9 +34,10 @@ const struct cmd_entry cmd_refresh_client_entry = {
|
||||
.name = "refresh-client",
|
||||
.alias = "refresh",
|
||||
|
||||
.args = { "A:B:cC:Df:F:l::LRSt:U", 0, 1, NULL },
|
||||
.args = { "A:B:cC:Df:r:F:lLRSt:U", 0, 1, NULL },
|
||||
.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,
|
||||
.exec = cmd_refresh_client_exec
|
||||
@@ -45,36 +46,17 @@ const struct cmd_entry cmd_refresh_client_entry = {
|
||||
static void
|
||||
cmd_refresh_client_update_subscription(struct client *tc, const char *value)
|
||||
{
|
||||
char *copy, *split, *name, *what;
|
||||
enum control_sub_type subtype;
|
||||
int subid = -1;
|
||||
char *name, *format;
|
||||
enum monitor_type type;
|
||||
int id;
|
||||
|
||||
copy = name = xstrdup(value);
|
||||
if ((split = strchr(copy, ':')) == NULL) {
|
||||
control_remove_sub(tc, copy);
|
||||
goto out;
|
||||
if (monitor_parse(value, &name, &type, &id, &format) != 0) {
|
||||
control_remove_sub(tc, value);
|
||||
return;
|
||||
}
|
||||
*split++ = '\0';
|
||||
|
||||
what = split;
|
||||
if ((split = strchr(what, ':')) == NULL)
|
||||
goto out;
|
||||
*split++ = '\0';
|
||||
|
||||
if (strcmp(what, "%*") == 0)
|
||||
subtype = CONTROL_SUB_ALL_PANES;
|
||||
else if (sscanf(what, "%%%d", &subid) == 1 && subid >= 0)
|
||||
subtype = CONTROL_SUB_PANE;
|
||||
else if (strcmp(what, "@*") == 0)
|
||||
subtype = CONTROL_SUB_ALL_WINDOWS;
|
||||
else if (sscanf(what, "@%d", &subid) == 1 && subid >= 0)
|
||||
subtype = CONTROL_SUB_WINDOW;
|
||||
else
|
||||
subtype = CONTROL_SUB_SESSION;
|
||||
control_add_sub(tc, name, subtype, subid, split);
|
||||
|
||||
out:
|
||||
free(copy);
|
||||
control_add_sub(tc, name, type, id, format);
|
||||
free(name);
|
||||
free(format);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
@@ -84,7 +66,6 @@ cmd_refresh_client_control_client_size(struct cmd *self, struct cmdq_item *item)
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
const char *size = args_get(args, 'C');
|
||||
u_int w, x, y;
|
||||
struct client_window *cw;
|
||||
|
||||
if (sscanf(size, "@%u:%ux%u", &w, &x, &y) == 3) {
|
||||
if (x < WINDOW_MINIMUM || x > WINDOW_MAXIMUM ||
|
||||
@@ -94,22 +75,16 @@ cmd_refresh_client_control_client_size(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
log_debug("%s: client %s window @%u: size %ux%u", __func__,
|
||||
tc->name, w, x, y);
|
||||
cw = server_client_add_client_window(tc, w);
|
||||
cw->sx = x;
|
||||
cw->sy = y;
|
||||
control_set_window_size(tc, w, x, y);
|
||||
tc->flags |= CLIENT_WINDOWSIZECHANGED;
|
||||
recalculate_sizes_now(1);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
if (sscanf(size, "@%u:", &w) == 1) {
|
||||
cw = server_client_get_client_window(tc, w);
|
||||
if (cw != NULL) {
|
||||
log_debug("%s: client %s window @%u: no size", __func__,
|
||||
tc->name, w);
|
||||
cw->sx = 0;
|
||||
cw->sy = 0;
|
||||
recalculate_sizes_now(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);
|
||||
}
|
||||
|
||||
@@ -162,35 +137,39 @@ out:
|
||||
free(copy);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_refresh_client_clipboard(struct cmd *self, struct cmdq_item *item)
|
||||
static void
|
||||
cmd_refresh_report(struct tty *tty, const char *value)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
const char *p;
|
||||
u_int i;
|
||||
struct cmd_find_state fs;
|
||||
struct window_pane *wp;
|
||||
u_int pane;
|
||||
int fg, bg;
|
||||
size_t size = 0;
|
||||
char *copy, *split;
|
||||
|
||||
p = args_get(args, 'l');
|
||||
if (p == NULL) {
|
||||
if (tc->flags & CLIENT_CLIPBOARDBUFFER)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
tc->flags |= CLIENT_CLIPBOARDBUFFER;
|
||||
} else {
|
||||
if (cmd_find_target(&fs, item, p, CMD_FIND_PANE, 0) != 0)
|
||||
return (CMD_RETURN_ERROR);
|
||||
for (i = 0; i < tc->clipboard_npanes; i++) {
|
||||
if (tc->clipboard_panes[i] == fs.wp->id)
|
||||
break;
|
||||
}
|
||||
if (i != tc->clipboard_npanes)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
tc->clipboard_panes = xreallocarray(tc->clipboard_panes,
|
||||
tc->clipboard_npanes + 1, sizeof *tc->clipboard_panes);
|
||||
tc->clipboard_panes[tc->clipboard_npanes++] = fs.wp->id;
|
||||
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;
|
||||
}
|
||||
tty_clipboard_query(&tc->tty);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
out:
|
||||
free(copy);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
@@ -255,13 +234,17 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 'l'))
|
||||
return (cmd_refresh_client_clipboard(self, item));
|
||||
if (args_has(args, 'l')) {
|
||||
tty_clipboard_query(&tc->tty);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 'F')) /* -F is an alias for -f */
|
||||
server_client_set_flags(tc, args_get(args, 'F'));
|
||||
if (args_has(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 (~tc->flags & CLIENT_CONTROL)
|
||||
|
||||
@@ -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>
|
||||
@@ -49,15 +49,17 @@ cmd_rename_session_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 session *s = target->s;
|
||||
struct event_payload *ep;
|
||||
struct cmd_find_state fs;
|
||||
char *newname, *tmp;
|
||||
|
||||
tmp = format_single_from_target(item, args_string(args, 0));
|
||||
newname = session_check_name(tmp);
|
||||
if (newname == NULL) {
|
||||
cmdq_error(item, "invalid session: %s", 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);
|
||||
if (strcmp(newname, s->name) == 0) {
|
||||
free(newname);
|
||||
@@ -69,13 +71,20 @@ cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
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);
|
||||
free(s->name);
|
||||
s->name = newname;
|
||||
RB_INSERT(sessions, &sessions, s);
|
||||
|
||||
server_status_session(s);
|
||||
notify_session("session-renamed", s);
|
||||
events_fire("session-renamed", ep);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -48,15 +48,21 @@ cmd_rename_window_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 winlink *wl = target->wl;
|
||||
char *newname;
|
||||
char *name;
|
||||
|
||||
newname = format_single_from_target(item, args_string(args, 0));
|
||||
window_set_name(wl->window, newname);
|
||||
name = format_single_from_target(item, args_string(args, 0));
|
||||
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);
|
||||
free(name);
|
||||
|
||||
server_redraw_window_borders(wl->window);
|
||||
server_status_window(wl->window);
|
||||
free(newname);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -29,16 +30,20 @@
|
||||
|
||||
static enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
static void cmd_resize_pane_mouse_update(struct client *,
|
||||
struct mouse_event *);
|
||||
static enum cmd_retval cmd_resize_pane_mouse_update(struct cmd *,
|
||||
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 = {
|
||||
.name = "resize-pane",
|
||||
.alias = "resizep",
|
||||
|
||||
.args = { "DLMRTt:Ux:y:Z", 0, 1, NULL },
|
||||
.usage = "[-DLMRTUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " "
|
||||
"[adjustment]",
|
||||
.args = { "D::L::MR::Tt:U::x:y:Z", 0, 1, NULL },
|
||||
.usage = "[-MTZ] [-D lines] [-L columns] [-R columns] [-U lines] "
|
||||
"[-x width] [-y height] " CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.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 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;
|
||||
const char *errstr;
|
||||
char *cause;
|
||||
u_int adjust;
|
||||
int x, y, status;
|
||||
struct layout_cell *lc = wp->layout_cell;
|
||||
enum layout_type type;
|
||||
const char *errstr, *argval;
|
||||
const char flags[4] = { 'U', 'D', 'L', 'R' };
|
||||
char *cause = NULL, flag;
|
||||
int adjust, x, y, status, opposite = 0;
|
||||
long unsigned i;
|
||||
struct grid *gd = wp->base.grid;
|
||||
|
||||
if (args_has(args, 'T')) {
|
||||
if (!TAILQ_EMPTY(&wp->modes))
|
||||
return (CMD_RETURN_NORMAL);
|
||||
adjust = screen_size_y(&wp->base) - 1 - wp->base.cy;
|
||||
if (adjust > gd->hsize)
|
||||
if (adjust > (int)gd->hsize)
|
||||
adjust = gd->hsize;
|
||||
grid_remove_history(gd, adjust);
|
||||
wp->base.cy += adjust;
|
||||
@@ -75,19 +80,12 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 'M')) {
|
||||
if (!event->m.valid || cmd_mouse_window(&event->m, &s) == NULL)
|
||||
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, 'M'))
|
||||
return (cmd_resize_pane_mouse_update(self, item));
|
||||
|
||||
if (args_has(args, 'Z')) {
|
||||
if (w->flags & WINDOW_ZOOMED)
|
||||
window_unzoom(w);
|
||||
window_unzoom(w, 1);
|
||||
else
|
||||
window_zoom(wp);
|
||||
server_redraw_window(w);
|
||||
@@ -95,33 +93,31 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
server_unzoom_window(w);
|
||||
|
||||
if (args_count(args) == 0)
|
||||
adjust = 1;
|
||||
else {
|
||||
adjust = strtonum(args_string(args, 0), 1, INT_MAX, &errstr);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(item, "adjustment %s", errstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
cmdq_error(item, "width %s", cause);
|
||||
free(cause);
|
||||
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')) {
|
||||
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) {
|
||||
cmdq_error(item, "height %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
status = options_get_number(w->options, "pane-border-status");
|
||||
status = window_get_pane_status(w);
|
||||
switch (status) {
|
||||
case PANE_STATUS_TOP:
|
||||
if (y != INT_MAX && wp->yoff == 1)
|
||||
@@ -132,29 +128,236 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
y++;
|
||||
break;
|
||||
}
|
||||
layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y);
|
||||
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'))
|
||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust, 1);
|
||||
else if (args_has(args, 'R'))
|
||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust, 1);
|
||||
else if (args_has(args, 'U'))
|
||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust, 1);
|
||||
else if (args_has(args, 'D'))
|
||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust, 1);
|
||||
server_redraw_window(wl->window);
|
||||
for (i = 0; i < nitems(flags); i++) {
|
||||
flag = flags[i];
|
||||
if (!args_has(args, flag))
|
||||
continue;
|
||||
|
||||
argval = args_get(args, flag);
|
||||
if (argval == NULL) {
|
||||
if (args_count(args) == 0)
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
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 window *w;
|
||||
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 },
|
||||
};
|
||||
struct layout_cell *cells[nitems(offsets)], *lc;
|
||||
|
||||
@@ -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>
|
||||
@@ -53,8 +53,7 @@ cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct session *s = target->s;
|
||||
const char *errstr;
|
||||
char *cause;
|
||||
u_int adjust, sx, sy;
|
||||
int xpixel = -1, ypixel = -1;
|
||||
u_int adjust, sx, sy, xpixel = 0, ypixel = 0;
|
||||
|
||||
if (args_count(args) == 0)
|
||||
adjust = 1;
|
||||
|
||||
@@ -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>
|
||||
@@ -34,9 +34,9 @@ const struct cmd_entry cmd_respawn_pane_entry = {
|
||||
.name = "respawn-pane",
|
||||
.alias = "respawnp",
|
||||
|
||||
.args = { "c:e:kt:", 0, -1, NULL },
|
||||
.usage = "[-k] [-c start-directory] [-e environment] "
|
||||
CMD_TARGET_PANE_USAGE " [shell-command]",
|
||||
.args = { "c:e:Ekt:", 0, -1, NULL },
|
||||
.usage = "[-Ek] [-c start-directory] [-e environment] "
|
||||
CMD_TARGET_PANE_USAGE " [shell-command [argument ...]]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
@@ -75,6 +75,8 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
sc.cwd = args_get(args, 'c');
|
||||
|
||||
sc.flags = SPAWN_RESPAWN;
|
||||
if (args_has(args, 'E'))
|
||||
sc.flags |= SPAWN_EMPTY;
|
||||
if (args_has(args, 'k'))
|
||||
sc.flags |= SPAWN_KILL;
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -34,9 +34,9 @@ const struct cmd_entry cmd_respawn_window_entry = {
|
||||
.name = "respawn-window",
|
||||
.alias = "respawnw",
|
||||
|
||||
.args = { "c:e:kt:", 0, -1, NULL },
|
||||
.usage = "[-k] [-c start-directory] [-e environment] "
|
||||
CMD_TARGET_WINDOW_USAGE " [shell-command]",
|
||||
.args = { "c:e:Ekt:", 0, -1, NULL },
|
||||
.usage = "[-Ek] [-c start-directory] [-e environment] "
|
||||
CMD_TARGET_WINDOW_USAGE " [shell-command [argument ...]]",
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
@@ -74,6 +74,8 @@ cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
sc.cwd = args_get(args, 'c');
|
||||
|
||||
sc.flags = SPAWN_RESPAWN;
|
||||
if (args_has(args, 'E'))
|
||||
sc.flags |= SPAWN_EMPTY;
|
||||
if (args_has(args, 'k'))
|
||||
sc.flags |= SPAWN_KILL;
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -109,6 +109,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
window_set_active_pane(w, wp, 1);
|
||||
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||
window_pop_zoom(w);
|
||||
redraw_invalidate_scene(w);
|
||||
server_redraw_window(w);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
@@ -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>
|
||||
@@ -44,8 +44,9 @@ const struct cmd_entry cmd_run_shell_entry = {
|
||||
.name = "run-shell",
|
||||
.alias = "run",
|
||||
|
||||
.args = { "bd:Ct:", 0, 1, cmd_run_shell_args_parse },
|
||||
.usage = "[-bC] [-d delay] " CMD_TARGET_PANE_USAGE " [shell-command]",
|
||||
.args = { "bd:Ct:Es:c:", 0, -1, cmd_run_shell_args_parse },
|
||||
.usage = "[-bCE] [-c start-directory] [-d delay] " CMD_TARGET_PANE_USAGE
|
||||
" [shell-command [argument ...]]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||
|
||||
@@ -84,16 +85,23 @@ cmd_run_shell_print(struct job *job, const char *msg)
|
||||
|
||||
if (cdata->wp_id != -1)
|
||||
wp = window_pane_find_by_id(cdata->wp_id);
|
||||
if (wp == NULL && cdata->item != NULL)
|
||||
wp = server_client_get_pane(cdata->client);
|
||||
if (wp == NULL && cmd_find_from_nothing(&fs, 0) == 0)
|
||||
wp = fs.wp;
|
||||
if (wp == NULL)
|
||||
return;
|
||||
if (wp == NULL) {
|
||||
if (cdata->item != NULL) {
|
||||
cmdq_print(cdata->item, "%s", msg);
|
||||
return;
|
||||
}
|
||||
if (cdata->client != NULL && cdata->client->session != NULL)
|
||||
wp = cdata->client->session->curw->window->active;
|
||||
if (wp == NULL && cmd_find_from_nothing(&fs, 0) == 0)
|
||||
wp = fs.wp;
|
||||
if (wp == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
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_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL,
|
||||
NULL);
|
||||
window_copy_add(wp, 1, "%s", msg);
|
||||
}
|
||||
|
||||
@@ -103,13 +111,16 @@ cmd_run_shell_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 cmd_run_shell_data *cdata;
|
||||
struct client *c = cmdq_get_client(item);
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct session *s = target->s;
|
||||
struct window_pane *wp = target->wp;
|
||||
const char *delay, *cmd;
|
||||
struct format_tree *ft;
|
||||
double d;
|
||||
struct timeval tv;
|
||||
char *end;
|
||||
char *end, key[16];
|
||||
u_int i;
|
||||
int wait = !args_has(args, 'b');
|
||||
|
||||
if ((delay = args_get(args, 'd')) != NULL) {
|
||||
@@ -124,8 +135,15 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
cdata = xcalloc(1, sizeof *cdata);
|
||||
if (!args_has(args, 'C')) {
|
||||
cmd = args_string(args, 0);
|
||||
if (cmd != NULL)
|
||||
cdata->cmd = format_single_from_target(item, cmd);
|
||||
if (cmd != NULL) {
|
||||
ft = format_create_from_target(item);
|
||||
for (i = 1; i < args_count(args); i++) {
|
||||
xsnprintf(key, sizeof key, "%u", i);
|
||||
format_add(ft, key, "%s", args_string(args, i));
|
||||
}
|
||||
cdata->cmd = format_expand(ft, cmd);
|
||||
format_free(ft);
|
||||
}
|
||||
} else {
|
||||
cdata->state = args_make_commands_prepare(self, item, 0, NULL,
|
||||
wait, 1);
|
||||
@@ -137,7 +155,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
cdata->wp_id = -1;
|
||||
|
||||
if (wait) {
|
||||
cdata->client = cmdq_get_client(item);
|
||||
cdata->client = c;
|
||||
cdata->item = item;
|
||||
} else {
|
||||
cdata->client = tc;
|
||||
@@ -145,8 +163,13 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
if (cdata->client != NULL)
|
||||
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;
|
||||
if (s != NULL)
|
||||
@@ -185,8 +208,17 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg)
|
||||
}
|
||||
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)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -194,7 +226,7 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg)
|
||||
if (cmdlist == NULL) {
|
||||
if (cdata->item == NULL) {
|
||||
*error = toupper((u_char)*error);
|
||||
status_message_set(c, -1, 1, 0, "%s", error);
|
||||
status_message_set(c, -1, 1, 0, 0, "%s", error);
|
||||
} else
|
||||
cmdq_error(cdata->item, "%s", error);
|
||||
free(error);
|
||||
|
||||
@@ -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>
|
||||
@@ -65,7 +65,7 @@ cmd_save_buffer_done(__unused struct client *c, const char *path, int error,
|
||||
return;
|
||||
|
||||
if (error != 0)
|
||||
cmdq_error(item, "%s: %s", path, strerror(error));
|
||||
cmdq_error(item, "%s: %s", strerror(error), path);
|
||||
cmdq_continue(item);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,8 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
int flags;
|
||||
const char *bufname = args_get(args, 'b'), *bufdata;
|
||||
size_t bufsize;
|
||||
char *path, *tmp;
|
||||
char *path;
|
||||
struct evbuffer *evb;
|
||||
|
||||
if (bufname == NULL) {
|
||||
if ((pb = paste_get_top(NULL)) == NULL) {
|
||||
@@ -96,10 +97,12 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
if (cmd_get_entry(self) == &cmd_show_buffer_entry) {
|
||||
if (c->session != NULL || (c->flags & CLIENT_CONTROL)) {
|
||||
utf8_stravisx(&tmp, bufdata, bufsize,
|
||||
VIS_OCTAL|VIS_CSTYLE|VIS_TAB);
|
||||
cmdq_print(item, "%s", tmp);
|
||||
free(tmp);
|
||||
evb = evbuffer_new();
|
||||
if (evb == NULL)
|
||||
fatalx("out of memory");
|
||||
evbuffer_add(evb, bufdata, bufsize);
|
||||
cmdq_print_data(item, evb);
|
||||
evbuffer_free(evb);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
path = xstrdup("-");
|
||||
|
||||
@@ -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>
|
||||
@@ -90,7 +90,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
|
||||
previous = 1;
|
||||
|
||||
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)
|
||||
@@ -139,7 +139,7 @@ changed:
|
||||
free(oldlayout);
|
||||
recalculate_sizes();
|
||||
server_redraw_window(w);
|
||||
notify_window("window-layout-changed", w);
|
||||
events_fire_window("window-layout-changed", w);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
error:
|
||||
|
||||
@@ -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>
|
||||
@@ -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
|
||||
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);
|
||||
struct cmd_find_state *current = cmdq_get_current(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 window *w = wl->window;
|
||||
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;
|
||||
char *title;
|
||||
const char *style;
|
||||
struct options_entry *o;
|
||||
|
||||
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);
|
||||
if (lastwp == NULL)
|
||||
lastwp = TAILQ_NEXT(w->active, entry);
|
||||
@@ -130,32 +198,8 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 'm') || args_has(args, 'M')) {
|
||||
if (args_has(args, 'm') && !window_pane_visible(wp))
|
||||
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) {
|
||||
lastwp->flags |= (PANE_REDRAW|PANE_STYLECHANGED);
|
||||
server_redraw_window_borders(lastwp->window);
|
||||
server_status_window(lastwp->window);
|
||||
}
|
||||
if (markedwp != NULL) {
|
||||
markedwp->flags |= (PANE_REDRAW|PANE_STYLECHANGED);
|
||||
server_redraw_window_borders(markedwp->window);
|
||||
server_status_window(markedwp->window);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
if (args_has(args, 'm') || args_has(args, 'M'))
|
||||
return (cmd_select_pane_marked_pane(self, item));
|
||||
|
||||
style = args_get(args, 'P');
|
||||
if (style != NULL) {
|
||||
@@ -165,7 +209,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
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')) {
|
||||
cmdq_print(item, "%s", options_get_string(oo, "window-style"));
|
||||
@@ -207,8 +251,14 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
if (args_has(args, 'T')) {
|
||||
title = format_single_from_target(item, args_get(args, 'T'));
|
||||
if (screen_set_title(&wp->base, title)) {
|
||||
notify_pane("pane-title-changed", wp);
|
||||
if (screen_set_title(&wp->base, title, 0)) {
|
||||
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_status_window(wp->window);
|
||||
}
|
||||
@@ -216,18 +266,12 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (c != NULL && c->session != NULL && (c->flags & CLIENT_ACTIVEPANE))
|
||||
activewp = server_client_get_pane(c);
|
||||
else
|
||||
activewp = w->active;
|
||||
if (wp == activewp)
|
||||
if (wp == w->active)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
if (window_push_zoom(w, 0, args_has(args, 'Z')))
|
||||
server_redraw_window(w);
|
||||
window_redraw_active_switch(w, wp);
|
||||
if (c != NULL && c->session != NULL && (c->flags & CLIENT_ACTIVEPANE))
|
||||
server_client_set_pane(c, wp);
|
||||
else if (window_set_active_pane(w, wp, 1))
|
||||
if (window_set_active_pane(w, wp, 1))
|
||||
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||
cmdq_insert_hook(s, item, current, "after-select-pane");
|
||||
cmd_select_pane_redraw(w);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
@@ -33,13 +33,14 @@ const struct cmd_entry cmd_send_keys_entry = {
|
||||
.name = "send-keys",
|
||||
.alias = "send",
|
||||
|
||||
.args = { "FHlMN:Rt:X", 0, -1, NULL },
|
||||
.usage = "[-FHlMRX] [-N repeat-count] " CMD_TARGET_PANE_USAGE
|
||||
" key ...",
|
||||
.args = { "c:FHKlMN:Rt:X", 0, -1, NULL },
|
||||
.usage = "[-FHKlMRX] [-c target-client] [-N repeat-count] "
|
||||
CMD_TARGET_PANE_USAGE " [key ...]",
|
||||
|
||||
.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
|
||||
};
|
||||
|
||||
@@ -58,7 +59,7 @@ const struct cmd_entry cmd_send_prefix_entry = {
|
||||
|
||||
static struct cmdq_item *
|
||||
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 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 window_pane *wp = target->wp;
|
||||
struct window_mode_entry *wme;
|
||||
struct key_table *table;
|
||||
struct key_table *table = NULL;
|
||||
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);
|
||||
if (wme == NULL || wme->mode->key_table == NULL) {
|
||||
@@ -102,14 +124,16 @@ cmd_send_keys_inject_string(struct cmdq_item *item, struct cmdq_item *after,
|
||||
n = strtol(s, &endptr, 16);
|
||||
if (*s =='\0' || n < 0 || n > 0xff || *endptr != '\0')
|
||||
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');
|
||||
if (!literal) {
|
||||
key = key_string_lookup_string(s);
|
||||
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)
|
||||
return (after);
|
||||
}
|
||||
@@ -125,7 +149,8 @@ cmd_send_keys_inject_string(struct cmdq_item *item, struct cmdq_item *after,
|
||||
continue;
|
||||
key = uc;
|
||||
}
|
||||
after = cmd_send_keys_inject_key(item, after, key);
|
||||
after = cmd_send_keys_inject_key(item, after, args,
|
||||
key);
|
||||
}
|
||||
free(ud);
|
||||
}
|
||||
@@ -150,8 +175,14 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
u_int count = args_count(args);
|
||||
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')) {
|
||||
np = args_strtonum(args, 'N', 1, UINT_MAX, &cause);
|
||||
np = args_strtonum_and_expand(args, 'N', 1, UINT_MAX, item,
|
||||
&cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "repeat count %s", cause);
|
||||
free(cause);
|
||||
@@ -192,21 +223,23 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
key = options_get_number(s->options, "prefix2");
|
||||
else
|
||||
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);
|
||||
}
|
||||
|
||||
if (args_has(args, 'R')) {
|
||||
colour_palette_clear(&wp->palette);
|
||||
input_reset(wp->ictx, 1);
|
||||
wp->flags |= (PANE_STYLECHANGED|PANE_REDRAW);
|
||||
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--)
|
||||
cmd_send_keys_inject_key(item, NULL, event->key);
|
||||
after = cmd_send_keys_inject_key(item, after, args,
|
||||
event->key);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD$ */
|
||||
/* $OpenBSD: cmd-server-access.c,v 1.6 2026/06/09 12:58:40 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021 Dallas Lyons <dallasdlyons@gmail.com>
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -37,66 +38,71 @@ const struct cmd_entry cmd_server_access_entry = {
|
||||
.name = "server-access",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "adlrw", 0, 1, NULL },
|
||||
.usage = "[-adlrw] " CMD_TARGET_PANE_USAGE " [user]",
|
||||
.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, struct passwd *pw)
|
||||
cmd_server_access_deny(struct cmdq_item *item, id_t id, int flags,
|
||||
const char *type, const char *name)
|
||||
{
|
||||
struct client *loop;
|
||||
struct server_acl_user *user;
|
||||
uid_t uid;
|
||||
|
||||
if ((user = server_acl_user_find(pw->pw_uid)) == NULL) {
|
||||
cmdq_error(item, "user %s not found", pw->pw_name);
|
||||
if (!server_acl_find(id, flags)) {
|
||||
cmdq_error(item, "%s %s not found", type, name);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
TAILQ_FOREACH(loop, &clients, entry) {
|
||||
uid = proc_get_peer_uid(loop->peer);
|
||||
if (uid == server_acl_get_uid(user)) {
|
||||
loop->exit_message = xstrdup("access not allowed");
|
||||
loop->flags |= CLIENT_EXIT;
|
||||
}
|
||||
}
|
||||
server_acl_user_deny(pw->pw_uid);
|
||||
|
||||
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 *name;
|
||||
struct passwd *pw = NULL;
|
||||
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 argument");
|
||||
cmdq_error(item, "missing user or group argument");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
name = format_single(item, args_string(args, 0), c, NULL, NULL, NULL);
|
||||
if (*name != '\0')
|
||||
pw = getpwnam(name);
|
||||
if (pw == NULL) {
|
||||
cmdq_error(item, "unknown user: %s", name);
|
||||
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(name);
|
||||
free(arg);
|
||||
|
||||
if (pw->pw_uid == 0 || pw->pw_uid == getuid()) {
|
||||
if ((~flags & SERVER_ACL_IS_GROUP) && (id == 0 || id == getuid())) {
|
||||
cmdq_error(item, "%s owns the server, can't change access",
|
||||
pw->pw_name);
|
||||
name);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
@@ -110,36 +116,35 @@ cmd_server_access_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
|
||||
if (args_has(args, 'd'))
|
||||
return (cmd_server_access_deny(item, pw));
|
||||
return (cmd_server_access_deny(item, id, flags, type, name));
|
||||
if (args_has(args, 'a')) {
|
||||
if (server_acl_user_find(pw->pw_uid) != NULL) {
|
||||
cmdq_error(item, "user %s is already added",
|
||||
pw->pw_name);
|
||||
if (server_acl_find(id, flags)) {
|
||||
cmdq_error(item, "%s %s is already added", type, name);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
server_acl_user_allow(pw->pw_uid);
|
||||
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 user does not exist. */
|
||||
if (server_acl_user_find(pw->pw_uid) == NULL)
|
||||
server_acl_user_allow(pw->pw_uid);
|
||||
/* -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_user_find(pw->pw_uid) == NULL) {
|
||||
cmdq_error(item, "user %s not found", pw->pw_name);
|
||||
if (!server_acl_find(id, flags)) {
|
||||
cmdq_error(item, "%s %s not found", type, name);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
server_acl_user_allow_write(pw->pw_uid);
|
||||
server_acl_allow_write(id, flags);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 'r')) {
|
||||
if (server_acl_user_find(pw->pw_uid) == NULL) {
|
||||
cmdq_error(item, "user %s not found", pw->pw_name);
|
||||
if (!server_acl_find(id, flags)) {
|
||||
cmdq_error(item, "%s %s not found", type, name);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
server_acl_user_deny_write(pw->pw_uid);
|
||||
server_acl_deny_write(id, flags);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -35,7 +35,7 @@ const struct cmd_entry cmd_set_buffer_entry = {
|
||||
|
||||
.args = { "ab:t:n:w", 0, 1, NULL },
|
||||
.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,
|
||||
.exec = cmd_set_buffer_exec
|
||||
@@ -57,53 +57,59 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct paste_buffer *pb;
|
||||
char *bufdata, *cause;
|
||||
const char *bufname, *olddata;
|
||||
size_t bufsize, newsize;
|
||||
struct paste_buffer *pb = NULL;
|
||||
char *bufname = NULL, *bufdata = NULL, *cause = NULL;
|
||||
const char *olddata;
|
||||
size_t bufsize = 0, newsize;
|
||||
|
||||
bufname = args_get(args, 'b');
|
||||
if (bufname == NULL)
|
||||
pb = NULL;
|
||||
else
|
||||
if (args_get(args, 'b') != NULL) {
|
||||
bufname = xstrdup(args_get(args, 'b'));
|
||||
pb = paste_get_name(bufname);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if (pb == NULL) {
|
||||
cmdq_error(item, "no buffer");
|
||||
return (CMD_RETURN_ERROR);
|
||||
goto fail;
|
||||
}
|
||||
paste_free(pb);
|
||||
free(bufname);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if (pb == NULL) {
|
||||
cmdq_error(item, "no buffer");
|
||||
return (CMD_RETURN_ERROR);
|
||||
goto fail;
|
||||
}
|
||||
if (paste_rename(bufname, args_get(args, 'n'), &cause) != 0) {
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
goto fail;
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_count(args) != 1) {
|
||||
cmdq_error(item, "no data specified");
|
||||
return (CMD_RETURN_ERROR);
|
||||
goto fail;
|
||||
}
|
||||
if ((newsize = strlen(args_string(args, 0))) == 0)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
bufsize = 0;
|
||||
bufdata = NULL;
|
||||
|
||||
if (args_has(args, 'a') && pb != NULL) {
|
||||
olddata = paste_buffer_data(pb, &bufsize);
|
||||
bufdata = xmalloc(bufsize);
|
||||
@@ -116,12 +122,16 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
if (paste_set(bufdata, bufsize, bufname, &cause) != 0) {
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(bufdata);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
goto fail;
|
||||
}
|
||||
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);
|
||||
|
||||
fail:
|
||||
free(bufdata);
|
||||
free(bufname);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -35,7 +35,7 @@ const struct cmd_entry cmd_set_environment_entry = {
|
||||
.alias = "setenv",
|
||||
|
||||
.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 },
|
||||
|
||||
|
||||
196
cmd-set-option.c
196
cmd-set-option.c
@@ -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>
|
||||
@@ -31,6 +31,10 @@ 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 = {
|
||||
.name = "set-option",
|
||||
@@ -62,8 +66,9 @@ const struct cmd_entry cmd_set_hook_entry = {
|
||||
.name = "set-hook",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "agpRt:uw", 1, 2, cmd_set_option_args_parse },
|
||||
.usage = "[-agpRuw] " CMD_TARGET_PANE_USAGE " hook [command]",
|
||||
.args = { "agpERTt:uB:w", 0, 2, cmd_set_option_args_parse },
|
||||
.usage = "[-agpERTuw] [-B name:what:format] " CMD_TARGET_PANE_USAGE " "
|
||||
"[hook] [command]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||
|
||||
@@ -72,14 +77,152 @@ const struct cmd_entry cmd_set_hook_entry = {
|
||||
};
|
||||
|
||||
static enum args_parse_type
|
||||
cmd_set_option_args_parse(__unused struct args *args, u_int idx,
|
||||
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
|
||||
cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
@@ -89,26 +232,34 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct window_pane *loop;
|
||||
struct options *oo;
|
||||
struct options_entry *parent, *o, *po;
|
||||
char *name, *argument, *expanded = NULL;
|
||||
char *cause;
|
||||
char *name, *argument, *cause;
|
||||
char *expanded = NULL, *array_key = NULL;
|
||||
const char *value;
|
||||
int window, idx, already, error, ambiguous;
|
||||
int window, already, error, ambiguous;
|
||||
int scope;
|
||||
|
||||
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. */
|
||||
argument = format_single_from_target(item, args_string(args, 0));
|
||||
|
||||
/* If set-hook -R, fire the hook straight away. */
|
||||
if (cmd_get_entry(self) == &cmd_set_hook_entry && args_has(args, 'R')) {
|
||||
notify_hook(item, argument);
|
||||
hooks_run(item, argument);
|
||||
free(argument);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
/* Parse option name and index. */
|
||||
name = options_match(argument, &idx, &ambiguous);
|
||||
/* Parse option name and array key. */
|
||||
name = options_match(argument, &array_key, &ambiguous);
|
||||
if (name == NULL) {
|
||||
if (args_has(args, 'q'))
|
||||
goto out;
|
||||
@@ -140,21 +291,23 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||
o = options_get_only(oo, name);
|
||||
parent = options_get(oo, name);
|
||||
|
||||
/* Check that array options and indexes match up. */
|
||||
if (idx != -1 && (*name == '@' || !options_is_array(parent))) {
|
||||
/* Check that array options and keys match up. */
|
||||
if (array_key != NULL && (*name == '@' || !options_is_array(parent))) {
|
||||
cmdq_error(item, "not an array: %s", argument);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* With -o, check this option is not already set. */
|
||||
if (!args_has(args, 'u') && args_has(args, 'o')) {
|
||||
if (idx == -1)
|
||||
if (array_key == NULL)
|
||||
already = (o != NULL);
|
||||
else {
|
||||
if (o == NULL)
|
||||
already = 0;
|
||||
else if (options_array_get(o, array_key) != NULL)
|
||||
already = 1;
|
||||
else
|
||||
already = (options_array_get(o, idx) != NULL);
|
||||
already = 0;
|
||||
}
|
||||
if (already) {
|
||||
if (args_has(args, 'q'))
|
||||
@@ -170,7 +323,8 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||
po = options_get_only(loop->options, name);
|
||||
if (po == NULL)
|
||||
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);
|
||||
free(cause);
|
||||
goto fail;
|
||||
@@ -180,7 +334,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (args_has(args, 'u') || args_has(args, 'U')) {
|
||||
if (o == NULL)
|
||||
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);
|
||||
free(cause);
|
||||
goto fail;
|
||||
@@ -191,7 +345,9 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||
goto fail;
|
||||
}
|
||||
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),
|
||||
options_table_entry(parent)->name, value,
|
||||
args_has(args, 'a'), &cause);
|
||||
@@ -207,7 +363,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
if (o == NULL)
|
||||
o = options_empty(oo, options_table_entry(parent));
|
||||
if (idx == -1) {
|
||||
if (array_key == NULL) {
|
||||
if (!append)
|
||||
options_array_clear(o);
|
||||
if (options_array_assign(o, value, &cause) != 0) {
|
||||
@@ -215,7 +371,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||
free(cause);
|
||||
goto fail;
|
||||
}
|
||||
} else if (options_array_set(o, idx, value, append,
|
||||
} else if (options_array_set(o, array_key, value, append,
|
||||
&cause) != 0) {
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
@@ -229,11 +385,13 @@ out:
|
||||
free(argument);
|
||||
free(expanded);
|
||||
free(name);
|
||||
free(array_key);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
fail:
|
||||
free(argument);
|
||||
free(expanded);
|
||||
free(name);
|
||||
free(array_key);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -39,7 +39,7 @@ const struct cmd_entry cmd_show_environment_entry = {
|
||||
.alias = "showenv",
|
||||
|
||||
.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 },
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_show_messages_entry = {
|
||||
.args = { "JTt:", 0, 0, NULL },
|
||||
.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
|
||||
};
|
||||
|
||||
@@ -55,7 +55,7 @@ cmd_show_messages_terminals(struct cmd *self, struct cmdq_item *item, int blank)
|
||||
|
||||
n = 0;
|
||||
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;
|
||||
if (blank) {
|
||||
cmdq_print(item, "%s", "");
|
||||
|
||||
@@ -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>
|
||||
@@ -27,10 +27,23 @@
|
||||
* 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 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 *,
|
||||
int, struct options *);
|
||||
|
||||
@@ -38,8 +51,8 @@ const struct cmd_entry cmd_show_options_entry = {
|
||||
.name = "show-options",
|
||||
.alias = "show",
|
||||
|
||||
.args = { "AgHpqst:vw", 0, 1, NULL },
|
||||
.usage = "[-AgHpqsvw] " CMD_TARGET_PANE_USAGE " [option]",
|
||||
.args = { "AgF:Hpqst:vw", 0, 1, NULL },
|
||||
.usage = "[-AgHpqsvw] [-F format] " CMD_TARGET_PANE_USAGE " [option]",
|
||||
|
||||
.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",
|
||||
.alias = "showw",
|
||||
|
||||
.args = { "gvt:", 0, 1, NULL },
|
||||
.usage = "[-gv] " CMD_TARGET_WINDOW_USAGE " [option]",
|
||||
.args = { "F:gvt:", 0, 1, NULL },
|
||||
.usage = "[-gv] [-F format] " CMD_TARGET_WINDOW_USAGE " [option]",
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
|
||||
|
||||
@@ -64,8 +77,8 @@ const struct cmd_entry cmd_show_hooks_entry = {
|
||||
.name = "show-hooks",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "gpt:w", 0, 1, NULL },
|
||||
.usage = "[-gpw] " CMD_TARGET_PANE_USAGE,
|
||||
.args = { "BF:gpt:w", 0, 1, NULL },
|
||||
.usage = "[-Bgpw] [-F format] " CMD_TARGET_PANE_USAGE " [hook]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||
|
||||
@@ -80,7 +93,8 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct options *oo;
|
||||
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;
|
||||
|
||||
window = (cmd_get_entry(self) == &cmd_show_window_options_entry);
|
||||
@@ -95,11 +109,20 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
||||
free(cause);
|
||||
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));
|
||||
}
|
||||
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 (args_has(args, 'q'))
|
||||
goto out;
|
||||
@@ -124,9 +147,20 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
||||
parent = 1;
|
||||
} else
|
||||
parent = 0;
|
||||
if (o != NULL)
|
||||
cmd_show_options_print(self, item, o, idx, parent);
|
||||
else if (*name == '@') {
|
||||
if (o != NULL) {
|
||||
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);
|
||||
@@ -135,64 +169,171 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
out:
|
||||
free(name);
|
||||
free(array_key);
|
||||
free(argument);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
fail:
|
||||
free(name);
|
||||
free(array_key);
|
||||
free(argument);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
static void
|
||||
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 options_array_item *a;
|
||||
const char *name = options_name(o);
|
||||
char *value, *tmp = NULL, *escaped;
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct options_array_item *a;
|
||||
struct format_tree *ft;
|
||||
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) {
|
||||
xasprintf(&tmp, "%s[%d]", name, idx);
|
||||
name = tmp;
|
||||
} else {
|
||||
if (options_is_array(o)) {
|
||||
a = options_array_first(o);
|
||||
if (a == NULL) {
|
||||
if (!args_has(args, 'v'))
|
||||
cmdq_print(item, "%s", name);
|
||||
return;
|
||||
}
|
||||
if (array_key != NULL)
|
||||
value = options_to_string(o, array_key, 0);
|
||||
else if (options_is_array(o)) {
|
||||
a = options_array_first(o);
|
||||
if (a != NULL) {
|
||||
while (a != NULL) {
|
||||
idx = options_array_item_index(a);
|
||||
cmd_show_options_print(self, item, o, idx,
|
||||
array_key = options_array_item_key(a);
|
||||
cmd_show_options_print(self, item, o, array_key,
|
||||
parent);
|
||||
a = options_array_next(a);
|
||||
}
|
||||
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 (args_has(args, 'v'))
|
||||
cmdq_print(item, "%s", value);
|
||||
else if (options_is_string(o)) {
|
||||
escaped = args_escape(value);
|
||||
if (parent)
|
||||
cmdq_print(item, "%s* %s", name, escaped);
|
||||
else
|
||||
cmdq_print(item, "%s %s", name, escaped);
|
||||
free(escaped);
|
||||
if (template == NULL)
|
||||
template = SHOW_OPTIONS_TEMPLATE;
|
||||
|
||||
if (oe != NULL && (oe->flags & OPTIONS_TABLE_IS_HOOK))
|
||||
is_hook = 1;
|
||||
else if (oe == NULL)
|
||||
is_user = 1;
|
||||
|
||||
ft = format_create_from_target(item);
|
||||
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 {
|
||||
if (parent)
|
||||
cmdq_print(item, "%s* %s", name, value);
|
||||
else
|
||||
cmdq_print(item, "%s %s", name, value);
|
||||
format_add(ft, "option_array_key", "%s", "");
|
||||
format_add(ft, "option_has_array_key", "0");
|
||||
}
|
||||
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
|
||||
@@ -202,18 +343,29 @@ cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope,
|
||||
struct args *args = cmd_get_args(self);
|
||||
const struct options_table_entry *oe;
|
||||
struct options_entry *o;
|
||||
struct options_array_item *a;
|
||||
const char *name;
|
||||
u_int idx;
|
||||
int parent;
|
||||
int parent, is_user_hook;
|
||||
|
||||
if (cmd_get_entry(self) != &cmd_show_hooks_entry) {
|
||||
o = options_first(oo);
|
||||
while (o != NULL) {
|
||||
if (options_table_entry(o) == NULL)
|
||||
cmd_show_options_print(self, item, o, -1, 0);
|
||||
o = options_next(o);
|
||||
o = options_first(oo);
|
||||
while (o != NULL) {
|
||||
if (options_table_entry(o) == NULL) {
|
||||
name = options_name(o);
|
||||
is_user_hook = 0;
|
||||
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++) {
|
||||
if (~oe->scope & scope)
|
||||
@@ -237,24 +389,7 @@ cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope,
|
||||
} else
|
||||
parent = 0;
|
||||
|
||||
if (!options_is_array(o))
|
||||
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);
|
||||
}
|
||||
}
|
||||
cmd_show_options_print(self, item, o, NULL, parent);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD$ */
|
||||
/* $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>
|
||||
@@ -32,7 +32,7 @@ const struct cmd_entry cmd_show_prompt_history_entry = {
|
||||
.alias = "showphist",
|
||||
|
||||
.args = { "T:", 0, 0, NULL },
|
||||
.usage = "[-T type]",
|
||||
.usage = "[-T prompt-type]",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_show_prompt_history_exec
|
||||
@@ -43,7 +43,7 @@ const struct cmd_entry cmd_clear_prompt_history_entry = {
|
||||
.alias = "clearphist",
|
||||
|
||||
.args = { "T:", 0, 0, NULL },
|
||||
.usage = "[-T type]",
|
||||
.usage = "[-T prompt-type]",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_show_prompt_history_exec
|
||||
@@ -55,51 +55,44 @@ 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 tidx, hidx;
|
||||
u_int t, h;
|
||||
const char *v;
|
||||
|
||||
if (cmd_get_entry(self) == &cmd_clear_prompt_history_entry) {
|
||||
if (typestr == NULL) {
|
||||
for (tidx = 0; tidx < PROMPT_NTYPES; tidx++) {
|
||||
free(status_prompt_hlist[tidx]);
|
||||
status_prompt_hlist[tidx] = NULL;
|
||||
status_prompt_hsize[tidx] = 0;
|
||||
}
|
||||
for (t = 0; t < PROMPT_NTYPES; t++)
|
||||
prompt_history_clear(t);
|
||||
} else {
|
||||
type = status_prompt_type(typestr);
|
||||
type = prompt_type(typestr);
|
||||
if (type == PROMPT_TYPE_INVALID) {
|
||||
cmdq_error(item, "invalid type: %s", typestr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
free(status_prompt_hlist[type]);
|
||||
status_prompt_hlist[type] = NULL;
|
||||
status_prompt_hsize[type] = 0;
|
||||
prompt_history_clear(type);
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (typestr == NULL) {
|
||||
for (tidx = 0; tidx < PROMPT_NTYPES; tidx++) {
|
||||
cmdq_print(item, "History for %s:\n",
|
||||
status_prompt_type_string(tidx));
|
||||
for (hidx = 0; hidx < status_prompt_hsize[tidx];
|
||||
hidx++) {
|
||||
cmdq_print(item, "%d: %s", hidx + 1,
|
||||
status_prompt_hlist[tidx][hidx]);
|
||||
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 = status_prompt_type(typestr);
|
||||
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",
|
||||
status_prompt_type_string(type));
|
||||
for (hidx = 0; hidx < status_prompt_hsize[type]; hidx++) {
|
||||
cmdq_print(item, "%d: %s", hidx + 1,
|
||||
status_prompt_hlist[type][hidx]);
|
||||
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", "");
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <glob.h>
|
||||
#include <stdlib.h>
|
||||
@@ -29,14 +30,19 @@
|
||||
* 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 *);
|
||||
|
||||
const struct cmd_entry cmd_source_file_entry = {
|
||||
.name = "source-file",
|
||||
.alias = "source",
|
||||
|
||||
.args = { "Fnqv", 1, -1, NULL },
|
||||
.usage = "[-Fnqv] path ...",
|
||||
.args = { "t:Fnqv", 1, -1, NULL },
|
||||
.usage = "[-Fnqv] " CMD_TARGET_PANE_USAGE " path ...",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_source_file_exec
|
||||
@@ -57,6 +63,16 @@ struct cmd_source_file_data {
|
||||
static enum cmd_retval
|
||||
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);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
@@ -92,15 +108,16 @@ cmd_source_file_done(struct client *c, const char *path, int error,
|
||||
size_t bsize = EVBUFFER_LENGTH(buffer);
|
||||
u_int n;
|
||||
struct cmdq_item *new_item;
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
|
||||
if (!closed)
|
||||
return;
|
||||
|
||||
if (error != 0)
|
||||
cmdq_error(item, "%s: %s", path, strerror(error));
|
||||
cmdq_error(item, "%s: %s", strerror(error), path);
|
||||
else if (bsize != 0) {
|
||||
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;
|
||||
else if (new_item != NULL)
|
||||
cdata->after = new_item;
|
||||
@@ -124,6 +141,21 @@ cmd_source_file_add(struct cmd_source_file_data *cdata, const char *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
|
||||
cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
@@ -134,9 +166,25 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
||||
char *pattern, *cwd, *expanded = NULL;
|
||||
const char *path, *error;
|
||||
glob_t g;
|
||||
int result;
|
||||
int result, parse_flags;
|
||||
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->item = item;
|
||||
|
||||
@@ -144,10 +192,13 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
||||
cdata->flags |= CMD_PARSE_QUIET;
|
||||
if (args_has(args, 'n'))
|
||||
cdata->flags |= CMD_PARSE_PARSEONLY;
|
||||
if (args_has(args, 'v'))
|
||||
cdata->flags |= CMD_PARSE_VERBOSE;
|
||||
if (c == NULL || ~c->flags & CLIENT_CONTROL) {
|
||||
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_count(args); i++) {
|
||||
path = args_string(args, i);
|
||||
@@ -176,7 +227,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
||||
error = strerror(ENOMEM);
|
||||
else
|
||||
error = strerror(EINVAL);
|
||||
cmdq_error(item, "%s: %s", path, error);
|
||||
cmdq_error(item, "%s: %s", error, path);
|
||||
retval = CMD_RETURN_ERROR;
|
||||
}
|
||||
globfree(&g);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD$ */
|
||||
/* $OpenBSD: cmd-split-window.c,v 1.148 2026/08/07 08:10:53 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
@@ -27,22 +27,44 @@
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Split a window (add a new pane).
|
||||
* Create a new pane.
|
||||
*/
|
||||
|
||||
#define SPLIT_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||
|
||||
static enum cmd_retval cmd_split_window_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
static enum cmd_retval cmd_split_window_exec(struct cmd *, 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 = {
|
||||
.name = "split-window",
|
||||
.alias = "splitw",
|
||||
|
||||
.args = { "bc:de:fF:hIl:p:Pt:vZ", 0, -1, NULL },
|
||||
.usage = "[-bdefhIPvZ] [-c start-directory] [-e environment] "
|
||||
"[-F format] [-l size] " CMD_TARGET_PANE_USAGE
|
||||
"[shell-command]",
|
||||
.args = { "bB:c:de:EfF:hIkl:m:p:PR:s:S:t:T:vWZ", 0, -1, NULL },
|
||||
.usage = "[-bdefhIklPvWZ] [-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] "
|
||||
CMD_TARGET_PANE_USAGE " [shell-command [argument ...]]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
@@ -61,86 +83,92 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct session *s = target->s;
|
||||
struct winlink *wl = target->wl;
|
||||
struct window *w = wl->window;
|
||||
struct window_pane *wp = target->wp, *new_wp;
|
||||
enum layout_type type;
|
||||
struct layout_cell *lc;
|
||||
struct window_pane *wp = target->wp, *new_wp = NULL;
|
||||
struct layout_cell *lc = NULL;
|
||||
struct event_payload *ep;
|
||||
struct cmd_find_state fs;
|
||||
int size, percentage, flags, input;
|
||||
const char *template, *errstr, *p;
|
||||
char *cause, *cp, *copy;
|
||||
size_t plen;
|
||||
struct key_event *event = cmdq_get_event(item);
|
||||
int input, empty, is_floating, flags = 0;
|
||||
const char *template, *style, *value;
|
||||
char *cause = NULL, *cp, *title;
|
||||
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'))
|
||||
type = LAYOUT_LEFTRIGHT;
|
||||
else
|
||||
type = LAYOUT_TOPBOTTOM;
|
||||
if ((p = args_get(args, 'l')) != NULL) {
|
||||
plen = strlen(p);
|
||||
if (p[plen - 1] == '%') {
|
||||
copy = xstrdup(p);
|
||||
copy[plen - 1] = '\0';
|
||||
percentage = strtonum(copy, 0, INT_MAX, &errstr);
|
||||
free(copy);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(item, "percentage %s", errstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (args_has(args, 'f')) {
|
||||
if (type == LAYOUT_TOPBOTTOM)
|
||||
size = (w->sy * percentage) / 100;
|
||||
else
|
||||
size = (w->sx * percentage) / 100;
|
||||
} else {
|
||||
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);
|
||||
if (cmd_get_entry(self) == &cmd_new_pane_entry)
|
||||
is_floating = !args_has(args, 'L');
|
||||
else {
|
||||
window_unzoom(w, 1);
|
||||
is_floating = window_pane_is_floating(wp);
|
||||
flags |= SPAWN_SPLIT;
|
||||
}
|
||||
|
||||
if (args_has(args, 'O')) {
|
||||
if (!is_floating) {
|
||||
cmdq_error(item, "modal pane must be floating");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (args_has(args, 'f')) {
|
||||
if (type == LAYOUT_TOPBOTTOM)
|
||||
size = (w->sy * percentage) / 100;
|
||||
else
|
||||
size = (w->sx * percentage) / 100;
|
||||
} else {
|
||||
if (type == LAYOUT_TOPBOTTOM)
|
||||
size = (wp->sy * percentage) / 100;
|
||||
else
|
||||
size = (wp->sx * percentage) / 100;
|
||||
if (w->modal != NULL) {
|
||||
cmdq_error(item, "window already has a modal pane");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else
|
||||
size = -1;
|
||||
}
|
||||
|
||||
window_push_zoom(wp->window, 1, args_has(args, 'Z'));
|
||||
input = (args_has(args, 'I') && count == 0);
|
||||
if (args_has(args, 'M') && is_floating) {
|
||||
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'))
|
||||
flags |= SPAWN_BEFORE;
|
||||
if (args_has(args, 'f'))
|
||||
flags |= SPAWN_FULLSIZE;
|
||||
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;
|
||||
|
||||
lc = layout_split_pane(wp, type, size, flags);
|
||||
if (lc == NULL) {
|
||||
cmdq_error(item, "no space for new pane");
|
||||
if ((value = args_get(args, 'B')) == NULL)
|
||||
lines = window_get_pane_lines(w);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -162,43 +190,98 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
sc.idx = -1;
|
||||
sc.cwd = args_get(args, 'c');
|
||||
|
||||
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) {
|
||||
cmdq_error(item, "create pane failed: %s", cause);
|
||||
free(cause);
|
||||
if (sc.argv != NULL)
|
||||
cmd_free_argv(sc.argc, sc.argv);
|
||||
environ_free(sc.environ);
|
||||
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 (args_has(args, 'C') && args_has(args, 'O'))
|
||||
new_wp->flags |= PANE_CLOSEONCLICK;
|
||||
|
||||
style = args_get(args, 's');
|
||||
if (style != NULL) {
|
||||
if (options_set_string(new_wp->options, "window-style", 0,
|
||||
"%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);
|
||||
}
|
||||
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:
|
||||
server_client_remove_pane(new_wp);
|
||||
layout_close_pane(new_wp);
|
||||
window_remove_pane(wp->window, new_wp);
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
if (sc.argv != NULL)
|
||||
cmd_free_argv(sc.argc, sc.argv);
|
||||
environ_free(sc.environ);
|
||||
return (CMD_RETURN_ERROR);
|
||||
goto fail;
|
||||
case 1:
|
||||
input = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!args_has(args, 'd'))
|
||||
if (~flags & SPAWN_DETACHED)
|
||||
cmd_find_from_winlink_pane(current, wl, new_wp, 0);
|
||||
window_pop_zoom(wp->window);
|
||||
server_redraw_window(wp->window);
|
||||
server_status_session(s);
|
||||
|
||||
if ((~flags & SPAWN_FLOATING) && !args_has(args, 'O')) {
|
||||
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 ((template = args_get(args, 'F')) == NULL)
|
||||
@@ -216,5 +299,105 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
environ_free(sc.environ);
|
||||
if (input)
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -42,6 +42,22 @@ const struct cmd_entry cmd_swap_pane_entry = {
|
||||
.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
|
||||
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 layout_cell *src_lc, *dst_lc;
|
||||
u_int sx, sy, xoff, yoff;
|
||||
int src_idx, dst_idx;
|
||||
|
||||
dst_w = target->wl->window;
|
||||
dst_wp = target->wp;
|
||||
dst_idx = target->wl->idx;
|
||||
src_w = source->wl->window;
|
||||
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')))
|
||||
server_redraw_window(dst_w);
|
||||
|
||||
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_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 = cmd_swap_pane_next_tiled_pane(src_wp);
|
||||
}
|
||||
} 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_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 = cmd_swap_pane_prev_tiled_pane(src_wp);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
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;
|
||||
dst_lc = dst_wp->layout_cell;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
xoff = src_wp->xoff; yoff = src_wp->yoff;
|
||||
@@ -128,16 +176,25 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
window_set_active_pane(dst_w, src_wp, 1);
|
||||
}
|
||||
if (src_w != dst_w) {
|
||||
if (src_w->last == src_wp)
|
||||
src_w->last = NULL;
|
||||
if (dst_w->last == dst_wp)
|
||||
dst_w->last = NULL;
|
||||
window_pane_stack_remove(&src_w->last_panes, src_wp);
|
||||
window_pane_stack_remove(&dst_w->last_panes, dst_wp);
|
||||
colour_palette_from_option(&src_wp->palette, src_wp->options);
|
||||
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);
|
||||
notify_window("window-layout-changed", src_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)
|
||||
notify_window("window-layout-changed", dst_w);
|
||||
events_fire_window("window-layout-changed", dst_w);
|
||||
|
||||
out:
|
||||
if (window_pop_zoom(src_w))
|
||||
|
||||
@@ -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>
|
||||
@@ -38,7 +38,7 @@ const struct cmd_entry cmd_swap_window_entry = {
|
||||
.source = { 's', CMD_FIND_WINDOW, CMD_FIND_DEFAULT_MARKED },
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.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;
|
||||
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')) {
|
||||
session_select(dst, wl_dst->idx);
|
||||
if (src != dst)
|
||||
|
||||
@@ -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>
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@@ -34,9 +35,9 @@ const struct cmd_entry cmd_switch_client_entry = {
|
||||
.name = "switch-client",
|
||||
.alias = "switchc",
|
||||
|
||||
.args = { "lc:EFnpt:rT:Z", 0, 0, NULL },
|
||||
.args = { "c:EFlnO:pt:rT:Z", 0, 0, NULL },
|
||||
.usage = "[-ElnprZ] [-c target-client] [-t target-session] "
|
||||
"[-T key-table]",
|
||||
"[-T key-table] [-O order]",
|
||||
|
||||
/* -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');
|
||||
enum cmd_find_type type;
|
||||
int flags;
|
||||
struct client *c = cmdq_get_client(item);
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
@@ -60,8 +62,11 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct window_pane *wp;
|
||||
const char *tablename;
|
||||
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;
|
||||
flags = 0;
|
||||
} else {
|
||||
@@ -75,6 +80,13 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
wp = target.wp;
|
||||
|
||||
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)
|
||||
tc->flags &= ~(CLIENT_READONLY|CLIENT_IGNORESIZE);
|
||||
else
|
||||
@@ -94,13 +106,22 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
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 ((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");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} 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");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
261
cmd-wait-for.c
261
cmd-wait-for.c
@@ -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>
|
||||
@@ -34,8 +34,8 @@ const struct cmd_entry cmd_wait_for_entry = {
|
||||
.name = "wait-for",
|
||||
.alias = "wait",
|
||||
|
||||
.args = { "LSU", 1, 1, NULL },
|
||||
.usage = "[-L|-S|-U] channel",
|
||||
.args = { "EF:LSUlvw:", 1, 1, NULL },
|
||||
.usage = "[-ELSUlv] [-F format] [-w waiter] name",
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_wait_for_exec
|
||||
@@ -46,6 +46,17 @@ struct wait_item {
|
||||
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 {
|
||||
const char *name;
|
||||
int locked;
|
||||
@@ -76,9 +87,28 @@ static enum cmd_retval cmd_wait_for_lock(struct cmdq_item *, const char *,
|
||||
struct wait_channel *);
|
||||
static enum cmd_retval cmd_wait_for_unlock(struct cmdq_item *, const char *,
|
||||
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 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 *
|
||||
cmd_wait_for_add(const char *name)
|
||||
@@ -117,16 +147,53 @@ cmd_wait_for_remove(struct wait_channel *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
|
||||
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_string(args, 0);
|
||||
struct wait_channel *wc, find;
|
||||
struct wait_channel *wc, find = { .name = name };
|
||||
|
||||
if (args_has(args, 'E'))
|
||||
return (cmd_wait_for_event(item, name, args));
|
||||
|
||||
find.name = name;
|
||||
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'))
|
||||
return (cmd_wait_for_signal(item, name, wc));
|
||||
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));
|
||||
}
|
||||
|
||||
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
|
||||
cmd_wait_for_signal(__unused struct cmdq_item *item, const char *name,
|
||||
struct wait_channel *wc)
|
||||
@@ -245,6 +485,13 @@ cmd_wait_for_flush(void)
|
||||
{
|
||||
struct wait_channel *wc, *wc1;
|
||||
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) {
|
||||
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
|
||||
|
||||
117
cmd.c
117
cmd.c
@@ -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>
|
||||
@@ -47,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_popup_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_has_session_entry;
|
||||
extern const struct cmd_entry cmd_if_shell_entry;
|
||||
@@ -72,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_move_pane_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_window_entry;
|
||||
extern const struct cmd_entry cmd_next_layout_entry;
|
||||
@@ -115,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_window_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_unlink_window_entry;
|
||||
extern const struct cmd_entry cmd_up_pane_entry;
|
||||
extern const struct cmd_entry cmd_wait_for_entry;
|
||||
|
||||
const struct cmd_entry *cmd_table[] = {
|
||||
@@ -165,6 +165,7 @@ const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_lock_session_entry,
|
||||
&cmd_move_pane_entry,
|
||||
&cmd_move_window_entry,
|
||||
&cmd_new_pane_entry,
|
||||
&cmd_new_session_entry,
|
||||
&cmd_new_window_entry,
|
||||
&cmd_next_layout_entry,
|
||||
@@ -208,6 +209,7 @@ const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_swap_pane_entry,
|
||||
&cmd_swap_window_entry,
|
||||
&cmd_switch_client_entry,
|
||||
&cmd_switch_mode_entry,
|
||||
&cmd_unbind_key_entry,
|
||||
&cmd_unlink_window_entry,
|
||||
&cmd_wait_for_entry,
|
||||
@@ -222,6 +224,7 @@ struct cmd {
|
||||
|
||||
char *file;
|
||||
u_int line;
|
||||
int parse_flags;
|
||||
|
||||
TAILQ_ENTRY(cmd) qentry;
|
||||
};
|
||||
@@ -304,6 +307,8 @@ cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv)
|
||||
|
||||
if (argc == 0)
|
||||
return (0);
|
||||
if (argc < 0 || argc > 1000)
|
||||
return (-1);
|
||||
*argv = xcalloc(argc, sizeof **argv);
|
||||
|
||||
buf[len - 1] = '\0';
|
||||
@@ -414,6 +419,13 @@ cmd_get_source(struct cmd *cmd, const char **file, u_int *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. */
|
||||
char *
|
||||
cmd_get_alias(const char *name)
|
||||
@@ -446,7 +458,7 @@ cmd_get_alias(const char *name)
|
||||
}
|
||||
|
||||
/* Look up a command entry by name. */
|
||||
static const struct cmd_entry *
|
||||
const struct cmd_entry *
|
||||
cmd_find(const char *name, char **cause)
|
||||
{
|
||||
const struct cmd_entry **loop, *entry, *found = NULL;
|
||||
@@ -498,7 +510,7 @@ ambiguous:
|
||||
/* Parse a single command from an argument vector. */
|
||||
struct cmd *
|
||||
cmd_parse(struct args_value *values, u_int count, const char *file, u_int line,
|
||||
char **cause)
|
||||
int parse_flags, char **cause)
|
||||
{
|
||||
const struct cmd_entry *entry;
|
||||
struct cmd *cmd;
|
||||
@@ -527,6 +539,7 @@ cmd_parse(struct args_value *values, u_int count, const char *file, u_int line,
|
||||
cmd = xcalloc(1, sizeof *cmd);
|
||||
cmd->entry = entry;
|
||||
cmd->args = args;
|
||||
cmd->parse_flags = parse_flags;
|
||||
|
||||
if (file != NULL)
|
||||
cmd->file = xstrdup(file);
|
||||
@@ -638,7 +651,7 @@ cmd_list_free(struct cmd_list *cmdlist)
|
||||
|
||||
/* Copy a command list, expanding %s in arguments. */
|
||||
struct cmd_list *
|
||||
cmd_list_copy(struct cmd_list *cmdlist, int argc, char **argv)
|
||||
cmd_list_copy(const struct cmd_list *cmdlist, int argc, char **argv)
|
||||
{
|
||||
struct cmd *cmd;
|
||||
struct cmd_list *new_cmdlist;
|
||||
@@ -669,11 +682,16 @@ cmd_list_copy(struct cmd_list *cmdlist, int argc, char **argv)
|
||||
|
||||
/* Get a command list as a string. */
|
||||
char *
|
||||
cmd_list_print(struct cmd_list *cmdlist, int escaped)
|
||||
cmd_list_print(const struct cmd_list *cmdlist, int flags)
|
||||
{
|
||||
struct cmd *cmd, *next;
|
||||
char *buf, *this;
|
||||
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;
|
||||
buf = xcalloc(1, len);
|
||||
@@ -688,17 +706,11 @@ cmd_list_print(struct cmd_list *cmdlist, int escaped)
|
||||
|
||||
next = TAILQ_NEXT(cmd, qentry);
|
||||
if (next != NULL) {
|
||||
if (cmd->group != next->group) {
|
||||
if (escaped)
|
||||
strlcat(buf, " \\;\\; ", len);
|
||||
else
|
||||
strlcat(buf, " ;; ", len);
|
||||
} else {
|
||||
if (escaped)
|
||||
strlcat(buf, " \\; ", len);
|
||||
else
|
||||
strlcat(buf, " ; ", len);
|
||||
}
|
||||
if (!no_groups && cmd->group != next->group)
|
||||
separator = double_separator;
|
||||
else
|
||||
separator = single_separator;
|
||||
strlcat(buf, separator, len);
|
||||
}
|
||||
|
||||
free(this);
|
||||
@@ -766,9 +778,9 @@ cmd_mouse_at(struct window_pane *wp, struct mouse_event *m, u_int *xp,
|
||||
if (m->statusat == 0 && 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);
|
||||
if (y < wp->yoff || y >= wp->yoff + wp->sy)
|
||||
if ((int)y < wp->yoff || (int)y >= wp->yoff + (int)wp->sy)
|
||||
return (-1);
|
||||
|
||||
if (xp != NULL)
|
||||
@@ -812,9 +824,15 @@ cmd_mouse_pane(struct mouse_event *m, struct session **sp,
|
||||
|
||||
if ((wl = cmd_mouse_window(m, sp)) == NULL)
|
||||
return (NULL);
|
||||
if ((wp = window_pane_find_by_id(m->wp)) == NULL)
|
||||
return (NULL);
|
||||
if (!window_has_pane(wl->window, wp))
|
||||
if (m->wp == -1)
|
||||
wp = wl->window->active;
|
||||
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);
|
||||
|
||||
if (wlp != NULL)
|
||||
@@ -822,14 +840,19 @@ cmd_mouse_pane(struct mouse_event *m, struct session **sp,
|
||||
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 *
|
||||
cmd_template_replace(const char *template, const char *s, int idx)
|
||||
{
|
||||
char ch, *buf;
|
||||
const char *ptr, *cp, quote[] = "\"\\$;~";
|
||||
int replaced, quoted;
|
||||
size_t len;
|
||||
char ch, *buf;
|
||||
const char *ptr, *cp, dquote[] = "\"\\$;~";
|
||||
int replaced;
|
||||
size_t len, slen;
|
||||
enum { NQ, SQ, DQ } quote;
|
||||
|
||||
if (strchr(template, '%') == NULL)
|
||||
return (xstrdup(template));
|
||||
@@ -843,30 +866,52 @@ cmd_template_replace(const char *template, const char *s, int idx)
|
||||
while (*ptr != '\0') {
|
||||
switch (ch = *ptr++) {
|
||||
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)
|
||||
break;
|
||||
replaced = 1;
|
||||
}
|
||||
ptr++;
|
||||
|
||||
quoted = (*ptr == '%');
|
||||
if (quoted)
|
||||
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++) {
|
||||
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++] = *cp;
|
||||
}
|
||||
buf[len] = '\0';
|
||||
continue;
|
||||
}
|
||||
if (len > SIZE_MAX - 2)
|
||||
fatalx("argument too long");
|
||||
buf = xrealloc(buf, len + 2);
|
||||
buf[len++] = ch;
|
||||
buf[len] = '\0';
|
||||
}
|
||||
|
||||
log_debug("%s: %s -> %s", __func__, template, buf);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
306
colour.c
306
colour.c
@@ -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>
|
||||
@@ -26,6 +26,85 @@
|
||||
|
||||
#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
|
||||
colour_dist_sq(int R, int G, int B, int r, int g, int b)
|
||||
{
|
||||
@@ -120,6 +199,28 @@ colour_force_rgb(int c)
|
||||
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. */
|
||||
const char *
|
||||
colour_tostring(int c)
|
||||
@@ -130,6 +231,13 @@ colour_tostring(int c)
|
||||
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");
|
||||
}
|
||||
|
||||
if (c & COLOUR_FLAG_RGB) {
|
||||
colour_split_rgb(c, &r, &g, &b);
|
||||
xsnprintf(s, sizeof s, "#%02x%02x%02x", r, g, b);
|
||||
@@ -182,6 +290,98 @@ colour_tostring(int c)
|
||||
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. */
|
||||
int
|
||||
colour_fromstring(const char *s)
|
||||
@@ -190,6 +390,7 @@ colour_fromstring(const char *s)
|
||||
const char *cp;
|
||||
int n;
|
||||
u_char r, g, b;
|
||||
u_int i;
|
||||
|
||||
if (*s == '#' && strlen(s) == 7) {
|
||||
for (cp = s + 1; isxdigit((u_char) *cp); cp++)
|
||||
@@ -220,6 +421,11 @@ colour_fromstring(const char *s)
|
||||
if (strcasecmp(s, "terminal") == 0)
|
||||
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)
|
||||
return (0);
|
||||
if (strcasecmp(s, "red") == 0 || strcmp(s, "1") == 0)
|
||||
@@ -942,13 +1148,18 @@ colour_byname(const char *name)
|
||||
{ "yellow3", 0xcdcd00 },
|
||||
{ "yellow4", 0x8b8b00 }
|
||||
};
|
||||
u_int i;
|
||||
int c;
|
||||
u_int i;
|
||||
int c;
|
||||
const char *errstr;
|
||||
|
||||
if (strncmp(name, "grey", 4) == 0 || strncmp(name, "gray", 4) == 0) {
|
||||
if (!isdigit((u_char)name[4]))
|
||||
if (strncasecmp(name, "grey", 4) == 0 ||
|
||||
strncasecmp(name, "gray", 4) == 0) {
|
||||
if (name[4] == '\0')
|
||||
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)
|
||||
return (-1);
|
||||
return (colour_join_rgb(c, c, c));
|
||||
@@ -960,6 +1171,47 @@ colour_byname(const char *name)
|
||||
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)
|
||||
@@ -996,22 +1248,22 @@ colour_palette_free(struct colour_palette *p)
|
||||
|
||||
/* Get a colour from a palette. */
|
||||
int
|
||||
colour_palette_get(struct colour_palette *p, int c)
|
||||
colour_palette_get(struct colour_palette *p, int n)
|
||||
{
|
||||
if (p == NULL)
|
||||
return (-1);
|
||||
|
||||
if (c >= 90 && c <= 97)
|
||||
c = 8 + c - 90;
|
||||
else if (c & COLOUR_FLAG_256)
|
||||
c &= ~COLOUR_FLAG_256;
|
||||
else if (c >= 8)
|
||||
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[c] != -1)
|
||||
return (p->palette[c]);
|
||||
if (p->default_palette != NULL && p->default_palette[c] != -1)
|
||||
return (p->default_palette[c]);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1021,15 +1273,14 @@ colour_palette_set(struct colour_palette *p, int n, int c)
|
||||
{
|
||||
u_int i;
|
||||
|
||||
if (p == NULL || n > 255)
|
||||
if (p == NULL || n < 0 || n > 255)
|
||||
return (0);
|
||||
|
||||
if (c == -1 && p->palette == NULL)
|
||||
return (0);
|
||||
|
||||
if (c != -1 && p->palette == NULL) {
|
||||
if (p->palette == NULL)
|
||||
p->palette = xcalloc(256, sizeof *p->palette);
|
||||
if (p->palette == NULL) {
|
||||
p->palette = xcalloc(256, sizeof *p->palette);
|
||||
for (i = 0; i < 256; i++)
|
||||
p->palette[i] = -1;
|
||||
}
|
||||
@@ -1043,7 +1294,8 @@ colour_palette_from_option(struct colour_palette *p, struct options *oo)
|
||||
{
|
||||
struct options_entry *o;
|
||||
struct options_array_item *a;
|
||||
u_int i, n;
|
||||
union options_value *ov;
|
||||
u_int i;
|
||||
int c;
|
||||
|
||||
if (p == NULL)
|
||||
@@ -1061,13 +1313,11 @@ colour_palette_from_option(struct colour_palette *p, struct options *oo)
|
||||
p->default_palette = xcalloc(256, sizeof *p->default_palette);
|
||||
for (i = 0; i < 256; i++)
|
||||
p->default_palette[i] = -1;
|
||||
while (a != NULL) {
|
||||
n = options_array_item_index(a);
|
||||
if (n < 256) {
|
||||
c = options_array_item_value(a)->number;
|
||||
p->default_palette[n] = c;
|
||||
for (i = 0; i < 256; i++) {
|
||||
ov = options_array_getv(o, "%u", i);
|
||||
if (ov != NULL) {
|
||||
c = ov->number;
|
||||
p->default_palette[i] = c;
|
||||
}
|
||||
a = options_array_next(a);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
47
compat.h
47
compat.h
@@ -38,6 +38,14 @@
|
||||
#include <event2/bufferevent_compat.h>
|
||||
#else
|
||||
#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
|
||||
|
||||
#ifdef HAVE_MALLOC_TRIM
|
||||
@@ -289,6 +297,11 @@ void explicit_bzero(void *, size_t);
|
||||
int getdtablecount(void);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETDTABLESIZE
|
||||
/* getdtablesize.c */
|
||||
int getdtablesize(void);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CLOSEFROM
|
||||
/* closefrom.c */
|
||||
void closefrom(int);
|
||||
@@ -334,6 +347,18 @@ char *strndup(const char *, size_t);
|
||||
void *memmem(const void *, size_t, const void *, size_t);
|
||||
#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 *);
|
||||
@@ -363,7 +388,7 @@ int clock_gettime(int, struct timespec *);
|
||||
/* base64.c */
|
||||
#undef b64_ntop
|
||||
#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);
|
||||
#endif
|
||||
|
||||
@@ -385,11 +410,6 @@ int asprintf(char **, const char *, ...);
|
||||
int vasprintf(char **, const char *, va_list);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FGETLN
|
||||
/* fgetln.c */
|
||||
char *fgetln(FILE *, size_t *);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETLINE
|
||||
/* getline.c */
|
||||
ssize_t getline(char **, size_t *, FILE *);
|
||||
@@ -423,7 +443,9 @@ void *recallocarray(void *, size_t, size_t, size_t);
|
||||
|
||||
#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
|
||||
@@ -436,14 +458,17 @@ int utf8proc_wctomb(char *, wchar_t);
|
||||
#ifdef NEED_FUZZING
|
||||
/* tmux.c */
|
||||
#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
|
||||
|
||||
/* getopt.c */
|
||||
extern int BSDopterr;
|
||||
extern int BSDoptind;
|
||||
extern int BSDoptopt;
|
||||
extern int BSDoptreset;
|
||||
extern char *BSDoptarg;
|
||||
extern int BSDopterr;
|
||||
extern int BSDoptind;
|
||||
extern int BSDoptopt;
|
||||
extern int BSDoptreset;
|
||||
extern char *BSDoptarg;
|
||||
int BSDgetopt(int, char *const *, const char *);
|
||||
#define getopt(ac, av, o) BSDgetopt(ac, av, o)
|
||||
#define opterr BSDopterr
|
||||
|
||||
@@ -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.
|
||||
@@ -46,15 +46,15 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
static const char Base64[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
static const char Pad64 = '=';
|
||||
@@ -107,9 +107,9 @@ static const char Pad64 = '=';
|
||||
end of the data is performed using the '=' character.
|
||||
|
||||
Since all base64 input is an integral number of octets, only the
|
||||
-------------------------------------------------
|
||||
-------------------------------------------------
|
||||
following cases can arise:
|
||||
|
||||
|
||||
(1) the final quantum of encoding input is an integral
|
||||
multiple of 24 bits; here, the final unit of encoded
|
||||
output will be an integral multiple of 4 characters
|
||||
@@ -123,15 +123,12 @@ static const char Pad64 = '=';
|
||||
*/
|
||||
|
||||
int
|
||||
b64_ntop(src, srclength, target, targsize)
|
||||
u_char const *src;
|
||||
size_t srclength;
|
||||
char *target;
|
||||
size_t targsize;
|
||||
b64_ntop(unsigned char const *src, size_t srclength, char *target,
|
||||
size_t targsize)
|
||||
{
|
||||
size_t datalength = 0;
|
||||
u_char input[3];
|
||||
u_char output[4];
|
||||
unsigned char input[3];
|
||||
unsigned char output[4];
|
||||
int i;
|
||||
|
||||
while (2 < srclength) {
|
||||
@@ -152,14 +149,14 @@ b64_ntop(src, srclength, target, targsize)
|
||||
target[datalength++] = Base64[output[2]];
|
||||
target[datalength++] = Base64[output[3]];
|
||||
}
|
||||
|
||||
|
||||
/* Now we worry about padding. */
|
||||
if (0 != srclength) {
|
||||
/* Get what's left. */
|
||||
input[0] = input[1] = input[2] = '\0';
|
||||
for (i = 0; i < srclength; i++)
|
||||
input[i] = *src++;
|
||||
|
||||
|
||||
output[0] = input[0] >> 2;
|
||||
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
|
||||
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|
||||
@@ -187,13 +184,10 @@ b64_ntop(src, srclength, target, targsize)
|
||||
*/
|
||||
|
||||
int
|
||||
b64_pton(src, target, targsize)
|
||||
char const *src;
|
||||
u_char *target;
|
||||
size_t targsize;
|
||||
b64_pton(char const *src, unsigned char *target, size_t targsize)
|
||||
{
|
||||
int tarindex, state, ch;
|
||||
u_char nextbyte;
|
||||
unsigned char nextbyte;
|
||||
char *pos;
|
||||
|
||||
state = 0;
|
||||
@@ -207,7 +201,7 @@ b64_pton(src, target, targsize)
|
||||
break;
|
||||
|
||||
pos = strchr(Base64, ch);
|
||||
if (pos == 0) /* A non-base64 character. */
|
||||
if (pos == 0) /* A non-base64 character. */
|
||||
return (-1);
|
||||
|
||||
switch (state) {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#endif
|
||||
|
||||
int
|
||||
clock_gettime(int clock, struct timespec *ts)
|
||||
clock_gettime(__unused int clock, struct timespec *ts)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
|
||||
@@ -49,12 +49,12 @@
|
||||
|
||||
#include <mach/mach.h>
|
||||
|
||||
#include <Availability.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <unistd.h>
|
||||
|
||||
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 *,
|
||||
uid_t, mach_port_t *);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -18,13 +18,28 @@
|
||||
|
||||
#include <glob.h>
|
||||
#include <unistd.h>
|
||||
#if defined(HAVE_LIBPROC_H)
|
||||
#include <libproc.h>
|
||||
#endif
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
void fatal(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
|
||||
getdtablecount(void)
|
||||
{
|
||||
|
||||
@@ -74,8 +74,14 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
|
||||
}
|
||||
if (ptr + 2 >= eptr) {
|
||||
char *nbuf;
|
||||
size_t nbufsiz = *bufsiz * 2;
|
||||
size_t nbufsiz;
|
||||
ssize_t d = ptr - *buf;
|
||||
|
||||
if (*bufsiz > SIZE_MAX / 2) {
|
||||
errno = EOVERFLOW;
|
||||
return -1;
|
||||
}
|
||||
nbufsiz = *bufsiz * 2;
|
||||
if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
|
||||
return -1;
|
||||
*buf = nbuf;
|
||||
|
||||
115
compat/getopt.c
115
compat/getopt.c
@@ -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
577
compat/getopt_long.c
Normal 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) */
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_UCRED_H
|
||||
#include <ucred.h>
|
||||
@@ -30,7 +31,7 @@ getpeereid(int s, uid_t *uid, gid_t *gid)
|
||||
{
|
||||
#ifdef HAVE_SO_PEERCRED
|
||||
struct ucred uc;
|
||||
int len = sizeof uc;
|
||||
socklen_t len = sizeof uc;
|
||||
|
||||
if (getsockopt(s, SOL_SOCKET, SO_PEERCRED, &uc, &len) == -1)
|
||||
return (-1);
|
||||
@@ -38,9 +39,6 @@ getpeereid(int s, uid_t *uid, gid_t *gid)
|
||||
*gid = uc.gid;
|
||||
return (0);
|
||||
#elif defined(HAVE_GETPEERUCRED)
|
||||
int
|
||||
getpeereid(int s, uid_t *uid, gid_t *gid)
|
||||
{
|
||||
ucred_t *ucred = NULL;
|
||||
|
||||
if (getpeerucred(s, &ucred) == -1)
|
||||
@@ -51,8 +49,9 @@ getpeereid(int s, uid_t *uid, gid_t *gid)
|
||||
return (-1);
|
||||
ucred_free(ucred);
|
||||
return (0);
|
||||
}
|
||||
#else
|
||||
return (getuid());
|
||||
*uid = geteuid();
|
||||
*gid = getegid();
|
||||
return (0);
|
||||
#endif
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user