mirror of
https://github.com/tmux/tmux.git
synced 2026-03-11 11:05:46 +00:00
Compare commits
1630 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88c831af6e | ||
|
|
e254aeb9f9 | ||
|
|
1d4c54717c | ||
|
|
30b816f101 | ||
|
|
9803aee98e | ||
|
|
a34a72d2d9 | ||
|
|
4d80980e50 | ||
|
|
85152ef35c | ||
|
|
ebce251183 | ||
|
|
a3c1b730c9 | ||
|
|
a7b0b30bdd | ||
|
|
d4c2a935f2 | ||
|
|
cc967ffeb9 | ||
|
|
4bea559037 | ||
|
|
674de910ca | ||
|
|
5434a2759a | ||
|
|
b7551c9193 | ||
|
|
d4312281da | ||
|
|
d9eb34b28d | ||
|
|
b79189958f | ||
|
|
ad5c4e719b | ||
|
|
db7570daab | ||
|
|
60069fe8fe | ||
|
|
d817f88fec | ||
|
|
90b331ea46 | ||
|
|
e2d59a6c17 | ||
|
|
2ca1849350 | ||
|
|
e210abf335 | ||
|
|
f9b4095188 | ||
|
|
d1f0138653 | ||
|
|
9e7ec2e971 | ||
|
|
3a9a24a7c0 | ||
|
|
c1b9948525 | ||
|
|
76862acf3e | ||
|
|
f308663ad4 | ||
|
|
876f46abb9 | ||
|
|
620a87db25 | ||
|
|
08014af243 | ||
|
|
774bffb3c6 | ||
|
|
9c920214e6 | ||
|
|
5cc3d50289 | ||
|
|
9ec457575d | ||
|
|
398af28d2a | ||
|
|
8798079ab0 | ||
|
|
c26ec766cb | ||
|
|
c3794d4303 | ||
|
|
4fbb296438 | ||
|
|
21128fea1e | ||
|
|
693c106a1d | ||
|
|
046d8b096f | ||
|
|
0cbab892d5 | ||
|
|
b44f78fe9f | ||
|
|
3f5ec24b5a | ||
|
|
d8d9c2af98 | ||
|
|
cf317412d9 | ||
|
|
5213d9674b | ||
|
|
0e45ca1718 | ||
|
|
c1eeac86fe | ||
|
|
03ee7f7edf | ||
|
|
a8ca1340ad | ||
|
|
7d169a3679 | ||
|
|
98e500f598 | ||
|
|
1c1797e4f2 | ||
|
|
653d1e2fc8 | ||
|
|
9b48c77493 | ||
|
|
96146a8c6f | ||
|
|
7d53e2c946 | ||
|
|
213deb5c66 | ||
|
|
69c1521895 | ||
|
|
17e6dc4405 | ||
|
|
a7341715c1 | ||
|
|
521bf41d12 | ||
|
|
f0c3e9babe | ||
|
|
edd59d9e0f | ||
|
|
326c5bf1b4 | ||
|
|
550906cb09 | ||
|
|
175d82c95b | ||
|
|
3740f8f846 | ||
|
|
adfa5050d5 | ||
|
|
f62dcc1ea1 | ||
|
|
d6dc4c30f4 | ||
|
|
d635d79042 | ||
|
|
b8ce435a54 | ||
|
|
6e0c097d9f | ||
|
|
d9807eeba1 | ||
|
|
cb752f9938 | ||
|
|
2e98603db9 | ||
|
|
39628e8280 | ||
|
|
40af1a854c | ||
|
|
fb5b958837 | ||
|
|
99f78340af | ||
|
|
4a01da19df | ||
|
|
d390a90bf0 | ||
|
|
c41a93d130 | ||
|
|
0a4fd0f7a4 | ||
|
|
a54e670301 | ||
|
|
2651c0d69c | ||
|
|
87a2a13f68 | ||
|
|
5775074f73 | ||
|
|
abb4af7a14 | ||
|
|
b9bbe1d81c | ||
|
|
cd62411d78 | ||
|
|
e39c5a9e14 | ||
|
|
b2fe881307 | ||
|
|
b6659dc563 | ||
|
|
3ce1b91b1b | ||
|
|
2589d117b0 | ||
|
|
8aec4c93eb | ||
|
|
9960a06a67 | ||
|
|
0ecb11fe4f | ||
|
|
7d604ab717 | ||
|
|
ee5e97926d | ||
|
|
e9ebdac3dd | ||
|
|
5339b8ce3a | ||
|
|
20134fa9f4 | ||
|
|
1f01dd8c0a | ||
|
|
25eb48aea3 | ||
|
|
e5cee89727 | ||
|
|
d86c6b2fff | ||
|
|
5175db270d | ||
|
|
8d63a99390 | ||
|
|
f16b6aeabb | ||
|
|
df69ee07e2 | ||
|
|
31def00f59 | ||
|
|
27bd09f075 | ||
|
|
391f1f08c0 | ||
|
|
8357a55d76 | ||
|
|
5f38f8cd64 | ||
|
|
5ae4b4acc0 | ||
|
|
67e70770c8 | ||
|
|
bcacbb1a89 | ||
|
|
bba822105b | ||
|
|
dc2c174496 | ||
|
|
6c4166ce20 | ||
|
|
5dad3166f9 | ||
|
|
e80e7b38bb | ||
|
|
6457052a93 | ||
|
|
d91bf78e8a | ||
|
|
bc8d09ef84 | ||
|
|
8144e5cb7e | ||
|
|
fce026eb32 | ||
|
|
e097f0b4ee | ||
|
|
ff7343c203 | ||
|
|
3d47b5cd07 | ||
|
|
6ce5ed60a6 | ||
|
|
c80f75f4f4 | ||
|
|
4564624f2c | ||
|
|
84aa9c34f8 | ||
|
|
db7d3a3966 | ||
|
|
f513898e92 | ||
|
|
7407459ed1 | ||
|
|
fa0f10d77a | ||
|
|
ddade84e0a | ||
|
|
1cf916ca73 | ||
|
|
12544ccd41 | ||
|
|
dac6e55e0a | ||
|
|
213544a30a | ||
|
|
159faa4ed7 | ||
|
|
f9cb06cf2c | ||
|
|
28427efbac | ||
|
|
e14bf9bb8f | ||
|
|
d0f362a503 | ||
|
|
ea6844b5b7 | ||
|
|
def72b2985 | ||
|
|
a0b271a8a0 | ||
|
|
7a529cc32a | ||
|
|
f89d0c3c2c | ||
|
|
4bf85ecbb0 | ||
|
|
cae34a8ce7 | ||
|
|
07377d5a97 | ||
|
|
b5b630229a | ||
|
|
d256660a78 | ||
|
|
b2f301f4e2 | ||
|
|
719755574d | ||
|
|
89f35125b4 | ||
|
|
e7f3be9187 | ||
|
|
0cad8a5808 | ||
|
|
69e0aabcdf | ||
|
|
3cb428bc7e | ||
|
|
e0fcd3b247 | ||
|
|
21140d426d | ||
|
|
13d5ac6f9e | ||
|
|
1e7cea407d | ||
|
|
bb38112ec8 | ||
|
|
1d2b487c84 | ||
|
|
4efd45628d | ||
|
|
4fcbf4b872 | ||
|
|
046e8363b4 | ||
|
|
992dbdedd8 | ||
|
|
d344816d91 | ||
|
|
75e7c7eed5 | ||
|
|
4b6babcfa2 | ||
|
|
268a2efb16 | ||
|
|
b5812013ef | ||
|
|
a734b41fda | ||
|
|
4846af8f95 | ||
|
|
341f67e827 | ||
|
|
38611d3207 | ||
|
|
215ee46106 | ||
|
|
d5150484d1 | ||
|
|
656a668473 | ||
|
|
7aafee7e48 | ||
|
|
dc6bd98425 | ||
|
|
34a331aa99 | ||
|
|
6351940744 | ||
|
|
65fc8ef43a | ||
|
|
d5ab166307 | ||
|
|
a6456f4db3 | ||
|
|
dd34cc012a | ||
|
|
2c0846569d | ||
|
|
afbbdff581 | ||
|
|
cb60ea1bdb | ||
|
|
3aee28c58b | ||
|
|
088232e0e0 | ||
|
|
5e5acbeccd | ||
|
|
f0843d2173 | ||
|
|
457147d59d | ||
|
|
75f218dc73 | ||
|
|
1d00f88757 | ||
|
|
e5f4bf3f3e | ||
|
|
13c54a04a0 | ||
|
|
4e452a2e11 | ||
|
|
ae5954d30a | ||
|
|
01f5f041d3 | ||
|
|
d9cb059e34 | ||
|
|
ec3be580ec | ||
|
|
02462e5e57 | ||
|
|
ffce6b34b2 | ||
|
|
108fb38cbc | ||
|
|
0a2b3492c3 | ||
|
|
8ab7fcf7eb | ||
|
|
129f0dc893 | ||
|
|
2b508f7f6b | ||
|
|
536fc24653 | ||
|
|
95832241aa | ||
|
|
8091dcdd97 | ||
|
|
f8dbfb0aa7 | ||
|
|
b9216d9566 | ||
|
|
a9eb5e12ec | ||
|
|
164c2cbcb0 | ||
|
|
20e17604b5 | ||
|
|
a0295b4c2f | ||
|
|
9bc44043a4 | ||
|
|
d0cca3924e | ||
|
|
34bb013b92 | ||
|
|
4cb976b408 | ||
|
|
c0888f3fd1 | ||
|
|
9def6baaba | ||
|
|
c7624fd25d | ||
|
|
32de1d52ea | ||
|
|
677286bc0e | ||
|
|
19e81ffda5 | ||
|
|
d718a14bd0 | ||
|
|
04ce5cc2d1 | ||
|
|
065384056b | ||
|
|
3d7b8105e1 | ||
|
|
3b56ebce6d | ||
|
|
2ab568fa88 | ||
|
|
4e4568cade | ||
|
|
d0d1c0e486 | ||
|
|
d37650dc4f | ||
|
|
cf3b73167d | ||
|
|
5532615bc0 | ||
|
|
0fa8d18775 | ||
|
|
5cbdd84686 | ||
|
|
2be75a0129 | ||
|
|
ec3a764c76 | ||
|
|
e3defd9b25 | ||
|
|
1930181b18 | ||
|
|
332bfbf273 | ||
|
|
7a68cff1db | ||
|
|
6d9fe6c3aa | ||
|
|
c2ed0186de | ||
|
|
3866988f87 | ||
|
|
43f8d62f6a | ||
|
|
a880639f48 | ||
|
|
57eb948c48 | ||
|
|
6c3186a19a | ||
|
|
10a5a2175e | ||
|
|
be7cec5640 | ||
|
|
492e3aa437 | ||
|
|
6b19621112 | ||
|
|
324ffe20e9 | ||
|
|
38f169113e | ||
|
|
e34c6fd187 | ||
|
|
ac01c2025a | ||
|
|
e08a40be56 | ||
|
|
abd1f615b2 | ||
|
|
a7b6445cc3 | ||
|
|
96fe3b26c1 | ||
|
|
93fd9cc29d | ||
|
|
87841b4f91 | ||
|
|
676c62647c | ||
|
|
30f6d9b167 | ||
|
|
1cb579d0fd | ||
|
|
3d4ebeb1b0 | ||
|
|
0fc4353fb3 | ||
|
|
ca413cf270 | ||
|
|
b2b5d88f3f | ||
|
|
ecec113b63 | ||
|
|
0740d3dbb8 | ||
|
|
9301eeb4dd | ||
|
|
1df427bc7b | ||
|
|
219442cff7 | ||
|
|
3aaf5b9b1e | ||
|
|
b463d3de54 | ||
|
|
f705c0e013 | ||
|
|
11dcbd7556 | ||
|
|
03ec2482c9 | ||
|
|
a2387330ce | ||
|
|
3689640b4e | ||
|
|
36c7c7537a | ||
|
|
2bdae526ad | ||
|
|
69f6b23945 | ||
|
|
a0e7facee6 | ||
|
|
a24b67fc5a | ||
|
|
521247bedb | ||
|
|
9ad028e8ee | ||
|
|
d9c848d3a6 | ||
|
|
66fb24c3a5 | ||
|
|
d3c04b74ec | ||
|
|
09ef2c9f40 | ||
|
|
edc298d0a1 | ||
|
|
703baa8769 | ||
|
|
0d77e5e959 | ||
|
|
c120d09a5e | ||
|
|
3a0d40b84d | ||
|
|
234211a6f6 | ||
|
|
7ecbc18d5d | ||
|
|
dc7fb15251 | ||
|
|
ce79d6081f | ||
|
|
d5a63c21b4 | ||
|
|
b066ad0fd8 | ||
|
|
620b59e843 | ||
|
|
f71b3054cd | ||
|
|
60dd440082 | ||
|
|
f72f21951c | ||
|
|
67b333ec84 | ||
|
|
b9f36cc226 | ||
|
|
bbf44d6ff3 | ||
|
|
9ebee6aef8 | ||
|
|
095e1b410a | ||
|
|
210b4553a5 | ||
|
|
e0ad1e5706 | ||
|
|
436f3b357e | ||
|
|
ba89a048ed | ||
|
|
dcef4f8084 | ||
|
|
030d284006 | ||
|
|
1b037f74f4 | ||
|
|
750e6ad542 | ||
|
|
5f72510edf | ||
|
|
5d86284a1a | ||
|
|
3cd9ea1789 | ||
|
|
3585feca54 | ||
|
|
a373235106 | ||
|
|
9f3399da00 | ||
|
|
c05a47ad0d | ||
|
|
a932742a8a | ||
|
|
bb728b89a7 | ||
|
|
64d16cf2d6 | ||
|
|
b8eae3902b | ||
|
|
d1bdc9a161 | ||
|
|
cd92f44686 | ||
|
|
206ae727f9 | ||
|
|
5fcd6711e4 | ||
|
|
d227a2e661 | ||
|
|
0b8ce56d73 | ||
|
|
095ffe9cd1 | ||
|
|
1a4d78c7af | ||
|
|
286fef9b4d | ||
|
|
1891f1ce99 | ||
|
|
3ab25ac5b5 | ||
|
|
3a4f765a51 | ||
|
|
d0adcbc98a | ||
|
|
e75187310d | ||
|
|
7a0468c95c | ||
|
|
1b0d235e3a | ||
|
|
36e537bcef | ||
|
|
fd51bf61c9 | ||
|
|
fe4f760eba | ||
|
|
3a4b82d27a | ||
|
|
ccdafdabca | ||
|
|
39e277be3c | ||
|
|
1650155589 | ||
|
|
42327f06df | ||
|
|
1585b1e928 | ||
|
|
9ab191b053 | ||
|
|
13032d1d88 | ||
|
|
64387d18dd | ||
|
|
25bf0faf21 | ||
|
|
112fc58e6e | ||
|
|
ba68bed10e | ||
|
|
30e8ed393e | ||
|
|
a6fc49ae08 | ||
|
|
94c2adf499 | ||
|
|
9c541e42f0 | ||
|
|
96601ce9fe | ||
|
|
1cec111af3 | ||
|
|
ae7a7be819 | ||
|
|
58684ea998 | ||
|
|
914f8584ef | ||
|
|
2287ec7b3e | ||
|
|
8f84217023 | ||
|
|
83447580b1 | ||
|
|
1cd9ff4460 | ||
|
|
cd079e8fbf | ||
|
|
8703e9f2f9 | ||
|
|
2da0730f78 | ||
|
|
bdbd4e28c2 | ||
|
|
1276ea3653 | ||
|
|
f79b467dce | ||
|
|
d4b58c71a2 | ||
|
|
5fb4f8c1fa | ||
|
|
5a0ecc5931 | ||
|
|
e7a4b68f73 | ||
|
|
a7e5092bd4 | ||
|
|
b73ac822fb | ||
|
|
0ad532d9c2 | ||
|
|
b0ad6e94bb | ||
|
|
b2ae7c6261 | ||
|
|
6c9269baa7 | ||
|
|
45784bd5d6 | ||
|
|
b5349ab5d9 | ||
|
|
7874b00d4c | ||
|
|
6139fac10d | ||
|
|
d0d98d4ec0 | ||
|
|
29f04400b5 | ||
|
|
5126037ea0 | ||
|
|
d7a3fc3df4 | ||
|
|
59dc08a7a0 | ||
|
|
fe3621cbc5 | ||
|
|
89c07dedd9 | ||
|
|
28a0b6fd20 | ||
|
|
f54482a461 | ||
|
|
afcc29a51d | ||
|
|
33df467d40 | ||
|
|
510b43569f | ||
|
|
a8b22d3673 | ||
|
|
19923625d4 | ||
|
|
3b4d26d16b | ||
|
|
01052ca38e | ||
|
|
ee44a8dca9 | ||
|
|
89acd757d0 | ||
|
|
56040be346 | ||
|
|
e6bb3d6942 | ||
|
|
aba555509e | ||
|
|
c50c4ec834 | ||
|
|
9858071dd0 | ||
|
|
b0169d9b84 | ||
|
|
e34c6e2305 | ||
|
|
761bd3c9e3 | ||
|
|
5e9429e2d6 | ||
|
|
4387db506f | ||
|
|
d7bae0edce | ||
|
|
482bd7b65e | ||
|
|
f42364b4b5 | ||
|
|
5be8175b0b | ||
|
|
5576fe42b2 | ||
|
|
1944747759 | ||
|
|
28c4c86589 | ||
|
|
7ed9b0f8fb | ||
|
|
11497af4dd | ||
|
|
b0878774e0 | ||
|
|
e71f0842ce | ||
|
|
9b47a48393 | ||
|
|
0482983d53 | ||
|
|
2b512dc49d | ||
|
|
ae45c2ea45 | ||
|
|
11f81e8134 | ||
|
|
ad6a528f61 | ||
|
|
46f27eab22 | ||
|
|
e4703bacb5 | ||
|
|
e4573de97b | ||
|
|
63e76b555d | ||
|
|
13e7f060b1 | ||
|
|
fa34c76275 | ||
|
|
985cd3a4de | ||
|
|
03c1c1cd9f | ||
|
|
0e70c8801c | ||
|
|
617386370b | ||
|
|
bf1e237410 | ||
|
|
8d3b726396 | ||
|
|
47b335dee7 | ||
|
|
6c76724201 | ||
|
|
29434cb043 | ||
|
|
b7454e37cb | ||
|
|
e2a5e02022 | ||
|
|
cac532c3d1 | ||
|
|
e186450788 | ||
|
|
3e8092709c | ||
|
|
1b77ae2684 | ||
|
|
60134cebda | ||
|
|
f34861bad4 | ||
|
|
6503207185 | ||
|
|
3bba401609 | ||
|
|
31657820bc | ||
|
|
be3643fba0 | ||
|
|
f62d3d22bb | ||
|
|
67dc249d0e | ||
|
|
0778ef230b | ||
|
|
bebfd7c2c8 | ||
|
|
348c3e69de | ||
|
|
0d6a64070c | ||
|
|
bb4d770e45 | ||
|
|
e55a59eebc | ||
|
|
11cd05db27 | ||
|
|
6c6255f2d7 | ||
|
|
227e458ebb | ||
|
|
89eb95265a | ||
|
|
d98efa5378 | ||
|
|
a9c6976268 | ||
|
|
d9c99b83c7 | ||
|
|
d27956f160 | ||
|
|
e334deb872 | ||
|
|
e50dc0745f | ||
|
|
f11f71752a | ||
|
|
9e7a5fa5ef | ||
|
|
9c01a3d0db | ||
|
|
278effd7ea | ||
|
|
59c13133de | ||
|
|
41afc38dcc | ||
|
|
0beb31c261 | ||
|
|
6694a01861 | ||
|
|
9900e28ba8 | ||
|
|
fc69b9ccb7 | ||
|
|
d3dd6709bc | ||
|
|
3cded44623 | ||
|
|
50cad52ae6 | ||
|
|
701b5bdf61 | ||
|
|
4e120c00f7 | ||
|
|
7d4588f470 | ||
|
|
893be14cf8 | ||
|
|
342a47bc77 | ||
|
|
18ed37622e | ||
|
|
ec56ec7920 | ||
|
|
0c5a964e63 | ||
|
|
c4c542efb9 | ||
|
|
2bc150d16d | ||
|
|
7163907ab6 | ||
|
|
02fc1fe0da | ||
|
|
8e67b07489 | ||
|
|
0ed80637e7 | ||
|
|
b03418fc6b | ||
|
|
c0f03afbac | ||
|
|
0646b3caf2 | ||
|
|
b2e752b384 | ||
|
|
08632b4f0a | ||
|
|
10b73b7a11 | ||
|
|
cd0f22b96e | ||
|
|
610056abbe | ||
|
|
3743238a86 | ||
|
|
531db321e3 | ||
|
|
642f549e4d | ||
|
|
0fc65537a3 | ||
|
|
091db41bc9 | ||
|
|
67300e9524 | ||
|
|
f2a4ef5260 | ||
|
|
7dc1720522 | ||
|
|
07dcf8610f | ||
|
|
2d74ce1d3a | ||
|
|
5879e2a32b | ||
|
|
1392fba63d | ||
|
|
1c6ab725f5 | ||
|
|
4012917302 | ||
|
|
dd7abd9b4c | ||
|
|
51c776fe93 | ||
|
|
9382e546df | ||
|
|
659d15786a | ||
|
|
2307b91ecb | ||
|
|
a2c87eb899 | ||
|
|
33a90efc93 | ||
|
|
009d8d2ea7 | ||
|
|
aa8f9018ea | ||
|
|
4de04fac2c | ||
|
|
593bcbdd49 | ||
|
|
9f5b9ba0d6 | ||
|
|
b1a3090877 | ||
|
|
4271320bb7 | ||
|
|
51eab54102 | ||
|
|
51c135ed73 | ||
|
|
f6d36e60cf | ||
|
|
38bc7e87c5 | ||
|
|
95c6d9d31d | ||
|
|
3d85d2be6a | ||
|
|
6681db7af0 | ||
|
|
b90e869b8b | ||
|
|
de64913786 | ||
|
|
b34c8f5f39 | ||
|
|
70f5384d8f | ||
|
|
a2cd71ff03 | ||
|
|
990971f486 | ||
|
|
ce3fff4dbb | ||
|
|
1533930c11 | ||
|
|
14a5071ce0 | ||
|
|
c5fefd51af | ||
|
|
862b89b78b | ||
|
|
5920a55a87 | ||
|
|
b7d5b911ac | ||
|
|
8da8bc477f | ||
|
|
a0e7539743 | ||
|
|
f7ae833b6d | ||
|
|
8dcb62cd87 | ||
|
|
ecac081a55 | ||
|
|
b4c2710bf7 | ||
|
|
7da60e78c6 | ||
|
|
f7646d2738 | ||
|
|
3f44ab2f0f | ||
|
|
a9dacf10ce | ||
|
|
66c38d8c5d | ||
|
|
736764b560 | ||
|
|
a00a0cd0c1 | ||
|
|
3d99e261a1 | ||
|
|
2e6142ab84 | ||
|
|
10abdd97cf | ||
|
|
c3c65c32a5 | ||
|
|
36a80b2cd6 | ||
|
|
c6ba781379 | ||
|
|
9b57743cca | ||
|
|
ac8aa0bc0f | ||
|
|
3c37b09272 | ||
|
|
a32d095c97 | ||
|
|
676d0809d2 | ||
|
|
fa5be75396 | ||
|
|
d398bbc53b | ||
|
|
82ba7e69ec | ||
|
|
23fb261b85 | ||
|
|
0d5542e65e | ||
|
|
d6b5b644b8 | ||
|
|
b7758a9932 | ||
|
|
ebcc0ebd2d | ||
|
|
c4724c7861 | ||
|
|
998d76c6b4 | ||
|
|
495a3056e9 | ||
|
|
3116e3ce21 | ||
|
|
4e28426c0d | ||
|
|
9ea05dc2ba | ||
|
|
72dd70b0c0 | ||
|
|
5ef8689328 | ||
|
|
95dfa950b8 | ||
|
|
735cfaf09a | ||
|
|
0e320881d5 | ||
|
|
1a6cb5fd54 | ||
|
|
22dd0beaa0 | ||
|
|
c153a43299 | ||
|
|
0b05e6d8cb | ||
|
|
2305a27308 | ||
|
|
391b209008 | ||
|
|
c744964cd9 | ||
|
|
05e5bc7882 | ||
|
|
62822cc78d | ||
|
|
9a0571ff32 | ||
|
|
4d477aaeef | ||
|
|
64c26cf8ce | ||
|
|
dcfa183cfe | ||
|
|
21dc792395 | ||
|
|
f7cb814613 | ||
|
|
04b4ce8117 | ||
|
|
d5fb69b904 | ||
|
|
f772e1d362 | ||
|
|
2a2e24a177 | ||
|
|
dfc2ad1e5f | ||
|
|
38ee1e66aa | ||
|
|
796ae34f2f | ||
|
|
5483a460fd | ||
|
|
3abd4ca9a7 | ||
|
|
b4e50303ab | ||
|
|
4aa8284b39 | ||
|
|
22101e3fe3 | ||
|
|
a339427e45 | ||
|
|
7fdb647e19 | ||
|
|
da194cc435 | ||
|
|
f5dd79a01a | ||
|
|
4a6191c5d1 | ||
|
|
8212e76291 | ||
|
|
91b7db766c | ||
|
|
7c3d4e35d7 | ||
|
|
4d8d70a846 | ||
|
|
b8bc525afe | ||
|
|
106011aa53 | ||
|
|
97c40b1f37 | ||
|
|
027f5310b4 | ||
|
|
4b2e459062 | ||
|
|
13fbec2586 | ||
|
|
71e6b4d617 | ||
|
|
51a284e056 | ||
|
|
3cc7f2e191 | ||
|
|
f81b3ddf94 | ||
|
|
e447088a8a | ||
|
|
ad2767c7fb | ||
|
|
9fea75149a | ||
|
|
f4b9b84190 | ||
|
|
f9e513895c | ||
|
|
99075aaa72 | ||
|
|
de15f2b567 | ||
|
|
6f578a434b | ||
|
|
90d40e27da | ||
|
|
ef3e483a0d | ||
|
|
fcbf4ea2c0 | ||
|
|
243c63f867 | ||
|
|
7459be544e | ||
|
|
b70be285b7 | ||
|
|
dac1d365c0 | ||
|
|
dcdd2fb094 | ||
|
|
328861e330 | ||
|
|
39b1cdbdb9 | ||
|
|
3db559cf5a | ||
|
|
cc094fdfe6 | ||
|
|
1caa73afb4 | ||
|
|
ddb5bb80fa | ||
|
|
4ba8fce7ea | ||
|
|
1f7ac1e0cb | ||
|
|
8fffdd28fb | ||
|
|
59eaef6107 | ||
|
|
55f51c4949 | ||
|
|
c87379b04d | ||
|
|
97350cd883 | ||
|
|
5081d73330 | ||
|
|
b42f231027 | ||
|
|
dc57c5bb50 | ||
|
|
575510045a | ||
|
|
4c7b3a5906 | ||
|
|
91cf94b34b | ||
|
|
fabf40b3b3 | ||
|
|
66bf2e2f04 | ||
|
|
c12e0b0708 | ||
|
|
bbd9652d32 | ||
|
|
d9001ead7d | ||
|
|
d517ffe7c9 | ||
|
|
8ba590b473 | ||
|
|
635d36f928 | ||
|
|
5f366e6d54 | ||
|
|
a3024f3d2a | ||
|
|
399002baa4 | ||
|
|
809902226e | ||
|
|
45ac2cc4e7 | ||
|
|
727fdb44a0 | ||
|
|
3cb0c8e650 | ||
|
|
1a41a3b48f | ||
|
|
1527ed0ff8 | ||
|
|
bce5aedc64 | ||
|
|
1d58ca61a7 | ||
|
|
074780fea4 | ||
|
|
ec68dae252 | ||
|
|
7a9bfabf7a | ||
|
|
cbc7a23e33 | ||
|
|
f9451028c0 | ||
|
|
1feea926ed | ||
|
|
8512811535 | ||
|
|
224ae13ab0 | ||
|
|
5fd1cf743e | ||
|
|
563f34477a | ||
|
|
a5ae0dc216 | ||
|
|
a0b2b8e875 | ||
|
|
acc331c787 | ||
|
|
8777a809dc | ||
|
|
ec48709dc2 | ||
|
|
9829cfc8d2 | ||
|
|
4c2e037046 | ||
|
|
1c97866a5f | ||
|
|
063a474fe0 | ||
|
|
a7158784f2 | ||
|
|
e35f5b35bd | ||
|
|
fc6a835be8 | ||
|
|
ee9be88946 | ||
|
|
0bb00a0df3 | ||
|
|
72bc03ac4c | ||
|
|
56447d73c1 | ||
|
|
0986001908 | ||
|
|
2bd39071d3 | ||
|
|
ac6b1a817b | ||
|
|
ba832ff2c3 | ||
|
|
2ec5aca064 | ||
|
|
e8424d333e | ||
|
|
1b4a76d58f | ||
|
|
7230fe1648 | ||
|
|
60869fa4c3 | ||
|
|
ba7aa506f3 | ||
|
|
9817d41947 | ||
|
|
74e742113d | ||
|
|
e9b357550f | ||
|
|
38ac9bb414 | ||
|
|
c01816c26d | ||
|
|
36bb298bfa | ||
|
|
e275bc52f2 | ||
|
|
ef45c1c65b | ||
|
|
c202377859 | ||
|
|
34b4c2e607 | ||
|
|
dcb85fe4b1 | ||
|
|
8fe9ecae05 | ||
|
|
946337484e | ||
|
|
181e1cc711 | ||
|
|
f18b224983 | ||
|
|
7d288e7fd8 | ||
|
|
fb22aaf87f | ||
|
|
5ac6ea61bd | ||
|
|
66957412d5 | ||
|
|
ac6092c27f | ||
|
|
81336d6bb0 | ||
|
|
ab38d91913 | ||
|
|
915031b049 | ||
|
|
02438c01b7 | ||
|
|
bee17719d8 | ||
|
|
0cd4f4e321 | ||
|
|
3acb995ef3 | ||
|
|
40b6941c0f | ||
|
|
142962742c | ||
|
|
2df0882722 | ||
|
|
70b2f1981e | ||
|
|
cb0bf6a043 | ||
|
|
971a7b2fe0 | ||
|
|
7851bb81f5 | ||
|
|
53ef4c2bab | ||
|
|
5116aaa51a | ||
|
|
e41055c5aa | ||
|
|
dd36982ad5 | ||
|
|
5ce49941fb | ||
|
|
09c34be825 | ||
|
|
e4b743cced | ||
|
|
9128b7df7f | ||
|
|
90d4cbe67e | ||
|
|
625348122c | ||
|
|
27c2b98f5f | ||
|
|
344a241c28 | ||
|
|
fdda6ef8bd | ||
|
|
c78426f033 | ||
|
|
9e208584ed | ||
|
|
5be38f2b3a | ||
|
|
b7fc4f3760 | ||
|
|
bbad75fb6c | ||
|
|
a090b78e8d | ||
|
|
0a4d830ee1 | ||
|
|
f3b4b60aa8 | ||
|
|
012e7106de | ||
|
|
bbdf78cd97 | ||
|
|
6b4b4c78cf | ||
|
|
ee1cc9f415 | ||
|
|
053e40572c | ||
|
|
47f69075a0 | ||
|
|
b4beb1a5cb | ||
|
|
738489f2bb | ||
|
|
d57ba5e30b | ||
|
|
ca24e00d75 | ||
|
|
513c1cf0c7 | ||
|
|
d13d3a9902 | ||
|
|
c529c02ac0 | ||
|
|
745fd16452 | ||
|
|
f4514f5c60 | ||
|
|
a5acabd923 | ||
|
|
e65aa04ad7 | ||
|
|
d0afc47bfb | ||
|
|
ce743b2058 | ||
|
|
88bb9381b2 | ||
|
|
876ded6dfe | ||
|
|
5a4ba76293 | ||
|
|
31bb577075 | ||
|
|
10aab82539 | ||
|
|
1c4b7d33b1 | ||
|
|
8ff0d06d34 | ||
|
|
6cf9965e42 | ||
|
|
c45a56d66b | ||
|
|
a8300b7a44 | ||
|
|
98122860cc | ||
|
|
dd8174f545 | ||
|
|
5350212e53 | ||
|
|
4f7e669271 | ||
|
|
165538b4bd | ||
|
|
6338fd78f7 | ||
|
|
181f7722b3 | ||
|
|
41863470ba | ||
|
|
c4637da860 | ||
|
|
382aa8f6de | ||
|
|
a460e1ada3 | ||
|
|
aaef0d316f | ||
|
|
76bb6d6138 | ||
|
|
2536ea12cb | ||
|
|
cb3b0e661d | ||
|
|
2cee0139e4 | ||
|
|
132485a660 | ||
|
|
d55ee38c7f | ||
|
|
e214ea1c59 | ||
|
|
85ae64b981 | ||
|
|
4a87cef46f | ||
|
|
8c00dc2b6b | ||
|
|
38aa9a447a | ||
|
|
6dc796bb29 | ||
|
|
d8e566d0e9 | ||
|
|
5820efa513 | ||
|
|
e05fe0ba05 | ||
|
|
134a33f6e0 | ||
|
|
cc9ef11985 | ||
|
|
9ad2347258 | ||
|
|
dbefea339f | ||
|
|
9260888d1c | ||
|
|
eaa188bb63 | ||
|
|
dc8b7d6b03 | ||
|
|
84392ffc0d | ||
|
|
c6828bf32b | ||
|
|
31552722a8 | ||
|
|
d7d4d7830b | ||
|
|
dbf2351d3a | ||
|
|
9731625230 | ||
|
|
a572533c89 | ||
|
|
8ec8d1f32a | ||
|
|
21b23f8e54 | ||
|
|
fce889235c | ||
|
|
f41a3914a5 | ||
|
|
c643ac4827 | ||
|
|
97e02eae7d | ||
|
|
516bfe7ba3 | ||
|
|
9463492ac1 | ||
|
|
2f14ef61ff | ||
|
|
2e39ab59d7 | ||
|
|
ac4e4a2b6c | ||
|
|
13d1df659f | ||
|
|
4afecbe400 | ||
|
|
bb625a76d9 | ||
|
|
b027aa103c | ||
|
|
59269a431b | ||
|
|
c8f2584d87 | ||
|
|
24d7cf6618 | ||
|
|
1fdf489cae | ||
|
|
0614ca434a | ||
|
|
8085adb8a2 | ||
|
|
3d88da7b2a | ||
|
|
ee46dba585 | ||
|
|
a505ca69d9 | ||
|
|
428f76db80 | ||
|
|
b6ebf7cb60 | ||
|
|
6257be6371 | ||
|
|
9800dc4697 | ||
|
|
b8e4bd2029 | ||
|
|
941032b707 | ||
|
|
fe99f6fa11 | ||
|
|
6103628129 | ||
|
|
cbd3b1bc9b | ||
|
|
04db3c6211 | ||
|
|
858b8b190b | ||
|
|
7af01a4afb | ||
|
|
9e4a3d50f0 | ||
|
|
44fd6f4381 | ||
|
|
8ab3a3d9aa | ||
|
|
8bdcc10c8f | ||
|
|
6369fca253 | ||
|
|
9b771a96f0 | ||
|
|
f8f2421ac3 | ||
|
|
9e6d1b24c8 | ||
|
|
587e7127eb | ||
|
|
6b522bd770 | ||
|
|
edc901d107 | ||
|
|
e88a2ba7d4 | ||
|
|
629afba526 | ||
|
|
f92cc84631 | ||
|
|
6ea6d1b29f | ||
|
|
39afe3fc2a | ||
|
|
3584fa15ec | ||
|
|
6091b051fb | ||
|
|
a053aeddf8 | ||
|
|
50ece89ab9 | ||
|
|
197f8b88bf | ||
|
|
c8d0608369 | ||
|
|
1b03bc2404 | ||
|
|
b26ea8462e | ||
|
|
323469723b | ||
|
|
d7fa9bc056 | ||
|
|
256a55b33b | ||
|
|
53f1e6eed2 | ||
|
|
0b8a7dc4a2 | ||
|
|
cf9804f2a0 | ||
|
|
bc90c7c199 | ||
|
|
3e93bdf31b | ||
|
|
bc236109fd | ||
|
|
07ad6da7e8 | ||
|
|
ea1721bcb0 | ||
|
|
2486a36af3 | ||
|
|
6a1ebb11df | ||
|
|
1fd3a405e6 | ||
|
|
91e4dc83fc | ||
|
|
a4ea6a9d19 | ||
|
|
0e5f20a97d | ||
|
|
bc67e01e52 | ||
|
|
eba57d84a6 | ||
|
|
3d1936e9c7 | ||
|
|
932f0a757f | ||
|
|
cddb781127 | ||
|
|
220f3f2384 | ||
|
|
9ac062acef | ||
|
|
765a38e534 | ||
|
|
c2e78a3104 | ||
|
|
1eb665832a | ||
|
|
64e9d07b1b | ||
|
|
d23635f66d | ||
|
|
4640627f6e | ||
|
|
83bf166a1f | ||
|
|
f881502f84 | ||
|
|
32291172bf | ||
|
|
eb7f8b6d33 | ||
|
|
d8c0634524 | ||
|
|
11e97f4eb0 | ||
|
|
813d78e46a | ||
|
|
2931277608 | ||
|
|
6b3ec44ee9 | ||
|
|
19e502c64e | ||
|
|
a9a0cd8297 | ||
|
|
88c3b9c989 | ||
|
|
804b8696a4 | ||
|
|
b5d23ef38b | ||
|
|
c190a65c69 | ||
|
|
bf4b27e679 | ||
|
|
d73516c0a9 | ||
|
|
ac95da3afc | ||
|
|
5be3fb86b9 | ||
|
|
4dd332c95e | ||
|
|
fea7bda58f | ||
|
|
88f689e167 | ||
|
|
5743da5588 | ||
|
|
1310ea2729 | ||
|
|
2acf349d4e | ||
|
|
acedc2dcf2 | ||
|
|
c40d8cbda4 | ||
|
|
07bd160861 | ||
|
|
2c9d4dfdd4 | ||
|
|
df7b68480c | ||
|
|
31ccf2f813 | ||
|
|
480211f0ee | ||
|
|
59e65cbda2 | ||
|
|
649b7c132d | ||
|
|
b6bc8a6828 | ||
|
|
f2d249fdc7 | ||
|
|
c28d4e41cf | ||
|
|
1572e483c2 | ||
|
|
f8ea4f44e8 | ||
|
|
e3dcc5327a | ||
|
|
bd24bdd411 | ||
|
|
7335ef5792 | ||
|
|
3266fb5441 | ||
|
|
ab96772436 | ||
|
|
c7ace08193 | ||
|
|
f82598ca2d | ||
|
|
b29d4affd8 | ||
|
|
6594af3729 | ||
|
|
6df9ac7c37 | ||
|
|
73f58b90a0 | ||
|
|
23d7ed3187 | ||
|
|
a2e03ce3cb | ||
|
|
15b643fc11 | ||
|
|
150fba5ecd | ||
|
|
c507bf25de | ||
|
|
dbaa28492e | ||
|
|
960cd3da69 | ||
|
|
82d6bab57c | ||
|
|
24baf14e53 | ||
|
|
5fcf7149d4 | ||
|
|
4d4ec52df8 | ||
|
|
69e7f4af19 | ||
|
|
61990deb36 | ||
|
|
0ec1ce005c | ||
|
|
f0cb57d8ac | ||
|
|
930f67f474 | ||
|
|
1de812d5a8 | ||
|
|
c272de7cba | ||
|
|
5edc465802 | ||
|
|
ec195a4e15 | ||
|
|
bb2d57dcbf | ||
|
|
02c4760ace | ||
|
|
51a1f25247 | ||
|
|
895efe7b05 | ||
|
|
83f5581da4 | ||
|
|
884ebb6dab | ||
|
|
c274551db6 | ||
|
|
f796336a12 | ||
|
|
3b944fe7e8 | ||
|
|
afd0bd7cb0 | ||
|
|
a5c17d77bf | ||
|
|
d33caca6c7 | ||
|
|
c23bde74ec | ||
|
|
ecffcf1667 | ||
|
|
26682256b3 | ||
|
|
5838ee1263 | ||
|
|
b7cb7d10f9 | ||
|
|
521659db4b | ||
|
|
a3a150faf2 | ||
|
|
ce5c441f0f | ||
|
|
99de03ea32 | ||
|
|
d463eddb8b | ||
|
|
ed3535db8a | ||
|
|
2fe369831c | ||
|
|
86fb9737dc | ||
|
|
d15e88cb68 | ||
|
|
83e44c7d8e | ||
|
|
fde3bda453 | ||
|
|
1a5aba47c7 | ||
|
|
6b4ed722b1 | ||
|
|
1ce325b31e | ||
|
|
f5d38f2696 | ||
|
|
bd5b011ecd | ||
|
|
8fd77cbb5b | ||
|
|
c1653ff654 | ||
|
|
22b2b7c6c5 | ||
|
|
d5bc78d98b | ||
|
|
a3799e0350 | ||
|
|
35b926c445 | ||
|
|
2e2e762743 | ||
|
|
266c13df18 | ||
|
|
633e74ef80 | ||
|
|
1fa8a8f4a6 | ||
|
|
d07d18258b | ||
|
|
a004fc3592 | ||
|
|
4b883524d8 | ||
|
|
15556ad0d6 | ||
|
|
27c5df22cf | ||
|
|
03f4ab4bd5 | ||
|
|
f1c982608f | ||
|
|
c18e027ad5 | ||
|
|
dd9dd142c9 | ||
|
|
2f517111ef | ||
|
|
9311e4255e | ||
|
|
61c7bfc128 | ||
|
|
14eb6df45e | ||
|
|
698e003fcd | ||
|
|
cc2c061289 | ||
|
|
9d33b3f72a | ||
|
|
0027aa3d1e | ||
|
|
1292540bb5 | ||
|
|
4631c07483 | ||
|
|
d895d4a9f0 | ||
|
|
d3da62d53a | ||
|
|
b644b17599 | ||
|
|
36475f80e9 | ||
|
|
52b02850ca | ||
|
|
7ca3d7ac8e | ||
|
|
3756fce553 | ||
|
|
9386f640a5 | ||
|
|
bcfb4f2a07 | ||
|
|
aa7c0f1ce8 | ||
|
|
2a5f08c15a | ||
|
|
70fc085862 | ||
|
|
09cc530299 | ||
|
|
966818c23d | ||
|
|
7c9f827bfe | ||
|
|
2a300c6661 | ||
|
|
53570b1505 | ||
|
|
11f0f812c5 | ||
|
|
620402a833 | ||
|
|
3f7e2589cd | ||
|
|
ed26a1d3bb | ||
|
|
ae1debbc92 | ||
|
|
622e018570 | ||
|
|
a2a8518f74 | ||
|
|
7182f6d799 | ||
|
|
646d6a929c | ||
|
|
6f9a2ee50a | ||
|
|
98e9e09588 | ||
|
|
9541471f87 | ||
|
|
c1fee8793d | ||
|
|
e61ee94e26 | ||
|
|
9116905b24 | ||
|
|
64950f4524 | ||
|
|
8973af82c5 | ||
|
|
f415d43c3b | ||
|
|
8f9858ba2f | ||
|
|
ba42910595 | ||
|
|
78c789e1cb | ||
|
|
b5059bc8a4 | ||
|
|
05fe69eb92 | ||
|
|
06b3f49c49 | ||
|
|
1063e5d0e4 | ||
|
|
7f77c395e3 | ||
|
|
e2a18894b3 | ||
|
|
0714e41148 | ||
|
|
5cc971facd | ||
|
|
b402cef338 | ||
|
|
a9b6bfdddd | ||
|
|
a604dfbb97 | ||
|
|
e9d170176d | ||
|
|
304296972b | ||
|
|
d0eae2cbfd | ||
|
|
4d90ce7b40 | ||
|
|
48ede1a00a | ||
|
|
c261ae32d2 | ||
|
|
e8ea3ccd58 | ||
|
|
7bcd7c2752 | ||
|
|
7dbabe84e4 | ||
|
|
3dadb349eb | ||
|
|
e43ce15736 | ||
|
|
6297285527 | ||
|
|
2c863b9f2c | ||
|
|
221ce5afb3 | ||
|
|
1297c39a31 | ||
|
|
4c944910fa | ||
|
|
deac1fc188 | ||
|
|
29b1b2fb5e | ||
|
|
af3db9a4fe | ||
|
|
a26817d604 | ||
|
|
167a8c9edc | ||
|
|
97eb537f38 | ||
|
|
37b0bcd7c1 | ||
|
|
5b56ea1816 | ||
|
|
602aae7839 | ||
|
|
05eb4ece44 | ||
|
|
5840c3e13a | ||
|
|
cd5294dfb4 | ||
|
|
88b83be07b | ||
|
|
65a28912eb | ||
|
|
d8a2ceea43 | ||
|
|
c32ca6a8e6 | ||
|
|
c9f55c1063 | ||
|
|
1127a290f4 | ||
|
|
bd5cf2e809 | ||
|
|
9002e60adf | ||
|
|
bd2fe4ce9b | ||
|
|
e6d5633671 | ||
|
|
e098f7b285 | ||
|
|
3deb17e841 | ||
|
|
15f6a41a75 | ||
|
|
75b6736cf4 | ||
|
|
80196c9abc | ||
|
|
becdf220fd | ||
|
|
dcde77cd09 | ||
|
|
f03dd8d216 | ||
|
|
a5d55ba16d | ||
|
|
2936f4f32c | ||
|
|
e2686d8819 | ||
|
|
b2606c0421 | ||
|
|
e3e0d70c0e | ||
|
|
f42a0475e4 | ||
|
|
a834d037bc | ||
|
|
cccd072ed1 | ||
|
|
5f0e688b50 | ||
|
|
ec8930c144 | ||
|
|
3e46bcec93 | ||
|
|
5d13704e04 | ||
|
|
52f8578984 | ||
|
|
09c6432854 | ||
|
|
796bfbd7af | ||
|
|
56dd5dfff4 | ||
|
|
3eb77bf53f | ||
|
|
89826983eb | ||
|
|
697051d1fd | ||
|
|
67266dc25c | ||
|
|
817e93ac94 | ||
|
|
1650b8552f | ||
|
|
ec1396c9ee | ||
|
|
ec3dba01b2 | ||
|
|
8ce1f0b047 | ||
|
|
6fbfcfc0d7 | ||
|
|
5a9b7b230c | ||
|
|
522fc94d12 | ||
|
|
deaba44835 | ||
|
|
de7483a114 | ||
|
|
d9dcc5ed44 | ||
|
|
1c73e75982 | ||
|
|
920b9c5872 | ||
|
|
1880b83c37 | ||
|
|
46cb0de347 | ||
|
|
7562781c9d | ||
|
|
2a146852ef | ||
|
|
361801aaaa | ||
|
|
2aa4d47312 | ||
|
|
2dda197980 | ||
|
|
6043d9cf89 | ||
|
|
a3fc9dee32 | ||
|
|
d637cb33da | ||
|
|
f5c0695605 | ||
|
|
21130b0c49 | ||
|
|
a5ad186547 | ||
|
|
5e7a48a865 | ||
|
|
2386fa2355 | ||
|
|
723f363c07 | ||
|
|
a98dbb67b9 | ||
|
|
28cf7dc39e | ||
|
|
744ccb7cc9 | ||
|
|
db584544f4 | ||
|
|
f4718dcdf2 | ||
|
|
4ec1b5d4e2 | ||
|
|
6e0626d3af | ||
|
|
dd51dd14af | ||
|
|
7cd412dc57 | ||
|
|
1870b96578 | ||
|
|
2e4df706f6 | ||
|
|
1141acfd4c | ||
|
|
53c1b32e02 | ||
|
|
f2451c1e29 | ||
|
|
a551ff2b1b | ||
|
|
7174c76bf0 | ||
|
|
6708ad19c5 | ||
|
|
fb0301f8b8 | ||
|
|
c84145751a | ||
|
|
b72f9bea43 | ||
|
|
9c6fa90857 | ||
|
|
83d1f2b480 | ||
|
|
19aae6dbd8 | ||
|
|
aa3a262caa | ||
|
|
b6afa30c39 | ||
|
|
75a44d856e | ||
|
|
41207e4861 | ||
|
|
acdef09e00 | ||
|
|
d29b57f597 | ||
|
|
0237e1dafd | ||
|
|
a92993228f | ||
|
|
6a97901691 | ||
|
|
39aa8b32b1 | ||
|
|
1bf524c1b7 | ||
|
|
a734488a4b | ||
|
|
94e2339842 | ||
|
|
5263b3f61e | ||
|
|
962b9c6548 | ||
|
|
48c36d628a | ||
|
|
e2a80151ae | ||
|
|
2572c7139b | ||
|
|
e7cda4f363 | ||
|
|
54c6848d75 | ||
|
|
9a07e8f372 | ||
|
|
e8957009c7 | ||
|
|
62017452e9 | ||
|
|
16f424d25d | ||
|
|
95d593dd51 | ||
|
|
545893df73 | ||
|
|
680f2098f1 | ||
|
|
376c808b50 | ||
|
|
4cf6396e4c | ||
|
|
17170f5d6e | ||
|
|
19cb1fb592 | ||
|
|
c30fbd1d8d | ||
|
|
6bc9ee3420 | ||
|
|
4192449112 | ||
|
|
f1efd6b4e7 | ||
|
|
21cfef45d6 | ||
|
|
ae7dda10ce | ||
|
|
646632de1d | ||
|
|
770ea563ee | ||
|
|
946affe60d | ||
|
|
89543e999d | ||
|
|
fc17ce0150 | ||
|
|
441c118b63 | ||
|
|
ac55534055 | ||
|
|
821de39b27 | ||
|
|
ede2dd2d3a | ||
|
|
08d32a1522 | ||
|
|
d956ed0760 | ||
|
|
6fe25a08d7 | ||
|
|
222b8e6743 | ||
|
|
d6908dd9c2 | ||
|
|
ac2ab6501d | ||
|
|
8bfbc8c61d | ||
|
|
ff90170738 | ||
|
|
6ebb1df8fe | ||
|
|
ff500b46c9 | ||
|
|
72d56bd614 | ||
|
|
ad1945c278 | ||
|
|
82b45b460e | ||
|
|
1e574bb70c | ||
|
|
537c32b6b6 | ||
|
|
f44ae0535e | ||
|
|
910d6282c4 | ||
|
|
20e322bf9b | ||
|
|
edd3142d1f | ||
|
|
097b96ea44 | ||
|
|
5ccd0025a0 | ||
|
|
d358a352c0 | ||
|
|
e63567d51c | ||
|
|
f41ef2198b | ||
|
|
61bd3ae1c6 | ||
|
|
5ef5bd7c31 | ||
|
|
7f98193beb | ||
|
|
d2c3dbc665 | ||
|
|
2f75b07d08 | ||
|
|
280619a4e8 | ||
|
|
6db6df882c | ||
|
|
db411ca515 | ||
|
|
3fb3613d34 | ||
|
|
30f47dfc5e | ||
|
|
27fc963631 | ||
|
|
d8de72ca77 | ||
|
|
ef5f356da2 | ||
|
|
1919deab1f | ||
|
|
fd0971542f | ||
|
|
d7b4aa0ff3 | ||
|
|
79bc6041c9 | ||
|
|
8be8016a76 | ||
|
|
d4a143a425 | ||
|
|
bf0f56d04e | ||
|
|
0e7c6bdcc7 | ||
|
|
7e8ff69a14 | ||
|
|
eee3dd297e | ||
|
|
5afe17d147 | ||
|
|
664a0bd559 | ||
|
|
4422b958c3 | ||
|
|
295879cced | ||
|
|
e073441c36 | ||
|
|
27e9f77a49 | ||
|
|
f8ea82d7dc | ||
|
|
890db6eaaf | ||
|
|
99395856ff | ||
|
|
9cf68ac868 | ||
|
|
2ddcb51df3 | ||
|
|
9875be3327 | ||
|
|
a182502af0 | ||
|
|
86504af149 | ||
|
|
1825609d8d | ||
|
|
43ff216fa6 | ||
|
|
ff54332b66 | ||
|
|
84da2f32ec | ||
|
|
b7a272fe6d | ||
|
|
9e5a581307 | ||
|
|
f34f1fd78d | ||
|
|
a476d4c587 | ||
|
|
21f8ed50db | ||
|
|
b8bd24817f | ||
|
|
08c7249636 | ||
|
|
29ac832cb3 | ||
|
|
85dac1e378 | ||
|
|
1f1623e04d | ||
|
|
3c0500f282 | ||
|
|
9f0653386b | ||
|
|
ec818b8791 | ||
|
|
81f06ba170 | ||
|
|
851a35eb5e | ||
|
|
8f2950f4ee | ||
|
|
e0a6376690 | ||
|
|
1903756171 | ||
|
|
81010f52db | ||
|
|
22d1b9412e | ||
|
|
d50810267e | ||
|
|
82b070ddfa | ||
|
|
55f8219d3c | ||
|
|
35092835b0 | ||
|
|
8fe3f1dcb2 | ||
|
|
eed4f7600d | ||
|
|
503c6a3377 | ||
|
|
18ebc99906 | ||
|
|
edc2e7da98 | ||
|
|
796b2e3ec9 | ||
|
|
1fb3948ff1 | ||
|
|
1496aa5dbc | ||
|
|
6ce734cec0 | ||
|
|
826add53f1 | ||
|
|
1aaf47e698 | ||
|
|
de2ea2d178 | ||
|
|
3fcbe1e27b | ||
|
|
81b4aca934 | ||
|
|
63753735ec | ||
|
|
32312e0252 | ||
|
|
802e129fd7 | ||
|
|
f1463ff3c1 | ||
|
|
0af7fa08d2 | ||
|
|
20002ec6cd | ||
|
|
8fc34ca044 | ||
|
|
a9e3d5c56a | ||
|
|
bb459beb03 | ||
|
|
8df98d1f5b | ||
|
|
6cde05147e | ||
|
|
8565ae234b | ||
|
|
3eb1bfddd4 | ||
|
|
a5830b9603 | ||
|
|
f17a5f1e82 | ||
|
|
bfa46e8f91 | ||
|
|
f0bcbcfa7f | ||
|
|
1b9ac18565 | ||
|
|
582660bdf3 | ||
|
|
62822b1848 | ||
|
|
abb5e36199 | ||
|
|
947fabc751 | ||
|
|
a03ae97fbf | ||
|
|
3ec8efc803 | ||
|
|
f7a9eb46fc | ||
|
|
853ad68162 | ||
|
|
e6e1b45fa1 | ||
|
|
944520b3a8 | ||
|
|
942ea4267d | ||
|
|
245685433e | ||
|
|
7eff7f7629 | ||
|
|
cd5a4f4c35 | ||
|
|
7be69bfa03 | ||
|
|
6f4600c533 | ||
|
|
fbcee9f114 | ||
|
|
0e95769b43 | ||
|
|
b9155e835a | ||
|
|
f90450f854 | ||
|
|
418128bebc | ||
|
|
63b38ef628 | ||
|
|
1b245388b5 | ||
|
|
cd71a13a14 | ||
|
|
4eed190649 | ||
|
|
c3c14817c9 | ||
|
|
b8ec0c713f | ||
|
|
93631b3ca7 | ||
|
|
49477de55c | ||
|
|
dff949747c | ||
|
|
7597cb6834 | ||
|
|
4f2e5f8c50 | ||
|
|
28bcf774e5 | ||
|
|
1e06ec41dc | ||
|
|
0828e06ad7 | ||
|
|
d3d4bacd82 | ||
|
|
94f5ddb60c | ||
|
|
658659532a | ||
|
|
6528d47ed8 | ||
|
|
5b3db7b56c | ||
|
|
3d7cf00359 | ||
|
|
e2a0c5ad7a | ||
|
|
32398b98a8 | ||
|
|
0fdd47660a | ||
|
|
6208128fa2 | ||
|
|
940e2ae1fd | ||
|
|
144aed48fa | ||
|
|
f63f5e6489 | ||
|
|
17a6c01d58 | ||
|
|
8536ad0ce7 | ||
|
|
3a55871d04 | ||
|
|
cd4566cd69 | ||
|
|
133539a2d4 | ||
|
|
89404788c9 | ||
|
|
6c442c19ba | ||
|
|
a8ec5f1d09 | ||
|
|
eb6007102e | ||
|
|
cdce5f739d | ||
|
|
5707eb3256 | ||
|
|
6db7bd6791 | ||
|
|
5db59a0d20 | ||
|
|
80af85a102 | ||
|
|
a385f75792 | ||
|
|
0abd8ea84f | ||
|
|
72e464fa04 | ||
|
|
c21ffbc772 | ||
|
|
6e4b947d71 | ||
|
|
3ee4b334e7 | ||
|
|
404411f5e7 | ||
|
|
d601c42ea2 | ||
|
|
b233616853 | ||
|
|
5518b6138d | ||
|
|
ab4e5e8574 | ||
|
|
b6b00c53bd | ||
|
|
2f5c3d881d | ||
|
|
a03cf0e183 | ||
|
|
d2275f4abf | ||
|
|
0c33b73db0 | ||
|
|
8dc73f2df5 | ||
|
|
6805217783 | ||
|
|
0f5168f971 | ||
|
|
c111310600 | ||
|
|
d58bfe5f0a | ||
|
|
095f16d64f | ||
|
|
25911d32e1 | ||
|
|
1001902143 | ||
|
|
03af7c99b5 | ||
|
|
92de1ad6c8 | ||
|
|
0b54a2d723 | ||
|
|
8913d853e4 | ||
|
|
cba338ac13 | ||
|
|
8931f0018a | ||
|
|
b476fab34d | ||
|
|
96ca072482 | ||
|
|
cc59ee4e6a | ||
|
|
dd2f8d7d74 | ||
|
|
4b64bd7b01 | ||
|
|
c495337e76 | ||
|
|
cae92a2041 | ||
|
|
5adb342147 | ||
|
|
3b0bd5a3e6 | ||
|
|
6099a3399e | ||
|
|
1a86934e09 | ||
|
|
626fe978e1 | ||
|
|
99dee98a2b | ||
|
|
db7357fdcc | ||
|
|
5436f6be19 | ||
|
|
1b70993207 | ||
|
|
a8fe667267 | ||
|
|
9ff8c354ab | ||
|
|
de79ce38a5 | ||
|
|
6c27e434c6 | ||
|
|
41fb824cbe | ||
|
|
ab5273d9a9 | ||
|
|
488a67e5a3 | ||
|
|
df9a2886dd | ||
|
|
4337a9b2d5 | ||
|
|
78f6b511fd | ||
|
|
522bf77cf4 | ||
|
|
f1bd3807ae | ||
|
|
c8cf438d44 | ||
|
|
e1b4a37722 | ||
|
|
792aeb926e | ||
|
|
88daeb5410 | ||
|
|
83d984eca8 | ||
|
|
b21e356e56 | ||
|
|
525bd431b2 | ||
|
|
143aa718e5 | ||
|
|
59a5728527 | ||
|
|
54a5f82588 | ||
|
|
fb543c7707 | ||
|
|
9164dd63e7 | ||
|
|
827fac4c0b | ||
|
|
044e6f7660 | ||
|
|
a6f2d82335 | ||
|
|
4a74349ff5 | ||
|
|
a583bbb730 | ||
|
|
631f81f519 | ||
|
|
5732d666a1 | ||
|
|
eccaaeee6e | ||
|
|
cdf472f2de | ||
|
|
a3f7928084 | ||
|
|
38a33addf7 | ||
|
|
71a903d4be | ||
|
|
91241f1457 | ||
|
|
ce989a91d1 | ||
|
|
8aa72ac803 | ||
|
|
2b967aa1d2 | ||
|
|
74dfb503a8 | ||
|
|
3085ca7153 | ||
|
|
cc9cc1aea8 | ||
|
|
323b7cbfbe | ||
|
|
f0a716f484 | ||
|
|
cd214f8f6a | ||
|
|
7c5f1af26f | ||
|
|
53dc88e276 | ||
|
|
6b148c8dce | ||
|
|
6317046bd1 | ||
|
|
5d1b6888dc | ||
|
|
1f2d9e64bb | ||
|
|
d8a35ffa50 | ||
|
|
850965584e | ||
|
|
ddf2efe57b | ||
|
|
e397e3a5f8 | ||
|
|
c80ad456cc | ||
|
|
058772e4e6 | ||
|
|
7d6896ae79 | ||
|
|
5fbdca890a | ||
|
|
a91ecf44fa | ||
|
|
f8771a538e | ||
|
|
ba3ad75002 | ||
|
|
22b44cbb2b |
493
CHANGES
493
CHANGES
@@ -1,3 +1,488 @@
|
|||||||
|
CHANGES FROM 1.5 TO 1.6, 23 January 2012
|
||||||
|
|
||||||
|
* Extend the mode-mouse option to add a third choice which means the mouse
|
||||||
|
does not enter copy mode.
|
||||||
|
* Add a -r flag to switch-client to toggle the client read-only flag.
|
||||||
|
* Add pane-base-index option.
|
||||||
|
* Support \ for line continuation in the configuration file.
|
||||||
|
* Framework for more powerful formatting of command output and use it for
|
||||||
|
list-{panes,windows,sessions}. This allows more descriptive replacements
|
||||||
|
(such as #{session_name}) and conditionals.
|
||||||
|
* Mark dead panes with some text saying they are dead.
|
||||||
|
* Reject $SHELL if it is not a full path.
|
||||||
|
* Add -S option to refresh-client to redraw status line.
|
||||||
|
* Add an else clause for if-shell.
|
||||||
|
* Try to resolve relative paths for loadb and saveb (first, using client
|
||||||
|
working directory, if any, then default-path or session working directory).
|
||||||
|
* Support for \e[3J to clear the history and send the corresponding
|
||||||
|
terminfo code (E3) before locking.
|
||||||
|
* When in copy mode, make repeat count indicate buffer to replace, if used.
|
||||||
|
* Add screen*:XT to terminal-overrides for tmux-in-tmux.
|
||||||
|
* Status-line message attributes added.
|
||||||
|
* Move word-separators to be a session rather than window option.
|
||||||
|
* Change the way the working directory for new processes is discovered. If
|
||||||
|
default-path isn't empty, it is used. Otherwise, if a new window is created
|
||||||
|
from the command-line, the working directory of the client is used. If not,
|
||||||
|
platform specific code is used to retrieve the current working directory
|
||||||
|
of the process in the active pane. If that fails, the directory where the
|
||||||
|
session was created is used, instead.
|
||||||
|
* Do not change the current pane if both mouse-select-{pane,window} are
|
||||||
|
enabled.
|
||||||
|
* Add \033[s and \033[u to save and restore cursor position.
|
||||||
|
* Allow $HOME to be used as default-path.
|
||||||
|
* Add CNL and CPL escape sequences.
|
||||||
|
* Calculate last position correctly for UTF-8 wide characters.
|
||||||
|
* Add an option allow-rename to disable the window rename escape sequence.
|
||||||
|
* Attributes for each type of status-line alert (ie bell, content and
|
||||||
|
activity) added. Therefore, remove the superfluous options
|
||||||
|
window-status-alert-{attr,bg,fg}.
|
||||||
|
* Add a -R flag to send-keys to reset the terminal.
|
||||||
|
* Add strings to allow the aixterm bright colours to be used when
|
||||||
|
configuring colours.
|
||||||
|
* Drop the ability to have a list of keys in the prefix in favour of two
|
||||||
|
separate options, prefix and prefix2.
|
||||||
|
* Flag -2 added to send-prefix to send the secondary prefix key.
|
||||||
|
* Show pane size in top right of display panes mode.
|
||||||
|
* Some memory leaks plugged.
|
||||||
|
* More command-prompt editing improvements.
|
||||||
|
* Various manpage improvements.
|
||||||
|
* More Vi mode improvements.
|
||||||
|
|
||||||
|
CHANGES FROM 1.4 TO 1.5, 09 July 2011
|
||||||
|
|
||||||
|
* Support xterm mouse modes 1002 and 1003.
|
||||||
|
* Change from a per-session stack of buffers to one global stack. This renders
|
||||||
|
copy-buffer useless and makes buffer-limit now a server option.
|
||||||
|
* Fix most-recently-used choice by avoiding reset the activity timer for
|
||||||
|
unattached sessions every second.
|
||||||
|
* Add a -P option to new-window and split-window to print the new window or
|
||||||
|
pane index in target form (useful to pass it into other commands).
|
||||||
|
* Handle a # at the end of a replacement string (such as status-left)
|
||||||
|
correctly.
|
||||||
|
* Support for UTF-8 mouse input (\033[1005h) which was added in xterm 262.
|
||||||
|
If the new mouse-utf8 option is on, UTF-8 mouse input is enabled for all
|
||||||
|
UTF-8 terminals. The option defaults to on if LANG etc are set in the same
|
||||||
|
manner as the utf8 option.
|
||||||
|
* Support for HP-UX.
|
||||||
|
* Accept colours of the hex form #ffffff and translate to the nearest from the
|
||||||
|
xterm(1) 256-colour set.
|
||||||
|
* Clear the non-blocking IO flag (O_NONBLOCK) on the stdio file descriptors
|
||||||
|
before closing them (fixes things like "tmux ls && cat").
|
||||||
|
* Use TMPDIR if set.
|
||||||
|
* Fix next and previous session functions to actually work.
|
||||||
|
* Support -x and -y for new-session to specify the initial size of the window
|
||||||
|
if created detached with -d.
|
||||||
|
* Make bind-key accept characters with the top-bit-set and print them as octal.
|
||||||
|
* Set $TMUX without the session when background jobs are run.
|
||||||
|
* Simplify the way jobs work and drop the persist type, so all jobs are
|
||||||
|
fire-and-forget.
|
||||||
|
* Accept tcgetattr/tcsetattr(3) failure, fixes problems with fatal() if the
|
||||||
|
terminal disappears while locked.
|
||||||
|
* Add a -P option to detach to HUP the client's parent process (usually causing
|
||||||
|
it to exit as well).
|
||||||
|
* Support passing through escape sequences to the underlying terminal by using
|
||||||
|
DCS with a "tmux;" prefix.
|
||||||
|
* Prevent tiled producing a corrupt layout when only one column is needed.
|
||||||
|
* Give each pane created in a tmux server a unique id (starting from 0), put it
|
||||||
|
in the TMUX_PANE environment variable and accept it as a target.
|
||||||
|
* Allow a start and end line to be specified for capture-pane which may be
|
||||||
|
negative to capture part of the history.
|
||||||
|
* Add -a and -s options to lsp to list all panes in the server or session
|
||||||
|
respectively. Likewise add -s to lsw.
|
||||||
|
* Change -t on display-message to be target-pane for the #[A-Z] replacements
|
||||||
|
and add -c as target-client.
|
||||||
|
* The attach-session command now prefers the most recently used unattached
|
||||||
|
session.
|
||||||
|
* Add -s option to detach-client to detach all clients attached to a session.
|
||||||
|
* Add -t to list-clients.
|
||||||
|
* Change window with mouse wheel over status line if mouse-select-window is on.
|
||||||
|
* When mode-mouse is on, automatically enter copy mode when the mouse is
|
||||||
|
dragged or the mouse wheel is used. Also exit copy mode when the mouse wheel
|
||||||
|
is scrolled off the bottom.
|
||||||
|
* Provide #h character pair for short hostname (no domain).
|
||||||
|
* Don't use strnvis(3) for the title as it breaks UTF-8.
|
||||||
|
* Use the tsl and fsl terminfo(5) capabilities to update terminal title and
|
||||||
|
automatically fill them in on terminals with the XT capability (which means
|
||||||
|
their title setting is xterm-compatible).
|
||||||
|
* Add a new option, mouse-resize-pane. When on, panes may be resized by
|
||||||
|
dragging their borders.
|
||||||
|
* Fix crash by resetting last pane on {break,swap}-pane across windows.
|
||||||
|
* Add three new copy-mode commands - select-line, copy-line, copy-end-of-line.
|
||||||
|
* Support setting the xterm clipboard when copying from copy mode using the
|
||||||
|
xterm escape sequence for the purpose (if xterm is configured to allow it).
|
||||||
|
* Support xterm(1) cursor colour change sequences through terminfo(5) Cc
|
||||||
|
(set) and Cr (reset) extensions.
|
||||||
|
* Support DECSCUSR sequence to set the cursor style with two new terminfo(5)
|
||||||
|
extensions, Cs and Csr.
|
||||||
|
* Make the command-prompt custom prompts recognize the status-left option
|
||||||
|
character pairs.
|
||||||
|
* Add a respawn-pane command.
|
||||||
|
* Add a couple of extra xterm-style keys that gnome terminal provides.
|
||||||
|
* Allow the initial context on prompts to be set with the new -I option to
|
||||||
|
command-prompt. Include the current window and session name in the prompt
|
||||||
|
when renaming and add a new key binding ($) for rename session.
|
||||||
|
* Option bell-on-alert added to trigger the terminal bell when there is an
|
||||||
|
alert.
|
||||||
|
* Change the list-keys format so that it shows the keys using actual tmux
|
||||||
|
commands which should be able to be directly copied into the config file.
|
||||||
|
* Show full targets for lsp/lsw -a.
|
||||||
|
* Make confirm-before prompt customizable with -p option like command-prompt
|
||||||
|
and add the character pairs #W and #P to the default kill-{pane,window}
|
||||||
|
prompts.
|
||||||
|
* Avoid sending data to suspended/locked clients.
|
||||||
|
* Small memory leaks in error paths plugged.
|
||||||
|
* Vi mode improvements.
|
||||||
|
|
||||||
|
CHANGES FROM 1.3 TO 1.4, 27 December 2010
|
||||||
|
|
||||||
|
* Window bell reporting fixed.
|
||||||
|
* Show which pane is active in the list-panes output.
|
||||||
|
* Backoff reworked.
|
||||||
|
* Prevent the server from dying when switching into copy mode when already
|
||||||
|
in a different mode.
|
||||||
|
* Reset running jobs when the status line is enabled or disabled.
|
||||||
|
* Simplify xterm modifier detection.
|
||||||
|
* Avoid crashing in copy mode if the screen size is too small for the
|
||||||
|
indicator.
|
||||||
|
* Flags -n and -p added to switch-client.
|
||||||
|
* Use UTF-8 line drawing characters on UTF-8 terminals, thus fixing some
|
||||||
|
terminals (eg putty) which disable the vt100 ACS mode switching sequences
|
||||||
|
in UTF-8 mode. On terminals without ACS, use ASCII equivalents.
|
||||||
|
* New server option exit-unattached added.
|
||||||
|
* New session option destroy-unattached added.
|
||||||
|
* Fall back on normal session choice method if $TMUX exists but is invalid
|
||||||
|
rather than rejecting.
|
||||||
|
* Mark repeating keys with "(repeat)" in the key list.
|
||||||
|
* When removing a pane, don't change the active pane unless the active pane
|
||||||
|
is actually the one being removed.
|
||||||
|
* New command last-pane added.
|
||||||
|
* AIX fixes.
|
||||||
|
* Flag -a added to unbind-key.
|
||||||
|
* Add XAUTHORITY to update-environment.
|
||||||
|
* More info regarding window and pane flags is now shown in list-*.
|
||||||
|
* If VISUAL or EDITOR contains "vi" configure mode-keys and status-key to vi.
|
||||||
|
* New window option monitor-silence and session option visual-silence added.
|
||||||
|
* In the built-in layouts distribute the panes more evenly.
|
||||||
|
* Set the default value of main-pane-width to 80 instead of 81.
|
||||||
|
* Command-line flag -V added.
|
||||||
|
* Instead of keeping a per-client prompt history make it global.
|
||||||
|
* Fix rectangle copy to behave like emacs (the cursor is not part of the
|
||||||
|
selection on the right edge but on the left it is).
|
||||||
|
* Flag -l added to switch-client.
|
||||||
|
* Retrieve environment variables from the global environment rather than
|
||||||
|
getenv(3), thus allowing them to be updated during the configuration file.
|
||||||
|
* New window options other-pane-{height,width} added.
|
||||||
|
* More minor bugs fixed and manpage improvements.
|
||||||
|
|
||||||
|
CHANGES FROM 1.2 TO 1.3, 18 July 2010
|
||||||
|
|
||||||
|
* New input parser.
|
||||||
|
* Flags to move through panes -UDLR added to select-pane.
|
||||||
|
* Commands up-pane, and down-pane removed, since equivalent behaviour is now
|
||||||
|
available through the target flag (-t:+ and -t:-).
|
||||||
|
* Jump-forward/backward in copy move (based on vi's F, and f commands).
|
||||||
|
* Make paste-buffer accept a pane as a target.
|
||||||
|
* Flag -a added to new-window to insert a window after an existing one, moving
|
||||||
|
windows up if necessary.
|
||||||
|
* Merge more mode into copy mode.
|
||||||
|
* Run job commands explicitly in the global environment (which can be modified
|
||||||
|
with setenv -g), rather than with the environment tmux started with.
|
||||||
|
* Use the machine's hostname as the default title, instead of an empty string.
|
||||||
|
* Prevent double free if the window option remain-on-exit is set.
|
||||||
|
* Key string conversions rewritten.
|
||||||
|
* Mark zombie windows as dead in the choose-window list.
|
||||||
|
* Tiled layout added.
|
||||||
|
* Signal handling reworked.
|
||||||
|
* Reset SIGCHLD after fork to fix problems with some shells.
|
||||||
|
* Select-prompt command removed. Therefore, bound ' to command-prompt -p index
|
||||||
|
"select-window -t:%%" by default.
|
||||||
|
* Catch SIGHUP and terminate if running as a client, thus avoiding clients from
|
||||||
|
being left hanging around when, for instance, a SSH session is disconnected.
|
||||||
|
* Solaris 9 fixes (such as adding compat {get,set}env(3) code).
|
||||||
|
* Accept none instead of default for attributes.
|
||||||
|
* Window options window-status-alert-{alert,bg,fg} added.
|
||||||
|
* Flag -s added to the paste-buffer command to specify a custom separator.
|
||||||
|
* Allow dragging to make a selection in copy mode if the mode-mouse option is
|
||||||
|
set.
|
||||||
|
* Support the mouse scroll wheel.
|
||||||
|
* Make pipe-pane accept special character sequences (eg #I).
|
||||||
|
* Fix problems with window sizing when starting tmux from .xinitrc.
|
||||||
|
* Give tmux sockets (but not the containing folder) group permissions.
|
||||||
|
* Extend the target flags (ie -t) to accept an offset (for example -t:+2), and
|
||||||
|
make it wrap windows, and panes.
|
||||||
|
* New command choose-buffer added.
|
||||||
|
* New server option detach-on-destroy to set what happens to a client when the
|
||||||
|
session it is attached to is destroyed. If on (default), the client is
|
||||||
|
detached. Otherwise, the client is switched to the most recently active of
|
||||||
|
the remaining sessions.
|
||||||
|
* The commands load-buffer, and save-buffer now accept a dash (-) as the file
|
||||||
|
to read from stdin, or write to stdout.
|
||||||
|
* Custom layouts added.
|
||||||
|
* Additional code reduction, bug fixes, and manpage enhancements.
|
||||||
|
|
||||||
|
CHANGES FROM 1.1 TO 1.2, 10 March 2010
|
||||||
|
|
||||||
|
* Switch to libevent.
|
||||||
|
* Emulate the ri (reverse index) capability, ergo allowing tmux to at least
|
||||||
|
start on Sun consoles (TERM=sun, or sun-color).
|
||||||
|
* Assign each entry a number, or lowercase letter in choose mode, and accept
|
||||||
|
that as a shortcut key.
|
||||||
|
* Permit top-bit-set characters to be entered in the status line.
|
||||||
|
* Mark no-prefix keys with (no prefix), rather than [] in list-keys.
|
||||||
|
* New command show-messages (alias showmsgs), and new session option
|
||||||
|
message-limit, to show a per-client log of status lines messages up to the
|
||||||
|
number defined by message-limit.
|
||||||
|
* Do not interpret #() for display-message to avoid leaking commands.
|
||||||
|
* New window options window-status-format, and window-status-current-format to
|
||||||
|
control the format of each window in the status line.
|
||||||
|
* Add a -p flag to display-message to print the output, instead of displaying
|
||||||
|
it in the status line.
|
||||||
|
* Emulate il1, dl1, ich1 to run with vt100 feature set.
|
||||||
|
* New command capture-pane (alias capturep) to copy the entire pane contents
|
||||||
|
to a paste buffer.
|
||||||
|
* Avoid duplicating code by adding a -w flag to set-option, and show-options to
|
||||||
|
set, and show window options. The commands set-window-option, and
|
||||||
|
show-window-options are now aliases.
|
||||||
|
* Panes can now be referred to as top, bottom, top-left, etc.
|
||||||
|
* Add server-wide options, which can be set with set-option -s, and shown with
|
||||||
|
show-options -s.
|
||||||
|
* New server option quiet (like -q from the command line).
|
||||||
|
* New server option escape-time to set the timeout used to detect if escapes
|
||||||
|
are alone, part of a function key, or meta sequence.
|
||||||
|
* New session options pane-active-border-bg, pane-active-border-fg,
|
||||||
|
pane-border-bg, and pane-border-fg to set pane colours.
|
||||||
|
* Make split-window accept a pane target, instead of a window.
|
||||||
|
* New command join-pane (alias joinp) to split, and move an existing pane into
|
||||||
|
the space (the opposite of break-pane), thus simplifying calls to
|
||||||
|
split-window, followed by move-window.
|
||||||
|
* Permit S- prefix on keys for shift when the terminal/terminfo supports them.
|
||||||
|
* Window targets (-t flag) can now refer to the last window (!), next (+), and
|
||||||
|
previous (-) window by number.
|
||||||
|
* Mode keys to jump to the bottom/top of history, end of the next word, scroll
|
||||||
|
up/down, and reverse search in copy mode.
|
||||||
|
* New session option display-panes-active-colour to display the active pane in
|
||||||
|
a different colour with the display-panes command.
|
||||||
|
* Read the socket path from $TMUX if it's present, and -L, and -S are not
|
||||||
|
given.
|
||||||
|
* Vi-style mode keys B, W, and E to navigate between words in copy mode.
|
||||||
|
* Start in more mode when configuration file errors are detected.
|
||||||
|
* Rectangle copy support added.
|
||||||
|
* If attach-session was specified with the -r flag, make the client read-only.
|
||||||
|
* Per-window alternate-screen option.
|
||||||
|
* Make load-buffer work with FIFOs.
|
||||||
|
* New window option word-separators to set the characters considered as word
|
||||||
|
separators in copy mode.
|
||||||
|
* Permit keys in copy mode to be prefixed by a repeat count, entered with [1-9]
|
||||||
|
in vi mode, or M-[1-9] in emacs mode.
|
||||||
|
* utf8 improvements.
|
||||||
|
* As usual, additional code reduction, bug fixes, and manpage enhancements.
|
||||||
|
|
||||||
|
CHANGES FROM 1.0 TO 1.1, 05 November 2009
|
||||||
|
|
||||||
|
* New run-shell (alias run) command to run an external command without a
|
||||||
|
window, capture it's stdout, and send it to output mode.
|
||||||
|
* Ability to define multiple prefix keys.
|
||||||
|
* Internal locking mechanism removed. Instead, detach each client and run the
|
||||||
|
external command specified in the new session option lock-command (by default
|
||||||
|
lock -np), thus allowing the system password to be used.
|
||||||
|
* set-password command, and -U command line flag removed per the above change.
|
||||||
|
* Add support for -c command line flag to execute a shell command.
|
||||||
|
* New lock-client (alias lockc), and lock-session (alias locks) commands to
|
||||||
|
lock a particular client, or all clients attached to a session.
|
||||||
|
* Support C-n/C-p/C-v/M-v with emacs keys in choice mode.
|
||||||
|
* Use : for goto line rather than g in vi mode.
|
||||||
|
* Try to guess which client to use when no target client was specified. Finds
|
||||||
|
the current session, and if only one client is present, use it. Otherwise,
|
||||||
|
return the most recently used client.
|
||||||
|
* Make C-Down/C-Up in copy mode scroll the screen down/up one line without
|
||||||
|
moving the cursor.
|
||||||
|
* Scroll mode superseded by copy mode.
|
||||||
|
* New synchronize-panes window option to send all input to all other panes in
|
||||||
|
the same window.
|
||||||
|
* New lock-server session option to lock, when off (on by default), each
|
||||||
|
session when it has been idle for the lock-after-time setting. When on, the
|
||||||
|
entire server locks when all sessions have been idle for their individual
|
||||||
|
lock-after-time setting.
|
||||||
|
* Add support for grouped sessions which have independent name, options,
|
||||||
|
current window, but where the linked windows are synchronized (ie creating,
|
||||||
|
killing windows are mirrored between the sessions). A grouped session may be
|
||||||
|
created by passing -t to new-session.
|
||||||
|
* New mouse-select-pane session option to select the current pane with the
|
||||||
|
mouse.
|
||||||
|
* Queue, and run commands in the background for if-shell, status-left,
|
||||||
|
status-right, and #() by starting each once every status-interval. Adds the
|
||||||
|
capability to call some programs which would previously cause the server to
|
||||||
|
hang (eg sleep/tmux). It also avoids running commands excessively (ie if used
|
||||||
|
multiple times, it will be run only once).
|
||||||
|
* When a window is zombified and automatic-rename is on, append [dead] to the
|
||||||
|
name.
|
||||||
|
* Split list-panes (alias lsp) off from list-windows.
|
||||||
|
* New pipe-pane (alias pipep) to redirect a pane output to an external command.
|
||||||
|
* Support for automatic-renames for Solaris.
|
||||||
|
* Permit attributes to be turned off in #[] by prefixing with no (eg nobright).
|
||||||
|
* Add H/M/L in vi mode, and M-R/M-r in emacs to move the cursor to the top,
|
||||||
|
middle, and bottom of the screen.
|
||||||
|
* -a option added to kill-pane to kill all except current pane.
|
||||||
|
* The -d command line flag is now gone (can be replaced by terminal-overrides).
|
||||||
|
Just use op/AX to detect default colours.
|
||||||
|
* input/tty/utf8 improvements.
|
||||||
|
* xterm-keys rewrite.
|
||||||
|
* Additional code reduction, and bug fixes.
|
||||||
|
|
||||||
|
CHANGES FROM 0.9 TO 1.0, 20 Sept 2009
|
||||||
|
|
||||||
|
* Option to alter the format of the window title set by tmux.
|
||||||
|
* Backoff for a while after multiple incorrect password attempts.
|
||||||
|
* Quick display of pane numbers (C-b q).
|
||||||
|
* Better choose-window, choose-session commands and a new choose-client command.
|
||||||
|
* Option to request multiple responses when using command-prompt.
|
||||||
|
* Improved environment handling.
|
||||||
|
* Combine wrapped lines when pasting.
|
||||||
|
* Option to override terminal settings (terminal-overrides).
|
||||||
|
* Use the full range of ACS characters for drawing pane separator lines.
|
||||||
|
* Customisable mode keys.
|
||||||
|
* Status line colour options, with embedded colours in status-left/right, and
|
||||||
|
an option to centre the window list.
|
||||||
|
* Much improved layouts, including both horizontal and vertical splitting.
|
||||||
|
* Optional visual bell, activity and content indications.
|
||||||
|
* Set the utf8 and status-utf8 options when the server is started with -u.
|
||||||
|
* display-message command to show a message in the status line, by default some
|
||||||
|
information about the current window.
|
||||||
|
* Improved current process detection on NetBSD.
|
||||||
|
* unlink-window -k is now the same as kill-window.
|
||||||
|
* attach-session now works from inside tmux.
|
||||||
|
* A system-wide configuration file, /etc/tmux.conf.
|
||||||
|
* A number of new commands in copy mode, including searching.
|
||||||
|
* Panes are now specified using the target (-t) notation.
|
||||||
|
* -t now accepts fnmatch(3) patterns and looks for prefixes.
|
||||||
|
* Translate \r into \n when pasting.
|
||||||
|
* Support for binding commands to keys without the prefix key
|
||||||
|
* Support for alternate screen (terminfo smcup/rmcup).
|
||||||
|
* Maintain data that goes off screen after reducing the window size, so it can
|
||||||
|
be restored when the size is increased again.
|
||||||
|
* New if-shell command to test a shell command before running a tmux command.
|
||||||
|
* tmux now works as the shell.
|
||||||
|
* Man page reorganisation.
|
||||||
|
* Many minor additions, much code tidying and several bug fixes.
|
||||||
|
|
||||||
|
CHANGES FROM 0.8 TO 0.9, 01 July 2009
|
||||||
|
|
||||||
|
* Major changes to build infrastructure: cleanup of makefiles and addition
|
||||||
|
of a configure script.
|
||||||
|
* monitor-content window option to monitor a window for a specific fnmatch(3)
|
||||||
|
pattern. The find-window command also now accepts fnmatch(3) patterns.
|
||||||
|
* previous-layout and select-layout commands, and a main-horizontal layout.
|
||||||
|
* Recreate the server socket on SIGUSR1.
|
||||||
|
* clear-history command.
|
||||||
|
* Use ACS line drawing characters for pane separator lines.
|
||||||
|
* UTF-8 improvements, and code to detect UTF-8 support by looking at
|
||||||
|
environment variables.
|
||||||
|
* The resize-pane-up and resize-pane-down commands are now merged together
|
||||||
|
into a new resize-pane command with -U and -D flags.
|
||||||
|
* confirm-before command to request a yes/no answer before executing dangerous
|
||||||
|
commands.
|
||||||
|
* Status line bug fixes, support for UTF-8 (status-utf8 option), and a key to
|
||||||
|
paste from the paste buffer.
|
||||||
|
* Support for some additional escape sequences and terminal features, including
|
||||||
|
better support for insert mode and tab stops.
|
||||||
|
* Improved window resizing behaviour, modelled after xterm.
|
||||||
|
* Some code reduction and a number of miscellaneous bug fixes.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
On 01 June 2009, tmux was imported into the OpenBSD base system. From this date
|
||||||
|
onward changes are logged as part of the normal CVS commit message to either
|
||||||
|
OpenBSD or SourceForge CVS. This file will be updated to contain a summary of
|
||||||
|
major changes with each release, and to mention important configuration or
|
||||||
|
command syntax changes during development.
|
||||||
|
|
||||||
|
The list of older changes is below.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
21 May 2009
|
||||||
|
|
||||||
|
* stat(2) files before trying to load them to avoid problems, for example
|
||||||
|
with "source-file /dev/zero".
|
||||||
|
|
||||||
|
19 May 2009
|
||||||
|
|
||||||
|
* Try to guess if the window is UTF-8 by outputting a three-byte UTF-8 wide
|
||||||
|
character and seeing how much the cursor moves. Currently tries to figure out
|
||||||
|
if this works by some stupid checks on the terminal, these need to be
|
||||||
|
rethought. Also might be better using a width 1 character rather than width 2.
|
||||||
|
* If LANG contains "UTF-8", assume the terminal supports UTF-8, on the grounds
|
||||||
|
that anyone who configures it probably wants UTF-8. Not certain if this is
|
||||||
|
a perfect idea but let's see if it causes any problems.
|
||||||
|
* New window option: monitor-content. Searches for a string in a window and if
|
||||||
|
it matches, highlight the status line.
|
||||||
|
|
||||||
|
18 May 2009
|
||||||
|
|
||||||
|
* main-horizontal layout and main-pane-height option to match vertical.
|
||||||
|
* New window option main-pane-width to set the width of the large left pane with
|
||||||
|
main-vertical (was left-vertical) layout.
|
||||||
|
* Lots of layout cleanup. manual layout is now manual-vertical.
|
||||||
|
|
||||||
|
16 May 2009
|
||||||
|
|
||||||
|
* select-layout command and a few default key bindings (M-0, M-1, M-2, M-9) to
|
||||||
|
select layouts.
|
||||||
|
* Recreate server socket on SIGUSR1, per SF feature request 2792533.
|
||||||
|
|
||||||
|
14 May 2009
|
||||||
|
|
||||||
|
* Keys in status line (p in vi mode, M-y in emacs) to paste the first line
|
||||||
|
of the upper paste buffer. Suggested by Dan Colish.
|
||||||
|
* clear-history command to clear a pane's history.
|
||||||
|
* Don't force wrapping with \n when asked, let the cursor code figure it out.
|
||||||
|
Should fix terminals which use this to detect line breaks.
|
||||||
|
* Major cleanup and restructuring of build infrastructure. Still separate files
|
||||||
|
for GNU and BSD make, but they are now hugely simplified at the expense of
|
||||||
|
adding a configure script which must be run before make. Now build and
|
||||||
|
install with:
|
||||||
|
|
||||||
|
$ ./configure && make && sudo make install
|
||||||
|
|
||||||
|
04 May 2009
|
||||||
|
|
||||||
|
* Use ACS line drawing characters for pane separator lines.
|
||||||
|
|
||||||
|
30 April 2009
|
||||||
|
|
||||||
|
* Support command sequences without a space before the semicolon, for example
|
||||||
|
"neww; neww" now works as well as "neww ; neww". "neww;neww" is still an
|
||||||
|
error.
|
||||||
|
* previous-layout command.
|
||||||
|
* Display the layout name in window lists.
|
||||||
|
* Merge resize-pane-up and resize-pane-down into resize-pane with -U and -D
|
||||||
|
flags.
|
||||||
|
|
||||||
|
29 April 2009
|
||||||
|
|
||||||
|
* Get rid of compat/vis.* - only one function was used which is easily
|
||||||
|
replaced,and less compat code == good.
|
||||||
|
|
||||||
|
27 April 2009
|
||||||
|
|
||||||
|
* Avoid using the prompt history when the server is locked, and prevent any
|
||||||
|
input entered from being added to the client's prompt history.
|
||||||
|
* New command, confirm-before (alias confirm), which asks for confirmation
|
||||||
|
before executing a command. Bound "&" and "x" by default to confirm-before
|
||||||
|
"kill-window" and confirm-before "kill-pane", respectively.
|
||||||
|
|
||||||
|
23 April 2009
|
||||||
|
|
||||||
|
* Support NEL, yet another way of making newline. Fixes the output from some
|
||||||
|
Gentoo packaging thing. Reported by someone on SF then logs that allowed a
|
||||||
|
fix sent by tcunha.
|
||||||
|
* Use the xenl terminfo flag to detect early-wrap terminals like the FreeBSD
|
||||||
|
console. Many thanks for a very informative email from Christian Weisgerber.
|
||||||
|
|
||||||
|
21 April 2009
|
||||||
|
|
||||||
|
* tmux 0.8 released.
|
||||||
|
|
||||||
17 April 2009
|
17 April 2009
|
||||||
|
|
||||||
* Remove the right number of characters from the buffer when escape then
|
* Remove the right number of characters from the buffer when escape then
|
||||||
@@ -247,7 +732,7 @@
|
|||||||
18 January 2009
|
18 January 2009
|
||||||
|
|
||||||
* Unbreak UTF-8.
|
* Unbreak UTF-8.
|
||||||
* -a flag to next-window and previous-window to select the next or previous
|
* -a flag to next-window and previous-window to select the next or previous
|
||||||
window with activity or bell. Bound to M-n and M-p.
|
window with activity or bell. Bound to M-n and M-p.
|
||||||
* find-window command to search window names, titles and visible content (but
|
* find-window command to search window names, titles and visible content (but
|
||||||
not history) for a string. If only one is found, the window is selected
|
not history) for a string. If only one is found, the window is selected
|
||||||
@@ -332,7 +817,7 @@
|
|||||||
|
|
||||||
* Vertical window splitting. Currently can only split a window into two panes.
|
* Vertical window splitting. Currently can only split a window into two panes.
|
||||||
New split-window command splits (bound to ") and switch-pane command (bound to
|
New split-window command splits (bound to ") and switch-pane command (bound to
|
||||||
o) switches between panes.
|
o) switches between panes.
|
||||||
|
|
||||||
close-pane, swap-pane commands are to follow. Also to come are pane resizing,
|
close-pane, swap-pane commands are to follow. Also to come are pane resizing,
|
||||||
>2 panes, the ability to break a pane out to a full window and vice versa and
|
>2 panes, the ability to break a pane out to a full window and vice versa and
|
||||||
@@ -351,7 +836,7 @@
|
|||||||
|
|
||||||
* New option, lock-after-time. If there is no activity in the period specified
|
* New option, lock-after-time. If there is no activity in the period specified
|
||||||
by this option (in seconds), tmux will lock the server. Default is 1800 (30
|
by this option (in seconds), tmux will lock the server. Default is 1800 (30
|
||||||
minutes), set to 0 to disable.
|
minutes), set to 0 to disable.
|
||||||
* Server locking. Two new commands: set-password to set a password (a
|
* Server locking. Two new commands: set-password to set a password (a
|
||||||
preencrypted password may be specified with -c); and lock-server to lock the
|
preencrypted password may be specified with -c); and lock-server to lock the
|
||||||
server until the password is entered. Also an additional command line flag,
|
server until the password is entered. Also an additional command line flag,
|
||||||
@@ -1204,7 +1689,7 @@
|
|||||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||||
customisation.
|
customisation.
|
||||||
|
|
||||||
$Id: CHANGES,v 1.272 2009-04-17 12:36:21 nicm Exp $
|
$Id$
|
||||||
|
|
||||||
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
|
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
|
||||||
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
|
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
|
||||||
|
|||||||
326
FAQ
326
FAQ
@@ -1,33 +1,115 @@
|
|||||||
tmux frequently asked questions
|
tmux frequently asked questions
|
||||||
|
|
||||||
* How is tmux different from GNU screen? What else does it offer?
|
******************************************************************************
|
||||||
|
* 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. *
|
||||||
|
******************************************************************************
|
||||||
|
|
||||||
tmux offers several advantages over screen:
|
* How is tmux different from GNU screen?
|
||||||
|
|
||||||
- a clearly-defined client-server model: windows are independent entities which
|
tmux and GNU screen have many similarities. Some of the main differences I am
|
||||||
may be attached simultaneously to multiple sessions and viewed from multiple
|
aware of are (bearing in mind I haven't used screen for a few years now):
|
||||||
clients (terminals), as well as moved freely between sessions within the same
|
|
||||||
tmux server;
|
|
||||||
- a consistent, well-documented command interface, with the same syntax
|
|
||||||
whether used interactively, as a key binding, or from the shell;
|
|
||||||
- easily scriptable from the shell;
|
|
||||||
- multiple paste buffers;
|
|
||||||
- choice of vi or emacs key layouts;
|
|
||||||
- an option to limit the window size;
|
|
||||||
- a more usable status line syntax, with the ability to display the first line
|
|
||||||
of output of a specific command;
|
|
||||||
- a cleaner, modern, easily extended, BSD-licensed codebase.
|
|
||||||
|
|
||||||
There are still a few features screen includes that tmux omits:
|
- 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).
|
||||||
|
|
||||||
- builtin serial and telnet support; this is bloat and is unlikely to be added
|
This has advantages, notably: windows may be linked simultaneously to
|
||||||
to tmux;
|
multiple sessions; windows may be moved freely between sessions; and a client
|
||||||
- wider platform support, for example IRIX and HP-UX, and for odd terminals.
|
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.
|
||||||
|
|
||||||
|
- screen has support for updating utmp. Nobody has really come up with a clean,
|
||||||
|
portable way to do this without making tmux setuid or setgid yet.
|
||||||
|
|
||||||
|
- 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?
|
* I found a bug! What do I do?
|
||||||
|
|
||||||
Please send bug reports by email to nicm@users.sourceforge.net. Please
|
Please send bug reports by email to nicm@users.sourceforge.net or
|
||||||
include as much of the following information as possible:
|
tmux-users@lists.sourceforge.net. Please include as much of the following
|
||||||
|
information as possible:
|
||||||
|
|
||||||
- the version of tmux you are running;
|
- the version of tmux you are running;
|
||||||
- the operating system you are using and its version;
|
- the operating system you are using and its version;
|
||||||
@@ -42,16 +124,17 @@ include as much of the following information as possible:
|
|||||||
|
|
||||||
Please send feature requests by email to nicm@users.sourceforge.net.
|
Please send feature requests by email to nicm@users.sourceforge.net.
|
||||||
|
|
||||||
* Why do you use the screen termcap inside tmux? It sucks.
|
* 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
|
It is already widely available. It is planned to change to something else such
|
||||||
such as xterm-color at some point, if possible.
|
as xterm-xfree86 at some point, if possible.
|
||||||
|
|
||||||
* I don't see any colour in my terminal! Help!
|
* I don't see any colour in my terminal! Help!
|
||||||
|
|
||||||
On some platforms, common termcaps such as xterm do not include colour. screen
|
On some platforms, common terminal descriptions such as xterm do not include
|
||||||
ignores this, tmux does not. If the terminal emulator in use supports colour,
|
colour. screen ignores this, tmux does not. If the terminal emulator in use
|
||||||
use a termcap which correctly lists this, such as xterm-color.
|
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
|
* tmux freezes my terminal when I attach to a session. I even have to kill -9
|
||||||
the shell it was started from to recover!
|
the shell it was started from to recover!
|
||||||
@@ -81,23 +164,31 @@ default) to the new key. For example:
|
|||||||
|
|
||||||
* How do I use UTF-8?
|
* How do I use UTF-8?
|
||||||
|
|
||||||
When running tmux in a UTF-8 capable terminal, two things must be done to
|
When running tmux in a UTF-8 capable terminal, UTF-8 must be turned on in tmux;
|
||||||
enable support. UTF-8 must be turned on in tmux; this may be done separately
|
as of release 0.9, tmux attempts to autodetect a UTF-8-capable terminal by
|
||||||
for each tmux window or globally by setting the "utf8" flag:
|
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:
|
||||||
|
|
||||||
setw -g utf8 on
|
$ tmux -u new
|
||||||
|
|
||||||
And, as it is not possible to automatically detect that a terminal is UTF-8
|
Since the 1.0 release, tmux will turn on UTF-8 related options automatically
|
||||||
capable, tmux must be told by passing the -u flag when creating or
|
(ie status-utf8, and utf8) if the above conditions are met.
|
||||||
attaching a client to a tmux session:
|
|
||||||
|
|
||||||
$ tmux -u new
|
|
||||||
|
|
||||||
* How do I use a 256 colour terminal?
|
* How do I use a 256 colour terminal?
|
||||||
|
|
||||||
tmux will attempt to detect a 256 colour terminal both by looking at the Co
|
Provided the underlying terminal supports 256 colours, it is usually sufficient
|
||||||
termcap entry and, as this is broken for some terminals such as xterm-256color,
|
to add the following to ~/.tmux.conf:
|
||||||
by looking for the string "256col" in the termcap name.
|
|
||||||
|
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
|
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.
|
to a session to indicate the terminal supports 256 colours.
|
||||||
@@ -105,22 +196,18 @@ to a session to indicate the terminal supports 256 colours.
|
|||||||
* vim or $otherprogram doesn't display 256 colours. What's up?
|
* 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
|
Some programs attempt to detect the number of colours a terminal is capable of
|
||||||
by checking the Co termcap entry. However, this is not reliable, and in any
|
by checking the colors terminfo or Co termcap entry. However, this is not
|
||||||
case is missing from the "screen" termcap used inside tmux.
|
reliable, and in any case is missing from the "screen" terminal description
|
||||||
|
used inside tmux.
|
||||||
|
|
||||||
There are three options to allow programs to recognise they are running on
|
There are two options (aside from using "screen-256color") to allow programs to
|
||||||
a 256-colour terminal inside tmux:
|
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
|
- 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
|
screen. For vim, you can do this by overriding the t_Co option, see
|
||||||
http://vim.wikia.com/wiki/256_colors_in_vim.
|
http://vim.wikia.com/wiki/256_colors_in_vim.
|
||||||
- If the platform includes it, using the "screen-256color" termcap (set
|
- Creating a custom terminfo file that includes colors#256 in ~/.terminfo and
|
||||||
TERM=screen-256color). "infocmp screen-256color" can be used to check if this
|
using it instead. These may be compiled with tic(1).
|
||||||
is supported. It is not currently possible to set this globally inside tmux
|
|
||||||
but it may be done in a shell startup script by checking if TERM is screen
|
|
||||||
and exporting TERM=screen-256color instead.
|
|
||||||
- Creating a custom terminfo file that includes Co#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?
|
* How do I make Ctrl-PgUp and Ctrl-PgDn work in vim?
|
||||||
|
|
||||||
@@ -149,6 +236,8 @@ 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
|
it may be possible to configure vim to accept these, an example of how to do so
|
||||||
would be welcome.
|
would be welcome.
|
||||||
|
|
||||||
|
vim users may also want to set the "ttyfast" option inside tmux.
|
||||||
|
|
||||||
* Why doesn't elinks set the window title inside tmux?
|
* 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
|
There isn't a way to detect if a terminal supports setting the window title, so
|
||||||
@@ -186,4 +275,139 @@ 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
|
if this is a problem, turn it off with "setw -g automatic-rename off". If this
|
||||||
doesn't fix it, please report the problem.
|
doesn't fix it, please report the problem.
|
||||||
|
|
||||||
$Id: FAQ,v 1.21 2009-03-31 23:17:28 nicm Exp $
|
* 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'
|
||||||
|
|
||||||
|
* How can I open a new window in the same directory as the current window?
|
||||||
|
|
||||||
|
One option is to just run "TMUX= tmux" in the window. However, this only works if no
|
||||||
|
command is running, so that you can input the command.
|
||||||
|
|
||||||
|
A workaround is to let tmux know about the current path through an environment
|
||||||
|
variable. To do so, use the following command:
|
||||||
|
|
||||||
|
[ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I") $PWD
|
||||||
|
|
||||||
|
Which sets TMUXPWD_i (where i is the number of the current window) to the path
|
||||||
|
of the current directory. This command can be added to PS1, for example:
|
||||||
|
|
||||||
|
PS1='$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I") $PWD)\h$ '
|
||||||
|
|
||||||
|
When a new window is created, the shell should be asked to change
|
||||||
|
directory. You can define a new binding (for example, if using GNU bash):
|
||||||
|
|
||||||
|
bind-key C-c run-shell 'tmux neww "cd $(tmux display -p "\$TMUXPWD_#I"); exec bash"'
|
||||||
|
|
||||||
|
This solution will work even if a command is currently running in the terminal,
|
||||||
|
but it will not work from a window that has just been swapped with another
|
||||||
|
because TMUXPWD_i will not be updated after a swap. However, once a new prompt
|
||||||
|
is displayed, TMUXPWD_i is updated properly.
|
||||||
|
|
||||||
|
* tmux doesn't start with "daemon failed"
|
||||||
|
|
||||||
|
tmux shows something similar to this when started:
|
||||||
|
|
||||||
|
fatal: server_start: daemon failed: No such file or directory
|
||||||
|
fatal: main_dispatch: imsg_read failed
|
||||||
|
|
||||||
|
A possible reason is that /dev/null is not a character device or is otherwise
|
||||||
|
inaccessible.
|
||||||
|
|
||||||
|
Check with:
|
||||||
|
|
||||||
|
file /dev/null
|
||||||
|
ls -l /dev/null
|
||||||
|
|
||||||
|
If it is not a character device or has incorrect permissions, it can typically
|
||||||
|
be recreated with:
|
||||||
|
|
||||||
|
cd /dev && rm null && ./MAKEDEV null
|
||||||
|
|
||||||
|
* vim displays reverse video instead of italics, while less displays italics
|
||||||
|
(or just regular text) instead of reverse. What's wrong?
|
||||||
|
|
||||||
|
Screen's terminfo description lacks italics mode and has standout mode in its
|
||||||
|
place, but using the same escape sequence that urxvt uses for italics. This
|
||||||
|
means applications (like vim) looking for italics will not find it and might
|
||||||
|
turn to reverse in its place, while applications (like less) asking for
|
||||||
|
standout will end up with italics instead of reverse. To make applications
|
||||||
|
aware that tmux supports italics and to use a proper escape sequence for
|
||||||
|
standout, you'll need to create a new terminfo file with modified sgr, smso,
|
||||||
|
rmso, sitm and ritm entries:
|
||||||
|
|
||||||
|
$ mkdir $HOME/.terminfo/
|
||||||
|
$ screen_terminfo="screen"
|
||||||
|
$ infocmp "$screen_terminfo" | sed \
|
||||||
|
-e 's/^screen[^|]*|[^,]*,/screen-it|screen with italics support,/' \
|
||||||
|
-e 's/%?%p1%t;3%/%?%p1%t;7%/' \
|
||||||
|
-e 's/smso=[^,]*,/smso=\\E[7m,/' \
|
||||||
|
-e 's/rmso=[^,]*,/rmso=\\E[27m,/' \
|
||||||
|
-e '$s/$/ sitm=\\E[3m, ritm=\\E[23m,/' > /tmp/screen.terminfo
|
||||||
|
$ tic /tmp/screen.terminfo
|
||||||
|
|
||||||
|
And tell tmux to use it in ~/.tmux.conf:
|
||||||
|
|
||||||
|
set -g default-terminal "screen-it"
|
||||||
|
|
||||||
|
If your terminal supports 256 colors, use:
|
||||||
|
|
||||||
|
$ screen_terminfo="screen-256color"
|
||||||
|
|
||||||
|
instead of "screen". See the FAQ entry about 256 colors support for more info.
|
||||||
|
Also note that tmux will still display reverse video on terminals that do not
|
||||||
|
support italics.
|
||||||
|
|
||||||
|
If your urxvt cannot display italics at all, make sure you have an italics
|
||||||
|
capable font enabled, for example, add to ~/.Xdefaults:
|
||||||
|
|
||||||
|
urxvt.italicFont: xft:Bitstream Vera Sans Mono:italic:autohint=true
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|||||||
144
GNUmakefile
144
GNUmakefile
@@ -1,144 +0,0 @@
|
|||||||
# $Id: GNUmakefile,v 1.82 2009-04-21 20:10:22 nicm Exp $
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
PROG= tmux
|
|
||||||
VERSION= 0.8
|
|
||||||
|
|
||||||
DATE= $(shell date +%Y%m%d-%H%M)
|
|
||||||
|
|
||||||
#FDEBUG= 1
|
|
||||||
|
|
||||||
META?= \002
|
|
||||||
|
|
||||||
SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
|
|
||||||
xmalloc.c xmalloc-debug.c input.c input-keys.c \
|
|
||||||
screen.c screen-write.c screen-redraw.c \
|
|
||||||
grid.c grid-view.c \
|
|
||||||
window.c session.c log.c client.c client-msg.c client-fn.c cfg.c \
|
|
||||||
key-string.c key-bindings.c resize.c arg.c mode-key.c \
|
|
||||||
layout.c cmd.c cmd-generic.c cmd-string.c cmd-list.c \
|
|
||||||
cmd-detach-client.c cmd-list-sessions.c cmd-new-window.c cmd-bind-key.c \
|
|
||||||
cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \
|
|
||||||
cmd-set-option.c cmd-rename-window.c cmd-select-window.c \
|
|
||||||
cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c \
|
|
||||||
cmd-refresh-client.c cmd-kill-window.c cmd-list-clients.c \
|
|
||||||
cmd-link-window.c cmd-unlink-window.c cmd-next-window.c cmd-send-keys.c \
|
|
||||||
cmd-swap-window.c cmd-rename-session.c cmd-kill-session.c \
|
|
||||||
cmd-switch-client.c cmd-has-session.c cmd-scroll-mode.c cmd-copy-mode.c \
|
|
||||||
cmd-paste-buffer.c cmd-new-session.c cmd-start-server.c \
|
|
||||||
cmd-kill-server.c cmd-set-window-option.c cmd-show-options.c \
|
|
||||||
cmd-show-window-options.c cmd-command-prompt.c cmd-set-buffer.c \
|
|
||||||
cmd-show-buffer.c cmd-list-buffers.c cmd-delete-buffer.c \
|
|
||||||
cmd-list-commands.c cmd-move-window.c cmd-select-prompt.c \
|
|
||||||
cmd-respawn-window.c cmd-source-file.c cmd-server-info.c \
|
|
||||||
cmd-clock-mode.c cmd-lock-server.c cmd-set-password.c \
|
|
||||||
cmd-save-buffer.c cmd-select-pane.c cmd-split-window.c \
|
|
||||||
cmd-resize-pane-up.c cmd-resize-pane-down.c cmd-kill-pane.c \
|
|
||||||
cmd-up-pane.c cmd-down-pane.c cmd-choose-window.c cmd-choose-session.c \
|
|
||||||
cmd-suspend-client.c cmd-find-window.c cmd-load-buffer.c \
|
|
||||||
cmd-copy-buffer.c cmd-break-pane.c cmd-swap-pane.c cmd-next-layout.c \
|
|
||||||
cmd-rotate-window.c \
|
|
||||||
window-clock.c window-scroll.c window-more.c window-copy.c \
|
|
||||||
window-choose.c \
|
|
||||||
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
|
|
||||||
tty.c tty-term.c tty-keys.c tty-write.c util.c names.c \
|
|
||||||
osdep-unknown.c osdep-openbsd.c osdep-freebsd.c osdep-linux.c \
|
|
||||||
osdep-darwin.c attributes.c
|
|
||||||
|
|
||||||
CC?= gcc
|
|
||||||
INCDIRS+= -I. -I-
|
|
||||||
CFLAGS+= -DBUILD="\"$(VERSION) ($(DATE))\"" -DMETA="'${META}'"
|
|
||||||
ifdef FDEBUG
|
|
||||||
CFLAGS+= -g -ggdb -DDEBUG
|
|
||||||
LDFLAGS+= -rdynamic
|
|
||||||
LIBS+= -ldl
|
|
||||||
endif
|
|
||||||
ifeq (${CC},gcc)
|
|
||||||
CFLAGS+= -Wno-long-long -Wall -W -Wnested-externs -Wformat=2
|
|
||||||
CFLAGS+= -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
|
|
||||||
CFLAGS+= -Wwrite-strings -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare
|
|
||||||
CFLAGS+= -Wundef -Wbad-function-cast -Winline -Wcast-align
|
|
||||||
endif
|
|
||||||
|
|
||||||
LDFLAGS+=
|
|
||||||
LIBS+= -lncurses
|
|
||||||
|
|
||||||
PREFIX?= /usr/local
|
|
||||||
INSTALLDIR= install -d
|
|
||||||
INSTALLBIN= install -g bin -o root -m 555
|
|
||||||
INSTALLMAN= install -g bin -o root -m 444
|
|
||||||
|
|
||||||
ifeq ($(shell uname),AIX)
|
|
||||||
INCDIRS+= -I/usr/local/include/ncurses -Icompat
|
|
||||||
SRCS+= compat/vis.c compat/strlcpy.c compat/strlcat.c compat/strtonum.c \
|
|
||||||
compat/fgetln.c compat/asprintf.c compat/daemon.c compat/forkpty-aix.c \
|
|
||||||
compat/getopt_long.c compat/bsd-poll.c
|
|
||||||
CFLAGS+= -DNO_TREE_H -DNO_ASPRINTF -DNO_QUEUE_H -DNO_VSYSLOG \
|
|
||||||
-DNO_PROGNAME -DNO_STRLCPY -DNO_STRLCAT -DNO_STRTONUM \
|
|
||||||
-DNO_SETPROCTITLE -DNO_QUEUE_H -DNO_TREE_H -DNO_FORKPTY -DNO_FGETLN \
|
|
||||||
-DBROKEN_GETOPT -DBROKEN_POLL -DNO_PATHS_H
|
|
||||||
LDFLAGS+= -L/usr/local/lib
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(shell uname),IRIX64)
|
|
||||||
INCDIRS+= -Icompat -I/usr/local/include/ncurses
|
|
||||||
SRCS+= compat/strlcpy.c compat/strtonum.c compat/daemon.c \
|
|
||||||
compat/asprintf.c compat/fgetln.c compat/forkpty-irix.c
|
|
||||||
CFLAGS+= -DNO_STRLCPY -DNO_STRTONUM -DNO_TREE_H -DNO_SETPROCTITLE \
|
|
||||||
-DNO_DAEMON -DNO_FORKPTY -DNO_PROGNAME -DNO_ASPRINTF -DNO_FGETLN \
|
|
||||||
-DBROKEN_VSNPRINTF -D_SGI_SOURCE -std=c99
|
|
||||||
LDFLAGS+= -L/usr/local/lib
|
|
||||||
LIBS+= -lgen
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(shell uname),SunOS)
|
|
||||||
INCDIRS+= -Icompat -I/usr/local/include/ncurses
|
|
||||||
SRCS+= compat/strtonum.c compat/daemon.c compat/forkpty-sunos.c \
|
|
||||||
compat/asprintf.c compat/fgetln.c compat/vis.c
|
|
||||||
CFLAGS+= -DNO_STRTONUM -DNO_TREE_H -DNO_PATHS_H -DNO_SETPROCTITLE \
|
|
||||||
-DNO_DAEMON -DNO_FORKPTY -DNO_PROGNAME -DNO_ASPRINTF -DNO_FGETLN
|
|
||||||
LDFLAGS+= -L/usr/local/lib
|
|
||||||
LIBS+= -lsocket -lnsl
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(shell uname),Darwin)
|
|
||||||
INCDIRS+= -Icompat
|
|
||||||
SRCS+= compat/strtonum.c compat/bsd-poll.c compat/vis.c
|
|
||||||
CFLAGS+= -DNO_STRTONUM -DNO_SETRESUID -DNO_SETRESGID -DNO_SETPROCTITLE \
|
|
||||||
-DNO_QUEUE_H -DNO_TREE_H -DBROKEN_POLL
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(shell uname),Linux)
|
|
||||||
INCDIRS+= -Icompat
|
|
||||||
SRCS+= compat/strlcpy.c compat/strlcat.c compat/strtonum.c \
|
|
||||||
compat/fgetln.c compat/getopt_long.c compat/vis.c
|
|
||||||
CFLAGS+= $(shell getconf LFS_CFLAGS) -D_GNU_SOURCE \
|
|
||||||
-DNO_STRLCPY -DNO_STRLCAT -DNO_STRTONUM -DNO_SETPROCTITLE \
|
|
||||||
-DNO_QUEUE_H -DNO_TREE_H -DUSE_PTY_H -DNO_FGETLN \
|
|
||||||
-DBROKEN_GETOPT -std=c99
|
|
||||||
LIBS+= -lcrypt -lutil
|
|
||||||
endif
|
|
||||||
|
|
||||||
OBJS= $(patsubst %.c,%.o,$(SRCS))
|
|
||||||
|
|
||||||
CLEANFILES= ${PROG} *.o .depend *~ ${PROG}.core *.log compat/*.o index.html
|
|
||||||
|
|
||||||
CPPFLAGS:= ${INCDIRS} ${CPPFLAGS}
|
|
||||||
|
|
||||||
all: $(PROG)
|
|
||||||
|
|
||||||
$(PROG): $(OBJS)
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $+ $(LIBS)
|
|
||||||
|
|
||||||
depend: $(SRCS)
|
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -MM $(SRCS) > .depend
|
|
||||||
|
|
||||||
install:
|
|
||||||
$(INSTALLDIR) $(DESTDIR)$(PREFIX)/bin
|
|
||||||
$(INSTALLBIN) $(PROG) $(DESTDIR)$(PREFIX)/bin/$(PROG)
|
|
||||||
$(INSTALLDIR) $(DESTDIR)$(PREFIX)/man/man1
|
|
||||||
$(INSTALLMAN) $(PROG).1 $(DESTDIR)$(PREFIX)/man/man1/$(PROG).1
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(CLEANFILES)
|
|
||||||
158
Makefile
158
Makefile
@@ -1,158 +0,0 @@
|
|||||||
# $Id: Makefile,v 1.121 2009-04-21 20:10:22 nicm Exp $
|
|
||||||
|
|
||||||
.SUFFIXES: .c .o .y .h
|
|
||||||
.PHONY: clean update-index.html upload-index.html
|
|
||||||
|
|
||||||
PROG= tmux
|
|
||||||
VERSION= 0.8
|
|
||||||
|
|
||||||
OS!= uname
|
|
||||||
REL!= uname -r
|
|
||||||
DATE!= date +%Y%m%d-%H%M
|
|
||||||
|
|
||||||
#FDEBUG= 1
|
|
||||||
|
|
||||||
META?= \002 # C-b
|
|
||||||
|
|
||||||
SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
|
|
||||||
xmalloc.c xmalloc-debug.c input.c input-keys.c \
|
|
||||||
screen.c screen-write.c screen-redraw.c \
|
|
||||||
grid.c grid-view.c \
|
|
||||||
window.c session.c log.c client.c client-msg.c client-fn.c cfg.c \
|
|
||||||
layout.c key-string.c key-bindings.c resize.c arg.c mode-key.c \
|
|
||||||
cmd.c cmd-generic.c cmd-string.c cmd-list.c \
|
|
||||||
cmd-detach-client.c cmd-list-sessions.c cmd-new-window.c cmd-bind-key.c \
|
|
||||||
cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \
|
|
||||||
cmd-set-option.c cmd-rename-window.c cmd-select-window.c \
|
|
||||||
cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c \
|
|
||||||
cmd-refresh-client.c cmd-kill-window.c cmd-list-clients.c \
|
|
||||||
cmd-link-window.c cmd-unlink-window.c cmd-next-window.c cmd-send-keys.c \
|
|
||||||
cmd-swap-window.c cmd-rename-session.c cmd-kill-session.c \
|
|
||||||
cmd-switch-client.c cmd-has-session.c cmd-scroll-mode.c cmd-copy-mode.c \
|
|
||||||
cmd-paste-buffer.c cmd-new-session.c cmd-start-server.c \
|
|
||||||
cmd-kill-server.c cmd-set-window-option.c cmd-show-options.c \
|
|
||||||
cmd-show-window-options.c cmd-command-prompt.c cmd-set-buffer.c \
|
|
||||||
cmd-show-buffer.c cmd-list-buffers.c cmd-delete-buffer.c \
|
|
||||||
cmd-list-commands.c cmd-move-window.c cmd-select-prompt.c \
|
|
||||||
cmd-respawn-window.c cmd-source-file.c cmd-server-info.c \
|
|
||||||
cmd-clock-mode.c cmd-lock-server.c cmd-set-password.c \
|
|
||||||
cmd-save-buffer.c cmd-select-pane.c cmd-split-window.c \
|
|
||||||
cmd-resize-pane-up.c cmd-resize-pane-down.c cmd-kill-pane.c \
|
|
||||||
cmd-up-pane.c cmd-down-pane.c cmd-choose-window.c cmd-choose-session.c \
|
|
||||||
cmd-suspend-client.c cmd-find-window.c cmd-load-buffer.c \
|
|
||||||
cmd-copy-buffer.c cmd-break-pane.c cmd-swap-pane.c cmd-next-layout.c \
|
|
||||||
cmd-rotate-window.c \
|
|
||||||
window-clock.c window-scroll.c window-more.c window-copy.c \
|
|
||||||
window-choose.c \
|
|
||||||
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
|
|
||||||
tty.c tty-term.c tty-keys.c tty-write.c util.c names.c attributes.c \
|
|
||||||
osdep-unknown.c osdep-openbsd.c osdep-freebsd.c osdep-linux.c \
|
|
||||||
osdep-darwin.c osdep-netbsd.c
|
|
||||||
|
|
||||||
CC?= c
|
|
||||||
INCDIRS+= -I. -I- -I/usr/local/include
|
|
||||||
CFLAGS+= -DMETA="'${META}'"
|
|
||||||
.ifdef PROFILE
|
|
||||||
# Don't use ccache
|
|
||||||
CC= /usr/bin/gcc
|
|
||||||
CFLAGS+= -pg -DPROFILE -O0
|
|
||||||
.endif
|
|
||||||
.ifdef FDEBUG
|
|
||||||
CFLAGS+= -g -ggdb -DDEBUG
|
|
||||||
LDFLAGS+= -Wl,-E
|
|
||||||
CFLAGS+= -DBUILD="\"$(VERSION) ($(DATE))\""
|
|
||||||
.else
|
|
||||||
CFLAGS+= -DBUILD="\"$(VERSION)\""
|
|
||||||
.endif
|
|
||||||
#CFLAGS+= -pedantic -std=c99
|
|
||||||
CFLAGS+= -Wno-long-long -Wall -W -Wnested-externs -Wformat=2
|
|
||||||
CFLAGS+= -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
|
|
||||||
CFLAGS+= -Wwrite-strings -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare
|
|
||||||
CFLAGS+= -Wundef -Wbad-function-cast -Winline -Wcast-align
|
|
||||||
|
|
||||||
PREFIX?= /usr/local
|
|
||||||
INSTALLDIR= install -d
|
|
||||||
INSTALLBIN= install -g bin -o root -m 555
|
|
||||||
INSTALLMAN= install -g bin -o root -m 444
|
|
||||||
|
|
||||||
LDFLAGS+= -L/usr/local/lib
|
|
||||||
.ifdef PROFILE
|
|
||||||
LDFLAGS+= -pg
|
|
||||||
.endif
|
|
||||||
LIBS+= -lutil -lncurses
|
|
||||||
|
|
||||||
# FreeBSD and DragonFly
|
|
||||||
.if ${OS} == "FreeBSD" || ${OS} == "DragonFly"
|
|
||||||
INCDIRS+= -Icompat
|
|
||||||
SRCS+= compat/vis.c
|
|
||||||
CFLAGS+= -DUSE_LIBUTIL_H -DNO_QUEUE_H -DNO_TREE_H
|
|
||||||
LIBS+= -lcrypt
|
|
||||||
.endif
|
|
||||||
|
|
||||||
# NetBSD
|
|
||||||
.if ${OS} == "NetBSD"
|
|
||||||
INCDIRS= -Icompat
|
|
||||||
SRCS+= compat/strtonum.c compat/vis.c
|
|
||||||
LIBS+= -lcrypt
|
|
||||||
CFLAGS+=-DNO_STRTONUM
|
|
||||||
.endif
|
|
||||||
|
|
||||||
OBJS= ${SRCS:S/.c/.o/:S/.y/.o/}
|
|
||||||
|
|
||||||
DISTDIR= ${PROG}-${VERSION}
|
|
||||||
DISTFILES= *.[chyl] Makefile GNUmakefile *.[1-9] NOTES TODO CHANGES FAQ \
|
|
||||||
`find examples compat -type f -and ! -path '*CVS*'`
|
|
||||||
|
|
||||||
CLEANFILES= ${PROG} *.o .depend *~ ${PROG}.core *.log compat/*.o index.html
|
|
||||||
|
|
||||||
CPPFLAGS:= ${INCDIRS} ${CPPFLAGS}
|
|
||||||
|
|
||||||
.c.o:
|
|
||||||
${CC} ${CPPFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
|
|
||||||
|
|
||||||
.y.o:
|
|
||||||
${YACC} ${.IMPSRC}
|
|
||||||
${CC} ${CPPFLAGS} ${CFLAGS} -c y.tab.c -o ${.TARGET}
|
|
||||||
|
|
||||||
all: ${PROG}
|
|
||||||
|
|
||||||
${PROG}: ${OBJS}
|
|
||||||
${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LIBS}
|
|
||||||
|
|
||||||
depend:
|
|
||||||
mkdep ${CPPFLAGS} ${CFLAGS} ${SRCS:M*.c}
|
|
||||||
|
|
||||||
dist: clean
|
|
||||||
grep '^#FDEBUG=' Makefile
|
|
||||||
grep '^#FDEBUG=' GNUmakefile
|
|
||||||
[ "`(grep '^VERSION' Makefile; grep '^VERSION' GNUmakefile)| \
|
|
||||||
uniq -u`" = "" ]
|
|
||||||
tar -zc \
|
|
||||||
-s '/.*/${DISTDIR}\/\0/' \
|
|
||||||
-f ${DISTDIR}.tar.gz ${DISTFILES}
|
|
||||||
|
|
||||||
lint:
|
|
||||||
lint -chvx ${CFLAGS:M-D*} ${SRCS:M*.c}
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f ${CLEANFILES}
|
|
||||||
|
|
||||||
upload-index.html: update-index.html
|
|
||||||
scp index.html images/*.png \
|
|
||||||
nicm,tmux@web.sf.net:/home/groups/t/tm/tmux/htdocs
|
|
||||||
rm -f images/small-*
|
|
||||||
|
|
||||||
update-index.html:
|
|
||||||
(cd images && \
|
|
||||||
rm -f small-* && \
|
|
||||||
for i in *.png; do \
|
|
||||||
convert "$$i" -resize 200x150 "small-$$i"; \
|
|
||||||
done \
|
|
||||||
)
|
|
||||||
sed "s/%%VERSION%%/${VERSION}/g" index.html.in >index.html
|
|
||||||
|
|
||||||
install: all
|
|
||||||
${INSTALLDIR} ${DESTDIR}${PREFIX}/bin
|
|
||||||
${INSTALLBIN} ${PROG} ${DESTDIR}${PREFIX}/bin/
|
|
||||||
${INSTALLDIR} ${DESTDIR}${PREFIX}/man/man1
|
|
||||||
${INSTALLMAN} ${PROG}.1 ${DESTDIR}${PREFIX}/man/man1/
|
|
||||||
242
Makefile.am
Normal file
242
Makefile.am
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
# $Id$
|
||||||
|
|
||||||
|
# Obvious program stuff.
|
||||||
|
bin_PROGRAMS = tmux
|
||||||
|
dist_man1_MANS = tmux.1
|
||||||
|
|
||||||
|
# Distribution tarball options.
|
||||||
|
EXTRA_DIST = \
|
||||||
|
CHANGES FAQ NOTES TODO examples compat \
|
||||||
|
array.h compat.h tmux.h osdep-*.c
|
||||||
|
dist-hook:
|
||||||
|
grep "^#found_debug=" configure
|
||||||
|
find $(distdir) -name .svn -type d|xargs rm -Rf
|
||||||
|
|
||||||
|
# Preprocessor flags.
|
||||||
|
CPPFLAGS += @XOPEN_DEFINES@
|
||||||
|
|
||||||
|
# glibc as usual does things ass-backwards and hides useful things by default,
|
||||||
|
# so everyone has to add this.
|
||||||
|
if IS_GLIBC
|
||||||
|
CFLAGS += -D_GNU_SOURCE
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Set flags for gcc. gcc4 whines abouts silly stuff so it needs slightly
|
||||||
|
# different flags.
|
||||||
|
if IS_GCC
|
||||||
|
CFLAGS += -std=c99
|
||||||
|
if IS_DEBUG
|
||||||
|
CFLAGS += -g -ggdb -O0
|
||||||
|
CFLAGS += -Wno-long-long -Wall -W -Wnested-externs -Wformat=2
|
||||||
|
CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
|
||||||
|
CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare
|
||||||
|
CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align
|
||||||
|
CPPFLAGS += -DDEBUG
|
||||||
|
endif
|
||||||
|
if IS_GCC4
|
||||||
|
CPPFLAGS += -iquote. -I/usr/local/include
|
||||||
|
if IS_DEBUG
|
||||||
|
CFLAGS += -Wno-pointer-sign
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
CPPFLAGS += -I. -I- -I/usr/local/include
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Set flags for Solaris.
|
||||||
|
if IS_SUNOS
|
||||||
|
CPPFLAGS += -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Set flags for Sun CC.
|
||||||
|
if IS_SUNCC
|
||||||
|
CFLAGS += -erroff=E_EMPTY_DECLARATION
|
||||||
|
endif
|
||||||
|
|
||||||
|
# List of sources.
|
||||||
|
dist_tmux_SOURCES = \
|
||||||
|
arguments.c \
|
||||||
|
attributes.c \
|
||||||
|
cfg.c \
|
||||||
|
client.c \
|
||||||
|
clock.c \
|
||||||
|
cmd-attach-session.c \
|
||||||
|
cmd-bind-key.c \
|
||||||
|
cmd-break-pane.c \
|
||||||
|
cmd-capture-pane.c \
|
||||||
|
cmd-choose-buffer.c \
|
||||||
|
cmd-choose-client.c \
|
||||||
|
cmd-choose-session.c \
|
||||||
|
cmd-choose-window.c \
|
||||||
|
cmd-clear-history.c \
|
||||||
|
cmd-clock-mode.c \
|
||||||
|
cmd-command-prompt.c \
|
||||||
|
cmd-confirm-before.c \
|
||||||
|
cmd-copy-mode.c \
|
||||||
|
cmd-delete-buffer.c \
|
||||||
|
cmd-detach-client.c \
|
||||||
|
cmd-display-message.c \
|
||||||
|
cmd-display-panes.c \
|
||||||
|
cmd-find-window.c \
|
||||||
|
cmd-has-session.c \
|
||||||
|
cmd-if-shell.c \
|
||||||
|
cmd-join-pane.c \
|
||||||
|
cmd-kill-pane.c \
|
||||||
|
cmd-kill-server.c \
|
||||||
|
cmd-kill-session.c \
|
||||||
|
cmd-kill-window.c \
|
||||||
|
cmd-link-window.c \
|
||||||
|
cmd-list-buffers.c \
|
||||||
|
cmd-list-clients.c \
|
||||||
|
cmd-list-commands.c \
|
||||||
|
cmd-list-keys.c \
|
||||||
|
cmd-list-panes.c \
|
||||||
|
cmd-list-sessions.c \
|
||||||
|
cmd-list-windows.c \
|
||||||
|
cmd-list.c \
|
||||||
|
cmd-load-buffer.c \
|
||||||
|
cmd-lock-server.c \
|
||||||
|
cmd-move-window.c \
|
||||||
|
cmd-new-session.c \
|
||||||
|
cmd-new-window.c \
|
||||||
|
cmd-paste-buffer.c \
|
||||||
|
cmd-pipe-pane.c \
|
||||||
|
cmd-refresh-client.c \
|
||||||
|
cmd-rename-session.c \
|
||||||
|
cmd-rename-window.c \
|
||||||
|
cmd-resize-pane.c \
|
||||||
|
cmd-respawn-pane.c \
|
||||||
|
cmd-respawn-window.c \
|
||||||
|
cmd-rotate-window.c \
|
||||||
|
cmd-run-shell.c \
|
||||||
|
cmd-save-buffer.c \
|
||||||
|
cmd-select-layout.c \
|
||||||
|
cmd-select-pane.c \
|
||||||
|
cmd-select-window.c \
|
||||||
|
cmd-send-keys.c \
|
||||||
|
cmd-send-prefix.c \
|
||||||
|
cmd-server-info.c \
|
||||||
|
cmd-set-buffer.c \
|
||||||
|
cmd-set-environment.c \
|
||||||
|
cmd-set-option.c \
|
||||||
|
cmd-show-buffer.c \
|
||||||
|
cmd-show-environment.c \
|
||||||
|
cmd-show-messages.c \
|
||||||
|
cmd-show-options.c \
|
||||||
|
cmd-source-file.c \
|
||||||
|
cmd-split-window.c \
|
||||||
|
cmd-start-server.c \
|
||||||
|
cmd-string.c \
|
||||||
|
cmd-suspend-client.c \
|
||||||
|
cmd-swap-pane.c \
|
||||||
|
cmd-swap-window.c \
|
||||||
|
cmd-switch-client.c \
|
||||||
|
cmd-unbind-key.c \
|
||||||
|
cmd-unlink-window.c \
|
||||||
|
cmd.c \
|
||||||
|
colour.c \
|
||||||
|
environ.c \
|
||||||
|
format.c \
|
||||||
|
grid-utf8.c \
|
||||||
|
grid-view.c \
|
||||||
|
grid.c \
|
||||||
|
input-keys.c \
|
||||||
|
input.c \
|
||||||
|
job.c \
|
||||||
|
key-bindings.c \
|
||||||
|
key-string.c \
|
||||||
|
layout-custom.c \
|
||||||
|
layout-set.c \
|
||||||
|
layout.c \
|
||||||
|
log.c \
|
||||||
|
mode-key.c \
|
||||||
|
names.c \
|
||||||
|
options-table.c \
|
||||||
|
options.c \
|
||||||
|
paste.c \
|
||||||
|
resize.c \
|
||||||
|
screen-redraw.c \
|
||||||
|
screen-write.c \
|
||||||
|
screen.c \
|
||||||
|
server-client.c \
|
||||||
|
server-fn.c \
|
||||||
|
server-window.c \
|
||||||
|
server.c \
|
||||||
|
session.c \
|
||||||
|
signal.c \
|
||||||
|
status.c \
|
||||||
|
tmux.c \
|
||||||
|
tty-acs.c \
|
||||||
|
tty-keys.c \
|
||||||
|
tty-term.c \
|
||||||
|
tty.c \
|
||||||
|
utf8.c \
|
||||||
|
window-choose.c \
|
||||||
|
window-clock.c \
|
||||||
|
window-copy.c \
|
||||||
|
window.c \
|
||||||
|
xmalloc.c \
|
||||||
|
xterm-keys.c
|
||||||
|
nodist_tmux_SOURCES = osdep-@PLATFORM@.c
|
||||||
|
|
||||||
|
# Pile in all the compat/ stuff that is needed.
|
||||||
|
if NO_FORKPTY
|
||||||
|
nodist_tmux_SOURCES += compat/forkpty-@PLATFORM@.c
|
||||||
|
endif
|
||||||
|
if NO_IMSG
|
||||||
|
nodist_tmux_SOURCES += compat/imsg.c compat/imsg-buffer.c
|
||||||
|
endif
|
||||||
|
if NO_CLOSEFROM
|
||||||
|
nodist_tmux_SOURCES += compat/closefrom.c
|
||||||
|
endif
|
||||||
|
if NO_DAEMON
|
||||||
|
nodist_tmux_SOURCES += compat/daemon.c
|
||||||
|
endif
|
||||||
|
if NO_SETENV
|
||||||
|
nodist_tmux_SOURCES += compat/setenv.c
|
||||||
|
endif
|
||||||
|
if NO_STRLCAT
|
||||||
|
nodist_tmux_SOURCES += compat/strlcat.c
|
||||||
|
endif
|
||||||
|
if NO_STRLCPY
|
||||||
|
nodist_tmux_SOURCES += compat/strlcpy.c
|
||||||
|
endif
|
||||||
|
if NO_ASPRINTF
|
||||||
|
nodist_tmux_SOURCES += compat/asprintf.c
|
||||||
|
endif
|
||||||
|
if NO_FGETLN
|
||||||
|
nodist_tmux_SOURCES += compat/fgetln.c
|
||||||
|
endif
|
||||||
|
if NO_GETOPT
|
||||||
|
nodist_tmux_SOURCES += compat/getopt.c
|
||||||
|
endif
|
||||||
|
if NO_STRCASESTR
|
||||||
|
nodist_tmux_SOURCES += compat/strcasestr.c
|
||||||
|
endif
|
||||||
|
if NO_STRSEP
|
||||||
|
nodist_tmux_SOURCES += compat/strsep.c
|
||||||
|
endif
|
||||||
|
if NO_VIS
|
||||||
|
nodist_tmux_SOURCES += compat/vis.c compat/unvis.c
|
||||||
|
endif
|
||||||
|
if NO_STRTONUM
|
||||||
|
nodist_tmux_SOURCES += compat/strtonum.c
|
||||||
|
endif
|
||||||
|
if NO_B64_NTOP
|
||||||
|
nodist_tmux_SOURCES += compat/b64_ntop.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Update SF web site.
|
||||||
|
upload-index.html: update-index.html
|
||||||
|
scp www/index.html www/main.css www/images/*.png \
|
||||||
|
${USER},tmux@web.sf.net:/home/groups/t/tm/tmux/htdocs
|
||||||
|
rm -f www/index.html www/images/small-*
|
||||||
|
|
||||||
|
update-index.html:
|
||||||
|
(cd www/images && \
|
||||||
|
rm -f small-* && \
|
||||||
|
for i in *.png; do \
|
||||||
|
convert "$$i" -resize 200x150 "small-$$i"; \
|
||||||
|
done \
|
||||||
|
)
|
||||||
|
sed "s/%%VERSION%%/${VERSION}/g" www/index.html.in >www/index.html
|
||||||
79
NOTES
79
NOTES
@@ -4,14 +4,31 @@ tmux is a "terminal multiplexer", it enables a number of terminals (or windows)
|
|||||||
to be accessed and controlled from a single terminal. tmux is intended to be a
|
to be accessed and controlled from a single terminal. tmux is intended to be a
|
||||||
simple, modern, BSD-licensed alternative to programs such as GNU screen.
|
simple, modern, BSD-licensed alternative to programs such as GNU screen.
|
||||||
|
|
||||||
This 0.8 release runs on OpenBSD, FreeBSD, Linux and OS X and may still run on
|
This release runs on OpenBSD, FreeBSD, NetBSD, Linux and OS X and may still
|
||||||
Solaris (although it hasn't been tested in a while). It is usable, although
|
run on Solaris and AIX (although they haven't been tested in a while). It is
|
||||||
there remain a number of missing features and some remaining bugs are expected.
|
usable, although there remain a number of missing features and some remaining
|
||||||
|
bugs are expected.
|
||||||
|
|
||||||
If upgrading from 0.5, PLEASE NOTE the following configuration file changes: it
|
If upgrading from 1.5, PLEASE NOTE:
|
||||||
is now required to pass the -g flag to set-option or set-window-option to set
|
- The word-separators window option is now a session option.
|
||||||
global options; remain-by-default and utf8-default are now gone, use global
|
- The options used to change the window attributes when an alert occurs were
|
||||||
window options (set-window-option -g) instead.
|
removed. Each kind of alert has its own individual set of options.
|
||||||
|
- The ability to have a list of prefix keys was dropped in favour of two
|
||||||
|
separate options, prefix and prefix2.
|
||||||
|
|
||||||
|
Since the 1.2 release that tmux depends on libevent. Download it from:
|
||||||
|
|
||||||
|
http://www.monkey.org/~provos/libevent/
|
||||||
|
|
||||||
|
To build tmux from a release tarball, do:
|
||||||
|
|
||||||
|
$ ./configure && make
|
||||||
|
$ sudo make install
|
||||||
|
|
||||||
|
To build from a version control checkout, the configure script must be
|
||||||
|
generated by running:
|
||||||
|
|
||||||
|
$ sh autogen.sh
|
||||||
|
|
||||||
tmux consists of a server part and multiple clients. The server is created when
|
tmux consists of a server part and multiple clients. The server is created when
|
||||||
required and runs continuously unless killed by the user. Clients access the
|
required and runs continuously unless killed by the user. Clients access the
|
||||||
@@ -24,39 +41,10 @@ windows into several simultaneously displayed panes; and to bind and unbind
|
|||||||
command keys (invoked preceded by a prefix key, by default ctrl-b). Please see
|
command keys (invoked preceded by a prefix key, by default ctrl-b). Please see
|
||||||
the tmux(1) man page for further information.
|
the tmux(1) man page for further information.
|
||||||
|
|
||||||
The following is a summary of major features implemented in this version:
|
|
||||||
|
|
||||||
- Basic multiplexing, window switching, attaching and detaching.
|
|
||||||
- Window listing and renaming.
|
|
||||||
- Key binding.
|
|
||||||
- Handling of client terminal resize.
|
|
||||||
- Terminal emulation sufficient to handle most curses applications.
|
|
||||||
- A optional status line (enabled by default).
|
|
||||||
- Window history and copy and paste.
|
|
||||||
- Support for VT100 line drawing characters.
|
|
||||||
- A large command set.
|
|
||||||
- Vertical window splitting and layout.
|
|
||||||
- Automatic server locking on inactivity.
|
|
||||||
- A configuration file.
|
|
||||||
- UTF-8 support.
|
|
||||||
|
|
||||||
And major missing features:
|
|
||||||
|
|
||||||
- Proper mouse support.
|
|
||||||
- No support for programs changing termios(4) settings or other tty(4) ioctls.
|
|
||||||
|
|
||||||
A more extensive, but rough, todo list is included in the TODO file.
|
A more extensive, but rough, todo list is included in the TODO file.
|
||||||
|
|
||||||
tmux also depends on several features of the client terminal (TERM), if these
|
tmux also depends on several features of the client terminal (TERM), if these
|
||||||
are missing it may refuse to run, or not behave correctly. Known working are
|
are missing it may refuse to run, or not behave correctly.
|
||||||
TERM=screen (tmux in screen), xterm, xterm-color and rxvt. Note that TERM=xterm
|
|
||||||
does not support colour on OpenBSD. screen ignores this, tmux does not: use
|
|
||||||
xterm-color or rxvt for colour.
|
|
||||||
|
|
||||||
tmux supports UTF-8. To use it, the utf8 option must be set on each window;
|
|
||||||
this may be turned on for all windows by setting it as a global option, see
|
|
||||||
tmux(1) and the FAQ file. In addition, when starting tmux or attaching to an
|
|
||||||
existing session from a UTF-8-capable terminal, the -u flag must be specified.
|
|
||||||
|
|
||||||
A Vim syntax file is available in the examples directory. To install it:
|
A Vim syntax file is available in the examples directory. To install it:
|
||||||
|
|
||||||
@@ -74,15 +62,6 @@ A Vim syntax file is available in the examples directory. To install it:
|
|||||||
For debugging, running tmux with -v or -vv will generate server and client log
|
For debugging, running tmux with -v or -vv will generate server and client log
|
||||||
files in the current directory.
|
files in the current directory.
|
||||||
|
|
||||||
The CVS HEAD version of tmux often has additional features from the release
|
|
||||||
versions; if interested, testing it is encouraged. It can be obtained by
|
|
||||||
anonymous CVS from SourceForge:
|
|
||||||
|
|
||||||
$ cvs -d:pserver:anoncvs@tmux.cvs.sf.net:/cvsroot/tmux co tmux
|
|
||||||
|
|
||||||
If running CVS HEAD, please note it is development code and there may be bugs
|
|
||||||
and undocumented features; please read the CHANGES file for information.
|
|
||||||
|
|
||||||
tmux mailing lists are available; visit:
|
tmux mailing lists are available; visit:
|
||||||
|
|
||||||
https://sourceforge.net/mail/?group_id=200378
|
https://sourceforge.net/mail/?group_id=200378
|
||||||
@@ -92,6 +71,12 @@ welcome. Please send by email to:
|
|||||||
|
|
||||||
nicm@users.sf.net
|
nicm@users.sf.net
|
||||||
|
|
||||||
|
This file and the CHANGES, FAQ and TODO files are licensed under the ISC
|
||||||
|
license. Files under examples/ remain copyright their authors unless otherwise
|
||||||
|
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. Please contact me with any queries.
|
||||||
|
|
||||||
-- Nicholas Marriott <nicm@users.sf.net>
|
-- Nicholas Marriott <nicm@users.sf.net>
|
||||||
|
|
||||||
$Id: NOTES,v 1.45 2009-04-21 20:06:12 nicm Exp $
|
$Id$
|
||||||
|
|||||||
227
TODO
227
TODO
@@ -1,103 +1,144 @@
|
|||||||
- line mode/char-at-a-time mode a la telnet?
|
- implicitly add exec to the commands for new windows (switch to disable it)?
|
||||||
- handle ioctl/termios stuff on window sockets
|
- bring back detach-session to detach all clients on a session?
|
||||||
- figure out once and for all what is going on with backspace and del
|
|
||||||
backspace should be translated per the termios setting.
|
|
||||||
del passed through?
|
|
||||||
- window creation/idle time
|
|
||||||
- profile/optimise, particularly (i suspect) input.c
|
|
||||||
- could use bsearch all over the place or get rid of smaller tables (clientmsg)
|
|
||||||
- better errors when creating new windows/sessions (how?)
|
|
||||||
- Implicitly add exec to the commands for new windows (switch to disable it)
|
|
||||||
- it would be nice to have multichar commands so you could have C-b K K for
|
|
||||||
kill-window to limit accidental presses
|
|
||||||
- commands:
|
|
||||||
extend list-clients to list clients attached to a session (-a for all?)
|
|
||||||
bring back detach-session to detach all clients on a session?
|
|
||||||
clone-session command to link all windows to a new session
|
|
||||||
- allow fnmatch for -c, so that you can, eg, detach all clients
|
- allow fnmatch for -c, so that you can, eg, detach all clients
|
||||||
- bind non prefix keys
|
|
||||||
- garbage collect window history (100 lines at a time?) if it hasn't been used
|
- garbage collect window history (100 lines at a time?) if it hasn't been used
|
||||||
in $x time (need window creation/use times)
|
in $x time
|
||||||
- lift SHRT_MAX limits for history
|
|
||||||
- audit copy/scroll and other modes for problems with very small windows
|
|
||||||
- split clients into three RB trees by fd: attached/unattached/dead?
|
|
||||||
or tailqs? what would be fastest per-char?
|
|
||||||
- c/p is still borken in some ways
|
|
||||||
- better mode features: search, back word, forward word, etc
|
|
||||||
- flags to centre screen in window
|
- flags to centre screen in window
|
||||||
- better terminal emulation (identify, insert mode, some other bits)
|
|
||||||
- when resizing, use history
|
|
||||||
- audit for leftover/unused code
|
|
||||||
- activity/bell should be per-window not per-link? what if it is cur win in
|
- activity/bell should be per-window not per-link? what if it is cur win in
|
||||||
session not being watched?
|
session not being watched?
|
||||||
- tidy up window modes
|
|
||||||
- next prev word etc in command prompt; also ^K
|
|
||||||
- many more info() displays for various things
|
|
||||||
- vi half page scroll
|
|
||||||
- backspace should perhaps wrap backwards over newlines which were not moved
|
|
||||||
down by a newline: screen and the OS X terminal does this but xterm and most
|
|
||||||
others do not. this might be hard: a flag for each grid line (top bit of size
|
|
||||||
maybe)? a single flag is insufficient as can't then tell when to /stop/
|
|
||||||
unwrapping
|
|
||||||
- input.c is too complicated. simplify?
|
|
||||||
- use a better termcap internally instead of screen, perhaps xterm
|
- use a better termcap internally instead of screen, perhaps xterm
|
||||||
- a command to display the status line briefly when it is turned off
|
|
||||||
- FAQ "Can I have some examples of cool things I can do with tmux?" -- linkw,
|
|
||||||
more??
|
|
||||||
- kill all but current pane
|
|
||||||
- fix rxvt cursor fg issue (text under cursor can have non-white fg)
|
|
||||||
- key handling sucks a bit and needs to be reworked
|
|
||||||
- some people find first window being 0 rather than 1 is awkward on the
|
|
||||||
keyboard. what about a new-window-index option that sets the base at which
|
|
||||||
tmux starts numbering new windows, then they can do: set -g new-window-index
|
|
||||||
1; bind 0 selectw -t:10
|
|
||||||
- some way to change status line colours based on something? command?
|
|
||||||
- client sx/sy should be in tty, then can let the terminal wrap at edge
|
|
||||||
to allow xterm to pick up it should be one line for its c/p
|
|
||||||
- should be able to move to a hidden pane and it would be moved into view. pane
|
- should be able to move to a hidden pane and it would be moved into view. pane
|
||||||
number in status line/top-right would be cool for this
|
number in status line/top-right would be cool for this
|
||||||
- command to run something without a window at all - output to
|
- support other mouse modes (highlight etc) and use it in copy mode
|
||||||
window-more. what for? isnt this the same as doing it w/ splitw/neww now?
|
|
||||||
- command to purge window history? or apply history-limit changes?
|
|
||||||
- clone session command
|
|
||||||
- make command sequences more usable: don't require space around ;, handle
|
|
||||||
errors better
|
|
||||||
- would be nice if tmux could be the shell (tmux attach, but hard link to tmux
|
|
||||||
binary as "tmuxsh" or wrapper script?) -- problems with tty dev permissions
|
|
||||||
- support other mouse modes (highlight etc) and use it in copy mode
|
|
||||||
- set-remain-on-exit is a bit of a hack, some way to do it generically?
|
- set-remain-on-exit is a bit of a hack, some way to do it generically?
|
||||||
- set-option should be set-session-option and should be overall global options
|
|
||||||
for stuff like mode keys?
|
|
||||||
- a confirm-before command which asks "Are you sure? (y/n)" before executing
|
|
||||||
command, eg bind-key "&" confirm-before "kill-window"
|
|
||||||
- might be nice if attach-session behaved like switch-client inside an
|
|
||||||
existing client
|
|
||||||
- key to switch to copy mode from scroll mode
|
|
||||||
- attach should have a flag to create session if it doesn't exist
|
|
||||||
- clear window title on exit
|
- clear window title on exit
|
||||||
- better support for stupid margin terminals. strcmp for cons25 sucks, how can
|
- would be nice to be able to use "--" to mark start of command w/ neww etc
|
||||||
these be autodetected?
|
to avoid quoting
|
||||||
- refer to windows by name etc (duplicates? fnmatch?)
|
- make command sequences more usable: don't require space after ;, handle
|
||||||
- the output code (tty.c) could do with optimisation depending on term
|
errors better
|
||||||
capibilities
|
- attach should have a flag to create session if it doesn't exist
|
||||||
- resize-pane-up/down should be resize-pane -U/-D. ditto up-pane/down-pane
|
- choice and more mode would be better per client than per window?
|
||||||
should be select-pane -U/-D
|
- hooks to which commands may be attached, for example: tmux add-hook
|
||||||
- layout/split stuff:
|
"new-session" if-shell "[ -e $HOME/.tmux-session.conf ]" source-file
|
||||||
horiz split command, and similar resizing commands as for vert split
|
$HOME/.tmux-session.conf
|
||||||
display the layout in a readable format somewhere
|
- get it passing all the vttest tests that don't require resizing the terminal
|
||||||
previous-layout command
|
- way to set socket path from config file
|
||||||
select-layout command
|
- what about utmp etc? can tmux update it like screen? setgid?
|
||||||
make manual layout a bit less of a hack and make it handle a grid
|
- warts on current naming:
|
||||||
should the layout be a window option???
|
- display-time but message-fg/bg/attr
|
||||||
more layouts
|
- list-* vs show-*
|
||||||
better resizing of shells when changing layout
|
- server-info
|
||||||
find and fix bug with clear screen after horiz split
|
- up-pane/down-pane/swap-pane -U/swap-pane -D vs next-*/previous-*
|
||||||
speed improvements? -- still too slow over ssh!
|
- split-window -> split-pane??
|
||||||
hardcoded 81 for left-vertical is nasty
|
- a way for force-width/height to apply to only one pane (how?)
|
||||||
- test bug sshing from freebsd console (tom iirc?)
|
- command to list what is actually running in each window with command line,
|
||||||
- fix build on solaris 10
|
pid (need some adaption of the osdep code)
|
||||||
- rotate-window has redraw bugs... :-/
|
- support for bce
|
||||||
|
- some way to force a screen to use the entire terminal even if it is forced
|
||||||
(hopefully) for 0.8, in no particular order:
|
to be smaller by other clients. pan smaller terminal? (like screen F)
|
||||||
- nothing!
|
-- idea of a "view" onto a window, need base x/y offsets for redraw
|
||||||
|
- handle resize better in copy mode
|
||||||
|
- way to copy stuff that is off screen due to resize
|
||||||
|
- commands should be able to succeed or fail and have || or && for command
|
||||||
|
lists
|
||||||
|
- some way to KEEP a command running continually and just use its LAST line of
|
||||||
|
output
|
||||||
|
- UTF-8 to a non-UTF-8 terminal should not be able to balls up
|
||||||
|
the terminal - www/ruby-addressable; make regress
|
||||||
|
- support esc-esc to quit in modes
|
||||||
|
- fix ctrl+F1-F4 output. to what?
|
||||||
|
- better utf8 support: window names, prompt input, message display
|
||||||
|
- session history for client and last-session command
|
||||||
|
- option to change status line colour when current window is in a mode?
|
||||||
|
- option to move copy mode indicator into status line
|
||||||
|
- list-buffer/show-buffer should display UTF-8
|
||||||
|
- selection behaviour closer to vi in vi mode
|
||||||
|
- live update: server started with -U connects to server, requests sessions and
|
||||||
|
windows, receives fds
|
||||||
|
- command to show a tree of sessions-windows-panes (active marked with *)
|
||||||
|
- sort out inheriting config from shell on new sessions/windows:
|
||||||
|
should pick up default-path/termios/etc from client if possible,
|
||||||
|
else leave empty/default
|
||||||
|
- link panes into multiple windows
|
||||||
|
- bells should be passed between sessions with visual-bell etc
|
||||||
|
- use screen-256color when started on 256 colour terminal??
|
||||||
|
- if-shell/run-shell should block further command execution in the same command
|
||||||
|
sequence until its shell exits, to allow them to be used from the config file
|
||||||
|
- better session sharing: create-socket command to create socket somewhere (-r
|
||||||
|
flag for readonly)
|
||||||
|
- multiline status line (no?)
|
||||||
|
- flag for absolute pane size to resize-pane
|
||||||
|
- sanity check input to socket
|
||||||
|
- support title stack, both internally and externally
|
||||||
|
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=1149299+0+archive/2010/freebsd-questions/20100207.freebsd-questions
|
||||||
|
- command to show status line information briefly when it is off
|
||||||
|
- some way to pad # stuff with spaces, #!2T maybe
|
||||||
|
- a binding to "scroll down and exit at bottom" copy mode
|
||||||
|
- some way to pass keystrokes in copy mode through to underlying window
|
||||||
|
- last window update time and # replacement for it for display-message
|
||||||
|
- find-window across sessions - other ways to make session handling easier?
|
||||||
|
- ' and " should be parsed the same (eg "\e" vs '\e') in config and command
|
||||||
|
prompt?
|
||||||
|
- command to toggle selection not to move it in copy-mode
|
||||||
|
- why are alerts per-winlink? try per window?
|
||||||
|
- audit of escape sequence support vs xterm
|
||||||
|
- support binding keys to mouse (mouse-select-pane -> mouse-keys or something,
|
||||||
|
mouse click == select-pane -t %%, mouse scroll up == copy-mode)
|
||||||
|
- something for -t "last window in session" so a session can be used as a stack
|
||||||
|
- synchronous commands - client sends cmd and blocks, neww/splitw saves client
|
||||||
|
ptr then when program inside died, sends MSG_SOMETHING with wait status to
|
||||||
|
client
|
||||||
|
- documentation improvements - rlpowell's tutorial - build instructions
|
||||||
|
- bind commands to key sequences? -- make it so ALL keys go through a table,
|
||||||
|
first an implicit table in which C-b is the only default binding to a
|
||||||
|
command that says "next key from $othertable" and so on. means -n can
|
||||||
|
go away as well
|
||||||
|
- monitor, bell etc should monitor /all/ panes in the window not just one
|
||||||
|
- a history of commands that can be reversed (reverse member of each command,
|
||||||
|
and a buffer) info() when changing to same window
|
||||||
|
- way to add dest for break-pane; maybe some easier way to unbreak-pane
|
||||||
|
- case insensitive searching
|
||||||
|
- option to move status line to top
|
||||||
|
- configurable borders and empty space filler for when panes < window?
|
||||||
|
- mouse-select-pane will screw up with !MODE_MOUSE_STANDARD (it sets the
|
||||||
|
flag on w/o checking the others before calling tty_update_mode)
|
||||||
|
- multiple keys could be done with tables, ie have prefixes go and instead
|
||||||
|
bind -n ^A prefix-table "default"
|
||||||
|
where prefix-table sets command lookup table and sets prefix flag, then next
|
||||||
|
key is looked up in that table
|
||||||
|
- pass shell commands as argv rather than strings, allow them to be specified
|
||||||
|
in commands without quotes
|
||||||
|
- a command to choose from a generic list, so you can do eg
|
||||||
|
choose-list -l Abc,Moo,Blah "run-shell 'sh /my/choose/script %%'"
|
||||||
|
- numeric prefix in copy mode should be paste buffer for C-w
|
||||||
|
- named buffers and allow gaps in the stack
|
||||||
|
- get rid of separate UTF-8 cell stuff: add 1 byte to cell and store BMP as
|
||||||
|
uint16_t+3 bits of flags. anything <=0xffff is Unicode, higher are used to
|
||||||
|
build tree of combined characters/non-BMP (LRU dropped when full)
|
||||||
|
- entry in FAQ about what to do when someone does mkdir /tmp/tmux-1000
|
||||||
|
- show size under pane number in display-panes mode
|
||||||
|
- monitor-activity is broken in several ways with multiple clients
|
||||||
|
- monitor-activity should be more powerful (eg set a region)
|
||||||
|
- maybe a way to put pane names instead of window names in status line
|
||||||
|
- support for borderless panes
|
||||||
|
- run-shell/if-shell should support status_replace stuff
|
||||||
|
- wait-pane command or another way to make it synchronous/wait for command to
|
||||||
|
finish
|
||||||
|
- last-pane across sessions
|
||||||
|
- attach should take a pane and select it as well as attaching
|
||||||
|
- should default-path be a window option?
|
||||||
|
- option to put status line at top (why?)
|
||||||
|
- panes should have names like windows
|
||||||
|
- command-prompt doesn't work if made read-only. why?
|
||||||
|
- option to quote format eg #{session_name:quoted}
|
||||||
|
- formats need to be used for much much more stuff!
|
||||||
|
- formats need conditions for >0 (for #P)
|
||||||
|
- flags to find-window to select what is searched (title, name, content, history)
|
||||||
|
- fetch full command line on !Linux, and add option to strip prefixes
|
||||||
|
such as "sh " "/bin/sh " etc etc
|
||||||
|
- synchronize-windows option
|
||||||
|
- possibly support rxvt-unicode extended mouse input (1015)
|
||||||
|
- append to buffer in copy mode
|
||||||
|
* We need a tmux terminfo entry to document the extensions we are using in
|
||||||
|
upstream terminfo. Must NOT change (only add or remove) anything from
|
||||||
|
TERM=screen so we can fallback!
|
||||||
|
|||||||
194
arg.c
194
arg.c
@@ -1,194 +0,0 @@
|
|||||||
/* $Id: arg.c,v 1.5 2008-08-28 17:45:25 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <fnmatch.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
struct client *arg_lookup_client(const char *);
|
|
||||||
struct session *arg_lookup_session(const char *);
|
|
||||||
|
|
||||||
struct client *
|
|
||||||
arg_lookup_client(const char *name)
|
|
||||||
{
|
|
||||||
struct client *c;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
|
||||||
c = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c != NULL && strcmp(name, c->tty.path) == 0)
|
|
||||||
return (c);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct session *
|
|
||||||
arg_lookup_session(const char *name)
|
|
||||||
{
|
|
||||||
struct session *s, *newest = NULL;
|
|
||||||
struct timeval *tv;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
tv = NULL;
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
|
|
||||||
s = ARRAY_ITEM(&sessions, i);
|
|
||||||
if (s == NULL || fnmatch(name, s->name, 0) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (tv == NULL || timercmp(&s->tv, tv, >)) {
|
|
||||||
newest = s;
|
|
||||||
tv = &s->tv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (newest);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct client *
|
|
||||||
arg_parse_client(const char *arg)
|
|
||||||
{
|
|
||||||
struct client *c;
|
|
||||||
char *arg2;
|
|
||||||
size_t n;
|
|
||||||
|
|
||||||
if (arg != NULL && (arg[0] != ':' || arg[1] != '\0')) {
|
|
||||||
arg2 = xstrdup(arg);
|
|
||||||
|
|
||||||
/* Trim a trailing : if any from the argument. */
|
|
||||||
n = strlen(arg2);
|
|
||||||
if (arg2[n - 1] == ':')
|
|
||||||
arg2[n - 1] = '\0';
|
|
||||||
|
|
||||||
/* Try and look up the client name. */
|
|
||||||
c = arg_lookup_client(arg2);
|
|
||||||
xfree(arg2);
|
|
||||||
return (c);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct session *
|
|
||||||
arg_parse_session(const char *arg)
|
|
||||||
{
|
|
||||||
struct session *s;
|
|
||||||
struct client *c;
|
|
||||||
char *arg2;
|
|
||||||
size_t n;
|
|
||||||
|
|
||||||
if (arg != NULL && (arg[0] != ':' || arg[1] != '\0')) {
|
|
||||||
arg2 = xstrdup(arg);
|
|
||||||
|
|
||||||
/* Trim a trailing : if any from the argument. */
|
|
||||||
n = strlen(arg2);
|
|
||||||
if (arg2[n - 1] == ':')
|
|
||||||
arg2[n - 1] = '\0';
|
|
||||||
|
|
||||||
/* See if the argument matches a session. */
|
|
||||||
if ((s = arg_lookup_session(arg2)) != NULL) {
|
|
||||||
xfree(arg2);
|
|
||||||
return (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If not try a client. */
|
|
||||||
if ((c = arg_lookup_client(arg2)) != NULL) {
|
|
||||||
xfree(arg2);
|
|
||||||
return (c->session);
|
|
||||||
}
|
|
||||||
|
|
||||||
xfree(arg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
arg_parse_window(const char *arg, struct session **s, int *idx)
|
|
||||||
{
|
|
||||||
char *arg2, *ptr;
|
|
||||||
const char *errstr;
|
|
||||||
|
|
||||||
*idx = -1;
|
|
||||||
|
|
||||||
/* Handle no argument or a single :. */
|
|
||||||
if (arg == NULL || (arg[0] == ':' && arg[1] == '\0')) {
|
|
||||||
*s = arg_parse_session(NULL);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the separator if any. */
|
|
||||||
arg2 = xstrdup(arg);
|
|
||||||
ptr = strrchr(arg2, ':');
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If it is first, this means no session name, so use current session
|
|
||||||
* and try to convert the rest as index.
|
|
||||||
*/
|
|
||||||
if (ptr == arg2) {
|
|
||||||
*idx = strtonum(ptr + 1, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xfree(arg2);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
xfree(arg2);
|
|
||||||
*s = arg_parse_session(NULL);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If missing, try as an index, else look up immediately. */
|
|
||||||
if (ptr == NULL) {
|
|
||||||
*idx = strtonum(arg2, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr == NULL) {
|
|
||||||
/* This is good as an index; use current session. */
|
|
||||||
xfree(arg2);
|
|
||||||
*s = arg_parse_session(NULL);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
*idx = -1;
|
|
||||||
goto lookup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If last, strip it and look up as a session. */
|
|
||||||
if (ptr[1] == '\0') {
|
|
||||||
*ptr = '\0';
|
|
||||||
goto lookup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Present but not first and not last. Break and convert both. */
|
|
||||||
*ptr = '\0';
|
|
||||||
*idx = strtonum(ptr + 1, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xfree(arg2);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
lookup:
|
|
||||||
/* Look up as session. */
|
|
||||||
*s = arg_parse_session(arg2);
|
|
||||||
xfree(arg2);
|
|
||||||
if (*s == NULL)
|
|
||||||
return (1);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
222
arguments.c
Normal file
222
arguments.c
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/* Create an arguments set with no flags. */
|
||||||
|
struct args *
|
||||||
|
args_create(int argc, ...)
|
||||||
|
{
|
||||||
|
struct args *args;
|
||||||
|
va_list ap;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
args = xcalloc(1, sizeof *args);
|
||||||
|
if ((args->flags = bit_alloc(SCHAR_MAX)) == NULL)
|
||||||
|
fatal("bit_alloc failed");
|
||||||
|
|
||||||
|
args->argc = argc;
|
||||||
|
if (argc == 0)
|
||||||
|
args->argv = NULL;
|
||||||
|
else
|
||||||
|
args->argv = xcalloc(argc, sizeof *args->argv);
|
||||||
|
|
||||||
|
va_start(ap, argc);
|
||||||
|
for (i = 0; i < argc; i++)
|
||||||
|
args->argv[i] = xstrdup(va_arg(ap, char *));
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse an argv and argc into a new argument set. */
|
||||||
|
struct args *
|
||||||
|
args_parse(const char *template, int argc, char **argv)
|
||||||
|
{
|
||||||
|
struct args *args;
|
||||||
|
char *ptr;
|
||||||
|
int opt;
|
||||||
|
|
||||||
|
args = xcalloc(1, sizeof *args);
|
||||||
|
if ((args->flags = bit_alloc(SCHAR_MAX)) == NULL)
|
||||||
|
fatal("bit_alloc failed");
|
||||||
|
|
||||||
|
optreset = 1;
|
||||||
|
optind = 1;
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, template)) != -1) {
|
||||||
|
if (opt < 0 || opt >= SCHAR_MAX)
|
||||||
|
continue;
|
||||||
|
if (opt == '?' || (ptr = strchr(template, opt)) == NULL) {
|
||||||
|
xfree(args->flags);
|
||||||
|
xfree(args);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
bit_set(args->flags, opt);
|
||||||
|
if (ptr[1] == ':') {
|
||||||
|
if (args->values[opt] != NULL)
|
||||||
|
xfree(args->values[opt]);
|
||||||
|
args->values[opt] = xstrdup(optarg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
argc -= optind;
|
||||||
|
argv += optind;
|
||||||
|
|
||||||
|
args->argc = argc;
|
||||||
|
args->argv = cmd_copy_argv(argc, argv);
|
||||||
|
|
||||||
|
return (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free an arguments set. */
|
||||||
|
void
|
||||||
|
args_free(struct args *args)
|
||||||
|
{
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
cmd_free_argv(args->argc, args->argv);
|
||||||
|
|
||||||
|
for (i = 0; i < SCHAR_MAX; i++) {
|
||||||
|
if (args->values[i] != NULL)
|
||||||
|
xfree(args->values[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
xfree(args->flags);
|
||||||
|
xfree(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print a set of arguments. */
|
||||||
|
size_t
|
||||||
|
args_print(struct args *args, char *buf, size_t len)
|
||||||
|
{
|
||||||
|
size_t off;
|
||||||
|
int i;
|
||||||
|
const char *quotes;
|
||||||
|
|
||||||
|
/* There must be at least one byte at the start. */
|
||||||
|
if (len == 0)
|
||||||
|
return (0);
|
||||||
|
off = 0;
|
||||||
|
|
||||||
|
/* Process the flags first. */
|
||||||
|
buf[off++] = '-';
|
||||||
|
for (i = 0; i < SCHAR_MAX; i++) {
|
||||||
|
if (!bit_test(args->flags, i) || args->values[i] != NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (off == len - 1) {
|
||||||
|
buf[off] = '\0';
|
||||||
|
return (len);
|
||||||
|
}
|
||||||
|
buf[off++] = i;
|
||||||
|
buf[off] = '\0';
|
||||||
|
}
|
||||||
|
if (off == 1)
|
||||||
|
buf[--off] = '\0';
|
||||||
|
|
||||||
|
/* Then the flags with arguments. */
|
||||||
|
for (i = 0; i < SCHAR_MAX; i++) {
|
||||||
|
if (!bit_test(args->flags, i) || args->values[i] == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (off >= len) {
|
||||||
|
/* snprintf will have zero terminated. */
|
||||||
|
return (len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strchr(args->values[i], ' ') != NULL)
|
||||||
|
quotes = "\"";
|
||||||
|
else
|
||||||
|
quotes = "";
|
||||||
|
off += xsnprintf(buf + off, len - off, "%s-%c %s%s%s",
|
||||||
|
off != 0 ? " " : "", i, quotes, args->values[i], quotes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* And finally the argument vector. */
|
||||||
|
for (i = 0; i < args->argc; i++) {
|
||||||
|
if (off >= len) {
|
||||||
|
/* snprintf will have zero terminated. */
|
||||||
|
return (len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strchr(args->argv[i], ' ') != NULL)
|
||||||
|
quotes = "\"";
|
||||||
|
else
|
||||||
|
quotes = "";
|
||||||
|
off += xsnprintf(buf + off, len - off, "%s%s%s%s",
|
||||||
|
off != 0 ? " " : "", quotes, args->argv[i], quotes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (off);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return if an argument is present. */
|
||||||
|
int
|
||||||
|
args_has(struct args *args, u_char ch)
|
||||||
|
{
|
||||||
|
return (bit_test(args->flags, ch));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set argument value. */
|
||||||
|
void
|
||||||
|
args_set(struct args *args, u_char ch, const char *value)
|
||||||
|
{
|
||||||
|
if (args->values[ch] != NULL)
|
||||||
|
xfree(args->values[ch]);
|
||||||
|
if (value != NULL)
|
||||||
|
args->values[ch] = xstrdup(value);
|
||||||
|
else
|
||||||
|
args->values[ch] = NULL;
|
||||||
|
bit_set(args->flags, ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get argument value. Will be NULL if it isn't present. */
|
||||||
|
const char *
|
||||||
|
args_get(struct args *args, u_char ch)
|
||||||
|
{
|
||||||
|
return (args->values[ch]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert an argument value to a number. */
|
||||||
|
long long
|
||||||
|
args_strtonum(struct args *args,
|
||||||
|
u_char ch, long long minval, long long maxval, char **cause)
|
||||||
|
{
|
||||||
|
const char *errstr;
|
||||||
|
long long ll;
|
||||||
|
|
||||||
|
if (!args_has(args, ch)) {
|
||||||
|
*cause = xstrdup("missing");
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ll = strtonum(args->values[ch], minval, maxval, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
*cause = xstrdup(errstr);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
*cause = NULL;
|
||||||
|
return (ll);
|
||||||
|
}
|
||||||
10
array.h
10
array.h
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: array.h,v 1.7 2008-09-29 16:58:02 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
#ifndef ARRAY_H
|
#ifndef ARRAY_H
|
||||||
#define ARRAY_H
|
#define ARRAY_H
|
||||||
|
|
||||||
|
#define ARRAY_INITIALIZER { NULL, 0, 0 }
|
||||||
|
|
||||||
#define ARRAY_DECL(n, c) \
|
#define ARRAY_DECL(n, c) \
|
||||||
struct n { \
|
struct n { \
|
||||||
c *list; \
|
c *list; \
|
||||||
@@ -45,7 +47,7 @@
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ARRAY_EMPTY(a) ((a) == NULL || (a)->num == 0)
|
#define ARRAY_EMPTY(a) (((void *) (a)) == NULL || (a)->num == 0)
|
||||||
#define ARRAY_LENGTH(a) ((a)->num)
|
#define ARRAY_LENGTH(a) ((a)->num)
|
||||||
#define ARRAY_DATA(a) ((a)->list)
|
#define ARRAY_DATA(a) ((a)->list)
|
||||||
|
|
||||||
@@ -85,7 +87,7 @@
|
|||||||
ARRAY_ITEMSIZE(a) * ((a)->num - (i) - 1)); \
|
ARRAY_ITEMSIZE(a) * ((a)->num - (i) - 1)); \
|
||||||
} \
|
} \
|
||||||
(a)->num--; \
|
(a)->num--; \
|
||||||
if ((a)->num == 0) \
|
if ((a)->num == 0) \
|
||||||
ARRAY_FREE(a); \
|
ARRAY_FREE(a); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@@ -102,7 +104,7 @@
|
|||||||
|
|
||||||
#define ARRAY_CONCAT(a, b) do { \
|
#define ARRAY_CONCAT(a, b) do { \
|
||||||
ARRAY_ENSURE(a, (b)->num); \
|
ARRAY_ENSURE(a, (b)->num); \
|
||||||
memcpy((a)->list + (a)->num, (b)->list, (b)->num * ARRAY_ITEMSIZE(a)) \
|
memcpy((a)->list + (a)->num, (b)->list, (b)->num * ARRAY_ITEMSIZE(a)); \
|
||||||
(a)->num += (b)->num; \
|
(a)->num += (b)->num; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|||||||
47
attributes.c
47
attributes.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: attributes.c,v 1.1 2009-01-27 20:22:33 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
|
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
|
||||||
@@ -23,29 +23,30 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
attributes_tostring(u_char ch)
|
attributes_tostring(u_char attr)
|
||||||
{
|
{
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
|
|
||||||
if (ch == 0)
|
if (attr == 0)
|
||||||
return ("default");
|
return ("none");
|
||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
if (ch & GRID_ATTR_BRIGHT)
|
if (attr & GRID_ATTR_BRIGHT)
|
||||||
strlcat(buf, "bright,", sizeof (buf));
|
strlcat(buf, "bright,", sizeof (buf));
|
||||||
if (ch & GRID_ATTR_DIM)
|
if (attr & GRID_ATTR_DIM)
|
||||||
strlcat(buf, "dim,", sizeof (buf));
|
strlcat(buf, "dim,", sizeof (buf));
|
||||||
if (ch & GRID_ATTR_UNDERSCORE)
|
if (attr & GRID_ATTR_UNDERSCORE)
|
||||||
strlcat(buf, "underscore,", sizeof (buf));
|
strlcat(buf, "underscore,", sizeof (buf));
|
||||||
if (ch & GRID_ATTR_BLINK)
|
if (attr & GRID_ATTR_BLINK)
|
||||||
strlcat(buf, "blink,", sizeof (buf));
|
strlcat(buf, "blink,", sizeof (buf));
|
||||||
if (ch & GRID_ATTR_REVERSE)
|
if (attr & GRID_ATTR_REVERSE)
|
||||||
strlcat(buf, "reverse,", sizeof (buf));
|
strlcat(buf, "reverse,", sizeof (buf));
|
||||||
if (ch & GRID_ATTR_HIDDEN)
|
if (attr & GRID_ATTR_HIDDEN)
|
||||||
strlcat(buf, "hidden,", sizeof (buf));
|
strlcat(buf, "hidden,", sizeof (buf));
|
||||||
if (ch & GRID_ATTR_ITALICS)
|
if (attr & GRID_ATTR_ITALICS)
|
||||||
strlcat(buf, "italics,", sizeof (buf));
|
strlcat(buf, "italics,", sizeof (buf));
|
||||||
*(strrchr(buf, ',')) = '\0';
|
if (*buf != '\0')
|
||||||
|
*(strrchr(buf, ',')) = '\0';
|
||||||
|
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
@@ -54,7 +55,7 @@ int
|
|||||||
attributes_fromstring(const char *str)
|
attributes_fromstring(const char *str)
|
||||||
{
|
{
|
||||||
const char delimiters[] = " ,|";
|
const char delimiters[] = " ,|";
|
||||||
u_char ch;
|
u_char attr;
|
||||||
size_t end;
|
size_t end;
|
||||||
|
|
||||||
if (*str == '\0' || strcspn(str, delimiters) == 0)
|
if (*str == '\0' || strcspn(str, delimiters) == 0)
|
||||||
@@ -62,31 +63,31 @@ attributes_fromstring(const char *str)
|
|||||||
if (strchr(delimiters, str[strlen(str) - 1]) != NULL)
|
if (strchr(delimiters, str[strlen(str) - 1]) != NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (strcasecmp(str, "default") == 0)
|
if (strcasecmp(str, "default") == 0 || strcasecmp(str, "none") == 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
ch = 0;
|
attr = 0;
|
||||||
do {
|
do {
|
||||||
end = strcspn(str, delimiters);
|
end = strcspn(str, delimiters);
|
||||||
if ((end == 6 && strncasecmp(str, "bright", end) == 0) ||
|
if ((end == 6 && strncasecmp(str, "bright", end) == 0) ||
|
||||||
(end == 4 && strncasecmp(str, "bold", end) == 0))
|
(end == 4 && strncasecmp(str, "bold", end) == 0))
|
||||||
ch |= GRID_ATTR_BRIGHT;
|
attr |= GRID_ATTR_BRIGHT;
|
||||||
else if (end == 3 && strncasecmp(str, "dim", end) == 0)
|
else if (end == 3 && strncasecmp(str, "dim", end) == 0)
|
||||||
ch |= GRID_ATTR_DIM;
|
attr |= GRID_ATTR_DIM;
|
||||||
else if (end == 10 && strncasecmp(str, "underscore", end) == 0)
|
else if (end == 10 && strncasecmp(str, "underscore", end) == 0)
|
||||||
ch |= GRID_ATTR_UNDERSCORE;
|
attr |= GRID_ATTR_UNDERSCORE;
|
||||||
else if (end == 5 && strncasecmp(str, "blink", end) == 0)
|
else if (end == 5 && strncasecmp(str, "blink", end) == 0)
|
||||||
ch |= GRID_ATTR_BLINK;
|
attr |= GRID_ATTR_BLINK;
|
||||||
else if (end == 7 && strncasecmp(str, "reverse", end) == 0)
|
else if (end == 7 && strncasecmp(str, "reverse", end) == 0)
|
||||||
ch |= GRID_ATTR_REVERSE;
|
attr |= GRID_ATTR_REVERSE;
|
||||||
else if (end == 6 && strncasecmp(str, "hidden", end) == 0)
|
else if (end == 6 && strncasecmp(str, "hidden", end) == 0)
|
||||||
ch |= GRID_ATTR_HIDDEN;
|
attr |= GRID_ATTR_HIDDEN;
|
||||||
else if (end == 7 && strncasecmp(str, "italics", end) == 0)
|
else if (end == 7 && strncasecmp(str, "italics", end) == 0)
|
||||||
ch |= GRID_ATTR_ITALICS;
|
attr |= GRID_ATTR_ITALICS;
|
||||||
else
|
else
|
||||||
return (-1);
|
return (-1);
|
||||||
str += end + strspn(str + end, delimiters);
|
str += end + strspn(str + end, delimiters);
|
||||||
} while (*str != '\0');
|
} while (*str != '\0');
|
||||||
|
|
||||||
return (ch);
|
return (attr);
|
||||||
}
|
}
|
||||||
|
|||||||
16
autogen.sh
Normal file
16
autogen.sh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
[ -z "$AUTOMAKE_VERSION" ] && export AUTOMAKE_VERSION=1.10
|
||||||
|
[ -z "$AUTOCONF_VERSION" ] && export AUTOCONF_VERSION=2.65
|
||||||
|
|
||||||
|
die()
|
||||||
|
{
|
||||||
|
echo "$@" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir -p etc
|
||||||
|
aclocal || die "aclocal failed"
|
||||||
|
automake --add-missing --force-missing --copy --foreign || die "automake failed"
|
||||||
|
autoreconf || die "autoreconf failed"
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
/* $Id: buffer-poll.c,v 1.10 2008-09-09 22:16:36 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/* Set up pollfd for buffers. */
|
|
||||||
void
|
|
||||||
buffer_set(
|
|
||||||
struct pollfd *pfd, int fd, unused struct buffer *in, struct buffer *out)
|
|
||||||
{
|
|
||||||
pfd->fd = fd;
|
|
||||||
pfd->events = POLLIN;
|
|
||||||
if (BUFFER_USED(out) > 0)
|
|
||||||
pfd->events |= POLLOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill buffers from socket based on poll results. */
|
|
||||||
int
|
|
||||||
buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
|
|
||||||
{
|
|
||||||
ssize_t n;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
log_debug("buffer_poll (%ld): fd=%d, revents=%d; out=%zu in=%zu",
|
|
||||||
(long) getpid(),
|
|
||||||
pfd->fd, pfd->revents, BUFFER_USED(out), BUFFER_USED(in));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BROKEN_POLL
|
|
||||||
if (pfd->revents & (POLLERR|POLLNVAL|POLLHUP))
|
|
||||||
return (-1);
|
|
||||||
#endif
|
|
||||||
if (pfd->revents & POLLIN) {
|
|
||||||
buffer_ensure(in, BUFSIZ);
|
|
||||||
n = read(pfd->fd, BUFFER_IN(in), BUFFER_FREE(in));
|
|
||||||
#if 0
|
|
||||||
log_debug("buffer_poll: fd=%d, read=%zd", pfd->fd, n);
|
|
||||||
#endif
|
|
||||||
if (n == 0)
|
|
||||||
return (-1);
|
|
||||||
if (n == -1) {
|
|
||||||
if (errno != EINTR && errno != EAGAIN)
|
|
||||||
return (-1);
|
|
||||||
} else
|
|
||||||
buffer_add(in, n);
|
|
||||||
}
|
|
||||||
if (BUFFER_USED(out) > 0 && pfd->revents & POLLOUT) {
|
|
||||||
n = write(pfd->fd, BUFFER_OUT(out), BUFFER_USED(out));
|
|
||||||
#if 0
|
|
||||||
log_debug("buffer_poll: fd=%d, write=%zd", pfd->fd, n);
|
|
||||||
#endif
|
|
||||||
if (n == -1) {
|
|
||||||
if (errno != EINTR && errno != EAGAIN)
|
|
||||||
return (-1);
|
|
||||||
} else
|
|
||||||
buffer_remove(out, n);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Flush buffer output to socket. */
|
|
||||||
void
|
|
||||||
buffer_flush(int fd, struct buffer *in, struct buffer *out)
|
|
||||||
{
|
|
||||||
struct pollfd pfd;
|
|
||||||
|
|
||||||
while (BUFFER_USED(out) > 0) {
|
|
||||||
buffer_set(&pfd, fd, in, out);
|
|
||||||
|
|
||||||
if (poll(&pfd, 1, INFTIM) == -1) {
|
|
||||||
if (errno == EAGAIN || errno == EINTR)
|
|
||||||
continue;
|
|
||||||
fatal("poll failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer_poll(&pfd, in, out) != 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
227
buffer.c
227
buffer.c
@@ -1,227 +0,0 @@
|
|||||||
/* $Id: buffer.c,v 1.5 2008-08-07 20:20:52 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/* Create a buffer. */
|
|
||||||
struct buffer *
|
|
||||||
buffer_create(size_t size)
|
|
||||||
{
|
|
||||||
struct buffer *b;
|
|
||||||
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
|
|
||||||
b = xcalloc(1, sizeof *b);
|
|
||||||
|
|
||||||
b->base = xmalloc(size);
|
|
||||||
b->space = size;
|
|
||||||
|
|
||||||
return (b);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Destroy a buffer. */
|
|
||||||
void
|
|
||||||
buffer_destroy(struct buffer *b)
|
|
||||||
{
|
|
||||||
xfree(b->base);
|
|
||||||
xfree(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Empty a buffer. */
|
|
||||||
void
|
|
||||||
buffer_clear(struct buffer *b)
|
|
||||||
{
|
|
||||||
b->size = 0;
|
|
||||||
b->off = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure free space for size in buffer. */
|
|
||||||
void
|
|
||||||
buffer_ensure(struct buffer *b, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
|
|
||||||
if (BUFFER_FREE(b) >= size)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (b->off > 0) {
|
|
||||||
if (b->size > 0)
|
|
||||||
memmove(b->base, b->base + b->off, b->size);
|
|
||||||
b->off = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SIZE_MAX - b->size < size)
|
|
||||||
fatalx("size too big");
|
|
||||||
while (b->space < b->size + size) {
|
|
||||||
b->base = xrealloc(b->base, 2, b->space);
|
|
||||||
b->space *= 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust buffer after data appended. */
|
|
||||||
void
|
|
||||||
buffer_add(struct buffer *b, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
if (size > b->space - b->size)
|
|
||||||
fatalx("overflow");
|
|
||||||
|
|
||||||
b->size += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reverse buffer add. */
|
|
||||||
void
|
|
||||||
buffer_reverse_add(struct buffer *b, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
if (size > b->size)
|
|
||||||
fatalx("underflow");
|
|
||||||
|
|
||||||
b->size -= size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust buffer after data removed. */
|
|
||||||
void
|
|
||||||
buffer_remove(struct buffer *b, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
if (size > b->size)
|
|
||||||
fatalx("underflow");
|
|
||||||
|
|
||||||
b->size -= size;
|
|
||||||
b->off += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reverse buffer remove. */
|
|
||||||
void
|
|
||||||
buffer_reverse_remove(struct buffer *b, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
if (size > b->off)
|
|
||||||
fatalx("overflow");
|
|
||||||
|
|
||||||
b->size += size;
|
|
||||||
b->off -= size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Insert a section into the buffer. */
|
|
||||||
void
|
|
||||||
buffer_insert_range(struct buffer *b, size_t base, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
if (base > b->size)
|
|
||||||
fatalx("range outside buffer");
|
|
||||||
|
|
||||||
buffer_ensure(b, size);
|
|
||||||
memmove(b->base + b->off + base + size,
|
|
||||||
b->base + b->off + base, b->size - base);
|
|
||||||
b->size += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Delete a section from the buffer. */
|
|
||||||
void
|
|
||||||
buffer_delete_range(struct buffer *b, size_t base, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
if (size > b->size)
|
|
||||||
fatalx("size too big");
|
|
||||||
if (base + size > b->size)
|
|
||||||
fatalx("range outside buffer");
|
|
||||||
|
|
||||||
memmove(b->base + b->off + base,
|
|
||||||
b->base + b->off + base + size, b->size - base - size);
|
|
||||||
b->size -= size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy data into a buffer. */
|
|
||||||
void
|
|
||||||
buffer_write(struct buffer *b, const void *data, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
|
|
||||||
buffer_ensure(b, size);
|
|
||||||
memcpy(BUFFER_IN(b), data, size);
|
|
||||||
buffer_add(b, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy data out of a buffer. */
|
|
||||||
void
|
|
||||||
buffer_read(struct buffer *b, void *data, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
if (size > b->size)
|
|
||||||
fatalx("underflow");
|
|
||||||
|
|
||||||
memcpy(data, BUFFER_OUT(b), size);
|
|
||||||
buffer_remove(b, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Store an 8-bit value. */
|
|
||||||
void
|
|
||||||
buffer_write8(struct buffer *b, uint8_t n)
|
|
||||||
{
|
|
||||||
buffer_ensure(b, 1);
|
|
||||||
BUFFER_IN(b)[0] = n;
|
|
||||||
buffer_add(b, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Store a 16-bit value. */
|
|
||||||
void
|
|
||||||
buffer_write16(struct buffer *b, uint16_t n)
|
|
||||||
{
|
|
||||||
buffer_ensure(b, 2);
|
|
||||||
BUFFER_IN(b)[0] = n & 0xff;
|
|
||||||
BUFFER_IN(b)[1] = n >> 8;
|
|
||||||
buffer_add(b, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Extract an 8-bit value. */
|
|
||||||
uint8_t
|
|
||||||
buffer_read8(struct buffer *b)
|
|
||||||
{
|
|
||||||
uint8_t n;
|
|
||||||
|
|
||||||
n = BUFFER_OUT(b)[0];
|
|
||||||
buffer_remove(b, 1);
|
|
||||||
return (n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Extract a 16-bit value. */
|
|
||||||
uint16_t
|
|
||||||
buffer_read16(struct buffer *b)
|
|
||||||
{
|
|
||||||
uint16_t n;
|
|
||||||
|
|
||||||
n = BUFFER_OUT(b)[0] | (BUFFER_OUT(b)[1] << 8);
|
|
||||||
buffer_remove(b, 2);
|
|
||||||
return (n);
|
|
||||||
}
|
|
||||||
113
cfg.c
113
cfg.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cfg.c,v 1.15 2009-03-31 22:23:43 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -29,17 +30,20 @@
|
|||||||
* argv array and executed as a command.
|
* argv array and executed as a command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *cfg_string(FILE *, char, int);
|
|
||||||
void printflike2 cfg_print(struct cmd_ctx *, const char *, ...);
|
void printflike2 cfg_print(struct cmd_ctx *, const char *, ...);
|
||||||
void printflike2 cfg_error(struct cmd_ctx *, const char *, ...);
|
void printflike2 cfg_error(struct cmd_ctx *, const char *, ...);
|
||||||
|
|
||||||
char *cfg_cause;
|
char *cfg_cause;
|
||||||
|
int cfg_finished;
|
||||||
|
struct causelist cfg_causes = ARRAY_INITIALIZER;
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
void printflike2
|
void printflike2
|
||||||
cfg_print(unused struct cmd_ctx *ctx, unused const char *fmt, ...)
|
cfg_print(unused struct cmd_ctx *ctx, unused const char *fmt, ...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
void printflike2
|
void printflike2
|
||||||
cfg_error(unused struct cmd_ctx *ctx, const char *fmt, ...)
|
cfg_error(unused struct cmd_ctx *ctx, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
@@ -50,72 +54,109 @@ cfg_error(unused struct cmd_ctx *ctx, const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void printflike2
|
||||||
load_cfg(const char *path, char **cause)
|
cfg_add_cause(struct causelist *causes, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
FILE *f;
|
char *cause;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
xvasprintf(&cause, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
ARRAY_ADD(causes, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load configuration file. Returns -1 for an error with a list of messages in
|
||||||
|
* causes. Note that causes must be initialised by the caller!
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
u_int n;
|
u_int n;
|
||||||
char *buf, *line, *ptr;
|
char *buf, *line, *cause;
|
||||||
size_t len;
|
size_t len;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd_ctx ctx;
|
struct cmd_ctx ctx;
|
||||||
|
int retval;
|
||||||
|
|
||||||
if ((f = fopen(path, "rb")) == NULL) {
|
if ((f = fopen(path, "rb")) == NULL) {
|
||||||
xasprintf(cause, "%s: %s", path, strerror(errno));
|
cfg_add_cause(causes, "%s: %s", path, strerror(errno));
|
||||||
return (1);
|
return (-1);
|
||||||
}
|
}
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
line = NULL;
|
line = NULL;
|
||||||
|
retval = 0;
|
||||||
while ((buf = fgetln(f, &len))) {
|
while ((buf = fgetln(f, &len))) {
|
||||||
if (buf[len - 1] == '\n')
|
if (buf[len - 1] == '\n')
|
||||||
buf[len - 1] = '\0';
|
len--;
|
||||||
|
|
||||||
|
if (line != NULL)
|
||||||
|
line = xrealloc(line, 1, strlen(line) + len + 1);
|
||||||
else {
|
else {
|
||||||
line = xrealloc(line, 1, len + 1);
|
line = xmalloc(len + 1);
|
||||||
memcpy(line, buf, len);
|
*line = '\0';
|
||||||
line[len] = '\0';
|
|
||||||
buf = line;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Append buffer to line. strncat will terminate. */
|
||||||
|
strncat(line, buf, len);
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
if (cmd_string_parse(buf, &cmdlist, cause) != 0) {
|
/* Continuation: get next line? */
|
||||||
if (*cause == NULL)
|
len = strlen(line);
|
||||||
continue;
|
if (len > 0 && line[len - 1] == '\\') {
|
||||||
goto error;
|
line[len - 1] = '\0';
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
buf = line;
|
||||||
|
line = NULL;
|
||||||
|
|
||||||
|
if (cmd_string_parse(buf, &cmdlist, &cause) != 0) {
|
||||||
|
xfree(buf);
|
||||||
|
if (cause == NULL)
|
||||||
|
continue;
|
||||||
|
cfg_add_cause(causes, "%s: %u: %s", path, n, cause);
|
||||||
|
xfree(cause);
|
||||||
|
continue;
|
||||||
|
} else
|
||||||
|
xfree(buf);
|
||||||
if (cmdlist == NULL)
|
if (cmdlist == NULL)
|
||||||
continue;
|
continue;
|
||||||
cfg_cause = NULL;
|
cfg_cause = NULL;
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
if (ctxin == NULL) {
|
||||||
ctx.cursession = NULL;
|
ctx.msgdata = NULL;
|
||||||
ctx.curclient = NULL;
|
ctx.curclient = NULL;
|
||||||
|
ctx.cmdclient = NULL;
|
||||||
|
} else {
|
||||||
|
ctx.msgdata = ctxin->msgdata;
|
||||||
|
ctx.curclient = ctxin->curclient;
|
||||||
|
ctx.cmdclient = ctxin->cmdclient;
|
||||||
|
}
|
||||||
|
|
||||||
ctx.error = cfg_error;
|
ctx.error = cfg_error;
|
||||||
ctx.print = cfg_print;
|
ctx.print = cfg_print;
|
||||||
ctx.info = cfg_print;
|
ctx.info = cfg_print;
|
||||||
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
|
|
||||||
cfg_cause = NULL;
|
cfg_cause = NULL;
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
if (cmd_list_exec(cmdlist, &ctx) == 1)
|
||||||
|
retval = 1;
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
if (cfg_cause != NULL) {
|
if (cfg_cause != NULL) {
|
||||||
*cause = cfg_cause;
|
cfg_add_cause(
|
||||||
goto error;
|
causes, "%s: %d: %s", path, n, cfg_cause);
|
||||||
|
xfree(cfg_cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (line != NULL)
|
if (line != NULL) {
|
||||||
|
cfg_add_cause(causes,
|
||||||
|
"%s: %d: line continuation at end of file", path, n);
|
||||||
xfree(line);
|
xfree(line);
|
||||||
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
return (0);
|
return (retval);
|
||||||
|
|
||||||
error:
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
xasprintf(&ptr, "%s: %s at line %u", path, *cause, n);
|
|
||||||
xfree(*cause);
|
|
||||||
*cause = ptr;
|
|
||||||
return (1);
|
|
||||||
}
|
}
|
||||||
|
|||||||
92
client-fn.c
92
client-fn.c
@@ -1,92 +0,0 @@
|
|||||||
/* $Id: client-fn.c,v 1.6 2009-03-04 17:24:07 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
client_fill_session(struct msg_command_data *data)
|
|
||||||
{
|
|
||||||
char *env, *ptr1, *ptr2, buf[256];
|
|
||||||
size_t len;
|
|
||||||
const char *errstr;
|
|
||||||
long long ll;
|
|
||||||
|
|
||||||
data->pid = -1;
|
|
||||||
if ((env = getenv("TMUX")) == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((ptr2 = strrchr(env, ',')) == NULL || ptr2 == env)
|
|
||||||
return;
|
|
||||||
for (ptr1 = ptr2 - 1; ptr1 > env && *ptr1 != ','; ptr1--)
|
|
||||||
;
|
|
||||||
if (*ptr1 != ',')
|
|
||||||
return;
|
|
||||||
ptr1++;
|
|
||||||
ptr2++;
|
|
||||||
|
|
||||||
len = ptr2 - ptr1 - 1;
|
|
||||||
if (len > (sizeof buf) - 1)
|
|
||||||
return;
|
|
||||||
memcpy(buf, ptr1, len);
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
ll = strtonum(buf, 0, LONG_MAX, &errstr);
|
|
||||||
if (errstr != NULL)
|
|
||||||
return;
|
|
||||||
data->pid = ll;
|
|
||||||
|
|
||||||
ll = strtonum(ptr2, 0, UINT_MAX, &errstr);
|
|
||||||
if (errstr != NULL)
|
|
||||||
return;
|
|
||||||
data->idx = ll;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
client_write_server(
|
|
||||||
struct client_ctx *cctx, enum hdrtype type, void *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct hdr hdr;
|
|
||||||
|
|
||||||
hdr.type = type;
|
|
||||||
hdr.size = len;
|
|
||||||
buffer_write(cctx->srv_out, &hdr, sizeof hdr);
|
|
||||||
|
|
||||||
if (buf != NULL && len > 0)
|
|
||||||
buffer_write(cctx->srv_out, buf, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
client_write_server2(struct client_ctx *cctx,
|
|
||||||
enum hdrtype type, void *buf1, size_t len1, void *buf2, size_t len2)
|
|
||||||
{
|
|
||||||
struct hdr hdr;
|
|
||||||
|
|
||||||
hdr.type = type;
|
|
||||||
hdr.size = len1 + len2;
|
|
||||||
buffer_write(cctx->srv_out, &hdr, sizeof hdr);
|
|
||||||
|
|
||||||
if (buf1 != NULL && len1 > 0)
|
|
||||||
buffer_write(cctx->srv_out, buf1, len1);
|
|
||||||
if (buf2 != NULL && len2 > 0)
|
|
||||||
buffer_write(cctx->srv_out, buf2, len2);
|
|
||||||
}
|
|
||||||
159
client-msg.c
159
client-msg.c
@@ -1,159 +0,0 @@
|
|||||||
/* $Id: client-msg.c,v 1.18 2009-01-21 22:47:31 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
int client_msg_fn_detach(struct hdr *, struct client_ctx *, char **);
|
|
||||||
int client_msg_fn_error(struct hdr *, struct client_ctx *, char **);
|
|
||||||
int client_msg_fn_shutdown(struct hdr *, struct client_ctx *, char **);
|
|
||||||
int client_msg_fn_exit(struct hdr *, struct client_ctx *, char **);
|
|
||||||
int client_msg_fn_exited(struct hdr *, struct client_ctx *, char **);
|
|
||||||
int client_msg_fn_suspend(struct hdr *, struct client_ctx *, char **);
|
|
||||||
|
|
||||||
struct client_msg {
|
|
||||||
enum hdrtype type;
|
|
||||||
int (*fn)(struct hdr *, struct client_ctx *, char **);
|
|
||||||
};
|
|
||||||
struct client_msg client_msg_table[] = {
|
|
||||||
{ MSG_DETACH, client_msg_fn_detach },
|
|
||||||
{ MSG_ERROR, client_msg_fn_error },
|
|
||||||
{ MSG_EXIT, client_msg_fn_exit },
|
|
||||||
{ MSG_EXITED, client_msg_fn_exited },
|
|
||||||
{ MSG_SHUTDOWN, client_msg_fn_shutdown },
|
|
||||||
{ MSG_SUSPEND, client_msg_fn_suspend },
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
client_msg_dispatch(struct client_ctx *cctx, char **error)
|
|
||||||
{
|
|
||||||
struct hdr hdr;
|
|
||||||
struct client_msg *msg;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
if (BUFFER_USED(cctx->srv_in) < sizeof hdr)
|
|
||||||
return (1);
|
|
||||||
memcpy(&hdr, BUFFER_OUT(cctx->srv_in), sizeof hdr);
|
|
||||||
if (BUFFER_USED(cctx->srv_in) < (sizeof hdr) + hdr.size)
|
|
||||||
return (1);
|
|
||||||
buffer_remove(cctx->srv_in, sizeof hdr);
|
|
||||||
|
|
||||||
for (i = 0; i < nitems(client_msg_table); i++) {
|
|
||||||
msg = client_msg_table + i;
|
|
||||||
if (msg->type == hdr.type) {
|
|
||||||
if (msg->fn(&hdr, cctx, error) != 0)
|
|
||||||
return (-1);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fatalx("unexpected message");
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
client_msg_fn_error(struct hdr *hdr, struct client_ctx *cctx, char **error)
|
|
||||||
{
|
|
||||||
if (hdr->size > SIZE_MAX - 1)
|
|
||||||
fatalx("bad MSG_ERROR size");
|
|
||||||
|
|
||||||
*error = xmalloc(hdr->size + 1);
|
|
||||||
buffer_read(cctx->srv_in, *error, hdr->size);
|
|
||||||
(*error)[hdr->size] = '\0';
|
|
||||||
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
client_msg_fn_detach(
|
|
||||||
struct hdr *hdr, unused struct client_ctx *cctx, unused char **error)
|
|
||||||
{
|
|
||||||
if (hdr->size != 0)
|
|
||||||
fatalx("bad MSG_DETACH size");
|
|
||||||
|
|
||||||
client_write_server(cctx, MSG_EXITING, NULL, 0);
|
|
||||||
cctx->flags |= CCTX_DETACH;
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
client_msg_fn_shutdown(
|
|
||||||
struct hdr *hdr, unused struct client_ctx *cctx, unused char **error)
|
|
||||||
{
|
|
||||||
if (hdr->size != 0)
|
|
||||||
fatalx("bad MSG_SHUTDOWN size");
|
|
||||||
|
|
||||||
client_write_server(cctx, MSG_EXITING, NULL, 0);
|
|
||||||
cctx->flags |= CCTX_SHUTDOWN;
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
client_msg_fn_exit(
|
|
||||||
struct hdr *hdr, unused struct client_ctx *cctx, unused char **error)
|
|
||||||
{
|
|
||||||
if (hdr->size != 0)
|
|
||||||
fatalx("bad MSG_EXIT size");
|
|
||||||
|
|
||||||
client_write_server(cctx, MSG_EXITING, NULL, 0);
|
|
||||||
cctx->flags |= CCTX_EXIT;
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
client_msg_fn_exited(
|
|
||||||
struct hdr *hdr, unused struct client_ctx *cctx, unused char **error)
|
|
||||||
{
|
|
||||||
if (hdr->size != 0)
|
|
||||||
fatalx("bad MSG_EXITED size");
|
|
||||||
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
client_msg_fn_suspend(
|
|
||||||
struct hdr *hdr, unused struct client_ctx *cctx, unused char **error)
|
|
||||||
{
|
|
||||||
struct sigaction act;
|
|
||||||
|
|
||||||
if (hdr->size != 0)
|
|
||||||
fatalx("bad MSG_SUSPEND size");
|
|
||||||
|
|
||||||
memset(&act, 0, sizeof act);
|
|
||||||
sigemptyset(&act.sa_mask);
|
|
||||||
act.sa_flags = SA_RESTART;
|
|
||||||
|
|
||||||
act.sa_handler = SIG_DFL;
|
|
||||||
if (sigaction(SIGTSTP, &act, NULL) != 0)
|
|
||||||
fatal("sigaction failed");
|
|
||||||
|
|
||||||
act.sa_handler = sighandler;
|
|
||||||
if (sigaction(SIGCONT, &act, NULL) != 0)
|
|
||||||
fatal("sigaction failed");
|
|
||||||
|
|
||||||
kill(getpid(), SIGTSTP);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
616
client.c
616
client.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: client.c,v 1.46 2009-03-31 22:20:42 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -17,212 +17,492 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <event.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
void client_handle_winch(struct client_ctx *);
|
struct imsgbuf client_ibuf;
|
||||||
|
struct event client_event;
|
||||||
|
const char *client_exitmsg;
|
||||||
|
int client_exitval;
|
||||||
|
enum msgtype client_exittype;
|
||||||
|
int client_attached;
|
||||||
|
|
||||||
|
int client_connect(char *, int);
|
||||||
|
void client_send_identify(int);
|
||||||
|
void client_send_environ(void);
|
||||||
|
void client_write_server(enum msgtype, void *, size_t);
|
||||||
|
void client_update_event(void);
|
||||||
|
void client_signal(int, short, void *);
|
||||||
|
void client_callback(int, short, void *);
|
||||||
|
int client_dispatch_attached(void);
|
||||||
|
int client_dispatch_wait(void *);
|
||||||
|
|
||||||
|
/* Connect client to server. */
|
||||||
int
|
int
|
||||||
client_init(char *path, struct client_ctx *cctx, int start_server, int flags)
|
client_connect(char *path, int start_server)
|
||||||
{
|
{
|
||||||
struct sockaddr_un sa;
|
struct sockaddr_un sa;
|
||||||
struct stat sb;
|
size_t size;
|
||||||
struct msg_identify_data data;
|
int fd;
|
||||||
struct winsize ws;
|
|
||||||
size_t size;
|
|
||||||
int mode;
|
|
||||||
struct buffer *b;
|
|
||||||
char *name;
|
|
||||||
|
|
||||||
if (lstat(path, &sb) != 0) {
|
|
||||||
if (start_server && errno == ENOENT) {
|
|
||||||
if ((cctx->srv_fd = server_start(path)) == -1)
|
|
||||||
goto start_failed;
|
|
||||||
goto server_started;
|
|
||||||
}
|
|
||||||
goto not_found;
|
|
||||||
}
|
|
||||||
if (!S_ISSOCK(sb.st_mode)) {
|
|
||||||
errno = ENOTSOCK;
|
|
||||||
goto not_found;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&sa, 0, sizeof sa);
|
memset(&sa, 0, sizeof sa);
|
||||||
sa.sun_family = AF_UNIX;
|
sa.sun_family = AF_UNIX;
|
||||||
size = strlcpy(sa.sun_path, path, sizeof sa.sun_path);
|
size = strlcpy(sa.sun_path, path, sizeof sa.sun_path);
|
||||||
if (size >= sizeof sa.sun_path) {
|
if (size >= sizeof sa.sun_path) {
|
||||||
errno = ENAMETOOLONG;
|
errno = ENAMETOOLONG;
|
||||||
goto not_found;
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cctx->srv_fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
||||||
fatal("socket");
|
fatal("socket failed");
|
||||||
|
|
||||||
if (connect(
|
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
||||||
cctx->srv_fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
if (!start_server)
|
||||||
if (errno == ECONNREFUSED) {
|
goto failed;
|
||||||
if (unlink(path) != 0 || !start_server)
|
switch (errno) {
|
||||||
goto not_found;
|
case ECONNREFUSED:
|
||||||
if ((cctx->srv_fd = server_start(path)) == -1)
|
if (unlink(path) != 0)
|
||||||
goto start_failed;
|
goto failed;
|
||||||
goto server_started;
|
/* FALLTHROUGH */
|
||||||
}
|
case ENOENT:
|
||||||
goto not_found;
|
if ((fd = server_start()) == -1)
|
||||||
}
|
goto failed;
|
||||||
|
|
||||||
server_started:
|
|
||||||
if ((mode = fcntl(cctx->srv_fd, F_GETFL)) == -1)
|
|
||||||
fatal("fcntl failed");
|
|
||||||
if (fcntl(cctx->srv_fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
|
||||||
fatal("fcntl failed");
|
|
||||||
cctx->srv_in = buffer_create(BUFSIZ);
|
|
||||||
cctx->srv_out = buffer_create(BUFSIZ);
|
|
||||||
|
|
||||||
if (isatty(STDIN_FILENO)) {
|
|
||||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
|
|
||||||
fatal("ioctl(TIOCGWINSZ)");
|
|
||||||
data.version = PROTOCOL_VERSION;
|
|
||||||
data.flags = flags;
|
|
||||||
data.sx = ws.ws_col;
|
|
||||||
data.sy = ws.ws_row;
|
|
||||||
*data.tty = '\0';
|
|
||||||
if (getcwd(data.cwd, sizeof data.cwd) == NULL)
|
|
||||||
*data.cwd = '\0';
|
|
||||||
|
|
||||||
if ((name = ttyname(STDIN_FILENO)) == NULL)
|
|
||||||
fatal("ttyname failed");
|
|
||||||
if (strlcpy(data.tty, name, sizeof data.tty) >= sizeof data.tty)
|
|
||||||
fatalx("ttyname failed");
|
|
||||||
|
|
||||||
b = buffer_create(BUFSIZ);
|
|
||||||
cmd_send_string(b, getenv("TERM"));
|
|
||||||
client_write_server2(cctx, MSG_IDENTIFY,
|
|
||||||
&data, sizeof data, BUFFER_OUT(b), BUFFER_USED(b));
|
|
||||||
buffer_destroy(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
start_failed:
|
|
||||||
log_warnx("server failed to start");
|
|
||||||
return (1);
|
|
||||||
|
|
||||||
not_found:
|
|
||||||
log_warn("server not found");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
client_main(struct client_ctx *cctx)
|
|
||||||
{
|
|
||||||
struct pollfd pfd;
|
|
||||||
char *error;
|
|
||||||
int xtimeout; /* Yay for ncurses namespace! */
|
|
||||||
|
|
||||||
siginit();
|
|
||||||
|
|
||||||
logfile("client");
|
|
||||||
#ifndef NO_SETPROCTITLE
|
|
||||||
setproctitle("client");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
error = NULL;
|
|
||||||
xtimeout = INFTIM;
|
|
||||||
while (!sigterm) {
|
|
||||||
if (sigchld) {
|
|
||||||
waitpid(WAIT_ANY, NULL, WNOHANG);
|
|
||||||
sigchld = 0;
|
|
||||||
}
|
|
||||||
if (sigwinch)
|
|
||||||
client_handle_winch(cctx);
|
|
||||||
if (sigcont) {
|
|
||||||
siginit();
|
|
||||||
client_write_server(cctx, MSG_WAKEUP, NULL, 0);
|
|
||||||
sigcont = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (client_msg_dispatch(cctx, &error)) {
|
|
||||||
case -1:
|
|
||||||
goto out;
|
|
||||||
case 0:
|
|
||||||
/* May be more in buffer, don't let poll block. */
|
|
||||||
xtimeout = 0;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Out of data, poll may block. */
|
goto failed;
|
||||||
xtimeout = INFTIM;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setblocking(fd, 0);
|
||||||
|
return (fd);
|
||||||
|
|
||||||
|
failed:
|
||||||
|
close(fd);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Client main loop. */
|
||||||
|
int
|
||||||
|
client_main(int argc, char **argv, int flags)
|
||||||
|
{
|
||||||
|
struct cmd *cmd;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
struct msg_command_data cmddata;
|
||||||
|
int cmdflags, fd;
|
||||||
|
pid_t ppid;
|
||||||
|
enum msgtype msg;
|
||||||
|
char *cause;
|
||||||
|
|
||||||
|
/* Set up the initial command. */
|
||||||
|
cmdflags = 0;
|
||||||
|
if (shell_cmd != NULL) {
|
||||||
|
msg = MSG_SHELL;
|
||||||
|
cmdflags = CMD_STARTSERVER;
|
||||||
|
} else if (argc == 0) {
|
||||||
|
msg = MSG_COMMAND;
|
||||||
|
cmdflags = CMD_STARTSERVER|CMD_SENDENVIRON|CMD_CANTNEST;
|
||||||
|
} else {
|
||||||
|
msg = MSG_COMMAND;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* It sucks parsing the command string twice (in client and
|
||||||
|
* later in server) but it is necessary to get the start server
|
||||||
|
* flag.
|
||||||
|
*/
|
||||||
|
if ((cmdlist = cmd_list_parse(argc, argv, &cause)) == NULL) {
|
||||||
|
log_warnx("%s", cause);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
cmdflags &= ~CMD_STARTSERVER;
|
||||||
|
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||||
|
if (cmd->entry->flags & CMD_STARTSERVER)
|
||||||
|
cmdflags |= CMD_STARTSERVER;
|
||||||
|
if (cmd->entry->flags & CMD_SENDENVIRON)
|
||||||
|
cmdflags |= CMD_SENDENVIRON;
|
||||||
|
if (cmd->entry->flags & CMD_CANTNEST)
|
||||||
|
cmdflags |= CMD_CANTNEST;
|
||||||
|
}
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if this could be a nested session, if the command can't nest:
|
||||||
|
* if the socket path matches $TMUX, this is probably the same server.
|
||||||
|
*/
|
||||||
|
if (shell_cmd == NULL && environ_path != NULL &&
|
||||||
|
cmdflags & CMD_CANTNEST && strcmp(socket_path, environ_path) == 0) {
|
||||||
|
log_warnx("sessions should be nested with care. "
|
||||||
|
"unset $TMUX to force.");
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialise the client socket and start the server. */
|
||||||
|
fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
|
||||||
|
if (fd == -1) {
|
||||||
|
log_warn("failed to connect to server");
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set process title, log and signals now this is the client. */
|
||||||
|
#ifdef HAVE_SETPROCTITLE
|
||||||
|
setproctitle("client (%s)", socket_path);
|
||||||
|
#endif
|
||||||
|
logfile("client");
|
||||||
|
|
||||||
|
/* Create imsg. */
|
||||||
|
imsg_init(&client_ibuf, fd);
|
||||||
|
event_set(&client_event, fd, EV_READ, client_callback, shell_cmd);
|
||||||
|
|
||||||
|
/* Establish signal handlers. */
|
||||||
|
set_signals(client_signal);
|
||||||
|
|
||||||
|
/* Send initial environment. */
|
||||||
|
if (cmdflags & CMD_SENDENVIRON)
|
||||||
|
client_send_environ();
|
||||||
|
client_send_identify(flags);
|
||||||
|
|
||||||
|
/* Send first command. */
|
||||||
|
if (msg == MSG_COMMAND) {
|
||||||
|
/* Fill in command line arguments. */
|
||||||
|
cmddata.pid = environ_pid;
|
||||||
|
cmddata.idx = environ_idx;
|
||||||
|
|
||||||
|
/* Prepare command for server. */
|
||||||
|
cmddata.argc = argc;
|
||||||
|
if (cmd_pack_argv(
|
||||||
|
argc, argv, cmddata.argv, sizeof cmddata.argv) != 0) {
|
||||||
|
log_warnx("command too long");
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
client_write_server(msg, &cmddata, sizeof cmddata);
|
||||||
|
} else if (msg == MSG_SHELL)
|
||||||
|
client_write_server(msg, NULL, 0);
|
||||||
|
|
||||||
|
/* Set the event and dispatch. */
|
||||||
|
client_update_event();
|
||||||
|
event_dispatch();
|
||||||
|
|
||||||
|
/* Print the exit message, if any, and exit. */
|
||||||
|
if (client_attached) {
|
||||||
|
if (client_exitmsg != NULL && !login_shell)
|
||||||
|
printf("[%s]\n", client_exitmsg);
|
||||||
|
|
||||||
|
ppid = getppid();
|
||||||
|
if (client_exittype == MSG_DETACHKILL && ppid > 1)
|
||||||
|
kill(ppid, SIGHUP);
|
||||||
|
}
|
||||||
|
return (client_exitval);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Send identify message to server with the file descriptors. */
|
||||||
|
void
|
||||||
|
client_send_identify(int flags)
|
||||||
|
{
|
||||||
|
struct msg_identify_data data;
|
||||||
|
char *term;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
data.flags = flags;
|
||||||
|
|
||||||
|
if (getcwd(data.cwd, sizeof data.cwd) == NULL)
|
||||||
|
*data.cwd = '\0';
|
||||||
|
|
||||||
|
term = getenv("TERM");
|
||||||
|
if (term == NULL ||
|
||||||
|
strlcpy(data.term, term, sizeof data.term) >= sizeof data.term)
|
||||||
|
*data.term = '\0';
|
||||||
|
|
||||||
|
if ((fd = dup(STDIN_FILENO)) == -1)
|
||||||
|
fatal("dup failed");
|
||||||
|
imsg_compose(&client_ibuf,
|
||||||
|
MSG_IDENTIFY, PROTOCOL_VERSION, -1, fd, &data, sizeof data);
|
||||||
|
|
||||||
|
if ((fd = dup(STDOUT_FILENO)) == -1)
|
||||||
|
fatal("dup failed");
|
||||||
|
imsg_compose(&client_ibuf,
|
||||||
|
MSG_STDOUT, PROTOCOL_VERSION, -1, fd, NULL, 0);
|
||||||
|
|
||||||
|
if ((fd = dup(STDERR_FILENO)) == -1)
|
||||||
|
fatal("dup failed");
|
||||||
|
imsg_compose(&client_ibuf,
|
||||||
|
MSG_STDERR, PROTOCOL_VERSION, -1, fd, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Forward entire environment to server. */
|
||||||
|
void
|
||||||
|
client_send_environ(void)
|
||||||
|
{
|
||||||
|
struct msg_environ_data data;
|
||||||
|
char **var;
|
||||||
|
|
||||||
|
for (var = environ; *var != NULL; var++) {
|
||||||
|
if (strlcpy(data.var, *var, sizeof data.var) >= sizeof data.var)
|
||||||
|
continue;
|
||||||
|
client_write_server(MSG_ENVIRON, &data, sizeof data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write a message to the server without a file descriptor. */
|
||||||
|
void
|
||||||
|
client_write_server(enum msgtype type, void *buf, size_t len)
|
||||||
|
{
|
||||||
|
imsg_compose(&client_ibuf, type, PROTOCOL_VERSION, -1, -1, buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update client event based on whether it needs to read or read and write. */
|
||||||
|
void
|
||||||
|
client_update_event(void)
|
||||||
|
{
|
||||||
|
short events;
|
||||||
|
|
||||||
|
event_del(&client_event);
|
||||||
|
events = EV_READ;
|
||||||
|
if (client_ibuf.w.queued > 0)
|
||||||
|
events |= EV_WRITE;
|
||||||
|
event_set(
|
||||||
|
&client_event, client_ibuf.fd, events, client_callback, shell_cmd);
|
||||||
|
event_add(&client_event, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Callback to handle signals in the client. */
|
||||||
|
/* ARGSUSED */
|
||||||
|
void
|
||||||
|
client_signal(int sig, unused short events, unused void *data)
|
||||||
|
{
|
||||||
|
struct sigaction sigact;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
if (!client_attached) {
|
||||||
|
switch (sig) {
|
||||||
|
case SIGCHLD:
|
||||||
|
waitpid(WAIT_ANY, &status, WNOHANG);
|
||||||
|
break;
|
||||||
|
case SIGTERM:
|
||||||
|
event_loopexit(NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
switch (sig) {
|
||||||
|
case SIGHUP:
|
||||||
|
client_exitmsg = "lost tty";
|
||||||
|
client_exitval = 1;
|
||||||
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
|
break;
|
||||||
|
case SIGTERM:
|
||||||
|
client_exitmsg = "terminated";
|
||||||
|
client_exitval = 1;
|
||||||
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
|
break;
|
||||||
|
case SIGWINCH:
|
||||||
|
client_write_server(MSG_RESIZE, NULL, 0);
|
||||||
|
break;
|
||||||
|
case SIGCONT:
|
||||||
|
memset(&sigact, 0, sizeof sigact);
|
||||||
|
sigemptyset(&sigact.sa_mask);
|
||||||
|
sigact.sa_flags = SA_RESTART;
|
||||||
|
sigact.sa_handler = SIG_IGN;
|
||||||
|
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
||||||
|
fatal("sigaction failed");
|
||||||
|
client_write_server(MSG_WAKEUP, NULL, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pfd.fd = cctx->srv_fd;
|
client_update_event();
|
||||||
pfd.events = POLLIN;
|
}
|
||||||
if (BUFFER_USED(cctx->srv_out) > 0)
|
|
||||||
pfd.events |= POLLOUT;
|
|
||||||
|
|
||||||
if (poll(&pfd, 1, xtimeout) == -1) {
|
/* Callback for client imsg read events. */
|
||||||
if (errno == EAGAIN || errno == EINTR)
|
/* ARGSUSED */
|
||||||
continue;
|
void
|
||||||
fatal("poll failed");
|
client_callback(unused int fd, short events, void *data)
|
||||||
|
{
|
||||||
|
ssize_t n;
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
if (events & EV_READ) {
|
||||||
|
if ((n = imsg_read(&client_ibuf)) == -1 || n == 0)
|
||||||
|
goto lost_server;
|
||||||
|
if (client_attached)
|
||||||
|
retval = client_dispatch_attached();
|
||||||
|
else
|
||||||
|
retval = client_dispatch_wait(data);
|
||||||
|
if (retval != 0) {
|
||||||
|
event_loopexit(NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (events & EV_WRITE) {
|
||||||
|
if (msgbuf_write(&client_ibuf.w) < 0)
|
||||||
|
goto lost_server;
|
||||||
|
}
|
||||||
|
|
||||||
|
client_update_event();
|
||||||
|
return;
|
||||||
|
|
||||||
|
lost_server:
|
||||||
|
client_exitmsg = "lost server";
|
||||||
|
client_exitval = 1;
|
||||||
|
event_loopexit(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dispatch imsgs when in wait state (before MSG_READY). */
|
||||||
|
int
|
||||||
|
client_dispatch_wait(void *data)
|
||||||
|
{
|
||||||
|
struct imsg imsg;
|
||||||
|
ssize_t n, datalen;
|
||||||
|
struct msg_shell_data shelldata;
|
||||||
|
struct msg_exit_data exitdata;
|
||||||
|
const char *shellcmd = data;
|
||||||
|
|
||||||
|
if ((n = imsg_read(&client_ibuf)) == -1 || n == 0)
|
||||||
|
fatalx("imsg_read failed");
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
|
||||||
|
fatalx("imsg_get failed");
|
||||||
|
if (n == 0)
|
||||||
|
return (0);
|
||||||
|
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
|
||||||
|
|
||||||
|
switch (imsg.hdr.type) {
|
||||||
|
case MSG_EXIT:
|
||||||
|
case MSG_SHUTDOWN:
|
||||||
|
if (datalen != sizeof exitdata) {
|
||||||
|
if (datalen != 0)
|
||||||
|
fatalx("bad MSG_EXIT size");
|
||||||
|
} else {
|
||||||
|
memcpy(&exitdata, imsg.data, sizeof exitdata);
|
||||||
|
client_exitval = exitdata.retcode;
|
||||||
|
}
|
||||||
|
imsg_free(&imsg);
|
||||||
|
return (-1);
|
||||||
|
case MSG_READY:
|
||||||
|
if (datalen != 0)
|
||||||
|
fatalx("bad MSG_READY size");
|
||||||
|
|
||||||
|
client_attached = 1;
|
||||||
|
break;
|
||||||
|
case MSG_VERSION:
|
||||||
|
if (datalen != 0)
|
||||||
|
fatalx("bad MSG_VERSION size");
|
||||||
|
|
||||||
|
log_warnx("protocol version mismatch (client %u, "
|
||||||
|
"server %u)", PROTOCOL_VERSION, imsg.hdr.peerid);
|
||||||
|
client_exitval = 1;
|
||||||
|
|
||||||
|
imsg_free(&imsg);
|
||||||
|
return (-1);
|
||||||
|
case MSG_SHELL:
|
||||||
|
if (datalen != sizeof shelldata)
|
||||||
|
fatalx("bad MSG_SHELL size");
|
||||||
|
memcpy(&shelldata, imsg.data, sizeof shelldata);
|
||||||
|
shelldata.shell[(sizeof shelldata.shell) - 1] = '\0';
|
||||||
|
|
||||||
|
clear_signals(0);
|
||||||
|
|
||||||
|
shell_exec(shelldata.shell, shellcmd);
|
||||||
|
/* NOTREACHED */
|
||||||
|
default:
|
||||||
|
fatalx("unexpected message");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer_poll(&pfd, cctx->srv_in, cctx->srv_out) != 0)
|
imsg_free(&imsg);
|
||||||
goto server_dead;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
if (sigterm) {
|
|
||||||
printf("[terminated]\n");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cctx->flags & CCTX_SHUTDOWN) {
|
|
||||||
printf("[server exited]\n");
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cctx->flags & CCTX_EXIT) {
|
|
||||||
printf("[exited]\n");
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cctx->flags & CCTX_DETACH) {
|
|
||||||
printf("[detached]\n");
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("[error: %s]\n", error);
|
|
||||||
return (1);
|
|
||||||
|
|
||||||
server_dead:
|
|
||||||
printf("[lost server]\n");
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* Dispatch imsgs in attached state (after MSG_READY). */
|
||||||
client_handle_winch(struct client_ctx *cctx)
|
/* ARGSUSED */
|
||||||
|
int
|
||||||
|
client_dispatch_attached(void)
|
||||||
{
|
{
|
||||||
struct msg_resize_data data;
|
struct imsg imsg;
|
||||||
struct winsize ws;
|
struct msg_lock_data lockdata;
|
||||||
|
struct sigaction sigact;
|
||||||
|
ssize_t n, datalen;
|
||||||
|
|
||||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
|
for (;;) {
|
||||||
fatal("ioctl failed");
|
if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
|
||||||
|
fatalx("imsg_get failed");
|
||||||
|
if (n == 0)
|
||||||
|
return (0);
|
||||||
|
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
|
||||||
|
|
||||||
data.sx = ws.ws_col;
|
log_debug("client got %d", imsg.hdr.type);
|
||||||
data.sy = ws.ws_row;
|
switch (imsg.hdr.type) {
|
||||||
client_write_server(cctx, MSG_RESIZE, &data, sizeof data);
|
case MSG_DETACHKILL:
|
||||||
|
case MSG_DETACH:
|
||||||
|
if (datalen != 0)
|
||||||
|
fatalx("bad MSG_DETACH size");
|
||||||
|
|
||||||
sigwinch = 0;
|
client_exittype = imsg.hdr.type;
|
||||||
|
if (imsg.hdr.type == MSG_DETACHKILL)
|
||||||
|
client_exitmsg = "detached and SIGHUP";
|
||||||
|
else
|
||||||
|
client_exitmsg = "detached";
|
||||||
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
|
break;
|
||||||
|
case MSG_EXIT:
|
||||||
|
if (datalen != 0 &&
|
||||||
|
datalen != sizeof (struct msg_exit_data))
|
||||||
|
fatalx("bad MSG_EXIT size");
|
||||||
|
|
||||||
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
|
client_exitmsg = "exited";
|
||||||
|
break;
|
||||||
|
case MSG_EXITED:
|
||||||
|
if (datalen != 0)
|
||||||
|
fatalx("bad MSG_EXITED size");
|
||||||
|
|
||||||
|
imsg_free(&imsg);
|
||||||
|
return (-1);
|
||||||
|
case MSG_SHUTDOWN:
|
||||||
|
if (datalen != 0)
|
||||||
|
fatalx("bad MSG_SHUTDOWN size");
|
||||||
|
|
||||||
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
|
client_exitmsg = "server exited";
|
||||||
|
client_exitval = 1;
|
||||||
|
break;
|
||||||
|
case MSG_SUSPEND:
|
||||||
|
if (datalen != 0)
|
||||||
|
fatalx("bad MSG_SUSPEND size");
|
||||||
|
|
||||||
|
memset(&sigact, 0, sizeof sigact);
|
||||||
|
sigemptyset(&sigact.sa_mask);
|
||||||
|
sigact.sa_flags = SA_RESTART;
|
||||||
|
sigact.sa_handler = SIG_DFL;
|
||||||
|
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
||||||
|
fatal("sigaction failed");
|
||||||
|
kill(getpid(), SIGTSTP);
|
||||||
|
break;
|
||||||
|
case MSG_LOCK:
|
||||||
|
if (datalen != sizeof lockdata)
|
||||||
|
fatalx("bad MSG_LOCK size");
|
||||||
|
memcpy(&lockdata, imsg.data, sizeof lockdata);
|
||||||
|
|
||||||
|
lockdata.cmd[(sizeof lockdata.cmd) - 1] = '\0';
|
||||||
|
system(lockdata.cmd);
|
||||||
|
client_write_server(MSG_UNLOCK, NULL, 0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fatalx("unexpected message");
|
||||||
|
}
|
||||||
|
|
||||||
|
imsg_free(&imsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
clock.c
28
clock.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: clock.c,v 1.3 2009-03-27 16:59:57 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -97,7 +97,7 @@ const char clock_table[14][5][5] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
clock_draw(struct screen_write_ctx *ctx, u_int colour, int style)
|
clock_draw(struct screen_write_ctx *ctx, int colour, int style)
|
||||||
{
|
{
|
||||||
struct screen *s = ctx->s;
|
struct screen *s = ctx->s;
|
||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
@@ -112,8 +112,6 @@ clock_draw(struct screen_write_ctx *ctx, u_int colour, int style)
|
|||||||
strftime(tim, sizeof tim, "%H:%M", localtime(&t));
|
strftime(tim, sizeof tim, "%H:%M", localtime(&t));
|
||||||
|
|
||||||
screen_write_clearscreen(ctx);
|
screen_write_clearscreen(ctx);
|
||||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
|
||||||
gc.fg = colour;
|
|
||||||
|
|
||||||
if (screen_size_x(s) < 6 * strlen(tim) || screen_size_y(s) < 6) {
|
if (screen_size_x(s) < 6 * strlen(tim) || screen_size_y(s) < 6) {
|
||||||
if (screen_size_x(s) >= strlen(tim) && screen_size_y(s) != 0) {
|
if (screen_size_x(s) >= strlen(tim) && screen_size_y(s) != 0) {
|
||||||
@@ -121,25 +119,28 @@ clock_draw(struct screen_write_ctx *ctx, u_int colour, int style)
|
|||||||
y = screen_size_y(s) / 2;
|
y = screen_size_y(s) / 2;
|
||||||
screen_write_cursormove(ctx, x, y);
|
screen_write_cursormove(ctx, x, y);
|
||||||
|
|
||||||
gc.fg = colour;
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||||
|
colour_set_fg(&gc, colour);
|
||||||
screen_write_puts(ctx, &gc, "%s", tim);
|
screen_write_puts(ctx, &gc, "%s", tim);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
x = (screen_size_x(s) / 2) - 3 * strlen(tim);
|
x = (screen_size_x(s) / 2) - 3 * strlen(tim);
|
||||||
y = (screen_size_y(s) / 2) - 3;
|
y = (screen_size_y(s) / 2) - 3;
|
||||||
|
|
||||||
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||||
|
colour_set_bg(&gc, colour);
|
||||||
for (ptr = tim; *ptr != '\0'; ptr++) {
|
for (ptr = tim; *ptr != '\0'; ptr++) {
|
||||||
if (*ptr >= '0' && *ptr <= '9')
|
if (*ptr >= '0' && *ptr <= '9')
|
||||||
idx = *ptr - '0';
|
idx = *ptr - '0';
|
||||||
else if (*ptr == ':')
|
else if (*ptr == ':')
|
||||||
idx = 10;
|
idx = 10;
|
||||||
else if (*ptr == 'A')
|
else if (*ptr == 'A')
|
||||||
idx = 11;
|
idx = 11;
|
||||||
else if (*ptr == 'P')
|
else if (*ptr == 'P')
|
||||||
idx = 12;
|
idx = 12;
|
||||||
else if (*ptr == 'M')
|
else if (*ptr == 'M')
|
||||||
idx = 13;
|
idx = 13;
|
||||||
else {
|
else {
|
||||||
x += 6;
|
x += 6;
|
||||||
@@ -147,13 +148,10 @@ clock_draw(struct screen_write_ctx *ctx, u_int colour, int style)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < 5; j++) {
|
for (j = 0; j < 5; j++) {
|
||||||
screen_write_cursormove(ctx, x, y + j);
|
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
|
screen_write_cursormove(ctx, x + i, y + j);
|
||||||
if (clock_table[idx][j][i])
|
if (clock_table[idx][j][i])
|
||||||
gc.attr |= GRID_ATTR_REVERSE;
|
screen_write_putc(ctx, &gc, ' ');
|
||||||
else
|
|
||||||
gc.attr &= ~GRID_ATTR_REVERSE;
|
|
||||||
screen_write_putc(ctx, &gc, ' ');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x += 6;
|
x += 6;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-attach-session.c,v 1.24 2009-01-23 16:59:14 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,53 +28,87 @@ int cmd_attach_session_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_attach_session_entry = {
|
const struct cmd_entry cmd_attach_session_entry = {
|
||||||
"attach-session", "attach",
|
"attach-session", "attach",
|
||||||
"[-d] " CMD_TARGET_SESSION_USAGE,
|
"drt:", 0, 0,
|
||||||
CMD_DFLAG|CMD_CANTNEST|CMD_STARTSERVER,
|
"[-dr] " CMD_TARGET_SESSION_USAGE,
|
||||||
cmd_target_init,
|
CMD_CANTNEST|CMD_STARTSERVER|CMD_SENDENVIRON,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_attach_session_exec,
|
NULL,
|
||||||
cmd_target_send,
|
cmd_attach_session_exec
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
char *cause;
|
struct client *c;
|
||||||
|
const char *update;
|
||||||
if (ctx->curclient != NULL)
|
char *overrides, *cause;
|
||||||
return (0);
|
u_int i;
|
||||||
|
|
||||||
if (ARRAY_LENGTH(&sessions) == 0) {
|
if (RB_EMPTY(&sessions)) {
|
||||||
ctx->error(ctx, "no sessions");
|
ctx->error(ctx, "no sessions");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 1)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
|
if (ctx->cmdclient == NULL && ctx->curclient == NULL)
|
||||||
ctx->error(ctx, "not a terminal");
|
return (0);
|
||||||
return (-1);
|
|
||||||
|
if (ctx->cmdclient == NULL) {
|
||||||
|
if (args_has(self->args, 'd')) {
|
||||||
|
/*
|
||||||
|
* Can't use server_write_session in case attaching to
|
||||||
|
* the same session as currently attached to.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c == NULL || c->session != s)
|
||||||
|
continue;
|
||||||
|
if (c == ctx->curclient)
|
||||||
|
continue;
|
||||||
|
server_write_client(c, MSG_DETACH, NULL, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->curclient->session = s;
|
||||||
|
session_update_activity(s);
|
||||||
|
server_redraw_client(ctx->curclient);
|
||||||
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
|
} else {
|
||||||
|
if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
|
||||||
|
ctx->error(ctx, "not a terminal");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
overrides =
|
||||||
|
options_get_string(&s->options, "terminal-overrides");
|
||||||
|
if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
|
||||||
|
ctx->error(ctx, "terminal open failed: %s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(self->args, 'r'))
|
||||||
|
ctx->cmdclient->flags |= CLIENT_READONLY;
|
||||||
|
|
||||||
|
if (args_has(self->args, 'd'))
|
||||||
|
server_write_session(s, MSG_DETACH, NULL, 0);
|
||||||
|
|
||||||
|
ctx->cmdclient->session = s;
|
||||||
|
session_update_activity(s);
|
||||||
|
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
||||||
|
|
||||||
|
update = options_get_string(&s->options, "update-environment");
|
||||||
|
environ_update(update, &ctx->cmdclient->environ, &s->environ);
|
||||||
|
|
||||||
|
server_redraw_client(ctx->cmdclient);
|
||||||
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tty_open(&ctx->cmdclient->tty, &cause) != 0) {
|
|
||||||
ctx->error(ctx, "terminal open failed: %s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->flags & CMD_DFLAG)
|
|
||||||
server_write_session(s, MSG_DETACH, NULL, 0);
|
|
||||||
ctx->cmdclient->session = s;
|
|
||||||
|
|
||||||
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_redraw_client(ctx->cmdclient);
|
server_update_socket();
|
||||||
|
|
||||||
return (1);
|
return (1); /* 1 means don't tell command client to exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
173
cmd-bind-key.c
173
cmd-bind-key.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-bind-key.c,v 1.20 2009-03-28 14:08:09 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,140 +18,103 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bind a key to a command, this recurses through cmd_*.
|
* Bind a key to a command, this recurses through cmd_*.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_bind_key_parse(struct cmd *, int, char **, char **);
|
int cmd_bind_key_check(struct args *);
|
||||||
int cmd_bind_key_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_bind_key_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_bind_key_send(struct cmd *, struct buffer *);
|
|
||||||
void cmd_bind_key_recv(struct cmd *, struct buffer *);
|
|
||||||
void cmd_bind_key_free(struct cmd *);
|
|
||||||
size_t cmd_bind_key_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_bind_key_data {
|
int cmd_bind_key_table(struct cmd *, struct cmd_ctx *, int);
|
||||||
int key;
|
|
||||||
int can_repeat;
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_bind_key_entry = {
|
const struct cmd_entry cmd_bind_key_entry = {
|
||||||
"bind-key", "bind",
|
"bind-key", "bind",
|
||||||
"[-r] key command [arguments]",
|
"cnrt:", 1, -1,
|
||||||
|
"[-cnr] [-t key-table] key command [arguments]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_bind_key_parse,
|
cmd_bind_key_check,
|
||||||
cmd_bind_key_exec,
|
cmd_bind_key_exec
|
||||||
cmd_bind_key_send,
|
|
||||||
cmd_bind_key_recv,
|
|
||||||
cmd_bind_key_free,
|
|
||||||
cmd_bind_key_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_bind_key_parse(struct cmd *self, int argc, char **argv, char **cause)
|
cmd_bind_key_check(struct args *args)
|
||||||
{
|
{
|
||||||
struct cmd_bind_key_data *data;
|
if (args_has(args, 't')) {
|
||||||
int opt;
|
if (args->argc != 2)
|
||||||
|
return (-1);
|
||||||
self->data = data = xmalloc(sizeof *data);
|
} else {
|
||||||
data->can_repeat = 0;
|
if (args->argc < 2)
|
||||||
data->cmdlist = NULL;
|
return (-1);
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "r")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'r':
|
|
||||||
data->can_repeat = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc < 1)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
if ((data->key = key_string_lookup_string(argv[0])) == KEYC_NONE) {
|
|
||||||
xasprintf(cause, "unknown key: %s", argv[0]);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
if ((data->cmdlist = cmd_list_parse(argc, argv, cause)) == NULL)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
error:
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_bind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_bind_key_data *data = self->data;
|
struct args *args = self->args;
|
||||||
|
char *cause;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
int key;
|
||||||
|
|
||||||
if (data == NULL)
|
key = key_string_lookup_string(args->argv[0]);
|
||||||
return (0);
|
if (key == KEYC_NONE) {
|
||||||
|
ctx->error(ctx, "unknown key: %s", args->argv[0]);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
key_bindings_add(data->key, data->can_repeat, data->cmdlist);
|
if (args_has(args, 't'))
|
||||||
data->cmdlist = NULL; /* avoid free */
|
return (cmd_bind_key_table(self, ctx, key));
|
||||||
|
|
||||||
|
cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, &cause);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
|
ctx->error(ctx, "%s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!args_has(args, 'n'))
|
||||||
|
key |= KEYC_PREFIX;
|
||||||
|
key_bindings_add(key, args_has(args, 'r'), cmdlist);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
cmd_bind_key_send(struct cmd *self, struct buffer *b)
|
cmd_bind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
||||||
{
|
{
|
||||||
struct cmd_bind_key_data *data = self->data;
|
struct args *args = self->args;
|
||||||
|
const char *tablename;
|
||||||
|
const struct mode_key_table *mtab;
|
||||||
|
struct mode_key_binding *mbind, mtmp;
|
||||||
|
enum mode_key_cmd cmd;
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
tablename = args_get(args, 't');
|
||||||
cmd_list_send(data->cmdlist, b);
|
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
||||||
}
|
ctx->error(ctx, "unknown key table: %s", tablename);
|
||||||
|
return (-1);
|
||||||
void
|
|
||||||
cmd_bind_key_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_bind_key_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->cmdlist = cmd_list_recv(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_bind_key_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_bind_key_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->cmdlist != NULL)
|
|
||||||
cmd_list_free(data->cmdlist);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_bind_key_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_bind_key_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
const char *skey;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len) {
|
|
||||||
skey = key_string_lookup_key(data->key);
|
|
||||||
off += xsnprintf(buf + off, len - off, " %s ", skey);
|
|
||||||
}
|
}
|
||||||
if (off < len)
|
|
||||||
off += cmd_list_print(data->cmdlist, buf + off, len - off);
|
cmd = mode_key_fromstring(mtab->cmdstr, args->argv[1]);
|
||||||
return (off);
|
if (cmd == MODEKEY_NONE) {
|
||||||
|
ctx->error(ctx, "unknown command: %s", args->argv[1]);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
mtmp.key = key;
|
||||||
|
mtmp.mode = !!args_has(args, 'c');
|
||||||
|
if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {
|
||||||
|
mbind->cmd = cmd;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
mbind = xmalloc(sizeof *mbind);
|
||||||
|
mbind->key = mtmp.key;
|
||||||
|
mbind->mode = mtmp.mode;
|
||||||
|
mbind->cmd = cmd;
|
||||||
|
RB_INSERT(mode_key_tree, mtab->tree, mbind);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-break-pane.c,v 1.1 2009-03-07 09:29:54 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,63 +30,60 @@ int cmd_break_pane_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_break_pane_entry = {
|
const struct cmd_entry cmd_break_pane_entry = {
|
||||||
"break-pane", "breakp",
|
"break-pane", "breakp",
|
||||||
CMD_PANE_WINDOW_USAGE " [-d]",
|
"dt:", 0, 0,
|
||||||
CMD_DFLAG,
|
"[-d] " CMD_TARGET_PANE_USAGE,
|
||||||
cmd_pane_init,
|
0,
|
||||||
cmd_pane_parse,
|
NULL,
|
||||||
cmd_break_pane_exec,
|
NULL,
|
||||||
cmd_pane_send,
|
cmd_break_pane_exec
|
||||||
cmd_pane_recv,
|
|
||||||
cmd_pane_free,
|
|
||||||
cmd_pane_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_pane_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
char *cause;
|
char *cause;
|
||||||
|
int base_idx;
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
|
||||||
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
if (data->pane == -1)
|
|
||||||
wp = wl->window->active;
|
|
||||||
else {
|
|
||||||
wp = window_pane_at_index(wl->window, data->pane);
|
|
||||||
if (wp == NULL) {
|
|
||||||
ctx->error(ctx, "no pane: %d", data->pane);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window_count_panes(wl->window) == 1) {
|
if (window_count_panes(wl->window) == 1) {
|
||||||
ctx->error(ctx, "can't break pane: %d", data->pane);
|
ctx->error(ctx, "can't break with only one pane");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_REMOVE(&wl->window->panes, wp, entry);
|
w = wl->window;
|
||||||
if (wl->window->active == wp) {
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
wl->window->active = TAILQ_PREV(wp, window_panes, entry);
|
if (wp == w->active) {
|
||||||
if (wl->window->active == NULL)
|
w->active = w->last;
|
||||||
wl->window->active = TAILQ_NEXT(wp, entry);
|
w->last = NULL;
|
||||||
}
|
if (w->active == NULL) {
|
||||||
window_fit_panes(wl->window);
|
w->active = TAILQ_PREV(wp, window_panes, entry);
|
||||||
|
if (w->active == NULL)
|
||||||
|
w->active = TAILQ_NEXT(wp, entry);
|
||||||
|
}
|
||||||
|
} else if (wp == w->last)
|
||||||
|
w->last = NULL;
|
||||||
|
layout_close_pane(wp);
|
||||||
|
|
||||||
w = wp->window = window_create1(s->sx, s->sy);
|
w = wp->window = window_create1(s->sx, s->sy);
|
||||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||||
w->active = wp;
|
w->active = wp;
|
||||||
window_fit_panes(w);
|
w->name = default_window_name(w);
|
||||||
w->name = default_window_name(w);
|
layout_init(w);
|
||||||
|
|
||||||
wl = session_attach(s, w, -1, &cause); /* can't fail */
|
base_idx = options_get_number(&s->options, "base-index");
|
||||||
|
wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */
|
||||||
|
if (!args_has(self->args, 'd'))
|
||||||
|
session_select(s, wl->idx);
|
||||||
|
|
||||||
if (!(data->flags & CMD_DFLAG))
|
|
||||||
session_select(s, wl->idx);
|
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
|
server_status_session_group(s);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
124
cmd-capture-pane.c
Normal file
124
cmd-capture-pane.c
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Write the entire contents of a pane to a buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_capture_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_capture_pane_entry = {
|
||||||
|
"capture-pane", "capturep",
|
||||||
|
"b:E:S:t:", 0, 0,
|
||||||
|
"[-b buffer-index] [-E end-line] [-S start-line] [-t target-pane]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_capture_pane_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct window_pane *wp;
|
||||||
|
char *buf, *line, *cause;
|
||||||
|
struct screen *s;
|
||||||
|
struct grid *gd;
|
||||||
|
int buffer, n;
|
||||||
|
u_int i, limit, top, bottom, tmp;
|
||||||
|
size_t len, linelen;
|
||||||
|
|
||||||
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
|
return (-1);
|
||||||
|
s = &wp->base;
|
||||||
|
gd = s->grid;
|
||||||
|
|
||||||
|
buf = NULL;
|
||||||
|
len = 0;
|
||||||
|
|
||||||
|
n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
top = gd->hsize;
|
||||||
|
xfree(cause);
|
||||||
|
} else if (n < 0 && (u_int) -n > gd->hsize)
|
||||||
|
top = 0;
|
||||||
|
else
|
||||||
|
top = gd->hsize + n;
|
||||||
|
if (top > gd->hsize + gd->sy - 1)
|
||||||
|
top = gd->hsize + gd->sy - 1;
|
||||||
|
|
||||||
|
n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
bottom = gd->hsize + gd->sy - 1;
|
||||||
|
xfree(cause);
|
||||||
|
} else if (n < 0 && (u_int) -n > gd->hsize)
|
||||||
|
bottom = 0;
|
||||||
|
else
|
||||||
|
bottom = gd->hsize + n;
|
||||||
|
if (bottom > gd->hsize + gd->sy - 1)
|
||||||
|
bottom = gd->hsize + gd->sy - 1;
|
||||||
|
|
||||||
|
if (bottom < top) {
|
||||||
|
tmp = bottom;
|
||||||
|
bottom = top;
|
||||||
|
top = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = top; i <= bottom; i++) {
|
||||||
|
line = grid_string_cells(s->grid, 0, i, screen_size_x(s));
|
||||||
|
linelen = strlen(line);
|
||||||
|
|
||||||
|
buf = xrealloc(buf, 1, len + linelen + 1);
|
||||||
|
memcpy(buf + len, line, linelen);
|
||||||
|
len += linelen;
|
||||||
|
buf[len++] = '\n';
|
||||||
|
|
||||||
|
xfree(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
|
|
||||||
|
if (!args_has(args, 'b')) {
|
||||||
|
paste_add(&global_buffers, buf, len, limit);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
|
xfree(buf);
|
||||||
|
xfree(cause);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paste_replace(&global_buffers, buffer, buf, len) != 0) {
|
||||||
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
|
xfree(buf);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
143
cmd-choose-buffer.c
Normal file
143
cmd-choose-buffer.c
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enter choice mode to choose a buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_choose_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
void cmd_choose_buffer_callback(void *, int);
|
||||||
|
void cmd_choose_buffer_free(void *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_choose_buffer_entry = {
|
||||||
|
"choose-buffer", NULL,
|
||||||
|
"t:", 0, 1,
|
||||||
|
CMD_TARGET_WINDOW_USAGE " [template]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_choose_buffer_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_choose_buffer_data {
|
||||||
|
struct client *client;
|
||||||
|
char *template;
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct cmd_choose_buffer_data *cdata;
|
||||||
|
struct winlink *wl;
|
||||||
|
struct paste_buffer *pb;
|
||||||
|
u_int idx;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
|
if (ctx->curclient == NULL) {
|
||||||
|
ctx->error(ctx, "must be run interactively");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (paste_get_top(&global_buffers) == NULL)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
idx = 0;
|
||||||
|
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
|
||||||
|
tmp = paste_print(pb, 50);
|
||||||
|
window_choose_add(wl->window->active, idx - 1,
|
||||||
|
"%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp);
|
||||||
|
xfree(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
cdata = xmalloc(sizeof *cdata);
|
||||||
|
if (args->argc != 0)
|
||||||
|
cdata->template = xstrdup(args->argv[0]);
|
||||||
|
else
|
||||||
|
cdata->template = xstrdup("paste-buffer -b '%%'");
|
||||||
|
cdata->client = ctx->curclient;
|
||||||
|
cdata->client->references++;
|
||||||
|
|
||||||
|
window_choose_ready(wl->window->active,
|
||||||
|
0, cmd_choose_buffer_callback, cmd_choose_buffer_free, cdata);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_choose_buffer_callback(void *data, int idx)
|
||||||
|
{
|
||||||
|
struct cmd_choose_buffer_data *cdata = data;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
struct cmd_ctx ctx;
|
||||||
|
char *template, *cause, tmp[16];
|
||||||
|
|
||||||
|
if (idx == -1)
|
||||||
|
return;
|
||||||
|
if (cdata->client->flags & CLIENT_DEAD)
|
||||||
|
return;
|
||||||
|
|
||||||
|
xsnprintf(tmp, sizeof tmp, "%u", idx);
|
||||||
|
template = cmd_template_replace(cdata->template, tmp, 1);
|
||||||
|
|
||||||
|
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
||||||
|
if (cause != NULL) {
|
||||||
|
*cause = toupper((u_char) *cause);
|
||||||
|
status_message_set(cdata->client, "%s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
}
|
||||||
|
xfree(template);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
xfree(template);
|
||||||
|
|
||||||
|
ctx.msgdata = NULL;
|
||||||
|
ctx.curclient = cdata->client;
|
||||||
|
|
||||||
|
ctx.error = key_bindings_error;
|
||||||
|
ctx.print = key_bindings_print;
|
||||||
|
ctx.info = key_bindings_info;
|
||||||
|
|
||||||
|
ctx.cmdclient = NULL;
|
||||||
|
|
||||||
|
cmd_list_exec(cmdlist, &ctx);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_choose_buffer_free(void *data)
|
||||||
|
{
|
||||||
|
struct cmd_choose_buffer_data *cdata = data;
|
||||||
|
|
||||||
|
cdata->client->references--;
|
||||||
|
xfree(cdata->template);
|
||||||
|
xfree(cdata);
|
||||||
|
}
|
||||||
153
cmd-choose-client.c
Normal file
153
cmd-choose-client.c
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enter choice mode to choose a client.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_choose_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
void cmd_choose_client_callback(void *, int);
|
||||||
|
void cmd_choose_client_free(void *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_choose_client_entry = {
|
||||||
|
"choose-client", NULL,
|
||||||
|
"t:", 0, 1,
|
||||||
|
CMD_TARGET_WINDOW_USAGE " [template]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_choose_client_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_choose_client_data {
|
||||||
|
struct client *client;
|
||||||
|
char *template;
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct cmd_choose_client_data *cdata;
|
||||||
|
struct winlink *wl;
|
||||||
|
struct client *c;
|
||||||
|
u_int i, idx, cur;
|
||||||
|
|
||||||
|
if (ctx->curclient == NULL) {
|
||||||
|
ctx->error(ctx, "must be run interactively");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
cur = idx = 0;
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c == NULL || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
if (c == ctx->curclient)
|
||||||
|
cur = idx;
|
||||||
|
idx++;
|
||||||
|
|
||||||
|
window_choose_add(wl->window->active, i,
|
||||||
|
"%s: %s [%ux%u %s]%s%s", c->tty.path,
|
||||||
|
c->session->name, c->tty.sx, c->tty.sy,
|
||||||
|
c->tty.termname,
|
||||||
|
c->tty.flags & TTY_UTF8 ? " (utf8)" : "",
|
||||||
|
c->flags & CLIENT_READONLY ? " (ro)" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
cdata = xmalloc(sizeof *cdata);
|
||||||
|
if (args->argc != 0)
|
||||||
|
cdata->template = xstrdup(args->argv[0]);
|
||||||
|
else
|
||||||
|
cdata->template = xstrdup("detach-client -t '%%'");
|
||||||
|
cdata->client = ctx->curclient;
|
||||||
|
cdata->client->references++;
|
||||||
|
|
||||||
|
window_choose_ready(wl->window->active,
|
||||||
|
cur, cmd_choose_client_callback, cmd_choose_client_free, cdata);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_choose_client_callback(void *data, int idx)
|
||||||
|
{
|
||||||
|
struct cmd_choose_client_data *cdata = data;
|
||||||
|
struct client *c;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
struct cmd_ctx ctx;
|
||||||
|
char *template, *cause;
|
||||||
|
|
||||||
|
if (idx == -1)
|
||||||
|
return;
|
||||||
|
if (cdata->client->flags & CLIENT_DEAD)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ((u_int) idx > ARRAY_LENGTH(&clients) - 1)
|
||||||
|
return;
|
||||||
|
c = ARRAY_ITEM(&clients, idx);
|
||||||
|
if (c == NULL || c->session == NULL)
|
||||||
|
return;
|
||||||
|
template = cmd_template_replace(cdata->template, c->tty.path, 1);
|
||||||
|
|
||||||
|
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
||||||
|
if (cause != NULL) {
|
||||||
|
*cause = toupper((u_char) *cause);
|
||||||
|
status_message_set(c, "%s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
}
|
||||||
|
xfree(template);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
xfree(template);
|
||||||
|
|
||||||
|
ctx.msgdata = NULL;
|
||||||
|
ctx.curclient = cdata->client;
|
||||||
|
|
||||||
|
ctx.error = key_bindings_error;
|
||||||
|
ctx.print = key_bindings_print;
|
||||||
|
ctx.info = key_bindings_info;
|
||||||
|
|
||||||
|
ctx.cmdclient = NULL;
|
||||||
|
|
||||||
|
cmd_list_exec(cmdlist, &ctx);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_choose_client_free(void *data)
|
||||||
|
{
|
||||||
|
struct cmd_choose_client_data *cdata = data;
|
||||||
|
|
||||||
|
cdata->client->references--;
|
||||||
|
xfree(cdata->template);
|
||||||
|
xfree(cdata);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-choose-session.c,v 1.6 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -27,64 +29,75 @@
|
|||||||
int cmd_choose_session_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_choose_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_choose_session_callback(void *, int);
|
void cmd_choose_session_callback(void *, int);
|
||||||
|
void cmd_choose_session_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_session_entry = {
|
const struct cmd_entry cmd_choose_session_entry = {
|
||||||
"choose-session", NULL,
|
"choose-session", NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"t:", 0, 1,
|
||||||
|
CMD_TARGET_WINDOW_USAGE " [template]",
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_choose_session_exec,
|
cmd_choose_session_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_choose_session_data {
|
struct cmd_choose_session_data {
|
||||||
u_int client;
|
struct client *client;
|
||||||
|
char *template;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct cmd_choose_session_data *cdata;
|
struct cmd_choose_session_data *cdata;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
u_int i, idx, cur;
|
struct session_group *sg;
|
||||||
|
u_int idx, sgidx, cur;
|
||||||
|
char tmp[64];
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
cur = idx = 0;
|
cur = idx = 0;
|
||||||
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
s = ARRAY_ITEM(&sessions, i);
|
|
||||||
if (s == NULL)
|
|
||||||
continue;
|
|
||||||
if (s == ctx->curclient->session)
|
if (s == ctx->curclient->session)
|
||||||
cur = idx;
|
cur = idx;
|
||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
window_choose_add(wl->window->active, i,
|
sg = session_group_find(s);
|
||||||
"%s: %u windows [%ux%u]%s", s->name,
|
if (sg == NULL)
|
||||||
|
*tmp = '\0';
|
||||||
|
else {
|
||||||
|
sgidx = session_group_index(sg);
|
||||||
|
xsnprintf(tmp, sizeof tmp, " (group %u)", sgidx);
|
||||||
|
}
|
||||||
|
|
||||||
|
window_choose_add(wl->window->active, s->idx,
|
||||||
|
"%s: %u windows [%ux%u]%s%s", s->name,
|
||||||
winlink_count(&s->windows), s->sx, s->sy,
|
winlink_count(&s->windows), s->sx, s->sy,
|
||||||
s->flags & SESSION_UNATTACHED ? "" : " (attached)");
|
tmp, s->flags & SESSION_UNATTACHED ? "" : " (attached)");
|
||||||
}
|
}
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
cdata->client = server_client_index(ctx->curclient);
|
if (args->argc != 0)
|
||||||
|
cdata->template = xstrdup(args->argv[0]);
|
||||||
|
else
|
||||||
|
cdata->template = xstrdup("switch-client -t '%%'");
|
||||||
|
cdata->client = ctx->curclient;
|
||||||
|
cdata->client->references++;
|
||||||
|
|
||||||
window_choose_ready(
|
window_choose_ready(wl->window->active,
|
||||||
wl->window->active, cur, cmd_choose_session_callback, cdata);
|
cur, cmd_choose_session_callback, cmd_choose_session_free, cdata);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -93,15 +106,51 @@ void
|
|||||||
cmd_choose_session_callback(void *data, int idx)
|
cmd_choose_session_callback(void *data, int idx)
|
||||||
{
|
{
|
||||||
struct cmd_choose_session_data *cdata = data;
|
struct cmd_choose_session_data *cdata = data;
|
||||||
struct client *c;
|
struct session *s;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
struct cmd_ctx ctx;
|
||||||
|
char *template, *cause;
|
||||||
|
|
||||||
if (idx != -1 && cdata->client <= ARRAY_LENGTH(&clients) - 1) {
|
if (idx == -1)
|
||||||
c = ARRAY_ITEM(&clients, cdata->client);
|
return;
|
||||||
if (c != NULL && (u_int) idx <= ARRAY_LENGTH(&sessions) - 1) {
|
if (cdata->client->flags & CLIENT_DEAD)
|
||||||
c->session = ARRAY_ITEM(&sessions, idx);
|
return;
|
||||||
recalculate_sizes();
|
|
||||||
server_redraw_client(c);
|
s = session_find_by_index(idx);
|
||||||
|
if (s == NULL)
|
||||||
|
return;
|
||||||
|
template = cmd_template_replace(cdata->template, s->name, 1);
|
||||||
|
|
||||||
|
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
||||||
|
if (cause != NULL) {
|
||||||
|
*cause = toupper((u_char) *cause);
|
||||||
|
status_message_set(cdata->client, "%s", cause);
|
||||||
|
xfree(cause);
|
||||||
}
|
}
|
||||||
|
xfree(template);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
xfree(template);
|
||||||
|
|
||||||
|
ctx.msgdata = NULL;
|
||||||
|
ctx.curclient = cdata->client;
|
||||||
|
|
||||||
|
ctx.error = key_bindings_error;
|
||||||
|
ctx.print = key_bindings_print;
|
||||||
|
ctx.info = key_bindings_info;
|
||||||
|
|
||||||
|
ctx.cmdclient = NULL;
|
||||||
|
|
||||||
|
cmd_list_exec(cmdlist, &ctx);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_choose_session_free(void *data)
|
||||||
|
{
|
||||||
|
struct cmd_choose_session_data *cdata = data;
|
||||||
|
|
||||||
|
cdata->client->references--;
|
||||||
|
xfree(cdata->template);
|
||||||
xfree(cdata);
|
xfree(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-choose-window.c,v 1.7 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -27,33 +29,35 @@
|
|||||||
int cmd_choose_window_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_choose_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_choose_window_callback(void *, int);
|
void cmd_choose_window_callback(void *, int);
|
||||||
|
void cmd_choose_window_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_window_entry = {
|
const struct cmd_entry cmd_choose_window_entry = {
|
||||||
"choose-window", NULL,
|
"choose-window", NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"t:", 0, 1,
|
||||||
|
CMD_TARGET_WINDOW_USAGE " [template]",
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_choose_window_exec,
|
cmd_choose_window_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_choose_window_data {
|
struct cmd_choose_window_data {
|
||||||
u_int session;
|
struct client *client;
|
||||||
|
struct session *session;
|
||||||
|
char *template;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct cmd_choose_window_data *cdata;
|
struct cmd_choose_window_data *cdata;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl, *wm;
|
struct winlink *wl, *wm;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
u_int idx, cur;
|
u_int idx, cur;
|
||||||
|
char *flags, *title;
|
||||||
|
const char *left, *right;
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
@@ -61,9 +65,9 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
s = ctx->curclient->session;
|
s = ctx->curclient->session;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
@@ -75,32 +79,91 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cur = idx;
|
cur = idx;
|
||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
|
flags = window_printable_flags(s, wm);
|
||||||
|
title = w->active->screen->title;
|
||||||
|
if (wm == wl)
|
||||||
|
title = w->active->base.title;
|
||||||
|
left = " \"";
|
||||||
|
right = "\"";
|
||||||
|
if (*title == '\0')
|
||||||
|
left = right = "";
|
||||||
|
|
||||||
window_choose_add(wl->window->active,
|
window_choose_add(wl->window->active,
|
||||||
wm->idx, "%3d: %s [%ux%u] (%u panes)", wm->idx, w->name,
|
wm->idx, "%3d: %s%s [%ux%u] (%u panes%s)%s%s%s",
|
||||||
w->sx, w->sy, window_count_panes(w));
|
wm->idx, w->name, flags, w->sx, w->sy, window_count_panes(w),
|
||||||
|
w->active->fd == -1 ? ", dead" : "",
|
||||||
|
left, title, right);
|
||||||
|
|
||||||
|
xfree(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
if (session_index(s, &cdata->session) != 0)
|
if (args->argc != 0)
|
||||||
fatalx("session not found");
|
cdata->template = xstrdup(args->argv[0]);
|
||||||
|
else
|
||||||
|
cdata->template = xstrdup("select-window -t '%%'");
|
||||||
|
cdata->session = s;
|
||||||
|
cdata->session->references++;
|
||||||
|
cdata->client = ctx->curclient;
|
||||||
|
cdata->client->references++;
|
||||||
|
|
||||||
window_choose_ready(
|
window_choose_ready(wl->window->active,
|
||||||
wl->window->active, cur, cmd_choose_window_callback, cdata);
|
cur, cmd_choose_window_callback, cmd_choose_window_free, cdata);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_choose_window_callback(void *data, int idx)
|
cmd_choose_window_callback(void *data, int idx)
|
||||||
{
|
{
|
||||||
struct cmd_choose_window_data *cdata = data;
|
struct cmd_choose_window_data *cdata = data;
|
||||||
struct session *s;
|
struct session *s = cdata->session;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
struct cmd_ctx ctx;
|
||||||
|
char *target, *template, *cause;
|
||||||
|
|
||||||
if (idx != -1 && cdata->session <= ARRAY_LENGTH(&sessions) - 1) {
|
if (idx == -1)
|
||||||
s = ARRAY_ITEM(&sessions, cdata->session);
|
return;
|
||||||
if (s != NULL && session_select(s, idx) == 0)
|
if (!session_alive(s))
|
||||||
server_redraw_session(s);
|
return;
|
||||||
recalculate_sizes();
|
if (cdata->client->flags & CLIENT_DEAD)
|
||||||
|
return;
|
||||||
|
|
||||||
|
xasprintf(&target, "%s:%d", s->name, idx);
|
||||||
|
template = cmd_template_replace(cdata->template, target, 1);
|
||||||
|
xfree(target);
|
||||||
|
|
||||||
|
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
||||||
|
if (cause != NULL) {
|
||||||
|
*cause = toupper((u_char) *cause);
|
||||||
|
status_message_set(cdata->client, "%s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
}
|
||||||
|
xfree(template);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
xfree(template);
|
||||||
|
|
||||||
|
ctx.msgdata = NULL;
|
||||||
|
ctx.curclient = cdata->client;
|
||||||
|
|
||||||
|
ctx.error = key_bindings_error;
|
||||||
|
ctx.print = key_bindings_print;
|
||||||
|
ctx.info = key_bindings_info;
|
||||||
|
|
||||||
|
ctx.cmdclient = NULL;
|
||||||
|
|
||||||
|
cmd_list_exec(cmdlist, &ctx);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_choose_window_free(void *data)
|
||||||
|
{
|
||||||
|
struct cmd_choose_window_data *cdata = data;
|
||||||
|
|
||||||
|
cdata->session->references--;
|
||||||
|
cdata->client->references--;
|
||||||
|
xfree(cdata->template);
|
||||||
xfree(cdata);
|
xfree(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-next-layout.c,v 1.1 2009-04-01 18:21:26 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -21,34 +21,34 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Switch window to next layout.
|
* Clear pane history.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_next_layout_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_clear_history_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_next_layout_entry = {
|
const struct cmd_entry cmd_clear_history_entry = {
|
||||||
"next-layout", "nextl",
|
"clear-history", "clearhist",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_PANE_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_next_layout_exec,
|
cmd_clear_history_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_next_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_clear_history_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct window_pane *wp;
|
||||||
|
struct grid *gd;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
gd = wp->base.grid;
|
||||||
|
|
||||||
layout_next(wl->window);
|
grid_move_lines(gd, 0, gd->hsize, gd->sy);
|
||||||
|
gd->hsize = 0;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-clock-mode.c,v 1.3 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,27 +28,24 @@ int cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_clock_mode_entry = {
|
const struct cmd_entry cmd_clock_mode_entry = {
|
||||||
"clock-mode", NULL,
|
"clock-mode", NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_PANE_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_clock_mode_exec,
|
cmd_clock_mode_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_clock_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_clock_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
window_pane_set_mode(wl->window->active, &window_clock_mode);
|
window_pane_set_mode(wp, &window_clock_mode);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-command-prompt.c,v 1.16 2009-02-16 18:58:14 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -27,46 +28,57 @@
|
|||||||
* Prompt for command in client.
|
* Prompt for command in client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_command_prompt_init(struct cmd *, int);
|
void cmd_command_prompt_key_binding(struct cmd *, int);
|
||||||
|
int cmd_command_prompt_check(struct args *);
|
||||||
int cmd_command_prompt_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_command_prompt_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
int cmd_command_prompt_callback(void *, const char *);
|
int cmd_command_prompt_callback(void *, const char *);
|
||||||
|
void cmd_command_prompt_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_command_prompt_entry = {
|
const struct cmd_entry cmd_command_prompt_entry = {
|
||||||
"command-prompt", NULL,
|
"command-prompt", NULL,
|
||||||
CMD_TARGET_CLIENT_USAGE " [template]",
|
"I:p:t:", 0, 1,
|
||||||
CMD_ARG01,
|
"[-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " [template]",
|
||||||
cmd_command_prompt_init,
|
0,
|
||||||
cmd_target_parse,
|
cmd_command_prompt_key_binding,
|
||||||
cmd_command_prompt_exec,
|
NULL,
|
||||||
cmd_target_send,
|
cmd_command_prompt_exec
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_command_prompt_data {
|
struct cmd_command_prompt_cdata {
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
char *inputs;
|
||||||
|
char *next_input;
|
||||||
|
char *next_prompt;
|
||||||
|
char *prompts;
|
||||||
char *template;
|
char *template;
|
||||||
|
int idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_command_prompt_init(struct cmd *self, int key)
|
cmd_command_prompt_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data;
|
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
case '$':
|
||||||
|
self->args = args_create(1, "rename-session '%%'");
|
||||||
|
args_set(self->args, 'I', "#S");
|
||||||
|
break;
|
||||||
case ',':
|
case ',':
|
||||||
data->arg = xstrdup("rename-window '%%'");
|
self->args = args_create(1, "rename-window '%%'");
|
||||||
|
args_set(self->args, 'I', "#W");
|
||||||
break;
|
break;
|
||||||
case '.':
|
case '.':
|
||||||
data->arg = xstrdup("move-window -t '%%'");
|
self->args = args_create(1, "move-window -t '%%'");
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
data->arg = xstrdup("find-window '%%'");
|
self->args = args_create(1, "find-window '%%'");
|
||||||
|
break;
|
||||||
|
case '\'':
|
||||||
|
self->args = args_create(1, "select-window -t ':%%'");
|
||||||
|
args_set(self->args, 'p', "index");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
self->args = args_create(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,12 +86,14 @@ cmd_command_prompt_init(struct cmd *self, int key)
|
|||||||
int
|
int
|
||||||
cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct cmd_command_prompt_data *cdata;
|
const char *inputs, *prompts;
|
||||||
|
struct cmd_command_prompt_cdata *cdata;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
char *hdr, *ptr;
|
char *prompt, *ptr, *input = NULL;
|
||||||
|
size_t n;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (c->prompt_string != NULL)
|
if (c->prompt_string != NULL)
|
||||||
@@ -87,17 +101,44 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
cdata->c = c;
|
cdata->c = c;
|
||||||
if (data->arg != NULL) {
|
cdata->idx = 1;
|
||||||
cdata->template = xstrdup(data->arg);
|
cdata->inputs = NULL;
|
||||||
if ((ptr = strchr(data->arg, ' ')) == NULL)
|
cdata->next_input = NULL;
|
||||||
ptr = strchr(data->arg, '\0');
|
cdata->next_prompt = NULL;
|
||||||
xasprintf(&hdr, "(%.*s) ", (int) (ptr - data->arg), data->arg);
|
cdata->prompts = NULL;
|
||||||
} else {
|
cdata->template = NULL;
|
||||||
cdata->template = NULL;
|
|
||||||
hdr = xstrdup(":");
|
if (args->argc != 0)
|
||||||
|
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
|
||||||
|
cdata->prompts = xstrdup(":");
|
||||||
|
|
||||||
|
/* Get first prompt. */
|
||||||
|
cdata->next_prompt = cdata->prompts;
|
||||||
|
ptr = strsep(&cdata->next_prompt, ",");
|
||||||
|
if (prompts == NULL)
|
||||||
|
prompt = xstrdup(ptr);
|
||||||
|
else
|
||||||
|
xasprintf(&prompt, "%s ", ptr);
|
||||||
|
|
||||||
|
/* Get initial prompt input. */
|
||||||
|
if ((inputs = args_get(args, 'I')) != NULL) {
|
||||||
|
cdata->inputs = xstrdup(inputs);
|
||||||
|
cdata->next_input = cdata->inputs;
|
||||||
|
input = strsep(&cdata->next_input, ",");
|
||||||
}
|
}
|
||||||
status_prompt_set(c, hdr, cmd_command_prompt_callback, cdata, 0);
|
|
||||||
xfree(hdr);
|
status_prompt_set(c, prompt, input, cmd_command_prompt_callback,
|
||||||
|
cmd_command_prompt_free, cdata, 0);
|
||||||
|
xfree(prompt);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -105,62 +146,44 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
int
|
int
|
||||||
cmd_command_prompt_callback(void *data, const char *s)
|
cmd_command_prompt_callback(void *data, const char *s)
|
||||||
{
|
{
|
||||||
struct cmd_command_prompt_data *cdata = data;
|
struct cmd_command_prompt_cdata *cdata = data;
|
||||||
struct client *c = cdata->c;
|
struct client *c = cdata->c;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd_ctx ctx;
|
struct cmd_ctx ctx;
|
||||||
char *cause, *ptr, *buf, ch;
|
char *cause, *new_template, *prompt, *ptr;
|
||||||
size_t len, slen;
|
char *input = NULL;
|
||||||
|
|
||||||
if (s == NULL) {
|
if (s == NULL)
|
||||||
xfree(cdata);
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
new_template = cmd_template_replace(cdata->template, s, cdata->idx);
|
||||||
|
xfree(cdata->template);
|
||||||
|
cdata->template = new_template;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if there are more prompts; if so, get its respective input
|
||||||
|
* and update the prompt data.
|
||||||
|
*/
|
||||||
|
if ((ptr = strsep(&cdata->next_prompt, ",")) != NULL) {
|
||||||
|
xasprintf(&prompt, "%s ", ptr);
|
||||||
|
input = strsep(&cdata->next_input, ",");
|
||||||
|
status_prompt_update(c, prompt, input);
|
||||||
|
|
||||||
|
xfree(prompt);
|
||||||
|
cdata->idx++;
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
slen = strlen(s);
|
|
||||||
|
|
||||||
len = 0;
|
if (cmd_string_parse(new_template, &cmdlist, &cause) != 0) {
|
||||||
buf = NULL;
|
if (cause != NULL) {
|
||||||
if (cdata->template != NULL) {
|
*cause = toupper((u_char) *cause);
|
||||||
ptr = cdata->template;
|
status_message_set(c, "%s", cause);
|
||||||
while (*ptr != '\0') {
|
xfree(cause);
|
||||||
switch (ch = *ptr++) {
|
|
||||||
case '%':
|
|
||||||
if (*ptr != '%')
|
|
||||||
break;
|
|
||||||
ptr++;
|
|
||||||
|
|
||||||
buf = xrealloc(buf, 1, len + slen + 1);
|
|
||||||
memcpy(buf + len, s, slen);
|
|
||||||
len += slen;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
buf = xrealloc(buf, 1, len + 2);
|
|
||||||
buf[len++] = ch;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
xfree(cdata->template);
|
|
||||||
|
|
||||||
buf[len] = '\0';
|
|
||||||
s = buf;
|
|
||||||
}
|
|
||||||
xfree(cdata);
|
|
||||||
|
|
||||||
if (cmd_string_parse(s, &cmdlist, &cause) != 0) {
|
|
||||||
if (cause == NULL)
|
|
||||||
return (0);
|
|
||||||
*cause = toupper((u_char) *cause);
|
|
||||||
status_message_set(c, cause);
|
|
||||||
xfree(cause);
|
|
||||||
cmdlist = NULL;
|
|
||||||
}
|
|
||||||
if (buf != NULL)
|
|
||||||
xfree(buf);
|
|
||||||
if (cmdlist == NULL)
|
|
||||||
return (0);
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
ctx.msgdata = NULL;
|
||||||
ctx.cursession = c->session;
|
|
||||||
ctx.curclient = c;
|
ctx.curclient = c;
|
||||||
|
|
||||||
ctx.error = key_bindings_error;
|
ctx.error = key_bindings_error;
|
||||||
@@ -172,7 +195,21 @@ cmd_command_prompt_callback(void *data, const char *s)
|
|||||||
cmd_list_exec(cmdlist, &ctx);
|
cmd_list_exec(cmdlist, &ctx);
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
|
|
||||||
if (c->prompt_callback != (void *) &cmd_command_prompt_callback)
|
if (c->prompt_callbackfn != (void *) &cmd_command_prompt_callback)
|
||||||
return (1);
|
return (1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_command_prompt_free(void *data)
|
||||||
|
{
|
||||||
|
struct cmd_command_prompt_cdata *cdata = data;
|
||||||
|
|
||||||
|
if (cdata->inputs != NULL)
|
||||||
|
xfree(cdata->inputs);
|
||||||
|
if (cdata->prompts != NULL)
|
||||||
|
xfree(cdata->prompts);
|
||||||
|
if (cdata->template != NULL)
|
||||||
|
xfree(cdata->template);
|
||||||
|
xfree(cdata);
|
||||||
|
}
|
||||||
|
|||||||
150
cmd-confirm-before.c
Normal file
150
cmd-confirm-before.c
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.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 <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Asks for confirmation before executing a command.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void cmd_confirm_before_key_binding(struct cmd *, int);
|
||||||
|
int cmd_confirm_before_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
int cmd_confirm_before_callback(void *, const char *);
|
||||||
|
void cmd_confirm_before_free(void *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_confirm_before_entry = {
|
||||||
|
"confirm-before", "confirm",
|
||||||
|
"p:t:", 1, 1,
|
||||||
|
"[-p prompt] " CMD_TARGET_CLIENT_USAGE " command",
|
||||||
|
0,
|
||||||
|
cmd_confirm_before_key_binding,
|
||||||
|
NULL,
|
||||||
|
cmd_confirm_before_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_confirm_before_data {
|
||||||
|
struct client *c;
|
||||||
|
char *cmd;
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_confirm_before_key_binding(struct cmd *self, int key)
|
||||||
|
{
|
||||||
|
switch (key) {
|
||||||
|
case '&':
|
||||||
|
self->args = args_create(1, "kill-window");
|
||||||
|
args_set(self->args, 'p', "kill-window #W? (y/n)");
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
self->args = args_create(1, "kill-pane");
|
||||||
|
args_set(self->args, 'p', "kill-pane #P? (y/n)");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
self->args = args_create(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct cmd_confirm_before_data *cdata;
|
||||||
|
struct client *c;
|
||||||
|
char *cmd, *copy, *new_prompt, *ptr;
|
||||||
|
const char *prompt;
|
||||||
|
|
||||||
|
if (ctx->curclient == NULL) {
|
||||||
|
ctx->error(ctx, "must be run interactively");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if ((prompt = args_get(args, 'p')) != NULL)
|
||||||
|
xasprintf(&new_prompt, "%s ", prompt);
|
||||||
|
else {
|
||||||
|
ptr = copy = xstrdup(args->argv[0]);
|
||||||
|
cmd = strsep(&ptr, " \t");
|
||||||
|
xasprintf(&new_prompt, "Confirm '%s'? (y/n) ", cmd);
|
||||||
|
xfree(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
cdata = xmalloc(sizeof *cdata);
|
||||||
|
cdata->cmd = xstrdup(args->argv[0]);
|
||||||
|
cdata->c = c;
|
||||||
|
status_prompt_set(cdata->c, new_prompt, NULL,
|
||||||
|
cmd_confirm_before_callback, cmd_confirm_before_free, cdata,
|
||||||
|
PROMPT_SINGLE);
|
||||||
|
|
||||||
|
xfree(new_prompt);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_confirm_before_callback(void *data, const char *s)
|
||||||
|
{
|
||||||
|
struct cmd_confirm_before_data *cdata = data;
|
||||||
|
struct client *c = cdata->c;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
struct cmd_ctx ctx;
|
||||||
|
char *cause;
|
||||||
|
|
||||||
|
if (s == NULL || *s == '\0')
|
||||||
|
return (0);
|
||||||
|
if (tolower((u_char) s[0]) != 'y' || s[1] != '\0')
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
if (cmd_string_parse(cdata->cmd, &cmdlist, &cause) != 0) {
|
||||||
|
if (cause != NULL) {
|
||||||
|
*cause = toupper((u_char) *cause);
|
||||||
|
status_message_set(c, "%s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.msgdata = NULL;
|
||||||
|
ctx.curclient = c;
|
||||||
|
|
||||||
|
ctx.error = key_bindings_error;
|
||||||
|
ctx.print = key_bindings_print;
|
||||||
|
ctx.info = key_bindings_info;
|
||||||
|
|
||||||
|
ctx.cmdclient = NULL;
|
||||||
|
|
||||||
|
cmd_list_exec(cmdlist, &ctx);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_confirm_before_free(void *data)
|
||||||
|
{
|
||||||
|
struct cmd_confirm_before_data *cdata = data;
|
||||||
|
|
||||||
|
if (cdata->cmd != NULL)
|
||||||
|
xfree(cdata->cmd);
|
||||||
|
xfree(cdata);
|
||||||
|
}
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
/* $Id: cmd-copy-buffer.c,v 1.1 2009-02-03 17:21:19 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.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 <stdlib.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copies a session paste buffer to another session.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_copy_buffer_parse(struct cmd *, int, char **, char **);
|
|
||||||
int cmd_copy_buffer_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_copy_buffer_send(struct cmd *, struct buffer *);
|
|
||||||
void cmd_copy_buffer_recv(struct cmd *, struct buffer *);
|
|
||||||
void cmd_copy_buffer_free(struct cmd *);
|
|
||||||
void cmd_copy_buffer_init(struct cmd *, int);
|
|
||||||
size_t cmd_copy_buffer_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_copy_buffer_data {
|
|
||||||
char *dst_session;
|
|
||||||
char *src_session;
|
|
||||||
int dst_idx;
|
|
||||||
int src_idx;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_copy_buffer_entry = {
|
|
||||||
"copy-buffer", "copyb",
|
|
||||||
"[-a src-index] [-b dst-index] [-s src-session] [-t dst-session]",
|
|
||||||
0,
|
|
||||||
cmd_copy_buffer_init,
|
|
||||||
cmd_copy_buffer_parse,
|
|
||||||
cmd_copy_buffer_exec,
|
|
||||||
cmd_copy_buffer_send,
|
|
||||||
cmd_copy_buffer_recv,
|
|
||||||
cmd_copy_buffer_free,
|
|
||||||
cmd_copy_buffer_print
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_copy_buffer_init(struct cmd *self, unused int arg)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->dst_session = NULL;
|
|
||||||
data->src_session = NULL;
|
|
||||||
data->dst_idx = -1;
|
|
||||||
data->src_idx = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_copy_buffer_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data;
|
|
||||||
const char *errstr;
|
|
||||||
int n, opt;
|
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "a:b:s:t:")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'a':
|
|
||||||
if (data->src_idx == -1) {
|
|
||||||
n = strtonum(optarg, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "buffer %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->src_idx = n;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'b':
|
|
||||||
if (data->dst_idx == -1) {
|
|
||||||
n = strtonum(optarg, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "buffer %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->dst_idx = n;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
if (data->src_session == NULL)
|
|
||||||
data->src_session = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->dst_session == NULL)
|
|
||||||
data->dst_session = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
error:
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_copy_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data = self->data;
|
|
||||||
struct paste_buffer *pb;
|
|
||||||
struct session *dst_session, *src_session;
|
|
||||||
u_int limit;
|
|
||||||
|
|
||||||
if ((dst_session = cmd_find_session(ctx, data->dst_session)) == NULL ||
|
|
||||||
(src_session = cmd_find_session(ctx, data->src_session)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (data->src_idx == -1) {
|
|
||||||
if ((pb = paste_get_top(&src_session->buffers)) == NULL) {
|
|
||||||
ctx->error(ctx, "no buffers");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((pb = paste_get_index(&src_session->buffers,
|
|
||||||
data->src_idx)) == NULL) {
|
|
||||||
ctx->error(ctx, "no buffer %d", data->src_idx);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
limit = options_get_number(&dst_session->options, "buffer-limit");
|
|
||||||
if (data->dst_idx == -1) {
|
|
||||||
paste_add(&dst_session->buffers, xstrdup(pb->data), limit);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
if (paste_replace(&dst_session->buffers, data->dst_idx,
|
|
||||||
xstrdup(pb->data)) != 0) {
|
|
||||||
ctx->error(ctx, "no buffer %d", data->dst_idx);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_copy_buffer_send(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data = self->data;
|
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
|
||||||
cmd_send_string(b, data->dst_session);
|
|
||||||
cmd_send_string(b, data->src_session);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_copy_buffer_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->dst_session = cmd_recv_string(b);
|
|
||||||
data->src_session = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_copy_buffer_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->dst_session != NULL)
|
|
||||||
xfree(data->dst_session);
|
|
||||||
if (data->src_session != NULL)
|
|
||||||
xfree(data->src_session);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_copy_buffer_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->src_idx != -1) {
|
|
||||||
off += xsnprintf(buf + off, len - off, " -a %d",
|
|
||||||
data->src_idx);
|
|
||||||
}
|
|
||||||
if (off < len && data->dst_idx != -1) {
|
|
||||||
off += xsnprintf(buf + off, len - off, " -b %d",
|
|
||||||
data->dst_idx);
|
|
||||||
}
|
|
||||||
if (off < len && data->src_session != NULL) {
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -s ",
|
|
||||||
data->src_session);
|
|
||||||
}
|
|
||||||
if (off < len && data->dst_session != NULL) {
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ",
|
|
||||||
data->dst_session);
|
|
||||||
}
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-copy-mode.c,v 1.16 2009-02-25 21:56:46 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,33 +24,41 @@
|
|||||||
* Enter copy mode.
|
* Enter copy mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void cmd_copy_mode_key_binding(struct cmd *, int);
|
||||||
int cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_copy_mode_entry = {
|
const struct cmd_entry cmd_copy_mode_entry = {
|
||||||
"copy-mode", NULL,
|
"copy-mode", NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"t:u", 0, 0,
|
||||||
CMD_UFLAG,
|
"[-u] " CMD_TARGET_PANE_USAGE,
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
cmd_copy_mode_key_binding,
|
||||||
cmd_copy_mode_exec,
|
NULL,
|
||||||
cmd_target_send,
|
cmd_copy_mode_exec
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_copy_mode_key_binding(struct cmd *self, int key)
|
||||||
|
{
|
||||||
|
self->args = args_create(0);
|
||||||
|
if (key == KEYC_PPAGE)
|
||||||
|
args_set(self->args, 'u', NULL);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
window_pane_set_mode(wl->window->active, &window_copy_mode);
|
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
||||||
if (data->flags & CMD_UFLAG)
|
return (0);
|
||||||
window_copy_pageup(wl->window->active);
|
window_copy_init_from_pane(wp);
|
||||||
|
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
|
||||||
|
window_copy_pageup(wp);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-delete-buffer.c,v 1.4 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,32 +30,37 @@ int cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_delete_buffer_entry = {
|
const struct cmd_entry cmd_delete_buffer_entry = {
|
||||||
"delete-buffer", "deleteb",
|
"delete-buffer", "deleteb",
|
||||||
CMD_BUFFER_SESSION_USAGE,
|
"b:", 0, 0,
|
||||||
|
CMD_BUFFER_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_buffer_init,
|
NULL,
|
||||||
cmd_buffer_parse,
|
NULL,
|
||||||
cmd_delete_buffer_exec,
|
cmd_delete_buffer_exec
|
||||||
cmd_buffer_send,
|
|
||||||
cmd_buffer_recv,
|
|
||||||
cmd_buffer_free,
|
|
||||||
cmd_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
char *cause;
|
||||||
|
int buffer;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if (!args_has(args, 'b')) {
|
||||||
return (-1);
|
paste_free_top(&global_buffers);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
if (data->buffer == -1)
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
paste_free_top(&s->buffers);
|
if (cause != NULL) {
|
||||||
else if (paste_free_index(&s->buffers, data->buffer) != 0) {
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
xfree(cause);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paste_free_index(&global_buffers, buffer) != 0) {
|
||||||
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-detach-client.c,v 1.7 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,27 +28,45 @@ int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_detach_client_entry = {
|
const struct cmd_entry cmd_detach_client_entry = {
|
||||||
"detach-client", "detach",
|
"detach-client", "detach",
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
"s:t:P", 0, 0,
|
||||||
0,
|
"[-P] [-s target-session] " CMD_TARGET_CLIENT_USAGE,
|
||||||
cmd_target_init,
|
CMD_READONLY,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_detach_client_exec,
|
NULL,
|
||||||
cmd_target_send,
|
cmd_detach_client_exec
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
struct session *s;
|
||||||
|
enum msgtype msgtype;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
if (args_has(args, 'P'))
|
||||||
return (-1);
|
msgtype = MSG_DETACHKILL;
|
||||||
|
else
|
||||||
|
msgtype = MSG_DETACH;
|
||||||
|
|
||||||
server_write_client(c, MSG_DETACH, NULL, 0);
|
if (args_has(args, 's')) {
|
||||||
|
s = cmd_find_session(ctx, args_get(args, 's'), 0);
|
||||||
|
if (s == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c != NULL && c->session == s)
|
||||||
|
server_write_client(c, msgtype, NULL, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
c = cmd_find_client(ctx, args_get(args, 't'));
|
||||||
|
if (c == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
server_write_client(c, msgtype, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
78
cmd-display-message.c
Normal file
78
cmd-display-message.c
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.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 <time.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Displays a message in the status line.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_display_message_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_display_message_entry = {
|
||||||
|
"display-message", "display",
|
||||||
|
"c:pt:", 0, 1,
|
||||||
|
"[-p] [-c target-client] [-t target-pane] [message]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_display_message_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct client *c;
|
||||||
|
struct session *s;
|
||||||
|
struct winlink *wl;
|
||||||
|
struct window_pane *wp;
|
||||||
|
const char *template;
|
||||||
|
char *msg;
|
||||||
|
|
||||||
|
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (args_has(args, 't') != 0) {
|
||||||
|
wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp);
|
||||||
|
if (wl == NULL)
|
||||||
|
return (-1);
|
||||||
|
} else {
|
||||||
|
s = NULL;
|
||||||
|
wl = NULL;
|
||||||
|
wp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args->argc == 0)
|
||||||
|
template = "[#S] #I:#W, current pane #P - (%H:%M %d-%b-%y)";
|
||||||
|
else
|
||||||
|
template = args->argv[0];
|
||||||
|
|
||||||
|
msg = status_replace(c, s, wl, wp, template, time(NULL), 0);
|
||||||
|
if (args_has(self->args, 'p'))
|
||||||
|
ctx->print(ctx, "%s", msg);
|
||||||
|
else
|
||||||
|
status_message_set(c, "%s", msg);
|
||||||
|
xfree(msg);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-down-pane.c,v 1.7 2009-04-01 21:10:08 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -21,41 +21,31 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move down a pane.
|
* Display panes on a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_down_pane_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_display_panes_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_down_pane_entry = {
|
const struct cmd_entry cmd_display_panes_entry = {
|
||||||
"down-pane", "downp",
|
"display-panes", "displayp",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_down_pane_exec,
|
cmd_display_panes_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_display_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct client *c;
|
||||||
struct window *w;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
|
||||||
|
|
||||||
do {
|
server_set_identify(c);
|
||||||
w->active = TAILQ_NEXT(w->active, entry);
|
|
||||||
if (w->active == NULL)
|
|
||||||
w->active = TAILQ_FIRST(&w->panes);
|
|
||||||
layout_refresh(w, 1);
|
|
||||||
} while (w->active->flags & PANE_HIDDEN);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-find-window.c,v 1.6 2009-03-29 11:18:28 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <fnmatch.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -29,29 +30,26 @@
|
|||||||
int cmd_find_window_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_find_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_find_window_callback(void *, int);
|
void cmd_find_window_callback(void *, int);
|
||||||
char *cmd_find_window_search(struct window_pane *, const char *);
|
void cmd_find_window_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_find_window_entry = {
|
const struct cmd_entry cmd_find_window_entry = {
|
||||||
"find-window", "findw",
|
"find-window", "findw",
|
||||||
|
"t:", 1, 1,
|
||||||
CMD_TARGET_WINDOW_USAGE " match-string",
|
CMD_TARGET_WINDOW_USAGE " match-string",
|
||||||
CMD_ARG1,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_find_window_exec,
|
cmd_find_window_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_find_window_data {
|
struct cmd_find_window_data {
|
||||||
u_int session;
|
struct session *session;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct cmd_find_window_data *cdata;
|
struct cmd_find_window_data *cdata;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl, *wm;
|
struct winlink *wl, *wm;
|
||||||
@@ -59,8 +57,8 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
ARRAY_DECL(, u_int) list_idx;
|
ARRAY_DECL(, u_int) list_idx;
|
||||||
ARRAY_DECL(, char *) list_ctx;
|
ARRAY_DECL(, char *) list_ctx;
|
||||||
char *sres, *sctx;
|
char *str, *sres, *sctx, *searchstr;
|
||||||
u_int i;
|
u_int i, line;
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
@@ -68,42 +66,48 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
s = ctx->curclient->session;
|
s = ctx->curclient->session;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
str = args->argv[0];
|
||||||
|
|
||||||
ARRAY_INIT(&list_idx);
|
ARRAY_INIT(&list_idx);
|
||||||
ARRAY_INIT(&list_ctx);
|
ARRAY_INIT(&list_ctx);
|
||||||
|
|
||||||
|
xasprintf(&searchstr, "*%s*", str);
|
||||||
RB_FOREACH(wm, winlinks, &s->windows) {
|
RB_FOREACH(wm, winlinks, &s->windows) {
|
||||||
i = 0;
|
i = 0;
|
||||||
TAILQ_FOREACH(wp, &wm->window->panes, entry) {
|
TAILQ_FOREACH(wp, &wm->window->panes, entry) {
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (strstr(wm->window->name, data->arg) != NULL)
|
if (fnmatch(searchstr, wm->window->name, 0) == 0)
|
||||||
sctx = xstrdup("");
|
sctx = xstrdup("");
|
||||||
else {
|
else {
|
||||||
sres = cmd_find_window_search(wp, data->arg);
|
sres = window_pane_search(wp, str, &line);
|
||||||
if (sres == NULL &&
|
if (sres == NULL &&
|
||||||
strstr(wp->base.title, data->arg) == NULL)
|
fnmatch(searchstr, wp->base.title, 0) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sres == NULL) {
|
if (sres == NULL) {
|
||||||
xasprintf(&sctx,
|
xasprintf(&sctx,
|
||||||
"pane %u title: \"%s\"", i - 1,
|
"pane %u title: \"%s\"", i - 1,
|
||||||
wp->base.title);
|
wp->base.title);
|
||||||
} else {
|
} else {
|
||||||
xasprintf(&sctx, "\"%s\"", sres);
|
xasprintf(&sctx,
|
||||||
|
"pane %u line %u: \"%s\"", i - 1,
|
||||||
|
line + 1, sres);
|
||||||
xfree(sres);
|
xfree(sres);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ARRAY_ADD(&list_idx, wm->idx);
|
ARRAY_ADD(&list_idx, wm->idx);
|
||||||
ARRAY_ADD(&list_ctx, sctx);
|
ARRAY_ADD(&list_ctx, sctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
xfree(searchstr);
|
||||||
|
|
||||||
if (ARRAY_LENGTH(&list_idx) == 0) {
|
if (ARRAY_LENGTH(&list_idx) == 0) {
|
||||||
ctx->error(ctx, "no windows matching: %s", data->arg);
|
ctx->error(ctx, "no windows matching: %s", str);
|
||||||
ARRAY_FREE(&list_idx);
|
ARRAY_FREE(&list_idx);
|
||||||
ARRAY_FREE(&list_ctx);
|
ARRAY_FREE(&list_ctx);
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -123,7 +127,7 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
wm = winlink_find_by_index(
|
wm = winlink_find_by_index(
|
||||||
&s->windows, ARRAY_ITEM(&list_idx, i));
|
&s->windows, ARRAY_ITEM(&list_idx, i));
|
||||||
w = wm->window;
|
w = wm->window;
|
||||||
|
|
||||||
sctx = ARRAY_ITEM(&list_ctx, i);
|
sctx = ARRAY_ITEM(&list_ctx, i);
|
||||||
window_choose_add(wl->window->active,
|
window_choose_add(wl->window->active,
|
||||||
wm->idx, "%3d: %s [%ux%u] (%u panes) %s", wm->idx, w->name,
|
wm->idx, "%3d: %s [%ux%u] (%u panes) %s", wm->idx, w->name,
|
||||||
@@ -132,11 +136,11 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
if (session_index(s, &cdata->session) != 0)
|
cdata->session = s;
|
||||||
fatalx("session not found");
|
cdata->session->references++;
|
||||||
|
|
||||||
window_choose_ready(
|
window_choose_ready(wl->window->active,
|
||||||
wl->window->active, 0, cmd_find_window_callback, cdata);
|
0, cmd_find_window_callback, cmd_find_window_free, cdata);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
ARRAY_FREE(&list_idx);
|
ARRAY_FREE(&list_idx);
|
||||||
@@ -149,56 +153,24 @@ void
|
|||||||
cmd_find_window_callback(void *data, int idx)
|
cmd_find_window_callback(void *data, int idx)
|
||||||
{
|
{
|
||||||
struct cmd_find_window_data *cdata = data;
|
struct cmd_find_window_data *cdata = data;
|
||||||
struct session *s;
|
struct session *s = cdata->session;
|
||||||
|
|
||||||
if (idx != -1 && cdata->session <= ARRAY_LENGTH(&sessions) - 1) {
|
if (idx == -1)
|
||||||
s = ARRAY_ITEM(&sessions, cdata->session);
|
return;
|
||||||
if (s != NULL && session_select(s, idx) == 0)
|
if (!session_alive(s))
|
||||||
server_redraw_session(s);
|
return;
|
||||||
|
|
||||||
|
if (session_select(s, idx) == 0) {
|
||||||
|
server_redraw_session(s);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_find_window_free(void *data)
|
||||||
|
{
|
||||||
|
struct cmd_find_window_data *cdata = data;
|
||||||
|
|
||||||
|
cdata->session->references--;
|
||||||
xfree(cdata);
|
xfree(cdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
|
||||||
cmd_find_window_search(struct window_pane *wp, const char *searchstr)
|
|
||||||
{
|
|
||||||
const struct grid_cell *gc;
|
|
||||||
const struct grid_utf8 *gu;
|
|
||||||
char *buf, *s;
|
|
||||||
size_t off;
|
|
||||||
u_int i, j, k;
|
|
||||||
|
|
||||||
buf = xmalloc(1);
|
|
||||||
|
|
||||||
for (j = 0; j < screen_size_y(&wp->base); j++) {
|
|
||||||
off = 0;
|
|
||||||
for (i = 0; i < screen_size_x(&wp->base); i++) {
|
|
||||||
gc = grid_view_peek_cell(wp->base.grid, i, j);
|
|
||||||
if (gc->flags & GRID_FLAG_UTF8) {
|
|
||||||
gu = grid_view_peek_utf8(wp->base.grid, i, j);
|
|
||||||
buf = xrealloc(buf, 1, off + 8);
|
|
||||||
for (k = 0; k < UTF8_SIZE; k++) {
|
|
||||||
if (gu->data[k] == 0xff)
|
|
||||||
break;
|
|
||||||
buf[off++] = gu->data[k];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
buf = xrealloc(buf, 1, off + 1);
|
|
||||||
buf[off++] = gc->data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (off > 0 && buf[off - 1] == ' ')
|
|
||||||
off--;
|
|
||||||
buf[off] = '\0';
|
|
||||||
|
|
||||||
if ((s = strstr(buf, searchstr)) != NULL) {
|
|
||||||
s = section_string(buf, off, s - buf, 40);
|
|
||||||
xfree(buf);
|
|
||||||
return (s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
xfree(buf);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|||||||
694
cmd-generic.c
694
cmd-generic.c
@@ -1,694 +0,0 @@
|
|||||||
/* $Id: cmd-generic.c,v 1.25 2009-04-03 17:31:44 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
#define CMD_FLAGS "adDgkuU"
|
|
||||||
#define CMD_FLAGMASK (CMD_AFLAG|CMD_DFLAG|CMD_UPPERDFLAG|CMD_GFLAG|CMD_KFLAG| \
|
|
||||||
CMD_UFLAG|CMD_UPPERUFLAG)
|
|
||||||
|
|
||||||
int cmd_do_flags(int, int, int *);
|
|
||||||
size_t cmd_print_flags(char *, size_t, size_t, int);
|
|
||||||
int cmd_fill_argument(int, char **, int, char **);
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_prarg(char *buf, size_t len, const char *prefix, char *arg)
|
|
||||||
{
|
|
||||||
if (strchr(arg, ' ' ) != NULL)
|
|
||||||
return (xsnprintf(buf, len, "%s\"%s\"", prefix, arg));
|
|
||||||
return (xsnprintf(buf, len, "%s%s", prefix, arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_do_flags(int opt, int iflags, int *oflags)
|
|
||||||
{
|
|
||||||
switch (opt) {
|
|
||||||
case 'a':
|
|
||||||
if (iflags & CMD_AFLAG) {
|
|
||||||
(*oflags) |= CMD_AFLAG;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
case 'd':
|
|
||||||
if (iflags & CMD_DFLAG) {
|
|
||||||
(*oflags) |= CMD_DFLAG;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
case 'D':
|
|
||||||
if (iflags & CMD_UPPERDFLAG) {
|
|
||||||
(*oflags) |= CMD_UPPERDFLAG;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
case 'g':
|
|
||||||
if (iflags & CMD_GFLAG) {
|
|
||||||
(*oflags) |= CMD_GFLAG;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
case 'k':
|
|
||||||
if (iflags & CMD_KFLAG) {
|
|
||||||
(*oflags) |= CMD_KFLAG;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
case 'u':
|
|
||||||
if (iflags & CMD_UFLAG) {
|
|
||||||
(*oflags) |= CMD_UFLAG;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
case 'U':
|
|
||||||
if (iflags & CMD_UPPERUFLAG) {
|
|
||||||
(*oflags) |= CMD_UPPERUFLAG;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_print_flags(char *buf, size_t len, size_t off, int flags)
|
|
||||||
{
|
|
||||||
size_t boff = off;
|
|
||||||
|
|
||||||
if ((flags & CMD_FLAGMASK) == 0)
|
|
||||||
return (0);
|
|
||||||
off += xsnprintf(buf + off, len - off, " -");
|
|
||||||
if (off < len && flags & CMD_AFLAG)
|
|
||||||
off += xsnprintf(buf + off, len - off, "a");
|
|
||||||
if (off < len && flags & CMD_UPPERDFLAG)
|
|
||||||
off += xsnprintf(buf + off, len - off, "D");
|
|
||||||
if (off < len && flags & CMD_DFLAG)
|
|
||||||
off += xsnprintf(buf + off, len - off, "d");
|
|
||||||
if (off < len && flags & CMD_GFLAG)
|
|
||||||
off += xsnprintf(buf + off, len - off, "g");
|
|
||||||
if (off < len && flags & CMD_KFLAG)
|
|
||||||
off += xsnprintf(buf + off, len - off, "k");
|
|
||||||
if (off < len && flags & CMD_UFLAG)
|
|
||||||
off += xsnprintf(buf + off, len - off, "u");
|
|
||||||
if (off < len && flags & CMD_UPPERUFLAG)
|
|
||||||
off += xsnprintf(buf + off, len - off, "U");
|
|
||||||
return (off - boff);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_fill_argument(int flags, char **arg, int argc, char **argv)
|
|
||||||
{
|
|
||||||
*arg = NULL;
|
|
||||||
|
|
||||||
if (flags & CMD_ARG1) {
|
|
||||||
if (argc != 1)
|
|
||||||
return (-1);
|
|
||||||
*arg = xstrdup(argv[0]);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & CMD_ARG01) {
|
|
||||||
if (argc != 0 && argc != 1)
|
|
||||||
return (-1);
|
|
||||||
if (argc == 1)
|
|
||||||
*arg = xstrdup(argv[0]);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc != 0)
|
|
||||||
return (-1);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_target_init(struct cmd *self, unused int key)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->flags = 0;
|
|
||||||
data->target = NULL;
|
|
||||||
data->arg = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_target_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data;
|
|
||||||
int opt;
|
|
||||||
|
|
||||||
/* Don't use the entry version since it may be dependent on key. */
|
|
||||||
cmd_target_init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, CMD_FLAGS "t:")) != -1) {
|
|
||||||
switch (cmd_do_flags(opt, self->entry->flags, &data->flags)) {
|
|
||||||
case -1:
|
|
||||||
goto usage;
|
|
||||||
case 0:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (opt) {
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (cmd_fill_argument(self->entry->flags, &data->arg, argc, argv) != 0)
|
|
||||||
goto usage;
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_target_send(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
|
||||||
cmd_send_string(b, data->target);
|
|
||||||
cmd_send_string(b, data->arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_target_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->target = cmd_recv_string(b);
|
|
||||||
data->arg = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_target_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
if (data->arg != NULL)
|
|
||||||
xfree(data->arg);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_target_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
off += cmd_print_flags(buf, len, off, data->flags);
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->arg != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_srcdst_init(struct cmd *self, unused int key)
|
|
||||||
{
|
|
||||||
struct cmd_srcdst_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->flags = 0;
|
|
||||||
data->src = NULL;
|
|
||||||
data->dst = NULL;
|
|
||||||
data->arg = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_srcdst_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_srcdst_data *data;
|
|
||||||
int opt;
|
|
||||||
|
|
||||||
cmd_srcdst_init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, CMD_FLAGS "s:t:")) != -1) {
|
|
||||||
switch (cmd_do_flags(opt, self->entry->flags, &data->flags)) {
|
|
||||||
case -1:
|
|
||||||
goto usage;
|
|
||||||
case 0:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (opt) {
|
|
||||||
case 's':
|
|
||||||
if (data->src == NULL)
|
|
||||||
data->src = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->dst == NULL)
|
|
||||||
data->dst = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (cmd_fill_argument(self->entry->flags, &data->arg, argc, argv) != 0)
|
|
||||||
goto usage;
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_srcdst_send(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_srcdst_data *data = self->data;
|
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
|
||||||
cmd_send_string(b, data->src);
|
|
||||||
cmd_send_string(b, data->dst);
|
|
||||||
cmd_send_string(b, data->arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_srcdst_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_srcdst_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->src = cmd_recv_string(b);
|
|
||||||
data->dst = cmd_recv_string(b);
|
|
||||||
data->arg = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_srcdst_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_srcdst_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->src != NULL)
|
|
||||||
xfree(data->src);
|
|
||||||
if (data->dst != NULL)
|
|
||||||
xfree(data->dst);
|
|
||||||
if (data->arg != NULL)
|
|
||||||
xfree(data->arg);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_srcdst_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_srcdst_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
off += cmd_print_flags(buf, len, off, data->flags);
|
|
||||||
if (off < len && data->src != NULL)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -s %s", data->src);
|
|
||||||
if (off < len && data->dst != NULL)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -t %s", data->dst);
|
|
||||||
if (off < len && data->arg != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_buffer_init(struct cmd *self, unused int key)
|
|
||||||
{
|
|
||||||
struct cmd_buffer_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->flags = 0;
|
|
||||||
data->target = NULL;
|
|
||||||
data->buffer = -1;
|
|
||||||
data->arg = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_buffer_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_buffer_data *data;
|
|
||||||
int opt, n;
|
|
||||||
const char *errstr;
|
|
||||||
|
|
||||||
cmd_buffer_init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, CMD_FLAGS "b:t:")) != -1) {
|
|
||||||
switch (cmd_do_flags(opt, self->entry->flags, &data->flags)) {
|
|
||||||
case -1:
|
|
||||||
goto usage;
|
|
||||||
case 0:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (opt) {
|
|
||||||
case 'b':
|
|
||||||
if (data->buffer == -1) {
|
|
||||||
n = strtonum(optarg, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "buffer %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->buffer = n;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (cmd_fill_argument(self->entry->flags, &data->arg, argc, argv) != 0)
|
|
||||||
goto usage;
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
error:
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_buffer_send(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_buffer_data *data = self->data;
|
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
|
||||||
cmd_send_string(b, data->target);
|
|
||||||
cmd_send_string(b, data->arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_buffer_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_buffer_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->target = cmd_recv_string(b);
|
|
||||||
data->arg = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_buffer_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_buffer_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
if (data->arg != NULL)
|
|
||||||
xfree(data->arg);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_buffer_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_buffer_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
off += cmd_print_flags(buf, len, off, data->flags);
|
|
||||||
if (off < len && data->buffer != -1)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -b %d", data->buffer);
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->arg != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_option_init(struct cmd *self, unused int key)
|
|
||||||
{
|
|
||||||
struct cmd_option_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->flags = 0;
|
|
||||||
data->target = NULL;
|
|
||||||
data->option = NULL;
|
|
||||||
data->value = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_option_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_option_data *data;
|
|
||||||
int opt;
|
|
||||||
|
|
||||||
/* Don't use the entry version since it may be dependent on key. */
|
|
||||||
cmd_option_init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, CMD_FLAGS "t:")) != -1) {
|
|
||||||
switch (cmd_do_flags(opt, self->entry->flags, &data->flags)) {
|
|
||||||
case -1:
|
|
||||||
goto usage;
|
|
||||||
case 0:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (opt) {
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (argc == 2) {
|
|
||||||
data->option = xstrdup(argv[0]);
|
|
||||||
data->value = xstrdup(argv[1]);
|
|
||||||
} else if (argc == 1)
|
|
||||||
data->option = xstrdup(argv[0]);
|
|
||||||
else
|
|
||||||
goto usage;
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_option_send(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_option_data *data = self->data;
|
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
|
||||||
cmd_send_string(b, data->target);
|
|
||||||
cmd_send_string(b, data->option);
|
|
||||||
cmd_send_string(b, data->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_option_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_option_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->target = cmd_recv_string(b);
|
|
||||||
data->option = cmd_recv_string(b);
|
|
||||||
data->value = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_option_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_option_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
if (data->option != NULL)
|
|
||||||
xfree(data->option);
|
|
||||||
if (data->value != NULL)
|
|
||||||
xfree(data->value);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_option_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_option_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
off += cmd_print_flags(buf, len, off, data->flags);
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->option != NULL)
|
|
||||||
off += xsnprintf(buf + off, len - off, " %s", data->option);
|
|
||||||
if (off < len && data->value != NULL)
|
|
||||||
off += xsnprintf(buf + off, len - off, " %s", data->value);
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_pane_init(struct cmd *self, unused int key)
|
|
||||||
{
|
|
||||||
struct cmd_pane_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->flags = 0;
|
|
||||||
data->target = NULL;
|
|
||||||
data->arg = NULL;
|
|
||||||
data->pane = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_pane_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_pane_data *data;
|
|
||||||
int opt, n;
|
|
||||||
const char *errstr;
|
|
||||||
|
|
||||||
/* Don't use the entry version since it may be dependent on key. */
|
|
||||||
cmd_pane_init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, CMD_FLAGS "p:t:")) != -1) {
|
|
||||||
switch (cmd_do_flags(opt, self->entry->flags, &data->flags)) {
|
|
||||||
case -1:
|
|
||||||
goto usage;
|
|
||||||
case 0:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (opt) {
|
|
||||||
case 'p':
|
|
||||||
if (data->pane == -1) {
|
|
||||||
n = strtonum(optarg, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "pane %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->pane = n;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (cmd_fill_argument(self->entry->flags, &data->arg, argc, argv) != 0)
|
|
||||||
goto usage;
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
error:
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_pane_send(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_pane_data *data = self->data;
|
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
|
||||||
cmd_send_string(b, data->target);
|
|
||||||
cmd_send_string(b, data->arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_pane_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_pane_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->target = cmd_recv_string(b);
|
|
||||||
data->arg = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_pane_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_pane_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
if (data->arg != NULL)
|
|
||||||
xfree(data->arg);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_pane_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_pane_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
off += cmd_print_flags(buf, len, off, data->flags);
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->arg != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-has-session.c,v 1.12 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,23 +28,20 @@ int cmd_has_session_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_has_session_entry = {
|
const struct cmd_entry cmd_has_session_entry = {
|
||||||
"has-session", "has",
|
"has-session", "has",
|
||||||
|
"t:", 0, 0,
|
||||||
CMD_TARGET_SESSION_USAGE,
|
CMD_TARGET_SESSION_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_has_session_exec,
|
cmd_has_session_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_has_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_has_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
|
|
||||||
if (cmd_find_session(ctx, data->target) == NULL)
|
if (cmd_find_session(ctx, args_get(args, 't'), 0) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
122
cmd-if-shell.c
Normal file
122
cmd-if-shell.c
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
|
* Copyright (c) 2009 Nicholas Marriott <nicm@openbsd.org>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF 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/wait.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Executes a tmux command if a shell command returns true or false.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_if_shell_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
void cmd_if_shell_callback(struct job *);
|
||||||
|
void cmd_if_shell_free(void *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_if_shell_entry = {
|
||||||
|
"if-shell", "if",
|
||||||
|
"", 2, 3,
|
||||||
|
"shell-command command [command]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_if_shell_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_if_shell_data {
|
||||||
|
char *cmd_if;
|
||||||
|
char *cmd_else;
|
||||||
|
struct cmd_ctx ctx;
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct cmd_if_shell_data *cdata;
|
||||||
|
const char *shellcmd = args->argv[0];
|
||||||
|
|
||||||
|
cdata = xmalloc(sizeof *cdata);
|
||||||
|
cdata->cmd_if = xstrdup(args->argv[1]);
|
||||||
|
if (args->argc == 3)
|
||||||
|
cdata->cmd_else = xstrdup(args->argv[2]);
|
||||||
|
else
|
||||||
|
cdata->cmd_else = NULL;
|
||||||
|
memcpy(&cdata->ctx, ctx, sizeof cdata->ctx);
|
||||||
|
|
||||||
|
if (ctx->cmdclient != NULL)
|
||||||
|
ctx->cmdclient->references++;
|
||||||
|
if (ctx->curclient != NULL)
|
||||||
|
ctx->curclient->references++;
|
||||||
|
|
||||||
|
job_run(shellcmd, cmd_if_shell_callback, cmd_if_shell_free, cdata);
|
||||||
|
|
||||||
|
return (1); /* don't let client exit */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_if_shell_callback(struct job *job)
|
||||||
|
{
|
||||||
|
struct cmd_if_shell_data *cdata = job->data;
|
||||||
|
struct cmd_ctx *ctx = &cdata->ctx;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
char *cause, *cmd;
|
||||||
|
|
||||||
|
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0) {
|
||||||
|
cmd = cdata->cmd_else;
|
||||||
|
if (cmd == NULL)
|
||||||
|
return;
|
||||||
|
} else
|
||||||
|
cmd = cdata->cmd_if;
|
||||||
|
if (cmd_string_parse(cmd, &cmdlist, &cause) != 0) {
|
||||||
|
if (cause != NULL) {
|
||||||
|
ctx->error(ctx, "%s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_list_exec(cmdlist, ctx);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_if_shell_free(void *data)
|
||||||
|
{
|
||||||
|
struct cmd_if_shell_data *cdata = data;
|
||||||
|
struct cmd_ctx *ctx = &cdata->ctx;
|
||||||
|
struct msg_exit_data exitdata;
|
||||||
|
|
||||||
|
if (ctx->cmdclient != NULL) {
|
||||||
|
ctx->cmdclient->references--;
|
||||||
|
exitdata.retcode = ctx->cmdclient->retcode;
|
||||||
|
ctx->cmdclient->flags |= CLIENT_EXIT;
|
||||||
|
}
|
||||||
|
if (ctx->curclient != NULL)
|
||||||
|
ctx->curclient->references--;
|
||||||
|
|
||||||
|
if (cdata->cmd_else != NULL)
|
||||||
|
xfree(cdata->cmd_else);
|
||||||
|
xfree(cdata->cmd_if);
|
||||||
|
xfree(cdata);
|
||||||
|
}
|
||||||
145
cmd-join-pane.c
Normal file
145
cmd-join-pane.c
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Join a pane into another (like split/swap/kill).
|
||||||
|
*/
|
||||||
|
|
||||||
|
void cmd_join_pane_key_binding(struct cmd *, int);
|
||||||
|
int cmd_join_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_join_pane_entry = {
|
||||||
|
"join-pane", "joinp",
|
||||||
|
"dhvp:l:s:t:", 0, 0,
|
||||||
|
"[-dhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
||||||
|
0,
|
||||||
|
cmd_join_pane_key_binding,
|
||||||
|
NULL,
|
||||||
|
cmd_join_pane_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_join_pane_key_binding(struct cmd *self, int key)
|
||||||
|
{
|
||||||
|
switch (key) {
|
||||||
|
case '%':
|
||||||
|
self->args = args_create(0);
|
||||||
|
args_set(self->args, 'h', NULL);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
self->args = args_create(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct session *dst_s;
|
||||||
|
struct winlink *src_wl, *dst_wl;
|
||||||
|
struct window *src_w, *dst_w;
|
||||||
|
struct window_pane *src_wp, *dst_wp;
|
||||||
|
char *cause;
|
||||||
|
int size, percentage, dst_idx;
|
||||||
|
enum layout_type type;
|
||||||
|
struct layout_cell *lc;
|
||||||
|
|
||||||
|
dst_wl = cmd_find_pane(ctx, args_get(args, 't'), &dst_s, &dst_wp);
|
||||||
|
if (dst_wl == NULL)
|
||||||
|
return (-1);
|
||||||
|
dst_w = dst_wl->window;
|
||||||
|
dst_idx = dst_wl->idx;
|
||||||
|
|
||||||
|
src_wl = cmd_find_pane(ctx, args_get(args, 's'), NULL, &src_wp);
|
||||||
|
if (src_wl == NULL)
|
||||||
|
return (-1);
|
||||||
|
src_w = src_wl->window;
|
||||||
|
|
||||||
|
if (src_w == dst_w) {
|
||||||
|
ctx->error(ctx, "can't join a pane to its own window");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
type = LAYOUT_TOPBOTTOM;
|
||||||
|
if (args_has(args, 'h'))
|
||||||
|
type = LAYOUT_LEFTRIGHT;
|
||||||
|
|
||||||
|
size = -1;
|
||||||
|
if (args_has(args, 'l')) {
|
||||||
|
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
ctx->error(ctx, "size %s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} else if (args_has(args, 'p')) {
|
||||||
|
percentage = args_strtonum(args, 'p', 0, 100, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
ctx->error(ctx, "percentage %s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
|
size = (dst_wp->sy * percentage) / 100;
|
||||||
|
else
|
||||||
|
size = (dst_wp->sx * percentage) / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((lc = layout_split_pane(dst_wp, type, size)) == NULL) {
|
||||||
|
ctx->error(ctx, "create pane failed: pane too small");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
layout_close_pane(src_wp);
|
||||||
|
|
||||||
|
if (src_w->active == src_wp) {
|
||||||
|
src_w->active = TAILQ_PREV(src_wp, window_panes, entry);
|
||||||
|
if (src_w->active == NULL)
|
||||||
|
src_w->active = TAILQ_NEXT(src_wp, entry);
|
||||||
|
}
|
||||||
|
TAILQ_REMOVE(&src_w->panes, src_wp, entry);
|
||||||
|
|
||||||
|
if (window_count_panes(src_w) == 0)
|
||||||
|
server_kill_window(src_w);
|
||||||
|
|
||||||
|
src_wp->window = dst_w;
|
||||||
|
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
||||||
|
layout_assign_pane(lc, src_wp);
|
||||||
|
|
||||||
|
recalculate_sizes();
|
||||||
|
|
||||||
|
server_redraw_window(src_w);
|
||||||
|
server_redraw_window(dst_w);
|
||||||
|
|
||||||
|
if (!args_has(args, 'd')) {
|
||||||
|
window_set_active_pane(dst_w, src_wp);
|
||||||
|
session_select(dst_s, dst_idx);
|
||||||
|
server_redraw_session(dst_s);
|
||||||
|
} else
|
||||||
|
server_status_session(dst_s);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-kill-pane.c,v 1.6 2009-04-01 21:10:08 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,43 +30,46 @@ int cmd_kill_pane_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_kill_pane_entry = {
|
const struct cmd_entry cmd_kill_pane_entry = {
|
||||||
"kill-pane", "killp",
|
"kill-pane", "killp",
|
||||||
CMD_PANE_WINDOW_USAGE,
|
"at:", 0, 0,
|
||||||
|
"[-a] " CMD_TARGET_PANE_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_pane_init,
|
NULL,
|
||||||
cmd_pane_parse,
|
NULL,
|
||||||
cmd_kill_pane_exec,
|
cmd_kill_pane_exec
|
||||||
cmd_pane_send,
|
|
||||||
cmd_pane_recv,
|
|
||||||
cmd_pane_free,
|
|
||||||
cmd_pane_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_pane_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window_pane *wp;
|
struct window_pane *loopwp, *nextwp, *wp;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
if (data->pane == -1)
|
|
||||||
wp = wl->window->active;
|
|
||||||
else {
|
|
||||||
wp = window_pane_at_index(wl->window, data->pane);
|
|
||||||
if (wp == NULL) {
|
|
||||||
ctx->error(ctx, "no pane: %d", data->pane);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window_count_panes(wl->window) == 1) {
|
if (window_count_panes(wl->window) == 1) {
|
||||||
ctx->error(ctx, "can't kill pane: %d", data->pane);
|
/* Only one pane, kill the window. */
|
||||||
return (-1);
|
server_kill_window(wl->window);
|
||||||
|
recalculate_sizes();
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
window_remove_pane(wl->window, wp);
|
if (args_has(self->args, 'a')) {
|
||||||
|
loopwp = TAILQ_FIRST(&wl->window->panes);
|
||||||
|
while (loopwp != NULL) {
|
||||||
|
nextwp = TAILQ_NEXT(loopwp, entry);
|
||||||
|
if (loopwp != wp) {
|
||||||
|
layout_close_pane(loopwp);
|
||||||
|
window_remove_pane(wl->window, loopwp);
|
||||||
|
}
|
||||||
|
loopwp = nextwp;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
layout_close_pane(wp);
|
||||||
|
window_remove_pane(wl->window, wp);
|
||||||
|
}
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
layout_refresh(wl->window, 0);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-kill-server.c,v 1.6 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,21 +31,19 @@ int cmd_kill_server_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_kill_server_entry = {
|
const struct cmd_entry cmd_kill_server_entry = {
|
||||||
"kill-server", NULL,
|
"kill-server", NULL,
|
||||||
|
"", 0, 0,
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_kill_server_exec,
|
cmd_kill_server_exec
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
cmd_kill_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_kill_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
sigterm = 1;
|
kill(getpid(), SIGTERM);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-kill-session.c,v 1.12 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,37 +31,24 @@ int cmd_kill_session_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_kill_session_entry = {
|
const struct cmd_entry cmd_kill_session_entry = {
|
||||||
"kill-session", NULL,
|
"kill-session", NULL,
|
||||||
|
"t:", 0, 0,
|
||||||
CMD_TARGET_SESSION_USAGE,
|
CMD_TARGET_SESSION_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_kill_session_exec,
|
cmd_kill_session_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_kill_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct client *c;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
server_destroy_session(s);
|
||||||
c = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c->session == s) {
|
|
||||||
c->session = NULL;
|
|
||||||
server_write_client(c, MSG_EXIT, NULL, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
|
||||||
|
|
||||||
session_destroy(s);
|
session_destroy(s);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-kill-window.c,v 1.15 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,41 +28,24 @@ int cmd_kill_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_kill_window_entry = {
|
const struct cmd_entry cmd_kill_window_entry = {
|
||||||
"kill-window", "killw",
|
"kill-window", "killw",
|
||||||
|
"t:", 0, 0,
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_kill_window_exec,
|
cmd_kill_window_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct session *s;
|
|
||||||
struct client *c;
|
|
||||||
u_int i;
|
|
||||||
int destroyed;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
destroyed = session_detach(s, wl);
|
server_kill_window(wl->window);
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
|
||||||
c = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c == NULL || c->session != s)
|
|
||||||
continue;
|
|
||||||
if (destroyed) {
|
|
||||||
c->session = NULL;
|
|
||||||
server_write_client(c, MSG_EXIT, NULL, 0);
|
|
||||||
} else
|
|
||||||
server_redraw_client(c);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
/* $Id: cmd-last-window.c,v 1.16 2009-01-19 18:23:40 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Move to last window.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_last_window_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_last_window_entry = {
|
|
||||||
"last-window", "last",
|
|
||||||
CMD_TARGET_SESSION_USAGE,
|
|
||||||
0,
|
|
||||||
cmd_target_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_last_window_exec,
|
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_last_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct session *s;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (session_last(s) == 0)
|
|
||||||
server_redraw_session(s);
|
|
||||||
else {
|
|
||||||
ctx->error(ctx, "no last window");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-link-window.c,v 1.28 2009-01-23 16:59:14 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,79 +30,35 @@ int cmd_link_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_link_window_entry = {
|
const struct cmd_entry cmd_link_window_entry = {
|
||||||
"link-window", "linkw",
|
"link-window", "linkw",
|
||||||
|
"dks:t:", 0, 0,
|
||||||
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
CMD_DFLAG|CMD_KFLAG,
|
0,
|
||||||
cmd_srcdst_init,
|
NULL,
|
||||||
cmd_srcdst_parse,
|
NULL,
|
||||||
cmd_link_window_exec,
|
cmd_link_window_exec
|
||||||
cmd_srcdst_send,
|
|
||||||
cmd_srcdst_recv,
|
|
||||||
cmd_srcdst_free,
|
|
||||||
cmd_srcdst_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_srcdst_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *dst;
|
struct session *src, *dst;
|
||||||
struct winlink *wl_src, *wl_dst;
|
struct winlink *wl;
|
||||||
char *cause;
|
char *cause;
|
||||||
int idx;
|
int idx, kflag, dflag;
|
||||||
|
|
||||||
if ((wl_src = cmd_find_window(ctx, data->src, NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 's'), &src)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &dst)) == -2)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (arg_parse_window(data->dst, &dst, &idx) != 0) {
|
kflag = args_has(self->args, 'k');
|
||||||
ctx->error(ctx, "bad window: %s", data->dst);
|
dflag = args_has(self->args, 'd');
|
||||||
return (-1);
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||||
}
|
ctx->error(ctx, "can't link window: %s", cause);
|
||||||
if (dst == NULL)
|
|
||||||
dst = ctx->cursession;
|
|
||||||
if (dst == NULL)
|
|
||||||
dst = cmd_current_session(ctx);
|
|
||||||
if (dst == NULL) {
|
|
||||||
ctx->error(ctx, "session not found: %s", data->dst);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_dst = NULL;
|
|
||||||
if (idx != -1)
|
|
||||||
wl_dst = winlink_find_by_index(&dst->windows, idx);
|
|
||||||
if (wl_dst != NULL) {
|
|
||||||
if (wl_dst->window == wl_src->window)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
if (data->flags & CMD_KFLAG) {
|
|
||||||
/*
|
|
||||||
* Can't use session_detach as it will destroy session
|
|
||||||
* if this makes it empty.
|
|
||||||
*/
|
|
||||||
session_alert_cancel(dst, wl_dst);
|
|
||||||
winlink_stack_remove(&dst->lastw, wl_dst);
|
|
||||||
winlink_remove(&dst->windows, wl_dst);
|
|
||||||
|
|
||||||
/* Force select/redraw if current. */
|
|
||||||
if (wl_dst == dst->curw) {
|
|
||||||
data->flags &= ~CMD_DFLAG;
|
|
||||||
dst->curw = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_dst = session_attach(dst, wl_src->window, idx, &cause);
|
|
||||||
if (wl_dst == NULL) {
|
|
||||||
ctx->error(ctx, "create session failed: %s", cause);
|
|
||||||
xfree(cause);
|
xfree(cause);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->flags & CMD_DFLAG)
|
|
||||||
server_status_session(dst);
|
|
||||||
else {
|
|
||||||
session_select(dst, wl_dst->idx);
|
|
||||||
server_redraw_session(dst);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-buffers.c,v 1.7 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,62 +30,29 @@ int cmd_list_buffers_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_list_buffers_entry = {
|
const struct cmd_entry cmd_list_buffers_entry = {
|
||||||
"list-buffers", "lsb",
|
"list-buffers", "lsb",
|
||||||
CMD_TARGET_SESSION_USAGE,
|
"", 0, 0,
|
||||||
|
"",
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_list_buffers_exec,
|
cmd_list_buffers_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
cmd_list_buffers_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_buffers_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct session *s;
|
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
size_t size, in, out;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (s->sx > 35) { /* leave three for ... */
|
|
||||||
size = s->sx - 32;
|
|
||||||
tmp = xmalloc(size + 1);
|
|
||||||
} else {
|
|
||||||
size = 0;
|
|
||||||
tmp = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) {
|
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
|
||||||
if (tmp != NULL) {
|
tmp = paste_print(pb, 50);
|
||||||
in = out = 0;
|
ctx->print(ctx,
|
||||||
while (out < size && pb->data[in] != '\0') {
|
"%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp);
|
||||||
if (pb->data[in] > 31 && pb->data[in] != 127)
|
|
||||||
tmp[out++] = pb->data[in];
|
|
||||||
in++;
|
|
||||||
}
|
|
||||||
tmp[out] = '\0';
|
|
||||||
if (out == size) {
|
|
||||||
tmp[out - 1] = '.';
|
|
||||||
tmp[out - 2] = '.';
|
|
||||||
tmp[out - 3] = '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->print(ctx, "%d: %zu bytes: \"%s\"",
|
|
||||||
idx - 1, strlen(pb->data), tmp);
|
|
||||||
} else
|
|
||||||
ctx->print(ctx, "%d: %zu bytes", idx, strlen(pb->data));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tmp != NULL)
|
|
||||||
xfree(tmp);
|
xfree(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-clients.c,v 1.13 2009-02-11 17:50:32 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,30 +31,59 @@ int cmd_list_clients_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_list_clients_entry = {
|
const struct cmd_entry cmd_list_clients_entry = {
|
||||||
"list-clients", "lsc",
|
"list-clients", "lsc",
|
||||||
"",
|
"F:t:", 0, 0,
|
||||||
0,
|
"[-F format] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
CMD_READONLY,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_list_clients_exec,
|
cmd_list_clients_exec
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
cmd_list_clients_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct client *c;
|
struct args *args = self->args;
|
||||||
u_int i;
|
struct client *c;
|
||||||
|
struct session *s;
|
||||||
|
struct format_tree *ft;
|
||||||
|
const char *template;
|
||||||
|
u_int i;
|
||||||
|
char *line;
|
||||||
|
|
||||||
|
if (args_has(args, 't')) {
|
||||||
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
|
if (s == NULL)
|
||||||
|
return (-1);
|
||||||
|
} else
|
||||||
|
s = NULL;
|
||||||
|
|
||||||
|
template = args_get(args, 'F');
|
||||||
|
if (template == NULL) {
|
||||||
|
template = "#{client_tty}: #{session_name} "
|
||||||
|
"[#{client_width}x#{client_height} #{client_termname}]"
|
||||||
|
"#{?client_utf8, (utf8),}"
|
||||||
|
"#{?client_readonly, (ro),}";
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
if (c == NULL || c->session == NULL)
|
if (c == NULL || c->session == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ctx->print(ctx, "%s: %s [%ux%u %s]", c->tty.path,
|
if (s != NULL && s != c->session)
|
||||||
c->session->name, c->tty.sx, c->tty.sy, c->tty.termname);
|
continue;
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
format_add(ft, "line", "%u", i);
|
||||||
|
format_session(ft, c->session);
|
||||||
|
format_client(ft, c);
|
||||||
|
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
ctx->print(ctx, "%s", line);
|
||||||
|
xfree(line);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-commands.c,v 1.3 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,17 +28,15 @@ int cmd_list_commands_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_list_commands_entry = {
|
const struct cmd_entry cmd_list_commands_entry = {
|
||||||
"list-commands", "lscm",
|
"list-commands", "lscm",
|
||||||
|
"", 0, 0,
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_list_commands_exec,
|
cmd_list_commands_exec
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
|
|||||||
120
cmd-list-keys.c
120
cmd-list-keys.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-keys.c,v 1.13 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -26,33 +28,121 @@
|
|||||||
|
|
||||||
int cmd_list_keys_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_list_keys_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
int cmd_list_keys_table(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_keys_entry = {
|
const struct cmd_entry cmd_list_keys_entry = {
|
||||||
"list-keys", "lsk",
|
"list-keys", "lsk",
|
||||||
"",
|
"t:", 0, 0,
|
||||||
|
"[-t key-table]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_list_keys_exec,
|
cmd_list_keys_exec
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_list_keys_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
const char *key;
|
const char *key;
|
||||||
char tmp[BUFSIZ];
|
char tmp[BUFSIZ], flags[8];
|
||||||
|
size_t used;
|
||||||
|
int width, keywidth;
|
||||||
|
|
||||||
SPLAY_FOREACH(bd, key_bindings, &key_bindings) {
|
if (args_has(args, 't'))
|
||||||
if ((key = key_string_lookup_key(bd->key)) == NULL)
|
return (cmd_list_keys_table(self, ctx));
|
||||||
|
|
||||||
|
width = 0;
|
||||||
|
|
||||||
|
RB_FOREACH(bd, key_bindings, &key_bindings) {
|
||||||
|
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
||||||
|
if (key == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
*tmp = '\0';
|
keywidth = strlen(key);
|
||||||
cmd_list_print(bd->cmdlist, tmp, sizeof tmp);
|
if (!(bd->key & KEYC_PREFIX)) {
|
||||||
ctx->print(ctx, "%11s: %s", key, tmp);
|
if (bd->can_repeat)
|
||||||
|
keywidth += 4;
|
||||||
|
else
|
||||||
|
keywidth += 3;
|
||||||
|
} else if (bd->can_repeat)
|
||||||
|
keywidth += 3;
|
||||||
|
if (keywidth > width)
|
||||||
|
width = keywidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
RB_FOREACH(bd, key_bindings, &key_bindings) {
|
||||||
|
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
||||||
|
if (key == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
*flags = '\0';
|
||||||
|
if (!(bd->key & KEYC_PREFIX)) {
|
||||||
|
if (bd->can_repeat)
|
||||||
|
xsnprintf(flags, sizeof flags, "-rn ");
|
||||||
|
else
|
||||||
|
xsnprintf(flags, sizeof flags, "-n ");
|
||||||
|
} else if (bd->can_repeat)
|
||||||
|
xsnprintf(flags, sizeof flags, "-r ");
|
||||||
|
|
||||||
|
used = xsnprintf(tmp, sizeof tmp, "%s%*s ",
|
||||||
|
flags, (int) (width - strlen(flags)), key);
|
||||||
|
if (used >= sizeof tmp)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
cmd_list_print(bd->cmdlist, tmp + used, (sizeof tmp) - used);
|
||||||
|
ctx->print(ctx, "bind-key %s", tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_list_keys_table(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
const char *tablename;
|
||||||
|
const struct mode_key_table *mtab;
|
||||||
|
struct mode_key_binding *mbind;
|
||||||
|
const char *key, *cmdstr, *mode;
|
||||||
|
int width, keywidth, any_mode;
|
||||||
|
|
||||||
|
tablename = args_get(args, 't');
|
||||||
|
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
||||||
|
ctx->error(ctx, "unknown key table: %s", tablename);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
width = 0;
|
||||||
|
any_mode = 0;
|
||||||
|
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
||||||
|
key = key_string_lookup_key(mbind->key);
|
||||||
|
if (key == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (mbind->mode != 0)
|
||||||
|
any_mode = 1;
|
||||||
|
|
||||||
|
keywidth = strlen(key);
|
||||||
|
if (keywidth > width)
|
||||||
|
width = keywidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
||||||
|
key = key_string_lookup_key(mbind->key);
|
||||||
|
if (key == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
mode = "";
|
||||||
|
if (mbind->mode != 0)
|
||||||
|
mode = "c";
|
||||||
|
cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd);
|
||||||
|
if (cmdstr != NULL) {
|
||||||
|
ctx->print(ctx, "bind-key -%st %s%s %*s %s",
|
||||||
|
mode, any_mode && *mode == '\0' ? " " : "",
|
||||||
|
mtab->name, (int) width, key, cmdstr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
143
cmd-list-panes.c
Normal file
143
cmd-list-panes.c
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List panes on given window.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_list_panes_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
void cmd_list_panes_server(struct cmd *, struct cmd_ctx *);
|
||||||
|
void cmd_list_panes_session(
|
||||||
|
struct cmd *, struct session *, struct cmd_ctx *, int);
|
||||||
|
void cmd_list_panes_window(struct cmd *,
|
||||||
|
struct session *, struct winlink *, struct cmd_ctx *, int);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_list_panes_entry = {
|
||||||
|
"list-panes", "lsp",
|
||||||
|
"asF:t:", 0, 0,
|
||||||
|
"[-as] [-F format] [-t target]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_list_panes_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct session *s;
|
||||||
|
struct winlink *wl;
|
||||||
|
|
||||||
|
if (args_has(args, 'a'))
|
||||||
|
cmd_list_panes_server(self, ctx);
|
||||||
|
else if (args_has(args, 's')) {
|
||||||
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
|
if (s == NULL)
|
||||||
|
return (-1);
|
||||||
|
cmd_list_panes_session(self, s, ctx, 1);
|
||||||
|
} else {
|
||||||
|
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
||||||
|
if (wl == NULL)
|
||||||
|
return (-1);
|
||||||
|
cmd_list_panes_window(self, s, wl, ctx, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_list_panes_server(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
|
RB_FOREACH(s, sessions, &sessions)
|
||||||
|
cmd_list_panes_session(self, s, ctx, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_list_panes_session(
|
||||||
|
struct cmd *self, struct session *s, struct cmd_ctx *ctx, int type)
|
||||||
|
{
|
||||||
|
struct winlink *wl;
|
||||||
|
|
||||||
|
RB_FOREACH(wl, winlinks, &s->windows)
|
||||||
|
cmd_list_panes_window(self, s, wl, ctx, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_list_panes_window(struct cmd *self,
|
||||||
|
struct session *s, struct winlink *wl, struct cmd_ctx *ctx, int type)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct window_pane *wp;
|
||||||
|
u_int n;
|
||||||
|
struct format_tree *ft;
|
||||||
|
const char *template;
|
||||||
|
char *line;
|
||||||
|
|
||||||
|
template = args_get(args, 'F');
|
||||||
|
if (template == NULL) {
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
template = "#{pane_index}: "
|
||||||
|
"[#{pane_width}x#{pane_height}] [history "
|
||||||
|
"#{history_size}/#{history_limit}, "
|
||||||
|
"#{history_bytes} bytes] #{pane_id}"
|
||||||
|
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
template = "#{window_index}.#{pane_index}: "
|
||||||
|
"[#{pane_width}x#{pane_height}] [history "
|
||||||
|
"#{history_size}/#{history_limit}, "
|
||||||
|
"#{history_bytes} bytes] #{pane_id}"
|
||||||
|
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
template = "#{session_name}:#{window_index}.#{pane_index}: "
|
||||||
|
"[#{pane_width}x#{pane_height}] [history "
|
||||||
|
"#{history_size}/#{history_limit}, "
|
||||||
|
"#{history_bytes} bytes] #{pane_id}"
|
||||||
|
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||||
|
ft = format_create();
|
||||||
|
format_add(ft, "line", "%u", n);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, wp);
|
||||||
|
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
ctx->print(ctx, "%s", line);
|
||||||
|
xfree(line);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-sessions.c,v 1.19 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,37 +30,46 @@
|
|||||||
int cmd_list_sessions_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_list_sessions_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_sessions_entry = {
|
const struct cmd_entry cmd_list_sessions_entry = {
|
||||||
"list-sessions", "ls", "",
|
"list-sessions", "ls",
|
||||||
|
"F:", 0, 0,
|
||||||
|
"[-F format]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_list_sessions_exec,
|
cmd_list_sessions_exec
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_list_sessions_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_sessions_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct session *s;
|
struct args *args = self->args;
|
||||||
char *tim;
|
struct session *s;
|
||||||
u_int i;
|
u_int n;
|
||||||
time_t t;
|
struct format_tree *ft;
|
||||||
|
const char *template;
|
||||||
|
char *line;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
|
template = args_get(args, 'F');
|
||||||
s = ARRAY_ITEM(&sessions, i);
|
if (template == NULL) {
|
||||||
if (s == NULL)
|
template = "#{session_name}: #{session_windows} windows "
|
||||||
continue;
|
"(created #{session_created_string}) [#{session_width}x"
|
||||||
|
"#{session_height}]#{?session_grouped, (group ,}"
|
||||||
|
"#{session_group}#{?session_grouped,),}"
|
||||||
|
"#{?session_attached, (attached),}";
|
||||||
|
}
|
||||||
|
|
||||||
t = s->tv.tv_sec;
|
n = 0;
|
||||||
tim = ctime(&t);
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
*strchr(tim, '\n') = '\0';
|
ft = format_create();
|
||||||
|
format_add(ft, "line", "%u", n);
|
||||||
|
format_session(ft, s);
|
||||||
|
|
||||||
ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]%s",
|
line = format_expand(ft, template);
|
||||||
s->name, winlink_count(&s->windows), tim, s->sx, s->sy,
|
ctx->print(ctx, "%s", line);
|
||||||
s->flags & SESSION_UNATTACHED ? "" : " (attached)");
|
xfree(line);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-windows.c,v 1.33 2009-03-28 20:17:29 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,60 +28,90 @@
|
|||||||
|
|
||||||
int cmd_list_windows_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_list_windows_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
void cmd_list_windows_server(struct cmd *, struct cmd_ctx *);
|
||||||
|
void cmd_list_windows_session(
|
||||||
|
struct cmd *, struct session *, struct cmd_ctx *, int);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_windows_entry = {
|
const struct cmd_entry cmd_list_windows_entry = {
|
||||||
"list-windows", "lsw",
|
"list-windows", "lsw",
|
||||||
CMD_TARGET_SESSION_USAGE,
|
"aF:t:", 0, 0,
|
||||||
|
"[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_list_windows_exec,
|
cmd_list_windows_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
|
||||||
struct window *w;
|
|
||||||
struct window_pane *wp;
|
|
||||||
struct grid *gd;
|
|
||||||
u_int i;
|
|
||||||
unsigned long long size;
|
|
||||||
const char *name;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if (args_has(args, 'a'))
|
||||||
return (-1);
|
cmd_list_windows_server(self, ctx);
|
||||||
|
else {
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
w = wl->window;
|
if (s == NULL)
|
||||||
ctx->print(ctx,
|
return (-1);
|
||||||
"%3d: %s [%ux%u]", wl->idx, w->name, w->sx, w->sy);
|
cmd_list_windows_session(self, s, ctx, 0);
|
||||||
|
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
|
||||||
gd = wp->base.grid;
|
|
||||||
|
|
||||||
size = 0;
|
|
||||||
for (i = 0; i < gd->hsize; i++) {
|
|
||||||
size += gd->size[i] * sizeof **gd->data;
|
|
||||||
size += gd->usize[i] * sizeof **gd->udata;
|
|
||||||
}
|
|
||||||
size += gd->hsize * (sizeof *gd->data);
|
|
||||||
size += gd->hsize * (sizeof *gd->size);
|
|
||||||
|
|
||||||
if (wp->fd != -1)
|
|
||||||
name = ttyname(wp->fd);
|
|
||||||
else
|
|
||||||
name = "unknown";
|
|
||||||
ctx->print(ctx,
|
|
||||||
" %s [%ux%u] [history %u/%u, %llu bytes]",
|
|
||||||
name, wp->sx, wp->sy, gd->hsize, gd->hlimit, size);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_list_windows_server(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
|
RB_FOREACH(s, sessions, &sessions)
|
||||||
|
cmd_list_windows_session(self, s, ctx, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_list_windows_session(
|
||||||
|
struct cmd *self, struct session *s, struct cmd_ctx *ctx, int type)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct winlink *wl;
|
||||||
|
u_int n;
|
||||||
|
struct format_tree *ft;
|
||||||
|
const char *template;
|
||||||
|
char *line;
|
||||||
|
|
||||||
|
template = args_get(args, 'F');
|
||||||
|
if (template == NULL) {
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
template = "#{window_index}: "
|
||||||
|
"#{window_name} "
|
||||||
|
"[#{window_width}x#{window_height}] "
|
||||||
|
"[layout #{window_layout}]"
|
||||||
|
"#{?window_active, (active),}";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
template = "#{session_name}:#{window_index}: "
|
||||||
|
"#{window_name} "
|
||||||
|
"[#{window_width}x#{window_height}] "
|
||||||
|
"[layout #{window_layout}]"
|
||||||
|
"#{?window_active, (active),}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
|
ft = format_create();
|
||||||
|
format_add(ft, "line", "%u", n);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
ctx->print(ctx, "%s", line);
|
||||||
|
xfree(line);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
133
cmd-list.c
133
cmd-list.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list.c,v 1.3 2009-02-16 18:57:16 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,33 +28,53 @@ cmd_list_parse(int argc, char **argv, char **cause)
|
|||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
int i, lastsplit;
|
int i, lastsplit;
|
||||||
|
size_t arglen, new_argc;
|
||||||
|
char **copy_argv, **new_argv;
|
||||||
|
|
||||||
|
copy_argv = cmd_copy_argv(argc, argv);
|
||||||
|
|
||||||
cmdlist = xmalloc(sizeof *cmdlist);
|
cmdlist = xmalloc(sizeof *cmdlist);
|
||||||
TAILQ_INIT(cmdlist);
|
cmdlist->references = 1;
|
||||||
|
TAILQ_INIT(&cmdlist->list);
|
||||||
|
|
||||||
lastsplit = 0;
|
lastsplit = 0;
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
if (strcmp(argv[i], "\\;") == 0) {
|
arglen = strlen(copy_argv[i]);
|
||||||
argv[i][0] = ';';
|
if (arglen == 0 || copy_argv[i][arglen - 1] != ';')
|
||||||
argv[i][1] = '\0';
|
continue;
|
||||||
} else if (strcmp(argv[i], ";") == 0) {
|
copy_argv[i][arglen - 1] = '\0';
|
||||||
cmd = cmd_parse(i - lastsplit, argv + lastsplit, cause);
|
|
||||||
if (cmd == NULL)
|
if (arglen > 1 && copy_argv[i][arglen - 2] == '\\') {
|
||||||
goto bad;
|
copy_argv[i][arglen - 2] = ';';
|
||||||
TAILQ_INSERT_TAIL(cmdlist, cmd, qentry);
|
continue;
|
||||||
lastsplit = i + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_argc = i - lastsplit;
|
||||||
|
new_argv = copy_argv + lastsplit;
|
||||||
|
if (arglen != 1)
|
||||||
|
new_argc++;
|
||||||
|
|
||||||
|
cmd = cmd_parse(new_argc, new_argv, cause);
|
||||||
|
if (cmd == NULL)
|
||||||
|
goto bad;
|
||||||
|
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
||||||
|
|
||||||
|
lastsplit = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = cmd_parse(argc - lastsplit, argv + lastsplit, cause);
|
if (lastsplit != argc) {
|
||||||
if (cmd == NULL)
|
cmd = cmd_parse(argc - lastsplit, copy_argv + lastsplit, cause);
|
||||||
goto bad;
|
if (cmd == NULL)
|
||||||
TAILQ_INSERT_TAIL(cmdlist, cmd, qentry);
|
goto bad;
|
||||||
|
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_free_argv(argc, copy_argv);
|
||||||
return (cmdlist);
|
return (cmdlist);
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
|
cmd_free_argv(argc, copy_argv);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,58 +82,49 @@ int
|
|||||||
cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
|
cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
int n;
|
int n, retval;
|
||||||
|
|
||||||
TAILQ_FOREACH(cmd, cmdlist, qentry) {
|
retval = 0;
|
||||||
if ((n = cmd_exec(cmd, ctx)) != 0)
|
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||||
return (n);
|
if ((n = cmd_exec(cmd, ctx)) == -1)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A 1 return value means the command client is being attached
|
||||||
|
* (sent MSG_READY).
|
||||||
|
*/
|
||||||
|
if (n == 1) {
|
||||||
|
retval = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The command client has been attached, so mangle the
|
||||||
|
* context to treat any following commands as if they
|
||||||
|
* were called from inside.
|
||||||
|
*/
|
||||||
|
if (ctx->curclient == NULL) {
|
||||||
|
ctx->curclient = ctx->cmdclient;
|
||||||
|
ctx->cmdclient = NULL;
|
||||||
|
|
||||||
|
ctx->error = key_bindings_error;
|
||||||
|
ctx->print = key_bindings_print;
|
||||||
|
ctx->info = key_bindings_info;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (0);
|
return (retval);
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_list_send(struct cmd_list *cmdlist, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd *cmd;
|
|
||||||
u_int n;
|
|
||||||
|
|
||||||
n = 0;
|
|
||||||
TAILQ_FOREACH(cmd, cmdlist, qentry)
|
|
||||||
n++;
|
|
||||||
|
|
||||||
buffer_write(b, &n, sizeof n);
|
|
||||||
TAILQ_FOREACH(cmd, cmdlist, qentry)
|
|
||||||
cmd_send(cmd, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct cmd_list *
|
|
||||||
cmd_list_recv(struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmd *cmd;
|
|
||||||
u_int n;
|
|
||||||
|
|
||||||
buffer_read(b, &n, sizeof n);
|
|
||||||
|
|
||||||
cmdlist = xmalloc(sizeof *cmdlist);
|
|
||||||
TAILQ_INIT(cmdlist);
|
|
||||||
|
|
||||||
while (n-- > 0) {
|
|
||||||
cmd = cmd_recv(b);
|
|
||||||
TAILQ_INSERT_TAIL(cmdlist, cmd, qentry);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (cmdlist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_list_free(struct cmd_list *cmdlist)
|
cmd_list_free(struct cmd_list *cmdlist)
|
||||||
{
|
{
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
|
|
||||||
while (!TAILQ_EMPTY(cmdlist)) {
|
if (--cmdlist->references != 0)
|
||||||
cmd = TAILQ_FIRST(cmdlist);
|
return;
|
||||||
TAILQ_REMOVE(cmdlist, cmd, qentry);
|
|
||||||
|
while (!TAILQ_EMPTY(&cmdlist->list)) {
|
||||||
|
cmd = TAILQ_FIRST(&cmdlist->list);
|
||||||
|
TAILQ_REMOVE(&cmdlist->list, cmd, qentry);
|
||||||
cmd_free(cmd);
|
cmd_free(cmd);
|
||||||
}
|
}
|
||||||
xfree(cmdlist);
|
xfree(cmdlist);
|
||||||
@@ -126,7 +137,7 @@ cmd_list_print(struct cmd_list *cmdlist, char *buf, size_t len)
|
|||||||
size_t off;
|
size_t off;
|
||||||
|
|
||||||
off = 0;
|
off = 0;
|
||||||
TAILQ_FOREACH(cmd, cmdlist, qentry) {
|
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||||
if (off >= len)
|
if (off >= len)
|
||||||
break;
|
break;
|
||||||
off += cmd_print(cmd, buf + off, len - off);
|
off += cmd_print(cmd, buf + off, len - off);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-load-buffer.c,v 1.2 2009-01-27 23:26:15 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -27,76 +27,163 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loads a session paste buffer from a file.
|
* Loads a paste buffer from a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_load_buffer_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_load_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
void cmd_load_buffer_callback(struct client *, void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_load_buffer_entry = {
|
const struct cmd_entry cmd_load_buffer_entry = {
|
||||||
"load-buffer", "loadb",
|
"load-buffer", "loadb",
|
||||||
CMD_BUFFER_SESSION_USAGE " path",
|
"b:", 1, 1,
|
||||||
CMD_ARG1,
|
CMD_BUFFER_USAGE " path",
|
||||||
cmd_buffer_init,
|
0,
|
||||||
cmd_buffer_parse,
|
NULL,
|
||||||
cmd_load_buffer_exec,
|
NULL,
|
||||||
cmd_buffer_send,
|
cmd_load_buffer_exec
|
||||||
cmd_buffer_recv,
|
|
||||||
cmd_buffer_free,
|
|
||||||
cmd_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct client *c = ctx->cmdclient;
|
||||||
struct stat statbuf;
|
struct session *s;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *buf;
|
const char *path, *newpath, *wd;
|
||||||
u_int limit;
|
char *pdata, *new_pdata, *cause;
|
||||||
|
size_t psize;
|
||||||
|
u_int limit;
|
||||||
|
int ch, buffer;
|
||||||
|
int *buffer_ptr;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if (!args_has(args, 'b'))
|
||||||
return (-1);
|
buffer = -1;
|
||||||
|
else {
|
||||||
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (stat(data->arg, &statbuf) < 0) {
|
path = args->argv[0];
|
||||||
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
|
if (strcmp(path, "-") == 0) {
|
||||||
|
if (c == NULL) {
|
||||||
|
ctx->error(ctx, "%s: can't read from stdin", path);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (c->flags & CLIENT_TERMINAL) {
|
||||||
|
ctx->error(ctx, "%s: stdin is a tty", path);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (c->stdin_fd == -1) {
|
||||||
|
ctx->error(ctx, "%s: can't read from stdin", path);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer_ptr = xmalloc(sizeof *buffer_ptr);
|
||||||
|
*buffer_ptr = buffer;
|
||||||
|
|
||||||
|
c->stdin_data = buffer_ptr;
|
||||||
|
c->stdin_callback = cmd_load_buffer_callback;
|
||||||
|
|
||||||
|
c->references++;
|
||||||
|
bufferevent_enable(c->stdin_event, EV_READ);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c != NULL)
|
||||||
|
wd = c->cwd;
|
||||||
|
else if ((s = cmd_current_session(ctx, 0)) != NULL) {
|
||||||
|
wd = options_get_string(&s->options, "default-path");
|
||||||
|
if (*wd == '\0')
|
||||||
|
wd = s->cwd;
|
||||||
|
} else
|
||||||
|
wd = NULL;
|
||||||
|
if (wd != NULL && *wd != '\0') {
|
||||||
|
newpath = get_full_path(wd, path);
|
||||||
|
if (newpath != NULL)
|
||||||
|
path = newpath;
|
||||||
|
}
|
||||||
|
if ((f = fopen(path, "rb")) == NULL) {
|
||||||
|
ctx->error(ctx, "%s: %s", path, strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((f = fopen(data->arg, "r")) == NULL) {
|
pdata = NULL;
|
||||||
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
|
psize = 0;
|
||||||
return (-1);
|
while ((ch = getc(f)) != EOF) {
|
||||||
|
/* Do not let the server die due to memory exhaustion. */
|
||||||
|
if ((new_pdata = realloc(pdata, psize + 2)) == NULL) {
|
||||||
|
ctx->error(ctx, "realloc error: %s", strerror(errno));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
pdata = new_pdata;
|
||||||
|
pdata[psize++] = ch;
|
||||||
}
|
}
|
||||||
|
if (ferror(f)) {
|
||||||
/*
|
ctx->error(ctx, "%s: read error", path);
|
||||||
* We don't want to die due to memory exhaustion, hence xmalloc can't
|
goto error;
|
||||||
* be used here.
|
|
||||||
*/
|
|
||||||
if ((buf = malloc(statbuf.st_size + 1)) == NULL) {
|
|
||||||
ctx->error(ctx, "malloc error: %s", strerror(errno));
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
if (pdata != NULL)
|
||||||
|
pdata[psize] = '\0';
|
||||||
|
|
||||||
if (fread(buf, 1, statbuf.st_size, f) != (size_t) statbuf.st_size) {
|
|
||||||
ctx->error(ctx, "%s: fread error", data->arg);
|
|
||||||
xfree(buf);
|
|
||||||
fclose(f);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
buf[statbuf.st_size] = '\0';
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
limit = options_get_number(&s->options, "buffer-limit");
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
if (data->buffer == -1) {
|
if (buffer == -1) {
|
||||||
paste_add(&s->buffers, buf, limit);
|
paste_add(&global_buffers, pdata, psize, limit);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (paste_replace(&s->buffers, data->buffer, buf) != 0) {
|
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
xfree(buf);
|
xfree(pdata);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (pdata != NULL)
|
||||||
|
xfree(pdata);
|
||||||
|
if (f != NULL)
|
||||||
|
fclose(f);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_load_buffer_callback(struct client *c, void *data)
|
||||||
|
{
|
||||||
|
int *buffer = data;
|
||||||
|
char *pdata;
|
||||||
|
size_t psize;
|
||||||
|
u_int limit;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Event callback has already checked client is not dead and reduced
|
||||||
|
* its reference count. But tell it to exit.
|
||||||
|
*/
|
||||||
|
c->flags |= CLIENT_EXIT;
|
||||||
|
|
||||||
|
psize = EVBUFFER_LENGTH(c->stdin_event->input);
|
||||||
|
if (psize == 0 || (pdata = malloc(psize + 1)) == NULL) {
|
||||||
|
xfree(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bufferevent_read(c->stdin_event, pdata, psize);
|
||||||
|
pdata[psize] = '\0';
|
||||||
|
|
||||||
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
|
if (*buffer == -1)
|
||||||
|
paste_add(&global_buffers, pdata, psize, limit);
|
||||||
|
else if (paste_replace(&global_buffers, *buffer, pdata, psize) != 0) {
|
||||||
|
/* No context so can't use server_client_msg_error. */
|
||||||
|
evbuffer_add_printf(
|
||||||
|
c->stderr_event->output, "no buffer %d\n", *buffer);
|
||||||
|
bufferevent_enable(c->stderr_event, EV_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
xfree(data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-lock-server.c,v 1.2 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -25,30 +25,61 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock server.
|
* Lock commands.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_lock_server_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_lock_server_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
int cmd_lock_server_callback(void *, const char *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_lock_server_entry = {
|
const struct cmd_entry cmd_lock_server_entry = {
|
||||||
"lock-server", "lock",
|
"lock-server", "lock",
|
||||||
|
"", 0, 0,
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_lock_server_exec,
|
cmd_lock_server_exec
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_lock_session_entry = {
|
||||||
|
"lock-session", "locks",
|
||||||
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_SESSION_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_lock_server_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_lock_client_entry = {
|
||||||
|
"lock-client", "lockc",
|
||||||
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_lock_server_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
cmd_lock_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_lock_server_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
server_lock();
|
struct args *args = self->args;
|
||||||
|
struct client *c;
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
|
if (self->entry == &cmd_lock_server_entry)
|
||||||
|
server_lock();
|
||||||
|
else if (self->entry == &cmd_lock_session_entry) {
|
||||||
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
server_lock_session(s);
|
||||||
|
} else {
|
||||||
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
|
return (-1);
|
||||||
|
server_lock_client(c);
|
||||||
|
}
|
||||||
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-move-window.c,v 1.5 2009-01-23 16:59:14 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,93 +30,36 @@ int cmd_move_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_move_window_entry = {
|
const struct cmd_entry cmd_move_window_entry = {
|
||||||
"move-window", "movew",
|
"move-window", "movew",
|
||||||
|
"dks:t:", 0, 0,
|
||||||
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
CMD_DFLAG|CMD_KFLAG,
|
0,
|
||||||
cmd_srcdst_init,
|
NULL,
|
||||||
cmd_srcdst_parse,
|
NULL,
|
||||||
cmd_move_window_exec,
|
cmd_move_window_exec
|
||||||
cmd_srcdst_send,
|
|
||||||
cmd_srcdst_recv,
|
|
||||||
cmd_srcdst_free,
|
|
||||||
cmd_srcdst_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_srcdst_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *src, *dst;
|
struct session *src, *dst;
|
||||||
struct winlink *wl_src, *wl_dst;
|
struct winlink *wl;
|
||||||
struct client *c;
|
char *cause;
|
||||||
u_int i;
|
int idx, kflag, dflag;
|
||||||
int destroyed, idx;
|
|
||||||
char *cause;
|
|
||||||
|
|
||||||
if ((wl_src = cmd_find_window(ctx, data->src, &src)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 's'), &src)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &dst)) == -2)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (arg_parse_window(data->dst, &dst, &idx) != 0) {
|
kflag = args_has(self->args, 'k');
|
||||||
ctx->error(ctx, "bad window: %s", data->dst);
|
dflag = args_has(self->args, 'd');
|
||||||
return (-1);
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||||
}
|
ctx->error(ctx, "can't move window: %s", cause);
|
||||||
if (dst == NULL)
|
|
||||||
dst = ctx->cursession;
|
|
||||||
if (dst == NULL)
|
|
||||||
dst = cmd_current_session(ctx);
|
|
||||||
if (dst == NULL) {
|
|
||||||
ctx->error(ctx, "session not found: %s", data->dst);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_dst = NULL;
|
|
||||||
if (idx != -1)
|
|
||||||
wl_dst = winlink_find_by_index(&dst->windows, idx);
|
|
||||||
if (wl_dst != NULL) {
|
|
||||||
if (wl_dst->window == wl_src->window)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
if (data->flags & CMD_KFLAG) {
|
|
||||||
/*
|
|
||||||
* Can't use session_detach as it will destroy session
|
|
||||||
* if this makes it empty.
|
|
||||||
*/
|
|
||||||
session_alert_cancel(dst, wl_dst);
|
|
||||||
winlink_stack_remove(&dst->lastw, wl_dst);
|
|
||||||
winlink_remove(&dst->windows, wl_dst);
|
|
||||||
|
|
||||||
/* Force select/redraw if current. */
|
|
||||||
if (wl_dst == dst->curw) {
|
|
||||||
data->flags &= ~CMD_DFLAG;
|
|
||||||
dst->curw = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_dst = session_attach(dst, wl_src->window, idx, &cause);
|
|
||||||
if (wl_dst == NULL) {
|
|
||||||
ctx->error(ctx, "attach window failed: %s", cause);
|
|
||||||
xfree(cause);
|
xfree(cause);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
server_unlink_window(src, wl);
|
||||||
destroyed = session_detach(src, wl_src);
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
|
||||||
c = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c == NULL || c->session != src)
|
|
||||||
continue;
|
|
||||||
if (destroyed) {
|
|
||||||
c->session = NULL;
|
|
||||||
server_write_client(c, MSG_EXIT, NULL, 0);
|
|
||||||
} else
|
|
||||||
server_redraw_client(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->flags & CMD_DFLAG)
|
|
||||||
server_status_session(dst);
|
|
||||||
else {
|
|
||||||
session_select(dst, wl_dst->idx);
|
|
||||||
server_redraw_session(dst);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-new-session.c,v 1.40 2009-04-01 18:21:24 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,231 +18,262 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new session and attach to the current terminal unless -d is given.
|
* Create a new session and attach to the current terminal unless -d is given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_new_session_parse(struct cmd *, int, char **, char **);
|
int cmd_new_session_check(struct args *);
|
||||||
int cmd_new_session_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_new_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_new_session_send(struct cmd *, struct buffer *);
|
|
||||||
void cmd_new_session_recv(struct cmd *, struct buffer *);
|
|
||||||
void cmd_new_session_free(struct cmd *);
|
|
||||||
void cmd_new_session_init(struct cmd *, int);
|
|
||||||
size_t cmd_new_session_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_new_session_data {
|
|
||||||
char *newname;
|
|
||||||
char *winname;
|
|
||||||
char *cmd;
|
|
||||||
int flag_detached;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_new_session_entry = {
|
const struct cmd_entry cmd_new_session_entry = {
|
||||||
"new-session", "new",
|
"new-session", "new",
|
||||||
"[-d] [-n window-name] [-s session-name] [command]",
|
"dn:s:t:x:y:", 0, 1,
|
||||||
CMD_STARTSERVER|CMD_CANTNEST,
|
"[-d] [-n window-name] [-s session-name] [-t target-session] "
|
||||||
cmd_new_session_init,
|
"[-x width] [-y height] [command]",
|
||||||
cmd_new_session_parse,
|
CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON,
|
||||||
cmd_new_session_exec,
|
NULL,
|
||||||
cmd_new_session_send,
|
cmd_new_session_check,
|
||||||
cmd_new_session_recv,
|
cmd_new_session_exec
|
||||||
cmd_new_session_free,
|
|
||||||
cmd_new_session_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
|
||||||
cmd_new_session_init(struct cmd *self, unused int arg)
|
|
||||||
{
|
|
||||||
struct cmd_new_session_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->flag_detached = 0;
|
|
||||||
data->newname = NULL;
|
|
||||||
data->winname = NULL;
|
|
||||||
data->cmd = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_new_session_parse(struct cmd *self, int argc, char **argv, char **cause)
|
cmd_new_session_check(struct args *args)
|
||||||
{
|
{
|
||||||
struct cmd_new_session_data *data;
|
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n')))
|
||||||
int opt;
|
return (-1);
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "ds:n:")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'd':
|
|
||||||
data->flag_detached = 1;
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
if (data->newname == NULL)
|
|
||||||
data->newname = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
if (data->winname == NULL)
|
|
||||||
data->winname = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 0 && argc != 1)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
if (argc == 1)
|
|
||||||
data->cmd = xstrdup(argv[0]);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_new_session_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct client *c = ctx->cmdclient;
|
struct session *s, *old_s, *groupwith;
|
||||||
struct session *s;
|
struct window *w;
|
||||||
char *cmd, *cwd, *cause;
|
struct window_pane *wp;
|
||||||
u_int sx, sy;
|
struct environ env;
|
||||||
|
struct termios tio, *tiop;
|
||||||
|
struct passwd *pw;
|
||||||
|
const char *newname, *target, *update, *cwd, *errstr;
|
||||||
|
char *overrides, *cmd, *cause;
|
||||||
|
int detached, idx;
|
||||||
|
u_int sx, sy, i;
|
||||||
|
|
||||||
if (ctx->curclient != NULL)
|
newname = args_get(args, 's');
|
||||||
return (0);
|
if (newname != NULL) {
|
||||||
|
if (!session_check_name(newname)) {
|
||||||
if (!data->flag_detached) {
|
ctx->error(ctx, "bad session name: %s", newname);
|
||||||
if (c == NULL) {
|
|
||||||
ctx->error(ctx, "no client to attach to");
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (!(c->flags & CLIENT_TERMINAL)) {
|
if (session_find(newname) != NULL) {
|
||||||
|
ctx->error(ctx, "duplicate session: %s", newname);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
target = args_get(args, 't');
|
||||||
|
if (target != NULL) {
|
||||||
|
groupwith = cmd_find_session(ctx, target, 0);
|
||||||
|
if (groupwith == NULL)
|
||||||
|
return (-1);
|
||||||
|
} else
|
||||||
|
groupwith = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There are three cases:
|
||||||
|
*
|
||||||
|
* 1. If cmdclient is non-NULL, new-session has been called from the
|
||||||
|
* command-line - cmdclient is to become a new attached, interactive
|
||||||
|
* client. Unless -d is given, the terminal must be opened and then
|
||||||
|
* the client sent MSG_READY.
|
||||||
|
*
|
||||||
|
* 2. If cmdclient is NULL, new-session has been called from an
|
||||||
|
* existing client (such as a key binding).
|
||||||
|
*
|
||||||
|
* 3. Both are NULL, the command was in the configuration file. Treat
|
||||||
|
* this as if -d was given even if it was not.
|
||||||
|
*
|
||||||
|
* In all cases, a new additional session needs to be created and
|
||||||
|
* (unless -d) set as the current session for the client.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Set -d if no client. */
|
||||||
|
detached = args_has(args, 'd');
|
||||||
|
if (ctx->cmdclient == NULL && ctx->curclient == NULL)
|
||||||
|
detached = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Save the termios settings, part of which is used for new windows in
|
||||||
|
* this session.
|
||||||
|
*
|
||||||
|
* This is read again with tcgetattr() rather than using tty.tio as if
|
||||||
|
* detached, tty_open won't be called. Because of this, it must be done
|
||||||
|
* before opening the terminal as that calls tcsetattr() to prepare for
|
||||||
|
* tmux taking over.
|
||||||
|
*/
|
||||||
|
if (ctx->cmdclient != NULL && ctx->cmdclient->tty.fd != -1) {
|
||||||
|
if (tcgetattr(ctx->cmdclient->tty.fd, &tio) != 0)
|
||||||
|
fatal("tcgetattr failed");
|
||||||
|
tiop = &tio;
|
||||||
|
} else
|
||||||
|
tiop = NULL;
|
||||||
|
|
||||||
|
/* Open the terminal if necessary. */
|
||||||
|
if (!detached && ctx->cmdclient != NULL) {
|
||||||
|
if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
|
||||||
ctx->error(ctx, "not a terminal");
|
ctx->error(ctx, "not a terminal");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
overrides =
|
||||||
|
options_get_string(&global_s_options, "terminal-overrides");
|
||||||
|
if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
|
||||||
|
ctx->error(ctx, "open terminal failed: %s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->newname != NULL && session_find(data->newname) != NULL) {
|
/* Get the new session working directory. */
|
||||||
ctx->error(ctx, "duplicate session: %s", data->newname);
|
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||||
return (-1);
|
cwd = ctx->cmdclient->cwd;
|
||||||
}
|
else {
|
||||||
|
pw = getpwuid(getuid());
|
||||||
cmd = data->cmd;
|
if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
|
||||||
if (cmd == NULL)
|
cwd = pw->pw_dir;
|
||||||
cmd = options_get_string(&global_options, "default-command");
|
|
||||||
if (c == NULL || c->cwd == NULL)
|
|
||||||
cwd = options_get_string(&global_options, "default-path");
|
|
||||||
else
|
|
||||||
cwd = c->cwd;
|
|
||||||
|
|
||||||
sx = 80;
|
|
||||||
sy = 25;
|
|
||||||
if (!data->flag_detached) {
|
|
||||||
sx = c->tty.sx;
|
|
||||||
sy = c->tty.sy;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options_get_number(&global_options, "status")) {
|
|
||||||
if (sy == 0)
|
|
||||||
sy = 1;
|
|
||||||
else
|
else
|
||||||
sy--;
|
cwd = "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data->flag_detached && tty_open(&c->tty, &cause) != 0) {
|
/* Find new session size. */
|
||||||
ctx->error(ctx, "open terminal failed: %s", cause);
|
if (ctx->cmdclient != NULL) {
|
||||||
xfree(cause);
|
sx = ctx->cmdclient->tty.sx;
|
||||||
return (-1);
|
sy = ctx->cmdclient->tty.sy;
|
||||||
|
} else if (ctx->curclient != NULL) {
|
||||||
|
sx = ctx->curclient->tty.sx;
|
||||||
|
sy = ctx->curclient->tty.sy;
|
||||||
|
} else {
|
||||||
|
sx = 80;
|
||||||
|
sy = 24;
|
||||||
}
|
}
|
||||||
|
if (detached) {
|
||||||
|
if (args_has(args, 'x')) {
|
||||||
|
sx = strtonum(
|
||||||
|
args_get(args, 'x'), 1, USHRT_MAX, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
ctx->error(ctx, "width %s", errstr);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args_has(args, 'y')) {
|
||||||
|
sy = strtonum(
|
||||||
|
args_get(args, 'y'), 1, USHRT_MAX, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
ctx->error(ctx, "height %s", errstr);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sy > 0 && options_get_number(&global_s_options, "status"))
|
||||||
|
sy--;
|
||||||
|
if (sx == 0)
|
||||||
|
sx = 1;
|
||||||
|
if (sy == 0)
|
||||||
|
sy = 1;
|
||||||
|
|
||||||
|
/* Figure out the command for the new window. */
|
||||||
|
if (target != NULL)
|
||||||
|
cmd = NULL;
|
||||||
|
else if (args->argc != 0)
|
||||||
|
cmd = args->argv[0];
|
||||||
|
else
|
||||||
|
cmd = options_get_string(&global_s_options, "default-command");
|
||||||
|
|
||||||
s = session_create(data->newname, cmd, cwd, sx, sy, &cause);
|
/* Construct the environment. */
|
||||||
|
environ_init(&env);
|
||||||
|
update = options_get_string(&global_s_options, "update-environment");
|
||||||
|
if (ctx->cmdclient != NULL)
|
||||||
|
environ_update(update, &ctx->cmdclient->environ, &env);
|
||||||
|
|
||||||
|
/* Create the new session. */
|
||||||
|
idx = -1 - options_get_number(&global_s_options, "base-index");
|
||||||
|
s = session_create(newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause);
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
ctx->error(ctx, "create session failed: %s", cause);
|
ctx->error(ctx, "create session failed: %s", cause);
|
||||||
xfree(cause);
|
xfree(cause);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (data->winname != NULL) {
|
environ_free(&env);
|
||||||
xfree(s->curw->window->name);
|
|
||||||
s->curw->window->name = xstrdup(data->winname);
|
/* Set the initial window name if one given. */
|
||||||
options_set_number(
|
if (cmd != NULL && args_has(args, 'n')) {
|
||||||
&s->curw->window->options, "automatic-rename", 0);
|
w = s->curw->window;
|
||||||
|
|
||||||
|
xfree(w->name);
|
||||||
|
w->name = xstrdup(args_get(args, 'n'));
|
||||||
|
|
||||||
|
options_set_number(&w->options, "automatic-rename", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->flag_detached) {
|
/*
|
||||||
if (c != NULL)
|
* If a target session is given, this is to be part of a session group,
|
||||||
server_write_client(c, MSG_EXIT, NULL, 0);
|
* so add it to the group and synchronize.
|
||||||
} else {
|
*/
|
||||||
c->session = s;
|
if (groupwith != NULL) {
|
||||||
server_write_client(c, MSG_READY, NULL, 0);
|
session_group_add(groupwith, s);
|
||||||
server_redraw_client(c);
|
session_group_synchronize_to(s);
|
||||||
|
session_select(s, RB_ROOT(&s->windows)->idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the client to the new session. If a command client exists, it is
|
||||||
|
* taking this session and needs to get MSG_READY and stay around.
|
||||||
|
*/
|
||||||
|
if (!detached) {
|
||||||
|
if (ctx->cmdclient != NULL) {
|
||||||
|
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
||||||
|
|
||||||
|
old_s = ctx->cmdclient->session;
|
||||||
|
if (old_s != NULL)
|
||||||
|
ctx->cmdclient->last_session = old_s;
|
||||||
|
ctx->cmdclient->session = s;
|
||||||
|
session_update_activity(s);
|
||||||
|
server_redraw_client(ctx->cmdclient);
|
||||||
|
} else {
|
||||||
|
old_s = ctx->curclient->session;
|
||||||
|
if (old_s != NULL)
|
||||||
|
ctx->curclient->last_session = old_s;
|
||||||
|
ctx->curclient->session = s;
|
||||||
|
session_update_activity(s);
|
||||||
|
server_redraw_client(ctx->curclient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
server_update_socket();
|
||||||
|
|
||||||
return (1);
|
/*
|
||||||
}
|
* If there are still configuration file errors to display, put the new
|
||||||
|
* session's current window into more mode and display them now.
|
||||||
void
|
*/
|
||||||
cmd_new_session_send(struct cmd *self, struct buffer *b)
|
if (cfg_finished && !ARRAY_EMPTY(&cfg_causes)) {
|
||||||
{
|
wp = s->curw->window->active;
|
||||||
struct cmd_new_session_data *data = self->data;
|
window_pane_set_mode(wp, &window_copy_mode);
|
||||||
|
window_copy_init_for_output(wp);
|
||||||
buffer_write(b, data, sizeof *data);
|
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
|
||||||
cmd_send_string(b, data->newname);
|
cause = ARRAY_ITEM(&cfg_causes, i);
|
||||||
cmd_send_string(b, data->winname);
|
window_copy_add(wp, "%s", cause);
|
||||||
cmd_send_string(b, data->cmd);
|
xfree(cause);
|
||||||
}
|
}
|
||||||
|
ARRAY_FREE(&cfg_causes);
|
||||||
void
|
}
|
||||||
cmd_new_session_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
return (!detached); /* 1 means don't tell command client to exit */
|
||||||
struct cmd_new_session_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->newname = cmd_recv_string(b);
|
|
||||||
data->winname = cmd_recv_string(b);
|
|
||||||
data->cmd = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_new_session_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_new_session_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->newname != NULL)
|
|
||||||
xfree(data->newname);
|
|
||||||
if (data->winname != NULL)
|
|
||||||
xfree(data->winname);
|
|
||||||
if (data->cmd != NULL)
|
|
||||||
xfree(data->cmd);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_new_session_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_new_session_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->flag_detached)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -d");
|
|
||||||
if (off < len && data->newname != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -s ", data->newname);
|
|
||||||
if (off < len && data->winname != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -n ", data->winname);
|
|
||||||
if (off < len && data->cmd != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->cmd);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
240
cmd-new-window.c
240
cmd-new-window.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-new-window.c,v 1.31 2009-01-23 16:59:14 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,216 +26,96 @@
|
|||||||
* Create a new window.
|
* Create a new window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_new_window_parse(struct cmd *, int, char **, char **);
|
|
||||||
int cmd_new_window_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_new_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_new_window_send(struct cmd *, struct buffer *);
|
|
||||||
void cmd_new_window_recv(struct cmd *, struct buffer *);
|
|
||||||
void cmd_new_window_free(struct cmd *);
|
|
||||||
void cmd_new_window_init(struct cmd *, int);
|
|
||||||
size_t cmd_new_window_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_new_window_data {
|
|
||||||
char *target;
|
|
||||||
char *name;
|
|
||||||
char *cmd;
|
|
||||||
int flag_detached;
|
|
||||||
int flag_kill;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_new_window_entry = {
|
const struct cmd_entry cmd_new_window_entry = {
|
||||||
"new-window", "neww",
|
"new-window", "neww",
|
||||||
"[-dk] [-n window-name] [-t target-window] [command]",
|
"adkn:Pt:", 0, 1,
|
||||||
|
"[-adk] [-n window-name] [-t target-window] [command]",
|
||||||
0,
|
0,
|
||||||
cmd_new_window_init,
|
NULL,
|
||||||
cmd_new_window_parse,
|
NULL,
|
||||||
cmd_new_window_exec,
|
cmd_new_window_exec
|
||||||
cmd_new_window_send,
|
|
||||||
cmd_new_window_recv,
|
|
||||||
cmd_new_window_free,
|
|
||||||
cmd_new_window_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
|
||||||
cmd_new_window_init(struct cmd *self, unused int arg)
|
|
||||||
{
|
|
||||||
struct cmd_new_window_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->target = NULL;
|
|
||||||
data->name = NULL;
|
|
||||||
data->cmd = NULL;
|
|
||||||
data->flag_detached = 0;
|
|
||||||
data->flag_kill = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_new_window_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_new_window_data *data;
|
|
||||||
int opt;
|
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "dkt:n:")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'd':
|
|
||||||
data->flag_detached = 1;
|
|
||||||
break;
|
|
||||||
case 'k':
|
|
||||||
data->flag_kill = 1;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
if (data->name == NULL)
|
|
||||||
data->name = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 0 && argc != 1)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
if (argc == 1)
|
|
||||||
data->cmd = xstrdup(argv[0]);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_new_window_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
char *cmd, *cwd, *cause;
|
const char *cmd, *cwd;
|
||||||
int idx;
|
char *cause;
|
||||||
|
int idx, last, detached;
|
||||||
|
|
||||||
if (data == NULL)
|
if (args_has(args, 'a')) {
|
||||||
return (0);
|
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
||||||
|
if (wl == NULL)
|
||||||
|
return (-1);
|
||||||
|
idx = wl->idx + 1;
|
||||||
|
|
||||||
if (arg_parse_window(data->target, &s, &idx) != 0) {
|
/* Find the next free index. */
|
||||||
ctx->error(ctx, "bad window: %s", data->target);
|
for (last = idx; last < INT_MAX; last++) {
|
||||||
return (-1);
|
if (winlink_find_by_index(&s->windows, last) == NULL)
|
||||||
}
|
break;
|
||||||
if (s == NULL)
|
}
|
||||||
s = ctx->cursession;
|
if (last == INT_MAX) {
|
||||||
if (s == NULL)
|
ctx->error(ctx, "no free window indexes");
|
||||||
s = cmd_current_session(ctx);
|
return (-1);
|
||||||
if (s == NULL) {
|
}
|
||||||
ctx->error(ctx, "session not found: %s", data->target);
|
|
||||||
return (-1);
|
/* Move everything from last - 1 to idx up a bit. */
|
||||||
|
for (; last > idx; last--) {
|
||||||
|
wl = winlink_find_by_index(&s->windows, last - 1);
|
||||||
|
server_link_window(s, wl, s, last, 0, 0, NULL);
|
||||||
|
server_unlink_window(s, wl);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &s)) == -2)
|
||||||
|
return (-1);
|
||||||
}
|
}
|
||||||
|
detached = args_has(args, 'd');
|
||||||
|
|
||||||
wl = NULL;
|
wl = NULL;
|
||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
wl = winlink_find_by_index(&s->windows, idx);
|
wl = winlink_find_by_index(&s->windows, idx);
|
||||||
if (wl != NULL) {
|
if (wl != NULL && args_has(args, 'k')) {
|
||||||
if (data->flag_kill) {
|
/*
|
||||||
/*
|
* Can't use session_detach as it will destroy session if this
|
||||||
* Can't use session_detach as it will destroy session
|
* makes it empty.
|
||||||
* if this makes it empty.
|
*/
|
||||||
*/
|
wl->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
session_alert_cancel(s, wl);
|
winlink_stack_remove(&s->lastw, wl);
|
||||||
winlink_stack_remove(&s->lastw, wl);
|
winlink_remove(&s->windows, wl);
|
||||||
winlink_remove(&s->windows, wl);
|
|
||||||
|
|
||||||
/* Force select/redraw if current. */
|
/* Force select/redraw if current. */
|
||||||
if (wl == s->curw) {
|
if (wl == s->curw) {
|
||||||
data->flag_detached = 0;
|
detached = 0;
|
||||||
s->curw = NULL;
|
s->curw = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = data->cmd;
|
if (args->argc == 0)
|
||||||
if (cmd == NULL)
|
|
||||||
cmd = options_get_string(&s->options, "default-command");
|
cmd = options_get_string(&s->options, "default-command");
|
||||||
if (ctx->cmdclient == NULL || ctx->cmdclient->cwd == NULL)
|
|
||||||
cwd = options_get_string(&global_options, "default-path");
|
|
||||||
else
|
else
|
||||||
cwd = ctx->cmdclient->cwd;
|
cmd = args->argv[0];
|
||||||
|
cwd = cmd_get_default_path(ctx);
|
||||||
|
|
||||||
wl = session_new(s, data->name, cmd, cwd, idx, &cause);
|
if (idx == -1)
|
||||||
|
idx = -1 - options_get_number(&s->options, "base-index");
|
||||||
|
wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause);
|
||||||
if (wl == NULL) {
|
if (wl == NULL) {
|
||||||
ctx->error(ctx, "create window failed: %s", cause);
|
ctx->error(ctx, "create window failed: %s", cause);
|
||||||
xfree(cause);
|
xfree(cause);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (!data->flag_detached) {
|
if (!detached) {
|
||||||
session_select(s, wl->idx);
|
session_select(s, wl->idx);
|
||||||
server_redraw_session(s);
|
server_redraw_session_group(s);
|
||||||
} else
|
} else
|
||||||
server_status_session(s);
|
server_status_session_group(s);
|
||||||
|
|
||||||
|
if (args_has(args, 'P'))
|
||||||
|
ctx->print(ctx, "%s:%u", s->name, wl->idx);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
cmd_new_window_send(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_new_window_data *data = self->data;
|
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
|
||||||
cmd_send_string(b, data->target);
|
|
||||||
cmd_send_string(b, data->name);
|
|
||||||
cmd_send_string(b, data->cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_new_window_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_new_window_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->target = cmd_recv_string(b);
|
|
||||||
data->name = cmd_recv_string(b);
|
|
||||||
data->cmd = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_new_window_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_new_window_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
if (data->name != NULL)
|
|
||||||
xfree(data->name);
|
|
||||||
if (data->cmd != NULL)
|
|
||||||
xfree(data->cmd);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_new_window_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_new_window_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->flag_detached)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -d");
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->name != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -n ", data->name);
|
|
||||||
if (off < len && data->cmd != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->cmd);
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
/* $Id: cmd-next-window.c,v 1.16 2009-03-28 14:08:09 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Move to next window.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void cmd_next_window_init(struct cmd *, int);
|
|
||||||
int cmd_next_window_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_next_window_entry = {
|
|
||||||
"next-window", "next",
|
|
||||||
CMD_TARGET_SESSION_USAGE,
|
|
||||||
CMD_AFLAG,
|
|
||||||
cmd_next_window_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_next_window_exec,
|
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_next_window_init(struct cmd *self, int key)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data;
|
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
if (key == KEYC_ADDESC('n'))
|
|
||||||
data->flags |= CMD_AFLAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_next_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct session *s;
|
|
||||||
int activity;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
activity = 0;
|
|
||||||
if (data->flags & CMD_AFLAG)
|
|
||||||
activity = 1;
|
|
||||||
|
|
||||||
if (session_next(s, activity) == 0)
|
|
||||||
server_redraw_session(s);
|
|
||||||
else {
|
|
||||||
ctx->error(ctx, "no next window");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-paste-buffer.c,v 1.15 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -28,51 +29,93 @@
|
|||||||
|
|
||||||
int cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
void cmd_paste_buffer_filter(
|
||||||
|
struct window_pane *, const char *, size_t, const char *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_paste_buffer_entry = {
|
const struct cmd_entry cmd_paste_buffer_entry = {
|
||||||
"paste-buffer", "pasteb",
|
"paste-buffer", "pasteb",
|
||||||
"[-d] " CMD_BUFFER_WINDOW_USAGE,
|
"db:rs:t:", 0, 0,
|
||||||
CMD_DFLAG,
|
"[-dr] [-s separator] [-b buffer-index] [-t target-pane]",
|
||||||
cmd_buffer_init,
|
0,
|
||||||
cmd_buffer_parse,
|
NULL,
|
||||||
cmd_paste_buffer_exec,
|
NULL,
|
||||||
cmd_buffer_send,
|
cmd_paste_buffer_exec
|
||||||
cmd_buffer_recv,
|
|
||||||
cmd_buffer_free,
|
|
||||||
cmd_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct window_pane *wp;
|
||||||
struct window *w;
|
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
|
const char *sepstr;
|
||||||
|
char *cause;
|
||||||
|
int buffer;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
|
||||||
|
|
||||||
if (data->buffer == -1)
|
if (!args_has(args, 'b'))
|
||||||
pb = paste_get_top(&s->buffers);
|
buffer = -1;
|
||||||
else {
|
else {
|
||||||
if ((pb = paste_get_index(&s->buffers, data->buffer)) == NULL) {
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
if (cause != NULL) {
|
||||||
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
|
xfree(cause);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb != NULL)
|
if (buffer == -1)
|
||||||
buffer_write(w->active->out, pb->data, strlen(pb->data));
|
pb = paste_get_top(&global_buffers);
|
||||||
|
else {
|
||||||
/* Delete the buffer if -d. */
|
pb = paste_get_index(&global_buffers, buffer);
|
||||||
if (data->flags & CMD_DFLAG) {
|
if (pb == NULL) {
|
||||||
if (data->buffer == -1)
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
paste_free_top(&s->buffers);
|
return (-1);
|
||||||
else
|
}
|
||||||
paste_free_index(&s->buffers, data->buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
if (pb != NULL) {
|
||||||
|
sepstr = args_get(args, 's');
|
||||||
|
if (sepstr == NULL) {
|
||||||
|
if (args_has(args, 'r'))
|
||||||
|
sepstr = "\n";
|
||||||
|
else
|
||||||
|
sepstr = "\r";
|
||||||
|
}
|
||||||
|
cmd_paste_buffer_filter(wp, pb->data, pb->size, sepstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Delete the buffer if -d. */
|
||||||
|
if (args_has(args, 'd')) {
|
||||||
|
if (buffer == -1)
|
||||||
|
paste_free_top(&global_buffers);
|
||||||
|
else
|
||||||
|
paste_free_index(&global_buffers, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add bytes to a buffer and filter '\n' according to separator. */
|
||||||
|
void
|
||||||
|
cmd_paste_buffer_filter(
|
||||||
|
struct window_pane *wp, const char *data, size_t size, const char *sep)
|
||||||
|
{
|
||||||
|
const char *end = data + size;
|
||||||
|
const char *lf;
|
||||||
|
size_t seplen;
|
||||||
|
|
||||||
|
seplen = strlen(sep);
|
||||||
|
while ((lf = memchr(data, '\n', end - data)) != NULL) {
|
||||||
|
if (lf != data)
|
||||||
|
bufferevent_write(wp->event, data, lf - data);
|
||||||
|
bufferevent_write(wp->event, sep, seplen);
|
||||||
|
data = lf + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end != data)
|
||||||
|
bufferevent_write(wp->event, data, end - data);
|
||||||
}
|
}
|
||||||
|
|||||||
143
cmd-pipe-pane.c
Normal file
143
cmd-pipe-pane.c
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Open pipe to redirect pane output. If already open, close first.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_pipe_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_pipe_pane_entry = {
|
||||||
|
"pipe-pane", "pipep",
|
||||||
|
"ot:", 0, 1,
|
||||||
|
"[-o] " CMD_TARGET_PANE_USAGE " [command]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_pipe_pane_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct client *c;
|
||||||
|
struct window_pane *wp;
|
||||||
|
char *command;
|
||||||
|
int old_fd, pipe_fd[2], null_fd;
|
||||||
|
|
||||||
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
|
return (-1);
|
||||||
|
c = cmd_find_client(ctx, NULL);
|
||||||
|
|
||||||
|
/* Destroy the old pipe. */
|
||||||
|
old_fd = wp->pipe_fd;
|
||||||
|
if (wp->pipe_fd != -1) {
|
||||||
|
bufferevent_free(wp->pipe_event);
|
||||||
|
close(wp->pipe_fd);
|
||||||
|
wp->pipe_fd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If no pipe command, that is enough. */
|
||||||
|
if (args->argc == 0 || *args->argv[0] == '\0')
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* With -o, only open the new pipe if there was no previous one. This
|
||||||
|
* allows a pipe to be toggled with a single key, for example:
|
||||||
|
*
|
||||||
|
* bind ^p pipep -o 'cat >>~/output'
|
||||||
|
*/
|
||||||
|
if (args_has(self->args, 'o') && old_fd != -1)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
/* Open the new pipe. */
|
||||||
|
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_fd) != 0) {
|
||||||
|
ctx->error(ctx, "socketpair error: %s", strerror(errno));
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fork the child. */
|
||||||
|
switch (fork()) {
|
||||||
|
case -1:
|
||||||
|
ctx->error(ctx, "fork error: %s", strerror(errno));
|
||||||
|
return (-1);
|
||||||
|
case 0:
|
||||||
|
/* Child process. */
|
||||||
|
close(pipe_fd[0]);
|
||||||
|
clear_signals(1);
|
||||||
|
|
||||||
|
if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
|
||||||
|
_exit(1);
|
||||||
|
if (pipe_fd[1] != STDIN_FILENO)
|
||||||
|
close(pipe_fd[1]);
|
||||||
|
|
||||||
|
null_fd = open(_PATH_DEVNULL, O_WRONLY, 0);
|
||||||
|
if (dup2(null_fd, STDOUT_FILENO) == -1)
|
||||||
|
_exit(1);
|
||||||
|
if (dup2(null_fd, STDERR_FILENO) == -1)
|
||||||
|
_exit(1);
|
||||||
|
if (null_fd != STDOUT_FILENO && null_fd != STDERR_FILENO)
|
||||||
|
close(null_fd);
|
||||||
|
|
||||||
|
closefrom(STDERR_FILENO + 1);
|
||||||
|
|
||||||
|
command = status_replace(
|
||||||
|
c, NULL, NULL, NULL, args->argv[0], time(NULL), 0);
|
||||||
|
execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL);
|
||||||
|
_exit(1);
|
||||||
|
default:
|
||||||
|
/* Parent process. */
|
||||||
|
close(pipe_fd[1]);
|
||||||
|
|
||||||
|
wp->pipe_fd = pipe_fd[0];
|
||||||
|
wp->pipe_off = EVBUFFER_LENGTH(wp->event->input);
|
||||||
|
|
||||||
|
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);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
|
void
|
||||||
|
cmd_pipe_pane_error_callback(
|
||||||
|
unused struct bufferevent *bufev, unused short what, void *data)
|
||||||
|
{
|
||||||
|
struct window_pane *wp = data;
|
||||||
|
|
||||||
|
bufferevent_free(wp->pipe_event);
|
||||||
|
close(wp->pipe_fd);
|
||||||
|
wp->pipe_fd = -1;
|
||||||
|
}
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
/* $Id: cmd-previous-window.c,v 1.16 2009-03-28 14:08:09 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Move to previous window.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void cmd_previous_window_init(struct cmd *, int);
|
|
||||||
int cmd_previous_window_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_previous_window_entry = {
|
|
||||||
"previous-window", "prev",
|
|
||||||
CMD_TARGET_SESSION_USAGE,
|
|
||||||
CMD_AFLAG,
|
|
||||||
cmd_previous_window_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_previous_window_exec,
|
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_previous_window_init(struct cmd *self, int key)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data;
|
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
if (key == KEYC_ADDESC('p'))
|
|
||||||
data->flags |= CMD_AFLAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_previous_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct session *s;
|
|
||||||
int activity;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
activity = 0;
|
|
||||||
if (data->flags & CMD_AFLAG)
|
|
||||||
activity = 1;
|
|
||||||
|
|
||||||
if (session_previous(s, activity) == 0)
|
|
||||||
server_redraw_session(s);
|
|
||||||
else {
|
|
||||||
ctx->error(ctx, "no previous window");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-refresh-client.c,v 1.8 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,27 +28,28 @@ int cmd_refresh_client_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_refresh_client_entry = {
|
const struct cmd_entry cmd_refresh_client_entry = {
|
||||||
"refresh-client", "refresh",
|
"refresh-client", "refresh",
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
"St:", 0, 0,
|
||||||
|
"[-S] " CMD_TARGET_CLIENT_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_refresh_client_exec,
|
cmd_refresh_client_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_refresh_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_refresh_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
server_redraw_client(c);
|
if (args_has(args, 'S')) {
|
||||||
|
status_update_jobs(c);
|
||||||
|
server_status_client(c);
|
||||||
|
} else
|
||||||
|
server_redraw_client(c);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-rename-session.c,v 1.15 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,28 +30,40 @@ int cmd_rename_session_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_rename_session_entry = {
|
const struct cmd_entry cmd_rename_session_entry = {
|
||||||
"rename-session", "rename",
|
"rename-session", "rename",
|
||||||
|
"t:", 1, 1,
|
||||||
CMD_TARGET_SESSION_USAGE " new-name",
|
CMD_TARGET_SESSION_USAGE " new-name",
|
||||||
CMD_ARG1,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_rename_session_exec,
|
cmd_rename_session_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
const char *newname;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
newname = args->argv[0];
|
||||||
|
if (!session_check_name(newname)) {
|
||||||
|
ctx->error(ctx, "bad session name: %s", newname);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (session_find(newname) != NULL) {
|
||||||
|
ctx->error(ctx, "duplicate session: %s", newname);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
RB_REMOVE(sessions, &sessions, s);
|
||||||
xfree(s->name);
|
xfree(s->name);
|
||||||
s->name = xstrdup(data->arg);
|
s->name = xstrdup(newname);
|
||||||
|
RB_INSERT(sessions, &sessions, s);
|
||||||
|
|
||||||
|
server_status_session(s);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-rename-window.c,v 1.26 2009-01-20 19:35:03 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,32 +30,29 @@ int cmd_rename_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_rename_window_entry = {
|
const struct cmd_entry cmd_rename_window_entry = {
|
||||||
"rename-window", "renamew",
|
"rename-window", "renamew",
|
||||||
|
"t:", 1, 1,
|
||||||
CMD_TARGET_WINDOW_USAGE " new-name",
|
CMD_TARGET_WINDOW_USAGE " new-name",
|
||||||
CMD_ARG1,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_rename_window_exec,
|
cmd_rename_window_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
xfree(wl->window->name);
|
xfree(wl->window->name);
|
||||||
wl->window->name = xstrdup(data->arg);
|
wl->window->name = xstrdup(args->argv[0]);
|
||||||
options_set_number(&wl->window->options, "automatic-rename", 0);
|
options_set_number(&wl->window->options, "automatic-rename", 0);
|
||||||
|
|
||||||
server_status_session(s);
|
server_status_window(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
/* $Id: cmd-resize-pane-down.c,v 1.8 2009-04-02 21:11:52 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decrease pane size.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void cmd_resize_pane_down_init(struct cmd *, int);
|
|
||||||
int cmd_resize_pane_down_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_resize_pane_down_entry = {
|
|
||||||
"resize-pane-down", "resizep-down",
|
|
||||||
CMD_PANE_WINDOW_USAGE " [adjustment]",
|
|
||||||
CMD_ARG01,
|
|
||||||
cmd_resize_pane_down_init,
|
|
||||||
cmd_pane_parse,
|
|
||||||
cmd_resize_pane_down_exec,
|
|
||||||
cmd_pane_send,
|
|
||||||
cmd_pane_recv,
|
|
||||||
cmd_pane_free,
|
|
||||||
cmd_pane_print
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_resize_pane_down_init(struct cmd *self, int key)
|
|
||||||
{
|
|
||||||
struct cmd_pane_data *data;
|
|
||||||
|
|
||||||
cmd_pane_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
if (key == KEYC_ADDESC(KEYC_DOWN))
|
|
||||||
data->arg = xstrdup("5");
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_resize_pane_down_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_pane_data *data = self->data;
|
|
||||||
struct winlink *wl;
|
|
||||||
const char *errstr;
|
|
||||||
struct window_pane *wp, *wq;
|
|
||||||
u_int adjust;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
if (wl->window->layout != 0) {
|
|
||||||
ctx->error(ctx, "window not in manual layout");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (data->pane == -1)
|
|
||||||
wp = wl->window->active;
|
|
||||||
else {
|
|
||||||
wp = window_pane_at_index(wl->window, data->pane);
|
|
||||||
if (wp == NULL) {
|
|
||||||
ctx->error(ctx, "no pane: %d", data->pane);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->arg == NULL)
|
|
||||||
adjust = 1;
|
|
||||||
else {
|
|
||||||
adjust = strtonum(data->arg, 1, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
ctx->error(ctx, "adjustment %s: %s", errstr, data->arg);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this is not the last window, keep trying to increase size and
|
|
||||||
* remove it from the next windows. If it is the last, do so on the
|
|
||||||
* previous window.
|
|
||||||
*/
|
|
||||||
if (TAILQ_NEXT(wp, entry) == NULL) {
|
|
||||||
if (wp == TAILQ_FIRST(&wl->window->panes)) {
|
|
||||||
/* Only one pane. */
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
wp = TAILQ_PREV(wp, window_panes, entry);
|
|
||||||
}
|
|
||||||
while (adjust-- > 0) {
|
|
||||||
wq = wp;
|
|
||||||
while ((wq = TAILQ_NEXT(wq, entry)) != NULL) {
|
|
||||||
if (wq->sy > PANE_MINIMUM) {
|
|
||||||
window_pane_resize(wq, wq->sx, wq->sy - 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (wq == NULL)
|
|
||||||
break;
|
|
||||||
window_pane_resize(wp, wp->sx, wp->sy + 1);
|
|
||||||
|
|
||||||
}
|
|
||||||
window_update_panes(wl->window);
|
|
||||||
|
|
||||||
server_redraw_window(wl->window);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
/* $Id: cmd-resize-pane-up.c,v 1.8 2009-04-02 21:11:52 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Increase pane size.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void cmd_resize_pane_up_init(struct cmd *, int);
|
|
||||||
int cmd_resize_pane_up_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_resize_pane_up_entry = {
|
|
||||||
"resize-pane-up", "resizep-up",
|
|
||||||
CMD_PANE_WINDOW_USAGE " [adjustment]",
|
|
||||||
CMD_ARG01,
|
|
||||||
cmd_resize_pane_up_init,
|
|
||||||
cmd_pane_parse,
|
|
||||||
cmd_resize_pane_up_exec,
|
|
||||||
cmd_pane_send,
|
|
||||||
cmd_pane_recv,
|
|
||||||
cmd_pane_free,
|
|
||||||
cmd_pane_print
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_resize_pane_up_init(struct cmd *self, int key)
|
|
||||||
{
|
|
||||||
struct cmd_pane_data *data;
|
|
||||||
|
|
||||||
cmd_pane_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
if (key == KEYC_ADDESC(KEYC_UP))
|
|
||||||
data->arg = xstrdup("5");
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_resize_pane_up_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_pane_data *data = self->data;
|
|
||||||
struct winlink *wl;
|
|
||||||
const char *errstr;
|
|
||||||
struct window_pane *wp, *wq;
|
|
||||||
u_int adjust;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
if (wl->window->layout != 0) {
|
|
||||||
ctx->error(ctx, "window not in manual layout");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (data->pane == -1)
|
|
||||||
wp = wl->window->active;
|
|
||||||
else {
|
|
||||||
wp = window_pane_at_index(wl->window, data->pane);
|
|
||||||
if (wp == NULL) {
|
|
||||||
ctx->error(ctx, "no pane: %d", data->pane);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->arg == NULL)
|
|
||||||
adjust = 1;
|
|
||||||
else {
|
|
||||||
adjust = strtonum(data->arg, 1, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
ctx->error(ctx, "adjustment %s: %s", errstr, data->arg);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this is not the last window, keep trying to reduce size and add
|
|
||||||
* to the following window. If it is the last, do so on the previous
|
|
||||||
* window.
|
|
||||||
*/
|
|
||||||
wq = TAILQ_NEXT(wp, entry);
|
|
||||||
if (wq == NULL) {
|
|
||||||
if (wp == TAILQ_FIRST(&wl->window->panes)) {
|
|
||||||
/* Only one pane. */
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
wq = wp;
|
|
||||||
wp = TAILQ_PREV(wq, window_panes, entry);
|
|
||||||
}
|
|
||||||
while (adjust-- > 0) {
|
|
||||||
if (wp->sy <= PANE_MINIMUM)
|
|
||||||
break;
|
|
||||||
window_pane_resize(wq, wq->sx, wq->sy + 1);
|
|
||||||
window_pane_resize(wp, wp->sx, wp->sy - 1);
|
|
||||||
}
|
|
||||||
window_update_panes(wl->window);
|
|
||||||
|
|
||||||
server_redraw_window(wl->window);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
117
cmd-resize-pane.c
Normal file
117
cmd-resize-pane.c
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Increase or decrease pane size.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void cmd_resize_pane_key_binding(struct cmd *, int);
|
||||||
|
int cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_resize_pane_entry = {
|
||||||
|
"resize-pane", "resizep",
|
||||||
|
"DLRt:U", 0, 1,
|
||||||
|
"[-DLRU] " CMD_TARGET_PANE_USAGE " [adjustment]",
|
||||||
|
0,
|
||||||
|
cmd_resize_pane_key_binding,
|
||||||
|
NULL,
|
||||||
|
cmd_resize_pane_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_resize_pane_key_binding(struct cmd *self, int key)
|
||||||
|
{
|
||||||
|
switch (key) {
|
||||||
|
case KEYC_UP | KEYC_CTRL:
|
||||||
|
self->args = args_create(0);
|
||||||
|
args_set(self->args, 'U', NULL);
|
||||||
|
break;
|
||||||
|
case KEYC_DOWN | KEYC_CTRL:
|
||||||
|
self->args = args_create(0);
|
||||||
|
args_set(self->args, 'D', NULL);
|
||||||
|
break;
|
||||||
|
case KEYC_LEFT | KEYC_CTRL:
|
||||||
|
self->args = args_create(0);
|
||||||
|
args_set(self->args, 'L', NULL);
|
||||||
|
break;
|
||||||
|
case KEYC_RIGHT | KEYC_CTRL:
|
||||||
|
self->args = args_create(0);
|
||||||
|
args_set(self->args, 'R', NULL);
|
||||||
|
break;
|
||||||
|
case KEYC_UP | KEYC_ESCAPE:
|
||||||
|
self->args = args_create(1, "5");
|
||||||
|
args_set(self->args, 'U', NULL);
|
||||||
|
break;
|
||||||
|
case KEYC_DOWN | KEYC_ESCAPE:
|
||||||
|
self->args = args_create(1, "5");
|
||||||
|
args_set(self->args, 'D', NULL);
|
||||||
|
break;
|
||||||
|
case KEYC_LEFT | KEYC_ESCAPE:
|
||||||
|
self->args = args_create(1, "5");
|
||||||
|
args_set(self->args, 'L', NULL);
|
||||||
|
break;
|
||||||
|
case KEYC_RIGHT | KEYC_ESCAPE:
|
||||||
|
self->args = args_create(1, "5");
|
||||||
|
args_set(self->args, 'R', NULL);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
self->args = args_create(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct winlink *wl;
|
||||||
|
const char *errstr;
|
||||||
|
struct window_pane *wp;
|
||||||
|
u_int adjust;
|
||||||
|
|
||||||
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (args->argc == 0)
|
||||||
|
adjust = 1;
|
||||||
|
else {
|
||||||
|
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
ctx->error(ctx, "adjustment %s", errstr);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(self->args, 'L'))
|
||||||
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
|
||||||
|
else if (args_has(self->args, 'R'))
|
||||||
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust);
|
||||||
|
else if (args_has(self->args, 'U'))
|
||||||
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust);
|
||||||
|
else if (args_has(self->args, 'D'))
|
||||||
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
|
||||||
|
server_redraw_window(wl->window);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
91
cmd-respawn-pane.c
Normal file
91
cmd-respawn-pane.c
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
* Copyright (c) 2011 Marcel P. Partap <mpartap@gmx.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Respawn a pane (restart the command). Kill existing if -k given.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_respawn_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_respawn_pane_entry = {
|
||||||
|
"respawn-pane", "respawnp",
|
||||||
|
"kt:", 0, 1,
|
||||||
|
"[-k] " CMD_TARGET_PANE_USAGE " [command]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_respawn_pane_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct winlink *wl;
|
||||||
|
struct window *w;
|
||||||
|
struct window_pane *wp;
|
||||||
|
struct session *s;
|
||||||
|
struct environ env;
|
||||||
|
const char *cmd;
|
||||||
|
char *cause;
|
||||||
|
u_int idx;
|
||||||
|
|
||||||
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
w = wl->window;
|
||||||
|
|
||||||
|
if (!args_has(self->args, 'k') && wp->fd != -1) {
|
||||||
|
if (window_pane_index(wp, &idx) != 0)
|
||||||
|
fatalx("index not found");
|
||||||
|
ctx->error(ctx, "pane still active: %s:%u.%u",
|
||||||
|
s->name, wl->idx, idx);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
environ_init(&env);
|
||||||
|
environ_copy(&global_environ, &env);
|
||||||
|
environ_copy(&s->environ, &env);
|
||||||
|
server_fill_environ(s, &env);
|
||||||
|
|
||||||
|
window_pane_reset_mode(wp);
|
||||||
|
screen_reinit(&wp->base);
|
||||||
|
input_init(wp);
|
||||||
|
|
||||||
|
if (args->argc != 0)
|
||||||
|
cmd = args->argv[0];
|
||||||
|
else
|
||||||
|
cmd = NULL;
|
||||||
|
if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) {
|
||||||
|
ctx->error(ctx, "respawn pane failed: %s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
environ_free(&env);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
wp->flags |= PANE_REDRAW;
|
||||||
|
server_status_window(w);
|
||||||
|
|
||||||
|
environ_free(&env);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-respawn-window.c,v 1.14 2009-03-04 17:24:07 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,33 +30,31 @@ int cmd_respawn_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_respawn_window_entry = {
|
const struct cmd_entry cmd_respawn_window_entry = {
|
||||||
"respawn-window", "respawnw",
|
"respawn-window", "respawnw",
|
||||||
|
"kt:", 0, 1,
|
||||||
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
|
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
|
||||||
CMD_ARG01|CMD_KFLAG,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_respawn_window_exec,
|
cmd_respawn_window_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
const char **env;
|
struct environ env;
|
||||||
|
const char *cmd;
|
||||||
char *cause;
|
char *cause;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (!(data->flags & CMD_KFLAG)) {
|
if (!args_has(self->args, 'k')) {
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
if (wp->fd == -1)
|
if (wp->fd == -1)
|
||||||
continue;
|
continue;
|
||||||
@@ -66,22 +64,37 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
env = server_fill_environ(s);
|
environ_init(&env);
|
||||||
|
environ_copy(&global_environ, &env);
|
||||||
|
environ_copy(&s->environ, &env);
|
||||||
|
server_fill_environ(s, &env);
|
||||||
|
|
||||||
wp = TAILQ_FIRST(&w->panes);
|
wp = TAILQ_FIRST(&w->panes);
|
||||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
window_destroy_panes(w);
|
layout_free(w);
|
||||||
|
window_destroy_panes(w);
|
||||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||||
window_pane_resize(wp, w->sx, w->sy);
|
window_pane_resize(wp, w->sx, w->sy);
|
||||||
if (window_pane_spawn(wp, data->arg, NULL, env, &cause) != 0) {
|
if (args->argc != 0)
|
||||||
|
cmd = args->argv[0];
|
||||||
|
else
|
||||||
|
cmd = NULL;
|
||||||
|
if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) {
|
||||||
ctx->error(ctx, "respawn window failed: %s", cause);
|
ctx->error(ctx, "respawn window failed: %s", cause);
|
||||||
xfree(cause);
|
xfree(cause);
|
||||||
|
environ_free(&env);
|
||||||
|
server_destroy_pane(wp);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
layout_init(w);
|
||||||
|
window_pane_reset_mode(wp);
|
||||||
screen_reinit(&wp->base);
|
screen_reinit(&wp->base);
|
||||||
|
input_init(wp);
|
||||||
|
window_set_active_pane(w, wp);
|
||||||
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
|
|
||||||
|
environ_free(&env);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-rotate-window.c,v 1.2 2009-04-21 20:06:46 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,88 +24,96 @@
|
|||||||
* Rotate the panes in a window.
|
* Rotate the panes in a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_rotate_window_init(struct cmd *, int);
|
void cmd_rotate_window_key_binding(struct cmd *, int);
|
||||||
int cmd_rotate_window_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_rotate_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rotate_window_entry = {
|
const struct cmd_entry cmd_rotate_window_entry = {
|
||||||
"rotate-window", "rotatew",
|
"rotate-window", "rotatew",
|
||||||
|
"Dt:U", 0, 0,
|
||||||
"[-DU] " CMD_TARGET_WINDOW_USAGE,
|
"[-DU] " CMD_TARGET_WINDOW_USAGE,
|
||||||
CMD_UPPERUFLAG|CMD_UPPERDFLAG,
|
0,
|
||||||
cmd_rotate_window_init,
|
cmd_rotate_window_key_binding,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_rotate_window_exec,
|
cmd_rotate_window_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_rotate_window_init(struct cmd *self, int key)
|
cmd_rotate_window_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data;
|
self->args = args_create(0);
|
||||||
|
if (key == ('o' | KEYC_ESCAPE))
|
||||||
cmd_target_init(self, key);
|
args_set(self->args, 'D', NULL);
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
if (key == KEYC_ADDESC('o'))
|
|
||||||
data->flags |= CMD_UPPERDFLAG;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
struct window_pane *wp, *wp2;
|
struct window_pane *wp, *wp2;
|
||||||
|
struct layout_cell *lc;
|
||||||
u_int sx, sy, xoff, yoff;
|
u_int sx, sy, xoff, yoff;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (data->flags & CMD_UPPERDFLAG) {
|
if (args_has(self->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);
|
||||||
|
|
||||||
|
lc = wp->layout_cell;
|
||||||
xoff = wp->xoff; yoff = wp->yoff;
|
xoff = wp->xoff; yoff = wp->yoff;
|
||||||
sx = wp->sx; sy = wp->sy;
|
sx = wp->sx; sy = wp->sy;
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
if ((wp2 = TAILQ_NEXT(wp, entry)) == NULL)
|
if ((wp2 = TAILQ_NEXT(wp, entry)) == NULL)
|
||||||
break;
|
break;
|
||||||
|
wp->layout_cell = wp2->layout_cell;
|
||||||
|
if (wp->layout_cell != NULL)
|
||||||
|
wp->layout_cell->wp = wp;
|
||||||
wp->xoff = wp2->xoff; wp->yoff = wp2->yoff;
|
wp->xoff = wp2->xoff; wp->yoff = wp2->yoff;
|
||||||
window_pane_resize(wp, wp2->sx, wp2->sy);
|
window_pane_resize(wp, wp2->sx, wp2->sy);
|
||||||
}
|
}
|
||||||
|
wp->layout_cell = lc;
|
||||||
|
if (wp->layout_cell != NULL)
|
||||||
|
wp->layout_cell->wp = wp;
|
||||||
wp->xoff = xoff; wp->yoff = yoff;
|
wp->xoff = xoff; wp->yoff = yoff;
|
||||||
window_pane_resize(wp, sx, sy);
|
window_pane_resize(wp, sx, sy);
|
||||||
|
|
||||||
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);
|
window_set_active_pane(w, 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);
|
||||||
TAILQ_INSERT_TAIL(&w->panes, wp, entry);
|
TAILQ_INSERT_TAIL(&w->panes, wp, entry);
|
||||||
|
|
||||||
|
lc = wp->layout_cell;
|
||||||
xoff = wp->xoff; yoff = wp->yoff;
|
xoff = wp->xoff; yoff = wp->yoff;
|
||||||
sx = wp->sx; sy = wp->sy;
|
sx = wp->sx; sy = wp->sy;
|
||||||
TAILQ_FOREACH_REVERSE(wp, &w->panes, window_panes, entry) {
|
TAILQ_FOREACH_REVERSE(wp, &w->panes, window_panes, entry) {
|
||||||
if ((wp2 = TAILQ_PREV(wp, window_panes, entry)) == NULL)
|
if ((wp2 = TAILQ_PREV(wp, window_panes, entry)) == NULL)
|
||||||
break;
|
break;
|
||||||
|
wp->layout_cell = wp2->layout_cell;
|
||||||
|
if (wp->layout_cell != NULL)
|
||||||
|
wp->layout_cell->wp = wp;
|
||||||
wp->xoff = wp2->xoff; wp->yoff = wp2->yoff;
|
wp->xoff = wp2->xoff; wp->yoff = wp2->yoff;
|
||||||
window_pane_resize(wp, wp2->sx, wp2->sy);
|
window_pane_resize(wp, wp2->sx, wp2->sy);
|
||||||
}
|
}
|
||||||
|
wp->layout_cell = lc;
|
||||||
|
if (wp->layout_cell != NULL)
|
||||||
|
wp->layout_cell->wp = wp;
|
||||||
wp->xoff = xoff; wp->yoff = yoff;
|
wp->xoff = xoff; wp->yoff = yoff;
|
||||||
window_pane_resize(wp, sx, sy);
|
window_pane_resize(wp, sx, sy);
|
||||||
|
|
||||||
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);
|
window_set_active_pane(w, wp);
|
||||||
|
server_redraw_window(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout_refresh(w, 0);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
141
cmd-run-shell.c
Normal file
141
cmd-run-shell.c
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
|
* Copyright (c) 2009 Nicholas Marriott <nicm@openbsd.org>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF 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/wait.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Runs a command without a window.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_run_shell_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
void cmd_run_shell_callback(struct job *);
|
||||||
|
void cmd_run_shell_free(void *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_run_shell_entry = {
|
||||||
|
"run-shell", "run",
|
||||||
|
"", 1, 1,
|
||||||
|
"command",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_run_shell_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_run_shell_data {
|
||||||
|
char *cmd;
|
||||||
|
struct cmd_ctx ctx;
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct cmd_run_shell_data *cdata;
|
||||||
|
const char *shellcmd = args->argv[0];
|
||||||
|
|
||||||
|
cdata = xmalloc(sizeof *cdata);
|
||||||
|
cdata->cmd = xstrdup(args->argv[0]);
|
||||||
|
memcpy(&cdata->ctx, ctx, sizeof cdata->ctx);
|
||||||
|
|
||||||
|
if (ctx->cmdclient != NULL)
|
||||||
|
ctx->cmdclient->references++;
|
||||||
|
if (ctx->curclient != NULL)
|
||||||
|
ctx->curclient->references++;
|
||||||
|
|
||||||
|
job_run(shellcmd, cmd_run_shell_callback, cmd_run_shell_free, cdata);
|
||||||
|
|
||||||
|
return (1); /* don't let client exit */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_run_shell_callback(struct job *job)
|
||||||
|
{
|
||||||
|
struct cmd_run_shell_data *cdata = job->data;
|
||||||
|
struct cmd_ctx *ctx = &cdata->ctx;
|
||||||
|
char *cmd, *msg, *line;
|
||||||
|
size_t size;
|
||||||
|
int retcode;
|
||||||
|
u_int lines;
|
||||||
|
|
||||||
|
if (ctx->cmdclient != NULL && ctx->cmdclient->flags & CLIENT_DEAD)
|
||||||
|
return;
|
||||||
|
if (ctx->curclient != NULL && ctx->curclient->flags & CLIENT_DEAD)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lines = 0;
|
||||||
|
do {
|
||||||
|
if ((line = evbuffer_readline(job->event->input)) != NULL) {
|
||||||
|
ctx->print(ctx, "%s", line);
|
||||||
|
lines++;
|
||||||
|
}
|
||||||
|
} while (line != NULL);
|
||||||
|
|
||||||
|
size = EVBUFFER_LENGTH(job->event->input);
|
||||||
|
if (size != 0) {
|
||||||
|
line = xmalloc(size + 1);
|
||||||
|
memcpy(line, EVBUFFER_DATA(job->event->input), size);
|
||||||
|
line[size] = '\0';
|
||||||
|
|
||||||
|
ctx->print(ctx, "%s", line);
|
||||||
|
lines++;
|
||||||
|
|
||||||
|
xfree(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = cdata->cmd;
|
||||||
|
|
||||||
|
msg = NULL;
|
||||||
|
if (WIFEXITED(job->status)) {
|
||||||
|
if ((retcode = WEXITSTATUS(job->status)) != 0)
|
||||||
|
xasprintf(&msg, "'%s' returned %d", cmd, retcode);
|
||||||
|
} else if (WIFSIGNALED(job->status)) {
|
||||||
|
retcode = WTERMSIG(job->status);
|
||||||
|
xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode);
|
||||||
|
}
|
||||||
|
if (msg != NULL) {
|
||||||
|
if (lines != 0)
|
||||||
|
ctx->print(ctx, "%s", msg);
|
||||||
|
else
|
||||||
|
ctx->info(ctx, "%s", msg);
|
||||||
|
xfree(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_run_shell_free(void *data)
|
||||||
|
{
|
||||||
|
struct cmd_run_shell_data *cdata = data;
|
||||||
|
struct cmd_ctx *ctx = &cdata->ctx;
|
||||||
|
|
||||||
|
if (ctx->cmdclient != NULL) {
|
||||||
|
ctx->cmdclient->references--;
|
||||||
|
ctx->cmdclient->flags |= CLIENT_EXIT;
|
||||||
|
}
|
||||||
|
if (ctx->curclient != NULL)
|
||||||
|
ctx->curclient->references--;
|
||||||
|
|
||||||
|
xfree(cdata->cmd);
|
||||||
|
xfree(cdata);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-save-buffer.c,v 1.4 2009-02-08 13:36:40 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -25,66 +25,93 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Saves a session paste buffer to a file.
|
* Saves a paste buffer to a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_save_buffer_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_save_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_save_buffer_entry = {
|
const struct cmd_entry cmd_save_buffer_entry = {
|
||||||
"save-buffer", "saveb",
|
"save-buffer", "saveb",
|
||||||
"[-a] " CMD_BUFFER_SESSION_USAGE " path",
|
"ab:", 1, 1,
|
||||||
CMD_AFLAG|CMD_ARG1,
|
"[-a] " CMD_BUFFER_USAGE,
|
||||||
cmd_buffer_init,
|
0,
|
||||||
cmd_buffer_parse,
|
NULL,
|
||||||
cmd_save_buffer_exec,
|
NULL,
|
||||||
cmd_buffer_send,
|
cmd_save_buffer_exec
|
||||||
cmd_buffer_recv,
|
|
||||||
cmd_buffer_free,
|
|
||||||
cmd_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct client *c = ctx->cmdclient;
|
||||||
|
struct session *s;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
mode_t mask;
|
const char *path, *newpath, *wd;
|
||||||
|
char *cause;
|
||||||
|
int buffer;
|
||||||
|
mode_t mask;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if (!args_has(args, 'b')) {
|
||||||
return (-1);
|
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
||||||
|
|
||||||
if (data->buffer == -1) {
|
|
||||||
if ((pb = paste_get_top(&s->buffers)) == NULL) {
|
|
||||||
ctx->error(ctx, "no buffers");
|
ctx->error(ctx, "no buffers");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((pb = paste_get_index(&s->buffers, data->buffer)) == NULL) {
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
if (cause != NULL) {
|
||||||
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
pb = paste_get_index(&global_buffers, buffer);
|
||||||
|
if (pb == NULL) {
|
||||||
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mask = umask(S_IRWXG | S_IRWXO);
|
path = args->argv[0];
|
||||||
if (data->flags & CMD_AFLAG)
|
if (strcmp(path, "-") == 0) {
|
||||||
f = fopen(data->arg, "a");
|
if (c == NULL) {
|
||||||
else
|
ctx->error(ctx, "%s: can't write to stdout", path);
|
||||||
f = fopen(data->arg, "w");
|
return (-1);
|
||||||
if (f == NULL) {
|
}
|
||||||
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
|
bufferevent_write(c->stdout_event, pb->data, pb->size);
|
||||||
return (-1);
|
} else {
|
||||||
}
|
if (c != NULL)
|
||||||
|
wd = c->cwd;
|
||||||
|
else if ((s = cmd_current_session(ctx, 0)) != NULL) {
|
||||||
|
wd = options_get_string(&s->options, "default-path");
|
||||||
|
if (*wd == '\0')
|
||||||
|
wd = s->cwd;
|
||||||
|
} else
|
||||||
|
wd = NULL;
|
||||||
|
if (wd != NULL && *wd != '\0') {
|
||||||
|
newpath = get_full_path(wd, path);
|
||||||
|
if (newpath != NULL)
|
||||||
|
path = newpath;
|
||||||
|
}
|
||||||
|
|
||||||
if (fwrite(pb->data, 1, strlen(pb->data), f) != strlen(pb->data)) {
|
mask = umask(S_IRWXG | S_IRWXO);
|
||||||
ctx->error(ctx, "%s: fwrite error", data->arg);
|
if (args_has(self->args, 'a'))
|
||||||
fclose(f);
|
f = fopen(path, "ab");
|
||||||
return (-1);
|
else
|
||||||
|
f = fopen(path, "wb");
|
||||||
|
umask(mask);
|
||||||
|
if (f == NULL) {
|
||||||
|
ctx->error(ctx, "%s: %s", path, strerror(errno));
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
|
||||||
|
ctx->error(ctx, "%s: fwrite error", path);
|
||||||
|
fclose(f);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
umask(mask);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
/* $Id: cmd-scroll-mode.c,v 1.16 2009-01-27 23:35:44 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enter scroll mode.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void cmd_scroll_mode_init(struct cmd *, int);
|
|
||||||
int cmd_scroll_mode_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_scroll_mode_entry = {
|
|
||||||
"scroll-mode", NULL,
|
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
|
||||||
CMD_UFLAG,
|
|
||||||
cmd_scroll_mode_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_scroll_mode_exec,
|
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_scroll_mode_init(struct cmd *self, int key)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data;
|
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
switch (key) {
|
|
||||||
case KEYC_PPAGE:
|
|
||||||
data->flags |= CMD_UFLAG;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_scroll_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct winlink *wl;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
window_pane_set_mode(wl->window->active, &window_scroll_mode);
|
|
||||||
if (data->flags & CMD_UFLAG)
|
|
||||||
window_scroll_pageup(wl->window->active);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
133
cmd-select-layout.c
Normal file
133
cmd-select-layout.c
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Switch window to selected layout.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void cmd_select_layout_key_binding(struct cmd *, int);
|
||||||
|
int cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_select_layout_entry = {
|
||||||
|
"select-layout", "selectl",
|
||||||
|
"npt:", 0, 1,
|
||||||
|
"[-np] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
||||||
|
0,
|
||||||
|
cmd_select_layout_key_binding,
|
||||||
|
NULL,
|
||||||
|
cmd_select_layout_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_next_layout_entry = {
|
||||||
|
"next-layout", "nextl",
|
||||||
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_select_layout_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_previous_layout_entry = {
|
||||||
|
"previous-layout", "prevl",
|
||||||
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_select_layout_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_select_layout_key_binding(struct cmd *self, int key)
|
||||||
|
{
|
||||||
|
switch (key) {
|
||||||
|
case '1' | KEYC_ESCAPE:
|
||||||
|
self->args = args_create(1, "even-horizontal");
|
||||||
|
break;
|
||||||
|
case '2' | KEYC_ESCAPE:
|
||||||
|
self->args = args_create(1, "even-vertical");
|
||||||
|
break;
|
||||||
|
case '3' | KEYC_ESCAPE:
|
||||||
|
self->args = args_create(1, "main-horizontal");
|
||||||
|
break;
|
||||||
|
case '4' | KEYC_ESCAPE:
|
||||||
|
self->args = args_create(1, "main-vertical");
|
||||||
|
break;
|
||||||
|
case '5' | KEYC_ESCAPE:
|
||||||
|
self->args = args_create(1, "tiled");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
self->args = args_create(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct winlink *wl;
|
||||||
|
const char *layoutname;
|
||||||
|
int next, previous, layout;
|
||||||
|
|
||||||
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
next = self->entry == &cmd_next_layout_entry;
|
||||||
|
if (args_has(self->args, 'n'))
|
||||||
|
next = 1;
|
||||||
|
previous = self->entry == &cmd_previous_layout_entry;
|
||||||
|
if (args_has(self->args, 'p'))
|
||||||
|
previous = 1;
|
||||||
|
|
||||||
|
if (next || previous) {
|
||||||
|
if (next)
|
||||||
|
layout = layout_set_next(wl->window);
|
||||||
|
else
|
||||||
|
layout = layout_set_previous(wl->window);
|
||||||
|
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args->argc == 0)
|
||||||
|
layout = wl->window->lastlayout;
|
||||||
|
else
|
||||||
|
layout = layout_set_lookup(args->argv[0]);
|
||||||
|
if (layout != -1) {
|
||||||
|
layout = layout_set_select(wl->window, layout);
|
||||||
|
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args->argc != 0) {
|
||||||
|
layoutname = args->argv[0];
|
||||||
|
if (layout_parse(wl->window, layoutname) == -1) {
|
||||||
|
ctx->error(ctx, "can't set layout: %s", layoutname);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
ctx->info(ctx, "arranging in: %s", layoutname);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-select-pane.c,v 1.4 2009-04-01 21:10:08 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,46 +24,93 @@
|
|||||||
* Select pane.
|
* Select pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void cmd_select_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_select_pane_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_select_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_pane_entry = {
|
const struct cmd_entry cmd_select_pane_entry = {
|
||||||
"select-pane", "selectp",
|
"select-pane", "selectp",
|
||||||
CMD_PANE_WINDOW_USAGE,
|
"lDLRt:U", 0, 0,
|
||||||
|
"[-lDLRU] " CMD_TARGET_PANE_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_pane_init,
|
cmd_select_pane_key_binding,
|
||||||
cmd_pane_parse,
|
NULL,
|
||||||
cmd_select_pane_exec,
|
cmd_select_pane_exec
|
||||||
cmd_pane_send,
|
|
||||||
cmd_pane_recv,
|
|
||||||
cmd_pane_free,
|
|
||||||
cmd_pane_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_last_pane_entry = {
|
||||||
|
"last-pane", "lastp",
|
||||||
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_select_pane_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_select_pane_key_binding(struct cmd *self, int key)
|
||||||
|
{
|
||||||
|
self->args = args_create(0);
|
||||||
|
if (key == KEYC_UP)
|
||||||
|
args_set(self->args, 'U', NULL);
|
||||||
|
if (key == KEYC_DOWN)
|
||||||
|
args_set(self->args, 'D', NULL);
|
||||||
|
if (key == KEYC_LEFT)
|
||||||
|
args_set(self->args, 'L', NULL);
|
||||||
|
if (key == KEYC_RIGHT)
|
||||||
|
args_set(self->args, 'R', NULL);
|
||||||
|
if (key == 'o')
|
||||||
|
args_set(self->args, 't', ":.+");
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_pane_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) {
|
||||||
return (-1);
|
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
||||||
if (data->pane == -1)
|
if (wl == NULL)
|
||||||
wp = wl->window->active;
|
return (-1);
|
||||||
else {
|
|
||||||
wp = window_pane_at_index(wl->window, data->pane);
|
if (wl->window->last == NULL) {
|
||||||
if (wp == NULL) {
|
ctx->error(ctx, "no last pane");
|
||||||
ctx->error(ctx, "no pane: %d", data->pane);
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window_set_active_pane(wl->window, wl->window->last);
|
||||||
|
server_status_window(wl->window);
|
||||||
|
server_redraw_window_borders(wl->window);
|
||||||
|
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wp->flags & PANE_HIDDEN) {
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
ctx->error(ctx, "pane %d is hidden", data->pane);
|
return (-1);
|
||||||
|
|
||||||
|
if (!window_pane_visible(wp)) {
|
||||||
|
ctx->error(ctx, "pane not visible");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args_has(self->args, 'L'))
|
||||||
|
wp = window_pane_find_left(wp);
|
||||||
|
else if (args_has(self->args, 'R'))
|
||||||
|
wp = window_pane_find_right(wp);
|
||||||
|
else if (args_has(self->args, 'U'))
|
||||||
|
wp = window_pane_find_up(wp);
|
||||||
|
else if (args_has(self->args, 'D'))
|
||||||
|
wp = window_pane_find_down(wp);
|
||||||
|
if (wp == NULL) {
|
||||||
|
ctx->error(ctx, "pane not found");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
window_set_active_pane(wl->window, wp);
|
window_set_active_pane(wl->window, wp);
|
||||||
layout_refresh(wl->window, 1);
|
server_status_window(wl->window);
|
||||||
|
server_redraw_window_borders(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
/* $Id: cmd-select-prompt.c,v 1.7 2009-02-13 18:57:55 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prompt for window index and select it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_select_prompt_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
int cmd_select_prompt_callback(void *, const char *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_prompt_entry = {
|
|
||||||
"select-prompt", NULL,
|
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
|
||||||
0,
|
|
||||||
cmd_target_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_select_prompt_exec,
|
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_select_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct client *c;
|
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (c->prompt_string != NULL)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
status_prompt_set(c, "index ", cmd_select_prompt_callback, c, 0);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_select_prompt_callback(void *data, const char *s)
|
|
||||||
{
|
|
||||||
struct client *c = data;
|
|
||||||
const char *errstr;
|
|
||||||
char msg[128];
|
|
||||||
u_int idx;
|
|
||||||
|
|
||||||
if (s == NULL)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
idx = strtonum(s, 0, UINT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xsnprintf(msg, sizeof msg, "Index %s: %s", errstr, s);
|
|
||||||
status_message_set(c, msg);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (winlink_find_by_index(&c->session->windows, idx) == NULL) {
|
|
||||||
xsnprintf(msg, sizeof msg,
|
|
||||||
"Window not found: %s:%d", c->session->name, idx);
|
|
||||||
status_message_set(c, msg);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (session_select(c->session, idx) == 0)
|
|
||||||
server_redraw_session(c->session);
|
|
||||||
recalculate_sizes();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-select-window.c,v 1.21 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,45 +26,113 @@
|
|||||||
* Select window by index.
|
* Select window by index.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_window_init(struct cmd *, int);
|
void cmd_select_window_key_binding(struct cmd *, int);
|
||||||
int cmd_select_window_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_select_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_window_entry = {
|
const struct cmd_entry cmd_select_window_entry = {
|
||||||
"select-window", "selectw",
|
"select-window", "selectw",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"lnpt:", 0, 0,
|
||||||
|
"[-lnp] " CMD_TARGET_WINDOW_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_select_window_init,
|
cmd_select_window_key_binding,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_select_window_exec,
|
cmd_select_window_exec
|
||||||
cmd_target_send,
|
};
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
const struct cmd_entry cmd_next_window_entry = {
|
||||||
cmd_target_print
|
"next-window", "next",
|
||||||
|
"at:", 0, 0,
|
||||||
|
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
0,
|
||||||
|
cmd_select_window_key_binding,
|
||||||
|
NULL,
|
||||||
|
cmd_select_window_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_previous_window_entry = {
|
||||||
|
"previous-window", "prev",
|
||||||
|
"at:", 0, 0,
|
||||||
|
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
0,
|
||||||
|
cmd_select_window_key_binding,
|
||||||
|
NULL,
|
||||||
|
cmd_select_window_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_last_window_entry = {
|
||||||
|
"last-window", "last",
|
||||||
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_SESSION_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_select_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_select_window_init(struct cmd *self, int key)
|
cmd_select_window_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data;
|
char tmp[16];
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
self->args = args_create(0);
|
||||||
data = self->data;
|
if (key >= '0' && key <= '9') {
|
||||||
|
xsnprintf(tmp, sizeof tmp, ":%d", key - '0');
|
||||||
xasprintf(&data->target, ":%d", key - '0');
|
args_set(self->args, 't', tmp);
|
||||||
|
}
|
||||||
|
if (key == ('n' | KEYC_ESCAPE) || key == ('p' | KEYC_ESCAPE))
|
||||||
|
args_set(self->args, 'a', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
int next, previous, last, activity;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
next = self->entry == &cmd_next_window_entry;
|
||||||
return (-1);
|
if (args_has(self->args, 'n'))
|
||||||
|
next = 1;
|
||||||
|
previous = self->entry == &cmd_previous_window_entry;
|
||||||
|
if (args_has(self->args, 'p'))
|
||||||
|
previous = 1;
|
||||||
|
last = self->entry == &cmd_last_window_entry;
|
||||||
|
if (args_has(self->args, 'l'))
|
||||||
|
last = 1;
|
||||||
|
|
||||||
|
if (next || previous || last) {
|
||||||
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
|
if (s == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
activity = args_has(self->args, 'a');
|
||||||
|
if (next) {
|
||||||
|
if (session_next(s, activity) != 0) {
|
||||||
|
ctx->error(ctx, "no next window");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} else if (previous) {
|
||||||
|
if (session_previous(s, activity) != 0) {
|
||||||
|
ctx->error(ctx, "no previous window");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (session_last(s) != 0) {
|
||||||
|
ctx->error(ctx, "no last window");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (session_select(s, wl->idx) == 0)
|
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
|
} else {
|
||||||
|
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
||||||
|
if (wl == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (session_select(s, wl->idx) == 0)
|
||||||
|
server_redraw_session(s);
|
||||||
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
175
cmd-send-keys.c
175
cmd-send-keys.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-send-keys.c,v 1.18 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,159 +27,57 @@
|
|||||||
* Send keys to client.
|
* Send keys to client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_send_keys_parse(struct cmd *, int, char **, char **);
|
|
||||||
int cmd_send_keys_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_send_keys_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_send_keys_send(struct cmd *, struct buffer *);
|
|
||||||
void cmd_send_keys_recv(struct cmd *, struct buffer *);
|
|
||||||
void cmd_send_keys_free(struct cmd *);
|
|
||||||
size_t cmd_send_keys_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_send_keys_data {
|
|
||||||
char *target;
|
|
||||||
int idx;
|
|
||||||
u_int nkeys;
|
|
||||||
int *keys;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_send_keys_entry = {
|
const struct cmd_entry cmd_send_keys_entry = {
|
||||||
"send-keys", "send",
|
"send-keys", "send",
|
||||||
"[-t target-window] key ...",
|
"Rt:", 0, -1,
|
||||||
|
"[-R] [-t target-pane] key ...",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_send_keys_parse,
|
NULL,
|
||||||
cmd_send_keys_exec,
|
cmd_send_keys_exec
|
||||||
cmd_send_keys_send,
|
|
||||||
cmd_send_keys_recv,
|
|
||||||
cmd_send_keys_free,
|
|
||||||
cmd_send_keys_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
|
||||||
cmd_send_keys_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_send_keys_data *data;
|
|
||||||
int opt, key;
|
|
||||||
char *s;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->target = NULL;
|
|
||||||
data->idx = -1;
|
|
||||||
data->nkeys = 0;
|
|
||||||
data->keys = NULL;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "t:")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc == 0)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
while (argc-- != 0) {
|
|
||||||
if ((key = key_string_lookup_string(*argv)) != KEYC_NONE) {
|
|
||||||
data->keys = xrealloc(
|
|
||||||
data->keys, data->nkeys + 1, sizeof *data->keys);
|
|
||||||
data->keys[data->nkeys++] = key;
|
|
||||||
} else {
|
|
||||||
for (s = *argv; *s != '\0'; s++) {
|
|
||||||
data->keys = xrealloc(data->keys,
|
|
||||||
data->nkeys + 1, sizeof *data->keys);
|
|
||||||
data->keys[data->nkeys++] = *s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
argv++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_send_keys_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct window_pane *wp;
|
||||||
u_int i;
|
struct session *s;
|
||||||
|
struct input_ctx *ictx;
|
||||||
|
const char *str;
|
||||||
|
int i, key;
|
||||||
|
|
||||||
if (data == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if (args_has(args, 'R')) {
|
||||||
return (-1);
|
ictx = &wp->ictx;
|
||||||
|
|
||||||
for (i = 0; i < data->nkeys; i++) {
|
memcpy(&ictx->cell, &grid_default_cell, sizeof ictx->cell);
|
||||||
window_pane_key(
|
memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell);
|
||||||
wl->window->active, ctx->curclient, data->keys[i]);
|
ictx->old_cx = 0;
|
||||||
|
ictx->old_cy = 0;
|
||||||
|
|
||||||
|
if (wp->mode == NULL)
|
||||||
|
screen_write_start(&ictx->ctx, wp, &wp->base);
|
||||||
|
else
|
||||||
|
screen_write_start(&ictx->ctx, NULL, &wp->base);
|
||||||
|
screen_write_reset(&ictx->ctx);
|
||||||
|
screen_write_stop(&ictx->ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < args->argc; i++) {
|
||||||
|
str = args->argv[i];
|
||||||
|
|
||||||
|
if ((key = key_string_lookup_string(str)) != KEYC_NONE) {
|
||||||
|
window_pane_key(wp, s, key);
|
||||||
|
} else {
|
||||||
|
for (; *str != '\0'; str++)
|
||||||
|
window_pane_key(wp, s, *str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
cmd_send_keys_send(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_send_keys_data *data = self->data;
|
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
|
||||||
cmd_send_string(b, data->target);
|
|
||||||
buffer_write(b, data->keys, data->nkeys * sizeof *data->keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_send_keys_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_send_keys_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->target = cmd_recv_string(b);
|
|
||||||
data->keys = xcalloc(data->nkeys, sizeof *data->keys);
|
|
||||||
buffer_read(b, data->keys, data->nkeys * sizeof *data->keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_send_keys_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_send_keys_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_send_keys_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_send_keys_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->idx != -1)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -i %d", data->idx);
|
|
||||||
|
|
||||||
for (i = 0; i < data->nkeys; i++) {
|
|
||||||
if (off >= len)
|
|
||||||
break;
|
|
||||||
off += xsnprintf(buf + off,
|
|
||||||
len - off, " %s", key_string_lookup_key(data->keys[i]));
|
|
||||||
}
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-send-prefix.c,v 1.23 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,30 +28,30 @@ int cmd_send_prefix_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_send_prefix_entry = {
|
const struct cmd_entry cmd_send_prefix_entry = {
|
||||||
"send-prefix", NULL,
|
"send-prefix", NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"2t:", 0, 0,
|
||||||
|
"[-2] " CMD_TARGET_PANE_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_send_prefix_exec,
|
cmd_send_prefix_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct window_pane *wp;
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
key = options_get_number(&s->options, "prefix");
|
if (args_has(args, '2'))
|
||||||
window_pane_key(wl->window->active, ctx->curclient, key);
|
key = options_get_number(&s->options, "prefix2");
|
||||||
|
else
|
||||||
|
key = options_get_number(&s->options, "prefix");
|
||||||
|
window_pane_key(wp, s, key);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-server-info.c,v 1.14 2009-04-02 23:28:16 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -23,7 +23,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <vis.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -35,45 +34,45 @@ int cmd_server_info_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_server_info_entry = {
|
const struct cmd_entry cmd_server_info_entry = {
|
||||||
"server-info", "info",
|
"server-info", "info",
|
||||||
|
"", 0, 0,
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_server_info_exec,
|
cmd_server_info_exec
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct tty_term *term;
|
struct tty_term *term;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct tty_code *code;
|
struct tty_code *code;
|
||||||
struct tty_term_code_entry *ent;
|
const struct tty_term_code_entry *ent;
|
||||||
struct utsname un;
|
struct utsname un;
|
||||||
struct grid *gd;
|
struct job *job;
|
||||||
u_int i, j, k;
|
struct grid *gd;
|
||||||
char out[BUFSIZ];
|
struct grid_line *gl;
|
||||||
char *tim;
|
u_int i, j, k;
|
||||||
time_t t;
|
char out[80];
|
||||||
u_int lines, ulines;
|
char *tim;
|
||||||
size_t size, usize;
|
time_t t;
|
||||||
|
u_int lines, ulines;
|
||||||
|
size_t size, usize;
|
||||||
|
|
||||||
tim = ctime(&start_time);
|
tim = ctime(&start_time);
|
||||||
*strchr(tim, '\n') = '\0';
|
*strchr(tim, '\n') = '\0';
|
||||||
ctx->print(ctx,
|
ctx->print(ctx,
|
||||||
"tmux " BUILD ", pid %ld, started %s", (long) getpid(), tim);
|
"tmux " VERSION ", pid %ld, started %s", (long) getpid(), tim);
|
||||||
ctx->print(ctx, "socket path %s, debug level %d%s",
|
ctx->print(
|
||||||
socket_path, debug_level, be_quiet ? ", quiet" : "");
|
ctx, "socket path %s, debug level %d", socket_path, debug_level);
|
||||||
if (uname(&un) == 0) {
|
if (uname(&un) >= 0) {
|
||||||
ctx->print(ctx, "system is %s %s %s %s",
|
ctx->print(ctx, "system is %s %s %s %s",
|
||||||
un.sysname, un.release, un.version, un.machine);
|
un.sysname, un.release, un.version, un.machine);
|
||||||
}
|
}
|
||||||
if (cfg_file != NULL)
|
if (cfg_file != NULL)
|
||||||
@@ -81,9 +80,7 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else
|
else
|
||||||
ctx->print(ctx, "configuration file not specified");
|
ctx->print(ctx, "configuration file not specified");
|
||||||
ctx->print(ctx, "protocol version is %d", PROTOCOL_VERSION);
|
ctx->print(ctx, "protocol version is %d", PROTOCOL_VERSION);
|
||||||
ctx->print(ctx, "%u clients, %u sessions",
|
ctx->print(ctx, "%s", "");
|
||||||
ARRAY_LENGTH(&clients), ARRAY_LENGTH(&sessions));
|
|
||||||
ctx->print(ctx, "");
|
|
||||||
|
|
||||||
ctx->print(ctx, "Clients:");
|
ctx->print(ctx, "Clients:");
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
@@ -91,50 +88,50 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (c == NULL || c->session == NULL)
|
if (c == NULL || c->session == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ctx->print(ctx, "%2d: %p %s (%d, %d): %s [%ux%u %s] "
|
ctx->print(ctx,"%2d: %s (%d, %d): %s [%ux%u %s bs=%hho] "
|
||||||
"[flags=0x%x/0x%x]", i, c, c->tty.path, c->fd, c->tty.fd,
|
"[flags=0x%x/0x%x, references=%u]", i, c->tty.path,
|
||||||
c->session->name, c->tty.sx, c->tty.sy, c->tty.termname,
|
c->ibuf.fd, c->tty.fd, c->session->name,
|
||||||
c->flags, c->tty.flags);
|
c->tty.sx, c->tty.sy, c->tty.termname,
|
||||||
|
c->tty.tio.c_cc[VERASE], c->flags,
|
||||||
|
c->tty.flags, c->references);
|
||||||
}
|
}
|
||||||
ctx->print(ctx, "");
|
ctx->print(ctx, "%s", "");
|
||||||
|
|
||||||
ctx->print(ctx, "Sessions: [%zu/%zu]",
|
ctx->print(ctx, "Sessions: [%zu/%zu]",
|
||||||
sizeof (struct grid_cell), sizeof (struct grid_utf8));
|
sizeof (struct grid_cell), sizeof (struct grid_utf8));
|
||||||
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
s = ARRAY_ITEM(&sessions, i);
|
t = s->creation_time.tv_sec;
|
||||||
if (s == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
t = s->tv.tv_sec;
|
|
||||||
tim = ctime(&t);
|
tim = ctime(&t);
|
||||||
*strchr(tim, '\n') = '\0';
|
*strchr(tim, '\n') = '\0';
|
||||||
|
|
||||||
ctx->print(ctx, "%2u: %p %s: %u windows (created %s) [%ux%u] "
|
ctx->print(ctx, "%2u: %s: %u windows (created %s) [%ux%u] "
|
||||||
"[flags=0x%x]", i, s, s->name, winlink_count(&s->windows),
|
"[flags=0x%x]", s->idx, s->name,
|
||||||
tim, s->sx, s->sy, s->flags);
|
winlink_count(&s->windows), tim, s->sx, s->sy, s->flags);
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
ctx->print(ctx, "%4u: %p/%p %s [%ux%u] [flags=0x%x, "
|
ctx->print(ctx, "%4u: %s [%ux%u] [flags=0x%x, "
|
||||||
"references=%u, layout=%u]", wl->idx, wl, w, w->name,
|
"references=%u, last layout=%d]", wl->idx, w->name,
|
||||||
w->sx, w->sy, w->flags, w->references, w->layout);
|
w->sx, w->sy, w->flags, w->references,
|
||||||
|
w->lastlayout);
|
||||||
j = 0;
|
j = 0;
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
lines = ulines = size = usize = 0;
|
lines = ulines = size = usize = 0;
|
||||||
gd = wp->base.grid;
|
gd = wp->base.grid;
|
||||||
for (k = 0; k < gd->hsize + gd->sy; k++) {
|
for (k = 0; k < gd->hsize + gd->sy; k++) {
|
||||||
if (gd->data[k] != NULL) {
|
gl = &gd->linedata[k];
|
||||||
|
if (gl->celldata != NULL) {
|
||||||
lines++;
|
lines++;
|
||||||
size += gd->size[k] *
|
size += gl->cellsize *
|
||||||
sizeof (**gd->data);
|
sizeof *gl->celldata;
|
||||||
}
|
}
|
||||||
if (gd->udata[k] != NULL) {
|
if (gl->utf8data != NULL) {
|
||||||
ulines++;
|
ulines++;
|
||||||
usize += gd->usize[k] *
|
usize += gl->utf8size *
|
||||||
sizeof (**gd->udata);
|
sizeof *gl->utf8data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx->print(ctx, "%6u: %p %s %lu %d %u/%u, %zu "
|
ctx->print(ctx, "%6u: %s %lu %d %u/%u, %zu "
|
||||||
"bytes; UTF-8 %u/%u, %zu bytes", j, wp,
|
"bytes; UTF-8 %u/%u, %zu bytes", j,
|
||||||
wp->tty, (u_long) wp->pid, wp->fd, lines,
|
wp->tty, (u_long) wp->pid, wp->fd, lines,
|
||||||
gd->hsize + gd->sy, size, ulines,
|
gd->hsize + gd->sy, size, ulines,
|
||||||
gd->hsize + gd->sy, usize);
|
gd->hsize + gd->sy, usize);
|
||||||
@@ -142,10 +139,10 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx->print(ctx, "");
|
ctx->print(ctx, "%s", "");
|
||||||
|
|
||||||
ctx->print(ctx, "Terminals:");
|
ctx->print(ctx, "Terminals:");
|
||||||
SLIST_FOREACH(term, &tty_terms, entry) {
|
LIST_FOREACH(term, &tty_terms, entry) {
|
||||||
ctx->print(ctx, "%s [references=%u, flags=0x%x]:",
|
ctx->print(ctx, "%s [references=%u, flags=0x%x]:",
|
||||||
term->name, term->references, term->flags);
|
term->name, term->references, term->flags);
|
||||||
for (i = 0; i < NTTYCODE; i++) {
|
for (i = 0; i < NTTYCODE; i++) {
|
||||||
@@ -157,10 +154,8 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ent->code, ent->name);
|
ent->code, ent->name);
|
||||||
break;
|
break;
|
||||||
case TTYCODE_STRING:
|
case TTYCODE_STRING:
|
||||||
strnvis(out, code->value.string,
|
strnvis(out, code->value.string, sizeof out,
|
||||||
sizeof out, VIS_OCTAL|VIS_WHITE);
|
VIS_OCTAL|VIS_TAB|VIS_NL);
|
||||||
out[(sizeof out) - 1] = '\0';
|
|
||||||
|
|
||||||
ctx->print(ctx, "%2u: %s: (string) %s",
|
ctx->print(ctx, "%2u: %s: (string) %s",
|
||||||
ent->code, ent->name, out);
|
ent->code, ent->name, out);
|
||||||
break;
|
break;
|
||||||
@@ -176,7 +171,13 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx->print(ctx, "");
|
ctx->print(ctx, "%s", "");
|
||||||
|
|
||||||
|
ctx->print(ctx, "Jobs:");
|
||||||
|
LIST_FOREACH(job, &all_jobs, lentry) {
|
||||||
|
ctx->print(ctx, "%s [fd=%d, pid=%d, status=%d]",
|
||||||
|
job->cmd, job->fd, job->pid, job->status);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-buffer.c,v 1.7 2009-01-25 18:51:28 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,47 +18,58 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add or set a session paste buffer.
|
* Add or set a paste buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_buffer_entry = {
|
const struct cmd_entry cmd_set_buffer_entry = {
|
||||||
"set-buffer", "setb",
|
"set-buffer", "setb",
|
||||||
CMD_BUFFER_SESSION_USAGE " data",
|
"b:", 1, 1,
|
||||||
CMD_ARG1,
|
CMD_BUFFER_USAGE " data",
|
||||||
cmd_buffer_init,
|
0,
|
||||||
cmd_buffer_parse,
|
NULL,
|
||||||
cmd_set_buffer_exec,
|
NULL,
|
||||||
cmd_buffer_send,
|
cmd_set_buffer_exec
|
||||||
cmd_buffer_recv,
|
|
||||||
cmd_buffer_free,
|
|
||||||
cmd_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
u_int limit;
|
||||||
u_int limit;
|
char *pdata, *cause;
|
||||||
|
size_t psize;
|
||||||
|
int buffer;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
return (-1);
|
|
||||||
|
|
||||||
limit = options_get_number(&s->options, "buffer-limit");
|
pdata = xstrdup(args->argv[0]);
|
||||||
if (data->buffer == -1) {
|
psize = strlen(pdata);
|
||||||
paste_add(&s->buffers, xstrdup(data->arg), limit);
|
|
||||||
|
if (!args_has(args, 'b')) {
|
||||||
|
paste_add(&global_buffers, pdata, psize, limit);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (paste_replace(&s->buffers, data->buffer, xstrdup(data->arg)) != 0) {
|
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
xfree(pdata);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
||||||
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
|
xfree(pdata);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
94
cmd-set-environment.c
Normal file
94
cmd-set-environment.c
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set an environment variable.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_set_environment_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_set_environment_entry = {
|
||||||
|
"set-environment", "setenv",
|
||||||
|
"grt:u", 1, 2,
|
||||||
|
"[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_set_environment_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct session *s;
|
||||||
|
struct environ *env;
|
||||||
|
const char *name, *value;
|
||||||
|
|
||||||
|
name = args->argv[0];
|
||||||
|
if (*name == '\0') {
|
||||||
|
ctx->error(ctx, "empty variable name");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (strchr(name, '=') != NULL) {
|
||||||
|
ctx->error(ctx, "variable name contains =");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args->argc < 1)
|
||||||
|
value = NULL;
|
||||||
|
else
|
||||||
|
value = args->argv[1];
|
||||||
|
|
||||||
|
if (args_has(self->args, 'g'))
|
||||||
|
env = &global_environ;
|
||||||
|
else {
|
||||||
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
env = &s->environ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(self->args, 'u')) {
|
||||||
|
if (value != NULL) {
|
||||||
|
ctx->error(ctx, "can't specify a value with -u");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
environ_unset(env, name);
|
||||||
|
} else if (args_has(self->args, 'r')) {
|
||||||
|
if (value != NULL) {
|
||||||
|
ctx->error(ctx, "can't specify a value with -r");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
environ_set(env, name, NULL);
|
||||||
|
} else {
|
||||||
|
if (value == NULL) {
|
||||||
|
ctx->error(ctx, "no value specified");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
environ_set(env, name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
442
cmd-set-option.c
442
cmd-set-option.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-option.c,v 1.60 2009-03-21 12:44:06 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,135 +29,161 @@
|
|||||||
|
|
||||||
int cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
int cmd_set_option_find(const char *, const struct options_table_entry **,
|
||||||
|
const struct options_table_entry **);
|
||||||
|
|
||||||
|
int cmd_set_option_unset(struct cmd *, struct cmd_ctx *,
|
||||||
|
const struct options_table_entry *, struct options *,
|
||||||
|
const char *);
|
||||||
|
int cmd_set_option_set(struct cmd *, struct cmd_ctx *,
|
||||||
|
const struct options_table_entry *, struct options *,
|
||||||
|
const char *);
|
||||||
|
|
||||||
|
struct options_entry *cmd_set_option_string(struct cmd *, struct cmd_ctx *,
|
||||||
|
const struct options_table_entry *, struct options *,
|
||||||
|
const char *);
|
||||||
|
struct options_entry *cmd_set_option_number(struct cmd *, struct cmd_ctx *,
|
||||||
|
const struct options_table_entry *, struct options *,
|
||||||
|
const char *);
|
||||||
|
struct options_entry *cmd_set_option_key(struct cmd *, struct cmd_ctx *,
|
||||||
|
const struct options_table_entry *, struct options *,
|
||||||
|
const char *);
|
||||||
|
struct options_entry *cmd_set_option_colour(struct cmd *, struct cmd_ctx *,
|
||||||
|
const struct options_table_entry *, struct options *,
|
||||||
|
const char *);
|
||||||
|
struct options_entry *cmd_set_option_attributes(struct cmd *, struct cmd_ctx *,
|
||||||
|
const struct options_table_entry *, struct options *,
|
||||||
|
const char *);
|
||||||
|
struct options_entry *cmd_set_option_flag(struct cmd *, struct cmd_ctx *,
|
||||||
|
const struct options_table_entry *, struct options *,
|
||||||
|
const char *);
|
||||||
|
struct options_entry *cmd_set_option_choice(struct cmd *, struct cmd_ctx *,
|
||||||
|
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 = {
|
||||||
"set-option", "set",
|
"set-option", "set",
|
||||||
CMD_OPTION_SESSION_USAGE,
|
"agst:uw", 1, 2,
|
||||||
CMD_GFLAG|CMD_UFLAG,
|
"[-agsuw] [-t target-session|target-window] option [value]",
|
||||||
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_option_parse,
|
NULL,
|
||||||
cmd_set_option_exec,
|
cmd_set_option_exec
|
||||||
cmd_option_send,
|
|
||||||
cmd_option_recv,
|
|
||||||
cmd_option_free,
|
|
||||||
cmd_option_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *set_option_status_keys_list[] = {
|
const struct cmd_entry cmd_set_window_option_entry = {
|
||||||
"emacs", "vi", NULL
|
"set-window-option", "setw",
|
||||||
};
|
"agt:u", 1, 2,
|
||||||
const char *set_option_bell_action_list[] = {
|
"[-agu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
||||||
"none", "any", "current", NULL
|
0,
|
||||||
};
|
NULL,
|
||||||
const struct set_option_entry set_option_table[NSETOPTION] = {
|
NULL,
|
||||||
{ "bell-action", SET_OPTION_CHOICE, 0, 0, set_option_bell_action_list },
|
cmd_set_option_exec
|
||||||
{ "buffer-limit", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
|
||||||
{ "default-command", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "default-path", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "display-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
|
||||||
{ "history-limit", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "lock-after-time", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "message-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "message-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "message-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "prefix", SET_OPTION_KEY, 0, 0, NULL },
|
|
||||||
{ "repeat-time", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
|
||||||
{ "set-remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "set-titles", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "status", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "status-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "status-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "status-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "status-interval", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "status-keys", SET_OPTION_CHOICE, 0, 0, set_option_status_keys_list },
|
|
||||||
{ "status-left", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "status-left-length", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
|
||||||
{ "status-right", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "status-right-length", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Look for an option in all three tables. */
|
||||||
|
int
|
||||||
|
cmd_set_option_find(
|
||||||
|
const char *optstr, const struct options_table_entry **table,
|
||||||
|
const struct options_table_entry **oe)
|
||||||
|
{
|
||||||
|
static const struct options_table_entry *tables[] = {
|
||||||
|
server_options_table,
|
||||||
|
window_options_table,
|
||||||
|
session_options_table
|
||||||
|
};
|
||||||
|
const struct options_table_entry *oe_loop;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < nitems(tables); i++) {
|
||||||
|
for (oe_loop = tables[i]; oe_loop->name != NULL; oe_loop++) {
|
||||||
|
if (strncmp(oe_loop->name, optstr, strlen(optstr)) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* If already found, ambiguous. */
|
||||||
|
if (*oe != NULL)
|
||||||
|
return (-1);
|
||||||
|
*oe = oe_loop;
|
||||||
|
*table = tables[i];
|
||||||
|
|
||||||
|
/* Bail now if an exact match. */
|
||||||
|
if (strcmp((*oe)->name, optstr) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_option_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
const struct options_table_entry *table, *oe;
|
||||||
struct client *c;
|
struct session *s;
|
||||||
struct options *oo;
|
struct winlink *wl;
|
||||||
const struct set_option_entry *entry;
|
struct client *c;
|
||||||
u_int i;
|
struct options *oo;
|
||||||
|
const char *optstr, *valstr;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
if (data->flags & CMD_GFLAG)
|
/* Get the option name and value. */
|
||||||
oo = &global_options;
|
optstr = args->argv[0];
|
||||||
else {
|
if (*optstr == '\0') {
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
oo = &s->options;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*data->option == '\0') {
|
|
||||||
ctx->error(ctx, "invalid option");
|
ctx->error(ctx, "invalid option");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
if (args->argc < 2)
|
||||||
|
valstr = NULL;
|
||||||
|
else
|
||||||
|
valstr = args->argv[1];
|
||||||
|
|
||||||
entry = NULL;
|
/* Find the option entry, try each table. */
|
||||||
for (i = 0; i < NSETOPTION; i++) {
|
table = oe = NULL;
|
||||||
if (strncmp(set_option_table[i].name,
|
if (cmd_set_option_find(optstr, &table, &oe) != 0) {
|
||||||
data->option, strlen(data->option)) != 0)
|
ctx->error(ctx, "ambiguous option: %s", optstr);
|
||||||
continue;
|
return (-1);
|
||||||
if (entry != NULL) {
|
|
||||||
ctx->error(ctx, "ambiguous option: %s", data->option);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
entry = &set_option_table[i];
|
|
||||||
|
|
||||||
/* Bail now if an exact match. */
|
|
||||||
if (strcmp(entry->name, data->option) == 0)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (entry == NULL) {
|
if (oe == NULL) {
|
||||||
ctx->error(ctx, "unknown option: %s", data->option);
|
ctx->error(ctx, "unknown option: %s", optstr);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->flags & CMD_UFLAG) {
|
/* Work out the tree from the table. */
|
||||||
if (data->flags & CMD_GFLAG) {
|
if (table == server_options_table)
|
||||||
ctx->error(ctx,
|
oo = &global_options;
|
||||||
"can't unset global option: %s", entry->name);
|
else if (table == window_options_table) {
|
||||||
return (-1);
|
if (args_has(self->args, 'g'))
|
||||||
|
oo = &global_w_options;
|
||||||
|
else {
|
||||||
|
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
||||||
|
if (wl == NULL)
|
||||||
|
return (-1);
|
||||||
|
oo = &wl->window->options;
|
||||||
}
|
}
|
||||||
if (data->value != NULL) {
|
} else if (table == session_options_table) {
|
||||||
ctx->error(ctx,
|
if (args_has(self->args, 'g'))
|
||||||
"value passed to unset option: %s", entry->name);
|
oo = &global_s_options;
|
||||||
return (-1);
|
else {
|
||||||
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
|
if (s == NULL)
|
||||||
|
return (-1);
|
||||||
|
oo = &s->options;
|
||||||
}
|
}
|
||||||
|
|
||||||
options_remove(oo, entry->name);
|
|
||||||
ctx->info(ctx, "unset option: %s", entry->name);
|
|
||||||
} else {
|
} else {
|
||||||
switch (entry->type) {
|
ctx->error(ctx, "unknown table");
|
||||||
case SET_OPTION_STRING:
|
return (-1);
|
||||||
set_option_string(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_NUMBER:
|
|
||||||
set_option_number(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_KEY:
|
|
||||||
set_option_key(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_COLOUR:
|
|
||||||
set_option_colour(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_ATTRIBUTES:
|
|
||||||
set_option_attributes(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_FLAG:
|
|
||||||
set_option_flag(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_CHOICE:
|
|
||||||
set_option_choice(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Unset or set the option. */
|
||||||
|
if (args_has(args, 'u')) {
|
||||||
|
if (cmd_set_option_unset(self, ctx, oe, oo, valstr) != 0)
|
||||||
|
return (-1);
|
||||||
|
} else {
|
||||||
|
if (cmd_set_option_set(self, ctx, oe, oo, valstr) != 0)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update sizes and redraw. May not need it but meh. */
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
@@ -167,3 +193,207 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Unset an option. */
|
||||||
|
int
|
||||||
|
cmd_set_option_unset(struct cmd *self, struct cmd_ctx *ctx,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
|
||||||
|
if (args_has(args, 'g')) {
|
||||||
|
ctx->error(ctx, "can't unset global option: %s", oe->name);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (value != NULL) {
|
||||||
|
ctx->error(ctx, "value passed to unset option: %s", oe->name);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
options_remove(oo, oe->name);
|
||||||
|
ctx->info(ctx, "unset option: %s", oe->name);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set an option. */
|
||||||
|
int
|
||||||
|
cmd_set_option_set(struct cmd *self, struct cmd_ctx *ctx,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
|
{
|
||||||
|
struct options_entry *o;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
if (oe->type != OPTIONS_TABLE_FLAG && value == NULL) {
|
||||||
|
ctx->error(ctx, "empty value");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
o = NULL;
|
||||||
|
switch (oe->type) {
|
||||||
|
case OPTIONS_TABLE_STRING:
|
||||||
|
o = cmd_set_option_string(self, ctx, oe, oo, value);
|
||||||
|
break;
|
||||||
|
case OPTIONS_TABLE_NUMBER:
|
||||||
|
o = cmd_set_option_number(self, ctx, oe, oo, value);
|
||||||
|
break;
|
||||||
|
case OPTIONS_TABLE_KEY:
|
||||||
|
o = cmd_set_option_key(self, ctx, oe, oo, value);
|
||||||
|
break;
|
||||||
|
case OPTIONS_TABLE_COLOUR:
|
||||||
|
o = cmd_set_option_colour(self, ctx, oe, oo, value);
|
||||||
|
break;
|
||||||
|
case OPTIONS_TABLE_ATTRIBUTES:
|
||||||
|
o = cmd_set_option_attributes(self, ctx, oe, oo, value);
|
||||||
|
break;
|
||||||
|
case OPTIONS_TABLE_FLAG:
|
||||||
|
o = cmd_set_option_flag(self, ctx, oe, oo, value);
|
||||||
|
break;
|
||||||
|
case OPTIONS_TABLE_CHOICE:
|
||||||
|
o = cmd_set_option_choice(self, ctx, oe, oo, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (o == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
s = options_table_print_entry(oe, o);
|
||||||
|
ctx->info(ctx, "set option: %s -> %s", oe->name, s);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set a string option. */
|
||||||
|
struct options_entry *
|
||||||
|
cmd_set_option_string(struct cmd *self, unused struct cmd_ctx *ctx,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct options_entry *o;
|
||||||
|
char *oldval, *newval;
|
||||||
|
|
||||||
|
if (args_has(args, 'a')) {
|
||||||
|
oldval = options_get_string(oo, oe->name);
|
||||||
|
xasprintf(&newval, "%s%s", oldval, value);
|
||||||
|
} else
|
||||||
|
newval = xstrdup(value);
|
||||||
|
|
||||||
|
o = options_set_string(oo, oe->name, "%s", newval);
|
||||||
|
|
||||||
|
xfree(newval);
|
||||||
|
return (o);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set a number option. */
|
||||||
|
struct options_entry *
|
||||||
|
cmd_set_option_number(unused struct cmd *self, struct cmd_ctx *ctx,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
|
{
|
||||||
|
long long ll;
|
||||||
|
const char *errstr;
|
||||||
|
|
||||||
|
ll = strtonum(value, oe->minimum, oe->maximum, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
ctx->error(ctx, "value is %s: %s", errstr, value);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (options_set_number(oo, oe->name, ll));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set a key option. */
|
||||||
|
struct options_entry *
|
||||||
|
cmd_set_option_key(unused struct cmd *self, struct cmd_ctx *ctx,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
|
{
|
||||||
|
int key;
|
||||||
|
|
||||||
|
if ((key = key_string_lookup_string(value)) == KEYC_NONE) {
|
||||||
|
ctx->error(ctx, "bad key: %s", value);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (options_set_number(oo, oe->name, key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set a colour option. */
|
||||||
|
struct options_entry *
|
||||||
|
cmd_set_option_colour(unused struct cmd *self, struct cmd_ctx *ctx,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
|
{
|
||||||
|
int colour;
|
||||||
|
|
||||||
|
if ((colour = colour_fromstring(value)) == -1) {
|
||||||
|
ctx->error(ctx, "bad colour: %s", value);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (options_set_number(oo, oe->name, colour));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set an attributes option. */
|
||||||
|
struct options_entry *
|
||||||
|
cmd_set_option_attributes(unused struct cmd *self, struct cmd_ctx *ctx,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
|
{
|
||||||
|
int attr;
|
||||||
|
|
||||||
|
if ((attr = attributes_fromstring(value)) == -1) {
|
||||||
|
ctx->error(ctx, "bad attributes: %s", value);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (options_set_number(oo, oe->name, attr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set a flag option. */
|
||||||
|
struct options_entry *
|
||||||
|
cmd_set_option_flag(unused struct cmd *self, struct cmd_ctx *ctx,
|
||||||
|
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 ((value[0] == '1' && value[1] == '\0') ||
|
||||||
|
strcasecmp(value, "on") == 0 ||
|
||||||
|
strcasecmp(value, "yes") == 0)
|
||||||
|
flag = 1;
|
||||||
|
else if ((value[0] == '0' && value[1] == '\0') ||
|
||||||
|
strcasecmp(value, "off") == 0 ||
|
||||||
|
strcasecmp(value, "no") == 0)
|
||||||
|
flag = 0;
|
||||||
|
else {
|
||||||
|
ctx->error(ctx, "bad value: %s", value);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (options_set_number(oo, oe->name, flag));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set a choice option. */
|
||||||
|
struct options_entry *
|
||||||
|
cmd_set_option_choice(unused struct cmd *self, struct cmd_ctx *ctx,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
|
{
|
||||||
|
const char **choicep;
|
||||||
|
int n, choice = -1;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
for (choicep = oe->choices; *choicep != NULL; choicep++) {
|
||||||
|
n++;
|
||||||
|
if (strncmp(*choicep, value, strlen(value)) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (choice != -1) {
|
||||||
|
ctx->error(ctx, "ambiguous value: %s", value);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
choice = n - 1;
|
||||||
|
}
|
||||||
|
if (choice == -1) {
|
||||||
|
ctx->error(ctx, "unknown value: %s", value);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (options_set_number(oo, oe->name, choice));
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,169 +0,0 @@
|
|||||||
/* $Id: cmd-set-password.c,v 1.3 2009-01-19 18:23:40 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set server password.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_set_password_parse(struct cmd *, int, char **, char **);
|
|
||||||
int cmd_set_password_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_set_password_send(struct cmd *, struct buffer *);
|
|
||||||
void cmd_set_password_recv(struct cmd *, struct buffer *);
|
|
||||||
void cmd_set_password_free(struct cmd *);
|
|
||||||
void cmd_set_password_init(struct cmd *, int);
|
|
||||||
size_t cmd_set_password_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_set_password_data {
|
|
||||||
char *password;
|
|
||||||
int flag_encrypted;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_password_entry = {
|
|
||||||
"set-password", "pass",
|
|
||||||
"[-c] password",
|
|
||||||
0,
|
|
||||||
cmd_set_password_init,
|
|
||||||
cmd_set_password_parse,
|
|
||||||
cmd_set_password_exec,
|
|
||||||
cmd_set_password_send,
|
|
||||||
cmd_set_password_recv,
|
|
||||||
cmd_set_password_free,
|
|
||||||
cmd_set_password_print
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_set_password_init(struct cmd *self, unused int arg)
|
|
||||||
{
|
|
||||||
struct cmd_set_password_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->password = NULL;
|
|
||||||
data->flag_encrypted = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_set_password_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_set_password_data *data;
|
|
||||||
int opt;
|
|
||||||
char *out;
|
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "c")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'c':
|
|
||||||
data->flag_encrypted = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 1)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
if (!data->flag_encrypted) {
|
|
||||||
if ((out = crypt(argv[0], "$1")) != NULL)
|
|
||||||
data->password = xstrdup(out);
|
|
||||||
} else
|
|
||||||
data->password = xstrdup(argv[0]);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_set_password_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_set_password_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->password == NULL) {
|
|
||||||
ctx->error(ctx, "failed to encrypt password");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (server_password != NULL)
|
|
||||||
xfree(server_password);
|
|
||||||
if (*data->password == '\0')
|
|
||||||
server_password = NULL;
|
|
||||||
else
|
|
||||||
server_password = xstrdup(data->password);
|
|
||||||
log_debug("pw now %s", server_password);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_set_password_send(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_set_password_data *data = self->data;
|
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
|
||||||
cmd_send_string(b, data->password);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_set_password_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_set_password_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->password = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_set_password_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_set_password_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->password != NULL)
|
|
||||||
xfree(data->password);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_set_password_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_set_password_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->flag_encrypted)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -c");
|
|
||||||
if (off < len && data->password != NULL)
|
|
||||||
off += xsnprintf(buf + off, len - off, " password");
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
/* $Id: cmd-set-window-option.c,v 1.24 2009-01-30 00:24:49 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set a window option.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_set_window_option_parse(struct cmd *, int, char **, char **);
|
|
||||||
int cmd_set_window_option_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_set_window_option_send(struct cmd *, struct buffer *);
|
|
||||||
void cmd_set_window_option_recv(struct cmd *, struct buffer *);
|
|
||||||
void cmd_set_window_option_free(struct cmd *);
|
|
||||||
size_t cmd_set_window_option_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_window_option_entry = {
|
|
||||||
"set-window-option", "setw",
|
|
||||||
CMD_OPTION_WINDOW_USAGE,
|
|
||||||
CMD_GFLAG|CMD_UFLAG,
|
|
||||||
NULL,
|
|
||||||
cmd_option_parse,
|
|
||||||
cmd_set_window_option_exec,
|
|
||||||
cmd_option_send,
|
|
||||||
cmd_option_recv,
|
|
||||||
cmd_option_free,
|
|
||||||
cmd_option_print
|
|
||||||
};
|
|
||||||
|
|
||||||
const char *set_option_mode_keys_list[] = {
|
|
||||||
"emacs", "vi", NULL
|
|
||||||
};
|
|
||||||
const char *set_option_clock_mode_style_list[] = {
|
|
||||||
"12", "24", NULL
|
|
||||||
};
|
|
||||||
const struct set_option_entry set_window_option_table[NSETWINDOWOPTION] = {
|
|
||||||
{ "aggressive-resize", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "automatic-rename", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "clock-mode-colour", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "clock-mode-style",
|
|
||||||
SET_OPTION_CHOICE, 0, 0, set_option_clock_mode_style_list },
|
|
||||||
{ "force-height", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "force-width", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "mode-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "mode-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "mode-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "mode-keys", SET_OPTION_CHOICE, 0, 0, set_option_mode_keys_list },
|
|
||||||
{ "monitor-activity", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "utf8", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "window-status-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "window-status-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "window-status-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "xterm-keys", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_option_data *data = self->data;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct client *c;
|
|
||||||
struct options *oo;
|
|
||||||
const struct set_option_entry *entry;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
if (data->flags & CMD_GFLAG)
|
|
||||||
oo = &global_window_options;
|
|
||||||
else {
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
oo = &wl->window->options;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*data->option == '\0') {
|
|
||||||
ctx->error(ctx, "invalid option");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
entry = NULL;
|
|
||||||
for (i = 0; i < NSETWINDOWOPTION; i++) {
|
|
||||||
if (strncmp(set_window_option_table[i].name,
|
|
||||||
data->option, strlen(data->option)) != 0)
|
|
||||||
continue;
|
|
||||||
if (entry != NULL) {
|
|
||||||
ctx->error(ctx, "ambiguous option: %s", data->option);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
entry = &set_window_option_table[i];
|
|
||||||
|
|
||||||
/* Bail now if an exact match. */
|
|
||||||
if (strcmp(entry->name, data->option) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (entry == NULL) {
|
|
||||||
ctx->error(ctx, "unknown option: %s", data->option);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->flags & CMD_UFLAG) {
|
|
||||||
if (data->flags & CMD_GFLAG) {
|
|
||||||
ctx->error(ctx,
|
|
||||||
"can't unset global option: %s", entry->name);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (data->value != NULL) {
|
|
||||||
ctx->error(ctx,
|
|
||||||
"value passed to unset option: %s", entry->name);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
options_remove(oo, entry->name);
|
|
||||||
ctx->info(ctx, "unset option: %s", entry->name);
|
|
||||||
} else {
|
|
||||||
switch (entry->type) {
|
|
||||||
case SET_OPTION_STRING:
|
|
||||||
set_option_string(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_NUMBER:
|
|
||||||
set_option_number(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_KEY:
|
|
||||||
set_option_key(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_COLOUR:
|
|
||||||
set_option_colour(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_ATTRIBUTES:
|
|
||||||
set_option_attributes(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_FLAG:
|
|
||||||
set_option_flag(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_CHOICE:
|
|
||||||
set_option_choice(ctx, oo, entry, data->value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
recalculate_sizes();
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
|
||||||
c = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c != NULL && c->session != NULL)
|
|
||||||
server_redraw_client(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-show-buffer.c,v 1.4 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,72 +18,92 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show a session paste buffer.
|
* Show a paste buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_buffer_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_show_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_buffer_entry = {
|
const struct cmd_entry cmd_show_buffer_entry = {
|
||||||
"show-buffer", "showb",
|
"show-buffer", "showb",
|
||||||
CMD_BUFFER_SESSION_USAGE,
|
"b:", 0, 0,
|
||||||
|
CMD_BUFFER_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_buffer_init,
|
NULL,
|
||||||
cmd_buffer_parse,
|
NULL,
|
||||||
cmd_show_buffer_exec,
|
cmd_show_buffer_exec
|
||||||
cmd_buffer_send,
|
|
||||||
cmd_buffer_recv,
|
|
||||||
cmd_buffer_free,
|
|
||||||
cmd_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
u_int size;
|
int buffer;
|
||||||
char *buf, *ptr;
|
char *in, *buf, *ptr, *cause;
|
||||||
size_t len;
|
size_t size, len;
|
||||||
|
u_int width;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(ctx, NULL, 0)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (data->buffer == -1) {
|
if (!args_has(args, 'b')) {
|
||||||
if ((pb = paste_get_top(&s->buffers)) == NULL) {
|
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
||||||
ctx->error(ctx, "no buffers");
|
ctx->error(ctx, "no buffers");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
} else if ((pb = paste_get_index(&s->buffers, data->buffer)) == NULL) {
|
} else {
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
return (-1);
|
if (cause != NULL) {
|
||||||
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
pb = paste_get_index(&global_buffers, buffer);
|
||||||
|
if (pb == NULL) {
|
||||||
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb != NULL) {
|
size = pb->size;
|
||||||
size = s->sx;
|
if (size > SIZE_MAX / 4 - 1)
|
||||||
|
size = SIZE_MAX / 4 - 1;
|
||||||
|
in = xmalloc(size * 4 + 1);
|
||||||
|
strvisx(in, pb->data, size, VIS_OCTAL|VIS_TAB);
|
||||||
|
|
||||||
buf = xmalloc(size + 1);
|
width = s->sx;
|
||||||
len = 0;
|
if (ctx->cmdclient != NULL)
|
||||||
|
width = ctx->cmdclient->tty.sx;
|
||||||
|
|
||||||
ptr = pb->data;
|
buf = xmalloc(width + 1);
|
||||||
do {
|
len = 0;
|
||||||
buf[len++] = *ptr++;
|
|
||||||
|
|
||||||
if (len == size) {
|
ptr = in;
|
||||||
buf[len] = '\0';
|
do {
|
||||||
ctx->print(ctx, buf);
|
buf[len++] = *ptr++;
|
||||||
|
|
||||||
len = 0;
|
if (len == width || buf[len - 1] == '\n') {
|
||||||
}
|
if (buf[len - 1] == '\n')
|
||||||
} while (*ptr != '\0');
|
len--;
|
||||||
|
buf[len] = '\0';
|
||||||
|
|
||||||
|
ctx->print(ctx, "%s", buf);
|
||||||
|
len = 0;
|
||||||
|
}
|
||||||
|
} while (*ptr != '\0');
|
||||||
|
|
||||||
|
if (len != 0) {
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
ctx->print(ctx, buf);
|
ctx->print(ctx, "%s", buf);
|
||||||
}
|
}
|
||||||
|
xfree(buf);
|
||||||
|
|
||||||
|
xfree(in);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
66
cmd-show-environment.c
Normal file
66
cmd-show-environment.c
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Show environment.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_show_environment_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_show_environment_entry = {
|
||||||
|
"show-environment", "showenv",
|
||||||
|
"gt:", 0, 0,
|
||||||
|
"[-g] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_show_environment_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct session *s;
|
||||||
|
struct environ *env;
|
||||||
|
struct environ_entry *envent;
|
||||||
|
|
||||||
|
if (args_has(self->args, 'g'))
|
||||||
|
env = &global_environ;
|
||||||
|
else {
|
||||||
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
env = &s->environ;
|
||||||
|
}
|
||||||
|
|
||||||
|
RB_FOREACH(envent, environ, env) {
|
||||||
|
if (envent->value != NULL)
|
||||||
|
ctx->print(ctx, "%s=%s", envent->name, envent->value);
|
||||||
|
else
|
||||||
|
ctx->print(ctx, "-%s", envent->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-up-pane.c,v 1.7 2009-04-01 21:10:08 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,44 +18,47 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move up a pane.
|
* Show client message log.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_up_pane_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_show_messages_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_up_pane_entry = {
|
const struct cmd_entry cmd_show_messages_entry = {
|
||||||
"up-pane", "upp",
|
"show-messages", "showmsgs",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_up_pane_exec,
|
cmd_show_messages_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_up_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct client *c;
|
||||||
struct window *w;
|
struct message_entry *msg;
|
||||||
|
char *tim;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
|
||||||
|
|
||||||
do {
|
for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
|
||||||
w->active = TAILQ_PREV(w->active, window_panes, entry);
|
msg = &ARRAY_ITEM(&c->message_log, i);
|
||||||
if (w->active == NULL)
|
|
||||||
w->active = TAILQ_LAST(&w->panes, window_panes);
|
tim = ctime(&msg->msg_time);
|
||||||
layout_refresh(w, 1);
|
*strchr(tim, '\n') = '\0';
|
||||||
} while (w->active->flags & PANE_HIDDEN);
|
|
||||||
|
ctx->print(ctx, "%s %s", tim, msg->msg);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-show-options.c,v 1.11 2009-01-27 20:22:33 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,79 +31,66 @@ int cmd_show_options_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_show_options_entry = {
|
const struct cmd_entry cmd_show_options_entry = {
|
||||||
"show-options", "show",
|
"show-options", "show",
|
||||||
"[-g] " CMD_TARGET_SESSION_USAGE,
|
"gst:w", 0, 0,
|
||||||
CMD_GFLAG,
|
"[-gsw] [-t target-session|target-window]",
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_show_options_exec,
|
NULL,
|
||||||
cmd_target_send,
|
cmd_show_options_exec
|
||||||
cmd_target_recv,
|
};
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
const struct cmd_entry cmd_show_window_options_entry = {
|
||||||
|
"show-window-options", "showw",
|
||||||
|
"gt:", 0, 0,
|
||||||
|
"[-g] " CMD_TARGET_WINDOW_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
cmd_show_options_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
const struct options_table_entry *table, *oe;
|
||||||
struct options *oo;
|
struct session *s;
|
||||||
const struct set_option_entry *entry;
|
struct winlink *wl;
|
||||||
u_int i;
|
struct options *oo;
|
||||||
char *vs;
|
struct options_entry *o;
|
||||||
long long vn;
|
const char *optval;
|
||||||
|
|
||||||
if (data->flags & CMD_GFLAG)
|
if (args_has(self->args, 's')) {
|
||||||
oo = &global_options;
|
oo = &global_options;
|
||||||
else {
|
table = server_options_table;
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
} else if (args_has(self->args, 'w') ||
|
||||||
return (-1);
|
self->entry == &cmd_show_window_options_entry) {
|
||||||
oo = &s->options;
|
table = window_options_table;
|
||||||
|
if (args_has(self->args, 'g'))
|
||||||
|
oo = &global_w_options;
|
||||||
|
else {
|
||||||
|
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
||||||
|
if (wl == NULL)
|
||||||
|
return (-1);
|
||||||
|
oo = &wl->window->options;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
table = session_options_table;
|
||||||
|
if (args_has(self->args, 'g'))
|
||||||
|
oo = &global_s_options;
|
||||||
|
else {
|
||||||
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
|
if (s == NULL)
|
||||||
|
return (-1);
|
||||||
|
oo = &s->options;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < NSETOPTION; i++) {
|
for (oe = table; oe->name != NULL; oe++) {
|
||||||
entry = &set_option_table[i];
|
if ((o = options_find1(oo, oe->name)) == NULL)
|
||||||
|
|
||||||
if (options_find1(oo, entry->name) == NULL)
|
|
||||||
continue;
|
continue;
|
||||||
|
optval = options_table_print_entry(oe, o);
|
||||||
switch (entry->type) {
|
ctx->print(ctx, "%s %s", oe->name, optval);
|
||||||
case SET_OPTION_STRING:
|
|
||||||
vs = options_get_string(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s \"%s\"", entry->name, vs);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_NUMBER:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s %lld", entry->name, vn);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_KEY:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s %s",
|
|
||||||
entry->name, key_string_lookup_key(vn));
|
|
||||||
break;
|
|
||||||
case SET_OPTION_COLOUR:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s %s",
|
|
||||||
entry->name, colour_tostring(vn));
|
|
||||||
break;
|
|
||||||
case SET_OPTION_ATTRIBUTES:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s %s",
|
|
||||||
entry->name, attributes_tostring(vn));
|
|
||||||
break;
|
|
||||||
case SET_OPTION_FLAG:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
if (vn)
|
|
||||||
ctx->print(ctx, "%s on", entry->name);
|
|
||||||
else
|
|
||||||
ctx->print(ctx, "%s off", entry->name);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_CHOICE:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s %s",
|
|
||||||
entry->name, entry->choices[vn]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
/* $Id: cmd-show-window-options.c,v 1.7 2009-01-27 20:22:33 nicm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Show window options.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_show_window_options_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_window_options_entry = {
|
|
||||||
"show-window-options", "showw",
|
|
||||||
"[-g] " CMD_TARGET_WINDOW_USAGE,
|
|
||||||
CMD_GFLAG,
|
|
||||||
cmd_target_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_show_window_options_exec,
|
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_show_window_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct options *oo;
|
|
||||||
const struct set_option_entry *entry;
|
|
||||||
u_int i;
|
|
||||||
char *vs;
|
|
||||||
long long vn;
|
|
||||||
|
|
||||||
if (data->flags & CMD_GFLAG)
|
|
||||||
oo = &global_window_options;
|
|
||||||
else {
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
oo = &wl->window->options;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < NSETWINDOWOPTION; i++) {
|
|
||||||
entry = &set_window_option_table[i];
|
|
||||||
|
|
||||||
if (options_find1(oo, entry->name) == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
switch (entry->type) {
|
|
||||||
case SET_OPTION_STRING:
|
|
||||||
vs = options_get_string(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s \"%s\"", entry->name, vs);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_NUMBER:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s %lld", entry->name, vn);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_KEY:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s %s",
|
|
||||||
entry->name, key_string_lookup_key(vn));
|
|
||||||
break;
|
|
||||||
case SET_OPTION_COLOUR:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s %s",
|
|
||||||
entry->name, colour_tostring(vn));
|
|
||||||
break;
|
|
||||||
case SET_OPTION_ATTRIBUTES:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s %s",
|
|
||||||
entry->name, attributes_tostring(vn));
|
|
||||||
break;
|
|
||||||
case SET_OPTION_FLAG:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
if (vn)
|
|
||||||
ctx->print(ctx, "%s on", entry->name);
|
|
||||||
else
|
|
||||||
ctx->print(ctx, "%s off", entry->name);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_CHOICE:
|
|
||||||
vn = options_get_number(oo, entry->name);
|
|
||||||
ctx->print(ctx, "%s %s",
|
|
||||||
entry->name, entry->choices[vn]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-source-file.c,v 1.5 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -24,124 +24,51 @@
|
|||||||
* Sources a configuration file.
|
* Sources a configuration file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_source_file_parse(struct cmd *, int, char **, char **);
|
|
||||||
int cmd_source_file_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_source_file_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_source_file_send(struct cmd *, struct buffer *);
|
|
||||||
void cmd_source_file_recv(struct cmd *, struct buffer *);
|
|
||||||
void cmd_source_file_free(struct cmd *);
|
|
||||||
void cmd_source_file_init(struct cmd *, int);
|
|
||||||
size_t cmd_source_file_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_source_file_data {
|
|
||||||
char *path;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_source_file_entry = {
|
const struct cmd_entry cmd_source_file_entry = {
|
||||||
"source-file", "source",
|
"source-file", "source",
|
||||||
|
"", 1, 1,
|
||||||
"path",
|
"path",
|
||||||
0,
|
0,
|
||||||
cmd_source_file_init,
|
NULL,
|
||||||
cmd_source_file_parse,
|
NULL,
|
||||||
cmd_source_file_exec,
|
cmd_source_file_exec
|
||||||
cmd_source_file_send,
|
|
||||||
cmd_source_file_recv,
|
|
||||||
cmd_source_file_free,
|
|
||||||
cmd_source_file_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
|
||||||
cmd_source_file_init(struct cmd *self, unused int arg)
|
|
||||||
{
|
|
||||||
struct cmd_source_file_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->path = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_source_file_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_source_file_data *data;
|
|
||||||
int opt;
|
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 1)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
data->path = xstrdup(argv[0]);
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_source_file_data *data = self->data;
|
struct args *args = self->args;
|
||||||
char *cause;
|
struct causelist causes;
|
||||||
|
char *cause;
|
||||||
|
struct window_pane *wp;
|
||||||
|
int retval;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
if (load_cfg(data->path, &cause) != 0) {
|
ARRAY_INIT(&causes);
|
||||||
ctx->error(ctx, "%s", cause);
|
|
||||||
xfree(cause);
|
retval = load_cfg(args->argv[0], ctx, &causes);
|
||||||
return (-1);
|
if (ARRAY_EMPTY(&causes))
|
||||||
|
return (retval);
|
||||||
|
|
||||||
|
if (retval == 1 && !RB_EMPTY(&sessions) && ctx->cmdclient != NULL) {
|
||||||
|
wp = RB_MIN(sessions, &sessions)->curw->window->active;
|
||||||
|
window_pane_set_mode(wp, &window_copy_mode);
|
||||||
|
window_copy_init_for_output(wp);
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&causes); i++) {
|
||||||
|
cause = ARRAY_ITEM(&causes, i);
|
||||||
|
window_copy_add(wp, "%s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&causes); i++) {
|
||||||
|
cause = ARRAY_ITEM(&causes, i);
|
||||||
|
ctx->print(ctx, "%s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
ARRAY_FREE(&causes);
|
||||||
|
|
||||||
return (0);
|
return (retval);
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_source_file_send(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_source_file_data *data = self->data;
|
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
|
||||||
cmd_send_string(b, data->path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_source_file_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_source_file_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->path = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_source_file_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_source_file_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->path != NULL)
|
|
||||||
xfree(data->path);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_source_file_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_source_file_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->path != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->path);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-split-window.c,v 1.12 2009-04-03 17:21:46 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -27,209 +27,123 @@
|
|||||||
* Split a window (add a new pane).
|
* Split a window (add a new pane).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_split_window_parse(struct cmd *, int, char **, char **);
|
void cmd_split_window_key_binding(struct cmd *, int);
|
||||||
int cmd_split_window_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_split_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_split_window_send(struct cmd *, struct buffer *);
|
|
||||||
void cmd_split_window_recv(struct cmd *, struct buffer *);
|
|
||||||
void cmd_split_window_free(struct cmd *);
|
|
||||||
void cmd_split_window_init(struct cmd *, int);
|
|
||||||
size_t cmd_split_window_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_split_window_data {
|
|
||||||
char *target;
|
|
||||||
char *cmd;
|
|
||||||
int flag_detached;
|
|
||||||
int percentage;
|
|
||||||
int lines;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_split_window_entry = {
|
const struct cmd_entry cmd_split_window_entry = {
|
||||||
"split-window", "splitw",
|
"split-window", "splitw",
|
||||||
"[-d] [-p percentage|-l lines] [-t target-window] [command]",
|
"dl:hp:Pt:v", 0, 1,
|
||||||
|
"[-dhvP] [-p percentage|-l size] [-t target-pane] [command]",
|
||||||
0,
|
0,
|
||||||
cmd_split_window_init,
|
cmd_split_window_key_binding,
|
||||||
cmd_split_window_parse,
|
NULL,
|
||||||
cmd_split_window_exec,
|
cmd_split_window_exec
|
||||||
cmd_split_window_send,
|
|
||||||
cmd_split_window_recv,
|
|
||||||
cmd_split_window_free,
|
|
||||||
cmd_split_window_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_split_window_init(struct cmd *self, unused int arg)
|
cmd_split_window_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_split_window_data *data;
|
self->args = args_create(0);
|
||||||
|
if (key == '%')
|
||||||
self->data = data = xmalloc(sizeof *data);
|
args_set(self->args, 'h', NULL);
|
||||||
data->target = NULL;
|
|
||||||
data->cmd = NULL;
|
|
||||||
data->flag_detached = 0;
|
|
||||||
data->percentage = -1;
|
|
||||||
data->lines = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_split_window_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_split_window_data *data;
|
|
||||||
int opt, n;
|
|
||||||
const char *errstr;
|
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "dl:p:t:")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'd':
|
|
||||||
data->flag_detached = 1;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
if (data->percentage == -1 && data->lines == -1) {
|
|
||||||
n = strtonum(optarg, 1, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "lines %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->lines = n;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
if (data->lines == -1 && data->percentage == -1) {
|
|
||||||
n = strtonum(optarg, 1, 100, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(
|
|
||||||
cause, "percentage %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->percentage = n;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 0 && argc != 1)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
if (argc == 1)
|
|
||||||
data->cmd = xstrdup(argv[0]);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
error:
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_split_window_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp, *new_wp = NULL;
|
||||||
const char **env;
|
struct environ env;
|
||||||
char *cmd, *cwd, *cause;
|
const char *cmd, *cwd, *shell;
|
||||||
u_int hlimit, lines;
|
char *cause, *new_cause;
|
||||||
|
u_int hlimit, paneidx;
|
||||||
|
int size, percentage;
|
||||||
|
enum layout_type type;
|
||||||
|
struct layout_cell *lc;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
env = server_fill_environ(s);
|
environ_init(&env);
|
||||||
|
environ_copy(&global_environ, &env);
|
||||||
|
environ_copy(&s->environ, &env);
|
||||||
|
server_fill_environ(s, &env);
|
||||||
|
|
||||||
cmd = data->cmd;
|
if (args->argc == 0)
|
||||||
if (cmd == NULL)
|
|
||||||
cmd = options_get_string(&s->options, "default-command");
|
cmd = options_get_string(&s->options, "default-command");
|
||||||
if (ctx->cmdclient == NULL || ctx->cmdclient->cwd == NULL)
|
|
||||||
cwd = options_get_string(&global_options, "default-path");
|
|
||||||
else
|
else
|
||||||
cwd = ctx->cmdclient->cwd;
|
cmd = args->argv[0];
|
||||||
|
cwd = cmd_get_default_path(ctx);
|
||||||
|
|
||||||
lines = -1;
|
type = LAYOUT_TOPBOTTOM;
|
||||||
if (data->lines != -1)
|
if (args_has(args, 'h'))
|
||||||
lines = data->lines;
|
type = LAYOUT_LEFTRIGHT;
|
||||||
else if (data->percentage != -1)
|
|
||||||
lines = (w->active->sy * data->percentage) / 100;
|
|
||||||
|
|
||||||
hlimit = options_get_number(&s->options, "history-limit");
|
size = -1;
|
||||||
wp = window_add_pane(w, lines, cmd, cwd, env, hlimit, &cause);
|
if (args_has(args, 'l')) {
|
||||||
if (wp == NULL) {
|
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
||||||
ctx->error(ctx, "create pane failed: %s", cause);
|
if (cause != NULL) {
|
||||||
xfree(cause);
|
xasprintf(&new_cause, "size %s", cause);
|
||||||
return (-1);
|
xfree(cause);
|
||||||
|
cause = new_cause;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
} else if (args_has(args, 'p')) {
|
||||||
|
percentage = args_strtonum(args, 'p', 0, INT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
xasprintf(&new_cause, "percentage %s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
cause = new_cause;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
|
size = (wp->sy * percentage) / 100;
|
||||||
|
else
|
||||||
|
size = (wp->sx * percentage) / 100;
|
||||||
}
|
}
|
||||||
|
hlimit = options_get_number(&s->options, "history-limit");
|
||||||
|
|
||||||
|
shell = options_get_string(&s->options, "default-shell");
|
||||||
|
if (*shell == '\0' || areshell(shell))
|
||||||
|
shell = _PATH_BSHELL;
|
||||||
|
|
||||||
|
if ((lc = layout_split_pane(wp, type, size)) == NULL) {
|
||||||
|
cause = xstrdup("pane too small");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
new_wp = window_add_pane(w, hlimit);
|
||||||
|
if (window_pane_spawn(
|
||||||
|
new_wp, cmd, shell, cwd, &env, s->tio, &cause) != 0)
|
||||||
|
goto error;
|
||||||
|
layout_assign_pane(lc, new_wp);
|
||||||
|
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
|
|
||||||
if (!data->flag_detached) {
|
if (!args_has(args, 'd')) {
|
||||||
window_set_active_pane(w, wp);
|
window_set_active_pane(w, new_wp);
|
||||||
session_select(s, wl->idx);
|
session_select(s, wl->idx);
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
} else
|
} else
|
||||||
server_status_session(s);
|
server_status_session(s);
|
||||||
layout_refresh(w, 0);
|
|
||||||
|
|
||||||
|
environ_free(&env);
|
||||||
|
|
||||||
|
if (args_has(args, 'P')) {
|
||||||
|
if (window_pane_index(new_wp, &paneidx) != 0)
|
||||||
|
fatalx("index not found");
|
||||||
|
ctx->print(ctx, "%s:%u.%u", s->name, wl->idx, paneidx);
|
||||||
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
|
||||||
|
error:
|
||||||
void
|
environ_free(&env);
|
||||||
cmd_split_window_send(struct cmd *self, struct buffer *b)
|
if (new_wp != NULL)
|
||||||
{
|
window_remove_pane(w, new_wp);
|
||||||
struct cmd_split_window_data *data = self->data;
|
ctx->error(ctx, "create pane failed: %s", cause);
|
||||||
|
xfree(cause);
|
||||||
buffer_write(b, data, sizeof *data);
|
return (-1);
|
||||||
cmd_send_string(b, data->target);
|
|
||||||
cmd_send_string(b, data->cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_split_window_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_split_window_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->target = cmd_recv_string(b);
|
|
||||||
data->cmd = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_split_window_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_split_window_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
if (data->cmd != NULL)
|
|
||||||
xfree(data->cmd);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_split_window_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_split_window_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->flag_detached)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -d");
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->cmd != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->cmd);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-start-server.c,v 1.6 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,17 +28,15 @@ int cmd_start_server_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_start_server_entry = {
|
const struct cmd_entry cmd_start_server_entry = {
|
||||||
"start-server", "start",
|
"start-server", "start",
|
||||||
|
"", 0, 0,
|
||||||
"",
|
"",
|
||||||
CMD_STARTSERVER,
|
CMD_STARTSERVER,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_start_server_exec,
|
cmd_start_server_exec
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
cmd_start_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_start_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
|
|||||||
171
cmd-string.c
171
cmd-string.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-string.c,v 1.13 2009-02-16 19:29:17 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -19,9 +19,11 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -30,20 +32,23 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_string_getc(const char *, size_t *);
|
int cmd_string_getc(const char *, size_t *);
|
||||||
void cmd_string_ungetc(const char *, size_t *);
|
void cmd_string_ungetc(size_t *);
|
||||||
char *cmd_string_string(const char *, size_t *, char, int);
|
char *cmd_string_string(const char *, size_t *, char, int);
|
||||||
char *cmd_string_variable(const char *, size_t *);
|
char *cmd_string_variable(const char *, size_t *);
|
||||||
|
char *cmd_string_expand_tilde(const char *, size_t *);
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_string_getc(const char *s, size_t *p)
|
cmd_string_getc(const char *s, size_t *p)
|
||||||
{
|
{
|
||||||
if (s[*p] == '\0')
|
const u_char *ucs = s;
|
||||||
|
|
||||||
|
if (ucs[*p] == '\0')
|
||||||
return (EOF);
|
return (EOF);
|
||||||
return (s[(*p)++]);
|
return (ucs[(*p)++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_string_ungetc(unused const char *s, size_t *p)
|
cmd_string_ungetc(size_t *p)
|
||||||
{
|
{
|
||||||
(*p)--;
|
(*p)--;
|
||||||
}
|
}
|
||||||
@@ -56,29 +61,17 @@ int
|
|||||||
cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
||||||
{
|
{
|
||||||
size_t p;
|
size_t p;
|
||||||
int ch, argc, rval, have_arg;
|
int ch, i, argc, rval;
|
||||||
char **argv, *buf, *t, *u;
|
char **argv, *buf, *t;
|
||||||
|
const char *whitespace, *equals;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if ((t = strchr(s, ' ')) == NULL && (t = strchr(s, '\t')) == NULL)
|
|
||||||
t = strchr(s, '\0');
|
|
||||||
if ((u = strchr(s, '=')) != NULL && u < t) {
|
|
||||||
if (putenv(s) != 0) {
|
|
||||||
xasprintf(cause, "assignment failed: %s", s);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
*cmdlist = NULL;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
argv = NULL;
|
argv = NULL;
|
||||||
argc = 0;
|
argc = 0;
|
||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
have_arg = 0;
|
|
||||||
|
|
||||||
*cause = NULL;
|
*cause = NULL;
|
||||||
|
|
||||||
*cmdlist = NULL;
|
*cmdlist = NULL;
|
||||||
@@ -95,8 +88,6 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
xfree(t);
|
xfree(t);
|
||||||
|
|
||||||
have_arg = 1;
|
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
|
if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
|
||||||
@@ -105,8 +96,6 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
xfree(t);
|
xfree(t);
|
||||||
|
|
||||||
have_arg = 1;
|
|
||||||
break;
|
break;
|
||||||
case '$':
|
case '$':
|
||||||
if ((t = cmd_string_variable(s, &p)) == NULL)
|
if ((t = cmd_string_variable(s, &p)) == NULL)
|
||||||
@@ -114,8 +103,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
|
xfree(t);
|
||||||
have_arg = 1;
|
|
||||||
break;
|
break;
|
||||||
case '#':
|
case '#':
|
||||||
/* Comment: discard rest of line. */
|
/* Comment: discard rest of line. */
|
||||||
@@ -125,7 +113,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
case EOF:
|
case EOF:
|
||||||
case ' ':
|
case ' ':
|
||||||
case '\t':
|
case '\t':
|
||||||
if (have_arg) {
|
if (buf != NULL) {
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, 1, len + 1);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
@@ -134,12 +122,20 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
have_arg = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch != EOF)
|
if (ch != EOF)
|
||||||
break;
|
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));
|
||||||
|
}
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@@ -147,20 +143,25 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
if (*cmdlist == NULL)
|
if (*cmdlist == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
do
|
|
||||||
xfree(argv[argc - 1]);
|
|
||||||
while (--argc > 0);
|
|
||||||
|
|
||||||
rval = 0;
|
rval = 0;
|
||||||
goto out;
|
goto out;
|
||||||
|
case '~':
|
||||||
|
if (buf == NULL) {
|
||||||
|
if ((t = cmd_string_expand_tilde(s, &p)) == NULL)
|
||||||
|
goto error;
|
||||||
|
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
||||||
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
|
len += strlen(t);
|
||||||
|
xfree(t);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* FALLTHROUGH */
|
||||||
default:
|
default:
|
||||||
if (len >= SIZE_MAX - 2)
|
if (len >= SIZE_MAX - 2)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, 1, len + 1);
|
||||||
buf[len++] = ch;
|
buf[len++] = ch;
|
||||||
|
|
||||||
have_arg = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,10 +173,11 @@ out:
|
|||||||
if (buf != NULL)
|
if (buf != NULL)
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
|
|
||||||
while (--argc >= 0)
|
if (argv != NULL) {
|
||||||
xfree(argv[argc]);
|
for (i = 0; i < argc; i++)
|
||||||
if (argv != NULL)
|
xfree(argv[i]);
|
||||||
xfree(argv);
|
xfree(argv);
|
||||||
|
}
|
||||||
|
|
||||||
return (rval);
|
return (rval);
|
||||||
}
|
}
|
||||||
@@ -187,30 +189,33 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
|||||||
char *buf, *t;
|
char *buf, *t;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
while ((ch = cmd_string_getc(s, p)) != endch) {
|
while ((ch = cmd_string_getc(s, p)) != endch) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case EOF:
|
case EOF:
|
||||||
goto error;
|
goto error;
|
||||||
case '\\':
|
case '\\':
|
||||||
if (!esc)
|
if (!esc)
|
||||||
break;
|
break;
|
||||||
switch (ch = cmd_string_getc(s, p)) {
|
switch (ch = cmd_string_getc(s, p)) {
|
||||||
case EOF:
|
case EOF:
|
||||||
goto error;
|
goto error;
|
||||||
case 'r':
|
case 'e':
|
||||||
ch = '\r';
|
ch = '\033';
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'r':
|
||||||
ch = '\n';
|
ch = '\r';
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 'n':
|
||||||
ch = '\t';
|
ch = '\n';
|
||||||
break;
|
break;
|
||||||
}
|
case 't':
|
||||||
break;
|
ch = '\t';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case '$':
|
case '$':
|
||||||
if (!esc)
|
if (!esc)
|
||||||
break;
|
break;
|
||||||
@@ -219,14 +224,15 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
|||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
|
xfree(t);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len >= SIZE_MAX - 2)
|
if (len >= SIZE_MAX - 2)
|
||||||
goto error;
|
goto error;
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, 1, len + 1);
|
||||||
buf[len++] = ch;
|
buf[len++] = ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, 1, len + 1);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
@@ -241,9 +247,10 @@ error:
|
|||||||
char *
|
char *
|
||||||
cmd_string_variable(const char *s, size_t *p)
|
cmd_string_variable(const char *s, size_t *p)
|
||||||
{
|
{
|
||||||
int ch, fch;
|
int ch, fch;
|
||||||
char *buf, *t;
|
char *buf, *t;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
struct environ_entry *envent;
|
||||||
|
|
||||||
#define cmd_string_first(ch) ((ch) == '_' || \
|
#define cmd_string_first(ch) ((ch) == '_' || \
|
||||||
((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z'))
|
((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z'))
|
||||||
@@ -251,7 +258,7 @@ cmd_string_variable(const char *s, size_t *p)
|
|||||||
((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z') || \
|
((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z') || \
|
||||||
((ch) >= '0' && (ch) <= '9'))
|
((ch) >= '0' && (ch) <= '9'))
|
||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
fch = EOF;
|
fch = EOF;
|
||||||
@@ -274,7 +281,7 @@ cmd_string_variable(const char *s, size_t *p)
|
|||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, 1, len + 1);
|
||||||
buf[len++] = ch;
|
buf[len++] = ch;
|
||||||
|
|
||||||
for(;;) {
|
for (;;) {
|
||||||
ch = cmd_string_getc(s, p);
|
ch = cmd_string_getc(s, p);
|
||||||
if (ch == EOF || !cmd_string_other(ch))
|
if (ch == EOF || !cmd_string_other(ch))
|
||||||
break;
|
break;
|
||||||
@@ -290,20 +297,48 @@ cmd_string_variable(const char *s, size_t *p)
|
|||||||
if (fch == '{' && ch != '}')
|
if (fch == '{' && ch != '}')
|
||||||
goto error;
|
goto error;
|
||||||
if (ch != EOF && fch != '{')
|
if (ch != EOF && fch != '{')
|
||||||
cmd_string_ungetc(s, p); /* ch */
|
cmd_string_ungetc(p); /* ch */
|
||||||
|
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, 1, len + 1);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
if ((t = getenv(buf)) == NULL) {
|
envent = environ_find(&global_environ, buf);
|
||||||
xfree(buf);
|
|
||||||
return (xstrdup(""));
|
|
||||||
}
|
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
return (xstrdup(t));
|
if (envent == NULL)
|
||||||
|
return (xstrdup(""));
|
||||||
|
return (xstrdup(envent->value));
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (buf != NULL)
|
if (buf != NULL)
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
cmd_string_expand_tilde(const char *s, size_t *p)
|
||||||
|
{
|
||||||
|
struct passwd *pw;
|
||||||
|
struct environ_entry *envent;
|
||||||
|
char *home, *path, *username;
|
||||||
|
|
||||||
|
home = NULL;
|
||||||
|
if (cmd_string_getc(s, p) == '/') {
|
||||||
|
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);
|
||||||
|
if ((username = cmd_string_string(s, p, '/', 0)) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
if ((pw = getpwnam(username)) != NULL)
|
||||||
|
home = pw->pw_dir;
|
||||||
|
xfree(username);
|
||||||
|
}
|
||||||
|
if (home == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
xasprintf(&path, "%s/", home);
|
||||||
|
return (path);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-suspend-client.c,v 1.2 2009-01-19 18:23:40 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,31 +29,23 @@
|
|||||||
|
|
||||||
int cmd_suspend_client_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_suspend_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
struct cmd_suspend_client_data {
|
|
||||||
char *name;
|
|
||||||
char *target;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_suspend_client_entry = {
|
const struct cmd_entry cmd_suspend_client_entry = {
|
||||||
"suspend-client", "suspendc",
|
"suspend-client", "suspendc",
|
||||||
"[-c target-client]",
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_suspend_client_exec,
|
cmd_suspend_client_exec
|
||||||
cmd_target_send,
|
|
||||||
cmd_target_recv,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_suspend_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_suspend_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
tty_stop_tty(&c->tty);
|
tty_stop_tty(&c->tty);
|
||||||
|
|||||||
303
cmd-swap-pane.c
303
cmd-swap-pane.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-swap-pane.c,v 1.4 2009-04-03 17:21:46 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,260 +26,117 @@
|
|||||||
* Swap two panes.
|
* Swap two panes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_swap_pane_parse(struct cmd *, int, char **, char **);
|
void cmd_swap_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_swap_pane_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_swap_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_swap_pane_send(struct cmd *, struct buffer *);
|
|
||||||
void cmd_swap_pane_recv(struct cmd *, struct buffer *);
|
|
||||||
void cmd_swap_pane_free(struct cmd *);
|
|
||||||
void cmd_swap_pane_init(struct cmd *, int);
|
|
||||||
size_t cmd_swap_pane_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_swap_pane_data {
|
|
||||||
char *target;
|
|
||||||
int src;
|
|
||||||
int dst;
|
|
||||||
int flag_detached;
|
|
||||||
int flag_up;
|
|
||||||
int flag_down;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_swap_pane_entry = {
|
const struct cmd_entry cmd_swap_pane_entry = {
|
||||||
"swap-pane", "swapp",
|
"swap-pane", "swapp",
|
||||||
"[-dDU] [-t target-window] [-p src-index] [-q dst-index]",
|
"dDs:t:U", 0, 0,
|
||||||
|
"[-dDU] " CMD_SRCDST_PANE_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_swap_pane_init,
|
cmd_swap_pane_key_binding,
|
||||||
cmd_swap_pane_parse,
|
NULL,
|
||||||
cmd_swap_pane_exec,
|
cmd_swap_pane_exec
|
||||||
cmd_swap_pane_send,
|
|
||||||
cmd_swap_pane_recv,
|
|
||||||
cmd_swap_pane_free,
|
|
||||||
cmd_swap_pane_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_swap_pane_init(struct cmd *self, int key)
|
cmd_swap_pane_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_swap_pane_data *data;
|
self->args = args_create(0);
|
||||||
|
if (key == '{')
|
||||||
self->data = data = xmalloc(sizeof *data);
|
args_set(self->args, 'U', NULL);
|
||||||
data->target = NULL;
|
else if (key == '}')
|
||||||
data->src = -1;
|
args_set(self->args, 'D', NULL);
|
||||||
data->dst = -1;
|
|
||||||
data->flag_detached = 0;
|
|
||||||
data->flag_up = 0;
|
|
||||||
data->flag_down = 0;
|
|
||||||
|
|
||||||
switch (key) {
|
|
||||||
case '{':
|
|
||||||
data->flag_up = 1;
|
|
||||||
break;
|
|
||||||
case '}':
|
|
||||||
data->flag_down = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_swap_pane_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_swap_pane_data *data;
|
|
||||||
int opt, n;
|
|
||||||
const char *errstr;
|
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "dDt:p:q:U")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'd':
|
|
||||||
data->flag_detached = 1;
|
|
||||||
break;
|
|
||||||
case 'D':
|
|
||||||
data->flag_up = 0;
|
|
||||||
data->flag_down = 1;
|
|
||||||
data->dst = -1;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
if (data->src == -1) {
|
|
||||||
n = strtonum(optarg, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "src %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->src = n;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
if (data->dst == -1) {
|
|
||||||
n = strtonum(optarg, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "dst %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->dst = n;
|
|
||||||
}
|
|
||||||
data->flag_up = 0;
|
|
||||||
data->flag_down = 0;
|
|
||||||
break;
|
|
||||||
case 'U':
|
|
||||||
data->flag_up = 1;
|
|
||||||
data->flag_down = 0;
|
|
||||||
data->dst = -1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 0)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
error:
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_swap_pane_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *src_wl, *dst_wl;
|
||||||
struct window *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;
|
||||||
u_int xx, yy;
|
struct layout_cell *src_lc, *dst_lc;
|
||||||
|
u_int sx, sy, xoff, yoff;
|
||||||
|
|
||||||
if (data == NULL)
|
dst_wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &dst_wp);
|
||||||
return (0);
|
if (dst_wl == NULL)
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
dst_w = dst_wl->window;
|
||||||
|
|
||||||
if (data->src == -1)
|
if (!args_has(args, 's')) {
|
||||||
src_wp = w->active;
|
src_w = dst_w;
|
||||||
else {
|
if (args_has(self->args, 'D')) {
|
||||||
src_wp = window_pane_at_index(w, data->src);
|
src_wp = TAILQ_NEXT(dst_wp, entry);
|
||||||
if (src_wp == NULL) {
|
if (src_wp == NULL)
|
||||||
ctx->error(ctx, "no pane: %d", data->src);
|
src_wp = TAILQ_FIRST(&dst_w->panes);
|
||||||
|
} else if (args_has(self->args, 'U')) {
|
||||||
|
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||||
|
if (src_wp == NULL)
|
||||||
|
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
||||||
|
} else
|
||||||
|
return (0);
|
||||||
|
} else {
|
||||||
|
src_wl = cmd_find_pane(ctx, args_get(args, 's'), NULL, &src_wp);
|
||||||
|
if (src_wl == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
src_w = src_wl->window;
|
||||||
}
|
|
||||||
if (data->dst == -1)
|
|
||||||
dst_wp = w->active;
|
|
||||||
else {
|
|
||||||
dst_wp = window_pane_at_index(w, data->dst);
|
|
||||||
if (dst_wp == NULL) {
|
|
||||||
ctx->error(ctx, "no pane: %d", data->dst);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->dst == -1 && data->flag_up) {
|
|
||||||
if ((dst_wp = TAILQ_PREV(src_wp, window_panes, entry)) == NULL)
|
|
||||||
dst_wp = TAILQ_LAST(&w->panes, window_panes);
|
|
||||||
}
|
|
||||||
if (data->dst == -1 && data->flag_down) {
|
|
||||||
if ((dst_wp = TAILQ_NEXT(src_wp, entry)) == NULL)
|
|
||||||
dst_wp = TAILQ_FIRST(&w->panes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src_wp == dst_wp)
|
if (src_wp == dst_wp)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
tmp_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
tmp_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||||
TAILQ_REMOVE(&w->panes, dst_wp, entry);
|
TAILQ_REMOVE(&dst_w->panes, dst_wp, entry);
|
||||||
TAILQ_REPLACE(&w->panes, src_wp, dst_wp, entry);
|
TAILQ_REPLACE(&src_w->panes, src_wp, dst_wp, entry);
|
||||||
if (tmp_wp == src_wp)
|
if (tmp_wp == src_wp)
|
||||||
tmp_wp = dst_wp;
|
tmp_wp = dst_wp;
|
||||||
if (tmp_wp == NULL)
|
if (tmp_wp == NULL)
|
||||||
TAILQ_INSERT_HEAD(&w->panes, src_wp, entry);
|
TAILQ_INSERT_HEAD(&dst_w->panes, src_wp, entry);
|
||||||
else
|
else
|
||||||
TAILQ_INSERT_AFTER(&w->panes, tmp_wp, src_wp, entry);
|
TAILQ_INSERT_AFTER(&dst_w->panes, tmp_wp, src_wp, entry);
|
||||||
|
|
||||||
xx = src_wp->xoff;
|
src_lc = src_wp->layout_cell;
|
||||||
yy = src_wp->yoff;
|
dst_lc = dst_wp->layout_cell;
|
||||||
src_wp->xoff = dst_wp->xoff;
|
src_lc->wp = dst_wp;
|
||||||
src_wp->yoff = dst_wp->yoff;
|
dst_wp->layout_cell = src_lc;
|
||||||
dst_wp->xoff = xx;
|
dst_lc->wp = src_wp;
|
||||||
dst_wp->yoff = yy;
|
src_wp->layout_cell = dst_lc;
|
||||||
|
|
||||||
xx = src_wp->sx;
|
src_wp->window = dst_w;
|
||||||
yy = src_wp->sy;
|
dst_wp->window = src_w;
|
||||||
|
|
||||||
|
sx = src_wp->sx; sy = src_wp->sy;
|
||||||
|
xoff = src_wp->xoff; yoff = src_wp->yoff;
|
||||||
|
src_wp->xoff = dst_wp->xoff; src_wp->yoff = dst_wp->yoff;
|
||||||
window_pane_resize(src_wp, dst_wp->sx, dst_wp->sy);
|
window_pane_resize(src_wp, dst_wp->sx, dst_wp->sy);
|
||||||
window_pane_resize(dst_wp, xx, yy);
|
dst_wp->xoff = xoff; dst_wp->yoff = yoff;
|
||||||
|
window_pane_resize(dst_wp, sx, sy);
|
||||||
|
|
||||||
if (!data->flag_detached) {
|
if (!args_has(self->args, 'd')) {
|
||||||
window_set_active_pane(w, dst_wp);
|
if (src_w != dst_w) {
|
||||||
layout_refresh(w, 0);
|
window_set_active_pane(src_w, dst_wp);
|
||||||
|
window_set_active_pane(dst_w, src_wp);
|
||||||
|
} else {
|
||||||
|
tmp_wp = dst_wp;
|
||||||
|
if (!window_pane_visible(tmp_wp))
|
||||||
|
tmp_wp = src_wp;
|
||||||
|
window_set_active_pane(src_w, tmp_wp);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (src_w->active == src_wp)
|
||||||
|
window_set_active_pane(src_w, dst_wp);
|
||||||
|
if (dst_w->active == dst_wp)
|
||||||
|
window_set_active_pane(dst_w, src_wp);
|
||||||
}
|
}
|
||||||
|
if (src_w != dst_w) {
|
||||||
|
if (src_w->last == src_wp)
|
||||||
|
src_w->last = NULL;
|
||||||
|
if (dst_w->last == dst_wp)
|
||||||
|
dst_w->last = NULL;
|
||||||
|
}
|
||||||
|
server_redraw_window(src_w);
|
||||||
|
server_redraw_window(dst_w);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
cmd_swap_pane_send(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_swap_pane_data *data = self->data;
|
|
||||||
|
|
||||||
buffer_write(b, data, sizeof *data);
|
|
||||||
cmd_send_string(b, data->target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_swap_pane_recv(struct cmd *self, struct buffer *b)
|
|
||||||
{
|
|
||||||
struct cmd_swap_pane_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
buffer_read(b, data, sizeof *data);
|
|
||||||
data->target = cmd_recv_string(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_swap_pane_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_swap_pane_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_swap_pane_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_swap_pane_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len &&
|
|
||||||
(data->flag_down || data->flag_up || data->flag_detached)) {
|
|
||||||
off += xsnprintf(buf + off, len - off, " -");
|
|
||||||
if (off < len && data->flag_detached)
|
|
||||||
off += xsnprintf(buf + off, len - off, "d");
|
|
||||||
if (off < len && data->flag_up)
|
|
||||||
off += xsnprintf(buf + off, len - off, "D");
|
|
||||||
if (off < len && data->flag_down)
|
|
||||||
off += xsnprintf(buf + off, len - off, "U");
|
|
||||||
}
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->src != -1)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -p %d", data->src);
|
|
||||||
if (off < len && data->dst != -1)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -q %d", data->dst);
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user