mirror of
https://github.com/tmux/tmux.git
synced 2026-03-14 04:25:47 +00:00
Compare commits
1542 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b5c3fc49f | ||
|
|
b4ad1759b8 | ||
|
|
6589120667 | ||
|
|
0cdcae3532 | ||
|
|
0e87430462 | ||
|
|
43d2b6a648 | ||
|
|
8249fbfb60 | ||
|
|
3a545376f0 | ||
|
|
5cc9380bfa | ||
|
|
ca84659ca1 | ||
|
|
8dc78377d1 | ||
|
|
64deb34c3b | ||
|
|
8b05d84ece | ||
|
|
619ffe1f4f | ||
|
|
9107b0c69a | ||
|
|
ea289bc457 | ||
|
|
9763282dc1 | ||
|
|
44dccf7ea2 | ||
|
|
80b5c0e076 | ||
|
|
7a3ec77dbd | ||
|
|
48750022c0 | ||
|
|
ce0b285aad | ||
|
|
17bbf90393 | ||
|
|
0d0b3cf9a4 | ||
|
|
149f5bac05 | ||
|
|
253f1395a0 | ||
|
|
e342304134 | ||
|
|
d785c37ee2 | ||
|
|
69683ba7b4 | ||
|
|
7b189f1ad7 | ||
|
|
84612a8196 | ||
|
|
5d60bc7f7c | ||
|
|
42272dfbd5 | ||
|
|
5b85efeb93 | ||
|
|
eb0ad181e9 | ||
|
|
dc3df931d7 | ||
|
|
d3d48fa3e7 | ||
|
|
73f29094d0 | ||
|
|
a043b975ca | ||
|
|
68cc635ed5 | ||
|
|
b2a9f4115f | ||
|
|
b433886840 | ||
|
|
248cd423a1 | ||
|
|
b79f86e32a | ||
|
|
40505e59f1 | ||
|
|
a1cd0eee1b | ||
|
|
c914fcfacb | ||
|
|
4d7967de7a | ||
|
|
28fd3a3835 | ||
|
|
996a636713 | ||
|
|
41a448193f | ||
|
|
0304555184 | ||
|
|
f536dc47c4 | ||
|
|
d6066552ee | ||
|
|
59c760dfcd | ||
|
|
c06b2e4fb9 | ||
|
|
1f29f6ac4d | ||
|
|
3ad812cbd5 | ||
|
|
53c430eced | ||
|
|
6307d63715 | ||
|
|
4f8a6867fa | ||
|
|
9e7bbc7281 | ||
|
|
c96a2a3c9e | ||
|
|
7263fa36eb | ||
|
|
adc9fad4ac | ||
|
|
9247c90d69 | ||
|
|
a679a4a708 | ||
|
|
2e43372d0b | ||
|
|
473911fb73 | ||
|
|
686d461144 | ||
|
|
554f19eb05 | ||
|
|
fc8d3f7a56 | ||
|
|
56e37487a8 | ||
|
|
674545f7e6 | ||
|
|
35690fb3a5 | ||
|
|
1c608031b5 | ||
|
|
84a4007b06 | ||
|
|
753775033a | ||
|
|
d39c58c01c | ||
|
|
58e8e0eac8 | ||
|
|
d50f157f7e | ||
|
|
a1e4908ed7 | ||
|
|
f61fc576d9 | ||
|
|
73c6785538 | ||
|
|
6804d5841e | ||
|
|
96aaa87df6 | ||
|
|
454e7d9c3a | ||
|
|
db27dc82f0 | ||
|
|
061027fefc | ||
|
|
45d68963ab | ||
|
|
200b0e5821 | ||
|
|
30b801decf | ||
|
|
ca3f92e78c | ||
|
|
c8849ac990 | ||
|
|
44307712ed | ||
|
|
20129b7bf9 | ||
|
|
a194430e5d | ||
|
|
cf2e65c0e2 | ||
|
|
8889a48f9b | ||
|
|
a3dec6bece | ||
|
|
ff4097e02c | ||
|
|
c081af2963 | ||
|
|
89a96b05fa | ||
|
|
5385a9bb34 | ||
|
|
d697b5ef20 | ||
|
|
81858d7891 | ||
|
|
7a583b1e54 | ||
|
|
35a8a61254 | ||
|
|
513bd8f62d | ||
|
|
1f5e6e35d5 | ||
|
|
a432fcd306 | ||
|
|
06d27e94b2 | ||
|
|
188be9718e | ||
|
|
bbd3e822c7 | ||
|
|
45a2e2d6c6 | ||
|
|
a10143a2d1 | ||
|
|
38530de622 | ||
|
|
f040bc249f | ||
|
|
ede8312d59 | ||
|
|
df912e3540 | ||
|
|
3886f60671 | ||
|
|
a3391692ad | ||
|
|
91f54b59ac | ||
|
|
b0f4f94b5b | ||
|
|
f20c6fe009 | ||
|
|
191a92c0c6 | ||
|
|
adba3d35b1 | ||
|
|
63f5c38023 | ||
|
|
7e02d2f459 | ||
|
|
5761712799 | ||
|
|
9bb97522d5 | ||
|
|
f4053bc217 | ||
|
|
67b926cf3c | ||
|
|
5b6f78186c | ||
|
|
39abca401a | ||
|
|
a7917430d8 | ||
|
|
202c04414c | ||
|
|
bc47596313 | ||
|
|
dfc845e7f9 | ||
|
|
0159c74a32 | ||
|
|
a401420273 | ||
|
|
fce30422f3 | ||
|
|
2a36a0a067 | ||
|
|
1c15848c47 | ||
|
|
4a634a7da4 | ||
|
|
576f2694b1 | ||
|
|
0f00c3b47a | ||
|
|
2942eca895 | ||
|
|
7c39850d1f | ||
|
|
a13b4a819a | ||
|
|
a4a2c68fa9 | ||
|
|
2113115cdd | ||
|
|
038e8b770d | ||
|
|
04ac61ecd7 | ||
|
|
eed7d9b473 | ||
|
|
021e95b09f | ||
|
|
bf4b02cea2 | ||
|
|
e96d514247 | ||
|
|
bcda6eed63 | ||
|
|
2e3a260315 | ||
|
|
b24829a99c | ||
|
|
7c7bd14c61 | ||
|
|
30b23baaf5 | ||
|
|
169d362945 | ||
|
|
c6fc8771a9 | ||
|
|
626c8aa8e7 | ||
|
|
db20f2d907 | ||
|
|
63d109fb7f | ||
|
|
226f9fa012 | ||
|
|
f51c55c3f0 | ||
|
|
fbf2bd865c | ||
|
|
1845800651 | ||
|
|
993f1b96a3 | ||
|
|
196710e2d3 | ||
|
|
ed85c5a198 | ||
|
|
1f23f6d686 | ||
|
|
17da2f7d5f | ||
|
|
fff7c0b276 | ||
|
|
5cc4961fd2 | ||
|
|
baafc17a1e | ||
|
|
49b2a255b6 | ||
|
|
d9cb07df3b | ||
|
|
a97f22ff2b | ||
|
|
ffab6dbc9a | ||
|
|
04bf0d8efc | ||
|
|
3604b31b6f | ||
|
|
84c708f355 | ||
|
|
fe4f00834d | ||
|
|
ebf94bc9cb | ||
|
|
682884edc5 | ||
|
|
82b053a811 | ||
|
|
2f93affb98 | ||
|
|
243d12752c | ||
|
|
7a4679a17f | ||
|
|
d61c572c92 | ||
|
|
cae8d02b2e | ||
|
|
ac7e2f13e9 | ||
|
|
50cefec497 | ||
|
|
1340c012b0 | ||
|
|
2f0db58777 | ||
|
|
470f521410 | ||
|
|
8f29eeaae6 | ||
|
|
f2f9bc0181 | ||
|
|
5f92f62ac3 | ||
|
|
673b1abe5f | ||
|
|
37f9bb46d8 | ||
|
|
218b692221 | ||
|
|
96a34a0c0a | ||
|
|
132403b6be | ||
|
|
3e6454f2d6 | ||
|
|
f66b105c21 | ||
|
|
b74b875f25 | ||
|
|
e79c647052 | ||
|
|
b728970c65 | ||
|
|
e45dc6ae59 | ||
|
|
d0907861f9 | ||
|
|
cc979bda0f | ||
|
|
a6c22d650b | ||
|
|
e60f48ab09 | ||
|
|
ff5155f719 | ||
|
|
714416074a | ||
|
|
bea5155fee | ||
|
|
995c9a50ab | ||
|
|
c8c6a23d66 | ||
|
|
6df8953f4f | ||
|
|
00e2e35740 | ||
|
|
31cf5314ee | ||
|
|
bdfbb52951 | ||
|
|
94795eb48e | ||
|
|
d3e432069b | ||
|
|
0f9e0d1cfe | ||
|
|
48e6ebbe1e | ||
|
|
e02d1bce98 | ||
|
|
ed58b2d353 | ||
|
|
5cbca2e70f | ||
|
|
e8dff68588 | ||
|
|
e65c5ad56c | ||
|
|
bae2701289 | ||
|
|
c6e0af9bdb | ||
|
|
6703ca8d26 | ||
|
|
ce67a44a94 | ||
|
|
14e5cdf02e | ||
|
|
21f62c2cee | ||
|
|
bd6153195f | ||
|
|
e5b3858944 | ||
|
|
09e6b7c137 | ||
|
|
36ece3fcf5 | ||
|
|
f99de22808 | ||
|
|
b58d7f78a1 | ||
|
|
2ce636a315 | ||
|
|
2c4e8b92ab | ||
|
|
86c1335452 | ||
|
|
631d6b59fd | ||
|
|
ed54f01d2f | ||
|
|
711d2205dd | ||
|
|
18d3498fb2 | ||
|
|
c829bdf537 | ||
|
|
20d10c608d | ||
|
|
e1273fb6a1 | ||
|
|
85f5485cb5 | ||
|
|
b831f86354 | ||
|
|
c11da7ca88 | ||
|
|
f881ff1c18 | ||
|
|
cd8e536c43 | ||
|
|
58e5442d37 | ||
|
|
faf51d748e | ||
|
|
407f66ccbc | ||
|
|
bfc9f475c6 | ||
|
|
8121b541e0 | ||
|
|
65748fb197 | ||
|
|
37e5b5d947 | ||
|
|
8ff20a5c6d | ||
|
|
f9f6eea444 | ||
|
|
621fa0a686 | ||
|
|
0edaa34bfd | ||
|
|
c0cfbe12e4 | ||
|
|
7c9d003e99 | ||
|
|
49ce38b09a | ||
|
|
b1e4b8769b | ||
|
|
90bf560fe4 | ||
|
|
5672f2ce6b | ||
|
|
01f2b5d64b | ||
|
|
f59971276a | ||
|
|
2e2c9bd623 | ||
|
|
bf9e7a1c68 | ||
|
|
df31f1dfc9 | ||
|
|
0f9f30de2e | ||
|
|
f41efd9d89 | ||
|
|
ba7278373d | ||
|
|
e4eb43ec71 | ||
|
|
dc83ba0372 | ||
|
|
cf8faa3b33 | ||
|
|
68ba5377e3 | ||
|
|
be4d77e60f | ||
|
|
bde45cdd9c | ||
|
|
a7c615a794 | ||
|
|
92c522228b | ||
|
|
3a902f4196 | ||
|
|
0987d55231 | ||
|
|
5aa28473dd | ||
|
|
21ab66569c | ||
|
|
070d266aae | ||
|
|
3b990ef6b2 | ||
|
|
e920fa3e36 | ||
|
|
84207f06b7 | ||
|
|
c7f078dcbc | ||
|
|
3893cc17a4 | ||
|
|
4d1c513968 | ||
|
|
14d6a4ab26 | ||
|
|
e678ba3943 | ||
|
|
166681eee9 | ||
|
|
1fdac2adf1 | ||
|
|
40b1d64ce7 | ||
|
|
d8805af66b | ||
|
|
46210344a6 | ||
|
|
4f480c901d | ||
|
|
50f5d2a7ec | ||
|
|
95f48a219a | ||
|
|
87d092d226 | ||
|
|
e87d4b43ab | ||
|
|
f152379e5a | ||
|
|
889fe42e11 | ||
|
|
164e85cca7 | ||
|
|
0b34fefe6e | ||
|
|
928f40615c | ||
|
|
7ad052583a | ||
|
|
d3c842d367 | ||
|
|
a597e3546c | ||
|
|
0489213b1b | ||
|
|
9b8fc982ec | ||
|
|
92a720157b | ||
|
|
c8c0d68128 | ||
|
|
523ed3873d | ||
|
|
005566f915 | ||
|
|
698361ccde | ||
|
|
71df37c247 | ||
|
|
21c11c7f48 | ||
|
|
4e05a2c0ae | ||
|
|
575bfa4b4b | ||
|
|
31ddae7735 | ||
|
|
33fac234c0 | ||
|
|
1bbb793263 | ||
|
|
799f437eff | ||
|
|
be63fef872 | ||
|
|
ac9ebc29a2 | ||
|
|
3307813a07 | ||
|
|
3d98adaf91 | ||
|
|
cf11809cd4 | ||
|
|
32a6092f71 | ||
|
|
e7c7024907 | ||
|
|
3275e9bd5b | ||
|
|
9d79a56402 | ||
|
|
18012f5b18 | ||
|
|
03dca66ae2 | ||
|
|
178a20718c | ||
|
|
30f4c30ca3 | ||
|
|
8b68ea1462 | ||
|
|
f4fdddc930 | ||
|
|
e4f1fbd008 | ||
|
|
89ab147093 | ||
|
|
95f427c34e | ||
|
|
e0d2221879 | ||
|
|
4b8bb7770f | ||
|
|
07ac16807f | ||
|
|
82f4db0d10 | ||
|
|
4d9ccd3229 | ||
|
|
b801118fe5 | ||
|
|
952ffdd288 | ||
|
|
4e7de210e4 | ||
|
|
aaf0bfccf4 | ||
|
|
a870a596bc | ||
|
|
88f25bb677 | ||
|
|
290636bc86 | ||
|
|
3e94fa70f9 | ||
|
|
cfa6ac9161 | ||
|
|
6e6e8046ba | ||
|
|
d7ea1ac847 | ||
|
|
fe055c89f5 | ||
|
|
fddbd44c18 | ||
|
|
67949de0a1 | ||
|
|
3f49137f90 | ||
|
|
fe7cf0ba90 | ||
|
|
94e46dd724 | ||
|
|
c82e06804e | ||
|
|
509a7e8b73 | ||
|
|
98e24b9f70 | ||
|
|
0fd0030a2a | ||
|
|
4bb01c1768 | ||
|
|
efb639e1d2 | ||
|
|
8363d19307 | ||
|
|
fdeaa73342 | ||
|
|
d1ae2d9757 | ||
|
|
908a22e41c | ||
|
|
c2176afe9c | ||
|
|
6b3988b749 | ||
|
|
896c55291f | ||
|
|
2ee0d851d9 | ||
|
|
c08a532440 | ||
|
|
49a5a587ec | ||
|
|
677ed3e5f0 | ||
|
|
f188345b33 | ||
|
|
0e59bc75fd | ||
|
|
937173ff11 | ||
|
|
e4a7cefe0c | ||
|
|
e23df3af5a | ||
|
|
9c1d3046ca | ||
|
|
c846298747 | ||
|
|
230d0fbc9e | ||
|
|
9bbc63ed65 | ||
|
|
ad2cc63412 | ||
|
|
a7a44bfcd9 | ||
|
|
d2d2df1365 | ||
|
|
224255cb89 | ||
|
|
74b2eaa73e | ||
|
|
e254aeb9f9 | ||
|
|
1d4c54717c | ||
|
|
30b816f101 | ||
|
|
9803aee98e | ||
|
|
a34a72d2d9 | ||
|
|
4d80980e50 | ||
|
|
85152ef35c | ||
|
|
678e67437f | ||
|
|
b92e81a1aa | ||
|
|
ebce251183 | ||
|
|
e870a3f3ec | ||
|
|
a3c1b730c9 | ||
|
|
a7b0b30bdd | ||
|
|
d4c2a935f2 | ||
|
|
cc967ffeb9 | ||
|
|
4bea559037 | ||
|
|
674de910ca | ||
|
|
8ed9124f3f | ||
|
|
535286c05a | ||
|
|
7f24020cbe | ||
|
|
be7b56a613 | ||
|
|
66f04514cf | ||
|
|
cd10f7322a | ||
|
|
5434a2759a | ||
|
|
b7551c9193 | ||
|
|
d4312281da | ||
|
|
d9eb34b28d | ||
|
|
b79189958f | ||
|
|
ad5c4e719b | ||
|
|
db7570daab | ||
|
|
8332413305 | ||
|
|
8cf19ab770 | ||
|
|
199d148740 | ||
|
|
dcad13155b | ||
|
|
e6519d3e27 | ||
|
|
299a8fd4a3 | ||
|
|
60069fe8fe | ||
|
|
d817f88fec | ||
|
|
eeaf92ad06 | ||
|
|
16f9667620 | ||
|
|
90b331ea46 | ||
|
|
e2d59a6c17 | ||
|
|
2ca1849350 | ||
|
|
e210abf335 | ||
|
|
f9b4095188 | ||
|
|
d1f0138653 | ||
|
|
92aef64c5a | ||
|
|
fdd1d0b72e | ||
|
|
d377a68593 | ||
|
|
5db593e5c2 | ||
|
|
d71e4b9aca | ||
|
|
9e7ec2e971 | ||
|
|
3a9a24a7c0 | ||
|
|
da145e7c20 | ||
|
|
d655566ce7 | ||
|
|
c1b9948525 | ||
|
|
f308ba93aa | ||
|
|
76862acf3e | ||
|
|
f308663ad4 | ||
|
|
876f46abb9 | ||
|
|
620a87db25 | ||
|
|
e04d13f6a6 | ||
|
|
c44d2d854f | ||
|
|
31f13e49d8 | ||
|
|
2397083f7e | ||
|
|
08014af243 | ||
|
|
774bffb3c6 | ||
|
|
9c920214e6 | ||
|
|
5cc3d50289 | ||
|
|
9ec457575d | ||
|
|
fc5f8804ec | ||
|
|
fd25d35868 | ||
|
|
7c9bc377a3 | ||
|
|
57df442916 | ||
|
|
398af28d2a | ||
|
|
8798079ab0 | ||
|
|
c26ec766cb | ||
|
|
c3794d4303 | ||
|
|
4fbb296438 | ||
|
|
21128fea1e | ||
|
|
9f738dd2fe | ||
|
|
693c106a1d | ||
|
|
6c1c304fc3 | ||
|
|
e5bf63cb59 | ||
|
|
046d8b096f | ||
|
|
0cbab892d5 | ||
|
|
b44f78fe9f | ||
|
|
3f5ec24b5a | ||
|
|
d8d9c2af98 | ||
|
|
e5d6df8979 | ||
|
|
cf317412d9 | ||
|
|
b2ee98b8d7 | ||
|
|
5213d9674b | ||
|
|
0ff42d975b | ||
|
|
5ed3daf28b | ||
|
|
f5a73c5433 | ||
|
|
0e45ca1718 | ||
|
|
c1eeac86fe | ||
|
|
03ee7f7edf | ||
|
|
a8ca1340ad | ||
|
|
7d169a3679 | ||
|
|
98e500f598 | ||
|
|
1c1797e4f2 | ||
|
|
653d1e2fc8 | ||
|
|
9b48c77493 | ||
|
|
96146a8c6f | ||
|
|
e3225bc4e3 | ||
|
|
f0aad68aee | ||
|
|
7d53e2c946 | ||
|
|
7ff4cf9405 | ||
|
|
179d0686d7 | ||
|
|
b32254acda | ||
|
|
16d75a6bf2 | ||
|
|
e63909655c | ||
|
|
213deb5c66 | ||
|
|
69c1521895 | ||
|
|
6821ccc882 | ||
|
|
17e6dc4405 | ||
|
|
a7341715c1 | ||
|
|
521bf41d12 | ||
|
|
f0c3e9babe | ||
|
|
edd59d9e0f | ||
|
|
326c5bf1b4 | ||
|
|
550906cb09 | ||
|
|
175d82c95b | ||
|
|
49ef0b4af3 | ||
|
|
3740f8f846 | ||
|
|
adfa5050d5 | ||
|
|
f62dcc1ea1 | ||
|
|
b1ed2d5bd9 | ||
|
|
e6a59c4bee | ||
|
|
d6dc4c30f4 | ||
|
|
f14da260c8 | ||
|
|
d635d79042 | ||
|
|
b8ce435a54 | ||
|
|
b6bd9515ea | ||
|
|
6e0c097d9f | ||
|
|
d9807eeba1 | ||
|
|
cb752f9938 | ||
|
|
2e98603db9 | ||
|
|
39628e8280 | ||
|
|
40af1a854c | ||
|
|
fb5b958837 | ||
|
|
99f78340af | ||
|
|
5985143813 | ||
|
|
9800eaa63f | ||
|
|
423649b2c6 | ||
|
|
2888843a18 | ||
|
|
4a5dff3f11 | ||
|
|
4a01da19df | ||
|
|
d390a90bf0 | ||
|
|
c41a93d130 | ||
|
|
0a4fd0f7a4 | ||
|
|
a54e670301 | ||
|
|
4697b35d4f | ||
|
|
0588168a64 | ||
|
|
f01b7191a3 | ||
|
|
029c34ce6b | ||
|
|
47d41d0203 | ||
|
|
2651c0d69c | ||
|
|
87a2a13f68 | ||
|
|
5775074f73 | ||
|
|
abb4af7a14 | ||
|
|
b9bbe1d81c | ||
|
|
3657aa675e | ||
|
|
88e9079870 | ||
|
|
cd62411d78 | ||
|
|
f95f792ddf | ||
|
|
2fc84c7c34 | ||
|
|
6b734d1074 | ||
|
|
e39c5a9e14 | ||
|
|
b2fe881307 | ||
|
|
b6659dc563 | ||
|
|
3ce1b91b1b | ||
|
|
2589d117b0 | ||
|
|
8aec4c93eb | ||
|
|
9960a06a67 | ||
|
|
cf90f2a29c | ||
|
|
cc5bcbfb59 | ||
|
|
be179f6d7e | ||
|
|
0ecb11fe4f | ||
|
|
7d604ab717 | ||
|
|
ee5e97926d | ||
|
|
0252796a57 | ||
|
|
e9ebdac3dd | ||
|
|
5339b8ce3a | ||
|
|
20134fa9f4 | ||
|
|
1f01dd8c0a | ||
|
|
25eb48aea3 | ||
|
|
e5cee89727 | ||
|
|
d86c6b2fff | ||
|
|
7e423ea491 | ||
|
|
9dacc1700b | ||
|
|
d5269a2eed | ||
|
|
a8e9654b65 | ||
|
|
2de9b1e005 | ||
|
|
b4b3d9c936 | ||
|
|
26aa0689a5 | ||
|
|
a70379d8f9 | ||
|
|
5e90476b25 | ||
|
|
f12158bc25 | ||
|
|
94f86edfee | ||
|
|
ad60a2c952 | ||
|
|
1202284f37 | ||
|
|
0503f83c64 | ||
|
|
65177b82be | ||
|
|
2b60c648c4 | ||
|
|
f537870909 | ||
|
|
34e5ec1807 | ||
|
|
480e48aa66 | ||
|
|
70d232289b | ||
|
|
240cae4c92 | ||
|
|
1af2021de6 | ||
|
|
3ea5e06bfb | ||
|
|
944b5e6fa0 | ||
|
|
96e7f33da3 | ||
|
|
58908fd8c5 | ||
|
|
f702dbfea2 | ||
|
|
fb527c1bad | ||
|
|
ec3efab01e | ||
|
|
583c885d68 | ||
|
|
acfabf3a50 | ||
|
|
538af37c35 | ||
|
|
6f08472049 | ||
|
|
f3741f0653 | ||
|
|
295ace6820 | ||
|
|
b0a88ebead | ||
|
|
a70df70d20 | ||
|
|
b1dfc740a3 | ||
|
|
7dddf56c08 | ||
|
|
075816eb72 | ||
|
|
eb288aae32 | ||
|
|
dc8fb9fb23 | ||
|
|
8738141913 | ||
|
|
3970853feb | ||
|
|
0f97ac4221 | ||
|
|
0bb2119781 | ||
|
|
4e75e82cc3 | ||
|
|
f4432030ee | ||
|
|
044c0f978f | ||
|
|
3dc7b805d3 | ||
|
|
735f87bc66 | ||
|
|
98d450ac3a | ||
|
|
48a1169f4e | ||
|
|
0a09d04e1b | ||
|
|
ec89eb9552 | ||
|
|
c8a14def9f | ||
|
|
5d519ba526 | ||
|
|
f16ea60cc0 | ||
|
|
f8a218882a | ||
|
|
f7e9aedf10 | ||
|
|
beb6db9b5f | ||
|
|
25d551e8b2 | ||
|
|
d88c20e718 | ||
|
|
f19a4bf9d1 | ||
|
|
82e0165c49 | ||
|
|
fa6abac98d | ||
|
|
71e8e26ccc | ||
|
|
7ce8fee4f3 | ||
|
|
808502ac3d | ||
|
|
d74e5bffba | ||
|
|
54456d5602 | ||
|
|
0a404aabd3 | ||
|
|
79e30daeae | ||
|
|
d5ed5fb08f | ||
|
|
c36f67a288 | ||
|
|
7954126dcd | ||
|
|
ce91520e12 | ||
|
|
8ec3e5725c | ||
|
|
7462c03281 | ||
|
|
567741caf5 | ||
|
|
9fc2c34a3b | ||
|
|
b6bb350289 | ||
|
|
bcc7c689c1 | ||
|
|
db7a89b1ee | ||
|
|
4dfb29fa38 | ||
|
|
ecc22c521d | ||
|
|
1270f8fed8 | ||
|
|
1df3355438 | ||
|
|
8820aa9f65 | ||
|
|
3872e24847 | ||
|
|
b8023044c3 | ||
|
|
1377427e70 | ||
|
|
3de1700f61 | ||
|
|
8f8e81c0c9 | ||
|
|
4f34e25dd8 | ||
|
|
9ad9e8c5dd | ||
|
|
fa4a75cdab | ||
|
|
2d82567070 | ||
|
|
588ebb5393 | ||
|
|
96ab50a701 | ||
|
|
b3438c86bf | ||
|
|
47e18f4cea | ||
|
|
17f1cd5be8 | ||
|
|
c3041eb9f0 | ||
|
|
69cb1f830e | ||
|
|
703160b5d6 | ||
|
|
64f02dab7c | ||
|
|
96c37fa80a | ||
|
|
55346b0d10 | ||
|
|
7502cb3adb | ||
|
|
ac3b78a841 | ||
|
|
5158dd9a8d | ||
|
|
3e8124009f | ||
|
|
a4515ce138 | ||
|
|
f833b885a1 | ||
|
|
67ee86085c | ||
|
|
5d0cfe079b | ||
|
|
1c86713afd | ||
|
|
b6950ed8aa | ||
|
|
04b32fa734 | ||
|
|
91218f8714 | ||
|
|
1a1efd5bc9 | ||
|
|
4fb1045f5a | ||
|
|
2b3c2fd852 | ||
|
|
cc42614fa9 | ||
|
|
2231e72968 | ||
|
|
f7c42c21ba | ||
|
|
230e39ec35 | ||
|
|
efa8c93664 | ||
|
|
3e0bc052e1 | ||
|
|
d3d25365f1 | ||
|
|
6fd2b5b87f | ||
|
|
acf13ce978 | ||
|
|
1b8488ee75 | ||
|
|
6fcdc714b6 | ||
|
|
8705c6b435 | ||
|
|
9358cfaf4a | ||
|
|
a51dcdc430 | ||
|
|
c65d4220f0 | ||
|
|
c198664d15 | ||
|
|
8715247a43 | ||
|
|
51487ed22f | ||
|
|
20ed20ea1e | ||
|
|
9802fea615 | ||
|
|
7ce77ffc9c | ||
|
|
6be32c89c5 | ||
|
|
1f18523565 | ||
|
|
e26a351865 | ||
|
|
ebd0eb4fb4 | ||
|
|
ef9b2eb566 | ||
|
|
9a1b4f9ed3 | ||
|
|
7e542d119b | ||
|
|
503edae26f | ||
|
|
e4e728664b | ||
|
|
17b56562c4 | ||
|
|
c7fccfa299 | ||
|
|
023137a891 | ||
|
|
34d05ea7cd | ||
|
|
5de84eca3d | ||
|
|
a3efd2ab5a | ||
|
|
139754b9fe | ||
|
|
248fb14f08 | ||
|
|
31954339d1 | ||
|
|
f56b4ec2ff | ||
|
|
6c42f1a89e | ||
|
|
65ff5b00bd | ||
|
|
f6cd0342f6 | ||
|
|
1580afdfdf | ||
|
|
7aef2994e4 | ||
|
|
08bcd6978c | ||
|
|
4789a4ee1f | ||
|
|
9a7cde0c9b | ||
|
|
66152010a7 | ||
|
|
2772557d15 | ||
|
|
ea4487c6da | ||
|
|
cb564bb427 | ||
|
|
3696cce4ae | ||
|
|
c1c5f43a01 | ||
|
|
a22a6deda5 | ||
|
|
bbf743769b | ||
|
|
de68c2a7da | ||
|
|
5309252053 | ||
|
|
8e8e0f1d53 | ||
|
|
f69ce39a6c | ||
|
|
fc9f08235b | ||
|
|
5f5104e782 | ||
|
|
e3be9b1951 | ||
|
|
c2822ca119 | ||
|
|
828f12b748 | ||
|
|
ae70071494 | ||
|
|
3999886901 | ||
|
|
cc474b4ede | ||
|
|
8363e31953 | ||
|
|
933dc48de3 | ||
|
|
4274a7ec89 | ||
|
|
77f9c49829 | ||
|
|
c87187f913 | ||
|
|
bf09b00fe9 | ||
|
|
a97b7ad11c | ||
|
|
2b80ede963 | ||
|
|
2a0f3f0d79 | ||
|
|
a471b5de9c | ||
|
|
43355fa75c | ||
|
|
b9c873cdaa | ||
|
|
b4b9b831ee | ||
|
|
552c9cd83f | ||
|
|
76bbdeb586 | ||
|
|
07a71fd432 | ||
|
|
26524c99f6 | ||
|
|
34464da8d3 | ||
|
|
42e2413978 | ||
|
|
ef7293379f | ||
|
|
386849edc1 | ||
|
|
e63f0546a1 | ||
|
|
447a07e9f8 | ||
|
|
ad466a69aa | ||
|
|
5afb820d23 | ||
|
|
278d9bc721 | ||
|
|
1484eb8a51 | ||
|
|
dcc100f165 | ||
|
|
4e3bed2035 | ||
|
|
510ec3fb9e | ||
|
|
ceed5cc9a9 | ||
|
|
0440d325d9 | ||
|
|
36c0871c23 | ||
|
|
b88ec14f0e | ||
|
|
cc724f327a | ||
|
|
43fa9a9ba6 | ||
|
|
e1e120de1c | ||
|
|
7b7397241f | ||
|
|
1618f3eae6 | ||
|
|
c47d66f49b | ||
|
|
1e8faaa217 | ||
|
|
608eef731a | ||
|
|
4f5c5b37b8 | ||
|
|
0ed727a012 | ||
|
|
d91127958d | ||
|
|
4af4d12475 | ||
|
|
e5f01febd7 | ||
|
|
72d1afa169 | ||
|
|
e0f4697e7c | ||
|
|
c4a2fdf15b | ||
|
|
af5e0bd15a | ||
|
|
ec1d37b1b2 | ||
|
|
c919139433 | ||
|
|
fc09ec3025 | ||
|
|
99e54f46c7 | ||
|
|
2240199dbf | ||
|
|
83e1a33ff5 | ||
|
|
d529e7e14e | ||
|
|
6769115df2 | ||
|
|
261b6b8615 | ||
|
|
3ae1b82695 | ||
|
|
67dd5df876 | ||
|
|
622593a77f | ||
|
|
a6d52405a8 | ||
|
|
842bc2b855 | ||
|
|
a2c86dcbf6 | ||
|
|
ac9daf92d7 | ||
|
|
f81190a793 | ||
|
|
6704c86301 | ||
|
|
680f920b55 | ||
|
|
089c33f5be | ||
|
|
46d5c14b17 | ||
|
|
b02cd35354 | ||
|
|
7425122c1c | ||
|
|
56481a46bf | ||
|
|
41f90bd08f | ||
|
|
d3d85c3df9 | ||
|
|
d267845cfc | ||
|
|
c550e66e85 | ||
|
|
e16b7b8399 | ||
|
|
9abbe349af | ||
|
|
509ce7f766 | ||
|
|
0ac6efa6d5 | ||
|
|
6f04866044 | ||
|
|
021037c419 | ||
|
|
4baafd8126 | ||
|
|
48dd72005e | ||
|
|
7bc3f5dd8a | ||
|
|
56a33b157b | ||
|
|
c7046b9a0c | ||
|
|
6ac3343617 | ||
|
|
f1dd95650b | ||
|
|
6767072c9d | ||
|
|
efbcf8747d | ||
|
|
73b8c3ebf3 | ||
|
|
25211020bf | ||
|
|
24634b6281 | ||
|
|
3a89d1ef7f | ||
|
|
a61b8a2033 | ||
|
|
c164f5886f | ||
|
|
d285f7fd4d | ||
|
|
44ded35d5d | ||
|
|
f429057072 | ||
|
|
11dedde511 | ||
|
|
2dc74f2e4d | ||
|
|
4651180503 | ||
|
|
bb53c20c18 | ||
|
|
0a86d3579e | ||
|
|
4a5017d1d8 | ||
|
|
3ef3802629 | ||
|
|
8aba77b7be | ||
|
|
5e6a7c85cc | ||
|
|
e7c6f81016 | ||
|
|
604b02cfaa | ||
|
|
d6bd9c0e7f | ||
|
|
9ffe549ab1 | ||
|
|
06ce9da32a | ||
|
|
c29bfd2ff3 | ||
|
|
383c682563 | ||
|
|
8a37a1cc2d | ||
|
|
65c9004550 | ||
|
|
6abd984608 | ||
|
|
f941879c15 | ||
|
|
05213e4c8c | ||
|
|
3e2cc2d2c4 | ||
|
|
ba6dedbbbd | ||
|
|
f26312ffbf | ||
|
|
e31480cf44 | ||
|
|
1e5a94fdb5 | ||
|
|
75e13c8977 | ||
|
|
b9ade6e6bb | ||
|
|
c0d3e4315c | ||
|
|
8865eb2866 | ||
|
|
097a501414 | ||
|
|
7d75dbbdda | ||
|
|
f569950664 | ||
|
|
a4ebd9af33 | ||
|
|
d5d0a36f66 | ||
|
|
8f301ed62d | ||
|
|
3211bc5f23 | ||
|
|
6789088dce | ||
|
|
6a45fab608 | ||
|
|
519c6fc7e7 | ||
|
|
ac46e87685 | ||
|
|
526bb6f3e9 | ||
|
|
462a11301a | ||
|
|
ad8509f361 | ||
|
|
739b937b74 | ||
|
|
7e4f8b45b6 | ||
|
|
121ba57b55 | ||
|
|
9ee979167a | ||
|
|
a775107f5f | ||
|
|
cd9b1b1fd3 | ||
|
|
a3715e7867 | ||
|
|
4feee126b8 | ||
|
|
19ea306606 | ||
|
|
0dda866679 | ||
|
|
84d2e6c8a0 | ||
|
|
30962cb200 | ||
|
|
3f58cbaae9 | ||
|
|
a4c9a80dac | ||
|
|
6311bd119e | ||
|
|
796eb522ac | ||
|
|
e755475475 | ||
|
|
15a64b805e | ||
|
|
6c9862662f | ||
|
|
6bbc92a6f5 | ||
|
|
459e9de81a | ||
|
|
0926a23014 | ||
|
|
f27fefd7b8 | ||
|
|
29a5931c6a | ||
|
|
2182e1badc | ||
|
|
106ee8f30a | ||
|
|
1acf066fb9 | ||
|
|
e7f4319ac6 | ||
|
|
c2eb869f72 | ||
|
|
8cb410c63c | ||
|
|
ba5404d93e | ||
|
|
4ca857e0e9 | ||
|
|
621dabd44e | ||
|
|
3e147967e2 | ||
|
|
9c0147915e | ||
|
|
d31d4c05cf | ||
|
|
094bca5ac3 | ||
|
|
87821fce0e | ||
|
|
fce47e2e63 | ||
|
|
9b9d26f80e | ||
|
|
58688c48aa | ||
|
|
5d56225d95 | ||
|
|
070e3b4178 | ||
|
|
2cea9433c2 | ||
|
|
33b337f618 | ||
|
|
543fb99bc6 | ||
|
|
8b8a211185 | ||
|
|
4a38189349 | ||
|
|
ed781e84ee | ||
|
|
ac5b7d518e | ||
|
|
8d4eae5662 | ||
|
|
a78cc98c8b | ||
|
|
8db145da1e | ||
|
|
68f5c9c72d | ||
|
|
a9ca8df8e3 | ||
|
|
67bf0933e2 | ||
|
|
5d7bff4051 | ||
|
|
9f6d685c05 | ||
|
|
10e05f9867 | ||
|
|
76ef8770cd | ||
|
|
dafa0f022c | ||
|
|
390472566c | ||
|
|
a18a374d51 | ||
|
|
8e47966225 | ||
|
|
1415eb3dd2 | ||
|
|
5d397462e4 | ||
|
|
5ae542e7ee | ||
|
|
d9deb4b530 | ||
|
|
89763f2ace | ||
|
|
9df4e7597d | ||
|
|
08a8ccf46b | ||
|
|
2756437f4b | ||
|
|
15b9946a40 | ||
|
|
d9961f40bf | ||
|
|
05831b52c4 | ||
|
|
b92fcf23fd | ||
|
|
38f64b3da3 | ||
|
|
9f47c6083a | ||
|
|
6609093625 | ||
|
|
591fa23f6e | ||
|
|
daf150c38d | ||
|
|
f98d13e7dc | ||
|
|
bed8153ba0 | ||
|
|
297ebb1160 | ||
|
|
ff55eb5bfa | ||
|
|
80e0158112 | ||
|
|
05855393f0 | ||
|
|
a790e16fa2 | ||
|
|
25c604fb1c | ||
|
|
38e13942ac | ||
|
|
b58bf49e91 | ||
|
|
80444436f3 | ||
|
|
44d6a2c435 | ||
|
|
946ed97273 | ||
|
|
b1264a7416 | ||
|
|
b3c4956efe | ||
|
|
6a6a42aa3a | ||
|
|
862fe15c32 | ||
|
|
fde36fccc3 | ||
|
|
5bebbd81d7 | ||
|
|
a02c7e804c | ||
|
|
06ffed3216 | ||
|
|
91ad830c88 | ||
|
|
7342615c7d | ||
|
|
abb728684b | ||
|
|
4d6091379b | ||
|
|
ea8c8c5f33 | ||
|
|
abf3a5d50e | ||
|
|
f575e39b0a | ||
|
|
10f58cb1bc | ||
|
|
a94535f318 | ||
|
|
d2dfbef05a | ||
|
|
d8332e6373 | ||
|
|
0785f2872f | ||
|
|
5761ab6b55 | ||
|
|
5289da29ba | ||
|
|
c95f1d1ff9 | ||
|
|
01943062b4 | ||
|
|
86182f33c3 | ||
|
|
1c853c6860 | ||
|
|
2a585dc4ed | ||
|
|
42fd44f1db | ||
|
|
992dd86309 | ||
|
|
2f813ef75d | ||
|
|
32299e4010 | ||
|
|
e8b25188ad | ||
|
|
dc3fdc8dc7 | ||
|
|
1eaefbf169 | ||
|
|
5730cbf3e3 | ||
|
|
eb5f4460d1 | ||
|
|
37ffdff5ba | ||
|
|
ed62d1263c | ||
|
|
a8b1379ccb | ||
|
|
6b804f3a4a | ||
|
|
539c73bdb1 | ||
|
|
6dc6333323 | ||
|
|
353f2a2ad4 | ||
|
|
53957dcbaa | ||
|
|
e831649b64 | ||
|
|
fd2ef18a70 | ||
|
|
c92c2bfb10 | ||
|
|
bbca6fe5b0 | ||
|
|
5cce40d4c3 | ||
|
|
d0aa883e07 | ||
|
|
fcd3b260ac | ||
|
|
a0ec4a11ee | ||
|
|
25d2000625 | ||
|
|
b3604dcf83 | ||
|
|
db4452d307 | ||
|
|
10a656eedb | ||
|
|
3c9619bb0a | ||
|
|
48b6d18e7f | ||
|
|
3a7636ff0f | ||
|
|
5bed597e61 | ||
|
|
7b4f0398c3 | ||
|
|
385236e967 | ||
|
|
df818c1b69 | ||
|
|
c2b8f3b55a | ||
|
|
1f22a199fb | ||
|
|
9c40a4edc5 | ||
|
|
eddcc3dfa9 | ||
|
|
fd35b6f836 | ||
|
|
eb0c33cba4 | ||
|
|
284b94662a | ||
|
|
d69b364b5f | ||
|
|
90ad041fa5 | ||
|
|
59e667906f | ||
|
|
a22c06a2d6 | ||
|
|
9a4855295b | ||
|
|
dd46f634fe | ||
|
|
af2b0f452c | ||
|
|
9b5da97e6f | ||
|
|
683ddbc466 | ||
|
|
7825871d6a | ||
|
|
9afb0d739e | ||
|
|
6f2169037e | ||
|
|
480f5d3184 | ||
|
|
1af09d6330 | ||
|
|
62f234ce3b | ||
|
|
387f4d42cc | ||
|
|
d1e6388fed | ||
|
|
2afe395ff2 | ||
|
|
daa26079ee | ||
|
|
fe26b5d25f | ||
|
|
43d62c1ae3 | ||
|
|
70355021d8 | ||
|
|
dba0d54cf5 | ||
|
|
1a3c334c75 | ||
|
|
adad557499 | ||
|
|
ad566a86de | ||
|
|
71dc6e04e8 | ||
|
|
38df960e68 | ||
|
|
0907ca1931 | ||
|
|
760e39e405 | ||
|
|
5d78371628 | ||
|
|
9294cb099f | ||
|
|
4dcb5040a0 | ||
|
|
d7626cd9d7 | ||
|
|
8608c6970d | ||
|
|
693b3d03e6 | ||
|
|
eb9826f65d | ||
|
|
56157444de | ||
|
|
0aab5811ca | ||
|
|
687c4a9fab | ||
|
|
33ae063cae | ||
|
|
762459954f | ||
|
|
972a6f5656 | ||
|
|
f05b32f7ad | ||
|
|
0a2a354499 | ||
|
|
b4ef3e5071 | ||
|
|
fbb030d7f7 | ||
|
|
64b5f39656 | ||
|
|
325e20d76d | ||
|
|
88f3ffe86e | ||
|
|
cebc988dd4 | ||
|
|
abedfa77da | ||
|
|
ff4b4e667a | ||
|
|
4bc0f6e7e9 | ||
|
|
f68ade7b1d | ||
|
|
095ecf2d90 | ||
|
|
b7c364a853 | ||
|
|
5aa49e695e | ||
|
|
2988c594cc | ||
|
|
9ed62eeb91 | ||
|
|
6bca92db4d | ||
|
|
4658c063d5 | ||
|
|
3a20a05a49 | ||
|
|
9dd72b9583 | ||
|
|
b7d031cc92 | ||
|
|
93b353d353 | ||
|
|
bf38a311da | ||
|
|
3af09ac946 | ||
|
|
d528184836 | ||
|
|
2cb2bb8257 | ||
|
|
56ddd3c0b1 | ||
|
|
82efcc32ec | ||
|
|
35ca994ba2 | ||
|
|
9400fdac77 | ||
|
|
4ca2200d83 | ||
|
|
45043ebf3e | ||
|
|
d42b86d22b | ||
|
|
c734789b18 | ||
|
|
205857b232 | ||
|
|
97ca5711f9 | ||
|
|
123ae9e103 | ||
|
|
8fa1858a2c | ||
|
|
1764ef81ef | ||
|
|
fecf8dc44e | ||
|
|
9200a0be7a | ||
|
|
18ea820cb0 | ||
|
|
631a618238 | ||
|
|
b01dcd7971 | ||
|
|
962fa20b36 | ||
|
|
64caf59e84 | ||
|
|
0a9005678d | ||
|
|
96dd3e8eb9 | ||
|
|
6fab9a3e6f | ||
|
|
a448524424 | ||
|
|
6b37b2d79d | ||
|
|
e3c3d746f7 | ||
|
|
b769aa59d3 | ||
|
|
fc9107a16a | ||
|
|
c7a8db5543 | ||
|
|
14ebcab5b0 | ||
|
|
105ce36792 | ||
|
|
9b5f5ed8e8 | ||
|
|
273f1b385c | ||
|
|
63d499f480 | ||
|
|
5c60162e3c | ||
|
|
a6dd9e8e7e | ||
|
|
4278199101 | ||
|
|
f39865e8e4 | ||
|
|
8548624676 | ||
|
|
8a873b97a3 | ||
|
|
8cb8a0da8d | ||
|
|
d771614d33 | ||
|
|
372a8cb1d9 | ||
|
|
3f3b01c7ce | ||
|
|
51c95747d8 | ||
|
|
e323f6620d | ||
|
|
ccba613e5b | ||
|
|
e97006b102 | ||
|
|
ffab22bb35 | ||
|
|
83af55bed4 | ||
|
|
be0d6faa15 | ||
|
|
751a2fa915 | ||
|
|
81a457e6fb | ||
|
|
459abafcea | ||
|
|
7a4bac82d7 | ||
|
|
74c35c513e | ||
|
|
c5ac2579ba | ||
|
|
61b7dc522d | ||
|
|
c089e19020 | ||
|
|
7d5e494716 | ||
|
|
f8aa5821be | ||
|
|
34bb735a65 | ||
|
|
04319964b9 | ||
|
|
8102ec3be5 | ||
|
|
71ede76c68 | ||
|
|
2e5b3ab8bc | ||
|
|
ddf97f8289 | ||
|
|
1ba5ce9cb3 | ||
|
|
f949107a32 | ||
|
|
be16f79438 | ||
|
|
7b847ced4a | ||
|
|
4f1d81c4ce | ||
|
|
90400ae96a | ||
|
|
a910b38a35 | ||
|
|
c7394ac4e0 | ||
|
|
43cd40e87a | ||
|
|
1eb303e6d4 | ||
|
|
926b52b600 | ||
|
|
915a1913e1 | ||
|
|
65ac8e9f0c | ||
|
|
f817a338d0 | ||
|
|
0198bb6bf3 | ||
|
|
1501b3fbbd | ||
|
|
234ad54b2c | ||
|
|
bf121f7c60 | ||
|
|
c741f2f4a6 | ||
|
|
55336657d4 | ||
|
|
c41aa49059 | ||
|
|
3f4418d84d | ||
|
|
036de0c5e4 | ||
|
|
c488e5e40d | ||
|
|
8b7be5861e | ||
|
|
fa617467b1 | ||
|
|
145ba777e8 | ||
|
|
dc6271cd79 | ||
|
|
003a2e6479 | ||
|
|
840fff5e5e | ||
|
|
1c58b94141 | ||
|
|
406fc209ac | ||
|
|
feaf91ab93 | ||
|
|
c828c2f366 | ||
|
|
e7cd547457 | ||
|
|
5cf994856f | ||
|
|
09cbd0c695 | ||
|
|
7a359c00ac | ||
|
|
39154402e5 | ||
|
|
375be90fd1 | ||
|
|
3ad4de6c8c | ||
|
|
3026118c70 | ||
|
|
e2ff51f93f | ||
|
|
52793e7a3f | ||
|
|
2e3bb5a511 | ||
|
|
b02e429788 | ||
|
|
7a005b91b3 | ||
|
|
bc497dbb92 | ||
|
|
9a52ef099a | ||
|
|
85e8b70625 | ||
|
|
e0a19abb99 | ||
|
|
4310282a4c | ||
|
|
4ec8ade11c | ||
|
|
ff65e37545 | ||
|
|
f0635717b3 | ||
|
|
60db6e3df4 | ||
|
|
edcb22a6fb | ||
|
|
181e1bcffd | ||
|
|
fa64c1235e | ||
|
|
ec0c33b844 | ||
|
|
de73fed73d | ||
|
|
d7de29e1e5 | ||
|
|
ad18e45206 | ||
|
|
57381aa560 | ||
|
|
b3107d26df | ||
|
|
05f1680efa | ||
|
|
6491274f60 | ||
|
|
e985629440 | ||
|
|
90f8151ffd | ||
|
|
92cc3a6914 | ||
|
|
06ddd3dcf8 | ||
|
|
5e01b6d663 | ||
|
|
e89e70e715 | ||
|
|
ccaf8724e4 | ||
|
|
04e97e8aef | ||
|
|
746fe5832a | ||
|
|
4027335fa9 | ||
|
|
bcddddf98d | ||
|
|
12ef3ceda1 | ||
|
|
a0647f1616 | ||
|
|
9e3bb986d5 | ||
|
|
93bf2a1d72 | ||
|
|
6b69b93b53 | ||
|
|
189fb08e13 | ||
|
|
ac54dee9bb | ||
|
|
9a391b3320 | ||
|
|
1673735f02 | ||
|
|
e4bb08e1f5 | ||
|
|
5db47ed53a | ||
|
|
95caeaa5dc | ||
|
|
97f105cde2 | ||
|
|
61f3fc7e4d | ||
|
|
8df3035831 | ||
|
|
6d86882ed4 | ||
|
|
9f1dd4d0af | ||
|
|
5f13bb0c3a | ||
|
|
479d614884 | ||
|
|
071494d8fa | ||
|
|
a87228b4ff | ||
|
|
a419e73f7a | ||
|
|
2b331084b4 | ||
|
|
c1d6d7ac6b | ||
|
|
d3c461097b | ||
|
|
f596be9950 | ||
|
|
9e5d585ba4 | ||
|
|
86785004ba | ||
|
|
2da4864483 | ||
|
|
309b76fb32 | ||
|
|
d95274c5f2 | ||
|
|
13e29dd7b5 | ||
|
|
ad0aad21d5 | ||
|
|
fc65da1eed | ||
|
|
584eda8339 | ||
|
|
639fbe0392 | ||
|
|
55d8c01c33 | ||
|
|
6b3b852ebc | ||
|
|
34a82e7629 | ||
|
|
2bb89bc5bc | ||
|
|
133173850c | ||
|
|
c6dac5c3c9 | ||
|
|
029599c02c | ||
|
|
1d1ea681f0 | ||
|
|
5a1a106637 | ||
|
|
ce4eb6559e | ||
|
|
4a04b498db | ||
|
|
16e017d5a6 | ||
|
|
ba84ddcf8e | ||
|
|
895171478f | ||
|
|
e0d1954840 | ||
|
|
96a7cf1e6a | ||
|
|
05b511f96a | ||
|
|
bb14c36a27 | ||
|
|
5ee84436c8 | ||
|
|
f7df0bac96 | ||
|
|
dd4a3b24fc | ||
|
|
ddad0be5f7 | ||
|
|
bb4bab4c26 | ||
|
|
2ec2837daa | ||
|
|
6a309c53a8 | ||
|
|
5bd72ec629 | ||
|
|
e43b6a2dd2 | ||
|
|
3eb6080de3 | ||
|
|
76a9d98562 | ||
|
|
6945e86fd7 | ||
|
|
044ebf1952 | ||
|
|
b9a179089b | ||
|
|
725938fb85 | ||
|
|
c6012aaabc | ||
|
|
c0862dae45 | ||
|
|
54afcfbfb4 | ||
|
|
b292f71c49 | ||
|
|
e32e0d5692 | ||
|
|
73732ffa05 | ||
|
|
ff2cc0e387 | ||
|
|
550b855c9d | ||
|
|
6036bdd06c | ||
|
|
fc6a65c620 | ||
|
|
0ca6f667e3 | ||
|
|
6f5150a943 | ||
|
|
ad006bc6b6 | ||
|
|
ce53936a2b | ||
|
|
1938c994e7 | ||
|
|
7ddba901a4 | ||
|
|
d3b5c242cc | ||
|
|
216df07688 | ||
|
|
65deba3a35 | ||
|
|
9642f0373f | ||
|
|
3e9d9a2119 | ||
|
|
924bf8477f | ||
|
|
92da443a9e | ||
|
|
780fd8f7a6 | ||
|
|
aa3403a343 | ||
|
|
9601b72e4c | ||
|
|
ca617d679f | ||
|
|
615d85fb23 | ||
|
|
f08c9b2217 | ||
|
|
ae2ea52575 | ||
|
|
e76caa0017 | ||
|
|
975f516f51 | ||
|
|
fe20c0d89e | ||
|
|
4a9b01eb0d | ||
|
|
6910458a92 | ||
|
|
ceace9c6bd | ||
|
|
5f108d9df6 | ||
|
|
5d91555c7c | ||
|
|
cba885a67c | ||
|
|
cf411053c7 | ||
|
|
023d8d38ec | ||
|
|
359285928b | ||
|
|
0b788a3d61 | ||
|
|
88555d96d5 | ||
|
|
9e49ec6cd3 | ||
|
|
22d51ec1ea | ||
|
|
fa8333eddb | ||
|
|
22355ce947 | ||
|
|
bd098c273b | ||
|
|
e415ead361 | ||
|
|
2f7198246e | ||
|
|
289320a9b1 | ||
|
|
4cbbbddf22 | ||
|
|
9cd5ba40d3 | ||
|
|
4a6d62e401 | ||
|
|
daa1faa905 | ||
|
|
25d5734496 | ||
|
|
58361eb965 | ||
|
|
5f2f07ed8a | ||
|
|
81181bfb72 | ||
|
|
24e1327d0d | ||
|
|
29f9d5f335 | ||
|
|
86c93c6e34 | ||
|
|
643c219d18 | ||
|
|
f63761eabc | ||
|
|
8c497ecac0 | ||
|
|
084d07f4eb | ||
|
|
b4efd1ca89 | ||
|
|
923ccfa2e8 | ||
|
|
474fdebb7a | ||
|
|
9ced016cbc | ||
|
|
e538d4adae | ||
|
|
eb424cf63d | ||
|
|
69e150b7e3 | ||
|
|
fe5edad1fc | ||
|
|
4c5c125173 | ||
|
|
68e06fb6b7 | ||
|
|
003e8e65f7 | ||
|
|
710393e388 | ||
|
|
2660692fb1 | ||
|
|
916669a244 | ||
|
|
46f80d01ff | ||
|
|
b11b1dd1c0 | ||
|
|
1ec736a3dc | ||
|
|
c506e7f711 | ||
|
|
eb8ab96980 | ||
|
|
e225ce0fd7 | ||
|
|
e8c10f5b34 | ||
|
|
5050171f6b | ||
|
|
dbbb297d5f | ||
|
|
be17ac1eb2 | ||
|
|
40c242a6d5 | ||
|
|
a7075f1c66 | ||
|
|
1675ddb4d1 | ||
|
|
ed8350422e | ||
|
|
9144d30848 | ||
|
|
83078bdcbc | ||
|
|
74d0851ac5 | ||
|
|
23326e40cf | ||
|
|
3db2433448 | ||
|
|
7e796dea03 | ||
|
|
096cbf2ea5 | ||
|
|
f4b8f00255 | ||
|
|
da8401d8be | ||
|
|
2de599ac0e | ||
|
|
7b4077ef87 | ||
|
|
27cfa81110 | ||
|
|
013b88dfc3 | ||
|
|
6d2830a473 | ||
|
|
69f3c24647 | ||
|
|
c2b0fdae5b | ||
|
|
89262c62fe | ||
|
|
18665b8cc9 | ||
|
|
a3c32841e6 | ||
|
|
1156467726 | ||
|
|
74749e8705 | ||
|
|
85e0d8a221 | ||
|
|
38b2c42f63 | ||
|
|
50bd094856 | ||
|
|
f031975dc0 | ||
|
|
d42fb43f4f | ||
|
|
d6015824dd | ||
|
|
6c1f03578d | ||
|
|
8dd2f0da3f | ||
|
|
0ba85cc326 | ||
|
|
c1a4c0186a | ||
|
|
52ec9b9ec4 | ||
|
|
ebe07c2726 | ||
|
|
3f16fcb30a | ||
|
|
2faec76afa | ||
|
|
655a1aea6c | ||
|
|
6521427a45 | ||
|
|
7d45e29683 | ||
|
|
41d985ace3 | ||
|
|
e659aa86b9 | ||
|
|
5823854b5e | ||
|
|
c5dbec9e85 | ||
|
|
646cfa6983 | ||
|
|
fdda4142bf | ||
|
|
3f76a973ee | ||
|
|
4215d009a5 | ||
|
|
a35630838f | ||
|
|
dc373abba8 | ||
|
|
f60bc7e03b | ||
|
|
49c776ea59 | ||
|
|
3686645e77 | ||
|
|
df91860b52 | ||
|
|
29d4016572 | ||
|
|
6e3f673ef7 | ||
|
|
35876eaab9 |
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
*.o
|
||||||
|
*~
|
||||||
|
.deps/
|
||||||
|
aclocal.m4
|
||||||
|
autom4te.cache/
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
etc/
|
||||||
|
tmux
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
configure
|
||||||
110
CHANGES
110
CHANGES
@@ -1,3 +1,113 @@
|
|||||||
|
CHANGES FROM 1.6 to 1.7, 13 October 2012
|
||||||
|
|
||||||
|
* tmux configuration files now support line-continuation with a "\" at the
|
||||||
|
end of a line.
|
||||||
|
* New option status-position to move the status line to the top or bottom of
|
||||||
|
the screen.
|
||||||
|
* Enforce history-limit option when clearing the screen.
|
||||||
|
* Give each window a unique id, like panes but prefixed with @.
|
||||||
|
* Add pane id to each pane in layout description (while still accepting
|
||||||
|
the old form).
|
||||||
|
* Provide defined ways to set the various default-path possibilities: ~
|
||||||
|
for home directory, . for server start directory, - for session start
|
||||||
|
directory and empty for the pane's working directory (the default). All
|
||||||
|
can also be used as part of a relative path (eg -/foo). Also provide -c
|
||||||
|
flags to neww and splitw to override default-path setting.
|
||||||
|
* Add -l flag to send-keys to send input literally (without translating
|
||||||
|
key names).
|
||||||
|
* Allow a single option to be specified to show-options to show just that
|
||||||
|
option.
|
||||||
|
* New command "move-pane" (like join-pane but allows the same window).
|
||||||
|
* join-pane and move-pane commands learn "-b" option to place the pane to
|
||||||
|
the left or above.
|
||||||
|
* Support for bracketed-paste mode.
|
||||||
|
* Allow send-keys command to accept hex values.
|
||||||
|
* Add locking around "start-server" to avoid race-conditions.
|
||||||
|
* break-pane learns -P/-F arguments for display formatting.
|
||||||
|
* set-option learns "-q" to make it quiet, and not print out anything.
|
||||||
|
* copy mode learns "wrap-search" option.
|
||||||
|
* Add a simple form of output rate limiting by counting the number of
|
||||||
|
certain C0 sequences (linefeeds, backspaces, carriage returns) and if it
|
||||||
|
exceeds a threshold (current default 250/millisecond), start to redraw
|
||||||
|
the pane every 100 milliseconds instead of making each change as it
|
||||||
|
comes. Two configuration options - c0-change-trigger and
|
||||||
|
c0-change-interval.
|
||||||
|
* find-window learns new flags: "-C", "-N", "-T" to match against either or
|
||||||
|
all of a window's content, name, or title. Defaults to all three options
|
||||||
|
if none specified.
|
||||||
|
* find-window automatically selects the appropriate pane for the found
|
||||||
|
matches.
|
||||||
|
* show-environment can now accept one option to show that environment value.
|
||||||
|
* Exit mouse mode when end-of-screen reached when scrolling with the mouse
|
||||||
|
wheel.
|
||||||
|
* select-layout learns -u and -U for layout history stacks.
|
||||||
|
* kill-window, detach-client, kill-session all learn "-a" option for
|
||||||
|
killing all but the current thing specified.
|
||||||
|
* move-window learns "-r" option to renumber window sequentially in a
|
||||||
|
session.
|
||||||
|
* New session option "renumber-windows" to automatically renumber windows in
|
||||||
|
a session when a window is closed. (see "move-window -r").
|
||||||
|
* Only enter copy-mode on scroll up.
|
||||||
|
* choose-* and list-* commands all use "-F" for format specifiers.
|
||||||
|
* When spawning external commands, the value from the "default-shell" option
|
||||||
|
is now used, rather than assuming /bin/sh.
|
||||||
|
* New choose-tree command to render window/sessions as a tree for selection.
|
||||||
|
* display-message learns new format options.
|
||||||
|
* For linked-windows across sessions, all flags for that window are now
|
||||||
|
cleared across sessions.
|
||||||
|
* Lots and lots of bug fixes, fixing memory-leaks, etc.
|
||||||
|
* Various manpage improvements.
|
||||||
|
|
||||||
|
CHANGES FROM 1.5 TO 1.6, 23 January 2012
|
||||||
|
|
||||||
|
* Extend the mode-mouse option to add a third choice which means the mouse
|
||||||
|
does not enter copy mode.
|
||||||
|
* Add a -r flag to switch-client to toggle the client read-only flag.
|
||||||
|
* Add pane-base-index option.
|
||||||
|
* Support \ for line continuation in the configuration file.
|
||||||
|
* Framework for more powerful formatting of command output and use it for
|
||||||
|
list-{panes,windows,sessions}. This allows more descriptive replacements
|
||||||
|
(such as #{session_name}) and conditionals.
|
||||||
|
* Mark dead panes with some text saying they are dead.
|
||||||
|
* Reject $SHELL if it is not a full path.
|
||||||
|
* Add -S option to refresh-client to redraw status line.
|
||||||
|
* Add an else clause for if-shell.
|
||||||
|
* Try to resolve relative paths for loadb and saveb (first, using client
|
||||||
|
working directory, if any, then default-path or session working directory).
|
||||||
|
* Support for \e[3J to clear the history and send the corresponding
|
||||||
|
terminfo code (E3) before locking.
|
||||||
|
* When in copy mode, make repeat count indicate buffer to replace, if used.
|
||||||
|
* Add screen*:XT to terminal-overrides for tmux-in-tmux.
|
||||||
|
* Status-line message attributes added.
|
||||||
|
* Move word-separators to be a session rather than window option.
|
||||||
|
* Change the way the working directory for new processes is discovered. If
|
||||||
|
default-path isn't empty, it is used. Otherwise, if a new window is created
|
||||||
|
from the command-line, the working directory of the client is used. If not,
|
||||||
|
platform specific code is used to retrieve the current working directory
|
||||||
|
of the process in the active pane. If that fails, the directory where the
|
||||||
|
session was created is used, instead.
|
||||||
|
* Do not change the current pane if both mouse-select-{pane,window} are
|
||||||
|
enabled.
|
||||||
|
* Add \033[s and \033[u to save and restore cursor position.
|
||||||
|
* Allow $HOME to be used as default-path.
|
||||||
|
* Add CNL and CPL escape sequences.
|
||||||
|
* Calculate last position correctly for UTF-8 wide characters.
|
||||||
|
* Add an option allow-rename to disable the window rename escape sequence.
|
||||||
|
* Attributes for each type of status-line alert (ie bell, content and
|
||||||
|
activity) added. Therefore, remove the superfluous options
|
||||||
|
window-status-alert-{attr,bg,fg}.
|
||||||
|
* Add a -R flag to send-keys to reset the terminal.
|
||||||
|
* Add strings to allow the aixterm bright colours to be used when
|
||||||
|
configuring colours.
|
||||||
|
* Drop the ability to have a list of keys in the prefix in favour of two
|
||||||
|
separate options, prefix and prefix2.
|
||||||
|
* Flag -2 added to send-prefix to send the secondary prefix key.
|
||||||
|
* Show pane size in top right of display panes mode.
|
||||||
|
* Some memory leaks plugged.
|
||||||
|
* More command-prompt editing improvements.
|
||||||
|
* Various manpage improvements.
|
||||||
|
* More Vi mode improvements.
|
||||||
|
|
||||||
CHANGES FROM 1.4 TO 1.5, 09 July 2011
|
CHANGES FROM 1.4 TO 1.5, 09 July 2011
|
||||||
|
|
||||||
* Support xterm mouse modes 1002 and 1003.
|
* Support xterm mouse modes 1002 and 1003.
|
||||||
|
|||||||
32
FAQ
32
FAQ
@@ -409,5 +409,37 @@ If your urxvt cannot display italics at all, make sure you have an italics
|
|||||||
capable font enabled, for example, add to ~/.Xdefaults:
|
capable font enabled, for example, add to ~/.Xdefaults:
|
||||||
|
|
||||||
urxvt.italicFont: xft:Bitstream Vera Sans Mono:italic:autohint=true
|
urxvt.italicFont: xft:Bitstream Vera Sans Mono:italic:autohint=true
|
||||||
|
|
||||||
|
* How can I make tmux use my terminal's scrollback buffer?
|
||||||
|
|
||||||
|
Normally, tmux enables the terminal's "alternate screen". Most terminals (such
|
||||||
|
as xterm) do not save scrollback for the alternate screen. You might prefer
|
||||||
|
tmux to use the normal screen, so it uses your terminal's scrollback
|
||||||
|
buffer. This way, you can access the scrollback buffer as usual, for example
|
||||||
|
using the mouse wheel - although there is no guarantee output inside tmux will
|
||||||
|
always (or ever) be added to the scrollback.
|
||||||
|
|
||||||
|
You can make tmux use the normal screen by telling it that your terminal does
|
||||||
|
not have an alternate screen. Put the following in ~/.tmux.conf:
|
||||||
|
|
||||||
|
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
|
||||||
|
|
||||||
|
Adjust if your $TERM does not start with xterm.
|
||||||
|
|
||||||
|
tmux will still emulate the alternate screen for applications run under tmux,
|
||||||
|
so you don't really lose anything with this setting. The only disadvantage is
|
||||||
|
that when you exit tmux, it will not restore whatever was there before you
|
||||||
|
started.
|
||||||
|
|
||||||
|
* How do I see the default configuration?
|
||||||
|
|
||||||
|
Show the default session options by starting a new tmux server with no
|
||||||
|
configuration file:
|
||||||
|
|
||||||
|
$ tmux -Lfoo -f/dev/null start\; show -g
|
||||||
|
|
||||||
|
Or the default window options:
|
||||||
|
|
||||||
|
$ tmux -Lfoo -f/dev/null start\; show -gw
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
|
|||||||
16
Makefile.am
16
Makefile.am
@@ -43,11 +43,6 @@ CPPFLAGS += -I. -I- -I/usr/local/include
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Set flags for static.
|
|
||||||
if IS_STATIC
|
|
||||||
LDFLAGS += -static
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Set flags for Solaris.
|
# Set flags for Solaris.
|
||||||
if IS_SUNOS
|
if IS_SUNOS
|
||||||
CPPFLAGS += -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS
|
CPPFLAGS += -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS
|
||||||
@@ -71,8 +66,8 @@ dist_tmux_SOURCES = \
|
|||||||
cmd-capture-pane.c \
|
cmd-capture-pane.c \
|
||||||
cmd-choose-buffer.c \
|
cmd-choose-buffer.c \
|
||||||
cmd-choose-client.c \
|
cmd-choose-client.c \
|
||||||
cmd-choose-session.c \
|
cmd-choose-list.c \
|
||||||
cmd-choose-window.c \
|
cmd-choose-tree.c \
|
||||||
cmd-clear-history.c \
|
cmd-clear-history.c \
|
||||||
cmd-clock-mode.c \
|
cmd-clock-mode.c \
|
||||||
cmd-command-prompt.c \
|
cmd-command-prompt.c \
|
||||||
@@ -140,7 +135,10 @@ dist_tmux_SOURCES = \
|
|||||||
cmd-unlink-window.c \
|
cmd-unlink-window.c \
|
||||||
cmd.c \
|
cmd.c \
|
||||||
colour.c \
|
colour.c \
|
||||||
|
control.c \
|
||||||
|
control-notify.c \
|
||||||
environ.c \
|
environ.c \
|
||||||
|
format.c \
|
||||||
grid-utf8.c \
|
grid-utf8.c \
|
||||||
grid-view.c \
|
grid-view.c \
|
||||||
grid.c \
|
grid.c \
|
||||||
@@ -155,6 +153,7 @@ dist_tmux_SOURCES = \
|
|||||||
log.c \
|
log.c \
|
||||||
mode-key.c \
|
mode-key.c \
|
||||||
names.c \
|
names.c \
|
||||||
|
notify.c \
|
||||||
options-table.c \
|
options-table.c \
|
||||||
options.c \
|
options.c \
|
||||||
paste.c \
|
paste.c \
|
||||||
@@ -226,6 +225,9 @@ endif
|
|||||||
if NO_STRTONUM
|
if NO_STRTONUM
|
||||||
nodist_tmux_SOURCES += compat/strtonum.c
|
nodist_tmux_SOURCES += compat/strtonum.c
|
||||||
endif
|
endif
|
||||||
|
if NO_B64_NTOP
|
||||||
|
nodist_tmux_SOURCES += compat/b64_ntop.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Update SF web site.
|
# Update SF web site.
|
||||||
upload-index.html: update-index.html
|
upload-index.html: update-index.html
|
||||||
|
|||||||
53
NOTES
53
NOTES
@@ -5,60 +5,67 @@ to be accessed and controlled from a single terminal. tmux is intended to be a
|
|||||||
simple, modern, BSD-licensed alternative to programs such as GNU screen.
|
simple, modern, BSD-licensed alternative to programs such as GNU screen.
|
||||||
|
|
||||||
This release runs on OpenBSD, FreeBSD, NetBSD, Linux and OS X and may still
|
This release runs on OpenBSD, FreeBSD, NetBSD, Linux and OS X and may still
|
||||||
run on Solaris and AIX (although they haven't been tested in a while). It is
|
run on Solaris and AIX (although they haven't been tested in a while).
|
||||||
usable, although there remain a number of missing features and some remaining
|
|
||||||
bugs are expected.
|
|
||||||
|
|
||||||
Since the 1.2 release that tmux depends on libevent. Download it from:
|
Since the 1.2 release tmux depends on libevent. Download it from:
|
||||||
|
|
||||||
http://www.monkey.org/~provos/libevent/
|
http://www.monkey.org/~provos/libevent/
|
||||||
|
|
||||||
tmux consists of a server part and multiple clients. The server is created when
|
To build tmux from a release tarball, do:
|
||||||
required and runs continuously unless killed by the user. Clients access the
|
|
||||||
server through a socket in /tmp. Multiple sessions may be created on a single
|
|
||||||
server and attached to a number of clients. Each session may then have a number
|
|
||||||
of windows and windows may be linked to a number of sessions. Commands are
|
|
||||||
available to create, rename and destroy windows and sessions; to attach and
|
|
||||||
detach sessions from client terminals; to set configuration options; to split
|
|
||||||
windows into several simultaneously displayed panes; and to bind and unbind
|
|
||||||
command keys (invoked preceded by a prefix key, by default ctrl-b). Please see
|
|
||||||
the tmux(1) man page for further information.
|
|
||||||
|
|
||||||
A more extensive, but rough, todo list is included in the TODO file.
|
$ ./configure && make
|
||||||
|
$ sudo make install
|
||||||
|
|
||||||
tmux also depends on several features of the client terminal (TERM), if these
|
To get and build the latest version control checkout:
|
||||||
are missing it may refuse to run, or not behave correctly.
|
|
||||||
|
$ git clone git://tmux.git.sourceforge.net/gitroot/tmux/tmux
|
||||||
|
$ cd tmux
|
||||||
|
$ sh autogen.sh
|
||||||
|
$ ./configure && make
|
||||||
|
|
||||||
|
For more information see https://sourceforge.net/scm/?type=git&group_id=200378
|
||||||
|
and http://git-scm.com.
|
||||||
|
|
||||||
|
For documentation on using tmux, see the tmux.1 manpage. It can be viewed from
|
||||||
|
the source tree with:
|
||||||
|
|
||||||
|
$ nroff -mdoc tmux.1|less
|
||||||
|
|
||||||
|
Some common questions are answered in the FAQ file and a more extensive (but
|
||||||
|
slightly out of date) guide is available in the OpenBSD FAQ at
|
||||||
|
http://www.openbsd.org/faq/faq7.html#tmux. A rough todo list is in the TODO
|
||||||
|
file.
|
||||||
|
|
||||||
A Vim syntax file is available in the examples directory. To install it:
|
A Vim syntax file is available in the examples directory. To install it:
|
||||||
|
|
||||||
- Drop the file in the syntax directory in your runtimepath (such as
|
- Drop the file in the syntax directory into runtimepath (such as
|
||||||
~/.vim/syntax/tmux.vim).
|
~/.vim/syntax/tmux.vim).
|
||||||
- Make the filetype recognisable by adding the following to filetype.vim
|
- Make the filetype recognisable by adding the following to filetype.vim
|
||||||
in your runtimepath (~/.vim/filetype.vim):
|
(~/.vim/filetype.vim):
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
au BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux
|
au BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
- Switch on syntax highlighting by adding "syntax enable" to your vimrc file.
|
- Switch on syntax highlighting by adding "syntax enable" to .vimrc.
|
||||||
|
|
||||||
For debugging, running tmux with -v or -vv will generate server and client log
|
For debugging, running tmux with -v or -vv will generate server and client log
|
||||||
files in the current directory.
|
files in the current directory.
|
||||||
|
|
||||||
tmux mailing lists are available; visit:
|
tmux mailing lists are available. The visit:
|
||||||
|
|
||||||
https://sourceforge.net/mail/?group_id=200378
|
https://sourceforge.net/mail/?group_id=200378
|
||||||
|
|
||||||
Bug reports, feature suggestions and especially code contributions are most
|
Bug reports, feature suggestions and especially code contributions are most
|
||||||
welcome. Please send by email to:
|
welcome. Please send by email to:
|
||||||
|
|
||||||
nicm@users.sf.net
|
tmux-users@lists.sourceforge.net
|
||||||
|
|
||||||
This file and the CHANGES, FAQ and TODO files are licensed under the ISC
|
This file and the CHANGES, FAQ and TODO files are licensed under the ISC
|
||||||
license. Files under examples/ remain copyright their authors unless otherwise
|
license. Files under examples/ remain copyright their authors unless otherwise
|
||||||
stated in the file but permission has been received to distribute them with
|
stated in the file but permission has been received to distribute them with
|
||||||
tmux. All other files have a license and copyright notice at their
|
tmux. All other files have a license and copyright notice at their
|
||||||
start. Please contact me with any queries.
|
start.
|
||||||
|
|
||||||
-- Nicholas Marriott <nicm@users.sf.net>
|
-- Nicholas Marriott <nicm@users.sf.net>
|
||||||
|
|
||||||
|
|||||||
173
SYNCING
Normal file
173
SYNCING
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
Preamble
|
||||||
|
========
|
||||||
|
|
||||||
|
Tmux on SourceForge has two git repositories [1] "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 that long to appear in this git repository.
|
||||||
|
|
||||||
|
It is assumed that the person doing the sync has read/write access to the
|
||||||
|
tmux repository on SourceForge already.
|
||||||
|
|
||||||
|
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 ssh://${USER}@tmux.git.sf.net/gitroot/tmux/tmux
|
||||||
|
% git clone ssh://${USER}@tmux.git.sf.net/gitroot/tmux/tmux-openbsd
|
||||||
|
|
||||||
|
Note that you do not need additoinal 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
|
||||||
|
portable:
|
||||||
|
|
||||||
|
% 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 BULDING 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
|
||||||
|
|
||||||
|
Release tmux for next version
|
||||||
|
=============================
|
||||||
|
|
||||||
|
1. Comment the "found_debug=yes" line in configure.ac, since releases
|
||||||
|
don't have debugging enabled, otherwise make(1) aborts when
|
||||||
|
preparing the distribution.
|
||||||
|
|
||||||
|
2. Update and commit NOTES 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.
|
||||||
|
|
||||||
|
3. Tag with:
|
||||||
|
|
||||||
|
% git tag -a 1.X
|
||||||
|
|
||||||
|
Where "1.X" is the next version.
|
||||||
|
|
||||||
|
Push the tag out with:
|
||||||
|
|
||||||
|
% git push --tags
|
||||||
|
|
||||||
|
4. Build the tarball with make dist. Now that it's using autoconf there
|
||||||
|
shouldn't be any weird files (such as the original and rejection files
|
||||||
|
from patch(1)) but it doesn't hurt taking a quick look at it.
|
||||||
|
|
||||||
|
5. Split the release changes into a new file. This should be named
|
||||||
|
tmux-$VERSION-readme to make sourceforge show it automagically in specific
|
||||||
|
parts of the project page.
|
||||||
|
|
||||||
|
6. Upload the tarball and the above file. Make the tarball the default
|
||||||
|
download by selecting all operating systems under the file details.
|
||||||
|
|
||||||
|
7. Run make update-index.html upload-index.html to replace %%VERSION%%.
|
||||||
|
|
||||||
|
8. Bump version in configure.ac and uncomment "found_debug=yes" to create
|
||||||
|
a debug build by default.
|
||||||
|
|
||||||
|
9. Update freshmeat.
|
||||||
|
|
||||||
|
[1] http://tmux.git.sourceforge.net/git/gitweb-index.cgi
|
||||||
76
TODO
76
TODO
@@ -1,3 +1,19 @@
|
|||||||
|
NOTES
|
||||||
|
=====
|
||||||
|
|
||||||
|
This file describes rough notes regarding ideas for potential future tmux
|
||||||
|
development. It's not necessarily guaranteed that items in this TODO file
|
||||||
|
will ever get implemented.
|
||||||
|
|
||||||
|
It is asked therefore, that anyone thinking of undertaking a task in this
|
||||||
|
TODO file, email tmux-users@lists.sf.net to discuss the feature.
|
||||||
|
|
||||||
|
Thie file is split up between tmux user interface (UI) issues, and terminal
|
||||||
|
compatibility issues.
|
||||||
|
|
||||||
|
TMUX UI ISSUES
|
||||||
|
==============
|
||||||
|
|
||||||
- implicitly add exec to the commands for new windows (switch to disable it)?
|
- implicitly add exec to the commands for new windows (switch to disable it)?
|
||||||
- bring back detach-session to detach all clients on a session?
|
- bring back detach-session to detach all clients on a session?
|
||||||
- allow fnmatch for -c, so that you can, eg, detach all clients
|
- allow fnmatch for -c, so that you can, eg, detach all clients
|
||||||
@@ -6,13 +22,10 @@
|
|||||||
- flags to centre screen in window
|
- flags to centre screen in window
|
||||||
- activity/bell should be per-window not per-link? what if it is cur win in
|
- activity/bell should be per-window not per-link? what if it is cur win in
|
||||||
session not being watched?
|
session not being watched?
|
||||||
- next prev word etc in command prompt
|
|
||||||
- use a better termcap internally instead of screen, perhaps xterm
|
|
||||||
- should be able to move to a hidden pane and it would be moved into view. pane
|
- should be able to move to a hidden pane and it would be moved into view. pane
|
||||||
number in status line/top-right would be cool for this
|
number in status line/top-right would be cool for this
|
||||||
- support other mouse modes (highlight etc) and use it in copy mode
|
- support other mouse modes (highlight etc) and use it in copy mode
|
||||||
- set-remain-on-exit is a bit of a hack, some way to do it generically?
|
- set-remain-on-exit is a bit of a hack, some way to do it generically?
|
||||||
- clear window title on exit
|
|
||||||
- would be nice to be able to use "--" to mark start of command w/ neww etc
|
- would be nice to be able to use "--" to mark start of command w/ neww etc
|
||||||
to avoid quoting
|
to avoid quoting
|
||||||
- make command sequences more usable: don't require space after ;, handle
|
- make command sequences more usable: don't require space after ;, handle
|
||||||
@@ -22,7 +35,6 @@
|
|||||||
- hooks to which commands may be attached, for example: tmux add-hook
|
- hooks to which commands may be attached, for example: tmux add-hook
|
||||||
"new-session" if-shell "[ -e $HOME/.tmux-session.conf ]" source-file
|
"new-session" if-shell "[ -e $HOME/.tmux-session.conf ]" source-file
|
||||||
$HOME/.tmux-session.conf
|
$HOME/.tmux-session.conf
|
||||||
- get it passing all the vttest tests that don't require resizing the terminal
|
|
||||||
- way to set socket path from config file
|
- way to set socket path from config file
|
||||||
- what about utmp etc? can tmux update it like screen? setgid?
|
- what about utmp etc? can tmux update it like screen? setgid?
|
||||||
- warts on current naming:
|
- warts on current naming:
|
||||||
@@ -34,7 +46,6 @@
|
|||||||
- a way for force-width/height to apply to only one pane (how?)
|
- a way for force-width/height to apply to only one pane (how?)
|
||||||
- command to list what is actually running in each window with command line,
|
- command to list what is actually running in each window with command line,
|
||||||
pid (need some adaption of the osdep code)
|
pid (need some adaption of the osdep code)
|
||||||
- support for bce
|
|
||||||
- some way to force a screen to use the entire terminal even if it is forced
|
- some way to force a screen to use the entire terminal even if it is forced
|
||||||
to be smaller by other clients. pan smaller terminal? (like screen F)
|
to be smaller by other clients. pan smaller terminal? (like screen F)
|
||||||
-- idea of a "view" onto a window, need base x/y offsets for redraw
|
-- idea of a "view" onto a window, need base x/y offsets for redraw
|
||||||
@@ -56,18 +67,14 @@
|
|||||||
- selection behaviour closer to vi in vi mode
|
- selection behaviour closer to vi in vi mode
|
||||||
- live update: server started with -U connects to server, requests sessions and
|
- live update: server started with -U connects to server, requests sessions and
|
||||||
windows, receives fds
|
windows, receives fds
|
||||||
- command to show a tree of sessions-windows-panes (active marked with *)
|
|
||||||
- sort out inheriting config from shell on new sessions/windows:
|
- sort out inheriting config from shell on new sessions/windows:
|
||||||
should pick up default-path/termios/etc from client if possible,
|
should pick up default-path/termios/etc from client if possible,
|
||||||
else leave empty/default
|
else leave empty/default
|
||||||
- link panes into multiple windows
|
- link panes into multiple windows
|
||||||
- bells should be passed between sessions with visual-bell etc
|
- bells should be passed between sessions with visual-bell etc
|
||||||
- use screen-256color when started on 256 colour terminal??
|
|
||||||
- if-shell/run-shell should block further command execution in the same command
|
|
||||||
sequence until its shell exits, to allow them to be used from the config file
|
sequence until its shell exits, to allow them to be used from the config file
|
||||||
- better session sharing: create-socket command to create socket somewhere (-r
|
- better session sharing: create-socket command to create socket somewhere (-r
|
||||||
flag for readonly)
|
flag for readonly)
|
||||||
- allow buffer to be specified when copying in copy mode
|
|
||||||
- multiline status line (no?)
|
- multiline status line (no?)
|
||||||
- flag for absolute pane size to resize-pane
|
- flag for absolute pane size to resize-pane
|
||||||
- sanity check input to socket
|
- sanity check input to socket
|
||||||
@@ -82,7 +89,6 @@
|
|||||||
- ' and " should be parsed the same (eg "\e" vs '\e') in config and command
|
- ' and " should be parsed the same (eg "\e" vs '\e') in config and command
|
||||||
prompt?
|
prompt?
|
||||||
- command to toggle selection not to move it in copy-mode
|
- command to toggle selection not to move it in copy-mode
|
||||||
- why are alerts per-winlink? try per window?
|
|
||||||
- audit of escape sequence support vs xterm
|
- audit of escape sequence support vs xterm
|
||||||
- support binding keys to mouse (mouse-select-pane -> mouse-keys or something,
|
- support binding keys to mouse (mouse-select-pane -> mouse-keys or something,
|
||||||
mouse click == select-pane -t %%, mouse scroll up == copy-mode)
|
mouse click == select-pane -t %%, mouse scroll up == copy-mode)
|
||||||
@@ -90,7 +96,6 @@
|
|||||||
- synchronous commands - client sends cmd and blocks, neww/splitw saves client
|
- synchronous commands - client sends cmd and blocks, neww/splitw saves client
|
||||||
ptr then when program inside died, sends MSG_SOMETHING with wait status to
|
ptr then when program inside died, sends MSG_SOMETHING with wait status to
|
||||||
client
|
client
|
||||||
- documentation improvements - rlpowell's tutorial - build instructions
|
|
||||||
- bind commands to key sequences? -- make it so ALL keys go through a table,
|
- bind commands to key sequences? -- make it so ALL keys go through a table,
|
||||||
first an implicit table in which C-b is the only default binding to a
|
first an implicit table in which C-b is the only default binding to a
|
||||||
command that says "next key from $othertable" and so on. means -n can
|
command that says "next key from $othertable" and so on. means -n can
|
||||||
@@ -100,8 +105,6 @@
|
|||||||
and a buffer) info() when changing to same window
|
and a buffer) info() when changing to same window
|
||||||
- way to add dest for break-pane; maybe some easier way to unbreak-pane
|
- way to add dest for break-pane; maybe some easier way to unbreak-pane
|
||||||
- case insensitive searching
|
- case insensitive searching
|
||||||
- pane-index option like base-index
|
|
||||||
- option to move status line to top
|
|
||||||
- configurable borders and empty space filler for when panes < window?
|
- configurable borders and empty space filler for when panes < window?
|
||||||
- mouse-select-pane will screw up with !MODE_MOUSE_STANDARD (it sets the
|
- mouse-select-pane will screw up with !MODE_MOUSE_STANDARD (it sets the
|
||||||
flag on w/o checking the others before calling tty_update_mode)
|
flag on w/o checking the others before calling tty_update_mode)
|
||||||
@@ -111,30 +114,57 @@
|
|||||||
key is looked up in that table
|
key is looked up in that table
|
||||||
- pass shell commands as argv rather than strings, allow them to be specified
|
- pass shell commands as argv rather than strings, allow them to be specified
|
||||||
in commands without quotes
|
in commands without quotes
|
||||||
- a command to choose from a generic list, so you can do eg
|
|
||||||
choose-list -l Abc,Moo,Blah "run-shell 'sh /my/choose/script %%'"
|
|
||||||
- else part for if-shell
|
|
||||||
- add general internal format for lists (key=value) and a way to output them in
|
|
||||||
different representations, use for list-windows, etc etc. see message id
|
|
||||||
20110221205346.GA1580@yelena.nicm.ath.cx
|
|
||||||
- numeric prefix in copy mode should be paste buffer for C-w
|
- numeric prefix in copy mode should be paste buffer for C-w
|
||||||
- named buffers and allow gaps in the stack
|
- named buffers and allow gaps in the stack
|
||||||
- npage/ppage/dc/ic should have aliases for more typical names
|
|
||||||
- get rid of separate UTF-8 cell stuff: add 1 byte to cell and store BMP as
|
- get rid of separate UTF-8 cell stuff: add 1 byte to cell and store BMP as
|
||||||
uint16_t+3 bits of flags. anything <=0xffff is Unicode, higher are used to
|
uint16_t+3 bits of flags. anything <=0xffff is Unicode, higher are used to
|
||||||
build tree of combined characters/non-BMP (LRU dropped when full)
|
build tree of combined characters/non-BMP (LRU dropped when full)
|
||||||
- entry in FAQ about what to do when someone does mkdir /tmp/tmux-1000
|
- entry in FAQ about what to do when someone does mkdir /tmp/tmux-1000
|
||||||
- show size under pane number in display-panes mode
|
|
||||||
- monitor-activity is broken in several ways with multiple clients
|
- monitor-activity is broken in several ways with multiple clients
|
||||||
- monitor-activity should be more powerful (eg set a region)
|
- monitor-activity should be more powerful (eg set a region)
|
||||||
- maybe a way to put pane names instead of window names in status line
|
- maybe a way to put pane names instead of window names in status line
|
||||||
- Support for borderless panes
|
- support for borderless panes
|
||||||
- run-shell/if-shell should support status_replace stuff
|
- run-shell/if-shell should support status_replace stuff
|
||||||
- wait-pane command or another way to make it synchronous/wait for command to
|
- wait-pane command or another way to make it synchronous/wait for command to
|
||||||
finish
|
finish
|
||||||
- way to get command window was started with (part of format stuff?)
|
|
||||||
- last-pane across sessions
|
- last-pane across sessions
|
||||||
- attach should take a pane and select it as well as attaching
|
- attach should take a pane and select it as well as attaching
|
||||||
|
- panes should have names like windows
|
||||||
|
- command-prompt doesn't work if made read-only. why?
|
||||||
|
- option to quote format eg #{session_name:quoted}
|
||||||
|
- formats need conditions for >0 (for #P)
|
||||||
|
- fetch full command line on !Linux, and add option to strip prefixes
|
||||||
|
such as "sh " "/bin/sh " etc etc
|
||||||
|
- synchronize-windows option
|
||||||
|
- append to buffer in copy mode
|
||||||
|
- way to paste w/o trailing whitespace
|
||||||
|
- flag to switch-client to switch all clients
|
||||||
|
- history of layouts and undo/redo flags to selectl
|
||||||
|
- way to tag a layout as a number/name
|
||||||
|
- optimize pane redraws, 20120318184853.GK10965@yelena.nicm.ath.cx
|
||||||
|
- support multibyte key strings
|
||||||
|
- allow commands to be executed when certaing patterns in a screen
|
||||||
|
are clicked on with the mouse
|
||||||
|
- flag to make next/previous commands skip a window
|
||||||
|
- way to do tmux command/run-shell from mode keys
|
||||||
|
- send command to all windows
|
||||||
|
- choose-pane command
|
||||||
|
- Augment choose-tree to do this? TA to investigate.
|
||||||
|
- choose-mode and copy-mode are very similar. Perhaps make choose-mode a
|
||||||
|
subset of copy-mode in that it inherits key-bindings and other traits but
|
||||||
|
not all.
|
||||||
|
|
||||||
|
TERMINAL ISSUES
|
||||||
|
================
|
||||||
|
|
||||||
|
- use a better termcap internally instead of screen, perhaps xterm
|
||||||
|
- clear window title on exit (see using xterm title stack)
|
||||||
|
- get it passing all the vttest tests that don't require resizing the terminal
|
||||||
|
- support for bce
|
||||||
|
- use screen-256color when started on 256 colour terminal??
|
||||||
|
- if-shell/run-shell should block further command execution in the same command
|
||||||
|
- possibly support rxvt-unicode extended mouse input (1015)
|
||||||
|
- wrap/no wrap esc seq DEC CSI ? 7 h/l
|
||||||
* We need a tmux terminfo entry to document the extensions we are using in
|
* We need a tmux terminfo entry to document the extensions we are using in
|
||||||
upstream terminfo. Must NOT change (only add or remove) anything from
|
upstream terminfo. Must NOT change (only add or remove) anything from
|
||||||
TERM=screen so we can fallback!
|
TERM=screen so we can fallback!
|
||||||
|
|||||||
20
arguments.c
20
arguments.c
@@ -68,15 +68,14 @@ args_parse(const char *template, int argc, char **argv)
|
|||||||
if (opt < 0 || opt >= SCHAR_MAX)
|
if (opt < 0 || opt >= SCHAR_MAX)
|
||||||
continue;
|
continue;
|
||||||
if (opt == '?' || (ptr = strchr(template, opt)) == NULL) {
|
if (opt == '?' || (ptr = strchr(template, opt)) == NULL) {
|
||||||
xfree(args->flags);
|
free(args->flags);
|
||||||
xfree(args);
|
free(args);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bit_set(args->flags, opt);
|
bit_set(args->flags, opt);
|
||||||
if (ptr[1] == ':') {
|
if (ptr[1] == ':') {
|
||||||
if (args->values[opt] != NULL)
|
free(args->values[opt]);
|
||||||
xfree(args->values[opt]);
|
|
||||||
args->values[opt] = xstrdup(optarg);
|
args->values[opt] = xstrdup(optarg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,13 +96,11 @@ args_free(struct args *args)
|
|||||||
|
|
||||||
cmd_free_argv(args->argc, args->argv);
|
cmd_free_argv(args->argc, args->argv);
|
||||||
|
|
||||||
for (i = 0; i < SCHAR_MAX; i++) {
|
for (i = 0; i < SCHAR_MAX; i++)
|
||||||
if (args->values[i] != NULL)
|
free(args->values[i]);
|
||||||
xfree(args->values[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
xfree(args->flags);
|
free(args->flags);
|
||||||
xfree(args);
|
free(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print a set of arguments. */
|
/* Print a set of arguments. */
|
||||||
@@ -182,8 +179,7 @@ args_has(struct args *args, u_char ch)
|
|||||||
void
|
void
|
||||||
args_set(struct args *args, u_char ch, const char *value)
|
args_set(struct args *args, u_char ch, const char *value)
|
||||||
{
|
{
|
||||||
if (args->values[ch] != NULL)
|
free(args->values[ch]);
|
||||||
xfree(args->values[ch]);
|
|
||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
args->values[ch] = xstrdup(value);
|
args->values[ch] = xstrdup(value);
|
||||||
else
|
else
|
||||||
|
|||||||
5
array.h
5
array.h
@@ -109,13 +109,12 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ARRAY_FREE(a) do { \
|
#define ARRAY_FREE(a) do { \
|
||||||
if ((a)->list != NULL) \
|
free((a)->list); \
|
||||||
xfree((a)->list); \
|
|
||||||
ARRAY_INIT(a); \
|
ARRAY_INIT(a); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define ARRAY_FREEALL(a) do { \
|
#define ARRAY_FREEALL(a) do { \
|
||||||
ARRAY_FREE(a); \
|
ARRAY_FREE(a); \
|
||||||
xfree(a); \
|
free(a); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
28
attributes.c
28
attributes.c
@@ -26,27 +26,21 @@ const char *
|
|||||||
attributes_tostring(u_char attr)
|
attributes_tostring(u_char attr)
|
||||||
{
|
{
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (attr == 0)
|
if (attr == 0)
|
||||||
return ("none");
|
return ("none");
|
||||||
|
|
||||||
buf[0] = '\0';
|
len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s",
|
||||||
if (attr & GRID_ATTR_BRIGHT)
|
attr & GRID_ATTR_BRIGHT ? "bright," : "",
|
||||||
strlcat(buf, "bright,", sizeof (buf));
|
attr & GRID_ATTR_DIM ? "dim," : "",
|
||||||
if (attr & GRID_ATTR_DIM)
|
attr & GRID_ATTR_UNDERSCORE ? "underscore," : "",
|
||||||
strlcat(buf, "dim,", sizeof (buf));
|
attr & GRID_ATTR_BLINK ? "blink," : "",
|
||||||
if (attr & GRID_ATTR_UNDERSCORE)
|
attr & GRID_ATTR_REVERSE ? "reverse," : "",
|
||||||
strlcat(buf, "underscore,", sizeof (buf));
|
attr & GRID_ATTR_HIDDEN ? "hidden," : "",
|
||||||
if (attr & GRID_ATTR_BLINK)
|
attr & GRID_ATTR_ITALICS ? "italics," : "");
|
||||||
strlcat(buf, "blink,", sizeof (buf));
|
if (len > 0)
|
||||||
if (attr & GRID_ATTR_REVERSE)
|
buf[len - 1] = '\0';
|
||||||
strlcat(buf, "reverse,", sizeof (buf));
|
|
||||||
if (attr & GRID_ATTR_HIDDEN)
|
|
||||||
strlcat(buf, "hidden,", sizeof (buf));
|
|
||||||
if (attr & GRID_ATTR_ITALICS)
|
|
||||||
strlcat(buf, "italics,", sizeof (buf));
|
|
||||||
if (*buf != '\0')
|
|
||||||
*(strrchr(buf, ',')) = '\0';
|
|
||||||
|
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|||||||
0
autogen.sh
Normal file → Executable file
0
autogen.sh
Normal file → Executable file
62
cfg.c
62
cfg.c
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -80,7 +81,7 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
|
|||||||
size_t len;
|
size_t len;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd_ctx ctx;
|
struct cmd_ctx ctx;
|
||||||
int retval;
|
enum cmd_retval retval;
|
||||||
|
|
||||||
if ((f = fopen(path, "rb")) == NULL) {
|
if ((f = fopen(path, "rb")) == NULL) {
|
||||||
cfg_add_cause(causes, "%s: %s", path, strerror(errno));
|
cfg_add_cause(causes, "%s: %s", path, strerror(errno));
|
||||||
@@ -89,25 +90,42 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
|
|||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
line = NULL;
|
line = NULL;
|
||||||
retval = 0;
|
retval = CMD_RETURN_NORMAL;
|
||||||
while ((buf = fgetln(f, &len))) {
|
while ((buf = fgetln(f, &len))) {
|
||||||
if (buf[len - 1] == '\n')
|
if (buf[len - 1] == '\n')
|
||||||
buf[len - 1] = '\0';
|
len--;
|
||||||
|
|
||||||
|
if (line != NULL)
|
||||||
|
line = xrealloc(line, 1, strlen(line) + len + 1);
|
||||||
else {
|
else {
|
||||||
line = xrealloc(line, 1, len + 1);
|
line = xmalloc(len + 1);
|
||||||
memcpy(line, buf, len);
|
*line = '\0';
|
||||||
line[len] = '\0';
|
|
||||||
buf = line;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Append buffer to line. strncat will terminate. */
|
||||||
|
strncat(line, buf, len);
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
|
/* Continuation: get next line? */
|
||||||
|
len = strlen(line);
|
||||||
|
if (len > 0 && line[len - 1] == '\\') {
|
||||||
|
line[len - 1] = '\0';
|
||||||
|
/* Ignore escaped backslash at EOL. */
|
||||||
|
if (len > 1 && line[len - 2] != '\\')
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
buf = line;
|
||||||
|
line = NULL;
|
||||||
|
|
||||||
if (cmd_string_parse(buf, &cmdlist, &cause) != 0) {
|
if (cmd_string_parse(buf, &cmdlist, &cause) != 0) {
|
||||||
|
free(buf);
|
||||||
if (cause == NULL)
|
if (cause == NULL)
|
||||||
continue;
|
continue;
|
||||||
cfg_add_cause(causes, "%s: %u: %s", path, n, cause);
|
cfg_add_cause(causes, "%s: %u: %s", path, n, cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
continue;
|
continue;
|
||||||
}
|
} else
|
||||||
|
free(buf);
|
||||||
if (cmdlist == NULL)
|
if (cmdlist == NULL)
|
||||||
continue;
|
continue;
|
||||||
cfg_cause = NULL;
|
cfg_cause = NULL;
|
||||||
@@ -127,16 +145,30 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
|
|||||||
ctx.info = cfg_print;
|
ctx.info = cfg_print;
|
||||||
|
|
||||||
cfg_cause = NULL;
|
cfg_cause = NULL;
|
||||||
if (cmd_list_exec(cmdlist, &ctx) == 1)
|
switch (cmd_list_exec(cmdlist, &ctx)) {
|
||||||
retval = 1;
|
case CMD_RETURN_YIELD:
|
||||||
|
if (retval != CMD_RETURN_ATTACH)
|
||||||
|
retval = CMD_RETURN_YIELD;
|
||||||
|
break;
|
||||||
|
case CMD_RETURN_ATTACH:
|
||||||
|
retval = CMD_RETURN_ATTACH;
|
||||||
|
break;
|
||||||
|
case CMD_RETURN_ERROR:
|
||||||
|
case CMD_RETURN_NORMAL:
|
||||||
|
break;
|
||||||
|
}
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
if (cfg_cause != NULL) {
|
if (cfg_cause != NULL) {
|
||||||
cfg_add_cause(causes, "%s: %d: %s", path, n, cfg_cause);
|
cfg_add_cause(
|
||||||
xfree(cfg_cause);
|
causes, "%s: %d: %s", path, n, cfg_cause);
|
||||||
|
free(cfg_cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (line != NULL)
|
if (line != NULL) {
|
||||||
xfree(line);
|
cfg_add_cause(causes,
|
||||||
|
"%s: %d: line continuation at end of file", path, n);
|
||||||
|
free(line);
|
||||||
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
return (retval);
|
return (retval);
|
||||||
|
|||||||
241
client.c
241
client.c
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/file.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
@@ -34,20 +35,58 @@
|
|||||||
|
|
||||||
struct imsgbuf client_ibuf;
|
struct imsgbuf client_ibuf;
|
||||||
struct event client_event;
|
struct event client_event;
|
||||||
const char *client_exitmsg;
|
struct event client_stdin;
|
||||||
|
enum {
|
||||||
|
CLIENT_EXIT_NONE,
|
||||||
|
CLIENT_EXIT_DETACHED,
|
||||||
|
CLIENT_EXIT_DETACHED_HUP,
|
||||||
|
CLIENT_EXIT_LOST_TTY,
|
||||||
|
CLIENT_EXIT_TERMINATED,
|
||||||
|
CLIENT_EXIT_LOST_SERVER,
|
||||||
|
CLIENT_EXIT_EXITED,
|
||||||
|
CLIENT_EXIT_SERVER_EXITED,
|
||||||
|
} client_exitreason = CLIENT_EXIT_NONE;
|
||||||
int client_exitval;
|
int client_exitval;
|
||||||
enum msgtype client_exittype;
|
enum msgtype client_exittype;
|
||||||
int client_attached;
|
int client_attached;
|
||||||
|
|
||||||
|
int client_get_lock(char *);
|
||||||
int client_connect(char *, int);
|
int client_connect(char *, int);
|
||||||
void client_send_identify(int);
|
void client_send_identify(int);
|
||||||
void client_send_environ(void);
|
void client_send_environ(void);
|
||||||
void client_write_server(enum msgtype, void *, size_t);
|
void client_write_server(enum msgtype, void *, size_t);
|
||||||
void client_update_event(void);
|
void client_update_event(void);
|
||||||
void client_signal(int, short, void *);
|
void client_signal(int, short, void *);
|
||||||
|
void client_stdin_callback(int, short, void *);
|
||||||
|
void client_write(int, const char *, size_t);
|
||||||
void client_callback(int, short, void *);
|
void client_callback(int, short, void *);
|
||||||
int client_dispatch_attached(void);
|
int client_dispatch_attached(void);
|
||||||
int client_dispatch_wait(void *);
|
int client_dispatch_wait(void *);
|
||||||
|
const char *client_exit_message(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get server create lock. If already held then server start is happening in
|
||||||
|
* another client, so block until the lock is released and return -1 to
|
||||||
|
* retry. Ignore other errors - just continue and start the server without the
|
||||||
|
* lock.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
client_get_lock(char *lockfile)
|
||||||
|
{
|
||||||
|
int lockfd;
|
||||||
|
|
||||||
|
if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1)
|
||||||
|
fatal("open failed");
|
||||||
|
|
||||||
|
if (flock(lockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK) {
|
||||||
|
while (flock(lockfd, LOCK_EX) == -1 && errno == EINTR)
|
||||||
|
/* nothing */;
|
||||||
|
close(lockfd);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (lockfd);
|
||||||
|
}
|
||||||
|
|
||||||
/* Connect client to server. */
|
/* Connect client to server. */
|
||||||
int
|
int
|
||||||
@@ -55,7 +94,8 @@ client_connect(char *path, int start_server)
|
|||||||
{
|
{
|
||||||
struct sockaddr_un sa;
|
struct sockaddr_un sa;
|
||||||
size_t size;
|
size_t size;
|
||||||
int fd;
|
int fd, lockfd;
|
||||||
|
char *lockfile;
|
||||||
|
|
||||||
memset(&sa, 0, sizeof sa);
|
memset(&sa, 0, sizeof sa);
|
||||||
sa.sun_family = AF_UNIX;
|
sa.sun_family = AF_UNIX;
|
||||||
@@ -65,24 +105,25 @@ client_connect(char *path, int start_server)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retry:
|
||||||
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
||||||
fatal("socket failed");
|
fatal("socket failed");
|
||||||
|
|
||||||
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
||||||
|
if (errno != ECONNREFUSED && errno != ENOENT)
|
||||||
|
goto failed;
|
||||||
if (!start_server)
|
if (!start_server)
|
||||||
goto failed;
|
goto failed;
|
||||||
switch (errno) {
|
close(fd);
|
||||||
case ECONNREFUSED:
|
|
||||||
if (unlink(path) != 0)
|
xasprintf(&lockfile, "%s.lock", path);
|
||||||
goto failed;
|
if ((lockfd = client_get_lock(lockfile)) == -1)
|
||||||
/* FALLTHROUGH */
|
goto retry;
|
||||||
case ENOENT:
|
if (unlink(path) != 0 && errno != ENOENT)
|
||||||
if ((fd = server_start()) == -1)
|
return (-1);
|
||||||
goto failed;
|
fd = server_start(lockfd, lockfile);
|
||||||
break;
|
free(lockfile);
|
||||||
default:
|
close(lockfd);
|
||||||
goto failed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setblocking(fd, 0);
|
setblocking(fd, 0);
|
||||||
@@ -93,6 +134,31 @@ failed:
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get exit string from reason number. */
|
||||||
|
const char *
|
||||||
|
client_exit_message(void)
|
||||||
|
{
|
||||||
|
switch (client_exitreason) {
|
||||||
|
case CLIENT_EXIT_NONE:
|
||||||
|
break;
|
||||||
|
case CLIENT_EXIT_DETACHED:
|
||||||
|
return ("detached");
|
||||||
|
case CLIENT_EXIT_DETACHED_HUP:
|
||||||
|
return ("detached and SIGHUP");
|
||||||
|
case CLIENT_EXIT_LOST_TTY:
|
||||||
|
return ("lost tty");
|
||||||
|
case CLIENT_EXIT_TERMINATED:
|
||||||
|
return ("terminated");
|
||||||
|
case CLIENT_EXIT_LOST_SERVER:
|
||||||
|
return ("lost server");
|
||||||
|
case CLIENT_EXIT_EXITED:
|
||||||
|
return ("exited");
|
||||||
|
case CLIENT_EXIT_SERVER_EXITED:
|
||||||
|
return ("server exited");
|
||||||
|
}
|
||||||
|
return ("unknown reason");
|
||||||
|
}
|
||||||
|
|
||||||
/* Client main loop. */
|
/* Client main loop. */
|
||||||
int
|
int
|
||||||
client_main(int argc, char **argv, int flags)
|
client_main(int argc, char **argv, int flags)
|
||||||
@@ -104,6 +170,7 @@ client_main(int argc, char **argv, int flags)
|
|||||||
pid_t ppid;
|
pid_t ppid;
|
||||||
enum msgtype msg;
|
enum msgtype msg;
|
||||||
char *cause;
|
char *cause;
|
||||||
|
struct termios tio, saved_tio;
|
||||||
|
|
||||||
/* Set up the initial command. */
|
/* Set up the initial command. */
|
||||||
cmdflags = 0;
|
cmdflags = 0;
|
||||||
@@ -122,7 +189,7 @@ client_main(int argc, char **argv, int flags)
|
|||||||
* flag.
|
* flag.
|
||||||
*/
|
*/
|
||||||
if ((cmdlist = cmd_list_parse(argc, argv, &cause)) == NULL) {
|
if ((cmdlist = cmd_list_parse(argc, argv, &cause)) == NULL) {
|
||||||
log_warnx("%s", cause);
|
fprintf(stderr, "%s\n", cause);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
cmdflags &= ~CMD_STARTSERVER;
|
cmdflags &= ~CMD_STARTSERVER;
|
||||||
@@ -142,16 +209,17 @@ client_main(int argc, char **argv, int flags)
|
|||||||
* if the socket path matches $TMUX, this is probably the same server.
|
* if the socket path matches $TMUX, this is probably the same server.
|
||||||
*/
|
*/
|
||||||
if (shell_cmd == NULL && environ_path != NULL &&
|
if (shell_cmd == NULL && environ_path != NULL &&
|
||||||
cmdflags & CMD_CANTNEST && strcmp(socket_path, environ_path) == 0) {
|
(cmdflags & CMD_CANTNEST) &&
|
||||||
log_warnx("sessions should be nested with care. "
|
strcmp(socket_path, environ_path) == 0) {
|
||||||
"unset $TMUX to force.");
|
fprintf(stderr, "sessions should be nested with care, "
|
||||||
|
"unset $TMUX to force\n");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise the client socket and start the server. */
|
/* Initialise the client socket and start the server. */
|
||||||
fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
|
fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
log_warn("failed to connect to server");
|
fprintf(stderr, "failed to connect to server\n");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +233,30 @@ client_main(int argc, char **argv, int flags)
|
|||||||
imsg_init(&client_ibuf, fd);
|
imsg_init(&client_ibuf, fd);
|
||||||
event_set(&client_event, fd, EV_READ, client_callback, shell_cmd);
|
event_set(&client_event, fd, EV_READ, client_callback, shell_cmd);
|
||||||
|
|
||||||
|
/* Create stdin handler. */
|
||||||
|
setblocking(STDIN_FILENO, 0);
|
||||||
|
event_set(&client_stdin, STDIN_FILENO, EV_READ|EV_PERSIST,
|
||||||
|
client_stdin_callback, NULL);
|
||||||
|
if (flags & IDENTIFY_TERMIOS) {
|
||||||
|
if (tcgetattr(STDIN_FILENO, &saved_tio) != 0) {
|
||||||
|
fprintf(stderr, "tcgetattr failed: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
cfmakeraw(&tio);
|
||||||
|
tio.c_iflag = ICRNL|IXANY;
|
||||||
|
tio.c_oflag = OPOST|ONLCR;
|
||||||
|
#ifdef NOKERNINFO
|
||||||
|
tio.c_lflag = NOKERNINFO;
|
||||||
|
#endif
|
||||||
|
tio.c_cflag = CREAD|CS8|HUPCL;
|
||||||
|
tio.c_cc[VMIN] = 1;
|
||||||
|
tio.c_cc[VTIME] = 0;
|
||||||
|
cfsetispeed(&tio, cfgetispeed(&saved_tio));
|
||||||
|
cfsetospeed(&tio, cfgetospeed(&saved_tio));
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &tio);
|
||||||
|
}
|
||||||
|
|
||||||
/* Establish signal handlers. */
|
/* Establish signal handlers. */
|
||||||
set_signals(client_signal);
|
set_signals(client_signal);
|
||||||
|
|
||||||
@@ -183,7 +275,7 @@ client_main(int argc, char **argv, int flags)
|
|||||||
cmddata.argc = argc;
|
cmddata.argc = argc;
|
||||||
if (cmd_pack_argv(
|
if (cmd_pack_argv(
|
||||||
argc, argv, cmddata.argv, sizeof cmddata.argv) != 0) {
|
argc, argv, cmddata.argv, sizeof cmddata.argv) != 0) {
|
||||||
log_warnx("command too long");
|
fprintf(stderr, "command too long\n");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,13 +289,15 @@ client_main(int argc, char **argv, int flags)
|
|||||||
|
|
||||||
/* Print the exit message, if any, and exit. */
|
/* Print the exit message, if any, and exit. */
|
||||||
if (client_attached) {
|
if (client_attached) {
|
||||||
if (client_exitmsg != NULL && !login_shell)
|
if (client_exitreason != CLIENT_EXIT_NONE && !login_shell)
|
||||||
printf("[%s]\n", client_exitmsg);
|
printf("[%s]\n", client_exit_message());
|
||||||
|
|
||||||
ppid = getppid();
|
ppid = getppid();
|
||||||
if (client_exittype == MSG_DETACHKILL && ppid > 1)
|
if (client_exittype == MSG_DETACHKILL && ppid > 1)
|
||||||
kill(ppid, SIGHUP);
|
kill(ppid, SIGHUP);
|
||||||
}
|
} else if (flags & IDENTIFY_TERMIOS)
|
||||||
|
tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
|
||||||
|
setblocking(STDIN_FILENO, 1);
|
||||||
return (client_exitval);
|
return (client_exitval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,16 +323,7 @@ client_send_identify(int flags)
|
|||||||
fatal("dup failed");
|
fatal("dup failed");
|
||||||
imsg_compose(&client_ibuf,
|
imsg_compose(&client_ibuf,
|
||||||
MSG_IDENTIFY, PROTOCOL_VERSION, -1, fd, &data, sizeof data);
|
MSG_IDENTIFY, PROTOCOL_VERSION, -1, fd, &data, sizeof data);
|
||||||
|
client_update_event();
|
||||||
if ((fd = dup(STDOUT_FILENO)) == -1)
|
|
||||||
fatal("dup failed");
|
|
||||||
imsg_compose(&client_ibuf,
|
|
||||||
MSG_STDOUT, PROTOCOL_VERSION, -1, fd, NULL, 0);
|
|
||||||
|
|
||||||
if ((fd = dup(STDERR_FILENO)) == -1)
|
|
||||||
fatal("dup failed");
|
|
||||||
imsg_compose(&client_ibuf,
|
|
||||||
MSG_STDERR, PROTOCOL_VERSION, -1, fd, NULL, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Forward entire environment to server. */
|
/* Forward entire environment to server. */
|
||||||
@@ -260,6 +345,7 @@ void
|
|||||||
client_write_server(enum msgtype type, void *buf, size_t len)
|
client_write_server(enum msgtype type, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
imsg_compose(&client_ibuf, type, PROTOCOL_VERSION, -1, -1, buf, len);
|
imsg_compose(&client_ibuf, type, PROTOCOL_VERSION, -1, -1, buf, len);
|
||||||
|
client_update_event();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update client event based on whether it needs to read or read and write. */
|
/* Update client event based on whether it needs to read or read and write. */
|
||||||
@@ -297,12 +383,12 @@ client_signal(int sig, unused short events, unused void *data)
|
|||||||
} else {
|
} else {
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
case SIGHUP:
|
case SIGHUP:
|
||||||
client_exitmsg = "lost tty";
|
client_exitreason = CLIENT_EXIT_LOST_TTY;
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
client_write_server(MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
break;
|
break;
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
client_exitmsg = "terminated";
|
client_exitreason = CLIENT_EXIT_TERMINATED;
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
client_write_server(MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
break;
|
break;
|
||||||
@@ -354,11 +440,46 @@ client_callback(unused int fd, short events, void *data)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
lost_server:
|
lost_server:
|
||||||
client_exitmsg = "lost server";
|
client_exitreason = CLIENT_EXIT_LOST_SERVER;
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
event_loopexit(NULL);
|
event_loopexit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Callback for client stdin read events. */
|
||||||
|
/* ARGSUSED */
|
||||||
|
void
|
||||||
|
client_stdin_callback(unused int fd, unused short events, unused void *data1)
|
||||||
|
{
|
||||||
|
struct msg_stdin_data data;
|
||||||
|
|
||||||
|
data.size = read(STDIN_FILENO, data.data, sizeof data.data);
|
||||||
|
if (data.size < 0 && (errno == EINTR || errno == EAGAIN))
|
||||||
|
return;
|
||||||
|
|
||||||
|
client_write_server(MSG_STDIN, &data, sizeof data);
|
||||||
|
if (data.size <= 0)
|
||||||
|
event_del(&client_stdin);
|
||||||
|
client_update_event();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Force write to file descriptor. */
|
||||||
|
void
|
||||||
|
client_write(int fd, const char *data, size_t size)
|
||||||
|
{
|
||||||
|
ssize_t used;
|
||||||
|
|
||||||
|
while (size != 0) {
|
||||||
|
used = write(fd, data, size);
|
||||||
|
if (used == -1) {
|
||||||
|
if (errno == EINTR || errno == EAGAIN)
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
data += used;
|
||||||
|
size -= used;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Dispatch imsgs when in wait state (before MSG_READY). */
|
/* Dispatch imsgs when in wait state (before MSG_READY). */
|
||||||
int
|
int
|
||||||
client_dispatch_wait(void *data)
|
client_dispatch_wait(void *data)
|
||||||
@@ -367,11 +488,10 @@ client_dispatch_wait(void *data)
|
|||||||
ssize_t n, datalen;
|
ssize_t n, datalen;
|
||||||
struct msg_shell_data shelldata;
|
struct msg_shell_data shelldata;
|
||||||
struct msg_exit_data exitdata;
|
struct msg_exit_data exitdata;
|
||||||
|
struct msg_stdout_data stdoutdata;
|
||||||
|
struct msg_stderr_data stderrdata;
|
||||||
const char *shellcmd = data;
|
const char *shellcmd = data;
|
||||||
|
|
||||||
if ((n = imsg_read(&client_ibuf)) == -1 || n == 0)
|
|
||||||
fatalx("imsg_read failed");
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
|
if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
|
||||||
fatalx("imsg_get failed");
|
fatalx("imsg_get failed");
|
||||||
@@ -379,6 +499,7 @@ client_dispatch_wait(void *data)
|
|||||||
return (0);
|
return (0);
|
||||||
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
|
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
|
||||||
|
|
||||||
|
log_debug("got %d from server", imsg.hdr.type);
|
||||||
switch (imsg.hdr.type) {
|
switch (imsg.hdr.type) {
|
||||||
case MSG_EXIT:
|
case MSG_EXIT:
|
||||||
case MSG_SHUTDOWN:
|
case MSG_SHUTDOWN:
|
||||||
@@ -395,14 +516,36 @@ client_dispatch_wait(void *data)
|
|||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
fatalx("bad MSG_READY size");
|
fatalx("bad MSG_READY size");
|
||||||
|
|
||||||
|
event_del(&client_stdin);
|
||||||
client_attached = 1;
|
client_attached = 1;
|
||||||
break;
|
break;
|
||||||
|
case MSG_STDIN:
|
||||||
|
if (datalen != 0)
|
||||||
|
fatalx("bad MSG_STDIN size");
|
||||||
|
|
||||||
|
event_add(&client_stdin, NULL);
|
||||||
|
break;
|
||||||
|
case MSG_STDOUT:
|
||||||
|
if (datalen != sizeof stdoutdata)
|
||||||
|
fatalx("bad MSG_STDOUT");
|
||||||
|
memcpy(&stdoutdata, imsg.data, sizeof stdoutdata);
|
||||||
|
|
||||||
|
client_write(STDOUT_FILENO, stdoutdata.data, stdoutdata.size);
|
||||||
|
break;
|
||||||
|
case MSG_STDERR:
|
||||||
|
if (datalen != sizeof stderrdata)
|
||||||
|
fatalx("bad MSG_STDERR");
|
||||||
|
memcpy(&stderrdata, imsg.data, sizeof stderrdata);
|
||||||
|
|
||||||
|
client_write(STDERR_FILENO, stderrdata.data, stderrdata.size);
|
||||||
|
break;
|
||||||
case MSG_VERSION:
|
case MSG_VERSION:
|
||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
fatalx("bad MSG_VERSION size");
|
fatalx("bad MSG_VERSION size");
|
||||||
|
|
||||||
log_warnx("protocol version mismatch (client %u, "
|
fprintf(stderr, "protocol version mismatch "
|
||||||
"server %u)", PROTOCOL_VERSION, imsg.hdr.peerid);
|
"(client %u, server %u)\n", PROTOCOL_VERSION,
|
||||||
|
imsg.hdr.peerid);
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
|
|
||||||
imsg_free(&imsg);
|
imsg_free(&imsg);
|
||||||
@@ -417,6 +560,12 @@ client_dispatch_wait(void *data)
|
|||||||
|
|
||||||
shell_exec(shelldata.shell, shellcmd);
|
shell_exec(shelldata.shell, shellcmd);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
case MSG_DETACH:
|
||||||
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
|
break;
|
||||||
|
case MSG_EXITED:
|
||||||
|
imsg_free(&imsg);
|
||||||
|
return (-1);
|
||||||
default:
|
default:
|
||||||
fatalx("unexpected message");
|
fatalx("unexpected message");
|
||||||
}
|
}
|
||||||
@@ -442,7 +591,7 @@ client_dispatch_attached(void)
|
|||||||
return (0);
|
return (0);
|
||||||
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
|
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
|
||||||
|
|
||||||
log_debug("client got %d", imsg.hdr.type);
|
log_debug("got %d from server", imsg.hdr.type);
|
||||||
switch (imsg.hdr.type) {
|
switch (imsg.hdr.type) {
|
||||||
case MSG_DETACHKILL:
|
case MSG_DETACHKILL:
|
||||||
case MSG_DETACH:
|
case MSG_DETACH:
|
||||||
@@ -451,9 +600,9 @@ client_dispatch_attached(void)
|
|||||||
|
|
||||||
client_exittype = imsg.hdr.type;
|
client_exittype = imsg.hdr.type;
|
||||||
if (imsg.hdr.type == MSG_DETACHKILL)
|
if (imsg.hdr.type == MSG_DETACHKILL)
|
||||||
client_exitmsg = "detached and SIGHUP";
|
client_exitreason = CLIENT_EXIT_DETACHED_HUP;
|
||||||
else
|
else
|
||||||
client_exitmsg = "detached";
|
client_exitreason = CLIENT_EXIT_DETACHED;
|
||||||
client_write_server(MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
break;
|
break;
|
||||||
case MSG_EXIT:
|
case MSG_EXIT:
|
||||||
@@ -462,7 +611,7 @@ client_dispatch_attached(void)
|
|||||||
fatalx("bad MSG_EXIT size");
|
fatalx("bad MSG_EXIT size");
|
||||||
|
|
||||||
client_write_server(MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
client_exitmsg = "exited";
|
client_exitreason = CLIENT_EXIT_EXITED;
|
||||||
break;
|
break;
|
||||||
case MSG_EXITED:
|
case MSG_EXITED:
|
||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
@@ -475,7 +624,7 @@ client_dispatch_attached(void)
|
|||||||
fatalx("bad MSG_SHUTDOWN size");
|
fatalx("bad MSG_SHUTDOWN size");
|
||||||
|
|
||||||
client_write_server(MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
client_exitmsg = "server exited";
|
client_exitreason = CLIENT_EXIT_SERVER_EXITED;
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
break;
|
break;
|
||||||
case MSG_SUSPEND:
|
case MSG_SUSPEND:
|
||||||
|
|||||||
@@ -18,13 +18,15 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attach existing session to the current terminal.
|
* Attach existing session to the current terminal.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_attach_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_attach_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_attach_session_entry = {
|
const struct cmd_entry cmd_attach_session_entry = {
|
||||||
"attach-session", "attach",
|
"attach-session", "attach",
|
||||||
@@ -36,26 +38,26 @@ const struct cmd_entry cmd_attach_session_entry = {
|
|||||||
cmd_attach_session_exec
|
cmd_attach_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
const char *update;
|
const char *update;
|
||||||
char *overrides, *cause;
|
char *cause;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
if (RB_EMPTY(&sessions)) {
|
if (RB_EMPTY(&sessions)) {
|
||||||
ctx->error(ctx, "no sessions");
|
ctx->error(ctx, "no sessions");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 1)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 1)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (ctx->cmdclient == NULL && ctx->curclient == NULL)
|
if (ctx->cmdclient == NULL && ctx->curclient == NULL)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
if (ctx->cmdclient == NULL) {
|
if (ctx->cmdclient == NULL) {
|
||||||
if (args_has(self->args, 'd')) {
|
if (args_has(self->args, 'd')) {
|
||||||
@@ -74,20 +76,15 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx->curclient->session = s;
|
ctx->curclient->session = s;
|
||||||
|
notify_attached_session_changed(ctx->curclient);
|
||||||
session_update_activity(s);
|
session_update_activity(s);
|
||||||
server_redraw_client(ctx->curclient);
|
server_redraw_client(ctx->curclient);
|
||||||
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
} else {
|
} else {
|
||||||
if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
|
if (server_client_open(ctx->cmdclient, s, &cause) != 0) {
|
||||||
ctx->error(ctx, "not a terminal");
|
ctx->error(ctx, "open terminal failed: %s", cause);
|
||||||
return (-1);
|
free(cause);
|
||||||
}
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
overrides =
|
|
||||||
options_get_string(&s->options, "terminal-overrides");
|
|
||||||
if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
|
|
||||||
ctx->error(ctx, "terminal open failed: %s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'r'))
|
if (args_has(self->args, 'r'))
|
||||||
@@ -97,16 +94,18 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_write_session(s, MSG_DETACH, NULL, 0);
|
server_write_session(s, MSG_DETACH, NULL, 0);
|
||||||
|
|
||||||
ctx->cmdclient->session = s;
|
ctx->cmdclient->session = s;
|
||||||
|
notify_attached_session_changed(ctx->cmdclient);
|
||||||
session_update_activity(s);
|
session_update_activity(s);
|
||||||
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
server_write_ready(ctx->cmdclient);
|
||||||
|
|
||||||
update = options_get_string(&s->options, "update-environment");
|
update = options_get_string(&s->options, "update-environment");
|
||||||
environ_update(update, &ctx->cmdclient->environ, &s->environ);
|
environ_update(update, &ctx->cmdclient->environ, &s->environ);
|
||||||
|
|
||||||
server_redraw_client(ctx->cmdclient);
|
server_redraw_client(ctx->cmdclient);
|
||||||
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_update_socket();
|
server_update_socket();
|
||||||
|
|
||||||
return (1); /* 1 means don't tell command client to exit */
|
return (CMD_RETURN_ATTACH);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,10 +27,10 @@
|
|||||||
* Bind a key to a command, this recurses through cmd_*.
|
* Bind a key to a command, this recurses through cmd_*.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_bind_key_check(struct args *);
|
enum cmd_retval cmd_bind_key_check(struct args *);
|
||||||
int cmd_bind_key_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
int cmd_bind_key_table(struct cmd *, struct cmd_ctx *, int);
|
enum cmd_retval cmd_bind_key_table(struct cmd *, struct cmd_ctx *, int);
|
||||||
|
|
||||||
const struct cmd_entry cmd_bind_key_entry = {
|
const struct cmd_entry cmd_bind_key_entry = {
|
||||||
"bind-key", "bind",
|
"bind-key", "bind",
|
||||||
@@ -41,20 +42,20 @@ const struct cmd_entry cmd_bind_key_entry = {
|
|||||||
cmd_bind_key_exec
|
cmd_bind_key_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_bind_key_check(struct args *args)
|
cmd_bind_key_check(struct args *args)
|
||||||
{
|
{
|
||||||
if (args_has(args, 't')) {
|
if (args_has(args, 't')) {
|
||||||
if (args->argc != 2)
|
if (args->argc != 2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
} else {
|
} else {
|
||||||
if (args->argc < 2)
|
if (args->argc < 2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -65,7 +66,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
key = key_string_lookup_string(args->argv[0]);
|
key = key_string_lookup_string(args->argv[0]);
|
||||||
if (key == KEYC_NONE) {
|
if (key == KEYC_NONE) {
|
||||||
ctx->error(ctx, "unknown key: %s", args->argv[0]);
|
ctx->error(ctx, "unknown key: %s", args->argv[0]);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 't'))
|
if (args_has(args, 't'))
|
||||||
@@ -74,17 +75,17 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, &cause);
|
cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, &cause);
|
||||||
if (cmdlist == NULL) {
|
if (cmdlist == NULL) {
|
||||||
ctx->error(ctx, "%s", cause);
|
ctx->error(ctx, "%s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args_has(args, 'n'))
|
if (!args_has(args, 'n'))
|
||||||
key |= KEYC_PREFIX;
|
key |= KEYC_PREFIX;
|
||||||
key_bindings_add(key, args_has(args, 'r'), cmdlist);
|
key_bindings_add(key, args_has(args, 'r'), cmdlist);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_bind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
cmd_bind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -96,25 +97,25 @@ cmd_bind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
|||||||
tablename = args_get(args, 't');
|
tablename = args_get(args, 't');
|
||||||
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
||||||
ctx->error(ctx, "unknown key table: %s", tablename);
|
ctx->error(ctx, "unknown key table: %s", tablename);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = mode_key_fromstring(mtab->cmdstr, args->argv[1]);
|
cmd = mode_key_fromstring(mtab->cmdstr, args->argv[1]);
|
||||||
if (cmd == MODEKEY_NONE) {
|
if (cmd == MODEKEY_NONE) {
|
||||||
ctx->error(ctx, "unknown command: %s", args->argv[1]);
|
ctx->error(ctx, "unknown command: %s", args->argv[1]);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtmp.key = key;
|
mtmp.key = key;
|
||||||
mtmp.mode = !!args_has(args, 'c');
|
mtmp.mode = !!args_has(args, 'c');
|
||||||
if ((mbind = SPLAY_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {
|
if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {
|
||||||
mbind->cmd = cmd;
|
mbind->cmd = cmd;
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
mbind = xmalloc(sizeof *mbind);
|
mbind = xmalloc(sizeof *mbind);
|
||||||
mbind->key = mtmp.key;
|
mbind->key = mtmp.key;
|
||||||
mbind->mode = mtmp.mode;
|
mbind->mode = mtmp.mode;
|
||||||
mbind->cmd = cmd;
|
mbind->cmd = cmd;
|
||||||
SPLAY_INSERT(mode_key_tree, mtab->tree, mbind);
|
RB_INSERT(mode_key_tree, mtab->tree, mbind);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,19 +26,19 @@
|
|||||||
* Break pane off into a window.
|
* Break pane off into a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_break_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_break_pane_entry = {
|
const struct cmd_entry cmd_break_pane_entry = {
|
||||||
"break-pane", "breakp",
|
"break-pane", "breakp",
|
||||||
"dt:", 0, 0,
|
"dPF:t:", 0, 0,
|
||||||
"[-d] " CMD_TARGET_PANE_USAGE,
|
"[-dP] [-F format] " CMD_TARGET_PANE_USAGE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_break_pane_exec
|
cmd_break_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -46,15 +46,20 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct session *s;
|
struct session *s;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
|
char *name;
|
||||||
char *cause;
|
char *cause;
|
||||||
int base_idx;
|
int base_idx;
|
||||||
|
struct client *c;
|
||||||
|
struct format_tree *ft;
|
||||||
|
const char *template;
|
||||||
|
char *cp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_count_panes(wl->window) == 1) {
|
if (window_count_panes(wl->window) == 1) {
|
||||||
ctx->error(ctx, "can't break with only one pane");
|
ctx->error(ctx, "can't break with only one pane");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
@@ -74,7 +79,9 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
w = wp->window = window_create1(s->sx, s->sy);
|
w = wp->window = window_create1(s->sx, s->sy);
|
||||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||||
w->active = wp;
|
w->active = wp;
|
||||||
w->name = default_window_name(w);
|
name = default_window_name(w);
|
||||||
|
window_set_name(w, name);
|
||||||
|
free(name);
|
||||||
layout_init(w);
|
layout_init(w);
|
||||||
|
|
||||||
base_idx = options_get_number(&s->options, "base-index");
|
base_idx = options_get_number(&s->options, "base-index");
|
||||||
@@ -85,5 +92,23 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
server_status_session_group(s);
|
server_status_session_group(s);
|
||||||
|
|
||||||
return (0);
|
if (args_has(args, 'P')) {
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = BREAK_PANE_TEMPLATE;
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
if ((c = cmd_find_client(ctx, NULL)) != NULL)
|
||||||
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, wp);
|
||||||
|
|
||||||
|
cp = format_expand(ft, template);
|
||||||
|
ctx->print(ctx, "%s", cp);
|
||||||
|
free(cp);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
* Write the entire contents of a pane to a buffer.
|
* Write the entire contents of a pane to a buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_capture_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_capture_pane_entry = {
|
const struct cmd_entry cmd_capture_pane_entry = {
|
||||||
"capture-pane", "capturep",
|
"capture-pane", "capturep",
|
||||||
@@ -39,7 +39,7 @@ const struct cmd_entry cmd_capture_pane_entry = {
|
|||||||
cmd_capture_pane_exec
|
cmd_capture_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -52,17 +52,17 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
size_t len, linelen;
|
size_t len, linelen;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
s = &wp->base;
|
s = &wp->base;
|
||||||
gd = s->grid;
|
gd = s->grid;
|
||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
n = args_strtonum(args, 'S', SHRT_MIN, SHRT_MAX, &cause);
|
n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
top = gd->hsize;
|
top = gd->hsize;
|
||||||
xfree(cause);
|
free(cause);
|
||||||
} else if (n < 0 && (u_int) -n > gd->hsize)
|
} else if (n < 0 && (u_int) -n > gd->hsize)
|
||||||
top = 0;
|
top = 0;
|
||||||
else
|
else
|
||||||
@@ -70,10 +70,10 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (top > gd->hsize + gd->sy - 1)
|
if (top > gd->hsize + gd->sy - 1)
|
||||||
top = gd->hsize + gd->sy - 1;
|
top = gd->hsize + gd->sy - 1;
|
||||||
|
|
||||||
n = args_strtonum(args, 'E', SHRT_MIN, SHRT_MAX, &cause);
|
n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
bottom = gd->hsize + gd->sy - 1;
|
bottom = gd->hsize + gd->sy - 1;
|
||||||
xfree(cause);
|
free(cause);
|
||||||
} else if (n < 0 && (u_int) -n > gd->hsize)
|
} else if (n < 0 && (u_int) -n > gd->hsize)
|
||||||
bottom = 0;
|
bottom = 0;
|
||||||
else
|
else
|
||||||
@@ -96,28 +96,29 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
len += linelen;
|
len += linelen;
|
||||||
buf[len++] = '\n';
|
buf[len++] = '\n';
|
||||||
|
|
||||||
xfree(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
limit = options_get_number(&global_options, "buffer-limit");
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
|
|
||||||
if (!args_has(args, 'b')) {
|
if (!args_has(args, 'b')) {
|
||||||
paste_add(&global_buffers, buf, len, limit);
|
paste_add(&global_buffers, buf, len, limit);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
xfree(cause);
|
free(buf);
|
||||||
return (-1);
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paste_replace(&global_buffers, buffer, buf, len) != 0) {
|
if (paste_replace(&global_buffers, buffer, buf, len) != 0) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
xfree(buf);
|
free(buf);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,118 +27,100 @@
|
|||||||
* Enter choice mode to choose a buffer.
|
* Enter choice mode to choose a buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_choose_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_choose_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_choose_buffer_callback(void *, int);
|
void cmd_choose_buffer_callback(struct window_choose_data *);
|
||||||
void cmd_choose_buffer_free(void *);
|
void cmd_choose_buffer_free(struct window_choose_data *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_buffer_entry = {
|
const struct cmd_entry cmd_choose_buffer_entry = {
|
||||||
"choose-buffer", NULL,
|
"choose-buffer", NULL,
|
||||||
"t:", 0, 1,
|
"F:t:", 0, 1,
|
||||||
CMD_TARGET_WINDOW_USAGE " [template]",
|
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_choose_buffer_exec
|
cmd_choose_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_choose_buffer_data {
|
enum cmd_retval
|
||||||
struct client *client;
|
|
||||||
char *template;
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct cmd_choose_buffer_data *cdata;
|
struct window_choose_data *cdata;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
|
char *action, *action_data;
|
||||||
|
const char *template;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
char *tmp;
|
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = CHOOSE_BUFFER_TEMPLATE;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (paste_get_top(&global_buffers) == NULL)
|
if (paste_get_top(&global_buffers) == NULL)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
if (args->argc != 0)
|
||||||
|
action = xstrdup(args->argv[0]);
|
||||||
|
else
|
||||||
|
action = xstrdup("paste-buffer -b '%%'");
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
|
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
|
||||||
tmp = paste_print(pb, 50);
|
cdata = window_choose_data_create(ctx);
|
||||||
window_choose_add(wl->window->active, idx - 1,
|
cdata->idx = idx - 1;
|
||||||
"%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp);
|
cdata->client->references++;
|
||||||
xfree(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata->ft_template = xstrdup(template);
|
||||||
if (args->argc != 0)
|
format_add(cdata->ft, "line", "%u", idx - 1);
|
||||||
cdata->template = xstrdup(args->argv[0]);
|
format_paste_buffer(cdata->ft, pb);
|
||||||
else
|
|
||||||
cdata->template = xstrdup("paste-buffer -b '%%'");
|
xasprintf(&action_data, "%u", idx - 1);
|
||||||
cdata->client = ctx->curclient;
|
cdata->command = cmd_template_replace(action, action_data, 1);
|
||||||
cdata->client->references++;
|
free(action_data);
|
||||||
|
|
||||||
|
window_choose_add(wl->window->active, cdata);
|
||||||
|
}
|
||||||
|
free(action);
|
||||||
|
|
||||||
window_choose_ready(wl->window->active,
|
window_choose_ready(wl->window->active,
|
||||||
0, cmd_choose_buffer_callback, cmd_choose_buffer_free, cdata);
|
0, cmd_choose_buffer_callback, cmd_choose_buffer_free);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_choose_buffer_callback(void *data, int idx)
|
cmd_choose_buffer_callback(struct window_choose_data *cdata)
|
||||||
{
|
{
|
||||||
struct cmd_choose_buffer_data *cdata = data;
|
if (cdata == NULL)
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmd_ctx ctx;
|
|
||||||
char *template, *cause, tmp[16];
|
|
||||||
|
|
||||||
if (idx == -1)
|
|
||||||
return;
|
return;
|
||||||
if (cdata->client->flags & CLIENT_DEAD)
|
if (cdata->client->flags & CLIENT_DEAD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xsnprintf(tmp, sizeof tmp, "%u", idx);
|
window_choose_ctx(cdata);
|
||||||
template = cmd_template_replace(cdata->template, tmp, 1);
|
|
||||||
|
|
||||||
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
|
||||||
if (cause != NULL) {
|
|
||||||
*cause = toupper((u_char) *cause);
|
|
||||||
status_message_set(cdata->client, "%s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
|
||||||
ctx.curclient = cdata->client;
|
|
||||||
|
|
||||||
ctx.error = key_bindings_error;
|
|
||||||
ctx.print = key_bindings_print;
|
|
||||||
ctx.info = key_bindings_info;
|
|
||||||
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
|
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_choose_buffer_free(void *data)
|
cmd_choose_buffer_free(struct window_choose_data *data)
|
||||||
{
|
{
|
||||||
struct cmd_choose_buffer_data *cdata = data;
|
struct window_choose_data *cdata = data;
|
||||||
|
|
||||||
|
if (cdata == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
cdata->client->references--;
|
cdata->client->references--;
|
||||||
xfree(cdata->template);
|
|
||||||
xfree(cdata);
|
free(cdata->command);
|
||||||
|
free(cdata->ft_template);
|
||||||
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,15 +27,15 @@
|
|||||||
* Enter choice mode to choose a client.
|
* Enter choice mode to choose a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_choose_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_choose_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_choose_client_callback(void *, int);
|
void cmd_choose_client_callback(struct window_choose_data *);
|
||||||
void cmd_choose_client_free(void *);
|
void cmd_choose_client_free(struct window_choose_data *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_client_entry = {
|
const struct cmd_entry cmd_choose_client_entry = {
|
||||||
"choose-client", NULL,
|
"choose-client", NULL,
|
||||||
"t:", 0, 1,
|
"F:t:", 0, 1,
|
||||||
CMD_TARGET_WINDOW_USAGE " [template]",
|
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -46,25 +47,35 @@ struct cmd_choose_client_data {
|
|||||||
char *template;
|
char *template;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct cmd_choose_client_data *cdata;
|
struct window_choose_data *cdata;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
const char *template;
|
||||||
|
char *action;
|
||||||
u_int i, idx, cur;
|
u_int i, idx, cur;
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = CHOOSE_CLIENT_TEMPLATE;
|
||||||
|
|
||||||
|
if (args->argc != 0)
|
||||||
|
action = xstrdup(args->argv[0]);
|
||||||
|
else
|
||||||
|
action = xstrdup("detach-client -t '%%'");
|
||||||
|
|
||||||
cur = idx = 0;
|
cur = idx = 0;
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
@@ -75,77 +86,56 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cur = idx;
|
cur = idx;
|
||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
window_choose_add(wl->window->active, i,
|
cdata = window_choose_data_create(ctx);
|
||||||
"%s: %s [%ux%u %s]%s", c->tty.path,
|
cdata->idx = i;
|
||||||
c->session->name, c->tty.sx, c->tty.sy,
|
cdata->client->references++;
|
||||||
c->tty.termname, c->tty.flags & TTY_UTF8 ? " (utf8)" : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata->ft_template = xstrdup(template);
|
||||||
if (args->argc != 0)
|
format_add(cdata->ft, "line", "%u", i);
|
||||||
cdata->template = xstrdup(args->argv[0]);
|
format_session(cdata->ft, c->session);
|
||||||
else
|
format_client(cdata->ft, c);
|
||||||
cdata->template = xstrdup("detach-client -t '%%'");
|
|
||||||
cdata->client = ctx->curclient;
|
cdata->command = cmd_template_replace(action, c->tty.path, 1);
|
||||||
cdata->client->references++;
|
|
||||||
|
window_choose_add(wl->window->active, cdata);
|
||||||
|
}
|
||||||
|
free(action);
|
||||||
|
|
||||||
window_choose_ready(wl->window->active,
|
window_choose_ready(wl->window->active,
|
||||||
cur, cmd_choose_client_callback, cmd_choose_client_free, cdata);
|
cur, cmd_choose_client_callback, cmd_choose_client_free);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_choose_client_callback(void *data, int idx)
|
cmd_choose_client_callback(struct window_choose_data *cdata)
|
||||||
{
|
{
|
||||||
struct cmd_choose_client_data *cdata = data;
|
struct client *c;
|
||||||
struct client *c;
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmd_ctx ctx;
|
|
||||||
char *template, *cause;
|
|
||||||
|
|
||||||
if (idx == -1)
|
if (cdata == NULL)
|
||||||
return;
|
return;
|
||||||
if (cdata->client->flags & CLIENT_DEAD)
|
if (cdata->client->flags & CLIENT_DEAD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((u_int) idx > ARRAY_LENGTH(&clients) - 1)
|
if (cdata->idx > ARRAY_LENGTH(&clients) - 1)
|
||||||
return;
|
return;
|
||||||
c = ARRAY_ITEM(&clients, idx);
|
c = ARRAY_ITEM(&clients, cdata->idx);
|
||||||
if (c == NULL || c->session == NULL)
|
if (c == NULL || c->session == NULL)
|
||||||
return;
|
return;
|
||||||
template = cmd_template_replace(cdata->template, c->tty.path, 1);
|
|
||||||
|
|
||||||
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
window_choose_ctx(cdata);
|
||||||
if (cause != NULL) {
|
|
||||||
*cause = toupper((u_char) *cause);
|
|
||||||
status_message_set(c, "%s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
|
||||||
ctx.curclient = cdata->client;
|
|
||||||
|
|
||||||
ctx.error = key_bindings_error;
|
|
||||||
ctx.print = key_bindings_print;
|
|
||||||
ctx.info = key_bindings_info;
|
|
||||||
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
|
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_choose_client_free(void *data)
|
cmd_choose_client_free(struct window_choose_data *cdata)
|
||||||
{
|
{
|
||||||
struct cmd_choose_client_data *cdata = data;
|
if (cdata == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
cdata->client->references--;
|
cdata->client->references--;
|
||||||
xfree(cdata->template);
|
|
||||||
xfree(cdata);
|
free(cdata->ft_template);
|
||||||
|
free(cdata->command);
|
||||||
|
format_free(cdata->ft);
|
||||||
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
123
cmd-choose-list.c
Normal file
123
cmd-choose-list.c
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.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 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 <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
#define CMD_CHOOSE_LIST_DEFAULT_TEMPLATE "run-shell '%%'"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enter choose mode to choose a custom list.
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum cmd_retval cmd_choose_list_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
void cmd_choose_list_callback(struct window_choose_data *);
|
||||||
|
void cmd_choose_list_free(struct window_choose_data *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_choose_list_entry = {
|
||||||
|
"choose-list", NULL,
|
||||||
|
"l:t:", 0, 1,
|
||||||
|
"[-l items] " CMD_TARGET_WINDOW_USAGE "[template]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_choose_list_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_choose_list_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct winlink *wl;
|
||||||
|
const char *list1;
|
||||||
|
char *template, *item, *copy, *list;
|
||||||
|
u_int idx;
|
||||||
|
|
||||||
|
if (ctx->curclient == NULL) {
|
||||||
|
ctx->error(ctx, "must be run interactively");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((list1 = args_get(args, 'l')) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
if (args->argc != 0)
|
||||||
|
template = xstrdup(args->argv[0]);
|
||||||
|
else
|
||||||
|
template = xstrdup(CMD_CHOOSE_LIST_DEFAULT_TEMPLATE);
|
||||||
|
|
||||||
|
copy = list = xstrdup(list1);
|
||||||
|
idx = 0;
|
||||||
|
while ((item = strsep(&list, ",")) != NULL)
|
||||||
|
{
|
||||||
|
if (*item == '\0') /* no empty entries */
|
||||||
|
continue;
|
||||||
|
window_choose_add_item(wl->window->active, ctx, wl, item,
|
||||||
|
template, idx);
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
free(copy);
|
||||||
|
|
||||||
|
if (idx == 0) {
|
||||||
|
free(template);
|
||||||
|
window_pane_reset_mode(wl->window->active);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
window_choose_ready(wl->window->active, 0, cmd_choose_list_callback,
|
||||||
|
cmd_choose_list_free);
|
||||||
|
|
||||||
|
free(template);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_choose_list_callback(struct window_choose_data *cdata)
|
||||||
|
{
|
||||||
|
if (cdata == NULL || (cdata->client->flags & CLIENT_DEAD))
|
||||||
|
return;
|
||||||
|
|
||||||
|
window_choose_ctx(cdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_choose_list_free(struct window_choose_data *cdata)
|
||||||
|
{
|
||||||
|
cdata->session->references--;
|
||||||
|
cdata->client->references--;
|
||||||
|
|
||||||
|
free(cdata->ft_template);
|
||||||
|
free(cdata->command);
|
||||||
|
format_free(cdata->ft);
|
||||||
|
free(cdata);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* 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 <ctype.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enter choice mode to choose a session.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_choose_session_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
void cmd_choose_session_callback(void *, int);
|
|
||||||
void cmd_choose_session_free(void *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_session_entry = {
|
|
||||||
"choose-session", NULL,
|
|
||||||
"t:", 0, 1,
|
|
||||||
CMD_TARGET_WINDOW_USAGE " [template]",
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_choose_session_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
struct cmd_choose_session_data {
|
|
||||||
struct client *client;
|
|
||||||
char *template;
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct cmd_choose_session_data *cdata;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct session *s;
|
|
||||||
struct session_group *sg;
|
|
||||||
u_int idx, sgidx, cur;
|
|
||||||
char tmp[64];
|
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
|
||||||
ctx->error(ctx, "must be run interactively");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
cur = idx = 0;
|
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
|
||||||
if (s == ctx->curclient->session)
|
|
||||||
cur = idx;
|
|
||||||
idx++;
|
|
||||||
|
|
||||||
sg = session_group_find(s);
|
|
||||||
if (sg == NULL)
|
|
||||||
*tmp = '\0';
|
|
||||||
else {
|
|
||||||
sgidx = session_group_index(sg);
|
|
||||||
xsnprintf(tmp, sizeof tmp, " (group %u)", sgidx);
|
|
||||||
}
|
|
||||||
|
|
||||||
window_choose_add(wl->window->active, s->idx,
|
|
||||||
"%s: %u windows [%ux%u]%s%s", s->name,
|
|
||||||
winlink_count(&s->windows), s->sx, s->sy,
|
|
||||||
tmp, s->flags & SESSION_UNATTACHED ? "" : " (attached)");
|
|
||||||
}
|
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
|
||||||
if (args->argc != 0)
|
|
||||||
cdata->template = xstrdup(args->argv[0]);
|
|
||||||
else
|
|
||||||
cdata->template = xstrdup("switch-client -t '%%'");
|
|
||||||
cdata->client = ctx->curclient;
|
|
||||||
cdata->client->references++;
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active,
|
|
||||||
cur, cmd_choose_session_callback, cmd_choose_session_free, cdata);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_choose_session_callback(void *data, int idx)
|
|
||||||
{
|
|
||||||
struct cmd_choose_session_data *cdata = data;
|
|
||||||
struct session *s;
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmd_ctx ctx;
|
|
||||||
char *template, *cause;
|
|
||||||
|
|
||||||
if (idx == -1)
|
|
||||||
return;
|
|
||||||
if (cdata->client->flags & CLIENT_DEAD)
|
|
||||||
return;
|
|
||||||
|
|
||||||
s = session_find_by_index(idx);
|
|
||||||
if (s == NULL)
|
|
||||||
return;
|
|
||||||
template = cmd_template_replace(cdata->template, s->name, 1);
|
|
||||||
|
|
||||||
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
|
||||||
if (cause != NULL) {
|
|
||||||
*cause = toupper((u_char) *cause);
|
|
||||||
status_message_set(cdata->client, "%s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
|
||||||
ctx.curclient = cdata->client;
|
|
||||||
|
|
||||||
ctx.error = key_bindings_error;
|
|
||||||
ctx.print = key_bindings_print;
|
|
||||||
ctx.info = key_bindings_info;
|
|
||||||
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
|
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_choose_session_free(void *data)
|
|
||||||
{
|
|
||||||
struct cmd_choose_session_data *cdata = data;
|
|
||||||
|
|
||||||
cdata->client->references--;
|
|
||||||
xfree(cdata->template);
|
|
||||||
xfree(cdata);
|
|
||||||
}
|
|
||||||
261
cmd-choose-tree.c
Normal file
261
cmd-choose-tree.c
Normal file
@@ -0,0 +1,261 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.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 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 <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
#define CMD_CHOOSE_TREE_WINDOW_ACTION "select-window -t '%%'"
|
||||||
|
#define CMD_CHOOSE_TREE_SESSION_ACTION "switch-client -t '%%'"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enter choice mode to choose a session and/or window.
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
void cmd_choose_tree_callback(struct window_choose_data *);
|
||||||
|
void cmd_choose_tree_free(struct window_choose_data *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_choose_tree_entry = {
|
||||||
|
"choose-tree", NULL,
|
||||||
|
"S:W:swb:c:t:", 0, 1,
|
||||||
|
"[-sw] [-b session-template] [-c window template] [-S format] " \
|
||||||
|
"[-W format] " CMD_TARGET_WINDOW_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_choose_tree_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_choose_session_entry = {
|
||||||
|
"choose-session", NULL,
|
||||||
|
"F:t:", 0, 1,
|
||||||
|
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_choose_tree_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_choose_window_entry = {
|
||||||
|
"choose-window", NULL,
|
||||||
|
"F:t:", 0, 1,
|
||||||
|
CMD_TARGET_WINDOW_USAGE "[-F format] [template]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_choose_tree_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct winlink *wl, *wm;
|
||||||
|
struct session *s, *s2;
|
||||||
|
struct window_choose_data *wcd = NULL;
|
||||||
|
const char *ses_template, *win_template;
|
||||||
|
char *final_win_action, *cur_win_template;
|
||||||
|
char *final_win_template_middle;
|
||||||
|
char *final_win_template_last;
|
||||||
|
const char *ses_action, *win_action;
|
||||||
|
u_int cur_win, idx_ses, win_ses, win_max;
|
||||||
|
u_int wflag, sflag;
|
||||||
|
|
||||||
|
ses_template = win_template = NULL;
|
||||||
|
ses_action = win_action = NULL;
|
||||||
|
|
||||||
|
if (ctx->curclient == NULL) {
|
||||||
|
ctx->error(ctx, "must be run interactively");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
s = ctx->curclient->session;
|
||||||
|
|
||||||
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
/* Sort out which command this is. */
|
||||||
|
wflag = sflag = 0;
|
||||||
|
if (self->entry == &cmd_choose_session_entry) {
|
||||||
|
sflag = 1;
|
||||||
|
if ((ses_template = args_get(args, 'F')) == NULL)
|
||||||
|
ses_template = CHOOSE_TREE_SESSION_TEMPLATE;
|
||||||
|
|
||||||
|
if (args->argc != 0)
|
||||||
|
ses_action = args->argv[0];
|
||||||
|
else
|
||||||
|
ses_action = CMD_CHOOSE_TREE_SESSION_ACTION;
|
||||||
|
} else if (self->entry == &cmd_choose_window_entry) {
|
||||||
|
wflag = 1;
|
||||||
|
if ((win_template = args_get(args, 'F')) == NULL)
|
||||||
|
win_template = CHOOSE_TREE_WINDOW_TEMPLATE;
|
||||||
|
|
||||||
|
if (args->argc != 0)
|
||||||
|
win_action = args->argv[0];
|
||||||
|
else
|
||||||
|
win_action = CMD_CHOOSE_TREE_WINDOW_ACTION;
|
||||||
|
} else {
|
||||||
|
wflag = args_has(args, 'w');
|
||||||
|
sflag = args_has(args, 's');
|
||||||
|
|
||||||
|
if ((ses_action = args_get(args, 'b')) == NULL)
|
||||||
|
ses_action = CMD_CHOOSE_TREE_SESSION_ACTION;
|
||||||
|
|
||||||
|
if ((win_action = args_get(args, 'c')) == NULL)
|
||||||
|
win_action = CMD_CHOOSE_TREE_WINDOW_ACTION;
|
||||||
|
|
||||||
|
if ((ses_template = args_get(args, 'S')) == NULL)
|
||||||
|
ses_template = CHOOSE_TREE_SESSION_TEMPLATE;
|
||||||
|
|
||||||
|
if ((win_template = args_get(args, 'W')) == NULL)
|
||||||
|
win_template = CHOOSE_TREE_WINDOW_TEMPLATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If not asking for windows and sessions, assume no "-ws" given and
|
||||||
|
* hence display the entire tree outright.
|
||||||
|
*/
|
||||||
|
if (!wflag && !sflag)
|
||||||
|
wflag = sflag = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we're drawing in tree mode, including sessions, then pad the
|
||||||
|
* window template, otherwise just render the windows as a flat list
|
||||||
|
* without any padding.
|
||||||
|
*/
|
||||||
|
if (wflag && sflag) {
|
||||||
|
xasprintf(&final_win_template_middle,
|
||||||
|
" \001tq\001> %s", win_template);
|
||||||
|
xasprintf(&final_win_template_last,
|
||||||
|
" \001mq\001> %s", win_template);
|
||||||
|
} else if (wflag) {
|
||||||
|
final_win_template_middle = xstrdup(win_template);
|
||||||
|
final_win_template_last = xstrdup(win_template);
|
||||||
|
} else
|
||||||
|
final_win_template_middle = final_win_template_last = NULL;
|
||||||
|
|
||||||
|
idx_ses = cur_win = -1;
|
||||||
|
RB_FOREACH(s2, sessions, &sessions) {
|
||||||
|
idx_ses++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we're just choosing windows, jump straight there. Note
|
||||||
|
* that this implies the current session, so only choose
|
||||||
|
* windows when the session matches this one.
|
||||||
|
*/
|
||||||
|
if (wflag && !sflag) {
|
||||||
|
if (s != s2)
|
||||||
|
continue;
|
||||||
|
goto windows_only;
|
||||||
|
}
|
||||||
|
|
||||||
|
wcd = window_choose_add_session(wl->window->active,
|
||||||
|
ctx, s2, ses_template, (char *)ses_action, idx_ses);
|
||||||
|
|
||||||
|
/* If we're just choosing sessions, skip choosing windows. */
|
||||||
|
if (sflag && !wflag) {
|
||||||
|
if (s == s2)
|
||||||
|
cur_win = idx_ses;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
windows_only:
|
||||||
|
win_ses = win_max = -1;
|
||||||
|
RB_FOREACH(wm, winlinks, &s2->windows)
|
||||||
|
win_max++;
|
||||||
|
RB_FOREACH(wm, winlinks, &s2->windows) {
|
||||||
|
win_ses++;
|
||||||
|
if (sflag && wflag)
|
||||||
|
idx_ses++;
|
||||||
|
|
||||||
|
if (wm == s2->curw && s == s2) {
|
||||||
|
if (wflag && !sflag) {
|
||||||
|
/*
|
||||||
|
* Then we're only counting windows.
|
||||||
|
* So remember which is the current
|
||||||
|
* window in the list.
|
||||||
|
*/
|
||||||
|
cur_win = win_ses;
|
||||||
|
} else
|
||||||
|
cur_win = idx_ses;
|
||||||
|
}
|
||||||
|
|
||||||
|
xasprintf(&final_win_action, "%s ; %s", win_action,
|
||||||
|
wcd ? wcd->command : "");
|
||||||
|
|
||||||
|
if (win_ses != win_max)
|
||||||
|
cur_win_template = final_win_template_middle;
|
||||||
|
else
|
||||||
|
cur_win_template = final_win_template_last;
|
||||||
|
|
||||||
|
window_choose_add_window(wl->window->active,
|
||||||
|
ctx, s2, wm, cur_win_template,
|
||||||
|
final_win_action,
|
||||||
|
(wflag && !sflag) ? win_ses : idx_ses);
|
||||||
|
|
||||||
|
free(final_win_action);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* If we're just drawing windows, don't consider moving on to
|
||||||
|
* other sessions as we only list windows in this session.
|
||||||
|
*/
|
||||||
|
if (wflag && !sflag)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free(final_win_template_middle);
|
||||||
|
free(final_win_template_last);
|
||||||
|
|
||||||
|
window_choose_ready(wl->window->active, cur_win,
|
||||||
|
cmd_choose_tree_callback, cmd_choose_tree_free);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_choose_tree_callback(struct window_choose_data *cdata)
|
||||||
|
{
|
||||||
|
if (cdata == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cdata->client->flags & CLIENT_DEAD)
|
||||||
|
return;
|
||||||
|
|
||||||
|
window_choose_ctx(cdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_choose_tree_free(struct window_choose_data *cdata)
|
||||||
|
{
|
||||||
|
cdata->session->references--;
|
||||||
|
cdata->client->references--;
|
||||||
|
|
||||||
|
free(cdata->ft_template);
|
||||||
|
free(cdata->command);
|
||||||
|
format_free(cdata->ft);
|
||||||
|
free(cdata);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* 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 <ctype.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enter choice mode to choose a window.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_choose_window_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
void cmd_choose_window_callback(void *, int);
|
|
||||||
void cmd_choose_window_free(void *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_window_entry = {
|
|
||||||
"choose-window", NULL,
|
|
||||||
"t:", 0, 1,
|
|
||||||
CMD_TARGET_WINDOW_USAGE " [template]",
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_choose_window_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
struct cmd_choose_window_data {
|
|
||||||
struct client *client;
|
|
||||||
struct session *session;
|
|
||||||
char *template;
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct cmd_choose_window_data *cdata;
|
|
||||||
struct session *s;
|
|
||||||
struct winlink *wl, *wm;
|
|
||||||
struct window *w;
|
|
||||||
u_int idx, cur;
|
|
||||||
char *flags, *title;
|
|
||||||
const char *left, *right;
|
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
|
||||||
ctx->error(ctx, "must be run interactively");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
s = ctx->curclient->session;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
cur = idx = 0;
|
|
||||||
RB_FOREACH(wm, winlinks, &s->windows) {
|
|
||||||
w = wm->window;
|
|
||||||
|
|
||||||
if (wm == s->curw)
|
|
||||||
cur = idx;
|
|
||||||
idx++;
|
|
||||||
|
|
||||||
flags = window_printable_flags(s, wm);
|
|
||||||
title = w->active->screen->title;
|
|
||||||
if (wm == wl)
|
|
||||||
title = w->active->base.title;
|
|
||||||
left = " \"";
|
|
||||||
right = "\"";
|
|
||||||
if (*title == '\0')
|
|
||||||
left = right = "";
|
|
||||||
|
|
||||||
window_choose_add(wl->window->active,
|
|
||||||
wm->idx, "%3d: %s%s [%ux%u] (%u panes%s)%s%s%s",
|
|
||||||
wm->idx, w->name, flags, w->sx, w->sy, window_count_panes(w),
|
|
||||||
w->active->fd == -1 ? ", dead" : "",
|
|
||||||
left, title, right);
|
|
||||||
|
|
||||||
xfree(flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
|
||||||
if (args->argc != 0)
|
|
||||||
cdata->template = xstrdup(args->argv[0]);
|
|
||||||
else
|
|
||||||
cdata->template = xstrdup("select-window -t '%%'");
|
|
||||||
cdata->session = s;
|
|
||||||
cdata->session->references++;
|
|
||||||
cdata->client = ctx->curclient;
|
|
||||||
cdata->client->references++;
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active,
|
|
||||||
cur, cmd_choose_window_callback, cmd_choose_window_free, cdata);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_choose_window_callback(void *data, int idx)
|
|
||||||
{
|
|
||||||
struct cmd_choose_window_data *cdata = data;
|
|
||||||
struct session *s = cdata->session;
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmd_ctx ctx;
|
|
||||||
char *target, *template, *cause;
|
|
||||||
|
|
||||||
if (idx == -1)
|
|
||||||
return;
|
|
||||||
if (!session_alive(s))
|
|
||||||
return;
|
|
||||||
if (cdata->client->flags & CLIENT_DEAD)
|
|
||||||
return;
|
|
||||||
|
|
||||||
xasprintf(&target, "%s:%d", s->name, idx);
|
|
||||||
template = cmd_template_replace(cdata->template, target, 1);
|
|
||||||
xfree(target);
|
|
||||||
|
|
||||||
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
|
||||||
if (cause != NULL) {
|
|
||||||
*cause = toupper((u_char) *cause);
|
|
||||||
status_message_set(cdata->client, "%s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
|
||||||
ctx.curclient = cdata->client;
|
|
||||||
|
|
||||||
ctx.error = key_bindings_error;
|
|
||||||
ctx.print = key_bindings_print;
|
|
||||||
ctx.info = key_bindings_info;
|
|
||||||
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
|
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_choose_window_free(void *data)
|
|
||||||
{
|
|
||||||
struct cmd_choose_window_data *cdata = data;
|
|
||||||
|
|
||||||
cdata->session->references--;
|
|
||||||
cdata->client->references--;
|
|
||||||
xfree(cdata->template);
|
|
||||||
xfree(cdata);
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
* Clear pane history.
|
* Clear pane history.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_clear_history_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_clear_history_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_clear_history_entry = {
|
const struct cmd_entry cmd_clear_history_entry = {
|
||||||
"clear-history", "clearhist",
|
"clear-history", "clearhist",
|
||||||
@@ -36,7 +36,7 @@ const struct cmd_entry cmd_clear_history_entry = {
|
|||||||
cmd_clear_history_exec
|
cmd_clear_history_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_clear_history_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_clear_history_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -44,11 +44,11 @@ cmd_clear_history_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct grid *gd;
|
struct grid *gd;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
gd = wp->base.grid;
|
gd = wp->base.grid;
|
||||||
|
|
||||||
grid_move_lines(gd, 0, gd->hsize, gd->sy);
|
grid_move_lines(gd, 0, gd->hsize, gd->sy);
|
||||||
gd->hsize = 0;
|
gd->hsize = 0;
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
* Enter clock mode.
|
* Enter clock mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_clock_mode_entry = {
|
const struct cmd_entry cmd_clock_mode_entry = {
|
||||||
"clock-mode", NULL,
|
"clock-mode", NULL,
|
||||||
@@ -36,16 +36,16 @@ const struct cmd_entry cmd_clock_mode_entry = {
|
|||||||
cmd_clock_mode_exec
|
cmd_clock_mode_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_clock_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_clock_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
window_pane_set_mode(wp, &window_clock_mode);
|
window_pane_set_mode(wp, &window_clock_mode);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@
|
|||||||
|
|
||||||
void cmd_command_prompt_key_binding(struct cmd *, int);
|
void cmd_command_prompt_key_binding(struct cmd *, int);
|
||||||
int cmd_command_prompt_check(struct args *);
|
int cmd_command_prompt_check(struct args *);
|
||||||
int cmd_command_prompt_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_command_prompt_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
int cmd_command_prompt_callback(void *, const char *);
|
int cmd_command_prompt_callback(void *, const char *);
|
||||||
void cmd_command_prompt_free(void *);
|
void cmd_command_prompt_free(void *);
|
||||||
@@ -83,7 +84,7 @@ cmd_command_prompt_key_binding(struct cmd *self, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -94,10 +95,10 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (c->prompt_string != NULL)
|
if (c->prompt_string != NULL)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
cdata->c = c;
|
cdata->c = c;
|
||||||
@@ -138,9 +139,9 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
status_prompt_set(c, prompt, input, cmd_command_prompt_callback,
|
status_prompt_set(c, prompt, input, cmd_command_prompt_callback,
|
||||||
cmd_command_prompt_free, cdata, 0);
|
cmd_command_prompt_free, cdata, 0);
|
||||||
xfree(prompt);
|
free(prompt);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -157,7 +158,7 @@ cmd_command_prompt_callback(void *data, const char *s)
|
|||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
new_template = cmd_template_replace(cdata->template, s, cdata->idx);
|
new_template = cmd_template_replace(cdata->template, s, cdata->idx);
|
||||||
xfree(cdata->template);
|
free(cdata->template);
|
||||||
cdata->template = new_template;
|
cdata->template = new_template;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -169,7 +170,7 @@ cmd_command_prompt_callback(void *data, const char *s)
|
|||||||
input = strsep(&cdata->next_input, ",");
|
input = strsep(&cdata->next_input, ",");
|
||||||
status_prompt_update(c, prompt, input);
|
status_prompt_update(c, prompt, input);
|
||||||
|
|
||||||
xfree(prompt);
|
free(prompt);
|
||||||
cdata->idx++;
|
cdata->idx++;
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
@@ -178,7 +179,7 @@ cmd_command_prompt_callback(void *data, const char *s)
|
|||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
*cause = toupper((u_char) *cause);
|
*cause = toupper((u_char) *cause);
|
||||||
status_message_set(c, "%s", cause);
|
status_message_set(c, "%s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -205,11 +206,8 @@ cmd_command_prompt_free(void *data)
|
|||||||
{
|
{
|
||||||
struct cmd_command_prompt_cdata *cdata = data;
|
struct cmd_command_prompt_cdata *cdata = data;
|
||||||
|
|
||||||
if (cdata->inputs != NULL)
|
free(cdata->inputs);
|
||||||
xfree(cdata->inputs);
|
free(cdata->prompts);
|
||||||
if (cdata->prompts != NULL)
|
free(cdata->template);
|
||||||
xfree(cdata->prompts);
|
free(cdata);
|
||||||
if (cdata->template != NULL)
|
|
||||||
xfree(cdata->template);
|
|
||||||
xfree(cdata);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -25,11 +26,11 @@
|
|||||||
* Asks for confirmation before executing a command.
|
* Asks for confirmation before executing a command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_confirm_before_key_binding(struct cmd *, int);
|
void cmd_confirm_before_key_binding(struct cmd *, int);
|
||||||
int cmd_confirm_before_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_confirm_before_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
int cmd_confirm_before_callback(void *, const char *);
|
int cmd_confirm_before_callback(void *, const char *);
|
||||||
void cmd_confirm_before_free(void *);
|
void cmd_confirm_before_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_confirm_before_entry = {
|
const struct cmd_entry cmd_confirm_before_entry = {
|
||||||
"confirm-before", "confirm",
|
"confirm-before", "confirm",
|
||||||
@@ -64,7 +65,7 @@ cmd_confirm_before_key_binding(struct cmd *self, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -75,11 +76,11 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if ((prompt = args_get(args, 'p')) != NULL)
|
if ((prompt = args_get(args, 'p')) != NULL)
|
||||||
xasprintf(&new_prompt, "%s ", prompt);
|
xasprintf(&new_prompt, "%s ", prompt);
|
||||||
@@ -87,7 +88,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ptr = copy = xstrdup(args->argv[0]);
|
ptr = copy = xstrdup(args->argv[0]);
|
||||||
cmd = strsep(&ptr, " \t");
|
cmd = strsep(&ptr, " \t");
|
||||||
xasprintf(&new_prompt, "Confirm '%s'? (y/n) ", cmd);
|
xasprintf(&new_prompt, "Confirm '%s'? (y/n) ", cmd);
|
||||||
xfree(copy);
|
free(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
@@ -97,8 +98,8 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cmd_confirm_before_callback, cmd_confirm_before_free, cdata,
|
cmd_confirm_before_callback, cmd_confirm_before_free, cdata,
|
||||||
PROMPT_SINGLE);
|
PROMPT_SINGLE);
|
||||||
|
|
||||||
xfree(new_prompt);
|
free(new_prompt);
|
||||||
return (1);
|
return (CMD_RETURN_YIELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -119,7 +120,7 @@ cmd_confirm_before_callback(void *data, const char *s)
|
|||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
*cause = toupper((u_char) *cause);
|
*cause = toupper((u_char) *cause);
|
||||||
status_message_set(c, "%s", cause);
|
status_message_set(c, "%s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -144,7 +145,6 @@ cmd_confirm_before_free(void *data)
|
|||||||
{
|
{
|
||||||
struct cmd_confirm_before_data *cdata = data;
|
struct cmd_confirm_before_data *cdata = data;
|
||||||
|
|
||||||
if (cdata->cmd != NULL)
|
free(cdata->cmd);
|
||||||
xfree(cdata->cmd);
|
free(cdata);
|
||||||
xfree(cdata);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
* Enter copy mode.
|
* Enter copy mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_copy_mode_key_binding(struct cmd *, int);
|
void cmd_copy_mode_key_binding(struct cmd *, int);
|
||||||
int cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_copy_mode_entry = {
|
const struct cmd_entry cmd_copy_mode_entry = {
|
||||||
"copy-mode", NULL,
|
"copy-mode", NULL,
|
||||||
@@ -45,20 +45,20 @@ cmd_copy_mode_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 'u', NULL);
|
args_set(self->args, 'u', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
window_copy_init_from_pane(wp);
|
window_copy_init_from_pane(wp);
|
||||||
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
|
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
|
||||||
window_copy_pageup(wp);
|
window_copy_pageup(wp);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
* Delete a paste buffer.
|
* Delete a paste buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_delete_buffer_entry = {
|
const struct cmd_entry cmd_delete_buffer_entry = {
|
||||||
"delete-buffer", "deleteb",
|
"delete-buffer", "deleteb",
|
||||||
@@ -38,7 +38,7 @@ const struct cmd_entry cmd_delete_buffer_entry = {
|
|||||||
cmd_delete_buffer_exec
|
cmd_delete_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -47,20 +47,20 @@ cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (!args_has(args, 'b')) {
|
if (!args_has(args, 'b')) {
|
||||||
paste_free_top(&global_buffers);
|
paste_free_top(&global_buffers);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paste_free_index(&global_buffers, buffer) != 0) {
|
if (paste_free_index(&global_buffers, buffer) != 0) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,23 +24,23 @@
|
|||||||
* Detach a client.
|
* Detach a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_detach_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_detach_client_entry = {
|
const struct cmd_entry cmd_detach_client_entry = {
|
||||||
"detach-client", "detach",
|
"detach-client", "detach",
|
||||||
"s:t:P", 0, 0,
|
"as:t:P", 0, 0,
|
||||||
"[-P] [-s target-session] " CMD_TARGET_CLIENT_USAGE,
|
"[-P] [-a] [-s target-session] " CMD_TARGET_CLIENT_USAGE,
|
||||||
CMD_READONLY,
|
CMD_READONLY,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_detach_client_exec
|
cmd_detach_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c, *c2;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
enum msgtype msgtype;
|
enum msgtype msgtype;
|
||||||
u_int i;
|
u_int i;
|
||||||
@@ -53,7 +53,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (args_has(args, 's')) {
|
if (args_has(args, 's')) {
|
||||||
s = cmd_find_session(ctx, args_get(args, 's'), 0);
|
s = cmd_find_session(ctx, args_get(args, 's'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
@@ -63,10 +63,18 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
} else {
|
} else {
|
||||||
c = cmd_find_client(ctx, args_get(args, 't'));
|
c = cmd_find_client(ctx, args_get(args, 't'));
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
server_write_client(c, msgtype, NULL, 0);
|
if (args_has(args, 'a')) {
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c2 = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c2 == NULL || c == c2)
|
||||||
|
continue;
|
||||||
|
server_write_client(c2, msgtype, NULL, 0);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
server_write_client(c, msgtype, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,19 +27,19 @@
|
|||||||
* Displays a message in the status line.
|
* Displays a message in the status line.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_display_message_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_display_message_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_display_message_entry = {
|
const struct cmd_entry cmd_display_message_entry = {
|
||||||
"display-message", "display",
|
"display-message", "display",
|
||||||
"c:pt:", 0, 1,
|
"c:pt:F:", 0, 1,
|
||||||
"[-p] [-c target-client] [-t target-pane] [message]",
|
"[-p] [-c target-client] [-t target-pane] [-F format] [message]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_display_message_exec
|
cmd_display_message_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -48,31 +49,52 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
const char *template;
|
const char *template;
|
||||||
char *msg;
|
char *msg;
|
||||||
|
struct format_tree *ft;
|
||||||
|
char out[BUFSIZ];
|
||||||
|
time_t t;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, 't') != 0) {
|
if (args_has(args, 't')) {
|
||||||
wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp);
|
wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
} else {
|
} else {
|
||||||
s = NULL;
|
wl = cmd_find_pane(ctx, NULL, &s, &wp);
|
||||||
wl = NULL;
|
if (wl == NULL)
|
||||||
wp = NULL;
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc == 0)
|
if (args_has(args, 'F') && args->argc != 0) {
|
||||||
template = "[#S] #I:#W, current pane #P - (%H:%M %d-%b-%y)";
|
ctx->error(ctx, "only one of -F or argument must be given");
|
||||||
else
|
return (CMD_RETURN_ERROR);
|
||||||
template = args->argv[0];
|
}
|
||||||
|
|
||||||
msg = status_replace(c, s, wl, wp, template, time(NULL), 0);
|
template = args_get(args, 'F');
|
||||||
|
if (args->argc != 0)
|
||||||
|
template = args->argv[0];
|
||||||
|
if (template == NULL)
|
||||||
|
template = DISPLAY_MESSAGE_TEMPLATE;
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, wp);
|
||||||
|
|
||||||
|
t = time(NULL);
|
||||||
|
len = strftime(out, sizeof out, template, localtime(&t));
|
||||||
|
out[len] = '\0';
|
||||||
|
|
||||||
|
msg = format_expand(ft, out);
|
||||||
if (args_has(self->args, 'p'))
|
if (args_has(self->args, 'p'))
|
||||||
ctx->print(ctx, "%s", msg);
|
ctx->print(ctx, "%s", msg);
|
||||||
else
|
else
|
||||||
status_message_set(c, "%s", msg);
|
status_message_set(c, "%s", msg);
|
||||||
xfree(msg);
|
|
||||||
|
|
||||||
return (0);
|
free(msg);
|
||||||
|
format_free(ft);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
* Display panes on a client.
|
* Display panes on a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_display_panes_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_display_panes_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_display_panes_entry = {
|
const struct cmd_entry cmd_display_panes_entry = {
|
||||||
"display-panes", "displayp",
|
"display-panes", "displayp",
|
||||||
@@ -36,16 +36,16 @@ const struct cmd_entry cmd_display_panes_entry = {
|
|||||||
cmd_display_panes_exec
|
cmd_display_panes_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_display_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_display_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
server_set_identify(c);
|
server_set_identify(c);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -27,15 +28,25 @@
|
|||||||
* Find window containing text.
|
* Find window containing text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_find_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_find_window_callback(void *, int);
|
void cmd_find_window_callback(struct window_choose_data *);
|
||||||
void cmd_find_window_free(void *);
|
void cmd_find_window_free(struct window_choose_data *);
|
||||||
|
|
||||||
|
/* Flags for determining matching behavior. */
|
||||||
|
#define CMD_FIND_WINDOW_BY_TITLE 0x1
|
||||||
|
#define CMD_FIND_WINDOW_BY_CONTENT 0x2
|
||||||
|
#define CMD_FIND_WINDOW_BY_NAME 0x4
|
||||||
|
|
||||||
|
#define CMD_FIND_WINDOW_ALL \
|
||||||
|
(CMD_FIND_WINDOW_BY_TITLE | \
|
||||||
|
CMD_FIND_WINDOW_BY_CONTENT | \
|
||||||
|
CMD_FIND_WINDOW_BY_NAME)
|
||||||
|
|
||||||
const struct cmd_entry cmd_find_window_entry = {
|
const struct cmd_entry cmd_find_window_entry = {
|
||||||
"find-window", "findw",
|
"find-window", "findw",
|
||||||
"t:", 1, 1,
|
"F:CNt:T", 1, 4,
|
||||||
CMD_TARGET_WINDOW_USAGE " match-string",
|
"[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -43,78 +54,121 @@ const struct cmd_entry cmd_find_window_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_find_window_data {
|
struct cmd_find_window_data {
|
||||||
struct session *session;
|
struct winlink *wl;
|
||||||
|
char *list_ctx;
|
||||||
|
u_int pane_id;
|
||||||
};
|
};
|
||||||
|
ARRAY_DECL(cmd_find_window_data_list, struct cmd_find_window_data);
|
||||||
|
|
||||||
int
|
u_int cmd_find_window_match_flags(struct args *);
|
||||||
|
void cmd_find_window_match(struct cmd_find_window_data_list *, int,
|
||||||
|
struct winlink *, const char *, const char *);
|
||||||
|
|
||||||
|
u_int
|
||||||
|
cmd_find_window_match_flags(struct args *args)
|
||||||
|
{
|
||||||
|
u_int match_flags = 0;
|
||||||
|
|
||||||
|
/* Turn on flags based on the options. */
|
||||||
|
if (args_has(args, 'T'))
|
||||||
|
match_flags |= CMD_FIND_WINDOW_BY_TITLE;
|
||||||
|
if (args_has(args, 'C'))
|
||||||
|
match_flags |= CMD_FIND_WINDOW_BY_CONTENT;
|
||||||
|
if (args_has(args, 'N'))
|
||||||
|
match_flags |= CMD_FIND_WINDOW_BY_NAME;
|
||||||
|
|
||||||
|
/* If none of the flags were set, default to matching anything. */
|
||||||
|
if (match_flags == 0)
|
||||||
|
match_flags = CMD_FIND_WINDOW_ALL;
|
||||||
|
|
||||||
|
return (match_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_find_window_match(struct cmd_find_window_data_list *find_list,
|
||||||
|
int match_flags, struct winlink *wl, const char *str, const char *searchstr)
|
||||||
|
{
|
||||||
|
struct cmd_find_window_data find_data;
|
||||||
|
struct window_pane *wp;
|
||||||
|
u_int i, line;
|
||||||
|
char *sres;
|
||||||
|
|
||||||
|
memset(&find_data, 0, sizeof find_data);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||||
|
i++;
|
||||||
|
|
||||||
|
if ((match_flags & CMD_FIND_WINDOW_BY_NAME) &&
|
||||||
|
fnmatch(searchstr, wl->window->name, 0) == 0) {
|
||||||
|
find_data.list_ctx = xstrdup("");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((match_flags & CMD_FIND_WINDOW_BY_TITLE) &&
|
||||||
|
fnmatch(searchstr, wp->base.title, 0) == 0) {
|
||||||
|
xasprintf(&find_data.list_ctx,
|
||||||
|
"pane %u title: \"%s\"", i - 1, wp->base.title);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_flags & CMD_FIND_WINDOW_BY_CONTENT &&
|
||||||
|
(sres = window_pane_search(wp, str, &line)) != NULL) {
|
||||||
|
xasprintf(&find_data.list_ctx,
|
||||||
|
"pane %u line %u: \"%s\"", i - 1, line + 1, sres);
|
||||||
|
free(sres);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (find_data.list_ctx != NULL) {
|
||||||
|
find_data.wl = wl;
|
||||||
|
find_data.pane_id = i - 1;
|
||||||
|
ARRAY_ADD(find_list, find_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct cmd_find_window_data *cdata;
|
struct window_choose_data *cdata;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl, *wm;
|
struct winlink *wl, *wm;
|
||||||
struct window *w;
|
struct cmd_find_window_data_list find_list;
|
||||||
struct window_pane *wp;
|
char *str, *searchstr;
|
||||||
ARRAY_DECL(, u_int) list_idx;
|
const char *template;
|
||||||
ARRAY_DECL(, char *) list_ctx;
|
u_int i, match_flags;
|
||||||
char *str, *sres, *sctx, *searchstr;
|
|
||||||
u_int i, line;
|
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
s = ctx->curclient->session;
|
s = ctx->curclient->session;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = FIND_WINDOW_TEMPLATE;
|
||||||
|
|
||||||
|
match_flags = cmd_find_window_match_flags(args);
|
||||||
str = args->argv[0];
|
str = args->argv[0];
|
||||||
|
|
||||||
ARRAY_INIT(&list_idx);
|
ARRAY_INIT(&find_list);
|
||||||
ARRAY_INIT(&list_ctx);
|
|
||||||
|
|
||||||
xasprintf(&searchstr, "*%s*", str);
|
xasprintf(&searchstr, "*%s*", str);
|
||||||
RB_FOREACH(wm, winlinks, &s->windows) {
|
RB_FOREACH(wm, winlinks, &s->windows)
|
||||||
i = 0;
|
cmd_find_window_match (&find_list, match_flags, wm, str, searchstr);
|
||||||
TAILQ_FOREACH(wp, &wm->window->panes, entry) {
|
free(searchstr);
|
||||||
i++;
|
|
||||||
|
|
||||||
if (fnmatch(searchstr, wm->window->name, 0) == 0)
|
if (ARRAY_LENGTH(&find_list) == 0) {
|
||||||
sctx = xstrdup("");
|
|
||||||
else {
|
|
||||||
sres = window_pane_search(wp, str, &line);
|
|
||||||
if (sres == NULL &&
|
|
||||||
fnmatch(searchstr, wp->base.title, 0) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (sres == NULL) {
|
|
||||||
xasprintf(&sctx,
|
|
||||||
"pane %u title: \"%s\"", i - 1,
|
|
||||||
wp->base.title);
|
|
||||||
} else {
|
|
||||||
xasprintf(&sctx,
|
|
||||||
"pane %u line %u: \"%s\"", i - 1,
|
|
||||||
line + 1, sres);
|
|
||||||
xfree(sres);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ARRAY_ADD(&list_idx, wm->idx);
|
|
||||||
ARRAY_ADD(&list_ctx, sctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xfree(searchstr);
|
|
||||||
|
|
||||||
if (ARRAY_LENGTH(&list_idx) == 0) {
|
|
||||||
ctx->error(ctx, "no windows matching: %s", str);
|
ctx->error(ctx, "no windows matching: %s", str);
|
||||||
ARRAY_FREE(&list_idx);
|
ARRAY_FREE(&find_list);
|
||||||
ARRAY_FREE(&list_ctx);
|
return (CMD_RETURN_ERROR);
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ARRAY_LENGTH(&list_idx) == 1) {
|
if (ARRAY_LENGTH(&find_list) == 1) {
|
||||||
if (session_select(s, ARRAY_FIRST(&list_idx)) == 0)
|
if (session_select(s, ARRAY_FIRST(&find_list).wl->idx) == 0)
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
goto out;
|
goto out;
|
||||||
@@ -123,54 +177,66 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&list_idx); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&find_list); i++) {
|
||||||
wm = winlink_find_by_index(
|
wm = ARRAY_ITEM(&find_list, i).wl;
|
||||||
&s->windows, ARRAY_ITEM(&list_idx, i));
|
|
||||||
w = wm->window;
|
|
||||||
|
|
||||||
sctx = ARRAY_ITEM(&list_ctx, i);
|
cdata = window_choose_data_create(ctx);
|
||||||
window_choose_add(wl->window->active,
|
cdata->idx = wm->idx;
|
||||||
wm->idx, "%3d: %s [%ux%u] (%u panes) %s", wm->idx, w->name,
|
cdata->client->references++;
|
||||||
w->sx, w->sy, window_count_panes(w), sctx);
|
cdata->wl = wm;
|
||||||
xfree(sctx);
|
|
||||||
|
cdata->ft_template = xstrdup(template);
|
||||||
|
cdata->pane_id = ARRAY_ITEM(&find_list, i).pane_id;
|
||||||
|
|
||||||
|
format_add(cdata->ft, "line", "%u", i);
|
||||||
|
format_add(cdata->ft, "window_find_matches", "%s",
|
||||||
|
ARRAY_ITEM(&find_list, i).list_ctx);
|
||||||
|
format_session(cdata->ft, s);
|
||||||
|
format_winlink(cdata->ft, s, wm);
|
||||||
|
|
||||||
|
window_choose_add(wl->window->active, cdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
|
||||||
cdata->session = s;
|
|
||||||
cdata->session->references++;
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active,
|
window_choose_ready(wl->window->active,
|
||||||
0, cmd_find_window_callback, cmd_find_window_free, cdata);
|
0, cmd_find_window_callback, cmd_find_window_free);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
ARRAY_FREE(&list_idx);
|
ARRAY_FREE(&find_list);
|
||||||
ARRAY_FREE(&list_ctx);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_find_window_callback(void *data, int idx)
|
cmd_find_window_callback(struct window_choose_data *cdata)
|
||||||
{
|
{
|
||||||
struct cmd_find_window_data *cdata = data;
|
struct session *s;
|
||||||
struct session *s = cdata->session;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if (idx == -1)
|
if (cdata == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
s = cdata->session;
|
||||||
if (!session_alive(s))
|
if (!session_alive(s))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (session_select(s, idx) == 0) {
|
wp = window_pane_at_index(cdata->wl->window, cdata->pane_id);
|
||||||
|
if (wp != NULL && window_pane_visible(wp))
|
||||||
|
window_set_active_pane(cdata->wl->window, wp);
|
||||||
|
|
||||||
|
if (session_select(s, cdata->idx) == 0) {
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_find_window_free(void *data)
|
cmd_find_window_free(struct window_choose_data *cdata)
|
||||||
{
|
{
|
||||||
struct cmd_find_window_data *cdata = data;
|
if (cdata == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
cdata->session->references--;
|
cdata->session->references--;
|
||||||
xfree(cdata);
|
|
||||||
|
free(cdata->ft_template);
|
||||||
|
format_free(cdata->ft);
|
||||||
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
* Cause client to report an error and exit with 1 if session doesn't exist.
|
* Cause client to report an error and exit with 1 if session doesn't exist.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_has_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_has_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_has_session_entry = {
|
const struct cmd_entry cmd_has_session_entry = {
|
||||||
"has-session", "has",
|
"has-session", "has",
|
||||||
@@ -36,13 +36,13 @@ const struct cmd_entry cmd_has_session_entry = {
|
|||||||
cmd_has_session_exec
|
cmd_has_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_has_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_has_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
|
|
||||||
if (cmd_find_session(ctx, args_get(args, 't'), 0) == NULL)
|
if (cmd_find_session(ctx, args_get(args, 't'), 0) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,23 +20,24 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Executes a tmux command if a shell command returns true.
|
* Executes a tmux command if a shell command returns true or false.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_if_shell_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_if_shell_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_if_shell_callback(struct job *);
|
void cmd_if_shell_callback(struct job *);
|
||||||
void cmd_if_shell_free(void *);
|
void cmd_if_shell_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_if_shell_entry = {
|
const struct cmd_entry cmd_if_shell_entry = {
|
||||||
"if-shell", "if",
|
"if-shell", "if",
|
||||||
"", 2, 2,
|
"", 2, 3,
|
||||||
"shell-command command",
|
"shell-command command [command]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -44,11 +45,12 @@ const struct cmd_entry cmd_if_shell_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_if_shell_data {
|
struct cmd_if_shell_data {
|
||||||
char *cmd;
|
char *cmd_if;
|
||||||
|
char *cmd_else;
|
||||||
struct cmd_ctx ctx;
|
struct cmd_ctx ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -56,7 +58,11 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
const char *shellcmd = args->argv[0];
|
const char *shellcmd = args->argv[0];
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
cdata->cmd = xstrdup(args->argv[1]);
|
cdata->cmd_if = xstrdup(args->argv[1]);
|
||||||
|
if (args->argc == 3)
|
||||||
|
cdata->cmd_else = xstrdup(args->argv[2]);
|
||||||
|
else
|
||||||
|
cdata->cmd_else = NULL;
|
||||||
memcpy(&cdata->ctx, ctx, sizeof cdata->ctx);
|
memcpy(&cdata->ctx, ctx, sizeof cdata->ctx);
|
||||||
|
|
||||||
if (ctx->cmdclient != NULL)
|
if (ctx->cmdclient != NULL)
|
||||||
@@ -66,7 +72,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
job_run(shellcmd, cmd_if_shell_callback, cmd_if_shell_free, cdata);
|
job_run(shellcmd, cmd_if_shell_callback, cmd_if_shell_free, cdata);
|
||||||
|
|
||||||
return (1); /* don't let client exit */
|
return (CMD_RETURN_YIELD); /* don't let client exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -75,15 +81,18 @@ cmd_if_shell_callback(struct job *job)
|
|||||||
struct cmd_if_shell_data *cdata = job->data;
|
struct cmd_if_shell_data *cdata = job->data;
|
||||||
struct cmd_ctx *ctx = &cdata->ctx;
|
struct cmd_ctx *ctx = &cdata->ctx;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
char *cause;
|
char *cause, *cmd;
|
||||||
|
|
||||||
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0)
|
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0) {
|
||||||
return;
|
cmd = cdata->cmd_else;
|
||||||
|
if (cmd == NULL)
|
||||||
if (cmd_string_parse(cdata->cmd, &cmdlist, &cause) != 0) {
|
return;
|
||||||
|
} else
|
||||||
|
cmd = cdata->cmd_if;
|
||||||
|
if (cmd_string_parse(cmd, &cmdlist, &cause) != 0) {
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "%s", cause);
|
ctx->error(ctx, "%s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -97,16 +106,15 @@ cmd_if_shell_free(void *data)
|
|||||||
{
|
{
|
||||||
struct cmd_if_shell_data *cdata = data;
|
struct cmd_if_shell_data *cdata = data;
|
||||||
struct cmd_ctx *ctx = &cdata->ctx;
|
struct cmd_ctx *ctx = &cdata->ctx;
|
||||||
struct msg_exit_data exitdata;
|
|
||||||
|
|
||||||
if (ctx->cmdclient != NULL) {
|
if (ctx->cmdclient != NULL) {
|
||||||
ctx->cmdclient->references--;
|
ctx->cmdclient->references--;
|
||||||
exitdata.retcode = ctx->cmdclient->retcode;
|
|
||||||
ctx->cmdclient->flags |= CLIENT_EXIT;
|
ctx->cmdclient->flags |= CLIENT_EXIT;
|
||||||
}
|
}
|
||||||
if (ctx->curclient != NULL)
|
if (ctx->curclient != NULL)
|
||||||
ctx->curclient->references--;
|
ctx->curclient->references--;
|
||||||
|
|
||||||
xfree(cdata->cmd);
|
free(cdata->cmd_else);
|
||||||
xfree(cdata);
|
free(cdata->cmd_if);
|
||||||
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
* Copyright (c) 2011 George Nachman <tmux@georgester.com>
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
@@ -24,22 +25,34 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Join a pane into another (like split/swap/kill).
|
* Join or move a pane into another (like split/swap/kill).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_join_pane_key_binding(struct cmd *, int);
|
void cmd_join_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_join_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
enum cmd_retval join_pane(struct cmd *, struct cmd_ctx *, int);
|
||||||
|
|
||||||
const struct cmd_entry cmd_join_pane_entry = {
|
const struct cmd_entry cmd_join_pane_entry = {
|
||||||
"join-pane", "joinp",
|
"join-pane", "joinp",
|
||||||
"dhvp:l:s:t:", 0, 0,
|
"bdhvp:l:s:t:", 0, 0,
|
||||||
"[-dhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
"[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
||||||
0,
|
0,
|
||||||
cmd_join_pane_key_binding,
|
cmd_join_pane_key_binding,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_join_pane_exec
|
cmd_join_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_move_pane_entry = {
|
||||||
|
"move-pane", "movep",
|
||||||
|
"bdhvp:l:s:t:", 0, 0,
|
||||||
|
"[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_join_pane_exec
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_join_pane_key_binding(struct cmd *self, int key)
|
cmd_join_pane_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
@@ -54,8 +67,14 @@ cmd_join_pane_key_binding(struct cmd *self, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
return (join_pane(self, ctx, self->entry == &cmd_join_pane_entry));
|
||||||
|
}
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *dst_s;
|
struct session *dst_s;
|
||||||
@@ -69,18 +88,22 @@ cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
dst_wl = cmd_find_pane(ctx, args_get(args, 't'), &dst_s, &dst_wp);
|
dst_wl = cmd_find_pane(ctx, args_get(args, 't'), &dst_s, &dst_wp);
|
||||||
if (dst_wl == NULL)
|
if (dst_wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
dst_w = dst_wl->window;
|
dst_w = dst_wl->window;
|
||||||
dst_idx = dst_wl->idx;
|
dst_idx = dst_wl->idx;
|
||||||
|
|
||||||
src_wl = cmd_find_pane(ctx, args_get(args, 's'), NULL, &src_wp);
|
src_wl = cmd_find_pane(ctx, args_get(args, 's'), NULL, &src_wp);
|
||||||
if (src_wl == NULL)
|
if (src_wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
src_w = src_wl->window;
|
src_w = src_wl->window;
|
||||||
|
|
||||||
if (src_w == dst_w) {
|
if (not_same_window && src_w == dst_w) {
|
||||||
ctx->error(ctx, "can't join a pane to its own window");
|
ctx->error(ctx, "can't join a pane to its own window");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (!not_same_window && src_wp == dst_wp) {
|
||||||
|
ctx->error(ctx, "source and target panes must be different");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
type = LAYOUT_TOPBOTTOM;
|
type = LAYOUT_TOPBOTTOM;
|
||||||
@@ -92,25 +115,25 @@ cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "size %s", cause);
|
ctx->error(ctx, "size %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'p')) {
|
} else if (args_has(args, 'p')) {
|
||||||
percentage = args_strtonum(args, 'p', 0, 100, &cause);
|
percentage = args_strtonum(args, 'p', 0, 100, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "percentage %s", cause);
|
ctx->error(ctx, "percentage %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (type == LAYOUT_TOPBOTTOM)
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
size = (dst_wp->sy * percentage) / 100;
|
size = (dst_wp->sy * percentage) / 100;
|
||||||
else
|
else
|
||||||
size = (dst_wp->sx * percentage) / 100;
|
size = (dst_wp->sx * percentage) / 100;
|
||||||
}
|
}
|
||||||
|
lc = layout_split_pane(dst_wp, type, size, args_has(args, 'b'));
|
||||||
if ((lc = layout_split_pane(dst_wp, type, size)) == NULL) {
|
if (lc == NULL) {
|
||||||
ctx->error(ctx, "create pane failed: pane too small");
|
ctx->error(ctx, "create pane failed: pane too small");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout_close_pane(src_wp);
|
layout_close_pane(src_wp);
|
||||||
@@ -124,6 +147,8 @@ cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (window_count_panes(src_w) == 0)
|
if (window_count_panes(src_w) == 0)
|
||||||
server_kill_window(src_w);
|
server_kill_window(src_w);
|
||||||
|
else
|
||||||
|
notify_window_layout_changed(src_w);
|
||||||
|
|
||||||
src_wp->window = dst_w;
|
src_wp->window = dst_w;
|
||||||
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
||||||
@@ -141,5 +166,6 @@ cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
} else
|
} else
|
||||||
server_status_session(dst_s);
|
server_status_session(dst_s);
|
||||||
|
|
||||||
return (0);
|
notify_window_layout_changed(dst_w);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
* Kill pane.
|
* Kill pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_pane_entry = {
|
const struct cmd_entry cmd_kill_pane_entry = {
|
||||||
"kill-pane", "killp",
|
"kill-pane", "killp",
|
||||||
@@ -38,32 +38,29 @@ const struct cmd_entry cmd_kill_pane_entry = {
|
|||||||
cmd_kill_pane_exec
|
cmd_kill_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window_pane *loopwp, *nextwp, *wp;
|
struct window_pane *loopwp, *tmpwp, *wp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_count_panes(wl->window) == 1) {
|
if (window_count_panes(wl->window) == 1) {
|
||||||
/* Only one pane, kill the window. */
|
/* Only one pane, kill the window. */
|
||||||
server_kill_window(wl->window);
|
server_kill_window(wl->window);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'a')) {
|
if (args_has(self->args, 'a')) {
|
||||||
loopwp = TAILQ_FIRST(&wl->window->panes);
|
TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) {
|
||||||
while (loopwp != NULL) {
|
if (loopwp == wp)
|
||||||
nextwp = TAILQ_NEXT(loopwp, entry);
|
continue;
|
||||||
if (loopwp != wp) {
|
layout_close_pane(loopwp);
|
||||||
layout_close_pane(loopwp);
|
window_remove_pane(wl->window, loopwp);
|
||||||
window_remove_pane(wl->window, loopwp);
|
|
||||||
}
|
|
||||||
loopwp = nextwp;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
layout_close_pane(wp);
|
layout_close_pane(wp);
|
||||||
@@ -71,5 +68,5 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
* Kill the server and do nothing else.
|
* Kill the server and do nothing else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_server_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_server_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_server_entry = {
|
const struct cmd_entry cmd_kill_server_entry = {
|
||||||
"kill-server", NULL,
|
"kill-server", NULL,
|
||||||
@@ -40,10 +40,10 @@ const struct cmd_entry cmd_kill_server_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_kill_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_kill_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
kill(getpid(), SIGTERM);
|
kill(getpid(), SIGTERM);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,29 +27,37 @@
|
|||||||
* Note this deliberately has no alias to make it hard to hit by accident.
|
* Note this deliberately has no alias to make it hard to hit by accident.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_session_entry = {
|
const struct cmd_entry cmd_kill_session_entry = {
|
||||||
"kill-session", NULL,
|
"kill-session", NULL,
|
||||||
"t:", 0, 0,
|
"at:", 0, 0,
|
||||||
CMD_TARGET_SESSION_USAGE,
|
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_kill_session_exec
|
cmd_kill_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_kill_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s, *s2, *s3;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
server_destroy_session(s);
|
if (args_has(args, 'a')) {
|
||||||
session_destroy(s);
|
RB_FOREACH_SAFE(s2, sessions, &sessions, s3) {
|
||||||
|
if (s != s2) {
|
||||||
return (0);
|
server_destroy_session(s2);
|
||||||
|
session_destroy(s2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
server_destroy_session(s);
|
||||||
|
session_destroy(s);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,29 +24,36 @@
|
|||||||
* Destroy window.
|
* Destroy window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_window_entry = {
|
const struct cmd_entry cmd_kill_window_entry = {
|
||||||
"kill-window", "killw",
|
"kill-window", "killw",
|
||||||
"t:", 0, 0,
|
"at:", 0, 0,
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"[-a] " CMD_TARGET_WINDOW_USAGE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_kill_window_exec
|
cmd_kill_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl, *wl2, *wl3;
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if (args_has(args, 'a')) {
|
||||||
|
RB_FOREACH_SAFE(wl2, winlinks, &s->windows, wl3) {
|
||||||
|
if (wl != wl2)
|
||||||
|
server_kill_window(wl2->window);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
server_kill_window(wl->window);
|
||||||
|
|
||||||
server_kill_window(wl->window);
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
* Link a window into another session.
|
* Link a window into another session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_link_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_link_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_link_window_entry = {
|
const struct cmd_entry cmd_link_window_entry = {
|
||||||
"link-window", "linkw",
|
"link-window", "linkw",
|
||||||
@@ -38,7 +38,7 @@ const struct cmd_entry cmd_link_window_entry = {
|
|||||||
cmd_link_window_exec
|
cmd_link_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -48,18 +48,18 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
int idx, kflag, dflag;
|
int idx, kflag, dflag;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 's'), &src)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 's'), &src)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &dst)) == -2)
|
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &dst)) == -2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
kflag = args_has(self->args, 'k');
|
kflag = args_has(self->args, 'k');
|
||||||
dflag = args_has(self->args, 'd');
|
dflag = args_has(self->args, 'd');
|
||||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||||
ctx->error(ctx, "can't link window: %s", cause);
|
ctx->error(ctx, "can't link window: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,12 +27,12 @@
|
|||||||
* List paste buffers.
|
* List paste buffers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_buffers_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_buffers_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_buffers_entry = {
|
const struct cmd_entry cmd_list_buffers_entry = {
|
||||||
"list-buffers", "lsb",
|
"list-buffers", "lsb",
|
||||||
"", 0, 0,
|
"F:", 0, 0,
|
||||||
"",
|
"[-F format]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -39,20 +40,31 @@ const struct cmd_entry cmd_list_buffers_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_buffers_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_buffers_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
|
struct format_tree *ft;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
char *tmp;
|
char *line;
|
||||||
|
const char *template;
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = LIST_BUFFERS_TEMPLATE;
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
|
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
|
||||||
tmp = paste_print(pb, 50);
|
ft = format_create();
|
||||||
ctx->print(ctx,
|
format_add(ft, "line", "%u", idx - 1);
|
||||||
"%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp);
|
format_paste_buffer(ft, pb);
|
||||||
xfree(tmp);
|
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
ctx->print(ctx, "%s", line);
|
||||||
|
free(line);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -31,47 +32,55 @@ int cmd_list_clients_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_list_clients_entry = {
|
const struct cmd_entry cmd_list_clients_entry = {
|
||||||
"list-clients", "lsc",
|
"list-clients", "lsc",
|
||||||
"t:", 0, 0,
|
"F:t:", 0, 0,
|
||||||
CMD_TARGET_SESSION_USAGE,
|
"[-F format] " CMD_TARGET_SESSION_USAGE,
|
||||||
0,
|
CMD_READONLY,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_list_clients_exec
|
cmd_list_clients_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
u_int i;
|
struct format_tree *ft;
|
||||||
const char *s_utf8;
|
const char *template;
|
||||||
|
u_int i;
|
||||||
|
char *line;
|
||||||
|
|
||||||
if (args_has(args, 't')) {
|
if (args_has(args, 't')) {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
} else
|
} else
|
||||||
s = NULL;
|
s = NULL;
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = LIST_CLIENTS_TEMPLATE;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
if (c == NULL || c->session == NULL)
|
if (c == NULL || c->session == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (c->tty.flags & TTY_UTF8)
|
|
||||||
s_utf8 = " (utf8)";
|
|
||||||
else
|
|
||||||
s_utf8 = "";
|
|
||||||
|
|
||||||
if (s != NULL && s != c->session)
|
if (s != NULL && s != c->session)
|
||||||
continue;
|
continue;
|
||||||
ctx->print(ctx, "%s: %s [%ux%u %s]%s", c->tty.path,
|
|
||||||
c->session->name, c->tty.sx, c->tty.sy,
|
ft = format_create();
|
||||||
c->tty.termname, s_utf8);
|
format_add(ft, "line", "%u", i);
|
||||||
|
format_session(ft, c->session);
|
||||||
|
format_client(ft, c);
|
||||||
|
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
ctx->print(ctx, "%s", line);
|
||||||
|
free(line);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
* List all commands with usages.
|
* List all commands with usages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_commands_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_commands_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_commands_entry = {
|
const struct cmd_entry cmd_list_commands_entry = {
|
||||||
"list-commands", "lscm",
|
"list-commands", "lscm",
|
||||||
@@ -37,7 +37,7 @@ const struct cmd_entry cmd_list_commands_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
const struct cmd_entry **entryp;
|
const struct cmd_entry **entryp;
|
||||||
@@ -45,5 +45,5 @@ cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
for (entryp = cmd_table; *entryp != NULL; entryp++)
|
for (entryp = cmd_table; *entryp != NULL; entryp++)
|
||||||
ctx->print(ctx, "%s %s", (*entryp)->name, (*entryp)->usage);
|
ctx->print(ctx, "%s %s", (*entryp)->name, (*entryp)->usage);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,8 @@
|
|||||||
* List key bindings.
|
* List key bindings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_keys_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
enum cmd_retval cmd_list_keys_table(struct cmd *, struct cmd_ctx *);
|
||||||
int cmd_list_keys_table(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_keys_entry = {
|
const struct cmd_entry cmd_list_keys_entry = {
|
||||||
"list-keys", "lsk",
|
"list-keys", "lsk",
|
||||||
@@ -40,7 +39,7 @@ const struct cmd_entry cmd_list_keys_entry = {
|
|||||||
cmd_list_keys_exec
|
cmd_list_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -54,9 +53,8 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (cmd_list_keys_table(self, ctx));
|
return (cmd_list_keys_table(self, ctx));
|
||||||
|
|
||||||
width = 0;
|
width = 0;
|
||||||
*flags = '\0';
|
|
||||||
|
|
||||||
SPLAY_FOREACH(bd, key_bindings, &key_bindings) {
|
RB_FOREACH(bd, key_bindings, &key_bindings) {
|
||||||
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
continue;
|
continue;
|
||||||
@@ -73,11 +71,12 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
width = keywidth;
|
width = keywidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPLAY_FOREACH(bd, key_bindings, &key_bindings) {
|
RB_FOREACH(bd, key_bindings, &key_bindings) {
|
||||||
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
*flags = '\0';
|
||||||
if (!(bd->key & KEYC_PREFIX)) {
|
if (!(bd->key & KEYC_PREFIX)) {
|
||||||
if (bd->can_repeat)
|
if (bd->can_repeat)
|
||||||
xsnprintf(flags, sizeof flags, "-rn ");
|
xsnprintf(flags, sizeof flags, "-rn ");
|
||||||
@@ -95,7 +94,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->print(ctx, "bind-key %s", tmp);
|
ctx->print(ctx, "bind-key %s", tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -111,12 +110,12 @@ cmd_list_keys_table(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
tablename = args_get(args, 't');
|
tablename = args_get(args, 't');
|
||||||
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
||||||
ctx->error(ctx, "unknown key table: %s", tablename);
|
ctx->error(ctx, "unknown key table: %s", tablename);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
width = 0;
|
width = 0;
|
||||||
any_mode = 0;
|
any_mode = 0;
|
||||||
SPLAY_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
||||||
key = key_string_lookup_key(mbind->key);
|
key = key_string_lookup_key(mbind->key);
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
continue;
|
continue;
|
||||||
@@ -129,7 +128,7 @@ cmd_list_keys_table(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
width = keywidth;
|
width = keywidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPLAY_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
||||||
key = key_string_lookup_key(mbind->key);
|
key = key_string_lookup_key(mbind->key);
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
continue;
|
continue;
|
||||||
@@ -145,5 +144,5 @@ cmd_list_keys_table(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
117
cmd-list-panes.c
117
cmd-list-panes.c
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,24 +27,25 @@
|
|||||||
* List panes on given window.
|
* List panes on given window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_panes_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_panes_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_list_panes_server(struct cmd_ctx *);
|
void cmd_list_panes_server(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_list_panes_session(struct session *, struct cmd_ctx *, int);
|
void cmd_list_panes_session(
|
||||||
void cmd_list_panes_window(
|
struct cmd *, struct session *, struct cmd_ctx *, int);
|
||||||
|
void cmd_list_panes_window(struct cmd *,
|
||||||
struct session *, struct winlink *, struct cmd_ctx *, int);
|
struct session *, struct winlink *, struct cmd_ctx *, int);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_panes_entry = {
|
const struct cmd_entry cmd_list_panes_entry = {
|
||||||
"list-panes", "lsp",
|
"list-panes", "lsp",
|
||||||
"ast:", 0, 0,
|
"asF:t:", 0, 0,
|
||||||
"[-as] [-t target]",
|
"[-as] [-F format] [-t target]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_list_panes_exec
|
cmd_list_panes_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -51,87 +53,92 @@ cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
|
||||||
if (args_has(args, 'a'))
|
if (args_has(args, 'a'))
|
||||||
cmd_list_panes_server(ctx);
|
cmd_list_panes_server(self, ctx);
|
||||||
else if (args_has(args, 's')) {
|
else if (args_has(args, 's')) {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
cmd_list_panes_session(s, ctx, 1);
|
cmd_list_panes_session(self, s, ctx, 1);
|
||||||
} else {
|
} else {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
cmd_list_panes_window(s, wl, ctx, 0);
|
cmd_list_panes_window(self, s, wl, ctx, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_list_panes_server(struct cmd_ctx *ctx)
|
cmd_list_panes_server(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
RB_FOREACH(s, sessions, &sessions)
|
RB_FOREACH(s, sessions, &sessions)
|
||||||
cmd_list_panes_session(s, ctx, 2);
|
cmd_list_panes_session(self, s, ctx, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_list_panes_session(struct session *s, struct cmd_ctx *ctx, int type)
|
cmd_list_panes_session(
|
||||||
|
struct cmd *self, struct session *s, struct cmd_ctx *ctx, int type)
|
||||||
{
|
{
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
|
||||||
RB_FOREACH(wl, winlinks, &s->windows)
|
RB_FOREACH(wl, winlinks, &s->windows)
|
||||||
cmd_list_panes_window(s, wl, ctx, type);
|
cmd_list_panes_window(self, s, wl, ctx, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_list_panes_window(
|
cmd_list_panes_window(struct cmd *self,
|
||||||
struct session *s, struct winlink *wl, struct cmd_ctx *ctx, int type)
|
struct session *s, struct winlink *wl, struct cmd_ctx *ctx, int type)
|
||||||
{
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct grid *gd;
|
u_int n;
|
||||||
struct grid_line *gl;
|
struct format_tree *ft;
|
||||||
u_int i, n;
|
const char *template;
|
||||||
unsigned long long size;
|
char *line;
|
||||||
|
|
||||||
|
template = args_get(args, 'F');
|
||||||
|
if (template == NULL) {
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
template = "#{pane_index}: "
|
||||||
|
"[#{pane_width}x#{pane_height}] [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 "
|
||||||
|
"#{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}, "
|
||||||
|
"#{history_bytes} bytes] #{pane_id}"
|
||||||
|
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||||
gd = wp->base.grid;
|
ft = format_create();
|
||||||
|
format_add(ft, "line", "%u", n);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, wp);
|
||||||
|
|
||||||
size = 0;
|
line = format_expand(ft, template);
|
||||||
for (i = 0; i < gd->hsize; i++) {
|
ctx->print(ctx, "%s", line);
|
||||||
gl = &gd->linedata[i];
|
free(line);
|
||||||
size += gl->cellsize * sizeof *gl->celldata;
|
|
||||||
size += gl->utf8size * sizeof *gl->utf8data;
|
|
||||||
}
|
|
||||||
size += gd->hsize * sizeof *gd->linedata;
|
|
||||||
|
|
||||||
switch (type) {
|
format_free(ft);
|
||||||
case 0:
|
|
||||||
ctx->print(ctx,
|
|
||||||
"%u: [%ux%u] [history %u/%u, %llu bytes] %%%u%s%s",
|
|
||||||
n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size,
|
|
||||||
wp->id, wp == wp->window->active ? " (active)" : "",
|
|
||||||
wp->fd == -1 ? " (dead)" : "");
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
ctx->print(ctx,
|
|
||||||
"%d.%u: [%ux%u] [history %u/%u, %llu bytes] "
|
|
||||||
"%%%u%s%s", wl->idx,
|
|
||||||
n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size,
|
|
||||||
wp->id, wp == wp->window->active ? " (active)" : "",
|
|
||||||
wp->fd == -1 ? " (dead)" : "");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
ctx->print(ctx,
|
|
||||||
"%s:%d.%u: [%ux%u] [history %u/%u, %llu bytes] "
|
|
||||||
"%%%u%s%s", s->name, wl->idx,
|
|
||||||
n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size,
|
|
||||||
wp->id, wp == wp->window->active ? " (active)" : "",
|
|
||||||
wp->fd == -1 ? " (dead)" : "");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -27,45 +28,44 @@
|
|||||||
* List all sessions.
|
* List all sessions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_sessions_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_sessions_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_sessions_entry = {
|
const struct cmd_entry cmd_list_sessions_entry = {
|
||||||
"list-sessions", "ls",
|
"list-sessions", "ls",
|
||||||
"", 0, 0,
|
"F:", 0, 0,
|
||||||
"",
|
"[-F format]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_list_sessions_exec
|
cmd_list_sessions_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
enum cmd_retval
|
||||||
int
|
cmd_list_sessions_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
cmd_list_sessions_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct session_group *sg;
|
u_int n;
|
||||||
char *tim, tmp[64];
|
struct format_tree *ft;
|
||||||
u_int idx;
|
const char *template;
|
||||||
time_t t;
|
char *line;
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = LIST_SESSIONS_TEMPLATE;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
sg = session_group_find(s);
|
ft = format_create();
|
||||||
if (sg == NULL)
|
format_add(ft, "line", "%u", n);
|
||||||
*tmp = '\0';
|
format_session(ft, s);
|
||||||
else {
|
|
||||||
idx = session_group_index(sg);
|
|
||||||
xsnprintf(tmp, sizeof tmp, " (group %u)", idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
t = s->creation_time.tv_sec;
|
line = format_expand(ft, template);
|
||||||
tim = ctime(&t);
|
ctx->print(ctx, "%s", line);
|
||||||
*strchr(tim, '\n') = '\0';
|
free(line);
|
||||||
|
|
||||||
ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]%s%s",
|
format_free(ft);
|
||||||
s->name, winlink_count(&s->windows), tim, s->sx, s->sy,
|
n++;
|
||||||
tmp, s->flags & SESSION_UNATTACHED ? "" : " (attached)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,67 +27,84 @@
|
|||||||
* List windows on given session.
|
* List windows on given session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_windows_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_list_windows_server(struct cmd_ctx *);
|
void cmd_list_windows_server(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_list_windows_session(struct session *, struct cmd_ctx *, int);
|
void cmd_list_windows_session(
|
||||||
|
struct cmd *, struct session *, struct cmd_ctx *, int);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_windows_entry = {
|
const struct cmd_entry cmd_list_windows_entry = {
|
||||||
"list-windows", "lsw",
|
"list-windows", "lsw",
|
||||||
"at:", 0, 0,
|
"F:at:", 0, 0,
|
||||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
"[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_list_windows_exec
|
cmd_list_windows_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
if (args_has(args, 'a'))
|
if (args_has(args, 'a'))
|
||||||
cmd_list_windows_server(ctx);
|
cmd_list_windows_server(self, ctx);
|
||||||
else {
|
else {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
cmd_list_windows_session(s, ctx, 0);
|
cmd_list_windows_session(self, s, ctx, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_list_windows_server(struct cmd_ctx *ctx)
|
cmd_list_windows_server(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
RB_FOREACH(s, sessions, &sessions)
|
RB_FOREACH(s, sessions, &sessions)
|
||||||
cmd_list_windows_session(s, ctx, 1);
|
cmd_list_windows_session(self, s, ctx, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_list_windows_session(struct session *s, struct cmd_ctx *ctx, int type)
|
cmd_list_windows_session(
|
||||||
|
struct cmd *self, struct session *s, struct cmd_ctx *ctx, int type)
|
||||||
{
|
{
|
||||||
struct winlink *wl;
|
struct args *args = self->args;
|
||||||
char *layout;
|
struct winlink *wl;
|
||||||
|
u_int n;
|
||||||
|
struct format_tree *ft;
|
||||||
|
const char *template;
|
||||||
|
char *line;
|
||||||
|
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
template = args_get(args, 'F');
|
||||||
layout = layout_dump(wl->window);
|
if (template == NULL) {
|
||||||
if (type) {
|
switch (type) {
|
||||||
ctx->print(ctx, "%s:%d: %s [%ux%u] [layout %s]%s",
|
case 0:
|
||||||
s->name, wl->idx, wl->window->name, wl->window->sx,
|
template = LIST_WINDOWS_TEMPLATE;
|
||||||
wl->window->sy, layout,
|
break;
|
||||||
wl == s->curw ? " (active)" : "");
|
case 1:
|
||||||
} else {
|
template = LIST_WINDOWS_WITH_SESSION_TEMPLATE;
|
||||||
ctx->print(ctx, "%d: %s [%ux%u] [layout %s]%s",
|
break;
|
||||||
wl->idx, wl->window->name, wl->window->sx,
|
|
||||||
wl->window->sy, layout,
|
|
||||||
wl == s->curw ? " (active)" : "");
|
|
||||||
}
|
}
|
||||||
xfree(layout);
|
}
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
|
ft = format_create();
|
||||||
|
format_add(ft, "line", "%u", n);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
ctx->print(ctx, "%s", line);
|
||||||
|
free(line);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
49
cmd-list.c
49
cmd-list.c
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -78,28 +79,39 @@ bad:
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
|
cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
|
struct client *c = ctx->curclient;
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
int n, retval;
|
enum cmd_retval retval;
|
||||||
|
int guards, n;
|
||||||
|
|
||||||
|
guards = 0;
|
||||||
|
if (c != NULL && c->session != NULL)
|
||||||
|
guards = c->flags & CLIENT_CONTROL;
|
||||||
|
|
||||||
|
notify_disable();
|
||||||
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||||
if ((n = cmd_exec(cmd, ctx)) == -1)
|
if (guards)
|
||||||
return (-1);
|
ctx->print(ctx, "%%begin");
|
||||||
|
n = cmd_exec(cmd, ctx);
|
||||||
|
if (guards)
|
||||||
|
ctx->print(ctx, "%%end");
|
||||||
|
|
||||||
/*
|
switch (n)
|
||||||
* A 1 return value means the command client is being attached
|
{
|
||||||
* (sent MSG_READY).
|
case CMD_RETURN_ERROR:
|
||||||
*/
|
return (CMD_RETURN_ERROR);
|
||||||
if (n == 1) {
|
case CMD_RETURN_ATTACH:
|
||||||
retval = 1;
|
/* Client is being attached (send MSG_READY). */
|
||||||
|
retval = CMD_RETURN_ATTACH;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The command client has been attached, so mangle the
|
* Mangle the context to treat any following commands
|
||||||
* context to treat any following commands as if they
|
* as if they were called from inside.
|
||||||
* were called from inside.
|
|
||||||
*/
|
*/
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->curclient = ctx->cmdclient;
|
ctx->curclient = ctx->cmdclient;
|
||||||
@@ -109,8 +121,17 @@ cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
|
|||||||
ctx->print = key_bindings_print;
|
ctx->print = key_bindings_print;
|
||||||
ctx->info = key_bindings_info;
|
ctx->info = key_bindings_info;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case CMD_RETURN_YIELD:
|
||||||
|
if (retval == CMD_RETURN_NORMAL)
|
||||||
|
retval = CMD_RETURN_YIELD;
|
||||||
|
break;
|
||||||
|
case CMD_RETURN_NORMAL:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notify_enable();
|
||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +148,7 @@ cmd_list_free(struct cmd_list *cmdlist)
|
|||||||
TAILQ_REMOVE(&cmdlist->list, cmd, qentry);
|
TAILQ_REMOVE(&cmdlist->list, cmd, qentry);
|
||||||
cmd_free(cmd);
|
cmd_free(cmd);
|
||||||
}
|
}
|
||||||
xfree(cmdlist);
|
free(cmdlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
|
|||||||
@@ -27,11 +27,11 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loads a session paste buffer from a file.
|
* Loads a paste buffer from a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_load_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_load_buffer_callback(struct client *, void *);
|
void cmd_load_buffer_callback(struct client *, int, void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_load_buffer_entry = {
|
const struct cmd_entry cmd_load_buffer_entry = {
|
||||||
"load-buffer", "loadb",
|
"load-buffer", "loadb",
|
||||||
@@ -43,18 +43,18 @@ const struct cmd_entry cmd_load_buffer_entry = {
|
|||||||
cmd_load_buffer_exec
|
cmd_load_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c = ctx->cmdclient;
|
struct client *c = ctx->cmdclient;
|
||||||
|
struct session *s;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
const char *path;
|
const char *path, *newpath, *wd;
|
||||||
char *pdata, *new_pdata, *cause;
|
char *pdata, *new_pdata, *cause;
|
||||||
size_t psize;
|
size_t psize;
|
||||||
u_int limit;
|
u_int limit;
|
||||||
int ch, buffer;
|
int ch, error, buffer, *buffer_ptr;
|
||||||
int *buffer_ptr;
|
|
||||||
|
|
||||||
if (!args_has(args, 'b'))
|
if (!args_has(args, 'b'))
|
||||||
buffer = -1;
|
buffer = -1;
|
||||||
@@ -62,40 +62,42 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path = args->argv[0];
|
path = args->argv[0];
|
||||||
if (strcmp(path, "-") == 0) {
|
if (strcmp(path, "-") == 0) {
|
||||||
if (c == NULL) {
|
|
||||||
ctx->error(ctx, "%s: can't read from stdin", path);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (c->flags & CLIENT_TERMINAL) {
|
|
||||||
ctx->error(ctx, "%s: stdin is a tty", path);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (c->stdin_fd == -1) {
|
|
||||||
ctx->error(ctx, "%s: can't read from stdin", path);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer_ptr = xmalloc(sizeof *buffer_ptr);
|
buffer_ptr = xmalloc(sizeof *buffer_ptr);
|
||||||
*buffer_ptr = buffer;
|
*buffer_ptr = buffer;
|
||||||
|
|
||||||
c->stdin_data = buffer_ptr;
|
error = server_set_stdin_callback (c, cmd_load_buffer_callback,
|
||||||
c->stdin_callback = cmd_load_buffer_callback;
|
buffer_ptr, &cause);
|
||||||
|
if (error != 0) {
|
||||||
c->references++;
|
ctx->error(ctx, "%s: %s", path, cause);
|
||||||
bufferevent_enable(c->stdin_event, EV_READ);
|
free(cause);
|
||||||
return (1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_YIELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c != NULL)
|
||||||
|
wd = c->cwd;
|
||||||
|
else if ((s = cmd_current_session(ctx, 0)) != NULL) {
|
||||||
|
wd = options_get_string(&s->options, "default-path");
|
||||||
|
if (*wd == '\0')
|
||||||
|
wd = s->cwd;
|
||||||
|
} else
|
||||||
|
wd = NULL;
|
||||||
|
if (wd != NULL && *wd != '\0') {
|
||||||
|
newpath = get_full_path(wd, path);
|
||||||
|
if (newpath != NULL)
|
||||||
|
path = newpath;
|
||||||
|
}
|
||||||
if ((f = fopen(path, "rb")) == NULL) {
|
if ((f = fopen(path, "rb")) == NULL) {
|
||||||
ctx->error(ctx, "%s: %s", path, strerror(errno));
|
ctx->error(ctx, "%s: %s", path, strerror(errno));
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
pdata = NULL;
|
pdata = NULL;
|
||||||
@@ -121,54 +123,55 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
limit = options_get_number(&global_options, "buffer-limit");
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
if (buffer == -1) {
|
if (buffer == -1) {
|
||||||
paste_add(&global_buffers, pdata, psize, limit);
|
paste_add(&global_buffers, pdata, psize, limit);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
return (-1);
|
free(pdata);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (pdata != NULL)
|
free(pdata);
|
||||||
xfree(pdata);
|
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_load_buffer_callback(struct client *c, void *data)
|
cmd_load_buffer_callback(struct client *c, int closed, void *data)
|
||||||
{
|
{
|
||||||
int *buffer = data;
|
int *buffer = data;
|
||||||
char *pdata;
|
char *pdata;
|
||||||
size_t psize;
|
size_t psize;
|
||||||
u_int limit;
|
u_int limit;
|
||||||
|
|
||||||
/*
|
if (!closed)
|
||||||
* Event callback has already checked client is not dead and reduced
|
return;
|
||||||
* its reference count. But tell it to exit.
|
c->stdin_callback = NULL;
|
||||||
*/
|
|
||||||
|
c->references--;
|
||||||
c->flags |= CLIENT_EXIT;
|
c->flags |= CLIENT_EXIT;
|
||||||
|
|
||||||
psize = EVBUFFER_LENGTH(c->stdin_event->input);
|
psize = EVBUFFER_LENGTH(c->stdin_data);
|
||||||
if (psize == 0 || (pdata = malloc(psize + 1)) == NULL) {
|
if (psize == 0 || (pdata = malloc(psize + 1)) == NULL) {
|
||||||
xfree(data);
|
free(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bufferevent_read(c->stdin_event, pdata, psize);
|
memcpy(pdata, EVBUFFER_DATA(c->stdin_data), psize);
|
||||||
pdata[psize] = '\0';
|
pdata[psize] = '\0';
|
||||||
|
evbuffer_drain(c->stdin_data, psize);
|
||||||
|
|
||||||
limit = options_get_number(&global_options, "buffer-limit");
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
if (*buffer == -1)
|
if (*buffer == -1)
|
||||||
paste_add(&global_buffers, pdata, psize, limit);
|
paste_add(&global_buffers, pdata, psize, limit);
|
||||||
else if (paste_replace(&global_buffers, *buffer, pdata, psize) != 0) {
|
else if (paste_replace(&global_buffers, *buffer, pdata, psize) != 0) {
|
||||||
/* No context so can't use server_client_msg_error. */
|
/* No context so can't use server_client_msg_error. */
|
||||||
evbuffer_add_printf(
|
evbuffer_add_printf(c->stderr_data, "no buffer %d\n", *buffer);
|
||||||
c->stderr_event->output, "no buffer %d\n", *buffer);
|
server_push_stderr(c);
|
||||||
bufferevent_enable(c->stderr_event, EV_WRITE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
* Lock commands.
|
* Lock commands.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_lock_server_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_lock_server_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_lock_server_entry = {
|
const struct cmd_entry cmd_lock_server_entry = {
|
||||||
"lock-server", "lock",
|
"lock-server", "lock",
|
||||||
@@ -61,7 +61,7 @@ const struct cmd_entry cmd_lock_client_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_lock_server_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_lock_server_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -72,14 +72,14 @@ cmd_lock_server_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
|||||||
server_lock();
|
server_lock();
|
||||||
else if (self->entry == &cmd_lock_session_entry) {
|
else if (self->entry == &cmd_lock_session_entry) {
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
server_lock_session(s);
|
server_lock_session(s);
|
||||||
} else {
|
} else {
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
server_lock_client(c);
|
server_lock_client(c);
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,41 +26,51 @@
|
|||||||
* Move a window.
|
* Move a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_move_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_move_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_move_window_entry = {
|
const struct cmd_entry cmd_move_window_entry = {
|
||||||
"move-window", "movew",
|
"move-window", "movew",
|
||||||
"dks:t:", 0, 0,
|
"dkrs:t:", 0, 0,
|
||||||
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
"[-dkr] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_move_window_exec
|
cmd_move_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *src, *dst;
|
struct session *src, *dst, *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
char *cause;
|
char *cause;
|
||||||
int idx, kflag, dflag;
|
int idx, kflag, dflag;
|
||||||
|
|
||||||
|
if (args_has(args, 'r')) {
|
||||||
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
session_renumber_windows(s);
|
||||||
|
recalculate_sizes();
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 's'), &src)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 's'), &src)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &dst)) == -2)
|
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &dst)) == -2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
kflag = args_has(self->args, 'k');
|
kflag = args_has(self->args, 'k');
|
||||||
dflag = args_has(self->args, 'd');
|
dflag = args_has(self->args, 'd');
|
||||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||||
ctx->error(ctx, "can't move window: %s", cause);
|
ctx->error(ctx, "can't move window: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
server_unlink_window(src, wl);
|
server_unlink_window(src, wl);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
* Create a new session and attach to the current terminal unless -d is given.
|
* Create a new session and attach to the current terminal unless -d is given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_new_session_check(struct args *);
|
enum cmd_retval cmd_new_session_check(struct args *);
|
||||||
int cmd_new_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_new_session_entry = {
|
const struct cmd_entry cmd_new_session_entry = {
|
||||||
"new-session", "new",
|
"new-session", "new",
|
||||||
@@ -44,15 +44,15 @@ const struct cmd_entry cmd_new_session_entry = {
|
|||||||
cmd_new_session_exec
|
cmd_new_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_new_session_check(struct args *args)
|
cmd_new_session_check(struct args *args)
|
||||||
{
|
{
|
||||||
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n')))
|
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n')))
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -63,7 +63,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct termios tio, *tiop;
|
struct termios tio, *tiop;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
const char *newname, *target, *update, *cwd, *errstr;
|
const char *newname, *target, *update, *cwd, *errstr;
|
||||||
char *overrides, *cmd, *cause;
|
char *cmd, *cause;
|
||||||
int detached, idx;
|
int detached, idx;
|
||||||
u_int sx, sy, i;
|
u_int sx, sy, i;
|
||||||
|
|
||||||
@@ -71,11 +71,11 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (newname != NULL) {
|
if (newname != NULL) {
|
||||||
if (!session_check_name(newname)) {
|
if (!session_check_name(newname)) {
|
||||||
ctx->error(ctx, "bad session name: %s", newname);
|
ctx->error(ctx, "bad session name: %s", newname);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (session_find(newname) != NULL) {
|
if (session_find(newname) != NULL) {
|
||||||
ctx->error(ctx, "duplicate session: %s", newname);
|
ctx->error(ctx, "duplicate session: %s", newname);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (target != NULL) {
|
if (target != NULL) {
|
||||||
groupwith = cmd_find_session(ctx, target, 0);
|
groupwith = cmd_find_session(ctx, target, 0);
|
||||||
if (groupwith == NULL)
|
if (groupwith == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
} else
|
} else
|
||||||
groupwith = NULL;
|
groupwith = NULL;
|
||||||
|
|
||||||
@@ -128,17 +128,10 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
/* Open the terminal if necessary. */
|
/* Open the terminal if necessary. */
|
||||||
if (!detached && ctx->cmdclient != NULL) {
|
if (!detached && ctx->cmdclient != NULL) {
|
||||||
if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
|
if (server_client_open(ctx->cmdclient, NULL, &cause) != 0) {
|
||||||
ctx->error(ctx, "not a terminal");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
overrides =
|
|
||||||
options_get_string(&global_s_options, "terminal-overrides");
|
|
||||||
if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
|
|
||||||
ctx->error(ctx, "open terminal failed: %s", cause);
|
ctx->error(ctx, "open terminal failed: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,15 +147,23 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Find new session size. */
|
/* Find new session size. */
|
||||||
if (detached) {
|
if (ctx->cmdclient != NULL) {
|
||||||
|
sx = ctx->cmdclient->tty.sx;
|
||||||
|
sy = ctx->cmdclient->tty.sy;
|
||||||
|
} else if (ctx->curclient != NULL) {
|
||||||
|
sx = ctx->curclient->tty.sx;
|
||||||
|
sy = ctx->curclient->tty.sy;
|
||||||
|
} else {
|
||||||
sx = 80;
|
sx = 80;
|
||||||
sy = 24;
|
sy = 24;
|
||||||
|
}
|
||||||
|
if (detached) {
|
||||||
if (args_has(args, 'x')) {
|
if (args_has(args, 'x')) {
|
||||||
sx = strtonum(
|
sx = strtonum(
|
||||||
args_get(args, 'x'), 1, USHRT_MAX, &errstr);
|
args_get(args, 'x'), 1, USHRT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
ctx->error(ctx, "width %s", errstr);
|
ctx->error(ctx, "width %s", errstr);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args_has(args, 'y')) {
|
if (args_has(args, 'y')) {
|
||||||
@@ -170,15 +171,9 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
args_get(args, 'y'), 1, USHRT_MAX, &errstr);
|
args_get(args, 'y'), 1, USHRT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
ctx->error(ctx, "height %s", errstr);
|
ctx->error(ctx, "height %s", errstr);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ctx->cmdclient != NULL) {
|
|
||||||
sx = ctx->cmdclient->tty.sx;
|
|
||||||
sy = ctx->cmdclient->tty.sy;
|
|
||||||
} else {
|
|
||||||
sx = ctx->curclient->tty.sx;
|
|
||||||
sy = ctx->curclient->tty.sy;
|
|
||||||
}
|
}
|
||||||
if (sy > 0 && options_get_number(&global_s_options, "status"))
|
if (sy > 0 && options_get_number(&global_s_options, "status"))
|
||||||
sy--;
|
sy--;
|
||||||
@@ -206,8 +201,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
s = session_create(newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause);
|
s = session_create(newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause);
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
ctx->error(ctx, "create session failed: %s", cause);
|
ctx->error(ctx, "create session failed: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
|
|
||||||
@@ -215,8 +210,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (cmd != NULL && args_has(args, 'n')) {
|
if (cmd != NULL && args_has(args, 'n')) {
|
||||||
w = s->curw->window;
|
w = s->curw->window;
|
||||||
|
|
||||||
xfree(w->name);
|
window_set_name(w, args_get(args, 'n'));
|
||||||
w->name = xstrdup(args_get(args, 'n'));
|
|
||||||
|
|
||||||
options_set_number(&w->options, "automatic-rename", 0);
|
options_set_number(&w->options, "automatic-rename", 0);
|
||||||
}
|
}
|
||||||
@@ -237,12 +231,13 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
*/
|
*/
|
||||||
if (!detached) {
|
if (!detached) {
|
||||||
if (ctx->cmdclient != NULL) {
|
if (ctx->cmdclient != NULL) {
|
||||||
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
server_write_ready(ctx->cmdclient);
|
||||||
|
|
||||||
old_s = ctx->cmdclient->session;
|
old_s = ctx->cmdclient->session;
|
||||||
if (old_s != NULL)
|
if (old_s != NULL)
|
||||||
ctx->cmdclient->last_session = old_s;
|
ctx->cmdclient->last_session = old_s;
|
||||||
ctx->cmdclient->session = s;
|
ctx->cmdclient->session = s;
|
||||||
|
notify_attached_session_changed(ctx->cmdclient);
|
||||||
session_update_activity(s);
|
session_update_activity(s);
|
||||||
server_redraw_client(ctx->cmdclient);
|
server_redraw_client(ctx->cmdclient);
|
||||||
} else {
|
} else {
|
||||||
@@ -250,6 +245,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (old_s != NULL)
|
if (old_s != NULL)
|
||||||
ctx->curclient->last_session = old_s;
|
ctx->curclient->last_session = old_s;
|
||||||
ctx->curclient->session = s;
|
ctx->curclient->session = s;
|
||||||
|
notify_attached_session_changed(ctx->curclient);
|
||||||
session_update_activity(s);
|
session_update_activity(s);
|
||||||
server_redraw_client(ctx->curclient);
|
server_redraw_client(ctx->curclient);
|
||||||
}
|
}
|
||||||
@@ -268,10 +264,10 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
|
||||||
cause = ARRAY_ITEM(&cfg_causes, i);
|
cause = ARRAY_ITEM(&cfg_causes, i);
|
||||||
window_copy_add(wp, "%s", cause);
|
window_copy_add(wp, "%s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
}
|
}
|
||||||
ARRAY_FREE(&cfg_causes);
|
ARRAY_FREE(&cfg_causes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (!detached); /* 1 means don't tell command client to exit */
|
return (detached ? CMD_RETURN_NORMAL : CMD_RETURN_ATTACH);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,27 +30,33 @@ int cmd_new_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_new_window_entry = {
|
const struct cmd_entry cmd_new_window_entry = {
|
||||||
"new-window", "neww",
|
"new-window", "neww",
|
||||||
"adkn:Pt:", 0, 1,
|
"ac:dF:kn:Pt:", 0, 1,
|
||||||
"[-adk] [-n window-name] [-t target-window] [command]",
|
"[-adkP] [-c start-directory] [-F format] [-n window-name] "
|
||||||
|
"[-t target-window] [command]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_new_window_exec
|
cmd_new_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
char *cmd, *cwd, *cause;
|
struct client *c;
|
||||||
int idx, last, detached;
|
const char *cmd, *cwd;
|
||||||
|
const char *template;
|
||||||
|
char *cause;
|
||||||
|
int idx, last, detached;
|
||||||
|
struct format_tree *ft;
|
||||||
|
char *cp;
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
idx = wl->idx + 1;
|
idx = wl->idx + 1;
|
||||||
|
|
||||||
/* Find the next free index. */
|
/* Find the next free index. */
|
||||||
@@ -60,7 +66,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
if (last == INT_MAX) {
|
if (last == INT_MAX) {
|
||||||
ctx->error(ctx, "no free window indexes");
|
ctx->error(ctx, "no free window indexes");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move everything from last - 1 to idx up a bit. */
|
/* Move everything from last - 1 to idx up a bit. */
|
||||||
@@ -71,7 +77,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &s)) == -2)
|
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &s)) == -2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
detached = args_has(args, 'd');
|
detached = args_has(args, 'd');
|
||||||
|
|
||||||
@@ -83,6 +89,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
* Can't use session_detach as it will destroy session if this
|
* Can't use session_detach as it will destroy session if this
|
||||||
* makes it empty.
|
* makes it empty.
|
||||||
*/
|
*/
|
||||||
|
notify_window_unlinked(s, wl->window);
|
||||||
wl->flags &= ~WINLINK_ALERTFLAGS;
|
wl->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
winlink_stack_remove(&s->lastw, wl);
|
winlink_stack_remove(&s->lastw, wl);
|
||||||
winlink_remove(&s->windows, wl);
|
winlink_remove(&s->windows, wl);
|
||||||
@@ -98,21 +105,15 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cmd = options_get_string(&s->options, "default-command");
|
cmd = options_get_string(&s->options, "default-command");
|
||||||
else
|
else
|
||||||
cmd = args->argv[0];
|
cmd = args->argv[0];
|
||||||
cwd = options_get_string(&s->options, "default-path");
|
cwd = cmd_get_default_path(ctx, args_get(args, 'c'));
|
||||||
if (*cwd == '\0') {
|
|
||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
|
||||||
cwd = ctx->cmdclient->cwd;
|
|
||||||
else
|
|
||||||
cwd = s->cwd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
idx = -1 - options_get_number(&s->options, "base-index");
|
idx = -1 - options_get_number(&s->options, "base-index");
|
||||||
wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause);
|
wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause);
|
||||||
if (wl == NULL) {
|
if (wl == NULL) {
|
||||||
ctx->error(ctx, "create window failed: %s", cause);
|
ctx->error(ctx, "create window failed: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (!detached) {
|
if (!detached) {
|
||||||
session_select(s, wl->idx);
|
session_select(s, wl->idx);
|
||||||
@@ -120,7 +121,23 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
} else
|
} else
|
||||||
server_status_session_group(s);
|
server_status_session_group(s);
|
||||||
|
|
||||||
if (args_has(args, 'P'))
|
if (args_has(args, 'P')) {
|
||||||
ctx->print(ctx, "%s:%u", s->name, wl->idx);
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
return (0);
|
template = NEW_WINDOW_TEMPLATE;
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
if ((c = cmd_find_client(ctx, NULL)) != NULL)
|
||||||
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, wl->window->active);
|
||||||
|
|
||||||
|
cp = format_expand(ft, template);
|
||||||
|
ctx->print(ctx, "%s", cp);
|
||||||
|
free(cp);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,22 +27,22 @@
|
|||||||
* Paste paste buffer if present.
|
* Paste paste buffer if present.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_paste_buffer_filter(
|
void cmd_paste_buffer_filter(struct window_pane *,
|
||||||
struct window_pane *, const char *, size_t, const char *);
|
const char *, size_t, const char *, int bracket);
|
||||||
|
|
||||||
const struct cmd_entry cmd_paste_buffer_entry = {
|
const struct cmd_entry cmd_paste_buffer_entry = {
|
||||||
"paste-buffer", "pasteb",
|
"paste-buffer", "pasteb",
|
||||||
"db:rs:t:", 0, 0,
|
"db:prs:t:", 0, 0,
|
||||||
"[-dr] [-s separator] [-b buffer-index] [-t target-pane]",
|
"[-dpr] [-s separator] [-b buffer-index] [-t target-pane]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_paste_buffer_exec
|
cmd_paste_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -52,9 +52,10 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
const char *sepstr;
|
const char *sepstr;
|
||||||
char *cause;
|
char *cause;
|
||||||
int buffer;
|
int buffer;
|
||||||
|
int pflag;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (!args_has(args, 'b'))
|
if (!args_has(args, 'b'))
|
||||||
buffer = -1;
|
buffer = -1;
|
||||||
@@ -62,8 +63,8 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
pb = paste_get_index(&global_buffers, buffer);
|
pb = paste_get_index(&global_buffers, buffer);
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +86,9 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else
|
else
|
||||||
sepstr = "\r";
|
sepstr = "\r";
|
||||||
}
|
}
|
||||||
cmd_paste_buffer_filter(wp, pb->data, pb->size, sepstr);
|
pflag = args_has(args, 'p') &&
|
||||||
|
(wp->screen->mode & MODE_BRACKETPASTE);
|
||||||
|
cmd_paste_buffer_filter(wp, pb->data, pb->size, sepstr, pflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete the buffer if -d. */
|
/* Delete the buffer if -d. */
|
||||||
@@ -96,18 +99,21 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
paste_free_index(&global_buffers, buffer);
|
paste_free_index(&global_buffers, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add bytes to a buffer and filter '\n' according to separator. */
|
/* Add bytes to a buffer and filter '\n' according to separator. */
|
||||||
void
|
void
|
||||||
cmd_paste_buffer_filter(
|
cmd_paste_buffer_filter(struct window_pane *wp,
|
||||||
struct window_pane *wp, const char *data, size_t size, const char *sep)
|
const char *data, size_t size, const char *sep, int bracket)
|
||||||
{
|
{
|
||||||
const char *end = data + size;
|
const char *end = data + size;
|
||||||
const char *lf;
|
const char *lf;
|
||||||
size_t seplen;
|
size_t seplen;
|
||||||
|
|
||||||
|
if (bracket)
|
||||||
|
bufferevent_write(wp->event, "\033[200~", 6);
|
||||||
|
|
||||||
seplen = strlen(sep);
|
seplen = strlen(sep);
|
||||||
while ((lf = memchr(data, '\n', end - data)) != NULL) {
|
while ((lf = memchr(data, '\n', end - data)) != NULL) {
|
||||||
if (lf != data)
|
if (lf != data)
|
||||||
@@ -118,4 +124,7 @@ cmd_paste_buffer_filter(
|
|||||||
|
|
||||||
if (end != data)
|
if (end != data)
|
||||||
bufferevent_write(wp->event, data, end - data);
|
bufferevent_write(wp->event, data, end - data);
|
||||||
|
|
||||||
|
if (bracket)
|
||||||
|
bufferevent_write(wp->event, "\033[201~", 6);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,21 +31,21 @@
|
|||||||
* Open pipe to redirect pane output. If already open, close first.
|
* Open pipe to redirect pane output. If already open, close first.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_pipe_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
|
void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_pipe_pane_entry = {
|
const struct cmd_entry cmd_pipe_pane_entry = {
|
||||||
"pipe-pane", "pipep",
|
"pipe-pane", "pipep",
|
||||||
"ot:", 0, 1,
|
"ot:", 0, 1,
|
||||||
CMD_TARGET_PANE_USAGE "[-o] [command]",
|
"[-o] " CMD_TARGET_PANE_USAGE " [command]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_pipe_pane_exec
|
cmd_pipe_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -54,11 +54,9 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
char *command;
|
char *command;
|
||||||
int old_fd, pipe_fd[2], null_fd;
|
int old_fd, pipe_fd[2], null_fd;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
c = cmd_find_client(ctx, NULL);
|
||||||
|
|
||||||
/* Destroy the old pipe. */
|
/* Destroy the old pipe. */
|
||||||
old_fd = wp->pipe_fd;
|
old_fd = wp->pipe_fd;
|
||||||
@@ -70,7 +68,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
/* If no pipe command, that is enough. */
|
/* If no pipe command, that is enough. */
|
||||||
if (args->argc == 0 || *args->argv[0] == '\0')
|
if (args->argc == 0 || *args->argv[0] == '\0')
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* With -o, only open the new pipe if there was no previous one. This
|
* With -o, only open the new pipe if there was no previous one. This
|
||||||
@@ -79,19 +77,19 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
* bind ^p pipep -o 'cat >>~/output'
|
* bind ^p pipep -o 'cat >>~/output'
|
||||||
*/
|
*/
|
||||||
if (args_has(self->args, 'o') && old_fd != -1)
|
if (args_has(self->args, 'o') && old_fd != -1)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
/* Open the new pipe. */
|
/* Open the new pipe. */
|
||||||
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_fd) != 0) {
|
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_fd) != 0) {
|
||||||
ctx->error(ctx, "socketpair error: %s", strerror(errno));
|
ctx->error(ctx, "socketpair error: %s", strerror(errno));
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fork the child. */
|
/* Fork the child. */
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
ctx->error(ctx, "fork error: %s", strerror(errno));
|
ctx->error(ctx, "fork error: %s", strerror(errno));
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
case 0:
|
case 0:
|
||||||
/* Child process. */
|
/* Child process. */
|
||||||
close(pipe_fd[0]);
|
close(pipe_fd[0]);
|
||||||
@@ -128,7 +126,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
||||||
|
|
||||||
setblocking(wp->pipe_fd, 0);
|
setblocking(wp->pipe_fd, 0);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,28 +24,32 @@
|
|||||||
* Refresh client.
|
* Refresh client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_refresh_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_refresh_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_refresh_client_entry = {
|
const struct cmd_entry cmd_refresh_client_entry = {
|
||||||
"refresh-client", "refresh",
|
"refresh-client", "refresh",
|
||||||
"t:", 0, 0,
|
"St:", 0, 0,
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
"[-S] " CMD_TARGET_CLIENT_USAGE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_refresh_client_exec
|
cmd_refresh_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_refresh_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_refresh_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
server_redraw_client(c);
|
if (args_has(args, 'S')) {
|
||||||
|
status_update_jobs(c);
|
||||||
|
server_status_client(c);
|
||||||
|
} else
|
||||||
|
server_redraw_client(c);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
* Change session name.
|
* Change session name.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_rename_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_rename_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rename_session_entry = {
|
const struct cmd_entry cmd_rename_session_entry = {
|
||||||
"rename-session", "rename",
|
"rename-session", "rename",
|
||||||
@@ -38,7 +38,7 @@ const struct cmd_entry cmd_rename_session_entry = {
|
|||||||
cmd_rename_session_exec
|
cmd_rename_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -48,22 +48,23 @@ cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
newname = args->argv[0];
|
newname = args->argv[0];
|
||||||
if (!session_check_name(newname)) {
|
if (!session_check_name(newname)) {
|
||||||
ctx->error(ctx, "bad session name: %s", newname);
|
ctx->error(ctx, "bad session name: %s", newname);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (session_find(newname) != NULL) {
|
if (session_find(newname) != NULL) {
|
||||||
ctx->error(ctx, "duplicate session: %s", newname);
|
ctx->error(ctx, "duplicate session: %s", newname);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
RB_REMOVE(sessions, &sessions, s);
|
RB_REMOVE(sessions, &sessions, s);
|
||||||
xfree(s->name);
|
free(s->name);
|
||||||
s->name = xstrdup(newname);
|
s->name = xstrdup(newname);
|
||||||
RB_INSERT(sessions, &sessions, s);
|
RB_INSERT(sessions, &sessions, s);
|
||||||
|
|
||||||
server_status_session(s);
|
server_status_session(s);
|
||||||
|
notify_session_renamed(s);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
* Rename a window.
|
* Rename a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_rename_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_rename_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rename_window_entry = {
|
const struct cmd_entry cmd_rename_window_entry = {
|
||||||
"rename-window", "renamew",
|
"rename-window", "renamew",
|
||||||
@@ -38,7 +38,7 @@ const struct cmd_entry cmd_rename_window_entry = {
|
|||||||
cmd_rename_window_exec
|
cmd_rename_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -46,13 +46,12 @@ cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
xfree(wl->window->name);
|
window_set_name(wl->window, args->argv[0]);
|
||||||
wl->window->name = xstrdup(args->argv[0]);
|
|
||||||
options_set_number(&wl->window->options, "automatic-rename", 0);
|
options_set_number(&wl->window->options, "automatic-rename", 0);
|
||||||
|
|
||||||
server_status_window(wl->window);
|
server_status_window(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
* Increase or decrease pane size.
|
* Increase or decrease pane size.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_resize_pane_key_binding(struct cmd *, int);
|
void cmd_resize_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_resize_pane_entry = {
|
const struct cmd_entry cmd_resize_pane_entry = {
|
||||||
"resize-pane", "resizep",
|
"resize-pane", "resizep",
|
||||||
@@ -81,7 +81,7 @@ cmd_resize_pane_key_binding(struct cmd *self, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -91,7 +91,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int adjust;
|
u_int adjust;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args->argc == 0)
|
if (args->argc == 0)
|
||||||
adjust = 1;
|
adjust = 1;
|
||||||
@@ -99,10 +99,11 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
ctx->error(ctx, "adjustment %s", errstr);
|
ctx->error(ctx, "adjustment %s", errstr);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
layout_list_add(wp->window);
|
||||||
if (args_has(self->args, 'L'))
|
if (args_has(self->args, 'L'))
|
||||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
|
||||||
else if (args_has(self->args, 'R'))
|
else if (args_has(self->args, 'R'))
|
||||||
@@ -113,5 +114,5 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
* Respawn a pane (restart the command). Kill existing if -k given.
|
* Respawn a pane (restart the command). Kill existing if -k given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_respawn_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_respawn_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_respawn_pane_entry = {
|
const struct cmd_entry cmd_respawn_pane_entry = {
|
||||||
"respawn-pane", "respawnp",
|
"respawn-pane", "respawnp",
|
||||||
@@ -39,7 +40,7 @@ const struct cmd_entry cmd_respawn_pane_entry = {
|
|||||||
cmd_respawn_pane_exec
|
cmd_respawn_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -49,16 +50,19 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct session *s;
|
struct session *s;
|
||||||
struct environ env;
|
struct environ env;
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
char *cause;
|
char *cause;
|
||||||
|
u_int idx;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (!args_has(self->args, 'k') && wp->fd != -1) {
|
if (!args_has(self->args, 'k') && wp->fd != -1) {
|
||||||
|
if (window_pane_index(wp, &idx) != 0)
|
||||||
|
fatalx("index not found");
|
||||||
ctx->error(ctx, "pane still active: %s:%u.%u",
|
ctx->error(ctx, "pane still active: %s:%u.%u",
|
||||||
s->name, wl->idx, window_pane_index(w, wp));
|
s->name, wl->idx, idx);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
environ_init(&env);
|
environ_init(&env);
|
||||||
@@ -76,13 +80,13 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cmd = NULL;
|
cmd = NULL;
|
||||||
if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) {
|
if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) {
|
||||||
ctx->error(ctx, "respawn pane failed: %s", cause);
|
ctx->error(ctx, "respawn pane failed: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
wp->flags |= PANE_REDRAW;
|
wp->flags |= PANE_REDRAW;
|
||||||
server_status_window(w);
|
server_status_window(w);
|
||||||
|
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
* Respawn a window (restart the command). Kill existing if -k given.
|
* Respawn a window (restart the command). Kill existing if -k given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_respawn_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_respawn_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_respawn_window_entry = {
|
const struct cmd_entry cmd_respawn_window_entry = {
|
||||||
"respawn-window", "respawnw",
|
"respawn-window", "respawnw",
|
||||||
@@ -38,7 +39,7 @@ const struct cmd_entry cmd_respawn_window_entry = {
|
|||||||
cmd_respawn_window_exec
|
cmd_respawn_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -51,7 +52,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
char *cause;
|
char *cause;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (!args_has(self->args, 'k')) {
|
if (!args_has(self->args, 'k')) {
|
||||||
@@ -60,7 +61,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
continue;
|
continue;
|
||||||
ctx->error(ctx,
|
ctx->error(ctx,
|
||||||
"window still active: %s:%d", s->name, wl->idx);
|
"window still active: %s:%d", s->name, wl->idx);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,10 +82,10 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cmd = NULL;
|
cmd = NULL;
|
||||||
if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) {
|
if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) {
|
||||||
ctx->error(ctx, "respawn window failed: %s", cause);
|
ctx->error(ctx, "respawn window failed: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
server_destroy_pane(wp);
|
server_destroy_pane(wp);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
layout_init(w);
|
layout_init(w);
|
||||||
window_pane_reset_mode(wp);
|
window_pane_reset_mode(wp);
|
||||||
@@ -96,5 +97,5 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
|
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
* Rotate the panes in a window.
|
* Rotate the panes in a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_rotate_window_key_binding(struct cmd *, int);
|
void cmd_rotate_window_key_binding(struct cmd *, int);
|
||||||
int cmd_rotate_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_rotate_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rotate_window_entry = {
|
const struct cmd_entry cmd_rotate_window_entry = {
|
||||||
"rotate-window", "rotatew",
|
"rotate-window", "rotatew",
|
||||||
@@ -45,7 +45,7 @@ cmd_rotate_window_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 'D', NULL);
|
args_set(self->args, 'D', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -56,7 +56,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int sx, sy, xoff, yoff;
|
u_int sx, sy, xoff, yoff;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (args_has(self->args, 'D')) {
|
if (args_has(self->args, 'D')) {
|
||||||
@@ -115,5 +115,5 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -28,10 +29,9 @@
|
|||||||
* Runs a command without a window.
|
* Runs a command without a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_run_shell_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_run_shell_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
void cmd_run_shell_callback(struct job *);
|
||||||
void cmd_run_shell_callback(struct job *);
|
void cmd_run_shell_free(void *);
|
||||||
void cmd_run_shell_free(void *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_run_shell_entry = {
|
const struct cmd_entry cmd_run_shell_entry = {
|
||||||
"run-shell", "run",
|
"run-shell", "run",
|
||||||
@@ -48,7 +48,7 @@ struct cmd_run_shell_data {
|
|||||||
struct cmd_ctx ctx;
|
struct cmd_ctx ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -66,7 +66,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
job_run(shellcmd, cmd_run_shell_callback, cmd_run_shell_free, cdata);
|
job_run(shellcmd, cmd_run_shell_callback, cmd_run_shell_free, cdata);
|
||||||
|
|
||||||
return (1); /* don't let client exit */
|
return (CMD_RETURN_YIELD); /* don't let client exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -101,7 +101,7 @@ cmd_run_shell_callback(struct job *job)
|
|||||||
ctx->print(ctx, "%s", line);
|
ctx->print(ctx, "%s", line);
|
||||||
lines++;
|
lines++;
|
||||||
|
|
||||||
xfree(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = cdata->cmd;
|
cmd = cdata->cmd;
|
||||||
@@ -119,7 +119,7 @@ cmd_run_shell_callback(struct job *job)
|
|||||||
ctx->print(ctx, "%s", msg);
|
ctx->print(ctx, "%s", msg);
|
||||||
else
|
else
|
||||||
ctx->info(ctx, "%s", msg);
|
ctx->info(ctx, "%s", msg);
|
||||||
xfree(msg);
|
free(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +136,6 @@ cmd_run_shell_free(void *data)
|
|||||||
if (ctx->curclient != NULL)
|
if (ctx->curclient != NULL)
|
||||||
ctx->curclient->references--;
|
ctx->curclient->references--;
|
||||||
|
|
||||||
xfree(cdata->cmd);
|
free(cdata->cmd);
|
||||||
xfree(cdata);
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,33 +20,35 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Saves a session paste buffer to a file.
|
* Saves a paste buffer to a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_save_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_save_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_save_buffer_entry = {
|
const struct cmd_entry cmd_save_buffer_entry = {
|
||||||
"save-buffer", "saveb",
|
"save-buffer", "saveb",
|
||||||
"ab:", 1, 1,
|
"ab:", 1, 1,
|
||||||
"[-a] " CMD_BUFFER_USAGE,
|
"[-a] " CMD_BUFFER_USAGE " path",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_save_buffer_exec
|
cmd_save_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c = ctx->cmdclient;
|
struct client *c = ctx->cmdclient;
|
||||||
|
struct session *s;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
const char *path;
|
const char *path, *newpath, *wd;
|
||||||
char *cause;
|
char *cause;
|
||||||
int buffer;
|
int buffer;
|
||||||
mode_t mask;
|
mode_t mask;
|
||||||
@@ -55,20 +57,20 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (!args_has(args, 'b')) {
|
if (!args_has(args, 'b')) {
|
||||||
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
||||||
ctx->error(ctx, "no buffers");
|
ctx->error(ctx, "no buffers");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
pb = paste_get_index(&global_buffers, buffer);
|
pb = paste_get_index(&global_buffers, buffer);
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,10 +78,25 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (strcmp(path, "-") == 0) {
|
if (strcmp(path, "-") == 0) {
|
||||||
if (c == NULL) {
|
if (c == NULL) {
|
||||||
ctx->error(ctx, "%s: can't write to stdout", path);
|
ctx->error(ctx, "%s: can't write to stdout", path);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
bufferevent_write(c->stdout_event, pb->data, pb->size);
|
evbuffer_add(c->stdout_data, pb->data, pb->size);
|
||||||
|
server_push_stdout(c);
|
||||||
} else {
|
} else {
|
||||||
|
if (c != NULL)
|
||||||
|
wd = c->cwd;
|
||||||
|
else if ((s = cmd_current_session(ctx, 0)) != NULL) {
|
||||||
|
wd = options_get_string(&s->options, "default-path");
|
||||||
|
if (*wd == '\0')
|
||||||
|
wd = s->cwd;
|
||||||
|
} else
|
||||||
|
wd = NULL;
|
||||||
|
if (wd != NULL && *wd != '\0') {
|
||||||
|
newpath = get_full_path(wd, path);
|
||||||
|
if (newpath != NULL)
|
||||||
|
path = newpath;
|
||||||
|
}
|
||||||
|
|
||||||
mask = umask(S_IRWXG | S_IRWXO);
|
mask = umask(S_IRWXG | S_IRWXO);
|
||||||
if (args_has(self->args, 'a'))
|
if (args_has(self->args, 'a'))
|
||||||
f = fopen(path, "ab");
|
f = fopen(path, "ab");
|
||||||
@@ -88,15 +105,15 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
umask(mask);
|
umask(mask);
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
ctx->error(ctx, "%s: %s", path, strerror(errno));
|
ctx->error(ctx, "%s: %s", path, strerror(errno));
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
|
if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
|
||||||
ctx->error(ctx, "%s: fwrite error", path);
|
ctx->error(ctx, "%s: fwrite error", path);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,13 @@
|
|||||||
* Switch window to selected layout.
|
* Switch window to selected layout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_layout_key_binding(struct cmd *, int);
|
void cmd_select_layout_key_binding(struct cmd *, int);
|
||||||
int cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_layout_entry = {
|
const struct cmd_entry cmd_select_layout_entry = {
|
||||||
"select-layout", "selectl",
|
"select-layout", "selectl",
|
||||||
"npt:", 0, 1,
|
"nprut:", 0, 1,
|
||||||
"[-np] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
"[-npUu] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
||||||
0,
|
0,
|
||||||
cmd_select_layout_key_binding,
|
cmd_select_layout_key_binding,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -76,22 +76,32 @@ cmd_select_layout_key_binding(struct cmd *self, int key)
|
|||||||
case '5' | KEYC_ESCAPE:
|
case '5' | KEYC_ESCAPE:
|
||||||
self->args = args_create(1, "tiled");
|
self->args = args_create(1, "tiled");
|
||||||
break;
|
break;
|
||||||
|
case 'u':
|
||||||
|
self->args = args_create(0);
|
||||||
|
args_set(self->args, 'u', NULL);
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
self->args = args_create(0);
|
||||||
|
args_set(self->args, 'U', NULL);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
self->args = args_create(0);
|
self->args = args_create(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
struct window *w;
|
||||||
const char *layoutname;
|
const char *layoutname;
|
||||||
int next, previous, layout;
|
int next, previous, layout;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
w = wl->window;
|
||||||
|
|
||||||
next = self->entry == &cmd_next_layout_entry;
|
next = self->entry == &cmd_next_layout_entry;
|
||||||
if (args_has(self->args, 'n'))
|
if (args_has(self->args, 'n'))
|
||||||
@@ -100,13 +110,29 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (args_has(self->args, 'p'))
|
if (args_has(self->args, 'p'))
|
||||||
previous = 1;
|
previous = 1;
|
||||||
|
|
||||||
|
layout_list_add(w);
|
||||||
|
if (args_has(self->args, 'U')) {
|
||||||
|
if ((layoutname = layout_list_redo(w)) == NULL) {
|
||||||
|
ctx->info(ctx, "no more layout history");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
goto set_layout;
|
||||||
|
} else if (args_has(self->args, 'u')) {
|
||||||
|
if ((layoutname = layout_list_undo(w)) == NULL) {
|
||||||
|
ctx->info(ctx, "no more layout history");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
goto set_layout;
|
||||||
|
}
|
||||||
|
|
||||||
if (next || previous) {
|
if (next || previous) {
|
||||||
if (next)
|
if (next)
|
||||||
layout = layout_set_next(wl->window);
|
layout = layout_set_next(wl->window);
|
||||||
else
|
else
|
||||||
layout = layout_set_previous(wl->window);
|
layout = layout_set_previous(wl->window);
|
||||||
|
server_redraw_window(wl->window);
|
||||||
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc == 0)
|
if (args->argc == 0)
|
||||||
@@ -115,19 +141,21 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
layout = layout_set_lookup(args->argv[0]);
|
layout = layout_set_lookup(args->argv[0]);
|
||||||
if (layout != -1) {
|
if (layout != -1) {
|
||||||
layout = layout_set_select(wl->window, layout);
|
layout = layout_set_select(wl->window, layout);
|
||||||
|
server_redraw_window(wl->window);
|
||||||
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc != 0) {
|
if (args->argc == 0)
|
||||||
layoutname = args->argv[0];
|
return (CMD_RETURN_NORMAL);
|
||||||
if (layout_parse(wl->window, layoutname) == -1) {
|
layoutname = args->argv[0];
|
||||||
ctx->error(ctx, "can't set layout: %s", layoutname);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
ctx->info(ctx, "arranging in: %s", layoutname);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
set_layout:
|
||||||
|
if (layout_parse(wl->window, layoutname) == -1) {
|
||||||
|
ctx->error(ctx, "can't set layout: %s", layoutname);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
server_redraw_window(wl->window);
|
||||||
|
ctx->info(ctx, "arranging in: %s", layoutname);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
* Select pane.
|
* Select pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_pane_key_binding(struct cmd *, int);
|
void cmd_select_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_select_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_pane_entry = {
|
const struct cmd_entry cmd_select_pane_entry = {
|
||||||
"select-pane", "selectp",
|
"select-pane", "selectp",
|
||||||
@@ -63,7 +63,7 @@ cmd_select_pane_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 't', ":.+");
|
args_set(self->args, 't', ":.+");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -73,26 +73,26 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) {
|
if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (wl->window->last == NULL) {
|
if (wl->window->last == NULL) {
|
||||||
ctx->error(ctx, "no last pane");
|
ctx->error(ctx, "no last pane");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
window_set_active_pane(wl->window, wl->window->last);
|
window_set_active_pane(wl->window, wl->window->last);
|
||||||
server_status_window(wl->window);
|
server_status_window(wl->window);
|
||||||
server_redraw_window_borders(wl->window);
|
server_redraw_window_borders(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (!window_pane_visible(wp)) {
|
if (!window_pane_visible(wp)) {
|
||||||
ctx->error(ctx, "pane not visible");
|
ctx->error(ctx, "pane not visible");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'L'))
|
if (args_has(self->args, 'L'))
|
||||||
@@ -105,12 +105,12 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
wp = window_pane_find_down(wp);
|
wp = window_pane_find_down(wp);
|
||||||
if (wp == NULL) {
|
if (wp == NULL) {
|
||||||
ctx->error(ctx, "pane not found");
|
ctx->error(ctx, "pane not found");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
window_set_active_pane(wl->window, wp);
|
window_set_active_pane(wl->window, wp);
|
||||||
server_status_window(wl->window);
|
server_status_window(wl->window);
|
||||||
server_redraw_window_borders(wl->window);
|
server_redraw_window_borders(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
* Select window by index.
|
* Select window by index.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_window_key_binding(struct cmd *, int);
|
void cmd_select_window_key_binding(struct cmd *, int);
|
||||||
int cmd_select_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_window_entry = {
|
const struct cmd_entry cmd_select_window_entry = {
|
||||||
"select-window", "selectw",
|
"select-window", "selectw",
|
||||||
@@ -83,7 +83,7 @@ cmd_select_window_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 'a', NULL);
|
args_set(self->args, 'a', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -104,23 +104,23 @@ cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (next || previous || last) {
|
if (next || previous || last) {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
activity = args_has(self->args, 'a');
|
activity = args_has(self->args, 'a');
|
||||||
if (next) {
|
if (next) {
|
||||||
if (session_next(s, activity) != 0) {
|
if (session_next(s, activity) != 0) {
|
||||||
ctx->error(ctx, "no next window");
|
ctx->error(ctx, "no next window");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (previous) {
|
} else if (previous) {
|
||||||
if (session_previous(s, activity) != 0) {
|
if (session_previous(s, activity) != 0) {
|
||||||
ctx->error(ctx, "no previous window");
|
ctx->error(ctx, "no previous window");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (session_last(s) != 0) {
|
if (session_last(s) != 0) {
|
||||||
ctx->error(ctx, "no last window");
|
ctx->error(ctx, "no last window");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,12 +128,12 @@ cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
} else {
|
} else {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (session_select(s, wl->idx) == 0)
|
if (session_select(s, wl->idx) == 0)
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,34 +27,52 @@
|
|||||||
* Send keys to client.
|
* Send keys to client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_send_keys_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_send_keys_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_send_keys_entry = {
|
const struct cmd_entry cmd_send_keys_entry = {
|
||||||
"send-keys", "send",
|
"send-keys", "send",
|
||||||
"t:", 0, -1,
|
"lRt:", 0, -1,
|
||||||
"[-t target-pane] key ...",
|
"[-lR] [-t target-pane] key ...",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_send_keys_exec
|
cmd_send_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
struct input_ctx *ictx;
|
||||||
const char *str;
|
const char *str;
|
||||||
int i, key;
|
int i, key;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if (args_has(args, 'R')) {
|
||||||
|
ictx = &wp->ictx;
|
||||||
|
|
||||||
|
memcpy(&ictx->cell, &grid_default_cell, sizeof ictx->cell);
|
||||||
|
memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell);
|
||||||
|
ictx->old_cx = 0;
|
||||||
|
ictx->old_cy = 0;
|
||||||
|
|
||||||
|
if (wp->mode == NULL)
|
||||||
|
screen_write_start(&ictx->ctx, wp, &wp->base);
|
||||||
|
else
|
||||||
|
screen_write_start(&ictx->ctx, NULL, &wp->base);
|
||||||
|
screen_write_reset(&ictx->ctx);
|
||||||
|
screen_write_stop(&ictx->ctx);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < args->argc; i++) {
|
for (i = 0; i < args->argc; i++) {
|
||||||
str = args->argv[i];
|
str = args->argv[i];
|
||||||
|
|
||||||
if ((key = key_string_lookup_string(str)) != KEYC_NONE) {
|
if (!args_has(args, 'l') &&
|
||||||
|
(key = key_string_lookup_string(str)) != KEYC_NONE) {
|
||||||
window_pane_key(wp, s, key);
|
window_pane_key(wp, s, key);
|
||||||
} else {
|
} else {
|
||||||
for (; *str != '\0'; str++)
|
for (; *str != '\0'; str++)
|
||||||
@@ -61,5 +80,5 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,31 +24,34 @@
|
|||||||
* Send prefix key as a key.
|
* Send prefix key as a key.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_send_prefix_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_send_prefix_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_send_prefix_entry = {
|
const struct cmd_entry cmd_send_prefix_entry = {
|
||||||
"send-prefix", NULL,
|
"send-prefix", NULL,
|
||||||
"t:", 0, 0,
|
"2t:", 0, 0,
|
||||||
CMD_TARGET_PANE_USAGE,
|
"[-2] " CMD_TARGET_PANE_USAGE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_send_prefix_exec
|
cmd_send_prefix_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct keylist *keylist;
|
int key;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
keylist = options_get_data(&s->options, "prefix");
|
if (args_has(args, '2'))
|
||||||
window_pane_key(wp, s, ARRAY_FIRST(keylist));
|
key = options_get_number(&s->options, "prefix2");
|
||||||
|
else
|
||||||
|
key = options_get_number(&s->options, "prefix");
|
||||||
|
window_pane_key(wp, s, key);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
* Show various information about server.
|
* Show various information about server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_server_info_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_server_info_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_server_info_entry = {
|
const struct cmd_entry cmd_server_info_entry = {
|
||||||
"server-info", "info",
|
"server-info", "info",
|
||||||
@@ -43,7 +43,7 @@ const struct cmd_entry cmd_server_info_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct tty_term *term;
|
struct tty_term *term;
|
||||||
@@ -88,12 +88,12 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (c == NULL || c->session == NULL)
|
if (c == NULL || c->session == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ctx->print(ctx,"%2d: %s (%d, %d): %s [%ux%u %s bs=%hho] "
|
ctx->print(ctx,"%2d: %s (%d, %d): %s [%ux%u %s bs=%hho "
|
||||||
"[flags=0x%x/0x%x, references=%u]", i, c->tty.path,
|
"xterm=%u] [flags=0x%x/0x%x, references=%u]", i,
|
||||||
c->ibuf.fd, c->tty.fd, c->session->name,
|
c->tty.path, c->ibuf.fd, c->tty.fd, c->session->name,
|
||||||
c->tty.sx, c->tty.sy, c->tty.termname,
|
c->tty.sx, c->tty.sy, c->tty.termname,
|
||||||
c->tty.tio.c_cc[VERASE], c->flags,
|
c->tty.tio.c_cc[VERASE], c->tty.xterm_version,
|
||||||
c->tty.flags, c->references);
|
c->flags, c->tty.flags, c->references);
|
||||||
}
|
}
|
||||||
ctx->print(ctx, "%s", "");
|
ctx->print(ctx, "%s", "");
|
||||||
|
|
||||||
@@ -179,5 +179,5 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
job->cmd, job->fd, job->pid, job->status);
|
job->cmd, job->fd, job->pid, job->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,16 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add or set a session paste buffer.
|
* Add or set a paste buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_buffer_entry = {
|
const struct cmd_entry cmd_set_buffer_entry = {
|
||||||
"set-buffer", "setb",
|
"set-buffer", "setb",
|
||||||
@@ -38,7 +39,7 @@ const struct cmd_entry cmd_set_buffer_entry = {
|
|||||||
cmd_set_buffer_exec
|
cmd_set_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -54,22 +55,22 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (!args_has(args, 'b')) {
|
if (!args_has(args, 'b')) {
|
||||||
paste_add(&global_buffers, pdata, psize, limit);
|
paste_add(&global_buffers, pdata, psize, limit);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
xfree(pdata);
|
free(pdata);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
xfree(pdata);
|
free(pdata);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
* Set an environment variable.
|
* Set an environment variable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_set_environment_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_set_environment_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_environment_entry = {
|
const struct cmd_entry cmd_set_environment_entry = {
|
||||||
"set-environment", "setenv",
|
"set-environment", "setenv",
|
||||||
@@ -39,7 +39,7 @@ const struct cmd_entry cmd_set_environment_entry = {
|
|||||||
cmd_set_environment_exec
|
cmd_set_environment_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -50,11 +50,11 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
name = args->argv[0];
|
name = args->argv[0];
|
||||||
if (*name == '\0') {
|
if (*name == '\0') {
|
||||||
ctx->error(ctx, "empty variable name");
|
ctx->error(ctx, "empty variable name");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (strchr(name, '=') != NULL) {
|
if (strchr(name, '=') != NULL) {
|
||||||
ctx->error(ctx, "variable name contains =");
|
ctx->error(ctx, "variable name contains =");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc < 1)
|
if (args->argc < 1)
|
||||||
@@ -66,29 +66,29 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
env = &global_environ;
|
env = &global_environ;
|
||||||
else {
|
else {
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
env = &s->environ;
|
env = &s->environ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'u')) {
|
if (args_has(self->args, 'u')) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
ctx->error(ctx, "can't specify a value with -u");
|
ctx->error(ctx, "can't specify a value with -u");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_unset(env, name);
|
environ_unset(env, name);
|
||||||
} else if (args_has(self->args, 'r')) {
|
} else if (args_has(self->args, 'r')) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
ctx->error(ctx, "can't specify a value with -r");
|
ctx->error(ctx, "can't specify a value with -r");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_set(env, name, NULL);
|
environ_set(env, name, NULL);
|
||||||
} else {
|
} else {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
ctx->error(ctx, "no value specified");
|
ctx->error(ctx, "no value specified");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_set(env, name, value);
|
environ_set(env, name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
124
cmd-set-option.c
124
cmd-set-option.c
@@ -27,10 +27,7 @@
|
|||||||
* Set an option.
|
* Set an option.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
int cmd_set_option_find(const char *, const struct options_table_entry **,
|
|
||||||
const struct options_table_entry **);
|
|
||||||
|
|
||||||
int cmd_set_option_unset(struct cmd *, struct cmd_ctx *,
|
int cmd_set_option_unset(struct cmd *, struct cmd_ctx *,
|
||||||
const struct options_table_entry *, struct options *,
|
const struct options_table_entry *, struct options *,
|
||||||
@@ -45,7 +42,7 @@ struct options_entry *cmd_set_option_string(struct cmd *, struct cmd_ctx *,
|
|||||||
struct options_entry *cmd_set_option_number(struct cmd *, struct cmd_ctx *,
|
struct options_entry *cmd_set_option_number(struct cmd *, struct cmd_ctx *,
|
||||||
const struct options_table_entry *, struct options *,
|
const struct options_table_entry *, struct options *,
|
||||||
const char *);
|
const char *);
|
||||||
struct options_entry *cmd_set_option_keys(struct cmd *, struct cmd_ctx *,
|
struct options_entry *cmd_set_option_key(struct cmd *, struct cmd_ctx *,
|
||||||
const struct options_table_entry *, struct options *,
|
const struct options_table_entry *, struct options *,
|
||||||
const char *);
|
const char *);
|
||||||
struct options_entry *cmd_set_option_colour(struct cmd *, struct cmd_ctx *,
|
struct options_entry *cmd_set_option_colour(struct cmd *, struct cmd_ctx *,
|
||||||
@@ -63,8 +60,8 @@ struct options_entry *cmd_set_option_choice(struct cmd *, struct cmd_ctx *,
|
|||||||
|
|
||||||
const struct cmd_entry cmd_set_option_entry = {
|
const struct cmd_entry cmd_set_option_entry = {
|
||||||
"set-option", "set",
|
"set-option", "set",
|
||||||
"agst:uw", 1, 2,
|
"agqst:uw", 1, 2,
|
||||||
"[-agsuw] [-t target-session|target-window] option [value]",
|
"[-agsquw] [-t target-session|target-window] option [value]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -73,48 +70,15 @@ const struct cmd_entry cmd_set_option_entry = {
|
|||||||
|
|
||||||
const struct cmd_entry cmd_set_window_option_entry = {
|
const struct cmd_entry cmd_set_window_option_entry = {
|
||||||
"set-window-option", "setw",
|
"set-window-option", "setw",
|
||||||
"agt:u", 1, 2,
|
"agqt:u", 1, 2,
|
||||||
"[-agu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
"[-agqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_set_option_exec
|
cmd_set_option_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Look for an option in all three tables. */
|
enum cmd_retval
|
||||||
int
|
|
||||||
cmd_set_option_find(
|
|
||||||
const char *optstr, const struct options_table_entry **table,
|
|
||||||
const struct options_table_entry **oe)
|
|
||||||
{
|
|
||||||
static const struct options_table_entry *tables[] = {
|
|
||||||
server_options_table,
|
|
||||||
window_options_table,
|
|
||||||
session_options_table
|
|
||||||
};
|
|
||||||
const struct options_table_entry *oe_loop;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
for (i = 0; i < nitems(tables); i++) {
|
|
||||||
for (oe_loop = tables[i]; oe_loop->name != NULL; oe_loop++) {
|
|
||||||
if (strncmp(oe_loop->name, optstr, strlen(optstr)) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* If already found, ambiguous. */
|
|
||||||
if (*oe != NULL)
|
|
||||||
return (-1);
|
|
||||||
*oe = oe_loop;
|
|
||||||
*table = tables[i];
|
|
||||||
|
|
||||||
/* Bail now if an exact match. */
|
|
||||||
if (strcmp((*oe)->name, optstr) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -123,6 +87,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct options *oo;
|
struct options *oo;
|
||||||
|
struct window *w;
|
||||||
const char *optstr, *valstr;
|
const char *optstr, *valstr;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
@@ -130,7 +95,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
optstr = args->argv[0];
|
optstr = args->argv[0];
|
||||||
if (*optstr == '\0') {
|
if (*optstr == '\0') {
|
||||||
ctx->error(ctx, "invalid option");
|
ctx->error(ctx, "invalid option");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (args->argc < 2)
|
if (args->argc < 2)
|
||||||
valstr = NULL;
|
valstr = NULL;
|
||||||
@@ -139,13 +104,13 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
/* Find the option entry, try each table. */
|
/* Find the option entry, try each table. */
|
||||||
table = oe = NULL;
|
table = oe = NULL;
|
||||||
if (cmd_set_option_find(optstr, &table, &oe) != 0) {
|
if (options_table_find(optstr, &table, &oe) != 0) {
|
||||||
ctx->error(ctx, "ambiguous option: %s", optstr);
|
ctx->error(ctx, "ambiguous option: %s", optstr);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (oe == NULL) {
|
if (oe == NULL) {
|
||||||
ctx->error(ctx, "unknown option: %s", optstr);
|
ctx->error(ctx, "unknown option: %s", optstr);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Work out the tree from the table. */
|
/* Work out the tree from the table. */
|
||||||
@@ -157,7 +122,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else {
|
else {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
oo = &wl->window->options;
|
oo = &wl->window->options;
|
||||||
}
|
}
|
||||||
} else if (table == session_options_table) {
|
} else if (table == session_options_table) {
|
||||||
@@ -166,21 +131,33 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else {
|
else {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
oo = &s->options;
|
oo = &s->options;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx->error(ctx, "unknown table");
|
ctx->error(ctx, "unknown table");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unset or set the option. */
|
/* Unset or set the option. */
|
||||||
if (args_has(args, 'u')) {
|
if (args_has(args, 'u')) {
|
||||||
if (cmd_set_option_unset(self, ctx, oe, oo, valstr) != 0)
|
if (cmd_set_option_unset(self, ctx, oe, oo, valstr) != 0)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
} else {
|
} else {
|
||||||
if (cmd_set_option_set(self, ctx, oe, oo, valstr) != 0)
|
if (cmd_set_option_set(self, ctx, oe, oo, valstr) != 0)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Start or stop timers when automatic-rename changed. */
|
||||||
|
if (strcmp (oe->name, "automatic-rename") == 0) {
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
|
||||||
|
if ((w = ARRAY_ITEM(&windows, i)) == NULL)
|
||||||
|
continue;
|
||||||
|
if (options_get_number(&w->options, "automatic-rename"))
|
||||||
|
queue_window_name(w);
|
||||||
|
else if (event_initialized(&w->name_timer))
|
||||||
|
evtimer_del(&w->name_timer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update sizes and redraw. May not need it but meh. */
|
/* Update sizes and redraw. May not need it but meh. */
|
||||||
@@ -191,7 +168,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unset an option. */
|
/* Unset an option. */
|
||||||
@@ -211,7 +188,8 @@ cmd_set_option_unset(struct cmd *self, struct cmd_ctx *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
options_remove(oo, oe->name);
|
options_remove(oo, oe->name);
|
||||||
ctx->info(ctx, "unset option: %s", oe->name);
|
if (!args_has(args, 'q'))
|
||||||
|
ctx->info(ctx, "unset option: %s", oe->name);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,6 +198,7 @@ int
|
|||||||
cmd_set_option_set(struct cmd *self, struct cmd_ctx *ctx,
|
cmd_set_option_set(struct cmd *self, struct cmd_ctx *ctx,
|
||||||
const struct options_table_entry *oe, struct options *oo, const char *value)
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
{
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
struct options_entry *o;
|
struct options_entry *o;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
@@ -236,8 +215,8 @@ cmd_set_option_set(struct cmd *self, struct cmd_ctx *ctx,
|
|||||||
case OPTIONS_TABLE_NUMBER:
|
case OPTIONS_TABLE_NUMBER:
|
||||||
o = cmd_set_option_number(self, ctx, oe, oo, value);
|
o = cmd_set_option_number(self, ctx, oe, oo, value);
|
||||||
break;
|
break;
|
||||||
case OPTIONS_TABLE_KEYS:
|
case OPTIONS_TABLE_KEY:
|
||||||
o = cmd_set_option_keys(self, ctx, oe, oo, value);
|
o = cmd_set_option_key(self, ctx, oe, oo, value);
|
||||||
break;
|
break;
|
||||||
case OPTIONS_TABLE_COLOUR:
|
case OPTIONS_TABLE_COLOUR:
|
||||||
o = cmd_set_option_colour(self, ctx, oe, oo, value);
|
o = cmd_set_option_colour(self, ctx, oe, oo, value);
|
||||||
@@ -256,7 +235,8 @@ cmd_set_option_set(struct cmd *self, struct cmd_ctx *ctx,
|
|||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
s = options_table_print_entry(oe, o);
|
s = options_table_print_entry(oe, o);
|
||||||
ctx->info(ctx, "set option: %s -> %s", oe->name, s);
|
if (!args_has(args, 'q'))
|
||||||
|
ctx->info(ctx, "set option: %s -> %s", oe->name, s);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +245,7 @@ struct options_entry *
|
|||||||
cmd_set_option_string(struct cmd *self, unused struct cmd_ctx *ctx,
|
cmd_set_option_string(struct cmd *self, unused struct cmd_ctx *ctx,
|
||||||
const struct options_table_entry *oe, struct options *oo, const char *value)
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct options_entry *o;
|
struct options_entry *o;
|
||||||
char *oldval, *newval;
|
char *oldval, *newval;
|
||||||
|
|
||||||
@@ -277,7 +257,7 @@ cmd_set_option_string(struct cmd *self, unused struct cmd_ctx *ctx,
|
|||||||
|
|
||||||
o = options_set_string(oo, oe->name, "%s", newval);
|
o = options_set_string(oo, oe->name, "%s", newval);
|
||||||
|
|
||||||
xfree(newval);
|
free(newval);
|
||||||
return (o);
|
return (o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,31 +278,19 @@ cmd_set_option_number(unused struct cmd *self, struct cmd_ctx *ctx,
|
|||||||
return (options_set_number(oo, oe->name, ll));
|
return (options_set_number(oo, oe->name, ll));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set a keys option. */
|
/* Set a key option. */
|
||||||
struct options_entry *
|
struct options_entry *
|
||||||
cmd_set_option_keys(unused struct cmd *self, struct cmd_ctx *ctx,
|
cmd_set_option_key(unused struct cmd *self, struct cmd_ctx *ctx,
|
||||||
const struct options_table_entry *oe, struct options *oo, const char *value)
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
{
|
{
|
||||||
struct keylist *keylist;
|
int key;
|
||||||
char *copy, *ptr, *s;
|
|
||||||
int key;
|
|
||||||
|
|
||||||
keylist = xmalloc(sizeof *keylist);
|
if ((key = key_string_lookup_string(value)) == KEYC_NONE) {
|
||||||
ARRAY_INIT(keylist);
|
ctx->error(ctx, "bad key: %s", value);
|
||||||
|
return (NULL);
|
||||||
ptr = copy = xstrdup(value);
|
|
||||||
while ((s = strsep(&ptr, ",")) != NULL) {
|
|
||||||
if ((key = key_string_lookup_string(s)) == KEYC_NONE) {
|
|
||||||
ctx->error(ctx, "unknown key: %s", s);
|
|
||||||
xfree(copy);
|
|
||||||
xfree(keylist);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
ARRAY_ADD(keylist, key);
|
|
||||||
}
|
}
|
||||||
xfree(copy);
|
|
||||||
|
|
||||||
return (options_set_data(oo, oe->name, keylist, xfree));
|
return (options_set_number(oo, oe->name, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set a colour option. */
|
/* Set a colour option. */
|
||||||
|
|||||||
@@ -18,13 +18,15 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show a session paste buffer.
|
* Show a paste buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_show_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_buffer_entry = {
|
const struct cmd_entry cmd_show_buffer_entry = {
|
||||||
"show-buffer", "showb",
|
"show-buffer", "showb",
|
||||||
@@ -36,7 +38,7 @@ const struct cmd_entry cmd_show_buffer_entry = {
|
|||||||
cmd_show_buffer_exec
|
cmd_show_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -48,25 +50,25 @@ cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int width;
|
u_int width;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, NULL, 0)) == NULL)
|
if ((s = cmd_find_session(ctx, NULL, 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (!args_has(args, 'b')) {
|
if (!args_has(args, 'b')) {
|
||||||
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
||||||
ctx->error(ctx, "no buffers");
|
ctx->error(ctx, "no buffers");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
pb = paste_get_index(&global_buffers, buffer);
|
pb = paste_get_index(&global_buffers, buffer);
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,9 +103,9 @@ cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
ctx->print(ctx, "%s", buf);
|
ctx->print(ctx, "%s", buf);
|
||||||
}
|
}
|
||||||
xfree(buf);
|
free(buf);
|
||||||
|
|
||||||
xfree(in);
|
free(in);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,19 +27,19 @@
|
|||||||
* Show environment.
|
* Show environment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_environment_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_show_environment_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_environment_entry = {
|
const struct cmd_entry cmd_show_environment_entry = {
|
||||||
"show-environment", "showenv",
|
"show-environment", "showenv",
|
||||||
"gt:", 0, 0,
|
"gt:", 0, 1,
|
||||||
"[-g] " CMD_TARGET_SESSION_USAGE,
|
"[-g] " CMD_TARGET_SESSION_USAGE " [name]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_show_environment_exec
|
cmd_show_environment_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -51,10 +51,23 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
env = &global_environ;
|
env = &global_environ;
|
||||||
else {
|
else {
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
env = &s->environ;
|
env = &s->environ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args->argc != 0) {
|
||||||
|
envent = environ_find(env, args->argv[0]);
|
||||||
|
if (envent == NULL) {
|
||||||
|
ctx->error(ctx, "unknown variable: %s", args->argv[0]);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (envent->value != NULL)
|
||||||
|
ctx->print(ctx, "%s=%s", envent->name, envent->value);
|
||||||
|
else
|
||||||
|
ctx->print(ctx, "-%s", envent->name);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
RB_FOREACH(envent, environ, env) {
|
RB_FOREACH(envent, environ, env) {
|
||||||
if (envent->value != NULL)
|
if (envent->value != NULL)
|
||||||
ctx->print(ctx, "%s=%s", envent->name, envent->value);
|
ctx->print(ctx, "%s=%s", envent->name, envent->value);
|
||||||
@@ -62,5 +75,5 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->print(ctx, "-%s", envent->name);
|
ctx->print(ctx, "-%s", envent->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
* Show client message log.
|
* Show client message log.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_messages_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_show_messages_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_messages_entry = {
|
const struct cmd_entry cmd_show_messages_entry = {
|
||||||
"show-messages", "showmsgs",
|
"show-messages", "showmsgs",
|
||||||
@@ -39,7 +39,7 @@ const struct cmd_entry cmd_show_messages_entry = {
|
|||||||
cmd_show_messages_exec
|
cmd_show_messages_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -49,7 +49,7 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
|
||||||
msg = &ARRAY_ITEM(&c->message_log, i);
|
msg = &ARRAY_ITEM(&c->message_log, i);
|
||||||
@@ -60,5 +60,5 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->print(ctx, "%s %s", tim, msg->msg);
|
ctx->print(ctx, "%s %s", tim, msg->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,12 @@
|
|||||||
* Show options.
|
* Show options.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_options_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_options_entry = {
|
const struct cmd_entry cmd_show_options_entry = {
|
||||||
"show-options", "show",
|
"show-options", "show",
|
||||||
"gst:w", 0, 0,
|
"gst:w", 0, 1,
|
||||||
"[-gsw] [-t target-session|target-window]",
|
"[-gsw] [-t target-session|target-window] [option]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -41,15 +41,15 @@ const struct cmd_entry cmd_show_options_entry = {
|
|||||||
|
|
||||||
const struct cmd_entry cmd_show_window_options_entry = {
|
const struct cmd_entry cmd_show_window_options_entry = {
|
||||||
"show-window-options", "showw",
|
"show-window-options", "showw",
|
||||||
"gt:", 0, 0,
|
"gt:", 0, 1,
|
||||||
"[-g] " CMD_TARGET_WINDOW_USAGE,
|
"[-g] " CMD_TARGET_WINDOW_USAGE " [option]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_show_options_exec
|
cmd_show_options_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -71,7 +71,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else {
|
else {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
oo = &wl->window->options;
|
oo = &wl->window->options;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -81,17 +81,33 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else {
|
else {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
oo = &s->options;
|
oo = &s->options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (oe = table; oe->name != NULL; oe++) {
|
if (args->argc != 0) {
|
||||||
|
table = oe = NULL;
|
||||||
|
if (options_table_find(args->argv[0], &table, &oe) != 0) {
|
||||||
|
ctx->error(ctx, "ambiguous option: %s", args->argv[0]);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (oe == NULL) {
|
||||||
|
ctx->error(ctx, "unknown option: %s", args->argv[0]);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
if ((o = options_find1(oo, oe->name)) == NULL)
|
if ((o = options_find1(oo, oe->name)) == NULL)
|
||||||
continue;
|
return (CMD_RETURN_NORMAL);
|
||||||
optval = options_table_print_entry(oe, o);
|
optval = options_table_print_entry(oe, o);
|
||||||
ctx->print(ctx, "%s %s", oe->name, optval);
|
ctx->print(ctx, "%s %s", oe->name, optval);
|
||||||
|
} else {
|
||||||
|
for (oe = table; oe->name != NULL; oe++) {
|
||||||
|
if ((o = options_find1(oo, oe->name)) == NULL)
|
||||||
|
continue;
|
||||||
|
optval = options_table_print_entry(oe, o);
|
||||||
|
ctx->print(ctx, "%s %s", oe->name, optval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,15 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sources a configuration file.
|
* Sources a configuration file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_source_file_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_source_file_entry = {
|
const struct cmd_entry cmd_source_file_entry = {
|
||||||
"source-file", "source",
|
"source-file", "source",
|
||||||
@@ -36,7 +38,7 @@ const struct cmd_entry cmd_source_file_entry = {
|
|||||||
cmd_source_file_exec
|
cmd_source_file_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -59,13 +61,13 @@ cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
for (i = 0; i < ARRAY_LENGTH(&causes); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&causes); i++) {
|
||||||
cause = ARRAY_ITEM(&causes, i);
|
cause = ARRAY_ITEM(&causes, i);
|
||||||
window_copy_add(wp, "%s", cause);
|
window_copy_add(wp, "%s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < ARRAY_LENGTH(&causes); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&causes); i++) {
|
||||||
cause = ARRAY_ITEM(&causes, i);
|
cause = ARRAY_ITEM(&causes, i);
|
||||||
ctx->print(ctx, "%s", cause);
|
ctx->print(ctx, "%s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ARRAY_FREE(&causes);
|
ARRAY_FREE(&causes);
|
||||||
|
|||||||
@@ -27,13 +27,14 @@
|
|||||||
* Split a window (add a new pane).
|
* Split a window (add a new pane).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_split_window_key_binding(struct cmd *, int);
|
void cmd_split_window_key_binding(struct cmd *, int);
|
||||||
int cmd_split_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_split_window_entry = {
|
const struct cmd_entry cmd_split_window_entry = {
|
||||||
"split-window", "splitw",
|
"split-window", "splitw",
|
||||||
"dl:hp:Pt:v", 0, 1,
|
"c:dF:l:hp:Pt:v", 0, 1,
|
||||||
"[-dhvP] [-p percentage|-l size] [-t target-pane] [command]",
|
"[-dhvP] [-c start-directory] [-F format] [-p percentage|-l size] "
|
||||||
|
"[-t target-pane] [command]",
|
||||||
0,
|
0,
|
||||||
cmd_split_window_key_binding,
|
cmd_split_window_key_binding,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -48,7 +49,7 @@ cmd_split_window_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 'h', NULL);
|
args_set(self->args, 'h', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -57,15 +58,19 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct window *w;
|
struct window *w;
|
||||||
struct window_pane *wp, *new_wp = NULL;
|
struct window_pane *wp, *new_wp = NULL;
|
||||||
struct environ env;
|
struct environ env;
|
||||||
char *cmd, *cwd, *cause;
|
const char *cmd, *cwd, *shell;
|
||||||
const char *shell;
|
char *cause, *new_cause;
|
||||||
u_int hlimit, paneidx;
|
u_int hlimit;
|
||||||
int size, percentage;
|
int size, percentage;
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
struct layout_cell *lc;
|
struct layout_cell *lc;
|
||||||
|
const char *template;
|
||||||
|
struct client *c;
|
||||||
|
struct format_tree *ft;
|
||||||
|
char *cp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
environ_init(&env);
|
environ_init(&env);
|
||||||
@@ -77,13 +82,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cmd = options_get_string(&s->options, "default-command");
|
cmd = options_get_string(&s->options, "default-command");
|
||||||
else
|
else
|
||||||
cmd = args->argv[0];
|
cmd = args->argv[0];
|
||||||
cwd = options_get_string(&s->options, "default-path");
|
cwd = cmd_get_default_path(ctx, args_get(args, 'c'));
|
||||||
if (*cwd == '\0') {
|
|
||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
|
||||||
cwd = ctx->cmdclient->cwd;
|
|
||||||
else
|
|
||||||
cwd = s->cwd;
|
|
||||||
}
|
|
||||||
|
|
||||||
type = LAYOUT_TOPBOTTOM;
|
type = LAYOUT_TOPBOTTOM;
|
||||||
if (args_has(args, 'h'))
|
if (args_has(args, 'h'))
|
||||||
@@ -93,16 +92,18 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (args_has(args, 'l')) {
|
if (args_has(args, 'l')) {
|
||||||
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "size %s", cause);
|
xasprintf(&new_cause, "size %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
cause = new_cause;
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'p')) {
|
} else if (args_has(args, 'p')) {
|
||||||
percentage = args_strtonum(args, 'p', 0, INT_MAX, &cause);
|
percentage = args_strtonum(args, 'p', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "percentage %s", cause);
|
xasprintf(&new_cause, "percentage %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
cause = new_cause;
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
if (type == LAYOUT_TOPBOTTOM)
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
size = (wp->sy * percentage) / 100;
|
size = (wp->sy * percentage) / 100;
|
||||||
@@ -115,7 +116,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (*shell == '\0' || areshell(shell))
|
if (*shell == '\0' || areshell(shell))
|
||||||
shell = _PATH_BSHELL;
|
shell = _PATH_BSHELL;
|
||||||
|
|
||||||
if ((lc = layout_split_pane(wp, type, size)) == NULL) {
|
if ((lc = layout_split_pane(wp, type, size, 0)) == NULL) {
|
||||||
cause = xstrdup("pane too small");
|
cause = xstrdup("pane too small");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@@ -137,16 +138,30 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
|
|
||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
paneidx = window_pane_index(wl->window, new_wp);
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
ctx->print(ctx, "%s:%u.%u", s->name, wl->idx, paneidx);
|
template = SPLIT_WINDOW_TEMPLATE;
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
if ((c = cmd_find_client(ctx, NULL)) != NULL)
|
||||||
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, new_wp);
|
||||||
|
|
||||||
|
cp = format_expand(ft, template);
|
||||||
|
ctx->print(ctx, "%s", cp);
|
||||||
|
free(cp);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
}
|
}
|
||||||
return (0);
|
notify_window_layout_changed(w);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
if (new_wp != NULL)
|
if (new_wp != NULL)
|
||||||
window_remove_pane(w, new_wp);
|
window_remove_pane(w, new_wp);
|
||||||
ctx->error(ctx, "create pane failed: %s", cause);
|
ctx->error(ctx, "create pane failed: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
* Start the server and do nothing else.
|
* Start the server and do nothing else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_start_server_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_start_server_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_start_server_entry = {
|
const struct cmd_entry cmd_start_server_entry = {
|
||||||
"start-server", "start",
|
"start-server", "start",
|
||||||
@@ -37,8 +37,8 @@ const struct cmd_entry cmd_start_server_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_start_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_start_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
27
cmd-string.c
27
cmd-string.c
@@ -87,7 +87,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
xfree(t);
|
free(t);
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
|
if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
|
||||||
@@ -95,7 +95,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
xfree(t);
|
free(t);
|
||||||
break;
|
break;
|
||||||
case '$':
|
case '$':
|
||||||
if ((t = cmd_string_variable(s, &p)) == NULL)
|
if ((t = cmd_string_variable(s, &p)) == NULL)
|
||||||
@@ -103,7 +103,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
xfree(t);
|
free(t);
|
||||||
break;
|
break;
|
||||||
case '#':
|
case '#':
|
||||||
/* Comment: discard rest of line. */
|
/* Comment: discard rest of line. */
|
||||||
@@ -152,7 +152,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
xfree(t);
|
free(t);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
@@ -170,13 +170,12 @@ error:
|
|||||||
xasprintf(cause, "invalid or unknown command: %s", s);
|
xasprintf(cause, "invalid or unknown command: %s", s);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (buf != NULL)
|
free(buf);
|
||||||
xfree(buf);
|
|
||||||
|
|
||||||
if (argv != NULL) {
|
if (argv != NULL) {
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
xfree(argv[i]);
|
free(argv[i]);
|
||||||
xfree(argv);
|
free(argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (rval);
|
return (rval);
|
||||||
@@ -224,7 +223,7 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
|||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
xfree(t);
|
free(t);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,8 +238,7 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
|||||||
return (buf);
|
return (buf);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (buf != NULL)
|
free(buf);
|
||||||
xfree(buf);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,14 +301,13 @@ cmd_string_variable(const char *s, size_t *p)
|
|||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
envent = environ_find(&global_environ, buf);
|
envent = environ_find(&global_environ, buf);
|
||||||
xfree(buf);
|
free(buf);
|
||||||
if (envent == NULL)
|
if (envent == NULL)
|
||||||
return (xstrdup(""));
|
return (xstrdup(""));
|
||||||
return (xstrdup(envent->value));
|
return (xstrdup(envent->value));
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (buf != NULL)
|
free(buf);
|
||||||
xfree(buf);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +331,7 @@ cmd_string_expand_tilde(const char *s, size_t *p)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
if ((pw = getpwnam(username)) != NULL)
|
if ((pw = getpwnam(username)) != NULL)
|
||||||
home = pw->pw_dir;
|
home = pw->pw_dir;
|
||||||
xfree(username);
|
free(username);
|
||||||
}
|
}
|
||||||
if (home == NULL)
|
if (home == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
* Suspend client with SIGTSTP.
|
* Suspend client with SIGTSTP.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_suspend_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_suspend_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_suspend_client_entry = {
|
const struct cmd_entry cmd_suspend_client_entry = {
|
||||||
"suspend-client", "suspendc",
|
"suspend-client", "suspendc",
|
||||||
@@ -39,18 +39,18 @@ const struct cmd_entry cmd_suspend_client_entry = {
|
|||||||
cmd_suspend_client_exec
|
cmd_suspend_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_suspend_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_suspend_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
tty_stop_tty(&c->tty);
|
tty_stop_tty(&c->tty);
|
||||||
c->flags |= CLIENT_SUSPENDED;
|
c->flags |= CLIENT_SUSPENDED;
|
||||||
server_write_client(c, MSG_SUSPEND, NULL, 0);
|
server_write_client(c, MSG_SUSPEND, NULL, 0);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
* Swap two panes.
|
* Swap two panes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_swap_pane_key_binding(struct cmd *, int);
|
void cmd_swap_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_swap_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_swap_pane_entry = {
|
const struct cmd_entry cmd_swap_pane_entry = {
|
||||||
"swap-pane", "swapp",
|
"swap-pane", "swapp",
|
||||||
@@ -49,7 +49,7 @@ cmd_swap_pane_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 'D', NULL);
|
args_set(self->args, 'D', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -61,7 +61,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
dst_wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &dst_wp);
|
dst_wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &dst_wp);
|
||||||
if (dst_wl == NULL)
|
if (dst_wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
dst_w = dst_wl->window;
|
dst_w = dst_wl->window;
|
||||||
|
|
||||||
if (!args_has(args, 's')) {
|
if (!args_has(args, 's')) {
|
||||||
@@ -75,16 +75,16 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (src_wp == NULL)
|
if (src_wp == NULL)
|
||||||
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
||||||
} else
|
} else
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
} else {
|
} else {
|
||||||
src_wl = cmd_find_pane(ctx, args_get(args, 's'), NULL, &src_wp);
|
src_wl = cmd_find_pane(ctx, args_get(args, 's'), NULL, &src_wp);
|
||||||
if (src_wl == NULL)
|
if (src_wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
src_w = src_wl->window;
|
src_w = src_wl->window;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src_wp == dst_wp)
|
if (src_wp == dst_wp)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
tmp_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
tmp_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||||
TAILQ_REMOVE(&dst_w->panes, dst_wp, entry);
|
TAILQ_REMOVE(&dst_w->panes, dst_wp, entry);
|
||||||
@@ -138,5 +138,5 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_window(src_w);
|
server_redraw_window(src_w);
|
||||||
server_redraw_window(dst_w);
|
server_redraw_window(dst_w);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const struct cmd_entry cmd_swap_window_entry = {
|
|||||||
cmd_swap_window_exec
|
cmd_swap_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -50,21 +50,21 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
target_src = args_get(args, 's');
|
target_src = args_get(args, 's');
|
||||||
if ((wl_src = cmd_find_window(ctx, target_src, &src)) == NULL)
|
if ((wl_src = cmd_find_window(ctx, target_src, &src)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
target_dst = args_get(args, 't');
|
target_dst = args_get(args, 't');
|
||||||
if ((wl_dst = cmd_find_window(ctx, target_dst, &dst)) == NULL)
|
if ((wl_dst = cmd_find_window(ctx, target_dst, &dst)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
sg_src = session_group_find(src);
|
sg_src = session_group_find(src);
|
||||||
sg_dst = session_group_find(dst);
|
sg_dst = session_group_find(dst);
|
||||||
if (src != dst &&
|
if (src != dst &&
|
||||||
sg_src != NULL && sg_dst != NULL && sg_src == sg_dst) {
|
sg_src != NULL && sg_dst != NULL && sg_src == sg_dst) {
|
||||||
ctx->error(ctx, "can't move window, sessions are grouped");
|
ctx->error(ctx, "can't move window, sessions are grouped");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_dst->window == wl_src->window)
|
if (wl_dst->window == wl_src->window)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
w = wl_dst->window;
|
w = wl_dst->window;
|
||||||
wl_dst->window = wl_src->window;
|
wl_dst->window = wl_src->window;
|
||||||
@@ -83,5 +83,5 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,14 +27,14 @@
|
|||||||
* Switch client to a different session.
|
* Switch client to a different session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_switch_client_key_binding(struct cmd *, int);
|
void cmd_switch_client_key_binding(struct cmd *, int);
|
||||||
int cmd_switch_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_switch_client_entry = {
|
const struct cmd_entry cmd_switch_client_entry = {
|
||||||
"switch-client", "switchc",
|
"switch-client", "switchc",
|
||||||
"lc:npt:", 0, 0,
|
"lc:npt:r", 0, 0,
|
||||||
"[-lnp] [-c target-client] [-t target-session]",
|
"[-lnpr] [-c target-client] [-t target-session]",
|
||||||
0,
|
CMD_READONLY,
|
||||||
cmd_switch_client_key_binding,
|
cmd_switch_client_key_binding,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_switch_client_exec
|
cmd_switch_client_exec
|
||||||
@@ -57,7 +57,7 @@ cmd_switch_client_key_binding(struct cmd *self, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -65,30 +65,40 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if (args_has(args, 'r')) {
|
||||||
|
if (c->flags & CLIENT_READONLY) {
|
||||||
|
c->flags &= ~CLIENT_READONLY;
|
||||||
|
ctx->info(ctx, "made client writable");
|
||||||
|
} else {
|
||||||
|
c->flags |= CLIENT_READONLY;
|
||||||
|
ctx->info(ctx, "made client read-only");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s = NULL;
|
s = NULL;
|
||||||
if (args_has(args, 'n')) {
|
if (args_has(args, 'n')) {
|
||||||
if ((s = session_next_session(c->session)) == NULL) {
|
if ((s = session_next_session(c->session)) == NULL) {
|
||||||
ctx->error(ctx, "can't find next session");
|
ctx->error(ctx, "can't find next session");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'p')) {
|
} else if (args_has(args, 'p')) {
|
||||||
if ((s = session_previous_session(c->session)) == NULL) {
|
if ((s = session_previous_session(c->session)) == NULL) {
|
||||||
ctx->error(ctx, "can't find previous session");
|
ctx->error(ctx, "can't find previous session");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'l')) {
|
} else if (args_has(args, 'l')) {
|
||||||
if (c->last_session != NULL && session_alive(c->last_session))
|
if (c->last_session != NULL && session_alive(c->last_session))
|
||||||
s = c->last_session;
|
s = c->last_session;
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
ctx->error(ctx, "can't find last session");
|
ctx->error(ctx, "can't find last session");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (c->session != NULL)
|
if (c->session != NULL)
|
||||||
c->last_session = c->session;
|
c->last_session = c->session;
|
||||||
@@ -98,6 +108,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_check_unattached();
|
server_check_unattached();
|
||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,16 +18,17 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unbind key from command.
|
* Unbind key from command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_unbind_key_check(struct args *);
|
enum cmd_retval cmd_unbind_key_check(struct args *);
|
||||||
int cmd_unbind_key_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
enum cmd_retval cmd_unbind_key_table(struct cmd *, struct cmd_ctx *, int);
|
||||||
int cmd_unbind_key_table(struct cmd *, struct cmd_ctx *, int);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_unbind_key_entry = {
|
const struct cmd_entry cmd_unbind_key_entry = {
|
||||||
"unbind-key", "unbind",
|
"unbind-key", "unbind",
|
||||||
@@ -39,49 +40,50 @@ const struct cmd_entry cmd_unbind_key_entry = {
|
|||||||
cmd_unbind_key_exec
|
cmd_unbind_key_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_unbind_key_check(struct args *args)
|
cmd_unbind_key_check(struct args *args)
|
||||||
{
|
{
|
||||||
if (args_has(args, 'a') && (args->argc != 0 || args_has(args, 't')))
|
if (args_has(args, 'a') && args->argc != 0)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
if (!args_has(args, 'a') && args->argc != 1)
|
if (!args_has(args, 'a') && args->argc != 1)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
if (!args_has(args, 'a')) {
|
||||||
while (!SPLAY_EMPTY(&key_bindings)) {
|
key = key_string_lookup_string(args->argv[0]);
|
||||||
bd = SPLAY_ROOT(&key_bindings);
|
if (key == KEYC_NONE) {
|
||||||
SPLAY_REMOVE(key_bindings, &key_bindings, bd);
|
ctx->error(ctx, "unknown key: %s", args->argv[0]);
|
||||||
cmd_list_free(bd->cmdlist);
|
return (CMD_RETURN_ERROR);
|
||||||
xfree(bd);
|
|
||||||
}
|
}
|
||||||
return (0);
|
} else
|
||||||
}
|
key = KEYC_NONE;
|
||||||
|
|
||||||
key = key_string_lookup_string(args->argv[0]);
|
|
||||||
if (key == KEYC_NONE) {
|
|
||||||
ctx->error(ctx, "unknown key: %s", args->argv[0]);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args_has(args, 't'))
|
if (args_has(args, 't'))
|
||||||
return (cmd_unbind_key_table(self, ctx, key));
|
return (cmd_unbind_key_table(self, ctx, key));
|
||||||
|
|
||||||
|
if (key == KEYC_NONE) {
|
||||||
|
while (!RB_EMPTY(&key_bindings)) {
|
||||||
|
bd = RB_ROOT(&key_bindings);
|
||||||
|
key_bindings_remove(bd->key);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (!args_has(args, 'n'))
|
if (!args_has(args, 'n'))
|
||||||
key |= KEYC_PREFIX;
|
key |= KEYC_PREFIX;
|
||||||
key_bindings_remove(key);
|
key_bindings_remove(key);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -92,14 +94,23 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
|||||||
tablename = args_get(args, 't');
|
tablename = args_get(args, 't');
|
||||||
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
||||||
ctx->error(ctx, "unknown key table: %s", tablename);
|
ctx->error(ctx, "unknown key table: %s", tablename);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == KEYC_NONE) {
|
||||||
|
while (!RB_EMPTY(mtab->tree)) {
|
||||||
|
mbind = RB_ROOT(mtab->tree);
|
||||||
|
RB_REMOVE(mode_key_tree, mtab->tree, mbind);
|
||||||
|
free(mbind);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtmp.key = key;
|
mtmp.key = key;
|
||||||
mtmp.mode = !!args_has(args, 'c');
|
mtmp.mode = !!args_has(args, 'c');
|
||||||
if ((mbind = SPLAY_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {
|
if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {
|
||||||
SPLAY_REMOVE(mode_key_tree, mtab->tree, mbind);
|
RB_REMOVE(mode_key_tree, mtab->tree, mbind);
|
||||||
xfree(mbind);
|
free(mbind);
|
||||||
}
|
}
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
* Unlink a window, unless it would be destroyed by doing so (only one link).
|
* Unlink a window, unless it would be destroyed by doing so (only one link).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_unlink_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_unlink_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_unlink_window_entry = {
|
const struct cmd_entry cmd_unlink_window_entry = {
|
||||||
"unlink-window", "unlinkw",
|
"unlink-window", "unlinkw",
|
||||||
@@ -36,7 +36,7 @@ const struct cmd_entry cmd_unlink_window_entry = {
|
|||||||
cmd_unlink_window_exec
|
cmd_unlink_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_unlink_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_unlink_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@@ -47,7 +47,7 @@ cmd_unlink_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int references;
|
u_int references;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
sg = session_group_find(s);
|
sg = session_group_find(s);
|
||||||
@@ -60,11 +60,11 @@ cmd_unlink_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (!args_has(self->args, 'k') && w->references == references) {
|
if (!args_has(self->args, 'k') && w->references == references) {
|
||||||
ctx->error(ctx, "window is only linked to one session");
|
ctx->error(ctx, "window is only linked to one session");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
server_unlink_window(s, wl);
|
server_unlink_window(s, wl);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
214
cmd.c
214
cmd.c
@@ -20,6 +20,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
|
#include <pwd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -33,7 +34,9 @@ const struct cmd_entry *cmd_table[] = {
|
|||||||
&cmd_capture_pane_entry,
|
&cmd_capture_pane_entry,
|
||||||
&cmd_choose_buffer_entry,
|
&cmd_choose_buffer_entry,
|
||||||
&cmd_choose_client_entry,
|
&cmd_choose_client_entry,
|
||||||
|
&cmd_choose_list_entry,
|
||||||
&cmd_choose_session_entry,
|
&cmd_choose_session_entry,
|
||||||
|
&cmd_choose_tree_entry,
|
||||||
&cmd_choose_window_entry,
|
&cmd_choose_window_entry,
|
||||||
&cmd_clear_history_entry,
|
&cmd_clear_history_entry,
|
||||||
&cmd_clock_mode_entry,
|
&cmd_clock_mode_entry,
|
||||||
@@ -66,6 +69,7 @@ const struct cmd_entry *cmd_table[] = {
|
|||||||
&cmd_lock_client_entry,
|
&cmd_lock_client_entry,
|
||||||
&cmd_lock_server_entry,
|
&cmd_lock_server_entry,
|
||||||
&cmd_lock_session_entry,
|
&cmd_lock_session_entry,
|
||||||
|
&cmd_move_pane_entry,
|
||||||
&cmd_move_window_entry,
|
&cmd_move_window_entry,
|
||||||
&cmd_new_session_entry,
|
&cmd_new_session_entry,
|
||||||
&cmd_new_window_entry,
|
&cmd_new_window_entry,
|
||||||
@@ -119,8 +123,10 @@ struct session *cmd_lookup_session(const char *, int *);
|
|||||||
struct winlink *cmd_lookup_window(struct session *, const char *, int *);
|
struct winlink *cmd_lookup_window(struct session *, const char *, int *);
|
||||||
int cmd_lookup_index(struct session *, const char *, int *);
|
int cmd_lookup_index(struct session *, const char *, int *);
|
||||||
struct window_pane *cmd_lookup_paneid(const char *);
|
struct window_pane *cmd_lookup_paneid(const char *);
|
||||||
struct session *cmd_pane_session(struct cmd_ctx *,
|
struct winlink *cmd_lookup_winlink_windowid(struct session *, const char *);
|
||||||
struct window_pane *, struct winlink **);
|
struct window *cmd_lookup_windowid(const char *);
|
||||||
|
struct session *cmd_window_session(struct cmd_ctx *,
|
||||||
|
struct window *, struct winlink **);
|
||||||
struct winlink *cmd_find_window_offset(const char *, struct session *, int *);
|
struct winlink *cmd_find_window_offset(const char *, struct session *, int *);
|
||||||
int cmd_find_index_offset(const char *, struct session *, int *);
|
int cmd_find_index_offset(const char *, struct session *, int *);
|
||||||
struct window_pane *cmd_find_pane_offset(const char *, struct winlink *);
|
struct window_pane *cmd_find_pane_offset(const char *, struct winlink *);
|
||||||
@@ -192,11 +198,9 @@ cmd_free_argv(int argc, char **argv)
|
|||||||
|
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
return;
|
return;
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++)
|
||||||
if (argv[i] != NULL)
|
free(argv[i]);
|
||||||
xfree(argv[i]);
|
free(argv);
|
||||||
}
|
|
||||||
xfree(argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd *
|
struct cmd *
|
||||||
@@ -276,7 +280,7 @@ usage:
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_exec(struct cmd *cmd, struct cmd_ctx *ctx)
|
cmd_exec(struct cmd *cmd, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
return (cmd->entry->exec(cmd, ctx));
|
return (cmd->entry->exec(cmd, ctx));
|
||||||
@@ -285,9 +289,8 @@ cmd_exec(struct cmd *cmd, struct cmd_ctx *ctx)
|
|||||||
void
|
void
|
||||||
cmd_free(struct cmd *cmd)
|
cmd_free(struct cmd *cmd)
|
||||||
{
|
{
|
||||||
if (cmd->args != NULL)
|
args_free(cmd->args);
|
||||||
args_free(cmd->args);
|
free(cmd);
|
||||||
xfree(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
@@ -299,11 +302,10 @@ cmd_print(struct cmd *cmd, char *buf, size_t len)
|
|||||||
if (off < len) {
|
if (off < len) {
|
||||||
used = args_print(cmd->args, buf + off, len - off);
|
used = args_print(cmd->args, buf + off, len - off);
|
||||||
if (used == 0)
|
if (used == 0)
|
||||||
buf[off - 1] = '\0';
|
off--;
|
||||||
else {
|
else
|
||||||
off += used;
|
off += used;
|
||||||
buf[off] = '\0';
|
buf[off] = '\0';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (off);
|
return (off);
|
||||||
}
|
}
|
||||||
@@ -502,7 +504,7 @@ cmd_find_client(struct cmd_ctx *ctx, const char *arg)
|
|||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
ctx->error(ctx, "client not found: %s", tmparg);
|
ctx->error(ctx, "client not found: %s", tmparg);
|
||||||
|
|
||||||
xfree(tmparg);
|
free(tmparg);
|
||||||
return (c);
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,6 +588,10 @@ cmd_lookup_window(struct session *s, const char *name, int *ambiguous)
|
|||||||
|
|
||||||
*ambiguous = 0;
|
*ambiguous = 0;
|
||||||
|
|
||||||
|
/* Try as a window id. */
|
||||||
|
if ((wl = cmd_lookup_winlink_windowid(s, name)) != NULL)
|
||||||
|
return (wl);
|
||||||
|
|
||||||
/* First see if this is a valid window index in this session. */
|
/* First see if this is a valid window index in this session. */
|
||||||
idx = strtonum(name, 0, INT_MAX, &errstr);
|
idx = strtonum(name, 0, INT_MAX, &errstr);
|
||||||
if (errstr == NULL) {
|
if (errstr == NULL) {
|
||||||
@@ -648,10 +654,7 @@ cmd_lookup_index(struct session *s, const char *name, int *ambiguous)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Lookup pane id. An initial % means a pane id. */
|
||||||
* Lookup pane id. An initial % means a pane id. sp must already point to the
|
|
||||||
* current session.
|
|
||||||
*/
|
|
||||||
struct window_pane *
|
struct window_pane *
|
||||||
cmd_lookup_paneid(const char *arg)
|
cmd_lookup_paneid(const char *arg)
|
||||||
{
|
{
|
||||||
@@ -667,19 +670,50 @@ cmd_lookup_paneid(const char *arg)
|
|||||||
return (window_pane_find_by_id(paneid));
|
return (window_pane_find_by_id(paneid));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find session and winlink for pane. */
|
/* Lookup window id in a session. An initial @ means a window id. */
|
||||||
|
struct winlink *
|
||||||
|
cmd_lookup_winlink_windowid(struct session *s, const char *arg)
|
||||||
|
{
|
||||||
|
const char *errstr;
|
||||||
|
u_int windowid;
|
||||||
|
|
||||||
|
if (*arg != '@')
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
windowid = strtonum(arg + 1, 0, UINT_MAX, &errstr);
|
||||||
|
if (errstr != NULL)
|
||||||
|
return (NULL);
|
||||||
|
return (winlink_find_by_window_id(&s->windows, windowid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Lookup window id. An initial @ means a window id. */
|
||||||
|
struct window *
|
||||||
|
cmd_lookup_windowid(const char *arg)
|
||||||
|
{
|
||||||
|
const char *errstr;
|
||||||
|
u_int windowid;
|
||||||
|
|
||||||
|
if (*arg != '@')
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
windowid = strtonum(arg + 1, 0, UINT_MAX, &errstr);
|
||||||
|
if (errstr != NULL)
|
||||||
|
return (NULL);
|
||||||
|
return (window_find_by_id(windowid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find session and winlink for window. */
|
||||||
struct session *
|
struct session *
|
||||||
cmd_pane_session(struct cmd_ctx *ctx, struct window_pane *wp,
|
cmd_window_session(struct cmd_ctx *ctx, struct window *w, struct winlink **wlp)
|
||||||
struct winlink **wlp)
|
|
||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct sessionslist ss;
|
struct sessionslist ss;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
|
||||||
/* If this pane is in the current session, return that winlink. */
|
/* If this window is in the current session, return that winlink. */
|
||||||
s = cmd_current_session(ctx, 0);
|
s = cmd_current_session(ctx, 0);
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
wl = winlink_find_by_window(&s->windows, wp->window);
|
wl = winlink_find_by_window(&s->windows, w);
|
||||||
if (wl != NULL) {
|
if (wl != NULL) {
|
||||||
if (wlp != NULL)
|
if (wlp != NULL)
|
||||||
*wlp = wl;
|
*wlp = wl;
|
||||||
@@ -687,16 +721,16 @@ cmd_pane_session(struct cmd_ctx *ctx, struct window_pane *wp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise choose from all sessions with this pane. */
|
/* Otherwise choose from all sessions with this window. */
|
||||||
ARRAY_INIT(&ss);
|
ARRAY_INIT(&ss);
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
if (winlink_find_by_window(&s->windows, wp->window) != NULL)
|
if (winlink_find_by_window(&s->windows, w) != NULL)
|
||||||
ARRAY_ADD(&ss, s);
|
ARRAY_ADD(&ss, s);
|
||||||
}
|
}
|
||||||
s = cmd_choose_session_list(&ss);
|
s = cmd_choose_session_list(&ss);
|
||||||
ARRAY_FREE(&ss);
|
ARRAY_FREE(&ss);
|
||||||
if (wlp != NULL)
|
if (wlp != NULL)
|
||||||
*wlp = winlink_find_by_window(&s->windows, wp->window);
|
*wlp = winlink_find_by_window(&s->windows, w);
|
||||||
return (s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -706,6 +740,7 @@ cmd_find_session(struct cmd_ctx *ctx, const char *arg, int prefer_unattached)
|
|||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
struct window *w;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
char *tmparg;
|
char *tmparg;
|
||||||
size_t arglen;
|
size_t arglen;
|
||||||
@@ -715,9 +750,11 @@ cmd_find_session(struct cmd_ctx *ctx, const char *arg, int prefer_unattached)
|
|||||||
if (arg == NULL)
|
if (arg == NULL)
|
||||||
return (cmd_current_session(ctx, prefer_unattached));
|
return (cmd_current_session(ctx, prefer_unattached));
|
||||||
|
|
||||||
/* Lookup as pane id. */
|
/* Lookup as pane id or window id. */
|
||||||
if ((wp = cmd_lookup_paneid(arg)) != NULL)
|
if ((wp = cmd_lookup_paneid(arg)) != NULL)
|
||||||
return (cmd_pane_session(ctx, wp, NULL));
|
return (cmd_window_session(ctx, wp->window, NULL));
|
||||||
|
if ((w = cmd_lookup_windowid(arg)) != NULL)
|
||||||
|
return (cmd_window_session(ctx, w, NULL));
|
||||||
|
|
||||||
/* Trim a single trailing colon if any. */
|
/* Trim a single trailing colon if any. */
|
||||||
tmparg = xstrdup(arg);
|
tmparg = xstrdup(arg);
|
||||||
@@ -727,7 +764,7 @@ cmd_find_session(struct cmd_ctx *ctx, const char *arg, int prefer_unattached)
|
|||||||
|
|
||||||
/* An empty session name is the current session. */
|
/* An empty session name is the current session. */
|
||||||
if (*tmparg == '\0') {
|
if (*tmparg == '\0') {
|
||||||
xfree(tmparg);
|
free(tmparg);
|
||||||
return (cmd_current_session(ctx, prefer_unattached));
|
return (cmd_current_session(ctx, prefer_unattached));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,7 +783,7 @@ cmd_find_session(struct cmd_ctx *ctx, const char *arg, int prefer_unattached)
|
|||||||
ctx->error(ctx, "session not found: %s", tmparg);
|
ctx->error(ctx, "session not found: %s", tmparg);
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(tmparg);
|
free(tmparg);
|
||||||
return (s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -779,7 +816,7 @@ cmd_find_window(struct cmd_ctx *ctx, const char *arg, struct session **sp)
|
|||||||
|
|
||||||
/* Lookup as pane id. */
|
/* Lookup as pane id. */
|
||||||
if ((wp = cmd_lookup_paneid(arg)) != NULL) {
|
if ((wp = cmd_lookup_paneid(arg)) != NULL) {
|
||||||
s = cmd_pane_session(ctx, wp, &wl);
|
s = cmd_window_session(ctx, wp->window, &wl);
|
||||||
if (sp != NULL)
|
if (sp != NULL)
|
||||||
*sp = s;
|
*sp = s;
|
||||||
return (wl);
|
return (wl);
|
||||||
@@ -821,7 +858,7 @@ cmd_find_window(struct cmd_ctx *ctx, const char *arg, struct session **sp)
|
|||||||
goto not_found;
|
goto not_found;
|
||||||
|
|
||||||
if (sessptr != NULL)
|
if (sessptr != NULL)
|
||||||
xfree(sessptr);
|
free(sessptr);
|
||||||
return (wl);
|
return (wl);
|
||||||
|
|
||||||
no_colon:
|
no_colon:
|
||||||
@@ -859,8 +896,7 @@ no_session:
|
|||||||
ctx->error(ctx, "multiple sessions: %s", arg);
|
ctx->error(ctx, "multiple sessions: %s", arg);
|
||||||
else
|
else
|
||||||
ctx->error(ctx, "session not found: %s", arg);
|
ctx->error(ctx, "session not found: %s", arg);
|
||||||
if (sessptr != NULL)
|
free(sessptr);
|
||||||
xfree(sessptr);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
not_found:
|
not_found:
|
||||||
@@ -868,8 +904,7 @@ not_found:
|
|||||||
ctx->error(ctx, "multiple windows: %s", arg);
|
ctx->error(ctx, "multiple windows: %s", arg);
|
||||||
else
|
else
|
||||||
ctx->error(ctx, "window not found: %s", arg);
|
ctx->error(ctx, "window not found: %s", arg);
|
||||||
if (sessptr != NULL)
|
free(sessptr);
|
||||||
xfree(sessptr);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -960,8 +995,7 @@ cmd_find_index(struct cmd_ctx *ctx, const char *arg, struct session **sp)
|
|||||||
} else if ((idx = cmd_lookup_index(s, winptr, &ambiguous)) == -1)
|
} else if ((idx = cmd_lookup_index(s, winptr, &ambiguous)) == -1)
|
||||||
goto invalid_index;
|
goto invalid_index;
|
||||||
|
|
||||||
if (sessptr != NULL)
|
free(sessptr);
|
||||||
xfree(sessptr);
|
|
||||||
return (idx);
|
return (idx);
|
||||||
|
|
||||||
no_colon:
|
no_colon:
|
||||||
@@ -1000,8 +1034,7 @@ no_session:
|
|||||||
ctx->error(ctx, "multiple sessions: %s", arg);
|
ctx->error(ctx, "multiple sessions: %s", arg);
|
||||||
else
|
else
|
||||||
ctx->error(ctx, "session not found: %s", arg);
|
ctx->error(ctx, "session not found: %s", arg);
|
||||||
if (sessptr != NULL)
|
free(sessptr);
|
||||||
xfree(sessptr);
|
|
||||||
return (-2);
|
return (-2);
|
||||||
|
|
||||||
invalid_index:
|
invalid_index:
|
||||||
@@ -1009,8 +1042,7 @@ invalid_index:
|
|||||||
goto not_found;
|
goto not_found;
|
||||||
ctx->error(ctx, "invalid index: %s", arg);
|
ctx->error(ctx, "invalid index: %s", arg);
|
||||||
|
|
||||||
if (sessptr != NULL)
|
free(sessptr);
|
||||||
xfree(sessptr);
|
|
||||||
return (-2);
|
return (-2);
|
||||||
|
|
||||||
not_found:
|
not_found:
|
||||||
@@ -1018,8 +1050,7 @@ not_found:
|
|||||||
ctx->error(ctx, "multiple windows: %s", arg);
|
ctx->error(ctx, "multiple windows: %s", arg);
|
||||||
else
|
else
|
||||||
ctx->error(ctx, "window not found: %s", arg);
|
ctx->error(ctx, "window not found: %s", arg);
|
||||||
if (sessptr != NULL)
|
free(sessptr);
|
||||||
xfree(sessptr);
|
|
||||||
return (-2);
|
return (-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,7 +1111,7 @@ cmd_find_pane(struct cmd_ctx *ctx,
|
|||||||
|
|
||||||
/* Lookup as pane id. */
|
/* Lookup as pane id. */
|
||||||
if ((*wpp = cmd_lookup_paneid(arg)) != NULL) {
|
if ((*wpp = cmd_lookup_paneid(arg)) != NULL) {
|
||||||
s = cmd_pane_session(ctx, *wpp, &wl);
|
s = cmd_window_session(ctx, (*wpp)->window, &wl);
|
||||||
if (sp != NULL)
|
if (sp != NULL)
|
||||||
*sp = s;
|
*sp = s;
|
||||||
return (wl);
|
return (wl);
|
||||||
@@ -1113,7 +1144,7 @@ cmd_find_pane(struct cmd_ctx *ctx,
|
|||||||
goto lookup_string;
|
goto lookup_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(winptr);
|
free(winptr);
|
||||||
return (wl);
|
return (wl);
|
||||||
|
|
||||||
lookup_string:
|
lookup_string:
|
||||||
@@ -1123,7 +1154,7 @@ lookup_string:
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(winptr);
|
free(winptr);
|
||||||
return (wl);
|
return (wl);
|
||||||
|
|
||||||
no_period:
|
no_period:
|
||||||
@@ -1149,7 +1180,7 @@ lookup_window:
|
|||||||
return (wl);
|
return (wl);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
xfree(winptr);
|
free(winptr);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1212,3 +1243,86 @@ cmd_template_replace(char *template, const char *s, int idx)
|
|||||||
|
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the default path for a new pane, using the given path or the
|
||||||
|
* default-path option if it is NULL. Several special values are accepted: the
|
||||||
|
* empty string or relative path for the current pane's working directory, ~
|
||||||
|
* for the user's home, - for the session working directory, . for the tmux
|
||||||
|
* server's working directory. The default on failure is the session's working
|
||||||
|
* directory.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
cmd_get_default_path(struct cmd_ctx *ctx, const char *cwd)
|
||||||
|
{
|
||||||
|
struct session *s;
|
||||||
|
struct environ_entry *envent;
|
||||||
|
const char *root;
|
||||||
|
char tmp[MAXPATHLEN];
|
||||||
|
struct passwd *pw;
|
||||||
|
int n;
|
||||||
|
size_t skip;
|
||||||
|
static char path[MAXPATHLEN];
|
||||||
|
|
||||||
|
if ((s = cmd_current_session(ctx, 0)) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
if (cwd == NULL)
|
||||||
|
cwd = options_get_string(&s->options, "default-path");
|
||||||
|
|
||||||
|
skip = 1;
|
||||||
|
if (strcmp(cwd, "$HOME") == 0 || strncmp(cwd, "$HOME/", 6) == 0) {
|
||||||
|
/* User's home directory - $HOME. */
|
||||||
|
skip = 5;
|
||||||
|
goto find_home;
|
||||||
|
} else if (cwd[0] == '~' && (cwd[1] == '\0' || cwd[1] == '/')) {
|
||||||
|
/* User's home directory - ~. */
|
||||||
|
goto find_home;
|
||||||
|
} else if (cwd[0] == '-' && (cwd[1] == '\0' || cwd[1] == '/')) {
|
||||||
|
/* Session working directory. */
|
||||||
|
root = s->cwd;
|
||||||
|
goto complete_path;
|
||||||
|
} else if (cwd[0] == '.' && (cwd[1] == '\0' || cwd[1] == '/')) {
|
||||||
|
/* Server working directory. */
|
||||||
|
if (getcwd(tmp, sizeof tmp) != NULL) {
|
||||||
|
root = tmp;
|
||||||
|
goto complete_path;
|
||||||
|
}
|
||||||
|
return (s->cwd);
|
||||||
|
} else if (*cwd == '/') {
|
||||||
|
/* Absolute path. */
|
||||||
|
return (cwd);
|
||||||
|
} else {
|
||||||
|
/* Empty or relative path. */
|
||||||
|
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||||
|
root = ctx->cmdclient->cwd;
|
||||||
|
else if (ctx->curclient != NULL && s->curw != NULL)
|
||||||
|
root = osdep_get_cwd(s->curw->window->active->fd);
|
||||||
|
else
|
||||||
|
return (s->cwd);
|
||||||
|
skip = 0;
|
||||||
|
if (root != NULL)
|
||||||
|
goto complete_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (s->cwd);
|
||||||
|
|
||||||
|
find_home:
|
||||||
|
envent = environ_find(&global_environ, "HOME");
|
||||||
|
if (envent != NULL && *envent->value != '\0')
|
||||||
|
root = envent->value;
|
||||||
|
else if ((pw = getpwuid(getuid())) != NULL)
|
||||||
|
root = pw->pw_dir;
|
||||||
|
else
|
||||||
|
return (s->cwd);
|
||||||
|
|
||||||
|
complete_path:
|
||||||
|
if (root[skip] == '\0') {
|
||||||
|
strlcpy(path, root, sizeof path);
|
||||||
|
return (path);
|
||||||
|
}
|
||||||
|
n = snprintf(path, sizeof path, "%s/%s", root, cwd + skip);
|
||||||
|
if (n > 0 && (size_t)n < sizeof path)
|
||||||
|
return (path);
|
||||||
|
return (s->cwd);
|
||||||
|
}
|
||||||
|
|||||||
52
colour.c
52
colour.c
@@ -19,7 +19,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <math.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ struct colour_rgb {
|
|||||||
struct colour_rgb *colour_rgb_256;
|
struct colour_rgb *colour_rgb_256;
|
||||||
|
|
||||||
void colour_rgb_generate256(void);
|
void colour_rgb_generate256(void);
|
||||||
double colour_rgb_distance(struct colour_rgb *, struct colour_rgb *);
|
u_int colour_rgb_distance(struct colour_rgb *, struct colour_rgb *);
|
||||||
int colour_rgb_find(struct colour_rgb *);
|
int colour_rgb_find(struct colour_rgb *);
|
||||||
|
|
||||||
/* Generate 256 colour RGB table. */
|
/* Generate 256 colour RGB table. */
|
||||||
@@ -91,7 +90,7 @@ colour_rgb_generate256(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get colour RGB distance. */
|
/* Get colour RGB distance. */
|
||||||
double
|
u_int
|
||||||
colour_rgb_distance(struct colour_rgb *rgb1, struct colour_rgb *rgb2)
|
colour_rgb_distance(struct colour_rgb *rgb1, struct colour_rgb *rgb2)
|
||||||
{
|
{
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
@@ -99,21 +98,20 @@ colour_rgb_distance(struct colour_rgb *rgb1, struct colour_rgb *rgb2)
|
|||||||
r = rgb1->r - rgb2->r;
|
r = rgb1->r - rgb2->r;
|
||||||
g = rgb1->g - rgb2->g;
|
g = rgb1->g - rgb2->g;
|
||||||
b = rgb1->b - rgb2->b;
|
b = rgb1->b - rgb2->b;
|
||||||
return (sqrt(r * r + g * g + b * b));
|
return (r * r + g * g + b * b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Work out the nearest colour from the 256 colour set. */
|
/* Work out the nearest colour from the 256 colour set. */
|
||||||
int
|
int
|
||||||
colour_rgb_find(struct colour_rgb *rgb)
|
colour_rgb_find(struct colour_rgb *rgb)
|
||||||
{
|
{
|
||||||
double distance, lowest;
|
u_int distance, lowest, colour, i;
|
||||||
u_int colour, i;
|
|
||||||
|
|
||||||
if (colour_rgb_256 == NULL)
|
if (colour_rgb_256 == NULL)
|
||||||
colour_rgb_generate256();
|
colour_rgb_generate256();
|
||||||
|
|
||||||
colour = 16;
|
colour = 16;
|
||||||
lowest = INFINITY;
|
lowest = UINT_MAX;
|
||||||
for (i = 0; i < 240; i++) {
|
for (i = 0; i < 240; i++) {
|
||||||
distance = colour_rgb_distance(&colour_rgb_256[i], rgb);
|
distance = colour_rgb_distance(&colour_rgb_256[i], rgb);
|
||||||
if (distance < lowest) {
|
if (distance < lowest) {
|
||||||
@@ -172,6 +170,22 @@ colour_tostring(int c)
|
|||||||
return ("white");
|
return ("white");
|
||||||
case 8:
|
case 8:
|
||||||
return ("default");
|
return ("default");
|
||||||
|
case 90:
|
||||||
|
return ("brightblack");
|
||||||
|
case 91:
|
||||||
|
return ("brightred");
|
||||||
|
case 92:
|
||||||
|
return ("brightgreen");
|
||||||
|
case 93:
|
||||||
|
return ("brightyellow");
|
||||||
|
case 94:
|
||||||
|
return ("brightblue");
|
||||||
|
case 95:
|
||||||
|
return ("brightmagenta");
|
||||||
|
case 96:
|
||||||
|
return ("brightcyan");
|
||||||
|
case 97:
|
||||||
|
return ("brightwhite");
|
||||||
}
|
}
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@@ -221,6 +235,30 @@ colour_fromstring(const char *s)
|
|||||||
return (7);
|
return (7);
|
||||||
if (strcasecmp(s, "default") == 0 || (s[0] == '8' && s[1] == '\0'))
|
if (strcasecmp(s, "default") == 0 || (s[0] == '8' && s[1] == '\0'))
|
||||||
return (8);
|
return (8);
|
||||||
|
if (strcasecmp(s, "brightblack") == 0 ||
|
||||||
|
(s[0] == '9' && s[1] == '0' && s[1] == '\0'))
|
||||||
|
return (90);
|
||||||
|
if (strcasecmp(s, "brightred") == 0 ||
|
||||||
|
(s[0] == '9' && s[1] == '1' && s[1] == '\0'))
|
||||||
|
return (91);
|
||||||
|
if (strcasecmp(s, "brightgreen") == 0 ||
|
||||||
|
(s[0] == '9' && s[1] == '2' && s[1] == '\0'))
|
||||||
|
return (92);
|
||||||
|
if (strcasecmp(s, "brightyellow") == 0 ||
|
||||||
|
(s[0] == '9' && s[1] == '3' && s[1] == '\0'))
|
||||||
|
return (93);
|
||||||
|
if (strcasecmp(s, "brightblue") == 0 ||
|
||||||
|
(s[0] == '9' && s[1] == '4' && s[1] == '\0'))
|
||||||
|
return (94);
|
||||||
|
if (strcasecmp(s, "brightmagenta") == 0 ||
|
||||||
|
(s[0] == '9' && s[1] == '5' && s[1] == '\0'))
|
||||||
|
return (95);
|
||||||
|
if (strcasecmp(s, "brightcyan") == 0 ||
|
||||||
|
(s[0] == '9' && s[1] == '6' && s[1] == '\0'))
|
||||||
|
return (96);
|
||||||
|
if (strcasecmp(s, "brightwhite") == 0 ||
|
||||||
|
(s[0] == '9' && s[1] == '7' && s[1] == '\0'))
|
||||||
|
return (97);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
5
compat.h
5
compat.h
@@ -196,6 +196,11 @@ size_t strlcat(char *, const char *, size_t);
|
|||||||
int daemon(int, int);
|
int daemon(int, int);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_B64_NTOP
|
||||||
|
/* b64_ntop.c */
|
||||||
|
int b64_ntop(const char *, size_t, char *, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_FORKPTY
|
#ifndef HAVE_FORKPTY
|
||||||
/* forkpty.c */
|
/* forkpty.c */
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|||||||
@@ -44,13 +44,16 @@ int
|
|||||||
vasprintf(char **ret, const char *fmt, va_list ap)
|
vasprintf(char **ret, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
va_list ap2;
|
||||||
|
|
||||||
|
va_copy(ap2, ap);
|
||||||
|
|
||||||
if ((n = vsnprintf(NULL, 0, fmt, ap)) < 0)
|
if ((n = vsnprintf(NULL, 0, fmt, ap)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
*ret = xmalloc(n + 1);
|
*ret = xmalloc(n + 1);
|
||||||
if ((n = vsnprintf(*ret, n + 1, fmt, ap)) < 0) {
|
if ((n = vsnprintf(*ret, n + 1, fmt, ap2)) < 0) {
|
||||||
xfree(*ret);
|
free(*ret);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
182
compat/b64_ntop.c
Normal file
182
compat/b64_ntop.c
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1996, 1998 by Internet Software Consortium.
|
||||||
|
*
|
||||||
|
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||||
|
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||||
|
* CONSORTIUM 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Portions Copyright (c) 1995 by International Business Machines, Inc.
|
||||||
|
*
|
||||||
|
* International Business Machines, Inc. (hereinafter called IBM) grants
|
||||||
|
* permission under its copyrights to use, copy, modify, and distribute this
|
||||||
|
* Software with or without fee, provided that the above copyright notice and
|
||||||
|
* all paragraphs of this notice appear in all copies, and that the name of IBM
|
||||||
|
* not be used in connection with the marketing of any product incorporating
|
||||||
|
* the Software or modifications thereof, without specific, written prior
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* To the extent it has a right to do so, IBM grants an immunity from suit
|
||||||
|
* under its patents, if any, for the use, sale or manufacture of products to
|
||||||
|
* the extent that such products are used for performing Domain Name System
|
||||||
|
* dynamic updates in TCP/IP networks by means of the Software. No immunity is
|
||||||
|
* granted for any product per se or for any other function of any product.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
|
||||||
|
* DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
|
||||||
|
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define Assert(Cond) if (!(Cond)) abort()
|
||||||
|
|
||||||
|
static const char Base64[] =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
static const char Pad64 = '=';
|
||||||
|
|
||||||
|
/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
|
||||||
|
The following encoding technique is taken from RFC 1521 by Borenstein
|
||||||
|
and Freed. It is reproduced here in a slightly edited form for
|
||||||
|
convenience.
|
||||||
|
|
||||||
|
A 65-character subset of US-ASCII is used, enabling 6 bits to be
|
||||||
|
represented per printable character. (The extra 65th character, "=",
|
||||||
|
is used to signify a special processing function.)
|
||||||
|
|
||||||
|
The encoding process represents 24-bit groups of input bits as output
|
||||||
|
strings of 4 encoded characters. Proceeding from left to right, a
|
||||||
|
24-bit input group is formed by concatenating 3 8-bit input groups.
|
||||||
|
These 24 bits are then treated as 4 concatenated 6-bit groups, each
|
||||||
|
of which is translated into a single digit in the base64 alphabet.
|
||||||
|
|
||||||
|
Each 6-bit group is used as an index into an array of 64 printable
|
||||||
|
characters. The character referenced by the index is placed in the
|
||||||
|
output string.
|
||||||
|
|
||||||
|
Table 1: The Base64 Alphabet
|
||||||
|
|
||||||
|
Value Encoding Value Encoding Value Encoding Value Encoding
|
||||||
|
0 A 17 R 34 i 51 z
|
||||||
|
1 B 18 S 35 j 52 0
|
||||||
|
2 C 19 T 36 k 53 1
|
||||||
|
3 D 20 U 37 l 54 2
|
||||||
|
4 E 21 V 38 m 55 3
|
||||||
|
5 F 22 W 39 n 56 4
|
||||||
|
6 G 23 X 40 o 57 5
|
||||||
|
7 H 24 Y 41 p 58 6
|
||||||
|
8 I 25 Z 42 q 59 7
|
||||||
|
9 J 26 a 43 r 60 8
|
||||||
|
10 K 27 b 44 s 61 9
|
||||||
|
11 L 28 c 45 t 62 +
|
||||||
|
12 M 29 d 46 u 63 /
|
||||||
|
13 N 30 e 47 v
|
||||||
|
14 O 31 f 48 w (pad) =
|
||||||
|
15 P 32 g 49 x
|
||||||
|
16 Q 33 h 50 y
|
||||||
|
|
||||||
|
Special processing is performed if fewer than 24 bits are available
|
||||||
|
at the end of the data being encoded. A full encoding quantum is
|
||||||
|
always completed at the end of a quantity. When fewer than 24 input
|
||||||
|
bits are available in an input group, zero bits are added (on the
|
||||||
|
right) to form an integral number of 6-bit groups. Padding at the
|
||||||
|
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
|
||||||
|
with no "=" padding,
|
||||||
|
(2) the final quantum of encoding input is exactly 8 bits;
|
||||||
|
here, the final unit of encoded output will be two
|
||||||
|
characters followed by two "=" padding characters, or
|
||||||
|
(3) the final quantum of encoding input is exactly 16 bits;
|
||||||
|
here, the final unit of encoded output will be three
|
||||||
|
characters followed by one "=" padding character.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
|
||||||
|
size_t datalength = 0;
|
||||||
|
uint8_t input[3];
|
||||||
|
uint8_t output[4];
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
while (2 < srclength) {
|
||||||
|
input[0] = *src++;
|
||||||
|
input[1] = *src++;
|
||||||
|
input[2] = *src++;
|
||||||
|
srclength -= 3;
|
||||||
|
|
||||||
|
output[0] = input[0] >> 2;
|
||||||
|
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
|
||||||
|
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|
||||||
|
output[3] = input[2] & 0x3f;
|
||||||
|
Assert(output[0] < 64);
|
||||||
|
Assert(output[1] < 64);
|
||||||
|
Assert(output[2] < 64);
|
||||||
|
Assert(output[3] < 64);
|
||||||
|
|
||||||
|
if (datalength + 4 > targsize)
|
||||||
|
return (-1);
|
||||||
|
target[datalength++] = Base64[output[0]];
|
||||||
|
target[datalength++] = Base64[output[1]];
|
||||||
|
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);
|
||||||
|
Assert(output[0] < 64);
|
||||||
|
Assert(output[1] < 64);
|
||||||
|
Assert(output[2] < 64);
|
||||||
|
|
||||||
|
if (datalength + 4 > targsize)
|
||||||
|
return (-1);
|
||||||
|
target[datalength++] = Base64[output[0]];
|
||||||
|
target[datalength++] = Base64[output[1]];
|
||||||
|
if (srclength == 1)
|
||||||
|
target[datalength++] = Pad64;
|
||||||
|
else
|
||||||
|
target[datalength++] = Base64[output[2]];
|
||||||
|
target[datalength++] = Pad64;
|
||||||
|
}
|
||||||
|
if (datalength >= targsize)
|
||||||
|
return (-1);
|
||||||
|
target[datalength] = '\0'; /* Returned value doesn't count \0. */
|
||||||
|
return (datalength);
|
||||||
|
}
|
||||||
@@ -43,9 +43,7 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
char *
|
char *
|
||||||
fgetln(fp, len)
|
fgetln(FILE *fp, size_t *len)
|
||||||
FILE *fp;
|
|
||||||
size_t *len;
|
|
||||||
{
|
{
|
||||||
static char *buf = NULL;
|
static char *buf = NULL;
|
||||||
static size_t bufsiz = 0;
|
static size_t bufsiz = 0;
|
||||||
|
|||||||
@@ -52,10 +52,7 @@ char *BSDoptarg; /* argument associated with option */
|
|||||||
* Parse argc/argv argument vector.
|
* Parse argc/argv argument vector.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
BSDgetopt(nargc, nargv, ostr)
|
BSDgetopt(int nargc, char *const *nargv, const char *ostr)
|
||||||
int nargc;
|
|
||||||
char * const *nargv;
|
|
||||||
const char *ostr;
|
|
||||||
{
|
{
|
||||||
static char *place = EMSG; /* option letter processing */
|
static char *place = EMSG; /* option letter processing */
|
||||||
char *oli; /* option letter list index */
|
char *oli; /* option letter list index */
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD: queue.h,v 1.36 2012/04/11 13:29:14 naddy Exp $ */
|
||||||
/* $OpenBSD: queue.h,v 1.31 2005/11/25 08:06:25 otto Exp $ */
|
|
||||||
/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */
|
/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -37,7 +36,7 @@
|
|||||||
#define _SYS_QUEUE_H_
|
#define _SYS_QUEUE_H_
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file defines five types of data structures: singly-linked lists,
|
* This file defines five types of data structures: singly-linked lists,
|
||||||
* lists, simple queues, tail queues, and circular queues.
|
* lists, simple queues, tail queues, and circular queues.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -83,7 +82,7 @@
|
|||||||
* For details on the use of these macros, see the queue(3) manual page.
|
* For details on the use of these macros, see the queue(3) manual page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef QUEUE_MACRO_DEBUG
|
#if defined(QUEUE_MACRO_DEBUG) || (defined(_KERNEL) && defined(DIAGNOSTIC))
|
||||||
#define _Q_INVALIDATE(a) (a) = ((void *)-1)
|
#define _Q_INVALIDATE(a) (a) = ((void *)-1)
|
||||||
#else
|
#else
|
||||||
#define _Q_INVALIDATE(a)
|
#define _Q_INVALIDATE(a)
|
||||||
@@ -96,15 +95,15 @@
|
|||||||
struct name { \
|
struct name { \
|
||||||
struct type *slh_first; /* first element */ \
|
struct type *slh_first; /* first element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SLIST_HEAD_INITIALIZER(head) \
|
#define SLIST_HEAD_INITIALIZER(head) \
|
||||||
{ NULL }
|
{ NULL }
|
||||||
|
|
||||||
#define SLIST_ENTRY(type) \
|
#define SLIST_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
struct type *sle_next; /* next element */ \
|
struct type *sle_next; /* next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Singly-linked List access methods.
|
* Singly-linked List access methods.
|
||||||
*/
|
*/
|
||||||
@@ -118,10 +117,10 @@ struct { \
|
|||||||
(var) != SLIST_END(head); \
|
(var) != SLIST_END(head); \
|
||||||
(var) = SLIST_NEXT(var, field))
|
(var) = SLIST_NEXT(var, field))
|
||||||
|
|
||||||
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
|
#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||||
for ((varp) = &SLIST_FIRST((head)); \
|
for ((var) = SLIST_FIRST(head); \
|
||||||
((var) = *(varp)) != SLIST_END(head); \
|
(var) && ((tvar) = SLIST_NEXT(var, field), 1); \
|
||||||
(varp) = &SLIST_NEXT((var), field))
|
(var) = (tvar))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Singly-linked List functions.
|
* Singly-linked List functions.
|
||||||
@@ -140,7 +139,7 @@ struct { \
|
|||||||
(head)->slh_first = (elm); \
|
(head)->slh_first = (elm); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SLIST_REMOVE_NEXT(head, elm, field) do { \
|
#define SLIST_REMOVE_AFTER(elm, field) do { \
|
||||||
(elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
|
(elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@@ -192,6 +191,11 @@ struct { \
|
|||||||
(var)!= LIST_END(head); \
|
(var)!= LIST_END(head); \
|
||||||
(var) = LIST_NEXT(var, field))
|
(var) = LIST_NEXT(var, field))
|
||||||
|
|
||||||
|
#define LIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||||
|
for ((var) = LIST_FIRST(head); \
|
||||||
|
(var) && ((tvar) = LIST_NEXT(var, field), 1); \
|
||||||
|
(var) = (tvar))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List functions.
|
* List functions.
|
||||||
*/
|
*/
|
||||||
@@ -270,6 +274,11 @@ struct { \
|
|||||||
(var) != SIMPLEQ_END(head); \
|
(var) != SIMPLEQ_END(head); \
|
||||||
(var) = SIMPLEQ_NEXT(var, field))
|
(var) = SIMPLEQ_NEXT(var, field))
|
||||||
|
|
||||||
|
#define SIMPLEQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||||
|
for ((var) = SIMPLEQ_FIRST(head); \
|
||||||
|
(var) && ((tvar) = SIMPLEQ_NEXT(var, field), 1); \
|
||||||
|
(var) = (tvar))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple queue functions.
|
* Simple queue functions.
|
||||||
*/
|
*/
|
||||||
@@ -301,6 +310,12 @@ struct { \
|
|||||||
(head)->sqh_last = &(head)->sqh_first; \
|
(head)->sqh_last = &(head)->sqh_first; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \
|
||||||
|
if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \
|
||||||
|
== NULL) \
|
||||||
|
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tail queue definitions.
|
* Tail queue definitions.
|
||||||
*/
|
*/
|
||||||
@@ -319,8 +334,8 @@ struct { \
|
|||||||
struct type **tqe_prev; /* address of previous next element */ \
|
struct type **tqe_prev; /* address of previous next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tail queue access methods
|
* tail queue access methods
|
||||||
*/
|
*/
|
||||||
#define TAILQ_FIRST(head) ((head)->tqh_first)
|
#define TAILQ_FIRST(head) ((head)->tqh_first)
|
||||||
#define TAILQ_END(head) NULL
|
#define TAILQ_END(head) NULL
|
||||||
@@ -338,11 +353,24 @@ struct { \
|
|||||||
(var) != TAILQ_END(head); \
|
(var) != TAILQ_END(head); \
|
||||||
(var) = TAILQ_NEXT(var, field))
|
(var) = TAILQ_NEXT(var, field))
|
||||||
|
|
||||||
|
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||||
|
for ((var) = TAILQ_FIRST(head); \
|
||||||
|
(var) != TAILQ_END(head) && \
|
||||||
|
((tvar) = TAILQ_NEXT(var, field), 1); \
|
||||||
|
(var) = (tvar))
|
||||||
|
|
||||||
|
|
||||||
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
||||||
for((var) = TAILQ_LAST(head, headname); \
|
for((var) = TAILQ_LAST(head, headname); \
|
||||||
(var) != TAILQ_END(head); \
|
(var) != TAILQ_END(head); \
|
||||||
(var) = TAILQ_PREV(var, headname, field))
|
(var) = TAILQ_PREV(var, headname, field))
|
||||||
|
|
||||||
|
#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
|
||||||
|
for ((var) = TAILQ_LAST(head, headname); \
|
||||||
|
(var) != TAILQ_END(head) && \
|
||||||
|
((tvar) = TAILQ_PREV(var, headname, field), 1); \
|
||||||
|
(var) = (tvar))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tail queue functions.
|
* Tail queue functions.
|
||||||
*/
|
*/
|
||||||
@@ -427,7 +455,7 @@ struct { \
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Circular queue access methods
|
* Circular queue access methods
|
||||||
*/
|
*/
|
||||||
#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
|
#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
|
||||||
#define CIRCLEQ_LAST(head) ((head)->cqh_last)
|
#define CIRCLEQ_LAST(head) ((head)->cqh_last)
|
||||||
@@ -442,11 +470,23 @@ struct { \
|
|||||||
(var) != CIRCLEQ_END(head); \
|
(var) != CIRCLEQ_END(head); \
|
||||||
(var) = CIRCLEQ_NEXT(var, field))
|
(var) = CIRCLEQ_NEXT(var, field))
|
||||||
|
|
||||||
|
#define CIRCLEQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||||
|
for ((var) = CIRCLEQ_FIRST(head); \
|
||||||
|
(var) != CIRCLEQ_END(head) && \
|
||||||
|
((tvar) = CIRCLEQ_NEXT(var, field), 1); \
|
||||||
|
(var) = (tvar))
|
||||||
|
|
||||||
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
|
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
|
||||||
for((var) = CIRCLEQ_LAST(head); \
|
for((var) = CIRCLEQ_LAST(head); \
|
||||||
(var) != CIRCLEQ_END(head); \
|
(var) != CIRCLEQ_END(head); \
|
||||||
(var) = CIRCLEQ_PREV(var, field))
|
(var) = CIRCLEQ_PREV(var, field))
|
||||||
|
|
||||||
|
#define CIRCLEQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
|
||||||
|
for ((var) = CIRCLEQ_LAST(head, headname); \
|
||||||
|
(var) != CIRCLEQ_END(head) && \
|
||||||
|
((tvar) = CIRCLEQ_PREV(var, headname, field), 1); \
|
||||||
|
(var) = (tvar))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Circular queue functions.
|
* Circular queue functions.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* $OpenBSD: tree.h,v 1.12 2009/03/02 09:42:55 mikeb Exp $ */
|
/* $OpenBSD: tree.h,v 1.13 2011/07/09 00:19:45 pirofti Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@@ -84,7 +84,7 @@ struct { \
|
|||||||
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
|
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
|
||||||
(head)->sph_root = tmp; \
|
(head)->sph_root = tmp; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
|
#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
|
||||||
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
|
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
|
||||||
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
|
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
|
||||||
@@ -731,9 +731,19 @@ name##_RB_MINMAX(struct name *head, int val) \
|
|||||||
(x) != NULL; \
|
(x) != NULL; \
|
||||||
(x) = name##_RB_NEXT(x))
|
(x) = name##_RB_NEXT(x))
|
||||||
|
|
||||||
|
#define RB_FOREACH_SAFE(x, name, head, y) \
|
||||||
|
for ((x) = RB_MIN(name, head); \
|
||||||
|
((x) != NULL) && ((y) = name##_RB_NEXT(x), 1); \
|
||||||
|
(x) = (y))
|
||||||
|
|
||||||
#define RB_FOREACH_REVERSE(x, name, head) \
|
#define RB_FOREACH_REVERSE(x, name, head) \
|
||||||
for ((x) = RB_MAX(name, head); \
|
for ((x) = RB_MAX(name, head); \
|
||||||
(x) != NULL; \
|
(x) != NULL; \
|
||||||
(x) = name##_RB_PREV(x))
|
(x) = name##_RB_PREV(x))
|
||||||
|
|
||||||
|
#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \
|
||||||
|
for ((x) = RB_MAX(name, head); \
|
||||||
|
((x) != NULL) && ((y) = name##_RB_PREV(x), 1); \
|
||||||
|
(x) = (y))
|
||||||
|
|
||||||
#endif /* _SYS_TREE_H_ */
|
#endif /* _SYS_TREE_H_ */
|
||||||
|
|||||||
95
configure.ac
95
configure.ac
@@ -1,7 +1,7 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
# Miscellaneous autofoo bullshit.
|
# Miscellaneous autofoo bullshit.
|
||||||
AC_INIT(tmux, 1.5)
|
AC_INIT(tmux, 1.7)
|
||||||
|
|
||||||
AC_CONFIG_AUX_DIR(etc)
|
AC_CONFIG_AUX_DIR(etc)
|
||||||
AM_INIT_AUTOMAKE([foreign])
|
AM_INIT_AUTOMAKE([foreign])
|
||||||
@@ -12,6 +12,7 @@ AC_CANONICAL_HOST
|
|||||||
# autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
|
# autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
|
||||||
# empty default.
|
# empty default.
|
||||||
: ${CFLAGS=""}
|
: ${CFLAGS=""}
|
||||||
|
|
||||||
# Set up the compiler in two different ways and say yes we may want to install.
|
# Set up the compiler in two different ways and say yes we may want to install.
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AM_PROG_CC_C_O
|
AM_PROG_CC_C_O
|
||||||
@@ -52,9 +53,8 @@ AM_CONDITIONAL(IS_DEBUG, test "x$found_debug" = xyes)
|
|||||||
AC_ARG_ENABLE(
|
AC_ARG_ENABLE(
|
||||||
static,
|
static,
|
||||||
AC_HELP_STRING(--enable-static, create a static build),
|
AC_HELP_STRING(--enable-static, create a static build),
|
||||||
[found_static=$enable_static]
|
[LDFLAGS="$LDFLAGS -static"]
|
||||||
)
|
)
|
||||||
AM_CONDITIONAL(IS_STATIC, test "x" = xyes)
|
|
||||||
|
|
||||||
# Is this gcc?
|
# Is this gcc?
|
||||||
AM_CONDITIONAL(IS_GCC, test "x$GCC" = xyes)
|
AM_CONDITIONAL(IS_GCC, test "x$GCC" = xyes)
|
||||||
@@ -102,12 +102,28 @@ AM_CONDITIONAL(IS_GLIBC, test "x$found_glibc" = xyes)
|
|||||||
AC_MSG_RESULT($found_glibc)
|
AC_MSG_RESULT($found_glibc)
|
||||||
|
|
||||||
# Look for clock_gettime. Must come before event_init.
|
# Look for clock_gettime. Must come before event_init.
|
||||||
AC_CHECK_LIB(rt, clock_gettime)
|
AC_SEARCH_LIBS(clock_gettime, rt)
|
||||||
|
|
||||||
# Look for libevent.
|
# Look for libevent.
|
||||||
AC_SEARCH_LIBS(event_init, [event event-1.4 event2], found_libevent=yes, found_libevent=no)
|
PKG_CHECK_MODULES(
|
||||||
|
LIBEVENT,
|
||||||
|
libevent,
|
||||||
|
[
|
||||||
|
CPPFLAGS="$LIBEVENT_CFLAGS $CPPFLAGS"
|
||||||
|
LIBS="$LIBEVENT_LIBS $LIBS"
|
||||||
|
found_libevent=yes
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AC_SEARCH_LIBS(
|
||||||
|
event_init,
|
||||||
|
[event event-1.4 event2],
|
||||||
|
found_libevent=yes,
|
||||||
|
found_libevent=no
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
if test "x$found_libevent" = xno; then
|
if test "x$found_libevent" = xno; then
|
||||||
AC_MSG_ERROR("libevent not found")
|
AC_MSG_ERROR("libevent not found")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Look for curses.
|
# Look for curses.
|
||||||
@@ -121,16 +137,48 @@ if test "x$found_curses" = xno; then
|
|||||||
AC_MSG_ERROR("curses not found")
|
AC_MSG_ERROR("curses not found")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for b64_ntop.
|
||||||
|
AC_MSG_CHECKING(for b64_ntop)
|
||||||
|
AC_TRY_LINK(
|
||||||
|
[
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <resolv.h>
|
||||||
|
],
|
||||||
|
[b64_ntop(NULL, 0, NULL, 0);],
|
||||||
|
found_b64_ntop=yes,
|
||||||
|
found_b64_ntop=no
|
||||||
|
)
|
||||||
|
if test "x$found_b64_ntop" = xno; then
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for b64_ntop with -lresolv)
|
||||||
|
LIBS="$LIBS -lresolv"
|
||||||
|
AC_TRY_LINK(
|
||||||
|
[
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <resolv.h>
|
||||||
|
],
|
||||||
|
[b64_ntop(NULL, 0, NULL, 0);],
|
||||||
|
found_b64_ntop=yes,
|
||||||
|
found_b64_ntop=no
|
||||||
|
)
|
||||||
|
if test "x$found_b64_ntop" = xno; then
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$found_b64_ntop" = xyes; then
|
||||||
|
AC_DEFINE(HAVE_B64_NTOP)
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL(NO_B64_NTOP, [test "x$found_b64_ntop" = xno])
|
||||||
|
|
||||||
# Look for networking libraries.
|
# Look for networking libraries.
|
||||||
AC_SEARCH_LIBS(b64_ntop, resolv)
|
|
||||||
AC_SEARCH_LIBS(__b64_ntop, resolv)
|
|
||||||
AC_SEARCH_LIBS(inet_ntoa, nsl)
|
AC_SEARCH_LIBS(inet_ntoa, nsl)
|
||||||
AC_SEARCH_LIBS(socket, socket)
|
AC_SEARCH_LIBS(socket, socket)
|
||||||
AC_CHECK_LIB(xnet, socket)
|
AC_CHECK_LIB(xnet, socket)
|
||||||
|
|
||||||
# Look for sqrt.
|
|
||||||
AC_SEARCH_LIBS(sqrt, m)
|
|
||||||
|
|
||||||
# Check for CMSG_DATA. Some platforms require _XOPEN_SOURCE_EXTENDED (for
|
# Check for CMSG_DATA. Some platforms require _XOPEN_SOURCE_EXTENDED (for
|
||||||
# example see xopen_networking(7) on HP-UX).
|
# example see xopen_networking(7) on HP-UX).
|
||||||
XOPEN_DEFINES=
|
XOPEN_DEFINES=
|
||||||
@@ -291,6 +339,7 @@ AM_CONDITIONAL(NO_GETOPT, [test "x$found_getopt" = xno])
|
|||||||
AC_CHECK_FUNCS(
|
AC_CHECK_FUNCS(
|
||||||
[ \
|
[ \
|
||||||
bzero \
|
bzero \
|
||||||
|
dirfd \
|
||||||
setproctitle \
|
setproctitle \
|
||||||
sysconf \
|
sysconf \
|
||||||
]
|
]
|
||||||
@@ -298,7 +347,7 @@ AC_CHECK_FUNCS(
|
|||||||
|
|
||||||
# Check for BSD-style integer types.
|
# Check for BSD-style integer types.
|
||||||
AC_MSG_CHECKING(for BSD-style unsigned types)
|
AC_MSG_CHECKING(for BSD-style unsigned types)
|
||||||
AC_COMPILE_IFELSE(
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
|
||||||
[
|
[
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_STDINT_H
|
#ifdef HAVE_STDINT_H
|
||||||
@@ -308,7 +357,7 @@ AC_COMPILE_IFELSE(
|
|||||||
#endif
|
#endif
|
||||||
int main(void)
|
int main(void)
|
||||||
{ u_int8_t u8; u_int16_t u16; u_int32_t u32; u_int64_t u64; }
|
{ u_int8_t u8; u_int16_t u16; u_int32_t u32; u_int64_t u64; }
|
||||||
],
|
])],
|
||||||
[AC_DEFINE(HAVE_BSD_TYPES) AC_MSG_RESULT(yes)],
|
[AC_DEFINE(HAVE_BSD_TYPES) AC_MSG_RESULT(yes)],
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
)
|
)
|
||||||
@@ -332,7 +381,7 @@ fi
|
|||||||
|
|
||||||
# Look for __progname.
|
# Look for __progname.
|
||||||
AC_MSG_CHECKING(for __progname)
|
AC_MSG_CHECKING(for __progname)
|
||||||
AC_LINK_IFELSE(
|
AC_LINK_IFELSE([AC_LANG_SOURCE(
|
||||||
[
|
[
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -342,7 +391,7 @@ AC_LINK_IFELSE(
|
|||||||
printf("%s\n", cp);
|
printf("%s\n", cp);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
],
|
])],
|
||||||
[AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
|
[AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
)
|
)
|
||||||
@@ -364,15 +413,6 @@ else
|
|||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Look for /proc/$$/fd.
|
|
||||||
AC_MSG_CHECKING(for /proc/\$\$/fd)
|
|
||||||
if test -d /proc/$$/fd; then
|
|
||||||
AC_DEFINE(HAVE_DIRFD)
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Figure out the platform for osdep-*.c and forkpty-*.c.
|
# Figure out the platform for osdep-*.c and forkpty-*.c.
|
||||||
AC_MSG_CHECKING(platform)
|
AC_MSG_CHECKING(platform)
|
||||||
case "$host_os" in
|
case "$host_os" in
|
||||||
@@ -385,11 +425,15 @@ case "$host_os" in
|
|||||||
AC_DEFINE(BROKEN_CMSG_FIRSTHDR)
|
AC_DEFINE(BROKEN_CMSG_FIRSTHDR)
|
||||||
PLATFORM=darwin
|
PLATFORM=darwin
|
||||||
;;
|
;;
|
||||||
|
*dragonfly*)
|
||||||
|
AC_MSG_RESULT(dragonfly)
|
||||||
|
PLATFORM=dragonfly
|
||||||
|
;;
|
||||||
*linux*)
|
*linux*)
|
||||||
AC_MSG_RESULT(linux)
|
AC_MSG_RESULT(linux)
|
||||||
PLATFORM=linux
|
PLATFORM=linux
|
||||||
;;
|
;;
|
||||||
*freebsd*|*dragonfly*)
|
*freebsd*)
|
||||||
AC_MSG_RESULT(freebsd)
|
AC_MSG_RESULT(freebsd)
|
||||||
PLATFORM=freebsd
|
PLATFORM=freebsd
|
||||||
;;
|
;;
|
||||||
@@ -421,6 +465,7 @@ esac
|
|||||||
AC_SUBST(PLATFORM)
|
AC_SUBST(PLATFORM)
|
||||||
AM_CONDITIONAL(IS_AIX, test "x$PLATFORM" = xaix)
|
AM_CONDITIONAL(IS_AIX, test "x$PLATFORM" = xaix)
|
||||||
AM_CONDITIONAL(IS_DARWIN, test "x$PLATFORM" = xdarwin)
|
AM_CONDITIONAL(IS_DARWIN, test "x$PLATFORM" = xdarwin)
|
||||||
|
AM_CONDITIONAL(IS_DRAGONFLY, test "x$PLATFORM" = xdragonfly)
|
||||||
AM_CONDITIONAL(IS_LINUX, test "x$PLATFORM" = xlinux)
|
AM_CONDITIONAL(IS_LINUX, test "x$PLATFORM" = xlinux)
|
||||||
AM_CONDITIONAL(IS_FREEBSD, test "x$PLATFORM" = xfreebsd)
|
AM_CONDITIONAL(IS_FREEBSD, test "x$PLATFORM" = xfreebsd)
|
||||||
AM_CONDITIONAL(IS_NETBSD, test "x$PLATFORM" = xnetbsd)
|
AM_CONDITIONAL(IS_NETBSD, test "x$PLATFORM" = xnetbsd)
|
||||||
|
|||||||
212
control-notify.c
Normal file
212
control-notify.c
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2012 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
* Copyright (c) 2012 George Nachman <tmux@georgester.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 "tmux.h"
|
||||||
|
|
||||||
|
#define CONTROL_SHOULD_NOTIFY_CLIENT(c) \
|
||||||
|
((c) != NULL && ((c)->flags & CLIENT_CONTROL))
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_input(struct client *c, struct window_pane *wp,
|
||||||
|
struct evbuffer *input)
|
||||||
|
{
|
||||||
|
u_char *buf;
|
||||||
|
size_t len;
|
||||||
|
struct evbuffer *message;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
if (c->session == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
buf = EVBUFFER_DATA(input);
|
||||||
|
len = EVBUFFER_LENGTH(input);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Only write input if the window pane is linked to a window belonging
|
||||||
|
* to the client's session.
|
||||||
|
*/
|
||||||
|
if (winlink_find_by_window(&c->session->windows, wp->window) != NULL) {
|
||||||
|
message = evbuffer_new();
|
||||||
|
evbuffer_add_printf(message, "%%output %%%u ", wp->id);
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
evbuffer_add_printf(message, "%02hhx", buf[i]);
|
||||||
|
control_write_buffer(c, message);
|
||||||
|
evbuffer_free(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_window_layout_changed(struct window *w)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
struct session *s;
|
||||||
|
struct format_tree *ft;
|
||||||
|
struct winlink *wl;
|
||||||
|
u_int i;
|
||||||
|
const char *template;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
s = c->session;
|
||||||
|
|
||||||
|
if (winlink_find_by_window_id(&s->windows, w->id) == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When the last pane in a window is closed it won't have a
|
||||||
|
* layout root and we don't need to inform the client about the
|
||||||
|
* layout change because the whole window will go away soon.
|
||||||
|
*/
|
||||||
|
if (w->layout_root == NULL)
|
||||||
|
continue;
|
||||||
|
template = "%layout-change #{window_id} #{window_layout}";
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
wl = winlink_find_by_window(&s->windows, w);
|
||||||
|
if (wl != NULL) {
|
||||||
|
format_winlink(ft, c->session, wl);
|
||||||
|
control_write(c, "%s", format_expand(ft, template));
|
||||||
|
}
|
||||||
|
format_free(ft);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_window_unlinked(unused struct session *s, struct window *w)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
struct session *cs;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
cs = c->session;
|
||||||
|
|
||||||
|
if (winlink_find_by_window_id(&cs->windows, w->id) != NULL)
|
||||||
|
control_write(c, "%%window-close %u", w->id);
|
||||||
|
else
|
||||||
|
control_write(c, "%%unlinked-window-close %u", w->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_window_linked(unused struct session *s, struct window *w)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
struct session *cs;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
cs = c->session;
|
||||||
|
|
||||||
|
if (winlink_find_by_window_id(&cs->windows, w->id) != NULL)
|
||||||
|
control_write(c, "%%window-add %u", w->id);
|
||||||
|
else
|
||||||
|
control_write(c, "%%unlinked-window-add %u", w->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_window_renamed(struct window *w)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
struct session *s;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
s = c->session;
|
||||||
|
|
||||||
|
if (winlink_find_by_window_id(&s->windows, w->id) != NULL) {
|
||||||
|
control_write(c, "%%window-renamed %u %s",
|
||||||
|
w->id, w->name);
|
||||||
|
} else {
|
||||||
|
control_write(c, "%%unlinked-window-renamed %u %s",
|
||||||
|
w->id, w->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_attached_session_changed(struct client *c)
|
||||||
|
{
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
|
||||||
|
return;
|
||||||
|
s = c->session;
|
||||||
|
|
||||||
|
control_write(c, "%%session-changed %d %s", s->idx, s->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_session_renamed(struct session *s)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session != s)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
control_write(c, "%%session-renamed %s", s->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_session_created(unused struct session *s)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
control_write(c, "%%sessions-changed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_session_close(unused struct session *s)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
control_write(c, "%%sessions-changed");
|
||||||
|
}
|
||||||
|
}
|
||||||
130
control.c
Normal file
130
control.c
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2012 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
* Copyright (c) 2012 George Nachman <tmux@georgester.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 <event.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
void printflike2 control_msg_error(struct cmd_ctx *, const char *, ...);
|
||||||
|
void printflike2 control_msg_print(struct cmd_ctx *, const char *, ...);
|
||||||
|
void printflike2 control_msg_info(struct cmd_ctx *, const char *, ...);
|
||||||
|
|
||||||
|
/* Command error callback. */
|
||||||
|
void printflike2
|
||||||
|
control_msg_error(struct cmd_ctx *ctx, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
struct client *c = ctx->curclient;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
evbuffer_add_vprintf(c->stdout_data, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
evbuffer_add(c->stdout_data, "\n", 1);
|
||||||
|
server_push_stdout(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Command print callback. */
|
||||||
|
void printflike2
|
||||||
|
control_msg_print(struct cmd_ctx *ctx, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
struct client *c = ctx->curclient;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
evbuffer_add_vprintf(c->stdout_data, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
evbuffer_add(c->stdout_data, "\n", 1);
|
||||||
|
server_push_stdout(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Command info callback. */
|
||||||
|
void printflike2
|
||||||
|
control_msg_info(unused struct cmd_ctx *ctx, unused const char *fmt, ...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write a line. */
|
||||||
|
void printflike2
|
||||||
|
control_write(struct client *c, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
evbuffer_add_vprintf(c->stdout_data, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
evbuffer_add(c->stdout_data, "\n", 1);
|
||||||
|
server_push_stdout(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write a buffer, adding a terminal newline. Empties buffer. */
|
||||||
|
void
|
||||||
|
control_write_buffer(struct client *c, struct evbuffer *buffer)
|
||||||
|
{
|
||||||
|
evbuffer_add_buffer(c->stdout_data, buffer);
|
||||||
|
evbuffer_add(c->stdout_data, "\n", 1);
|
||||||
|
server_push_stdout(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Control input callback. Read lines and fire commands. */
|
||||||
|
void
|
||||||
|
control_callback(struct client *c, int closed, unused void *data)
|
||||||
|
{
|
||||||
|
char *line, *cause;
|
||||||
|
struct cmd_ctx ctx;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
|
||||||
|
if (closed)
|
||||||
|
c->flags |= CLIENT_EXIT;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
line = evbuffer_readln(c->stdin_data, NULL, EVBUFFER_EOL_LF);
|
||||||
|
if (line == NULL)
|
||||||
|
break;
|
||||||
|
if (*line == '\0') { /* empty line exit */
|
||||||
|
c->flags |= CLIENT_EXIT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.msgdata = NULL;
|
||||||
|
ctx.cmdclient = NULL;
|
||||||
|
ctx.curclient = c;
|
||||||
|
|
||||||
|
ctx.error = control_msg_error;
|
||||||
|
ctx.print = control_msg_print;
|
||||||
|
ctx.info = control_msg_info;
|
||||||
|
|
||||||
|
if (cmd_string_parse(line, &cmdlist, &cause) != 0) {
|
||||||
|
control_write(c, "%%error in line \"%s\": %s", line,
|
||||||
|
cause);
|
||||||
|
free(cause);
|
||||||
|
} else {
|
||||||
|
cmd_list_exec(cmdlist, &ctx);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user