mirror of
https://github.com/tmux/tmux.git
synced 2026-03-11 11:05:46 +00:00
Compare commits
692 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2365b09d6a | ||
|
|
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 |
198
CHANGES
198
CHANGES
@@ -1,3 +1,199 @@
|
|||||||
|
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
|
CHANGES FROM 0.9 TO 1.0, 20 Sept 2009
|
||||||
|
|
||||||
* Option to alter the format of the window title set by tmux.
|
* Option to alter the format of the window title set by tmux.
|
||||||
@@ -1358,7 +1554,7 @@ The list of older changes is below.
|
|||||||
(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.300 2009-09-20 18:54:21 nicm Exp $
|
$Id: CHANGES,v 1.304 2010-12-27 21:37:42 tcunha Exp $
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
229
FAQ
229
FAQ
@@ -1,33 +1,116 @@
|
|||||||
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 HP-UX, 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;
|
||||||
@@ -82,19 +165,17 @@ 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:
|
|
||||||
|
|
||||||
setw -g utf8 on
|
|
||||||
|
|
||||||
As of release 0.9, tmux attempts to autodetect a UTF-8-capable terminal by
|
|
||||||
checking the LC_ALL, LC_CTYPE and LANG environment variables. list-clients may
|
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
|
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:
|
flag may be specified when creating or attaching a client to a tmux session:
|
||||||
|
|
||||||
$ tmux -u new
|
$ tmux -u new
|
||||||
|
|
||||||
|
Since the 1.0 release, tmux will turn on UTF-8 related options automatically
|
||||||
|
(ie status-utf8, and utf8) if the above conditions are met.
|
||||||
|
|
||||||
* How do I use a 256 colour terminal?
|
* How do I use a 256 colour terminal?
|
||||||
|
|
||||||
Provided the underlying terminal supports 256 colours, it is usually sufficient
|
Provided the underlying terminal supports 256 colours, it is usually sufficient
|
||||||
@@ -156,6 +237,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
|
||||||
@@ -201,4 +284,92 @@ 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
|
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.
|
line drawing characters in the lower part of the same configuration page.
|
||||||
|
|
||||||
$Id: FAQ,v 1.29 2009-08-08 20:46:26 nicm Exp $
|
* 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
|
||||||
|
|
||||||
|
$Id: FAQ,v 1.41 2010-12-15 23:31:30 nicm Exp $
|
||||||
|
|||||||
38
GNUmakefile
38
GNUmakefile
@@ -1,16 +1,37 @@
|
|||||||
# $Id: GNUmakefile,v 1.114 2009-09-20 18:54:21 nicm Exp $
|
# $Id: GNUmakefile,v 1.130 2010-12-27 21:32:16 tcunha 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.
|
||||||
|
#
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
VERSION= 1.0
|
VERSION= 1.4
|
||||||
|
|
||||||
#FDEBUG= 1
|
#FDEBUG= 1
|
||||||
|
|
||||||
CC?= gcc
|
CC?= cc
|
||||||
CFLAGS+= -DBUILD="\"$(VERSION)\""
|
CFLAGS+= -DBUILD="\"$(VERSION)\""
|
||||||
LDFLAGS+= -L/usr/local/lib
|
LDFLAGS+= -L/usr/local/lib
|
||||||
LIBS+=
|
LIBS+=
|
||||||
|
|
||||||
|
# Sun CC
|
||||||
|
ifneq ($(shell ($(CC) -V 2>&1|awk '/Sun C/' || true)), )
|
||||||
|
CFLAGS+= -erroff=E_EMPTY_DECLARATION
|
||||||
|
FDEBUG=
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef FDEBUG
|
ifdef FDEBUG
|
||||||
CFLAGS+= -g -ggdb -DDEBUG
|
CFLAGS+= -g -ggdb -DDEBUG
|
||||||
CFLAGS+= -Wno-long-long -Wall -W -Wnested-externs -Wformat=2
|
CFLAGS+= -Wno-long-long -Wall -W -Wnested-externs -Wformat=2
|
||||||
@@ -31,11 +52,12 @@ endif
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
PREFIX?= /usr/local
|
PREFIX?= /usr/local
|
||||||
INSTALLDIR= install -d
|
INSTALL?= install
|
||||||
INSTALLBIN= install -g bin -o root -m 555
|
INSTALLDIR= $(INSTALL) -d
|
||||||
INSTALLMAN= install -g bin -o root -m 444
|
INSTALLBIN= $(INSTALL) -m 555
|
||||||
|
INSTALLMAN= $(INSTALL) -m 444
|
||||||
|
|
||||||
SRCS= $(shell echo *.c|sed 's|osdep-[a-z0-9]*.c||g')
|
SRCS= $(shell echo *.c|LC_ALL=C sed 's|osdep-[a-z0-9]*.c||g')
|
||||||
include config.mk
|
include config.mk
|
||||||
OBJS= $(patsubst %.c,%.o,$(SRCS))
|
OBJS= $(patsubst %.c,%.o,$(SRCS))
|
||||||
|
|
||||||
@@ -48,7 +70,7 @@ depend: $(SRCS)
|
|||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -MM $(SRCS) > .depend
|
$(CC) $(CPPFLAGS) $(CFLAGS) -MM $(SRCS) > .depend
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f tmux *.o *~ *.core *.log compat/*.o
|
rm -f tmux *.o *~ *.core *.log compat/*.o compat/*~
|
||||||
|
|
||||||
clean-depend:
|
clean-depend:
|
||||||
rm -f .depend
|
rm -f .depend
|
||||||
|
|||||||
30
Makefile
30
Makefile
@@ -1,9 +1,24 @@
|
|||||||
# $Id: Makefile,v 1.149 2009-09-20 18:54:21 nicm Exp $
|
# $Id: Makefile,v 1.162 2010-12-27 21:32:16 tcunha 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.
|
||||||
|
#
|
||||||
|
|
||||||
.SUFFIXES: .c .o
|
.SUFFIXES: .c .o
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
VERSION= 1.0
|
VERSION= 1.4
|
||||||
|
|
||||||
#FDEBUG= 1
|
#FDEBUG= 1
|
||||||
|
|
||||||
@@ -33,11 +48,12 @@ CFLAGS+= -Wno-pointer-sign
|
|||||||
.endif
|
.endif
|
||||||
|
|
||||||
PREFIX?= /usr/local
|
PREFIX?= /usr/local
|
||||||
INSTALLDIR= install -d
|
INSTALL?= install
|
||||||
INSTALLBIN= install -g bin -o root -m 555
|
INSTALLDIR= ${INSTALL} -d
|
||||||
INSTALLMAN= install -g bin -o root -m 444
|
INSTALLBIN= ${INSTALL} -m 555
|
||||||
|
INSTALLMAN= ${INSTALL} -m 444
|
||||||
|
|
||||||
SRCS!= echo *.c|sed 's|osdep-[a-z0-9]*.c||g'
|
SRCS!= echo *.c|LC_ALL=C sed 's|osdep-[a-z0-9]*.c||g'
|
||||||
.include "config.mk"
|
.include "config.mk"
|
||||||
OBJS= ${SRCS:S/.c/.o/}
|
OBJS= ${SRCS:S/.c/.o/}
|
||||||
|
|
||||||
@@ -53,7 +69,7 @@ depend:
|
|||||||
mkdep ${CPPFLAGS} ${CFLAGS} ${SRCS:M*.c}
|
mkdep ${CPPFLAGS} ${CFLAGS} ${SRCS:M*.c}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f tmux *.o *~ *.core *.log compat/*.o
|
rm -f tmux *.o *~ *.core *.log compat/*.o compat/*~
|
||||||
|
|
||||||
clean-depend:
|
clean-depend:
|
||||||
rm -f .depend
|
rm -f .depend
|
||||||
|
|||||||
48
NOTES
48
NOTES
@@ -4,15 +4,15 @@ 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.9 release runs on OpenBSD, FreeBSD, NetBSD, Linux and OS X and may still
|
This release runs on OpenBSD, FreeBSD, NetBSD, Linux and OS X and may still
|
||||||
run on Solaris and AIX (although they hasn't been tested in a while). It is
|
run on Solaris and AIX (although they haven't been tested in a while). It is
|
||||||
usable, although there remain a number of missing features and some remaining
|
usable, although there remain a number of missing features and some remaining
|
||||||
bugs are expected.
|
bugs are expected.
|
||||||
|
|
||||||
If upgrading from 0.5, PLEASE NOTE the following configuration file changes: it
|
Since the 1.2 release that tmux depends on libevent. Download the stable
|
||||||
is now required to pass the -g flag to set-option or set-window-option to set
|
version from:
|
||||||
global options; remain-by-default and utf8-default are now gone, use global
|
|
||||||
window options (set-window-option -g) instead.
|
http://www.monkey.org/~provos/libevent/
|
||||||
|
|
||||||
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
|
||||||
@@ -25,36 +25,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.
|
|
||||||
|
|
||||||
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. As of 0.9, tmux attempts to autodetect a
|
|
||||||
UTF-8-capable terminal by checking the LC_ALL, LC_CTYPE and LANG environment
|
|
||||||
variables. list-clients may be used to check if this is detected correctly; if
|
|
||||||
not, the -u command-line flag may be specified.
|
|
||||||
|
|
||||||
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:
|
||||||
|
|
||||||
@@ -81,6 +55,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.49 2009-07-06 18:53:24 nicm Exp $
|
$Id: NOTES,v 1.54 2010-12-27 21:36:37 tcunha Exp $
|
||||||
|
|||||||
146
TODO
146
TODO
@@ -1,4 +1,3 @@
|
|||||||
- window creation/idle time
|
|
||||||
- better errors when creating new windows/sessions (how?)
|
- better errors when creating new windows/sessions (how?)
|
||||||
- implicitly add exec to the commands for new windows (switch to disable it)?
|
- implicitly add exec to the commands for new windows (switch to disable it)?
|
||||||
- it would be nice to have multichar commands eg C-b K K
|
- it would be nice to have multichar commands eg C-b K K
|
||||||
@@ -7,100 +6,125 @@
|
|||||||
bring back detach-session to detach all clients on a session?
|
bring back detach-session to detach all clients on a session?
|
||||||
- allow fnmatch for -c, so that you can, eg, detach all clients
|
- allow fnmatch for -c, so that you can, eg, detach all clients
|
||||||
- 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?
|
- lift SHRT_MAX limits for history?
|
||||||
- better mode features: search
|
|
||||||
- flags to centre screen in window
|
- flags to centre screen in window
|
||||||
- better terminal emulation
|
|
||||||
- activity/bell should be per-window not per-link? what if it is cur win in
|
- activity/bell should be per-window not per-link? what if it is cur win in
|
||||||
session not being watched?
|
session not being watched?
|
||||||
- next prev word etc in command prompt; also ^K
|
- next prev word etc in command prompt
|
||||||
- many more info() displays for various things
|
|
||||||
- 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
|
||||||
- kill all but current pane
|
|
||||||
- fix rxvt cursor fg issue (text under cursor can have non-white fg)
|
|
||||||
- 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
|
||||||
- support other mouse modes (highlight etc) and use it in copy mode
|
- support other mouse modes (highlight etc) and use it in copy mode
|
||||||
- set-remain-on-exit is a bit of a hack, some way to do it generically?
|
- set-remain-on-exit is a bit of a hack, some way to do it generically?
|
||||||
- set-option should be set-session-option and should be overall global options
|
|
||||||
for stuff like mode keys?
|
|
||||||
also quiet, utf8 and maybe other flags?
|
|
||||||
-g is a bit unexpected in conf file
|
|
||||||
- clear window title on exit
|
- clear window title on exit
|
||||||
- the output code (tty.c) could do with optimisation depending on term
|
|
||||||
capibilities
|
|
||||||
- would be nice to be able to use "--" to mark start of command w/ neww etc
|
- would be nice to be able to use "--" to mark start of command w/ neww etc
|
||||||
to avoid quoting
|
to avoid quoting
|
||||||
- goto line and search history in copy/scroll modes
|
|
||||||
- clone session command
|
|
||||||
- make command sequences more usable: don't require space after ;, handle
|
- make command sequences more usable: don't require space after ;, handle
|
||||||
errors better
|
errors better
|
||||||
- key to switch to copy mode from scroll mode
|
|
||||||
- attach should have a flag to create session if it doesn't exist
|
- attach should have a flag to create session if it doesn't exist
|
||||||
- rename split-window -> split-pane??
|
|
||||||
- fix UTF-8 guesswork on sparc64, improve tty checks
|
|
||||||
- choice and more mode would be better per client than per window?
|
- choice and more mode would be better per client than per window?
|
||||||
- hooks to which commands may be attached, for example: tmux add-hook
|
- hooks to which commands may be attached, for example: tmux add-hook
|
||||||
"new-session" if-shell "[ -e $HOME/.tmux-session.conf ]" source-file
|
"new-session" if-shell "[ -e $HOME/.tmux-session.conf ]" source-file
|
||||||
$HOME/.tmux-session.conf
|
$HOME/.tmux-session.conf
|
||||||
- get it passing all the vttest tests that don't require resizing the terminal
|
- get it passing all the vttest tests that don't require resizing the terminal
|
||||||
- esc seq to set window title should be documented and should set
|
|
||||||
automatic-rename
|
|
||||||
- way to set socket path from config file
|
- way to set socket path from config file
|
||||||
- XXX once env stuff is in, default-path and VISUAL/EDITOR should be picked up
|
|
||||||
when session is started
|
|
||||||
- what about utmp etc? can tmux update it like screen? setgid?
|
- what about utmp etc? can tmux update it like screen? setgid?
|
||||||
- H/M/L commands in copy mode with vi-keys, for jumping to the top/middle/last
|
|
||||||
line on the screen
|
|
||||||
- split list-windows into separate list-windows and list-panes
|
|
||||||
- warts on current naming:
|
- warts on current naming:
|
||||||
- display-time but message-fg/bg/attr
|
- display-time but message-fg/bg/attr
|
||||||
- list-* vs show-*
|
- list-* vs show-*
|
||||||
- server-info
|
- server-info
|
||||||
- up-pane/down-pane/swap-pane -U/swap-pane -D vs next-*/previous-*
|
- up-pane/down-pane/swap-pane -U/swap-pane -D vs next-*/previous-*
|
||||||
- pcvt25 doesn't work properly, why? (bce?)
|
- split-window -> split-pane??
|
||||||
- tidy up and prioritise todo list ;-)
|
|
||||||
- it is only possible to specify 8 colours to fg/bg options; should be able to
|
|
||||||
set 256 as well
|
|
||||||
- neww and attach can create a session if none exists?
|
|
||||||
would work fine with config file since
|
|
||||||
- a way for force-width/height to apply to only one pane (how?)
|
- a way for force-width/height to apply to only one pane (how?)
|
||||||
- **** a command to run something without a window and send any output to the
|
|
||||||
window-more. if no output, info() a line saying "'%s' returned %d". so i can
|
|
||||||
bind mpc control commands to function keys ;-)
|
|
||||||
- command to list what is actually running in each window with command line,
|
- command to list what is actually running in each window with command line,
|
||||||
pid (need some adaption of the osdep code)
|
pid (need some adaption of the osdep code)
|
||||||
- string option to change/remove the symbols (*-+ etc) in status line
|
|
||||||
- support for bce
|
- support for bce
|
||||||
- it would be nice if the start/end line keys in copy mode were aware of
|
|
||||||
wrapped lines
|
|
||||||
- per session locking
|
|
||||||
- some way to force a screen to use the entire terminal even if it is forced
|
- some way to force a screen to use the entire terminal even if it is forced
|
||||||
to be smaller by other clients. pan smaller terminal? (like screen F)
|
to be smaller by other clients. pan smaller terminal? (like screen F)
|
||||||
-- idea of a "view" onto a window, need base x/y offsets
|
-- idea of a "view" onto a window, need base x/y offsets for redraw
|
||||||
for redraw
|
|
||||||
- a window option which means data is echoed to all panes in a window
|
|
||||||
- support running tmux from inside tmux [#(), if-shell] --
|
|
||||||
generic system-like function which may take a callback
|
|
||||||
also sets up environment (TMUX) and has a timeout
|
|
||||||
for #(): command schedular, status line queues it with a time, run in
|
|
||||||
main loop, and uses most recent result -- can also be used for persistent
|
|
||||||
commands which never exit just continually output
|
|
||||||
for if-shell, callback??
|
|
||||||
- handle resize better in copy mode
|
- handle resize better in copy mode
|
||||||
- way to copy stuff that is off screen due to resize
|
- way to copy stuff that is off screen due to resize
|
||||||
- fix line wrapping c&p problems in xterm etc
|
|
||||||
- a way to address panes by name ("top-left") and position ("0,0")
|
|
||||||
- ability to specify multiple prefix keys
|
|
||||||
- commands should be able to succeed or fail and have || or && for command
|
- commands should be able to succeed or fail and have || or && for command
|
||||||
lists
|
lists
|
||||||
- support the mouse wheel to scroll through history
|
- some way to KEEP a command running continually and just use its LAST line of
|
||||||
|
output
|
||||||
|
- bind commands to mouse buttons
|
||||||
|
- UTF-8 to a non-UTF-8 terminal should not be able to balls up
|
||||||
|
the terminal - www/ruby-addressable; make regress
|
||||||
|
- 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
|
||||||
|
- support esc-esc to quit in modes
|
||||||
|
- fix ctrl+F1-F4 output. to what?
|
||||||
|
- look into xterm clearing its selection when scrolling etc
|
||||||
|
- 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
|
||||||
|
- -h option to capture-pane to capture the history as well
|
||||||
|
- 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)
|
||||||
|
- allow buffer to be specified when copying in copy mode
|
||||||
|
- multiline status line (no?)
|
||||||
|
- flag for absolute pane size to resize-pane
|
||||||
|
- sanity check input to socket
|
||||||
|
- select-buffer command
|
||||||
|
- support title stack, both internally and externally
|
||||||
|
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=1149299+0+archive/2010/freebsd-questions/20100207.freebsd-questions
|
||||||
|
- copy buffers should be global, limit can be server option, nuke copy-buffer
|
||||||
|
command
|
||||||
|
- command to show status line information briefly when it is off
|
||||||
|
- some way to pad # stuff with spaces, #!2T maybe
|
||||||
|
- FreeBSD console problems
|
||||||
|
- 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
|
||||||
|
- better configure? with-libevent
|
||||||
|
- bind commands to key sequences?
|
||||||
|
- 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
|
||||||
|
- don't pass UTF-8 through vis for titles
|
||||||
|
- clearing screen should push lines into history
|
||||||
|
- add a unique ever-increasing pane id to each pane, export it in $TMUX_PANE
|
||||||
|
(as %1, %2 etc) and allow it to be used as a target
|
||||||
|
- way to add dest for break-pane; maybe some easier way to unbreak-pane
|
||||||
|
- case insensitive searching
|
||||||
|
- dynamically generated jobs (eg "date ...") do not work well because
|
||||||
|
their entries are never collected, should either store status jobs in
|
||||||
|
a different tree or flush all unused persist jobs every update rather
|
||||||
|
than just updating them
|
||||||
|
- pane-index option like base-index
|
||||||
|
- option to move status line to top
|
||||||
|
- support "xterm2" mouse mode
|
||||||
|
- respawn-pane command
|
||||||
|
- configurable borders and empty space filler for when panes < window?
|
||||||
|
|
||||||
|
|||||||
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: array.h,v 1.11 2010-06-06 00:27:08 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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)
|
||||||
|
|
||||||
|
|||||||
46
attributes.c
46
attributes.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: attributes.c,v 1.2 2009-06-25 15:25:45 nicm Exp $ */
|
/* $Id: attributes.c,v 1.4 2010-06-05 23:54:51 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
|
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
|
||||||
@@ -23,29 +23,29 @@
|
|||||||
#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));
|
||||||
if (*buf)
|
if (*buf != '\0')
|
||||||
*(strrchr(buf, ',')) = '\0';
|
*(strrchr(buf, ',')) = '\0';
|
||||||
|
|
||||||
return (buf);
|
return (buf);
|
||||||
@@ -55,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)
|
||||||
@@ -63,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
/* $Id: buffer-poll.c,v 1.16 2009-08-19 09:28:10 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"
|
|
||||||
|
|
||||||
/* Fill buffers from socket based on poll results. */
|
|
||||||
int
|
|
||||||
buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
|
|
||||||
{
|
|
||||||
ssize_t n;
|
|
||||||
|
|
||||||
if (pfd->revents & (POLLERR|POLLNVAL|POLLHUP))
|
|
||||||
return (-1);
|
|
||||||
if (pfd->revents & POLLIN) {
|
|
||||||
buffer_ensure(in, BUFSIZ);
|
|
||||||
n = read(pfd->fd, BUFFER_IN(in), BUFFER_FREE(in));
|
|
||||||
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 (n == -1) {
|
|
||||||
if (errno != EINTR && errno != EAGAIN)
|
|
||||||
return (-1);
|
|
||||||
} else
|
|
||||||
buffer_remove(out, n);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
139
buffer.c
139
buffer.c
@@ -1,139 +0,0 @@
|
|||||||
/* $Id: buffer.c,v 1.8 2009-08-21 21:09:13 tcunha 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy data into a buffer. */
|
|
||||||
void
|
|
||||||
buffer_write(struct buffer *b, const void *data, size_t 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;
|
|
||||||
b->size++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
62
cfg.c
62
cfg.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cfg.c,v 1.22 2009-08-24 16:27:03 tcunha Exp $ */
|
/* $Id: cfg.c,v 1.27 2010-06-06 00:04:18 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -33,13 +33,17 @@
|
|||||||
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,19 +54,36 @@ cfg_error(unused struct cmd_ctx *ctx, const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void printflike2
|
||||||
load_cfg(const char *path, struct cmd_ctx *ctxin, 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;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -78,10 +99,12 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, char **cause)
|
|||||||
}
|
}
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
if (cmd_string_parse(buf, &cmdlist, cause) != 0) {
|
if (cmd_string_parse(buf, &cmdlist, &cause) != 0) {
|
||||||
if (*cause == NULL)
|
if (cause == NULL)
|
||||||
continue;
|
continue;
|
||||||
goto error;
|
cfg_add_cause(causes, "%s: %u: %s", path, n, cause);
|
||||||
|
xfree(cause);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (cmdlist == NULL)
|
if (cmdlist == NULL)
|
||||||
continue;
|
continue;
|
||||||
@@ -105,23 +128,16 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, char **cause)
|
|||||||
cmd_list_exec(cmdlist, &ctx);
|
cmd_list_exec(cmdlist, &ctx);
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
if (cfg_cause != NULL) {
|
if (cfg_cause != NULL) {
|
||||||
*cause = cfg_cause;
|
cfg_add_cause(causes, "%s: %d: %s", path, n, cfg_cause);
|
||||||
goto error;
|
xfree(cfg_cause);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (line != NULL)
|
if (line != NULL)
|
||||||
xfree(line);
|
xfree(line);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
if (ARRAY_LENGTH(causes) != 0)
|
||||||
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
error:
|
|
||||||
if (line != NULL)
|
|
||||||
xfree(line);
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
xasprintf(&ptr, "%s: %s at line %u", path, *cause, n);
|
|
||||||
xfree(*cause);
|
|
||||||
*cause = ptr;
|
|
||||||
return (1);
|
|
||||||
}
|
}
|
||||||
|
|||||||
90
client-fn.c
90
client-fn.c
@@ -1,90 +0,0 @@
|
|||||||
/* $Id: client-fn.c,v 1.10 2009-08-14 21:04:04 tcunha 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 <unistd.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 msgtype type, void *buf, size_t len)
|
|
||||||
{
|
|
||||||
imsg_compose(&cctx->ibuf, type, PROTOCOL_VERSION, -1, -1, buf, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
client_suspend(void)
|
|
||||||
{
|
|
||||||
struct sigaction act;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
606
client.c
606
client.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: client.c,v 1.70 2009-09-03 21:06:30 tcunha Exp $ */
|
/* $Id: client.c,v 1.100 2010-10-24 19:54:41 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -17,290 +17,442 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#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_send_environ(struct client_ctx *);
|
struct imsgbuf client_ibuf;
|
||||||
void client_handle_winch(struct client_ctx *);
|
struct event client_event;
|
||||||
|
const char *client_exitmsg;
|
||||||
|
int client_exitval;
|
||||||
|
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 cmdflags, 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, mode;
|
||||||
struct winsize ws;
|
|
||||||
size_t size;
|
|
||||||
int fd, fd2, mode;
|
|
||||||
char *name, *term;
|
|
||||||
#ifdef HAVE_SETPROCTITLE
|
|
||||||
char rpathbuf[MAXPATHLEN];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SETPROCTITLE
|
|
||||||
if (realpath(path, rpathbuf) == NULL)
|
|
||||||
strlcpy(rpathbuf, path, sizeof rpathbuf);
|
|
||||||
setproctitle("client (%s)", rpathbuf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (lstat(path, &sb) != 0) {
|
|
||||||
if (cmdflags & CMD_STARTSERVER && errno == ENOENT) {
|
|
||||||
if ((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 ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
||||||
fatal("socket");
|
fatal("socket failed");
|
||||||
|
|
||||||
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
||||||
if (errno == ECONNREFUSED) {
|
if (!start_server)
|
||||||
if (unlink(path) != 0 || !(cmdflags & CMD_STARTSERVER))
|
goto failed;
|
||||||
goto not_found;
|
switch (errno) {
|
||||||
if ((fd = server_start(path)) == -1)
|
case ECONNREFUSED:
|
||||||
goto start_failed;
|
if (unlink(path) != 0)
|
||||||
goto server_started;
|
goto failed;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
case ENOENT:
|
||||||
|
if ((fd = server_start()) == -1)
|
||||||
|
goto failed;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto failed;
|
||||||
}
|
}
|
||||||
goto not_found;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server_started:
|
|
||||||
if ((mode = fcntl(fd, F_GETFL)) == -1)
|
if ((mode = fcntl(fd, F_GETFL)) == -1)
|
||||||
fatal("fcntl failed");
|
fatal("fcntl failed");
|
||||||
if (fcntl(fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
if (fcntl(fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
||||||
fatal("fcntl failed");
|
fatal("fcntl failed");
|
||||||
imsg_init(&cctx->ibuf, fd);
|
return (fd);
|
||||||
|
|
||||||
if (cmdflags & CMD_SENDENVIRON)
|
failed:
|
||||||
client_send_environ(cctx);
|
close(fd);
|
||||||
if (isatty(STDIN_FILENO)) {
|
return (-1);
|
||||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
|
|
||||||
fatal("ioctl(TIOCGWINSZ)");
|
|
||||||
data.flags = flags;
|
|
||||||
data.sx = ws.ws_col;
|
|
||||||
data.sy = ws.ws_row;
|
|
||||||
|
|
||||||
if (getcwd(data.cwd, sizeof data.cwd) == NULL)
|
|
||||||
*data.cwd = '\0';
|
|
||||||
|
|
||||||
*data.term = '\0';
|
|
||||||
if ((term = getenv("TERM")) != NULL) {
|
|
||||||
if (strlcpy(data.term,
|
|
||||||
term, sizeof data.term) >= sizeof data.term)
|
|
||||||
*data.term = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
*data.tty = '\0';
|
|
||||||
if ((name = ttyname(STDIN_FILENO)) == NULL)
|
|
||||||
fatal("ttyname failed");
|
|
||||||
if (strlcpy(data.tty, name, sizeof data.tty) >= sizeof data.tty)
|
|
||||||
fatalx("ttyname failed");
|
|
||||||
|
|
||||||
fd2 = dup(STDIN_FILENO);
|
|
||||||
imsg_compose(&cctx->ibuf, MSG_IDENTIFY,
|
|
||||||
PROTOCOL_VERSION, -1, fd2, &data, sizeof data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
start_failed:
|
|
||||||
log_warnx("server failed to start");
|
|
||||||
return (1);
|
|
||||||
|
|
||||||
not_found:
|
|
||||||
log_warn("server not found");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
client_send_environ(struct client_ctx *cctx)
|
|
||||||
{
|
|
||||||
char **var;
|
|
||||||
struct msg_environ_data data;
|
|
||||||
|
|
||||||
for (var = environ; *var != NULL; var++) {
|
|
||||||
if (strlcpy(data.var, *var, sizeof data.var) >= sizeof data.var)
|
|
||||||
continue;
|
|
||||||
client_write_server(cctx, MSG_ENVIRON, &data, sizeof data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Client main loop. */
|
||||||
int
|
int
|
||||||
client_main(struct client_ctx *cctx)
|
client_main(int argc, char **argv, int flags)
|
||||||
{
|
{
|
||||||
struct pollfd pfd;
|
struct cmd *cmd;
|
||||||
int n, nfds;
|
struct cmd_list *cmdlist;
|
||||||
|
struct msg_command_data cmddata;
|
||||||
|
int cmdflags, fd;
|
||||||
|
enum msgtype msg;
|
||||||
|
char *cause;
|
||||||
|
|
||||||
siginit();
|
/* 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;
|
||||||
|
|
||||||
logfile("client");
|
/*
|
||||||
|
* It sucks parsing the command string twice (in client and
|
||||||
/*
|
* later in server) but it is necessary to get the start server
|
||||||
* imsg_read in the first client poll loop (before the terminal has
|
* flag.
|
||||||
* been initialiased) may have read messages into the buffer after the
|
*/
|
||||||
* MSG_READY switched to here. Process anything outstanding now so poll
|
if ((cmdlist = cmd_list_parse(argc, argv, &cause)) == NULL) {
|
||||||
* doesn't hang waiting for messages that have already arrived.
|
log_warnx("%s", cause);
|
||||||
*/
|
|
||||||
if (client_msg_dispatch(cctx) != 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
if (sigterm)
|
|
||||||
client_write_server(cctx, MSG_EXITING, NULL, 0);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
pfd.fd = cctx->ibuf.fd;
|
|
||||||
pfd.events = POLLIN;
|
|
||||||
if (cctx->ibuf.w.queued > 0)
|
|
||||||
pfd.events |= POLLOUT;
|
|
||||||
|
|
||||||
if ((nfds = poll(&pfd, 1, INFTIM)) == -1) {
|
|
||||||
if (errno == EAGAIN || errno == EINTR)
|
|
||||||
continue;
|
|
||||||
fatal("poll failed");
|
|
||||||
}
|
|
||||||
if (nfds == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (pfd.revents & (POLLERR|POLLHUP|POLLNVAL))
|
|
||||||
fatalx("socket error");
|
|
||||||
|
|
||||||
if (pfd.revents & POLLIN) {
|
|
||||||
if ((n = imsg_read(&cctx->ibuf)) == -1 || n == 0) {
|
|
||||||
cctx->exittype = CCTX_DIED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (client_msg_dispatch(cctx) != 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pfd.revents & POLLOUT) {
|
|
||||||
if (msgbuf_write(&cctx->ibuf.w) < 0) {
|
|
||||||
cctx->exittype = CCTX_DIED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
if (sigterm) {
|
|
||||||
printf("[terminated]\n");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
switch (cctx->exittype) {
|
|
||||||
case CCTX_DIED:
|
|
||||||
printf("[lost server]\n");
|
|
||||||
return (0);
|
|
||||||
case CCTX_SHUTDOWN:
|
|
||||||
printf("[server exited]\n");
|
|
||||||
return (0);
|
|
||||||
case CCTX_EXIT:
|
|
||||||
if (cctx->errstr != NULL) {
|
|
||||||
printf("[error: %s]\n", cctx->errstr);
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
printf("[exited]\n");
|
cmdflags &= ~CMD_STARTSERVER;
|
||||||
return (0);
|
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||||
case CCTX_DETACH:
|
if (cmd->entry->flags & CMD_STARTSERVER)
|
||||||
printf("[detached]\n");
|
cmdflags |= CMD_STARTSERVER;
|
||||||
return (0);
|
if (cmd->entry->flags & CMD_SENDENVIRON)
|
||||||
default:
|
cmdflags |= CMD_SENDENVIRON;
|
||||||
printf("[unknown error]\n");
|
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);
|
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 && client_exitmsg != NULL && !login_shell)
|
||||||
|
printf("[%s]\n", client_exitmsg);
|
||||||
|
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
|
void
|
||||||
client_handle_winch(struct client_ctx *cctx)
|
client_write_server(enum msgtype type, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
struct msg_resize_data data;
|
imsg_compose(&client_ibuf, type, PROTOCOL_VERSION, -1, -1, buf, len);
|
||||||
struct winsize ws;
|
|
||||||
|
|
||||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
|
|
||||||
fatal("ioctl failed");
|
|
||||||
|
|
||||||
data.sx = ws.ws_col;
|
|
||||||
data.sy = ws.ws_row;
|
|
||||||
client_write_server(cctx, MSG_RESIZE, &data, sizeof data);
|
|
||||||
|
|
||||||
sigwinch = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
/* Update client event based on whether it needs to read or read and write. */
|
||||||
client_msg_dispatch(struct client_ctx *cctx)
|
void
|
||||||
|
client_update_event(void)
|
||||||
{
|
{
|
||||||
struct imsg imsg;
|
short events;
|
||||||
struct msg_print_data printdata;
|
|
||||||
ssize_t n, datalen;
|
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;
|
||||||
|
}
|
||||||
|
} 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client_update_event();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Callback for client imsg read events. */
|
||||||
|
/* ARGSUSED */
|
||||||
|
void
|
||||||
|
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 (;;) {
|
for (;;) {
|
||||||
if ((n = imsg_get(&cctx->ibuf, &imsg)) == -1)
|
if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
|
||||||
fatalx("imsg_get failed");
|
fatalx("imsg_get failed");
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return (0);
|
return (0);
|
||||||
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
imsg_free(&imsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dispatch imsgs in attached state (after MSG_READY). */
|
||||||
|
/* ARGSUSED */
|
||||||
|
int
|
||||||
|
client_dispatch_attached(void)
|
||||||
|
{
|
||||||
|
struct imsg imsg;
|
||||||
|
struct msg_lock_data lockdata;
|
||||||
|
struct sigaction sigact;
|
||||||
|
ssize_t n, datalen;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
log_debug("client got %d", imsg.hdr.type);
|
||||||
switch (imsg.hdr.type) {
|
switch (imsg.hdr.type) {
|
||||||
case MSG_DETACH:
|
case MSG_DETACH:
|
||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
fatalx("bad MSG_DETACH size");
|
fatalx("bad MSG_DETACH size");
|
||||||
|
|
||||||
client_write_server(cctx, MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
cctx->exittype = CCTX_DETACH;
|
client_exitmsg = "detached";
|
||||||
break;
|
break;
|
||||||
case MSG_ERROR:
|
|
||||||
if (datalen != sizeof printdata)
|
|
||||||
fatalx("bad MSG_ERROR size");
|
|
||||||
memcpy(&printdata, imsg.data, sizeof printdata);
|
|
||||||
|
|
||||||
printdata.msg[(sizeof printdata.msg) - 1] = '\0';
|
|
||||||
/* Error string used after exit message from server. */
|
|
||||||
cctx->errstr = xstrdup(printdata.msg);
|
|
||||||
imsg_free(&imsg);
|
|
||||||
return (-1);
|
|
||||||
case MSG_EXIT:
|
case MSG_EXIT:
|
||||||
if (datalen != 0)
|
if (datalen != 0 &&
|
||||||
|
datalen != sizeof (struct msg_exit_data))
|
||||||
fatalx("bad MSG_EXIT size");
|
fatalx("bad MSG_EXIT size");
|
||||||
|
|
||||||
client_write_server(cctx, MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
cctx->exittype = CCTX_EXIT;
|
client_exitmsg = "exited";
|
||||||
break;
|
break;
|
||||||
case MSG_EXITED:
|
case MSG_EXITED:
|
||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
@@ -312,14 +464,30 @@ client_msg_dispatch(struct client_ctx *cctx)
|
|||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
fatalx("bad MSG_SHUTDOWN size");
|
fatalx("bad MSG_SHUTDOWN size");
|
||||||
|
|
||||||
client_write_server(cctx, MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
cctx->exittype = CCTX_SHUTDOWN;
|
client_exitmsg = "server exited";
|
||||||
|
client_exitval = 1;
|
||||||
break;
|
break;
|
||||||
case MSG_SUSPEND:
|
case MSG_SUSPEND:
|
||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
fatalx("bad MSG_SUSPEND size");
|
fatalx("bad MSG_SUSPEND size");
|
||||||
|
|
||||||
client_suspend();
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
fatalx("unexpected message");
|
fatalx("unexpected message");
|
||||||
|
|||||||
12
clock.c
12
clock.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: clock.c,v 1.7 2009-09-11 14:13:52 tcunha Exp $ */
|
/* $Id: clock.c,v 1.9 2009-12-04 22:14:47 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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;
|
||||||
@@ -134,13 +134,13 @@ clock_draw(struct screen_write_ctx *ctx, u_int colour, int style)
|
|||||||
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;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-attach-session.c,v 1.32 2009-08-09 17:48:55 tcunha Exp $ */
|
/* $Id: cmd-attach-session.c,v 1.37 2010-12-22 15:36:44 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -28,8 +28,8 @@ 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,
|
"[-dr] " CMD_TARGET_SESSION_USAGE,
|
||||||
CMD_CANTNEST|CMD_STARTSERVER|CMD_SENDENVIRON, CMD_CHFLAG('d'),
|
CMD_CANTNEST|CMD_STARTSERVER|CMD_SENDENVIRON, "dr",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_attach_session_exec,
|
cmd_attach_session_exec,
|
||||||
@@ -47,7 +47,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
char *overrides, *cause;
|
char *overrides, *cause;
|
||||||
u_int i;
|
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);
|
||||||
}
|
}
|
||||||
@@ -58,8 +58,8 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if (ctx->cmdclient == NULL) {
|
if (ctx->cmdclient == NULL) {
|
||||||
if (data->chflags & CMD_CHFLAG('d')) {
|
if (cmd_check_flag(data->chflags, 'd')) {
|
||||||
/*
|
/*
|
||||||
* Can't use server_write_session in case attaching to
|
* Can't use server_write_session in case attaching to
|
||||||
* the same session as currently attached to.
|
* the same session as currently attached to.
|
||||||
*/
|
*/
|
||||||
@@ -72,7 +72,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_write_client(c, MSG_DETACH, NULL, 0);
|
server_write_client(c, MSG_DETACH, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->curclient->session = s;
|
ctx->curclient->session = s;
|
||||||
server_redraw_client(ctx->curclient);
|
server_redraw_client(ctx->curclient);
|
||||||
} else {
|
} else {
|
||||||
@@ -89,7 +89,10 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('d'))
|
if (cmd_check_flag(data->chflags, 'r'))
|
||||||
|
ctx->cmdclient->flags |= CLIENT_READONLY;
|
||||||
|
|
||||||
|
if (cmd_check_flag(data->chflags, 'd'))
|
||||||
server_write_session(s, MSG_DETACH, NULL, 0);
|
server_write_session(s, MSG_DETACH, NULL, 0);
|
||||||
|
|
||||||
ctx->cmdclient->session = s;
|
ctx->cmdclient->session = s;
|
||||||
@@ -101,6 +104,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_client(ctx->cmdclient);
|
server_redraw_client(ctx->cmdclient);
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
server_update_socket();
|
||||||
|
|
||||||
return (1); /* 1 means don't tell command client to exit */
|
return (1); /* 1 means don't tell command client to exit */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-bind-key.c,v 1.25 2009-07-28 23:19:06 tcunha Exp $ */
|
/* $Id: cmd-bind-key.c,v 1.29 2010-07-02 02:43:01 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -46,7 +46,7 @@ struct cmd_bind_key_data {
|
|||||||
const struct cmd_entry cmd_bind_key_entry = {
|
const struct cmd_entry cmd_bind_key_entry = {
|
||||||
"bind-key", "bind",
|
"bind-key", "bind",
|
||||||
"[-cnr] [-t key-table] key command [arguments]",
|
"[-cnr] [-t key-table] key command [arguments]",
|
||||||
0, 0,
|
0, "",
|
||||||
NULL,
|
NULL,
|
||||||
cmd_bind_key_parse,
|
cmd_bind_key_parse,
|
||||||
cmd_bind_key_exec,
|
cmd_bind_key_exec,
|
||||||
@@ -79,7 +79,8 @@ cmd_bind_key_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
data->can_repeat = 1;
|
data->can_repeat = 1;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
data->tablename = xstrdup(optarg);
|
if (data->tablename == NULL)
|
||||||
|
data->tablename = xstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto usage;
|
goto usage;
|
||||||
@@ -129,7 +130,7 @@ cmd_bind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
|||||||
return (cmd_bind_key_table(self, ctx));
|
return (cmd_bind_key_table(self, ctx));
|
||||||
|
|
||||||
key_bindings_add(data->key, data->can_repeat, data->cmdlist);
|
key_bindings_add(data->key, data->can_repeat, data->cmdlist);
|
||||||
data->cmdlist = NULL; /* avoid free */
|
data->cmdlist->references++;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -152,7 +153,7 @@ cmd_bind_key_table(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->error(ctx, "unknown command: %s", data->modecmd);
|
ctx->error(ctx, "unknown command: %s", data->modecmd);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtmp.key = data->key & ~KEYC_PREFIX;
|
mtmp.key = data->key & ~KEYC_PREFIX;
|
||||||
mtmp.mode = data->command_key ? 1 : 0;
|
mtmp.mode = data->command_key ? 1 : 0;
|
||||||
if ((mbind = SPLAY_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {
|
if ((mbind = SPLAY_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {
|
||||||
@@ -191,8 +192,17 @@ cmd_bind_key_print(struct cmd *self, char *buf, size_t len)
|
|||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
off += xsnprintf(buf, len, "%s", self->entry->name);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return (off);
|
return (off);
|
||||||
|
|
||||||
|
if (off < len && data->command_key)
|
||||||
|
off += xsnprintf(buf + off, len - off, " -c");
|
||||||
|
if (off < len && !(data->key & KEYC_PREFIX))
|
||||||
|
off += xsnprintf(buf + off, len - off, " -n");
|
||||||
|
if (off < len && data->can_repeat)
|
||||||
|
off += xsnprintf(buf + off, len - off, " -r");
|
||||||
|
if (off < len && data->tablename != NULL)
|
||||||
|
off += cmd_prarg(buf + off, len - off, " -t ", data->tablename);
|
||||||
if (off < len) {
|
if (off < len) {
|
||||||
skey = key_string_lookup_key(data->key);
|
skey = key_string_lookup_key(data->key & ~KEYC_PREFIX);
|
||||||
off += xsnprintf(buf + off, len - off, " %s ", skey);
|
off += xsnprintf(buf + off, len - off, " %s ", skey);
|
||||||
}
|
}
|
||||||
if (off < len)
|
if (off < len)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-break-pane.c,v 1.8 2009-08-16 19:16:27 tcunha Exp $ */
|
/* $Id: cmd-break-pane.c,v 1.11 2009-12-04 22:14:47 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ 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_TARGET_PANE_USAGE " [-d]",
|
CMD_TARGET_PANE_USAGE " [-d]",
|
||||||
0, CMD_CHFLAG('d'),
|
0, "d",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_break_pane_exec,
|
cmd_break_pane_exec,
|
||||||
@@ -64,20 +64,21 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (wl->window->active == NULL)
|
if (wl->window->active == NULL)
|
||||||
wl->window->active = TAILQ_NEXT(wp, entry);
|
wl->window->active = TAILQ_NEXT(wp, entry);
|
||||||
}
|
}
|
||||||
layout_close_pane(wp);
|
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;
|
||||||
w->name = default_window_name(w);
|
w->name = default_window_name(w);
|
||||||
layout_init(w);
|
layout_init(w);
|
||||||
|
|
||||||
base_idx = options_get_number(&s->options, "base-index");
|
base_idx = options_get_number(&s->options, "base-index");
|
||||||
wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */
|
wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */
|
||||||
if (!(data->chflags & CMD_CHFLAG('d')))
|
if (!cmd_check_flag(data->chflags, 'd'))
|
||||||
session_select(s, wl->idx);
|
session_select(s, wl->idx);
|
||||||
|
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
|
server_status_session_group(s);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
83
cmd-capture-pane.c
Normal file
83
cmd-capture-pane.c
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/* $Id: cmd-capture-pane.c,v 1.3 2010-01-22 17:29:19 tcunha Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 <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",
|
||||||
|
CMD_BUFFER_PANE_USAGE,
|
||||||
|
0, "",
|
||||||
|
cmd_buffer_init,
|
||||||
|
cmd_buffer_parse,
|
||||||
|
cmd_capture_pane_exec,
|
||||||
|
cmd_buffer_free,
|
||||||
|
cmd_buffer_print
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct cmd_buffer_data *data = self->data;
|
||||||
|
struct window_pane *wp;
|
||||||
|
char *buf, *line;
|
||||||
|
struct screen *s;
|
||||||
|
struct session *sess;
|
||||||
|
u_int i, limit;
|
||||||
|
size_t len, linelen;
|
||||||
|
|
||||||
|
if (cmd_find_pane(ctx, data->target, &sess, &wp) == NULL)
|
||||||
|
return (-1);
|
||||||
|
s = &wp->base;
|
||||||
|
|
||||||
|
buf = NULL;
|
||||||
|
len = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < screen_size_y(s); i++) {
|
||||||
|
line = grid_view_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(&sess->options, "buffer-limit");
|
||||||
|
if (data->buffer == -1) {
|
||||||
|
paste_add(&sess->buffers, buf, len, limit);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
if (paste_replace(&sess->buffers, data->buffer, buf, len) != 0) {
|
||||||
|
ctx->error(ctx, "no buffer %d", data->buffer);
|
||||||
|
xfree(buf);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
146
cmd-choose-buffer.c
Normal file
146
cmd-choose-buffer.c
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
/* $Id: cmd-choose-buffer.c,v 1.1 2010-06-22 23:35:20 tcunha Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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,
|
||||||
|
CMD_TARGET_WINDOW_USAGE " [template]",
|
||||||
|
CMD_ARG01, "",
|
||||||
|
cmd_target_init,
|
||||||
|
cmd_target_parse,
|
||||||
|
cmd_choose_buffer_exec,
|
||||||
|
cmd_target_free,
|
||||||
|
cmd_target_print
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_choose_buffer_data {
|
||||||
|
struct client *client;
|
||||||
|
char *template;
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct cmd_target_data *data = self->data;
|
||||||
|
struct cmd_choose_buffer_data *cdata;
|
||||||
|
struct session *s;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
s = ctx->curclient->session;
|
||||||
|
|
||||||
|
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (paste_get_top(&s->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(&s->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 (data->arg != NULL)
|
||||||
|
cdata->template = xstrdup(data->arg);
|
||||||
|
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);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-choose-client.c,v 1.3 2009-09-07 23:59:19 tcunha Exp $ */
|
/* $Id: cmd-choose-client.c,v 1.4 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -34,7 +34,7 @@ void cmd_choose_client_free(void *);
|
|||||||
const struct cmd_entry cmd_choose_client_entry = {
|
const struct cmd_entry cmd_choose_client_entry = {
|
||||||
"choose-client", NULL,
|
"choose-client", NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE " [template]",
|
CMD_TARGET_WINDOW_USAGE " [template]",
|
||||||
CMD_ARG01, 0,
|
CMD_ARG01, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_choose_client_exec,
|
cmd_choose_client_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-choose-session.c,v 1.13 2009-09-07 23:59:19 tcunha Exp $ */
|
/* $Id: cmd-choose-session.c,v 1.17 2010-12-22 15:36:44 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -34,7 +34,7 @@ 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 " [template]",
|
CMD_TARGET_WINDOW_USAGE " [template]",
|
||||||
CMD_ARG01, 0,
|
CMD_ARG01, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_choose_session_exec,
|
cmd_choose_session_exec,
|
||||||
@@ -54,7 +54,9 @@ cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
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");
|
||||||
@@ -68,18 +70,23 @@ cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
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);
|
||||||
@@ -110,9 +117,7 @@ cmd_choose_session_callback(void *data, int idx)
|
|||||||
if (cdata->client->flags & CLIENT_DEAD)
|
if (cdata->client->flags & CLIENT_DEAD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((u_int) idx > ARRAY_LENGTH(&sessions) - 1)
|
s = session_find_by_index(idx);
|
||||||
return;
|
|
||||||
s = ARRAY_ITEM(&sessions, idx);
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return;
|
return;
|
||||||
template = cmd_template_replace(cdata->template, s->name, 1);
|
template = cmd_template_replace(cdata->template, s->name, 1);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-choose-window.c,v 1.17 2009-09-07 23:59:19 tcunha Exp $ */
|
/* $Id: cmd-choose-window.c,v 1.24 2010-12-22 15:28:50 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -34,7 +34,7 @@ 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 " [template]",
|
CMD_TARGET_WINDOW_USAGE " [template]",
|
||||||
CMD_ARG01, 0,
|
CMD_ARG01, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_choose_window_exec,
|
cmd_choose_window_exec,
|
||||||
@@ -81,15 +81,17 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
flag = ' ';
|
flag = ' ';
|
||||||
if (session_alert_has(s, wm, WINDOW_ACTIVITY))
|
if (wm->flags & WINLINK_ACTIVITY)
|
||||||
flag = '#';
|
flag = '#';
|
||||||
else if (session_alert_has(s, wm, WINDOW_BELL))
|
else if (wm->flags & WINLINK_BELL)
|
||||||
flag = '!';
|
flag = '!';
|
||||||
else if (session_alert_has(s, wm, WINDOW_CONTENT))
|
else if (wm->flags & WINLINK_CONTENT)
|
||||||
flag = '+';
|
flag = '+';
|
||||||
|
else if (wm->flags & WINLINK_SILENCE)
|
||||||
|
flag = '~';
|
||||||
else if (wm == s->curw)
|
else if (wm == s->curw)
|
||||||
flag = '*';
|
flag = '*';
|
||||||
else if (wm == SLIST_FIRST(&s->lastw))
|
else if (wm == TAILQ_FIRST(&s->lastw))
|
||||||
flag = '-';
|
flag = '-';
|
||||||
|
|
||||||
title = w->active->screen->title;
|
title = w->active->screen->title;
|
||||||
@@ -101,8 +103,9 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
left = right = "";
|
left = right = "";
|
||||||
|
|
||||||
window_choose_add(wl->window->active,
|
window_choose_add(wl->window->active,
|
||||||
wm->idx, "%3d: %s%c [%ux%u] (%u panes)%s%s%s",
|
wm->idx, "%3d: %s%c [%ux%u] (%u panes%s)%s%s%s",
|
||||||
wm->idx, w->name, flag, w->sx, w->sy, window_count_panes(w),
|
wm->idx, w->name, flag, w->sx, w->sy, window_count_panes(w),
|
||||||
|
w->active->fd == -1 ? ", dead" : "",
|
||||||
left, title, right);
|
left, title, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,30 +119,29 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cdata->client = ctx->curclient;
|
cdata->client = ctx->curclient;
|
||||||
cdata->client->references++;
|
cdata->client->references++;
|
||||||
|
|
||||||
window_choose_ready(wl->window->active,
|
window_choose_ready(wl->window->active,
|
||||||
cur, cmd_choose_window_callback, cmd_choose_window_free, 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 = cdata->session;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd_ctx ctx;
|
struct cmd_ctx ctx;
|
||||||
char *target, *template, *cause;
|
char *target, *template, *cause;
|
||||||
|
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
return;
|
return;
|
||||||
if (cdata->client->flags & CLIENT_DEAD)
|
if (!session_alive(s))
|
||||||
return;
|
|
||||||
if (cdata->session->flags & SESSION_DEAD)
|
|
||||||
return;
|
return;
|
||||||
if (cdata->client->session != cdata->session)
|
if (cdata->client->flags & CLIENT_DEAD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xasprintf(&target, "%s:%d", cdata->session->name, idx);
|
xasprintf(&target, "%s:%d", s->name, idx);
|
||||||
template = cmd_template_replace(cdata->template, target, 1);
|
template = cmd_template_replace(cdata->template, target, 1);
|
||||||
xfree(target);
|
xfree(target);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-clear-history.c,v 1.7 2009-07-30 21:04:40 tcunha Exp $ */
|
/* $Id: cmd-clear-history.c,v 1.8 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ int cmd_clear_history_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_clear_history_entry = {
|
const struct cmd_entry cmd_clear_history_entry = {
|
||||||
"clear-history", "clearhist",
|
"clear-history", "clearhist",
|
||||||
CMD_TARGET_PANE_USAGE,
|
CMD_TARGET_PANE_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_clear_history_exec,
|
cmd_clear_history_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-clock-mode.c,v 1.6 2009-08-20 11:37:46 tcunha Exp $ */
|
/* $Id: cmd-clock-mode.c,v 1.7 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ 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_PANE_USAGE,
|
CMD_TARGET_PANE_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_clock_mode_exec,
|
cmd_clock_mode_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-command-prompt.c,v 1.25 2009-08-25 13:53:39 tcunha Exp $ */
|
/* $Id: cmd-command-prompt.c,v 1.28 2010-05-14 14:33:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -39,7 +39,7 @@ void cmd_command_prompt_cfree(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 " [-p prompts] [template]",
|
CMD_TARGET_CLIENT_USAGE " [-p prompts] [template]",
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_command_prompt_init,
|
cmd_command_prompt_init,
|
||||||
cmd_command_prompt_parse,
|
cmd_command_prompt_parse,
|
||||||
cmd_command_prompt_exec,
|
cmd_command_prompt_exec,
|
||||||
@@ -81,6 +81,10 @@ cmd_command_prompt_init(struct cmd *self, int key)
|
|||||||
case 'f':
|
case 'f':
|
||||||
data->template = xstrdup("find-window '%%'");
|
data->template = xstrdup("find-window '%%'");
|
||||||
break;
|
break;
|
||||||
|
case '\'':
|
||||||
|
data->template = xstrdup("select-window -t ':%%'");
|
||||||
|
data->prompts = xstrdup("index");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +94,7 @@ cmd_command_prompt_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
struct cmd_command_prompt_data *data;
|
struct cmd_command_prompt_data *data;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
self->entry->init(self, KEYC_NONE);
|
||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "p:t:")) != -1) {
|
while ((opt = getopt(argc, argv, "p:t:")) != -1) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-confirm-before.c,v 1.11 2009-08-24 16:24:18 tcunha Exp $ */
|
/* $Id: cmd-confirm-before.c,v 1.12 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -34,7 +34,7 @@ void cmd_confirm_before_free(void *);
|
|||||||
const struct cmd_entry cmd_confirm_before_entry = {
|
const struct cmd_entry cmd_confirm_before_entry = {
|
||||||
"confirm-before", "confirm",
|
"confirm-before", "confirm",
|
||||||
CMD_TARGET_CLIENT_USAGE " command",
|
CMD_TARGET_CLIENT_USAGE " command",
|
||||||
CMD_ARG1, 0,
|
CMD_ARG1, "",
|
||||||
cmd_confirm_before_init,
|
cmd_confirm_before_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_confirm_before_exec,
|
cmd_confirm_before_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-copy-buffer.c,v 1.4 2009-09-07 23:48:54 tcunha Exp $ */
|
/* $Id: cmd-copy-buffer.c,v 1.7 2009-11-28 14:50:36 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -43,7 +43,7 @@ struct cmd_copy_buffer_data {
|
|||||||
const struct cmd_entry cmd_copy_buffer_entry = {
|
const struct cmd_entry cmd_copy_buffer_entry = {
|
||||||
"copy-buffer", "copyb",
|
"copy-buffer", "copyb",
|
||||||
"[-a src-index] [-b dst-index] [-s src-session] [-t dst-session]",
|
"[-a src-index] [-b dst-index] [-s src-session] [-t dst-session]",
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_copy_buffer_init,
|
cmd_copy_buffer_init,
|
||||||
cmd_copy_buffer_parse,
|
cmd_copy_buffer_parse,
|
||||||
cmd_copy_buffer_exec,
|
cmd_copy_buffer_exec,
|
||||||
@@ -51,6 +51,7 @@ const struct cmd_entry cmd_copy_buffer_entry = {
|
|||||||
cmd_copy_buffer_print
|
cmd_copy_buffer_print
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
void
|
void
|
||||||
cmd_copy_buffer_init(struct cmd *self, unused int arg)
|
cmd_copy_buffer_init(struct cmd *self, unused int arg)
|
||||||
{
|
{
|
||||||
@@ -70,7 +71,7 @@ cmd_copy_buffer_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
const char *errstr;
|
const char *errstr;
|
||||||
int n, opt;
|
int n, opt;
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
self->entry->init(self, KEYC_NONE);
|
||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "a:b:s:t:")) != -1) {
|
while ((opt = getopt(argc, argv, "a:b:s:t:")) != -1) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-copy-mode.c,v 1.23 2009-08-20 11:37:46 tcunha Exp $ */
|
/* $Id: cmd-copy-mode.c,v 1.28 2010-08-11 22:18:28 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,19 +24,35 @@
|
|||||||
* Enter copy mode.
|
* Enter copy mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void cmd_copy_mode_init(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,
|
||||||
"[-u] " CMD_TARGET_PANE_USAGE,
|
"[-u] " CMD_TARGET_PANE_USAGE,
|
||||||
0, CMD_CHFLAG('u'),
|
0, "u",
|
||||||
cmd_target_init,
|
cmd_copy_mode_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_copy_mode_exec,
|
cmd_copy_mode_exec,
|
||||||
cmd_target_free,
|
cmd_target_free,
|
||||||
NULL
|
cmd_target_print
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_copy_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:
|
||||||
|
cmd_set_flag(&data->chflags, 'u');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
@@ -46,8 +62,10 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
window_pane_set_mode(wp, &window_copy_mode);
|
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
||||||
if (wp->mode == &window_copy_mode && data->chflags & CMD_CHFLAG('u'))
|
return (0);
|
||||||
|
window_copy_init_from_pane(wp);
|
||||||
|
if (wp->mode == &window_copy_mode && cmd_check_flag(data->chflags, 'u'))
|
||||||
window_copy_pageup(wp);
|
window_copy_pageup(wp);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-delete-buffer.c,v 1.7 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-delete-buffer.c,v 1.8 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ 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,
|
CMD_BUFFER_SESSION_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_buffer_init,
|
cmd_buffer_init,
|
||||||
cmd_buffer_parse,
|
cmd_buffer_parse,
|
||||||
cmd_delete_buffer_exec,
|
cmd_delete_buffer_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-detach-client.c,v 1.9 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-detach-client.c,v 1.11 2010-02-08 18:27:34 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ 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,
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
0, 0,
|
CMD_READONLY, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_detach_client_exec,
|
cmd_detach_client_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-display-message.c,v 1.2 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-display-message.c,v 1.7 2009-11-28 14:39:53 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -30,8 +30,8 @@ int cmd_display_message_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_display_message_entry = {
|
const struct cmd_entry cmd_display_message_entry = {
|
||||||
"display-message", "display",
|
"display-message", "display",
|
||||||
CMD_TARGET_CLIENT_USAGE " [message]",
|
"[-p] " CMD_TARGET_CLIENT_USAGE " [message]",
|
||||||
CMD_ARG01, 0,
|
CMD_ARG01, "p",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_display_message_exec,
|
cmd_display_message_exec,
|
||||||
@@ -55,8 +55,11 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else
|
else
|
||||||
template = data->arg;
|
template = data->arg;
|
||||||
|
|
||||||
msg = status_replace(c->session, template, time(NULL));
|
msg = status_replace(c, NULL, template, time(NULL), 0);
|
||||||
status_message_set(c, "%s", msg);
|
if (cmd_check_flag(data->chflags, 'p'))
|
||||||
|
ctx->print(ctx, "%s", msg);
|
||||||
|
else
|
||||||
|
status_message_set(c, "%s", msg);
|
||||||
xfree(msg);
|
xfree(msg);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-display-panes.c,v 1.1 2009-08-31 22:30:15 tcunha Exp $ */
|
/* $Id: cmd-display-panes.c,v 1.2 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ int cmd_display_panes_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_display_panes_entry = {
|
const struct cmd_entry cmd_display_panes_entry = {
|
||||||
"display-panes", "displayp",
|
"display-panes", "displayp",
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_display_panes_exec,
|
cmd_display_panes_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-find-window.c,v 1.13 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-find-window.c,v 1.15 2010-12-22 15:28:50 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,11 +30,12 @@
|
|||||||
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);
|
||||||
|
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",
|
||||||
CMD_TARGET_WINDOW_USAGE " match-string",
|
CMD_TARGET_WINDOW_USAGE " match-string",
|
||||||
CMD_ARG1, 0,
|
CMD_ARG1, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_find_window_exec,
|
cmd_find_window_exec,
|
||||||
@@ -43,7 +44,7 @@ const struct cmd_entry cmd_find_window_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_find_window_data {
|
struct cmd_find_window_data {
|
||||||
u_int session;
|
struct session *session;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -134,11 +135,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, xfree, cdata);
|
0, cmd_find_window_callback, cmd_find_window_free, cdata);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
ARRAY_FREE(&list_idx);
|
ARRAY_FREE(&list_idx);
|
||||||
@@ -151,12 +152,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);
|
||||||
|
}
|
||||||
|
|||||||
113
cmd-generic.c
113
cmd-generic.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-generic.c,v 1.34 2009-08-26 22:13:52 tcunha Exp $ */
|
/* $Id: cmd-generic.c,v 1.38 2009-12-04 22:14:47 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
int cmd_getopt(int, char **, const char *, uint64_t);
|
int cmd_getopt(int, char **, const char *, const char *);
|
||||||
int cmd_flags(int, uint64_t, uint64_t *);
|
int cmd_parse_flags(int, const char *, uint64_t *);
|
||||||
size_t cmd_print_flags(char *, size_t, size_t, uint64_t);
|
size_t cmd_print_flags(char *, size_t, size_t, uint64_t);
|
||||||
int cmd_fill_argument(int, char **, char **, int, char **);
|
int cmd_fill_argument(int, char **, char **, int, char **);
|
||||||
|
|
||||||
@@ -36,54 +36,56 @@ cmd_prarg(char *buf, size_t len, const char *prefix, char *arg)
|
|||||||
return (xsnprintf(buf, len, "%s%s", prefix, arg));
|
return (xsnprintf(buf, len, "%s%s", prefix, arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepend flags from chflags onto flagstr and call getopt. */
|
/* Append two flag strings together and call getopt. */
|
||||||
int
|
int
|
||||||
cmd_getopt(int argc, char **argv, const char *flagstr, uint64_t chflags)
|
cmd_getopt(int argc, char **argv, const char *flagstr, const char *chflagstr)
|
||||||
{
|
{
|
||||||
u_char ch;
|
char tmp[BUFSIZ];
|
||||||
char buf[128];
|
|
||||||
size_t len, off;
|
|
||||||
|
|
||||||
*buf = '\0';
|
if (strlcpy(tmp, flagstr, sizeof tmp) >= sizeof tmp)
|
||||||
|
fatalx("strlcpy overflow");
|
||||||
len = sizeof buf;
|
if (strlcat(tmp, chflagstr, sizeof tmp) >= sizeof tmp)
|
||||||
off = 0;
|
fatalx("strlcat overflow");
|
||||||
|
return (getopt(argc, argv, tmp));
|
||||||
for (ch = 0; ch < 26; ch++) {
|
|
||||||
if (chflags & CMD_CHFLAG('a' + ch))
|
|
||||||
off += xsnprintf(buf + off, len - off, "%c", 'a' + ch);
|
|
||||||
if (chflags & CMD_CHFLAG('A' + ch))
|
|
||||||
off += xsnprintf(buf + off, len - off, "%c", 'A' + ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
strlcat(buf, flagstr, sizeof buf);
|
|
||||||
|
|
||||||
return (getopt(argc, argv, buf));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Return if flag character is set. */
|
||||||
* If this option is expected (in ichflags), set it in ochflags, otherwise
|
|
||||||
* return -1.
|
|
||||||
*/
|
|
||||||
int
|
int
|
||||||
cmd_flags(int opt, uint64_t ichflags, uint64_t *ochflags)
|
cmd_check_flag(uint64_t chflags, int flag)
|
||||||
{
|
{
|
||||||
u_char ch;
|
if (flag >= 'A' && flag <= 'Z')
|
||||||
|
flag = 26 + flag - 'A';
|
||||||
for (ch = 0; ch < 26; ch++) {
|
else if (flag >= 'a' && flag <= 'z')
|
||||||
if (opt == 'a' + ch && ichflags & CMD_CHFLAG(opt)) {
|
flag = flag - 'a';
|
||||||
(*ochflags) |= CMD_CHFLAG(opt);
|
else
|
||||||
return (0);
|
return (0);
|
||||||
}
|
return ((chflags & (1ULL << flag)) != 0);
|
||||||
if (opt == 'A' + ch && ichflags & CMD_CHFLAG(opt)) {
|
|
||||||
(*ochflags) |= CMD_CHFLAG(opt);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print the flags supported in chflags. */
|
/* Set flag character. */
|
||||||
|
void
|
||||||
|
cmd_set_flag(uint64_t *chflags, int flag)
|
||||||
|
{
|
||||||
|
if (flag >= 'A' && flag <= 'Z')
|
||||||
|
flag = 26 + flag - 'A';
|
||||||
|
else if (flag >= 'a' && flag <= 'z')
|
||||||
|
flag = flag - 'a';
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
(*chflags) |= (1ULL << flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If this option is expected, set it in chflags, otherwise return -1. */
|
||||||
|
int
|
||||||
|
cmd_parse_flags(int opt, const char *chflagstr, uint64_t *chflags)
|
||||||
|
{
|
||||||
|
if (strchr(chflagstr, opt) == NULL)
|
||||||
|
return (-1);
|
||||||
|
cmd_set_flag(chflags, opt);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print the flags present in chflags. */
|
||||||
size_t
|
size_t
|
||||||
cmd_print_flags(char *buf, size_t len, size_t off, uint64_t chflags)
|
cmd_print_flags(char *buf, size_t len, size_t off, uint64_t chflags)
|
||||||
{
|
{
|
||||||
@@ -95,9 +97,9 @@ cmd_print_flags(char *buf, size_t len, size_t off, uint64_t chflags)
|
|||||||
off += xsnprintf(buf + off, len - off, " -");
|
off += xsnprintf(buf + off, len - off, " -");
|
||||||
|
|
||||||
for (ch = 0; ch < 26; ch++) {
|
for (ch = 0; ch < 26; ch++) {
|
||||||
if (chflags & CMD_CHFLAG('a' + ch))
|
if (cmd_check_flag(chflags, 'a' + ch))
|
||||||
off += xsnprintf(buf + off, len - off, "%c", 'a' + ch);
|
off += xsnprintf(buf + off, len - off, "%c", 'a' + ch);
|
||||||
if (chflags & CMD_CHFLAG('A' + ch))
|
if (cmd_check_flag(chflags, 'A' + ch))
|
||||||
off += xsnprintf(buf + off, len - off, "%c", 'A' + ch);
|
off += xsnprintf(buf + off, len - off, "%c", 'A' + ch);
|
||||||
}
|
}
|
||||||
return (off - boff);
|
return (off - boff);
|
||||||
@@ -139,13 +141,14 @@ cmd_fill_argument(int flags, char **arg, char **arg2, int argc, char **argv)
|
|||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
*arg2 = xstrdup(argv[1]);
|
*arg2 = xstrdup(argv[1]);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc != 0)
|
if (argc != 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
void
|
void
|
||||||
cmd_target_init(struct cmd *self, unused int key)
|
cmd_target_init(struct cmd *self, unused int key)
|
||||||
{
|
{
|
||||||
@@ -170,7 +173,7 @@ cmd_target_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
while ((opt = cmd_getopt(argc, argv, "t:", entry->chflags)) != -1) {
|
while ((opt = cmd_getopt(argc, argv, "t:", entry->chflags)) != -1) {
|
||||||
if (cmd_flags(opt, entry->chflags, &data->chflags) == 0)
|
if (cmd_parse_flags(opt, entry->chflags, &data->chflags) == 0)
|
||||||
continue;
|
continue;
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 't':
|
case 't':
|
||||||
@@ -222,13 +225,14 @@ cmd_target_print(struct cmd *self, char *buf, size_t len)
|
|||||||
off += cmd_print_flags(buf, len, off, data->chflags);
|
off += cmd_print_flags(buf, len, off, data->chflags);
|
||||||
if (off < len && data->target != NULL)
|
if (off < len && data->target != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
||||||
if (off < len && data->arg != NULL)
|
if (off < len && data->arg != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
||||||
if (off < len && data->arg2 != NULL)
|
if (off < len && data->arg2 != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg2);
|
off += cmd_prarg(buf + off, len - off, " ", data->arg2);
|
||||||
return (off);
|
return (off);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
void
|
void
|
||||||
cmd_srcdst_init(struct cmd *self, unused int key)
|
cmd_srcdst_init(struct cmd *self, unused int key)
|
||||||
{
|
{
|
||||||
@@ -253,7 +257,7 @@ cmd_srcdst_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
while ((opt = cmd_getopt(argc, argv, "s:t:", entry->chflags)) != -1) {
|
while ((opt = cmd_getopt(argc, argv, "s:t:", entry->chflags)) != -1) {
|
||||||
if (cmd_flags(opt, entry->chflags, &data->chflags) == 0)
|
if (cmd_parse_flags(opt, entry->chflags, &data->chflags) == 0)
|
||||||
continue;
|
continue;
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 's':
|
case 's':
|
||||||
@@ -313,13 +317,14 @@ cmd_srcdst_print(struct cmd *self, char *buf, size_t len)
|
|||||||
off += xsnprintf(buf + off, len - off, " -s %s", data->src);
|
off += xsnprintf(buf + off, len - off, " -s %s", data->src);
|
||||||
if (off < len && data->dst != NULL)
|
if (off < len && data->dst != NULL)
|
||||||
off += xsnprintf(buf + off, len - off, " -t %s", data->dst);
|
off += xsnprintf(buf + off, len - off, " -t %s", data->dst);
|
||||||
if (off < len && data->arg != NULL)
|
if (off < len && data->arg != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
||||||
if (off < len && data->arg2 != NULL)
|
if (off < len && data->arg2 != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg2);
|
off += cmd_prarg(buf + off, len - off, " ", data->arg2);
|
||||||
return (off);
|
return (off);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
void
|
void
|
||||||
cmd_buffer_init(struct cmd *self, unused int key)
|
cmd_buffer_init(struct cmd *self, unused int key)
|
||||||
{
|
{
|
||||||
@@ -345,7 +350,7 @@ cmd_buffer_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
while ((opt = cmd_getopt(argc, argv, "b:t:", entry->chflags)) != -1) {
|
while ((opt = cmd_getopt(argc, argv, "b:t:", entry->chflags)) != -1) {
|
||||||
if (cmd_flags(opt, entry->chflags, &data->chflags) == 0)
|
if (cmd_parse_flags(opt, entry->chflags, &data->chflags) == 0)
|
||||||
continue;
|
continue;
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'b':
|
case 'b':
|
||||||
@@ -410,9 +415,9 @@ cmd_buffer_print(struct cmd *self, char *buf, size_t len)
|
|||||||
off += xsnprintf(buf + off, len - off, " -b %d", data->buffer);
|
off += xsnprintf(buf + off, len - off, " -b %d", data->buffer);
|
||||||
if (off < len && data->target != NULL)
|
if (off < len && data->target != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
||||||
if (off < len && data->arg != NULL)
|
if (off < len && data->arg != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
||||||
if (off < len && data->arg2 != NULL)
|
if (off < len && data->arg2 != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg2);
|
off += cmd_prarg(buf + off, len - off, " ", data->arg2);
|
||||||
return (off);
|
return (off);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-has-session.c,v 1.14 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-has-session.c,v 1.15 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ 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",
|
||||||
CMD_TARGET_SESSION_USAGE,
|
CMD_TARGET_SESSION_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_has_session_exec,
|
cmd_has_session_exec,
|
||||||
|
|||||||
148
cmd-if-shell.c
148
cmd-if-shell.c
@@ -1,7 +1,8 @@
|
|||||||
/* $Id: cmd-if-shell.c,v 1.4 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-if-shell.c,v 1.10 2010-08-09 21:44:25 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* 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
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
@@ -17,9 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -28,124 +28,92 @@
|
|||||||
* Executes a tmux command if a shell command returns true.
|
* Executes a tmux command if a shell command returns true.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_if_shell_parse(struct cmd *, int, char **, char **);
|
|
||||||
int cmd_if_shell_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_if_shell_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_if_shell_free(struct cmd *);
|
|
||||||
void cmd_if_shell_init(struct cmd *, int);
|
|
||||||
size_t cmd_if_shell_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_if_shell_data {
|
void cmd_if_shell_callback(struct job *);
|
||||||
char *cmd;
|
void cmd_if_shell_free(void *);
|
||||||
char *sh_cmd;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_if_shell_entry = {
|
const struct cmd_entry cmd_if_shell_entry = {
|
||||||
"if-shell", "if",
|
"if-shell", "if",
|
||||||
"shell-command command",
|
"shell-command command",
|
||||||
0, 0,
|
CMD_ARG2, "",
|
||||||
cmd_if_shell_init,
|
cmd_target_init,
|
||||||
cmd_if_shell_parse,
|
cmd_target_parse,
|
||||||
cmd_if_shell_exec,
|
cmd_if_shell_exec,
|
||||||
cmd_if_shell_free,
|
cmd_target_free,
|
||||||
cmd_if_shell_print
|
cmd_target_print
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
struct cmd_if_shell_data {
|
||||||
cmd_if_shell_init(struct cmd *self, unused int arg)
|
char *cmd;
|
||||||
{
|
struct cmd_ctx ctx;
|
||||||
struct cmd_if_shell_data *data;
|
};
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->cmd = NULL;
|
|
||||||
data->sh_cmd = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_if_shell_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_if_shell_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 != 2)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
data->sh_cmd = xstrdup(argv[0]);
|
|
||||||
data->cmd = xstrdup(argv[1]);
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_if_shell_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
|
struct cmd_if_shell_data *cdata;
|
||||||
|
struct job *job;
|
||||||
|
|
||||||
|
cdata = xmalloc(sizeof *cdata);
|
||||||
|
cdata->cmd = xstrdup(data->arg2);
|
||||||
|
memcpy(&cdata->ctx, ctx, sizeof cdata->ctx);
|
||||||
|
|
||||||
|
if (ctx->cmdclient != NULL)
|
||||||
|
ctx->cmdclient->references++;
|
||||||
|
if (ctx->curclient != NULL)
|
||||||
|
ctx->curclient->references++;
|
||||||
|
|
||||||
|
job = job_add(NULL, 0, NULL,
|
||||||
|
data->arg, cmd_if_shell_callback, cmd_if_shell_free, cdata);
|
||||||
|
job_run(job);
|
||||||
|
|
||||||
|
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;
|
struct cmd_list *cmdlist;
|
||||||
char *cause;
|
char *cause;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if ((ret = system(data->sh_cmd)) < 0) {
|
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0)
|
||||||
ctx->error(ctx, "system error: %s", strerror(errno));
|
return;
|
||||||
return (-1);
|
|
||||||
} else if (ret != 0)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
if (cmd_string_parse(data->cmd, &cmdlist, &cause) != 0) {
|
if (cmd_string_parse(cdata->cmd, &cmdlist, &cause) != 0) {
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "%s", cause);
|
ctx->error(ctx, "%s", cause);
|
||||||
xfree(cause);
|
xfree(cause);
|
||||||
}
|
}
|
||||||
return (-1);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd_list_exec(cmdlist, ctx) < 0) {
|
if (cmd_list_exec(cmdlist, ctx) < 0) {
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
return (-1);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_if_shell_free(struct cmd *self)
|
cmd_if_shell_free(void *data)
|
||||||
{
|
{
|
||||||
struct cmd_if_shell_data *data = self->data;
|
struct cmd_if_shell_data *cdata = data;
|
||||||
|
struct cmd_ctx *ctx = &cdata->ctx;
|
||||||
|
struct msg_exit_data exitdata;
|
||||||
|
|
||||||
if (data->cmd != NULL)
|
if (ctx->cmdclient != NULL) {
|
||||||
xfree(data->cmd);
|
ctx->cmdclient->references--;
|
||||||
if (data->sh_cmd != NULL)
|
exitdata.retcode = ctx->cmdclient->retcode;
|
||||||
xfree(data->sh_cmd);
|
ctx->cmdclient->flags |= CLIENT_EXIT;
|
||||||
xfree(data);
|
}
|
||||||
}
|
if (ctx->curclient != NULL)
|
||||||
|
ctx->curclient->references--;
|
||||||
size_t
|
|
||||||
cmd_if_shell_print(struct cmd *self, char *buf, size_t len)
|
xfree(cdata->cmd);
|
||||||
{
|
xfree(cdata);
|
||||||
struct cmd_if_shell_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->sh_cmd != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->sh_cmd);
|
|
||||||
if (off < len && data->cmd != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->cmd);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
257
cmd-join-pane.c
Normal file
257
cmd-join-pane.c
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
/* $Id: cmd-join-pane.c,v 1.5 2010-08-11 22:17:32 tcunha 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 <unistd.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Join a pane into another (like split/swap/kill).
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_join_pane_parse(struct cmd *, int, char **, char **);
|
||||||
|
int cmd_join_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
void cmd_join_pane_free(struct cmd *);
|
||||||
|
void cmd_join_pane_init(struct cmd *, int);
|
||||||
|
size_t cmd_join_pane_print(struct cmd *, char *, size_t);
|
||||||
|
|
||||||
|
struct cmd_join_pane_data {
|
||||||
|
char *src;
|
||||||
|
char *dst;
|
||||||
|
int flag_detached;
|
||||||
|
int flag_horizontal;
|
||||||
|
int percentage;
|
||||||
|
int size;
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_join_pane_entry = {
|
||||||
|
"join-pane", "joinp",
|
||||||
|
"[-dhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
||||||
|
0, "",
|
||||||
|
cmd_join_pane_init,
|
||||||
|
cmd_join_pane_parse,
|
||||||
|
cmd_join_pane_exec,
|
||||||
|
cmd_join_pane_free,
|
||||||
|
cmd_join_pane_print
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_join_pane_init(struct cmd *self, int key)
|
||||||
|
{
|
||||||
|
struct cmd_join_pane_data *data;
|
||||||
|
|
||||||
|
self->data = data = xmalloc(sizeof *data);
|
||||||
|
data->src = NULL;
|
||||||
|
data->dst = NULL;
|
||||||
|
data->flag_detached = 0;
|
||||||
|
data->flag_horizontal = 0;
|
||||||
|
data->percentage = -1;
|
||||||
|
data->size = -1;
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case '%':
|
||||||
|
data->flag_horizontal = 1;
|
||||||
|
break;
|
||||||
|
case '"':
|
||||||
|
data->flag_horizontal = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_join_pane_parse(struct cmd *self, int argc, char **argv, char **cause)
|
||||||
|
{
|
||||||
|
struct cmd_join_pane_data *data;
|
||||||
|
int opt;
|
||||||
|
const char *errstr;
|
||||||
|
|
||||||
|
self->entry->init(self, KEYC_NONE);
|
||||||
|
data = self->data;
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "dhl:p:s:t:v")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'd':
|
||||||
|
data->flag_detached = 1;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
data->flag_horizontal = 1;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
if (data->src == NULL)
|
||||||
|
data->src = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
if (data->dst == NULL)
|
||||||
|
data->dst = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
if (data->percentage != -1 || data->size != -1)
|
||||||
|
break;
|
||||||
|
data->size = strtonum(optarg, 1, INT_MAX, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
xasprintf(cause, "size %s", errstr);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
if (data->size != -1 || data->percentage != -1)
|
||||||
|
break;
|
||||||
|
data->percentage = strtonum(optarg, 1, 100, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
xasprintf(cause, "percentage %s", errstr);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
data->flag_horizontal = 0;
|
||||||
|
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
|
||||||
|
cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct cmd_join_pane_data *data = self->data;
|
||||||
|
struct session *dst_s;
|
||||||
|
struct winlink *src_wl, *dst_wl;
|
||||||
|
struct window *src_w, *dst_w;
|
||||||
|
struct window_pane *src_wp, *dst_wp;
|
||||||
|
int size, dst_idx;
|
||||||
|
enum layout_type type;
|
||||||
|
struct layout_cell *lc;
|
||||||
|
|
||||||
|
if ((dst_wl = cmd_find_pane(ctx, data->dst, &dst_s, &dst_wp)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
dst_w = dst_wl->window;
|
||||||
|
dst_idx = dst_wl->idx;
|
||||||
|
|
||||||
|
if ((src_wl = cmd_find_pane(ctx, data->src, NULL, &src_wp)) == 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 (data->flag_horizontal)
|
||||||
|
type = LAYOUT_LEFTRIGHT;
|
||||||
|
|
||||||
|
size = -1;
|
||||||
|
if (data->size != -1)
|
||||||
|
size = data->size;
|
||||||
|
else if (data->percentage != -1) {
|
||||||
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
|
size = (dst_wp->sy * data->percentage) / 100;
|
||||||
|
else
|
||||||
|
size = (dst_wp->sx * data->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 (!data->flag_detached) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_join_pane_free(struct cmd *self)
|
||||||
|
{
|
||||||
|
struct cmd_join_pane_data *data = self->data;
|
||||||
|
|
||||||
|
if (data->src != NULL)
|
||||||
|
xfree(data->src);
|
||||||
|
if (data->dst != NULL)
|
||||||
|
xfree(data->dst);
|
||||||
|
xfree(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
cmd_join_pane_print(struct cmd *self, char *buf, size_t len)
|
||||||
|
{
|
||||||
|
struct cmd_join_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_detached)
|
||||||
|
off += xsnprintf(buf + off, len - off, " -d");
|
||||||
|
if (off < len && data->flag_horizontal)
|
||||||
|
off += xsnprintf(buf + off, len - off, " -h");
|
||||||
|
if (off < len && data->size > 0)
|
||||||
|
off += xsnprintf(buf + off, len - off, " -l %d", data->size);
|
||||||
|
if (off < len && data->percentage > 0) {
|
||||||
|
off += xsnprintf(
|
||||||
|
buf + off, len - off, " -p %d", data->percentage);
|
||||||
|
}
|
||||||
|
if (off < len && data->src != NULL)
|
||||||
|
off += cmd_prarg(buf + off, len - off, " -s ", data->src);
|
||||||
|
if (off < len && data->dst != NULL)
|
||||||
|
off += cmd_prarg(buf + off, len - off, " -t ", data->dst);
|
||||||
|
return (off);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-kill-pane.c,v 1.12 2009-07-30 20:45:20 tcunha Exp $ */
|
/* $Id: cmd-kill-pane.c,v 1.15 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,8 +30,8 @@ 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_TARGET_PANE_USAGE,
|
"[-a] " CMD_TARGET_PANE_USAGE,
|
||||||
0, 0,
|
0, "a",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_kill_pane_exec,
|
cmd_kill_pane_exec,
|
||||||
@@ -44,7 +44,7 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window_pane *wp;
|
struct window_pane *loopwp, *nextwp, *wp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, data->target, NULL, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, data->target, NULL, &wp)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -52,11 +52,25 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (window_count_panes(wl->window) == 1) {
|
if (window_count_panes(wl->window) == 1) {
|
||||||
/* Only one pane, kill the window. */
|
/* Only one pane, kill the window. */
|
||||||
server_kill_window(wl->window);
|
server_kill_window(wl->window);
|
||||||
|
recalculate_sizes();
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout_close_pane(wp);
|
if (cmd_check_flag(data->chflags, 'a')) {
|
||||||
window_remove_pane(wl->window, wp);
|
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);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-kill-server.c,v 1.8 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-kill-server.c,v 1.11 2009-11-28 14:50:36 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -32,7 +32,7 @@ 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, "",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_kill_server_exec,
|
cmd_kill_server_exec,
|
||||||
@@ -40,10 +40,11 @@ const struct cmd_entry cmd_kill_server_entry = {
|
|||||||
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.14 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-kill-session.c,v 1.18 2010-07-02 02:43:50 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -32,7 +32,7 @@ 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,
|
||||||
CMD_TARGET_SESSION_USAGE,
|
CMD_TARGET_SESSION_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_kill_session_exec,
|
cmd_kill_session_exec,
|
||||||
@@ -45,21 +45,11 @@ cmd_kill_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
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, data->target)) == 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.19 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-kill-window.c,v 1.21 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ 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",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_kill_window_exec,
|
cmd_kill_window_exec,
|
||||||
@@ -47,6 +47,7 @@ cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
server_kill_window(wl->window);
|
server_kill_window(wl->window);
|
||||||
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id: cmd-down-pane.c,v 1.12 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-last-pane.c,v 1.1 2010-10-24 01:34:30 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
@@ -21,24 +21,24 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move down a pane.
|
* Move to last pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_down_pane_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_last_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_down_pane_entry = {
|
const struct cmd_entry cmd_last_pane_entry = {
|
||||||
"down-pane", "downp",
|
"last-pane", "lastp",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_down_pane_exec,
|
cmd_last_pane_exec,
|
||||||
cmd_target_free,
|
cmd_target_free,
|
||||||
cmd_target_print
|
cmd_target_print
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_last_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
@@ -48,12 +48,11 @@ cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
do {
|
if (w->last == NULL) {
|
||||||
w->active = TAILQ_NEXT(w->active, entry);
|
ctx->error(ctx, "no last pane");
|
||||||
if (w->active == NULL)
|
return (-1);
|
||||||
w->active = TAILQ_FIRST(&w->panes);
|
}
|
||||||
} while (!window_pane_visible(w->active));
|
window_set_active_pane(w, w->last);
|
||||||
server_status_window(wl->window);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-last-window.c,v 1.18 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-last-window.c,v 1.19 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ int cmd_last_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_last_window_entry = {
|
const struct cmd_entry cmd_last_window_entry = {
|
||||||
"last-window", "last",
|
"last-window", "last",
|
||||||
CMD_TARGET_SESSION_USAGE,
|
CMD_TARGET_SESSION_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_last_window_exec,
|
cmd_last_window_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-link-window.c,v 1.32 2009-08-16 19:16:27 tcunha Exp $ */
|
/* $Id: cmd-link-window.c,v 1.36 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ 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",
|
||||||
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
0, CMD_CHFLAG('d')|CMD_CHFLAG('k'),
|
0, "dk",
|
||||||
cmd_srcdst_init,
|
cmd_srcdst_init,
|
||||||
cmd_srcdst_parse,
|
cmd_srcdst_parse,
|
||||||
cmd_link_window_exec,
|
cmd_link_window_exec,
|
||||||
@@ -43,55 +43,23 @@ 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 cmd_srcdst_data *data = self->data;
|
||||||
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, data->src, &src)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
if ((idx = cmd_find_index(ctx, data->dst, &dst)) == -2)
|
if ((idx = cmd_find_index(ctx, data->dst, &dst)) == -2)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
wl_dst = NULL;
|
kflag = cmd_check_flag(data->chflags, 'k');
|
||||||
if (idx != -1)
|
dflag = cmd_check_flag(data->chflags, 'd');
|
||||||
wl_dst = winlink_find_by_index(&dst->windows, idx);
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||||
if (wl_dst != NULL) {
|
ctx->error(ctx, "can't link window: %s", cause);
|
||||||
if (wl_dst->window == wl_src->window)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('k')) {
|
|
||||||
/*
|
|
||||||
* 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->chflags &= ~CMD_CHFLAG('d');
|
|
||||||
dst->curw = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (idx == -1)
|
|
||||||
idx = -1 - options_get_number(&dst->options, "base-index");
|
|
||||||
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->chflags & CMD_CHFLAG('d'))
|
|
||||||
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.12 2009-09-07 23:48:54 tcunha Exp $ */
|
/* $Id: cmd-list-buffers.c,v 1.16 2010-06-22 23:35:20 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ 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,
|
CMD_TARGET_SESSION_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_list_buffers_exec,
|
cmd_list_buffers_exec,
|
||||||
@@ -46,32 +46,17 @@ cmd_list_buffers_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct session *s;
|
struct session *s;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
char tmp[51 * 4 + 1];
|
char *tmp;
|
||||||
size_t size, len;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) {
|
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) {
|
||||||
size = pb->size;
|
tmp = paste_print(pb, 50);
|
||||||
|
ctx->print(ctx,
|
||||||
/* Translate the first 50 characters. */
|
"%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp);
|
||||||
len = size;
|
xfree(tmp);
|
||||||
if (len > 50)
|
|
||||||
len = 50;
|
|
||||||
strvisx(tmp, pb->data, len, VIS_OCTAL|VIS_TAB|VIS_NL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the first 50 characterswere encoded as a longer string,
|
|
||||||
* or there is definitely more data, add "...".
|
|
||||||
*/
|
|
||||||
if (size > 50 || strlen(tmp) > 50) {
|
|
||||||
tmp[50 - 3] = '\0';
|
|
||||||
strlcat(tmp, "...", sizeof tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->print(ctx, "%u: %zu bytes: \"%s\"", idx - 1, size, tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-clients.c,v 1.18 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-list-clients.c,v 1.20 2009-11-28 14:50:36 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -32,7 +32,7 @@ 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",
|
||||||
"",
|
"",
|
||||||
0, 0,
|
0, "",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_list_clients_exec,
|
cmd_list_clients_exec,
|
||||||
@@ -40,6 +40,7 @@ const struct cmd_entry cmd_list_clients_entry = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
cmd_list_clients_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_clients_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-commands.c,v 1.5 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-list-commands.c,v 1.7 2009-11-28 14:50:36 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ 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, "",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_list_commands_exec,
|
cmd_list_commands_exec,
|
||||||
@@ -37,6 +37,7 @@ const struct cmd_entry cmd_list_commands_entry = {
|
|||||||
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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-keys.c,v 1.20 2009-07-28 23:19:06 tcunha Exp $ */
|
/* $Id: cmd-list-keys.c,v 1.25 2010-10-24 01:31:57 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -33,7 +33,7 @@ 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 key-table]",
|
"[-t key-table]",
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_list_keys_exec,
|
cmd_list_keys_exec,
|
||||||
@@ -47,7 +47,8 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
const char *key;
|
const char *key;
|
||||||
char tmp[BUFSIZ], keytmp[64];
|
char tmp[BUFSIZ];
|
||||||
|
size_t used;
|
||||||
int width, keywidth;
|
int width, keywidth;
|
||||||
|
|
||||||
if (data->target != NULL)
|
if (data->target != NULL)
|
||||||
@@ -70,14 +71,22 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
used = xsnprintf(tmp, sizeof tmp, "%*s: ", width, key);
|
||||||
|
if (used >= sizeof tmp)
|
||||||
|
continue;
|
||||||
|
|
||||||
*tmp = '\0';
|
|
||||||
cmd_list_print(bd->cmdlist, tmp, sizeof tmp);
|
|
||||||
if (!(bd->key & KEYC_PREFIX)) {
|
if (!(bd->key & KEYC_PREFIX)) {
|
||||||
xsnprintf(keytmp, sizeof keytmp, "[%s]", key);
|
used = strlcat(tmp, "(no prefix) ", sizeof tmp);
|
||||||
key = keytmp;
|
if (used >= sizeof tmp)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
ctx->print(ctx, "%*s: %s", width, key, tmp);
|
if (bd->can_repeat) {
|
||||||
|
used = strlcat(tmp, "(repeat) ", sizeof tmp);
|
||||||
|
if (used >= sizeof tmp)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
cmd_list_print(bd->cmdlist, tmp + used, (sizeof tmp) - used);
|
||||||
|
ctx->print(ctx, "%s", tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
76
cmd-list-panes.c
Normal file
76
cmd-list-panes.c
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/* $Id: cmd-list-panes.c,v 1.6 2010-12-06 21:56:32 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 <unistd.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List panes on given window.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_list_panes_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_list_panes_entry = {
|
||||||
|
"list-panes", "lsp",
|
||||||
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
|
0, "",
|
||||||
|
cmd_target_init,
|
||||||
|
cmd_target_parse,
|
||||||
|
cmd_list_panes_exec,
|
||||||
|
cmd_target_free,
|
||||||
|
cmd_target_print
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct cmd_target_data *data = self->data;
|
||||||
|
struct winlink *wl;
|
||||||
|
struct window_pane *wp;
|
||||||
|
struct grid *gd;
|
||||||
|
struct grid_line *gl;
|
||||||
|
u_int i, n;
|
||||||
|
unsigned long long size;
|
||||||
|
|
||||||
|
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||||
|
gd = wp->base.grid;
|
||||||
|
|
||||||
|
size = 0;
|
||||||
|
for (i = 0; i < gd->hsize; i++) {
|
||||||
|
gl = &gd->linedata[i];
|
||||||
|
size += gl->cellsize * sizeof *gl->celldata;
|
||||||
|
size += gl->utf8size * sizeof *gl->utf8data;
|
||||||
|
}
|
||||||
|
size += gd->hsize * sizeof *gd->linedata;
|
||||||
|
|
||||||
|
ctx->print(ctx, "%u: [%ux%u] [history %u/%u, %llu bytes]%s%s",
|
||||||
|
n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size,
|
||||||
|
wp == wp->window->active ? " (active)" : "",
|
||||||
|
wp->fd == -1 ? " (dead)" : "");
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-sessions.c,v 1.21 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-list-sessions.c,v 1.26 2010-12-22 15:36:44 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ 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", "",
|
||||||
0, 0,
|
0, "",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_list_sessions_exec,
|
cmd_list_sessions_exec,
|
||||||
@@ -39,26 +39,32 @@ const struct cmd_entry cmd_list_sessions_entry = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
cmd_list_sessions_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_sessions_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
char *tim;
|
struct session_group *sg;
|
||||||
u_int i;
|
char *tim, tmp[64];
|
||||||
time_t t;
|
u_int idx;
|
||||||
|
time_t t;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
s = ARRAY_ITEM(&sessions, i);
|
sg = session_group_find(s);
|
||||||
if (s == NULL)
|
if (sg == NULL)
|
||||||
continue;
|
*tmp = '\0';
|
||||||
|
else {
|
||||||
|
idx = session_group_index(sg);
|
||||||
|
xsnprintf(tmp, sizeof tmp, " (group %u)", idx);
|
||||||
|
}
|
||||||
|
|
||||||
t = s->tv.tv_sec;
|
t = s->creation_time.tv_sec;
|
||||||
tim = ctime(&t);
|
tim = ctime(&t);
|
||||||
*strchr(tim, '\n') = '\0';
|
*strchr(tim, '\n') = '\0';
|
||||||
|
|
||||||
ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]%s",
|
ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]%s%s",
|
||||||
s->name, winlink_count(&s->windows), tim, s->sx, s->sy,
|
s->name, winlink_count(&s->windows), tim, s->sx, s->sy,
|
||||||
s->flags & SESSION_UNATTACHED ? "" : " (attached)");
|
tmp, s->flags & SESSION_UNATTACHED ? "" : " (attached)");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-windows.c,v 1.40 2009-08-09 17:28:23 tcunha Exp $ */
|
/* $Id: cmd-list-windows.c,v 1.44 2010-12-06 21:56:32 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ int cmd_list_windows_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
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,
|
CMD_TARGET_SESSION_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_list_windows_exec,
|
cmd_list_windows_exec,
|
||||||
@@ -45,42 +45,17 @@ cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window *w;
|
char *layout;
|
||||||
struct window_pane *wp;
|
|
||||||
struct grid *gd;
|
|
||||||
struct grid_line *gl;
|
|
||||||
u_int i;
|
|
||||||
unsigned long long size;
|
|
||||||
const char *name;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
w = wl->window;
|
layout = layout_dump(wl->window);
|
||||||
ctx->print(ctx,
|
ctx->print(ctx, "%d: %s [%ux%u] [layout %s]%s",
|
||||||
"%3d: %s [%ux%u]", wl->idx, w->name, w->sx, w->sy);
|
wl->idx, wl->window->name, wl->window->sx, wl->window->sy,
|
||||||
|
layout, wl == s->curw ? " (active)" : "");
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
xfree(layout);
|
||||||
gd = wp->base.grid;
|
|
||||||
|
|
||||||
size = 0;
|
|
||||||
for (i = 0; i < gd->hsize; i++) {
|
|
||||||
gl = &gd->linedata[i];
|
|
||||||
size += gl->cellsize * sizeof *gl->celldata;
|
|
||||||
size += gl->utf8size * sizeof *gl->utf8data;
|
|
||||||
}
|
|
||||||
size += gd->hsize * sizeof *gd->linedata;
|
|
||||||
|
|
||||||
name = NULL;
|
|
||||||
if (wp->fd != -1)
|
|
||||||
name = ttyname(wp->fd);
|
|
||||||
if (name == NULL)
|
|
||||||
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);
|
||||||
|
|||||||
73
cmd-list.c
73
cmd-list.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list.c,v 1.6 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-list.c,v 1.10 2010-12-06 21:48:56 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,47 +29,52 @@ cmd_list_parse(int argc, char **argv, char **cause)
|
|||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
int i, lastsplit;
|
int i, lastsplit;
|
||||||
size_t arglen, new_argc;
|
size_t arglen, new_argc;
|
||||||
char **new_argv;
|
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++) {
|
||||||
arglen = strlen(argv[i]);
|
arglen = strlen(copy_argv[i]);
|
||||||
if (arglen == 0 || argv[i][arglen - 1] != ';')
|
if (arglen == 0 || copy_argv[i][arglen - 1] != ';')
|
||||||
continue;
|
continue;
|
||||||
argv[i][arglen - 1] = '\0';
|
copy_argv[i][arglen - 1] = '\0';
|
||||||
|
|
||||||
if (arglen > 1 && argv[i][arglen - 2] == '\\') {
|
if (arglen > 1 && copy_argv[i][arglen - 2] == '\\') {
|
||||||
argv[i][arglen - 2] = ';';
|
copy_argv[i][arglen - 2] = ';';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_argc = i - lastsplit;
|
new_argc = i - lastsplit;
|
||||||
new_argv = argv + lastsplit;
|
new_argv = copy_argv + lastsplit;
|
||||||
if (arglen != 1)
|
if (arglen != 1)
|
||||||
new_argc++;
|
new_argc++;
|
||||||
|
|
||||||
cmd = cmd_parse(new_argc, new_argv, cause);
|
cmd = cmd_parse(new_argc, new_argv, cause);
|
||||||
if (cmd == NULL)
|
if (cmd == NULL)
|
||||||
goto bad;
|
goto bad;
|
||||||
TAILQ_INSERT_TAIL(cmdlist, cmd, qentry);
|
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
||||||
|
|
||||||
lastsplit = i + 1;
|
lastsplit = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastsplit != argc) {
|
if (lastsplit != argc) {
|
||||||
cmd = cmd_parse(argc - lastsplit, argv + lastsplit, cause);
|
cmd = cmd_parse(argc - lastsplit, copy_argv + lastsplit, cause);
|
||||||
if (cmd == NULL)
|
if (cmd == NULL)
|
||||||
goto bad;
|
goto bad;
|
||||||
TAILQ_INSERT_TAIL(cmdlist, cmd, qentry);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,13 +82,36 @@ 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
|
void
|
||||||
@@ -91,9 +119,12 @@ 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);
|
||||||
@@ -106,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.10 2009-09-07 23:48:54 tcunha Exp $ */
|
/* $Id: cmd-load-buffer.c,v 1.18 2010-12-22 15:28:50 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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>
|
||||||
@@ -31,11 +31,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
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",
|
CMD_BUFFER_SESSION_USAGE " path",
|
||||||
CMD_ARG1, 0,
|
CMD_ARG1, "",
|
||||||
cmd_buffer_init,
|
cmd_buffer_init,
|
||||||
cmd_buffer_parse,
|
cmd_buffer_parse,
|
||||||
cmd_load_buffer_exec,
|
cmd_load_buffer_exec,
|
||||||
@@ -43,22 +44,51 @@ const struct cmd_entry cmd_load_buffer_entry = {
|
|||||||
cmd_buffer_print
|
cmd_buffer_print
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct cmd_load_buffer_cdata {
|
||||||
|
struct session *session;
|
||||||
|
int buffer;
|
||||||
|
};
|
||||||
|
|
||||||
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 cmd_buffer_data *data = self->data;
|
||||||
struct session *s;
|
struct cmd_load_buffer_cdata *cdata;
|
||||||
struct stat sb;
|
struct session *s;
|
||||||
FILE *f;
|
struct client *c = ctx->cmdclient;
|
||||||
u_char *buf;
|
FILE *f;
|
||||||
u_int limit;
|
char *pdata, *new_pdata;
|
||||||
|
size_t psize;
|
||||||
|
u_int limit;
|
||||||
|
int ch;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (stat(data->arg, &sb) < 0) {
|
if (strcmp(data->arg, "-") == 0) {
|
||||||
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
|
if (c == NULL) {
|
||||||
return (-1);
|
ctx->error(ctx, "%s: can't read from stdin", data->arg);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (c->flags & CLIENT_TERMINAL) {
|
||||||
|
ctx->error(ctx, "%s: stdin is a tty", data->arg);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (c->stdin_fd == -1) {
|
||||||
|
ctx->error(ctx, "%s: can't read from stdin", data->arg);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
cdata = xmalloc(sizeof *cdata);
|
||||||
|
cdata->session = s;
|
||||||
|
cdata->session->references++;
|
||||||
|
cdata->buffer = data->buffer;
|
||||||
|
c->stdin_data = cdata;
|
||||||
|
c->stdin_callback = cmd_load_buffer_callback;
|
||||||
|
|
||||||
|
c->references++;
|
||||||
|
bufferevent_enable(c->stdin_event, EV_READ);
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((f = fopen(data->arg, "rb")) == NULL) {
|
if ((f = fopen(data->arg, "rb")) == NULL) {
|
||||||
@@ -66,35 +96,90 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
pdata = NULL;
|
||||||
* We don't want to die due to memory exhaustion, hence xmalloc can't
|
psize = 0;
|
||||||
* be used here.
|
while ((ch = getc(f)) != EOF) {
|
||||||
*/
|
/* Do not let the server die due to memory exhaustion. */
|
||||||
if ((buf = malloc(sb.st_size + 1)) == NULL) {
|
if ((new_pdata = realloc(pdata, psize + 2)) == NULL) {
|
||||||
ctx->error(ctx, "malloc error: %s", strerror(errno));
|
ctx->error(ctx, "realloc error: %s", strerror(errno));
|
||||||
fclose(f);
|
goto error;
|
||||||
return (-1);
|
}
|
||||||
|
pdata = new_pdata;
|
||||||
|
pdata[psize++] = ch;
|
||||||
}
|
}
|
||||||
|
if (ferror(f)) {
|
||||||
if (fread(buf, 1, sb.st_size, f) != (size_t) sb.st_size) {
|
ctx->error(ctx, "%s: read error", data->arg);
|
||||||
ctx->error(ctx, "%s: fread error", data->arg);
|
goto error;
|
||||||
xfree(buf);
|
|
||||||
fclose(f);
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
if (pdata != NULL)
|
||||||
|
pdata[psize] = '\0';
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
f = NULL;
|
||||||
|
|
||||||
limit = options_get_number(&s->options, "buffer-limit");
|
limit = options_get_number(&s->options, "buffer-limit");
|
||||||
if (data->buffer == -1) {
|
if (data->buffer == -1) {
|
||||||
paste_add(&s->buffers, buf, sb.st_size, limit);
|
paste_add(&s->buffers, pdata, psize, limit);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (paste_replace(&s->buffers, data->buffer, buf, sb.st_size) != 0) {
|
if (paste_replace(&s->buffers, data->buffer, pdata, psize) != 0) {
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
ctx->error(ctx, "no buffer %d", data->buffer);
|
||||||
xfree(buf);
|
|
||||||
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)
|
||||||
|
{
|
||||||
|
struct cmd_load_buffer_cdata *cdata = data;
|
||||||
|
struct session *s = cdata->session;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/* Does the target session still exist? */
|
||||||
|
if (!session_alive(s))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
psize = EVBUFFER_LENGTH(c->stdin_event->input);
|
||||||
|
if (psize == 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
pdata = malloc(psize + 1);
|
||||||
|
if (pdata == NULL)
|
||||||
|
goto out;
|
||||||
|
bufferevent_read(c->stdin_event, pdata, psize);
|
||||||
|
pdata[psize] = '\0';
|
||||||
|
|
||||||
|
limit = options_get_number(&s->options, "buffer-limit");
|
||||||
|
if (cdata->buffer == -1) {
|
||||||
|
paste_add(&s->buffers, pdata, psize, limit);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (paste_replace(&s->buffers, cdata->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", cdata->buffer);
|
||||||
|
bufferevent_enable(c->stderr_event, EV_WRITE);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
cdata->session->references--;
|
||||||
|
xfree(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-up-pane.c,v 1.12 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-lock-client.c,v 1.2 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -21,39 +21,33 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move up a pane.
|
* Lock a single client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_up_pane_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_lock_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_up_pane_entry = {
|
const struct cmd_entry cmd_lock_client_entry = {
|
||||||
"up-pane", "upp",
|
"lock-client", "lockc",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_up_pane_exec,
|
cmd_lock_client_exec,
|
||||||
cmd_target_free,
|
cmd_target_free,
|
||||||
cmd_target_print
|
cmd_target_print
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_up_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_lock_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
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, data->target)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
|
||||||
|
|
||||||
do {
|
server_lock_client(c);
|
||||||
w->active = TAILQ_PREV(w->active, window_panes, entry);
|
recalculate_sizes();
|
||||||
if (w->active == NULL)
|
|
||||||
w->active = TAILQ_LAST(&w->panes, window_panes);
|
|
||||||
} while (!window_pane_visible(w->active));
|
|
||||||
server_status_window(wl->window);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-lock-server.c,v 1.6 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-lock-server.c,v 1.9 2009-11-28 14:50:36 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -33,7 +33,7 @@ int cmd_lock_server_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_lock_server_entry = {
|
const struct cmd_entry cmd_lock_server_entry = {
|
||||||
"lock-server", "lock",
|
"lock-server", "lock",
|
||||||
"",
|
"",
|
||||||
0, 0,
|
0, "",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_lock_server_exec,
|
cmd_lock_server_exec,
|
||||||
@@ -41,10 +41,12 @@ const struct cmd_entry cmd_lock_server_entry = {
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
cmd_lock_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_lock_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
server_lock();
|
server_lock();
|
||||||
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id: cmd-scroll-mode.c,v 1.23 2009-08-20 11:37:46 tcunha Exp $ */
|
/* $Id: cmd-lock-session.c,v 1.2 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
@@ -21,50 +21,33 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enter scroll mode.
|
* Lock all clients attached to a session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_scroll_mode_init(struct cmd *, int);
|
int cmd_lock_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
int cmd_scroll_mode_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_scroll_mode_entry = {
|
const struct cmd_entry cmd_lock_session_entry = {
|
||||||
"scroll-mode", NULL,
|
"lock-session", "locks",
|
||||||
"[-u] " CMD_TARGET_PANE_USAGE,
|
CMD_TARGET_SESSION_USAGE,
|
||||||
0, CMD_CHFLAG('u'),
|
0, "",
|
||||||
cmd_scroll_mode_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_scroll_mode_exec,
|
cmd_lock_session_exec,
|
||||||
cmd_target_free,
|
cmd_target_free,
|
||||||
cmd_target_print
|
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->chflags |= CMD_CHFLAG('u');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_scroll_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_lock_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct window_pane *wp;
|
struct session *s;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
|
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
window_pane_set_mode(wp, &window_scroll_mode);
|
server_lock_session(s);
|
||||||
if (wp->mode == &window_scroll_mode && data->chflags & CMD_CHFLAG('u'))
|
recalculate_sizes();
|
||||||
window_scroll_pageup(wp);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-move-window.c,v 1.9 2009-08-16 19:16:27 tcunha Exp $ */
|
/* $Id: cmd-move-window.c,v 1.13 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ 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",
|
||||||
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
0, CMD_CHFLAG('d')|CMD_CHFLAG('k'),
|
0, "dk",
|
||||||
cmd_srcdst_init,
|
cmd_srcdst_init,
|
||||||
cmd_srcdst_parse,
|
cmd_srcdst_parse,
|
||||||
cmd_move_window_exec,
|
cmd_move_window_exec,
|
||||||
@@ -44,68 +44,23 @@ cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
{
|
{
|
||||||
struct cmd_srcdst_data *data = self->data;
|
struct cmd_srcdst_data *data = self->data;
|
||||||
struct session *src, *dst;
|
struct session *src, *dst;
|
||||||
struct winlink *wl_src, *wl_dst;
|
struct winlink *wl;
|
||||||
struct client *c;
|
|
||||||
u_int i;
|
|
||||||
int destroyed, idx;
|
|
||||||
char *cause;
|
char *cause;
|
||||||
|
int idx, kflag, dflag;
|
||||||
|
|
||||||
if ((wl_src = cmd_find_window(ctx, data->src, &src)) == NULL)
|
if ((wl = cmd_find_window(ctx, data->src, &src)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
if ((idx = cmd_find_index(ctx, data->dst, &dst)) == -2)
|
if ((idx = cmd_find_index(ctx, data->dst, &dst)) == -2)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
wl_dst = NULL;
|
kflag = cmd_check_flag(data->chflags, 'k');
|
||||||
if (idx != -1)
|
dflag = cmd_check_flag(data->chflags, 'd');
|
||||||
wl_dst = winlink_find_by_index(&dst->windows, idx);
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||||
if (wl_dst != NULL) {
|
ctx->error(ctx, "can't move window: %s", cause);
|
||||||
if (wl_dst->window == wl_src->window)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('k')) {
|
|
||||||
/*
|
|
||||||
* 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->chflags &= ~CMD_CHFLAG('d');
|
|
||||||
dst->curw = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (idx == -1)
|
|
||||||
idx = -1 - options_get_number(&dst->options, "base-index");
|
|
||||||
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->chflags & CMD_CHFLAG('d'))
|
|
||||||
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.66 2009-09-16 12:36:27 nicm Exp $ */
|
/* $Id: cmd-new-session.c,v 1.80 2010-12-22 15:31:00 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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 <pwd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -35,6 +36,7 @@ void cmd_new_session_init(struct cmd *, int);
|
|||||||
size_t cmd_new_session_print(struct cmd *, char *, size_t);
|
size_t cmd_new_session_print(struct cmd *, char *, size_t);
|
||||||
|
|
||||||
struct cmd_new_session_data {
|
struct cmd_new_session_data {
|
||||||
|
char *target;
|
||||||
char *newname;
|
char *newname;
|
||||||
char *winname;
|
char *winname;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
@@ -43,8 +45,8 @@ struct cmd_new_session_data {
|
|||||||
|
|
||||||
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]",
|
"[-d] [-n window-name] [-s session-name] [-t target-session] [command]",
|
||||||
CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON, 0,
|
CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON, "",
|
||||||
cmd_new_session_init,
|
cmd_new_session_init,
|
||||||
cmd_new_session_parse,
|
cmd_new_session_parse,
|
||||||
cmd_new_session_exec,
|
cmd_new_session_exec,
|
||||||
@@ -52,6 +54,7 @@ const struct cmd_entry cmd_new_session_entry = {
|
|||||||
cmd_new_session_print
|
cmd_new_session_print
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
void
|
void
|
||||||
cmd_new_session_init(struct cmd *self, unused int arg)
|
cmd_new_session_init(struct cmd *self, unused int arg)
|
||||||
{
|
{
|
||||||
@@ -59,6 +62,7 @@ cmd_new_session_init(struct cmd *self, unused int arg)
|
|||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
self->data = data = xmalloc(sizeof *data);
|
||||||
data->flag_detached = 0;
|
data->flag_detached = 0;
|
||||||
|
data->target = NULL;
|
||||||
data->newname = NULL;
|
data->newname = NULL;
|
||||||
data->winname = NULL;
|
data->winname = NULL;
|
||||||
data->cmd = NULL;
|
data->cmd = NULL;
|
||||||
@@ -70,10 +74,10 @@ cmd_new_session_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
struct cmd_new_session_data *data;
|
struct cmd_new_session_data *data;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
self->entry->init(self, KEYC_NONE);
|
||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "ds:n:")) != -1) {
|
while ((opt = getopt(argc, argv, "ds:t:n:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'd':
|
case 'd':
|
||||||
data->flag_detached = 1;
|
data->flag_detached = 1;
|
||||||
@@ -82,6 +86,10 @@ cmd_new_session_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
if (data->newname == NULL)
|
if (data->newname == NULL)
|
||||||
data->newname = xstrdup(optarg);
|
data->newname = xstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
if (data->target == NULL)
|
||||||
|
data->target = xstrdup(optarg);
|
||||||
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
if (data->winname == NULL)
|
if (data->winname == NULL)
|
||||||
data->winname = xstrdup(optarg);
|
data->winname = xstrdup(optarg);
|
||||||
@@ -95,6 +103,9 @@ cmd_new_session_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
if (argc != 0 && argc != 1)
|
if (argc != 0 && argc != 1)
|
||||||
goto usage;
|
goto usage;
|
||||||
|
|
||||||
|
if (data->target != NULL && (argc == 1 || data->winname != NULL))
|
||||||
|
goto usage;
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
data->cmd = xstrdup(argv[0]);
|
data->cmd = xstrdup(argv[0]);
|
||||||
|
|
||||||
@@ -111,20 +122,27 @@ 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 cmd_new_session_data *data = self->data;
|
||||||
struct session *s;
|
struct session *s, *old_s, *groupwith;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
|
struct window_pane *wp;
|
||||||
struct environ env;
|
struct environ env;
|
||||||
struct termios tio, *tiop;
|
struct termios tio, *tiop;
|
||||||
const char *update;
|
struct passwd *pw;
|
||||||
char *overrides, *cmd, *cwd, *cause;
|
const char *update, *cwd;
|
||||||
|
char *overrides, *cmd, *cause;
|
||||||
int detached, idx;
|
int detached, idx;
|
||||||
u_int sx, sy;
|
u_int sx, sy, i;
|
||||||
|
|
||||||
if (data->newname != NULL && session_find(data->newname) != NULL) {
|
if (data->newname != NULL && session_find(data->newname) != NULL) {
|
||||||
ctx->error(ctx, "duplicate session: %s", data->newname);
|
ctx->error(ctx, "duplicate session: %s", data->newname);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
groupwith = NULL;
|
||||||
|
if (data->target != NULL &&
|
||||||
|
(groupwith = cmd_find_session(ctx, data->target)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There are three cases:
|
* There are three cases:
|
||||||
*
|
*
|
||||||
@@ -170,8 +188,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->error(ctx, "not a terminal");
|
ctx->error(ctx, "not a terminal");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
overrides =
|
overrides =
|
||||||
options_get_string(&global_s_options, "terminal-overrides");
|
options_get_string(&global_s_options, "terminal-overrides");
|
||||||
if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
|
if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
|
||||||
ctx->error(ctx, "open terminal failed: %s", cause);
|
ctx->error(ctx, "open terminal failed: %s", cause);
|
||||||
@@ -183,8 +201,13 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
/* Get the new session working directory. */
|
/* Get the new session working directory. */
|
||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||||
cwd = ctx->cmdclient->cwd;
|
cwd = ctx->cmdclient->cwd;
|
||||||
else
|
else {
|
||||||
cwd = options_get_string(&global_s_options, "default-path");
|
pw = getpwuid(getuid());
|
||||||
|
if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
|
||||||
|
cwd = pw->pw_dir;
|
||||||
|
else
|
||||||
|
cwd = "/";
|
||||||
|
}
|
||||||
|
|
||||||
/* Find new session size. */
|
/* Find new session size. */
|
||||||
if (detached) {
|
if (detached) {
|
||||||
@@ -205,7 +228,9 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
sy = 1;
|
sy = 1;
|
||||||
|
|
||||||
/* Figure out the command for the new window. */
|
/* Figure out the command for the new window. */
|
||||||
if (data->cmd != NULL)
|
if (data->target != NULL)
|
||||||
|
cmd = NULL;
|
||||||
|
else if (data->cmd != NULL)
|
||||||
cmd = data->cmd;
|
cmd = data->cmd;
|
||||||
else
|
else
|
||||||
cmd = options_get_string(&global_s_options, "default-command");
|
cmd = options_get_string(&global_s_options, "default-command");
|
||||||
@@ -228,7 +253,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
|
|
||||||
/* Set the initial window name if one given. */
|
/* Set the initial window name if one given. */
|
||||||
if (data->winname != NULL) {
|
if (cmd != NULL && data->winname != NULL) {
|
||||||
w = s->curw->window;
|
w = s->curw->window;
|
||||||
|
|
||||||
xfree(w->name);
|
xfree(w->name);
|
||||||
@@ -237,21 +262,55 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
options_set_number(&w->options, "automatic-rename", 0);
|
options_set_number(&w->options, "automatic-rename", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If a target session is given, this is to be part of a session group,
|
||||||
|
* so add it to the group and synchronize.
|
||||||
|
*/
|
||||||
|
if (groupwith != NULL) {
|
||||||
|
session_group_add(groupwith, s);
|
||||||
|
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
|
* 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.
|
* taking this session and needs to get MSG_READY and stay around.
|
||||||
*/
|
*/
|
||||||
if (!detached) {
|
if (!detached) {
|
||||||
if (ctx->cmdclient != NULL) {
|
if (ctx->cmdclient != NULL) {
|
||||||
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
||||||
ctx->cmdclient->session = s;
|
|
||||||
|
old_s = ctx->cmdclient->session;
|
||||||
|
if (old_s != NULL)
|
||||||
|
ctx->cmdclient->last_session = old_s;
|
||||||
|
ctx->cmdclient->session = s;
|
||||||
server_redraw_client(ctx->cmdclient);
|
server_redraw_client(ctx->cmdclient);
|
||||||
} else {
|
} else {
|
||||||
ctx->curclient->session = s;
|
old_s = ctx->curclient->session;
|
||||||
|
if (old_s != NULL)
|
||||||
|
ctx->curclient->last_session = old_s;
|
||||||
|
ctx->curclient->session = s;
|
||||||
server_redraw_client(ctx->curclient);
|
server_redraw_client(ctx->curclient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
server_update_socket();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there are still configuration file errors to display, put the new
|
||||||
|
* session's current window into more mode and display them now.
|
||||||
|
*/
|
||||||
|
if (cfg_finished && !ARRAY_EMPTY(&cfg_causes)) {
|
||||||
|
wp = s->curw->window->active;
|
||||||
|
window_pane_set_mode(wp, &window_copy_mode);
|
||||||
|
window_copy_init_for_output(wp);
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
|
||||||
|
cause = ARRAY_ITEM(&cfg_causes, i);
|
||||||
|
window_copy_add(wp, "%s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
}
|
||||||
|
ARRAY_FREE(&cfg_causes);
|
||||||
|
}
|
||||||
|
|
||||||
return (!detached); /* 1 means don't tell command client to exit */
|
return (!detached); /* 1 means don't tell command client to exit */
|
||||||
}
|
}
|
||||||
@@ -281,10 +340,12 @@ cmd_new_session_print(struct cmd *self, char *buf, size_t len)
|
|||||||
return (off);
|
return (off);
|
||||||
if (off < len && data->flag_detached)
|
if (off < len && data->flag_detached)
|
||||||
off += xsnprintf(buf + off, len - off, " -d");
|
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)
|
if (off < len && data->winname != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " -n ", data->winname);
|
off += cmd_prarg(buf + off, len - off, " -n ", data->winname);
|
||||||
|
if (off < len && data->newname != NULL)
|
||||||
|
off += cmd_prarg(buf + off, len - off, " -s ", data->newname);
|
||||||
|
if (off < len && data->target != NULL)
|
||||||
|
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
||||||
if (off < len && data->cmd != NULL)
|
if (off < len && data->cmd != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->cmd);
|
off += cmd_prarg(buf + off, len - off, " ", data->cmd);
|
||||||
return (off);
|
return (off);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-new-window.c,v 1.37 2009-08-16 19:16:27 tcunha Exp $ */
|
/* $Id: cmd-new-window.c,v 1.47 2010-07-02 02:49:19 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -36,14 +36,15 @@ struct cmd_new_window_data {
|
|||||||
char *target;
|
char *target;
|
||||||
char *name;
|
char *name;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
int flag_insert_after;
|
||||||
int flag_detached;
|
int flag_detached;
|
||||||
int flag_kill;
|
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]",
|
"[-adk] [-n window-name] [-t target-window] [command]",
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_new_window_init,
|
cmd_new_window_init,
|
||||||
cmd_new_window_parse,
|
cmd_new_window_parse,
|
||||||
cmd_new_window_exec,
|
cmd_new_window_exec,
|
||||||
@@ -51,6 +52,7 @@ const struct cmd_entry cmd_new_window_entry = {
|
|||||||
cmd_new_window_print
|
cmd_new_window_print
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
void
|
void
|
||||||
cmd_new_window_init(struct cmd *self, unused int arg)
|
cmd_new_window_init(struct cmd *self, unused int arg)
|
||||||
{
|
{
|
||||||
@@ -60,6 +62,7 @@ cmd_new_window_init(struct cmd *self, unused int arg)
|
|||||||
data->target = NULL;
|
data->target = NULL;
|
||||||
data->name = NULL;
|
data->name = NULL;
|
||||||
data->cmd = NULL;
|
data->cmd = NULL;
|
||||||
|
data->flag_insert_after = 0;
|
||||||
data->flag_detached = 0;
|
data->flag_detached = 0;
|
||||||
data->flag_kill = 0;
|
data->flag_kill = 0;
|
||||||
}
|
}
|
||||||
@@ -70,11 +73,14 @@ cmd_new_window_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
struct cmd_new_window_data *data;
|
struct cmd_new_window_data *data;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
self->entry->init(self, KEYC_NONE);
|
||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "dkt:n:")) != -1) {
|
while ((opt = getopt(argc, argv, "adkt:n:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case 'a':
|
||||||
|
data->flag_insert_after = 1;
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
data->flag_detached = 1;
|
data->flag_detached = 1;
|
||||||
break;
|
break;
|
||||||
@@ -117,42 +123,66 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
char *cmd, *cwd, *cause;
|
char *cmd, *cwd, *cause;
|
||||||
int idx;
|
int idx, last;
|
||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if ((idx = cmd_find_index(ctx, data->target, &s)) == -2)
|
if (data->flag_insert_after) {
|
||||||
return (-1);
|
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
idx = wl->idx + 1;
|
||||||
|
|
||||||
|
/* Find the next free index. */
|
||||||
|
for (last = idx; last < INT_MAX; last++) {
|
||||||
|
if (winlink_find_by_index(&s->windows, last) == NULL)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (last == INT_MAX) {
|
||||||
|
ctx->error(ctx, "no free window indexes");
|
||||||
|
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, data->target, &s)) == -2)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
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 && data->flag_kill) {
|
||||||
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;
|
data->flag_detached = 0;
|
||||||
s->curw = NULL;
|
s->curw = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = data->cmd;
|
cmd = data->cmd;
|
||||||
if (cmd == NULL)
|
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(&s->options, "default-path");
|
||||||
cwd = options_get_string(&s->options, "default-path");
|
if (*cwd == '\0') {
|
||||||
else
|
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||||
cwd = ctx->cmdclient->cwd;
|
cwd = ctx->cmdclient->cwd;
|
||||||
|
else
|
||||||
|
cwd = s->cwd;
|
||||||
|
}
|
||||||
|
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
idx = -1 - options_get_number(&s->options, "base-index");
|
idx = -1 - options_get_number(&s->options, "base-index");
|
||||||
@@ -164,9 +194,9 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
if (!data->flag_detached) {
|
if (!data->flag_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);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-next-layout.c,v 1.5 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-next-layout.c,v 1.6 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ int cmd_next_layout_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_next_layout_entry = {
|
const struct cmd_entry cmd_next_layout_entry = {
|
||||||
"next-layout", "nextl",
|
"next-layout", "nextl",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_next_layout_exec,
|
cmd_next_layout_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-next-window.c,v 1.20 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-next-window.c,v 1.21 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,7 +30,7 @@ int cmd_next_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_next_window_entry = {
|
const struct cmd_entry cmd_next_window_entry = {
|
||||||
"next-window", "next",
|
"next-window", "next",
|
||||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
0, CMD_CHFLAG('a'),
|
0, "a",
|
||||||
cmd_next_window_init,
|
cmd_next_window_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_next_window_exec,
|
cmd_next_window_exec,
|
||||||
@@ -47,7 +47,7 @@ cmd_next_window_init(struct cmd *self, int key)
|
|||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
if (key == ('n' | KEYC_ESCAPE))
|
if (key == ('n' | KEYC_ESCAPE))
|
||||||
data->chflags |= CMD_CHFLAG('a');
|
cmd_set_flag(&data->chflags, 'a');
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -61,7 +61,7 @@ cmd_next_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
activity = 0;
|
activity = 0;
|
||||||
if (data->chflags & CMD_CHFLAG('a'))
|
if (cmd_check_flag(data->chflags, 'a'))
|
||||||
activity = 1;
|
activity = 1;
|
||||||
|
|
||||||
if (session_next(s, activity) == 0)
|
if (session_next(s, activity) == 0)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-paste-buffer.c,v 1.20 2009-09-07 23:48:54 tcunha Exp $ */
|
/* $Id: cmd-paste-buffer.c,v 1.29 2010-08-11 22:17:32 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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"
|
||||||
@@ -26,32 +27,112 @@
|
|||||||
* Paste paste buffer if present.
|
* Paste paste buffer if present.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct cmd_paste_buffer_data {
|
||||||
|
char *target;
|
||||||
|
int buffer;
|
||||||
|
|
||||||
|
int flag_delete;
|
||||||
|
char *sepstr;
|
||||||
|
};
|
||||||
|
|
||||||
|
void cmd_paste_buffer_init(struct cmd *, int);
|
||||||
|
int cmd_paste_buffer_parse(struct cmd *, int, char **, char **);
|
||||||
int cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_paste_buffer_lf2cr(struct buffer *, const char *, size_t);
|
void cmd_paste_buffer_filter(
|
||||||
|
struct window_pane *, const char *, size_t, char *);
|
||||||
|
void cmd_paste_buffer_free(struct cmd *);
|
||||||
|
size_t cmd_paste_buffer_print(struct cmd *, char *, size_t);
|
||||||
|
|
||||||
const struct cmd_entry cmd_paste_buffer_entry = {
|
const struct cmd_entry cmd_paste_buffer_entry = {
|
||||||
"paste-buffer", "pasteb",
|
"paste-buffer", "pasteb",
|
||||||
"[-dr] " CMD_BUFFER_WINDOW_USAGE,
|
"[-dr] [-s separator] [-b buffer-index] [-t target-pane]",
|
||||||
0, CMD_CHFLAG('d')|CMD_CHFLAG('r'),
|
0, "",
|
||||||
cmd_buffer_init,
|
cmd_paste_buffer_init,
|
||||||
cmd_buffer_parse,
|
cmd_paste_buffer_parse,
|
||||||
cmd_paste_buffer_exec,
|
cmd_paste_buffer_exec,
|
||||||
cmd_buffer_free,
|
cmd_paste_buffer_free,
|
||||||
cmd_buffer_print
|
cmd_paste_buffer_print
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
|
void
|
||||||
|
cmd_paste_buffer_init(struct cmd *self, unused int arg)
|
||||||
|
{
|
||||||
|
struct cmd_paste_buffer_data *data;
|
||||||
|
|
||||||
|
self->data = data = xmalloc(sizeof *data);
|
||||||
|
data->target = NULL;
|
||||||
|
data->buffer = -1;
|
||||||
|
data->flag_delete = 0;
|
||||||
|
data->sepstr = xstrdup("\r");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_paste_buffer_parse(struct cmd *self, int argc, char **argv, char **cause)
|
||||||
|
{
|
||||||
|
struct cmd_paste_buffer_data *data;
|
||||||
|
int opt, n;
|
||||||
|
const char *errstr;
|
||||||
|
|
||||||
|
cmd_paste_buffer_init(self, 0);
|
||||||
|
data = self->data;
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "b:ds:t:r")) != -1) {
|
||||||
|
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 'd':
|
||||||
|
data->flag_delete = 1;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
if (data->sepstr != NULL)
|
||||||
|
xfree(data->sepstr);
|
||||||
|
data->sepstr = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
if (data->target == NULL)
|
||||||
|
data->target = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
if (data->sepstr != NULL)
|
||||||
|
xfree(data->sepstr);
|
||||||
|
data->sepstr = xstrdup("\n");
|
||||||
|
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
|
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 cmd_paste_buffer_data *data = self->data;
|
||||||
struct winlink *wl;
|
struct window_pane *wp;
|
||||||
struct window_pane *wp;
|
struct session *s;
|
||||||
struct session *s;
|
struct paste_buffer *pb;
|
||||||
struct paste_buffer *pb;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
if (cmd_find_pane(ctx, data->target, &s, &wp) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
wp = wl->window->active;
|
|
||||||
|
|
||||||
if (data->buffer == -1)
|
if (data->buffer == -1)
|
||||||
pb = paste_get_top(&s->buffers);
|
pb = paste_get_top(&s->buffers);
|
||||||
@@ -62,39 +143,80 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb != NULL && *pb->data != '\0') {
|
if (pb != NULL)
|
||||||
/* -r means raw data without LF->CR conversion. */
|
cmd_paste_buffer_filter(wp, pb->data, pb->size, data->sepstr);
|
||||||
if (data->chflags & CMD_CHFLAG('r'))
|
|
||||||
buffer_write(wp->out, pb->data, pb->size);
|
|
||||||
else
|
|
||||||
cmd_paste_buffer_lf2cr(wp->out, pb->data, pb->size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Delete the buffer if -d. */
|
/* Delete the buffer if -d. */
|
||||||
if (data->chflags & CMD_CHFLAG('d')) {
|
if (data->flag_delete) {
|
||||||
if (data->buffer == -1)
|
if (data->buffer == -1)
|
||||||
paste_free_top(&s->buffers);
|
paste_free_top(&s->buffers);
|
||||||
else
|
else
|
||||||
paste_free_index(&s->buffers, data->buffer);
|
paste_free_index(&s->buffers, data->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add bytes to a buffer but change every '\n' to '\r'. */
|
/* Add bytes to a buffer and filter '\n' according to separator. */
|
||||||
void
|
void
|
||||||
cmd_paste_buffer_lf2cr(struct buffer *b, const char *data, size_t size)
|
cmd_paste_buffer_filter(
|
||||||
|
struct window_pane *wp, const char *data, size_t size, char *sep)
|
||||||
{
|
{
|
||||||
const char *end = data + size;
|
const char *end = data + size;
|
||||||
const char *lf;
|
const char *lf;
|
||||||
|
size_t seplen;
|
||||||
|
|
||||||
|
seplen = strlen(sep);
|
||||||
while ((lf = memchr(data, '\n', end - data)) != NULL) {
|
while ((lf = memchr(data, '\n', end - data)) != NULL) {
|
||||||
if (lf != data)
|
if (lf != data)
|
||||||
buffer_write(b, data, lf - data);
|
bufferevent_write(wp->event, data, lf - data);
|
||||||
buffer_write8(b, '\r');
|
bufferevent_write(wp->event, sep, seplen);
|
||||||
data = lf + 1;
|
data = lf + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end != data)
|
if (end != data)
|
||||||
buffer_write(b, data, end - data);
|
bufferevent_write(wp->event, data, end - data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_paste_buffer_free(struct cmd *self)
|
||||||
|
{
|
||||||
|
struct cmd_paste_buffer_data *data = self->data;
|
||||||
|
|
||||||
|
if (data->target != NULL)
|
||||||
|
xfree(data->target);
|
||||||
|
if (data->sepstr != NULL)
|
||||||
|
xfree(data->sepstr);
|
||||||
|
xfree(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
cmd_paste_buffer_print(struct cmd *self, char *buf, size_t len)
|
||||||
|
{
|
||||||
|
struct cmd_paste_buffer_data *data = self->data;
|
||||||
|
size_t off = 0;
|
||||||
|
char tmp[BUFSIZ];
|
||||||
|
int r_flag;
|
||||||
|
|
||||||
|
r_flag = 0;
|
||||||
|
if (data->sepstr != NULL)
|
||||||
|
r_flag = (data->sepstr[0] == '\n' && data->sepstr[1] == '\0');
|
||||||
|
|
||||||
|
off += xsnprintf(buf, len, "%s", self->entry->name);
|
||||||
|
if (data == NULL)
|
||||||
|
return (off);
|
||||||
|
if (off < len && data->flag_delete)
|
||||||
|
off += xsnprintf(buf + off, len - off, " -d");
|
||||||
|
if (off < len && r_flag)
|
||||||
|
off += xsnprintf(buf + off, len - off, " -r");
|
||||||
|
if (off < len && data->buffer != -1)
|
||||||
|
off += xsnprintf(buf + off, len - off, " -b %d", data->buffer);
|
||||||
|
if (off < len && data->sepstr != NULL && !r_flag) {
|
||||||
|
strnvis(
|
||||||
|
tmp, data->sepstr, sizeof tmp, VIS_OCTAL|VIS_TAB|VIS_NL);
|
||||||
|
off += cmd_prarg(buf + off, len - off, " -s ", tmp);
|
||||||
|
}
|
||||||
|
if (off < len && data->target != NULL)
|
||||||
|
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
||||||
|
return (off);
|
||||||
}
|
}
|
||||||
|
|||||||
148
cmd-pipe-pane.c
Normal file
148
cmd-pipe-pane.c
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/* $Id: cmd-pipe-pane.c,v 1.15 2010-10-24 00:45:57 tcunha 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 <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",
|
||||||
|
CMD_TARGET_PANE_USAGE "[-o] [command]",
|
||||||
|
CMD_ARG01, "o",
|
||||||
|
cmd_target_init,
|
||||||
|
cmd_target_parse,
|
||||||
|
cmd_pipe_pane_exec,
|
||||||
|
cmd_target_free,
|
||||||
|
cmd_target_print
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct cmd_target_data *data = self->data;
|
||||||
|
struct client *c;
|
||||||
|
struct window_pane *wp;
|
||||||
|
char *command;
|
||||||
|
int old_fd, pipe_fd[2], null_fd, mode;
|
||||||
|
|
||||||
|
if ((c = cmd_find_client(ctx, NULL)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
/* 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 (data->arg == NULL || *data->arg == '\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 (cmd_check_flag(data->chflags, '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, data->arg, 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);
|
||||||
|
|
||||||
|
if ((mode = fcntl(wp->pipe_fd, F_GETFL)) == -1)
|
||||||
|
fatal("fcntl failed");
|
||||||
|
if (fcntl(wp->pipe_fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
||||||
|
fatal("fcntl failed");
|
||||||
|
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,4 +1,4 @@
|
|||||||
/* $Id: cmd-previous-layout.c,v 1.4 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-previous-layout.c,v 1.6 2009-12-04 22:14:47 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ int cmd_previous_layout_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_previous_layout_entry = {
|
const struct cmd_entry cmd_previous_layout_entry = {
|
||||||
"previous-layout", "prevl",
|
"previous-layout", "prevl",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_previous_layout_exec,
|
cmd_previous_layout_exec,
|
||||||
@@ -43,7 +43,7 @@ cmd_previous_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
u_int layout;
|
u_int layout;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-previous-window.c,v 1.20 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-previous-window.c,v 1.21 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,7 +30,7 @@ int cmd_previous_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_previous_window_entry = {
|
const struct cmd_entry cmd_previous_window_entry = {
|
||||||
"previous-window", "prev",
|
"previous-window", "prev",
|
||||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
0, CMD_CHFLAG('a'),
|
0, "a",
|
||||||
cmd_previous_window_init,
|
cmd_previous_window_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_previous_window_exec,
|
cmd_previous_window_exec,
|
||||||
@@ -47,7 +47,7 @@ cmd_previous_window_init(struct cmd *self, int key)
|
|||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
if (key == ('p' | KEYC_ESCAPE))
|
if (key == ('p' | KEYC_ESCAPE))
|
||||||
data->chflags |= CMD_CHFLAG('a');
|
cmd_set_flag(&data->chflags, 'a');
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -61,7 +61,7 @@ cmd_previous_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
activity = 0;
|
activity = 0;
|
||||||
if (data->chflags & CMD_CHFLAG('a'))
|
if (cmd_check_flag(data->chflags, 'a'))
|
||||||
activity = 1;
|
activity = 1;
|
||||||
|
|
||||||
if (session_previous(s, activity) == 0)
|
if (session_previous(s, activity) == 0)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-refresh-client.c,v 1.10 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-refresh-client.c,v 1.11 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ 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,
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_refresh_client_exec,
|
cmd_refresh_client_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-rename-session.c,v 1.18 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-rename-session.c,v 1.21 2010-12-22 15:36:44 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ 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",
|
||||||
CMD_TARGET_SESSION_USAGE " new-name",
|
CMD_TARGET_SESSION_USAGE " new-name",
|
||||||
CMD_ARG1, 0,
|
CMD_ARG1, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_rename_session_exec,
|
cmd_rename_session_exec,
|
||||||
@@ -45,11 +45,18 @@ cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
|
if (data->arg != NULL && session_find(data->arg) != NULL) {
|
||||||
|
ctx->error(ctx, "duplicate session: %s", data->arg);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
RB_REMOVE(sessions, &sessions, s);
|
||||||
xfree(s->name);
|
xfree(s->name);
|
||||||
s->name = xstrdup(data->arg);
|
s->name = xstrdup(data->arg);
|
||||||
|
RB_INSERT(sessions, &sessions, s);
|
||||||
|
|
||||||
server_status_session(s);
|
server_status_session(s);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-rename-window.c,v 1.29 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-rename-window.c,v 1.31 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ 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",
|
||||||
CMD_TARGET_WINDOW_USAGE " new-name",
|
CMD_TARGET_WINDOW_USAGE " new-name",
|
||||||
CMD_ARG1, 0,
|
CMD_ARG1, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_rename_window_exec,
|
cmd_rename_window_exec,
|
||||||
@@ -53,7 +53,7 @@ cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
wl->window->name = xstrdup(data->arg);
|
wl->window->name = xstrdup(data->arg);
|
||||||
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,4 +1,4 @@
|
|||||||
/* $Id: cmd-resize-pane.c,v 1.12 2009-07-30 20:45:20 tcunha Exp $ */
|
/* $Id: cmd-resize-pane.c,v 1.14 2009-12-04 22:14:47 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,9 +31,8 @@ int cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_resize_pane_entry = {
|
const struct cmd_entry cmd_resize_pane_entry = {
|
||||||
"resize-pane", "resizep",
|
"resize-pane", "resizep",
|
||||||
"[-DU] " CMD_TARGET_PANE_USAGE " [adjustment]",
|
"[-DLRU] " CMD_TARGET_PANE_USAGE " [adjustment]",
|
||||||
CMD_ARG01,
|
CMD_ARG01, "DLRU",
|
||||||
CMD_CHFLAG('D')|CMD_CHFLAG('L')|CMD_CHFLAG('R')|CMD_CHFLAG('U'),
|
|
||||||
cmd_resize_pane_init,
|
cmd_resize_pane_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_resize_pane_exec,
|
cmd_resize_pane_exec,
|
||||||
@@ -50,28 +49,28 @@ cmd_resize_pane_init(struct cmd *self, int key)
|
|||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
if (key == (KEYC_UP | KEYC_CTRL))
|
if (key == (KEYC_UP | KEYC_CTRL))
|
||||||
data->chflags |= CMD_CHFLAG('U');
|
cmd_set_flag(&data->chflags, 'U');
|
||||||
if (key == (KEYC_DOWN | KEYC_CTRL))
|
if (key == (KEYC_DOWN | KEYC_CTRL))
|
||||||
data->chflags |= CMD_CHFLAG('D');
|
cmd_set_flag(&data->chflags, 'D');
|
||||||
if (key == (KEYC_LEFT | KEYC_CTRL))
|
if (key == (KEYC_LEFT | KEYC_CTRL))
|
||||||
data->chflags |= CMD_CHFLAG('L');
|
cmd_set_flag(&data->chflags, 'L');
|
||||||
if (key == (KEYC_RIGHT | KEYC_CTRL))
|
if (key == (KEYC_RIGHT | KEYC_CTRL))
|
||||||
data->chflags |= CMD_CHFLAG('R');
|
cmd_set_flag(&data->chflags, 'R');
|
||||||
|
|
||||||
if (key == (KEYC_UP | KEYC_ESCAPE)) {
|
if (key == (KEYC_UP | KEYC_ESCAPE)) {
|
||||||
data->chflags |= CMD_CHFLAG('U');
|
cmd_set_flag(&data->chflags, 'U');
|
||||||
data->arg = xstrdup("5");
|
data->arg = xstrdup("5");
|
||||||
}
|
}
|
||||||
if (key == (KEYC_DOWN | KEYC_ESCAPE)) {
|
if (key == (KEYC_DOWN | KEYC_ESCAPE)) {
|
||||||
data->chflags |= CMD_CHFLAG('D');
|
cmd_set_flag(&data->chflags, 'D');
|
||||||
data->arg = xstrdup("5");
|
data->arg = xstrdup("5");
|
||||||
}
|
}
|
||||||
if (key == (KEYC_LEFT | KEYC_ESCAPE)) {
|
if (key == (KEYC_LEFT | KEYC_ESCAPE)) {
|
||||||
data->chflags |= CMD_CHFLAG('L');
|
cmd_set_flag(&data->chflags, 'L');
|
||||||
data->arg = xstrdup("5");
|
data->arg = xstrdup("5");
|
||||||
}
|
}
|
||||||
if (key == (KEYC_RIGHT | KEYC_ESCAPE)) {
|
if (key == (KEYC_RIGHT | KEYC_ESCAPE)) {
|
||||||
data->chflags |= CMD_CHFLAG('R');
|
cmd_set_flag(&data->chflags, 'R');
|
||||||
data->arg = xstrdup("5");
|
data->arg = xstrdup("5");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,15 +97,14 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->chflags & (CMD_CHFLAG('L')|CMD_CHFLAG('R'))) {
|
if (cmd_check_flag(data->chflags, 'L'))
|
||||||
if (data->chflags & CMD_CHFLAG('L'))
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
|
||||||
adjust = -adjust;
|
else if (cmd_check_flag(data->chflags, 'R'))
|
||||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust);
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust);
|
||||||
} else {
|
else if (cmd_check_flag(data->chflags, 'U'))
|
||||||
if (data->chflags & CMD_CHFLAG('U'))
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust);
|
||||||
adjust = -adjust;
|
else if (cmd_check_flag(data->chflags, 'D'))
|
||||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
|
||||||
}
|
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-respawn-window.c,v 1.22 2009-09-16 12:36:27 nicm Exp $ */
|
/* $Id: cmd-respawn-window.c,v 1.25 2009-12-04 22:14:47 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ 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",
|
||||||
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
|
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
|
||||||
CMD_ARG01, CMD_CHFLAG('k'),
|
CMD_ARG01, "k",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_respawn_window_exec,
|
cmd_respawn_window_exec,
|
||||||
@@ -54,7 +54,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (!(data->chflags & CMD_CHFLAG('k'))) {
|
if (!cmd_check_flag(data->chflags, 'k')) {
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
if (wp->fd == -1)
|
if (wp->fd == -1)
|
||||||
continue;
|
continue;
|
||||||
@@ -72,7 +72,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
wp = TAILQ_FIRST(&w->panes);
|
wp = TAILQ_FIRST(&w->panes);
|
||||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
layout_free(w);
|
layout_free(w);
|
||||||
window_destroy_panes(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(
|
if (window_pane_spawn(
|
||||||
@@ -80,6 +80,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->error(ctx, "respawn window failed: %s", cause);
|
ctx->error(ctx, "respawn window failed: %s", cause);
|
||||||
xfree(cause);
|
xfree(cause);
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
|
server_destroy_pane(wp);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
layout_init(w);
|
layout_init(w);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-rotate-window.c,v 1.9 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-rotate-window.c,v 1.10 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,7 +30,7 @@ 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",
|
||||||
"[-DU] " CMD_TARGET_WINDOW_USAGE,
|
"[-DU] " CMD_TARGET_WINDOW_USAGE,
|
||||||
0, CMD_CHFLAG('D')|CMD_CHFLAG('U'),
|
0, "DU",
|
||||||
cmd_rotate_window_init,
|
cmd_rotate_window_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_rotate_window_exec,
|
cmd_rotate_window_exec,
|
||||||
@@ -47,7 +47,7 @@ cmd_rotate_window_init(struct cmd *self, int key)
|
|||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
if (key == ('o' | KEYC_ESCAPE))
|
if (key == ('o' | KEYC_ESCAPE))
|
||||||
data->chflags |= CMD_CHFLAG('D');
|
cmd_set_flag(&data->chflags, 'D');
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -64,7 +64,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('D')) {
|
if (cmd_check_flag(data->chflags, '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);
|
||||||
|
|||||||
144
cmd-run-shell.c
Normal file
144
cmd-run-shell.c
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
/* $Id: cmd-run-shell.c,v 1.9 2010-08-09 21:44:25 tcunha Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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",
|
||||||
|
"command",
|
||||||
|
CMD_ARG1, "",
|
||||||
|
cmd_target_init,
|
||||||
|
cmd_target_parse,
|
||||||
|
cmd_run_shell_exec,
|
||||||
|
cmd_target_free,
|
||||||
|
cmd_target_print
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_run_shell_data {
|
||||||
|
char *cmd;
|
||||||
|
struct cmd_ctx ctx;
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct cmd_target_data *data = self->data;
|
||||||
|
struct cmd_run_shell_data *cdata;
|
||||||
|
struct job *job;
|
||||||
|
|
||||||
|
cdata = xmalloc(sizeof *cdata);
|
||||||
|
cdata->cmd = xstrdup(data->arg);
|
||||||
|
memcpy(&cdata->ctx, ctx, sizeof cdata->ctx);
|
||||||
|
|
||||||
|
if (ctx->cmdclient != NULL)
|
||||||
|
ctx->cmdclient->references++;
|
||||||
|
if (ctx->curclient != NULL)
|
||||||
|
ctx->curclient->references++;
|
||||||
|
|
||||||
|
job = job_add(NULL, 0, NULL,
|
||||||
|
data->arg, cmd_run_shell_callback, cmd_run_shell_free, cdata);
|
||||||
|
job_run(job);
|
||||||
|
|
||||||
|
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.8 2009-09-07 23:48:54 tcunha Exp $ */
|
/* $Id: cmd-save-buffer.c,v 1.12 2010-08-09 21:44:25 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -33,7 +33,7 @@ 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",
|
"[-a] " CMD_BUFFER_SESSION_USAGE " path",
|
||||||
CMD_ARG1, CMD_CHFLAG('a'),
|
CMD_ARG1, "a",
|
||||||
cmd_buffer_init,
|
cmd_buffer_init,
|
||||||
cmd_buffer_parse,
|
cmd_buffer_parse,
|
||||||
cmd_save_buffer_exec,
|
cmd_save_buffer_exec,
|
||||||
@@ -47,7 +47,7 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct cmd_buffer_data *data = self->data;
|
struct cmd_buffer_data *data = self->data;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
mode_t mask;
|
mode_t mask;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
||||||
@@ -65,24 +65,31 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mask = umask(S_IRWXG | S_IRWXO);
|
if (strcmp(data->arg, "-") == 0) {
|
||||||
if (data->chflags & CMD_CHFLAG('a'))
|
if (ctx->cmdclient == NULL) {
|
||||||
f = fopen(data->arg, "ab");
|
ctx->error(ctx, "%s: can't write to stdout", data->arg);
|
||||||
else
|
return (-1);
|
||||||
f = fopen(data->arg, "wb");
|
}
|
||||||
if (f == NULL) {
|
bufferevent_write(
|
||||||
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
|
ctx->cmdclient->stdout_event, pb->data, pb->size);
|
||||||
return (-1);
|
} else {
|
||||||
|
mask = umask(S_IRWXG | S_IRWXO);
|
||||||
|
if (cmd_check_flag(data->chflags, 'a'))
|
||||||
|
f = fopen(data->arg, "ab");
|
||||||
|
else
|
||||||
|
f = fopen(data->arg, "wb");
|
||||||
|
umask(mask);
|
||||||
|
if (f == NULL) {
|
||||||
|
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
|
||||||
|
ctx->error(ctx, "%s: fwrite error", data->arg);
|
||||||
|
fclose(f);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
|
|
||||||
ctx->error(ctx, "%s: fwrite error", data->arg);
|
|
||||||
fclose(f);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
umask(mask);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-select-layout.c,v 1.8 2009-07-28 23:04:29 tcunha Exp $ */
|
/* $Id: cmd-select-layout.c,v 1.12 2010-07-02 02:54:52 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -30,7 +30,7 @@ int cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_select_layout_entry = {
|
const struct cmd_entry cmd_select_layout_entry = {
|
||||||
"select-layout", "selectl",
|
"select-layout", "selectl",
|
||||||
CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
||||||
CMD_ARG01, 0,
|
CMD_ARG01, "",
|
||||||
cmd_select_layout_init,
|
cmd_select_layout_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_select_layout_exec,
|
cmd_select_layout_exec,
|
||||||
@@ -52,13 +52,16 @@ cmd_select_layout_init(struct cmd *self, int key)
|
|||||||
break;
|
break;
|
||||||
case ('2' | KEYC_ESCAPE):
|
case ('2' | KEYC_ESCAPE):
|
||||||
data->arg = xstrdup("even-vertical");
|
data->arg = xstrdup("even-vertical");
|
||||||
break;
|
break;
|
||||||
case ('3' | KEYC_ESCAPE):
|
case ('3' | KEYC_ESCAPE):
|
||||||
data->arg = xstrdup("main-horizontal");
|
data->arg = xstrdup("main-horizontal");
|
||||||
break;
|
break;
|
||||||
case ('4' | KEYC_ESCAPE):
|
case ('4' | KEYC_ESCAPE):
|
||||||
data->arg = xstrdup("main-vertical");
|
data->arg = xstrdup("main-vertical");
|
||||||
break;
|
break;
|
||||||
|
case ('5' | KEYC_ESCAPE):
|
||||||
|
data->arg = xstrdup("tiled");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,13 +79,16 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
layout = wl->window->lastlayout;
|
layout = wl->window->lastlayout;
|
||||||
if (layout == -1)
|
if (layout == -1)
|
||||||
return (0);
|
return (0);
|
||||||
} else if ((layout = layout_set_lookup(data->arg)) == -1) {
|
} else if ((layout = layout_set_lookup(data->arg)) != -1) {
|
||||||
ctx->error(ctx, "unknown layout or ambiguous: %s", data->arg);
|
layout = layout_set_select(wl->window, layout);
|
||||||
return (-1);
|
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
||||||
|
} else {
|
||||||
|
if (layout_parse(wl->window, data->arg) == -1) {
|
||||||
|
ctx->error(ctx, "can't set layout: %s", data->arg);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
ctx->info(ctx, "arranging in: %s", data->arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout = layout_set_select(wl->window, layout);
|
|
||||||
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-select-pane.c,v 1.10 2009-07-30 20:45:20 tcunha Exp $ */
|
/* $Id: cmd-select-pane.c,v 1.13 2010-03-15 22:03:38 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,19 +24,40 @@
|
|||||||
* Select pane.
|
* Select pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void cmd_select_pane_init(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_TARGET_PANE_USAGE,
|
"[-DLRU] " CMD_TARGET_PANE_USAGE,
|
||||||
0, 0,
|
0, "DLRU",
|
||||||
cmd_target_init,
|
cmd_select_pane_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_select_pane_exec,
|
cmd_select_pane_exec,
|
||||||
cmd_target_free,
|
cmd_target_free,
|
||||||
cmd_target_print
|
cmd_target_print
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_select_pane_init(struct cmd *self, int key)
|
||||||
|
{
|
||||||
|
struct cmd_target_data *data;
|
||||||
|
|
||||||
|
cmd_target_init(self, key);
|
||||||
|
data = self->data;
|
||||||
|
|
||||||
|
if (key == KEYC_UP)
|
||||||
|
cmd_set_flag(&data->chflags, 'U');
|
||||||
|
if (key == KEYC_DOWN)
|
||||||
|
cmd_set_flag(&data->chflags, 'D');
|
||||||
|
if (key == KEYC_LEFT)
|
||||||
|
cmd_set_flag(&data->chflags, 'L');
|
||||||
|
if (key == KEYC_RIGHT)
|
||||||
|
cmd_set_flag(&data->chflags, 'R');
|
||||||
|
if (key == 'o')
|
||||||
|
data->target = xstrdup(":.+");
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
@@ -51,8 +72,23 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->error(ctx, "pane not visible: %s", data->target);
|
ctx->error(ctx, "pane not visible: %s", data->target);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmd_check_flag(data->chflags, 'L'))
|
||||||
|
wp = window_pane_find_left(wp);
|
||||||
|
else if (cmd_check_flag(data->chflags, 'R'))
|
||||||
|
wp = window_pane_find_right(wp);
|
||||||
|
else if (cmd_check_flag(data->chflags, 'U'))
|
||||||
|
wp = window_pane_find_up(wp);
|
||||||
|
else if (cmd_check_flag(data->chflags, '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);
|
||||||
server_status_window(wl->window);
|
server_status_window(wl->window);
|
||||||
|
server_redraw_window_borders(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
/* $Id: cmd-select-prompt.c,v 1.12 2009-08-16 19:29:24 tcunha 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, 0,
|
|
||||||
cmd_target_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_select_prompt_exec,
|
|
||||||
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, NULL, 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 || *s == '\0')
|
|
||||||
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, "%s", 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, "%s", 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.23 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-select-window.c,v 1.24 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -32,7 +32,7 @@ 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,
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_select_window_init,
|
cmd_select_window_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_select_window_exec,
|
cmd_select_window_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-send-keys.c,v 1.21 2009-08-20 11:37:46 tcunha Exp $ */
|
/* $Id: cmd-send-keys.c,v 1.25 2010-05-22 21:56:04 micahcowan Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -33,15 +33,14 @@ size_t cmd_send_keys_print(struct cmd *, char *, size_t);
|
|||||||
|
|
||||||
struct cmd_send_keys_data {
|
struct cmd_send_keys_data {
|
||||||
char *target;
|
char *target;
|
||||||
int idx;
|
u_int nkeys;
|
||||||
u_int nkeys;
|
|
||||||
int *keys;
|
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-pane] key ...",
|
"[-t target-pane] key ...",
|
||||||
0, 0,
|
0, "",
|
||||||
NULL,
|
NULL,
|
||||||
cmd_send_keys_parse,
|
cmd_send_keys_parse,
|
||||||
cmd_send_keys_exec,
|
cmd_send_keys_exec,
|
||||||
@@ -58,7 +57,6 @@ cmd_send_keys_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
self->data = data = xmalloc(sizeof *data);
|
||||||
data->target = NULL;
|
data->target = NULL;
|
||||||
data->idx = -1;
|
|
||||||
data->nkeys = 0;
|
data->nkeys = 0;
|
||||||
data->keys = NULL;
|
data->keys = NULL;
|
||||||
|
|
||||||
@@ -107,16 +105,17 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
{
|
{
|
||||||
struct cmd_send_keys_data *data = self->data;
|
struct cmd_send_keys_data *data = self->data;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
struct session *s;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, data->target, &s, &wp) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
for (i = 0; i < data->nkeys; i++)
|
for (i = 0; i < data->nkeys; i++)
|
||||||
window_pane_key(wp, ctx->curclient, data->keys[i]);
|
window_pane_key(wp, s, data->keys[i]);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -143,8 +142,6 @@ cmd_send_keys_print(struct cmd *self, char *buf, size_t len)
|
|||||||
return (off);
|
return (off);
|
||||||
if (off < len && data->target != NULL)
|
if (off < len && data->target != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
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++) {
|
for (i = 0; i < data->nkeys; i++) {
|
||||||
if (off >= len)
|
if (off >= len)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-send-prefix.c,v 1.26 2009-08-20 11:37:46 tcunha Exp $ */
|
/* $Id: cmd-send-prefix.c,v 1.29 2010-05-22 21:56:04 micahcowan Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ 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_PANE_USAGE,
|
CMD_TARGET_PANE_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_send_prefix_exec,
|
cmd_send_prefix_exec,
|
||||||
@@ -43,13 +43,13 @@ cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
int key;
|
struct keylist *keylist;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, data->target, &s, &wp) == NULL)
|
if (cmd_find_pane(ctx, data->target, &s, &wp) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
key = options_get_number(&s->options, "prefix");
|
keylist = options_get_data(&s->options, "prefix");
|
||||||
window_pane_key(wp, ctx->curclient, key);
|
window_pane_key(wp, s, ARRAY_FIRST(keylist));
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-server-info.c,v 1.28 2009-09-07 23:59:19 tcunha Exp $ */
|
/* $Id: cmd-server-info.c,v 1.38 2010-12-22 15:36:44 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -35,7 +35,7 @@ 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, "",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_server_info_exec,
|
cmd_server_info_exec,
|
||||||
@@ -43,6 +43,7 @@ const struct cmd_entry cmd_server_info_entry = {
|
|||||||
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)
|
||||||
{
|
{
|
||||||
@@ -55,6 +56,7 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct tty_code *code;
|
struct tty_code *code;
|
||||||
struct tty_term_code_entry *ent;
|
struct tty_term_code_entry *ent;
|
||||||
struct utsname un;
|
struct utsname un;
|
||||||
|
struct job *job;
|
||||||
struct grid *gd;
|
struct grid *gd;
|
||||||
struct grid_line *gl;
|
struct grid_line *gl;
|
||||||
u_int i, j, k;
|
u_int i, j, k;
|
||||||
@@ -68,11 +70,10 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
*strchr(tim, '\n') = '\0';
|
*strchr(tim, '\n') = '\0';
|
||||||
ctx->print(ctx,
|
ctx->print(ctx,
|
||||||
"tmux " BUILD ", pid %ld, started %s", (long) getpid(), tim);
|
"tmux " BUILD ", pid %ld, started %s", (long) getpid(), tim);
|
||||||
ctx->print(ctx, "socket path %s, debug level %d%s%s",
|
ctx->print(
|
||||||
socket_path, debug_level, be_quiet ? ", quiet" : "",
|
ctx, "socket path %s, debug level %d", socket_path, debug_level);
|
||||||
login_shell ? ", login shell" : "");
|
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)
|
||||||
@@ -80,8 +81,6 @@ 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",
|
|
||||||
ARRAY_LENGTH(&clients), ARRAY_LENGTH(&sessions));
|
|
||||||
ctx->print(ctx, "%s", "");
|
ctx->print(ctx, "%s", "");
|
||||||
|
|
||||||
ctx->print(ctx, "Clients:");
|
ctx->print(ctx, "Clients:");
|
||||||
@@ -93,26 +92,21 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->print(ctx, "%2d: %s (%d, %d): %s [%ux%u %s] "
|
ctx->print(ctx, "%2d: %s (%d, %d): %s [%ux%u %s] "
|
||||||
"[flags=0x%x/0x%x, references=%u]", i, c->tty.path,
|
"[flags=0x%x/0x%x, references=%u]", i, c->tty.path,
|
||||||
c->ibuf.fd, c->tty.fd, c->session->name,
|
c->ibuf.fd, c->tty.fd, c->session->name,
|
||||||
c->tty.sx, c->tty.sy, c->tty.termname, c->flags,
|
c->tty.sx, c->tty.sy, c->tty.termname, c->flags,
|
||||||
c->tty.flags, c->references);
|
c->tty.flags, c->references);
|
||||||
}
|
}
|
||||||
ctx->print(ctx, "%s", "");
|
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: %s: %u windows (created %s) [%ux%u] "
|
ctx->print(ctx, "%2u: %s: %u windows (created %s) [%ux%u] "
|
||||||
"[flags=0x%x, references=%u]", i, s->name,
|
"[flags=0x%x]", s->idx, s->name,
|
||||||
winlink_count(&s->windows), tim, s->sx, s->sy, s->flags,
|
winlink_count(&s->windows), tim, s->sx, s->sy, s->flags);
|
||||||
s->references);
|
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
ctx->print(ctx, "%4u: %s [%ux%u] [flags=0x%x, "
|
ctx->print(ctx, "%4u: %s [%ux%u] [flags=0x%x, "
|
||||||
@@ -147,7 +141,7 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
ctx->print(ctx, "%s", "");
|
ctx->print(ctx, "%s", "");
|
||||||
|
|
||||||
ctx->print(ctx, "Terminals:");
|
ctx->print(ctx, "Terminals:");
|
||||||
SLIST_FOREACH(term, &tty_terms, entry) {
|
SLIST_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);
|
||||||
@@ -179,5 +173,11 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
ctx->print(ctx, "%s", "");
|
ctx->print(ctx, "%s", "");
|
||||||
|
|
||||||
|
ctx->print(ctx, "Jobs:");
|
||||||
|
SLIST_FOREACH(job, &all_jobs, lentry) {
|
||||||
|
ctx->print(ctx, "%s [fd=%d, pid=%d, status=%d, flags=0x%x]",
|
||||||
|
job->cmd, job->fd, job->pid, job->status, job->flags);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-buffer.c,v 1.10 2009-09-07 23:48:54 tcunha Exp $ */
|
/* $Id: cmd-set-buffer.c,v 1.12 2009-11-28 14:54:12 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ 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",
|
CMD_BUFFER_SESSION_USAGE " data",
|
||||||
CMD_ARG1, 0,
|
CMD_ARG1, "",
|
||||||
cmd_buffer_init,
|
cmd_buffer_init,
|
||||||
cmd_buffer_parse,
|
cmd_buffer_parse,
|
||||||
cmd_set_buffer_exec,
|
cmd_set_buffer_exec,
|
||||||
@@ -45,7 +45,7 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct cmd_buffer_data *data = self->data;
|
struct cmd_buffer_data *data = self->data;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
u_int limit;
|
u_int limit;
|
||||||
u_char *pdata;
|
char *pdata;
|
||||||
size_t psize;
|
size_t psize;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-environment.c,v 1.2 2009-08-11 14:42:59 nicm Exp $ */
|
/* $Id: cmd-set-environment.c,v 1.3 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -32,7 +32,7 @@ int cmd_set_environment_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_set_environment_entry = {
|
const struct cmd_entry cmd_set_environment_entry = {
|
||||||
"set-environment", "setenv",
|
"set-environment", "setenv",
|
||||||
"[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
"[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
||||||
CMD_ARG12, CMD_CHFLAG('g')|CMD_CHFLAG('r')|CMD_CHFLAG('u'),
|
CMD_ARG12, "gru",
|
||||||
NULL,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_set_environment_exec,
|
cmd_set_environment_exec,
|
||||||
@@ -56,7 +56,7 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('g'))
|
if (cmd_check_flag(data->chflags, 'g'))
|
||||||
env = &global_environ;
|
env = &global_environ;
|
||||||
else {
|
else {
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
||||||
@@ -64,13 +64,13 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
env = &s->environ;
|
env = &s->environ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('u')) {
|
if (cmd_check_flag(data->chflags, 'u')) {
|
||||||
if (data->arg2 != NULL) {
|
if (data->arg2 != NULL) {
|
||||||
ctx->error(ctx, "can't specify a value with -u");
|
ctx->error(ctx, "can't specify a value with -u");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
environ_unset(env, data->arg);
|
environ_unset(env, data->arg);
|
||||||
} else if (data->chflags & CMD_CHFLAG('r')) {
|
} else if (cmd_check_flag(data->chflags, 'r')) {
|
||||||
if (data->arg2 != NULL) {
|
if (data->arg2 != NULL) {
|
||||||
ctx->error(ctx, "can't specify a value with -r");
|
ctx->error(ctx, "can't specify a value with -r");
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|||||||
428
cmd-set-option.c
428
cmd-set-option.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-option.c,v 1.79 2009-09-19 18:53:01 tcunha Exp $ */
|
/* $Id: cmd-set-option.c,v 1.102 2010-12-22 15:23:59 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,10 +29,27 @@
|
|||||||
|
|
||||||
int cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const char *cmd_set_option_print(
|
||||||
|
const struct set_option_entry *, struct options_entry *);
|
||||||
|
void cmd_set_option_string(struct cmd_ctx *,
|
||||||
|
struct options *, const struct set_option_entry *, char *, int);
|
||||||
|
void cmd_set_option_number(struct cmd_ctx *,
|
||||||
|
struct options *, const struct set_option_entry *, char *);
|
||||||
|
void cmd_set_option_keys(struct cmd_ctx *,
|
||||||
|
struct options *, const struct set_option_entry *, char *);
|
||||||
|
void cmd_set_option_colour(struct cmd_ctx *,
|
||||||
|
struct options *, const struct set_option_entry *, char *);
|
||||||
|
void cmd_set_option_attributes(struct cmd_ctx *,
|
||||||
|
struct options *, const struct set_option_entry *, char *);
|
||||||
|
void cmd_set_option_flag(struct cmd_ctx *,
|
||||||
|
struct options *, const struct set_option_entry *, char *);
|
||||||
|
void cmd_set_option_choice(struct cmd_ctx *,
|
||||||
|
struct options *, const struct set_option_entry *, char *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_option_entry = {
|
const struct cmd_entry cmd_set_option_entry = {
|
||||||
"set-option", "set",
|
"set-option", "set",
|
||||||
"[-agu] " CMD_TARGET_SESSION_USAGE " option [value]",
|
"[-agsuw] [-t target-session|target-window] option [value]",
|
||||||
CMD_ARG12, CMD_CHFLAG('a')|CMD_CHFLAG('g')|CMD_CHFLAG('u'),
|
CMD_ARG12, "agsuw",
|
||||||
NULL,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_set_option_exec,
|
cmd_set_option_exec,
|
||||||
@@ -40,6 +57,12 @@ const struct cmd_entry cmd_set_option_entry = {
|
|||||||
cmd_target_print
|
cmd_target_print
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *set_option_mode_keys_list[] = {
|
||||||
|
"emacs", "vi", NULL
|
||||||
|
};
|
||||||
|
const char *set_option_clock_mode_style_list[] = {
|
||||||
|
"12", "24", NULL
|
||||||
|
};
|
||||||
const char *set_option_status_keys_list[] = {
|
const char *set_option_status_keys_list[] = {
|
||||||
"emacs", "vi", NULL
|
"emacs", "vi", NULL
|
||||||
};
|
};
|
||||||
@@ -49,7 +72,15 @@ const char *set_option_status_justify_list[] = {
|
|||||||
const char *set_option_bell_action_list[] = {
|
const char *set_option_bell_action_list[] = {
|
||||||
"none", "any", "current", NULL
|
"none", "any", "current", NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct set_option_entry set_option_table[] = {
|
const struct set_option_entry set_option_table[] = {
|
||||||
|
{ "escape-time", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
||||||
|
{ "exit-unattached", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ "quiet", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ NULL, 0, 0, 0, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct set_option_entry set_session_option_table[] = {
|
||||||
{ "base-index", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
{ "base-index", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
||||||
{ "bell-action", SET_OPTION_CHOICE, 0, 0, set_option_bell_action_list },
|
{ "bell-action", SET_OPTION_CHOICE, 0, 0, set_option_bell_action_list },
|
||||||
{ "buffer-limit", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
{ "buffer-limit", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
||||||
@@ -57,15 +88,26 @@ const struct set_option_entry set_option_table[] = {
|
|||||||
{ "default-path", SET_OPTION_STRING, 0, 0, NULL },
|
{ "default-path", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
{ "default-shell", SET_OPTION_STRING, 0, 0, NULL },
|
{ "default-shell", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
{ "default-terminal", SET_OPTION_STRING, 0, 0, NULL },
|
{ "default-terminal", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
|
{ "destroy-unattached", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ "detach-on-destroy", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "display-panes-colour", SET_OPTION_COLOUR, 0, 0, NULL },
|
{ "display-panes-colour", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "display-panes-active-colour", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
{ "display-panes-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
{ "display-panes-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
||||||
{ "display-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
{ "display-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
||||||
{ "history-limit", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
{ "history-limit", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
||||||
{ "lock-after-time", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
{ "lock-after-time", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
||||||
|
{ "lock-command", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
|
{ "lock-server", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "message-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
{ "message-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
||||||
{ "message-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
{ "message-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
{ "message-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
{ "message-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
{ "prefix", SET_OPTION_KEY, 0, 0, NULL },
|
{ "message-limit", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
||||||
|
{ "mouse-select-pane", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ "pane-active-border-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "pane-active-border-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "pane-border-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "pane-border-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "prefix", SET_OPTION_KEYS, 0, 0, NULL },
|
||||||
{ "repeat-time", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
{ "repeat-time", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
||||||
{ "set-remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "set-remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "set-titles", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "set-titles", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
@@ -75,7 +117,7 @@ const struct set_option_entry set_option_table[] = {
|
|||||||
{ "status-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
{ "status-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
{ "status-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
{ "status-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
{ "status-interval", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
{ "status-interval", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
||||||
{ "status-justify",
|
{ "status-justify",
|
||||||
SET_OPTION_CHOICE, 0, 0, set_option_status_justify_list },
|
SET_OPTION_CHOICE, 0, 0, set_option_status_justify_list },
|
||||||
{ "status-keys", SET_OPTION_CHOICE, 0, 0, set_option_status_keys_list },
|
{ "status-keys", SET_OPTION_CHOICE, 0, 0, set_option_status_keys_list },
|
||||||
{ "status-left", SET_OPTION_STRING, 0, 0, NULL },
|
{ "status-left", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
@@ -88,12 +130,53 @@ const struct set_option_entry set_option_table[] = {
|
|||||||
{ "status-right-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
{ "status-right-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
{ "status-right-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
{ "status-right-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
{ "status-right-length", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
{ "status-right-length", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
||||||
{ "status-utf8", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "status-utf8", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "terminal-overrides", SET_OPTION_STRING, 0, 0, NULL },
|
{ "terminal-overrides", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
{ "update-environment", SET_OPTION_STRING, 0, 0, NULL },
|
{ "update-environment", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
{ "visual-activity", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "visual-activity", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "visual-bell", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "visual-bell", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "visual-content", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "visual-content", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ "visual-silence", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ NULL, 0, 0, 0, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct set_option_entry set_window_option_table[] = {
|
||||||
|
{ "aggressive-resize", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ "alternate-screen", 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 },
|
||||||
|
{ "main-pane-height", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
||||||
|
{ "main-pane-width", SET_OPTION_NUMBER, 1, 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 },
|
||||||
|
{ "mode-mouse", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ "monitor-activity", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ "monitor-content", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
|
{ "monitor-silence",SET_OPTION_NUMBER, 0, INT_MAX, NULL},
|
||||||
|
{ "other-pane-height", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
||||||
|
{ "other-pane-width", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
||||||
|
{ "remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ "synchronize-panes", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ "utf8", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ "window-status-alert-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
||||||
|
{ "window-status-alert-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "window-status-alert-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "window-status-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
||||||
|
{ "window-status-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "window-status-current-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
||||||
|
{ "window-status-current-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "window-status-current-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "window-status-current-format", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
|
{ "window-status-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "window-status-format", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
|
{ "word-separators", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
|
{ "xterm-keys", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ NULL, 0, 0, 0, NULL }
|
{ NULL, 0, 0, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -101,18 +184,40 @@ 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_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
|
const struct set_option_entry *table;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
struct winlink *wl;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct options *oo;
|
struct options *oo;
|
||||||
const struct set_option_entry *entry, *opt;
|
const struct set_option_entry *entry, *opt;
|
||||||
|
struct jobs *jobs;
|
||||||
|
struct job *job, *nextjob;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
int try_again;
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('g'))
|
if (cmd_check_flag(data->chflags, 's')) {
|
||||||
oo = &global_s_options;
|
oo = &global_options;
|
||||||
else {
|
table = set_option_table;
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
} else if (cmd_check_flag(data->chflags, 'w')) {
|
||||||
return (-1);
|
table = set_window_option_table;
|
||||||
oo = &s->options;
|
if (cmd_check_flag(data->chflags, 'g'))
|
||||||
|
oo = &global_w_options;
|
||||||
|
else {
|
||||||
|
wl = cmd_find_window(ctx, data->target, NULL);
|
||||||
|
if (wl == NULL)
|
||||||
|
return (-1);
|
||||||
|
oo = &wl->window->options;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
table = set_session_option_table;
|
||||||
|
if (cmd_check_flag(data->chflags, 'g'))
|
||||||
|
oo = &global_s_options;
|
||||||
|
else {
|
||||||
|
s = cmd_find_session(ctx, data->target);
|
||||||
|
if (s == NULL)
|
||||||
|
return (-1);
|
||||||
|
oo = &s->options;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*data->arg == '\0') {
|
if (*data->arg == '\0') {
|
||||||
@@ -121,7 +226,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry = NULL;
|
entry = NULL;
|
||||||
for (opt = set_option_table; opt->name != NULL; opt++) {
|
for (opt = table; opt->name != NULL; opt++) {
|
||||||
if (strncmp(opt->name, data->arg, strlen(data->arg)) != 0)
|
if (strncmp(opt->name, data->arg, strlen(data->arg)) != 0)
|
||||||
continue;
|
continue;
|
||||||
if (entry != NULL) {
|
if (entry != NULL) {
|
||||||
@@ -139,8 +244,8 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('u')) {
|
if (cmd_check_flag(data->chflags, 'u')) {
|
||||||
if (data->chflags & CMD_CHFLAG('g')) {
|
if (cmd_check_flag(data->chflags, 'g')) {
|
||||||
ctx->error(ctx,
|
ctx->error(ctx,
|
||||||
"can't unset global option: %s", entry->name);
|
"can't unset global option: %s", entry->name);
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -156,26 +261,26 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
} else {
|
} else {
|
||||||
switch (entry->type) {
|
switch (entry->type) {
|
||||||
case SET_OPTION_STRING:
|
case SET_OPTION_STRING:
|
||||||
set_option_string(ctx, oo, entry,
|
cmd_set_option_string(ctx, oo, entry,
|
||||||
data->arg2, data->chflags & CMD_CHFLAG('a'));
|
data->arg2, cmd_check_flag(data->chflags, 'a'));
|
||||||
break;
|
break;
|
||||||
case SET_OPTION_NUMBER:
|
case SET_OPTION_NUMBER:
|
||||||
set_option_number(ctx, oo, entry, data->arg2);
|
cmd_set_option_number(ctx, oo, entry, data->arg2);
|
||||||
break;
|
break;
|
||||||
case SET_OPTION_KEY:
|
case SET_OPTION_KEYS:
|
||||||
set_option_key(ctx, oo, entry, data->arg2);
|
cmd_set_option_keys(ctx, oo, entry, data->arg2);
|
||||||
break;
|
break;
|
||||||
case SET_OPTION_COLOUR:
|
case SET_OPTION_COLOUR:
|
||||||
set_option_colour(ctx, oo, entry, data->arg2);
|
cmd_set_option_colour(ctx, oo, entry, data->arg2);
|
||||||
break;
|
break;
|
||||||
case SET_OPTION_ATTRIBUTES:
|
case SET_OPTION_ATTRIBUTES:
|
||||||
set_option_attributes(ctx, oo, entry, data->arg2);
|
cmd_set_option_attributes(ctx, oo, entry, data->arg2);
|
||||||
break;
|
break;
|
||||||
case SET_OPTION_FLAG:
|
case SET_OPTION_FLAG:
|
||||||
set_option_flag(ctx, oo, entry, data->arg2);
|
cmd_set_option_flag(ctx, oo, entry, data->arg2);
|
||||||
break;
|
break;
|
||||||
case SET_OPTION_CHOICE:
|
case SET_OPTION_CHOICE:
|
||||||
set_option_choice(ctx, oo, entry, data->arg2);
|
cmd_set_option_choice(ctx, oo, entry, data->arg2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,5 +292,278 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Special-case: kill all persistent jobs if status-left, status-right
|
||||||
|
* or set-titles-string have changed. Persistent jobs are only used by
|
||||||
|
* the status line at the moment so this works XXX.
|
||||||
|
*/
|
||||||
|
if (strcmp(entry->name, "status-left") == 0 ||
|
||||||
|
strcmp(entry->name, "status-right") == 0 ||
|
||||||
|
strcmp(entry->name, "status") == 0 ||
|
||||||
|
strcmp(entry->name, "set-titles-string") == 0 ||
|
||||||
|
strcmp(entry->name, "window-status-format") == 0) {
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c == NULL || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
jobs = &c->status_jobs;
|
||||||
|
do {
|
||||||
|
try_again = 0;
|
||||||
|
job = RB_ROOT(jobs);
|
||||||
|
while (job != NULL) {
|
||||||
|
nextjob = RB_NEXT(jobs, jobs, job);
|
||||||
|
if (job->flags & JOB_PERSIST) {
|
||||||
|
job_remove(jobs, job);
|
||||||
|
try_again = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
job = nextjob;
|
||||||
|
}
|
||||||
|
} while (try_again);
|
||||||
|
server_redraw_client(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cmd_set_option_print(
|
||||||
|
const struct set_option_entry *entry, struct options_entry *o)
|
||||||
|
{
|
||||||
|
static char out[BUFSIZ];
|
||||||
|
const char *s;
|
||||||
|
struct keylist *keylist;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
*out = '\0';
|
||||||
|
switch (entry->type) {
|
||||||
|
case SET_OPTION_STRING:
|
||||||
|
xsnprintf(out, sizeof out, "\"%s\"", o->str);
|
||||||
|
break;
|
||||||
|
case SET_OPTION_NUMBER:
|
||||||
|
xsnprintf(out, sizeof out, "%lld", o->num);
|
||||||
|
break;
|
||||||
|
case SET_OPTION_KEYS:
|
||||||
|
keylist = o->data;
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(keylist); i++) {
|
||||||
|
strlcat(out, key_string_lookup_key(
|
||||||
|
ARRAY_ITEM(keylist, i)), sizeof out);
|
||||||
|
if (i != ARRAY_LENGTH(keylist) - 1)
|
||||||
|
strlcat(out, ",", sizeof out);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SET_OPTION_COLOUR:
|
||||||
|
s = colour_tostring(o->num);
|
||||||
|
xsnprintf(out, sizeof out, "%s", s);
|
||||||
|
break;
|
||||||
|
case SET_OPTION_ATTRIBUTES:
|
||||||
|
s = attributes_tostring(o->num);
|
||||||
|
xsnprintf(out, sizeof out, "%s", s);
|
||||||
|
break;
|
||||||
|
case SET_OPTION_FLAG:
|
||||||
|
if (o->num)
|
||||||
|
strlcpy(out, "on", sizeof out);
|
||||||
|
else
|
||||||
|
strlcpy(out, "off", sizeof out);
|
||||||
|
break;
|
||||||
|
case SET_OPTION_CHOICE:
|
||||||
|
s = entry->choices[o->num];
|
||||||
|
xsnprintf(out, sizeof out, "%s", s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return (out);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_set_option_string(struct cmd_ctx *ctx, struct options *oo,
|
||||||
|
const struct set_option_entry *entry, char *value, int append)
|
||||||
|
{
|
||||||
|
struct options_entry *o;
|
||||||
|
char *oldvalue, *newvalue;
|
||||||
|
|
||||||
|
if (value == NULL) {
|
||||||
|
ctx->error(ctx, "empty value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (append) {
|
||||||
|
oldvalue = options_get_string(oo, entry->name);
|
||||||
|
xasprintf(&newvalue, "%s%s", oldvalue, value);
|
||||||
|
} else
|
||||||
|
newvalue = value;
|
||||||
|
|
||||||
|
o = options_set_string(oo, entry->name, "%s", newvalue);
|
||||||
|
ctx->info(ctx,
|
||||||
|
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
||||||
|
|
||||||
|
if (newvalue != value)
|
||||||
|
xfree(newvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_set_option_number(struct cmd_ctx *ctx, struct options *oo,
|
||||||
|
const struct set_option_entry *entry, char *value)
|
||||||
|
{
|
||||||
|
struct options_entry *o;
|
||||||
|
long long number;
|
||||||
|
const char *errstr;
|
||||||
|
|
||||||
|
if (value == NULL) {
|
||||||
|
ctx->error(ctx, "empty value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
number = strtonum(value, entry->minimum, entry->maximum, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
ctx->error(ctx, "value is %s: %s", errstr, value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
o = options_set_number(oo, entry->name, number);
|
||||||
|
ctx->info(ctx,
|
||||||
|
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_set_option_keys(struct cmd_ctx *ctx, struct options *oo,
|
||||||
|
const struct set_option_entry *entry, char *value)
|
||||||
|
{
|
||||||
|
struct options_entry *o;
|
||||||
|
struct keylist *keylist;
|
||||||
|
char *copyvalue, *ptr, *str;
|
||||||
|
int key;
|
||||||
|
|
||||||
|
if (value == NULL) {
|
||||||
|
ctx->error(ctx, "empty value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
keylist = xmalloc(sizeof *keylist);
|
||||||
|
ARRAY_INIT(keylist);
|
||||||
|
|
||||||
|
ptr = copyvalue = xstrdup(value);
|
||||||
|
while ((str = strsep(&ptr, ",")) != NULL) {
|
||||||
|
if ((key = key_string_lookup_string(str)) == KEYC_NONE) {
|
||||||
|
xfree(keylist);
|
||||||
|
ctx->error(ctx, "unknown key: %s", str);
|
||||||
|
xfree(copyvalue);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ARRAY_ADD(keylist, key);
|
||||||
|
}
|
||||||
|
xfree(copyvalue);
|
||||||
|
|
||||||
|
o = options_set_data(oo, entry->name, keylist, xfree);
|
||||||
|
ctx->info(ctx,
|
||||||
|
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_set_option_colour(struct cmd_ctx *ctx, struct options *oo,
|
||||||
|
const struct set_option_entry *entry, char *value)
|
||||||
|
{
|
||||||
|
struct options_entry *o;
|
||||||
|
int colour;
|
||||||
|
|
||||||
|
if (value == NULL) {
|
||||||
|
ctx->error(ctx, "empty value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((colour = colour_fromstring(value)) == -1) {
|
||||||
|
ctx->error(ctx, "bad colour: %s", value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
o = options_set_number(oo, entry->name, colour);
|
||||||
|
ctx->info(ctx,
|
||||||
|
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_set_option_attributes(struct cmd_ctx *ctx, struct options *oo,
|
||||||
|
const struct set_option_entry *entry, char *value)
|
||||||
|
{
|
||||||
|
struct options_entry *o;
|
||||||
|
int attr;
|
||||||
|
|
||||||
|
if (value == NULL) {
|
||||||
|
ctx->error(ctx, "empty value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((attr = attributes_fromstring(value)) == -1) {
|
||||||
|
ctx->error(ctx, "bad attributes: %s", value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
o = options_set_number(oo, entry->name, attr);
|
||||||
|
ctx->info(ctx,
|
||||||
|
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_set_option_flag(struct cmd_ctx *ctx, struct options *oo,
|
||||||
|
const struct set_option_entry *entry, char *value)
|
||||||
|
{
|
||||||
|
struct options_entry *o;
|
||||||
|
int flag;
|
||||||
|
|
||||||
|
if (value == NULL || *value == '\0')
|
||||||
|
flag = !options_get_number(oo, entry->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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
o = options_set_number(oo, entry->name, flag);
|
||||||
|
ctx->info(ctx,
|
||||||
|
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_set_option_choice(struct cmd_ctx *ctx, struct options *oo,
|
||||||
|
const struct set_option_entry *entry, char *value)
|
||||||
|
{
|
||||||
|
struct options_entry *o;
|
||||||
|
const char **choicep;
|
||||||
|
int n, choice = -1;
|
||||||
|
|
||||||
|
if (value == NULL) {
|
||||||
|
ctx->error(ctx, "empty value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
for (choicep = entry->choices; *choicep != NULL; choicep++) {
|
||||||
|
n++;
|
||||||
|
if (strncmp(*choicep, value, strlen(value)) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (choice != -1) {
|
||||||
|
ctx->error(ctx, "ambiguous option value: %s", value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
choice = n - 1;
|
||||||
|
}
|
||||||
|
if (choice == -1) {
|
||||||
|
ctx->error(ctx, "unknown option value: %s", value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
o = options_set_number(oo, entry->name, choice);
|
||||||
|
ctx->info(ctx,
|
||||||
|
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,145 +0,0 @@
|
|||||||
/* $Id: cmd-set-password.c,v 1.8 2009-07-28 22:12:16 tcunha 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_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, 0,
|
|
||||||
cmd_set_password_init,
|
|
||||||
cmd_set_password_parse,
|
|
||||||
cmd_set_password_exec,
|
|
||||||
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);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
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,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-window-option.c,v 1.38 2009-08-11 14:42:59 nicm Exp $ */
|
/* $Id: cmd-set-window-option.c,v 1.43 2009-12-04 22:11:23 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,13 +18,10 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set a window option.
|
* Set a window option. This is just an alias for set-option -w.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_set_window_option_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_set_window_option_exec(struct cmd *, struct cmd_ctx *);
|
||||||
@@ -32,7 +29,7 @@ int cmd_set_window_option_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_set_window_option_entry = {
|
const struct cmd_entry cmd_set_window_option_entry = {
|
||||||
"set-window-option", "setw",
|
"set-window-option", "setw",
|
||||||
"[-agu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
"[-agu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
||||||
CMD_ARG12, CMD_CHFLAG('a')|CMD_CHFLAG('g')|CMD_CHFLAG('u'),
|
CMD_ARG12, "agu",
|
||||||
NULL,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_set_window_option_exec,
|
cmd_set_window_option_exec,
|
||||||
@@ -40,130 +37,11 @@ const struct cmd_entry cmd_set_window_option_entry = {
|
|||||||
cmd_target_print
|
cmd_target_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[] = {
|
|
||||||
{ "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 },
|
|
||||||
{ "main-pane-height", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
|
||||||
{ "main-pane-width", SET_OPTION_NUMBER, 1, 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 },
|
|
||||||
{ "mode-mouse", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "monitor-activity", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "monitor-content", SET_OPTION_STRING, 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-current-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "window-status-current-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "window-status-current-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "window-status-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "xterm-keys", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ NULL, 0, 0, 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct winlink *wl;
|
|
||||||
struct client *c;
|
|
||||||
struct options *oo;
|
|
||||||
const struct set_option_entry *entry, *opt;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('g'))
|
cmd_set_flag(&data->chflags, 'w');
|
||||||
oo = &global_w_options;
|
return (cmd_set_option_entry.exec(self, ctx));
|
||||||
else {
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
oo = &wl->window->options;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*data->arg == '\0') {
|
|
||||||
ctx->error(ctx, "invalid option");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
entry = NULL;
|
|
||||||
for (opt = set_window_option_table; opt->name != NULL; opt++) {
|
|
||||||
if (strncmp(opt->name, data->arg, strlen(data->arg)) != 0)
|
|
||||||
continue;
|
|
||||||
if (entry != NULL) {
|
|
||||||
ctx->error(ctx, "ambiguous option: %s", data->arg);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
entry = opt;
|
|
||||||
|
|
||||||
/* Bail now if an exact match. */
|
|
||||||
if (strcmp(entry->name, data->arg) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (entry == NULL) {
|
|
||||||
ctx->error(ctx, "unknown option: %s", data->arg);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('u')) {
|
|
||||||
if (data->chflags & CMD_CHFLAG('g')) {
|
|
||||||
ctx->error(ctx,
|
|
||||||
"can't unset global option: %s", entry->name);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (data->arg2 != 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->arg2, data->chflags & CMD_CHFLAG('a'));
|
|
||||||
break;
|
|
||||||
case SET_OPTION_NUMBER:
|
|
||||||
set_option_number(ctx, oo, entry, data->arg2);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_KEY:
|
|
||||||
set_option_key(ctx, oo, entry, data->arg2);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_COLOUR:
|
|
||||||
set_option_colour(ctx, oo, entry, data->arg2);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_ATTRIBUTES:
|
|
||||||
set_option_attributes(ctx, oo, entry, data->arg2);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_FLAG:
|
|
||||||
set_option_flag(ctx, oo, entry, data->arg2);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_CHOICE:
|
|
||||||
set_option_choice(ctx, oo, entry, data->arg2);
|
|
||||||
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.10 2009-09-07 23:48:54 tcunha Exp $ */
|
/* $Id: cmd-show-buffer.c,v 1.12 2009-12-04 22:14:47 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ 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,
|
CMD_BUFFER_SESSION_USAGE,
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_buffer_init,
|
cmd_buffer_init,
|
||||||
cmd_buffer_parse,
|
cmd_buffer_parse,
|
||||||
cmd_show_buffer_exec,
|
cmd_show_buffer_exec,
|
||||||
@@ -71,24 +71,24 @@ cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
width = s->sx;
|
width = s->sx;
|
||||||
if (ctx->cmdclient != NULL)
|
if (ctx->cmdclient != NULL)
|
||||||
width = ctx->cmdclient->tty.sx;
|
width = ctx->cmdclient->tty.sx;
|
||||||
|
|
||||||
buf = xmalloc(width + 1);
|
buf = xmalloc(width + 1);
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
ptr = in;
|
ptr = in;
|
||||||
do {
|
do {
|
||||||
buf[len++] = *ptr++;
|
buf[len++] = *ptr++;
|
||||||
|
|
||||||
if (len == width || buf[len - 1] == '\n') {
|
if (len == width || buf[len - 1] == '\n') {
|
||||||
if (buf[len - 1] == '\n')
|
if (buf[len - 1] == '\n')
|
||||||
len--;
|
len--;
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
ctx->print(ctx, "%s", buf);
|
ctx->print(ctx, "%s", buf);
|
||||||
len = 0;
|
len = 0;
|
||||||
}
|
}
|
||||||
} while (*ptr != '\0');
|
} while (*ptr != '\0');
|
||||||
|
|
||||||
if (len != 0) {
|
if (len != 0) {
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
ctx->print(ctx, "%s", buf);
|
ctx->print(ctx, "%s", buf);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-show-environment.c,v 1.1 2009-08-09 17:48:55 tcunha Exp $ */
|
/* $Id: cmd-show-environment.c,v 1.2 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -32,7 +32,7 @@ int cmd_show_environment_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_show_environment_entry = {
|
const struct cmd_entry cmd_show_environment_entry = {
|
||||||
"show-environment", "showenv",
|
"show-environment", "showenv",
|
||||||
"[-g] " CMD_TARGET_SESSION_USAGE,
|
"[-g] " CMD_TARGET_SESSION_USAGE,
|
||||||
0, CMD_CHFLAG('g'),
|
0, "g",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_show_environment_exec,
|
cmd_show_environment_exec,
|
||||||
@@ -48,7 +48,7 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct environ *env;
|
struct environ *env;
|
||||||
struct environ_entry *envent;
|
struct environ_entry *envent;
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('g'))
|
if (cmd_check_flag(data->chflags, 'g'))
|
||||||
env = &global_environ;
|
env = &global_environ;
|
||||||
else {
|
else {
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
||||||
|
|||||||
65
cmd-show-messages.c
Normal file
65
cmd-show-messages.c
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/* $Id: cmd-show-messages.c,v 1.2 2009-12-04 22:14:47 tcunha 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 <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Show client message log.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int cmd_show_messages_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_show_messages_entry = {
|
||||||
|
"show-messages", "showmsgs",
|
||||||
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
|
0, "",
|
||||||
|
cmd_target_init,
|
||||||
|
cmd_target_parse,
|
||||||
|
cmd_show_messages_exec,
|
||||||
|
cmd_target_free,
|
||||||
|
cmd_target_print
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct cmd_target_data *data = self->data;
|
||||||
|
struct client *c;
|
||||||
|
struct message_entry *msg;
|
||||||
|
char *tim;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
|
||||||
|
msg = &ARRAY_ITEM(&c->message_log, i);
|
||||||
|
|
||||||
|
tim = ctime(&msg->msg_time);
|
||||||
|
*strchr(tim, '\n') = '\0';
|
||||||
|
|
||||||
|
ctx->print(ctx, "%s %s", tim, msg->msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-show-options.c,v 1.16 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-show-options.c,v 1.21 2009-12-10 16:59:02 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,8 +31,8 @@ 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,
|
"[-gsw] [-t target-session|target-window]",
|
||||||
0, CMD_CHFLAG('g'),
|
0, "gsw",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_show_options_exec,
|
cmd_show_options_exec,
|
||||||
@@ -44,61 +44,44 @@ 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 cmd_target_data *data = self->data;
|
||||||
|
const struct set_option_entry *table;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
struct winlink *wl;
|
||||||
struct options *oo;
|
struct options *oo;
|
||||||
|
struct options_entry *o;
|
||||||
const struct set_option_entry *entry;
|
const struct set_option_entry *entry;
|
||||||
char *vs;
|
const char *optval;
|
||||||
long long vn;
|
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('g'))
|
if (cmd_check_flag(data->chflags, 's')) {
|
||||||
oo = &global_s_options;
|
oo = &global_options;
|
||||||
else {
|
table = set_option_table;
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
} else if (cmd_check_flag(data->chflags, 'w')) {
|
||||||
return (-1);
|
table = set_window_option_table;
|
||||||
oo = &s->options;
|
if (cmd_check_flag(data->chflags, 'g'))
|
||||||
|
oo = &global_w_options;
|
||||||
|
else {
|
||||||
|
wl = cmd_find_window(ctx, data->target, NULL);
|
||||||
|
if (wl == NULL)
|
||||||
|
return (-1);
|
||||||
|
oo = &wl->window->options;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
table = set_session_option_table;
|
||||||
|
if (cmd_check_flag(data->chflags, 'g'))
|
||||||
|
oo = &global_s_options;
|
||||||
|
else {
|
||||||
|
s = cmd_find_session(ctx, data->target);
|
||||||
|
if (s == NULL)
|
||||||
|
return (-1);
|
||||||
|
oo = &s->options;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (entry = set_option_table; entry->name != NULL; entry++) {
|
for (entry = table; entry->name != NULL; entry++) {
|
||||||
if (options_find1(oo, entry->name) == NULL)
|
if ((o = options_find1(oo, entry->name)) == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
optval = cmd_set_option_print(entry, o);
|
||||||
switch (entry->type) {
|
ctx->print(ctx, "%s %s", entry->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,4 +1,4 @@
|
|||||||
/* $Id: cmd-show-window-options.c,v 1.12 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-show-window-options.c,v 1.15 2009-12-04 22:11:23 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show window options.
|
* Show window options. This is an alias for show-options -w.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_window_options_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_show_window_options_exec(struct cmd *, struct cmd_ctx *);
|
||||||
@@ -32,7 +32,7 @@ int cmd_show_window_options_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_show_window_options_entry = {
|
const struct cmd_entry cmd_show_window_options_entry = {
|
||||||
"show-window-options", "showw",
|
"show-window-options", "showw",
|
||||||
"[-g] " CMD_TARGET_WINDOW_USAGE,
|
"[-g] " CMD_TARGET_WINDOW_USAGE,
|
||||||
0, CMD_CHFLAG('g'),
|
0, "g",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_show_window_options_exec,
|
cmd_show_window_options_exec,
|
||||||
@@ -44,62 +44,7 @@ int
|
|||||||
cmd_show_window_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_window_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct winlink *wl;
|
|
||||||
struct options *oo;
|
|
||||||
const struct set_option_entry *entry;
|
|
||||||
char *vs;
|
|
||||||
long long vn;
|
|
||||||
|
|
||||||
if (data->chflags & CMD_CHFLAG('g'))
|
cmd_set_flag(&data->chflags, 'w');
|
||||||
oo = &global_w_options;
|
return (cmd_show_options_entry.exec(self, ctx));
|
||||||
else {
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
oo = &wl->window->options;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (entry = set_window_option_table; entry->name != NULL; entry++) {
|
|
||||||
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.8 2009-08-24 16:27:03 tcunha Exp $ */
|
/* $Id: cmd-source-file.c,v 1.13 2010-02-08 18:29:32 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -37,7 +37,7 @@ struct cmd_source_file_data {
|
|||||||
const struct cmd_entry cmd_source_file_entry = {
|
const struct cmd_entry cmd_source_file_entry = {
|
||||||
"source-file", "source",
|
"source-file", "source",
|
||||||
"path",
|
"path",
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_source_file_init,
|
cmd_source_file_init,
|
||||||
cmd_source_file_parse,
|
cmd_source_file_parse,
|
||||||
cmd_source_file_exec,
|
cmd_source_file_exec,
|
||||||
@@ -45,6 +45,7 @@ const struct cmd_entry cmd_source_file_entry = {
|
|||||||
cmd_source_file_print
|
cmd_source_file_print
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
void
|
void
|
||||||
cmd_source_file_init(struct cmd *self, unused int arg)
|
cmd_source_file_init(struct cmd *self, unused int arg)
|
||||||
{
|
{
|
||||||
@@ -60,7 +61,7 @@ cmd_source_file_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
struct cmd_source_file_data *data;
|
struct cmd_source_file_data *data;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
self->entry->init(self, KEYC_NONE);
|
||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "")) != -1) {
|
while ((opt = getopt(argc, argv, "")) != -1) {
|
||||||
@@ -88,12 +89,18 @@ 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 cmd_source_file_data *data = self->data;
|
||||||
|
struct causelist causes;
|
||||||
char *cause;
|
char *cause;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
if (load_cfg(data->path, ctx, &cause) != 0) {
|
ARRAY_INIT(&causes);
|
||||||
ctx->error(ctx, "%s", cause);
|
if (load_cfg(data->path, ctx, &causes) != 0) {
|
||||||
xfree(cause);
|
for (i = 0; i < ARRAY_LENGTH(&causes); i++) {
|
||||||
return (-1);
|
cause = ARRAY_ITEM(&causes, i);
|
||||||
|
ctx->print(ctx, "%s", cause);
|
||||||
|
xfree(cause);
|
||||||
|
}
|
||||||
|
ARRAY_FREE(&causes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-split-window.c,v 1.27 2009-09-16 12:36:27 nicm Exp $ */
|
/* $Id: cmd-split-window.c,v 1.35 2010-07-02 02:49:19 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -44,8 +44,8 @@ struct cmd_split_window_data {
|
|||||||
|
|
||||||
const struct cmd_entry cmd_split_window_entry = {
|
const struct cmd_entry cmd_split_window_entry = {
|
||||||
"split-window", "splitw",
|
"split-window", "splitw",
|
||||||
"[-dhv] [-p percentage|-l size] [-t target-window] [command]",
|
"[-dhv] [-p percentage|-l size] [-t target-pane] [command]",
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_split_window_init,
|
cmd_split_window_init,
|
||||||
cmd_split_window_parse,
|
cmd_split_window_parse,
|
||||||
cmd_split_window_exec,
|
cmd_split_window_exec,
|
||||||
@@ -69,7 +69,7 @@ cmd_split_window_init(struct cmd *self, int key)
|
|||||||
switch (key) {
|
switch (key) {
|
||||||
case '%':
|
case '%':
|
||||||
data->flag_horizontal = 1;
|
data->flag_horizontal = 1;
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
data->flag_horizontal = 0;
|
data->flag_horizontal = 0;
|
||||||
break;
|
break;
|
||||||
@@ -83,7 +83,7 @@ cmd_split_window_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
int opt;
|
int opt;
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
|
|
||||||
self->entry->init(self, 0);
|
self->entry->init(self, KEYC_NONE);
|
||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "dhl:p:t:v")) != -1) {
|
while ((opt = getopt(argc, argv, "dhl:p:t:v")) != -1) {
|
||||||
@@ -148,15 +148,16 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
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;
|
||||||
struct environ env;
|
struct environ env;
|
||||||
char *cmd, *cwd, *cause;
|
char *cmd, *cwd, *cause;
|
||||||
const char *shell;
|
const char *shell;
|
||||||
u_int hlimit;
|
u_int hlimit;
|
||||||
int size;
|
int size;
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
|
struct layout_cell *lc;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
if ((wl = cmd_find_pane(ctx, data->target, &s, &wp)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
@@ -168,38 +169,47 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cmd = data->cmd;
|
cmd = data->cmd;
|
||||||
if (cmd == NULL)
|
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(&s->options, "default-path");
|
||||||
cwd = options_get_string(&s->options, "default-path");
|
if (*cwd == '\0') {
|
||||||
else
|
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||||
cwd = ctx->cmdclient->cwd;
|
cwd = ctx->cmdclient->cwd;
|
||||||
|
else
|
||||||
size = -1;
|
cwd = s->cwd;
|
||||||
if (data->size != -1)
|
}
|
||||||
size = data->size;
|
|
||||||
else if (data->percentage != -1)
|
|
||||||
size = (w->active->sy * data->percentage) / 100;
|
|
||||||
hlimit = options_get_number(&s->options, "history-limit");
|
|
||||||
|
|
||||||
type = LAYOUT_TOPBOTTOM;
|
type = LAYOUT_TOPBOTTOM;
|
||||||
if (data->flag_horizontal)
|
if (data->flag_horizontal)
|
||||||
type = LAYOUT_LEFTRIGHT;
|
type = LAYOUT_LEFTRIGHT;
|
||||||
|
|
||||||
|
size = -1;
|
||||||
|
if (data->size != -1)
|
||||||
|
size = data->size;
|
||||||
|
else if (data->percentage != -1) {
|
||||||
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
|
size = (wp->sy * data->percentage) / 100;
|
||||||
|
else
|
||||||
|
size = (wp->sx * data->percentage) / 100;
|
||||||
|
}
|
||||||
|
hlimit = options_get_number(&s->options, "history-limit");
|
||||||
|
|
||||||
shell = options_get_string(&s->options, "default-shell");
|
shell = options_get_string(&s->options, "default-shell");
|
||||||
if (*shell == '\0' || areshell(shell))
|
if (*shell == '\0' || areshell(shell))
|
||||||
shell = _PATH_BSHELL;
|
shell = _PATH_BSHELL;
|
||||||
|
|
||||||
wp = window_add_pane(w, hlimit);
|
if ((lc = layout_split_pane(wp, type, size)) == NULL) {
|
||||||
if (window_pane_spawn(wp, cmd, shell, cwd, &env, s->tio, &cause) != 0)
|
|
||||||
goto error;
|
|
||||||
if (layout_split_pane(w->active, type, size, wp) != 0) {
|
|
||||||
cause = xstrdup("pane too small");
|
cause = xstrdup("pane too small");
|
||||||
goto error;
|
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 (!data->flag_detached) {
|
||||||
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
|
||||||
@@ -210,8 +220,8 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
if (wp != NULL)
|
if (new_wp != NULL)
|
||||||
window_remove_pane(w, wp);
|
window_remove_pane(w, new_wp);
|
||||||
ctx->error(ctx, "create pane failed: %s", cause);
|
ctx->error(ctx, "create pane failed: %s", cause);
|
||||||
xfree(cause);
|
xfree(cause);
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-start-server.c,v 1.8 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-start-server.c,v 1.10 2009-11-28 14:50:36 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ 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",
|
||||||
"",
|
"",
|
||||||
CMD_STARTSERVER, 0,
|
CMD_STARTSERVER, "",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_start_server_exec,
|
cmd_start_server_exec,
|
||||||
@@ -37,6 +37,7 @@ const struct cmd_entry cmd_start_server_entry = {
|
|||||||
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)
|
||||||
{
|
{
|
||||||
|
|||||||
130
cmd-string.c
130
cmd-string.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-string.c,v 1.23 2009-08-09 17:48:55 tcunha Exp $ */
|
/* $Id: cmd-string.c,v 1.32 2010-12-13 22:53:56 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
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 *);
|
char *cmd_string_expand_tilde(const char *, size_t *);
|
||||||
@@ -40,13 +40,15 @@ 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)--;
|
||||||
}
|
}
|
||||||
@@ -59,7 +61,7 @@ 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, i, argc, rval, have_arg;
|
int ch, i, argc, rval;
|
||||||
char **argv, *buf, *t;
|
char **argv, *buf, *t;
|
||||||
const char *whitespace, *equals;
|
const char *whitespace, *equals;
|
||||||
size_t len;
|
size_t len;
|
||||||
@@ -70,8 +72,6 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
buf = NULL;
|
buf = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
have_arg = 0;
|
|
||||||
|
|
||||||
*cause = NULL;
|
*cause = NULL;
|
||||||
|
|
||||||
*cmdlist = NULL;
|
*cmdlist = NULL;
|
||||||
@@ -88,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)
|
||||||
@@ -98,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)
|
||||||
@@ -108,8 +104,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 '#':
|
||||||
/* Comment: discard rest of line. */
|
/* Comment: discard rest of line. */
|
||||||
@@ -119,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';
|
||||||
|
|
||||||
@@ -128,23 +122,19 @@ 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;
|
||||||
if (argc == 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
while (argc != 0) {
|
||||||
equals = strchr(argv[i], '=');
|
equals = strchr(argv[0], '=');
|
||||||
whitespace = argv[i] + strcspn(argv[i], " \t");
|
whitespace = argv[0] + strcspn(argv[0], " \t");
|
||||||
if (equals == NULL || equals > whitespace)
|
if (equals == NULL || equals > whitespace)
|
||||||
break;
|
break;
|
||||||
environ_put(&global_environ, argv[i]);
|
environ_put(&global_environ, argv[0]);
|
||||||
memmove(&argv[i], &argv[i + 1], argc - i - 1);
|
|
||||||
argc--;
|
argc--;
|
||||||
|
memmove(argv, argv + 1, argc * (sizeof *argv));
|
||||||
}
|
}
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
goto out;
|
goto out;
|
||||||
@@ -153,14 +143,10 @@ 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 '~':
|
case '~':
|
||||||
if (have_arg == 0) {
|
if (buf == NULL) {
|
||||||
if ((t = cmd_string_expand_tilde(s, &p)) == NULL)
|
if ((t = cmd_string_expand_tilde(s, &p)) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
||||||
@@ -176,8 +162,6 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
|
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, 1, len + 1);
|
||||||
buf[len++] = ch;
|
buf[len++] = ch;
|
||||||
|
|
||||||
have_arg = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,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);
|
||||||
}
|
}
|
||||||
@@ -204,33 +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 'e':
|
case 'e':
|
||||||
ch = '\033';
|
ch = '\033';
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
ch = '\r';
|
ch = '\r';
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
ch = '\n';
|
ch = '\n';
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
ch = '\t';
|
ch = '\t';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '$':
|
case '$':
|
||||||
if (!esc)
|
if (!esc)
|
||||||
break;
|
break;
|
||||||
@@ -241,13 +226,13 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
|||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
xfree(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';
|
||||||
@@ -262,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'))
|
||||||
@@ -272,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;
|
||||||
@@ -311,17 +297,16 @@ 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)
|
||||||
@@ -332,23 +317,24 @@ error:
|
|||||||
char *
|
char *
|
||||||
cmd_string_expand_tilde(const char *s, size_t *p)
|
cmd_string_expand_tilde(const char *s, size_t *p)
|
||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
char *home, *path, *username;
|
struct environ_entry *envent;
|
||||||
|
char *home, *path, *username;
|
||||||
|
|
||||||
home = NULL;
|
home = NULL;
|
||||||
if (cmd_string_getc(s, p) == '/') {
|
if (cmd_string_getc(s, p) == '/') {
|
||||||
if ((home = getenv("HOME")) == NULL) {
|
envent = environ_find(&global_environ, "HOME");
|
||||||
if ((pw = getpwuid(getuid())) != NULL)
|
if (envent != NULL && *envent->value != '\0')
|
||||||
home = pw->pw_dir;
|
home = envent->value;
|
||||||
}
|
else if ((pw = getpwuid(getuid())) != NULL)
|
||||||
|
home = pw->pw_dir;
|
||||||
} else {
|
} else {
|
||||||
cmd_string_ungetc(s, p);
|
cmd_string_ungetc(p);
|
||||||
if ((username = cmd_string_string(s, p, '/', 0)) == NULL)
|
if ((username = cmd_string_string(s, p, '/', 0)) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if ((pw = getpwnam(username)) != NULL)
|
if ((pw = getpwnam(username)) != NULL)
|
||||||
home = pw->pw_dir;
|
home = pw->pw_dir;
|
||||||
if (username != NULL)
|
xfree(username);
|
||||||
xfree(username);
|
|
||||||
}
|
}
|
||||||
if (home == NULL)
|
if (home == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-suspend-client.c,v 1.4 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-suspend-client.c,v 1.5 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -37,7 +37,7 @@ struct cmd_suspend_client_data {
|
|||||||
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]",
|
"[-c target-client]",
|
||||||
0, 0,
|
0, "",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_suspend_client_exec,
|
cmd_suspend_client_exec,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-swap-pane.c,v 1.13 2009-07-30 21:04:40 tcunha Exp $ */
|
/* $Id: cmd-swap-pane.c,v 1.15 2009-12-04 22:14:47 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -32,7 +32,7 @@ int cmd_swap_pane_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_swap_pane_entry = {
|
const struct cmd_entry cmd_swap_pane_entry = {
|
||||||
"swap-pane", "swapp",
|
"swap-pane", "swapp",
|
||||||
"[-dDU] " CMD_SRCDST_PANE_USAGE,
|
"[-dDU] " CMD_SRCDST_PANE_USAGE,
|
||||||
0, CMD_CHFLAG('d')|CMD_CHFLAG('D')|CMD_CHFLAG('U'),
|
0, "dDU",
|
||||||
cmd_swap_pane_init,
|
cmd_swap_pane_init,
|
||||||
cmd_srcdst_parse,
|
cmd_srcdst_parse,
|
||||||
cmd_swap_pane_exec,
|
cmd_swap_pane_exec,
|
||||||
@@ -49,11 +49,12 @@ cmd_swap_pane_init(struct cmd *self, int key)
|
|||||||
data = self->data;
|
data = self->data;
|
||||||
|
|
||||||
if (key == '{')
|
if (key == '{')
|
||||||
data->chflags |= CMD_CHFLAG('U');
|
cmd_set_flag(&data->chflags, 'U');
|
||||||
else if (key == '}')
|
else if (key == '}')
|
||||||
data->chflags |= CMD_CHFLAG('D');
|
cmd_set_flag(&data->chflags, 'D');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
@@ -73,11 +74,11 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (data->src == NULL) {
|
if (data->src == NULL) {
|
||||||
src_w = dst_w;
|
src_w = dst_w;
|
||||||
if (data->chflags & CMD_CHFLAG('D')) {
|
if (cmd_check_flag(data->chflags, 'D')) {
|
||||||
src_wp = TAILQ_NEXT(dst_wp, entry);
|
src_wp = TAILQ_NEXT(dst_wp, entry);
|
||||||
if (src_wp == NULL)
|
if (src_wp == NULL)
|
||||||
src_wp = TAILQ_FIRST(&dst_w->panes);
|
src_wp = TAILQ_FIRST(&dst_w->panes);
|
||||||
} else if (data->chflags & CMD_CHFLAG('U')) {
|
} else if (cmd_check_flag(data->chflags, 'U')) {
|
||||||
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||||
if (src_wp == NULL)
|
if (src_wp == NULL)
|
||||||
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
||||||
@@ -109,7 +110,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
dst_wp->layout_cell = src_lc;
|
dst_wp->layout_cell = src_lc;
|
||||||
dst_lc->wp = src_wp;
|
dst_lc->wp = src_wp;
|
||||||
src_wp->layout_cell = dst_lc;
|
src_wp->layout_cell = dst_lc;
|
||||||
|
|
||||||
src_wp->window = dst_w;
|
src_wp->window = dst_w;
|
||||||
dst_wp->window = src_w;
|
dst_wp->window = src_w;
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
dst_wp->xoff = xoff; dst_wp->yoff = yoff;
|
dst_wp->xoff = xoff; dst_wp->yoff = yoff;
|
||||||
window_pane_resize(dst_wp, sx, sy);
|
window_pane_resize(dst_wp, sx, sy);
|
||||||
|
|
||||||
if (!(data->chflags & CMD_CHFLAG('d'))) {
|
if (!cmd_check_flag(data->chflags, 'd')) {
|
||||||
if (src_w != dst_w) {
|
if (src_w != dst_w) {
|
||||||
window_set_active_pane(src_w, dst_wp);
|
window_set_active_pane(src_w, dst_wp);
|
||||||
window_set_active_pane(dst_w, src_wp);
|
window_set_active_pane(dst_w, src_wp);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-swap-window.c,v 1.17 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-swap-window.c,v 1.19 2009-11-14 17:56:39 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,7 +31,7 @@ int cmd_swap_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_swap_window_entry = {
|
const struct cmd_entry cmd_swap_window_entry = {
|
||||||
"swap-window", "swapw",
|
"swap-window", "swapw",
|
||||||
"[-d] " CMD_SRCDST_WINDOW_USAGE,
|
"[-d] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
0, CMD_CHFLAG('d'),
|
0, "d",
|
||||||
cmd_srcdst_init,
|
cmd_srcdst_init,
|
||||||
cmd_srcdst_parse,
|
cmd_srcdst_parse,
|
||||||
cmd_swap_window_exec,
|
cmd_swap_window_exec,
|
||||||
@@ -44,6 +44,7 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
{
|
{
|
||||||
struct cmd_srcdst_data *data = self->data;
|
struct cmd_srcdst_data *data = self->data;
|
||||||
struct session *src, *dst;
|
struct session *src, *dst;
|
||||||
|
struct session_group *sg_src, *sg_dst;
|
||||||
struct winlink *wl_src, *wl_dst;
|
struct winlink *wl_src, *wl_dst;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
|
|
||||||
@@ -52,6 +53,14 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if ((wl_dst = cmd_find_window(ctx, data->dst, &dst)) == NULL)
|
if ((wl_dst = cmd_find_window(ctx, data->dst, &dst)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
sg_src = session_group_find(src);
|
||||||
|
sg_dst = session_group_find(dst);
|
||||||
|
if (src != dst &&
|
||||||
|
sg_src != NULL && sg_dst != NULL && sg_src == sg_dst) {
|
||||||
|
ctx->error(ctx, "can't move window, sessions are grouped");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
if (wl_dst->window == wl_src->window)
|
if (wl_dst->window == wl_src->window)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
@@ -59,14 +68,17 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
wl_dst->window = wl_src->window;
|
wl_dst->window = wl_src->window;
|
||||||
wl_src->window = w;
|
wl_src->window = w;
|
||||||
|
|
||||||
if (!(data->chflags & CMD_CHFLAG('d'))) {
|
if (!cmd_check_flag(data->chflags, 'd')) {
|
||||||
session_select(dst, wl_dst->idx);
|
session_select(dst, wl_dst->idx);
|
||||||
if (src != dst)
|
if (src != dst)
|
||||||
session_select(src, wl_src->idx);
|
session_select(src, wl_src->idx);
|
||||||
}
|
}
|
||||||
server_redraw_session(src);
|
session_group_synchronize_from(src);
|
||||||
if (src != dst)
|
server_redraw_session_group(src);
|
||||||
server_redraw_session(dst);
|
if (src != dst) {
|
||||||
|
session_group_synchronize_from(dst);
|
||||||
|
server_redraw_session_group(dst);
|
||||||
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-switch-client.c,v 1.17 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-switch-client.c,v 1.23 2010-12-22 15:31:00 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
* Switch client to a different session.
|
* Switch client to a different session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void cmd_switch_client_init(struct cmd *, int);
|
||||||
int cmd_switch_client_parse(struct cmd *, int, char **, char **);
|
int cmd_switch_client_parse(struct cmd *, int, char **, char **);
|
||||||
int cmd_switch_client_exec(struct cmd *, struct cmd_ctx *);
|
int cmd_switch_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_switch_client_free(struct cmd *);
|
void cmd_switch_client_free(struct cmd *);
|
||||||
@@ -35,36 +36,85 @@ size_t cmd_switch_client_print(struct cmd *, char *, size_t);
|
|||||||
struct cmd_switch_client_data {
|
struct cmd_switch_client_data {
|
||||||
char *name;
|
char *name;
|
||||||
char *target;
|
char *target;
|
||||||
|
int flag_last;
|
||||||
|
int flag_next;
|
||||||
|
int flag_previous;
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_switch_client_entry = {
|
const struct cmd_entry cmd_switch_client_entry = {
|
||||||
"switch-client", "switchc",
|
"switch-client", "switchc",
|
||||||
"[-c target-client] [-t target-session]",
|
"[-lnp] [-c target-client] [-t target-session]",
|
||||||
0, 0,
|
0, "",
|
||||||
NULL,
|
cmd_switch_client_init,
|
||||||
cmd_switch_client_parse,
|
cmd_switch_client_parse,
|
||||||
cmd_switch_client_exec,
|
cmd_switch_client_exec,
|
||||||
cmd_switch_client_free,
|
cmd_switch_client_free,
|
||||||
cmd_switch_client_print
|
cmd_switch_client_print
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_switch_client_init(struct cmd *self, int key)
|
||||||
|
{
|
||||||
|
struct cmd_switch_client_data *data;
|
||||||
|
|
||||||
|
self->data = data = xmalloc(sizeof *data);
|
||||||
|
data->name = NULL;
|
||||||
|
data->target = NULL;
|
||||||
|
data->flag_last = 0;
|
||||||
|
data->flag_next = 0;
|
||||||
|
data->flag_previous = 0;
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case '(':
|
||||||
|
data->flag_previous = 1;
|
||||||
|
break;
|
||||||
|
case ')':
|
||||||
|
data->flag_next = 1;
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
data->flag_last = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_switch_client_parse(struct cmd *self, int argc, char **argv, char **cause)
|
cmd_switch_client_parse(struct cmd *self, int argc, char **argv, char **cause)
|
||||||
{
|
{
|
||||||
struct cmd_switch_client_data *data;
|
struct cmd_switch_client_data *data;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
self->entry->init(self, KEYC_NONE);
|
||||||
data->name = NULL;
|
data = self->data;
|
||||||
data->target = NULL;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "c:t:")) != -1) {
|
while ((opt = getopt(argc, argv, "c:lnpt:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'c':
|
case 'c':
|
||||||
data->name = xstrdup(optarg);
|
if (data->name == NULL)
|
||||||
|
data->name = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
if (data->flag_next || data->flag_previous ||
|
||||||
|
data->target != NULL)
|
||||||
|
goto usage;
|
||||||
|
data->flag_last = 1;
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
if (data->flag_previous || data->flag_last ||
|
||||||
|
data->target != NULL)
|
||||||
|
goto usage;
|
||||||
|
data->flag_next = 1;
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
if (data->flag_next || data->flag_last ||
|
||||||
|
data->target != NULL)
|
||||||
|
goto usage;
|
||||||
|
data->flag_next = 1;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
data->target = xstrdup(optarg);
|
if (data->flag_next || data->flag_previous)
|
||||||
|
goto usage;
|
||||||
|
if (data->target == NULL)
|
||||||
|
data->target = xstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto usage;
|
goto usage;
|
||||||
@@ -96,12 +146,36 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->name)) == NULL)
|
if ((c = cmd_find_client(ctx, data->name)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
|
s = NULL;
|
||||||
|
if (data->flag_next) {
|
||||||
|
if ((s = session_next_session(c->session)) == NULL) {
|
||||||
|
ctx->error(ctx, "can't find next session");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} else if (data->flag_previous) {
|
||||||
|
if ((s = session_previous_session(c->session)) == NULL) {
|
||||||
|
ctx->error(ctx, "can't find previous session");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} else if (data->flag_last) {
|
||||||
|
if (c->last_session != NULL && session_alive(c->last_session))
|
||||||
|
s = c->last_session;
|
||||||
|
if (s == NULL) {
|
||||||
|
ctx->error(ctx, "can't find last session");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
s = cmd_find_session(ctx, data->target);
|
||||||
|
if (s == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
if (c->session != NULL)
|
||||||
|
c->last_session = c->session;
|
||||||
c->session = s;
|
c->session = s;
|
||||||
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
server_check_unattached();
|
||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
@@ -128,6 +202,12 @@ cmd_switch_client_print(struct cmd *self, char *buf, size_t len)
|
|||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
off += xsnprintf(buf, len, "%s", self->entry->name);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return (off);
|
return (off);
|
||||||
|
if (off < len && data->flag_last)
|
||||||
|
off += xsnprintf(buf + off, len - off, "%s", " -l");
|
||||||
|
if (off < len && data->flag_next)
|
||||||
|
off += xsnprintf(buf + off, len - off, "%s", " -n");
|
||||||
|
if (off < len && data->flag_previous)
|
||||||
|
off += xsnprintf(buf + off, len - off, "%s", " -p");
|
||||||
if (off < len && data->name != NULL)
|
if (off < len && data->name != NULL)
|
||||||
off += cmd_prarg(buf + off, len - off, " -c ", data->name);
|
off += cmd_prarg(buf + off, len - off, " -c ", data->name);
|
||||||
if (off < len && data->target != NULL)
|
if (off < len && data->target != NULL)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-unbind-key.c,v 1.20 2009-07-28 23:19:06 tcunha Exp $ */
|
/* $Id: cmd-unbind-key.c,v 1.23 2010-12-06 21:51:02 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -33,14 +33,15 @@ int cmd_unbind_key_table(struct cmd *, struct cmd_ctx *);
|
|||||||
struct cmd_unbind_key_data {
|
struct cmd_unbind_key_data {
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
|
int flag_all;
|
||||||
int command_key;
|
int command_key;
|
||||||
char *tablename;
|
char *tablename;
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_unbind_key_entry = {
|
const struct cmd_entry cmd_unbind_key_entry = {
|
||||||
"unbind-key", "unbind",
|
"unbind-key", "unbind",
|
||||||
"[-cn] [-t key-table] key",
|
"[-acn] [-t key-table] key",
|
||||||
0, 0,
|
0, "",
|
||||||
NULL,
|
NULL,
|
||||||
cmd_unbind_key_parse,
|
cmd_unbind_key_parse,
|
||||||
cmd_unbind_key_exec,
|
cmd_unbind_key_exec,
|
||||||
@@ -55,11 +56,15 @@ cmd_unbind_key_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
int opt, no_prefix = 0;
|
int opt, no_prefix = 0;
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
self->data = data = xmalloc(sizeof *data);
|
||||||
|
data->flag_all = 0;
|
||||||
data->command_key = 0;
|
data->command_key = 0;
|
||||||
data->tablename = NULL;
|
data->tablename = NULL;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "cnt:")) != -1) {
|
while ((opt = getopt(argc, argv, "acnt:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case 'a':
|
||||||
|
data->flag_all = 1;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
data->command_key = 1;
|
data->command_key = 1;
|
||||||
break;
|
break;
|
||||||
@@ -67,7 +72,8 @@ cmd_unbind_key_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
no_prefix = 1;
|
no_prefix = 1;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
data->tablename = xstrdup(optarg);
|
if (data->tablename == NULL)
|
||||||
|
data->tablename = xstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto usage;
|
goto usage;
|
||||||
@@ -75,15 +81,20 @@ cmd_unbind_key_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
}
|
}
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
if (argc != 1)
|
if (data->flag_all && (argc != 0 || data->tablename))
|
||||||
|
goto usage;
|
||||||
|
if (!data->flag_all && argc != 1)
|
||||||
goto usage;
|
goto usage;
|
||||||
|
|
||||||
if ((data->key = key_string_lookup_string(argv[0])) == KEYC_NONE) {
|
if (!data->flag_all) {
|
||||||
xasprintf(cause, "unknown key: %s", argv[0]);
|
data->key = key_string_lookup_string(argv[0]);
|
||||||
goto error;
|
if (data->key == KEYC_NONE) {
|
||||||
|
xasprintf(cause, "unknown key: %s", argv[0]);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if (!no_prefix)
|
||||||
|
data->key |= KEYC_PREFIX;
|
||||||
}
|
}
|
||||||
if (!no_prefix)
|
|
||||||
data->key |= KEYC_PREFIX;
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
@@ -99,13 +110,23 @@ int
|
|||||||
cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_unbind_key_data *data = self->data;
|
struct cmd_unbind_key_data *data = self->data;
|
||||||
|
struct key_binding *bd;
|
||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
if (data->tablename != NULL)
|
if (data->flag_all) {
|
||||||
return (cmd_unbind_key_table(self, ctx));
|
while (!SPLAY_EMPTY(&key_bindings)) {
|
||||||
|
bd = SPLAY_ROOT(&key_bindings);
|
||||||
|
SPLAY_REMOVE(key_bindings, &key_bindings, bd);
|
||||||
|
cmd_list_free(bd->cmdlist);
|
||||||
|
xfree(bd);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (data->tablename != NULL)
|
||||||
|
return (cmd_unbind_key_table(self, ctx));
|
||||||
|
|
||||||
key_bindings_remove(data->key);
|
key_bindings_remove(data->key);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-unlink-window.c,v 1.16 2009-07-28 22:12:16 tcunha Exp $ */
|
/* $Id: cmd-unlink-window.c,v 1.21 2009-12-04 22:14:47 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -29,7 +29,7 @@ int cmd_unlink_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
const struct cmd_entry cmd_unlink_window_entry = {
|
const struct cmd_entry cmd_unlink_window_entry = {
|
||||||
"unlink-window", "unlinkw",
|
"unlink-window", "unlinkw",
|
||||||
"[-k] " CMD_TARGET_WINDOW_USAGE,
|
"[-k] " CMD_TARGET_WINDOW_USAGE,
|
||||||
0, CMD_CHFLAG('k'),
|
0, "k",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_unlink_window_exec,
|
cmd_unlink_window_exec,
|
||||||
@@ -42,30 +42,29 @@ cmd_unlink_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct session *s;
|
struct window *w;
|
||||||
struct client *c;
|
struct session *s, *s2;
|
||||||
u_int i;
|
struct session_group *sg;
|
||||||
int destroyed;
|
u_int references;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
w = wl->window;
|
||||||
|
|
||||||
if (!(data->chflags & CMD_CHFLAG('k')) && wl->window->references == 1) {
|
sg = session_group_find(s);
|
||||||
|
if (sg != NULL) {
|
||||||
|
references = 0;
|
||||||
|
TAILQ_FOREACH(s2, &sg->sessions, gentry)
|
||||||
|
references++;
|
||||||
|
} else
|
||||||
|
references = 1;
|
||||||
|
|
||||||
|
if (!cmd_check_flag(data->chflags, 'k') && w->references == references) {
|
||||||
ctx->error(ctx, "window is only linked to one session");
|
ctx->error(ctx, "window is only linked to one session");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyed = session_detach(s, wl);
|
server_unlink_window(s, wl);
|
||||||
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);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user