mirror of
https://github.com/tmux/tmux.git
synced 2026-03-12 03:25:45 +00:00
Compare commits
1936 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f21cb71fbe | ||
|
|
990218739a | ||
|
|
e7c2f53f2a | ||
|
|
9b2f02efbd | ||
|
|
b087483538 | ||
|
|
b946bf43f5 | ||
|
|
d64a815e8d | ||
|
|
a54309147d | ||
|
|
fb3c5efa50 | ||
|
|
aace1ead1e | ||
|
|
0aa959d7a3 | ||
|
|
83ff1e9bd3 | ||
|
|
28833efb48 | ||
|
|
175d1854d4 | ||
|
|
7461c165b5 | ||
|
|
d912687be7 | ||
|
|
d566c780e5 | ||
|
|
54bcaab70e | ||
|
|
9583878a7b | ||
|
|
d720a1487b | ||
|
|
5f662d91db | ||
|
|
94b71bcb64 | ||
|
|
36882ec789 | ||
|
|
9b28200578 | ||
|
|
ab4a4b2ad0 | ||
|
|
05c97d7fe9 | ||
|
|
b9a4beb6e7 | ||
|
|
2d84ee9001 | ||
|
|
2e5664d2df | ||
|
|
1384525dc1 | ||
|
|
591b26e46f | ||
|
|
e87d808594 | ||
|
|
1cb8145dc5 | ||
|
|
c57039bc3d | ||
|
|
9c0520f2c5 | ||
|
|
c3dbbdaadf | ||
|
|
843e605b89 | ||
|
|
643813c6ed | ||
|
|
223ed4a989 | ||
|
|
080080fa23 | ||
|
|
df3ab87964 | ||
|
|
3cc2486106 | ||
|
|
57cb6ef3a2 | ||
|
|
02ddd4ce70 | ||
|
|
b008a07ebb | ||
|
|
04e17a7e11 | ||
|
|
cd7550cdf1 | ||
|
|
c2b53598ad | ||
|
|
57b4d3d593 | ||
|
|
cdaa758340 | ||
|
|
c916feaf29 | ||
|
|
31ae09efa0 | ||
|
|
066575fd5a | ||
|
|
792455ce87 | ||
|
|
4eec3270ec | ||
|
|
640666fb36 | ||
|
|
67d2335130 | ||
|
|
481e48d119 | ||
|
|
1ea19245b3 | ||
|
|
b69efbdd30 | ||
|
|
0dd694f5fd | ||
|
|
2a9d697771 | ||
|
|
4e809a3130 | ||
|
|
3c3c08b6d9 | ||
|
|
cc6c6edb6f | ||
|
|
8e9b10062b | ||
|
|
12c6c723a9 | ||
|
|
fd65210139 | ||
|
|
266e662fae | ||
|
|
d455da45eb | ||
|
|
0fe3b739a1 | ||
|
|
392253f032 | ||
|
|
385a361bf8 | ||
|
|
a24cf4a5e1 | ||
|
|
55e73e3612 | ||
|
|
c5bdae466e | ||
|
|
bce1dee034 | ||
|
|
dbfee6a468 | ||
|
|
fd96ccfd80 | ||
|
|
b79df1dc29 | ||
|
|
180ebf0208 | ||
|
|
514a723f74 | ||
|
|
92434b0afd | ||
|
|
e8f2609ca4 | ||
|
|
41a01fc629 | ||
|
|
41b31fe240 | ||
|
|
78ca1b0265 | ||
|
|
3ea36830f3 | ||
|
|
6b2009ad72 | ||
|
|
5d3296c53b | ||
|
|
1e6e606f54 | ||
|
|
daac28febb | ||
|
|
69257bc0aa | ||
|
|
8684e60f51 | ||
|
|
fa27cbd035 | ||
|
|
dc8fefe902 | ||
|
|
fba9ebcc0c | ||
|
|
48a3dba6b9 | ||
|
|
2fa16eee53 | ||
|
|
e741a0bcd7 | ||
|
|
14dc2acc25 | ||
|
|
0414b1fc78 | ||
|
|
4b112c19f1 | ||
|
|
8a0b279c31 | ||
|
|
6b45464120 | ||
|
|
27ee34e7fa | ||
|
|
e9819eef3c | ||
|
|
9e4c5133c8 | ||
|
|
11e7915195 | ||
|
|
0ad2beae7e | ||
|
|
55e76edd3c | ||
|
|
f27e1d07fc | ||
|
|
203d604bf7 | ||
|
|
ee7acde149 | ||
|
|
82db1fa9e5 | ||
|
|
c948c6b697 | ||
|
|
c889e11375 | ||
|
|
f734d81074 | ||
|
|
8b8d0963da | ||
|
|
c9f2dc5ee5 | ||
|
|
dd25a6cdc2 | ||
|
|
47bc867ab9 | ||
|
|
b9b7daf3b2 | ||
|
|
631a89954f | ||
|
|
36734afdd8 | ||
|
|
640d9e54b7 | ||
|
|
2b4c144f96 | ||
|
|
ba3c1534e0 | ||
|
|
e340df2034 | ||
|
|
02e04477de | ||
|
|
4c2a78029d | ||
|
|
921880e00b | ||
|
|
d22c15107b | ||
|
|
c6a3446398 | ||
|
|
8de4c15dfa | ||
|
|
c75cced07d | ||
|
|
96ad1d7779 | ||
|
|
b1fa3e25e4 | ||
|
|
cb50a51127 | ||
|
|
b7ddfb39f3 | ||
|
|
ddb3750c8b | ||
|
|
79409dc1cc | ||
|
|
fd6e46596d | ||
|
|
743f772bef | ||
|
|
be033b1ed0 | ||
|
|
1811dc5271 | ||
|
|
2f854969ff | ||
|
|
130b77edc7 | ||
|
|
05802a6fe3 | ||
|
|
e100d465da | ||
|
|
13a0b6bb3f | ||
|
|
d4b006b9fa | ||
|
|
e09625e38b | ||
|
|
7475165cd8 | ||
|
|
ac1f294bb9 | ||
|
|
96b66f8fc3 | ||
|
|
713f3b05f3 | ||
|
|
9af5f3ff81 | ||
|
|
a9a0039be4 | ||
|
|
cb80901d33 | ||
|
|
9cc02d1498 | ||
|
|
acb4bd9e56 | ||
|
|
35a0606de1 | ||
|
|
5aaf640629 | ||
|
|
c0a34821c1 | ||
|
|
20f5e377fb | ||
|
|
178289fb4c | ||
|
|
6ea36afc4b | ||
|
|
97fd291079 | ||
|
|
9491a5c1cf | ||
|
|
8872a0da8e | ||
|
|
0f5a2c86da | ||
|
|
9f66fb4fd7 | ||
|
|
d60e585d9e | ||
|
|
dfdc23d86c | ||
|
|
7417e391d5 | ||
|
|
68e04907de | ||
|
|
10e14ae504 | ||
|
|
1199f8fc59 | ||
|
|
e67548dc36 | ||
|
|
446177a832 | ||
|
|
4eabd7ec90 | ||
|
|
d150d9b384 | ||
|
|
3fd34e70e5 | ||
|
|
50f25a8f05 | ||
|
|
c7c1018e9b | ||
|
|
7bccc82284 | ||
|
|
d091253a5d | ||
|
|
e1c283325e | ||
|
|
5e6a8177e5 | ||
|
|
75adf8368a | ||
|
|
6c333cc486 | ||
|
|
7d23d019c0 | ||
|
|
9b1f620aa0 | ||
|
|
dd0c814779 | ||
|
|
9b9a5a292d | ||
|
|
c54a5d9fb3 | ||
|
|
d8da761d54 | ||
|
|
3408595f77 | ||
|
|
9094f01c6b | ||
|
|
b6099f31ea | ||
|
|
4b482c95c3 | ||
|
|
54309cc25d | ||
|
|
503af3df54 | ||
|
|
b2e909b252 | ||
|
|
a4367b44fb | ||
|
|
78c0b96004 | ||
|
|
776ce8a9d5 | ||
|
|
ea70e68a51 | ||
|
|
0f9354eec2 | ||
|
|
21d8f77a0d | ||
|
|
163732e89f | ||
|
|
0a63ab4f0f | ||
|
|
3e495b4001 | ||
|
|
418ab1a553 | ||
|
|
ffc28a7765 | ||
|
|
4b2821ff98 | ||
|
|
b77dd75b57 | ||
|
|
16e43d6a42 | ||
|
|
f38a6bbd81 | ||
|
|
126d364abe | ||
|
|
85338bb75f | ||
|
|
61fce272ea | ||
|
|
f1282a683d | ||
|
|
c68ea386d1 | ||
|
|
3d74e89a39 | ||
|
|
a3d5bfcece | ||
|
|
1ebe79dd62 | ||
|
|
b3a724f30c | ||
|
|
98e7fbb2ac | ||
|
|
d2eab39ffa | ||
|
|
aa70f28069 | ||
|
|
acf331f7f1 | ||
|
|
4ede35c48c | ||
|
|
c17b0a202a | ||
|
|
46572ba904 | ||
|
|
61af9d7cc2 | ||
|
|
b98b4e23a3 | ||
|
|
7e4908f751 | ||
|
|
787f9de5d8 | ||
|
|
044999ce6d | ||
|
|
faa0570309 | ||
|
|
6d37984f4f | ||
|
|
4bb5a1d6a7 | ||
|
|
649c0d8e91 | ||
|
|
373541104b | ||
|
|
64c486ae81 | ||
|
|
6b6b0e91d0 | ||
|
|
c0346701df | ||
|
|
7e110b9d99 | ||
|
|
f20e3ee62c | ||
|
|
ef15b4195f | ||
|
|
68db958477 | ||
|
|
997b11741c | ||
|
|
7b60645732 | ||
|
|
c9fcb76651 | ||
|
|
52847a9518 | ||
|
|
3054846143 | ||
|
|
2b0bc9f1c5 | ||
|
|
404214b0ac | ||
|
|
a3cf995017 | ||
|
|
4f077fe62c | ||
|
|
e06efab9da | ||
|
|
780dd7ac82 | ||
|
|
2311bbd28a | ||
|
|
08d21936e4 | ||
|
|
22a528905d | ||
|
|
95950bf668 | ||
|
|
d4cb178249 | ||
|
|
24cba5907b | ||
|
|
1eb9500644 | ||
|
|
dad3090d32 | ||
|
|
4a76861925 | ||
|
|
9b6aeacdc0 | ||
|
|
0752fdaf6a | ||
|
|
9e786030df | ||
|
|
33ebb9ec39 | ||
|
|
74c40d04ea | ||
|
|
3bb14001b9 | ||
|
|
d87ab0cadf | ||
|
|
bf6a5c056d | ||
|
|
7497ecd979 | ||
|
|
0d19d78fff | ||
|
|
458b6eb600 | ||
|
|
8f79b079cd | ||
|
|
db8dff6814 | ||
|
|
5526627558 | ||
|
|
ba35e8f292 | ||
|
|
2283f19876 | ||
|
|
152bfa02f0 | ||
|
|
a5c89a1802 | ||
|
|
aa4de2d4b2 | ||
|
|
570943beb7 | ||
|
|
1e12e1d843 | ||
|
|
5ea7a00eba | ||
|
|
e78142232f | ||
|
|
628f3ad9f4 | ||
|
|
40fddfbdd6 | ||
|
|
2c862b04af | ||
|
|
36619607ba | ||
|
|
d2d984647e | ||
|
|
844f2eacf4 | ||
|
|
95f5d406e5 | ||
|
|
561b5c6fdb | ||
|
|
5330a2a85d | ||
|
|
d90fa2ec13 | ||
|
|
325c85a5c1 | ||
|
|
29e64a8c64 | ||
|
|
c05002b0f2 | ||
|
|
314e933914 | ||
|
|
a3428487a7 | ||
|
|
cae0fbbe8c | ||
|
|
461217d0f0 | ||
|
|
58642011df | ||
|
|
9a56671a75 | ||
|
|
45dbbb78b0 | ||
|
|
43e8f60bc6 | ||
|
|
f5c5847788 | ||
|
|
1015b124d5 | ||
|
|
d3328a3b1e | ||
|
|
70ba3c147f | ||
|
|
af56e50f74 | ||
|
|
00445ebadd | ||
|
|
e36f932f62 | ||
|
|
dda701d95f | ||
|
|
b851c628f4 | ||
|
|
a64b7cfe5d | ||
|
|
bee95bf378 | ||
|
|
75135ded09 | ||
|
|
2a7b4bb017 | ||
|
|
d3ede11212 | ||
|
|
5819d2a9d7 | ||
|
|
b9fa8f12d7 | ||
|
|
5ea143f521 | ||
|
|
a8f3ad4487 | ||
|
|
6749a30a6e | ||
|
|
1a6156d8fd | ||
|
|
1fccfd7be5 | ||
|
|
6b46c62bb4 | ||
|
|
d7837cca52 | ||
|
|
9fc925ac51 | ||
|
|
2864a31311 | ||
|
|
6f8cedb1bc | ||
|
|
a02d95a313 | ||
|
|
84319aa8f0 | ||
|
|
0d1be2e328 | ||
|
|
7e6c2cb238 | ||
|
|
8a8001350d | ||
|
|
6de466cf8b | ||
|
|
24916f2f6e | ||
|
|
442e49f51c | ||
|
|
3cf19d6dd0 | ||
|
|
759953cb8d | ||
|
|
ddf7ac5ae4 | ||
|
|
06fd3b00ff | ||
|
|
a8e2d851fe | ||
|
|
81f1d625af | ||
|
|
0f5b7814b5 | ||
|
|
5636d38a9d | ||
|
|
12c49fa3bd | ||
|
|
e88b74350f | ||
|
|
1afe9e98de | ||
|
|
c34a79b152 | ||
|
|
d81a5c630f | ||
|
|
0ace779cde | ||
|
|
fe7d9af331 | ||
|
|
9fe43d6acb | ||
|
|
9908681ba8 | ||
|
|
afbf0d42a7 | ||
|
|
7177eeaa42 | ||
|
|
db2412e2ac | ||
|
|
b7398a4918 | ||
|
|
afdef6d122 | ||
|
|
36f8fa316d | ||
|
|
13f1a922e1 | ||
|
|
f947d25c9d | ||
|
|
1de107c405 | ||
|
|
353439acee | ||
|
|
a44024a795 | ||
|
|
15b6774f9b | ||
|
|
382e09bed1 | ||
|
|
5da94182ae | ||
|
|
c83feeb6f8 | ||
|
|
178894b0fe | ||
|
|
4dbbcff72b | ||
|
|
4aa5dd0ee0 | ||
|
|
b6f00a3945 | ||
|
|
abea17afd9 | ||
|
|
f523fddf6a | ||
|
|
99946aaaaf | ||
|
|
5f9ba2f223 | ||
|
|
8084a2c9e6 | ||
|
|
b951f0621c | ||
|
|
28a31201d3 | ||
|
|
99c262b7d0 | ||
|
|
899e629bf0 | ||
|
|
4c6eb6cc2f | ||
|
|
bc27451e15 | ||
|
|
1fbb7f1a41 | ||
|
|
3742f66abb | ||
|
|
3a6beea064 | ||
|
|
e0e9a54a32 | ||
|
|
ec47907772 | ||
|
|
bd1dc89a5d | ||
|
|
fb109ae97d | ||
|
|
66d637be3d | ||
|
|
ba9f47c544 | ||
|
|
9b991a7301 | ||
|
|
0041e40ca8 | ||
|
|
a0998e42b7 | ||
|
|
cf7289662f | ||
|
|
8576ecaf32 | ||
|
|
b3ab39c4d9 | ||
|
|
2e5c49a1fd | ||
|
|
8763bced76 | ||
|
|
c2f88373e7 | ||
|
|
7d5fd5fcd0 | ||
|
|
f6c49cecc1 | ||
|
|
7ba845297f | ||
|
|
733185d0a9 | ||
|
|
d54e990c4f | ||
|
|
fe106842c8 | ||
|
|
41e633acf5 | ||
|
|
1a6e696b08 | ||
|
|
d401340c51 | ||
|
|
d15d54c2c8 | ||
|
|
3f35b5299f | ||
|
|
026ad08b56 | ||
|
|
b342bd0b46 | ||
|
|
c67b702588 | ||
|
|
ddc4512d2e | ||
|
|
3d8efdf310 | ||
|
|
bfe14b5312 | ||
|
|
a15939b502 | ||
|
|
4fbf564292 | ||
|
|
59d1147469 | ||
|
|
e7990375cb | ||
|
|
623e54788e | ||
|
|
3f138dc40c | ||
|
|
63b2547a02 | ||
|
|
9b3ae84993 | ||
|
|
3d2686a236 | ||
|
|
ed971268be | ||
|
|
d413a945ac | ||
|
|
9d58febc8f | ||
|
|
33fbf82ac0 | ||
|
|
1721d1994e | ||
|
|
0ec18e537d | ||
|
|
117737c6ca | ||
|
|
a7ce19347a | ||
|
|
4289a1ebfa | ||
|
|
5d2288b22a | ||
|
|
7a1a01feef | ||
|
|
e6f7180af1 | ||
|
|
ad5a561adb | ||
|
|
4179b42424 | ||
|
|
f691d46a16 | ||
|
|
1bd08f903b | ||
|
|
6270392d04 | ||
|
|
4d9e6ea310 | ||
|
|
05dac2e42c | ||
|
|
6551f4bb3b | ||
|
|
e0add119ea | ||
|
|
e83ebf50de | ||
|
|
40253048ca | ||
|
|
c484c5a2a1 | ||
|
|
4160df4ca4 | ||
|
|
68bebe1fb7 | ||
|
|
76a9e6f27b | ||
|
|
22a8afee9e | ||
|
|
12efb40dc5 | ||
|
|
0f7d39c410 | ||
|
|
b9dc855016 | ||
|
|
5c49e1d0c1 | ||
|
|
e45401846f | ||
|
|
85d7afaefc | ||
|
|
76d6d3641f | ||
|
|
8b804fb589 | ||
|
|
a81685bfac | ||
|
|
c426e485e5 | ||
|
|
27126f8797 | ||
|
|
66b5477cc1 | ||
|
|
226b6a2192 | ||
|
|
7d4b416fe6 | ||
|
|
215d3f8c0d | ||
|
|
b8f2dd8237 | ||
|
|
526e860a7a | ||
|
|
1db6d6fea6 | ||
|
|
48dd250af1 | ||
|
|
44449b305b | ||
|
|
fb0b2cd37a | ||
|
|
30086e504c | ||
|
|
5b8f033e06 | ||
|
|
f55c991a1b | ||
|
|
4117a7ed19 | ||
|
|
b4f95c43fc | ||
|
|
4740ecbeae | ||
|
|
ddfed259f6 | ||
|
|
1b31d148c9 | ||
|
|
6943fbbb81 | ||
|
|
305c832a97 | ||
|
|
61dfbe702e | ||
|
|
23254f59da | ||
|
|
bb7cc8e8fd | ||
|
|
52869ed182 | ||
|
|
19104d592b | ||
|
|
cf7f3a436a | ||
|
|
c41916ee16 | ||
|
|
bb5798aa0e | ||
|
|
27591570c4 | ||
|
|
acacb718e5 | ||
|
|
30f2e8ff29 | ||
|
|
69e980602b | ||
|
|
cbde98f67b | ||
|
|
895f1d93d5 | ||
|
|
eb50e7a2c8 | ||
|
|
6e8f400edc | ||
|
|
a5b29a1250 | ||
|
|
2e5584c2b4 | ||
|
|
060515684d | ||
|
|
c6cdab1f79 | ||
|
|
3ed0973493 | ||
|
|
f68a908c8a | ||
|
|
fed1e384ad | ||
|
|
999c1c771b | ||
|
|
727ce7e4bb | ||
|
|
2627ab322e | ||
|
|
6c94774b70 | ||
|
|
ae297cb487 | ||
|
|
537964b92d | ||
|
|
1bc467fe52 | ||
|
|
6bf033beae | ||
|
|
88eb302221 | ||
|
|
43f292b2e0 | ||
|
|
baf1550227 | ||
|
|
f811127bb6 | ||
|
|
f8cc48a43f | ||
|
|
af38936473 | ||
|
|
0e11036055 | ||
|
|
a24260bb23 | ||
|
|
9436a31603 | ||
|
|
1718420c48 | ||
|
|
68b1fd0cc6 | ||
|
|
d4eeeb5498 | ||
|
|
0f73af876f | ||
|
|
1fd6ca2260 | ||
|
|
2d843b5021 | ||
|
|
fc118e13a9 | ||
|
|
25e128d398 | ||
|
|
93f42d360b | ||
|
|
325cbe90d9 | ||
|
|
d35a9ac5f2 | ||
|
|
1ad7c6b8f8 | ||
|
|
0c7ddae2ab | ||
|
|
5c12230a08 | ||
|
|
bee3e3e28d | ||
|
|
068b8b03ad | ||
|
|
150c9f3fe0 | ||
|
|
697b912f26 | ||
|
|
b9c95937ed | ||
|
|
1a53e79057 | ||
|
|
c84ed36719 | ||
|
|
17e4744459 | ||
|
|
fa68d0a16e | ||
|
|
d9450bfccd | ||
|
|
cc096ae929 | ||
|
|
1f75c98f49 | ||
|
|
aba4438013 | ||
|
|
00cf5fbde6 | ||
|
|
3c10df4f87 | ||
|
|
89c17e44fb | ||
|
|
20d2a31b40 | ||
|
|
c7a0f56c71 | ||
|
|
1921fac814 | ||
|
|
36ab4c7c49 | ||
|
|
7d105738b6 | ||
|
|
5e9412608e | ||
|
|
7a2fed494b | ||
|
|
344a6a6202 | ||
|
|
382222af8e | ||
|
|
9892d80d6f | ||
|
|
c10d83b4df | ||
|
|
a2e0db67cc | ||
|
|
fcb00a4161 | ||
|
|
762fa58ce8 | ||
|
|
cfef0c6658 | ||
|
|
f2ec81cf21 | ||
|
|
20d97eb849 | ||
|
|
ec7f5305b1 | ||
|
|
95e304d111 | ||
|
|
cd14ac0486 | ||
|
|
05ec232f3e | ||
|
|
266918a580 | ||
|
|
95a4cc3bce | ||
|
|
e81a92449e | ||
|
|
7411f21c5f | ||
|
|
2377092a70 | ||
|
|
af25cab11b | ||
|
|
6cb74f4b7d | ||
|
|
fdd368a294 | ||
|
|
3ec7e3c006 | ||
|
|
9715c61de0 | ||
|
|
e76d44a640 | ||
|
|
373b13b240 | ||
|
|
fe4e9470bb | ||
|
|
29763d006a | ||
|
|
f4648c1ca1 | ||
|
|
9f045787a5 | ||
|
|
ce1ec90fcc | ||
|
|
28e0658fa9 | ||
|
|
96538b489b | ||
|
|
4a6eca5bd7 | ||
|
|
fe4ef307b7 | ||
|
|
87be2da4e1 | ||
|
|
2b9f8ae485 | ||
|
|
88bd5b15ff | ||
|
|
5849c950d0 | ||
|
|
0c7895076e | ||
|
|
bc4f725820 | ||
|
|
975aa3ccd6 | ||
|
|
55d472a9fe | ||
|
|
eb8e76d433 | ||
|
|
ba9f32b464 | ||
|
|
0509be0740 | ||
|
|
0d84fdd953 | ||
|
|
c5443da2d3 | ||
|
|
5f2bfd9807 | ||
|
|
e7de2fe552 | ||
|
|
65e4c57d3a | ||
|
|
a9d501e975 | ||
|
|
97417a1813 | ||
|
|
7abdfbe20e | ||
|
|
7a02910feb | ||
|
|
dd8ba0b5a8 | ||
|
|
36976ce5e6 | ||
|
|
bac7a68023 | ||
|
|
fc70ac4d59 | ||
|
|
fb4585bbe0 | ||
|
|
61f231a496 | ||
|
|
55fdaab365 | ||
|
|
1cedf78284 | ||
|
|
23fdbc9ea6 | ||
|
|
394589d493 | ||
|
|
d3546cc85c | ||
|
|
447ead940e | ||
|
|
7b9c0ced21 | ||
|
|
fb1c929dc6 | ||
|
|
819ad1a007 | ||
|
|
d303e55258 | ||
|
|
3b833a0c01 | ||
|
|
6bf2a43e67 | ||
|
|
5391342b08 | ||
|
|
9a4b45dc0f | ||
|
|
ad2532c3f4 | ||
|
|
075c086d29 | ||
|
|
7b8dcbaa86 | ||
|
|
75b2c1693e | ||
|
|
1394420c37 | ||
|
|
ec82fcdfea | ||
|
|
5658b628b9 | ||
|
|
b429a00cce | ||
|
|
410ccce4a3 | ||
|
|
312a7a1e62 | ||
|
|
ed598e9fe1 | ||
|
|
fa97b0a95b | ||
|
|
3dfc79fb09 | ||
|
|
5fc5c03dad | ||
|
|
0d6de44a37 | ||
|
|
81f78f0da7 | ||
|
|
c38e0a4bbc | ||
|
|
1f0b317088 | ||
|
|
6c35d17800 | ||
|
|
df0983af39 | ||
|
|
fa81d838da | ||
|
|
45d62482da | ||
|
|
bcb41a09b3 | ||
|
|
9e2fbb31ec | ||
|
|
985504ff2c | ||
|
|
e304673c65 | ||
|
|
b8a102d26f | ||
|
|
d980d965dd | ||
|
|
f0239a8fe9 | ||
|
|
2e4503ad4e | ||
|
|
54ea8f74ae | ||
|
|
e647eeb0c9 | ||
|
|
26945d7956 | ||
|
|
c7851e0ee7 | ||
|
|
a011b67f56 | ||
|
|
c3f93e7178 | ||
|
|
931b1c6d59 | ||
|
|
e9d369a09e | ||
|
|
6adf561507 | ||
|
|
95adc0e6ba | ||
|
|
02753ba9ea | ||
|
|
acc1090e77 | ||
|
|
fc864529f5 | ||
|
|
782dd941da | ||
|
|
ba8290aeae | ||
|
|
4f6bc0a0a9 | ||
|
|
f7c8f1ae29 | ||
|
|
ba97ae1737 | ||
|
|
7669cfb330 | ||
|
|
bc0c9c7920 | ||
|
|
07c23ccc05 | ||
|
|
2130a07b70 | ||
|
|
26f899be10 | ||
|
|
bdb8bb790e | ||
|
|
8760f877e1 | ||
|
|
97882f9ce2 | ||
|
|
5fce21728e | ||
|
|
fa64b89ad7 | ||
|
|
49e9f93738 | ||
|
|
8028560f82 | ||
|
|
225a384dbb | ||
|
|
404379049a | ||
|
|
2a1bb91bf7 | ||
|
|
a33bb3e876 | ||
|
|
8cf1504ba6 | ||
|
|
427b820426 | ||
|
|
1d6bd50343 | ||
|
|
ca29dc9abc | ||
|
|
dc42c35f1f | ||
|
|
b5b5221c13 | ||
|
|
995af0e2b7 | ||
|
|
5d21faa99c | ||
|
|
c9815307eb | ||
|
|
506adf3764 | ||
|
|
d551ab8e5c | ||
|
|
68d797587e | ||
|
|
ea9873e60e | ||
|
|
cfb78654c2 | ||
|
|
051cf5437a | ||
|
|
311be04d61 | ||
|
|
5e59c301b7 | ||
|
|
7e67db79dc | ||
|
|
f84d32ca5e | ||
|
|
5dd0e82809 | ||
|
|
2a1f27eb1a | ||
|
|
e15a8a7c46 | ||
|
|
ed65535c41 | ||
|
|
60cbdf9ccd | ||
|
|
5083e93957 | ||
|
|
f2ec911b8a | ||
|
|
c83d6ee0b1 | ||
|
|
83c96d2685 | ||
|
|
58b3d66229 | ||
|
|
bdbec099cc | ||
|
|
2ad9caad3f | ||
|
|
a337403868 | ||
|
|
e0cae08c04 | ||
|
|
99e9a4c786 | ||
|
|
7c94dae702 | ||
|
|
021c64310d | ||
|
|
8eb1a7d5dc | ||
|
|
f7a6482e6b | ||
|
|
909b737289 | ||
|
|
e5caf64815 | ||
|
|
ac9778395f | ||
|
|
1a33ea9671 | ||
|
|
9d88d82d5e | ||
|
|
6f417ec943 | ||
|
|
56d097cfe0 | ||
|
|
6ab17e3e15 | ||
|
|
12da13c9d1 | ||
|
|
d5999f8b5c | ||
|
|
bc6137f9e4 | ||
|
|
a585a1b81a | ||
|
|
a3129fd4e8 | ||
|
|
5caec3020d | ||
|
|
f4adcfa0e2 | ||
|
|
ecfeee2e82 | ||
|
|
899bee0056 | ||
|
|
00da99f2c4 | ||
|
|
72948d9f1d | ||
|
|
66d1193a00 | ||
|
|
fd47084224 | ||
|
|
d37a580085 | ||
|
|
50f8ead4e6 | ||
|
|
9f5aca62a9 | ||
|
|
9b7697db62 | ||
|
|
208e2dad1e | ||
|
|
ae5ddfdc1a | ||
|
|
ff599f4004 | ||
|
|
9d191a6093 | ||
|
|
4a4daf1303 | ||
|
|
92f187d1c2 | ||
|
|
845a664bb2 | ||
|
|
5ed17e84fa | ||
|
|
6a50cf89b4 | ||
|
|
39cf9c9d31 | ||
|
|
5a5db02b85 | ||
|
|
38cc1a1843 | ||
|
|
2a6b215328 | ||
|
|
88bc8f3528 | ||
|
|
f2be3ad46f | ||
|
|
2a3456cd3b | ||
|
|
bd5918760e | ||
|
|
4909a70174 | ||
|
|
d7e11d0af7 | ||
|
|
01831da5f5 | ||
|
|
af8134a6ff | ||
|
|
a988c36ccb | ||
|
|
e0f26dcda3 | ||
|
|
8f671d3eef | ||
|
|
3182728b70 | ||
|
|
5862f59ed7 | ||
|
|
1f94274b92 | ||
|
|
d2fb0efcd1 | ||
|
|
dbfce2a4d8 | ||
|
|
98994a8bb1 | ||
|
|
b580a55191 | ||
|
|
ff16836d1d | ||
|
|
5411033f66 | ||
|
|
8383409e88 | ||
|
|
d20a3ef57c | ||
|
|
bac8c72381 | ||
|
|
b9563340b7 | ||
|
|
8ae9329aa8 | ||
|
|
0417f1f2be | ||
|
|
4d5cab4085 | ||
|
|
3cdb2f0bb7 | ||
|
|
66bad2e979 | ||
|
|
7236838dea | ||
|
|
eb5ee80c74 | ||
|
|
a785a7f700 | ||
|
|
742976893e | ||
|
|
1d331c7e62 | ||
|
|
9fe8b28746 | ||
|
|
6a2ca34216 | ||
|
|
3b83bda29c | ||
|
|
a1bc339340 | ||
|
|
260de2cb5e | ||
|
|
890d8da2e3 | ||
|
|
ac8678aefe | ||
|
|
62d3af17f9 | ||
|
|
3ff46b2e43 | ||
|
|
dca93c56e0 | ||
|
|
73e30cbda8 | ||
|
|
c18fbefe93 | ||
|
|
c913fb99b6 | ||
|
|
8976dac9e0 | ||
|
|
bef217b241 | ||
|
|
1e2df2d464 | ||
|
|
9fd3318dd8 | ||
|
|
4e3015a892 | ||
|
|
bdbbd9711c | ||
|
|
9cccb8c115 | ||
|
|
4ec61bef46 | ||
|
|
0a2ef2b932 | ||
|
|
7b085136a7 | ||
|
|
534f9e3ab1 | ||
|
|
b32ce34cf2 | ||
|
|
3f47ff6ecd | ||
|
|
2adf3f42ee | ||
|
|
b642b3c8e3 | ||
|
|
d63de1e407 | ||
|
|
32e510bd70 | ||
|
|
28e72ae34d | ||
|
|
01a2ddf3f8 | ||
|
|
4fcc02ee9d | ||
|
|
78a00c845c | ||
|
|
2c482939fd | ||
|
|
933929cd62 | ||
|
|
40fefe2cbc | ||
|
|
fce56c56ef | ||
|
|
374e273df5 | ||
|
|
cf688db4b5 | ||
|
|
98967c5ec9 | ||
|
|
45b4e337cb | ||
|
|
82760a9960 | ||
|
|
c15487318b | ||
|
|
a58eaec540 | ||
|
|
7fe8edc396 | ||
|
|
8b4b3ff4fc | ||
|
|
577c0e3e5a | ||
|
|
5a5b950e8b | ||
|
|
f8a1f8843c | ||
|
|
9bba26f8c5 | ||
|
|
8fa822b521 | ||
|
|
64571368dc | ||
|
|
93742ed5df | ||
|
|
a77960c540 | ||
|
|
4b703d3049 | ||
|
|
ca5e6bf5f2 | ||
|
|
44cad8f4ed | ||
|
|
d0505fd042 | ||
|
|
349a62ed4f | ||
|
|
775fb562bd | ||
|
|
1686a15fb6 | ||
|
|
661d0dfac9 | ||
|
|
8213558cc7 | ||
|
|
a582b62287 | ||
|
|
bb820fa761 | ||
|
|
14d90e4901 | ||
|
|
3db0d50df4 | ||
|
|
f12d7f0d4b | ||
|
|
205d15e82d | ||
|
|
7b4b78b419 | ||
|
|
7b749eff35 | ||
|
|
f401791a56 | ||
|
|
dab63b029e | ||
|
|
64333e3ef8 | ||
|
|
c56b81a2ce | ||
|
|
23266e8e09 | ||
|
|
31d880f751 | ||
|
|
908e6bb68f | ||
|
|
276ca5f04c | ||
|
|
c4893d8efd | ||
|
|
1016f112bf | ||
|
|
b7397bf413 | ||
|
|
45a10dde95 | ||
|
|
88aa1c8dc3 | ||
|
|
e2917b2627 | ||
|
|
3df4959f51 | ||
|
|
531869bd92 | ||
|
|
c5689a5a40 | ||
|
|
a7027ed8e5 | ||
|
|
e71a915412 | ||
|
|
b2f19c9d06 | ||
|
|
f2d03f4fdd | ||
|
|
4f88344df3 | ||
|
|
a209ea3953 | ||
|
|
1da7475d0e | ||
|
|
d6daf37df4 | ||
|
|
5f483499f3 | ||
|
|
0cc812ae34 | ||
|
|
c41673f3fa | ||
|
|
1b86f520ea | ||
|
|
a0f3999ce7 | ||
|
|
69e0b8326a | ||
|
|
333da3b64b | ||
|
|
7062b0e65d | ||
|
|
f2e4aa8d1c | ||
|
|
00c34df186 | ||
|
|
35fd6d134a | ||
|
|
6f3475c6c7 | ||
|
|
005e462e01 | ||
|
|
dcdccf8333 | ||
|
|
e9b58d9de4 | ||
|
|
896581628d | ||
|
|
5577535891 | ||
|
|
696826913c | ||
|
|
455284f1c0 | ||
|
|
c975de2e07 | ||
|
|
ba7fb49fb9 | ||
|
|
b0a99e85b6 | ||
|
|
abb4e9e2fa | ||
|
|
17f6c3be8e | ||
|
|
01defc9f49 | ||
|
|
e8bb385d6d | ||
|
|
45f3cea263 | ||
|
|
a5e4d3a2d8 | ||
|
|
bf9c933cae | ||
|
|
da1f6fc2c8 | ||
|
|
44657bf932 | ||
|
|
67c3a014b9 | ||
|
|
07b0ea03c3 | ||
|
|
147b5ae514 | ||
|
|
9952201ca7 | ||
|
|
17c2c4219d | ||
|
|
3fc001d0a2 | ||
|
|
9c69a79f9a | ||
|
|
640c6fdd5f | ||
|
|
380a1ea8ef | ||
|
|
b85be36d1c | ||
|
|
54a3ed751e | ||
|
|
a22fe33aa0 | ||
|
|
e95df0bc39 | ||
|
|
c582f7d177 | ||
|
|
ca29903c82 | ||
|
|
e65306d8e7 | ||
|
|
c14fb5b633 | ||
|
|
ad437f13d5 | ||
|
|
4681415a15 | ||
|
|
7930cb54c0 | ||
|
|
91f53d590b | ||
|
|
3e0d31c4e9 | ||
|
|
4acc8d0ff5 | ||
|
|
3faa51a0ca | ||
|
|
3034a71488 | ||
|
|
2e2b8a95bd | ||
|
|
26a55ddcf9 | ||
|
|
1a4ddfa8a7 | ||
|
|
5383b047d1 | ||
|
|
14da999408 | ||
|
|
63a3fd3c0f | ||
|
|
8c39813665 | ||
|
|
3ebcf25149 | ||
|
|
a05c27a7e1 | ||
|
|
6bc3902f5d | ||
|
|
c2c2d44c72 | ||
|
|
515dfea4b7 | ||
|
|
31fd071faa | ||
|
|
0bfa615997 | ||
|
|
60ca29df64 | ||
|
|
35f582583a | ||
|
|
ddbc4a0f6c | ||
|
|
1f4a5b5dfe | ||
|
|
076034345a | ||
|
|
af2d48f4d2 | ||
|
|
8c8cddbe02 | ||
|
|
bbdc08780c | ||
|
|
174a2ad731 | ||
|
|
7c78b2b756 | ||
|
|
310f0a960c | ||
|
|
6c3ade76df | ||
|
|
487285b325 | ||
|
|
9c601ebde8 | ||
|
|
0273d809d0 | ||
|
|
e0527d7731 | ||
|
|
a204595e4c | ||
|
|
cf89abb013 | ||
|
|
c06c14fb29 | ||
|
|
716550021e | ||
|
|
f199fb6a2b | ||
|
|
f69e09a67e | ||
|
|
241fd72f75 | ||
|
|
5b13dafbab | ||
|
|
7340d5adfd | ||
|
|
7120ab2f16 | ||
|
|
695a591f8e | ||
|
|
03d7dba5d8 | ||
|
|
20c3adca41 | ||
|
|
28f23f18e9 | ||
|
|
b0372840e7 | ||
|
|
2a62917444 | ||
|
|
69ea6b9373 | ||
|
|
ed17760a52 | ||
|
|
ddb2d1221b | ||
|
|
06d4553a15 | ||
|
|
1caebaa49a | ||
|
|
7e9b87f396 | ||
|
|
dc66795e35 | ||
|
|
d6d05883ad | ||
|
|
d5f223a3fe | ||
|
|
983357603a | ||
|
|
6b709e655e | ||
|
|
c624382929 | ||
|
|
8b5d5dca9f | ||
|
|
a3bce7a322 | ||
|
|
c1d0b6a6ee | ||
|
|
232a0ffc34 | ||
|
|
ecb257f0ef | ||
|
|
d1b73be6e1 | ||
|
|
a4b4b29987 | ||
|
|
57ad1f6ddf | ||
|
|
54bd761286 | ||
|
|
b5d789a531 | ||
|
|
166aa97f75 | ||
|
|
d47789620b | ||
|
|
16ee4de5df | ||
|
|
4afe26fa82 | ||
|
|
62bb6e37e0 | ||
|
|
216ddf3da5 | ||
|
|
8da6de3e66 | ||
|
|
74b958ecbe | ||
|
|
af16ce6ad9 | ||
|
|
16efa84838 | ||
|
|
901c2eb20a | ||
|
|
ede0f2f633 | ||
|
|
a3de5dbab1 | ||
|
|
ef35c9f765 | ||
|
|
66c4ed98d6 | ||
|
|
eb1084754c | ||
|
|
79e5b62907 | ||
|
|
1fd756066c | ||
|
|
cfabe30bec | ||
|
|
5af2f68a2c | ||
|
|
67ee995cc1 | ||
|
|
fe536457cc | ||
|
|
76688d2040 | ||
|
|
aceae73b9a | ||
|
|
82326dcbe2 | ||
|
|
6c10fc659a | ||
|
|
38e3baab2a | ||
|
|
8121127606 | ||
|
|
a45164f2e0 | ||
|
|
2ebef95994 | ||
|
|
93b946ee50 | ||
|
|
66a2720c56 | ||
|
|
364a885b0c | ||
|
|
fa3d4fab85 | ||
|
|
69a2d46ee5 | ||
|
|
952ba84611 | ||
|
|
83157c02d6 | ||
|
|
2a836bc306 | ||
|
|
2c6ea705fd | ||
|
|
6a539c00df | ||
|
|
c6e9160c67 | ||
|
|
dd92b6e83d | ||
|
|
29f2120e5b | ||
|
|
cb89f2f2a1 | ||
|
|
b87dc608d9 | ||
|
|
5047670693 | ||
|
|
52bbac506c | ||
|
|
373ef850e0 | ||
|
|
b569585000 | ||
|
|
b9f0571780 | ||
|
|
b5aaefc727 | ||
|
|
5267ce8ff4 | ||
|
|
b7861f34ba | ||
|
|
73bd816076 | ||
|
|
d9b3133321 | ||
|
|
5f122af556 | ||
|
|
983ebb2689 | ||
|
|
55b8d74561 | ||
|
|
e2100c5f5f | ||
|
|
486421ceff | ||
|
|
b0940bdf54 | ||
|
|
f957db81d9 | ||
|
|
ed2a486f46 | ||
|
|
f6a0f8730e | ||
|
|
84eabb2658 | ||
|
|
57cc4d45d5 | ||
|
|
675def0396 | ||
|
|
6419f66523 | ||
|
|
75d10058a4 | ||
|
|
18d4802a7b | ||
|
|
b6618b631b | ||
|
|
31c027a37a | ||
|
|
ee9f708500 | ||
|
|
031d7ce840 | ||
|
|
25faca41eb | ||
|
|
fc58e44f89 | ||
|
|
ce20572ace | ||
|
|
2ffbd5b5f0 | ||
|
|
429f86397b | ||
|
|
3219e0314e | ||
|
|
65b45c9c32 | ||
|
|
58b659a26e | ||
|
|
f5357ed940 | ||
|
|
778612d152 | ||
|
|
46aa92420a | ||
|
|
6447404cc2 | ||
|
|
13b7fd82c1 | ||
|
|
3c9b8a28c6 | ||
|
|
736d8350e9 | ||
|
|
73b4d098ce | ||
|
|
5ec3621101 | ||
|
|
a568aaa0c0 | ||
|
|
b254115acd | ||
|
|
ff18787b2c | ||
|
|
d33adc4fd0 | ||
|
|
e4cdc9fa0b | ||
|
|
669059aa19 | ||
|
|
18a64ad52d | ||
|
|
92af3766ec | ||
|
|
dedd9edf7f | ||
|
|
d4ce210713 | ||
|
|
e6facdcb0c | ||
|
|
96dcbe217b | ||
|
|
e45f42db29 | ||
|
|
bad8d0fd20 | ||
|
|
b886393042 | ||
|
|
3192178f15 | ||
|
|
8c96e2a6d9 | ||
|
|
5ffb869e1a | ||
|
|
bed3069fd7 | ||
|
|
dcc28434f4 | ||
|
|
8dcea2cc14 | ||
|
|
4e637b1b61 | ||
|
|
07aef38591 | ||
|
|
e45d624df2 | ||
|
|
c7374c31c4 | ||
|
|
81069f66f9 | ||
|
|
38d4d69639 | ||
|
|
6308c48efd | ||
|
|
cc768d77ec | ||
|
|
73f9f0334c | ||
|
|
28c33f67bc | ||
|
|
235e0bd65a | ||
|
|
9a0ce98c54 | ||
|
|
b298478435 | ||
|
|
78723af99f | ||
|
|
8b8a007e8e | ||
|
|
8abcea18a2 | ||
|
|
0ef3e28609 | ||
|
|
f557c7d8ca | ||
|
|
b43b13faf9 | ||
|
|
164ba041c9 | ||
|
|
86018a3947 | ||
|
|
85120b37ea | ||
|
|
21a2ccc5f1 | ||
|
|
84f0622c85 | ||
|
|
a584e11d6b | ||
|
|
0ff335961e | ||
|
|
021cdbe1c0 | ||
|
|
9fdc3a069a | ||
|
|
d96ab34019 | ||
|
|
37005d04a9 | ||
|
|
29c29e7717 | ||
|
|
48a46e066e | ||
|
|
ba665e24e3 | ||
|
|
dca084e703 | ||
|
|
bbc0898060 | ||
|
|
0ff172fabf | ||
|
|
a412dd616f | ||
|
|
02a848d77c | ||
|
|
7acc4addb5 | ||
|
|
c4e811e519 | ||
|
|
a5c55e4393 | ||
|
|
ed6c036ee3 | ||
|
|
55b96a5bd5 | ||
|
|
1cb073d48e | ||
|
|
641a9cd3f5 | ||
|
|
10e90ae01f | ||
|
|
8c93b768e4 | ||
|
|
b0782df8a6 | ||
|
|
f7598b8a26 | ||
|
|
2f586905fc | ||
|
|
4219939c10 | ||
|
|
6b2129696f | ||
|
|
dc0d34e137 | ||
|
|
83a70172a4 | ||
|
|
4a6c06d6a9 | ||
|
|
02e348c069 | ||
|
|
a863834574 | ||
|
|
1de74e27e5 | ||
|
|
d058e963fd | ||
|
|
13808ccede | ||
|
|
a3edfd9e84 | ||
|
|
75b70be4a6 | ||
|
|
b67db455a8 | ||
|
|
2c29b3e82c | ||
|
|
8fcac1b794 | ||
|
|
75061cb45d | ||
|
|
20598dff25 | ||
|
|
0b22d574e0 | ||
|
|
1df39aa962 | ||
|
|
9d80ad16f9 | ||
|
|
c0a790453c | ||
|
|
dbc5d7b331 | ||
|
|
3ed03df23f | ||
|
|
32bc8f4dd4 | ||
|
|
d2b35e19cd | ||
|
|
89131c3e90 | ||
|
|
fc2fb0eb95 | ||
|
|
dfd72f5250 | ||
|
|
11ae6d16e5 | ||
|
|
09bcbc57da | ||
|
|
1c3e1bae41 | ||
|
|
3821ca4917 | ||
|
|
7bf5d4b946 | ||
|
|
a3c6172495 | ||
|
|
b675e6b2d5 | ||
|
|
58b50fb543 | ||
|
|
7712e6f82b | ||
|
|
7e067cb9dc | ||
|
|
c39dfb17ae | ||
|
|
2a8c2648f0 | ||
|
|
74c755f2ab | ||
|
|
a55e569af5 | ||
|
|
beffdf6575 | ||
|
|
379400cfa6 | ||
|
|
f538f2ae9b | ||
|
|
7140cce7f3 | ||
|
|
1ec93570bf | ||
|
|
2c53b23d59 | ||
|
|
4123d69b51 | ||
|
|
35d21be19a | ||
|
|
beb0c01c27 | ||
|
|
00471dc783 | ||
|
|
3f4ee98162 | ||
|
|
37ae8a9e0f | ||
|
|
ec34439f9c | ||
|
|
e958db09a7 | ||
|
|
b833fabeb2 | ||
|
|
44364d7112 | ||
|
|
4165ed96f8 | ||
|
|
c11f628342 | ||
|
|
504b97b6a4 | ||
|
|
92faa2eaeb | ||
|
|
592cb73a69 | ||
|
|
74b2c40b1b | ||
|
|
a538141a72 | ||
|
|
c4a4bd6ac5 | ||
|
|
879de25583 | ||
|
|
d174b9cfcc | ||
|
|
8e9b6e0948 | ||
|
|
63b7a031a5 | ||
|
|
1282bb81fe | ||
|
|
7becf326e3 | ||
|
|
73c871ba0a | ||
|
|
b6be03f01a | ||
|
|
0b39e6427f | ||
|
|
6525ca5158 | ||
|
|
e362d42dc6 | ||
|
|
f10d3675f8 | ||
|
|
31b1ab4852 | ||
|
|
33a585c47f | ||
|
|
672df72b71 | ||
|
|
c0cf4843e5 | ||
|
|
69b8f100b7 | ||
|
|
7382ba82c5 | ||
|
|
8794562a85 | ||
|
|
31ab5caa35 | ||
|
|
1ed5326f5a | ||
|
|
ab5f9ab55b | ||
|
|
dc2adc6bc1 | ||
|
|
7981e653d8 | ||
|
|
bc9198072b | ||
|
|
e88c48ce0e | ||
|
|
f54f3e2abe | ||
|
|
bb210ce773 | ||
|
|
e36fab2f70 | ||
|
|
14d8cd6445 | ||
|
|
094a047ddf | ||
|
|
771744426e | ||
|
|
3eb40a520a | ||
|
|
7d98c51805 | ||
|
|
c2bc84aa4d | ||
|
|
b7777e7ef3 | ||
|
|
91f6347485 | ||
|
|
94a8ef1cae | ||
|
|
95195f5258 | ||
|
|
a70762c9b5 | ||
|
|
5bd5c9c84e | ||
|
|
72e9ebf2ec | ||
|
|
05e7fbd60f | ||
|
|
1d1208e335 | ||
|
|
a568b9cadc | ||
|
|
07dfdb974d | ||
|
|
6dbd63ba4f | ||
|
|
d23af6cca0 | ||
|
|
56e1132db4 | ||
|
|
aeedb464a6 | ||
|
|
583b4ab72b | ||
|
|
5a2d0533a8 | ||
|
|
a5a873dccc | ||
|
|
ab73997cc5 | ||
|
|
9a453dd354 | ||
|
|
8d66f4fba4 | ||
|
|
89e80cabd5 | ||
|
|
0a88377086 | ||
|
|
3909aff06a | ||
|
|
69f292a90e | ||
|
|
93b2871cab | ||
|
|
7a72eff4a4 | ||
|
|
d16b640fe8 | ||
|
|
0e7219d437 | ||
|
|
d1337053b6 | ||
|
|
4cf4302962 | ||
|
|
1f404f6a23 | ||
|
|
bc3786ece9 | ||
|
|
0610f44380 | ||
|
|
07d93db427 | ||
|
|
bded743706 | ||
|
|
3497843f02 | ||
|
|
b25dc423b0 | ||
|
|
0fd9a97202 | ||
|
|
6f587570ed | ||
|
|
acb8248ba6 | ||
|
|
8101f1ef16 | ||
|
|
bbac2aee1f | ||
|
|
bf635e7741 | ||
|
|
ee123c2489 | ||
|
|
24c8f523eb | ||
|
|
aaad44bbe7 | ||
|
|
370cf75458 | ||
|
|
4a7587931c | ||
|
|
eec27f9257 | ||
|
|
f922920609 | ||
|
|
0cd55eb1e7 | ||
|
|
009a5e4213 | ||
|
|
6920be311b | ||
|
|
3aa72b42b2 | ||
|
|
02df86079b | ||
|
|
5e956f1148 | ||
|
|
cd9ccbc1e9 | ||
|
|
7536d690fd | ||
|
|
b8aec17af1 | ||
|
|
f4196138ce | ||
|
|
fe1aa9299e | ||
|
|
568f5ef3c6 | ||
|
|
bafe6f5a7c | ||
|
|
be6dc83277 | ||
|
|
c2bbaab2ac | ||
|
|
ffb83d23e1 | ||
|
|
4d05d88304 | ||
|
|
9ae2284726 | ||
|
|
b4750e4c35 | ||
|
|
1b2c62afe9 | ||
|
|
f28032b031 | ||
|
|
52756fb3c5 | ||
|
|
cb018a4212 | ||
|
|
833fe5bdee | ||
|
|
313f2263f8 | ||
|
|
8d94bb67ab | ||
|
|
03758a50dc | ||
|
|
83a8e1fd20 | ||
|
|
90bf7026f6 | ||
|
|
f1e68bfdd2 | ||
|
|
4946f74253 | ||
|
|
e5d9ceff18 | ||
|
|
c9642ee213 | ||
|
|
4e03239d1f | ||
|
|
144025e3e6 | ||
|
|
93c3fb78a3 | ||
|
|
51233d8b2a | ||
|
|
adcc71d4d5 | ||
|
|
68429cd0d3 | ||
|
|
c38f0d85da | ||
|
|
f9c7f9a17a | ||
|
|
16bdd970dc | ||
|
|
d451502676 | ||
|
|
df6488a470 | ||
|
|
776eef49d8 | ||
|
|
6e764fb53e | ||
|
|
86207ee676 | ||
|
|
66e8811c64 | ||
|
|
a9644c1f8b | ||
|
|
8a8e2eb04a | ||
|
|
da72a0b7a8 | ||
|
|
aae2b7aa89 | ||
|
|
fee096a406 | ||
|
|
be0ad01b7c | ||
|
|
daea0e4fff | ||
|
|
cc1bc9717c | ||
|
|
9cb5afe114 | ||
|
|
2a9a75a569 | ||
|
|
5f8138faf5 | ||
|
|
160e3e2be3 | ||
|
|
d88c381ce9 | ||
|
|
f495b150fa | ||
|
|
3771ab7c67 | ||
|
|
7a0c94b28a | ||
|
|
32f1ceddc9 | ||
|
|
ccbe2545d9 | ||
|
|
54ca7b230d | ||
|
|
575fd1e322 | ||
|
|
e52d791212 | ||
|
|
c8bf8ee931 | ||
|
|
c403bfc894 | ||
|
|
a3612a5472 | ||
|
|
3e8efcc555 | ||
|
|
e0929262db | ||
|
|
7cc4706646 | ||
|
|
d37f266524 | ||
|
|
bd803e82e9 | ||
|
|
f9308bc244 | ||
|
|
7697f5aa8f | ||
|
|
4429941668 | ||
|
|
fc05bf255a | ||
|
|
8f1302282b | ||
|
|
c6129f9c09 | ||
|
|
747cab4281 | ||
|
|
3c12b477d3 | ||
|
|
d2c9168954 | ||
|
|
218b181985 | ||
|
|
7445d303e0 | ||
|
|
6ca8c58462 | ||
|
|
e4bf1e5128 | ||
|
|
79f52825b5 | ||
|
|
d24c9d7d3e | ||
|
|
35ffd093d7 | ||
|
|
10a9440055 | ||
|
|
b496b1fe11 | ||
|
|
428b51e031 | ||
|
|
abfb9656ef | ||
|
|
68cb1c0e6b | ||
|
|
a02c2e55c0 | ||
|
|
85671a5bed | ||
|
|
201036ad80 | ||
|
|
65257b8e9b | ||
|
|
696b5a628f | ||
|
|
562af864bd | ||
|
|
0a1a88d63c | ||
|
|
4c42381410 | ||
|
|
900f6fc17e | ||
|
|
30bacf6f30 | ||
|
|
8a5ceac3a9 | ||
|
|
f5bc85591a | ||
|
|
7afe417a60 | ||
|
|
45dfc5a074 | ||
|
|
f0b69c7711 | ||
|
|
e44bdcce4c | ||
|
|
2e8f6805eb | ||
|
|
a77355b6bf | ||
|
|
a27ba6e380 | ||
|
|
77efcf8bdd | ||
|
|
6610e89689 | ||
|
|
d306bbe11e | ||
|
|
c011446e78 | ||
|
|
b6aef2490f | ||
|
|
2f19df09b1 | ||
|
|
931c17ed4f | ||
|
|
24d9dc518d | ||
|
|
045d0c3b9f | ||
|
|
a54b0055f6 | ||
|
|
304f86cdbb | ||
|
|
2874a431c0 | ||
|
|
5e7f1b9f0a | ||
|
|
16670410ca | ||
|
|
054a825ee2 | ||
|
|
b2224947fa | ||
|
|
4d53fd98a6 | ||
|
|
21062d74d5 | ||
|
|
938d91d2c3 | ||
|
|
93fe1b8659 | ||
|
|
9bda7e881a | ||
|
|
8a473b5757 | ||
|
|
733cea8847 | ||
|
|
4e956d545a | ||
|
|
e075198049 | ||
|
|
2b79d36652 | ||
|
|
29d20a55b6 | ||
|
|
f518a077b1 | ||
|
|
72797074f3 | ||
|
|
fab8ca0737 | ||
|
|
0e23ab4cce | ||
|
|
92997b781a | ||
|
|
a131b82e95 | ||
|
|
1ac96200a7 | ||
|
|
fd3b7f3572 | ||
|
|
b8b00aad5d | ||
|
|
8e4ae12b4d | ||
|
|
2056a9ef9e | ||
|
|
c5253ad8f7 | ||
|
|
2b67907176 | ||
|
|
f117c7d94a | ||
|
|
d1f939cede | ||
|
|
1aae53596d | ||
|
|
54782af616 | ||
|
|
61605c6883 | ||
|
|
f8481f93c5 | ||
|
|
cddf50b715 | ||
|
|
0c5ed177c4 | ||
|
|
814e40522c | ||
|
|
1544c688e6 | ||
|
|
8049baf0bd | ||
|
|
8d0819bff1 | ||
|
|
c8efffb4db | ||
|
|
19cb0a1a92 | ||
|
|
00ac1af43f | ||
|
|
fd9a53b4a4 | ||
|
|
a94696defa | ||
|
|
77f582ff13 | ||
|
|
f5973b7776 | ||
|
|
21ade85f24 | ||
|
|
74becbfd6f | ||
|
|
193b6bcf36 | ||
|
|
7160b8c2d5 | ||
|
|
191f695bad | ||
|
|
58c97695c9 | ||
|
|
53cbae544f | ||
|
|
b2e791b574 | ||
|
|
92af7f5901 | ||
|
|
bae95844d7 | ||
|
|
b3e8d440ed | ||
|
|
b1a06ef22e | ||
|
|
3dbacbb62b | ||
|
|
f4ffaf5a7f | ||
|
|
353d1825d5 | ||
|
|
94ccc6aeaa | ||
|
|
189017c078 | ||
|
|
540f0b3e45 | ||
|
|
6369ea10d7 | ||
|
|
ea5a223a2e | ||
|
|
5b2c8156d5 | ||
|
|
afb4dbd465 | ||
|
|
b096ad9f22 | ||
|
|
40cb4cb086 | ||
|
|
3f54c9292f | ||
|
|
bec6c807cd | ||
|
|
953c3ef47a | ||
|
|
7ab2690be8 | ||
|
|
12e9c974fa | ||
|
|
024846b4d8 | ||
|
|
64613b9d41 | ||
|
|
806520f025 | ||
|
|
a5d4b7f3d9 | ||
|
|
248ad8bdb2 | ||
|
|
f194f103a2 | ||
|
|
3e27be353d | ||
|
|
c3b2e5eed3 | ||
|
|
ada75af199 | ||
|
|
bce952777a | ||
|
|
2e98c9057d | ||
|
|
2740490e27 | ||
|
|
877bdb46ed | ||
|
|
ebc5cb447f | ||
|
|
992ef70fb6 | ||
|
|
5acee1c04e | ||
|
|
871b83cbab | ||
|
|
14a96df9ee | ||
|
|
e5d85c6c3c | ||
|
|
4abc8f717a | ||
|
|
8e1cef4040 | ||
|
|
a47d2397df | ||
|
|
b8bda67f30 | ||
|
|
73c5a487c1 | ||
|
|
57c514d2f8 | ||
|
|
0c99c7dbff | ||
|
|
acef311fe3 | ||
|
|
8824dae6f7 | ||
|
|
252a7373d6 | ||
|
|
82f3e0e9e6 | ||
|
|
8880bdb67c | ||
|
|
806d5dcb17 | ||
|
|
b52b40b2bc | ||
|
|
d9960b2d4d | ||
|
|
3c06bec03f | ||
|
|
ee19d304ff | ||
|
|
48478ea0a9 | ||
|
|
7bdb675469 | ||
|
|
f155316be7 | ||
|
|
dca7d1c0fd | ||
|
|
1704d4a6b7 | ||
|
|
46593e7aa2 | ||
|
|
fcdae6925a | ||
|
|
0e4d1d8493 | ||
|
|
b11de5adc7 | ||
|
|
9368914ee7 | ||
|
|
175f215187 | ||
|
|
18cb135218 | ||
|
|
04f469a324 | ||
|
|
26c42ad1e4 | ||
|
|
77603c4f2d | ||
|
|
7019f77c05 | ||
|
|
9880114aff | ||
|
|
3625bcba24 | ||
|
|
b1a87b2ee4 | ||
|
|
c5a30513ed | ||
|
|
ebe7bd7c8b | ||
|
|
683ca270d4 | ||
|
|
78e783e786 | ||
|
|
cbd360b7dd | ||
|
|
23e944c91d | ||
|
|
f15fcb6a1d | ||
|
|
8c0edcbfa3 | ||
|
|
b7f6356053 | ||
|
|
b65c72c45c | ||
|
|
19c534e325 | ||
|
|
5f05c41126 | ||
|
|
9134e4de1e | ||
|
|
582c2671dd | ||
|
|
0bb9d51965 | ||
|
|
6d9f936ff2 | ||
|
|
594348440e | ||
|
|
091cd0109f | ||
|
|
225164a9d6 | ||
|
|
f3152079e1 | ||
|
|
bf82f15bba | ||
|
|
4273c1b80e | ||
|
|
488583dc8d | ||
|
|
f1828921df | ||
|
|
7eed5ad97b | ||
|
|
80d9964a30 | ||
|
|
150ef86800 | ||
|
|
315d45a0eb | ||
|
|
2a412fad04 | ||
|
|
fe6f520054 | ||
|
|
c7f3599ebc | ||
|
|
b7589750a1 | ||
|
|
c310212d28 | ||
|
|
94d99d5462 | ||
|
|
9120df33ef | ||
|
|
1ab0745f8e | ||
|
|
c5d2de7ec0 | ||
|
|
ca1d78f523 | ||
|
|
6daf06b1ad | ||
|
|
69b7c496ac | ||
|
|
1e981f4c6d | ||
|
|
d325104d10 | ||
|
|
b3de4a3dec | ||
|
|
81db6bab91 | ||
|
|
f2e54e1e2f | ||
|
|
e9d32f901a | ||
|
|
f835be4bb2 | ||
|
|
3aadc9d665 | ||
|
|
bfb700cf41 | ||
|
|
d0accdba88 | ||
|
|
f58721a9e8 | ||
|
|
325396046a | ||
|
|
c52548f6fd | ||
|
|
8edbbb9865 | ||
|
|
73c125f248 | ||
|
|
1721056f35 | ||
|
|
6eef24c37a | ||
|
|
973de5a704 | ||
|
|
57332be8da | ||
|
|
44737b06db | ||
|
|
d50e47fc4a | ||
|
|
9f02feb9d0 | ||
|
|
72d1be5ddd | ||
|
|
1935eb5c1e | ||
|
|
62e0ed5d7e | ||
|
|
945339b443 | ||
|
|
c930fd5ff6 | ||
|
|
dda70d4ef1 | ||
|
|
7d3d996383 | ||
|
|
d23561f381 | ||
|
|
cbf9224c5f | ||
|
|
c965870585 | ||
|
|
9ee93b3ea3 | ||
|
|
df680d7257 | ||
|
|
d02c4bda3a | ||
|
|
938768ed3d | ||
|
|
3368b602a8 | ||
|
|
b185449d07 | ||
|
|
c2cac69a22 | ||
|
|
1a0d3cd5d3 | ||
|
|
adc1f21eae | ||
|
|
994cb872cf | ||
|
|
66829ee12e | ||
|
|
1751da76d5 | ||
|
|
ba014c1a60 | ||
|
|
886c282679 | ||
|
|
ccf39fcdc1 | ||
|
|
ee65bde130 | ||
|
|
b091790622 | ||
|
|
a352570e9f | ||
|
|
d459314517 | ||
|
|
1286c56188 | ||
|
|
40982a01fb | ||
|
|
7aeb4473ad | ||
|
|
72a4602b88 | ||
|
|
30275bc610 | ||
|
|
3e498cdb49 | ||
|
|
7624800ddc | ||
|
|
f0ed61f53c | ||
|
|
a6cd84869e | ||
|
|
7fa55b0419 | ||
|
|
bf35441608 | ||
|
|
f52eac6225 | ||
|
|
2c08a3a559 | ||
|
|
2eb6d6e31b | ||
|
|
334c28afe7 | ||
|
|
5944230c50 | ||
|
|
8bcdd8fc21 | ||
|
|
d518067be6 | ||
|
|
f703a30dfe | ||
|
|
1a0951959f | ||
|
|
b347a994fd | ||
|
|
6126fa0995 | ||
|
|
85df418728 | ||
|
|
558e5639d0 | ||
|
|
d8d746b4b8 | ||
|
|
570028e9c0 | ||
|
|
7c3e7d6535 | ||
|
|
5b065e93b3 | ||
|
|
d3f37566e2 | ||
|
|
b8b31ad53e | ||
|
|
7f479ffdce | ||
|
|
4901d9ddc8 | ||
|
|
ffba21a60c | ||
|
|
98b81e9834 | ||
|
|
17ec688ced | ||
|
|
0b77d17b35 | ||
|
|
d0566a474a | ||
|
|
99e3cbc526 | ||
|
|
b85de1ddb3 | ||
|
|
c1ccefc62d | ||
|
|
6ac7abe8f0 | ||
|
|
909e1c1a86 | ||
|
|
7936ce3874 | ||
|
|
b8b85fbb0c | ||
|
|
282c5f9644 | ||
|
|
165aa59760 | ||
|
|
10c38436aa | ||
|
|
a0404b6902 | ||
|
|
eb26dbd072 | ||
|
|
6c093010e0 | ||
|
|
d2160e3f83 | ||
|
|
b822d24b15 | ||
|
|
fc54bfe6b0 | ||
|
|
1a49ebaa9f | ||
|
|
e4dc1568ce | ||
|
|
1bd0851ee8 | ||
|
|
1b7c2dd056 | ||
|
|
d45c12b6c9 | ||
|
|
90ae7682ed | ||
|
|
e6af0ad23e | ||
|
|
34674bb180 | ||
|
|
784b711393 | ||
|
|
81a548bcc4 | ||
|
|
fd1750af49 | ||
|
|
2bf2f5d58e | ||
|
|
40811eb8d4 | ||
|
|
2756d12750 | ||
|
|
7839993fe7 | ||
|
|
47a4a9992c | ||
|
|
d75dd2ab1c | ||
|
|
6e665708fc | ||
|
|
d3830e622f | ||
|
|
0538676aa3 | ||
|
|
4c9f41f1ad | ||
|
|
e588ddb5d6 | ||
|
|
f3ec8693e3 | ||
|
|
e9b09faab2 | ||
|
|
5ea6148362 | ||
|
|
9e0d7bddc0 | ||
|
|
aa0a57fd56 | ||
|
|
d86c70af96 | ||
|
|
4538c269d0 | ||
|
|
446eb11cde | ||
|
|
fa1375c09f | ||
|
|
f141e9b37a | ||
|
|
3fba377ddd | ||
|
|
01a4752503 | ||
|
|
d66cbf20f7 | ||
|
|
7e4314eccb | ||
|
|
7c71c3e27d | ||
|
|
5eeee39cc1 | ||
|
|
796974ddf6 | ||
|
|
75f5b3dab6 | ||
|
|
9f330897a8 | ||
|
|
710eeb2a33 | ||
|
|
3493b7dac7 | ||
|
|
d51b4f92d7 | ||
|
|
3d8a8ea0c6 | ||
|
|
2057812c8f | ||
|
|
13360ad541 | ||
|
|
9389cfbec9 | ||
|
|
7be152412e | ||
|
|
d0fa48db1e | ||
|
|
884a21d0f5 | ||
|
|
21bca549d3 | ||
|
|
bda970b3b1 | ||
|
|
75ec17f0b5 | ||
|
|
d62121e7bb | ||
|
|
06d101657f | ||
|
|
2f7ffab0e8 | ||
|
|
3ed5e56a39 | ||
|
|
a0802dd486 | ||
|
|
f2675cdf04 | ||
|
|
e3864c383f | ||
|
|
25c0dc5e6e | ||
|
|
8954d01f96 | ||
|
|
b2fe9bff3f | ||
|
|
a36da3a878 | ||
|
|
c103f2fbcb | ||
|
|
aa4920fea3 | ||
|
|
5532766b19 | ||
|
|
5dbf3cb036 | ||
|
|
ddf929390e | ||
|
|
23519fc0b4 | ||
|
|
04288fcd4c | ||
|
|
84c22d053b | ||
|
|
7581762c8e | ||
|
|
7673732c0f | ||
|
|
2dfd3fbd71 | ||
|
|
3a13e066ba | ||
|
|
bcd9bcae2a | ||
|
|
939f796f08 | ||
|
|
27364345bf | ||
|
|
35c19ffc28 | ||
|
|
b0b5cad496 | ||
|
|
965edf8a5c | ||
|
|
1c271852fc | ||
|
|
7ea560261c | ||
|
|
304ea079d2 | ||
|
|
c190c73240 | ||
|
|
e8567098a4 | ||
|
|
a9ebb62d54 | ||
|
|
bdea2f9eda | ||
|
|
f5b041e394 | ||
|
|
e496a548d7 | ||
|
|
3d39b18e31 | ||
|
|
a96a8a1aab | ||
|
|
064124cc5f | ||
|
|
7af5fec038 | ||
|
|
f884fff869 | ||
|
|
c7a121cfc0 | ||
|
|
777be296ee | ||
|
|
a0172a6ae5 | ||
|
|
1099442c0a | ||
|
|
18989cd430 | ||
|
|
828145456c | ||
|
|
097a046e4a | ||
|
|
3977dba761 | ||
|
|
a41cd8d75b | ||
|
|
662d471215 | ||
|
|
06b5805479 | ||
|
|
d6debc21c7 | ||
|
|
ddb52a2b15 | ||
|
|
13441e8cb8 | ||
|
|
a97d5b8e60 | ||
|
|
399d7380a5 | ||
|
|
c231381aa3 | ||
|
|
c30d60f7ae | ||
|
|
9fb9f78e43 | ||
|
|
a0cf65db77 | ||
|
|
2ee9c4df12 | ||
|
|
e6c77e7afb | ||
|
|
76cb088d16 | ||
|
|
907ad00300 | ||
|
|
88a4da9747 | ||
|
|
25c430b1cd | ||
|
|
772d61f3ed | ||
|
|
5b1cf02f2e | ||
|
|
66f4c60a84 | ||
|
|
fce095665c | ||
|
|
2555ac58cc | ||
|
|
e323101ede | ||
|
|
ce52e45d44 | ||
|
|
4f3c31a6b6 | ||
|
|
70bc8ef845 | ||
|
|
cd60e57b6a | ||
|
|
3d2b7d5bce | ||
|
|
04f54ab38f | ||
|
|
46c7dbef0f | ||
|
|
11b90bc959 | ||
|
|
792e2856c9 | ||
|
|
d89b35e682 | ||
|
|
a46ccbd883 | ||
|
|
5dda1abc32 | ||
|
|
55640a31b3 | ||
|
|
88428cff3a | ||
|
|
c24b58e2ee | ||
|
|
9e537c808b | ||
|
|
2c4543b9e9 | ||
|
|
b58bca9a72 | ||
|
|
27dcf470dc | ||
|
|
caa8290510 | ||
|
|
7f9b225cc2 | ||
|
|
4ccb2e2c21 | ||
|
|
cbee283c26 | ||
|
|
9fcda95a6f | ||
|
|
7ada64d5f8 | ||
|
|
20f0d917be | ||
|
|
e312db1408 | ||
|
|
743bd1275f | ||
|
|
69c86379e3 | ||
|
|
46b3c1a025 | ||
|
|
3ea893464f | ||
|
|
738e789dbd | ||
|
|
66afcf5be0 | ||
|
|
4b0ed56e32 | ||
|
|
dc2af8347b | ||
|
|
64ea8829af | ||
|
|
629cfec8a3 | ||
|
|
7f63658709 | ||
|
|
5e4d9a3197 | ||
|
|
982354765b | ||
|
|
5fe0576dcb |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,6 +6,7 @@
|
|||||||
core
|
core
|
||||||
tags
|
tags
|
||||||
.deps/
|
.deps/
|
||||||
|
compat/.dirstamp
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
autom4te.cache/
|
autom4te.cache/
|
||||||
config.log
|
config.log
|
||||||
@@ -15,3 +16,5 @@ tmux
|
|||||||
Makefile
|
Makefile
|
||||||
Makefile.in
|
Makefile.in
|
||||||
configure
|
configure
|
||||||
|
tmux.1.*
|
||||||
|
*.dSYM
|
||||||
|
|||||||
53
.mailmap
53
.mailmap
@@ -1,24 +1,37 @@
|
|||||||
Bob Beck <beck@openbsd.org> beck <beck>
|
Bob Beck <beck@openbsd.org> beck <beck>
|
||||||
Igor Sobrado <sobrado@openbsd.org> sobrado <sobrado>
|
Claudio Jeker <claudio@openbsd.org> claudio <claudio>
|
||||||
Jacek Masiulaniec <jacekm@openbsd.org> jacekm <jacekm>
|
Igor Sobrado <sobrado@openbsd.org> sobrado <sobrado>
|
||||||
Jason McIntyre <jmc@openbsd.org> jcm <jcm>
|
Ingo Schwarze <schwarze@openbsd.org> schwarze <schwarze>
|
||||||
|
Jacek Masiulaniec <jacekm@openbsd.org> jacekm <jacekm>
|
||||||
|
Jason McIntyre <jmc@openbsd.org> jmc <jmc>
|
||||||
Joel Sing <jsing@openbsd.org> jsing <jsing>
|
Joel Sing <jsing@openbsd.org> jsing <jsing>
|
||||||
Marc Espie <espie@openbsd.org> espie <espie>
|
Jonathan Gray <jsg@openbsd.org> jsg <jsg>
|
||||||
Matthew Dempsky <matthew@openbsd.org> matthew <matthew>
|
Kenneth R Westerback <krw@openbsd.org> krw <krw>
|
||||||
Matthias Kilian <kili@openbsd.org> kili <kili>
|
Marc Espie <espie@openbsd.org> espie <espie>
|
||||||
Matthieu Herrb <matthieu@openbsd.org> matthieu <matthieu>
|
Matthew Dempsky <matthew@openbsd.org> matthew <matthew>
|
||||||
Miod Vallat <miod@openbsd.org> miod <miod>
|
Matthias Kilian <kili@openbsd.org> kili <kili>
|
||||||
Nicholas Marriott <nicm@openbsd.org> nicm <nicm>
|
Matthieu Herrb <matthieu@openbsd.org> matthieu <matthieu>
|
||||||
Nicholas Marriott <nicm@openbsd.org> no_author <no_author@example.org>
|
Michael McConville <mmcc@openbsd.org> mmcc <mmcc>
|
||||||
<nicm@openbsd.org> <nicholas.marriott@gmail.com>
|
Miod Vallat <miod@openbsd.org> miod <miod>
|
||||||
Okan Demirmen <okan@openbsd.org> okan <okan>
|
Nicholas Marriott <nicholas.marriott@gmail.com> Nicholas Marriott <nicm@openbsd.org>
|
||||||
|
Nicholas Marriott <nicholas.marriott@gmail.com> nicm <nicm>
|
||||||
|
Nicholas Marriott <nicholas.marriott@gmail.com> no_author <no_author@example.org>
|
||||||
|
Okan Demirmen <okan@openbsd.org> okan <okan>
|
||||||
Philip Guenther <guenther@openbsd.org> guenther <guenther>
|
Philip Guenther <guenther@openbsd.org> guenther <guenther>
|
||||||
Pierre-Yves Ritschard <pyr@openbsd.org> pyr <pyr>
|
Pierre-Yves Ritschard <pyr@openbsd.org> pyr <pyr>
|
||||||
Ray Lai <ray@openbsd.org> ray <ray>
|
Ray Lai <ray@openbsd.org> ray <ray>
|
||||||
Ryan McBride <mcbride@openbsd.org> mcbride <mcbride>
|
Ryan McBride <mcbride@openbsd.org> mcbride <mcbride>
|
||||||
Stefan Sperling <stsp@openbsd.org> stsp <stsp>
|
Sebastian Benoit <benno@openbsd.org> benno <benno>
|
||||||
Stuart Henderson <sthen@openbsd.org> sthen <sthen>
|
Sebastien Marie <semarie@openbsd.org> semarie <semarie>
|
||||||
Ted Unangst <tedu@openbsd.org> tedu <tedu>
|
Stefan Sperling <stsp@openbsd.org> stsp <stsp>
|
||||||
Theo Deraadt <deraadt@openbsd.org> deraadt <deraadt>
|
Stuart Henderson <sthen@openbsd.org> sthen <sthen>
|
||||||
|
Ted Unangst <tedu@openbsd.org> tedu <tedu>
|
||||||
|
Theo de Raadt <deraadt@openbsd.org> Theo Deraadt <deraadt@openbsd.org>
|
||||||
|
Theo de Raadt <deraadt@openbsd.org> deraadt <deraadt>
|
||||||
Thomas Adam <thomas@xteddy.org> Thomas <thomas@xteddy.org>
|
Thomas Adam <thomas@xteddy.org> Thomas <thomas@xteddy.org>
|
||||||
William Yodlowsky <william@openbsd.org> william <william>
|
Thomas Adam <thomas@xteddy.org> Thomas Adam <thomas.adam@smoothwall.net>
|
||||||
|
Thomas Adam <thomas@xteddy.org> n6tadam <n6tadam@xteddy.org>
|
||||||
|
Tim van der Molen <tim@openbsd.org> tim <tim>
|
||||||
|
Tobias Stoeckmann <tobias@openbsd.org> tobias <tobias>
|
||||||
|
Todd C Miller <millert@openbsd.org> millert <millert>
|
||||||
|
William Yodlowsky <william@openbsd.org> william <william>
|
||||||
|
|||||||
10
.travis.yml
Normal file
10
.travis.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
language: c
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- compiler: gcc
|
||||||
|
- compiler: clang
|
||||||
|
env: CFLAGS="-g -O2"
|
||||||
|
before_install:
|
||||||
|
- sudo apt-get update -qq
|
||||||
|
- sudo apt-get -y install debhelper autotools-dev dh-autoreconf file libncurses5-dev libevent-dev pkg-config libutempter-dev build-essential
|
||||||
|
script: (CFLAGS= ./autogen.sh) && ./configure --enable-debug && make
|
||||||
358
CHANGES
358
CHANGES
@@ -1,3 +1,346 @@
|
|||||||
|
CHANGES FROM 2.3 to 2.4 20 April 2017
|
||||||
|
|
||||||
|
Incompatible Changes
|
||||||
|
====================
|
||||||
|
|
||||||
|
* Key tables have undergone major changes. Mode key tables are no longer
|
||||||
|
separate from the main key tables. All mode key tables have been removed,
|
||||||
|
together with the -t flag to bind-key and unbind-key.
|
||||||
|
|
||||||
|
The emacs-edit, vi-edit, emacs-choose and vi-choose tables have been replaced
|
||||||
|
by fixed key bindings in the command prompt and choose modes. The mode-keys
|
||||||
|
and status-keys options remain.
|
||||||
|
|
||||||
|
The emacs-copy and vi-copy tables have been replaced by the copy-mode and
|
||||||
|
copy-mode-vi tables. Commands are sent using the -X and -N flags to
|
||||||
|
send-keys. So the following:
|
||||||
|
|
||||||
|
bind -temacs-copy C-Up scroll-up
|
||||||
|
bind -temacs-copy -R5 WheelUpPane scroll-up
|
||||||
|
|
||||||
|
Becomes:
|
||||||
|
|
||||||
|
bind -Tcopy-mode C-Up send -X scroll-up
|
||||||
|
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up
|
||||||
|
|
||||||
|
This changes allows the full command parser (including command sequences) and
|
||||||
|
command set to be used - for example, the normal command prompt with editing
|
||||||
|
and history is now used for searching, jumping, and so on instead of a custom
|
||||||
|
one. The default C-r binding is now:
|
||||||
|
|
||||||
|
bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"
|
||||||
|
|
||||||
|
There are also some new commmands available with send -X, such as
|
||||||
|
copy-pipe-and-cancel.
|
||||||
|
* set-remain-on-exit has gone -- can be achieved with hooks instead.
|
||||||
|
* Hooks: before hooks have been removed and only a selection of commands now
|
||||||
|
have after hooks (they are no longer automatic). Additional hooks have been
|
||||||
|
added.
|
||||||
|
* The xterm-keys option now defaults to on.
|
||||||
|
|
||||||
|
Normal Changes
|
||||||
|
==============
|
||||||
|
|
||||||
|
* Support for mouse double and triple clicks.
|
||||||
|
* BCE (Background Colour Erase) is now supported.
|
||||||
|
* All occurrences of a search string in copy mode are now highlighted;
|
||||||
|
additionally, the number of search results is displayed. The highlighting
|
||||||
|
updates interactively with the default emacs key bindings (incremental
|
||||||
|
search).
|
||||||
|
* source-file now understands glob patterns.
|
||||||
|
* Formats now have simple comparisons:
|
||||||
|
|
||||||
|
#{==:a,b}
|
||||||
|
#{!=:a,b}
|
||||||
|
|
||||||
|
* There are the following new formats:
|
||||||
|
|
||||||
|
- #{version} -- the tmux server version;
|
||||||
|
- #{client_termtype} -- the terminal type of the client;
|
||||||
|
- #{client_name} -- the name of a client;
|
||||||
|
- #{client_written} -- the number of bytes written to the client.
|
||||||
|
|
||||||
|
* The configuration file now accepts %if/%endif conditional blocks which are
|
||||||
|
processed when it is parsed; the argument is a format string (useful with the
|
||||||
|
new format comparison options).
|
||||||
|
* detach-client now has -E to execute a command replacing the client instead of
|
||||||
|
exiting.
|
||||||
|
* Add support for custom command aliases, this is an array option which
|
||||||
|
contains items of the form "alias=command". This is consulted when an
|
||||||
|
unknown command is parsed.
|
||||||
|
* break-pane now has -n to specify the new window name.
|
||||||
|
* OSC 52 support has been added for programs inside tmux to set a tmux buffer.
|
||||||
|
* The mouse "all event" mode (1003) is now supported.
|
||||||
|
* Palette setting is now possible (OSC 4 and 104).
|
||||||
|
* Strikethrough support (a recent terminfo is required).
|
||||||
|
* Grouped sessions can now be named (new -t).
|
||||||
|
* terminal-overrides and update-environment are now array options (the previous
|
||||||
|
set -ag syntax should work without change).
|
||||||
|
* There have been substantial performance improvements.
|
||||||
|
|
||||||
|
CHANGES FROM 2.2 to 2.3 29 September 2016
|
||||||
|
|
||||||
|
Incompatible Changes
|
||||||
|
====================
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
Normal Changes
|
||||||
|
==============
|
||||||
|
|
||||||
|
* New option 'pane-border-status' to add text in the pane borders.
|
||||||
|
* Support for hooks on commands: 'after' and 'before' hooks.
|
||||||
|
* 'source-file' understands '-q' to suppress errors for nonexistent files.
|
||||||
|
* Lots of UTF8 improvements, especially on MacOS.
|
||||||
|
* 'window-status-separator' understands #[] expansions.
|
||||||
|
* 'split-window' understands '-f' for performing a full-width split.
|
||||||
|
* Allow report count to be specified when using 'bind-key -R'.
|
||||||
|
* 'set -a' for appending to user options (@foo) is now supported.
|
||||||
|
* 'display-panes' can now accept a command to run, rather than always
|
||||||
|
selecting the pane.
|
||||||
|
|
||||||
|
CHANGES FROM 2.1 to 2.2 10 April 2016
|
||||||
|
|
||||||
|
Incompatible Changes
|
||||||
|
====================
|
||||||
|
|
||||||
|
* The format strings which referenced time have been removed. Instead:
|
||||||
|
|
||||||
|
#{t:window_activity}
|
||||||
|
|
||||||
|
can be used.
|
||||||
|
|
||||||
|
* Support for TMPDIR has been removed. Use TMUX_TMPDIR instead.
|
||||||
|
* UTF8 detection now happens automatically if the client supports it, hence
|
||||||
|
the:
|
||||||
|
|
||||||
|
mouse-utf8
|
||||||
|
utf8
|
||||||
|
|
||||||
|
options has been removed.
|
||||||
|
* The:
|
||||||
|
|
||||||
|
mouse_utf8_flag
|
||||||
|
|
||||||
|
format string has been removed.
|
||||||
|
* The -I option to show-messages has been removed. See:
|
||||||
|
|
||||||
|
#{t:start_time}
|
||||||
|
|
||||||
|
format option instead.
|
||||||
|
|
||||||
|
Normal Changes
|
||||||
|
==============
|
||||||
|
|
||||||
|
* Panes are unzoomed with selectp -LRUD
|
||||||
|
* New formats added:
|
||||||
|
|
||||||
|
#{scroll_position}
|
||||||
|
#{socket_path}
|
||||||
|
#{=10:...} -- limit to N characters (from the start)
|
||||||
|
#{=-10:...} -- limit to N characters (from the end)
|
||||||
|
#{t:...} -- used to format time-based formats
|
||||||
|
#{b:...} -- used to ascertain basename from string
|
||||||
|
#{d:...} -- used to ascertain dirname from string
|
||||||
|
#{s:...} -- used to perform substitutions on a string
|
||||||
|
|
||||||
|
* Job output is run via the format system, so formats work again
|
||||||
|
* If display-time is set to 0, then the indicators wait for a key to be
|
||||||
|
pressed.
|
||||||
|
* list-keys and list-commands can be run without starting the tmux server.
|
||||||
|
* kill-session learns -C to clear all alerts in all windows of the session.
|
||||||
|
* Support for hooks (internal for now), but hooks for the following have been
|
||||||
|
implemented:
|
||||||
|
|
||||||
|
alert-bell
|
||||||
|
alert-silence
|
||||||
|
alert-activity
|
||||||
|
client-attached
|
||||||
|
client-detached
|
||||||
|
client-resized
|
||||||
|
pane-died
|
||||||
|
pane-exited
|
||||||
|
|
||||||
|
* RGB (24bit) colour support. The 'Tc' flag must be set in the external TERM
|
||||||
|
entry (using terminal-overrides or a custom terminfo entry).
|
||||||
|
|
||||||
|
|
||||||
|
CHANGES FROM 2.0 to 2.1 18 October 2015
|
||||||
|
|
||||||
|
Incompatible Changes
|
||||||
|
====================
|
||||||
|
|
||||||
|
* Mouse-mode has been rewritten. There's now no longer options for:
|
||||||
|
- mouse-resize-pane
|
||||||
|
- mouse-select-pane
|
||||||
|
- mouse-select-window
|
||||||
|
- mode-mouse
|
||||||
|
|
||||||
|
Instead there is just one option: 'mouse' which turns on mouse support
|
||||||
|
entirely.
|
||||||
|
* 'default-terminal' is now a session option. Furthermore, if this is set
|
||||||
|
to 'screen-*' then emulate what screen does. If italics are wanted, this
|
||||||
|
can be set to 'tmux' but this is still new and not necessarily supported
|
||||||
|
on all platforms with older ncurses installs.
|
||||||
|
* The c0-* options for rate-limiting have been removed. Instead, a backoff
|
||||||
|
approach is used.
|
||||||
|
|
||||||
|
Normal Changes
|
||||||
|
==============
|
||||||
|
|
||||||
|
* New formats:
|
||||||
|
- session_activity
|
||||||
|
- window_linked
|
||||||
|
- window_activity_format
|
||||||
|
- session_alerts
|
||||||
|
- session_last_attached
|
||||||
|
- client_pid
|
||||||
|
- pid
|
||||||
|
* 'copy-selection', 'append-selection', 'start-named-buffer' now understand
|
||||||
|
an '-x' flag to prevent it exiting copying mode.
|
||||||
|
* 'select-pane' now understands '-P' to set window/pane background colours.
|
||||||
|
* 'renumber-windows' now understands windows which are unlinked.
|
||||||
|
* 'bind' now understands multiple key tables. Allows for key-chaining.
|
||||||
|
* 'select-layout' understands '-o' to undo the last layout change.
|
||||||
|
* The environment is updated when switching sessions as well as attaching.
|
||||||
|
* 'select-pane' now understands '-M' for marking a pane. This marked pane
|
||||||
|
can then be used with commands which understand src-pane specifiers
|
||||||
|
automatically.
|
||||||
|
* If a session/window target is prefixed with '=' then only an exact match
|
||||||
|
is considered.
|
||||||
|
* 'move-window' understands '-a'.
|
||||||
|
* 'update-environment' understands '-E' when attach-session is used on an
|
||||||
|
already attached client.
|
||||||
|
* 'show-environment' understands '-s' to output Bourne-compatible commands.
|
||||||
|
* New option: 'history-file' to save/restore command prompt history.
|
||||||
|
* Copy mode is exited if the history is cleared whilst in copy-mode.
|
||||||
|
* 'copy-mode' learned '-e' to exit copy-mode when scrolling to end.
|
||||||
|
|
||||||
|
CHANGES FROM 1.9a to 2.0 6 March 2015
|
||||||
|
|
||||||
|
Incompatible Changes
|
||||||
|
====================
|
||||||
|
|
||||||
|
* The choose-list command has been removed.
|
||||||
|
* 'terminal-overrides' is now a server option, not a session option.
|
||||||
|
* 'message-limit' is now a server option, not a session option.
|
||||||
|
* 'monitor-content' option has been removed.
|
||||||
|
* 'pane_start_path' option has been removed.
|
||||||
|
* The "info" mechanism which used to (for some commands) provide feedback
|
||||||
|
has been removed, and like other commands, they now produce nothing on
|
||||||
|
success.
|
||||||
|
|
||||||
|
Normal Changes
|
||||||
|
==============
|
||||||
|
|
||||||
|
* tmux can now write an entry to utmp if the library 'utempter' is present
|
||||||
|
at compile time.
|
||||||
|
* set-buffer learned append mode (-a), and a corresponding
|
||||||
|
'append-selection' command has been added to copy-mode.
|
||||||
|
* choose-mode now has the following commands which can be bound:
|
||||||
|
- start-of-list
|
||||||
|
- end-of-list
|
||||||
|
- top-line
|
||||||
|
- bottom-line
|
||||||
|
|
||||||
|
* choose-buffer now understands UTF-8.
|
||||||
|
* Pane navigation has changed:
|
||||||
|
- The old way of always using the top or left if the choice is ambiguous.
|
||||||
|
- The new way of remembering the last used pane is annoying if the
|
||||||
|
layout is balanced and the leftmost is obvious to the user (because
|
||||||
|
clearly if we go right from the top-left in a tiled set of four we want
|
||||||
|
to end up in top-right, even if we were last using the bottom-right).
|
||||||
|
|
||||||
|
So instead, use a combination of both: if there is only one possible
|
||||||
|
pane alongside the current pane, move to it, otherwise choose the most
|
||||||
|
recently used of the choice.
|
||||||
|
* 'set-buffer' can now be told to give names to buffers.
|
||||||
|
* The 'new-session', 'new-window', 'split-window', and 'respawn-pane' commands
|
||||||
|
now understand multiple arguments and handle quoting problems correctly.
|
||||||
|
* 'capture-pane' understands '-S-' to mean the start of the pane, and '-E-' to
|
||||||
|
mean the end of the pane.
|
||||||
|
* Support for function keys beyond F12 has changed. The following explains:
|
||||||
|
- F13-F24 are S-F1 to S-F12
|
||||||
|
- F25-F36 are C-F1 to C-F12
|
||||||
|
- F37-F48 are C-S-F1 to C-S-F12
|
||||||
|
- F49-F60 are M-F1 to M-F12
|
||||||
|
- F61-F63 are M-S-F1 to M-S-F3
|
||||||
|
|
||||||
|
Therefore, F13 becomes a binding of S-F1, etc.
|
||||||
|
* Support using pane id as part of session or window specifier (so % means
|
||||||
|
session-of-%1 or window-of-%1) and window id as part of session
|
||||||
|
(so @1 means session-of-@1).
|
||||||
|
* 'copy-pipe' command now understands formats via -F
|
||||||
|
* 'if-shell' command now understands formats via -F
|
||||||
|
* 'split-window' and 'join-window' understand -b to create the pane to the left
|
||||||
|
or above the target pane.
|
||||||
|
|
||||||
|
CHANGES FROM 1.9 to 1.9a 22 February 2014
|
||||||
|
|
||||||
|
NOTE: This is a bug-fix release to address some important bugs which just
|
||||||
|
missed the 1.9 deadline, but were found afterwards.
|
||||||
|
|
||||||
|
Normal Changes
|
||||||
|
==============
|
||||||
|
|
||||||
|
* Fix crash due to uninitialized lastwp member of layout_cell
|
||||||
|
* Fix -fg/-bg/-style with 256 colour terminals.
|
||||||
|
|
||||||
|
CHANGES FROM 1.8 to 1.9, 20 February 2014
|
||||||
|
|
||||||
|
NOTE: This release has bumped the tmux protocol version. It is therefore
|
||||||
|
advised that the prior tmux server is restarted when this version of tmux is
|
||||||
|
installed, to avoid protocol mismatch errors for newer clients trying to
|
||||||
|
talk to an older running tmux server.
|
||||||
|
|
||||||
|
Incompatible Changes
|
||||||
|
====================
|
||||||
|
|
||||||
|
* 88 colour support has been removed.
|
||||||
|
* 'default-path' has been removed. The new-window command accepts '-c' to
|
||||||
|
cater for this. The previous value of "." can be replaced with: 'neww -c
|
||||||
|
$PWD', the previous value of '' which meant current path of the pane can
|
||||||
|
be specified as: 'neww -c "#{pane_current_path}"'
|
||||||
|
|
||||||
|
Deprecated Changes
|
||||||
|
==================
|
||||||
|
|
||||||
|
* The single format specifiers: #A -> #Z (where defined) have been
|
||||||
|
deprecated and replaced with longer-named equivalents, as listed in the
|
||||||
|
FORMATS section of the tmux manpage.
|
||||||
|
* The various foo-{fg,bg,attr} commands have been deprecated and replaced
|
||||||
|
with equivalent foo-style option instead. Currently this is still
|
||||||
|
backwards-compatible, but will be removed over time.
|
||||||
|
|
||||||
|
Normal Changes
|
||||||
|
==============
|
||||||
|
|
||||||
|
* A new environment variable TMUX_TMPDIR is now honoured, allowing the
|
||||||
|
socket directory to be set outside of TMPDIR (/tmp/ if not set).
|
||||||
|
* If -s not given to swap-pane the current pane is assumed.
|
||||||
|
* A #{pane_synchronized} format specifier has been added to be a conditional
|
||||||
|
format if a pane is in a synchronised mode (c.f. synchronize-panes)
|
||||||
|
* Tmux now runs under Cygwin natively.
|
||||||
|
* Formats can now be nested within each other and expanded accordingly.
|
||||||
|
* Added 'automatic-rename-format' option to allow the automatic rename
|
||||||
|
mechanism to use something other than the default of
|
||||||
|
#{pane_current_command}.
|
||||||
|
* new-session learnt '-c' to specify the starting directory for that session
|
||||||
|
and all subsequent windows therein.
|
||||||
|
* The session name is now shown in the message printed to the terminal when
|
||||||
|
a session is detached.
|
||||||
|
* Lots more format specifiers have been added.
|
||||||
|
* Server race conditions have been fixed; in particular commands are not run
|
||||||
|
until after the configuration file is read completely.
|
||||||
|
* Case insensitive searching in tmux's copy-mode is now possible.
|
||||||
|
* attach-session and switch-client learnt the '-t' option to accept a window
|
||||||
|
and/or a pane to use.
|
||||||
|
* Copy-mode is only exited if no selection is in progress.
|
||||||
|
* Paste key in copy-mode is now possible to enter text from the clipboard.
|
||||||
|
* status-interval set to '0' now works as intended.
|
||||||
|
* tmux now supports 256 colours running under fbterm.
|
||||||
|
* Many bug fixes!
|
||||||
|
|
||||||
CHANGES FROM 1.7 to 1.8, 26 March 2013
|
CHANGES FROM 1.7 to 1.8, 26 March 2013
|
||||||
|
|
||||||
Incompatible Changes
|
Incompatible Changes
|
||||||
@@ -17,7 +360,7 @@ Normal Changes
|
|||||||
* run-shell learnt '-t' to specify the pane to use when displaying output.
|
* run-shell learnt '-t' to specify the pane to use when displaying output.
|
||||||
* Support for middle-click pasting.
|
* Support for middle-click pasting.
|
||||||
* choose-tree learns '-u' to start uncollapsed.
|
* choose-tree learns '-u' to start uncollapsed.
|
||||||
* select-window learnt '-T; to toggle to the last window if it's already
|
* select-window learnt '-T' to toggle to the last window if it's already
|
||||||
current.
|
current.
|
||||||
* New session option 'assume-paste-time' for pasting text versus key-binding
|
* New session option 'assume-paste-time' for pasting text versus key-binding
|
||||||
actions.
|
actions.
|
||||||
@@ -37,9 +380,9 @@ Normal Changes
|
|||||||
the 'source-file' command.
|
the 'source-file' command.
|
||||||
* 'copy-pipe' mode command to copy selection and pipe the selection to a
|
* 'copy-pipe' mode command to copy selection and pipe the selection to a
|
||||||
command.
|
command.
|
||||||
* Changes panes can now emit focus notifications for certain applications
|
* Panes can now emit focus notifications for certain applications
|
||||||
which use those.
|
which use those.
|
||||||
* run-shell and if-shell now accept format placeholders.
|
* run-shell and if-shell now accept formats.
|
||||||
* resize-pane learnt '-Z' for zooming a pane temporarily.
|
* resize-pane learnt '-Z' for zooming a pane temporarily.
|
||||||
* new-session learnt '-A' to make it behave like attach-session.
|
* new-session learnt '-A' to make it behave like attach-session.
|
||||||
* set-option learnt '-o' to prevent setting an option which is already set.
|
* set-option learnt '-o' to prevent setting an option which is already set.
|
||||||
@@ -776,7 +1119,7 @@ The list of older changes is below.
|
|||||||
* -u flag to scroll-mode and copy-mode to start scrolled one page
|
* -u flag to scroll-mode and copy-mode to start scrolled one page
|
||||||
up. scroll-mode -u is bound to prefix,page-up (ppage) by default.
|
up. scroll-mode -u is bound to prefix,page-up (ppage) by default.
|
||||||
* Allow status, mode and message attributes to be changed by three new options:
|
* Allow status, mode and message attributes to be changed by three new options:
|
||||||
status-attr, mode-attr, message-attr. A comma-separataed list is accepted
|
status-attr, mode-attr, message-attr. A comma-separated list is accepted
|
||||||
containing: bright, dim, underscore, blink, reverse, hidden, italics, for
|
containing: bright, dim, underscore, blink, reverse, hidden, italics, for
|
||||||
example:
|
example:
|
||||||
|
|
||||||
@@ -1799,10 +2142,3 @@ The list of older changes is below.
|
|||||||
emacs) that don't require scrolling regions (ESC[r) mostly work fine
|
emacs) that don't require scrolling regions (ESC[r) mostly work fine
|
||||||
(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$
|
|
||||||
|
|
||||||
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: dstidx srcname srcidx winlink lsw nabc sabc Exp Tiago Cunha dch
|
|
||||||
LocalWords: setw Chisnall renamew merdely eg Maier newname selectw neww Gass
|
|
||||||
|
|||||||
33
CONTRIBUTING
Normal file
33
CONTRIBUTING
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
When reporting issues:
|
||||||
|
|
||||||
|
YOU MUST INCLUDE THE TMUX VERSION
|
||||||
|
|
||||||
|
DO NOT OPEN AN ISSUE THAT DOES NOT MENTION THE TMUX VERSION
|
||||||
|
|
||||||
|
Please also include:
|
||||||
|
|
||||||
|
- your platform (Linux, OS X, or whatever);
|
||||||
|
- a brief description of the problem with steps to reproduce;
|
||||||
|
- a minimal tmux config, if you can't reproduce without a config;
|
||||||
|
- your terminal, and $TERM inside and outside of tmux;
|
||||||
|
- logs from tmux (see below);
|
||||||
|
- at most one or two screenshots, if helpful.
|
||||||
|
|
||||||
|
This should include at least the output of:
|
||||||
|
|
||||||
|
$ uname -sp && tmux -V && echo $TERM
|
||||||
|
|
||||||
|
Please do not report bugs (crashes, incorrect behaviour) without reproducing on
|
||||||
|
a tmux built from Git master.
|
||||||
|
|
||||||
|
Note that TERM inside tmux must be a variant of screen or tmux (for example:
|
||||||
|
screen or screen-256color, tmux or tmux-256color). Please ensure this is the
|
||||||
|
case before opening an issue.
|
||||||
|
|
||||||
|
To run tmux without a config and get logs, run:
|
||||||
|
|
||||||
|
tmux -Ltest kill-server
|
||||||
|
tmux -vvvv -Ltest -f/dev/null new
|
||||||
|
|
||||||
|
Then reproduce the problem, exit tmux, and attach the tmux-server-*.log file
|
||||||
|
from the current directory to the issue.
|
||||||
21
COPYING
Normal file
21
COPYING
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
THIS IS FOR INFORMATION ONLY, CODE IS UNDER THE LICENCE AT THE TOP OF ITS FILE.
|
||||||
|
|
||||||
|
The README, CHANGES, FAQ and TODO files are licensed under the ISC
|
||||||
|
license. 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,
|
||||||
|
typically:
|
||||||
|
|
||||||
|
Copyright (c) <author>
|
||||||
|
|
||||||
|
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.
|
||||||
138
FAQ
138
FAQ
@@ -95,9 +95,6 @@ aware of are (bearing in mind I haven't used screen for a few years now):
|
|||||||
- screen has builtin serial and telnet support; this is bloat and is unlikely
|
- screen has builtin serial and telnet support; this is bloat and is unlikely
|
||||||
to be added to tmux.
|
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.
|
- Environment handling is different.
|
||||||
|
|
||||||
- tmux tends to be more demanding on the terminal so tends to show up terminal
|
- tmux tends to be more demanding on the terminal so tends to show up terminal
|
||||||
@@ -107,8 +104,12 @@ aware of are (bearing in mind I haven't used screen for a few years now):
|
|||||||
|
|
||||||
* 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 or
|
Check the latest version of tmux from Git to see if the problem is still
|
||||||
tmux-users@lists.sourceforge.net. Please include as much of the following
|
reproducible. Sometimes the length of time between releases means a lot of
|
||||||
|
fixes can be sitting in Git and the problem might already be fixed.
|
||||||
|
|
||||||
|
Please send bug reports by email to nicholas.marriott@gmail.com or
|
||||||
|
tmux-users@googlegroups.com. Please include as much of the following
|
||||||
information as possible:
|
information as possible:
|
||||||
|
|
||||||
- the version of tmux you are running;
|
- the version of tmux you are running;
|
||||||
@@ -122,7 +123,7 @@ information as possible:
|
|||||||
|
|
||||||
* Why doesn't tmux do $x?
|
* Why doesn't tmux do $x?
|
||||||
|
|
||||||
Please send feature requests by email to nicm@users.sourceforge.net.
|
Please send feature requests by email to tmux-users@googlegroups.com.
|
||||||
|
|
||||||
* Why do you use the screen terminal description inside tmux? It sucks.
|
* Why do you use the screen terminal description inside tmux? It sucks.
|
||||||
|
|
||||||
@@ -238,6 +239,31 @@ would be welcome.
|
|||||||
|
|
||||||
vim users may also want to set the "ttyfast" option inside tmux.
|
vim users may also want to set the "ttyfast" option inside tmux.
|
||||||
|
|
||||||
|
* How do I make ctrl and shift arrow keys work in emacs?
|
||||||
|
|
||||||
|
The terminal-init-screen function in term/screen.el is called for new frames,
|
||||||
|
but it doesn't configure any function keys.
|
||||||
|
|
||||||
|
If the tmux xterm-keys option is on, it is enough to define the same keys as
|
||||||
|
xterm. Add the following to init.el or .emacs to do this:
|
||||||
|
|
||||||
|
(defadvice terminal-init-screen
|
||||||
|
;; The advice is named `tmux', and is run before `terminal-init-screen' runs.
|
||||||
|
(before tmux activate)
|
||||||
|
;; Docstring. This describes the advice and is made available inside emacs;
|
||||||
|
;; for example when doing C-h f terminal-init-screen RET
|
||||||
|
"Apply xterm keymap, allowing use of keys passed through tmux."
|
||||||
|
;; This is the elisp code that is run before `terminal-init-screen'.
|
||||||
|
(if (getenv "TMUX")
|
||||||
|
(let ((map (copy-keymap xterm-function-map)))
|
||||||
|
(set-keymap-parent map (keymap-parent input-decode-map))
|
||||||
|
(set-keymap-parent input-decode-map map))))
|
||||||
|
|
||||||
|
And ensure .tmux.conf contains "set -g xterm-keys on".
|
||||||
|
|
||||||
|
Alternatively, the screen.el file can be copied to the load path and
|
||||||
|
customized.
|
||||||
|
|
||||||
* Why doesn't elinks set the window title inside tmux?
|
* 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
|
||||||
@@ -326,42 +352,33 @@ 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'
|
bind x set lock-command '/usr/bin/vlock' \; lock-client \; set lock-command 'tput civis && read -s -n1'
|
||||||
|
|
||||||
* vim displays reverse video instead of italics, while less displays italics
|
* I don't see italics! Or less and vim show italics and reverse the wrong way round!
|
||||||
(or just regular text) instead of reverse. What's wrong?
|
|
||||||
|
|
||||||
Screen's terminfo description lacks italics mode and has standout mode in its
|
GNU screen does not support italics and the "screen" terminfo description uses
|
||||||
place, but using the same escape sequence that urxvt uses for italics. This
|
the italics escape sequence incorrectly.
|
||||||
means applications (like vim) looking for italics will not find it and might
|
|
||||||
turn to reverse in its place, while applications (like less) asking for
|
|
||||||
standout will end up with italics instead of reverse. To make applications
|
|
||||||
aware that tmux supports italics and to use a proper escape sequence for
|
|
||||||
standout, you'll need to create a new terminfo file with modified sgr, smso,
|
|
||||||
rmso, sitm and ritm entries:
|
|
||||||
|
|
||||||
$ mkdir $HOME/.terminfo/
|
As of tmux 2.1, if default-terminal is set to "screen" or matches "screen-*",
|
||||||
$ screen_terminfo="screen"
|
tmux will behave like screen and italics will be disabled.
|
||||||
$ infocmp "$screen_terminfo" | sed \
|
|
||||||
-e 's/^screen[^|]*|[^,]*,/screen-it|screen with italics support,/' \
|
To enable italics, create a new terminfo entry called "tmux" (some platforms
|
||||||
-e 's/%?%p1%t;3%/%?%p1%t;7%/' \
|
may already have this, you can check with "infocmp tmux"):
|
||||||
-e 's/smso=[^,]*,/smso=\\E[7m,/' \
|
|
||||||
-e 's/rmso=[^,]*,/rmso=\\E[27m,/' \
|
$ cat <<EOF|tic -x -
|
||||||
-e '$s/$/ sitm=\\E[3m, ritm=\\E[23m,/' > /tmp/screen.terminfo
|
tmux|tmux terminal multiplexer,
|
||||||
$ tic /tmp/screen.terminfo
|
ritm=\E[23m, rmso=\E[27m, sitm=\E[3m, smso=\E[7m, Ms@,
|
||||||
|
use=xterm+tmux, use=screen,
|
||||||
|
|
||||||
|
tmux-256color|tmux with 256 colors,
|
||||||
|
use=xterm+256setaf, use=tmux,
|
||||||
|
EOF
|
||||||
|
$
|
||||||
|
|
||||||
And tell tmux to use it in ~/.tmux.conf:
|
And tell tmux to use it in ~/.tmux.conf:
|
||||||
|
|
||||||
set -g default-terminal "screen-it"
|
set -g default-terminal "tmux"
|
||||||
|
|
||||||
If your terminal supports 256 colors, use:
|
If using urxvt, make sure you have an italics capable font enabled. for
|
||||||
|
example, add to ~/.Xdefaults:
|
||||||
$ screen_terminfo="screen-256color"
|
|
||||||
|
|
||||||
instead of "screen". See the FAQ entry about 256 colors support for more info.
|
|
||||||
Also note that tmux will still display reverse video on terminals that do not
|
|
||||||
support italics.
|
|
||||||
|
|
||||||
If your urxvt cannot display italics at all, make sure you have an italics
|
|
||||||
capable font enabled, for example, add to ~/.Xdefaults:
|
|
||||||
|
|
||||||
urxvt.italicFont: xft:Bitstream Vera Sans Mono:italic:autohint=true
|
urxvt.italicFont: xft:Bitstream Vera Sans Mono:italic:autohint=true
|
||||||
|
|
||||||
@@ -377,7 +394,7 @@ always (or ever) be added to the scrollback.
|
|||||||
You can make tmux use the normal screen by telling it that your terminal does
|
You can make tmux use the normal screen by telling it that your terminal does
|
||||||
not have an alternate screen. Put the following in ~/.tmux.conf:
|
not have an alternate screen. Put the following in ~/.tmux.conf:
|
||||||
|
|
||||||
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
|
set -ga terminal-overrides ',xterm*:smcup@:rmcup@'
|
||||||
|
|
||||||
Adjust if your $TERM does not start with xterm.
|
Adjust if your $TERM does not start with xterm.
|
||||||
|
|
||||||
@@ -397,4 +414,49 @@ Or the default window options:
|
|||||||
|
|
||||||
$ tmux -Lfoo -f/dev/null start\; show -gw
|
$ tmux -Lfoo -f/dev/null start\; show -gw
|
||||||
|
|
||||||
$Id$
|
* How do I copy a selection from tmux to the system's clipboard?
|
||||||
|
|
||||||
|
When running in xterm(1), tmux can automatically send copied text to the
|
||||||
|
clipboard. This is controlled by the set-clipboard option and also needs this
|
||||||
|
X resource to be set:
|
||||||
|
|
||||||
|
XTerm*disallowedWindowOps: 20,21,SetXprop
|
||||||
|
|
||||||
|
For rxvt-unicode (urxvt), there is an unofficial Perl extension here:
|
||||||
|
|
||||||
|
http://anti.teamidiot.de/static/nei/*/Code/urxvt/
|
||||||
|
|
||||||
|
Otherwise a key binding for copy mode using xclip (or xsel) works:
|
||||||
|
|
||||||
|
bind -temacs-copy C-y copy-pipe "xclip -i >/dev/null"
|
||||||
|
|
||||||
|
Or for inside and outside copy mode with the prefix key:
|
||||||
|
|
||||||
|
bind C-y run -b "tmux save-buffer - | xclip -i"
|
||||||
|
|
||||||
|
On OS X, look at the pbcopy(1) and pbpaste(1) commands.
|
||||||
|
|
||||||
|
* Why don't some commands work inside tmux on OS X?
|
||||||
|
|
||||||
|
Apple requires some undocumented, unsupported fiddling to allow commands that
|
||||||
|
interact with the GUI to work. Neither tmux itself nor most shells do this, so
|
||||||
|
an external program is required. This can be found here:
|
||||||
|
|
||||||
|
https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
|
||||||
|
|
||||||
|
Affected commands may include say(1), pbcopy(1), pbpaste(1) and ssh(1).
|
||||||
|
|
||||||
|
* Why do I see dots around a session when I attach to it?
|
||||||
|
|
||||||
|
tmux limits the size of the window to the smallest attached session. If
|
||||||
|
it didn't do this then it would be impossible to see the entire window.
|
||||||
|
The dots mark the size of the window tmux can display.
|
||||||
|
|
||||||
|
To avoid this, detach all other clients when attaching:
|
||||||
|
|
||||||
|
$ tmux attach -d
|
||||||
|
|
||||||
|
Or from inside tmux by detaching individual clients with C-b D or all
|
||||||
|
using:
|
||||||
|
|
||||||
|
C-b : attach -d
|
||||||
|
|||||||
1
ISSUE_TEMPLATE
Normal file
1
ISSUE_TEMPLATE
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Please read https://raw.githubusercontent.com/tmux/tmux/master/CONTRIBUTING
|
||||||
171
Makefile.am
171
Makefile.am
@@ -1,97 +1,92 @@
|
|||||||
# $Id$
|
# Makefile.am
|
||||||
|
|
||||||
# Obvious program stuff.
|
# Obvious program stuff.
|
||||||
bin_PROGRAMS = tmux
|
bin_PROGRAMS = tmux
|
||||||
dist_man1_MANS = tmux.1
|
CLEANFILES = tmux.1.mdoc tmux.1.man
|
||||||
|
|
||||||
# Distribution tarball options.
|
# Distribution tarball options.
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
CHANGES FAQ README TODO examples compat \
|
CHANGES FAQ README TODO COPYING example_tmux.conf compat/*.[ch] \
|
||||||
array.h compat.h tmux.h osdep-*.c
|
osdep-*.c mdoc2man.awk tmux.1
|
||||||
dist-hook:
|
dist-hook:
|
||||||
grep "^#found_debug=" configure
|
grep "^#enable_debug=" configure
|
||||||
find $(distdir) -name .svn -type d|xargs rm -Rf
|
|
||||||
|
|
||||||
# Preprocessor flags.
|
# Preprocessor flags.
|
||||||
CPPFLAGS += @XOPEN_DEFINES@
|
AM_CPPFLAGS += @XOPEN_DEFINES@ -DTMUX_CONF="\"$(sysconfdir)/tmux.conf\""
|
||||||
|
|
||||||
# glibc as usual does things ass-backwards and hides useful things by default,
|
# Additional object files.
|
||||||
# so everyone has to add this.
|
LDADD = $(LIBOBJS)
|
||||||
if IS_GLIBC
|
|
||||||
CFLAGS += -D_GNU_SOURCE
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Set flags for gcc. gcc4 whines abouts silly stuff so it needs slightly
|
# Set flags for gcc.
|
||||||
# different flags.
|
|
||||||
if IS_GCC
|
if IS_GCC
|
||||||
CFLAGS += -std=gnu99
|
AM_CFLAGS += -std=gnu99 -O2
|
||||||
if IS_DEBUG
|
if IS_DEBUG
|
||||||
CFLAGS += -O0 -g
|
AM_CFLAGS += -g
|
||||||
CFLAGS += -Wno-long-long -Wall -W -Wnested-externs -Wformat=2
|
AM_CFLAGS += -Wno-long-long -Wall -W -Wformat=2
|
||||||
CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
|
AM_CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
|
||||||
CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare
|
AM_CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare
|
||||||
CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align
|
AM_CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align
|
||||||
CFLAGS += -Wdeclaration-after-statement
|
AM_CFLAGS += -Wdeclaration-after-statement -Wno-pointer-sign -Wno-attributes
|
||||||
CPPFLAGS += -DDEBUG
|
AM_CFLAGS += -Wno-unused-result
|
||||||
else
|
AM_CPPFLAGS += -DDEBUG
|
||||||
CFLAGS += -O2
|
|
||||||
endif
|
|
||||||
if IS_GCC4
|
|
||||||
CPPFLAGS += -iquote. -I/usr/local/include
|
|
||||||
if IS_DEBUG
|
|
||||||
CFLAGS += -Wno-pointer-sign
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
CPPFLAGS += -I. -I- -I/usr/local/include
|
|
||||||
endif
|
endif
|
||||||
|
AM_CPPFLAGS += -iquote.
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Set flags for Solaris.
|
# Set flags for Solaris.
|
||||||
if IS_SUNOS
|
if IS_SUNOS
|
||||||
CPPFLAGS += -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS
|
if IS_GCC
|
||||||
|
AM_CPPFLAGS += -D_XPG6
|
||||||
|
else
|
||||||
|
AM_CPPFLAGS += -D_XPG4_2
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Set flags for Sun CC.
|
# Set flags for Sun CC.
|
||||||
if IS_SUNCC
|
if IS_SUNCC
|
||||||
CFLAGS += -erroff=E_EMPTY_DECLARATION
|
AM_CFLAGS += -erroff=E_EMPTY_DECLARATION
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Set _LINUX_SOURCE_COMPAT for AIX for malloc(0).
|
||||||
|
if IS_AIX
|
||||||
|
AM_CPPFLAGS += -D_LINUX_SOURCE_COMPAT=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Set flags for NetBSD.
|
||||||
|
if IS_NETBSD
|
||||||
|
AM_CPPFLAGS += -D_OPENBSD_SOURCE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# List of sources.
|
# List of sources.
|
||||||
dist_tmux_SOURCES = \
|
dist_tmux_SOURCES = \
|
||||||
|
alerts.c \
|
||||||
arguments.c \
|
arguments.c \
|
||||||
attributes.c \
|
attributes.c \
|
||||||
cfg.c \
|
cfg.c \
|
||||||
client.c \
|
client.c \
|
||||||
clock.c \
|
|
||||||
cmd-attach-session.c \
|
cmd-attach-session.c \
|
||||||
cmd-bind-key.c \
|
cmd-bind-key.c \
|
||||||
cmd-break-pane.c \
|
cmd-break-pane.c \
|
||||||
cmd-capture-pane.c \
|
cmd-capture-pane.c \
|
||||||
cmd-choose-buffer.c \
|
cmd-choose-buffer.c \
|
||||||
cmd-choose-client.c \
|
cmd-choose-client.c \
|
||||||
cmd-choose-list.c \
|
|
||||||
cmd-choose-tree.c \
|
cmd-choose-tree.c \
|
||||||
cmd-clear-history.c \
|
|
||||||
cmd-clock-mode.c \
|
|
||||||
cmd-command-prompt.c \
|
cmd-command-prompt.c \
|
||||||
cmd-confirm-before.c \
|
cmd-confirm-before.c \
|
||||||
cmd-copy-mode.c \
|
cmd-copy-mode.c \
|
||||||
cmd-delete-buffer.c \
|
|
||||||
cmd-detach-client.c \
|
cmd-detach-client.c \
|
||||||
cmd-display-message.c \
|
cmd-display-message.c \
|
||||||
cmd-display-panes.c \
|
cmd-display-panes.c \
|
||||||
cmd-find-window.c \
|
cmd-find-window.c \
|
||||||
cmd-has-session.c \
|
cmd-find.c \
|
||||||
cmd-if-shell.c \
|
cmd-if-shell.c \
|
||||||
cmd-join-pane.c \
|
cmd-join-pane.c \
|
||||||
cmd-kill-pane.c \
|
cmd-kill-pane.c \
|
||||||
cmd-kill-server.c \
|
cmd-kill-server.c \
|
||||||
cmd-kill-session.c \
|
cmd-kill-session.c \
|
||||||
cmd-kill-window.c \
|
cmd-kill-window.c \
|
||||||
cmd-link-window.c \
|
|
||||||
cmd-list-buffers.c \
|
cmd-list-buffers.c \
|
||||||
cmd-list-clients.c \
|
cmd-list-clients.c \
|
||||||
cmd-list-commands.c \
|
|
||||||
cmd-list-keys.c \
|
cmd-list-keys.c \
|
||||||
cmd-list-panes.c \
|
cmd-list-panes.c \
|
||||||
cmd-list-sessions.c \
|
cmd-list-sessions.c \
|
||||||
@@ -118,33 +113,31 @@ dist_tmux_SOURCES = \
|
|||||||
cmd-select-pane.c \
|
cmd-select-pane.c \
|
||||||
cmd-select-window.c \
|
cmd-select-window.c \
|
||||||
cmd-send-keys.c \
|
cmd-send-keys.c \
|
||||||
cmd-server-info.c \
|
|
||||||
cmd-set-buffer.c \
|
cmd-set-buffer.c \
|
||||||
cmd-set-environment.c \
|
cmd-set-environment.c \
|
||||||
|
cmd-set-hook.c \
|
||||||
cmd-set-option.c \
|
cmd-set-option.c \
|
||||||
cmd-show-environment.c \
|
cmd-show-environment.c \
|
||||||
cmd-show-messages.c \
|
cmd-show-messages.c \
|
||||||
cmd-show-options.c \
|
cmd-show-options.c \
|
||||||
cmd-source-file.c \
|
cmd-source-file.c \
|
||||||
cmd-split-window.c \
|
cmd-split-window.c \
|
||||||
cmd-start-server.c \
|
|
||||||
cmd-string.c \
|
cmd-string.c \
|
||||||
cmd-suspend-client.c \
|
|
||||||
cmd-swap-pane.c \
|
cmd-swap-pane.c \
|
||||||
cmd-swap-window.c \
|
cmd-swap-window.c \
|
||||||
cmd-switch-client.c \
|
cmd-switch-client.c \
|
||||||
cmd-unbind-key.c \
|
cmd-unbind-key.c \
|
||||||
cmd-unlink-window.c \
|
|
||||||
cmd-wait-for.c \
|
cmd-wait-for.c \
|
||||||
cmd.c \
|
cmd.c \
|
||||||
colour.c \
|
colour.c \
|
||||||
control.c \
|
compat.h \
|
||||||
control-notify.c \
|
control-notify.c \
|
||||||
|
control.c \
|
||||||
environ.c \
|
environ.c \
|
||||||
format.c \
|
format.c \
|
||||||
grid-cell.c \
|
|
||||||
grid-view.c \
|
grid-view.c \
|
||||||
grid.c \
|
grid.c \
|
||||||
|
hooks.c \
|
||||||
input-keys.c \
|
input-keys.c \
|
||||||
input.c \
|
input.c \
|
||||||
job.c \
|
job.c \
|
||||||
@@ -154,24 +147,26 @@ dist_tmux_SOURCES = \
|
|||||||
layout-set.c \
|
layout-set.c \
|
||||||
layout.c \
|
layout.c \
|
||||||
log.c \
|
log.c \
|
||||||
mode-key.c \
|
|
||||||
names.c \
|
names.c \
|
||||||
notify.c \
|
notify.c \
|
||||||
options-table.c \
|
options-table.c \
|
||||||
options.c \
|
options.c \
|
||||||
paste.c \
|
paste.c \
|
||||||
|
proc.c \
|
||||||
|
pty.c \
|
||||||
resize.c \
|
resize.c \
|
||||||
screen-redraw.c \
|
screen-redraw.c \
|
||||||
screen-write.c \
|
screen-write.c \
|
||||||
screen.c \
|
screen.c \
|
||||||
server-client.c \
|
server-client.c \
|
||||||
server-fn.c \
|
server-fn.c \
|
||||||
server-window.c \
|
|
||||||
server.c \
|
server.c \
|
||||||
session.c \
|
session.c \
|
||||||
signal.c \
|
signal.c \
|
||||||
status.c \
|
status.c \
|
||||||
|
style.c \
|
||||||
tmux.c \
|
tmux.c \
|
||||||
|
tmux.h \
|
||||||
tty-acs.c \
|
tty-acs.c \
|
||||||
tty-keys.c \
|
tty-keys.c \
|
||||||
tty-term.c \
|
tty-term.c \
|
||||||
@@ -182,67 +177,29 @@ dist_tmux_SOURCES = \
|
|||||||
window-copy.c \
|
window-copy.c \
|
||||||
window.c \
|
window.c \
|
||||||
xmalloc.c \
|
xmalloc.c \
|
||||||
|
xmalloc.h \
|
||||||
xterm-keys.c
|
xterm-keys.c
|
||||||
nodist_tmux_SOURCES = osdep-@PLATFORM@.c
|
nodist_tmux_SOURCES = osdep-@PLATFORM@.c
|
||||||
|
|
||||||
# Pile in all the compat/ stuff that is needed.
|
# Add compat file for forkpty.
|
||||||
if NO_FORKPTY
|
if NEED_FORKPTY
|
||||||
nodist_tmux_SOURCES += compat/forkpty-@PLATFORM@.c
|
nodist_tmux_SOURCES += compat/forkpty-@PLATFORM@.c
|
||||||
endif
|
endif
|
||||||
if NO_IMSG
|
|
||||||
nodist_tmux_SOURCES += compat/imsg.c compat/imsg-buffer.c
|
# Add compat file for utf8proc.
|
||||||
endif
|
if HAVE_UTF8PROC
|
||||||
if NO_CLOSEFROM
|
nodist_tmux_SOURCES += compat/utf8proc.c
|
||||||
nodist_tmux_SOURCES += compat/closefrom.c
|
|
||||||
endif
|
|
||||||
if NO_DAEMON
|
|
||||||
nodist_tmux_SOURCES += compat/daemon.c
|
|
||||||
endif
|
|
||||||
if NO_SETENV
|
|
||||||
nodist_tmux_SOURCES += compat/setenv.c
|
|
||||||
endif
|
|
||||||
if NO_STRLCAT
|
|
||||||
nodist_tmux_SOURCES += compat/strlcat.c
|
|
||||||
endif
|
|
||||||
if NO_STRLCPY
|
|
||||||
nodist_tmux_SOURCES += compat/strlcpy.c
|
|
||||||
endif
|
|
||||||
if NO_ASPRINTF
|
|
||||||
nodist_tmux_SOURCES += compat/asprintf.c
|
|
||||||
endif
|
|
||||||
if NO_FGETLN
|
|
||||||
nodist_tmux_SOURCES += compat/fgetln.c
|
|
||||||
endif
|
|
||||||
if NO_GETOPT
|
|
||||||
nodist_tmux_SOURCES += compat/getopt.c
|
|
||||||
endif
|
|
||||||
if NO_STRCASESTR
|
|
||||||
nodist_tmux_SOURCES += compat/strcasestr.c
|
|
||||||
endif
|
|
||||||
if NO_STRSEP
|
|
||||||
nodist_tmux_SOURCES += compat/strsep.c
|
|
||||||
endif
|
|
||||||
if NO_VIS
|
|
||||||
nodist_tmux_SOURCES += compat/vis.c compat/unvis.c
|
|
||||||
endif
|
|
||||||
if NO_STRTONUM
|
|
||||||
nodist_tmux_SOURCES += compat/strtonum.c
|
|
||||||
endif
|
|
||||||
if NO_B64_NTOP
|
|
||||||
nodist_tmux_SOURCES += compat/b64_ntop.c
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Update SF web site.
|
# Install tmux.1 in the right format.
|
||||||
upload-index.html: update-index.html
|
install-exec-hook:
|
||||||
scp www/index.html www/main.css www/images/*.png \
|
if test x@MANFORMAT@ = xmdoc; then \
|
||||||
${USER},tmux@web.sf.net:/home/groups/t/tm/tmux/htdocs
|
sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" $(srcdir)/tmux.1 \
|
||||||
rm -f www/index.html www/images/small-*
|
>$(srcdir)/tmux.1.mdoc; \
|
||||||
|
else \
|
||||||
update-index.html:
|
sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" $(srcdir)/tmux.1| \
|
||||||
(cd www/images && \
|
$(AWK) -f$(srcdir)/mdoc2man.awk >$(srcdir)/tmux.1.man; \
|
||||||
rm -f small-* && \
|
fi
|
||||||
for i in *.png; do \
|
$(mkdir_p) $(DESTDIR)$(mandir)/man1
|
||||||
convert "$$i" -resize 200x150 "small-$$i"; \
|
$(INSTALL_DATA) $(srcdir)/tmux.1.@MANFORMAT@ \
|
||||||
done \
|
$(DESTDIR)$(mandir)/man1/tmux.1
|
||||||
)
|
|
||||||
sed "s/%%VERSION%%/${VERSION}/g" www/index.html.in >www/index.html
|
|
||||||
|
|||||||
61
README
61
README
@@ -4,57 +4,70 @@ 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 release runs on OpenBSD, FreeBSD, NetBSD, Linux and OS X and may still
|
This release runs on OpenBSD, FreeBSD, NetBSD, Linux, OS X and Solaris.
|
||||||
run on Solaris and AIX (although they haven't been tested in a while).
|
|
||||||
|
|
||||||
Since the 1.2 release tmux depends on libevent. Download it from:
|
tmux depends on libevent 2.x. Download it from:
|
||||||
|
|
||||||
http://www.monkey.org/~provos/libevent/
|
http://libevent.org
|
||||||
|
|
||||||
To build tmux from a release tarball, do:
|
It also depends on ncurses, available from:
|
||||||
|
|
||||||
|
http://invisible-island.net/ncurses/
|
||||||
|
|
||||||
|
To build and install tmux from a release tarball, use:
|
||||||
|
|
||||||
$ ./configure && make
|
$ ./configure && make
|
||||||
$ sudo make install
|
$ sudo make install
|
||||||
|
|
||||||
|
tmux can use the utempter library to update utmp(5), if it is installed - run
|
||||||
|
configure with --enable-utempter to enable this.
|
||||||
|
|
||||||
To get and build the latest from version control:
|
To get and build the latest from version control:
|
||||||
|
|
||||||
$ git clone git://git.code.sf.net/p/tmux/tmux-code tmux
|
$ git clone https://github.com/tmux/tmux.git
|
||||||
$ cd tmux
|
$ cd tmux
|
||||||
$ sh autogen.sh
|
$ sh autogen.sh
|
||||||
$ ./configure && make
|
$ ./configure && make
|
||||||
|
|
||||||
For more information see https://sourceforge.net/scm/?type=git&group_id=200378
|
For more information see http://git-scm.com. Patches should be sent by email to
|
||||||
and http://git-scm.com. Patches should be sent by email to the mailing list at
|
the mailing list at tmux-users@googlegroups.com.
|
||||||
tmux-users@lists.sourceforge.net.
|
|
||||||
|
|
||||||
For documentation on using tmux, see the tmux.1 manpage. It can be viewed from
|
For documentation on using tmux, see the tmux.1 manpage. It can be viewed from
|
||||||
the source tree with:
|
the source tree with:
|
||||||
|
|
||||||
$ nroff -mdoc tmux.1|less
|
$ nroff -mdoc tmux.1|less
|
||||||
|
|
||||||
Some common questions are answered in the FAQ file and a more extensive (but
|
Some common questions are answered in the FAQ file, a rough todo list is in the
|
||||||
slightly out of date) guide is available in the OpenBSD FAQ at
|
TODO file and an example configuration in example_tmux.conf.
|
||||||
http://www.openbsd.org/faq/faq7.html#tmux. A rough todo list is in the TODO
|
|
||||||
file and some example configurations and a Vim syntax file are in the examples
|
A vim(1) syntax file is available at:
|
||||||
directory.
|
|
||||||
|
https://github.com/ericpruitt/tmux.vim
|
||||||
|
https://raw.githubusercontent.com/ericpruitt/tmux.vim/master/vim/syntax/tmux.vim
|
||||||
|
|
||||||
|
And a bash(1) completion file at:
|
||||||
|
|
||||||
|
https://github.com/imomaliev/tmux-bash-completion
|
||||||
|
|
||||||
For debugging, running tmux with -v or -vv will generate server and client log
|
For debugging, running tmux with -v or -vv will generate server and client log
|
||||||
files in the current directory.
|
files in the current directory.
|
||||||
|
|
||||||
tmux mailing lists are available. Visit:
|
tmux mailing lists are available. For general discussion and bug reports:
|
||||||
|
|
||||||
https://sourceforge.net/mail/?group_id=200378
|
https://groups.google.com/forum/#!forum/tmux-users
|
||||||
|
|
||||||
|
And for Git commit emails:
|
||||||
|
|
||||||
|
https://groups.google.com/forum/#!forum/tmux-git
|
||||||
|
|
||||||
|
Subscribe by sending an email to <tmux-users+subscribe@googlegroups.com>.
|
||||||
|
|
||||||
Bug reports, feature suggestions and especially code contributions are most
|
Bug reports, feature suggestions and especially code contributions are most
|
||||||
welcome. Please send by email to:
|
welcome. Please send by email to:
|
||||||
|
|
||||||
tmux-users@lists.sourceforge.net
|
tmux-users@googlegroups.com
|
||||||
|
|
||||||
This file and the CHANGES, FAQ and TODO files are licensed under the ISC
|
This file and the CHANGES, FAQ, SYNCING and TODO files are licensed under the
|
||||||
license. Files under examples/ remain copyright their authors unless otherwise
|
ISC license. All other files have a license and copyright notice at their start.
|
||||||
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.
|
|
||||||
|
|
||||||
-- Nicholas Marriott <nicm@users.sf.net>
|
-- Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
|
|
||||||
$Id$
|
|
||||||
|
|||||||
86
SYNCING
86
SYNCING
@@ -1,10 +1,10 @@
|
|||||||
Preamble
|
Preamble
|
||||||
========
|
========
|
||||||
|
|
||||||
Tmux on SourceForge has two git repositories [1] "tmux-code" and "tmux-openbsd".
|
Tmux portable relies on repositories "tmux" and "tmux-openbsd".
|
||||||
Here's a description of them:
|
Here's a description of them:
|
||||||
|
|
||||||
* "tmux-code" is the portable version, the one which contains code for other
|
* "tmux" is the portable version, the one which contains code for other
|
||||||
operating systems, and autotools, etc., which isn't found or needed in the
|
operating systems, and autotools, etc., which isn't found or needed in the
|
||||||
OpenBSD base system.
|
OpenBSD base system.
|
||||||
|
|
||||||
@@ -17,9 +17,6 @@ repository will take at least that long to appear in this git repository.
|
|||||||
(It might take longer, depending on the CVS mirror used to import the
|
(It might take longer, depending on the CVS mirror used to import the
|
||||||
OpenBSD code).
|
OpenBSD code).
|
||||||
|
|
||||||
It is assumed that the person doing the sync has read/write access to the
|
|
||||||
tmux-code repository on SourceForge already.
|
|
||||||
|
|
||||||
If you've never used git before, git tracks meta-data about the committer
|
If you've never used git before, git tracks meta-data about the committer
|
||||||
and the author, as part of a commit, hence:
|
and the author, as part of a commit, hence:
|
||||||
|
|
||||||
@@ -37,11 +34,11 @@ this information has ever been set before.
|
|||||||
Cloning repositories
|
Cloning repositories
|
||||||
====================
|
====================
|
||||||
|
|
||||||
This involves having both tmux-code and tmux-openbsd cloned, as in:
|
This involves having both tmux and tmux-openbsd cloned, as in:
|
||||||
|
|
||||||
% cd /some/where/useful
|
% cd /some/where/useful
|
||||||
% git clone ssh://${USER}@git.code.sf.net/p/tmux/tmux
|
% git clone https://github.com/tmux/tmux.git
|
||||||
% git clone ssh://${USER}@git.code.sf.net/p/tmux/tmux-openbsd
|
% git clone https://github.com/ThomasAdam/tmux-openbsd.git
|
||||||
|
|
||||||
Note that you do not need additional checkouts to manage the sync -- an
|
Note that you do not need additional checkouts to manage the sync -- an
|
||||||
existing clone of either repositories will suffice. So if you already have
|
existing clone of either repositories will suffice. So if you already have
|
||||||
@@ -50,56 +47,56 @@ these checkouts existing, skip that.
|
|||||||
Adding in git-remotes
|
Adding in git-remotes
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
Because the portable "tmux-code" git repository and the "tmux-openbsd"
|
Because the portable "tmux" git repository and the "tmux-openbsd"
|
||||||
repository do not inherently share any history between each other, the
|
repository do not inherently share any history between each other, the
|
||||||
history has been faked between them. This "faking of history" is something
|
history has been faked between them. This "faking of history" is something
|
||||||
which has to be told to git for the purposes of comparing the "tmux" and
|
which has to be told to git for the purposes of comparing the "tmux" and
|
||||||
"tmux-openbsd" repositories for syncing. To do this, we must reference the
|
"tmux-openbsd" repositories for syncing. To do this, we must reference the
|
||||||
clone of the "tmux-openbsd" repository from the "tmux-code" repository, as
|
clone of the "tmux-openbsd" repository from the "tmux" repository, as
|
||||||
shown by the following command:
|
shown by the following command:
|
||||||
|
|
||||||
% cd /path/to/tmux-code
|
% cd /path/to/tmux
|
||||||
% git remote add obsd-tmux file:///path/to/tmux-openbsd
|
% git remote add obsd-tmux file:///path/to/tmux-openbsd
|
||||||
|
|
||||||
So that now, the remote "obsd-tmux" can be used to reference branches and
|
So that now, the remote "obsd-tmux" can be used to reference branches and
|
||||||
commits from the "tmux-openbsd" repository, but from the context of the
|
commits from the "tmux-openbsd" repository, but from the context of the
|
||||||
portable "tmux-code" repository, which makes sense because it's the "tmux"
|
portable "tmux" repository, which makes sense because it's the "tmux"
|
||||||
repository which will have the updates applied to them.
|
repository which will have the updates applied to them.
|
||||||
|
|
||||||
Fetching updates
|
Fetching updates
|
||||||
================
|
================
|
||||||
|
|
||||||
To ensure the latest commits from "tmux-openbsd" can be found from within
|
To ensure the latest commits from "tmux-openbsd" can be found from within
|
||||||
"tmux-code", we have to ensure the "master" branch from "tmux-openbsd" is
|
"tmux", we have to ensure the "master" branch from "tmux-openbsd" is
|
||||||
up-to-date first, and then reference that update in "tmux-code", as in:
|
up-to-date first, and then reference that update in "tmux", as in:
|
||||||
|
|
||||||
% cd /path/to/tmux-openbsd
|
% cd /path/to/tmux-openbsd
|
||||||
% git checkout master
|
% git checkout master
|
||||||
% git pull
|
% git pull
|
||||||
|
|
||||||
Then back in "tmux-code":
|
Then back in "tmux":
|
||||||
|
|
||||||
% cd /path/to/tmux-code
|
% cd /path/to/tmux
|
||||||
% git fetch obsd-tmux-code
|
% git fetch obsd-tmux
|
||||||
|
|
||||||
Creating the necessary branches
|
Creating the necessary branches
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
Now that "tmux-code" can see commits and branches from "tmux-openbsd" by way
|
Now that "tmux" can see commits and branches from "tmux-openbsd" by way
|
||||||
of the remote name "obsd-tmux", we can now create the master branch from
|
of the remote name "obsd-tmux", we can now create the master branch from
|
||||||
"tmux-openbsd" in the "tmux-code" repository:
|
"tmux-openbsd" in the "tmux" repository:
|
||||||
|
|
||||||
% git checkout -b obsd-master obsd-tmux/master
|
% git checkout -b obsd-master obsd-tmux/master
|
||||||
|
|
||||||
Adding in the fake history points
|
Adding in the fake history points
|
||||||
=================================
|
=================================
|
||||||
|
|
||||||
To tie both the "master" branch from "tmux-code" and the "obsd-master"
|
To tie both the "master" branch from "tmux" and the "obsd-master"
|
||||||
branch from "tmux-openbsd" together, the fake history points added to the
|
branch from "tmux-openbsd" together, the fake history points added to the
|
||||||
"tmux-code" repository need to be added. To do this, we must add an
|
"tmux" repository need to be added. To do this, we must add an
|
||||||
additional refspec line, as in:
|
additional refspec line, as in:
|
||||||
|
|
||||||
% cd /path/to/tmux-code
|
% cd /path/to/tmux
|
||||||
% git config --add remote.origin.fetch '+refs/replace/*:refs/replace/*'
|
% git config --add remote.origin.fetch '+refs/replace/*:refs/replace/*'
|
||||||
% git fetch origin
|
% git fetch origin
|
||||||
|
|
||||||
@@ -110,7 +107,7 @@ Make sure the "master" branch is checked out:
|
|||||||
|
|
||||||
% git checkout master
|
% git checkout master
|
||||||
|
|
||||||
The following will show commits on OpenBSD not yet synched with "tmux-code":
|
The following will show commits on OpenBSD not yet synched with "tmux":
|
||||||
|
|
||||||
% git log master..obsd-master
|
% git log master..obsd-master
|
||||||
|
|
||||||
@@ -118,7 +115,7 @@ From there, merge the result in, fixing up any conflicts which might arise.
|
|||||||
|
|
||||||
% git merge obsd-master
|
% git merge obsd-master
|
||||||
|
|
||||||
Then ensure things look correct by BULDING the result of that sync:
|
Then ensure things look correct by BUILDING the result of that sync:
|
||||||
|
|
||||||
% make clean && ./autogen.sh && ./configure && make
|
% make clean && ./autogen.sh && ./configure && make
|
||||||
|
|
||||||
@@ -131,10 +128,19 @@ And if happy:
|
|||||||
|
|
||||||
% git push origin master
|
% git push origin master
|
||||||
|
|
||||||
|
Keeping an eye on libutil in OpenBSD
|
||||||
|
====================================
|
||||||
|
|
||||||
|
A lot of the compat/ code in tmux comes from libutil, especially imsg.
|
||||||
|
Sometimes the API can change, etc., which might cause interesting problems
|
||||||
|
trying to run the portable version of tmux. It's worth checking
|
||||||
|
periodically for any changes to libutil in OpenBSD and syncing those files
|
||||||
|
to compat/ as and when appropriate.
|
||||||
|
|
||||||
Release tmux for next version
|
Release tmux for next version
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
1. Comment the "found_debug=yes" line in configure.ac, since releases
|
1. Comment the "enable_debug=yes" line in configure.ac, since releases
|
||||||
don't have debugging enabled, otherwise make(1) aborts when
|
don't have debugging enabled, otherwise make(1) aborts when
|
||||||
preparing the distribution.
|
preparing the distribution.
|
||||||
|
|
||||||
@@ -145,30 +151,26 @@ Release tmux for next version
|
|||||||
|
|
||||||
3. Tag with:
|
3. Tag with:
|
||||||
|
|
||||||
% git tag -a 1.X
|
% git tag -a 2.X
|
||||||
|
|
||||||
Where "1.X" is the next version.
|
Where "2.X" is the next version.
|
||||||
|
|
||||||
Push the tag out with:
|
Push the tag out with:
|
||||||
|
|
||||||
% git push 1.X
|
% git push 2.X
|
||||||
|
|
||||||
4. Build the tarball with make dist. Now that it's using autoconf there
|
4. Build the tarball with 'make dist'.
|
||||||
shouldn't be any weird files (such as the original and rejection files
|
|
||||||
from patch(1)) but it doesn't hurt taking a quick look at it.
|
|
||||||
|
|
||||||
5. Split the release changes into a new file. This should be named
|
5. Check the tarball. If it's good, go here to select the tag just pushed:
|
||||||
tmux-$VERSION-readme to make sourceforge show it automagically in specific
|
|
||||||
parts of the project page.
|
|
||||||
|
|
||||||
6. Upload the tarball and the above file. Make the tarball the default
|
https://github.com/tmux/tmux/tags
|
||||||
download by selecting all operating systems under the file details.
|
|
||||||
|
|
||||||
7. Run make update-index.html upload-index.html to replace %%VERSION%%.
|
Click the "Add release notes", upload the tarball and add a link in the
|
||||||
|
description field to the CHANGES file.
|
||||||
|
|
||||||
8. Bump version in configure.ac and uncomment "found_debug=yes" to create
|
7. Clone the tmux.github.io repository, and change the RELEASE version in
|
||||||
a debug build by default.
|
the Makefile. Commit it, and run 'make' to replace %%VERSION%%. Push
|
||||||
|
the result out.
|
||||||
|
|
||||||
9. Update freshmeat.
|
8. Bump version in tmux/tmux.git configure.ac and uncomment "enable_debug=yes" to
|
||||||
|
create a debug build by default.
|
||||||
[1] https://sourceforge.net/p/tmux/_list/git
|
|
||||||
|
|||||||
261
TODO
261
TODO
@@ -1,155 +1,122 @@
|
|||||||
NOTES
|
- command bits and pieces:
|
||||||
=====
|
* allow multiple targets: fnmatch for -t/-c, for example detach all
|
||||||
|
clients with -t*
|
||||||
|
* add -c for new-session like new-window
|
||||||
|
* ' and " should be parsed the same (eg "\e" vs '\e') in config
|
||||||
|
and command prompt
|
||||||
|
* last-pane across sessions
|
||||||
|
* resize-pane -p to match split-window -p
|
||||||
|
* flag to wait-for to have a timeout and/or to stop waiting when the
|
||||||
|
client gets a signal
|
||||||
|
|
||||||
This file describes rough notes regarding ideas for potential future tmux
|
- make command sequences more usable
|
||||||
development. It's not necessarily guaranteed that items in this TODO file
|
* don't require space after ;
|
||||||
will ever get implemented.
|
* options for error handling: && and ||?
|
||||||
|
|
||||||
It is asked therefore, that anyone thinking of undertaking a task in this
|
- options bits and pieces:
|
||||||
TODO file, email tmux-users@lists.sf.net to discuss the feature.
|
* way to set socket path from config file
|
||||||
|
|
||||||
Thie file is split up between tmux user interface (UI) issues, and terminal
|
- format improvements:
|
||||||
compatibility issues.
|
* option to quote format (#{q:session_name})
|
||||||
|
* some way to pad # stuff with spaces
|
||||||
|
* formats to show if a window is linked into multiple sessions, into
|
||||||
|
multiple attached sessions, and is the active window in multiple
|
||||||
|
attached sessions?
|
||||||
|
|
||||||
TMUX UI ISSUES
|
- choose mode improvements:
|
||||||
==============
|
* choose-pane command (augment choose-tree to do this?)
|
||||||
|
* flag to choose-* for sort order
|
||||||
|
* two choices (first one then second, for swap-pane and join-pane)
|
||||||
|
* choose modes should ditch the key bindings and just have fixed keys, and
|
||||||
|
be more customized to their purpose (d to delete a buffer for choose-buffer,
|
||||||
|
a preview of buffer contents, etc)
|
||||||
|
|
||||||
|
- improve monitor-*:
|
||||||
|
* straighten out rules for multiple clients
|
||||||
|
* think about what happens across sessions
|
||||||
|
* monitor changes within a region
|
||||||
|
* perhaps monitor /all/ panes in the window not just one
|
||||||
|
|
||||||
|
- improve mouse support:
|
||||||
|
* bind commands to mouse in different areas?
|
||||||
|
* commands executed when clicking on a pattern (URL)
|
||||||
|
|
||||||
- implicitly add exec to the commands for new windows (switch to disable it)?
|
|
||||||
- bring back detach-session to detach all clients on a session?
|
|
||||||
- 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
|
|
||||||
in $x time
|
|
||||||
- flags to centre screen in window
|
|
||||||
- activity/bell should be per-window not per-link? what if it is cur win in
|
|
||||||
session not being watched?
|
|
||||||
- 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
|
|
||||||
- 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?
|
|
||||||
- would be nice to be able to use "--" to mark start of command w/ neww etc
|
|
||||||
to avoid quoting
|
|
||||||
- make command sequences more usable: don't require space after ;, handle
|
|
||||||
errors better
|
|
||||||
- choice and more mode would be better per client than per window?
|
|
||||||
- hooks to which commands may be attached, for example: tmux add-hook
|
|
||||||
"new-session" if-shell "[ -e $HOME/.tmux-session.conf ]" source-file
|
|
||||||
$HOME/.tmux-session.conf
|
|
||||||
- way to set socket path from config file
|
|
||||||
- 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
|
|
||||||
- up-pane/down-pane/swap-pane -U/swap-pane -D vs next-*/previous-*
|
|
||||||
- split-window -> split-pane??
|
|
||||||
- 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)
|
|
||||||
-- idea of a "view" onto a window, need base x/y offsets for redraw
|
|
||||||
- commands should be able to succeed or fail and have || or && for command
|
|
||||||
lists
|
|
||||||
- some way to keep a command running continually and just use its last line of
|
|
||||||
output
|
|
||||||
- UTF-8 to a non-UTF-8 terminal should not be able to balls up
|
|
||||||
the terminal - www/ruby-addressable; make regress
|
|
||||||
- support esc-esc to quit in modes
|
|
||||||
- fix ctrl+F1-F4 output. to what?
|
|
||||||
- better utf8 support: window names, prompt input, message display
|
|
||||||
- option to move copy mode indicator into status line
|
|
||||||
- selection behaviour closer to vi in vi mode
|
|
||||||
- live update: server started with -U connects to server, requests sessions and
|
|
||||||
windows, receives fds
|
|
||||||
- sort out inheriting config from shell on new sessions/windows:
|
|
||||||
should pick up default-path/termios/etc from client if possible,
|
|
||||||
else leave empty/default
|
|
||||||
- link panes into multiple windows
|
|
||||||
- bells should be passed between sessions with visual-bell etc
|
|
||||||
sequence until its shell exits, to allow them to be used from the config file
|
|
||||||
- better session sharing: create-socket command to create socket somewhere (-r
|
|
||||||
flag for readonly)
|
|
||||||
- multiline status line (no?)
|
|
||||||
- support title stack, both internally and externally
|
|
||||||
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=1149299+0+archive/2010/freebsd-questions/20100207.freebsd-questions
|
|
||||||
- some way to pad # stuff with spaces, #!2T maybe
|
|
||||||
- a binding to "scroll down and exit at bottom" copy mode
|
|
||||||
- some way to pass keystrokes in copy mode through to underlying window. why?
|
|
||||||
- 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
|
|
||||||
- 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)
|
|
||||||
- bind commands to key sequences? -- make it so ALL keys go through a table,
|
|
||||||
first an implicit table in which C-b is the only default binding to a
|
|
||||||
command that says "next key from $othertable" and so on. means -n can
|
|
||||||
go away as well
|
|
||||||
- monitor, bell etc should monitor /all/ panes in the window not just one
|
|
||||||
- a history of commands that can be reversed (reverse member of each command,
|
|
||||||
and a buffer)
|
|
||||||
- info() when changing to same window
|
|
||||||
- way to add dest for break-pane; maybe some easier way to unbreak-pane
|
|
||||||
- case insensitive searching
|
|
||||||
- incremental searching in copy mode.
|
|
||||||
- configurable borders and empty space filler for when panes < window?
|
|
||||||
- mouse-select-pane will screw up with !MODE_MOUSE_STANDARD (it sets the
|
|
||||||
flag on w/o checking the others before calling tty_update_mode)
|
|
||||||
- pass shell commands as argv rather than strings, allow them to be specified
|
|
||||||
in commands without quotes
|
|
||||||
- named buffers and allow gaps in the stack
|
|
||||||
- monitor-activity is broken in several ways with multiple clients
|
|
||||||
- monitor-activity should be more powerful (eg set a region)
|
|
||||||
- maybe a way to put pane names instead of window names in status line
|
|
||||||
- support for borderless panes
|
|
||||||
- wait-for command 20130222153957.GY6782@yelena.nicm.ath.cx
|
|
||||||
- last-pane across sessions
|
|
||||||
- panes should have names like windows
|
|
||||||
- command-prompt doesn't work if made read-only. why?
|
|
||||||
- option to quote format eg #{session_name:quoted}
|
|
||||||
- formats need conditions for >0 (for #P)
|
|
||||||
- fetch full command line on !Linux, and add option to strip prefixes
|
|
||||||
such as "sh " "/bin/sh " etc etc
|
|
||||||
- synchronize-windows option
|
|
||||||
- append to buffer in copy mode
|
|
||||||
- way to paste w/o trailing whitespace
|
|
||||||
- flag to switch-client to switch all clients
|
|
||||||
- history of layouts and undo/redo flags to selectl
|
|
||||||
- way to tag a layout as a number/name
|
|
||||||
- optimize pane redraws, 20120318184853.GK10965@yelena.nicm.ath.cx
|
|
||||||
- support multibyte key strings
|
|
||||||
- allow commands to be executed when certain patterns in a screen
|
|
||||||
are clicked on with the mouse
|
|
||||||
- flag to make next/previous commands skip a window
|
|
||||||
- way to do tmux command/run-shell from mode keys
|
|
||||||
- send command to all windows
|
|
||||||
- choose-pane command (augment choose-tree to do this?)
|
|
||||||
- choose-mode and copy-mode are very similar. Perhaps make choose-mode a subset
|
|
||||||
of copy-mode in that it inherits key-bindings and other traits but not all
|
|
||||||
- add -c for new-session like new-window
|
|
||||||
- flag to choose-* for sort order (eg sort windows/sessions/clients by last
|
|
||||||
used time) - perhaps using formats (but what about numeric sort)?
|
|
||||||
- instead of separate window and session options, just one master options list
|
|
||||||
with each option having a type (window or session), then options on window,
|
|
||||||
on session, and global. for window options we look window->session->global,
|
|
||||||
and for session we look session->global
|
|
||||||
- maybe keep last layout + size around and if size reverts just put it back
|
|
||||||
- way to set hints/limits about pane size for resizing
|
|
||||||
- revamp layouts: they are too complicated, should be more closely integrated,
|
|
||||||
should support hints, layout sets should just be a special case of custom
|
|
||||||
layouts, and we should support panes that are not attached to a cell at
|
|
||||||
all. this could be the time to introduce panelink to replace layout_cell
|
|
||||||
- run-shell/if-shell should support formats
|
|
||||||
- attach should take a pane and select it as well as attaching
|
|
||||||
- attach should have a flag to create session if it doesn't exist. or better
|
|
||||||
new a flag to attach it
|
|
||||||
|
|
||||||
TERMINAL ISSUES
|
- copy/paste improvements:
|
||||||
================
|
* paste w/o trailing whitespace
|
||||||
|
* command to toggle selection not to move it in copy-mode
|
||||||
|
* regex searching
|
||||||
|
* searching in copy mode should unwrap lines, so if you search for "foobar"
|
||||||
|
then it should be found even if it is now "foo\nbar" (if the WRAP flag
|
||||||
|
is set on the line)
|
||||||
|
* capture-pane option to preserve spaces but not join lines
|
||||||
|
* improve word and line selection in copy mode (for example when dragging
|
||||||
|
it should select by word. compare how xterm works. GitHub issue 682)
|
||||||
|
|
||||||
- use a better termcap internally instead of screen, perhaps xterm
|
- layout stuff
|
||||||
- clear window title on exit (see using xterm title stack)
|
* way to tag a layout as a number/name
|
||||||
- get it passing all the vttest tests that don't require resizing the terminal
|
* maybe keep last layout + size around and if size reverts just put it
|
||||||
- support for bce
|
back
|
||||||
- use screen-256color when started on 256 colour terminal?
|
* revamp layouts: they are too complicated, should be more closely
|
||||||
* We need a tmux terminfo entry to document the extensions we are using in
|
integrated, should support hints, layout sets should just be a
|
||||||
upstream terminfo. Must NOT change (only add or remove) anything from
|
special case of custom layouts, and we should support panes that are
|
||||||
TERM=screen so we can fallback!
|
not attached to a cell at all. this could be the time to introduce
|
||||||
|
panelink to replace layout_cell
|
||||||
|
* way to set hints/limits about pane size for resizing
|
||||||
|
* panning over window (window larger than visible)
|
||||||
|
* a mode where one application can cross two panes (ie x|y, width =
|
||||||
|
COLUMNS/2 but height = ROWS * 2)
|
||||||
|
* separate active panes for different clients
|
||||||
|
|
||||||
|
- code cleanup
|
||||||
|
* instead of separate window and session options, just one master
|
||||||
|
options list with each option having a type (window or session), then
|
||||||
|
options on window, on session, and global. for window options we look
|
||||||
|
window->session->global, and for session we look session->global.
|
||||||
|
problem: what about windows in multiple sessions? there are contexts
|
||||||
|
where we do not know which session, or where multiple choices makes
|
||||||
|
no sense... could at least have one global list for all types of
|
||||||
|
global options and keep separate window,session lists
|
||||||
|
* the way pane, window, session destroy is handled is too complicated
|
||||||
|
and the distinction between session.c, window.c and server-fn.c
|
||||||
|
functions is not clear. could we just have kill_pane(),
|
||||||
|
kill_window(), unlink_window(), kill_session() that fix up all data
|
||||||
|
structures (flagging sessions as dead) and return a value to say
|
||||||
|
whether clients need to be checked for dead sessions? sort of like
|
||||||
|
session_detach now but more so. or some other scheme to make it
|
||||||
|
simpler and clearer? also would be nice to remove/rename server-fn.c
|
||||||
|
* more readable way to work out the various things commands need to
|
||||||
|
know about the client, notably:
|
||||||
|
- is this the config file? (cmdq->c == NULL)
|
||||||
|
- is this a command client? (cmdq->c != NULL &&
|
||||||
|
cmdq->c->session == NULL)
|
||||||
|
- is this a control client?
|
||||||
|
- can i do stdin or stdout to this client?
|
||||||
|
or even guarantee that cmdq->c != NULL and provide a better way to
|
||||||
|
tell when in the config file - then we use cmdq->c if we need a
|
||||||
|
client w/o a session else cmd_current_client
|
||||||
|
|
||||||
|
- miscellaneous
|
||||||
|
* way to keep a job running just read its last line of output for #()
|
||||||
|
* link panes into multiple windows
|
||||||
|
* live update: server started with -U connects to server, requests
|
||||||
|
sessions and windows, receives file descriptors
|
||||||
|
* there are inconsistencies in what we get from old shell and what
|
||||||
|
comes from config for new sessions and windows. likewise, panes and
|
||||||
|
jobs and run-shell and lock command all start with slightly different
|
||||||
|
environments
|
||||||
|
* multiline status line? separate command prompt and status line?
|
||||||
|
* automatic pane logging
|
||||||
|
* marks in history, automatically add (move?) one when pane is changed
|
||||||
|
* this doesn't work, need pane reference count probably:
|
||||||
|
bind -n DoubleClick3Status confirm-before -p "kill-window #I? (y/n)" kill-window
|
||||||
|
|
||||||
|
- hooks
|
||||||
|
* more hooks for various things
|
||||||
|
* finish after hooks for special commands
|
||||||
|
* multiple hooks with the same name?
|
||||||
|
* finish hooks for notifys
|
||||||
|
* for session_closed, if no sessions at all, perhaps fake up a temporary one
|
||||||
|
|||||||
322
alerts.c
Normal file
322
alerts.c
Normal file
@@ -0,0 +1,322 @@
|
|||||||
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <event.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
static int alerts_fired;
|
||||||
|
|
||||||
|
static void alerts_timer(int, short, void *);
|
||||||
|
static int alerts_enabled(struct window *, int);
|
||||||
|
static void alerts_callback(int, short, void *);
|
||||||
|
static void alerts_reset(struct window *);
|
||||||
|
|
||||||
|
static int alerts_check_all(struct window *);
|
||||||
|
static int alerts_check_bell(struct window *);
|
||||||
|
static int alerts_check_activity(struct window *);
|
||||||
|
static int alerts_check_silence(struct window *);
|
||||||
|
static void printflike(2, 3) alerts_set_message(struct session *, const char *,
|
||||||
|
...);
|
||||||
|
static void alerts_ring_bell(struct session *);
|
||||||
|
|
||||||
|
static TAILQ_HEAD(, window) alerts_list = TAILQ_HEAD_INITIALIZER(alerts_list);
|
||||||
|
|
||||||
|
static void
|
||||||
|
alerts_timer(__unused int fd, __unused short events, void *arg)
|
||||||
|
{
|
||||||
|
struct window *w = arg;
|
||||||
|
|
||||||
|
log_debug("@%u alerts timer expired", w->id);
|
||||||
|
alerts_reset(w);
|
||||||
|
alerts_queue(w, WINDOW_SILENCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
alerts_callback(__unused int fd, __unused short events, __unused void *arg)
|
||||||
|
{
|
||||||
|
struct window *w, *w1;
|
||||||
|
int alerts;
|
||||||
|
|
||||||
|
TAILQ_FOREACH_SAFE(w, &alerts_list, alerts_entry, w1) {
|
||||||
|
alerts = alerts_check_all(w);
|
||||||
|
log_debug("@%u alerts check, alerts %#x", w->id, alerts);
|
||||||
|
|
||||||
|
w->alerts_queued = 0;
|
||||||
|
TAILQ_REMOVE(&alerts_list, w, alerts_entry);
|
||||||
|
|
||||||
|
w->flags &= ~WINDOW_ALERTFLAGS;
|
||||||
|
window_remove_ref(w);
|
||||||
|
}
|
||||||
|
alerts_fired = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
alerts_check_all(struct window *w)
|
||||||
|
{
|
||||||
|
int alerts;
|
||||||
|
|
||||||
|
alerts = alerts_check_bell(w);
|
||||||
|
alerts |= alerts_check_activity(w);
|
||||||
|
alerts |= alerts_check_silence(w);
|
||||||
|
return (alerts);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
alerts_check_session(struct session *s)
|
||||||
|
{
|
||||||
|
struct winlink *wl;
|
||||||
|
|
||||||
|
RB_FOREACH(wl, winlinks, &s->windows)
|
||||||
|
alerts_check_all(wl->window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
alerts_enabled(struct window *w, int flags)
|
||||||
|
{
|
||||||
|
if (flags & WINDOW_BELL)
|
||||||
|
return (1);
|
||||||
|
if (flags & WINDOW_ACTIVITY) {
|
||||||
|
if (options_get_number(w->options, "monitor-activity"))
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
if (flags & WINDOW_SILENCE) {
|
||||||
|
if (options_get_number(w->options, "monitor-silence") != 0)
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
alerts_reset_all(void)
|
||||||
|
{
|
||||||
|
struct window *w;
|
||||||
|
|
||||||
|
RB_FOREACH(w, windows, &windows)
|
||||||
|
alerts_reset(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
alerts_reset(struct window *w)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
w->flags &= ~WINDOW_SILENCE;
|
||||||
|
event_del(&w->alerts_timer);
|
||||||
|
|
||||||
|
timerclear(&tv);
|
||||||
|
tv.tv_sec = options_get_number(w->options, "monitor-silence");
|
||||||
|
|
||||||
|
log_debug("@%u alerts timer reset %u", w->id, (u_int)tv.tv_sec);
|
||||||
|
if (tv.tv_sec != 0)
|
||||||
|
event_add(&w->alerts_timer, &tv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
alerts_queue(struct window *w, int flags)
|
||||||
|
{
|
||||||
|
if (w->flags & WINDOW_ACTIVITY)
|
||||||
|
alerts_reset(w);
|
||||||
|
|
||||||
|
if (!event_initialized(&w->alerts_timer))
|
||||||
|
evtimer_set(&w->alerts_timer, alerts_timer, w);
|
||||||
|
|
||||||
|
if ((w->flags & flags) != flags) {
|
||||||
|
w->flags |= flags;
|
||||||
|
log_debug("@%u alerts flags added %#x", w->id, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!w->alerts_queued) {
|
||||||
|
w->alerts_queued = 1;
|
||||||
|
TAILQ_INSERT_TAIL(&alerts_list, w, alerts_entry);
|
||||||
|
w->references++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!alerts_fired && alerts_enabled(w, flags)) {
|
||||||
|
log_debug("alerts check queued (by @%u)", w->id);
|
||||||
|
event_once(-1, EV_TIMEOUT, alerts_callback, NULL, NULL);
|
||||||
|
alerts_fired = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
alerts_check_bell(struct window *w)
|
||||||
|
{
|
||||||
|
struct window *ws;
|
||||||
|
struct winlink *wl;
|
||||||
|
struct session *s;
|
||||||
|
struct client *c;
|
||||||
|
int action, visual;
|
||||||
|
|
||||||
|
if (~w->flags & WINDOW_BELL)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(wl, &w->winlinks, wentry)
|
||||||
|
wl->session->flags &= ~SESSION_ALERTED;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(wl, &w->winlinks, wentry) {
|
||||||
|
if (wl->flags & WINLINK_BELL)
|
||||||
|
continue;
|
||||||
|
s = wl->session;
|
||||||
|
if (s->curw != wl) {
|
||||||
|
wl->flags |= WINLINK_BELL;
|
||||||
|
notify_winlink("alert-bell", s, wl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s->flags & SESSION_ALERTED)
|
||||||
|
continue;
|
||||||
|
s->flags |= SESSION_ALERTED;
|
||||||
|
|
||||||
|
action = options_get_number(s->options, "bell-action");
|
||||||
|
if (action == BELL_NONE)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
visual = options_get_number(s->options, "visual-bell");
|
||||||
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
|
if (c->session != s || c->flags & CLIENT_CONTROL)
|
||||||
|
continue;
|
||||||
|
ws = c->session->curw->window;
|
||||||
|
|
||||||
|
if (action == BELL_CURRENT && ws != w)
|
||||||
|
action = BELL_NONE;
|
||||||
|
if (action == BELL_OTHER && ws != w)
|
||||||
|
action = BELL_NONE;
|
||||||
|
|
||||||
|
if (!visual) {
|
||||||
|
if (action != BELL_NONE)
|
||||||
|
tty_putcode(&c->tty, TTYC_BEL);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (action == BELL_CURRENT)
|
||||||
|
status_message_set(c, "Bell in current window");
|
||||||
|
else if (action != BELL_NONE) {
|
||||||
|
status_message_set(c, "Bell in window %d",
|
||||||
|
wl->idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (WINDOW_BELL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
alerts_check_activity(struct window *w)
|
||||||
|
{
|
||||||
|
struct winlink *wl;
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
|
if (~w->flags & WINDOW_ACTIVITY)
|
||||||
|
return (0);
|
||||||
|
if (!options_get_number(w->options, "monitor-activity"))
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(wl, &w->winlinks, wentry)
|
||||||
|
wl->session->flags &= ~SESSION_ALERTED;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(wl, &w->winlinks, wentry) {
|
||||||
|
if (wl->flags & WINLINK_ACTIVITY)
|
||||||
|
continue;
|
||||||
|
s = wl->session;
|
||||||
|
if (s->curw == wl)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
wl->flags |= WINLINK_ACTIVITY;
|
||||||
|
notify_winlink("alert-activity", s, wl);
|
||||||
|
|
||||||
|
if (s->flags & SESSION_ALERTED)
|
||||||
|
continue;
|
||||||
|
s->flags |= SESSION_ALERTED;
|
||||||
|
|
||||||
|
if (options_get_number(s->options, "bell-on-alert"))
|
||||||
|
alerts_ring_bell(s);
|
||||||
|
if (options_get_number(s->options, "visual-activity"))
|
||||||
|
alerts_set_message(s, "Activity in window %d", wl->idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (WINDOW_ACTIVITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
alerts_check_silence(struct window *w)
|
||||||
|
{
|
||||||
|
struct winlink *wl;
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
|
if (~w->flags & WINDOW_SILENCE)
|
||||||
|
return (0);
|
||||||
|
if (!options_get_number(w->options, "monitor-silence"))
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(wl, &w->winlinks, wentry)
|
||||||
|
wl->session->flags &= ~SESSION_ALERTED;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(wl, &w->winlinks, wentry) {
|
||||||
|
if (wl->flags & WINLINK_SILENCE)
|
||||||
|
continue;
|
||||||
|
s = wl->session;
|
||||||
|
if (s->curw == wl)
|
||||||
|
continue;
|
||||||
|
wl->flags |= WINLINK_SILENCE;
|
||||||
|
notify_winlink("alert-silence", s, wl);
|
||||||
|
|
||||||
|
if (s->flags & SESSION_ALERTED)
|
||||||
|
continue;
|
||||||
|
s->flags |= SESSION_ALERTED;
|
||||||
|
|
||||||
|
if (options_get_number(s->options, "bell-on-alert"))
|
||||||
|
alerts_ring_bell(s);
|
||||||
|
|
||||||
|
if (!options_get_number(s->options, "visual-silence"))
|
||||||
|
alerts_set_message(s, "Silence in window %d", wl->idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (WINDOW_SILENCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
alerts_set_message(struct session *s, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
va_list ap;
|
||||||
|
char *message;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
xvasprintf(&message, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
|
if (c->session == s)
|
||||||
|
status_message_set(c, "%s", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
alerts_ring_bell(struct session *s)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
|
if (c->session == s && !(c->flags & CLIENT_CONTROL))
|
||||||
|
tty_putcode(&c->tty, TTYC_BEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
228
arguments.c
228
arguments.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -20,33 +20,41 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/* Create an arguments set with no flags. */
|
/*
|
||||||
struct args *
|
* Manipulate command arguments.
|
||||||
args_create(int argc, ...)
|
*/
|
||||||
|
|
||||||
|
struct args_entry {
|
||||||
|
u_char flag;
|
||||||
|
char *value;
|
||||||
|
RB_ENTRY(args_entry) entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void args_set(struct args *, u_char, const char *);
|
||||||
|
static struct args_entry *args_find(struct args *, u_char);
|
||||||
|
|
||||||
|
static int args_cmp(struct args_entry *, struct args_entry *);
|
||||||
|
RB_GENERATE_STATIC(args_tree, args_entry, entry, args_cmp);
|
||||||
|
|
||||||
|
/* Arguments tree comparison function. */
|
||||||
|
static int
|
||||||
|
args_cmp(struct args_entry *a1, struct args_entry *a2)
|
||||||
{
|
{
|
||||||
struct args *args;
|
return (a1->flag - a2->flag);
|
||||||
va_list ap;
|
}
|
||||||
int i;
|
|
||||||
|
|
||||||
args = xcalloc(1, sizeof *args);
|
/* Find a flag in the arguments tree. */
|
||||||
if ((args->flags = bit_alloc(SCHAR_MAX)) == NULL)
|
static struct args_entry *
|
||||||
fatal("bit_alloc failed");
|
args_find(struct args *args, u_char ch)
|
||||||
|
{
|
||||||
|
struct args_entry entry;
|
||||||
|
|
||||||
args->argc = argc;
|
entry.flag = ch;
|
||||||
if (argc == 0)
|
return (RB_FIND(args_tree, &args->tree, &entry));
|
||||||
args->argv = NULL;
|
|
||||||
else
|
|
||||||
args->argv = xcalloc(argc, sizeof *args->argv);
|
|
||||||
|
|
||||||
va_start(ap, argc);
|
|
||||||
for (i = 0; i < argc; i++)
|
|
||||||
args->argv[i] = xstrdup(va_arg(ap, char *));
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
return (args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse an argv and argc into a new argument set. */
|
/* Parse an argv and argc into a new argument set. */
|
||||||
@@ -54,30 +62,21 @@ struct args *
|
|||||||
args_parse(const char *template, int argc, char **argv)
|
args_parse(const char *template, int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct args *args;
|
struct args *args;
|
||||||
char *ptr;
|
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
args = xcalloc(1, sizeof *args);
|
args = xcalloc(1, sizeof *args);
|
||||||
if ((args->flags = bit_alloc(SCHAR_MAX)) == NULL)
|
|
||||||
fatal("bit_alloc failed");
|
|
||||||
|
|
||||||
optreset = 1;
|
optreset = 1;
|
||||||
optind = 1;
|
optind = 1;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, template)) != -1) {
|
while ((opt = getopt(argc, argv, template)) != -1) {
|
||||||
if (opt < 0 || opt >= SCHAR_MAX)
|
if (opt < 0)
|
||||||
continue;
|
continue;
|
||||||
if (opt == '?' || (ptr = strchr(template, opt)) == NULL) {
|
if (opt == '?' || strchr(template, opt) == NULL) {
|
||||||
free(args->flags);
|
args_free(args);
|
||||||
free(args);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
args_set(args, opt, optarg);
|
||||||
bit_set(args->flags, opt);
|
|
||||||
if (ptr[1] == ':') {
|
|
||||||
free(args->values[opt]);
|
|
||||||
args->values[opt] = xstrdup(optarg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
@@ -92,122 +91,155 @@ args_parse(const char *template, int argc, char **argv)
|
|||||||
void
|
void
|
||||||
args_free(struct args *args)
|
args_free(struct args *args)
|
||||||
{
|
{
|
||||||
u_int i;
|
struct args_entry *entry;
|
||||||
|
struct args_entry *entry1;
|
||||||
|
|
||||||
cmd_free_argv(args->argc, args->argv);
|
cmd_free_argv(args->argc, args->argv);
|
||||||
|
|
||||||
for (i = 0; i < SCHAR_MAX; i++)
|
RB_FOREACH_SAFE(entry, args_tree, &args->tree, entry1) {
|
||||||
free(args->values[i]);
|
RB_REMOVE(args_tree, &args->tree, entry);
|
||||||
|
free(entry->value);
|
||||||
|
free(entry);
|
||||||
|
}
|
||||||
|
|
||||||
free(args->flags);
|
|
||||||
free(args);
|
free(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print a set of arguments. */
|
/* Add to string. */
|
||||||
size_t
|
static void printflike(3, 4)
|
||||||
args_print(struct args *args, char *buf, size_t len)
|
args_print_add(char **buf, size_t *len, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
size_t off;
|
va_list ap;
|
||||||
int i;
|
char *s;
|
||||||
const char *quotes;
|
size_t slen;
|
||||||
|
|
||||||
/* There must be at least one byte at the start. */
|
va_start(ap, fmt);
|
||||||
if (len == 0)
|
slen = xvasprintf(&s, fmt, ap);
|
||||||
return (0);
|
va_end(ap);
|
||||||
off = 0;
|
|
||||||
|
*len += slen;
|
||||||
|
*buf = xrealloc(*buf, *len);
|
||||||
|
|
||||||
|
strlcat(*buf, s, *len);
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print a set of arguments. */
|
||||||
|
char *
|
||||||
|
args_print(struct args *args)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
char *buf, *escaped;
|
||||||
|
int i, flags;
|
||||||
|
struct args_entry *entry;
|
||||||
|
static const char quoted[] = " #\"';$";
|
||||||
|
|
||||||
|
len = 1;
|
||||||
|
buf = xcalloc(1, len);
|
||||||
|
|
||||||
/* Process the flags first. */
|
/* Process the flags first. */
|
||||||
buf[off++] = '-';
|
RB_FOREACH(entry, args_tree, &args->tree) {
|
||||||
for (i = 0; i < SCHAR_MAX; i++) {
|
if (entry->value != NULL)
|
||||||
if (!bit_test(args->flags, i) || args->values[i] != NULL)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (off == len - 1) {
|
if (*buf == '\0')
|
||||||
buf[off] = '\0';
|
args_print_add(&buf, &len, "-");
|
||||||
return (len);
|
args_print_add(&buf, &len, "%c", entry->flag);
|
||||||
}
|
|
||||||
buf[off++] = i;
|
|
||||||
buf[off] = '\0';
|
|
||||||
}
|
}
|
||||||
if (off == 1)
|
|
||||||
buf[--off] = '\0';
|
|
||||||
|
|
||||||
/* Then the flags with arguments. */
|
/* Then the flags with arguments. */
|
||||||
for (i = 0; i < SCHAR_MAX; i++) {
|
RB_FOREACH(entry, args_tree, &args->tree) {
|
||||||
if (!bit_test(args->flags, i) || args->values[i] == NULL)
|
if (entry->value == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (off >= len) {
|
if (*buf != '\0')
|
||||||
/* snprintf will have zero terminated. */
|
args_print_add(&buf, &len, " -%c ", entry->flag);
|
||||||
return (len);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strchr(args->values[i], ' ') != NULL)
|
|
||||||
quotes = "\"";
|
|
||||||
else
|
else
|
||||||
quotes = "";
|
args_print_add(&buf, &len, "-%c ", entry->flag);
|
||||||
off += xsnprintf(buf + off, len - off, "%s-%c %s%s%s",
|
|
||||||
off != 0 ? " " : "", i, quotes, args->values[i], quotes);
|
flags = VIS_OCTAL|VIS_TAB|VIS_NL;
|
||||||
|
if (entry->value[strcspn(entry->value, quoted)] != '\0')
|
||||||
|
flags |= VIS_DQ;
|
||||||
|
utf8_stravis(&escaped, entry->value, flags);
|
||||||
|
if (flags & VIS_DQ)
|
||||||
|
args_print_add(&buf, &len, "\"%s\"", escaped);
|
||||||
|
else
|
||||||
|
args_print_add(&buf, &len, "%s", escaped);
|
||||||
|
free(escaped);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* And finally the argument vector. */
|
/* And finally the argument vector. */
|
||||||
for (i = 0; i < args->argc; i++) {
|
for (i = 0; i < args->argc; i++) {
|
||||||
if (off >= len) {
|
if (*buf != '\0')
|
||||||
/* snprintf will have zero terminated. */
|
args_print_add(&buf, &len, " ");
|
||||||
return (len);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strchr(args->argv[i], ' ') != NULL)
|
flags = VIS_OCTAL|VIS_TAB|VIS_NL;
|
||||||
quotes = "\"";
|
if (args->argv[i][strcspn(args->argv[i], quoted)] != '\0')
|
||||||
|
flags |= VIS_DQ;
|
||||||
|
utf8_stravis(&escaped, args->argv[i], flags);
|
||||||
|
if (flags & VIS_DQ)
|
||||||
|
args_print_add(&buf, &len, "\"%s\"", escaped);
|
||||||
else
|
else
|
||||||
quotes = "";
|
args_print_add(&buf, &len, "%s", escaped);
|
||||||
off += xsnprintf(buf + off, len - off, "%s%s%s%s",
|
free(escaped);
|
||||||
off != 0 ? " " : "", quotes, args->argv[i], quotes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (off);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return if an argument is present. */
|
/* Return if an argument is present. */
|
||||||
int
|
int
|
||||||
args_has(struct args *args, u_char ch)
|
args_has(struct args *args, u_char ch)
|
||||||
{
|
{
|
||||||
return (bit_test(args->flags, ch));
|
return (args_find(args, ch) == NULL ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set argument value. */
|
/* Set argument value in the arguments tree. */
|
||||||
void
|
static void
|
||||||
args_set(struct args *args, u_char ch, const char *value)
|
args_set(struct args *args, u_char ch, const char *value)
|
||||||
{
|
{
|
||||||
free(args->values[ch]);
|
struct args_entry *entry;
|
||||||
|
|
||||||
|
/* Replace existing argument. */
|
||||||
|
if ((entry = args_find(args, ch)) != NULL) {
|
||||||
|
free(entry->value);
|
||||||
|
entry->value = NULL;
|
||||||
|
} else {
|
||||||
|
entry = xcalloc(1, sizeof *entry);
|
||||||
|
entry->flag = ch;
|
||||||
|
RB_INSERT(args_tree, &args->tree, entry);
|
||||||
|
}
|
||||||
|
|
||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
args->values[ch] = xstrdup(value);
|
entry->value = xstrdup(value);
|
||||||
else
|
|
||||||
args->values[ch] = NULL;
|
|
||||||
bit_set(args->flags, ch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get argument value. Will be NULL if it isn't present. */
|
/* Get argument value. Will be NULL if it isn't present. */
|
||||||
const char *
|
const char *
|
||||||
args_get(struct args *args, u_char ch)
|
args_get(struct args *args, u_char ch)
|
||||||
{
|
{
|
||||||
return (args->values[ch]);
|
struct args_entry *entry;
|
||||||
|
|
||||||
|
if ((entry = args_find(args, ch)) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
return (entry->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert an argument value to a number. */
|
/* Convert an argument value to a number. */
|
||||||
long long
|
long long
|
||||||
args_strtonum(struct args *args,
|
args_strtonum(struct args *args, u_char ch, long long minval, long long maxval,
|
||||||
u_char ch, long long minval, long long maxval, char **cause)
|
char **cause)
|
||||||
{
|
{
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
long long ll;
|
long long ll;
|
||||||
|
struct args_entry *entry;
|
||||||
|
|
||||||
if (!args_has(args, ch)) {
|
if ((entry = args_find(args, ch)) == NULL) {
|
||||||
*cause = xstrdup("missing");
|
*cause = xstrdup("missing");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ll = strtonum(args->values[ch], minval, maxval, &errstr);
|
ll = strtonum(entry->value, minval, maxval, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
*cause = xstrdup(errstr);
|
*cause = xstrdup(errstr);
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
120
array.h
120
array.h
@@ -1,120 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2006 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARRAY_H
|
|
||||||
#define ARRAY_H
|
|
||||||
|
|
||||||
#define ARRAY_INITIALIZER { NULL, 0, 0 }
|
|
||||||
|
|
||||||
#define ARRAY_DECL(n, c) \
|
|
||||||
struct n { \
|
|
||||||
c *list; \
|
|
||||||
u_int num; \
|
|
||||||
size_t space; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ARRAY_ITEM(a, i) ((a)->list[i])
|
|
||||||
#define ARRAY_ITEMSIZE(a) (sizeof *(a)->list)
|
|
||||||
#define ARRAY_INITIALSPACE(a) (10 * ARRAY_ITEMSIZE(a))
|
|
||||||
|
|
||||||
#define ARRAY_ENSURE(a, n) do { \
|
|
||||||
if (UINT_MAX - (n) < (a)->num) \
|
|
||||||
fatalx("number too big"); \
|
|
||||||
if (SIZE_MAX / ((a)->num + (n)) < ARRAY_ITEMSIZE(a)) \
|
|
||||||
fatalx("size too big"); \
|
|
||||||
if ((a)->space == 0) { \
|
|
||||||
(a)->space = ARRAY_INITIALSPACE(a); \
|
|
||||||
(a)->list = xrealloc((a)->list, 1, (a)->space); \
|
|
||||||
} \
|
|
||||||
while ((a)->space <= ((a)->num + (n)) * ARRAY_ITEMSIZE(a)) { \
|
|
||||||
(a)->list = xrealloc((a)->list, 2, (a)->space); \
|
|
||||||
(a)->space *= 2; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define ARRAY_EMPTY(a) (((void *) (a)) == NULL || (a)->num == 0)
|
|
||||||
#define ARRAY_LENGTH(a) ((a)->num)
|
|
||||||
#define ARRAY_DATA(a) ((a)->list)
|
|
||||||
|
|
||||||
#define ARRAY_FIRST(a) ARRAY_ITEM(a, 0)
|
|
||||||
#define ARRAY_LAST(a) ARRAY_ITEM(a, (a)->num - 1)
|
|
||||||
|
|
||||||
#define ARRAY_INIT(a) do { \
|
|
||||||
(a)->num = 0; \
|
|
||||||
(a)->list = NULL; \
|
|
||||||
(a)->space = 0; \
|
|
||||||
} while (0)
|
|
||||||
#define ARRAY_CLEAR(a) do { \
|
|
||||||
(a)->num = 0; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define ARRAY_SET(a, i, s) do { \
|
|
||||||
(a)->list[i] = s; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define ARRAY_ADD(a, s) do { \
|
|
||||||
ARRAY_ENSURE(a, 1); \
|
|
||||||
(a)->list[(a)->num] = s; \
|
|
||||||
(a)->num++; \
|
|
||||||
} while (0)
|
|
||||||
#define ARRAY_INSERT(a, i, s) do { \
|
|
||||||
ARRAY_ENSURE(a, 1); \
|
|
||||||
if ((i) < (a)->num) { \
|
|
||||||
memmove((a)->list + (i) + 1, (a)->list + (i), \
|
|
||||||
ARRAY_ITEMSIZE(a) * ((a)->num - (i))); \
|
|
||||||
} \
|
|
||||||
(a)->list[i] = s; \
|
|
||||||
(a)->num++; \
|
|
||||||
} while (0)
|
|
||||||
#define ARRAY_REMOVE(a, i) do { \
|
|
||||||
if ((i) < (a)->num - 1) { \
|
|
||||||
memmove((a)->list + (i), (a)->list + (i) + 1, \
|
|
||||||
ARRAY_ITEMSIZE(a) * ((a)->num - (i) - 1)); \
|
|
||||||
} \
|
|
||||||
(a)->num--; \
|
|
||||||
if ((a)->num == 0) \
|
|
||||||
ARRAY_FREE(a); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define ARRAY_EXPAND(a, n) do { \
|
|
||||||
ARRAY_ENSURE(a, n); \
|
|
||||||
(a)->num += n; \
|
|
||||||
} while (0)
|
|
||||||
#define ARRAY_TRUNC(a, n) do { \
|
|
||||||
if ((a)->num > n) \
|
|
||||||
(a)->num -= n; \
|
|
||||||
else \
|
|
||||||
ARRAY_FREE(a); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define ARRAY_CONCAT(a, b) do { \
|
|
||||||
ARRAY_ENSURE(a, (b)->num); \
|
|
||||||
memcpy((a)->list + (a)->num, (b)->list, (b)->num * ARRAY_ITEMSIZE(a)); \
|
|
||||||
(a)->num += (b)->num; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define ARRAY_FREE(a) do { \
|
|
||||||
free((a)->list); \
|
|
||||||
ARRAY_INIT(a); \
|
|
||||||
} while (0)
|
|
||||||
#define ARRAY_FREEALL(a) do { \
|
|
||||||
ARRAY_FREE(a); \
|
|
||||||
free(a); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
25
attributes.c
25
attributes.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
|
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
attributes_tostring(u_char attr)
|
attributes_tostring(int attr)
|
||||||
{
|
{
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
size_t len;
|
size_t len;
|
||||||
@@ -31,14 +31,15 @@ attributes_tostring(u_char attr)
|
|||||||
if (attr == 0)
|
if (attr == 0)
|
||||||
return ("none");
|
return ("none");
|
||||||
|
|
||||||
len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s",
|
len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s%s",
|
||||||
attr & GRID_ATTR_BRIGHT ? "bright," : "",
|
(attr & GRID_ATTR_BRIGHT) ? "bright," : "",
|
||||||
attr & GRID_ATTR_DIM ? "dim," : "",
|
(attr & GRID_ATTR_DIM) ? "dim," : "",
|
||||||
attr & GRID_ATTR_UNDERSCORE ? "underscore," : "",
|
(attr & GRID_ATTR_UNDERSCORE) ? "underscore," : "",
|
||||||
attr & GRID_ATTR_BLINK ? "blink," : "",
|
(attr & GRID_ATTR_BLINK)? "blink," : "",
|
||||||
attr & GRID_ATTR_REVERSE ? "reverse," : "",
|
(attr & GRID_ATTR_REVERSE) ? "reverse," : "",
|
||||||
attr & GRID_ATTR_HIDDEN ? "hidden," : "",
|
(attr & GRID_ATTR_HIDDEN) ? "hidden," : "",
|
||||||
attr & GRID_ATTR_ITALICS ? "italics," : "");
|
(attr & GRID_ATTR_ITALICS) ? "italics," : "",
|
||||||
|
(attr & GRID_ATTR_STRIKETHROUGH) ? "strikethrough," : "");
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
buf[len - 1] = '\0';
|
buf[len - 1] = '\0';
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ int
|
|||||||
attributes_fromstring(const char *str)
|
attributes_fromstring(const char *str)
|
||||||
{
|
{
|
||||||
const char delimiters[] = " ,|";
|
const char delimiters[] = " ,|";
|
||||||
u_char attr;
|
int attr;
|
||||||
size_t end;
|
size_t end;
|
||||||
|
|
||||||
if (*str == '\0' || strcspn(str, delimiters) == 0)
|
if (*str == '\0' || strcspn(str, delimiters) == 0)
|
||||||
@@ -78,6 +79,8 @@ attributes_fromstring(const char *str)
|
|||||||
attr |= 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)
|
||||||
attr |= GRID_ATTR_ITALICS;
|
attr |= GRID_ATTR_ITALICS;
|
||||||
|
else if (end == 13 && strncasecmp(str, "strikethrough", end) == 0)
|
||||||
|
attr |= GRID_ATTR_STRIKETHROUGH;
|
||||||
else
|
else
|
||||||
return (-1);
|
return (-1);
|
||||||
str += end + strspn(str + end, delimiters);
|
str += end + strspn(str + end, delimiters);
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# $Id$
|
|
||||||
|
|
||||||
if [ "x$(uname)" = "xOpenBSD" ]; then
|
if [ "x$(uname)" = "xOpenBSD" ]; then
|
||||||
[ -z "$AUTOMAKE_VERSION" ] && export AUTOMAKE_VERSION=1.10
|
[ -z "$AUTOMAKE_VERSION" ] && export AUTOMAKE_VERSION=1.15
|
||||||
[ -z "$AUTOCONF_VERSION" ] && export AUTOCONF_VERSION=2.65
|
[ -z "$AUTOCONF_VERSION" ] && export AUTOCONF_VERSION=2.69
|
||||||
fi
|
fi
|
||||||
|
|
||||||
die()
|
die()
|
||||||
|
|||||||
223
cfg.c
223
cfg.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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,135 +17,204 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
struct cmd_q *cfg_cmd_q;
|
static char *cfg_file;
|
||||||
int cfg_finished;
|
int cfg_finished;
|
||||||
int cfg_references;
|
static char **cfg_causes;
|
||||||
struct causelist cfg_causes;
|
static u_int cfg_ncauses;
|
||||||
|
struct client *cfg_client;
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cfg_done(__unused struct cmdq_item *item, __unused void *data)
|
||||||
|
{
|
||||||
|
if (cfg_finished)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
cfg_finished = 1;
|
||||||
|
|
||||||
|
if (!RB_EMPTY(&sessions))
|
||||||
|
cfg_show_causes(RB_MIN(sessions, &sessions));
|
||||||
|
|
||||||
|
if (cfg_client != NULL)
|
||||||
|
server_client_unref(cfg_client);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_cfg_file(const char *path)
|
||||||
|
{
|
||||||
|
free(cfg_file);
|
||||||
|
cfg_file = xstrdup(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
start_cfg(void)
|
||||||
|
{
|
||||||
|
const char *home;
|
||||||
|
int quiet = 0;
|
||||||
|
|
||||||
|
cfg_client = TAILQ_FIRST(&clients);
|
||||||
|
if (cfg_client != NULL)
|
||||||
|
cfg_client->references++;
|
||||||
|
|
||||||
|
load_cfg(TMUX_CONF, cfg_client, NULL, 1);
|
||||||
|
|
||||||
|
if (cfg_file == NULL && (home = find_home()) != NULL) {
|
||||||
|
xasprintf(&cfg_file, "%s/.tmux.conf", home);
|
||||||
|
quiet = 1;
|
||||||
|
}
|
||||||
|
if (cfg_file != NULL)
|
||||||
|
load_cfg(cfg_file, cfg_client, NULL, quiet);
|
||||||
|
|
||||||
|
cmdq_append(cfg_client, cmdq_get_callback(cfg_done, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
load_cfg(const char *path, struct cmd_q *cmdq, char **cause)
|
load_cfg(const char *path, struct client *c, struct cmdq_item *item, int quiet)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
u_int n, found;
|
const char delim[3] = { '\\', '\\', '\0' };
|
||||||
char *buf, *copy, *line, *cause1, *msg;
|
u_int found = 0;
|
||||||
size_t len, oldlen;
|
size_t line = 0;
|
||||||
struct cmd_list *cmdlist;
|
char *buf, *cause1, *p, *q, *s;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
struct cmdq_item *new_item;
|
||||||
|
int condition = 0;
|
||||||
|
struct format_tree *ft;
|
||||||
|
|
||||||
log_debug("loading %s", path);
|
log_debug("loading %s", path);
|
||||||
if ((f = fopen(path, "rb")) == NULL) {
|
if ((f = fopen(path, "rb")) == NULL) {
|
||||||
xasprintf(cause, "%s: %s", path, strerror(errno));
|
if (errno == ENOENT && quiet)
|
||||||
|
return (0);
|
||||||
|
cfg_add_cause("%s: %s", path, strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = found = 0;
|
while ((buf = fparseln(f, NULL, &line, delim, 0)) != NULL) {
|
||||||
line = NULL;
|
log_debug("%s: %s", path, buf);
|
||||||
while ((buf = fgetln(f, &len))) {
|
|
||||||
/* Trim \n. */
|
|
||||||
if (buf[len - 1] == '\n')
|
|
||||||
len--;
|
|
||||||
log_debug("%s: %.*s", path, (int)len, buf);
|
|
||||||
|
|
||||||
/* Current line is the continuation of the previous one. */
|
p = buf;
|
||||||
if (line != NULL) {
|
while (isspace((u_char)*p))
|
||||||
oldlen = strlen(line);
|
p++;
|
||||||
line = xrealloc(line, 1, oldlen + len + 1);
|
if (*p == '\0') {
|
||||||
} else {
|
free(buf);
|
||||||
oldlen = 0;
|
|
||||||
line = xmalloc(len + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Append current line to the previous. */
|
|
||||||
memcpy(line + oldlen, buf, len);
|
|
||||||
line[oldlen + len] = '\0';
|
|
||||||
n++;
|
|
||||||
|
|
||||||
/* Continuation: get next line? */
|
|
||||||
len = strlen(line);
|
|
||||||
if (len > 0 && line[len - 1] == '\\') {
|
|
||||||
line[len - 1] = '\0';
|
|
||||||
|
|
||||||
/* Ignore escaped backslash at EOL. */
|
|
||||||
if (len > 1 && line[len - 2] != '\\')
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
copy = line;
|
|
||||||
line = NULL;
|
|
||||||
|
|
||||||
/* Skip empty lines. */
|
|
||||||
buf = copy;
|
|
||||||
while (isspace((u_char)*buf))
|
|
||||||
buf++;
|
|
||||||
if (*buf == '\0') {
|
|
||||||
free(copy);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
q = p + strlen(p) - 1;
|
||||||
|
while (q != p && isspace((u_char)*q))
|
||||||
|
*q-- = '\0';
|
||||||
|
|
||||||
/* Parse and run the command. */
|
if (condition != 0 && strcmp(p, "%endif") == 0) {
|
||||||
if (cmd_string_parse(buf, &cmdlist, path, n, &cause1) != 0) {
|
condition = 0;
|
||||||
free(copy);
|
continue;
|
||||||
|
}
|
||||||
|
if (strncmp(p, "%if ", 4) == 0) {
|
||||||
|
if (condition != 0) {
|
||||||
|
cfg_add_cause("%s:%zu: nested %%if", path,
|
||||||
|
line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ft = format_create(NULL, FORMAT_NONE, FORMAT_NOJOBS);
|
||||||
|
|
||||||
|
s = p + 3;
|
||||||
|
while (isspace((u_char)*s))
|
||||||
|
s++;
|
||||||
|
s = format_expand(ft, s);
|
||||||
|
if (*s != '\0' && (s[0] != '0' || s[1] != '\0'))
|
||||||
|
condition = 1;
|
||||||
|
else
|
||||||
|
condition = -1;
|
||||||
|
free(s);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (condition == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
cmdlist = cmd_string_parse(p, path, line, &cause1);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
|
free(buf);
|
||||||
if (cause1 == NULL)
|
if (cause1 == NULL)
|
||||||
continue;
|
continue;
|
||||||
xasprintf(&msg, "%s:%u: %s", path, n, cause1);
|
cfg_add_cause("%s:%zu: %s", path, line, cause1);
|
||||||
ARRAY_ADD(&cfg_causes, msg);
|
|
||||||
free(cause1);
|
free(cause1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
free(copy);
|
free(buf);
|
||||||
|
|
||||||
if (cmdlist == NULL)
|
if (cmdlist == NULL)
|
||||||
continue;
|
continue;
|
||||||
cmdq_append(cmdq, cmdlist);
|
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
|
||||||
|
if (item != NULL)
|
||||||
|
cmdq_insert_after(item, new_item);
|
||||||
|
else
|
||||||
|
cmdq_append(c, new_item);
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
|
|
||||||
found++;
|
found++;
|
||||||
}
|
}
|
||||||
if (line != NULL)
|
|
||||||
free(line);
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
return (found);
|
return (found);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cfg_default_done(unused struct cmd_q *cmdq)
|
cfg_add_cause(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
if (--cfg_references != 0)
|
va_list ap;
|
||||||
return;
|
char *msg;
|
||||||
cfg_finished = 1;
|
|
||||||
|
|
||||||
if (!RB_EMPTY(&sessions))
|
va_start(ap, fmt);
|
||||||
cfg_show_causes(RB_MIN(sessions, &sessions));
|
xvasprintf(&msg, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
cmdq_free(cfg_cmd_q);
|
cfg_ncauses++;
|
||||||
cfg_cmd_q = NULL;
|
cfg_causes = xreallocarray(cfg_causes, cfg_ncauses, sizeof *cfg_causes);
|
||||||
|
cfg_causes[cfg_ncauses - 1] = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cfg_print_causes(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < cfg_ncauses; i++) {
|
||||||
|
cmdq_print(item, "%s", cfg_causes[i]);
|
||||||
|
free(cfg_causes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(cfg_causes);
|
||||||
|
cfg_causes = NULL;
|
||||||
|
cfg_ncauses = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cfg_show_causes(struct session *s)
|
cfg_show_causes(struct session *s)
|
||||||
{
|
{
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
char *cause;
|
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
if (s == NULL || ARRAY_EMPTY(&cfg_causes))
|
if (s == NULL || cfg_ncauses == 0)
|
||||||
return;
|
return;
|
||||||
wp = s->curw->window->active;
|
wp = s->curw->window->active;
|
||||||
|
|
||||||
window_pane_set_mode(wp, &window_copy_mode);
|
window_pane_set_mode(wp, &window_copy_mode);
|
||||||
window_copy_init_for_output(wp);
|
window_copy_init_for_output(wp);
|
||||||
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
|
for (i = 0; i < cfg_ncauses; i++) {
|
||||||
cause = ARRAY_ITEM(&cfg_causes, i);
|
window_copy_add(wp, "%s", cfg_causes[i]);
|
||||||
window_copy_add(wp, "%s", cause);
|
free(cfg_causes[i]);
|
||||||
free(cause);
|
|
||||||
}
|
}
|
||||||
ARRAY_FREE(&cfg_causes);
|
|
||||||
|
free(cfg_causes);
|
||||||
|
cfg_causes = NULL;
|
||||||
|
cfg_ncauses = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
159
clock.c
159
clock.c
@@ -1,159 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
const char clock_table[14][5][5] = {
|
|
||||||
{ { 1,1,1,1,1 }, /* 0 */
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 } },
|
|
||||||
{ { 0,0,0,0,1 }, /* 1 */
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 0,0,0,0,1 } },
|
|
||||||
{ { 1,1,1,1,1 }, /* 2 */
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 },
|
|
||||||
{ 1,0,0,0,0 },
|
|
||||||
{ 1,1,1,1,1 } },
|
|
||||||
{ { 1,1,1,1,1 }, /* 3 */
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 },
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 } },
|
|
||||||
{ { 1,0,0,0,1 }, /* 4 */
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 },
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 0,0,0,0,1 } },
|
|
||||||
{ { 1,1,1,1,1 }, /* 5 */
|
|
||||||
{ 1,0,0,0,0 },
|
|
||||||
{ 1,1,1,1,1 },
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 } },
|
|
||||||
{ { 1,1,1,1,1 }, /* 6 */
|
|
||||||
{ 1,0,0,0,0 },
|
|
||||||
{ 1,1,1,1,1 },
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 } },
|
|
||||||
{ { 1,1,1,1,1 }, /* 7 */
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 0,0,0,0,1 } },
|
|
||||||
{ { 1,1,1,1,1 }, /* 8 */
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 },
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 } },
|
|
||||||
{ { 1,1,1,1,1 }, /* 9 */
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 },
|
|
||||||
{ 0,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 } },
|
|
||||||
{ { 0,0,0,0,0 }, /* : */
|
|
||||||
{ 0,0,1,0,0 },
|
|
||||||
{ 0,0,0,0,0 },
|
|
||||||
{ 0,0,1,0,0 },
|
|
||||||
{ 0,0,0,0,0 } },
|
|
||||||
{ { 1,1,1,1,1 }, /* A */
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 },
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,0,0,0,1 } },
|
|
||||||
{ { 1,1,1,1,1 }, /* P */
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,1,1,1,1 },
|
|
||||||
{ 1,0,0,0,0 },
|
|
||||||
{ 1,0,0,0,0 } },
|
|
||||||
{ { 1,0,0,0,1 }, /* M */
|
|
||||||
{ 1,1,0,1,1 },
|
|
||||||
{ 1,0,1,0,1 },
|
|
||||||
{ 1,0,0,0,1 },
|
|
||||||
{ 1,0,0,0,1 } },
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
clock_draw(struct screen_write_ctx *ctx, int colour, int style)
|
|
||||||
{
|
|
||||||
struct screen *s = ctx->s;
|
|
||||||
struct grid_cell gc;
|
|
||||||
char tim[64], *ptr;
|
|
||||||
time_t t;
|
|
||||||
u_int i, j, x, y, idx;
|
|
||||||
|
|
||||||
t = time(NULL);
|
|
||||||
if (style == 0)
|
|
||||||
strftime(tim, sizeof tim, "%l:%M %p", localtime(&t));
|
|
||||||
else
|
|
||||||
strftime(tim, sizeof tim, "%H:%M", localtime(&t));
|
|
||||||
|
|
||||||
screen_write_clearscreen(ctx);
|
|
||||||
|
|
||||||
if (screen_size_x(s) < 6 * strlen(tim) || screen_size_y(s) < 6) {
|
|
||||||
if (screen_size_x(s) >= strlen(tim) && screen_size_y(s) != 0) {
|
|
||||||
x = (screen_size_x(s) / 2) - (strlen(tim) / 2);
|
|
||||||
y = screen_size_y(s) / 2;
|
|
||||||
screen_write_cursormove(ctx, x, y);
|
|
||||||
|
|
||||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
|
||||||
colour_set_fg(&gc, colour);
|
|
||||||
screen_write_puts(ctx, &gc, "%s", tim);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = (screen_size_x(s) / 2) - 3 * strlen(tim);
|
|
||||||
y = (screen_size_y(s) / 2) - 3;
|
|
||||||
|
|
||||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
|
||||||
colour_set_bg(&gc, colour);
|
|
||||||
for (ptr = tim; *ptr != '\0'; ptr++) {
|
|
||||||
if (*ptr >= '0' && *ptr <= '9')
|
|
||||||
idx = *ptr - '0';
|
|
||||||
else if (*ptr == ':')
|
|
||||||
idx = 10;
|
|
||||||
else if (*ptr == 'A')
|
|
||||||
idx = 11;
|
|
||||||
else if (*ptr == 'P')
|
|
||||||
idx = 12;
|
|
||||||
else if (*ptr == 'M')
|
|
||||||
idx = 13;
|
|
||||||
else {
|
|
||||||
x += 6;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < 5; j++) {
|
|
||||||
for (i = 0; i < 5; i++) {
|
|
||||||
screen_write_cursormove(ctx, x + i, y + j);
|
|
||||||
if (clock_table[idx][j][i])
|
|
||||||
screen_write_putc(ctx, &gc, ' ');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
x += 6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -18,7 +18,11 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,95 +30,121 @@
|
|||||||
* Attach existing session to the current terminal.
|
* Attach existing session to the current terminal.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_attach_session_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_attach_session_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_attach_session_entry = {
|
const struct cmd_entry cmd_attach_session_entry = {
|
||||||
"attach-session", "attach",
|
.name = "attach-session",
|
||||||
"drt:", 0, 0,
|
.alias = "attach",
|
||||||
"[-dr] " CMD_TARGET_SESSION_USAGE,
|
|
||||||
CMD_CANTNEST|CMD_STARTSERVER|CMD_SENDENVIRON,
|
.args = { "c:dErt:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-dEr] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_attach_session_exec
|
.tflag = CMD_SESSION_WITHPANE,
|
||||||
|
|
||||||
|
.flags = CMD_STARTSERVER,
|
||||||
|
.exec = cmd_attach_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
enum cmd_retval
|
||||||
cmd_attach_session(struct cmd_q *cmdq, const char* tflag, int dflag, int rflag)
|
cmd_attach_session(struct cmdq_item *item, int dflag, int rflag,
|
||||||
|
const char *cflag, int Eflag)
|
||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s = item->state.tflag.s;
|
||||||
struct client *c;
|
struct client *c = item->client, *c_loop;
|
||||||
const char *update;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
char *cause;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
u_int i;
|
char *cause;
|
||||||
|
|
||||||
if (RB_EMPTY(&sessions)) {
|
if (RB_EMPTY(&sessions)) {
|
||||||
cmdq_error(cmdq, "no sessions");
|
cmdq_error(item, "no sessions");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
|
if (c == NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (cmdq->client == NULL)
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
if (server_client_check_nested(c)) {
|
||||||
|
cmdq_error(item, "sessions should be nested with care, "
|
||||||
|
"unset $TMUX to force");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
if (cmdq->client->session != NULL) {
|
if (wl != NULL) {
|
||||||
|
if (wp != NULL)
|
||||||
|
window_set_active_pane(wp->window, wp);
|
||||||
|
session_set_current(s, wl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cflag != NULL) {
|
||||||
|
free((void *)s->cwd);
|
||||||
|
s->cwd = format_single(item, cflag, c, s, wl, wp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c->session != NULL) {
|
||||||
if (dflag) {
|
if (dflag) {
|
||||||
/*
|
TAILQ_FOREACH(c_loop, &clients, entry) {
|
||||||
* Can't use server_write_session in case attaching to
|
if (c_loop->session != s || c == c_loop)
|
||||||
* the same session as currently attached to.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
|
||||||
c = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c == NULL || c->session != s)
|
|
||||||
continue;
|
continue;
|
||||||
if (c == cmdq->client)
|
server_client_detach(c_loop, MSG_DETACH);
|
||||||
continue;
|
|
||||||
server_write_client(c, MSG_DETACH, NULL, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!Eflag)
|
||||||
|
environ_update(s->options, c->environ, s->environ);
|
||||||
|
|
||||||
cmdq->client->session = s;
|
c->session = s;
|
||||||
notify_attached_session_changed(cmdq->client);
|
if (!item->repeat)
|
||||||
session_update_activity(s);
|
server_client_set_key_table(c, NULL);
|
||||||
server_redraw_client(cmdq->client);
|
status_timer_start(c);
|
||||||
|
notify_client("client-session-changed", c);
|
||||||
|
session_update_activity(s, NULL);
|
||||||
|
gettimeofday(&s->last_attached_time, NULL);
|
||||||
|
server_redraw_client(c);
|
||||||
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
} else {
|
} else {
|
||||||
if (server_client_open(cmdq->client, s, &cause) != 0) {
|
if (server_client_open(c, &cause) != 0) {
|
||||||
cmdq_error(cmdq, "open terminal failed: %s", cause);
|
cmdq_error(item, "open terminal failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rflag)
|
if (rflag)
|
||||||
cmdq->client->flags |= CLIENT_READONLY;
|
c->flags |= CLIENT_READONLY;
|
||||||
|
|
||||||
if (dflag)
|
if (dflag) {
|
||||||
server_write_session(s, MSG_DETACH, NULL, 0);
|
TAILQ_FOREACH(c_loop, &clients, entry) {
|
||||||
|
if (c_loop->session != s || c == c_loop)
|
||||||
|
continue;
|
||||||
|
server_client_detach(c_loop, MSG_DETACH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!Eflag)
|
||||||
|
environ_update(s->options, c->environ, s->environ);
|
||||||
|
|
||||||
update = options_get_string(&s->options, "update-environment");
|
c->session = s;
|
||||||
environ_update(update, &cmdq->client->environ, &s->environ);
|
server_client_set_key_table(c, NULL);
|
||||||
|
status_timer_start(c);
|
||||||
cmdq->client->session = s;
|
notify_client("client-session-changed", c);
|
||||||
notify_attached_session_changed(cmdq->client);
|
session_update_activity(s, NULL);
|
||||||
session_update_activity(s);
|
gettimeofday(&s->last_attached_time, NULL);
|
||||||
server_redraw_client(cmdq->client);
|
server_redraw_client(c);
|
||||||
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
|
|
||||||
server_write_ready(cmdq->client);
|
if (~c->flags & CLIENT_CONTROL)
|
||||||
cmdq->client_exit = 0;
|
proc_send(c->peer, MSG_READY, -1, NULL, 0);
|
||||||
|
notify_client("client-attached", c);
|
||||||
|
c->flags |= CLIENT_ATTACHED;
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
alerts_check_session(s);
|
||||||
server_update_socket();
|
server_update_socket();
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_attach_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
|
|
||||||
return (cmd_attach_session(cmdq, args_get(args, 't'),
|
return (cmd_attach_session(item, args_has(args, 'd'),
|
||||||
args_has(args, 'd'), args_has(args, 'r')));
|
args_has(args, 'r'), args_get(args, 'c'), args_has(args, 'E')));
|
||||||
}
|
}
|
||||||
|
|||||||
114
cmd-bind-key.c
114
cmd-bind-key.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -24,113 +24,53 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bind a key to a command, this recurses through cmd_*.
|
* Bind a key to a command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_bind_key_check(struct args *);
|
static enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmdq_item *);
|
||||||
enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
enum cmd_retval cmd_bind_key_table(struct cmd *, struct cmd_q *, int);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_bind_key_entry = {
|
const struct cmd_entry cmd_bind_key_entry = {
|
||||||
"bind-key", "bind",
|
.name = "bind-key",
|
||||||
"cnrt:", 1, -1,
|
.alias = "bind",
|
||||||
"[-cnr] [-t key-table] key command [arguments]",
|
|
||||||
0,
|
.args = { "cnrT:", 2, -1 },
|
||||||
NULL,
|
.usage = "[-cnr] [-T key-table] key "
|
||||||
cmd_bind_key_check,
|
"command [arguments]",
|
||||||
cmd_bind_key_exec
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_bind_key_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_bind_key_check(struct args *args)
|
cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
|
||||||
if (args_has(args, 't')) {
|
|
||||||
if (args->argc != 2 && args->argc != 3)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
} else {
|
|
||||||
if (args->argc < 2)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
char *cause;
|
char *cause;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
int key;
|
key_code key;
|
||||||
|
const char *tablename;
|
||||||
|
|
||||||
key = key_string_lookup_string(args->argv[0]);
|
key = key_string_lookup_string(args->argv[0]);
|
||||||
if (key == KEYC_NONE) {
|
if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
|
||||||
cmdq_error(cmdq, "unknown key: %s", args->argv[0]);
|
cmdq_error(item, "unknown key: %s", args->argv[0]);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 't'))
|
if (args_has(args, 'T'))
|
||||||
return (cmd_bind_key_table(self, cmdq, key));
|
tablename = args_get(args, 'T');
|
||||||
|
else if (args_has(args, 'n'))
|
||||||
|
tablename = "root";
|
||||||
|
else
|
||||||
|
tablename = "prefix";
|
||||||
|
|
||||||
cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, NULL, 0,
|
cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, NULL, 0,
|
||||||
&cause);
|
&cause);
|
||||||
if (cmdlist == NULL) {
|
if (cmdlist == NULL) {
|
||||||
cmdq_error(cmdq, "%s", cause);
|
cmdq_error(item, "%s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args_has(args, 'n'))
|
key_bindings_add(tablename, key, args_has(args, 'r'), cmdlist);
|
||||||
key |= KEYC_PREFIX;
|
|
||||||
key_bindings_add(key, args_has(args, 'r'), cmdlist);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_bind_key_table(struct cmd *self, struct cmd_q *cmdq, int key)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
const char *tablename;
|
|
||||||
const struct mode_key_table *mtab;
|
|
||||||
struct mode_key_binding *mbind, mtmp;
|
|
||||||
enum mode_key_cmd cmd;
|
|
||||||
const char *arg;
|
|
||||||
|
|
||||||
tablename = args_get(args, 't');
|
|
||||||
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
|
||||||
cmdq_error(cmdq, "unknown key table: %s", tablename);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd = mode_key_fromstring(mtab->cmdstr, args->argv[1]);
|
|
||||||
if (cmd == MODEKEY_NONE) {
|
|
||||||
cmdq_error(cmdq, "unknown command: %s", args->argv[1]);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cmd != MODEKEYCOPY_COPYPIPE) {
|
|
||||||
if (args->argc != 2) {
|
|
||||||
cmdq_error(cmdq, "no argument allowed");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
arg = NULL;
|
|
||||||
} else {
|
|
||||||
if (args->argc != 3) {
|
|
||||||
cmdq_error(cmdq, "no argument given");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
arg = args->argv[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
mtmp.key = key;
|
|
||||||
mtmp.mode = !!args_has(args, 'c');
|
|
||||||
if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) == NULL) {
|
|
||||||
mbind = xmalloc(sizeof *mbind);
|
|
||||||
mbind->key = mtmp.key;
|
|
||||||
mbind->mode = mtmp.mode;
|
|
||||||
RB_INSERT(mode_key_tree, mtab->tree, mbind);
|
|
||||||
}
|
|
||||||
mbind->cmd = cmd;
|
|
||||||
mbind->arg = arg != NULL ? xstrdup(arg) : NULL;
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
115
cmd-break-pane.c
115
cmd-break-pane.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -26,90 +26,89 @@
|
|||||||
* Break pane off into a window.
|
* Break pane off into a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmd_q *);
|
#define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_break_pane_entry = {
|
const struct cmd_entry cmd_break_pane_entry = {
|
||||||
"break-pane", "breakp",
|
.name = "break-pane",
|
||||||
"dPF:t:", 0, 0,
|
.alias = "breakp",
|
||||||
"[-dP] [-F format] " CMD_TARGET_PANE_USAGE,
|
|
||||||
0,
|
.args = { "dPF:n:s:t:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-dP] [-F format] [-n window-name] [-s src-pane] [-t dst-window]",
|
||||||
NULL,
|
|
||||||
cmd_break_pane_exec
|
.sflag = CMD_PANE,
|
||||||
|
.tflag = CMD_WINDOW_INDEX,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_break_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct client *c = item->state.c;
|
||||||
struct session *s;
|
struct winlink *wl = item->state.sflag.wl;
|
||||||
struct window_pane *wp;
|
struct session *src_s = item->state.sflag.s;
|
||||||
struct window *w;
|
struct session *dst_s = item->state.tflag.s;
|
||||||
char *name;
|
struct window_pane *wp = item->state.sflag.wp;
|
||||||
char *cause;
|
struct window *w = wl->window;
|
||||||
int base_idx;
|
char *name, *cause;
|
||||||
struct client *c;
|
int idx = item->state.tflag.idx;
|
||||||
struct format_tree *ft;
|
|
||||||
const char *template;
|
const char *template;
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
|
if (idx != -1 && winlink_find_by_index(&dst_s->windows, idx) != NULL) {
|
||||||
return (CMD_RETURN_ERROR);
|
cmdq_error(item, "index %d already in use", idx);
|
||||||
|
|
||||||
if (window_count_panes(wl->window) == 1) {
|
|
||||||
cmdq_error(cmdq, "can't break with only one pane");
|
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
w = wl->window;
|
if (window_count_panes(w) == 1) {
|
||||||
|
cmdq_error(item, "can't break with only one pane");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
server_unzoom_window(w);
|
server_unzoom_window(w);
|
||||||
|
|
||||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
if (wp == w->active) {
|
window_lost_pane(w, wp);
|
||||||
w->active = w->last;
|
|
||||||
w->last = NULL;
|
|
||||||
if (w->active == NULL) {
|
|
||||||
w->active = TAILQ_PREV(wp, window_panes, entry);
|
|
||||||
if (w->active == NULL)
|
|
||||||
w->active = TAILQ_NEXT(wp, entry);
|
|
||||||
}
|
|
||||||
} else if (wp == w->last)
|
|
||||||
w->last = NULL;
|
|
||||||
layout_close_pane(wp);
|
layout_close_pane(wp);
|
||||||
|
|
||||||
w = wp->window = window_create1(s->sx, s->sy);
|
w = wp->window = window_create(dst_s->sx, dst_s->sy);
|
||||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||||
w->active = wp;
|
w->active = wp;
|
||||||
name = default_window_name(w);
|
|
||||||
window_set_name(w, name);
|
if (!args_has(args, 'n')) {
|
||||||
free(name);
|
name = default_window_name(w);
|
||||||
|
window_set_name(w, name);
|
||||||
|
free(name);
|
||||||
|
} else {
|
||||||
|
window_set_name(w, args_get(args, 'n'));
|
||||||
|
options_set_number(w->options, "automatic-rename", 0);
|
||||||
|
}
|
||||||
|
|
||||||
layout_init(w, wp);
|
layout_init(w, wp);
|
||||||
|
wp->flags |= PANE_CHANGED;
|
||||||
|
|
||||||
base_idx = options_get_number(&s->options, "base-index");
|
if (idx == -1)
|
||||||
wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */
|
idx = -1 - options_get_number(dst_s->options, "base-index");
|
||||||
|
wl = session_attach(dst_s, w, idx, &cause); /* can't fail */
|
||||||
if (!args_has(self->args, 'd'))
|
if (!args_has(self->args, 'd'))
|
||||||
session_select(s, wl->idx);
|
session_select(dst_s, wl->idx);
|
||||||
|
|
||||||
server_redraw_session(s);
|
server_redraw_session(src_s);
|
||||||
server_status_session_group(s);
|
if (src_s != dst_s)
|
||||||
|
server_redraw_session(dst_s);
|
||||||
|
server_status_session_group(src_s);
|
||||||
|
if (src_s != dst_s)
|
||||||
|
server_status_session_group(dst_s);
|
||||||
|
|
||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = BREAK_PANE_TEMPLATE;
|
template = BREAK_PANE_TEMPLATE;
|
||||||
|
cp = format_single(item, template, c, dst_s, wl, wp);
|
||||||
ft = format_create();
|
cmdq_print(item, "%s", cp);
|
||||||
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
|
||||||
format_client(ft, c);
|
|
||||||
format_session(ft, s);
|
|
||||||
format_winlink(ft, s, wl);
|
|
||||||
format_window_pane(ft, wp);
|
|
||||||
|
|
||||||
cp = format_expand(ft, template);
|
|
||||||
cmdq_print(cmdq, "%s", cp);
|
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
format_free(ft);
|
|
||||||
}
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net>
|
* Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net>
|
||||||
@@ -27,56 +27,74 @@
|
|||||||
* Write the entire contents of a pane to a buffer or stdout.
|
* Write the entire contents of a pane to a buffer or stdout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
char *cmd_capture_pane_append(char *, size_t *, char *, size_t);
|
static char *cmd_capture_pane_append(char *, size_t *, char *, size_t);
|
||||||
char *cmd_capture_pane_pending(struct args *, struct window_pane *,
|
static char *cmd_capture_pane_pending(struct args *, struct window_pane *,
|
||||||
size_t *);
|
size_t *);
|
||||||
char *cmd_capture_pane_history(struct args *, struct cmd_q *,
|
static char *cmd_capture_pane_history(struct args *, struct cmdq_item *,
|
||||||
struct window_pane *, size_t *);
|
struct window_pane *, size_t *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_capture_pane_entry = {
|
const struct cmd_entry cmd_capture_pane_entry = {
|
||||||
"capture-pane", "capturep",
|
.name = "capture-pane",
|
||||||
"ab:CeE:JpPqS:t:", 0, 0,
|
.alias = "capturep",
|
||||||
"[-aCeJpPq] [-b buffer-index] [-E end-line] [-S start-line]"
|
|
||||||
CMD_TARGET_PANE_USAGE,
|
.args = { "ab:CeE:JpPqS:t:", 0, 0 },
|
||||||
0,
|
.usage = "[-aCeJpPq] " CMD_BUFFER_USAGE " [-E end-line] "
|
||||||
NULL,
|
"[-S start-line]" CMD_TARGET_PANE_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_capture_pane_exec
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_capture_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
char *
|
const struct cmd_entry cmd_clear_history_entry = {
|
||||||
|
.name = "clear-history",
|
||||||
|
.alias = "clearhist",
|
||||||
|
|
||||||
|
.args = { "t:", 0, 0 },
|
||||||
|
.usage = CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_capture_pane_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static char *
|
||||||
cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen)
|
cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen)
|
||||||
{
|
{
|
||||||
buf = xrealloc(buf, 1, *len + linelen + 1);
|
buf = xrealloc(buf, *len + linelen + 1);
|
||||||
memcpy(buf + *len, line, linelen);
|
memcpy(buf + *len, line, linelen);
|
||||||
*len += linelen;
|
*len += linelen;
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
||||||
size_t *len)
|
size_t *len)
|
||||||
{
|
{
|
||||||
char *buf, *line, tmp[5];
|
struct evbuffer *pending;
|
||||||
size_t linelen;
|
char *buf, *line, tmp[5];
|
||||||
u_int i;
|
size_t linelen;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
if (wp->ictx.since_ground == NULL)
|
pending = input_pending(wp);
|
||||||
|
if (pending == NULL)
|
||||||
return (xstrdup(""));
|
return (xstrdup(""));
|
||||||
|
|
||||||
line = EVBUFFER_DATA(wp->ictx.since_ground);
|
line = EVBUFFER_DATA(pending);
|
||||||
linelen = EVBUFFER_LENGTH(wp->ictx.since_ground);
|
linelen = EVBUFFER_LENGTH(pending);
|
||||||
|
|
||||||
buf = xstrdup("");
|
buf = xstrdup("");
|
||||||
if (args_has(args, 'C')) {
|
if (args_has(args, 'C')) {
|
||||||
for (i = 0; i < linelen; i++) {
|
for (i = 0; i < linelen; i++) {
|
||||||
if (line[i] >= ' ') {
|
if (line[i] >= ' ' && line[i] != '\\') {
|
||||||
tmp[0] = line[i];
|
tmp[0] = line[i];
|
||||||
tmp[1] = '\0';
|
tmp[1] = '\0';
|
||||||
} else
|
} else
|
||||||
xsnprintf(tmp, sizeof tmp, "\\%03o", line[i]);
|
xsnprintf(tmp, sizeof tmp, "\\%03hho", line[i]);
|
||||||
buf = cmd_capture_pane_append(buf, len, tmp,
|
buf = cmd_capture_pane_append(buf, len, tmp,
|
||||||
strlen(tmp));
|
strlen(tmp));
|
||||||
}
|
}
|
||||||
@@ -85,8 +103,8 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
|||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
|
cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
||||||
struct window_pane *wp, size_t *len)
|
struct window_pane *wp, size_t *len)
|
||||||
{
|
{
|
||||||
struct grid *gd;
|
struct grid *gd;
|
||||||
@@ -95,6 +113,7 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
|
|||||||
int n, with_codes, escape_c0, join_lines;
|
int n, with_codes, escape_c0, join_lines;
|
||||||
u_int i, sx, top, bottom, tmp;
|
u_int i, sx, top, bottom, tmp;
|
||||||
char *cause, *buf, *line;
|
char *cause, *buf, *line;
|
||||||
|
const char *Sflag, *Eflag;
|
||||||
size_t linelen;
|
size_t linelen;
|
||||||
|
|
||||||
sx = screen_size_x(&wp->base);
|
sx = screen_size_x(&wp->base);
|
||||||
@@ -102,7 +121,7 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
|
|||||||
gd = wp->saved_grid;
|
gd = wp->saved_grid;
|
||||||
if (gd == NULL) {
|
if (gd == NULL) {
|
||||||
if (!args_has(args, 'q')) {
|
if (!args_has(args, 'q')) {
|
||||||
cmdq_error(cmdq, "no alternate screen");
|
cmdq_error(item, "no alternate screen");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
return (xstrdup(""));
|
return (xstrdup(""));
|
||||||
@@ -110,27 +129,37 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
|
|||||||
} else
|
} else
|
||||||
gd = wp->base.grid;
|
gd = wp->base.grid;
|
||||||
|
|
||||||
n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause);
|
Sflag = args_get(args, 'S');
|
||||||
if (cause != NULL) {
|
if (Sflag != NULL && strcmp(Sflag, "-") == 0)
|
||||||
top = gd->hsize;
|
|
||||||
free(cause);
|
|
||||||
} else if (n < 0 && (u_int) -n > gd->hsize)
|
|
||||||
top = 0;
|
top = 0;
|
||||||
else
|
else {
|
||||||
top = gd->hsize + n;
|
n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause);
|
||||||
if (top > gd->hsize + gd->sy - 1)
|
if (cause != NULL) {
|
||||||
top = gd->hsize + gd->sy - 1;
|
top = gd->hsize;
|
||||||
|
free(cause);
|
||||||
|
} else if (n < 0 && (u_int) -n > gd->hsize)
|
||||||
|
top = 0;
|
||||||
|
else
|
||||||
|
top = gd->hsize + n;
|
||||||
|
if (top > gd->hsize + gd->sy - 1)
|
||||||
|
top = gd->hsize + gd->sy - 1;
|
||||||
|
}
|
||||||
|
|
||||||
n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause);
|
Eflag = args_get(args, 'E');
|
||||||
if (cause != NULL) {
|
if (Eflag != NULL && strcmp(Eflag, "-") == 0)
|
||||||
bottom = gd->hsize + gd->sy - 1;
|
|
||||||
free(cause);
|
|
||||||
} else if (n < 0 && (u_int) -n > gd->hsize)
|
|
||||||
bottom = 0;
|
|
||||||
else
|
|
||||||
bottom = gd->hsize + n;
|
|
||||||
if (bottom > gd->hsize + gd->sy - 1)
|
|
||||||
bottom = gd->hsize + gd->sy - 1;
|
bottom = gd->hsize + gd->sy - 1;
|
||||||
|
else {
|
||||||
|
n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
bottom = gd->hsize + gd->sy - 1;
|
||||||
|
free(cause);
|
||||||
|
} else if (n < 0 && (u_int) -n > gd->hsize)
|
||||||
|
bottom = 0;
|
||||||
|
else
|
||||||
|
bottom = gd->hsize + n;
|
||||||
|
if (bottom > gd->hsize + gd->sy - 1)
|
||||||
|
bottom = gd->hsize + gd->sy - 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (bottom < top) {
|
if (bottom < top) {
|
||||||
tmp = bottom;
|
tmp = bottom;
|
||||||
@@ -159,56 +188,52 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
|
|||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
char *buf, *cause;
|
char *buf, *cause;
|
||||||
int buffer;
|
const char *bufname;
|
||||||
u_int limit;
|
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
|
if (self->entry == &cmd_clear_history_entry) {
|
||||||
return (CMD_RETURN_ERROR);
|
if (wp->mode == &window_copy_mode)
|
||||||
|
window_pane_reset_mode(wp);
|
||||||
|
grid_clear_history(wp->base.grid);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
if (args_has(args, 'P'))
|
if (args_has(args, 'P'))
|
||||||
buf = cmd_capture_pane_pending(args, wp, &len);
|
buf = cmd_capture_pane_pending(args, wp, &len);
|
||||||
else
|
else
|
||||||
buf = cmd_capture_pane_history(args, cmdq, wp, &len);
|
buf = cmd_capture_pane_history(args, item, wp, &len);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, 'p')) {
|
if (args_has(args, 'p')) {
|
||||||
c = cmdq->client;
|
c = item->client;
|
||||||
if (c == NULL ||
|
if (c == NULL ||
|
||||||
(c->session != NULL && !(c->flags & CLIENT_CONTROL))) {
|
(c->session != NULL && !(c->flags & CLIENT_CONTROL))) {
|
||||||
cmdq_error(cmdq, "can't write to stdout");
|
cmdq_error(item, "can't write to stdout");
|
||||||
|
free(buf);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
evbuffer_add(c->stdout_data, buf, len);
|
evbuffer_add(c->stdout_data, buf, len);
|
||||||
|
free(buf);
|
||||||
if (args_has(args, 'P') && len > 0)
|
if (args_has(args, 'P') && len > 0)
|
||||||
evbuffer_add(c->stdout_data, "\n", 1);
|
evbuffer_add(c->stdout_data, "\n", 1);
|
||||||
server_push_stdout(c);
|
server_client_push_stdout(c);
|
||||||
} else {
|
} else {
|
||||||
limit = options_get_number(&global_options, "buffer-limit");
|
bufname = NULL;
|
||||||
if (!args_has(args, 'b')) {
|
if (args_has(args, 'b'))
|
||||||
paste_add(&global_buffers, buf, len, limit);
|
bufname = args_get(args, 'b');
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
if (paste_set(buf, len, bufname, &cause) != 0) {
|
||||||
if (cause != NULL) {
|
cmdq_error(item, "%s", cause);
|
||||||
cmdq_error(cmdq, "buffer %s", cause);
|
|
||||||
free(buf);
|
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paste_replace(&global_buffers, buffer, buf, len) != 0) {
|
|
||||||
cmdq_error(cmdq, "no buffer %d", buffer);
|
|
||||||
free(buf);
|
free(buf);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,42 +27,46 @@
|
|||||||
* Enter choice mode to choose a buffer.
|
* Enter choice mode to choose a buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_choose_buffer_exec(struct cmd *, struct cmd_q *);
|
#define CHOOSE_BUFFER_TEMPLATE \
|
||||||
|
"#{buffer_name}: #{buffer_size} bytes: #{buffer_sample}"
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_choose_buffer_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_buffer_entry = {
|
const struct cmd_entry cmd_choose_buffer_entry = {
|
||||||
"choose-buffer", NULL,
|
.name = "choose-buffer",
|
||||||
"F:t:", 0, 1,
|
.alias = NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
|
||||||
0,
|
.args = { "F:t:", 0, 1 },
|
||||||
NULL,
|
.usage = CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||||
NULL,
|
|
||||||
cmd_choose_buffer_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_choose_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_choose_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c = item->state.c;
|
||||||
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct window_choose_data *cdata;
|
struct window_choose_data *cdata;
|
||||||
struct winlink *wl;
|
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
char *action, *action_data;
|
char *action, *action_data;
|
||||||
const char *template;
|
const char *template;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
|
|
||||||
if ((c = cmd_current_client(cmdq)) == NULL) {
|
if (c == NULL) {
|
||||||
cmdq_error(cmdq, "no client available");
|
cmdq_error(item, "no client available");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = CHOOSE_BUFFER_TEMPLATE;
|
template = CHOOSE_BUFFER_TEMPLATE;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
if (paste_get_top(NULL) == NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (paste_get_top(&global_buffers) == NULL)
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
@@ -74,19 +78,20 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
action = xstrdup("paste-buffer -b '%%'");
|
action = xstrdup("paste-buffer -b '%%'");
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
|
pb = NULL;
|
||||||
|
while ((pb = paste_walk(pb)) != NULL) {
|
||||||
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
||||||
cdata->idx = idx - 1;
|
cdata->idx = idx;
|
||||||
|
|
||||||
cdata->ft_template = xstrdup(template);
|
cdata->ft_template = xstrdup(template);
|
||||||
format_add(cdata->ft, "line", "%u", idx - 1);
|
format_defaults_paste_buffer(cdata->ft, pb);
|
||||||
format_paste_buffer(cdata->ft, pb);
|
|
||||||
|
|
||||||
xasprintf(&action_data, "%u", idx - 1);
|
xasprintf(&action_data, "%s", paste_buffer_name(pb));
|
||||||
cdata->command = cmd_template_replace(action, action_data, 1);
|
cdata->command = cmd_template_replace(action, action_data, 1);
|
||||||
free(action_data);
|
free(action_data);
|
||||||
|
|
||||||
window_choose_add(wl->window->active, cdata);
|
window_choose_add(wl->window->active, cdata);
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
free(action);
|
free(action);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,44 +27,51 @@
|
|||||||
* Enter choice mode to choose a client.
|
* Enter choice mode to choose a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_choose_client_exec(struct cmd *, struct cmd_q *);
|
#define CHOOSE_CLIENT_TEMPLATE \
|
||||||
|
"#{client_name}: #{session_name} " \
|
||||||
|
"[#{client_width}x#{client_height} #{client_termname}]" \
|
||||||
|
"#{?client_utf8, (utf8),}#{?client_readonly, (ro),} " \
|
||||||
|
"(last used #{t:client_activity})"
|
||||||
|
|
||||||
void cmd_choose_client_callback(struct window_choose_data *);
|
static enum cmd_retval cmd_choose_client_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
|
static void cmd_choose_client_callback(struct window_choose_data *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_client_entry = {
|
const struct cmd_entry cmd_choose_client_entry = {
|
||||||
"choose-client", NULL,
|
.name = "choose-client",
|
||||||
"F:t:", 0, 1,
|
.alias = NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
|
||||||
0,
|
.args = { "F:t:", 0, 1 },
|
||||||
NULL,
|
.usage = CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||||
NULL,
|
|
||||||
cmd_choose_client_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_choose_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_choose_client_data {
|
struct cmd_choose_client_data {
|
||||||
struct client *client;
|
struct client *client;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_choose_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c = item->state.c;
|
||||||
struct client *c1;
|
struct client *c1;
|
||||||
struct window_choose_data *cdata;
|
struct window_choose_data *cdata;
|
||||||
struct winlink *wl;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
const char *template;
|
const char *template;
|
||||||
char *action;
|
char *action;
|
||||||
u_int i, idx, cur;
|
u_int idx, cur;
|
||||||
|
|
||||||
if ((c = cmd_current_client(cmdq)) == NULL) {
|
if (c == NULL) {
|
||||||
cmdq_error(cmdq, "no client available");
|
cmdq_error(item, "no client available");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
@@ -77,25 +84,24 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
action = xstrdup("detach-client -t '%%'");
|
action = xstrdup("detach-client -t '%%'");
|
||||||
|
|
||||||
cur = idx = 0;
|
cur = idx = 0;
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
TAILQ_FOREACH(c1, &clients, entry) {
|
||||||
c1 = ARRAY_ITEM(&clients, i);
|
if (c1->session == NULL)
|
||||||
if (c1 == NULL || c1->session == NULL || c1->tty.path == NULL)
|
|
||||||
continue;
|
continue;
|
||||||
if (c1 == cmdq->client)
|
if (c1 == item->client)
|
||||||
cur = idx;
|
cur = idx;
|
||||||
idx++;
|
|
||||||
|
|
||||||
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
||||||
cdata->idx = i;
|
cdata->idx = idx;
|
||||||
|
|
||||||
cdata->ft_template = xstrdup(template);
|
cdata->ft_template = xstrdup(template);
|
||||||
format_add(cdata->ft, "line", "%u", i);
|
format_add(cdata->ft, "line", "%u", idx);
|
||||||
format_session(cdata->ft, c1->session);
|
format_defaults(cdata->ft, c1, NULL, NULL, NULL);
|
||||||
format_client(cdata->ft, c1);
|
|
||||||
|
|
||||||
cdata->command = cmd_template_replace(action, c1->tty.path, 1);
|
cdata->command = cmd_template_replace(action, c1->name, 1);
|
||||||
|
|
||||||
window_choose_add(wl->window->active, cdata);
|
window_choose_add(wl->window->active, cdata);
|
||||||
|
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
free(action);
|
free(action);
|
||||||
|
|
||||||
@@ -105,19 +111,23 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_choose_client_callback(struct window_choose_data *cdata)
|
cmd_choose_client_callback(struct window_choose_data *cdata)
|
||||||
{
|
{
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
u_int idx;
|
||||||
|
|
||||||
if (cdata == NULL)
|
if (cdata == NULL)
|
||||||
return;
|
return;
|
||||||
if (cdata->start_client->flags & CLIENT_DEAD)
|
if (cdata->start_client->flags & CLIENT_DEAD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cdata->idx > ARRAY_LENGTH(&clients) - 1)
|
idx = 0;
|
||||||
return;
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
c = ARRAY_ITEM(&clients, cdata->idx);
|
if (idx == cdata->idx)
|
||||||
|
break;
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
if (c == NULL || c->session == NULL)
|
if (c == NULL || c->session == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
#define CMD_CHOOSE_LIST_DEFAULT_TEMPLATE "run-shell '%%'"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enter choose mode to choose a custom list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum cmd_retval cmd_choose_list_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_list_entry = {
|
|
||||||
"choose-list", NULL,
|
|
||||||
"l:t:", 0, 1,
|
|
||||||
"[-l items] " CMD_TARGET_WINDOW_USAGE "[template]",
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_choose_list_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_choose_list_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct client *c;
|
|
||||||
struct winlink *wl;
|
|
||||||
const char *list1;
|
|
||||||
char *template, *item, *copy, *list;
|
|
||||||
u_int idx;
|
|
||||||
|
|
||||||
if ((c = cmd_current_client(cmdq)) == NULL) {
|
|
||||||
cmdq_error(cmdq, "no client available");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((list1 = args_get(args, 'l')) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
|
|
||||||
if (args->argc != 0)
|
|
||||||
template = xstrdup(args->argv[0]);
|
|
||||||
else
|
|
||||||
template = xstrdup(CMD_CHOOSE_LIST_DEFAULT_TEMPLATE);
|
|
||||||
|
|
||||||
copy = list = xstrdup(list1);
|
|
||||||
idx = 0;
|
|
||||||
while ((item = strsep(&list, ",")) != NULL)
|
|
||||||
{
|
|
||||||
if (*item == '\0') /* no empty entries */
|
|
||||||
continue;
|
|
||||||
window_choose_add_item(wl->window->active, c, wl, item,
|
|
||||||
template, idx);
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
free(copy);
|
|
||||||
|
|
||||||
if (idx == 0) {
|
|
||||||
free(template);
|
|
||||||
window_pane_reset_mode(wl->window->active);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active, 0, NULL);
|
|
||||||
|
|
||||||
free(template);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.org>
|
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.org>
|
||||||
@@ -32,46 +32,64 @@
|
|||||||
* Enter choice mode to choose a session and/or window.
|
* Enter choice mode to choose a session and/or window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmd_q *);
|
#define CHOOSE_TREE_SESSION_TEMPLATE \
|
||||||
|
"#{session_name}: #{session_windows} windows" \
|
||||||
|
"#{?session_grouped, (group ,}" \
|
||||||
|
"#{session_group}#{?session_grouped,),}" \
|
||||||
|
"#{?session_attached, (attached),}"
|
||||||
|
#define CHOOSE_TREE_WINDOW_TEMPLATE \
|
||||||
|
"#{window_index}: #{window_name}#{window_flags} " \
|
||||||
|
"\"#{pane_title}\""
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_tree_entry = {
|
const struct cmd_entry cmd_choose_tree_entry = {
|
||||||
"choose-tree", NULL,
|
.name = "choose-tree",
|
||||||
"S:W:swub:c:t:", 0, 1,
|
.alias = NULL,
|
||||||
"[-suw] [-b session-template] [-c window template] [-S format] " \
|
|
||||||
"[-W format] " CMD_TARGET_WINDOW_USAGE,
|
.args = { "S:W:swub:c:t:", 0, 1 },
|
||||||
0,
|
.usage = "[-suw] [-b session-template] [-c window template] "
|
||||||
NULL,
|
"[-S format] [-W format] " CMD_TARGET_WINDOW_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_choose_tree_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_choose_tree_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_session_entry = {
|
const struct cmd_entry cmd_choose_session_entry = {
|
||||||
"choose-session", NULL,
|
.name = "choose-session",
|
||||||
"F:t:", 0, 1,
|
.alias = NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
|
||||||
0,
|
.args = { "F:t:", 0, 1 },
|
||||||
NULL,
|
.usage = CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||||
NULL,
|
|
||||||
cmd_choose_tree_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_choose_tree_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_window_entry = {
|
const struct cmd_entry cmd_choose_window_entry = {
|
||||||
"choose-window", NULL,
|
.name = "choose-window",
|
||||||
"F:t:", 0, 1,
|
.alias = NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE "[-F format] [template]",
|
|
||||||
0,
|
.args = { "F:t:", 0, 1 },
|
||||||
NULL,
|
.usage = CMD_TARGET_WINDOW_USAGE "[-F format] [template]",
|
||||||
NULL,
|
|
||||||
cmd_choose_tree_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_choose_tree_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_choose_tree_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl, *wm;
|
struct client *c = item->state.c;
|
||||||
struct session *s, *s2;
|
struct winlink *wl = item->state.tflag.wl, *wm;
|
||||||
struct client *c;
|
struct session *s = item->state.tflag.s, *s2;
|
||||||
struct window_choose_data *wcd = NULL;
|
struct window_choose_data *wcd = NULL;
|
||||||
const char *ses_template, *win_template;
|
const char *ses_template, *win_template;
|
||||||
char *final_win_action, *cur_win_template;
|
char *final_win_action, *cur_win_template;
|
||||||
@@ -84,17 +102,11 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
ses_template = win_template = NULL;
|
ses_template = win_template = NULL;
|
||||||
ses_action = win_action = NULL;
|
ses_action = win_action = NULL;
|
||||||
|
|
||||||
if ((c = cmd_current_client(cmdq)) == NULL) {
|
if (c == NULL) {
|
||||||
cmdq_error(cmdq, "no client available");
|
cmdq_error(item, "no client available");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s = c->session) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
@@ -232,8 +244,10 @@ windows_only:
|
|||||||
|
|
||||||
window_choose_ready(wl->window->active, cur_win, NULL);
|
window_choose_ready(wl->window->active, cur_win, NULL);
|
||||||
|
|
||||||
if (args_has(args, 'u'))
|
if (args_has(args, 'u')) {
|
||||||
window_choose_expand_all(wl->window->active);
|
window_choose_expand_all(wl->window->active);
|
||||||
|
window_choose_set_current(wl->window->active, cur_win);
|
||||||
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clear pane history.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum cmd_retval cmd_clear_history_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_clear_history_entry = {
|
|
||||||
"clear-history", "clearhist",
|
|
||||||
"t:", 0, 0,
|
|
||||||
CMD_TARGET_PANE_USAGE,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_clear_history_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_clear_history_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct window_pane *wp;
|
|
||||||
struct grid *gd;
|
|
||||||
|
|
||||||
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
gd = wp->base.grid;
|
|
||||||
|
|
||||||
grid_move_lines(gd, 0, gd->hsize, gd->sy);
|
|
||||||
gd->hsize = 0;
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -29,85 +29,64 @@
|
|||||||
* Prompt for command in client.
|
* Prompt for command in client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_command_prompt_key_binding(struct cmd *, int);
|
static enum cmd_retval cmd_command_prompt_exec(struct cmd *,
|
||||||
int cmd_command_prompt_check(struct args *);
|
struct cmdq_item *);
|
||||||
enum cmd_retval cmd_command_prompt_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
int cmd_command_prompt_callback(void *, const char *);
|
static int cmd_command_prompt_callback(void *, const char *, int);
|
||||||
void cmd_command_prompt_free(void *);
|
static void cmd_command_prompt_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_command_prompt_entry = {
|
const struct cmd_entry cmd_command_prompt_entry = {
|
||||||
"command-prompt", NULL,
|
.name = "command-prompt",
|
||||||
"I:p:t:", 0, 1,
|
.alias = NULL,
|
||||||
"[-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " [template]",
|
|
||||||
0,
|
.args = { "1iI:Np:t:", 0, 1 },
|
||||||
cmd_command_prompt_key_binding,
|
.usage = "[-1Ni] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " "
|
||||||
NULL,
|
"[template]",
|
||||||
cmd_command_prompt_exec
|
|
||||||
|
.tflag = CMD_CLIENT,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_command_prompt_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_command_prompt_cdata {
|
struct cmd_command_prompt_cdata {
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
int flags;
|
||||||
|
|
||||||
char *inputs;
|
char *inputs;
|
||||||
char *next_input;
|
char *next_input;
|
||||||
char *next_prompt;
|
|
||||||
char *prompts;
|
char *prompts;
|
||||||
|
char *next_prompt;
|
||||||
|
|
||||||
char *template;
|
char *template;
|
||||||
int idx;
|
int idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_command_prompt_key_binding(struct cmd *self, int key)
|
cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
|
||||||
switch (key) {
|
|
||||||
case '$':
|
|
||||||
self->args = args_create(1, "rename-session '%%'");
|
|
||||||
args_set(self->args, 'I', "#S");
|
|
||||||
break;
|
|
||||||
case ',':
|
|
||||||
self->args = args_create(1, "rename-window '%%'");
|
|
||||||
args_set(self->args, 'I', "#W");
|
|
||||||
break;
|
|
||||||
case '.':
|
|
||||||
self->args = args_create(1, "move-window -t '%%'");
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
self->args = args_create(1, "find-window '%%'");
|
|
||||||
break;
|
|
||||||
case '\'':
|
|
||||||
self->args = args_create(1, "select-window -t ':%%'");
|
|
||||||
args_set(self->args, 'p', "index");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
self->args = args_create(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
const char *inputs, *prompts;
|
const char *inputs, *prompts;
|
||||||
struct cmd_command_prompt_cdata *cdata;
|
struct cmd_command_prompt_cdata *cdata;
|
||||||
struct client *c;
|
struct client *c = item->state.c;
|
||||||
char *prompt, *ptr, *input = NULL;
|
char *prompt, *ptr, *input = NULL;
|
||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (c->prompt_string != NULL)
|
if (c->prompt_string != NULL)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
cdata->c = c;
|
cdata->c = c;
|
||||||
cdata->idx = 1;
|
|
||||||
cdata->inputs = NULL;
|
cdata->inputs = NULL;
|
||||||
cdata->next_input = NULL;
|
cdata->next_input = NULL;
|
||||||
cdata->next_prompt = NULL;
|
|
||||||
cdata->prompts = NULL;
|
cdata->prompts = NULL;
|
||||||
|
cdata->next_prompt = NULL;
|
||||||
|
|
||||||
cdata->template = NULL;
|
cdata->template = NULL;
|
||||||
|
cdata->idx = 1;
|
||||||
|
|
||||||
if (args->argc != 0)
|
if (args->argc != 0)
|
||||||
cdata->template = xstrdup(args->argv[0]);
|
cdata->template = xstrdup(args->argv[0]);
|
||||||
@@ -137,34 +116,56 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
input = strsep(&cdata->next_input, ",");
|
input = strsep(&cdata->next_input, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args_has(args, '1'))
|
||||||
|
cdata->flags |= PROMPT_SINGLE;
|
||||||
|
else if (args_has(args, 'N'))
|
||||||
|
cdata->flags |= PROMPT_NUMERIC;
|
||||||
|
else if (args_has(args, 'i'))
|
||||||
|
cdata->flags |= PROMPT_INCREMENTAL;
|
||||||
status_prompt_set(c, prompt, input, cmd_command_prompt_callback,
|
status_prompt_set(c, prompt, input, cmd_command_prompt_callback,
|
||||||
cmd_command_prompt_free, cdata, 0);
|
cmd_command_prompt_free, cdata, cdata->flags);
|
||||||
free(prompt);
|
free(prompt);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static enum cmd_retval
|
||||||
cmd_command_prompt_callback(void *data, const char *s)
|
cmd_command_prompt_error(struct cmdq_item *item, void *data)
|
||||||
|
{
|
||||||
|
char *error = data;
|
||||||
|
|
||||||
|
cmdq_error(item, "%s", error);
|
||||||
|
free(error);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmd_command_prompt_callback(void *data, const char *s, int done)
|
||||||
{
|
{
|
||||||
struct cmd_command_prompt_cdata *cdata = data;
|
struct cmd_command_prompt_cdata *cdata = data;
|
||||||
struct client *c = cdata->c;
|
struct client *c = cdata->c;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
|
struct cmdq_item *new_item;
|
||||||
char *cause, *new_template, *prompt, *ptr;
|
char *cause, *new_template, *prompt, *ptr;
|
||||||
char *input = NULL;
|
char *input = NULL;
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
|
if (done && (cdata->flags & PROMPT_INCREMENTAL))
|
||||||
|
return (0);
|
||||||
|
|
||||||
new_template = cmd_template_replace(cdata->template, s, cdata->idx);
|
new_template = cmd_template_replace(cdata->template, s, cdata->idx);
|
||||||
free(cdata->template);
|
if (done) {
|
||||||
cdata->template = new_template;
|
free(cdata->template);
|
||||||
|
cdata->template = new_template;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if there are more prompts; if so, get its respective input
|
* Check if there are more prompts; if so, get its respective input
|
||||||
* and update the prompt data.
|
* and update the prompt data.
|
||||||
*/
|
*/
|
||||||
if ((ptr = strsep(&cdata->next_prompt, ",")) != NULL) {
|
if (done && (ptr = strsep(&cdata->next_prompt, ",")) != NULL) {
|
||||||
xasprintf(&prompt, "%s ", ptr);
|
xasprintf(&prompt, "%s ", ptr);
|
||||||
input = strsep(&cdata->next_input, ",");
|
input = strsep(&cdata->next_input, ",");
|
||||||
status_prompt_update(c, prompt, input);
|
status_prompt_update(c, prompt, input);
|
||||||
@@ -174,24 +175,29 @@ cmd_command_prompt_callback(void *data, const char *s)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd_string_parse(new_template, &cmdlist, NULL, 0, &cause) != 0) {
|
cmdlist = cmd_string_parse(new_template, NULL, 0, &cause);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
*cause = toupper((u_char) *cause);
|
new_item = cmdq_get_callback(cmd_command_prompt_error,
|
||||||
status_message_set(c, "%s", cause);
|
cause);
|
||||||
free(cause);
|
} else
|
||||||
}
|
new_item = NULL;
|
||||||
return (0);
|
} else {
|
||||||
|
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdq_run(c->cmdq, cmdlist);
|
if (new_item != NULL)
|
||||||
cmd_list_free(cmdlist);
|
cmdq_append(c, new_item);
|
||||||
|
|
||||||
if (c->prompt_callbackfn != (void *) &cmd_command_prompt_callback)
|
if (!done)
|
||||||
|
free(new_template);
|
||||||
|
if (c->prompt_callbackfn != (void *)&cmd_command_prompt_callback)
|
||||||
return (1);
|
return (1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_command_prompt_free(void *data)
|
cmd_command_prompt_free(void *data)
|
||||||
{
|
{
|
||||||
struct cmd_command_prompt_cdata *cdata = data;
|
struct cmd_command_prompt_cdata *cdata = data;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -26,20 +28,23 @@
|
|||||||
* Asks for confirmation before executing a command.
|
* Asks for confirmation before executing a command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_confirm_before_key_binding(struct cmd *, int);
|
static enum cmd_retval cmd_confirm_before_exec(struct cmd *,
|
||||||
enum cmd_retval cmd_confirm_before_exec(struct cmd *, struct cmd_q *);
|
struct cmdq_item *);
|
||||||
|
|
||||||
int cmd_confirm_before_callback(void *, const char *);
|
static int cmd_confirm_before_callback(void *, const char *, int);
|
||||||
void cmd_confirm_before_free(void *);
|
static void cmd_confirm_before_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_confirm_before_entry = {
|
const struct cmd_entry cmd_confirm_before_entry = {
|
||||||
"confirm-before", "confirm",
|
.name = "confirm-before",
|
||||||
"p:t:", 1, 1,
|
.alias = "confirm",
|
||||||
"[-p prompt] " CMD_TARGET_CLIENT_USAGE " command",
|
|
||||||
0,
|
.args = { "p:t:", 1, 1 },
|
||||||
cmd_confirm_before_key_binding,
|
.usage = "[-p prompt] " CMD_TARGET_CLIENT_USAGE " command",
|
||||||
NULL,
|
|
||||||
cmd_confirm_before_exec
|
.tflag = CMD_CLIENT,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_confirm_before_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_confirm_before_data {
|
struct cmd_confirm_before_data {
|
||||||
@@ -47,36 +52,15 @@ struct cmd_confirm_before_data {
|
|||||||
struct client *client;
|
struct client *client;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_confirm_before_key_binding(struct cmd *self, int key)
|
cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
|
||||||
switch (key) {
|
|
||||||
case '&':
|
|
||||||
self->args = args_create(1, "kill-window");
|
|
||||||
args_set(self->args, 'p', "kill-window #W? (y/n)");
|
|
||||||
break;
|
|
||||||
case 'x':
|
|
||||||
self->args = args_create(1, "kill-pane");
|
|
||||||
args_set(self->args, 'p', "kill-pane #P? (y/n)");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
self->args = args_create(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct cmd_confirm_before_data *cdata;
|
struct cmd_confirm_before_data *cdata;
|
||||||
struct client *c;
|
struct client *c = item->state.c;
|
||||||
char *cmd, *copy, *new_prompt, *ptr;
|
char *cmd, *copy, *new_prompt, *ptr;
|
||||||
const char *prompt;
|
const char *prompt;
|
||||||
|
|
||||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if ((prompt = args_get(args, 'p')) != NULL)
|
if ((prompt = args_get(args, 'p')) != NULL)
|
||||||
xasprintf(&new_prompt, "%s ", prompt);
|
xasprintf(&new_prompt, "%s ", prompt);
|
||||||
else {
|
else {
|
||||||
@@ -100,12 +84,24 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static enum cmd_retval
|
||||||
cmd_confirm_before_callback(void *data, const char *s)
|
cmd_confirm_before_error(struct cmdq_item *item, void *data)
|
||||||
|
{
|
||||||
|
char *error = data;
|
||||||
|
|
||||||
|
cmdq_error(item, "%s", error);
|
||||||
|
free(error);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmd_confirm_before_callback(void *data, const char *s, __unused int done)
|
||||||
{
|
{
|
||||||
struct cmd_confirm_before_data *cdata = data;
|
struct cmd_confirm_before_data *cdata = data;
|
||||||
struct client *c = cdata->client;
|
struct client *c = cdata->client;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
|
struct cmdq_item *new_item;
|
||||||
char *cause;
|
char *cause;
|
||||||
|
|
||||||
if (c->flags & CLIENT_DEAD)
|
if (c->flags & CLIENT_DEAD)
|
||||||
@@ -116,27 +112,31 @@ cmd_confirm_before_callback(void *data, const char *s)
|
|||||||
if (tolower((u_char) s[0]) != 'y' || s[1] != '\0')
|
if (tolower((u_char) s[0]) != 'y' || s[1] != '\0')
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if (cmd_string_parse(cdata->cmd, &cmdlist, NULL, 0, &cause) != 0) {
|
cmdlist = cmd_string_parse(cdata->cmd, NULL, 0, &cause);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
cmdq_error(c->cmdq, "%s", cause);
|
new_item = cmdq_get_callback(cmd_confirm_before_error,
|
||||||
free(cause);
|
cause);
|
||||||
}
|
} else
|
||||||
return (0);
|
new_item = NULL;
|
||||||
|
} else {
|
||||||
|
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdq_run(c->cmdq, cmdlist);
|
if (new_item != NULL)
|
||||||
cmd_list_free(cmdlist);
|
cmdq_append(c, new_item);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_confirm_before_free(void *data)
|
cmd_confirm_before_free(void *data)
|
||||||
{
|
{
|
||||||
struct cmd_confirm_before_data *cdata = data;
|
struct cmd_confirm_before_data *cdata = data;
|
||||||
struct client *c = cdata->client;
|
struct client *c = cdata->client;
|
||||||
|
|
||||||
c->references--;
|
server_client_unref(c);
|
||||||
|
|
||||||
free(cdata->cmd);
|
free(cdata->cmd);
|
||||||
free(cdata);
|
free(cdata);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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,44 +21,69 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enter copy mode.
|
* Enter copy or clock mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_copy_mode_key_binding(struct cmd *, int);
|
static enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmdq_item *);
|
||||||
enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_copy_mode_entry = {
|
const struct cmd_entry cmd_copy_mode_entry = {
|
||||||
"copy-mode", NULL,
|
.name = "copy-mode",
|
||||||
"t:u", 0, 0,
|
.alias = NULL,
|
||||||
"[-u] " CMD_TARGET_PANE_USAGE,
|
|
||||||
0,
|
.args = { "Met:u", 0, 0 },
|
||||||
cmd_copy_mode_key_binding,
|
.usage = "[-Mu] " CMD_TARGET_PANE_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_copy_mode_exec
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_copy_mode_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
const struct cmd_entry cmd_clock_mode_entry = {
|
||||||
cmd_copy_mode_key_binding(struct cmd *self, int key)
|
.name = "clock-mode",
|
||||||
{
|
.alias = NULL,
|
||||||
self->args = args_create(0);
|
|
||||||
if (key == KEYC_PPAGE)
|
|
||||||
args_set(self->args, 'u', NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
.args = { "t:", 0, 0 },
|
||||||
cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq)
|
.usage = CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_copy_mode_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct client *c = item->client;
|
||||||
|
struct session *s;
|
||||||
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
|
|
||||||
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
|
if (args_has(args, 'M')) {
|
||||||
return (CMD_RETURN_ERROR);
|
if ((wp = cmd_mouse_pane(&item->mouse, &s, NULL)) == NULL)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
if (c == NULL || c->session != s)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
if (self->entry == &cmd_clock_mode_entry) {
|
||||||
|
window_pane_set_mode(wp, &window_clock_mode);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
window_copy_init_from_pane(wp);
|
}
|
||||||
|
|
||||||
|
if (wp->mode != &window_copy_mode) {
|
||||||
|
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
window_copy_init_from_pane(wp, args_has(self->args, 'e'));
|
||||||
|
}
|
||||||
|
if (args_has(args, 'M')) {
|
||||||
|
if (wp->mode != NULL && wp->mode != &window_copy_mode)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
window_copy_start_drag(c, &item->mouse);
|
||||||
|
}
|
||||||
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
|
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
|
||||||
window_copy_pageup(wp);
|
window_copy_pageup(wp, 0);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Delete a paste buffer.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum cmd_retval cmd_delete_buffer_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_delete_buffer_entry = {
|
|
||||||
"delete-buffer", "deleteb",
|
|
||||||
"b:", 0, 0,
|
|
||||||
CMD_BUFFER_USAGE,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_delete_buffer_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_delete_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
char *cause;
|
|
||||||
int buffer;
|
|
||||||
|
|
||||||
if (!args_has(args, 'b')) {
|
|
||||||
paste_free_top(&global_buffers);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
|
||||||
if (cause != NULL) {
|
|
||||||
cmdq_error(cmdq, "buffer %s", cause);
|
|
||||||
free(cause);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paste_free_index(&global_buffers, buffer) != 0) {
|
|
||||||
cmdq_error(cmdq, "no buffer %d", buffer);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -18,32 +18,60 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Detach a client.
|
* Detach a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_detach_client_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_detach_client_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_detach_client_entry = {
|
const struct cmd_entry cmd_detach_client_entry = {
|
||||||
"detach-client", "detach",
|
.name = "detach-client",
|
||||||
"as:t:P", 0, 0,
|
.alias = "detach",
|
||||||
"[-P] [-a] [-s target-session] " CMD_TARGET_CLIENT_USAGE,
|
|
||||||
CMD_READONLY,
|
.args = { "aE:s:t:P", 0, 0 },
|
||||||
NULL,
|
.usage = "[-aP] [-E shell-command] "
|
||||||
NULL,
|
"[-s target-session] " CMD_TARGET_CLIENT_USAGE,
|
||||||
cmd_detach_client_exec
|
|
||||||
|
.sflag = CMD_SESSION,
|
||||||
|
.tflag = CMD_CLIENT,
|
||||||
|
|
||||||
|
.flags = CMD_READONLY,
|
||||||
|
.exec = cmd_detach_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
const struct cmd_entry cmd_suspend_client_entry = {
|
||||||
cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
.name = "suspend-client",
|
||||||
|
.alias = "suspendc",
|
||||||
|
|
||||||
|
.args = { "t:", 0, 0 },
|
||||||
|
.usage = CMD_TARGET_CLIENT_USAGE,
|
||||||
|
|
||||||
|
.tflag = CMD_CLIENT,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_detach_client_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c, *c2;
|
struct client *c = item->state.c, *cloop;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
enum msgtype msgtype;
|
enum msgtype msgtype;
|
||||||
u_int i;
|
const char *cmd = args_get(args, 'E');
|
||||||
|
|
||||||
|
if (self->entry == &cmd_suspend_client_entry) {
|
||||||
|
tty_stop_tty(&c->tty);
|
||||||
|
c->flags |= CLIENT_SUSPENDED;
|
||||||
|
proc_send(c->peer, MSG_SUSPEND, -1, NULL, 0);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (args_has(args, 'P'))
|
if (args_has(args, 'P'))
|
||||||
msgtype = MSG_DETACHKILL;
|
msgtype = MSG_DETACHKILL;
|
||||||
@@ -51,30 +79,33 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
msgtype = MSG_DETACH;
|
msgtype = MSG_DETACH;
|
||||||
|
|
||||||
if (args_has(args, 's')) {
|
if (args_has(args, 's')) {
|
||||||
s = cmd_find_session(cmdq, args_get(args, 's'), 0);
|
s = item->state.sflag.s;
|
||||||
if (s == NULL)
|
TAILQ_FOREACH(cloop, &clients, entry) {
|
||||||
return (CMD_RETURN_ERROR);
|
if (cloop->session == s) {
|
||||||
|
if (cmd != NULL)
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
server_client_exec(cloop, cmd);
|
||||||
c = ARRAY_ITEM(&clients, i);
|
else
|
||||||
if (c != NULL && c->session == s)
|
server_client_detach(cloop, msgtype);
|
||||||
server_write_client(c, msgtype, NULL, 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
c = cmd_find_client(cmdq, args_get(args, 't'), 0);
|
|
||||||
if (c == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
|
||||||
c2 = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c2 == NULL || c == c2)
|
|
||||||
continue;
|
|
||||||
server_write_client(c2, msgtype, NULL, 0);
|
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
server_write_client(c, msgtype, NULL, 0);
|
return (CMD_RETURN_STOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'a')) {
|
||||||
|
TAILQ_FOREACH(cloop, &clients, entry) {
|
||||||
|
if (cloop->session != NULL && cloop != c) {
|
||||||
|
if (cmd != NULL)
|
||||||
|
server_client_exec(cloop, cmd);
|
||||||
|
else
|
||||||
|
server_client_detach(cloop, msgtype);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd != NULL)
|
||||||
|
server_client_exec(c, cmd);
|
||||||
|
else
|
||||||
|
server_client_detach(c, msgtype);
|
||||||
return (CMD_RETURN_STOP);
|
return (CMD_RETURN_STOP);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -27,84 +27,62 @@
|
|||||||
* Displays a message in the status line.
|
* Displays a message in the status line.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_display_message_exec(struct cmd *, struct cmd_q *);
|
#define DISPLAY_MESSAGE_TEMPLATE \
|
||||||
|
"[#{session_name}] #{window_index}:" \
|
||||||
|
"#{window_name}, current pane #{pane_index} " \
|
||||||
|
"- (%H:%M %d-%b-%y)"
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_display_message_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_display_message_entry = {
|
const struct cmd_entry cmd_display_message_entry = {
|
||||||
"display-message", "display",
|
.name = "display-message",
|
||||||
"c:pt:F:", 0, 1,
|
.alias = "display",
|
||||||
"[-p] [-c target-client] [-F format] " CMD_TARGET_PANE_USAGE
|
|
||||||
" [message]",
|
.args = { "c:pt:F:", 0, 1 },
|
||||||
0,
|
.usage = "[-p] [-c target-client] [-F format] "
|
||||||
NULL,
|
CMD_TARGET_PANE_USAGE " [message]",
|
||||||
NULL,
|
|
||||||
cmd_display_message_exec
|
.cflag = CMD_CLIENT_CANFAIL,
|
||||||
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_display_message_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_display_message_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c = item->state.c;
|
||||||
struct session *s;
|
struct session *s = item->state.tflag.s;
|
||||||
struct winlink *wl;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
const char *template;
|
const char *template;
|
||||||
char *msg;
|
char *msg;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
char out[BUFSIZ];
|
|
||||||
time_t t;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (args_has(args, 't')) {
|
|
||||||
wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
|
|
||||||
if (wl == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
} else {
|
|
||||||
wl = cmd_find_pane(cmdq, NULL, &s, &wp);
|
|
||||||
if (wl == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args_has(args, 'F') && args->argc != 0) {
|
if (args_has(args, 'F') && args->argc != 0) {
|
||||||
cmdq_error(cmdq, "only one of -F or argument must be given");
|
cmdq_error(item, "only one of -F or argument must be given");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 'c')) {
|
|
||||||
c = cmd_find_client(cmdq, args_get(args, 'c'), 0);
|
|
||||||
if (c == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
} else {
|
|
||||||
c = cmd_current_client(cmdq);
|
|
||||||
if (c == NULL && !args_has(self->args, 'p')) {
|
|
||||||
cmdq_error(cmdq, "no client available");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template = args_get(args, 'F');
|
template = args_get(args, 'F');
|
||||||
if (args->argc != 0)
|
if (args->argc != 0)
|
||||||
template = args->argv[0];
|
template = args->argv[0];
|
||||||
if (template == NULL)
|
if (template == NULL)
|
||||||
template = DISPLAY_MESSAGE_TEMPLATE;
|
template = DISPLAY_MESSAGE_TEMPLATE;
|
||||||
|
|
||||||
ft = format_create();
|
ft = format_create(item, FORMAT_NONE, 0);
|
||||||
if (c != NULL)
|
format_defaults(ft, c, s, wl, wp);
|
||||||
format_client(ft, c);
|
|
||||||
format_session(ft, s);
|
|
||||||
format_winlink(ft, s, wl);
|
|
||||||
format_window_pane(ft, wp);
|
|
||||||
|
|
||||||
t = time(NULL);
|
msg = format_expand_time(ft, template, time(NULL));
|
||||||
len = strftime(out, sizeof out, template, localtime(&t));
|
|
||||||
out[len] = '\0';
|
|
||||||
|
|
||||||
msg = format_expand(ft, out);
|
|
||||||
if (args_has(self->args, 'p'))
|
if (args_has(self->args, 'p'))
|
||||||
cmdq_print(cmdq, "%s", msg);
|
cmdq_print(item, "%s", msg);
|
||||||
else
|
else if (c != NULL)
|
||||||
status_message_set(c, "%s", msg);
|
status_message_set(c, "%s", msg);
|
||||||
free(msg);
|
free(msg);
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -18,34 +18,98 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Display panes on a client.
|
* Display panes on a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_display_panes_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_display_panes_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
|
static void cmd_display_panes_callback(struct client *,
|
||||||
|
struct window_pane *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_display_panes_entry = {
|
const struct cmd_entry cmd_display_panes_entry = {
|
||||||
"display-panes", "displayp",
|
.name = "display-panes",
|
||||||
"t:", 0, 0,
|
.alias = "displayp",
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
|
||||||
0,
|
.args = { "t:", 0, 1 },
|
||||||
NULL,
|
.usage = CMD_TARGET_CLIENT_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_display_panes_exec
|
.tflag = CMD_CLIENT,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_display_panes_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_display_panes_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c = item->state.c;
|
||||||
|
|
||||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
if (c->identify_callback != NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
server_set_identify(c);
|
c->identify_callback = cmd_display_panes_callback;
|
||||||
|
if (args->argc != 0)
|
||||||
|
c->identify_callback_data = xstrdup(args->argv[0]);
|
||||||
|
else
|
||||||
|
c->identify_callback_data = xstrdup("select-pane -t '%%'");
|
||||||
|
|
||||||
|
server_client_set_identify(c);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_display_panes_error(struct cmdq_item *item, void *data)
|
||||||
|
{
|
||||||
|
char *error = data;
|
||||||
|
|
||||||
|
cmdq_error(item, "%s", error);
|
||||||
|
free(error);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_display_panes_callback(struct client *c, struct window_pane *wp)
|
||||||
|
{
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
struct cmdq_item *new_item;
|
||||||
|
char *template, *cmd, *expanded, *cause;
|
||||||
|
|
||||||
|
template = c->identify_callback_data;
|
||||||
|
if (wp == NULL)
|
||||||
|
goto out;
|
||||||
|
xasprintf(&expanded, "%%%u", wp->id);
|
||||||
|
cmd = cmd_template_replace(template, expanded, 1);
|
||||||
|
|
||||||
|
cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
|
if (cause != NULL) {
|
||||||
|
new_item = cmdq_get_callback(cmd_display_panes_error,
|
||||||
|
cause);
|
||||||
|
} else
|
||||||
|
new_item = NULL;
|
||||||
|
} else {
|
||||||
|
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_item != NULL)
|
||||||
|
cmdq_append(c, new_item);
|
||||||
|
|
||||||
|
free(cmd);
|
||||||
|
free(expanded);
|
||||||
|
|
||||||
|
out:
|
||||||
|
free(c->identify_callback_data);
|
||||||
|
c->identify_callback_data = NULL;
|
||||||
|
c->identify_callback = NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -28,9 +28,14 @@
|
|||||||
* Find window containing text.
|
* Find window containing text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmd_q *);
|
#define FIND_WINDOW_TEMPLATE \
|
||||||
|
"#{window_index}: #{window_name} " \
|
||||||
|
"[#{window_width}x#{window_height}] " \
|
||||||
|
"(#{window_panes} panes) #{window_find_matches}"
|
||||||
|
|
||||||
void cmd_find_window_callback(struct window_choose_data *);
|
static enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
|
static void cmd_find_window_callback(struct window_choose_data *);
|
||||||
|
|
||||||
/* Flags for determining matching behavior. */
|
/* Flags for determining matching behavior. */
|
||||||
#define CMD_FIND_WINDOW_BY_TITLE 0x1
|
#define CMD_FIND_WINDOW_BY_TITLE 0x1
|
||||||
@@ -43,27 +48,31 @@ void cmd_find_window_callback(struct window_choose_data *);
|
|||||||
CMD_FIND_WINDOW_BY_NAME)
|
CMD_FIND_WINDOW_BY_NAME)
|
||||||
|
|
||||||
const struct cmd_entry cmd_find_window_entry = {
|
const struct cmd_entry cmd_find_window_entry = {
|
||||||
"find-window", "findw",
|
.name = "find-window",
|
||||||
"F:CNt:T", 1, 4,
|
.alias = "findw",
|
||||||
"[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string",
|
|
||||||
0,
|
.args = { "F:CNt:T", 1, 4 },
|
||||||
NULL,
|
.usage = "[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string",
|
||||||
NULL,
|
|
||||||
cmd_find_window_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_find_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_find_window_data {
|
struct cmd_find_window_data {
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
char *list_ctx;
|
char *list_ctx;
|
||||||
u_int pane_id;
|
u_int pane_id;
|
||||||
|
TAILQ_ENTRY(cmd_find_window_data) entry;
|
||||||
};
|
};
|
||||||
ARRAY_DECL(cmd_find_window_data_list, struct cmd_find_window_data);
|
TAILQ_HEAD(cmd_find_window_list, cmd_find_window_data);
|
||||||
|
|
||||||
u_int cmd_find_window_match_flags(struct args *);
|
static u_int cmd_find_window_match_flags(struct args *);
|
||||||
void cmd_find_window_match(struct cmd_find_window_data_list *, int,
|
static void cmd_find_window_match(struct cmd_find_window_list *, int,
|
||||||
struct winlink *, const char *, const char *);
|
struct winlink *, const char *, const char *);
|
||||||
|
|
||||||
u_int
|
static u_int
|
||||||
cmd_find_window_match_flags(struct args *args)
|
cmd_find_window_match_flags(struct args *args)
|
||||||
{
|
{
|
||||||
u_int match_flags = 0;
|
u_int match_flags = 0;
|
||||||
@@ -83,16 +92,17 @@ cmd_find_window_match_flags(struct args *args)
|
|||||||
return (match_flags);
|
return (match_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_find_window_match(struct cmd_find_window_data_list *find_list,
|
cmd_find_window_match(struct cmd_find_window_list *find_list,
|
||||||
int match_flags, struct winlink *wl, const char *str, const char *searchstr)
|
int match_flags, struct winlink *wl, const char *str,
|
||||||
|
const char *searchstr)
|
||||||
{
|
{
|
||||||
struct cmd_find_window_data find_data;
|
struct cmd_find_window_data *find_data;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
u_int i, line;
|
u_int i, line;
|
||||||
char *sres;
|
char *sres;
|
||||||
|
|
||||||
memset(&find_data, 0, sizeof find_data);
|
find_data = xcalloc(1, sizeof *find_data);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||||
@@ -100,53 +110,53 @@ cmd_find_window_match(struct cmd_find_window_data_list *find_list,
|
|||||||
|
|
||||||
if ((match_flags & CMD_FIND_WINDOW_BY_NAME) &&
|
if ((match_flags & CMD_FIND_WINDOW_BY_NAME) &&
|
||||||
fnmatch(searchstr, wl->window->name, 0) == 0) {
|
fnmatch(searchstr, wl->window->name, 0) == 0) {
|
||||||
find_data.list_ctx = xstrdup("");
|
find_data->list_ctx = xstrdup("");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((match_flags & CMD_FIND_WINDOW_BY_TITLE) &&
|
if ((match_flags & CMD_FIND_WINDOW_BY_TITLE) &&
|
||||||
fnmatch(searchstr, wp->base.title, 0) == 0) {
|
fnmatch(searchstr, wp->base.title, 0) == 0) {
|
||||||
xasprintf(&find_data.list_ctx,
|
xasprintf(&find_data->list_ctx,
|
||||||
"pane %u title: \"%s\"", i - 1, wp->base.title);
|
"pane %u title: \"%s\"", i - 1, wp->base.title);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match_flags & CMD_FIND_WINDOW_BY_CONTENT &&
|
if (match_flags & CMD_FIND_WINDOW_BY_CONTENT &&
|
||||||
(sres = window_pane_search(wp, str, &line)) != NULL) {
|
(sres = window_pane_search(wp, str, &line)) != NULL) {
|
||||||
xasprintf(&find_data.list_ctx,
|
xasprintf(&find_data->list_ctx,
|
||||||
"pane %u line %u: \"%s\"", i - 1, line + 1, sres);
|
"pane %u line %u: \"%s\"", i - 1, line + 1, sres);
|
||||||
free(sres);
|
free(sres);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (find_data.list_ctx != NULL) {
|
|
||||||
find_data.wl = wl;
|
if (find_data->list_ctx != NULL) {
|
||||||
find_data.pane_id = i - 1;
|
find_data->wl = wl;
|
||||||
ARRAY_ADD(find_list, find_data);
|
find_data->pane_id = i - 1;
|
||||||
}
|
TAILQ_INSERT_TAIL(find_list, find_data, entry);
|
||||||
|
} else
|
||||||
|
free(find_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_find_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c = item->state.c;
|
||||||
struct window_choose_data *cdata;
|
struct window_choose_data *cdata;
|
||||||
struct session *s;
|
struct session *s = item->state.tflag.s;
|
||||||
struct winlink *wl, *wm;
|
struct winlink *wl = item->state.tflag.wl, *wm;
|
||||||
struct cmd_find_window_data_list find_list;
|
struct cmd_find_window_list find_list;
|
||||||
|
struct cmd_find_window_data *find_data;
|
||||||
|
struct cmd_find_window_data *find_data1;
|
||||||
char *str, *searchstr;
|
char *str, *searchstr;
|
||||||
const char *template;
|
const char *template;
|
||||||
u_int i, match_flags;
|
u_int i, match_flags;
|
||||||
|
|
||||||
if ((c = cmd_current_client(cmdq)) == NULL) {
|
if (c == NULL) {
|
||||||
cmdq_error(cmdq, "no client available");
|
cmdq_error(item, "no client available");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
s = c->session;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = FIND_WINDOW_TEMPLATE;
|
template = FIND_WINDOW_TEMPLATE;
|
||||||
@@ -154,21 +164,20 @@ cmd_find_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
match_flags = cmd_find_window_match_flags(args);
|
match_flags = cmd_find_window_match_flags(args);
|
||||||
str = args->argv[0];
|
str = args->argv[0];
|
||||||
|
|
||||||
ARRAY_INIT(&find_list);
|
TAILQ_INIT(&find_list);
|
||||||
|
|
||||||
xasprintf(&searchstr, "*%s*", str);
|
xasprintf(&searchstr, "*%s*", str);
|
||||||
RB_FOREACH(wm, winlinks, &s->windows)
|
RB_FOREACH(wm, winlinks, &s->windows)
|
||||||
cmd_find_window_match (&find_list, match_flags, wm, str, searchstr);
|
cmd_find_window_match(&find_list, match_flags, wm, str, searchstr);
|
||||||
free(searchstr);
|
free(searchstr);
|
||||||
|
|
||||||
if (ARRAY_LENGTH(&find_list) == 0) {
|
if (TAILQ_EMPTY(&find_list)) {
|
||||||
cmdq_error(cmdq, "no windows matching: %s", str);
|
cmdq_error(item, "no windows matching: %s", str);
|
||||||
ARRAY_FREE(&find_list);
|
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ARRAY_LENGTH(&find_list) == 1) {
|
if (TAILQ_NEXT(TAILQ_FIRST(&find_list), entry) == NULL) {
|
||||||
if (session_select(s, ARRAY_FIRST(&find_list).wl->idx) == 0)
|
if (session_select(s, TAILQ_FIRST(&find_list)->wl->idx) == 0)
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
goto out;
|
goto out;
|
||||||
@@ -177,34 +186,37 @@ cmd_find_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&find_list); i++) {
|
i = 0;
|
||||||
wm = ARRAY_ITEM(&find_list, i).wl;
|
TAILQ_FOREACH(find_data, &find_list, entry) {
|
||||||
|
|
||||||
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
||||||
cdata->idx = wm->idx;
|
cdata->idx = find_data->wl->idx;
|
||||||
cdata->wl = wm;
|
cdata->wl = find_data->wl;
|
||||||
|
|
||||||
cdata->ft_template = xstrdup(template);
|
cdata->ft_template = xstrdup(template);
|
||||||
cdata->pane_id = ARRAY_ITEM(&find_list, i).pane_id;
|
cdata->pane_id = find_data->pane_id;
|
||||||
|
|
||||||
format_add(cdata->ft, "line", "%u", i);
|
format_add(cdata->ft, "line", "%u", i);
|
||||||
format_add(cdata->ft, "window_find_matches", "%s",
|
format_add(cdata->ft, "window_find_matches", "%s",
|
||||||
ARRAY_ITEM(&find_list, i).list_ctx);
|
find_data->list_ctx);
|
||||||
format_session(cdata->ft, s);
|
format_defaults(cdata->ft, NULL, s, find_data->wl, NULL);
|
||||||
format_winlink(cdata->ft, s, wm);
|
|
||||||
format_window_pane(cdata->ft, wm->window->active);
|
|
||||||
|
|
||||||
window_choose_add(wl->window->active, cdata);
|
window_choose_add(wl->window->active, cdata);
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
window_choose_ready(wl->window->active, 0, cmd_find_window_callback);
|
window_choose_ready(wl->window->active, 0, cmd_find_window_callback);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
ARRAY_FREE(&find_list);
|
TAILQ_FOREACH_SAFE(find_data, &find_list, entry, find_data1) {
|
||||||
|
free(find_data->list_ctx);
|
||||||
|
TAILQ_REMOVE(&find_list, find_data, entry);
|
||||||
|
free(find_data);
|
||||||
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_find_window_callback(struct window_choose_data *cdata)
|
cmd_find_window_callback(struct window_choose_data *cdata)
|
||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
|||||||
1295
cmd-find.c
Normal file
1295
cmd-find.c
Normal file
File diff suppressed because it is too large
Load Diff
210
cmd-if-shell.c
210
cmd-if-shell.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -29,148 +29,174 @@
|
|||||||
* Executes a tmux command if a shell command returns true or false.
|
* Executes a tmux command if a shell command returns true or false.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_if_shell_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_if_shell_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
void cmd_if_shell_callback(struct job *);
|
static enum cmd_retval cmd_if_shell_error(struct cmdq_item *, void *);
|
||||||
void cmd_if_shell_done(struct cmd_q *);
|
static void cmd_if_shell_callback(struct job *);
|
||||||
void cmd_if_shell_free(void *);
|
static void cmd_if_shell_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_if_shell_entry = {
|
const struct cmd_entry cmd_if_shell_entry = {
|
||||||
"if-shell", "if",
|
.name = "if-shell",
|
||||||
"bt:", 2, 3,
|
.alias = "if",
|
||||||
"[-b] " CMD_TARGET_PANE_USAGE " shell-command command [command]",
|
|
||||||
0,
|
.args = { "bFt:", 2, 3 },
|
||||||
NULL,
|
.usage = "[-bF] " CMD_TARGET_PANE_USAGE " shell-command command "
|
||||||
NULL,
|
"[command]",
|
||||||
cmd_if_shell_exec
|
|
||||||
|
.tflag = CMD_PANE_CANFAIL,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_if_shell_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_if_shell_data {
|
struct cmd_if_shell_data {
|
||||||
char *cmd_if;
|
char *file;
|
||||||
char *cmd_else;
|
u_int line;
|
||||||
struct cmd_q *cmdq;
|
|
||||||
int bflag;
|
char *cmd_if;
|
||||||
int started;
|
char *cmd_else;
|
||||||
|
|
||||||
|
struct client *client;
|
||||||
|
struct cmdq_item *item;
|
||||||
|
struct mouse_event mouse;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct cmd_if_shell_data *cdata;
|
struct cmd_if_shell_data *cdata;
|
||||||
char *shellcmd;
|
char *shellcmd, *cmd, *cause;
|
||||||
struct client *c;
|
struct cmd_list *cmdlist;
|
||||||
struct session *s = NULL;
|
struct cmdq_item *new_item;
|
||||||
struct winlink *wl = NULL;
|
struct client *c = item->state.c;
|
||||||
struct window_pane *wp = NULL;
|
struct session *s = item->state.tflag.s;
|
||||||
struct format_tree *ft;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
|
const char *cwd;
|
||||||
|
|
||||||
if (args_has(args, 't'))
|
if (item->client != NULL && item->client->session == NULL)
|
||||||
wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
|
cwd = item->client->cwd;
|
||||||
else {
|
else if (s != NULL)
|
||||||
c = cmd_find_client(cmdq, NULL, 1);
|
cwd = s->cwd;
|
||||||
if (c != NULL && c->session != NULL) {
|
else
|
||||||
s = c->session;
|
cwd = NULL;
|
||||||
wl = s->curw;
|
|
||||||
wp = wl->window->active;
|
shellcmd = format_single(item, args->argv[0], c, s, wl, wp);
|
||||||
|
if (args_has(args, 'F')) {
|
||||||
|
cmd = NULL;
|
||||||
|
if (*shellcmd != '0' && *shellcmd != '\0')
|
||||||
|
cmd = args->argv[1];
|
||||||
|
else if (args->argc == 3)
|
||||||
|
cmd = args->argv[2];
|
||||||
|
free(shellcmd);
|
||||||
|
if (cmd == NULL)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
new_item = cmdq_get_command(cmdlist, NULL, &item->mouse, 0);
|
||||||
|
cmdq_insert_after(item, new_item);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ft = format_create();
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
if (s != NULL)
|
if (self->file != NULL) {
|
||||||
format_session(ft, s);
|
cdata->file = xstrdup(self->file);
|
||||||
if (s != NULL && wl != NULL)
|
cdata->line = self->line;
|
||||||
format_winlink(ft, s, wl);
|
}
|
||||||
if (wp != NULL)
|
|
||||||
format_window_pane(ft, wp);
|
|
||||||
shellcmd = format_expand(ft, args->argv[0]);
|
|
||||||
format_free(ft);
|
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
|
||||||
cdata->cmd_if = xstrdup(args->argv[1]);
|
cdata->cmd_if = xstrdup(args->argv[1]);
|
||||||
if (args->argc == 3)
|
if (args->argc == 3)
|
||||||
cdata->cmd_else = xstrdup(args->argv[2]);
|
cdata->cmd_else = xstrdup(args->argv[2]);
|
||||||
else
|
else
|
||||||
cdata->cmd_else = NULL;
|
cdata->cmd_else = NULL;
|
||||||
cdata->bflag = args_has(args, 'b');
|
|
||||||
|
|
||||||
cdata->started = 0;
|
cdata->client = item->client;
|
||||||
cdata->cmdq = cmdq;
|
cdata->client->references++;
|
||||||
cmdq->references++;
|
|
||||||
|
|
||||||
job_run(shellcmd, s, cmd_if_shell_callback, cmd_if_shell_free, cdata);
|
if (!args_has(args, 'b'))
|
||||||
|
cdata->item = item;
|
||||||
|
else
|
||||||
|
cdata->item = NULL;
|
||||||
|
memcpy(&cdata->mouse, &item->mouse, sizeof cdata->mouse);
|
||||||
|
|
||||||
|
job_run(shellcmd, s, cwd, cmd_if_shell_callback, cmd_if_shell_free,
|
||||||
|
cdata);
|
||||||
free(shellcmd);
|
free(shellcmd);
|
||||||
|
|
||||||
if (cdata->bflag)
|
if (args_has(args, 'b'))
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
return (CMD_RETURN_WAIT);
|
return (CMD_RETURN_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
|
cmd_if_shell_error(struct cmdq_item *item, void *data)
|
||||||
|
{
|
||||||
|
char *error = data;
|
||||||
|
|
||||||
|
cmdq_error(item, "%s", error);
|
||||||
|
free(error);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
cmd_if_shell_callback(struct job *job)
|
cmd_if_shell_callback(struct job *job)
|
||||||
{
|
{
|
||||||
struct cmd_if_shell_data *cdata = job->data;
|
struct cmd_if_shell_data *cdata = job->data;
|
||||||
struct cmd_q *cmdq = cdata->cmdq, *cmdq1;
|
struct client *c = cdata->client;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
char *cause, *cmd;
|
struct cmdq_item *new_item;
|
||||||
|
char *cause, *cmd, *file = cdata->file;
|
||||||
if (cmdq->dead)
|
u_int line = cdata->line;
|
||||||
return;
|
|
||||||
|
|
||||||
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0)
|
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0)
|
||||||
cmd = cdata->cmd_else;
|
cmd = cdata->cmd_else;
|
||||||
else
|
else
|
||||||
cmd = cdata->cmd_if;
|
cmd = cdata->cmd_if;
|
||||||
if (cmd == NULL)
|
if (cmd == NULL)
|
||||||
return;
|
goto out;
|
||||||
|
|
||||||
if (cmd_string_parse(cmd, &cmdlist, NULL, 0, &cause) != 0) {
|
cmdlist = cmd_string_parse(cmd, file, line, &cause);
|
||||||
if (cause != NULL) {
|
if (cmdlist == NULL) {
|
||||||
cmdq_error(cmdq, "%s", cause);
|
if (cause != NULL)
|
||||||
free(cause);
|
new_item = cmdq_get_callback(cmd_if_shell_error, cause);
|
||||||
}
|
else
|
||||||
return;
|
new_item = NULL;
|
||||||
|
} else {
|
||||||
|
new_item = cmdq_get_command(cmdlist, NULL, &cdata->mouse, 0);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
cdata->started = 1;
|
if (new_item != NULL) {
|
||||||
|
if (cdata->item == NULL)
|
||||||
|
cmdq_append(c, new_item);
|
||||||
|
else
|
||||||
|
cmdq_insert_after(cdata->item, new_item);
|
||||||
|
}
|
||||||
|
|
||||||
cmdq1 = cmdq_new(cmdq->client);
|
out:
|
||||||
cmdq1->emptyfn = cmd_if_shell_done;
|
if (cdata->item != NULL)
|
||||||
cmdq1->data = cdata;
|
cdata->item->flags &= ~CMDQ_WAITING;
|
||||||
|
|
||||||
cmdq_run(cmdq1, cmdlist);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_if_shell_done(struct cmd_q *cmdq1)
|
|
||||||
{
|
|
||||||
struct cmd_if_shell_data *cdata = cmdq1->data;
|
|
||||||
struct cmd_q *cmdq = cdata->cmdq;
|
|
||||||
|
|
||||||
if (!cmdq_free(cmdq) && !cdata->bflag)
|
|
||||||
cmdq_continue(cmdq);
|
|
||||||
|
|
||||||
cmdq_free(cmdq1);
|
|
||||||
|
|
||||||
free(cdata->cmd_else);
|
|
||||||
free(cdata->cmd_if);
|
|
||||||
free(cdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_if_shell_free(void *data)
|
cmd_if_shell_free(void *data)
|
||||||
{
|
{
|
||||||
struct cmd_if_shell_data *cdata = data;
|
struct cmd_if_shell_data *cdata = data;
|
||||||
struct cmd_q *cmdq = cdata->cmdq;
|
|
||||||
|
|
||||||
if (cdata->started)
|
server_client_unref(cdata->client);
|
||||||
return;
|
|
||||||
|
|
||||||
if (!cmdq_free(cmdq) && !cdata->bflag)
|
|
||||||
cmdq_continue(cmdq);
|
|
||||||
|
|
||||||
free(cdata->cmd_else);
|
free(cdata->cmd_else);
|
||||||
free(cdata->cmd_if);
|
free(cdata->cmd_if);
|
||||||
|
|
||||||
|
free(cdata->file);
|
||||||
free(cdata);
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
116
cmd-join-pane.c
116
cmd-join-pane.c
@@ -1,8 +1,8 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 George Nachman <tmux@georgester.com>
|
* Copyright (c) 2011 George Nachman <tmux@georgester.com>
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -28,53 +28,38 @@
|
|||||||
* Join or move a pane into another (like split/swap/kill).
|
* Join or move a pane into another (like split/swap/kill).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_join_pane_key_binding(struct cmd *, int);
|
static enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
enum cmd_retval join_pane(struct cmd *, struct cmd_q *, int);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_join_pane_entry = {
|
const struct cmd_entry cmd_join_pane_entry = {
|
||||||
"join-pane", "joinp",
|
.name = "join-pane",
|
||||||
"bdhvp:l:s:t:", 0, 0,
|
.alias = "joinp",
|
||||||
"[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
|
||||||
0,
|
.args = { "bdhvp:l:s:t:", 0, 0 },
|
||||||
cmd_join_pane_key_binding,
|
.usage = "[-bdhv] [-p percentage|-l size] " CMD_SRCDST_PANE_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_join_pane_exec
|
.sflag = CMD_PANE_MARKED,
|
||||||
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_join_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_move_pane_entry = {
|
const struct cmd_entry cmd_move_pane_entry = {
|
||||||
"move-pane", "movep",
|
.name = "move-pane",
|
||||||
"bdhvp:l:s:t:", 0, 0,
|
.alias = "movep",
|
||||||
"[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
|
||||||
0,
|
.args = { "bdhvp:l:s:t:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-bdhv] [-p percentage|-l size] " CMD_SRCDST_PANE_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_join_pane_exec
|
.sflag = CMD_PANE,
|
||||||
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_join_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_join_pane_key_binding(struct cmd *self, int key)
|
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
|
||||||
switch (key) {
|
|
||||||
case '%':
|
|
||||||
self->args = args_create(0);
|
|
||||||
args_set(self->args, 'h', NULL);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
self->args = args_create(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_join_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
return (join_pane(self, cmdq, self->entry == &cmd_join_pane_entry));
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
|
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *dst_s;
|
struct session *dst_s;
|
||||||
@@ -85,26 +70,31 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
|
|||||||
int size, percentage, dst_idx;
|
int size, percentage, dst_idx;
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
struct layout_cell *lc;
|
struct layout_cell *lc;
|
||||||
|
int not_same_window;
|
||||||
|
|
||||||
dst_wl = cmd_find_pane(cmdq, args_get(args, 't'), &dst_s, &dst_wp);
|
if (self->entry == &cmd_join_pane_entry)
|
||||||
if (dst_wl == NULL)
|
not_same_window = 1;
|
||||||
return (CMD_RETURN_ERROR);
|
else
|
||||||
|
not_same_window = 0;
|
||||||
|
|
||||||
|
dst_s = item->state.tflag.s;
|
||||||
|
dst_wl = item->state.tflag.wl;
|
||||||
|
dst_wp = item->state.tflag.wp;
|
||||||
dst_w = dst_wl->window;
|
dst_w = dst_wl->window;
|
||||||
dst_idx = dst_wl->idx;
|
dst_idx = dst_wl->idx;
|
||||||
server_unzoom_window(dst_w);
|
server_unzoom_window(dst_w);
|
||||||
|
|
||||||
src_wl = cmd_find_pane(cmdq, args_get(args, 's'), NULL, &src_wp);
|
src_wl = item->state.sflag.wl;
|
||||||
if (src_wl == NULL)
|
src_wp = item->state.sflag.wp;
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
src_w = src_wl->window;
|
src_w = src_wl->window;
|
||||||
server_unzoom_window(src_w);
|
server_unzoom_window(src_w);
|
||||||
|
|
||||||
if (not_same_window && src_w == dst_w) {
|
if (not_same_window && src_w == dst_w) {
|
||||||
cmdq_error(cmdq, "can't join a pane to its own window");
|
cmdq_error(item, "can't join a pane to its own window");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (!not_same_window && src_wp == dst_wp) {
|
if (!not_same_window && src_wp == dst_wp) {
|
||||||
cmdq_error(cmdq, "source and target panes must be different");
|
cmdq_error(item, "source and target panes must be different");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,14 +106,14 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
|
|||||||
if (args_has(args, 'l')) {
|
if (args_has(args, 'l')) {
|
||||||
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
cmdq_error(cmdq, "size %s", cause);
|
cmdq_error(item, "size %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'p')) {
|
} else if (args_has(args, 'p')) {
|
||||||
percentage = args_strtonum(args, 'p', 0, 100, &cause);
|
percentage = args_strtonum(args, 'p', 0, 100, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
cmdq_error(cmdq, "percentage %s", cause);
|
cmdq_error(item, "percentage %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
@@ -132,26 +122,17 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
|
|||||||
else
|
else
|
||||||
size = (dst_wp->sx * percentage) / 100;
|
size = (dst_wp->sx * percentage) / 100;
|
||||||
}
|
}
|
||||||
lc = layout_split_pane(dst_wp, type, size, args_has(args, 'b'));
|
lc = layout_split_pane(dst_wp, type, size, args_has(args, 'b'), 0);
|
||||||
if (lc == NULL) {
|
if (lc == NULL) {
|
||||||
cmdq_error(cmdq, "create pane failed: pane too small");
|
cmdq_error(item, "create pane failed: pane too small");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout_close_pane(src_wp);
|
layout_close_pane(src_wp);
|
||||||
|
|
||||||
if (src_w->active == src_wp) {
|
window_lost_pane(src_w, 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);
|
TAILQ_REMOVE(&src_w->panes, src_wp, entry);
|
||||||
|
|
||||||
if (window_count_panes(src_w) == 0)
|
|
||||||
server_kill_window(src_w);
|
|
||||||
else
|
|
||||||
notify_window_layout_changed(src_w);
|
|
||||||
|
|
||||||
src_wp->window = dst_w;
|
src_wp->window = dst_w;
|
||||||
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
||||||
layout_assign_pane(lc, src_wp);
|
layout_assign_pane(lc, src_wp);
|
||||||
@@ -168,6 +149,11 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
|
|||||||
} else
|
} else
|
||||||
server_status_session(dst_s);
|
server_status_session(dst_s);
|
||||||
|
|
||||||
notify_window_layout_changed(dst_w);
|
if (window_count_panes(src_w) == 0)
|
||||||
|
server_kill_window(src_w);
|
||||||
|
else
|
||||||
|
notify_window("window-layout-changed", src_w);
|
||||||
|
notify_window("window-layout-changed", dst_w);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -26,36 +26,29 @@
|
|||||||
* Kill pane.
|
* Kill pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_kill_pane_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_kill_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_pane_entry = {
|
const struct cmd_entry cmd_kill_pane_entry = {
|
||||||
"kill-pane", "killp",
|
.name = "kill-pane",
|
||||||
"at:", 0, 0,
|
.alias = "killp",
|
||||||
"[-a] " CMD_TARGET_PANE_USAGE,
|
|
||||||
0,
|
.args = { "at:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-a] " CMD_TARGET_PANE_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_kill_pane_exec
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_kill_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_kill_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_kill_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct winlink *wl;
|
struct window_pane *loopwp, *tmpwp, *wp = item->state.tflag.wp;
|
||||||
struct window_pane *loopwp, *tmpwp, *wp;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
server_unzoom_window(wl->window);
|
server_unzoom_window(wl->window);
|
||||||
|
|
||||||
if (window_count_panes(wl->window) == 1) {
|
|
||||||
/* Only one pane, kill the window. */
|
|
||||||
server_kill_window(wl->window);
|
|
||||||
recalculate_sizes();
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args_has(self->args, 'a')) {
|
if (args_has(self->args, 'a')) {
|
||||||
TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) {
|
TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) {
|
||||||
if (loopwp == wp)
|
if (loopwp == wp)
|
||||||
@@ -63,11 +56,17 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
layout_close_pane(loopwp);
|
layout_close_pane(loopwp);
|
||||||
window_remove_pane(wl->window, loopwp);
|
window_remove_pane(wl->window, loopwp);
|
||||||
}
|
}
|
||||||
|
server_redraw_window(wl->window);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window_count_panes(wl->window) == 1) {
|
||||||
|
server_kill_window(wl->window);
|
||||||
|
recalculate_sizes();
|
||||||
} else {
|
} else {
|
||||||
layout_close_pane(wp);
|
layout_close_pane(wp);
|
||||||
window_remove_pane(wl->window, wp);
|
window_remove_pane(wl->window, wp);
|
||||||
|
server_redraw_window(wl->window);
|
||||||
}
|
}
|
||||||
server_redraw_window(wl->window);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,22 +27,35 @@
|
|||||||
* Kill the server and do nothing else.
|
* Kill the server and do nothing else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_kill_server_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_kill_server_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_server_entry = {
|
const struct cmd_entry cmd_kill_server_entry = {
|
||||||
"kill-server", NULL,
|
.name = "kill-server",
|
||||||
"", 0, 0,
|
.alias = NULL,
|
||||||
"",
|
|
||||||
0,
|
.args = { "", 0, 0 },
|
||||||
NULL,
|
.usage = "",
|
||||||
NULL,
|
|
||||||
cmd_kill_server_exec
|
.flags = 0,
|
||||||
|
.exec = cmd_kill_server_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
const struct cmd_entry cmd_start_server_entry = {
|
||||||
cmd_kill_server_exec(unused struct cmd *self, unused struct cmd_q *cmdq)
|
.name = "start-server",
|
||||||
|
.alias = "start",
|
||||||
|
|
||||||
|
.args = { "", 0, 0 },
|
||||||
|
.usage = "",
|
||||||
|
|
||||||
|
.flags = CMD_STARTSERVER,
|
||||||
|
.exec = cmd_kill_server_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_kill_server_exec(struct cmd *self, __unused struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
kill(getpid(), SIGTERM);
|
if (self->entry == &cmd_kill_server_entry)
|
||||||
|
kill(getpid(), SIGTERM);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,32 +27,41 @@
|
|||||||
* Note this deliberately has no alias to make it hard to hit by accident.
|
* Note this deliberately has no alias to make it hard to hit by accident.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_kill_session_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_kill_session_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_session_entry = {
|
const struct cmd_entry cmd_kill_session_entry = {
|
||||||
"kill-session", NULL,
|
.name = "kill-session",
|
||||||
"at:", 0, 0,
|
.alias = NULL,
|
||||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
|
||||||
0,
|
.args = { "aCt:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-aC] " CMD_TARGET_SESSION_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_kill_session_exec
|
.tflag = CMD_SESSION,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_kill_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_kill_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s, *s2, *s3;
|
struct session *s, *sloop, *stmp;
|
||||||
|
struct winlink *wl;
|
||||||
|
|
||||||
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
s = item->state.tflag.s;
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'C')) {
|
||||||
RB_FOREACH_SAFE(s2, sessions, &sessions, s3) {
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
if (s != s2) {
|
wl->window->flags &= ~WINDOW_ALERTFLAGS;
|
||||||
server_destroy_session(s2);
|
wl->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
session_destroy(s2);
|
}
|
||||||
|
server_redraw_session(s);
|
||||||
|
} else if (args_has(args, 'a')) {
|
||||||
|
RB_FOREACH_SAFE(sloop, sessions, &sessions, stmp) {
|
||||||
|
if (sloop != s) {
|
||||||
|
server_destroy_session(sloop);
|
||||||
|
session_destroy(sloop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -24,35 +24,57 @@
|
|||||||
* Destroy window.
|
* Destroy window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_kill_window_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_kill_window_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_window_entry = {
|
const struct cmd_entry cmd_kill_window_entry = {
|
||||||
"kill-window", "killw",
|
.name = "kill-window",
|
||||||
"at:", 0, 0,
|
.alias = "killw",
|
||||||
"[-a] " CMD_TARGET_WINDOW_USAGE,
|
|
||||||
0,
|
.args = { "at:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-a] " CMD_TARGET_WINDOW_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_kill_window_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_kill_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
const struct cmd_entry cmd_unlink_window_entry = {
|
||||||
cmd_kill_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
.name = "unlink-window",
|
||||||
|
.alias = "unlinkw",
|
||||||
|
|
||||||
|
.args = { "kt:", 0, 0 },
|
||||||
|
.usage = "[-k] " CMD_TARGET_WINDOW_USAGE,
|
||||||
|
|
||||||
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_kill_window_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_kill_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl, *wl2, *wl3;
|
struct winlink *wl = item->state.tflag.wl, *wl2, *wl3;
|
||||||
struct session *s;
|
struct window *w = wl->window;
|
||||||
|
struct session *s = item->state.tflag.s;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
|
if (self->entry == &cmd_unlink_window_entry) {
|
||||||
return (CMD_RETURN_ERROR);
|
if (!args_has(self->args, 'k') && !session_is_linked(s, w)) {
|
||||||
|
cmdq_error(item, "window only linked to one session");
|
||||||
if (args_has(args, 'a')) {
|
return (CMD_RETURN_ERROR);
|
||||||
RB_FOREACH_SAFE(wl2, winlinks, &s->windows, wl3) {
|
|
||||||
if (wl != wl2)
|
|
||||||
server_kill_window(wl2->window);
|
|
||||||
}
|
}
|
||||||
} else
|
server_unlink_window(s, wl);
|
||||||
server_kill_window(wl->window);
|
} else {
|
||||||
|
if (args_has(args, 'a')) {
|
||||||
|
RB_FOREACH_SAFE(wl2, winlinks, &s->windows, wl3) {
|
||||||
|
if (wl != wl2)
|
||||||
|
server_kill_window(wl2->window);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
server_kill_window(wl->window);
|
||||||
|
}
|
||||||
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Link a window into another session.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum cmd_retval cmd_link_window_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_link_window_entry = {
|
|
||||||
"link-window", "linkw",
|
|
||||||
"dks:t:", 0, 0,
|
|
||||||
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_link_window_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_link_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct session *src, *dst;
|
|
||||||
struct winlink *wl;
|
|
||||||
char *cause;
|
|
||||||
int idx, kflag, dflag;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 's'), &src)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
if ((idx = cmd_find_index(cmdq, args_get(args, 't'), &dst)) == -2)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
kflag = args_has(self->args, 'k');
|
|
||||||
dflag = args_has(self->args, 'd');
|
|
||||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
|
||||||
cmdq_error(cmdq, "can't link window: %s", cause);
|
|
||||||
free(cause);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,39 +27,41 @@
|
|||||||
* List paste buffers.
|
* List paste buffers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_list_buffers_exec(struct cmd *, struct cmd_q *);
|
#define LIST_BUFFERS_TEMPLATE \
|
||||||
|
"#{buffer_name}: #{buffer_size} bytes: \"#{buffer_sample}\""
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_list_buffers_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_buffers_entry = {
|
const struct cmd_entry cmd_list_buffers_entry = {
|
||||||
"list-buffers", "lsb",
|
.name = "list-buffers",
|
||||||
"F:", 0, 0,
|
.alias = "lsb",
|
||||||
"[-F format]",
|
|
||||||
0,
|
.args = { "F:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-F format]",
|
||||||
NULL,
|
|
||||||
cmd_list_buffers_exec
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_list_buffers_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_buffers_exec(unused struct cmd *self, struct cmd_q *cmdq)
|
cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
u_int idx;
|
|
||||||
char *line;
|
char *line;
|
||||||
const char *template;
|
const char *template;
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = LIST_BUFFERS_TEMPLATE;
|
template = LIST_BUFFERS_TEMPLATE;
|
||||||
|
|
||||||
idx = 0;
|
pb = NULL;
|
||||||
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
|
while ((pb = paste_walk(pb)) != NULL) {
|
||||||
ft = format_create();
|
ft = format_create(item, FORMAT_NONE, 0);
|
||||||
format_add(ft, "line", "%u", idx - 1);
|
format_defaults_paste_buffer(ft, pb);
|
||||||
format_paste_buffer(ft, pb);
|
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
line = format_expand(ft, template);
|
||||||
cmdq_print(cmdq, "%s", line);
|
cmdq_print(item, "%s", line);
|
||||||
free(line);
|
free(line);
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -28,57 +28,61 @@
|
|||||||
* List all clients.
|
* List all clients.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmd_q *);
|
#define LIST_CLIENTS_TEMPLATE \
|
||||||
|
"#{client_name}: #{session_name} " \
|
||||||
|
"[#{client_width}x#{client_height} #{client_termname}]" \
|
||||||
|
"#{?client_utf8, (utf8),} #{?client_readonly, (ro),}"
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_clients_entry = {
|
const struct cmd_entry cmd_list_clients_entry = {
|
||||||
"list-clients", "lsc",
|
.name = "list-clients",
|
||||||
"F:t:", 0, 0,
|
.alias = "lsc",
|
||||||
"[-F format] " CMD_TARGET_SESSION_USAGE,
|
|
||||||
CMD_READONLY,
|
.args = { "F:t:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-F format] " CMD_TARGET_SESSION_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_list_clients_exec
|
.tflag = CMD_SESSION,
|
||||||
|
|
||||||
|
.flags = CMD_READONLY|CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_list_clients_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
const char *template;
|
const char *template;
|
||||||
u_int i;
|
u_int idx;
|
||||||
char *line;
|
char *line;
|
||||||
|
|
||||||
if (args_has(args, 't')) {
|
if (args_has(args, 't'))
|
||||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
s = item->state.tflag.s;
|
||||||
if (s == NULL)
|
else
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
} else
|
|
||||||
s = NULL;
|
s = NULL;
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = LIST_CLIENTS_TEMPLATE;
|
template = LIST_CLIENTS_TEMPLATE;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
idx = 0;
|
||||||
c = ARRAY_ITEM(&clients, i);
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
if (c == NULL || c->session == NULL)
|
if (c->session == NULL || (s != NULL && s != c->session))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (s != NULL && s != c->session)
|
ft = format_create(item, FORMAT_NONE, 0);
|
||||||
continue;
|
format_add(ft, "line", "%u", idx);
|
||||||
|
format_defaults(ft, c, NULL, NULL, NULL);
|
||||||
ft = format_create();
|
|
||||||
format_add(ft, "line", "%u", i);
|
|
||||||
format_session(ft, c->session);
|
|
||||||
format_client(ft, c);
|
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
line = format_expand(ft, template);
|
||||||
cmdq_print(cmdq, "%s", line);
|
cmdq_print(item, "%s", line);
|
||||||
free(line);
|
free(line);
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* List all commands with usages.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum cmd_retval cmd_list_commands_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_commands_entry = {
|
|
||||||
"list-commands", "lscm",
|
|
||||||
"", 0, 0,
|
|
||||||
"",
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_list_commands_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_list_commands_exec(unused struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
const struct cmd_entry **entryp;
|
|
||||||
|
|
||||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
|
||||||
if ((*entryp)->alias != NULL) {
|
|
||||||
cmdq_print(cmdq, "%s (%s) %s", (*entryp)->name,
|
|
||||||
(*entryp)->alias, (*entryp)->usage);
|
|
||||||
} else {
|
|
||||||
cmdq_print(cmdq, "%s %s", (*entryp)->name,
|
|
||||||
(*entryp)->usage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
224
cmd-list-keys.c
224
cmd-list-keys.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -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,126 +27,147 @@
|
|||||||
* List key bindings.
|
* List key bindings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmdq_item *);
|
||||||
enum cmd_retval cmd_list_keys_table(struct cmd *, struct cmd_q *);
|
|
||||||
|
static enum cmd_retval cmd_list_keys_commands(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_keys_entry = {
|
const struct cmd_entry cmd_list_keys_entry = {
|
||||||
"list-keys", "lsk",
|
.name = "list-keys",
|
||||||
"t:", 0, 0,
|
.alias = "lsk",
|
||||||
"[-t key-table]",
|
|
||||||
0,
|
.args = { "T:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-T key-table]",
|
||||||
NULL,
|
|
||||||
cmd_list_keys_exec
|
.flags = CMD_STARTSERVER|CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_list_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
const struct cmd_entry cmd_list_commands_entry = {
|
||||||
cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
.name = "list-commands",
|
||||||
|
.alias = "lscm",
|
||||||
|
|
||||||
|
.args = { "F:", 0, 0 },
|
||||||
|
.usage = "[-F format]",
|
||||||
|
|
||||||
|
.flags = CMD_STARTSERVER|CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_list_keys_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
|
struct key_table *table;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
const char *key;
|
const char *key, *tablename, *r;
|
||||||
char tmp[BUFSIZ], flags[8];
|
char *cp, tmp[BUFSIZ];
|
||||||
size_t used;
|
int repeat, width, tablewidth, keywidth;
|
||||||
int width, keywidth;
|
|
||||||
|
|
||||||
if (args_has(args, 't'))
|
if (self->entry == &cmd_list_commands_entry)
|
||||||
return (cmd_list_keys_table(self, cmdq));
|
return (cmd_list_keys_commands(self, item));
|
||||||
|
|
||||||
width = 0;
|
tablename = args_get(args, 'T');
|
||||||
|
if (tablename != NULL && key_bindings_get_table(tablename, 0) == NULL) {
|
||||||
RB_FOREACH(bd, key_bindings, &key_bindings) {
|
cmdq_error(item, "table %s doesn't exist", tablename);
|
||||||
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
|
||||||
if (key == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
keywidth = strlen(key);
|
|
||||||
if (!(bd->key & KEYC_PREFIX)) {
|
|
||||||
if (bd->can_repeat)
|
|
||||||
keywidth += 4;
|
|
||||||
else
|
|
||||||
keywidth += 3;
|
|
||||||
} else if (bd->can_repeat)
|
|
||||||
keywidth += 3;
|
|
||||||
if (keywidth > width)
|
|
||||||
width = keywidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
RB_FOREACH(bd, key_bindings, &key_bindings) {
|
|
||||||
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
|
||||||
if (key == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
*flags = '\0';
|
|
||||||
if (!(bd->key & KEYC_PREFIX)) {
|
|
||||||
if (bd->can_repeat)
|
|
||||||
xsnprintf(flags, sizeof flags, "-rn ");
|
|
||||||
else
|
|
||||||
xsnprintf(flags, sizeof flags, "-n ");
|
|
||||||
} else if (bd->can_repeat)
|
|
||||||
xsnprintf(flags, sizeof flags, "-r ");
|
|
||||||
|
|
||||||
used = xsnprintf(tmp, sizeof tmp, "%s%*s ",
|
|
||||||
flags, (int) (width - strlen(flags)), key);
|
|
||||||
if (used >= sizeof tmp)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
cmd_list_print(bd->cmdlist, tmp + used, (sizeof tmp) - used);
|
|
||||||
cmdq_print(cmdq, "bind-key %s", tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
const char *tablename;
|
|
||||||
const struct mode_key_table *mtab;
|
|
||||||
struct mode_key_binding *mbind;
|
|
||||||
const char *key, *cmdstr, *mode;
|
|
||||||
int width, keywidth, any_mode;
|
|
||||||
|
|
||||||
tablename = args_get(args, 't');
|
|
||||||
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
|
||||||
cmdq_error(cmdq, "unknown key table: %s", tablename);
|
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
width = 0;
|
repeat = 0;
|
||||||
any_mode = 0;
|
tablewidth = keywidth = 0;
|
||||||
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
RB_FOREACH(table, key_tables, &key_tables) {
|
||||||
key = key_string_lookup_key(mbind->key);
|
if (tablename != NULL && strcmp(table->name, tablename) != 0)
|
||||||
if (key == NULL)
|
|
||||||
continue;
|
continue;
|
||||||
|
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
|
||||||
|
key = key_string_lookup_key(bd->key);
|
||||||
|
|
||||||
if (mbind->mode != 0)
|
if (bd->can_repeat)
|
||||||
any_mode = 1;
|
repeat = 1;
|
||||||
|
|
||||||
keywidth = strlen(key);
|
width = utf8_cstrwidth(table->name);
|
||||||
if (keywidth > width)
|
if (width > tablewidth)
|
||||||
width = keywidth;
|
tablewidth = width;
|
||||||
|
width = utf8_cstrwidth(key);
|
||||||
|
if (width > keywidth)
|
||||||
|
keywidth = width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
RB_FOREACH(table, key_tables, &key_tables) {
|
||||||
key = key_string_lookup_key(mbind->key);
|
if (tablename != NULL && strcmp(table->name, tablename) != 0)
|
||||||
if (key == NULL)
|
|
||||||
continue;
|
continue;
|
||||||
|
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
|
||||||
|
key = key_string_lookup_key(bd->key);
|
||||||
|
|
||||||
mode = "";
|
if (!repeat)
|
||||||
if (mbind->mode != 0)
|
r = "";
|
||||||
mode = "c";
|
else if (bd->can_repeat)
|
||||||
cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd);
|
r = "-r ";
|
||||||
if (cmdstr != NULL) {
|
else
|
||||||
cmdq_print(cmdq, "bind-key -%st %s%s %*s %s%s%s%s",
|
r = " ";
|
||||||
mode, any_mode && *mode == '\0' ? " " : "",
|
xsnprintf(tmp, sizeof tmp, "%s-T ", r);
|
||||||
mtab->name, (int) width, key, cmdstr,
|
|
||||||
mbind->arg != NULL ? " \"" : "",
|
cp = utf8_padcstr(table->name, tablewidth);
|
||||||
mbind->arg != NULL ? mbind->arg : "",
|
strlcat(tmp, cp, sizeof tmp);
|
||||||
mbind->arg != NULL ? "\"": "");
|
strlcat(tmp, " ", sizeof tmp);
|
||||||
|
free(cp);
|
||||||
|
|
||||||
|
cp = utf8_padcstr(key, keywidth);
|
||||||
|
strlcat(tmp, cp, sizeof tmp);
|
||||||
|
strlcat(tmp, " ", sizeof tmp);
|
||||||
|
free(cp);
|
||||||
|
|
||||||
|
cp = cmd_list_print(bd->cmdlist);
|
||||||
|
strlcat(tmp, cp, sizeof tmp);
|
||||||
|
free(cp);
|
||||||
|
|
||||||
|
cmdq_print(item, "bind-key %s", tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
const struct cmd_entry **entryp;
|
||||||
|
const struct cmd_entry *entry;
|
||||||
|
struct format_tree *ft;
|
||||||
|
const char *template, *s;
|
||||||
|
char *line;
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL) {
|
||||||
|
template = "#{command_list_name}"
|
||||||
|
"#{?command_list_alias, (#{command_list_alias}),} "
|
||||||
|
"#{command_list_usage}";
|
||||||
|
}
|
||||||
|
|
||||||
|
ft = format_create(item, FORMAT_NONE, 0);
|
||||||
|
format_defaults(ft, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
||||||
|
entry = *entryp;
|
||||||
|
|
||||||
|
format_add(ft, "command_list_name", "%s", entry->name);
|
||||||
|
if (entry->alias != NULL)
|
||||||
|
s = entry->alias;
|
||||||
|
else
|
||||||
|
s = "";
|
||||||
|
format_add(ft, "command_list_alias", "%s", s);
|
||||||
|
if (entry->usage != NULL)
|
||||||
|
s = entry->usage;
|
||||||
|
else
|
||||||
|
s = "";
|
||||||
|
format_add(ft, "command_list_usage", "%s", s);
|
||||||
|
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
if (*line != '\0')
|
||||||
|
cmdq_print(item, "%s", line);
|
||||||
|
free(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -27,70 +26,66 @@
|
|||||||
* List panes on given window.
|
* List panes on given window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_list_panes_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_list_panes_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
void cmd_list_panes_server(struct cmd *, struct cmd_q *);
|
static void cmd_list_panes_server(struct cmd *, struct cmdq_item *);
|
||||||
void cmd_list_panes_session(
|
static void cmd_list_panes_session(struct cmd *, struct session *,
|
||||||
struct cmd *, struct session *, struct cmd_q *, int);
|
struct cmdq_item *, int);
|
||||||
void cmd_list_panes_window(struct cmd *,
|
static void cmd_list_panes_window(struct cmd *, struct session *,
|
||||||
struct session *, struct winlink *, struct cmd_q *, int);
|
struct winlink *, struct cmdq_item *, int);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_panes_entry = {
|
const struct cmd_entry cmd_list_panes_entry = {
|
||||||
"list-panes", "lsp",
|
.name = "list-panes",
|
||||||
"asF:t:", 0, 0,
|
.alias = "lsp",
|
||||||
"[-as] [-F format] " CMD_TARGET_WINDOW_USAGE,
|
|
||||||
0,
|
.args = { "asF:t:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-as] [-F format] " CMD_TARGET_WINDOW_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_list_panes_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_list_panes_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_panes_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_list_panes_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s = item->state.tflag.s;
|
||||||
struct winlink *wl;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
|
|
||||||
if (args_has(args, 'a'))
|
if (args_has(args, 'a'))
|
||||||
cmd_list_panes_server(self, cmdq);
|
cmd_list_panes_server(self, item);
|
||||||
else if (args_has(args, 's')) {
|
else if (args_has(args, 's'))
|
||||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
cmd_list_panes_session(self, s, item, 1);
|
||||||
if (s == NULL)
|
else
|
||||||
return (CMD_RETURN_ERROR);
|
cmd_list_panes_window(self, s, wl, item, 0);
|
||||||
cmd_list_panes_session(self, s, cmdq, 1);
|
|
||||||
} else {
|
|
||||||
wl = cmd_find_window(cmdq, args_get(args, 't'), &s);
|
|
||||||
if (wl == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
cmd_list_panes_window(self, s, wl, cmdq, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_list_panes_server(struct cmd *self, struct cmd_q *cmdq)
|
cmd_list_panes_server(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
RB_FOREACH(s, sessions, &sessions)
|
RB_FOREACH(s, sessions, &sessions)
|
||||||
cmd_list_panes_session(self, s, cmdq, 2);
|
cmd_list_panes_session(self, s, item, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_list_panes_session(
|
cmd_list_panes_session(struct cmd *self, struct session *s,
|
||||||
struct cmd *self, struct session *s, struct cmd_q *cmdq, int type)
|
struct cmdq_item *item, int type)
|
||||||
{
|
{
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
|
||||||
RB_FOREACH(wl, winlinks, &s->windows)
|
RB_FOREACH(wl, winlinks, &s->windows)
|
||||||
cmd_list_panes_window(self, s, wl, cmdq, type);
|
cmd_list_panes_window(self, s, wl, item, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_list_panes_window(struct cmd *self,
|
cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
|
||||||
struct session *s, struct winlink *wl, struct cmd_q *cmdq, int type)
|
struct cmdq_item *item, int type)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
@@ -117,9 +112,9 @@ cmd_list_panes_window(struct cmd *self,
|
|||||||
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
template = "#{session_name}:#{window_index}.#{pane_index}: "
|
template = "#{session_name}:#{window_index}."
|
||||||
"[#{pane_width}x#{pane_height}] [history "
|
"#{pane_index}: [#{pane_width}x#{pane_height}] "
|
||||||
"#{history_size}/#{history_limit}, "
|
"[history #{history_size}/#{history_limit}, "
|
||||||
"#{history_bytes} bytes] #{pane_id}"
|
"#{history_bytes} bytes] #{pane_id}"
|
||||||
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||||
break;
|
break;
|
||||||
@@ -128,14 +123,12 @@ cmd_list_panes_window(struct cmd *self,
|
|||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||||
ft = format_create();
|
ft = format_create(item, FORMAT_NONE, 0);
|
||||||
format_add(ft, "line", "%u", n);
|
format_add(ft, "line", "%u", n);
|
||||||
format_session(ft, s);
|
format_defaults(ft, NULL, s, wl, wp);
|
||||||
format_winlink(ft, s, wl);
|
|
||||||
format_window_pane(ft, wp);
|
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
line = format_expand(ft, template);
|
||||||
cmdq_print(cmdq, "%s", line);
|
cmdq_print(item, "%s", line);
|
||||||
free(line);
|
free(line);
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -28,20 +28,30 @@
|
|||||||
* List all sessions.
|
* List all sessions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_list_sessions_exec(struct cmd *, struct cmd_q *);
|
#define LIST_SESSIONS_TEMPLATE \
|
||||||
|
"#{session_name}: #{session_windows} windows " \
|
||||||
|
"(created #{t:session_created}) " \
|
||||||
|
"[#{session_width}x#{session_height}]" \
|
||||||
|
"#{?session_grouped, (group ,}" \
|
||||||
|
"#{session_group}#{?session_grouped,),}" \
|
||||||
|
"#{?session_attached, (attached),}"
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_list_sessions_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_sessions_entry = {
|
const struct cmd_entry cmd_list_sessions_entry = {
|
||||||
"list-sessions", "ls",
|
.name = "list-sessions",
|
||||||
"F:", 0, 0,
|
.alias = "ls",
|
||||||
"[-F format]",
|
|
||||||
0,
|
.args = { "F:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-F format]",
|
||||||
NULL,
|
|
||||||
cmd_list_sessions_exec
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_list_sessions_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_sessions_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
@@ -55,12 +65,12 @@ cmd_list_sessions_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
ft = format_create();
|
ft = format_create(item, FORMAT_NONE, 0);
|
||||||
format_add(ft, "line", "%u", n);
|
format_add(ft, "line", "%u", n);
|
||||||
format_session(ft, s);
|
format_defaults(ft, NULL, s, NULL, NULL);
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
line = format_expand(ft, template);
|
||||||
cmdq_print(cmdq, "%s", line);
|
cmdq_print(item, "%s", line);
|
||||||
free(line);
|
free(line);
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,52 +27,62 @@
|
|||||||
* List windows on given session.
|
* List windows on given session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmd_q *);
|
#define LIST_WINDOWS_TEMPLATE \
|
||||||
|
"#{window_index}: #{window_name}#{window_flags} " \
|
||||||
|
"(#{window_panes} panes) " \
|
||||||
|
"[#{window_width}x#{window_height}] " \
|
||||||
|
"[layout #{window_layout}] #{window_id}" \
|
||||||
|
"#{?window_active, (active),}";
|
||||||
|
#define LIST_WINDOWS_WITH_SESSION_TEMPLATE \
|
||||||
|
"#{session_name}:" \
|
||||||
|
"#{window_index}: #{window_name}#{window_flags} " \
|
||||||
|
"(#{window_panes} panes) " \
|
||||||
|
"[#{window_width}x#{window_height}] "
|
||||||
|
|
||||||
void cmd_list_windows_server(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmdq_item *);
|
||||||
void cmd_list_windows_session(
|
|
||||||
struct cmd *, struct session *, struct cmd_q *, int);
|
static void cmd_list_windows_server(struct cmd *, struct cmdq_item *);
|
||||||
|
static void cmd_list_windows_session(struct cmd *, struct session *,
|
||||||
|
struct cmdq_item *, int);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_windows_entry = {
|
const struct cmd_entry cmd_list_windows_entry = {
|
||||||
"list-windows", "lsw",
|
.name = "list-windows",
|
||||||
"F:at:", 0, 0,
|
.alias = "lsw",
|
||||||
"[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
|
|
||||||
0,
|
.args = { "F:at:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_list_windows_exec
|
.tflag = CMD_SESSION,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_list_windows_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_windows_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_list_windows_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
|
||||||
|
|
||||||
if (args_has(args, 'a'))
|
if (args_has(args, 'a'))
|
||||||
cmd_list_windows_server(self, cmdq);
|
cmd_list_windows_server(self, item);
|
||||||
else {
|
else
|
||||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
cmd_list_windows_session(self, item->state.tflag.s, item, 0);
|
||||||
if (s == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
cmd_list_windows_session(self, s, cmdq, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_list_windows_server(struct cmd *self, struct cmd_q *cmdq)
|
cmd_list_windows_server(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
RB_FOREACH(s, sessions, &sessions)
|
RB_FOREACH(s, sessions, &sessions)
|
||||||
cmd_list_windows_session(self, s, cmdq, 1);
|
cmd_list_windows_session(self, s, item, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_list_windows_session(
|
cmd_list_windows_session(struct cmd *self, struct session *s,
|
||||||
struct cmd *self, struct session *s, struct cmd_q *cmdq, int type)
|
struct cmdq_item *item, int type)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
@@ -95,14 +105,12 @@ cmd_list_windows_session(
|
|||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
ft = format_create();
|
ft = format_create(item, FORMAT_NONE, 0);
|
||||||
format_add(ft, "line", "%u", n);
|
format_add(ft, "line", "%u", n);
|
||||||
format_session(ft, s);
|
format_defaults(ft, NULL, s, wl, NULL);
|
||||||
format_winlink(ft, s, wl);
|
|
||||||
format_window_pane(ft, wl->window->active);
|
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
line = format_expand(ft, template);
|
||||||
cmdq_print(cmdq, "%s", line);
|
cmdq_print(item, "%s", line);
|
||||||
free(line);
|
free(line);
|
||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|||||||
35
cmd-list.c
35
cmd-list.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
struct cmd_list *
|
struct cmd_list *
|
||||||
cmd_list_parse(int argc, char **argv, const char* file, u_int line,
|
cmd_list_parse(int argc, char **argv, const char *file, u_int line,
|
||||||
char **cause)
|
char **cause)
|
||||||
{
|
{
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
@@ -99,21 +99,28 @@ cmd_list_free(struct cmd_list *cmdlist)
|
|||||||
free(cmdlist);
|
free(cmdlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
char *
|
||||||
cmd_list_print(struct cmd_list *cmdlist, char *buf, size_t len)
|
cmd_list_print(struct cmd_list *cmdlist)
|
||||||
{
|
{
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
size_t off;
|
char *buf, *this;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
len = 1;
|
||||||
|
buf = xcalloc(1, len);
|
||||||
|
|
||||||
off = 0;
|
|
||||||
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||||
if (off >= len)
|
this = cmd_print(cmd);
|
||||||
break;
|
|
||||||
off += cmd_print(cmd, buf + off, len - off);
|
len += strlen(this) + 3;
|
||||||
if (off >= len)
|
buf = xrealloc(buf, len);
|
||||||
break;
|
|
||||||
|
strlcat(buf, this, len);
|
||||||
if (TAILQ_NEXT(cmd, qentry) != NULL)
|
if (TAILQ_NEXT(cmd, qentry) != NULL)
|
||||||
off += xsnprintf(buf + off, len - off, " ; ");
|
strlcat(buf, " ; ", len);
|
||||||
|
|
||||||
|
free(this);
|
||||||
}
|
}
|
||||||
return (off);
|
|
||||||
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -30,73 +31,65 @@
|
|||||||
* Loads a paste buffer from a file.
|
* Loads a paste buffer from a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmdq_item *);
|
||||||
void cmd_load_buffer_callback(struct client *, int, void *);
|
|
||||||
|
static void cmd_load_buffer_callback(struct client *, int, void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_load_buffer_entry = {
|
const struct cmd_entry cmd_load_buffer_entry = {
|
||||||
"load-buffer", "loadb",
|
.name = "load-buffer",
|
||||||
"b:", 1, 1,
|
.alias = "loadb",
|
||||||
CMD_BUFFER_USAGE " path",
|
|
||||||
0,
|
.args = { "b:", 1, 1 },
|
||||||
NULL,
|
.usage = CMD_BUFFER_USAGE " path",
|
||||||
NULL,
|
|
||||||
cmd_load_buffer_exec
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_load_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
struct cmd_load_buffer_data {
|
||||||
cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
struct cmdq_item *item;
|
||||||
{
|
char *bufname;
|
||||||
struct args *args = self->args;
|
};
|
||||||
struct client *c = cmdq->client;
|
|
||||||
struct session *s;
|
|
||||||
FILE *f;
|
|
||||||
const char *path, *newpath, *wd;
|
|
||||||
char *pdata, *new_pdata, *cause;
|
|
||||||
size_t psize;
|
|
||||||
u_int limit;
|
|
||||||
int ch, error, buffer, *buffer_ptr;
|
|
||||||
|
|
||||||
if (!args_has(args, 'b'))
|
static enum cmd_retval
|
||||||
buffer = -1;
|
cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
else {
|
{
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
struct args *args = self->args;
|
||||||
if (cause != NULL) {
|
struct cmd_load_buffer_data *cdata;
|
||||||
cmdq_error(cmdq, "buffer %s", cause);
|
struct client *c = item->client;
|
||||||
free(cause);
|
FILE *f;
|
||||||
return (CMD_RETURN_ERROR);
|
const char *path, *bufname;
|
||||||
}
|
char *pdata, *new_pdata, *cause, *file;
|
||||||
}
|
size_t psize;
|
||||||
|
int ch, error;
|
||||||
|
|
||||||
|
bufname = NULL;
|
||||||
|
if (args_has(args, 'b'))
|
||||||
|
bufname = args_get(args, 'b');
|
||||||
|
|
||||||
path = args->argv[0];
|
path = args->argv[0];
|
||||||
if (strcmp(path, "-") == 0) {
|
if (strcmp(path, "-") == 0) {
|
||||||
buffer_ptr = xmalloc(sizeof *buffer_ptr);
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
*buffer_ptr = buffer;
|
cdata->item = item;
|
||||||
|
|
||||||
error = server_set_stdin_callback (c, cmd_load_buffer_callback,
|
if (bufname != NULL)
|
||||||
buffer_ptr, &cause);
|
cdata->bufname = xstrdup(bufname);
|
||||||
|
|
||||||
|
error = server_set_stdin_callback(c, cmd_load_buffer_callback,
|
||||||
|
cdata, &cause);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
cmdq_error(cmdq, "%s: %s", path, cause);
|
cmdq_error(item, "%s: %s", path, cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
return (CMD_RETURN_WAIT);
|
return (CMD_RETURN_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != NULL)
|
file = server_client_get_path(c, path);
|
||||||
wd = c->cwd;
|
f = fopen(file, "rb");
|
||||||
else if ((s = cmd_current_session(cmdq, 0)) != NULL) {
|
if (f == NULL) {
|
||||||
wd = options_get_string(&s->options, "default-path");
|
cmdq_error(item, "%s: %s", file, strerror(errno));
|
||||||
if (*wd == '\0')
|
free(file);
|
||||||
wd = s->cwd;
|
|
||||||
} else
|
|
||||||
wd = NULL;
|
|
||||||
if (wd != NULL && *wd != '\0') {
|
|
||||||
newpath = get_full_path(wd, path);
|
|
||||||
if (newpath != NULL)
|
|
||||||
path = newpath;
|
|
||||||
}
|
|
||||||
if ((f = fopen(path, "rb")) == NULL) {
|
|
||||||
cmdq_error(cmdq, "%s: %s", path, strerror(errno));
|
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,29 +98,26 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
while ((ch = getc(f)) != EOF) {
|
while ((ch = getc(f)) != EOF) {
|
||||||
/* Do not let the server die due to memory exhaustion. */
|
/* Do not let the server die due to memory exhaustion. */
|
||||||
if ((new_pdata = realloc(pdata, psize + 2)) == NULL) {
|
if ((new_pdata = realloc(pdata, psize + 2)) == NULL) {
|
||||||
cmdq_error(cmdq, "realloc error: %s", strerror(errno));
|
cmdq_error(item, "realloc error: %s", strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
pdata = new_pdata;
|
pdata = new_pdata;
|
||||||
pdata[psize++] = ch;
|
pdata[psize++] = ch;
|
||||||
}
|
}
|
||||||
if (ferror(f)) {
|
if (ferror(f)) {
|
||||||
cmdq_error(cmdq, "%s: read error", path);
|
cmdq_error(item, "%s: read error", file);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (pdata != NULL)
|
if (pdata != NULL)
|
||||||
pdata[psize] = '\0';
|
pdata[psize] = '\0';
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
free(file);
|
||||||
|
|
||||||
limit = options_get_number(&global_options, "buffer-limit");
|
if (paste_set(pdata, psize, bufname, &cause) != 0) {
|
||||||
if (buffer == -1) {
|
cmdq_error(item, "%s", cause);
|
||||||
paste_add(&global_buffers, pdata, psize, limit);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
|
||||||
cmdq_error(cmdq, "no buffer %d", buffer);
|
|
||||||
free(pdata);
|
free(pdata);
|
||||||
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,42 +130,44 @@ error:
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_load_buffer_callback(struct client *c, int closed, void *data)
|
cmd_load_buffer_callback(struct client *c, int closed, void *data)
|
||||||
{
|
{
|
||||||
int *buffer = data;
|
struct cmd_load_buffer_data *cdata = data;
|
||||||
char *pdata;
|
char *pdata, *cause, *saved;
|
||||||
size_t psize;
|
size_t psize;
|
||||||
u_int limit;
|
|
||||||
|
|
||||||
if (!closed)
|
if (!closed)
|
||||||
return;
|
return;
|
||||||
c->stdin_callback = NULL;
|
c->stdin_callback = NULL;
|
||||||
|
|
||||||
c->references--;
|
server_client_unref(c);
|
||||||
if (c->flags & CLIENT_DEAD)
|
if (c->flags & CLIENT_DEAD)
|
||||||
return;
|
goto out;
|
||||||
|
|
||||||
psize = EVBUFFER_LENGTH(c->stdin_data);
|
psize = EVBUFFER_LENGTH(c->stdin_data);
|
||||||
if (psize == 0 || (pdata = malloc(psize + 1)) == NULL) {
|
if (psize == 0 || (pdata = malloc(psize + 1)) == NULL)
|
||||||
free(data);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
memcpy(pdata, EVBUFFER_DATA(c->stdin_data), psize);
|
memcpy(pdata, EVBUFFER_DATA(c->stdin_data), psize);
|
||||||
pdata[psize] = '\0';
|
pdata[psize] = '\0';
|
||||||
evbuffer_drain(c->stdin_data, psize);
|
evbuffer_drain(c->stdin_data, psize);
|
||||||
|
|
||||||
limit = options_get_number(&global_options, "buffer-limit");
|
if (paste_set(pdata, psize, cdata->bufname, &cause) != 0) {
|
||||||
if (*buffer == -1)
|
|
||||||
paste_add(&global_buffers, pdata, psize, limit);
|
|
||||||
else if (paste_replace(&global_buffers, *buffer, pdata, psize) != 0) {
|
|
||||||
/* No context so can't use server_client_msg_error. */
|
/* No context so can't use server_client_msg_error. */
|
||||||
evbuffer_add_printf(c->stderr_data, "no buffer %d\n", *buffer);
|
if (~c->flags & CLIENT_UTF8) {
|
||||||
server_push_stderr(c);
|
saved = cause;
|
||||||
|
cause = utf8_sanitize(saved);
|
||||||
|
free(saved);
|
||||||
|
}
|
||||||
|
evbuffer_add_printf(c->stderr_data, "%s", cause);
|
||||||
|
server_client_push_stderr(c);
|
||||||
|
free(pdata);
|
||||||
|
free(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(data);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
cmdq_continue(c->cmdq);
|
cdata->item->flags &= ~CMDQ_WAITING;
|
||||||
|
|
||||||
|
free(cdata->bufname);
|
||||||
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -18,68 +18,61 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock commands.
|
* Lock commands.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_lock_server_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_lock_server_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_lock_server_entry = {
|
const struct cmd_entry cmd_lock_server_entry = {
|
||||||
"lock-server", "lock",
|
.name = "lock-server",
|
||||||
"", 0, 0,
|
.alias = "lock",
|
||||||
"",
|
|
||||||
0,
|
.args = { "", 0, 0 },
|
||||||
NULL,
|
.usage = "",
|
||||||
NULL,
|
|
||||||
cmd_lock_server_exec
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_lock_server_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_lock_session_entry = {
|
const struct cmd_entry cmd_lock_session_entry = {
|
||||||
"lock-session", "locks",
|
.name = "lock-session",
|
||||||
"t:", 0, 0,
|
.alias = "locks",
|
||||||
CMD_TARGET_SESSION_USAGE,
|
|
||||||
0,
|
.args = { "t:", 0, 0 },
|
||||||
NULL,
|
.usage = CMD_TARGET_SESSION_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_lock_server_exec
|
.tflag = CMD_SESSION,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_lock_server_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_lock_client_entry = {
|
const struct cmd_entry cmd_lock_client_entry = {
|
||||||
"lock-client", "lockc",
|
.name = "lock-client",
|
||||||
"t:", 0, 0,
|
.alias = "lockc",
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
|
||||||
0,
|
.args = { "t:", 0, 0 },
|
||||||
NULL,
|
.usage = CMD_TARGET_CLIENT_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_lock_server_exec
|
.tflag = CMD_CLIENT,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_lock_server_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_lock_server_exec(struct cmd *self, unused struct cmd_q *cmdq)
|
cmd_lock_server_exec(struct cmd *self, __unused struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
|
||||||
struct client *c;
|
|
||||||
struct session *s;
|
|
||||||
|
|
||||||
if (self->entry == &cmd_lock_server_entry)
|
if (self->entry == &cmd_lock_server_entry)
|
||||||
server_lock();
|
server_lock();
|
||||||
else if (self->entry == &cmd_lock_session_entry) {
|
else if (self->entry == &cmd_lock_session_entry)
|
||||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
server_lock_session(item->state.tflag.s);
|
||||||
if (s == NULL)
|
else
|
||||||
return (CMD_RETURN_ERROR);
|
server_lock_client(item->state.c);
|
||||||
server_lock_session(s);
|
|
||||||
} else {
|
|
||||||
c = cmd_find_client(cmdq, args_get(args, 't'), 0);
|
|
||||||
if (c == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
server_lock_client(c);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -26,50 +26,79 @@
|
|||||||
* Move a window.
|
* Move a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_move_window_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_move_window_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_move_window_entry = {
|
const struct cmd_entry cmd_move_window_entry = {
|
||||||
"move-window", "movew",
|
.name = "move-window",
|
||||||
"dkrs:t:", 0, 0,
|
.alias = "movew",
|
||||||
"[-dkr] " CMD_SRCDST_WINDOW_USAGE,
|
|
||||||
0,
|
.args = { "adkrs:t:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-dkr] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_move_window_exec
|
.sflag = CMD_WINDOW,
|
||||||
|
.tflag = CMD_MOVEW_R,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_move_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
const struct cmd_entry cmd_link_window_entry = {
|
||||||
cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
.name = "link-window",
|
||||||
|
.alias = "linkw",
|
||||||
|
|
||||||
|
.args = { "adks:t:", 0, 0 },
|
||||||
|
.usage = "[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
|
|
||||||
|
.sflag = CMD_WINDOW,
|
||||||
|
.tflag = CMD_WINDOW_INDEX,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_move_window_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_move_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *src, *dst, *s;
|
struct session *src = item->state.sflag.s;
|
||||||
struct winlink *wl;
|
struct session *dst = item->state.tflag.s;
|
||||||
|
struct winlink *wl = item->state.sflag.wl;
|
||||||
char *cause;
|
char *cause;
|
||||||
int idx, kflag, dflag;
|
int idx = item->state.tflag.idx, kflag, dflag, sflag;
|
||||||
|
|
||||||
if (args_has(args, 'r')) {
|
if (args_has(args, 'r')) {
|
||||||
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
session_renumber_windows(dst);
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
session_renumber_windows(s);
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 's'), &src)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
if ((idx = cmd_find_index(cmdq, args_get(args, 't'), &dst)) == -2)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
kflag = args_has(self->args, 'k');
|
kflag = args_has(self->args, 'k');
|
||||||
dflag = args_has(self->args, 'd');
|
dflag = args_has(self->args, 'd');
|
||||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
sflag = args_has(self->args, 's');
|
||||||
cmdq_error(cmdq, "can't move window: %s", cause);
|
|
||||||
|
if (args_has(self->args, 'a')) {
|
||||||
|
if ((idx = winlink_shuffle_up(dst, dst->curw)) == -1)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag,
|
||||||
|
&cause) != 0) {
|
||||||
|
cmdq_error(item, "can't link window: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
server_unlink_window(src, wl);
|
if (self->entry == &cmd_move_window_entry)
|
||||||
|
server_unlink_window(src, wl);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Renumber the winlinks in the src session only, the destination
|
||||||
|
* session already has the correct winlink id to us, either
|
||||||
|
* automatically or specified by -s.
|
||||||
|
*/
|
||||||
|
if (!sflag && options_get_number(src->options, "renumber-windows"))
|
||||||
|
session_renumber_windows(src);
|
||||||
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -18,7 +18,8 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <pwd.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
@@ -30,69 +31,116 @@
|
|||||||
* Create a new session and attach to the current terminal unless -d is given.
|
* Create a new session and attach to the current terminal unless -d is given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_new_session_check(struct args *);
|
#define NEW_SESSION_TEMPLATE "#{session_name}:"
|
||||||
enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
static enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_new_session_entry = {
|
const struct cmd_entry cmd_new_session_entry = {
|
||||||
"new-session", "new",
|
.name = "new-session",
|
||||||
"AdDF:n:Ps:t:x:y:", 0, 1,
|
.alias = "new",
|
||||||
"[-AdDP] [-F format] [-n window-name] [-s session-name] "
|
|
||||||
CMD_TARGET_SESSION_USAGE " [-x width] [-y height] [command]",
|
.args = { "Ac:dDEF:n:Ps:t:x:y:", 0, -1 },
|
||||||
CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON,
|
.usage = "[-AdDEP] [-c start-directory] [-F format] [-n window-name] "
|
||||||
NULL,
|
"[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
|
||||||
cmd_new_session_check,
|
"[-y height] [command]",
|
||||||
cmd_new_session_exec
|
|
||||||
|
.tflag = CMD_SESSION_CANFAIL,
|
||||||
|
|
||||||
|
.flags = CMD_STARTSERVER,
|
||||||
|
.exec = cmd_new_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
const struct cmd_entry cmd_has_session_entry = {
|
||||||
cmd_new_session_check(struct args *args)
|
.name = "has-session",
|
||||||
{
|
.alias = "has",
|
||||||
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n')))
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
.args = { "t:", 0, 0 },
|
||||||
cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
.usage = CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
|
.tflag = CMD_SESSION,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_new_session_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c = cmdq->client;
|
struct client *c = item->client;
|
||||||
struct session *s, *groupwith;
|
struct session *s, *as, *groupwith;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
struct environ env;
|
struct environ *env;
|
||||||
struct termios tio, *tiop;
|
struct termios tio, *tiop;
|
||||||
struct passwd *pw;
|
struct session_group *sg;
|
||||||
const char *newname, *target, *update, *cwd, *errstr;
|
const char *newname, *errstr, *template, *group, *prefix;
|
||||||
const char *template;
|
const char *path, *cmd, *cwd, *to_free = NULL;
|
||||||
char *cmd, *cause, *cp;
|
char **argv, *cause, *cp;
|
||||||
int detached, idx;
|
int detached, already_attached, idx, argc;
|
||||||
u_int sx, sy;
|
u_int sx, sy;
|
||||||
int already_attached;
|
struct environ_entry *envent;
|
||||||
struct format_tree *ft;
|
struct cmd_find_state fs;
|
||||||
|
|
||||||
|
if (self->entry == &cmd_has_session_entry) {
|
||||||
|
/*
|
||||||
|
* cmd_prepare() will fail if the session cannot be found,
|
||||||
|
* hence always return success here.
|
||||||
|
*/
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) {
|
||||||
|
cmdq_error(item, "command or window name given with target");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
newname = args_get(args, 's');
|
newname = args_get(args, 's');
|
||||||
if (newname != NULL) {
|
if (newname != NULL) {
|
||||||
if (!session_check_name(newname)) {
|
if (!session_check_name(newname)) {
|
||||||
cmdq_error(cmdq, "bad session name: %s", newname);
|
cmdq_error(item, "bad session name: %s", newname);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (session_find(newname) != NULL) {
|
if ((as = session_find(newname)) != NULL) {
|
||||||
if (args_has(args, 'A')) {
|
if (args_has(args, 'A')) {
|
||||||
return (cmd_attach_session(cmdq, newname,
|
/*
|
||||||
args_has(args, 'D'), 0));
|
* This item is now destined for
|
||||||
|
* attach-session. Because attach-session will
|
||||||
|
* have already been prepared, copy this
|
||||||
|
* session into its tflag so it can be used.
|
||||||
|
*/
|
||||||
|
cmd_find_from_session(&item->state.tflag, as);
|
||||||
|
return (cmd_attach_session(item,
|
||||||
|
args_has(args, 'D'), 0, NULL,
|
||||||
|
args_has(args, 'E')));
|
||||||
}
|
}
|
||||||
cmdq_error(cmdq, "duplicate session: %s", newname);
|
cmdq_error(item, "duplicate session: %s", newname);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
target = args_get(args, 't');
|
/* Is this going to be part of a session group? */
|
||||||
if (target != NULL) {
|
group = args_get(args, 't');
|
||||||
groupwith = cmd_find_session(cmdq, target, 0);
|
if (group != NULL) {
|
||||||
if (groupwith == NULL)
|
groupwith = item->state.tflag.s;
|
||||||
return (CMD_RETURN_ERROR);
|
if (groupwith == NULL) {
|
||||||
} else
|
if (!session_check_name(group)) {
|
||||||
|
cmdq_error(item, "bad group name: %s", group);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
sg = session_group_find(group);
|
||||||
|
} else
|
||||||
|
sg = session_group_contains(groupwith);
|
||||||
|
if (sg != NULL)
|
||||||
|
prefix = sg->name;
|
||||||
|
else if (groupwith != NULL)
|
||||||
|
prefix = groupwith->name;
|
||||||
|
else
|
||||||
|
prefix = group;
|
||||||
|
} else {
|
||||||
groupwith = NULL;
|
groupwith = NULL;
|
||||||
|
sg = NULL;
|
||||||
|
prefix = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set -d if no client. */
|
/* Set -d if no client. */
|
||||||
detached = args_has(args, 'd');
|
detached = args_has(args, 'd');
|
||||||
@@ -104,16 +152,30 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
if (c != NULL && c->session != NULL)
|
if (c != NULL && c->session != NULL)
|
||||||
already_attached = 1;
|
already_attached = 1;
|
||||||
|
|
||||||
|
/* Get the new session working directory. */
|
||||||
|
if (args_has(args, 'c')) {
|
||||||
|
cwd = args_get(args, 'c');
|
||||||
|
to_free = cwd = format_single(item, cwd, c, NULL, NULL, NULL);
|
||||||
|
} else if (c != NULL && c->session == NULL && c->cwd != NULL)
|
||||||
|
cwd = c->cwd;
|
||||||
|
else
|
||||||
|
cwd = ".";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Save the termios settings, part of which is used for new windows in
|
* If this is a new client, check for nesting and save the termios
|
||||||
* this session.
|
* settings (part of which is used for new windows in this session).
|
||||||
*
|
*
|
||||||
* This is read again with tcgetattr() rather than using tty.tio as if
|
* tcgetattr() is used rather than using tty.tio since if the client is
|
||||||
* detached, tty_open won't be called. Because of this, it must be done
|
* detached, tty_open won't be called. It must be done before opening
|
||||||
* before opening the terminal as that calls tcsetattr() to prepare for
|
* the terminal as that calls tcsetattr() to prepare for tmux taking
|
||||||
* tmux taking over.
|
* over.
|
||||||
*/
|
*/
|
||||||
if (!detached && !already_attached && c->tty.fd != -1) {
|
if (!detached && !already_attached && c->tty.fd != -1) {
|
||||||
|
if (server_client_check_nested(item->client)) {
|
||||||
|
cmdq_error(item, "sessions should be nested with care, "
|
||||||
|
"unset $TMUX to force");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
if (tcgetattr(c->tty.fd, &tio) != 0)
|
if (tcgetattr(c->tty.fd, &tio) != 0)
|
||||||
fatal("tcgetattr failed");
|
fatal("tcgetattr failed");
|
||||||
tiop = &tio;
|
tiop = &tio;
|
||||||
@@ -122,24 +184,13 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
|
|
||||||
/* Open the terminal if necessary. */
|
/* Open the terminal if necessary. */
|
||||||
if (!detached && !already_attached) {
|
if (!detached && !already_attached) {
|
||||||
if (server_client_open(c, NULL, &cause) != 0) {
|
if (server_client_open(c, &cause) != 0) {
|
||||||
cmdq_error(cmdq, "open terminal failed: %s", cause);
|
cmdq_error(item, "open terminal failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the new session working directory. */
|
|
||||||
if (c != NULL && c->cwd != NULL)
|
|
||||||
cwd = c->cwd;
|
|
||||||
else {
|
|
||||||
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 (c != NULL) {
|
if (c != NULL) {
|
||||||
sx = c->tty.sx;
|
sx = c->tty.sx;
|
||||||
@@ -151,18 +202,18 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
if (detached && args_has(args, 'x')) {
|
if (detached && args_has(args, 'x')) {
|
||||||
sx = strtonum(args_get(args, 'x'), 1, USHRT_MAX, &errstr);
|
sx = strtonum(args_get(args, 'x'), 1, USHRT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
cmdq_error(cmdq, "width %s", errstr);
|
cmdq_error(item, "width %s", errstr);
|
||||||
return (CMD_RETURN_ERROR);
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (detached && args_has(args, 'y')) {
|
if (detached && args_has(args, 'y')) {
|
||||||
sy = strtonum(args_get(args, 'y'), 1, USHRT_MAX, &errstr);
|
sy = strtonum(args_get(args, 'y'), 1, USHRT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
cmdq_error(cmdq, "height %s", errstr);
|
cmdq_error(item, "height %s", errstr);
|
||||||
return (CMD_RETURN_ERROR);
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sy > 0 && options_get_number(&global_s_options, "status"))
|
if (sy > 0 && options_get_number(global_s_options, "status"))
|
||||||
sy--;
|
sy--;
|
||||||
if (sx == 0)
|
if (sx == 0)
|
||||||
sx = 1;
|
sx = 1;
|
||||||
@@ -170,58 +221,88 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
sy = 1;
|
sy = 1;
|
||||||
|
|
||||||
/* Figure out the command for the new window. */
|
/* Figure out the command for the new window. */
|
||||||
if (target != NULL)
|
argc = -1;
|
||||||
cmd = NULL;
|
argv = NULL;
|
||||||
else if (args->argc != 0)
|
if (!args_has(args, 't') && args->argc != 0) {
|
||||||
cmd = args->argv[0];
|
argc = args->argc;
|
||||||
|
argv = args->argv;
|
||||||
|
} else if (sg == NULL && groupwith == NULL) {
|
||||||
|
cmd = options_get_string(global_s_options, "default-command");
|
||||||
|
if (cmd != NULL && *cmd != '\0') {
|
||||||
|
argc = 1;
|
||||||
|
argv = (char **)&cmd;
|
||||||
|
} else {
|
||||||
|
argc = 0;
|
||||||
|
argv = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
path = NULL;
|
||||||
|
if (c != NULL && c->session == NULL)
|
||||||
|
envent = environ_find(c->environ, "PATH");
|
||||||
else
|
else
|
||||||
cmd = options_get_string(&global_s_options, "default-command");
|
envent = environ_find(global_environ, "PATH");
|
||||||
|
if (envent != NULL)
|
||||||
|
path = envent->value;
|
||||||
|
|
||||||
/* Construct the environment. */
|
/* Construct the environment. */
|
||||||
environ_init(&env);
|
env = environ_create();
|
||||||
update = options_get_string(&global_s_options, "update-environment");
|
if (c != NULL && !args_has(args, 'E'))
|
||||||
if (c != NULL)
|
environ_update(global_s_options, c->environ, env);
|
||||||
environ_update(update, &c->environ, &env);
|
|
||||||
|
|
||||||
/* Create the new session. */
|
/* Create the new session. */
|
||||||
idx = -1 - options_get_number(&global_s_options, "base-index");
|
idx = -1 - options_get_number(global_s_options, "base-index");
|
||||||
s = session_create(newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause);
|
s = session_create(prefix, newname, argc, argv, path, cwd, env, tiop,
|
||||||
|
idx, sx, sy, &cause);
|
||||||
|
environ_free(env);
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
cmdq_error(cmdq, "create session failed: %s", cause);
|
cmdq_error(item, "create session failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
goto error;
|
||||||
}
|
}
|
||||||
environ_free(&env);
|
|
||||||
|
|
||||||
/* Set the initial window name if one given. */
|
/* Set the initial window name if one given. */
|
||||||
if (cmd != NULL && args_has(args, 'n')) {
|
if (argc >= 0 && args_has(args, 'n')) {
|
||||||
w = s->curw->window;
|
w = s->curw->window;
|
||||||
window_set_name(w, args_get(args, 'n'));
|
window_set_name(w, args_get(args, 'n'));
|
||||||
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,
|
* If a target session is given, this is to be part of a session group,
|
||||||
* so add it to the group and synchronize.
|
* so add it to the group and synchronize.
|
||||||
*/
|
*/
|
||||||
if (groupwith != NULL) {
|
if (group != NULL) {
|
||||||
session_group_add(groupwith, s);
|
if (sg == NULL) {
|
||||||
|
if (groupwith != NULL) {
|
||||||
|
sg = session_group_new(groupwith->name);
|
||||||
|
session_group_add(sg, groupwith);
|
||||||
|
} else
|
||||||
|
sg = session_group_new(group);
|
||||||
|
}
|
||||||
|
session_group_add(sg, s);
|
||||||
session_group_synchronize_to(s);
|
session_group_synchronize_to(s);
|
||||||
session_select(s, RB_ROOT(&s->windows)->idx);
|
session_select(s, RB_MIN(winlinks, &s->windows)->idx);
|
||||||
}
|
}
|
||||||
|
notify_session("session-created", s);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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 (!already_attached)
|
if (!already_attached) {
|
||||||
server_write_ready(c);
|
if (~c->flags & CLIENT_CONTROL)
|
||||||
else if (c->session != NULL)
|
proc_send(c->peer, MSG_READY, -1, NULL, 0);
|
||||||
|
} else if (c->session != NULL)
|
||||||
c->last_session = c->session;
|
c->last_session = c->session;
|
||||||
c->session = s;
|
c->session = s;
|
||||||
notify_attached_session_changed(c);
|
if (!item->repeat)
|
||||||
session_update_activity(s);
|
server_client_set_key_table(c, NULL);
|
||||||
|
status_timer_start(c);
|
||||||
|
notify_client("client-session-changed", c);
|
||||||
|
session_update_activity(s, NULL);
|
||||||
|
gettimeofday(&s->last_attached_time, NULL);
|
||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
@@ -238,20 +319,24 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = NEW_SESSION_TEMPLATE;
|
template = NEW_SESSION_TEMPLATE;
|
||||||
|
cp = format_single(item, template, c, s, NULL, NULL);
|
||||||
ft = format_create();
|
cmdq_print(item, "%s", cp);
|
||||||
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
|
||||||
format_client(ft, c);
|
|
||||||
format_session(ft, s);
|
|
||||||
|
|
||||||
cp = format_expand(ft, template);
|
|
||||||
cmdq_print(cmdq, "%s", cp);
|
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
format_free(ft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!detached)
|
if (!detached)
|
||||||
cmdq->client_exit = 0;
|
c->flags |= CLIENT_ATTACHED;
|
||||||
|
|
||||||
|
if (to_free != NULL)
|
||||||
|
free((void *)to_free);
|
||||||
|
|
||||||
|
cmd_find_from_session(&fs, s);
|
||||||
|
hooks_insert(s->hooks, item, &fs, "after-new-session");
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (to_free != NULL)
|
||||||
|
free((void *)to_free);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
148
cmd-new-window.c
148
cmd-new-window.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -18,7 +18,11 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,59 +30,77 @@
|
|||||||
* Create a new window.
|
* Create a new window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_new_window_exec(struct cmd *, struct cmd_q *);
|
#define NEW_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_new_window_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_new_window_entry = {
|
const struct cmd_entry cmd_new_window_entry = {
|
||||||
"new-window", "neww",
|
.name = "new-window",
|
||||||
"ac:dF:kn:Pt:", 0, 1,
|
.alias = "neww",
|
||||||
"[-adkP] [-c start-directory] [-F format] [-n window-name] "
|
|
||||||
CMD_TARGET_WINDOW_USAGE " [command]",
|
.args = { "ac:dF:kn:Pt:", 0, -1 },
|
||||||
0,
|
.usage = "[-adkP] [-c start-directory] [-F format] [-n window-name] "
|
||||||
NULL,
|
CMD_TARGET_WINDOW_USAGE " [command]",
|
||||||
NULL,
|
|
||||||
cmd_new_window_exec
|
.tflag = CMD_WINDOW_INDEX,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_new_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s = item->state.tflag.s;
|
||||||
struct winlink *wl;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct client *c;
|
struct client *c = item->state.c;
|
||||||
const char *cmd, *cwd, *template;
|
int idx = item->state.tflag.idx;
|
||||||
char *cause, *cp;
|
const char *cmd, *path, *template, *cwd, *to_free;
|
||||||
int idx, last, detached;
|
char **argv, *cause, *cp;
|
||||||
struct format_tree *ft;
|
int argc, detached;
|
||||||
|
struct environ_entry *envent;
|
||||||
|
struct cmd_find_state fs;
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
wl = cmd_find_window(cmdq, args_get(args, 't'), &s);
|
if ((idx = winlink_shuffle_up(s, wl)) == -1) {
|
||||||
if (wl == NULL)
|
cmdq_error(item, "no free window indexes");
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
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) {
|
|
||||||
cmdq_error(cmdq, "no free window indexes");
|
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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(cmdq, args_get(args, 't'), &s)) == -2)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
}
|
||||||
detached = args_has(args, 'd');
|
detached = args_has(args, 'd');
|
||||||
|
|
||||||
|
if (args->argc == 0) {
|
||||||
|
cmd = options_get_string(s->options, "default-command");
|
||||||
|
if (cmd != NULL && *cmd != '\0') {
|
||||||
|
argc = 1;
|
||||||
|
argv = (char **)&cmd;
|
||||||
|
} else {
|
||||||
|
argc = 0;
|
||||||
|
argv = NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
argc = args->argc;
|
||||||
|
argv = args->argv;
|
||||||
|
}
|
||||||
|
|
||||||
|
path = NULL;
|
||||||
|
if (item->client != NULL && item->client->session == NULL)
|
||||||
|
envent = environ_find(item->client->environ, "PATH");
|
||||||
|
else
|
||||||
|
envent = environ_find(s->environ, "PATH");
|
||||||
|
if (envent != NULL)
|
||||||
|
path = envent->value;
|
||||||
|
|
||||||
|
to_free = NULL;
|
||||||
|
if (args_has(args, 'c')) {
|
||||||
|
cwd = args_get(args, 'c');
|
||||||
|
to_free = cwd = format_single(item, cwd, c, s, NULL, NULL);
|
||||||
|
} else if (item->client != NULL && item->client->session == NULL)
|
||||||
|
cwd = item->client->cwd;
|
||||||
|
else
|
||||||
|
cwd = s->cwd;
|
||||||
|
|
||||||
wl = NULL;
|
wl = NULL;
|
||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
wl = winlink_find_by_index(&s->windows, idx);
|
wl = winlink_find_by_index(&s->windows, idx);
|
||||||
@@ -87,7 +109,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
* Can't use session_detach as it will destroy session if this
|
* Can't use session_detach as it will destroy session if this
|
||||||
* makes it empty.
|
* makes it empty.
|
||||||
*/
|
*/
|
||||||
notify_window_unlinked(s, wl->window);
|
notify_session_window("window-unlinked", s, wl->window);
|
||||||
wl->flags &= ~WINLINK_ALERTFLAGS;
|
wl->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
winlink_stack_remove(&s->lastw, wl);
|
winlink_stack_remove(&s->lastw, wl);
|
||||||
winlink_remove(&s->windows, wl);
|
winlink_remove(&s->windows, wl);
|
||||||
@@ -99,19 +121,14 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc == 0)
|
|
||||||
cmd = options_get_string(&s->options, "default-command");
|
|
||||||
else
|
|
||||||
cmd = args->argv[0];
|
|
||||||
cwd = cmd_get_default_path(cmdq, args_get(args, 'c'));
|
|
||||||
|
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
idx = -1 - options_get_number(&s->options, "base-index");
|
idx = -1 - options_get_number(s->options, "base-index");
|
||||||
wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause);
|
wl = session_new(s, args_get(args, 'n'), argc, argv, path, cwd, idx,
|
||||||
|
&cause);
|
||||||
if (wl == NULL) {
|
if (wl == NULL) {
|
||||||
cmdq_error(cmdq, "create window failed: %s", cause);
|
cmdq_error(item, "create window failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
goto error;
|
||||||
}
|
}
|
||||||
if (!detached) {
|
if (!detached) {
|
||||||
session_select(s, wl->idx);
|
session_select(s, wl->idx);
|
||||||
@@ -122,20 +139,21 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = NEW_WINDOW_TEMPLATE;
|
template = NEW_WINDOW_TEMPLATE;
|
||||||
|
cp = format_single(item, template, c, s, wl, NULL);
|
||||||
ft = format_create();
|
cmdq_print(item, "%s", cp);
|
||||||
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
|
||||||
format_client(ft, c);
|
|
||||||
format_session(ft, s);
|
|
||||||
format_winlink(ft, s, wl);
|
|
||||||
format_window_pane(ft, wl->window->active);
|
|
||||||
|
|
||||||
cp = format_expand(ft, template);
|
|
||||||
cmdq_print(cmdq, "%s", cp);
|
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
format_free(ft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (to_free != NULL)
|
||||||
|
free((void *)to_free);
|
||||||
|
|
||||||
|
cmd_find_from_winlink(&fs, s, wl);
|
||||||
|
hooks_insert(s->hooks, item, &fs, "after-new-window");
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (to_free != NULL)
|
||||||
|
free((void *)to_free);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,58 +27,47 @@
|
|||||||
* Paste paste buffer if present.
|
* Paste paste buffer if present.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_paste_buffer_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_paste_buffer_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
void cmd_paste_buffer_filter(struct window_pane *,
|
|
||||||
const char *, size_t, const char *, int);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_paste_buffer_entry = {
|
const struct cmd_entry cmd_paste_buffer_entry = {
|
||||||
"paste-buffer", "pasteb",
|
.name = "paste-buffer",
|
||||||
"db:prs:t:", 0, 0,
|
.alias = "pasteb",
|
||||||
"[-dpr] [-s separator] [-b buffer-index] " CMD_TARGET_PANE_USAGE,
|
|
||||||
0,
|
.args = { "db:prs:t:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-dpr] [-s separator] " CMD_BUFFER_USAGE " "
|
||||||
NULL,
|
CMD_TARGET_PANE_USAGE,
|
||||||
cmd_paste_buffer_exec
|
|
||||||
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_paste_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
struct session *s;
|
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
const char *sepstr;
|
const char *sepstr, *bufname, *bufdata, *bufend, *line;
|
||||||
char *cause;
|
size_t seplen, bufsize;
|
||||||
int buffer;
|
int bracket = args_has(args, 'p');
|
||||||
int pflag;
|
|
||||||
|
|
||||||
if (cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp) == NULL)
|
bufname = NULL;
|
||||||
return (CMD_RETURN_ERROR);
|
if (args_has(args, 'b'))
|
||||||
|
bufname = args_get(args, 'b');
|
||||||
|
|
||||||
if (!args_has(args, 'b'))
|
if (bufname == NULL)
|
||||||
buffer = -1;
|
pb = paste_get_top(NULL);
|
||||||
else {
|
else {
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
pb = paste_get_name(bufname);
|
||||||
if (cause != NULL) {
|
|
||||||
cmdq_error(cmdq, "buffer %s", cause);
|
|
||||||
free(cause);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer == -1)
|
|
||||||
pb = paste_get_top(&global_buffers);
|
|
||||||
else {
|
|
||||||
pb = paste_get_index(&global_buffers, buffer);
|
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
cmdq_error(cmdq, "no buffer %d", buffer);
|
cmdq_error(item, "no buffer %s", bufname);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb != NULL) {
|
if (pb != NULL && ~wp->flags & PANE_INPUTOFF) {
|
||||||
sepstr = args_get(args, 's');
|
sepstr = args_get(args, 's');
|
||||||
if (sepstr == NULL) {
|
if (sepstr == NULL) {
|
||||||
if (args_has(args, 'r'))
|
if (args_has(args, 'r'))
|
||||||
@@ -86,17 +75,33 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
else
|
else
|
||||||
sepstr = "\r";
|
sepstr = "\r";
|
||||||
}
|
}
|
||||||
pflag = (wp->screen->mode & MODE_BRACKETPASTE);
|
seplen = strlen(sepstr);
|
||||||
paste_send_pane(pb, wp, sepstr, args_has(args, 'p') && pflag);
|
|
||||||
|
if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
|
||||||
|
bufferevent_write(wp->event, "\033[200~", 6);
|
||||||
|
|
||||||
|
bufdata = paste_buffer_data(pb, &bufsize);
|
||||||
|
bufend = bufdata + bufsize;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
line = memchr(bufdata, '\n', bufend - bufdata);
|
||||||
|
if (line == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
bufferevent_write(wp->event, bufdata, line - bufdata);
|
||||||
|
bufferevent_write(wp->event, sepstr, seplen);
|
||||||
|
|
||||||
|
bufdata = line + 1;
|
||||||
|
}
|
||||||
|
if (bufdata != bufend)
|
||||||
|
bufferevent_write(wp->event, bufdata, bufend - bufdata);
|
||||||
|
|
||||||
|
if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
|
||||||
|
bufferevent_write(wp->event, "\033[201~", 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete the buffer if -d. */
|
if (pb != NULL && args_has(args, 'd'))
|
||||||
if (args_has(args, 'd')) {
|
paste_free(pb);
|
||||||
if (buffer == -1)
|
|
||||||
paste_free_top(&global_buffers);
|
|
||||||
else
|
|
||||||
paste_free_index(&global_buffers, buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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,6 +21,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -31,32 +32,34 @@
|
|||||||
* Open pipe to redirect pane output. If already open, close first.
|
* Open pipe to redirect pane output. If already open, close first.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
|
static void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_pipe_pane_entry = {
|
const struct cmd_entry cmd_pipe_pane_entry = {
|
||||||
"pipe-pane", "pipep",
|
.name = "pipe-pane",
|
||||||
"ot:", 0, 1,
|
.alias = "pipep",
|
||||||
"[-o] " CMD_TARGET_PANE_USAGE " [command]",
|
|
||||||
0,
|
.args = { "ot:", 0, 1 },
|
||||||
NULL,
|
.usage = "[-o] " CMD_TARGET_PANE_USAGE " [command]",
|
||||||
NULL,
|
|
||||||
cmd_pipe_pane_exec
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_pipe_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c = item->state.c;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
char *command;
|
struct session *s = item->state.tflag.s;
|
||||||
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
|
char *cmd;
|
||||||
int old_fd, pipe_fd[2], null_fd;
|
int old_fd, pipe_fd[2], null_fd;
|
||||||
|
struct format_tree *ft;
|
||||||
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
c = cmd_find_client(cmdq, NULL, 1);
|
|
||||||
|
|
||||||
/* Destroy the old pipe. */
|
/* Destroy the old pipe. */
|
||||||
old_fd = wp->pipe_fd;
|
old_fd = wp->pipe_fd;
|
||||||
@@ -81,14 +84,22 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
|
|
||||||
/* Open the new pipe. */
|
/* Open the new pipe. */
|
||||||
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_fd) != 0) {
|
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_fd) != 0) {
|
||||||
cmdq_error(cmdq, "socketpair error: %s", strerror(errno));
|
cmdq_error(item, "socketpair error: %s", strerror(errno));
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Expand the command. */
|
||||||
|
ft = format_create(item, FORMAT_NONE, 0);
|
||||||
|
format_defaults(ft, c, s, wl, wp);
|
||||||
|
cmd = format_expand_time(ft, args->argv[0], time(NULL));
|
||||||
|
format_free(ft);
|
||||||
|
|
||||||
/* Fork the child. */
|
/* Fork the child. */
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
cmdq_error(cmdq, "fork error: %s", strerror(errno));
|
cmdq_error(item, "fork error: %s", strerror(errno));
|
||||||
|
|
||||||
|
free(cmd);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
case 0:
|
case 0:
|
||||||
/* Child process. */
|
/* Child process. */
|
||||||
@@ -110,9 +121,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
|
|
||||||
closefrom(STDERR_FILENO + 1);
|
closefrom(STDERR_FILENO + 1);
|
||||||
|
|
||||||
command = status_replace(
|
execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);
|
||||||
c, NULL, NULL, NULL, args->argv[0], time(NULL), 0);
|
|
||||||
execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL);
|
|
||||||
_exit(1);
|
_exit(1);
|
||||||
default:
|
default:
|
||||||
/* Parent process. */
|
/* Parent process. */
|
||||||
@@ -126,13 +135,15 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
||||||
|
|
||||||
setblocking(wp->pipe_fd, 0);
|
setblocking(wp->pipe_fd, 0);
|
||||||
|
|
||||||
|
free(cmd);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_pipe_pane_error_callback(
|
cmd_pipe_pane_error_callback(__unused struct bufferevent *bufev,
|
||||||
unused struct bufferevent *bufev, unused short what, void *data)
|
__unused short what, void *data)
|
||||||
{
|
{
|
||||||
struct window_pane *wp = data;
|
struct window_pane *wp = data;
|
||||||
|
|
||||||
|
|||||||
579
cmd-queue.c
579
cmd-queue.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -20,61 +20,381 @@
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/* Create new command queue. */
|
/* Global command queue. */
|
||||||
struct cmd_q *
|
static struct cmdq_list global_queue = TAILQ_HEAD_INITIALIZER(global_queue);
|
||||||
cmdq_new(struct client *c)
|
|
||||||
|
/* Get command queue name. */
|
||||||
|
static const char *
|
||||||
|
cmdq_name(struct client *c)
|
||||||
{
|
{
|
||||||
struct cmd_q *cmdq;
|
static char s[32];
|
||||||
|
|
||||||
cmdq = xcalloc(1, sizeof *cmdq);
|
if (c == NULL)
|
||||||
cmdq->references = 1;
|
return ("<global>");
|
||||||
cmdq->dead = 0;
|
xsnprintf(s, sizeof s, "<%p>", c);
|
||||||
|
return (s);
|
||||||
cmdq->client = c;
|
|
||||||
cmdq->client_exit = 0;
|
|
||||||
|
|
||||||
TAILQ_INIT(&cmdq->queue);
|
|
||||||
cmdq->item = NULL;
|
|
||||||
cmdq->cmd = NULL;
|
|
||||||
|
|
||||||
return (cmdq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free command queue */
|
/* Get command queue from client. */
|
||||||
int
|
static struct cmdq_list *
|
||||||
cmdq_free(struct cmd_q *cmdq)
|
cmdq_get(struct client *c)
|
||||||
{
|
{
|
||||||
if (--cmdq->references != 0)
|
if (c == NULL)
|
||||||
return (cmdq->dead);
|
return (&global_queue);
|
||||||
|
return (&c->queue);
|
||||||
|
}
|
||||||
|
|
||||||
cmdq_flush(cmdq);
|
/* Append an item. */
|
||||||
free(cmdq);
|
void
|
||||||
return (1);
|
cmdq_append(struct client *c, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct cmdq_list *queue = cmdq_get(c);
|
||||||
|
struct cmdq_item *next;
|
||||||
|
|
||||||
|
do {
|
||||||
|
next = item->next;
|
||||||
|
item->next = NULL;
|
||||||
|
|
||||||
|
if (c != NULL)
|
||||||
|
c->references++;
|
||||||
|
item->client = c;
|
||||||
|
|
||||||
|
item->queue = queue;
|
||||||
|
TAILQ_INSERT_TAIL(queue, item, entry);
|
||||||
|
|
||||||
|
item = next;
|
||||||
|
} while (item != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Insert an item. */
|
||||||
|
void
|
||||||
|
cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct client *c = after->client;
|
||||||
|
struct cmdq_list *queue = after->queue;
|
||||||
|
struct cmdq_item *next;
|
||||||
|
|
||||||
|
do {
|
||||||
|
next = item->next;
|
||||||
|
item->next = NULL;
|
||||||
|
|
||||||
|
if (c != NULL)
|
||||||
|
c->references++;
|
||||||
|
item->client = c;
|
||||||
|
|
||||||
|
item->queue = queue;
|
||||||
|
if (after->next != NULL)
|
||||||
|
TAILQ_INSERT_AFTER(queue, after->next, item, entry);
|
||||||
|
else
|
||||||
|
TAILQ_INSERT_AFTER(queue, after, item, entry);
|
||||||
|
after->next = item;
|
||||||
|
|
||||||
|
item = next;
|
||||||
|
} while (item != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove an item. */
|
||||||
|
static void
|
||||||
|
cmdq_remove(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
if (item->formats != NULL)
|
||||||
|
format_free(item->formats);
|
||||||
|
|
||||||
|
if (item->client != NULL)
|
||||||
|
server_client_unref(item->client);
|
||||||
|
|
||||||
|
if (item->type == CMDQ_COMMAND)
|
||||||
|
cmd_list_free(item->cmdlist);
|
||||||
|
|
||||||
|
TAILQ_REMOVE(item->queue, item, entry);
|
||||||
|
|
||||||
|
free((void *)item->name);
|
||||||
|
free(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set command group. */
|
||||||
|
static u_int
|
||||||
|
cmdq_next_group(void)
|
||||||
|
{
|
||||||
|
static u_int group;
|
||||||
|
|
||||||
|
return (++group);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove all subsequent items that match this item's group. */
|
||||||
|
static void
|
||||||
|
cmdq_remove_group(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct cmdq_item *this, *next;
|
||||||
|
|
||||||
|
this = TAILQ_NEXT(item, entry);
|
||||||
|
while (this != NULL) {
|
||||||
|
next = TAILQ_NEXT(this, entry);
|
||||||
|
if (this->group == item->group)
|
||||||
|
cmdq_remove(this);
|
||||||
|
this = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get a command for the command queue. */
|
||||||
|
struct cmdq_item *
|
||||||
|
cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
|
||||||
|
struct mouse_event *m, int flags)
|
||||||
|
{
|
||||||
|
struct cmdq_item *item, *first = NULL, *last = NULL;
|
||||||
|
struct cmd *cmd;
|
||||||
|
u_int group = cmdq_next_group();
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||||
|
xasprintf(&tmp, "command[%s]", cmd->entry->name);
|
||||||
|
|
||||||
|
item = xcalloc(1, sizeof *item);
|
||||||
|
item->name = tmp;
|
||||||
|
item->type = CMDQ_COMMAND;
|
||||||
|
|
||||||
|
item->group = group;
|
||||||
|
item->flags = flags;
|
||||||
|
|
||||||
|
item->cmdlist = cmdlist;
|
||||||
|
item->cmd = cmd;
|
||||||
|
|
||||||
|
if (current != NULL)
|
||||||
|
cmd_find_copy_state(&item->current, current);
|
||||||
|
if (m != NULL)
|
||||||
|
memcpy(&item->mouse, m, sizeof item->mouse);
|
||||||
|
cmdlist->references++;
|
||||||
|
|
||||||
|
if (first == NULL)
|
||||||
|
first = item;
|
||||||
|
if (last != NULL)
|
||||||
|
last->next = item;
|
||||||
|
last = item;
|
||||||
|
}
|
||||||
|
return (first);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fire command on command queue. */
|
||||||
|
static enum cmd_retval
|
||||||
|
cmdq_fire_command(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct client *c = item->client;
|
||||||
|
struct cmd *cmd = item->cmd;
|
||||||
|
enum cmd_retval retval;
|
||||||
|
const char *name;
|
||||||
|
struct cmd_find_state *fsp, fs;
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
flags = !!(cmd->flags & CMD_CONTROL);
|
||||||
|
cmdq_guard(item, "begin", flags);
|
||||||
|
|
||||||
|
if (cmd_prepare_state(cmd, item) != 0) {
|
||||||
|
retval = CMD_RETURN_ERROR;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (item->client == NULL)
|
||||||
|
item->client = cmd_find_client(item, NULL, CMD_FIND_QUIET);
|
||||||
|
|
||||||
|
retval = cmd->entry->exec(cmd, item);
|
||||||
|
if (retval == CMD_RETURN_ERROR)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (cmd->entry->flags & CMD_AFTERHOOK) {
|
||||||
|
name = cmd->entry->name;
|
||||||
|
if (cmd_find_valid_state(&item->state.tflag))
|
||||||
|
fsp = &item->state.tflag;
|
||||||
|
else {
|
||||||
|
if (cmd_find_current(&fs, item, CMD_FIND_QUIET) != 0)
|
||||||
|
goto out;
|
||||||
|
fsp = &fs;
|
||||||
|
}
|
||||||
|
hooks_insert(fsp->s->hooks, item, fsp, "after-%s", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
item->client = c;
|
||||||
|
if (retval == CMD_RETURN_ERROR)
|
||||||
|
cmdq_guard(item, "error", flags);
|
||||||
|
else
|
||||||
|
cmdq_guard(item, "end", flags);
|
||||||
|
return (retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get a callback for the command queue. */
|
||||||
|
struct cmdq_item *
|
||||||
|
cmdq_get_callback1(const char *name, cmdq_cb cb, void *data)
|
||||||
|
{
|
||||||
|
struct cmdq_item *item;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
|
xasprintf(&tmp, "callback[%s]", name);
|
||||||
|
|
||||||
|
item = xcalloc(1, sizeof *item);
|
||||||
|
item->name = tmp;
|
||||||
|
item->type = CMDQ_CALLBACK;
|
||||||
|
|
||||||
|
item->group = 0;
|
||||||
|
item->flags = 0;
|
||||||
|
|
||||||
|
item->cb = cb;
|
||||||
|
item->data = data;
|
||||||
|
|
||||||
|
return (item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fire callback on callback queue. */
|
||||||
|
static enum cmd_retval
|
||||||
|
cmdq_fire_callback(struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
return (item->cb(item, item->data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add a format to command queue. */
|
||||||
|
void
|
||||||
|
cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
struct cmdq_item *loop;
|
||||||
|
char *value;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
xvasprintf(&value, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
for (loop = item; loop != NULL; loop = item->next) {
|
||||||
|
if (loop->formats == NULL)
|
||||||
|
loop->formats = format_create(NULL, FORMAT_NONE, 0);
|
||||||
|
format_add(loop->formats, key, "%s", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Process next item on command queue. */
|
||||||
|
u_int
|
||||||
|
cmdq_next(struct client *c)
|
||||||
|
{
|
||||||
|
struct cmdq_list *queue = cmdq_get(c);
|
||||||
|
const char *name = cmdq_name(c);
|
||||||
|
struct cmdq_item *item;
|
||||||
|
enum cmd_retval retval;
|
||||||
|
u_int items = 0;
|
||||||
|
static u_int number;
|
||||||
|
|
||||||
|
if (TAILQ_EMPTY(queue)) {
|
||||||
|
log_debug("%s %s: empty", __func__, name);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
if (TAILQ_FIRST(queue)->flags & CMDQ_WAITING) {
|
||||||
|
log_debug("%s %s: waiting", __func__, name);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
log_debug("%s %s: enter", __func__, name);
|
||||||
|
for (;;) {
|
||||||
|
item = TAILQ_FIRST(queue);
|
||||||
|
if (item == NULL)
|
||||||
|
break;
|
||||||
|
log_debug("%s %s: %s (%d), flags %x", __func__, name,
|
||||||
|
item->name, item->type, item->flags);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Any item with the waiting flag set waits until an external
|
||||||
|
* event clears the flag (for example, a job - look at
|
||||||
|
* run-shell).
|
||||||
|
*/
|
||||||
|
if (item->flags & CMDQ_WAITING)
|
||||||
|
goto waiting;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Items are only fired once, once the fired flag is set, a
|
||||||
|
* waiting flag can only be cleared by an external event.
|
||||||
|
*/
|
||||||
|
if (~item->flags & CMDQ_FIRED) {
|
||||||
|
item->time = time(NULL);
|
||||||
|
item->number = ++number;
|
||||||
|
|
||||||
|
switch (item->type)
|
||||||
|
{
|
||||||
|
case CMDQ_COMMAND:
|
||||||
|
retval = cmdq_fire_command(item);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If a command returns an error, remove any
|
||||||
|
* subsequent commands in the same group.
|
||||||
|
*/
|
||||||
|
if (retval == CMD_RETURN_ERROR)
|
||||||
|
cmdq_remove_group(item);
|
||||||
|
break;
|
||||||
|
case CMDQ_CALLBACK:
|
||||||
|
retval = cmdq_fire_callback(item);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
retval = CMD_RETURN_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
item->flags |= CMDQ_FIRED;
|
||||||
|
|
||||||
|
if (retval == CMD_RETURN_WAIT) {
|
||||||
|
item->flags |= CMDQ_WAITING;
|
||||||
|
goto waiting;
|
||||||
|
}
|
||||||
|
items++;
|
||||||
|
}
|
||||||
|
cmdq_remove(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
log_debug("%s %s: exit (empty)", __func__, name);
|
||||||
|
return (items);
|
||||||
|
|
||||||
|
waiting:
|
||||||
|
log_debug("%s %s: exit (wait)", __func__, name);
|
||||||
|
return (items);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print a guard line. */
|
||||||
|
void
|
||||||
|
cmdq_guard(struct cmdq_item *item, const char *guard, int flags)
|
||||||
|
{
|
||||||
|
struct client *c = item->client;
|
||||||
|
|
||||||
|
if (c == NULL || !(c->flags & CLIENT_CONTROL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u %d\n", guard,
|
||||||
|
(long)item->time, item->number, flags);
|
||||||
|
server_client_push_stdout(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show message from command. */
|
/* Show message from command. */
|
||||||
void printflike2
|
void
|
||||||
cmdq_print(struct cmd_q *cmdq, const char *fmt, ...)
|
cmdq_print(struct cmdq_item *item, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
struct client *c = cmdq->client;
|
struct client *c = item->client;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
char *tmp, *msg;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
/* nothing */;
|
/* nothing */;
|
||||||
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
||||||
va_start(ap, fmt);
|
if (~c->flags & CLIENT_UTF8) {
|
||||||
evbuffer_add_vprintf(c->stdout_data, fmt, ap);
|
xvasprintf(&tmp, fmt, ap);
|
||||||
va_end(ap);
|
msg = utf8_sanitize(tmp);
|
||||||
|
free(tmp);
|
||||||
|
evbuffer_add(c->stdout_data, msg, strlen(msg));
|
||||||
|
free(msg);
|
||||||
|
} else
|
||||||
|
evbuffer_add_vprintf(c->stdout_data, fmt, ap);
|
||||||
evbuffer_add(c->stdout_data, "\n", 1);
|
evbuffer_add(c->stdout_data, "\n", 1);
|
||||||
server_push_stdout(c);
|
server_client_push_stdout(c);
|
||||||
} else {
|
} else {
|
||||||
w = c->session->curw->window;
|
w = c->session->curw->window;
|
||||||
if (w->active->mode != &window_copy_mode) {
|
if (w->active->mode != &window_copy_mode) {
|
||||||
@@ -88,62 +408,34 @@ cmdq_print(struct cmd_q *cmdq, const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show info from command. */
|
/* Show error from command. */
|
||||||
void printflike2
|
void
|
||||||
cmdq_info(struct cmd_q *cmdq, const char *fmt, ...)
|
cmdq_error(struct cmdq_item *item, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
struct client *c = cmdq->client;
|
struct client *c = item->client;
|
||||||
|
struct cmd *cmd = item->cmd;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
if (options_get_number(&global_options, "quiet"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
|
|
||||||
if (c == NULL)
|
|
||||||
/* nothing */;
|
|
||||||
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
|
||||||
va_start(ap, fmt);
|
|
||||||
evbuffer_add_vprintf(c->stdout_data, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
evbuffer_add(c->stdout_data, "\n", 1);
|
|
||||||
server_push_stdout(c);
|
|
||||||
} else {
|
|
||||||
xvasprintf(&msg, fmt, ap);
|
|
||||||
*msg = toupper((u_char) *msg);
|
|
||||||
status_message_set(c, "%s", msg);
|
|
||||||
free(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Show error from command. */
|
|
||||||
void printflike2
|
|
||||||
cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
struct client *c = cmdq->client;
|
|
||||||
struct cmd *cmd = cmdq->cmd;
|
|
||||||
va_list ap;
|
|
||||||
char *msg, *cause;
|
|
||||||
size_t msglen;
|
size_t msglen;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
msglen = xvasprintf(&msg, fmt, ap);
|
msglen = xvasprintf(&msg, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (c == NULL) {
|
if (c == NULL)
|
||||||
xasprintf(&cause, "%s:%u: %s", cmd->file, cmd->line, msg);
|
cfg_add_cause("%s:%u: %s", cmd->file, cmd->line, msg);
|
||||||
ARRAY_ADD(&cfg_causes, cause);
|
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
||||||
} else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
if (~c->flags & CLIENT_UTF8) {
|
||||||
|
tmp = msg;
|
||||||
|
msg = utf8_sanitize(tmp);
|
||||||
|
free(tmp);
|
||||||
|
msglen = strlen(msg);
|
||||||
|
}
|
||||||
evbuffer_add(c->stderr_data, msg, msglen);
|
evbuffer_add(c->stderr_data, msg, msglen);
|
||||||
evbuffer_add(c->stderr_data, "\n", 1);
|
evbuffer_add(c->stderr_data, "\n", 1);
|
||||||
|
server_client_push_stderr(c);
|
||||||
server_push_stderr(c);
|
c->retval = 1;
|
||||||
c->retcode = 1;
|
|
||||||
} else {
|
} else {
|
||||||
*msg = toupper((u_char) *msg);
|
*msg = toupper((u_char) *msg);
|
||||||
status_message_set(c, "%s", msg);
|
status_message_set(c, "%s", msg);
|
||||||
@@ -151,132 +443,3 @@ cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
|
|||||||
|
|
||||||
free(msg);
|
free(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print a guard line. */
|
|
||||||
int
|
|
||||||
cmdq_guard(struct cmd_q *cmdq, const char *guard)
|
|
||||||
{
|
|
||||||
struct client *c = cmdq->client;
|
|
||||||
|
|
||||||
if (c == NULL || c->session == NULL)
|
|
||||||
return 0;
|
|
||||||
if (!(c->flags & CLIENT_CONTROL))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u\n", guard,
|
|
||||||
(long) cmdq->time, cmdq->number);
|
|
||||||
server_push_stdout(c);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add command list to queue and begin processing if needed. */
|
|
||||||
void
|
|
||||||
cmdq_run(struct cmd_q *cmdq, struct cmd_list *cmdlist)
|
|
||||||
{
|
|
||||||
cmdq_append(cmdq, cmdlist);
|
|
||||||
|
|
||||||
if (cmdq->item == NULL) {
|
|
||||||
cmdq->cmd = NULL;
|
|
||||||
cmdq_continue(cmdq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add command list to queue. */
|
|
||||||
void
|
|
||||||
cmdq_append(struct cmd_q *cmdq, struct cmd_list *cmdlist)
|
|
||||||
{
|
|
||||||
struct cmd_q_item *item;
|
|
||||||
|
|
||||||
item = xcalloc(1, sizeof *item);
|
|
||||||
item->cmdlist = cmdlist;
|
|
||||||
TAILQ_INSERT_TAIL(&cmdq->queue, item, qentry);
|
|
||||||
cmdlist->references++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Continue processing command queue. Returns 1 if finishes empty. */
|
|
||||||
int
|
|
||||||
cmdq_continue(struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct cmd_q_item *next;
|
|
||||||
enum cmd_retval retval;
|
|
||||||
int empty, guard;
|
|
||||||
char s[1024];
|
|
||||||
|
|
||||||
notify_disable();
|
|
||||||
|
|
||||||
empty = TAILQ_EMPTY(&cmdq->queue);
|
|
||||||
if (empty)
|
|
||||||
goto empty;
|
|
||||||
|
|
||||||
if (cmdq->item == NULL) {
|
|
||||||
cmdq->item = TAILQ_FIRST(&cmdq->queue);
|
|
||||||
cmdq->cmd = TAILQ_FIRST(&cmdq->item->cmdlist->list);
|
|
||||||
} else
|
|
||||||
cmdq->cmd = TAILQ_NEXT(cmdq->cmd, qentry);
|
|
||||||
|
|
||||||
do {
|
|
||||||
next = TAILQ_NEXT(cmdq->item, qentry);
|
|
||||||
|
|
||||||
while (cmdq->cmd != NULL) {
|
|
||||||
cmd_print(cmdq->cmd, s, sizeof s);
|
|
||||||
log_debug("cmdq %p: %s (client %d)", cmdq, s,
|
|
||||||
cmdq->client != NULL ? cmdq->client->ibuf.fd : -1);
|
|
||||||
|
|
||||||
cmdq->time = time(NULL);
|
|
||||||
cmdq->number++;
|
|
||||||
|
|
||||||
guard = cmdq_guard(cmdq, "begin");
|
|
||||||
retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq);
|
|
||||||
if (guard) {
|
|
||||||
if (retval == CMD_RETURN_ERROR)
|
|
||||||
cmdq_guard(cmdq, "error");
|
|
||||||
else
|
|
||||||
cmdq_guard(cmdq, "end");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (retval == CMD_RETURN_ERROR)
|
|
||||||
break;
|
|
||||||
if (retval == CMD_RETURN_WAIT)
|
|
||||||
goto out;
|
|
||||||
if (retval == CMD_RETURN_STOP) {
|
|
||||||
cmdq_flush(cmdq);
|
|
||||||
goto empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmdq->cmd = TAILQ_NEXT(cmdq->cmd, qentry);
|
|
||||||
}
|
|
||||||
|
|
||||||
TAILQ_REMOVE(&cmdq->queue, cmdq->item, qentry);
|
|
||||||
cmd_list_free(cmdq->item->cmdlist);
|
|
||||||
free(cmdq->item);
|
|
||||||
|
|
||||||
cmdq->item = next;
|
|
||||||
if (cmdq->item != NULL)
|
|
||||||
cmdq->cmd = TAILQ_FIRST(&cmdq->item->cmdlist->list);
|
|
||||||
} while (cmdq->item != NULL);
|
|
||||||
|
|
||||||
empty:
|
|
||||||
if (cmdq->client_exit)
|
|
||||||
cmdq->client->flags |= CLIENT_EXIT;
|
|
||||||
if (cmdq->emptyfn != NULL)
|
|
||||||
cmdq->emptyfn(cmdq); /* may free cmdq */
|
|
||||||
empty = 1;
|
|
||||||
|
|
||||||
out:
|
|
||||||
notify_enable();
|
|
||||||
return (empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Flush command queue. */
|
|
||||||
void
|
|
||||||
cmdq_flush(struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct cmd_q_item *item, *item1;
|
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(item, &cmdq->queue, qentry, item1) {
|
|
||||||
TAILQ_REMOVE(&cmdq->queue, item, qentry);
|
|
||||||
cmd_list_free(item->cmdlist);
|
|
||||||
free(item);
|
|
||||||
}
|
|
||||||
cmdq->item = NULL;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -24,54 +24,57 @@
|
|||||||
* Refresh client.
|
* Refresh client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_refresh_client_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_refresh_client_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_refresh_client_entry = {
|
const struct cmd_entry cmd_refresh_client_entry = {
|
||||||
"refresh-client", "refresh",
|
.name = "refresh-client",
|
||||||
"C:St:", 0, 0,
|
.alias = "refresh",
|
||||||
"[-S] [-C size]" CMD_TARGET_CLIENT_USAGE,
|
|
||||||
0,
|
.args = { "C:St:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-S] [-C size] " CMD_TARGET_CLIENT_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_refresh_client_exec
|
.tflag = CMD_CLIENT,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_refresh_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_refresh_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c = item->state.c;
|
||||||
const char *size;
|
const char *size;
|
||||||
u_int w, h;
|
u_int w, h;
|
||||||
|
|
||||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (args_has(args, 'C')) {
|
if (args_has(args, 'C')) {
|
||||||
if ((size = args_get(args, 'C')) == NULL) {
|
if ((size = args_get(args, 'C')) == NULL) {
|
||||||
cmdq_error(cmdq, "missing size");
|
cmdq_error(item, "missing size");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (sscanf(size, "%u,%u", &w, &h) != 2) {
|
if (sscanf(size, "%u,%u", &w, &h) != 2) {
|
||||||
cmdq_error(cmdq, "bad size argument");
|
cmdq_error(item, "bad size argument");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (w < PANE_MINIMUM || w > 5000 ||
|
if (w < PANE_MINIMUM || w > 5000 ||
|
||||||
h < PANE_MINIMUM || h > 5000) {
|
h < PANE_MINIMUM || h > 5000) {
|
||||||
cmdq_error(cmdq, "size too small or too big");
|
cmdq_error(item, "size too small or too big");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (!(c->flags & CLIENT_CONTROL)) {
|
if (!(c->flags & CLIENT_CONTROL)) {
|
||||||
cmdq_error(cmdq, "not a control client");
|
cmdq_error(item, "not a control client");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (tty_set_size(&c->tty, w, h))
|
if (tty_set_size(&c->tty, w, h))
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
} else if (args_has(args, 'S')) {
|
} else if (args_has(args, 'S')) {
|
||||||
status_update_jobs(c);
|
c->flags |= CLIENT_STATUSFORCE;
|
||||||
server_status_client(c);
|
server_status_client(c);
|
||||||
} else
|
} else {
|
||||||
|
c->flags |= CLIENT_STATUSFORCE;
|
||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,45 +27,49 @@
|
|||||||
* Change session name.
|
* Change session name.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_rename_session_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_rename_session_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rename_session_entry = {
|
const struct cmd_entry cmd_rename_session_entry = {
|
||||||
"rename-session", "rename",
|
.name = "rename-session",
|
||||||
"t:", 1, 1,
|
.alias = "rename",
|
||||||
CMD_TARGET_SESSION_USAGE " new-name",
|
|
||||||
0,
|
.args = { "t:", 1, 1 },
|
||||||
NULL,
|
.usage = CMD_TARGET_SESSION_USAGE " new-name",
|
||||||
NULL,
|
|
||||||
cmd_rename_session_exec
|
.tflag = CMD_SESSION,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_rename_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_rename_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s = item->state.tflag.s;
|
||||||
const char *newname;
|
const char *newname;
|
||||||
|
|
||||||
newname = args->argv[0];
|
newname = args->argv[0];
|
||||||
|
if (strcmp(newname, s->name) == 0)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
if (!session_check_name(newname)) {
|
if (!session_check_name(newname)) {
|
||||||
cmdq_error(cmdq, "bad session name: %s", newname);
|
cmdq_error(item, "bad session name: %s", newname);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (session_find(newname) != NULL) {
|
if (session_find(newname) != NULL) {
|
||||||
cmdq_error(cmdq, "duplicate session: %s", newname);
|
cmdq_error(item, "duplicate session: %s", newname);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
RB_REMOVE(sessions, &sessions, s);
|
RB_REMOVE(sessions, &sessions, s);
|
||||||
free(s->name);
|
free(s->name);
|
||||||
s->name = xstrdup(newname);
|
s->name = xstrdup(newname);
|
||||||
RB_INSERT(sessions, &sessions, s);
|
RB_INSERT(sessions, &sessions, s);
|
||||||
|
|
||||||
server_status_session(s);
|
server_status_session(s);
|
||||||
notify_session_renamed(s);
|
notify_session("session-renamed", s);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -26,30 +26,30 @@
|
|||||||
* Rename a window.
|
* Rename a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_rename_window_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_rename_window_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rename_window_entry = {
|
const struct cmd_entry cmd_rename_window_entry = {
|
||||||
"rename-window", "renamew",
|
.name = "rename-window",
|
||||||
"t:", 1, 1,
|
.alias = "renamew",
|
||||||
CMD_TARGET_WINDOW_USAGE " new-name",
|
|
||||||
0,
|
.args = { "t:", 1, 1 },
|
||||||
NULL,
|
.usage = CMD_TARGET_WINDOW_USAGE " new-name",
|
||||||
NULL,
|
|
||||||
cmd_rename_window_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_rename_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_rename_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_rename_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct winlink *wl;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
window_set_name(wl->window, args->argv[0]);
|
window_set_name(wl->window, args->argv[0]);
|
||||||
options_set_number(&wl->window->options, "automatic-rename", 0);
|
options_set_number(wl->window->options, "automatic-rename", 0);
|
||||||
|
|
||||||
server_status_window(wl->window);
|
server_status_window(wl->window);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -26,80 +26,48 @@
|
|||||||
* Increase or decrease pane size.
|
* Increase or decrease pane size.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_resize_pane_key_binding(struct cmd *, int);
|
static enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
static void cmd_resize_pane_mouse_update(struct client *,
|
||||||
|
struct mouse_event *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_resize_pane_entry = {
|
const struct cmd_entry cmd_resize_pane_entry = {
|
||||||
"resize-pane", "resizep",
|
.name = "resize-pane",
|
||||||
"DLRt:Ux:y:Z", 0, 1,
|
.alias = "resizep",
|
||||||
"[-DLRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " [adjustment]",
|
|
||||||
0,
|
.args = { "DLMRt:Ux:y:Z", 0, 1 },
|
||||||
cmd_resize_pane_key_binding,
|
.usage = "[-DLMRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " "
|
||||||
NULL,
|
"[adjustment]",
|
||||||
cmd_resize_pane_exec
|
|
||||||
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_resize_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_resize_pane_key_binding(struct cmd *self, int key)
|
cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
|
||||||
switch (key) {
|
|
||||||
case KEYC_UP | KEYC_CTRL:
|
|
||||||
self->args = args_create(0);
|
|
||||||
args_set(self->args, 'U', NULL);
|
|
||||||
break;
|
|
||||||
case KEYC_DOWN | KEYC_CTRL:
|
|
||||||
self->args = args_create(0);
|
|
||||||
args_set(self->args, 'D', NULL);
|
|
||||||
break;
|
|
||||||
case KEYC_LEFT | KEYC_CTRL:
|
|
||||||
self->args = args_create(0);
|
|
||||||
args_set(self->args, 'L', NULL);
|
|
||||||
break;
|
|
||||||
case KEYC_RIGHT | KEYC_CTRL:
|
|
||||||
self->args = args_create(0);
|
|
||||||
args_set(self->args, 'R', NULL);
|
|
||||||
break;
|
|
||||||
case KEYC_UP | KEYC_ESCAPE:
|
|
||||||
self->args = args_create(1, "5");
|
|
||||||
args_set(self->args, 'U', NULL);
|
|
||||||
break;
|
|
||||||
case KEYC_DOWN | KEYC_ESCAPE:
|
|
||||||
self->args = args_create(1, "5");
|
|
||||||
args_set(self->args, 'D', NULL);
|
|
||||||
break;
|
|
||||||
case KEYC_LEFT | KEYC_ESCAPE:
|
|
||||||
self->args = args_create(1, "5");
|
|
||||||
args_set(self->args, 'L', NULL);
|
|
||||||
break;
|
|
||||||
case KEYC_RIGHT | KEYC_ESCAPE:
|
|
||||||
self->args = args_create(1, "5");
|
|
||||||
args_set(self->args, 'R', NULL);
|
|
||||||
break;
|
|
||||||
case 'z':
|
|
||||||
self->args = args_create(0);
|
|
||||||
args_set(self->args, 'Z', NULL);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
self->args = args_create(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
struct window *w;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
|
struct window *w = wl->window;
|
||||||
|
struct client *c = item->client;
|
||||||
|
struct session *s = item->state.tflag.s;
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
char *cause;
|
char *cause;
|
||||||
struct window_pane *wp;
|
|
||||||
u_int adjust;
|
u_int adjust;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
|
if (args_has(args, 'M')) {
|
||||||
return (CMD_RETURN_ERROR);
|
if (cmd_mouse_window(&item->mouse, &s) == NULL)
|
||||||
w = wl->window;
|
return (CMD_RETURN_NORMAL);
|
||||||
|
if (c == NULL || c->session != s)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
c->tty.mouse_drag_update = cmd_resize_pane_mouse_update;
|
||||||
|
cmd_resize_pane_mouse_update(c, &item->mouse);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (args_has(args, 'Z')) {
|
if (args_has(args, 'Z')) {
|
||||||
if (w->flags & WINDOW_ZOOMED)
|
if (w->flags & WINDOW_ZOOMED)
|
||||||
@@ -117,7 +85,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
else {
|
else {
|
||||||
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
cmdq_error(cmdq, "adjustment %s", errstr);
|
cmdq_error(item, "adjustment %s", errstr);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +94,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
x = args_strtonum(self->args, 'x', PANE_MINIMUM, INT_MAX,
|
x = args_strtonum(self->args, 'x', PANE_MINIMUM, INT_MAX,
|
||||||
&cause);
|
&cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
cmdq_error(cmdq, "width %s", cause);
|
cmdq_error(item, "width %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
@@ -136,7 +104,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
y = args_strtonum(self->args, 'y', PANE_MINIMUM, INT_MAX,
|
y = args_strtonum(self->args, 'y', PANE_MINIMUM, INT_MAX,
|
||||||
&cause);
|
&cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
cmdq_error(cmdq, "height %s", cause);
|
cmdq_error(item, "height %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
@@ -144,14 +112,63 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'L'))
|
if (args_has(self->args, 'L'))
|
||||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust, 1);
|
||||||
else if (args_has(self->args, 'R'))
|
else if (args_has(self->args, 'R'))
|
||||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust);
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust, 1);
|
||||||
else if (args_has(self->args, 'U'))
|
else if (args_has(self->args, 'U'))
|
||||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust);
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust, 1);
|
||||||
else if (args_has(self->args, 'D'))
|
else if (args_has(self->args, 'D'))
|
||||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust, 1);
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m)
|
||||||
|
{
|
||||||
|
struct winlink *wl;
|
||||||
|
struct window_pane *wp;
|
||||||
|
int found;
|
||||||
|
u_int y, ly;
|
||||||
|
|
||||||
|
wl = cmd_mouse_window(m, NULL);
|
||||||
|
if (wl == NULL) {
|
||||||
|
c->tty.mouse_drag_update = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
y = m->y;
|
||||||
|
if (m->statusat == 0 && y > 0)
|
||||||
|
y--;
|
||||||
|
else if (m->statusat > 0 && y >= (u_int)m->statusat)
|
||||||
|
y = m->statusat - 1;
|
||||||
|
ly = m->ly;
|
||||||
|
if (m->statusat == 0 && ly > 0)
|
||||||
|
ly--;
|
||||||
|
else if (m->statusat > 0 && ly >= (u_int)m->statusat)
|
||||||
|
ly = m->statusat - 1;
|
||||||
|
|
||||||
|
found = 0;
|
||||||
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||||
|
if (!window_pane_visible(wp))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (wp->xoff + wp->sx == m->lx &&
|
||||||
|
wp->yoff <= 1 + ly &&
|
||||||
|
wp->yoff + wp->sy >= ly) {
|
||||||
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, m->x - m->lx, 0);
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
if (wp->yoff + wp->sy == ly &&
|
||||||
|
wp->xoff <= 1 + m->lx &&
|
||||||
|
wp->xoff + wp->sx >= m->lx) {
|
||||||
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, y - ly, 0);
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found)
|
||||||
|
server_redraw_window(wl->window);
|
||||||
|
else
|
||||||
|
c->tty.mouse_drag_update = NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
* Copyright (c) 2011 Marcel P. Partap <mpartap@gmx.net>
|
* Copyright (c) 2011 Marcel P. Partap <mpartap@gmx.net>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
@@ -28,65 +28,67 @@
|
|||||||
* Respawn a pane (restart the command). Kill existing if -k given.
|
* Respawn a pane (restart the command). Kill existing if -k given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_respawn_pane_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_respawn_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_respawn_pane_entry = {
|
const struct cmd_entry cmd_respawn_pane_entry = {
|
||||||
"respawn-pane", "respawnp",
|
.name = "respawn-pane",
|
||||||
"kt:", 0, 1,
|
.alias = "respawnp",
|
||||||
"[-k] " CMD_TARGET_PANE_USAGE " [command]",
|
|
||||||
0,
|
.args = { "kt:", 0, -1 },
|
||||||
NULL,
|
.usage = "[-k] " CMD_TARGET_PANE_USAGE " [command]",
|
||||||
NULL,
|
|
||||||
cmd_respawn_pane_exec
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_respawn_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct window *w;
|
struct window *w = wl->window;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
struct session *s;
|
struct session *s = item->state.tflag.s;
|
||||||
struct environ env;
|
struct environ *env;
|
||||||
const char *cmd;
|
const char *path;
|
||||||
char *cause;
|
char *cause;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
|
struct environ_entry *envent;
|
||||||
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
w = wl->window;
|
|
||||||
|
|
||||||
if (!args_has(self->args, 'k') && wp->fd != -1) {
|
if (!args_has(self->args, 'k') && wp->fd != -1) {
|
||||||
if (window_pane_index(wp, &idx) != 0)
|
if (window_pane_index(wp, &idx) != 0)
|
||||||
fatalx("index not found");
|
fatalx("index not found");
|
||||||
cmdq_error(cmdq, "pane still active: %s:%u.%u",
|
cmdq_error(item, "pane still active: %s:%d.%u",
|
||||||
s->name, wl->idx, idx);
|
s->name, wl->idx, idx);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
environ_init(&env);
|
|
||||||
environ_copy(&global_environ, &env);
|
|
||||||
environ_copy(&s->environ, &env);
|
|
||||||
server_fill_environ(s, &env);
|
|
||||||
|
|
||||||
window_pane_reset_mode(wp);
|
window_pane_reset_mode(wp);
|
||||||
screen_reinit(&wp->base);
|
screen_reinit(&wp->base);
|
||||||
input_init(wp);
|
input_init(wp);
|
||||||
|
|
||||||
if (args->argc != 0)
|
path = NULL;
|
||||||
cmd = args->argv[0];
|
if (item->client != NULL && item->client->session == NULL)
|
||||||
|
envent = environ_find(item->client->environ, "PATH");
|
||||||
else
|
else
|
||||||
cmd = NULL;
|
envent = environ_find(s->environ, "PATH");
|
||||||
if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) {
|
if (envent != NULL)
|
||||||
cmdq_error(cmdq, "respawn pane failed: %s", cause);
|
path = envent->value;
|
||||||
|
|
||||||
|
env = environ_for_session(s);
|
||||||
|
if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
|
||||||
|
s->tio, &cause) != 0) {
|
||||||
|
cmdq_error(item, "respawn pane failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
environ_free(&env);
|
environ_free(env);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
environ_free(env);
|
||||||
|
|
||||||
wp->flags |= PANE_REDRAW;
|
wp->flags |= PANE_REDRAW;
|
||||||
server_status_window(w);
|
server_status_window(w);
|
||||||
|
|
||||||
environ_free(&env);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,66 +27,70 @@
|
|||||||
* Respawn a window (restart the command). Kill existing if -k given.
|
* Respawn a window (restart the command). Kill existing if -k given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_respawn_window_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_respawn_window_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_respawn_window_entry = {
|
const struct cmd_entry cmd_respawn_window_entry = {
|
||||||
"respawn-window", "respawnw",
|
.name = "respawn-window",
|
||||||
"kt:", 0, 1,
|
.alias = "respawnw",
|
||||||
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
|
|
||||||
0,
|
.args = { "kt:", 0, -1 },
|
||||||
NULL,
|
.usage = "[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
|
||||||
NULL,
|
|
||||||
cmd_respawn_window_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_respawn_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct session *s = item->state.tflag.s;
|
||||||
struct window *w;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
|
struct window *w = wl->window;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct session *s;
|
struct environ *env;
|
||||||
struct environ env;
|
const char *path;
|
||||||
const char *cmd;
|
|
||||||
char *cause;
|
char *cause;
|
||||||
|
struct environ_entry *envent;
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
w = wl->window;
|
|
||||||
|
|
||||||
if (!args_has(self->args, 'k')) {
|
if (!args_has(self->args, 'k')) {
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
if (wp->fd == -1)
|
if (wp->fd == -1)
|
||||||
continue;
|
continue;
|
||||||
cmdq_error(cmdq,
|
cmdq_error(item, "window still active: %s:%d", s->name,
|
||||||
"window still active: %s:%d", s->name, wl->idx);
|
wl->idx);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
environ_init(&env);
|
|
||||||
environ_copy(&global_environ, &env);
|
|
||||||
environ_copy(&s->environ, &env);
|
|
||||||
server_fill_environ(s, &env);
|
|
||||||
|
|
||||||
wp = TAILQ_FIRST(&w->panes);
|
wp = TAILQ_FIRST(&w->panes);
|
||||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
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 (args->argc != 0)
|
|
||||||
cmd = args->argv[0];
|
path = NULL;
|
||||||
|
if (item->client != NULL && item->client->session == NULL)
|
||||||
|
envent = environ_find(item->client->environ, "PATH");
|
||||||
else
|
else
|
||||||
cmd = NULL;
|
envent = environ_find(s->environ, "PATH");
|
||||||
if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) {
|
if (envent != NULL)
|
||||||
cmdq_error(cmdq, "respawn window failed: %s", cause);
|
path = envent->value;
|
||||||
|
|
||||||
|
env = environ_for_session(s);
|
||||||
|
if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
|
||||||
|
s->tio, &cause) != 0) {
|
||||||
|
cmdq_error(item, "respawn window failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
environ_free(&env);
|
environ_free(env);
|
||||||
server_destroy_pane(wp);
|
server_destroy_pane(wp, 0);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
environ_free(env);
|
||||||
layout_init(w, wp);
|
layout_init(w, wp);
|
||||||
window_pane_reset_mode(wp);
|
window_pane_reset_mode(wp);
|
||||||
screen_reinit(&wp->base);
|
screen_reinit(&wp->base);
|
||||||
@@ -96,6 +100,5 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
|
|
||||||
environ_free(&env);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -24,40 +24,32 @@
|
|||||||
* Rotate the panes in a window.
|
* Rotate the panes in a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_rotate_window_key_binding(struct cmd *, int);
|
static enum cmd_retval cmd_rotate_window_exec(struct cmd *,
|
||||||
enum cmd_retval cmd_rotate_window_exec(struct cmd *, struct cmd_q *);
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rotate_window_entry = {
|
const struct cmd_entry cmd_rotate_window_entry = {
|
||||||
"rotate-window", "rotatew",
|
.name = "rotate-window",
|
||||||
"Dt:U", 0, 0,
|
.alias = "rotatew",
|
||||||
"[-DU] " CMD_TARGET_WINDOW_USAGE,
|
|
||||||
0,
|
.args = { "Dt:U", 0, 0 },
|
||||||
cmd_rotate_window_key_binding,
|
.usage = "[-DU] " CMD_TARGET_WINDOW_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_rotate_window_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_rotate_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_rotate_window_key_binding(struct cmd *self, int key)
|
cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
self->args = args_create(0);
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
if (key == ('o' | KEYC_ESCAPE))
|
struct window *w = wl->window;
|
||||||
args_set(self->args, 'D', NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_rotate_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct window *w;
|
|
||||||
struct window_pane *wp, *wp2;
|
struct window_pane *wp, *wp2;
|
||||||
struct layout_cell *lc;
|
struct layout_cell *lc;
|
||||||
u_int sx, sy, xoff, yoff;
|
u_int sx, sy, xoff, yoff;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
server_unzoom_window(w);
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
w = wl->window;
|
|
||||||
|
|
||||||
if (args_has(self->args, 'D')) {
|
if (args_has(self->args, 'D')) {
|
||||||
wp = TAILQ_LAST(&w->panes, window_panes);
|
wp = TAILQ_LAST(&w->panes, window_panes);
|
||||||
|
|||||||
139
cmd-run-shell.c
139
cmd-run-shell.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -29,40 +29,50 @@
|
|||||||
* Runs a command without a window.
|
* Runs a command without a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_run_shell_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_run_shell_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
void cmd_run_shell_callback(struct job *);
|
static void cmd_run_shell_callback(struct job *);
|
||||||
void cmd_run_shell_free(void *);
|
static void cmd_run_shell_free(void *);
|
||||||
void cmd_run_shell_print(struct job *, const char *);
|
static void cmd_run_shell_print(struct job *, const char *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_run_shell_entry = {
|
const struct cmd_entry cmd_run_shell_entry = {
|
||||||
"run-shell", "run",
|
.name = "run-shell",
|
||||||
"bt:", 1, 1,
|
.alias = "run",
|
||||||
"[-b] " CMD_TARGET_PANE_USAGE " shell-command",
|
|
||||||
0,
|
.args = { "bt:", 1, 1 },
|
||||||
NULL,
|
.usage = "[-b] " CMD_TARGET_PANE_USAGE " shell-command",
|
||||||
NULL,
|
|
||||||
cmd_run_shell_exec
|
.tflag = CMD_PANE_CANFAIL,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_run_shell_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_run_shell_data {
|
struct cmd_run_shell_data {
|
||||||
char *cmd;
|
char *cmd;
|
||||||
struct cmd_q *cmdq;
|
struct cmdq_item *item;
|
||||||
int bflag;
|
int wp_id;
|
||||||
int wp_id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_run_shell_print(struct job *job, const char *msg)
|
cmd_run_shell_print(struct job *job, const char *msg)
|
||||||
{
|
{
|
||||||
struct cmd_run_shell_data *cdata = job->data;
|
struct cmd_run_shell_data *cdata = job->data;
|
||||||
struct window_pane *wp = NULL;
|
struct window_pane *wp = NULL;
|
||||||
|
struct cmd_find_state fs;
|
||||||
|
|
||||||
if (cdata->wp_id != -1)
|
if (cdata->wp_id != -1)
|
||||||
wp = window_pane_find_by_id(cdata->wp_id);
|
wp = window_pane_find_by_id(cdata->wp_id);
|
||||||
if (wp == NULL) {
|
if (wp == NULL) {
|
||||||
cmdq_print(cdata->cmdq, "%s", msg);
|
if (cdata->item != NULL) {
|
||||||
return;
|
cmdq_print(cdata->item, "%s", msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cmd_find_current (&fs, NULL, CMD_FIND_QUIET) != 0)
|
||||||
|
return;
|
||||||
|
wp = fs.wp;
|
||||||
|
if (wp == NULL)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window_pane_set_mode(wp, &window_copy_mode) == 0)
|
if (window_pane_set_mode(wp, &window_copy_mode) == 0)
|
||||||
@@ -71,74 +81,55 @@ cmd_run_shell_print(struct job *job, const char *msg)
|
|||||||
window_copy_add(wp, "%s", msg);
|
window_copy_add(wp, "%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct cmd_run_shell_data *cdata;
|
struct cmd_run_shell_data *cdata;
|
||||||
char *shellcmd;
|
struct client *c = item->state.c;
|
||||||
struct client *c;
|
struct session *s = item->state.tflag.s;
|
||||||
struct session *s = NULL;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct winlink *wl = NULL;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
struct window_pane *wp = NULL;
|
const char *cwd;
|
||||||
struct format_tree *ft;
|
|
||||||
|
|
||||||
if (args_has(args, 't'))
|
if (item->client != NULL && item->client->session == NULL)
|
||||||
wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
|
cwd = item->client->cwd;
|
||||||
else {
|
else if (s != NULL)
|
||||||
c = cmd_find_client(cmdq, NULL, 1);
|
cwd = s->cwd;
|
||||||
if (c != NULL && c->session != NULL) {
|
else
|
||||||
s = c->session;
|
cwd = NULL;
|
||||||
wl = s->curw;
|
|
||||||
wp = wl->window->active;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ft = format_create();
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
if (s != NULL)
|
cdata->cmd = format_single(item, args->argv[0], c, s, wl, wp);
|
||||||
format_session(ft, s);
|
|
||||||
if (s != NULL && wl != NULL)
|
|
||||||
format_winlink(ft, s, wl);
|
|
||||||
if (wp != NULL)
|
|
||||||
format_window_pane(ft, wp);
|
|
||||||
shellcmd = format_expand(ft, args->argv[0]);
|
|
||||||
format_free(ft);
|
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
if (args_has(args, 't') && wp != NULL)
|
||||||
cdata->cmd = shellcmd;
|
cdata->wp_id = wp->id;
|
||||||
cdata->bflag = args_has(args, 'b');
|
else
|
||||||
cdata->wp_id = wp != NULL ? (int) wp->id : -1;
|
cdata->wp_id = -1;
|
||||||
|
|
||||||
cdata->cmdq = cmdq;
|
if (!args_has(args, 'b'))
|
||||||
cmdq->references++;
|
cdata->item = item;
|
||||||
|
|
||||||
job_run(shellcmd, s, cmd_run_shell_callback, cmd_run_shell_free, cdata);
|
job_run(cdata->cmd, s, cwd, cmd_run_shell_callback, cmd_run_shell_free,
|
||||||
|
cdata);
|
||||||
|
|
||||||
if (cdata->bflag)
|
if (args_has(args, 'b'))
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
return (CMD_RETURN_WAIT);
|
return (CMD_RETURN_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_run_shell_callback(struct job *job)
|
cmd_run_shell_callback(struct job *job)
|
||||||
{
|
{
|
||||||
struct cmd_run_shell_data *cdata = job->data;
|
struct cmd_run_shell_data *cdata = job->data;
|
||||||
struct cmd_q *cmdq = cdata->cmdq;
|
char *cmd = cdata->cmd, *msg, *line;
|
||||||
char *cmd, *msg, *line;
|
|
||||||
size_t size;
|
size_t size;
|
||||||
int retcode;
|
int retcode;
|
||||||
u_int lines;
|
|
||||||
|
|
||||||
if (cmdq->dead)
|
|
||||||
return;
|
|
||||||
cmd = cdata->cmd;
|
|
||||||
|
|
||||||
lines = 0;
|
|
||||||
do {
|
do {
|
||||||
if ((line = evbuffer_readline(job->event->input)) != NULL) {
|
if ((line = evbuffer_readline(job->event->input)) != NULL) {
|
||||||
cmd_run_shell_print(job, line);
|
cmd_run_shell_print(job, line);
|
||||||
free(line);
|
free(line);
|
||||||
lines++;
|
|
||||||
}
|
}
|
||||||
} while (line != NULL);
|
} while (line != NULL);
|
||||||
|
|
||||||
@@ -149,7 +140,6 @@ cmd_run_shell_callback(struct job *job)
|
|||||||
line[size] = '\0';
|
line[size] = '\0';
|
||||||
|
|
||||||
cmd_run_shell_print(job, line);
|
cmd_run_shell_print(job, line);
|
||||||
lines++;
|
|
||||||
|
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
@@ -162,23 +152,18 @@ cmd_run_shell_callback(struct job *job)
|
|||||||
retcode = WTERMSIG(job->status);
|
retcode = WTERMSIG(job->status);
|
||||||
xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode);
|
xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode);
|
||||||
}
|
}
|
||||||
if (msg != NULL) {
|
if (msg != NULL)
|
||||||
if (lines == 0)
|
cmd_run_shell_print(job, msg);
|
||||||
cmdq_info(cmdq, "%s", msg);
|
free(msg);
|
||||||
else
|
|
||||||
cmd_run_shell_print(job, msg);
|
if (cdata->item != NULL)
|
||||||
free(msg);
|
cdata->item->flags &= ~CMDQ_WAITING;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_run_shell_free(void *data)
|
cmd_run_shell_free(void *data)
|
||||||
{
|
{
|
||||||
struct cmd_run_shell_data *cdata = data;
|
struct cmd_run_shell_data *cdata = data;
|
||||||
struct cmd_q *cmdq = cdata->cmdq;
|
|
||||||
|
|
||||||
if (!cmdq_free(cmdq) && !cdata->bflag)
|
|
||||||
cmdq_continue(cmdq);
|
|
||||||
|
|
||||||
free(cdata->cmd);
|
free(cdata->cmd);
|
||||||
free(cdata);
|
free(cdata);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -20,8 +20,10 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -29,72 +31,64 @@
|
|||||||
* Saves a paste buffer to a file.
|
* Saves a paste buffer to a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_save_buffer_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_save_buffer_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_save_buffer_entry = {
|
const struct cmd_entry cmd_save_buffer_entry = {
|
||||||
"save-buffer", "saveb",
|
.name = "save-buffer",
|
||||||
"ab:", 1, 1,
|
.alias = "saveb",
|
||||||
"[-a] " CMD_BUFFER_USAGE " path",
|
|
||||||
0,
|
.args = { "ab:", 1, 1 },
|
||||||
NULL,
|
.usage = "[-a] " CMD_BUFFER_USAGE " path",
|
||||||
NULL,
|
|
||||||
cmd_save_buffer_exec
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_save_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_buffer_entry = {
|
const struct cmd_entry cmd_show_buffer_entry = {
|
||||||
"show-buffer", "showb",
|
.name = "show-buffer",
|
||||||
"b:", 0, 0,
|
.alias = "showb",
|
||||||
CMD_BUFFER_USAGE,
|
|
||||||
0,
|
.args = { "b:", 0, 0 },
|
||||||
NULL,
|
.usage = CMD_BUFFER_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_save_buffer_exec
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_save_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c = item->client;
|
||||||
struct session *s;
|
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
const char *path, *newpath, *wd;
|
const char *path, *bufname, *bufdata, *start, *end;
|
||||||
char *cause, *start, *end;
|
const char *flags;
|
||||||
size_t size, used;
|
char *msg, *file;
|
||||||
int buffer;
|
size_t size, used, msglen, bufsize;
|
||||||
mode_t mask;
|
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *msg;
|
|
||||||
size_t msglen;
|
|
||||||
|
|
||||||
if (!args_has(args, 'b')) {
|
if (!args_has(args, 'b')) {
|
||||||
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
if ((pb = paste_get_top(NULL)) == NULL) {
|
||||||
cmdq_error(cmdq, "no buffers");
|
cmdq_error(item, "no buffers");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
bufname = args_get(args, 'b');
|
||||||
if (cause != NULL) {
|
pb = paste_get_name(bufname);
|
||||||
cmdq_error(cmdq, "buffer %s", cause);
|
|
||||||
free(cause);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
pb = paste_get_index(&global_buffers, buffer);
|
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
cmdq_error(cmdq, "no buffer %d", buffer);
|
cmdq_error(item, "no buffer %s", bufname);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bufdata = paste_buffer_data(pb, &bufsize);
|
||||||
|
|
||||||
if (self->entry == &cmd_show_buffer_entry)
|
if (self->entry == &cmd_show_buffer_entry)
|
||||||
path = "-";
|
path = "-";
|
||||||
else
|
else
|
||||||
path = args->argv[0];
|
path = args->argv[0];
|
||||||
if (strcmp(path, "-") == 0) {
|
if (strcmp(path, "-") == 0) {
|
||||||
c = cmdq->client;
|
|
||||||
if (c == NULL) {
|
if (c == NULL) {
|
||||||
cmdq_error(cmdq, "can't write to stdout");
|
cmdq_error(item, "can't write to stdout");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (c->session == NULL || (c->flags & CLIENT_CONTROL))
|
if (c->session == NULL || (c->flags & CLIENT_CONTROL))
|
||||||
@@ -102,67 +96,55 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
goto do_print;
|
goto do_print;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = cmdq->client;
|
flags = "wb";
|
||||||
if (c != NULL)
|
|
||||||
wd = c->cwd;
|
|
||||||
else if ((s = cmd_current_session(cmdq, 0)) != NULL) {
|
|
||||||
wd = options_get_string(&s->options, "default-path");
|
|
||||||
if (*wd == '\0')
|
|
||||||
wd = s->cwd;
|
|
||||||
} else
|
|
||||||
wd = NULL;
|
|
||||||
if (wd != NULL && *wd != '\0') {
|
|
||||||
newpath = get_full_path(wd, path);
|
|
||||||
if (newpath != NULL)
|
|
||||||
path = newpath;
|
|
||||||
}
|
|
||||||
|
|
||||||
mask = umask(S_IRWXG | S_IRWXO);
|
|
||||||
if (args_has(self->args, 'a'))
|
if (args_has(self->args, 'a'))
|
||||||
f = fopen(path, "ab");
|
flags = "ab";
|
||||||
else
|
|
||||||
f = fopen(path, "wb");
|
file = server_client_get_path(c, path);
|
||||||
umask(mask);
|
f = fopen(file, flags);
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
cmdq_error(cmdq, "%s: %s", path, strerror(errno));
|
cmdq_error(item, "%s: %s", file, strerror(errno));
|
||||||
|
free(file);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
|
|
||||||
cmdq_error(cmdq, "%s: fwrite error", path);
|
if (fwrite(bufdata, 1, bufsize, f) != bufsize) {
|
||||||
|
cmdq_error(item, "%s: write error", file);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
free(file);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
do_stdout:
|
do_stdout:
|
||||||
evbuffer_add(c->stdout_data, pb->data, pb->size);
|
evbuffer_add(c->stdout_data, bufdata, bufsize);
|
||||||
server_push_stdout(c);
|
server_client_push_stdout(c);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
do_print:
|
do_print:
|
||||||
if (pb->size > (INT_MAX / 4) - 1) {
|
if (bufsize > (INT_MAX / 4) - 1) {
|
||||||
cmdq_error(cmdq, "buffer too big");
|
cmdq_error(item, "buffer too big");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
msg = NULL;
|
msg = NULL;
|
||||||
msglen = 0;
|
|
||||||
|
|
||||||
used = 0;
|
used = 0;
|
||||||
while (used != pb->size) {
|
while (used != bufsize) {
|
||||||
start = pb->data + used;
|
start = bufdata + used;
|
||||||
end = memchr(start, '\n', pb->size - used);
|
end = memchr(start, '\n', bufsize - used);
|
||||||
if (end != NULL)
|
if (end != NULL)
|
||||||
size = end - start;
|
size = end - start;
|
||||||
else
|
else
|
||||||
size = pb->size - used;
|
size = bufsize - used;
|
||||||
|
|
||||||
msglen = size * 4 + 1;
|
msglen = size * 4 + 1;
|
||||||
msg = xrealloc(msg, 1, msglen);
|
msg = xrealloc(msg, msglen);
|
||||||
|
|
||||||
strvisx(msg, start, size, VIS_OCTAL|VIS_TAB);
|
strvisx(msg, start, size, VIS_OCTAL|VIS_TAB);
|
||||||
cmdq_print(cmdq, "%s", msg);
|
cmdq_print(item, "%s", msg);
|
||||||
|
|
||||||
used += size + (end != NULL);
|
used += size + (end != NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -18,118 +18,123 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Switch window to selected layout.
|
* Switch window to selected layout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_layout_key_binding(struct cmd *, int);
|
static enum cmd_retval cmd_select_layout_exec(struct cmd *,
|
||||||
enum cmd_retval cmd_select_layout_exec(struct cmd *, struct cmd_q *);
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_layout_entry = {
|
const struct cmd_entry cmd_select_layout_entry = {
|
||||||
"select-layout", "selectl",
|
.name = "select-layout",
|
||||||
"npt:", 0, 1,
|
.alias = "selectl",
|
||||||
"[-np] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
|
||||||
0,
|
.args = { "nopt:", 0, 1 },
|
||||||
cmd_select_layout_key_binding,
|
.usage = "[-nop] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
||||||
NULL,
|
|
||||||
cmd_select_layout_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_select_layout_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_next_layout_entry = {
|
const struct cmd_entry cmd_next_layout_entry = {
|
||||||
"next-layout", "nextl",
|
.name = "next-layout",
|
||||||
"t:", 0, 0,
|
.alias = "nextl",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
|
||||||
0,
|
.args = { "t:", 0, 0 },
|
||||||
NULL,
|
.usage = CMD_TARGET_WINDOW_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_select_layout_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_select_layout_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_previous_layout_entry = {
|
const struct cmd_entry cmd_previous_layout_entry = {
|
||||||
"previous-layout", "prevl",
|
.name = "previous-layout",
|
||||||
"t:", 0, 0,
|
.alias = "prevl",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
|
||||||
0,
|
.args = { "t:", 0, 0 },
|
||||||
NULL,
|
.usage = CMD_TARGET_WINDOW_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_select_layout_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_select_layout_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_select_layout_key_binding(struct cmd *self, int key)
|
cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
|
||||||
switch (key) {
|
|
||||||
case '1' | KEYC_ESCAPE:
|
|
||||||
self->args = args_create(1, "even-horizontal");
|
|
||||||
break;
|
|
||||||
case '2' | KEYC_ESCAPE:
|
|
||||||
self->args = args_create(1, "even-vertical");
|
|
||||||
break;
|
|
||||||
case '3' | KEYC_ESCAPE:
|
|
||||||
self->args = args_create(1, "main-horizontal");
|
|
||||||
break;
|
|
||||||
case '4' | KEYC_ESCAPE:
|
|
||||||
self->args = args_create(1, "main-vertical");
|
|
||||||
break;
|
|
||||||
case '5' | KEYC_ESCAPE:
|
|
||||||
self->args = args_create(1, "tiled");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
self->args = args_create(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
|
struct window *w;
|
||||||
const char *layoutname;
|
const char *layoutname;
|
||||||
|
char *oldlayout;
|
||||||
int next, previous, layout;
|
int next, previous, layout;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
w = wl->window;
|
||||||
return (CMD_RETURN_ERROR);
|
server_unzoom_window(w);
|
||||||
server_unzoom_window(wl->window);
|
|
||||||
|
|
||||||
next = self->entry == &cmd_next_layout_entry;
|
next = self->entry == &cmd_next_layout_entry;
|
||||||
if (args_has(self->args, 'n'))
|
if (args_has(args, 'n'))
|
||||||
next = 1;
|
next = 1;
|
||||||
previous = self->entry == &cmd_previous_layout_entry;
|
previous = self->entry == &cmd_previous_layout_entry;
|
||||||
if (args_has(self->args, 'p'))
|
if (args_has(args, 'p'))
|
||||||
previous = 1;
|
previous = 1;
|
||||||
|
|
||||||
|
oldlayout = w->old_layout;
|
||||||
|
w->old_layout = layout_dump(w->layout_root);
|
||||||
|
|
||||||
if (next || previous) {
|
if (next || previous) {
|
||||||
if (next)
|
if (next)
|
||||||
layout = layout_set_next(wl->window);
|
layout_set_next(w);
|
||||||
else
|
else
|
||||||
layout = layout_set_previous(wl->window);
|
layout_set_previous(w);
|
||||||
server_redraw_window(wl->window);
|
goto changed;
|
||||||
cmdq_info(cmdq, "arranging in: %s", layout_set_name(layout));
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc == 0)
|
if (!args_has(args, 'o')) {
|
||||||
layout = wl->window->lastlayout;
|
if (args->argc == 0)
|
||||||
else
|
layout = w->lastlayout;
|
||||||
layout = layout_set_lookup(args->argv[0]);
|
else
|
||||||
if (layout != -1) {
|
layout = layout_set_lookup(args->argv[0]);
|
||||||
layout = layout_set_select(wl->window, layout);
|
if (layout != -1) {
|
||||||
server_redraw_window(wl->window);
|
layout_set_select(w, layout);
|
||||||
cmdq_info(cmdq, "arranging in: %s", layout_set_name(layout));
|
goto changed;
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args->argc != 0) {
|
|
||||||
layoutname = args->argv[0];
|
|
||||||
if (layout_parse(wl->window, layoutname) == -1) {
|
|
||||||
cmdq_error(cmdq, "can't set layout: %s", layoutname);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
}
|
||||||
server_redraw_window(wl->window);
|
|
||||||
cmdq_info(cmdq, "arranging in: %s", layoutname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args->argc != 0)
|
||||||
|
layoutname = args->argv[0];
|
||||||
|
else if (args_has(args, 'o'))
|
||||||
|
layoutname = oldlayout;
|
||||||
|
else
|
||||||
|
layoutname = NULL;
|
||||||
|
|
||||||
|
if (layoutname != NULL) {
|
||||||
|
if (layout_parse(w, layoutname) == -1) {
|
||||||
|
cmdq_error(item, "can't set layout: %s", layoutname);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
goto changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(oldlayout);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
changed:
|
||||||
|
free(oldlayout);
|
||||||
|
server_redraw_window(w);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
error:
|
||||||
|
free(w->old_layout);
|
||||||
|
w->old_layout = oldlayout;
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -24,95 +24,140 @@
|
|||||||
* Select pane.
|
* Select pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_pane_key_binding(struct cmd *, int);
|
static enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_pane_entry = {
|
const struct cmd_entry cmd_select_pane_entry = {
|
||||||
"select-pane", "selectp",
|
.name = "select-pane",
|
||||||
"lDLRt:U", 0, 0,
|
.alias = "selectp",
|
||||||
"[-lDLRU] " CMD_TARGET_PANE_USAGE,
|
|
||||||
0,
|
.args = { "DdegLlMmP:Rt:U", 0, 0 },
|
||||||
cmd_select_pane_key_binding,
|
.usage = "[-DdegLlMmRU] [-P style] " CMD_TARGET_PANE_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_select_pane_exec
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_select_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_last_pane_entry = {
|
const struct cmd_entry cmd_last_pane_entry = {
|
||||||
"last-pane", "lastp",
|
.name = "last-pane",
|
||||||
"t:", 0, 0,
|
.alias = "lastp",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
|
||||||
0,
|
.args = { "det:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-de] " CMD_TARGET_WINDOW_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_select_pane_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_select_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_select_pane_key_binding(struct cmd *self, int key)
|
cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
|
||||||
self->args = args_create(0);
|
|
||||||
if (key == KEYC_UP)
|
|
||||||
args_set(self->args, 'U', NULL);
|
|
||||||
if (key == KEYC_DOWN)
|
|
||||||
args_set(self->args, 'D', NULL);
|
|
||||||
if (key == KEYC_LEFT)
|
|
||||||
args_set(self->args, 'L', NULL);
|
|
||||||
if (key == KEYC_RIGHT)
|
|
||||||
args_set(self->args, 'R', NULL);
|
|
||||||
if (key == 'o')
|
|
||||||
args_set(self->args, 't', ":.+");
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct window_pane *wp;
|
struct window *w = wl->window;
|
||||||
|
struct session *s = item->state.tflag.s;
|
||||||
|
struct window_pane *wp = item->state.tflag.wp, *lastwp, *markedwp;
|
||||||
|
const char *style;
|
||||||
|
|
||||||
if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) {
|
if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) {
|
||||||
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
|
|
||||||
if (wl == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
if (wl->window->last == NULL) {
|
if (wl->window->last == NULL) {
|
||||||
cmdq_error(cmdq, "no last pane");
|
cmdq_error(item, "no last pane");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
server_unzoom_window(wl->window);
|
if (args_has(self->args, 'e'))
|
||||||
window_set_active_pane(wl->window, wl->window->last);
|
w->last->flags &= ~PANE_INPUTOFF;
|
||||||
server_status_window(wl->window);
|
else if (args_has(self->args, 'd'))
|
||||||
server_redraw_window_borders(wl->window);
|
w->last->flags |= PANE_INPUTOFF;
|
||||||
|
else {
|
||||||
|
server_unzoom_window(w);
|
||||||
|
window_redraw_active_switch(w, w->last);
|
||||||
|
if (window_set_active_pane(w, w->last)) {
|
||||||
|
server_status_window(w);
|
||||||
|
server_redraw_window_borders(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
|
if (args_has(args, 'm') || args_has(args, 'M')) {
|
||||||
return (CMD_RETURN_ERROR);
|
if (args_has(args, 'm') && !window_pane_visible(wp))
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
lastwp = marked_pane.wp;
|
||||||
|
|
||||||
|
if (args_has(args, 'M') || server_is_marked(s, wl, wp))
|
||||||
|
server_clear_marked();
|
||||||
|
else
|
||||||
|
server_set_marked(s, wl, wp);
|
||||||
|
markedwp = marked_pane.wp;
|
||||||
|
|
||||||
|
if (lastwp != NULL) {
|
||||||
|
server_redraw_window_borders(lastwp->window);
|
||||||
|
server_status_window(lastwp->window);
|
||||||
|
}
|
||||||
|
if (markedwp != NULL) {
|
||||||
|
server_redraw_window_borders(markedwp->window);
|
||||||
|
server_status_window(markedwp->window);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(self->args, 'P') || args_has(self->args, 'g')) {
|
||||||
|
if (args_has(args, 'P')) {
|
||||||
|
style = args_get(args, 'P');
|
||||||
|
if (style_parse(&grid_default_cell, &wp->colgc,
|
||||||
|
style) == -1) {
|
||||||
|
cmdq_error(item, "bad style: %s", style);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
wp->flags |= PANE_REDRAW;
|
||||||
|
}
|
||||||
|
if (args_has(self->args, 'g'))
|
||||||
|
cmdq_print(item, "%s", style_tostring(&wp->colgc));
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(self->args, 'L')) {
|
||||||
|
server_unzoom_window(wp->window);
|
||||||
|
wp = window_pane_find_left(wp);
|
||||||
|
} else if (args_has(self->args, 'R')) {
|
||||||
|
server_unzoom_window(wp->window);
|
||||||
|
wp = window_pane_find_right(wp);
|
||||||
|
} else if (args_has(self->args, 'U')) {
|
||||||
|
server_unzoom_window(wp->window);
|
||||||
|
wp = window_pane_find_up(wp);
|
||||||
|
} else if (args_has(self->args, 'D')) {
|
||||||
|
server_unzoom_window(wp->window);
|
||||||
|
wp = window_pane_find_down(wp);
|
||||||
|
}
|
||||||
|
if (wp == NULL)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
if (args_has(self->args, 'e')) {
|
||||||
|
wp->flags &= ~PANE_INPUTOFF;
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
if (args_has(self->args, 'd')) {
|
||||||
|
wp->flags |= PANE_INPUTOFF;
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wp == w->active)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
server_unzoom_window(wp->window);
|
server_unzoom_window(wp->window);
|
||||||
if (!window_pane_visible(wp)) {
|
if (!window_pane_visible(wp)) {
|
||||||
cmdq_error(cmdq, "pane not visible");
|
cmdq_error(item, "pane not visible");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
window_redraw_active_switch(w, wp);
|
||||||
if (args_has(self->args, 'L'))
|
if (window_set_active_pane(w, wp)) {
|
||||||
wp = window_pane_find_left(wp);
|
server_status_window(w);
|
||||||
else if (args_has(self->args, 'R'))
|
server_redraw_window_borders(w);
|
||||||
wp = window_pane_find_right(wp);
|
|
||||||
else if (args_has(self->args, 'U'))
|
|
||||||
wp = window_pane_find_up(wp);
|
|
||||||
else if (args_has(self->args, 'D'))
|
|
||||||
wp = window_pane_find_down(wp);
|
|
||||||
if (wp == NULL) {
|
|
||||||
cmdq_error(cmdq, "pane not found");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window_set_active_pane(wl->window, wp);
|
|
||||||
server_status_window(wl->window);
|
|
||||||
server_redraw_window_borders(wl->window);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -26,69 +26,66 @@
|
|||||||
* Select window by index.
|
* Select window by index.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_window_key_binding(struct cmd *, int);
|
static enum cmd_retval cmd_select_window_exec(struct cmd *,
|
||||||
enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_q *);
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_window_entry = {
|
const struct cmd_entry cmd_select_window_entry = {
|
||||||
"select-window", "selectw",
|
.name = "select-window",
|
||||||
"lnpTt:", 0, 0,
|
.alias = "selectw",
|
||||||
"[-lnpT] " CMD_TARGET_WINDOW_USAGE,
|
|
||||||
0,
|
.args = { "lnpTt:", 0, 0 },
|
||||||
cmd_select_window_key_binding,
|
.usage = "[-lnpT] " CMD_TARGET_WINDOW_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_select_window_exec
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_select_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_next_window_entry = {
|
const struct cmd_entry cmd_next_window_entry = {
|
||||||
"next-window", "next",
|
.name = "next-window",
|
||||||
"at:", 0, 0,
|
.alias = "next",
|
||||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
|
||||||
0,
|
.args = { "at:", 0, 0 },
|
||||||
cmd_select_window_key_binding,
|
.usage = "[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_select_window_exec
|
.tflag = CMD_SESSION,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_select_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_previous_window_entry = {
|
const struct cmd_entry cmd_previous_window_entry = {
|
||||||
"previous-window", "prev",
|
.name = "previous-window",
|
||||||
"at:", 0, 0,
|
.alias = "prev",
|
||||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
|
||||||
0,
|
.args = { "at:", 0, 0 },
|
||||||
cmd_select_window_key_binding,
|
.usage = "[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_select_window_exec
|
.tflag = CMD_SESSION,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_select_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_last_window_entry = {
|
const struct cmd_entry cmd_last_window_entry = {
|
||||||
"last-window", "last",
|
.name = "last-window",
|
||||||
"t:", 0, 0,
|
.alias = "last",
|
||||||
CMD_TARGET_SESSION_USAGE,
|
|
||||||
0,
|
.args = { "t:", 0, 0 },
|
||||||
NULL,
|
.usage = CMD_TARGET_SESSION_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_select_window_exec
|
.tflag = CMD_SESSION,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_select_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_select_window_key_binding(struct cmd *self, int key)
|
cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
char tmp[16];
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
|
struct session *s = item->state.tflag.s;
|
||||||
self->args = args_create(0);
|
|
||||||
if (key >= '0' && key <= '9') {
|
|
||||||
xsnprintf(tmp, sizeof tmp, ":%d", key - '0');
|
|
||||||
args_set(self->args, 't', tmp);
|
|
||||||
}
|
|
||||||
if (key == ('n' | KEYC_ESCAPE) || key == ('p' | KEYC_ESCAPE))
|
|
||||||
args_set(self->args, 'a', NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_select_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct session *s;
|
|
||||||
int next, previous, last, activity;
|
int next, previous, last, activity;
|
||||||
|
|
||||||
next = self->entry == &cmd_next_window_entry;
|
next = self->entry == &cmd_next_window_entry;
|
||||||
@@ -102,41 +99,33 @@ cmd_select_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
last = 1;
|
last = 1;
|
||||||
|
|
||||||
if (next || previous || last) {
|
if (next || previous || last) {
|
||||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
|
||||||
if (s == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
activity = args_has(self->args, 'a');
|
activity = args_has(self->args, 'a');
|
||||||
if (next) {
|
if (next) {
|
||||||
if (session_next(s, activity) != 0) {
|
if (session_next(s, activity) != 0) {
|
||||||
cmdq_error(cmdq, "no next window");
|
cmdq_error(item, "no next window");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (previous) {
|
} else if (previous) {
|
||||||
if (session_previous(s, activity) != 0) {
|
if (session_previous(s, activity) != 0) {
|
||||||
cmdq_error(cmdq, "no previous window");
|
cmdq_error(item, "no previous window");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (session_last(s) != 0) {
|
if (session_last(s) != 0) {
|
||||||
cmdq_error(cmdq, "no last window");
|
cmdq_error(item, "no last window");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
} else {
|
} else {
|
||||||
wl = cmd_find_window(cmdq, args_get(args, 't'), &s);
|
|
||||||
if (wl == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If -T and select-window is invoked on same window as
|
* If -T and select-window is invoked on same window as
|
||||||
* current, switch to previous window.
|
* current, switch to previous window.
|
||||||
*/
|
*/
|
||||||
if (args_has(self->args, 'T') && wl == s->curw) {
|
if (args_has(self->args, 'T') && wl == s->curw) {
|
||||||
if (session_last(s) != 0) {
|
if (session_last(s) != 0) {
|
||||||
cmdq_error(cmdq, "no last window");
|
cmdq_error(item, "no last window");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
|
|||||||
143
cmd-send-keys.c
143
cmd-send-keys.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,76 +27,117 @@
|
|||||||
* Send keys to client.
|
* Send keys to client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_send_keys_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_send_keys_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_send_keys_entry = {
|
const struct cmd_entry cmd_send_keys_entry = {
|
||||||
"send-keys", "send",
|
.name = "send-keys",
|
||||||
"lRt:", 0, -1,
|
.alias = "send",
|
||||||
"[-lR] " CMD_TARGET_PANE_USAGE " key ...",
|
|
||||||
0,
|
.args = { "lXRMN:t:", 0, -1 },
|
||||||
NULL,
|
.usage = "[-lXRM] [-N repeat-count] " CMD_TARGET_PANE_USAGE " key ...",
|
||||||
NULL,
|
|
||||||
cmd_send_keys_exec
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_send_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_send_prefix_entry = {
|
const struct cmd_entry cmd_send_prefix_entry = {
|
||||||
"send-prefix", NULL,
|
.name = "send-prefix",
|
||||||
"2t:", 0, 0,
|
.alias = NULL,
|
||||||
"[-2] " CMD_TARGET_PANE_USAGE,
|
|
||||||
0,
|
.args = { "2t:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-2] " CMD_TARGET_PANE_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_send_keys_exec
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_send_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_send_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct client *c = item->state.c;
|
||||||
struct session *s;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
struct input_ctx *ictx;
|
struct session *s = item->state.tflag.s;
|
||||||
const char *str;
|
struct mouse_event *m = &item->mouse;
|
||||||
int i, key;
|
struct utf8_data *ud, *uc;
|
||||||
|
wchar_t wc;
|
||||||
|
int i, literal;
|
||||||
|
key_code key;
|
||||||
|
u_int np = 1;
|
||||||
|
char *cause = NULL;
|
||||||
|
|
||||||
if (cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp) == NULL)
|
if (args_has(args, 'N')) {
|
||||||
return (CMD_RETURN_ERROR);
|
np = args_strtonum(args, 'N', 1, UINT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "repeat count %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (args_has(args, 'X') || args->argc == 0)
|
||||||
|
wp->modeprefix = np;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'X')) {
|
||||||
|
if (wp->mode == NULL || wp->mode->command == NULL) {
|
||||||
|
cmdq_error(item, "not in a mode");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (!m->valid)
|
||||||
|
wp->mode->command(wp, c, s, args, NULL);
|
||||||
|
else
|
||||||
|
wp->mode->command(wp, c, s, args, m);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'M')) {
|
||||||
|
wp = cmd_mouse_pane(m, &s, NULL);
|
||||||
|
if (wp == NULL) {
|
||||||
|
cmdq_error(item, "no mouse target");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
window_pane_key(wp, NULL, s, m->key, m);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (self->entry == &cmd_send_prefix_entry) {
|
if (self->entry == &cmd_send_prefix_entry) {
|
||||||
if (args_has(args, '2'))
|
if (args_has(args, '2'))
|
||||||
key = options_get_number(&s->options, "prefix2");
|
key = options_get_number(s->options, "prefix2");
|
||||||
else
|
else
|
||||||
key = options_get_number(&s->options, "prefix");
|
key = options_get_number(s->options, "prefix");
|
||||||
window_pane_key(wp, s, key);
|
window_pane_key(wp, NULL, s, key, NULL);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 'R')) {
|
if (args_has(args, 'R')) {
|
||||||
ictx = &wp->ictx;
|
window_pane_reset_palette(wp);
|
||||||
|
input_reset(wp, 1);
|
||||||
memcpy(&ictx->cell, &grid_default_cell, sizeof ictx->cell);
|
|
||||||
memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell);
|
|
||||||
ictx->old_cx = 0;
|
|
||||||
ictx->old_cy = 0;
|
|
||||||
|
|
||||||
if (wp->mode == NULL)
|
|
||||||
screen_write_start(&ictx->ctx, wp, &wp->base);
|
|
||||||
else
|
|
||||||
screen_write_start(&ictx->ctx, NULL, &wp->base);
|
|
||||||
screen_write_reset(&ictx->ctx);
|
|
||||||
screen_write_stop(&ictx->ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < args->argc; i++) {
|
for (; np != 0; np--) {
|
||||||
str = args->argv[i];
|
for (i = 0; i < args->argc; i++) {
|
||||||
|
literal = args_has(args, 'l');
|
||||||
if (!args_has(args, 'l') &&
|
if (!literal) {
|
||||||
(key = key_string_lookup_string(str)) != KEYC_NONE) {
|
key = key_string_lookup_string(args->argv[i]);
|
||||||
window_pane_key(wp, s, key);
|
if (key != KEYC_NONE && key != KEYC_UNKNOWN)
|
||||||
} else {
|
window_pane_key(wp, NULL, s, key, NULL);
|
||||||
for (; *str != '\0'; str++)
|
else
|
||||||
window_pane_key(wp, s, *str);
|
literal = 1;
|
||||||
|
}
|
||||||
|
if (literal) {
|
||||||
|
ud = utf8_fromcstr(args->argv[i]);
|
||||||
|
for (uc = ud; uc->size != 0; uc++) {
|
||||||
|
if (utf8_combine(uc, &wc) != UTF8_DONE)
|
||||||
|
continue;
|
||||||
|
window_pane_key(wp, NULL, s, wc, NULL);
|
||||||
|
}
|
||||||
|
free(ud);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
@@ -1,174 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 <sys/utsname.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Show various information about server.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum cmd_retval cmd_server_info_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_server_info_entry = {
|
|
||||||
"server-info", "info",
|
|
||||||
"", 0, 0,
|
|
||||||
"",
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_server_info_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_server_info_exec(unused struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct tty_term *term;
|
|
||||||
struct client *c;
|
|
||||||
struct session *s;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct window *w;
|
|
||||||
struct window_pane *wp;
|
|
||||||
struct tty_code *code;
|
|
||||||
const struct tty_term_code_entry *ent;
|
|
||||||
struct utsname un;
|
|
||||||
struct job *job;
|
|
||||||
struct grid *gd;
|
|
||||||
struct grid_line *gl;
|
|
||||||
u_int i, j, k, lines;
|
|
||||||
size_t size;
|
|
||||||
char out[80];
|
|
||||||
char *tim;
|
|
||||||
time_t t;
|
|
||||||
|
|
||||||
tim = ctime(&start_time);
|
|
||||||
*strchr(tim, '\n') = '\0';
|
|
||||||
cmdq_print(cmdq,
|
|
||||||
"tmux " VERSION ", pid %ld, started %s", (long) getpid(), tim);
|
|
||||||
cmdq_print(cmdq, "socket path %s, debug level %d", socket_path,
|
|
||||||
debug_level);
|
|
||||||
if (uname(&un) >= 0) {
|
|
||||||
cmdq_print(cmdq, "system is %s %s %s %s",
|
|
||||||
un.sysname, un.release, un.version, un.machine);
|
|
||||||
}
|
|
||||||
if (cfg_file != NULL)
|
|
||||||
cmdq_print(cmdq, "configuration file is %s", cfg_file);
|
|
||||||
else
|
|
||||||
cmdq_print(cmdq, "configuration file not specified");
|
|
||||||
cmdq_print(cmdq, "protocol version is %d", PROTOCOL_VERSION);
|
|
||||||
cmdq_print(cmdq, "%s", "");
|
|
||||||
|
|
||||||
cmdq_print(cmdq, "Clients:");
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
|
||||||
c = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c == NULL || c->session == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
cmdq_print(cmdq,"%2d: %s (%d, %d): %s [%ux%u %s bs=%hho "
|
|
||||||
"class=%u] [flags=0x%x/0x%x, references=%u]", i,
|
|
||||||
c->tty.path, c->ibuf.fd, c->tty.fd, c->session->name,
|
|
||||||
c->tty.sx, c->tty.sy, c->tty.termname,
|
|
||||||
c->tty.tio.c_cc[VERASE], c->tty.class,
|
|
||||||
c->flags, c->tty.flags, c->references);
|
|
||||||
}
|
|
||||||
cmdq_print(cmdq, "%s", "");
|
|
||||||
|
|
||||||
cmdq_print(cmdq, "Sessions: [%zu]", sizeof (struct grid_cell));
|
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
|
||||||
t = s->creation_time.tv_sec;
|
|
||||||
tim = ctime(&t);
|
|
||||||
*strchr(tim, '\n') = '\0';
|
|
||||||
|
|
||||||
cmdq_print(cmdq, "%2u: %s: %u windows (created %s) [%ux%u] "
|
|
||||||
"[flags=0x%x]", s->id, s->name,
|
|
||||||
winlink_count(&s->windows), tim, s->sx, s->sy, s->flags);
|
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
|
||||||
w = wl->window;
|
|
||||||
cmdq_print(cmdq, "%4u: %s [%ux%u] [flags=0x%x, "
|
|
||||||
"references=%u, last layout=%d]", wl->idx, w->name,
|
|
||||||
w->sx, w->sy, w->flags, w->references,
|
|
||||||
w->lastlayout);
|
|
||||||
j = 0;
|
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
|
||||||
lines = size = 0;
|
|
||||||
gd = wp->base.grid;
|
|
||||||
for (k = 0; k < gd->hsize + gd->sy; k++) {
|
|
||||||
gl = &gd->linedata[k];
|
|
||||||
if (gl->celldata == NULL)
|
|
||||||
continue;
|
|
||||||
lines++;
|
|
||||||
size += gl->cellsize *
|
|
||||||
sizeof *gl->celldata;
|
|
||||||
}
|
|
||||||
cmdq_print(cmdq,
|
|
||||||
"%6u: %s %lu %d %u/%u, %zu bytes", j,
|
|
||||||
wp->tty, (u_long) wp->pid, wp->fd, lines,
|
|
||||||
gd->hsize + gd->sy, size);
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmdq_print(cmdq, "%s", "");
|
|
||||||
|
|
||||||
cmdq_print(cmdq, "Terminals:");
|
|
||||||
LIST_FOREACH(term, &tty_terms, entry) {
|
|
||||||
cmdq_print(cmdq, "%s [references=%u, flags=0x%x]:",
|
|
||||||
term->name, term->references, term->flags);
|
|
||||||
for (i = 0; i < NTTYCODE; i++) {
|
|
||||||
ent = &tty_term_codes[i];
|
|
||||||
code = &term->codes[ent->code];
|
|
||||||
switch (code->type) {
|
|
||||||
case TTYCODE_NONE:
|
|
||||||
cmdq_print(cmdq, "%2u: %s: [missing]",
|
|
||||||
ent->code, ent->name);
|
|
||||||
break;
|
|
||||||
case TTYCODE_STRING:
|
|
||||||
strnvis(out, code->value.string, sizeof out,
|
|
||||||
VIS_OCTAL|VIS_TAB|VIS_NL);
|
|
||||||
cmdq_print(cmdq, "%2u: %s: (string) %s",
|
|
||||||
ent->code, ent->name, out);
|
|
||||||
break;
|
|
||||||
case TTYCODE_NUMBER:
|
|
||||||
cmdq_print(cmdq, "%2u: %s: (number) %d",
|
|
||||||
ent->code, ent->name, code->value.number);
|
|
||||||
break;
|
|
||||||
case TTYCODE_FLAG:
|
|
||||||
cmdq_print(cmdq, "%2u: %s: (flag) %s",
|
|
||||||
ent->code, ent->name,
|
|
||||||
code->value.flag ? "true" : "false");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmdq_print(cmdq, "%s", "");
|
|
||||||
|
|
||||||
cmdq_print(cmdq, "Jobs:");
|
|
||||||
LIST_FOREACH(job, &all_jobs, lentry) {
|
|
||||||
cmdq_print(cmdq, "%s [fd=%d, pid=%d, status=%d]",
|
|
||||||
job->cmd, job->fd, job->pid, job->status);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
113
cmd-set-buffer.c
113
cmd-set-buffer.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -24,51 +24,98 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add or set a paste buffer.
|
* Add, set, append to or delete a paste buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_set_buffer_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_set_buffer_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_buffer_entry = {
|
const struct cmd_entry cmd_set_buffer_entry = {
|
||||||
"set-buffer", "setb",
|
.name = "set-buffer",
|
||||||
"b:", 1, 1,
|
.alias = "setb",
|
||||||
CMD_BUFFER_USAGE " data",
|
|
||||||
0,
|
.args = { "ab:n:", 0, 1 },
|
||||||
NULL,
|
.usage = "[-a] " CMD_BUFFER_USAGE " [-n new-buffer-name] data",
|
||||||
NULL,
|
|
||||||
cmd_set_buffer_exec
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_set_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
const struct cmd_entry cmd_delete_buffer_entry = {
|
||||||
cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
.name = "delete-buffer",
|
||||||
|
.alias = "deleteb",
|
||||||
|
|
||||||
|
.args = { "b:", 0, 0 },
|
||||||
|
.usage = CMD_BUFFER_USAGE,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_set_buffer_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
u_int limit;
|
struct paste_buffer *pb;
|
||||||
char *pdata, *cause;
|
char *bufdata, *cause;
|
||||||
size_t psize;
|
const char *bufname, *olddata;
|
||||||
int buffer;
|
size_t bufsize, newsize;
|
||||||
|
|
||||||
limit = options_get_number(&global_options, "buffer-limit");
|
bufname = args_get(args, 'b');
|
||||||
|
if (bufname == NULL)
|
||||||
|
pb = NULL;
|
||||||
|
else
|
||||||
|
pb = paste_get_name(bufname);
|
||||||
|
|
||||||
pdata = xstrdup(args->argv[0]);
|
if (self->entry == &cmd_delete_buffer_entry) {
|
||||||
psize = strlen(pdata);
|
if (pb == NULL)
|
||||||
|
pb = paste_get_top(&bufname);
|
||||||
if (!args_has(args, 'b')) {
|
if (pb == NULL) {
|
||||||
paste_add(&global_buffers, pdata, psize, limit);
|
cmdq_error(item, "no buffer");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
paste_free(pb);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
if (args_has(args, 'n')) {
|
||||||
if (cause != NULL) {
|
if (pb == NULL)
|
||||||
cmdq_error(cmdq, "buffer %s", cause);
|
pb = paste_get_top(&bufname);
|
||||||
free(cause);
|
if (pb == NULL) {
|
||||||
free(pdata);
|
cmdq_error(item, "no buffer");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (paste_rename(bufname, args_get(args, 'n'), &cause) != 0) {
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
if (args->argc != 1) {
|
||||||
cmdq_error(cmdq, "no buffer %d", buffer);
|
cmdq_error(item, "no data specified");
|
||||||
free(pdata);
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if ((newsize = strlen(args->argv[0])) == 0)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
bufsize = 0;
|
||||||
|
bufdata = NULL;
|
||||||
|
|
||||||
|
if (args_has(args, 'a') && pb != NULL) {
|
||||||
|
olddata = paste_buffer_data(pb, &bufsize);
|
||||||
|
bufdata = xmalloc(bufsize);
|
||||||
|
memcpy(bufdata, olddata, bufsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
bufdata = xrealloc(bufdata, bufsize + newsize);
|
||||||
|
memcpy(bufdata + bufsize, args->argv[0], newsize);
|
||||||
|
bufsize += newsize;
|
||||||
|
|
||||||
|
if (paste_set(bufdata, bufsize, bufname, &cause) != 0) {
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(bufdata);
|
||||||
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,33 +27,36 @@
|
|||||||
* Set an environment variable.
|
* Set an environment variable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_set_environment_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_set_environment_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_environment_entry = {
|
const struct cmd_entry cmd_set_environment_entry = {
|
||||||
"set-environment", "setenv",
|
.name = "set-environment",
|
||||||
"grt:u", 1, 2,
|
.alias = "setenv",
|
||||||
"[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
|
||||||
0,
|
.args = { "grt:u", 1, 2 },
|
||||||
NULL,
|
.usage = "[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
||||||
NULL,
|
|
||||||
cmd_set_environment_exec
|
.tflag = CMD_SESSION_CANFAIL,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_set_environment_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
|
||||||
struct environ *env;
|
struct environ *env;
|
||||||
const char *name, *value;
|
const char *name, *value, *target;
|
||||||
|
|
||||||
name = args->argv[0];
|
name = args->argv[0];
|
||||||
if (*name == '\0') {
|
if (*name == '\0') {
|
||||||
cmdq_error(cmdq, "empty variable name");
|
cmdq_error(item, "empty variable name");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (strchr(name, '=') != NULL) {
|
if (strchr(name, '=') != NULL) {
|
||||||
cmdq_error(cmdq, "variable name contains =");
|
cmdq_error(item, "variable name contains =");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,31 +66,37 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
value = args->argv[1];
|
value = args->argv[1];
|
||||||
|
|
||||||
if (args_has(self->args, 'g'))
|
if (args_has(self->args, 'g'))
|
||||||
env = &global_environ;
|
env = global_environ;
|
||||||
else {
|
else {
|
||||||
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
if (item->state.tflag.s == NULL) {
|
||||||
|
target = args_get(args, 't');
|
||||||
|
if (target != NULL)
|
||||||
|
cmdq_error(item, "no such session: %s", target);
|
||||||
|
else
|
||||||
|
cmdq_error(item, "no current session");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
env = &s->environ;
|
}
|
||||||
|
env = item->state.tflag.s->environ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'u')) {
|
if (args_has(self->args, 'u')) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
cmdq_error(cmdq, "can't specify a value with -u");
|
cmdq_error(item, "can't specify a value with -u");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_unset(env, name);
|
environ_unset(env, name);
|
||||||
} else if (args_has(self->args, 'r')) {
|
} else if (args_has(self->args, 'r')) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
cmdq_error(cmdq, "can't specify a value with -r");
|
cmdq_error(item, "can't specify a value with -r");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_set(env, name, NULL);
|
environ_clear(env, name);
|
||||||
} else {
|
} else {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
cmdq_error(cmdq, "no value specified");
|
cmdq_error(item, "no value specified");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_set(env, name, value);
|
environ_set(env, name, "%s", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
130
cmd-set-hook.c
Normal file
130
cmd-set-hook.c
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.org>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set or show global or session hooks.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_set_hook_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_set_hook_entry = {
|
||||||
|
.name = "set-hook",
|
||||||
|
.alias = NULL,
|
||||||
|
|
||||||
|
.args = { "gt:u", 1, 2 },
|
||||||
|
.usage = "[-gu] " CMD_TARGET_SESSION_USAGE " hook-name [command]",
|
||||||
|
|
||||||
|
.tflag = CMD_SESSION_CANFAIL,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_set_hook_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_show_hooks_entry = {
|
||||||
|
.name = "show-hooks",
|
||||||
|
.alias = NULL,
|
||||||
|
|
||||||
|
.args = { "gt:", 0, 1 },
|
||||||
|
.usage = "[-g] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
|
.tflag = CMD_SESSION,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_set_hook_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_set_hook_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
struct hooks *hooks;
|
||||||
|
struct hook *hook;
|
||||||
|
char *cause, *tmp;
|
||||||
|
const char *name, *cmd, *target;
|
||||||
|
|
||||||
|
if (args_has(args, 'g'))
|
||||||
|
hooks = global_hooks;
|
||||||
|
else {
|
||||||
|
if (item->state.tflag.s == NULL) {
|
||||||
|
target = args_get(args, 't');
|
||||||
|
if (target != NULL)
|
||||||
|
cmdq_error(item, "no such session: %s", target);
|
||||||
|
else
|
||||||
|
cmdq_error(item, "no current session");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
hooks = item->state.tflag.s->hooks;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self->entry == &cmd_show_hooks_entry) {
|
||||||
|
hook = hooks_first(hooks);
|
||||||
|
while (hook != NULL) {
|
||||||
|
tmp = cmd_list_print(hook->cmdlist);
|
||||||
|
cmdq_print(item, "%s -> %s", hook->name, tmp);
|
||||||
|
free(tmp);
|
||||||
|
|
||||||
|
hook = hooks_next(hook);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
name = args->argv[0];
|
||||||
|
if (*name == '\0') {
|
||||||
|
cmdq_error(item, "invalid hook name");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (args->argc < 2)
|
||||||
|
cmd = NULL;
|
||||||
|
else
|
||||||
|
cmd = args->argv[1];
|
||||||
|
|
||||||
|
if (args_has(args, 'u')) {
|
||||||
|
if (cmd != NULL) {
|
||||||
|
cmdq_error(item, "command passed to unset hook: %s",
|
||||||
|
name);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
hooks_remove(hooks, name);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd == NULL) {
|
||||||
|
cmdq_error(item, "no command to set hook: %s", name);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
hooks_add(hooks, name, cmdlist);
|
||||||
|
cmd_list_free(cmdlist);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
664
cmd-set-option.c
664
cmd-set-option.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,430 +27,366 @@
|
|||||||
* Set an option.
|
* Set an option.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
enum cmd_retval cmd_set_option_user(struct cmd *, struct cmd_q *,
|
static int cmd_set_option_set(struct cmd *, struct cmdq_item *,
|
||||||
const char *, const char *);
|
struct options *, struct options_entry *, const char *);
|
||||||
|
static int cmd_set_option_flag(struct cmdq_item *,
|
||||||
int cmd_set_option_unset(struct cmd *, struct cmd_q *,
|
const struct options_table_entry *, struct options *,
|
||||||
const struct options_table_entry *, struct options *,
|
const char *);
|
||||||
const char *);
|
static int cmd_set_option_choice(struct cmdq_item *,
|
||||||
int cmd_set_option_set(struct cmd *, struct cmd_q *,
|
const struct options_table_entry *, struct options *,
|
||||||
const struct options_table_entry *, struct options *,
|
const char *);
|
||||||
const char *);
|
|
||||||
|
|
||||||
struct options_entry *cmd_set_option_string(struct cmd *, struct cmd_q *,
|
|
||||||
const struct options_table_entry *, struct options *,
|
|
||||||
const char *);
|
|
||||||
struct options_entry *cmd_set_option_number(struct cmd *, struct cmd_q *,
|
|
||||||
const struct options_table_entry *, struct options *,
|
|
||||||
const char *);
|
|
||||||
struct options_entry *cmd_set_option_key(struct cmd *, struct cmd_q *,
|
|
||||||
const struct options_table_entry *, struct options *,
|
|
||||||
const char *);
|
|
||||||
struct options_entry *cmd_set_option_colour(struct cmd *, struct cmd_q *,
|
|
||||||
const struct options_table_entry *, struct options *,
|
|
||||||
const char *);
|
|
||||||
struct options_entry *cmd_set_option_attributes(struct cmd *, struct cmd_q *,
|
|
||||||
const struct options_table_entry *, struct options *,
|
|
||||||
const char *);
|
|
||||||
struct options_entry *cmd_set_option_flag(struct cmd *, struct cmd_q *,
|
|
||||||
const struct options_table_entry *, struct options *,
|
|
||||||
const char *);
|
|
||||||
struct options_entry *cmd_set_option_choice(struct cmd *, struct cmd_q *,
|
|
||||||
const struct options_table_entry *, struct options *,
|
|
||||||
const char *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_option_entry = {
|
const struct cmd_entry cmd_set_option_entry = {
|
||||||
"set-option", "set",
|
.name = "set-option",
|
||||||
"agoqst:uw", 1, 2,
|
.alias = "set",
|
||||||
"[-agosquw] [-t target-session|target-window] option [value]",
|
|
||||||
0,
|
.args = { "agoqst:uw", 1, 2 },
|
||||||
NULL,
|
.usage = "[-agosquw] [-t target-window] option [value]",
|
||||||
NULL,
|
|
||||||
cmd_set_option_exec
|
.tflag = CMD_WINDOW_CANFAIL,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_set_option_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_window_option_entry = {
|
const struct cmd_entry cmd_set_window_option_entry = {
|
||||||
"set-window-option", "setw",
|
.name = "set-window-option",
|
||||||
"agoqt:u", 1, 2,
|
.alias = "setw",
|
||||||
"[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
|
||||||
0,
|
.args = { "agoqt:u", 1, 2 },
|
||||||
NULL,
|
.usage = "[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
||||||
NULL,
|
|
||||||
cmd_set_option_exec
|
.tflag = CMD_WINDOW_CANFAIL,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_set_option_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
const struct options_table_entry *table, *oe;
|
int append = args_has(args, 'a');
|
||||||
struct session *s;
|
struct cmd_find_state *fs = &item->state.tflag;
|
||||||
struct winlink *wl;
|
struct session *s = fs->s;
|
||||||
struct client *c;
|
struct winlink *wl = fs->wl;
|
||||||
struct options *oo;
|
struct window *w;
|
||||||
struct window *w;
|
struct client *c;
|
||||||
const char *optstr, *valstr;
|
enum options_table_scope scope;
|
||||||
u_int i;
|
struct options *oo;
|
||||||
|
struct options_entry *parent, *o;
|
||||||
|
const char *name, *value, *target;
|
||||||
|
int window, idx, already, error, ambiguous;
|
||||||
|
char *cause;
|
||||||
|
|
||||||
/* Get the option name and value. */
|
/* Parse option name and index. */
|
||||||
optstr = args->argv[0];
|
name = options_match(args->argv[0], &idx, &ambiguous);
|
||||||
if (*optstr == '\0') {
|
if (name == NULL) {
|
||||||
cmdq_error(cmdq, "invalid option");
|
if (args_has(args, 'q'))
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
if (ambiguous)
|
||||||
|
cmdq_error(item, "ambiguous option: %s", args->argv[0]);
|
||||||
|
else
|
||||||
|
cmdq_error(item, "invalid option: %s", args->argv[0]);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (args->argc < 2)
|
if (args->argc < 2)
|
||||||
valstr = NULL;
|
value = NULL;
|
||||||
else
|
else
|
||||||
valstr = args->argv[1];
|
value = args->argv[1];
|
||||||
|
|
||||||
/* Is this a user option? */
|
/*
|
||||||
if (*optstr == '@')
|
* Figure out the scope: for user options it comes from the arguments,
|
||||||
return (cmd_set_option_user(self, cmdq, optstr, valstr));
|
* otherwise from the option name.
|
||||||
|
*/
|
||||||
/* Find the option entry, try each table. */
|
if (*name == '@') {
|
||||||
table = oe = NULL;
|
window = (self->entry == &cmd_set_window_option_entry);
|
||||||
if (options_table_find(optstr, &table, &oe) != 0) {
|
scope = options_scope_from_flags(args, window, fs, &oo, &cause);
|
||||||
cmdq_error(cmdq, "ambiguous option: %s", optstr);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
if (oe == NULL) {
|
|
||||||
cmdq_error(cmdq, "unknown option: %s", optstr);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Work out the tree from the table. */
|
|
||||||
if (table == server_options_table)
|
|
||||||
oo = &global_options;
|
|
||||||
else if (table == window_options_table) {
|
|
||||||
if (args_has(self->args, 'g'))
|
|
||||||
oo = &global_w_options;
|
|
||||||
else {
|
|
||||||
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
|
|
||||||
if (wl == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
oo = &wl->window->options;
|
|
||||||
}
|
|
||||||
} else if (table == session_options_table) {
|
|
||||||
if (args_has(self->args, 'g'))
|
|
||||||
oo = &global_s_options;
|
|
||||||
else {
|
|
||||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
|
||||||
if (s == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
oo = &s->options;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
cmdq_error(cmdq, "unknown table");
|
if (options_get_only(global_options, name) != NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
scope = OPTIONS_TABLE_SERVER;
|
||||||
|
else if (options_get_only(global_s_options, name) != NULL)
|
||||||
|
scope = OPTIONS_TABLE_SESSION;
|
||||||
|
else if (options_get_only(global_w_options, name) != NULL)
|
||||||
|
scope = OPTIONS_TABLE_WINDOW;
|
||||||
|
else {
|
||||||
|
scope = OPTIONS_TABLE_NONE;
|
||||||
|
xasprintf(&cause, "unknown option: %s", args->argv[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (scope == OPTIONS_TABLE_NONE) {
|
||||||
/* Unset or set the option. */
|
if (args_has(args, 'q'))
|
||||||
if (args_has(args, 'u')) {
|
|
||||||
if (cmd_set_option_unset(self, cmdq, oe, oo, valstr) != 0)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
} else {
|
|
||||||
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
|
|
||||||
if (!args_has(args, 'q'))
|
|
||||||
cmdq_print(cmdq, "already set: %s", optstr);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
cmdq_error(item, "%s", cause);
|
||||||
if (cmd_set_option_set(self, cmdq, oe, oo, valstr) != 0)
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Which table should this option go into? */
|
||||||
|
if (scope == OPTIONS_TABLE_SERVER)
|
||||||
|
oo = global_options;
|
||||||
|
else if (scope == OPTIONS_TABLE_SESSION) {
|
||||||
|
if (args_has(self->args, 'g'))
|
||||||
|
oo = global_s_options;
|
||||||
|
else if (s == NULL) {
|
||||||
|
target = args_get(args, 't');
|
||||||
|
if (target != NULL)
|
||||||
|
cmdq_error(item, "no such session: %s", target);
|
||||||
|
else
|
||||||
|
cmdq_error(item, "no current session");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
|
} else
|
||||||
|
oo = s->options;
|
||||||
|
} else if (scope == OPTIONS_TABLE_WINDOW) {
|
||||||
|
if (args_has(self->args, 'g'))
|
||||||
|
oo = global_w_options;
|
||||||
|
else if (wl == NULL) {
|
||||||
|
target = args_get(args, 't');
|
||||||
|
if (target != NULL)
|
||||||
|
cmdq_error(item, "no such window: %s", target);
|
||||||
|
else
|
||||||
|
cmdq_error(item, "no current window");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
} else
|
||||||
|
oo = wl->window->options;
|
||||||
}
|
}
|
||||||
|
o = options_get_only(oo, name);
|
||||||
|
parent = options_get(oo, name);
|
||||||
|
|
||||||
/* Start or stop timers when automatic-rename changed. */
|
/* Check that array options and indexes match up. */
|
||||||
if (strcmp (oe->name, "automatic-rename") == 0) {
|
if (idx != -1) {
|
||||||
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
|
if (*name == '@' || options_array_size(parent, NULL) == -1) {
|
||||||
if ((w = ARRAY_ITEM(&windows, i)) == NULL)
|
cmdq_error(item, "not an array: %s", args->argv[0]);
|
||||||
continue;
|
return (CMD_RETURN_ERROR);
|
||||||
if (options_get_number(&w->options, "automatic-rename"))
|
|
||||||
queue_window_name(w);
|
|
||||||
else if (event_initialized(&w->name_timer))
|
|
||||||
evtimer_del(&w->name_timer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update sizes and redraw. May not need it but meh. */
|
/* With -o, check this option is not already set. */
|
||||||
|
if (!args_has(args, 'u') && args_has(args, 'o')) {
|
||||||
|
if (idx == -1)
|
||||||
|
already = (o != NULL);
|
||||||
|
else {
|
||||||
|
if (o == NULL)
|
||||||
|
already = 0;
|
||||||
|
else
|
||||||
|
already = (options_array_get(o, idx) != NULL);
|
||||||
|
}
|
||||||
|
if (already) {
|
||||||
|
if (args_has(args, 'q'))
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
cmdq_error(item, "already set: %s", args->argv[0]);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Change the option. */
|
||||||
|
if (args_has(args, 'u')) {
|
||||||
|
if (o == NULL)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
if (idx == -1) {
|
||||||
|
if (oo == global_options ||
|
||||||
|
oo == global_s_options ||
|
||||||
|
oo == global_w_options)
|
||||||
|
options_default(oo, options_table_entry(o));
|
||||||
|
else
|
||||||
|
options_remove(o);
|
||||||
|
} else
|
||||||
|
options_array_set(o, idx, NULL, 0);
|
||||||
|
} else if (*name == '@') {
|
||||||
|
if (value == NULL) {
|
||||||
|
cmdq_error(item, "empty value");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
options_set_string(oo, name, append, "%s", value);
|
||||||
|
} else if (idx == -1 && options_array_size(parent, NULL) == -1) {
|
||||||
|
error = cmd_set_option_set(self, item, oo, parent, value);
|
||||||
|
if (error != 0)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
} else {
|
||||||
|
if (value == NULL) {
|
||||||
|
cmdq_error(item, "empty value");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (o == NULL)
|
||||||
|
o = options_empty(oo, options_table_entry(parent));
|
||||||
|
if (idx == -1) {
|
||||||
|
if (!append)
|
||||||
|
options_array_clear(o);
|
||||||
|
options_array_assign(o, value);
|
||||||
|
} else if (options_array_set(o, idx, value, append) != 0) {
|
||||||
|
cmdq_error(item, "invalid index: %s", args->argv[0]);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update timers and so on for various options. */
|
||||||
|
if (strcmp(name, "automatic-rename") == 0) {
|
||||||
|
RB_FOREACH(w, windows, &windows) {
|
||||||
|
if (w->active == NULL)
|
||||||
|
continue;
|
||||||
|
if (options_get_number(w->options, "automatic-rename"))
|
||||||
|
w->active->flags |= PANE_CHANGED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (strcmp(name, "key-table") == 0) {
|
||||||
|
TAILQ_FOREACH(c, &clients, entry)
|
||||||
|
server_client_set_key_table(c, NULL);
|
||||||
|
}
|
||||||
|
if (strcmp(name, "status") == 0 ||
|
||||||
|
strcmp(name, "status-interval") == 0)
|
||||||
|
status_timer_start_all();
|
||||||
|
if (strcmp(name, "monitor-silence") == 0)
|
||||||
|
alerts_reset_all();
|
||||||
|
if (strcmp(name, "window-style") == 0 ||
|
||||||
|
strcmp(name, "window-active-style") == 0) {
|
||||||
|
RB_FOREACH(w, windows, &windows)
|
||||||
|
w->flags |= WINDOW_STYLECHANGED;
|
||||||
|
}
|
||||||
|
if (strcmp(name, "pane-border-status") == 0) {
|
||||||
|
RB_FOREACH(w, windows, &windows)
|
||||||
|
layout_fix_panes(w, w->sx, w->sy);
|
||||||
|
}
|
||||||
|
RB_FOREACH (s, sessions, &sessions)
|
||||||
|
status_update_saved(s);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update sizes and redraw. May not always be necessary but do it
|
||||||
|
* anyway.
|
||||||
|
*/
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
if (c->session != NULL)
|
||||||
if (c != NULL && c->session != NULL)
|
|
||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set user option. */
|
static int
|
||||||
enum cmd_retval
|
cmd_set_option_set(struct cmd *self, struct cmdq_item *item, struct options *oo,
|
||||||
cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char* optstr,
|
struct options_entry *parent, const char *value)
|
||||||
const char *valstr)
|
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
const struct options_table_entry *oe;
|
||||||
struct session *s;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
int append = args_has(args, 'a');
|
||||||
struct options *oo;
|
struct options_entry *o;
|
||||||
|
long long number;
|
||||||
|
const char *errstr;
|
||||||
|
key_code key;
|
||||||
|
|
||||||
if (args_has(args, 's'))
|
oe = options_table_entry(parent);
|
||||||
oo = &global_options;
|
if (value == NULL &&
|
||||||
else if (args_has(self->args, 'w') ||
|
oe->type != OPTIONS_TABLE_FLAG &&
|
||||||
self->entry == &cmd_set_window_option_entry) {
|
oe->type != OPTIONS_TABLE_CHOICE) {
|
||||||
if (args_has(self->args, 'g'))
|
cmdq_error(item, "empty value");
|
||||||
oo = &global_w_options;
|
|
||||||
else {
|
|
||||||
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
|
|
||||||
if (wl == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
oo = &wl->window->options;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (args_has(self->args, 'g'))
|
|
||||||
oo = &global_s_options;
|
|
||||||
else {
|
|
||||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
|
||||||
if (s == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
oo = &s->options;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args_has(args, 'u')) {
|
|
||||||
if (options_find1(oo, optstr) == NULL) {
|
|
||||||
cmdq_error(cmdq, "unknown option: %s", optstr);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
if (valstr != NULL) {
|
|
||||||
cmdq_error(cmdq, "value passed to unset option: %s",
|
|
||||||
optstr);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
options_remove(oo, optstr);
|
|
||||||
} else {
|
|
||||||
if (valstr == NULL) {
|
|
||||||
cmdq_error(cmdq, "empty value");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
|
|
||||||
if (!args_has(args, 'q'))
|
|
||||||
cmdq_print(cmdq, "already set: %s", optstr);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
options_set_string(oo, optstr, "%s", valstr);
|
|
||||||
if (!args_has(args, 'q')) {
|
|
||||||
cmdq_info(cmdq, "set option: %s -> %s", optstr,
|
|
||||||
valstr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Unset an option. */
|
|
||||||
int
|
|
||||||
cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq,
|
|
||||||
const struct options_table_entry *oe, struct options *oo, const char *value)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
|
|
||||||
if (args_has(args, 'g')) {
|
|
||||||
cmdq_error(cmdq, "can't unset global option: %s", oe->name);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (value != NULL) {
|
|
||||||
cmdq_error(cmdq, "value passed to unset option: %s", oe->name);
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
options_remove(oo, oe->name);
|
|
||||||
if (!args_has(args, 'q'))
|
|
||||||
cmdq_info(cmdq, "unset option: %s", oe->name);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set an option. */
|
|
||||||
int
|
|
||||||
cmd_set_option_set(struct cmd *self, struct cmd_q *cmdq,
|
|
||||||
const struct options_table_entry *oe, struct options *oo, const char *value)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct options_entry *o;
|
|
||||||
const char *s;
|
|
||||||
|
|
||||||
if (oe->type != OPTIONS_TABLE_FLAG && value == NULL) {
|
|
||||||
cmdq_error(cmdq, "empty value");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
o = NULL;
|
|
||||||
switch (oe->type) {
|
switch (oe->type) {
|
||||||
case OPTIONS_TABLE_STRING:
|
case OPTIONS_TABLE_STRING:
|
||||||
o = cmd_set_option_string(self, cmdq, oe, oo, value);
|
options_set_string(oo, oe->name, append, "%s", value);
|
||||||
break;
|
return (0);
|
||||||
case OPTIONS_TABLE_NUMBER:
|
case OPTIONS_TABLE_NUMBER:
|
||||||
o = cmd_set_option_number(self, cmdq, oe, oo, value);
|
number = strtonum(value, oe->minimum, oe->maximum, &errstr);
|
||||||
break;
|
if (errstr != NULL) {
|
||||||
|
cmdq_error(item, "value is %s: %s", errstr, value);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
options_set_number(oo, oe->name, number);
|
||||||
|
return (0);
|
||||||
case OPTIONS_TABLE_KEY:
|
case OPTIONS_TABLE_KEY:
|
||||||
o = cmd_set_option_key(self, cmdq, oe, oo, value);
|
key = key_string_lookup_string(value);
|
||||||
break;
|
if (key == KEYC_UNKNOWN) {
|
||||||
|
cmdq_error(item, "bad key: %s", value);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
options_set_number(oo, oe->name, key);
|
||||||
|
return (0);
|
||||||
case OPTIONS_TABLE_COLOUR:
|
case OPTIONS_TABLE_COLOUR:
|
||||||
o = cmd_set_option_colour(self, cmdq, oe, oo, value);
|
if ((number = colour_fromstring(value)) == -1) {
|
||||||
break;
|
cmdq_error(item, "bad colour: %s", value);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
o = options_set_number(oo, oe->name, number);
|
||||||
|
options_style_update_new(oo, o);
|
||||||
|
return (0);
|
||||||
case OPTIONS_TABLE_ATTRIBUTES:
|
case OPTIONS_TABLE_ATTRIBUTES:
|
||||||
o = cmd_set_option_attributes(self, cmdq, oe, oo, value);
|
if ((number = attributes_fromstring(value)) == -1) {
|
||||||
break;
|
cmdq_error(item, "bad attributes: %s", value);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
o = options_set_number(oo, oe->name, number);
|
||||||
|
options_style_update_new(oo, o);
|
||||||
|
return (0);
|
||||||
case OPTIONS_TABLE_FLAG:
|
case OPTIONS_TABLE_FLAG:
|
||||||
o = cmd_set_option_flag(self, cmdq, oe, oo, value);
|
return (cmd_set_option_flag(item, oe, oo, value));
|
||||||
break;
|
|
||||||
case OPTIONS_TABLE_CHOICE:
|
case OPTIONS_TABLE_CHOICE:
|
||||||
o = cmd_set_option_choice(self, cmdq, oe, oo, value);
|
return (cmd_set_option_choice(item, oe, oo, value));
|
||||||
|
case OPTIONS_TABLE_STYLE:
|
||||||
|
o = options_set_style(oo, oe->name, append, value);
|
||||||
|
if (o == NULL) {
|
||||||
|
cmdq_error(item, "bad style: %s", value);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
options_style_update_old(oo, o);
|
||||||
|
return (0);
|
||||||
|
case OPTIONS_TABLE_ARRAY:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (o == NULL)
|
return (-1);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
s = options_table_print_entry(oe, o, 0);
|
|
||||||
if (!args_has(args, 'q'))
|
|
||||||
cmdq_info(cmdq, "set option: %s -> %s", oe->name, s);
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set a string option. */
|
static int
|
||||||
struct options_entry *
|
cmd_set_option_flag(struct cmdq_item *item,
|
||||||
cmd_set_option_string(struct cmd *self, unused struct cmd_q *cmdq,
|
const struct options_table_entry *oe, struct options *oo,
|
||||||
const struct options_table_entry *oe, struct options *oo, const char *value)
|
const char *value)
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct options_entry *o;
|
|
||||||
char *oldval, *newval;
|
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
|
||||||
oldval = options_get_string(oo, oe->name);
|
|
||||||
xasprintf(&newval, "%s%s", oldval, value);
|
|
||||||
} else
|
|
||||||
newval = xstrdup(value);
|
|
||||||
|
|
||||||
o = options_set_string(oo, oe->name, "%s", newval);
|
|
||||||
|
|
||||||
free(newval);
|
|
||||||
return (o);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set a number option. */
|
|
||||||
struct options_entry *
|
|
||||||
cmd_set_option_number(unused struct cmd *self, struct cmd_q *cmdq,
|
|
||||||
const struct options_table_entry *oe, struct options *oo, const char *value)
|
|
||||||
{
|
|
||||||
long long ll;
|
|
||||||
const char *errstr;
|
|
||||||
|
|
||||||
ll = strtonum(value, oe->minimum, oe->maximum, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
cmdq_error(cmdq, "value is %s: %s", errstr, value);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (options_set_number(oo, oe->name, ll));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set a key option. */
|
|
||||||
struct options_entry *
|
|
||||||
cmd_set_option_key(unused struct cmd *self, struct cmd_q *cmdq,
|
|
||||||
const struct options_table_entry *oe, struct options *oo, const char *value)
|
|
||||||
{
|
|
||||||
int key;
|
|
||||||
|
|
||||||
if ((key = key_string_lookup_string(value)) == KEYC_NONE) {
|
|
||||||
cmdq_error(cmdq, "bad key: %s", value);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (options_set_number(oo, oe->name, key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set a colour option. */
|
|
||||||
struct options_entry *
|
|
||||||
cmd_set_option_colour(unused struct cmd *self, struct cmd_q *cmdq,
|
|
||||||
const struct options_table_entry *oe, struct options *oo, const char *value)
|
|
||||||
{
|
|
||||||
int colour;
|
|
||||||
|
|
||||||
if ((colour = colour_fromstring(value)) == -1) {
|
|
||||||
cmdq_error(cmdq, "bad colour: %s", value);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (options_set_number(oo, oe->name, colour));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set an attributes option. */
|
|
||||||
struct options_entry *
|
|
||||||
cmd_set_option_attributes(unused struct cmd *self, struct cmd_q *cmdq,
|
|
||||||
const struct options_table_entry *oe, struct options *oo, const char *value)
|
|
||||||
{
|
|
||||||
int attr;
|
|
||||||
|
|
||||||
if ((attr = attributes_fromstring(value)) == -1) {
|
|
||||||
cmdq_error(cmdq, "bad attributes: %s", value);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (options_set_number(oo, oe->name, attr));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set a flag option. */
|
|
||||||
struct options_entry *
|
|
||||||
cmd_set_option_flag(unused struct cmd *self, struct cmd_q *cmdq,
|
|
||||||
const struct options_table_entry *oe, struct options *oo, const char *value)
|
|
||||||
{
|
{
|
||||||
int flag;
|
int flag;
|
||||||
|
|
||||||
if (value == NULL || *value == '\0')
|
if (value == NULL || *value == '\0')
|
||||||
flag = !options_get_number(oo, oe->name);
|
flag = !options_get_number(oo, oe->name);
|
||||||
|
else if (strcmp(value, "1") == 0 ||
|
||||||
|
strcasecmp(value, "on") == 0 ||
|
||||||
|
strcasecmp(value, "yes") == 0)
|
||||||
|
flag = 1;
|
||||||
|
else if (strcmp(value, "0") == 0 ||
|
||||||
|
strcasecmp(value, "off") == 0 ||
|
||||||
|
strcasecmp(value, "no") == 0)
|
||||||
|
flag = 0;
|
||||||
else {
|
else {
|
||||||
if ((value[0] == '1' && value[1] == '\0') ||
|
cmdq_error(item, "bad value: %s", value);
|
||||||
strcasecmp(value, "on") == 0 ||
|
return (-1);
|
||||||
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 {
|
|
||||||
cmdq_error(cmdq, "bad value: %s", value);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
options_set_number(oo, oe->name, flag);
|
||||||
return (options_set_number(oo, oe->name, flag));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set a choice option. */
|
static int
|
||||||
struct options_entry *
|
cmd_set_option_choice(struct cmdq_item *item,
|
||||||
cmd_set_option_choice(unused struct cmd *self, struct cmd_q *cmdq,
|
|
||||||
const struct options_table_entry *oe, struct options *oo,
|
const struct options_table_entry *oe, struct options *oo,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
const char **choicep;
|
const char **cp;
|
||||||
int n, choice = -1;
|
int n, choice = -1;
|
||||||
|
|
||||||
n = 0;
|
if (value == NULL) {
|
||||||
for (choicep = oe->choices; *choicep != NULL; choicep++) {
|
choice = options_get_number(oo, oe->name);
|
||||||
n++;
|
if (choice < 2)
|
||||||
if (strncmp(*choicep, value, strlen(value)) != 0)
|
choice = !choice;
|
||||||
continue;
|
} else {
|
||||||
|
n = 0;
|
||||||
if (choice != -1) {
|
for (cp = oe->choices; *cp != NULL; cp++) {
|
||||||
cmdq_error(cmdq, "ambiguous value: %s", value);
|
if (strcmp(*cp, value) == 0)
|
||||||
return (NULL);
|
choice = n;
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
if (choice == -1) {
|
||||||
|
cmdq_error(item, "unknown value: %s", value);
|
||||||
|
return (-1);
|
||||||
}
|
}
|
||||||
choice = n - 1;
|
|
||||||
}
|
}
|
||||||
if (choice == -1) {
|
options_set_number(oo, oe->name, choice);
|
||||||
cmdq_error(cmdq, "unknown value: %s", value);
|
return (0);
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (options_set_number(oo, oe->name, choice));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,53 +27,110 @@
|
|||||||
* Show environment.
|
* Show environment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_show_environment_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_show_environment_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
|
static char *cmd_show_environment_escape(struct environ_entry *);
|
||||||
|
static void cmd_show_environment_print(struct cmd *, struct cmdq_item *,
|
||||||
|
struct environ_entry *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_environment_entry = {
|
const struct cmd_entry cmd_show_environment_entry = {
|
||||||
"show-environment", "showenv",
|
.name = "show-environment",
|
||||||
"gt:", 0, 1,
|
.alias = "showenv",
|
||||||
"[-g] " CMD_TARGET_SESSION_USAGE " [name]",
|
|
||||||
0,
|
.args = { "gst:", 0, 1 },
|
||||||
NULL,
|
.usage = "[-gs] " CMD_TARGET_SESSION_USAGE " [name]",
|
||||||
NULL,
|
|
||||||
cmd_show_environment_exec
|
.tflag = CMD_SESSION_CANFAIL,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_show_environment_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static char *
|
||||||
cmd_show_environment_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_show_environment_escape(struct environ_entry *envent)
|
||||||
|
{
|
||||||
|
const char *value = envent->value;
|
||||||
|
char c, *out, *ret;
|
||||||
|
|
||||||
|
out = ret = xmalloc(strlen(value) * 2 + 1); /* at most twice the size */
|
||||||
|
while ((c = *value++) != '\0') {
|
||||||
|
/* POSIX interprets $ ` " and \ in double quotes. */
|
||||||
|
if (c == '$' || c == '`' || c == '"' || c == '\\')
|
||||||
|
*out++ = '\\';
|
||||||
|
*out++ = c;
|
||||||
|
}
|
||||||
|
*out = '\0';
|
||||||
|
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_show_environment_print(struct cmd *self, struct cmdq_item *item,
|
||||||
|
struct environ_entry *envent)
|
||||||
|
{
|
||||||
|
char *escaped;
|
||||||
|
|
||||||
|
if (!args_has(self->args, 's')) {
|
||||||
|
if (envent->value != NULL)
|
||||||
|
cmdq_print(item, "%s=%s", envent->name, envent->value);
|
||||||
|
else
|
||||||
|
cmdq_print(item, "-%s", envent->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (envent->value != NULL) {
|
||||||
|
escaped = cmd_show_environment_escape(envent);
|
||||||
|
cmdq_print(item, "%s=\"%s\"; export %s;", envent->name, escaped,
|
||||||
|
envent->name);
|
||||||
|
free(escaped);
|
||||||
|
} else
|
||||||
|
cmdq_print(item, "unset %s;", envent->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
|
||||||
struct environ *env;
|
struct environ *env;
|
||||||
struct environ_entry *envent;
|
struct environ_entry *envent;
|
||||||
|
const char *target;
|
||||||
|
|
||||||
|
if ((target = args_get(args, 't')) != NULL) {
|
||||||
|
if (item->state.tflag.s == NULL) {
|
||||||
|
cmdq_error(item, "no such session: %s", target);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'g'))
|
if (args_has(self->args, 'g'))
|
||||||
env = &global_environ;
|
env = global_environ;
|
||||||
else {
|
else {
|
||||||
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
if (item->state.tflag.s == NULL) {
|
||||||
|
target = args_get(args, 't');
|
||||||
|
if (target != NULL)
|
||||||
|
cmdq_error(item, "no such session: %s", target);
|
||||||
|
else
|
||||||
|
cmdq_error(item, "no current session");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
env = &s->environ;
|
}
|
||||||
|
env = item->state.tflag.s->environ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc != 0) {
|
if (args->argc != 0) {
|
||||||
envent = environ_find(env, args->argv[0]);
|
envent = environ_find(env, args->argv[0]);
|
||||||
if (envent == NULL) {
|
if (envent == NULL) {
|
||||||
cmdq_error(cmdq, "unknown variable: %s", args->argv[0]);
|
cmdq_error(item, "unknown variable: %s", args->argv[0]);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (envent->value != NULL)
|
cmd_show_environment_print(self, item, envent);
|
||||||
cmdq_print(cmdq, "%s=%s", envent->name, envent->value);
|
|
||||||
else
|
|
||||||
cmdq_print(cmdq, "-%s", envent->name);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_FOREACH(envent, environ, env) {
|
envent = environ_first(env);
|
||||||
if (envent->value != NULL)
|
while (envent != NULL) {
|
||||||
cmdq_print(cmdq, "%s=%s", envent->name, envent->value);
|
cmd_show_environment_print(self, item, envent);
|
||||||
else
|
envent = environ_next(envent);
|
||||||
cmdq_print(cmdq, "-%s", envent->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -27,37 +28,91 @@
|
|||||||
* Show client message log.
|
* Show client message log.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_show_messages_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_show_messages_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_messages_entry = {
|
const struct cmd_entry cmd_show_messages_entry = {
|
||||||
"show-messages", "showmsgs",
|
.name = "show-messages",
|
||||||
"t:", 0, 0,
|
.alias = "showmsgs",
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
|
||||||
0,
|
.args = { "JTt:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-JT] " CMD_TARGET_CLIENT_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_show_messages_exec
|
.tflag = CMD_CLIENT,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_show_messages_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static int cmd_show_messages_terminals(struct cmdq_item *, int);
|
||||||
cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq)
|
static int cmd_show_messages_jobs(struct cmdq_item *, int);
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmd_show_messages_terminals(struct cmdq_item *item, int blank)
|
||||||
|
{
|
||||||
|
struct tty_term *term;
|
||||||
|
u_int i, n;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
LIST_FOREACH(term, &tty_terms, entry) {
|
||||||
|
if (blank) {
|
||||||
|
cmdq_print(item, "%s", "");
|
||||||
|
blank = 0;
|
||||||
|
}
|
||||||
|
cmdq_print(item, "Terminal %u: %s [references=%u, flags=0x%x]:",
|
||||||
|
n, term->name, term->references, term->flags);
|
||||||
|
n++;
|
||||||
|
for (i = 0; i < tty_term_ncodes(); i++)
|
||||||
|
cmdq_print(item, "%s", tty_term_describe(term, i));
|
||||||
|
}
|
||||||
|
return (n != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmd_show_messages_jobs(struct cmdq_item *item, int blank)
|
||||||
|
{
|
||||||
|
struct job *job;
|
||||||
|
u_int n;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
LIST_FOREACH(job, &all_jobs, lentry) {
|
||||||
|
if (blank) {
|
||||||
|
cmdq_print(item, "%s", "");
|
||||||
|
blank = 0;
|
||||||
|
}
|
||||||
|
cmdq_print(item, "Job %u: %s [fd=%d, pid=%ld, status=%d]",
|
||||||
|
n, job->cmd, job->fd, (long)job->pid, job->status);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
return (n != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_show_messages_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c = item->state.c;
|
||||||
struct message_entry *msg;
|
struct message_entry *msg;
|
||||||
char *tim;
|
char *tim;
|
||||||
u_int i;
|
int done, blank;
|
||||||
|
|
||||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
done = blank = 0;
|
||||||
return (CMD_RETURN_ERROR);
|
if (args_has(args, 'T')) {
|
||||||
|
blank = cmd_show_messages_terminals(item, blank);
|
||||||
for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
|
done = 1;
|
||||||
msg = &ARRAY_ITEM(&c->message_log, i);
|
}
|
||||||
|
if (args_has(args, 'J')) {
|
||||||
|
cmd_show_messages_jobs(item, blank);
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
if (done)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(msg, &c->message_log, entry) {
|
||||||
tim = ctime(&msg->msg_time);
|
tim = ctime(&msg->msg_time);
|
||||||
*strchr(tim, '\n') = '\0';
|
*strchr(tim, '\n') = '\0';
|
||||||
|
|
||||||
cmdq_print(cmdq, "%s %s", tim, msg->msg);
|
cmdq_print(item, "%s %s", tim, msg->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,147 +27,153 @@
|
|||||||
* Show options.
|
* Show options.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
enum cmd_retval cmd_show_options_one(struct cmd *, struct cmd_q *,
|
static enum cmd_retval cmd_show_options_one(struct cmd *, struct cmdq_item *,
|
||||||
struct options *, int);
|
struct options *);
|
||||||
enum cmd_retval cmd_show_options_all(struct cmd *, struct cmd_q *,
|
static enum cmd_retval cmd_show_options_all(struct cmd *, struct cmdq_item *,
|
||||||
const struct options_table_entry *, struct options *);
|
struct options *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_options_entry = {
|
const struct cmd_entry cmd_show_options_entry = {
|
||||||
"show-options", "show",
|
.name = "show-options",
|
||||||
"gqst:vw", 0, 1,
|
.alias = "show",
|
||||||
"[-gqsvw] [-t target-session|target-window] [option]",
|
|
||||||
0,
|
.args = { "gqst:vw", 0, 1 },
|
||||||
NULL,
|
.usage = "[-gqsvw] [-t target-session|target-window] [option]",
|
||||||
NULL,
|
|
||||||
cmd_show_options_exec
|
.tflag = CMD_WINDOW_CANFAIL,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_show_options_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_window_options_entry = {
|
const struct cmd_entry cmd_show_window_options_entry = {
|
||||||
"show-window-options", "showw",
|
.name = "show-window-options",
|
||||||
"gvt:", 0, 1,
|
.alias = "showw",
|
||||||
"[-gv] " CMD_TARGET_WINDOW_USAGE " [option]",
|
|
||||||
0,
|
.args = { "gvt:", 0, 1 },
|
||||||
NULL,
|
.usage = "[-gv] " CMD_TARGET_WINDOW_USAGE " [option]",
|
||||||
NULL,
|
|
||||||
cmd_show_options_exec
|
.tflag = CMD_WINDOW_CANFAIL,
|
||||||
|
|
||||||
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_show_options_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct cmd_find_state *fs = &item->state.tflag;
|
||||||
struct winlink *wl;
|
struct options *oo;
|
||||||
const struct options_table_entry *table;
|
enum options_table_scope scope;
|
||||||
struct options *oo;
|
char *cause;
|
||||||
int quiet;
|
int window;
|
||||||
|
|
||||||
if (args_has(self->args, 's')) {
|
window = (self->entry == &cmd_show_window_options_entry);
|
||||||
oo = &global_options;
|
scope = options_scope_from_flags(args, window, fs, &oo, &cause);
|
||||||
table = server_options_table;
|
if (scope == OPTIONS_TABLE_NONE) {
|
||||||
} else if (args_has(self->args, 'w') ||
|
cmdq_error(item, "%s", cause);
|
||||||
self->entry == &cmd_show_window_options_entry) {
|
free(cause);
|
||||||
table = window_options_table;
|
return (CMD_RETURN_ERROR);
|
||||||
if (args_has(self->args, 'g'))
|
|
||||||
oo = &global_w_options;
|
|
||||||
else {
|
|
||||||
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
|
|
||||||
if (wl == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
oo = &wl->window->options;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
table = session_options_table;
|
|
||||||
if (args_has(self->args, 'g'))
|
|
||||||
oo = &global_s_options;
|
|
||||||
else {
|
|
||||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
|
||||||
if (s == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
oo = &s->options;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quiet = args_has(self->args, 'q');
|
|
||||||
if (args->argc == 0)
|
if (args->argc == 0)
|
||||||
return (cmd_show_options_all(self, cmdq, table, oo));
|
return (cmd_show_options_all(self, item, oo));
|
||||||
else
|
else
|
||||||
return (cmd_show_options_one(self, cmdq, oo, quiet));
|
return (cmd_show_options_one(self, item, oo));
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static void
|
||||||
cmd_show_options_one(struct cmd *self, struct cmd_q *cmdq,
|
cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
|
||||||
struct options *oo, int quiet)
|
struct options_entry *o, int idx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
const char *name;
|
||||||
const struct options_table_entry *table, *oe;
|
const char *value;
|
||||||
struct options_entry *o;
|
char *tmp, *escaped;
|
||||||
const char *optval;
|
u_int size, i;
|
||||||
|
|
||||||
if (*args->argv[0] == '@') {
|
if (idx != -1) {
|
||||||
if ((o = options_find1(oo, args->argv[0])) == NULL) {
|
xasprintf(&tmp, "%s[%d]", options_name(o), idx);
|
||||||
if (quiet)
|
name = tmp;
|
||||||
return (CMD_RETURN_NORMAL);
|
} else {
|
||||||
cmdq_error(cmdq, "unknown option: %s", args->argv[0]);
|
if (options_array_size(o, &size) != -1) {
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
if (options_array_get(o, i) == NULL)
|
||||||
|
continue;
|
||||||
|
cmd_show_options_print(self, item, o, i);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tmp = NULL;
|
||||||
|
name = options_name(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = options_tostring(o, idx, 0);
|
||||||
|
if (args_has(self->args, 'v'))
|
||||||
|
cmdq_print(item, "%s", value);
|
||||||
|
else if (options_isstring(o)) {
|
||||||
|
utf8_stravis(&escaped, value, VIS_OCTAL|VIS_TAB|VIS_NL|VIS_DQ);
|
||||||
|
cmdq_print(item, "%s \"%s\"", name, escaped);
|
||||||
|
free(escaped);
|
||||||
|
} else
|
||||||
|
cmdq_print(item, "%s %s", name, value);
|
||||||
|
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_show_options_one(struct cmd *self, struct cmdq_item *item,
|
||||||
|
struct options *oo)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct options_entry *o;
|
||||||
|
int idx, ambiguous;
|
||||||
|
const char *name = args->argv[0];
|
||||||
|
|
||||||
|
o = options_match_get(oo, name, &idx, 1, &ambiguous);
|
||||||
|
if (o == NULL) {
|
||||||
|
if (args_has(args, 'q'))
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
if (ambiguous) {
|
||||||
|
cmdq_error(item, "ambiguous option: %s", name);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (args_has(self->args, 'v'))
|
if (*name != '@' &&
|
||||||
cmdq_print(cmdq, "%s", o->str);
|
options_match_get(oo, name, &idx, 0, &ambiguous) != NULL)
|
||||||
else
|
return (CMD_RETURN_NORMAL);
|
||||||
cmdq_print(cmdq, "%s \"%s\"", o->name, o->str);
|
cmdq_error(item, "unknown option: %s", name);
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
table = oe = NULL;
|
|
||||||
if (options_table_find(args->argv[0], &table, &oe) != 0) {
|
|
||||||
cmdq_error(cmdq, "ambiguous option: %s", args->argv[0]);
|
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (oe == NULL) {
|
cmd_show_options_print(self, item, o, idx);
|
||||||
if (quiet)
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
cmdq_error(cmdq, "unknown option: %s", args->argv[0]);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
if ((o = options_find1(oo, oe->name)) == NULL)
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
optval = options_table_print_entry(oe, o, args_has(self->args, 'v'));
|
|
||||||
if (args_has(self->args, 'v'))
|
|
||||||
cmdq_print(cmdq, "%s", optval);
|
|
||||||
else
|
|
||||||
cmdq_print(cmdq, "%s %s", oe->name, optval);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_show_options_all(struct cmd *self, struct cmd_q *cmdq,
|
cmd_show_options_all(struct cmd *self, struct cmdq_item *item,
|
||||||
const struct options_table_entry *table, struct options *oo)
|
struct options *oo)
|
||||||
{
|
{
|
||||||
|
struct options_entry *o;
|
||||||
const struct options_table_entry *oe;
|
const struct options_table_entry *oe;
|
||||||
struct options_entry *o;
|
u_int size, idx;
|
||||||
const char *optval;
|
|
||||||
|
|
||||||
RB_FOREACH(o, options_tree, &oo->tree) {
|
o = options_first(oo);
|
||||||
if (*o->name == '@') {
|
while (o != NULL) {
|
||||||
if (args_has(self->args, 'v'))
|
oe = options_table_entry(o);
|
||||||
cmdq_print(cmdq, "%s", o->str);
|
if (oe != NULL && oe->style != NULL) {
|
||||||
else
|
o = options_next(o);
|
||||||
cmdq_print(cmdq, "%s \"%s\"", o->name, o->str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (oe = table; oe->name != NULL; oe++) {
|
|
||||||
if ((o = options_find1(oo, oe->name)) == NULL)
|
|
||||||
continue;
|
continue;
|
||||||
optval = options_table_print_entry(oe, o,
|
}
|
||||||
args_has(self->args, 'v'));
|
if (options_array_size(o, &size) == -1)
|
||||||
if (args_has(self->args, 'v'))
|
cmd_show_options_print(self, item, o, -1);
|
||||||
cmdq_print(cmdq, "%s", optval);
|
else {
|
||||||
else
|
for (idx = 0; idx < size; idx++) {
|
||||||
cmdq_print(cmdq, "%s %s", oe->name, optval);
|
if (options_array_get(o, idx) == NULL)
|
||||||
|
continue;
|
||||||
|
cmd_show_options_print(self, item, o, idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
o = options_next(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -18,7 +18,10 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <glob.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,83 +29,70 @@
|
|||||||
* Sources a configuration file.
|
* Sources a configuration file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
void cmd_source_file_show(struct cmd_q *);
|
static enum cmd_retval cmd_source_file_done(struct cmdq_item *, void *);
|
||||||
void cmd_source_file_done(struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_source_file_entry = {
|
const struct cmd_entry cmd_source_file_entry = {
|
||||||
"source-file", "source",
|
.name = "source-file",
|
||||||
"", 1, 1,
|
.alias = "source",
|
||||||
"path",
|
|
||||||
0,
|
.args = { "q", 1, 1 },
|
||||||
NULL,
|
.usage = "[-q] path",
|
||||||
NULL,
|
|
||||||
cmd_source_file_exec
|
.flags = 0,
|
||||||
|
.exec = cmd_source_file_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_source_file_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct cmd_q *cmdq1;
|
int quiet = args_has(args, 'q');
|
||||||
char *cause;
|
struct client *c = item->client;
|
||||||
|
struct cmdq_item *new_item;
|
||||||
|
enum cmd_retval retval;
|
||||||
|
char *pattern, *tmp;
|
||||||
|
const char *path = args->argv[0];
|
||||||
|
glob_t g;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
cmdq1 = cmdq_new(NULL);
|
if (*path == '/')
|
||||||
cmdq1->emptyfn = cmd_source_file_done;
|
pattern = xstrdup(path);
|
||||||
cmdq1->data = cmdq;
|
else {
|
||||||
|
utf8_stravis(&tmp, server_client_get_cwd(c), VIS_GLOB);
|
||||||
|
xasprintf(&pattern, "%s/%s", tmp, path);
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
log_debug("%s: %s", __func__, pattern);
|
||||||
|
|
||||||
switch (load_cfg(args->argv[0], cmdq1, &cause)) {
|
retval = CMD_RETURN_NORMAL;
|
||||||
case -1:
|
if (glob(pattern, 0, NULL, &g) != 0) {
|
||||||
if (cfg_references == 0) {
|
if (!quiet || errno != ENOENT) {
|
||||||
cmdq_free(cmdq1);
|
cmdq_error(item, "%s: %s", path, strerror(errno));
|
||||||
cmdq_error(cmdq, "%s", cause);
|
retval = CMD_RETURN_ERROR;
|
||||||
free(cause);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
}
|
||||||
ARRAY_ADD(&cfg_causes, cause);
|
free(pattern);
|
||||||
/* FALLTHROUGH */
|
return (retval);
|
||||||
case 0:
|
}
|
||||||
if (cfg_references == 0)
|
free(pattern);
|
||||||
cmd_source_file_show(cmdq);
|
|
||||||
cmdq_free(cmdq1);
|
for (i = 0; i < (u_int)g.gl_pathc; i++) {
|
||||||
return (CMD_RETURN_NORMAL);
|
if (load_cfg(g.gl_pathv[i], c, item, quiet) < 0)
|
||||||
|
retval = CMD_RETURN_ERROR;
|
||||||
|
}
|
||||||
|
if (cfg_finished) {
|
||||||
|
new_item = cmdq_get_callback(cmd_source_file_done, NULL);
|
||||||
|
cmdq_insert_after(item, new_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdq->references++;
|
globfree(&g);
|
||||||
cfg_references++;
|
return (retval);
|
||||||
|
|
||||||
cmdq_continue(cmdq1);
|
|
||||||
return (CMD_RETURN_WAIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_source_file_show(struct cmd_q *cmdq)
|
cmd_source_file_done(struct cmdq_item *item, __unused void *data)
|
||||||
{
|
{
|
||||||
u_int i;
|
cfg_print_causes(item);
|
||||||
char *cause;
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
|
|
||||||
cause = ARRAY_ITEM(&cfg_causes, i);
|
|
||||||
cmdq_print(cmdq, "%s", cause);
|
|
||||||
free(cause);
|
|
||||||
}
|
|
||||||
ARRAY_FREE(&cfg_causes);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_source_file_done(struct cmd_q *cmdq1)
|
|
||||||
{
|
|
||||||
struct cmd_q *cmdq = cmdq1->data;
|
|
||||||
|
|
||||||
cmdq_free(cmdq1);
|
|
||||||
|
|
||||||
cfg_references--;
|
|
||||||
|
|
||||||
if (cmdq_free(cmdq))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (cfg_references == 0)
|
|
||||||
cmd_source_file_show(cmdq);
|
|
||||||
cmdq_continue(cmdq);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -18,7 +18,10 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -27,63 +30,68 @@
|
|||||||
* Split a window (add a new pane).
|
* Split a window (add a new pane).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_split_window_key_binding(struct cmd *, int);
|
#define SPLIT_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||||
enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
static enum cmd_retval cmd_split_window_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_split_window_entry = {
|
const struct cmd_entry cmd_split_window_entry = {
|
||||||
"split-window", "splitw",
|
.name = "split-window",
|
||||||
"c:dF:l:hp:Pt:v", 0, 1,
|
.alias = "splitw",
|
||||||
"[-dhvP] [-c start-directory] [-F format] [-p percentage|-l size] "
|
|
||||||
CMD_TARGET_PANE_USAGE " [command]",
|
.args = { "bc:dfF:l:hp:Pt:v", 0, -1 },
|
||||||
0,
|
.usage = "[-bdfhvP] [-c start-directory] [-F format] "
|
||||||
cmd_split_window_key_binding,
|
"[-p percentage|-l size] " CMD_TARGET_PANE_USAGE " [command]",
|
||||||
NULL,
|
|
||||||
cmd_split_window_exec
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_split_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_split_window_key_binding(struct cmd *self, int key)
|
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
|
||||||
self->args = args_create(0);
|
|
||||||
if (key == '%')
|
|
||||||
args_set(self->args, 'h', NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct client *c = item->state.c;
|
||||||
struct winlink *wl;
|
struct session *s = item->state.tflag.s;
|
||||||
struct window *w;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct window_pane *wp, *new_wp = NULL;
|
struct window *w = wl->window;
|
||||||
struct environ env;
|
struct window_pane *wp = item->state.tflag.wp, *new_wp = NULL;
|
||||||
const char *cmd, *cwd, *shell;
|
struct environ *env;
|
||||||
char *cause, *new_cause;
|
const char *cmd, *path, *shell, *template, *cwd, *to_free;
|
||||||
|
char **argv, *cause, *new_cause, *cp;
|
||||||
u_int hlimit;
|
u_int hlimit;
|
||||||
int size, percentage;
|
int argc, size, percentage;
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
struct layout_cell *lc;
|
struct layout_cell *lc;
|
||||||
const char *template;
|
struct environ_entry *envent;
|
||||||
struct client *c;
|
struct cmd_find_state fs;
|
||||||
struct format_tree *ft;
|
|
||||||
char *cp;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
w = wl->window;
|
|
||||||
server_unzoom_window(w);
|
server_unzoom_window(w);
|
||||||
|
|
||||||
environ_init(&env);
|
if (args->argc == 0) {
|
||||||
environ_copy(&global_environ, &env);
|
cmd = options_get_string(s->options, "default-command");
|
||||||
environ_copy(&s->environ, &env);
|
if (cmd != NULL && *cmd != '\0') {
|
||||||
server_fill_environ(s, &env);
|
argc = 1;
|
||||||
|
argv = (char **)&cmd;
|
||||||
|
} else {
|
||||||
|
argc = 0;
|
||||||
|
argv = NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
argc = args->argc;
|
||||||
|
argv = args->argv;
|
||||||
|
}
|
||||||
|
|
||||||
if (args->argc == 0)
|
to_free = NULL;
|
||||||
cmd = options_get_string(&s->options, "default-command");
|
if (args_has(args, 'c')) {
|
||||||
|
cwd = args_get(args, 'c');
|
||||||
|
to_free = cwd = format_single(item, cwd, c, s, NULL, NULL);
|
||||||
|
} else if (item->client != NULL && item->client->session == NULL)
|
||||||
|
cwd = item->client->cwd;
|
||||||
else
|
else
|
||||||
cmd = args->argv[0];
|
cwd = s->cwd;
|
||||||
cwd = cmd_get_default_path(cmdq, args_get(args, 'c'));
|
|
||||||
|
|
||||||
type = LAYOUT_TOPBOTTOM;
|
type = LAYOUT_TOPBOTTOM;
|
||||||
if (args_has(args, 'h'))
|
if (args_has(args, 'h'))
|
||||||
@@ -111,22 +119,37 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
else
|
else
|
||||||
size = (wp->sx * percentage) / 100;
|
size = (wp->sx * percentage) / 100;
|
||||||
}
|
}
|
||||||
hlimit = options_get_number(&s->options, "history-limit");
|
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;
|
||||||
|
|
||||||
if ((lc = layout_split_pane(wp, type, size, 0)) == NULL) {
|
lc = layout_split_pane(wp, type, size, args_has(args, 'b'),
|
||||||
|
args_has(args, 'f'));
|
||||||
|
if (lc == NULL) {
|
||||||
cause = xstrdup("pane too small");
|
cause = xstrdup("pane too small");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
new_wp = window_add_pane(w, hlimit);
|
new_wp = window_add_pane(w, wp, args_has(args, 'b'), hlimit);
|
||||||
if (window_pane_spawn(
|
|
||||||
new_wp, cmd, shell, cwd, &env, s->tio, &cause) != 0)
|
|
||||||
goto error;
|
|
||||||
layout_assign_pane(lc, new_wp);
|
layout_assign_pane(lc, new_wp);
|
||||||
|
|
||||||
|
path = NULL;
|
||||||
|
if (item->client != NULL && item->client->session == NULL)
|
||||||
|
envent = environ_find(item->client->environ, "PATH");
|
||||||
|
else
|
||||||
|
envent = environ_find(s->environ, "PATH");
|
||||||
|
if (envent != NULL)
|
||||||
|
path = envent->value;
|
||||||
|
|
||||||
|
env = environ_for_session(s);
|
||||||
|
if (window_pane_spawn(new_wp, argc, argv, path, shell, cwd, env,
|
||||||
|
s->tio, &cause) != 0) {
|
||||||
|
environ_free(env);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
environ_free(env);
|
||||||
|
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
|
|
||||||
if (!args_has(args, 'd')) {
|
if (!args_has(args, 'd')) {
|
||||||
@@ -136,33 +159,37 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
} else
|
} else
|
||||||
server_status_session(s);
|
server_status_session(s);
|
||||||
|
|
||||||
environ_free(&env);
|
|
||||||
|
|
||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = SPLIT_WINDOW_TEMPLATE;
|
template = SPLIT_WINDOW_TEMPLATE;
|
||||||
|
cp = format_single(item, template, c, s, wl, new_wp);
|
||||||
ft = format_create();
|
cmdq_print(item, "%s", cp);
|
||||||
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
|
||||||
format_client(ft, c);
|
|
||||||
format_session(ft, s);
|
|
||||||
format_winlink(ft, s, wl);
|
|
||||||
format_window_pane(ft, new_wp);
|
|
||||||
|
|
||||||
cp = format_expand(ft, template);
|
|
||||||
cmdq_print(cmdq, "%s", cp);
|
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
format_free(ft);
|
|
||||||
}
|
}
|
||||||
notify_window_layout_changed(w);
|
notify_window("window-layout-changed", w);
|
||||||
|
|
||||||
|
if (to_free != NULL)
|
||||||
|
free((void *)to_free);
|
||||||
|
|
||||||
|
cmd_find_clear_state(&fs, NULL, 0);
|
||||||
|
fs.s = s;
|
||||||
|
fs.wl = wl;
|
||||||
|
fs.w = w;
|
||||||
|
fs.wp = new_wp;
|
||||||
|
cmd_find_log_state(__func__, &fs);
|
||||||
|
hooks_insert(s->hooks, item, &fs, "after-split-window");
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
environ_free(&env);
|
if (new_wp != NULL) {
|
||||||
if (new_wp != NULL)
|
layout_close_pane(new_wp);
|
||||||
window_remove_pane(w, new_wp);
|
window_remove_pane(w, new_wp);
|
||||||
cmdq_error(cmdq, "create pane failed: %s", cause);
|
}
|
||||||
|
cmdq_error(item, "create pane failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
|
|
||||||
|
if (to_free != NULL)
|
||||||
|
free((void *)to_free);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
192
cmd-string.c
192
cmd-string.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -31,14 +31,14 @@
|
|||||||
* Parse a command from a string.
|
* Parse a command from a string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_string_getc(const char *, size_t *);
|
static int cmd_string_getc(const char *, size_t *);
|
||||||
void cmd_string_ungetc(size_t *);
|
static void cmd_string_ungetc(size_t *);
|
||||||
void cmd_string_copy(char **, char *, size_t *);
|
static void cmd_string_copy(char **, char *, size_t *);
|
||||||
char *cmd_string_string(const char *, size_t *, char, int);
|
static char *cmd_string_string(const char *, size_t *, char, int);
|
||||||
char *cmd_string_variable(const char *, size_t *);
|
static char *cmd_string_variable(const char *, size_t *);
|
||||||
char *cmd_string_expand_tilde(const char *, size_t *);
|
static char *cmd_string_expand_tilde(const char *, size_t *);
|
||||||
|
|
||||||
int
|
static int
|
||||||
cmd_string_getc(const char *s, size_t *p)
|
cmd_string_getc(const char *s, size_t *p)
|
||||||
{
|
{
|
||||||
const u_char *ucs = s;
|
const u_char *ucs = s;
|
||||||
@@ -48,38 +48,21 @@ cmd_string_getc(const char *s, size_t *p)
|
|||||||
return (ucs[(*p)++]);
|
return (ucs[(*p)++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_string_ungetc(size_t *p)
|
cmd_string_ungetc(size_t *p)
|
||||||
{
|
{
|
||||||
(*p)--;
|
(*p)--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Parse command string. Returns -1 on error. If returning -1, cause is error
|
|
||||||
* string, or NULL for empty command.
|
|
||||||
*/
|
|
||||||
int
|
int
|
||||||
cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file,
|
cmd_string_split(const char *s, int *rargc, char ***rargv)
|
||||||
u_int line, char **cause)
|
|
||||||
{
|
{
|
||||||
size_t p;
|
size_t p = 0;
|
||||||
int ch, i, argc, rval;
|
int ch, argc = 0, append = 0;
|
||||||
char **argv, *buf, *t;
|
char **argv = NULL, *buf = NULL, *t;
|
||||||
const char *whitespace, *equals;
|
const char *whitespace, *equals;
|
||||||
size_t len;
|
size_t len = 0;
|
||||||
|
|
||||||
argv = NULL;
|
|
||||||
argc = 0;
|
|
||||||
|
|
||||||
buf = NULL;
|
|
||||||
len = 0;
|
|
||||||
|
|
||||||
*cause = NULL;
|
|
||||||
|
|
||||||
*cmdlist = NULL;
|
|
||||||
rval = -1;
|
|
||||||
|
|
||||||
p = 0;
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ch = cmd_string_getc(s, &p);
|
ch = cmd_string_getc(s, &p);
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
@@ -107,10 +90,11 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file,
|
|||||||
case ' ':
|
case ' ':
|
||||||
case '\t':
|
case '\t':
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, len + 1);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
argv = xrealloc(argv, argc + 1, sizeof *argv);
|
argv = xreallocarray(argv, argc + 1,
|
||||||
|
sizeof *argv);
|
||||||
argv[argc++] = buf;
|
argv[argc++] = buf;
|
||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
@@ -125,68 +109,88 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file,
|
|||||||
whitespace = argv[0] + strcspn(argv[0], " \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[0]);
|
environ_put(global_environ, argv[0]);
|
||||||
argc--;
|
argc--;
|
||||||
memmove(argv, argv + 1, argc * (sizeof *argv));
|
memmove(argv, argv + 1, argc * (sizeof *argv));
|
||||||
}
|
}
|
||||||
if (argc == 0)
|
goto done;
|
||||||
goto out;
|
|
||||||
|
|
||||||
*cmdlist = cmd_list_parse(argc, argv, file, line, cause);
|
|
||||||
if (*cmdlist == NULL)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
rval = 0;
|
|
||||||
goto out;
|
|
||||||
case '~':
|
case '~':
|
||||||
if (buf == NULL) {
|
if (buf != NULL) {
|
||||||
t = cmd_string_expand_tilde(s, &p);
|
append = 1;
|
||||||
if (t == NULL)
|
|
||||||
goto error;
|
|
||||||
cmd_string_copy(&buf, t, &len);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
t = cmd_string_expand_tilde(s, &p);
|
||||||
default:
|
if (t == NULL)
|
||||||
if (len >= SIZE_MAX - 2)
|
|
||||||
goto error;
|
goto error;
|
||||||
|
cmd_string_copy(&buf, t, &len);
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
break;
|
||||||
buf[len++] = ch;
|
default:
|
||||||
|
append = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (append) {
|
||||||
|
if (len >= SIZE_MAX - 2)
|
||||||
|
goto error;
|
||||||
|
buf = xrealloc(buf, len + 1);
|
||||||
|
buf[len++] = ch;
|
||||||
|
}
|
||||||
|
append = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
*rargc = argc;
|
||||||
|
*rargv = argv;
|
||||||
|
|
||||||
|
free(buf);
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (argv != NULL)
|
||||||
|
cmd_free_argv(argc, argv);
|
||||||
|
free(buf);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct cmd_list *
|
||||||
|
cmd_string_parse(const char *s, const char *file, u_int line, char **cause)
|
||||||
|
{
|
||||||
|
struct cmd_list *cmdlist = NULL;
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
|
|
||||||
|
*cause = NULL;
|
||||||
|
if (cmd_string_split(s, &argc, &argv) != 0)
|
||||||
|
goto error;
|
||||||
|
if (argc != 0) {
|
||||||
|
cmdlist = cmd_list_parse(argc, argv, file, line, cause);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
|
cmd_free_argv(argc, argv);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmd_free_argv(argc, argv);
|
||||||
|
return (cmdlist);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
xasprintf(cause, "invalid or unknown command: %s", s);
|
xasprintf(cause, "invalid or unknown command: %s", s);
|
||||||
|
return (NULL);
|
||||||
out:
|
|
||||||
free(buf);
|
|
||||||
|
|
||||||
if (argv != NULL) {
|
|
||||||
for (i = 0; i < argc; i++)
|
|
||||||
free(argv[i]);
|
|
||||||
free(argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (rval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cmd_string_copy(char **dst, char *src, size_t *len)
|
cmd_string_copy(char **dst, char *src, size_t *len)
|
||||||
{
|
{
|
||||||
size_t srclen;
|
size_t srclen;
|
||||||
|
|
||||||
srclen = strlen(src);
|
srclen = strlen(src);
|
||||||
|
|
||||||
*dst = xrealloc(*dst, 1, *len + srclen + 1);
|
*dst = xrealloc(*dst, *len + srclen + 1);
|
||||||
strlcpy(*dst + *len, src, srclen + 1);
|
strlcpy(*dst + *len, src, srclen + 1);
|
||||||
|
|
||||||
*len += srclen;
|
*len += srclen;
|
||||||
free(src);
|
free(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
@@ -231,11 +235,11 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
|||||||
|
|
||||||
if (len >= SIZE_MAX - 2)
|
if (len >= SIZE_MAX - 2)
|
||||||
goto error;
|
goto error;
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, len + 1);
|
||||||
buf[len++] = ch;
|
buf[len++] = ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, len + 1);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
return (buf);
|
return (buf);
|
||||||
|
|
||||||
@@ -244,7 +248,7 @@ error:
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static 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;
|
||||||
@@ -278,7 +282,7 @@ cmd_string_variable(const char *s, size_t *p)
|
|||||||
return (t);
|
return (t);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, len + 1);
|
||||||
buf[len++] = ch;
|
buf[len++] = ch;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -288,7 +292,7 @@ cmd_string_variable(const char *s, size_t *p)
|
|||||||
else {
|
else {
|
||||||
if (len >= SIZE_MAX - 3)
|
if (len >= SIZE_MAX - 3)
|
||||||
goto error;
|
goto error;
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, len + 1);
|
||||||
buf[len++] = ch;
|
buf[len++] = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,10 +303,10 @@ cmd_string_variable(const char *s, size_t *p)
|
|||||||
if (ch != EOF && fch != '{')
|
if (ch != EOF && fch != '{')
|
||||||
cmd_string_ungetc(p); /* ch */
|
cmd_string_ungetc(p); /* ch */
|
||||||
|
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, len + 1);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
envent = environ_find(&global_environ, buf);
|
envent = environ_find(global_environ, buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
if (envent == NULL)
|
if (envent == NULL)
|
||||||
return (xstrdup(""));
|
return (xstrdup(""));
|
||||||
@@ -313,31 +317,49 @@ error:
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static 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;
|
||||||
struct environ_entry *envent;
|
struct environ_entry *envent;
|
||||||
char *home, *path, *username;
|
char *home, *path, *user, *cp;
|
||||||
|
int last;
|
||||||
|
|
||||||
home = NULL;
|
home = NULL;
|
||||||
if (cmd_string_getc(s, p) == '/') {
|
|
||||||
envent = environ_find(&global_environ, "HOME");
|
last = cmd_string_getc(s, p);
|
||||||
|
if (last == EOF || last == '/' || last == ' '|| last == '\t') {
|
||||||
|
envent = environ_find(global_environ, "HOME");
|
||||||
if (envent != NULL && *envent->value != '\0')
|
if (envent != NULL && *envent->value != '\0')
|
||||||
home = envent->value;
|
home = envent->value;
|
||||||
else if ((pw = getpwuid(getuid())) != NULL)
|
else if ((pw = getpwuid(getuid())) != NULL)
|
||||||
home = pw->pw_dir;
|
home = pw->pw_dir;
|
||||||
} else {
|
} else {
|
||||||
cmd_string_ungetc(p);
|
cmd_string_ungetc(p);
|
||||||
if ((username = cmd_string_string(s, p, '/', 0)) == NULL)
|
|
||||||
return (NULL);
|
cp = user = xmalloc(strlen(s));
|
||||||
if ((pw = getpwnam(username)) != NULL)
|
for (;;) {
|
||||||
|
last = cmd_string_getc(s, p);
|
||||||
|
if (last == EOF ||
|
||||||
|
last == '/' ||
|
||||||
|
last == ' '||
|
||||||
|
last == '\t')
|
||||||
|
break;
|
||||||
|
*cp++ = last;
|
||||||
|
}
|
||||||
|
*cp = '\0';
|
||||||
|
|
||||||
|
if ((pw = getpwnam(user)) != NULL)
|
||||||
home = pw->pw_dir;
|
home = pw->pw_dir;
|
||||||
free(username);
|
free(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (home == NULL)
|
if (home == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
xasprintf(&path, "%s/", home);
|
if (last != EOF)
|
||||||
|
xasprintf(&path, "%s%c", home, last);
|
||||||
|
else
|
||||||
|
xasprintf(&path, "%s", home);
|
||||||
return (path);
|
return (path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Suspend client with SIGTSTP.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum cmd_retval cmd_suspend_client_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_suspend_client_entry = {
|
|
||||||
"suspend-client", "suspendc",
|
|
||||||
"t:", 0, 0,
|
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_suspend_client_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_suspend_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct client *c;
|
|
||||||
|
|
||||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
tty_stop_tty(&c->tty);
|
|
||||||
c->flags |= CLIENT_SUSPENDED;
|
|
||||||
server_write_client(c, MSG_SUSPEND, NULL, 0);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -26,62 +26,46 @@
|
|||||||
* Swap two panes.
|
* Swap two panes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_swap_pane_key_binding(struct cmd *, int);
|
static enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_swap_pane_entry = {
|
const struct cmd_entry cmd_swap_pane_entry = {
|
||||||
"swap-pane", "swapp",
|
.name = "swap-pane",
|
||||||
"dDs:t:U", 0, 0,
|
.alias = "swapp",
|
||||||
"[-dDU] " CMD_SRCDST_PANE_USAGE,
|
|
||||||
0,
|
.args = { "dDs:t:U", 0, 0 },
|
||||||
cmd_swap_pane_key_binding,
|
.usage = "[-dDU] " CMD_SRCDST_PANE_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_swap_pane_exec
|
.sflag = CMD_PANE_MARKED,
|
||||||
|
.tflag = CMD_PANE,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_swap_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_swap_pane_key_binding(struct cmd *self, int key)
|
cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
self->args = args_create(0);
|
|
||||||
if (key == '{')
|
|
||||||
args_set(self->args, 'U', NULL);
|
|
||||||
else if (key == '}')
|
|
||||||
args_set(self->args, 'D', NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct winlink *src_wl, *dst_wl;
|
|
||||||
struct window *src_w, *dst_w;
|
struct window *src_w, *dst_w;
|
||||||
struct window_pane *tmp_wp, *src_wp, *dst_wp;
|
struct window_pane *tmp_wp, *src_wp, *dst_wp;
|
||||||
struct layout_cell *src_lc, *dst_lc;
|
struct layout_cell *src_lc, *dst_lc;
|
||||||
u_int sx, sy, xoff, yoff;
|
u_int sx, sy, xoff, yoff;
|
||||||
|
|
||||||
dst_wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &dst_wp);
|
dst_w = item->state.tflag.wl->window;
|
||||||
if (dst_wl == NULL)
|
dst_wp = item->state.tflag.wp;
|
||||||
return (CMD_RETURN_ERROR);
|
src_w = item->state.sflag.wl->window;
|
||||||
dst_w = dst_wl->window;
|
src_wp = item->state.sflag.wp;
|
||||||
server_unzoom_window(dst_w);
|
server_unzoom_window(dst_w);
|
||||||
|
|
||||||
if (!args_has(args, 's')) {
|
if (args_has(self->args, 'D')) {
|
||||||
src_w = dst_w;
|
src_w = dst_w;
|
||||||
if (args_has(self->args, '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 (args_has(self->args, 'U')) {
|
||||||
} else if (args_has(self->args, 'U')) {
|
src_w = dst_w;
|
||||||
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||||
if (src_wp == NULL)
|
if (src_wp == NULL)
|
||||||
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
||||||
} else
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
} else {
|
|
||||||
src_wl = cmd_find_pane(cmdq, args_get(args, 's'), NULL, &src_wp);
|
|
||||||
if (src_wl == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
src_w = src_wl->window;
|
|
||||||
}
|
}
|
||||||
server_unzoom_window(src_w);
|
server_unzoom_window(src_w);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -26,49 +26,56 @@
|
|||||||
* Swap one window with another.
|
* Swap one window with another.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_swap_window_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_swap_window_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_swap_window_entry = {
|
const struct cmd_entry cmd_swap_window_entry = {
|
||||||
"swap-window", "swapw",
|
.name = "swap-window",
|
||||||
"ds:t:", 0, 0,
|
.alias = "swapw",
|
||||||
"[-d] " CMD_SRCDST_WINDOW_USAGE,
|
|
||||||
0,
|
.args = { "ds:t:", 0, 0 },
|
||||||
NULL,
|
.usage = "[-d] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
NULL,
|
|
||||||
cmd_swap_window_exec
|
.sflag = CMD_WINDOW_MARKED,
|
||||||
|
.tflag = CMD_WINDOW,
|
||||||
|
|
||||||
|
.flags = 0,
|
||||||
|
.exec = cmd_swap_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_swap_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_swap_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
|
||||||
const char *target_src, *target_dst;
|
|
||||||
struct session *src, *dst;
|
struct session *src, *dst;
|
||||||
struct session_group *sg_src, *sg_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_src, *w_dst;
|
||||||
|
|
||||||
target_src = args_get(args, 's');
|
wl_src = item->state.sflag.wl;
|
||||||
if ((wl_src = cmd_find_window(cmdq, target_src, &src)) == NULL)
|
src = item->state.sflag.s;
|
||||||
return (CMD_RETURN_ERROR);
|
sg_src = session_group_contains(src);
|
||||||
target_dst = args_get(args, 't');
|
|
||||||
if ((wl_dst = cmd_find_window(cmdq, target_dst, &dst)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
|
|
||||||
sg_src = session_group_find(src);
|
wl_dst = item->state.tflag.wl;
|
||||||
sg_dst = session_group_find(dst);
|
dst = item->state.tflag.s;
|
||||||
if (src != dst &&
|
sg_dst = session_group_contains(dst);
|
||||||
sg_src != NULL && sg_dst != NULL && sg_src == sg_dst) {
|
|
||||||
cmdq_error(cmdq, "can't move window, sessions are grouped");
|
if (src != dst && sg_src != NULL && sg_dst != NULL &&
|
||||||
|
sg_src == sg_dst) {
|
||||||
|
cmdq_error(item, "can't move window, sessions are grouped");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_dst->window == wl_src->window)
|
if (wl_dst->window == wl_src->window)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
w = wl_dst->window;
|
w_dst = wl_dst->window;
|
||||||
wl_dst->window = wl_src->window;
|
TAILQ_REMOVE(&w_dst->winlinks, wl_dst, wentry);
|
||||||
wl_src->window = w;
|
w_src = wl_src->window;
|
||||||
|
TAILQ_REMOVE(&w_src->winlinks, wl_src, wentry);
|
||||||
|
|
||||||
|
wl_dst->window = w_src;
|
||||||
|
TAILQ_INSERT_TAIL(&w_src->winlinks, wl_dst, wentry);
|
||||||
|
wl_src->window = w_dst;
|
||||||
|
TAILQ_INSERT_TAIL(&w_dst->winlinks, wl_src, wentry);
|
||||||
|
|
||||||
if (!args_has(self->args, 'd')) {
|
if (!args_has(self->args, 'd')) {
|
||||||
session_select(dst, wl_dst->idx);
|
session_select(dst, wl_dst->idx);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -27,88 +27,98 @@
|
|||||||
* Switch client to a different session.
|
* Switch client to a different session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_switch_client_key_binding(struct cmd *, int);
|
static enum cmd_retval cmd_switch_client_exec(struct cmd *,
|
||||||
enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_q *);
|
struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_switch_client_entry = {
|
const struct cmd_entry cmd_switch_client_entry = {
|
||||||
"switch-client", "switchc",
|
.name = "switch-client",
|
||||||
"lc:npt:r", 0, 0,
|
.alias = "switchc",
|
||||||
"[-lnpr] [-c target-client] [-t target-session]",
|
|
||||||
CMD_READONLY,
|
.args = { "lc:Enpt:rT:", 0, 0 },
|
||||||
cmd_switch_client_key_binding,
|
.usage = "[-Elnpr] [-c target-client] [-t target-session] "
|
||||||
NULL,
|
"[-T key-table]",
|
||||||
cmd_switch_client_exec
|
|
||||||
|
.cflag = CMD_CLIENT,
|
||||||
|
.tflag = CMD_SESSION_WITHPANE,
|
||||||
|
|
||||||
|
.flags = CMD_READONLY,
|
||||||
|
.exec = cmd_switch_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static enum cmd_retval
|
||||||
cmd_switch_client_key_binding(struct cmd *self, int key)
|
cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
self->args = args_create(0);
|
struct args *args = self->args;
|
||||||
switch (key) {
|
struct cmd_state *state = &item->state;
|
||||||
case '(':
|
struct client *c = state->c;
|
||||||
args_set(self->args, 'p', NULL);
|
struct session *s = item->state.tflag.s;
|
||||||
break;
|
struct window_pane *wp;
|
||||||
case ')':
|
const char *tablename;
|
||||||
args_set(self->args, 'n', NULL);
|
struct key_table *table;
|
||||||
break;
|
|
||||||
case 'L':
|
|
||||||
args_set(self->args, 'l', NULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
if (args_has(args, 'r'))
|
||||||
cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
c->flags ^= CLIENT_READONLY;
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct client *c;
|
|
||||||
struct session *s;
|
|
||||||
|
|
||||||
if ((c = cmd_find_client(cmdq, args_get(args, 'c'), 0)) == NULL)
|
tablename = args_get(args, 'T');
|
||||||
return (CMD_RETURN_ERROR);
|
if (tablename != NULL) {
|
||||||
|
table = key_bindings_get_table(tablename, 0);
|
||||||
if (args_has(args, 'r')) {
|
if (table == NULL) {
|
||||||
if (c->flags & CLIENT_READONLY) {
|
cmdq_error(item, "table %s doesn't exist", tablename);
|
||||||
c->flags &= ~CLIENT_READONLY;
|
return (CMD_RETURN_ERROR);
|
||||||
cmdq_info(cmdq, "made client writable");
|
|
||||||
} else {
|
|
||||||
c->flags |= CLIENT_READONLY;
|
|
||||||
cmdq_info(cmdq, "made client read-only");
|
|
||||||
}
|
}
|
||||||
|
table->references++;
|
||||||
|
key_bindings_unref_table(c->keytable);
|
||||||
|
c->keytable = table;
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
s = NULL;
|
|
||||||
if (args_has(args, 'n')) {
|
if (args_has(args, 'n')) {
|
||||||
if ((s = session_next_session(c->session)) == NULL) {
|
if ((s = session_next_session(c->session)) == NULL) {
|
||||||
cmdq_error(cmdq, "can't find next session");
|
cmdq_error(item, "can't find next session");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'p')) {
|
} else if (args_has(args, 'p')) {
|
||||||
if ((s = session_previous_session(c->session)) == NULL) {
|
if ((s = session_previous_session(c->session)) == NULL) {
|
||||||
cmdq_error(cmdq, "can't find previous session");
|
cmdq_error(item, "can't find previous session");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'l')) {
|
} else if (args_has(args, 'l')) {
|
||||||
if (c->last_session != NULL && session_alive(c->last_session))
|
if (c->last_session != NULL && session_alive(c->last_session))
|
||||||
s = c->last_session;
|
s = c->last_session;
|
||||||
|
else
|
||||||
|
s = NULL;
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
cmdq_error(cmdq, "can't find last session");
|
cmdq_error(item, "can't find last session");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
if (item->client == NULL)
|
||||||
if (s == NULL)
|
return (CMD_RETURN_NORMAL);
|
||||||
return (CMD_RETURN_ERROR);
|
if (state->tflag.wl != NULL) {
|
||||||
|
wp = state->tflag.wp;
|
||||||
|
if (wp != NULL)
|
||||||
|
window_set_active_pane(wp->window, wp);
|
||||||
|
session_set_current(s, state->tflag.wl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (c->session != NULL)
|
if (!args_has(args, 'E'))
|
||||||
|
environ_update(s->options, c->environ, s->environ);
|
||||||
|
|
||||||
|
if (c->session != NULL && c->session != s)
|
||||||
c->last_session = c->session;
|
c->last_session = c->session;
|
||||||
c->session = s;
|
c->session = s;
|
||||||
session_update_activity(s);
|
if (!item->repeat)
|
||||||
|
server_client_set_key_table(c, NULL);
|
||||||
|
status_timer_start(c);
|
||||||
|
session_update_activity(s, NULL);
|
||||||
|
gettimeofday(&s->last_attached_time, NULL);
|
||||||
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_check_unattached();
|
server_check_unattached();
|
||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
|
alerts_check_session(s);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
126
cmd-unbind-key.c
126
cmd-unbind-key.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -26,91 +26,69 @@
|
|||||||
* Unbind key from command.
|
* Unbind key from command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_unbind_key_check(struct args *);
|
static enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmdq_item *);
|
||||||
enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmd_q *);
|
|
||||||
enum cmd_retval cmd_unbind_key_table(struct cmd *, struct cmd_q *, int);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_unbind_key_entry = {
|
const struct cmd_entry cmd_unbind_key_entry = {
|
||||||
"unbind-key", "unbind",
|
.name = "unbind-key",
|
||||||
"acnt:", 0, 1,
|
.alias = "unbind",
|
||||||
"[-acn] [-t key-table] key",
|
|
||||||
0,
|
.args = { "anT:", 0, 1 },
|
||||||
NULL,
|
.usage = "[-an] [-T key-table] key",
|
||||||
cmd_unbind_key_check,
|
|
||||||
cmd_unbind_key_exec
|
.flags = CMD_AFTERHOOK,
|
||||||
|
.exec = cmd_unbind_key_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_unbind_key_check(struct args *args)
|
cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
if (args_has(args, 'a') && args->argc != 0)
|
struct args *args = self->args;
|
||||||
return (CMD_RETURN_ERROR);
|
key_code key;
|
||||||
if (!args_has(args, 'a') && args->argc != 1)
|
const char *tablename;
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct key_binding *bd;
|
|
||||||
int key;
|
|
||||||
|
|
||||||
if (!args_has(args, 'a')) {
|
if (!args_has(args, 'a')) {
|
||||||
key = key_string_lookup_string(args->argv[0]);
|
if (args->argc != 1) {
|
||||||
if (key == KEYC_NONE) {
|
cmdq_error(item, "missing key");
|
||||||
cmdq_error(cmdq, "unknown key: %s", args->argv[0]);
|
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else
|
key = key_string_lookup_string(args->argv[0]);
|
||||||
key = KEYC_NONE;
|
if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
|
||||||
|
cmdq_error(item, "unknown key: %s", args->argv[0]);
|
||||||
if (args_has(args, 't'))
|
return (CMD_RETURN_ERROR);
|
||||||
return (cmd_unbind_key_table(self, cmdq, key));
|
|
||||||
|
|
||||||
if (key == KEYC_NONE) {
|
|
||||||
while (!RB_EMPTY(&key_bindings)) {
|
|
||||||
bd = RB_ROOT(&key_bindings);
|
|
||||||
key_bindings_remove(bd->key);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (args->argc != 0) {
|
||||||
|
cmdq_error(item, "key given with -a");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
key = KEYC_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == KEYC_UNKNOWN) {
|
||||||
|
tablename = args_get(args, 'T');
|
||||||
|
if (tablename == NULL) {
|
||||||
|
key_bindings_remove_table("root");
|
||||||
|
key_bindings_remove_table("prefix");
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
if (key_bindings_get_table(tablename, 0) == NULL) {
|
||||||
|
cmdq_error(item, "table %s doesn't exist", tablename);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
key_bindings_remove_table(tablename);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args_has(args, 'n'))
|
if (args_has(args, 'T')) {
|
||||||
key |= KEYC_PREFIX;
|
tablename = args_get(args, 'T');
|
||||||
key_bindings_remove(key);
|
if (key_bindings_get_table(tablename, 0) == NULL) {
|
||||||
return (CMD_RETURN_NORMAL);
|
cmdq_error(item, "table %s doesn't exist", tablename);
|
||||||
}
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_unbind_key_table(struct cmd *self, struct cmd_q *cmdq, int key)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
const char *tablename;
|
|
||||||
const struct mode_key_table *mtab;
|
|
||||||
struct mode_key_binding *mbind, mtmp;
|
|
||||||
|
|
||||||
tablename = args_get(args, 't');
|
|
||||||
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
|
||||||
cmdq_error(cmdq, "unknown key table: %s", tablename);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key == KEYC_NONE) {
|
|
||||||
while (!RB_EMPTY(mtab->tree)) {
|
|
||||||
mbind = RB_ROOT(mtab->tree);
|
|
||||||
RB_REMOVE(mode_key_tree, mtab->tree, mbind);
|
|
||||||
free(mbind);
|
|
||||||
}
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
} else if (args_has(args, 'n'))
|
||||||
}
|
tablename = "root";
|
||||||
|
else
|
||||||
mtmp.key = key;
|
tablename = "prefix";
|
||||||
mtmp.mode = !!args_has(args, 'c');
|
key_bindings_remove(tablename, key);
|
||||||
if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {
|
|
||||||
RB_REMOVE(mode_key_tree, mtab->tree, mbind);
|
|
||||||
free(mbind);
|
|
||||||
}
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unlink a window, unless it would be destroyed by doing so (only one link).
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum cmd_retval cmd_unlink_window_exec(struct cmd *, struct cmd_q *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_unlink_window_entry = {
|
|
||||||
"unlink-window", "unlinkw",
|
|
||||||
"kt:", 0, 0,
|
|
||||||
"[-k] " CMD_TARGET_WINDOW_USAGE,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_unlink_window_exec
|
|
||||||
};
|
|
||||||
|
|
||||||
enum cmd_retval
|
|
||||||
cmd_unlink_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|
||||||
{
|
|
||||||
struct args *args = self->args;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct window *w;
|
|
||||||
struct session *s, *s2;
|
|
||||||
struct session_group *sg;
|
|
||||||
u_int references;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
w = wl->window;
|
|
||||||
|
|
||||||
sg = session_group_find(s);
|
|
||||||
if (sg != NULL) {
|
|
||||||
references = 0;
|
|
||||||
TAILQ_FOREACH(s2, &sg->sessions, gentry)
|
|
||||||
references++;
|
|
||||||
} else
|
|
||||||
references = 1;
|
|
||||||
|
|
||||||
if (!args_has(self->args, 'k') && w->references == references) {
|
|
||||||
cmdq_error(cmdq, "window is only linked to one session");
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
server_unlink_window(s, wl);
|
|
||||||
recalculate_sizes();
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
}
|
|
||||||
247
cmd-wait-for.c
247
cmd-wait-for.c
@@ -1,7 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
* Copyright (c) 2013 Thiago de Arruda <tpadilha84@gmail.com>
|
* Copyright (c) 2013 Thiago de Arruda <tpadilha84@gmail.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
@@ -28,51 +28,97 @@
|
|||||||
* Block or wake a client on a named wait channel.
|
* Block or wake a client on a named wait channel.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_wait_for_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_wait_for_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_wait_for_entry = {
|
const struct cmd_entry cmd_wait_for_entry = {
|
||||||
"wait-for", "wait",
|
.name = "wait-for",
|
||||||
"LSU", 1, 1,
|
.alias = "wait",
|
||||||
"[-LSU] channel",
|
|
||||||
0,
|
.args = { "LSU", 1, 1 },
|
||||||
NULL,
|
.usage = "[-L|-S|-U] channel",
|
||||||
NULL,
|
|
||||||
cmd_wait_for_exec
|
.flags = 0,
|
||||||
|
.exec = cmd_wait_for_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wait_item {
|
||||||
|
struct cmdq_item *item;
|
||||||
|
TAILQ_ENTRY(wait_item) entry;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wait_channel {
|
struct wait_channel {
|
||||||
const char *name;
|
const char *name;
|
||||||
int locked;
|
int locked;
|
||||||
|
int woken;
|
||||||
|
|
||||||
TAILQ_HEAD(, cmd_q) waiters;
|
TAILQ_HEAD(, wait_item) waiters;
|
||||||
TAILQ_HEAD(, cmd_q) lockers;
|
TAILQ_HEAD(, wait_item) lockers;
|
||||||
|
|
||||||
RB_ENTRY(wait_channel) entry;
|
RB_ENTRY(wait_channel) entry;
|
||||||
};
|
};
|
||||||
RB_HEAD(wait_channels, wait_channel);
|
RB_HEAD(wait_channels, wait_channel);
|
||||||
struct wait_channels wait_channels = RB_INITIALIZER(wait_channels);
|
static struct wait_channels wait_channels = RB_INITIALIZER(wait_channels);
|
||||||
|
|
||||||
int wait_channel_cmp(struct wait_channel *, struct wait_channel *);
|
static int wait_channel_cmp(struct wait_channel *, struct wait_channel *);
|
||||||
RB_PROTOTYPE(wait_channels, wait_channel, entry, wait_channel_cmp);
|
RB_GENERATE_STATIC(wait_channels, wait_channel, entry, wait_channel_cmp);
|
||||||
RB_GENERATE(wait_channels, wait_channel, entry, wait_channel_cmp);
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
wait_channel_cmp(struct wait_channel *wc1, struct wait_channel *wc2)
|
wait_channel_cmp(struct wait_channel *wc1, struct wait_channel *wc2)
|
||||||
{
|
{
|
||||||
return (strcmp(wc1->name, wc2->name));
|
return (strcmp(wc1->name, wc2->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval cmd_wait_for_signal(struct cmd_q *, const char *,
|
static enum cmd_retval cmd_wait_for_signal(struct cmdq_item *, const char *,
|
||||||
struct wait_channel *);
|
struct wait_channel *);
|
||||||
enum cmd_retval cmd_wait_for_wait(struct cmd_q *, const char *,
|
static enum cmd_retval cmd_wait_for_wait(struct cmdq_item *, const char *,
|
||||||
struct wait_channel *);
|
struct wait_channel *);
|
||||||
enum cmd_retval cmd_wait_for_lock(struct cmd_q *, const char *,
|
static enum cmd_retval cmd_wait_for_lock(struct cmdq_item *, const char *,
|
||||||
struct wait_channel *);
|
struct wait_channel *);
|
||||||
enum cmd_retval cmd_wait_for_unlock(struct cmd_q *, const char *,
|
static enum cmd_retval cmd_wait_for_unlock(struct cmdq_item *, const char *,
|
||||||
struct wait_channel *);
|
struct wait_channel *);
|
||||||
|
|
||||||
enum cmd_retval
|
static struct wait_channel *cmd_wait_for_add(const char *);
|
||||||
cmd_wait_for_exec(struct cmd *self, struct cmd_q *cmdq)
|
static void cmd_wait_for_remove(struct wait_channel *);
|
||||||
|
|
||||||
|
static struct wait_channel *
|
||||||
|
cmd_wait_for_add(const char *name)
|
||||||
|
{
|
||||||
|
struct wait_channel *wc;
|
||||||
|
|
||||||
|
wc = xmalloc(sizeof *wc);
|
||||||
|
wc->name = xstrdup(name);
|
||||||
|
|
||||||
|
wc->locked = 0;
|
||||||
|
wc->woken = 0;
|
||||||
|
|
||||||
|
TAILQ_INIT(&wc->waiters);
|
||||||
|
TAILQ_INIT(&wc->lockers);
|
||||||
|
|
||||||
|
RB_INSERT(wait_channels, &wait_channels, wc);
|
||||||
|
|
||||||
|
log_debug("add wait channel %s", wc->name);
|
||||||
|
|
||||||
|
return (wc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_wait_for_remove(struct wait_channel *wc)
|
||||||
|
{
|
||||||
|
if (wc->locked)
|
||||||
|
return;
|
||||||
|
if (!TAILQ_EMPTY(&wc->waiters) || !wc->woken)
|
||||||
|
return;
|
||||||
|
|
||||||
|
log_debug("remove wait channel %s", wc->name);
|
||||||
|
|
||||||
|
RB_REMOVE(wait_channels, &wait_channels, wc);
|
||||||
|
|
||||||
|
free((void *)wc->name);
|
||||||
|
free(wc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_wait_for_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
const char *name = args->argv[0];
|
const char *name = args->argv[0];
|
||||||
@@ -82,85 +128,88 @@ cmd_wait_for_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
wc = RB_FIND(wait_channels, &wait_channels, &wc0);
|
wc = RB_FIND(wait_channels, &wait_channels, &wc0);
|
||||||
|
|
||||||
if (args_has(args, 'S'))
|
if (args_has(args, 'S'))
|
||||||
return (cmd_wait_for_signal(cmdq, name, wc));
|
return (cmd_wait_for_signal(item, name, wc));
|
||||||
if (args_has(args, 'L'))
|
if (args_has(args, 'L'))
|
||||||
return (cmd_wait_for_lock(cmdq, name, wc));
|
return (cmd_wait_for_lock(item, name, wc));
|
||||||
if (args_has(args, 'U'))
|
if (args_has(args, 'U'))
|
||||||
return (cmd_wait_for_unlock(cmdq, name, wc));
|
return (cmd_wait_for_unlock(item, name, wc));
|
||||||
return (cmd_wait_for_wait(cmdq, name, wc));
|
return (cmd_wait_for_wait(item, name, wc));
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_wait_for_signal(struct cmd_q *cmdq, const char *name,
|
cmd_wait_for_signal(__unused struct cmdq_item *item, const char *name,
|
||||||
struct wait_channel *wc)
|
struct wait_channel *wc)
|
||||||
{
|
{
|
||||||
struct cmd_q *wq, *wq1;
|
struct wait_item *wi, *wi1;
|
||||||
|
|
||||||
if (wc == NULL || TAILQ_EMPTY(&wc->waiters)) {
|
if (wc == NULL)
|
||||||
cmdq_error(cmdq, "no waiting clients on %s", name);
|
wc = cmd_wait_for_add(name);
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
if (TAILQ_EMPTY(&wc->waiters) && !wc->woken) {
|
||||||
|
log_debug("signal wait channel %s, no waiters", wc->name);
|
||||||
TAILQ_FOREACH_SAFE(wq, &wc->waiters, waitentry, wq1) {
|
wc->woken = 1;
|
||||||
TAILQ_REMOVE(&wc->waiters, wq, waitentry);
|
return (CMD_RETURN_NORMAL);
|
||||||
if (!cmdq_free(wq))
|
}
|
||||||
cmdq_continue(wq);
|
log_debug("signal wait channel %s, with waiters", wc->name);
|
||||||
}
|
|
||||||
|
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
|
||||||
if (!wc->locked) {
|
wi->item->flags &= ~CMDQ_WAITING;
|
||||||
RB_REMOVE(wait_channels, &wait_channels, wc);
|
|
||||||
free((void*) wc->name);
|
TAILQ_REMOVE(&wc->waiters, wi, entry);
|
||||||
free(wc);
|
free(wi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd_wait_for_remove(wc);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_wait_for_wait(struct cmd_q *cmdq, const char *name,
|
cmd_wait_for_wait(struct cmdq_item *item, const char *name,
|
||||||
struct wait_channel *wc)
|
struct wait_channel *wc)
|
||||||
{
|
{
|
||||||
if (cmdq->client == NULL || cmdq->client->session != NULL) {
|
struct client *c = item->client;
|
||||||
cmdq_error(cmdq, "not able to wait");
|
struct wait_item *wi;
|
||||||
|
|
||||||
|
if (c == NULL || c->session != NULL) {
|
||||||
|
cmdq_error(item, "not able to wait");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wc == NULL) {
|
if (wc == NULL)
|
||||||
wc = xmalloc(sizeof *wc);
|
wc = cmd_wait_for_add(name);
|
||||||
wc->name = xstrdup(name);
|
|
||||||
wc->locked = 0;
|
|
||||||
TAILQ_INIT(&wc->waiters);
|
|
||||||
TAILQ_INIT(&wc->lockers);
|
|
||||||
RB_INSERT(wait_channels, &wait_channels, wc);
|
|
||||||
}
|
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&wc->waiters, cmdq, waitentry);
|
if (wc->woken) {
|
||||||
cmdq->references++;
|
log_debug("wait channel %s already woken (%p)", wc->name, c);
|
||||||
|
cmd_wait_for_remove(wc);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
log_debug("wait channel %s not woken (%p)", wc->name, c);
|
||||||
|
|
||||||
|
wi = xcalloc(1, sizeof *wi);
|
||||||
|
wi->item = item;
|
||||||
|
TAILQ_INSERT_TAIL(&wc->waiters, wi, entry);
|
||||||
|
|
||||||
return (CMD_RETURN_WAIT);
|
return (CMD_RETURN_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_wait_for_lock(struct cmd_q *cmdq, const char *name,
|
cmd_wait_for_lock(struct cmdq_item *item, const char *name,
|
||||||
struct wait_channel *wc)
|
struct wait_channel *wc)
|
||||||
{
|
{
|
||||||
if (cmdq->client == NULL || cmdq->client->session != NULL) {
|
struct wait_item *wi;
|
||||||
cmdq_error(cmdq, "not able to lock");
|
|
||||||
|
if (item->client == NULL || item->client->session != NULL) {
|
||||||
|
cmdq_error(item, "not able to lock");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wc == NULL) {
|
if (wc == NULL)
|
||||||
wc = xmalloc(sizeof *wc);
|
wc = cmd_wait_for_add(name);
|
||||||
wc->name = xstrdup(name);
|
|
||||||
wc->locked = 0;
|
|
||||||
TAILQ_INIT(&wc->waiters);
|
|
||||||
TAILQ_INIT(&wc->lockers);
|
|
||||||
RB_INSERT(wait_channels, &wait_channels, wc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wc->locked) {
|
if (wc->locked) {
|
||||||
TAILQ_INSERT_TAIL(&wc->lockers, cmdq, waitentry);
|
wi = xcalloc(1, sizeof *wi);
|
||||||
cmdq->references++;
|
wi->item = item;
|
||||||
|
TAILQ_INSERT_TAIL(&wc->lockers, wi, entry);
|
||||||
return (CMD_RETURN_WAIT);
|
return (CMD_RETURN_WAIT);
|
||||||
}
|
}
|
||||||
wc->locked = 1;
|
wc->locked = 1;
|
||||||
@@ -168,30 +217,48 @@ cmd_wait_for_lock(struct cmd_q *cmdq, const char *name,
|
|||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_wait_for_unlock(struct cmd_q *cmdq, const char *name,
|
cmd_wait_for_unlock(struct cmdq_item *item, const char *name,
|
||||||
struct wait_channel *wc)
|
struct wait_channel *wc)
|
||||||
{
|
{
|
||||||
struct cmd_q *wq;
|
struct wait_item *wi;
|
||||||
|
|
||||||
if (wc == NULL || !wc->locked) {
|
if (wc == NULL || !wc->locked) {
|
||||||
cmdq_error(cmdq, "channel %s not locked", name);
|
cmdq_error(item, "channel %s not locked", name);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wq = TAILQ_FIRST(&wc->lockers)) != NULL) {
|
if ((wi = TAILQ_FIRST(&wc->lockers)) != NULL) {
|
||||||
TAILQ_REMOVE(&wc->lockers, wq, waitentry);
|
wi->item->flags &= ~CMDQ_WAITING;
|
||||||
if (!cmdq_free(wq))
|
TAILQ_REMOVE(&wc->lockers, wi, entry);
|
||||||
cmdq_continue(wq);
|
free(wi);
|
||||||
} else {
|
} else {
|
||||||
wc->locked = 0;
|
wc->locked = 0;
|
||||||
if (TAILQ_EMPTY(&wc->waiters)) {
|
cmd_wait_for_remove(wc);
|
||||||
RB_REMOVE(wait_channels, &wait_channels, wc);
|
|
||||||
free((void*) wc->name);
|
|
||||||
free(wc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_wait_for_flush(void)
|
||||||
|
{
|
||||||
|
struct wait_channel *wc, *wc1;
|
||||||
|
struct wait_item *wi, *wi1;
|
||||||
|
|
||||||
|
RB_FOREACH_SAFE(wc, wait_channels, &wait_channels, wc1) {
|
||||||
|
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
|
||||||
|
wi->item->flags &= ~CMDQ_WAITING;
|
||||||
|
TAILQ_REMOVE(&wc->waiters, wi, entry);
|
||||||
|
free(wi);
|
||||||
|
}
|
||||||
|
wc->woken = 1;
|
||||||
|
TAILQ_FOREACH_SAFE(wi, &wc->lockers, entry, wi1) {
|
||||||
|
wi->item->flags &= ~CMDQ_WAITING;
|
||||||
|
TAILQ_REMOVE(&wc->lockers, wi, entry);
|
||||||
|
free(wi);
|
||||||
|
}
|
||||||
|
wc->locked = 0;
|
||||||
|
cmd_wait_for_remove(wc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
263
colour.c
263
colour.c
@@ -1,7 +1,8 @@
|
|||||||
/* $Id$ */
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
|
* Copyright (c) 2016 Avi Halachmi <avihpit@yahoo.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -24,120 +25,83 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
|
static int
|
||||||
|
colour_dist_sq(int R, int G, int B, int r, int g, int b)
|
||||||
|
{
|
||||||
|
return ((R - r) * (R - r) + (G - g) * (G - g) + (B - b) * (B - b));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
colour_to_6cube(int v)
|
||||||
|
{
|
||||||
|
if (v < 48)
|
||||||
|
return (0);
|
||||||
|
if (v < 114)
|
||||||
|
return (1);
|
||||||
|
return ((v - 35) / 40);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Colour to string conversion functions. Bit 8 of the colour means it is one
|
* Convert an RGB triplet to the xterm(1) 256 colour palette.
|
||||||
* of the 256 colour palette.
|
*
|
||||||
|
* xterm provides a 6x6x6 colour cube (16 - 231) and 24 greys (232 - 255). We
|
||||||
|
* map our RGB colour to the closest in the cube, also work out the closest
|
||||||
|
* grey, and use the nearest of the two.
|
||||||
|
*
|
||||||
|
* Note that the xterm has much lower resolution for darker colours (they are
|
||||||
|
* not evenly spread out), so our 6 levels are not evenly spread: 0x0, 0x5f
|
||||||
|
* (95), 0x87 (135), 0xaf (175), 0xd7 (215) and 0xff (255). Greys are more
|
||||||
|
* evenly spread (8, 18, 28 ... 238).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* An RGB colour. */
|
|
||||||
struct colour_rgb {
|
|
||||||
u_char r;
|
|
||||||
u_char g;
|
|
||||||
u_char b;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 256 colour RGB table, generated on first use. */
|
|
||||||
struct colour_rgb *colour_rgb_256;
|
|
||||||
|
|
||||||
void colour_rgb_generate256(void);
|
|
||||||
u_int colour_rgb_distance(struct colour_rgb *, struct colour_rgb *);
|
|
||||||
int colour_rgb_find(struct colour_rgb *);
|
|
||||||
|
|
||||||
/* Generate 256 colour RGB table. */
|
|
||||||
void
|
|
||||||
colour_rgb_generate256(void)
|
|
||||||
{
|
|
||||||
struct colour_rgb *rgb;
|
|
||||||
u_int i, r, g, b;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allocate the table. The first 16 colours are often changed by users
|
|
||||||
* and terminals so don't include them.
|
|
||||||
*/
|
|
||||||
colour_rgb_256 = xcalloc(240, sizeof *colour_rgb_256);
|
|
||||||
|
|
||||||
/* Add the colours first. */
|
|
||||||
r = g = b = 0;
|
|
||||||
for (i = 240; i > 24; i--) {
|
|
||||||
rgb = &colour_rgb_256[240 - i];
|
|
||||||
|
|
||||||
if (r != 0)
|
|
||||||
rgb->r = (r * 40) + 55;
|
|
||||||
if (g != 0)
|
|
||||||
rgb->g = (g * 40) + 55;
|
|
||||||
if (b != 0)
|
|
||||||
rgb->b = (b * 40) + 55;
|
|
||||||
|
|
||||||
b++;
|
|
||||||
if (b > 5) {
|
|
||||||
b = 0;
|
|
||||||
g++;
|
|
||||||
}
|
|
||||||
if (g > 5) {
|
|
||||||
g = 0;
|
|
||||||
r++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Then add the greys. */
|
|
||||||
for (i = 24; i > 0; i--) {
|
|
||||||
rgb = &colour_rgb_256[240 - i];
|
|
||||||
|
|
||||||
rgb->r = 8 + (24 - i) * 10;
|
|
||||||
rgb->g = 8 + (24 - i) * 10;
|
|
||||||
rgb->b = 8 + (24 - i) * 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get colour RGB distance. */
|
|
||||||
u_int
|
|
||||||
colour_rgb_distance(struct colour_rgb *rgb1, struct colour_rgb *rgb2)
|
|
||||||
{
|
|
||||||
int r, g, b;
|
|
||||||
|
|
||||||
r = rgb1->r - rgb2->r;
|
|
||||||
g = rgb1->g - rgb2->g;
|
|
||||||
b = rgb1->b - rgb2->b;
|
|
||||||
return (r * r + g * g + b * b);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Work out the nearest colour from the 256 colour set. */
|
|
||||||
int
|
int
|
||||||
colour_rgb_find(struct colour_rgb *rgb)
|
colour_find_rgb(u_char r, u_char g, u_char b)
|
||||||
{
|
{
|
||||||
u_int distance, lowest, colour, i;
|
static const int q2c[6] = { 0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff };
|
||||||
|
int qr, qg, qb, cr, cg, cb, d, idx;
|
||||||
|
int grey_avg, grey_idx, grey;
|
||||||
|
|
||||||
if (colour_rgb_256 == NULL)
|
/* Map RGB to 6x6x6 cube. */
|
||||||
colour_rgb_generate256();
|
qr = colour_to_6cube(r); cr = q2c[qr];
|
||||||
|
qg = colour_to_6cube(g); cg = q2c[qg];
|
||||||
|
qb = colour_to_6cube(b); cb = q2c[qb];
|
||||||
|
|
||||||
colour = 16;
|
/* If we have hit the colour exactly, return early. */
|
||||||
lowest = UINT_MAX;
|
if (cr == r && cg == g && cb == b)
|
||||||
for (i = 0; i < 240; i++) {
|
return ((16 + (36 * qr) + (6 * qg) + qb) | COLOUR_FLAG_256);
|
||||||
distance = colour_rgb_distance(&colour_rgb_256[i], rgb);
|
|
||||||
if (distance < lowest) {
|
/* Work out the closest grey (average of RGB). */
|
||||||
lowest = distance;
|
grey_avg = (r + g + b) / 3;
|
||||||
colour = 16 + i;
|
if (grey_avg > 238)
|
||||||
}
|
grey_idx = 23;
|
||||||
}
|
else
|
||||||
return (colour);
|
grey_idx = (grey_avg - 3) / 10;
|
||||||
|
grey = 8 + (10 * grey_idx);
|
||||||
|
|
||||||
|
/* Is grey or 6x6x6 colour closest? */
|
||||||
|
d = colour_dist_sq(cr, cg, cb, r, g, b);
|
||||||
|
if (colour_dist_sq(grey, grey, grey, r, g, b) < d)
|
||||||
|
idx = 232 + grey_idx;
|
||||||
|
else
|
||||||
|
idx = 16 + (36 * qr) + (6 * qg) + qb;
|
||||||
|
return (idx | COLOUR_FLAG_256);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set grid cell foreground colour. */
|
/* Join RGB into a colour. */
|
||||||
void
|
int
|
||||||
colour_set_fg(struct grid_cell *gc, int c)
|
colour_join_rgb(u_char r, u_char g, u_char b)
|
||||||
{
|
{
|
||||||
if (c & 0x100)
|
return ((((int)((r) & 0xff)) << 16) |
|
||||||
gc->flags |= GRID_FLAG_FG256;
|
(((int)((g) & 0xff)) << 8) |
|
||||||
gc->fg = c;
|
(((int)((b) & 0xff))) | COLOUR_FLAG_RGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set grid cell background colour. */
|
/* Split colour into RGB. */
|
||||||
void
|
void
|
||||||
colour_set_bg(struct grid_cell *gc, int c)
|
colour_split_rgb(int c, u_char *r, u_char *g, u_char *b)
|
||||||
{
|
{
|
||||||
if (c & 0x100)
|
*r = (c >> 16) & 0xff;
|
||||||
gc->flags |= GRID_FLAG_BG256;
|
*g = (c >> 8) & 0xff;
|
||||||
gc->bg = c;
|
*b = c & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert colour to a string. */
|
/* Convert colour to a string. */
|
||||||
@@ -145,9 +109,16 @@ const char *
|
|||||||
colour_tostring(int c)
|
colour_tostring(int c)
|
||||||
{
|
{
|
||||||
static char s[32];
|
static char s[32];
|
||||||
|
u_char r, g, b;
|
||||||
|
|
||||||
if (c & 0x100) {
|
if (c & COLOUR_FLAG_RGB) {
|
||||||
xsnprintf(s, sizeof s, "colour%u", c & ~0x100);
|
colour_split_rgb(c, &r, &g, &b);
|
||||||
|
xsnprintf(s, sizeof s, "#%02x%02x%02x", r, g, b);
|
||||||
|
return (s);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c & COLOUR_FLAG_256) {
|
||||||
|
xsnprintf(s, sizeof s, "colour%u", c & 0xff);
|
||||||
return (s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,70 +165,62 @@ colour_tostring(int c)
|
|||||||
int
|
int
|
||||||
colour_fromstring(const char *s)
|
colour_fromstring(const char *s)
|
||||||
{
|
{
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
const char *cp;
|
const char *cp;
|
||||||
struct colour_rgb rgb;
|
int n;
|
||||||
int n;
|
u_char r, g, b;
|
||||||
|
|
||||||
if (*s == '#' && strlen(s) == 7) {
|
if (*s == '#' && strlen(s) == 7) {
|
||||||
for (cp = s + 1; isxdigit((u_char) *cp); cp++)
|
for (cp = s + 1; isxdigit((u_char) *cp); cp++)
|
||||||
;
|
;
|
||||||
if (*cp != '\0')
|
if (*cp != '\0')
|
||||||
return (-1);
|
return (-1);
|
||||||
n = sscanf(s + 1, "%2hhx%2hhx%2hhx", &rgb.r, &rgb.g, &rgb.b);
|
n = sscanf(s + 1, "%2hhx%2hhx%2hhx", &r, &g, &b);
|
||||||
if (n != 3)
|
if (n != 3)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (colour_rgb_find(&rgb) | 0x100);
|
return (colour_join_rgb(r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncasecmp(s, "colour", (sizeof "colour") - 1) == 0) {
|
if (strncasecmp(s, "colour", (sizeof "colour") - 1) == 0) {
|
||||||
n = strtonum(s + (sizeof "colour") - 1, 0, 255, &errstr);
|
n = strtonum(s + (sizeof "colour") - 1, 0, 255, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (n | 0x100);
|
return (n | COLOUR_FLAG_256);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp(s, "black") == 0 || (s[0] == '0' && s[1] == '\0'))
|
if (strcasecmp(s, "black") == 0 || strcmp(s, "0") == 0)
|
||||||
return (0);
|
return (0);
|
||||||
if (strcasecmp(s, "red") == 0 || (s[0] == '1' && s[1] == '\0'))
|
if (strcasecmp(s, "red") == 0 || strcmp(s, "1") == 0)
|
||||||
return (1);
|
return (1);
|
||||||
if (strcasecmp(s, "green") == 0 || (s[0] == '2' && s[1] == '\0'))
|
if (strcasecmp(s, "green") == 0 || strcmp(s, "2") == 0)
|
||||||
return (2);
|
return (2);
|
||||||
if (strcasecmp(s, "yellow") == 0 || (s[0] == '3' && s[1] == '\0'))
|
if (strcasecmp(s, "yellow") == 0 || strcmp(s, "3") == 0)
|
||||||
return (3);
|
return (3);
|
||||||
if (strcasecmp(s, "blue") == 0 || (s[0] == '4' && s[1] == '\0'))
|
if (strcasecmp(s, "blue") == 0 || strcmp(s, "4") == 0)
|
||||||
return (4);
|
return (4);
|
||||||
if (strcasecmp(s, "magenta") == 0 || (s[0] == '5' && s[1] == '\0'))
|
if (strcasecmp(s, "magenta") == 0 || strcmp(s, "5") == 0)
|
||||||
return (5);
|
return (5);
|
||||||
if (strcasecmp(s, "cyan") == 0 || (s[0] == '6' && s[1] == '\0'))
|
if (strcasecmp(s, "cyan") == 0 || strcmp(s, "6") == 0)
|
||||||
return (6);
|
return (6);
|
||||||
if (strcasecmp(s, "white") == 0 || (s[0] == '7' && s[1] == '\0'))
|
if (strcasecmp(s, "white") == 0 || strcmp(s, "7") == 0)
|
||||||
return (7);
|
return (7);
|
||||||
if (strcasecmp(s, "default") == 0 || (s[0] == '8' && s[1] == '\0'))
|
if (strcasecmp(s, "default") == 0 || strcmp(s, "8") == 0)
|
||||||
return (8);
|
return (8);
|
||||||
if (strcasecmp(s, "brightblack") == 0 ||
|
if (strcasecmp(s, "brightblack") == 0 || strcmp(s, "90") == 0)
|
||||||
(s[0] == '9' && s[1] == '0' && s[1] == '\0'))
|
|
||||||
return (90);
|
return (90);
|
||||||
if (strcasecmp(s, "brightred") == 0 ||
|
if (strcasecmp(s, "brightred") == 0 || strcmp(s, "91") == 0)
|
||||||
(s[0] == '9' && s[1] == '1' && s[1] == '\0'))
|
|
||||||
return (91);
|
return (91);
|
||||||
if (strcasecmp(s, "brightgreen") == 0 ||
|
if (strcasecmp(s, "brightgreen") == 0 || strcmp(s, "92") == 0)
|
||||||
(s[0] == '9' && s[1] == '2' && s[1] == '\0'))
|
|
||||||
return (92);
|
return (92);
|
||||||
if (strcasecmp(s, "brightyellow") == 0 ||
|
if (strcasecmp(s, "brightyellow") == 0 || strcmp(s, "93") == 0)
|
||||||
(s[0] == '9' && s[1] == '3' && s[1] == '\0'))
|
|
||||||
return (93);
|
return (93);
|
||||||
if (strcasecmp(s, "brightblue") == 0 ||
|
if (strcasecmp(s, "brightblue") == 0 || strcmp(s, "94") == 0)
|
||||||
(s[0] == '9' && s[1] == '4' && s[1] == '\0'))
|
|
||||||
return (94);
|
return (94);
|
||||||
if (strcasecmp(s, "brightmagenta") == 0 ||
|
if (strcasecmp(s, "brightmagenta") == 0 || strcmp(s, "95") == 0)
|
||||||
(s[0] == '9' && s[1] == '5' && s[1] == '\0'))
|
|
||||||
return (95);
|
return (95);
|
||||||
if (strcasecmp(s, "brightcyan") == 0 ||
|
if (strcasecmp(s, "brightcyan") == 0 || strcmp(s, "96") == 0)
|
||||||
(s[0] == '9' && s[1] == '6' && s[1] == '\0'))
|
|
||||||
return (96);
|
return (96);
|
||||||
if (strcasecmp(s, "brightwhite") == 0 ||
|
if (strcasecmp(s, "brightwhite") == 0 || strcmp(s, "97") == 0)
|
||||||
(s[0] == '9' && s[1] == '7' && s[1] == '\0'))
|
|
||||||
return (97);
|
return (97);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -287,29 +250,3 @@ colour_256to16(u_char c)
|
|||||||
|
|
||||||
return (table[c]);
|
return (table[c]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert 256 colour palette to 88. */
|
|
||||||
u_char
|
|
||||||
colour_256to88(u_char c)
|
|
||||||
{
|
|
||||||
static const u_char table[256] = {
|
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
||||||
16, 17, 17, 18, 18, 19, 20, 21, 21, 22, 22, 23, 20, 21, 21, 22,
|
|
||||||
22, 23, 24, 25, 25, 26, 26, 27, 24, 25, 25, 26, 26, 27, 28, 29,
|
|
||||||
29, 30, 30, 31, 32, 33, 33, 34, 34, 35, 36, 37, 37, 38, 38, 39,
|
|
||||||
36, 37, 37, 38, 38, 39, 40, 41, 41, 42, 42, 43, 40, 41, 41, 42,
|
|
||||||
42, 43, 44, 45, 45, 46, 46, 47, 32, 33, 33, 34, 34, 35, 36, 37,
|
|
||||||
37, 38, 38, 39, 36, 37, 37, 38, 38, 39, 40, 41, 41, 42, 42, 43,
|
|
||||||
40, 41, 41, 42, 42, 43, 44, 45, 45, 46, 46, 47, 48, 49, 49, 50,
|
|
||||||
50, 51, 52, 53, 53, 54, 54, 55, 52, 53, 53, 54, 54, 55, 56, 57,
|
|
||||||
57, 58, 58, 59, 56, 57, 57, 58, 58, 59, 60, 61, 61, 62, 62, 63,
|
|
||||||
48, 49, 49, 50, 50, 51, 52, 53, 53, 54, 54, 55, 52, 53, 53, 54,
|
|
||||||
54, 55, 56, 57, 57, 58, 58, 59, 56, 57, 57, 58, 58, 59, 60, 61,
|
|
||||||
61, 62, 62, 63, 64, 65, 65, 66, 66, 67, 68, 69, 69, 70, 70, 71,
|
|
||||||
68, 69, 69, 70, 70, 71, 72, 73, 73, 74, 74, 75, 72, 73, 73, 74,
|
|
||||||
74, 75, 76, 77, 77, 78, 78, 79, 0, 0, 80, 80, 80, 81, 81, 81,
|
|
||||||
82, 82, 82, 83, 83, 83, 84, 84, 84, 85, 85, 85, 86, 86, 86, 87
|
|
||||||
};
|
|
||||||
|
|
||||||
return (table[c]);
|
|
||||||
}
|
|
||||||
|
|||||||
151
compat.h
151
compat.h
@@ -1,7 +1,5 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -19,10 +17,21 @@
|
|||||||
#ifndef COMPAT_H
|
#ifndef COMPAT_H
|
||||||
#define COMPAT_H
|
#define COMPAT_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
#ifndef __GNUC__
|
#ifndef __GNUC__
|
||||||
#define __attribute__(a)
|
#define __attribute__(a)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __unused
|
||||||
|
#define __unused __attribute__ ((__unused__))
|
||||||
|
#endif
|
||||||
#ifndef __dead
|
#ifndef __dead
|
||||||
#define __dead __attribute__ ((__noreturn__))
|
#define __dead __attribute__ ((__noreturn__))
|
||||||
#endif
|
#endif
|
||||||
@@ -30,11 +39,25 @@
|
|||||||
#define __packed __attribute__ ((__packed__))
|
#define __packed __attribute__ ((__packed__))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_BSD_TYPES
|
#ifndef ECHOPRT
|
||||||
typedef uint8_t u_int8_t;
|
#define ECHOPRT 0
|
||||||
typedef uint16_t u_int16_t;
|
#endif
|
||||||
typedef uint32_t u_int32_t;
|
|
||||||
typedef uint64_t u_int64_t;
|
#ifndef ACCESSPERMS
|
||||||
|
#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(FIONREAD) && defined(__sun)
|
||||||
|
#include <sys/filio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_ERR_H
|
||||||
|
#include <err.h>
|
||||||
|
#else
|
||||||
|
void err(int, const char *, ...);
|
||||||
|
void errx(int, const char *, ...);
|
||||||
|
void warn(const char *, ...);
|
||||||
|
void warnx(const char *, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_PATHS_H
|
#ifndef HAVE_PATHS_H
|
||||||
@@ -45,6 +68,16 @@ typedef uint64_t u_int64_t;
|
|||||||
#define _PATH_DEV "/dev/"
|
#define _PATH_DEV "/dev/"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __OpenBSD__
|
||||||
|
#define pledge(s, p) (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
|
#include <stdint.h>
|
||||||
|
#else
|
||||||
|
#include <inttypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_QUEUE_H
|
#ifdef HAVE_QUEUE_H
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#else
|
#else
|
||||||
@@ -91,12 +124,6 @@ typedef uint64_t u_int64_t;
|
|||||||
#include "compat/imsg.h"
|
#include "compat/imsg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STDINT_H
|
|
||||||
#include <stdint.h>
|
|
||||||
#else
|
|
||||||
#include <inttypes.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BROKEN_CMSG_FIRSTHDR
|
#ifdef BROKEN_CMSG_FIRSTHDR
|
||||||
#undef CMSG_FIRSTHDR
|
#undef CMSG_FIRSTHDR
|
||||||
#define CMSG_FIRSTHDR(mhdr) \
|
#define CMSG_FIRSTHDR(mhdr) \
|
||||||
@@ -121,6 +148,10 @@ typedef uint64_t u_int64_t;
|
|||||||
#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
|
#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_DIRECTORY
|
||||||
|
#define O_DIRECTORY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef INFTIM
|
#ifndef INFTIM
|
||||||
#define INFTIM -1
|
#define INFTIM -1
|
||||||
#endif
|
#endif
|
||||||
@@ -152,18 +183,46 @@ typedef uint64_t u_int64_t;
|
|||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef timersub
|
||||||
|
#define timersub(tvp, uvp, vvp) \
|
||||||
|
do { \
|
||||||
|
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
||||||
|
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
|
||||||
|
if ((vvp)->tv_usec < 0) { \
|
||||||
|
(vvp)->tv_sec--; \
|
||||||
|
(vvp)->tv_usec += 1000000; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TTY_NAME_MAX
|
#ifndef TTY_NAME_MAX
|
||||||
#define TTY_NAME_MAX 32
|
#define TTY_NAME_MAX 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_BZERO
|
#ifndef HOST_NAME_MAX
|
||||||
#undef bzero
|
#define HOST_NAME_MAX 255
|
||||||
#define bzero(buf, len) memset(buf, 0, len);
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_FLOCK
|
||||||
|
#define LOCK_SH 0
|
||||||
|
#define LOCK_EX 0
|
||||||
|
#define LOCK_NB 0
|
||||||
|
#define flock(fd, op) (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_EXPLICIT_BZERO
|
||||||
|
/* explicit_bzero.c */
|
||||||
|
void explicit_bzero(void *, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETDTABLECOUNT
|
||||||
|
/* getdtablecount.c */
|
||||||
|
int getdtablecount(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_CLOSEFROM
|
#ifndef HAVE_CLOSEFROM
|
||||||
/* closefrom.c */
|
/* closefrom.c */
|
||||||
void closefrom(int);
|
void closefrom(int);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STRCASESTR
|
#ifndef HAVE_STRCASESTR
|
||||||
@@ -191,14 +250,37 @@ size_t strlcpy(char *, const char *, size_t);
|
|||||||
size_t strlcat(char *, const char *, size_t);
|
size_t strlcat(char *, const char *, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRNLEN
|
||||||
|
/* strnlen.c */
|
||||||
|
size_t strnlen(const char *, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRNDUP
|
||||||
|
/* strndup.c */
|
||||||
|
char *strndup(const char *, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_DAEMON
|
#ifndef HAVE_DAEMON
|
||||||
/* daemon.c */
|
/* daemon.c */
|
||||||
int daemon(int, int);
|
int daemon(int, int);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETPROGNAME
|
||||||
|
/* getprogname.c */
|
||||||
|
const char *getprogname(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_SETPROCTITLE
|
||||||
|
/* setproctitle.c */
|
||||||
|
void setproctitle(const char *, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_B64_NTOP
|
#ifndef HAVE_B64_NTOP
|
||||||
/* b64_ntop.c */
|
/* base64.c */
|
||||||
|
#undef b64_ntop
|
||||||
|
#undef b64_pton
|
||||||
int b64_ntop(const char *, size_t, char *, size_t);
|
int b64_ntop(const char *, size_t, char *, size_t);
|
||||||
|
int b64_pton(const char *, u_char *, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_FORKPTY
|
#ifndef HAVE_FORKPTY
|
||||||
@@ -218,12 +300,43 @@ int vasprintf(char **, const char *, va_list);
|
|||||||
char *fgetln(FILE *, size_t *);
|
char *fgetln(FILE *, size_t *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_FPARSELN
|
||||||
|
char *fparseln(FILE *, size_t *, size_t *, const char *, int);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SETENV
|
#ifndef HAVE_SETENV
|
||||||
/* setenv.c */
|
/* setenv.c */
|
||||||
int setenv(const char *, const char *, int);
|
int setenv(const char *, const char *, int);
|
||||||
int unsetenv(const char *);
|
int unsetenv(const char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_CFMAKERAW
|
||||||
|
/* cfmakeraw.c */
|
||||||
|
void cfmakeraw(struct termios *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_FREEZERO
|
||||||
|
/* freezero.c */
|
||||||
|
void freezero(void *, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_REALLOCARRAY
|
||||||
|
/* reallocarray.c */
|
||||||
|
void *reallocarray(void *, size_t, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_RECALLOCARRAY
|
||||||
|
/* recallocarray.c */
|
||||||
|
void *recallocarray(void *, size_t, size_t, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UTF8PROC
|
||||||
|
/* utf8proc.c */
|
||||||
|
int utf8proc_wcwidth(wchar_t);
|
||||||
|
int utf8proc_mbtowc(wchar_t *, const char *, size_t);
|
||||||
|
int utf8proc_wctomb(char *, wchar_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT
|
#ifdef HAVE_GETOPT
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2006 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -16,16 +14,13 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef HAVE_STDINT_H
|
|
||||||
#include <stdint.h>
|
|
||||||
#else
|
|
||||||
#include <inttypes.h>
|
|
||||||
#endif
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "compat.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
asprintf(char **ret, const char *fmt, ...)
|
asprintf(char **ret, const char *fmt, ...)
|
||||||
@@ -56,10 +51,12 @@ vasprintf(char **ret, const char *fmt, va_list ap)
|
|||||||
free(*ret);
|
free(*ret);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
va_end(ap2);
|
||||||
|
|
||||||
return (n);
|
return (n);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
va_end(ap2);
|
||||||
*ret = NULL;
|
*ret = NULL;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
/* $OpenBSD: base64.c,v 1.8 2015/01/16 16:48:51 deraadt Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 1998 by Internet Software Consortium.
|
* Copyright (c) 1996 by Internet Software Consortium.
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -41,19 +43,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <arpa/nameser.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <resolv.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define Assert(Cond) if (!(Cond)) abort()
|
|
||||||
|
|
||||||
static const char Base64[] =
|
static const char Base64[] =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
static const char Pad64 = '=';
|
static const char Pad64 = '=';
|
||||||
@@ -122,11 +123,16 @@ static const char Pad64 = '=';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
|
b64_ntop(src, srclength, target, targsize)
|
||||||
|
u_char const *src;
|
||||||
|
size_t srclength;
|
||||||
|
char *target;
|
||||||
|
size_t targsize;
|
||||||
|
{
|
||||||
size_t datalength = 0;
|
size_t datalength = 0;
|
||||||
uint8_t input[3];
|
u_char input[3];
|
||||||
uint8_t output[4];
|
u_char output[4];
|
||||||
size_t i;
|
int i;
|
||||||
|
|
||||||
while (2 < srclength) {
|
while (2 < srclength) {
|
||||||
input[0] = *src++;
|
input[0] = *src++;
|
||||||
@@ -138,10 +144,6 @@ b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
|
|||||||
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
|
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
|
||||||
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|
||||||
output[3] = input[2] & 0x3f;
|
output[3] = input[2] & 0x3f;
|
||||||
Assert(output[0] < 64);
|
|
||||||
Assert(output[1] < 64);
|
|
||||||
Assert(output[2] < 64);
|
|
||||||
Assert(output[3] < 64);
|
|
||||||
|
|
||||||
if (datalength + 4 > targsize)
|
if (datalength + 4 > targsize)
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -161,9 +163,6 @@ b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
|
|||||||
output[0] = input[0] >> 2;
|
output[0] = input[0] >> 2;
|
||||||
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
|
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
|
||||||
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|
||||||
Assert(output[0] < 64);
|
|
||||||
Assert(output[1] < 64);
|
|
||||||
Assert(output[2] < 64);
|
|
||||||
|
|
||||||
if (datalength + 4 > targsize)
|
if (datalength + 4 > targsize)
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -180,3 +179,137 @@ b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
|
|||||||
target[datalength] = '\0'; /* Returned value doesn't count \0. */
|
target[datalength] = '\0'; /* Returned value doesn't count \0. */
|
||||||
return (datalength);
|
return (datalength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* skips all whitespace anywhere.
|
||||||
|
converts characters, four at a time, starting at (or after)
|
||||||
|
src from base - 64 numbers into three 8 bit bytes in the target area.
|
||||||
|
it returns the number of data bytes stored at the target, or -1 on error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
b64_pton(src, target, targsize)
|
||||||
|
char const *src;
|
||||||
|
u_char *target;
|
||||||
|
size_t targsize;
|
||||||
|
{
|
||||||
|
int tarindex, state, ch;
|
||||||
|
u_char nextbyte;
|
||||||
|
char *pos;
|
||||||
|
|
||||||
|
state = 0;
|
||||||
|
tarindex = 0;
|
||||||
|
|
||||||
|
while ((ch = (unsigned char)*src++) != '\0') {
|
||||||
|
if (isspace(ch)) /* Skip whitespace anywhere. */
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (ch == Pad64)
|
||||||
|
break;
|
||||||
|
|
||||||
|
pos = strchr(Base64, ch);
|
||||||
|
if (pos == 0) /* A non-base64 character. */
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case 0:
|
||||||
|
if (target) {
|
||||||
|
if (tarindex >= targsize)
|
||||||
|
return (-1);
|
||||||
|
target[tarindex] = (pos - Base64) << 2;
|
||||||
|
}
|
||||||
|
state = 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (target) {
|
||||||
|
if (tarindex >= targsize)
|
||||||
|
return (-1);
|
||||||
|
target[tarindex] |= (pos - Base64) >> 4;
|
||||||
|
nextbyte = ((pos - Base64) & 0x0f) << 4;
|
||||||
|
if (tarindex + 1 < targsize)
|
||||||
|
target[tarindex+1] = nextbyte;
|
||||||
|
else if (nextbyte)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
tarindex++;
|
||||||
|
state = 2;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (target) {
|
||||||
|
if (tarindex >= targsize)
|
||||||
|
return (-1);
|
||||||
|
target[tarindex] |= (pos - Base64) >> 2;
|
||||||
|
nextbyte = ((pos - Base64) & 0x03) << 6;
|
||||||
|
if (tarindex + 1 < targsize)
|
||||||
|
target[tarindex+1] = nextbyte;
|
||||||
|
else if (nextbyte)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
tarindex++;
|
||||||
|
state = 3;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (target) {
|
||||||
|
if (tarindex >= targsize)
|
||||||
|
return (-1);
|
||||||
|
target[tarindex] |= (pos - Base64);
|
||||||
|
}
|
||||||
|
tarindex++;
|
||||||
|
state = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We are done decoding Base-64 chars. Let's see if we ended
|
||||||
|
* on a byte boundary, and/or with erroneous trailing characters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (ch == Pad64) { /* We got a pad char. */
|
||||||
|
ch = (unsigned char)*src++; /* Skip it, get next. */
|
||||||
|
switch (state) {
|
||||||
|
case 0: /* Invalid = in first position */
|
||||||
|
case 1: /* Invalid = in second position */
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
case 2: /* Valid, means one byte of info */
|
||||||
|
/* Skip any number of spaces. */
|
||||||
|
for (; ch != '\0'; ch = (unsigned char)*src++)
|
||||||
|
if (!isspace(ch))
|
||||||
|
break;
|
||||||
|
/* Make sure there is another trailing = sign. */
|
||||||
|
if (ch != Pad64)
|
||||||
|
return (-1);
|
||||||
|
ch = (unsigned char)*src++; /* Skip the = */
|
||||||
|
/* Fall through to "single trailing =" case. */
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
|
case 3: /* Valid, means two bytes of info */
|
||||||
|
/*
|
||||||
|
* We know this char is an =. Is there anything but
|
||||||
|
* whitespace after it?
|
||||||
|
*/
|
||||||
|
for (; ch != '\0'; ch = (unsigned char)*src++)
|
||||||
|
if (!isspace(ch))
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now make sure for cases 2 and 3 that the "extra"
|
||||||
|
* bits that slopped past the last full byte were
|
||||||
|
* zeros. If we don't check them, they become a
|
||||||
|
* subliminal channel.
|
||||||
|
*/
|
||||||
|
if (target && tarindex < targsize &&
|
||||||
|
target[tarindex] != 0)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* We ended by seeing the end of the string. Make sure we
|
||||||
|
* have no partial bytes lying around.
|
||||||
|
*/
|
||||||
|
if (state != 0)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (tarindex);
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
/* $Id$ */
|
|
||||||
/* $OpenBSD: bitstring.h,v 1.5 2003/06/02 19:34:12 millert Exp $ */
|
/* $OpenBSD: bitstring.h,v 1.5 2003/06/02 19:34:12 millert Exp $ */
|
||||||
/* $NetBSD: bitstring.h,v 1.5 1997/05/14 15:49:55 pk Exp $ */
|
/* $NetBSD: bitstring.h,v 1.5 1997/05/14 15:49:55 pk Exp $ */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/* $OpenBSD$ */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2013 Dagobert Michelsen
|
||||||
|
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -19,37 +18,16 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "compat.h"
|
||||||
|
|
||||||
/* Get cell width. */
|
|
||||||
u_int
|
|
||||||
grid_cell_width(const struct grid_cell *gc)
|
|
||||||
{
|
|
||||||
return (gc->xstate >> 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get cell data. */
|
|
||||||
void
|
void
|
||||||
grid_cell_get(const struct grid_cell *gc, struct utf8_data *ud)
|
cfmakeraw(struct termios *tio)
|
||||||
{
|
{
|
||||||
ud->size = gc->xstate & 0xf;
|
tio->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
|
||||||
ud->width = gc->xstate >> 4;
|
tio->c_oflag &= ~OPOST;
|
||||||
memcpy(ud->data, gc->xdata, ud->size);
|
tio->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
|
||||||
}
|
tio->c_cflag &= ~(CSIZE|PARENB);
|
||||||
|
tio->c_cflag |= CS8;
|
||||||
/* Set cell data. */
|
|
||||||
void
|
|
||||||
grid_cell_set(struct grid_cell *gc, const struct utf8_data *ud)
|
|
||||||
{
|
|
||||||
memcpy(gc->xdata, ud->data, ud->size);
|
|
||||||
gc->xstate = (ud->width << 4) | ud->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set a single character as cell data. */
|
|
||||||
void
|
|
||||||
grid_cell_one(struct grid_cell *gc, u_char ch)
|
|
||||||
{
|
|
||||||
*gc->xdata = ch;
|
|
||||||
gc->xstate = (1 << 4) | 1;
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004-2005 Todd C. Miller <Todd.Miller@courtesan.com>
|
* Copyright (c) 2004-2005 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
*
|
*
|
||||||
@@ -16,8 +14,6 @@
|
|||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_CLOSEFROM
|
#ifndef HAVE_CLOSEFROM
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -49,6 +45,8 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "compat.h"
|
||||||
|
|
||||||
#ifndef OPEN_MAX
|
#ifndef OPEN_MAX
|
||||||
# define OPEN_MAX 256
|
# define OPEN_MAX 256
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user