mirror of
https://github.com/tmux/tmux.git
synced 2026-03-11 19:15:45 +00:00
Compare commits
3778 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac44566c9c | ||
|
|
64f1076d97 | ||
|
|
489c69f5ed | ||
|
|
f897049935 | ||
|
|
d8b66110f7 | ||
|
|
8b1a3bb2e5 | ||
|
|
37771a5a8d | ||
|
|
3a8a31d8d2 | ||
|
|
c36ffcbe56 | ||
|
|
3d8ead8a97 | ||
|
|
141cd78407 | ||
|
|
d0c8124661 | ||
|
|
2917bc5274 | ||
|
|
2d1e93447e | ||
|
|
31b6c9356c | ||
|
|
9e2a7c28f5 | ||
|
|
73b2277af8 | ||
|
|
a84c109604 | ||
|
|
4823acca8f | ||
|
|
34807388b0 | ||
|
|
08be883297 | ||
|
|
13bd0e46db | ||
|
|
6e9a914014 | ||
|
|
7990e5fa8f | ||
|
|
4860a58d07 | ||
|
|
99af9f23bd | ||
|
|
9ebbe2cca7 | ||
|
|
692bae9ea6 | ||
|
|
a6645c4de4 | ||
|
|
06292baadc | ||
|
|
ceda0a68ae | ||
|
|
4fa90c9acf | ||
|
|
c7e61a01e5 | ||
|
|
963e824f5f | ||
|
|
de6bce057a | ||
|
|
937ba1d8dd | ||
|
|
651891c3bd | ||
|
|
4008e2ff6d | ||
|
|
b88130d24b | ||
|
|
fc7ee7efc7 | ||
|
|
d0eb3fe543 | ||
|
|
2ac0faf119 | ||
|
|
775789fbd5 | ||
|
|
7b6fbe7262 | ||
|
|
109d2bda1a | ||
|
|
ddd4e57c65 | ||
|
|
3c2621b41b | ||
|
|
5039be657c | ||
|
|
d02254f754 | ||
|
|
aa1353947e | ||
|
|
171004dfd0 | ||
|
|
c773fe89e7 | ||
|
|
093b5a5518 | ||
|
|
db1665868f | ||
|
|
c07e856d24 | ||
|
|
692ce59bce | ||
|
|
9e7c1aee48 | ||
|
|
4c2eedca5a | ||
|
|
ac6c1e9589 | ||
|
|
0903790b00 | ||
|
|
03de52653e | ||
|
|
da06719309 | ||
|
|
fc84097379 | ||
|
|
4fd725c6e1 | ||
|
|
d39dcea30a | ||
|
|
bfd65398a9 | ||
|
|
452d987e0e | ||
|
|
8ef899f315 | ||
|
|
a18d1146aa | ||
|
|
5b5004e5ac | ||
|
|
6ff8f8fbf9 | ||
|
|
c9616700ca | ||
|
|
4c928dce74 | ||
|
|
fb37d52dde | ||
|
|
363d9c401e | ||
|
|
8643ece345 | ||
|
|
9ba433e521 | ||
|
|
3823fa2c57 | ||
|
|
0a8571b6fe | ||
|
|
ea9f416c99 | ||
|
|
036d8993e6 | ||
|
|
e8530c9fee | ||
|
|
dd4c0109a9 | ||
|
|
43530d4397 | ||
|
|
553d4cba79 | ||
|
|
c62a9ca16b | ||
|
|
424f13fe13 | ||
|
|
4bb6da75ba | ||
|
|
a28175dbfd | ||
|
|
fc204bb5e5 | ||
|
|
6207a45139 | ||
|
|
3c3643f580 | ||
|
|
89c1c43ef9 | ||
|
|
2e9d7ebf15 | ||
|
|
d8ddeec7db | ||
|
|
6f0254e6a8 | ||
|
|
aa17f0e0c1 | ||
|
|
0ae8b681b2 | ||
|
|
6c0067c103 | ||
|
|
5458cb2850 | ||
|
|
0c374868ca | ||
|
|
bf5d3f2e26 | ||
|
|
d5ef837f63 | ||
|
|
b79e28b2c3 | ||
|
|
8ffd5458ff | ||
|
|
b54e1fc4f7 | ||
|
|
bdb6321229 | ||
|
|
bd29a48b56 | ||
|
|
f3f1c3db58 | ||
|
|
608d113486 | ||
|
|
9ae69c3795 | ||
|
|
0960862950 | ||
|
|
44ad25b367 | ||
|
|
40b97b1715 | ||
|
|
4bdb855020 | ||
|
|
ea7136fb83 | ||
|
|
428f8a9b28 | ||
|
|
84faada25b | ||
|
|
55d0abad89 | ||
|
|
7d91b4b90b | ||
|
|
66369416fc | ||
|
|
001e26d0bb | ||
|
|
2e39d698d2 | ||
|
|
e809c2ec35 | ||
|
|
4266d3efc8 | ||
|
|
40a20bc8ae | ||
|
|
f7bf7e9671 | ||
|
|
008ecd4592 | ||
|
|
73a2b12088 | ||
|
|
605bf21ff2 | ||
|
|
f028445407 | ||
|
|
bdf8e614af | ||
|
|
4dea352dee | ||
|
|
151875d144 | ||
|
|
88fd1f00b8 | ||
|
|
1a14d6d2e1 | ||
|
|
381c00a74e | ||
|
|
5aadee6df4 | ||
|
|
a5545dbc9f | ||
|
|
fdf465925e | ||
|
|
36e1ac6556 | ||
|
|
ffa376edf7 | ||
|
|
b777780720 | ||
|
|
347cd0b5f8 | ||
|
|
0ca28b362e | ||
|
|
51b80b985e | ||
|
|
789a98982e | ||
|
|
b202a2f1b5 | ||
|
|
7e79108f8a | ||
|
|
f09cde2542 | ||
|
|
9f9156c030 | ||
|
|
d394293ba5 | ||
|
|
c57a09269b | ||
|
|
8191c58737 | ||
|
|
f68d35c529 | ||
|
|
c02bc4dbe9 | ||
|
|
4872811ba7 | ||
|
|
1a1290f30b | ||
|
|
7be7ca7195 | ||
|
|
32197fa52d | ||
|
|
9653a52a6a | ||
|
|
d60c8942ce | ||
|
|
c99f9e92e0 | ||
|
|
e26356607e | ||
|
|
43e5e80343 | ||
|
|
1742138f05 | ||
|
|
c767d62329 | ||
|
|
7ad29b9831 | ||
|
|
d209fe9b1e | ||
|
|
c5542637d7 | ||
|
|
e7c829fc67 | ||
|
|
579829eef2 | ||
|
|
3aa20f6e75 | ||
|
|
f78279bb2e | ||
|
|
a99d7c6314 | ||
|
|
cf1ed67fcc | ||
|
|
1aec420465 | ||
|
|
16e4b39359 | ||
|
|
9456258ccc | ||
|
|
c41d59f232 | ||
|
|
d682ef88e6 | ||
|
|
c1e6e54e6e | ||
|
|
62f657845e | ||
|
|
a9841a6d1e | ||
|
|
70ecf17f85 | ||
|
|
71d453f169 | ||
|
|
071849f82f | ||
|
|
52084b2948 | ||
|
|
dfbc6b1888 | ||
|
|
e3a8b8434c | ||
|
|
8636848e63 | ||
|
|
3d93b0c52e | ||
|
|
d9942c769e | ||
|
|
6a45e6c256 | ||
|
|
b770a429c6 | ||
|
|
11e69f6025 | ||
|
|
57837bbf67 | ||
|
|
4c60afde78 | ||
|
|
ed689cd54e | ||
|
|
7a44984069 | ||
|
|
dee72ed41f | ||
|
|
1071ef8fc5 | ||
|
|
2b535bc173 | ||
|
|
b791f00bf1 | ||
|
|
3e82ad5340 | ||
|
|
7b1030293c | ||
|
|
a5fd80bbc3 | ||
|
|
fda3937734 | ||
|
|
b13c230749 | ||
|
|
715f39a53a | ||
|
|
2f74e811f1 | ||
|
|
828efc7bcf | ||
|
|
84936b832f | ||
|
|
c8494dff7b | ||
|
|
8fcc212e7a | ||
|
|
0e281530cb | ||
|
|
efded95ed7 | ||
|
|
18870913c5 | ||
|
|
63b7282377 | ||
|
|
269dab4b3e | ||
|
|
4ece43a029 | ||
|
|
8b3e2eab5a | ||
|
|
e4c4ceb286 | ||
|
|
b7e22d00b4 | ||
|
|
1a11c972ae | ||
|
|
43b841f188 | ||
|
|
f9b0460840 | ||
|
|
659d876cd5 | ||
|
|
ac43186dff | ||
|
|
e79fb214f8 | ||
|
|
9cf58d1a52 | ||
|
|
a2a02fd7d7 | ||
|
|
237ee6f231 | ||
|
|
4e57894e85 | ||
|
|
8c9fbbf4f3 | ||
|
|
3f3d61bd58 | ||
|
|
80d4f4afc6 | ||
|
|
2546216019 | ||
|
|
ff8882a24f | ||
|
|
ffe2410639 | ||
|
|
9e14c1f88d | ||
|
|
29a5dfc7c0 | ||
|
|
645bf8b3ab | ||
|
|
f41c536ff3 | ||
|
|
bdd05bdbd3 | ||
|
|
fe385b180f | ||
|
|
0eb5d25453 | ||
|
|
1d98394b41 | ||
|
|
149d9cc851 | ||
|
|
204d8f31d7 | ||
|
|
fbe6fe7f55 | ||
|
|
168eab11a7 | ||
|
|
41b318ac7c | ||
|
|
bf636d9575 | ||
|
|
39d41d0810 | ||
|
|
9d8131c190 | ||
|
|
0ff991b25f | ||
|
|
15c70e562c | ||
|
|
8f34504736 | ||
|
|
551e0c36d9 | ||
|
|
48eba4c195 | ||
|
|
9f605178c3 | ||
|
|
bcafe51378 | ||
|
|
280fe77edd | ||
|
|
b9524f5b72 | ||
|
|
a2018b2c3f | ||
|
|
c21af7e446 | ||
|
|
d73078838d | ||
|
|
22eb0334c3 | ||
|
|
a9ac614691 | ||
|
|
1d0f68dee9 | ||
|
|
ac4bb89d43 | ||
|
|
b55f34029a | ||
|
|
907f58cc3c | ||
|
|
023b0f76c3 | ||
|
|
ddaeebc213 | ||
|
|
1262e685b8 | ||
|
|
0bd78b42c0 | ||
|
|
4a0126f7fb | ||
|
|
7acc8d703d | ||
|
|
77118f3a9f | ||
|
|
e25926d3c4 | ||
|
|
0cb75f1332 | ||
|
|
93b1b78150 | ||
|
|
493922dc4b | ||
|
|
f10854cfc5 | ||
|
|
993e7a937f | ||
|
|
f5af3cfb21 | ||
|
|
e7e112fbd0 | ||
|
|
c42087c789 | ||
|
|
3aa458ea63 | ||
|
|
c4a6f403bb | ||
|
|
9789ea3fb4 | ||
|
|
f416ae1c12 | ||
|
|
d578cf8d3f | ||
|
|
789cb91f31 | ||
|
|
eb1f8d70a7 | ||
|
|
42895efac3 | ||
|
|
483cc77c1c | ||
|
|
9b1ea8b16d | ||
|
|
b41892622d | ||
|
|
9051220243 | ||
|
|
c0031f8b85 | ||
|
|
c1a30ed995 | ||
|
|
565de3f54b | ||
|
|
153ae758c9 | ||
|
|
5086377f30 | ||
|
|
7c0789d2d2 | ||
|
|
2a32565e0c | ||
|
|
7ced0a03d2 | ||
|
|
cb51942669 | ||
|
|
093fb53773 | ||
|
|
21e00e4635 | ||
|
|
09afc6c8ee | ||
|
|
a41a927441 | ||
|
|
3fe01ff09c | ||
|
|
b5ab4d2c13 | ||
|
|
4d79d463ef | ||
|
|
7cb48fc40b | ||
|
|
8bd17bff49 | ||
|
|
3b3f42053a | ||
|
|
70ff8cfe1e | ||
|
|
6249a4b866 | ||
|
|
7e497c7f23 | ||
|
|
1536b7e206 | ||
|
|
e46d0632a5 | ||
|
|
20da167377 | ||
|
|
fe475bd856 | ||
|
|
079f48e8a6 | ||
|
|
aaa043a20f | ||
|
|
48f41e4a41 | ||
|
|
6fb80527f3 | ||
|
|
f86eba2129 | ||
|
|
50f4e0fac9 | ||
|
|
77c135349a | ||
|
|
c449512be4 | ||
|
|
17290b9121 | ||
|
|
3be369522b | ||
|
|
dbfbd8a195 | ||
|
|
9614f51560 | ||
|
|
36896f6dd0 | ||
|
|
2d08235987 | ||
|
|
2291045116 | ||
|
|
9dd1f442c5 | ||
|
|
8edece2cdb | ||
|
|
d001a94d7b | ||
|
|
c2580cfe24 | ||
|
|
dafd6f462f | ||
|
|
2111142cf1 | ||
|
|
0fc961b22e | ||
|
|
5ce34add77 | ||
|
|
934f357149 | ||
|
|
ff2766b024 | ||
|
|
9ef854f5a9 | ||
|
|
a10452be2d | ||
|
|
9cc8e40aa0 | ||
|
|
f49f92737f | ||
|
|
19344ec890 | ||
|
|
a2cc601c3d | ||
|
|
9ab1ba36cd | ||
|
|
f03c3ca6c3 | ||
|
|
0a0ded3268 | ||
|
|
6da520c5a1 | ||
|
|
68dc9af9ac | ||
|
|
f7b30ed3d4 | ||
|
|
e867528209 | ||
|
|
038dfb27a8 | ||
|
|
416c27c995 | ||
|
|
19344efa78 | ||
|
|
9c34aad21c | ||
|
|
7c2dcd7238 | ||
|
|
03149bf7f6 | ||
|
|
497021d0db | ||
|
|
cfdc5b62ad | ||
|
|
9b08e5139b | ||
|
|
e139f977b1 | ||
|
|
9abf5d9fe5 | ||
|
|
273577ba0a | ||
|
|
e15058e60f | ||
|
|
de5cd54124 | ||
|
|
c6cf09450a | ||
|
|
c6e7568471 | ||
|
|
7b8ececd8d | ||
|
|
42ba6c1b22 | ||
|
|
9a2fdf8fd4 | ||
|
|
00812c9053 | ||
|
|
33c59100ae | ||
|
|
36d904011a | ||
|
|
9d9445a48e | ||
|
|
a8da24771c | ||
|
|
ab1d18d00f | ||
|
|
ee431d482a | ||
|
|
e06c09889c | ||
|
|
86dfbda0e4 | ||
|
|
697cebb4c1 | ||
|
|
3c65475561 | ||
|
|
dc6bc0e95a | ||
|
|
b130e951cc | ||
|
|
9e19f132f2 | ||
|
|
1afe22086f | ||
|
|
8e8b9865d1 | ||
|
|
a39827a85c | ||
|
|
9e03df5500 | ||
|
|
dd602eaa61 | ||
|
|
d0d2c39dec | ||
|
|
57fec74966 | ||
|
|
9360e0ef32 | ||
|
|
f08c019d41 | ||
|
|
c3af8f6b16 | ||
|
|
01c4919f5f | ||
|
|
cdacc12ce3 | ||
|
|
d8c527a5f9 | ||
|
|
b22edcf3a5 | ||
|
|
786cff8db9 | ||
|
|
b63afaea61 | ||
|
|
9c89f7c2af | ||
|
|
d46870ede5 | ||
|
|
a888ce9963 | ||
|
|
8ff3091d16 | ||
|
|
d9f84854ac | ||
|
|
89fe2680a9 | ||
|
|
7cee982f90 | ||
|
|
42358cc521 | ||
|
|
06869ff22f | ||
|
|
616bde08ac | ||
|
|
6d0828b81c | ||
|
|
42ddf02ffc | ||
|
|
56390e0a39 | ||
|
|
18a5835aff | ||
|
|
67960dcc9a | ||
|
|
0b355ae811 | ||
|
|
6a9bb2a622 | ||
|
|
988e59cf3e | ||
|
|
30e06e9d85 | ||
|
|
810daefdd1 | ||
|
|
ccc9dc3bb4 | ||
|
|
be2eb57d62 | ||
|
|
c07d582e24 | ||
|
|
afb3a5fe71 | ||
|
|
020c403dff | ||
|
|
e77e11ec6b | ||
|
|
3edda3c5e7 | ||
|
|
1184dc08d4 | ||
|
|
18838fbc87 | ||
|
|
be2617036f | ||
|
|
0f6227f46b | ||
|
|
c1ac007576 | ||
|
|
201a8d8e7e | ||
|
|
b566cd57bf | ||
|
|
87fe00e8b4 | ||
|
|
ced83792b1 | ||
|
|
42f6d11a6b | ||
|
|
74fb959f6d | ||
|
|
9daaf01730 | ||
|
|
86a184b288 | ||
|
|
af596c0828 | ||
|
|
58c8ea1209 | ||
|
|
2f2bb82f5f | ||
|
|
6a5d210e55 | ||
|
|
384f0ee269 | ||
|
|
006a529db1 | ||
|
|
af1496b300 | ||
|
|
2b60ff588e | ||
|
|
cd89000c1d | ||
|
|
20b0b38cf4 | ||
|
|
0a8f356c72 | ||
|
|
af611815ea | ||
|
|
4ae2c64657 | ||
|
|
cd692b5a68 | ||
|
|
bf33e807b6 | ||
|
|
cf7e1c94df | ||
|
|
1b28b2b51d | ||
|
|
95baa32383 | ||
|
|
ead75c2d51 | ||
|
|
2cad9a6af8 | ||
|
|
3b7dae9a53 | ||
|
|
5ed64657d8 | ||
|
|
c6b51cea92 | ||
|
|
58d1a206c6 | ||
|
|
e0c982c5ad | ||
|
|
d4423dca19 | ||
|
|
8bcd392ee7 | ||
|
|
3a6d82b7c8 | ||
|
|
0c84a20d2f | ||
|
|
996e54763c | ||
|
|
18105c8ecb | ||
|
|
d6306b634e | ||
|
|
6e9a9d265e | ||
|
|
36648f2668 | ||
|
|
7f86cab1d2 | ||
|
|
39b1e96b45 | ||
|
|
1e9c3b3c63 | ||
|
|
fc6580574e | ||
|
|
2df7bc14fa | ||
|
|
880abd0ec2 | ||
|
|
1c69a91c25 | ||
|
|
98de5784a0 | ||
|
|
d4eda7f9e5 | ||
|
|
89a0046ad3 | ||
|
|
60a0a904e0 | ||
|
|
c0508c9321 | ||
|
|
fe44b105e4 | ||
|
|
ad7113e0db | ||
|
|
23e613fcf5 | ||
|
|
98b92c0525 | ||
|
|
57f331438a | ||
|
|
8aed444201 | ||
|
|
f97d784f17 | ||
|
|
759f949654 | ||
|
|
f1d8724198 | ||
|
|
367ee79df0 | ||
|
|
d5a84de842 | ||
|
|
355ced93cc | ||
|
|
bc0bd8213d | ||
|
|
141a823ea4 | ||
|
|
42e7959336 | ||
|
|
9947f7416a | ||
|
|
c030d6fe36 | ||
|
|
046530878b | ||
|
|
a26ebccd42 | ||
|
|
92a26a8b8c | ||
|
|
f74a98cd07 | ||
|
|
4893edd5d6 | ||
|
|
6a0a783c26 | ||
|
|
7f40c5b647 | ||
|
|
eabbc80b75 | ||
|
|
190b88fcab | ||
|
|
2adbe3ec16 | ||
|
|
9efa419955 | ||
|
|
921be61930 | ||
|
|
b0ff446727 | ||
|
|
65c0af76fb | ||
|
|
87b248f3e8 | ||
|
|
2d9f4ca9a1 | ||
|
|
fc82f2525c | ||
|
|
ded695504f | ||
|
|
ac16f2c641 | ||
|
|
fc7f1e7acb | ||
|
|
207b1bc385 | ||
|
|
d26a4ea463 | ||
|
|
422fcd294a | ||
|
|
b638886716 | ||
|
|
938130bc69 | ||
|
|
5e491e7947 | ||
|
|
792d13af49 | ||
|
|
964deae422 | ||
|
|
6a1706a62f | ||
|
|
10d689e735 | ||
|
|
5d4c3ef762 | ||
|
|
e6e737ac0b | ||
|
|
ee3f1d25d5 | ||
|
|
bfbe972225 | ||
|
|
cf217fa618 | ||
|
|
25337ac102 | ||
|
|
a3d920930b | ||
|
|
2fb6089e81 | ||
|
|
ad9b805983 | ||
|
|
04952f15df | ||
|
|
98cd8e4cad | ||
|
|
9ed1226a66 | ||
|
|
afd9b68d10 | ||
|
|
54d2249716 | ||
|
|
7eff2fe780 | ||
|
|
a731b1a916 | ||
|
|
f84f1c0cfe | ||
|
|
7d4224f207 | ||
|
|
bf14bf6259 | ||
|
|
f39a71aaad | ||
|
|
cd9a81e242 | ||
|
|
047c011a15 | ||
|
|
649685ff6d | ||
|
|
2750195709 | ||
|
|
2da096d828 | ||
|
|
2e59ff2db9 | ||
|
|
60688afe9c | ||
|
|
e8d6d53a7b | ||
|
|
dc0746946e | ||
|
|
2be5488693 | ||
|
|
d54b18ca2b | ||
|
|
fa71e9a079 | ||
|
|
0fd01f8873 | ||
|
|
a9b880921d | ||
|
|
88d9a8fc05 | ||
|
|
818b2176ef | ||
|
|
722f395e61 | ||
|
|
0027ee13a0 | ||
|
|
c7c7e875a0 | ||
|
|
85ef73591d | ||
|
|
5076beb009 | ||
|
|
f85208602d | ||
|
|
df681390a6 | ||
|
|
040164555a | ||
|
|
c67abcf818 | ||
|
|
07e2d88c20 | ||
|
|
784d6a3929 | ||
|
|
53ee4f0334 | ||
|
|
c0598e2515 | ||
|
|
3276f0c184 | ||
|
|
948d2fad0a | ||
|
|
1fdec20b0d | ||
|
|
375f6c90b0 | ||
|
|
b46abeb34d | ||
|
|
57396b55a2 | ||
|
|
c401c91ad9 | ||
|
|
5080acc127 | ||
|
|
a5cf7a9b39 | ||
|
|
97900d0442 | ||
|
|
a4f336a91a | ||
|
|
7e34645fcb | ||
|
|
1b7afd5129 | ||
|
|
7a4ba6d4a5 | ||
|
|
770d28b8c5 | ||
|
|
6c0397f497 | ||
|
|
a6b361e775 | ||
|
|
28b6237c62 | ||
|
|
e5e4df7a22 | ||
|
|
b2b94dcba7 | ||
|
|
080079c55a | ||
|
|
e6e3c75ed7 | ||
|
|
47923bd5f6 | ||
|
|
9aad945f7e | ||
|
|
9c82ff1778 | ||
|
|
ff64aafeab | ||
|
|
ba9b9367d5 | ||
|
|
e4856de8bf | ||
|
|
70d330a353 | ||
|
|
c6149adf55 | ||
|
|
5c5712be5c | ||
|
|
8941dbe482 | ||
|
|
9c1633a865 | ||
|
|
1f9aad2bb4 | ||
|
|
db3aabcc34 | ||
|
|
138ffc7cb6 | ||
|
|
d721fb2a9f | ||
|
|
7532a5cf95 | ||
|
|
71c3234dc7 | ||
|
|
ef676e1202 | ||
|
|
ecac73f664 | ||
|
|
8fccbbb026 | ||
|
|
333cf6429a | ||
|
|
add03dfb8d | ||
|
|
b55f0ac6b9 | ||
|
|
cb8a0d83fb | ||
|
|
630c592ef8 | ||
|
|
10b3cd17fa | ||
|
|
8f1cc0e9fa | ||
|
|
77fc7ac3be | ||
|
|
57100376cc | ||
|
|
1fc0d1b74f | ||
|
|
200b6536e1 | ||
|
|
7d330c19e8 | ||
|
|
774903f6c4 | ||
|
|
8d2286b769 | ||
|
|
4fe5aa99fb | ||
|
|
c76904343a | ||
|
|
60cacdffea | ||
|
|
4acad43013 | ||
|
|
49d33a4282 | ||
|
|
76f5d3364c | ||
|
|
c77924bb56 | ||
|
|
9695114230 | ||
|
|
5745bd27fd | ||
|
|
6f46f71d58 | ||
|
|
197a116f5a | ||
|
|
eb82ad5216 | ||
|
|
3934d9b24d | ||
|
|
ef46eb91a5 | ||
|
|
0cca695d6e | ||
|
|
619d934d7b | ||
|
|
9b4148b12c | ||
|
|
5071b82c77 | ||
|
|
8235957eaa | ||
|
|
be2413292f | ||
|
|
289ac55ebd | ||
|
|
7bd9cdf6fc | ||
|
|
1bf2f811ea | ||
|
|
acba07629e | ||
|
|
8a9bfd0cdd | ||
|
|
65bb36d6bd | ||
|
|
f26b8c57ff | ||
|
|
9e986d6a96 | ||
|
|
51ff77d47b | ||
|
|
2c188ee0c5 | ||
|
|
cc27a43c40 | ||
|
|
c57df2bb73 | ||
|
|
537302f2c1 | ||
|
|
264fe7fc2a | ||
|
|
add20637f2 | ||
|
|
ee9885a40c | ||
|
|
d0ab1a837a | ||
|
|
fb23df679b | ||
|
|
837ca176d1 | ||
|
|
aff2a473ec | ||
|
|
b8581ec80e | ||
|
|
af82106fae | ||
|
|
759efe1b33 | ||
|
|
7ca863c5af | ||
|
|
7800a431ea | ||
|
|
bf0f694f91 | ||
|
|
50a77f4417 | ||
|
|
fed7b29c7e | ||
|
|
5f63181ed5 | ||
|
|
9574496333 | ||
|
|
5374417428 | ||
|
|
5359b76619 | ||
|
|
c8802c776a | ||
|
|
da05d05824 | ||
|
|
d8996a1c1d | ||
|
|
e06a4e041c | ||
|
|
479c9563c7 | ||
|
|
9f6164a05c | ||
|
|
9b1fdb291e | ||
|
|
3d5a02bf45 | ||
|
|
bf595a0cb0 | ||
|
|
68c8905859 | ||
|
|
03f9963f3d | ||
|
|
257e9ba69a | ||
|
|
9c77a5b9f0 | ||
|
|
b2482535d0 | ||
|
|
097a792f9d | ||
|
|
25df71b90d | ||
|
|
c4b969ca62 | ||
|
|
409e121cac | ||
|
|
3c3d371f99 | ||
|
|
8554b80b8b | ||
|
|
3be44313aa | ||
|
|
ed280e14c8 | ||
|
|
86d505af46 | ||
|
|
7186ab25c9 | ||
|
|
a049ebd6f7 | ||
|
|
adb620c4e4 | ||
|
|
2b9830f0e7 | ||
|
|
a19cac5c46 | ||
|
|
ddcf5b801a | ||
|
|
b28fffc0f7 | ||
|
|
e6b40cb339 | ||
|
|
33ac7a346e | ||
|
|
3b10392bfc | ||
|
|
3358c9a8f1 | ||
|
|
5cdc1bdd32 | ||
|
|
31a6e5eff4 | ||
|
|
768fb9080f | ||
|
|
42b0be4cfd | ||
|
|
a0b39dba31 | ||
|
|
732288c489 | ||
|
|
34312fd6ee | ||
|
|
cf5e1bb80a | ||
|
|
5a4b2fd68c | ||
|
|
d776c9acfc | ||
|
|
329c2c2a91 | ||
|
|
d62aee506b | ||
|
|
388f0fe973 | ||
|
|
609baea95e | ||
|
|
daec63e5e6 | ||
|
|
fd756a150b | ||
|
|
c6375a0d40 | ||
|
|
24636be42b | ||
|
|
f4f8d3b5ed | ||
|
|
6616b42b2c | ||
|
|
a3c6057b51 | ||
|
|
c7266ca78d | ||
|
|
03d173cbd8 | ||
|
|
c6d6af4903 | ||
|
|
6ac09aa47c | ||
|
|
a252fadf8a | ||
|
|
78da5a3756 | ||
|
|
7fe3588e49 | ||
|
|
841ce74b43 | ||
|
|
95a374d7d2 | ||
|
|
210e71edf3 | ||
|
|
03b83a5a34 | ||
|
|
1f0c0914c7 | ||
|
|
4a753dbefc | ||
|
|
3ed37a2079 | ||
|
|
1dec1ca146 | ||
|
|
bc71e233d9 | ||
|
|
2e9bafaf14 | ||
|
|
03054598df | ||
|
|
72d905f32c | ||
|
|
c0048d6d20 | ||
|
|
324f87cf14 | ||
|
|
0084cbef5a | ||
|
|
069f5925af | ||
|
|
921991c98d | ||
|
|
326d2ef234 | ||
|
|
63b6eec278 | ||
|
|
5241dae87d | ||
|
|
4d3367e965 | ||
|
|
68cacaec68 | ||
|
|
c286fbdcd7 | ||
|
|
62036121fa | ||
|
|
110ba767e5 | ||
|
|
08e6360f23 | ||
|
|
d371764d02 | ||
|
|
b0da0cee4d | ||
|
|
d589be6c65 | ||
|
|
caa8703a23 | ||
|
|
5f32b7d961 | ||
|
|
de94a344f6 | ||
|
|
c76b28de24 | ||
|
|
944fde7c57 | ||
|
|
90dd474c3e | ||
|
|
6cbc83c6a6 | ||
|
|
e463e8622d | ||
|
|
01b13de655 | ||
|
|
41822ef782 | ||
|
|
5ed5b11b45 | ||
|
|
84955e3d62 | ||
|
|
f984446d19 | ||
|
|
0f02fecd95 | ||
|
|
28d26fca35 | ||
|
|
3676779156 | ||
|
|
3177d7b617 | ||
|
|
551bafc18d | ||
|
|
5413a73ded | ||
|
|
c587ad027f | ||
|
|
82836c7394 | ||
|
|
a8be47f0f4 | ||
|
|
5fdea440ce | ||
|
|
66aaa9e484 | ||
|
|
2b0d798982 | ||
|
|
bacae4b4ad | ||
|
|
4f62aadc93 | ||
|
|
7869ec87e0 | ||
|
|
de9697b456 | ||
|
|
0dad8dd982 | ||
|
|
41ababdf6c | ||
|
|
1a7eb6ca90 | ||
|
|
158f0e8c41 | ||
|
|
f2d4a1f022 | ||
|
|
21ce1e04fe | ||
|
|
c1be1b351d | ||
|
|
22e5fc02c3 | ||
|
|
30786abe0e | ||
|
|
3f8954b11b | ||
|
|
befe7cb1c5 | ||
|
|
65a539c02e | ||
|
|
4cc6db7281 | ||
|
|
79f075bf1b | ||
|
|
54773d23b5 | ||
|
|
7d7d7c9605 | ||
|
|
63aa968642 | ||
|
|
7a0cec5ecf | ||
|
|
2588c3e52e | ||
|
|
92615b534a | ||
|
|
7789639b5d | ||
|
|
614611a8bd | ||
|
|
4c07367bfe | ||
|
|
13a0da205b | ||
|
|
2bb0b9d6c5 | ||
|
|
a2b8506917 | ||
|
|
f725f9bc8a | ||
|
|
94d96c6179 | ||
|
|
e2f6f58fe5 | ||
|
|
db9195463d | ||
|
|
6feb8f6505 | ||
|
|
9b00472820 | ||
|
|
9d7b1960c2 | ||
|
|
5d451551b6 | ||
|
|
fada3eb932 | ||
|
|
26773ea9ef | ||
|
|
163908fe8a | ||
|
|
44ada9cd67 | ||
|
|
7eea3d7ab8 | ||
|
|
01fd4b997e | ||
|
|
e9d49161e0 | ||
|
|
9013600074 | ||
|
|
7a06b92061 | ||
|
|
338ec859a4 | ||
|
|
f6755c6f2c | ||
|
|
705411ea5c | ||
|
|
9d80ec6cc9 | ||
|
|
be5988457f | ||
|
|
33e332428c | ||
|
|
24cd6851f6 | ||
|
|
19812b2d29 | ||
|
|
4bccff9556 | ||
|
|
ef5602a590 | ||
|
|
acd70ea643 | ||
|
|
950d3c5bbc | ||
|
|
97b5962ab1 | ||
|
|
e3fa6cd96c | ||
|
|
93cc8df692 | ||
|
|
4b88872c85 | ||
|
|
c063831df5 | ||
|
|
42490f4750 | ||
|
|
63f9f3113c | ||
|
|
e37aa45681 | ||
|
|
7cbf4c9027 | ||
|
|
78ec057916 | ||
|
|
f0e02387b2 | ||
|
|
e3ff887d2a | ||
|
|
0ea6cdca90 | ||
|
|
d723466df2 | ||
|
|
732c72c98e | ||
|
|
bb4bc8caf4 | ||
|
|
38c5788232 | ||
|
|
7496e70bd7 | ||
|
|
df3fe2aa72 | ||
|
|
c1d5dda62e | ||
|
|
51915b9b0a | ||
|
|
ed575182e3 | ||
|
|
32f2d9d089 | ||
|
|
35c2958ae4 | ||
|
|
b1a8c0fe02 | ||
|
|
3dfb77416f | ||
|
|
1d4296f17f | ||
|
|
a83fb8127a | ||
|
|
9f3874e5c7 | ||
|
|
87521214d3 | ||
|
|
6a8d848a3e | ||
|
|
0d0683c28a | ||
|
|
96ad8280b2 | ||
|
|
0490707671 | ||
|
|
ac98385e55 | ||
|
|
57aaad2ddb | ||
|
|
3b929f332a | ||
|
|
c827f5092d | ||
|
|
d8feffd2bf | ||
|
|
f48c46a76a | ||
|
|
f06ee2b87b | ||
|
|
9b4c05b6b9 | ||
|
|
3b9b823df5 | ||
|
|
8aa34f616f | ||
|
|
5ea6ccbb7f | ||
|
|
434ac8734a | ||
|
|
47af583a50 | ||
|
|
aaf87abfb4 | ||
|
|
bacb4d1b4d | ||
|
|
ad2f7642f2 | ||
|
|
059580e0f7 | ||
|
|
cb2943faab | ||
|
|
7c28597e0f | ||
|
|
fb52921a86 | ||
|
|
ddc67152a5 | ||
|
|
4cf595a402 | ||
|
|
5107e84897 | ||
|
|
736a276cc9 | ||
|
|
825feac9f8 | ||
|
|
d8c0069254 | ||
|
|
33d4f854c0 | ||
|
|
9865ad27a5 | ||
|
|
16b497e12b | ||
|
|
a25af7d0f3 | ||
|
|
a11aa870b3 | ||
|
|
0431d4d639 | ||
|
|
d863978464 | ||
|
|
57d5f67552 | ||
|
|
bab7a9a085 | ||
|
|
2ab53d30d0 | ||
|
|
d25738b61e | ||
|
|
a35c897f0f | ||
|
|
1e879ef458 | ||
|
|
43514f4af6 | ||
|
|
8d75542986 | ||
|
|
3a5b576399 | ||
|
|
77b1290698 | ||
|
|
77bd6b9ec3 | ||
|
|
1bbdd2aba2 | ||
|
|
73bf358f6d | ||
|
|
f706a7e236 | ||
|
|
cfc7c9cf24 | ||
|
|
866117636e | ||
|
|
6c659494f5 | ||
|
|
02a6b39db7 | ||
|
|
f02a6c34e0 | ||
|
|
f9f97c8145 | ||
|
|
84e22168a5 | ||
|
|
b573dbba90 | ||
|
|
0c5cbbbf5c | ||
|
|
9f38a8807c | ||
|
|
64c276c23b | ||
|
|
1ee231956c | ||
|
|
788f56b40a | ||
|
|
c46a607dc1 | ||
|
|
e5106bfb96 | ||
|
|
747423be67 | ||
|
|
607e6b1c33 | ||
|
|
7a236869ba | ||
|
|
9ea971dc04 | ||
|
|
5f7ff732fa | ||
|
|
83024f57a6 | ||
|
|
01ba6a23f2 | ||
|
|
022d0210c5 | ||
|
|
f03b27c72b | ||
|
|
4ca6b42c24 | ||
|
|
bde3829131 | ||
|
|
d00d682069 | ||
|
|
f2951bd4a5 | ||
|
|
8da4573088 | ||
|
|
c03b57465b | ||
|
|
40467726e3 | ||
|
|
2e7ec8c0b9 | ||
|
|
32c97a7f2f | ||
|
|
e2d01795d2 | ||
|
|
589d3eb48f | ||
|
|
cf6034da92 | ||
|
|
ce8c56cc97 | ||
|
|
43c292fa91 | ||
|
|
cb9a0627f0 | ||
|
|
7a6446ac17 | ||
|
|
cd6af4a52e | ||
|
|
8363c6af2e | ||
|
|
6c2bf0e221 | ||
|
|
88575a27e2 | ||
|
|
3a892228f4 | ||
|
|
5fa8e5e13f | ||
|
|
73cf767a35 | ||
|
|
b2588eed03 | ||
|
|
9af78c8e69 | ||
|
|
dda3bf896b | ||
|
|
98650658a7 | ||
|
|
6f6b7f8261 | ||
|
|
bb6242675a | ||
|
|
33f9b08bbb | ||
|
|
e88d48f804 | ||
|
|
dfcc9f8cbc | ||
|
|
16f1c5f0a1 | ||
|
|
bbb3509bc5 | ||
|
|
c5c2871d22 | ||
|
|
bc4681c83d | ||
|
|
f29d3c7f74 | ||
|
|
90614dfe05 | ||
|
|
30cf20d615 | ||
|
|
c2048c5c65 | ||
|
|
ff860e5fe4 | ||
|
|
715835510b | ||
|
|
bedf2bd437 | ||
|
|
e6abe55134 | ||
|
|
83cd593b9c | ||
|
|
cd208c9d72 | ||
|
|
7579097db6 | ||
|
|
73cbe46f8d | ||
|
|
caf7aeb3a9 | ||
|
|
30fb628388 | ||
|
|
a57c2bf97e | ||
|
|
efb5e58c38 | ||
|
|
3cd63cc9e0 | ||
|
|
71fc9f3ee8 | ||
|
|
1ac47400d2 | ||
|
|
998a6b0aea | ||
|
|
ba99996676 | ||
|
|
db97bef60b | ||
|
|
10470cea67 | ||
|
|
22ccae1c9d | ||
|
|
5900b164a4 | ||
|
|
b307fc8cd5 | ||
|
|
28cd956729 | ||
|
|
6c98f222e9 | ||
|
|
8f5ff4bf66 | ||
|
|
a4b9b5a1e5 | ||
|
|
4208641de7 | ||
|
|
be568ea3b2 | ||
|
|
8b800b41c9 | ||
|
|
60bb8fa86d | ||
|
|
9017af2355 | ||
|
|
7019937b52 | ||
|
|
e8224fb0d1 | ||
|
|
46cbbe3d45 | ||
|
|
ef9700816f | ||
|
|
12cfd0d22b | ||
|
|
ee0df1b8f8 | ||
|
|
3eb91efba1 | ||
|
|
d98f9f7fe5 | ||
|
|
541872bc57 | ||
|
|
7f87280cd5 | ||
|
|
ff77658f27 | ||
|
|
81e5736510 | ||
|
|
7bef887fd1 | ||
|
|
8995d571d8 | ||
|
|
0792b65863 | ||
|
|
de4ac37baa | ||
|
|
b243f1b2ee | ||
|
|
d06c7197d4 | ||
|
|
fb039d5b82 | ||
|
|
c01251d023 | ||
|
|
1466b570ee | ||
|
|
2301bee87d | ||
|
|
81f9a23d25 | ||
|
|
c44750792a | ||
|
|
48131c6d02 | ||
|
|
9d99dad9e8 | ||
|
|
de3a898e8a | ||
|
|
9cd45ddad3 | ||
|
|
8a4a2153fd | ||
|
|
b6dfb9996a | ||
|
|
ba9f89c44e | ||
|
|
40ad11b2b5 | ||
|
|
a7d4703bfe | ||
|
|
583aaebc0a | ||
|
|
9c6502fcc9 | ||
|
|
dd7006c850 | ||
|
|
9710ec5244 | ||
|
|
6aaef3e705 | ||
|
|
0982a1a975 | ||
|
|
6d8efe9319 | ||
|
|
0cd5ed9e9b | ||
|
|
5f425ee318 | ||
|
|
6876381276 | ||
|
|
cb7e6698f3 | ||
|
|
e858270006 | ||
|
|
8986c8dfcd | ||
|
|
742e670805 | ||
|
|
b04f8acb70 | ||
|
|
11e404ca3c | ||
|
|
fb42ae3071 | ||
|
|
3a76a56824 | ||
|
|
ce5de76592 | ||
|
|
af3ffa9c41 | ||
|
|
5c275c2a1a | ||
|
|
5df9b3650a | ||
|
|
d768fc2553 | ||
|
|
0526d074d0 | ||
|
|
6642706f7b | ||
|
|
632636dba5 | ||
|
|
2b58c226db | ||
|
|
79e1984962 | ||
|
|
e40831a002 | ||
|
|
679b2288e8 | ||
|
|
5b6d4c4fd1 | ||
|
|
32186950f5 | ||
|
|
c6215b55e0 | ||
|
|
1492ae11a5 | ||
|
|
8d7f341a85 | ||
|
|
e3005e5ec4 | ||
|
|
fe3ab51b78 | ||
|
|
c579be1f2a | ||
|
|
03430887be | ||
|
|
1e29ebd412 | ||
|
|
39904f7fc6 | ||
|
|
3dddc11603 | ||
|
|
be471c328e | ||
|
|
e3d71d9bdf | ||
|
|
3dd2e85075 | ||
|
|
c13f2e1135 | ||
|
|
86955dbfe1 | ||
|
|
f0546b0ff8 | ||
|
|
a5d69ab4b0 | ||
|
|
5c48086e5c | ||
|
|
0242513ce7 | ||
|
|
509221520c | ||
|
|
545a610c6b | ||
|
|
255802d8d7 | ||
|
|
ffc159a456 | ||
|
|
8156d9ba41 | ||
|
|
70a6af6287 | ||
|
|
d6542c333d | ||
|
|
3b51abcf22 | ||
|
|
0898a868c6 | ||
|
|
9fcf413d87 | ||
|
|
bba71f696f | ||
|
|
8d185395e4 | ||
|
|
9ff017e908 | ||
|
|
fb774b77d0 | ||
|
|
82423975df | ||
|
|
66da51b631 | ||
|
|
3c86fa2ad0 | ||
|
|
0730dce5ab | ||
|
|
63f4a3c4e5 | ||
|
|
91d112bf12 | ||
|
|
4148417a2a | ||
|
|
607594f6e5 | ||
|
|
b18834be8a | ||
|
|
032723c874 | ||
|
|
c6bcf3dba5 | ||
|
|
24c15eda79 | ||
|
|
d4866d5fe6 | ||
|
|
603280cb28 | ||
|
|
a3011be0d2 | ||
|
|
71c590a37f | ||
|
|
dc1e1125a5 | ||
|
|
a75aca4d6a | ||
|
|
9df33bc536 | ||
|
|
b96c5e3687 | ||
|
|
fc28e2065a | ||
|
|
199689954b | ||
|
|
ccb8b9eb2a | ||
|
|
5a2db4c7e8 | ||
|
|
bd0fb22f0a | ||
|
|
f04cc39976 | ||
|
|
606bd5f8c6 | ||
|
|
f72deb092a | ||
|
|
f97305af31 | ||
|
|
3cbe186efb | ||
|
|
a98ee00dd9 | ||
|
|
c68baaad98 | ||
|
|
d936fde7ef | ||
|
|
70a0eb3a22 | ||
|
|
c43f2dce1b | ||
|
|
950e982001 | ||
|
|
8bd29a30bf | ||
|
|
681c0d2bfb | ||
|
|
caf096394b | ||
|
|
f6095cad99 | ||
|
|
ed786309cc | ||
|
|
e288ea153c | ||
|
|
fd451aa796 | ||
|
|
4724702d4e | ||
|
|
f0c1233d4f | ||
|
|
27634645e9 | ||
|
|
9a74bba007 | ||
|
|
70a5207bd1 | ||
|
|
33046ecee2 | ||
|
|
bf8aa9804b | ||
|
|
fd5c3e6122 | ||
|
|
82fbff4e08 | ||
|
|
76cfb5f471 | ||
|
|
2f1578ef83 | ||
|
|
bfdc4373d7 | ||
|
|
3ee1addbb9 | ||
|
|
0d28ee9274 | ||
|
|
e94bd5ccff | ||
|
|
bbab5b7a30 | ||
|
|
3eb1519bd7 | ||
|
|
0dcb6e5eb4 | ||
|
|
f1193b4891 | ||
|
|
5ddbf0c918 | ||
|
|
61e55fa50d | ||
|
|
72c46aa15e | ||
|
|
1326529f99 | ||
|
|
dac285c92a | ||
|
|
572a6b21b5 | ||
|
|
5306bb0db7 | ||
|
|
ba9962b568 | ||
|
|
9d83c5e948 | ||
|
|
ff53eed402 | ||
|
|
ac5045a00f | ||
|
|
ffe39edf2f | ||
|
|
95841ba16a | ||
|
|
d064060904 | ||
|
|
0b8ae4de5c | ||
|
|
9726c4454e | ||
|
|
8e1d28453d | ||
|
|
02197f20d0 | ||
|
|
970e8f734c | ||
|
|
ce2b6ff40e | ||
|
|
910457f68d | ||
|
|
649e5970e9 | ||
|
|
733abfcfc5 | ||
|
|
7f321a4cc6 | ||
|
|
a868bacb46 | ||
|
|
7a4aa14618 | ||
|
|
d5fac75667 | ||
|
|
977cf3cf69 | ||
|
|
07ffed8b6f | ||
|
|
7ffb414299 | ||
|
|
3c298b98ce | ||
|
|
b33a302235 | ||
|
|
20e89605c9 | ||
|
|
31ed29e551 | ||
|
|
9a5b2c93a7 | ||
|
|
d8cda9286f | ||
|
|
6125800876 | ||
|
|
4c8706d399 | ||
|
|
9ab81e1879 | ||
|
|
d603dbdef0 | ||
|
|
30601d11a8 | ||
|
|
4dc76e084b | ||
|
|
7ca0b9ddfa | ||
|
|
991d5a9c74 | ||
|
|
3afcc6faac | ||
|
|
57168f3f59 | ||
|
|
7e319756d2 | ||
|
|
e369f64669 | ||
|
|
680e7a382f | ||
|
|
847a061e31 | ||
|
|
8d9ea1b97c | ||
|
|
f5b7ebc540 | ||
|
|
1479e32e1a | ||
|
|
c8f3736b07 | ||
|
|
92a2e7411f | ||
|
|
9ec68db74f | ||
|
|
f43e3e5b4f | ||
|
|
86433c6fb5 | ||
|
|
cf8ef63c4a | ||
|
|
ec9e03d09a | ||
|
|
3bece648bd | ||
|
|
68c2d5c48d | ||
|
|
f70eda3817 | ||
|
|
a880237141 | ||
|
|
9d597390ca | ||
|
|
5f50e7d942 | ||
|
|
4f638c0e31 | ||
|
|
e2e5169f84 | ||
|
|
ebf27f6900 | ||
|
|
476c185997 | ||
|
|
f2dfc2759e | ||
|
|
dc0c3aa391 | ||
|
|
d6680b9474 | ||
|
|
859a4c3460 | ||
|
|
b9392d5cb1 | ||
|
|
a34ceb1074 | ||
|
|
51909a107f | ||
|
|
86d6ac2f06 | ||
|
|
ca5afb34bf | ||
|
|
88b66e9e28 | ||
|
|
ed946dccc7 | ||
|
|
eea85fb4c7 | ||
|
|
3206869ea5 | ||
|
|
c3e1b841f9 | ||
|
|
869c0e860f | ||
|
|
3c1f34c208 | ||
|
|
1fed7e84a3 | ||
|
|
634a2bb647 | ||
|
|
9b45ba82fd | ||
|
|
233d14f4da | ||
|
|
2e931d4994 | ||
|
|
eadf18b9fa | ||
|
|
cbbf5febff | ||
|
|
e538bef757 | ||
|
|
fc9ecdc665 | ||
|
|
37b1600d9c | ||
|
|
a0fee328bf | ||
|
|
60860aced8 | ||
|
|
b2a262e353 | ||
|
|
b895ffbf37 | ||
|
|
2ab289980a | ||
|
|
655134f77c | ||
|
|
20fcdcfea1 | ||
|
|
aa084bb49e | ||
|
|
e4a4fcfc90 | ||
|
|
43e3e53908 | ||
|
|
769ae10658 | ||
|
|
d0957529ed | ||
|
|
5a55d1390a | ||
|
|
d8b6560cbf | ||
|
|
f08bfa7cd1 | ||
|
|
93eb2c8c53 | ||
|
|
212c0c1f72 | ||
|
|
9f0973b711 | ||
|
|
df7fbcd7a5 | ||
|
|
8d7e127b17 | ||
|
|
82c65e3f37 | ||
|
|
98aa835079 | ||
|
|
944177eec3 | ||
|
|
2fdd5fa507 | ||
|
|
40e65c5115 | ||
|
|
90158b5977 | ||
|
|
31bc4c4346 | ||
|
|
d329b035ce | ||
|
|
1f19355fb0 | ||
|
|
112b0f417c | ||
|
|
e0d984597b | ||
|
|
1f5e520def | ||
|
|
90de0c1a9b | ||
|
|
743ab5728d | ||
|
|
70a674dde1 | ||
|
|
3b089fc69f | ||
|
|
ab8d685302 | ||
|
|
5e008eefaa | ||
|
|
c973801f92 | ||
|
|
8f1179d656 | ||
|
|
405b71e016 | ||
|
|
468be2a37f | ||
|
|
7d6723b5f7 | ||
|
|
f26b7b7788 | ||
|
|
a5f99e14c6 | ||
|
|
b30989a964 | ||
|
|
aa4f3a9b3d | ||
|
|
2aa177d102 | ||
|
|
66d5e5de7a | ||
|
|
af82094439 | ||
|
|
2bf612a806 | ||
|
|
c0d9eaff9b | ||
|
|
1e42689661 | ||
|
|
a109e839d1 | ||
|
|
6b01eac774 | ||
|
|
5661346c41 | ||
|
|
0d0fc13aaa | ||
|
|
83868ceb1a | ||
|
|
0fa306d73c | ||
|
|
43e1577b5d | ||
|
|
2b1e8d06e1 | ||
|
|
a284664e71 | ||
|
|
2a9bdb700d | ||
|
|
629ba1b838 | ||
|
|
c9b4d5a4a5 | ||
|
|
6cacaa94a5 | ||
|
|
332aca754b | ||
|
|
b6aeb86c20 | ||
|
|
74df7071ad | ||
|
|
04a1a84bb8 | ||
|
|
f69bdda950 | ||
|
|
43295bd4a5 | ||
|
|
e215a566a4 | ||
|
|
2a2ebf315f | ||
|
|
5340bf556e | ||
|
|
1f515663d1 | ||
|
|
2964dde903 | ||
|
|
e450416c93 | ||
|
|
b730083d7a | ||
|
|
3a1fc7315c | ||
|
|
3df68d6b00 | ||
|
|
6c437d45ac | ||
|
|
068b92b051 | ||
|
|
2372b0fdc6 | ||
|
|
eb448daa1a | ||
|
|
1bf9555e4f | ||
|
|
afe4ea4250 | ||
|
|
824efe7be4 | ||
|
|
1c78155e70 | ||
|
|
4000052d92 | ||
|
|
d52ac7d027 | ||
|
|
bd3fb2fb10 | ||
|
|
d8d7769104 | ||
|
|
4c3bdc5a36 | ||
|
|
cf63465eb0 | ||
|
|
b5c86fdc0c | ||
|
|
63c2ed1483 | ||
|
|
2e5b496053 | ||
|
|
e8c99496cd | ||
|
|
cf13d1e110 | ||
|
|
50ee41423f | ||
|
|
ea4425b9bd | ||
|
|
23d79cfda8 | ||
|
|
8b673cc4f2 | ||
|
|
fddcad6957 | ||
|
|
208d9449b7 | ||
|
|
fee585ea14 | ||
|
|
30eaf885c4 | ||
|
|
c60389acbf | ||
|
|
9ffdcc7656 | ||
|
|
a4a3d89598 | ||
|
|
0d8ba2e57f | ||
|
|
92c8cc17c3 | ||
|
|
d919fa1ed0 | ||
|
|
47a5afe5bf | ||
|
|
03b2998abe | ||
|
|
c908d2039f | ||
|
|
a06cf900c7 | ||
|
|
4e5e2c19d0 | ||
|
|
c586208991 | ||
|
|
976cf6c60f | ||
|
|
d9cd493d09 | ||
|
|
2154e1f4fb | ||
|
|
8b43fcd82b | ||
|
|
c4732af006 | ||
|
|
c8bddfba2b | ||
|
|
4403afe29c | ||
|
|
81ba6477ff | ||
|
|
23a3742dc8 | ||
|
|
4ea3370316 | ||
|
|
a9bf5367da | ||
|
|
dc74d2e054 | ||
|
|
b0a6025897 | ||
|
|
d3c5202f50 | ||
|
|
b3782d2dc8 | ||
|
|
f837dcdd58 | ||
|
|
3f6af4156f | ||
|
|
62c0617d79 | ||
|
|
3d5decb305 | ||
|
|
4694e9a2b6 | ||
|
|
2a4d4bda2b | ||
|
|
f5366ff828 | ||
|
|
5fbae8c8c6 | ||
|
|
ebe866c378 | ||
|
|
7e501f1993 | ||
|
|
049ccb4a4b | ||
|
|
822ee4e0a6 | ||
|
|
31a51cae1d | ||
|
|
f3931497f8 | ||
|
|
563b7331da | ||
|
|
8339702d47 | ||
|
|
9819470058 | ||
|
|
191a836560 | ||
|
|
674ec410b7 | ||
|
|
91e40de2da | ||
|
|
a54a88edd6 | ||
|
|
5ef790a6c4 | ||
|
|
175e45005f | ||
|
|
ce6b3a539d | ||
|
|
86159fca82 | ||
|
|
bda2a0282a | ||
|
|
38ce6adab6 | ||
|
|
f336599a3a | ||
|
|
fd8652ceda | ||
|
|
2ced370bee | ||
|
|
a4cb700269 | ||
|
|
ff6f2ff6d9 | ||
|
|
392b381d1c | ||
|
|
370f0bb98d | ||
|
|
ca0166f26f | ||
|
|
ea610a3119 | ||
|
|
bc2e0cf7ff | ||
|
|
d73fcfc176 | ||
|
|
967e5f8be3 | ||
|
|
fd4d3e8793 | ||
|
|
6f03e49e68 | ||
|
|
35779d655d | ||
|
|
49ec074271 | ||
|
|
dc893405e1 | ||
|
|
b34af611a5 | ||
|
|
bbfb44e9b2 | ||
|
|
32ce468b22 | ||
|
|
4589297e43 | ||
|
|
26e8e467e8 | ||
|
|
bb5a1925ab | ||
|
|
3a5219c6d0 | ||
|
|
e16191dbfc | ||
|
|
14a9fd58d5 | ||
|
|
aeefd585a0 | ||
|
|
18aab90959 | ||
|
|
6c82982711 | ||
|
|
e71c5efd58 | ||
|
|
2ac6cc2633 | ||
|
|
a48cc458a6 | ||
|
|
1fdacba111 | ||
|
|
b3e5a99c8f | ||
|
|
6ae26a6b54 | ||
|
|
87a59efc94 | ||
|
|
033d6472cb | ||
|
|
a06a0e1392 | ||
|
|
d48f0e114e | ||
|
|
9a0763c3a0 | ||
|
|
2420bd8584 | ||
|
|
40126ee96c | ||
|
|
31e3f2d530 | ||
|
|
98a18d064a | ||
|
|
5ac5cd995e | ||
|
|
6bde1c1837 | ||
|
|
fa835339fd | ||
|
|
b53e60f4c6 | ||
|
|
2a9e2b556a | ||
|
|
fb9e53ba19 | ||
|
|
e10f5a72ce | ||
|
|
8425084b8a | ||
|
|
dc56b3cd32 | ||
|
|
2bc05db54f | ||
|
|
bd87f6bf00 | ||
|
|
574a9e4b6c | ||
|
|
844b363baf | ||
|
|
0ab82d9531 | ||
|
|
292b335ca5 | ||
|
|
e2a26740b9 | ||
|
|
ecbdcc256f | ||
|
|
303d342d5f | ||
|
|
c914abfa19 | ||
|
|
72984c4834 | ||
|
|
ff8dd150e0 | ||
|
|
dceb6a15d0 | ||
|
|
126bacb473 | ||
|
|
592f141dee | ||
|
|
d67245c734 | ||
|
|
472d77fd0f | ||
|
|
6ea6d46d0a | ||
|
|
daa95810b5 | ||
|
|
367b4e4e0f | ||
|
|
4de0bd4c5c | ||
|
|
cf9baddd6f | ||
|
|
469eda7e44 | ||
|
|
4e053685df | ||
|
|
beb214bcb3 | ||
|
|
d056144aa1 | ||
|
|
3fb4d4df43 | ||
|
|
2df75aa117 | ||
|
|
9605b080f6 | ||
|
|
379ca54c80 | ||
|
|
edeb81ba9e | ||
|
|
78595457f9 | ||
|
|
a3cbc014c3 | ||
|
|
58fb81d19a | ||
|
|
463864f5a2 | ||
|
|
2391fe23ab | ||
|
|
80e52545a0 | ||
|
|
f03b61131b | ||
|
|
0487029fc5 | ||
|
|
5bf96c2f2c | ||
|
|
428137d876 | ||
|
|
7dbe623156 | ||
|
|
21a39c997b | ||
|
|
aebeeec1e9 | ||
|
|
26312a7774 | ||
|
|
a29196ca6a | ||
|
|
4e0a718666 | ||
|
|
41dec585df | ||
|
|
9dd58470e4 | ||
|
|
471f697423 | ||
|
|
0dd1944206 | ||
|
|
57fe03dc5a | ||
|
|
53c84fd4aa | ||
|
|
740f047a85 | ||
|
|
c2167c5ee8 | ||
|
|
e8ca5a4c7d | ||
|
|
67090dd91d | ||
|
|
401f197750 | ||
|
|
ca60aabab5 | ||
|
|
7317a0865c | ||
|
|
0b828b91a5 | ||
|
|
dcf537519f | ||
|
|
c364a7142c | ||
|
|
3a4f3ee087 | ||
|
|
6d92b99dbc | ||
|
|
e6b17e77db | ||
|
|
e23c73457a | ||
|
|
3e60ab1caf | ||
|
|
7501e297dd | ||
|
|
340fd691cb | ||
|
|
031d4864a9 | ||
|
|
2cf967ee67 | ||
|
|
e95b644139 | ||
|
|
5ee4d991b6 | ||
|
|
c4d8100b2f | ||
|
|
bef70132ac | ||
|
|
31621036ad | ||
|
|
97c8374855 | ||
|
|
4dc0f3ee6b | ||
|
|
09a66451ce | ||
|
|
0bdbf47ef9 | ||
|
|
12eceaf2b3 | ||
|
|
09a2246b00 | ||
|
|
e6d9f3f90c | ||
|
|
3f55d05386 | ||
|
|
4cb1d3d7a9 | ||
|
|
6214cd0726 | ||
|
|
9d44df9da9 | ||
|
|
212cf53ea9 | ||
|
|
ba20e46bdc | ||
|
|
8d238491d0 | ||
|
|
5a34f51d33 | ||
|
|
c489bf0a1e | ||
|
|
8502517d30 | ||
|
|
0070313e28 | ||
|
|
d01e7aac89 | ||
|
|
5fa377d927 | ||
|
|
79a9a7b931 | ||
|
|
532d06c399 | ||
|
|
013d857ef8 | ||
|
|
690d72adb3 | ||
|
|
ca18990826 | ||
|
|
5e97d79eb1 | ||
|
|
a61cbf1c33 | ||
|
|
aa7dccf8e1 | ||
|
|
708e9bc072 | ||
|
|
b0fa36734e | ||
|
|
63e17d8cad | ||
|
|
66ecb1dff4 | ||
|
|
7a95e9bf7e | ||
|
|
c80fc6bf9e | ||
|
|
2f89d2e7d8 | ||
|
|
deacfedc65 | ||
|
|
32c134f5a9 | ||
|
|
23b4e1b9d8 | ||
|
|
e810f15272 | ||
|
|
1f6c00f8ef | ||
|
|
63390d2dd6 | ||
|
|
9991a14e81 | ||
|
|
fc13e9bc2b | ||
|
|
a08f1c8c59 | ||
|
|
a10c4c60cb | ||
|
|
c89ed7c092 | ||
|
|
e7aeb77bd9 | ||
|
|
cb09705df3 | ||
|
|
4fcbd6700f | ||
|
|
ff5e3d1a88 | ||
|
|
fbc8fca067 | ||
|
|
1cfa6b0d5c | ||
|
|
b203f7f19f | ||
|
|
97d490204b | ||
|
|
55901367d0 | ||
|
|
ff250aa30e | ||
|
|
955d9d22b9 | ||
|
|
daef6f6b67 | ||
|
|
846b99e0cb | ||
|
|
d9a4449307 | ||
|
|
af69289e0e | ||
|
|
cb1131a294 | ||
|
|
e078f975c5 | ||
|
|
bf84359dfb | ||
|
|
1fa9bcc183 | ||
|
|
3f1fc9cde3 | ||
|
|
8110c7a25f | ||
|
|
dbebdb2d36 | ||
|
|
93dca5ab3f | ||
|
|
5ce194f15d | ||
|
|
af21e76fdb | ||
|
|
ec61aa3025 | ||
|
|
5c888e168e | ||
|
|
cc19203be2 | ||
|
|
7af5817245 | ||
|
|
3d33a19102 | ||
|
|
6a33a12798 | ||
|
|
8e01221d02 | ||
|
|
272f3dbf2e | ||
|
|
048f1ff18a | ||
|
|
66bab1f6cf | ||
|
|
25487757bc | ||
|
|
5af6943940 | ||
|
|
7324442b42 | ||
|
|
6f700904a9 | ||
|
|
881b8e9bb5 | ||
|
|
a9743fa047 | ||
|
|
04033add19 | ||
|
|
d9fa122fd2 | ||
|
|
fe601e5417 | ||
|
|
b06235c345 | ||
|
|
7c52d702e4 | ||
|
|
3d76748161 | ||
|
|
2d151d8ca5 | ||
|
|
24316bed49 | ||
|
|
c1acfb4341 | ||
|
|
1f8256fc50 | ||
|
|
a43a156846 | ||
|
|
79b4d83952 | ||
|
|
c30e765c7b | ||
|
|
e62db55713 | ||
|
|
266bbba484 | ||
|
|
d0fa520788 | ||
|
|
646bfe403e | ||
|
|
1574126e8a | ||
|
|
5811dd7ceb | ||
|
|
f3d6d4e802 | ||
|
|
9b571dacee | ||
|
|
527f66ed23 | ||
|
|
e67d65064e | ||
|
|
c107708bcc | ||
|
|
a477c03ad5 | ||
|
|
ae73fd363b | ||
|
|
650d38962f | ||
|
|
bb107d2979 | ||
|
|
61550ac2e0 | ||
|
|
5d69b9c4a7 | ||
|
|
2d8fd35de2 | ||
|
|
8650f44340 | ||
|
|
ca13208b6b | ||
|
|
18886cb510 | ||
|
|
d1c1e05ea7 | ||
|
|
d53e1fedd5 | ||
|
|
0d3fdae7b6 | ||
|
|
f87be8d052 | ||
|
|
351c5423f0 | ||
|
|
ac91635f82 | ||
|
|
0c73dbb7e1 | ||
|
|
5653bc8287 | ||
|
|
766b425d05 | ||
|
|
c74572da92 | ||
|
|
e94a15b3d6 | ||
|
|
1a612a5936 | ||
|
|
e25fa4ba1b | ||
|
|
906dfe9f5c | ||
|
|
106e5d07be | ||
|
|
63f2034f29 | ||
|
|
cf5f93b2b3 | ||
|
|
e46cf86d30 | ||
|
|
950af33636 | ||
|
|
4a31eedc26 | ||
|
|
4b21fd2ed1 | ||
|
|
899b3d2436 | ||
|
|
662728d6c7 | ||
|
|
b4a21b5d80 | ||
|
|
bb31776dd3 | ||
|
|
ccd7368cc5 | ||
|
|
ecb6db6b6a | ||
|
|
d4826aa1aa | ||
|
|
df1bce40f0 | ||
|
|
8ae3915cc2 | ||
|
|
4b5a16567a | ||
|
|
b72498c4ff | ||
|
|
5935100181 | ||
|
|
de5163a634 | ||
|
|
dd5299841a | ||
|
|
445dfa8512 | ||
|
|
291b85746f | ||
|
|
2cbca7ce16 | ||
|
|
9a60d41db4 | ||
|
|
bd91015b13 | ||
|
|
985bc0ee4a | ||
|
|
18671a27b6 | ||
|
|
57bd6e0447 | ||
|
|
d524cb64e7 | ||
|
|
d0b8f5340e | ||
|
|
1cabccbb2b | ||
|
|
32c3fe40eb | ||
|
|
c706aadf52 | ||
|
|
4a5182e665 | ||
|
|
117ec1b2e6 | ||
|
|
2083a6ea20 | ||
|
|
135bb1edee | ||
|
|
c91b4b2e14 | ||
|
|
3898d4e7c8 | ||
|
|
86862c976a | ||
|
|
b1be668a3e | ||
|
|
b846ec2665 | ||
|
|
4bc0a83d51 | ||
|
|
8c9bbc3749 | ||
|
|
62ff5e4b01 | ||
|
|
7da5418758 | ||
|
|
100db552d1 | ||
|
|
2b83ee5557 | ||
|
|
deffef6f13 | ||
|
|
ea5fdd5331 | ||
|
|
2ccf15e5d8 | ||
|
|
4a93294152 | ||
|
|
d55510ebc8 | ||
|
|
94c90385d2 | ||
|
|
e1799ed7c8 | ||
|
|
c87595326c | ||
|
|
b0a37e7514 | ||
|
|
e153b928ff | ||
|
|
349617a818 | ||
|
|
baf1fca273 | ||
|
|
1d2bd864f2 | ||
|
|
d94bdf7420 | ||
|
|
5289d4ed13 | ||
|
|
87d79e6d36 | ||
|
|
a7a9460d27 | ||
|
|
a877a5d8c9 | ||
|
|
857fca1095 | ||
|
|
bbd6e899a8 | ||
|
|
7a21e911e1 | ||
|
|
282a7a8d96 | ||
|
|
abeb31dd3d | ||
|
|
7f2925a01d | ||
|
|
413c4cfd1b | ||
|
|
5aba26f2cb | ||
|
|
2846be326a | ||
|
|
5f18844b32 | ||
|
|
d8433add47 | ||
|
|
d90ca7ecd6 | ||
|
|
9edef17698 | ||
|
|
c1b015f24e | ||
|
|
9311ed049b | ||
|
|
21eb2ba419 | ||
|
|
2e347d6a38 | ||
|
|
363d950ac0 | ||
|
|
5e38d26257 | ||
|
|
5ec80bd249 | ||
|
|
4744aa43af | ||
|
|
b2443aa2f9 | ||
|
|
b3cadf8260 | ||
|
|
1aa2845026 | ||
|
|
dd66ede38b | ||
|
|
a2e47b5279 | ||
|
|
3aa1e5810c | ||
|
|
b6dfca9b4d | ||
|
|
8dc06446ec | ||
|
|
fc1855f514 | ||
|
|
6d6309014e | ||
|
|
53a29a2ffa | ||
|
|
ebeb457385 | ||
|
|
1e72f5ea43 | ||
|
|
fe1778e377 | ||
|
|
c7883d5c87 | ||
|
|
c2c9b77f14 | ||
|
|
533c5ee7ad | ||
|
|
b9a00cbe8a | ||
|
|
e11295f42d | ||
|
|
c68291f627 | ||
|
|
1ef9a69f4f | ||
|
|
6d9b3704f5 | ||
|
|
63ec791854 | ||
|
|
653a159225 | ||
|
|
2159ff3256 | ||
|
|
fc83517913 | ||
|
|
3f7f9a0e20 | ||
|
|
187277eaad | ||
|
|
acc00cd13a | ||
|
|
34804f2709 | ||
|
|
3f86d6d460 | ||
|
|
0a11f1607b | ||
|
|
adb76fd1ce | ||
|
|
9a65102bfc | ||
|
|
77d5b0cc53 | ||
|
|
53d6b94e8a | ||
|
|
8f2b5d714a | ||
|
|
04cdd03525 | ||
|
|
b117c3b812 | ||
|
|
c20eb0c0ae | ||
|
|
9cbe9675ea | ||
|
|
ad38ef6ff4 | ||
|
|
de6b30a51c | ||
|
|
da4034944d | ||
|
|
756591b4ca | ||
|
|
70534cfde6 | ||
|
|
1c433f1354 | ||
|
|
c0602f357d | ||
|
|
a1fc8f8b23 | ||
|
|
52e3d960e7 | ||
|
|
26f5dfbe46 | ||
|
|
e9e5facb0e | ||
|
|
b0b07fb585 | ||
|
|
886fdb1f7e | ||
|
|
5288801d3e | ||
|
|
315961faec | ||
|
|
b96ac80901 | ||
|
|
c4d0089edb | ||
|
|
916c3787d7 | ||
|
|
9e0e860031 | ||
|
|
0e8710f507 | ||
|
|
ff135b34a4 | ||
|
|
5d0eb619f1 | ||
|
|
d388dbdea9 | ||
|
|
6a2f32b4fd | ||
|
|
1c8f7c1f7a | ||
|
|
eff881b15a | ||
|
|
a2efdb21a8 | ||
|
|
8fa0b0cd26 | ||
|
|
77b827f879 | ||
|
|
0953b994ff | ||
|
|
9077b212c3 | ||
|
|
a4e19bcd80 | ||
|
|
bc36b473f1 | ||
|
|
10975961de | ||
|
|
8d2af4fb54 | ||
|
|
ac050b2583 | ||
|
|
3234017260 | ||
|
|
938ad5a98c | ||
|
|
71ab50eddd | ||
|
|
fccce69cf0 | ||
|
|
832b8a8cf5 | ||
|
|
c9b9b0c7c3 | ||
|
|
b65eab5505 | ||
|
|
450315aa74 | ||
|
|
a20d96000e | ||
|
|
9bcf5c0b90 | ||
|
|
90f4e149c1 | ||
|
|
7e6db00dd2 | ||
|
|
05a15215c5 | ||
|
|
66db12db31 | ||
|
|
567b27e10a | ||
|
|
faf2ed48fb | ||
|
|
9f378a163f | ||
|
|
a5922546ac | ||
|
|
3476eccf48 | ||
|
|
0dbf414578 | ||
|
|
8dedccaa20 | ||
|
|
dd2fdcda79 | ||
|
|
e54d4e7fe0 | ||
|
|
0ced25ce50 | ||
|
|
1d4cdbc227 | ||
|
|
e5fd85415d | ||
|
|
b8356c650a | ||
|
|
cd30633d10 | ||
|
|
b66d62d2d0 | ||
|
|
c129ed3233 | ||
|
|
46092f2760 | ||
|
|
89d2a20e56 | ||
|
|
46ed81fc45 | ||
|
|
bb6630af31 | ||
|
|
dfd29977e0 | ||
|
|
38f1546a66 | ||
|
|
cc8b41f294 | ||
|
|
e221ef203c | ||
|
|
e6cddcf752 | ||
|
|
e6d1b6770c | ||
|
|
2624edde46 | ||
|
|
0bb1a50b88 | ||
|
|
2ca95840d1 | ||
|
|
2a4714e76b | ||
|
|
0dd4977d5c | ||
|
|
01b3bb8e2c | ||
|
|
c9cd8f9b5d | ||
|
|
3bbd66c013 | ||
|
|
eedf059d00 | ||
|
|
588865152a | ||
|
|
1fb504d0d5 | ||
|
|
34de379c7d | ||
|
|
a46916b452 | ||
|
|
df633c527d | ||
|
|
aa264ae568 | ||
|
|
ecde339f59 | ||
|
|
c713b65b9e | ||
|
|
586cafff0f | ||
|
|
5aa9e425b4 | ||
|
|
374f5ea60c | ||
|
|
88ca500546 | ||
|
|
6d0376a679 | ||
|
|
8036d0f834 | ||
|
|
852a2f2e1f | ||
|
|
593fddf84b | ||
|
|
4346098e97 | ||
|
|
e0b17e796b | ||
|
|
f986539e3c | ||
|
|
8a57d14f4b | ||
|
|
75a93207d4 | ||
|
|
55b14cdc6a | ||
|
|
8a838b0372 | ||
|
|
f652d777a6 | ||
|
|
5123bb7db4 | ||
|
|
edca27ae45 | ||
|
|
af6ae35900 | ||
|
|
8828b958f0 | ||
|
|
5aeab5ab40 | ||
|
|
c6d4baa4e5 | ||
|
|
9a55f65702 | ||
|
|
e4efd59fe0 | ||
|
|
1a4e64ba69 | ||
|
|
7c25f22074 | ||
|
|
b66501df0c | ||
|
|
4d6805284b | ||
|
|
68cf61aa46 | ||
|
|
005cd48620 | ||
|
|
9894e50c42 | ||
|
|
06c3079d66 | ||
|
|
7bbca49395 | ||
|
|
5b71943f89 | ||
|
|
a3ff5a9e25 | ||
|
|
159e648ccb | ||
|
|
c3e96cce4e | ||
|
|
35c4897d8f | ||
|
|
74ed17d41b | ||
|
|
c15396459b | ||
|
|
de34436d4c | ||
|
|
17e4f2394a | ||
|
|
ce61bf931b | ||
|
|
e8273a993e | ||
|
|
581ed718e7 | ||
|
|
2cd8ea7680 | ||
|
|
7595b22e72 | ||
|
|
7b0e688a96 | ||
|
|
af4b62d10b | ||
|
|
0c06409c9d | ||
|
|
18cfd9befa | ||
|
|
76f373ab35 | ||
|
|
617136c234 | ||
|
|
f16085a362 | ||
|
|
4ffbebedce | ||
|
|
c0d74661b7 | ||
|
|
b21a9b1c4e | ||
|
|
80f20b8e4e | ||
|
|
bd0342b0a7 | ||
|
|
5717633cf5 | ||
|
|
1ddc128860 | ||
|
|
0610f66fa9 | ||
|
|
115bb33257 | ||
|
|
71eb965dd9 | ||
|
|
fb396286ff | ||
|
|
c18a46cf56 | ||
|
|
62c646ac32 | ||
|
|
372841f70a | ||
|
|
69eff51538 | ||
|
|
7021757c9d | ||
|
|
cae2dfc95a | ||
|
|
37b7a29cca | ||
|
|
45be93f604 | ||
|
|
7cae4e8e89 | ||
|
|
7815b30c7d | ||
|
|
9abeff7f0b | ||
|
|
f584fe1b00 | ||
|
|
d162ff48f3 | ||
|
|
55aeaffb1a | ||
|
|
882d0b785d | ||
|
|
fa3871b1be | ||
|
|
c859748210 | ||
|
|
fa36e9bc88 | ||
|
|
c91a0948e3 | ||
|
|
6385bd1e08 | ||
|
|
6571dd50f8 | ||
|
|
516f6099fc | ||
|
|
7863445e5d | ||
|
|
f7bc753442 | ||
|
|
5625c62044 | ||
|
|
1a2e66f345 | ||
|
|
b8b48e2e37 | ||
|
|
2a5702a936 | ||
|
|
39dc809751 | ||
|
|
4eba98313c | ||
|
|
e4898de98d | ||
|
|
256f7e8f38 | ||
|
|
e512a3642a | ||
|
|
6d9beccb41 | ||
|
|
8d1d7fd775 | ||
|
|
c820585dd0 | ||
|
|
07bf5cbd27 | ||
|
|
444e9f3c58 | ||
|
|
59cb022c42 | ||
|
|
2991f4aad0 | ||
|
|
9e4d0b2b6d | ||
|
|
add75a06cd | ||
|
|
ccd24c9cb2 | ||
|
|
8be179de46 | ||
|
|
f65b9c0d36 | ||
|
|
549b3599ef | ||
|
|
4694afbed4 | ||
|
|
229be034fb | ||
|
|
ba542e42b7 | ||
|
|
b20753f2a3 | ||
|
|
22e9cf04ca | ||
|
|
37919a6b6a | ||
|
|
fdbc1116ef | ||
|
|
0c6c8c4efc | ||
|
|
a1f6bd55b6 | ||
|
|
c391d50cbb | ||
|
|
58b47bf01b | ||
|
|
9900ccd04e | ||
|
|
24cd726dae | ||
|
|
6c28d0dd06 | ||
|
|
f48b041cf2 | ||
|
|
a4d8437bc2 | ||
|
|
dc882adb2e | ||
|
|
470cba356d | ||
|
|
ae9ca620bd | ||
|
|
400750bb26 | ||
|
|
096f0d35a6 | ||
|
|
54553903de | ||
|
|
fb29242168 | ||
|
|
c915cfc7e4 | ||
|
|
3ad4a7a571 | ||
|
|
47174f5130 | ||
|
|
4822130b3c | ||
|
|
0bf153daa6 | ||
|
|
63a69fe085 | ||
|
|
43b36752ce | ||
|
|
19d5f4a0bd | ||
|
|
265164d251 | ||
|
|
6f0241e645 | ||
|
|
87bcc0c7e0 | ||
|
|
32be954bdd | ||
|
|
44dad918f8 | ||
|
|
bc36700d05 | ||
|
|
531daba584 | ||
|
|
8b22da69b6 | ||
|
|
7a15d10bf4 | ||
|
|
7f3feb1896 | ||
|
|
7eada28f96 | ||
|
|
b905c5d455 | ||
|
|
e388702260 | ||
|
|
60ab714451 | ||
|
|
a6129e9974 | ||
|
|
84995ae172 | ||
|
|
685eb381de | ||
|
|
ee3d3db364 | ||
|
|
90e962fff8 | ||
|
|
f165221dc4 | ||
|
|
32816eaebd | ||
|
|
7cdf5ee9bc | ||
|
|
24350879cd | ||
|
|
f3ea318a04 | ||
|
|
2c38e01b54 | ||
|
|
d0b8d036be | ||
|
|
2e39b621c9 | ||
|
|
0eb7b54731 | ||
|
|
74b424075c | ||
|
|
9169ee0e87 | ||
|
|
cdf138372c | ||
|
|
a01c9ffc6c | ||
|
|
da515570dc | ||
|
|
8457f54edc | ||
|
|
835a6c0cf0 | ||
|
|
04eee2410d | ||
|
|
3e701309a4 | ||
|
|
e9b1294331 | ||
|
|
381333c4a9 | ||
|
|
193e637de0 | ||
|
|
deb734c7f6 | ||
|
|
61b075a263 | ||
|
|
36eb16ce7d | ||
|
|
ed16f51e26 | ||
|
|
6628e542b5 | ||
|
|
507816b1d6 | ||
|
|
73b8c2ef3c | ||
|
|
36169d8a68 | ||
|
|
7c6c66cc3c | ||
|
|
6d3d47c25b | ||
|
|
1870cc70ef | ||
|
|
6b0091e185 | ||
|
|
a770a3bf7e | ||
|
|
7110226b96 | ||
|
|
ac85a3e0d3 | ||
|
|
9cc603cbad | ||
|
|
566ab9aa28 | ||
|
|
206d878127 | ||
|
|
47d06cb023 | ||
|
|
4ea07716de | ||
|
|
0aa6c6f647 | ||
|
|
88ee5b1a73 | ||
|
|
b931bbb319 | ||
|
|
817d199cbb | ||
|
|
67d2408279 | ||
|
|
07e37479c2 | ||
|
|
a6b1cbba02 | ||
|
|
5cd00eda0b | ||
|
|
745233d6a1 | ||
|
|
1764f66b7d | ||
|
|
54efe33799 | ||
|
|
d0cd68d5e4 | ||
|
|
ef54a08080 | ||
|
|
4223293ed8 | ||
|
|
f8cb759bdb | ||
|
|
3879509426 | ||
|
|
479d411dda | ||
|
|
52b6ca5706 | ||
|
|
1bdd4828bd | ||
|
|
b4520aaf2c | ||
|
|
eaa58d28dc | ||
|
|
e6b02dec19 | ||
|
|
00723f1f5c | ||
|
|
21f9b39f06 | ||
|
|
e24e9867ec | ||
|
|
6ce943f4d9 | ||
|
|
828001ecc5 | ||
|
|
58908b045b | ||
|
|
dcf41ec927 | ||
|
|
2b2b193791 | ||
|
|
7922f4ee7b | ||
|
|
5134666702 | ||
|
|
268f2b047a | ||
|
|
c284ebe0ad | ||
|
|
0d99519c3d | ||
|
|
64fb7e472a | ||
|
|
ab630f72ed | ||
|
|
96abf400a5 | ||
|
|
f733d3f3eb | ||
|
|
6aeb679066 | ||
|
|
15d7e564dd | ||
|
|
5b2048fbb9 | ||
|
|
55eb3e4773 | ||
|
|
92ecd611f6 | ||
|
|
875139f5fa | ||
|
|
7826d40ff9 | ||
|
|
edf96b06a5 | ||
|
|
ec1b8e5f05 | ||
|
|
2173365f4f | ||
|
|
7836779e21 | ||
|
|
25ae028695 | ||
|
|
1b0cc4503e | ||
|
|
a52fe9cf7f | ||
|
|
866b053f25 | ||
|
|
48897fbc44 | ||
|
|
67d995d100 | ||
|
|
ad98fad9a3 | ||
|
|
34084fe666 | ||
|
|
c5d74b1deb | ||
|
|
3bb11ec484 | ||
|
|
743939ec84 | ||
|
|
e00730d149 | ||
|
|
640149337f | ||
|
|
5f5f029e3b | ||
|
|
fa409194d3 | ||
|
|
08e2828592 | ||
|
|
bc5881c4d2 | ||
|
|
c416fe0da4 | ||
|
|
9ea05b2fb3 | ||
|
|
2349b1dbef | ||
|
|
067604bf8c | ||
|
|
7fb8eec8f1 | ||
|
|
c13838436e | ||
|
|
7a30e6b941 | ||
|
|
eb4d60b1ce | ||
|
|
0134574a67 | ||
|
|
c942f11ba8 | ||
|
|
5afe7eb850 | ||
|
|
b2fd161b07 | ||
|
|
d0655f321f | ||
|
|
fef8ee23c0 | ||
|
|
c16faa4fed | ||
|
|
bbcb199174 | ||
|
|
47c0405b33 | ||
|
|
f378a0b24d | ||
|
|
58f870ef6e | ||
|
|
eaf526b1ea | ||
|
|
87a11a9214 | ||
|
|
c2fde58701 | ||
|
|
daa93b3fdc | ||
|
|
1ebd8c1234 | ||
|
|
5d0504ee11 | ||
|
|
81d4f95c2f | ||
|
|
20c1f1aec6 | ||
|
|
82d0d85675 | ||
|
|
3c312a9150 | ||
|
|
0ed96c4609 | ||
|
|
0d3f306c8e | ||
|
|
350a434939 | ||
|
|
4bc445f080 | ||
|
|
dbdff241b2 | ||
|
|
5dfe9db788 | ||
|
|
f3dc38dcae | ||
|
|
48cbbb8757 | ||
|
|
1f966c495c | ||
|
|
b67fd8f472 | ||
|
|
16b7719418 | ||
|
|
518a687886 | ||
|
|
2dbf062a89 | ||
|
|
eb399e64d5 | ||
|
|
08b07b1a08 | ||
|
|
eb215d3d3f | ||
|
|
c225262e13 | ||
|
|
4408df1e8a | ||
|
|
bad95db878 | ||
|
|
4fc8741794 | ||
|
|
d9c95c900c | ||
|
|
a1006db91b | ||
|
|
57948a0dfc | ||
|
|
ccdebead79 | ||
|
|
4e5f80dc62 | ||
|
|
6700018ce5 | ||
|
|
b5de0a20d8 | ||
|
|
f7fb5df543 | ||
|
|
004ee66227 | ||
|
|
56e5067c46 | ||
|
|
1b96902d73 | ||
|
|
2cb268d51b | ||
|
|
fb7ce5b5d5 | ||
|
|
9fd62efcf0 | ||
|
|
0c5e9c6efa | ||
|
|
eb57cbcc29 | ||
|
|
b598bbcc2e | ||
|
|
f18cd5b19c | ||
|
|
bbe8ebf9c2 | ||
|
|
68d59a16ce | ||
|
|
7323ffeef2 | ||
|
|
4e2cc0ae2a | ||
|
|
341b330a04 | ||
|
|
eeedb43ae8 | ||
|
|
02253d1e5c | ||
|
|
f4c7141f5d | ||
|
|
8cf21feefd | ||
|
|
bbd1032a2a | ||
|
|
f0712a7569 | ||
|
|
9d1cecea8e | ||
|
|
e6995196f2 | ||
|
|
a74e37d32d | ||
|
|
d89510e1aa | ||
|
|
e3359f8349 | ||
|
|
2534aa4d2d | ||
|
|
e8adcae0f2 | ||
|
|
48c684cbc2 | ||
|
|
6f8f4bb206 | ||
|
|
cb1a626692 | ||
|
|
232050830b | ||
|
|
dd254b90d7 | ||
|
|
77deef733b | ||
|
|
24ab1bc714 | ||
|
|
647887b794 | ||
|
|
d018477359 | ||
|
|
827913102e | ||
|
|
1ee40307b5 | ||
|
|
d30b612809 | ||
|
|
697f938355 | ||
|
|
5ae2d421fb | ||
|
|
83be3afc54 | ||
|
|
c739772436 | ||
|
|
7a1abd66e7 | ||
|
|
d70d24d360 | ||
|
|
f27cac585c | ||
|
|
846d57e1b8 | ||
|
|
54670d898f | ||
|
|
c45b255a88 | ||
|
|
5e4f371408 | ||
|
|
7e4439beb7 | ||
|
|
74f150670a | ||
|
|
3c355ec3b0 | ||
|
|
d346d692eb | ||
|
|
63e07b245f | ||
|
|
a5e36a4bd6 | ||
|
|
658ecb0777 | ||
|
|
a23ce1b45f | ||
|
|
0feae4d8ae | ||
|
|
4b7e97ba53 | ||
|
|
b6b7486423 | ||
|
|
2e90841f2e | ||
|
|
b31515fec3 | ||
|
|
9a476c5f29 | ||
|
|
5423bf6db8 | ||
|
|
648471ecee | ||
|
|
7ce8135138 | ||
|
|
4fa1f961f3 | ||
|
|
df0334d3b3 | ||
|
|
6640790bdc | ||
|
|
39c55d5b6f | ||
|
|
79f09b4d85 | ||
|
|
e85ea9f67d | ||
|
|
2db9a18362 | ||
|
|
37583f0a69 | ||
|
|
06ad86053c | ||
|
|
5644d37876 | ||
|
|
ed0f2831b4 | ||
|
|
21fae50089 | ||
|
|
0f243f0388 | ||
|
|
9b3fefc435 | ||
|
|
45f4ff5485 | ||
|
|
eb8eeab05e | ||
|
|
26f2740110 | ||
|
|
a2d7f380b2 | ||
|
|
c4744620af | ||
|
|
3d660b0023 | ||
|
|
49bf7dc77e | ||
|
|
11315c589a | ||
|
|
2db5f9c215 | ||
|
|
cea87758e7 | ||
|
|
58bbce09e2 | ||
|
|
900e583c7a | ||
|
|
e698ee01dd | ||
|
|
2dd9a4fb9c | ||
|
|
b8b865fb17 | ||
|
|
da552eb73b | ||
|
|
b90a9fcd13 | ||
|
|
e19622b8db | ||
|
|
8f40f791d9 | ||
|
|
bb9a123ddd | ||
|
|
90dba3ec66 | ||
|
|
47712fc113 | ||
|
|
bf6d1aeaa4 | ||
|
|
df7b5292ab | ||
|
|
7e7c8faa34 | ||
|
|
f6a9f6b4ad | ||
|
|
9e7774bb96 | ||
|
|
7c78ebce45 | ||
|
|
80b82c8d14 | ||
|
|
8e33cc61b1 | ||
|
|
99852f8401 | ||
|
|
b749a39cdb | ||
|
|
b89f2f28bb | ||
|
|
a786a59176 | ||
|
|
eac055bfaf | ||
|
|
6ceeceab7a | ||
|
|
c9216493cf | ||
|
|
91b6145499 | ||
|
|
9cbbdb90bf | ||
|
|
f4d858e7a0 | ||
|
|
98ef369b27 | ||
|
|
fc2016dbb6 | ||
|
|
177599efb7 | ||
|
|
ad11d49d64 | ||
|
|
b74b8be680 | ||
|
|
ab244cc7ad | ||
|
|
a4be028b76 | ||
|
|
29b2d07b6b | ||
|
|
cbe781203f | ||
|
|
3a4cf62aa9 | ||
|
|
ddf53d6e4e | ||
|
|
3635b3cd6c | ||
|
|
bc112a8c89 | ||
|
|
55c694a467 | ||
|
|
be5af704ad | ||
|
|
6a489fa7f6 | ||
|
|
b9fbf02ad5 | ||
|
|
2da050413c | ||
|
|
abcd4bd246 | ||
|
|
cf30e0f935 | ||
|
|
68c2fc6824 | ||
|
|
4ff7bc3eb3 | ||
|
|
b6b4f86cfc | ||
|
|
6ce38b7395 | ||
|
|
a07df21e79 | ||
|
|
b434692db2 | ||
|
|
e483ce138f | ||
|
|
dae2868d12 | ||
|
|
5a501a8ae2 | ||
|
|
c4a9299956 | ||
|
|
3a6d90adad | ||
|
|
87ea14328c | ||
|
|
f797ac9ff6 | ||
|
|
c599ad63f8 | ||
|
|
80d76612b8 | ||
|
|
d83f356218 | ||
|
|
a1d4bf20f7 | ||
|
|
20b938bcb1 | ||
|
|
c14b0d7c00 | ||
|
|
bdab595095 | ||
|
|
50c4c5917d | ||
|
|
f1100f97f7 | ||
|
|
69a2f73449 | ||
|
|
e3c2772d2f | ||
|
|
70775b3c28 | ||
|
|
1d8e545bc1 | ||
|
|
c4a92e5799 | ||
|
|
97a317a656 | ||
|
|
cb5e681ef6 | ||
|
|
5aae58295e | ||
|
|
4a44ae06bf | ||
|
|
f4e835754c | ||
|
|
f8ad72b2ee | ||
|
|
fc1df91e03 | ||
|
|
c1573727f0 | ||
|
|
a0e2c1b4ca | ||
|
|
5f92f92908 | ||
|
|
adca856806 | ||
|
|
03945276f7 | ||
|
|
c1ede507d9 | ||
|
|
cd1fc42df6 | ||
|
|
ae541287d3 | ||
|
|
b3ca410bc3 | ||
|
|
ec151b79ec | ||
|
|
797042584e | ||
|
|
df07723e20 | ||
|
|
ee9bc355f5 | ||
|
|
250fdd08be | ||
|
|
9272fe36e2 | ||
|
|
5895f1d9f7 | ||
|
|
fadbf497a4 | ||
|
|
748633c887 | ||
|
|
d53c2d0ebe | ||
|
|
08f55414e1 | ||
|
|
7a4a286ea2 | ||
|
|
9ae658983c | ||
|
|
03da0ced46 | ||
|
|
539a6e7fa0 | ||
|
|
c95cd9ed5e | ||
|
|
c22470bd14 | ||
|
|
4c28ed4e4e | ||
|
|
31cb95893e | ||
|
|
ae83a5b010 | ||
|
|
29b70e2757 | ||
|
|
52b8274285 | ||
|
|
dcb2bb33a2 | ||
|
|
a924694820 | ||
|
|
0a94dbe051 | ||
|
|
8da756c4f0 | ||
|
|
7bb8ab1c0e | ||
|
|
5e9757b30b | ||
|
|
d1d3bbb458 | ||
|
|
45203582ff | ||
|
|
ebc9dcb3bb | ||
|
|
4bbf941436 | ||
|
|
f31847db62 | ||
|
|
f35f15b107 | ||
|
|
eef11b64e1 | ||
|
|
b8a9c740bb | ||
|
|
26b9a8e49b | ||
|
|
3e72e98e3b | ||
|
|
d5902eeae9 | ||
|
|
7e6a26cc9d | ||
|
|
b12df01861 | ||
|
|
9d42bd328c | ||
|
|
e337c1ba7d | ||
|
|
057c04e32a | ||
|
|
8e971f187a | ||
|
|
e8814a7e93 | ||
|
|
1a9f9c09b4 | ||
|
|
d9ad461b5e | ||
|
|
915097d312 | ||
|
|
181841fb67 | ||
|
|
43796bf131 | ||
|
|
e13c1e5320 | ||
|
|
e37f34facc | ||
|
|
c91680822d | ||
|
|
37bb993f53 | ||
|
|
db5a7c1740 | ||
|
|
1ec3fb5f30 | ||
|
|
8f40796f05 | ||
|
|
09e90c1645 | ||
|
|
f274b1b9d7 | ||
|
|
53914e50b9 | ||
|
|
e252984993 | ||
|
|
d3f0c72e20 | ||
|
|
4ca1de1b8b | ||
|
|
17bc11bd15 | ||
|
|
f6933e43c2 | ||
|
|
900238a306 | ||
|
|
027a7ac829 | ||
|
|
2c6c3a1d27 | ||
|
|
8382ae65b7 | ||
|
|
ec690208a3 | ||
|
|
b28b8312f2 | ||
|
|
c2d79add31 | ||
|
|
feff55b92f | ||
|
|
3d29b97768 | ||
|
|
39ea8a2787 | ||
|
|
480cdedcac | ||
|
|
88ee5a1a00 | ||
|
|
2c5f3074bc | ||
|
|
9d2ef8bf0d | ||
|
|
1a3a973bd0 | ||
|
|
adf9e77702 | ||
|
|
82e47403c6 | ||
|
|
41b8bb4eef | ||
|
|
b26523c26d | ||
|
|
200a1c62c6 | ||
|
|
e4eec92852 | ||
|
|
2df757521a | ||
|
|
8fb796b5b3 | ||
|
|
82b25a9d62 | ||
|
|
89d2c7eb26 | ||
|
|
026450c1a8 | ||
|
|
c5e2532b67 | ||
|
|
75d112c484 | ||
|
|
414208aab1 | ||
|
|
7dced37673 | ||
|
|
95d68fcba1 | ||
|
|
a05c3a7aa6 | ||
|
|
c17edd594e | ||
|
|
47795d1695 | ||
|
|
2ce8e0110c | ||
|
|
4425c1e1b3 | ||
|
|
409d52ed41 | ||
|
|
e90b5dcea3 | ||
|
|
ffcc60211d | ||
|
|
7cdb1cfc8d | ||
|
|
480ba99a16 | ||
|
|
8827b7f9a6 | ||
|
|
a4424fbebf | ||
|
|
eefbbfde77 | ||
|
|
7eeb479705 | ||
|
|
8d137233a9 | ||
|
|
c96957583f | ||
|
|
580cd16f4c | ||
|
|
4382538e4b | ||
|
|
e7a530fe4c | ||
|
|
05d07413ff | ||
|
|
b8360504f3 | ||
|
|
a062650d4b | ||
|
|
f012db9be9 | ||
|
|
299d4f3aaa | ||
|
|
eba6cf61c9 | ||
|
|
0ec410689c | ||
|
|
e0fd295054 | ||
|
|
99a8469ee4 | ||
|
|
12255411f2 | ||
|
|
c0116b2c5b | ||
|
|
799a154b91 | ||
|
|
793f4d89d6 | ||
|
|
90cd045cf3 | ||
|
|
94f6488f0e | ||
|
|
d4bf4bd7c7 | ||
|
|
522d1bd309 | ||
|
|
a21de4c483 | ||
|
|
714311a696 | ||
|
|
9f0904ce6f | ||
|
|
ae3eba6e08 | ||
|
|
6b332127ca | ||
|
|
bd40d704e2 | ||
|
|
65e5e14561 | ||
|
|
103e44d936 | ||
|
|
097973e3d5 | ||
|
|
5fef946df4 | ||
|
|
023c2c5392 | ||
|
|
e90d4a6021 | ||
|
|
2e84d1cf03 | ||
|
|
6431005169 | ||
|
|
9beb3eb593 | ||
|
|
6dee409981 | ||
|
|
f3fc81b178 | ||
|
|
463bd8abb9 | ||
|
|
a65a6d62d1 | ||
|
|
207789dc2d | ||
|
|
d7586d3d65 | ||
|
|
f8d3d247d8 | ||
|
|
6b0fa14470 | ||
|
|
a69211aff5 | ||
|
|
930245d7ff | ||
|
|
0dc8b7d5d8 | ||
|
|
19a3a9ee20 | ||
|
|
f3e01ecc42 | ||
|
|
6c260af56d | ||
|
|
e817821104 | ||
|
|
f006116bac | ||
|
|
43431e7e84 | ||
|
|
eb8b51effc | ||
|
|
389cf63cbc | ||
|
|
2148fe33cd | ||
|
|
1a6540fea0 | ||
|
|
7d702f3cef | ||
|
|
d0c462f718 | ||
|
|
238d2aa870 | ||
|
|
6bb505eb73 | ||
|
|
83b9807370 | ||
|
|
3e6e533779 | ||
|
|
27bfb56ad5 | ||
|
|
c49f2a0365 | ||
|
|
3e3eb1dd0f | ||
|
|
a4fe7e81c8 | ||
|
|
4ce26b0393 | ||
|
|
82bf0f4d48 | ||
|
|
8590ee65e6 | ||
|
|
d67b99c7e4 | ||
|
|
092c7bfeb8 | ||
|
|
bf2cf33fc6 | ||
|
|
75aeb733f2 | ||
|
|
723010ba72 | ||
|
|
7ca2e2fe88 | ||
|
|
9d450cc6d0 | ||
|
|
5571d7a21c | ||
|
|
e353d0cab3 | ||
|
|
282f7fbd37 | ||
|
|
b68fc7f104 | ||
|
|
54dfe36340 | ||
|
|
c4f4904f9b | ||
|
|
d769fec8d6 | ||
|
|
f1ce611345 | ||
|
|
3856116069 | ||
|
|
afe231c94c | ||
|
|
ae4cccb4f1 | ||
|
|
98ee93bde3 | ||
|
|
87d82170a6 | ||
|
|
3a7e15511b | ||
|
|
e128c7fcd8 | ||
|
|
8db89f8efb | ||
|
|
c271cb9ff8 | ||
|
|
6e0c663a89 | ||
|
|
56246c2936 | ||
|
|
54da493476 | ||
|
|
82ebd98c5f | ||
|
|
831c67c2d8 | ||
|
|
d6f7be6345 | ||
|
|
eb064e8a62 | ||
|
|
9b83b1daa6 | ||
|
|
4acd345c6a | ||
|
|
d9ac0e7576 | ||
|
|
dcf0bc2cc9 | ||
|
|
cf4566b47b | ||
|
|
50e77536fe | ||
|
|
cd4e467751 | ||
|
|
9228fead48 | ||
|
|
38b8a198ba | ||
|
|
1eefbd28e8 | ||
|
|
1ee944a19d | ||
|
|
1b0512aa7e | ||
|
|
b5b5d35eee | ||
|
|
c5f660e33a | ||
|
|
e1e520d741 | ||
|
|
699d9d2fac | ||
|
|
c3c3927c2b | ||
|
|
00f19b7f91 | ||
|
|
42da951edf | ||
|
|
180bbab1fc | ||
|
|
69c59c52b6 | ||
|
|
19370631ea | ||
|
|
99c1853792 | ||
|
|
a131655235 | ||
|
|
677bb168a9 | ||
|
|
c91323e4d6 | ||
|
|
50d1d04913 | ||
|
|
67e2f5869a | ||
|
|
3a9c199ae7 | ||
|
|
bd6d0b3101 | ||
|
|
f1dd65cbdf | ||
|
|
c18d7c5fcb | ||
|
|
0d64531f66 | ||
|
|
f44dafd224 | ||
|
|
198b0a23a2 | ||
|
|
ad27b7decd | ||
|
|
fc00839adc | ||
|
|
aa13bd4016 | ||
|
|
d62fd78655 | ||
|
|
6dcca5fda4 | ||
|
|
c5f6ea5c0d | ||
|
|
004a9b52f0 | ||
|
|
e5f06d2cf6 | ||
|
|
cb10bfb8ef | ||
|
|
2e00d775e4 | ||
|
|
21d9750450 | ||
|
|
f431e20f3d | ||
|
|
3c68e51609 | ||
|
|
299b7289ea | ||
|
|
4bc45fc95a | ||
|
|
f9682d2e55 | ||
|
|
a384245c5a | ||
|
|
b24d7d9c95 | ||
|
|
453a62c672 | ||
|
|
89db309e10 | ||
|
|
d53d3bce59 | ||
|
|
3439c02e9d | ||
|
|
fcd0e3082b | ||
|
|
d9767b8112 | ||
|
|
85a9c2f52b | ||
|
|
69440d19b7 | ||
|
|
eac30a86d7 | ||
|
|
d4177e954c | ||
|
|
45ae9a8e35 | ||
|
|
9f75635596 | ||
|
|
4d505574dc | ||
|
|
e8e4f4ec3e | ||
|
|
4097257bef | ||
|
|
a14512e23e | ||
|
|
84e4652513 | ||
|
|
fc3d85e34b | ||
|
|
43656d4ea7 | ||
|
|
fff85d854e | ||
|
|
cf6075fb29 | ||
|
|
33298d6df6 | ||
|
|
4bb48998e0 | ||
|
|
5d9e591ae8 | ||
|
|
4d16df9312 | ||
|
|
18e554aa61 | ||
|
|
4cb13d95ba | ||
|
|
e36d6ee06a | ||
|
|
901eed7b71 | ||
|
|
750d5830c2 | ||
|
|
e286178aa7 | ||
|
|
c176361788 | ||
|
|
dc7e53897a | ||
|
|
429c4bc51b | ||
|
|
1156d91cf8 | ||
|
|
4c5b0fbbcc | ||
|
|
5a288b1efe | ||
|
|
82c789ee58 | ||
|
|
7e0f9ab3eb | ||
|
|
87bd8965c6 | ||
|
|
2aa517c805 | ||
|
|
ec81bd2399 | ||
|
|
3ab229da70 | ||
|
|
2cecabd75e | ||
|
|
c4b0da5513 | ||
|
|
5489796737 | ||
|
|
85f09f9a4c | ||
|
|
293fd0d258 | ||
|
|
dfb7bb6830 | ||
|
|
f1e14f86c4 | ||
|
|
6644d209d2 | ||
|
|
7c4a2253e8 | ||
|
|
2d65bbd941 | ||
|
|
a609e6361a | ||
|
|
32a81e197b | ||
|
|
f2c0605d6d | ||
|
|
1677bb0dea | ||
|
|
dddc544b8f | ||
|
|
643eecde86 | ||
|
|
567d3e27ab | ||
|
|
a2e08b587a | ||
|
|
cb75ec25c8 | ||
|
|
7d06216289 | ||
|
|
4ab208ecc8 | ||
|
|
6aa0bedad2 | ||
|
|
c6e39976c6 | ||
|
|
c869366133 | ||
|
|
b9022e33ea | ||
|
|
772b3b7a06 | ||
|
|
b0d7623b7e | ||
|
|
4a96f599f6 | ||
|
|
564e44adc6 | ||
|
|
6752f41c2a | ||
|
|
51c09bf2b4 | ||
|
|
d24a44230a | ||
|
|
8d752f5aaa | ||
|
|
e7827f8bc2 | ||
|
|
f980e868dd | ||
|
|
3c1f0cfc34 | ||
|
|
5b9211d827 | ||
|
|
3f189945d8 | ||
|
|
f3ab05e7cd | ||
|
|
2219f7cc73 | ||
|
|
1fd3b9ec1c | ||
|
|
da31eddadc | ||
|
|
c660e46149 | ||
|
|
e3b1358bbc | ||
|
|
5943cd1907 | ||
|
|
78287e27c8 | ||
|
|
82bc2c87a9 | ||
|
|
cd4c94f76b | ||
|
|
bba1809eac | ||
|
|
e6ee3e9504 | ||
|
|
1c1ec84aa3 | ||
|
|
f3fcf977e4 | ||
|
|
4a3ac3bd26 | ||
|
|
3c5d3a3780 | ||
|
|
fe44f90e5b | ||
|
|
031e9bc854 | ||
|
|
0cbccc90ab | ||
|
|
71d90c11dd | ||
|
|
2546572e8e | ||
|
|
835ccbac46 | ||
|
|
b5b67c5386 | ||
|
|
fbe488e4de | ||
|
|
bb629f3be7 | ||
|
|
883a428e27 | ||
|
|
e44e2c48dd | ||
|
|
ece737274e | ||
|
|
5ece386cdf | ||
|
|
7653328ce7 | ||
|
|
fc111d2b12 | ||
|
|
04402db616 | ||
|
|
1b5a8a0f09 | ||
|
|
e33b623f21 | ||
|
|
73b54a0e5f | ||
|
|
5a97af7961 | ||
|
|
f4aefb738e | ||
|
|
481c3f3f2e | ||
|
|
cb039b986e | ||
|
|
f6c54f3f03 | ||
|
|
06d58b3b7b | ||
|
|
8968acd678 | ||
|
|
c9ef144dca | ||
|
|
09f71ed1b2 | ||
|
|
f0ddc301b7 | ||
|
|
916c4c499d | ||
|
|
fac792dc27 | ||
|
|
bbcfee362f | ||
|
|
bfc1f0ca62 | ||
|
|
7bcc0d16f2 | ||
|
|
f03776c262 | ||
|
|
ffa4d48967 | ||
|
|
79c3fd4f39 | ||
|
|
6d071c468c | ||
|
|
294accea1b | ||
|
|
792fcb1dbf | ||
|
|
da359269cb | ||
|
|
92da105b58 | ||
|
|
ecc5cea09b | ||
|
|
d68a17a1df | ||
|
|
52cb7a6382 | ||
|
|
00fda57ddf | ||
|
|
405bb8435c | ||
|
|
c6c4960b35 | ||
|
|
2c4f2393ec | ||
|
|
08bc226527 | ||
|
|
6b38334b28 | ||
|
|
c1f0918f8a | ||
|
|
6861045d38 | ||
|
|
9f8d193b11 | ||
|
|
a13e57f701 | ||
|
|
e722ba38e3 | ||
|
|
b1dc2b5353 | ||
|
|
e0e08fcd2d | ||
|
|
0a913b09cf | ||
|
|
4f7a5d1e40 | ||
|
|
6ac84585e6 | ||
|
|
d21f8ecc13 | ||
|
|
5e2150cf18 | ||
|
|
a07ad6b5a3 | ||
|
|
ff4d7d541f | ||
|
|
e8f4ca6a52 | ||
|
|
a084f2dcb7 | ||
|
|
517d673dbe | ||
|
|
b4a301f8fe | ||
|
|
04a1fc9d36 | ||
|
|
0292243b29 | ||
|
|
ef38a420b2 | ||
|
|
7536d57b16 | ||
|
|
9ee1a8f701 | ||
|
|
0e0f2f765b | ||
|
|
bff957a475 | ||
|
|
ed962e7612 | ||
|
|
458b87150b | ||
|
|
ae46a19b8e | ||
|
|
3b959c05ff | ||
|
|
46f642b030 | ||
|
|
8b74e959ef | ||
|
|
320237fdb8 | ||
|
|
161b57869e | ||
|
|
92732a2540 | ||
|
|
b3eebdec48 | ||
|
|
b24c9e34a9 | ||
|
|
073d439965 | ||
|
|
f956c17c09 | ||
|
|
0406ec0ec2 | ||
|
|
f34ebfed76 | ||
|
|
962f255ee8 | ||
|
|
c62404673e | ||
|
|
979313832c | ||
|
|
1d6fe43c7b | ||
|
|
4cbf596dc5 | ||
|
|
d738d51688 | ||
|
|
acb2413852 | ||
|
|
2628af573d | ||
|
|
aa2b3472c5 | ||
|
|
ce6be7afd4 | ||
|
|
d2d43987d0 | ||
|
|
bd3332b211 | ||
|
|
3a298454ce | ||
|
|
b588b1729a | ||
|
|
818fda0363 | ||
|
|
b4f5b99e4b | ||
|
|
e8b33af780 | ||
|
|
1d306e926a | ||
|
|
33595a255f | ||
|
|
85044a634b | ||
|
|
2d71bef0ca | ||
|
|
f6d34f066c | ||
|
|
672c49d512 | ||
|
|
27578815da | ||
|
|
25e2e22791 | ||
|
|
10d60faba5 | ||
|
|
2c755e3c55 | ||
|
|
bace79a571 | ||
|
|
4206bcc10e | ||
|
|
38064e7593 | ||
|
|
1416ceb575 | ||
|
|
d58bccfc63 | ||
|
|
9bd4b96766 | ||
|
|
0b32fa81b6 | ||
|
|
0425e3178d | ||
|
|
13f9a061ac | ||
|
|
f33d2ab29e | ||
|
|
1e9f8a3523 | ||
|
|
2fbd491ff0 | ||
|
|
81b393a493 | ||
|
|
5755bfc619 | ||
|
|
10f0094be9 | ||
|
|
786f5e505e | ||
|
|
6dffbc4849 | ||
|
|
e6fd429d58 | ||
|
|
95ab1aaaec | ||
|
|
f628afc850 | ||
|
|
49f04a997a | ||
|
|
1aeac384f3 | ||
|
|
9032ac2a05 | ||
|
|
71e00c718c | ||
|
|
7a6b21de65 | ||
|
|
4f5cb88c2b | ||
|
|
0e6eda02a6 | ||
|
|
feaa5660a3 | ||
|
|
b03f58b977 | ||
|
|
b2bc34af12 | ||
|
|
400529eea0 | ||
|
|
938156d73b | ||
|
|
ba4a884d75 | ||
|
|
2796ae81d0 | ||
|
|
f3f534a3a0 | ||
|
|
6c3ee42568 | ||
|
|
2f0ffe6adb | ||
|
|
4002dbf0c1 | ||
|
|
162d3cb1f4 | ||
|
|
7d2004a8dd | ||
|
|
860acecc0d | ||
|
|
028f9d1d87 | ||
|
|
303d20a758 | ||
|
|
3f0efc050a | ||
|
|
7804fa1b82 | ||
|
|
7b819357ff | ||
|
|
595b52490e | ||
|
|
3ec05e9405 | ||
|
|
f8a30e1588 | ||
|
|
3f6bfbaf2b | ||
|
|
95d340cc4f | ||
|
|
ff4c80d53d | ||
|
|
bc72cf2f52 | ||
|
|
de730f68a4 | ||
|
|
9cc04a0f9a | ||
|
|
349aeb806a | ||
|
|
f98c66ece8 | ||
|
|
a1009e7bd3 | ||
|
|
3c24bc5617 | ||
|
|
7f093fcddc | ||
|
|
5a564a0c1a | ||
|
|
9ebd630675 | ||
|
|
5cdd578906 | ||
|
|
a870c255c4 | ||
|
|
d5c837904b | ||
|
|
fa33603dc1 | ||
|
|
fa8294436c | ||
|
|
82f0c859a2 | ||
|
|
9768091ee4 | ||
|
|
f9c396db41 | ||
|
|
bdb7e48cba | ||
|
|
c42e89a598 | ||
|
|
afd3127d89 | ||
|
|
4ab3b18b36 | ||
|
|
2ea22fce5e | ||
|
|
cd8a7fb07b | ||
|
|
cd39920abd | ||
|
|
469a9e9439 | ||
|
|
34c0807be6 | ||
|
|
c9d482ab48 | ||
|
|
bde0224deb | ||
|
|
b6cdac05c7 | ||
|
|
4e3d661284 | ||
|
|
1c5093c1c4 | ||
|
|
67254ed8df | ||
|
|
6cf2f74fe9 | ||
|
|
1ed994a6c8 | ||
|
|
40d246b29c | ||
|
|
2977317243 | ||
|
|
3a7b9d5735 | ||
|
|
2eca63b98e | ||
|
|
c4b04b1624 | ||
|
|
efd01f3bfd | ||
|
|
749f67b7d8 | ||
|
|
a7da2357a5 | ||
|
|
f103927a52 | ||
|
|
0fd73f238d | ||
|
|
50cdfc06fb | ||
|
|
3c6cdf0115 | ||
|
|
86e648d906 | ||
|
|
849d06c0df | ||
|
|
09aee53763 | ||
|
|
4efba0bf9f | ||
|
|
0c7f64458f | ||
|
|
ff77010f70 | ||
|
|
7339845c01 | ||
|
|
99072e1d81 | ||
|
|
f9881b3b5d | ||
|
|
b1ad075d11 | ||
|
|
ef904cfef2 | ||
|
|
ddffda4da5 | ||
|
|
d5b92ac37e | ||
|
|
0a54a07909 | ||
|
|
65dd7345e0 | ||
|
|
0cefdff1b6 | ||
|
|
e771f10dc6 | ||
|
|
fc41bf46ac | ||
|
|
2808f8261c | ||
|
|
c234032fcf | ||
|
|
bc6211cca5 | ||
|
|
164590e34c | ||
|
|
9feb35b7c4 | ||
|
|
f44d02c7f5 | ||
|
|
646995384d | ||
|
|
2dfdb55ace | ||
|
|
a51668ca06 | ||
|
|
bc0e527f32 | ||
|
|
f54f171d5c | ||
|
|
01918cb017 | ||
|
|
a2c52d9f26 | ||
|
|
407075d8c7 | ||
|
|
cdd8c93f54 | ||
|
|
c88e945bc5 | ||
|
|
018f1b8a80 | ||
|
|
4b9e76aaaa | ||
|
|
46847e9b2e | ||
|
|
1952b3f746 | ||
|
|
546060f340 | ||
|
|
c44bb2df17 | ||
|
|
f7c85f3ed8 | ||
|
|
5a7cf897f2 | ||
|
|
8053b65f1e | ||
|
|
a00cdcdfcb | ||
|
|
228e1a3951 | ||
|
|
ebaf54251a | ||
|
|
b74b047730 | ||
|
|
04c6db2d0f | ||
|
|
6abb62df1e | ||
|
|
7cf00d6b72 | ||
|
|
7d59f82cf9 | ||
|
|
cbf1504fca | ||
|
|
83b2d5c513 | ||
|
|
b4e74f4310 | ||
|
|
26d73a7736 | ||
|
|
57069287a1 | ||
|
|
4799f43298 | ||
|
|
7bc6c105b7 | ||
|
|
ad71e7f9d2 | ||
|
|
71d2ab184b | ||
|
|
c067af8e7d | ||
|
|
3fa538181b | ||
|
|
be2201200f | ||
|
|
84df87011c | ||
|
|
5e36d52651 | ||
|
|
bd9133b31d | ||
|
|
9b32758a0c | ||
|
|
5aa435a9f0 | ||
|
|
1b92afa799 | ||
|
|
a618271e12 | ||
|
|
8598fd1bc5 | ||
|
|
59df942e09 | ||
|
|
621bb15b83 | ||
|
|
8e24b0bb3e | ||
|
|
0c07b10b30 | ||
|
|
8f9491ddfe | ||
|
|
9bab73f489 | ||
|
|
4e867202e8 | ||
|
|
e27b588b6c | ||
|
|
479cac4896 | ||
|
|
95e3e363ff | ||
|
|
7637518b07 | ||
|
|
9263a65b5f | ||
|
|
b29028a914 | ||
|
|
1ea17a72f0 | ||
|
|
f57aa143c1 | ||
|
|
e53094bc5f | ||
|
|
18b611bc8d | ||
|
|
79d2351ce8 | ||
|
|
79a9472dbc | ||
|
|
d64daf874f | ||
|
|
1b4402c823 | ||
|
|
7fbd2f5498 | ||
|
|
45841400f2 | ||
|
|
f38b5a1b58 | ||
|
|
da5d563375 | ||
|
|
bceccc6b63 | ||
|
|
183193bdbc | ||
|
|
5b93f0fcd3 | ||
|
|
ee3e0eb183 | ||
|
|
55db3623bf | ||
|
|
db8849e7ca | ||
|
|
bfc9fb4b3b | ||
|
|
314ee137a9 | ||
|
|
f36d2ecb07 | ||
|
|
98a478ceb3 | ||
|
|
9f39470b38 | ||
|
|
458b4b7701 | ||
|
|
31508228bc | ||
|
|
1e8c9fb490 | ||
|
|
098967a085 | ||
|
|
665f046950 | ||
|
|
641191ab20 | ||
|
|
9f2db6a0af | ||
|
|
bf03197e18 | ||
|
|
cac4eadca0 | ||
|
|
3310972d75 | ||
|
|
d95fad3d5f | ||
|
|
9ecf657703 | ||
|
|
88327c7698 | ||
|
|
e811132b05 | ||
|
|
bd2896b65e | ||
|
|
522d751eee | ||
|
|
3bc08b0dc0 | ||
|
|
af679326b2 | ||
|
|
aa6e6fa0f2 | ||
|
|
9bdbe171b7 | ||
|
|
98a3c98c28 | ||
|
|
de2ddddd60 | ||
|
|
a9ffb56b65 | ||
|
|
14b97fc889 | ||
|
|
d0a600ccaa | ||
|
|
a368548645 | ||
|
|
13fe06a459 | ||
|
|
87e87030fe | ||
|
|
a5ef1f2ed6 | ||
|
|
f5d7a80272 | ||
|
|
33f9b316a3 | ||
|
|
d6ff630498 | ||
|
|
eceaa9a493 | ||
|
|
2e19a5ecb9 | ||
|
|
fb1f0fee5a | ||
|
|
6048b0f483 | ||
|
|
f12b857415 | ||
|
|
79bdca4638 | ||
|
|
21f8ac2766 | ||
|
|
89b56c3451 | ||
|
|
fe7486d43b | ||
|
|
400b807d75 | ||
|
|
5f07da6227 | ||
|
|
7eb3ef66e5 | ||
|
|
82776c456e | ||
|
|
80bdd89856 | ||
|
|
ed6327c87b | ||
|
|
b21a710de7 | ||
|
|
aa32457772 | ||
|
|
5c78b48cdf | ||
|
|
5fc2d4a4fc | ||
|
|
969af935f3 | ||
|
|
4f04b2094c | ||
|
|
0d88f8a78b | ||
|
|
6de991d855 | ||
|
|
ff67ef945d | ||
|
|
711b8164bb | ||
|
|
35985c0add | ||
|
|
cfc81692e6 | ||
|
|
a4a7c3c68d | ||
|
|
e7d53020b4 | ||
|
|
03519021b9 | ||
|
|
6f2698004e | ||
|
|
28a5bc8fae | ||
|
|
20154f391e | ||
|
|
98c4291df2 | ||
|
|
5c0ce192ed | ||
|
|
cc743dc296 | ||
|
|
d254293a6d | ||
|
|
850c26dd46 | ||
|
|
db07f33886 | ||
|
|
2fae6a5761 | ||
|
|
2ee0962c96 | ||
|
|
42935bde71 | ||
|
|
ffebf00585 | ||
|
|
ead6d652ff | ||
|
|
a14aa788d4 | ||
|
|
d8721b35a0 | ||
|
|
97738921cd | ||
|
|
486ce9b098 | ||
|
|
8fb6666f17 | ||
|
|
cb77c2aa78 | ||
|
|
0c94c3fbee | ||
|
|
94712a8b0d | ||
|
|
dec6ec9e29 | ||
|
|
9da78d72de | ||
|
|
d0c992306d | ||
|
|
54c2d48d7d | ||
|
|
e6cbeb4f38 | ||
|
|
4581240ced | ||
|
|
f6bad7efd7 | ||
|
|
713e0ddef3 | ||
|
|
ff45b2d343 | ||
|
|
91280f1fca | ||
|
|
7de25d86e1 | ||
|
|
ba31d3a88c | ||
|
|
54cd292f09 | ||
|
|
d1f5142dab | ||
|
|
058d2b94dc | ||
|
|
c177a627d2 | ||
|
|
8f8e0975f1 | ||
|
|
b602c1fb9a | ||
|
|
7448b38327 | ||
|
|
85d5a377c5 | ||
|
|
b9a6162d2f | ||
|
|
8f5903d7c3 | ||
|
|
f0ac0d6793 | ||
|
|
2a04665626 | ||
|
|
07c0970f54 | ||
|
|
546123f950 | ||
|
|
f2f9605c63 | ||
|
|
e4e060f2be | ||
|
|
e3b034fac7 | ||
|
|
82c0eed36d | ||
|
|
80994a8de1 | ||
|
|
9e1093b7d7 | ||
|
|
f2029f9d9e | ||
|
|
b2a2c3a1e9 | ||
|
|
f915a4bf0c | ||
|
|
91b220525b | ||
|
|
988c6bc433 | ||
|
|
1d858aa89e | ||
|
|
e24a077752 | ||
|
|
645fe9013f | ||
|
|
896c1da7da | ||
|
|
d24bd7394d | ||
|
|
aebb17dc75 | ||
|
|
d9d2f84a4b | ||
|
|
068d1b97b2 | ||
|
|
4bf6f2706e | ||
|
|
9f39652d87 | ||
|
|
c48440fd40 | ||
|
|
1afe71cc0a | ||
|
|
0e1b339c10 | ||
|
|
3dceddd70e | ||
|
|
2595718dd3 | ||
|
|
6ebd737590 | ||
|
|
e64d078a4c | ||
|
|
ae0b7c7d72 | ||
|
|
a770ef3e2a | ||
|
|
b95d1de8fd | ||
|
|
7e5262ae9a | ||
|
|
14ecb5032e | ||
|
|
1bd66b65a3 | ||
|
|
051a29ca03 | ||
|
|
c6975b3bb4 | ||
|
|
68bf7c532b | ||
|
|
9b73d76ddd | ||
|
|
5d616f4c72 | ||
|
|
8a81993ae1 | ||
|
|
b5c0b2cae2 | ||
|
|
803b8815bd | ||
|
|
785ce66ab9 | ||
|
|
640d97afd0 | ||
|
|
194e9f611b | ||
|
|
ea295ac397 | ||
|
|
5512de6a61 | ||
|
|
26792b9035 | ||
|
|
919f55ac4a | ||
|
|
2cd0ba5057 | ||
|
|
80283f99fb | ||
|
|
ced74bd72c | ||
|
|
50e3e3e72f | ||
|
|
c8a706117f | ||
|
|
0b3911631b | ||
|
|
0ca78ee51f | ||
|
|
f87d80737e | ||
|
|
9fd9952752 | ||
|
|
19f3a5c612 | ||
|
|
3c451a64b5 | ||
|
|
85c48aafff | ||
|
|
61ea49c6dd | ||
|
|
3b8f92359d | ||
|
|
182357f24b | ||
|
|
0ca9664ecf | ||
|
|
508e2f0b3a | ||
|
|
f5a37d0071 | ||
|
|
4d72b8fff7 | ||
|
|
9464b94f64 | ||
|
|
c2aa40449c | ||
|
|
3f3f13fbd7 | ||
|
|
e97daead43 | ||
|
|
623f4b12d3 | ||
|
|
5a44e18490 | ||
|
|
ab6f0bb348 | ||
|
|
4e8b1b9ac2 | ||
|
|
d81aec2439 | ||
|
|
6ae04dd5a0 | ||
|
|
968296bb07 | ||
|
|
320abba341 | ||
|
|
88711e885e | ||
|
|
7f4513ec34 | ||
|
|
2d5101621b | ||
|
|
0817132f97 | ||
|
|
24abfb72eb | ||
|
|
fe7a871a23 | ||
|
|
4e4c500879 | ||
|
|
0407d847a4 | ||
|
|
19afd842bf | ||
|
|
17d4c39f24 | ||
|
|
d9e740f86d | ||
|
|
c9037fde1c | ||
|
|
84ddc72744 | ||
|
|
75842bfe66 | ||
|
|
5849b73b81 | ||
|
|
58e9d12f23 | ||
|
|
53b25635da | ||
|
|
481703d669 | ||
|
|
b0c1cefeda | ||
|
|
2c5a6f9af5 | ||
|
|
c03565611e | ||
|
|
f32fd2df69 | ||
|
|
829fe38ab1 | ||
|
|
06684c93de | ||
|
|
d17c90583a | ||
|
|
fe26f977e6 | ||
|
|
6e99a2f4bb | ||
|
|
c9896d9554 | ||
|
|
ad417f6eb7 | ||
|
|
299c552e33 | ||
|
|
cd46568ebe | ||
|
|
937f8ed095 | ||
|
|
6ce8fe0537 | ||
|
|
c363c236aa | ||
|
|
e19df0e869 | ||
|
|
7ba5ad4cfb | ||
|
|
5c82432200 | ||
|
|
74ecc866cf | ||
|
|
b20a00f93e | ||
|
|
641a885af8 | ||
|
|
62144b9f57 | ||
|
|
43a1294ed9 | ||
|
|
58f6456af7 | ||
|
|
2c6af068d7 | ||
|
|
695dc5a153 | ||
|
|
5fddddbe21 | ||
|
|
e5ae9dd53d | ||
|
|
102df8dc80 | ||
|
|
e58d16b2df | ||
|
|
e755ca37b3 | ||
|
|
3b649d2fcd | ||
|
|
533a5719c5 | ||
|
|
aeda2e5808 | ||
|
|
392da897ff | ||
|
|
d81fa579c3 | ||
|
|
515da63d2b | ||
|
|
384736e955 | ||
|
|
6f3b6c8d92 | ||
|
|
a2681ffcee | ||
|
|
50a5f84cb4 | ||
|
|
24c387206c | ||
|
|
ba93a647f1 | ||
|
|
e1606172dd | ||
|
|
c9ec33d0d0 | ||
|
|
43264dfbf4 | ||
|
|
8d37f699ad | ||
|
|
8c29f7413b | ||
|
|
17655e5ba6 | ||
|
|
95850e1aca | ||
|
|
c1f62f1fde | ||
|
|
3887d95bca | ||
|
|
cf782c4f54 | ||
|
|
e91e8a2a6c | ||
|
|
d36ac3db15 | ||
|
|
be4c01697c | ||
|
|
0072bc65e6 | ||
|
|
37f83adca8 | ||
|
|
578a63bbc9 | ||
|
|
6b83ca0077 | ||
|
|
78ae4ee82c | ||
|
|
d6edd06749 | ||
|
|
6e8d29e9a2 | ||
|
|
8dd776106d | ||
|
|
e85213a944 | ||
|
|
26f1857154 | ||
|
|
f7a037ba26 | ||
|
|
61114c6c72 | ||
|
|
d3e8709ab5 | ||
|
|
37531673a3 | ||
|
|
31901e3c07 | ||
|
|
a34de2e378 | ||
|
|
2f6935a630 | ||
|
|
a5fd5782f8 | ||
|
|
fb02df66cc | ||
|
|
d10def5b0b | ||
|
|
2357bfb254 | ||
|
|
87babfa473 | ||
|
|
eb9839fd32 | ||
|
|
6e5121be7e | ||
|
|
4efd41f3af | ||
|
|
99351c9cae | ||
|
|
60074a6bc6 | ||
|
|
a3967de9a5 | ||
|
|
044019d9d6 | ||
|
|
db44151a37 | ||
|
|
ceab7154d4 | ||
|
|
0b4c408168 | ||
|
|
f069c0ba09 | ||
|
|
9c4caf49a2 | ||
|
|
2be01ab4ec | ||
|
|
b462063cd5 | ||
|
|
8aaf86a6ea | ||
|
|
bd71cbbe27 | ||
|
|
88517ceebb | ||
|
|
6a292f09ba | ||
|
|
71ec616e4d | ||
|
|
ff526e43de | ||
|
|
d563aa7c7b | ||
|
|
ae5a62a514 | ||
|
|
c86d83f835 | ||
|
|
9a1b9f15a1 | ||
|
|
af2c7ce646 | ||
|
|
b541a97821 | ||
|
|
a8b84b7cfa | ||
|
|
495e2ed17f | ||
|
|
d8c397d1b7 | ||
|
|
d8d6c2746e | ||
|
|
6fdaaa0637 | ||
|
|
034b19b734 | ||
|
|
cb8eba1530 | ||
|
|
7aa8b8a25c | ||
|
|
abcbfcb0e8 | ||
|
|
70bc07a358 | ||
|
|
7f83b53027 | ||
|
|
8405fcdd9b | ||
|
|
f56f09ea38 | ||
|
|
c62cfe64c8 | ||
|
|
78cf3c14ca | ||
|
|
89e057dc4a | ||
|
|
466066c3a1 | ||
|
|
ff3d05d92f | ||
|
|
eadd79acec | ||
|
|
d019821281 | ||
|
|
f4848b437f | ||
|
|
e941e532fa | ||
|
|
a1986c5973 | ||
|
|
6e2b3f435a | ||
|
|
07d3c4d882 | ||
|
|
f81e87f1e2 | ||
|
|
6abfd9b8ff | ||
|
|
07c679b52d | ||
|
|
b4c633cc40 | ||
|
|
54c5070767 | ||
|
|
17cf1b21c6 | ||
|
|
8f364053ca | ||
|
|
2e4e521629 | ||
|
|
fa20f19494 | ||
|
|
c1d8b0f74e | ||
|
|
3815e4f05e | ||
|
|
72488b526b | ||
|
|
5fec6c598e | ||
|
|
dee6bb5a31 | ||
|
|
566b9623b3 | ||
|
|
3f3fb43850 | ||
|
|
2248b886fe | ||
|
|
82b30f2322 | ||
|
|
6b841a036a | ||
|
|
a7d1ee5433 | ||
|
|
0f7160eb2f | ||
|
|
91d6bff8b8 | ||
|
|
5cdccf78a1 | ||
|
|
5fc0be5045 | ||
|
|
9852bd743c | ||
|
|
7d3bf6453e | ||
|
|
fe4467ad2b | ||
|
|
b2322b3893 | ||
|
|
fccfc4e4be | ||
|
|
e65cc09276 | ||
|
|
25cf126de8 | ||
|
|
1492c9d7d9 | ||
|
|
3c63ad4a9c | ||
|
|
3b40f8e42c | ||
|
|
08b125194e | ||
|
|
1d60dd5872 | ||
|
|
f0ce29c341 | ||
|
|
e1b3dc89d2 | ||
|
|
0f708dd6e2 | ||
|
|
730312e60f | ||
|
|
bbe9da063e | ||
|
|
7ec2a2b9ce | ||
|
|
ccdc369025 | ||
|
|
768740ae98 | ||
|
|
07a13697e1 | ||
|
|
8daa1d5f54 | ||
|
|
de86bf1856 | ||
|
|
2103a09430 | ||
|
|
c6a8ad23a1 | ||
|
|
c1ec28a34b | ||
|
|
0824850bbc | ||
|
|
27c3852103 | ||
|
|
ac2ba0961b | ||
|
|
237b7a50f4 | ||
|
|
5dd5543fe4 | ||
|
|
4bb5bb9450 | ||
|
|
31b06571aa | ||
|
|
e7b1e05bbd | ||
|
|
6f9b9655d7 | ||
|
|
45ee118b26 | ||
|
|
0d6fc7eb1e | ||
|
|
ed8ddf2449 | ||
|
|
b4c9f6edba | ||
|
|
a704f57971 | ||
|
|
6b60a5c6d6 | ||
|
|
147740ed40 | ||
|
|
3df7c91f1a | ||
|
|
58744de3eb | ||
|
|
b1bd0c7fc1 | ||
|
|
76887b1d27 | ||
|
|
06a2644ab2 | ||
|
|
ef9afddd1a | ||
|
|
3065b21375 | ||
|
|
358df10191 | ||
|
|
3bb426d92c | ||
|
|
26db50d6df | ||
|
|
8c6ad55320 | ||
|
|
e0d49ad758 | ||
|
|
e725b96a59 | ||
|
|
11e2af6df7 | ||
|
|
acbbc93501 | ||
|
|
932f6cfbfc | ||
|
|
1265e212e4 | ||
|
|
e4cd8751a2 | ||
|
|
2678fe53f5 | ||
|
|
e3698e6e1f | ||
|
|
8b84fc177c | ||
|
|
5122f3477f | ||
|
|
1076a2e26c | ||
|
|
fba6140a4a | ||
|
|
51112221ee | ||
|
|
0453ad0146 | ||
|
|
ed3cfaafb2 | ||
|
|
d0d42dc4cb | ||
|
|
fbbf5a108b | ||
|
|
58b796608f | ||
|
|
05062e7d2d | ||
|
|
bfaa885f10 | ||
|
|
9913cce3ba | ||
|
|
1029f2b277 | ||
|
|
1f7ca973c5 | ||
|
|
6b1ceca86a | ||
|
|
53d4ed22e8 | ||
|
|
feb044bd2d | ||
|
|
bedf8bd437 | ||
|
|
6cb4a3bb19 | ||
|
|
4039802fce | ||
|
|
5e98770936 | ||
|
|
6ee0afb579 | ||
|
|
4e01036cb6 | ||
|
|
28687f2d55 | ||
|
|
42285ac989 | ||
|
|
6fba9a39b7 | ||
|
|
fa677fc0e1 | ||
|
|
b565644c81 | ||
|
|
7247553c77 | ||
|
|
f059fe3ef2 | ||
|
|
8b0fd63ddb | ||
|
|
336beeb09a | ||
|
|
a00b0d13ed | ||
|
|
1ca920bbeb | ||
|
|
1e376be13d | ||
|
|
6995497e5b | ||
|
|
95ed7d48c8 | ||
|
|
a61200776d | ||
|
|
a67df17763 | ||
|
|
233bae6992 | ||
|
|
d685604d04 | ||
|
|
91dec25fc9 | ||
|
|
af93453190 | ||
|
|
6e57401610 | ||
|
|
dec00d3579 | ||
|
|
154c95d0c9 | ||
|
|
ac7080b31b | ||
|
|
a073d11c3e | ||
|
|
e028ab3476 | ||
|
|
5362f956f0 | ||
|
|
8037159f93 | ||
|
|
4dbab75855 | ||
|
|
adcd5aff6f | ||
|
|
bab4da5133 | ||
|
|
3ec28ceb9b | ||
|
|
ed45052d6d | ||
|
|
411640c032 | ||
|
|
eea93638c6 | ||
|
|
a2ca51c27a | ||
|
|
e640907d24 | ||
|
|
74b2deae1c | ||
|
|
143ccd27b4 | ||
|
|
a4d2fa1b6d | ||
|
|
065c360730 | ||
|
|
738d9aece7 | ||
|
|
8c38409aef | ||
|
|
61ed6425bd | ||
|
|
6e8c93afdd | ||
|
|
8c4ae1c938 | ||
|
|
4aa02c3743 | ||
|
|
356fab7bcb | ||
|
|
9543f076fd | ||
|
|
86d6666fe7 | ||
|
|
405cc337f3 | ||
|
|
772dacc89b | ||
|
|
696d2889f4 | ||
|
|
9316b9b57a | ||
|
|
fb288ef9a7 | ||
|
|
7077980055 | ||
|
|
50b27c8c0d | ||
|
|
bbc35b0b19 | ||
|
|
d7280917da | ||
|
|
78352fdd32 | ||
|
|
63f8a2cb89 | ||
|
|
e1686c26dd | ||
|
|
a999f6f876 | ||
|
|
e62e17d046 | ||
|
|
2f04108f3a | ||
|
|
1c83c0ebcd | ||
|
|
8ec6c323b6 | ||
|
|
c5b7faaefc | ||
|
|
467ece53e6 | ||
|
|
8149bc3fa6 | ||
|
|
adf5628087 | ||
|
|
67cd496b39 | ||
|
|
184039044a | ||
|
|
757eb060cd | ||
|
|
3442066054 | ||
|
|
80235d6fdd | ||
|
|
493a1846d0 | ||
|
|
73b9328c1f | ||
|
|
248aa54bfd | ||
|
|
70cc8f2c7e | ||
|
|
92d86586b7 | ||
|
|
a8e0363914 | ||
|
|
35008200bd | ||
|
|
113356c848 | ||
|
|
b3d0ed4057 | ||
|
|
61c0189bb1 | ||
|
|
f17ecaa495 | ||
|
|
9c4d0d454a | ||
|
|
d60663ea86 | ||
|
|
ea6428a5d2 | ||
|
|
80c6b487dc | ||
|
|
7eb496c00c | ||
|
|
aad4e4ddb1 | ||
|
|
cea83c0e1f | ||
|
|
bd39fcbeea | ||
|
|
0d073907b5 | ||
|
|
5ee6dc2120 | ||
|
|
64552ae304 | ||
|
|
b95e5827c1 | ||
|
|
8a214b2f8e | ||
|
|
5bc5fe5e7e | ||
|
|
a2ace9da24 | ||
|
|
d3959a2118 | ||
|
|
1257501499 | ||
|
|
bfd7209053 | ||
|
|
1883d299bf | ||
|
|
15253448af | ||
|
|
b017dc7e32 | ||
|
|
b5a6458cde | ||
|
|
de45957c42 | ||
|
|
f4a42738af | ||
|
|
d5158620bb | ||
|
|
bf5a196c78 | ||
|
|
5d7dfefa36 | ||
|
|
dbc8cae18c | ||
|
|
1e1e0f1fbb | ||
|
|
385bf084a5 | ||
|
|
eb1f362687 | ||
|
|
5386e6583d | ||
|
|
d1497527c6 | ||
|
|
91d202da7e | ||
|
|
3888bf9d12 | ||
|
|
3df4e78492 | ||
|
|
b74b6dc77f | ||
|
|
31625c2d17 | ||
|
|
dcdaf5c8b9 | ||
|
|
36181775cd | ||
|
|
1ba7f1d03f | ||
|
|
b160de5cb4 | ||
|
|
7edaedf3a1 | ||
|
|
cb5fcb3d22 | ||
|
|
58f8421eac | ||
|
|
7a4c66b7f5 | ||
|
|
d58c3793d6 | ||
|
|
ea190d862a | ||
|
|
9f9f8c8e76 | ||
|
|
50f1f1dce9 | ||
|
|
0264ef094a | ||
|
|
f688653710 | ||
|
|
886d896098 | ||
|
|
8331000764 | ||
|
|
0cd74723e1 | ||
|
|
20e30593a5 | ||
|
|
e2a18e2b37 | ||
|
|
da724fe1c0 | ||
|
|
ffd8beb6f6 | ||
|
|
5d3cf2ff15 | ||
|
|
7f813dcb6a | ||
|
|
18bab30792 | ||
|
|
60f7b05c0c | ||
|
|
7f626c8959 | ||
|
|
886d50dcab | ||
|
|
7d3e2c83d4 | ||
|
|
1cdc4568bd | ||
|
|
99582befc4 | ||
|
|
c0d3f204b0 | ||
|
|
989cdca95f | ||
|
|
def8f852e3 | ||
|
|
349cdd6110 | ||
|
|
c54a5b3690 | ||
|
|
6d961d672d | ||
|
|
247ec2ad88 | ||
|
|
8ab2753521 | ||
|
|
2dc9bfd93a | ||
|
|
9dc6946ebf | ||
|
|
0868512bbc | ||
|
|
b519551153 | ||
|
|
f8b3f1622d | ||
|
|
0e3c5ebe1a | ||
|
|
daef51e038 | ||
|
|
e82c42661b |
79
.github/CONTRIBUTING.md
vendored
Normal file
79
.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
## What should I do before opening an issue?
|
||||||
|
|
||||||
|
Before opening an issue, please ensure that:
|
||||||
|
|
||||||
|
- Your problem is a specific problem or question or suggestion, not a general
|
||||||
|
complaint.
|
||||||
|
|
||||||
|
- `$TERM` inside tmux is screen, screen-256color, tmux or tmux-256color. Check
|
||||||
|
by running `echo $TERM` inside tmux.
|
||||||
|
|
||||||
|
- You can reproduce the problem with the latest tmux release, or a build from
|
||||||
|
Git master.
|
||||||
|
|
||||||
|
- Your question or issue is not covered [in the
|
||||||
|
manual](https://man.openbsd.org/tmux.1) (run `man tmux`).
|
||||||
|
|
||||||
|
- Your problem is not mentioned in [the CHANGES
|
||||||
|
file](https://raw.githubusercontent.com/tmux/tmux/master/CHANGES).
|
||||||
|
|
||||||
|
- Nobody else has opened the same issue recently.
|
||||||
|
|
||||||
|
## What should I include in an issue?
|
||||||
|
|
||||||
|
Please include the output of:
|
||||||
|
|
||||||
|
~~~bash
|
||||||
|
uname -sp && tmux -V && echo $TERM
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Also include:
|
||||||
|
|
||||||
|
- Your platform (Linux, macOS, or whatever).
|
||||||
|
|
||||||
|
- A brief description of the problem with steps to reproduce.
|
||||||
|
|
||||||
|
- A minimal tmux config, if you can't reproduce without a config.
|
||||||
|
|
||||||
|
- Your terminal, and `$TERM` inside and outside of tmux.
|
||||||
|
|
||||||
|
- Logs from tmux (see below). Please attach logs to the issue directly rather
|
||||||
|
than using a download site or pastebin. Put in a zip file if necessary.
|
||||||
|
|
||||||
|
- At most one or two screenshots, if helpful.
|
||||||
|
|
||||||
|
## How do I test without a .tmux.conf?
|
||||||
|
|
||||||
|
Run a separate tmux server with `-f/dev/null` to skip loading `.tmux.conf`:
|
||||||
|
|
||||||
|
~~~bash
|
||||||
|
tmux -Ltest kill-server
|
||||||
|
tmux -Ltest -f/dev/null new
|
||||||
|
~~~
|
||||||
|
|
||||||
|
## How do I get logs from tmux?
|
||||||
|
|
||||||
|
Add `-vv` to tmux to create three log files in the current directory. If you can
|
||||||
|
reproduce without a configuration file:
|
||||||
|
|
||||||
|
~~~bash
|
||||||
|
tmux -Ltest kill-server
|
||||||
|
tmux -vv -Ltest -f/dev/null new
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Or if you need your configuration:
|
||||||
|
|
||||||
|
~~~base
|
||||||
|
tmux kill-server
|
||||||
|
tmux -vv new
|
||||||
|
~~~
|
||||||
|
|
||||||
|
The log files are:
|
||||||
|
|
||||||
|
- `tmux-server*.log`: server log file.
|
||||||
|
|
||||||
|
- `tmux-client*.log`: client log file.
|
||||||
|
|
||||||
|
- `tmux-out*.log`: output log file.
|
||||||
|
|
||||||
|
Please attach the log files to your issue.
|
||||||
2
.github/FUNDING.yml
vendored
Normal file
2
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
github: nicm
|
||||||
|
liberapay: tmux
|
||||||
22
.github/ISSUE_TEMPLATE.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
### Issue description
|
||||||
|
|
||||||
|
Please read https://github.com/tmux/tmux/blob/master/.github/CONTRIBUTING.md
|
||||||
|
before opening an issue.
|
||||||
|
|
||||||
|
If you have upgraded, make sure your issue is not covered in the CHANGES file
|
||||||
|
for your version: https://raw.githubusercontent.com/tmux/tmux/master/CHANGES
|
||||||
|
|
||||||
|
Describe the problem and the steps to reproduce. Add a minimal tmux config if
|
||||||
|
necessary. Screenshots can be helpful, but no more than one or two.
|
||||||
|
|
||||||
|
Do not report bugs (crashes, incorrect behaviour) without reproducing on a tmux
|
||||||
|
built from the latest code in Git.
|
||||||
|
|
||||||
|
### Required information
|
||||||
|
|
||||||
|
Please provide the following information:
|
||||||
|
|
||||||
|
* tmux version (`tmux -V`).
|
||||||
|
* Platform (`uname -sp`).
|
||||||
|
* $TERM inside and outside of tmux (`echo $TERM`).
|
||||||
|
* Logs from tmux (`tmux kill-server; tmux -vv new`).
|
||||||
95
.github/README.md
vendored
Normal file
95
.github/README.md
vendored
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
# Welcome to tmux!
|
||||||
|
|
||||||
|
tmux is a terminal multiplexer: it enables a number of terminals to be created,
|
||||||
|
accessed, and controlled from a single screen. tmux may be detached from a
|
||||||
|
screen and continue running in the background, then later reattached.
|
||||||
|
|
||||||
|
This release runs on OpenBSD, FreeBSD, NetBSD, Linux, macOS and Solaris.
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
tmux depends on [libevent](https://libevent.org) 2.x, available from [this
|
||||||
|
page](https://github.com/libevent/libevent/releases/latest).
|
||||||
|
|
||||||
|
It also depends on [ncurses](https://www.gnu.org/software/ncurses/), available
|
||||||
|
from [this page](https://invisible-mirror.net/archives/ncurses/).
|
||||||
|
|
||||||
|
To build tmux, a C compiler (for example gcc or clang), make, pkg-config and a
|
||||||
|
suitable yacc (yacc or bison) are needed.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Binary packages
|
||||||
|
|
||||||
|
Some platforms provide binary packages for tmux, although these are sometimes
|
||||||
|
out of date. Examples are listed on
|
||||||
|
[this page](https://github.com/tmux/tmux/wiki/Installing).
|
||||||
|
|
||||||
|
### From release tarball
|
||||||
|
|
||||||
|
To build and install tmux from a release tarball, use:
|
||||||
|
|
||||||
|
~~~bash
|
||||||
|
./configure && make
|
||||||
|
sudo make install
|
||||||
|
~~~
|
||||||
|
|
||||||
|
tmux can use the utempter library to update utmp(5), if it is installed - run
|
||||||
|
configure with `--enable-utempter` to enable this.
|
||||||
|
|
||||||
|
For more detailed instructions on building and installing tmux, see
|
||||||
|
[this page](https://github.com/tmux/tmux/wiki/Installing).
|
||||||
|
|
||||||
|
### From version control
|
||||||
|
|
||||||
|
To get and build the latest from version control - note that this requires
|
||||||
|
`autoconf`, `automake` and `pkg-config`:
|
||||||
|
|
||||||
|
~~~bash
|
||||||
|
git clone https://github.com/tmux/tmux.git
|
||||||
|
cd tmux
|
||||||
|
sh autogen.sh
|
||||||
|
./configure && make
|
||||||
|
~~~
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Bug reports, feature suggestions and especially code contributions are most
|
||||||
|
welcome. Please send by email to:
|
||||||
|
|
||||||
|
tmux-users@googlegroups.com
|
||||||
|
|
||||||
|
Or open a GitHub issue or pull request. **Please read [this
|
||||||
|
document](CONTRIBUTING.md) before opening an issue.**
|
||||||
|
|
||||||
|
There is [a list of suggestions for contributions](https://github.com/tmux/tmux/wiki/Contributing).
|
||||||
|
Please feel free to ask on the mailing list if you're thinking of working on something or need
|
||||||
|
further information.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
For documentation on using tmux, see the tmux.1 manpage. View it from the
|
||||||
|
source tree with:
|
||||||
|
|
||||||
|
~~~bash
|
||||||
|
nroff -mdoc tmux.1|less
|
||||||
|
~~~
|
||||||
|
|
||||||
|
A small example configuration is in `example_tmux.conf`.
|
||||||
|
|
||||||
|
And a bash(1) completion file at:
|
||||||
|
|
||||||
|
https://github.com/imomaliev/tmux-bash-completion
|
||||||
|
|
||||||
|
For debugging, run tmux with `-v` or `-vv` to generate server and client log
|
||||||
|
files in the current directory.
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
The tmux mailing list for general discussion and bug reports is:
|
||||||
|
|
||||||
|
https://groups.google.com/forum/#!forum/tmux-users
|
||||||
|
|
||||||
|
Subscribe by sending an email to:
|
||||||
|
|
||||||
|
tmux-users+subscribe@googlegroups.com
|
||||||
24
.github/travis/before-install.sh
vendored
Normal file
24
.github/travis/before-install.sh
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
||||||
|
sudo apt-get update -qq
|
||||||
|
sudo apt-get -y install bison \
|
||||||
|
autotools-dev \
|
||||||
|
libncurses5-dev \
|
||||||
|
libevent-dev \
|
||||||
|
pkg-config \
|
||||||
|
libutempter-dev \
|
||||||
|
build-essential
|
||||||
|
|
||||||
|
if [ "$BUILD" = "musl" -o "$BUILD" = "musl-static" ]; then
|
||||||
|
sudo apt-get -y install musl-dev \
|
||||||
|
musl-tools
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$TRAVIS_OS_NAME" = "freebsd" ]; then
|
||||||
|
sudo pkg install -y \
|
||||||
|
automake \
|
||||||
|
libevent \
|
||||||
|
pkgconf
|
||||||
|
fi
|
||||||
38
.github/travis/build-all.sh
vendored
Normal file
38
.github/travis/build-all.sh
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
BUILD=$PWD/build
|
||||||
|
|
||||||
|
LIBEVENT=https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stab\
|
||||||
|
le.tar.gz
|
||||||
|
NCURSES=https://ftp.gnu.org/gnu/ncurses/ncurses-6.2.tar.gz
|
||||||
|
|
||||||
|
wget -4q $LIBEVENT || exit 1
|
||||||
|
tar -zxf libevent-*.tar.gz || exit 1
|
||||||
|
(cd libevent-*/ &&
|
||||||
|
./configure --prefix=$BUILD \
|
||||||
|
--enable-shared \
|
||||||
|
--disable-libevent-regress \
|
||||||
|
--disable-samples &&
|
||||||
|
make && make install) || exit 1
|
||||||
|
|
||||||
|
wget -4q $NCURSES || exit 1
|
||||||
|
tar -zxf ncurses-*.tar.gz || exit 1
|
||||||
|
(cd ncurses-*/ &&
|
||||||
|
CPPFLAGS=-P ./configure --prefix=$BUILD \
|
||||||
|
--with-shared \
|
||||||
|
--with-termlib \
|
||||||
|
--without-ada \
|
||||||
|
--without-cxx \
|
||||||
|
--without-manpages \
|
||||||
|
--without-progs \
|
||||||
|
--without-tests \
|
||||||
|
--without-tack \
|
||||||
|
--disable-database \
|
||||||
|
--enable-termcap \
|
||||||
|
--enable-pc-files \
|
||||||
|
--with-pkg-config-libdir=$BUILD/lib/pkgconfig &&
|
||||||
|
make && make install) || exit 1
|
||||||
|
|
||||||
|
sh autogen.sh || exit 1
|
||||||
|
PKG_CONFIG_PATH=$BUILD/lib/pkgconfig ./configure --prefix=$BUILD "$@"
|
||||||
|
make && make install || (cat config.log; exit 1)
|
||||||
25
.github/travis/build.sh
vendored
Normal file
25
.github/travis/build.sh
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
sh autogen.sh || exit 1
|
||||||
|
case "$BUILD" in
|
||||||
|
static)
|
||||||
|
./configure --enable-static || exit 1
|
||||||
|
exec make
|
||||||
|
;;
|
||||||
|
all)
|
||||||
|
sh $(dirname $0)/build-all.sh
|
||||||
|
exec make
|
||||||
|
;;
|
||||||
|
musl)
|
||||||
|
CC=musl-gcc sh $(dirname $0)/build-all.sh
|
||||||
|
exec make
|
||||||
|
;;
|
||||||
|
musl-static)
|
||||||
|
CC=musl-gcc sh $(dirname $0)/build-all.sh --enable-static
|
||||||
|
exec make
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
./configure || exit 1
|
||||||
|
exec make
|
||||||
|
;;
|
||||||
|
esac
|
||||||
34
.github/workflows/lock.yml
vendored
Normal file
34
.github/workflows/lock.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
name: 'Lock Threads'
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
discussions: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: lock-threads
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
action:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: dessant/lock-threads@v5
|
||||||
|
with:
|
||||||
|
github-token: ${{ github.token }}
|
||||||
|
issue-inactive-days: '30'
|
||||||
|
issue-comment: >
|
||||||
|
This issue has been automatically locked since there
|
||||||
|
has not been any recent activity after it was closed.
|
||||||
|
pr-inactive-days: '60'
|
||||||
|
pr-comment: >
|
||||||
|
This pull request has been automatically locked since there
|
||||||
|
has not been any recent activity after it was closed.
|
||||||
|
discussion-inactive-days: '60'
|
||||||
|
discussion-comment: >
|
||||||
|
This discussion has been automatically locked since there
|
||||||
|
has not been any recent activity after it was closed.
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -18,3 +18,6 @@ Makefile.in
|
|||||||
configure
|
configure
|
||||||
tmux.1.*
|
tmux.1.*
|
||||||
*.dSYM
|
*.dSYM
|
||||||
|
cmd-parse.c
|
||||||
|
fuzz/*-fuzzer
|
||||||
|
.dirstamp
|
||||||
|
|||||||
94
.travis.yml
94
.travis.yml
@@ -1,10 +1,88 @@
|
|||||||
language: c
|
language: c
|
||||||
matrix:
|
|
||||||
include:
|
os:
|
||||||
- compiler: gcc
|
- linux
|
||||||
- compiler: clang
|
- freebsd
|
||||||
env: CFLAGS="-g -O2"
|
- osx
|
||||||
|
|
||||||
|
compiler:
|
||||||
|
- gcc
|
||||||
|
- clang
|
||||||
|
|
||||||
|
arch:
|
||||||
|
- amd64
|
||||||
|
- arm64
|
||||||
|
|
||||||
|
env:
|
||||||
|
- BUILD=
|
||||||
|
- BUILD=static
|
||||||
|
- BUILD=all
|
||||||
|
- BUILD=musl
|
||||||
|
- BUILD=musl-static
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
exclude:
|
||||||
|
# Static builds are broken on OS X (by Apple)
|
||||||
|
- os: osx
|
||||||
|
compiler: gcc
|
||||||
|
env: BUILD=static
|
||||||
|
- os: osx
|
||||||
|
compiler: clang
|
||||||
|
env: BUILD=static
|
||||||
|
# No musl on FreeBSD
|
||||||
|
- os: freebsd
|
||||||
|
compiler: gcc
|
||||||
|
env: BUILD=musl
|
||||||
|
- os: freebsd
|
||||||
|
compiler: clang
|
||||||
|
env: BUILD=musl
|
||||||
|
- os: freebsd
|
||||||
|
compiler: gcc
|
||||||
|
env: BUILD=musl-static
|
||||||
|
- os: freebsd
|
||||||
|
compiler: clang
|
||||||
|
env: BUILD=musl-static
|
||||||
|
# No musl on OS X
|
||||||
|
- os: osx
|
||||||
|
compiler: gcc
|
||||||
|
env: BUILD=musl
|
||||||
|
- os: osx
|
||||||
|
compiler: clang
|
||||||
|
env: BUILD=musl
|
||||||
|
- os: osx
|
||||||
|
compiler: gcc
|
||||||
|
env: BUILD=musl-static
|
||||||
|
- os: osx
|
||||||
|
compiler: clang
|
||||||
|
env: BUILD=musl-static
|
||||||
|
# arm64 doesn't link ncurses
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
arch: arm64
|
||||||
|
env: BUILD=all
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
arch: arm64
|
||||||
|
env: BUILD=all
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
arch: arm64
|
||||||
|
env: BUILD=musl
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
arch: arm64
|
||||||
|
env: BUILD=musl
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
arch: arm64
|
||||||
|
env: BUILD=musl-static
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
arch: arm64
|
||||||
|
env: BUILD=musl-static
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get update -qq
|
- sh .github/travis/before-install.sh
|
||||||
- sudo apt-get -y install debhelper autotools-dev dh-autoreconf file libncurses5-dev libevent-dev pkg-config libutempter-dev build-essential
|
|
||||||
script: (CFLAGS= ./autogen.sh) && ./configure --enable-debug && make
|
script:
|
||||||
|
- sh .github/travis/build.sh
|
||||||
|
|||||||
33
CONTRIBUTING
33
CONTRIBUTING
@@ -1,33 +0,0 @@
|
|||||||
When reporting issues:
|
|
||||||
|
|
||||||
YOU MUST INCLUDE THE TMUX VERSION
|
|
||||||
|
|
||||||
DO NOT OPEN AN ISSUE THAT DOES NOT MENTION THE TMUX VERSION
|
|
||||||
|
|
||||||
Please also include:
|
|
||||||
|
|
||||||
- your platform (Linux, OS X, or whatever);
|
|
||||||
- a brief description of the problem with steps to reproduce;
|
|
||||||
- a minimal tmux config, if you can't reproduce without a config;
|
|
||||||
- your terminal, and $TERM inside and outside of tmux;
|
|
||||||
- logs from tmux (see below);
|
|
||||||
- at most one or two screenshots, if helpful.
|
|
||||||
|
|
||||||
This should include at least the output of:
|
|
||||||
|
|
||||||
$ uname -sp && tmux -V && echo $TERM
|
|
||||||
|
|
||||||
Please do not report bugs (crashes, incorrect behaviour) without reproducing on
|
|
||||||
a tmux built from Git master.
|
|
||||||
|
|
||||||
Note that TERM inside tmux must be a variant of screen or tmux (for example:
|
|
||||||
screen or screen-256color, tmux or tmux-256color). Please ensure this is the
|
|
||||||
case before opening an issue.
|
|
||||||
|
|
||||||
To run tmux without a config and get logs, run:
|
|
||||||
|
|
||||||
tmux -Ltest kill-server
|
|
||||||
tmux -vvvv -Ltest -f/dev/null new
|
|
||||||
|
|
||||||
Then reproduce the problem, exit tmux, and attach the tmux-server-*.log file
|
|
||||||
from the current directory to the issue.
|
|
||||||
7
COPYING
7
COPYING
@@ -1,10 +1,7 @@
|
|||||||
THIS IS FOR INFORMATION ONLY, CODE IS UNDER THE LICENCE AT THE TOP OF ITS FILE.
|
THIS IS FOR INFORMATION ONLY, CODE IS UNDER THE LICENCE AT THE TOP OF ITS FILE.
|
||||||
|
|
||||||
The README, CHANGES, FAQ and TODO files are licensed under the ISC
|
The README, CHANGES, FAQ and TODO files are licensed under the ISC license. All
|
||||||
license. Files under examples/ remain copyright their authors unless otherwise
|
other files have a license and copyright notice at their start, typically:
|
||||||
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 start,
|
|
||||||
typically:
|
|
||||||
|
|
||||||
Copyright (c) <author>
|
Copyright (c) <author>
|
||||||
|
|
||||||
|
|||||||
462
FAQ
462
FAQ
@@ -1,462 +0,0 @@
|
|||||||
tmux frequently asked questions
|
|
||||||
|
|
||||||
******************************************************************************
|
|
||||||
* PLEASE NOTE: most display problems are due to incorrect TERM! Before *
|
|
||||||
* reporting problems make SURE that TERM settings are correct inside and *
|
|
||||||
* outside tmux. *
|
|
||||||
* *
|
|
||||||
* Inside tmux TERM must be "screen" or similar (such as "screen-256color"). *
|
|
||||||
* Don't bother reporting problems where it isn't! *
|
|
||||||
* *
|
|
||||||
* Outside, it must match your terminal: particularly, use "rxvt" for rxvt *
|
|
||||||
* and derivatives. *
|
|
||||||
******************************************************************************
|
|
||||||
|
|
||||||
* How is tmux different from GNU screen?
|
|
||||||
|
|
||||||
tmux and GNU screen have many similarities. Some of the main differences I am
|
|
||||||
aware of are (bearing in mind I haven't used screen for a few years now):
|
|
||||||
|
|
||||||
- tmux uses a client-server model. Each server has single Unix domain socket in
|
|
||||||
/tmp and within one server there are multiple sessions which may be attached
|
|
||||||
to multiple clients (terminals).
|
|
||||||
|
|
||||||
This has advantages, notably: windows may be linked simultaneously to
|
|
||||||
multiple sessions; windows may be moved freely between sessions; and a client
|
|
||||||
may be switched between sessions easily (C-b D). There is one major
|
|
||||||
disadvantage: if the server crashes, game over, all sessions die. In
|
|
||||||
practice, however, tmux is quite stable and gets more so as people report any
|
|
||||||
bugs they hit :-).
|
|
||||||
|
|
||||||
This model is different from screen, where typically each new screen instance
|
|
||||||
is independent. tmux supports the same behaviour by using multiple servers
|
|
||||||
with the -L option but it is not typically recommended.
|
|
||||||
|
|
||||||
- Different command interfaces. One of the goals of tmux is that the shell
|
|
||||||
should be easily usable as a scripting language - almost all tmux commands
|
|
||||||
can be used from the shell and behave identically whether used from the
|
|
||||||
shell, from a key binding or from the command prompt. Personally I also find
|
|
||||||
tmux's command interface much more consistent and clearer, but this is
|
|
||||||
subjective.
|
|
||||||
|
|
||||||
- tmux calls window names (what you see in the status line) "names", screen
|
|
||||||
calls them "titles".
|
|
||||||
|
|
||||||
- tmux has a multiple paste buffers. Not a major one but comes in handy quite a
|
|
||||||
lot.
|
|
||||||
|
|
||||||
- tmux supports automatically renaming windows to the running application
|
|
||||||
without gross hacks using escape sequences. Its even on by default.
|
|
||||||
|
|
||||||
- tmux has a choice of vi or emacs key layouts. Again, not major, but I use
|
|
||||||
emacs so if tmux did support only one key set it would be emacs and then all
|
|
||||||
the vi users would get humpy. Key bindings may be completely reconfigured in
|
|
||||||
any case.
|
|
||||||
|
|
||||||
- tmux has an option to limit the window size.
|
|
||||||
|
|
||||||
- tmux has search in windows (C-b f).
|
|
||||||
|
|
||||||
- The window split (pane) model is different. tmux has two objects, windows and
|
|
||||||
panes; screen has just windows. This difference has several implications:
|
|
||||||
|
|
||||||
* In screen you can have a window appear in several layouts, in tmux a pane
|
|
||||||
can only be in one window (fixing this is a big todo item but quite
|
|
||||||
invasive).
|
|
||||||
|
|
||||||
* tmux layouts are immutable and do not get changed unless you modify them.
|
|
||||||
|
|
||||||
* In tmux, all panes are closed when you kill a window.
|
|
||||||
|
|
||||||
* tmux panes do not have individual names, titles and so on.
|
|
||||||
|
|
||||||
I think tmux's model is much easier to manage and navigate within a window,
|
|
||||||
but breaking panes off from and joining them to windows is more clumsy.
|
|
||||||
|
|
||||||
tmux also has support for preset pane layouts.
|
|
||||||
|
|
||||||
- tmux's status line syntax is more readable and easier to use. I think it'd be
|
|
||||||
hard for anyone to argue with this. tmux doesn't support running a command
|
|
||||||
constantly and always using the last line of its output, commands must be run
|
|
||||||
again each time.
|
|
||||||
|
|
||||||
- tmux has modern, easily extended code. Again hard to argue screen is better
|
|
||||||
if you have looked at the code.
|
|
||||||
|
|
||||||
- tmux depends on libevent. I don't see this as a disadvantage: libevent is
|
|
||||||
small and portable, and on modern systems with current package management
|
|
||||||
systems dependencies are not an issue. libevent brings advantages in code
|
|
||||||
simplicity and performance.
|
|
||||||
|
|
||||||
- screen allows the window to be bigger than the terminal and can pan around
|
|
||||||
it. tmux limits the size to the largest attached client. This is a big todo
|
|
||||||
item for tmux but it is not trivial.
|
|
||||||
|
|
||||||
- screen has builtin serial and telnet support; this is bloat and is unlikely
|
|
||||||
to be added to tmux.
|
|
||||||
|
|
||||||
- Environment handling is different.
|
|
||||||
|
|
||||||
- tmux tends to be more demanding on the terminal so tends to show up terminal
|
|
||||||
and application bugs which screen does not.
|
|
||||||
|
|
||||||
- screen has wider platform support, for example IRIX, and for odd terminals.
|
|
||||||
|
|
||||||
* I found a bug! What do I do?
|
|
||||||
|
|
||||||
Check the latest version of tmux from Git to see if the problem is still
|
|
||||||
reproducible. Sometimes the length of time between releases means a lot of
|
|
||||||
fixes can be sitting in Git and the problem might already be fixed.
|
|
||||||
|
|
||||||
Please send bug reports by email to nicholas.marriott@gmail.com or
|
|
||||||
tmux-users@googlegroups.com. Please include as much of the following
|
|
||||||
information as possible:
|
|
||||||
|
|
||||||
- the version of tmux you are running;
|
|
||||||
- the operating system you are using and its version;
|
|
||||||
- the terminal emulator you are using and the TERM setting when tmux was
|
|
||||||
started;
|
|
||||||
- a description of the problem;
|
|
||||||
- if the problem is repeatable, the steps to repeat the problem;
|
|
||||||
- for screen corruption issues, a screenshot and the output of "infocmp $TERM"
|
|
||||||
from outside tmux are often very useful.
|
|
||||||
|
|
||||||
* Why doesn't tmux do $x?
|
|
||||||
|
|
||||||
Please send feature requests by email to tmux-users@googlegroups.com.
|
|
||||||
|
|
||||||
* Why do you use the screen terminal description inside tmux? It sucks.
|
|
||||||
|
|
||||||
It is already widely available. It is planned to change to something else such
|
|
||||||
as xterm-xfree86 at some point, if possible.
|
|
||||||
|
|
||||||
* I don't see any colour in my terminal! Help!
|
|
||||||
|
|
||||||
On some platforms, common terminal descriptions such as xterm do not include
|
|
||||||
colour. screen ignores this, tmux does not. If the terminal emulator in use
|
|
||||||
supports colour, use a value for TERM which correctly lists this, such as
|
|
||||||
xterm-color.
|
|
||||||
|
|
||||||
* tmux freezes my terminal when I attach to a session. I even have to kill -9
|
|
||||||
the shell it was started from to recover!
|
|
||||||
|
|
||||||
Some consoles really really don't like attempts to set the window title. Tell
|
|
||||||
tmux not to do this by turning off the "set-titles" option (you can do this
|
|
||||||
in .tmux.conf):
|
|
||||||
|
|
||||||
set -g set-titles off
|
|
||||||
|
|
||||||
If this doesn't fix it, send a bug report.
|
|
||||||
|
|
||||||
* Why is C-b the prefix key? How do I change it?
|
|
||||||
|
|
||||||
The default key is C-b because the prototype of tmux was originally developed
|
|
||||||
inside screen and C-b was chosen not to clash with the screen meta key. It
|
|
||||||
also has the advantage of not interfering with the use of C-a for start-of-line
|
|
||||||
in emacs and the shell (although it does interfere with previous-character).
|
|
||||||
|
|
||||||
Changing is simple: change the "prefix-key" option, and - if required - move
|
|
||||||
the binding of the "send-prefix" command from C-b (C-b C-b sends C-b by
|
|
||||||
default) to the new key. For example:
|
|
||||||
|
|
||||||
set -g prefix C-a
|
|
||||||
unbind C-b
|
|
||||||
bind C-a send-prefix
|
|
||||||
|
|
||||||
* How do I use UTF-8?
|
|
||||||
|
|
||||||
When running tmux in a UTF-8 capable terminal, UTF-8 must be turned on in tmux;
|
|
||||||
as of release 0.9, tmux attempts to autodetect a UTF-8-capable terminal by
|
|
||||||
checking the LC_ALL, LC_CTYPE and LANG environment variables. list-clients may
|
|
||||||
be used to check if this is detected correctly; if not, the -u command-line
|
|
||||||
flag may be specified when creating or attaching a client to a tmux session:
|
|
||||||
|
|
||||||
$ tmux -u new
|
|
||||||
|
|
||||||
Since the 1.0 release, tmux will turn on UTF-8 related options automatically
|
|
||||||
(ie status-utf8, and utf8) if the above conditions are met.
|
|
||||||
|
|
||||||
* How do I use a 256 colour terminal?
|
|
||||||
|
|
||||||
Provided the underlying terminal supports 256 colours, it is usually sufficient
|
|
||||||
to add the following to ~/.tmux.conf:
|
|
||||||
|
|
||||||
set -g default-terminal "screen-256color"
|
|
||||||
|
|
||||||
Note that some platforms do not support "screen-256color" ("infocmp
|
|
||||||
screen-256color" will return an error) - in this case see the next entry in
|
|
||||||
this FAQ.
|
|
||||||
|
|
||||||
tmux attempts to detect a 256 colour terminal both by looking at the colors
|
|
||||||
terminfo entry and by looking for the string "256col" in the TERM environment
|
|
||||||
variable.
|
|
||||||
|
|
||||||
If both these methods fail, the -2 flag may be passed to tmux when attaching
|
|
||||||
to a session to indicate the terminal supports 256 colours.
|
|
||||||
|
|
||||||
* vim or $otherprogram doesn't display 256 colours. What's up?
|
|
||||||
|
|
||||||
Some programs attempt to detect the number of colours a terminal is capable of
|
|
||||||
by checking the colors terminfo or Co termcap entry. However, this is not
|
|
||||||
reliable, and in any case is missing from the "screen" terminal description
|
|
||||||
used inside tmux.
|
|
||||||
|
|
||||||
There are two options (aside from using "screen-256color") to allow programs to
|
|
||||||
recognise they are running on a 256-colour terminal inside tmux:
|
|
||||||
|
|
||||||
- Manually force the application to use 256 colours always or if TERM is set to
|
|
||||||
screen. For vim, you can do this by overriding the t_Co option, see
|
|
||||||
http://vim.wikia.com/wiki/256_colors_in_vim.
|
|
||||||
- Creating a custom terminfo file that includes colors#256 in ~/.terminfo and
|
|
||||||
using it instead. These may be compiled with tic(1).
|
|
||||||
|
|
||||||
* How do I make Ctrl-PgUp and Ctrl-PgDn work in vim?
|
|
||||||
|
|
||||||
tmux supports passing through ctrl (and where supported by the client terminal,
|
|
||||||
alt and shift) modifiers to function keys using xterm(1)-style key sequences.
|
|
||||||
This may be enabled per window, or globally with the tmux command:
|
|
||||||
|
|
||||||
setw -g xterm-keys on
|
|
||||||
|
|
||||||
Because the TERM variable inside tmux must be set to "screen", vim will not
|
|
||||||
automatically detect these keys are available; however, the appropriate key
|
|
||||||
sequences can be overridden in .vimrc using the following:
|
|
||||||
|
|
||||||
if &term == "screen"
|
|
||||||
set t_kN=^[[6;*~
|
|
||||||
set t_kP=^[[5;*~
|
|
||||||
endif
|
|
||||||
|
|
||||||
And similarly for any other keys for which modifiers are desired.
|
|
||||||
|
|
||||||
Please note that the "xterm-keys" setting may affect other programs, in the
|
|
||||||
same way as running them in a standard xterm; for example most shells do not
|
|
||||||
expect to receive xterm(1)-style key sequences so this setting may prevent keys
|
|
||||||
such as ctrl-left and ctrl-right working correctly. tmux also passes through
|
|
||||||
the ctrl (bit 5 set, for example ^[[5~ to ^[[5^) modifier in non-xterm(1) mode;
|
|
||||||
it may be possible to configure vim to accept these, an example of how to do so
|
|
||||||
would be welcome.
|
|
||||||
|
|
||||||
vim users may also want to set the "ttyfast" option inside tmux.
|
|
||||||
|
|
||||||
* How do I make ctrl and shift arrow keys work in emacs?
|
|
||||||
|
|
||||||
The terminal-init-screen function in term/screen.el is called for new frames,
|
|
||||||
but it doesn't configure any function keys.
|
|
||||||
|
|
||||||
If the tmux xterm-keys option is on, it is enough to define the same keys as
|
|
||||||
xterm. Add the following to init.el or .emacs to do this:
|
|
||||||
|
|
||||||
(defadvice terminal-init-screen
|
|
||||||
;; The advice is named `tmux', and is run before `terminal-init-screen' runs.
|
|
||||||
(before tmux activate)
|
|
||||||
;; Docstring. This describes the advice and is made available inside emacs;
|
|
||||||
;; for example when doing C-h f terminal-init-screen RET
|
|
||||||
"Apply xterm keymap, allowing use of keys passed through tmux."
|
|
||||||
;; This is the elisp code that is run before `terminal-init-screen'.
|
|
||||||
(if (getenv "TMUX")
|
|
||||||
(let ((map (copy-keymap xterm-function-map)))
|
|
||||||
(set-keymap-parent map (keymap-parent input-decode-map))
|
|
||||||
(set-keymap-parent input-decode-map map))))
|
|
||||||
|
|
||||||
And ensure .tmux.conf contains "set -g xterm-keys on".
|
|
||||||
|
|
||||||
Alternatively, the screen.el file can be copied to the load path and
|
|
||||||
customized.
|
|
||||||
|
|
||||||
* Why doesn't elinks set the window title inside tmux?
|
|
||||||
|
|
||||||
There isn't a way to detect if a terminal supports setting the window title, so
|
|
||||||
elinks attempts to guess by looking at the environment. Rather than looking for
|
|
||||||
TERM=screen, it uses the STY variable to detect if it is running in screen;
|
|
||||||
tmux does not use this so the check fails. A workaround is to set STY before
|
|
||||||
running elinks.
|
|
||||||
|
|
||||||
The following shell function does this, and also clears the window title on
|
|
||||||
exit (elinks, for some strange reason, sets it to the value of TERM):
|
|
||||||
|
|
||||||
elinks() {
|
|
||||||
STY= `which elinks` $*
|
|
||||||
echo -ne \\033]0\;\\007;
|
|
||||||
}
|
|
||||||
|
|
||||||
* What is the proper way to escape characters with #(command)?
|
|
||||||
|
|
||||||
When using the #(command) construction to include the output from a command in
|
|
||||||
the status line, the command will be parsed twice. First, when it's read by the
|
|
||||||
configuration file or the command-prompt parser, and second when the status
|
|
||||||
line is being drawn and the command is passed to the shell. For example, to
|
|
||||||
echo the string "(test)" to the status line, either single or double quotes
|
|
||||||
could be used:
|
|
||||||
|
|
||||||
set -g status-right "#(echo \\\\(test\\\\))"
|
|
||||||
set -g status-right '#(echo \\\(test\\\))'
|
|
||||||
|
|
||||||
In both cases, the status-right option will be set to the string "#(echo
|
|
||||||
\\(test\\))" and the command executed will be "echo \(test\)".
|
|
||||||
|
|
||||||
* tmux uses too much CPU. What do I do?
|
|
||||||
|
|
||||||
Automatic window renaming may use a lot of CPU, particularly on slow computers:
|
|
||||||
if this is a problem, turn it off with "setw -g automatic-rename off". If this
|
|
||||||
doesn't fix it, please report the problem.
|
|
||||||
|
|
||||||
* I use PuTTY and my tmux window pane separators are all qqqqqqqqq's!
|
|
||||||
|
|
||||||
PuTTY is using a character set translation that doesn't support ACS line
|
|
||||||
drawing. With a Unicode font, try setting PuTTY to use a different translation
|
|
||||||
on the Window -> Translation configuration page. For example, change UTF-8 to
|
|
||||||
ISO-8859-1 or CP437. It may also be necessary to adjust the way PuTTY treats
|
|
||||||
line drawing characters in the lower part of the same configuration page.
|
|
||||||
|
|
||||||
* What is the best way to display the load average? Why no #L?
|
|
||||||
|
|
||||||
It isn't possible to get the load average portably in code and it is preferable
|
|
||||||
not to add portability goop. The following works on at least Linux, *BSD and OS
|
|
||||||
X:
|
|
||||||
|
|
||||||
uptime|awk '{split(substr($0, index($0, "load")), a, ":"); print a[2]}'
|
|
||||||
|
|
||||||
* How do I attach the same session to multiple clients but with a different
|
|
||||||
current window, like screen -x?
|
|
||||||
|
|
||||||
One or more of the windows can be linked into multiple sessions manually with
|
|
||||||
link-window, or a grouped session with all the windows can be created with
|
|
||||||
new-session -t.
|
|
||||||
|
|
||||||
* Ctrl and arrow keys doesn't work in putty! What do I do?
|
|
||||||
|
|
||||||
putty inverts the sense of the cursor key mode on ctrl, which is a bit hard for
|
|
||||||
tmux to detect properly. To get ctrl keys right, change the terminfo settings
|
|
||||||
so kUP5 (Ctrl-Up etc) are the adjusted versions, and disable smkx/rmkx so tmux
|
|
||||||
doesn't change the mode. For example with this line in .tmux.conf (assuming you
|
|
||||||
have TERM set to xterm):
|
|
||||||
|
|
||||||
set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@"
|
|
||||||
|
|
||||||
Note that this will only work in tmux 1.2 and above.
|
|
||||||
|
|
||||||
* How can I blank the tmux window?
|
|
||||||
|
|
||||||
GNU screen has a feature whereby it will blank the screen after a period of
|
|
||||||
inactivity. To do the same thing in tmux, use the lock-command setting, for
|
|
||||||
example (with GNU bash):
|
|
||||||
|
|
||||||
set -g lock-command 'tput civis && read -s -n1'
|
|
||||||
|
|
||||||
This will remove the cursor and tell the shell to quit once a key has been
|
|
||||||
pressed. For zsh, use "read -s -k1".
|
|
||||||
|
|
||||||
In addition, it's possible to have both blanking and locking (for instance via
|
|
||||||
lock(1) or vlock(1)) by using the following:
|
|
||||||
|
|
||||||
bind x set lock-command '/usr/bin/vlock' \; lock-client \; set lock-command 'tput civis && read -s -n1'
|
|
||||||
|
|
||||||
* I don't see italics! Or less and vim show italics and reverse the wrong way round!
|
|
||||||
|
|
||||||
GNU screen does not support italics and the "screen" terminfo description uses
|
|
||||||
the italics escape sequence incorrectly.
|
|
||||||
|
|
||||||
As of tmux 2.1, if default-terminal is set to "screen" or matches "screen-*",
|
|
||||||
tmux will behave like screen and italics will be disabled.
|
|
||||||
|
|
||||||
To enable italics, create a new terminfo entry called "tmux" (some platforms
|
|
||||||
may already have this, you can check with "infocmp tmux"):
|
|
||||||
|
|
||||||
$ cat <<EOF|tic -x -
|
|
||||||
tmux|tmux terminal multiplexer,
|
|
||||||
ritm=\E[23m, rmso=\E[27m, sitm=\E[3m, smso=\E[7m, Ms@,
|
|
||||||
use=xterm+tmux, use=screen,
|
|
||||||
|
|
||||||
tmux-256color|tmux with 256 colors,
|
|
||||||
use=xterm+256setaf, use=tmux,
|
|
||||||
EOF
|
|
||||||
$
|
|
||||||
|
|
||||||
And tell tmux to use it in ~/.tmux.conf:
|
|
||||||
|
|
||||||
set -g default-terminal "tmux"
|
|
||||||
|
|
||||||
If using urxvt, make sure you have an italics capable font enabled. for
|
|
||||||
example, add to ~/.Xdefaults:
|
|
||||||
|
|
||||||
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 -ga 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
|
|
||||||
|
|
||||||
* How do I copy a selection from tmux to the system's clipboard?
|
|
||||||
|
|
||||||
When running in xterm(1), tmux can automatically send copied text to the
|
|
||||||
clipboard. This is controlled by the set-clipboard option and also needs this
|
|
||||||
X resource to be set:
|
|
||||||
|
|
||||||
XTerm*disallowedWindowOps: 20,21,SetXprop
|
|
||||||
|
|
||||||
For rxvt-unicode (urxvt), there is an unofficial Perl extension here:
|
|
||||||
|
|
||||||
http://anti.teamidiot.de/static/nei/*/Code/urxvt/
|
|
||||||
|
|
||||||
Otherwise a key binding for copy mode using xclip (or xsel) works:
|
|
||||||
|
|
||||||
bind -temacs-copy C-y copy-pipe "xclip -i >/dev/null"
|
|
||||||
|
|
||||||
Or for inside and outside copy mode with the prefix key:
|
|
||||||
|
|
||||||
bind C-y run -b "tmux save-buffer - | xclip -i"
|
|
||||||
|
|
||||||
On OS X, look at the pbcopy(1) and pbpaste(1) commands.
|
|
||||||
|
|
||||||
* Why don't some commands work inside tmux on OS X?
|
|
||||||
|
|
||||||
Apple requires some undocumented, unsupported fiddling to allow commands that
|
|
||||||
interact with the GUI to work. Neither tmux itself nor most shells do this, so
|
|
||||||
an external program is required. This can be found here:
|
|
||||||
|
|
||||||
https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
|
|
||||||
|
|
||||||
Affected commands may include say(1), pbcopy(1), pbpaste(1) and ssh(1).
|
|
||||||
|
|
||||||
* Why do I see dots around a session when I attach to it?
|
|
||||||
|
|
||||||
tmux limits the size of the window to the smallest attached session. If
|
|
||||||
it didn't do this then it would be impossible to see the entire window.
|
|
||||||
The dots mark the size of the window tmux can display.
|
|
||||||
|
|
||||||
To avoid this, detach all other clients when attaching:
|
|
||||||
|
|
||||||
$ tmux attach -d
|
|
||||||
|
|
||||||
Or from inside tmux by detaching individual clients with C-b D or all
|
|
||||||
using:
|
|
||||||
|
|
||||||
C-b : attach -d
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Please read https://raw.githubusercontent.com/tmux/tmux/master/CONTRIBUTING
|
|
||||||
74
Makefile.am
74
Makefile.am
@@ -1,16 +1,19 @@
|
|||||||
# Makefile.am
|
|
||||||
|
|
||||||
# Obvious program stuff.
|
# Obvious program stuff.
|
||||||
bin_PROGRAMS = tmux
|
bin_PROGRAMS = tmux
|
||||||
CLEANFILES = tmux.1.mdoc tmux.1.man
|
CLEANFILES = tmux.1.mdoc tmux.1.man cmd-parse.c
|
||||||
|
|
||||||
# Distribution tarball options.
|
# Distribution tarball options.
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
CHANGES FAQ README TODO COPYING example_tmux.conf compat/*.[ch] \
|
CHANGES README README.ja COPYING example_tmux.conf \
|
||||||
osdep-*.c mdoc2man.awk tmux.1
|
osdep-*.c mdoc2man.awk tmux.1
|
||||||
|
dist_EXTRA_tmux_SOURCES = compat/*.[ch]
|
||||||
|
|
||||||
# Preprocessor flags.
|
# Preprocessor flags.
|
||||||
AM_CPPFLAGS += @XOPEN_DEFINES@ -DTMUX_CONF="\"$(sysconfdir)/tmux.conf\""
|
AM_CPPFLAGS += @XOPEN_DEFINES@ \
|
||||||
|
-DTMUX_VERSION='"@VERSION@"' \
|
||||||
|
-DTMUX_CONF='"$(sysconfdir)/tmux.conf:~/.tmux.conf:$$XDG_CONFIG_HOME/tmux/tmux.conf:~/.config/tmux/tmux.conf"' \
|
||||||
|
-DTMUX_LOCK_CMD='"@DEFAULT_LOCK_CMD@"' \
|
||||||
|
-DTMUX_TERM='"@DEFAULT_TERM@"'
|
||||||
|
|
||||||
# Additional object files.
|
# Additional object files.
|
||||||
LDADD = $(LIBOBJS)
|
LDADD = $(LIBOBJS)
|
||||||
@@ -25,7 +28,10 @@ AM_CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
|
|||||||
AM_CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare
|
AM_CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare
|
||||||
AM_CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align
|
AM_CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align
|
||||||
AM_CFLAGS += -Wdeclaration-after-statement -Wno-pointer-sign -Wno-attributes
|
AM_CFLAGS += -Wdeclaration-after-statement -Wno-pointer-sign -Wno-attributes
|
||||||
AM_CFLAGS += -Wno-unused-result
|
AM_CFLAGS += -Wno-unused-result -Wno-format-y2k
|
||||||
|
if IS_DARWIN
|
||||||
|
AM_CFLAGS += -Wno-deprecated-declarations -Wno-cast-align
|
||||||
|
endif
|
||||||
AM_CPPFLAGS += -DDEBUG
|
AM_CPPFLAGS += -DDEBUG
|
||||||
endif
|
endif
|
||||||
AM_CPPFLAGS += -iquote.
|
AM_CPPFLAGS += -iquote.
|
||||||
@@ -55,6 +61,11 @@ if IS_NETBSD
|
|||||||
AM_CPPFLAGS += -D_OPENBSD_SOURCE
|
AM_CPPFLAGS += -D_OPENBSD_SOURCE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Set flags for Haiku.
|
||||||
|
if IS_HAIKU
|
||||||
|
AM_CPPFLAGS += -D_BSD_SOURCE
|
||||||
|
endif
|
||||||
|
|
||||||
# List of sources.
|
# List of sources.
|
||||||
dist_tmux_SOURCES = \
|
dist_tmux_SOURCES = \
|
||||||
alerts.c \
|
alerts.c \
|
||||||
@@ -66,13 +77,12 @@ dist_tmux_SOURCES = \
|
|||||||
cmd-bind-key.c \
|
cmd-bind-key.c \
|
||||||
cmd-break-pane.c \
|
cmd-break-pane.c \
|
||||||
cmd-capture-pane.c \
|
cmd-capture-pane.c \
|
||||||
cmd-choose-buffer.c \
|
|
||||||
cmd-choose-client.c \
|
|
||||||
cmd-choose-tree.c \
|
cmd-choose-tree.c \
|
||||||
cmd-command-prompt.c \
|
cmd-command-prompt.c \
|
||||||
cmd-confirm-before.c \
|
cmd-confirm-before.c \
|
||||||
cmd-copy-mode.c \
|
cmd-copy-mode.c \
|
||||||
cmd-detach-client.c \
|
cmd-detach-client.c \
|
||||||
|
cmd-display-menu.c \
|
||||||
cmd-display-message.c \
|
cmd-display-message.c \
|
||||||
cmd-display-panes.c \
|
cmd-display-panes.c \
|
||||||
cmd-find-window.c \
|
cmd-find-window.c \
|
||||||
@@ -89,12 +99,12 @@ dist_tmux_SOURCES = \
|
|||||||
cmd-list-panes.c \
|
cmd-list-panes.c \
|
||||||
cmd-list-sessions.c \
|
cmd-list-sessions.c \
|
||||||
cmd-list-windows.c \
|
cmd-list-windows.c \
|
||||||
cmd-list.c \
|
|
||||||
cmd-load-buffer.c \
|
cmd-load-buffer.c \
|
||||||
cmd-lock-server.c \
|
cmd-lock-server.c \
|
||||||
cmd-move-window.c \
|
cmd-move-window.c \
|
||||||
cmd-new-session.c \
|
cmd-new-session.c \
|
||||||
cmd-new-window.c \
|
cmd-new-window.c \
|
||||||
|
cmd-parse.y \
|
||||||
cmd-paste-buffer.c \
|
cmd-paste-buffer.c \
|
||||||
cmd-pipe-pane.c \
|
cmd-pipe-pane.c \
|
||||||
cmd-queue.c \
|
cmd-queue.c \
|
||||||
@@ -102,6 +112,7 @@ dist_tmux_SOURCES = \
|
|||||||
cmd-rename-session.c \
|
cmd-rename-session.c \
|
||||||
cmd-rename-window.c \
|
cmd-rename-window.c \
|
||||||
cmd-resize-pane.c \
|
cmd-resize-pane.c \
|
||||||
|
cmd-resize-window.c \
|
||||||
cmd-respawn-pane.c \
|
cmd-respawn-pane.c \
|
||||||
cmd-respawn-window.c \
|
cmd-respawn-window.c \
|
||||||
cmd-rotate-window.c \
|
cmd-rotate-window.c \
|
||||||
@@ -111,16 +122,16 @@ dist_tmux_SOURCES = \
|
|||||||
cmd-select-pane.c \
|
cmd-select-pane.c \
|
||||||
cmd-select-window.c \
|
cmd-select-window.c \
|
||||||
cmd-send-keys.c \
|
cmd-send-keys.c \
|
||||||
|
cmd-server-access.c \
|
||||||
cmd-set-buffer.c \
|
cmd-set-buffer.c \
|
||||||
cmd-set-environment.c \
|
cmd-set-environment.c \
|
||||||
cmd-set-hook.c \
|
|
||||||
cmd-set-option.c \
|
cmd-set-option.c \
|
||||||
cmd-show-environment.c \
|
cmd-show-environment.c \
|
||||||
cmd-show-messages.c \
|
cmd-show-messages.c \
|
||||||
cmd-show-options.c \
|
cmd-show-options.c \
|
||||||
|
cmd-show-prompt-history.c \
|
||||||
cmd-source-file.c \
|
cmd-source-file.c \
|
||||||
cmd-split-window.c \
|
cmd-split-window.c \
|
||||||
cmd-string.c \
|
|
||||||
cmd-swap-pane.c \
|
cmd-swap-pane.c \
|
||||||
cmd-swap-window.c \
|
cmd-swap-window.c \
|
||||||
cmd-switch-client.c \
|
cmd-switch-client.c \
|
||||||
@@ -132,10 +143,13 @@ dist_tmux_SOURCES = \
|
|||||||
control-notify.c \
|
control-notify.c \
|
||||||
control.c \
|
control.c \
|
||||||
environ.c \
|
environ.c \
|
||||||
|
file.c \
|
||||||
format.c \
|
format.c \
|
||||||
|
format-draw.c \
|
||||||
|
grid-reader.c \
|
||||||
grid-view.c \
|
grid-view.c \
|
||||||
grid.c \
|
grid.c \
|
||||||
hooks.c \
|
hyperlinks.c \
|
||||||
input-keys.c \
|
input-keys.c \
|
||||||
input.c \
|
input.c \
|
||||||
job.c \
|
job.c \
|
||||||
@@ -145,37 +159,47 @@ dist_tmux_SOURCES = \
|
|||||||
layout-set.c \
|
layout-set.c \
|
||||||
layout.c \
|
layout.c \
|
||||||
log.c \
|
log.c \
|
||||||
|
menu.c \
|
||||||
|
mode-tree.c \
|
||||||
names.c \
|
names.c \
|
||||||
notify.c \
|
notify.c \
|
||||||
options-table.c \
|
options-table.c \
|
||||||
options.c \
|
options.c \
|
||||||
paste.c \
|
paste.c \
|
||||||
|
popup.c \
|
||||||
proc.c \
|
proc.c \
|
||||||
|
regsub.c \
|
||||||
resize.c \
|
resize.c \
|
||||||
screen-redraw.c \
|
screen-redraw.c \
|
||||||
screen-write.c \
|
screen-write.c \
|
||||||
screen.c \
|
screen.c \
|
||||||
|
server-acl.c \
|
||||||
server-client.c \
|
server-client.c \
|
||||||
server-fn.c \
|
server-fn.c \
|
||||||
server.c \
|
server.c \
|
||||||
session.c \
|
session.c \
|
||||||
signal.c \
|
spawn.c \
|
||||||
status.c \
|
status.c \
|
||||||
style.c \
|
style.c \
|
||||||
tmux.c \
|
tmux.c \
|
||||||
tmux.h \
|
tmux.h \
|
||||||
|
tmux-protocol.h \
|
||||||
tty-acs.c \
|
tty-acs.c \
|
||||||
|
tty-features.c \
|
||||||
tty-keys.c \
|
tty-keys.c \
|
||||||
tty-term.c \
|
tty-term.c \
|
||||||
tty.c \
|
tty.c \
|
||||||
|
utf8-combined.c \
|
||||||
utf8.c \
|
utf8.c \
|
||||||
window-choose.c \
|
window-buffer.c \
|
||||||
|
window-client.c \
|
||||||
window-clock.c \
|
window-clock.c \
|
||||||
window-copy.c \
|
window-copy.c \
|
||||||
|
window-customize.c \
|
||||||
|
window-tree.c \
|
||||||
window.c \
|
window.c \
|
||||||
xmalloc.c \
|
xmalloc.c \
|
||||||
xmalloc.h \
|
xmalloc.h
|
||||||
xterm-keys.c
|
|
||||||
nodist_tmux_SOURCES = osdep-@PLATFORM@.c
|
nodist_tmux_SOURCES = osdep-@PLATFORM@.c
|
||||||
|
|
||||||
# Add compat file for forkpty.
|
# Add compat file for forkpty.
|
||||||
@@ -183,11 +207,27 @@ if NEED_FORKPTY
|
|||||||
nodist_tmux_SOURCES += compat/forkpty-@PLATFORM@.c
|
nodist_tmux_SOURCES += compat/forkpty-@PLATFORM@.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Add compat file for systemd.
|
||||||
|
if HAVE_SYSTEMD
|
||||||
|
nodist_tmux_SOURCES += compat/systemd.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Add compat file for utf8proc.
|
# Add compat file for utf8proc.
|
||||||
if HAVE_UTF8PROC
|
if HAVE_UTF8PROC
|
||||||
nodist_tmux_SOURCES += compat/utf8proc.c
|
nodist_tmux_SOURCES += compat/utf8proc.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Enable sixel support.
|
||||||
|
if ENABLE_SIXEL
|
||||||
|
dist_tmux_SOURCES += image.c image-sixel.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
if NEED_FUZZING
|
||||||
|
check_PROGRAMS = fuzz/input-fuzzer
|
||||||
|
fuzz_input_fuzzer_LDFLAGS = $(FUZZING_LIBS)
|
||||||
|
fuzz_input_fuzzer_LDADD = $(LDADD) $(tmux_OBJECTS)
|
||||||
|
endif
|
||||||
|
|
||||||
# Install tmux.1 in the right format.
|
# Install tmux.1 in the right format.
|
||||||
install-exec-hook:
|
install-exec-hook:
|
||||||
if test x@MANFORMAT@ = xmdoc; then \
|
if test x@MANFORMAT@ = xmdoc; then \
|
||||||
@@ -195,7 +235,7 @@ install-exec-hook:
|
|||||||
>$(srcdir)/tmux.1.mdoc; \
|
>$(srcdir)/tmux.1.mdoc; \
|
||||||
else \
|
else \
|
||||||
sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" $(srcdir)/tmux.1| \
|
sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" $(srcdir)/tmux.1| \
|
||||||
$(AWK) -f$(srcdir)/mdoc2man.awk >$(srcdir)/tmux.1.man; \
|
$(AWK) -f $(srcdir)/mdoc2man.awk >$(srcdir)/tmux.1.man; \
|
||||||
fi
|
fi
|
||||||
$(mkdir_p) $(DESTDIR)$(mandir)/man1
|
$(mkdir_p) $(DESTDIR)$(mandir)/man1
|
||||||
$(INSTALL_DATA) $(srcdir)/tmux.1.@MANFORMAT@ \
|
$(INSTALL_DATA) $(srcdir)/tmux.1.@MANFORMAT@ \
|
||||||
|
|||||||
99
README
99
README
@@ -1,18 +1,25 @@
|
|||||||
Welcome to tmux!
|
Welcome to tmux!
|
||||||
|
|
||||||
tmux is a "terminal multiplexer", it enables a number of terminals (or windows)
|
tmux is a terminal multiplexer: it enables a number of terminals to be created,
|
||||||
to be accessed and controlled from a single terminal. tmux is intended to be a
|
accessed, and controlled from a single screen. tmux may be detached from a
|
||||||
simple, modern, BSD-licensed alternative to programs such as GNU screen.
|
screen and continue running in the background, then later reattached.
|
||||||
|
|
||||||
This release runs on OpenBSD, FreeBSD, NetBSD, Linux, OS X and Solaris.
|
This release runs on OpenBSD, FreeBSD, NetBSD, Linux, macOS and Solaris.
|
||||||
|
|
||||||
tmux depends on libevent 2.x. Download it from:
|
* Dependencies
|
||||||
|
|
||||||
http://libevent.org
|
tmux depends on libevent 2.x, available from:
|
||||||
|
|
||||||
|
https://github.com/libevent/libevent/releases/latest
|
||||||
|
|
||||||
It also depends on ncurses, available from:
|
It also depends on ncurses, available from:
|
||||||
|
|
||||||
http://invisible-island.net/ncurses/
|
https://invisible-mirror.net/archives/ncurses/
|
||||||
|
|
||||||
|
To build tmux, a C compiler (for example gcc or clang), make, pkg-config and a
|
||||||
|
suitable yacc (yacc or bison) are needed.
|
||||||
|
|
||||||
|
* Installation
|
||||||
|
|
||||||
To build and install tmux from a release tarball, use:
|
To build and install tmux from a release tarball, use:
|
||||||
|
|
||||||
@@ -22,52 +29,58 @@ To build and install tmux from a release tarball, use:
|
|||||||
tmux can use the utempter library to update utmp(5), if it is installed - run
|
tmux can use the utempter library to update utmp(5), if it is installed - run
|
||||||
configure with --enable-utempter to enable this.
|
configure with --enable-utempter to enable this.
|
||||||
|
|
||||||
To get and build the latest from version control:
|
To get and build the latest from version control - note that this requires
|
||||||
|
autoconf, automake and pkg-config:
|
||||||
|
|
||||||
$ git clone https://github.com/tmux/tmux.git
|
$ git clone https://github.com/tmux/tmux.git
|
||||||
$ cd tmux
|
$ cd tmux
|
||||||
$ sh autogen.sh
|
$ sh autogen.sh
|
||||||
$ ./configure && make
|
$ ./configure && make
|
||||||
|
|
||||||
For more information see http://git-scm.com. Patches should be sent by email to
|
* Contributing
|
||||||
the mailing list at tmux-users@googlegroups.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, a rough todo list is in the
|
|
||||||
TODO file and an example configuration in example_tmux.conf.
|
|
||||||
|
|
||||||
A vim(1) syntax file is available at:
|
|
||||||
|
|
||||||
https://github.com/ericpruitt/tmux.vim
|
|
||||||
https://raw.githubusercontent.com/ericpruitt/tmux.vim/master/vim/syntax/tmux.vim
|
|
||||||
|
|
||||||
And a bash(1) completion file at:
|
|
||||||
|
|
||||||
https://github.com/imomaliev/tmux-bash-completion
|
|
||||||
|
|
||||||
For debugging, running tmux with -v or -vv will generate server and client log
|
|
||||||
files in the current directory.
|
|
||||||
|
|
||||||
tmux mailing lists are available. For general discussion and bug reports:
|
|
||||||
|
|
||||||
https://groups.google.com/forum/#!forum/tmux-users
|
|
||||||
|
|
||||||
And for Git commit emails:
|
|
||||||
|
|
||||||
https://groups.google.com/forum/#!forum/tmux-git
|
|
||||||
|
|
||||||
Subscribe by sending an email to <tmux-users+subscribe@googlegroups.com>.
|
|
||||||
|
|
||||||
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:
|
||||||
|
|
||||||
tmux-users@googlegroups.com
|
tmux-users@googlegroups.com
|
||||||
|
|
||||||
This file and the CHANGES, FAQ, SYNCING and TODO files are licensed under the
|
Or open a GitHub issue or pull request.
|
||||||
ISC license. All other files have a license and copyright notice at their start.
|
|
||||||
|
|
||||||
-- Nicholas Marriott <nicholas.marriott@gmail.com>
|
* Documentation
|
||||||
|
|
||||||
|
For documentation on using tmux, see the tmux.1 manpage. View it from the
|
||||||
|
source tree with:
|
||||||
|
|
||||||
|
$ nroff -mdoc tmux.1|less
|
||||||
|
|
||||||
|
A small example configuration is in example_tmux.conf.
|
||||||
|
|
||||||
|
Other documentation is available in the wiki:
|
||||||
|
|
||||||
|
https://github.com/tmux/tmux/wiki
|
||||||
|
|
||||||
|
Also see the tmux FAQ at:
|
||||||
|
|
||||||
|
https://github.com/tmux/tmux/wiki/FAQ
|
||||||
|
|
||||||
|
A bash(1) completion file is at:
|
||||||
|
|
||||||
|
https://github.com/imomaliev/tmux-bash-completion
|
||||||
|
|
||||||
|
For debugging, run tmux with -v and -vv to generate server and client log files
|
||||||
|
in the current directory.
|
||||||
|
|
||||||
|
* Support
|
||||||
|
|
||||||
|
The tmux mailing list for general discussion and bug reports is:
|
||||||
|
|
||||||
|
https://groups.google.com/forum/#!forum/tmux-users
|
||||||
|
|
||||||
|
Subscribe by sending an email to:
|
||||||
|
|
||||||
|
tmux-users+subscribe@googlegroups.com
|
||||||
|
|
||||||
|
* License
|
||||||
|
|
||||||
|
This file and the CHANGES files are licensed under the ISC license. All other
|
||||||
|
files have a license and copyright notice at their start.
|
||||||
|
|||||||
62
README.ja
Normal file
62
README.ja
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
tmuxへようこそ!
|
||||||
|
|
||||||
|
tmuxはターミナルマルチプレクサーです。複数のターミナルを一つのスクリーン内に作成し、操作することができます。
|
||||||
|
バックグラウンドで処理を実行中に一度スクリーンから離れて後から復帰することも可能です。
|
||||||
|
|
||||||
|
OpenBSD、FreeBSD、NetBSD、Linux、macOS、Solarisで実行できます。
|
||||||
|
|
||||||
|
tmuxはlibevent 2.x.に依存します。 下記からダウンロードしてください。
|
||||||
|
|
||||||
|
http://libevent.org
|
||||||
|
|
||||||
|
また、ncursesも必要です。こちらからどうぞ。
|
||||||
|
|
||||||
|
http://invisible-island.net/ncurses/
|
||||||
|
|
||||||
|
tarballでのtmuxのビルドとインストール方法。
|
||||||
|
|
||||||
|
$ ./configure && make
|
||||||
|
$ sudo make install
|
||||||
|
|
||||||
|
tmuxはutmp(5)をアップデートするためにutempterを使うことができます。もしインストール済みであればオプション「--enable-utempter」をつけて実行してください。
|
||||||
|
|
||||||
|
リポジトリから最新バージョンを手に入れるためには下記を実行。
|
||||||
|
|
||||||
|
$ git clone https://github.com/tmux/tmux.git
|
||||||
|
$ cd tmux
|
||||||
|
$ sh autogen.sh
|
||||||
|
$ ./configure && make
|
||||||
|
|
||||||
|
(ビルドのためにはlibevent、ncurses libraries、headersに加えて、C compiler、make、autoconf、automake、pkg-configが必要です。)
|
||||||
|
|
||||||
|
詳しい情報はhttp://git-scm.comをご覧ください。修正はメール<tmux-users@googlegroups.com>宛、もしくはhttps://github.com/tmux/tmux/issuesにて受け付けています。
|
||||||
|
|
||||||
|
tmuxのドキュメントについてはtmux.1マニュアルをご覧ください。こちらのコマンドで参照可能です。
|
||||||
|
|
||||||
|
$ nroff -mdoc tmux.1|less
|
||||||
|
|
||||||
|
サンプル設定は本リポジトリのexample_tmux.confに
|
||||||
|
また、bash-completionファイルは下記にあります。
|
||||||
|
|
||||||
|
https://github.com/imomaliev/tmux-bash-completion
|
||||||
|
|
||||||
|
「-v」や「-vv」を指定することでデバッグモードでの起動が可能です。カレントディレクトリにサーバーやクライアントのログファイルが生成されます。
|
||||||
|
|
||||||
|
議論やバグレポート用のメーリングリストにはこちらから参加可能です。
|
||||||
|
|
||||||
|
https://groups.google.com/forum/#!forum/tmux-users
|
||||||
|
|
||||||
|
gitコミットについての連絡先
|
||||||
|
|
||||||
|
https://groups.google.com/forum/#!forum/tmux-git
|
||||||
|
|
||||||
|
購読は<tmux-users+subscribe@googlegroups.com>までメールをお願いします。
|
||||||
|
|
||||||
|
バグレポートや機能追加(特にコードへの貢献)は大歓迎です。こちらにご連絡ください。
|
||||||
|
|
||||||
|
tmux-users@googlegroups.com
|
||||||
|
|
||||||
|
本ファイル、CHANGES、 FAQ、SYNCINGそしてTODOはISC licenseで保護されています。
|
||||||
|
その他のファイルのライセンスや著作権については、ファイルの上部に明記されています。
|
||||||
|
|
||||||
|
-- Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
17
SYNCING
17
SYNCING
@@ -89,7 +89,7 @@ of the remote name "obsd-tmux", we can now create the master branch from
|
|||||||
% git checkout -b obsd-master obsd-tmux/master
|
% git checkout -b obsd-master obsd-tmux/master
|
||||||
|
|
||||||
Adding in the fake history points
|
Adding in the fake history points
|
||||||
=================================
|
=================================
|
||||||
|
|
||||||
To tie both the "master" branch from "tmux" and the "obsd-master"
|
To tie both the "master" branch from "tmux" and the "obsd-master"
|
||||||
branch from "tmux-openbsd" together, the fake history points added to the
|
branch from "tmux-openbsd" together, the fake history points added to the
|
||||||
@@ -145,7 +145,9 @@ Release tmux for next version
|
|||||||
upgrades and the latter should mention all the major changes since
|
upgrades and the latter should mention all the major changes since
|
||||||
the last version.
|
the last version.
|
||||||
|
|
||||||
2. Tag with:
|
2. Make sure configure.ac has the new version number.
|
||||||
|
|
||||||
|
3. Tag with:
|
||||||
|
|
||||||
% git tag -a 2.X
|
% git tag -a 2.X
|
||||||
|
|
||||||
@@ -155,18 +157,17 @@ Release tmux for next version
|
|||||||
|
|
||||||
% git push --tags
|
% git push --tags
|
||||||
|
|
||||||
3. Build the tarball with 'make dist'.
|
4. Build the tarball with 'make dist'.
|
||||||
|
|
||||||
4. Check the tarball. If it's good, go here to select the tag just pushed:
|
5. Check the tarball. If it's good, go here to select the tag just pushed:
|
||||||
|
|
||||||
https://github.com/tmux/tmux/tags
|
https://github.com/tmux/tmux/tags
|
||||||
|
|
||||||
Click the "Add release notes", upload the tarball and add a link in the
|
Click the "Add release notes", upload the tarball and add a link in the
|
||||||
description field to the CHANGES file.
|
description field to the CHANGES file.
|
||||||
|
|
||||||
5. Clone the tmux.github.io repository, and change the RELEASE version in the
|
6. Clone the tmux.github.io repository, and change the RELEASE version in the
|
||||||
Makefile. Commit it, and run 'make' to replace %%VERSION%%. Push the
|
Makefile. Commit it, and run 'make' to replace %%RELEASE%%. Push the
|
||||||
result out.
|
result out.
|
||||||
|
|
||||||
6. Bump version in tmux/tmux.git configure.ac and uncomment "enable_debug=yes"
|
7. Change version back to master in configure.ac.
|
||||||
to create a debug build by default.
|
|
||||||
|
|||||||
127
TODO
127
TODO
@@ -1,127 +0,0 @@
|
|||||||
- command bits and pieces:
|
|
||||||
* allow multiple targets: fnmatch for -t/-c, for example detach all
|
|
||||||
clients with -t*
|
|
||||||
* add -c for new-session like new-window
|
|
||||||
* ' and " should be parsed the same (eg "\e" vs '\e') in config
|
|
||||||
and command prompt
|
|
||||||
* last-pane across sessions
|
|
||||||
* resize-pane -p to match split-window -p
|
|
||||||
* flag to wait-for to have a timeout and/or to stop waiting when the
|
|
||||||
client gets a signal
|
|
||||||
|
|
||||||
- make command sequences more usable
|
|
||||||
* don't require space after ;
|
|
||||||
* options for error handling: && and ||?
|
|
||||||
|
|
||||||
- options bits and pieces:
|
|
||||||
* way to set socket path from config file
|
|
||||||
|
|
||||||
- format improvements:
|
|
||||||
* option to quote format (#{q:session_name})
|
|
||||||
* some way to pad # stuff with spaces
|
|
||||||
* formats to show if a window is linked into multiple sessions, into
|
|
||||||
multiple attached sessions, and is the active window in multiple
|
|
||||||
attached sessions?
|
|
||||||
* comparison operators like < and > (for #{version}?)
|
|
||||||
* %else statement in config file
|
|
||||||
|
|
||||||
- choose mode improvements:
|
|
||||||
* choose-pane command (augment choose-tree to do this?)
|
|
||||||
* flag to choose-* for sort order
|
|
||||||
* two choices (first one then second, for swap-pane and join-pane)
|
|
||||||
* choose modes should ditch the key bindings and just have fixed keys, and
|
|
||||||
be more customized to their purpose (d to delete a buffer for choose-buffer,
|
|
||||||
a preview of buffer contents, etc)
|
|
||||||
|
|
||||||
- improve monitor-*:
|
|
||||||
* straighten out rules for multiple clients
|
|
||||||
* think about what happens across sessions
|
|
||||||
* monitor changes within a region
|
|
||||||
* perhaps monitor /all/ panes in the window not just one
|
|
||||||
|
|
||||||
- improve mouse support:
|
|
||||||
* bind commands to mouse in different areas?
|
|
||||||
* commands executed when clicking on a pattern (URL)
|
|
||||||
|
|
||||||
- warts on current naming:
|
|
||||||
* display-time but message-fg/bg/attr
|
|
||||||
* list-* vs show-*
|
|
||||||
|
|
||||||
- copy/paste improvements:
|
|
||||||
* paste w/o trailing whitespace
|
|
||||||
* command to toggle selection not to move it in copy-mode
|
|
||||||
* regex searching
|
|
||||||
* searching in copy mode should unwrap lines, so if you search for "foobar"
|
|
||||||
then it should be found even if it is now "foo\nbar" (if the WRAP flag
|
|
||||||
is set on the line)
|
|
||||||
* capture-pane option to preserve spaces but not join lines
|
|
||||||
* improve word and line selection in copy mode (for example when
|
|
||||||
dragging it should select by word. compare how xterm works. GitHub
|
|
||||||
issue 682)
|
|
||||||
|
|
||||||
- layout stuff
|
|
||||||
* way to tag a layout as a number/name
|
|
||||||
* maybe keep last layout + size around and if size reverts just put it
|
|
||||||
back
|
|
||||||
* revamp layouts: they are too complicated, should be more closely
|
|
||||||
integrated, should support hints, layout sets should just be a
|
|
||||||
special case of custom layouts, and we should support panes that are
|
|
||||||
not attached to a cell at all. this could be the time to introduce
|
|
||||||
panelink to replace layout_cell
|
|
||||||
* way to set hints/limits about pane size for resizing
|
|
||||||
* panning over window (window larger than visible)
|
|
||||||
* a mode where one application can cross two panes (ie x|y, width =
|
|
||||||
COLUMNS/2 but height = ROWS * 2)
|
|
||||||
* separate active panes for different clients
|
|
||||||
* way to choose where the freed space goes when a pane is killed:
|
|
||||||
option to kill-pane? GitHub issue 918
|
|
||||||
|
|
||||||
- code cleanup
|
|
||||||
* instead of separate window and session options, just one master
|
|
||||||
options list with each option having a type (window or session), then
|
|
||||||
options on window, on session, and global. for window options we look
|
|
||||||
window->session->global, and for session we look session->global.
|
|
||||||
problem: what about windows in multiple sessions? there are contexts
|
|
||||||
where we do not know which session, or where multiple choices makes
|
|
||||||
no sense... could at least have one global list for all types of
|
|
||||||
global options and keep separate window,session lists
|
|
||||||
* the way pane, window, session destroy is handled is too complicated
|
|
||||||
and the distinction between session.c, window.c and server-fn.c
|
|
||||||
functions is not clear. could we just have kill_pane(),
|
|
||||||
kill_window(), unlink_window(), kill_session() that fix up all data
|
|
||||||
structures (flagging sessions as dead) and return a value to say
|
|
||||||
whether clients need to be checked for dead sessions? sort of like
|
|
||||||
session_detach now but more so. or some other scheme to make it
|
|
||||||
simpler and clearer? also would be nice to remove/rename server-fn.c
|
|
||||||
* more readable way to work out the various things commands need to
|
|
||||||
know about the client, notably:
|
|
||||||
- is this the config file? (cmdq->c == NULL)
|
|
||||||
- is this a command client? (cmdq->c != NULL &&
|
|
||||||
cmdq->c->session == NULL)
|
|
||||||
- is this a control client?
|
|
||||||
- can i do stdin or stdout to this client?
|
|
||||||
or even guarantee that cmdq->c != NULL and provide a better way to
|
|
||||||
tell when in the config file - then we use cmdq->c if we need a
|
|
||||||
client w/o a session else cmd_current_client
|
|
||||||
|
|
||||||
- miscellaneous
|
|
||||||
* link panes into multiple windows
|
|
||||||
* live update: server started with -U connects to server, requests
|
|
||||||
sessions and windows, receives file descriptors
|
|
||||||
* there are inconsistencies in what we get from old shell and what
|
|
||||||
comes from config for new sessions and windows. likewise, panes and
|
|
||||||
jobs and run-shell and lock command all start with slightly different
|
|
||||||
environments
|
|
||||||
* multiline status line? separate command prompt and status line?
|
|
||||||
* automatic pane logging
|
|
||||||
* marks in history, automatically add (move?) one when pane is changed
|
|
||||||
* this doesn't work, need pane reference count probably:
|
|
||||||
bind -n DoubleClick3Status confirm-before -p "kill-window #I? (y/n)" kill-window
|
|
||||||
* respawn -c flag same as neww etc
|
|
||||||
|
|
||||||
- hooks
|
|
||||||
* more hooks for various things
|
|
||||||
* finish after hooks for special commands
|
|
||||||
* multiple hooks with the same name?
|
|
||||||
* finish hooks for notifys
|
|
||||||
* for session_closed, if no sessions at all, perhaps fake up a temporary one
|
|
||||||
163
alerts.c
163
alerts.c
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <event.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -30,13 +29,13 @@ static int alerts_enabled(struct window *, int);
|
|||||||
static void alerts_callback(int, short, void *);
|
static void alerts_callback(int, short, void *);
|
||||||
static void alerts_reset(struct window *);
|
static void alerts_reset(struct window *);
|
||||||
|
|
||||||
|
static int alerts_action_applies(struct winlink *, const char *);
|
||||||
static int alerts_check_all(struct window *);
|
static int alerts_check_all(struct window *);
|
||||||
static int alerts_check_bell(struct window *);
|
static int alerts_check_bell(struct window *);
|
||||||
static int alerts_check_activity(struct window *);
|
static int alerts_check_activity(struct window *);
|
||||||
static int alerts_check_silence(struct window *);
|
static int alerts_check_silence(struct window *);
|
||||||
static void printflike(2, 3) alerts_set_message(struct session *, const char *,
|
static void alerts_set_message(struct winlink *, const char *,
|
||||||
...);
|
const char *);
|
||||||
static void alerts_ring_bell(struct session *);
|
|
||||||
|
|
||||||
static TAILQ_HEAD(, window) alerts_list = TAILQ_HEAD_INITIALIZER(alerts_list);
|
static TAILQ_HEAD(, window) alerts_list = TAILQ_HEAD_INITIALIZER(alerts_list);
|
||||||
|
|
||||||
@@ -46,7 +45,6 @@ alerts_timer(__unused int fd, __unused short events, void *arg)
|
|||||||
struct window *w = arg;
|
struct window *w = arg;
|
||||||
|
|
||||||
log_debug("@%u alerts timer expired", w->id);
|
log_debug("@%u alerts timer expired", w->id);
|
||||||
alerts_reset(w);
|
|
||||||
alerts_queue(w, WINDOW_SILENCE);
|
alerts_queue(w, WINDOW_SILENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,12 +67,33 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg)
|
|||||||
alerts_fired = 0;
|
alerts_fired = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
alerts_action_applies(struct winlink *wl, const char *name)
|
||||||
|
{
|
||||||
|
int action;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* {bell,activity,silence}-action determines when to alert: none means
|
||||||
|
* nothing happens, current means only do something for the current
|
||||||
|
* window and other means only for windows other than the current.
|
||||||
|
*/
|
||||||
|
|
||||||
|
action = options_get_number(wl->session->options, name);
|
||||||
|
if (action == ALERT_ANY)
|
||||||
|
return (1);
|
||||||
|
if (action == ALERT_CURRENT)
|
||||||
|
return (wl == wl->session->curw);
|
||||||
|
if (action == ALERT_OTHER)
|
||||||
|
return (wl != wl->session->curw);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
alerts_check_all(struct window *w)
|
alerts_check_all(struct window *w)
|
||||||
{
|
{
|
||||||
int alerts;
|
int alerts;
|
||||||
|
|
||||||
alerts = alerts_check_bell(w);
|
alerts = alerts_check_bell(w);
|
||||||
alerts |= alerts_check_activity(w);
|
alerts |= alerts_check_activity(w);
|
||||||
alerts |= alerts_check_silence(w);
|
alerts |= alerts_check_silence(w);
|
||||||
return (alerts);
|
return (alerts);
|
||||||
@@ -92,8 +111,10 @@ alerts_check_session(struct session *s)
|
|||||||
static int
|
static int
|
||||||
alerts_enabled(struct window *w, int flags)
|
alerts_enabled(struct window *w, int flags)
|
||||||
{
|
{
|
||||||
if (flags & WINDOW_BELL)
|
if (flags & WINDOW_BELL) {
|
||||||
return (1);
|
if (options_get_number(w->options, "monitor-bell"))
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
if (flags & WINDOW_ACTIVITY) {
|
if (flags & WINDOW_ACTIVITY) {
|
||||||
if (options_get_number(w->options, "monitor-activity"))
|
if (options_get_number(w->options, "monitor-activity"))
|
||||||
return (1);
|
return (1);
|
||||||
@@ -119,6 +140,9 @@ alerts_reset(struct window *w)
|
|||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
|
if (!event_initialized(&w->alerts_timer))
|
||||||
|
evtimer_set(&w->alerts_timer, alerts_timer, w);
|
||||||
|
|
||||||
w->flags &= ~WINDOW_SILENCE;
|
w->flags &= ~WINDOW_SILENCE;
|
||||||
event_del(&w->alerts_timer);
|
event_del(&w->alerts_timer);
|
||||||
|
|
||||||
@@ -133,11 +157,7 @@ alerts_reset(struct window *w)
|
|||||||
void
|
void
|
||||||
alerts_queue(struct window *w, int flags)
|
alerts_queue(struct window *w, int flags)
|
||||||
{
|
{
|
||||||
if (w->flags & WINDOW_ACTIVITY)
|
alerts_reset(w);
|
||||||
alerts_reset(w);
|
|
||||||
|
|
||||||
if (!event_initialized(&w->alerts_timer))
|
|
||||||
evtimer_set(&w->alerts_timer, alerts_timer, w);
|
|
||||||
|
|
||||||
if ((w->flags & flags) != flags) {
|
if ((w->flags & flags) != flags) {
|
||||||
w->flags |= flags;
|
w->flags |= flags;
|
||||||
@@ -162,58 +182,36 @@ alerts_queue(struct window *w, int flags)
|
|||||||
static int
|
static int
|
||||||
alerts_check_bell(struct window *w)
|
alerts_check_bell(struct window *w)
|
||||||
{
|
{
|
||||||
struct window *ws;
|
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct client *c;
|
|
||||||
int action, visual;
|
|
||||||
|
|
||||||
if (~w->flags & WINDOW_BELL)
|
if (~w->flags & WINDOW_BELL)
|
||||||
return (0);
|
return (0);
|
||||||
|
if (!options_get_number(w->options, "monitor-bell"))
|
||||||
|
return (0);
|
||||||
|
|
||||||
TAILQ_FOREACH(wl, &w->winlinks, wentry)
|
TAILQ_FOREACH(wl, &w->winlinks, wentry)
|
||||||
wl->session->flags &= ~SESSION_ALERTED;
|
wl->session->flags &= ~SESSION_ALERTED;
|
||||||
|
|
||||||
TAILQ_FOREACH(wl, &w->winlinks, wentry) {
|
TAILQ_FOREACH(wl, &w->winlinks, wentry) {
|
||||||
if (wl->flags & WINLINK_BELL)
|
/*
|
||||||
continue;
|
* Bells are allowed even if there is an existing bell (so do
|
||||||
|
* not check WINLINK_BELL).
|
||||||
|
*/
|
||||||
s = wl->session;
|
s = wl->session;
|
||||||
if (s->curw != wl) {
|
if (s->curw != wl || s->attached == 0) {
|
||||||
wl->flags |= WINLINK_BELL;
|
wl->flags |= WINLINK_BELL;
|
||||||
notify_winlink("alert-bell", wl);
|
server_status_session(s);
|
||||||
}
|
}
|
||||||
|
if (!alerts_action_applies(wl, "bell-action"))
|
||||||
|
continue;
|
||||||
|
notify_winlink("alert-bell", wl);
|
||||||
|
|
||||||
if (s->flags & SESSION_ALERTED)
|
if (s->flags & SESSION_ALERTED)
|
||||||
continue;
|
continue;
|
||||||
s->flags |= SESSION_ALERTED;
|
s->flags |= SESSION_ALERTED;
|
||||||
|
|
||||||
action = options_get_number(s->options, "bell-action");
|
alerts_set_message(wl, "Bell", "visual-bell");
|
||||||
if (action == BELL_NONE)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
visual = options_get_number(s->options, "visual-bell");
|
|
||||||
TAILQ_FOREACH(c, &clients, entry) {
|
|
||||||
if (c->session != s || c->flags & CLIENT_CONTROL)
|
|
||||||
continue;
|
|
||||||
ws = c->session->curw->window;
|
|
||||||
|
|
||||||
if (action == BELL_CURRENT && ws != w)
|
|
||||||
action = BELL_NONE;
|
|
||||||
if (action == BELL_OTHER && ws != w)
|
|
||||||
action = BELL_NONE;
|
|
||||||
|
|
||||||
if (!visual) {
|
|
||||||
if (action != BELL_NONE)
|
|
||||||
tty_putcode(&c->tty, TTYC_BEL);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (action == BELL_CURRENT)
|
|
||||||
status_message_set(c, "Bell in current window");
|
|
||||||
else if (action != BELL_NONE) {
|
|
||||||
status_message_set(c, "Bell in window %d",
|
|
||||||
wl->idx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (WINDOW_BELL);
|
return (WINDOW_BELL);
|
||||||
@@ -237,20 +235,19 @@ alerts_check_activity(struct window *w)
|
|||||||
if (wl->flags & WINLINK_ACTIVITY)
|
if (wl->flags & WINLINK_ACTIVITY)
|
||||||
continue;
|
continue;
|
||||||
s = wl->session;
|
s = wl->session;
|
||||||
if (s->curw == wl)
|
if (s->curw != wl || s->attached == 0) {
|
||||||
|
wl->flags |= WINLINK_ACTIVITY;
|
||||||
|
server_status_session(s);
|
||||||
|
}
|
||||||
|
if (!alerts_action_applies(wl, "activity-action"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
wl->flags |= WINLINK_ACTIVITY;
|
|
||||||
notify_winlink("alert-activity", wl);
|
notify_winlink("alert-activity", wl);
|
||||||
|
|
||||||
if (s->flags & SESSION_ALERTED)
|
if (s->flags & SESSION_ALERTED)
|
||||||
continue;
|
continue;
|
||||||
s->flags |= SESSION_ALERTED;
|
s->flags |= SESSION_ALERTED;
|
||||||
|
|
||||||
if (options_get_number(s->options, "bell-on-alert"))
|
alerts_set_message(wl, "Activity", "visual-activity");
|
||||||
alerts_ring_bell(s);
|
|
||||||
if (options_get_number(s->options, "visual-activity"))
|
|
||||||
alerts_set_message(s, "Activity in window %d", wl->idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (WINDOW_ACTIVITY);
|
return (WINDOW_ACTIVITY);
|
||||||
@@ -264,7 +261,7 @@ alerts_check_silence(struct window *w)
|
|||||||
|
|
||||||
if (~w->flags & WINDOW_SILENCE)
|
if (~w->flags & WINDOW_SILENCE)
|
||||||
return (0);
|
return (0);
|
||||||
if (!options_get_number(w->options, "monitor-silence"))
|
if (options_get_number(w->options, "monitor-silence") == 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
TAILQ_FOREACH(wl, &w->winlinks, wentry)
|
TAILQ_FOREACH(wl, &w->winlinks, wentry)
|
||||||
@@ -274,51 +271,55 @@ alerts_check_silence(struct window *w)
|
|||||||
if (wl->flags & WINLINK_SILENCE)
|
if (wl->flags & WINLINK_SILENCE)
|
||||||
continue;
|
continue;
|
||||||
s = wl->session;
|
s = wl->session;
|
||||||
if (s->curw == wl)
|
if (s->curw != wl || s->attached == 0) {
|
||||||
|
wl->flags |= WINLINK_SILENCE;
|
||||||
|
server_status_session(s);
|
||||||
|
}
|
||||||
|
if (!alerts_action_applies(wl, "silence-action"))
|
||||||
continue;
|
continue;
|
||||||
wl->flags |= WINLINK_SILENCE;
|
|
||||||
notify_winlink("alert-silence", wl);
|
notify_winlink("alert-silence", wl);
|
||||||
|
|
||||||
if (s->flags & SESSION_ALERTED)
|
if (s->flags & SESSION_ALERTED)
|
||||||
continue;
|
continue;
|
||||||
s->flags |= SESSION_ALERTED;
|
s->flags |= SESSION_ALERTED;
|
||||||
|
|
||||||
if (options_get_number(s->options, "bell-on-alert"))
|
alerts_set_message(wl, "Silence", "visual-silence");
|
||||||
alerts_ring_bell(s);
|
|
||||||
|
|
||||||
if (!options_get_number(s->options, "visual-silence"))
|
|
||||||
alerts_set_message(s, "Silence in window %d", wl->idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (WINDOW_SILENCE);
|
return (WINDOW_SILENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
alerts_set_message(struct session *s, const char *fmt, ...)
|
alerts_set_message(struct winlink *wl, const char *type, const char *option)
|
||||||
{
|
{
|
||||||
struct client *c;
|
struct client *c;
|
||||||
va_list ap;
|
int visual;
|
||||||
char *message;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
/*
|
||||||
xvasprintf(&message, fmt, ap);
|
* We have found an alert (bell, activity or silence), so we need to
|
||||||
va_end(ap);
|
* pass it on to the user. For each client attached to this session,
|
||||||
|
* decide whether a bell, message or both is needed.
|
||||||
|
*
|
||||||
|
* If visual-{bell,activity,silence} is on, then a message is
|
||||||
|
* substituted for a bell; if it is off, a bell is sent as normal; both
|
||||||
|
* mean both a bell and message is sent.
|
||||||
|
*/
|
||||||
|
|
||||||
|
visual = options_get_number(wl->session->options, option);
|
||||||
TAILQ_FOREACH(c, &clients, entry) {
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
if (c->session == s)
|
if (c->session != wl->session || c->flags & CLIENT_CONTROL)
|
||||||
status_message_set(c, "%s", message);
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
free(message);
|
if (visual == VISUAL_OFF || visual == VISUAL_BOTH)
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
alerts_ring_bell(struct session *s)
|
|
||||||
{
|
|
||||||
struct client *c;
|
|
||||||
|
|
||||||
TAILQ_FOREACH(c, &clients, entry) {
|
|
||||||
if (c->session == s && !(c->flags & CLIENT_CONTROL))
|
|
||||||
tty_putcode(&c->tty, TTYC_BEL);
|
tty_putcode(&c->tty, TTYC_BEL);
|
||||||
|
if (visual == VISUAL_OFF)
|
||||||
|
continue;
|
||||||
|
if (c->session->curw == wl) {
|
||||||
|
status_message_set(c, -1, 1, 0, "%s in current window",
|
||||||
|
type);
|
||||||
|
} else {
|
||||||
|
status_message_set(c, -1, 1, 0, "%s in window %d", type,
|
||||||
|
wl->idx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1015
arguments.c
1015
arguments.c
File diff suppressed because it is too large
Load Diff
60
attributes.c
60
attributes.c
@@ -25,13 +25,14 @@
|
|||||||
const char *
|
const char *
|
||||||
attributes_tostring(int attr)
|
attributes_tostring(int attr)
|
||||||
{
|
{
|
||||||
static char buf[128];
|
static char buf[512];
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (attr == 0)
|
if (attr == 0)
|
||||||
return ("none");
|
return ("none");
|
||||||
|
|
||||||
len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s%s",
|
len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
||||||
|
(attr & GRID_ATTR_CHARSET) ? "acs," : "",
|
||||||
(attr & GRID_ATTR_BRIGHT) ? "bright," : "",
|
(attr & GRID_ATTR_BRIGHT) ? "bright," : "",
|
||||||
(attr & GRID_ATTR_DIM) ? "dim," : "",
|
(attr & GRID_ATTR_DIM) ? "dim," : "",
|
||||||
(attr & GRID_ATTR_UNDERSCORE) ? "underscore," : "",
|
(attr & GRID_ATTR_UNDERSCORE) ? "underscore," : "",
|
||||||
@@ -39,7 +40,12 @@ attributes_tostring(int attr)
|
|||||||
(attr & GRID_ATTR_REVERSE) ? "reverse," : "",
|
(attr & GRID_ATTR_REVERSE) ? "reverse," : "",
|
||||||
(attr & GRID_ATTR_HIDDEN) ? "hidden," : "",
|
(attr & GRID_ATTR_HIDDEN) ? "hidden," : "",
|
||||||
(attr & GRID_ATTR_ITALICS) ? "italics," : "",
|
(attr & GRID_ATTR_ITALICS) ? "italics," : "",
|
||||||
(attr & GRID_ATTR_STRIKETHROUGH) ? "strikethrough," : "");
|
(attr & GRID_ATTR_STRIKETHROUGH) ? "strikethrough," : "",
|
||||||
|
(attr & GRID_ATTR_UNDERSCORE_2) ? "double-underscore," : "",
|
||||||
|
(attr & GRID_ATTR_UNDERSCORE_3) ? "curly-underscore," : "",
|
||||||
|
(attr & GRID_ATTR_UNDERSCORE_4) ? "dotted-underscore," : "",
|
||||||
|
(attr & GRID_ATTR_UNDERSCORE_5) ? "dashed-underscore," : "",
|
||||||
|
(attr & GRID_ATTR_OVERLINE) ? "overline," : "");
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
buf[len - 1] = '\0';
|
buf[len - 1] = '\0';
|
||||||
|
|
||||||
@@ -52,6 +58,27 @@ attributes_fromstring(const char *str)
|
|||||||
const char delimiters[] = " ,|";
|
const char delimiters[] = " ,|";
|
||||||
int attr;
|
int attr;
|
||||||
size_t end;
|
size_t end;
|
||||||
|
u_int i;
|
||||||
|
struct {
|
||||||
|
const char *name;
|
||||||
|
int attr;
|
||||||
|
} table[] = {
|
||||||
|
{ "acs", GRID_ATTR_CHARSET },
|
||||||
|
{ "bright", GRID_ATTR_BRIGHT },
|
||||||
|
{ "bold", GRID_ATTR_BRIGHT },
|
||||||
|
{ "dim", GRID_ATTR_DIM },
|
||||||
|
{ "underscore", GRID_ATTR_UNDERSCORE },
|
||||||
|
{ "blink", GRID_ATTR_BLINK },
|
||||||
|
{ "reverse", GRID_ATTR_REVERSE },
|
||||||
|
{ "hidden", GRID_ATTR_HIDDEN },
|
||||||
|
{ "italics", GRID_ATTR_ITALICS },
|
||||||
|
{ "strikethrough", GRID_ATTR_STRIKETHROUGH },
|
||||||
|
{ "double-underscore", GRID_ATTR_UNDERSCORE_2 },
|
||||||
|
{ "curly-underscore", GRID_ATTR_UNDERSCORE_3 },
|
||||||
|
{ "dotted-underscore", GRID_ATTR_UNDERSCORE_4 },
|
||||||
|
{ "dashed-underscore", GRID_ATTR_UNDERSCORE_5 },
|
||||||
|
{ "overline", GRID_ATTR_OVERLINE }
|
||||||
|
};
|
||||||
|
|
||||||
if (*str == '\0' || strcspn(str, delimiters) == 0)
|
if (*str == '\0' || strcspn(str, delimiters) == 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -64,24 +91,15 @@ attributes_fromstring(const char *str)
|
|||||||
attr = 0;
|
attr = 0;
|
||||||
do {
|
do {
|
||||||
end = strcspn(str, delimiters);
|
end = strcspn(str, delimiters);
|
||||||
if ((end == 6 && strncasecmp(str, "bright", end) == 0) ||
|
for (i = 0; i < nitems(table); i++) {
|
||||||
(end == 4 && strncasecmp(str, "bold", end) == 0))
|
if (end != strlen(table[i].name))
|
||||||
attr |= GRID_ATTR_BRIGHT;
|
continue;
|
||||||
else if (end == 3 && strncasecmp(str, "dim", end) == 0)
|
if (strncasecmp(str, table[i].name, end) == 0) {
|
||||||
attr |= GRID_ATTR_DIM;
|
attr |= table[i].attr;
|
||||||
else if (end == 10 && strncasecmp(str, "underscore", end) == 0)
|
break;
|
||||||
attr |= GRID_ATTR_UNDERSCORE;
|
}
|
||||||
else if (end == 5 && strncasecmp(str, "blink", end) == 0)
|
}
|
||||||
attr |= GRID_ATTR_BLINK;
|
if (i == nitems(table))
|
||||||
else if (end == 7 && strncasecmp(str, "reverse", end) == 0)
|
|
||||||
attr |= GRID_ATTR_REVERSE;
|
|
||||||
else if (end == 6 && strncasecmp(str, "hidden", end) == 0)
|
|
||||||
attr |= GRID_ATTR_HIDDEN;
|
|
||||||
else if (end == 7 && strncasecmp(str, "italics", end) == 0)
|
|
||||||
attr |= GRID_ATTR_ITALICS;
|
|
||||||
else if (end == 13 && strncasecmp(str, "strikethrough", end) == 0)
|
|
||||||
attr |= GRID_ATTR_STRIKETHROUGH;
|
|
||||||
else
|
|
||||||
return (-1);
|
return (-1);
|
||||||
str += end + strspn(str + end, delimiters);
|
str += end + strspn(str + end, delimiters);
|
||||||
} while (*str != '\0');
|
} while (*str != '\0');
|
||||||
|
|||||||
247
cfg.c
247
cfg.c
@@ -23,16 +23,19 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
static char *cfg_file;
|
struct client *cfg_client;
|
||||||
int cfg_finished;
|
int cfg_finished;
|
||||||
static char **cfg_causes;
|
static char **cfg_causes;
|
||||||
static u_int cfg_ncauses;
|
static u_int cfg_ncauses;
|
||||||
static struct cmdq_item *cfg_item;
|
static struct cmdq_item *cfg_item;
|
||||||
|
|
||||||
|
int cfg_quiet = 1;
|
||||||
|
char **cfg_files;
|
||||||
|
u_int cfg_nfiles;
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cfg_client_done(__unused struct cmdq_item *item, __unused void *data)
|
cfg_client_done(__unused struct cmdq_item *item, __unused void *data)
|
||||||
{
|
{
|
||||||
@@ -48,35 +51,26 @@ cfg_done(__unused struct cmdq_item *item, __unused void *data)
|
|||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
cfg_finished = 1;
|
cfg_finished = 1;
|
||||||
|
|
||||||
if (!RB_EMPTY(&sessions))
|
cfg_show_causes(NULL);
|
||||||
cfg_show_causes(RB_MIN(sessions, &sessions));
|
|
||||||
|
|
||||||
if (cfg_item != NULL)
|
if (cfg_item != NULL)
|
||||||
cfg_item->flags &= ~CMDQ_WAITING;
|
cmdq_continue(cfg_item);
|
||||||
|
|
||||||
status_prompt_load_history();
|
status_prompt_load_history();
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
set_cfg_file(const char *path)
|
|
||||||
{
|
|
||||||
free(cfg_file);
|
|
||||||
cfg_file = xstrdup(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
start_cfg(void)
|
start_cfg(void)
|
||||||
{
|
{
|
||||||
const char *home;
|
struct client *c;
|
||||||
int quiet = 0;
|
u_int i;
|
||||||
struct client *c;
|
int flags = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configuration files are loaded without a client, so NULL is passed
|
* Configuration files are loaded without a client, so commands are run
|
||||||
* into load_cfg() and commands run in the global queue with
|
* in the global queue with item->client NULL.
|
||||||
* item->client NULL.
|
|
||||||
*
|
*
|
||||||
* However, we must block the initial client (but just the initial
|
* However, we must block the initial client (but just the initial
|
||||||
* client) so that its command runs after the configuration is loaded.
|
* client) so that its command runs after the configuration is loaded.
|
||||||
@@ -84,113 +78,129 @@ start_cfg(void)
|
|||||||
* command queue is currently empty and our callback will be at the
|
* command queue is currently empty and our callback will be at the
|
||||||
* front - we need to get in before MSG_COMMAND.
|
* front - we need to get in before MSG_COMMAND.
|
||||||
*/
|
*/
|
||||||
c = TAILQ_FIRST(&clients);
|
cfg_client = c = TAILQ_FIRST(&clients);
|
||||||
if (c != NULL) {
|
if (c != NULL) {
|
||||||
cfg_item = cmdq_get_callback(cfg_client_done, NULL);
|
cfg_item = cmdq_get_callback(cfg_client_done, NULL);
|
||||||
cmdq_append(c, cfg_item);
|
cmdq_append(c, cfg_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
load_cfg(TMUX_CONF, NULL, NULL, 1);
|
if (cfg_quiet)
|
||||||
|
flags = CMD_PARSE_QUIET;
|
||||||
if (cfg_file == NULL && (home = find_home()) != NULL) {
|
for (i = 0; i < cfg_nfiles; i++)
|
||||||
xasprintf(&cfg_file, "%s/.tmux.conf", home);
|
load_cfg(cfg_files[i], c, NULL, NULL, flags, NULL);
|
||||||
quiet = 1;
|
|
||||||
}
|
|
||||||
if (cfg_file != NULL)
|
|
||||||
load_cfg(cfg_file, NULL, NULL, quiet);
|
|
||||||
|
|
||||||
cmdq_append(NULL, cmdq_get_callback(cfg_done, NULL));
|
cmdq_append(NULL, cmdq_get_callback(cfg_done, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
load_cfg(const char *path, struct client *c, struct cmdq_item *item, int quiet)
|
load_cfg(const char *path, struct client *c, struct cmdq_item *item,
|
||||||
|
struct cmd_find_state *current, int flags, struct cmdq_item **new_item)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
const char delim[3] = { '\\', '\\', '\0' };
|
struct cmd_parse_input pi;
|
||||||
u_int found = 0;
|
struct cmd_parse_result *pr;
|
||||||
size_t line = 0;
|
struct cmdq_item *new_item0;
|
||||||
char *buf, *cause1, *p, *q, *s;
|
struct cmdq_state *state;
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmdq_item *new_item;
|
if (new_item != NULL)
|
||||||
int condition = 0;
|
*new_item = NULL;
|
||||||
struct format_tree *ft;
|
|
||||||
|
|
||||||
log_debug("loading %s", path);
|
log_debug("loading %s", path);
|
||||||
if ((f = fopen(path, "rb")) == NULL) {
|
if ((f = fopen(path, "rb")) == NULL) {
|
||||||
if (errno == ENOENT && quiet)
|
if (errno == ENOENT && (flags & CMD_PARSE_QUIET))
|
||||||
return (0);
|
return (0);
|
||||||
cfg_add_cause("%s: %s", path, strerror(errno));
|
cfg_add_cause("%s: %s", path, strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((buf = fparseln(f, NULL, &line, delim, 0)) != NULL) {
|
memset(&pi, 0, sizeof pi);
|
||||||
log_debug("%s: %s", path, buf);
|
pi.flags = flags;
|
||||||
|
pi.file = path;
|
||||||
|
pi.line = 1;
|
||||||
|
pi.item = item;
|
||||||
|
pi.c = c;
|
||||||
|
|
||||||
p = buf;
|
pr = cmd_parse_from_file(f, &pi);
|
||||||
while (isspace((u_char)*p))
|
|
||||||
p++;
|
|
||||||
if (*p == '\0') {
|
|
||||||
free(buf);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
q = p + strlen(p) - 1;
|
|
||||||
while (q != p && isspace((u_char)*q))
|
|
||||||
*q-- = '\0';
|
|
||||||
|
|
||||||
if (condition != 0 && strcmp(p, "%endif") == 0) {
|
|
||||||
condition = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (strncmp(p, "%if ", 4) == 0) {
|
|
||||||
if (condition != 0) {
|
|
||||||
cfg_add_cause("%s:%zu: nested %%if", path,
|
|
||||||
line);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ft = format_create(NULL, NULL, FORMAT_NONE,
|
|
||||||
FORMAT_NOJOBS);
|
|
||||||
|
|
||||||
s = p + 3;
|
|
||||||
while (isspace((u_char)*s))
|
|
||||||
s++;
|
|
||||||
s = format_expand(ft, s);
|
|
||||||
if (*s != '\0' && (s[0] != '0' || s[1] != '\0'))
|
|
||||||
condition = 1;
|
|
||||||
else
|
|
||||||
condition = -1;
|
|
||||||
free(s);
|
|
||||||
|
|
||||||
format_free(ft);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (condition == -1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
cmdlist = cmd_string_parse(p, path, line, &cause1);
|
|
||||||
if (cmdlist == NULL) {
|
|
||||||
free(buf);
|
|
||||||
if (cause1 == NULL)
|
|
||||||
continue;
|
|
||||||
cfg_add_cause("%s:%zu: %s", path, line, cause1);
|
|
||||||
free(cause1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
free(buf);
|
|
||||||
|
|
||||||
if (cmdlist == NULL)
|
|
||||||
continue;
|
|
||||||
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
|
|
||||||
if (item != NULL)
|
|
||||||
cmdq_insert_after(item, new_item);
|
|
||||||
else
|
|
||||||
cmdq_append(c, new_item);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
|
|
||||||
found++;
|
|
||||||
}
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
if (pr->status == CMD_PARSE_ERROR) {
|
||||||
|
cfg_add_cause("%s", pr->error);
|
||||||
|
free(pr->error);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (flags & CMD_PARSE_PARSEONLY) {
|
||||||
|
cmd_list_free(pr->cmdlist);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
return (found);
|
if (item != NULL)
|
||||||
|
state = cmdq_copy_state(cmdq_get_state(item), current);
|
||||||
|
else
|
||||||
|
state = cmdq_new_state(NULL, NULL, 0);
|
||||||
|
cmdq_add_format(state, "current_file", "%s", pi.file);
|
||||||
|
|
||||||
|
new_item0 = cmdq_get_command(pr->cmdlist, state);
|
||||||
|
if (item != NULL)
|
||||||
|
new_item0 = cmdq_insert_after(item, new_item0);
|
||||||
|
else
|
||||||
|
new_item0 = cmdq_append(NULL, new_item0);
|
||||||
|
cmd_list_free(pr->cmdlist);
|
||||||
|
cmdq_free_state(state);
|
||||||
|
|
||||||
|
if (new_item != NULL)
|
||||||
|
*new_item = new_item0;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
load_cfg_from_buffer(const void *buf, size_t len, const char *path,
|
||||||
|
struct client *c, struct cmdq_item *item, struct cmd_find_state *current,
|
||||||
|
int flags, struct cmdq_item **new_item)
|
||||||
|
{
|
||||||
|
struct cmd_parse_input pi;
|
||||||
|
struct cmd_parse_result *pr;
|
||||||
|
struct cmdq_item *new_item0;
|
||||||
|
struct cmdq_state *state;
|
||||||
|
|
||||||
|
if (new_item != NULL)
|
||||||
|
*new_item = NULL;
|
||||||
|
|
||||||
|
log_debug("loading %s", path);
|
||||||
|
|
||||||
|
memset(&pi, 0, sizeof pi);
|
||||||
|
pi.flags = flags;
|
||||||
|
pi.file = path;
|
||||||
|
pi.line = 1;
|
||||||
|
pi.item = item;
|
||||||
|
pi.c = c;
|
||||||
|
|
||||||
|
pr = cmd_parse_from_buffer(buf, len, &pi);
|
||||||
|
if (pr->status == CMD_PARSE_ERROR) {
|
||||||
|
cfg_add_cause("%s", pr->error);
|
||||||
|
free(pr->error);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (flags & CMD_PARSE_PARSEONLY) {
|
||||||
|
cmd_list_free(pr->cmdlist);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item != NULL)
|
||||||
|
state = cmdq_copy_state(cmdq_get_state(item), current);
|
||||||
|
else
|
||||||
|
state = cmdq_new_state(NULL, NULL, 0);
|
||||||
|
cmdq_add_format(state, "current_file", "%s", pi.file);
|
||||||
|
|
||||||
|
new_item0 = cmdq_get_command(pr->cmdlist, state);
|
||||||
|
if (item != NULL)
|
||||||
|
new_item0 = cmdq_insert_after(item, new_item0);
|
||||||
|
else
|
||||||
|
new_item0 = cmdq_append(NULL, new_item0);
|
||||||
|
cmd_list_free(pr->cmdlist);
|
||||||
|
cmdq_free_state(state);
|
||||||
|
|
||||||
|
if (new_item != NULL)
|
||||||
|
*new_item = new_item0;
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -226,20 +236,41 @@ cfg_print_causes(struct cmdq_item *item)
|
|||||||
void
|
void
|
||||||
cfg_show_causes(struct session *s)
|
cfg_show_causes(struct session *s)
|
||||||
{
|
{
|
||||||
struct window_pane *wp;
|
struct client *c = TAILQ_FIRST(&clients);
|
||||||
u_int i;
|
struct window_pane *wp;
|
||||||
|
struct window_mode_entry *wme;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
if (s == NULL || cfg_ncauses == 0)
|
if (cfg_ncauses == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (c != NULL && (c->flags & CLIENT_CONTROL)) {
|
||||||
|
for (i = 0; i < cfg_ncauses; i++) {
|
||||||
|
control_write(c, "%%config-error %s", cfg_causes[i]);
|
||||||
|
free(cfg_causes[i]);
|
||||||
|
}
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s == NULL) {
|
||||||
|
if (c != NULL && c->session != NULL)
|
||||||
|
s = c->session;
|
||||||
|
else
|
||||||
|
s = RB_MIN(sessions, &sessions);
|
||||||
|
}
|
||||||
|
if (s == NULL || s->attached == 0) /* wait for an attached session */
|
||||||
return;
|
return;
|
||||||
wp = s->curw->window->active;
|
wp = s->curw->window->active;
|
||||||
|
|
||||||
window_pane_set_mode(wp, &window_copy_mode);
|
wme = TAILQ_FIRST(&wp->modes);
|
||||||
window_copy_init_for_output(wp);
|
if (wme == NULL || wme->mode != &window_view_mode)
|
||||||
|
window_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL);
|
||||||
for (i = 0; i < cfg_ncauses; i++) {
|
for (i = 0; i < cfg_ncauses; i++) {
|
||||||
window_copy_add(wp, "%s", cfg_causes[i]);
|
window_copy_add(wp, 0, "%s", cfg_causes[i]);
|
||||||
free(cfg_causes[i]);
|
free(cfg_causes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
free(cfg_causes);
|
free(cfg_causes);
|
||||||
cfg_causes = NULL;
|
cfg_causes = NULL;
|
||||||
cfg_ncauses = 0;
|
cfg_ncauses = 0;
|
||||||
|
|||||||
433
client.c
433
client.c
@@ -17,14 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#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/uio.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <event.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -35,8 +34,8 @@
|
|||||||
|
|
||||||
static struct tmuxproc *client_proc;
|
static struct tmuxproc *client_proc;
|
||||||
static struct tmuxpeer *client_peer;
|
static struct tmuxpeer *client_peer;
|
||||||
static int client_flags;
|
static uint64_t client_flags;
|
||||||
static struct event client_stdin;
|
static int client_suspended;
|
||||||
static enum {
|
static enum {
|
||||||
CLIENT_EXIT_NONE,
|
CLIENT_EXIT_NONE,
|
||||||
CLIENT_EXIT_DETACHED,
|
CLIENT_EXIT_DETACHED,
|
||||||
@@ -46,24 +45,28 @@ static enum {
|
|||||||
CLIENT_EXIT_LOST_SERVER,
|
CLIENT_EXIT_LOST_SERVER,
|
||||||
CLIENT_EXIT_EXITED,
|
CLIENT_EXIT_EXITED,
|
||||||
CLIENT_EXIT_SERVER_EXITED,
|
CLIENT_EXIT_SERVER_EXITED,
|
||||||
|
CLIENT_EXIT_MESSAGE_PROVIDED
|
||||||
} client_exitreason = CLIENT_EXIT_NONE;
|
} client_exitreason = CLIENT_EXIT_NONE;
|
||||||
|
static int client_exitflag;
|
||||||
static int client_exitval;
|
static int client_exitval;
|
||||||
static enum msgtype client_exittype;
|
static enum msgtype client_exittype;
|
||||||
static const char *client_exitsession;
|
static const char *client_exitsession;
|
||||||
|
static char *client_exitmessage;
|
||||||
static const char *client_execshell;
|
static const char *client_execshell;
|
||||||
static const char *client_execcmd;
|
static const char *client_execcmd;
|
||||||
static int client_attached;
|
static int client_attached;
|
||||||
|
static struct client_files client_files = RB_INITIALIZER(&client_files);
|
||||||
|
|
||||||
static __dead void client_exec(const char *,const char *);
|
static __dead void client_exec(const char *,const char *);
|
||||||
static int client_get_lock(char *);
|
static int client_get_lock(char *);
|
||||||
static int client_connect(struct event_base *, const char *, int);
|
static int client_connect(struct event_base *, const char *,
|
||||||
static void client_send_identify(const char *, const char *);
|
uint64_t);
|
||||||
static void client_stdin_callback(int, short, void *);
|
static void client_send_identify(const char *, const char *,
|
||||||
static void client_write(int, const char *, size_t);
|
char **, u_int, const char *, int);
|
||||||
static void client_signal(int);
|
static void client_signal(int);
|
||||||
static void client_dispatch(struct imsg *, void *);
|
static void client_dispatch(struct imsg *, void *);
|
||||||
static void client_dispatch_attached(struct imsg *);
|
static void client_dispatch_attached(struct imsg *);
|
||||||
static void client_dispatch_wait(struct imsg *, const char *);
|
static void client_dispatch_wait(struct imsg *);
|
||||||
static const char *client_exit_message(void);
|
static const char *client_exit_message(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -99,7 +102,7 @@ client_get_lock(char *lockfile)
|
|||||||
|
|
||||||
/* Connect client to server. */
|
/* Connect client to server. */
|
||||||
static int
|
static int
|
||||||
client_connect(struct event_base *base, const char *path, int start_server)
|
client_connect(struct event_base *base, const char *path, uint64_t flags)
|
||||||
{
|
{
|
||||||
struct sockaddr_un sa;
|
struct sockaddr_un sa;
|
||||||
size_t size;
|
size_t size;
|
||||||
@@ -124,7 +127,9 @@ retry:
|
|||||||
log_debug("connect failed: %s", strerror(errno));
|
log_debug("connect failed: %s", strerror(errno));
|
||||||
if (errno != ECONNREFUSED && errno != ENOENT)
|
if (errno != ECONNREFUSED && errno != ENOENT)
|
||||||
goto failed;
|
goto failed;
|
||||||
if (!start_server)
|
if (flags & CLIENT_NOSTARTSERVER)
|
||||||
|
goto failed;
|
||||||
|
if (~flags & CLIENT_STARTSERVER)
|
||||||
goto failed;
|
goto failed;
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
@@ -156,7 +161,7 @@ retry:
|
|||||||
close(lockfd);
|
close(lockfd);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
fd = server_start(base, lockfd, lockfile);
|
fd = server_start(client_proc, flags, base, lockfd, lockfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locked && lockfd >= 0) {
|
if (locked && lockfd >= 0) {
|
||||||
@@ -203,68 +208,86 @@ client_exit_message(void)
|
|||||||
case CLIENT_EXIT_TERMINATED:
|
case CLIENT_EXIT_TERMINATED:
|
||||||
return ("terminated");
|
return ("terminated");
|
||||||
case CLIENT_EXIT_LOST_SERVER:
|
case CLIENT_EXIT_LOST_SERVER:
|
||||||
return ("lost server");
|
return ("server exited unexpectedly");
|
||||||
case CLIENT_EXIT_EXITED:
|
case CLIENT_EXIT_EXITED:
|
||||||
return ("exited");
|
return ("exited");
|
||||||
case CLIENT_EXIT_SERVER_EXITED:
|
case CLIENT_EXIT_SERVER_EXITED:
|
||||||
return ("server exited");
|
return ("server exited");
|
||||||
|
case CLIENT_EXIT_MESSAGE_PROVIDED:
|
||||||
|
return (client_exitmessage);
|
||||||
}
|
}
|
||||||
return ("unknown reason");
|
return ("unknown reason");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Exit if all streams flushed. */
|
||||||
|
static void
|
||||||
|
client_exit(void)
|
||||||
|
{
|
||||||
|
if (!file_write_left(&client_files))
|
||||||
|
proc_exit(client_proc);
|
||||||
|
}
|
||||||
|
|
||||||
/* Client main loop. */
|
/* Client main loop. */
|
||||||
int
|
int
|
||||||
client_main(struct event_base *base, int argc, char **argv, int flags,
|
client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
|
||||||
const char *shellcmd)
|
int feat)
|
||||||
{
|
{
|
||||||
struct cmd *cmd;
|
struct cmd_parse_result *pr;
|
||||||
struct cmd_list *cmdlist;
|
struct msg_command *data;
|
||||||
struct msg_command_data *data;
|
int fd, i;
|
||||||
int cmdflags, fd, i;
|
const char *ttynam, *termname, *cwd;
|
||||||
const char *ttynam, *cwd;
|
|
||||||
pid_t ppid;
|
pid_t ppid;
|
||||||
enum msgtype msg;
|
enum msgtype msg;
|
||||||
char *cause, path[PATH_MAX];
|
|
||||||
struct termios tio, saved_tio;
|
struct termios tio, saved_tio;
|
||||||
size_t size;
|
size_t size, linesize = 0;
|
||||||
|
ssize_t linelen;
|
||||||
/* Ignore SIGCHLD now or daemon() in the server will leave a zombie. */
|
char *line = NULL, **caps = NULL, *cause;
|
||||||
signal(SIGCHLD, SIG_IGN);
|
u_int ncaps = 0;
|
||||||
|
struct args_value *values;
|
||||||
/* Save the flags. */
|
|
||||||
client_flags = flags;
|
|
||||||
|
|
||||||
/* Set up the initial command. */
|
/* Set up the initial command. */
|
||||||
cmdflags = 0;
|
if (shell_command != NULL) {
|
||||||
if (shellcmd != NULL) {
|
|
||||||
msg = MSG_SHELL;
|
msg = MSG_SHELL;
|
||||||
cmdflags = CMD_STARTSERVER;
|
flags |= CLIENT_STARTSERVER;
|
||||||
} else if (argc == 0) {
|
} else if (argc == 0) {
|
||||||
msg = MSG_COMMAND;
|
msg = MSG_COMMAND;
|
||||||
cmdflags = CMD_STARTSERVER;
|
flags |= CLIENT_STARTSERVER;
|
||||||
} else {
|
} else {
|
||||||
msg = MSG_COMMAND;
|
msg = MSG_COMMAND;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It sucks parsing the command string twice (in client and
|
* It's annoying parsing the command string twice (in client
|
||||||
* later in server) but it is necessary to get the start server
|
* and later in server) but it is necessary to get the start
|
||||||
* flag.
|
* server flag.
|
||||||
*/
|
*/
|
||||||
cmdlist = cmd_list_parse(argc, argv, NULL, 0, &cause);
|
values = args_from_vector(argc, argv);
|
||||||
if (cmdlist != NULL) {
|
pr = cmd_parse_from_arguments(values, argc, NULL);
|
||||||
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
if (pr->status == CMD_PARSE_SUCCESS) {
|
||||||
if (cmd->entry->flags & CMD_STARTSERVER)
|
if (cmd_list_any_have(pr->cmdlist, CMD_STARTSERVER))
|
||||||
cmdflags |= CMD_STARTSERVER;
|
flags |= CLIENT_STARTSERVER;
|
||||||
}
|
cmd_list_free(pr->cmdlist);
|
||||||
cmd_list_free(cmdlist);
|
} else
|
||||||
}
|
free(pr->error);
|
||||||
|
args_free_values(values, argc);
|
||||||
|
free(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create client process structure (starts logging). */
|
/* Create client process structure (starts logging). */
|
||||||
client_proc = proc_start("client", base, 0, client_signal);
|
client_proc = proc_start("client");
|
||||||
|
proc_set_signals(client_proc, client_signal);
|
||||||
|
|
||||||
|
/* Save the flags. */
|
||||||
|
client_flags = flags;
|
||||||
|
log_debug("flags are %#llx", (unsigned long long)client_flags);
|
||||||
|
|
||||||
/* Initialize the client socket and start the server. */
|
/* Initialize the client socket and start the server. */
|
||||||
fd = client_connect(base, socket_path, cmdflags & CMD_STARTSERVER);
|
#ifdef HAVE_SYSTEMD
|
||||||
|
if (systemd_activated()) {
|
||||||
|
/* socket-based activation, do not even try to be a client. */
|
||||||
|
fd = server_start(client_proc, flags, base, 0, NULL);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
fd = client_connect(base, socket_path, client_flags);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
if (errno == ECONNREFUSED) {
|
if (errno == ECONNREFUSED) {
|
||||||
fprintf(stderr, "no server running on %s\n",
|
fprintf(stderr, "no server running on %s\n",
|
||||||
@@ -275,16 +298,15 @@ client_main(struct event_base *base, int argc, char **argv, int flags,
|
|||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
client_peer = proc_add_peer(client_proc, fd, client_dispatch,
|
client_peer = proc_add_peer(client_proc, fd, client_dispatch, NULL);
|
||||||
(void *)shellcmd);
|
|
||||||
|
|
||||||
/* Save these before pledge(). */
|
/* Save these before pledge(). */
|
||||||
if ((cwd = getcwd(path, sizeof path)) == NULL) {
|
if ((cwd = find_cwd()) == NULL && (cwd = find_home()) == NULL)
|
||||||
if ((cwd = find_home()) == NULL)
|
cwd = "/";
|
||||||
cwd = "/";
|
|
||||||
}
|
|
||||||
if ((ttynam = ttyname(STDIN_FILENO)) == NULL)
|
if ((ttynam = ttyname(STDIN_FILENO)) == NULL)
|
||||||
ttynam = "";
|
ttynam = "";
|
||||||
|
if ((termname = getenv("TERM")) == NULL)
|
||||||
|
termname = "";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Drop privileges for client. "proc exec" is needed for -c and for
|
* Drop privileges for client. "proc exec" is needed for -c and for
|
||||||
@@ -295,9 +317,21 @@ client_main(struct event_base *base, int argc, char **argv, int flags,
|
|||||||
*
|
*
|
||||||
* "sendfd" is dropped later in client_dispatch_wait().
|
* "sendfd" is dropped later in client_dispatch_wait().
|
||||||
*/
|
*/
|
||||||
if (pledge("stdio unix sendfd proc exec tty", NULL) != 0)
|
if (pledge(
|
||||||
|
"stdio rpath wpath cpath unix sendfd proc exec tty",
|
||||||
|
NULL) != 0)
|
||||||
fatal("pledge failed");
|
fatal("pledge failed");
|
||||||
|
|
||||||
|
/* Load terminfo entry if any. */
|
||||||
|
if (isatty(STDIN_FILENO) &&
|
||||||
|
*termname != '\0' &&
|
||||||
|
tty_term_read_list(termname, STDIN_FILENO, &caps, &ncaps,
|
||||||
|
&cause) != 0) {
|
||||||
|
fprintf(stderr, "%s\n", cause);
|
||||||
|
free(cause);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Free stuff that is not used in the client. */
|
/* Free stuff that is not used in the client. */
|
||||||
if (ptm_fd != -1)
|
if (ptm_fd != -1)
|
||||||
close(ptm_fd);
|
close(ptm_fd);
|
||||||
@@ -306,10 +340,7 @@ client_main(struct event_base *base, int argc, char **argv, int flags,
|
|||||||
options_free(global_w_options);
|
options_free(global_w_options);
|
||||||
environ_free(global_environ);
|
environ_free(global_environ);
|
||||||
|
|
||||||
/* Create stdin handler. */
|
/* Set up control mode. */
|
||||||
setblocking(STDIN_FILENO, 0);
|
|
||||||
event_set(&client_stdin, STDIN_FILENO, EV_READ|EV_PERSIST,
|
|
||||||
client_stdin_callback, NULL);
|
|
||||||
if (client_flags & CLIENT_CONTROLCONTROL) {
|
if (client_flags & CLIENT_CONTROLCONTROL) {
|
||||||
if (tcgetattr(STDIN_FILENO, &saved_tio) != 0) {
|
if (tcgetattr(STDIN_FILENO, &saved_tio) != 0) {
|
||||||
fprintf(stderr, "tcgetattr failed: %s\n",
|
fprintf(stderr, "tcgetattr failed: %s\n",
|
||||||
@@ -331,7 +362,9 @@ client_main(struct event_base *base, int argc, char **argv, int flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send identify messages. */
|
/* Send identify messages. */
|
||||||
client_send_identify(ttynam, cwd);
|
client_send_identify(ttynam, termname, caps, ncaps, cwd, feat);
|
||||||
|
tty_term_free_list(caps, ncaps);
|
||||||
|
proc_flush_peer(client_peer);
|
||||||
|
|
||||||
/* Send first command. */
|
/* Send first command. */
|
||||||
if (msg == MSG_COMMAND) {
|
if (msg == MSG_COMMAND) {
|
||||||
@@ -339,6 +372,10 @@ client_main(struct event_base *base, int argc, char **argv, int flags,
|
|||||||
size = 0;
|
size = 0;
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
size += strlen(argv[i]) + 1;
|
size += strlen(argv[i]) + 1;
|
||||||
|
if (size > MAX_IMSGSIZE - (sizeof *data)) {
|
||||||
|
fprintf(stderr, "command too long\n");
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
data = xmalloc((sizeof *data) + size);
|
data = xmalloc((sizeof *data) + size);
|
||||||
|
|
||||||
/* Prepare command for server. */
|
/* Prepare command for server. */
|
||||||
@@ -367,10 +404,14 @@ client_main(struct event_base *base, int argc, char **argv, int flags,
|
|||||||
if (client_exittype == MSG_EXEC) {
|
if (client_exittype == MSG_EXEC) {
|
||||||
if (client_flags & CLIENT_CONTROLCONTROL)
|
if (client_flags & CLIENT_CONTROLCONTROL)
|
||||||
tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
|
tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
|
||||||
clear_signals(0);
|
|
||||||
client_exec(client_execshell, client_execcmd);
|
client_exec(client_execshell, client_execcmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Restore streams to blocking. */
|
||||||
|
setblocking(STDIN_FILENO, 1);
|
||||||
|
setblocking(STDOUT_FILENO, 1);
|
||||||
|
setblocking(STDERR_FILENO, 1);
|
||||||
|
|
||||||
/* Print the exit message, if any, and exit. */
|
/* Print the exit message, if any, and exit. */
|
||||||
if (client_attached) {
|
if (client_attached) {
|
||||||
if (client_exitreason != CLIENT_EXIT_NONE)
|
if (client_exitreason != CLIENT_EXIT_NONE)
|
||||||
@@ -379,42 +420,66 @@ client_main(struct event_base *base, int argc, char **argv, int flags,
|
|||||||
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 (client_flags & CLIENT_CONTROLCONTROL) {
|
} else if (client_flags & CLIENT_CONTROL) {
|
||||||
if (client_exitreason != CLIENT_EXIT_NONE)
|
if (client_exitreason != CLIENT_EXIT_NONE)
|
||||||
printf("%%exit %s\n", client_exit_message());
|
printf("%%exit %s\n", client_exit_message());
|
||||||
else
|
else
|
||||||
printf("%%exit\n");
|
printf("%%exit\n");
|
||||||
printf("\033\\");
|
fflush(stdout);
|
||||||
tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
|
if (client_flags & CLIENT_CONTROL_WAITEXIT) {
|
||||||
|
setvbuf(stdin, NULL, _IOLBF, 0);
|
||||||
|
for (;;) {
|
||||||
|
linelen = getline(&line, &linesize, stdin);
|
||||||
|
if (linelen <= 1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free(line);
|
||||||
|
}
|
||||||
|
if (client_flags & CLIENT_CONTROLCONTROL) {
|
||||||
|
printf("\033\\");
|
||||||
|
fflush(stdout);
|
||||||
|
tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
|
||||||
|
}
|
||||||
} else if (client_exitreason != CLIENT_EXIT_NONE)
|
} else if (client_exitreason != CLIENT_EXIT_NONE)
|
||||||
fprintf(stderr, "%s\n", client_exit_message());
|
fprintf(stderr, "%s\n", client_exit_message());
|
||||||
setblocking(STDIN_FILENO, 1);
|
|
||||||
return (client_exitval);
|
return (client_exitval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send identify messages to server. */
|
/* Send identify messages to server. */
|
||||||
static void
|
static void
|
||||||
client_send_identify(const char *ttynam, const char *cwd)
|
client_send_identify(const char *ttynam, const char *termname, char **caps,
|
||||||
|
u_int ncaps, const char *cwd, int feat)
|
||||||
{
|
{
|
||||||
const char *s;
|
char **ss;
|
||||||
char **ss;
|
size_t sslen;
|
||||||
size_t sslen;
|
int fd;
|
||||||
int fd, flags = client_flags;
|
uint64_t flags = client_flags;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
proc_send(client_peer, MSG_IDENTIFY_FLAGS, -1, &flags, sizeof flags);
|
proc_send(client_peer, MSG_IDENTIFY_LONGFLAGS, -1, &flags, sizeof flags);
|
||||||
|
proc_send(client_peer, MSG_IDENTIFY_LONGFLAGS, -1, &client_flags,
|
||||||
|
sizeof client_flags);
|
||||||
|
|
||||||
if ((s = getenv("TERM")) == NULL)
|
proc_send(client_peer, MSG_IDENTIFY_TERM, -1, termname,
|
||||||
s = "";
|
strlen(termname) + 1);
|
||||||
proc_send(client_peer, MSG_IDENTIFY_TERM, -1, s, strlen(s) + 1);
|
proc_send(client_peer, MSG_IDENTIFY_FEATURES, -1, &feat, sizeof feat);
|
||||||
|
|
||||||
proc_send(client_peer, MSG_IDENTIFY_TTYNAME, -1, ttynam,
|
proc_send(client_peer, MSG_IDENTIFY_TTYNAME, -1, ttynam,
|
||||||
strlen(ttynam) + 1);
|
strlen(ttynam) + 1);
|
||||||
proc_send(client_peer, MSG_IDENTIFY_CWD, -1, cwd, strlen(cwd) + 1);
|
proc_send(client_peer, MSG_IDENTIFY_CWD, -1, cwd, strlen(cwd) + 1);
|
||||||
|
|
||||||
|
for (i = 0; i < ncaps; i++) {
|
||||||
|
proc_send(client_peer, MSG_IDENTIFY_TERMINFO, -1,
|
||||||
|
caps[i], strlen(caps[i]) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
if ((fd = dup(STDIN_FILENO)) == -1)
|
if ((fd = dup(STDIN_FILENO)) == -1)
|
||||||
fatal("dup failed");
|
fatal("dup failed");
|
||||||
proc_send(client_peer, MSG_IDENTIFY_STDIN, fd, NULL, 0);
|
proc_send(client_peer, MSG_IDENTIFY_STDIN, fd, NULL, 0);
|
||||||
|
if ((fd = dup(STDOUT_FILENO)) == -1)
|
||||||
|
fatal("dup failed");
|
||||||
|
proc_send(client_peer, MSG_IDENTIFY_STDOUT, fd, NULL, 0);
|
||||||
|
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
proc_send(client_peer, MSG_IDENTIFY_CLIENTPID, -1, &pid, sizeof pid);
|
proc_send(client_peer, MSG_IDENTIFY_CLIENTPID, -1, &pid, sizeof pid);
|
||||||
@@ -429,60 +494,18 @@ client_send_identify(const char *ttynam, const char *cwd)
|
|||||||
proc_send(client_peer, MSG_IDENTIFY_DONE, -1, NULL, 0);
|
proc_send(client_peer, MSG_IDENTIFY_DONE, -1, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback for client stdin read events. */
|
|
||||||
static void
|
|
||||||
client_stdin_callback(__unused int fd, __unused short events,
|
|
||||||
__unused void *arg)
|
|
||||||
{
|
|
||||||
struct msg_stdin_data data;
|
|
||||||
|
|
||||||
data.size = read(STDIN_FILENO, data.data, sizeof data.data);
|
|
||||||
if (data.size < 0 && (errno == EINTR || errno == EAGAIN))
|
|
||||||
return;
|
|
||||||
|
|
||||||
proc_send(client_peer, MSG_STDIN, -1, &data, sizeof data);
|
|
||||||
if (data.size <= 0)
|
|
||||||
event_del(&client_stdin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Force write to file descriptor. */
|
|
||||||
static 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Run command in shell; used for -c. */
|
/* Run command in shell; used for -c. */
|
||||||
static __dead void
|
static __dead void
|
||||||
client_exec(const char *shell, const char *shellcmd)
|
client_exec(const char *shell, const char *shellcmd)
|
||||||
{
|
{
|
||||||
const char *name, *ptr;
|
char *argv0;
|
||||||
char *argv0;
|
|
||||||
|
|
||||||
log_debug("shell %s, command %s", shell, shellcmd);
|
log_debug("shell %s, command %s", shell, shellcmd);
|
||||||
|
argv0 = shell_argv0(shell, !!(client_flags & CLIENT_LOGIN));
|
||||||
ptr = strrchr(shell, '/');
|
|
||||||
if (ptr != NULL && *(ptr + 1) != '\0')
|
|
||||||
name = ptr + 1;
|
|
||||||
else
|
|
||||||
name = shell;
|
|
||||||
if (client_flags & CLIENT_LOGIN)
|
|
||||||
xasprintf(&argv0, "-%s", name);
|
|
||||||
else
|
|
||||||
xasprintf(&argv0, "%s", name);
|
|
||||||
setenv("SHELL", shell, 1);
|
setenv("SHELL", shell, 1);
|
||||||
|
|
||||||
|
proc_clear_signals(client_proc, 1);
|
||||||
|
|
||||||
setblocking(STDIN_FILENO, 1);
|
setblocking(STDIN_FILENO, 1);
|
||||||
setblocking(STDOUT_FILENO, 1);
|
setblocking(STDOUT_FILENO, 1);
|
||||||
setblocking(STDERR_FILENO, 1);
|
setblocking(STDERR_FILENO, 1);
|
||||||
@@ -498,11 +521,23 @@ client_signal(int sig)
|
|||||||
{
|
{
|
||||||
struct sigaction sigact;
|
struct sigaction sigact;
|
||||||
int status;
|
int status;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
if (sig == SIGCHLD)
|
log_debug("%s: %s", __func__, strsignal(sig));
|
||||||
waitpid(WAIT_ANY, &status, WNOHANG);
|
if (sig == SIGCHLD) {
|
||||||
else if (!client_attached) {
|
for (;;) {
|
||||||
if (sig == SIGTERM)
|
pid = waitpid(WAIT_ANY, &status, WNOHANG);
|
||||||
|
if (pid == 0)
|
||||||
|
break;
|
||||||
|
if (pid == -1) {
|
||||||
|
if (errno == ECHILD)
|
||||||
|
break;
|
||||||
|
log_debug("waitpid failed: %s",
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (!client_attached) {
|
||||||
|
if (sig == SIGTERM || sig == SIGHUP)
|
||||||
proc_exit(client_proc);
|
proc_exit(client_proc);
|
||||||
} else {
|
} else {
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
@@ -512,7 +547,8 @@ client_signal(int sig)
|
|||||||
proc_send(client_peer, MSG_EXITING, -1, NULL, 0);
|
proc_send(client_peer, MSG_EXITING, -1, NULL, 0);
|
||||||
break;
|
break;
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
client_exitreason = CLIENT_EXIT_TERMINATED;
|
if (!client_suspended)
|
||||||
|
client_exitreason = CLIENT_EXIT_TERMINATED;
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
proc_send(client_peer, MSG_EXITING, -1, NULL, 0);
|
proc_send(client_peer, MSG_EXITING, -1, NULL, 0);
|
||||||
break;
|
break;
|
||||||
@@ -527,18 +563,31 @@ client_signal(int sig)
|
|||||||
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
||||||
fatal("sigaction failed");
|
fatal("sigaction failed");
|
||||||
proc_send(client_peer, MSG_WAKEUP, -1, NULL, 0);
|
proc_send(client_peer, MSG_WAKEUP, -1, NULL, 0);
|
||||||
|
client_suspended = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Callback for file write error or close. */
|
||||||
|
static void
|
||||||
|
client_file_check_cb(__unused struct client *c, __unused const char *path,
|
||||||
|
__unused int error, __unused int closed, __unused struct evbuffer *buffer,
|
||||||
|
__unused void *data)
|
||||||
|
{
|
||||||
|
if (client_exitflag)
|
||||||
|
client_exit();
|
||||||
|
}
|
||||||
|
|
||||||
/* Callback for client read events. */
|
/* Callback for client read events. */
|
||||||
static void
|
static void
|
||||||
client_dispatch(struct imsg *imsg, void *arg)
|
client_dispatch(struct imsg *imsg, __unused void *arg)
|
||||||
{
|
{
|
||||||
if (imsg == NULL) {
|
if (imsg == NULL) {
|
||||||
client_exitreason = CLIENT_EXIT_LOST_SERVER;
|
if (!client_exitflag) {
|
||||||
client_exitval = 1;
|
client_exitreason = CLIENT_EXIT_LOST_SERVER;
|
||||||
|
client_exitval = 1;
|
||||||
|
}
|
||||||
proc_exit(client_proc);
|
proc_exit(client_proc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -546,19 +595,42 @@ client_dispatch(struct imsg *imsg, void *arg)
|
|||||||
if (client_attached)
|
if (client_attached)
|
||||||
client_dispatch_attached(imsg);
|
client_dispatch_attached(imsg);
|
||||||
else
|
else
|
||||||
client_dispatch_wait(imsg, arg);
|
client_dispatch_wait(imsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Process an exit message. */
|
||||||
|
static void
|
||||||
|
client_dispatch_exit_message(char *data, size_t datalen)
|
||||||
|
{
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
if (datalen < sizeof retval && datalen != 0)
|
||||||
|
fatalx("bad MSG_EXIT size");
|
||||||
|
|
||||||
|
if (datalen >= sizeof retval) {
|
||||||
|
memcpy(&retval, data, sizeof retval);
|
||||||
|
client_exitval = retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (datalen > sizeof retval) {
|
||||||
|
datalen -= sizeof retval;
|
||||||
|
data += sizeof retval;
|
||||||
|
|
||||||
|
client_exitmessage = xmalloc(datalen);
|
||||||
|
memcpy(client_exitmessage, data, datalen);
|
||||||
|
client_exitmessage[datalen - 1] = '\0';
|
||||||
|
|
||||||
|
client_exitreason = CLIENT_EXIT_MESSAGE_PROVIDED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dispatch imsgs when in wait state (before MSG_READY). */
|
/* Dispatch imsgs when in wait state (before MSG_READY). */
|
||||||
static void
|
static void
|
||||||
client_dispatch_wait(struct imsg *imsg, const char *shellcmd)
|
client_dispatch_wait(struct imsg *imsg)
|
||||||
{
|
{
|
||||||
char *data;
|
char *data;
|
||||||
ssize_t datalen;
|
ssize_t datalen;
|
||||||
struct msg_stdout_data stdoutdata;
|
static int pledge_applied;
|
||||||
struct msg_stderr_data stderrdata;
|
|
||||||
int retval;
|
|
||||||
static int pledge_applied;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "sendfd" is no longer required once all of the identify messages
|
* "sendfd" is no longer required once all of the identify messages
|
||||||
@@ -567,10 +639,12 @@ client_dispatch_wait(struct imsg *imsg, const char *shellcmd)
|
|||||||
* get the first message from the server.
|
* get the first message from the server.
|
||||||
*/
|
*/
|
||||||
if (!pledge_applied) {
|
if (!pledge_applied) {
|
||||||
if (pledge("stdio unix proc exec tty", NULL) != 0)
|
if (pledge(
|
||||||
|
"stdio rpath wpath cpath unix proc exec tty",
|
||||||
|
NULL) != 0)
|
||||||
fatal("pledge failed");
|
fatal("pledge failed");
|
||||||
pledge_applied = 1;
|
pledge_applied = 1;
|
||||||
};
|
}
|
||||||
|
|
||||||
data = imsg->data;
|
data = imsg->data;
|
||||||
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
|
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
|
||||||
@@ -578,44 +652,17 @@ client_dispatch_wait(struct imsg *imsg, const char *shellcmd)
|
|||||||
switch (imsg->hdr.type) {
|
switch (imsg->hdr.type) {
|
||||||
case MSG_EXIT:
|
case MSG_EXIT:
|
||||||
case MSG_SHUTDOWN:
|
case MSG_SHUTDOWN:
|
||||||
if (datalen != sizeof retval && datalen != 0)
|
client_dispatch_exit_message(data, datalen);
|
||||||
fatalx("bad MSG_EXIT size");
|
client_exitflag = 1;
|
||||||
if (datalen == sizeof retval) {
|
client_exit();
|
||||||
memcpy(&retval, data, sizeof retval);
|
|
||||||
client_exitval = retval;
|
|
||||||
}
|
|
||||||
proc_exit(client_proc);
|
|
||||||
break;
|
break;
|
||||||
case MSG_READY:
|
case MSG_READY:
|
||||||
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;
|
||||||
proc_send(client_peer, MSG_RESIZE, -1, NULL, 0);
|
proc_send(client_peer, MSG_RESIZE, -1, NULL, 0);
|
||||||
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 size");
|
|
||||||
memcpy(&stdoutdata, data, sizeof stdoutdata);
|
|
||||||
|
|
||||||
client_write(STDOUT_FILENO, stdoutdata.data,
|
|
||||||
stdoutdata.size);
|
|
||||||
break;
|
|
||||||
case MSG_STDERR:
|
|
||||||
if (datalen != sizeof stderrdata)
|
|
||||||
fatalx("bad MSG_STDERR size");
|
|
||||||
memcpy(&stderrdata, 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");
|
||||||
@@ -626,12 +673,19 @@ client_dispatch_wait(struct imsg *imsg, const char *shellcmd)
|
|||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
proc_exit(client_proc);
|
proc_exit(client_proc);
|
||||||
break;
|
break;
|
||||||
|
case MSG_FLAGS:
|
||||||
|
if (datalen != sizeof client_flags)
|
||||||
|
fatalx("bad MSG_FLAGS string");
|
||||||
|
|
||||||
|
memcpy(&client_flags, data, sizeof client_flags);
|
||||||
|
log_debug("new flags are %#llx",
|
||||||
|
(unsigned long long)client_flags);
|
||||||
|
break;
|
||||||
case MSG_SHELL:
|
case MSG_SHELL:
|
||||||
if (datalen == 0 || data[datalen - 1] != '\0')
|
if (datalen == 0 || data[datalen - 1] != '\0')
|
||||||
fatalx("bad MSG_SHELL string");
|
fatalx("bad MSG_SHELL string");
|
||||||
|
|
||||||
clear_signals(0);
|
client_exec(data, shell_command);
|
||||||
client_exec(data, shellcmd);
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
case MSG_DETACH:
|
case MSG_DETACH:
|
||||||
case MSG_DETACHKILL:
|
case MSG_DETACHKILL:
|
||||||
@@ -640,6 +694,31 @@ client_dispatch_wait(struct imsg *imsg, const char *shellcmd)
|
|||||||
case MSG_EXITED:
|
case MSG_EXITED:
|
||||||
proc_exit(client_proc);
|
proc_exit(client_proc);
|
||||||
break;
|
break;
|
||||||
|
case MSG_READ_OPEN:
|
||||||
|
file_read_open(&client_files, client_peer, imsg, 1,
|
||||||
|
!(client_flags & CLIENT_CONTROL), client_file_check_cb,
|
||||||
|
NULL);
|
||||||
|
break;
|
||||||
|
case MSG_READ_CANCEL:
|
||||||
|
file_read_cancel(&client_files, imsg);
|
||||||
|
break;
|
||||||
|
case MSG_WRITE_OPEN:
|
||||||
|
file_write_open(&client_files, client_peer, imsg, 1,
|
||||||
|
!(client_flags & CLIENT_CONTROL), client_file_check_cb,
|
||||||
|
NULL);
|
||||||
|
break;
|
||||||
|
case MSG_WRITE:
|
||||||
|
file_write_data(&client_files, imsg);
|
||||||
|
break;
|
||||||
|
case MSG_WRITE_CLOSE:
|
||||||
|
file_write_close(&client_files, imsg);
|
||||||
|
break;
|
||||||
|
case MSG_OLDSTDERR:
|
||||||
|
case MSG_OLDSTDIN:
|
||||||
|
case MSG_OLDSTDOUT:
|
||||||
|
fprintf(stderr, "server version is too old for client\n");
|
||||||
|
proc_exit(client_proc);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,6 +734,14 @@ client_dispatch_attached(struct imsg *imsg)
|
|||||||
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
|
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
|
||||||
|
|
||||||
switch (imsg->hdr.type) {
|
switch (imsg->hdr.type) {
|
||||||
|
case MSG_FLAGS:
|
||||||
|
if (datalen != sizeof client_flags)
|
||||||
|
fatalx("bad MSG_FLAGS string");
|
||||||
|
|
||||||
|
memcpy(&client_flags, data, sizeof client_flags);
|
||||||
|
log_debug("new flags are %#llx",
|
||||||
|
(unsigned long long)client_flags);
|
||||||
|
break;
|
||||||
case MSG_DETACH:
|
case MSG_DETACH:
|
||||||
case MSG_DETACHKILL:
|
case MSG_DETACHKILL:
|
||||||
if (datalen == 0 || data[datalen - 1] != '\0')
|
if (datalen == 0 || data[datalen - 1] != '\0')
|
||||||
@@ -679,11 +766,10 @@ client_dispatch_attached(struct imsg *imsg)
|
|||||||
proc_send(client_peer, MSG_EXITING, -1, NULL, 0);
|
proc_send(client_peer, MSG_EXITING, -1, NULL, 0);
|
||||||
break;
|
break;
|
||||||
case MSG_EXIT:
|
case MSG_EXIT:
|
||||||
if (datalen != 0 && datalen != sizeof (int))
|
client_dispatch_exit_message(data, datalen);
|
||||||
fatalx("bad MSG_EXIT size");
|
if (client_exitreason == CLIENT_EXIT_NONE)
|
||||||
|
client_exitreason = CLIENT_EXIT_EXITED;
|
||||||
proc_send(client_peer, MSG_EXITING, -1, NULL, 0);
|
proc_send(client_peer, MSG_EXITING, -1, NULL, 0);
|
||||||
client_exitreason = CLIENT_EXIT_EXITED;
|
|
||||||
break;
|
break;
|
||||||
case MSG_EXITED:
|
case MSG_EXITED:
|
||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
@@ -709,6 +795,7 @@ client_dispatch_attached(struct imsg *imsg)
|
|||||||
sigact.sa_handler = SIG_DFL;
|
sigact.sa_handler = SIG_DFL;
|
||||||
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
||||||
fatal("sigaction failed");
|
fatal("sigaction failed");
|
||||||
|
client_suspended = 1;
|
||||||
kill(getpid(), SIGTSTP);
|
kill(getpid(), SIGTSTP);
|
||||||
break;
|
break;
|
||||||
case MSG_LOCK:
|
case MSG_LOCK:
|
||||||
|
|||||||
@@ -37,27 +37,30 @@ const struct cmd_entry cmd_attach_session_entry = {
|
|||||||
.name = "attach-session",
|
.name = "attach-session",
|
||||||
.alias = "attach",
|
.alias = "attach",
|
||||||
|
|
||||||
.args = { "c:dErt:", 0, 0 },
|
.args = { "c:dEf:rt:x", 0, 0, NULL },
|
||||||
.usage = "[-dEr] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
|
.usage = "[-dErx] [-c working-directory] [-f flags] "
|
||||||
|
CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
/* -t is special */
|
/* -t is special */
|
||||||
|
|
||||||
.flags = CMD_STARTSERVER,
|
.flags = CMD_STARTSERVER|CMD_READONLY,
|
||||||
.exec = cmd_attach_session_exec
|
.exec = cmd_attach_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
enum cmd_retval
|
||||||
cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
||||||
int rflag, const char *cflag, int Eflag)
|
int xflag, int rflag, const char *cflag, int Eflag, const char *fflag)
|
||||||
{
|
{
|
||||||
struct cmd_find_state *current = &item->shared->current;
|
struct cmd_find_state *current = cmdq_get_current(item);
|
||||||
|
struct cmd_find_state target;
|
||||||
enum cmd_find_type type;
|
enum cmd_find_type type;
|
||||||
int flags;
|
int flags;
|
||||||
struct client *c = item->client, *c_loop;
|
struct client *c = cmdq_get_client(item), *c_loop;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
char *cause;
|
char *cwd, *cause;
|
||||||
|
enum msgtype msgtype;
|
||||||
|
|
||||||
if (RB_EMPTY(&sessions)) {
|
if (RB_EMPTY(&sessions)) {
|
||||||
cmdq_error(item, "no sessions");
|
cmdq_error(item, "no sessions");
|
||||||
@@ -66,6 +69,7 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
|||||||
|
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
if (server_client_check_nested(c)) {
|
if (server_client_check_nested(c)) {
|
||||||
cmdq_error(item, "sessions should be nested with care, "
|
cmdq_error(item, "sessions should be nested with care, "
|
||||||
"unset $TMUX to force");
|
"unset $TMUX to force");
|
||||||
@@ -79,83 +83,83 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
|||||||
type = CMD_FIND_SESSION;
|
type = CMD_FIND_SESSION;
|
||||||
flags = CMD_FIND_PREFER_UNATTACHED;
|
flags = CMD_FIND_PREFER_UNATTACHED;
|
||||||
}
|
}
|
||||||
if (cmd_find_target(&item->target, item, tflag, type, flags) != 0)
|
if (cmd_find_target(&target, item, tflag, type, flags) != 0)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
s = item->target.s;
|
s = target.s;
|
||||||
wl = item->target.wl;
|
wl = target.wl;
|
||||||
wp = item->target.wp;
|
wp = target.wp;
|
||||||
|
|
||||||
if (wl != NULL) {
|
if (wl != NULL) {
|
||||||
if (wp != NULL)
|
if (wp != NULL)
|
||||||
window_set_active_pane(wp->window, wp);
|
window_set_active_pane(wp->window, wp, 1);
|
||||||
session_set_current(s, wl);
|
session_set_current(s, wl);
|
||||||
if (wp != NULL)
|
if (wp != NULL)
|
||||||
cmd_find_from_winlink_pane(current, wl, wp);
|
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||||
else
|
else
|
||||||
cmd_find_from_winlink(current, wl);
|
cmd_find_from_winlink(current, wl, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cflag != NULL) {
|
if (cflag != NULL) {
|
||||||
|
cwd = format_single(item, cflag, c, s, wl, wp);
|
||||||
free((void *)s->cwd);
|
free((void *)s->cwd);
|
||||||
s->cwd = format_single(item, cflag, c, s, wl, wp);
|
s->cwd = cwd;
|
||||||
}
|
}
|
||||||
|
if (fflag)
|
||||||
|
server_client_set_flags(c, fflag);
|
||||||
|
if (rflag)
|
||||||
|
c->flags |= (CLIENT_READONLY|CLIENT_IGNORESIZE);
|
||||||
|
|
||||||
|
c->last_session = c->session;
|
||||||
if (c->session != NULL) {
|
if (c->session != NULL) {
|
||||||
if (dflag) {
|
if (dflag || xflag) {
|
||||||
|
if (xflag)
|
||||||
|
msgtype = MSG_DETACHKILL;
|
||||||
|
else
|
||||||
|
msgtype = MSG_DETACH;
|
||||||
TAILQ_FOREACH(c_loop, &clients, entry) {
|
TAILQ_FOREACH(c_loop, &clients, entry) {
|
||||||
if (c_loop->session != s || c == c_loop)
|
if (c_loop->session != s || c == c_loop)
|
||||||
continue;
|
continue;
|
||||||
server_client_detach(c_loop, MSG_DETACH);
|
server_client_detach(c_loop, msgtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Eflag)
|
if (!Eflag)
|
||||||
environ_update(s->options, c->environ, s->environ);
|
environ_update(s->options, c->environ, s->environ);
|
||||||
|
|
||||||
c->session = s;
|
server_client_set_session(c, s);
|
||||||
if (~item->shared->flags & CMDQ_SHARED_REPEAT)
|
if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT)
|
||||||
server_client_set_key_table(c, NULL);
|
server_client_set_key_table(c, NULL);
|
||||||
status_timer_start(c);
|
|
||||||
notify_client("client-session-changed", c);
|
|
||||||
session_update_activity(s, NULL);
|
|
||||||
gettimeofday(&s->last_attached_time, NULL);
|
|
||||||
server_redraw_client(c);
|
|
||||||
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
|
||||||
} else {
|
} else {
|
||||||
if (server_client_open(c, &cause) != 0) {
|
if (server_client_open(c, &cause) != 0) {
|
||||||
cmdq_error(item, "open terminal failed: %s", cause);
|
cmdq_error(item, "open terminal failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (rflag)
|
|
||||||
c->flags |= CLIENT_READONLY;
|
|
||||||
|
|
||||||
if (dflag) {
|
if (dflag || xflag) {
|
||||||
|
if (xflag)
|
||||||
|
msgtype = MSG_DETACHKILL;
|
||||||
|
else
|
||||||
|
msgtype = MSG_DETACH;
|
||||||
TAILQ_FOREACH(c_loop, &clients, entry) {
|
TAILQ_FOREACH(c_loop, &clients, entry) {
|
||||||
if (c_loop->session != s || c == c_loop)
|
if (c_loop->session != s || c == c_loop)
|
||||||
continue;
|
continue;
|
||||||
server_client_detach(c_loop, MSG_DETACH);
|
server_client_detach(c_loop, msgtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Eflag)
|
if (!Eflag)
|
||||||
environ_update(s->options, c->environ, s->environ);
|
environ_update(s->options, c->environ, s->environ);
|
||||||
|
|
||||||
c->session = s;
|
server_client_set_session(c, s);
|
||||||
server_client_set_key_table(c, NULL);
|
server_client_set_key_table(c, NULL);
|
||||||
status_timer_start(c);
|
|
||||||
notify_client("client-session-changed", c);
|
|
||||||
session_update_activity(s, NULL);
|
|
||||||
gettimeofday(&s->last_attached_time, NULL);
|
|
||||||
server_redraw_client(c);
|
|
||||||
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
|
||||||
|
|
||||||
if (~c->flags & CLIENT_CONTROL)
|
if (~c->flags & CLIENT_CONTROL)
|
||||||
proc_send(c->peer, MSG_READY, -1, NULL, 0);
|
proc_send(c->peer, MSG_READY, -1, NULL, 0);
|
||||||
notify_client("client-attached", c);
|
notify_client("client-attached", c);
|
||||||
c->flags |= CLIENT_ATTACHED;
|
c->flags |= CLIENT_ATTACHED;
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
|
||||||
alerts_check_session(s);
|
if (cfg_finished)
|
||||||
server_update_socket();
|
cfg_show_causes(s);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
@@ -163,9 +167,9 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_attach_session_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_attach_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
|
|
||||||
return (cmd_attach_session(item, args_get(args, 't'),
|
return (cmd_attach_session(item, args_get(args, 't'),
|
||||||
args_has(args, 'd'), args_has(args, 'r'), args_get(args, 'c'),
|
args_has(args, 'd'), args_has(args, 'x'), args_has(args, 'r'),
|
||||||
args_has(args, 'E')));
|
args_get(args, 'c'), args_has(args, 'E'), args_get(args, 'f')));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,32 +27,44 @@
|
|||||||
* Bind a key to a command.
|
* Bind a key to a command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmdq_item *);
|
static enum args_parse_type cmd_bind_key_args_parse(struct args *, u_int,
|
||||||
|
char **);
|
||||||
|
static enum cmd_retval cmd_bind_key_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_bind_key_entry = {
|
const struct cmd_entry cmd_bind_key_entry = {
|
||||||
.name = "bind-key",
|
.name = "bind-key",
|
||||||
.alias = "bind",
|
.alias = "bind",
|
||||||
|
|
||||||
.args = { "cnrT:", 2, -1 },
|
.args = { "nrN:T:", 1, -1, cmd_bind_key_args_parse },
|
||||||
.usage = "[-cnr] [-T key-table] key "
|
.usage = "[-nr] [-T key-table] [-N note] key "
|
||||||
"command [arguments]",
|
"[command [arguments]]",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_bind_key_exec
|
.exec = cmd_bind_key_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static enum args_parse_type
|
||||||
|
cmd_bind_key_args_parse(__unused struct args *args, __unused u_int idx,
|
||||||
|
__unused char **cause)
|
||||||
|
{
|
||||||
|
return (ARGS_PARSE_COMMANDS_OR_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
char *cause;
|
key_code key;
|
||||||
struct cmd_list *cmdlist;
|
const char *tablename, *note = args_get(args, 'N');
|
||||||
key_code key;
|
struct cmd_parse_result *pr;
|
||||||
const char *tablename;
|
int repeat;
|
||||||
|
struct args_value *value;
|
||||||
|
u_int count = args_count(args);
|
||||||
|
|
||||||
key = key_string_lookup_string(args->argv[0]);
|
key = key_string_lookup_string(args_string(args, 0));
|
||||||
if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
|
if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
|
||||||
cmdq_error(item, "unknown key: %s", args->argv[0]);
|
cmdq_error(item, "unknown key: %s", args_string(args, 0));
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,15 +74,34 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
tablename = "root";
|
tablename = "root";
|
||||||
else
|
else
|
||||||
tablename = "prefix";
|
tablename = "prefix";
|
||||||
|
repeat = args_has(args, 'r');
|
||||||
|
|
||||||
cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, NULL, 0,
|
if (count == 1) {
|
||||||
&cause);
|
key_bindings_add(tablename, key, note, repeat, NULL);
|
||||||
if (cmdlist == NULL) {
|
return (CMD_RETURN_NORMAL);
|
||||||
cmdq_error(item, "%s", cause);
|
|
||||||
free(cause);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
key_bindings_add(tablename, key, args_has(args, 'r'), cmdlist);
|
value = args_value(args, 1);
|
||||||
|
if (count == 2 && value->type == ARGS_COMMANDS) {
|
||||||
|
key_bindings_add(tablename, key, note, repeat, value->cmdlist);
|
||||||
|
value->cmdlist->references++;
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 2)
|
||||||
|
pr = cmd_parse_from_string(args_string(args, 1), NULL);
|
||||||
|
else {
|
||||||
|
pr = cmd_parse_from_arguments(args_values(args) + 1, count - 1,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
switch (pr->status) {
|
||||||
|
case CMD_PARSE_ERROR:
|
||||||
|
cmdq_error(item, "%s", pr->error);
|
||||||
|
free(pr->error);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
case CMD_PARSE_SUCCESS:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
key_bindings_add(tablename, key, note, repeat, pr->cmdlist);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ const struct cmd_entry cmd_break_pane_entry = {
|
|||||||
.name = "break-pane",
|
.name = "break-pane",
|
||||||
.alias = "breakp",
|
.alias = "breakp",
|
||||||
|
|
||||||
.args = { "dPF:n:s:t:", 0, 0 },
|
.args = { "abdPF:n:s:t:", 0, 0, NULL },
|
||||||
.usage = "[-dP] [-F format] [-n window-name] [-s src-pane] "
|
.usage = "[-abdP] [-F format] [-n window-name] [-s src-pane] "
|
||||||
"[-t dst-window]",
|
"[-t dst-window]",
|
||||||
|
|
||||||
.source = { 's', CMD_FIND_PANE, 0 },
|
.source = { 's', CMD_FIND_PANE, 0 },
|
||||||
@@ -48,37 +48,61 @@ const struct cmd_entry cmd_break_pane_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct cmd_find_state *current = &item->shared->current;
|
struct cmd_find_state *current = cmdq_get_current(item);
|
||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct winlink *wl = item->source.wl;
|
struct cmd_find_state *source = cmdq_get_source(item);
|
||||||
struct session *src_s = item->source.s;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct session *dst_s = item->target.s;
|
struct winlink *wl = source->wl;
|
||||||
struct window_pane *wp = item->source.wp;
|
struct session *src_s = source->s;
|
||||||
|
struct session *dst_s = target->s;
|
||||||
|
struct window_pane *wp = source->wp;
|
||||||
struct window *w = wl->window;
|
struct window *w = wl->window;
|
||||||
char *name, *cause;
|
char *name, *cause, *cp;
|
||||||
int idx = item->target.idx;
|
int idx = target->idx, before;
|
||||||
const char *template;
|
const char *template;
|
||||||
char *cp;
|
|
||||||
|
|
||||||
if (idx != -1 && winlink_find_by_index(&dst_s->windows, idx) != NULL) {
|
before = args_has(args, 'b');
|
||||||
cmdq_error(item, "index %d already in use", idx);
|
if (args_has(args, 'a') || before) {
|
||||||
return (CMD_RETURN_ERROR);
|
if (target->wl != NULL)
|
||||||
}
|
idx = winlink_shuffle_up(dst_s, target->wl, before);
|
||||||
|
else
|
||||||
if (window_count_panes(w) == 1) {
|
idx = winlink_shuffle_up(dst_s, dst_s->curw, before);
|
||||||
cmdq_error(item, "can't break with only one pane");
|
if (idx == -1)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
server_unzoom_window(w);
|
server_unzoom_window(w);
|
||||||
|
|
||||||
|
if (window_count_panes(w) == 1) {
|
||||||
|
if (server_link_window(src_s, wl, dst_s, idx, 0,
|
||||||
|
!args_has(args, 'd'), &cause) != 0) {
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (args_has(args, 'n')) {
|
||||||
|
window_set_name(w, args_get(args, 'n'));
|
||||||
|
options_set_number(w->options, "automatic-rename", 0);
|
||||||
|
}
|
||||||
|
server_unlink_window(src_s, wl);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
if (idx != -1 && winlink_find_by_index(&dst_s->windows, idx) != NULL) {
|
||||||
|
cmdq_error(item, "index in use: %d", idx);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
|
server_client_remove_pane(wp);
|
||||||
window_lost_pane(w, wp);
|
window_lost_pane(w, wp);
|
||||||
layout_close_pane(wp);
|
layout_close_pane(wp);
|
||||||
|
|
||||||
w = wp->window = window_create(dst_s->sx, dst_s->sy);
|
w = wp->window = window_create(w->sx, w->sy, w->xpixel, w->ypixel);
|
||||||
|
options_set_parent(wp->options, w->options);
|
||||||
|
wp->flags |= PANE_STYLECHANGED;
|
||||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||||
w->active = wp;
|
w->active = wp;
|
||||||
|
w->latest = tc;
|
||||||
|
|
||||||
if (!args_has(args, 'n')) {
|
if (!args_has(args, 'n')) {
|
||||||
name = default_window_name(w);
|
name = default_window_name(w);
|
||||||
@@ -91,13 +115,14 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
layout_init(w, wp);
|
layout_init(w, wp);
|
||||||
wp->flags |= PANE_CHANGED;
|
wp->flags |= PANE_CHANGED;
|
||||||
|
colour_palette_from_option(&wp->palette, wp->options);
|
||||||
|
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
idx = -1 - options_get_number(dst_s->options, "base-index");
|
idx = -1 - options_get_number(dst_s->options, "base-index");
|
||||||
wl = session_attach(dst_s, w, idx, &cause); /* can't fail */
|
wl = session_attach(dst_s, w, idx, &cause); /* can't fail */
|
||||||
if (!args_has(self->args, 'd')) {
|
if (!args_has(args, 'd')) {
|
||||||
session_select(dst_s, wl->idx);
|
session_select(dst_s, wl->idx);
|
||||||
cmd_find_from_session(current, dst_s);
|
cmd_find_from_session(current, dst_s, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
server_redraw_session(src_s);
|
server_redraw_session(src_s);
|
||||||
@@ -110,7 +135,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = BREAK_PANE_TEMPLATE;
|
template = BREAK_PANE_TEMPLATE;
|
||||||
cp = format_single(item, template, c, dst_s, wl, wp);
|
cp = format_single(item, template, tc, dst_s, wl, wp);
|
||||||
cmdq_print(item, "%s", cp);
|
cmdq_print(item, "%s", cp);
|
||||||
free(cp);
|
free(cp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ const struct cmd_entry cmd_capture_pane_entry = {
|
|||||||
.name = "capture-pane",
|
.name = "capture-pane",
|
||||||
.alias = "capturep",
|
.alias = "capturep",
|
||||||
|
|
||||||
.args = { "ab:CeE:JpPqS:t:", 0, 0 },
|
.args = { "ab:CeE:JNpPqS:Tt:", 0, 0, NULL },
|
||||||
.usage = "[-aCeJpPq] " CMD_BUFFER_USAGE " [-E end-line] "
|
.usage = "[-aCeJNpPqT] " CMD_BUFFER_USAGE " [-E end-line] "
|
||||||
"[-S start-line]" CMD_TARGET_PANE_USAGE,
|
"[-S start-line] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
@@ -53,8 +53,8 @@ const struct cmd_entry cmd_clear_history_entry = {
|
|||||||
.name = "clear-history",
|
.name = "clear-history",
|
||||||
.alias = "clearhist",
|
.alias = "clearhist",
|
||||||
|
|
||||||
.args = { "t:", 0, 0 },
|
.args = { "Ht:", 0, 0, NULL },
|
||||||
.usage = CMD_TARGET_PANE_USAGE,
|
.usage = "[-H] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
|||||||
size_t linelen;
|
size_t linelen;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
pending = input_pending(wp);
|
pending = input_pending(wp->ictx);
|
||||||
if (pending == NULL)
|
if (pending == NULL)
|
||||||
return (xstrdup(""));
|
return (xstrdup(""));
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
|||||||
struct grid *gd;
|
struct grid *gd;
|
||||||
const struct grid_line *gl;
|
const struct grid_line *gl;
|
||||||
struct grid_cell *gc = NULL;
|
struct grid_cell *gc = NULL;
|
||||||
int n, with_codes, escape_c0, join_lines;
|
int n, join_lines, flags = 0;
|
||||||
u_int i, sx, top, bottom, tmp;
|
u_int i, sx, top, bottom, tmp;
|
||||||
char *cause, *buf, *line;
|
char *cause, *buf, *line;
|
||||||
const char *Sflag, *Eflag;
|
const char *Sflag, *Eflag;
|
||||||
@@ -118,7 +118,7 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
|||||||
|
|
||||||
sx = screen_size_x(&wp->base);
|
sx = screen_size_x(&wp->base);
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
gd = wp->saved_grid;
|
gd = wp->base.saved_grid;
|
||||||
if (gd == NULL) {
|
if (gd == NULL) {
|
||||||
if (!args_has(args, 'q')) {
|
if (!args_has(args, 'q')) {
|
||||||
cmdq_error(item, "no alternate screen");
|
cmdq_error(item, "no alternate screen");
|
||||||
@@ -133,7 +133,8 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
|||||||
if (Sflag != NULL && strcmp(Sflag, "-") == 0)
|
if (Sflag != NULL && strcmp(Sflag, "-") == 0)
|
||||||
top = 0;
|
top = 0;
|
||||||
else {
|
else {
|
||||||
n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause);
|
n = args_strtonum_and_expand(args, 'S', INT_MIN, SHRT_MAX,
|
||||||
|
item, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
top = gd->hsize;
|
top = gd->hsize;
|
||||||
free(cause);
|
free(cause);
|
||||||
@@ -149,7 +150,8 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
|||||||
if (Eflag != NULL && strcmp(Eflag, "-") == 0)
|
if (Eflag != NULL && strcmp(Eflag, "-") == 0)
|
||||||
bottom = gd->hsize + gd->sy - 1;
|
bottom = gd->hsize + gd->sy - 1;
|
||||||
else {
|
else {
|
||||||
n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause);
|
n = args_strtonum_and_expand(args, 'E', INT_MIN, SHRT_MAX,
|
||||||
|
item, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
bottom = gd->hsize + gd->sy - 1;
|
bottom = gd->hsize + gd->sy - 1;
|
||||||
free(cause);
|
free(cause);
|
||||||
@@ -167,14 +169,19 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
|||||||
top = tmp;
|
top = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
with_codes = args_has(args, 'e');
|
|
||||||
escape_c0 = args_has(args, 'C');
|
|
||||||
join_lines = args_has(args, 'J');
|
join_lines = args_has(args, 'J');
|
||||||
|
if (args_has(args, 'e'))
|
||||||
|
flags |= GRID_STRING_WITH_SEQUENCES;
|
||||||
|
if (args_has(args, 'C'))
|
||||||
|
flags |= GRID_STRING_ESCAPE_SEQUENCES;
|
||||||
|
if (!join_lines && !args_has(args, 'T'))
|
||||||
|
flags |= GRID_STRING_EMPTY_CELLS;
|
||||||
|
if (!join_lines && !args_has(args, 'N'))
|
||||||
|
flags |= GRID_STRING_TRIM_SPACES;
|
||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
for (i = top; i <= bottom; i++) {
|
for (i = top; i <= bottom; i++) {
|
||||||
line = grid_string_cells(gd, 0, i, sx, &gc, with_codes,
|
line = grid_string_cells(gd, 0, i, sx, &gc, flags, wp->screen);
|
||||||
escape_c0, !join_lines);
|
|
||||||
linelen = strlen(line);
|
linelen = strlen(line);
|
||||||
|
|
||||||
buf = cmd_capture_pane_append(buf, len, line, linelen);
|
buf = cmd_capture_pane_append(buf, len, line, linelen);
|
||||||
@@ -191,17 +198,18 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct client *c;
|
struct client *c = cmdq_get_client(item);
|
||||||
struct window_pane *wp = item->target.wp;
|
struct window_pane *wp = cmdq_get_target(item)->wp;
|
||||||
char *buf, *cause;
|
char *buf, *cause;
|
||||||
const char *bufname;
|
const char *bufname;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (self->entry == &cmd_clear_history_entry) {
|
if (cmd_get_entry(self) == &cmd_clear_history_entry) {
|
||||||
if (wp->mode == &window_copy_mode)
|
window_pane_reset_mode_all(wp);
|
||||||
window_pane_reset_mode(wp);
|
|
||||||
grid_clear_history(wp->base.grid);
|
grid_clear_history(wp->base.grid);
|
||||||
|
if (args_has(args, 'H'))
|
||||||
|
screen_reset_hyperlinks(wp->screen);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,18 +222,20 @@ cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, 'p')) {
|
if (args_has(args, 'p')) {
|
||||||
c = item->client;
|
if (len > 0 && buf[len - 1] == '\n')
|
||||||
if (c == NULL ||
|
len--;
|
||||||
(c->session != NULL && !(c->flags & CLIENT_CONTROL))) {
|
if (c->flags & CLIENT_CONTROL)
|
||||||
cmdq_error(item, "can't write to stdout");
|
control_write(c, "%.*s", (int)len, buf);
|
||||||
|
else {
|
||||||
|
if (!file_can_print(c)) {
|
||||||
|
cmdq_error(item, "can't write to client");
|
||||||
|
free(buf);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
file_print_buffer(c, buf, len);
|
||||||
|
file_print(c, "\n");
|
||||||
free(buf);
|
free(buf);
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
}
|
||||||
evbuffer_add(c->stdout_data, buf, len);
|
|
||||||
free(buf);
|
|
||||||
if (args_has(args, 'P') && len > 0)
|
|
||||||
evbuffer_add(c->stdout_data, "\n", 1);
|
|
||||||
server_client_push_stdout(c);
|
|
||||||
} else {
|
} else {
|
||||||
bufname = NULL;
|
bufname = NULL;
|
||||||
if (args_has(args, 'b'))
|
if (args_has(args, 'b'))
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
/* $OpenBSD$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enter choice mode to choose a buffer.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define CHOOSE_BUFFER_TEMPLATE \
|
|
||||||
"#{buffer_name}: #{buffer_size} bytes: #{buffer_sample}"
|
|
||||||
|
|
||||||
static enum cmd_retval cmd_choose_buffer_exec(struct cmd *,
|
|
||||||
struct cmdq_item *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_buffer_entry = {
|
|
||||||
.name = "choose-buffer",
|
|
||||||
.alias = NULL,
|
|
||||||
|
|
||||||
.args = { "F:t:", 0, 1 },
|
|
||||||
.usage = CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
|
||||||
|
|
||||||
.flags = 0,
|
|
||||||
.exec = cmd_choose_buffer_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
static enum cmd_retval
|
|
||||||
cmd_choose_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
|
||||||
struct winlink *wl = item->target.wl;
|
|
||||||
struct window_choose_data *cdata;
|
|
||||||
struct paste_buffer *pb;
|
|
||||||
char *action, *action_data;
|
|
||||||
const char *template;
|
|
||||||
u_int idx;
|
|
||||||
|
|
||||||
if (c == NULL) {
|
|
||||||
cmdq_error(item, "no client available");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
|
||||||
template = CHOOSE_BUFFER_TEMPLATE;
|
|
||||||
|
|
||||||
if (paste_get_top(NULL) == NULL)
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
|
|
||||||
if (args->argc != 0)
|
|
||||||
action = xstrdup(args->argv[0]);
|
|
||||||
else
|
|
||||||
action = xstrdup("paste-buffer -b '%%'");
|
|
||||||
|
|
||||||
idx = 0;
|
|
||||||
pb = NULL;
|
|
||||||
while ((pb = paste_walk(pb)) != NULL) {
|
|
||||||
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
|
||||||
cdata->idx = idx;
|
|
||||||
|
|
||||||
cdata->ft_template = xstrdup(template);
|
|
||||||
format_defaults_paste_buffer(cdata->ft, pb);
|
|
||||||
|
|
||||||
xasprintf(&action_data, "%s", paste_buffer_name(pb));
|
|
||||||
cdata->command = cmd_template_replace(action, action_data, 1);
|
|
||||||
free(action_data);
|
|
||||||
|
|
||||||
window_choose_add(wl->window->active, cdata);
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
free(action);
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active, 0, NULL);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
/* $OpenBSD$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enter choice mode to choose a client.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define CHOOSE_CLIENT_TEMPLATE \
|
|
||||||
"#{client_name}: #{session_name} " \
|
|
||||||
"[#{client_width}x#{client_height} #{client_termname}]" \
|
|
||||||
"#{?client_utf8, (utf8),}#{?client_readonly, (ro),} " \
|
|
||||||
"(last used #{t:client_activity})"
|
|
||||||
|
|
||||||
static enum cmd_retval cmd_choose_client_exec(struct cmd *,
|
|
||||||
struct cmdq_item *);
|
|
||||||
|
|
||||||
static void cmd_choose_client_callback(struct window_choose_data *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_client_entry = {
|
|
||||||
.name = "choose-client",
|
|
||||||
.alias = NULL,
|
|
||||||
|
|
||||||
.args = { "F:t:", 0, 1 },
|
|
||||||
.usage = CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
|
||||||
|
|
||||||
.flags = 0,
|
|
||||||
.exec = cmd_choose_client_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
struct cmd_choose_client_data {
|
|
||||||
struct client *client;
|
|
||||||
};
|
|
||||||
|
|
||||||
static enum cmd_retval
|
|
||||||
cmd_choose_client_exec(struct cmd *self, struct cmdq_item *item)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
|
||||||
struct client *c1;
|
|
||||||
struct window_choose_data *cdata;
|
|
||||||
struct winlink *wl = item->target.wl;
|
|
||||||
const char *template;
|
|
||||||
char *action;
|
|
||||||
u_int idx, cur;
|
|
||||||
|
|
||||||
if (c == NULL) {
|
|
||||||
cmdq_error(item, "no client available");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 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;
|
|
||||||
TAILQ_FOREACH(c1, &clients, entry) {
|
|
||||||
if (c1->session == NULL)
|
|
||||||
continue;
|
|
||||||
if (c1 == item->client)
|
|
||||||
cur = idx;
|
|
||||||
|
|
||||||
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
|
||||||
cdata->idx = idx;
|
|
||||||
|
|
||||||
cdata->ft_template = xstrdup(template);
|
|
||||||
format_add(cdata->ft, "line", "%u", idx);
|
|
||||||
format_defaults(cdata->ft, c1, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
cdata->command = cmd_template_replace(action, c1->name, 1);
|
|
||||||
|
|
||||||
window_choose_add(wl->window->active, cdata);
|
|
||||||
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
free(action);
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active, cur,
|
|
||||||
cmd_choose_client_callback);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cmd_choose_client_callback(struct window_choose_data *cdata)
|
|
||||||
{
|
|
||||||
struct client *c;
|
|
||||||
u_int idx;
|
|
||||||
|
|
||||||
if (cdata == NULL)
|
|
||||||
return;
|
|
||||||
if (cdata->start_client->flags & CLIENT_DEAD)
|
|
||||||
return;
|
|
||||||
|
|
||||||
idx = 0;
|
|
||||||
TAILQ_FOREACH(c, &clients, entry) {
|
|
||||||
if (idx == cdata->idx)
|
|
||||||
break;
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
if (c == NULL || c->session == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
window_choose_data_run(cdata);
|
|
||||||
}
|
|
||||||
@@ -18,236 +18,100 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.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.
|
* Enter a mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CHOOSE_TREE_SESSION_TEMPLATE \
|
static enum args_parse_type cmd_choose_tree_args_parse(struct args *args,
|
||||||
"#{session_name}: #{session_windows} windows" \
|
u_int idx, char **cause);
|
||||||
"#{?session_grouped, (group ,}" \
|
static enum cmd_retval cmd_choose_tree_exec(struct cmd *,
|
||||||
"#{session_group}#{?session_grouped,),}" \
|
struct cmdq_item *);
|
||||||
"#{?session_attached, (attached),}"
|
|
||||||
#define CHOOSE_TREE_WINDOW_TEMPLATE \
|
|
||||||
"#{window_index}: #{window_name}#{window_flags} " \
|
|
||||||
"\"#{pane_title}\""
|
|
||||||
|
|
||||||
static enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmdq_item *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_tree_entry = {
|
const struct cmd_entry cmd_choose_tree_entry = {
|
||||||
.name = "choose-tree",
|
.name = "choose-tree",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "S:W:swub:c:t:", 0, 1 },
|
.args = { "F:f:GK:NO:rst:wZ", 0, 1, cmd_choose_tree_args_parse },
|
||||||
.usage = "[-suw] [-b session-template] [-c window template] "
|
.usage = "[-GNrswZ] [-F format] [-f filter] [-K key-format] "
|
||||||
"[-S format] [-W format] " CMD_TARGET_WINDOW_USAGE,
|
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.exec = cmd_choose_tree_exec
|
.exec = cmd_choose_tree_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_session_entry = {
|
const struct cmd_entry cmd_choose_client_entry = {
|
||||||
.name = "choose-session",
|
.name = "choose-client",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "F:t:", 0, 1 },
|
.args = { "F:f:K:NO:rt:Z", 0, 1, cmd_choose_tree_args_parse },
|
||||||
.usage = CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
.usage = "[-NrZ] [-F format] [-f filter] [-K key-format] "
|
||||||
|
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.exec = cmd_choose_tree_exec
|
.exec = cmd_choose_tree_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_window_entry = {
|
const struct cmd_entry cmd_choose_buffer_entry = {
|
||||||
.name = "choose-window",
|
.name = "choose-buffer",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "F:t:", 0, 1 },
|
.args = { "F:f:K:NO:rt:Z", 0, 1, cmd_choose_tree_args_parse },
|
||||||
.usage = CMD_TARGET_WINDOW_USAGE "[-F format] [template]",
|
.usage = "[-NrZ] [-F format] [-f filter] [-K key-format] "
|
||||||
|
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.exec = cmd_choose_tree_exec
|
.exec = cmd_choose_tree_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_customize_mode_entry = {
|
||||||
|
.name = "customize-mode",
|
||||||
|
.alias = NULL,
|
||||||
|
|
||||||
|
.args = { "F:f:Nt:Z", 0, 0, NULL },
|
||||||
|
.usage = "[-NZ] [-F format] [-f filter] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_choose_tree_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum args_parse_type
|
||||||
|
cmd_choose_tree_args_parse(__unused struct args *args, __unused u_int idx,
|
||||||
|
__unused char **cause)
|
||||||
|
{
|
||||||
|
return (ARGS_PARSE_COMMANDS_OR_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct winlink *wl = item->target.wl, *wm;
|
struct window_pane *wp = target->wp;
|
||||||
struct session *s = item->target.s, *s2;
|
const struct window_mode *mode;
|
||||||
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;
|
if (cmd_get_entry(self) == &cmd_choose_buffer_entry) {
|
||||||
ses_action = win_action = NULL;
|
if (paste_is_empty())
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
if (c == NULL) {
|
mode = &window_buffer_mode;
|
||||||
cmdq_error(item, "no client available");
|
} else if (cmd_get_entry(self) == &cmd_choose_client_entry) {
|
||||||
return (CMD_RETURN_ERROR);
|
if (server_client_how_many() == 0)
|
||||||
}
|
return (CMD_RETURN_NORMAL);
|
||||||
|
mode = &window_client_mode;
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
} else if (cmd_get_entry(self) == &cmd_customize_mode_entry)
|
||||||
return (CMD_RETURN_NORMAL);
|
mode = &window_customize_mode;
|
||||||
|
else
|
||||||
/* Sort out which command this is. */
|
mode = &window_tree_mode;
|
||||||
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,
|
|
||||||
c, s2, ses_template, 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 %s",
|
|
||||||
wcd != NULL ? wcd->command : "",
|
|
||||||
wcd != NULL ? ";" : "", win_action);
|
|
||||||
|
|
||||||
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,
|
|
||||||
c, 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, NULL);
|
|
||||||
|
|
||||||
if (args_has(args, 'u')) {
|
|
||||||
window_choose_expand_all(wl->window->active);
|
|
||||||
window_choose_set_current(wl->window->active, cur_win);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
window_pane_set_mode(wp, NULL, mode, target, args);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,93 +29,125 @@
|
|||||||
* Prompt for command in client.
|
* Prompt for command in client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static enum cmd_retval cmd_command_prompt_exec(struct cmd *,
|
static enum args_parse_type cmd_command_prompt_args_parse(struct args *,
|
||||||
struct cmdq_item *);
|
u_int, char **);
|
||||||
|
static enum cmd_retval cmd_command_prompt_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
static int cmd_command_prompt_callback(void *, const char *, int);
|
static int cmd_command_prompt_callback(struct client *, void *,
|
||||||
|
const char *, int);
|
||||||
static void cmd_command_prompt_free(void *);
|
static void cmd_command_prompt_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_command_prompt_entry = {
|
const struct cmd_entry cmd_command_prompt_entry = {
|
||||||
.name = "command-prompt",
|
.name = "command-prompt",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "1iI:Np:t:", 0, 1 },
|
.args = { "1bFkiI:Np:t:T:", 0, 1, cmd_command_prompt_args_parse },
|
||||||
.usage = "[-1Ni] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " "
|
.usage = "[-1bFkiN] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE
|
||||||
"[template]",
|
" [-T type] [template]",
|
||||||
|
|
||||||
.flags = 0,
|
.flags = CMD_CLIENT_TFLAG,
|
||||||
.exec = cmd_command_prompt_exec
|
.exec = cmd_command_prompt_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_command_prompt_cdata {
|
struct cmd_command_prompt_prompt {
|
||||||
struct client *c;
|
char *input;
|
||||||
int flags;
|
char *prompt;
|
||||||
|
|
||||||
char *inputs;
|
|
||||||
char *next_input;
|
|
||||||
|
|
||||||
char *prompts;
|
|
||||||
char *next_prompt;
|
|
||||||
|
|
||||||
char *template;
|
|
||||||
int idx;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct cmd_command_prompt_cdata {
|
||||||
|
struct cmdq_item *item;
|
||||||
|
struct args_command_state *state;
|
||||||
|
|
||||||
|
int flags;
|
||||||
|
enum prompt_type prompt_type;
|
||||||
|
|
||||||
|
struct cmd_command_prompt_prompt *prompts;
|
||||||
|
u_int count;
|
||||||
|
u_int current;
|
||||||
|
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum args_parse_type
|
||||||
|
cmd_command_prompt_args_parse(__unused struct args *args, __unused u_int idx,
|
||||||
|
__unused char **cause)
|
||||||
|
{
|
||||||
|
return (ARGS_PARSE_COMMANDS_OR_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
const char *inputs, *prompts;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
const char *type, *s, *input;
|
||||||
struct cmd_command_prompt_cdata *cdata;
|
struct cmd_command_prompt_cdata *cdata;
|
||||||
struct client *c;
|
char *tmp, *prompts, *prompt, *next_prompt;
|
||||||
char *prompt, *ptr, *input = NULL;
|
char *inputs = NULL, *next_input;
|
||||||
size_t n;
|
u_int count = args_count(args);
|
||||||
|
int wait = !args_has(args, 'b'), space = 1;
|
||||||
|
|
||||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
if (tc->prompt_string != NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (c->prompt_string != NULL)
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
if (args_has(args, 'i'))
|
||||||
|
wait = 0;
|
||||||
|
|
||||||
cdata = xcalloc(1, sizeof *cdata);
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
cdata->c = c;
|
if (wait)
|
||||||
|
cdata->item = item;
|
||||||
|
cdata->state = args_make_commands_prepare(self, item, 0, "%1", wait,
|
||||||
|
args_has(args, 'F'));
|
||||||
|
|
||||||
cdata->inputs = NULL;
|
if ((s = args_get(args, 'p')) == NULL) {
|
||||||
cdata->next_input = NULL;
|
if (count != 0) {
|
||||||
|
tmp = args_make_commands_get_command(cdata->state);
|
||||||
cdata->prompts = NULL;
|
xasprintf(&prompts, "(%s)", tmp);
|
||||||
cdata->next_prompt = NULL;
|
free(tmp);
|
||||||
|
} else {
|
||||||
cdata->template = NULL;
|
prompts = xstrdup(":");
|
||||||
cdata->idx = 1;
|
space = 0;
|
||||||
|
}
|
||||||
if (args->argc != 0)
|
next_prompt = prompts;
|
||||||
cdata->template = xstrdup(args->argv[0]);
|
|
||||||
else
|
|
||||||
cdata->template = xstrdup("%1");
|
|
||||||
|
|
||||||
if ((prompts = args_get(args, 'p')) != NULL)
|
|
||||||
cdata->prompts = xstrdup(prompts);
|
|
||||||
else if (args->argc != 0) {
|
|
||||||
n = strcspn(cdata->template, " ,");
|
|
||||||
xasprintf(&cdata->prompts, "(%.*s) ", (int) n, cdata->template);
|
|
||||||
} else
|
} else
|
||||||
cdata->prompts = xstrdup(":");
|
next_prompt = prompts = xstrdup(s);
|
||||||
|
if ((s = args_get(args, 'I')) != NULL)
|
||||||
/* Get first prompt. */
|
next_input = inputs = xstrdup(s);
|
||||||
cdata->next_prompt = cdata->prompts;
|
|
||||||
ptr = strsep(&cdata->next_prompt, ",");
|
|
||||||
if (prompts == NULL)
|
|
||||||
prompt = xstrdup(ptr);
|
|
||||||
else
|
else
|
||||||
xasprintf(&prompt, "%s ", ptr);
|
next_input = NULL;
|
||||||
|
while ((prompt = strsep(&next_prompt, ",")) != NULL) {
|
||||||
|
cdata->prompts = xreallocarray(cdata->prompts, cdata->count + 1,
|
||||||
|
sizeof *cdata->prompts);
|
||||||
|
if (!space)
|
||||||
|
tmp = xstrdup(prompt);
|
||||||
|
else
|
||||||
|
xasprintf(&tmp, "%s ", prompt);
|
||||||
|
cdata->prompts[cdata->count].prompt = tmp;
|
||||||
|
|
||||||
/* Get initial prompt input. */
|
if (next_input != NULL) {
|
||||||
if ((inputs = args_get(args, 'I')) != NULL) {
|
input = strsep(&next_input, ",");
|
||||||
cdata->inputs = xstrdup(inputs);
|
if (input == NULL)
|
||||||
cdata->next_input = cdata->inputs;
|
input = "";
|
||||||
input = strsep(&cdata->next_input, ",");
|
} else
|
||||||
|
input = "";
|
||||||
|
cdata->prompts[cdata->count].input = xstrdup(input);
|
||||||
|
|
||||||
|
cdata->count++;
|
||||||
}
|
}
|
||||||
|
free(inputs);
|
||||||
|
free(prompts);
|
||||||
|
|
||||||
|
if ((type = args_get(args, 'T')) != NULL) {
|
||||||
|
cdata->prompt_type = status_prompt_type(type);
|
||||||
|
if (cdata->prompt_type == PROMPT_TYPE_INVALID) {
|
||||||
|
cmdq_error(item, "unknown type: %s", type);
|
||||||
|
cmd_command_prompt_free(cdata);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
cdata->prompt_type = PROMPT_TYPE_COMMAND;
|
||||||
|
|
||||||
if (args_has(args, '1'))
|
if (args_has(args, '1'))
|
||||||
cdata->flags |= PROMPT_SINGLE;
|
cdata->flags |= PROMPT_SINGLE;
|
||||||
@@ -123,78 +155,73 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
cdata->flags |= PROMPT_NUMERIC;
|
cdata->flags |= PROMPT_NUMERIC;
|
||||||
else if (args_has(args, 'i'))
|
else if (args_has(args, 'i'))
|
||||||
cdata->flags |= PROMPT_INCREMENTAL;
|
cdata->flags |= PROMPT_INCREMENTAL;
|
||||||
status_prompt_set(c, prompt, input, cmd_command_prompt_callback,
|
else if (args_has(args, 'k'))
|
||||||
cmd_command_prompt_free, cdata, cdata->flags);
|
cdata->flags |= PROMPT_KEY;
|
||||||
free(prompt);
|
status_prompt_set(tc, target, cdata->prompts[0].prompt,
|
||||||
|
cdata->prompts[0].input, cmd_command_prompt_callback,
|
||||||
|
cmd_command_prompt_free, cdata, cdata->flags, cdata->prompt_type);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
if (!wait)
|
||||||
}
|
return (CMD_RETURN_NORMAL);
|
||||||
|
return (CMD_RETURN_WAIT);
|
||||||
static enum cmd_retval
|
|
||||||
cmd_command_prompt_error(struct cmdq_item *item, void *data)
|
|
||||||
{
|
|
||||||
char *error = data;
|
|
||||||
|
|
||||||
cmdq_error(item, "%s", error);
|
|
||||||
free(error);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cmd_command_prompt_callback(void *data, const char *s, int done)
|
cmd_command_prompt_callback(struct client *c, void *data, const char *s,
|
||||||
|
int done)
|
||||||
{
|
{
|
||||||
struct cmd_command_prompt_cdata *cdata = data;
|
struct cmd_command_prompt_cdata *cdata = data;
|
||||||
struct client *c = cdata->c;
|
char *error;
|
||||||
struct cmd_list *cmdlist;
|
struct cmdq_item *item = cdata->item, *new_item;
|
||||||
struct cmdq_item *new_item;
|
struct cmd_list *cmdlist;
|
||||||
char *cause, *new_template, *prompt, *ptr;
|
struct cmd_command_prompt_prompt *prompt;
|
||||||
char *input = NULL;
|
int argc = 0;
|
||||||
|
char **argv = NULL;
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (0);
|
goto out;
|
||||||
if (done && (cdata->flags & PROMPT_INCREMENTAL))
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
new_template = cmd_template_replace(cdata->template, s, cdata->idx);
|
|
||||||
if (done) {
|
if (done) {
|
||||||
free(cdata->template);
|
if (cdata->flags & PROMPT_INCREMENTAL)
|
||||||
cdata->template = new_template;
|
goto out;
|
||||||
|
cmd_append_argv(&cdata->argc, &cdata->argv, s);
|
||||||
|
if (++cdata->current != cdata->count) {
|
||||||
|
prompt = &cdata->prompts[cdata->current];
|
||||||
|
status_prompt_update(c, prompt->prompt, prompt->input);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
argc = cdata->argc;
|
||||||
* Check if there are more prompts; if so, get its respective input
|
argv = cmd_copy_argv(cdata->argc, cdata->argv);
|
||||||
* and update the prompt data.
|
|
||||||
*/
|
|
||||||
if (done && (ptr = strsep(&cdata->next_prompt, ",")) != NULL) {
|
|
||||||
xasprintf(&prompt, "%s ", ptr);
|
|
||||||
input = strsep(&cdata->next_input, ",");
|
|
||||||
status_prompt_update(c, prompt, input);
|
|
||||||
|
|
||||||
free(prompt);
|
|
||||||
cdata->idx++;
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmdlist = cmd_string_parse(new_template, NULL, 0, &cause);
|
|
||||||
if (cmdlist == NULL) {
|
|
||||||
if (cause != NULL) {
|
|
||||||
new_item = cmdq_get_callback(cmd_command_prompt_error,
|
|
||||||
cause);
|
|
||||||
} else
|
|
||||||
new_item = NULL;
|
|
||||||
} else {
|
|
||||||
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_item != NULL)
|
|
||||||
cmdq_append(c, new_item);
|
|
||||||
|
|
||||||
if (!done)
|
if (!done)
|
||||||
free(new_template);
|
cmd_append_argv(&argc, &argv, s);
|
||||||
if (c->prompt_callbackfn != cmd_command_prompt_callback)
|
|
||||||
|
if (done) {
|
||||||
|
cmd_free_argv(cdata->argc, cdata->argv);
|
||||||
|
cdata->argc = argc;
|
||||||
|
cdata->argv = cmd_copy_argv(argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdlist = args_make_commands(cdata->state, argc, argv, &error);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
|
cmdq_append(c, cmdq_get_error(error));
|
||||||
|
free(error);
|
||||||
|
} else if (item == NULL) {
|
||||||
|
new_item = cmdq_get_command(cmdlist, NULL);
|
||||||
|
cmdq_append(c, new_item);
|
||||||
|
} else {
|
||||||
|
new_item = cmdq_get_command(cmdlist, cmdq_get_state(item));
|
||||||
|
cmdq_insert_after(item, new_item);
|
||||||
|
}
|
||||||
|
cmd_free_argv(argc, argv);
|
||||||
|
|
||||||
|
if (c->prompt_inputcb != cmd_command_prompt_callback)
|
||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (item != NULL)
|
||||||
|
cmdq_continue(item);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,9 +229,14 @@ static void
|
|||||||
cmd_command_prompt_free(void *data)
|
cmd_command_prompt_free(void *data)
|
||||||
{
|
{
|
||||||
struct cmd_command_prompt_cdata *cdata = data;
|
struct cmd_command_prompt_cdata *cdata = data;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
free(cdata->inputs);
|
for (i = 0; i < cdata->count; i++) {
|
||||||
|
free(cdata->prompts[i].prompt);
|
||||||
|
free(cdata->prompts[i].input);
|
||||||
|
}
|
||||||
free(cdata->prompts);
|
free(cdata->prompts);
|
||||||
free(cdata->template);
|
cmd_free_argv(cdata->argc, cdata->argv);
|
||||||
|
args_make_commands_free(cdata->state);
|
||||||
free(cdata);
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,106 +28,128 @@
|
|||||||
* Asks for confirmation before executing a command.
|
* Asks for confirmation before executing a command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static enum cmd_retval cmd_confirm_before_exec(struct cmd *,
|
static enum args_parse_type cmd_confirm_before_args_parse(struct args *,
|
||||||
struct cmdq_item *);
|
u_int, char **);
|
||||||
|
static enum cmd_retval cmd_confirm_before_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
static int cmd_confirm_before_callback(void *, const char *, int);
|
static int cmd_confirm_before_callback(struct client *, void *,
|
||||||
|
const char *, int);
|
||||||
static void cmd_confirm_before_free(void *);
|
static void cmd_confirm_before_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_confirm_before_entry = {
|
const struct cmd_entry cmd_confirm_before_entry = {
|
||||||
.name = "confirm-before",
|
.name = "confirm-before",
|
||||||
.alias = "confirm",
|
.alias = "confirm",
|
||||||
|
|
||||||
.args = { "p:t:", 1, 1 },
|
.args = { "bc:p:t:y", 1, 1, cmd_confirm_before_args_parse },
|
||||||
.usage = "[-p prompt] " CMD_TARGET_CLIENT_USAGE " command",
|
.usage = "[-by] [-c confirm_key] [-p prompt] " CMD_TARGET_CLIENT_USAGE
|
||||||
|
" command",
|
||||||
|
|
||||||
.flags = 0,
|
.flags = CMD_CLIENT_TFLAG,
|
||||||
.exec = cmd_confirm_before_exec
|
.exec = cmd_confirm_before_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_confirm_before_data {
|
struct cmd_confirm_before_data {
|
||||||
char *cmd;
|
struct cmdq_item *item;
|
||||||
struct client *client;
|
struct cmd_list *cmdlist;
|
||||||
|
u_char confirm_key;
|
||||||
|
int default_yes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static enum args_parse_type
|
||||||
|
cmd_confirm_before_args_parse(__unused struct args *args, __unused u_int idx,
|
||||||
|
__unused char **cause)
|
||||||
|
{
|
||||||
|
return (ARGS_PARSE_COMMANDS_OR_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct cmd_confirm_before_data *cdata;
|
struct cmd_confirm_before_data *cdata;
|
||||||
struct client *c;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
char *cmd, *copy, *new_prompt, *ptr;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
const char *prompt;
|
char *new_prompt;
|
||||||
|
const char *confirm_key, *prompt, *cmd;
|
||||||
|
int wait = !args_has(args, 'b');
|
||||||
|
|
||||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
|
cdata->cmdlist = args_make_commands_now(self, item, 0, 1);
|
||||||
|
if (cdata->cmdlist == NULL) {
|
||||||
|
free(cdata);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wait)
|
||||||
|
cdata->item = item;
|
||||||
|
|
||||||
|
cdata->default_yes = args_has(args, 'y');
|
||||||
|
if ((confirm_key = args_get(args, 'c')) != NULL) {
|
||||||
|
if (confirm_key[1] == '\0' &&
|
||||||
|
confirm_key[0] > 31 &&
|
||||||
|
confirm_key[0] < 127)
|
||||||
|
cdata->confirm_key = confirm_key[0];
|
||||||
|
else {
|
||||||
|
cmdq_error(item, "invalid confirm key");
|
||||||
|
free(cdata);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cdata->confirm_key = 'y';
|
||||||
|
|
||||||
if ((prompt = args_get(args, 'p')) != NULL)
|
if ((prompt = args_get(args, 'p')) != NULL)
|
||||||
xasprintf(&new_prompt, "%s ", prompt);
|
xasprintf(&new_prompt, "%s ", prompt);
|
||||||
else {
|
else {
|
||||||
ptr = copy = xstrdup(args->argv[0]);
|
cmd = cmd_get_entry(cmd_list_first(cdata->cmdlist))->name;
|
||||||
cmd = strsep(&ptr, " \t");
|
xasprintf(&new_prompt, "Confirm '%s'? (%c/n) ", cmd,
|
||||||
xasprintf(&new_prompt, "Confirm '%s'? (y/n) ", cmd);
|
cdata->confirm_key);
|
||||||
free(copy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
status_prompt_set(tc, target, new_prompt, NULL,
|
||||||
cdata->cmd = xstrdup(args->argv[0]);
|
|
||||||
|
|
||||||
cdata->client = c;
|
|
||||||
cdata->client->references++;
|
|
||||||
|
|
||||||
status_prompt_set(c, new_prompt, NULL,
|
|
||||||
cmd_confirm_before_callback, cmd_confirm_before_free, cdata,
|
cmd_confirm_before_callback, cmd_confirm_before_free, cdata,
|
||||||
PROMPT_SINGLE);
|
PROMPT_SINGLE, PROMPT_TYPE_COMMAND);
|
||||||
|
|
||||||
free(new_prompt);
|
free(new_prompt);
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum cmd_retval
|
if (!wait)
|
||||||
cmd_confirm_before_error(struct cmdq_item *item, void *data)
|
return (CMD_RETURN_NORMAL);
|
||||||
{
|
return (CMD_RETURN_WAIT);
|
||||||
char *error = data;
|
|
||||||
|
|
||||||
cmdq_error(item, "%s", error);
|
|
||||||
free(error);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cmd_confirm_before_callback(void *data, const char *s, __unused int done)
|
cmd_confirm_before_callback(struct client *c, void *data, const char *s,
|
||||||
|
__unused int done)
|
||||||
{
|
{
|
||||||
struct cmd_confirm_before_data *cdata = data;
|
struct cmd_confirm_before_data *cdata = data;
|
||||||
struct client *c = cdata->client;
|
struct cmdq_item *item = cdata->item, *new_item;
|
||||||
struct cmd_list *cmdlist;
|
int retcode = 1;
|
||||||
struct cmdq_item *new_item;
|
|
||||||
char *cause;
|
|
||||||
|
|
||||||
if (c->flags & CLIENT_DEAD)
|
if (c->flags & CLIENT_DEAD)
|
||||||
return (0);
|
goto out;
|
||||||
|
|
||||||
if (s == NULL || *s == '\0')
|
if (s == NULL)
|
||||||
return (0);
|
goto out;
|
||||||
if (tolower((u_char) s[0]) != 'y' || s[1] != '\0')
|
if (s[0] != cdata->confirm_key && (s[0] != '\0' || !cdata->default_yes))
|
||||||
return (0);
|
goto out;
|
||||||
|
retcode = 0;
|
||||||
|
|
||||||
cmdlist = cmd_string_parse(cdata->cmd, NULL, 0, &cause);
|
if (item == NULL) {
|
||||||
if (cmdlist == NULL) {
|
new_item = cmdq_get_command(cdata->cmdlist, NULL);
|
||||||
if (cause != NULL) {
|
cmdq_append(c, new_item);
|
||||||
new_item = cmdq_get_callback(cmd_confirm_before_error,
|
|
||||||
cause);
|
|
||||||
} else
|
|
||||||
new_item = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
|
new_item = cmdq_get_command(cdata->cmdlist,
|
||||||
cmd_list_free(cmdlist);
|
cmdq_get_state(item));
|
||||||
|
cmdq_insert_after(item, new_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_item != NULL)
|
out:
|
||||||
cmdq_append(c, new_item);
|
if (item != NULL) {
|
||||||
|
if (cmdq_get_client(item) != NULL &&
|
||||||
|
cmdq_get_client(item)->session == NULL)
|
||||||
|
cmdq_get_client(item)->retval = retcode;
|
||||||
|
cmdq_continue(item);
|
||||||
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,10 +157,7 @@ static void
|
|||||||
cmd_confirm_before_free(void *data)
|
cmd_confirm_before_free(void *data)
|
||||||
{
|
{
|
||||||
struct cmd_confirm_before_data *cdata = data;
|
struct cmd_confirm_before_data *cdata = data;
|
||||||
struct client *c = cdata->client;
|
|
||||||
|
|
||||||
server_client_unref(c);
|
cmd_list_free(cdata->cmdlist);
|
||||||
|
|
||||||
free(cdata->cmd);
|
|
||||||
free(cdata);
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,10 @@ const struct cmd_entry cmd_copy_mode_entry = {
|
|||||||
.name = "copy-mode",
|
.name = "copy-mode",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "Met:u", 0, 0 },
|
.args = { "deHMs:t:uq", 0, 0, NULL },
|
||||||
.usage = "[-Mu] " CMD_TARGET_PANE_USAGE,
|
.usage = "[-deHMuq] [-s src-pane] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
|
.source = { 's', CMD_FIND_PANE, 0 },
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
@@ -43,7 +44,7 @@ const struct cmd_entry cmd_clock_mode_entry = {
|
|||||||
.name = "clock-mode",
|
.name = "clock-mode",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "t:", 0, 0 },
|
.args = { "t:", 0, 0, NULL },
|
||||||
.usage = CMD_TARGET_PANE_USAGE,
|
.usage = CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
@@ -55,36 +56,43 @@ const struct cmd_entry cmd_clock_mode_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct cmdq_shared *shared = item->shared;
|
struct key_event *event = cmdq_get_event(item);
|
||||||
struct client *c = item->client;
|
struct cmd_find_state *source = cmdq_get_source(item);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct client *c = cmdq_get_client(item);
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct window_pane *wp = item->target.wp;
|
struct window_pane *wp = target->wp, *swp;
|
||||||
|
|
||||||
|
if (args_has(args, 'q')) {
|
||||||
|
window_pane_reset_mode_all(wp);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (args_has(args, 'M')) {
|
if (args_has(args, 'M')) {
|
||||||
if ((wp = cmd_mouse_pane(&shared->mouse, &s, NULL)) == NULL)
|
if ((wp = cmd_mouse_pane(&event->m, &s, NULL)) == NULL)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
if (c == NULL || c->session != s)
|
if (c == NULL || c->session != s)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->entry == &cmd_clock_mode_entry) {
|
if (cmd_get_entry(self) == &cmd_clock_mode_entry) {
|
||||||
window_pane_set_mode(wp, &window_clock_mode);
|
window_pane_set_mode(wp, NULL, &window_clock_mode, NULL, NULL);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wp->mode != &window_copy_mode) {
|
if (args_has(args, 's'))
|
||||||
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
swp = source->wp;
|
||||||
return (CMD_RETURN_NORMAL);
|
else
|
||||||
window_copy_init_from_pane(wp, args_has(self->args, 'e'));
|
swp = wp;
|
||||||
|
if (!window_pane_set_mode(wp, swp, &window_copy_mode, NULL, args)) {
|
||||||
|
if (args_has(args, 'M'))
|
||||||
|
window_copy_start_drag(c, &event->m);
|
||||||
}
|
}
|
||||||
if (args_has(args, 'M')) {
|
if (args_has(args, 'u'))
|
||||||
if (wp->mode != NULL && wp->mode != &window_copy_mode)
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
window_copy_start_drag(c, &shared->mouse);
|
|
||||||
}
|
|
||||||
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
|
|
||||||
window_copy_pageup(wp, 0);
|
window_copy_pageup(wp, 0);
|
||||||
|
if (args_has(args, 'd'))
|
||||||
|
window_copy_pagedown(wp, 0, args_has(args, 'e'));
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ const struct cmd_entry cmd_detach_client_entry = {
|
|||||||
.name = "detach-client",
|
.name = "detach-client",
|
||||||
.alias = "detach",
|
.alias = "detach",
|
||||||
|
|
||||||
.args = { "aE:s:t:P", 0, 0 },
|
.args = { "aE:s:t:P", 0, 0, NULL },
|
||||||
.usage = "[-aP] [-E shell-command] "
|
.usage = "[-aP] [-E shell-command] "
|
||||||
"[-s target-session] " CMD_TARGET_CLIENT_USAGE,
|
"[-s target-session] " CMD_TARGET_CLIENT_USAGE,
|
||||||
|
|
||||||
.source = { 's', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
.source = { 's', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
.flags = CMD_READONLY,
|
.flags = CMD_READONLY|CMD_CLIENT_TFLAG,
|
||||||
.exec = cmd_detach_client_exec
|
.exec = cmd_detach_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -47,27 +47,25 @@ const struct cmd_entry cmd_suspend_client_entry = {
|
|||||||
.name = "suspend-client",
|
.name = "suspend-client",
|
||||||
.alias = "suspendc",
|
.alias = "suspendc",
|
||||||
|
|
||||||
.args = { "t:", 0, 0 },
|
.args = { "t:", 0, 0, NULL },
|
||||||
.usage = CMD_TARGET_CLIENT_USAGE,
|
.usage = CMD_TARGET_CLIENT_USAGE,
|
||||||
|
|
||||||
.flags = 0,
|
.flags = CMD_CLIENT_TFLAG,
|
||||||
.exec = cmd_detach_client_exec
|
.exec = cmd_detach_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct client *c, *cloop;
|
struct cmd_find_state *source = cmdq_get_source(item);
|
||||||
struct session *s;
|
struct client *tc = cmdq_get_target_client(item), *loop;
|
||||||
enum msgtype msgtype;
|
struct session *s;
|
||||||
const char *cmd = args_get(args, 'E');
|
enum msgtype msgtype;
|
||||||
|
const char *cmd = args_get(args, 'E');
|
||||||
|
|
||||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
if (cmd_get_entry(self) == &cmd_suspend_client_entry) {
|
||||||
return (CMD_RETURN_ERROR);
|
server_client_suspend(tc);
|
||||||
|
|
||||||
if (self->entry == &cmd_suspend_client_entry) {
|
|
||||||
server_client_suspend(c);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,35 +75,35 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
msgtype = MSG_DETACH;
|
msgtype = MSG_DETACH;
|
||||||
|
|
||||||
if (args_has(args, 's')) {
|
if (args_has(args, 's')) {
|
||||||
s = item->source.s;
|
s = source->s;
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
TAILQ_FOREACH(cloop, &clients, entry) {
|
TAILQ_FOREACH(loop, &clients, entry) {
|
||||||
if (cloop->session == s) {
|
if (loop->session == s) {
|
||||||
if (cmd != NULL)
|
if (cmd != NULL)
|
||||||
server_client_exec(cloop, cmd);
|
server_client_exec(loop, cmd);
|
||||||
else
|
else
|
||||||
server_client_detach(cloop, msgtype);
|
server_client_detach(loop, msgtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (CMD_RETURN_STOP);
|
return (CMD_RETURN_STOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
TAILQ_FOREACH(cloop, &clients, entry) {
|
TAILQ_FOREACH(loop, &clients, entry) {
|
||||||
if (cloop->session != NULL && cloop != c) {
|
if (loop->session != NULL && loop != tc) {
|
||||||
if (cmd != NULL)
|
if (cmd != NULL)
|
||||||
server_client_exec(cloop, cmd);
|
server_client_exec(loop, cmd);
|
||||||
else
|
else
|
||||||
server_client_detach(cloop, msgtype);
|
server_client_detach(loop, msgtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd != NULL)
|
if (cmd != NULL)
|
||||||
server_client_exec(c, cmd);
|
server_client_exec(tc, cmd);
|
||||||
else
|
else
|
||||||
server_client_detach(c, msgtype);
|
server_client_detach(tc, msgtype);
|
||||||
return (CMD_RETURN_STOP);
|
return (CMD_RETURN_STOP);
|
||||||
}
|
}
|
||||||
|
|||||||
502
cmd-display-menu.c
Normal file
502
cmd-display-menu.c
Normal file
@@ -0,0 +1,502 @@
|
|||||||
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display a menu on a client.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static enum args_parse_type cmd_display_menu_args_parse(struct args *,
|
||||||
|
u_int, char **);
|
||||||
|
static enum cmd_retval cmd_display_menu_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
static enum cmd_retval cmd_display_popup_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_display_menu_entry = {
|
||||||
|
.name = "display-menu",
|
||||||
|
.alias = "menu",
|
||||||
|
|
||||||
|
.args = { "b:c:C:H:s:S:MOt:T:x:y:", 1, -1, cmd_display_menu_args_parse },
|
||||||
|
.usage = "[-MO] [-b border-lines] [-c target-client] "
|
||||||
|
"[-C starting-choice] [-H selected-style] [-s style] "
|
||||||
|
"[-S border-style] " CMD_TARGET_PANE_USAGE "[-T title] "
|
||||||
|
"[-x position] [-y position] name key command ...",
|
||||||
|
|
||||||
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK|CMD_CLIENT_CFLAG,
|
||||||
|
.exec = cmd_display_menu_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_display_popup_entry = {
|
||||||
|
.name = "display-popup",
|
||||||
|
.alias = "popup",
|
||||||
|
|
||||||
|
.args = { "Bb:Cc:d:e:Eh:s:S:t:T:w:x:y:", 0, -1, NULL },
|
||||||
|
.usage = "[-BCE] [-b border-lines] [-c target-client] "
|
||||||
|
"[-d start-directory] [-e environment] [-h height] "
|
||||||
|
"[-s style] [-S border-style] " CMD_TARGET_PANE_USAGE
|
||||||
|
"[-T title] [-w width] [-x position] [-y position] "
|
||||||
|
"[shell-command]",
|
||||||
|
|
||||||
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK|CMD_CLIENT_CFLAG,
|
||||||
|
.exec = cmd_display_popup_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum args_parse_type
|
||||||
|
cmd_display_menu_args_parse(struct args *args, u_int idx, __unused char **cause)
|
||||||
|
{
|
||||||
|
u_int i = 0;
|
||||||
|
enum args_parse_type type = ARGS_PARSE_STRING;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
type = ARGS_PARSE_STRING;
|
||||||
|
if (i == idx)
|
||||||
|
break;
|
||||||
|
if (*args_string(args, i++) == '\0')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
type = ARGS_PARSE_STRING;
|
||||||
|
if (i++ == idx)
|
||||||
|
break;
|
||||||
|
|
||||||
|
type = ARGS_PARSE_COMMANDS_OR_STRING;
|
||||||
|
if (i++ == idx)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return (type);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
|
||||||
|
struct args *args, u_int *px, u_int *py, u_int w, u_int h)
|
||||||
|
{
|
||||||
|
struct tty *tty = &tc->tty;
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct key_event *event = cmdq_get_event(item);
|
||||||
|
struct session *s = tc->session;
|
||||||
|
struct winlink *wl = target->wl;
|
||||||
|
struct window_pane *wp = target->wp;
|
||||||
|
struct style_ranges *ranges = NULL;
|
||||||
|
struct style_range *sr = NULL;
|
||||||
|
const char *xp, *yp;
|
||||||
|
char *p;
|
||||||
|
int top;
|
||||||
|
u_int line, ox, oy, sx, sy, lines, position;
|
||||||
|
long n;
|
||||||
|
struct format_tree *ft;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Work out the position from the -x and -y arguments. This is the
|
||||||
|
* bottom-left position.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* If the popup is too big, stop now. */
|
||||||
|
if (w > tty->sx || h > tty->sy)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
/* Create format with mouse position if any. */
|
||||||
|
ft = format_create_from_target(item);
|
||||||
|
if (event->m.valid) {
|
||||||
|
format_add(ft, "popup_mouse_x", "%u", event->m.x);
|
||||||
|
format_add(ft, "popup_mouse_y", "%u", event->m.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there are any status lines, add this window position and the
|
||||||
|
* status line position.
|
||||||
|
*/
|
||||||
|
top = status_at_line(tc);
|
||||||
|
if (top != -1) {
|
||||||
|
lines = status_line_size(tc);
|
||||||
|
if (top == 0)
|
||||||
|
top = lines;
|
||||||
|
else
|
||||||
|
top = 0;
|
||||||
|
position = options_get_number(s->options, "status-position");
|
||||||
|
|
||||||
|
for (line = 0; line < lines; line++) {
|
||||||
|
ranges = &tc->status.entries[line].ranges;
|
||||||
|
TAILQ_FOREACH(sr, ranges, entry) {
|
||||||
|
if (sr->type != STYLE_RANGE_WINDOW)
|
||||||
|
continue;
|
||||||
|
if (sr->argument == (u_int)wl->idx)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (sr != NULL)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sr != NULL) {
|
||||||
|
format_add(ft, "popup_window_status_line_x", "%u",
|
||||||
|
sr->start);
|
||||||
|
if (position == 0) {
|
||||||
|
format_add(ft, "popup_window_status_line_y",
|
||||||
|
"%u", line + 1 + h);
|
||||||
|
} else {
|
||||||
|
format_add(ft, "popup_window_status_line_y",
|
||||||
|
"%u", tty->sy - lines + line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position == 0)
|
||||||
|
format_add(ft, "popup_status_line_y", "%u", lines + h);
|
||||||
|
else {
|
||||||
|
format_add(ft, "popup_status_line_y", "%u",
|
||||||
|
tty->sy - lines);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
top = 0;
|
||||||
|
|
||||||
|
/* Popup width and height. */
|
||||||
|
format_add(ft, "popup_width", "%u", w);
|
||||||
|
format_add(ft, "popup_height", "%u", h);
|
||||||
|
|
||||||
|
/* Position so popup is in the centre. */
|
||||||
|
n = (long)(tty->sx - 1) / 2 - w / 2;
|
||||||
|
if (n < 0)
|
||||||
|
format_add(ft, "popup_centre_x", "%u", 0);
|
||||||
|
else
|
||||||
|
format_add(ft, "popup_centre_x", "%ld", n);
|
||||||
|
n = (tty->sy - 1) / 2 + h / 2;
|
||||||
|
if (n >= tty->sy)
|
||||||
|
format_add(ft, "popup_centre_y", "%u", tty->sy - h);
|
||||||
|
else
|
||||||
|
format_add(ft, "popup_centre_y", "%ld", n);
|
||||||
|
|
||||||
|
/* Position of popup relative to mouse. */
|
||||||
|
if (event->m.valid) {
|
||||||
|
n = (long)event->m.x - w / 2;
|
||||||
|
if (n < 0)
|
||||||
|
format_add(ft, "popup_mouse_centre_x", "%u", 0);
|
||||||
|
else
|
||||||
|
format_add(ft, "popup_mouse_centre_x", "%ld", n);
|
||||||
|
n = event->m.y - h / 2;
|
||||||
|
if (n + h >= tty->sy) {
|
||||||
|
format_add(ft, "popup_mouse_centre_y", "%u",
|
||||||
|
tty->sy - h);
|
||||||
|
} else
|
||||||
|
format_add(ft, "popup_mouse_centre_y", "%ld", n);
|
||||||
|
n = (long)event->m.y + h;
|
||||||
|
if (n >= tty->sy)
|
||||||
|
format_add(ft, "popup_mouse_top", "%u", tty->sy - 1);
|
||||||
|
else
|
||||||
|
format_add(ft, "popup_mouse_top", "%ld", n);
|
||||||
|
n = event->m.y - h;
|
||||||
|
if (n < 0)
|
||||||
|
format_add(ft, "popup_mouse_bottom", "%u", 0);
|
||||||
|
else
|
||||||
|
format_add(ft, "popup_mouse_bottom", "%ld", n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Position in pane. */
|
||||||
|
tty_window_offset(&tc->tty, &ox, &oy, &sx, &sy);
|
||||||
|
n = top + wp->yoff - oy + h;
|
||||||
|
if (n >= tty->sy)
|
||||||
|
format_add(ft, "popup_pane_top", "%u", tty->sy - h);
|
||||||
|
else
|
||||||
|
format_add(ft, "popup_pane_top", "%ld", n);
|
||||||
|
format_add(ft, "popup_pane_bottom", "%u", top + wp->yoff + wp->sy - oy);
|
||||||
|
format_add(ft, "popup_pane_left", "%u", wp->xoff - ox);
|
||||||
|
n = (long)wp->xoff + wp->sx - ox - w;
|
||||||
|
if (n < 0)
|
||||||
|
format_add(ft, "popup_pane_right", "%u", 0);
|
||||||
|
else
|
||||||
|
format_add(ft, "popup_pane_right", "%ld", n);
|
||||||
|
|
||||||
|
/* Expand horizontal position. */
|
||||||
|
xp = args_get(args, 'x');
|
||||||
|
if (xp == NULL || strcmp(xp, "C") == 0)
|
||||||
|
xp = "#{popup_centre_x}";
|
||||||
|
else if (strcmp(xp, "R") == 0)
|
||||||
|
xp = "#{popup_pane_right}";
|
||||||
|
else if (strcmp(xp, "P") == 0)
|
||||||
|
xp = "#{popup_pane_left}";
|
||||||
|
else if (strcmp(xp, "M") == 0)
|
||||||
|
xp = "#{popup_mouse_centre_x}";
|
||||||
|
else if (strcmp(xp, "W") == 0)
|
||||||
|
xp = "#{popup_window_status_line_x}";
|
||||||
|
p = format_expand(ft, xp);
|
||||||
|
n = strtol(p, NULL, 10);
|
||||||
|
if (n + w >= tty->sx)
|
||||||
|
n = tty->sx - w;
|
||||||
|
else if (n < 0)
|
||||||
|
n = 0;
|
||||||
|
*px = n;
|
||||||
|
log_debug("%s: -x: %s = %s = %u (-w %u)", __func__, xp, p, *px, w);
|
||||||
|
free(p);
|
||||||
|
|
||||||
|
/* Expand vertical position */
|
||||||
|
yp = args_get(args, 'y');
|
||||||
|
if (yp == NULL || strcmp(yp, "C") == 0)
|
||||||
|
yp = "#{popup_centre_y}";
|
||||||
|
else if (strcmp(yp, "P") == 0)
|
||||||
|
yp = "#{popup_pane_bottom}";
|
||||||
|
else if (strcmp(yp, "M") == 0)
|
||||||
|
yp = "#{popup_mouse_top}";
|
||||||
|
else if (strcmp(yp, "S") == 0)
|
||||||
|
yp = "#{popup_status_line_y}";
|
||||||
|
else if (strcmp(yp, "W") == 0)
|
||||||
|
yp = "#{popup_window_status_line_y}";
|
||||||
|
p = format_expand(ft, yp);
|
||||||
|
n = strtol(p, NULL, 10);
|
||||||
|
if (n < h)
|
||||||
|
n = 0;
|
||||||
|
else
|
||||||
|
n -= h;
|
||||||
|
if (n + h >= tty->sy)
|
||||||
|
n = tty->sy - h;
|
||||||
|
else if (n < 0)
|
||||||
|
n = 0;
|
||||||
|
*py = n;
|
||||||
|
log_debug("%s: -y: %s = %s = %u (-h %u)", __func__, yp, p, *py, h);
|
||||||
|
free(p);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct key_event *event = cmdq_get_event(item);
|
||||||
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
|
struct menu *menu = NULL;
|
||||||
|
struct menu_item menu_item;
|
||||||
|
const char *key, *name, *value;
|
||||||
|
const char *style = args_get(args, 's');
|
||||||
|
const char *border_style = args_get(args, 'S');
|
||||||
|
const char *selected_style = args_get(args, 'H');
|
||||||
|
enum box_lines lines = BOX_LINES_DEFAULT;
|
||||||
|
char *title, *cause;
|
||||||
|
int flags = 0, starting_choice = 0;
|
||||||
|
u_int px, py, i, count = args_count(args);
|
||||||
|
struct options *o = target->s->curw->window->options;
|
||||||
|
struct options_entry *oe;
|
||||||
|
|
||||||
|
|
||||||
|
if (tc->overlay_draw != NULL)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
if (args_has(args, 'C')) {
|
||||||
|
if (strcmp(args_get(args, 'C'), "-") == 0)
|
||||||
|
starting_choice = -1;
|
||||||
|
else {
|
||||||
|
starting_choice = args_strtonum(args, 'C', 0, UINT_MAX,
|
||||||
|
&cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "starting choice %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'T'))
|
||||||
|
title = format_single_from_target(item, args_get(args, 'T'));
|
||||||
|
else
|
||||||
|
title = xstrdup("");
|
||||||
|
menu = menu_create(title);
|
||||||
|
free(title);
|
||||||
|
|
||||||
|
for (i = 0; i != count; /* nothing */) {
|
||||||
|
name = args_string(args, i++);
|
||||||
|
if (*name == '\0') {
|
||||||
|
menu_add_item(menu, NULL, item, tc, target);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count - i < 2) {
|
||||||
|
cmdq_error(item, "not enough arguments");
|
||||||
|
menu_free(menu);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
key = args_string(args, i++);
|
||||||
|
|
||||||
|
menu_item.name = name;
|
||||||
|
menu_item.key = key_string_lookup_string(key);
|
||||||
|
menu_item.command = args_string(args, i++);
|
||||||
|
|
||||||
|
menu_add_item(menu, &menu_item, item, tc, target);
|
||||||
|
}
|
||||||
|
if (menu == NULL) {
|
||||||
|
cmdq_error(item, "invalid menu arguments");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (menu->count == 0) {
|
||||||
|
menu_free(menu);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
if (!cmd_display_menu_get_position(tc, item, args, &px, &py,
|
||||||
|
menu->width + 4, menu->count + 2)) {
|
||||||
|
menu_free(menu);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = args_get(args, 'b');
|
||||||
|
if (value != NULL) {
|
||||||
|
oe = options_get(o, "menu-border-lines");
|
||||||
|
lines = options_find_choice(options_table_entry(oe), value,
|
||||||
|
&cause);
|
||||||
|
if (lines == -1) {
|
||||||
|
cmdq_error(item, "menu-border-lines %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'O'))
|
||||||
|
flags |= MENU_STAYOPEN;
|
||||||
|
if (!event->m.valid && !args_has(args, 'M'))
|
||||||
|
flags |= MENU_NOMOUSE;
|
||||||
|
if (menu_display(menu, flags, starting_choice, item, px, py, tc, lines,
|
||||||
|
style, selected_style, border_style, target, NULL, NULL) != 0)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
return (CMD_RETURN_WAIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct session *s = target->s;
|
||||||
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
|
struct tty *tty = &tc->tty;
|
||||||
|
const char *value, *shell, *shellcmd = NULL;
|
||||||
|
const char *style = args_get(args, 's');
|
||||||
|
const char *border_style = args_get(args, 'S');
|
||||||
|
char *cwd, *cause = NULL, **argv = NULL, *title;
|
||||||
|
int flags = 0, argc = 0;
|
||||||
|
enum box_lines lines = BOX_LINES_DEFAULT;
|
||||||
|
u_int px, py, w, h, count = args_count(args);
|
||||||
|
struct args_value *av;
|
||||||
|
struct environ *env = NULL;
|
||||||
|
struct options *o = s->curw->window->options;
|
||||||
|
struct options_entry *oe;
|
||||||
|
|
||||||
|
if (args_has(args, 'C')) {
|
||||||
|
server_client_clear_overlay(tc);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
if (tc->overlay_draw != NULL)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
h = tty->sy / 2;
|
||||||
|
if (args_has(args, 'h')) {
|
||||||
|
h = args_percentage(args, 'h', 1, tty->sy, tty->sy, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "height %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
w = tty->sx / 2;
|
||||||
|
if (args_has(args, 'w')) {
|
||||||
|
w = args_percentage(args, 'w', 1, tty->sx, tty->sx, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "width %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (w > tty->sx)
|
||||||
|
w = tty->sx;
|
||||||
|
if (h > tty->sy)
|
||||||
|
h = tty->sy;
|
||||||
|
if (!cmd_display_menu_get_position(tc, item, args, &px, &py, w, h))
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
value = args_get(args, 'b');
|
||||||
|
if (args_has(args, 'B'))
|
||||||
|
lines = BOX_LINES_NONE;
|
||||||
|
else if (value != NULL) {
|
||||||
|
oe = options_get(o, "popup-border-lines");
|
||||||
|
lines = options_find_choice(options_table_entry(oe), value,
|
||||||
|
&cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "popup-border-lines %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
value = args_get(args, 'd');
|
||||||
|
if (value != NULL)
|
||||||
|
cwd = format_single_from_target(item, value);
|
||||||
|
else
|
||||||
|
cwd = xstrdup(server_client_get_cwd(tc, s));
|
||||||
|
if (count == 0)
|
||||||
|
shellcmd = options_get_string(s->options, "default-command");
|
||||||
|
else if (count == 1)
|
||||||
|
shellcmd = args_string(args, 0);
|
||||||
|
if (count <= 1 && (shellcmd == NULL || *shellcmd == '\0')) {
|
||||||
|
shellcmd = NULL;
|
||||||
|
shell = options_get_string(s->options, "default-shell");
|
||||||
|
if (!checkshell(shell))
|
||||||
|
shell = _PATH_BSHELL;
|
||||||
|
cmd_append_argv(&argc, &argv, shell);
|
||||||
|
} else
|
||||||
|
args_to_vector(args, &argc, &argv);
|
||||||
|
|
||||||
|
if (args_has(args, 'e') >= 1) {
|
||||||
|
env = environ_create();
|
||||||
|
av = args_first_value(args, 'e');
|
||||||
|
while (av != NULL) {
|
||||||
|
environ_put(env, av->string, 0);
|
||||||
|
av = args_next_value(av);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'T'))
|
||||||
|
title = format_single_from_target(item, args_get(args, 'T'));
|
||||||
|
else
|
||||||
|
title = xstrdup("");
|
||||||
|
if (args_has(args, 'E') > 1)
|
||||||
|
flags |= POPUP_CLOSEEXITZERO;
|
||||||
|
else if (args_has(args, 'E'))
|
||||||
|
flags |= POPUP_CLOSEEXIT;
|
||||||
|
if (popup_display(flags, lines, item, px, py, w, h, env, shellcmd, argc,
|
||||||
|
argv, cwd, title, tc, s, style, border_style, NULL, NULL) != 0) {
|
||||||
|
cmd_free_argv(argc, argv);
|
||||||
|
if (env != NULL)
|
||||||
|
environ_free(env);
|
||||||
|
free(cwd);
|
||||||
|
free(title);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
if (env != NULL)
|
||||||
|
environ_free(env);
|
||||||
|
free(cwd);
|
||||||
|
free(title);
|
||||||
|
cmd_free_argv(argc, argv);
|
||||||
|
return (CMD_RETURN_WAIT);
|
||||||
|
}
|
||||||
@@ -39,48 +39,118 @@ const struct cmd_entry cmd_display_message_entry = {
|
|||||||
.name = "display-message",
|
.name = "display-message",
|
||||||
.alias = "display",
|
.alias = "display",
|
||||||
|
|
||||||
.args = { "c:pt:F:", 0, 1 },
|
.args = { "ac:d:lINpt:F:v", 0, 1, NULL },
|
||||||
.usage = "[-p] [-c target-client] [-F format] "
|
.usage = "[-aIlNpv] [-c target-client] [-d delay] [-F format] "
|
||||||
CMD_TARGET_PANE_USAGE " [message]",
|
CMD_TARGET_PANE_USAGE " [message]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK|CMD_CLIENT_CFLAG|CMD_CLIENT_CANFAIL,
|
||||||
.exec = cmd_display_message_exec
|
.exec = cmd_display_message_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_display_message_each(const char *key, const char *value, void *arg)
|
||||||
|
{
|
||||||
|
struct cmdq_item *item = arg;
|
||||||
|
|
||||||
|
cmdq_print(item, "%s=%s", key, value);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct client *c;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct session *s = item->target.s;
|
struct client *tc = cmdq_get_target_client(item), *c;
|
||||||
struct winlink *wl = item->target.wl;
|
struct session *s = target->s;
|
||||||
struct window_pane *wp = item->target.wp;
|
struct winlink *wl = target->wl;
|
||||||
|
struct window_pane *wp = target->wp;
|
||||||
const char *template;
|
const char *template;
|
||||||
char *msg;
|
char *msg, *cause;
|
||||||
|
int delay = -1, flags, Nflag = args_has(args, 'N');
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
|
u_int count = args_count(args);
|
||||||
|
struct evbuffer *evb;
|
||||||
|
|
||||||
if (args_has(args, 'F') && args->argc != 0) {
|
if (args_has(args, 'I')) {
|
||||||
|
if (wp == NULL)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
switch (window_pane_start_input(wp, item, &cause)) {
|
||||||
|
case -1:
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
case 1:
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
case 0:
|
||||||
|
return (CMD_RETURN_WAIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'F') && count != 0) {
|
||||||
cmdq_error(item, "only one of -F or argument must be given");
|
cmdq_error(item, "only one of -F or argument must be given");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
c = cmd_find_client(item, args_get(args, 'c'), 1);
|
|
||||||
|
|
||||||
template = args_get(args, 'F');
|
if (args_has(args, 'd')) {
|
||||||
if (args->argc != 0)
|
delay = args_strtonum(args, 'd', 0, UINT_MAX, &cause);
|
||||||
template = args->argv[0];
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "delay %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count != 0)
|
||||||
|
template = args_string(args, 0);
|
||||||
|
else
|
||||||
|
template = args_get(args, 'F');
|
||||||
if (template == NULL)
|
if (template == NULL)
|
||||||
template = DISPLAY_MESSAGE_TEMPLATE;
|
template = DISPLAY_MESSAGE_TEMPLATE;
|
||||||
|
|
||||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
/*
|
||||||
|
* -c is intended to be the client where the message should be
|
||||||
|
* displayed if -p is not given. But it makes sense to use it for the
|
||||||
|
* formats too, assuming it matches the session. If it doesn't, use the
|
||||||
|
* best client for the session.
|
||||||
|
*/
|
||||||
|
if (tc != NULL && tc->session == s)
|
||||||
|
c = tc;
|
||||||
|
else if (s != NULL)
|
||||||
|
c = cmd_find_best_client(s);
|
||||||
|
else
|
||||||
|
c = NULL;
|
||||||
|
if (args_has(args, 'v'))
|
||||||
|
flags = FORMAT_VERBOSE;
|
||||||
|
else
|
||||||
|
flags = 0;
|
||||||
|
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, flags);
|
||||||
format_defaults(ft, c, s, wl, wp);
|
format_defaults(ft, c, s, wl, wp);
|
||||||
|
|
||||||
msg = format_expand_time(ft, template, time(NULL));
|
if (args_has(args, 'a')) {
|
||||||
if (args_has(self->args, 'p'))
|
format_each(ft, cmd_display_message_each, item);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'l'))
|
||||||
|
msg = xstrdup(template);
|
||||||
|
else
|
||||||
|
msg = format_expand_time(ft, template);
|
||||||
|
|
||||||
|
if (cmdq_get_client(item) == NULL)
|
||||||
|
cmdq_error(item, "%s", msg);
|
||||||
|
else if (args_has(args, 'p'))
|
||||||
cmdq_print(item, "%s", msg);
|
cmdq_print(item, "%s", msg);
|
||||||
else if (c != NULL)
|
else if (tc != NULL && (tc->flags & CLIENT_CONTROL)) {
|
||||||
status_message_set(c, "%s", msg);
|
evb = evbuffer_new();
|
||||||
|
if (evb == NULL)
|
||||||
|
fatalx("out of memory");
|
||||||
|
evbuffer_add_printf(evb, "%%message %s", msg);
|
||||||
|
server_client_print(tc, 0, evb);
|
||||||
|
evbuffer_free(evb);
|
||||||
|
} else if (tc != NULL)
|
||||||
|
status_message_set(tc, delay, 0, Nflag, "%s", msg);
|
||||||
free(msg);
|
free(msg);
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -27,90 +27,286 @@
|
|||||||
* Display panes on a client.
|
* Display panes on a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static enum cmd_retval cmd_display_panes_exec(struct cmd *,
|
static enum args_parse_type cmd_display_panes_args_parse(struct args *,
|
||||||
struct cmdq_item *);
|
u_int, char **);
|
||||||
|
static enum cmd_retval cmd_display_panes_exec(struct cmd *,
|
||||||
static void cmd_display_panes_callback(struct client *,
|
struct cmdq_item *);
|
||||||
struct window_pane *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_display_panes_entry = {
|
const struct cmd_entry cmd_display_panes_entry = {
|
||||||
.name = "display-panes",
|
.name = "display-panes",
|
||||||
.alias = "displayp",
|
.alias = "displayp",
|
||||||
|
|
||||||
.args = { "t:", 0, 1 },
|
.args = { "bd:Nt:", 0, 1, cmd_display_panes_args_parse },
|
||||||
.usage = CMD_TARGET_CLIENT_USAGE,
|
.usage = "[-bN] [-d duration] " CMD_TARGET_CLIENT_USAGE " [template]",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG,
|
||||||
.exec = cmd_display_panes_exec
|
.exec = cmd_display_panes_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct cmd_display_panes_data {
|
||||||
|
struct cmdq_item *item;
|
||||||
|
struct args_command_state *state;
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum args_parse_type
|
||||||
|
cmd_display_panes_args_parse(__unused struct args *args, __unused u_int idx,
|
||||||
|
__unused char **cause)
|
||||||
|
{
|
||||||
|
return (ARGS_PARSE_COMMANDS_OR_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_display_panes_draw_pane(struct screen_redraw_ctx *ctx,
|
||||||
|
struct window_pane *wp)
|
||||||
|
{
|
||||||
|
struct client *c = ctx->c;
|
||||||
|
struct tty *tty = &c->tty;
|
||||||
|
struct session *s = c->session;
|
||||||
|
struct options *oo = s->options;
|
||||||
|
struct window *w = wp->window;
|
||||||
|
struct grid_cell fgc, bgc;
|
||||||
|
u_int pane, idx, px, py, i, j, xoff, yoff, sx, sy;
|
||||||
|
int colour, active_colour;
|
||||||
|
char buf[16], lbuf[16], rbuf[16], *ptr;
|
||||||
|
size_t len, llen, rlen;
|
||||||
|
|
||||||
|
if (wp->xoff + wp->sx <= ctx->ox ||
|
||||||
|
wp->xoff >= ctx->ox + ctx->sx ||
|
||||||
|
wp->yoff + wp->sy <= ctx->oy ||
|
||||||
|
wp->yoff >= ctx->oy + ctx->sy)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (wp->xoff >= ctx->ox && wp->xoff + wp->sx <= ctx->ox + ctx->sx) {
|
||||||
|
/* All visible. */
|
||||||
|
xoff = wp->xoff - ctx->ox;
|
||||||
|
sx = wp->sx;
|
||||||
|
} else if (wp->xoff < ctx->ox &&
|
||||||
|
wp->xoff + wp->sx > ctx->ox + ctx->sx) {
|
||||||
|
/* Both left and right not visible. */
|
||||||
|
xoff = 0;
|
||||||
|
sx = ctx->sx;
|
||||||
|
} else if (wp->xoff < ctx->ox) {
|
||||||
|
/* Left not visible. */
|
||||||
|
xoff = 0;
|
||||||
|
sx = wp->sx - (ctx->ox - wp->xoff);
|
||||||
|
} else {
|
||||||
|
/* Right not visible. */
|
||||||
|
xoff = wp->xoff - ctx->ox;
|
||||||
|
sx = wp->sx - xoff;
|
||||||
|
}
|
||||||
|
if (wp->yoff >= ctx->oy && wp->yoff + wp->sy <= ctx->oy + ctx->sy) {
|
||||||
|
/* All visible. */
|
||||||
|
yoff = wp->yoff - ctx->oy;
|
||||||
|
sy = wp->sy;
|
||||||
|
} else if (wp->yoff < ctx->oy &&
|
||||||
|
wp->yoff + wp->sy > ctx->oy + ctx->sy) {
|
||||||
|
/* Both top and bottom not visible. */
|
||||||
|
yoff = 0;
|
||||||
|
sy = ctx->sy;
|
||||||
|
} else if (wp->yoff < ctx->oy) {
|
||||||
|
/* Top not visible. */
|
||||||
|
yoff = 0;
|
||||||
|
sy = wp->sy - (ctx->oy - wp->yoff);
|
||||||
|
} else {
|
||||||
|
/* Bottom not visible. */
|
||||||
|
yoff = wp->yoff - ctx->oy;
|
||||||
|
sy = wp->sy - yoff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx->statustop)
|
||||||
|
yoff += ctx->statuslines;
|
||||||
|
px = sx / 2;
|
||||||
|
py = sy / 2;
|
||||||
|
|
||||||
|
if (window_pane_index(wp, &pane) != 0)
|
||||||
|
fatalx("index not found");
|
||||||
|
len = xsnprintf(buf, sizeof buf, "%u", pane);
|
||||||
|
|
||||||
|
if (sx < len)
|
||||||
|
return;
|
||||||
|
colour = options_get_number(oo, "display-panes-colour");
|
||||||
|
active_colour = options_get_number(oo, "display-panes-active-colour");
|
||||||
|
|
||||||
|
memcpy(&fgc, &grid_default_cell, sizeof fgc);
|
||||||
|
memcpy(&bgc, &grid_default_cell, sizeof bgc);
|
||||||
|
if (w->active == wp) {
|
||||||
|
fgc.fg = active_colour;
|
||||||
|
bgc.bg = active_colour;
|
||||||
|
} else {
|
||||||
|
fgc.fg = colour;
|
||||||
|
bgc.bg = colour;
|
||||||
|
}
|
||||||
|
|
||||||
|
rlen = xsnprintf(rbuf, sizeof rbuf, "%ux%u", wp->sx, wp->sy);
|
||||||
|
if (pane > 9 && pane < 35)
|
||||||
|
llen = xsnprintf(lbuf, sizeof lbuf, "%c", 'a' + (pane - 10));
|
||||||
|
else
|
||||||
|
llen = 0;
|
||||||
|
|
||||||
|
if (sx < len * 6 || sy < 5) {
|
||||||
|
tty_attributes(tty, &fgc, &grid_default_cell, NULL, NULL);
|
||||||
|
if (sx >= len + llen + 1) {
|
||||||
|
len += llen + 1;
|
||||||
|
tty_cursor(tty, xoff + px - len / 2, yoff + py);
|
||||||
|
tty_putn(tty, buf, len, len);
|
||||||
|
tty_putn(tty, " ", 1, 1);
|
||||||
|
tty_putn(tty, lbuf, llen, llen);
|
||||||
|
} else {
|
||||||
|
tty_cursor(tty, xoff + px - len / 2, yoff + py);
|
||||||
|
tty_putn(tty, buf, len, len);
|
||||||
|
}
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
px -= len * 3;
|
||||||
|
py -= 2;
|
||||||
|
|
||||||
|
tty_attributes(tty, &bgc, &grid_default_cell, NULL, NULL);
|
||||||
|
for (ptr = buf; *ptr != '\0'; ptr++) {
|
||||||
|
if (*ptr < '0' || *ptr > '9')
|
||||||
|
continue;
|
||||||
|
idx = *ptr - '0';
|
||||||
|
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
for (i = px; i < px + 5; i++) {
|
||||||
|
tty_cursor(tty, xoff + i, yoff + py + j);
|
||||||
|
if (window_clock_table[idx][j][i - px])
|
||||||
|
tty_putc(tty, ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
px += 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sy <= 6)
|
||||||
|
goto out;
|
||||||
|
tty_attributes(tty, &fgc, &grid_default_cell, NULL, NULL);
|
||||||
|
if (rlen != 0 && sx >= rlen) {
|
||||||
|
tty_cursor(tty, xoff + sx - rlen, yoff);
|
||||||
|
tty_putn(tty, rbuf, rlen, rlen);
|
||||||
|
}
|
||||||
|
if (llen != 0) {
|
||||||
|
tty_cursor(tty, xoff + sx / 2 + len * 3 - llen - 1,
|
||||||
|
yoff + py + 5);
|
||||||
|
tty_putn(tty, lbuf, llen, llen);
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
tty_cursor(tty, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_display_panes_draw(struct client *c, __unused void *data,
|
||||||
|
struct screen_redraw_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct window *w = c->session->curw->window;
|
||||||
|
struct window_pane *wp;
|
||||||
|
|
||||||
|
log_debug("%s: %s @%u", __func__, c->name, w->id);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
|
if (window_pane_visible(wp))
|
||||||
|
cmd_display_panes_draw_pane(ctx, wp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_display_panes_free(__unused struct client *c, void *data)
|
||||||
|
{
|
||||||
|
struct cmd_display_panes_data *cdata = data;
|
||||||
|
|
||||||
|
if (cdata->item != NULL)
|
||||||
|
cmdq_continue(cdata->item);
|
||||||
|
args_make_commands_free(cdata->state);
|
||||||
|
free(cdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmd_display_panes_key(struct client *c, void *data, struct key_event *event)
|
||||||
|
{
|
||||||
|
struct cmd_display_panes_data *cdata = data;
|
||||||
|
char *expanded, *error;
|
||||||
|
struct cmdq_item *item = cdata->item, *new_item;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
struct window *w = c->session->curw->window;
|
||||||
|
struct window_pane *wp;
|
||||||
|
u_int index;
|
||||||
|
key_code key;
|
||||||
|
|
||||||
|
if (event->key >= '0' && event->key <= '9')
|
||||||
|
index = event->key - '0';
|
||||||
|
else if ((event->key & KEYC_MASK_MODIFIERS) == 0) {
|
||||||
|
key = (event->key & KEYC_MASK_KEY);
|
||||||
|
if (key >= 'a' && key <= 'z')
|
||||||
|
index = 10 + (key - 'a');
|
||||||
|
else
|
||||||
|
return (-1);
|
||||||
|
} else
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
wp = window_pane_at_index(w, index);
|
||||||
|
if (wp == NULL)
|
||||||
|
return (1);
|
||||||
|
window_unzoom(w, 1);
|
||||||
|
|
||||||
|
xasprintf(&expanded, "%%%u", wp->id);
|
||||||
|
|
||||||
|
cmdlist = args_make_commands(cdata->state, 1, &expanded, &error);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
|
cmdq_append(c, cmdq_get_error(error));
|
||||||
|
free(error);
|
||||||
|
} else if (item == NULL) {
|
||||||
|
new_item = cmdq_get_command(cmdlist, NULL);
|
||||||
|
cmdq_append(c, new_item);
|
||||||
|
} else {
|
||||||
|
new_item = cmdq_get_command(cmdlist, cmdq_get_state(item));
|
||||||
|
cmdq_insert_after(item, new_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(expanded);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct client *c;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
|
struct session *s = tc->session;
|
||||||
|
u_int delay;
|
||||||
|
char *cause;
|
||||||
|
struct cmd_display_panes_data *cdata;
|
||||||
|
int wait = !args_has(args, 'b');
|
||||||
|
|
||||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
if (tc->overlay_draw != NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (c->identify_callback != NULL)
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
c->identify_callback = cmd_display_panes_callback;
|
if (args_has(args, 'd')) {
|
||||||
if (args->argc != 0)
|
delay = args_strtonum(args, 'd', 0, UINT_MAX, &cause);
|
||||||
c->identify_callback_data = xstrdup(args->argv[0]);
|
|
||||||
else
|
|
||||||
c->identify_callback_data = xstrdup("select-pane -t '%%'");
|
|
||||||
|
|
||||||
server_client_set_identify(c);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum cmd_retval
|
|
||||||
cmd_display_panes_error(struct cmdq_item *item, void *data)
|
|
||||||
{
|
|
||||||
char *error = data;
|
|
||||||
|
|
||||||
cmdq_error(item, "%s", error);
|
|
||||||
free(error);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cmd_display_panes_callback(struct client *c, struct window_pane *wp)
|
|
||||||
{
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmdq_item *new_item;
|
|
||||||
char *template, *cmd, *expanded, *cause;
|
|
||||||
|
|
||||||
template = c->identify_callback_data;
|
|
||||||
if (wp == NULL)
|
|
||||||
goto out;
|
|
||||||
xasprintf(&expanded, "%%%u", wp->id);
|
|
||||||
cmd = cmd_template_replace(template, expanded, 1);
|
|
||||||
|
|
||||||
cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);
|
|
||||||
if (cmdlist == NULL) {
|
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
new_item = cmdq_get_callback(cmd_display_panes_error,
|
cmdq_error(item, "delay %s", cause);
|
||||||
cause);
|
free(cause);
|
||||||
} else
|
return (CMD_RETURN_ERROR);
|
||||||
new_item = NULL;
|
}
|
||||||
|
} else
|
||||||
|
delay = options_get_number(s->options, "display-panes-time");
|
||||||
|
|
||||||
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
|
if (wait)
|
||||||
|
cdata->item = item;
|
||||||
|
cdata->state = args_make_commands_prepare(self, item, 0,
|
||||||
|
"select-pane -t \"%%%\"", wait, 0);
|
||||||
|
|
||||||
|
if (args_has(args, 'N')) {
|
||||||
|
server_client_set_overlay(tc, delay, NULL, NULL,
|
||||||
|
cmd_display_panes_draw, NULL, cmd_display_panes_free, NULL,
|
||||||
|
cdata);
|
||||||
} else {
|
} else {
|
||||||
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
|
server_client_set_overlay(tc, delay, NULL, NULL,
|
||||||
cmd_list_free(cmdlist);
|
cmd_display_panes_draw, cmd_display_panes_key,
|
||||||
|
cmd_display_panes_free, NULL, cdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_item != NULL)
|
if (!wait)
|
||||||
cmdq_append(c, new_item);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
return (CMD_RETURN_WAIT);
|
||||||
free(cmd);
|
|
||||||
free(expanded);
|
|
||||||
|
|
||||||
out:
|
|
||||||
free(c->identify_callback_data);
|
|
||||||
c->identify_callback_data = NULL;
|
|
||||||
c->identify_callback = NULL;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <fnmatch.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -28,216 +26,91 @@
|
|||||||
* Find window containing text.
|
* Find window containing text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define FIND_WINDOW_TEMPLATE \
|
|
||||||
"#{window_index}: #{window_name} " \
|
|
||||||
"[#{window_width}x#{window_height}] " \
|
|
||||||
"(#{window_panes} panes) #{window_find_matches}"
|
|
||||||
|
|
||||||
static enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmdq_item *);
|
static enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
static void cmd_find_window_callback(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 = {
|
||||||
.name = "find-window",
|
.name = "find-window",
|
||||||
.alias = "findw",
|
.alias = "findw",
|
||||||
|
|
||||||
.args = { "F:CNt:T", 1, 4 },
|
.args = { "CiNrt:TZ", 1, 1, NULL },
|
||||||
.usage = "[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string",
|
.usage = "[-CiNrTZ] " CMD_TARGET_PANE_USAGE " match-string",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.exec = cmd_find_window_exec
|
.exec = cmd_find_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_find_window_data {
|
|
||||||
struct winlink *wl;
|
|
||||||
char *list_ctx;
|
|
||||||
u_int pane_id;
|
|
||||||
TAILQ_ENTRY(cmd_find_window_data) entry;
|
|
||||||
};
|
|
||||||
TAILQ_HEAD(cmd_find_window_list, cmd_find_window_data);
|
|
||||||
|
|
||||||
static u_int cmd_find_window_match_flags(struct args *);
|
|
||||||
static void cmd_find_window_match(struct cmd_find_window_list *, int,
|
|
||||||
struct winlink *, const char *, const char *);
|
|
||||||
|
|
||||||
static 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cmd_find_window_match(struct cmd_find_window_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;
|
|
||||||
|
|
||||||
find_data = xcalloc(1, 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;
|
|
||||||
TAILQ_INSERT_TAIL(find_list, find_data, entry);
|
|
||||||
} else
|
|
||||||
free(find_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self), *new_args;
|
||||||
struct cmd_find_state *current = &item->shared->current;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
struct window_pane *wp = target->wp;
|
||||||
struct window_choose_data *cdata;
|
const char *s = args_string(args, 0), *suffix = "";
|
||||||
struct session *s = item->target.s;
|
const char *star = "*";
|
||||||
struct winlink *wl = item->target.wl, *wm;
|
struct args_value *filter;
|
||||||
struct cmd_find_window_list find_list;
|
int C, N, T;
|
||||||
struct cmd_find_window_data *find_data;
|
|
||||||
struct cmd_find_window_data *find_data1;
|
|
||||||
char *str, *searchstr;
|
|
||||||
const char *template;
|
|
||||||
u_int i, match_flags;
|
|
||||||
|
|
||||||
if (c == NULL) {
|
C = args_has(args, 'C');
|
||||||
cmdq_error(item, "no client available");
|
N = args_has(args, 'N');
|
||||||
return (CMD_RETURN_ERROR);
|
T = args_has(args, 'T');
|
||||||
|
|
||||||
|
if (args_has(args, 'r'))
|
||||||
|
star = "";
|
||||||
|
if (args_has(args, 'r') && args_has(args, 'i'))
|
||||||
|
suffix = "/ri";
|
||||||
|
else if (args_has(args, 'r'))
|
||||||
|
suffix = "/r";
|
||||||
|
else if (args_has(args, 'i'))
|
||||||
|
suffix = "/i";
|
||||||
|
|
||||||
|
if (!C && !N && !T)
|
||||||
|
C = N = T = 1;
|
||||||
|
|
||||||
|
filter = xcalloc(1, sizeof *filter);
|
||||||
|
filter->type = ARGS_STRING;
|
||||||
|
|
||||||
|
if (C && N && T) {
|
||||||
|
xasprintf(&filter->string,
|
||||||
|
"#{||:"
|
||||||
|
"#{C%s:%s},#{||:#{m%s:%s%s%s,#{window_name}},"
|
||||||
|
"#{m%s:%s%s%s,#{pane_title}}}}",
|
||||||
|
suffix, s, suffix, star, s, star, suffix, star, s, star);
|
||||||
|
} else if (C && N) {
|
||||||
|
xasprintf(&filter->string,
|
||||||
|
"#{||:#{C%s:%s},#{m%s:%s%s%s,#{window_name}}}",
|
||||||
|
suffix, s, suffix, star, s, star);
|
||||||
|
} else if (C && T) {
|
||||||
|
xasprintf(&filter->string,
|
||||||
|
"#{||:#{C%s:%s},#{m%s:%s%s%s,#{pane_title}}}",
|
||||||
|
suffix, s, suffix, star, s, star);
|
||||||
|
} else if (N && T) {
|
||||||
|
xasprintf(&filter->string,
|
||||||
|
"#{||:#{m%s:%s%s%s,#{window_name}},"
|
||||||
|
"#{m%s:%s%s%s,#{pane_title}}}",
|
||||||
|
suffix, star, s, star, suffix, star, s, star);
|
||||||
|
} else if (C) {
|
||||||
|
xasprintf(&filter->string,
|
||||||
|
"#{C%s:%s}",
|
||||||
|
suffix, s);
|
||||||
|
} else if (N) {
|
||||||
|
xasprintf(&filter->string,
|
||||||
|
"#{m%s:%s%s%s,#{window_name}}",
|
||||||
|
suffix, star, s, star);
|
||||||
|
} else {
|
||||||
|
xasprintf(&filter->string,
|
||||||
|
"#{m%s:%s%s%s,#{pane_title}}",
|
||||||
|
suffix, star, s, star);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
new_args = args_create();
|
||||||
template = FIND_WINDOW_TEMPLATE;
|
if (args_has(args, 'Z'))
|
||||||
|
args_set(new_args, 'Z', NULL, 0);
|
||||||
|
args_set(new_args, 'f', filter, 0);
|
||||||
|
|
||||||
match_flags = cmd_find_window_match_flags(args);
|
window_pane_set_mode(wp, NULL, &window_tree_mode, target, new_args);
|
||||||
str = args->argv[0];
|
args_free(new_args);
|
||||||
|
|
||||||
TAILQ_INIT(&find_list);
|
|
||||||
|
|
||||||
xasprintf(&searchstr, "*%s*", str);
|
|
||||||
RB_FOREACH(wm, winlinks, &s->windows)
|
|
||||||
cmd_find_window_match(&find_list, match_flags, wm, str, searchstr);
|
|
||||||
free(searchstr);
|
|
||||||
|
|
||||||
if (TAILQ_EMPTY(&find_list)) {
|
|
||||||
cmdq_error(item, "no windows matching: %s", str);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TAILQ_NEXT(TAILQ_FIRST(&find_list), entry) == NULL) {
|
|
||||||
if (session_select(s, TAILQ_FIRST(&find_list)->wl->idx) == 0) {
|
|
||||||
cmd_find_from_session(current, s);
|
|
||||||
server_redraw_session(s);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
TAILQ_FOREACH(find_data, &find_list, entry) {
|
|
||||||
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
|
||||||
cdata->idx = find_data->wl->idx;
|
|
||||||
cdata->wl = find_data->wl;
|
|
||||||
|
|
||||||
cdata->ft_template = xstrdup(template);
|
|
||||||
cdata->pane_id = find_data->pane_id;
|
|
||||||
|
|
||||||
format_add(cdata->ft, "line", "%u", i);
|
|
||||||
format_add(cdata->ft, "window_find_matches", "%s",
|
|
||||||
find_data->list_ctx);
|
|
||||||
format_defaults(cdata->ft, NULL, s, find_data->wl, NULL);
|
|
||||||
|
|
||||||
window_choose_add(wl->window->active, cdata);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active, 0, cmd_find_window_callback);
|
|
||||||
|
|
||||||
out:
|
|
||||||
TAILQ_FOREACH_SAFE(find_data, &find_list, entry, find_data1) {
|
|
||||||
free(find_data->list_ctx);
|
|
||||||
TAILQ_REMOVE(&find_list, find_data, entry);
|
|
||||||
free(find_data);
|
|
||||||
}
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
cmd_find_window_callback(struct window_choose_data *cdata)
|
|
||||||
{
|
|
||||||
struct session *s;
|
|
||||||
struct window_pane *wp;
|
|
||||||
|
|
||||||
if (cdata == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
s = cdata->start_session;
|
|
||||||
if (!session_alive(s))
|
|
||||||
return;
|
|
||||||
|
|
||||||
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);
|
|
||||||
recalculate_sizes();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
350
cmd-find.c
350
cmd-find.c
@@ -34,6 +34,7 @@ static int cmd_find_best_winlink_with_window(struct cmd_find_state *);
|
|||||||
|
|
||||||
static const char *cmd_find_map_table(const char *[][2], const char *);
|
static const char *cmd_find_map_table(const char *[][2], const char *);
|
||||||
|
|
||||||
|
static void cmd_find_log_state(const char *, struct cmd_find_state *);
|
||||||
static int cmd_find_get_session(struct cmd_find_state *, const char *);
|
static int cmd_find_get_session(struct cmd_find_state *, const char *);
|
||||||
static int cmd_find_get_window(struct cmd_find_state *, const char *, int);
|
static int cmd_find_get_window(struct cmd_find_state *, const char *, int);
|
||||||
static int cmd_find_get_window_with_session(struct cmd_find_state *,
|
static int cmd_find_get_window_with_session(struct cmd_find_state *,
|
||||||
@@ -74,25 +75,28 @@ static const char *cmd_find_pane_table[][2] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Get session from TMUX if present. */
|
/* Find pane containing client if any. */
|
||||||
static struct session *
|
static struct window_pane *
|
||||||
cmd_find_try_TMUX(struct client *c)
|
cmd_find_inside_pane(struct client *c)
|
||||||
{
|
{
|
||||||
|
struct window_pane *wp;
|
||||||
struct environ_entry *envent;
|
struct environ_entry *envent;
|
||||||
char tmp[256];
|
|
||||||
long long pid;
|
|
||||||
u_int session;
|
|
||||||
|
|
||||||
envent = environ_find(c->environ, "TMUX");
|
if (c == NULL)
|
||||||
if (envent == NULL)
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
if (sscanf(envent->value, "%255[^,],%lld,%d", tmp, &pid, &session) != 3)
|
RB_FOREACH(wp, window_pane_tree, &all_window_panes) {
|
||||||
return (NULL);
|
if (wp->fd != -1 && strcmp(wp->tty, c->ttyname) == 0)
|
||||||
if (pid != getpid())
|
break;
|
||||||
return (NULL);
|
}
|
||||||
log_debug("client %p TMUX %s (session @%u)", c, envent->value, session);
|
if (wp == NULL) {
|
||||||
return (session_find_by_id(session));
|
envent = environ_find(c->environ, "TMUX_PANE");
|
||||||
|
if (envent != NULL)
|
||||||
|
wp = window_pane_find_by_id_str(envent->value);
|
||||||
|
}
|
||||||
|
if (wp != NULL)
|
||||||
|
log_debug("%s: got pane %%%u (%s)", __func__, wp->id, wp->tty);
|
||||||
|
return (wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is this client better? */
|
/* Is this client better? */
|
||||||
@@ -105,12 +109,12 @@ cmd_find_client_better(struct client *c, struct client *than)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Find best client for session. */
|
/* Find best client for session. */
|
||||||
static struct client *
|
struct client *
|
||||||
cmd_find_best_client(struct session *s)
|
cmd_find_best_client(struct session *s)
|
||||||
{
|
{
|
||||||
struct client *c_loop, *c;
|
struct client *c_loop, *c;
|
||||||
|
|
||||||
if (s->flags & SESSION_UNATTACHED)
|
if (s->attached == 0)
|
||||||
s = NULL;
|
s = NULL;
|
||||||
|
|
||||||
c = NULL;
|
c = NULL;
|
||||||
@@ -134,10 +138,10 @@ cmd_find_session_better(struct session *s, struct session *than, int flags)
|
|||||||
if (than == NULL)
|
if (than == NULL)
|
||||||
return (1);
|
return (1);
|
||||||
if (flags & CMD_FIND_PREFER_UNATTACHED) {
|
if (flags & CMD_FIND_PREFER_UNATTACHED) {
|
||||||
attached = (~than->flags & SESSION_UNATTACHED);
|
attached = (than->attached != 0);
|
||||||
if (attached && (s->flags & SESSION_UNATTACHED))
|
if (attached && s->attached == 0)
|
||||||
return (1);
|
return (1);
|
||||||
else if (!attached && (~s->flags & SESSION_UNATTACHED))
|
else if (!attached && s->attached != 0)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
return (timercmp(&s->activity_time, &than->activity_time, >));
|
return (timercmp(&s->activity_time, &than->activity_time, >));
|
||||||
@@ -150,6 +154,8 @@ cmd_find_best_session(struct session **slist, u_int ssize, int flags)
|
|||||||
struct session *s_loop, *s;
|
struct session *s_loop, *s;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
|
log_debug("%s: %u sessions to try", __func__, ssize);
|
||||||
|
|
||||||
s = NULL;
|
s = NULL;
|
||||||
if (slist != NULL) {
|
if (slist != NULL) {
|
||||||
for (i = 0; i < ssize; i++) {
|
for (i = 0; i < ssize; i++) {
|
||||||
@@ -173,6 +179,8 @@ cmd_find_best_session_with_window(struct cmd_find_state *fs)
|
|||||||
u_int ssize;
|
u_int ssize;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
|
log_debug("%s: window is @%u", __func__, fs->w->id);
|
||||||
|
|
||||||
ssize = 0;
|
ssize = 0;
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
if (!session_has(s, fs->w))
|
if (!session_has(s, fs->w))
|
||||||
@@ -194,7 +202,7 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the best winlink for a window (the current if it contains the pane,
|
* Find the best winlink for a window (the current if it contains the window,
|
||||||
* otherwise the first).
|
* otherwise the first).
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
@@ -202,6 +210,8 @@ cmd_find_best_winlink_with_window(struct cmd_find_state *fs)
|
|||||||
{
|
{
|
||||||
struct winlink *wl, *wl_loop;
|
struct winlink *wl, *wl_loop;
|
||||||
|
|
||||||
|
log_debug("%s: window is @%u", __func__, fs->w->id);
|
||||||
|
|
||||||
wl = NULL;
|
wl = NULL;
|
||||||
if (fs->s->curw != NULL && fs->s->curw->window == fs->w)
|
if (fs->s->curw != NULL && fs->s->curw->window == fs->w)
|
||||||
wl = fs->s->curw;
|
wl = fs->s->curw;
|
||||||
@@ -373,7 +383,7 @@ cmd_find_get_window_with_session(struct cmd_find_state *fs, const char *window)
|
|||||||
return (-1);
|
return (-1);
|
||||||
fs->idx = s->curw->idx + n;
|
fs->idx = s->curw->idx + n;
|
||||||
} else {
|
} else {
|
||||||
if (n < s->curw->idx)
|
if (n > s->curw->idx)
|
||||||
return (-1);
|
return (-1);
|
||||||
fs->idx = s->curw->idx - n;
|
fs->idx = s->curw->idx - n;
|
||||||
}
|
}
|
||||||
@@ -420,15 +430,16 @@ cmd_find_get_window_with_session(struct cmd_find_state *fs, const char *window)
|
|||||||
if (window[0] != '+' && window[0] != '-') {
|
if (window[0] != '+' && window[0] != '-') {
|
||||||
idx = strtonum(window, 0, INT_MAX, &errstr);
|
idx = strtonum(window, 0, INT_MAX, &errstr);
|
||||||
if (errstr == NULL) {
|
if (errstr == NULL) {
|
||||||
if (fs->flags & CMD_FIND_WINDOW_INDEX) {
|
|
||||||
fs->idx = idx;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
fs->wl = winlink_find_by_index(&fs->s->windows, idx);
|
fs->wl = winlink_find_by_index(&fs->s->windows, idx);
|
||||||
if (fs->wl != NULL) {
|
if (fs->wl != NULL) {
|
||||||
|
fs->idx = fs->wl->idx;
|
||||||
fs->w = fs->wl->window;
|
fs->w = fs->wl->window;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
if (fs->flags & CMD_FIND_WINDOW_INDEX) {
|
||||||
|
fs->idx = idx;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,7 +504,7 @@ cmd_find_get_pane(struct cmd_find_state *fs, const char *pane, int only)
|
|||||||
/* Check for pane ids starting with %. */
|
/* Check for pane ids starting with %. */
|
||||||
if (*pane == '%') {
|
if (*pane == '%') {
|
||||||
fs->wp = window_pane_find_by_id_str(pane);
|
fs->wp = window_pane_find_by_id_str(pane);
|
||||||
if (fs->wp == NULL || window_pane_outside(fs->wp))
|
if (fs->wp == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
fs->w = fs->wp->window;
|
fs->w = fs->wp->window;
|
||||||
return (cmd_find_best_session_with_window(fs));
|
return (cmd_find_best_session_with_window(fs));
|
||||||
@@ -530,7 +541,7 @@ cmd_find_get_pane_with_session(struct cmd_find_state *fs, const char *pane)
|
|||||||
/* Check for pane ids starting with %. */
|
/* Check for pane ids starting with %. */
|
||||||
if (*pane == '%') {
|
if (*pane == '%') {
|
||||||
fs->wp = window_pane_find_by_id_str(pane);
|
fs->wp = window_pane_find_by_id_str(pane);
|
||||||
if (fs->wp == NULL || window_pane_outside(fs->wp))
|
if (fs->wp == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
fs->w = fs->wp->window;
|
fs->w = fs->wp->window;
|
||||||
return (cmd_find_best_winlink_with_window(fs));
|
return (cmd_find_best_winlink_with_window(fs));
|
||||||
@@ -562,7 +573,7 @@ cmd_find_get_pane_with_window(struct cmd_find_state *fs, const char *pane)
|
|||||||
/* Check for pane ids starting with %. */
|
/* Check for pane ids starting with %. */
|
||||||
if (*pane == '%') {
|
if (*pane == '%') {
|
||||||
fs->wp = window_pane_find_by_id_str(pane);
|
fs->wp = window_pane_find_by_id_str(pane);
|
||||||
if (fs->wp == NULL || window_pane_outside(fs->wp))
|
if (fs->wp == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
if (fs->wp->window != fs->w)
|
if (fs->wp->window != fs->w)
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -571,30 +582,28 @@ cmd_find_get_pane_with_window(struct cmd_find_state *fs, const char *pane)
|
|||||||
|
|
||||||
/* Try special characters. */
|
/* Try special characters. */
|
||||||
if (strcmp(pane, "!") == 0) {
|
if (strcmp(pane, "!") == 0) {
|
||||||
if (fs->w->last == NULL)
|
fs->wp = TAILQ_FIRST(&fs->w->last_panes);
|
||||||
return (-1);
|
if (fs->wp == NULL)
|
||||||
fs->wp = fs->w->last;
|
|
||||||
if (fs->wp == NULL || window_pane_outside(fs->wp))
|
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
} else if (strcmp(pane, "{up-of}") == 0) {
|
} else if (strcmp(pane, "{up-of}") == 0) {
|
||||||
fs->wp = window_pane_find_up(fs->w->active);
|
fs->wp = window_pane_find_up(fs->w->active);
|
||||||
if (fs->wp == NULL || window_pane_outside(fs->wp))
|
if (fs->wp == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
} else if (strcmp(pane, "{down-of}") == 0) {
|
} else if (strcmp(pane, "{down-of}") == 0) {
|
||||||
fs->wp = window_pane_find_down(fs->w->active);
|
fs->wp = window_pane_find_down(fs->w->active);
|
||||||
if (fs->wp == NULL || window_pane_outside(fs->wp))
|
if (fs->wp == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
} else if (strcmp(pane, "{left-of}") == 0) {
|
} else if (strcmp(pane, "{left-of}") == 0) {
|
||||||
fs->wp = window_pane_find_left(fs->w->active);
|
fs->wp = window_pane_find_left(fs->w->active);
|
||||||
if (fs->wp == NULL || window_pane_outside(fs->wp))
|
if (fs->wp == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
} else if (strcmp(pane, "{right-of}") == 0) {
|
} else if (strcmp(pane, "{right-of}") == 0) {
|
||||||
fs->wp = window_pane_find_right(fs->w->active);
|
fs->wp = window_pane_find_right(fs->w->active);
|
||||||
if (fs->wp == NULL || window_pane_outside(fs->wp))
|
if (fs->wp == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -610,7 +619,7 @@ cmd_find_get_pane_with_window(struct cmd_find_state *fs, const char *pane)
|
|||||||
fs->wp = window_pane_next_by_number(fs->w, wp, n);
|
fs->wp = window_pane_next_by_number(fs->w, wp, n);
|
||||||
else
|
else
|
||||||
fs->wp = window_pane_previous_by_number(fs->w, wp, n);
|
fs->wp = window_pane_previous_by_number(fs->w, wp, n);
|
||||||
if (fs->wp != NULL && !window_pane_outside(fs->wp))
|
if (fs->wp != NULL)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -618,13 +627,13 @@ cmd_find_get_pane_with_window(struct cmd_find_state *fs, const char *pane)
|
|||||||
idx = strtonum(pane, 0, INT_MAX, &errstr);
|
idx = strtonum(pane, 0, INT_MAX, &errstr);
|
||||||
if (errstr == NULL) {
|
if (errstr == NULL) {
|
||||||
fs->wp = window_pane_at_index(fs->w, idx);
|
fs->wp = window_pane_at_index(fs->w, idx);
|
||||||
if (fs->wp != NULL && !window_pane_outside(fs->wp))
|
if (fs->wp != NULL)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try as a description. */
|
/* Try as a description. */
|
||||||
fs->wp = window_find_string(fs->w, pane);
|
fs->wp = window_find_string(fs->w, pane);
|
||||||
if (fs->wp != NULL && !window_pane_outside(fs->wp))
|
if (fs->wp != NULL)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -672,9 +681,7 @@ cmd_find_valid_state(struct cmd_find_state *fs)
|
|||||||
if (fs->w != fs->wl->window)
|
if (fs->w != fs->wl->window)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if (!window_has_pane(fs->w, fs->wp))
|
return (window_has_pane(fs->w, fs->wp));
|
||||||
return (0);
|
|
||||||
return (!window_pane_outside(fs->wp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy a state. */
|
/* Copy a state. */
|
||||||
@@ -689,11 +696,11 @@ cmd_find_copy_state(struct cmd_find_state *dst, struct cmd_find_state *src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Log the result. */
|
/* Log the result. */
|
||||||
void
|
static void
|
||||||
cmd_find_log_state(const char *prefix, struct cmd_find_state *fs)
|
cmd_find_log_state(const char *prefix, struct cmd_find_state *fs)
|
||||||
{
|
{
|
||||||
if (fs->s != NULL)
|
if (fs->s != NULL)
|
||||||
log_debug("%s: s=$%u", prefix, fs->s->id);
|
log_debug("%s: s=$%u %s", prefix, fs->s->id, fs->s->name);
|
||||||
else
|
else
|
||||||
log_debug("%s: s=none", prefix);
|
log_debug("%s: s=none", prefix);
|
||||||
if (fs->wl != NULL) {
|
if (fs->wl != NULL) {
|
||||||
@@ -713,9 +720,9 @@ cmd_find_log_state(const char *prefix, struct cmd_find_state *fs)
|
|||||||
|
|
||||||
/* Find state from a session. */
|
/* Find state from a session. */
|
||||||
void
|
void
|
||||||
cmd_find_from_session(struct cmd_find_state *fs, struct session *s)
|
cmd_find_from_session(struct cmd_find_state *fs, struct session *s, int flags)
|
||||||
{
|
{
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
|
|
||||||
fs->s = s;
|
fs->s = s;
|
||||||
fs->wl = fs->s->curw;
|
fs->wl = fs->s->curw;
|
||||||
@@ -727,9 +734,9 @@ cmd_find_from_session(struct cmd_find_state *fs, struct session *s)
|
|||||||
|
|
||||||
/* Find state from a winlink. */
|
/* Find state from a winlink. */
|
||||||
void
|
void
|
||||||
cmd_find_from_winlink(struct cmd_find_state *fs, struct winlink *wl)
|
cmd_find_from_winlink(struct cmd_find_state *fs, struct winlink *wl, int flags)
|
||||||
{
|
{
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
|
|
||||||
fs->s = wl->session;
|
fs->s = wl->session;
|
||||||
fs->wl = wl;
|
fs->wl = wl;
|
||||||
@@ -742,14 +749,14 @@ cmd_find_from_winlink(struct cmd_find_state *fs, struct winlink *wl)
|
|||||||
/* Find state from a session and window. */
|
/* Find state from a session and window. */
|
||||||
int
|
int
|
||||||
cmd_find_from_session_window(struct cmd_find_state *fs, struct session *s,
|
cmd_find_from_session_window(struct cmd_find_state *fs, struct session *s,
|
||||||
struct window *w)
|
struct window *w, int flags)
|
||||||
{
|
{
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
|
|
||||||
fs->s = s;
|
fs->s = s;
|
||||||
fs->w = w;
|
fs->w = w;
|
||||||
if (cmd_find_best_winlink_with_window(fs) != 0) {
|
if (cmd_find_best_winlink_with_window(fs) != 0) {
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
fs->wp = fs->w->active;
|
fs->wp = fs->w->active;
|
||||||
@@ -760,17 +767,17 @@ cmd_find_from_session_window(struct cmd_find_state *fs, struct session *s,
|
|||||||
|
|
||||||
/* Find state from a window. */
|
/* Find state from a window. */
|
||||||
int
|
int
|
||||||
cmd_find_from_window(struct cmd_find_state *fs, struct window *w)
|
cmd_find_from_window(struct cmd_find_state *fs, struct window *w, int flags)
|
||||||
{
|
{
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
|
|
||||||
fs->w = w;
|
fs->w = w;
|
||||||
if (cmd_find_best_session_with_window(fs) != 0) {
|
if (cmd_find_best_session_with_window(fs) != 0) {
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (cmd_find_best_winlink_with_window(fs) != 0) {
|
if (cmd_find_best_winlink_with_window(fs) != 0) {
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
fs->wp = fs->w->active;
|
fs->wp = fs->w->active;
|
||||||
@@ -782,9 +789,9 @@ cmd_find_from_window(struct cmd_find_state *fs, struct window *w)
|
|||||||
/* Find state from a winlink and pane. */
|
/* Find state from a winlink and pane. */
|
||||||
void
|
void
|
||||||
cmd_find_from_winlink_pane(struct cmd_find_state *fs, struct winlink *wl,
|
cmd_find_from_winlink_pane(struct cmd_find_state *fs, struct winlink *wl,
|
||||||
struct window_pane *wp)
|
struct window_pane *wp, int flags)
|
||||||
{
|
{
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
|
|
||||||
fs->s = wl->session;
|
fs->s = wl->session;
|
||||||
fs->wl = wl;
|
fs->wl = wl;
|
||||||
@@ -797,14 +804,10 @@ cmd_find_from_winlink_pane(struct cmd_find_state *fs, struct winlink *wl,
|
|||||||
|
|
||||||
/* Find state from a pane. */
|
/* Find state from a pane. */
|
||||||
int
|
int
|
||||||
cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp)
|
cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp, int flags)
|
||||||
{
|
{
|
||||||
if (cmd_find_from_window(fs, wp->window) != 0)
|
if (cmd_find_from_window(fs, wp->window, flags) != 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
if (window_pane_outside(wp)) {
|
|
||||||
cmd_find_clear_state(fs, 0);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
fs->wp = wp;
|
fs->wp = wp;
|
||||||
|
|
||||||
cmd_find_log_state(__func__, fs);
|
cmd_find_log_state(__func__, fs);
|
||||||
@@ -813,13 +816,13 @@ cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp)
|
|||||||
|
|
||||||
/* Find state from nothing. */
|
/* Find state from nothing. */
|
||||||
int
|
int
|
||||||
cmd_find_from_nothing(struct cmd_find_state *fs)
|
cmd_find_from_nothing(struct cmd_find_state *fs, int flags)
|
||||||
{
|
{
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
|
|
||||||
fs->s = cmd_find_best_session(NULL, 0, fs->flags);
|
fs->s = cmd_find_best_session(NULL, 0, flags);
|
||||||
if (fs->s == NULL) {
|
if (fs->s == NULL) {
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
fs->wl = fs->s->curw;
|
fs->wl = fs->s->curw;
|
||||||
@@ -833,16 +836,16 @@ cmd_find_from_nothing(struct cmd_find_state *fs)
|
|||||||
|
|
||||||
/* Find state from mouse. */
|
/* Find state from mouse. */
|
||||||
int
|
int
|
||||||
cmd_find_from_mouse(struct cmd_find_state *fs, struct mouse_event *m)
|
cmd_find_from_mouse(struct cmd_find_state *fs, struct mouse_event *m, int flags)
|
||||||
{
|
{
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
|
|
||||||
if (!m->valid)
|
if (!m->valid)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl);
|
fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl);
|
||||||
if (fs->wp == NULL) {
|
if (fs->wp == NULL) {
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
fs->w = fs->wl->window;
|
fs->w = fs->wl->window;
|
||||||
@@ -853,68 +856,52 @@ cmd_find_from_mouse(struct cmd_find_state *fs, struct mouse_event *m)
|
|||||||
|
|
||||||
/* Find state from client. */
|
/* Find state from client. */
|
||||||
int
|
int
|
||||||
cmd_find_from_client(struct cmd_find_state *fs, struct client *c)
|
cmd_find_from_client(struct cmd_find_state *fs, struct client *c, int flags)
|
||||||
{
|
{
|
||||||
struct session *s;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
|
||||||
/* If no client, treat as from nothing. */
|
/* If no client, treat as from nothing. */
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
return (cmd_find_from_nothing(fs));
|
return (cmd_find_from_nothing(fs, flags));
|
||||||
|
|
||||||
/* If this is an attached client, all done. */
|
/* If this is an attached client, all done. */
|
||||||
if (c->session != NULL) {
|
if (c->session != NULL) {
|
||||||
cmd_find_from_session(fs, c->session);
|
cmd_find_clear_state(fs, flags);
|
||||||
|
|
||||||
|
fs->wp = server_client_get_pane(c);
|
||||||
|
if (fs->wp == NULL) {
|
||||||
|
cmd_find_from_session(fs, c->session, flags);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
fs->s = c->session;
|
||||||
|
fs->wl = fs->s->curw;
|
||||||
|
fs->w = fs->wl->window;
|
||||||
|
|
||||||
|
cmd_find_log_state(__func__, fs);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, flags);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is an unattached client running in a pane, we can use that
|
* If this is an unattached client running in a pane, we can use that
|
||||||
* to limit the list of sessions to those containing that pane.
|
* to limit the list of sessions to those containing that pane.
|
||||||
*/
|
*/
|
||||||
RB_FOREACH(wp, window_pane_tree, &all_window_panes) {
|
wp = cmd_find_inside_pane(c);
|
||||||
if (strcmp(wp->tty, c->ttyname) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (wp == NULL)
|
if (wp == NULL)
|
||||||
goto unknown_pane;
|
goto unknown_pane;
|
||||||
|
|
||||||
/* If we have a session in TMUX, see if it has this pane. */
|
|
||||||
s = cmd_find_try_TMUX(c);
|
|
||||||
if (s != NULL) {
|
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
|
||||||
if (window_has_pane(wl->window, wp))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (wl != NULL) {
|
|
||||||
fs->s = s;
|
|
||||||
fs->wl = s->curw; /* use current session */
|
|
||||||
fs->w = fs->wl->window;
|
|
||||||
fs->wp = fs->w->active; /* use active pane */
|
|
||||||
|
|
||||||
cmd_find_log_state(__func__, fs);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't have a session, or it doesn't have this pane. Try all
|
* Don't have a session, or it doesn't have this pane. Try all
|
||||||
* sessions.
|
* sessions.
|
||||||
*/
|
*/
|
||||||
fs->w = wp->window;
|
fs->w = wp->window;
|
||||||
if (cmd_find_best_session_with_window(fs) != 0) {
|
if (cmd_find_best_session_with_window(fs) != 0) {
|
||||||
if (wp != NULL) {
|
/*
|
||||||
/*
|
* The window may have been destroyed but the pane
|
||||||
* The window may have been destroyed but the pane
|
* still on all_window_panes due to something else
|
||||||
* still on all_window_panes due to something else
|
* holding a reference.
|
||||||
* holding a reference.
|
*/
|
||||||
*/
|
goto unknown_pane;
|
||||||
goto unknown_pane;
|
|
||||||
}
|
|
||||||
cmd_find_clear_state(fs, 0);
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
fs->wl = fs->s->curw;
|
fs->wl = fs->s->curw;
|
||||||
fs->w = fs->wl->window;
|
fs->w = fs->wl->window;
|
||||||
@@ -924,18 +911,8 @@ cmd_find_from_client(struct cmd_find_state *fs, struct client *c)
|
|||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
unknown_pane:
|
unknown_pane:
|
||||||
/*
|
/* We can't find the pane so need to guess. */
|
||||||
* We're not running in a known pane, but maybe this client has TMUX
|
return (cmd_find_from_nothing(fs, flags));
|
||||||
* in the environment. That'd give us a session.
|
|
||||||
*/
|
|
||||||
s = cmd_find_try_TMUX(c);
|
|
||||||
if (s != NULL) {
|
|
||||||
cmd_find_from_session(fs, s);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Otherwise we need to guess. */
|
|
||||||
return (cmd_find_from_nothing(fs));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -948,8 +925,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
|
|||||||
{
|
{
|
||||||
struct mouse_event *m;
|
struct mouse_event *m;
|
||||||
struct cmd_find_state current;
|
struct cmd_find_state current;
|
||||||
char *colon, *period, *copy = NULL;
|
char *colon, *period, *copy = NULL, tmp[256];
|
||||||
const char *session, *window, *pane;
|
const char *session, *window, *pane, *s;
|
||||||
int window_only = 0, pane_only = 0;
|
int window_only = 0, pane_only = 0;
|
||||||
|
|
||||||
/* Can fail flag implies quiet. */
|
/* Can fail flag implies quiet. */
|
||||||
@@ -957,11 +934,35 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
|
|||||||
flags |= CMD_FIND_QUIET;
|
flags |= CMD_FIND_QUIET;
|
||||||
|
|
||||||
/* Log the arguments. */
|
/* Log the arguments. */
|
||||||
if (target == NULL)
|
if (type == CMD_FIND_PANE)
|
||||||
log_debug("%s: target none, type %d", __func__, type);
|
s = "pane";
|
||||||
|
else if (type == CMD_FIND_WINDOW)
|
||||||
|
s = "window";
|
||||||
|
else if (type == CMD_FIND_SESSION)
|
||||||
|
s = "session";
|
||||||
else
|
else
|
||||||
log_debug("%s: target %s, type %d", __func__, target, type);
|
s = "unknown";
|
||||||
log_debug("%s: item %p, flags %#x", __func__, item, flags);
|
*tmp = '\0';
|
||||||
|
if (flags & CMD_FIND_PREFER_UNATTACHED)
|
||||||
|
strlcat(tmp, "PREFER_UNATTACHED,", sizeof tmp);
|
||||||
|
if (flags & CMD_FIND_QUIET)
|
||||||
|
strlcat(tmp, "QUIET,", sizeof tmp);
|
||||||
|
if (flags & CMD_FIND_WINDOW_INDEX)
|
||||||
|
strlcat(tmp, "WINDOW_INDEX,", sizeof tmp);
|
||||||
|
if (flags & CMD_FIND_DEFAULT_MARKED)
|
||||||
|
strlcat(tmp, "DEFAULT_MARKED,", sizeof tmp);
|
||||||
|
if (flags & CMD_FIND_EXACT_SESSION)
|
||||||
|
strlcat(tmp, "EXACT_SESSION,", sizeof tmp);
|
||||||
|
if (flags & CMD_FIND_EXACT_WINDOW)
|
||||||
|
strlcat(tmp, "EXACT_WINDOW,", sizeof tmp);
|
||||||
|
if (flags & CMD_FIND_CANFAIL)
|
||||||
|
strlcat(tmp, "CANFAIL,", sizeof tmp);
|
||||||
|
if (*tmp != '\0')
|
||||||
|
tmp[strlen(tmp) - 1] = '\0';
|
||||||
|
else
|
||||||
|
strlcat(tmp, "NONE", sizeof tmp);
|
||||||
|
log_debug("%s: target %s, type %s, item %p, flags %s", __func__,
|
||||||
|
target == NULL ? "none" : target, s, item, tmp);
|
||||||
|
|
||||||
/* Clear new state. */
|
/* Clear new state. */
|
||||||
cmd_find_clear_state(fs, flags);
|
cmd_find_clear_state(fs, flags);
|
||||||
@@ -970,14 +971,18 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
|
|||||||
if (server_check_marked() && (flags & CMD_FIND_DEFAULT_MARKED)) {
|
if (server_check_marked() && (flags & CMD_FIND_DEFAULT_MARKED)) {
|
||||||
fs->current = &marked_pane;
|
fs->current = &marked_pane;
|
||||||
log_debug("%s: current is marked pane", __func__);
|
log_debug("%s: current is marked pane", __func__);
|
||||||
} else if (cmd_find_valid_state(&item->shared->current)) {
|
} else if (cmd_find_valid_state(cmdq_get_current(item))) {
|
||||||
fs->current = &item->shared->current;
|
fs->current = cmdq_get_current(item);
|
||||||
log_debug("%s: current is from queue", __func__);
|
log_debug("%s: current is from queue", __func__);
|
||||||
} else if (cmd_find_from_client(¤t, item->client) == 0) {
|
} else if (cmd_find_from_client(¤t, cmdq_get_client(item),
|
||||||
|
flags) == 0) {
|
||||||
fs->current = ¤t;
|
fs->current = ¤t;
|
||||||
log_debug("%s: current is from client", __func__);
|
log_debug("%s: current is from client", __func__);
|
||||||
} else
|
} else {
|
||||||
|
if (~flags & CMD_FIND_QUIET)
|
||||||
|
cmdq_error(item, "no current target");
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
if (!cmd_find_valid_state(fs->current))
|
if (!cmd_find_valid_state(fs->current))
|
||||||
fatalx("invalid current find state");
|
fatalx("invalid current find state");
|
||||||
|
|
||||||
@@ -987,16 +992,20 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
|
|||||||
|
|
||||||
/* Mouse target is a plain = or {mouse}. */
|
/* Mouse target is a plain = or {mouse}. */
|
||||||
if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) {
|
if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) {
|
||||||
m = &item->shared->mouse;
|
m = &cmdq_get_event(item)->m;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CMD_FIND_PANE:
|
case CMD_FIND_PANE:
|
||||||
fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl);
|
fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl);
|
||||||
if (fs->wp != NULL && !window_pane_outside(fs->wp))
|
if (fs->wp != NULL) {
|
||||||
fs->w = fs->wl->window;
|
fs->w = fs->wl->window;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
/* FALLTHROUGH */
|
||||||
case CMD_FIND_WINDOW:
|
case CMD_FIND_WINDOW:
|
||||||
case CMD_FIND_SESSION:
|
case CMD_FIND_SESSION:
|
||||||
fs->wl = cmd_mouse_window(m, &fs->s);
|
fs->wl = cmd_mouse_window(m, &fs->s);
|
||||||
|
if (fs->wl == NULL && fs->s != NULL)
|
||||||
|
fs->wl = fs->s->curw;
|
||||||
if (fs->wl != NULL) {
|
if (fs->wl != NULL) {
|
||||||
fs->w = fs->wl->window;
|
fs->w = fs->wl->window;
|
||||||
fs->wp = fs->w->active;
|
fs->wp = fs->w->active;
|
||||||
@@ -1098,9 +1107,16 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
|
|||||||
if (pane != NULL)
|
if (pane != NULL)
|
||||||
pane = cmd_find_map_table(cmd_find_pane_table, pane);
|
pane = cmd_find_map_table(cmd_find_pane_table, pane);
|
||||||
|
|
||||||
log_debug("%s: target %s (flags %#x): session=%s, window=%s, pane=%s",
|
if (session != NULL || window != NULL || pane != NULL) {
|
||||||
__func__, target, flags, session == NULL ? "none" : session,
|
log_debug("%s: target %s is %s%s%s%s%s%s",
|
||||||
window == NULL ? "none" : window, pane == NULL ? "none" : pane);
|
__func__, target,
|
||||||
|
session == NULL ? "" : "session ",
|
||||||
|
session == NULL ? "" : session,
|
||||||
|
window == NULL ? "" : "window ",
|
||||||
|
window == NULL ? "" : window,
|
||||||
|
pane == NULL ? "" : "pane ",
|
||||||
|
pane == NULL ? "" : pane);
|
||||||
|
}
|
||||||
|
|
||||||
/* No pane is allowed if want an index. */
|
/* No pane is allowed if want an index. */
|
||||||
if (pane != NULL && (flags & CMD_FIND_WINDOW_INDEX)) {
|
if (pane != NULL && (flags & CMD_FIND_WINDOW_INDEX)) {
|
||||||
@@ -1129,7 +1145,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
|
|||||||
/* This will fill in winlink and window. */
|
/* This will fill in winlink and window. */
|
||||||
if (cmd_find_get_window_with_session(fs, window) != 0)
|
if (cmd_find_get_window_with_session(fs, window) != 0)
|
||||||
goto no_window;
|
goto no_window;
|
||||||
fs->wp = fs->wl->window->active;
|
if (fs->wl != NULL) /* can be NULL if index only */
|
||||||
|
fs->wp = fs->wl->window->active;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1169,7 +1186,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
|
|||||||
/* This will fill in session, winlink and window. */
|
/* This will fill in session, winlink and window. */
|
||||||
if (cmd_find_get_window(fs, window, window_only) != 0)
|
if (cmd_find_get_window(fs, window, window_only) != 0)
|
||||||
goto no_window;
|
goto no_window;
|
||||||
fs->wp = fs->wl->window->active;
|
if (fs->wl != NULL) /* can be NULL if index only */
|
||||||
|
fs->wp = fs->wl->window->active;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1206,44 +1224,62 @@ found:
|
|||||||
|
|
||||||
no_session:
|
no_session:
|
||||||
if (~flags & CMD_FIND_QUIET)
|
if (~flags & CMD_FIND_QUIET)
|
||||||
cmdq_error(item, "can't find session %s", session);
|
cmdq_error(item, "can't find session: %s", session);
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
no_window:
|
no_window:
|
||||||
if (~flags & CMD_FIND_QUIET)
|
if (~flags & CMD_FIND_QUIET)
|
||||||
cmdq_error(item, "can't find window %s", window);
|
cmdq_error(item, "can't find window: %s", window);
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
no_pane:
|
no_pane:
|
||||||
if (~flags & CMD_FIND_QUIET)
|
if (~flags & CMD_FIND_QUIET)
|
||||||
cmdq_error(item, "can't find pane %s", pane);
|
cmdq_error(item, "can't find pane: %s", pane);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Find the current client. */
|
||||||
|
static struct client *
|
||||||
|
cmd_find_current_client(struct cmdq_item *item, int quiet)
|
||||||
|
{
|
||||||
|
struct client *c = NULL, *found;
|
||||||
|
struct session *s;
|
||||||
|
struct window_pane *wp;
|
||||||
|
struct cmd_find_state fs;
|
||||||
|
|
||||||
|
if (item != NULL)
|
||||||
|
c = cmdq_get_client(item);
|
||||||
|
if (c != NULL && c->session != NULL)
|
||||||
|
return (c);
|
||||||
|
|
||||||
|
found = NULL;
|
||||||
|
if (c != NULL && (wp = cmd_find_inside_pane(c)) != NULL) {
|
||||||
|
cmd_find_clear_state(&fs, CMD_FIND_QUIET);
|
||||||
|
fs.w = wp->window;
|
||||||
|
if (cmd_find_best_session_with_window(&fs) == 0)
|
||||||
|
found = cmd_find_best_client(fs.s);
|
||||||
|
} else {
|
||||||
|
s = cmd_find_best_session(NULL, 0, CMD_FIND_QUIET);
|
||||||
|
if (s != NULL)
|
||||||
|
found = cmd_find_best_client(s);
|
||||||
|
}
|
||||||
|
if (found == NULL && item != NULL && !quiet)
|
||||||
|
cmdq_error(item, "no current client");
|
||||||
|
log_debug("%s: no target, return %p", __func__, found);
|
||||||
|
return (found);
|
||||||
|
}
|
||||||
|
|
||||||
/* Find the target client or report an error and return NULL. */
|
/* Find the target client or report an error and return NULL. */
|
||||||
struct client *
|
struct client *
|
||||||
cmd_find_client(struct cmdq_item *item, const char *target, int quiet)
|
cmd_find_client(struct cmdq_item *item, const char *target, int quiet)
|
||||||
{
|
{
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct session *s;
|
|
||||||
char *copy;
|
char *copy;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
/* A NULL argument means the current client. */
|
/* A NULL argument means the current client. */
|
||||||
if (target == NULL) {
|
if (target == NULL)
|
||||||
c = NULL;
|
return (cmd_find_current_client(item, quiet));
|
||||||
if (item->client != NULL && item->client->session != NULL)
|
|
||||||
c = item->client;
|
|
||||||
else {
|
|
||||||
s = cmd_find_best_session(NULL, 0, CMD_FIND_QUIET);
|
|
||||||
if (s != NULL)
|
|
||||||
c = cmd_find_best_client(s);
|
|
||||||
}
|
|
||||||
if (c == NULL && !quiet)
|
|
||||||
cmdq_error(item, "no current client");
|
|
||||||
log_debug("%s: no target, return %p", __func__, c);
|
|
||||||
return (c);
|
|
||||||
}
|
|
||||||
copy = xstrdup(target);
|
copy = xstrdup(target);
|
||||||
|
|
||||||
/* Trim a single trailing colon if any. */
|
/* Trim a single trailing colon if any. */
|
||||||
@@ -1270,7 +1306,7 @@ cmd_find_client(struct cmdq_item *item, const char *target, int quiet)
|
|||||||
|
|
||||||
/* If no client found, report an error. */
|
/* If no client found, report an error. */
|
||||||
if (c == NULL && !quiet)
|
if (c == NULL && !quiet)
|
||||||
cmdq_error(item, "can't find client %s", copy);
|
cmdq_error(item, "can't find client: %s", copy);
|
||||||
|
|
||||||
free(copy);
|
free(copy);
|
||||||
log_debug("%s: target %s, return %p", __func__, target, c);
|
log_debug("%s: target %s, return %p", __func__, target, c);
|
||||||
|
|||||||
175
cmd-if-shell.c
175
cmd-if-shell.c
@@ -20,6 +20,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -29,16 +30,19 @@
|
|||||||
* Executes a tmux command if a shell command returns true or false.
|
* Executes a tmux command if a shell command returns true or false.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static enum cmd_retval cmd_if_shell_exec(struct cmd *, struct cmdq_item *);
|
static enum args_parse_type cmd_if_shell_args_parse(struct args *, u_int,
|
||||||
|
char **);
|
||||||
|
static enum cmd_retval cmd_if_shell_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
static void cmd_if_shell_callback(struct job *);
|
static void cmd_if_shell_callback(struct job *);
|
||||||
static void cmd_if_shell_free(void *);
|
static void cmd_if_shell_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_if_shell_entry = {
|
const struct cmd_entry cmd_if_shell_entry = {
|
||||||
.name = "if-shell",
|
.name = "if-shell",
|
||||||
.alias = "if",
|
.alias = "if",
|
||||||
|
|
||||||
.args = { "bFt:", 2, 3 },
|
.args = { "bFt:", 2, 3, cmd_if_shell_args_parse },
|
||||||
.usage = "[-bF] " CMD_TARGET_PANE_USAGE " shell-command command "
|
.usage = "[-bF] " CMD_TARGET_PANE_USAGE " shell-command command "
|
||||||
"[command]",
|
"[command]",
|
||||||
|
|
||||||
@@ -49,90 +53,83 @@ const struct cmd_entry cmd_if_shell_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_if_shell_data {
|
struct cmd_if_shell_data {
|
||||||
char *file;
|
struct args_command_state *cmd_if;
|
||||||
u_int line;
|
struct args_command_state *cmd_else;
|
||||||
|
|
||||||
char *cmd_if;
|
struct client *client;
|
||||||
char *cmd_else;
|
struct cmdq_item *item;
|
||||||
|
|
||||||
struct client *client;
|
|
||||||
struct cmdq_item *item;
|
|
||||||
struct mouse_event mouse;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static enum args_parse_type
|
||||||
|
cmd_if_shell_args_parse(__unused struct args *args, u_int idx,
|
||||||
|
__unused char **cause)
|
||||||
|
{
|
||||||
|
if (idx == 1 || idx == 2)
|
||||||
|
return (ARGS_PARSE_COMMANDS_OR_STRING);
|
||||||
|
return (ARGS_PARSE_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct cmdq_shared *shared = item->shared;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct cmd_if_shell_data *cdata;
|
struct cmd_if_shell_data *cdata;
|
||||||
char *shellcmd, *cmd, *cause;
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmdq_item *new_item;
|
struct cmdq_item *new_item;
|
||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
char *shellcmd;
|
||||||
struct session *s = item->target.s;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct winlink *wl = item->target.wl;
|
struct session *s = target->s;
|
||||||
struct window_pane *wp = item->target.wp;
|
struct cmd_list *cmdlist;
|
||||||
const char *cwd;
|
u_int count = args_count(args);
|
||||||
|
int wait = !args_has(args, 'b');
|
||||||
|
|
||||||
if (item->client != NULL && item->client->session == NULL)
|
shellcmd = format_single_from_target(item, args_string(args, 0));
|
||||||
cwd = item->client->cwd;
|
|
||||||
else if (s != NULL)
|
|
||||||
cwd = s->cwd;
|
|
||||||
else
|
|
||||||
cwd = NULL;
|
|
||||||
|
|
||||||
shellcmd = format_single(item, args->argv[0], c, s, wl, wp);
|
|
||||||
if (args_has(args, 'F')) {
|
if (args_has(args, 'F')) {
|
||||||
cmd = NULL;
|
|
||||||
if (*shellcmd != '0' && *shellcmd != '\0')
|
if (*shellcmd != '0' && *shellcmd != '\0')
|
||||||
cmd = args->argv[1];
|
cmdlist = args_make_commands_now(self, item, 1, 0);
|
||||||
else if (args->argc == 3)
|
else if (count == 3)
|
||||||
cmd = args->argv[2];
|
cmdlist = args_make_commands_now(self, item, 2, 0);
|
||||||
free(shellcmd);
|
else {
|
||||||
if (cmd == NULL)
|
free(shellcmd);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);
|
|
||||||
if (cmdlist == NULL) {
|
|
||||||
if (cause != NULL) {
|
|
||||||
cmdq_error(item, "%s", cause);
|
|
||||||
free(cause);
|
|
||||||
}
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
}
|
||||||
new_item = cmdq_get_command(cmdlist, NULL, &shared->mouse, 0);
|
free(shellcmd);
|
||||||
|
if (cmdlist == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
new_item = cmdq_get_command(cmdlist, cmdq_get_state(item));
|
||||||
cmdq_insert_after(item, new_item);
|
cmdq_insert_after(item, new_item);
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
cdata = xcalloc(1, sizeof *cdata);
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
if (self->file != NULL) {
|
|
||||||
cdata->file = xstrdup(self->file);
|
cdata->cmd_if = args_make_commands_prepare(self, item, 1, NULL, wait,
|
||||||
cdata->line = self->line;
|
0);
|
||||||
|
if (count == 3) {
|
||||||
|
cdata->cmd_else = args_make_commands_prepare(self, item, 2,
|
||||||
|
NULL, wait, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cdata->cmd_if = xstrdup(args->argv[1]);
|
if (wait) {
|
||||||
if (args->argc == 3)
|
cdata->client = cmdq_get_client(item);
|
||||||
cdata->cmd_else = xstrdup(args->argv[2]);
|
cdata->item = item;
|
||||||
else
|
} else
|
||||||
cdata->cmd_else = NULL;
|
cdata->client = tc;
|
||||||
|
|
||||||
cdata->client = item->client;
|
|
||||||
if (cdata->client != NULL)
|
if (cdata->client != NULL)
|
||||||
cdata->client->references++;
|
cdata->client->references++;
|
||||||
|
|
||||||
if (!args_has(args, 'b'))
|
if (job_run(shellcmd, 0, NULL, NULL, s,
|
||||||
cdata->item = item;
|
server_client_get_cwd(cmdq_get_client(item), s), NULL,
|
||||||
else
|
cmd_if_shell_callback, cmd_if_shell_free, cdata, 0, -1,
|
||||||
cdata->item = NULL;
|
-1) == NULL) {
|
||||||
memcpy(&cdata->mouse, &shared->mouse, sizeof cdata->mouse);
|
cmdq_error(item, "failed to run command: %s", shellcmd);
|
||||||
|
free(shellcmd);
|
||||||
job_run(shellcmd, s, cwd, NULL, cmd_if_shell_callback,
|
free(cdata);
|
||||||
cmd_if_shell_free, cdata);
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
free(shellcmd);
|
free(shellcmd);
|
||||||
|
|
||||||
if (args_has(args, 'b'))
|
if (!wait)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
return (CMD_RETURN_WAIT);
|
return (CMD_RETURN_WAIT);
|
||||||
}
|
}
|
||||||
@@ -140,41 +137,41 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
static void
|
static void
|
||||||
cmd_if_shell_callback(struct job *job)
|
cmd_if_shell_callback(struct job *job)
|
||||||
{
|
{
|
||||||
struct cmd_if_shell_data *cdata = job->data;
|
struct cmd_if_shell_data *cdata = job_get_data(job);
|
||||||
struct client *c = cdata->client;
|
struct client *c = cdata->client;
|
||||||
|
struct cmdq_item *item = cdata->item, *new_item;
|
||||||
|
struct args_command_state *state;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmdq_item *new_item;
|
char *error;
|
||||||
char *cause, *cmd, *file = cdata->file;
|
int status;
|
||||||
u_int line = cdata->line;
|
|
||||||
|
|
||||||
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0)
|
status = job_get_status(job);
|
||||||
cmd = cdata->cmd_else;
|
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
||||||
|
state = cdata->cmd_else;
|
||||||
else
|
else
|
||||||
cmd = cdata->cmd_if;
|
state = cdata->cmd_if;
|
||||||
if (cmd == NULL)
|
if (state == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
cmdlist = cmd_string_parse(cmd, file, line, &cause);
|
cmdlist = args_make_commands(state, 0, NULL, &error);
|
||||||
if (cmdlist == NULL) {
|
if (cmdlist == NULL) {
|
||||||
if (cause != NULL && cdata->item != NULL)
|
if (cdata->item == NULL) {
|
||||||
cmdq_error(cdata->item, "%s", cause);
|
*error = toupper((u_char)*error);
|
||||||
free(cause);
|
status_message_set(c, -1, 1, 0, "%s", error);
|
||||||
new_item = NULL;
|
} else
|
||||||
|
cmdq_error(cdata->item, "%s", error);
|
||||||
|
free(error);
|
||||||
|
} else if (item == NULL) {
|
||||||
|
new_item = cmdq_get_command(cmdlist, NULL);
|
||||||
|
cmdq_append(c, new_item);
|
||||||
} else {
|
} else {
|
||||||
new_item = cmdq_get_command(cmdlist, NULL, &cdata->mouse, 0);
|
new_item = cmdq_get_command(cmdlist, cmdq_get_state(item));
|
||||||
cmd_list_free(cmdlist);
|
cmdq_insert_after(item, new_item);
|
||||||
}
|
|
||||||
|
|
||||||
if (new_item != NULL) {
|
|
||||||
if (cdata->item == NULL)
|
|
||||||
cmdq_append(c, new_item);
|
|
||||||
else
|
|
||||||
cmdq_insert_after(cdata->item, new_item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (cdata->item != NULL)
|
if (cdata->item != NULL)
|
||||||
cdata->item->flags &= ~CMDQ_WAITING;
|
cmdq_continue(cdata->item);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -185,9 +182,9 @@ cmd_if_shell_free(void *data)
|
|||||||
if (cdata->client != NULL)
|
if (cdata->client != NULL)
|
||||||
server_client_unref(cdata->client);
|
server_client_unref(cdata->client);
|
||||||
|
|
||||||
free(cdata->cmd_else);
|
if (cdata->cmd_else != NULL)
|
||||||
free(cdata->cmd_if);
|
args_make_commands_free(cdata->cmd_else);
|
||||||
|
args_make_commands_free(cdata->cmd_if);
|
||||||
|
|
||||||
free(cdata->file);
|
|
||||||
free(cdata);
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
113
cmd-join-pane.c
113
cmd-join-pane.c
@@ -20,6 +20,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -34,8 +35,8 @@ const struct cmd_entry cmd_join_pane_entry = {
|
|||||||
.name = "join-pane",
|
.name = "join-pane",
|
||||||
.alias = "joinp",
|
.alias = "joinp",
|
||||||
|
|
||||||
.args = { "bdhvp:l:s:t:", 0, 0 },
|
.args = { "bdfhvp:l:s:t:", 0, 0, NULL },
|
||||||
.usage = "[-bdhv] [-p percentage|-l size] " CMD_SRCDST_PANE_USAGE,
|
.usage = "[-bdfhv] [-l size] " CMD_SRCDST_PANE_USAGE,
|
||||||
|
|
||||||
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
|
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
@@ -48,10 +49,10 @@ const struct cmd_entry cmd_move_pane_entry = {
|
|||||||
.name = "move-pane",
|
.name = "move-pane",
|
||||||
.alias = "movep",
|
.alias = "movep",
|
||||||
|
|
||||||
.args = { "bdhvp:l:s:t:", 0, 0 },
|
.args = { "bdfhvp:l:s:t:", 0, 0, NULL },
|
||||||
.usage = "[-bdhv] [-p percentage|-l size] " CMD_SRCDST_PANE_USAGE,
|
.usage = "[-bdfhv] [-l size] " CMD_SRCDST_PANE_USAGE,
|
||||||
|
|
||||||
.source = { 's', CMD_FIND_PANE, 0 },
|
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
@@ -61,40 +62,34 @@ const struct cmd_entry cmd_move_pane_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct cmd_find_state *current = &item->shared->current;
|
struct cmd_find_state *current = cmdq_get_current(item);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct cmd_find_state *source = cmdq_get_source(item);
|
||||||
struct session *dst_s;
|
struct session *dst_s;
|
||||||
struct winlink *src_wl, *dst_wl;
|
struct winlink *src_wl, *dst_wl;
|
||||||
struct window *src_w, *dst_w;
|
struct window *src_w, *dst_w;
|
||||||
struct window_pane *src_wp, *dst_wp;
|
struct window_pane *src_wp, *dst_wp;
|
||||||
char *cause;
|
char *cause = NULL;
|
||||||
int size, percentage, dst_idx;
|
int size, dst_idx;
|
||||||
|
int flags;
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
struct layout_cell *lc;
|
struct layout_cell *lc;
|
||||||
int not_same_window;
|
u_int curval = 0;
|
||||||
|
|
||||||
if (self->entry == &cmd_join_pane_entry)
|
dst_s = target->s;
|
||||||
not_same_window = 1;
|
dst_wl = target->wl;
|
||||||
else
|
dst_wp = target->wp;
|
||||||
not_same_window = 0;
|
|
||||||
|
|
||||||
dst_s = item->target.s;
|
|
||||||
dst_wl = item->target.wl;
|
|
||||||
dst_wp = item->target.wp;
|
|
||||||
dst_w = dst_wl->window;
|
dst_w = dst_wl->window;
|
||||||
dst_idx = dst_wl->idx;
|
dst_idx = dst_wl->idx;
|
||||||
server_unzoom_window(dst_w);
|
server_unzoom_window(dst_w);
|
||||||
|
|
||||||
src_wl = item->source.wl;
|
src_wl = source->wl;
|
||||||
src_wp = item->source.wp;
|
src_wp = source->wp;
|
||||||
src_w = src_wl->window;
|
src_w = src_wl->window;
|
||||||
server_unzoom_window(src_w);
|
server_unzoom_window(src_w);
|
||||||
|
|
||||||
if (not_same_window && src_w == dst_w) {
|
if (src_wp == dst_wp) {
|
||||||
cmdq_error(item, "can't join a pane to its own window");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
if (!not_same_window && src_wp == dst_wp) {
|
|
||||||
cmdq_error(item, "source and target panes must be different");
|
cmdq_error(item, "source and target panes must be different");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
@@ -103,27 +98,44 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (args_has(args, 'h'))
|
if (args_has(args, 'h'))
|
||||||
type = LAYOUT_LEFTRIGHT;
|
type = LAYOUT_LEFTRIGHT;
|
||||||
|
|
||||||
|
/* If the 'p' flag is dropped then this bit can be moved into 'l'. */
|
||||||
|
if (args_has(args, 'l') || args_has(args, 'p')) {
|
||||||
|
if (args_has(args, 'f')) {
|
||||||
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
|
curval = dst_w->sy;
|
||||||
|
else
|
||||||
|
curval = dst_w->sx;
|
||||||
|
} else {
|
||||||
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
|
curval = dst_wp->sy;
|
||||||
|
else
|
||||||
|
curval = dst_wp->sx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size = -1;
|
size = -1;
|
||||||
if (args_has(args, 'l')) {
|
if (args_has(args, 'l')) {
|
||||||
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
size = args_percentage_and_expand(args, 'l', 0, INT_MAX, curval,
|
||||||
if (cause != NULL) {
|
item, &cause);
|
||||||
cmdq_error(item, "size %s", cause);
|
|
||||||
free(cause);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
} else if (args_has(args, 'p')) {
|
} else if (args_has(args, 'p')) {
|
||||||
percentage = args_strtonum(args, 'p', 0, 100, &cause);
|
size = args_strtonum_and_expand(args, 'l', 0, 100, item,
|
||||||
if (cause != NULL) {
|
&cause);
|
||||||
cmdq_error(item, "percentage %s", cause);
|
if (cause == NULL)
|
||||||
free(cause);
|
size = curval * size / 100;
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
if (type == LAYOUT_TOPBOTTOM)
|
|
||||||
size = (dst_wp->sy * percentage) / 100;
|
|
||||||
else
|
|
||||||
size = (dst_wp->sx * percentage) / 100;
|
|
||||||
}
|
}
|
||||||
lc = layout_split_pane(dst_wp, type, size, args_has(args, 'b'), 0);
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "size %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
flags = 0;
|
||||||
|
if (args_has(args, 'b'))
|
||||||
|
flags |= SPAWN_BEFORE;
|
||||||
|
if (args_has(args, 'f'))
|
||||||
|
flags |= SPAWN_FULLSIZE;
|
||||||
|
|
||||||
|
lc = layout_split_pane(dst_wp, type, size, flags);
|
||||||
if (lc == NULL) {
|
if (lc == NULL) {
|
||||||
cmdq_error(item, "create pane failed: pane too small");
|
cmdq_error(item, "create pane failed: pane too small");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
@@ -131,12 +143,19 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
layout_close_pane(src_wp);
|
layout_close_pane(src_wp);
|
||||||
|
|
||||||
|
server_client_remove_pane(src_wp);
|
||||||
window_lost_pane(src_w, src_wp);
|
window_lost_pane(src_w, src_wp);
|
||||||
TAILQ_REMOVE(&src_w->panes, src_wp, entry);
|
TAILQ_REMOVE(&src_w->panes, src_wp, entry);
|
||||||
|
|
||||||
src_wp->window = dst_w;
|
src_wp->window = dst_w;
|
||||||
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
options_set_parent(src_wp->options, dst_w->options);
|
||||||
layout_assign_pane(lc, src_wp);
|
src_wp->flags |= PANE_STYLECHANGED;
|
||||||
|
if (flags & SPAWN_BEFORE)
|
||||||
|
TAILQ_INSERT_BEFORE(dst_wp, src_wp, entry);
|
||||||
|
else
|
||||||
|
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
||||||
|
layout_assign_pane(lc, src_wp, 0);
|
||||||
|
colour_palette_from_option(&src_wp->palette, src_wp->options);
|
||||||
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
@@ -144,15 +163,15 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
server_redraw_window(dst_w);
|
server_redraw_window(dst_w);
|
||||||
|
|
||||||
if (!args_has(args, 'd')) {
|
if (!args_has(args, 'd')) {
|
||||||
window_set_active_pane(dst_w, src_wp);
|
window_set_active_pane(dst_w, src_wp, 1);
|
||||||
session_select(dst_s, dst_idx);
|
session_select(dst_s, dst_idx);
|
||||||
cmd_find_from_session(current, dst_s);
|
cmd_find_from_session(current, dst_s, 0);
|
||||||
server_redraw_session(dst_s);
|
server_redraw_session(dst_s);
|
||||||
} else
|
} else
|
||||||
server_status_session(dst_s);
|
server_status_session(dst_s);
|
||||||
|
|
||||||
if (window_count_panes(src_w) == 0)
|
if (window_count_panes(src_w) == 0)
|
||||||
server_kill_window(src_w);
|
server_kill_window(src_w, 1);
|
||||||
else
|
else
|
||||||
notify_window("window-layout-changed", src_w);
|
notify_window("window-layout-changed", src_w);
|
||||||
notify_window("window-layout-changed", dst_w);
|
notify_window("window-layout-changed", dst_w);
|
||||||
|
|||||||
@@ -32,27 +32,29 @@ const struct cmd_entry cmd_kill_pane_entry = {
|
|||||||
.name = "kill-pane",
|
.name = "kill-pane",
|
||||||
.alias = "killp",
|
.alias = "killp",
|
||||||
|
|
||||||
.args = { "at:", 0, 0 },
|
.args = { "at:", 0, 0, NULL },
|
||||||
.usage = "[-a] " CMD_TARGET_PANE_USAGE,
|
.usage = "[-a] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
.flags = 0,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_kill_pane_exec
|
.exec = cmd_kill_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_kill_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_kill_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct winlink *wl = item->target.wl;
|
struct args *args = cmd_get_args(self);
|
||||||
struct window_pane *loopwp, *tmpwp, *wp = item->target.wp;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct winlink *wl = target->wl;
|
||||||
|
struct window_pane *loopwp, *tmpwp, *wp = target->wp;
|
||||||
|
|
||||||
server_unzoom_window(wl->window);
|
if (args_has(args, 'a')) {
|
||||||
|
server_unzoom_window(wl->window);
|
||||||
if (args_has(self->args, 'a')) {
|
|
||||||
TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) {
|
TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) {
|
||||||
if (loopwp == wp)
|
if (loopwp == wp)
|
||||||
continue;
|
continue;
|
||||||
|
server_client_remove_pane(loopwp);
|
||||||
layout_close_pane(loopwp);
|
layout_close_pane(loopwp);
|
||||||
window_remove_pane(wl->window, loopwp);
|
window_remove_pane(wl->window, loopwp);
|
||||||
}
|
}
|
||||||
@@ -60,13 +62,6 @@ cmd_kill_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window_count_panes(wl->window) == 1) {
|
server_kill_pane(wp);
|
||||||
server_kill_window(wl->window);
|
|
||||||
recalculate_sizes();
|
|
||||||
} else {
|
|
||||||
layout_close_pane(wp);
|
|
||||||
window_remove_pane(wl->window, wp);
|
|
||||||
server_redraw_window(wl->window);
|
|
||||||
}
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_kill_server_entry = {
|
|||||||
.name = "kill-server",
|
.name = "kill-server",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "", 0, 0 },
|
.args = { "", 0, 0, NULL },
|
||||||
.usage = "",
|
.usage = "",
|
||||||
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
@@ -44,7 +44,7 @@ const struct cmd_entry cmd_start_server_entry = {
|
|||||||
.name = "start-server",
|
.name = "start-server",
|
||||||
.alias = "start",
|
.alias = "start",
|
||||||
|
|
||||||
.args = { "", 0, 0 },
|
.args = { "", 0, 0, NULL },
|
||||||
.usage = "",
|
.usage = "",
|
||||||
|
|
||||||
.flags = CMD_STARTSERVER,
|
.flags = CMD_STARTSERVER,
|
||||||
@@ -54,7 +54,7 @@ const struct cmd_entry cmd_start_server_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_kill_server_exec(struct cmd *self, __unused struct cmdq_item *item)
|
cmd_kill_server_exec(struct cmd *self, __unused struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
if (self->entry == &cmd_kill_server_entry)
|
if (cmd_get_entry(self) == &cmd_kill_server_entry)
|
||||||
kill(getpid(), SIGTERM);
|
kill(getpid(), SIGTERM);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_kill_session_entry = {
|
|||||||
.name = "kill-session",
|
.name = "kill-session",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "aCt:", 0, 0 },
|
.args = { "aCt:", 0, 0, NULL },
|
||||||
.usage = "[-aC] " CMD_TARGET_SESSION_USAGE,
|
.usage = "[-aC] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||||
@@ -45,11 +45,10 @@ const struct cmd_entry cmd_kill_session_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct session *s, *sloop, *stmp;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct winlink *wl;
|
struct session *s = target->s, *sloop, *stmp;
|
||||||
|
struct winlink *wl;
|
||||||
s = item->target.s;
|
|
||||||
|
|
||||||
if (args_has(args, 'C')) {
|
if (args_has(args, 'C')) {
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
@@ -61,12 +60,12 @@ cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
RB_FOREACH_SAFE(sloop, sessions, &sessions, stmp) {
|
RB_FOREACH_SAFE(sloop, sessions, &sessions, stmp) {
|
||||||
if (sloop != s) {
|
if (sloop != s) {
|
||||||
server_destroy_session(sloop);
|
server_destroy_session(sloop);
|
||||||
session_destroy(sloop);
|
session_destroy(sloop, 1, __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
server_destroy_session(s);
|
server_destroy_session(s);
|
||||||
session_destroy(s);
|
session_destroy(s, 1, __func__);
|
||||||
}
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const struct cmd_entry cmd_kill_window_entry = {
|
|||||||
.name = "kill-window",
|
.name = "kill-window",
|
||||||
.alias = "killw",
|
.alias = "killw",
|
||||||
|
|
||||||
.args = { "at:", 0, 0 },
|
.args = { "at:", 0, 0, NULL },
|
||||||
.usage = "[-a] " CMD_TARGET_WINDOW_USAGE,
|
.usage = "[-a] " CMD_TARGET_WINDOW_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
@@ -43,7 +43,7 @@ const struct cmd_entry cmd_unlink_window_entry = {
|
|||||||
.name = "unlink-window",
|
.name = "unlink-window",
|
||||||
.alias = "unlinkw",
|
.alias = "unlinkw",
|
||||||
|
|
||||||
.args = { "kt:", 0, 0 },
|
.args = { "kt:", 0, 0, NULL },
|
||||||
.usage = "[-k] " CMD_TARGET_WINDOW_USAGE,
|
.usage = "[-k] " CMD_TARGET_WINDOW_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
@@ -55,27 +55,56 @@ const struct cmd_entry cmd_unlink_window_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_kill_window_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_kill_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct winlink *wl = item->target.wl, *wl2, *wl3;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct winlink *wl = target->wl, *loop;
|
||||||
struct window *w = wl->window;
|
struct window *w = wl->window;
|
||||||
struct session *s = item->target.s;
|
struct session *s = target->s;
|
||||||
|
u_int found;
|
||||||
|
|
||||||
if (self->entry == &cmd_unlink_window_entry) {
|
if (cmd_get_entry(self) == &cmd_unlink_window_entry) {
|
||||||
if (!args_has(self->args, 'k') && !session_is_linked(s, w)) {
|
if (!args_has(args, 'k') && !session_is_linked(s, w)) {
|
||||||
cmdq_error(item, "window only linked to one session");
|
cmdq_error(item, "window only linked to one session");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
server_unlink_window(s, wl);
|
server_unlink_window(s, wl);
|
||||||
} else {
|
recalculate_sizes();
|
||||||
if (args_has(args, 'a')) {
|
return (CMD_RETURN_NORMAL);
|
||||||
RB_FOREACH_SAFE(wl2, winlinks, &s->windows, wl3) {
|
|
||||||
if (wl != wl2)
|
|
||||||
server_kill_window(wl2->window);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
server_kill_window(wl->window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
recalculate_sizes();
|
if (args_has(args, 'a')) {
|
||||||
|
if (RB_PREV(winlinks, &s->windows, wl) == NULL &&
|
||||||
|
RB_NEXT(winlinks, &s->windows, wl) == NULL)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
/* Kill all windows except the current one. */
|
||||||
|
do {
|
||||||
|
found = 0;
|
||||||
|
RB_FOREACH(loop, winlinks, &s->windows) {
|
||||||
|
if (loop->window != wl->window) {
|
||||||
|
server_kill_window(loop->window, 0);
|
||||||
|
found++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (found != 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the current window appears in the session more than once,
|
||||||
|
* kill it as well.
|
||||||
|
*/
|
||||||
|
found = 0;
|
||||||
|
RB_FOREACH(loop, winlinks, &s->windows) {
|
||||||
|
if (loop->window == wl->window)
|
||||||
|
found++;
|
||||||
|
}
|
||||||
|
if (found > 1)
|
||||||
|
server_kill_window(wl->window, 0);
|
||||||
|
|
||||||
|
server_renumber_all();
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
server_kill_window(wl->window, 1);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ const struct cmd_entry cmd_list_buffers_entry = {
|
|||||||
.name = "list-buffers",
|
.name = "list-buffers",
|
||||||
.alias = "lsb",
|
.alias = "lsb",
|
||||||
|
|
||||||
.args = { "F:", 0, 0 },
|
.args = { "F:f:", 0, 0, NULL },
|
||||||
.usage = "[-F format]",
|
.usage = "[-F format] [-f filter]",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_list_buffers_exec
|
.exec = cmd_list_buffers_exec
|
||||||
@@ -46,23 +46,33 @@ const struct cmd_entry cmd_list_buffers_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
char *line;
|
const char *template, *filter;
|
||||||
const char *template;
|
char *line, *expanded;
|
||||||
|
int flag;
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = LIST_BUFFERS_TEMPLATE;
|
template = LIST_BUFFERS_TEMPLATE;
|
||||||
|
filter = args_get(args, 'f');
|
||||||
|
|
||||||
pb = NULL;
|
pb = NULL;
|
||||||
while ((pb = paste_walk(pb)) != NULL) {
|
while ((pb = paste_walk(pb)) != NULL) {
|
||||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
|
||||||
format_defaults_paste_buffer(ft, pb);
|
format_defaults_paste_buffer(ft, pb);
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
if (filter != NULL) {
|
||||||
cmdq_print(item, "%s", line);
|
expanded = format_expand(ft, filter);
|
||||||
free(line);
|
flag = format_true(expanded);
|
||||||
|
free(expanded);
|
||||||
|
} else
|
||||||
|
flag = 1;
|
||||||
|
if (flag) {
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
cmdq_print(item, "%s", line);
|
||||||
|
free(line);
|
||||||
|
}
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,10 +28,12 @@
|
|||||||
* List all clients.
|
* List all clients.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LIST_CLIENTS_TEMPLATE \
|
#define LIST_CLIENTS_TEMPLATE \
|
||||||
"#{client_name}: #{session_name} " \
|
"#{client_name}: #{session_name} " \
|
||||||
"[#{client_width}x#{client_height} #{client_termname}]" \
|
"[#{client_width}x#{client_height} #{client_termname}] " \
|
||||||
"#{?client_utf8, (utf8),} #{?client_readonly, (ro),}"
|
"#{?#{!=:#{client_uid},#{uid}}," \
|
||||||
|
"[user #{?client_user,#{client_user},#{client_uid},}] ,}" \
|
||||||
|
"#{?client_flags,(,}#{client_flags}#{?client_flags,),}"
|
||||||
|
|
||||||
static enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmdq_item *);
|
static enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
@@ -39,8 +41,8 @@ const struct cmd_entry cmd_list_clients_entry = {
|
|||||||
.name = "list-clients",
|
.name = "list-clients",
|
||||||
.alias = "lsc",
|
.alias = "lsc",
|
||||||
|
|
||||||
.args = { "F:t:", 0, 0 },
|
.args = { "F:f:t:", 0, 0, NULL },
|
||||||
.usage = "[-F format] " CMD_TARGET_SESSION_USAGE,
|
.usage = "[-F format] [-f filter] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||||
|
|
||||||
@@ -51,34 +53,45 @@ const struct cmd_entry cmd_list_clients_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
const char *template;
|
const char *template, *filter;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
char *line;
|
char *line, *expanded;
|
||||||
|
int flag;
|
||||||
|
|
||||||
if (args_has(args, 't'))
|
if (args_has(args, 't'))
|
||||||
s = item->target.s;
|
s = target->s;
|
||||||
else
|
else
|
||||||
s = NULL;
|
s = NULL;
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = LIST_CLIENTS_TEMPLATE;
|
template = LIST_CLIENTS_TEMPLATE;
|
||||||
|
filter = args_get(args, 'f');
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
TAILQ_FOREACH(c, &clients, entry) {
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
if (c->session == NULL || (s != NULL && s != c->session))
|
if (c->session == NULL || (s != NULL && s != c->session))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
|
||||||
format_add(ft, "line", "%u", idx);
|
format_add(ft, "line", "%u", idx);
|
||||||
format_defaults(ft, c, NULL, NULL, NULL);
|
format_defaults(ft, c, NULL, NULL, NULL);
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
if (filter != NULL) {
|
||||||
cmdq_print(item, "%s", line);
|
expanded = format_expand(ft, filter);
|
||||||
free(line);
|
flag = format_true(expanded);
|
||||||
|
free(expanded);
|
||||||
|
} else
|
||||||
|
flag = 1;
|
||||||
|
if (flag) {
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
cmdq_print(item, "%s", line);
|
||||||
|
free(line);
|
||||||
|
}
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|
||||||
|
|||||||
255
cmd-list-keys.c
255
cmd-list-keys.c
@@ -36,8 +36,8 @@ const struct cmd_entry cmd_list_keys_entry = {
|
|||||||
.name = "list-keys",
|
.name = "list-keys",
|
||||||
.alias = "lsk",
|
.alias = "lsk",
|
||||||
|
|
||||||
.args = { "T:", 0, 0 },
|
.args = { "1aNP:T:", 0, 1, NULL },
|
||||||
.usage = "[-T key-table]",
|
.usage = "[-1aN] [-P prefix-string] [-T key-table] [key]",
|
||||||
|
|
||||||
.flags = CMD_STARTSERVER|CMD_AFTERHOOK,
|
.flags = CMD_STARTSERVER|CMD_AFTERHOOK,
|
||||||
.exec = cmd_list_keys_exec
|
.exec = cmd_list_keys_exec
|
||||||
@@ -47,39 +47,184 @@ const struct cmd_entry cmd_list_commands_entry = {
|
|||||||
.name = "list-commands",
|
.name = "list-commands",
|
||||||
.alias = "lscm",
|
.alias = "lscm",
|
||||||
|
|
||||||
.args = { "F:", 0, 0 },
|
.args = { "F:", 0, 1, NULL },
|
||||||
.usage = "[-F format]",
|
.usage = "[-F format] [command]",
|
||||||
|
|
||||||
.flags = CMD_STARTSERVER|CMD_AFTERHOOK,
|
.flags = CMD_STARTSERVER|CMD_AFTERHOOK,
|
||||||
.exec = cmd_list_keys_exec
|
.exec = cmd_list_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static u_int
|
||||||
|
cmd_list_keys_get_width(const char *tablename, key_code only)
|
||||||
|
{
|
||||||
|
struct key_table *table;
|
||||||
|
struct key_binding *bd;
|
||||||
|
u_int width, keywidth = 0;
|
||||||
|
|
||||||
|
table = key_bindings_get_table(tablename, 0);
|
||||||
|
if (table == NULL)
|
||||||
|
return (0);
|
||||||
|
bd = key_bindings_first(table);
|
||||||
|
while (bd != NULL) {
|
||||||
|
if ((only != KEYC_UNKNOWN && bd->key != only) ||
|
||||||
|
KEYC_IS_MOUSE(bd->key) ||
|
||||||
|
bd->note == NULL ||
|
||||||
|
*bd->note == '\0') {
|
||||||
|
bd = key_bindings_next(table, bd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
width = utf8_cstrwidth(key_string_lookup_key(bd->key, 0));
|
||||||
|
if (width > keywidth)
|
||||||
|
keywidth = width;
|
||||||
|
|
||||||
|
bd = key_bindings_next(table, bd);
|
||||||
|
}
|
||||||
|
return (keywidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmd_list_keys_print_notes(struct cmdq_item *item, struct args *args,
|
||||||
|
const char *tablename, u_int keywidth, key_code only, const char *prefix)
|
||||||
|
{
|
||||||
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
|
struct key_table *table;
|
||||||
|
struct key_binding *bd;
|
||||||
|
const char *key;
|
||||||
|
char *tmp, *note;
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
|
table = key_bindings_get_table(tablename, 0);
|
||||||
|
if (table == NULL)
|
||||||
|
return (0);
|
||||||
|
bd = key_bindings_first(table);
|
||||||
|
while (bd != NULL) {
|
||||||
|
if ((only != KEYC_UNKNOWN && bd->key != only) ||
|
||||||
|
KEYC_IS_MOUSE(bd->key) ||
|
||||||
|
((bd->note == NULL || *bd->note == '\0') &&
|
||||||
|
!args_has(args, 'a'))) {
|
||||||
|
bd = key_bindings_next(table, bd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
found = 1;
|
||||||
|
key = key_string_lookup_key(bd->key, 0);
|
||||||
|
|
||||||
|
if (bd->note == NULL || *bd->note == '\0')
|
||||||
|
note = cmd_list_print(bd->cmdlist, 1);
|
||||||
|
else
|
||||||
|
note = xstrdup(bd->note);
|
||||||
|
tmp = utf8_padcstr(key, keywidth + 1);
|
||||||
|
if (args_has(args, '1') && tc != NULL) {
|
||||||
|
status_message_set(tc, -1, 1, 0, "%s%s%s", prefix, tmp,
|
||||||
|
note);
|
||||||
|
} else
|
||||||
|
cmdq_print(item, "%s%s%s", prefix, tmp, note);
|
||||||
|
free(tmp);
|
||||||
|
free(note);
|
||||||
|
|
||||||
|
if (args_has(args, '1'))
|
||||||
|
break;
|
||||||
|
bd = key_bindings_next(table, bd);
|
||||||
|
}
|
||||||
|
return (found);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
cmd_list_keys_get_prefix(struct args *args, key_code *prefix)
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
*prefix = options_get_number(global_s_options, "prefix");
|
||||||
|
if (!args_has(args, 'P')) {
|
||||||
|
if (*prefix != KEYC_NONE)
|
||||||
|
xasprintf(&s, "%s ", key_string_lookup_key(*prefix, 0));
|
||||||
|
else
|
||||||
|
s = xstrdup("");
|
||||||
|
} else
|
||||||
|
s = xstrdup(args_get(args, 'P'));
|
||||||
|
return (s);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct key_table *table;
|
struct key_table *table;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
const char *key, *tablename, *r;
|
const char *tablename, *r, *keystr;
|
||||||
char *cp, tmp[BUFSIZ];
|
char *key, *cp, *tmp, *start, *empty;
|
||||||
int repeat, width, tablewidth, keywidth;
|
key_code prefix, only = KEYC_UNKNOWN;
|
||||||
|
int repeat, width, tablewidth, keywidth, found = 0;
|
||||||
|
size_t tmpsize, tmpused, cplen;
|
||||||
|
|
||||||
if (self->entry == &cmd_list_commands_entry)
|
if (cmd_get_entry(self) == &cmd_list_commands_entry)
|
||||||
return (cmd_list_keys_commands(self, item));
|
return (cmd_list_keys_commands(self, item));
|
||||||
|
|
||||||
|
if ((keystr = args_string(args, 0)) != NULL) {
|
||||||
|
only = key_string_lookup_string(keystr);
|
||||||
|
if (only == KEYC_UNKNOWN) {
|
||||||
|
cmdq_error(item, "invalid key: %s", keystr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
only &= (KEYC_MASK_KEY|KEYC_MASK_MODIFIERS);
|
||||||
|
}
|
||||||
|
|
||||||
tablename = args_get(args, 'T');
|
tablename = args_get(args, 'T');
|
||||||
if (tablename != NULL && key_bindings_get_table(tablename, 0) == NULL) {
|
if (tablename != NULL && key_bindings_get_table(tablename, 0) == NULL) {
|
||||||
cmdq_error(item, "table %s doesn't exist", tablename);
|
cmdq_error(item, "table %s doesn't exist", tablename);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'N')) {
|
||||||
|
if (tablename == NULL) {
|
||||||
|
start = cmd_list_keys_get_prefix(args, &prefix);
|
||||||
|
keywidth = cmd_list_keys_get_width("root", only);
|
||||||
|
if (prefix != KEYC_NONE) {
|
||||||
|
width = cmd_list_keys_get_width("prefix", only);
|
||||||
|
if (width == 0)
|
||||||
|
prefix = KEYC_NONE;
|
||||||
|
else if (width > keywidth)
|
||||||
|
keywidth = width;
|
||||||
|
}
|
||||||
|
empty = utf8_padcstr("", utf8_cstrwidth(start));
|
||||||
|
|
||||||
|
found = cmd_list_keys_print_notes(item, args, "root",
|
||||||
|
keywidth, only, empty);
|
||||||
|
if (prefix != KEYC_NONE) {
|
||||||
|
if (cmd_list_keys_print_notes(item, args,
|
||||||
|
"prefix", keywidth, only, start))
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
free(empty);
|
||||||
|
} else {
|
||||||
|
if (args_has(args, 'P'))
|
||||||
|
start = xstrdup(args_get(args, 'P'));
|
||||||
|
else
|
||||||
|
start = xstrdup("");
|
||||||
|
keywidth = cmd_list_keys_get_width(tablename, only);
|
||||||
|
found = cmd_list_keys_print_notes(item, args, tablename,
|
||||||
|
keywidth, only, start);
|
||||||
|
|
||||||
|
}
|
||||||
|
free(start);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
repeat = 0;
|
repeat = 0;
|
||||||
tablewidth = keywidth = 0;
|
tablewidth = keywidth = 0;
|
||||||
RB_FOREACH(table, key_tables, &key_tables) {
|
table = key_bindings_first_table();
|
||||||
if (tablename != NULL && strcmp(table->name, tablename) != 0)
|
while (table != NULL) {
|
||||||
|
if (tablename != NULL && strcmp(table->name, tablename) != 0) {
|
||||||
|
table = key_bindings_next_table(table);
|
||||||
continue;
|
continue;
|
||||||
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
|
}
|
||||||
key = key_string_lookup_key(bd->key);
|
bd = key_bindings_first(table);
|
||||||
|
while (bd != NULL) {
|
||||||
|
if (only != KEYC_UNKNOWN && bd->key != only) {
|
||||||
|
bd = key_bindings_next(table, bd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
key = args_escape(key_string_lookup_key(bd->key, 0));
|
||||||
|
|
||||||
if (bd->flags & KEY_BINDING_REPEAT)
|
if (bd->flags & KEY_BINDING_REPEAT)
|
||||||
repeat = 1;
|
repeat = 1;
|
||||||
@@ -90,14 +235,30 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
width = utf8_cstrwidth(key);
|
width = utf8_cstrwidth(key);
|
||||||
if (width > keywidth)
|
if (width > keywidth)
|
||||||
keywidth = width;
|
keywidth = width;
|
||||||
|
|
||||||
|
free(key);
|
||||||
|
bd = key_bindings_next(table, bd);
|
||||||
}
|
}
|
||||||
|
table = key_bindings_next_table(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_FOREACH(table, key_tables, &key_tables) {
|
tmpsize = 256;
|
||||||
if (tablename != NULL && strcmp(table->name, tablename) != 0)
|
tmp = xmalloc(tmpsize);
|
||||||
|
|
||||||
|
table = key_bindings_first_table();
|
||||||
|
while (table != NULL) {
|
||||||
|
if (tablename != NULL && strcmp(table->name, tablename) != 0) {
|
||||||
|
table = key_bindings_next_table(table);
|
||||||
continue;
|
continue;
|
||||||
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
|
}
|
||||||
key = key_string_lookup_key(bd->key);
|
bd = key_bindings_first(table);
|
||||||
|
while (bd != NULL) {
|
||||||
|
if (only != KEYC_UNKNOWN && bd->key != only) {
|
||||||
|
bd = key_bindings_next(table, bd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
found = 1;
|
||||||
|
key = args_escape(key_string_lookup_key(bd->key, 0));
|
||||||
|
|
||||||
if (!repeat)
|
if (!repeat)
|
||||||
r = "";
|
r = "";
|
||||||
@@ -105,37 +266,69 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
r = "-r ";
|
r = "-r ";
|
||||||
else
|
else
|
||||||
r = " ";
|
r = " ";
|
||||||
xsnprintf(tmp, sizeof tmp, "%s-T ", r);
|
tmpused = xsnprintf(tmp, tmpsize, "%s-T ", r);
|
||||||
|
|
||||||
cp = utf8_padcstr(table->name, tablewidth);
|
cp = utf8_padcstr(table->name, tablewidth);
|
||||||
strlcat(tmp, cp, sizeof tmp);
|
cplen = strlen(cp) + 1;
|
||||||
strlcat(tmp, " ", sizeof tmp);
|
while (tmpused + cplen + 1 >= tmpsize) {
|
||||||
|
tmpsize *= 2;
|
||||||
|
tmp = xrealloc(tmp, tmpsize);
|
||||||
|
}
|
||||||
|
strlcat(tmp, cp, tmpsize);
|
||||||
|
tmpused = strlcat(tmp, " ", tmpsize);
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
cp = utf8_padcstr(key, keywidth);
|
cp = utf8_padcstr(key, keywidth);
|
||||||
strlcat(tmp, cp, sizeof tmp);
|
cplen = strlen(cp) + 1;
|
||||||
strlcat(tmp, " ", sizeof tmp);
|
while (tmpused + cplen + 1 >= tmpsize) {
|
||||||
|
tmpsize *= 2;
|
||||||
|
tmp = xrealloc(tmp, tmpsize);
|
||||||
|
}
|
||||||
|
strlcat(tmp, cp, tmpsize);
|
||||||
|
tmpused = strlcat(tmp, " ", tmpsize);
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
cp = cmd_list_print(bd->cmdlist);
|
cp = cmd_list_print(bd->cmdlist, 1);
|
||||||
strlcat(tmp, cp, sizeof tmp);
|
cplen = strlen(cp);
|
||||||
|
while (tmpused + cplen + 1 >= tmpsize) {
|
||||||
|
tmpsize *= 2;
|
||||||
|
tmp = xrealloc(tmp, tmpsize);
|
||||||
|
}
|
||||||
|
strlcat(tmp, cp, tmpsize);
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
cmdq_print(item, "bind-key %s", tmp);
|
if (args_has(args, '1') && tc != NULL) {
|
||||||
|
status_message_set(tc, -1, 1, 0, "bind-key %s",
|
||||||
|
tmp);
|
||||||
|
} else
|
||||||
|
cmdq_print(item, "bind-key %s", tmp);
|
||||||
|
free(key);
|
||||||
|
|
||||||
|
if (args_has(args, '1'))
|
||||||
|
break;
|
||||||
|
bd = key_bindings_next(table, bd);
|
||||||
}
|
}
|
||||||
|
table = key_bindings_next_table(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(tmp);
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (only != KEYC_UNKNOWN && !found) {
|
||||||
|
cmdq_error(item, "unknown key: %s", args_string(args, 0));
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item)
|
cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
const struct cmd_entry **entryp;
|
const struct cmd_entry **entryp;
|
||||||
const struct cmd_entry *entry;
|
const struct cmd_entry *entry;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
const char *template, *s;
|
const char *template, *s, *command;
|
||||||
char *line;
|
char *line;
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL) {
|
if ((template = args_get(args, 'F')) == NULL) {
|
||||||
@@ -144,11 +337,17 @@ cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item)
|
|||||||
"#{command_list_usage}";
|
"#{command_list_usage}";
|
||||||
}
|
}
|
||||||
|
|
||||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
|
||||||
format_defaults(ft, NULL, NULL, NULL, NULL);
|
format_defaults(ft, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
command = args_string(args, 0);
|
||||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
||||||
entry = *entryp;
|
entry = *entryp;
|
||||||
|
if (command != NULL &&
|
||||||
|
(strcmp(entry->name, command) != 0 &&
|
||||||
|
(entry->alias == NULL ||
|
||||||
|
strcmp(entry->alias, command) != 0)))
|
||||||
|
continue;
|
||||||
|
|
||||||
format_add(ft, "command_list_name", "%s", entry->name);
|
format_add(ft, "command_list_name", "%s", entry->name);
|
||||||
if (entry->alias != NULL)
|
if (entry->alias != NULL)
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ const struct cmd_entry cmd_list_panes_entry = {
|
|||||||
.name = "list-panes",
|
.name = "list-panes",
|
||||||
.alias = "lsp",
|
.alias = "lsp",
|
||||||
|
|
||||||
.args = { "asF:t:", 0, 0 },
|
.args = { "asF:f:t:", 0, 0, NULL },
|
||||||
.usage = "[-as] [-F format] " CMD_TARGET_WINDOW_USAGE,
|
.usage = "[-as] [-F format] [-f filter] " CMD_TARGET_WINDOW_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
|
|
||||||
@@ -50,9 +50,10 @@ const struct cmd_entry cmd_list_panes_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_panes_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_list_panes_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct session *s = item->target.s;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct winlink *wl = item->target.wl;
|
struct session *s = target->s;
|
||||||
|
struct winlink *wl = target->wl;
|
||||||
|
|
||||||
if (args_has(args, 'a'))
|
if (args_has(args, 'a'))
|
||||||
cmd_list_panes_server(self, item);
|
cmd_list_panes_server(self, item);
|
||||||
@@ -87,12 +88,13 @@ static void
|
|||||||
cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
|
cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
|
||||||
struct cmdq_item *item, int type)
|
struct cmdq_item *item, int type)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
u_int n;
|
u_int n;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
const char *template;
|
const char *template, *filter;
|
||||||
char *line;
|
char *line, *expanded;
|
||||||
|
int flag;
|
||||||
|
|
||||||
template = args_get(args, 'F');
|
template = args_get(args, 'F');
|
||||||
if (template == NULL) {
|
if (template == NULL) {
|
||||||
@@ -120,16 +122,25 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
filter = args_get(args, 'f');
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
|
||||||
format_add(ft, "line", "%u", n);
|
format_add(ft, "line", "%u", n);
|
||||||
format_defaults(ft, NULL, s, wl, wp);
|
format_defaults(ft, NULL, s, wl, wp);
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
if (filter != NULL) {
|
||||||
cmdq_print(item, "%s", line);
|
expanded = format_expand(ft, filter);
|
||||||
free(line);
|
flag = format_true(expanded);
|
||||||
|
free(expanded);
|
||||||
|
} else
|
||||||
|
flag = 1;
|
||||||
|
if (flag) {
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
cmdq_print(item, "%s", line);
|
||||||
|
free(line);
|
||||||
|
}
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
n++;
|
n++;
|
||||||
|
|||||||
@@ -30,8 +30,7 @@
|
|||||||
|
|
||||||
#define LIST_SESSIONS_TEMPLATE \
|
#define LIST_SESSIONS_TEMPLATE \
|
||||||
"#{session_name}: #{session_windows} windows " \
|
"#{session_name}: #{session_windows} windows " \
|
||||||
"(created #{t:session_created}) " \
|
"(created #{t:session_created})" \
|
||||||
"[#{session_width}x#{session_height}]" \
|
|
||||||
"#{?session_grouped, (group ,}" \
|
"#{?session_grouped, (group ,}" \
|
||||||
"#{session_group}#{?session_grouped,),}" \
|
"#{session_group}#{?session_grouped,),}" \
|
||||||
"#{?session_attached, (attached),}"
|
"#{?session_attached, (attached),}"
|
||||||
@@ -43,8 +42,8 @@ const struct cmd_entry cmd_list_sessions_entry = {
|
|||||||
.name = "list-sessions",
|
.name = "list-sessions",
|
||||||
.alias = "ls",
|
.alias = "ls",
|
||||||
|
|
||||||
.args = { "F:", 0, 0 },
|
.args = { "F:f:", 0, 0, NULL },
|
||||||
.usage = "[-F format]",
|
.usage = "[-F format] [-f filter]",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_list_sessions_exec
|
.exec = cmd_list_sessions_exec
|
||||||
@@ -53,25 +52,35 @@ const struct cmd_entry cmd_list_sessions_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct session *s;
|
struct session *s;
|
||||||
u_int n;
|
u_int n;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
const char *template;
|
const char *template, *filter;
|
||||||
char *line;
|
char *line, *expanded;
|
||||||
|
int flag;
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = LIST_SESSIONS_TEMPLATE;
|
template = LIST_SESSIONS_TEMPLATE;
|
||||||
|
filter = args_get(args, 'f');
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
|
||||||
format_add(ft, "line", "%u", n);
|
format_add(ft, "line", "%u", n);
|
||||||
format_defaults(ft, NULL, s, NULL, NULL);
|
format_defaults(ft, NULL, s, NULL, NULL);
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
if (filter != NULL) {
|
||||||
cmdq_print(item, "%s", line);
|
expanded = format_expand(ft, filter);
|
||||||
free(line);
|
flag = format_true(expanded);
|
||||||
|
free(expanded);
|
||||||
|
} else
|
||||||
|
flag = 1;
|
||||||
|
if (flag) {
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
cmdq_print(item, "%s", line);
|
||||||
|
free(line);
|
||||||
|
}
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
n++;
|
n++;
|
||||||
|
|||||||
@@ -28,14 +28,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define LIST_WINDOWS_TEMPLATE \
|
#define LIST_WINDOWS_TEMPLATE \
|
||||||
"#{window_index}: #{window_name}#{window_flags} " \
|
"#{window_index}: #{window_name}#{window_raw_flags} " \
|
||||||
"(#{window_panes} panes) " \
|
"(#{window_panes} panes) " \
|
||||||
"[#{window_width}x#{window_height}] " \
|
"[#{window_width}x#{window_height}] " \
|
||||||
"[layout #{window_layout}] #{window_id}" \
|
"[layout #{window_layout}] #{window_id}" \
|
||||||
"#{?window_active, (active),}";
|
"#{?window_active, (active),}";
|
||||||
#define LIST_WINDOWS_WITH_SESSION_TEMPLATE \
|
#define LIST_WINDOWS_WITH_SESSION_TEMPLATE \
|
||||||
"#{session_name}:" \
|
"#{session_name}:" \
|
||||||
"#{window_index}: #{window_name}#{window_flags} " \
|
"#{window_index}: #{window_name}#{window_raw_flags} " \
|
||||||
"(#{window_panes} panes) " \
|
"(#{window_panes} panes) " \
|
||||||
"[#{window_width}x#{window_height}] "
|
"[#{window_width}x#{window_height}] "
|
||||||
|
|
||||||
@@ -49,8 +49,8 @@ const struct cmd_entry cmd_list_windows_entry = {
|
|||||||
.name = "list-windows",
|
.name = "list-windows",
|
||||||
.alias = "lsw",
|
.alias = "lsw",
|
||||||
|
|
||||||
.args = { "F:at:", 0, 0 },
|
.args = { "F:f:at:", 0, 0, NULL },
|
||||||
.usage = "[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
|
.usage = "[-a] [-F format] [-f filter] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||||
|
|
||||||
@@ -61,12 +61,13 @@ const struct cmd_entry cmd_list_windows_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_windows_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_list_windows_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
|
||||||
if (args_has(args, 'a'))
|
if (args_has(args, 'a'))
|
||||||
cmd_list_windows_server(self, item);
|
cmd_list_windows_server(self, item);
|
||||||
else
|
else
|
||||||
cmd_list_windows_session(self, item->target.s, item, 0);
|
cmd_list_windows_session(self, target->s, item, 0);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
@@ -84,12 +85,13 @@ static void
|
|||||||
cmd_list_windows_session(struct cmd *self, struct session *s,
|
cmd_list_windows_session(struct cmd *self, struct session *s,
|
||||||
struct cmdq_item *item, int type)
|
struct cmdq_item *item, int type)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
u_int n;
|
u_int n;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
const char *template;
|
const char *template, *filter;
|
||||||
char *line;
|
char *line, *expanded;
|
||||||
|
int flag;
|
||||||
|
|
||||||
template = args_get(args, 'F');
|
template = args_get(args, 'F');
|
||||||
if (template == NULL) {
|
if (template == NULL) {
|
||||||
@@ -102,16 +104,25 @@ cmd_list_windows_session(struct cmd *self, struct session *s,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
filter = args_get(args, 'f');
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
|
||||||
format_add(ft, "line", "%u", n);
|
format_add(ft, "line", "%u", n);
|
||||||
format_defaults(ft, NULL, s, wl, NULL);
|
format_defaults(ft, NULL, s, wl, NULL);
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
if (filter != NULL) {
|
||||||
cmdq_print(item, "%s", line);
|
expanded = format_expand(ft, filter);
|
||||||
free(line);
|
flag = format_true(expanded);
|
||||||
|
free(expanded);
|
||||||
|
} else
|
||||||
|
flag = 1;
|
||||||
|
if (flag) {
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
cmdq_print(item, "%s", line);
|
||||||
|
free(line);
|
||||||
|
}
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
n++;
|
n++;
|
||||||
|
|||||||
126
cmd-list.c
126
cmd-list.c
@@ -1,126 +0,0 @@
|
|||||||
/* $OpenBSD$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
struct cmd_list *
|
|
||||||
cmd_list_parse(int argc, char **argv, const char *file, u_int line,
|
|
||||||
char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmd *cmd;
|
|
||||||
int i, lastsplit;
|
|
||||||
size_t arglen, new_argc;
|
|
||||||
char **copy_argv, **new_argv;
|
|
||||||
|
|
||||||
copy_argv = cmd_copy_argv(argc, argv);
|
|
||||||
|
|
||||||
cmdlist = xcalloc(1, sizeof *cmdlist);
|
|
||||||
cmdlist->references = 1;
|
|
||||||
TAILQ_INIT(&cmdlist->list);
|
|
||||||
|
|
||||||
lastsplit = 0;
|
|
||||||
for (i = 0; i < argc; i++) {
|
|
||||||
arglen = strlen(copy_argv[i]);
|
|
||||||
if (arglen == 0 || copy_argv[i][arglen - 1] != ';')
|
|
||||||
continue;
|
|
||||||
copy_argv[i][arglen - 1] = '\0';
|
|
||||||
|
|
||||||
if (arglen > 1 && copy_argv[i][arglen - 2] == '\\') {
|
|
||||||
copy_argv[i][arglen - 2] = ';';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_argc = i - lastsplit;
|
|
||||||
new_argv = copy_argv + lastsplit;
|
|
||||||
if (arglen != 1)
|
|
||||||
new_argc++;
|
|
||||||
|
|
||||||
cmd = cmd_parse(new_argc, new_argv, file, line, cause);
|
|
||||||
if (cmd == NULL)
|
|
||||||
goto bad;
|
|
||||||
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
|
||||||
|
|
||||||
lastsplit = i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastsplit != argc) {
|
|
||||||
cmd = cmd_parse(argc - lastsplit, copy_argv + lastsplit,
|
|
||||||
file, line, cause);
|
|
||||||
if (cmd == NULL)
|
|
||||||
goto bad;
|
|
||||||
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd_free_argv(argc, copy_argv);
|
|
||||||
return (cmdlist);
|
|
||||||
|
|
||||||
bad:
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
cmd_free_argv(argc, copy_argv);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_list_free(struct cmd_list *cmdlist)
|
|
||||||
{
|
|
||||||
struct cmd *cmd, *cmd1;
|
|
||||||
|
|
||||||
if (--cmdlist->references != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(cmd, &cmdlist->list, qentry, cmd1) {
|
|
||||||
TAILQ_REMOVE(&cmdlist->list, cmd, qentry);
|
|
||||||
args_free(cmd->args);
|
|
||||||
free(cmd->file);
|
|
||||||
free(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(cmdlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
cmd_list_print(struct cmd_list *cmdlist)
|
|
||||||
{
|
|
||||||
struct cmd *cmd;
|
|
||||||
char *buf, *this;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
len = 1;
|
|
||||||
buf = xcalloc(1, len);
|
|
||||||
|
|
||||||
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
|
||||||
this = cmd_print(cmd);
|
|
||||||
|
|
||||||
len += strlen(this) + 3;
|
|
||||||
buf = xrealloc(buf, len);
|
|
||||||
|
|
||||||
strlcat(buf, this, len);
|
|
||||||
if (TAILQ_NEXT(cmd, qentry) != NULL)
|
|
||||||
strlcat(buf, " ; ", len);
|
|
||||||
|
|
||||||
free(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (buf);
|
|
||||||
}
|
|
||||||
@@ -33,142 +33,81 @@
|
|||||||
|
|
||||||
static enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmdq_item *);
|
static enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
static 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 = {
|
||||||
.name = "load-buffer",
|
.name = "load-buffer",
|
||||||
.alias = "loadb",
|
.alias = "loadb",
|
||||||
|
|
||||||
.args = { "b:", 1, 1 },
|
.args = { "b:t:w", 1, 1, NULL },
|
||||||
.usage = CMD_BUFFER_USAGE " path",
|
.usage = CMD_BUFFER_USAGE " " CMD_TARGET_CLIENT_USAGE " path",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG|CMD_CLIENT_CANFAIL,
|
||||||
.exec = cmd_load_buffer_exec
|
.exec = cmd_load_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_load_buffer_data {
|
struct cmd_load_buffer_data {
|
||||||
|
struct client *client;
|
||||||
struct cmdq_item *item;
|
struct cmdq_item *item;
|
||||||
char *bufname;
|
char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_load_buffer_done(__unused struct client *c, const char *path, int error,
|
||||||
|
int closed, struct evbuffer *buffer, void *data)
|
||||||
|
{
|
||||||
|
struct cmd_load_buffer_data *cdata = data;
|
||||||
|
struct client *tc = cdata->client;
|
||||||
|
struct cmdq_item *item = cdata->item;
|
||||||
|
void *bdata = EVBUFFER_DATA(buffer);
|
||||||
|
size_t bsize = EVBUFFER_LENGTH(buffer);
|
||||||
|
void *copy;
|
||||||
|
char *cause;
|
||||||
|
|
||||||
|
if (!closed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (error != 0)
|
||||||
|
cmdq_error(item, "%s: %s", path, strerror(error));
|
||||||
|
else if (bsize != 0) {
|
||||||
|
copy = xmalloc(bsize);
|
||||||
|
memcpy(copy, bdata, bsize);
|
||||||
|
if (paste_set(copy, bsize, cdata->name, &cause) != 0) {
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
free(copy);
|
||||||
|
} else if (tc != NULL &&
|
||||||
|
tc->session != NULL &&
|
||||||
|
(~tc->flags & CLIENT_DEAD))
|
||||||
|
tty_set_selection(&tc->tty, "", copy, bsize);
|
||||||
|
if (tc != NULL)
|
||||||
|
server_client_unref(tc);
|
||||||
|
}
|
||||||
|
cmdq_continue(item);
|
||||||
|
|
||||||
|
free(cdata->name);
|
||||||
|
free(cdata);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct cmd_load_buffer_data *cdata;
|
struct cmd_load_buffer_data *cdata;
|
||||||
struct client *c = item->client;
|
const char *bufname = args_get(args, 'b');
|
||||||
FILE *f;
|
char *path;
|
||||||
const char *path, *bufname;
|
|
||||||
char *pdata, *new_pdata, *cause, *file;
|
|
||||||
size_t psize;
|
|
||||||
int ch, error;
|
|
||||||
|
|
||||||
bufname = NULL;
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
if (args_has(args, 'b'))
|
cdata->item = item;
|
||||||
bufname = args_get(args, 'b');
|
if (bufname != NULL)
|
||||||
|
cdata->name = xstrdup(bufname);
|
||||||
path = args->argv[0];
|
if (args_has(args, 'w') && tc != NULL) {
|
||||||
if (strcmp(path, "-") == 0) {
|
cdata->client = tc;
|
||||||
cdata = xcalloc(1, sizeof *cdata);
|
cdata->client->references++;
|
||||||
cdata->item = item;
|
|
||||||
|
|
||||||
if (bufname != NULL)
|
|
||||||
cdata->bufname = xstrdup(bufname);
|
|
||||||
|
|
||||||
error = server_set_stdin_callback(c, cmd_load_buffer_callback,
|
|
||||||
cdata, &cause);
|
|
||||||
if (error != 0) {
|
|
||||||
cmdq_error(item, "%s: %s", path, cause);
|
|
||||||
free(cause);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
return (CMD_RETURN_WAIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file = server_client_get_path(c, path);
|
path = format_single_from_target(item, args_string(args, 0));
|
||||||
f = fopen(file, "rb");
|
file_read(cmdq_get_client(item), path, cmd_load_buffer_done, cdata);
|
||||||
if (f == NULL) {
|
free(path);
|
||||||
cmdq_error(item, "%s: %s", file, strerror(errno));
|
|
||||||
free(file);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
pdata = NULL;
|
return (CMD_RETURN_WAIT);
|
||||||
psize = 0;
|
|
||||||
while ((ch = getc(f)) != EOF) {
|
|
||||||
/* Do not let the server die due to memory exhaustion. */
|
|
||||||
if ((new_pdata = realloc(pdata, psize + 2)) == NULL) {
|
|
||||||
cmdq_error(item, "realloc error: %s", strerror(errno));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
pdata = new_pdata;
|
|
||||||
pdata[psize++] = ch;
|
|
||||||
}
|
|
||||||
if (ferror(f)) {
|
|
||||||
cmdq_error(item, "%s: read error", file);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (pdata != NULL)
|
|
||||||
pdata[psize] = '\0';
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
free(file);
|
|
||||||
|
|
||||||
if (paste_set(pdata, psize, bufname, &cause) != 0) {
|
|
||||||
cmdq_error(item, "%s", cause);
|
|
||||||
free(pdata);
|
|
||||||
free(cause);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
|
|
||||||
error:
|
|
||||||
free(pdata);
|
|
||||||
if (f != NULL)
|
|
||||||
fclose(f);
|
|
||||||
free(file);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cmd_load_buffer_callback(struct client *c, int closed, void *data)
|
|
||||||
{
|
|
||||||
struct cmd_load_buffer_data *cdata = data;
|
|
||||||
char *pdata, *cause, *saved;
|
|
||||||
size_t psize;
|
|
||||||
|
|
||||||
if (!closed)
|
|
||||||
return;
|
|
||||||
c->stdin_callback = NULL;
|
|
||||||
|
|
||||||
server_client_unref(c);
|
|
||||||
if (c->flags & CLIENT_DEAD)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
psize = EVBUFFER_LENGTH(c->stdin_data);
|
|
||||||
if (psize == 0 || (pdata = malloc(psize + 1)) == NULL)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
memcpy(pdata, EVBUFFER_DATA(c->stdin_data), psize);
|
|
||||||
pdata[psize] = '\0';
|
|
||||||
evbuffer_drain(c->stdin_data, psize);
|
|
||||||
|
|
||||||
if (paste_set(pdata, psize, cdata->bufname, &cause) != 0) {
|
|
||||||
/* No context so can't use server_client_msg_error. */
|
|
||||||
if (~c->flags & CLIENT_UTF8) {
|
|
||||||
saved = cause;
|
|
||||||
cause = utf8_sanitize(saved);
|
|
||||||
free(saved);
|
|
||||||
}
|
|
||||||
evbuffer_add_printf(c->stderr_data, "%s", cause);
|
|
||||||
server_client_push_stderr(c);
|
|
||||||
free(pdata);
|
|
||||||
free(cause);
|
|
||||||
}
|
|
||||||
out:
|
|
||||||
cdata->item->flags &= ~CMDQ_WAITING;
|
|
||||||
|
|
||||||
free(cdata->bufname);
|
|
||||||
free(cdata);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const struct cmd_entry cmd_lock_server_entry = {
|
|||||||
.name = "lock-server",
|
.name = "lock-server",
|
||||||
.alias = "lock",
|
.alias = "lock",
|
||||||
|
|
||||||
.args = { "", 0, 0 },
|
.args = { "", 0, 0, NULL },
|
||||||
.usage = "",
|
.usage = "",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_lock_session_entry = {
|
|||||||
.name = "lock-session",
|
.name = "lock-session",
|
||||||
.alias = "locks",
|
.alias = "locks",
|
||||||
|
|
||||||
.args = { "t:", 0, 0 },
|
.args = { "t:", 0, 0, NULL },
|
||||||
.usage = CMD_TARGET_SESSION_USAGE,
|
.usage = CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||||
@@ -54,28 +54,25 @@ const struct cmd_entry cmd_lock_client_entry = {
|
|||||||
.name = "lock-client",
|
.name = "lock-client",
|
||||||
.alias = "lockc",
|
.alias = "lockc",
|
||||||
|
|
||||||
.args = { "t:", 0, 0 },
|
.args = { "t:", 0, 0, NULL },
|
||||||
.usage = CMD_TARGET_CLIENT_USAGE,
|
.usage = CMD_TARGET_CLIENT_USAGE,
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG,
|
||||||
.exec = cmd_lock_server_exec
|
.exec = cmd_lock_server_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_lock_server_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_lock_server_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct client *c;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
|
|
||||||
if (self->entry == &cmd_lock_server_entry)
|
if (cmd_get_entry(self) == &cmd_lock_server_entry)
|
||||||
server_lock();
|
server_lock();
|
||||||
else if (self->entry == &cmd_lock_session_entry)
|
else if (cmd_get_entry(self) == &cmd_lock_session_entry)
|
||||||
server_lock_session(item->target.s);
|
server_lock_session(target->s);
|
||||||
else {
|
else
|
||||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
server_lock_client(tc);
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
server_lock_client(c);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ const struct cmd_entry cmd_move_window_entry = {
|
|||||||
.name = "move-window",
|
.name = "move-window",
|
||||||
.alias = "movew",
|
.alias = "movew",
|
||||||
|
|
||||||
.args = { "adkrs:t:", 0, 0 },
|
.args = { "abdkrs:t:", 0, 0, NULL },
|
||||||
.usage = "[-dkr] " CMD_SRCDST_WINDOW_USAGE,
|
.usage = "[-abdkr] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
|
|
||||||
.source = { 's', CMD_FIND_WINDOW, 0 },
|
.source = { 's', CMD_FIND_WINDOW, 0 },
|
||||||
/* -t is special */
|
/* -t is special */
|
||||||
@@ -46,8 +46,8 @@ const struct cmd_entry cmd_link_window_entry = {
|
|||||||
.name = "link-window",
|
.name = "link-window",
|
||||||
.alias = "linkw",
|
.alias = "linkw",
|
||||||
|
|
||||||
.args = { "adks:t:", 0, 0 },
|
.args = { "abdks:t:", 0, 0, NULL },
|
||||||
.usage = "[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
.usage = "[-abdk] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
|
|
||||||
.source = { 's', CMD_FIND_WINDOW, 0 },
|
.source = { 's', CMD_FIND_WINDOW, 0 },
|
||||||
/* -t is special */
|
/* -t is special */
|
||||||
@@ -59,49 +59,53 @@ const struct cmd_entry cmd_link_window_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_move_window_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_move_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
const char *tflag = args_get(args, 't');
|
struct cmd_find_state *source = cmdq_get_source(item);
|
||||||
struct session *src;
|
struct cmd_find_state target;
|
||||||
struct session *dst;
|
const char *tflag = args_get(args, 't');
|
||||||
struct winlink *wl;
|
struct session *src = source->s;
|
||||||
char *cause;
|
struct session *dst;
|
||||||
int idx, kflag, dflag, sflag;
|
struct winlink *wl = source->wl;
|
||||||
|
char *cause;
|
||||||
|
int idx, kflag, dflag, sflag, before;
|
||||||
|
|
||||||
if (args_has(args, 'r')) {
|
if (args_has(args, 'r')) {
|
||||||
if (cmd_find_target(&item->target, item, tflag,
|
if (cmd_find_target(&target, item, tflag, CMD_FIND_SESSION,
|
||||||
CMD_FIND_SESSION, CMD_FIND_QUIET) != 0)
|
CMD_FIND_QUIET) != 0)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
session_renumber_windows(item->target.s);
|
session_renumber_windows(target.s);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_status_session(item->target.s);
|
server_status_session(target.s);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
if (cmd_find_target(&item->target, item, tflag, CMD_FIND_WINDOW,
|
if (cmd_find_target(&target, item, tflag, CMD_FIND_WINDOW,
|
||||||
CMD_FIND_WINDOW_INDEX) != 0)
|
CMD_FIND_WINDOW_INDEX) != 0)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
src = item->source.s;
|
dst = target.s;
|
||||||
dst = item->target.s;
|
idx = target.idx;
|
||||||
wl = item->source.wl;
|
|
||||||
idx = item->target.idx;
|
|
||||||
|
|
||||||
kflag = args_has(self->args, 'k');
|
kflag = args_has(args, 'k');
|
||||||
dflag = args_has(self->args, 'd');
|
dflag = args_has(args, 'd');
|
||||||
sflag = args_has(self->args, 's');
|
sflag = args_has(args, 's');
|
||||||
|
|
||||||
if (args_has(self->args, 'a')) {
|
before = args_has(args, 'b');
|
||||||
if ((idx = winlink_shuffle_up(dst, dst->curw)) == -1)
|
if (args_has(args, 'a') || before) {
|
||||||
|
if (target.wl != NULL)
|
||||||
|
idx = winlink_shuffle_up(dst, target.wl, before);
|
||||||
|
else
|
||||||
|
idx = winlink_shuffle_up(dst, dst->curw, before);
|
||||||
|
if (idx == -1)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag,
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||||
&cause) != 0) {
|
cmdq_error(item, "%s", cause);
|
||||||
cmdq_error(item, "can't link window: %s", cause);
|
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (self->entry == &cmd_move_window_entry)
|
if (cmd_get_entry(self) == &cmd_move_window_entry)
|
||||||
server_unlink_window(src, wl);
|
server_unlink_window(src, wl);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -39,10 +39,11 @@ const struct cmd_entry cmd_new_session_entry = {
|
|||||||
.name = "new-session",
|
.name = "new-session",
|
||||||
.alias = "new",
|
.alias = "new",
|
||||||
|
|
||||||
.args = { "Ac:dDEF:n:Ps:t:x:y:", 0, -1 },
|
.args = { "Ac:dDe:EF:f:n:Ps:t:x:Xy:", 0, -1, NULL },
|
||||||
.usage = "[-AdDEP] [-c start-directory] [-F format] [-n window-name] "
|
.usage = "[-AdDEPX] [-c start-directory] [-e environment] [-F format] "
|
||||||
"[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
|
"[-f flags] [-n window-name] [-s session-name] "
|
||||||
"[-y height] [command]",
|
CMD_TARGET_SESSION_USAGE " [-x width] [-y height] "
|
||||||
|
"[shell-command]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ const struct cmd_entry cmd_has_session_entry = {
|
|||||||
.name = "has-session",
|
.name = "has-session",
|
||||||
.alias = "has",
|
.alias = "has",
|
||||||
|
|
||||||
.args = { "t:", 0, 0 },
|
.args = { "t:", 0, 0, NULL },
|
||||||
.usage = CMD_TARGET_SESSION_USAGE,
|
.usage = CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||||
@@ -66,22 +67,26 @@ const struct cmd_entry cmd_has_session_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct client *c = item->client;
|
struct cmd_find_state *current = cmdq_get_current(item);
|
||||||
struct session *s, *as, *groupwith;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct window *w;
|
struct client *c = cmdq_get_client(item);
|
||||||
|
struct session *s, *as, *groupwith = NULL;
|
||||||
struct environ *env;
|
struct environ *env;
|
||||||
|
struct options *oo;
|
||||||
struct termios tio, *tiop;
|
struct termios tio, *tiop;
|
||||||
struct session_group *sg;
|
struct session_group *sg = NULL;
|
||||||
const char *newname, *errstr, *template, *group, *prefix;
|
const char *errstr, *template, *group, *tmp;
|
||||||
const char *path, *cmd, *cwd, *to_free = NULL;
|
char *cause, *cwd = NULL, *cp, *newname = NULL;
|
||||||
char **argv, *cause, *cp;
|
char *name, *prefix = NULL;
|
||||||
int detached, already_attached, idx, argc;
|
int detached, already_attached, is_control = 0;
|
||||||
u_int sx, sy;
|
u_int sx, sy, dsx, dsy, count = args_count(args);
|
||||||
struct environ_entry *envent;
|
struct spawn_context sc = { 0 };
|
||||||
struct cmd_find_state fs;
|
enum cmd_retval retval;
|
||||||
|
struct cmd_find_state fs;
|
||||||
|
struct args_value *av;
|
||||||
|
|
||||||
if (self->entry == &cmd_has_session_entry) {
|
if (cmd_get_entry(self) == &cmd_has_session_entry) {
|
||||||
/*
|
/*
|
||||||
* cmd_find_target() will fail if the session cannot be found,
|
* cmd_find_target() will fail if the session cannot be found,
|
||||||
* so always return success here.
|
* so always return success here.
|
||||||
@@ -89,56 +94,68 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) {
|
if (args_has(args, 't') && (count != 0 || args_has(args, 'n'))) {
|
||||||
cmdq_error(item, "command or window name given with target");
|
cmdq_error(item, "command or window name given with target");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
newname = args_get(args, 's');
|
tmp = args_get(args, 's');
|
||||||
if (newname != NULL) {
|
if (tmp != NULL) {
|
||||||
if (!session_check_name(newname)) {
|
name = format_single(item, tmp, c, NULL, NULL, NULL);
|
||||||
cmdq_error(item, "bad session name: %s", newname);
|
newname = session_check_name(name);
|
||||||
|
if (newname == NULL) {
|
||||||
|
cmdq_error(item, "invalid session: %s", name);
|
||||||
|
free(name);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if ((as = session_find(newname)) != NULL) {
|
free(name);
|
||||||
if (args_has(args, 'A')) {
|
}
|
||||||
return (cmd_attach_session(item,
|
if (args_has(args, 'A')) {
|
||||||
newname, args_has(args, 'D'),
|
if (newname != NULL)
|
||||||
0, NULL, args_has(args, 'E')));
|
as = session_find(newname);
|
||||||
}
|
else
|
||||||
cmdq_error(item, "duplicate session: %s", newname);
|
as = target->s;
|
||||||
return (CMD_RETURN_ERROR);
|
if (as != NULL) {
|
||||||
|
retval = cmd_attach_session(item, as->name,
|
||||||
|
args_has(args, 'D'), args_has(args, 'X'), 0, NULL,
|
||||||
|
args_has(args, 'E'), args_get(args, 'f'));
|
||||||
|
free(newname);
|
||||||
|
return (retval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (newname != NULL && session_find(newname) != NULL) {
|
||||||
|
cmdq_error(item, "duplicate session: %s", newname);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
/* Is this going to be part of a session group? */
|
/* Is this going to be part of a session group? */
|
||||||
group = args_get(args, 't');
|
group = args_get(args, 't');
|
||||||
if (group != NULL) {
|
if (group != NULL) {
|
||||||
groupwith = item->target.s;
|
groupwith = target->s;
|
||||||
if (groupwith == NULL) {
|
if (groupwith == NULL)
|
||||||
if (!session_check_name(group)) {
|
|
||||||
cmdq_error(item, "bad group name: %s", group);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
sg = session_group_find(group);
|
sg = session_group_find(group);
|
||||||
} else
|
else
|
||||||
sg = session_group_contains(groupwith);
|
sg = session_group_contains(groupwith);
|
||||||
if (sg != NULL)
|
if (sg != NULL)
|
||||||
prefix = sg->name;
|
prefix = xstrdup(sg->name);
|
||||||
else if (groupwith != NULL)
|
else if (groupwith != NULL)
|
||||||
prefix = groupwith->name;
|
prefix = xstrdup(groupwith->name);
|
||||||
else
|
else {
|
||||||
prefix = group;
|
prefix = session_check_name(group);
|
||||||
} else {
|
if (prefix == NULL) {
|
||||||
groupwith = NULL;
|
cmdq_error(item, "invalid session group: %s",
|
||||||
sg = NULL;
|
group);
|
||||||
prefix = NULL;
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set -d if no client. */
|
/* Set -d if no client. */
|
||||||
detached = args_has(args, 'd');
|
detached = args_has(args, 'd');
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
detached = 1;
|
detached = 1;
|
||||||
|
else if (c->flags & CLIENT_CONTROL)
|
||||||
|
is_control = 1;
|
||||||
|
|
||||||
/* Is this client already attached? */
|
/* Is this client already attached? */
|
||||||
already_attached = 0;
|
already_attached = 0;
|
||||||
@@ -146,13 +163,10 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
already_attached = 1;
|
already_attached = 1;
|
||||||
|
|
||||||
/* Get the new session working directory. */
|
/* Get the new session working directory. */
|
||||||
if (args_has(args, 'c')) {
|
if ((tmp = args_get(args, 'c')) != NULL)
|
||||||
cwd = args_get(args, 'c');
|
cwd = format_single(item, tmp, c, NULL, NULL, NULL);
|
||||||
to_free = cwd = format_single(item, cwd, c, NULL, NULL, NULL);
|
|
||||||
} else if (c != NULL && c->session == NULL && c->cwd != NULL)
|
|
||||||
cwd = c->cwd;
|
|
||||||
else
|
else
|
||||||
cwd = ".";
|
cwd = xstrdup(server_client_get_cwd(c, NULL));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is a new client, check for nesting and save the termios
|
* If this is a new client, check for nesting and save the termios
|
||||||
@@ -163,13 +177,16 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
* the terminal as that calls tcsetattr() to prepare for tmux taking
|
* the terminal as that calls tcsetattr() to prepare for tmux taking
|
||||||
* over.
|
* over.
|
||||||
*/
|
*/
|
||||||
if (!detached && !already_attached && c->tty.fd != -1) {
|
if (!detached &&
|
||||||
if (server_client_check_nested(item->client)) {
|
!already_attached &&
|
||||||
|
c->fd != -1 &&
|
||||||
|
(~c->flags & CLIENT_CONTROL)) {
|
||||||
|
if (server_client_check_nested(cmdq_get_client(item))) {
|
||||||
cmdq_error(item, "sessions should be nested with care, "
|
cmdq_error(item, "sessions should be nested with care, "
|
||||||
"unset $TMUX to force");
|
"unset $TMUX to force");
|
||||||
return (CMD_RETURN_ERROR);
|
goto fail;
|
||||||
}
|
}
|
||||||
if (tcgetattr(c->tty.fd, &tio) != 0)
|
if (tcgetattr(c->fd, &tio) != 0)
|
||||||
fatal("tcgetattr failed");
|
fatal("tcgetattr failed");
|
||||||
tiop = &tio;
|
tiop = &tio;
|
||||||
} else
|
} else
|
||||||
@@ -180,85 +197,105 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (server_client_open(c, &cause) != 0) {
|
if (server_client_open(c, &cause) != 0) {
|
||||||
cmdq_error(item, "open terminal failed: %s", cause);
|
cmdq_error(item, "open terminal failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
goto error;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get default session size. */
|
||||||
|
if (args_has(args, 'x')) {
|
||||||
|
tmp = args_get(args, 'x');
|
||||||
|
if (strcmp(tmp, "-") == 0) {
|
||||||
|
if (c != NULL)
|
||||||
|
dsx = c->tty.sx;
|
||||||
|
else
|
||||||
|
dsx = 80;
|
||||||
|
} else {
|
||||||
|
dsx = strtonum(tmp, 1, USHRT_MAX, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
cmdq_error(item, "width %s", errstr);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
dsx = 80;
|
||||||
|
if (args_has(args, 'y')) {
|
||||||
|
tmp = args_get(args, 'y');
|
||||||
|
if (strcmp(tmp, "-") == 0) {
|
||||||
|
if (c != NULL)
|
||||||
|
dsy = c->tty.sy;
|
||||||
|
else
|
||||||
|
dsy = 24;
|
||||||
|
} else {
|
||||||
|
dsy = strtonum(tmp, 1, USHRT_MAX, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
cmdq_error(item, "height %s", errstr);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
dsy = 24;
|
||||||
|
|
||||||
/* Find new session size. */
|
/* Find new session size. */
|
||||||
if (c != NULL) {
|
if (!detached && !is_control) {
|
||||||
sx = c->tty.sx;
|
sx = c->tty.sx;
|
||||||
sy = c->tty.sy;
|
sy = c->tty.sy;
|
||||||
|
if (sy > 0 && options_get_number(global_s_options, "status"))
|
||||||
|
sy--;
|
||||||
} else {
|
} else {
|
||||||
sx = 80;
|
tmp = options_get_string(global_s_options, "default-size");
|
||||||
sy = 24;
|
if (sscanf(tmp, "%ux%u", &sx, &sy) != 2) {
|
||||||
}
|
sx = dsx;
|
||||||
if (detached && args_has(args, 'x')) {
|
sy = dsy;
|
||||||
sx = strtonum(args_get(args, 'x'), 1, USHRT_MAX, &errstr);
|
} else {
|
||||||
if (errstr != NULL) {
|
if (args_has(args, 'x'))
|
||||||
cmdq_error(item, "width %s", errstr);
|
sx = dsx;
|
||||||
goto error;
|
if (args_has(args, 'y'))
|
||||||
|
sy = dsy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (detached && args_has(args, 'y')) {
|
|
||||||
sy = strtonum(args_get(args, 'y'), 1, USHRT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
cmdq_error(item, "height %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sy > 0 && options_get_number(global_s_options, "status"))
|
|
||||||
sy--;
|
|
||||||
if (sx == 0)
|
if (sx == 0)
|
||||||
sx = 1;
|
sx = 1;
|
||||||
if (sy == 0)
|
if (sy == 0)
|
||||||
sy = 1;
|
sy = 1;
|
||||||
|
|
||||||
/* Figure out the command for the new window. */
|
/* Create the new session. */
|
||||||
argc = -1;
|
oo = options_create(global_s_options);
|
||||||
argv = NULL;
|
if (args_has(args, 'x') || args_has(args, 'y')) {
|
||||||
if (!args_has(args, 't') && args->argc != 0) {
|
if (!args_has(args, 'x'))
|
||||||
argc = args->argc;
|
dsx = sx;
|
||||||
argv = args->argv;
|
if (!args_has(args, 'y'))
|
||||||
} else if (sg == NULL && groupwith == NULL) {
|
dsy = sy;
|
||||||
cmd = options_get_string(global_s_options, "default-command");
|
options_set_string(oo, "default-size", 0, "%ux%u", dsx, dsy);
|
||||||
if (cmd != NULL && *cmd != '\0') {
|
|
||||||
argc = 1;
|
|
||||||
argv = (char **)&cmd;
|
|
||||||
} else {
|
|
||||||
argc = 0;
|
|
||||||
argv = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
path = NULL;
|
|
||||||
if (c != NULL && c->session == NULL)
|
|
||||||
envent = environ_find(c->environ, "PATH");
|
|
||||||
else
|
|
||||||
envent = environ_find(global_environ, "PATH");
|
|
||||||
if (envent != NULL)
|
|
||||||
path = envent->value;
|
|
||||||
|
|
||||||
/* Construct the environment. */
|
|
||||||
env = environ_create();
|
env = environ_create();
|
||||||
if (c != NULL && !args_has(args, 'E'))
|
if (c != NULL && !args_has(args, 'E'))
|
||||||
environ_update(global_s_options, c->environ, env);
|
environ_update(global_s_options, c->environ, env);
|
||||||
|
av = args_first_value(args, 'e');
|
||||||
/* Create the new session. */
|
while (av != NULL) {
|
||||||
idx = -1 - options_get_number(global_s_options, "base-index");
|
environ_put(env, av->string, 0);
|
||||||
s = session_create(prefix, newname, argc, argv, path, cwd, env, tiop,
|
av = args_next_value(av);
|
||||||
idx, sx, sy, &cause);
|
|
||||||
environ_free(env);
|
|
||||||
if (s == NULL) {
|
|
||||||
cmdq_error(item, "create session failed: %s", cause);
|
|
||||||
free(cause);
|
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
s = session_create(prefix, newname, cwd, env, oo, tiop);
|
||||||
|
|
||||||
/* Set the initial window name if one given. */
|
/* Spawn the initial window. */
|
||||||
if (argc >= 0 && args_has(args, 'n')) {
|
sc.item = item;
|
||||||
w = s->curw->window;
|
sc.s = s;
|
||||||
window_set_name(w, args_get(args, 'n'));
|
if (!detached)
|
||||||
options_set_number(w->options, "automatic-rename", 0);
|
sc.tc = c;
|
||||||
|
|
||||||
|
sc.name = args_get(args, 'n');
|
||||||
|
args_to_vector(args, &sc.argc, &sc.argv);
|
||||||
|
|
||||||
|
sc.idx = -1;
|
||||||
|
sc.cwd = args_get(args, 'c');
|
||||||
|
|
||||||
|
sc.flags = 0;
|
||||||
|
|
||||||
|
if (spawn_window(&sc, &cause) == NULL) {
|
||||||
|
session_destroy(s, 0, __func__);
|
||||||
|
cmdq_error(item, "create window failed: %s", cause);
|
||||||
|
free(cause);
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -284,54 +321,50 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
* taking this session and needs to get MSG_READY and stay around.
|
* taking this session and needs to get MSG_READY and stay around.
|
||||||
*/
|
*/
|
||||||
if (!detached) {
|
if (!detached) {
|
||||||
|
if (args_has(args, 'f'))
|
||||||
|
server_client_set_flags(c, args_get(args, 'f'));
|
||||||
if (!already_attached) {
|
if (!already_attached) {
|
||||||
if (~c->flags & CLIENT_CONTROL)
|
if (~c->flags & CLIENT_CONTROL)
|
||||||
proc_send(c->peer, MSG_READY, -1, NULL, 0);
|
proc_send(c->peer, MSG_READY, -1, NULL, 0);
|
||||||
} else if (c->session != NULL)
|
} else if (c->session != NULL)
|
||||||
c->last_session = c->session;
|
c->last_session = c->session;
|
||||||
c->session = s;
|
server_client_set_session(c, s);
|
||||||
if (~item->shared->flags & CMDQ_SHARED_REPEAT)
|
if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT)
|
||||||
server_client_set_key_table(c, NULL);
|
server_client_set_key_table(c, NULL);
|
||||||
status_timer_start(c);
|
|
||||||
notify_client("client-session-changed", c);
|
|
||||||
session_update_activity(s, NULL);
|
|
||||||
gettimeofday(&s->last_attached_time, NULL);
|
|
||||||
server_redraw_client(c);
|
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
|
||||||
server_update_socket();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If there are still configuration file errors to display, put the new
|
|
||||||
* session's current window into more mode and display them now.
|
|
||||||
*/
|
|
||||||
if (cfg_finished)
|
|
||||||
cfg_show_causes(s);
|
|
||||||
|
|
||||||
/* Print if requested. */
|
/* Print if requested. */
|
||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = NEW_SESSION_TEMPLATE;
|
template = NEW_SESSION_TEMPLATE;
|
||||||
cp = format_single(item, template, c, s, NULL, NULL);
|
cp = format_single(item, template, c, s, s->curw, NULL);
|
||||||
cmdq_print(item, "%s", cp);
|
cmdq_print(item, "%s", cp);
|
||||||
free(cp);
|
free(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!detached) {
|
if (!detached)
|
||||||
c->flags |= CLIENT_ATTACHED;
|
c->flags |= CLIENT_ATTACHED;
|
||||||
cmd_find_from_session(&item->shared->current, s);
|
if (!args_has(args, 'd'))
|
||||||
}
|
cmd_find_from_session(current, s, 0);
|
||||||
|
|
||||||
if (to_free != NULL)
|
cmd_find_from_session(&fs, s, 0);
|
||||||
free((void *)to_free);
|
cmdq_insert_hook(s, item, &fs, "after-new-session");
|
||||||
|
|
||||||
cmd_find_from_session(&fs, s);
|
if (cfg_finished)
|
||||||
hooks_insert(s->hooks, item, &fs, "after-new-session");
|
cfg_show_causes(s);
|
||||||
|
|
||||||
|
if (sc.argv != NULL)
|
||||||
|
cmd_free_argv(sc.argc, sc.argv);
|
||||||
|
free(cwd);
|
||||||
|
free(newname);
|
||||||
|
free(prefix);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
error:
|
fail:
|
||||||
if (to_free != NULL)
|
if (sc.argv != NULL)
|
||||||
free((void *)to_free);
|
cmd_free_argv(sc.argc, sc.argv);
|
||||||
|
free(cwd);
|
||||||
|
free(newname);
|
||||||
|
free(prefix);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
172
cmd-new-window.c
172
cmd-new-window.c
@@ -38,9 +38,9 @@ const struct cmd_entry cmd_new_window_entry = {
|
|||||||
.name = "new-window",
|
.name = "new-window",
|
||||||
.alias = "neww",
|
.alias = "neww",
|
||||||
|
|
||||||
.args = { "ac:dF:kn:Pt:", 0, -1 },
|
.args = { "abc:de:F:kn:PSt:", 0, -1, NULL },
|
||||||
.usage = "[-adkP] [-c start-directory] [-F format] [-n window-name] "
|
.usage = "[-abdkPS] [-c start-directory] [-e environment] [-F format] "
|
||||||
CMD_TARGET_WINDOW_USAGE " [command]",
|
"[-n window-name] " CMD_TARGET_WINDOW_USAGE " [shell-command]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX },
|
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX },
|
||||||
|
|
||||||
@@ -51,89 +51,91 @@ const struct cmd_entry cmd_new_window_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct cmd_find_state *current = &item->shared->current;
|
struct client *c = cmdq_get_client(item);
|
||||||
struct session *s = item->target.s;
|
struct cmd_find_state *current = cmdq_get_current(item);
|
||||||
struct winlink *wl = item->target.wl;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
struct spawn_context sc = { 0 };
|
||||||
int idx = item->target.idx;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
const char *cmd, *path, *template, *cwd, *to_free;
|
struct session *s = target->s;
|
||||||
char **argv, *cause, *cp;
|
struct winlink *wl = target->wl, *new_wl = NULL;
|
||||||
int argc, detached;
|
int idx = target->idx, before;
|
||||||
struct environ_entry *envent;
|
char *cause = NULL, *cp, *expanded;
|
||||||
|
const char *template, *name;
|
||||||
struct cmd_find_state fs;
|
struct cmd_find_state fs;
|
||||||
|
struct args_value *av;
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
/*
|
||||||
if ((idx = winlink_shuffle_up(s, wl)) == -1) {
|
* If -S and -n are given and -t is not and a single window with this
|
||||||
cmdq_error(item, "no free window indexes");
|
* name already exists, select it.
|
||||||
|
*/
|
||||||
|
name = args_get(args, 'n');
|
||||||
|
if (args_has(args, 'S') && name != NULL && target->idx == -1) {
|
||||||
|
expanded = format_single(item, name, c, s, NULL, NULL);
|
||||||
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
|
if (strcmp(wl->window->name, expanded) != 0)
|
||||||
|
continue;
|
||||||
|
if (new_wl == NULL) {
|
||||||
|
new_wl = wl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
cmdq_error(item, "multiple windows named %s", name);
|
||||||
|
free(expanded);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
free(expanded);
|
||||||
detached = args_has(args, 'd');
|
if (new_wl != NULL) {
|
||||||
|
if (args_has(args, 'd'))
|
||||||
if (args->argc == 0) {
|
return (CMD_RETURN_NORMAL);
|
||||||
cmd = options_get_string(s->options, "default-command");
|
if (session_set_current(s, new_wl) == 0)
|
||||||
if (cmd != NULL && *cmd != '\0') {
|
server_redraw_session(s);
|
||||||
argc = 1;
|
if (c != NULL && c->session != NULL)
|
||||||
argv = (char **)&cmd;
|
s->curw->window->latest = c;
|
||||||
} else {
|
recalculate_sizes();
|
||||||
argc = 0;
|
return (CMD_RETURN_NORMAL);
|
||||||
argv = NULL;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
argc = args->argc;
|
|
||||||
argv = args->argv;
|
|
||||||
}
|
|
||||||
|
|
||||||
path = NULL;
|
|
||||||
if (item->client != NULL && item->client->session == NULL)
|
|
||||||
envent = environ_find(item->client->environ, "PATH");
|
|
||||||
else
|
|
||||||
envent = environ_find(s->environ, "PATH");
|
|
||||||
if (envent != NULL)
|
|
||||||
path = envent->value;
|
|
||||||
|
|
||||||
to_free = NULL;
|
|
||||||
if (args_has(args, 'c')) {
|
|
||||||
cwd = args_get(args, 'c');
|
|
||||||
to_free = cwd = format_single(item, cwd, c, s, NULL, NULL);
|
|
||||||
} else if (item->client != NULL && item->client->session == NULL)
|
|
||||||
cwd = item->client->cwd;
|
|
||||||
else
|
|
||||||
cwd = s->cwd;
|
|
||||||
|
|
||||||
wl = NULL;
|
|
||||||
if (idx != -1)
|
|
||||||
wl = winlink_find_by_index(&s->windows, idx);
|
|
||||||
if (wl != NULL && args_has(args, 'k')) {
|
|
||||||
/*
|
|
||||||
* Can't use session_detach as it will destroy session if this
|
|
||||||
* makes it empty.
|
|
||||||
*/
|
|
||||||
notify_session_window("window-unlinked", s, wl->window);
|
|
||||||
wl->flags &= ~WINLINK_ALERTFLAGS;
|
|
||||||
winlink_stack_remove(&s->lastw, wl);
|
|
||||||
winlink_remove(&s->windows, wl);
|
|
||||||
|
|
||||||
/* Force select/redraw if current. */
|
|
||||||
if (wl == s->curw) {
|
|
||||||
detached = 0;
|
|
||||||
s->curw = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idx == -1)
|
before = args_has(args, 'b');
|
||||||
idx = -1 - options_get_number(s->options, "base-index");
|
if (args_has(args, 'a') || before) {
|
||||||
wl = session_new(s, args_get(args, 'n'), argc, argv, path, cwd, idx,
|
idx = winlink_shuffle_up(s, wl, before);
|
||||||
&cause);
|
if (idx == -1)
|
||||||
if (wl == NULL) {
|
idx = target->idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
sc.item = item;
|
||||||
|
sc.s = s;
|
||||||
|
sc.tc = tc;
|
||||||
|
|
||||||
|
sc.name = args_get(args, 'n');
|
||||||
|
args_to_vector(args, &sc.argc, &sc.argv);
|
||||||
|
sc.environ = environ_create();
|
||||||
|
|
||||||
|
av = args_first_value(args, 'e');
|
||||||
|
while (av != NULL) {
|
||||||
|
environ_put(sc.environ, av->string, 0);
|
||||||
|
av = args_next_value(av);
|
||||||
|
}
|
||||||
|
|
||||||
|
sc.idx = idx;
|
||||||
|
sc.cwd = args_get(args, 'c');
|
||||||
|
|
||||||
|
sc.flags = 0;
|
||||||
|
if (args_has(args, 'd'))
|
||||||
|
sc.flags |= SPAWN_DETACHED;
|
||||||
|
if (args_has(args, 'k'))
|
||||||
|
sc.flags |= SPAWN_KILL;
|
||||||
|
|
||||||
|
if ((new_wl = spawn_window(&sc, &cause)) == NULL) {
|
||||||
cmdq_error(item, "create window failed: %s", cause);
|
cmdq_error(item, "create window failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
goto error;
|
if (sc.argv != NULL)
|
||||||
|
cmd_free_argv(sc.argc, sc.argv);
|
||||||
|
environ_free(sc.environ);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (!detached) {
|
if (!args_has(args, 'd') || new_wl == s->curw) {
|
||||||
session_select(s, wl->idx);
|
cmd_find_from_winlink(current, new_wl, 0);
|
||||||
cmd_find_from_winlink(current, wl);
|
|
||||||
server_redraw_session_group(s);
|
server_redraw_session_group(s);
|
||||||
} else
|
} else
|
||||||
server_status_session_group(s);
|
server_status_session_group(s);
|
||||||
@@ -141,21 +143,17 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = NEW_WINDOW_TEMPLATE;
|
template = NEW_WINDOW_TEMPLATE;
|
||||||
cp = format_single(item, template, c, s, wl, NULL);
|
cp = format_single(item, template, tc, s, new_wl,
|
||||||
|
new_wl->window->active);
|
||||||
cmdq_print(item, "%s", cp);
|
cmdq_print(item, "%s", cp);
|
||||||
free(cp);
|
free(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_free != NULL)
|
cmd_find_from_winlink(&fs, new_wl, 0);
|
||||||
free((void *)to_free);
|
cmdq_insert_hook(s, item, &fs, "after-new-window");
|
||||||
|
|
||||||
cmd_find_from_winlink(&fs, wl);
|
|
||||||
hooks_insert(s->hooks, item, &fs, "after-new-window");
|
|
||||||
|
|
||||||
|
if (sc.argv != NULL)
|
||||||
|
cmd_free_argv(sc.argc, sc.argv);
|
||||||
|
environ_free(sc.environ);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
error:
|
|
||||||
if (to_free != NULL)
|
|
||||||
free((void *)to_free);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|||||||
1734
cmd-parse.y
Normal file
1734
cmd-parse.y
Normal file
File diff suppressed because it is too large
Load Diff
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_paste_buffer_entry = {
|
|||||||
.name = "paste-buffer",
|
.name = "paste-buffer",
|
||||||
.alias = "pasteb",
|
.alias = "pasteb",
|
||||||
|
|
||||||
.args = { "db:prs:t:", 0, 0 },
|
.args = { "db:prs:t:", 0, 0, NULL },
|
||||||
.usage = "[-dpr] [-s separator] " CMD_BUFFER_USAGE " "
|
.usage = "[-dpr] [-s separator] " CMD_BUFFER_USAGE " "
|
||||||
CMD_TARGET_PANE_USAGE,
|
CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
@@ -46,13 +46,19 @@ const struct cmd_entry cmd_paste_buffer_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct window_pane *wp = item->target.wp;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct window_pane *wp = target->wp;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
const char *sepstr, *bufname, *bufdata, *bufend, *line;
|
const char *sepstr, *bufname, *bufdata, *bufend, *line;
|
||||||
size_t seplen, bufsize;
|
size_t seplen, bufsize;
|
||||||
int bracket = args_has(args, 'p');
|
int bracket = args_has(args, 'p');
|
||||||
|
|
||||||
|
if (window_pane_exited(wp)) {
|
||||||
|
cmdq_error(item, "target pane has exited");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
bufname = NULL;
|
bufname = NULL;
|
||||||
if (args_has(args, 'b'))
|
if (args_has(args, 'b'))
|
||||||
bufname = args_get(args, 'b');
|
bufname = args_get(args, 'b');
|
||||||
|
|||||||
141
cmd-pipe-pane.c
141
cmd-pipe-pane.c
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@@ -34,14 +35,16 @@
|
|||||||
|
|
||||||
static enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmdq_item *);
|
static enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
|
static void cmd_pipe_pane_read_callback(struct bufferevent *, void *);
|
||||||
|
static void cmd_pipe_pane_write_callback(struct bufferevent *, void *);
|
||||||
static void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
|
static 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 = {
|
||||||
.name = "pipe-pane",
|
.name = "pipe-pane",
|
||||||
.alias = "pipep",
|
.alias = "pipep",
|
||||||
|
|
||||||
.args = { "ot:", 0, 1 },
|
.args = { "IOot:", 0, 1, NULL },
|
||||||
.usage = "[-o] " CMD_TARGET_PANE_USAGE " [command]",
|
.usage = "[-IOo] " CMD_TARGET_PANE_USAGE " [shell-command]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
@@ -52,14 +55,23 @@ const struct cmd_entry cmd_pipe_pane_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct window_pane *wp = item->target.wp;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct session *s = item->target.s;
|
struct window_pane *wp = target->wp;
|
||||||
struct winlink *wl = item->target.wl;
|
struct session *s = target->s;
|
||||||
char *cmd;
|
struct winlink *wl = target->wl;
|
||||||
int old_fd, pipe_fd[2], null_fd;
|
struct window_pane_offset *wpo = &wp->pipe_offset;
|
||||||
struct format_tree *ft;
|
char *cmd;
|
||||||
|
int old_fd, pipe_fd[2], null_fd, in, out;
|
||||||
|
struct format_tree *ft;
|
||||||
|
sigset_t set, oldset;
|
||||||
|
|
||||||
|
/* Do nothing if pane is dead. */
|
||||||
|
if (window_pane_exited(wp)) {
|
||||||
|
cmdq_error(item, "target pane has exited");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
/* Destroy the old pipe. */
|
/* Destroy the old pipe. */
|
||||||
old_fd = wp->pipe_fd;
|
old_fd = wp->pipe_fd;
|
||||||
@@ -67,10 +79,15 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
bufferevent_free(wp->pipe_event);
|
bufferevent_free(wp->pipe_event);
|
||||||
close(wp->pipe_fd);
|
close(wp->pipe_fd);
|
||||||
wp->pipe_fd = -1;
|
wp->pipe_fd = -1;
|
||||||
|
|
||||||
|
if (window_pane_destroy_ready(wp)) {
|
||||||
|
server_destroy_pane(wp, 1);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no pipe command, that is enough. */
|
/* If no pipe command, that is enough. */
|
||||||
if (args->argc == 0 || *args->argv[0] == '\0')
|
if (args_count(args) == 0 || *args_string(args, 0) == '\0')
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -79,9 +96,18 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
*
|
*
|
||||||
* bind ^p pipep -o 'cat >>~/output'
|
* bind ^p pipep -o 'cat >>~/output'
|
||||||
*/
|
*/
|
||||||
if (args_has(self->args, 'o') && old_fd != -1)
|
if (args_has(args, 'o') && old_fd != -1)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
/* What do we want to do? Neither -I or -O is -O. */
|
||||||
|
if (args_has(args, 'I')) {
|
||||||
|
in = 1;
|
||||||
|
out = args_has(args, 'O');
|
||||||
|
} else {
|
||||||
|
in = 0;
|
||||||
|
out = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* 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) {
|
||||||
cmdq_error(item, "socketpair error: %s", strerror(errno));
|
cmdq_error(item, "socketpair error: %s", strerror(errno));
|
||||||
@@ -89,65 +115,116 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Expand the command. */
|
/* Expand the command. */
|
||||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
|
||||||
format_defaults(ft, c, s, wl, wp);
|
format_defaults(ft, tc, s, wl, wp);
|
||||||
cmd = format_expand_time(ft, args->argv[0], time(NULL));
|
cmd = format_expand_time(ft, args_string(args, 0));
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|
||||||
/* Fork the child. */
|
/* Fork the child. */
|
||||||
|
sigfillset(&set);
|
||||||
|
sigprocmask(SIG_BLOCK, &set, &oldset);
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
|
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||||
cmdq_error(item, "fork error: %s", strerror(errno));
|
cmdq_error(item, "fork error: %s", strerror(errno));
|
||||||
|
|
||||||
free(cmd);
|
free(cmd);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
case 0:
|
case 0:
|
||||||
/* Child process. */
|
/* Child process. */
|
||||||
|
proc_clear_signals(server_proc, 1);
|
||||||
|
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||||
close(pipe_fd[0]);
|
close(pipe_fd[0]);
|
||||||
clear_signals(1);
|
|
||||||
|
|
||||||
if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
|
null_fd = open(_PATH_DEVNULL, O_WRONLY);
|
||||||
_exit(1);
|
if (out) {
|
||||||
if (pipe_fd[1] != STDIN_FILENO)
|
if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
|
||||||
close(pipe_fd[1]);
|
_exit(1);
|
||||||
|
} else {
|
||||||
null_fd = open(_PATH_DEVNULL, O_WRONLY, 0);
|
if (dup2(null_fd, STDIN_FILENO) == -1)
|
||||||
if (dup2(null_fd, STDOUT_FILENO) == -1)
|
_exit(1);
|
||||||
_exit(1);
|
}
|
||||||
|
if (in) {
|
||||||
|
if (dup2(pipe_fd[1], STDOUT_FILENO) == -1)
|
||||||
|
_exit(1);
|
||||||
|
if (pipe_fd[1] != STDOUT_FILENO)
|
||||||
|
close(pipe_fd[1]);
|
||||||
|
} else {
|
||||||
|
if (dup2(null_fd, STDOUT_FILENO) == -1)
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
if (dup2(null_fd, STDERR_FILENO) == -1)
|
if (dup2(null_fd, STDERR_FILENO) == -1)
|
||||||
_exit(1);
|
_exit(1);
|
||||||
if (null_fd != STDOUT_FILENO && null_fd != STDERR_FILENO)
|
|
||||||
close(null_fd);
|
|
||||||
|
|
||||||
closefrom(STDERR_FILENO + 1);
|
closefrom(STDERR_FILENO + 1);
|
||||||
|
|
||||||
execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);
|
execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
default:
|
default:
|
||||||
/* Parent process. */
|
/* Parent process. */
|
||||||
|
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||||
close(pipe_fd[1]);
|
close(pipe_fd[1]);
|
||||||
|
|
||||||
wp->pipe_fd = pipe_fd[0];
|
wp->pipe_fd = pipe_fd[0];
|
||||||
wp->pipe_off = EVBUFFER_LENGTH(wp->event->input);
|
memcpy(wpo, &wp->offset, sizeof *wpo);
|
||||||
|
|
||||||
wp->pipe_event = bufferevent_new(wp->pipe_fd,
|
|
||||||
NULL, NULL, cmd_pipe_pane_error_callback, wp);
|
|
||||||
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
|
||||||
|
|
||||||
setblocking(wp->pipe_fd, 0);
|
setblocking(wp->pipe_fd, 0);
|
||||||
|
wp->pipe_event = bufferevent_new(wp->pipe_fd,
|
||||||
|
cmd_pipe_pane_read_callback,
|
||||||
|
cmd_pipe_pane_write_callback,
|
||||||
|
cmd_pipe_pane_error_callback,
|
||||||
|
wp);
|
||||||
|
if (wp->pipe_event == NULL)
|
||||||
|
fatalx("out of memory");
|
||||||
|
if (out)
|
||||||
|
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
||||||
|
if (in)
|
||||||
|
bufferevent_enable(wp->pipe_event, EV_READ);
|
||||||
|
|
||||||
free(cmd);
|
free(cmd);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_pipe_pane_read_callback(__unused struct bufferevent *bufev, void *data)
|
||||||
|
{
|
||||||
|
struct window_pane *wp = data;
|
||||||
|
struct evbuffer *evb = wp->pipe_event->input;
|
||||||
|
size_t available;
|
||||||
|
|
||||||
|
available = EVBUFFER_LENGTH(evb);
|
||||||
|
log_debug("%%%u pipe read %zu", wp->id, available);
|
||||||
|
|
||||||
|
bufferevent_write(wp->event, EVBUFFER_DATA(evb), available);
|
||||||
|
evbuffer_drain(evb, available);
|
||||||
|
|
||||||
|
if (window_pane_destroy_ready(wp))
|
||||||
|
server_destroy_pane(wp, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_pipe_pane_write_callback(__unused struct bufferevent *bufev, void *data)
|
||||||
|
{
|
||||||
|
struct window_pane *wp = data;
|
||||||
|
|
||||||
|
log_debug("%%%u pipe empty", wp->id);
|
||||||
|
|
||||||
|
if (window_pane_destroy_ready(wp))
|
||||||
|
server_destroy_pane(wp, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cmd_pipe_pane_error_callback(__unused struct bufferevent *bufev,
|
cmd_pipe_pane_error_callback(__unused struct bufferevent *bufev,
|
||||||
__unused short what, void *data)
|
__unused short what, void *data)
|
||||||
{
|
{
|
||||||
struct window_pane *wp = data;
|
struct window_pane *wp = data;
|
||||||
|
|
||||||
|
log_debug("%%%u pipe error", wp->id);
|
||||||
|
|
||||||
bufferevent_free(wp->pipe_event);
|
bufferevent_free(wp->pipe_event);
|
||||||
close(wp->pipe_fd);
|
close(wp->pipe_fd);
|
||||||
wp->pipe_fd = -1;
|
wp->pipe_fd = -1;
|
||||||
|
|
||||||
|
if (window_pane_destroy_ready(wp))
|
||||||
|
server_destroy_pane(wp, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
701
cmd-queue.c
701
cmd-queue.c
@@ -19,24 +19,90 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <pwd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/* Global command queue. */
|
/* Command queue flags. */
|
||||||
static struct cmdq_list global_queue = TAILQ_HEAD_INITIALIZER(global_queue);
|
#define CMDQ_FIRED 0x1
|
||||||
|
#define CMDQ_WAITING 0x2
|
||||||
|
|
||||||
|
/* Command queue item type. */
|
||||||
|
enum cmdq_type {
|
||||||
|
CMDQ_COMMAND,
|
||||||
|
CMDQ_CALLBACK,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Command queue item. */
|
||||||
|
struct cmdq_item {
|
||||||
|
char *name;
|
||||||
|
struct cmdq_list *queue;
|
||||||
|
struct cmdq_item *next;
|
||||||
|
|
||||||
|
struct client *client;
|
||||||
|
struct client *target_client;
|
||||||
|
|
||||||
|
enum cmdq_type type;
|
||||||
|
u_int group;
|
||||||
|
|
||||||
|
u_int number;
|
||||||
|
time_t time;
|
||||||
|
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
struct cmdq_state *state;
|
||||||
|
struct cmd_find_state source;
|
||||||
|
struct cmd_find_state target;
|
||||||
|
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
struct cmd *cmd;
|
||||||
|
|
||||||
|
cmdq_cb cb;
|
||||||
|
void *data;
|
||||||
|
|
||||||
|
TAILQ_ENTRY(cmdq_item) entry;
|
||||||
|
};
|
||||||
|
TAILQ_HEAD(cmdq_item_list, cmdq_item);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Command queue state. This is the context for commands on the command queue.
|
||||||
|
* It holds information about how the commands were fired (the key and flags),
|
||||||
|
* any additional formats for the commands, and the current default target.
|
||||||
|
* Multiple commands can share the same state and a command may update the
|
||||||
|
* default target.
|
||||||
|
*/
|
||||||
|
struct cmdq_state {
|
||||||
|
int references;
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
struct format_tree *formats;
|
||||||
|
|
||||||
|
struct key_event event;
|
||||||
|
struct cmd_find_state current;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Command queue. */
|
||||||
|
struct cmdq_list {
|
||||||
|
struct cmdq_item *item;
|
||||||
|
struct cmdq_item_list list;
|
||||||
|
};
|
||||||
|
|
||||||
/* Get command queue name. */
|
/* Get command queue name. */
|
||||||
static const char *
|
static const char *
|
||||||
cmdq_name(struct client *c)
|
cmdq_name(struct client *c)
|
||||||
{
|
{
|
||||||
static char s[32];
|
static char s[256];
|
||||||
|
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
return ("<global>");
|
return ("<global>");
|
||||||
xsnprintf(s, sizeof s, "<%p>", c);
|
if (c->name != NULL)
|
||||||
|
xsnprintf(s, sizeof s, "<%s>", c->name);
|
||||||
|
else
|
||||||
|
xsnprintf(s, sizeof s, "<%p>", c);
|
||||||
return (s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,13 +110,194 @@ cmdq_name(struct client *c)
|
|||||||
static struct cmdq_list *
|
static struct cmdq_list *
|
||||||
cmdq_get(struct client *c)
|
cmdq_get(struct client *c)
|
||||||
{
|
{
|
||||||
if (c == NULL)
|
static struct cmdq_list *global_queue;
|
||||||
return (&global_queue);
|
|
||||||
return (&c->queue);
|
if (c == NULL) {
|
||||||
|
if (global_queue == NULL)
|
||||||
|
global_queue = cmdq_new();
|
||||||
|
return (global_queue);
|
||||||
|
}
|
||||||
|
return (c->queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a queue. */
|
||||||
|
struct cmdq_list *
|
||||||
|
cmdq_new(void)
|
||||||
|
{
|
||||||
|
struct cmdq_list *queue;
|
||||||
|
|
||||||
|
queue = xcalloc(1, sizeof *queue);
|
||||||
|
TAILQ_INIT (&queue->list);
|
||||||
|
return (queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free a queue. */
|
||||||
|
void
|
||||||
|
cmdq_free(struct cmdq_list *queue)
|
||||||
|
{
|
||||||
|
if (!TAILQ_EMPTY(&queue->list))
|
||||||
|
fatalx("queue not empty");
|
||||||
|
free(queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get item name. */
|
||||||
|
const char *
|
||||||
|
cmdq_get_name(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
return (item->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get item client. */
|
||||||
|
struct client *
|
||||||
|
cmdq_get_client(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
return (item->client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get item target client. */
|
||||||
|
struct client *
|
||||||
|
cmdq_get_target_client(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
return (item->target_client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get item state. */
|
||||||
|
struct cmdq_state *
|
||||||
|
cmdq_get_state(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
return (item->state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get item target. */
|
||||||
|
struct cmd_find_state *
|
||||||
|
cmdq_get_target(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
return (&item->target);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get item source. */
|
||||||
|
struct cmd_find_state *
|
||||||
|
cmdq_get_source(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
return (&item->source);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get state event. */
|
||||||
|
struct key_event *
|
||||||
|
cmdq_get_event(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
return (&item->state->event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get state current target. */
|
||||||
|
struct cmd_find_state *
|
||||||
|
cmdq_get_current(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
return (&item->state->current);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get state flags. */
|
||||||
|
int
|
||||||
|
cmdq_get_flags(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
return (item->state->flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a new state. */
|
||||||
|
struct cmdq_state *
|
||||||
|
cmdq_new_state(struct cmd_find_state *current, struct key_event *event,
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
struct cmdq_state *state;
|
||||||
|
|
||||||
|
state = xcalloc(1, sizeof *state);
|
||||||
|
state->references = 1;
|
||||||
|
state->flags = flags;
|
||||||
|
|
||||||
|
if (event != NULL)
|
||||||
|
memcpy(&state->event, event, sizeof state->event);
|
||||||
|
else
|
||||||
|
state->event.key = KEYC_NONE;
|
||||||
|
if (current != NULL && cmd_find_valid_state(current))
|
||||||
|
cmd_find_copy_state(&state->current, current);
|
||||||
|
else
|
||||||
|
cmd_find_clear_state(&state->current, 0);
|
||||||
|
|
||||||
|
return (state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add a reference to a state. */
|
||||||
|
struct cmdq_state *
|
||||||
|
cmdq_link_state(struct cmdq_state *state)
|
||||||
|
{
|
||||||
|
state->references++;
|
||||||
|
return (state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make a copy of a state. */
|
||||||
|
struct cmdq_state *
|
||||||
|
cmdq_copy_state(struct cmdq_state *state, struct cmd_find_state *current)
|
||||||
|
{
|
||||||
|
if (current != NULL)
|
||||||
|
return (cmdq_new_state(current, &state->event, state->flags));
|
||||||
|
return (cmdq_new_state(&state->current, &state->event, state->flags));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free a state. */
|
||||||
|
void
|
||||||
|
cmdq_free_state(struct cmdq_state *state)
|
||||||
|
{
|
||||||
|
if (--state->references != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (state->formats != NULL)
|
||||||
|
format_free(state->formats);
|
||||||
|
free(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add a format to command queue. */
|
||||||
|
void
|
||||||
|
cmdq_add_format(struct cmdq_state *state, const char *key, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
char *value;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
xvasprintf(&value, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (state->formats == NULL)
|
||||||
|
state->formats = format_create(NULL, NULL, FORMAT_NONE, 0);
|
||||||
|
format_add(state->formats, key, "%s", value);
|
||||||
|
|
||||||
|
free(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add formats to command queue. */
|
||||||
|
void
|
||||||
|
cmdq_add_formats(struct cmdq_state *state, struct format_tree *ft)
|
||||||
|
{
|
||||||
|
if (state->formats == NULL)
|
||||||
|
state->formats = format_create(NULL, NULL, FORMAT_NONE, 0);
|
||||||
|
format_merge(state->formats, ft);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Merge formats from item. */
|
||||||
|
void
|
||||||
|
cmdq_merge_formats(struct cmdq_item *item, struct format_tree *ft)
|
||||||
|
{
|
||||||
|
const struct cmd_entry *entry;
|
||||||
|
|
||||||
|
if (item->cmd != NULL) {
|
||||||
|
entry = cmd_get_entry(item->cmd);
|
||||||
|
format_add(ft, "command", "%s", entry->name);
|
||||||
|
}
|
||||||
|
if (item->state->formats != NULL)
|
||||||
|
format_merge(ft, item->state->formats);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append an item. */
|
/* Append an item. */
|
||||||
void
|
struct cmdq_item *
|
||||||
cmdq_append(struct client *c, struct cmdq_item *item)
|
cmdq_append(struct client *c, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct cmdq_list *queue = cmdq_get(c);
|
struct cmdq_list *queue = cmdq_get(c);
|
||||||
@@ -65,14 +312,16 @@ cmdq_append(struct client *c, struct cmdq_item *item)
|
|||||||
item->client = c;
|
item->client = c;
|
||||||
|
|
||||||
item->queue = queue;
|
item->queue = queue;
|
||||||
TAILQ_INSERT_TAIL(queue, item, entry);
|
TAILQ_INSERT_TAIL(&queue->list, item, entry);
|
||||||
|
log_debug("%s %s: %s", __func__, cmdq_name(c), item->name);
|
||||||
|
|
||||||
item = next;
|
item = next;
|
||||||
} while (item != NULL);
|
} while (item != NULL);
|
||||||
|
return (TAILQ_LAST(&queue->list, cmdq_item_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert an item. */
|
/* Insert an item. */
|
||||||
void
|
struct cmdq_item *
|
||||||
cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item)
|
cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct client *c = after->client;
|
struct client *c = after->client;
|
||||||
@@ -81,60 +330,149 @@ cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
next = item->next;
|
next = item->next;
|
||||||
item->next = NULL;
|
item->next = after->next;
|
||||||
|
after->next = item;
|
||||||
|
|
||||||
if (c != NULL)
|
if (c != NULL)
|
||||||
c->references++;
|
c->references++;
|
||||||
item->client = c;
|
item->client = c;
|
||||||
|
|
||||||
item->queue = queue;
|
item->queue = queue;
|
||||||
if (after->next != NULL)
|
TAILQ_INSERT_AFTER(&queue->list, after, item, entry);
|
||||||
TAILQ_INSERT_AFTER(queue, after->next, item, entry);
|
log_debug("%s %s: %s after %s", __func__, cmdq_name(c),
|
||||||
else
|
item->name, after->name);
|
||||||
TAILQ_INSERT_AFTER(queue, after, item, entry);
|
|
||||||
after->next = item;
|
|
||||||
|
|
||||||
|
after = item;
|
||||||
item = next;
|
item = next;
|
||||||
} while (item != NULL);
|
} while (item != NULL);
|
||||||
|
return (after);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Insert a hook. */
|
||||||
|
void
|
||||||
|
cmdq_insert_hook(struct session *s, struct cmdq_item *item,
|
||||||
|
struct cmd_find_state *current, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
struct cmdq_state *state = item->state;
|
||||||
|
struct cmd *cmd = item->cmd;
|
||||||
|
struct args *args = cmd_get_args(cmd);
|
||||||
|
struct args_entry *ae;
|
||||||
|
struct args_value *av;
|
||||||
|
struct options *oo;
|
||||||
|
va_list ap;
|
||||||
|
char *name, tmp[32], flag, *arguments;
|
||||||
|
u_int i;
|
||||||
|
const char *value;
|
||||||
|
struct cmdq_item *new_item;
|
||||||
|
struct cmdq_state *new_state;
|
||||||
|
struct options_entry *o;
|
||||||
|
struct options_array_item *a;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
|
||||||
|
if (item->state->flags & CMDQ_STATE_NOHOOKS)
|
||||||
|
return;
|
||||||
|
if (s == NULL)
|
||||||
|
oo = global_s_options;
|
||||||
|
else
|
||||||
|
oo = s->options;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
xvasprintf(&name, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
o = options_get(oo, name);
|
||||||
|
if (o == NULL) {
|
||||||
|
free(name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log_debug("running hook %s (parent %p)", name, item);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The hooks get a new state because they should not update the current
|
||||||
|
* target or formats for any subsequent commands.
|
||||||
|
*/
|
||||||
|
new_state = cmdq_new_state(current, &state->event, CMDQ_STATE_NOHOOKS);
|
||||||
|
cmdq_add_format(new_state, "hook", "%s", name);
|
||||||
|
|
||||||
|
arguments = args_print(args);
|
||||||
|
cmdq_add_format(new_state, "hook_arguments", "%s", arguments);
|
||||||
|
free(arguments);
|
||||||
|
|
||||||
|
for (i = 0; i < args_count(args); i++) {
|
||||||
|
xsnprintf(tmp, sizeof tmp, "hook_argument_%d", i);
|
||||||
|
cmdq_add_format(new_state, tmp, "%s", args_string(args, i));
|
||||||
|
}
|
||||||
|
flag = args_first(args, &ae);
|
||||||
|
while (flag != 0) {
|
||||||
|
value = args_get(args, flag);
|
||||||
|
if (value == NULL) {
|
||||||
|
xsnprintf(tmp, sizeof tmp, "hook_flag_%c", flag);
|
||||||
|
cmdq_add_format(new_state, tmp, "1");
|
||||||
|
} else {
|
||||||
|
xsnprintf(tmp, sizeof tmp, "hook_flag_%c", flag);
|
||||||
|
cmdq_add_format(new_state, tmp, "%s", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
av = args_first_value(args, flag);
|
||||||
|
while (av != NULL) {
|
||||||
|
xsnprintf(tmp, sizeof tmp, "hook_flag_%c_%d", flag, i);
|
||||||
|
cmdq_add_format(new_state, tmp, "%s", av->string);
|
||||||
|
i++;
|
||||||
|
av = args_next_value(av);
|
||||||
|
}
|
||||||
|
|
||||||
|
flag = args_next(&ae);
|
||||||
|
}
|
||||||
|
|
||||||
|
a = options_array_first(o);
|
||||||
|
while (a != NULL) {
|
||||||
|
cmdlist = options_array_item_value(a)->cmdlist;
|
||||||
|
if (cmdlist != NULL) {
|
||||||
|
new_item = cmdq_get_command(cmdlist, new_state);
|
||||||
|
if (item != NULL)
|
||||||
|
item = cmdq_insert_after(item, new_item);
|
||||||
|
else
|
||||||
|
item = cmdq_append(NULL, new_item);
|
||||||
|
}
|
||||||
|
a = options_array_next(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdq_free_state(new_state);
|
||||||
|
free(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Continue processing command queue. */
|
||||||
|
void
|
||||||
|
cmdq_continue(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
item->flags &= ~CMDQ_WAITING;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove an item. */
|
/* Remove an item. */
|
||||||
static void
|
static void
|
||||||
cmdq_remove(struct cmdq_item *item)
|
cmdq_remove(struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
if (item->shared != NULL && --item->shared->references == 0) {
|
|
||||||
if (item->shared->formats != NULL)
|
|
||||||
format_free(item->shared->formats);
|
|
||||||
free(item->shared);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item->client != NULL)
|
if (item->client != NULL)
|
||||||
server_client_unref(item->client);
|
server_client_unref(item->client);
|
||||||
|
if (item->cmdlist != NULL)
|
||||||
if (item->type == CMDQ_COMMAND)
|
|
||||||
cmd_list_free(item->cmdlist);
|
cmd_list_free(item->cmdlist);
|
||||||
|
cmdq_free_state(item->state);
|
||||||
|
|
||||||
TAILQ_REMOVE(item->queue, item, entry);
|
TAILQ_REMOVE(&item->queue->list, item, entry);
|
||||||
|
|
||||||
free((void *)item->name);
|
free(item->name);
|
||||||
free(item);
|
free(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set command group. */
|
|
||||||
static u_int
|
|
||||||
cmdq_next_group(void)
|
|
||||||
{
|
|
||||||
static u_int group;
|
|
||||||
|
|
||||||
return (++group);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove all subsequent items that match this item's group. */
|
/* Remove all subsequent items that match this item's group. */
|
||||||
static void
|
static void
|
||||||
cmdq_remove_group(struct cmdq_item *item)
|
cmdq_remove_group(struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct cmdq_item *this, *next;
|
struct cmdq_item *this, *next;
|
||||||
|
|
||||||
|
if (item->group == 0)
|
||||||
|
return;
|
||||||
this = TAILQ_NEXT(item, entry);
|
this = TAILQ_NEXT(item, entry);
|
||||||
while (this != NULL) {
|
while (this != NULL) {
|
||||||
next = TAILQ_NEXT(this, entry);
|
next = TAILQ_NEXT(this, entry);
|
||||||
@@ -144,48 +482,57 @@ cmdq_remove_group(struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Empty command callback. */
|
||||||
|
static enum cmd_retval
|
||||||
|
cmdq_empty_command(__unused struct cmdq_item *item, __unused void *data)
|
||||||
|
{
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get a command for the command queue. */
|
/* Get a command for the command queue. */
|
||||||
struct cmdq_item *
|
struct cmdq_item *
|
||||||
cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
|
cmdq_get_command(struct cmd_list *cmdlist, struct cmdq_state *state)
|
||||||
struct mouse_event *m, int flags)
|
|
||||||
{
|
{
|
||||||
struct cmdq_item *item, *first = NULL, *last = NULL;
|
struct cmdq_item *item, *first = NULL, *last = NULL;
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
u_int group = cmdq_next_group();
|
const struct cmd_entry *entry;
|
||||||
char *tmp;
|
int created = 0;
|
||||||
struct cmdq_shared *shared;
|
|
||||||
|
|
||||||
shared = xcalloc(1, sizeof *shared);
|
if ((cmd = cmd_list_first(cmdlist)) == NULL)
|
||||||
if (current != NULL)
|
return (cmdq_get_callback(cmdq_empty_command, NULL));
|
||||||
cmd_find_copy_state(&shared->current, current);
|
|
||||||
else
|
|
||||||
cmd_find_clear_state(&shared->current, 0);
|
|
||||||
if (m != NULL)
|
|
||||||
memcpy(&shared->mouse, m, sizeof shared->mouse);
|
|
||||||
|
|
||||||
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
if (state == NULL) {
|
||||||
xasprintf(&tmp, "command[%s]", cmd->entry->name);
|
state = cmdq_new_state(NULL, NULL, 0);
|
||||||
|
created = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (cmd != NULL) {
|
||||||
|
entry = cmd_get_entry(cmd);
|
||||||
|
|
||||||
item = xcalloc(1, sizeof *item);
|
item = xcalloc(1, sizeof *item);
|
||||||
item->name = tmp;
|
xasprintf(&item->name, "[%s/%p]", entry->name, item);
|
||||||
item->type = CMDQ_COMMAND;
|
item->type = CMDQ_COMMAND;
|
||||||
|
|
||||||
item->group = group;
|
item->group = cmd_get_group(cmd);
|
||||||
item->flags = flags;
|
item->state = cmdq_link_state(state);
|
||||||
|
|
||||||
item->shared = shared;
|
|
||||||
item->cmdlist = cmdlist;
|
item->cmdlist = cmdlist;
|
||||||
item->cmd = cmd;
|
item->cmd = cmd;
|
||||||
|
|
||||||
shared->references++;
|
|
||||||
cmdlist->references++;
|
cmdlist->references++;
|
||||||
|
log_debug("%s: %s group %u", __func__, item->name, item->group);
|
||||||
|
|
||||||
if (first == NULL)
|
if (first == NULL)
|
||||||
first = item;
|
first = item;
|
||||||
if (last != NULL)
|
if (last != NULL)
|
||||||
last->next = item;
|
last->next = item;
|
||||||
last = item;
|
last = item;
|
||||||
|
|
||||||
|
cmd = cmd_list_next(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (created)
|
||||||
|
cmdq_free_state(state);
|
||||||
return (first);
|
return (first);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,11 +544,11 @@ cmdq_find_flag(struct cmdq_item *item, struct cmd_find_state *fs,
|
|||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
if (flag->flag == 0) {
|
if (flag->flag == 0) {
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_from_client(fs, item->target_client, 0);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = args_get(item->cmd->args, flag->flag);
|
value = args_get(cmd_get_args(item->cmd), flag->flag);
|
||||||
if (cmd_find_target(fs, item, value, flag->type, flag->flags) != 0) {
|
if (cmd_find_target(fs, item, value, flag->type, flag->flags) != 0) {
|
||||||
cmd_find_clear_state(fs, 0);
|
cmd_find_clear_state(fs, 0);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
@@ -209,22 +556,89 @@ cmdq_find_flag(struct cmdq_item *item, struct cmd_find_state *fs,
|
|||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add message with command. */
|
||||||
|
static void
|
||||||
|
cmdq_add_message(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct client *c = item->client;
|
||||||
|
struct cmdq_state *state = item->state;
|
||||||
|
const char *key;
|
||||||
|
char *tmp;
|
||||||
|
uid_t uid;
|
||||||
|
struct passwd *pw;
|
||||||
|
char *user = NULL;
|
||||||
|
|
||||||
|
tmp = cmd_print(item->cmd);
|
||||||
|
if (c != NULL) {
|
||||||
|
uid = proc_get_peer_uid(c->peer);
|
||||||
|
if (uid != (uid_t)-1 && uid != getuid()) {
|
||||||
|
if ((pw = getpwuid(uid)) != NULL)
|
||||||
|
xasprintf(&user, "[%s]", pw->pw_name);
|
||||||
|
else
|
||||||
|
user = xstrdup("[unknown]");
|
||||||
|
} else
|
||||||
|
user = xstrdup("");
|
||||||
|
if (c->session != NULL && state->event.key != KEYC_NONE) {
|
||||||
|
key = key_string_lookup_key(state->event.key, 0);
|
||||||
|
server_add_message("%s%s key %s: %s", c->name, user,
|
||||||
|
key, tmp);
|
||||||
|
} else {
|
||||||
|
server_add_message("%s%s command: %s", c->name, user,
|
||||||
|
tmp);
|
||||||
|
}
|
||||||
|
free(user);
|
||||||
|
} else
|
||||||
|
server_add_message("command: %s", tmp);
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
/* Fire command on command queue. */
|
/* Fire command on command queue. */
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmdq_fire_command(struct cmdq_item *item)
|
cmdq_fire_command(struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct client *c = item->client;
|
const char *name = cmdq_name(item->client);
|
||||||
|
struct cmdq_state *state = item->state;
|
||||||
struct cmd *cmd = item->cmd;
|
struct cmd *cmd = item->cmd;
|
||||||
const struct cmd_entry *entry = cmd->entry;
|
struct args *args = cmd_get_args(cmd);
|
||||||
|
const struct cmd_entry *entry = cmd_get_entry(cmd);
|
||||||
|
struct client *tc, *saved = item->client;
|
||||||
enum cmd_retval retval;
|
enum cmd_retval retval;
|
||||||
struct cmd_find_state *fsp, fs;
|
struct cmd_find_state *fsp, fs;
|
||||||
int flags;
|
int flags, quiet = 0;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
flags = !!(cmd->flags & CMD_CONTROL);
|
if (cfg_finished)
|
||||||
|
cmdq_add_message(item);
|
||||||
|
if (log_get_level() > 1) {
|
||||||
|
tmp = cmd_print(cmd);
|
||||||
|
log_debug("%s %s: (%u) %s", __func__, name, item->group, tmp);
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
flags = !!(state->flags & CMDQ_STATE_CONTROL);
|
||||||
cmdq_guard(item, "begin", flags);
|
cmdq_guard(item, "begin", flags);
|
||||||
|
|
||||||
if (item->client == NULL)
|
if (item->client == NULL)
|
||||||
item->client = cmd_find_client(item, NULL, 1);
|
item->client = cmd_find_client(item, NULL, 1);
|
||||||
|
|
||||||
|
if (entry->flags & CMD_CLIENT_CANFAIL)
|
||||||
|
quiet = 1;
|
||||||
|
if (entry->flags & CMD_CLIENT_CFLAG) {
|
||||||
|
tc = cmd_find_client(item, args_get(args, 'c'), quiet);
|
||||||
|
if (tc == NULL && !quiet) {
|
||||||
|
retval = CMD_RETURN_ERROR;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
} else if (entry->flags & CMD_CLIENT_TFLAG) {
|
||||||
|
tc = cmd_find_client(item, args_get(args, 't'), quiet);
|
||||||
|
if (tc == NULL && !quiet) {
|
||||||
|
retval = CMD_RETURN_ERROR;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
tc = cmd_find_client(item, NULL, 1);
|
||||||
|
item->target_client = tc;
|
||||||
|
|
||||||
retval = cmdq_find_flag(item, &item->source, &entry->source);
|
retval = cmdq_find_flag(item, &item->source, &entry->source);
|
||||||
if (retval == CMD_RETURN_ERROR)
|
if (retval == CMD_RETURN_ERROR)
|
||||||
goto out;
|
goto out;
|
||||||
@@ -239,20 +653,29 @@ cmdq_fire_command(struct cmdq_item *item)
|
|||||||
if (entry->flags & CMD_AFTERHOOK) {
|
if (entry->flags & CMD_AFTERHOOK) {
|
||||||
if (cmd_find_valid_state(&item->target))
|
if (cmd_find_valid_state(&item->target))
|
||||||
fsp = &item->target;
|
fsp = &item->target;
|
||||||
else if (cmd_find_valid_state(&item->shared->current))
|
else if (cmd_find_valid_state(&item->state->current))
|
||||||
fsp = &item->shared->current;
|
fsp = &item->state->current;
|
||||||
else if (cmd_find_from_client(&fs, item->client) == 0)
|
else if (cmd_find_from_client(&fs, item->client, 0) == 0)
|
||||||
fsp = &fs;
|
fsp = &fs;
|
||||||
else
|
else
|
||||||
goto out;
|
goto out;
|
||||||
hooks_insert(fsp->s->hooks, item, fsp, "after-%s", entry->name);
|
cmdq_insert_hook(fsp->s, item, fsp, "after-%s", entry->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
item->client = c;
|
item->client = saved;
|
||||||
if (retval == CMD_RETURN_ERROR)
|
if (retval == CMD_RETURN_ERROR) {
|
||||||
|
fsp = NULL;
|
||||||
|
if (cmd_find_valid_state(&item->target))
|
||||||
|
fsp = &item->target;
|
||||||
|
else if (cmd_find_valid_state(&item->state->current))
|
||||||
|
fsp = &item->state->current;
|
||||||
|
else if (cmd_find_from_client(&fs, item->client, 0) == 0)
|
||||||
|
fsp = &fs;
|
||||||
|
cmdq_insert_hook(fsp != NULL ? fsp->s : NULL, item, fsp,
|
||||||
|
"command-error");
|
||||||
cmdq_guard(item, "error", flags);
|
cmdq_guard(item, "error", flags);
|
||||||
else
|
} else
|
||||||
cmdq_guard(item, "end", flags);
|
cmdq_guard(item, "end", flags);
|
||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
@@ -262,16 +685,13 @@ struct cmdq_item *
|
|||||||
cmdq_get_callback1(const char *name, cmdq_cb cb, void *data)
|
cmdq_get_callback1(const char *name, cmdq_cb cb, void *data)
|
||||||
{
|
{
|
||||||
struct cmdq_item *item;
|
struct cmdq_item *item;
|
||||||
char *tmp;
|
|
||||||
|
|
||||||
xasprintf(&tmp, "callback[%s]", name);
|
|
||||||
|
|
||||||
item = xcalloc(1, sizeof *item);
|
item = xcalloc(1, sizeof *item);
|
||||||
item->name = tmp;
|
xasprintf(&item->name, "[%s/%p]", name, item);
|
||||||
item->type = CMDQ_CALLBACK;
|
item->type = CMDQ_CALLBACK;
|
||||||
|
|
||||||
item->group = 0;
|
item->group = 0;
|
||||||
item->flags = 0;
|
item->state = cmdq_new_state(NULL, NULL, 0);
|
||||||
|
|
||||||
item->cb = cb;
|
item->cb = cb;
|
||||||
item->data = data;
|
item->data = data;
|
||||||
@@ -279,6 +699,25 @@ cmdq_get_callback1(const char *name, cmdq_cb cb, void *data)
|
|||||||
return (item);
|
return (item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Generic error callback. */
|
||||||
|
static enum cmd_retval
|
||||||
|
cmdq_error_callback(struct cmdq_item *item, void *data)
|
||||||
|
{
|
||||||
|
char *error = data;
|
||||||
|
|
||||||
|
cmdq_error(item, "%s", error);
|
||||||
|
free(error);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get an error callback for the command queue. */
|
||||||
|
struct cmdq_item *
|
||||||
|
cmdq_get_error(const char *error)
|
||||||
|
{
|
||||||
|
return (cmdq_get_callback(cmdq_error_callback, xstrdup(error)));
|
||||||
|
}
|
||||||
|
|
||||||
/* Fire callback on callback queue. */
|
/* Fire callback on callback queue. */
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmdq_fire_callback(struct cmdq_item *item)
|
cmdq_fire_callback(struct cmdq_item *item)
|
||||||
@@ -286,25 +725,6 @@ cmdq_fire_callback(struct cmdq_item *item)
|
|||||||
return (item->cb(item, item->data));
|
return (item->cb(item, item->data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a format to command queue. */
|
|
||||||
void
|
|
||||||
cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
struct cmdq_shared *shared = item->shared;
|
|
||||||
va_list ap;
|
|
||||||
char *value;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
xvasprintf(&value, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
if (shared->formats == NULL)
|
|
||||||
shared->formats = format_create(NULL, NULL, FORMAT_NONE, 0);
|
|
||||||
format_add(shared->formats, key, "%s", value);
|
|
||||||
|
|
||||||
free(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Process next item on command queue. */
|
/* Process next item on command queue. */
|
||||||
u_int
|
u_int
|
||||||
cmdq_next(struct client *c)
|
cmdq_next(struct client *c)
|
||||||
@@ -316,18 +736,18 @@ cmdq_next(struct client *c)
|
|||||||
u_int items = 0;
|
u_int items = 0;
|
||||||
static u_int number;
|
static u_int number;
|
||||||
|
|
||||||
if (TAILQ_EMPTY(queue)) {
|
if (TAILQ_EMPTY(&queue->list)) {
|
||||||
log_debug("%s %s: empty", __func__, name);
|
log_debug("%s %s: empty", __func__, name);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (TAILQ_FIRST(queue)->flags & CMDQ_WAITING) {
|
if (TAILQ_FIRST(&queue->list)->flags & CMDQ_WAITING) {
|
||||||
log_debug("%s %s: waiting", __func__, name);
|
log_debug("%s %s: waiting", __func__, name);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_debug("%s %s: enter", __func__, name);
|
log_debug("%s %s: enter", __func__, name);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
item = TAILQ_FIRST(queue);
|
item = queue->item = TAILQ_FIRST(&queue->list);
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
log_debug("%s %s: %s (%d), flags %x", __func__, name,
|
log_debug("%s %s: %s (%d), flags %x", __func__, name,
|
||||||
@@ -377,6 +797,7 @@ cmdq_next(struct client *c)
|
|||||||
}
|
}
|
||||||
cmdq_remove(item);
|
cmdq_remove(item);
|
||||||
}
|
}
|
||||||
|
queue->item = NULL;
|
||||||
|
|
||||||
log_debug("%s %s: exit (empty)", __func__, name);
|
log_debug("%s %s: exit (empty)", __func__, name);
|
||||||
return (items);
|
return (items);
|
||||||
@@ -386,55 +807,55 @@ waiting:
|
|||||||
return (items);
|
return (items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get running item if any. */
|
||||||
|
struct cmdq_item *
|
||||||
|
cmdq_running(struct client *c)
|
||||||
|
{
|
||||||
|
struct cmdq_list *queue = cmdq_get(c);
|
||||||
|
|
||||||
|
if (queue->item == NULL)
|
||||||
|
return (NULL);
|
||||||
|
if (queue->item->flags & CMDQ_WAITING)
|
||||||
|
return (NULL);
|
||||||
|
return (queue->item);
|
||||||
|
}
|
||||||
|
|
||||||
/* Print a guard line. */
|
/* Print a guard line. */
|
||||||
void
|
void
|
||||||
cmdq_guard(struct cmdq_item *item, const char *guard, int flags)
|
cmdq_guard(struct cmdq_item *item, const char *guard, int flags)
|
||||||
{
|
{
|
||||||
struct client *c = item->client;
|
struct client *c = item->client;
|
||||||
|
long t = item->time;
|
||||||
|
u_int number = item->number;
|
||||||
|
|
||||||
if (c == NULL || !(c->flags & CLIENT_CONTROL))
|
if (c != NULL && (c->flags & CLIENT_CONTROL))
|
||||||
return;
|
control_write(c, "%%%s %ld %u %d", guard, t, number, flags);
|
||||||
|
}
|
||||||
|
|
||||||
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u %d\n", guard,
|
/* Show message from command. */
|
||||||
(long)item->time, item->number, flags);
|
void
|
||||||
server_client_push_stdout(c);
|
cmdq_print_data(struct cmdq_item *item, int parse, struct evbuffer *evb)
|
||||||
|
{
|
||||||
|
server_client_print(item->client, parse, evb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show message from command. */
|
/* Show message from command. */
|
||||||
void
|
void
|
||||||
cmdq_print(struct cmdq_item *item, const char *fmt, ...)
|
cmdq_print(struct cmdq_item *item, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
struct client *c = item->client;
|
|
||||||
struct window *w;
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *tmp, *msg;
|
struct evbuffer *evb;
|
||||||
|
|
||||||
|
evb = evbuffer_new();
|
||||||
|
if (evb == NULL)
|
||||||
|
fatalx("out of memory");
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
evbuffer_add_vprintf(evb, fmt, ap);
|
||||||
if (c == NULL)
|
|
||||||
/* nothing */;
|
|
||||||
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
|
||||||
if (~c->flags & CLIENT_UTF8) {
|
|
||||||
xvasprintf(&tmp, fmt, ap);
|
|
||||||
msg = utf8_sanitize(tmp);
|
|
||||||
free(tmp);
|
|
||||||
evbuffer_add(c->stdout_data, msg, strlen(msg));
|
|
||||||
free(msg);
|
|
||||||
} else
|
|
||||||
evbuffer_add_vprintf(c->stdout_data, fmt, ap);
|
|
||||||
evbuffer_add(c->stdout_data, "\n", 1);
|
|
||||||
server_client_push_stdout(c);
|
|
||||||
} else {
|
|
||||||
w = c->session->curw->window;
|
|
||||||
if (w->active->mode != &window_copy_mode) {
|
|
||||||
window_pane_reset_mode(w->active);
|
|
||||||
window_pane_set_mode(w->active, &window_copy_mode);
|
|
||||||
window_copy_init_for_output(w->active);
|
|
||||||
}
|
|
||||||
window_copy_vadd(w->active, fmt, ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
|
cmdq_print_data(item, 0, evb);
|
||||||
|
evbuffer_free(evb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show error from command. */
|
/* Show error from command. */
|
||||||
@@ -444,30 +865,34 @@ cmdq_error(struct cmdq_item *item, const char *fmt, ...)
|
|||||||
struct client *c = item->client;
|
struct client *c = item->client;
|
||||||
struct cmd *cmd = item->cmd;
|
struct cmd *cmd = item->cmd;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *msg;
|
char *msg, *tmp;
|
||||||
size_t msglen;
|
const char *file;
|
||||||
char *tmp;
|
u_int line;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
msglen = xvasprintf(&msg, fmt, ap);
|
xvasprintf(&msg, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (c == NULL)
|
log_debug("%s: %s", __func__, msg);
|
||||||
cfg_add_cause("%s:%u: %s", cmd->file, cmd->line, msg);
|
|
||||||
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
if (c == NULL) {
|
||||||
|
cmd_get_source(cmd, &file, &line);
|
||||||
|
cfg_add_cause("%s:%u: %s", file, line, msg);
|
||||||
|
} else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
||||||
|
server_add_message("%s message: %s", c->name, msg);
|
||||||
if (~c->flags & CLIENT_UTF8) {
|
if (~c->flags & CLIENT_UTF8) {
|
||||||
tmp = msg;
|
tmp = msg;
|
||||||
msg = utf8_sanitize(tmp);
|
msg = utf8_sanitize(tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
msglen = strlen(msg);
|
|
||||||
}
|
}
|
||||||
evbuffer_add(c->stderr_data, msg, msglen);
|
if (c->flags & CLIENT_CONTROL)
|
||||||
evbuffer_add(c->stderr_data, "\n", 1);
|
control_write(c, "%s", msg);
|
||||||
server_client_push_stderr(c);
|
else
|
||||||
|
file_error(c, "%s\n", msg);
|
||||||
c->retval = 1;
|
c->retval = 1;
|
||||||
} else {
|
} else {
|
||||||
*msg = toupper((u_char) *msg);
|
*msg = toupper((u_char) *msg);
|
||||||
status_message_set(c, "%s", msg);
|
status_message_set(c, -1, 1, 0, "%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(msg);
|
free(msg);
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -31,51 +34,302 @@ const struct cmd_entry cmd_refresh_client_entry = {
|
|||||||
.name = "refresh-client",
|
.name = "refresh-client",
|
||||||
.alias = "refresh",
|
.alias = "refresh",
|
||||||
|
|
||||||
.args = { "C:St:", 0, 0 },
|
.args = { "A:B:cC:Df:r:F:l::LRSt:U", 0, 1, NULL },
|
||||||
.usage = "[-S] [-C size] " CMD_TARGET_CLIENT_USAGE,
|
.usage = "[-cDlLRSU] [-A pane:state] [-B name:what:format] "
|
||||||
|
"[-C XxY] [-f flags] [-r pane:report]" CMD_TARGET_CLIENT_USAGE
|
||||||
|
" [adjustment]",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG,
|
||||||
.exec = cmd_refresh_client_exec
|
.exec = cmd_refresh_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_refresh_client_update_subscription(struct client *tc, const char *value)
|
||||||
|
{
|
||||||
|
char *copy, *split, *name, *what;
|
||||||
|
enum control_sub_type subtype;
|
||||||
|
int subid = -1;
|
||||||
|
|
||||||
|
copy = name = xstrdup(value);
|
||||||
|
if ((split = strchr(copy, ':')) == NULL) {
|
||||||
|
control_remove_sub(tc, copy);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
*split++ = '\0';
|
||||||
|
|
||||||
|
what = split;
|
||||||
|
if ((split = strchr(what, ':')) == NULL)
|
||||||
|
goto out;
|
||||||
|
*split++ = '\0';
|
||||||
|
|
||||||
|
if (strcmp(what, "%*") == 0)
|
||||||
|
subtype = CONTROL_SUB_ALL_PANES;
|
||||||
|
else if (sscanf(what, "%%%d", &subid) == 1 && subid >= 0)
|
||||||
|
subtype = CONTROL_SUB_PANE;
|
||||||
|
else if (strcmp(what, "@*") == 0)
|
||||||
|
subtype = CONTROL_SUB_ALL_WINDOWS;
|
||||||
|
else if (sscanf(what, "@%d", &subid) == 1 && subid >= 0)
|
||||||
|
subtype = CONTROL_SUB_WINDOW;
|
||||||
|
else
|
||||||
|
subtype = CONTROL_SUB_SESSION;
|
||||||
|
control_add_sub(tc, name, subtype, subid, split);
|
||||||
|
|
||||||
|
out:
|
||||||
|
free(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_refresh_client_control_client_size(struct cmd *self, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
|
const char *size = args_get(args, 'C');
|
||||||
|
u_int w, x, y;
|
||||||
|
struct client_window *cw;
|
||||||
|
|
||||||
|
if (sscanf(size, "@%u:%ux%u", &w, &x, &y) == 3) {
|
||||||
|
if (x < WINDOW_MINIMUM || x > WINDOW_MAXIMUM ||
|
||||||
|
y < WINDOW_MINIMUM || y > WINDOW_MAXIMUM) {
|
||||||
|
cmdq_error(item, "size too small or too big");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
log_debug("%s: client %s window @%u: size %ux%u", __func__,
|
||||||
|
tc->name, w, x, y);
|
||||||
|
cw = server_client_add_client_window(tc, w);
|
||||||
|
cw->sx = x;
|
||||||
|
cw->sy = y;
|
||||||
|
tc->flags |= CLIENT_WINDOWSIZECHANGED;
|
||||||
|
recalculate_sizes_now(1);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
if (sscanf(size, "@%u:", &w) == 1) {
|
||||||
|
cw = server_client_get_client_window(tc, w);
|
||||||
|
if (cw != NULL) {
|
||||||
|
log_debug("%s: client %s window @%u: no size", __func__,
|
||||||
|
tc->name, w);
|
||||||
|
cw->sx = 0;
|
||||||
|
cw->sy = 0;
|
||||||
|
recalculate_sizes_now(1);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sscanf(size, "%u,%u", &x, &y) != 2 &&
|
||||||
|
sscanf(size, "%ux%u", &x, &y) != 2) {
|
||||||
|
cmdq_error(item, "bad size argument");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (x < WINDOW_MINIMUM || x > WINDOW_MAXIMUM ||
|
||||||
|
y < WINDOW_MINIMUM || y > WINDOW_MAXIMUM) {
|
||||||
|
cmdq_error(item, "size too small or too big");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
tty_set_size(&tc->tty, x, y, 0, 0);
|
||||||
|
tc->flags |= CLIENT_SIZECHANGED;
|
||||||
|
recalculate_sizes_now(1);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_refresh_client_update_offset(struct client *tc, const char *value)
|
||||||
|
{
|
||||||
|
struct window_pane *wp;
|
||||||
|
char *copy, *split;
|
||||||
|
u_int pane;
|
||||||
|
|
||||||
|
if (*value != '%')
|
||||||
|
return;
|
||||||
|
copy = xstrdup(value);
|
||||||
|
if ((split = strchr(copy, ':')) == NULL)
|
||||||
|
goto out;
|
||||||
|
*split++ = '\0';
|
||||||
|
|
||||||
|
if (sscanf(copy, "%%%u", &pane) != 1)
|
||||||
|
goto out;
|
||||||
|
wp = window_pane_find_by_id(pane);
|
||||||
|
if (wp == NULL)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (strcmp(split, "on") == 0)
|
||||||
|
control_set_pane_on(tc, wp);
|
||||||
|
else if (strcmp(split, "off") == 0)
|
||||||
|
control_set_pane_off(tc, wp);
|
||||||
|
else if (strcmp(split, "continue") == 0)
|
||||||
|
control_continue_pane(tc, wp);
|
||||||
|
else if (strcmp(split, "pause") == 0)
|
||||||
|
control_pause_pane(tc, wp);
|
||||||
|
|
||||||
|
out:
|
||||||
|
free(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_refresh_client_clipboard(struct cmd *self, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
|
const char *p;
|
||||||
|
u_int i;
|
||||||
|
struct cmd_find_state fs;
|
||||||
|
|
||||||
|
p = args_get(args, 'l');
|
||||||
|
if (p == NULL) {
|
||||||
|
if (tc->flags & CLIENT_CLIPBOARDBUFFER)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
tc->flags |= CLIENT_CLIPBOARDBUFFER;
|
||||||
|
} else {
|
||||||
|
if (cmd_find_target(&fs, item, p, CMD_FIND_PANE, 0) != 0)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
for (i = 0; i < tc->clipboard_npanes; i++) {
|
||||||
|
if (tc->clipboard_panes[i] == fs.wp->id)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i != tc->clipboard_npanes)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
tc->clipboard_panes = xreallocarray(tc->clipboard_panes,
|
||||||
|
tc->clipboard_npanes + 1, sizeof *tc->clipboard_panes);
|
||||||
|
tc->clipboard_panes[tc->clipboard_npanes++] = fs.wp->id;
|
||||||
|
}
|
||||||
|
tty_clipboard_query(&tc->tty);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_refresh_report(struct tty *tty, const char *value)
|
||||||
|
{
|
||||||
|
struct window_pane *wp;
|
||||||
|
u_int pane;
|
||||||
|
size_t size = 0;
|
||||||
|
char *copy, *split;
|
||||||
|
|
||||||
|
if (*value != '%')
|
||||||
|
return;
|
||||||
|
copy = xstrdup(value);
|
||||||
|
if ((split = strchr(copy, ':')) == NULL)
|
||||||
|
goto out;
|
||||||
|
*split++ = '\0';
|
||||||
|
|
||||||
|
if (sscanf(copy, "%%%u", &pane) != 1)
|
||||||
|
goto out;
|
||||||
|
wp = window_pane_find_by_id(pane);
|
||||||
|
if (wp == NULL)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
tty_keys_colours(tty, split, strlen(split), &size, &wp->control_fg,
|
||||||
|
&wp->control_bg);
|
||||||
|
|
||||||
|
out:
|
||||||
|
free(copy);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct client *c;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
const char *size;
|
struct tty *tty = &tc->tty;
|
||||||
u_int w, h;
|
struct window *w;
|
||||||
|
const char *errstr;
|
||||||
|
u_int adjust;
|
||||||
|
struct args_value *av;
|
||||||
|
|
||||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
if (args_has(args, 'c') ||
|
||||||
return (CMD_RETURN_ERROR);
|
args_has(args, 'L') ||
|
||||||
|
args_has(args, 'R') ||
|
||||||
|
args_has(args, 'U') ||
|
||||||
|
args_has(args, 'D'))
|
||||||
|
{
|
||||||
|
if (args_count(args) == 0)
|
||||||
|
adjust = 1;
|
||||||
|
else {
|
||||||
|
adjust = strtonum(args_string(args, 0), 1, INT_MAX,
|
||||||
|
&errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
cmdq_error(item, "adjustment %s", errstr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (args_has(args, 'C')) {
|
if (args_has(args, 'c'))
|
||||||
if ((size = args_get(args, 'C')) == NULL) {
|
tc->pan_window = NULL;
|
||||||
cmdq_error(item, "missing size");
|
else {
|
||||||
return (CMD_RETURN_ERROR);
|
w = tc->session->curw->window;
|
||||||
|
if (tc->pan_window != w) {
|
||||||
|
tc->pan_window = w;
|
||||||
|
tc->pan_ox = tty->oox;
|
||||||
|
tc->pan_oy = tty->ooy;
|
||||||
|
}
|
||||||
|
if (args_has(args, 'L')) {
|
||||||
|
if (tc->pan_ox > adjust)
|
||||||
|
tc->pan_ox -= adjust;
|
||||||
|
else
|
||||||
|
tc->pan_ox = 0;
|
||||||
|
} else if (args_has(args, 'R')) {
|
||||||
|
tc->pan_ox += adjust;
|
||||||
|
if (tc->pan_ox > w->sx - tty->osx)
|
||||||
|
tc->pan_ox = w->sx - tty->osx;
|
||||||
|
} else if (args_has(args, 'U')) {
|
||||||
|
if (tc->pan_oy > adjust)
|
||||||
|
tc->pan_oy -= adjust;
|
||||||
|
else
|
||||||
|
tc->pan_oy = 0;
|
||||||
|
} else if (args_has(args, 'D')) {
|
||||||
|
tc->pan_oy += adjust;
|
||||||
|
if (tc->pan_oy > w->sy - tty->osy)
|
||||||
|
tc->pan_oy = w->sy - tty->osy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (sscanf(size, "%u,%u", &w, &h) != 2) {
|
tty_update_client_offset(tc);
|
||||||
cmdq_error(item, "bad size argument");
|
server_redraw_client(tc);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
|
||||||
if (w < PANE_MINIMUM || w > 5000 ||
|
|
||||||
h < PANE_MINIMUM || h > 5000) {
|
|
||||||
cmdq_error(item, "size too small or too big");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
if (!(c->flags & CLIENT_CONTROL)) {
|
|
||||||
cmdq_error(item, "not a control client");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
if (tty_set_size(&c->tty, w, h))
|
|
||||||
recalculate_sizes();
|
|
||||||
} else if (args_has(args, 'S')) {
|
|
||||||
c->flags |= CLIENT_STATUSFORCE;
|
|
||||||
server_status_client(c);
|
|
||||||
} else {
|
|
||||||
c->flags |= CLIENT_STATUSFORCE;
|
|
||||||
server_redraw_client(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'l'))
|
||||||
|
return (cmd_refresh_client_clipboard(self, item));
|
||||||
|
|
||||||
|
if (args_has(args, 'F')) /* -F is an alias for -f */
|
||||||
|
server_client_set_flags(tc, args_get(args, 'F'));
|
||||||
|
if (args_has(args, 'f'))
|
||||||
|
server_client_set_flags(tc, args_get(args, 'f'));
|
||||||
|
if (args_has(args, 'r'))
|
||||||
|
cmd_refresh_report(tty, args_get(args, 'r'));
|
||||||
|
|
||||||
|
if (args_has(args, 'A')) {
|
||||||
|
if (~tc->flags & CLIENT_CONTROL)
|
||||||
|
goto not_control_client;
|
||||||
|
av = args_first_value(args, 'A');
|
||||||
|
while (av != NULL) {
|
||||||
|
cmd_refresh_client_update_offset(tc, av->string);
|
||||||
|
av = args_next_value(av);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
if (args_has(args, 'B')) {
|
||||||
|
if (~tc->flags & CLIENT_CONTROL)
|
||||||
|
goto not_control_client;
|
||||||
|
av = args_first_value(args, 'B');
|
||||||
|
while (av != NULL) {
|
||||||
|
cmd_refresh_client_update_subscription(tc, av->string);
|
||||||
|
av = args_next_value(av);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
if (args_has(args, 'C')) {
|
||||||
|
if (~tc->flags & CLIENT_CONTROL)
|
||||||
|
goto not_control_client;
|
||||||
|
return (cmd_refresh_client_control_client_size(self, item));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'S')) {
|
||||||
|
tc->flags |= CLIENT_STATUSFORCE;
|
||||||
|
server_status_client(tc);
|
||||||
|
} else {
|
||||||
|
tc->flags |= CLIENT_STATUSFORCE;
|
||||||
|
server_redraw_client(tc);
|
||||||
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
not_control_client:
|
||||||
|
cmdq_error(item, "not a control client");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const struct cmd_entry cmd_rename_session_entry = {
|
|||||||
.name = "rename-session",
|
.name = "rename-session",
|
||||||
.alias = "rename",
|
.alias = "rename",
|
||||||
|
|
||||||
.args = { "t:", 1, 1 },
|
.args = { "t:", 1, 1, NULL },
|
||||||
.usage = CMD_TARGET_SESSION_USAGE " new-name",
|
.usage = CMD_TARGET_SESSION_USAGE " new-name",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||||
@@ -46,26 +46,32 @@ const struct cmd_entry cmd_rename_session_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct session *s = item->target.s;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
const char *newname;
|
struct session *s = target->s;
|
||||||
|
char *newname, *tmp;
|
||||||
|
|
||||||
newname = args->argv[0];
|
tmp = format_single_from_target(item, args_string(args, 0));
|
||||||
if (strcmp(newname, s->name) == 0)
|
newname = session_check_name(tmp);
|
||||||
return (CMD_RETURN_NORMAL);
|
if (newname == NULL) {
|
||||||
|
cmdq_error(item, "invalid session: %s", tmp);
|
||||||
if (!session_check_name(newname)) {
|
free(tmp);
|
||||||
cmdq_error(item, "bad session name: %s", newname);
|
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
free(tmp);
|
||||||
|
if (strcmp(newname, s->name) == 0) {
|
||||||
|
free(newname);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
if (session_find(newname) != NULL) {
|
if (session_find(newname) != NULL) {
|
||||||
cmdq_error(item, "duplicate session: %s", newname);
|
cmdq_error(item, "duplicate session: %s", newname);
|
||||||
|
free(newname);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_REMOVE(sessions, &sessions, s);
|
RB_REMOVE(sessions, &sessions, s);
|
||||||
free(s->name);
|
free(s->name);
|
||||||
s->name = xstrdup(newname);
|
s->name = newname;
|
||||||
RB_INSERT(sessions, &sessions, s);
|
RB_INSERT(sessions, &sessions, s);
|
||||||
|
|
||||||
server_status_session(s);
|
server_status_session(s);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_rename_window_entry = {
|
|||||||
.name = "rename-window",
|
.name = "rename-window",
|
||||||
.alias = "renamew",
|
.alias = "renamew",
|
||||||
|
|
||||||
.args = { "t:", 1, 1 },
|
.args = { "t:", 1, 1, NULL },
|
||||||
.usage = CMD_TARGET_WINDOW_USAGE " new-name",
|
.usage = CMD_TARGET_WINDOW_USAGE " new-name",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
@@ -45,13 +45,18 @@ const struct cmd_entry cmd_rename_window_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_rename_window_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_rename_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct winlink *wl = item->target.wl;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct winlink *wl = target->wl;
|
||||||
|
char *newname;
|
||||||
|
|
||||||
window_set_name(wl->window, args->argv[0]);
|
newname = format_single_from_target(item, args_string(args, 0));
|
||||||
|
window_set_name(wl->window, newname);
|
||||||
options_set_number(wl->window->options, "automatic-rename", 0);
|
options_set_number(wl->window->options, "automatic-rename", 0);
|
||||||
|
|
||||||
|
server_redraw_window_borders(wl->window);
|
||||||
server_status_window(wl->window);
|
server_status_window(wl->window);
|
||||||
|
free(newname);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
@@ -35,8 +36,8 @@ const struct cmd_entry cmd_resize_pane_entry = {
|
|||||||
.name = "resize-pane",
|
.name = "resize-pane",
|
||||||
.alias = "resizep",
|
.alias = "resizep",
|
||||||
|
|
||||||
.args = { "DLMRt:Ux:y:Z", 0, 1 },
|
.args = { "DLMRTt:Ux:y:Z", 0, 1, NULL },
|
||||||
.usage = "[-DLMRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " "
|
.usage = "[-DLMRTUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " "
|
||||||
"[adjustment]",
|
"[adjustment]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
@@ -48,52 +49,64 @@ const struct cmd_entry cmd_resize_pane_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct cmdq_shared *shared = item->shared;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct window_pane *wp = item->target.wp;
|
struct key_event *event = cmdq_get_event(item);
|
||||||
struct winlink *wl = item->target.wl;
|
struct window_pane *wp = target->wp;
|
||||||
|
struct winlink *wl = target->wl;
|
||||||
struct window *w = wl->window;
|
struct window *w = wl->window;
|
||||||
struct client *c = item->client;
|
struct client *c = cmdq_get_client(item);
|
||||||
struct session *s = item->target.s;
|
struct session *s = target->s;
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
char *cause;
|
char *cause;
|
||||||
u_int adjust;
|
u_int adjust;
|
||||||
int x, y;
|
int x, y, status;
|
||||||
|
struct grid *gd = wp->base.grid;
|
||||||
|
|
||||||
|
if (args_has(args, 'T')) {
|
||||||
|
if (!TAILQ_EMPTY(&wp->modes))
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
adjust = screen_size_y(&wp->base) - 1 - wp->base.cy;
|
||||||
|
if (adjust > gd->hsize)
|
||||||
|
adjust = gd->hsize;
|
||||||
|
grid_remove_history(gd, adjust);
|
||||||
|
wp->base.cy += adjust;
|
||||||
|
wp->flags |= PANE_REDRAW;
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (args_has(args, 'M')) {
|
if (args_has(args, 'M')) {
|
||||||
if (cmd_mouse_window(&shared->mouse, &s) == NULL)
|
if (!event->m.valid || cmd_mouse_window(&event->m, &s) == NULL)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
if (c == NULL || c->session != s)
|
if (c == NULL || c->session != s)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
c->tty.mouse_drag_update = cmd_resize_pane_mouse_update;
|
c->tty.mouse_drag_update = cmd_resize_pane_mouse_update;
|
||||||
cmd_resize_pane_mouse_update(c, &shared->mouse);
|
cmd_resize_pane_mouse_update(c, &event->m);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 'Z')) {
|
if (args_has(args, 'Z')) {
|
||||||
if (w->flags & WINDOW_ZOOMED)
|
if (w->flags & WINDOW_ZOOMED)
|
||||||
window_unzoom(w);
|
window_unzoom(w, 1);
|
||||||
else
|
else
|
||||||
window_zoom(wp);
|
window_zoom(wp);
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
server_status_window(w);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
server_unzoom_window(w);
|
server_unzoom_window(w);
|
||||||
|
|
||||||
if (args->argc == 0)
|
if (args_count(args) == 0)
|
||||||
adjust = 1;
|
adjust = 1;
|
||||||
else {
|
else {
|
||||||
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
adjust = strtonum(args_string(args, 0), 1, INT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
cmdq_error(item, "adjustment %s", errstr);
|
cmdq_error(item, "adjustment %s", errstr);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'x')) {
|
if (args_has(args, 'x')) {
|
||||||
x = args_strtonum(self->args, 'x', PANE_MINIMUM, INT_MAX,
|
x = args_percentage(args, 'x', 0, INT_MAX, w->sx, &cause);
|
||||||
&cause);
|
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
cmdq_error(item, "width %s", cause);
|
cmdq_error(item, "width %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
@@ -101,24 +114,34 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
layout_resize_pane_to(wp, LAYOUT_LEFTRIGHT, x);
|
layout_resize_pane_to(wp, LAYOUT_LEFTRIGHT, x);
|
||||||
}
|
}
|
||||||
if (args_has(self->args, 'y')) {
|
if (args_has(args, 'y')) {
|
||||||
y = args_strtonum(self->args, 'y', PANE_MINIMUM, INT_MAX,
|
y = args_percentage(args, 'y', 0, INT_MAX, w->sy, &cause);
|
||||||
&cause);
|
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
cmdq_error(item, "height %s", cause);
|
cmdq_error(item, "height %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
status = options_get_number(w->options, "pane-border-status");
|
||||||
|
switch (status) {
|
||||||
|
case PANE_STATUS_TOP:
|
||||||
|
if (y != INT_MAX && wp->yoff == 1)
|
||||||
|
y++;
|
||||||
|
break;
|
||||||
|
case PANE_STATUS_BOTTOM:
|
||||||
|
if (y != INT_MAX && wp->yoff + wp->sy == w->sy - 1)
|
||||||
|
y++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y);
|
layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'L'))
|
if (args_has(args, 'L'))
|
||||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust, 1);
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust, 1);
|
||||||
else if (args_has(self->args, 'R'))
|
else if (args_has(args, 'R'))
|
||||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust, 1);
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust, 1);
|
||||||
else if (args_has(self->args, 'U'))
|
else if (args_has(args, 'U'))
|
||||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust, 1);
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust, 1);
|
||||||
else if (args_has(self->args, 'D'))
|
else if (args_has(args, 'D'))
|
||||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust, 1);
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust, 1);
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
|
|
||||||
@@ -129,47 +152,64 @@ static void
|
|||||||
cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m)
|
cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m)
|
||||||
{
|
{
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window_pane *wp;
|
struct window *w;
|
||||||
int found;
|
u_int y, ly, x, lx;
|
||||||
u_int y, ly;
|
static const int offsets[][2] = {
|
||||||
|
{ 0, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 },
|
||||||
|
};
|
||||||
|
struct layout_cell *cells[nitems(offsets)], *lc;
|
||||||
|
u_int ncells = 0, i, j, resizes = 0;
|
||||||
|
enum layout_type type;
|
||||||
|
|
||||||
wl = cmd_mouse_window(m, NULL);
|
wl = cmd_mouse_window(m, NULL);
|
||||||
if (wl == NULL) {
|
if (wl == NULL) {
|
||||||
c->tty.mouse_drag_update = NULL;
|
c->tty.mouse_drag_update = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
w = wl->window;
|
||||||
|
|
||||||
y = m->y;
|
y = m->y + m->oy; x = m->x + m->ox;
|
||||||
if (m->statusat == 0 && y > 0)
|
if (m->statusat == 0 && y >= m->statuslines)
|
||||||
y--;
|
y -= m->statuslines;
|
||||||
else if (m->statusat > 0 && y >= (u_int)m->statusat)
|
else if (m->statusat > 0 && y >= (u_int)m->statusat)
|
||||||
y = m->statusat - 1;
|
y = m->statusat - 1;
|
||||||
ly = m->ly;
|
ly = m->ly + m->oy; lx = m->lx + m->ox;
|
||||||
if (m->statusat == 0 && ly > 0)
|
if (m->statusat == 0 && ly >= m->statuslines)
|
||||||
ly--;
|
ly -= m->statuslines;
|
||||||
else if (m->statusat > 0 && ly >= (u_int)m->statusat)
|
else if (m->statusat > 0 && ly >= (u_int)m->statusat)
|
||||||
ly = m->statusat - 1;
|
ly = m->statusat - 1;
|
||||||
|
|
||||||
found = 0;
|
for (i = 0; i < nitems(cells); i++) {
|
||||||
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
lc = layout_search_by_border(w->layout_root, lx + offsets[i][0],
|
||||||
if (!window_pane_visible(wp))
|
ly + offsets[i][1]);
|
||||||
|
if (lc == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (wp->xoff + wp->sx == m->lx &&
|
for (j = 0; j < ncells; j++) {
|
||||||
wp->yoff <= 1 + ly &&
|
if (cells[j] == lc) {
|
||||||
wp->yoff + wp->sy >= ly) {
|
lc = NULL;
|
||||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, m->x - m->lx, 0);
|
break;
|
||||||
found = 1;
|
}
|
||||||
}
|
}
|
||||||
if (wp->yoff + wp->sy == ly &&
|
if (lc == NULL)
|
||||||
wp->xoff <= 1 + m->lx &&
|
continue;
|
||||||
wp->xoff + wp->sx >= m->lx) {
|
|
||||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, y - ly, 0);
|
cells[ncells] = lc;
|
||||||
found = 1;
|
ncells++;
|
||||||
|
}
|
||||||
|
if (ncells == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < ncells; i++) {
|
||||||
|
type = cells[i]->parent->type;
|
||||||
|
if (y != ly && type == LAYOUT_TOPBOTTOM) {
|
||||||
|
layout_resize_layout(w, cells[i], type, y - ly, 0);
|
||||||
|
resizes++;
|
||||||
|
} else if (x != lx && type == LAYOUT_LEFTRIGHT) {
|
||||||
|
layout_resize_layout(w, cells[i], type, x - lx, 0);
|
||||||
|
resizes++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found)
|
if (resizes != 0)
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(w);
|
||||||
else
|
|
||||||
c->tty.mouse_drag_update = NULL;
|
|
||||||
}
|
}
|
||||||
|
|||||||
115
cmd-resize-window.c
Normal file
115
cmd-resize-window.c
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Increase or decrease window size.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_resize_window_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_resize_window_entry = {
|
||||||
|
.name = "resize-window",
|
||||||
|
.alias = "resizew",
|
||||||
|
|
||||||
|
.args = { "aADLRt:Ux:y:", 0, 1, NULL },
|
||||||
|
.usage = "[-aADLRU] [-x width] [-y height] " CMD_TARGET_WINDOW_USAGE " "
|
||||||
|
"[adjustment]",
|
||||||
|
|
||||||
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_resize_window_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct winlink *wl = target->wl;
|
||||||
|
struct window *w = wl->window;
|
||||||
|
struct session *s = target->s;
|
||||||
|
const char *errstr;
|
||||||
|
char *cause;
|
||||||
|
u_int adjust, sx, sy, xpixel = 0, ypixel = 0;
|
||||||
|
|
||||||
|
if (args_count(args) == 0)
|
||||||
|
adjust = 1;
|
||||||
|
else {
|
||||||
|
adjust = strtonum(args_string(args, 0), 1, INT_MAX, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
cmdq_error(item, "adjustment %s", errstr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sx = w->sx;
|
||||||
|
sy = w->sy;
|
||||||
|
|
||||||
|
if (args_has(args, 'x')) {
|
||||||
|
sx = args_strtonum(args, 'x', WINDOW_MINIMUM, WINDOW_MAXIMUM,
|
||||||
|
&cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "width %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args_has(args, 'y')) {
|
||||||
|
sy = args_strtonum(args, 'y', WINDOW_MINIMUM, WINDOW_MAXIMUM,
|
||||||
|
&cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "height %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'L')) {
|
||||||
|
if (sx >= adjust)
|
||||||
|
sx -= adjust;
|
||||||
|
} else if (args_has(args, 'R'))
|
||||||
|
sx += adjust;
|
||||||
|
else if (args_has(args, 'U')) {
|
||||||
|
if (sy >= adjust)
|
||||||
|
sy -= adjust;
|
||||||
|
} else if (args_has(args, 'D'))
|
||||||
|
sy += adjust;
|
||||||
|
|
||||||
|
if (args_has(args, 'A')) {
|
||||||
|
default_window_size(NULL, s, w, &sx, &sy, &xpixel, &ypixel,
|
||||||
|
WINDOW_SIZE_LARGEST);
|
||||||
|
} else if (args_has(args, 'a')) {
|
||||||
|
default_window_size(NULL, s, w, &sx, &sy, &xpixel, &ypixel,
|
||||||
|
WINDOW_SIZE_SMALLEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
options_set_number(w->options, "window-size", WINDOW_SIZE_MANUAL);
|
||||||
|
w->manual_sx = sx;
|
||||||
|
w->manual_sy = sy;
|
||||||
|
recalculate_size(w, 1);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -34,8 +34,9 @@ const struct cmd_entry cmd_respawn_pane_entry = {
|
|||||||
.name = "respawn-pane",
|
.name = "respawn-pane",
|
||||||
.alias = "respawnp",
|
.alias = "respawnp",
|
||||||
|
|
||||||
.args = { "kt:", 0, -1 },
|
.args = { "c:e:kt:", 0, -1, NULL },
|
||||||
.usage = "[-k] " CMD_TARGET_PANE_USAGE " [command]",
|
.usage = "[-k] [-c start-directory] [-e environment] "
|
||||||
|
CMD_TARGET_PANE_USAGE " [shell-command]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
@@ -46,49 +47,52 @@ const struct cmd_entry cmd_respawn_pane_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct winlink *wl = item->target.wl;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct window *w = wl->window;
|
struct spawn_context sc = { 0 };
|
||||||
struct window_pane *wp = item->target.wp;
|
struct session *s = target->s;
|
||||||
struct session *s = item->target.s;
|
struct winlink *wl = target->wl;
|
||||||
struct environ *env;
|
struct window_pane *wp = target->wp;
|
||||||
const char *path;
|
char *cause = NULL;
|
||||||
char *cause;
|
struct args_value *av;
|
||||||
u_int idx;
|
|
||||||
struct environ_entry *envent;
|
|
||||||
|
|
||||||
if (!args_has(self->args, 'k') && wp->fd != -1) {
|
sc.item = item;
|
||||||
if (window_pane_index(wp, &idx) != 0)
|
sc.s = s;
|
||||||
fatalx("index not found");
|
sc.wl = wl;
|
||||||
cmdq_error(item, "pane still active: %s:%d.%u",
|
|
||||||
s->name, wl->idx, idx);
|
sc.wp0 = wp;
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
args_to_vector(args, &sc.argc, &sc.argv);
|
||||||
|
sc.environ = environ_create();
|
||||||
|
|
||||||
|
av = args_first_value(args, 'e');
|
||||||
|
while (av != NULL) {
|
||||||
|
environ_put(sc.environ, av->string, 0);
|
||||||
|
av = args_next_value(av);
|
||||||
}
|
}
|
||||||
|
|
||||||
window_pane_reset_mode(wp);
|
sc.idx = -1;
|
||||||
screen_reinit(&wp->base);
|
sc.cwd = args_get(args, 'c');
|
||||||
input_init(wp);
|
|
||||||
|
|
||||||
path = NULL;
|
sc.flags = SPAWN_RESPAWN;
|
||||||
if (item->client != NULL && item->client->session == NULL)
|
if (args_has(args, 'k'))
|
||||||
envent = environ_find(item->client->environ, "PATH");
|
sc.flags |= SPAWN_KILL;
|
||||||
else
|
|
||||||
envent = environ_find(s->environ, "PATH");
|
|
||||||
if (envent != NULL)
|
|
||||||
path = envent->value;
|
|
||||||
|
|
||||||
env = environ_for_session(s, 0);
|
if (spawn_pane(&sc, &cause) == NULL) {
|
||||||
if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
|
|
||||||
s->tio, &cause) != 0) {
|
|
||||||
cmdq_error(item, "respawn pane failed: %s", cause);
|
cmdq_error(item, "respawn pane failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
environ_free(env);
|
if (sc.argv != NULL)
|
||||||
|
cmd_free_argv(sc.argc, sc.argv);
|
||||||
|
environ_free(sc.environ);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_free(env);
|
|
||||||
|
|
||||||
wp->flags |= PANE_REDRAW;
|
wp->flags |= PANE_REDRAW;
|
||||||
server_status_window(w);
|
server_redraw_window_borders(wp->window);
|
||||||
|
server_status_window(wp->window);
|
||||||
|
|
||||||
|
if (sc.argv != NULL)
|
||||||
|
cmd_free_argv(sc.argc, sc.argv);
|
||||||
|
environ_free(sc.environ);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -34,8 +34,9 @@ const struct cmd_entry cmd_respawn_window_entry = {
|
|||||||
.name = "respawn-window",
|
.name = "respawn-window",
|
||||||
.alias = "respawnw",
|
.alias = "respawnw",
|
||||||
|
|
||||||
.args = { "kt:", 0, -1 },
|
.args = { "c:e:kt:", 0, -1, NULL },
|
||||||
.usage = "[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
|
.usage = "[-k] [-c start-directory] [-e environment] "
|
||||||
|
CMD_TARGET_WINDOW_USAGE " [shell-command]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
|
|
||||||
@@ -46,59 +47,49 @@ const struct cmd_entry cmd_respawn_window_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct session *s = item->target.s;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct winlink *wl = item->target.wl;
|
struct spawn_context sc = { 0 };
|
||||||
struct window *w = wl->window;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct window_pane *wp;
|
struct session *s = target->s;
|
||||||
struct environ *env;
|
struct winlink *wl = target->wl;
|
||||||
const char *path;
|
char *cause = NULL;
|
||||||
char *cause;
|
struct args_value *av;
|
||||||
struct environ_entry *envent;
|
|
||||||
|
|
||||||
if (!args_has(self->args, 'k')) {
|
sc.item = item;
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
sc.s = s;
|
||||||
if (wp->fd == -1)
|
sc.wl = wl;
|
||||||
continue;
|
sc.tc = tc;
|
||||||
cmdq_error(item, "window still active: %s:%d", s->name,
|
|
||||||
wl->idx);
|
args_to_vector(args, &sc.argc, &sc.argv);
|
||||||
return (CMD_RETURN_ERROR);
|
sc.environ = environ_create();
|
||||||
}
|
|
||||||
|
av = args_first_value(args, 'e');
|
||||||
|
while (av != NULL) {
|
||||||
|
environ_put(sc.environ, av->string, 0);
|
||||||
|
av = args_next_value(av);
|
||||||
}
|
}
|
||||||
|
|
||||||
wp = TAILQ_FIRST(&w->panes);
|
sc.idx = -1;
|
||||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
sc.cwd = args_get(args, 'c');
|
||||||
layout_free(w);
|
|
||||||
window_destroy_panes(w);
|
|
||||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
|
||||||
window_pane_resize(wp, w->sx, w->sy);
|
|
||||||
|
|
||||||
path = NULL;
|
sc.flags = SPAWN_RESPAWN;
|
||||||
if (item->client != NULL && item->client->session == NULL)
|
if (args_has(args, 'k'))
|
||||||
envent = environ_find(item->client->environ, "PATH");
|
sc.flags |= SPAWN_KILL;
|
||||||
else
|
|
||||||
envent = environ_find(s->environ, "PATH");
|
|
||||||
if (envent != NULL)
|
|
||||||
path = envent->value;
|
|
||||||
|
|
||||||
env = environ_for_session(s, 0);
|
if (spawn_window(&sc, &cause) == NULL) {
|
||||||
if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
|
|
||||||
s->tio, &cause) != 0) {
|
|
||||||
cmdq_error(item, "respawn window failed: %s", cause);
|
cmdq_error(item, "respawn window failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
environ_free(env);
|
if (sc.argv != NULL)
|
||||||
server_destroy_pane(wp, 0);
|
cmd_free_argv(sc.argc, sc.argv);
|
||||||
|
environ_free(sc.environ);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_free(env);
|
|
||||||
layout_init(w, wp);
|
|
||||||
window_pane_reset_mode(wp);
|
|
||||||
screen_reinit(&wp->base);
|
|
||||||
input_init(wp);
|
|
||||||
window_set_active_pane(w, wp);
|
|
||||||
|
|
||||||
recalculate_sizes();
|
server_redraw_window(wl->window);
|
||||||
server_redraw_window(w);
|
|
||||||
|
|
||||||
|
if (sc.argv != NULL)
|
||||||
|
cmd_free_argv(sc.argc, sc.argv);
|
||||||
|
environ_free(sc.environ);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ const struct cmd_entry cmd_rotate_window_entry = {
|
|||||||
.name = "rotate-window",
|
.name = "rotate-window",
|
||||||
.alias = "rotatew",
|
.alias = "rotatew",
|
||||||
|
|
||||||
.args = { "Dt:U", 0, 0 },
|
.args = { "Dt:UZ", 0, 0, NULL },
|
||||||
.usage = "[-DU] " CMD_TARGET_WINDOW_USAGE,
|
.usage = "[-DUZ] " CMD_TARGET_WINDOW_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
|
|
||||||
@@ -43,16 +43,18 @@ const struct cmd_entry cmd_rotate_window_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct cmd_find_state *current = &item->shared->current;
|
struct args *args = cmd_get_args(self);
|
||||||
struct winlink *wl = item->target.wl;
|
struct cmd_find_state *current = cmdq_get_current(item);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct winlink *wl = target->wl;
|
||||||
struct window *w = wl->window;
|
struct window *w = wl->window;
|
||||||
struct window_pane *wp, *wp2;
|
struct window_pane *wp, *wp2;
|
||||||
struct layout_cell *lc;
|
struct layout_cell *lc;
|
||||||
u_int sx, sy, xoff, yoff;
|
u_int sx, sy, xoff, yoff;
|
||||||
|
|
||||||
server_unzoom_window(w);
|
window_push_zoom(w, 0, args_has(args, 'Z'));
|
||||||
|
|
||||||
if (args_has(self->args, 'D')) {
|
if (args_has(args, 'D')) {
|
||||||
wp = TAILQ_LAST(&w->panes, window_panes);
|
wp = TAILQ_LAST(&w->panes, window_panes);
|
||||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||||
@@ -77,9 +79,6 @@ cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
if ((wp = TAILQ_PREV(w->active, window_panes, entry)) == NULL)
|
if ((wp = TAILQ_PREV(w->active, window_panes, entry)) == NULL)
|
||||||
wp = TAILQ_LAST(&w->panes, window_panes);
|
wp = TAILQ_LAST(&w->panes, window_panes);
|
||||||
window_set_active_pane(w, wp);
|
|
||||||
cmd_find_from_winlink_pane(current, wl, wp);
|
|
||||||
server_redraw_window(w);
|
|
||||||
} else {
|
} else {
|
||||||
wp = TAILQ_FIRST(&w->panes);
|
wp = TAILQ_FIRST(&w->panes);
|
||||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
@@ -105,10 +104,12 @@ cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
if ((wp = TAILQ_NEXT(w->active, entry)) == NULL)
|
if ((wp = TAILQ_NEXT(w->active, entry)) == NULL)
|
||||||
wp = TAILQ_FIRST(&w->panes);
|
wp = TAILQ_FIRST(&w->panes);
|
||||||
window_set_active_pane(w, wp);
|
|
||||||
cmd_find_from_winlink_pane(current, wl, wp);
|
|
||||||
server_redraw_window(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window_set_active_pane(w, wp, 1);
|
||||||
|
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||||
|
window_pop_zoom(w);
|
||||||
|
server_redraw_window(w);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
210
cmd-run-shell.c
210
cmd-run-shell.c
@@ -20,6 +20,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -29,8 +30,12 @@
|
|||||||
* Runs a command without a window.
|
* Runs a command without a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static enum cmd_retval cmd_run_shell_exec(struct cmd *, struct cmdq_item *);
|
static enum args_parse_type cmd_run_shell_args_parse(struct args *, u_int,
|
||||||
|
char **);
|
||||||
|
static enum cmd_retval cmd_run_shell_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
|
static void cmd_run_shell_timer(int, short, void *);
|
||||||
static void cmd_run_shell_callback(struct job *);
|
static void cmd_run_shell_callback(struct job *);
|
||||||
static void cmd_run_shell_free(void *);
|
static void cmd_run_shell_free(void *);
|
||||||
static void cmd_run_shell_print(struct job *, const char *);
|
static void cmd_run_shell_print(struct job *, const char *);
|
||||||
@@ -39,8 +44,9 @@ const struct cmd_entry cmd_run_shell_entry = {
|
|||||||
.name = "run-shell",
|
.name = "run-shell",
|
||||||
.alias = "run",
|
.alias = "run",
|
||||||
|
|
||||||
.args = { "bt:", 1, 1 },
|
.args = { "bd:Ct:c:", 0, 2, cmd_run_shell_args_parse },
|
||||||
.usage = "[-b] " CMD_TARGET_PANE_USAGE " shell-command",
|
.usage = "[-bC] [-c start-directory] [-d delay] " CMD_TARGET_PANE_USAGE
|
||||||
|
" [shell-command]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
@@ -49,17 +55,33 @@ const struct cmd_entry cmd_run_shell_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_run_shell_data {
|
struct cmd_run_shell_data {
|
||||||
char *cmd;
|
struct client *client;
|
||||||
struct cmdq_item *item;
|
char *cmd;
|
||||||
int wp_id;
|
struct args_command_state *state;
|
||||||
|
char *cwd;
|
||||||
|
struct cmdq_item *item;
|
||||||
|
struct session *s;
|
||||||
|
int wp_id;
|
||||||
|
struct event timer;
|
||||||
|
int flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static enum args_parse_type
|
||||||
|
cmd_run_shell_args_parse(struct args *args, __unused u_int idx,
|
||||||
|
__unused char **cause)
|
||||||
|
{
|
||||||
|
if (args_has(args, 'C'))
|
||||||
|
return (ARGS_PARSE_COMMANDS_OR_STRING);
|
||||||
|
return (ARGS_PARSE_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cmd_run_shell_print(struct job *job, const char *msg)
|
cmd_run_shell_print(struct job *job, const char *msg)
|
||||||
{
|
{
|
||||||
struct cmd_run_shell_data *cdata = job->data;
|
struct cmd_run_shell_data *cdata = job_get_data(job);
|
||||||
struct window_pane *wp = NULL;
|
struct window_pane *wp = NULL;
|
||||||
struct cmd_find_state fs;
|
struct cmd_find_state fs;
|
||||||
|
struct window_mode_entry *wme;
|
||||||
|
|
||||||
if (cdata->wp_id != -1)
|
if (cdata->wp_id != -1)
|
||||||
wp = window_pane_find_by_id(cdata->wp_id);
|
wp = window_pane_find_by_id(cdata->wp_id);
|
||||||
@@ -68,75 +90,159 @@ cmd_run_shell_print(struct job *job, const char *msg)
|
|||||||
cmdq_print(cdata->item, "%s", msg);
|
cmdq_print(cdata->item, "%s", msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cmd_find_from_nothing(&fs) != 0)
|
if (cdata->item != NULL && cdata->client != NULL)
|
||||||
return;
|
wp = server_client_get_pane(cdata->client);
|
||||||
wp = fs.wp;
|
if (wp == NULL && cmd_find_from_nothing(&fs, 0) == 0)
|
||||||
|
wp = fs.wp;
|
||||||
if (wp == NULL)
|
if (wp == NULL)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window_pane_set_mode(wp, &window_copy_mode) == 0)
|
wme = TAILQ_FIRST(&wp->modes);
|
||||||
window_copy_init_for_output(wp);
|
if (wme == NULL || wme->mode != &window_view_mode)
|
||||||
if (wp->mode == &window_copy_mode)
|
window_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL);
|
||||||
window_copy_add(wp, "%s", msg);
|
window_copy_add(wp, 1, "%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct cmd_run_shell_data *cdata;
|
struct cmd_run_shell_data *cdata;
|
||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
struct client *c = cmdq_get_client(item);
|
||||||
struct session *s = item->target.s;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct winlink *wl = item->target.wl;
|
struct session *s = target->s;
|
||||||
struct window_pane *wp = item->target.wp;
|
struct window_pane *wp = target->wp;
|
||||||
const char *cwd;
|
const char *delay, *cmd;
|
||||||
|
double d;
|
||||||
|
struct timeval tv;
|
||||||
|
char *end;
|
||||||
|
int wait = !args_has(args, 'b');
|
||||||
|
|
||||||
if (item->client != NULL && item->client->session == NULL)
|
if ((delay = args_get(args, 'd')) != NULL) {
|
||||||
cwd = item->client->cwd;
|
d = strtod(delay, &end);
|
||||||
else if (s != NULL)
|
if (*end != '\0') {
|
||||||
cwd = s->cwd;
|
cmdq_error(item, "invalid delay time: %s", delay);
|
||||||
else
|
return (CMD_RETURN_ERROR);
|
||||||
cwd = NULL;
|
}
|
||||||
|
} else if (args_count(args) == 0)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
cdata = xcalloc(1, sizeof *cdata);
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
cdata->cmd = format_single(item, args->argv[0], c, s, wl, wp);
|
if (!args_has(args, 'C')) {
|
||||||
|
cmd = args_string(args, 0);
|
||||||
|
if (cmd != NULL)
|
||||||
|
cdata->cmd = format_single_from_target(item, cmd);
|
||||||
|
} else {
|
||||||
|
cdata->state = args_make_commands_prepare(self, item, 0, NULL,
|
||||||
|
wait, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (args_has(args, 't') && wp != NULL)
|
if (args_has(args, 't') && wp != NULL)
|
||||||
cdata->wp_id = wp->id;
|
cdata->wp_id = wp->id;
|
||||||
else
|
else
|
||||||
cdata->wp_id = -1;
|
cdata->wp_id = -1;
|
||||||
|
|
||||||
if (!args_has(args, 'b'))
|
if (wait) {
|
||||||
|
cdata->client = c;
|
||||||
cdata->item = item;
|
cdata->item = item;
|
||||||
|
} else {
|
||||||
|
cdata->client = tc;
|
||||||
|
cdata->flags |= JOB_NOWAIT;
|
||||||
|
}
|
||||||
|
if (cdata->client != NULL)
|
||||||
|
cdata->client->references++;
|
||||||
|
if (args_has(args, 'c'))
|
||||||
|
cdata->cwd = xstrdup(args_get(args, 'c'));
|
||||||
|
else
|
||||||
|
cdata->cwd = xstrdup(server_client_get_cwd(c, s));
|
||||||
|
|
||||||
job_run(cdata->cmd, s, cwd, NULL, cmd_run_shell_callback,
|
cdata->s = s;
|
||||||
cmd_run_shell_free, cdata);
|
if (s != NULL)
|
||||||
|
session_add_ref(s, __func__);
|
||||||
|
|
||||||
if (args_has(args, 'b'))
|
evtimer_set(&cdata->timer, cmd_run_shell_timer, cdata);
|
||||||
|
if (delay != NULL) {
|
||||||
|
timerclear(&tv);
|
||||||
|
tv.tv_sec = (time_t)d;
|
||||||
|
tv.tv_usec = (d - (double)tv.tv_sec) * 1000000U;
|
||||||
|
evtimer_add(&cdata->timer, &tv);
|
||||||
|
} else
|
||||||
|
event_active(&cdata->timer, EV_TIMEOUT, 1);
|
||||||
|
|
||||||
|
if (!wait)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
return (CMD_RETURN_WAIT);
|
return (CMD_RETURN_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_run_shell_timer(__unused int fd, __unused short events, void* arg)
|
||||||
|
{
|
||||||
|
struct cmd_run_shell_data *cdata = arg;
|
||||||
|
struct client *c = cdata->client;
|
||||||
|
const char *cmd = cdata->cmd;
|
||||||
|
struct cmdq_item *item = cdata->item, *new_item;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
char *error;
|
||||||
|
|
||||||
|
if (cdata->state == NULL) {
|
||||||
|
if (cmd == NULL) {
|
||||||
|
if (cdata->item != NULL)
|
||||||
|
cmdq_continue(cdata->item);
|
||||||
|
cmd_run_shell_free(cdata);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (job_run(cmd, 0, NULL, NULL, cdata->s, cdata->cwd, NULL,
|
||||||
|
cmd_run_shell_callback, cmd_run_shell_free, cdata,
|
||||||
|
cdata->flags, -1, -1) == NULL)
|
||||||
|
cmd_run_shell_free(cdata);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdlist = args_make_commands(cdata->state, 0, NULL, &error);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
|
if (cdata->item == NULL) {
|
||||||
|
*error = toupper((u_char)*error);
|
||||||
|
status_message_set(c, -1, 1, 0, "%s", error);
|
||||||
|
} else
|
||||||
|
cmdq_error(cdata->item, "%s", error);
|
||||||
|
free(error);
|
||||||
|
} else if (item == NULL) {
|
||||||
|
new_item = cmdq_get_command(cmdlist, NULL);
|
||||||
|
cmdq_append(c, new_item);
|
||||||
|
} else {
|
||||||
|
new_item = cmdq_get_command(cmdlist, cmdq_get_state(item));
|
||||||
|
cmdq_insert_after(item, new_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cdata->item != NULL)
|
||||||
|
cmdq_continue(cdata->item);
|
||||||
|
cmd_run_shell_free(cdata);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cmd_run_shell_callback(struct job *job)
|
cmd_run_shell_callback(struct job *job)
|
||||||
{
|
{
|
||||||
struct cmd_run_shell_data *cdata = job->data;
|
struct cmd_run_shell_data *cdata = job_get_data(job);
|
||||||
char *cmd = cdata->cmd, *msg, *line;
|
struct bufferevent *event = job_get_event(job);
|
||||||
|
struct cmdq_item *item = cdata->item;
|
||||||
|
char *cmd = cdata->cmd, *msg = NULL, *line;
|
||||||
size_t size;
|
size_t size;
|
||||||
int retcode;
|
int retcode, status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if ((line = evbuffer_readline(job->event->input)) != NULL) {
|
line = evbuffer_readln(event->input, NULL, EVBUFFER_EOL_LF);
|
||||||
|
if (line != NULL) {
|
||||||
cmd_run_shell_print(job, line);
|
cmd_run_shell_print(job, line);
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
} while (line != NULL);
|
} while (line != NULL);
|
||||||
|
|
||||||
size = EVBUFFER_LENGTH(job->event->input);
|
size = EVBUFFER_LENGTH(event->input);
|
||||||
if (size != 0) {
|
if (size != 0) {
|
||||||
line = xmalloc(size + 1);
|
line = xmalloc(size + 1);
|
||||||
memcpy(line, EVBUFFER_DATA(job->event->input), size);
|
memcpy(line, EVBUFFER_DATA(event->input), size);
|
||||||
line[size] = '\0';
|
line[size] = '\0';
|
||||||
|
|
||||||
cmd_run_shell_print(job, line);
|
cmd_run_shell_print(job, line);
|
||||||
@@ -144,20 +250,26 @@ cmd_run_shell_callback(struct job *job)
|
|||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = NULL;
|
status = job_get_status(job);
|
||||||
if (WIFEXITED(job->status)) {
|
if (WIFEXITED(status)) {
|
||||||
if ((retcode = WEXITSTATUS(job->status)) != 0)
|
if ((retcode = WEXITSTATUS(status)) != 0)
|
||||||
xasprintf(&msg, "'%s' returned %d", cmd, retcode);
|
xasprintf(&msg, "'%s' returned %d", cmd, retcode);
|
||||||
} else if (WIFSIGNALED(job->status)) {
|
} else if (WIFSIGNALED(status)) {
|
||||||
retcode = WTERMSIG(job->status);
|
retcode = WTERMSIG(status);
|
||||||
xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode);
|
xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode);
|
||||||
}
|
retcode += 128;
|
||||||
|
} else
|
||||||
|
retcode = 0;
|
||||||
if (msg != NULL)
|
if (msg != NULL)
|
||||||
cmd_run_shell_print(job, msg);
|
cmd_run_shell_print(job, msg);
|
||||||
free(msg);
|
free(msg);
|
||||||
|
|
||||||
if (cdata->item != NULL)
|
if (item != NULL) {
|
||||||
cdata->item->flags &= ~CMDQ_WAITING;
|
if (cmdq_get_client(item) != NULL &&
|
||||||
|
cmdq_get_client(item)->session == NULL)
|
||||||
|
cmdq_get_client(item)->retval = retcode;
|
||||||
|
cmdq_continue(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -165,6 +277,14 @@ cmd_run_shell_free(void *data)
|
|||||||
{
|
{
|
||||||
struct cmd_run_shell_data *cdata = data;
|
struct cmd_run_shell_data *cdata = data;
|
||||||
|
|
||||||
|
evtimer_del(&cdata->timer);
|
||||||
|
if (cdata->s != NULL)
|
||||||
|
session_remove_ref(cdata->s, __func__);
|
||||||
|
if (cdata->client != NULL)
|
||||||
|
server_client_unref(cdata->client);
|
||||||
|
if (cdata->state != NULL)
|
||||||
|
args_make_commands_free(cdata->state);
|
||||||
|
free(cdata->cwd);
|
||||||
free(cdata->cmd);
|
free(cdata->cmd);
|
||||||
free(cdata);
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const struct cmd_entry cmd_save_buffer_entry = {
|
|||||||
.name = "save-buffer",
|
.name = "save-buffer",
|
||||||
.alias = "saveb",
|
.alias = "saveb",
|
||||||
|
|
||||||
.args = { "ab:", 1, 1 },
|
.args = { "ab:", 1, 1, NULL },
|
||||||
.usage = "[-a] " CMD_BUFFER_USAGE " path",
|
.usage = "[-a] " CMD_BUFFER_USAGE " path",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
@@ -48,32 +48,45 @@ const struct cmd_entry cmd_show_buffer_entry = {
|
|||||||
.name = "show-buffer",
|
.name = "show-buffer",
|
||||||
.alias = "showb",
|
.alias = "showb",
|
||||||
|
|
||||||
.args = { "b:", 0, 0 },
|
.args = { "b:", 0, 0, NULL },
|
||||||
.usage = CMD_BUFFER_USAGE,
|
.usage = CMD_BUFFER_USAGE,
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_save_buffer_exec
|
.exec = cmd_save_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_save_buffer_done(__unused struct client *c, const char *path, int error,
|
||||||
|
__unused int closed, __unused struct evbuffer *buffer, void *data)
|
||||||
|
{
|
||||||
|
struct cmdq_item *item = data;
|
||||||
|
|
||||||
|
if (!closed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (error != 0)
|
||||||
|
cmdq_error(item, "%s: %s", path, strerror(error));
|
||||||
|
cmdq_continue(item);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct client *c = item->client;
|
struct client *c = cmdq_get_client(item);
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
const char *path, *bufname, *bufdata, *start, *end;
|
int flags;
|
||||||
const char *flags;
|
const char *bufname = args_get(args, 'b'), *bufdata;
|
||||||
char *msg, *file;
|
size_t bufsize;
|
||||||
size_t size, used, msglen, bufsize;
|
char *path;
|
||||||
FILE *f;
|
struct evbuffer *evb;
|
||||||
|
|
||||||
if (!args_has(args, 'b')) {
|
if (bufname == NULL) {
|
||||||
if ((pb = paste_get_top(NULL)) == NULL) {
|
if ((pb = paste_get_top(NULL)) == NULL) {
|
||||||
cmdq_error(item, "no buffers");
|
cmdq_error(item, "no buffers");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bufname = args_get(args, 'b');
|
|
||||||
pb = paste_get_name(bufname);
|
pb = paste_get_name(bufname);
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
cmdq_error(item, "no buffer %s", bufname);
|
cmdq_error(item, "no buffer %s", bufname);
|
||||||
@@ -82,74 +95,26 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
bufdata = paste_buffer_data(pb, &bufsize);
|
bufdata = paste_buffer_data(pb, &bufsize);
|
||||||
|
|
||||||
if (self->entry == &cmd_show_buffer_entry)
|
if (cmd_get_entry(self) == &cmd_show_buffer_entry) {
|
||||||
path = "-";
|
if (c->session != NULL || (c->flags & CLIENT_CONTROL)) {
|
||||||
else
|
evb = evbuffer_new();
|
||||||
path = args->argv[0];
|
if (evb == NULL)
|
||||||
if (strcmp(path, "-") == 0) {
|
fatalx("out of memory");
|
||||||
if (c == NULL) {
|
evbuffer_add(evb, bufdata, bufsize);
|
||||||
cmdq_error(item, "can't write to stdout");
|
cmdq_print_data(item, 1, evb);
|
||||||
return (CMD_RETURN_ERROR);
|
evbuffer_free(evb);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
if (c->session == NULL || (c->flags & CLIENT_CONTROL))
|
path = xstrdup("-");
|
||||||
goto do_stdout;
|
} else
|
||||||
goto do_print;
|
path = format_single_from_target(item, args_string(args, 0));
|
||||||
}
|
if (args_has(args, 'a'))
|
||||||
|
flags = O_APPEND;
|
||||||
|
else
|
||||||
|
flags = O_TRUNC;
|
||||||
|
file_write(cmdq_get_client(item), path, flags, bufdata, bufsize,
|
||||||
|
cmd_save_buffer_done, item);
|
||||||
|
free(path);
|
||||||
|
|
||||||
flags = "wb";
|
return (CMD_RETURN_WAIT);
|
||||||
if (args_has(self->args, 'a'))
|
|
||||||
flags = "ab";
|
|
||||||
|
|
||||||
file = server_client_get_path(c, path);
|
|
||||||
f = fopen(file, flags);
|
|
||||||
if (f == NULL) {
|
|
||||||
cmdq_error(item, "%s: %s", file, strerror(errno));
|
|
||||||
free(file);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fwrite(bufdata, 1, bufsize, f) != bufsize) {
|
|
||||||
cmdq_error(item, "%s: write error", file);
|
|
||||||
fclose(f);
|
|
||||||
free(file);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
free(file);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
|
|
||||||
do_stdout:
|
|
||||||
evbuffer_add(c->stdout_data, bufdata, bufsize);
|
|
||||||
server_client_push_stdout(c);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
|
|
||||||
do_print:
|
|
||||||
if (bufsize > (INT_MAX / 4) - 1) {
|
|
||||||
cmdq_error(item, "buffer too big");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
msg = NULL;
|
|
||||||
|
|
||||||
used = 0;
|
|
||||||
while (used != bufsize) {
|
|
||||||
start = bufdata + used;
|
|
||||||
end = memchr(start, '\n', bufsize - used);
|
|
||||||
if (end != NULL)
|
|
||||||
size = end - start;
|
|
||||||
else
|
|
||||||
size = bufsize - used;
|
|
||||||
|
|
||||||
msglen = size * 4 + 1;
|
|
||||||
msg = xrealloc(msg, msglen);
|
|
||||||
|
|
||||||
strvisx(msg, start, size, VIS_OCTAL|VIS_TAB);
|
|
||||||
cmdq_print(item, "%s", msg);
|
|
||||||
|
|
||||||
used += size + (end != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(msg);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ const struct cmd_entry cmd_select_layout_entry = {
|
|||||||
.name = "select-layout",
|
.name = "select-layout",
|
||||||
.alias = "selectl",
|
.alias = "selectl",
|
||||||
|
|
||||||
.args = { "nopt:", 0, 1 },
|
.args = { "Enopt:", 0, 1, NULL },
|
||||||
.usage = "[-nop] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
.usage = "[-Enop] " CMD_TARGET_PANE_USAGE " [layout-name]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_select_layout_exec
|
.exec = cmd_select_layout_exec
|
||||||
@@ -46,7 +46,7 @@ const struct cmd_entry cmd_next_layout_entry = {
|
|||||||
.name = "next-layout",
|
.name = "next-layout",
|
||||||
.alias = "nextl",
|
.alias = "nextl",
|
||||||
|
|
||||||
.args = { "t:", 0, 0 },
|
.args = { "t:", 0, 0, NULL },
|
||||||
.usage = CMD_TARGET_WINDOW_USAGE,
|
.usage = CMD_TARGET_WINDOW_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
@@ -59,7 +59,7 @@ const struct cmd_entry cmd_previous_layout_entry = {
|
|||||||
.name = "previous-layout",
|
.name = "previous-layout",
|
||||||
.alias = "prevl",
|
.alias = "prevl",
|
||||||
|
|
||||||
.args = { "t:", 0, 0 },
|
.args = { "t:", 0, 0, NULL },
|
||||||
.usage = CMD_TARGET_WINDOW_USAGE,
|
.usage = CMD_TARGET_WINDOW_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
@@ -71,20 +71,21 @@ const struct cmd_entry cmd_previous_layout_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct winlink *wl = item->target.wl;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct window *w;
|
struct winlink *wl = target->wl;
|
||||||
const char *layoutname;
|
struct window *w = wl->window;
|
||||||
char *oldlayout;
|
struct window_pane *wp = target->wp;
|
||||||
int next, previous, layout;
|
const char *layoutname;
|
||||||
|
char *oldlayout, *cause;
|
||||||
|
int next, previous, layout;
|
||||||
|
|
||||||
w = wl->window;
|
|
||||||
server_unzoom_window(w);
|
server_unzoom_window(w);
|
||||||
|
|
||||||
next = self->entry == &cmd_next_layout_entry;
|
next = (cmd_get_entry(self) == &cmd_next_layout_entry);
|
||||||
if (args_has(args, 'n'))
|
if (args_has(args, 'n'))
|
||||||
next = 1;
|
next = 1;
|
||||||
previous = self->entry == &cmd_previous_layout_entry;
|
previous = (cmd_get_entry(self) == &cmd_previous_layout_entry);
|
||||||
if (args_has(args, 'p'))
|
if (args_has(args, 'p'))
|
||||||
previous = 1;
|
previous = 1;
|
||||||
|
|
||||||
@@ -99,27 +100,33 @@ cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
goto changed;
|
goto changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'E')) {
|
||||||
|
layout_spread_out(wp);
|
||||||
|
goto changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_count(args) != 0)
|
||||||
|
layoutname = args_string(args, 0);
|
||||||
|
else if (args_has(args, 'o'))
|
||||||
|
layoutname = oldlayout;
|
||||||
|
else
|
||||||
|
layoutname = NULL;
|
||||||
|
|
||||||
if (!args_has(args, 'o')) {
|
if (!args_has(args, 'o')) {
|
||||||
if (args->argc == 0)
|
if (layoutname == NULL)
|
||||||
layout = w->lastlayout;
|
layout = w->lastlayout;
|
||||||
else
|
else
|
||||||
layout = layout_set_lookup(args->argv[0]);
|
layout = layout_set_lookup(layoutname);
|
||||||
if (layout != -1) {
|
if (layout != -1) {
|
||||||
layout_set_select(w, layout);
|
layout_set_select(w, layout);
|
||||||
goto changed;
|
goto changed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc != 0)
|
|
||||||
layoutname = args->argv[0];
|
|
||||||
else if (args_has(args, 'o'))
|
|
||||||
layoutname = oldlayout;
|
|
||||||
else
|
|
||||||
layoutname = NULL;
|
|
||||||
|
|
||||||
if (layoutname != NULL) {
|
if (layoutname != NULL) {
|
||||||
if (layout_parse(w, layoutname) == -1) {
|
if (layout_parse(w, layoutname, &cause) == -1) {
|
||||||
cmdq_error(item, "can't set layout: %s", layoutname);
|
cmdq_error(item, "%s: %s", cause, layoutname);
|
||||||
|
free(cause);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
goto changed;
|
goto changed;
|
||||||
@@ -130,7 +137,9 @@ cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
changed:
|
changed:
|
||||||
free(oldlayout);
|
free(oldlayout);
|
||||||
|
recalculate_sizes();
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
|
notify_window("window-layout-changed", w);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -30,8 +33,8 @@ const struct cmd_entry cmd_select_pane_entry = {
|
|||||||
.name = "select-pane",
|
.name = "select-pane",
|
||||||
.alias = "selectp",
|
.alias = "selectp",
|
||||||
|
|
||||||
.args = { "DdegLlMmP:Rt:U", 0, 0 },
|
.args = { "DdegLlMmP:RT:t:UZ", 0, 0, NULL }, /* -P and -g deprecated */
|
||||||
.usage = "[-DdegLlMmRU] [-P style] " CMD_TARGET_PANE_USAGE,
|
.usage = "[-DdeLlMmRUZ] [-T title] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
@@ -43,8 +46,8 @@ const struct cmd_entry cmd_last_pane_entry = {
|
|||||||
.name = "last-pane",
|
.name = "last-pane",
|
||||||
.alias = "lastp",
|
.alias = "lastp",
|
||||||
|
|
||||||
.args = { "det:", 0, 0 },
|
.args = { "det:Z", 0, 0, NULL },
|
||||||
.usage = "[-de] " CMD_TARGET_WINDOW_USAGE,
|
.usage = "[-deZ] " CMD_TARGET_WINDOW_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
|
|
||||||
@@ -52,35 +55,81 @@ const struct cmd_entry cmd_last_pane_entry = {
|
|||||||
.exec = cmd_select_pane_exec
|
.exec = cmd_select_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_select_pane_redraw(struct window *w)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Redraw entire window if it is bigger than the client (the
|
||||||
|
* offset may change), otherwise just draw borders.
|
||||||
|
*/
|
||||||
|
|
||||||
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
|
if (c->session == NULL || (c->flags & CLIENT_CONTROL))
|
||||||
|
continue;
|
||||||
|
if (c->session->curw->window == w && tty_window_bigger(&c->tty))
|
||||||
|
server_redraw_client(c);
|
||||||
|
else {
|
||||||
|
if (c->session->curw->window == w)
|
||||||
|
c->flags |= CLIENT_REDRAWBORDERS;
|
||||||
|
if (session_has(c->session, w))
|
||||||
|
c->flags |= CLIENT_REDRAWSTATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct cmd_find_state *current = &item->shared->current;
|
const struct cmd_entry *entry = cmd_get_entry(self);
|
||||||
struct winlink *wl = item->target.wl;
|
struct cmd_find_state *current = cmdq_get_current(item);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct client *c = cmdq_get_client(item);
|
||||||
|
struct winlink *wl = target->wl;
|
||||||
struct window *w = wl->window;
|
struct window *w = wl->window;
|
||||||
struct session *s = item->target.s;
|
struct session *s = target->s;
|
||||||
struct window_pane *wp = item->target.wp, *lastwp, *markedwp;
|
struct window_pane *wp = target->wp, *activewp, *lastwp, *markedwp;
|
||||||
|
struct options *oo = wp->options;
|
||||||
|
char *title;
|
||||||
const char *style;
|
const char *style;
|
||||||
|
struct options_entry *o;
|
||||||
|
|
||||||
if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) {
|
if (entry == &cmd_last_pane_entry || args_has(args, 'l')) {
|
||||||
lastwp = w->last;
|
/*
|
||||||
|
* Check for no last pane found in case the other pane was
|
||||||
|
* spawned without being visited (for example split-window -d).
|
||||||
|
*/
|
||||||
|
lastwp = TAILQ_FIRST(&w->last_panes);
|
||||||
|
if (lastwp == NULL && window_count_panes(w) == 2) {
|
||||||
|
lastwp = TAILQ_PREV(w->active, window_panes, entry);
|
||||||
|
if (lastwp == NULL)
|
||||||
|
lastwp = TAILQ_NEXT(w->active, entry);
|
||||||
|
}
|
||||||
if (lastwp == NULL) {
|
if (lastwp == NULL) {
|
||||||
cmdq_error(item, "no last pane");
|
cmdq_error(item, "no last pane");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (args_has(self->args, 'e'))
|
if (args_has(args, 'e')) {
|
||||||
lastwp->flags &= ~PANE_INPUTOFF;
|
lastwp->flags &= ~PANE_INPUTOFF;
|
||||||
else if (args_has(self->args, 'd'))
|
server_redraw_window_borders(lastwp->window);
|
||||||
|
server_status_window(lastwp->window);
|
||||||
|
} else if (args_has(args, 'd')) {
|
||||||
lastwp->flags |= PANE_INPUTOFF;
|
lastwp->flags |= PANE_INPUTOFF;
|
||||||
else {
|
server_redraw_window_borders(lastwp->window);
|
||||||
server_unzoom_window(w);
|
server_status_window(lastwp->window);
|
||||||
|
} else {
|
||||||
|
if (window_push_zoom(w, 0, args_has(args, 'Z')))
|
||||||
|
server_redraw_window(w);
|
||||||
window_redraw_active_switch(w, lastwp);
|
window_redraw_active_switch(w, lastwp);
|
||||||
if (window_set_active_pane(w, lastwp)) {
|
if (window_set_active_pane(w, lastwp, 1)) {
|
||||||
cmd_find_from_winlink(current, wl);
|
cmd_find_from_winlink(current, wl, 0);
|
||||||
server_status_window(w);
|
cmd_select_pane_redraw(w);
|
||||||
server_redraw_window_borders(w);
|
|
||||||
}
|
}
|
||||||
|
if (window_pop_zoom(w))
|
||||||
|
server_redraw_window(w);
|
||||||
}
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
@@ -88,7 +137,10 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (args_has(args, 'm') || args_has(args, 'M')) {
|
if (args_has(args, 'm') || args_has(args, 'M')) {
|
||||||
if (args_has(args, 'm') && !window_pane_visible(wp))
|
if (args_has(args, 'm') && !window_pane_visible(wp))
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
lastwp = marked_pane.wp;
|
if (server_check_marked())
|
||||||
|
lastwp = marked_pane.wp;
|
||||||
|
else
|
||||||
|
lastwp = NULL;
|
||||||
|
|
||||||
if (args_has(args, 'M') || server_is_marked(s, wl, wp))
|
if (args_has(args, 'M') || server_is_marked(s, wl, wp))
|
||||||
server_clear_marked();
|
server_clear_marked();
|
||||||
@@ -97,69 +149,94 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
markedwp = marked_pane.wp;
|
markedwp = marked_pane.wp;
|
||||||
|
|
||||||
if (lastwp != NULL) {
|
if (lastwp != NULL) {
|
||||||
|
lastwp->flags |= (PANE_REDRAW|PANE_STYLECHANGED);
|
||||||
server_redraw_window_borders(lastwp->window);
|
server_redraw_window_borders(lastwp->window);
|
||||||
server_status_window(lastwp->window);
|
server_status_window(lastwp->window);
|
||||||
}
|
}
|
||||||
if (markedwp != NULL) {
|
if (markedwp != NULL) {
|
||||||
|
markedwp->flags |= (PANE_REDRAW|PANE_STYLECHANGED);
|
||||||
server_redraw_window_borders(markedwp->window);
|
server_redraw_window_borders(markedwp->window);
|
||||||
server_status_window(markedwp->window);
|
server_status_window(markedwp->window);
|
||||||
}
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'P') || args_has(self->args, 'g')) {
|
style = args_get(args, 'P');
|
||||||
if (args_has(args, 'P')) {
|
if (style != NULL) {
|
||||||
style = args_get(args, 'P');
|
o = options_set_string(oo, "window-style", 0, "%s", style);
|
||||||
if (style_parse(&grid_default_cell, &wp->colgc,
|
if (o == NULL) {
|
||||||
style) == -1) {
|
cmdq_error(item, "bad style: %s", style);
|
||||||
cmdq_error(item, "bad style: %s", style);
|
return (CMD_RETURN_ERROR);
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
wp->flags |= PANE_REDRAW;
|
|
||||||
}
|
}
|
||||||
if (args_has(self->args, 'g'))
|
options_set_string(oo, "window-active-style", 0, "%s", style);
|
||||||
cmdq_print(item, "%s", style_tostring(&wp->colgc));
|
wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED);
|
||||||
|
}
|
||||||
|
if (args_has(args, 'g')) {
|
||||||
|
cmdq_print(item, "%s", options_get_string(oo, "window-style"));
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'L')) {
|
if (args_has(args, 'L')) {
|
||||||
server_unzoom_window(wp->window);
|
window_push_zoom(w, 0, 1);
|
||||||
wp = window_pane_find_left(wp);
|
wp = window_pane_find_left(wp);
|
||||||
} else if (args_has(self->args, 'R')) {
|
window_pop_zoom(w);
|
||||||
server_unzoom_window(wp->window);
|
} else if (args_has(args, 'R')) {
|
||||||
|
window_push_zoom(w, 0, 1);
|
||||||
wp = window_pane_find_right(wp);
|
wp = window_pane_find_right(wp);
|
||||||
} else if (args_has(self->args, 'U')) {
|
window_pop_zoom(w);
|
||||||
server_unzoom_window(wp->window);
|
} else if (args_has(args, 'U')) {
|
||||||
|
window_push_zoom(w, 0, 1);
|
||||||
wp = window_pane_find_up(wp);
|
wp = window_pane_find_up(wp);
|
||||||
} else if (args_has(self->args, 'D')) {
|
window_pop_zoom(w);
|
||||||
server_unzoom_window(wp->window);
|
} else if (args_has(args, 'D')) {
|
||||||
|
window_push_zoom(w, 0, 1);
|
||||||
wp = window_pane_find_down(wp);
|
wp = window_pane_find_down(wp);
|
||||||
|
window_pop_zoom(w);
|
||||||
}
|
}
|
||||||
if (wp == NULL)
|
if (wp == NULL)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
if (args_has(self->args, 'e')) {
|
if (args_has(args, 'e')) {
|
||||||
wp->flags &= ~PANE_INPUTOFF;
|
wp->flags &= ~PANE_INPUTOFF;
|
||||||
|
server_redraw_window_borders(wp->window);
|
||||||
|
server_status_window(wp->window);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
if (args_has(self->args, 'd')) {
|
if (args_has(args, 'd')) {
|
||||||
wp->flags |= PANE_INPUTOFF;
|
wp->flags |= PANE_INPUTOFF;
|
||||||
|
server_redraw_window_borders(wp->window);
|
||||||
|
server_status_window(wp->window);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wp == w->active)
|
if (args_has(args, 'T')) {
|
||||||
|
title = format_single_from_target(item, args_get(args, 'T'));
|
||||||
|
if (screen_set_title(&wp->base, title)) {
|
||||||
|
notify_pane("pane-title-changed", wp);
|
||||||
|
server_redraw_window_borders(wp->window);
|
||||||
|
server_status_window(wp->window);
|
||||||
|
}
|
||||||
|
free(title);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
server_unzoom_window(wp->window);
|
|
||||||
if (!window_pane_visible(wp)) {
|
|
||||||
cmdq_error(item, "pane not visible");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c != NULL && c->session != NULL && (c->flags & CLIENT_ACTIVEPANE))
|
||||||
|
activewp = server_client_get_pane(c);
|
||||||
|
else
|
||||||
|
activewp = w->active;
|
||||||
|
if (wp == activewp)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
if (window_push_zoom(w, 0, args_has(args, 'Z')))
|
||||||
|
server_redraw_window(w);
|
||||||
window_redraw_active_switch(w, wp);
|
window_redraw_active_switch(w, wp);
|
||||||
if (window_set_active_pane(w, wp)) {
|
if (c != NULL && c->session != NULL && (c->flags & CLIENT_ACTIVEPANE))
|
||||||
cmd_find_from_winlink(current, wl);
|
server_client_set_pane(c, wp);
|
||||||
server_status_window(w);
|
else if (window_set_active_pane(w, wp, 1))
|
||||||
server_redraw_window_borders(w);
|
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||||
}
|
cmdq_insert_hook(s, item, current, "after-select-pane");
|
||||||
|
cmd_select_pane_redraw(w);
|
||||||
|
if (window_pop_zoom(w))
|
||||||
|
server_redraw_window(w);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_select_window_entry = {
|
|||||||
.name = "select-window",
|
.name = "select-window",
|
||||||
.alias = "selectw",
|
.alias = "selectw",
|
||||||
|
|
||||||
.args = { "lnpTt:", 0, 0 },
|
.args = { "lnpTt:", 0, 0, NULL },
|
||||||
.usage = "[-lnpT] " CMD_TARGET_WINDOW_USAGE,
|
.usage = "[-lnpT] " CMD_TARGET_WINDOW_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
@@ -46,7 +46,7 @@ const struct cmd_entry cmd_next_window_entry = {
|
|||||||
.name = "next-window",
|
.name = "next-window",
|
||||||
.alias = "next",
|
.alias = "next",
|
||||||
|
|
||||||
.args = { "at:", 0, 0 },
|
.args = { "at:", 0, 0, NULL },
|
||||||
.usage = "[-a] " CMD_TARGET_SESSION_USAGE,
|
.usage = "[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||||
@@ -59,7 +59,7 @@ const struct cmd_entry cmd_previous_window_entry = {
|
|||||||
.name = "previous-window",
|
.name = "previous-window",
|
||||||
.alias = "prev",
|
.alias = "prev",
|
||||||
|
|
||||||
.args = { "at:", 0, 0 },
|
.args = { "at:", 0, 0, NULL },
|
||||||
.usage = "[-a] " CMD_TARGET_SESSION_USAGE,
|
.usage = "[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||||
@@ -72,7 +72,7 @@ const struct cmd_entry cmd_last_window_entry = {
|
|||||||
.name = "last-window",
|
.name = "last-window",
|
||||||
.alias = "last",
|
.alias = "last",
|
||||||
|
|
||||||
.args = { "t:", 0, 0 },
|
.args = { "t:", 0, 0, NULL },
|
||||||
.usage = CMD_TARGET_SESSION_USAGE,
|
.usage = CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||||
@@ -84,23 +84,26 @@ const struct cmd_entry cmd_last_window_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct cmd_find_state *current = &item->shared->current;
|
struct args *args = cmd_get_args(self);
|
||||||
struct winlink *wl = item->target.wl;
|
struct client *c = cmdq_get_client(item);
|
||||||
struct session *s = item->target.s;
|
struct cmd_find_state *current = cmdq_get_current(item);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct winlink *wl = target->wl;
|
||||||
|
struct session *s = target->s;
|
||||||
int next, previous, last, activity;
|
int next, previous, last, activity;
|
||||||
|
|
||||||
next = self->entry == &cmd_next_window_entry;
|
next = (cmd_get_entry(self) == &cmd_next_window_entry);
|
||||||
if (args_has(self->args, 'n'))
|
if (args_has(args, 'n'))
|
||||||
next = 1;
|
next = 1;
|
||||||
previous = self->entry == &cmd_previous_window_entry;
|
previous = (cmd_get_entry(self) == &cmd_previous_window_entry);
|
||||||
if (args_has(self->args, 'p'))
|
if (args_has(args, 'p'))
|
||||||
previous = 1;
|
previous = 1;
|
||||||
last = self->entry == &cmd_last_window_entry;
|
last = (cmd_get_entry(self) == &cmd_last_window_entry);
|
||||||
if (args_has(self->args, 'l'))
|
if (args_has(args, 'l'))
|
||||||
last = 1;
|
last = 1;
|
||||||
|
|
||||||
if (next || previous || last) {
|
if (next || previous || last) {
|
||||||
activity = args_has(self->args, 'a');
|
activity = args_has(args, 'a');
|
||||||
if (next) {
|
if (next) {
|
||||||
if (session_next(s, activity) != 0) {
|
if (session_next(s, activity) != 0) {
|
||||||
cmdq_error(item, "no next window");
|
cmdq_error(item, "no next window");
|
||||||
@@ -117,26 +120,30 @@ cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd_find_from_session(&item->shared->current, s);
|
cmd_find_from_session(current, s, 0);
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
|
cmdq_insert_hook(s, item, current, "after-select-window");
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* If -T and select-window is invoked on same window as
|
* If -T and select-window is invoked on same window as
|
||||||
* current, switch to previous window.
|
* current, switch to previous window.
|
||||||
*/
|
*/
|
||||||
if (args_has(self->args, 'T') && wl == s->curw) {
|
if (args_has(args, 'T') && wl == s->curw) {
|
||||||
if (session_last(s) != 0) {
|
if (session_last(s) != 0) {
|
||||||
cmdq_error(item, "no last window");
|
cmdq_error(item, "no last window");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (current->s == s)
|
if (current->s == s)
|
||||||
cmd_find_from_session(current, s);
|
cmd_find_from_session(current, s, 0);
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
} else if (session_select(s, wl->idx) == 0) {
|
} else if (session_select(s, wl->idx) == 0) {
|
||||||
cmd_find_from_session(current, s);
|
cmd_find_from_session(current, s, 0);
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
}
|
}
|
||||||
|
cmdq_insert_hook(s, item, current, "after-select-window");
|
||||||
}
|
}
|
||||||
|
if (c != NULL && c->session != NULL)
|
||||||
|
s->curw->window->latest = c;
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
188
cmd-send-keys.c
188
cmd-send-keys.c
@@ -33,12 +33,13 @@ const struct cmd_entry cmd_send_keys_entry = {
|
|||||||
.name = "send-keys",
|
.name = "send-keys",
|
||||||
.alias = "send",
|
.alias = "send",
|
||||||
|
|
||||||
.args = { "lXRMN:t:", 0, -1 },
|
.args = { "c:FHKlMN:Rt:X", 0, -1, NULL },
|
||||||
.usage = "[-lXRM] [-N repeat-count] " CMD_TARGET_PANE_USAGE " key ...",
|
.usage = "[-FHKlMRX] [-c target-client] [-N repeat-count] "
|
||||||
|
CMD_TARGET_PANE_USAGE " key ...",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK|CMD_CLIENT_CFLAG|CMD_CLIENT_CANFAIL,
|
||||||
.exec = cmd_send_keys_exec
|
.exec = cmd_send_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ const struct cmd_entry cmd_send_prefix_entry = {
|
|||||||
.name = "send-prefix",
|
.name = "send-prefix",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "2t:", 0, 0 },
|
.args = { "2t:", 0, 0, NULL },
|
||||||
.usage = "[-2] " CMD_TARGET_PANE_USAGE,
|
.usage = "[-2] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
@@ -55,64 +56,140 @@ const struct cmd_entry cmd_send_prefix_entry = {
|
|||||||
.exec = cmd_send_keys_exec
|
.exec = cmd_send_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static struct cmdq_item *
|
||||||
cmd_send_keys_inject(struct client *c, struct cmdq_item *item, key_code key)
|
cmd_send_keys_inject_key(struct cmdq_item *item, struct cmdq_item *after,
|
||||||
|
struct args *args, key_code key)
|
||||||
{
|
{
|
||||||
struct window_pane *wp = item->target.wp;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct session *s = item->target.s;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct key_table *table;
|
struct session *s = target->s;
|
||||||
struct key_binding *bd, bd_find;
|
struct winlink *wl = target->wl;
|
||||||
|
struct window_pane *wp = target->wp;
|
||||||
|
struct window_mode_entry *wme;
|
||||||
|
struct key_table *table = NULL;
|
||||||
|
struct key_binding *bd;
|
||||||
|
struct key_event *event;
|
||||||
|
|
||||||
if (wp->mode == NULL || wp->mode->key_table == NULL) {
|
if (args_has(args, 'K')) {
|
||||||
window_pane_key(wp, NULL, s, key, NULL);
|
if (tc == NULL)
|
||||||
return;
|
return (item);
|
||||||
|
event = xmalloc(sizeof *event);
|
||||||
|
event->key = key|KEYC_SENT;
|
||||||
|
memset(&event->m, 0, sizeof event->m);
|
||||||
|
if (server_client_handle_key(tc, event) == 0)
|
||||||
|
free(event);
|
||||||
|
return (item);
|
||||||
}
|
}
|
||||||
table = key_bindings_get_table(wp->mode->key_table(wp), 1);
|
|
||||||
|
|
||||||
bd_find.key = (key & ~KEYC_XTERM);
|
wme = TAILQ_FIRST(&wp->modes);
|
||||||
bd = RB_FIND(key_bindings, &table->key_bindings, &bd_find);
|
if (wme == NULL || wme->mode->key_table == NULL) {
|
||||||
|
if (window_pane_key(wp, tc, s, wl, key, NULL) != 0)
|
||||||
|
return (NULL);
|
||||||
|
return (item);
|
||||||
|
}
|
||||||
|
table = key_bindings_get_table(wme->mode->key_table(wme), 1);
|
||||||
|
|
||||||
|
bd = key_bindings_get(table, key & ~KEYC_MASK_FLAGS);
|
||||||
if (bd != NULL) {
|
if (bd != NULL) {
|
||||||
table->references++;
|
table->references++;
|
||||||
key_bindings_dispatch(bd, c, NULL, &item->target);
|
after = key_bindings_dispatch(bd, after, tc, NULL, target);
|
||||||
key_bindings_unref_table(table);
|
key_bindings_unref_table(table);
|
||||||
}
|
}
|
||||||
|
return (after);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmdq_item *
|
||||||
|
cmd_send_keys_inject_string(struct cmdq_item *item, struct cmdq_item *after,
|
||||||
|
struct args *args, int i)
|
||||||
|
{
|
||||||
|
const char *s = args_string(args, i);
|
||||||
|
struct utf8_data *ud, *loop;
|
||||||
|
utf8_char uc;
|
||||||
|
key_code key;
|
||||||
|
char *endptr;
|
||||||
|
long n;
|
||||||
|
int literal;
|
||||||
|
|
||||||
|
if (args_has(args, 'H')) {
|
||||||
|
n = strtol(s, &endptr, 16);
|
||||||
|
if (*s =='\0' || n < 0 || n > 0xff || *endptr != '\0')
|
||||||
|
return (item);
|
||||||
|
return (cmd_send_keys_inject_key(item, after, args,
|
||||||
|
KEYC_LITERAL|n));
|
||||||
|
}
|
||||||
|
|
||||||
|
literal = args_has(args, 'l');
|
||||||
|
if (!literal) {
|
||||||
|
key = key_string_lookup_string(s);
|
||||||
|
if (key != KEYC_NONE && key != KEYC_UNKNOWN) {
|
||||||
|
after = cmd_send_keys_inject_key(item, after, args,
|
||||||
|
key);
|
||||||
|
if (after != NULL)
|
||||||
|
return (after);
|
||||||
|
}
|
||||||
|
literal = 1;
|
||||||
|
}
|
||||||
|
if (literal) {
|
||||||
|
ud = utf8_fromcstr(s);
|
||||||
|
for (loop = ud; loop->size != 0; loop++) {
|
||||||
|
if (loop->size == 1 && loop->data[0] <= 0x7f)
|
||||||
|
key = loop->data[0];
|
||||||
|
else {
|
||||||
|
if (utf8_from_data(loop, &uc) != UTF8_DONE)
|
||||||
|
continue;
|
||||||
|
key = uc;
|
||||||
|
}
|
||||||
|
after = cmd_send_keys_inject_key(item, after, args,
|
||||||
|
key);
|
||||||
|
}
|
||||||
|
free(ud);
|
||||||
|
}
|
||||||
|
return (after);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct window_pane *wp = item->target.wp;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct session *s = item->target.s;
|
struct session *s = target->s;
|
||||||
struct mouse_event *m = &item->shared->mouse;
|
struct winlink *wl = target->wl;
|
||||||
struct utf8_data *ud, *uc;
|
struct window_pane *wp = target->wp;
|
||||||
wchar_t wc;
|
struct key_event *event = cmdq_get_event(item);
|
||||||
int i, literal;
|
struct mouse_event *m = &event->m;
|
||||||
key_code key;
|
struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes);
|
||||||
u_int np = 1;
|
struct cmdq_item *after = item;
|
||||||
char *cause = NULL;
|
key_code key;
|
||||||
|
u_int i, np = 1;
|
||||||
|
u_int count = args_count(args);
|
||||||
|
char *cause = NULL;
|
||||||
|
|
||||||
if (args_has(args, 'N')) {
|
if (args_has(args, 'N')) {
|
||||||
np = args_strtonum(args, 'N', 1, UINT_MAX, &cause);
|
np = args_strtonum_and_expand(args, 'N', 1, UINT_MAX, item,
|
||||||
|
&cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
cmdq_error(item, "repeat count %s", cause);
|
cmdq_error(item, "repeat count %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (args_has(args, 'X') || args->argc == 0)
|
if (wme != NULL && (args_has(args, 'X') || count == 0)) {
|
||||||
wp->modeprefix = np;
|
if (wme->mode->command == NULL) {
|
||||||
|
cmdq_error(item, "not in a mode");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
wme->prefix = np;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 'X')) {
|
if (args_has(args, 'X')) {
|
||||||
if (wp->mode == NULL || wp->mode->command == NULL) {
|
if (wme == NULL || wme->mode->command == NULL) {
|
||||||
cmdq_error(item, "not in a mode");
|
cmdq_error(item, "not in a mode");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (!m->valid)
|
if (!m->valid)
|
||||||
wp->mode->command(wp, c, s, args, NULL);
|
m = NULL;
|
||||||
else
|
wme->mode->command(wme, tc, s, wl, args, m);
|
||||||
wp->mode->command(wp, c, s, args, m);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,45 +199,38 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
cmdq_error(item, "no mouse target");
|
cmdq_error(item, "no mouse target");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
window_pane_key(wp, NULL, s, m->key, m);
|
window_pane_key(wp, tc, s, wl, m->key, m);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->entry == &cmd_send_prefix_entry) {
|
if (cmd_get_entry(self) == &cmd_send_prefix_entry) {
|
||||||
if (args_has(args, '2'))
|
if (args_has(args, '2'))
|
||||||
key = options_get_number(s->options, "prefix2");
|
key = options_get_number(s->options, "prefix2");
|
||||||
else
|
else
|
||||||
key = options_get_number(s->options, "prefix");
|
key = options_get_number(s->options, "prefix");
|
||||||
cmd_send_keys_inject(c, item, key);
|
cmd_send_keys_inject_key(item, item, args, key);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 'R')) {
|
if (args_has(args, 'R')) {
|
||||||
window_pane_reset_palette(wp);
|
colour_palette_clear(&wp->palette);
|
||||||
input_reset(wp, 1);
|
input_reset(wp->ictx, 1);
|
||||||
|
wp->flags |= (PANE_STYLECHANGED|PANE_REDRAW);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
if (args_has(args, 'N') || args_has(args, 'R'))
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
for (; np != 0; np--)
|
||||||
|
cmd_send_keys_inject_key(item, NULL, args, event->key);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; np != 0; np--) {
|
for (; np != 0; np--) {
|
||||||
for (i = 0; i < args->argc; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
literal = args_has(args, 'l');
|
after = cmd_send_keys_inject_string(item, after, args,
|
||||||
if (!literal) {
|
i);
|
||||||
key = key_string_lookup_string(args->argv[i]);
|
|
||||||
if (key != KEYC_NONE && key != KEYC_UNKNOWN)
|
|
||||||
cmd_send_keys_inject(c, item, key);
|
|
||||||
else
|
|
||||||
literal = 1;
|
|
||||||
}
|
|
||||||
if (literal) {
|
|
||||||
ud = utf8_fromcstr(args->argv[i]);
|
|
||||||
for (uc = ud; uc->size != 0; uc++) {
|
|
||||||
if (utf8_combine(uc, &wc) != UTF8_DONE)
|
|
||||||
continue;
|
|
||||||
cmd_send_keys_inject(c, item, wc);
|
|
||||||
}
|
|
||||||
free(ud);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
147
cmd-server-access.c
Normal file
147
cmd-server-access.c
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 Dallas Lyons <dallasdlyons@gmail.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Controls access to session.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_server_access_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_server_access_entry = {
|
||||||
|
.name = "server-access",
|
||||||
|
.alias = NULL,
|
||||||
|
|
||||||
|
.args = { "adlrw", 0, 1, NULL },
|
||||||
|
.usage = "[-adlrw] " CMD_TARGET_PANE_USAGE " [user]",
|
||||||
|
|
||||||
|
.flags = CMD_CLIENT_CANFAIL,
|
||||||
|
.exec = cmd_server_access_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_server_access_deny(struct cmdq_item *item, struct passwd *pw)
|
||||||
|
{
|
||||||
|
struct client *loop;
|
||||||
|
struct server_acl_user *user;
|
||||||
|
uid_t uid;
|
||||||
|
|
||||||
|
if ((user = server_acl_user_find(pw->pw_uid)) == NULL) {
|
||||||
|
cmdq_error(item, "user %s not found", pw->pw_name);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
TAILQ_FOREACH(loop, &clients, entry) {
|
||||||
|
uid = proc_get_peer_uid(loop->peer);
|
||||||
|
if (uid == server_acl_get_uid(user)) {
|
||||||
|
loop->exit_message = xstrdup("access not allowed");
|
||||||
|
loop->flags |= CLIENT_EXIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server_acl_user_deny(pw->pw_uid);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_server_access_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
|
||||||
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct client *c = cmdq_get_target_client(item);
|
||||||
|
char *name;
|
||||||
|
struct passwd *pw = NULL;
|
||||||
|
|
||||||
|
if (args_has(args, 'l')) {
|
||||||
|
server_acl_display(item);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
if (args_count(args) == 0) {
|
||||||
|
cmdq_error(item, "missing user argument");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
name = format_single(item, args_string(args, 0), c, NULL, NULL, NULL);
|
||||||
|
if (*name != '\0')
|
||||||
|
pw = getpwnam(name);
|
||||||
|
if (pw == NULL) {
|
||||||
|
cmdq_error(item, "unknown user: %s", name);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
free(name);
|
||||||
|
|
||||||
|
if (pw->pw_uid == 0 || pw->pw_uid == getuid()) {
|
||||||
|
cmdq_error(item, "%s owns the server, can't change access",
|
||||||
|
pw->pw_name);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'a') && args_has(args, 'd')) {
|
||||||
|
cmdq_error(item, "-a and -d cannot be used together");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (args_has(args, 'w') && args_has(args, 'r')) {
|
||||||
|
cmdq_error(item, "-r and -w cannot be used together");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'd'))
|
||||||
|
return (cmd_server_access_deny(item, pw));
|
||||||
|
if (args_has(args, 'a')) {
|
||||||
|
if (server_acl_user_find(pw->pw_uid) != NULL) {
|
||||||
|
cmdq_error(item, "user %s is already added",
|
||||||
|
pw->pw_name);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
server_acl_user_allow(pw->pw_uid);
|
||||||
|
/* Do not return - allow -r or -w with -a. */
|
||||||
|
} else if (args_has(args, 'r') || args_has(args, 'w')) {
|
||||||
|
/* -r or -w implies -a if user does not exist. */
|
||||||
|
if (server_acl_user_find(pw->pw_uid) == NULL)
|
||||||
|
server_acl_user_allow(pw->pw_uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'w')) {
|
||||||
|
if (server_acl_user_find(pw->pw_uid) == NULL) {
|
||||||
|
cmdq_error(item, "user %s not found", pw->pw_name);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
server_acl_user_allow_write(pw->pw_uid);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'r')) {
|
||||||
|
if (server_acl_user_find(pw->pw_uid) == NULL) {
|
||||||
|
cmdq_error(item, "user %s not found", pw->pw_name);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
server_acl_user_deny_write(pw->pw_uid);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
@@ -33,10 +33,11 @@ const struct cmd_entry cmd_set_buffer_entry = {
|
|||||||
.name = "set-buffer",
|
.name = "set-buffer",
|
||||||
.alias = "setb",
|
.alias = "setb",
|
||||||
|
|
||||||
.args = { "ab:n:", 0, 1 },
|
.args = { "ab:t:n:w", 0, 1, NULL },
|
||||||
.usage = "[-a] " CMD_BUFFER_USAGE " [-n new-buffer-name] data",
|
.usage = "[-aw] " CMD_BUFFER_USAGE " [-n new-buffer-name] "
|
||||||
|
CMD_TARGET_CLIENT_USAGE " data",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG|CMD_CLIENT_CANFAIL,
|
||||||
.exec = cmd_set_buffer_exec
|
.exec = cmd_set_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ const struct cmd_entry cmd_delete_buffer_entry = {
|
|||||||
.name = "delete-buffer",
|
.name = "delete-buffer",
|
||||||
.alias = "deleteb",
|
.alias = "deleteb",
|
||||||
|
|
||||||
.args = { "b:", 0, 0 },
|
.args = { "b:", 0, 0, NULL },
|
||||||
.usage = CMD_BUFFER_USAGE,
|
.usage = CMD_BUFFER_USAGE,
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
@@ -54,7 +55,8 @@ const struct cmd_entry cmd_delete_buffer_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
char *bufdata, *cause;
|
char *bufdata, *cause;
|
||||||
const char *bufname, *olddata;
|
const char *bufname, *olddata;
|
||||||
@@ -66,9 +68,14 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
else
|
else
|
||||||
pb = paste_get_name(bufname);
|
pb = paste_get_name(bufname);
|
||||||
|
|
||||||
if (self->entry == &cmd_delete_buffer_entry) {
|
if (cmd_get_entry(self) == &cmd_delete_buffer_entry) {
|
||||||
if (pb == NULL)
|
if (pb == NULL) {
|
||||||
|
if (bufname != NULL) {
|
||||||
|
cmdq_error(item, "unknown buffer: %s", bufname);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
pb = paste_get_top(&bufname);
|
pb = paste_get_top(&bufname);
|
||||||
|
}
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
cmdq_error(item, "no buffer");
|
cmdq_error(item, "no buffer");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
@@ -78,8 +85,13 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 'n')) {
|
if (args_has(args, 'n')) {
|
||||||
if (pb == NULL)
|
if (pb == NULL) {
|
||||||
|
if (bufname != NULL) {
|
||||||
|
cmdq_error(item, "unknown buffer: %s", bufname);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
pb = paste_get_top(&bufname);
|
pb = paste_get_top(&bufname);
|
||||||
|
}
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
cmdq_error(item, "no buffer");
|
cmdq_error(item, "no buffer");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
@@ -92,11 +104,11 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc != 1) {
|
if (args_count(args) != 1) {
|
||||||
cmdq_error(item, "no data specified");
|
cmdq_error(item, "no data specified");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if ((newsize = strlen(args->argv[0])) == 0)
|
if ((newsize = strlen(args_string(args, 0))) == 0)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
bufsize = 0;
|
bufsize = 0;
|
||||||
@@ -109,7 +121,7 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bufdata = xrealloc(bufdata, bufsize + newsize);
|
bufdata = xrealloc(bufdata, bufsize + newsize);
|
||||||
memcpy(bufdata + bufsize, args->argv[0], newsize);
|
memcpy(bufdata + bufsize, args_string(args, 0), newsize);
|
||||||
bufsize += newsize;
|
bufsize += newsize;
|
||||||
|
|
||||||
if (paste_set(bufdata, bufsize, bufname, &cause) != 0) {
|
if (paste_set(bufdata, bufsize, bufname, &cause) != 0) {
|
||||||
@@ -118,6 +130,8 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
if (args_has(args, 'w') && tc != NULL)
|
||||||
|
tty_set_selection(&tc->tty, "", bufdata, bufsize);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ const struct cmd_entry cmd_set_environment_entry = {
|
|||||||
.name = "set-environment",
|
.name = "set-environment",
|
||||||
.alias = "setenv",
|
.alias = "setenv",
|
||||||
|
|
||||||
.args = { "grt:u", 1, 2 },
|
.args = { "Fhgrt:u", 1, 2, NULL },
|
||||||
.usage = "[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
.usage = "[-Fhgru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
@@ -46,11 +46,14 @@ const struct cmd_entry cmd_set_environment_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct environ *env;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
const char *name, *value, *target;
|
struct environ *env;
|
||||||
|
const char *name = args_string(args, 0), *value;
|
||||||
|
const char *tflag;
|
||||||
|
char *expanded = NULL;
|
||||||
|
enum cmd_retval retval = CMD_RETURN_NORMAL;
|
||||||
|
|
||||||
name = args->argv[0];
|
|
||||||
if (*name == '\0') {
|
if (*name == '\0') {
|
||||||
cmdq_error(item, "empty variable name");
|
cmdq_error(item, "empty variable name");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
@@ -60,44 +63,57 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc < 2)
|
if (args_count(args) < 2)
|
||||||
value = NULL;
|
value = NULL;
|
||||||
else
|
else
|
||||||
value = args->argv[1];
|
value = args_string(args, 1);
|
||||||
|
if (value != NULL && args_has(args, 'F')) {
|
||||||
if (args_has(self->args, 'g'))
|
expanded = format_single_from_target(item, value);
|
||||||
|
value = expanded;
|
||||||
|
}
|
||||||
|
if (args_has(args, 'g'))
|
||||||
env = global_environ;
|
env = global_environ;
|
||||||
else {
|
else {
|
||||||
if (item->target.s == NULL) {
|
if (target->s == NULL) {
|
||||||
target = args_get(args, 't');
|
tflag = args_get(args, 't');
|
||||||
if (target != NULL)
|
if (tflag != NULL)
|
||||||
cmdq_error(item, "no such session: %s", target);
|
cmdq_error(item, "no such session: %s", tflag);
|
||||||
else
|
else
|
||||||
cmdq_error(item, "no current session");
|
cmdq_error(item, "no current session");
|
||||||
return (CMD_RETURN_ERROR);
|
retval = CMD_RETURN_ERROR;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
env = item->target.s->environ;
|
env = target->s->environ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'u')) {
|
if (args_has(args, 'u')) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
cmdq_error(item, "can't specify a value with -u");
|
cmdq_error(item, "can't specify a value with -u");
|
||||||
return (CMD_RETURN_ERROR);
|
retval = CMD_RETURN_ERROR;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
environ_unset(env, name);
|
environ_unset(env, name);
|
||||||
} else if (args_has(self->args, 'r')) {
|
} else if (args_has(args, 'r')) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
cmdq_error(item, "can't specify a value with -r");
|
cmdq_error(item, "can't specify a value with -r");
|
||||||
return (CMD_RETURN_ERROR);
|
retval = CMD_RETURN_ERROR;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
environ_clear(env, name);
|
environ_clear(env, name);
|
||||||
} else {
|
} else {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
cmdq_error(item, "no value specified");
|
cmdq_error(item, "no value specified");
|
||||||
return (CMD_RETURN_ERROR);
|
retval = CMD_RETURN_ERROR;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
environ_set(env, name, "%s", value);
|
|
||||||
|
if (args_has(args, 'h'))
|
||||||
|
environ_set(env, name, ENVIRON_HIDDEN, "%s", value);
|
||||||
|
else
|
||||||
|
environ_set(env, name, 0, "%s", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
out:
|
||||||
|
free(expanded);
|
||||||
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|||||||
130
cmd-set-hook.c
130
cmd-set-hook.c
@@ -1,130 +0,0 @@
|
|||||||
/* $OpenBSD$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set or show global or session hooks.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static enum cmd_retval cmd_set_hook_exec(struct cmd *, struct cmdq_item *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_hook_entry = {
|
|
||||||
.name = "set-hook",
|
|
||||||
.alias = NULL,
|
|
||||||
|
|
||||||
.args = { "gt:u", 1, 2 },
|
|
||||||
.usage = "[-gu] " CMD_TARGET_SESSION_USAGE " hook-name [command]",
|
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
|
||||||
.exec = cmd_set_hook_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_hooks_entry = {
|
|
||||||
.name = "show-hooks",
|
|
||||||
.alias = NULL,
|
|
||||||
|
|
||||||
.args = { "gt:", 0, 1 },
|
|
||||||
.usage = "[-g] " CMD_TARGET_SESSION_USAGE,
|
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
|
||||||
.exec = cmd_set_hook_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
static enum cmd_retval
|
|
||||||
cmd_set_hook_exec(struct cmd *self, struct cmdq_item *item)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct hooks *hooks;
|
|
||||||
struct hook *hook;
|
|
||||||
char *cause, *tmp;
|
|
||||||
const char *name, *cmd, *target;
|
|
||||||
|
|
||||||
if (args_has(args, 'g'))
|
|
||||||
hooks = global_hooks;
|
|
||||||
else {
|
|
||||||
if (item->target.s == NULL) {
|
|
||||||
target = args_get(args, 't');
|
|
||||||
if (target != NULL)
|
|
||||||
cmdq_error(item, "no such session: %s", target);
|
|
||||||
else
|
|
||||||
cmdq_error(item, "no current session");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
hooks = item->target.s->hooks;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self->entry == &cmd_show_hooks_entry) {
|
|
||||||
hook = hooks_first(hooks);
|
|
||||||
while (hook != NULL) {
|
|
||||||
tmp = cmd_list_print(hook->cmdlist);
|
|
||||||
cmdq_print(item, "%s -> %s", hook->name, tmp);
|
|
||||||
free(tmp);
|
|
||||||
|
|
||||||
hook = hooks_next(hook);
|
|
||||||
}
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
name = args->argv[0];
|
|
||||||
if (*name == '\0') {
|
|
||||||
cmdq_error(item, "invalid hook name");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
if (args->argc < 2)
|
|
||||||
cmd = NULL;
|
|
||||||
else
|
|
||||||
cmd = args->argv[1];
|
|
||||||
|
|
||||||
if (args_has(args, 'u')) {
|
|
||||||
if (cmd != NULL) {
|
|
||||||
cmdq_error(item, "command passed to unset hook: %s",
|
|
||||||
name);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
hooks_remove(hooks, name);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cmd == NULL) {
|
|
||||||
cmdq_error(item, "no command to set hook: %s", name);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);
|
|
||||||
if (cmdlist == NULL) {
|
|
||||||
if (cause != NULL) {
|
|
||||||
cmdq_error(item, "%s", cause);
|
|
||||||
free(cause);
|
|
||||||
}
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
hooks_add(hooks, name, cmdlist);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
383
cmd-set-option.c
383
cmd-set-option.c
@@ -27,25 +27,19 @@
|
|||||||
* Set an option.
|
* Set an option.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmdq_item *);
|
static enum args_parse_type cmd_set_option_args_parse(struct args *,
|
||||||
|
u_int, char **);
|
||||||
static int cmd_set_option_set(struct cmd *, struct cmdq_item *,
|
static enum cmd_retval cmd_set_option_exec(struct cmd *,
|
||||||
struct options *, struct options_entry *, const char *);
|
struct cmdq_item *);
|
||||||
static int cmd_set_option_flag(struct cmdq_item *,
|
|
||||||
const struct options_table_entry *, struct options *,
|
|
||||||
const char *);
|
|
||||||
static int cmd_set_option_choice(struct cmdq_item *,
|
|
||||||
const struct options_table_entry *, struct options *,
|
|
||||||
const char *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_option_entry = {
|
const struct cmd_entry cmd_set_option_entry = {
|
||||||
.name = "set-option",
|
.name = "set-option",
|
||||||
.alias = "set",
|
.alias = "set",
|
||||||
|
|
||||||
.args = { "agoqst:uw", 1, 2 },
|
.args = { "aFgopqst:uUw", 1, 2, cmd_set_option_args_parse },
|
||||||
.usage = "[-agosquw] [-t target-window] option [value]",
|
.usage = "[-aFgopqsuUw] " CMD_TARGET_PANE_USAGE " option [value]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
|
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_set_option_exec
|
.exec = cmd_set_option_exec
|
||||||
@@ -55,8 +49,8 @@ const struct cmd_entry cmd_set_window_option_entry = {
|
|||||||
.name = "set-window-option",
|
.name = "set-window-option",
|
||||||
.alias = "setw",
|
.alias = "setw",
|
||||||
|
|
||||||
.args = { "agoqt:u", 1, 2 },
|
.args = { "aFgoqt:u", 1, 2, cmd_set_option_args_parse },
|
||||||
.usage = "[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
.usage = "[-aFgoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
|
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
@@ -64,104 +58,92 @@ const struct cmd_entry cmd_set_window_option_entry = {
|
|||||||
.exec = cmd_set_option_exec
|
.exec = cmd_set_option_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_set_hook_entry = {
|
||||||
|
.name = "set-hook",
|
||||||
|
.alias = NULL,
|
||||||
|
|
||||||
|
.args = { "agpRt:uw", 1, 2, cmd_set_option_args_parse },
|
||||||
|
.usage = "[-agpRuw] " CMD_TARGET_PANE_USAGE " hook [command]",
|
||||||
|
|
||||||
|
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_set_option_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum args_parse_type
|
||||||
|
cmd_set_option_args_parse(__unused struct args *args, u_int idx,
|
||||||
|
__unused char **cause)
|
||||||
|
{
|
||||||
|
if (idx == 1)
|
||||||
|
return (ARGS_PARSE_COMMANDS_OR_STRING);
|
||||||
|
return (ARGS_PARSE_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
int append = args_has(args, 'a');
|
int append = args_has(args, 'a');
|
||||||
struct cmd_find_state *fs = &item->target;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct session *s = fs->s;
|
struct window_pane *loop;
|
||||||
struct winlink *wl = fs->wl;
|
|
||||||
struct window *w;
|
|
||||||
struct client *c;
|
|
||||||
enum options_table_scope scope;
|
|
||||||
struct options *oo;
|
struct options *oo;
|
||||||
struct options_entry *parent, *o;
|
struct options_entry *parent, *o, *po;
|
||||||
char *name;
|
char *name, *argument, *expanded = NULL;
|
||||||
const char *value, *target;
|
|
||||||
int window, idx, already, error, ambiguous;
|
|
||||||
char *cause;
|
char *cause;
|
||||||
|
const char *value;
|
||||||
|
int window, idx, already, error, ambiguous;
|
||||||
|
int scope;
|
||||||
|
|
||||||
|
window = (cmd_get_entry(self) == &cmd_set_window_option_entry);
|
||||||
|
|
||||||
|
/* Expand argument. */
|
||||||
|
argument = format_single_from_target(item, args_string(args, 0));
|
||||||
|
|
||||||
|
/* If set-hook -R, fire the hook straight away. */
|
||||||
|
if (cmd_get_entry(self) == &cmd_set_hook_entry && args_has(args, 'R')) {
|
||||||
|
notify_hook(item, argument);
|
||||||
|
free(argument);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse option name and index. */
|
/* Parse option name and index. */
|
||||||
name = options_match(args->argv[0], &idx, &ambiguous);
|
name = options_match(argument, &idx, &ambiguous);
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
if (args_has(args, 'q'))
|
if (args_has(args, 'q'))
|
||||||
return (CMD_RETURN_NORMAL);
|
goto out;
|
||||||
if (ambiguous)
|
if (ambiguous)
|
||||||
cmdq_error(item, "ambiguous option: %s", args->argv[0]);
|
cmdq_error(item, "ambiguous option: %s", argument);
|
||||||
else
|
else
|
||||||
cmdq_error(item, "invalid option: %s", args->argv[0]);
|
cmdq_error(item, "invalid option: %s", argument);
|
||||||
return (CMD_RETURN_ERROR);
|
goto fail;
|
||||||
}
|
}
|
||||||
if (args->argc < 2)
|
if (args_count(args) < 2)
|
||||||
value = NULL;
|
value = NULL;
|
||||||
else
|
else
|
||||||
value = args->argv[1];
|
value = args_string(args, 1);
|
||||||
|
if (value != NULL && args_has(args, 'F')) {
|
||||||
/*
|
expanded = format_single_from_target(item, value);
|
||||||
* Figure out the scope: for user options it comes from the arguments,
|
value = expanded;
|
||||||
* otherwise from the option name.
|
|
||||||
*/
|
|
||||||
if (*name == '@') {
|
|
||||||
window = (self->entry == &cmd_set_window_option_entry);
|
|
||||||
scope = options_scope_from_flags(args, window, fs, &oo, &cause);
|
|
||||||
} else {
|
|
||||||
if (options_get_only(global_options, name) != NULL)
|
|
||||||
scope = OPTIONS_TABLE_SERVER;
|
|
||||||
else if (options_get_only(global_s_options, name) != NULL)
|
|
||||||
scope = OPTIONS_TABLE_SESSION;
|
|
||||||
else if (options_get_only(global_w_options, name) != NULL)
|
|
||||||
scope = OPTIONS_TABLE_WINDOW;
|
|
||||||
else {
|
|
||||||
scope = OPTIONS_TABLE_NONE;
|
|
||||||
xasprintf(&cause, "unknown option: %s", args->argv[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get the scope and table for the option .*/
|
||||||
|
scope = options_scope_from_name(args, window, name, target, &oo,
|
||||||
|
&cause);
|
||||||
if (scope == OPTIONS_TABLE_NONE) {
|
if (scope == OPTIONS_TABLE_NONE) {
|
||||||
if (args_has(args, 'q'))
|
if (args_has(args, 'q'))
|
||||||
return (CMD_RETURN_NORMAL);
|
goto out;
|
||||||
cmdq_error(item, "%s", cause);
|
cmdq_error(item, "%s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Which table should this option go into? */
|
|
||||||
if (scope == OPTIONS_TABLE_SERVER)
|
|
||||||
oo = global_options;
|
|
||||||
else if (scope == OPTIONS_TABLE_SESSION) {
|
|
||||||
if (args_has(self->args, 'g'))
|
|
||||||
oo = global_s_options;
|
|
||||||
else if (s == NULL) {
|
|
||||||
target = args_get(args, 't');
|
|
||||||
if (target != NULL)
|
|
||||||
cmdq_error(item, "no such session: %s", target);
|
|
||||||
else
|
|
||||||
cmdq_error(item, "no current session");
|
|
||||||
goto fail;
|
|
||||||
} else
|
|
||||||
oo = s->options;
|
|
||||||
} else if (scope == OPTIONS_TABLE_WINDOW) {
|
|
||||||
if (args_has(self->args, 'g'))
|
|
||||||
oo = global_w_options;
|
|
||||||
else if (wl == NULL) {
|
|
||||||
target = args_get(args, 't');
|
|
||||||
if (target != NULL)
|
|
||||||
cmdq_error(item, "no such window: %s", target);
|
|
||||||
else
|
|
||||||
cmdq_error(item, "no current window");
|
|
||||||
goto fail;
|
|
||||||
} else
|
|
||||||
oo = wl->window->options;
|
|
||||||
}
|
|
||||||
o = options_get_only(oo, name);
|
o = options_get_only(oo, name);
|
||||||
parent = options_get(oo, name);
|
parent = options_get(oo, name);
|
||||||
|
|
||||||
/* Check that array options and indexes match up. */
|
/* Check that array options and indexes match up. */
|
||||||
if (idx != -1) {
|
if (idx != -1 && (*name == '@' || !options_is_array(parent))) {
|
||||||
if (*name == '@' || options_array_size(parent, NULL) == -1) {
|
cmdq_error(item, "not an array: %s", argument);
|
||||||
cmdq_error(item, "not an array: %s", args->argv[0]);
|
goto fail;
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* With -o, check this option is not already set. */
|
/* With -o, check this option is not already set. */
|
||||||
@@ -176,35 +158,48 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
if (already) {
|
if (already) {
|
||||||
if (args_has(args, 'q'))
|
if (args_has(args, 'q'))
|
||||||
return (CMD_RETURN_NORMAL);
|
goto out;
|
||||||
cmdq_error(item, "already set: %s", args->argv[0]);
|
cmdq_error(item, "already set: %s", argument);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Change the option. */
|
/* Change the option. */
|
||||||
if (args_has(args, 'u')) {
|
if (args_has(args, 'U') && scope == OPTIONS_TABLE_WINDOW) {
|
||||||
|
TAILQ_FOREACH(loop, &target->w->panes, entry) {
|
||||||
|
po = options_get_only(loop->options, name);
|
||||||
|
if (po == NULL)
|
||||||
|
continue;
|
||||||
|
if (options_remove_or_default(po, idx, &cause) != 0) {
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args_has(args, 'u') || args_has(args, 'U')) {
|
||||||
if (o == NULL)
|
if (o == NULL)
|
||||||
|
goto out;
|
||||||
|
if (options_remove_or_default(o, idx, &cause) != 0) {
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
goto fail;
|
goto fail;
|
||||||
if (idx == -1) {
|
}
|
||||||
if (oo == global_options ||
|
|
||||||
oo == global_s_options ||
|
|
||||||
oo == global_w_options)
|
|
||||||
options_default(oo, options_table_entry(o));
|
|
||||||
else
|
|
||||||
options_remove(o);
|
|
||||||
} else
|
|
||||||
options_array_set(o, idx, NULL, 0);
|
|
||||||
} else if (*name == '@') {
|
} else if (*name == '@') {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
cmdq_error(item, "empty value");
|
cmdq_error(item, "empty value");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
options_set_string(oo, name, append, "%s", value);
|
options_set_string(oo, name, append, "%s", value);
|
||||||
} else if (idx == -1 && options_array_size(parent, NULL) == -1) {
|
} else if (idx == -1 && !options_is_array(parent)) {
|
||||||
error = cmd_set_option_set(self, item, oo, parent, value);
|
error = options_from_string(oo, options_table_entry(parent),
|
||||||
if (error != 0)
|
options_table_entry(parent)->name, value,
|
||||||
|
args_has(args, 'a'), &cause);
|
||||||
|
if (error != 0) {
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
cmdq_error(item, "empty value");
|
cmdq_error(item, "empty value");
|
||||||
@@ -215,184 +210,30 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
if (!append)
|
if (!append)
|
||||||
options_array_clear(o);
|
options_array_clear(o);
|
||||||
options_array_assign(o, value);
|
if (options_array_assign(o, value, &cause) != 0) {
|
||||||
} else if (options_array_set(o, idx, value, append) != 0) {
|
cmdq_error(item, "%s", cause);
|
||||||
cmdq_error(item, "invalid index: %s", args->argv[0]);
|
free(cause);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
} else if (options_array_set(o, idx, value, append,
|
||||||
|
&cause) != 0) {
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update timers and so on for various options. */
|
options_push_changes(name);
|
||||||
if (strcmp(name, "automatic-rename") == 0) {
|
|
||||||
RB_FOREACH(w, windows, &windows) {
|
|
||||||
if (w->active == NULL)
|
|
||||||
continue;
|
|
||||||
if (options_get_number(w->options, "automatic-rename"))
|
|
||||||
w->active->flags |= PANE_CHANGED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strcmp(name, "key-table") == 0) {
|
|
||||||
TAILQ_FOREACH(c, &clients, entry)
|
|
||||||
server_client_set_key_table(c, NULL);
|
|
||||||
}
|
|
||||||
if (strcmp(name, "status") == 0 ||
|
|
||||||
strcmp(name, "status-interval") == 0)
|
|
||||||
status_timer_start_all();
|
|
||||||
if (strcmp(name, "monitor-silence") == 0)
|
|
||||||
alerts_reset_all();
|
|
||||||
if (strcmp(name, "window-style") == 0 ||
|
|
||||||
strcmp(name, "window-active-style") == 0) {
|
|
||||||
RB_FOREACH(w, windows, &windows)
|
|
||||||
w->flags |= WINDOW_STYLECHANGED;
|
|
||||||
}
|
|
||||||
if (strcmp(name, "pane-border-status") == 0) {
|
|
||||||
RB_FOREACH(w, windows, &windows)
|
|
||||||
layout_fix_panes(w, w->sx, w->sy);
|
|
||||||
}
|
|
||||||
RB_FOREACH (s, sessions, &sessions)
|
|
||||||
status_update_saved(s);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Update sizes and redraw. May not always be necessary but do it
|
|
||||||
* anyway.
|
|
||||||
*/
|
|
||||||
recalculate_sizes();
|
|
||||||
TAILQ_FOREACH(c, &clients, entry) {
|
|
||||||
if (c->session != NULL)
|
|
||||||
server_redraw_client(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
out:
|
||||||
|
free(argument);
|
||||||
|
free(expanded);
|
||||||
free(name);
|
free(name);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
free(argument);
|
||||||
|
free(expanded);
|
||||||
free(name);
|
free(name);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
cmd_set_option_set(struct cmd *self, struct cmdq_item *item, struct options *oo,
|
|
||||||
struct options_entry *parent, const char *value)
|
|
||||||
{
|
|
||||||
const struct options_table_entry *oe;
|
|
||||||
struct args *args = self->args;
|
|
||||||
int append = args_has(args, 'a');
|
|
||||||
struct options_entry *o;
|
|
||||||
long long number;
|
|
||||||
const char *errstr;
|
|
||||||
key_code key;
|
|
||||||
|
|
||||||
oe = options_table_entry(parent);
|
|
||||||
if (value == NULL &&
|
|
||||||
oe->type != OPTIONS_TABLE_FLAG &&
|
|
||||||
oe->type != OPTIONS_TABLE_CHOICE) {
|
|
||||||
cmdq_error(item, "empty value");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (oe->type) {
|
|
||||||
case OPTIONS_TABLE_STRING:
|
|
||||||
options_set_string(oo, oe->name, append, "%s", value);
|
|
||||||
return (0);
|
|
||||||
case OPTIONS_TABLE_NUMBER:
|
|
||||||
number = strtonum(value, oe->minimum, oe->maximum, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
cmdq_error(item, "value is %s: %s", errstr, value);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
options_set_number(oo, oe->name, number);
|
|
||||||
return (0);
|
|
||||||
case OPTIONS_TABLE_KEY:
|
|
||||||
key = key_string_lookup_string(value);
|
|
||||||
if (key == KEYC_UNKNOWN) {
|
|
||||||
cmdq_error(item, "bad key: %s", value);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
options_set_number(oo, oe->name, key);
|
|
||||||
return (0);
|
|
||||||
case OPTIONS_TABLE_COLOUR:
|
|
||||||
if ((number = colour_fromstring(value)) == -1) {
|
|
||||||
cmdq_error(item, "bad colour: %s", value);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
o = options_set_number(oo, oe->name, number);
|
|
||||||
options_style_update_new(oo, o);
|
|
||||||
return (0);
|
|
||||||
case OPTIONS_TABLE_ATTRIBUTES:
|
|
||||||
if ((number = attributes_fromstring(value)) == -1) {
|
|
||||||
cmdq_error(item, "bad attributes: %s", value);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
o = options_set_number(oo, oe->name, number);
|
|
||||||
options_style_update_new(oo, o);
|
|
||||||
return (0);
|
|
||||||
case OPTIONS_TABLE_FLAG:
|
|
||||||
return (cmd_set_option_flag(item, oe, oo, value));
|
|
||||||
case OPTIONS_TABLE_CHOICE:
|
|
||||||
return (cmd_set_option_choice(item, oe, oo, value));
|
|
||||||
case OPTIONS_TABLE_STYLE:
|
|
||||||
o = options_set_style(oo, oe->name, append, value);
|
|
||||||
if (o == NULL) {
|
|
||||||
cmdq_error(item, "bad style: %s", value);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
options_style_update_old(oo, o);
|
|
||||||
return (0);
|
|
||||||
case OPTIONS_TABLE_ARRAY:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
cmd_set_option_flag(struct cmdq_item *item,
|
|
||||||
const struct options_table_entry *oe, struct options *oo,
|
|
||||||
const char *value)
|
|
||||||
{
|
|
||||||
int flag;
|
|
||||||
|
|
||||||
if (value == NULL || *value == '\0')
|
|
||||||
flag = !options_get_number(oo, oe->name);
|
|
||||||
else if (strcmp(value, "1") == 0 ||
|
|
||||||
strcasecmp(value, "on") == 0 ||
|
|
||||||
strcasecmp(value, "yes") == 0)
|
|
||||||
flag = 1;
|
|
||||||
else if (strcmp(value, "0") == 0 ||
|
|
||||||
strcasecmp(value, "off") == 0 ||
|
|
||||||
strcasecmp(value, "no") == 0)
|
|
||||||
flag = 0;
|
|
||||||
else {
|
|
||||||
cmdq_error(item, "bad value: %s", value);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
options_set_number(oo, oe->name, flag);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
cmd_set_option_choice(struct cmdq_item *item,
|
|
||||||
const struct options_table_entry *oe, struct options *oo,
|
|
||||||
const char *value)
|
|
||||||
{
|
|
||||||
const char **cp;
|
|
||||||
int n, choice = -1;
|
|
||||||
|
|
||||||
if (value == NULL) {
|
|
||||||
choice = options_get_number(oo, oe->name);
|
|
||||||
if (choice < 2)
|
|
||||||
choice = !choice;
|
|
||||||
} else {
|
|
||||||
n = 0;
|
|
||||||
for (cp = oe->choices; *cp != NULL; cp++) {
|
|
||||||
if (strcmp(*cp, value) == 0)
|
|
||||||
choice = n;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
if (choice == -1) {
|
|
||||||
cmdq_error(item, "unknown value: %s", value);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options_set_number(oo, oe->name, choice);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ const struct cmd_entry cmd_show_environment_entry = {
|
|||||||
.name = "show-environment",
|
.name = "show-environment",
|
||||||
.alias = "showenv",
|
.alias = "showenv",
|
||||||
|
|
||||||
.args = { "gst:", 0, 1 },
|
.args = { "hgst:", 0, 1, NULL },
|
||||||
.usage = "[-gs] " CMD_TARGET_SESSION_USAGE " [name]",
|
.usage = "[-hgs] " CMD_TARGET_SESSION_USAGE " [name]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
@@ -69,9 +69,15 @@ static void
|
|||||||
cmd_show_environment_print(struct cmd *self, struct cmdq_item *item,
|
cmd_show_environment_print(struct cmd *self, struct cmdq_item *item,
|
||||||
struct environ_entry *envent)
|
struct environ_entry *envent)
|
||||||
{
|
{
|
||||||
char *escaped;
|
struct args *args = cmd_get_args(self);
|
||||||
|
char *escaped;
|
||||||
|
|
||||||
if (!args_has(self->args, 's')) {
|
if (!args_has(args, 'h') && (envent->flags & ENVIRON_HIDDEN))
|
||||||
|
return;
|
||||||
|
if (args_has(args, 'h') && (~envent->flags & ENVIRON_HIDDEN))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!args_has(args, 's')) {
|
||||||
if (envent->value != NULL)
|
if (envent->value != NULL)
|
||||||
cmdq_print(item, "%s=%s", envent->name, envent->value);
|
cmdq_print(item, "%s=%s", envent->name, envent->value);
|
||||||
else
|
else
|
||||||
@@ -91,36 +97,37 @@ cmd_show_environment_print(struct cmd *self, struct cmdq_item *item,
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct environ *env;
|
struct environ *env;
|
||||||
struct environ_entry *envent;
|
struct environ_entry *envent;
|
||||||
const char *target;
|
const char *tflag, *name = args_string(args, 0);
|
||||||
|
|
||||||
if ((target = args_get(args, 't')) != NULL) {
|
if ((tflag = args_get(args, 't')) != NULL) {
|
||||||
if (item->target.s == NULL) {
|
if (target->s == NULL) {
|
||||||
cmdq_error(item, "no such session: %s", target);
|
cmdq_error(item, "no such session: %s", tflag);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'g'))
|
if (args_has(args, 'g'))
|
||||||
env = global_environ;
|
env = global_environ;
|
||||||
else {
|
else {
|
||||||
if (item->target.s == NULL) {
|
if (target->s == NULL) {
|
||||||
target = args_get(args, 't');
|
tflag = args_get(args, 't');
|
||||||
if (target != NULL)
|
if (tflag != NULL)
|
||||||
cmdq_error(item, "no such session: %s", target);
|
cmdq_error(item, "no such session: %s", tflag);
|
||||||
else
|
else
|
||||||
cmdq_error(item, "no current session");
|
cmdq_error(item, "no current session");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
env = item->target.s->environ;
|
env = target->s->environ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc != 0) {
|
if (name != NULL) {
|
||||||
envent = environ_find(env, args->argv[0]);
|
envent = environ_find(env, name);
|
||||||
if (envent == NULL) {
|
if (envent == NULL) {
|
||||||
cmdq_error(item, "unknown variable: %s", args->argv[0]);
|
cmdq_error(item, "unknown variable: %s", name);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
cmd_show_environment_print(self, item, envent);
|
cmd_show_environment_print(self, item, envent);
|
||||||
|
|||||||
@@ -18,16 +18,19 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show client message log.
|
* Show message log.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define SHOW_MESSAGES_TEMPLATE \
|
||||||
|
"#{t/p:message_time}: #{message_text}"
|
||||||
|
|
||||||
static enum cmd_retval cmd_show_messages_exec(struct cmd *,
|
static enum cmd_retval cmd_show_messages_exec(struct cmd *,
|
||||||
struct cmdq_item *);
|
struct cmdq_item *);
|
||||||
|
|
||||||
@@ -35,30 +38,31 @@ const struct cmd_entry cmd_show_messages_entry = {
|
|||||||
.name = "show-messages",
|
.name = "show-messages",
|
||||||
.alias = "showmsgs",
|
.alias = "showmsgs",
|
||||||
|
|
||||||
.args = { "JTt:", 0, 0 },
|
.args = { "JTt:", 0, 0, NULL },
|
||||||
.usage = "[-JT] " CMD_TARGET_CLIENT_USAGE,
|
.usage = "[-JT] " CMD_TARGET_CLIENT_USAGE,
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG,
|
||||||
.exec = cmd_show_messages_exec
|
.exec = cmd_show_messages_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
static int cmd_show_messages_terminals(struct cmdq_item *, int);
|
|
||||||
static int cmd_show_messages_jobs(struct cmdq_item *, int);
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cmd_show_messages_terminals(struct cmdq_item *item, int blank)
|
cmd_show_messages_terminals(struct cmd *self, struct cmdq_item *item, int blank)
|
||||||
{
|
{
|
||||||
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct tty_term *term;
|
struct tty_term *term;
|
||||||
u_int i, n;
|
u_int i, n;
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
LIST_FOREACH(term, &tty_terms, entry) {
|
LIST_FOREACH(term, &tty_terms, entry) {
|
||||||
|
if (args_has(args, 't') && term != tc->tty.term)
|
||||||
|
continue;
|
||||||
if (blank) {
|
if (blank) {
|
||||||
cmdq_print(item, "%s", "");
|
cmdq_print(item, "%s", "");
|
||||||
blank = 0;
|
blank = 0;
|
||||||
}
|
}
|
||||||
cmdq_print(item, "Terminal %u: %s [references=%u, flags=0x%x]:",
|
cmdq_print(item, "Terminal %u: %s for %s, flags=0x%x:", n,
|
||||||
n, term->name, term->references, term->flags);
|
term->name, term->tty->client->name, term->flags);
|
||||||
n++;
|
n++;
|
||||||
for (i = 0; i < tty_term_ncodes(); i++)
|
for (i = 0; i < tty_term_ncodes(); i++)
|
||||||
cmdq_print(item, "%s", tty_term_describe(term, i));
|
cmdq_print(item, "%s", tty_term_describe(term, i));
|
||||||
@@ -66,55 +70,38 @@ cmd_show_messages_terminals(struct cmdq_item *item, int blank)
|
|||||||
return (n != 0);
|
return (n != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
cmd_show_messages_jobs(struct cmdq_item *item, int blank)
|
|
||||||
{
|
|
||||||
struct job *job;
|
|
||||||
u_int n;
|
|
||||||
|
|
||||||
n = 0;
|
|
||||||
LIST_FOREACH(job, &all_jobs, entry) {
|
|
||||||
if (blank) {
|
|
||||||
cmdq_print(item, "%s", "");
|
|
||||||
blank = 0;
|
|
||||||
}
|
|
||||||
cmdq_print(item, "Job %u: %s [fd=%d, pid=%ld, status=%d]",
|
|
||||||
n, job->cmd, job->fd, (long)job->pid, job->status);
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
return (n != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_show_messages_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_show_messages_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct client *c;
|
|
||||||
struct message_entry *msg;
|
struct message_entry *msg;
|
||||||
char *tim;
|
char *s;
|
||||||
int done, blank;
|
int done, blank;
|
||||||
|
struct format_tree *ft;
|
||||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
done = blank = 0;
|
done = blank = 0;
|
||||||
if (args_has(args, 'T')) {
|
if (args_has(args, 'T')) {
|
||||||
blank = cmd_show_messages_terminals(item, blank);
|
blank = cmd_show_messages_terminals(self, item, blank);
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
if (args_has(args, 'J')) {
|
if (args_has(args, 'J')) {
|
||||||
cmd_show_messages_jobs(item, blank);
|
job_print_summary(item, blank);
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
if (done)
|
if (done)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
TAILQ_FOREACH(msg, &c->message_log, entry) {
|
ft = format_create_from_target(item);
|
||||||
tim = ctime(&msg->msg_time);
|
TAILQ_FOREACH_REVERSE(msg, &message_log, message_list, entry) {
|
||||||
*strchr(tim, '\n') = '\0';
|
format_add(ft, "message_text", "%s", msg->msg);
|
||||||
|
format_add(ft, "message_number", "%u", msg->msg_num);
|
||||||
|
format_add_tv(ft, "message_time", &msg->msg_time);
|
||||||
|
|
||||||
cmdq_print(item, "%s %s", tim, msg->msg);
|
s = format_expand(ft, SHOW_MESSAGES_TEMPLATE);
|
||||||
|
cmdq_print(item, "%s", s);
|
||||||
|
free(s);
|
||||||
}
|
}
|
||||||
|
format_free(ft);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,19 +29,19 @@
|
|||||||
|
|
||||||
static enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmdq_item *);
|
static enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
static enum cmd_retval cmd_show_options_one(struct cmd *, struct cmdq_item *,
|
static void cmd_show_options_print(struct cmd *, struct cmdq_item *,
|
||||||
struct options *);
|
struct options_entry *, int, int);
|
||||||
static enum cmd_retval cmd_show_options_all(struct cmd *, struct cmdq_item *,
|
static enum cmd_retval cmd_show_options_all(struct cmd *, struct cmdq_item *,
|
||||||
struct options *);
|
int, struct options *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_options_entry = {
|
const struct cmd_entry cmd_show_options_entry = {
|
||||||
.name = "show-options",
|
.name = "show-options",
|
||||||
.alias = "show",
|
.alias = "show",
|
||||||
|
|
||||||
.args = { "gqst:vw", 0, 1 },
|
.args = { "AgHpqst:vw", 0, 1, NULL },
|
||||||
.usage = "[-gqsvw] [-t target-session|target-window] [option]",
|
.usage = "[-AgHpqsvw] " CMD_TARGET_PANE_USAGE " [option]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
|
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_show_options_exec
|
.exec = cmd_show_options_exec
|
||||||
@@ -51,7 +51,7 @@ const struct cmd_entry cmd_show_window_options_entry = {
|
|||||||
.name = "show-window-options",
|
.name = "show-window-options",
|
||||||
.alias = "showw",
|
.alias = "showw",
|
||||||
|
|
||||||
.args = { "gvt:", 0, 1 },
|
.args = { "gvt:", 0, 1, NULL },
|
||||||
.usage = "[-gv] " CMD_TARGET_WINDOW_USAGE " [option]",
|
.usage = "[-gv] " CMD_TARGET_WINDOW_USAGE " [option]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
|
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
|
||||||
@@ -60,120 +60,201 @@ const struct cmd_entry cmd_show_window_options_entry = {
|
|||||||
.exec = cmd_show_options_exec
|
.exec = cmd_show_options_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_show_hooks_entry = {
|
||||||
|
.name = "show-hooks",
|
||||||
|
.alias = NULL,
|
||||||
|
|
||||||
|
.args = { "gpt:w", 0, 1, NULL },
|
||||||
|
.usage = "[-gpw] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
|
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_show_options_exec
|
||||||
|
};
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct cmd_find_state *fs = &item->target;
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct options *oo;
|
struct options *oo;
|
||||||
enum options_table_scope scope;
|
char *argument, *name = NULL, *cause;
|
||||||
char *cause;
|
int window, idx, ambiguous, parent, scope;
|
||||||
int window;
|
struct options_entry *o;
|
||||||
|
|
||||||
window = (self->entry == &cmd_show_window_options_entry);
|
window = (cmd_get_entry(self) == &cmd_show_window_options_entry);
|
||||||
scope = options_scope_from_flags(args, window, fs, &oo, &cause);
|
|
||||||
|
if (args_count(args) == 0) {
|
||||||
|
scope = options_scope_from_flags(args, window, target, &oo,
|
||||||
|
&cause);
|
||||||
|
if (scope == OPTIONS_TABLE_NONE) {
|
||||||
|
if (args_has(args, 'q'))
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
return (cmd_show_options_all(self, item, scope, oo));
|
||||||
|
}
|
||||||
|
argument = format_single_from_target(item, args_string(args, 0));
|
||||||
|
|
||||||
|
name = options_match(argument, &idx, &ambiguous);
|
||||||
|
if (name == NULL) {
|
||||||
|
if (args_has(args, 'q'))
|
||||||
|
goto out;
|
||||||
|
if (ambiguous)
|
||||||
|
cmdq_error(item, "ambiguous option: %s", argument);
|
||||||
|
else
|
||||||
|
cmdq_error(item, "invalid option: %s", argument);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
scope = options_scope_from_name(args, window, name, target, &oo,
|
||||||
|
&cause);
|
||||||
if (scope == OPTIONS_TABLE_NONE) {
|
if (scope == OPTIONS_TABLE_NONE) {
|
||||||
|
if (args_has(args, 'q'))
|
||||||
|
goto out;
|
||||||
cmdq_error(item, "%s", cause);
|
cmdq_error(item, "%s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
goto fail;
|
||||||
|
}
|
||||||
|
o = options_get_only(oo, name);
|
||||||
|
if (args_has(args, 'A') && o == NULL) {
|
||||||
|
o = options_get(oo, name);
|
||||||
|
parent = 1;
|
||||||
|
} else
|
||||||
|
parent = 0;
|
||||||
|
if (o != NULL)
|
||||||
|
cmd_show_options_print(self, item, o, idx, parent);
|
||||||
|
else if (*name == '@') {
|
||||||
|
if (args_has(args, 'q'))
|
||||||
|
goto out;
|
||||||
|
cmdq_error(item, "invalid option: %s", argument);
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc == 0)
|
out:
|
||||||
return (cmd_show_options_all(self, item, oo));
|
free(name);
|
||||||
else
|
free(argument);
|
||||||
return (cmd_show_options_one(self, item, oo));
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
fail:
|
||||||
|
free(name);
|
||||||
|
free(argument);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
|
cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
|
||||||
struct options_entry *o, int idx)
|
struct options_entry *o, int idx, int parent)
|
||||||
{
|
{
|
||||||
const char *name;
|
struct args *args = cmd_get_args(self);
|
||||||
const char *value;
|
struct options_array_item *a;
|
||||||
char *tmp, *escaped;
|
const char *name = options_name(o);
|
||||||
u_int size, i;
|
char *value, *tmp = NULL, *escaped;
|
||||||
|
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
xasprintf(&tmp, "%s[%d]", options_name(o), idx);
|
xasprintf(&tmp, "%s[%d]", name, idx);
|
||||||
name = tmp;
|
name = tmp;
|
||||||
} else {
|
} else {
|
||||||
if (options_array_size(o, &size) != -1) {
|
if (options_is_array(o)) {
|
||||||
for (i = 0; i < size; i++) {
|
a = options_array_first(o);
|
||||||
if (options_array_get(o, i) == NULL)
|
if (a == NULL) {
|
||||||
continue;
|
if (!args_has(args, 'v'))
|
||||||
cmd_show_options_print(self, item, o, i);
|
cmdq_print(item, "%s", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (a != NULL) {
|
||||||
|
idx = options_array_item_index(a);
|
||||||
|
cmd_show_options_print(self, item, o, idx,
|
||||||
|
parent);
|
||||||
|
a = options_array_next(a);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tmp = NULL;
|
|
||||||
name = options_name(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
value = options_tostring(o, idx, 0);
|
value = options_to_string(o, idx, 0);
|
||||||
if (args_has(self->args, 'v'))
|
if (args_has(args, 'v'))
|
||||||
cmdq_print(item, "%s", value);
|
cmdq_print(item, "%s", value);
|
||||||
else if (options_isstring(o)) {
|
else if (options_is_string(o)) {
|
||||||
utf8_stravis(&escaped, value, VIS_OCTAL|VIS_TAB|VIS_NL|VIS_DQ);
|
escaped = args_escape(value);
|
||||||
cmdq_print(item, "%s \"%s\"", name, escaped);
|
if (parent)
|
||||||
|
cmdq_print(item, "%s* %s", name, escaped);
|
||||||
|
else
|
||||||
|
cmdq_print(item, "%s %s", name, escaped);
|
||||||
free(escaped);
|
free(escaped);
|
||||||
} else
|
} else {
|
||||||
cmdq_print(item, "%s %s", name, value);
|
if (parent)
|
||||||
|
cmdq_print(item, "%s* %s", name, value);
|
||||||
|
else
|
||||||
|
cmdq_print(item, "%s %s", name, value);
|
||||||
|
}
|
||||||
|
free(value);
|
||||||
|
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_show_options_one(struct cmd *self, struct cmdq_item *item,
|
cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope,
|
||||||
struct options *oo)
|
struct options *oo)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
struct options_entry *o;
|
|
||||||
int idx, ambiguous;
|
|
||||||
const char *name = args->argv[0];
|
|
||||||
|
|
||||||
o = options_match_get(oo, name, &idx, 1, &ambiguous);
|
|
||||||
if (o == NULL) {
|
|
||||||
if (args_has(args, 'q'))
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
if (ambiguous) {
|
|
||||||
cmdq_error(item, "ambiguous option: %s", name);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
if (*name != '@' &&
|
|
||||||
options_match_get(oo, name, &idx, 0, &ambiguous) != NULL)
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
cmdq_error(item, "unknown option: %s", name);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
cmd_show_options_print(self, item, o, idx);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum cmd_retval
|
|
||||||
cmd_show_options_all(struct cmd *self, struct cmdq_item *item,
|
|
||||||
struct options *oo)
|
|
||||||
{
|
|
||||||
struct options_entry *o;
|
|
||||||
const struct options_table_entry *oe;
|
const struct options_table_entry *oe;
|
||||||
u_int size, idx;
|
struct options_entry *o;
|
||||||
|
struct options_array_item *a;
|
||||||
|
const char *name;
|
||||||
|
u_int idx;
|
||||||
|
int parent;
|
||||||
|
|
||||||
o = options_first(oo);
|
if (cmd_get_entry(self) != &cmd_show_hooks_entry) {
|
||||||
while (o != NULL) {
|
o = options_first(oo);
|
||||||
oe = options_table_entry(o);
|
while (o != NULL) {
|
||||||
if (oe != NULL && oe->style != NULL) {
|
if (options_table_entry(o) == NULL)
|
||||||
|
cmd_show_options_print(self, item, o, -1, 0);
|
||||||
o = options_next(o);
|
o = options_next(o);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (options_array_size(o, &size) == -1)
|
}
|
||||||
cmd_show_options_print(self, item, o, -1);
|
for (oe = options_table; oe->name != NULL; oe++) {
|
||||||
else {
|
if (~oe->scope & scope)
|
||||||
for (idx = 0; idx < size; idx++) {
|
continue;
|
||||||
if (options_array_get(o, idx) == NULL)
|
|
||||||
continue;
|
if ((cmd_get_entry(self) != &cmd_show_hooks_entry &&
|
||||||
cmd_show_options_print(self, item, o, idx);
|
!args_has(args, 'H') &&
|
||||||
|
(oe->flags & OPTIONS_TABLE_IS_HOOK)) ||
|
||||||
|
(cmd_get_entry(self) == &cmd_show_hooks_entry &&
|
||||||
|
(~oe->flags & OPTIONS_TABLE_IS_HOOK)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
o = options_get_only(oo, oe->name);
|
||||||
|
if (o == NULL) {
|
||||||
|
if (!args_has(args, 'A'))
|
||||||
|
continue;
|
||||||
|
o = options_get(oo, oe->name);
|
||||||
|
if (o == NULL)
|
||||||
|
continue;
|
||||||
|
parent = 1;
|
||||||
|
} else
|
||||||
|
parent = 0;
|
||||||
|
|
||||||
|
if (!options_is_array(o))
|
||||||
|
cmd_show_options_print(self, item, o, -1, parent);
|
||||||
|
else if ((a = options_array_first(o)) == NULL) {
|
||||||
|
if (!args_has(args, 'v')) {
|
||||||
|
name = options_name(o);
|
||||||
|
if (parent)
|
||||||
|
cmdq_print(item, "%s*", name);
|
||||||
|
else
|
||||||
|
cmdq_print(item, "%s", name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (a != NULL) {
|
||||||
|
idx = options_array_item_index(a);
|
||||||
|
cmd_show_options_print(self, item, o, idx,
|
||||||
|
parent);
|
||||||
|
a = options_array_next(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o = options_next(o);
|
|
||||||
}
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
108
cmd-show-prompt-history.c
Normal file
108
cmd-show-prompt-history.c
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 Anindya Mukherjee <anindya49@hotmail.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Show or clear prompt history.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_show_prompt_history_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_show_prompt_history_entry = {
|
||||||
|
.name = "show-prompt-history",
|
||||||
|
.alias = "showphist",
|
||||||
|
|
||||||
|
.args = { "T:", 0, 0, NULL },
|
||||||
|
.usage = "[-T type]",
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_show_prompt_history_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_clear_prompt_history_entry = {
|
||||||
|
.name = "clear-prompt-history",
|
||||||
|
.alias = "clearphist",
|
||||||
|
|
||||||
|
.args = { "T:", 0, 0, NULL },
|
||||||
|
.usage = "[-T type]",
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_show_prompt_history_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_show_prompt_history_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct args *args = cmd_get_args(self);
|
||||||
|
const char *typestr = args_get(args, 'T');
|
||||||
|
enum prompt_type type;
|
||||||
|
u_int tidx, hidx;
|
||||||
|
|
||||||
|
if (cmd_get_entry(self) == &cmd_clear_prompt_history_entry) {
|
||||||
|
if (typestr == NULL) {
|
||||||
|
for (tidx = 0; tidx < PROMPT_NTYPES; tidx++) {
|
||||||
|
free(status_prompt_hlist[tidx]);
|
||||||
|
status_prompt_hlist[tidx] = NULL;
|
||||||
|
status_prompt_hsize[tidx] = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
type = status_prompt_type(typestr);
|
||||||
|
if (type == PROMPT_TYPE_INVALID) {
|
||||||
|
cmdq_error(item, "invalid type: %s", typestr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
free(status_prompt_hlist[type]);
|
||||||
|
status_prompt_hlist[type] = NULL;
|
||||||
|
status_prompt_hsize[type] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typestr == NULL) {
|
||||||
|
for (tidx = 0; tidx < PROMPT_NTYPES; tidx++) {
|
||||||
|
cmdq_print(item, "History for %s:\n",
|
||||||
|
status_prompt_type_string(tidx));
|
||||||
|
for (hidx = 0; hidx < status_prompt_hsize[tidx];
|
||||||
|
hidx++) {
|
||||||
|
cmdq_print(item, "%d: %s", hidx + 1,
|
||||||
|
status_prompt_hlist[tidx][hidx]);
|
||||||
|
}
|
||||||
|
cmdq_print(item, "%s", "");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
type = status_prompt_type(typestr);
|
||||||
|
if (type == PROMPT_TYPE_INVALID) {
|
||||||
|
cmdq_error(item, "invalid type: %s", typestr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
cmdq_print(item, "History for %s:\n",
|
||||||
|
status_prompt_type_string(type));
|
||||||
|
for (hidx = 0; hidx < status_prompt_hsize[type]; hidx++) {
|
||||||
|
cmdq_print(item, "%d: %s", hidx + 1,
|
||||||
|
status_prompt_hlist[type][hidx]);
|
||||||
|
}
|
||||||
|
cmdq_print(item, "%s", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
@@ -31,68 +31,178 @@
|
|||||||
|
|
||||||
static enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmdq_item *);
|
static enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
static enum cmd_retval cmd_source_file_done(struct cmdq_item *, void *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_source_file_entry = {
|
const struct cmd_entry cmd_source_file_entry = {
|
||||||
.name = "source-file",
|
.name = "source-file",
|
||||||
.alias = "source",
|
.alias = "source",
|
||||||
|
|
||||||
.args = { "q", 1, 1 },
|
.args = { "t:Fnqv", 1, -1, NULL },
|
||||||
.usage = "[-q] path",
|
.usage = "[-Fnqv] " CMD_TARGET_PANE_USAGE " path ...",
|
||||||
|
|
||||||
|
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.exec = cmd_source_file_exec
|
.exec = cmd_source_file_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum cmd_retval
|
struct cmd_source_file_data {
|
||||||
cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
struct cmdq_item *item;
|
||||||
{
|
int flags;
|
||||||
struct args *args = self->args;
|
|
||||||
int quiet = args_has(args, 'q');
|
|
||||||
struct client *c = item->client;
|
|
||||||
struct cmdq_item *new_item;
|
|
||||||
enum cmd_retval retval;
|
|
||||||
char *pattern, *tmp;
|
|
||||||
const char *path = args->argv[0];
|
|
||||||
glob_t g;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
if (*path == '/')
|
struct cmdq_item *after;
|
||||||
pattern = xstrdup(path);
|
enum cmd_retval retval;
|
||||||
else {
|
|
||||||
utf8_stravis(&tmp, server_client_get_cwd(c), VIS_GLOB);
|
|
||||||
xasprintf(&pattern, "%s/%s", tmp, path);
|
|
||||||
free(tmp);
|
|
||||||
}
|
|
||||||
log_debug("%s: %s", __func__, pattern);
|
|
||||||
|
|
||||||
retval = CMD_RETURN_NORMAL;
|
u_int current;
|
||||||
if (glob(pattern, 0, NULL, &g) != 0) {
|
char **files;
|
||||||
if (!quiet || errno != ENOENT) {
|
u_int nfiles;
|
||||||
cmdq_error(item, "%s: %s", path, strerror(errno));
|
};
|
||||||
retval = CMD_RETURN_ERROR;
|
|
||||||
}
|
|
||||||
free(pattern);
|
|
||||||
return (retval);
|
|
||||||
}
|
|
||||||
free(pattern);
|
|
||||||
|
|
||||||
for (i = 0; i < (u_int)g.gl_pathc; i++) {
|
|
||||||
if (load_cfg(g.gl_pathv[i], c, item, quiet) < 0)
|
|
||||||
retval = CMD_RETURN_ERROR;
|
|
||||||
}
|
|
||||||
if (cfg_finished) {
|
|
||||||
new_item = cmdq_get_callback(cmd_source_file_done, NULL);
|
|
||||||
cmdq_insert_after(item, new_item);
|
|
||||||
}
|
|
||||||
|
|
||||||
globfree(&g);
|
|
||||||
return (retval);
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_source_file_done(struct cmdq_item *item, __unused void *data)
|
cmd_source_file_complete_cb(struct cmdq_item *item, __unused void *data)
|
||||||
{
|
{
|
||||||
cfg_print_causes(item);
|
cfg_print_causes(item);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_source_file_complete(struct client *c, struct cmd_source_file_data *cdata)
|
||||||
|
{
|
||||||
|
struct cmdq_item *new_item;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
if (cfg_finished) {
|
||||||
|
if (cdata->retval == CMD_RETURN_ERROR &&
|
||||||
|
c != NULL &&
|
||||||
|
c->session == NULL)
|
||||||
|
c->retval = 1;
|
||||||
|
new_item = cmdq_get_callback(cmd_source_file_complete_cb, NULL);
|
||||||
|
cmdq_insert_after(cdata->after, new_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < cdata->nfiles; i++)
|
||||||
|
free(cdata->files[i]);
|
||||||
|
free(cdata->files);
|
||||||
|
free(cdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_source_file_done(struct client *c, const char *path, int error,
|
||||||
|
int closed, struct evbuffer *buffer, void *data)
|
||||||
|
{
|
||||||
|
struct cmd_source_file_data *cdata = data;
|
||||||
|
struct cmdq_item *item = cdata->item;
|
||||||
|
void *bdata = EVBUFFER_DATA(buffer);
|
||||||
|
size_t bsize = EVBUFFER_LENGTH(buffer);
|
||||||
|
u_int n;
|
||||||
|
struct cmdq_item *new_item;
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
|
||||||
|
if (!closed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (error != 0)
|
||||||
|
cmdq_error(item, "%s: %s", path, strerror(error));
|
||||||
|
else if (bsize != 0) {
|
||||||
|
if (load_cfg_from_buffer(bdata, bsize, path, c, cdata->after,
|
||||||
|
target, cdata->flags, &new_item) < 0)
|
||||||
|
cdata->retval = CMD_RETURN_ERROR;
|
||||||
|
else if (new_item != NULL)
|
||||||
|
cdata->after = new_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = ++cdata->current;
|
||||||
|
if (n < cdata->nfiles)
|
||||||
|
file_read(c, cdata->files[n], cmd_source_file_done, cdata);
|
||||||
|
else {
|
||||||
|
cmd_source_file_complete(c, cdata);
|
||||||
|
cmdq_continue(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_source_file_add(struct cmd_source_file_data *cdata, const char *path)
|
||||||
|
{
|
||||||
|
log_debug("%s: %s", __func__, path);
|
||||||
|
cdata->files = xreallocarray(cdata->files, cdata->nfiles + 1,
|
||||||
|
sizeof *cdata->files);
|
||||||
|
cdata->files[cdata->nfiles++] = xstrdup(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct cmd_source_file_data *cdata;
|
||||||
|
struct client *c = cmdq_get_client(item);
|
||||||
|
enum cmd_retval retval = CMD_RETURN_NORMAL;
|
||||||
|
char *pattern, *cwd, *expanded = NULL;
|
||||||
|
const char *path, *error;
|
||||||
|
glob_t g;
|
||||||
|
int result;
|
||||||
|
u_int i, j;
|
||||||
|
|
||||||
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
|
cdata->item = item;
|
||||||
|
|
||||||
|
if (args_has(args, 'q'))
|
||||||
|
cdata->flags |= CMD_PARSE_QUIET;
|
||||||
|
if (args_has(args, 'n'))
|
||||||
|
cdata->flags |= CMD_PARSE_PARSEONLY;
|
||||||
|
if (args_has(args, 'v'))
|
||||||
|
cdata->flags |= CMD_PARSE_VERBOSE;
|
||||||
|
|
||||||
|
utf8_stravis(&cwd, server_client_get_cwd(c, NULL), VIS_GLOB);
|
||||||
|
|
||||||
|
for (i = 0; i < args_count(args); i++) {
|
||||||
|
path = args_string(args, i);
|
||||||
|
if (args_has(args, 'F')) {
|
||||||
|
free(expanded);
|
||||||
|
expanded = format_single_from_target(item, path);
|
||||||
|
path = expanded;
|
||||||
|
}
|
||||||
|
if (strcmp(path, "-") == 0) {
|
||||||
|
cmd_source_file_add(cdata, "-");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*path == '/')
|
||||||
|
pattern = xstrdup(path);
|
||||||
|
else
|
||||||
|
xasprintf(&pattern, "%s/%s", cwd, path);
|
||||||
|
log_debug("%s: %s", __func__, pattern);
|
||||||
|
|
||||||
|
if ((result = glob(pattern, 0, NULL, &g)) != 0) {
|
||||||
|
if (result != GLOB_NOMATCH ||
|
||||||
|
(~cdata->flags & CMD_PARSE_QUIET)) {
|
||||||
|
if (result == GLOB_NOMATCH)
|
||||||
|
error = strerror(ENOENT);
|
||||||
|
else if (result == GLOB_NOSPACE)
|
||||||
|
error = strerror(ENOMEM);
|
||||||
|
else
|
||||||
|
error = strerror(EINVAL);
|
||||||
|
cmdq_error(item, "%s: %s", path, error);
|
||||||
|
retval = CMD_RETURN_ERROR;
|
||||||
|
}
|
||||||
|
globfree(&g);
|
||||||
|
free(pattern);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
free(pattern);
|
||||||
|
|
||||||
|
for (j = 0; j < g.gl_pathc; j++)
|
||||||
|
cmd_source_file_add(cdata, g.gl_pathv[j]);
|
||||||
|
globfree(&g);
|
||||||
|
}
|
||||||
|
free(expanded);
|
||||||
|
|
||||||
|
cdata->after = item;
|
||||||
|
cdata->retval = retval;
|
||||||
|
|
||||||
|
if (cdata->nfiles != 0) {
|
||||||
|
file_read(c, cdata->files[0], cmd_source_file_done, cdata);
|
||||||
|
retval = CMD_RETURN_WAIT;
|
||||||
|
} else
|
||||||
|
cmd_source_file_complete(c, cdata);
|
||||||
|
|
||||||
|
free(cwd);
|
||||||
|
return (retval);
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,9 +39,10 @@ const struct cmd_entry cmd_split_window_entry = {
|
|||||||
.name = "split-window",
|
.name = "split-window",
|
||||||
.alias = "splitw",
|
.alias = "splitw",
|
||||||
|
|
||||||
.args = { "bc:dfF:l:hp:Pt:v", 0, -1 },
|
.args = { "bc:de:fF:hIl:p:Pt:vZ", 0, -1, NULL },
|
||||||
.usage = "[-bdfhvP] [-c start-directory] [-F format] "
|
.usage = "[-bdefhIPvZ] [-c start-directory] [-e environment] "
|
||||||
"[-p percentage|-l size] " CMD_TARGET_PANE_USAGE " [command]",
|
"[-F format] [-l size] " CMD_TARGET_PANE_USAGE
|
||||||
|
"[shell-command]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
@@ -52,141 +53,147 @@ const struct cmd_entry cmd_split_window_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct cmd_find_state *current = &item->shared->current;
|
struct args *args = cmd_get_args(self);
|
||||||
struct args *args = self->args;
|
struct cmd_find_state *current = cmdq_get_current(item);
|
||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct session *s = item->target.s;
|
struct spawn_context sc = { 0 };
|
||||||
struct winlink *wl = item->target.wl;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
|
struct session *s = target->s;
|
||||||
|
struct winlink *wl = target->wl;
|
||||||
struct window *w = wl->window;
|
struct window *w = wl->window;
|
||||||
struct window_pane *wp = item->target.wp, *new_wp = NULL;
|
struct window_pane *wp = target->wp, *new_wp;
|
||||||
struct environ *env;
|
|
||||||
const char *cmd, *path, *shell, *template, *cwd, *to_free;
|
|
||||||
char **argv, *cause, *new_cause, *cp;
|
|
||||||
u_int hlimit;
|
|
||||||
int argc, size, percentage;
|
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
struct layout_cell *lc;
|
struct layout_cell *lc;
|
||||||
struct environ_entry *envent;
|
struct cmd_find_state fs;
|
||||||
struct cmd_find_state fs;
|
int size, flags, input;
|
||||||
|
const char *template;
|
||||||
server_unzoom_window(w);
|
char *cause = NULL, *cp;
|
||||||
|
struct args_value *av;
|
||||||
if (args->argc == 0) {
|
u_int count = args_count(args), curval = 0;
|
||||||
cmd = options_get_string(s->options, "default-command");
|
|
||||||
if (cmd != NULL && *cmd != '\0') {
|
|
||||||
argc = 1;
|
|
||||||
argv = (char **)&cmd;
|
|
||||||
} else {
|
|
||||||
argc = 0;
|
|
||||||
argv = NULL;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
argc = args->argc;
|
|
||||||
argv = args->argv;
|
|
||||||
}
|
|
||||||
|
|
||||||
to_free = NULL;
|
|
||||||
if (args_has(args, 'c')) {
|
|
||||||
cwd = args_get(args, 'c');
|
|
||||||
to_free = cwd = format_single(item, cwd, c, s, NULL, NULL);
|
|
||||||
} else if (item->client != NULL && item->client->session == NULL)
|
|
||||||
cwd = item->client->cwd;
|
|
||||||
else
|
|
||||||
cwd = s->cwd;
|
|
||||||
|
|
||||||
type = LAYOUT_TOPBOTTOM;
|
type = LAYOUT_TOPBOTTOM;
|
||||||
if (args_has(args, 'h'))
|
if (args_has(args, 'h'))
|
||||||
type = LAYOUT_LEFTRIGHT;
|
type = LAYOUT_LEFTRIGHT;
|
||||||
|
|
||||||
|
/* If the 'p' flag is dropped then this bit can be moved into 'l'. */
|
||||||
|
if (args_has(args, 'l') || args_has(args, 'p')) {
|
||||||
|
if (args_has(args, 'f')) {
|
||||||
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
|
curval = w->sy;
|
||||||
|
else
|
||||||
|
curval = w->sx;
|
||||||
|
} else {
|
||||||
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
|
curval = wp->sy;
|
||||||
|
else
|
||||||
|
curval = wp->sx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size = -1;
|
size = -1;
|
||||||
if (args_has(args, 'l')) {
|
if (args_has(args, 'l')) {
|
||||||
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
size = args_percentage_and_expand(args, 'l', 0, INT_MAX, curval,
|
||||||
if (cause != NULL) {
|
item, &cause);
|
||||||
xasprintf(&new_cause, "size %s", cause);
|
|
||||||
free(cause);
|
|
||||||
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);
|
size = args_strtonum_and_expand(args, 'p', 0, 100, item,
|
||||||
if (cause != NULL) {
|
&cause);
|
||||||
xasprintf(&new_cause, "percentage %s", cause);
|
if (cause == NULL)
|
||||||
free(cause);
|
size = curval * size / 100;
|
||||||
cause = new_cause;
|
}
|
||||||
goto error;
|
if (cause != NULL) {
|
||||||
}
|
cmdq_error(item, "size %s", cause);
|
||||||
if (type == LAYOUT_TOPBOTTOM)
|
free(cause);
|
||||||
size = (wp->sy * percentage) / 100;
|
return (CMD_RETURN_ERROR);
|
||||||
else
|
|
||||||
size = (wp->sx * percentage) / 100;
|
|
||||||
}
|
}
|
||||||
hlimit = options_get_number(s->options, "history-limit");
|
|
||||||
|
|
||||||
shell = options_get_string(s->options, "default-shell");
|
window_push_zoom(wp->window, 1, args_has(args, 'Z'));
|
||||||
if (*shell == '\0' || areshell(shell))
|
input = (args_has(args, 'I') && count == 0);
|
||||||
shell = _PATH_BSHELL;
|
|
||||||
|
|
||||||
lc = layout_split_pane(wp, type, size, args_has(args, 'b'),
|
flags = 0;
|
||||||
args_has(args, 'f'));
|
if (args_has(args, 'b'))
|
||||||
|
flags |= SPAWN_BEFORE;
|
||||||
|
if (args_has(args, 'f'))
|
||||||
|
flags |= SPAWN_FULLSIZE;
|
||||||
|
if (input || (count == 1 && *args_string(args, 0) == '\0'))
|
||||||
|
flags |= SPAWN_EMPTY;
|
||||||
|
|
||||||
|
lc = layout_split_pane(wp, type, size, flags);
|
||||||
if (lc == NULL) {
|
if (lc == NULL) {
|
||||||
cause = xstrdup("pane too small");
|
cmdq_error(item, "no space for new pane");
|
||||||
goto error;
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
new_wp = window_add_pane(w, wp, args_has(args, 'b'), hlimit);
|
|
||||||
layout_assign_pane(lc, new_wp);
|
|
||||||
|
|
||||||
path = NULL;
|
sc.item = item;
|
||||||
if (item->client != NULL && item->client->session == NULL)
|
sc.s = s;
|
||||||
envent = environ_find(item->client->environ, "PATH");
|
sc.wl = wl;
|
||||||
else
|
|
||||||
envent = environ_find(s->environ, "PATH");
|
|
||||||
if (envent != NULL)
|
|
||||||
path = envent->value;
|
|
||||||
|
|
||||||
env = environ_for_session(s, 0);
|
sc.wp0 = wp;
|
||||||
if (window_pane_spawn(new_wp, argc, argv, path, shell, cwd, env,
|
sc.lc = lc;
|
||||||
s->tio, &cause) != 0) {
|
|
||||||
environ_free(env);
|
args_to_vector(args, &sc.argc, &sc.argv);
|
||||||
goto error;
|
sc.environ = environ_create();
|
||||||
|
|
||||||
|
av = args_first_value(args, 'e');
|
||||||
|
while (av != NULL) {
|
||||||
|
environ_put(sc.environ, av->string, 0);
|
||||||
|
av = args_next_value(av);
|
||||||
}
|
}
|
||||||
environ_free(env);
|
|
||||||
|
|
||||||
server_redraw_window(w);
|
sc.idx = -1;
|
||||||
|
sc.cwd = args_get(args, 'c');
|
||||||
|
|
||||||
if (!args_has(args, 'd')) {
|
sc.flags = flags;
|
||||||
window_set_active_pane(w, new_wp);
|
if (args_has(args, 'd'))
|
||||||
session_select(s, wl->idx);
|
sc.flags |= SPAWN_DETACHED;
|
||||||
cmd_find_from_session(current, s);
|
if (args_has(args, 'Z'))
|
||||||
server_redraw_session(s);
|
sc.flags |= SPAWN_ZOOM;
|
||||||
} else
|
|
||||||
server_status_session(s);
|
if ((new_wp = spawn_pane(&sc, &cause)) == NULL) {
|
||||||
|
cmdq_error(item, "create pane failed: %s", cause);
|
||||||
|
free(cause);
|
||||||
|
if (sc.argv != NULL)
|
||||||
|
cmd_free_argv(sc.argc, sc.argv);
|
||||||
|
environ_free(sc.environ);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (input) {
|
||||||
|
switch (window_pane_start_input(new_wp, item, &cause)) {
|
||||||
|
case -1:
|
||||||
|
server_client_remove_pane(new_wp);
|
||||||
|
layout_close_pane(new_wp);
|
||||||
|
window_remove_pane(wp->window, new_wp);
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
if (sc.argv != NULL)
|
||||||
|
cmd_free_argv(sc.argc, sc.argv);
|
||||||
|
environ_free(sc.environ);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
case 1:
|
||||||
|
input = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!args_has(args, 'd'))
|
||||||
|
cmd_find_from_winlink_pane(current, wl, new_wp, 0);
|
||||||
|
window_pop_zoom(wp->window);
|
||||||
|
server_redraw_window(wp->window);
|
||||||
|
server_status_session(s);
|
||||||
|
|
||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = SPLIT_WINDOW_TEMPLATE;
|
template = SPLIT_WINDOW_TEMPLATE;
|
||||||
cp = format_single(item, template, c, s, wl, new_wp);
|
cp = format_single(item, template, tc, s, wl, new_wp);
|
||||||
cmdq_print(item, "%s", cp);
|
cmdq_print(item, "%s", cp);
|
||||||
free(cp);
|
free(cp);
|
||||||
}
|
}
|
||||||
notify_window("window-layout-changed", w);
|
|
||||||
|
|
||||||
if (to_free != NULL)
|
cmd_find_from_winlink_pane(&fs, wl, new_wp, 0);
|
||||||
free((void *)to_free);
|
cmdq_insert_hook(s, item, &fs, "after-split-window");
|
||||||
|
|
||||||
cmd_find_from_winlink_pane(&fs, wl, new_wp);
|
|
||||||
hooks_insert(s->hooks, item, &fs, "after-split-window");
|
|
||||||
|
|
||||||
|
if (sc.argv != NULL)
|
||||||
|
cmd_free_argv(sc.argc, sc.argv);
|
||||||
|
environ_free(sc.environ);
|
||||||
|
if (input)
|
||||||
|
return (CMD_RETURN_WAIT);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
error:
|
|
||||||
if (new_wp != NULL) {
|
|
||||||
layout_close_pane(new_wp);
|
|
||||||
window_remove_pane(w, new_wp);
|
|
||||||
}
|
|
||||||
cmdq_error(item, "create pane failed: %s", cause);
|
|
||||||
free(cause);
|
|
||||||
|
|
||||||
if (to_free != NULL)
|
|
||||||
free((void *)to_free);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|||||||
365
cmd-string.c
365
cmd-string.c
@@ -1,365 +0,0 @@
|
|||||||
/* $OpenBSD$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Parse a command from a string.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int cmd_string_getc(const char *, size_t *);
|
|
||||||
static void cmd_string_ungetc(size_t *);
|
|
||||||
static void cmd_string_copy(char **, char *, size_t *);
|
|
||||||
static char *cmd_string_string(const char *, size_t *, char, int);
|
|
||||||
static char *cmd_string_variable(const char *, size_t *);
|
|
||||||
static char *cmd_string_expand_tilde(const char *, size_t *);
|
|
||||||
|
|
||||||
static int
|
|
||||||
cmd_string_getc(const char *s, size_t *p)
|
|
||||||
{
|
|
||||||
const u_char *ucs = s;
|
|
||||||
|
|
||||||
if (ucs[*p] == '\0')
|
|
||||||
return (EOF);
|
|
||||||
return (ucs[(*p)++]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cmd_string_ungetc(size_t *p)
|
|
||||||
{
|
|
||||||
(*p)--;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_string_split(const char *s, int *rargc, char ***rargv)
|
|
||||||
{
|
|
||||||
size_t p = 0;
|
|
||||||
int ch, argc = 0, append = 0;
|
|
||||||
char **argv = NULL, *buf = NULL, *t;
|
|
||||||
const char *whitespace, *equals;
|
|
||||||
size_t len = 0;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
ch = cmd_string_getc(s, &p);
|
|
||||||
switch (ch) {
|
|
||||||
case '\'':
|
|
||||||
if ((t = cmd_string_string(s, &p, '\'', 0)) == NULL)
|
|
||||||
goto error;
|
|
||||||
cmd_string_copy(&buf, t, &len);
|
|
||||||
break;
|
|
||||||
case '"':
|
|
||||||
if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
|
|
||||||
goto error;
|
|
||||||
cmd_string_copy(&buf, t, &len);
|
|
||||||
break;
|
|
||||||
case '$':
|
|
||||||
if ((t = cmd_string_variable(s, &p)) == NULL)
|
|
||||||
goto error;
|
|
||||||
cmd_string_copy(&buf, t, &len);
|
|
||||||
break;
|
|
||||||
case '#':
|
|
||||||
/* Comment: discard rest of line. */
|
|
||||||
while ((ch = cmd_string_getc(s, &p)) != EOF)
|
|
||||||
;
|
|
||||||
/* FALLTHROUGH */
|
|
||||||
case EOF:
|
|
||||||
case ' ':
|
|
||||||
case '\t':
|
|
||||||
if (buf != NULL) {
|
|
||||||
buf = xrealloc(buf, len + 1);
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
argv = xreallocarray(argv, argc + 1,
|
|
||||||
sizeof *argv);
|
|
||||||
argv[argc++] = buf;
|
|
||||||
|
|
||||||
buf = NULL;
|
|
||||||
len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ch != EOF)
|
|
||||||
break;
|
|
||||||
|
|
||||||
while (argc != 0) {
|
|
||||||
equals = strchr(argv[0], '=');
|
|
||||||
whitespace = argv[0] + strcspn(argv[0], " \t");
|
|
||||||
if (equals == NULL || equals > whitespace)
|
|
||||||
break;
|
|
||||||
environ_put(global_environ, argv[0]);
|
|
||||||
argc--;
|
|
||||||
memmove(argv, argv + 1, argc * (sizeof *argv));
|
|
||||||
}
|
|
||||||
goto done;
|
|
||||||
case '~':
|
|
||||||
if (buf != NULL) {
|
|
||||||
append = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
t = cmd_string_expand_tilde(s, &p);
|
|
||||||
if (t == NULL)
|
|
||||||
goto error;
|
|
||||||
cmd_string_copy(&buf, t, &len);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
append = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (append) {
|
|
||||||
if (len >= SIZE_MAX - 2)
|
|
||||||
goto error;
|
|
||||||
buf = xrealloc(buf, len + 1);
|
|
||||||
buf[len++] = ch;
|
|
||||||
}
|
|
||||||
append = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
|
||||||
*rargc = argc;
|
|
||||||
*rargv = argv;
|
|
||||||
|
|
||||||
free(buf);
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
error:
|
|
||||||
if (argv != NULL)
|
|
||||||
cmd_free_argv(argc, argv);
|
|
||||||
free(buf);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct cmd_list *
|
|
||||||
cmd_string_parse(const char *s, const char *file, u_int line, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_list *cmdlist = NULL;
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
|
|
||||||
*cause = NULL;
|
|
||||||
if (cmd_string_split(s, &argc, &argv) != 0)
|
|
||||||
goto error;
|
|
||||||
if (argc != 0) {
|
|
||||||
cmdlist = cmd_list_parse(argc, argv, file, line, cause);
|
|
||||||
if (cmdlist == NULL) {
|
|
||||||
cmd_free_argv(argc, argv);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmd_free_argv(argc, argv);
|
|
||||||
return (cmdlist);
|
|
||||||
|
|
||||||
error:
|
|
||||||
xasprintf(cause, "invalid or unknown command: %s", s);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cmd_string_copy(char **dst, char *src, size_t *len)
|
|
||||||
{
|
|
||||||
size_t srclen;
|
|
||||||
|
|
||||||
srclen = strlen(src);
|
|
||||||
|
|
||||||
*dst = xrealloc(*dst, *len + srclen + 1);
|
|
||||||
strlcpy(*dst + *len, src, srclen + 1);
|
|
||||||
|
|
||||||
*len += srclen;
|
|
||||||
free(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
|
||||||
{
|
|
||||||
int ch;
|
|
||||||
char *buf, *t;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
buf = NULL;
|
|
||||||
len = 0;
|
|
||||||
|
|
||||||
while ((ch = cmd_string_getc(s, p)) != endch) {
|
|
||||||
switch (ch) {
|
|
||||||
case EOF:
|
|
||||||
goto error;
|
|
||||||
case '\\':
|
|
||||||
if (!esc)
|
|
||||||
break;
|
|
||||||
switch (ch = cmd_string_getc(s, p)) {
|
|
||||||
case EOF:
|
|
||||||
goto error;
|
|
||||||
case 'e':
|
|
||||||
ch = '\033';
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
ch = '\r';
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
ch = '\n';
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
ch = '\t';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '$':
|
|
||||||
if (!esc)
|
|
||||||
break;
|
|
||||||
if ((t = cmd_string_variable(s, p)) == NULL)
|
|
||||||
goto error;
|
|
||||||
cmd_string_copy(&buf, t, &len);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len >= SIZE_MAX - 2)
|
|
||||||
goto error;
|
|
||||||
buf = xrealloc(buf, len + 1);
|
|
||||||
buf[len++] = ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = xrealloc(buf, len + 1);
|
|
||||||
buf[len] = '\0';
|
|
||||||
return (buf);
|
|
||||||
|
|
||||||
error:
|
|
||||||
free(buf);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
cmd_string_variable(const char *s, size_t *p)
|
|
||||||
{
|
|
||||||
int ch, fch;
|
|
||||||
char *buf, *t;
|
|
||||||
size_t len;
|
|
||||||
struct environ_entry *envent;
|
|
||||||
|
|
||||||
#define cmd_string_first(ch) ((ch) == '_' || \
|
|
||||||
((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z'))
|
|
||||||
#define cmd_string_other(ch) ((ch) == '_' || \
|
|
||||||
((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z') || \
|
|
||||||
((ch) >= '0' && (ch) <= '9'))
|
|
||||||
|
|
||||||
buf = NULL;
|
|
||||||
len = 0;
|
|
||||||
|
|
||||||
fch = EOF;
|
|
||||||
switch (ch = cmd_string_getc(s, p)) {
|
|
||||||
case EOF:
|
|
||||||
goto error;
|
|
||||||
case '{':
|
|
||||||
fch = '{';
|
|
||||||
|
|
||||||
ch = cmd_string_getc(s, p);
|
|
||||||
if (!cmd_string_first(ch))
|
|
||||||
goto error;
|
|
||||||
/* FALLTHROUGH */
|
|
||||||
default:
|
|
||||||
if (!cmd_string_first(ch)) {
|
|
||||||
xasprintf(&t, "$%c", ch);
|
|
||||||
return (t);
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = xrealloc(buf, len + 1);
|
|
||||||
buf[len++] = ch;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
ch = cmd_string_getc(s, p);
|
|
||||||
if (ch == EOF || !cmd_string_other(ch))
|
|
||||||
break;
|
|
||||||
else {
|
|
||||||
if (len >= SIZE_MAX - 3)
|
|
||||||
goto error;
|
|
||||||
buf = xrealloc(buf, len + 1);
|
|
||||||
buf[len++] = ch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fch == '{' && ch != '}')
|
|
||||||
goto error;
|
|
||||||
if (ch != EOF && fch != '{')
|
|
||||||
cmd_string_ungetc(p); /* ch */
|
|
||||||
|
|
||||||
buf = xrealloc(buf, len + 1);
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
envent = environ_find(global_environ, buf);
|
|
||||||
free(buf);
|
|
||||||
if (envent == NULL)
|
|
||||||
return (xstrdup(""));
|
|
||||||
return (xstrdup(envent->value));
|
|
||||||
|
|
||||||
error:
|
|
||||||
free(buf);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
cmd_string_expand_tilde(const char *s, size_t *p)
|
|
||||||
{
|
|
||||||
struct passwd *pw;
|
|
||||||
struct environ_entry *envent;
|
|
||||||
char *home, *path, *user, *cp;
|
|
||||||
int last;
|
|
||||||
|
|
||||||
home = NULL;
|
|
||||||
|
|
||||||
last = cmd_string_getc(s, p);
|
|
||||||
if (last == EOF || last == '/' || last == ' '|| last == '\t') {
|
|
||||||
envent = environ_find(global_environ, "HOME");
|
|
||||||
if (envent != NULL && *envent->value != '\0')
|
|
||||||
home = envent->value;
|
|
||||||
else if ((pw = getpwuid(getuid())) != NULL)
|
|
||||||
home = pw->pw_dir;
|
|
||||||
} else {
|
|
||||||
cmd_string_ungetc(p);
|
|
||||||
|
|
||||||
cp = user = xmalloc(strlen(s));
|
|
||||||
for (;;) {
|
|
||||||
last = cmd_string_getc(s, p);
|
|
||||||
if (last == EOF ||
|
|
||||||
last == '/' ||
|
|
||||||
last == ' '||
|
|
||||||
last == '\t')
|
|
||||||
break;
|
|
||||||
*cp++ = last;
|
|
||||||
}
|
|
||||||
*cp = '\0';
|
|
||||||
|
|
||||||
if ((pw = getpwnam(user)) != NULL)
|
|
||||||
home = pw->pw_dir;
|
|
||||||
free(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (home == NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
if (last != EOF)
|
|
||||||
xasprintf(&path, "%s%c", home, last);
|
|
||||||
else
|
|
||||||
xasprintf(&path, "%s", home);
|
|
||||||
return (path);
|
|
||||||
}
|
|
||||||
@@ -32,8 +32,8 @@ const struct cmd_entry cmd_swap_pane_entry = {
|
|||||||
.name = "swap-pane",
|
.name = "swap-pane",
|
||||||
.alias = "swapp",
|
.alias = "swapp",
|
||||||
|
|
||||||
.args = { "dDs:t:U", 0, 0 },
|
.args = { "dDs:t:UZ", 0, 0, NULL },
|
||||||
.usage = "[-dDU] " CMD_SRCDST_PANE_USAGE,
|
.usage = "[-dDUZ] " CMD_SRCDST_PANE_USAGE,
|
||||||
|
|
||||||
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
|
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
@@ -45,32 +45,42 @@ const struct cmd_entry cmd_swap_pane_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct cmd_find_state *source = cmdq_get_source(item);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct window *src_w, *dst_w;
|
struct window *src_w, *dst_w;
|
||||||
struct window_pane *tmp_wp, *src_wp, *dst_wp;
|
struct window_pane *tmp_wp, *src_wp, *dst_wp;
|
||||||
struct layout_cell *src_lc, *dst_lc;
|
struct layout_cell *src_lc, *dst_lc;
|
||||||
u_int sx, sy, xoff, yoff;
|
u_int sx, sy, xoff, yoff;
|
||||||
|
|
||||||
dst_w = item->target.wl->window;
|
dst_w = target->wl->window;
|
||||||
dst_wp = item->target.wp;
|
dst_wp = target->wp;
|
||||||
src_w = item->source.wl->window;
|
src_w = source->wl->window;
|
||||||
src_wp = item->source.wp;
|
src_wp = source->wp;
|
||||||
server_unzoom_window(dst_w);
|
|
||||||
|
|
||||||
if (args_has(self->args, 'D')) {
|
if (window_push_zoom(dst_w, 0, args_has(args, 'Z')))
|
||||||
|
server_redraw_window(dst_w);
|
||||||
|
|
||||||
|
if (args_has(args, 'D')) {
|
||||||
src_w = dst_w;
|
src_w = dst_w;
|
||||||
src_wp = TAILQ_NEXT(dst_wp, entry);
|
src_wp = TAILQ_NEXT(dst_wp, entry);
|
||||||
if (src_wp == NULL)
|
if (src_wp == NULL)
|
||||||
src_wp = TAILQ_FIRST(&dst_w->panes);
|
src_wp = TAILQ_FIRST(&dst_w->panes);
|
||||||
} else if (args_has(self->args, 'U')) {
|
} else if (args_has(args, 'U')) {
|
||||||
src_w = dst_w;
|
src_w = dst_w;
|
||||||
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||||
if (src_wp == NULL)
|
if (src_wp == NULL)
|
||||||
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
||||||
}
|
}
|
||||||
server_unzoom_window(src_w);
|
|
||||||
|
if (src_w != dst_w && window_push_zoom(src_w, 0, args_has(args, 'Z')))
|
||||||
|
server_redraw_window(src_w);
|
||||||
|
|
||||||
if (src_wp == dst_wp)
|
if (src_wp == dst_wp)
|
||||||
return (CMD_RETURN_NORMAL);
|
goto out;
|
||||||
|
|
||||||
|
server_client_remove_pane(src_wp);
|
||||||
|
server_client_remove_pane(dst_wp);
|
||||||
|
|
||||||
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);
|
||||||
@@ -90,7 +100,11 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
src_wp->layout_cell = dst_lc;
|
src_wp->layout_cell = dst_lc;
|
||||||
|
|
||||||
src_wp->window = dst_w;
|
src_wp->window = dst_w;
|
||||||
|
options_set_parent(src_wp->options, dst_w->options);
|
||||||
|
src_wp->flags |= PANE_STYLECHANGED;
|
||||||
dst_wp->window = src_w;
|
dst_wp->window = src_w;
|
||||||
|
options_set_parent(dst_wp->options, src_w->options);
|
||||||
|
dst_wp->flags |= PANE_STYLECHANGED;
|
||||||
|
|
||||||
sx = src_wp->sx; sy = src_wp->sy;
|
sx = src_wp->sx; sy = src_wp->sy;
|
||||||
xoff = src_wp->xoff; yoff = src_wp->yoff;
|
xoff = src_wp->xoff; yoff = src_wp->yoff;
|
||||||
@@ -99,30 +113,36 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
dst_wp->xoff = xoff; dst_wp->yoff = yoff;
|
dst_wp->xoff = xoff; dst_wp->yoff = yoff;
|
||||||
window_pane_resize(dst_wp, sx, sy);
|
window_pane_resize(dst_wp, sx, sy);
|
||||||
|
|
||||||
if (!args_has(self->args, 'd')) {
|
if (!args_has(args, 'd')) {
|
||||||
if (src_w != dst_w) {
|
if (src_w != dst_w) {
|
||||||
window_set_active_pane(src_w, dst_wp);
|
window_set_active_pane(src_w, dst_wp, 1);
|
||||||
window_set_active_pane(dst_w, src_wp);
|
window_set_active_pane(dst_w, src_wp, 1);
|
||||||
} else {
|
} else {
|
||||||
tmp_wp = dst_wp;
|
tmp_wp = dst_wp;
|
||||||
if (!window_pane_visible(tmp_wp))
|
window_set_active_pane(src_w, tmp_wp, 1);
|
||||||
tmp_wp = src_wp;
|
|
||||||
window_set_active_pane(src_w, tmp_wp);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (src_w->active == src_wp)
|
if (src_w->active == src_wp)
|
||||||
window_set_active_pane(src_w, dst_wp);
|
window_set_active_pane(src_w, dst_wp, 1);
|
||||||
if (dst_w->active == dst_wp)
|
if (dst_w->active == dst_wp)
|
||||||
window_set_active_pane(dst_w, src_wp);
|
window_set_active_pane(dst_w, src_wp, 1);
|
||||||
}
|
}
|
||||||
if (src_w != dst_w) {
|
if (src_w != dst_w) {
|
||||||
if (src_w->last == src_wp)
|
window_pane_stack_remove(&src_w->last_panes, src_wp);
|
||||||
src_w->last = NULL;
|
window_pane_stack_remove(&dst_w->last_panes, dst_wp);
|
||||||
if (dst_w->last == dst_wp)
|
colour_palette_from_option(&src_wp->palette, src_wp->options);
|
||||||
dst_w->last = NULL;
|
colour_palette_from_option(&dst_wp->palette, dst_wp->options);
|
||||||
}
|
}
|
||||||
server_redraw_window(src_w);
|
server_redraw_window(src_w);
|
||||||
server_redraw_window(dst_w);
|
server_redraw_window(dst_w);
|
||||||
|
notify_window("window-layout-changed", src_w);
|
||||||
|
if (src_w != dst_w)
|
||||||
|
notify_window("window-layout-changed", dst_w);
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (window_pop_zoom(src_w))
|
||||||
|
server_redraw_window(src_w);
|
||||||
|
if (src_w != dst_w && window_pop_zoom(dst_w))
|
||||||
|
server_redraw_window(dst_w);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const struct cmd_entry cmd_swap_window_entry = {
|
|||||||
.name = "swap-window",
|
.name = "swap-window",
|
||||||
.alias = "swapw",
|
.alias = "swapw",
|
||||||
|
|
||||||
.args = { "ds:t:", 0, 0 },
|
.args = { "ds:t:", 0, 0, NULL },
|
||||||
.usage = "[-d] " CMD_SRCDST_WINDOW_USAGE,
|
.usage = "[-d] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
|
|
||||||
.source = { 's', CMD_FIND_WINDOW, CMD_FIND_DEFAULT_MARKED },
|
.source = { 's', CMD_FIND_WINDOW, CMD_FIND_DEFAULT_MARKED },
|
||||||
@@ -45,20 +45,20 @@ const struct cmd_entry cmd_swap_window_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_swap_window_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_swap_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct session *src, *dst;
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct cmd_find_state *source = cmdq_get_source(item);
|
||||||
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct session *src = source->s, *dst = target->s;
|
||||||
struct session_group *sg_src, *sg_dst;
|
struct session_group *sg_src, *sg_dst;
|
||||||
struct winlink *wl_src, *wl_dst;
|
struct winlink *wl_src = source->wl, *wl_dst = target->wl;
|
||||||
struct window *w_src, *w_dst;
|
struct window *w_src, *w_dst;
|
||||||
|
|
||||||
wl_src = item->source.wl;
|
|
||||||
src = item->source.s;
|
|
||||||
sg_src = session_group_contains(src);
|
sg_src = session_group_contains(src);
|
||||||
|
|
||||||
wl_dst = item->target.wl;
|
|
||||||
dst = item->target.s;
|
|
||||||
sg_dst = session_group_contains(dst);
|
sg_dst = session_group_contains(dst);
|
||||||
|
|
||||||
if (src != dst && sg_src != NULL && sg_dst != NULL &&
|
if (src != dst &&
|
||||||
|
sg_src != NULL &&
|
||||||
|
sg_dst != NULL &&
|
||||||
sg_src == sg_dst) {
|
sg_src == sg_dst) {
|
||||||
cmdq_error(item, "can't move window, sessions are grouped");
|
cmdq_error(item, "can't move window, sessions are grouped");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
@@ -77,7 +77,7 @@ cmd_swap_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
wl_src->window = w_dst;
|
wl_src->window = w_dst;
|
||||||
TAILQ_INSERT_TAIL(&w_dst->winlinks, wl_src, wentry);
|
TAILQ_INSERT_TAIL(&w_dst->winlinks, wl_src, wentry);
|
||||||
|
|
||||||
if (!args_has(self->args, 'd')) {
|
if (args_has(args, 'd')) {
|
||||||
session_select(dst, wl_dst->idx);
|
session_select(dst, wl_dst->idx);
|
||||||
if (src != dst)
|
if (src != dst)
|
||||||
session_select(src, wl_src->idx);
|
session_select(src, wl_src->idx);
|
||||||
|
|||||||
@@ -34,48 +34,52 @@ const struct cmd_entry cmd_switch_client_entry = {
|
|||||||
.name = "switch-client",
|
.name = "switch-client",
|
||||||
.alias = "switchc",
|
.alias = "switchc",
|
||||||
|
|
||||||
.args = { "lc:Enpt:rT:", 0, 0 },
|
.args = { "lc:EFnpt:rT:Z", 0, 0, NULL },
|
||||||
.usage = "[-Elnpr] [-c target-client] [-t target-session] "
|
.usage = "[-ElnprZ] [-c target-client] [-t target-session] "
|
||||||
"[-T key-table]",
|
"[-T key-table]",
|
||||||
|
|
||||||
/* -t is special */
|
/* -t is special */
|
||||||
|
|
||||||
.flags = CMD_READONLY,
|
.flags = CMD_READONLY|CMD_CLIENT_CFLAG,
|
||||||
.exec = cmd_switch_client_exec
|
.exec = cmd_switch_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct cmd_find_state *current = cmdq_get_current(item);
|
||||||
|
struct cmd_find_state target;
|
||||||
const char *tflag = args_get(args, 't');
|
const char *tflag = args_get(args, 't');
|
||||||
enum cmd_find_type type;
|
enum cmd_find_type type;
|
||||||
int flags;
|
int flags;
|
||||||
struct client *c;
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
struct window *w;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
const char *tablename;
|
const char *tablename;
|
||||||
struct key_table *table;
|
struct key_table *table;
|
||||||
|
|
||||||
if ((c = cmd_find_client(item, args_get(args, 'c'), 0)) == NULL)
|
if (tflag != NULL && tflag[strcspn(tflag, ":.%")] != '\0') {
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (tflag != NULL && tflag[strcspn(tflag, ":.")] != '\0') {
|
|
||||||
type = CMD_FIND_PANE;
|
type = CMD_FIND_PANE;
|
||||||
flags = 0;
|
flags = 0;
|
||||||
} else {
|
} else {
|
||||||
type = CMD_FIND_SESSION;
|
type = CMD_FIND_SESSION;
|
||||||
flags = CMD_FIND_PREFER_UNATTACHED;
|
flags = CMD_FIND_PREFER_UNATTACHED;
|
||||||
}
|
}
|
||||||
if (cmd_find_target(&item->target, item, tflag, type, flags) != 0)
|
if (cmd_find_target(&target, item, tflag, type, flags) != 0)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
s = item->target.s;
|
s = target.s;
|
||||||
wl = item->target.wl;
|
wl = target.wl;
|
||||||
wp = item->target.wp;
|
wp = target.wp;
|
||||||
|
|
||||||
if (args_has(args, 'r'))
|
if (args_has(args, 'r')) {
|
||||||
c->flags ^= CLIENT_READONLY;
|
if (tc->flags & CLIENT_READONLY)
|
||||||
|
tc->flags &= ~(CLIENT_READONLY|CLIENT_IGNORESIZE);
|
||||||
|
else
|
||||||
|
tc->flags |= (CLIENT_READONLY|CLIENT_IGNORESIZE);
|
||||||
|
}
|
||||||
|
|
||||||
tablename = args_get(args, 'T');
|
tablename = args_get(args, 'T');
|
||||||
if (tablename != NULL) {
|
if (tablename != NULL) {
|
||||||
@@ -85,24 +89,24 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
table->references++;
|
table->references++;
|
||||||
key_bindings_unref_table(c->keytable);
|
key_bindings_unref_table(tc->keytable);
|
||||||
c->keytable = table;
|
tc->keytable = table;
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 'n')) {
|
if (args_has(args, 'n')) {
|
||||||
if ((s = session_next_session(c->session)) == NULL) {
|
if ((s = session_next_session(tc->session)) == NULL) {
|
||||||
cmdq_error(item, "can't find next session");
|
cmdq_error(item, "can't find next session");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'p')) {
|
} else if (args_has(args, 'p')) {
|
||||||
if ((s = session_previous_session(c->session)) == NULL) {
|
if ((s = session_previous_session(tc->session)) == NULL) {
|
||||||
cmdq_error(item, "can't find previous session");
|
cmdq_error(item, "can't find previous session");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'l')) {
|
} else if (args_has(args, 'l')) {
|
||||||
if (c->last_session != NULL && session_alive(c->last_session))
|
if (tc->last_session != NULL && session_alive(tc->last_session))
|
||||||
s = c->last_session;
|
s = tc->last_session;
|
||||||
else
|
else
|
||||||
s = NULL;
|
s = NULL;
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
@@ -110,34 +114,29 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (item->client == NULL)
|
if (cmdq_get_client(item) == NULL)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
if (wl != NULL && wp != NULL && wp != wl->window->active) {
|
||||||
|
w = wl->window;
|
||||||
|
if (window_push_zoom(w, 0, args_has(args, 'Z')))
|
||||||
|
server_redraw_window(w);
|
||||||
|
window_redraw_active_switch(w, wp);
|
||||||
|
window_set_active_pane(w, wp, 1);
|
||||||
|
if (window_pop_zoom(w))
|
||||||
|
server_redraw_window(w);
|
||||||
|
}
|
||||||
if (wl != NULL) {
|
if (wl != NULL) {
|
||||||
if (wp != NULL)
|
|
||||||
window_set_active_pane(wp->window, wp);
|
|
||||||
session_set_current(s, wl);
|
session_set_current(s, wl);
|
||||||
cmd_find_from_session(&item->shared->current, s);
|
cmd_find_from_session(current, s, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args_has(args, 'E'))
|
if (!args_has(args, 'E'))
|
||||||
environ_update(s->options, c->environ, s->environ);
|
environ_update(s->options, tc->environ, s->environ);
|
||||||
|
|
||||||
if (c->session != NULL && c->session != s)
|
server_client_set_session(tc, s);
|
||||||
c->last_session = c->session;
|
if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT)
|
||||||
c->session = s;
|
server_client_set_key_table(tc, NULL);
|
||||||
if (~item->shared->flags & CMDQ_SHARED_REPEAT)
|
|
||||||
server_client_set_key_table(c, NULL);
|
|
||||||
status_timer_start(c);
|
|
||||||
notify_client("client-session-changed", c);
|
|
||||||
session_update_activity(s, NULL);
|
|
||||||
gettimeofday(&s->last_attached_time, NULL);
|
|
||||||
|
|
||||||
recalculate_sizes();
|
|
||||||
server_check_unattached();
|
|
||||||
server_redraw_client(c);
|
|
||||||
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
|
||||||
alerts_check_session(s);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ const struct cmd_entry cmd_unbind_key_entry = {
|
|||||||
.name = "unbind-key",
|
.name = "unbind-key",
|
||||||
.alias = "unbind",
|
.alias = "unbind",
|
||||||
|
|
||||||
.args = { "anT:", 0, 1 },
|
.args = { "anqT:", 0, 1, NULL },
|
||||||
.usage = "[-an] [-T key-table] key",
|
.usage = "[-anq] [-T key-table] key",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_unbind_key_exec
|
.exec = cmd_unbind_key_exec
|
||||||
@@ -42,47 +42,57 @@ const struct cmd_entry cmd_unbind_key_entry = {
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
key_code key;
|
key_code key;
|
||||||
const char *tablename;
|
const char *tablename, *keystr = args_string(args, 0);
|
||||||
|
int quiet = args_has(args, 'q');
|
||||||
|
|
||||||
if (!args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
if (args->argc != 1) {
|
if (keystr != NULL) {
|
||||||
cmdq_error(item, "missing key");
|
if (!quiet)
|
||||||
|
cmdq_error(item, "key given with -a");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
key = key_string_lookup_string(args->argv[0]);
|
|
||||||
if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
|
|
||||||
cmdq_error(item, "unknown key: %s", args->argv[0]);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (args->argc != 0) {
|
|
||||||
cmdq_error(item, "key given with -a");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
key = KEYC_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key == KEYC_UNKNOWN) {
|
|
||||||
tablename = args_get(args, 'T');
|
tablename = args_get(args, 'T');
|
||||||
if (tablename == NULL) {
|
if (tablename == NULL) {
|
||||||
key_bindings_remove_table("root");
|
if (args_has(args, 'n'))
|
||||||
key_bindings_remove_table("prefix");
|
tablename = "root";
|
||||||
return (CMD_RETURN_NORMAL);
|
else
|
||||||
|
tablename = "prefix";
|
||||||
}
|
}
|
||||||
if (key_bindings_get_table(tablename, 0) == NULL) {
|
if (key_bindings_get_table(tablename, 0) == NULL) {
|
||||||
cmdq_error(item, "table %s doesn't exist", tablename);
|
if (!quiet) {
|
||||||
|
cmdq_error(item, "table %s doesn't exist" ,
|
||||||
|
tablename);
|
||||||
|
}
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
key_bindings_remove_table(tablename);
|
key_bindings_remove_table(tablename);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keystr == NULL) {
|
||||||
|
if (!quiet)
|
||||||
|
cmdq_error(item, "missing key");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
key = key_string_lookup_string(keystr);
|
||||||
|
if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
|
||||||
|
if (!quiet)
|
||||||
|
cmdq_error(item, "unknown key: %s", keystr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
if (args_has(args, 'T')) {
|
if (args_has(args, 'T')) {
|
||||||
tablename = args_get(args, 'T');
|
tablename = args_get(args, 'T');
|
||||||
if (key_bindings_get_table(tablename, 0) == NULL) {
|
if (key_bindings_get_table(tablename, 0) == NULL) {
|
||||||
cmdq_error(item, "table %s doesn't exist", tablename);
|
if (!quiet) {
|
||||||
|
cmdq_error(item, "table %s doesn't exist" ,
|
||||||
|
tablename);
|
||||||
|
}
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'n'))
|
} else if (args_has(args, 'n'))
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const struct cmd_entry cmd_wait_for_entry = {
|
|||||||
.name = "wait-for",
|
.name = "wait-for",
|
||||||
.alias = "wait",
|
.alias = "wait",
|
||||||
|
|
||||||
.args = { "LSU", 1, 1 },
|
.args = { "LSU", 1, 1, NULL },
|
||||||
.usage = "[-L|-S|-U] channel",
|
.usage = "[-L|-S|-U] channel",
|
||||||
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
@@ -120,12 +120,12 @@ cmd_wait_for_remove(struct wait_channel *wc)
|
|||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_wait_for_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_wait_for_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = cmd_get_args(self);
|
||||||
const char *name = args->argv[0];
|
const char *name = args_string(args, 0);
|
||||||
struct wait_channel *wc, wc0;
|
struct wait_channel *wc, find;
|
||||||
|
|
||||||
wc0.name = name;
|
find.name = name;
|
||||||
wc = RB_FIND(wait_channels, &wait_channels, &wc0);
|
wc = RB_FIND(wait_channels, &wait_channels, &find);
|
||||||
|
|
||||||
if (args_has(args, 'S'))
|
if (args_has(args, 'S'))
|
||||||
return (cmd_wait_for_signal(item, name, wc));
|
return (cmd_wait_for_signal(item, name, wc));
|
||||||
@@ -153,7 +153,7 @@ cmd_wait_for_signal(__unused struct cmdq_item *item, const char *name,
|
|||||||
log_debug("signal wait channel %s, with waiters", wc->name);
|
log_debug("signal wait channel %s, with waiters", wc->name);
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
|
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
|
||||||
wi->item->flags &= ~CMDQ_WAITING;
|
cmdq_continue(wi->item);
|
||||||
|
|
||||||
TAILQ_REMOVE(&wc->waiters, wi, entry);
|
TAILQ_REMOVE(&wc->waiters, wi, entry);
|
||||||
free(wi);
|
free(wi);
|
||||||
@@ -167,10 +167,10 @@ static enum cmd_retval
|
|||||||
cmd_wait_for_wait(struct cmdq_item *item, const char *name,
|
cmd_wait_for_wait(struct cmdq_item *item, const char *name,
|
||||||
struct wait_channel *wc)
|
struct wait_channel *wc)
|
||||||
{
|
{
|
||||||
struct client *c = item->client;
|
struct client *c = cmdq_get_client(item);
|
||||||
struct wait_item *wi;
|
struct wait_item *wi;
|
||||||
|
|
||||||
if (c == NULL || c->session != NULL) {
|
if (c == NULL) {
|
||||||
cmdq_error(item, "not able to wait");
|
cmdq_error(item, "not able to wait");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ cmd_wait_for_lock(struct cmdq_item *item, const char *name,
|
|||||||
{
|
{
|
||||||
struct wait_item *wi;
|
struct wait_item *wi;
|
||||||
|
|
||||||
if (item->client == NULL || item->client->session != NULL) {
|
if (cmdq_get_client(item) == NULL) {
|
||||||
cmdq_error(item, "not able to lock");
|
cmdq_error(item, "not able to lock");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ cmd_wait_for_unlock(struct cmdq_item *item, const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((wi = TAILQ_FIRST(&wc->lockers)) != NULL) {
|
if ((wi = TAILQ_FIRST(&wc->lockers)) != NULL) {
|
||||||
wi->item->flags &= ~CMDQ_WAITING;
|
cmdq_continue(wi->item);
|
||||||
TAILQ_REMOVE(&wc->lockers, wi, entry);
|
TAILQ_REMOVE(&wc->lockers, wi, entry);
|
||||||
free(wi);
|
free(wi);
|
||||||
} else {
|
} else {
|
||||||
@@ -248,13 +248,13 @@ cmd_wait_for_flush(void)
|
|||||||
|
|
||||||
RB_FOREACH_SAFE(wc, wait_channels, &wait_channels, wc1) {
|
RB_FOREACH_SAFE(wc, wait_channels, &wait_channels, wc1) {
|
||||||
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
|
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
|
||||||
wi->item->flags &= ~CMDQ_WAITING;
|
cmdq_continue(wi->item);
|
||||||
TAILQ_REMOVE(&wc->waiters, wi, entry);
|
TAILQ_REMOVE(&wc->waiters, wi, entry);
|
||||||
free(wi);
|
free(wi);
|
||||||
}
|
}
|
||||||
wc->woken = 1;
|
wc->woken = 1;
|
||||||
TAILQ_FOREACH_SAFE(wi, &wc->lockers, entry, wi1) {
|
TAILQ_FOREACH_SAFE(wi, &wc->lockers, entry, wi1) {
|
||||||
wi->item->flags &= ~CMDQ_WAITING;
|
cmdq_continue(wi->item);
|
||||||
TAILQ_REMOVE(&wc->lockers, wi, entry);
|
TAILQ_REMOVE(&wc->lockers, wi, entry);
|
||||||
free(wi);
|
free(wi);
|
||||||
}
|
}
|
||||||
|
|||||||
573
cmd.c
573
cmd.c
@@ -33,19 +33,20 @@ extern const struct cmd_entry cmd_break_pane_entry;
|
|||||||
extern const struct cmd_entry cmd_capture_pane_entry;
|
extern const struct cmd_entry cmd_capture_pane_entry;
|
||||||
extern const struct cmd_entry cmd_choose_buffer_entry;
|
extern const struct cmd_entry cmd_choose_buffer_entry;
|
||||||
extern const struct cmd_entry cmd_choose_client_entry;
|
extern const struct cmd_entry cmd_choose_client_entry;
|
||||||
extern const struct cmd_entry cmd_choose_session_entry;
|
|
||||||
extern const struct cmd_entry cmd_choose_tree_entry;
|
extern const struct cmd_entry cmd_choose_tree_entry;
|
||||||
extern const struct cmd_entry cmd_choose_window_entry;
|
|
||||||
extern const struct cmd_entry cmd_clear_history_entry;
|
extern const struct cmd_entry cmd_clear_history_entry;
|
||||||
|
extern const struct cmd_entry cmd_clear_prompt_history_entry;
|
||||||
extern const struct cmd_entry cmd_clock_mode_entry;
|
extern const struct cmd_entry cmd_clock_mode_entry;
|
||||||
extern const struct cmd_entry cmd_command_prompt_entry;
|
extern const struct cmd_entry cmd_command_prompt_entry;
|
||||||
extern const struct cmd_entry cmd_confirm_before_entry;
|
extern const struct cmd_entry cmd_confirm_before_entry;
|
||||||
extern const struct cmd_entry cmd_copy_mode_entry;
|
extern const struct cmd_entry cmd_copy_mode_entry;
|
||||||
|
extern const struct cmd_entry cmd_customize_mode_entry;
|
||||||
extern const struct cmd_entry cmd_delete_buffer_entry;
|
extern const struct cmd_entry cmd_delete_buffer_entry;
|
||||||
extern const struct cmd_entry cmd_detach_client_entry;
|
extern const struct cmd_entry cmd_detach_client_entry;
|
||||||
|
extern const struct cmd_entry cmd_display_menu_entry;
|
||||||
extern const struct cmd_entry cmd_display_message_entry;
|
extern const struct cmd_entry cmd_display_message_entry;
|
||||||
|
extern const struct cmd_entry cmd_display_popup_entry;
|
||||||
extern const struct cmd_entry cmd_display_panes_entry;
|
extern const struct cmd_entry cmd_display_panes_entry;
|
||||||
extern const struct cmd_entry cmd_down_pane_entry;
|
|
||||||
extern const struct cmd_entry cmd_find_window_entry;
|
extern const struct cmd_entry cmd_find_window_entry;
|
||||||
extern const struct cmd_entry cmd_has_session_entry;
|
extern const struct cmd_entry cmd_has_session_entry;
|
||||||
extern const struct cmd_entry cmd_if_shell_entry;
|
extern const struct cmd_entry cmd_if_shell_entry;
|
||||||
@@ -82,6 +83,7 @@ extern const struct cmd_entry cmd_refresh_client_entry;
|
|||||||
extern const struct cmd_entry cmd_rename_session_entry;
|
extern const struct cmd_entry cmd_rename_session_entry;
|
||||||
extern const struct cmd_entry cmd_rename_window_entry;
|
extern const struct cmd_entry cmd_rename_window_entry;
|
||||||
extern const struct cmd_entry cmd_resize_pane_entry;
|
extern const struct cmd_entry cmd_resize_pane_entry;
|
||||||
|
extern const struct cmd_entry cmd_resize_window_entry;
|
||||||
extern const struct cmd_entry cmd_respawn_pane_entry;
|
extern const struct cmd_entry cmd_respawn_pane_entry;
|
||||||
extern const struct cmd_entry cmd_respawn_window_entry;
|
extern const struct cmd_entry cmd_respawn_window_entry;
|
||||||
extern const struct cmd_entry cmd_rotate_window_entry;
|
extern const struct cmd_entry cmd_rotate_window_entry;
|
||||||
@@ -92,6 +94,7 @@ extern const struct cmd_entry cmd_select_pane_entry;
|
|||||||
extern const struct cmd_entry cmd_select_window_entry;
|
extern const struct cmd_entry cmd_select_window_entry;
|
||||||
extern const struct cmd_entry cmd_send_keys_entry;
|
extern const struct cmd_entry cmd_send_keys_entry;
|
||||||
extern const struct cmd_entry cmd_send_prefix_entry;
|
extern const struct cmd_entry cmd_send_prefix_entry;
|
||||||
|
extern const struct cmd_entry cmd_server_access_entry;
|
||||||
extern const struct cmd_entry cmd_set_buffer_entry;
|
extern const struct cmd_entry cmd_set_buffer_entry;
|
||||||
extern const struct cmd_entry cmd_set_environment_entry;
|
extern const struct cmd_entry cmd_set_environment_entry;
|
||||||
extern const struct cmd_entry cmd_set_hook_entry;
|
extern const struct cmd_entry cmd_set_hook_entry;
|
||||||
@@ -102,6 +105,7 @@ extern const struct cmd_entry cmd_show_environment_entry;
|
|||||||
extern const struct cmd_entry cmd_show_hooks_entry;
|
extern const struct cmd_entry cmd_show_hooks_entry;
|
||||||
extern const struct cmd_entry cmd_show_messages_entry;
|
extern const struct cmd_entry cmd_show_messages_entry;
|
||||||
extern const struct cmd_entry cmd_show_options_entry;
|
extern const struct cmd_entry cmd_show_options_entry;
|
||||||
|
extern const struct cmd_entry cmd_show_prompt_history_entry;
|
||||||
extern const struct cmd_entry cmd_show_window_options_entry;
|
extern const struct cmd_entry cmd_show_window_options_entry;
|
||||||
extern const struct cmd_entry cmd_source_file_entry;
|
extern const struct cmd_entry cmd_source_file_entry;
|
||||||
extern const struct cmd_entry cmd_split_window_entry;
|
extern const struct cmd_entry cmd_split_window_entry;
|
||||||
@@ -112,7 +116,6 @@ extern const struct cmd_entry cmd_swap_window_entry;
|
|||||||
extern const struct cmd_entry cmd_switch_client_entry;
|
extern const struct cmd_entry cmd_switch_client_entry;
|
||||||
extern const struct cmd_entry cmd_unbind_key_entry;
|
extern const struct cmd_entry cmd_unbind_key_entry;
|
||||||
extern const struct cmd_entry cmd_unlink_window_entry;
|
extern const struct cmd_entry cmd_unlink_window_entry;
|
||||||
extern const struct cmd_entry cmd_up_pane_entry;
|
|
||||||
extern const struct cmd_entry cmd_wait_for_entry;
|
extern const struct cmd_entry cmd_wait_for_entry;
|
||||||
|
|
||||||
const struct cmd_entry *cmd_table[] = {
|
const struct cmd_entry *cmd_table[] = {
|
||||||
@@ -122,17 +125,19 @@ 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_session_entry,
|
|
||||||
&cmd_choose_tree_entry,
|
&cmd_choose_tree_entry,
|
||||||
&cmd_choose_window_entry,
|
|
||||||
&cmd_clear_history_entry,
|
&cmd_clear_history_entry,
|
||||||
|
&cmd_clear_prompt_history_entry,
|
||||||
&cmd_clock_mode_entry,
|
&cmd_clock_mode_entry,
|
||||||
&cmd_command_prompt_entry,
|
&cmd_command_prompt_entry,
|
||||||
&cmd_confirm_before_entry,
|
&cmd_confirm_before_entry,
|
||||||
&cmd_copy_mode_entry,
|
&cmd_copy_mode_entry,
|
||||||
|
&cmd_customize_mode_entry,
|
||||||
&cmd_delete_buffer_entry,
|
&cmd_delete_buffer_entry,
|
||||||
&cmd_detach_client_entry,
|
&cmd_detach_client_entry,
|
||||||
|
&cmd_display_menu_entry,
|
||||||
&cmd_display_message_entry,
|
&cmd_display_message_entry,
|
||||||
|
&cmd_display_popup_entry,
|
||||||
&cmd_display_panes_entry,
|
&cmd_display_panes_entry,
|
||||||
&cmd_find_window_entry,
|
&cmd_find_window_entry,
|
||||||
&cmd_has_session_entry,
|
&cmd_has_session_entry,
|
||||||
@@ -170,6 +175,7 @@ const struct cmd_entry *cmd_table[] = {
|
|||||||
&cmd_rename_session_entry,
|
&cmd_rename_session_entry,
|
||||||
&cmd_rename_window_entry,
|
&cmd_rename_window_entry,
|
||||||
&cmd_resize_pane_entry,
|
&cmd_resize_pane_entry,
|
||||||
|
&cmd_resize_window_entry,
|
||||||
&cmd_respawn_pane_entry,
|
&cmd_respawn_pane_entry,
|
||||||
&cmd_respawn_window_entry,
|
&cmd_respawn_window_entry,
|
||||||
&cmd_rotate_window_entry,
|
&cmd_rotate_window_entry,
|
||||||
@@ -180,6 +186,7 @@ const struct cmd_entry *cmd_table[] = {
|
|||||||
&cmd_select_window_entry,
|
&cmd_select_window_entry,
|
||||||
&cmd_send_keys_entry,
|
&cmd_send_keys_entry,
|
||||||
&cmd_send_prefix_entry,
|
&cmd_send_prefix_entry,
|
||||||
|
&cmd_server_access_entry,
|
||||||
&cmd_set_buffer_entry,
|
&cmd_set_buffer_entry,
|
||||||
&cmd_set_environment_entry,
|
&cmd_set_environment_entry,
|
||||||
&cmd_set_hook_entry,
|
&cmd_set_hook_entry,
|
||||||
@@ -190,6 +197,7 @@ const struct cmd_entry *cmd_table[] = {
|
|||||||
&cmd_show_hooks_entry,
|
&cmd_show_hooks_entry,
|
||||||
&cmd_show_messages_entry,
|
&cmd_show_messages_entry,
|
||||||
&cmd_show_options_entry,
|
&cmd_show_options_entry,
|
||||||
|
&cmd_show_prompt_history_entry,
|
||||||
&cmd_show_window_options_entry,
|
&cmd_show_window_options_entry,
|
||||||
&cmd_source_file_entry,
|
&cmd_source_file_entry,
|
||||||
&cmd_split_window_entry,
|
&cmd_split_window_entry,
|
||||||
@@ -204,6 +212,65 @@ const struct cmd_entry *cmd_table[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Instance of a command. */
|
||||||
|
struct cmd {
|
||||||
|
const struct cmd_entry *entry;
|
||||||
|
struct args *args;
|
||||||
|
u_int group;
|
||||||
|
|
||||||
|
char *file;
|
||||||
|
u_int line;
|
||||||
|
|
||||||
|
TAILQ_ENTRY(cmd) qentry;
|
||||||
|
};
|
||||||
|
TAILQ_HEAD(cmds, cmd);
|
||||||
|
|
||||||
|
/* Next group number for new command list. */
|
||||||
|
static u_int cmd_list_next_group = 1;
|
||||||
|
|
||||||
|
/* Log an argument vector. */
|
||||||
|
void printflike(3, 4)
|
||||||
|
cmd_log_argv(int argc, char **argv, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
char *prefix;
|
||||||
|
va_list ap;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
xvasprintf(&prefix, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
for (i = 0; i < argc; i++)
|
||||||
|
log_debug("%s: argv[%d]=%s", prefix, i, argv[i]);
|
||||||
|
free(prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prepend to an argument vector. */
|
||||||
|
void
|
||||||
|
cmd_prepend_argv(int *argc, char ***argv, const char *arg)
|
||||||
|
{
|
||||||
|
char **new_argv;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
new_argv = xreallocarray(NULL, (*argc) + 1, sizeof *new_argv);
|
||||||
|
new_argv[0] = xstrdup(arg);
|
||||||
|
for (i = 0; i < *argc; i++)
|
||||||
|
new_argv[1 + i] = (*argv)[i];
|
||||||
|
|
||||||
|
free(*argv);
|
||||||
|
*argv = new_argv;
|
||||||
|
(*argc)++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Append to an argument vector. */
|
||||||
|
void
|
||||||
|
cmd_append_argv(int *argc, char ***argv, const char *arg)
|
||||||
|
{
|
||||||
|
*argv = xreallocarray(*argv, (*argc) + 1, sizeof **argv);
|
||||||
|
(*argv)[(*argc)++] = xstrdup(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pack an argument vector up into a buffer. */
|
||||||
int
|
int
|
||||||
cmd_pack_argv(int argc, char **argv, char *buf, size_t len)
|
cmd_pack_argv(int argc, char **argv, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
@@ -212,6 +279,7 @@ cmd_pack_argv(int argc, char **argv, char *buf, size_t len)
|
|||||||
|
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
cmd_log_argv(argc, argv, "%s", __func__);
|
||||||
|
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
@@ -225,6 +293,7 @@ cmd_pack_argv(int argc, char **argv, char *buf, size_t len)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Unpack an argument vector from a packed buffer. */
|
||||||
int
|
int
|
||||||
cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv)
|
cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv)
|
||||||
{
|
{
|
||||||
@@ -244,13 +313,16 @@ cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv)
|
|||||||
|
|
||||||
arglen = strlen(buf) + 1;
|
arglen = strlen(buf) + 1;
|
||||||
(*argv)[i] = xstrdup(buf);
|
(*argv)[i] = xstrdup(buf);
|
||||||
|
|
||||||
buf += arglen;
|
buf += arglen;
|
||||||
len -= arglen;
|
len -= arglen;
|
||||||
}
|
}
|
||||||
|
cmd_log_argv(argc, *argv, "%s", __func__);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy an argument vector, ensuring it is terminated by NULL. */
|
||||||
char **
|
char **
|
||||||
cmd_copy_argv(int argc, char **argv)
|
cmd_copy_argv(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -267,6 +339,7 @@ cmd_copy_argv(int argc, char **argv)
|
|||||||
return (new_argv);
|
return (new_argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free an argument vector. */
|
||||||
void
|
void
|
||||||
cmd_free_argv(int argc, char **argv)
|
cmd_free_argv(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -279,140 +352,175 @@ cmd_free_argv(int argc, char **argv)
|
|||||||
free(argv);
|
free(argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Convert argument vector to a string. */
|
||||||
char *
|
char *
|
||||||
cmd_stringify_argv(int argc, char **argv)
|
cmd_stringify_argv(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf = NULL, *s;
|
||||||
|
size_t len = 0;
|
||||||
int i;
|
int i;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
return (xstrdup(""));
|
return (xstrdup(""));
|
||||||
|
|
||||||
len = 0;
|
|
||||||
buf = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
len += strlen(argv[i]) + 1;
|
s = args_escape(argv[i]);
|
||||||
|
log_debug("%s: %u %s = %s", __func__, i, argv[i], s);
|
||||||
|
|
||||||
|
len += strlen(s) + 1;
|
||||||
buf = xrealloc(buf, len);
|
buf = xrealloc(buf, len);
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
else
|
else
|
||||||
strlcat(buf, " ", len);
|
strlcat(buf, " ", len);
|
||||||
strlcat(buf, argv[i], len);
|
strlcat(buf, s, len);
|
||||||
|
|
||||||
|
free(s);
|
||||||
}
|
}
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
/* Get entry for command. */
|
||||||
cmd_try_alias(int *argc, char ***argv)
|
const struct cmd_entry *
|
||||||
|
cmd_get_entry(struct cmd *cmd)
|
||||||
{
|
{
|
||||||
struct options_entry *o;
|
return (cmd->entry);
|
||||||
int old_argc = *argc, new_argc;
|
|
||||||
char **old_argv = *argv, **new_argv;
|
|
||||||
u_int size, idx;
|
|
||||||
int i;
|
|
||||||
size_t wanted;
|
|
||||||
const char *s, *cp = NULL;
|
|
||||||
|
|
||||||
o = options_get_only(global_options, "command-alias");
|
|
||||||
if (o == NULL || options_array_size(o, &size) == -1 || size == 0)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
wanted = strlen(old_argv[0]);
|
|
||||||
for (idx = 0; idx < size; idx++) {
|
|
||||||
s = options_array_get(o, idx);
|
|
||||||
if (s == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
cp = strchr(s, '=');
|
|
||||||
if (cp == NULL || (size_t)(cp - s) != wanted)
|
|
||||||
continue;
|
|
||||||
if (strncmp(old_argv[0], s, wanted) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (idx == size)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (cmd_string_split(cp + 1, &new_argc, &new_argv) != 0)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
*argc = new_argc + old_argc - 1;
|
|
||||||
*argv = xcalloc((*argc) + 1, sizeof **argv);
|
|
||||||
|
|
||||||
for (i = 0; i < new_argc; i++)
|
|
||||||
(*argv)[i] = xstrdup(new_argv[i]);
|
|
||||||
for (i = 1; i < old_argc; i++)
|
|
||||||
(*argv)[new_argc + i - 1] = xstrdup(old_argv[i]);
|
|
||||||
|
|
||||||
log_debug("alias: %s=%s", old_argv[0], cp + 1);
|
|
||||||
for (i = 0; i < *argc; i++)
|
|
||||||
log_debug("alias: argv[%d] = %s", i, (*argv)[i]);
|
|
||||||
|
|
||||||
cmd_free_argv(new_argc, new_argv);
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd *
|
/* Get arguments for command. */
|
||||||
cmd_parse(int argc, char **argv, const char *file, u_int line, char **cause)
|
struct args *
|
||||||
|
cmd_get_args(struct cmd *cmd)
|
||||||
{
|
{
|
||||||
const char *name;
|
return (cmd->args);
|
||||||
const struct cmd_entry **entryp, *entry;
|
}
|
||||||
struct cmd *cmd;
|
|
||||||
struct args *args;
|
|
||||||
char s[BUFSIZ];
|
|
||||||
int ambiguous, allocated = 0;
|
|
||||||
|
|
||||||
*cause = NULL;
|
/* Get group for command. */
|
||||||
if (argc == 0) {
|
u_int
|
||||||
xasprintf(cause, "no command");
|
cmd_get_group(struct cmd *cmd)
|
||||||
|
{
|
||||||
|
return (cmd->group);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get file and line for command. */
|
||||||
|
void
|
||||||
|
cmd_get_source(struct cmd *cmd, const char **file, u_int *line)
|
||||||
|
{
|
||||||
|
if (file != NULL)
|
||||||
|
*file = cmd->file;
|
||||||
|
if (line != NULL)
|
||||||
|
*line = cmd->line;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Look for an alias for a command. */
|
||||||
|
char *
|
||||||
|
cmd_get_alias(const char *name)
|
||||||
|
{
|
||||||
|
struct options_entry *o;
|
||||||
|
struct options_array_item *a;
|
||||||
|
union options_value *ov;
|
||||||
|
size_t wanted, n;
|
||||||
|
const char *equals;
|
||||||
|
|
||||||
|
o = options_get_only(global_options, "command-alias");
|
||||||
|
if (o == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
wanted = strlen(name);
|
||||||
name = argv[0];
|
|
||||||
|
a = options_array_first(o);
|
||||||
|
while (a != NULL) {
|
||||||
|
ov = options_array_item_value(a);
|
||||||
|
|
||||||
|
equals = strchr(ov->string, '=');
|
||||||
|
if (equals != NULL) {
|
||||||
|
n = equals - ov->string;
|
||||||
|
if (n == wanted && strncmp(name, ov->string, n) == 0)
|
||||||
|
return (xstrdup(equals + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
a = options_array_next(a);
|
||||||
|
}
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Look up a command entry by name. */
|
||||||
|
static const struct cmd_entry *
|
||||||
|
cmd_find(const char *name, char **cause)
|
||||||
|
{
|
||||||
|
const struct cmd_entry **loop, *entry, *found = NULL;
|
||||||
|
int ambiguous;
|
||||||
|
char s[8192];
|
||||||
|
|
||||||
retry:
|
|
||||||
ambiguous = 0;
|
ambiguous = 0;
|
||||||
entry = NULL;
|
for (loop = cmd_table; *loop != NULL; loop++) {
|
||||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
entry = *loop;
|
||||||
if ((*entryp)->alias != NULL &&
|
if (entry->alias != NULL && strcmp(entry->alias, name) == 0) {
|
||||||
strcmp((*entryp)->alias, argv[0]) == 0) {
|
|
||||||
ambiguous = 0;
|
ambiguous = 0;
|
||||||
entry = *entryp;
|
found = entry;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp((*entryp)->name, argv[0], strlen(argv[0])) != 0)
|
if (strncmp(entry->name, name, strlen(name)) != 0)
|
||||||
continue;
|
continue;
|
||||||
if (entry != NULL)
|
if (found != NULL)
|
||||||
ambiguous = 1;
|
ambiguous = 1;
|
||||||
entry = *entryp;
|
found = entry;
|
||||||
|
|
||||||
/* Bail now if an exact match. */
|
if (strcmp(entry->name, name) == 0)
|
||||||
if (strcmp(entry->name, argv[0]) == 0)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((ambiguous || entry == NULL) &&
|
|
||||||
server_proc != NULL &&
|
|
||||||
!allocated &&
|
|
||||||
cmd_try_alias(&argc, &argv) == 0) {
|
|
||||||
allocated = 1;
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
if (ambiguous)
|
if (ambiguous)
|
||||||
goto ambiguous;
|
goto ambiguous;
|
||||||
if (entry == NULL) {
|
if (found == NULL) {
|
||||||
xasprintf(cause, "unknown command: %s", name);
|
xasprintf(cause, "unknown command: %s", name);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
return (found);
|
||||||
|
|
||||||
args = args_parse(entry->args.template, argc, argv);
|
ambiguous:
|
||||||
if (args == NULL)
|
*s = '\0';
|
||||||
goto usage;
|
for (loop = cmd_table; *loop != NULL; loop++) {
|
||||||
if (entry->args.lower != -1 && args->argc < entry->args.lower)
|
entry = *loop;
|
||||||
goto usage;
|
if (strncmp(entry->name, name, strlen(name)) != 0)
|
||||||
if (entry->args.upper != -1 && args->argc > entry->args.upper)
|
continue;
|
||||||
goto usage;
|
if (strlcat(s, entry->name, sizeof s) >= sizeof s)
|
||||||
|
break;
|
||||||
|
if (strlcat(s, ", ", sizeof s) >= sizeof s)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s[strlen(s) - 2] = '\0';
|
||||||
|
xasprintf(cause, "ambiguous command: %s, could be: %s", name, s);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse a single command from an argument vector. */
|
||||||
|
struct cmd *
|
||||||
|
cmd_parse(struct args_value *values, u_int count, const char *file, u_int line,
|
||||||
|
char **cause)
|
||||||
|
{
|
||||||
|
const struct cmd_entry *entry;
|
||||||
|
struct cmd *cmd;
|
||||||
|
struct args *args;
|
||||||
|
char *error = NULL;
|
||||||
|
|
||||||
|
if (count == 0 || values[0].type != ARGS_STRING) {
|
||||||
|
xasprintf(cause, "no command");
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
entry = cmd_find(values[0].string, cause);
|
||||||
|
if (entry == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
args = args_parse(&entry->args, values, count, &error);
|
||||||
|
if (args == NULL && error == NULL) {
|
||||||
|
xasprintf(cause, "usage: %s %s", entry->name, entry->usage);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
if (args == NULL) {
|
||||||
|
xasprintf(cause, "command %s: %s", entry->name, error);
|
||||||
|
free(error);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
cmd = xcalloc(1, sizeof *cmd);
|
cmd = xcalloc(1, sizeof *cmd);
|
||||||
cmd->entry = entry;
|
cmd->entry = entry;
|
||||||
@@ -422,31 +530,37 @@ retry:
|
|||||||
cmd->file = xstrdup(file);
|
cmd->file = xstrdup(file);
|
||||||
cmd->line = line;
|
cmd->line = line;
|
||||||
|
|
||||||
if (allocated)
|
|
||||||
cmd_free_argv(argc, argv);
|
|
||||||
return (cmd);
|
return (cmd);
|
||||||
|
|
||||||
ambiguous:
|
|
||||||
*s = '\0';
|
|
||||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
|
||||||
if (strncmp((*entryp)->name, argv[0], strlen(argv[0])) != 0)
|
|
||||||
continue;
|
|
||||||
if (strlcat(s, (*entryp)->name, sizeof s) >= sizeof s)
|
|
||||||
break;
|
|
||||||
if (strlcat(s, ", ", sizeof s) >= sizeof s)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
s[strlen(s) - 2] = '\0';
|
|
||||||
xasprintf(cause, "ambiguous command: %s, could be: %s", name, s);
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
if (args != NULL)
|
|
||||||
args_free(args);
|
|
||||||
xasprintf(cause, "usage: %s %s", entry->name, entry->usage);
|
|
||||||
return (NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free a command. */
|
||||||
|
void
|
||||||
|
cmd_free(struct cmd *cmd)
|
||||||
|
{
|
||||||
|
free(cmd->file);
|
||||||
|
|
||||||
|
args_free(cmd->args);
|
||||||
|
free(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy a command. */
|
||||||
|
struct cmd *
|
||||||
|
cmd_copy(struct cmd *cmd, int argc, char **argv)
|
||||||
|
{
|
||||||
|
struct cmd *new_cmd;
|
||||||
|
|
||||||
|
new_cmd = xcalloc(1, sizeof *new_cmd);
|
||||||
|
new_cmd->entry = cmd->entry;
|
||||||
|
new_cmd->args = args_copy(cmd->args, argc, argv);
|
||||||
|
|
||||||
|
if (cmd->file != NULL)
|
||||||
|
new_cmd->file = xstrdup(cmd->file);
|
||||||
|
new_cmd->line = cmd->line;
|
||||||
|
|
||||||
|
return (new_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get a command as a string. */
|
||||||
char *
|
char *
|
||||||
cmd_print(struct cmd *cmd)
|
cmd_print(struct cmd *cmd)
|
||||||
{
|
{
|
||||||
@@ -462,6 +576,175 @@ cmd_print(struct cmd *cmd)
|
|||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create a new command list. */
|
||||||
|
struct cmd_list *
|
||||||
|
cmd_list_new(void)
|
||||||
|
{
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
|
||||||
|
cmdlist = xcalloc(1, sizeof *cmdlist);
|
||||||
|
cmdlist->references = 1;
|
||||||
|
cmdlist->group = cmd_list_next_group++;
|
||||||
|
cmdlist->list = xcalloc(1, sizeof *cmdlist->list);
|
||||||
|
TAILQ_INIT(cmdlist->list);
|
||||||
|
return (cmdlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Append a command to a command list. */
|
||||||
|
void
|
||||||
|
cmd_list_append(struct cmd_list *cmdlist, struct cmd *cmd)
|
||||||
|
{
|
||||||
|
cmd->group = cmdlist->group;
|
||||||
|
TAILQ_INSERT_TAIL(cmdlist->list, cmd, qentry);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Append all commands from one list to another. */
|
||||||
|
void
|
||||||
|
cmd_list_append_all(struct cmd_list *cmdlist, struct cmd_list *from)
|
||||||
|
{
|
||||||
|
struct cmd *cmd;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cmd, from->list, qentry)
|
||||||
|
cmd->group = cmdlist->group;
|
||||||
|
TAILQ_CONCAT(cmdlist->list, from->list, qentry);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Move all commands from one command list to another. */
|
||||||
|
void
|
||||||
|
cmd_list_move(struct cmd_list *cmdlist, struct cmd_list *from)
|
||||||
|
{
|
||||||
|
TAILQ_CONCAT(cmdlist->list, from->list, qentry);
|
||||||
|
cmdlist->group = cmd_list_next_group++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free a command list. */
|
||||||
|
void
|
||||||
|
cmd_list_free(struct cmd_list *cmdlist)
|
||||||
|
{
|
||||||
|
struct cmd *cmd, *cmd1;
|
||||||
|
|
||||||
|
if (--cmdlist->references != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TAILQ_FOREACH_SAFE(cmd, cmdlist->list, qentry, cmd1) {
|
||||||
|
TAILQ_REMOVE(cmdlist->list, cmd, qentry);
|
||||||
|
cmd_free(cmd);
|
||||||
|
}
|
||||||
|
free(cmdlist->list);
|
||||||
|
free(cmdlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy a command list, expanding %s in arguments. */
|
||||||
|
struct cmd_list *
|
||||||
|
cmd_list_copy(struct cmd_list *cmdlist, int argc, char **argv)
|
||||||
|
{
|
||||||
|
struct cmd *cmd;
|
||||||
|
struct cmd_list *new_cmdlist;
|
||||||
|
struct cmd *new_cmd;
|
||||||
|
u_int group = cmdlist->group;
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
s = cmd_list_print(cmdlist, 0);
|
||||||
|
log_debug("%s: %s", __func__, s);
|
||||||
|
free(s);
|
||||||
|
|
||||||
|
new_cmdlist = cmd_list_new();
|
||||||
|
TAILQ_FOREACH(cmd, cmdlist->list, qentry) {
|
||||||
|
if (cmd->group != group) {
|
||||||
|
new_cmdlist->group = cmd_list_next_group++;
|
||||||
|
group = cmd->group;
|
||||||
|
}
|
||||||
|
new_cmd = cmd_copy(cmd, argc, argv);
|
||||||
|
cmd_list_append(new_cmdlist, new_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
s = cmd_list_print(new_cmdlist, 0);
|
||||||
|
log_debug("%s: %s", __func__, s);
|
||||||
|
free(s);
|
||||||
|
|
||||||
|
return (new_cmdlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get a command list as a string. */
|
||||||
|
char *
|
||||||
|
cmd_list_print(struct cmd_list *cmdlist, int escaped)
|
||||||
|
{
|
||||||
|
struct cmd *cmd, *next;
|
||||||
|
char *buf, *this;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
len = 1;
|
||||||
|
buf = xcalloc(1, len);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cmd, cmdlist->list, qentry) {
|
||||||
|
this = cmd_print(cmd);
|
||||||
|
|
||||||
|
len += strlen(this) + 6;
|
||||||
|
buf = xrealloc(buf, len);
|
||||||
|
|
||||||
|
strlcat(buf, this, len);
|
||||||
|
|
||||||
|
next = TAILQ_NEXT(cmd, qentry);
|
||||||
|
if (next != NULL) {
|
||||||
|
if (cmd->group != next->group) {
|
||||||
|
if (escaped)
|
||||||
|
strlcat(buf, " \\;\\; ", len);
|
||||||
|
else
|
||||||
|
strlcat(buf, " ;; ", len);
|
||||||
|
} else {
|
||||||
|
if (escaped)
|
||||||
|
strlcat(buf, " \\; ", len);
|
||||||
|
else
|
||||||
|
strlcat(buf, " ; ", len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get first command in list. */
|
||||||
|
struct cmd *
|
||||||
|
cmd_list_first(struct cmd_list *cmdlist)
|
||||||
|
{
|
||||||
|
return (TAILQ_FIRST(cmdlist->list));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get next command in list. */
|
||||||
|
struct cmd *
|
||||||
|
cmd_list_next(struct cmd *cmd)
|
||||||
|
{
|
||||||
|
return (TAILQ_NEXT(cmd, qentry));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do all of the commands in this command list have this flag? */
|
||||||
|
int
|
||||||
|
cmd_list_all_have(struct cmd_list *cmdlist, int flag)
|
||||||
|
{
|
||||||
|
struct cmd *cmd;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cmd, cmdlist->list, qentry) {
|
||||||
|
if (~cmd->entry->flags & flag)
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do any of the commands in this command list have this flag? */
|
||||||
|
int
|
||||||
|
cmd_list_any_have(struct cmd_list *cmdlist, int flag)
|
||||||
|
{
|
||||||
|
struct cmd *cmd;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cmd, cmdlist->list, qentry) {
|
||||||
|
if (cmd->entry->flags & flag)
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Adjust current mouse position for a pane. */
|
/* Adjust current mouse position for a pane. */
|
||||||
int
|
int
|
||||||
cmd_mouse_at(struct window_pane *wp, struct mouse_event *m, u_int *xp,
|
cmd_mouse_at(struct window_pane *wp, struct mouse_event *m, u_int *xp,
|
||||||
@@ -470,17 +753,16 @@ cmd_mouse_at(struct window_pane *wp, struct mouse_event *m, u_int *xp,
|
|||||||
u_int x, y;
|
u_int x, y;
|
||||||
|
|
||||||
if (last) {
|
if (last) {
|
||||||
x = m->lx;
|
x = m->lx + m->ox;
|
||||||
y = m->ly;
|
y = m->ly + m->oy;
|
||||||
} else {
|
} else {
|
||||||
x = m->x;
|
x = m->x + m->ox;
|
||||||
y = m->y;
|
y = m->y + m->oy;
|
||||||
}
|
}
|
||||||
|
log_debug("%s: x=%u, y=%u%s", __func__, x, y, last ? " (last)" : "");
|
||||||
|
|
||||||
if (m->statusat == 0 && y > 0)
|
if (m->statusat == 0 && y >= m->statuslines)
|
||||||
y--;
|
y -= m->statuslines;
|
||||||
else if (m->statusat > 0 && y >= (u_int)m->statusat)
|
|
||||||
y = m->statusat - 1;
|
|
||||||
|
|
||||||
if (x < wp->xoff || x >= wp->xoff + wp->sx)
|
if (x < wp->xoff || x >= wp->xoff + wp->sx)
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -500,17 +782,22 @@ cmd_mouse_window(struct mouse_event *m, struct session **sp)
|
|||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
|
struct winlink *wl;
|
||||||
|
|
||||||
if (!m->valid || m->s == -1 || m->w == -1)
|
if (!m->valid)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if ((s = session_find_by_id(m->s)) == NULL)
|
if (m->s == -1 || (s = session_find_by_id(m->s)) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if ((w = window_find_by_id(m->w)) == NULL)
|
if (m->w == -1)
|
||||||
return (NULL);
|
wl = s->curw;
|
||||||
|
else {
|
||||||
|
if ((w = window_find_by_id(m->w)) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
wl = winlink_find_by_window(&s->windows, w);
|
||||||
|
}
|
||||||
if (sp != NULL)
|
if (sp != NULL)
|
||||||
*sp = s;
|
*sp = s;
|
||||||
return (winlink_find_by_window(&s->windows, w));
|
return (wl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get current mouse pane if any. */
|
/* Get current mouse pane if any. */
|
||||||
@@ -523,10 +810,14 @@ cmd_mouse_pane(struct mouse_event *m, struct session **sp,
|
|||||||
|
|
||||||
if ((wl = cmd_mouse_window(m, sp)) == NULL)
|
if ((wl = cmd_mouse_window(m, sp)) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if ((wp = window_pane_find_by_id(m->wp)) == NULL)
|
if (m->wp == -1)
|
||||||
return (NULL);
|
wp = wl->window->active;
|
||||||
if (!window_has_pane(wl->window, wp))
|
else {
|
||||||
return (NULL);
|
if ((wp = window_pane_find_by_id(m->wp)) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
if (!window_has_pane(wl->window, wp))
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (wlp != NULL)
|
if (wlp != NULL)
|
||||||
*wlp = wl;
|
*wlp = wl;
|
||||||
@@ -538,7 +829,7 @@ char *
|
|||||||
cmd_template_replace(const char *template, const char *s, int idx)
|
cmd_template_replace(const char *template, const char *s, int idx)
|
||||||
{
|
{
|
||||||
char ch, *buf;
|
char ch, *buf;
|
||||||
const char *ptr, *cp, quote[] = "\"\\$";
|
const char *ptr, *cp, quote[] = "\"\\$;~";
|
||||||
int replaced, quoted;
|
int replaced, quoted;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
@@ -569,10 +860,6 @@ cmd_template_replace(const char *template, const char *s, int idx)
|
|||||||
for (cp = s; *cp != '\0'; cp++) {
|
for (cp = s; *cp != '\0'; cp++) {
|
||||||
if (quoted && strchr(quote, *cp) != NULL)
|
if (quoted && strchr(quote, *cp) != NULL)
|
||||||
buf[len++] = '\\';
|
buf[len++] = '\\';
|
||||||
if (quoted && *cp == ';') {
|
|
||||||
buf[len++] = '\\';
|
|
||||||
buf[len++] = '\\';
|
|
||||||
}
|
|
||||||
buf[len++] = *cp;
|
buf[len++] = *cp;
|
||||||
}
|
}
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|||||||
883
colour.c
883
colour.c
@@ -22,6 +22,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -104,6 +105,21 @@ colour_split_rgb(int c, u_char *r, u_char *g, u_char *b)
|
|||||||
*b = c & 0xff;
|
*b = c & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Force colour to RGB if not already. */
|
||||||
|
int
|
||||||
|
colour_force_rgb(int c)
|
||||||
|
{
|
||||||
|
if (c & COLOUR_FLAG_RGB)
|
||||||
|
return (c);
|
||||||
|
if (c & COLOUR_FLAG_256)
|
||||||
|
return (colour_256toRGB(c));
|
||||||
|
if (c >= 0 && c <= 7)
|
||||||
|
return (colour_256toRGB(c));
|
||||||
|
if (c >= 90 && c <= 97)
|
||||||
|
return (colour_256toRGB(8 + c - 90));
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Convert colour to a string. */
|
/* Convert colour to a string. */
|
||||||
const char *
|
const char *
|
||||||
colour_tostring(int c)
|
colour_tostring(int c)
|
||||||
@@ -111,6 +127,9 @@ colour_tostring(int c)
|
|||||||
static char s[32];
|
static char s[32];
|
||||||
u_char r, g, b;
|
u_char r, g, b;
|
||||||
|
|
||||||
|
if (c == -1)
|
||||||
|
return ("none");
|
||||||
|
|
||||||
if (c & COLOUR_FLAG_RGB) {
|
if (c & COLOUR_FLAG_RGB) {
|
||||||
colour_split_rgb(c, &r, &g, &b);
|
colour_split_rgb(c, &r, &g, &b);
|
||||||
xsnprintf(s, sizeof s, "#%02x%02x%02x", r, g, b);
|
xsnprintf(s, sizeof s, "#%02x%02x%02x", r, g, b);
|
||||||
@@ -141,6 +160,8 @@ colour_tostring(int c)
|
|||||||
return ("white");
|
return ("white");
|
||||||
case 8:
|
case 8:
|
||||||
return ("default");
|
return ("default");
|
||||||
|
case 9:
|
||||||
|
return ("terminal");
|
||||||
case 90:
|
case 90:
|
||||||
return ("brightblack");
|
return ("brightblack");
|
||||||
case 91:
|
case 91:
|
||||||
@@ -158,7 +179,7 @@ colour_tostring(int c)
|
|||||||
case 97:
|
case 97:
|
||||||
return ("brightwhite");
|
return ("brightwhite");
|
||||||
}
|
}
|
||||||
return (NULL);
|
return ("invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert colour from string. */
|
/* Convert colour from string. */
|
||||||
@@ -187,6 +208,17 @@ colour_fromstring(const char *s)
|
|||||||
return (-1);
|
return (-1);
|
||||||
return (n | COLOUR_FLAG_256);
|
return (n | COLOUR_FLAG_256);
|
||||||
}
|
}
|
||||||
|
if (strncasecmp(s, "color", (sizeof "color") - 1) == 0) {
|
||||||
|
n = strtonum(s + (sizeof "color") - 1, 0, 255, &errstr);
|
||||||
|
if (errstr != NULL)
|
||||||
|
return (-1);
|
||||||
|
return (n | COLOUR_FLAG_256);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcasecmp(s, "default") == 0)
|
||||||
|
return (8);
|
||||||
|
if (strcasecmp(s, "terminal") == 0)
|
||||||
|
return (9);
|
||||||
|
|
||||||
if (strcasecmp(s, "black") == 0 || strcmp(s, "0") == 0)
|
if (strcasecmp(s, "black") == 0 || strcmp(s, "0") == 0)
|
||||||
return (0);
|
return (0);
|
||||||
@@ -204,8 +236,6 @@ colour_fromstring(const char *s)
|
|||||||
return (6);
|
return (6);
|
||||||
if (strcasecmp(s, "white") == 0 || strcmp(s, "7") == 0)
|
if (strcasecmp(s, "white") == 0 || strcmp(s, "7") == 0)
|
||||||
return (7);
|
return (7);
|
||||||
if (strcasecmp(s, "default") == 0 || strcmp(s, "8") == 0)
|
|
||||||
return (8);
|
|
||||||
if (strcasecmp(s, "brightblack") == 0 || strcmp(s, "90") == 0)
|
if (strcasecmp(s, "brightblack") == 0 || strcmp(s, "90") == 0)
|
||||||
return (90);
|
return (90);
|
||||||
if (strcasecmp(s, "brightred") == 0 || strcmp(s, "91") == 0)
|
if (strcasecmp(s, "brightred") == 0 || strcmp(s, "91") == 0)
|
||||||
@@ -222,14 +252,88 @@ colour_fromstring(const char *s)
|
|||||||
return (96);
|
return (96);
|
||||||
if (strcasecmp(s, "brightwhite") == 0 || strcmp(s, "97") == 0)
|
if (strcasecmp(s, "brightwhite") == 0 || strcmp(s, "97") == 0)
|
||||||
return (97);
|
return (97);
|
||||||
return (-1);
|
return (colour_byname(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert 256 colour palette to 16. */
|
/* Convert 256 colour to RGB colour. */
|
||||||
u_char
|
int
|
||||||
colour_256to16(u_char c)
|
colour_256toRGB(int c)
|
||||||
{
|
{
|
||||||
static const u_char table[256] = {
|
static const int table[256] = {
|
||||||
|
0x000000, 0x800000, 0x008000, 0x808000,
|
||||||
|
0x000080, 0x800080, 0x008080, 0xc0c0c0,
|
||||||
|
0x808080, 0xff0000, 0x00ff00, 0xffff00,
|
||||||
|
0x0000ff, 0xff00ff, 0x00ffff, 0xffffff,
|
||||||
|
0x000000, 0x00005f, 0x000087, 0x0000af,
|
||||||
|
0x0000d7, 0x0000ff, 0x005f00, 0x005f5f,
|
||||||
|
0x005f87, 0x005faf, 0x005fd7, 0x005fff,
|
||||||
|
0x008700, 0x00875f, 0x008787, 0x0087af,
|
||||||
|
0x0087d7, 0x0087ff, 0x00af00, 0x00af5f,
|
||||||
|
0x00af87, 0x00afaf, 0x00afd7, 0x00afff,
|
||||||
|
0x00d700, 0x00d75f, 0x00d787, 0x00d7af,
|
||||||
|
0x00d7d7, 0x00d7ff, 0x00ff00, 0x00ff5f,
|
||||||
|
0x00ff87, 0x00ffaf, 0x00ffd7, 0x00ffff,
|
||||||
|
0x5f0000, 0x5f005f, 0x5f0087, 0x5f00af,
|
||||||
|
0x5f00d7, 0x5f00ff, 0x5f5f00, 0x5f5f5f,
|
||||||
|
0x5f5f87, 0x5f5faf, 0x5f5fd7, 0x5f5fff,
|
||||||
|
0x5f8700, 0x5f875f, 0x5f8787, 0x5f87af,
|
||||||
|
0x5f87d7, 0x5f87ff, 0x5faf00, 0x5faf5f,
|
||||||
|
0x5faf87, 0x5fafaf, 0x5fafd7, 0x5fafff,
|
||||||
|
0x5fd700, 0x5fd75f, 0x5fd787, 0x5fd7af,
|
||||||
|
0x5fd7d7, 0x5fd7ff, 0x5fff00, 0x5fff5f,
|
||||||
|
0x5fff87, 0x5fffaf, 0x5fffd7, 0x5fffff,
|
||||||
|
0x870000, 0x87005f, 0x870087, 0x8700af,
|
||||||
|
0x8700d7, 0x8700ff, 0x875f00, 0x875f5f,
|
||||||
|
0x875f87, 0x875faf, 0x875fd7, 0x875fff,
|
||||||
|
0x878700, 0x87875f, 0x878787, 0x8787af,
|
||||||
|
0x8787d7, 0x8787ff, 0x87af00, 0x87af5f,
|
||||||
|
0x87af87, 0x87afaf, 0x87afd7, 0x87afff,
|
||||||
|
0x87d700, 0x87d75f, 0x87d787, 0x87d7af,
|
||||||
|
0x87d7d7, 0x87d7ff, 0x87ff00, 0x87ff5f,
|
||||||
|
0x87ff87, 0x87ffaf, 0x87ffd7, 0x87ffff,
|
||||||
|
0xaf0000, 0xaf005f, 0xaf0087, 0xaf00af,
|
||||||
|
0xaf00d7, 0xaf00ff, 0xaf5f00, 0xaf5f5f,
|
||||||
|
0xaf5f87, 0xaf5faf, 0xaf5fd7, 0xaf5fff,
|
||||||
|
0xaf8700, 0xaf875f, 0xaf8787, 0xaf87af,
|
||||||
|
0xaf87d7, 0xaf87ff, 0xafaf00, 0xafaf5f,
|
||||||
|
0xafaf87, 0xafafaf, 0xafafd7, 0xafafff,
|
||||||
|
0xafd700, 0xafd75f, 0xafd787, 0xafd7af,
|
||||||
|
0xafd7d7, 0xafd7ff, 0xafff00, 0xafff5f,
|
||||||
|
0xafff87, 0xafffaf, 0xafffd7, 0xafffff,
|
||||||
|
0xd70000, 0xd7005f, 0xd70087, 0xd700af,
|
||||||
|
0xd700d7, 0xd700ff, 0xd75f00, 0xd75f5f,
|
||||||
|
0xd75f87, 0xd75faf, 0xd75fd7, 0xd75fff,
|
||||||
|
0xd78700, 0xd7875f, 0xd78787, 0xd787af,
|
||||||
|
0xd787d7, 0xd787ff, 0xd7af00, 0xd7af5f,
|
||||||
|
0xd7af87, 0xd7afaf, 0xd7afd7, 0xd7afff,
|
||||||
|
0xd7d700, 0xd7d75f, 0xd7d787, 0xd7d7af,
|
||||||
|
0xd7d7d7, 0xd7d7ff, 0xd7ff00, 0xd7ff5f,
|
||||||
|
0xd7ff87, 0xd7ffaf, 0xd7ffd7, 0xd7ffff,
|
||||||
|
0xff0000, 0xff005f, 0xff0087, 0xff00af,
|
||||||
|
0xff00d7, 0xff00ff, 0xff5f00, 0xff5f5f,
|
||||||
|
0xff5f87, 0xff5faf, 0xff5fd7, 0xff5fff,
|
||||||
|
0xff8700, 0xff875f, 0xff8787, 0xff87af,
|
||||||
|
0xff87d7, 0xff87ff, 0xffaf00, 0xffaf5f,
|
||||||
|
0xffaf87, 0xffafaf, 0xffafd7, 0xffafff,
|
||||||
|
0xffd700, 0xffd75f, 0xffd787, 0xffd7af,
|
||||||
|
0xffd7d7, 0xffd7ff, 0xffff00, 0xffff5f,
|
||||||
|
0xffff87, 0xffffaf, 0xffffd7, 0xffffff,
|
||||||
|
0x080808, 0x121212, 0x1c1c1c, 0x262626,
|
||||||
|
0x303030, 0x3a3a3a, 0x444444, 0x4e4e4e,
|
||||||
|
0x585858, 0x626262, 0x6c6c6c, 0x767676,
|
||||||
|
0x808080, 0x8a8a8a, 0x949494, 0x9e9e9e,
|
||||||
|
0xa8a8a8, 0xb2b2b2, 0xbcbcbc, 0xc6c6c6,
|
||||||
|
0xd0d0d0, 0xdadada, 0xe4e4e4, 0xeeeeee
|
||||||
|
};
|
||||||
|
|
||||||
|
return (table[c & 0xff] | COLOUR_FLAG_RGB);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert 256 colour to 16 colour. */
|
||||||
|
int
|
||||||
|
colour_256to16(int c)
|
||||||
|
{
|
||||||
|
static const char table[256] = {
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||||
0, 4, 4, 4, 12, 12, 2, 6, 4, 4, 12, 12, 2, 2, 6, 4,
|
0, 4, 4, 4, 12, 12, 2, 6, 4, 4, 12, 12, 2, 2, 6, 4,
|
||||||
12, 12, 2, 2, 2, 6, 12, 12, 10, 10, 10, 10, 14, 12, 10, 10,
|
12, 12, 2, 2, 2, 6, 12, 12, 10, 10, 10, 10, 14, 12, 10, 10,
|
||||||
@@ -248,5 +352,766 @@ colour_256to16(u_char c)
|
|||||||
8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 15, 15, 15, 15, 15, 15
|
8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 15, 15, 15, 15, 15, 15
|
||||||
};
|
};
|
||||||
|
|
||||||
return (table[c]);
|
return (table[c & 0xff]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get colour by X11 colour name. */
|
||||||
|
int
|
||||||
|
colour_byname(const char *name)
|
||||||
|
{
|
||||||
|
static const struct {
|
||||||
|
const char *name;
|
||||||
|
int c;
|
||||||
|
} colours[] = {
|
||||||
|
{ "AliceBlue", 0xf0f8ff },
|
||||||
|
{ "AntiqueWhite", 0xfaebd7 },
|
||||||
|
{ "AntiqueWhite1", 0xffefdb },
|
||||||
|
{ "AntiqueWhite2", 0xeedfcc },
|
||||||
|
{ "AntiqueWhite3", 0xcdc0b0 },
|
||||||
|
{ "AntiqueWhite4", 0x8b8378 },
|
||||||
|
{ "BlanchedAlmond", 0xffebcd },
|
||||||
|
{ "BlueViolet", 0x8a2be2 },
|
||||||
|
{ "CadetBlue", 0x5f9ea0 },
|
||||||
|
{ "CadetBlue1", 0x98f5ff },
|
||||||
|
{ "CadetBlue2", 0x8ee5ee },
|
||||||
|
{ "CadetBlue3", 0x7ac5cd },
|
||||||
|
{ "CadetBlue4", 0x53868b },
|
||||||
|
{ "CornflowerBlue", 0x6495ed },
|
||||||
|
{ "DarkBlue", 0x00008b },
|
||||||
|
{ "DarkCyan", 0x008b8b },
|
||||||
|
{ "DarkGoldenrod", 0xb8860b },
|
||||||
|
{ "DarkGoldenrod1", 0xffb90f },
|
||||||
|
{ "DarkGoldenrod2", 0xeead0e },
|
||||||
|
{ "DarkGoldenrod3", 0xcd950c },
|
||||||
|
{ "DarkGoldenrod4", 0x8b6508 },
|
||||||
|
{ "DarkGray", 0xa9a9a9 },
|
||||||
|
{ "DarkGreen", 0x006400 },
|
||||||
|
{ "DarkGrey", 0xa9a9a9 },
|
||||||
|
{ "DarkKhaki", 0xbdb76b },
|
||||||
|
{ "DarkMagenta", 0x8b008b },
|
||||||
|
{ "DarkOliveGreen", 0x556b2f },
|
||||||
|
{ "DarkOliveGreen1", 0xcaff70 },
|
||||||
|
{ "DarkOliveGreen2", 0xbcee68 },
|
||||||
|
{ "DarkOliveGreen3", 0xa2cd5a },
|
||||||
|
{ "DarkOliveGreen4", 0x6e8b3d },
|
||||||
|
{ "DarkOrange", 0xff8c00 },
|
||||||
|
{ "DarkOrange1", 0xff7f00 },
|
||||||
|
{ "DarkOrange2", 0xee7600 },
|
||||||
|
{ "DarkOrange3", 0xcd6600 },
|
||||||
|
{ "DarkOrange4", 0x8b4500 },
|
||||||
|
{ "DarkOrchid", 0x9932cc },
|
||||||
|
{ "DarkOrchid1", 0xbf3eff },
|
||||||
|
{ "DarkOrchid2", 0xb23aee },
|
||||||
|
{ "DarkOrchid3", 0x9a32cd },
|
||||||
|
{ "DarkOrchid4", 0x68228b },
|
||||||
|
{ "DarkRed", 0x8b0000 },
|
||||||
|
{ "DarkSalmon", 0xe9967a },
|
||||||
|
{ "DarkSeaGreen", 0x8fbc8f },
|
||||||
|
{ "DarkSeaGreen1", 0xc1ffc1 },
|
||||||
|
{ "DarkSeaGreen2", 0xb4eeb4 },
|
||||||
|
{ "DarkSeaGreen3", 0x9bcd9b },
|
||||||
|
{ "DarkSeaGreen4", 0x698b69 },
|
||||||
|
{ "DarkSlateBlue", 0x483d8b },
|
||||||
|
{ "DarkSlateGray", 0x2f4f4f },
|
||||||
|
{ "DarkSlateGray1", 0x97ffff },
|
||||||
|
{ "DarkSlateGray2", 0x8deeee },
|
||||||
|
{ "DarkSlateGray3", 0x79cdcd },
|
||||||
|
{ "DarkSlateGray4", 0x528b8b },
|
||||||
|
{ "DarkSlateGrey", 0x2f4f4f },
|
||||||
|
{ "DarkTurquoise", 0x00ced1 },
|
||||||
|
{ "DarkViolet", 0x9400d3 },
|
||||||
|
{ "DeepPink", 0xff1493 },
|
||||||
|
{ "DeepPink1", 0xff1493 },
|
||||||
|
{ "DeepPink2", 0xee1289 },
|
||||||
|
{ "DeepPink3", 0xcd1076 },
|
||||||
|
{ "DeepPink4", 0x8b0a50 },
|
||||||
|
{ "DeepSkyBlue", 0x00bfff },
|
||||||
|
{ "DeepSkyBlue1", 0x00bfff },
|
||||||
|
{ "DeepSkyBlue2", 0x00b2ee },
|
||||||
|
{ "DeepSkyBlue3", 0x009acd },
|
||||||
|
{ "DeepSkyBlue4", 0x00688b },
|
||||||
|
{ "DimGray", 0x696969 },
|
||||||
|
{ "DimGrey", 0x696969 },
|
||||||
|
{ "DodgerBlue", 0x1e90ff },
|
||||||
|
{ "DodgerBlue1", 0x1e90ff },
|
||||||
|
{ "DodgerBlue2", 0x1c86ee },
|
||||||
|
{ "DodgerBlue3", 0x1874cd },
|
||||||
|
{ "DodgerBlue4", 0x104e8b },
|
||||||
|
{ "FloralWhite", 0xfffaf0 },
|
||||||
|
{ "ForestGreen", 0x228b22 },
|
||||||
|
{ "GhostWhite", 0xf8f8ff },
|
||||||
|
{ "GreenYellow", 0xadff2f },
|
||||||
|
{ "HotPink", 0xff69b4 },
|
||||||
|
{ "HotPink1", 0xff6eb4 },
|
||||||
|
{ "HotPink2", 0xee6aa7 },
|
||||||
|
{ "HotPink3", 0xcd6090 },
|
||||||
|
{ "HotPink4", 0x8b3a62 },
|
||||||
|
{ "IndianRed", 0xcd5c5c },
|
||||||
|
{ "IndianRed1", 0xff6a6a },
|
||||||
|
{ "IndianRed2", 0xee6363 },
|
||||||
|
{ "IndianRed3", 0xcd5555 },
|
||||||
|
{ "IndianRed4", 0x8b3a3a },
|
||||||
|
{ "LavenderBlush", 0xfff0f5 },
|
||||||
|
{ "LavenderBlush1", 0xfff0f5 },
|
||||||
|
{ "LavenderBlush2", 0xeee0e5 },
|
||||||
|
{ "LavenderBlush3", 0xcdc1c5 },
|
||||||
|
{ "LavenderBlush4", 0x8b8386 },
|
||||||
|
{ "LawnGreen", 0x7cfc00 },
|
||||||
|
{ "LemonChiffon", 0xfffacd },
|
||||||
|
{ "LemonChiffon1", 0xfffacd },
|
||||||
|
{ "LemonChiffon2", 0xeee9bf },
|
||||||
|
{ "LemonChiffon3", 0xcdc9a5 },
|
||||||
|
{ "LemonChiffon4", 0x8b8970 },
|
||||||
|
{ "LightBlue", 0xadd8e6 },
|
||||||
|
{ "LightBlue1", 0xbfefff },
|
||||||
|
{ "LightBlue2", 0xb2dfee },
|
||||||
|
{ "LightBlue3", 0x9ac0cd },
|
||||||
|
{ "LightBlue4", 0x68838b },
|
||||||
|
{ "LightCoral", 0xf08080 },
|
||||||
|
{ "LightCyan", 0xe0ffff },
|
||||||
|
{ "LightCyan1", 0xe0ffff },
|
||||||
|
{ "LightCyan2", 0xd1eeee },
|
||||||
|
{ "LightCyan3", 0xb4cdcd },
|
||||||
|
{ "LightCyan4", 0x7a8b8b },
|
||||||
|
{ "LightGoldenrod", 0xeedd82 },
|
||||||
|
{ "LightGoldenrod1", 0xffec8b },
|
||||||
|
{ "LightGoldenrod2", 0xeedc82 },
|
||||||
|
{ "LightGoldenrod3", 0xcdbe70 },
|
||||||
|
{ "LightGoldenrod4", 0x8b814c },
|
||||||
|
{ "LightGoldenrodYellow", 0xfafad2 },
|
||||||
|
{ "LightGray", 0xd3d3d3 },
|
||||||
|
{ "LightGreen", 0x90ee90 },
|
||||||
|
{ "LightGrey", 0xd3d3d3 },
|
||||||
|
{ "LightPink", 0xffb6c1 },
|
||||||
|
{ "LightPink1", 0xffaeb9 },
|
||||||
|
{ "LightPink2", 0xeea2ad },
|
||||||
|
{ "LightPink3", 0xcd8c95 },
|
||||||
|
{ "LightPink4", 0x8b5f65 },
|
||||||
|
{ "LightSalmon", 0xffa07a },
|
||||||
|
{ "LightSalmon1", 0xffa07a },
|
||||||
|
{ "LightSalmon2", 0xee9572 },
|
||||||
|
{ "LightSalmon3", 0xcd8162 },
|
||||||
|
{ "LightSalmon4", 0x8b5742 },
|
||||||
|
{ "LightSeaGreen", 0x20b2aa },
|
||||||
|
{ "LightSkyBlue", 0x87cefa },
|
||||||
|
{ "LightSkyBlue1", 0xb0e2ff },
|
||||||
|
{ "LightSkyBlue2", 0xa4d3ee },
|
||||||
|
{ "LightSkyBlue3", 0x8db6cd },
|
||||||
|
{ "LightSkyBlue4", 0x607b8b },
|
||||||
|
{ "LightSlateBlue", 0x8470ff },
|
||||||
|
{ "LightSlateGray", 0x778899 },
|
||||||
|
{ "LightSlateGrey", 0x778899 },
|
||||||
|
{ "LightSteelBlue", 0xb0c4de },
|
||||||
|
{ "LightSteelBlue1", 0xcae1ff },
|
||||||
|
{ "LightSteelBlue2", 0xbcd2ee },
|
||||||
|
{ "LightSteelBlue3", 0xa2b5cd },
|
||||||
|
{ "LightSteelBlue4", 0x6e7b8b },
|
||||||
|
{ "LightYellow", 0xffffe0 },
|
||||||
|
{ "LightYellow1", 0xffffe0 },
|
||||||
|
{ "LightYellow2", 0xeeeed1 },
|
||||||
|
{ "LightYellow3", 0xcdcdb4 },
|
||||||
|
{ "LightYellow4", 0x8b8b7a },
|
||||||
|
{ "LimeGreen", 0x32cd32 },
|
||||||
|
{ "MediumAquamarine", 0x66cdaa },
|
||||||
|
{ "MediumBlue", 0x0000cd },
|
||||||
|
{ "MediumOrchid", 0xba55d3 },
|
||||||
|
{ "MediumOrchid1", 0xe066ff },
|
||||||
|
{ "MediumOrchid2", 0xd15fee },
|
||||||
|
{ "MediumOrchid3", 0xb452cd },
|
||||||
|
{ "MediumOrchid4", 0x7a378b },
|
||||||
|
{ "MediumPurple", 0x9370db },
|
||||||
|
{ "MediumPurple1", 0xab82ff },
|
||||||
|
{ "MediumPurple2", 0x9f79ee },
|
||||||
|
{ "MediumPurple3", 0x8968cd },
|
||||||
|
{ "MediumPurple4", 0x5d478b },
|
||||||
|
{ "MediumSeaGreen", 0x3cb371 },
|
||||||
|
{ "MediumSlateBlue", 0x7b68ee },
|
||||||
|
{ "MediumSpringGreen", 0x00fa9a },
|
||||||
|
{ "MediumTurquoise", 0x48d1cc },
|
||||||
|
{ "MediumVioletRed", 0xc71585 },
|
||||||
|
{ "MidnightBlue", 0x191970 },
|
||||||
|
{ "MintCream", 0xf5fffa },
|
||||||
|
{ "MistyRose", 0xffe4e1 },
|
||||||
|
{ "MistyRose1", 0xffe4e1 },
|
||||||
|
{ "MistyRose2", 0xeed5d2 },
|
||||||
|
{ "MistyRose3", 0xcdb7b5 },
|
||||||
|
{ "MistyRose4", 0x8b7d7b },
|
||||||
|
{ "NavajoWhite", 0xffdead },
|
||||||
|
{ "NavajoWhite1", 0xffdead },
|
||||||
|
{ "NavajoWhite2", 0xeecfa1 },
|
||||||
|
{ "NavajoWhite3", 0xcdb38b },
|
||||||
|
{ "NavajoWhite4", 0x8b795e },
|
||||||
|
{ "NavyBlue", 0x000080 },
|
||||||
|
{ "OldLace", 0xfdf5e6 },
|
||||||
|
{ "OliveDrab", 0x6b8e23 },
|
||||||
|
{ "OliveDrab1", 0xc0ff3e },
|
||||||
|
{ "OliveDrab2", 0xb3ee3a },
|
||||||
|
{ "OliveDrab3", 0x9acd32 },
|
||||||
|
{ "OliveDrab4", 0x698b22 },
|
||||||
|
{ "OrangeRed", 0xff4500 },
|
||||||
|
{ "OrangeRed1", 0xff4500 },
|
||||||
|
{ "OrangeRed2", 0xee4000 },
|
||||||
|
{ "OrangeRed3", 0xcd3700 },
|
||||||
|
{ "OrangeRed4", 0x8b2500 },
|
||||||
|
{ "PaleGoldenrod", 0xeee8aa },
|
||||||
|
{ "PaleGreen", 0x98fb98 },
|
||||||
|
{ "PaleGreen1", 0x9aff9a },
|
||||||
|
{ "PaleGreen2", 0x90ee90 },
|
||||||
|
{ "PaleGreen3", 0x7ccd7c },
|
||||||
|
{ "PaleGreen4", 0x548b54 },
|
||||||
|
{ "PaleTurquoise", 0xafeeee },
|
||||||
|
{ "PaleTurquoise1", 0xbbffff },
|
||||||
|
{ "PaleTurquoise2", 0xaeeeee },
|
||||||
|
{ "PaleTurquoise3", 0x96cdcd },
|
||||||
|
{ "PaleTurquoise4", 0x668b8b },
|
||||||
|
{ "PaleVioletRed", 0xdb7093 },
|
||||||
|
{ "PaleVioletRed1", 0xff82ab },
|
||||||
|
{ "PaleVioletRed2", 0xee799f },
|
||||||
|
{ "PaleVioletRed3", 0xcd6889 },
|
||||||
|
{ "PaleVioletRed4", 0x8b475d },
|
||||||
|
{ "PapayaWhip", 0xffefd5 },
|
||||||
|
{ "PeachPuff", 0xffdab9 },
|
||||||
|
{ "PeachPuff1", 0xffdab9 },
|
||||||
|
{ "PeachPuff2", 0xeecbad },
|
||||||
|
{ "PeachPuff3", 0xcdaf95 },
|
||||||
|
{ "PeachPuff4", 0x8b7765 },
|
||||||
|
{ "PowderBlue", 0xb0e0e6 },
|
||||||
|
{ "RebeccaPurple", 0x663399 },
|
||||||
|
{ "RosyBrown", 0xbc8f8f },
|
||||||
|
{ "RosyBrown1", 0xffc1c1 },
|
||||||
|
{ "RosyBrown2", 0xeeb4b4 },
|
||||||
|
{ "RosyBrown3", 0xcd9b9b },
|
||||||
|
{ "RosyBrown4", 0x8b6969 },
|
||||||
|
{ "RoyalBlue", 0x4169e1 },
|
||||||
|
{ "RoyalBlue1", 0x4876ff },
|
||||||
|
{ "RoyalBlue2", 0x436eee },
|
||||||
|
{ "RoyalBlue3", 0x3a5fcd },
|
||||||
|
{ "RoyalBlue4", 0x27408b },
|
||||||
|
{ "SaddleBrown", 0x8b4513 },
|
||||||
|
{ "SandyBrown", 0xf4a460 },
|
||||||
|
{ "SeaGreen", 0x2e8b57 },
|
||||||
|
{ "SeaGreen1", 0x54ff9f },
|
||||||
|
{ "SeaGreen2", 0x4eee94 },
|
||||||
|
{ "SeaGreen3", 0x43cd80 },
|
||||||
|
{ "SeaGreen4", 0x2e8b57 },
|
||||||
|
{ "SkyBlue", 0x87ceeb },
|
||||||
|
{ "SkyBlue1", 0x87ceff },
|
||||||
|
{ "SkyBlue2", 0x7ec0ee },
|
||||||
|
{ "SkyBlue3", 0x6ca6cd },
|
||||||
|
{ "SkyBlue4", 0x4a708b },
|
||||||
|
{ "SlateBlue", 0x6a5acd },
|
||||||
|
{ "SlateBlue1", 0x836fff },
|
||||||
|
{ "SlateBlue2", 0x7a67ee },
|
||||||
|
{ "SlateBlue3", 0x6959cd },
|
||||||
|
{ "SlateBlue4", 0x473c8b },
|
||||||
|
{ "SlateGray", 0x708090 },
|
||||||
|
{ "SlateGray1", 0xc6e2ff },
|
||||||
|
{ "SlateGray2", 0xb9d3ee },
|
||||||
|
{ "SlateGray3", 0x9fb6cd },
|
||||||
|
{ "SlateGray4", 0x6c7b8b },
|
||||||
|
{ "SlateGrey", 0x708090 },
|
||||||
|
{ "SpringGreen", 0x00ff7f },
|
||||||
|
{ "SpringGreen1", 0x00ff7f },
|
||||||
|
{ "SpringGreen2", 0x00ee76 },
|
||||||
|
{ "SpringGreen3", 0x00cd66 },
|
||||||
|
{ "SpringGreen4", 0x008b45 },
|
||||||
|
{ "SteelBlue", 0x4682b4 },
|
||||||
|
{ "SteelBlue1", 0x63b8ff },
|
||||||
|
{ "SteelBlue2", 0x5cacee },
|
||||||
|
{ "SteelBlue3", 0x4f94cd },
|
||||||
|
{ "SteelBlue4", 0x36648b },
|
||||||
|
{ "VioletRed", 0xd02090 },
|
||||||
|
{ "VioletRed1", 0xff3e96 },
|
||||||
|
{ "VioletRed2", 0xee3a8c },
|
||||||
|
{ "VioletRed3", 0xcd3278 },
|
||||||
|
{ "VioletRed4", 0x8b2252 },
|
||||||
|
{ "WebGray", 0x808080 },
|
||||||
|
{ "WebGreen", 0x008000 },
|
||||||
|
{ "WebGrey", 0x808080 },
|
||||||
|
{ "WebMaroon", 0x800000 },
|
||||||
|
{ "WebPurple", 0x800080 },
|
||||||
|
{ "WhiteSmoke", 0xf5f5f5 },
|
||||||
|
{ "X11Gray", 0xbebebe },
|
||||||
|
{ "X11Green", 0x00ff00 },
|
||||||
|
{ "X11Grey", 0xbebebe },
|
||||||
|
{ "X11Maroon", 0xb03060 },
|
||||||
|
{ "X11Purple", 0xa020f0 },
|
||||||
|
{ "YellowGreen", 0x9acd32 },
|
||||||
|
{ "alice blue", 0xf0f8ff },
|
||||||
|
{ "antique white", 0xfaebd7 },
|
||||||
|
{ "aqua", 0x00ffff },
|
||||||
|
{ "aquamarine", 0x7fffd4 },
|
||||||
|
{ "aquamarine1", 0x7fffd4 },
|
||||||
|
{ "aquamarine2", 0x76eec6 },
|
||||||
|
{ "aquamarine3", 0x66cdaa },
|
||||||
|
{ "aquamarine4", 0x458b74 },
|
||||||
|
{ "azure", 0xf0ffff },
|
||||||
|
{ "azure1", 0xf0ffff },
|
||||||
|
{ "azure2", 0xe0eeee },
|
||||||
|
{ "azure3", 0xc1cdcd },
|
||||||
|
{ "azure4", 0x838b8b },
|
||||||
|
{ "beige", 0xf5f5dc },
|
||||||
|
{ "bisque", 0xffe4c4 },
|
||||||
|
{ "bisque1", 0xffe4c4 },
|
||||||
|
{ "bisque2", 0xeed5b7 },
|
||||||
|
{ "bisque3", 0xcdb79e },
|
||||||
|
{ "bisque4", 0x8b7d6b },
|
||||||
|
{ "black", 0x000000 },
|
||||||
|
{ "blanched almond", 0xffebcd },
|
||||||
|
{ "blue violet", 0x8a2be2 },
|
||||||
|
{ "blue", 0x0000ff },
|
||||||
|
{ "blue1", 0x0000ff },
|
||||||
|
{ "blue2", 0x0000ee },
|
||||||
|
{ "blue3", 0x0000cd },
|
||||||
|
{ "blue4", 0x00008b },
|
||||||
|
{ "brown", 0xa52a2a },
|
||||||
|
{ "brown1", 0xff4040 },
|
||||||
|
{ "brown2", 0xee3b3b },
|
||||||
|
{ "brown3", 0xcd3333 },
|
||||||
|
{ "brown4", 0x8b2323 },
|
||||||
|
{ "burlywood", 0xdeb887 },
|
||||||
|
{ "burlywood1", 0xffd39b },
|
||||||
|
{ "burlywood2", 0xeec591 },
|
||||||
|
{ "burlywood3", 0xcdaa7d },
|
||||||
|
{ "burlywood4", 0x8b7355 },
|
||||||
|
{ "cadet blue", 0x5f9ea0 },
|
||||||
|
{ "chartreuse", 0x7fff00 },
|
||||||
|
{ "chartreuse1", 0x7fff00 },
|
||||||
|
{ "chartreuse2", 0x76ee00 },
|
||||||
|
{ "chartreuse3", 0x66cd00 },
|
||||||
|
{ "chartreuse4", 0x458b00 },
|
||||||
|
{ "chocolate", 0xd2691e },
|
||||||
|
{ "chocolate1", 0xff7f24 },
|
||||||
|
{ "chocolate2", 0xee7621 },
|
||||||
|
{ "chocolate3", 0xcd661d },
|
||||||
|
{ "chocolate4", 0x8b4513 },
|
||||||
|
{ "coral", 0xff7f50 },
|
||||||
|
{ "coral1", 0xff7256 },
|
||||||
|
{ "coral2", 0xee6a50 },
|
||||||
|
{ "coral3", 0xcd5b45 },
|
||||||
|
{ "coral4", 0x8b3e2f },
|
||||||
|
{ "cornflower blue", 0x6495ed },
|
||||||
|
{ "cornsilk", 0xfff8dc },
|
||||||
|
{ "cornsilk1", 0xfff8dc },
|
||||||
|
{ "cornsilk2", 0xeee8cd },
|
||||||
|
{ "cornsilk3", 0xcdc8b1 },
|
||||||
|
{ "cornsilk4", 0x8b8878 },
|
||||||
|
{ "crimson", 0xdc143c },
|
||||||
|
{ "cyan", 0x00ffff },
|
||||||
|
{ "cyan1", 0x00ffff },
|
||||||
|
{ "cyan2", 0x00eeee },
|
||||||
|
{ "cyan3", 0x00cdcd },
|
||||||
|
{ "cyan4", 0x008b8b },
|
||||||
|
{ "dark blue", 0x00008b },
|
||||||
|
{ "dark cyan", 0x008b8b },
|
||||||
|
{ "dark goldenrod", 0xb8860b },
|
||||||
|
{ "dark gray", 0xa9a9a9 },
|
||||||
|
{ "dark green", 0x006400 },
|
||||||
|
{ "dark grey", 0xa9a9a9 },
|
||||||
|
{ "dark khaki", 0xbdb76b },
|
||||||
|
{ "dark magenta", 0x8b008b },
|
||||||
|
{ "dark olive green", 0x556b2f },
|
||||||
|
{ "dark orange", 0xff8c00 },
|
||||||
|
{ "dark orchid", 0x9932cc },
|
||||||
|
{ "dark red", 0x8b0000 },
|
||||||
|
{ "dark salmon", 0xe9967a },
|
||||||
|
{ "dark sea green", 0x8fbc8f },
|
||||||
|
{ "dark slate blue", 0x483d8b },
|
||||||
|
{ "dark slate gray", 0x2f4f4f },
|
||||||
|
{ "dark slate grey", 0x2f4f4f },
|
||||||
|
{ "dark turquoise", 0x00ced1 },
|
||||||
|
{ "dark violet", 0x9400d3 },
|
||||||
|
{ "deep pink", 0xff1493 },
|
||||||
|
{ "deep sky blue", 0x00bfff },
|
||||||
|
{ "dim gray", 0x696969 },
|
||||||
|
{ "dim grey", 0x696969 },
|
||||||
|
{ "dodger blue", 0x1e90ff },
|
||||||
|
{ "firebrick", 0xb22222 },
|
||||||
|
{ "firebrick1", 0xff3030 },
|
||||||
|
{ "firebrick2", 0xee2c2c },
|
||||||
|
{ "firebrick3", 0xcd2626 },
|
||||||
|
{ "firebrick4", 0x8b1a1a },
|
||||||
|
{ "floral white", 0xfffaf0 },
|
||||||
|
{ "forest green", 0x228b22 },
|
||||||
|
{ "fuchsia", 0xff00ff },
|
||||||
|
{ "gainsboro", 0xdcdcdc },
|
||||||
|
{ "ghost white", 0xf8f8ff },
|
||||||
|
{ "gold", 0xffd700 },
|
||||||
|
{ "gold1", 0xffd700 },
|
||||||
|
{ "gold2", 0xeec900 },
|
||||||
|
{ "gold3", 0xcdad00 },
|
||||||
|
{ "gold4", 0x8b7500 },
|
||||||
|
{ "goldenrod", 0xdaa520 },
|
||||||
|
{ "goldenrod1", 0xffc125 },
|
||||||
|
{ "goldenrod2", 0xeeb422 },
|
||||||
|
{ "goldenrod3", 0xcd9b1d },
|
||||||
|
{ "goldenrod4", 0x8b6914 },
|
||||||
|
{ "green yellow", 0xadff2f },
|
||||||
|
{ "green", 0x00ff00 },
|
||||||
|
{ "green1", 0x00ff00 },
|
||||||
|
{ "green2", 0x00ee00 },
|
||||||
|
{ "green3", 0x00cd00 },
|
||||||
|
{ "green4", 0x008b00 },
|
||||||
|
{ "honeydew", 0xf0fff0 },
|
||||||
|
{ "honeydew1", 0xf0fff0 },
|
||||||
|
{ "honeydew2", 0xe0eee0 },
|
||||||
|
{ "honeydew3", 0xc1cdc1 },
|
||||||
|
{ "honeydew4", 0x838b83 },
|
||||||
|
{ "hot pink", 0xff69b4 },
|
||||||
|
{ "indian red", 0xcd5c5c },
|
||||||
|
{ "indigo", 0x4b0082 },
|
||||||
|
{ "ivory", 0xfffff0 },
|
||||||
|
{ "ivory1", 0xfffff0 },
|
||||||
|
{ "ivory2", 0xeeeee0 },
|
||||||
|
{ "ivory3", 0xcdcdc1 },
|
||||||
|
{ "ivory4", 0x8b8b83 },
|
||||||
|
{ "khaki", 0xf0e68c },
|
||||||
|
{ "khaki1", 0xfff68f },
|
||||||
|
{ "khaki2", 0xeee685 },
|
||||||
|
{ "khaki3", 0xcdc673 },
|
||||||
|
{ "khaki4", 0x8b864e },
|
||||||
|
{ "lavender blush", 0xfff0f5 },
|
||||||
|
{ "lavender", 0xe6e6fa },
|
||||||
|
{ "lawn green", 0x7cfc00 },
|
||||||
|
{ "lemon chiffon", 0xfffacd },
|
||||||
|
{ "light blue", 0xadd8e6 },
|
||||||
|
{ "light coral", 0xf08080 },
|
||||||
|
{ "light cyan", 0xe0ffff },
|
||||||
|
{ "light goldenrod yellow", 0xfafad2 },
|
||||||
|
{ "light goldenrod", 0xeedd82 },
|
||||||
|
{ "light gray", 0xd3d3d3 },
|
||||||
|
{ "light green", 0x90ee90 },
|
||||||
|
{ "light grey", 0xd3d3d3 },
|
||||||
|
{ "light pink", 0xffb6c1 },
|
||||||
|
{ "light salmon", 0xffa07a },
|
||||||
|
{ "light sea green", 0x20b2aa },
|
||||||
|
{ "light sky blue", 0x87cefa },
|
||||||
|
{ "light slate blue", 0x8470ff },
|
||||||
|
{ "light slate gray", 0x778899 },
|
||||||
|
{ "light slate grey", 0x778899 },
|
||||||
|
{ "light steel blue", 0xb0c4de },
|
||||||
|
{ "light yellow", 0xffffe0 },
|
||||||
|
{ "lime green", 0x32cd32 },
|
||||||
|
{ "lime", 0x00ff00 },
|
||||||
|
{ "linen", 0xfaf0e6 },
|
||||||
|
{ "magenta", 0xff00ff },
|
||||||
|
{ "magenta1", 0xff00ff },
|
||||||
|
{ "magenta2", 0xee00ee },
|
||||||
|
{ "magenta3", 0xcd00cd },
|
||||||
|
{ "magenta4", 0x8b008b },
|
||||||
|
{ "maroon", 0xb03060 },
|
||||||
|
{ "maroon1", 0xff34b3 },
|
||||||
|
{ "maroon2", 0xee30a7 },
|
||||||
|
{ "maroon3", 0xcd2990 },
|
||||||
|
{ "maroon4", 0x8b1c62 },
|
||||||
|
{ "medium aquamarine", 0x66cdaa },
|
||||||
|
{ "medium blue", 0x0000cd },
|
||||||
|
{ "medium orchid", 0xba55d3 },
|
||||||
|
{ "medium purple", 0x9370db },
|
||||||
|
{ "medium sea green", 0x3cb371 },
|
||||||
|
{ "medium slate blue", 0x7b68ee },
|
||||||
|
{ "medium spring green", 0x00fa9a },
|
||||||
|
{ "medium turquoise", 0x48d1cc },
|
||||||
|
{ "medium violet red", 0xc71585 },
|
||||||
|
{ "midnight blue", 0x191970 },
|
||||||
|
{ "mint cream", 0xf5fffa },
|
||||||
|
{ "misty rose", 0xffe4e1 },
|
||||||
|
{ "moccasin", 0xffe4b5 },
|
||||||
|
{ "navajo white", 0xffdead },
|
||||||
|
{ "navy blue", 0x000080 },
|
||||||
|
{ "navy", 0x000080 },
|
||||||
|
{ "old lace", 0xfdf5e6 },
|
||||||
|
{ "olive drab", 0x6b8e23 },
|
||||||
|
{ "olive", 0x808000 },
|
||||||
|
{ "orange red", 0xff4500 },
|
||||||
|
{ "orange", 0xffa500 },
|
||||||
|
{ "orange1", 0xffa500 },
|
||||||
|
{ "orange2", 0xee9a00 },
|
||||||
|
{ "orange3", 0xcd8500 },
|
||||||
|
{ "orange4", 0x8b5a00 },
|
||||||
|
{ "orchid", 0xda70d6 },
|
||||||
|
{ "orchid1", 0xff83fa },
|
||||||
|
{ "orchid2", 0xee7ae9 },
|
||||||
|
{ "orchid3", 0xcd69c9 },
|
||||||
|
{ "orchid4", 0x8b4789 },
|
||||||
|
{ "pale goldenrod", 0xeee8aa },
|
||||||
|
{ "pale green", 0x98fb98 },
|
||||||
|
{ "pale turquoise", 0xafeeee },
|
||||||
|
{ "pale violet red", 0xdb7093 },
|
||||||
|
{ "papaya whip", 0xffefd5 },
|
||||||
|
{ "peach puff", 0xffdab9 },
|
||||||
|
{ "peru", 0xcd853f },
|
||||||
|
{ "pink", 0xffc0cb },
|
||||||
|
{ "pink1", 0xffb5c5 },
|
||||||
|
{ "pink2", 0xeea9b8 },
|
||||||
|
{ "pink3", 0xcd919e },
|
||||||
|
{ "pink4", 0x8b636c },
|
||||||
|
{ "plum", 0xdda0dd },
|
||||||
|
{ "plum1", 0xffbbff },
|
||||||
|
{ "plum2", 0xeeaeee },
|
||||||
|
{ "plum3", 0xcd96cd },
|
||||||
|
{ "plum4", 0x8b668b },
|
||||||
|
{ "powder blue", 0xb0e0e6 },
|
||||||
|
{ "purple", 0xa020f0 },
|
||||||
|
{ "purple1", 0x9b30ff },
|
||||||
|
{ "purple2", 0x912cee },
|
||||||
|
{ "purple3", 0x7d26cd },
|
||||||
|
{ "purple4", 0x551a8b },
|
||||||
|
{ "rebecca purple", 0x663399 },
|
||||||
|
{ "red", 0xff0000 },
|
||||||
|
{ "red1", 0xff0000 },
|
||||||
|
{ "red2", 0xee0000 },
|
||||||
|
{ "red3", 0xcd0000 },
|
||||||
|
{ "red4", 0x8b0000 },
|
||||||
|
{ "rosy brown", 0xbc8f8f },
|
||||||
|
{ "royal blue", 0x4169e1 },
|
||||||
|
{ "saddle brown", 0x8b4513 },
|
||||||
|
{ "salmon", 0xfa8072 },
|
||||||
|
{ "salmon1", 0xff8c69 },
|
||||||
|
{ "salmon2", 0xee8262 },
|
||||||
|
{ "salmon3", 0xcd7054 },
|
||||||
|
{ "salmon4", 0x8b4c39 },
|
||||||
|
{ "sandy brown", 0xf4a460 },
|
||||||
|
{ "sea green", 0x2e8b57 },
|
||||||
|
{ "seashell", 0xfff5ee },
|
||||||
|
{ "seashell1", 0xfff5ee },
|
||||||
|
{ "seashell2", 0xeee5de },
|
||||||
|
{ "seashell3", 0xcdc5bf },
|
||||||
|
{ "seashell4", 0x8b8682 },
|
||||||
|
{ "sienna", 0xa0522d },
|
||||||
|
{ "sienna1", 0xff8247 },
|
||||||
|
{ "sienna2", 0xee7942 },
|
||||||
|
{ "sienna3", 0xcd6839 },
|
||||||
|
{ "sienna4", 0x8b4726 },
|
||||||
|
{ "silver", 0xc0c0c0 },
|
||||||
|
{ "sky blue", 0x87ceeb },
|
||||||
|
{ "slate blue", 0x6a5acd },
|
||||||
|
{ "slate gray", 0x708090 },
|
||||||
|
{ "slate grey", 0x708090 },
|
||||||
|
{ "snow", 0xfffafa },
|
||||||
|
{ "snow1", 0xfffafa },
|
||||||
|
{ "snow2", 0xeee9e9 },
|
||||||
|
{ "snow3", 0xcdc9c9 },
|
||||||
|
{ "snow4", 0x8b8989 },
|
||||||
|
{ "spring green", 0x00ff7f },
|
||||||
|
{ "steel blue", 0x4682b4 },
|
||||||
|
{ "tan", 0xd2b48c },
|
||||||
|
{ "tan1", 0xffa54f },
|
||||||
|
{ "tan2", 0xee9a49 },
|
||||||
|
{ "tan3", 0xcd853f },
|
||||||
|
{ "tan4", 0x8b5a2b },
|
||||||
|
{ "teal", 0x008080 },
|
||||||
|
{ "thistle", 0xd8bfd8 },
|
||||||
|
{ "thistle1", 0xffe1ff },
|
||||||
|
{ "thistle2", 0xeed2ee },
|
||||||
|
{ "thistle3", 0xcdb5cd },
|
||||||
|
{ "thistle4", 0x8b7b8b },
|
||||||
|
{ "tomato", 0xff6347 },
|
||||||
|
{ "tomato1", 0xff6347 },
|
||||||
|
{ "tomato2", 0xee5c42 },
|
||||||
|
{ "tomato3", 0xcd4f39 },
|
||||||
|
{ "tomato4", 0x8b3626 },
|
||||||
|
{ "turquoise", 0x40e0d0 },
|
||||||
|
{ "turquoise1", 0x00f5ff },
|
||||||
|
{ "turquoise2", 0x00e5ee },
|
||||||
|
{ "turquoise3", 0x00c5cd },
|
||||||
|
{ "turquoise4", 0x00868b },
|
||||||
|
{ "violet red", 0xd02090 },
|
||||||
|
{ "violet", 0xee82ee },
|
||||||
|
{ "web gray", 0x808080 },
|
||||||
|
{ "web green", 0x008000 },
|
||||||
|
{ "web grey", 0x808080 },
|
||||||
|
{ "web maroon", 0x800000 },
|
||||||
|
{ "web purple", 0x800080 },
|
||||||
|
{ "wheat", 0xf5deb3 },
|
||||||
|
{ "wheat1", 0xffe7ba },
|
||||||
|
{ "wheat2", 0xeed8ae },
|
||||||
|
{ "wheat3", 0xcdba96 },
|
||||||
|
{ "wheat4", 0x8b7e66 },
|
||||||
|
{ "white smoke", 0xf5f5f5 },
|
||||||
|
{ "white", 0xffffff },
|
||||||
|
{ "x11 gray", 0xbebebe },
|
||||||
|
{ "x11 green", 0x00ff00 },
|
||||||
|
{ "x11 grey", 0xbebebe },
|
||||||
|
{ "x11 maroon", 0xb03060 },
|
||||||
|
{ "x11 purple", 0xa020f0 },
|
||||||
|
{ "yellow green", 0x9acd32 },
|
||||||
|
{ "yellow", 0xffff00 },
|
||||||
|
{ "yellow1", 0xffff00 },
|
||||||
|
{ "yellow2", 0xeeee00 },
|
||||||
|
{ "yellow3", 0xcdcd00 },
|
||||||
|
{ "yellow4", 0x8b8b00 }
|
||||||
|
};
|
||||||
|
u_int i;
|
||||||
|
int c;
|
||||||
|
const char *errstr;
|
||||||
|
|
||||||
|
if (strncmp(name, "grey", 4) == 0 || strncmp(name, "gray", 4) == 0) {
|
||||||
|
if (name[4] == '\0')
|
||||||
|
return (-1);
|
||||||
|
c = strtonum(name + 4, 0, 100, &errstr);
|
||||||
|
if (errstr != NULL)
|
||||||
|
return (-1);
|
||||||
|
c = round(2.55 * c);
|
||||||
|
if (c < 0 || c > 255)
|
||||||
|
return (-1);
|
||||||
|
return (colour_join_rgb(c, c, c));
|
||||||
|
}
|
||||||
|
for (i = 0; i < nitems(colours); i++) {
|
||||||
|
if (strcasecmp(colours[i].name, name) == 0)
|
||||||
|
return (colours[i].c|COLOUR_FLAG_RGB);
|
||||||
|
}
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse colour from an X11 string. */
|
||||||
|
int
|
||||||
|
colour_parseX11(const char *p)
|
||||||
|
{
|
||||||
|
double c, m, y, k = 0;
|
||||||
|
u_int r, g, b;
|
||||||
|
size_t len = strlen(p);
|
||||||
|
int colour = -1;
|
||||||
|
char *copy;
|
||||||
|
|
||||||
|
if ((len == 12 && sscanf(p, "rgb:%02x/%02x/%02x", &r, &g, &b) == 3) ||
|
||||||
|
(len == 7 && sscanf(p, "#%02x%02x%02x", &r, &g, &b) == 3) ||
|
||||||
|
sscanf(p, "%d,%d,%d", &r, &g, &b) == 3)
|
||||||
|
colour = colour_join_rgb(r, g, b);
|
||||||
|
else if ((len == 18 &&
|
||||||
|
sscanf(p, "rgb:%04x/%04x/%04x", &r, &g, &b) == 3) ||
|
||||||
|
(len == 13 && sscanf(p, "#%04x%04x%04x", &r, &g, &b) == 3))
|
||||||
|
colour = colour_join_rgb(r >> 8, g >> 8, b >> 8);
|
||||||
|
else if ((sscanf(p, "cmyk:%lf/%lf/%lf/%lf", &c, &m, &y, &k) == 4 ||
|
||||||
|
sscanf(p, "cmy:%lf/%lf/%lf", &c, &m, &y) == 3) &&
|
||||||
|
c >= 0 && c <= 1 && m >= 0 && m <= 1 &&
|
||||||
|
y >= 0 && y <= 1 && k >= 0 && k <= 1) {
|
||||||
|
colour = colour_join_rgb(
|
||||||
|
(1 - c) * (1 - k) * 255,
|
||||||
|
(1 - m) * (1 - k) * 255,
|
||||||
|
(1 - y) * (1 - k) * 255);
|
||||||
|
} else {
|
||||||
|
while (len != 0 && *p == ' ') {
|
||||||
|
p++;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
while (len != 0 && p[len - 1] == ' ')
|
||||||
|
len--;
|
||||||
|
copy = xstrndup(p, len);
|
||||||
|
colour = colour_byname(copy);
|
||||||
|
free(copy);
|
||||||
|
}
|
||||||
|
log_debug("%s: %s = %s", __func__, p, colour_tostring(colour));
|
||||||
|
return (colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize palette. */
|
||||||
|
void
|
||||||
|
colour_palette_init(struct colour_palette *p)
|
||||||
|
{
|
||||||
|
p->fg = 8;
|
||||||
|
p->bg = 8;
|
||||||
|
p->palette = NULL;
|
||||||
|
p->default_palette = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear palette. */
|
||||||
|
void
|
||||||
|
colour_palette_clear(struct colour_palette *p)
|
||||||
|
{
|
||||||
|
if (p != NULL) {
|
||||||
|
p->fg = 8;
|
||||||
|
p->bg = 8;
|
||||||
|
free(p->palette);
|
||||||
|
p->palette = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free a palette. */
|
||||||
|
void
|
||||||
|
colour_palette_free(struct colour_palette *p)
|
||||||
|
{
|
||||||
|
if (p != NULL) {
|
||||||
|
free(p->palette);
|
||||||
|
p->palette = NULL;
|
||||||
|
free(p->default_palette);
|
||||||
|
p->default_palette = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get a colour from a palette. */
|
||||||
|
int
|
||||||
|
colour_palette_get(struct colour_palette *p, int c)
|
||||||
|
{
|
||||||
|
if (p == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (c >= 90 && c <= 97)
|
||||||
|
c = 8 + c - 90;
|
||||||
|
else if (c & COLOUR_FLAG_256)
|
||||||
|
c &= ~COLOUR_FLAG_256;
|
||||||
|
else if (c >= 8)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (p->palette != NULL && p->palette[c] != -1)
|
||||||
|
return (p->palette[c]);
|
||||||
|
if (p->default_palette != NULL && p->default_palette[c] != -1)
|
||||||
|
return (p->default_palette[c]);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set a colour in a palette. */
|
||||||
|
int
|
||||||
|
colour_palette_set(struct colour_palette *p, int n, int c)
|
||||||
|
{
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
if (p == NULL || n > 255)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
if (c == -1 && p->palette == NULL)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
if (c != -1 && p->palette == NULL) {
|
||||||
|
if (p->palette == NULL)
|
||||||
|
p->palette = xcalloc(256, sizeof *p->palette);
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
p->palette[i] = -1;
|
||||||
|
}
|
||||||
|
p->palette[n] = c;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Build palette defaults from an option. */
|
||||||
|
void
|
||||||
|
colour_palette_from_option(struct colour_palette *p, struct options *oo)
|
||||||
|
{
|
||||||
|
struct options_entry *o;
|
||||||
|
struct options_array_item *a;
|
||||||
|
u_int i, n;
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if (p == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
o = options_get(oo, "pane-colours");
|
||||||
|
if ((a = options_array_first(o)) == NULL) {
|
||||||
|
if (p->default_palette != NULL) {
|
||||||
|
free(p->default_palette);
|
||||||
|
p->default_palette = NULL;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (p->default_palette == NULL)
|
||||||
|
p->default_palette = xcalloc(256, sizeof *p->default_palette);
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
p->default_palette[i] = -1;
|
||||||
|
while (a != NULL) {
|
||||||
|
n = options_array_item_index(a);
|
||||||
|
if (n < 256) {
|
||||||
|
c = options_array_item_value(a)->number;
|
||||||
|
p->default_palette[n] = c;
|
||||||
|
}
|
||||||
|
a = options_array_next(a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
137
compat.h
137
compat.h
@@ -21,15 +21,41 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
|
||||||
|
#include <fnmatch.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_EVENT2_EVENT_H
|
||||||
|
#include <event2/event.h>
|
||||||
|
#include <event2/event_compat.h>
|
||||||
|
#include <event2/event_struct.h>
|
||||||
|
#include <event2/buffer.h>
|
||||||
|
#include <event2/buffer_compat.h>
|
||||||
|
#include <event2/bufferevent.h>
|
||||||
|
#include <event2/bufferevent_struct.h>
|
||||||
|
#include <event2/bufferevent_compat.h>
|
||||||
|
#else
|
||||||
|
#include <event.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_MALLOC_TRIM
|
||||||
|
#include <malloc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UTF8PROC
|
||||||
|
#include <utf8proc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __GNUC__
|
#ifndef __GNUC__
|
||||||
#define __attribute__(a)
|
#define __attribute__(a)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BROKEN___DEAD
|
||||||
|
#undef __dead
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __unused
|
#ifndef __unused
|
||||||
#define __unused __attribute__ ((__unused__))
|
#define __unused __attribute__ ((__unused__))
|
||||||
#endif
|
#endif
|
||||||
@@ -39,6 +65,9 @@
|
|||||||
#ifndef __packed
|
#ifndef __packed
|
||||||
#define __packed __attribute__ ((__packed__))
|
#define __packed __attribute__ ((__packed__))
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef __weak
|
||||||
|
#define __weak __attribute__ ((__weak__))
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ECHOPRT
|
#ifndef ECHOPRT
|
||||||
#define ECHOPRT 0
|
#define ECHOPRT 0
|
||||||
@@ -61,18 +90,46 @@ void warn(const char *, ...);
|
|||||||
void warnx(const char *, ...);
|
void warnx(const char *, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_PATHS_H
|
#ifdef HAVE_PATHS_H
|
||||||
#define _PATH_BSHELL "/bin/sh"
|
#include <paths.h>
|
||||||
#define _PATH_TMP "/tmp/"
|
#endif
|
||||||
|
|
||||||
|
#ifndef _PATH_BSHELL
|
||||||
|
#define _PATH_BSHELL "/bin/sh"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _PATH_TMP
|
||||||
|
#define _PATH_TMP "/tmp/"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _PATH_DEVNULL
|
||||||
#define _PATH_DEVNULL "/dev/null"
|
#define _PATH_DEVNULL "/dev/null"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _PATH_TTY
|
||||||
#define _PATH_TTY "/dev/tty"
|
#define _PATH_TTY "/dev/tty"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _PATH_DEV
|
||||||
#define _PATH_DEV "/dev/"
|
#define _PATH_DEV "/dev/"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _PATH_DEFPATH
|
||||||
|
#define _PATH_DEFPATH "/usr/bin:/bin"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _PATH_VI
|
||||||
|
#define _PATH_VI "/usr/bin/vi"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __OpenBSD__
|
#ifndef __OpenBSD__
|
||||||
#define pledge(s, p) (0)
|
#define pledge(s, p) (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef IMAXBEL
|
||||||
|
#define IMAXBEL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STDINT_H
|
#ifdef HAVE_STDINT_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#else
|
#else
|
||||||
@@ -97,21 +154,17 @@ void warnx(const char *, ...);
|
|||||||
#include "compat/bitstring.h"
|
#include "compat/bitstring.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PATHS_H
|
|
||||||
#include <paths.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_FORKPTY
|
|
||||||
#ifdef HAVE_LIBUTIL_H
|
#ifdef HAVE_LIBUTIL_H
|
||||||
#include <libutil.h>
|
#include <libutil.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PTY_H
|
#ifdef HAVE_PTY_H
|
||||||
#include <pty.h>
|
#include <pty.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UTIL_H
|
#ifdef HAVE_UTIL_H
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_VIS
|
#ifdef HAVE_VIS
|
||||||
#include <vis.h>
|
#include <vis.h>
|
||||||
@@ -153,6 +206,14 @@ void warnx(const char *, ...);
|
|||||||
#define O_DIRECTORY 0
|
#define O_DIRECTORY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef FNM_CASEFOLD
|
||||||
|
#ifdef FNM_IGNORECASE
|
||||||
|
#define FNM_CASEFOLD FNM_IGNORECASE
|
||||||
|
#else
|
||||||
|
#define FNM_CASEFOLD 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef INFTIM
|
#ifndef INFTIM
|
||||||
#define INFTIM -1
|
#define INFTIM -1
|
||||||
#endif
|
#endif
|
||||||
@@ -204,6 +265,13 @@ void warnx(const char *, ...);
|
|||||||
#define HOST_NAME_MAX 255
|
#define HOST_NAME_MAX 255
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CLOCK_REALTIME
|
||||||
|
#define CLOCK_REALTIME 0
|
||||||
|
#endif
|
||||||
|
#ifndef CLOCK_MONOTONIC
|
||||||
|
#define CLOCK_MONOTONIC CLOCK_REALTIME
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_FLOCK
|
#ifndef HAVE_FLOCK
|
||||||
#define LOCK_SH 0
|
#define LOCK_SH 0
|
||||||
#define LOCK_EX 0
|
#define LOCK_EX 0
|
||||||
@@ -221,6 +289,11 @@ void explicit_bzero(void *, size_t);
|
|||||||
int getdtablecount(void);
|
int getdtablecount(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETDTABLESIZE
|
||||||
|
/* getdtablesize.c */
|
||||||
|
int getdtablesize(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_CLOSEFROM
|
#ifndef HAVE_CLOSEFROM
|
||||||
/* closefrom.c */
|
/* closefrom.c */
|
||||||
void closefrom(int);
|
void closefrom(int);
|
||||||
@@ -261,6 +334,28 @@ size_t strnlen(const char *, size_t);
|
|||||||
char *strndup(const char *, size_t);
|
char *strndup(const char *, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_MEMMEM
|
||||||
|
/* memmem.c */
|
||||||
|
void *memmem(const void *, size_t, const void *, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_HTONLL
|
||||||
|
/* htonll.c */
|
||||||
|
#undef htonll
|
||||||
|
uint64_t htonll(uint64_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_NTOHLL
|
||||||
|
/* ntohll.c */
|
||||||
|
#undef ntohll
|
||||||
|
uint64_t ntohll(uint64_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETPEEREID
|
||||||
|
/* getpeereid.c */
|
||||||
|
int getpeereid(int, uid_t *, gid_t *);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_DAEMON
|
#ifndef HAVE_DAEMON
|
||||||
/* daemon.c */
|
/* daemon.c */
|
||||||
int daemon(int, int);
|
int daemon(int, int);
|
||||||
@@ -276,6 +371,11 @@ const char *getprogname(void);
|
|||||||
void setproctitle(const char *, ...);
|
void setproctitle(const char *, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_CLOCK_GETTIME
|
||||||
|
/* clock_gettime.c */
|
||||||
|
int clock_gettime(int, struct timespec *);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_B64_NTOP
|
#ifndef HAVE_B64_NTOP
|
||||||
/* base64.c */
|
/* base64.c */
|
||||||
#undef b64_ntop
|
#undef b64_ntop
|
||||||
@@ -307,8 +407,9 @@ int vasprintf(char **, const char *, va_list);
|
|||||||
char *fgetln(FILE *, size_t *);
|
char *fgetln(FILE *, size_t *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_FPARSELN
|
#ifndef HAVE_GETLINE
|
||||||
char *fparseln(FILE *, size_t *, size_t *, const char *, int);
|
/* getline.c */
|
||||||
|
ssize_t getline(char **, size_t *, FILE *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SETENV
|
#ifndef HAVE_SETENV
|
||||||
@@ -337,6 +438,13 @@ void *reallocarray(void *, size_t, size_t);
|
|||||||
void *recallocarray(void *, size_t, size_t, size_t);
|
void *recallocarray(void *, size_t, size_t, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYSTEMD
|
||||||
|
/* systemd.c */
|
||||||
|
int systemd_activated(void);
|
||||||
|
int systemd_create_socket(int, char **);
|
||||||
|
int systemd_move_pid_to_new_cgroup(pid_t, char **);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UTF8PROC
|
#ifdef HAVE_UTF8PROC
|
||||||
/* utf8proc.c */
|
/* utf8proc.c */
|
||||||
int utf8proc_wcwidth(wchar_t);
|
int utf8proc_wcwidth(wchar_t);
|
||||||
@@ -344,7 +452,11 @@ int utf8proc_mbtowc(wchar_t *, const char *, size_t);
|
|||||||
int utf8proc_wctomb(char *, wchar_t);
|
int utf8proc_wctomb(char *, wchar_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_GETOPT
|
#ifdef NEED_FUZZING
|
||||||
|
/* tmux.c */
|
||||||
|
#define main __weak main
|
||||||
|
#endif
|
||||||
|
|
||||||
/* getopt.c */
|
/* getopt.c */
|
||||||
extern int BSDopterr;
|
extern int BSDopterr;
|
||||||
extern int BSDoptind;
|
extern int BSDoptind;
|
||||||
@@ -358,6 +470,5 @@ int BSDgetopt(int, char *const *, const char *);
|
|||||||
#define optopt BSDoptopt
|
#define optopt BSDoptopt
|
||||||
#define optreset BSDoptreset
|
#define optreset BSDoptreset
|
||||||
#define optarg BSDoptarg
|
#define optarg BSDoptarg
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* COMPAT_H */
|
#endif /* COMPAT_H */
|
||||||
|
|||||||
@@ -19,8 +19,10 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
asprintf(char **ret, const char *fmt, ...)
|
asprintf(char **ret, const char *fmt, ...)
|
||||||
|
|||||||
37
compat/clock_gettime.c
Normal file
37
compat/clock_gettime.c
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "compat.h"
|
||||||
|
|
||||||
|
#ifndef TIMEVAL_TO_TIMESPEC
|
||||||
|
#define TIMEVAL_TO_TIMESPEC(tv, ts) do { \
|
||||||
|
(ts)->tv_sec = (tv)->tv_sec; \
|
||||||
|
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
clock_gettime(int clock, struct timespec *ts)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
TIMEVAL_TO_TIMESPEC(&tv, ts);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -44,6 +44,9 @@
|
|||||||
# include <ndir.h>
|
# include <ndir.h>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(HAVE_LIBPROC_H)
|
||||||
|
# include <libproc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
|
||||||
@@ -55,39 +58,15 @@
|
|||||||
__unused static const char rcsid[] = "$Sudo: closefrom.c,v 1.11 2006/08/17 15:26:54 millert Exp $";
|
__unused static const char rcsid[] = "$Sudo: closefrom.c,v 1.11 2006/08/17 15:26:54 millert Exp $";
|
||||||
#endif /* lint */
|
#endif /* lint */
|
||||||
|
|
||||||
|
#ifndef HAVE_FCNTL_CLOSEM
|
||||||
/*
|
/*
|
||||||
* Close all file descriptors greater than or equal to lowfd.
|
* Close all file descriptors greater than or equal to lowfd.
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_FCNTL_CLOSEM
|
static void
|
||||||
void
|
closefrom_fallback(int lowfd)
|
||||||
closefrom(int lowfd)
|
|
||||||
{
|
{
|
||||||
(void) fcntl(lowfd, F_CLOSEM, 0);
|
long fd, maxfd;
|
||||||
}
|
|
||||||
#else
|
|
||||||
void
|
|
||||||
closefrom(int lowfd)
|
|
||||||
{
|
|
||||||
long fd, maxfd;
|
|
||||||
#if defined(HAVE_DIRFD) && defined(HAVE_PROC_PID)
|
|
||||||
char fdpath[PATH_MAX], *endp;
|
|
||||||
struct dirent *dent;
|
|
||||||
DIR *dirp;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
/* Check for a /proc/$$/fd directory. */
|
|
||||||
len = snprintf(fdpath, sizeof(fdpath), "/proc/%ld/fd", (long)getpid());
|
|
||||||
if (len > 0 && (size_t)len <= sizeof(fdpath) && (dirp = opendir(fdpath))) {
|
|
||||||
while ((dent = readdir(dirp)) != NULL) {
|
|
||||||
fd = strtol(dent->d_name, &endp, 10);
|
|
||||||
if (dent->d_name != endp && *endp == '\0' &&
|
|
||||||
fd >= 0 && fd < INT_MAX && fd >= lowfd && fd != dirfd(dirp))
|
|
||||||
(void) close((int) fd);
|
|
||||||
}
|
|
||||||
(void) closedir(dirp);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Fall back on sysconf() or getdtablesize(). We avoid checking
|
* Fall back on sysconf() or getdtablesize(). We avoid checking
|
||||||
* resource limits since it is possible to open a file descriptor
|
* resource limits since it is possible to open a file descriptor
|
||||||
@@ -99,11 +78,78 @@ closefrom(int lowfd)
|
|||||||
maxfd = getdtablesize();
|
maxfd = getdtablesize();
|
||||||
#endif /* HAVE_SYSCONF */
|
#endif /* HAVE_SYSCONF */
|
||||||
if (maxfd < 0)
|
if (maxfd < 0)
|
||||||
maxfd = OPEN_MAX;
|
maxfd = OPEN_MAX;
|
||||||
|
|
||||||
for (fd = lowfd; fd < maxfd; fd++)
|
for (fd = lowfd; fd < maxfd; fd++)
|
||||||
(void) close((int) fd);
|
(void) close((int) fd);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_FCNTL_CLOSEM */
|
||||||
|
|
||||||
|
#ifdef HAVE_FCNTL_CLOSEM
|
||||||
|
void
|
||||||
|
closefrom(int lowfd)
|
||||||
|
{
|
||||||
|
(void) fcntl(lowfd, F_CLOSEM, 0);
|
||||||
|
}
|
||||||
|
#elif defined(HAVE_LIBPROC_H) && defined(HAVE_PROC_PIDINFO)
|
||||||
|
void
|
||||||
|
closefrom(int lowfd)
|
||||||
|
{
|
||||||
|
int i, r, sz;
|
||||||
|
pid_t pid = getpid();
|
||||||
|
struct proc_fdinfo *fdinfo_buf = NULL;
|
||||||
|
|
||||||
|
sz = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0);
|
||||||
|
if (sz == 0)
|
||||||
|
return; /* no fds, really? */
|
||||||
|
else if (sz == -1)
|
||||||
|
goto fallback;
|
||||||
|
if ((fdinfo_buf = malloc(sz)) == NULL)
|
||||||
|
goto fallback;
|
||||||
|
r = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, fdinfo_buf, sz);
|
||||||
|
if (r < 0 || r > sz)
|
||||||
|
goto fallback;
|
||||||
|
for (i = 0; i < r / (int)PROC_PIDLISTFD_SIZE; i++) {
|
||||||
|
if (fdinfo_buf[i].proc_fd >= lowfd)
|
||||||
|
close(fdinfo_buf[i].proc_fd);
|
||||||
|
}
|
||||||
|
free(fdinfo_buf);
|
||||||
|
return;
|
||||||
|
fallback:
|
||||||
|
free(fdinfo_buf);
|
||||||
|
closefrom_fallback(lowfd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#elif defined(HAVE_DIRFD) && defined(HAVE_PROC_PID)
|
||||||
|
void
|
||||||
|
closefrom(int lowfd)
|
||||||
|
{
|
||||||
|
long fd;
|
||||||
|
char fdpath[PATH_MAX], *endp;
|
||||||
|
struct dirent *dent;
|
||||||
|
DIR *dirp;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
/* Check for a /proc/$$/fd directory. */
|
||||||
|
len = snprintf(fdpath, sizeof(fdpath), "/proc/%ld/fd", (long)getpid());
|
||||||
|
if (len > 0 && (size_t)len < sizeof(fdpath) && (dirp = opendir(fdpath))) {
|
||||||
|
while ((dent = readdir(dirp)) != NULL) {
|
||||||
|
fd = strtol(dent->d_name, &endp, 10);
|
||||||
|
if (dent->d_name != endp && *endp == '\0' &&
|
||||||
|
fd >= 0 && fd < INT_MAX && fd >= lowfd && fd != dirfd(dirp))
|
||||||
|
(void) close((int) fd);
|
||||||
|
}
|
||||||
|
(void) closedir(dirp);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
/* /proc/$$/fd strategy failed, fall back to brute force closure */
|
||||||
|
closefrom_fallback(lowfd);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void
|
||||||
|
closefrom(int lowfd)
|
||||||
|
{
|
||||||
|
closefrom_fallback(lowfd);
|
||||||
}
|
}
|
||||||
#endif /* !HAVE_FCNTL_CLOSEM */
|
#endif /* !HAVE_FCNTL_CLOSEM */
|
||||||
#endif /* HAVE_CLOSEFROM */
|
#endif /* HAVE_CLOSEFROM */
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user