mirror of
https://github.com/tmux/tmux.git
synced 2026-03-11 11:05:46 +00:00
Compare commits
2806 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63a69fe085 | ||
|
|
43b36752ce | ||
|
|
19d5f4a0bd | ||
|
|
265164d251 | ||
|
|
6f0241e645 | ||
|
|
87bcc0c7e0 | ||
|
|
32be954bdd | ||
|
|
44dad918f8 | ||
|
|
bc36700d05 | ||
|
|
531daba584 | ||
|
|
8b22da69b6 | ||
|
|
7a15d10bf4 | ||
|
|
7f3feb1896 | ||
|
|
7eada28f96 | ||
|
|
b905c5d455 | ||
|
|
e388702260 | ||
|
|
60ab714451 | ||
|
|
a6129e9974 | ||
|
|
84995ae172 | ||
|
|
685eb381de | ||
|
|
ee3d3db364 | ||
|
|
90e962fff8 | ||
|
|
f165221dc4 | ||
|
|
32816eaebd | ||
|
|
7cdf5ee9bc | ||
|
|
24350879cd | ||
|
|
f3ea318a04 | ||
|
|
2c38e01b54 | ||
|
|
d0b8d036be | ||
|
|
2e39b621c9 | ||
|
|
0eb7b54731 | ||
|
|
74b424075c | ||
|
|
9169ee0e87 | ||
|
|
cdf138372c | ||
|
|
a01c9ffc6c | ||
|
|
da515570dc | ||
|
|
8457f54edc | ||
|
|
835a6c0cf0 | ||
|
|
04eee2410d | ||
|
|
3e701309a4 | ||
|
|
e9b1294331 | ||
|
|
381333c4a9 | ||
|
|
193e637de0 | ||
|
|
deb734c7f6 | ||
|
|
61b075a263 | ||
|
|
36eb16ce7d | ||
|
|
ed16f51e26 | ||
|
|
6628e542b5 | ||
|
|
507816b1d6 | ||
|
|
73b8c2ef3c | ||
|
|
36169d8a68 | ||
|
|
7c6c66cc3c | ||
|
|
6d3d47c25b | ||
|
|
1870cc70ef | ||
|
|
6b0091e185 | ||
|
|
a770a3bf7e | ||
|
|
7110226b96 | ||
|
|
ac85a3e0d3 | ||
|
|
9cc603cbad | ||
|
|
566ab9aa28 | ||
|
|
206d878127 | ||
|
|
47d06cb023 | ||
|
|
4ea07716de | ||
|
|
0aa6c6f647 | ||
|
|
88ee5b1a73 | ||
|
|
b931bbb319 | ||
|
|
817d199cbb | ||
|
|
67d2408279 | ||
|
|
07e37479c2 | ||
|
|
a6b1cbba02 | ||
|
|
5cd00eda0b | ||
|
|
745233d6a1 | ||
|
|
1764f66b7d | ||
|
|
54efe33799 | ||
|
|
d0cd68d5e4 | ||
|
|
ef54a08080 | ||
|
|
4223293ed8 | ||
|
|
f8cb759bdb | ||
|
|
3879509426 | ||
|
|
479d411dda | ||
|
|
52b6ca5706 | ||
|
|
1bdd4828bd | ||
|
|
b4520aaf2c | ||
|
|
eaa58d28dc | ||
|
|
e6b02dec19 | ||
|
|
00723f1f5c | ||
|
|
21f9b39f06 | ||
|
|
e24e9867ec | ||
|
|
6ce943f4d9 | ||
|
|
828001ecc5 | ||
|
|
58908b045b | ||
|
|
dcf41ec927 | ||
|
|
2b2b193791 | ||
|
|
7922f4ee7b | ||
|
|
5134666702 | ||
|
|
268f2b047a | ||
|
|
c284ebe0ad | ||
|
|
0d99519c3d | ||
|
|
64fb7e472a | ||
|
|
ab630f72ed | ||
|
|
96abf400a5 | ||
|
|
f733d3f3eb | ||
|
|
6aeb679066 | ||
|
|
15d7e564dd | ||
|
|
5b2048fbb9 | ||
|
|
55eb3e4773 | ||
|
|
92ecd611f6 | ||
|
|
875139f5fa | ||
|
|
7826d40ff9 | ||
|
|
edf96b06a5 | ||
|
|
ec1b8e5f05 | ||
|
|
2173365f4f | ||
|
|
7836779e21 | ||
|
|
25ae028695 | ||
|
|
1b0cc4503e | ||
|
|
a52fe9cf7f | ||
|
|
866b053f25 | ||
|
|
48897fbc44 | ||
|
|
67d995d100 | ||
|
|
ad98fad9a3 | ||
|
|
34084fe666 | ||
|
|
c5d74b1deb | ||
|
|
3bb11ec484 | ||
|
|
743939ec84 | ||
|
|
e00730d149 | ||
|
|
640149337f | ||
|
|
5f5f029e3b | ||
|
|
fa409194d3 | ||
|
|
08e2828592 | ||
|
|
bc5881c4d2 | ||
|
|
c416fe0da4 | ||
|
|
9ea05b2fb3 | ||
|
|
2349b1dbef | ||
|
|
067604bf8c | ||
|
|
7fb8eec8f1 | ||
|
|
c13838436e | ||
|
|
7a30e6b941 | ||
|
|
eb4d60b1ce | ||
|
|
0134574a67 | ||
|
|
c942f11ba8 | ||
|
|
5afe7eb850 | ||
|
|
b2fd161b07 | ||
|
|
d0655f321f | ||
|
|
fef8ee23c0 | ||
|
|
c16faa4fed | ||
|
|
bbcb199174 | ||
|
|
47c0405b33 | ||
|
|
f378a0b24d | ||
|
|
58f870ef6e | ||
|
|
eaf526b1ea | ||
|
|
87a11a9214 | ||
|
|
c2fde58701 | ||
|
|
daa93b3fdc | ||
|
|
1ebd8c1234 | ||
|
|
5d0504ee11 | ||
|
|
81d4f95c2f | ||
|
|
20c1f1aec6 | ||
|
|
82d0d85675 | ||
|
|
3c312a9150 | ||
|
|
0ed96c4609 | ||
|
|
0d3f306c8e | ||
|
|
350a434939 | ||
|
|
4bc445f080 | ||
|
|
dbdff241b2 | ||
|
|
5dfe9db788 | ||
|
|
f3dc38dcae | ||
|
|
48cbbb8757 | ||
|
|
1f966c495c | ||
|
|
b67fd8f472 | ||
|
|
16b7719418 | ||
|
|
518a687886 | ||
|
|
2dbf062a89 | ||
|
|
eb399e64d5 | ||
|
|
08b07b1a08 | ||
|
|
eb215d3d3f | ||
|
|
c225262e13 | ||
|
|
4408df1e8a | ||
|
|
bad95db878 | ||
|
|
4fc8741794 | ||
|
|
d9c95c900c | ||
|
|
a1006db91b | ||
|
|
57948a0dfc | ||
|
|
ccdebead79 | ||
|
|
4e5f80dc62 | ||
|
|
6700018ce5 | ||
|
|
b5de0a20d8 | ||
|
|
f7fb5df543 | ||
|
|
004ee66227 | ||
|
|
56e5067c46 | ||
|
|
1b96902d73 | ||
|
|
2cb268d51b | ||
|
|
fb7ce5b5d5 | ||
|
|
9fd62efcf0 | ||
|
|
0c5e9c6efa | ||
|
|
eb57cbcc29 | ||
|
|
b598bbcc2e | ||
|
|
f18cd5b19c | ||
|
|
bbe8ebf9c2 | ||
|
|
68d59a16ce | ||
|
|
7323ffeef2 | ||
|
|
4e2cc0ae2a | ||
|
|
341b330a04 | ||
|
|
eeedb43ae8 | ||
|
|
02253d1e5c | ||
|
|
f4c7141f5d | ||
|
|
8cf21feefd | ||
|
|
bbd1032a2a | ||
|
|
f0712a7569 | ||
|
|
9d1cecea8e | ||
|
|
e6995196f2 | ||
|
|
a74e37d32d | ||
|
|
d89510e1aa | ||
|
|
e3359f8349 | ||
|
|
2534aa4d2d | ||
|
|
e8adcae0f2 | ||
|
|
48c684cbc2 | ||
|
|
6f8f4bb206 | ||
|
|
cb1a626692 | ||
|
|
232050830b | ||
|
|
dd254b90d7 | ||
|
|
77deef733b | ||
|
|
24ab1bc714 | ||
|
|
647887b794 | ||
|
|
d018477359 | ||
|
|
827913102e | ||
|
|
1ee40307b5 | ||
|
|
d30b612809 | ||
|
|
697f938355 | ||
|
|
5ae2d421fb | ||
|
|
83be3afc54 | ||
|
|
c739772436 | ||
|
|
7a1abd66e7 | ||
|
|
d70d24d360 | ||
|
|
f27cac585c | ||
|
|
846d57e1b8 | ||
|
|
54670d898f | ||
|
|
c45b255a88 | ||
|
|
5e4f371408 | ||
|
|
7e4439beb7 | ||
|
|
74f150670a | ||
|
|
3c355ec3b0 | ||
|
|
d346d692eb | ||
|
|
63e07b245f | ||
|
|
a5e36a4bd6 | ||
|
|
658ecb0777 | ||
|
|
a23ce1b45f | ||
|
|
0feae4d8ae | ||
|
|
4b7e97ba53 | ||
|
|
b6b7486423 | ||
|
|
2e90841f2e | ||
|
|
b31515fec3 | ||
|
|
9a476c5f29 | ||
|
|
5423bf6db8 | ||
|
|
648471ecee | ||
|
|
7ce8135138 | ||
|
|
4fa1f961f3 | ||
|
|
df0334d3b3 | ||
|
|
6640790bdc | ||
|
|
39c55d5b6f | ||
|
|
79f09b4d85 | ||
|
|
e85ea9f67d | ||
|
|
2db9a18362 | ||
|
|
37583f0a69 | ||
|
|
06ad86053c | ||
|
|
5644d37876 | ||
|
|
ed0f2831b4 | ||
|
|
21fae50089 | ||
|
|
0f243f0388 | ||
|
|
9b3fefc435 | ||
|
|
45f4ff5485 | ||
|
|
eb8eeab05e | ||
|
|
26f2740110 | ||
|
|
a2d7f380b2 | ||
|
|
c4744620af | ||
|
|
3d660b0023 | ||
|
|
49bf7dc77e | ||
|
|
11315c589a | ||
|
|
2db5f9c215 | ||
|
|
cea87758e7 | ||
|
|
58bbce09e2 | ||
|
|
900e583c7a | ||
|
|
e698ee01dd | ||
|
|
2dd9a4fb9c | ||
|
|
b8b865fb17 | ||
|
|
da552eb73b | ||
|
|
b90a9fcd13 | ||
|
|
e19622b8db | ||
|
|
8f40f791d9 | ||
|
|
bb9a123ddd | ||
|
|
90dba3ec66 | ||
|
|
47712fc113 | ||
|
|
bf6d1aeaa4 | ||
|
|
df7b5292ab | ||
|
|
7e7c8faa34 | ||
|
|
f6a9f6b4ad | ||
|
|
9e7774bb96 | ||
|
|
7c78ebce45 | ||
|
|
80b82c8d14 | ||
|
|
8e33cc61b1 | ||
|
|
99852f8401 | ||
|
|
b749a39cdb | ||
|
|
b89f2f28bb | ||
|
|
a786a59176 | ||
|
|
eac055bfaf | ||
|
|
6ceeceab7a | ||
|
|
c9216493cf | ||
|
|
91b6145499 | ||
|
|
9cbbdb90bf | ||
|
|
f4d858e7a0 | ||
|
|
98ef369b27 | ||
|
|
fc2016dbb6 | ||
|
|
177599efb7 | ||
|
|
ad11d49d64 | ||
|
|
b74b8be680 | ||
|
|
ab244cc7ad | ||
|
|
a4be028b76 | ||
|
|
29b2d07b6b | ||
|
|
cbe781203f | ||
|
|
3a4cf62aa9 | ||
|
|
ddf53d6e4e | ||
|
|
3635b3cd6c | ||
|
|
bc112a8c89 | ||
|
|
55c694a467 | ||
|
|
be5af704ad | ||
|
|
6a489fa7f6 | ||
|
|
b9fbf02ad5 | ||
|
|
2da050413c | ||
|
|
abcd4bd246 | ||
|
|
cf30e0f935 | ||
|
|
68c2fc6824 | ||
|
|
4ff7bc3eb3 | ||
|
|
b6b4f86cfc | ||
|
|
6ce38b7395 | ||
|
|
a07df21e79 | ||
|
|
b434692db2 | ||
|
|
e483ce138f | ||
|
|
dae2868d12 | ||
|
|
5a501a8ae2 | ||
|
|
c4a9299956 | ||
|
|
3a6d90adad | ||
|
|
87ea14328c | ||
|
|
f797ac9ff6 | ||
|
|
c599ad63f8 | ||
|
|
80d76612b8 | ||
|
|
d83f356218 | ||
|
|
a1d4bf20f7 | ||
|
|
20b938bcb1 | ||
|
|
c14b0d7c00 | ||
|
|
bdab595095 | ||
|
|
50c4c5917d | ||
|
|
f1100f97f7 | ||
|
|
69a2f73449 | ||
|
|
e3c2772d2f | ||
|
|
70775b3c28 | ||
|
|
1d8e545bc1 | ||
|
|
c4a92e5799 | ||
|
|
97a317a656 | ||
|
|
cb5e681ef6 | ||
|
|
5aae58295e | ||
|
|
4a44ae06bf | ||
|
|
f4e835754c | ||
|
|
f8ad72b2ee | ||
|
|
fc1df91e03 | ||
|
|
c1573727f0 | ||
|
|
a0e2c1b4ca | ||
|
|
5f92f92908 | ||
|
|
adca856806 | ||
|
|
03945276f7 | ||
|
|
c1ede507d9 | ||
|
|
cd1fc42df6 | ||
|
|
ae541287d3 | ||
|
|
b3ca410bc3 | ||
|
|
ec151b79ec | ||
|
|
797042584e | ||
|
|
df07723e20 | ||
|
|
ee9bc355f5 | ||
|
|
250fdd08be | ||
|
|
9272fe36e2 | ||
|
|
5895f1d9f7 | ||
|
|
fadbf497a4 | ||
|
|
748633c887 | ||
|
|
d53c2d0ebe | ||
|
|
08f55414e1 | ||
|
|
7a4a286ea2 | ||
|
|
9ae658983c | ||
|
|
03da0ced46 | ||
|
|
539a6e7fa0 | ||
|
|
c95cd9ed5e | ||
|
|
c22470bd14 | ||
|
|
4c28ed4e4e | ||
|
|
31cb95893e | ||
|
|
ae83a5b010 | ||
|
|
29b70e2757 | ||
|
|
52b8274285 | ||
|
|
dcb2bb33a2 | ||
|
|
a924694820 | ||
|
|
0a94dbe051 | ||
|
|
8da756c4f0 | ||
|
|
7bb8ab1c0e | ||
|
|
5e9757b30b | ||
|
|
d1d3bbb458 | ||
|
|
45203582ff | ||
|
|
ebc9dcb3bb | ||
|
|
4bbf941436 | ||
|
|
f31847db62 | ||
|
|
f35f15b107 | ||
|
|
eef11b64e1 | ||
|
|
b8a9c740bb | ||
|
|
26b9a8e49b | ||
|
|
3e72e98e3b | ||
|
|
d5902eeae9 | ||
|
|
7e6a26cc9d | ||
|
|
b12df01861 | ||
|
|
9d42bd328c | ||
|
|
e337c1ba7d | ||
|
|
057c04e32a | ||
|
|
8e971f187a | ||
|
|
e8814a7e93 | ||
|
|
1a9f9c09b4 | ||
|
|
d9ad461b5e | ||
|
|
915097d312 | ||
|
|
181841fb67 | ||
|
|
43796bf131 | ||
|
|
e13c1e5320 | ||
|
|
e37f34facc | ||
|
|
c91680822d | ||
|
|
37bb993f53 | ||
|
|
db5a7c1740 | ||
|
|
1ec3fb5f30 | ||
|
|
8f40796f05 | ||
|
|
09e90c1645 | ||
|
|
f274b1b9d7 | ||
|
|
53914e50b9 | ||
|
|
e252984993 | ||
|
|
d3f0c72e20 | ||
|
|
4ca1de1b8b | ||
|
|
17bc11bd15 | ||
|
|
f6933e43c2 | ||
|
|
900238a306 | ||
|
|
027a7ac829 | ||
|
|
2c6c3a1d27 | ||
|
|
8382ae65b7 | ||
|
|
ec690208a3 | ||
|
|
b28b8312f2 | ||
|
|
c2d79add31 | ||
|
|
feff55b92f | ||
|
|
3d29b97768 | ||
|
|
39ea8a2787 | ||
|
|
480cdedcac | ||
|
|
88ee5a1a00 | ||
|
|
2c5f3074bc | ||
|
|
9d2ef8bf0d | ||
|
|
1a3a973bd0 | ||
|
|
adf9e77702 | ||
|
|
82e47403c6 | ||
|
|
41b8bb4eef | ||
|
|
b26523c26d | ||
|
|
200a1c62c6 | ||
|
|
e4eec92852 | ||
|
|
2df757521a | ||
|
|
8fb796b5b3 | ||
|
|
82b25a9d62 | ||
|
|
89d2c7eb26 | ||
|
|
026450c1a8 | ||
|
|
c5e2532b67 | ||
|
|
75d112c484 | ||
|
|
414208aab1 | ||
|
|
7dced37673 | ||
|
|
95d68fcba1 | ||
|
|
a05c3a7aa6 | ||
|
|
c17edd594e | ||
|
|
47795d1695 | ||
|
|
2ce8e0110c | ||
|
|
4425c1e1b3 | ||
|
|
409d52ed41 | ||
|
|
e90b5dcea3 | ||
|
|
ffcc60211d | ||
|
|
7cdb1cfc8d | ||
|
|
480ba99a16 | ||
|
|
8827b7f9a6 | ||
|
|
a4424fbebf | ||
|
|
eefbbfde77 | ||
|
|
7eeb479705 | ||
|
|
8d137233a9 | ||
|
|
c96957583f | ||
|
|
580cd16f4c | ||
|
|
4382538e4b | ||
|
|
e7a530fe4c | ||
|
|
05d07413ff | ||
|
|
b8360504f3 | ||
|
|
a062650d4b | ||
|
|
f012db9be9 | ||
|
|
299d4f3aaa | ||
|
|
eba6cf61c9 | ||
|
|
0ec410689c | ||
|
|
e0fd295054 | ||
|
|
99a8469ee4 | ||
|
|
12255411f2 | ||
|
|
c0116b2c5b | ||
|
|
799a154b91 | ||
|
|
793f4d89d6 | ||
|
|
90cd045cf3 | ||
|
|
94f6488f0e | ||
|
|
d4bf4bd7c7 | ||
|
|
522d1bd309 | ||
|
|
a21de4c483 | ||
|
|
714311a696 | ||
|
|
9f0904ce6f | ||
|
|
ae3eba6e08 | ||
|
|
6b332127ca | ||
|
|
bd40d704e2 | ||
|
|
65e5e14561 | ||
|
|
103e44d936 | ||
|
|
097973e3d5 | ||
|
|
5fef946df4 | ||
|
|
023c2c5392 | ||
|
|
e90d4a6021 | ||
|
|
2e84d1cf03 | ||
|
|
6431005169 | ||
|
|
9beb3eb593 | ||
|
|
6dee409981 | ||
|
|
f3fc81b178 | ||
|
|
463bd8abb9 | ||
|
|
a65a6d62d1 | ||
|
|
207789dc2d | ||
|
|
d7586d3d65 | ||
|
|
f8d3d247d8 | ||
|
|
6b0fa14470 | ||
|
|
a69211aff5 | ||
|
|
930245d7ff | ||
|
|
0dc8b7d5d8 | ||
|
|
19a3a9ee20 | ||
|
|
f3e01ecc42 | ||
|
|
6c260af56d | ||
|
|
e817821104 | ||
|
|
f006116bac | ||
|
|
43431e7e84 | ||
|
|
eb8b51effc | ||
|
|
389cf63cbc | ||
|
|
2148fe33cd | ||
|
|
1a6540fea0 | ||
|
|
7d702f3cef | ||
|
|
d0c462f718 | ||
|
|
238d2aa870 | ||
|
|
6bb505eb73 | ||
|
|
83b9807370 | ||
|
|
3e6e533779 | ||
|
|
27bfb56ad5 | ||
|
|
c49f2a0365 | ||
|
|
3e3eb1dd0f | ||
|
|
a4fe7e81c8 | ||
|
|
4ce26b0393 | ||
|
|
82bf0f4d48 | ||
|
|
8590ee65e6 | ||
|
|
d67b99c7e4 | ||
|
|
092c7bfeb8 | ||
|
|
bf2cf33fc6 | ||
|
|
75aeb733f2 | ||
|
|
723010ba72 | ||
|
|
7ca2e2fe88 | ||
|
|
9d450cc6d0 | ||
|
|
5571d7a21c | ||
|
|
e353d0cab3 | ||
|
|
282f7fbd37 | ||
|
|
b68fc7f104 | ||
|
|
54dfe36340 | ||
|
|
c4f4904f9b | ||
|
|
d769fec8d6 | ||
|
|
f1ce611345 | ||
|
|
3856116069 | ||
|
|
afe231c94c | ||
|
|
ae4cccb4f1 | ||
|
|
98ee93bde3 | ||
|
|
87d82170a6 | ||
|
|
3a7e15511b | ||
|
|
e128c7fcd8 | ||
|
|
8db89f8efb | ||
|
|
c271cb9ff8 | ||
|
|
6e0c663a89 | ||
|
|
56246c2936 | ||
|
|
54da493476 | ||
|
|
82ebd98c5f | ||
|
|
831c67c2d8 | ||
|
|
d6f7be6345 | ||
|
|
eb064e8a62 | ||
|
|
9b83b1daa6 | ||
|
|
4acd345c6a | ||
|
|
d9ac0e7576 | ||
|
|
dcf0bc2cc9 | ||
|
|
cf4566b47b | ||
|
|
50e77536fe | ||
|
|
cd4e467751 | ||
|
|
9228fead48 | ||
|
|
38b8a198ba | ||
|
|
1eefbd28e8 | ||
|
|
1ee944a19d | ||
|
|
1b0512aa7e | ||
|
|
b5b5d35eee | ||
|
|
c5f660e33a | ||
|
|
e1e520d741 | ||
|
|
699d9d2fac | ||
|
|
c3c3927c2b | ||
|
|
00f19b7f91 | ||
|
|
42da951edf | ||
|
|
180bbab1fc | ||
|
|
69c59c52b6 | ||
|
|
19370631ea | ||
|
|
99c1853792 | ||
|
|
a131655235 | ||
|
|
677bb168a9 | ||
|
|
c91323e4d6 | ||
|
|
50d1d04913 | ||
|
|
67e2f5869a | ||
|
|
3a9c199ae7 | ||
|
|
bd6d0b3101 | ||
|
|
f1dd65cbdf | ||
|
|
c18d7c5fcb | ||
|
|
0d64531f66 | ||
|
|
f44dafd224 | ||
|
|
198b0a23a2 | ||
|
|
ad27b7decd | ||
|
|
fc00839adc | ||
|
|
aa13bd4016 | ||
|
|
d62fd78655 | ||
|
|
6dcca5fda4 | ||
|
|
c5f6ea5c0d | ||
|
|
004a9b52f0 | ||
|
|
e5f06d2cf6 | ||
|
|
cb10bfb8ef | ||
|
|
2e00d775e4 | ||
|
|
21d9750450 | ||
|
|
f431e20f3d | ||
|
|
3c68e51609 | ||
|
|
299b7289ea | ||
|
|
4bc45fc95a | ||
|
|
f9682d2e55 | ||
|
|
a384245c5a | ||
|
|
b24d7d9c95 | ||
|
|
453a62c672 | ||
|
|
89db309e10 | ||
|
|
d53d3bce59 | ||
|
|
3439c02e9d | ||
|
|
fcd0e3082b | ||
|
|
d9767b8112 | ||
|
|
85a9c2f52b | ||
|
|
69440d19b7 | ||
|
|
eac30a86d7 | ||
|
|
d4177e954c | ||
|
|
45ae9a8e35 | ||
|
|
9f75635596 | ||
|
|
4d505574dc | ||
|
|
e8e4f4ec3e | ||
|
|
4097257bef | ||
|
|
a14512e23e | ||
|
|
84e4652513 | ||
|
|
fc3d85e34b | ||
|
|
43656d4ea7 | ||
|
|
fff85d854e | ||
|
|
cf6075fb29 | ||
|
|
33298d6df6 | ||
|
|
4bb48998e0 | ||
|
|
5d9e591ae8 | ||
|
|
4d16df9312 | ||
|
|
18e554aa61 | ||
|
|
4cb13d95ba | ||
|
|
e36d6ee06a | ||
|
|
901eed7b71 | ||
|
|
750d5830c2 | ||
|
|
e286178aa7 | ||
|
|
c176361788 | ||
|
|
dc7e53897a | ||
|
|
429c4bc51b | ||
|
|
1156d91cf8 | ||
|
|
4c5b0fbbcc | ||
|
|
5a288b1efe | ||
|
|
82c789ee58 | ||
|
|
7e0f9ab3eb | ||
|
|
87bd8965c6 | ||
|
|
2aa517c805 | ||
|
|
ec81bd2399 | ||
|
|
3ab229da70 | ||
|
|
2cecabd75e | ||
|
|
c4b0da5513 | ||
|
|
5489796737 | ||
|
|
85f09f9a4c | ||
|
|
293fd0d258 | ||
|
|
dfb7bb6830 | ||
|
|
f1e14f86c4 | ||
|
|
6644d209d2 | ||
|
|
7c4a2253e8 | ||
|
|
2d65bbd941 | ||
|
|
a609e6361a | ||
|
|
32a81e197b | ||
|
|
f2c0605d6d | ||
|
|
1677bb0dea | ||
|
|
dddc544b8f | ||
|
|
643eecde86 | ||
|
|
567d3e27ab | ||
|
|
a2e08b587a | ||
|
|
cb75ec25c8 | ||
|
|
7d06216289 | ||
|
|
4ab208ecc8 | ||
|
|
6aa0bedad2 | ||
|
|
c6e39976c6 | ||
|
|
c869366133 | ||
|
|
b9022e33ea | ||
|
|
772b3b7a06 | ||
|
|
b0d7623b7e | ||
|
|
4a96f599f6 | ||
|
|
564e44adc6 | ||
|
|
6752f41c2a | ||
|
|
51c09bf2b4 | ||
|
|
d24a44230a | ||
|
|
8d752f5aaa | ||
|
|
e7827f8bc2 | ||
|
|
f980e868dd | ||
|
|
3c1f0cfc34 | ||
|
|
5b9211d827 | ||
|
|
3f189945d8 | ||
|
|
f3ab05e7cd | ||
|
|
2219f7cc73 | ||
|
|
1fd3b9ec1c | ||
|
|
da31eddadc | ||
|
|
c660e46149 | ||
|
|
e3b1358bbc | ||
|
|
5943cd1907 | ||
|
|
78287e27c8 | ||
|
|
82bc2c87a9 | ||
|
|
cd4c94f76b | ||
|
|
bba1809eac | ||
|
|
e6ee3e9504 | ||
|
|
1c1ec84aa3 | ||
|
|
f3fcf977e4 | ||
|
|
4a3ac3bd26 | ||
|
|
3c5d3a3780 | ||
|
|
fe44f90e5b | ||
|
|
031e9bc854 | ||
|
|
0cbccc90ab | ||
|
|
71d90c11dd | ||
|
|
2546572e8e | ||
|
|
835ccbac46 | ||
|
|
b5b67c5386 | ||
|
|
fbe488e4de | ||
|
|
bb629f3be7 | ||
|
|
883a428e27 | ||
|
|
e44e2c48dd | ||
|
|
ece737274e | ||
|
|
5ece386cdf | ||
|
|
7653328ce7 | ||
|
|
fc111d2b12 | ||
|
|
04402db616 | ||
|
|
1b5a8a0f09 | ||
|
|
e33b623f21 | ||
|
|
73b54a0e5f | ||
|
|
5a97af7961 | ||
|
|
f4aefb738e | ||
|
|
481c3f3f2e | ||
|
|
cb039b986e | ||
|
|
f6c54f3f03 | ||
|
|
06d58b3b7b | ||
|
|
8968acd678 | ||
|
|
c9ef144dca | ||
|
|
09f71ed1b2 | ||
|
|
f0ddc301b7 | ||
|
|
916c4c499d | ||
|
|
fac792dc27 | ||
|
|
bbcfee362f | ||
|
|
bfc1f0ca62 | ||
|
|
7bcc0d16f2 | ||
|
|
f03776c262 | ||
|
|
ffa4d48967 | ||
|
|
79c3fd4f39 | ||
|
|
6d071c468c | ||
|
|
294accea1b | ||
|
|
792fcb1dbf | ||
|
|
da359269cb | ||
|
|
92da105b58 | ||
|
|
ecc5cea09b | ||
|
|
d68a17a1df | ||
|
|
52cb7a6382 | ||
|
|
00fda57ddf | ||
|
|
405bb8435c | ||
|
|
c6c4960b35 | ||
|
|
2c4f2393ec | ||
|
|
08bc226527 | ||
|
|
6b38334b28 | ||
|
|
c1f0918f8a | ||
|
|
6861045d38 | ||
|
|
9f8d193b11 | ||
|
|
a13e57f701 | ||
|
|
e722ba38e3 | ||
|
|
b1dc2b5353 | ||
|
|
e0e08fcd2d | ||
|
|
0a913b09cf | ||
|
|
4f7a5d1e40 | ||
|
|
6ac84585e6 | ||
|
|
d21f8ecc13 | ||
|
|
5e2150cf18 | ||
|
|
a07ad6b5a3 | ||
|
|
ff4d7d541f | ||
|
|
e8f4ca6a52 | ||
|
|
a084f2dcb7 | ||
|
|
517d673dbe | ||
|
|
b4a301f8fe | ||
|
|
04a1fc9d36 | ||
|
|
0292243b29 | ||
|
|
ef38a420b2 | ||
|
|
7536d57b16 | ||
|
|
9ee1a8f701 | ||
|
|
0e0f2f765b | ||
|
|
bff957a475 | ||
|
|
ed962e7612 | ||
|
|
458b87150b | ||
|
|
ae46a19b8e | ||
|
|
3b959c05ff | ||
|
|
46f642b030 | ||
|
|
8b74e959ef | ||
|
|
320237fdb8 | ||
|
|
161b57869e | ||
|
|
92732a2540 | ||
|
|
b3eebdec48 | ||
|
|
b24c9e34a9 | ||
|
|
073d439965 | ||
|
|
f956c17c09 | ||
|
|
0406ec0ec2 | ||
|
|
f34ebfed76 | ||
|
|
962f255ee8 | ||
|
|
c62404673e | ||
|
|
979313832c | ||
|
|
1d6fe43c7b | ||
|
|
4cbf596dc5 | ||
|
|
d738d51688 | ||
|
|
acb2413852 | ||
|
|
2628af573d | ||
|
|
aa2b3472c5 | ||
|
|
ce6be7afd4 | ||
|
|
d2d43987d0 | ||
|
|
bd3332b211 | ||
|
|
3a298454ce | ||
|
|
b588b1729a | ||
|
|
818fda0363 | ||
|
|
b4f5b99e4b | ||
|
|
e8b33af780 | ||
|
|
1d306e926a | ||
|
|
33595a255f | ||
|
|
85044a634b | ||
|
|
2d71bef0ca | ||
|
|
f6d34f066c | ||
|
|
672c49d512 | ||
|
|
27578815da | ||
|
|
25e2e22791 | ||
|
|
10d60faba5 | ||
|
|
2c755e3c55 | ||
|
|
bace79a571 | ||
|
|
4206bcc10e | ||
|
|
38064e7593 | ||
|
|
1416ceb575 | ||
|
|
d58bccfc63 | ||
|
|
9bd4b96766 | ||
|
|
0b32fa81b6 | ||
|
|
0425e3178d | ||
|
|
13f9a061ac | ||
|
|
f33d2ab29e | ||
|
|
1e9f8a3523 | ||
|
|
2fbd491ff0 | ||
|
|
81b393a493 | ||
|
|
5755bfc619 | ||
|
|
10f0094be9 | ||
|
|
786f5e505e | ||
|
|
6dffbc4849 | ||
|
|
e6fd429d58 | ||
|
|
95ab1aaaec | ||
|
|
f628afc850 | ||
|
|
49f04a997a | ||
|
|
1aeac384f3 | ||
|
|
9032ac2a05 | ||
|
|
71e00c718c | ||
|
|
7a6b21de65 | ||
|
|
4f5cb88c2b | ||
|
|
0e6eda02a6 | ||
|
|
feaa5660a3 | ||
|
|
b03f58b977 | ||
|
|
b2bc34af12 | ||
|
|
400529eea0 | ||
|
|
938156d73b | ||
|
|
ba4a884d75 | ||
|
|
2796ae81d0 | ||
|
|
f3f534a3a0 | ||
|
|
6c3ee42568 | ||
|
|
2f0ffe6adb | ||
|
|
4002dbf0c1 | ||
|
|
162d3cb1f4 | ||
|
|
7d2004a8dd | ||
|
|
860acecc0d | ||
|
|
028f9d1d87 | ||
|
|
303d20a758 | ||
|
|
3f0efc050a | ||
|
|
7804fa1b82 | ||
|
|
7b819357ff | ||
|
|
595b52490e | ||
|
|
3ec05e9405 | ||
|
|
f8a30e1588 | ||
|
|
3f6bfbaf2b | ||
|
|
95d340cc4f | ||
|
|
ff4c80d53d | ||
|
|
bc72cf2f52 | ||
|
|
de730f68a4 | ||
|
|
9cc04a0f9a | ||
|
|
349aeb806a | ||
|
|
f98c66ece8 | ||
|
|
a1009e7bd3 | ||
|
|
3c24bc5617 | ||
|
|
7f093fcddc | ||
|
|
5a564a0c1a | ||
|
|
9ebd630675 | ||
|
|
5cdd578906 | ||
|
|
a870c255c4 | ||
|
|
d5c837904b | ||
|
|
fa33603dc1 | ||
|
|
fa8294436c | ||
|
|
82f0c859a2 | ||
|
|
9768091ee4 | ||
|
|
f9c396db41 | ||
|
|
bdb7e48cba | ||
|
|
c42e89a598 | ||
|
|
afd3127d89 | ||
|
|
4ab3b18b36 | ||
|
|
2ea22fce5e | ||
|
|
cd8a7fb07b | ||
|
|
cd39920abd | ||
|
|
469a9e9439 | ||
|
|
34c0807be6 | ||
|
|
c9d482ab48 | ||
|
|
bde0224deb | ||
|
|
b6cdac05c7 | ||
|
|
4e3d661284 | ||
|
|
1c5093c1c4 | ||
|
|
67254ed8df | ||
|
|
6cf2f74fe9 | ||
|
|
1ed994a6c8 | ||
|
|
40d246b29c | ||
|
|
2977317243 | ||
|
|
3a7b9d5735 | ||
|
|
2eca63b98e | ||
|
|
c4b04b1624 | ||
|
|
efd01f3bfd | ||
|
|
749f67b7d8 | ||
|
|
a7da2357a5 | ||
|
|
f103927a52 | ||
|
|
0fd73f238d | ||
|
|
50cdfc06fb | ||
|
|
3c6cdf0115 | ||
|
|
86e648d906 | ||
|
|
849d06c0df | ||
|
|
09aee53763 | ||
|
|
4efba0bf9f | ||
|
|
0c7f64458f | ||
|
|
ff77010f70 | ||
|
|
7339845c01 | ||
|
|
99072e1d81 | ||
|
|
f9881b3b5d | ||
|
|
b1ad075d11 | ||
|
|
ef904cfef2 | ||
|
|
ddffda4da5 | ||
|
|
d5b92ac37e | ||
|
|
0a54a07909 | ||
|
|
65dd7345e0 | ||
|
|
0cefdff1b6 | ||
|
|
e771f10dc6 | ||
|
|
fc41bf46ac | ||
|
|
2808f8261c | ||
|
|
c234032fcf | ||
|
|
bc6211cca5 | ||
|
|
164590e34c | ||
|
|
9feb35b7c4 | ||
|
|
f44d02c7f5 | ||
|
|
646995384d | ||
|
|
2dfdb55ace | ||
|
|
a51668ca06 | ||
|
|
bc0e527f32 | ||
|
|
f54f171d5c | ||
|
|
01918cb017 | ||
|
|
a2c52d9f26 | ||
|
|
407075d8c7 | ||
|
|
cdd8c93f54 | ||
|
|
c88e945bc5 | ||
|
|
018f1b8a80 | ||
|
|
4b9e76aaaa | ||
|
|
46847e9b2e | ||
|
|
1952b3f746 | ||
|
|
546060f340 | ||
|
|
c44bb2df17 | ||
|
|
f7c85f3ed8 | ||
|
|
5a7cf897f2 | ||
|
|
8053b65f1e | ||
|
|
a00cdcdfcb | ||
|
|
228e1a3951 | ||
|
|
ebaf54251a | ||
|
|
b74b047730 | ||
|
|
04c6db2d0f | ||
|
|
6abb62df1e | ||
|
|
7cf00d6b72 | ||
|
|
7d59f82cf9 | ||
|
|
cbf1504fca | ||
|
|
83b2d5c513 | ||
|
|
b4e74f4310 | ||
|
|
26d73a7736 | ||
|
|
57069287a1 | ||
|
|
4799f43298 | ||
|
|
7bc6c105b7 | ||
|
|
ad71e7f9d2 | ||
|
|
71d2ab184b | ||
|
|
c067af8e7d | ||
|
|
3fa538181b | ||
|
|
be2201200f | ||
|
|
84df87011c | ||
|
|
5e36d52651 | ||
|
|
bd9133b31d | ||
|
|
9b32758a0c | ||
|
|
5aa435a9f0 | ||
|
|
1b92afa799 | ||
|
|
a618271e12 | ||
|
|
8598fd1bc5 | ||
|
|
59df942e09 | ||
|
|
621bb15b83 | ||
|
|
8e24b0bb3e | ||
|
|
0c07b10b30 | ||
|
|
8f9491ddfe | ||
|
|
9bab73f489 | ||
|
|
4e867202e8 | ||
|
|
e27b588b6c | ||
|
|
479cac4896 | ||
|
|
95e3e363ff | ||
|
|
7637518b07 | ||
|
|
9263a65b5f | ||
|
|
b29028a914 | ||
|
|
1ea17a72f0 | ||
|
|
f57aa143c1 | ||
|
|
e53094bc5f | ||
|
|
18b611bc8d | ||
|
|
79d2351ce8 | ||
|
|
79a9472dbc | ||
|
|
d64daf874f | ||
|
|
1b4402c823 | ||
|
|
7fbd2f5498 | ||
|
|
45841400f2 | ||
|
|
f38b5a1b58 | ||
|
|
da5d563375 | ||
|
|
bceccc6b63 | ||
|
|
183193bdbc | ||
|
|
5b93f0fcd3 | ||
|
|
ee3e0eb183 | ||
|
|
55db3623bf | ||
|
|
db8849e7ca | ||
|
|
bfc9fb4b3b | ||
|
|
314ee137a9 | ||
|
|
f36d2ecb07 | ||
|
|
98a478ceb3 | ||
|
|
9f39470b38 | ||
|
|
458b4b7701 | ||
|
|
31508228bc | ||
|
|
1e8c9fb490 | ||
|
|
098967a085 | ||
|
|
665f046950 | ||
|
|
641191ab20 | ||
|
|
9f2db6a0af | ||
|
|
bf03197e18 | ||
|
|
cac4eadca0 | ||
|
|
3310972d75 | ||
|
|
d95fad3d5f | ||
|
|
9ecf657703 | ||
|
|
88327c7698 | ||
|
|
e811132b05 | ||
|
|
bd2896b65e | ||
|
|
522d751eee | ||
|
|
3bc08b0dc0 | ||
|
|
af679326b2 | ||
|
|
aa6e6fa0f2 | ||
|
|
9bdbe171b7 | ||
|
|
98a3c98c28 | ||
|
|
de2ddddd60 | ||
|
|
a9ffb56b65 | ||
|
|
14b97fc889 | ||
|
|
d0a600ccaa | ||
|
|
a368548645 | ||
|
|
13fe06a459 | ||
|
|
87e87030fe | ||
|
|
a5ef1f2ed6 | ||
|
|
f5d7a80272 | ||
|
|
33f9b316a3 | ||
|
|
d6ff630498 | ||
|
|
eceaa9a493 | ||
|
|
2e19a5ecb9 | ||
|
|
fb1f0fee5a | ||
|
|
6048b0f483 | ||
|
|
f12b857415 | ||
|
|
79bdca4638 | ||
|
|
21f8ac2766 | ||
|
|
89b56c3451 | ||
|
|
fe7486d43b | ||
|
|
400b807d75 | ||
|
|
5f07da6227 | ||
|
|
7eb3ef66e5 | ||
|
|
82776c456e | ||
|
|
80bdd89856 | ||
|
|
ed6327c87b | ||
|
|
b21a710de7 | ||
|
|
aa32457772 | ||
|
|
5c78b48cdf | ||
|
|
5fc2d4a4fc | ||
|
|
969af935f3 | ||
|
|
4f04b2094c | ||
|
|
0d88f8a78b | ||
|
|
6de991d855 | ||
|
|
ff67ef945d | ||
|
|
711b8164bb | ||
|
|
35985c0add | ||
|
|
cfc81692e6 | ||
|
|
a4a7c3c68d | ||
|
|
e7d53020b4 | ||
|
|
03519021b9 | ||
|
|
6f2698004e | ||
|
|
28a5bc8fae | ||
|
|
20154f391e | ||
|
|
98c4291df2 | ||
|
|
5c0ce192ed | ||
|
|
cc743dc296 | ||
|
|
d254293a6d | ||
|
|
850c26dd46 | ||
|
|
db07f33886 | ||
|
|
2fae6a5761 | ||
|
|
2ee0962c96 | ||
|
|
42935bde71 | ||
|
|
ffebf00585 | ||
|
|
ead6d652ff | ||
|
|
a14aa788d4 | ||
|
|
d8721b35a0 | ||
|
|
97738921cd | ||
|
|
486ce9b098 | ||
|
|
8fb6666f17 | ||
|
|
cb77c2aa78 | ||
|
|
0c94c3fbee | ||
|
|
94712a8b0d | ||
|
|
dec6ec9e29 | ||
|
|
9da78d72de | ||
|
|
d0c992306d | ||
|
|
54c2d48d7d | ||
|
|
e6cbeb4f38 | ||
|
|
4581240ced | ||
|
|
f6bad7efd7 | ||
|
|
713e0ddef3 | ||
|
|
ff45b2d343 | ||
|
|
91280f1fca | ||
|
|
7de25d86e1 | ||
|
|
ba31d3a88c | ||
|
|
54cd292f09 | ||
|
|
d1f5142dab | ||
|
|
058d2b94dc | ||
|
|
c177a627d2 | ||
|
|
8f8e0975f1 | ||
|
|
b602c1fb9a | ||
|
|
7448b38327 | ||
|
|
85d5a377c5 | ||
|
|
b9a6162d2f | ||
|
|
8f5903d7c3 | ||
|
|
f0ac0d6793 | ||
|
|
2a04665626 | ||
|
|
07c0970f54 | ||
|
|
546123f950 | ||
|
|
f2f9605c63 | ||
|
|
e4e060f2be | ||
|
|
e3b034fac7 | ||
|
|
82c0eed36d | ||
|
|
80994a8de1 | ||
|
|
9e1093b7d7 | ||
|
|
f2029f9d9e | ||
|
|
b2a2c3a1e9 | ||
|
|
f915a4bf0c | ||
|
|
91b220525b | ||
|
|
988c6bc433 | ||
|
|
1d858aa89e | ||
|
|
e24a077752 | ||
|
|
645fe9013f | ||
|
|
896c1da7da | ||
|
|
d24bd7394d | ||
|
|
aebb17dc75 | ||
|
|
d9d2f84a4b | ||
|
|
068d1b97b2 | ||
|
|
4bf6f2706e | ||
|
|
9f39652d87 | ||
|
|
c48440fd40 | ||
|
|
1afe71cc0a | ||
|
|
0e1b339c10 | ||
|
|
3dceddd70e | ||
|
|
2595718dd3 | ||
|
|
6ebd737590 | ||
|
|
e64d078a4c | ||
|
|
ae0b7c7d72 | ||
|
|
a770ef3e2a | ||
|
|
b95d1de8fd | ||
|
|
7e5262ae9a | ||
|
|
14ecb5032e | ||
|
|
1bd66b65a3 | ||
|
|
051a29ca03 | ||
|
|
c6975b3bb4 | ||
|
|
68bf7c532b | ||
|
|
9b73d76ddd | ||
|
|
5d616f4c72 | ||
|
|
8a81993ae1 | ||
|
|
b5c0b2cae2 | ||
|
|
803b8815bd | ||
|
|
785ce66ab9 | ||
|
|
640d97afd0 | ||
|
|
194e9f611b | ||
|
|
ea295ac397 | ||
|
|
5512de6a61 | ||
|
|
26792b9035 | ||
|
|
919f55ac4a | ||
|
|
2cd0ba5057 | ||
|
|
80283f99fb | ||
|
|
ced74bd72c | ||
|
|
50e3e3e72f | ||
|
|
c8a706117f | ||
|
|
0b3911631b | ||
|
|
0ca78ee51f | ||
|
|
f87d80737e | ||
|
|
9fd9952752 | ||
|
|
19f3a5c612 | ||
|
|
3c451a64b5 | ||
|
|
85c48aafff | ||
|
|
61ea49c6dd | ||
|
|
3b8f92359d | ||
|
|
182357f24b | ||
|
|
0ca9664ecf | ||
|
|
508e2f0b3a | ||
|
|
f5a37d0071 | ||
|
|
4d72b8fff7 | ||
|
|
9464b94f64 | ||
|
|
c2aa40449c | ||
|
|
3f3f13fbd7 | ||
|
|
e97daead43 | ||
|
|
623f4b12d3 | ||
|
|
5a44e18490 | ||
|
|
ab6f0bb348 | ||
|
|
4e8b1b9ac2 | ||
|
|
d81aec2439 | ||
|
|
6ae04dd5a0 | ||
|
|
968296bb07 | ||
|
|
320abba341 | ||
|
|
88711e885e | ||
|
|
7f4513ec34 | ||
|
|
2d5101621b | ||
|
|
0817132f97 | ||
|
|
24abfb72eb | ||
|
|
fe7a871a23 | ||
|
|
4e4c500879 | ||
|
|
0407d847a4 | ||
|
|
19afd842bf | ||
|
|
17d4c39f24 | ||
|
|
d9e740f86d | ||
|
|
c9037fde1c | ||
|
|
84ddc72744 | ||
|
|
75842bfe66 | ||
|
|
5849b73b81 | ||
|
|
58e9d12f23 | ||
|
|
53b25635da | ||
|
|
481703d669 | ||
|
|
b0c1cefeda | ||
|
|
2c5a6f9af5 | ||
|
|
c03565611e | ||
|
|
f32fd2df69 | ||
|
|
829fe38ab1 | ||
|
|
06684c93de | ||
|
|
d17c90583a | ||
|
|
fe26f977e6 | ||
|
|
6e99a2f4bb | ||
|
|
c9896d9554 | ||
|
|
ad417f6eb7 | ||
|
|
299c552e33 | ||
|
|
cd46568ebe | ||
|
|
937f8ed095 | ||
|
|
6ce8fe0537 | ||
|
|
c363c236aa | ||
|
|
e19df0e869 | ||
|
|
7ba5ad4cfb | ||
|
|
5c82432200 | ||
|
|
74ecc866cf | ||
|
|
b20a00f93e | ||
|
|
641a885af8 | ||
|
|
62144b9f57 | ||
|
|
43a1294ed9 | ||
|
|
58f6456af7 | ||
|
|
2c6af068d7 | ||
|
|
695dc5a153 | ||
|
|
5fddddbe21 | ||
|
|
e5ae9dd53d | ||
|
|
102df8dc80 | ||
|
|
e58d16b2df | ||
|
|
e755ca37b3 | ||
|
|
3b649d2fcd | ||
|
|
533a5719c5 | ||
|
|
aeda2e5808 | ||
|
|
392da897ff | ||
|
|
d81fa579c3 | ||
|
|
515da63d2b | ||
|
|
384736e955 | ||
|
|
6f3b6c8d92 | ||
|
|
a2681ffcee | ||
|
|
50a5f84cb4 | ||
|
|
24c387206c | ||
|
|
ba93a647f1 | ||
|
|
e1606172dd | ||
|
|
c9ec33d0d0 | ||
|
|
43264dfbf4 | ||
|
|
8d37f699ad | ||
|
|
8c29f7413b | ||
|
|
17655e5ba6 | ||
|
|
95850e1aca | ||
|
|
c1f62f1fde | ||
|
|
3887d95bca | ||
|
|
cf782c4f54 | ||
|
|
e91e8a2a6c | ||
|
|
d36ac3db15 | ||
|
|
be4c01697c | ||
|
|
0072bc65e6 | ||
|
|
37f83adca8 | ||
|
|
578a63bbc9 | ||
|
|
6b83ca0077 | ||
|
|
78ae4ee82c | ||
|
|
d6edd06749 | ||
|
|
6e8d29e9a2 | ||
|
|
8dd776106d | ||
|
|
e85213a944 | ||
|
|
26f1857154 | ||
|
|
f7a037ba26 | ||
|
|
61114c6c72 | ||
|
|
d3e8709ab5 | ||
|
|
37531673a3 | ||
|
|
31901e3c07 | ||
|
|
a34de2e378 | ||
|
|
2f6935a630 | ||
|
|
a5fd5782f8 | ||
|
|
fb02df66cc | ||
|
|
d10def5b0b | ||
|
|
2357bfb254 | ||
|
|
87babfa473 | ||
|
|
eb9839fd32 | ||
|
|
6e5121be7e | ||
|
|
4efd41f3af | ||
|
|
99351c9cae | ||
|
|
60074a6bc6 | ||
|
|
a3967de9a5 | ||
|
|
044019d9d6 | ||
|
|
db44151a37 | ||
|
|
ceab7154d4 | ||
|
|
0b4c408168 | ||
|
|
f069c0ba09 | ||
|
|
9c4caf49a2 | ||
|
|
2be01ab4ec | ||
|
|
b462063cd5 | ||
|
|
8aaf86a6ea | ||
|
|
bd71cbbe27 | ||
|
|
88517ceebb | ||
|
|
6a292f09ba | ||
|
|
71ec616e4d | ||
|
|
ff526e43de | ||
|
|
d563aa7c7b | ||
|
|
ae5a62a514 | ||
|
|
c86d83f835 | ||
|
|
9a1b9f15a1 | ||
|
|
af2c7ce646 | ||
|
|
b541a97821 | ||
|
|
a8b84b7cfa | ||
|
|
495e2ed17f | ||
|
|
d8c397d1b7 | ||
|
|
d8d6c2746e | ||
|
|
6fdaaa0637 | ||
|
|
034b19b734 | ||
|
|
cb8eba1530 | ||
|
|
7aa8b8a25c | ||
|
|
abcbfcb0e8 | ||
|
|
70bc07a358 | ||
|
|
7f83b53027 | ||
|
|
8405fcdd9b | ||
|
|
f56f09ea38 | ||
|
|
c62cfe64c8 | ||
|
|
78cf3c14ca | ||
|
|
89e057dc4a | ||
|
|
466066c3a1 | ||
|
|
ff3d05d92f | ||
|
|
eadd79acec | ||
|
|
d019821281 | ||
|
|
f4848b437f | ||
|
|
e941e532fa | ||
|
|
a1986c5973 | ||
|
|
6e2b3f435a | ||
|
|
07d3c4d882 | ||
|
|
f81e87f1e2 | ||
|
|
6abfd9b8ff | ||
|
|
07c679b52d | ||
|
|
b4c633cc40 | ||
|
|
54c5070767 | ||
|
|
17cf1b21c6 | ||
|
|
8f364053ca | ||
|
|
2e4e521629 | ||
|
|
fa20f19494 | ||
|
|
c1d8b0f74e | ||
|
|
3815e4f05e | ||
|
|
72488b526b | ||
|
|
5fec6c598e | ||
|
|
dee6bb5a31 | ||
|
|
566b9623b3 | ||
|
|
3f3fb43850 | ||
|
|
2248b886fe | ||
|
|
82b30f2322 | ||
|
|
6b841a036a | ||
|
|
a7d1ee5433 | ||
|
|
0f7160eb2f | ||
|
|
91d6bff8b8 | ||
|
|
5cdccf78a1 | ||
|
|
5fc0be5045 | ||
|
|
9852bd743c | ||
|
|
7d3bf6453e | ||
|
|
fe4467ad2b | ||
|
|
b2322b3893 | ||
|
|
fccfc4e4be | ||
|
|
e65cc09276 | ||
|
|
25cf126de8 | ||
|
|
1492c9d7d9 | ||
|
|
3c63ad4a9c | ||
|
|
3b40f8e42c | ||
|
|
08b125194e | ||
|
|
1d60dd5872 | ||
|
|
f0ce29c341 | ||
|
|
e1b3dc89d2 | ||
|
|
0f708dd6e2 | ||
|
|
730312e60f | ||
|
|
bbe9da063e | ||
|
|
7ec2a2b9ce | ||
|
|
ccdc369025 | ||
|
|
768740ae98 | ||
|
|
07a13697e1 | ||
|
|
8daa1d5f54 | ||
|
|
de86bf1856 | ||
|
|
2103a09430 | ||
|
|
c6a8ad23a1 | ||
|
|
c1ec28a34b | ||
|
|
0824850bbc | ||
|
|
27c3852103 | ||
|
|
ac2ba0961b | ||
|
|
237b7a50f4 | ||
|
|
5dd5543fe4 | ||
|
|
4bb5bb9450 | ||
|
|
31b06571aa | ||
|
|
e7b1e05bbd | ||
|
|
6f9b9655d7 | ||
|
|
45ee118b26 | ||
|
|
0d6fc7eb1e | ||
|
|
ed8ddf2449 | ||
|
|
b4c9f6edba | ||
|
|
a704f57971 | ||
|
|
6b60a5c6d6 | ||
|
|
147740ed40 | ||
|
|
3df7c91f1a | ||
|
|
58744de3eb | ||
|
|
b1bd0c7fc1 | ||
|
|
76887b1d27 | ||
|
|
06a2644ab2 | ||
|
|
ef9afddd1a | ||
|
|
3065b21375 | ||
|
|
358df10191 | ||
|
|
3bb426d92c | ||
|
|
26db50d6df | ||
|
|
8c6ad55320 | ||
|
|
e0d49ad758 | ||
|
|
e725b96a59 | ||
|
|
11e2af6df7 | ||
|
|
acbbc93501 | ||
|
|
932f6cfbfc | ||
|
|
1265e212e4 | ||
|
|
e4cd8751a2 | ||
|
|
2678fe53f5 | ||
|
|
e3698e6e1f | ||
|
|
8b84fc177c | ||
|
|
5122f3477f | ||
|
|
1076a2e26c | ||
|
|
fba6140a4a | ||
|
|
51112221ee | ||
|
|
0453ad0146 | ||
|
|
ed3cfaafb2 | ||
|
|
d0d42dc4cb | ||
|
|
fbbf5a108b | ||
|
|
58b796608f | ||
|
|
05062e7d2d | ||
|
|
bfaa885f10 | ||
|
|
9913cce3ba | ||
|
|
1029f2b277 | ||
|
|
1f7ca973c5 | ||
|
|
6b1ceca86a | ||
|
|
53d4ed22e8 | ||
|
|
feb044bd2d | ||
|
|
bedf8bd437 | ||
|
|
6cb4a3bb19 | ||
|
|
4039802fce | ||
|
|
5e98770936 | ||
|
|
6ee0afb579 | ||
|
|
4e01036cb6 | ||
|
|
28687f2d55 | ||
|
|
42285ac989 | ||
|
|
6fba9a39b7 | ||
|
|
fa677fc0e1 | ||
|
|
b565644c81 | ||
|
|
7247553c77 | ||
|
|
f059fe3ef2 | ||
|
|
8b0fd63ddb | ||
|
|
336beeb09a | ||
|
|
a00b0d13ed | ||
|
|
1ca920bbeb | ||
|
|
1e376be13d | ||
|
|
6995497e5b | ||
|
|
95ed7d48c8 | ||
|
|
a61200776d | ||
|
|
a67df17763 | ||
|
|
233bae6992 | ||
|
|
d685604d04 | ||
|
|
91dec25fc9 | ||
|
|
af93453190 | ||
|
|
6e57401610 | ||
|
|
dec00d3579 | ||
|
|
154c95d0c9 | ||
|
|
ac7080b31b | ||
|
|
a073d11c3e | ||
|
|
e028ab3476 | ||
|
|
5362f956f0 | ||
|
|
8037159f93 | ||
|
|
4dbab75855 | ||
|
|
adcd5aff6f | ||
|
|
bab4da5133 | ||
|
|
3ec28ceb9b | ||
|
|
ed45052d6d | ||
|
|
411640c032 | ||
|
|
eea93638c6 | ||
|
|
a2ca51c27a | ||
|
|
e640907d24 | ||
|
|
74b2deae1c | ||
|
|
143ccd27b4 | ||
|
|
a4d2fa1b6d | ||
|
|
065c360730 | ||
|
|
738d9aece7 | ||
|
|
8c38409aef | ||
|
|
61ed6425bd | ||
|
|
6e8c93afdd | ||
|
|
8c4ae1c938 | ||
|
|
4aa02c3743 | ||
|
|
356fab7bcb | ||
|
|
9543f076fd | ||
|
|
86d6666fe7 | ||
|
|
405cc337f3 | ||
|
|
772dacc89b | ||
|
|
696d2889f4 | ||
|
|
9316b9b57a | ||
|
|
fb288ef9a7 | ||
|
|
7077980055 | ||
|
|
50b27c8c0d | ||
|
|
bbc35b0b19 | ||
|
|
d7280917da | ||
|
|
78352fdd32 | ||
|
|
63f8a2cb89 | ||
|
|
e1686c26dd | ||
|
|
a999f6f876 | ||
|
|
e62e17d046 | ||
|
|
2f04108f3a | ||
|
|
1c83c0ebcd | ||
|
|
8ec6c323b6 | ||
|
|
c5b7faaefc | ||
|
|
467ece53e6 | ||
|
|
8149bc3fa6 | ||
|
|
adf5628087 | ||
|
|
67cd496b39 | ||
|
|
184039044a | ||
|
|
757eb060cd | ||
|
|
3442066054 | ||
|
|
80235d6fdd | ||
|
|
493a1846d0 | ||
|
|
73b9328c1f | ||
|
|
248aa54bfd | ||
|
|
70cc8f2c7e | ||
|
|
92d86586b7 | ||
|
|
a8e0363914 | ||
|
|
35008200bd | ||
|
|
113356c848 | ||
|
|
b3d0ed4057 | ||
|
|
61c0189bb1 | ||
|
|
f17ecaa495 | ||
|
|
9c4d0d454a | ||
|
|
d60663ea86 | ||
|
|
ea6428a5d2 | ||
|
|
80c6b487dc | ||
|
|
7eb496c00c | ||
|
|
aad4e4ddb1 | ||
|
|
cea83c0e1f | ||
|
|
bd39fcbeea | ||
|
|
0d073907b5 | ||
|
|
5ee6dc2120 | ||
|
|
64552ae304 | ||
|
|
b95e5827c1 | ||
|
|
8a214b2f8e | ||
|
|
5bc5fe5e7e | ||
|
|
a2ace9da24 | ||
|
|
d3959a2118 | ||
|
|
1257501499 | ||
|
|
bfd7209053 | ||
|
|
1883d299bf | ||
|
|
15253448af | ||
|
|
b017dc7e32 | ||
|
|
b5a6458cde | ||
|
|
caa90735cf | ||
|
|
de45957c42 | ||
|
|
f4a42738af | ||
|
|
d5158620bb | ||
|
|
bf5a196c78 | ||
|
|
5d7dfefa36 | ||
|
|
dbc8cae18c | ||
|
|
1e1e0f1fbb | ||
|
|
385bf084a5 | ||
|
|
eb1f362687 | ||
|
|
5386e6583d | ||
|
|
d1497527c6 | ||
|
|
91d202da7e | ||
|
|
3888bf9d12 | ||
|
|
3df4e78492 | ||
|
|
b74b6dc77f | ||
|
|
31625c2d17 | ||
|
|
dcdaf5c8b9 | ||
|
|
36181775cd | ||
|
|
1ba7f1d03f | ||
|
|
b160de5cb4 | ||
|
|
7edaedf3a1 | ||
|
|
cb5fcb3d22 | ||
|
|
58f8421eac | ||
|
|
7a4c66b7f5 | ||
|
|
d58c3793d6 | ||
|
|
ea190d862a | ||
|
|
0f26739c9f | ||
|
|
ae2c5ad768 | ||
|
|
9f9f8c8e76 | ||
|
|
50f1f1dce9 | ||
|
|
0264ef094a | ||
|
|
f688653710 | ||
|
|
886d896098 | ||
|
|
8331000764 | ||
|
|
0cd74723e1 | ||
|
|
2bff5e7867 | ||
|
|
90f2a417af | ||
|
|
7c07f5f640 | ||
|
|
20e30593a5 | ||
|
|
e2a18e2b37 | ||
|
|
da724fe1c0 | ||
|
|
ffd8beb6f6 | ||
|
|
5d3cf2ff15 | ||
|
|
7f813dcb6a | ||
|
|
18bab30792 | ||
|
|
60f7b05c0c | ||
|
|
7f626c8959 | ||
|
|
886d50dcab | ||
|
|
7d3e2c83d4 | ||
|
|
1cdc4568bd | ||
|
|
69df38f8d8 | ||
|
|
5e30b81825 | ||
|
|
99582befc4 | ||
|
|
c0d3f204b0 | ||
|
|
989cdca95f | ||
|
|
def8f852e3 | ||
|
|
349cdd6110 | ||
|
|
c54a5b3690 | ||
|
|
6d961d672d | ||
|
|
247ec2ad88 | ||
|
|
8ab2753521 | ||
|
|
2dc9bfd93a | ||
|
|
9dc6946ebf | ||
|
|
0868512bbc | ||
|
|
b519551153 | ||
|
|
f8b3f1622d | ||
|
|
0e3c5ebe1a | ||
|
|
daef51e038 | ||
|
|
e82c42661b | ||
|
|
3a47dec424 | ||
|
|
7b17618890 | ||
|
|
71bc255e6f | ||
|
|
8f990c573c | ||
|
|
3f1d6102f3 | ||
|
|
3712b41aba | ||
|
|
4bcb64f8c1 | ||
|
|
a651b08a2f | ||
|
|
3b35daacf7 | ||
|
|
18f36906a9 | ||
|
|
5fee4638e0 | ||
|
|
d52f579fd5 | ||
|
|
2fef10b9ac | ||
|
|
f3221941f2 | ||
|
|
d98d316903 | ||
|
|
97ecb4f9d8 | ||
|
|
ca6a121e63 | ||
|
|
e354b0e40f | ||
|
|
0ccfb61bb0 | ||
|
|
4b39120d22 | ||
|
|
76950a6401 | ||
|
|
909d962d3a | ||
|
|
dde53cfde1 | ||
|
|
0adb60b3a6 | ||
|
|
a2dd7daf4e | ||
|
|
3a8e56b282 | ||
|
|
36202a63e9 | ||
|
|
abad809e7a | ||
|
|
0f2f783584 | ||
|
|
bcd6b41674 | ||
|
|
92053cb492 | ||
|
|
14cb489a3b | ||
|
|
54e2205e54 | ||
|
|
99b0f48b2e | ||
|
|
c12711affd | ||
|
|
e4b4125310 | ||
|
|
6b2d850e54 | ||
|
|
0daeefefdb | ||
|
|
d520dae6ac | ||
|
|
03d01eabb5 | ||
|
|
65d6278f88 | ||
|
|
c48d09ec88 | ||
|
|
4a51a9d9d5 | ||
|
|
b938212563 | ||
|
|
accaff8ac0 | ||
|
|
45965fb020 | ||
|
|
6ac39d5cdb | ||
|
|
9794c03537 | ||
|
|
1b221a56ea | ||
|
|
eb6fd6ff80 | ||
|
|
9d041d8e6c | ||
|
|
5172014668 | ||
|
|
b853054e71 | ||
|
|
a6a294c8f8 | ||
|
|
1e0eb914d9 | ||
|
|
ae1a6c2fc5 | ||
|
|
e802b683ea | ||
|
|
55cd4c7bc7 | ||
|
|
a4eaac359a | ||
|
|
ee45a8a149 | ||
|
|
b08e451c91 | ||
|
|
2c0f826c36 | ||
|
|
bcab77e266 | ||
|
|
d8398af770 | ||
|
|
30348edc7c | ||
|
|
59ff9b8128 | ||
|
|
2c9bdd9e32 | ||
|
|
21240c1a8f | ||
|
|
c8ecbf38ab | ||
|
|
194a121ef6 | ||
|
|
8867951144 | ||
|
|
fd13731049 | ||
|
|
c68ceca8cd | ||
|
|
efaf4c16cf | ||
|
|
2ad09ab5af | ||
|
|
1f209ed030 | ||
|
|
3c876235cc | ||
|
|
afa4e3ed9c | ||
|
|
c376c5a817 | ||
|
|
92a77e7654 | ||
|
|
4612419c14 | ||
|
|
c799425069 | ||
|
|
428be9803c | ||
|
|
bba588752f | ||
|
|
311dad8c28 | ||
|
|
93062ad099 | ||
|
|
22e594fcea | ||
|
|
02580ac134 | ||
|
|
b723f50e65 | ||
|
|
4a2e75fc8c | ||
|
|
9420758127 | ||
|
|
87997efe8d | ||
|
|
69e0f28333 | ||
|
|
51a0dbb172 | ||
|
|
7934e7a6b5 | ||
|
|
aebbb15fe2 | ||
|
|
48371216df | ||
|
|
e30f9dc1fa | ||
|
|
f21cb71fbe | ||
|
|
990218739a | ||
|
|
e7c2f53f2a | ||
|
|
21993105e5 | ||
|
|
9b2f02efbd | ||
|
|
0f25ad3ca3 | ||
|
|
f9c7c50a93 | ||
|
|
0b44ad99b5 | ||
|
|
78d707dc83 | ||
|
|
b087483538 | ||
|
|
3385159c94 | ||
|
|
f184c6f06c | ||
|
|
5a551ac57f | ||
|
|
53fde21bb8 | ||
|
|
b946bf43f5 | ||
|
|
d64a815e8d | ||
|
|
689f4bfac2 | ||
|
|
85af9c9c9d | ||
|
|
95c38087db | ||
|
|
fa6deb5866 | ||
|
|
a71c262d5f | ||
|
|
f731ae4a2d | ||
|
|
8c8ce08d79 | ||
|
|
de4f817bd6 | ||
|
|
623e35f594 | ||
|
|
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 |
78
.github/CONTRIBUTING.md
vendored
Normal file
78
.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
## What should I do before opening an issue?
|
||||
|
||||
Before opening an issue, please ensure that:
|
||||
|
||||
- Your problem is a specific problem or question or suggestion, not a general
|
||||
complaint.
|
||||
|
||||
- `$TERM` inside tmux is screen, screen-256color, tmux or tmux-256color. Check
|
||||
by running `echo $TERM` inside tmux.
|
||||
|
||||
- You can reproduce the problem with the latest tmux release, or a build from
|
||||
Git master.
|
||||
|
||||
- Your question or issue is not covered [in the
|
||||
manual](https://man.openbsd.org/tmux.1) (run `man tmux`).
|
||||
|
||||
- Your problem is not mentioned in the [CHANGES
|
||||
file](https://raw.githubusercontent.com/tmux/tmux/master/CHANGES) file.
|
||||
|
||||
- Nobody else has opened the same issue recently.
|
||||
|
||||
## What should I include in an issue?
|
||||
|
||||
Please include the output of:
|
||||
|
||||
~~~bash
|
||||
uname -sp && tmux -V && echo $TERM
|
||||
~~~
|
||||
|
||||
Also include:
|
||||
|
||||
- Your platform (Linux, 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.
|
||||
|
||||
## How do I test without a .tmux.conf?
|
||||
|
||||
Run a separate tmux server with `-f/dev/null` to skip loading `.tmux.conf`:
|
||||
|
||||
~~~bash
|
||||
tmux -Ltest kill-server
|
||||
tmux -Ltest -f/dev/null new
|
||||
~~~
|
||||
|
||||
## How do I get logs from tmux?
|
||||
|
||||
Add `-vv` to tmux to create three log files in the current directory. If you can
|
||||
reproduce without a configuration file:
|
||||
|
||||
~~~bash
|
||||
tmux -Ltest kill-server
|
||||
tmux -vv -Ltest -f/dev/null new
|
||||
~~~
|
||||
|
||||
Or if you need your configuration:
|
||||
|
||||
~~~base
|
||||
tmux kill-server
|
||||
tmux -vv new
|
||||
~~~
|
||||
|
||||
The log files are:
|
||||
|
||||
- `tmux-server*.log`: server log file.
|
||||
|
||||
- `tmux-client*.log`: client log file.
|
||||
|
||||
- `tmux-out*.log`: output log file.
|
||||
|
||||
Please attach the log files to your issue.
|
||||
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
liberapay: tmux
|
||||
22
.github/ISSUE_TEMPLATE.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
### Issue description
|
||||
|
||||
Please read https://github.com/tmux/tmux/blob/master/.github/CONTRIBUTING.md
|
||||
before opening an issue.
|
||||
|
||||
If you have upgraded, make sure your issue is not covered in the CHANGES file
|
||||
for your version: https://raw.githubusercontent.com/tmux/tmux/master/CHANGES
|
||||
|
||||
Describe the problem and the steps to reproduce. Add a minimal tmux config if
|
||||
necessary. Screenshots can be helpful, but no more than one or two.
|
||||
|
||||
Do not report bugs (crashes, incorrect behaviour) without reproducing on a tmux
|
||||
built from the latest code in Git.
|
||||
|
||||
### Required information
|
||||
|
||||
Please provide the following information:
|
||||
|
||||
* tmux version (`tmux -V`).
|
||||
* Platform (`uname -sp`).
|
||||
* $TERM inside and outside of tmux (`echo $TERM`).
|
||||
* Logs from tmux (`tmux kill-server; tmux -vv new`).
|
||||
83
.github/README.md
vendored
Normal file
83
.github/README.md
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
# Welcome to tmux!
|
||||
|
||||
tmux is a terminal multiplexer: it enables a number of terminals to be created,
|
||||
accessed, and controlled from a single screen. tmux may be detached from a
|
||||
screen and continue running in the background, then later reattached.
|
||||
|
||||
This release runs on OpenBSD, FreeBSD, NetBSD, Linux, OS X and Solaris.
|
||||
|
||||
## Dependencies
|
||||
|
||||
tmux depends on [libevent](https://libevent.org) 2.x, available from [this
|
||||
page](https://github.com/libevent/libevent/releases/latest).
|
||||
|
||||
It also depends on [ncurses](https://www.gnu.org/software/ncurses/), available
|
||||
from [this page](https://invisible-mirror.net/archives/ncurses/).
|
||||
|
||||
## Installation
|
||||
|
||||
### From release tarball
|
||||
|
||||
To build and install tmux from a release tarball, use:
|
||||
|
||||
~~~bash
|
||||
./configure && make
|
||||
sudo make install
|
||||
~~~
|
||||
|
||||
tmux can use the utempter library to update utmp(5), if it is installed - run
|
||||
configure with `--enable-utempter` to enable this.
|
||||
|
||||
### From version control
|
||||
|
||||
To get and build the latest from version control - note that this requires
|
||||
`autoconf`, `automake` and `pkg-config`:
|
||||
|
||||
~~~bash
|
||||
git clone https://github.com/tmux/tmux.git
|
||||
cd tmux
|
||||
sh autogen.sh
|
||||
./configure && make
|
||||
~~~
|
||||
|
||||
## Contributing
|
||||
|
||||
Bug reports, feature suggestions and especially code contributions are most
|
||||
welcome. Please send by email to:
|
||||
|
||||
tmux-users@googlegroups.com
|
||||
|
||||
Or open a GitHub issue or pull request. **Please read [this
|
||||
document](CONTRIBUTING.md) before opening an issue.**
|
||||
|
||||
There is [a list of suggestions for contributions](https://github.com/tmux/tmux/wiki/Contributing).
|
||||
Please feel free to ask on the mailing list if you're thinking of working on something or need
|
||||
further information.
|
||||
|
||||
## Documentation
|
||||
|
||||
For documentation on using tmux, see the tmux.1 manpage. View it from the
|
||||
source tree with:
|
||||
|
||||
~~~bash
|
||||
nroff -mdoc tmux.1|less
|
||||
~~~
|
||||
|
||||
A small example configuration is in `example_tmux.conf`.
|
||||
|
||||
And a bash(1) completion file at:
|
||||
|
||||
https://github.com/imomaliev/tmux-bash-completion
|
||||
|
||||
For debugging, run tmux with `-v` or `-vv` to generate server and client log
|
||||
files in the current directory.
|
||||
|
||||
## Support
|
||||
|
||||
The tmux mailing list for general discussion and bug reports is:
|
||||
|
||||
https://groups.google.com/forum/#!forum/tmux-users
|
||||
|
||||
Subscribe by sending an email to:
|
||||
|
||||
tmux-users+subscribe@googlegroups.com
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -17,3 +17,5 @@ Makefile
|
||||
Makefile.in
|
||||
configure
|
||||
tmux.1.*
|
||||
*.dSYM
|
||||
cmd-parse.c
|
||||
|
||||
9
.mailmap
9
.mailmap
@@ -1,9 +1,9 @@
|
||||
Bob Beck <beck@openbsd.org> beck <beck>
|
||||
Claudio Jeker <claudio@openbsd.org> claudio <claudio>
|
||||
Igor Sobrado <sobrado@openbsd.org> sobrado <sobrado>
|
||||
Ingo Schwarze <schwarze@openbsd.org> schwarze <schwarze>
|
||||
Jacek Masiulaniec <jacekm@openbsd.org> jacekm <jacekm>
|
||||
Jason McIntyre <jmc@openbsd.org> jmc <jmc>
|
||||
Jason McIntyre <jmc@openbsd.org> jcm <jcm>
|
||||
Joel Sing <jsing@openbsd.org> jsing <jsing>
|
||||
Jonathan Gray <jsg@openbsd.org> jsg <jsg>
|
||||
Kenneth R Westerback <krw@openbsd.org> krw <krw>
|
||||
@@ -11,6 +11,7 @@ Marc Espie <espie@openbsd.org> espie <espie>
|
||||
Matthew Dempsky <matthew@openbsd.org> matthew <matthew>
|
||||
Matthias Kilian <kili@openbsd.org> kili <kili>
|
||||
Matthieu Herrb <matthieu@openbsd.org> matthieu <matthieu>
|
||||
Michael McConville <mmcc@openbsd.org> mmcc <mmcc>
|
||||
Miod Vallat <miod@openbsd.org> miod <miod>
|
||||
Nicholas Marriott <nicholas.marriott@gmail.com> Nicholas Marriott <nicm@openbsd.org>
|
||||
Nicholas Marriott <nicholas.marriott@gmail.com> nicm <nicm>
|
||||
@@ -21,14 +22,16 @@ Pierre-Yves Ritschard <pyr@openbsd.org> pyr <pyr>
|
||||
Ray Lai <ray@openbsd.org> ray <ray>
|
||||
Ryan McBride <mcbride@openbsd.org> mcbride <mcbride>
|
||||
Sebastian Benoit <benno@openbsd.org> benno <benno>
|
||||
Sebastien Marie <semarie@openbsd.org> semarie <semarie>
|
||||
Stefan Sperling <stsp@openbsd.org> stsp <stsp>
|
||||
Stuart Henderson <sthen@openbsd.org> sthen <sthen>
|
||||
Ted Unangst <tedu@openbsd.org> tedu <tedu>
|
||||
Theo de Raadt <deraadt@openbsd.org> deraadt <deraadt>
|
||||
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> n6tadam <n6tadam@xteddy.org>
|
||||
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>
|
||||
|
||||
22
.travis.yml
22
.travis.yml
@@ -1,10 +1,16 @@
|
||||
language: c
|
||||
matrix:
|
||||
include:
|
||||
- compiler: gcc
|
||||
- compiler: clang
|
||||
env: CFLAGS="-g -O2"
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
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
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update -qq; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get -y install bison autotools-dev libncurses5-dev libevent-dev pkg-config libutempter-dev build-essential; fi
|
||||
|
||||
script:
|
||||
- ./autogen.sh && ./configure && make
|
||||
|
||||
890
CHANGES
890
CHANGES
@@ -1,4 +1,864 @@
|
||||
CHANGES FROM 2.0 to 2.1 18 October 2015
|
||||
CHANGES FROM 3.0 to 3.1
|
||||
|
||||
* Add support for adding a note to a key binding (with bind-key -N) and use
|
||||
this to add descriptions to the default key bindings. A new -N flag to
|
||||
list-keys shows key bindings with notes. Change the default ? binding to use
|
||||
this to show a readable summary of keys. Also extend command-prompt to return
|
||||
the name of the key pressed and add a default binding (/) to show the note
|
||||
for the next key pressed.
|
||||
|
||||
* Add support for the iTerm2 DSR 1337 sequence to get the terminal version.
|
||||
|
||||
* Treat plausible but invalid keys (like C-BSpace) as literal like any other
|
||||
unrecognised string passed to send-keys
|
||||
|
||||
* Detect iTerm2 and enable use of DECSLRM (much faster with horizontally split
|
||||
windows).
|
||||
|
||||
* Add -Z to default switch-client command in tree mode.
|
||||
|
||||
* Add ~ to quoted characters for %%%.
|
||||
|
||||
* Document client exit messages in the manual page.
|
||||
|
||||
* Do not let read-only clients limit the size, unless all clients are
|
||||
read-only.
|
||||
|
||||
* Add a number of new formats to inspect what sessions and clients a window is
|
||||
present or active in.
|
||||
|
||||
* Change file reading and writing to go through the client if necessary. This
|
||||
fixes commands like "tmux loadb /dev/fd/X". Also modify source-file to
|
||||
support "-" for standard input, like load-buffer and save-buffer.
|
||||
|
||||
* Add ~/.config/tmux/tmux.conf to the default search path for configuration
|
||||
files.
|
||||
|
||||
* Bump the escape sequence timeout to five seconds to allow for longer
|
||||
legitimate sequences.
|
||||
|
||||
* Make a best effort to set xpixel and ypixel for each pane and add formats for
|
||||
them.
|
||||
|
||||
* Add push-default to status-left and status-right in status-format[0].
|
||||
|
||||
* Add -F flag to send-keys to expand formats in search-backward and forward
|
||||
copy mode commands and copy_cursor_word and copy_cursor_line formats for word
|
||||
and line at cursor in copy mode. Use for default # and * binding with vi(1)
|
||||
keys.
|
||||
|
||||
* Do not clear search marks on cursor movement with vi(1) keys.
|
||||
|
||||
* Add p format modifier for padding to width and allow multiple substitutions
|
||||
in a single format.
|
||||
|
||||
* Add -f for full size to join-pane (like split-window).
|
||||
|
||||
* Handle OSC 7 (a VTE extension) and put the result in a new format (pane_path).
|
||||
|
||||
* Change new-session -A without a session name (that is, no -s option also) to
|
||||
attach to the best existing session like attach-session rather than creating
|
||||
a new one.
|
||||
|
||||
* Add an option to set the key sent by backspace for those whose system uses ^H
|
||||
rather than ^?.
|
||||
|
||||
* Add formats for cursor and selection position in copy mode.
|
||||
|
||||
* Add support for percentage sizes for resize-pane ("-x 10%"). Also change
|
||||
split-window and join-pane -l to accept similar percentages and no longer
|
||||
document -p.
|
||||
|
||||
* Make select-pane -P set window-active-style also to match previous behaviour.
|
||||
|
||||
* Do not use bright when emulating 256 colours on an 8 colour terminal because
|
||||
it is also bold on some terminals.
|
||||
|
||||
* Add a "latest" window-size option which tries to size windows based on the
|
||||
most recently used client. This is now the default.
|
||||
|
||||
* Make select-pane -P set window-active-style also to match previous behaviour.
|
||||
|
||||
* Do not truncate list-keys output.
|
||||
|
||||
* Turn automatic-rename back on if the \033k rename escape sequence is used
|
||||
with an empty name.
|
||||
|
||||
* Add support for percentage sizes for resize-pane ("-x 10%"). Also change
|
||||
split-window and join-pane -l to accept similar percentages and deprecate the
|
||||
-p flag.
|
||||
|
||||
* Add -F flag to send-keys to expand formats in search-backward and forward
|
||||
copy mode commands, this makes it easier to use the cursor_word and
|
||||
cursor_line formats.
|
||||
|
||||
* Add formats for word and line at cursor position in copy mode.
|
||||
|
||||
* Add formats for cursor and selection position in copy mode
|
||||
|
||||
* Support all the forms of RGB colour strings in OSC sequences rather than
|
||||
requiring two digits.
|
||||
|
||||
* Limit lazy resize to panes in attached sessions only
|
||||
|
||||
* Add an option to set the key sent by backspace for those whose system uses ^H
|
||||
rather than ^?.
|
||||
|
||||
* Change new-session -A without a session name (that is, no -s option also) to
|
||||
attach to the best existing session like attach-session rather than a new
|
||||
one.
|
||||
|
||||
* Change window-size default from smallest to latest.
|
||||
|
||||
* Add simple support for OSC 7 (result is available in the pane_path format).
|
||||
|
||||
* Add push-default and pop-default for styles which change the colours and
|
||||
attributes used for #[default]. These are used in status-format to restore
|
||||
the behaviour of window-status-style being the default for
|
||||
window-status-format.
|
||||
|
||||
* Add window_marked_flag.
|
||||
|
||||
* Add cursor-down-and-cancel in copy mode.
|
||||
|
||||
* Default to previous search string for search-forward and search-backward.
|
||||
|
||||
* Add -Z flag to rotate-window, select-pane, swap-pane, switch-client to
|
||||
preserve zoomed state.
|
||||
|
||||
* Add -N to capture-pane to preserve trailing spaces.
|
||||
|
||||
* Add reverse sorting in tree, client and buffer modes.
|
||||
|
||||
CHANGES FROM 3.0 to 3.0a
|
||||
|
||||
* Do not require REG_STARTEND.
|
||||
|
||||
* Respawn panes or windows correctly if default-command is set.
|
||||
|
||||
* Add missing option for after-kill-pane hook.
|
||||
|
||||
* Fix for crash with a format variable that doesn't exist.
|
||||
|
||||
* Do not truncate list-keys output on some platforms.
|
||||
|
||||
* Do not crash when restoring a layout with only one pane.
|
||||
|
||||
CHANGES FROM 2.9 to 3.0
|
||||
|
||||
* Workaround invalid layout strings generated by older tmux versions and add
|
||||
some additional sanity checks
|
||||
|
||||
* xterm 348 now disables margins when resized, so send DECLRMM again after
|
||||
resize.
|
||||
|
||||
* Add support for the SD (scroll down) escape sequence.
|
||||
|
||||
* Expand arguments to C and s format modifiers to match the m modifier.
|
||||
|
||||
* Add support for underscore colours (Setulc capability must be added with
|
||||
terminal-overrides as described in tmux(1)).
|
||||
|
||||
* Add a "fill" style attribute for the fill colour of the drawing area (where
|
||||
appropriate).
|
||||
|
||||
* New -H flag to send-keys to send literal keys.
|
||||
|
||||
* Format variables for pane mouse modes (mouse_utf8_flag and mouse_sgr_flag)
|
||||
and for origin mode (origin_flag).
|
||||
|
||||
* Add -F to refresh-client for flags for control mode clients, only one flag
|
||||
(no-output) supported at the moment.
|
||||
|
||||
* Add a few vi(1) keys for menus.
|
||||
|
||||
* Add pane options, set with set-option -p and displayed with show-options -p.
|
||||
Pane options inherit from window options (so every pane option is also
|
||||
a window option). The pane style is now configured by setting window-style
|
||||
and window-active-style in the pane options; select-pane -P and -g now change
|
||||
the option but are no longer documented.
|
||||
|
||||
* Do not document set-window-option and show-window-options. set-option -w and
|
||||
show-options -w should be used instead.
|
||||
|
||||
* Add a -A flag to show-options to show parent options as well (they are marked
|
||||
with a *).
|
||||
|
||||
* Resize panes lazily - do not resize unless they are in an attached, active
|
||||
window.
|
||||
|
||||
* Add regular expression support for the format search, match and substitute
|
||||
modifiers and make them able to ignore case. find-window now accepts -r to
|
||||
use regular expressions.
|
||||
|
||||
* Do not use $TMUX to find the session because for windows in multiple sessions
|
||||
it is wrong as often as it is right, and for windows in one session it is
|
||||
pointless. Instead use TMUX_PANE if it is present.
|
||||
|
||||
* Do not always resize the window back to its original size after applying a
|
||||
layout, keep it at the layout size until it must be resized (for example when
|
||||
attached and window-size is not manual).
|
||||
|
||||
* Add new-session -X and attach-session -x to send SIGHUP to parent when
|
||||
detaching (like detach-client -P).
|
||||
|
||||
* Support for octal escapes in strings (such as \007) and improve list-keys
|
||||
output so it parses correctly if copied into a configuration file.
|
||||
|
||||
* INCOMPATIBLE: Add a new {} syntax to the configuration file. This is a string
|
||||
similar to single quotes but also includes newlines and allows commands that
|
||||
take other commands as string arguments to be expressed more clearly and
|
||||
without additional escaping.
|
||||
|
||||
A literal { and } or a string containing { or } must now be escaped or
|
||||
quoted, for example '{' and '}' instead of { or }, or 'X#{foo}' instead of
|
||||
X#{foo}.
|
||||
|
||||
* New <, >, <= and >= comparison operators for formats.
|
||||
|
||||
* Improve escaping of special characters in list-keys output.
|
||||
|
||||
* INCOMPATIBLE: tmux's configuration parsing has changed to use yacc(1). There
|
||||
is one incompatible change: a \ on its own must be escaped or quoted as
|
||||
either \\ or '\' (the latter works on older tmux versions).
|
||||
|
||||
Entirely the same parser is now used for parsing the configuration file
|
||||
and for string commands. This means that constructs previously only
|
||||
available in .tmux.conf, such as %if, can now be used in string commands
|
||||
(for example, those given to if-shell - not commands invoked from the
|
||||
shell, they are still parsed by the shell itself).
|
||||
|
||||
* Add support for the overline attribute (SGR 53). The Smol capability is
|
||||
needed in terminal-overrides.
|
||||
|
||||
* Add the ability to create simple menus. Introduces new command
|
||||
display-menu. Default menus are bound to MouseDown3 on the status line;
|
||||
MouseDown3 or M-MouseDown3 on panes; MouseDown3 in tree, client and
|
||||
buffer modes; and C-b < and >.
|
||||
|
||||
* Allow panes to be empty (no command). They can be created either by piping to
|
||||
split-window -I, or by passing an empty command ('') to split-window. Output
|
||||
can be sent to an existing empty window with display-message -I.
|
||||
|
||||
* Add keys to jump between matching brackets (emacs C-M-f and C-M-b, vi %).
|
||||
|
||||
* Add a -e flag to new-window, split-window, respawn-window, respawn-pane to
|
||||
pass environment variables into the newly created process.
|
||||
|
||||
* Hooks are now stored in the options tree as array options, allowing them to
|
||||
have multiple separate commands. set-hook and show-hooks remain but
|
||||
set-option and show-options can now also be used (show-options will only show
|
||||
hooks if given the -H flag). Hooks with multiple commands are run in index
|
||||
order.
|
||||
|
||||
* Automatically scroll if dragging to create a selection with the mouse and the
|
||||
cursor reaches the top or bottom line.
|
||||
|
||||
* Add -no-clear variants of copy-selection and copy-pipe which do not clear the
|
||||
selection after copying. Make copy-pipe clear the selection by default to be
|
||||
consistent with copy-selection.
|
||||
|
||||
* Add an argument to copy commands to set the prefix for the buffer name, this
|
||||
(for example) allows buffers for different sessions to be named separately.
|
||||
|
||||
* Update session activity on focus event.
|
||||
|
||||
* Pass target from source-file into the config file parser so formats in %if
|
||||
and %endif have access to more useful variables.
|
||||
|
||||
* Add the ability to infer an option type (server, session, window) from its
|
||||
name to show-options (it was already present in set-option).
|
||||
|
||||
CHANGES FROM 2.9 to 2.9a
|
||||
|
||||
* Fix bugs in select-pane and the main-horizontal and main-vertical layouts.
|
||||
|
||||
CHANGES FROM 2.8 to 2.9
|
||||
|
||||
* Attempt to preserve horizontal cursor position as well as vertical with
|
||||
reflow.
|
||||
|
||||
* Rewrite main-vertical and horizontal and change layouts to better handle the
|
||||
case where all panes won't fit into the window size, reduce problems with
|
||||
pane border status lines and fix other bugs mostly found by Thomas Sattler.
|
||||
|
||||
* Add format variables for the default formats in the various modes
|
||||
(tree_mode_format and so on) and add a -a flag to display-message to list
|
||||
variables with values.
|
||||
|
||||
* Add a -v flag to display-message to show verbose messages as the format is
|
||||
parsed, this allows formats to be debugged
|
||||
|
||||
* Add support for HPA (\033[`).
|
||||
|
||||
* Add support for origin mode (\033[?6h).
|
||||
|
||||
* No longer clear history on RIS.
|
||||
|
||||
* Extend the #[] style syntax and use that together with previous format
|
||||
changes to allow the status line to be entirely configured with a single
|
||||
option.
|
||||
|
||||
Now that it is possible to configure their content, enable the existing code
|
||||
that lets the status line be multiple lines in height. The status option can
|
||||
now take a value of 2, 3, 4 or 5 (as well as the previous on or off) to
|
||||
configure more than one line. The new status-format array option configures
|
||||
the format of each line, the default just references the existing status-*
|
||||
options, although some of the more obscure status options may be eliminated
|
||||
in time.
|
||||
|
||||
Additions to the #[] syntax are: "align" to specify alignment (left, centre,
|
||||
right), "list" for the window list and "range" to configure ranges of text
|
||||
for the mouse bindings.
|
||||
|
||||
The "align" keyword can also be used to specify alignment of entries in tree
|
||||
mode and the pane status lines.
|
||||
|
||||
* Add E: and T: format modifiers to expand a format twice (useful to expand the
|
||||
value of an option).
|
||||
|
||||
* The individual -fg, -bg and -attr options have been removed; they
|
||||
were superseded by -style options in tmux 1.9.
|
||||
|
||||
* Allow more than one mode to be opened in a pane. Modes are kept on a stack
|
||||
and retrieved if the same mode is entered again. Exiting the active mode goes
|
||||
back to the previous one.
|
||||
|
||||
* When showing command output in copy mode, call it view mode instead (affects
|
||||
pane_mode format).
|
||||
|
||||
* Add -b to display-panes like run-shell.
|
||||
|
||||
* Handle UTF-8 in word-separators option.
|
||||
|
||||
* New "terminal" colour allowing options to use the terminal default colour
|
||||
rather than inheriting the default from a parent option.
|
||||
|
||||
* Do not move the cursor in copy mode when the mouse wheel is used.
|
||||
|
||||
* Use the same working directory rules for jobs as new windows rather than
|
||||
always starting in the user's home.
|
||||
|
||||
* Allow panes to be one line or column in size.
|
||||
|
||||
* Go to last line when goto-line number is out of range in copy mode.
|
||||
|
||||
* Yank previously cut text if any with C-y in the command prompt, only use the
|
||||
buffer if no text has been cut.
|
||||
|
||||
* Add q: format modifier to quote shell special characters.
|
||||
|
||||
* Add StatusLeft and StatusRight mouse locations (keys such as
|
||||
MouseDown1StatusLeft) for the status-left and status-right areas of the
|
||||
status line.
|
||||
|
||||
* Add -Z to find-window.
|
||||
|
||||
* Support for windows larger than the client. This adds two new options,
|
||||
window-size and default-size, and a new command, resize-window. The
|
||||
force-width and force-height options and the session_width and session_height
|
||||
formats have been removed.
|
||||
|
||||
The new window-size option tells tmux how to work out the size of windows:
|
||||
largest means it picks the size of the largest session, smallest the smallest
|
||||
session (similar to the old behaviour) and manual means that it does not
|
||||
automatically resize windows. aggressive-resize modifies the choice of
|
||||
session for largest and smallest as it did before.
|
||||
|
||||
If a window is in a session attached to a client that is too small, only part
|
||||
of the window is shown. tmux attempts to keep the cursor visible, so the part
|
||||
of the window displayed is changed as the cursor moves (with a small delay,
|
||||
to try and avoid excess redrawing when applications redraw status lines or
|
||||
similar that are not currently visible).
|
||||
|
||||
Drawing windows which are larger than the client is not as efficient as those
|
||||
which fit, particularly when the cursor moves, so it is recommended to avoid
|
||||
using this on slow machines or networks (set window-size to smallest or
|
||||
manual).
|
||||
|
||||
The resize-window command can be used to resize a window manually. If it is
|
||||
used, the window-size option is automatically set to manual for the window
|
||||
(undo this with "setw -u window-size"). resize-window works in a similar way
|
||||
to resize-pane (-U -D -L -R -x -y flags) but also has -a and -A flags. -a
|
||||
sets the window to the size of the smallest client (what it would be if
|
||||
window-size was smallest) and -A the largest.
|
||||
|
||||
For the same behaviour as force-width or force-height, use resize-window -x
|
||||
or -y.
|
||||
|
||||
If the global window-size option is set to manual, the default-size option is
|
||||
used for new windows. If -x or -y is used with new-session, that sets the
|
||||
default-size option for the new session.
|
||||
|
||||
The maximum size of a window is 10000x10000. But expect applications to
|
||||
complain and higher memory use if making a window that big. The minimum size
|
||||
is the size required for the current layout including borders.
|
||||
|
||||
The refresh-client command can be used to pan around a window, -U -D -L -R
|
||||
moves up, down, left or right and -c returns to automatic cursor
|
||||
tracking. The position is reset when the current window is changed.
|
||||
|
||||
CHANGES FROM 2.7 to 2.8
|
||||
|
||||
* Make display-panes block the client until a pane is chosen or it
|
||||
times out.
|
||||
|
||||
* Clear history on RIS like most other terminals do.
|
||||
|
||||
* Add an "Any" key to run a command if a key is pressed that is not
|
||||
bound in the current key table.
|
||||
|
||||
* Expand formats in load-buffer and save-buffer.
|
||||
|
||||
* Add a rectangle_toggle format.
|
||||
|
||||
* Add set-hook -R to run a hook immediately.
|
||||
|
||||
* Add README.ja.
|
||||
|
||||
* Add pane focus hooks.
|
||||
|
||||
* Allow any punctuation as separator for s/x/y not only /.
|
||||
|
||||
* Improve resizing with the mouse (fix resizing the wrong pane in some
|
||||
layouts, and allow resizing multiple panes at the same time).
|
||||
|
||||
* Allow , and } to be escaped in formats as #, and #}.
|
||||
|
||||
* Add KRB5CCNAME to update-environment.
|
||||
|
||||
* Change meaning of -c to display-message so the client is used if it
|
||||
matches the session given to -t.
|
||||
|
||||
* Fixes to : form of SGR.
|
||||
|
||||
* Add x and X to choose-tree to kill sessions, windows or panes.
|
||||
|
||||
CHANGES FROM 2.6 TO 2.7
|
||||
|
||||
* Remove EVENT_* variables from environment on platforms where tmux uses them
|
||||
so they do not pass on to panes.
|
||||
|
||||
* Fixes for hooks at server exit.
|
||||
|
||||
* Remove SGR 10 (was equivalent to SGR 0 but no other terminal seems to do
|
||||
this).
|
||||
|
||||
* Expand formats in window and session names.
|
||||
|
||||
* Add -Z flag to choose-tree, choose-client, choose-buffer to automatically
|
||||
zoom the pane when the mode is entered and unzoom when it exits, assuming the
|
||||
pane is not already zoomed. This is now part of the default key bindings.
|
||||
|
||||
* Add C-g to exit modes with emacs keys.
|
||||
|
||||
* Add exit-empty option to exit server if no sessions (defaults to on).
|
||||
|
||||
* Show if a filter is present in choose modes.
|
||||
|
||||
* Add pipe-pane -I to to connect stdin of the child process.
|
||||
|
||||
* Performance improvements for reflow.
|
||||
|
||||
* Use RGB terminfo(5) capability to detect RGB colour terminals (the existing
|
||||
Tc extension remains unchanged).
|
||||
|
||||
* Support for ISO colon-separated SGR sequences.
|
||||
|
||||
* Add select-layout -E to spread panes out evenly (bound to E key).
|
||||
|
||||
* Support wide characters properly when reflowing.
|
||||
|
||||
* Pass PWD to new panes as a hint to shells, as well as calling chdir().
|
||||
|
||||
* Performance improvements for the various choose modes.
|
||||
|
||||
* Only show first member of session groups in tree mode (-G flag to choose-tree
|
||||
to show all).
|
||||
|
||||
* Support %else in config files to match %if; from Brad Town in GitHub issue
|
||||
1071.
|
||||
|
||||
* Fix "kind" terminfo(5) capability to be S-Down not S-Up.
|
||||
|
||||
* Add a box around the preview label in tree mode.
|
||||
|
||||
* Show exit status and time in the remain-on-exit pane text; from Timo
|
||||
Boettcher in GitHub issue 1103.
|
||||
|
||||
* Correctly use pane-base-index in tree mode.
|
||||
|
||||
* Change the allow-rename option default to off.
|
||||
|
||||
* Support for xterm(1) title stack escape sequences (GitHub issue 1075 from
|
||||
Brad Town).
|
||||
|
||||
* Correctly remove padding cells to fix a UTF-8 display problem (GitHub issue
|
||||
1090).
|
||||
|
||||
CHANGES FROM 2.5 TO 2.6, 05 October 2017
|
||||
|
||||
* Add select-pane -T to set pane title.
|
||||
|
||||
* Fix memory leak when lines with BCE are removed from history.
|
||||
|
||||
* Fix (again) the "prefer unattached" behaviour of attach-session.
|
||||
|
||||
* Reorder how keys are checked to allow keys to be specified that have a
|
||||
leading escape. GitHub issue 1048.
|
||||
|
||||
* Support REP escape sequence (\033[b).
|
||||
|
||||
* Run alert hooks based on options rather than always, and allow further bells
|
||||
even if there is an existing bell.
|
||||
|
||||
* Add -d flag to display-panes to override display-panes-time.
|
||||
|
||||
* Add selection_present format when in copy mode (allows key bindings that do
|
||||
something different if there is a selection).
|
||||
|
||||
* Add pane_at_left, pane_at_right, pane_at_top and pane_at_bottom formats.
|
||||
|
||||
* Make bell, activity and silence alerting more consistent by: removing the
|
||||
bell-on-alert option; adding activity-action and silence-action options with
|
||||
the same possible values as the existing bell-action; adding a "both" value
|
||||
for the visual-bell, visual-activity and visual-silence options to trigger
|
||||
both a bell and a message.
|
||||
|
||||
* Add a pane_pipe format to show if pipe-pane is active.
|
||||
|
||||
* Block signals between forking and resetting signal handlers so that the
|
||||
libevent signal handler doesn't get called in the child and incorrectly write
|
||||
into the signal pipe that it still shares with the parent. GitHub issue 1001.
|
||||
|
||||
* Allow punctuation in pane_current_command.
|
||||
|
||||
* Add -c for respawn-pane and respawn-window.
|
||||
|
||||
* Wait for any remaining data to flush when a pane is closed while pipe-pane is
|
||||
in use.
|
||||
|
||||
* Fix working out current client with no target. GitHub issue 995.
|
||||
|
||||
* Try to fallback to C.UTF-8 as well as en_US.UTF-8 when looking for a UTF-8
|
||||
locale.
|
||||
|
||||
* Add user-keys option for user-defined key escape sequences (mapped to User0
|
||||
to User999 keys).
|
||||
|
||||
* Add pane-set-clipboard hook.
|
||||
|
||||
* FAQ file has moved out of repository to online.
|
||||
|
||||
* Fix problem with high CPU usage when a client dies unexpectedly. GitHub issue
|
||||
941.
|
||||
|
||||
* Do a dance on OS X 10.10 and above to return tmux to the user namespace,
|
||||
allowing access to the clipboard.
|
||||
|
||||
* Do not allow escape sequences which expect a specific terminator (APC, DSC,
|
||||
OSC) to wait for forever - use a small timeout. This reduces the chance of
|
||||
the pane locking up completely when sent garbage (cat /dev/random or
|
||||
similar).
|
||||
|
||||
* Support SIGUSR2 to toggle logging on a running server, also generate the
|
||||
"out" log file with -vv not -vvvv.
|
||||
|
||||
* Make set-clipboard a three state option: on (tmux both sends to outside
|
||||
terminal and accepts from applications inside); external (tmux sends outside
|
||||
but does not accept inside); and off.
|
||||
|
||||
* Fix OSC 4 palette setting for bright foreground colours. GitHub issue 954.
|
||||
|
||||
* Use setrgbf and setrgbb terminfo(5) capabilities to set RGB colours, if they
|
||||
are available. (Tc is still supported as well.)
|
||||
|
||||
* Fix redrawing panes when they are resized several times but end up with the
|
||||
size unchanged (for example, splitw/resizep -Z/breakp).
|
||||
|
||||
* Major rewrite of choose mode. Now includes preview, sorting, searching and
|
||||
tagging; commands that can be executed directly from the mode (for example,
|
||||
to delete one or more buffers); and filtering in tree mode.
|
||||
|
||||
* choose-window and choose-session are now aliases of choose-tree (in the
|
||||
command-alias option).
|
||||
|
||||
* Support OSC 10 and OSC 11 to set foreground and background colours.
|
||||
|
||||
* Check the U8 capability to determine whether to use UTF-8 line drawing
|
||||
characters for ACS.
|
||||
|
||||
* Some missing notifications for layout changes.
|
||||
|
||||
* Control mode clients now do not affect session sizes until they issue
|
||||
refresh-client -C. new-session -x and -y works with control clients even if
|
||||
the session is not detached.
|
||||
|
||||
* All new sessions that are unattached (whether with -d or started with no
|
||||
terminal) are now created with size 80 x 24. Whether the status line is on or
|
||||
off does not affect the size of new sessions until they are attached.
|
||||
|
||||
* Expand formats in option names and add -F flag to expand them in option values.
|
||||
|
||||
* Remember the search string for a pane even if copy mode is exited and entered
|
||||
again.
|
||||
|
||||
* Some further BCE fixes (scroll up, reverse index).
|
||||
|
||||
* Improvements to how terminals are cleared (entirely or partially).
|
||||
|
||||
CHANGES FROM 2.4 TO 2.5, 09 May 2017
|
||||
|
||||
* Reset updated flag when restarting #() command so that new output is properly
|
||||
recognised. GitHub issue 922.
|
||||
|
||||
* Fix ECH with a background colour.
|
||||
|
||||
* Do not rely on the terminal not moving the cursor after DL or EL.
|
||||
|
||||
* Fix send-keys and send-prefix in copy-mode (so C-b C-b works). GitHub issue
|
||||
905.
|
||||
|
||||
* Set the current pane for rotate-window so it works in command sequences.
|
||||
|
||||
* Add pane_mode format.
|
||||
|
||||
* Differentiate M-Up from Escape+Up when possible (that is, in terminals with
|
||||
xterm(1) style function keys). GitHub issue 907.
|
||||
|
||||
* Add session_stack and window_stack_index formats.
|
||||
|
||||
* Some new control mode notifications and corresponding hooks:
|
||||
pane-mode-changed, window-pane-changed, client-session-changed,
|
||||
session-window-changed.
|
||||
|
||||
* Format pane_search_string for last search term while in copy mode (useful
|
||||
with command-prompt -I).
|
||||
|
||||
* Fix a problem with high CPU usage and multiple clients with #(). GitHub issue
|
||||
889.
|
||||
|
||||
* Fix UTF-8 combining characters in column 0.
|
||||
|
||||
* Fix reference counting so that panes are properly destroyed and their
|
||||
processes killed.
|
||||
|
||||
* Clamp SU (CSI S) parameter to work around a bug in Konsole.
|
||||
|
||||
* Tweak line wrapping in full width panes to play more nicely with terminal
|
||||
copy and paste.
|
||||
|
||||
* Fix when we emit SGR 0 in capture-pane -e.
|
||||
|
||||
* Do not change TERM until after config file parsing has finished, so that
|
||||
commands run inside the config file can use it to make decisions (typically
|
||||
about default-terminal).
|
||||
|
||||
* Make the initial client wait until config file parsing has finished to avoid
|
||||
racing with commands.
|
||||
|
||||
* Fix core when if-shell fails.
|
||||
|
||||
* Only use ED to clear screen if the pane is at the bottom.
|
||||
|
||||
* Fix multibyte UTF-8 output.
|
||||
|
||||
* Code improvements around target (-t) resolution.
|
||||
|
||||
* Change how the default target (for commands without -t) is managed across
|
||||
command sequences: now it is set up at the start and commands are required
|
||||
to update it if needed. Fixes binding command sequences to mouse keys.
|
||||
|
||||
* Make if-shell from the config file work correctly.
|
||||
|
||||
* Change to always check the root key table if no binding is found in the
|
||||
current table (prefix table or copy-mode table or whatever). This means that
|
||||
root key bindings will take effect even in copy mode, if not overridden by a
|
||||
copy mode key binding.
|
||||
|
||||
* Fix so that the history file works again.
|
||||
|
||||
* Run config file without a client rather than using the first client, restores
|
||||
previous behaviour.
|
||||
|
||||
* If a #() command doesn't exit, continue to read from it and use its last full
|
||||
line of output.
|
||||
|
||||
* Handle slow terminals and fast output better: when the amount of data
|
||||
outstanding gets too large, discard output until it is drained and we are
|
||||
able to do a full redraw. Prevents tmux sitting on a huge buffer that the
|
||||
terminal will take forever to consume.
|
||||
|
||||
* Do not redraw a client unless we realistically think it can accept the data -
|
||||
defer redraws until the client has nothing else waiting to write.
|
||||
|
||||
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
|
||||
|
||||
These 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 -i -p'search up' "send -X search-backward-incremental '%%'"
|
||||
|
||||
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
|
||||
====================
|
||||
@@ -49,7 +909,7 @@ Normal Changes
|
||||
* 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
|
||||
CHANGES FROM 1.9a TO 2.0, 06 March 2015
|
||||
|
||||
Incompatible Changes
|
||||
====================
|
||||
@@ -108,18 +968,18 @@ Normal Changes
|
||||
* '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
|
||||
CHANGES FROM 1.9 TO 1.9a, 22 February 2014
|
||||
|
||||
NOTE: This is a bug-fix release to address some important bugs which just
|
||||
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.
|
||||
* Fix -fg/-bg/-style with 256 colour terminals.
|
||||
|
||||
CHANGES FROM 1.8 to 1.9, 20 February 2014
|
||||
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
|
||||
@@ -151,8 +1011,8 @@ 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_syncronized} format specifier has been added to be a conditional
|
||||
format if a pane is in a syncronised mode (c.f. syncronize-panes)
|
||||
* 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
|
||||
@@ -174,7 +1034,7 @@ Normal Changes
|
||||
* 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
|
||||
====================
|
||||
@@ -225,7 +1085,7 @@ Normal Changes
|
||||
* Lots and lots of bug fixes, fixing memory-leaks, etc.
|
||||
* Various manpage improvements.
|
||||
|
||||
CHANGES FROM 1.6 to 1.7, 13 October 2012
|
||||
CHANGES FROM 1.6 TO 1.7, 13 October 2012
|
||||
|
||||
* tmux configuration files now support line-continuation with a "\" at the
|
||||
end of a line.
|
||||
@@ -475,7 +1335,7 @@ CHANGES FROM 1.2 TO 1.3, 18 July 2010
|
||||
* Run job commands explicitly in the global environment (which can be modified
|
||||
with setenv -g), rather than with the environment tmux started with.
|
||||
* Use the machine's hostname as the default title, instead of an empty string.
|
||||
* Prevent double free if the window option remain-on-exit is set.
|
||||
* Prevent double free if the window option remain-on-exit is set.
|
||||
* Key string conversions rewritten.
|
||||
* Mark zombie windows as dead in the choose-window list.
|
||||
* Tiled layout added.
|
||||
@@ -577,7 +1437,7 @@ CHANGES FROM 1.0 TO 1.1, 05 November 2009
|
||||
* New lock-client (alias lockc), and lock-session (alias locks) commands to
|
||||
lock a particular client, or all clients attached to a session.
|
||||
* Support C-n/C-p/C-v/M-v with emacs keys in choice mode.
|
||||
* Use : for goto line rather than g in vi mode.
|
||||
* Use : for goto line rather than g in vi mode.
|
||||
* Try to guess which client to use when no target client was specified. Finds
|
||||
the current session, and if only one client is present, use it. Otherwise,
|
||||
return the most recently used client.
|
||||
@@ -616,7 +1476,7 @@ CHANGES FROM 1.0 TO 1.1, 05 November 2009
|
||||
* xterm-keys rewrite.
|
||||
* Additional code reduction, and bug fixes.
|
||||
|
||||
CHANGES FROM 0.9 TO 1.0, 20 Sept 2009
|
||||
CHANGES FROM 0.9 TO 1.0, 20 September 2009
|
||||
|
||||
* Option to alter the format of the window title set by tmux.
|
||||
* Backoff for a while after multiple incorrect password attempts.
|
||||
@@ -708,7 +1568,7 @@ The list of older changes is below.
|
||||
|
||||
* main-horizontal layout and main-pane-height option to match vertical.
|
||||
* New window option main-pane-width to set the width of the large left pane with
|
||||
main-vertical (was left-vertical) layout.
|
||||
main-vertical (was left-vertical) layout.
|
||||
* Lots of layout cleanup. manual layout is now manual-vertical.
|
||||
|
||||
16 May 2009
|
||||
@@ -952,7 +1812,7 @@ The list of older changes is below.
|
||||
* -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.
|
||||
* 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
|
||||
example:
|
||||
|
||||
|
||||
7
COPYING
7
COPYING
@@ -1,10 +1,7 @@
|
||||
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:
|
||||
The README, CHANGES, FAQ and TODO files are licensed under the ISC license. All
|
||||
other files have a license and copyright notice at their start, typically:
|
||||
|
||||
Copyright (c) <author>
|
||||
|
||||
|
||||
454
FAQ
454
FAQ
@@ -1,454 +0,0 @@
|
||||
tmux frequently asked questions
|
||||
|
||||
******************************************************************************
|
||||
* PLEASE NOTE: most display problems are due to incorrect TERM! Before *
|
||||
* reporting problems make SURE that TERM settings are correct inside and *
|
||||
* outside tmux. *
|
||||
* *
|
||||
* Inside tmux TERM must be "screen" or similar (such as "screen-256color"). *
|
||||
* Don't bother reporting problems where it isn't! *
|
||||
* *
|
||||
* Outside, it must match your terminal: particularly, use "rxvt" for rxvt *
|
||||
* and derivatives. *
|
||||
******************************************************************************
|
||||
|
||||
* How is tmux different from GNU screen?
|
||||
|
||||
tmux and GNU screen have many similarities. Some of the main differences I am
|
||||
aware of are (bearing in mind I haven't used screen for a few years now):
|
||||
|
||||
- tmux uses a client-server model. Each server has single Unix domain socket in
|
||||
/tmp and within one server there are multiple sessions which may be attached
|
||||
to multiple clients (terminals).
|
||||
|
||||
This has advantages, notably: windows may be linked simultaneously to
|
||||
multiple sessions; windows may be moved freely between sessions; and a client
|
||||
may be switched between sessions easily (C-b D). There is one major
|
||||
disadvantage: if the server crashes, game over, all sessions die. In
|
||||
practice, however, tmux is quite stable and gets more so as people report any
|
||||
bugs they hit :-).
|
||||
|
||||
This model is different from screen, where typically each new screen instance
|
||||
is independent. tmux supports the same behaviour by using multiple servers
|
||||
with the -L option but it is not typically recommended.
|
||||
|
||||
- Different command interfaces. One of the goals of tmux is that the shell
|
||||
should be easily usable as a scripting language - almost all tmux commands
|
||||
can be used from the shell and behave identically whether used from the
|
||||
shell, from a key binding or from the command prompt. Personally I also find
|
||||
tmux's command interface much more consistent and clearer, but this is
|
||||
subjective.
|
||||
|
||||
- tmux calls window names (what you see in the status line) "names", screen
|
||||
calls them "titles".
|
||||
|
||||
- tmux has a multiple paste buffers. Not a major one but comes in handy quite a
|
||||
lot.
|
||||
|
||||
- tmux supports automatically renaming windows to the running application
|
||||
without gross hacks using escape sequences. Its even on by default.
|
||||
|
||||
- tmux has a choice of vi or emacs key layouts. Again, not major, but I use
|
||||
emacs so if tmux did support only one key set it would be emacs and then all
|
||||
the vi users would get humpy. Key bindings may be completely reconfigured in
|
||||
any case.
|
||||
|
||||
- tmux has an option to limit the window size.
|
||||
|
||||
- tmux has search in windows (C-b f).
|
||||
|
||||
- The window split (pane) model is different. tmux has two objects, windows and
|
||||
panes; screen has just windows. This difference has several implications:
|
||||
|
||||
* In screen you can have a window appear in several layouts, in tmux a pane
|
||||
can only be in one window (fixing this is a big todo item but quite
|
||||
invasive).
|
||||
|
||||
* tmux layouts are immutable and do not get changed unless you modify them.
|
||||
|
||||
* In tmux, all panes are closed when you kill a window.
|
||||
|
||||
* tmux panes do not have individual names, titles and so on.
|
||||
|
||||
I think tmux's model is much easier to manage and navigate within a window,
|
||||
but breaking panes off from and joining them to windows is more clumsy.
|
||||
|
||||
tmux also has support for preset pane layouts.
|
||||
|
||||
- tmux's status line syntax is more readable and easier to use. I think it'd be
|
||||
hard for anyone to argue with this. tmux doesn't support running a command
|
||||
constantly and always using the last line of its output, commands must be run
|
||||
again each time.
|
||||
|
||||
- tmux has modern, easily extended code. Again hard to argue screen is better
|
||||
if you have looked at the code.
|
||||
|
||||
- tmux depends on libevent. I don't see this as a disadvantage: libevent is
|
||||
small and portable, and on modern systems with current package management
|
||||
systems dependencies are not an issue. libevent brings advantages in code
|
||||
simplicity and performance.
|
||||
|
||||
- screen allows the window to be bigger than the terminal and can pan around
|
||||
it. tmux limits the size to the largest attached client. This is a big todo
|
||||
item for tmux but it is not trivial.
|
||||
|
||||
- screen has builtin serial and telnet support; this is bloat and is unlikely
|
||||
to be added to tmux.
|
||||
|
||||
- Environment handling is different.
|
||||
|
||||
- tmux tends to be more demanding on the terminal so tends to show up terminal
|
||||
and application bugs which screen does not.
|
||||
|
||||
- screen has wider platform support, for example IRIX, and for odd terminals.
|
||||
|
||||
* I found a bug! What do I do?
|
||||
|
||||
Check the latest version of tmux from Git to see if the problem is still
|
||||
reproducible. Sometimes the length of time between releases means a lot of
|
||||
fixes can be sitting in Git and the problem might already be fixed.
|
||||
|
||||
Please send bug reports by email to nicholas.marriott@gmail.com or
|
||||
tmux-users@googlegroups.com. Please include as much of the following
|
||||
information as possible:
|
||||
|
||||
- the version of tmux you are running;
|
||||
- the operating system you are using and its version;
|
||||
- the terminal emulator you are using and the TERM setting when tmux was
|
||||
started;
|
||||
- a description of the problem;
|
||||
- if the problem is repeatable, the steps to repeat the problem;
|
||||
- for screen corruption issues, a screenshot and the output of "infocmp $TERM"
|
||||
from outside tmux are often very useful.
|
||||
|
||||
* Why doesn't tmux do $x?
|
||||
|
||||
Please send feature requests by email to tmux-users@googlegroups.com.
|
||||
|
||||
* Why do you use the screen terminal description inside tmux? It sucks.
|
||||
|
||||
It is already widely available. It is planned to change to something else such
|
||||
as xterm-xfree86 at some point, if possible.
|
||||
|
||||
* I don't see any colour in my terminal! Help!
|
||||
|
||||
On some platforms, common terminal descriptions such as xterm do not include
|
||||
colour. screen ignores this, tmux does not. If the terminal emulator in use
|
||||
supports colour, use a value for TERM which correctly lists this, such as
|
||||
xterm-color.
|
||||
|
||||
* tmux freezes my terminal when I attach to a session. I even have to kill -9
|
||||
the shell it was started from to recover!
|
||||
|
||||
Some consoles really really don't like attempts to set the window title. Tell
|
||||
tmux not to do this by turning off the "set-titles" option (you can do this
|
||||
in .tmux.conf):
|
||||
|
||||
set -g set-titles off
|
||||
|
||||
If this doesn't fix it, send a bug report.
|
||||
|
||||
* Why is C-b the prefix key? How do I change it?
|
||||
|
||||
The default key is C-b because the prototype of tmux was originally developed
|
||||
inside screen and C-b was chosen not to clash with the screen meta key. It
|
||||
also has the advantage of not interfering with the use of C-a for start-of-line
|
||||
in emacs and the shell (although it does interfere with previous-character).
|
||||
|
||||
Changing is simple: change the "prefix-key" option, and - if required - move
|
||||
the binding of the "send-prefix" command from C-b (C-b C-b sends C-b by
|
||||
default) to the new key. For example:
|
||||
|
||||
set -g prefix C-a
|
||||
unbind C-b
|
||||
bind C-a send-prefix
|
||||
|
||||
* How do I use UTF-8?
|
||||
|
||||
When running tmux in a UTF-8 capable terminal, UTF-8 must be turned on in tmux;
|
||||
as of release 0.9, tmux attempts to autodetect a UTF-8-capable terminal by
|
||||
checking the LC_ALL, LC_CTYPE and LANG environment variables. list-clients may
|
||||
be used to check if this is detected correctly; if not, the -u command-line
|
||||
flag may be specified when creating or attaching a client to a tmux session:
|
||||
|
||||
$ tmux -u new
|
||||
|
||||
Since the 1.0 release, tmux will turn on UTF-8 related options automatically
|
||||
(ie status-utf8, and utf8) if the above conditions are met.
|
||||
|
||||
* How do I use a 256 colour terminal?
|
||||
|
||||
Provided the underlying terminal supports 256 colours, it is usually sufficient
|
||||
to add the following to ~/.tmux.conf:
|
||||
|
||||
set -g default-terminal "screen-256color"
|
||||
|
||||
Note that some platforms do not support "screen-256color" ("infocmp
|
||||
screen-256color" will return an error) - in this case see the next entry in
|
||||
this FAQ.
|
||||
|
||||
tmux attempts to detect a 256 colour terminal both by looking at the colors
|
||||
terminfo entry and by looking for the string "256col" in the TERM environment
|
||||
variable.
|
||||
|
||||
If both these methods fail, the -2 flag may be passed to tmux when attaching
|
||||
to a session to indicate the terminal supports 256 colours.
|
||||
|
||||
* vim or $otherprogram doesn't display 256 colours. What's up?
|
||||
|
||||
Some programs attempt to detect the number of colours a terminal is capable of
|
||||
by checking the colors terminfo or Co termcap entry. However, this is not
|
||||
reliable, and in any case is missing from the "screen" terminal description
|
||||
used inside tmux.
|
||||
|
||||
There are two options (aside from using "screen-256color") to allow programs to
|
||||
recognise they are running on a 256-colour terminal inside tmux:
|
||||
|
||||
- Manually force the application to use 256 colours always or if TERM is set to
|
||||
screen. For vim, you can do this by overriding the t_Co option, see
|
||||
http://vim.wikia.com/wiki/256_colors_in_vim.
|
||||
- Creating a custom terminfo file that includes colors#256 in ~/.terminfo and
|
||||
using it instead. These may be compiled with tic(1).
|
||||
|
||||
* How do I make Ctrl-PgUp and Ctrl-PgDn work in vim?
|
||||
|
||||
tmux supports passing through ctrl (and where supported by the client terminal,
|
||||
alt and shift) modifiers to function keys using xterm(1)-style key sequences.
|
||||
This may be enabled per window, or globally with the tmux command:
|
||||
|
||||
setw -g xterm-keys on
|
||||
|
||||
Because the TERM variable inside tmux must be set to "screen", vim will not
|
||||
automatically detect these keys are available; however, the appropriate key
|
||||
sequences can be overridden in .vimrc using the following:
|
||||
|
||||
if &term == "screen"
|
||||
set t_kN=^[[6;*~
|
||||
set t_kP=^[[5;*~
|
||||
endif
|
||||
|
||||
And similarly for any other keys for which modifiers are desired.
|
||||
|
||||
Please note that the "xterm-keys" setting may affect other programs, in the
|
||||
same way as running them in a standard xterm; for example most shells do not
|
||||
expect to receive xterm(1)-style key sequences so this setting may prevent keys
|
||||
such as ctrl-left and ctrl-right working correctly. tmux also passes through
|
||||
the ctrl (bit 5 set, for example ^[[5~ to ^[[5^) modifier in non-xterm(1) mode;
|
||||
it may be possible to configure vim to accept these, an example of how to do so
|
||||
would be welcome.
|
||||
|
||||
vim users may also want to set the "ttyfast" option inside tmux.
|
||||
|
||||
* How do I make ctrl and shift arrow keys work in emacs?
|
||||
|
||||
The terminal-init-screen function in term/screen.el is called for new frames,
|
||||
but it doesn't configure any function keys.
|
||||
|
||||
If the tmux xterm-keys option is on, it is enough to define the same keys as
|
||||
xterm. Add the following to init.el or .emacs to do this:
|
||||
|
||||
(defadvice terminal-init-screen
|
||||
;; The advice is named `tmux', and is run before `terminal-init-screen' runs.
|
||||
(before tmux activate)
|
||||
;; Docstring. This describes the advice and is made available inside emacs;
|
||||
;; for example when doing C-h f terminal-init-screen RET
|
||||
"Apply xterm keymap, allowing use of keys passed through tmux."
|
||||
;; This is the elisp code that is run before `terminal-init-screen'.
|
||||
(if (getenv "TMUX")
|
||||
(let ((map (copy-keymap xterm-function-map)))
|
||||
(set-keymap-parent map (keymap-parent input-decode-map))
|
||||
(set-keymap-parent input-decode-map map))))
|
||||
|
||||
And ensure .tmux.conf contains "set -g xterm-keys on".
|
||||
|
||||
Alternatively, the screen.el file can be copied to the load path and
|
||||
customized.
|
||||
|
||||
* Why doesn't elinks set the window title inside tmux?
|
||||
|
||||
There isn't a way to detect if a terminal supports setting the window title, so
|
||||
elinks attempts to guess by looking at the environment. Rather than looking for
|
||||
TERM=screen, it uses the STY variable to detect if it is running in screen;
|
||||
tmux does not use this so the check fails. A workaround is to set STY before
|
||||
running elinks.
|
||||
|
||||
The following shell function does this, and also clears the window title on
|
||||
exit (elinks, for some strange reason, sets it to the value of TERM):
|
||||
|
||||
elinks() {
|
||||
STY= `which elinks` $*
|
||||
echo -ne \\033]0\;\\007;
|
||||
}
|
||||
|
||||
* What is the proper way to escape characters with #(command)?
|
||||
|
||||
When using the #(command) construction to include the output from a command in
|
||||
the status line, the command will be parsed twice. First, when it's read by the
|
||||
configuration file or the command-prompt parser, and second when the status
|
||||
line is being drawn and the command is passed to the shell. For example, to
|
||||
echo the string "(test)" to the status line, either single or double quotes
|
||||
could be used:
|
||||
|
||||
set -g status-right "#(echo \\\\(test\\\\))"
|
||||
set -g status-right '#(echo \\\(test\\\))'
|
||||
|
||||
In both cases, the status-right option will be set to the string "#(echo
|
||||
\\(test\\))" and the command executed will be "echo \(test\)".
|
||||
|
||||
* tmux uses too much CPU. What do I do?
|
||||
|
||||
Automatic window renaming may use a lot of CPU, particularly on slow computers:
|
||||
if this is a problem, turn it off with "setw -g automatic-rename off". If this
|
||||
doesn't fix it, please report the problem.
|
||||
|
||||
* I use PuTTY and my tmux window pane separators are all qqqqqqqqq's!
|
||||
|
||||
PuTTY is using a character set translation that doesn't support ACS line
|
||||
drawing. With a Unicode font, try setting PuTTY to use a different translation
|
||||
on the Window -> Translation configuration page. For example, change UTF-8 to
|
||||
ISO-8859-1 or CP437. It may also be necessary to adjust the way PuTTY treats
|
||||
line drawing characters in the lower part of the same configuration page.
|
||||
|
||||
* What is the best way to display the load average? Why no #L?
|
||||
|
||||
It isn't possible to get the load average portably in code and it is preferable
|
||||
not to add portability goop. The following works on at least Linux, *BSD and OS
|
||||
X:
|
||||
|
||||
uptime|awk '{split(substr($0, index($0, "load")), a, ":"); print a[2]}'
|
||||
|
||||
* How do I attach the same session to multiple clients but with a different
|
||||
current window, like screen -x?
|
||||
|
||||
One or more of the windows can be linked into multiple sessions manually with
|
||||
link-window, or a grouped session with all the windows can be created with
|
||||
new-session -t.
|
||||
|
||||
* Ctrl and arrow keys doesn't work in putty! What do I do?
|
||||
|
||||
putty inverts the sense of the cursor key mode on ctrl, which is a bit hard for
|
||||
tmux to detect properly. To get ctrl keys right, change the terminfo settings
|
||||
so kUP5 (Ctrl-Up etc) are the adjusted versions, and disable smkx/rmkx so tmux
|
||||
doesn't change the mode. For example with this line in .tmux.conf (assuming you
|
||||
have TERM set to xterm):
|
||||
|
||||
set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@"
|
||||
|
||||
Note that this will only work in tmux 1.2 and above.
|
||||
|
||||
* How can I blank the tmux window?
|
||||
|
||||
GNU screen has a feature whereby it will blank the screen after a period of
|
||||
inactivity. To do the same thing in tmux, use the lock-command setting, for
|
||||
example (with GNU bash):
|
||||
|
||||
set -g lock-command 'tput civis && read -s -n1'
|
||||
|
||||
This will remove the cursor and tell the shell to quit once a key has been
|
||||
pressed. For zsh, use "read -s -k1".
|
||||
|
||||
In addition, it's possible to have both blanking and locking (for instance via
|
||||
lock(1) or vlock(1)) by using the following:
|
||||
|
||||
bind x set lock-command '/usr/bin/vlock' \; lock-client \; set lock-command 'tput civis && read -s -n1'
|
||||
|
||||
* I don't see italics! Or less and vim show italics and reverse the wrong way round!
|
||||
|
||||
GNU screen does not support italics and the "screen" terminfo description uses
|
||||
the italics escape sequence incorrectly.
|
||||
|
||||
As of tmux 2.1, if default-terminal is set to "screen" or matches "screen-*",
|
||||
tmux will behave like screen and italics will be disabled.
|
||||
|
||||
To enable italics, create a new terminfo entry called "tmux" (some platforms
|
||||
may already have this, you can check with "infocmp tmux"):
|
||||
|
||||
$ cat <<EOF|tic -x -
|
||||
tmux|tmux terminal multiplexer,
|
||||
ritm=\E[23m, rmso=\E[27m, sitm=\E[3m, smso=\E[7m, Ms@,
|
||||
use=xterm+tmux, use=screen,
|
||||
|
||||
tmux-256color|tmux with 256 colors,
|
||||
use=xterm+256setaf, use=tmux,
|
||||
EOF
|
||||
$
|
||||
|
||||
And tell tmux to use it in ~/.tmux.conf:
|
||||
|
||||
set -g default-terminal "tmux"
|
||||
|
||||
If using urxvt, make sure you have an italics capable font enabled. for
|
||||
example, add to ~/.Xdefaults:
|
||||
|
||||
urxvt.italicFont: xft:Bitstream Vera Sans Mono:italic:autohint=true
|
||||
|
||||
* How can I make tmux use my terminal's scrollback buffer?
|
||||
|
||||
Normally, tmux enables the terminal's "alternate screen". Most terminals (such
|
||||
as xterm) do not save scrollback for the alternate screen. You might prefer
|
||||
tmux to use the normal screen, so it uses your terminal's scrollback
|
||||
buffer. This way, you can access the scrollback buffer as usual, for example
|
||||
using the mouse wheel - although there is no guarantee output inside tmux will
|
||||
always (or ever) be added to the scrollback.
|
||||
|
||||
You can make tmux use the normal screen by telling it that your terminal does
|
||||
not have an alternate screen. Put the following in ~/.tmux.conf:
|
||||
|
||||
set -ga terminal-overrides ',xterm*:smcup@:rmcup@'
|
||||
|
||||
Adjust if your $TERM does not start with xterm.
|
||||
|
||||
tmux will still emulate the alternate screen for applications run under tmux,
|
||||
so you don't really lose anything with this setting. The only disadvantage is
|
||||
that when you exit tmux, it will not restore whatever was there before you
|
||||
started.
|
||||
|
||||
* How do I see the default configuration?
|
||||
|
||||
Show the default session options by starting a new tmux server with no
|
||||
configuration file:
|
||||
|
||||
$ tmux -Lfoo -f/dev/null start\; show -g
|
||||
|
||||
Or the default window options:
|
||||
|
||||
$ tmux -Lfoo -f/dev/null start\; show -gw
|
||||
|
||||
* How do I copy a selection from tmux to the system's clipboard?
|
||||
|
||||
When running in xterm(1), tmux can automatically send copied text to the
|
||||
clipboard. This is controlled by the set-clipboard option and also needs this
|
||||
X resource to be set:
|
||||
|
||||
XTerm*disallowedWindowOps: 20,21,SetXprop
|
||||
|
||||
For rxvt-unicode (urxvt), there is an unofficial Perl extension here:
|
||||
|
||||
http://anti.teamidiot.de/static/nei/*/Code/urxvt/
|
||||
|
||||
Otherwise a key binding for copy mode using xclip (or xsel) works:
|
||||
|
||||
bind -temacs-copy C-y copy-pipe "xclip -i >/dev/null"
|
||||
|
||||
Or for inside and outside copy mode with the prefix key:
|
||||
|
||||
bind C-y run -b "tmux save-buffer - | xclip -i"
|
||||
|
||||
On OS X, reattach-to-usernamespace lets pbcopy/pbpaste work:
|
||||
|
||||
https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
|
||||
|
||||
* 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
|
||||
148
Makefile.am
148
Makefile.am
@@ -2,61 +2,60 @@
|
||||
|
||||
# Obvious program stuff.
|
||||
bin_PROGRAMS = tmux
|
||||
CLEANFILES = tmux.1.mdoc tmux.1.man
|
||||
CLEANFILES = tmux.1.mdoc tmux.1.man cmd-parse.c
|
||||
|
||||
# Distribution tarball options.
|
||||
EXTRA_DIST = \
|
||||
CHANGES FAQ README TODO COPYING examples compat/*.[ch] \
|
||||
array.h compat.h tmux.h osdep-*.c mdoc2man.awk tmux.1
|
||||
dist-hook:
|
||||
make clean
|
||||
grep "^#found_debug=" configure
|
||||
CHANGES README README.ja COPYING example_tmux.conf \
|
||||
osdep-*.c mdoc2man.awk tmux.1
|
||||
dist_EXTRA_tmux_SOURCES = compat/*.[ch]
|
||||
|
||||
# Preprocessor flags.
|
||||
CPPFLAGS += @XOPEN_DEFINES@ -DTMUX_CONF="\"$(sysconfdir)/tmux.conf\""
|
||||
AM_CPPFLAGS += @XOPEN_DEFINES@ \
|
||||
-DTMUX_VERSION="\"@VERSION@\"" \
|
||||
-DTMUX_CONF="\"$(sysconfdir)/tmux.conf:~/.tmux.conf:~/.config/tmux/tmux.conf\""
|
||||
|
||||
# glibc as usual does things ass-backwards and hides useful things by default,
|
||||
# so everyone has to add this.
|
||||
if IS_GLIBC
|
||||
CFLAGS += -D_GNU_SOURCE
|
||||
endif
|
||||
# Additional object files.
|
||||
LDADD = $(LIBOBJS)
|
||||
|
||||
# Set flags for gcc.
|
||||
if IS_GCC
|
||||
CFLAGS += -std=gnu99 -O2
|
||||
AM_CFLAGS += -std=gnu99 -O2
|
||||
if IS_DEBUG
|
||||
CFLAGS += -g
|
||||
CFLAGS += -Wno-long-long -Wall -W -Wnested-externs -Wformat=2
|
||||
CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
|
||||
CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare
|
||||
CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align
|
||||
CFLAGS += -Wdeclaration-after-statement -Wno-pointer-sign
|
||||
CPPFLAGS += -DDEBUG
|
||||
AM_CFLAGS += -g
|
||||
AM_CFLAGS += -Wno-long-long -Wall -W -Wformat=2
|
||||
AM_CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
|
||||
AM_CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare
|
||||
AM_CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align
|
||||
AM_CFLAGS += -Wdeclaration-after-statement -Wno-pointer-sign -Wno-attributes
|
||||
AM_CFLAGS += -Wno-unused-result
|
||||
AM_CPPFLAGS += -DDEBUG
|
||||
endif
|
||||
if IS_COVERAGE
|
||||
CFLAGS += -g -O0 --coverage
|
||||
LDFLAGS += --coverage
|
||||
endif
|
||||
CPPFLAGS += -iquote.
|
||||
AM_CPPFLAGS += -iquote.
|
||||
endif
|
||||
|
||||
# Set flags for Solaris.
|
||||
if IS_SUNOS
|
||||
if IS_GCC
|
||||
CPPFLAGS += -D_XPG6 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS
|
||||
AM_CPPFLAGS += -D_XPG6
|
||||
else
|
||||
CPPFLAGS += -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS
|
||||
AM_CPPFLAGS += -D_XPG4_2
|
||||
endif
|
||||
endif
|
||||
|
||||
# Set flags for Sun CC.
|
||||
if IS_SUNCC
|
||||
CFLAGS += -erroff=E_EMPTY_DECLARATION
|
||||
AM_CFLAGS += -erroff=E_EMPTY_DECLARATION
|
||||
endif
|
||||
|
||||
# Set _LINUX_SOURCE_COMPAT for AIX for mallocing 0 bytes
|
||||
# Set _LINUX_SOURCE_COMPAT for AIX for malloc(0).
|
||||
if IS_AIX
|
||||
DEFS += -D_LINUX_SOURCE_COMPAT=1
|
||||
AM_CPPFLAGS += -D_LINUX_SOURCE_COMPAT=1
|
||||
endif
|
||||
|
||||
# Set flags for NetBSD.
|
||||
if IS_NETBSD
|
||||
AM_CPPFLAGS += -D_OPENBSD_SOURCE
|
||||
endif
|
||||
|
||||
# List of sources.
|
||||
@@ -70,18 +69,16 @@ dist_tmux_SOURCES = \
|
||||
cmd-bind-key.c \
|
||||
cmd-break-pane.c \
|
||||
cmd-capture-pane.c \
|
||||
cmd-choose-buffer.c \
|
||||
cmd-choose-client.c \
|
||||
cmd-choose-tree.c \
|
||||
cmd-clear-history.c \
|
||||
cmd-command-prompt.c \
|
||||
cmd-confirm-before.c \
|
||||
cmd-copy-mode.c \
|
||||
cmd-detach-client.c \
|
||||
cmd-display-menu.c \
|
||||
cmd-display-message.c \
|
||||
cmd-display-panes.c \
|
||||
cmd-find.c \
|
||||
cmd-find-window.c \
|
||||
cmd-find.c \
|
||||
cmd-if-shell.c \
|
||||
cmd-join-pane.c \
|
||||
cmd-kill-pane.c \
|
||||
@@ -94,12 +91,12 @@ dist_tmux_SOURCES = \
|
||||
cmd-list-panes.c \
|
||||
cmd-list-sessions.c \
|
||||
cmd-list-windows.c \
|
||||
cmd-list.c \
|
||||
cmd-load-buffer.c \
|
||||
cmd-lock-server.c \
|
||||
cmd-move-window.c \
|
||||
cmd-new-session.c \
|
||||
cmd-new-window.c \
|
||||
cmd-parse.y \
|
||||
cmd-paste-buffer.c \
|
||||
cmd-pipe-pane.c \
|
||||
cmd-queue.c \
|
||||
@@ -107,6 +104,7 @@ dist_tmux_SOURCES = \
|
||||
cmd-rename-session.c \
|
||||
cmd-rename-window.c \
|
||||
cmd-resize-pane.c \
|
||||
cmd-resize-window.c \
|
||||
cmd-respawn-pane.c \
|
||||
cmd-respawn-window.c \
|
||||
cmd-rotate-window.c \
|
||||
@@ -124,7 +122,6 @@ dist_tmux_SOURCES = \
|
||||
cmd-show-options.c \
|
||||
cmd-source-file.c \
|
||||
cmd-split-window.c \
|
||||
cmd-string.c \
|
||||
cmd-swap-pane.c \
|
||||
cmd-swap-window.c \
|
||||
cmd-switch-client.c \
|
||||
@@ -132,11 +129,13 @@ dist_tmux_SOURCES = \
|
||||
cmd-wait-for.c \
|
||||
cmd.c \
|
||||
colour.c \
|
||||
control.c \
|
||||
compat.h \
|
||||
control-notify.c \
|
||||
control.c \
|
||||
environ.c \
|
||||
file.c \
|
||||
format.c \
|
||||
grid-cell.c \
|
||||
format-draw.c \
|
||||
grid-view.c \
|
||||
grid.c \
|
||||
input-keys.c \
|
||||
@@ -148,12 +147,15 @@ dist_tmux_SOURCES = \
|
||||
layout-set.c \
|
||||
layout.c \
|
||||
log.c \
|
||||
mode-key.c \
|
||||
menu.c \
|
||||
mode-tree.c \
|
||||
names.c \
|
||||
notify.c \
|
||||
options-table.c \
|
||||
options.c \
|
||||
paste.c \
|
||||
proc.c \
|
||||
regsub.c \
|
||||
resize.c \
|
||||
screen-redraw.c \
|
||||
screen-write.c \
|
||||
@@ -162,77 +164,35 @@ dist_tmux_SOURCES = \
|
||||
server-fn.c \
|
||||
server.c \
|
||||
session.c \
|
||||
signal.c \
|
||||
spawn.c \
|
||||
status.c \
|
||||
style.c \
|
||||
tmux.c \
|
||||
tmux.h \
|
||||
tty-acs.c \
|
||||
tty-keys.c \
|
||||
tty-term.c \
|
||||
tty.c \
|
||||
utf8.c \
|
||||
window-choose.c \
|
||||
window-buffer.c \
|
||||
window-client.c \
|
||||
window-clock.c \
|
||||
window-copy.c \
|
||||
window-tree.c \
|
||||
window.c \
|
||||
xmalloc.c \
|
||||
xmalloc.h \
|
||||
xterm-keys.c
|
||||
nodist_tmux_SOURCES = osdep-@PLATFORM@.c
|
||||
|
||||
# Pile in all the compat/ stuff that is needed.
|
||||
if NO_FORKPTY
|
||||
# Add compat file for forkpty.
|
||||
if NEED_FORKPTY
|
||||
nodist_tmux_SOURCES += compat/forkpty-@PLATFORM@.c
|
||||
endif
|
||||
if NO_IMSG
|
||||
nodist_tmux_SOURCES += compat/imsg.c compat/imsg-buffer.c
|
||||
endif
|
||||
if NO_CLOSEFROM
|
||||
nodist_tmux_SOURCES += compat/closefrom.c
|
||||
endif
|
||||
if NO_DAEMON
|
||||
nodist_tmux_SOURCES += compat/daemon.c
|
||||
endif
|
||||
if NO_SETENV
|
||||
nodist_tmux_SOURCES += compat/setenv.c
|
||||
endif
|
||||
if NO_STRLCAT
|
||||
nodist_tmux_SOURCES += compat/strlcat.c
|
||||
endif
|
||||
if NO_STRLCPY
|
||||
nodist_tmux_SOURCES += compat/strlcpy.c
|
||||
endif
|
||||
if NO_ASPRINTF
|
||||
nodist_tmux_SOURCES += compat/asprintf.c
|
||||
endif
|
||||
if NO_FGETLN
|
||||
nodist_tmux_SOURCES += compat/fgetln.c
|
||||
endif
|
||||
if NO_FPARSELN
|
||||
nodist_tmux_SOURCES += compat/fparseln.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
|
||||
if NO_CFMAKERAW
|
||||
nodist_tmux_SOURCES += compat/cfmakeraw.c
|
||||
endif
|
||||
if NO_OPENAT
|
||||
nodist_tmux_SOURCES += compat/openat.c
|
||||
|
||||
# Add compat file for utf8proc.
|
||||
if HAVE_UTF8PROC
|
||||
nodist_tmux_SOURCES += compat/utf8proc.c
|
||||
endif
|
||||
|
||||
# Install tmux.1 in the right format.
|
||||
@@ -242,7 +202,7 @@ install-exec-hook:
|
||||
>$(srcdir)/tmux.1.mdoc; \
|
||||
else \
|
||||
sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" $(srcdir)/tmux.1| \
|
||||
$(AWK) -f$(srcdir)/mdoc2man.awk >$(srcdir)/tmux.1.man; \
|
||||
$(AWK) -f $(srcdir)/mdoc2man.awk >$(srcdir)/tmux.1.man; \
|
||||
fi
|
||||
$(mkdir_p) $(DESTDIR)$(mandir)/man1
|
||||
$(INSTALL_DATA) $(srcdir)/tmux.1.@MANFORMAT@ \
|
||||
|
||||
88
README
88
README
@@ -1,61 +1,75 @@
|
||||
Welcome to tmux!
|
||||
|
||||
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
|
||||
simple, modern, BSD-licensed alternative to programs such as GNU screen.
|
||||
tmux is a terminal multiplexer: it enables a number of terminals to be created,
|
||||
accessed, and controlled from a single screen. tmux may be detached from a
|
||||
screen and continue running in the background, then later reattached.
|
||||
|
||||
This release runs on OpenBSD, FreeBSD, NetBSD, Linux, OS X and Solaris.
|
||||
|
||||
tmux depends on libevent 2.x. Download it from:
|
||||
* Dependencies
|
||||
|
||||
http://www.monkey.org/~provos/libevent/
|
||||
tmux depends on libevent 2.x, available from:
|
||||
|
||||
To build tmux from a release tarball, do:
|
||||
https://github.com/libevent/libevent/releases/latest
|
||||
|
||||
It also depends on ncurses, available from:
|
||||
|
||||
https://invisible-mirror.net/archives/ncurses/
|
||||
|
||||
* Installation
|
||||
|
||||
To build and install tmux from a release tarball, use:
|
||||
|
||||
$ ./configure && make
|
||||
$ sudo make install
|
||||
|
||||
To get and build the latest from version control:
|
||||
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 - note that this requires
|
||||
autoconf, automake and pkg-config:
|
||||
|
||||
$ git clone https://github.com/tmux/tmux.git
|
||||
$ cd tmux
|
||||
$ sh autogen.sh
|
||||
$ ./configure && make
|
||||
|
||||
For more information see http://git-scm.com. Patches should be sent by email to
|
||||
the mailing list at tmux-users@googlegroups.com.
|
||||
|
||||
For documentation on using tmux, see the tmux.1 manpage. It can be viewed from
|
||||
the source tree with:
|
||||
|
||||
$ nroff -mdoc tmux.1|less
|
||||
|
||||
Some common questions are answered in the FAQ file and a more extensive (but
|
||||
slightly out of date) guide is available in the OpenBSD FAQ at
|
||||
http://www.openbsd.org/faq/faq7.html#tmux. A rough todo list is in the TODO
|
||||
file and some example configurations and a Vim syntax file are in the examples
|
||||
directory.
|
||||
|
||||
For debugging, running tmux with -v or -vv will generate server and client log
|
||||
files in the current directory.
|
||||
|
||||
tmux mailing lists are available. For general discussion and bug reports:
|
||||
|
||||
https://groups.google.com/forum/#!forum/tmux-users
|
||||
|
||||
And for Git commit emails:
|
||||
|
||||
https://groups.google.com/forum/#!forum/tmux-git
|
||||
* Contributing
|
||||
|
||||
Bug reports, feature suggestions and especially code contributions are most
|
||||
welcome. Please send by email to:
|
||||
|
||||
tmux-users@googlegroups.com
|
||||
|
||||
This file and the CHANGES, FAQ, SYNCING 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.
|
||||
Or open a GitHub issue or pull request.
|
||||
|
||||
-- Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
* Documentation
|
||||
|
||||
For documentation on using tmux, see the tmux.1 manpage. View it from the
|
||||
source tree with:
|
||||
|
||||
$ nroff -mdoc tmux.1|less
|
||||
|
||||
A small example configuration is in example_tmux.conf.
|
||||
|
||||
A bash(1) completion file is at:
|
||||
|
||||
https://github.com/imomaliev/tmux-bash-completion
|
||||
|
||||
For debugging, run tmux with -v and -vv to generate server and client log files
|
||||
in the current directory.
|
||||
|
||||
* Support
|
||||
|
||||
The tmux mailing list for general discussion and bug reports is:
|
||||
|
||||
https://groups.google.com/forum/#!forum/tmux-users
|
||||
|
||||
Subscribe by sending an email to:
|
||||
|
||||
tmux-users+subscribe@googlegroups.com
|
||||
|
||||
* License
|
||||
|
||||
This file and the CHANGES files are licensed under the ISC license. All other
|
||||
files have a license and copyright notice at their start.
|
||||
|
||||
62
README.ja
Normal file
62
README.ja
Normal file
@@ -0,0 +1,62 @@
|
||||
tmuxへようこそ!
|
||||
|
||||
tmuxはターミナルマルチプレクサーです。複数のターミナルを一つのスクリーン内に作成し、操作することができます。
|
||||
バックグラウンドで処理を実行中に一度スクリーンから離れて後から復帰することも可能です。
|
||||
|
||||
OpenBSD、FreeBSD、NetBSD、Linux、OS X、Solarisで実行できます。
|
||||
|
||||
tmuxはlibevent 2.x.に依存します。 下記からダウンロードしてください。
|
||||
|
||||
http://libevent.org
|
||||
|
||||
また、ncursesも必要です。こちらからどうぞ。
|
||||
|
||||
http://invisible-island.net/ncurses/
|
||||
|
||||
tarballでのtmuxのビルドとインストール方法。
|
||||
|
||||
$ ./configure && make
|
||||
$ sudo make install
|
||||
|
||||
tmuxはutmp(5)をアップデートするためにutempterを使うことができます。もしインストール済みであればオプション「--enable-utempter」をつけて実行してください。
|
||||
|
||||
リポジトリから最新バージョンを手に入れるためには下記を実行。
|
||||
|
||||
$ git clone https://github.com/tmux/tmux.git
|
||||
$ cd tmux
|
||||
$ sh autogen.sh
|
||||
$ ./configure && make
|
||||
|
||||
(ビルドのためにはlibevent、ncurses libraries、headersに加えて、C compiler、make、autoconf、automake、pkg-configが必要です。)
|
||||
|
||||
詳しい情報はhttp://git-scm.comをご覧ください。修正はメール<tmux-users@googlegroups.com>宛、もしくはhttps://github.com/tmux/tmux/issuesにて受け付けています。
|
||||
|
||||
tmuxのドキュメントについてはtmux.1マニュアルをご覧ください。こちらのコマンドで参照可能です。
|
||||
|
||||
$ nroff -mdoc tmux.1|less
|
||||
|
||||
サンプル設定は本リポジトリのexample_tmux.confに
|
||||
また、bash-completionファイルは下記にあります。
|
||||
|
||||
https://github.com/imomaliev/tmux-bash-completion
|
||||
|
||||
「-v」や「-vv」を指定することでデバッグモードでの起動が可能です。カレントディレクトリにサーバーやクライアントのログファイルが生成されます。
|
||||
|
||||
議論やバグレポート用のメーリングリストにはこちらから参加可能です。
|
||||
|
||||
https://groups.google.com/forum/#!forum/tmux-users
|
||||
|
||||
gitコミットについての連絡先
|
||||
|
||||
https://groups.google.com/forum/#!forum/tmux-git
|
||||
|
||||
購読は<tmux-users+subscribe@googlegroups.com>までメールをお願いします。
|
||||
|
||||
バグレポートや機能追加(特にコードへの貢献)は大歓迎です。こちらにご連絡ください。
|
||||
|
||||
tmux-users@googlegroups.com
|
||||
|
||||
本ファイル、CHANGES、 FAQ、SYNCINGそしてTODOはISC licenseで保護されています。
|
||||
その他のファイルのライセンスや著作権については、ファイルの上部に明記されています。
|
||||
|
||||
-- Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
21
SYNCING
21
SYNCING
@@ -115,7 +115,7 @@ From there, merge the result in, fixing up any conflicts which might arise.
|
||||
|
||||
% git merge obsd-master
|
||||
|
||||
Then ensure things look correct by BULDING the result of that sync:
|
||||
Then ensure things look correct by BUILDING the result of that sync:
|
||||
|
||||
% make clean && ./autogen.sh && ./configure && make
|
||||
|
||||
@@ -140,15 +140,13 @@ to compat/ as and when appropriate.
|
||||
Release tmux for next version
|
||||
=============================
|
||||
|
||||
1. Comment the "found_debug=yes" line in configure.ac, since releases
|
||||
don't have debugging enabled, otherwise make(1) aborts when
|
||||
preparing the distribution.
|
||||
|
||||
2. Update and commit README and CHANGES. The former should be checked for
|
||||
1. Update and commit README and CHANGES. The former should be checked for
|
||||
anything outdated and updated with a list of things that might break
|
||||
upgrades and the latter should mention all the major changes since
|
||||
the last version.
|
||||
|
||||
2. Make sure configure.ac has the new version number.
|
||||
|
||||
3. Tag with:
|
||||
|
||||
% git tag -a 2.X
|
||||
@@ -157,7 +155,7 @@ Release tmux for next version
|
||||
|
||||
Push the tag out with:
|
||||
|
||||
% git push 2.X
|
||||
% git push --tags
|
||||
|
||||
4. Build the tarball with 'make dist'.
|
||||
|
||||
@@ -168,9 +166,8 @@ Release tmux for next version
|
||||
Click the "Add release notes", upload the tarball and add a link in the
|
||||
description field to the CHANGES file.
|
||||
|
||||
7. Clone the tmux.github.io repository, and change the RELEASE version in
|
||||
the Makefile. Commit it, and run 'make' to replace %%VERSION%%. Push
|
||||
the result out.
|
||||
6. Clone the tmux.github.io repository, and change the RELEASE version in the
|
||||
Makefile. Commit it, and run 'make' to replace %%RELEASE%%. Push the
|
||||
result out.
|
||||
|
||||
8. Bump version in tmu/tmux.git configure.ac and uncomment "found_debug=yes" to
|
||||
create a debug build by default.
|
||||
7. Change version back to master in configure.ac.
|
||||
|
||||
126
TODO
126
TODO
@@ -1,126 +0,0 @@
|
||||
- command bits and pieces:
|
||||
* allow multiple targets: fnmatch for -t/-c, for example detach all
|
||||
clients with -t*
|
||||
* add -c for new-session like new-window
|
||||
* ' and " should be parsed the same (eg "\e" vs '\e') in config
|
||||
and command prompt
|
||||
* last-pane across sessions
|
||||
|
||||
- make command sequences more usable
|
||||
* don't require space after ;
|
||||
* options for error handling: && and ||?
|
||||
|
||||
- options bits and pieces:
|
||||
* set-remain-on-exit is a complete hack
|
||||
* way to set socket path from config file
|
||||
|
||||
- format improvements:
|
||||
* option to quote format (#{session_name:quoted})
|
||||
* formats need conditions for >0 (for #P)
|
||||
* some way to pad # stuff with spaces
|
||||
* last window update time and format for it
|
||||
* formats to show if a window is linked into multiple sessions, into
|
||||
multiple attached sessions, and is the active window in multiple
|
||||
attached sessions?
|
||||
|
||||
- choose mode improvements:
|
||||
* choose-pane command (augment choose-tree to do this?)
|
||||
* choose-mode and copy-mode are very similar, make choose-mode a subset?
|
||||
* flag to choose-* for sort order
|
||||
* choose mode would be better per client than per window?
|
||||
* 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)
|
||||
|
||||
- hooks!
|
||||
|
||||
- warts on current naming:
|
||||
* display-time but message-fg/bg/attr
|
||||
* list-* vs show-*
|
||||
* split-window -> split-pane?
|
||||
|
||||
- better UTF-8 support:
|
||||
* window names and titles
|
||||
* message display
|
||||
* prompt input
|
||||
* multibyte key input
|
||||
* searching in copy mode
|
||||
|
||||
- copy/paste improvements:
|
||||
* incremental searching
|
||||
* paste w/o trailing whitespace
|
||||
* command to toggle selection not to move it in copy-mode
|
||||
* regex searching
|
||||
* copy-pipe should have -x as well
|
||||
|
||||
- layout stuff
|
||||
* way to tag a layout as a number/name
|
||||
* maybe keep last layout + size around and if size reverts just put it
|
||||
back
|
||||
* revamp layouts: they are too complicated, should be more closely
|
||||
integrated, should support hints, layout sets should just be a
|
||||
special case of custom layouts, and we should support panes that are
|
||||
not attached to a cell at all. this could be the time to introduce
|
||||
panelink to replace layout_cell
|
||||
* way to set hints/limits about pane size for resizing
|
||||
* panning over window (window larger than visible)
|
||||
* a mode where one application can cross two panes (ie x|y, width =
|
||||
COLUMNS/2 but height = ROWS * 2)
|
||||
* general key to space cells out evenly (horiz or vert) within their
|
||||
parent cell (could replace even-vert/even-horiz layouts)
|
||||
* separate active panes for different clients
|
||||
|
||||
- terminfo bits
|
||||
* use a better termcap internally instead of screen, perhaps xterm
|
||||
* use screen-256color when started on 256 colour terminal?
|
||||
|
||||
- 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
|
||||
* 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
|
||||
* optimize pane redraws, 20120318184853.GK10965@yelena.nicm.ath.cx
|
||||
|
||||
- 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?
|
||||
* customizable command aliases
|
||||
* automatic pane logging
|
||||
* BCE? We are halfway there (output side is done for pane backgrounds),
|
||||
just need to change how screen/grid handles erase
|
||||
334
alerts.c
334
alerts.c
@@ -1,7 +1,7 @@
|
||||
/* $OpenBSD$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
* 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
|
||||
@@ -19,80 +19,109 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <event.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
int alerts_fired;
|
||||
static int alerts_fired;
|
||||
|
||||
void alerts_timer(int, short, void *);
|
||||
int alerts_enabled(struct window *, int);
|
||||
void alerts_callback(int, short, void *);
|
||||
void alerts_reset(struct window *);
|
||||
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 *);
|
||||
|
||||
int alerts_check_bell(struct session *, struct winlink *);
|
||||
int alerts_check_activity(struct session *, struct winlink *);
|
||||
int alerts_check_silence(struct session *, struct winlink *);
|
||||
void alerts_ring_bell(struct session *);
|
||||
static int alerts_action_applies(struct winlink *, const char *);
|
||||
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 alerts_set_message(struct winlink *, const char *,
|
||||
const char *);
|
||||
|
||||
void
|
||||
alerts_timer(unused int fd, unused short events, void *arg)
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
alerts_callback(unused int fd, unused short events, unused void *arg)
|
||||
static void
|
||||
alerts_callback(__unused int fd, __unused short events, __unused void *arg)
|
||||
{
|
||||
struct window *w;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
int flags, alerts;
|
||||
struct window *w, *w1;
|
||||
int alerts;
|
||||
|
||||
RB_FOREACH(w, windows, &windows) {
|
||||
RB_FOREACH(s, sessions, &sessions) {
|
||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||
if (wl->window != w)
|
||||
continue;
|
||||
flags = w->flags;
|
||||
TAILQ_FOREACH_SAFE(w, &alerts_list, alerts_entry, w1) {
|
||||
alerts = alerts_check_all(w);
|
||||
log_debug("@%u alerts check, alerts %#x", w->id, alerts);
|
||||
|
||||
alerts = alerts_check_bell(s, wl);
|
||||
alerts |= alerts_check_activity(s, wl);
|
||||
alerts |= alerts_check_silence(s, wl);
|
||||
if (alerts != 0)
|
||||
server_status_session(s);
|
||||
w->alerts_queued = 0;
|
||||
TAILQ_REMOVE(&alerts_list, w, alerts_entry);
|
||||
|
||||
log_debug("%s:%d @%u alerts check, alerts %#x, "
|
||||
"flags %#x", s->name, wl->idx, w->id,
|
||||
alerts, flags);
|
||||
}
|
||||
}
|
||||
w->flags &= ~WINDOW_ALERTFLAGS;
|
||||
window_remove_ref(w, __func__);
|
||||
}
|
||||
alerts_fired = 0;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
alerts_action_applies(struct winlink *wl, const char *name)
|
||||
{
|
||||
int action;
|
||||
|
||||
/*
|
||||
* {bell,activity,silence}-action determines when to alert: none means
|
||||
* nothing happens, current means only do something for the current
|
||||
* window and other means only for windows other than the current.
|
||||
*/
|
||||
|
||||
action = options_get_number(wl->session->options, name);
|
||||
if (action == ALERT_ANY)
|
||||
return (1);
|
||||
if (action == ALERT_CURRENT)
|
||||
return (wl == wl->session->curw);
|
||||
if (action == ALERT_OTHER)
|
||||
return (wl != wl->session->curw);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
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)
|
||||
{
|
||||
struct session *s;
|
||||
|
||||
if (flags & WINDOW_BELL) {
|
||||
if (options_get_number(w->options, "monitor-bell"))
|
||||
return (1);
|
||||
}
|
||||
if (flags & WINDOW_ACTIVITY) {
|
||||
if (options_get_number(&w->options, "monitor-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);
|
||||
}
|
||||
if (~flags & WINDOW_BELL)
|
||||
return (0);
|
||||
RB_FOREACH(s, sessions, &sessions) {
|
||||
if (!session_has(s, w))
|
||||
continue;
|
||||
if (options_get_number(&s->options, "bell-action") != BELL_NONE)
|
||||
if (options_get_number(w->options, "monitor-silence") != 0)
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
@@ -107,16 +136,19 @@ alerts_reset_all(void)
|
||||
alerts_reset(w);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
alerts_reset(struct window *w)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
if (!event_initialized(&w->alerts_timer))
|
||||
evtimer_set(&w->alerts_timer, alerts_timer, w);
|
||||
|
||||
w->flags &= ~WINDOW_SILENCE;
|
||||
event_del(&w->alerts_timer);
|
||||
|
||||
timerclear(&tv);
|
||||
tv.tv_sec = options_get_number(&w->options, "monitor-silence");
|
||||
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)
|
||||
@@ -126,138 +158,166 @@ alerts_reset(struct window *w)
|
||||
void
|
||||
alerts_queue(struct window *w, int flags)
|
||||
{
|
||||
if (w->flags & WINDOW_ACTIVITY)
|
||||
alerts_reset(w);
|
||||
alerts_reset(w);
|
||||
|
||||
if (!event_initialized(&w->alerts_timer))
|
||||
evtimer_set(&w->alerts_timer, alerts_timer, w);
|
||||
if ((w->flags & flags) != flags) {
|
||||
w->flags |= flags;
|
||||
log_debug("@%u alerts flags added %#x", w->id, flags);
|
||||
}
|
||||
|
||||
if (w->flags & flags)
|
||||
return;
|
||||
w->flags |= flags;
|
||||
log_debug("@%u alerts flags added %#x", w->id, flags);
|
||||
if (alerts_enabled(w, flags)) {
|
||||
if (!w->alerts_queued) {
|
||||
w->alerts_queued = 1;
|
||||
TAILQ_INSERT_TAIL(&alerts_list, w, alerts_entry);
|
||||
window_add_ref(w, __func__);
|
||||
}
|
||||
|
||||
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;
|
||||
if (!alerts_fired) {
|
||||
log_debug("alerts check queued (by @%u)", w->id);
|
||||
event_once(-1, EV_TIMEOUT, alerts_callback, NULL, NULL);
|
||||
alerts_fired = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
alerts_check_bell(struct session *s, struct winlink *wl)
|
||||
static int
|
||||
alerts_check_bell(struct window *w)
|
||||
{
|
||||
struct client *c;
|
||||
struct window *w = wl->window;
|
||||
int action, visual;
|
||||
struct winlink *wl;
|
||||
struct session *s;
|
||||
|
||||
if (!(w->flags & WINDOW_BELL) || wl->flags & WINLINK_BELL)
|
||||
if (~w->flags & WINDOW_BELL)
|
||||
return (0);
|
||||
if (s->curw != wl || s->flags & SESSION_UNATTACHED)
|
||||
wl->flags |= WINLINK_BELL;
|
||||
if (s->flags & SESSION_UNATTACHED)
|
||||
return (0);
|
||||
if (s->curw->window == w)
|
||||
w->flags &= ~WINDOW_BELL;
|
||||
|
||||
action = options_get_number(&s->options, "bell-action");
|
||||
if (action == BELL_NONE)
|
||||
if (!options_get_number(w->options, "monitor-bell"))
|
||||
return (0);
|
||||
|
||||
visual = options_get_number(&s->options, "visual-bell");
|
||||
TAILQ_FOREACH(c, &clients, entry) {
|
||||
if (c->session != s || c->flags & CLIENT_CONTROL)
|
||||
continue;
|
||||
if (!visual) {
|
||||
if ((action == BELL_CURRENT &&
|
||||
c->session->curw->window == w) ||
|
||||
(action == BELL_OTHER &&
|
||||
c->session->curw->window != w) ||
|
||||
action == BELL_ANY)
|
||||
tty_putcode(&c->tty, TTYC_BEL);
|
||||
continue;
|
||||
TAILQ_FOREACH(wl, &w->winlinks, wentry)
|
||||
wl->session->flags &= ~SESSION_ALERTED;
|
||||
|
||||
TAILQ_FOREACH(wl, &w->winlinks, wentry) {
|
||||
/*
|
||||
* Bells are allowed even if there is an existing bell (so do
|
||||
* not check WINLINK_BELL).
|
||||
*/
|
||||
s = wl->session;
|
||||
if (s->curw != wl) {
|
||||
wl->flags |= WINLINK_BELL;
|
||||
server_status_session(s);
|
||||
}
|
||||
if (action == BELL_CURRENT && c->session->curw->window == w)
|
||||
status_message_set(c, "Bell in current window");
|
||||
else if (action == BELL_ANY || (action == BELL_OTHER &&
|
||||
c->session->curw->window != w))
|
||||
status_message_set(c, "Bell in window %d", wl->idx);
|
||||
if (!alerts_action_applies(wl, "bell-action"))
|
||||
continue;
|
||||
notify_winlink("alert-bell", wl);
|
||||
|
||||
if (s->flags & SESSION_ALERTED)
|
||||
continue;
|
||||
s->flags |= SESSION_ALERTED;
|
||||
|
||||
alerts_set_message(wl, "Bell", "visual-bell");
|
||||
}
|
||||
|
||||
return (WINDOW_BELL);
|
||||
}
|
||||
|
||||
int
|
||||
alerts_check_activity(struct session *s, struct winlink *wl)
|
||||
static int
|
||||
alerts_check_activity(struct window *w)
|
||||
{
|
||||
struct client *c;
|
||||
struct window *w = wl->window;
|
||||
struct winlink *wl;
|
||||
struct session *s;
|
||||
|
||||
if (s->curw->window == w)
|
||||
w->flags &= ~WINDOW_ACTIVITY;
|
||||
|
||||
if (!(w->flags & WINDOW_ACTIVITY) || wl->flags & WINLINK_ACTIVITY)
|
||||
if (~w->flags & WINDOW_ACTIVITY)
|
||||
return (0);
|
||||
if (s->curw == wl && !(s->flags & SESSION_UNATTACHED))
|
||||
if (!options_get_number(w->options, "monitor-activity"))
|
||||
return (0);
|
||||
|
||||
if (!options_get_number(&w->options, "monitor-activity"))
|
||||
return (0);
|
||||
TAILQ_FOREACH(wl, &w->winlinks, wentry)
|
||||
wl->session->flags &= ~SESSION_ALERTED;
|
||||
|
||||
if (options_get_number(&s->options, "bell-on-alert"))
|
||||
alerts_ring_bell(s);
|
||||
wl->flags |= WINLINK_ACTIVITY;
|
||||
|
||||
if (options_get_number(&s->options, "visual-activity")) {
|
||||
TAILQ_FOREACH(c, &clients, entry) {
|
||||
if (c->session != s)
|
||||
continue;
|
||||
status_message_set(c, "Activity in window %d", wl->idx);
|
||||
TAILQ_FOREACH(wl, &w->winlinks, wentry) {
|
||||
if (wl->flags & WINLINK_ACTIVITY)
|
||||
continue;
|
||||
s = wl->session;
|
||||
if (s->curw != wl) {
|
||||
wl->flags |= WINLINK_ACTIVITY;
|
||||
server_status_session(s);
|
||||
}
|
||||
if (!alerts_action_applies(wl, "activity-action"))
|
||||
continue;
|
||||
notify_winlink("alert-activity", wl);
|
||||
|
||||
if (s->flags & SESSION_ALERTED)
|
||||
continue;
|
||||
s->flags |= SESSION_ALERTED;
|
||||
|
||||
alerts_set_message(wl, "Activity", "visual-activity");
|
||||
}
|
||||
|
||||
return (WINDOW_ACTIVITY);
|
||||
}
|
||||
|
||||
int
|
||||
alerts_check_silence(struct session *s, struct winlink *wl)
|
||||
static int
|
||||
alerts_check_silence(struct window *w)
|
||||
{
|
||||
struct client *c;
|
||||
struct window *w = wl->window;
|
||||
struct winlink *wl;
|
||||
struct session *s;
|
||||
|
||||
if (s->curw->window == w)
|
||||
w->flags &= ~WINDOW_SILENCE;
|
||||
|
||||
if (!(w->flags & WINDOW_SILENCE) || wl->flags & WINLINK_SILENCE)
|
||||
if (~w->flags & WINDOW_SILENCE)
|
||||
return (0);
|
||||
if (s->curw == wl && !(s->flags & SESSION_UNATTACHED))
|
||||
if (options_get_number(w->options, "monitor-silence") == 0)
|
||||
return (0);
|
||||
|
||||
if (options_get_number(&w->options, "monitor-silence") == 0)
|
||||
return (0);
|
||||
TAILQ_FOREACH(wl, &w->winlinks, wentry)
|
||||
wl->session->flags &= ~SESSION_ALERTED;
|
||||
|
||||
if (options_get_number(&s->options, "bell-on-alert"))
|
||||
alerts_ring_bell(s);
|
||||
wl->flags |= WINLINK_SILENCE;
|
||||
|
||||
if (options_get_number(&s->options, "visual-silence")) {
|
||||
TAILQ_FOREACH(c, &clients, entry) {
|
||||
if (c->session != s)
|
||||
continue;
|
||||
status_message_set(c, "Silence in window %d", wl->idx);
|
||||
TAILQ_FOREACH(wl, &w->winlinks, wentry) {
|
||||
if (wl->flags & WINLINK_SILENCE)
|
||||
continue;
|
||||
s = wl->session;
|
||||
if (s->curw != wl) {
|
||||
wl->flags |= WINLINK_SILENCE;
|
||||
server_status_session(s);
|
||||
}
|
||||
if (!alerts_action_applies(wl, "silence-action"))
|
||||
continue;
|
||||
notify_winlink("alert-silence", wl);
|
||||
|
||||
if (s->flags & SESSION_ALERTED)
|
||||
continue;
|
||||
s->flags |= SESSION_ALERTED;
|
||||
|
||||
alerts_set_message(wl, "Silence", "visual-silence");
|
||||
}
|
||||
|
||||
return (WINDOW_SILENCE);
|
||||
}
|
||||
|
||||
void
|
||||
alerts_ring_bell(struct session *s)
|
||||
static void
|
||||
alerts_set_message(struct winlink *wl, const char *type, const char *option)
|
||||
{
|
||||
struct client *c;
|
||||
int visual;
|
||||
|
||||
/*
|
||||
* We have found an alert (bell, activity or silence), so we need to
|
||||
* pass it on to the user. For each client attached to this session,
|
||||
* decide whether a bell, message or both is needed.
|
||||
*
|
||||
* If visual-{bell,activity,silence} is on, then a message is
|
||||
* substituted for a bell; if it is off, a bell is sent as normal; both
|
||||
* mean both a bell and message is sent.
|
||||
*/
|
||||
|
||||
visual = options_get_number(wl->session->options, option);
|
||||
TAILQ_FOREACH(c, &clients, entry) {
|
||||
if (c->session == s && !(c->flags & CLIENT_CONTROL))
|
||||
if (c->session != wl->session || c->flags & CLIENT_CONTROL)
|
||||
continue;
|
||||
|
||||
if (visual == VISUAL_OFF || visual == VISUAL_BOTH)
|
||||
tty_putcode(&c->tty, TTYC_BEL);
|
||||
if (visual == VISUAL_OFF)
|
||||
continue;
|
||||
if (c->session->curw == wl)
|
||||
status_message_set(c, "%s in current window", type);
|
||||
else
|
||||
status_message_set(c, "%s in window %d", type, wl->idx);
|
||||
}
|
||||
}
|
||||
|
||||
274
arguments.c
274
arguments.c
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -28,49 +28,33 @@
|
||||
* Manipulate command arguments.
|
||||
*/
|
||||
|
||||
struct args_value {
|
||||
char *value;
|
||||
TAILQ_ENTRY(args_value) entry;
|
||||
};
|
||||
TAILQ_HEAD(args_values, args_value);
|
||||
|
||||
struct args_entry {
|
||||
u_char flag;
|
||||
char *value;
|
||||
struct args_values values;
|
||||
u_int count;
|
||||
RB_ENTRY(args_entry) entry;
|
||||
};
|
||||
|
||||
struct args_entry *args_find(struct args *, u_char);
|
||||
static struct args_entry *args_find(struct args *, u_char);
|
||||
|
||||
RB_GENERATE(args_tree, args_entry, entry, args_cmp);
|
||||
static int args_cmp(struct args_entry *, struct args_entry *);
|
||||
RB_GENERATE_STATIC(args_tree, args_entry, entry, args_cmp);
|
||||
|
||||
/* Arguments tree comparison function. */
|
||||
int
|
||||
static int
|
||||
args_cmp(struct args_entry *a1, struct args_entry *a2)
|
||||
{
|
||||
return (a1->flag - a2->flag);
|
||||
}
|
||||
|
||||
/* Create an arguments set with no flags. */
|
||||
struct args *
|
||||
args_create(int argc, ...)
|
||||
{
|
||||
struct args *args;
|
||||
va_list ap;
|
||||
int i;
|
||||
|
||||
args = xcalloc(1, sizeof *args);
|
||||
|
||||
args->argc = argc;
|
||||
if (argc == 0)
|
||||
args->argv = NULL;
|
||||
else
|
||||
args->argv = xcalloc(argc, sizeof *args->argv);
|
||||
|
||||
va_start(ap, argc);
|
||||
for (i = 0; i < argc; i++)
|
||||
args->argv[i] = xstrdup(va_arg(ap, char *));
|
||||
va_end(ap);
|
||||
|
||||
return (args);
|
||||
}
|
||||
|
||||
/* Find a flag in the arguments tree. */
|
||||
struct args_entry *
|
||||
static struct args_entry *
|
||||
args_find(struct args *args, u_char ch)
|
||||
{
|
||||
struct args_entry entry;
|
||||
@@ -115,116 +99,183 @@ args_free(struct args *args)
|
||||
{
|
||||
struct args_entry *entry;
|
||||
struct args_entry *entry1;
|
||||
struct args_value *value;
|
||||
struct args_value *value1;
|
||||
|
||||
cmd_free_argv(args->argc, args->argv);
|
||||
|
||||
RB_FOREACH_SAFE(entry, args_tree, &args->tree, entry1) {
|
||||
RB_REMOVE(args_tree, &args->tree, entry);
|
||||
free(entry->value);
|
||||
TAILQ_FOREACH_SAFE(value, &entry->values, entry, value1) {
|
||||
TAILQ_REMOVE(&entry->values, value, entry);
|
||||
free(value->value);
|
||||
free(value);
|
||||
}
|
||||
free(entry);
|
||||
}
|
||||
|
||||
free(args);
|
||||
}
|
||||
|
||||
/* Print a set of arguments. */
|
||||
size_t
|
||||
args_print(struct args *args, char *buf, size_t len)
|
||||
/* Add to string. */
|
||||
static void printflike(3, 4)
|
||||
args_print_add(char **buf, size_t *len, const char *fmt, ...)
|
||||
{
|
||||
size_t off, used;
|
||||
int i;
|
||||
const char *quotes;
|
||||
struct args_entry *entry;
|
||||
va_list ap;
|
||||
char *s;
|
||||
size_t slen;
|
||||
|
||||
/* There must be at least one byte at the start. */
|
||||
if (len == 0)
|
||||
return (0);
|
||||
off = 0;
|
||||
va_start(ap, fmt);
|
||||
slen = xvasprintf(&s, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
*len += slen;
|
||||
*buf = xrealloc(*buf, *len);
|
||||
|
||||
strlcat(*buf, s, *len);
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* Add value to string. */
|
||||
static void
|
||||
args_print_add_value(char **buf, size_t *len, struct args_entry *entry,
|
||||
struct args_value *value)
|
||||
{
|
||||
char *escaped;
|
||||
|
||||
if (**buf != '\0')
|
||||
args_print_add(buf, len, " -%c ", entry->flag);
|
||||
else
|
||||
args_print_add(buf, len, "-%c ", entry->flag);
|
||||
|
||||
escaped = args_escape(value->value);
|
||||
args_print_add(buf, len, "%s", escaped);
|
||||
free(escaped);
|
||||
}
|
||||
|
||||
/* Add argument to string. */
|
||||
static void
|
||||
args_print_add_argument(char **buf, size_t *len, const char *argument)
|
||||
{
|
||||
char *escaped;
|
||||
|
||||
if (**buf != '\0')
|
||||
args_print_add(buf, len, " ");
|
||||
|
||||
escaped = args_escape(argument);
|
||||
args_print_add(buf, len, "%s", escaped);
|
||||
free(escaped);
|
||||
}
|
||||
|
||||
/* Print a set of arguments. */
|
||||
char *
|
||||
args_print(struct args *args)
|
||||
{
|
||||
size_t len;
|
||||
char *buf;
|
||||
int i;
|
||||
u_int j;
|
||||
struct args_entry *entry;
|
||||
struct args_value *value;
|
||||
|
||||
len = 1;
|
||||
buf = xcalloc(1, len);
|
||||
|
||||
/* Process the flags first. */
|
||||
buf[off++] = '-';
|
||||
RB_FOREACH(entry, args_tree, &args->tree) {
|
||||
if (entry->value != NULL)
|
||||
if (!TAILQ_EMPTY(&entry->values))
|
||||
continue;
|
||||
|
||||
if (off == len - 1) {
|
||||
buf[off] = '\0';
|
||||
return (len);
|
||||
}
|
||||
buf[off++] = entry->flag;
|
||||
buf[off] = '\0';
|
||||
if (*buf == '\0')
|
||||
args_print_add(&buf, &len, "-");
|
||||
for (j = 0; j < entry->count; j++)
|
||||
args_print_add(&buf, &len, "%c", entry->flag);
|
||||
}
|
||||
if (off == 1)
|
||||
buf[--off] = '\0';
|
||||
|
||||
/* Then the flags with arguments. */
|
||||
RB_FOREACH(entry, args_tree, &args->tree) {
|
||||
if (entry->value == NULL)
|
||||
continue;
|
||||
|
||||
if (off >= len) {
|
||||
/* snprintf will have zero terminated. */
|
||||
return (len);
|
||||
}
|
||||
|
||||
if (strchr(entry->value, ' ') != NULL)
|
||||
quotes = "\"";
|
||||
else
|
||||
quotes = "";
|
||||
used = xsnprintf(buf + off, len - off, "%s-%c %s%s%s",
|
||||
off != 0 ? " " : "", entry->flag, quotes, entry->value,
|
||||
quotes);
|
||||
if (used > len - off)
|
||||
used = len - off;
|
||||
off += used;
|
||||
TAILQ_FOREACH(value, &entry->values, entry)
|
||||
args_print_add_value(&buf, &len, entry, value);
|
||||
}
|
||||
|
||||
/* And finally the argument vector. */
|
||||
for (i = 0; i < args->argc; i++) {
|
||||
if (off >= len) {
|
||||
/* snprintf will have zero terminated. */
|
||||
return (len);
|
||||
}
|
||||
for (i = 0; i < args->argc; i++)
|
||||
args_print_add_argument(&buf, &len, args->argv[i]);
|
||||
|
||||
if (strchr(args->argv[i], ' ') != NULL)
|
||||
quotes = "\"";
|
||||
else
|
||||
quotes = "";
|
||||
used = xsnprintf(buf + off, len - off, "%s%s%s%s",
|
||||
off != 0 ? " " : "", quotes, args->argv[i], quotes);
|
||||
if (used > len - off)
|
||||
used = len - off;
|
||||
off += used;
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/* Escape an argument. */
|
||||
char *
|
||||
args_escape(const char *s)
|
||||
{
|
||||
static const char quoted[] = " #\"';${}";
|
||||
char *escaped, *result;
|
||||
int flags;
|
||||
|
||||
if (*s == '\0')
|
||||
return (xstrdup(s));
|
||||
if (s[0] != ' ' &&
|
||||
(strchr(quoted, s[0]) != NULL || s[0] == '~') &&
|
||||
s[1] == '\0') {
|
||||
xasprintf(&escaped, "\\%c", s[0]);
|
||||
return (escaped);
|
||||
}
|
||||
|
||||
return (off);
|
||||
flags = VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL;
|
||||
if (s[strcspn(s, quoted)] != '\0')
|
||||
flags |= VIS_DQ;
|
||||
utf8_stravis(&escaped, s, flags);
|
||||
|
||||
if (flags & VIS_DQ) {
|
||||
if (*escaped == '~')
|
||||
xasprintf(&result, "\"\\%s\"", escaped);
|
||||
else
|
||||
xasprintf(&result, "\"%s\"", escaped);
|
||||
} else {
|
||||
if (*escaped == '~')
|
||||
xasprintf(&result, "\\%s", escaped);
|
||||
else
|
||||
result = xstrdup(escaped);
|
||||
}
|
||||
free(escaped);
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* Return if an argument is present. */
|
||||
int
|
||||
args_has(struct args *args, u_char ch)
|
||||
{
|
||||
return (args_find(args, ch) == NULL ? 0 : 1);
|
||||
struct args_entry *entry;
|
||||
|
||||
entry = args_find(args, ch);
|
||||
if (entry == NULL)
|
||||
return (0);
|
||||
return (entry->count);
|
||||
}
|
||||
|
||||
/* Set argument value in the arguments tree. */
|
||||
void
|
||||
args_set(struct args *args, u_char ch, const char *value)
|
||||
args_set(struct args *args, u_char ch, const char *s)
|
||||
{
|
||||
struct args_entry *entry;
|
||||
struct args_value *value;
|
||||
|
||||
/* Replace existing argument. */
|
||||
if ((entry = args_find(args, ch)) != NULL) {
|
||||
free(entry->value);
|
||||
entry->value = NULL;
|
||||
} else {
|
||||
entry = args_find(args, ch);
|
||||
if (entry == NULL) {
|
||||
entry = xcalloc(1, sizeof *entry);
|
||||
entry->flag = ch;
|
||||
entry->count = 1;
|
||||
TAILQ_INIT(&entry->values);
|
||||
RB_INSERT(args_tree, &args->tree, entry);
|
||||
}
|
||||
} else
|
||||
entry->count++;
|
||||
|
||||
if (value != NULL)
|
||||
entry->value = xstrdup(value);
|
||||
if (s != NULL) {
|
||||
value = xcalloc(1, sizeof *value);
|
||||
value->value = xstrdup(s);
|
||||
TAILQ_INSERT_TAIL(&entry->values, value, entry);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get argument value. Will be NULL if it isn't present. */
|
||||
@@ -235,7 +286,34 @@ args_get(struct args *args, u_char ch)
|
||||
|
||||
if ((entry = args_find(args, ch)) == NULL)
|
||||
return (NULL);
|
||||
return (entry->value);
|
||||
return (TAILQ_LAST(&entry->values, args_values)->value);
|
||||
}
|
||||
|
||||
/* Get first value in argument. */
|
||||
const char *
|
||||
args_first_value(struct args *args, u_char ch, struct args_value **value)
|
||||
{
|
||||
struct args_entry *entry;
|
||||
|
||||
if ((entry = args_find(args, ch)) == NULL)
|
||||
return (NULL);
|
||||
|
||||
*value = TAILQ_FIRST(&entry->values);
|
||||
if (*value == NULL)
|
||||
return (NULL);
|
||||
return ((*value)->value);
|
||||
}
|
||||
|
||||
/* Get next value in argument. */
|
||||
const char *
|
||||
args_next_value(struct args_value **value)
|
||||
{
|
||||
if (*value == NULL)
|
||||
return (NULL);
|
||||
*value = TAILQ_NEXT(*value, entry);
|
||||
if (*value == NULL)
|
||||
return (NULL);
|
||||
return ((*value)->value);
|
||||
}
|
||||
|
||||
/* Convert an argument value to a number. */
|
||||
@@ -246,13 +324,15 @@ args_strtonum(struct args *args, u_char ch, long long minval, long long maxval,
|
||||
const char *errstr;
|
||||
long long ll;
|
||||
struct args_entry *entry;
|
||||
struct args_value *value;
|
||||
|
||||
if ((entry = args_find(args, ch)) == NULL) {
|
||||
*cause = xstrdup("missing");
|
||||
return (0);
|
||||
}
|
||||
value = TAILQ_LAST(&entry->values, args_values);
|
||||
|
||||
ll = strtonum(entry->value, minval, maxval, &errstr);
|
||||
ll = strtonum(value->value, minval, maxval, &errstr);
|
||||
if (errstr != NULL) {
|
||||
*cause = xstrdup(errstr);
|
||||
return (0);
|
||||
|
||||
120
array.h
120
array.h
@@ -1,120 +0,0 @@
|
||||
/* $OpenBSD$ */
|
||||
|
||||
/*
|
||||
* 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, (a)->space); \
|
||||
} \
|
||||
while ((a)->space <= ((a)->num + (n)) * ARRAY_ITEMSIZE(a)) { \
|
||||
(a)->list = xreallocarray((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
|
||||
73
attributes.c
73
attributes.c
@@ -23,22 +23,28 @@
|
||||
#include "tmux.h"
|
||||
|
||||
const char *
|
||||
attributes_tostring(u_char attr)
|
||||
attributes_tostring(int attr)
|
||||
{
|
||||
static char buf[128];
|
||||
static char buf[512];
|
||||
size_t len;
|
||||
|
||||
if (attr == 0)
|
||||
return ("none");
|
||||
|
||||
len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s",
|
||||
attr & GRID_ATTR_BRIGHT ? "bright," : "",
|
||||
attr & GRID_ATTR_DIM ? "dim," : "",
|
||||
attr & GRID_ATTR_UNDERSCORE ? "underscore," : "",
|
||||
attr & GRID_ATTR_BLINK ? "blink," : "",
|
||||
attr & GRID_ATTR_REVERSE ? "reverse," : "",
|
||||
attr & GRID_ATTR_HIDDEN ? "hidden," : "",
|
||||
attr & GRID_ATTR_ITALICS ? "italics," : "");
|
||||
len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
||||
(attr & GRID_ATTR_BRIGHT) ? "bright," : "",
|
||||
(attr & GRID_ATTR_DIM) ? "dim," : "",
|
||||
(attr & GRID_ATTR_UNDERSCORE) ? "underscore," : "",
|
||||
(attr & GRID_ATTR_BLINK)? "blink," : "",
|
||||
(attr & GRID_ATTR_REVERSE) ? "reverse," : "",
|
||||
(attr & GRID_ATTR_HIDDEN) ? "hidden," : "",
|
||||
(attr & GRID_ATTR_ITALICS) ? "italics," : "",
|
||||
(attr & GRID_ATTR_STRIKETHROUGH) ? "strikethrough," : "",
|
||||
(attr & GRID_ATTR_UNDERSCORE_2) ? "double-underscore," : "",
|
||||
(attr & GRID_ATTR_UNDERSCORE_3) ? "curly-underscore," : "",
|
||||
(attr & GRID_ATTR_UNDERSCORE_4) ? "dotted-underscore," : "",
|
||||
(attr & GRID_ATTR_UNDERSCORE_5) ? "dashed-underscore," : "",
|
||||
(attr & GRID_ATTR_OVERLINE) ? "overline," : "");
|
||||
if (len > 0)
|
||||
buf[len - 1] = '\0';
|
||||
|
||||
@@ -49,8 +55,28 @@ int
|
||||
attributes_fromstring(const char *str)
|
||||
{
|
||||
const char delimiters[] = " ,|";
|
||||
u_char attr;
|
||||
int attr;
|
||||
size_t end;
|
||||
u_int i;
|
||||
struct {
|
||||
const char *name;
|
||||
int attr;
|
||||
} table[] = {
|
||||
{ "bright", GRID_ATTR_BRIGHT },
|
||||
{ "bold", GRID_ATTR_BRIGHT },
|
||||
{ "dim", GRID_ATTR_DIM },
|
||||
{ "underscore", GRID_ATTR_UNDERSCORE },
|
||||
{ "blink", GRID_ATTR_BLINK },
|
||||
{ "reverse", GRID_ATTR_REVERSE },
|
||||
{ "hidden", GRID_ATTR_HIDDEN },
|
||||
{ "italics", GRID_ATTR_ITALICS },
|
||||
{ "strikethrough", GRID_ATTR_STRIKETHROUGH },
|
||||
{ "double-underscore", GRID_ATTR_UNDERSCORE_2 },
|
||||
{ "curly-underscore", GRID_ATTR_UNDERSCORE_3 },
|
||||
{ "dotted-underscore", GRID_ATTR_UNDERSCORE_4 },
|
||||
{ "dashed-underscore", GRID_ATTR_UNDERSCORE_5 },
|
||||
{ "overline", GRID_ATTR_OVERLINE }
|
||||
};
|
||||
|
||||
if (*str == '\0' || strcspn(str, delimiters) == 0)
|
||||
return (-1);
|
||||
@@ -63,22 +89,15 @@ attributes_fromstring(const char *str)
|
||||
attr = 0;
|
||||
do {
|
||||
end = strcspn(str, delimiters);
|
||||
if ((end == 6 && strncasecmp(str, "bright", end) == 0) ||
|
||||
(end == 4 && strncasecmp(str, "bold", end) == 0))
|
||||
attr |= GRID_ATTR_BRIGHT;
|
||||
else if (end == 3 && strncasecmp(str, "dim", end) == 0)
|
||||
attr |= GRID_ATTR_DIM;
|
||||
else if (end == 10 && strncasecmp(str, "underscore", end) == 0)
|
||||
attr |= GRID_ATTR_UNDERSCORE;
|
||||
else if (end == 5 && strncasecmp(str, "blink", end) == 0)
|
||||
attr |= GRID_ATTR_BLINK;
|
||||
else if (end == 7 && strncasecmp(str, "reverse", end) == 0)
|
||||
attr |= GRID_ATTR_REVERSE;
|
||||
else if (end == 6 && strncasecmp(str, "hidden", end) == 0)
|
||||
attr |= GRID_ATTR_HIDDEN;
|
||||
else if (end == 7 && strncasecmp(str, "italics", end) == 0)
|
||||
attr |= GRID_ATTR_ITALICS;
|
||||
else
|
||||
for (i = 0; i < nitems(table); i++) {
|
||||
if (end != strlen(table[i].name))
|
||||
continue;
|
||||
if (strncasecmp(str, table[i].name, end) == 0) {
|
||||
attr |= table[i].attr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == nitems(table))
|
||||
return (-1);
|
||||
str += end + strspn(str + end, delimiters);
|
||||
} while (*str != '\0');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x$(uname)" = "xOpenBSD" ]; then
|
||||
[ -z "$AUTOMAKE_VERSION" ] && export AUTOMAKE_VERSION=1.10
|
||||
[ -z "$AUTOCONF_VERSION" ] && export AUTOCONF_VERSION=2.65
|
||||
[ -z "$AUTOMAKE_VERSION" ] && export AUTOMAKE_VERSION=1.15
|
||||
[ -z "$AUTOCONF_VERSION" ] && export AUTOCONF_VERSION=2.69
|
||||
fi
|
||||
|
||||
die()
|
||||
|
||||
289
cfg.c
289
cfg.c
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -23,19 +23,41 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
char *cfg_file;
|
||||
struct cmd_q *cfg_cmd_q;
|
||||
int cfg_finished;
|
||||
int cfg_references;
|
||||
char **cfg_causes;
|
||||
u_int cfg_ncauses;
|
||||
struct client *cfg_client;
|
||||
struct client *cfg_client;
|
||||
static char *cfg_file;
|
||||
int cfg_finished;
|
||||
static char **cfg_causes;
|
||||
static u_int cfg_ncauses;
|
||||
static struct cmdq_item *cfg_item;
|
||||
|
||||
void cfg_default_done(struct cmd_q *);
|
||||
static enum cmd_retval
|
||||
cfg_client_done(__unused struct cmdq_item *item, __unused void *data)
|
||||
{
|
||||
if (!cfg_finished)
|
||||
return (CMD_RETURN_WAIT);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
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_item != NULL)
|
||||
cmdq_continue(cfg_item);
|
||||
|
||||
status_prompt_load_history();
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
void
|
||||
set_cfg_file(const char *path)
|
||||
@@ -44,119 +66,178 @@ set_cfg_file(const char *path)
|
||||
cfg_file = xstrdup(path);
|
||||
}
|
||||
|
||||
static char *
|
||||
expand_cfg_file(const char *path, const char *home)
|
||||
{
|
||||
char *expanded, *name;
|
||||
const char *end;
|
||||
struct environ_entry *value;
|
||||
|
||||
if (strncmp(path, "~/", 2) == 0) {
|
||||
if (home == NULL)
|
||||
return (NULL);
|
||||
xasprintf(&expanded, "%s%s", home, path + 1);
|
||||
return (expanded);
|
||||
}
|
||||
|
||||
if (*path == '$') {
|
||||
end = strchr(path, '/');
|
||||
if (end == NULL)
|
||||
name = xstrdup(path + 1);
|
||||
else
|
||||
name = xstrndup(path + 1, end - path - 1);
|
||||
value = environ_find(global_environ, name);
|
||||
free(name);
|
||||
if (value == NULL)
|
||||
return (NULL);
|
||||
if (end == NULL)
|
||||
end = "";
|
||||
xasprintf(&expanded, "%s%s", value->value, end);
|
||||
return (expanded);
|
||||
}
|
||||
|
||||
return (xstrdup(path));
|
||||
}
|
||||
|
||||
void
|
||||
start_cfg(void)
|
||||
{
|
||||
char *cause = NULL;
|
||||
const char *home;
|
||||
const char *home = find_home();
|
||||
struct client *c;
|
||||
char *path, *copy, *next, *expanded;
|
||||
|
||||
cfg_cmd_q = cmdq_new(NULL);
|
||||
cfg_cmd_q->emptyfn = cfg_default_done;
|
||||
|
||||
cfg_finished = 0;
|
||||
cfg_references = 1;
|
||||
|
||||
cfg_client = TAILQ_FIRST(&clients);
|
||||
if (cfg_client != NULL)
|
||||
cfg_client->references++;
|
||||
|
||||
if (access(TMUX_CONF, R_OK) == 0) {
|
||||
if (load_cfg(TMUX_CONF, cfg_cmd_q, &cause) == -1)
|
||||
cfg_add_cause("%s: %s", TMUX_CONF, cause);
|
||||
} else if (errno != ENOENT)
|
||||
cfg_add_cause("%s: %s", TMUX_CONF, strerror(errno));
|
||||
|
||||
if (cfg_file == NULL && (home = find_home()) != NULL) {
|
||||
xasprintf(&cfg_file, "%s/.tmux.conf", home);
|
||||
if (access(cfg_file, R_OK) != 0 && errno == ENOENT) {
|
||||
free(cfg_file);
|
||||
cfg_file = NULL;
|
||||
}
|
||||
/*
|
||||
* Configuration files are loaded without a client, so commands are run
|
||||
* in the global queue with item->client NULL.
|
||||
*
|
||||
* However, we must block the initial client (but just the initial
|
||||
* client) so that its command runs after the configuration is loaded.
|
||||
* Because start_cfg() is called so early, we can be sure the client's
|
||||
* command queue is currently empty and our callback will be at the
|
||||
* front - we need to get in before MSG_COMMAND.
|
||||
*/
|
||||
cfg_client = c = TAILQ_FIRST(&clients);
|
||||
if (c != NULL) {
|
||||
cfg_item = cmdq_get_callback(cfg_client_done, NULL);
|
||||
cmdq_append(c, cfg_item);
|
||||
}
|
||||
if (cfg_file != NULL && load_cfg(cfg_file, cfg_cmd_q, &cause) == -1)
|
||||
cfg_add_cause("%s: %s", cfg_file, cause);
|
||||
free(cause);
|
||||
|
||||
cmdq_continue(cfg_cmd_q);
|
||||
if (cfg_file == NULL) {
|
||||
path = copy = xstrdup(TMUX_CONF);
|
||||
while ((next = strsep(&path, ":")) != NULL) {
|
||||
expanded = expand_cfg_file(next, home);
|
||||
if (expanded == NULL) {
|
||||
log_debug("couldn't expand %s", next);
|
||||
continue;
|
||||
}
|
||||
log_debug("expanded %s to %s", next, expanded);
|
||||
load_cfg(expanded, c, NULL, CMD_PARSE_QUIET, NULL);
|
||||
free(expanded);
|
||||
}
|
||||
free(copy);
|
||||
} else
|
||||
load_cfg(cfg_file, c, NULL, 0, NULL);
|
||||
|
||||
cmdq_append(NULL, cmdq_get_callback(cfg_done, NULL));
|
||||
}
|
||||
|
||||
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 flags,
|
||||
struct cmdq_item **new_item)
|
||||
{
|
||||
FILE *f;
|
||||
char delim[3] = { '\\', '\\', '\0' };
|
||||
u_int found;
|
||||
size_t line = 0;
|
||||
char *buf, *cause1, *p;
|
||||
struct cmd_list *cmdlist;
|
||||
FILE *f;
|
||||
struct cmd_parse_input pi;
|
||||
struct cmd_parse_result *pr;
|
||||
struct cmdq_item *new_item0;
|
||||
|
||||
if (new_item != NULL)
|
||||
*new_item = NULL;
|
||||
|
||||
log_debug("loading %s", path);
|
||||
if ((f = fopen(path, "rb")) == NULL) {
|
||||
xasprintf(cause, "%s: %s", path, strerror(errno));
|
||||
if (errno == ENOENT && (flags & CMD_PARSE_QUIET))
|
||||
return (0);
|
||||
cfg_add_cause("%s: %s", path, strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
found = 0;
|
||||
while ((buf = fparseln(f, NULL, &line, delim, 0)) != NULL) {
|
||||
log_debug("%s: %s", path, buf);
|
||||
memset(&pi, 0, sizeof pi);
|
||||
pi.flags = flags;
|
||||
pi.file = path;
|
||||
pi.line = 1;
|
||||
pi.item = item;
|
||||
pi.c = c;
|
||||
|
||||
/* Skip empty lines. */
|
||||
p = buf;
|
||||
while (isspace((u_char) *p))
|
||||
p++;
|
||||
if (*p == '\0') {
|
||||
free(buf);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Parse and run the command. */
|
||||
if (cmd_string_parse(p, &cmdlist, path, line, &cause1) != 0) {
|
||||
free(buf);
|
||||
if (cause1 == NULL)
|
||||
continue;
|
||||
cfg_add_cause("%s:%zu: %s", path, line, cause1);
|
||||
free(cause1);
|
||||
continue;
|
||||
}
|
||||
free(buf);
|
||||
|
||||
if (cmdlist == NULL)
|
||||
continue;
|
||||
cmdq_append(cmdq, cmdlist, NULL);
|
||||
cmd_list_free(cmdlist);
|
||||
found++;
|
||||
}
|
||||
pr = cmd_parse_from_file(f, &pi);
|
||||
fclose(f);
|
||||
if (pr->status == CMD_PARSE_EMPTY)
|
||||
return (0);
|
||||
if (pr->status == CMD_PARSE_ERROR) {
|
||||
cfg_add_cause("%s", pr->error);
|
||||
free(pr->error);
|
||||
return (-1);
|
||||
}
|
||||
if (flags & CMD_PARSE_PARSEONLY) {
|
||||
cmd_list_free(pr->cmdlist);
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (found);
|
||||
new_item0 = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);
|
||||
if (item != NULL)
|
||||
new_item0 = cmdq_insert_after(item, new_item0);
|
||||
else
|
||||
new_item0 = cmdq_append(NULL, new_item0);
|
||||
cmd_list_free(pr->cmdlist);
|
||||
|
||||
if (new_item != NULL)
|
||||
*new_item = new_item0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
cfg_default_done(unused struct cmd_q *cmdq)
|
||||
int
|
||||
load_cfg_from_buffer(const void *buf, size_t len, const char *path,
|
||||
struct client *c, struct cmdq_item *item, int flags,
|
||||
struct cmdq_item **new_item)
|
||||
{
|
||||
if (--cfg_references != 0)
|
||||
return;
|
||||
cfg_finished = 1;
|
||||
struct cmd_parse_input pi;
|
||||
struct cmd_parse_result *pr;
|
||||
struct cmdq_item *new_item0;
|
||||
|
||||
if (!RB_EMPTY(&sessions))
|
||||
cfg_show_causes(RB_MIN(sessions, &sessions));
|
||||
if (new_item != NULL)
|
||||
*new_item = NULL;
|
||||
|
||||
cmdq_free(cfg_cmd_q);
|
||||
cfg_cmd_q = NULL;
|
||||
log_debug("loading %s", path);
|
||||
|
||||
if (cfg_client != NULL) {
|
||||
/*
|
||||
* The client command queue starts with client_exit set to 1 so
|
||||
* only continue if not empty (that is, we have been delayed
|
||||
* during configuration parsing for long enough that the
|
||||
* MSG_COMMAND has arrived), else the client will exit before
|
||||
* the MSG_COMMAND which might tell it not to.
|
||||
*/
|
||||
if (!TAILQ_EMPTY(&cfg_client->cmdq->queue))
|
||||
cmdq_continue(cfg_client->cmdq);
|
||||
server_client_unref(cfg_client);
|
||||
cfg_client = NULL;
|
||||
memset(&pi, 0, sizeof pi);
|
||||
pi.flags = flags;
|
||||
pi.file = path;
|
||||
pi.line = 1;
|
||||
pi.item = item;
|
||||
pi.c = c;
|
||||
|
||||
pr = cmd_parse_from_buffer(buf, len, &pi);
|
||||
if (pr->status == CMD_PARSE_EMPTY)
|
||||
return (0);
|
||||
if (pr->status == CMD_PARSE_ERROR) {
|
||||
cfg_add_cause("%s", pr->error);
|
||||
free(pr->error);
|
||||
return (-1);
|
||||
}
|
||||
if (flags & CMD_PARSE_PARSEONLY) {
|
||||
cmd_list_free(pr->cmdlist);
|
||||
return (0);
|
||||
}
|
||||
|
||||
new_item0 = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);
|
||||
if (item != NULL)
|
||||
new_item0 = cmdq_insert_after(item, new_item0);
|
||||
else
|
||||
new_item0 = cmdq_append(NULL, new_item0);
|
||||
cmd_list_free(pr->cmdlist);
|
||||
|
||||
if (new_item != NULL)
|
||||
*new_item = new_item0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -175,12 +256,12 @@ cfg_add_cause(const char *fmt, ...)
|
||||
}
|
||||
|
||||
void
|
||||
cfg_print_causes(struct cmd_q *cmdq)
|
||||
cfg_print_causes(struct cmdq_item *item)
|
||||
{
|
||||
u_int i;
|
||||
|
||||
for (i = 0; i < cfg_ncauses; i++) {
|
||||
cmdq_print(cmdq, "%s", cfg_causes[i]);
|
||||
cmdq_print(item, "%s", cfg_causes[i]);
|
||||
free(cfg_causes[i]);
|
||||
}
|
||||
|
||||
@@ -192,15 +273,17 @@ cfg_print_causes(struct cmd_q *cmdq)
|
||||
void
|
||||
cfg_show_causes(struct session *s)
|
||||
{
|
||||
struct window_pane *wp;
|
||||
u_int i;
|
||||
struct window_pane *wp;
|
||||
struct window_mode_entry *wme;
|
||||
u_int i;
|
||||
|
||||
if (s == NULL || cfg_ncauses == 0)
|
||||
return;
|
||||
wp = s->curw->window->active;
|
||||
|
||||
window_pane_set_mode(wp, &window_copy_mode);
|
||||
window_copy_init_for_output(wp);
|
||||
wme = TAILQ_FIRST(&wp->modes);
|
||||
if (wme == NULL || wme->mode != &window_view_mode)
|
||||
window_pane_set_mode(wp, &window_view_mode, NULL, NULL);
|
||||
for (i = 0; i < cfg_ncauses; i++) {
|
||||
window_copy_add(wp, "%s", cfg_causes[i]);
|
||||
free(cfg_causes[i]);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -30,159 +30,156 @@
|
||||
* 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 = {
|
||||
"attach-session", "attach",
|
||||
"c:dErt:", 0, 0,
|
||||
"[-dEr] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
|
||||
CMD_STARTSERVER,
|
||||
cmd_attach_session_exec
|
||||
.name = "attach-session",
|
||||
.alias = "attach",
|
||||
|
||||
.args = { "c:dErt:x", 0, 0 },
|
||||
.usage = "[-dErx] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
/* -t is special */
|
||||
|
||||
.flags = CMD_STARTSERVER,
|
||||
.exec = cmd_attach_session_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
|
||||
const char *cflag, int Eflag)
|
||||
cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
||||
int xflag, int rflag, const char *cflag, int Eflag)
|
||||
{
|
||||
struct cmd_find_state *current = &item->shared->current;
|
||||
enum cmd_find_type type;
|
||||
int flags;
|
||||
struct client *c = item->client, *c_loop;
|
||||
struct session *s;
|
||||
struct client *c = cmdq->client, *c_loop;
|
||||
struct winlink *wl = NULL;
|
||||
struct window *w = NULL;
|
||||
struct window_pane *wp = NULL;
|
||||
const char *update;
|
||||
struct winlink *wl;
|
||||
struct window_pane *wp;
|
||||
char *cause;
|
||||
int fd;
|
||||
struct format_tree *ft;
|
||||
char *cp;
|
||||
enum msgtype msgtype;
|
||||
|
||||
if (RB_EMPTY(&sessions)) {
|
||||
cmdq_error(cmdq, "no sessions");
|
||||
cmdq_error(item, "no sessions");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
if (tflag == NULL) {
|
||||
if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
} else if (tflag[strcspn(tflag, ":.")] != '\0') {
|
||||
if ((wl = cmd_find_pane(cmdq, tflag, &s, &wp)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
} else {
|
||||
if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
w = window_find_by_id_str(tflag);
|
||||
if (w == NULL) {
|
||||
wp = window_pane_find_by_id_str(tflag);
|
||||
if (wp != NULL)
|
||||
w = wp->window;
|
||||
}
|
||||
if (w != NULL)
|
||||
wl = winlink_find_by_window(&s->windows, w);
|
||||
}
|
||||
|
||||
if (c == NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
if (server_client_check_nested(c)) {
|
||||
cmdq_error(cmdq, "sessions should be nested with care, "
|
||||
cmdq_error(item, "sessions should be nested with care, "
|
||||
"unset $TMUX to force");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
if (tflag != NULL && tflag[strcspn(tflag, ":.")] != '\0') {
|
||||
type = CMD_FIND_PANE;
|
||||
flags = 0;
|
||||
} else {
|
||||
type = CMD_FIND_SESSION;
|
||||
flags = CMD_FIND_PREFER_UNATTACHED;
|
||||
}
|
||||
if (cmd_find_target(&item->target, item, tflag, type, flags) != 0)
|
||||
return (CMD_RETURN_ERROR);
|
||||
s = item->target.s;
|
||||
wl = item->target.wl;
|
||||
wp = item->target.wp;
|
||||
|
||||
if (wl != NULL) {
|
||||
if (wp != NULL)
|
||||
window_set_active_pane(wp->window, wp);
|
||||
window_set_active_pane(wp->window, wp, 1);
|
||||
session_set_current(s, wl);
|
||||
if (wp != NULL)
|
||||
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||
else
|
||||
cmd_find_from_winlink(current, wl, 0);
|
||||
}
|
||||
|
||||
if (cflag != NULL) {
|
||||
ft = format_create();
|
||||
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s,
|
||||
NULL, NULL);
|
||||
cp = format_expand(ft, cflag);
|
||||
format_free(ft);
|
||||
|
||||
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
||||
free(cp);
|
||||
if (fd == -1) {
|
||||
cmdq_error(cmdq, "bad working directory: %s",
|
||||
strerror(errno));
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
close(s->cwd);
|
||||
s->cwd = fd;
|
||||
free((void *)s->cwd);
|
||||
s->cwd = format_single(item, cflag, c, s, wl, wp);
|
||||
}
|
||||
|
||||
c->last_session = c->session;
|
||||
if (c->session != NULL) {
|
||||
if (dflag) {
|
||||
/*
|
||||
* Can't use server_write_session in case attaching to
|
||||
* the same session as currently attached to.
|
||||
*/
|
||||
if (dflag || xflag) {
|
||||
if (xflag)
|
||||
msgtype = MSG_DETACHKILL;
|
||||
else
|
||||
msgtype = MSG_DETACH;
|
||||
TAILQ_FOREACH(c_loop, &clients, entry) {
|
||||
if (c_loop->session != s || c == c_loop)
|
||||
continue;
|
||||
server_write_client(c, MSG_DETACH,
|
||||
c_loop->session->name,
|
||||
strlen(c_loop->session->name) + 1);
|
||||
server_client_detach(c_loop, msgtype);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Eflag) {
|
||||
update = options_get_string(&s->options,
|
||||
"update-environment");
|
||||
environ_update(update, &c->environ, &s->environ);
|
||||
}
|
||||
if (!Eflag)
|
||||
environ_update(s->options, c->environ, s->environ);
|
||||
|
||||
c->session = s;
|
||||
if (~item->shared->flags & CMDQ_SHARED_REPEAT)
|
||||
server_client_set_key_table(c, NULL);
|
||||
tty_update_client_offset(c);
|
||||
status_timer_start(c);
|
||||
notify_attached_session_changed(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->window->latest = c;
|
||||
} else {
|
||||
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);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
if (rflag)
|
||||
c->flags |= CLIENT_READONLY;
|
||||
|
||||
if (dflag) {
|
||||
server_write_session(s, MSG_DETACH, s->name,
|
||||
strlen(s->name) + 1);
|
||||
}
|
||||
|
||||
if (!Eflag) {
|
||||
update = options_get_string(&s->options,
|
||||
"update-environment");
|
||||
environ_update(update, &c->environ, &s->environ);
|
||||
if (dflag || xflag) {
|
||||
if (xflag)
|
||||
msgtype = MSG_DETACHKILL;
|
||||
else
|
||||
msgtype = MSG_DETACH;
|
||||
TAILQ_FOREACH(c_loop, &clients, entry) {
|
||||
if (c_loop->session != s || c == c_loop)
|
||||
continue;
|
||||
server_client_detach(c_loop, msgtype);
|
||||
}
|
||||
}
|
||||
if (!Eflag)
|
||||
environ_update(s->options, c->environ, s->environ);
|
||||
|
||||
c->session = s;
|
||||
server_client_set_key_table(c, NULL);
|
||||
tty_update_client_offset(c);
|
||||
status_timer_start(c);
|
||||
notify_attached_session_changed(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->window->latest = c;
|
||||
|
||||
server_write_ready(c);
|
||||
cmdq->client_exit = 0;
|
||||
if (~c->flags & CLIENT_CONTROL)
|
||||
proc_send(c->peer, MSG_READY, -1, NULL, 0);
|
||||
notify_client("client-attached", c);
|
||||
c->flags |= CLIENT_ATTACHED;
|
||||
}
|
||||
recalculate_sizes();
|
||||
alerts_check_session(s);
|
||||
server_update_socket();
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_attach_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
|
||||
return (cmd_attach_session(cmdq, args_get(args, 't'),
|
||||
args_has(args, 'd'), args_has(args, 'r'), args_get(args, 'c'),
|
||||
args_has(args, 'E')));
|
||||
return (cmd_attach_session(item, args_get(args, 't'),
|
||||
args_has(args, 'd'), args_has(args, 'x'), args_has(args, 'r'),
|
||||
args_get(args, 'c'), args_has(args, 'E')));
|
||||
}
|
||||
|
||||
146
cmd-bind-key.c
146
cmd-bind-key.c
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -24,131 +24,63 @@
|
||||
#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_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
enum cmd_retval cmd_bind_key_mode_table(struct cmd *, struct cmd_q *, int);
|
||||
static enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_bind_key_entry = {
|
||||
"bind-key", "bind",
|
||||
"cnrt:T:", 1, -1,
|
||||
"[-cnr] [-t mode-table] [-T key-table] key command [arguments]",
|
||||
0,
|
||||
cmd_bind_key_exec
|
||||
.name = "bind-key",
|
||||
.alias = "bind",
|
||||
|
||||
.args = { "nrN:T:", 2, -1 },
|
||||
.usage = "[-nr] [-T key-table] [-N note] key "
|
||||
"command [arguments]",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_bind_key_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
char *cause;
|
||||
struct cmd_list *cmdlist;
|
||||
int key;
|
||||
const char *tablename;
|
||||
struct args *args = self->args;
|
||||
key_code key;
|
||||
const char *tablename, *note;
|
||||
struct cmd_parse_result *pr;
|
||||
char **argv = args->argv;
|
||||
int argc = args->argc, repeat;
|
||||
|
||||
if (args_has(args, 't')) {
|
||||
if (args->argc != 2 && args->argc != 3) {
|
||||
cmdq_error(cmdq, "not enough arguments");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else {
|
||||
if (args->argc < 2) {
|
||||
cmdq_error(cmdq, "not enough arguments");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
key = key_string_lookup_string(args->argv[0]);
|
||||
if (key == KEYC_NONE) {
|
||||
cmdq_error(cmdq, "unknown key: %s", args->argv[0]);
|
||||
key = key_string_lookup_string(argv[0]);
|
||||
if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
|
||||
cmdq_error(item, "unknown key: %s", argv[0]);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
if (args_has(args, 't'))
|
||||
return (cmd_bind_key_mode_table(self, cmdq, key));
|
||||
|
||||
if (args_has(args, 'T'))
|
||||
tablename = args_get(args, 'T');
|
||||
else if (args_has(args, 'n'))
|
||||
tablename = "root";
|
||||
else
|
||||
tablename = "prefix";
|
||||
repeat = args_has(args, 'r');
|
||||
|
||||
cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, NULL, 0,
|
||||
&cause);
|
||||
if (cmdlist == NULL) {
|
||||
cmdq_error(cmdq, "%s", cause);
|
||||
free(cause);
|
||||
if (argc == 2)
|
||||
pr = cmd_parse_from_string(argv[1], NULL);
|
||||
else
|
||||
pr = cmd_parse_from_arguments(argc - 1, argv + 1, NULL);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
cmdq_error(item, "empty command");
|
||||
return (CMD_RETURN_ERROR);
|
||||
case CMD_PARSE_ERROR:
|
||||
cmdq_error(item, "%s", pr->error);
|
||||
free(pr->error);
|
||||
return (CMD_RETURN_ERROR);
|
||||
case CMD_PARSE_SUCCESS:
|
||||
break;
|
||||
}
|
||||
|
||||
key_bindings_add(tablename, key, args_has(args, 'r'), cmdlist);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_bind_key_mode_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);
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case MODEKEYCOPY_APPENDSELECTION:
|
||||
case MODEKEYCOPY_COPYSELECTION:
|
||||
case MODEKEYCOPY_STARTNAMEDBUFFER:
|
||||
if (args->argc == 2)
|
||||
arg = NULL;
|
||||
else {
|
||||
arg = args->argv[2];
|
||||
if (strcmp(arg, "-x") != 0) {
|
||||
cmdq_error(cmdq, "unknown argument");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MODEKEYCOPY_COPYPIPE:
|
||||
if (args->argc != 3) {
|
||||
cmdq_error(cmdq, "no argument given");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
arg = args->argv[2];
|
||||
break;
|
||||
default:
|
||||
if (args->argc != 2) {
|
||||
cmdq_error(cmdq, "no argument allowed");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
arg = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
note = args_get(args, 'N');
|
||||
key_bindings_add(tablename, key, note, repeat, pr->cmdlist);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -28,45 +28,46 @@
|
||||
|
||||
#define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||
|
||||
enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_break_pane_entry = {
|
||||
"break-pane", "breakp",
|
||||
"dPF:s:t:", 0, 0,
|
||||
"[-dP] [-F format] " CMD_SRCDST_PANE_USAGE,
|
||||
0,
|
||||
cmd_break_pane_exec
|
||||
.name = "break-pane",
|
||||
.alias = "breakp",
|
||||
|
||||
.args = { "dPF:n:s:t:", 0, 0 },
|
||||
.usage = "[-dP] [-F format] [-n window-name] [-s src-pane] "
|
||||
"[-t dst-window]",
|
||||
|
||||
.source = { 's', CMD_FIND_PANE, 0 },
|
||||
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_break_pane_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl;
|
||||
struct session *src_s;
|
||||
struct session *dst_s;
|
||||
struct window_pane *wp;
|
||||
struct window *w;
|
||||
char *name;
|
||||
char *cause;
|
||||
int idx;
|
||||
struct format_tree *ft;
|
||||
struct cmd_find_state *current = &item->shared->current;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct winlink *wl = item->source.wl;
|
||||
struct session *src_s = item->source.s;
|
||||
struct session *dst_s = item->target.s;
|
||||
struct window_pane *wp = item->source.wp;
|
||||
struct window *w = wl->window;
|
||||
char *name, *cause;
|
||||
int idx = item->target.idx;
|
||||
const char *template;
|
||||
char *cp;
|
||||
|
||||
wl = cmd_find_pane(cmdq, args_get(args, 's'), &src_s, &wp);
|
||||
if (wl == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
if ((idx = cmd_find_index(cmdq, args_get(args, 't'), &dst_s)) == -2)
|
||||
return (CMD_RETURN_ERROR);
|
||||
if (idx != -1 && winlink_find_by_index(&dst_s->windows, idx) != NULL) {
|
||||
cmdq_error(cmdq, "index %d already in use", idx);
|
||||
cmdq_error(item, "index %d already in use", idx);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
w = wl->window;
|
||||
|
||||
if (window_count_panes(w) == 1) {
|
||||
cmdq_error(cmdq, "can't break with only one pane");
|
||||
cmdq_error(item, "can't break with only one pane");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
server_unzoom_window(w);
|
||||
@@ -75,19 +76,32 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
window_lost_pane(w, wp);
|
||||
layout_close_pane(wp);
|
||||
|
||||
w = wp->window = window_create1(dst_s->sx, dst_s->sy);
|
||||
w = wp->window = window_create(w->sx, w->sy, w->xpixel, w->ypixel);
|
||||
options_set_parent(wp->options, w->options);
|
||||
wp->flags |= PANE_STYLECHANGED;
|
||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||
w->active = wp;
|
||||
name = default_window_name(w);
|
||||
window_set_name(w, name);
|
||||
free(name);
|
||||
w->latest = c;
|
||||
|
||||
if (!args_has(args, 'n')) {
|
||||
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);
|
||||
wp->flags |= PANE_CHANGED;
|
||||
|
||||
if (idx == -1)
|
||||
idx = -1 - options_get_number(&dst_s->options, "base-index");
|
||||
idx = -1 - options_get_number(dst_s->options, "base-index");
|
||||
wl = session_attach(dst_s, w, idx, &cause); /* can't fail */
|
||||
if (!args_has(self->args, 'd'))
|
||||
if (!args_has(self->args, 'd')) {
|
||||
session_select(dst_s, wl->idx);
|
||||
cmd_find_from_session(current, dst_s, 0);
|
||||
}
|
||||
|
||||
server_redraw_session(src_s);
|
||||
if (src_s != dst_s)
|
||||
@@ -99,16 +113,9 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
if (args_has(args, 'P')) {
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = BREAK_PANE_TEMPLATE;
|
||||
|
||||
ft = format_create();
|
||||
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), dst_s, wl,
|
||||
wp);
|
||||
|
||||
cp = format_expand(ft, template);
|
||||
cmdq_print(cmdq, "%s", cp);
|
||||
cp = format_single(item, template, c, dst_s, wl, wp);
|
||||
cmdq_print(item, "%s", cp);
|
||||
free(cp);
|
||||
|
||||
format_free(ft);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -27,24 +27,42 @@
|
||||
* 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);
|
||||
char *cmd_capture_pane_pending(struct args *, struct window_pane *,
|
||||
static char *cmd_capture_pane_append(char *, size_t *, char *, size_t);
|
||||
static char *cmd_capture_pane_pending(struct args *, struct window_pane *,
|
||||
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 *);
|
||||
|
||||
const struct cmd_entry cmd_capture_pane_entry = {
|
||||
"capture-pane", "capturep",
|
||||
"ab:CeE:JpPqS:t:", 0, 0,
|
||||
"[-aCeJpPq] " CMD_BUFFER_USAGE " [-E end-line] [-S start-line]"
|
||||
CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
cmd_capture_pane_exec
|
||||
.name = "capture-pane",
|
||||
.alias = "capturep",
|
||||
|
||||
.args = { "ab:CeE:JNpPqS:t:", 0, 0 },
|
||||
.usage = "[-aCeJNpPq] " CMD_BUFFER_USAGE " [-E end-line] "
|
||||
"[-S start-line] " CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.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,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_capture_pane_exec
|
||||
};
|
||||
|
||||
static char *
|
||||
cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen)
|
||||
{
|
||||
buf = xrealloc(buf, *len + linelen + 1);
|
||||
@@ -53,7 +71,7 @@ cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen)
|
||||
return (buf);
|
||||
}
|
||||
|
||||
char *
|
||||
static char *
|
||||
cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
||||
size_t *len)
|
||||
{
|
||||
@@ -72,7 +90,7 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
||||
buf = xstrdup("");
|
||||
if (args_has(args, 'C')) {
|
||||
for (i = 0; i < linelen; i++) {
|
||||
if (line[i] >= ' ') {
|
||||
if (line[i] >= ' ' && line[i] != '\\') {
|
||||
tmp[0] = line[i];
|
||||
tmp[1] = '\0';
|
||||
} else
|
||||
@@ -85,14 +103,14 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
||||
return (buf);
|
||||
}
|
||||
|
||||
char *
|
||||
cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
|
||||
static char *
|
||||
cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
||||
struct window_pane *wp, size_t *len)
|
||||
{
|
||||
struct grid *gd;
|
||||
const struct grid_line *gl;
|
||||
struct grid_cell *gc = NULL;
|
||||
int n, with_codes, escape_c0, join_lines;
|
||||
int n, with_codes, escape_c0, join_lines, no_trim;
|
||||
u_int i, sx, top, bottom, tmp;
|
||||
char *cause, *buf, *line;
|
||||
const char *Sflag, *Eflag;
|
||||
@@ -103,7 +121,7 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
|
||||
gd = wp->saved_grid;
|
||||
if (gd == NULL) {
|
||||
if (!args_has(args, 'q')) {
|
||||
cmdq_error(cmdq, "no alternate screen");
|
||||
cmdq_error(item, "no alternate screen");
|
||||
return (NULL);
|
||||
}
|
||||
return (xstrdup(""));
|
||||
@@ -152,11 +170,12 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
|
||||
with_codes = args_has(args, 'e');
|
||||
escape_c0 = args_has(args, 'C');
|
||||
join_lines = args_has(args, 'J');
|
||||
no_trim = args_has(args, 'N');
|
||||
|
||||
buf = NULL;
|
||||
for (i = top; i <= bottom; i++) {
|
||||
line = grid_string_cells(gd, 0, i, sx, &gc, with_codes,
|
||||
escape_c0, !join_lines);
|
||||
escape_c0, !join_lines && !no_trim);
|
||||
linelen = strlen(line);
|
||||
|
||||
buf = cmd_capture_pane_append(buf, len, line, linelen);
|
||||
@@ -170,47 +189,47 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
|
||||
return (buf);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
struct window_pane *wp;
|
||||
struct client *c = item->client;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
char *buf, *cause;
|
||||
const char *bufname;
|
||||
size_t len;
|
||||
|
||||
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
if (self->entry == &cmd_clear_history_entry) {
|
||||
window_pane_reset_mode_all(wp);
|
||||
grid_clear_history(wp->base.grid);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
len = 0;
|
||||
if (args_has(args, 'P'))
|
||||
buf = cmd_capture_pane_pending(args, wp, &len);
|
||||
else
|
||||
buf = cmd_capture_pane_history(args, cmdq, wp, &len);
|
||||
buf = cmd_capture_pane_history(args, item, wp, &len);
|
||||
if (buf == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
if (args_has(args, 'p')) {
|
||||
c = cmdq->client;
|
||||
if (c == NULL ||
|
||||
(c->session != NULL && !(c->flags & CLIENT_CONTROL))) {
|
||||
cmdq_error(cmdq, "can't write to stdout");
|
||||
if (!file_can_print(c)) {
|
||||
cmdq_error(item, "can't write output to client");
|
||||
free(buf);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
evbuffer_add(c->stdout_data, buf, len);
|
||||
free(buf);
|
||||
file_print_buffer(c, buf, len);
|
||||
if (args_has(args, 'P') && len > 0)
|
||||
evbuffer_add(c->stdout_data, "\n", 1);
|
||||
server_push_stdout(c);
|
||||
file_print(c, "\n");
|
||||
free(buf);
|
||||
} else {
|
||||
bufname = NULL;
|
||||
if (args_has(args, 'b'))
|
||||
bufname = args_get(args, 'b');
|
||||
|
||||
if (paste_set(buf, len, bufname, &cause) != 0) {
|
||||
cmdq_error(cmdq, "%s", cause);
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
free(buf);
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/* $OpenBSD$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Enter choice mode to choose a buffer.
|
||||
*/
|
||||
|
||||
#define CHOOSE_BUFFER_TEMPLATE \
|
||||
"#{buffer_name}: #{buffer_size} bytes: #{buffer_sample}"
|
||||
|
||||
enum cmd_retval cmd_choose_buffer_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_choose_buffer_entry = {
|
||||
"choose-buffer", NULL,
|
||||
"F:t:", 0, 1,
|
||||
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||
0,
|
||||
cmd_choose_buffer_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
struct window_choose_data *cdata;
|
||||
struct winlink *wl;
|
||||
struct paste_buffer *pb;
|
||||
char *action, *action_data;
|
||||
const char *template;
|
||||
u_int idx;
|
||||
int utf8flag;
|
||||
|
||||
if ((c = cmd_find_client(cmdq, NULL, 1)) == NULL) {
|
||||
cmdq_error(cmdq, "no client available");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = CHOOSE_BUFFER_TEMPLATE;
|
||||
|
||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
utf8flag = options_get_number(&wl->window->options, "utf8");
|
||||
|
||||
if (paste_get_top(NULL) == NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
if (args->argc != 0)
|
||||
action = xstrdup(args->argv[0]);
|
||||
else
|
||||
action = xstrdup("paste-buffer -b '%%'");
|
||||
|
||||
idx = 0;
|
||||
pb = NULL;
|
||||
while ((pb = paste_walk(pb)) != NULL) {
|
||||
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
||||
cdata->idx = idx;
|
||||
|
||||
cdata->ft_template = xstrdup(template);
|
||||
format_defaults_paste_buffer(cdata->ft, pb, utf8flag);
|
||||
|
||||
xasprintf(&action_data, "%s", paste_buffer_name(pb));
|
||||
cdata->command = cmd_template_replace(action, action_data, 1);
|
||||
free(action_data);
|
||||
|
||||
window_choose_add(wl->window->active, cdata);
|
||||
idx++;
|
||||
}
|
||||
free(action);
|
||||
|
||||
window_choose_ready(wl->window->active, 0, NULL);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
/* $OpenBSD$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Enter choice mode to choose a client.
|
||||
*/
|
||||
|
||||
#define CHOOSE_CLIENT_TEMPLATE \
|
||||
"#{client_tty}: #{session_name} " \
|
||||
"[#{client_width}x#{client_height} #{client_termname}]" \
|
||||
"#{?client_utf8, (utf8),}#{?client_readonly, (ro),} " \
|
||||
"(last used #{client_activity_string})"
|
||||
|
||||
enum cmd_retval cmd_choose_client_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
void cmd_choose_client_callback(struct window_choose_data *);
|
||||
|
||||
const struct cmd_entry cmd_choose_client_entry = {
|
||||
"choose-client", NULL,
|
||||
"F:t:", 0, 1,
|
||||
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||
0,
|
||||
cmd_choose_client_exec
|
||||
};
|
||||
|
||||
struct cmd_choose_client_data {
|
||||
struct client *client;
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
struct client *c1;
|
||||
struct window_choose_data *cdata;
|
||||
struct winlink *wl;
|
||||
const char *template;
|
||||
char *action;
|
||||
u_int idx, cur;
|
||||
|
||||
if ((c = cmd_find_client(cmdq, NULL, 1)) == NULL) {
|
||||
cmdq_error(cmdq, "no client available");
|
||||
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 ((template = args_get(args, 'F')) == NULL)
|
||||
template = CHOOSE_CLIENT_TEMPLATE;
|
||||
|
||||
if (args->argc != 0)
|
||||
action = xstrdup(args->argv[0]);
|
||||
else
|
||||
action = xstrdup("detach-client -t '%%'");
|
||||
|
||||
cur = idx = 0;
|
||||
TAILQ_FOREACH(c1, &clients, entry) {
|
||||
if (c1->session == NULL || c1->tty.path == NULL)
|
||||
continue;
|
||||
if (c1 == cmdq->client)
|
||||
cur = idx;
|
||||
|
||||
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
||||
cdata->idx = idx;
|
||||
|
||||
cdata->ft_template = xstrdup(template);
|
||||
format_add(cdata->ft, "line", "%u", idx);
|
||||
format_defaults(cdata->ft, c1, NULL, NULL, NULL);
|
||||
|
||||
cdata->command = cmd_template_replace(action, c1->tty.path, 1);
|
||||
|
||||
window_choose_add(wl->window->active, cdata);
|
||||
|
||||
idx++;
|
||||
}
|
||||
free(action);
|
||||
|
||||
window_choose_ready(wl->window->active, cur,
|
||||
cmd_choose_client_callback);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_choose_client_callback(struct window_choose_data *cdata)
|
||||
{
|
||||
struct client *c;
|
||||
u_int idx;
|
||||
|
||||
if (cdata == NULL)
|
||||
return;
|
||||
if (cdata->start_client->flags & CLIENT_DEAD)
|
||||
return;
|
||||
|
||||
idx = 0;
|
||||
TAILQ_FOREACH(c, &clients, entry) {
|
||||
if (idx == cdata->idx)
|
||||
break;
|
||||
idx++;
|
||||
}
|
||||
if (c == NULL || c->session == NULL)
|
||||
return;
|
||||
|
||||
window_choose_data_run(cdata);
|
||||
}
|
||||
@@ -18,224 +18,74 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
#define CMD_CHOOSE_TREE_WINDOW_ACTION "select-window -t '%%'"
|
||||
#define CMD_CHOOSE_TREE_SESSION_ACTION "switch-client -t '%%'"
|
||||
|
||||
/*
|
||||
* Enter choice mode to choose a session and/or window.
|
||||
* Enter a mode.
|
||||
*/
|
||||
|
||||
#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}\""
|
||||
|
||||
enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_choose_tree_entry = {
|
||||
"choose-tree", NULL,
|
||||
"S:W:swub:c:t:", 0, 1,
|
||||
"[-suw] [-b session-template] [-c window template] [-S format] " \
|
||||
"[-W format] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_choose_tree_exec
|
||||
.name = "choose-tree",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "F:Gf:NO:rst:wZ", 0, 1 },
|
||||
.usage = "[-GNrswZ] [-F format] [-f filter] [-O sort-order] "
|
||||
CMD_TARGET_PANE_USAGE " [template]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_choose_tree_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_choose_session_entry = {
|
||||
"choose-session", NULL,
|
||||
"F:t:", 0, 1,
|
||||
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||
0,
|
||||
cmd_choose_tree_exec
|
||||
const struct cmd_entry cmd_choose_client_entry = {
|
||||
.name = "choose-client",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "F:f:NO:rt:Z", 0, 1 },
|
||||
.usage = "[-NrZ] [-F format] [-f filter] [-O sort-order] "
|
||||
CMD_TARGET_PANE_USAGE " [template]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_choose_tree_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_choose_window_entry = {
|
||||
"choose-window", NULL,
|
||||
"F:t:", 0, 1,
|
||||
CMD_TARGET_WINDOW_USAGE "[-F format] [template]",
|
||||
0,
|
||||
cmd_choose_tree_exec
|
||||
const struct cmd_entry cmd_choose_buffer_entry = {
|
||||
.name = "choose-buffer",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "F:f:NO:rt:Z", 0, 1 },
|
||||
.usage = "[-NrZ] [-F format] [-f filter] [-O sort-order] "
|
||||
CMD_TARGET_PANE_USAGE " [template]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_choose_tree_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_choose_tree_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl, *wm;
|
||||
struct session *s, *s2;
|
||||
struct client *c;
|
||||
struct window_choose_data *wcd = NULL;
|
||||
const char *ses_template, *win_template;
|
||||
char *final_win_action, *cur_win_template;
|
||||
char *final_win_template_middle;
|
||||
char *final_win_template_last;
|
||||
const char *ses_action, *win_action;
|
||||
u_int cur_win, idx_ses, win_ses, win_max;
|
||||
u_int wflag, sflag;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
const struct window_mode *mode;
|
||||
|
||||
ses_template = win_template = NULL;
|
||||
ses_action = win_action = NULL;
|
||||
|
||||
if ((c = cmd_find_client(cmdq, NULL, 1)) == NULL) {
|
||||
cmdq_error(cmdq, "no client available");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
/* Sort out which command this is. */
|
||||
wflag = sflag = 0;
|
||||
if (self->entry == &cmd_choose_session_entry) {
|
||||
sflag = 1;
|
||||
if ((ses_template = args_get(args, 'F')) == NULL)
|
||||
ses_template = CHOOSE_TREE_SESSION_TEMPLATE;
|
||||
|
||||
if (args->argc != 0)
|
||||
ses_action = args->argv[0];
|
||||
else
|
||||
ses_action = CMD_CHOOSE_TREE_SESSION_ACTION;
|
||||
} else if (self->entry == &cmd_choose_window_entry) {
|
||||
wflag = 1;
|
||||
if ((win_template = args_get(args, 'F')) == NULL)
|
||||
win_template = CHOOSE_TREE_WINDOW_TEMPLATE;
|
||||
|
||||
if (args->argc != 0)
|
||||
win_action = args->argv[0];
|
||||
else
|
||||
win_action = CMD_CHOOSE_TREE_WINDOW_ACTION;
|
||||
} else {
|
||||
wflag = args_has(args, 'w');
|
||||
sflag = args_has(args, 's');
|
||||
|
||||
if ((ses_action = args_get(args, 'b')) == NULL)
|
||||
ses_action = CMD_CHOOSE_TREE_SESSION_ACTION;
|
||||
|
||||
if ((win_action = args_get(args, 'c')) == NULL)
|
||||
win_action = CMD_CHOOSE_TREE_WINDOW_ACTION;
|
||||
|
||||
if ((ses_template = args_get(args, 'S')) == NULL)
|
||||
ses_template = CHOOSE_TREE_SESSION_TEMPLATE;
|
||||
|
||||
if ((win_template = args_get(args, 'W')) == NULL)
|
||||
win_template = CHOOSE_TREE_WINDOW_TEMPLATE;
|
||||
}
|
||||
|
||||
/*
|
||||
* If not asking for windows and sessions, assume no "-ws" given and
|
||||
* hence display the entire tree outright.
|
||||
*/
|
||||
if (!wflag && !sflag)
|
||||
wflag = sflag = 1;
|
||||
|
||||
/*
|
||||
* If we're drawing in tree mode, including sessions, then pad the
|
||||
* window template, otherwise just render the windows as a flat list
|
||||
* without any padding.
|
||||
*/
|
||||
if (wflag && sflag) {
|
||||
xasprintf(&final_win_template_middle,
|
||||
" \001tq\001> %s", win_template);
|
||||
xasprintf(&final_win_template_last,
|
||||
" \001mq\001> %s", win_template);
|
||||
} else if (wflag) {
|
||||
final_win_template_middle = xstrdup(win_template);
|
||||
final_win_template_last = xstrdup(win_template);
|
||||
if (self->entry == &cmd_choose_buffer_entry) {
|
||||
if (paste_get_top(NULL) == NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
mode = &window_buffer_mode;
|
||||
} else if (self->entry == &cmd_choose_client_entry) {
|
||||
if (server_client_how_many() == 0)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
mode = &window_client_mode;
|
||||
} else
|
||||
final_win_template_middle = final_win_template_last = NULL;
|
||||
|
||||
idx_ses = cur_win = -1;
|
||||
RB_FOREACH(s2, sessions, &sessions) {
|
||||
idx_ses++;
|
||||
|
||||
/*
|
||||
* If we're just choosing windows, jump straight there. Note
|
||||
* that this implies the current session, so only choose
|
||||
* windows when the session matches this one.
|
||||
*/
|
||||
if (wflag && !sflag) {
|
||||
if (s != s2)
|
||||
continue;
|
||||
goto windows_only;
|
||||
}
|
||||
|
||||
wcd = window_choose_add_session(wl->window->active,
|
||||
c, s2, ses_template, ses_action, idx_ses);
|
||||
|
||||
/* If we're just choosing sessions, skip choosing windows. */
|
||||
if (sflag && !wflag) {
|
||||
if (s == s2)
|
||||
cur_win = idx_ses;
|
||||
continue;
|
||||
}
|
||||
windows_only:
|
||||
win_ses = win_max = -1;
|
||||
RB_FOREACH(wm, winlinks, &s2->windows)
|
||||
win_max++;
|
||||
RB_FOREACH(wm, winlinks, &s2->windows) {
|
||||
win_ses++;
|
||||
if (sflag && wflag)
|
||||
idx_ses++;
|
||||
|
||||
if (wm == s2->curw && s == s2) {
|
||||
if (wflag && !sflag) {
|
||||
/*
|
||||
* Then we're only counting windows.
|
||||
* So remember which is the current
|
||||
* window in the list.
|
||||
*/
|
||||
cur_win = win_ses;
|
||||
} else
|
||||
cur_win = idx_ses;
|
||||
}
|
||||
|
||||
xasprintf(&final_win_action, "%s %s %s",
|
||||
wcd != NULL ? wcd->command : "",
|
||||
wcd != NULL ? ";" : "", win_action);
|
||||
|
||||
if (win_ses != win_max)
|
||||
cur_win_template = final_win_template_middle;
|
||||
else
|
||||
cur_win_template = final_win_template_last;
|
||||
|
||||
window_choose_add_window(wl->window->active,
|
||||
c, s2, wm, cur_win_template,
|
||||
final_win_action,
|
||||
(wflag && !sflag) ? win_ses : idx_ses);
|
||||
|
||||
free(final_win_action);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're just drawing windows, don't consider moving on to
|
||||
* other sessions as we only list windows in this session.
|
||||
*/
|
||||
if (wflag && !sflag)
|
||||
break;
|
||||
}
|
||||
free(final_win_template_middle);
|
||||
free(final_win_template_last);
|
||||
|
||||
window_choose_ready(wl->window->active, cur_win, NULL);
|
||||
|
||||
if (args_has(args, 'u')) {
|
||||
window_choose_expand_all(wl->window->active);
|
||||
window_choose_set_current(wl->window->active, cur_win);
|
||||
}
|
||||
mode = &window_tree_mode;
|
||||
|
||||
window_pane_set_mode(wp, mode, &item->target, args);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -29,31 +29,40 @@
|
||||
* Prompt for command in client.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_command_prompt_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_command_prompt_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
int cmd_command_prompt_callback(void *, const char *);
|
||||
void cmd_command_prompt_free(void *);
|
||||
static int cmd_command_prompt_callback(struct client *, void *,
|
||||
const char *, int);
|
||||
static void cmd_command_prompt_free(void *);
|
||||
|
||||
const struct cmd_entry cmd_command_prompt_entry = {
|
||||
"command-prompt", NULL,
|
||||
"I:p:t:", 0, 1,
|
||||
"[-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " [template]",
|
||||
0,
|
||||
cmd_command_prompt_exec
|
||||
.name = "command-prompt",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "1kiI:Np:t:", 0, 1 },
|
||||
.usage = "[-1kiN] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " "
|
||||
"[template]",
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_command_prompt_exec
|
||||
};
|
||||
|
||||
struct cmd_command_prompt_cdata {
|
||||
struct client *c;
|
||||
char *inputs;
|
||||
char *next_input;
|
||||
char *next_prompt;
|
||||
char *prompts;
|
||||
char *template;
|
||||
int idx;
|
||||
int flags;
|
||||
|
||||
char *inputs;
|
||||
char *next_input;
|
||||
|
||||
char *prompts;
|
||||
char *next_prompt;
|
||||
|
||||
char *template;
|
||||
int idx;
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
const char *inputs, *prompts;
|
||||
@@ -62,20 +71,22 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
char *prompt, *ptr, *input = NULL;
|
||||
size_t n;
|
||||
|
||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
if (c->prompt_string != NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
cdata = xmalloc(sizeof *cdata);
|
||||
cdata->c = c;
|
||||
cdata->idx = 1;
|
||||
cdata = xcalloc(1, sizeof *cdata);
|
||||
|
||||
cdata->inputs = NULL;
|
||||
cdata->next_input = NULL;
|
||||
cdata->next_prompt = NULL;
|
||||
|
||||
cdata->prompts = NULL;
|
||||
cdata->next_prompt = NULL;
|
||||
|
||||
cdata->template = NULL;
|
||||
cdata->idx = 1;
|
||||
|
||||
if (args->argc != 0)
|
||||
cdata->template = xstrdup(args->argv[0]);
|
||||
@@ -105,34 +116,47 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
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;
|
||||
else if (args_has(args, 'k'))
|
||||
cdata->flags |= PROMPT_KEY;
|
||||
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);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
int
|
||||
cmd_command_prompt_callback(void *data, const char *s)
|
||||
static int
|
||||
cmd_command_prompt_callback(struct client *c, void *data, const char *s,
|
||||
int done)
|
||||
{
|
||||
struct cmd_command_prompt_cdata *cdata = data;
|
||||
struct client *c = cdata->c;
|
||||
struct cmd_list *cmdlist;
|
||||
char *cause, *new_template, *prompt, *ptr;
|
||||
struct cmdq_item *new_item;
|
||||
char *new_template, *prompt, *ptr;
|
||||
char *input = NULL;
|
||||
struct cmd_parse_result *pr;
|
||||
|
||||
if (s == NULL)
|
||||
return (0);
|
||||
if (done && (cdata->flags & PROMPT_INCREMENTAL))
|
||||
return (0);
|
||||
|
||||
new_template = cmd_template_replace(cdata->template, s, cdata->idx);
|
||||
free(cdata->template);
|
||||
cdata->template = new_template;
|
||||
if (done) {
|
||||
free(cdata->template);
|
||||
cdata->template = new_template;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if there are more prompts; if so, get its respective input
|
||||
* and update the prompt data.
|
||||
*/
|
||||
if ((ptr = strsep(&cdata->next_prompt, ",")) != NULL) {
|
||||
if (done && (ptr = strsep(&cdata->next_prompt, ",")) != NULL) {
|
||||
xasprintf(&prompt, "%s ", ptr);
|
||||
input = strsep(&cdata->next_input, ",");
|
||||
status_prompt_update(c, prompt, input);
|
||||
@@ -142,24 +166,31 @@ cmd_command_prompt_callback(void *data, const char *s)
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (cmd_string_parse(new_template, &cmdlist, NULL, 0, &cause) != 0) {
|
||||
if (cause != NULL) {
|
||||
*cause = toupper((u_char) *cause);
|
||||
status_message_set(c, "%s", cause);
|
||||
free(cause);
|
||||
}
|
||||
return (0);
|
||||
pr = cmd_parse_from_string(new_template, NULL);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
new_item = NULL;
|
||||
break;
|
||||
case CMD_PARSE_ERROR:
|
||||
new_item = cmdq_get_error(pr->error);
|
||||
free(pr->error);
|
||||
cmdq_append(c, new_item);
|
||||
break;
|
||||
case CMD_PARSE_SUCCESS:
|
||||
new_item = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);
|
||||
cmd_list_free(pr->cmdlist);
|
||||
cmdq_append(c, new_item);
|
||||
break;
|
||||
}
|
||||
|
||||
cmdq_run(c->cmdq, cmdlist, NULL);
|
||||
cmd_list_free(cmdlist);
|
||||
|
||||
if (c->prompt_callbackfn != (void *) &cmd_command_prompt_callback)
|
||||
if (!done)
|
||||
free(new_template);
|
||||
if (c->prompt_inputcb != cmd_command_prompt_callback)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
cmd_command_prompt_free(void *data)
|
||||
{
|
||||
struct cmd_command_prompt_cdata *cdata = data;
|
||||
|
||||
@@ -28,26 +28,30 @@
|
||||
* Asks for confirmation before executing a command.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_confirm_before_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_confirm_before_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
int cmd_confirm_before_callback(void *, const char *);
|
||||
void cmd_confirm_before_free(void *);
|
||||
static int cmd_confirm_before_callback(struct client *, void *,
|
||||
const char *, int);
|
||||
static void cmd_confirm_before_free(void *);
|
||||
|
||||
const struct cmd_entry cmd_confirm_before_entry = {
|
||||
"confirm-before", "confirm",
|
||||
"p:t:", 1, 1,
|
||||
"[-p prompt] " CMD_TARGET_CLIENT_USAGE " command",
|
||||
0,
|
||||
cmd_confirm_before_exec
|
||||
.name = "confirm-before",
|
||||
.alias = "confirm",
|
||||
|
||||
.args = { "p:t:", 1, 1 },
|
||||
.usage = "[-p prompt] " CMD_TARGET_CLIENT_USAGE " command",
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_confirm_before_exec
|
||||
};
|
||||
|
||||
struct cmd_confirm_before_data {
|
||||
char *cmd;
|
||||
struct client *client;
|
||||
char *cmd;
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct cmd_confirm_before_data *cdata;
|
||||
@@ -55,7 +59,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
char *cmd, *copy, *new_prompt, *ptr;
|
||||
const char *prompt;
|
||||
|
||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
if ((prompt = args_get(args, 'p')) != NULL)
|
||||
@@ -70,9 +74,6 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
cdata = xmalloc(sizeof *cdata);
|
||||
cdata->cmd = xstrdup(args->argv[0]);
|
||||
|
||||
cdata->client = c;
|
||||
cdata->client->references++;
|
||||
|
||||
status_prompt_set(c, new_prompt, NULL,
|
||||
cmd_confirm_before_callback, cmd_confirm_before_free, cdata,
|
||||
PROMPT_SINGLE);
|
||||
@@ -81,43 +82,46 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
int
|
||||
cmd_confirm_before_callback(void *data, const char *s)
|
||||
static int
|
||||
cmd_confirm_before_callback(struct client *c, void *data, const char *s,
|
||||
__unused int done)
|
||||
{
|
||||
struct cmd_confirm_before_data *cdata = data;
|
||||
struct client *c = cdata->client;
|
||||
struct cmd_list *cmdlist;
|
||||
char *cause;
|
||||
struct cmdq_item *new_item;
|
||||
struct cmd_parse_result *pr;
|
||||
|
||||
if (c->flags & CLIENT_DEAD)
|
||||
return (0);
|
||||
|
||||
if (s == NULL || *s == '\0')
|
||||
return (0);
|
||||
if (tolower((u_char) s[0]) != 'y' || s[1] != '\0')
|
||||
if (tolower((u_char)s[0]) != 'y' || s[1] != '\0')
|
||||
return (0);
|
||||
|
||||
if (cmd_string_parse(cdata->cmd, &cmdlist, NULL, 0, &cause) != 0) {
|
||||
if (cause != NULL) {
|
||||
cmdq_error(c->cmdq, "%s", cause);
|
||||
free(cause);
|
||||
}
|
||||
return (0);
|
||||
pr = cmd_parse_from_string(cdata->cmd, NULL);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
new_item = NULL;
|
||||
break;
|
||||
case CMD_PARSE_ERROR:
|
||||
new_item = cmdq_get_error(pr->error);
|
||||
free(pr->error);
|
||||
cmdq_append(c, new_item);
|
||||
break;
|
||||
case CMD_PARSE_SUCCESS:
|
||||
new_item = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);
|
||||
cmd_list_free(pr->cmdlist);
|
||||
cmdq_append(c, new_item);
|
||||
break;
|
||||
}
|
||||
|
||||
cmdq_run(c->cmdq, cmdlist, NULL);
|
||||
cmd_list_free(cmdlist);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
cmd_confirm_before_free(void *data)
|
||||
{
|
||||
struct cmd_confirm_before_data *cdata = data;
|
||||
struct client *c = cdata->client;
|
||||
|
||||
server_client_unref(c);
|
||||
|
||||
free(cdata->cmd);
|
||||
free(cdata);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -24,57 +24,61 @@
|
||||
* Enter copy or clock mode.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_copy_mode_entry = {
|
||||
"copy-mode", NULL,
|
||||
"Met:u", 0, 0,
|
||||
"[-Meu] " CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
cmd_copy_mode_exec
|
||||
.name = "copy-mode",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "Met:u", 0, 0 },
|
||||
.usage = "[-Mu] " CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_copy_mode_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_clock_mode_entry = {
|
||||
"clock-mode", NULL,
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
cmd_copy_mode_exec
|
||||
.name = "clock-mode",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "t:", 0, 0 },
|
||||
.usage = CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_copy_mode_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c = cmdq->client;
|
||||
struct cmdq_shared *shared = item->shared;
|
||||
struct client *c = item->client;
|
||||
struct session *s;
|
||||
struct window_pane *wp;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
|
||||
if (args_has(args, 'M')) {
|
||||
if ((wp = cmd_mouse_pane(&cmdq->item->mouse, &s, NULL)) == NULL)
|
||||
if ((wp = cmd_mouse_pane(&shared->mouse, &s, NULL)) == NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
if (c == NULL || c->session != s)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
} else if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
if (self->entry == &cmd_clock_mode_entry) {
|
||||
window_pane_set_mode(wp, &window_clock_mode);
|
||||
window_pane_set_mode(wp, &window_clock_mode, NULL, NULL);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
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 (!window_pane_set_mode(wp, &window_copy_mode, NULL, args)) {
|
||||
if (args_has(args, 'M'))
|
||||
window_copy_start_drag(c, &shared->mouse);
|
||||
}
|
||||
if (args_has(args, 'M')) {
|
||||
if (wp->mode != NULL && wp->mode != &window_copy_mode)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
window_copy_start_drag(c, &cmdq->item->mouse);
|
||||
}
|
||||
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
|
||||
window_copy_pageup(wp);
|
||||
if (args_has(self->args, 'u'))
|
||||
window_copy_pageup(wp, 0);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -26,38 +26,48 @@
|
||||
* 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 = {
|
||||
"detach-client", "detach",
|
||||
"as:t:P", 0, 0,
|
||||
"[-P] [-a] [-s target-session] " CMD_TARGET_CLIENT_USAGE,
|
||||
CMD_READONLY,
|
||||
cmd_detach_client_exec
|
||||
.name = "detach-client",
|
||||
.alias = "detach",
|
||||
|
||||
.args = { "aE:s:t:P", 0, 0 },
|
||||
.usage = "[-aP] [-E shell-command] "
|
||||
"[-s target-session] " CMD_TARGET_CLIENT_USAGE,
|
||||
|
||||
.source = { 's', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = CMD_READONLY,
|
||||
.exec = cmd_detach_client_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_suspend_client_entry = {
|
||||
"suspend-client", "suspendc",
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_CLIENT_USAGE,
|
||||
0,
|
||||
cmd_detach_client_exec
|
||||
.name = "suspend-client",
|
||||
.alias = "suspendc",
|
||||
|
||||
.args = { "t:", 0, 0 },
|
||||
.usage = CMD_TARGET_CLIENT_USAGE,
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_detach_client_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c, *cloop;
|
||||
struct session *s;
|
||||
enum msgtype msgtype;
|
||||
const char *cmd = args_get(args, 'E');
|
||||
|
||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
if (self->entry == &cmd_suspend_client_entry) {
|
||||
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);
|
||||
server_client_suspend(c);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -67,36 +77,35 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
msgtype = MSG_DETACH;
|
||||
|
||||
if (args_has(args, 's')) {
|
||||
s = cmd_find_session(cmdq, args_get(args, 's'), 0);
|
||||
s = item->source.s;
|
||||
if (s == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
TAILQ_FOREACH(cloop, &clients, entry) {
|
||||
if (cloop->session != s)
|
||||
continue;
|
||||
server_write_client(cloop, msgtype,
|
||||
cloop->session->name,
|
||||
strlen(cloop->session->name) + 1);
|
||||
if (cloop->session == s) {
|
||||
if (cmd != NULL)
|
||||
server_client_exec(cloop, cmd);
|
||||
else
|
||||
server_client_detach(cloop, msgtype);
|
||||
}
|
||||
}
|
||||
return (CMD_RETURN_STOP);
|
||||
}
|
||||
|
||||
c = cmd_find_client(cmdq, args_get(args, 't'), 0);
|
||||
if (c == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
if (args_has(args, 'a')) {
|
||||
TAILQ_FOREACH(cloop, &clients, entry) {
|
||||
if (cloop->session == NULL || cloop == c)
|
||||
continue;
|
||||
server_write_client(cloop, msgtype,
|
||||
cloop->session->name,
|
||||
strlen(cloop->session->name) + 1);
|
||||
if (cloop->session != NULL && cloop != c) {
|
||||
if (cmd != NULL)
|
||||
server_client_exec(cloop, cmd);
|
||||
else
|
||||
server_client_detach(cloop, msgtype);
|
||||
}
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
server_write_client(c, msgtype, c->session->name,
|
||||
strlen(c->session->name) + 1);
|
||||
if (cmd != NULL)
|
||||
server_client_exec(c, cmd);
|
||||
else
|
||||
server_client_detach(c, msgtype);
|
||||
return (CMD_RETURN_STOP);
|
||||
}
|
||||
|
||||
178
cmd-display-menu.c
Normal file
178
cmd-display-menu.c
Normal file
@@ -0,0 +1,178 @@
|
||||
/* $OpenBSD$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Display a menu on a client.
|
||||
*/
|
||||
|
||||
static enum cmd_retval cmd_display_menu_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_display_menu_entry = {
|
||||
.name = "display-menu",
|
||||
.alias = "menu",
|
||||
|
||||
.args = { "c:t:T:x:y:", 1, -1 },
|
||||
.usage = "[-c target-client] " CMD_TARGET_PANE_USAGE " [-T title] "
|
||||
"[-x position] [-y position] name key command ...",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_display_menu_exec
|
||||
};
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct cmd_find_state *fs = &item->target;
|
||||
struct menu *menu = NULL;
|
||||
struct style_range *sr;
|
||||
struct menu_item menu_item;
|
||||
const char *xp, *yp, *key;
|
||||
char *title, *name;
|
||||
int at, flags, i;
|
||||
u_int px, py, ox, oy, sx, sy;
|
||||
|
||||
if ((c = cmd_find_client(item, args_get(args, 'c'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
if (c->overlay_draw != NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
at = status_at_line(c);
|
||||
|
||||
if (args_has(args, 'T'))
|
||||
title = format_single(NULL, args_get(args, 'T'), c, s, wl, wp);
|
||||
else
|
||||
title = xstrdup("");
|
||||
|
||||
menu = menu_create(title);
|
||||
|
||||
for (i = 0; i != args->argc; /* nothing */) {
|
||||
name = args->argv[i++];
|
||||
if (*name == '\0') {
|
||||
menu_add_item(menu, NULL, item, c, fs);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (args->argc - i < 2) {
|
||||
cmdq_error(item, "not enough arguments");
|
||||
free(title);
|
||||
menu_free(menu);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
key = args->argv[i++];
|
||||
|
||||
menu_item.name = name;
|
||||
menu_item.key = key_string_lookup_string(key);
|
||||
menu_item.command = args->argv[i++];
|
||||
|
||||
menu_add_item(menu, &menu_item, item, c, fs);
|
||||
}
|
||||
free(title);
|
||||
if (menu == NULL) {
|
||||
cmdq_error(item, "invalid menu arguments");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (menu->count == 0) {
|
||||
menu_free(menu);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
xp = args_get(args, 'x');
|
||||
if (xp == NULL)
|
||||
px = 0;
|
||||
else if (strcmp(xp, "R") == 0)
|
||||
px = c->tty.sx - 1;
|
||||
else if (strcmp(xp, "P") == 0) {
|
||||
tty_window_offset(&c->tty, &ox, &oy, &sx, &sy);
|
||||
if (wp->xoff >= ox)
|
||||
px = wp->xoff - ox;
|
||||
else
|
||||
px = 0;
|
||||
} else if (strcmp(xp, "M") == 0 && item->shared->mouse.valid) {
|
||||
if (item->shared->mouse.x > (menu->width + 4) / 2)
|
||||
px = item->shared->mouse.x - (menu->width + 4) / 2;
|
||||
else
|
||||
px = 0;
|
||||
}
|
||||
else if (strcmp(xp, "W") == 0) {
|
||||
if (at == -1)
|
||||
px = 0;
|
||||
else {
|
||||
TAILQ_FOREACH(sr, &c->status.entries[0].ranges, entry) {
|
||||
if (sr->type != STYLE_RANGE_WINDOW)
|
||||
continue;
|
||||
if (sr->argument == (u_int)wl->idx)
|
||||
break;
|
||||
}
|
||||
if (sr != NULL)
|
||||
px = sr->start;
|
||||
else
|
||||
px = 0;
|
||||
}
|
||||
} else
|
||||
px = strtoul(xp, NULL, 10);
|
||||
if (px + menu->width + 4 >= c->tty.sx)
|
||||
px = c->tty.sx - menu->width - 4;
|
||||
|
||||
yp = args_get(args, 'y');
|
||||
if (yp == NULL)
|
||||
py = 0;
|
||||
else if (strcmp(yp, "P") == 0) {
|
||||
tty_window_offset(&c->tty, &ox, &oy, &sx, &sy);
|
||||
if (wp->yoff + wp->sy >= oy)
|
||||
py = wp->yoff + wp->sy - oy;
|
||||
else
|
||||
py = 0;
|
||||
} else if (strcmp(yp, "M") == 0 && item->shared->mouse.valid)
|
||||
py = item->shared->mouse.y + menu->count + 2;
|
||||
else if (strcmp(yp, "S") == 0) {
|
||||
if (at == -1)
|
||||
py = c->tty.sy;
|
||||
else if (at == 0)
|
||||
py = status_line_size(c) + menu->count + 2;
|
||||
else
|
||||
py = at;
|
||||
} else
|
||||
py = strtoul(yp, NULL, 10);
|
||||
if (py < menu->count + 2)
|
||||
py = 0;
|
||||
else
|
||||
py -= menu->count + 2;
|
||||
if (py + menu->count + 2 >= c->tty.sy)
|
||||
py = c->tty.sy - menu->count - 2;
|
||||
|
||||
flags = 0;
|
||||
if (!item->shared->mouse.valid)
|
||||
flags |= MENU_NOMOUSE;
|
||||
if (menu_display(menu, flags, item, px, py, c, fs, NULL, NULL) != 0)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
@@ -32,78 +32,94 @@
|
||||
"#{window_name}, current pane #{pane_index} " \
|
||||
"- (%H:%M %d-%b-%y)"
|
||||
|
||||
enum cmd_retval cmd_display_message_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_display_message_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_display_message_entry = {
|
||||
"display-message", "display",
|
||||
"c:pt:F:", 0, 1,
|
||||
"[-p] [-c target-client] [-F format] " CMD_TARGET_PANE_USAGE
|
||||
" [message]",
|
||||
0,
|
||||
cmd_display_message_exec
|
||||
.name = "display-message",
|
||||
.alias = "display",
|
||||
|
||||
.args = { "ac:Ipt:F:v", 0, 1 },
|
||||
.usage = "[-aIpv] [-c target-client] [-F format] "
|
||||
CMD_TARGET_PANE_USAGE " [message]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_display_message_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_display_message_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static void
|
||||
cmd_display_message_each(const char *key, const char *value, void *arg)
|
||||
{
|
||||
struct cmdq_item *item = arg;
|
||||
|
||||
cmdq_print(item, "%s=%s", key, value);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
struct window_pane *wp;
|
||||
struct client *c, *target_c;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
const char *template;
|
||||
char *msg;
|
||||
char *msg, *cause;
|
||||
struct format_tree *ft;
|
||||
char out[BUFSIZ];
|
||||
time_t t;
|
||||
size_t len;
|
||||
int flags;
|
||||
|
||||
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)
|
||||
if (args_has(args, 'I')) {
|
||||
if (window_pane_start_input(wp, item, &cause) != 0) {
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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_find_client(cmdq, NULL, 1);
|
||||
if (c == NULL && !args_has(self->args, 'p')) {
|
||||
cmdq_error(cmdq, "no client available");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
template = args_get(args, 'F');
|
||||
if (args->argc != 0)
|
||||
template = args->argv[0];
|
||||
if (template == NULL)
|
||||
template = DISPLAY_MESSAGE_TEMPLATE;
|
||||
|
||||
ft = format_create();
|
||||
format_defaults(ft, c, s, wl, wp);
|
||||
|
||||
t = time(NULL);
|
||||
len = strftime(out, sizeof out, template, localtime(&t));
|
||||
out[len] = '\0';
|
||||
|
||||
msg = format_expand(ft, out);
|
||||
if (args_has(self->args, 'p'))
|
||||
cmdq_print(cmdq, "%s", msg);
|
||||
/*
|
||||
* -c is intended to be the client where the message should be
|
||||
* displayed if -p is not given. But it makes sense to use it for the
|
||||
* formats too, assuming it matches the session. If it doesn't, use the
|
||||
* best client for the session.
|
||||
*/
|
||||
c = cmd_find_client(item, args_get(args, 'c'), 1);
|
||||
if (c != NULL && c->session == s)
|
||||
target_c = c;
|
||||
else
|
||||
target_c = cmd_find_best_client(s);
|
||||
if (args_has(self->args, 'v'))
|
||||
flags = FORMAT_VERBOSE;
|
||||
else
|
||||
flags = 0;
|
||||
ft = format_create(item->client, item, FORMAT_NONE, flags);
|
||||
format_defaults(ft, target_c, s, wl, wp);
|
||||
|
||||
if (args_has(args, 'a')) {
|
||||
format_each(ft, cmd_display_message_each, item);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
msg = format_expand_time(ft, template);
|
||||
if (args_has(self->args, 'p'))
|
||||
cmdq_print(item, "%s", msg);
|
||||
else if (c != NULL)
|
||||
status_message_set(c, "%s", msg);
|
||||
free(msg);
|
||||
|
||||
format_free(ft);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -18,32 +18,265 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* 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 *);
|
||||
|
||||
const struct cmd_entry cmd_display_panes_entry = {
|
||||
"display-panes", "displayp",
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_CLIENT_USAGE,
|
||||
0,
|
||||
cmd_display_panes_exec
|
||||
.name = "display-panes",
|
||||
.alias = "displayp",
|
||||
|
||||
.args = { "bd:t:", 0, 1 },
|
||||
.usage = "[-b] [-d duration] " CMD_TARGET_CLIENT_USAGE " [template]",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_display_panes_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_display_panes_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
struct cmd_display_panes_data {
|
||||
struct cmdq_item *item;
|
||||
char *command;
|
||||
};
|
||||
|
||||
static void
|
||||
cmd_display_panes_draw_pane(struct screen_redraw_ctx *ctx,
|
||||
struct window_pane *wp)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
struct client *c = ctx->c;
|
||||
struct tty *tty = &c->tty;
|
||||
struct session *s = c->session;
|
||||
struct options *oo = s->options;
|
||||
struct window *w = wp->window;
|
||||
struct grid_cell gc;
|
||||
u_int idx, px, py, i, j, xoff, yoff, sx, sy;
|
||||
int colour, active_colour;
|
||||
char buf[16], *ptr;
|
||||
size_t len;
|
||||
|
||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
if (wp->xoff + wp->sx <= ctx->ox ||
|
||||
wp->xoff >= ctx->ox + ctx->sx ||
|
||||
wp->yoff + wp->sy <= ctx->oy ||
|
||||
wp->yoff >= ctx->oy + ctx->sy)
|
||||
return;
|
||||
|
||||
server_set_identify(c);
|
||||
if (wp->xoff >= ctx->ox && wp->xoff + wp->sx <= ctx->ox + ctx->sx) {
|
||||
/* All visible. */
|
||||
xoff = wp->xoff - ctx->ox;
|
||||
sx = wp->sx;
|
||||
} else if (wp->xoff < ctx->ox &&
|
||||
wp->xoff + wp->sx > ctx->ox + ctx->sx) {
|
||||
/* Both left and right not visible. */
|
||||
xoff = 0;
|
||||
sx = ctx->sx;
|
||||
} else if (wp->xoff < ctx->ox) {
|
||||
/* Left not visible. */
|
||||
xoff = 0;
|
||||
sx = wp->sx - (ctx->ox - wp->xoff);
|
||||
} else {
|
||||
/* Right not visible. */
|
||||
xoff = wp->xoff - ctx->ox;
|
||||
sx = wp->sx - xoff;
|
||||
}
|
||||
if (wp->yoff >= ctx->oy && wp->yoff + wp->sy <= ctx->oy + ctx->sy) {
|
||||
/* All visible. */
|
||||
yoff = wp->yoff - ctx->oy;
|
||||
sy = wp->sy;
|
||||
} else if (wp->yoff < ctx->oy &&
|
||||
wp->yoff + wp->sy > ctx->oy + ctx->sy) {
|
||||
/* Both top and bottom not visible. */
|
||||
yoff = 0;
|
||||
sy = ctx->sy;
|
||||
} else if (wp->yoff < ctx->oy) {
|
||||
/* Top not visible. */
|
||||
yoff = 0;
|
||||
sy = wp->sy - (ctx->oy - wp->yoff);
|
||||
} else {
|
||||
/* Bottom not visible. */
|
||||
yoff = wp->yoff - ctx->oy;
|
||||
sy = wp->sy - yoff;
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
if (ctx->statustop)
|
||||
yoff += ctx->statuslines;
|
||||
px = sx / 2;
|
||||
py = sy / 2;
|
||||
|
||||
if (window_pane_index(wp, &idx) != 0)
|
||||
fatalx("index not found");
|
||||
len = xsnprintf(buf, sizeof buf, "%u", idx);
|
||||
|
||||
if (sx < len)
|
||||
return;
|
||||
colour = options_get_number(oo, "display-panes-colour");
|
||||
active_colour = options_get_number(oo, "display-panes-active-colour");
|
||||
|
||||
if (sx < len * 6 || sy < 5) {
|
||||
tty_cursor(tty, xoff + px - len / 2, yoff + py);
|
||||
goto draw_text;
|
||||
}
|
||||
|
||||
px -= len * 3;
|
||||
py -= 2;
|
||||
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
if (w->active == wp)
|
||||
gc.bg = active_colour;
|
||||
else
|
||||
gc.bg = colour;
|
||||
gc.flags |= GRID_FLAG_NOPALETTE;
|
||||
|
||||
tty_attributes(tty, &gc, wp);
|
||||
for (ptr = buf; *ptr != '\0'; ptr++) {
|
||||
if (*ptr < '0' || *ptr > '9')
|
||||
continue;
|
||||
idx = *ptr - '0';
|
||||
|
||||
for (j = 0; j < 5; j++) {
|
||||
for (i = px; i < px + 5; i++) {
|
||||
tty_cursor(tty, xoff + i, yoff + py + j);
|
||||
if (window_clock_table[idx][j][i - px])
|
||||
tty_putc(tty, ' ');
|
||||
}
|
||||
}
|
||||
px += 6;
|
||||
}
|
||||
|
||||
len = xsnprintf(buf, sizeof buf, "%ux%u", wp->sx, wp->sy);
|
||||
if (sx < len || sy < 6)
|
||||
return;
|
||||
tty_cursor(tty, xoff + sx - len, yoff);
|
||||
|
||||
draw_text:
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
if (w->active == wp)
|
||||
gc.fg = active_colour;
|
||||
else
|
||||
gc.fg = colour;
|
||||
gc.flags |= GRID_FLAG_NOPALETTE;
|
||||
|
||||
tty_attributes(tty, &gc, wp);
|
||||
tty_puts(tty, buf);
|
||||
|
||||
tty_cursor(tty, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_display_panes_draw(struct client *c, struct screen_redraw_ctx *ctx)
|
||||
{
|
||||
struct window *w = c->session->curw->window;
|
||||
struct window_pane *wp;
|
||||
|
||||
log_debug("%s: %s @%u", __func__, c->name, w->id);
|
||||
|
||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||
if (window_pane_visible(wp))
|
||||
cmd_display_panes_draw_pane(ctx, wp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_display_panes_free(struct client *c)
|
||||
{
|
||||
struct cmd_display_panes_data *cdata = c->overlay_data;
|
||||
|
||||
if (cdata->item != NULL)
|
||||
cmdq_continue(cdata->item);
|
||||
free(cdata->command);
|
||||
free(cdata);
|
||||
}
|
||||
|
||||
static int
|
||||
cmd_display_panes_key(struct client *c, struct key_event *event)
|
||||
{
|
||||
struct cmd_display_panes_data *cdata = c->overlay_data;
|
||||
struct cmdq_item *new_item;
|
||||
char *cmd, *expanded;
|
||||
struct window *w = c->session->curw->window;
|
||||
struct window_pane *wp;
|
||||
struct cmd_parse_result *pr;
|
||||
|
||||
if (event->key < '0' || event->key > '9')
|
||||
return (-1);
|
||||
|
||||
wp = window_pane_at_index(w, event->key - '0');
|
||||
if (wp == NULL)
|
||||
return (1);
|
||||
window_unzoom(w);
|
||||
|
||||
xasprintf(&expanded, "%%%u", wp->id);
|
||||
cmd = cmd_template_replace(cdata->command, expanded, 1);
|
||||
|
||||
pr = cmd_parse_from_string(cmd, NULL);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
new_item = NULL;
|
||||
break;
|
||||
case CMD_PARSE_ERROR:
|
||||
new_item = cmdq_get_error(pr->error);
|
||||
free(pr->error);
|
||||
cmdq_append(c, new_item);
|
||||
break;
|
||||
case CMD_PARSE_SUCCESS:
|
||||
new_item = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);
|
||||
cmd_list_free(pr->cmdlist);
|
||||
cmdq_append(c, new_item);
|
||||
break;
|
||||
}
|
||||
|
||||
free(cmd);
|
||||
free(expanded);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
struct session *s;
|
||||
u_int delay;
|
||||
char *cause;
|
||||
struct cmd_display_panes_data *cdata;
|
||||
|
||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
s = c->session;
|
||||
|
||||
if (c->overlay_draw != NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
if (args_has(args, 'd')) {
|
||||
delay = args_strtonum(args, 'd', 0, UINT_MAX, &cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "delay %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else
|
||||
delay = options_get_number(s->options, "display-panes-time");
|
||||
|
||||
cdata = xmalloc(sizeof *cdata);
|
||||
if (args->argc != 0)
|
||||
cdata->command = xstrdup(args->argv[0]);
|
||||
else
|
||||
cdata->command = xstrdup("select-pane -t '%%'");
|
||||
if (args_has(args, 'b'))
|
||||
cdata->item = NULL;
|
||||
else
|
||||
cdata->item = item;
|
||||
|
||||
server_client_set_overlay(c, delay, cmd_display_panes_draw,
|
||||
cmd_display_panes_key, cmd_display_panes_free, cdata);
|
||||
|
||||
if (args_has(args, 'b'))
|
||||
return (CMD_RETURN_NORMAL);
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@@ -28,212 +26,100 @@
|
||||
* Find window containing text.
|
||||
*/
|
||||
|
||||
#define FIND_WINDOW_TEMPLATE \
|
||||
"#{window_index}: #{window_name} " \
|
||||
"[#{window_width}x#{window_height}] " \
|
||||
"(#{window_panes} panes) #{window_find_matches}"
|
||||
|
||||
enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
void cmd_find_window_callback(struct window_choose_data *);
|
||||
|
||||
/* Flags for determining matching behavior. */
|
||||
#define CMD_FIND_WINDOW_BY_TITLE 0x1
|
||||
#define CMD_FIND_WINDOW_BY_CONTENT 0x2
|
||||
#define CMD_FIND_WINDOW_BY_NAME 0x4
|
||||
|
||||
#define CMD_FIND_WINDOW_ALL \
|
||||
(CMD_FIND_WINDOW_BY_TITLE | \
|
||||
CMD_FIND_WINDOW_BY_CONTENT | \
|
||||
CMD_FIND_WINDOW_BY_NAME)
|
||||
static enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_find_window_entry = {
|
||||
"find-window", "findw",
|
||||
"F:CNt:T", 1, 4,
|
||||
"[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string",
|
||||
0,
|
||||
cmd_find_window_exec
|
||||
.name = "find-window",
|
||||
.alias = "findw",
|
||||
|
||||
.args = { "CNrt:TZ", 1, 1 },
|
||||
.usage = "[-CNrTZ] " CMD_TARGET_PANE_USAGE " match-string",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_find_window_exec
|
||||
};
|
||||
|
||||
struct cmd_find_window_data {
|
||||
struct winlink *wl;
|
||||
char *list_ctx;
|
||||
u_int pane_id;
|
||||
TAILQ_ENTRY(cmd_find_window_data) entry;
|
||||
};
|
||||
TAILQ_HEAD(cmd_find_window_list, cmd_find_window_data);
|
||||
|
||||
u_int cmd_find_window_match_flags(struct args *);
|
||||
void cmd_find_window_match(struct cmd_find_window_list *, int,
|
||||
struct winlink *, const char *, const char *);
|
||||
|
||||
u_int
|
||||
cmd_find_window_match_flags(struct args *args)
|
||||
static enum cmd_retval
|
||||
cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
u_int match_flags = 0;
|
||||
struct args *args = self->args, *new_args;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
const char *s = args->argv[0];
|
||||
char *filter, *argv = { NULL };
|
||||
int C, N, T;
|
||||
|
||||
/* Turn on flags based on the options. */
|
||||
if (args_has(args, 'T'))
|
||||
match_flags |= CMD_FIND_WINDOW_BY_TITLE;
|
||||
if (args_has(args, 'C'))
|
||||
match_flags |= CMD_FIND_WINDOW_BY_CONTENT;
|
||||
if (args_has(args, 'N'))
|
||||
match_flags |= CMD_FIND_WINDOW_BY_NAME;
|
||||
C = args_has(args, 'C');
|
||||
N = args_has(args, 'N');
|
||||
T = args_has(args, 'T');
|
||||
|
||||
/* If none of the flags were set, default to matching anything. */
|
||||
if (match_flags == 0)
|
||||
match_flags = CMD_FIND_WINDOW_ALL;
|
||||
if (!C && !N && !T)
|
||||
C = N = T = 1;
|
||||
|
||||
return (match_flags);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_find_window_match(struct cmd_find_window_list *find_list,
|
||||
int match_flags, struct winlink *wl, const char *str,
|
||||
const char *searchstr)
|
||||
{
|
||||
struct cmd_find_window_data *find_data;
|
||||
struct window_pane *wp;
|
||||
u_int i, line;
|
||||
char *sres;
|
||||
|
||||
find_data = xcalloc(1, sizeof *find_data);
|
||||
|
||||
i = 0;
|
||||
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||
i++;
|
||||
|
||||
if ((match_flags & CMD_FIND_WINDOW_BY_NAME) &&
|
||||
fnmatch(searchstr, wl->window->name, 0) == 0) {
|
||||
find_data->list_ctx = xstrdup("");
|
||||
break;
|
||||
}
|
||||
|
||||
if ((match_flags & CMD_FIND_WINDOW_BY_TITLE) &&
|
||||
fnmatch(searchstr, wp->base.title, 0) == 0) {
|
||||
xasprintf(&find_data->list_ctx,
|
||||
"pane %u title: \"%s\"", i - 1, wp->base.title);
|
||||
break;
|
||||
}
|
||||
|
||||
if (match_flags & CMD_FIND_WINDOW_BY_CONTENT &&
|
||||
(sres = window_pane_search(wp, str, &line)) != NULL) {
|
||||
xasprintf(&find_data->list_ctx,
|
||||
"pane %u line %u: \"%s\"", i - 1, line + 1, sres);
|
||||
free(sres);
|
||||
break;
|
||||
}
|
||||
if (!args_has(args, 'r')) {
|
||||
if (C && N && T) {
|
||||
xasprintf(&filter,
|
||||
"#{||:"
|
||||
"#{C:%s},#{||:#{m:*%s*,#{window_name}},"
|
||||
"#{m:*%s*,#{pane_title}}}}",
|
||||
s, s, s);
|
||||
} else if (C && N) {
|
||||
xasprintf(&filter,
|
||||
"#{||:#{C:%s},#{m:*%s*,#{window_name}}}",
|
||||
s, s);
|
||||
} else if (C && T) {
|
||||
xasprintf(&filter,
|
||||
"#{||:#{C:%s},#{m:*%s*,#{pane_title}}}",
|
||||
s, s);
|
||||
} else if (N && T) {
|
||||
xasprintf(&filter,
|
||||
"#{||:#{m:*%s*,#{window_name}},"
|
||||
"#{m:*%s*,#{pane_title}}}",
|
||||
s, s);
|
||||
} else if (C)
|
||||
xasprintf(&filter, "#{C:%s}", s);
|
||||
else if (N)
|
||||
xasprintf(&filter, "#{m:*%s*,#{window_name}}", s);
|
||||
else
|
||||
xasprintf(&filter, "#{m:*%s*,#{pane_title}}", s);
|
||||
} else {
|
||||
if (C && N && T) {
|
||||
xasprintf(&filter,
|
||||
"#{||:"
|
||||
"#{C/r:%s},#{||:#{m/r:%s,#{window_name}},"
|
||||
"#{m/r:%s,#{pane_title}}}}",
|
||||
s, s, s);
|
||||
} else if (C && N) {
|
||||
xasprintf(&filter,
|
||||
"#{||:#{C/r:%s},#{m/r:%s,#{window_name}}}",
|
||||
s, s);
|
||||
} else if (C && T) {
|
||||
xasprintf(&filter,
|
||||
"#{||:#{C/r:%s},#{m/r:%s,#{pane_title}}}",
|
||||
s, s);
|
||||
} else if (N && T) {
|
||||
xasprintf(&filter,
|
||||
"#{||:#{m/r:%s,#{window_name}},"
|
||||
"#{m/r:%s,#{pane_title}}}",
|
||||
s, s);
|
||||
} else if (C)
|
||||
xasprintf(&filter, "#{C/r:%s}", s);
|
||||
else if (N)
|
||||
xasprintf(&filter, "#{m/r:%s,#{window_name}}", s);
|
||||
else
|
||||
xasprintf(&filter, "#{m/r:%s,#{pane_title}}", s);
|
||||
}
|
||||
|
||||
if (find_data->list_ctx != NULL) {
|
||||
find_data->wl = wl;
|
||||
find_data->pane_id = i - 1;
|
||||
TAILQ_INSERT_TAIL(find_list, find_data, entry);
|
||||
} else
|
||||
free(find_data);
|
||||
}
|
||||
new_args = args_parse("", 1, &argv);
|
||||
if (args_has(args, 'Z'))
|
||||
args_set(new_args, 'Z', NULL);
|
||||
args_set(new_args, 'f', filter);
|
||||
|
||||
enum cmd_retval
|
||||
cmd_find_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
struct window_choose_data *cdata;
|
||||
struct session *s;
|
||||
struct winlink *wl, *wm;
|
||||
struct cmd_find_window_list find_list;
|
||||
struct cmd_find_window_data *find_data;
|
||||
struct cmd_find_window_data *find_data1;
|
||||
char *str, *searchstr;
|
||||
const char *template;
|
||||
u_int i, match_flags;
|
||||
window_pane_set_mode(wp, &window_tree_mode, &item->target, new_args);
|
||||
|
||||
if ((c = cmd_find_client(cmdq, NULL, 1)) == NULL) {
|
||||
cmdq_error(cmdq, "no client available");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
s = c->session;
|
||||
args_free(new_args);
|
||||
free(filter);
|
||||
|
||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = FIND_WINDOW_TEMPLATE;
|
||||
|
||||
match_flags = cmd_find_window_match_flags(args);
|
||||
str = args->argv[0];
|
||||
|
||||
TAILQ_INIT(&find_list);
|
||||
|
||||
xasprintf(&searchstr, "*%s*", str);
|
||||
RB_FOREACH(wm, winlinks, &s->windows)
|
||||
cmd_find_window_match(&find_list, match_flags, wm, str, searchstr);
|
||||
free(searchstr);
|
||||
|
||||
if (TAILQ_EMPTY(&find_list)) {
|
||||
cmdq_error(cmdq, "no windows matching: %s", str);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
if (TAILQ_NEXT(TAILQ_FIRST(&find_list), entry) == NULL) {
|
||||
if (session_select(s, TAILQ_FIRST(&find_list)->wl->idx) == 0)
|
||||
server_redraw_session(s);
|
||||
recalculate_sizes();
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||
goto out;
|
||||
|
||||
i = 0;
|
||||
TAILQ_FOREACH(find_data, &find_list, entry) {
|
||||
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
||||
cdata->idx = find_data->wl->idx;
|
||||
cdata->wl = find_data->wl;
|
||||
|
||||
cdata->ft_template = xstrdup(template);
|
||||
cdata->pane_id = find_data->pane_id;
|
||||
|
||||
format_add(cdata->ft, "line", "%u", i);
|
||||
format_add(cdata->ft, "window_find_matches", "%s",
|
||||
find_data->list_ctx);
|
||||
format_defaults(cdata->ft, NULL, s, find_data->wl, NULL);
|
||||
|
||||
window_choose_add(wl->window->active, cdata);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
window_choose_ready(wl->window->active, 0, cmd_find_window_callback);
|
||||
|
||||
out:
|
||||
TAILQ_FOREACH_SAFE(find_data, &find_list, entry, find_data1) {
|
||||
free(find_data->list_ctx);
|
||||
TAILQ_REMOVE(&find_list, find_data, entry);
|
||||
free(find_data);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_find_window_callback(struct window_choose_data *cdata)
|
||||
{
|
||||
struct session *s;
|
||||
struct window_pane *wp;
|
||||
|
||||
if (cdata == NULL)
|
||||
return;
|
||||
|
||||
s = cdata->start_session;
|
||||
if (!session_alive(s))
|
||||
return;
|
||||
|
||||
wp = window_pane_at_index(cdata->wl->window, cdata->pane_id);
|
||||
if (wp != NULL && window_pane_visible(wp))
|
||||
window_set_active_pane(cdata->wl->window, wp);
|
||||
|
||||
if (session_select(s, cdata->idx) == 0) {
|
||||
server_redraw_session(s);
|
||||
recalculate_sizes();
|
||||
}
|
||||
}
|
||||
|
||||
1006
cmd-find.c
1006
cmd-find.c
File diff suppressed because it is too large
Load Diff
240
cmd-if-shell.c
240
cmd-if-shell.c
@@ -29,181 +29,193 @@
|
||||
* 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 *);
|
||||
void cmd_if_shell_done(struct cmd_q *);
|
||||
void cmd_if_shell_free(void *);
|
||||
static void cmd_if_shell_callback(struct job *);
|
||||
static void cmd_if_shell_free(void *);
|
||||
|
||||
const struct cmd_entry cmd_if_shell_entry = {
|
||||
"if-shell", "if",
|
||||
"bFt:", 2, 3,
|
||||
"[-bF] " CMD_TARGET_PANE_USAGE " shell-command command [command]",
|
||||
0,
|
||||
cmd_if_shell_exec
|
||||
.name = "if-shell",
|
||||
.alias = "if",
|
||||
|
||||
.args = { "bFt:", 2, 3 },
|
||||
.usage = "[-bF] " CMD_TARGET_PANE_USAGE " shell-command command "
|
||||
"[command]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_if_shell_exec
|
||||
};
|
||||
|
||||
struct cmd_if_shell_data {
|
||||
struct cmd_parse_input input;
|
||||
|
||||
char *cmd_if;
|
||||
char *cmd_else;
|
||||
|
||||
struct cmd_q *cmdq;
|
||||
struct client *client;
|
||||
struct cmdq_item *item;
|
||||
struct mouse_event mouse;
|
||||
|
||||
int bflag;
|
||||
int references;
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct mouse_event *m = &item->shared->mouse;
|
||||
struct cmd_if_shell_data *cdata;
|
||||
char *shellcmd, *cmd, *cause;
|
||||
struct cmd_list *cmdlist;
|
||||
struct client *c;
|
||||
struct session *s = NULL;
|
||||
struct winlink *wl = NULL;
|
||||
struct window_pane *wp = NULL;
|
||||
struct format_tree *ft;
|
||||
int cwd;
|
||||
|
||||
if (args_has(args, 't')) {
|
||||
wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
|
||||
cwd = wp->cwd;
|
||||
} else {
|
||||
c = cmd_find_client(cmdq, NULL, 1);
|
||||
if (c != NULL && c->session != NULL) {
|
||||
s = c->session;
|
||||
wl = s->curw;
|
||||
wp = wl->window->active;
|
||||
}
|
||||
if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||
cwd = cmdq->client->cwd;
|
||||
else if (s != NULL)
|
||||
cwd = s->cwd;
|
||||
else
|
||||
cwd = -1;
|
||||
}
|
||||
|
||||
ft = format_create();
|
||||
format_defaults(ft, NULL, s, wl, wp);
|
||||
shellcmd = format_expand(ft, args->argv[0]);
|
||||
format_free(ft);
|
||||
char *shellcmd, *cmd;
|
||||
struct cmdq_item *new_item;
|
||||
struct cmd_find_state *fs = &item->target;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = fs->s;
|
||||
struct winlink *wl = fs->wl;
|
||||
struct window_pane *wp = fs->wp;
|
||||
struct cmd_parse_input pi;
|
||||
struct cmd_parse_result *pr;
|
||||
|
||||
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];
|
||||
else
|
||||
cmd = NULL;
|
||||
free(shellcmd);
|
||||
if (cmd == NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
if (cmd_string_parse(cmd, &cmdlist, NULL, 0, &cause) != 0) {
|
||||
if (cause != NULL) {
|
||||
cmdq_error(cmdq, "%s", cause);
|
||||
free(cause);
|
||||
}
|
||||
|
||||
memset(&pi, 0, sizeof pi);
|
||||
if (self->file != NULL)
|
||||
pi.file = self->file;
|
||||
pi.line = self->line;
|
||||
pi.item = item;
|
||||
pi.c = c;
|
||||
cmd_find_copy_state(&pi.fs, fs);
|
||||
|
||||
pr = cmd_parse_from_string(cmd, &pi);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
break;
|
||||
case CMD_PARSE_ERROR:
|
||||
cmdq_error(item, "%s", pr->error);
|
||||
free(pr->error);
|
||||
return (CMD_RETURN_ERROR);
|
||||
case CMD_PARSE_SUCCESS:
|
||||
new_item = cmdq_get_command(pr->cmdlist, fs, m, 0);
|
||||
cmdq_insert_after(item, new_item);
|
||||
cmd_list_free(pr->cmdlist);
|
||||
break;
|
||||
}
|
||||
cmdq_run(cmdq, cmdlist, &cmdq->item->mouse);
|
||||
cmd_list_free(cmdlist);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
cdata = xmalloc(sizeof *cdata);
|
||||
cdata = xcalloc(1, sizeof *cdata);
|
||||
|
||||
cdata->cmd_if = xstrdup(args->argv[1]);
|
||||
if (args->argc == 3)
|
||||
cdata->cmd_else = xstrdup(args->argv[2]);
|
||||
else
|
||||
cdata->cmd_else = NULL;
|
||||
memcpy(&cdata->mouse, m, sizeof cdata->mouse);
|
||||
|
||||
cdata->bflag = args_has(args, 'b');
|
||||
if (!args_has(args, 'b'))
|
||||
cdata->client = item->client;
|
||||
else
|
||||
cdata->client = c;
|
||||
if (cdata->client != NULL)
|
||||
cdata->client->references++;
|
||||
|
||||
cdata->cmdq = cmdq;
|
||||
memcpy(&cdata->mouse, &cmdq->item->mouse, sizeof cdata->mouse);
|
||||
cmdq->references++;
|
||||
if (!args_has(args, 'b'))
|
||||
cdata->item = item;
|
||||
else
|
||||
cdata->item = NULL;
|
||||
|
||||
cdata->references = 1;
|
||||
job_run(shellcmd, s, cwd, cmd_if_shell_callback, cmd_if_shell_free,
|
||||
cdata);
|
||||
memset(&cdata->input, 0, sizeof cdata->input);
|
||||
if (self->file != NULL)
|
||||
cdata->input.file = xstrdup(self->file);
|
||||
cdata->input.line = self->line;
|
||||
cdata->input.item = cdata->item;
|
||||
cdata->input.c = c;
|
||||
if (cdata->input.c != NULL)
|
||||
cdata->input.c->references++;
|
||||
cmd_find_copy_state(&cdata->input.fs, fs);
|
||||
|
||||
if (job_run(shellcmd, s, server_client_get_cwd(item->client, s), NULL,
|
||||
cmd_if_shell_callback, cmd_if_shell_free, cdata, 0) == NULL) {
|
||||
cmdq_error(item, "failed to run command: %s", shellcmd);
|
||||
free(shellcmd);
|
||||
free(cdata);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
free(shellcmd);
|
||||
|
||||
if (cdata->bflag)
|
||||
if (args_has(args, 'b'))
|
||||
return (CMD_RETURN_NORMAL);
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
cmd_if_shell_callback(struct job *job)
|
||||
{
|
||||
struct cmd_if_shell_data *cdata = job->data;
|
||||
struct cmd_q *cmdq = cdata->cmdq, *cmdq1;
|
||||
struct cmd_list *cmdlist;
|
||||
char *cause, *cmd;
|
||||
struct cmd_if_shell_data *cdata = job_get_data(job);
|
||||
struct client *c = cdata->client;
|
||||
struct mouse_event *m = &cdata->mouse;
|
||||
struct cmdq_item *new_item = NULL;
|
||||
char *cmd;
|
||||
int status;
|
||||
struct cmd_parse_result *pr;
|
||||
|
||||
if (cmdq->flags & CMD_Q_DEAD)
|
||||
return;
|
||||
|
||||
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0)
|
||||
status = job_get_status(job);
|
||||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
||||
cmd = cdata->cmd_else;
|
||||
else
|
||||
cmd = cdata->cmd_if;
|
||||
if (cmd == NULL)
|
||||
return;
|
||||
goto out;
|
||||
|
||||
if (cmd_string_parse(cmd, &cmdlist, NULL, 0, &cause) != 0) {
|
||||
if (cause != NULL) {
|
||||
cmdq_error(cmdq, "%s", cause);
|
||||
free(cause);
|
||||
}
|
||||
return;
|
||||
pr = cmd_parse_from_string(cmd, &cdata->input);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
break;
|
||||
case CMD_PARSE_ERROR:
|
||||
if (cdata->item != NULL)
|
||||
cmdq_error(cdata->item, "%s", pr->error);
|
||||
free(pr->error);
|
||||
break;
|
||||
case CMD_PARSE_SUCCESS:
|
||||
new_item = cmdq_get_command(pr->cmdlist, NULL, m, 0);
|
||||
cmd_list_free(pr->cmdlist);
|
||||
break;
|
||||
}
|
||||
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);
|
||||
cmdq1->emptyfn = cmd_if_shell_done;
|
||||
cmdq1->data = cdata;
|
||||
|
||||
cdata->references++;
|
||||
cmdq_run(cmdq1, cmdlist, &cdata->mouse);
|
||||
cmd_list_free(cmdlist);
|
||||
out:
|
||||
if (cdata->item != NULL)
|
||||
cmdq_continue(cdata->item);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_if_shell_done(struct cmd_q *cmdq1)
|
||||
{
|
||||
struct cmd_if_shell_data *cdata = cmdq1->data;
|
||||
struct cmd_q *cmdq = cdata->cmdq;
|
||||
|
||||
if (cmdq1->client_exit >= 0)
|
||||
cmdq->client_exit = cmdq1->client_exit;
|
||||
cmdq_free(cmdq1);
|
||||
|
||||
if (--cdata->references != 0)
|
||||
return;
|
||||
|
||||
if (!cmdq_free(cmdq) && !cdata->bflag)
|
||||
cmdq_continue(cmdq);
|
||||
|
||||
free(cdata->cmd_else);
|
||||
free(cdata->cmd_if);
|
||||
free(cdata);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
cmd_if_shell_free(void *data)
|
||||
{
|
||||
struct cmd_if_shell_data *cdata = data;
|
||||
struct cmd_q *cmdq = cdata->cmdq;
|
||||
|
||||
if (--cdata->references != 0)
|
||||
return;
|
||||
|
||||
if (!cmdq_free(cmdq) && !cdata->bflag)
|
||||
cmdq_continue(cmdq);
|
||||
if (cdata->client != NULL)
|
||||
server_client_unref(cdata->client);
|
||||
|
||||
free(cdata->cmd_else);
|
||||
free(cdata->cmd_if);
|
||||
|
||||
if (cdata->input.c != NULL)
|
||||
server_client_unref(cdata->input.c);
|
||||
free((void *)cdata->input.file);
|
||||
|
||||
free(cdata);
|
||||
}
|
||||
|
||||
135
cmd-join-pane.c
135
cmd-join-pane.c
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
* 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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tmux.h"
|
||||
@@ -28,64 +29,76 @@
|
||||
* Join or move a pane into another (like split/swap/kill).
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
enum cmd_retval join_pane(struct cmd *, struct cmd_q *, int);
|
||||
static enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_join_pane_entry = {
|
||||
"join-pane", "joinp",
|
||||
"bdhvp:l:s:t:", 0, 0,
|
||||
"[-bdhv] [-p percentage|-l size] " CMD_SRCDST_PANE_USAGE,
|
||||
0,
|
||||
cmd_join_pane_exec
|
||||
.name = "join-pane",
|
||||
.alias = "joinp",
|
||||
|
||||
.args = { "bdfhvp:l:s:t:", 0, 0 },
|
||||
.usage = "[-bdfhv] [-l size] " CMD_SRCDST_PANE_USAGE,
|
||||
|
||||
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_join_pane_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_move_pane_entry = {
|
||||
"move-pane", "movep",
|
||||
"bdhvp:l:s:t:", 0, 0,
|
||||
"[-bdhv] [-p percentage|-l size] " CMD_SRCDST_PANE_USAGE,
|
||||
0,
|
||||
cmd_join_pane_exec
|
||||
.name = "move-pane",
|
||||
.alias = "movep",
|
||||
|
||||
.args = { "bdhvp:l:s:t:", 0, 0 },
|
||||
.usage = "[-bdhv] [-p percentage|-l size] " CMD_SRCDST_PANE_USAGE,
|
||||
|
||||
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_join_pane_exec
|
||||
};
|
||||
|
||||
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)
|
||||
static enum cmd_retval
|
||||
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct cmd_find_state *current = &item->shared->current;
|
||||
struct session *dst_s;
|
||||
struct winlink *src_wl, *dst_wl;
|
||||
struct window *src_w, *dst_w;
|
||||
struct window_pane *src_wp, *dst_wp;
|
||||
char *cause;
|
||||
int size, percentage, dst_idx;
|
||||
char *cause, *copy;
|
||||
const char *errstr, *p;
|
||||
size_t plen;
|
||||
int size, percentage, dst_idx, not_same_window;
|
||||
int flags;
|
||||
enum layout_type type;
|
||||
struct layout_cell *lc;
|
||||
|
||||
dst_wl = cmd_find_pane(cmdq, args_get(args, 't'), &dst_s, &dst_wp);
|
||||
if (dst_wl == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
if (self->entry == &cmd_join_pane_entry)
|
||||
not_same_window = 1;
|
||||
else
|
||||
not_same_window = 0;
|
||||
|
||||
dst_s = item->target.s;
|
||||
dst_wl = item->target.wl;
|
||||
dst_wp = item->target.wp;
|
||||
dst_w = dst_wl->window;
|
||||
dst_idx = dst_wl->idx;
|
||||
server_unzoom_window(dst_w);
|
||||
|
||||
src_wl = cmd_find_pane_marked(cmdq, args_get(args, 's'), NULL, &src_wp);
|
||||
if (src_wl == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
src_wl = item->source.wl;
|
||||
src_wp = item->source.wp;
|
||||
src_w = src_wl->window;
|
||||
server_unzoom_window(src_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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -94,17 +107,33 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
|
||||
type = LAYOUT_LEFTRIGHT;
|
||||
|
||||
size = -1;
|
||||
if (args_has(args, 'l')) {
|
||||
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(cmdq, "size %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
if ((p = args_get(args, 'l')) != NULL) {
|
||||
plen = strlen(p);
|
||||
if (p[plen - 1] == '%') {
|
||||
copy = xstrdup(p);
|
||||
copy[plen - 1] = '\0';
|
||||
percentage = strtonum(copy, 0, INT_MAX, &errstr);
|
||||
free(copy);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(item, "percentage %s", errstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (type == LAYOUT_TOPBOTTOM)
|
||||
size = (dst_wp->sy * percentage) / 100;
|
||||
else
|
||||
size = (dst_wp->sx * percentage) / 100;
|
||||
} else {
|
||||
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "size %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
} else if (args_has(args, 'p')) {
|
||||
percentage = args_strtonum(args, 'p', 0, 100, &cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(cmdq, "percentage %s", cause);
|
||||
cmdq_error(item, "percentage %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
@@ -113,9 +142,16 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
|
||||
else
|
||||
size = (dst_wp->sx * percentage) / 100;
|
||||
}
|
||||
lc = layout_split_pane(dst_wp, type, size, args_has(args, 'b'));
|
||||
|
||||
flags = 0;
|
||||
if (args_has(args, 'b'))
|
||||
flags |= SPAWN_BEFORE;
|
||||
if (args_has(args, 'f'))
|
||||
flags |= SPAWN_FULLSIZE;
|
||||
|
||||
lc = layout_split_pane(dst_wp, type, size, flags);
|
||||
if (lc == NULL) {
|
||||
cmdq_error(cmdq, "create pane failed: pane too small");
|
||||
cmdq_error(item, "create pane failed: pane too small");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
@@ -124,12 +160,9 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
|
||||
window_lost_pane(src_w, src_wp);
|
||||
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;
|
||||
options_set_parent(src_wp->options, dst_w->options);
|
||||
src_wp->flags |= PANE_STYLECHANGED;
|
||||
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
||||
layout_assign_pane(lc, src_wp);
|
||||
|
||||
@@ -139,12 +172,18 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
|
||||
server_redraw_window(dst_w);
|
||||
|
||||
if (!args_has(args, 'd')) {
|
||||
window_set_active_pane(dst_w, src_wp);
|
||||
window_set_active_pane(dst_w, src_wp, 1);
|
||||
session_select(dst_s, dst_idx);
|
||||
cmd_find_from_session(current, dst_s, 0);
|
||||
server_redraw_session(dst_s);
|
||||
} else
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -26,46 +26,39 @@
|
||||
* 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 = {
|
||||
"kill-pane", "killp",
|
||||
"at:", 0, 0,
|
||||
"[-a] " CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
cmd_kill_pane_exec
|
||||
.name = "kill-pane",
|
||||
.alias = "killp",
|
||||
|
||||
.args = { "at:", 0, 0 },
|
||||
.usage = "[-a] " CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_kill_pane_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_kill_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_kill_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl;
|
||||
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);
|
||||
|
||||
if (window_count_panes(wl->window) == 1) {
|
||||
/* Only one pane, kill the window. */
|
||||
server_kill_window(wl->window);
|
||||
recalculate_sizes();
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *loopwp, *tmpwp, *wp = item->target.wp;
|
||||
|
||||
if (args_has(self->args, 'a')) {
|
||||
server_unzoom_window(wl->window);
|
||||
TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) {
|
||||
if (loopwp == wp)
|
||||
continue;
|
||||
layout_close_pane(loopwp);
|
||||
window_remove_pane(wl->window, loopwp);
|
||||
}
|
||||
} else {
|
||||
layout_close_pane(wp);
|
||||
window_remove_pane(wl->window, wp);
|
||||
server_redraw_window(wl->window);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
server_redraw_window(wl->window);
|
||||
|
||||
server_kill_pane(wp);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -27,26 +27,32 @@
|
||||
* 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 = {
|
||||
"kill-server", NULL,
|
||||
"", 0, 0,
|
||||
"",
|
||||
0,
|
||||
cmd_kill_server_exec
|
||||
.name = "kill-server",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "", 0, 0 },
|
||||
.usage = "",
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_kill_server_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_start_server_entry = {
|
||||
"start-server", "start",
|
||||
"", 0, 0,
|
||||
"",
|
||||
CMD_STARTSERVER,
|
||||
cmd_kill_server_exec
|
||||
.name = "start-server",
|
||||
.alias = "start",
|
||||
|
||||
.args = { "", 0, 0 },
|
||||
.usage = "",
|
||||
|
||||
.flags = CMD_STARTSERVER,
|
||||
.exec = cmd_kill_server_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_kill_server_exec(struct cmd *self, unused struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_kill_server_exec(struct cmd *self, __unused struct cmdq_item *item)
|
||||
{
|
||||
if (self->entry == &cmd_kill_server_entry)
|
||||
kill(getpid(), SIGTERM);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -27,35 +27,46 @@
|
||||
* 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 = {
|
||||
"kill-session", NULL,
|
||||
"at:", 0, 0,
|
||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
cmd_kill_session_exec
|
||||
.name = "kill-session",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "aCt:", 0, 0 },
|
||||
.usage = "[-aC] " CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_kill_session_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_kill_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s, *sloop, *stmp;
|
||||
struct winlink *wl;
|
||||
|
||||
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
s = item->target.s;
|
||||
|
||||
if (args_has(args, 'a')) {
|
||||
if (args_has(args, 'C')) {
|
||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||
wl->window->flags &= ~WINDOW_ALERTFLAGS;
|
||||
wl->flags &= ~WINLINK_ALERTFLAGS;
|
||||
}
|
||||
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);
|
||||
session_destroy(sloop, 1, __func__);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
server_destroy_session(s);
|
||||
session_destroy(s);
|
||||
session_destroy(s, 1, __func__);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -24,39 +24,45 @@
|
||||
* 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 = {
|
||||
"kill-window", "killw",
|
||||
"at:", 0, 0,
|
||||
"[-a] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_kill_window_exec
|
||||
.name = "kill-window",
|
||||
.alias = "killw",
|
||||
|
||||
.args = { "at:", 0, 0 },
|
||||
.usage = "[-a] " CMD_TARGET_WINDOW_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_kill_window_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_unlink_window_entry = {
|
||||
"unlink-window", "unlinkw",
|
||||
"kt:", 0, 0,
|
||||
"[-k] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_kill_window_exec
|
||||
.name = "unlink-window",
|
||||
.alias = "unlinkw",
|
||||
|
||||
.args = { "kt:", 0, 0 },
|
||||
.usage = "[-k] " CMD_TARGET_WINDOW_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_kill_window_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_kill_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_kill_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl, *wl2, *wl3;
|
||||
struct window *w;
|
||||
struct session *s;
|
||||
|
||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
w = wl->window;
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl = item->target.wl, *wl2, *wl3;
|
||||
struct window *w = wl->window;
|
||||
struct session *s = item->target.s;
|
||||
|
||||
if (self->entry == &cmd_unlink_window_entry) {
|
||||
if (!args_has(self->args, 'k') && !session_is_linked(s, w)) {
|
||||
cmdq_error(cmdq, "window only linked to one session");
|
||||
cmdq_error(item, "window only linked to one session");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
server_unlink_window(s, wl);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -30,18 +30,21 @@
|
||||
#define LIST_BUFFERS_TEMPLATE \
|
||||
"#{buffer_name}: #{buffer_size} bytes: \"#{buffer_sample}\""
|
||||
|
||||
enum cmd_retval cmd_list_buffers_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_list_buffers_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_list_buffers_entry = {
|
||||
"list-buffers", "lsb",
|
||||
"F:", 0, 0,
|
||||
"[-F format]",
|
||||
0,
|
||||
cmd_list_buffers_exec
|
||||
.name = "list-buffers",
|
||||
.alias = "lsb",
|
||||
|
||||
.args = { "F:", 0, 0 },
|
||||
.usage = "[-F format]",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_list_buffers_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_list_buffers_exec(unused struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct paste_buffer *pb;
|
||||
@@ -54,11 +57,11 @@ cmd_list_buffers_exec(unused struct cmd *self, struct cmd_q *cmdq)
|
||||
|
||||
pb = NULL;
|
||||
while ((pb = paste_walk(pb)) != NULL) {
|
||||
ft = format_create();
|
||||
format_defaults_paste_buffer(ft, pb, 0);
|
||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
||||
format_defaults_paste_buffer(ft, pb);
|
||||
|
||||
line = format_expand(ft, template);
|
||||
cmdq_print(cmdq, "%s", line);
|
||||
cmdq_print(item, "%s", line);
|
||||
free(line);
|
||||
|
||||
format_free(ft);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -29,22 +29,27 @@
|
||||
*/
|
||||
|
||||
#define LIST_CLIENTS_TEMPLATE \
|
||||
"#{client_tty}: #{session_name} " \
|
||||
"#{client_name}: #{session_name} " \
|
||||
"[#{client_width}x#{client_height} #{client_termname}]" \
|
||||
"#{?client_utf8, (utf8),} #{?client_readonly, (ro),}"
|
||||
|
||||
enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_list_clients_entry = {
|
||||
"list-clients", "lsc",
|
||||
"F:t:", 0, 0,
|
||||
"[-F format] " CMD_TARGET_SESSION_USAGE,
|
||||
CMD_READONLY,
|
||||
cmd_list_clients_exec
|
||||
.name = "list-clients",
|
||||
.alias = "lsc",
|
||||
|
||||
.args = { "F:t:", 0, 0 },
|
||||
.usage = "[-F format] " CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||
|
||||
.flags = CMD_READONLY|CMD_AFTERHOOK,
|
||||
.exec = cmd_list_clients_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
@@ -54,11 +59,9 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
u_int idx;
|
||||
char *line;
|
||||
|
||||
if (args_has(args, 't')) {
|
||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
||||
if (s == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
} else
|
||||
if (args_has(args, 't'))
|
||||
s = item->target.s;
|
||||
else
|
||||
s = NULL;
|
||||
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
@@ -69,12 +72,12 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
if (c->session == NULL || (s != NULL && s != c->session))
|
||||
continue;
|
||||
|
||||
ft = format_create();
|
||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
||||
format_add(ft, "line", "%u", idx);
|
||||
format_defaults(ft, c, NULL, NULL, NULL);
|
||||
|
||||
line = format_expand(ft, template);
|
||||
cmdq_print(cmdq, "%s", line);
|
||||
cmdq_print(item, "%s", line);
|
||||
free(line);
|
||||
|
||||
format_free(ft);
|
||||
|
||||
365
cmd-list-keys.c
365
cmd-list-keys.c
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
@@ -26,168 +27,324 @@
|
||||
* 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 *);
|
||||
enum cmd_retval cmd_list_keys_commands(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 = {
|
||||
"list-keys", "lsk",
|
||||
"t:T:", 0, 0,
|
||||
"[-t mode-table] [-T key-table]",
|
||||
0,
|
||||
cmd_list_keys_exec
|
||||
.name = "list-keys",
|
||||
.alias = "lsk",
|
||||
|
||||
.args = { "1NP:T:", 0, 1 },
|
||||
.usage = "[-1N] [-P prefix-string] [-T key-table] [key]",
|
||||
|
||||
.flags = CMD_STARTSERVER|CMD_AFTERHOOK,
|
||||
.exec = cmd_list_keys_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_list_commands_entry = {
|
||||
"list-commands", "lscm",
|
||||
"", 0, 0,
|
||||
"",
|
||||
0,
|
||||
cmd_list_keys_exec
|
||||
.name = "list-commands",
|
||||
.alias = "lscm",
|
||||
|
||||
.args = { "F:", 0, 0 },
|
||||
.usage = "[-F format]",
|
||||
|
||||
.flags = CMD_STARTSERVER|CMD_AFTERHOOK,
|
||||
.exec = cmd_list_keys_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static u_int
|
||||
cmd_list_keys_get_width(const char *tablename, key_code only)
|
||||
{
|
||||
struct key_table *table;
|
||||
struct key_binding *bd;
|
||||
u_int width, keywidth = 0;
|
||||
|
||||
table = key_bindings_get_table(tablename, 0);
|
||||
if (table == NULL)
|
||||
return (0);
|
||||
bd = key_bindings_first(table);
|
||||
while (bd != NULL) {
|
||||
if ((only != KEYC_UNKNOWN && bd->key != only) ||
|
||||
KEYC_IS_MOUSE(bd->key) ||
|
||||
bd->note == NULL) {
|
||||
bd = key_bindings_next(table, bd);
|
||||
continue;
|
||||
}
|
||||
width = utf8_cstrwidth(key_string_lookup_key(bd->key));
|
||||
if (width > keywidth)
|
||||
keywidth = width;
|
||||
|
||||
bd = key_bindings_next(table, bd);
|
||||
}
|
||||
return (keywidth);
|
||||
}
|
||||
|
||||
static int
|
||||
cmd_list_keys_print_notes(struct cmdq_item *item, struct args *args,
|
||||
const char *tablename, u_int keywidth, key_code only, const char *prefix)
|
||||
{
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct key_table *table;
|
||||
struct key_binding *bd;
|
||||
const char *key;
|
||||
char *tmp;
|
||||
int found = 0;
|
||||
|
||||
table = key_bindings_get_table(tablename, 0);
|
||||
if (table == NULL)
|
||||
return (0);
|
||||
bd = key_bindings_first(table);
|
||||
while (bd != NULL) {
|
||||
if ((only != KEYC_UNKNOWN && bd->key != only) ||
|
||||
KEYC_IS_MOUSE(bd->key) ||
|
||||
bd->note == NULL) {
|
||||
bd = key_bindings_next(table, bd);
|
||||
continue;
|
||||
}
|
||||
found = 1;
|
||||
key = key_string_lookup_key(bd->key);
|
||||
|
||||
tmp = utf8_padcstr(key, keywidth + 1);
|
||||
if (args_has(args, '1') && c != NULL)
|
||||
status_message_set(c, "%s%s%s", prefix, tmp, bd->note);
|
||||
else
|
||||
cmdq_print(item, "%s%s%s", prefix, tmp, bd->note);
|
||||
free(tmp);
|
||||
|
||||
if (args_has(args, '1'))
|
||||
break;
|
||||
bd = key_bindings_next(table, bd);
|
||||
}
|
||||
return (found);
|
||||
}
|
||||
|
||||
static char *
|
||||
cmd_list_keys_get_prefix(struct args *args, key_code *prefix)
|
||||
{
|
||||
char *s;
|
||||
|
||||
*prefix = options_get_number(global_s_options, "prefix");
|
||||
if (!args_has(args, 'P')) {
|
||||
if (*prefix != KEYC_NONE)
|
||||
xasprintf(&s, "%s ", key_string_lookup_key(*prefix));
|
||||
else
|
||||
s = xstrdup("");
|
||||
} else
|
||||
s = xstrdup(args_get(args, 'P'));
|
||||
return (s);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct key_table *table;
|
||||
struct key_binding *bd;
|
||||
const char *key, *tablename, *r;
|
||||
char tmp[BUFSIZ];
|
||||
size_t used;
|
||||
int repeat, width, tablewidth, keywidth;
|
||||
const char *tablename, *r;
|
||||
char *key, *cp, *tmp, *start, *empty;
|
||||
key_code prefix, only = KEYC_UNKNOWN;
|
||||
int repeat, width, tablewidth, keywidth, found = 0;
|
||||
size_t tmpsize, tmpused, cplen;
|
||||
|
||||
if (self->entry == &cmd_list_commands_entry)
|
||||
return (cmd_list_keys_commands(self, cmdq));
|
||||
return (cmd_list_keys_commands(self, item));
|
||||
|
||||
if (args_has(args, 't'))
|
||||
return (cmd_list_keys_table(self, cmdq));
|
||||
if (args->argc != 0) {
|
||||
only = key_string_lookup_string(args->argv[0]);
|
||||
if (only == KEYC_UNKNOWN) {
|
||||
cmdq_error(item, "invalid key: %s", args->argv[0]);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
tablename = args_get(args, 'T');
|
||||
if (tablename != NULL && key_bindings_get_table(tablename, 0) == NULL) {
|
||||
cmdq_error(cmdq, "table %s doesn't exist", tablename);
|
||||
cmdq_error(item, "table %s doesn't exist", tablename);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
if (args_has(args, 'N')) {
|
||||
if (tablename == NULL) {
|
||||
start = cmd_list_keys_get_prefix(args, &prefix);
|
||||
keywidth = cmd_list_keys_get_width("root", only);
|
||||
if (prefix != KEYC_NONE) {
|
||||
width = cmd_list_keys_get_width("prefix", only);
|
||||
if (width == 0)
|
||||
prefix = KEYC_NONE;
|
||||
else if (width > keywidth)
|
||||
keywidth = width;
|
||||
}
|
||||
empty = utf8_padcstr("", utf8_cstrwidth(start));
|
||||
|
||||
found = cmd_list_keys_print_notes(item, args, "root",
|
||||
keywidth, only, empty);
|
||||
if (prefix != KEYC_NONE) {
|
||||
if (cmd_list_keys_print_notes(item, args,
|
||||
"prefix", keywidth, only, start))
|
||||
found = 1;
|
||||
}
|
||||
free(empty);
|
||||
} else {
|
||||
if (args_has(args, 'P'))
|
||||
start = xstrdup(args_get(args, 'P'));
|
||||
else
|
||||
start = xstrdup("");
|
||||
keywidth = cmd_list_keys_get_width(tablename, only);
|
||||
found = cmd_list_keys_print_notes(item, args, tablename,
|
||||
keywidth, only, start);
|
||||
|
||||
}
|
||||
free(start);
|
||||
goto out;
|
||||
}
|
||||
|
||||
repeat = 0;
|
||||
tablewidth = keywidth = 0;
|
||||
RB_FOREACH(table, key_tables, &key_tables) {
|
||||
if (tablename != NULL && strcmp(table->name, tablename) != 0)
|
||||
table = key_bindings_first_table ();
|
||||
while (table != NULL) {
|
||||
if (tablename != NULL && strcmp(table->name, tablename) != 0) {
|
||||
table = key_bindings_next_table(table);
|
||||
continue;
|
||||
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
|
||||
key = key_string_lookup_key(bd->key);
|
||||
if (key == NULL)
|
||||
}
|
||||
bd = key_bindings_first(table);
|
||||
while (bd != NULL) {
|
||||
if (only != KEYC_UNKNOWN && bd->key != only) {
|
||||
bd = key_bindings_next(table, bd);
|
||||
continue;
|
||||
}
|
||||
key = args_escape(key_string_lookup_key(bd->key));
|
||||
|
||||
if (bd->can_repeat)
|
||||
if (bd->flags & KEY_BINDING_REPEAT)
|
||||
repeat = 1;
|
||||
|
||||
width = strlen(table->name);
|
||||
width = utf8_cstrwidth(table->name);
|
||||
if (width > tablewidth)
|
||||
tablewidth =width;
|
||||
width = strlen(key);
|
||||
tablewidth = width;
|
||||
width = utf8_cstrwidth(key);
|
||||
if (width > keywidth)
|
||||
keywidth = width;
|
||||
|
||||
free(key);
|
||||
bd = key_bindings_next(table, bd);
|
||||
}
|
||||
table = key_bindings_next_table(table);
|
||||
}
|
||||
|
||||
RB_FOREACH(table, key_tables, &key_tables) {
|
||||
if (tablename != NULL && strcmp(table->name, tablename) != 0)
|
||||
tmpsize = 256;
|
||||
tmp = xmalloc(tmpsize);
|
||||
|
||||
table = key_bindings_first_table ();
|
||||
while (table != NULL) {
|
||||
if (tablename != NULL && strcmp(table->name, tablename) != 0) {
|
||||
table = key_bindings_next_table(table);
|
||||
continue;
|
||||
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
|
||||
key = key_string_lookup_key(bd->key);
|
||||
if (key == NULL)
|
||||
}
|
||||
bd = key_bindings_first(table);
|
||||
while (bd != NULL) {
|
||||
if (only != KEYC_UNKNOWN && bd->key != only) {
|
||||
bd = key_bindings_next(table, bd);
|
||||
continue;
|
||||
}
|
||||
found = 1;
|
||||
key = args_escape(key_string_lookup_key(bd->key));
|
||||
|
||||
if (!repeat)
|
||||
r = "";
|
||||
else if (bd->can_repeat)
|
||||
else if (bd->flags & KEY_BINDING_REPEAT)
|
||||
r = "-r ";
|
||||
else
|
||||
r = " ";
|
||||
used = xsnprintf(tmp, sizeof tmp, "%s-T %-*s %-*s ", r,
|
||||
(int)tablewidth, table->name, (int)keywidth, key);
|
||||
if (used < sizeof tmp) {
|
||||
cmd_list_print(bd->cmdlist, tmp + used,
|
||||
(sizeof tmp) - used);
|
||||
}
|
||||
tmpused = xsnprintf(tmp, tmpsize, "%s-T ", r);
|
||||
|
||||
cmdq_print(cmdq, "bind-key %s", tmp);
|
||||
cp = utf8_padcstr(table->name, tablewidth);
|
||||
cplen = strlen(cp) + 1;
|
||||
while (tmpused + cplen + 1 >= tmpsize) {
|
||||
tmpsize *= 2;
|
||||
tmp = xrealloc(tmp, tmpsize);
|
||||
}
|
||||
tmpused = strlcat(tmp, cp, tmpsize);
|
||||
tmpused = strlcat(tmp, " ", tmpsize);
|
||||
free(cp);
|
||||
|
||||
cp = utf8_padcstr(key, keywidth);
|
||||
cplen = strlen(cp) + 1;
|
||||
while (tmpused + cplen + 1 >= tmpsize) {
|
||||
tmpsize *= 2;
|
||||
tmp = xrealloc(tmp, tmpsize);
|
||||
}
|
||||
tmpused = strlcat(tmp, cp, tmpsize);
|
||||
tmpused = strlcat(tmp, " ", tmpsize);
|
||||
free(cp);
|
||||
|
||||
cp = cmd_list_print(bd->cmdlist, 1);
|
||||
cplen = strlen(cp);
|
||||
while (tmpused + cplen + 1 >= tmpsize) {
|
||||
tmpsize *= 2;
|
||||
tmp = xrealloc(tmp, tmpsize);
|
||||
}
|
||||
strlcat(tmp, cp, tmpsize);
|
||||
free(cp);
|
||||
|
||||
cmdq_print(item, "bind-key %s", tmp);
|
||||
|
||||
free(key);
|
||||
bd = key_bindings_next(table, bd);
|
||||
}
|
||||
table = key_bindings_next_table(table);
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
free(tmp);
|
||||
|
||||
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);
|
||||
out:
|
||||
if (only != KEYC_UNKNOWN && !found) {
|
||||
cmdq_error(item, "unknown key: %s", args->argv[0]);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
width = 0;
|
||||
any_mode = 0;
|
||||
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
||||
key = key_string_lookup_key(mbind->key);
|
||||
if (key == NULL)
|
||||
continue;
|
||||
|
||||
if (mbind->mode != 0)
|
||||
any_mode = 1;
|
||||
|
||||
keywidth = strlen(key);
|
||||
if (keywidth > width)
|
||||
width = keywidth;
|
||||
}
|
||||
|
||||
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
||||
key = key_string_lookup_key(mbind->key);
|
||||
if (key == NULL)
|
||||
continue;
|
||||
|
||||
mode = "";
|
||||
if (mbind->mode != 0)
|
||||
mode = "c";
|
||||
cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd);
|
||||
if (cmdstr != NULL) {
|
||||
cmdq_print(cmdq, "bind-key -%st %s%s %*s %s%s%s%s",
|
||||
mode, any_mode && *mode == '\0' ? " " : "",
|
||||
mtab->name, (int) width, key, cmdstr,
|
||||
mbind->arg != NULL ? " \"" : "",
|
||||
mbind->arg != NULL ? mbind->arg : "",
|
||||
mbind->arg != NULL ? "\"": "");
|
||||
}
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_list_keys_commands(unused struct cmd *self, struct cmd_q *cmdq)
|
||||
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->client, item, FORMAT_NONE, 0);
|
||||
format_defaults(ft, NULL, NULL, NULL, NULL);
|
||||
|
||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
||||
entry = *entryp;
|
||||
if (entry->alias == NULL) {
|
||||
cmdq_print(cmdq, "%s %s", entry->name, entry->usage);
|
||||
continue;
|
||||
}
|
||||
cmdq_print(cmdq, "%s (%s) %s", entry->name, entry->alias,
|
||||
entry->usage);
|
||||
|
||||
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 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -26,68 +26,66 @@
|
||||
* 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 *);
|
||||
void cmd_list_panes_session(struct cmd *, struct session *, struct cmd_q *,
|
||||
int);
|
||||
void cmd_list_panes_window(struct cmd *, struct session *, struct winlink *,
|
||||
struct cmd_q *, int);
|
||||
static void cmd_list_panes_server(struct cmd *, struct cmdq_item *);
|
||||
static void cmd_list_panes_session(struct cmd *, struct session *,
|
||||
struct cmdq_item *, int);
|
||||
static void cmd_list_panes_window(struct cmd *, struct session *,
|
||||
struct winlink *, struct cmdq_item *, int);
|
||||
|
||||
const struct cmd_entry cmd_list_panes_entry = {
|
||||
"list-panes", "lsp",
|
||||
"asF:t:", 0, 0,
|
||||
"[-as] [-F format] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_list_panes_exec
|
||||
.name = "list-panes",
|
||||
.alias = "lsp",
|
||||
|
||||
.args = { "asF:t:", 0, 0 },
|
||||
.usage = "[-as] [-F format] " CMD_TARGET_WINDOW_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_list_panes_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_list_panes_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_list_panes_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
|
||||
if (args_has(args, 'a'))
|
||||
cmd_list_panes_server(self, cmdq);
|
||||
else if (args_has(args, 's')) {
|
||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
||||
if (s == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
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);
|
||||
}
|
||||
cmd_list_panes_server(self, item);
|
||||
else if (args_has(args, 's'))
|
||||
cmd_list_panes_session(self, s, item, 1);
|
||||
else
|
||||
cmd_list_panes_window(self, s, wl, item, 0);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_list_panes_server(struct cmd *self, struct cmd_q *cmdq)
|
||||
static void
|
||||
cmd_list_panes_server(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct session *s;
|
||||
|
||||
RB_FOREACH(s, sessions, &sessions)
|
||||
cmd_list_panes_session(self, s, cmdq, 2);
|
||||
cmd_list_panes_session(self, s, item, 2);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_list_panes_session(struct cmd *self, struct session *s, struct cmd_q *cmdq,
|
||||
int type)
|
||||
static void
|
||||
cmd_list_panes_session(struct cmd *self, struct session *s,
|
||||
struct cmdq_item *item, int type)
|
||||
{
|
||||
struct winlink *wl;
|
||||
|
||||
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, struct session *s, struct winlink *wl,
|
||||
struct cmd_q *cmdq, int type)
|
||||
struct cmdq_item *item, int type)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct window_pane *wp;
|
||||
@@ -125,12 +123,12 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
|
||||
|
||||
n = 0;
|
||||
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||
ft = format_create();
|
||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
||||
format_add(ft, "line", "%u", n);
|
||||
format_defaults(ft, NULL, s, wl, wp);
|
||||
|
||||
line = format_expand(ft, template);
|
||||
cmdq_print(cmdq, "%s", line);
|
||||
cmdq_print(item, "%s", line);
|
||||
free(line);
|
||||
|
||||
format_free(ft);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -30,24 +30,27 @@
|
||||
|
||||
#define LIST_SESSIONS_TEMPLATE \
|
||||
"#{session_name}: #{session_windows} windows " \
|
||||
"(created #{session_created_string}) " \
|
||||
"[#{session_width}x#{session_height}]" \
|
||||
"(created #{t:session_created})" \
|
||||
"#{?session_grouped, (group ,}" \
|
||||
"#{session_group}#{?session_grouped,),}" \
|
||||
"#{?session_attached, (attached),}"
|
||||
|
||||
enum cmd_retval cmd_list_sessions_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_list_sessions_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_list_sessions_entry = {
|
||||
"list-sessions", "ls",
|
||||
"F:", 0, 0,
|
||||
"[-F format]",
|
||||
0,
|
||||
cmd_list_sessions_exec
|
||||
.name = "list-sessions",
|
||||
.alias = "ls",
|
||||
|
||||
.args = { "F:", 0, 0 },
|
||||
.usage = "[-F format]",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_list_sessions_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_list_sessions_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s;
|
||||
@@ -61,12 +64,12 @@ cmd_list_sessions_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
|
||||
n = 0;
|
||||
RB_FOREACH(s, sessions, &sessions) {
|
||||
ft = format_create();
|
||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
||||
format_add(ft, "line", "%u", n);
|
||||
format_defaults(ft, NULL, s, NULL, NULL);
|
||||
|
||||
line = format_expand(ft, template);
|
||||
cmdq_print(cmdq, "%s", line);
|
||||
cmdq_print(item, "%s", line);
|
||||
free(line);
|
||||
|
||||
format_free(ft);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -39,54 +39,54 @@
|
||||
"(#{window_panes} panes) " \
|
||||
"[#{window_width}x#{window_height}] "
|
||||
|
||||
enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
void cmd_list_windows_server(struct cmd *, struct cmd_q *);
|
||||
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 = {
|
||||
"list-windows", "lsw",
|
||||
"F:at:", 0, 0,
|
||||
"[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
cmd_list_windows_exec
|
||||
.name = "list-windows",
|
||||
.alias = "lsw",
|
||||
|
||||
.args = { "F:at:", 0, 0 },
|
||||
.usage = "[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_list_windows_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_list_windows_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_list_windows_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s;
|
||||
|
||||
if (args_has(args, 'a'))
|
||||
cmd_list_windows_server(self, cmdq);
|
||||
else {
|
||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
||||
if (s == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
cmd_list_windows_session(self, s, cmdq, 0);
|
||||
}
|
||||
cmd_list_windows_server(self, item);
|
||||
else
|
||||
cmd_list_windows_session(self, item->target.s, item, 0);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_list_windows_server(struct cmd *self, struct cmd_q *cmdq)
|
||||
static void
|
||||
cmd_list_windows_server(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct session *s;
|
||||
|
||||
RB_FOREACH(s, sessions, &sessions)
|
||||
cmd_list_windows_session(self, s, cmdq, 1);
|
||||
cmd_list_windows_session(self, s, item, 1);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_list_windows_session(
|
||||
struct cmd *self, struct session *s, struct cmd_q *cmdq, int type)
|
||||
static void
|
||||
cmd_list_windows_session(struct cmd *self, struct session *s,
|
||||
struct cmdq_item *item, int type)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl;
|
||||
u_int n;
|
||||
u_int n;
|
||||
struct format_tree *ft;
|
||||
const char *template;
|
||||
char *line;
|
||||
@@ -105,12 +105,12 @@ cmd_list_windows_session(
|
||||
|
||||
n = 0;
|
||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||
ft = format_create();
|
||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
||||
format_add(ft, "line", "%u", n);
|
||||
format_defaults(ft, NULL, s, wl, NULL);
|
||||
|
||||
line = format_expand(ft, template);
|
||||
cmdq_print(cmdq, "%s", line);
|
||||
cmdq_print(item, "%s", line);
|
||||
free(line);
|
||||
|
||||
format_free(ft);
|
||||
|
||||
123
cmd-list.c
123
cmd-list.c
@@ -1,123 +0,0 @@
|
||||
/* $OpenBSD$ */
|
||||
|
||||
/*
|
||||
* 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"
|
||||
|
||||
struct cmd_list *
|
||||
cmd_list_parse(int argc, char **argv, const char *file, u_int line,
|
||||
char **cause)
|
||||
{
|
||||
struct cmd_list *cmdlist;
|
||||
struct cmd *cmd;
|
||||
int i, lastsplit;
|
||||
size_t arglen, new_argc;
|
||||
char **copy_argv, **new_argv;
|
||||
|
||||
copy_argv = cmd_copy_argv(argc, argv);
|
||||
|
||||
cmdlist = xcalloc(1, sizeof *cmdlist);
|
||||
cmdlist->references = 1;
|
||||
TAILQ_INIT(&cmdlist->list);
|
||||
|
||||
lastsplit = 0;
|
||||
for (i = 0; i < argc; i++) {
|
||||
arglen = strlen(copy_argv[i]);
|
||||
if (arglen == 0 || copy_argv[i][arglen - 1] != ';')
|
||||
continue;
|
||||
copy_argv[i][arglen - 1] = '\0';
|
||||
|
||||
if (arglen > 1 && copy_argv[i][arglen - 2] == '\\') {
|
||||
copy_argv[i][arglen - 2] = ';';
|
||||
continue;
|
||||
}
|
||||
|
||||
new_argc = i - lastsplit;
|
||||
new_argv = copy_argv + lastsplit;
|
||||
if (arglen != 1)
|
||||
new_argc++;
|
||||
|
||||
cmd = cmd_parse(new_argc, new_argv, file, line, cause);
|
||||
if (cmd == NULL)
|
||||
goto bad;
|
||||
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
||||
|
||||
lastsplit = i + 1;
|
||||
}
|
||||
|
||||
if (lastsplit != argc) {
|
||||
cmd = cmd_parse(argc - lastsplit, copy_argv + lastsplit,
|
||||
file, line, cause);
|
||||
if (cmd == NULL)
|
||||
goto bad;
|
||||
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
||||
}
|
||||
|
||||
cmd_free_argv(argc, copy_argv);
|
||||
return (cmdlist);
|
||||
|
||||
bad:
|
||||
cmd_list_free(cmdlist);
|
||||
cmd_free_argv(argc, copy_argv);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_list_free(struct cmd_list *cmdlist)
|
||||
{
|
||||
struct cmd *cmd, *cmd1;
|
||||
|
||||
if (--cmdlist->references != 0)
|
||||
return;
|
||||
|
||||
TAILQ_FOREACH_SAFE(cmd, &cmdlist->list, qentry, cmd1) {
|
||||
TAILQ_REMOVE(&cmdlist->list, cmd, qentry);
|
||||
args_free(cmd->args);
|
||||
free(cmd->file);
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
free(cmdlist);
|
||||
}
|
||||
|
||||
size_t
|
||||
cmd_list_print(struct cmd_list *cmdlist, char *buf, size_t len)
|
||||
{
|
||||
struct cmd *cmd;
|
||||
size_t off, used;
|
||||
|
||||
off = 0;
|
||||
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||
if (off >= len)
|
||||
break;
|
||||
off += cmd_print(cmd, buf + off, len - off);
|
||||
if (off >= len)
|
||||
break;
|
||||
if (TAILQ_NEXT(cmd, qentry) != NULL) {
|
||||
used = xsnprintf(buf + off, len - off, " ; ");
|
||||
if (used > len - off)
|
||||
used = len - off;
|
||||
off += used;
|
||||
}
|
||||
}
|
||||
return (off);
|
||||
}
|
||||
@@ -31,127 +31,77 @@
|
||||
* Loads a paste buffer from a file.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmd_q *);
|
||||
void cmd_load_buffer_callback(struct client *, int, void *);
|
||||
static enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_load_buffer_entry = {
|
||||
"load-buffer", "loadb",
|
||||
"b:", 1, 1,
|
||||
CMD_BUFFER_USAGE " path",
|
||||
0,
|
||||
cmd_load_buffer_exec
|
||||
.name = "load-buffer",
|
||||
.alias = "loadb",
|
||||
|
||||
.args = { "b:", 1, 1 },
|
||||
.usage = CMD_BUFFER_USAGE " path",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_load_buffer_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
struct cmd_load_buffer_data {
|
||||
struct cmdq_item *item;
|
||||
char *name;
|
||||
};
|
||||
|
||||
static void
|
||||
cmd_load_buffer_done(__unused struct client *c, const char *path, int error,
|
||||
int closed, struct evbuffer *buffer, void *data)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c = cmdq->client;
|
||||
struct session *s;
|
||||
FILE *f;
|
||||
const char *path, *bufname;
|
||||
char *pdata, *new_pdata, *cause;
|
||||
size_t psize;
|
||||
int ch, error, cwd, fd;
|
||||
|
||||
bufname = NULL;
|
||||
if (args_has(args, 'b'))
|
||||
bufname = args_get(args, 'b');
|
||||
|
||||
path = args->argv[0];
|
||||
if (strcmp(path, "-") == 0) {
|
||||
error = server_set_stdin_callback(c, cmd_load_buffer_callback,
|
||||
(void *)bufname, &cause);
|
||||
if (error != 0) {
|
||||
cmdq_error(cmdq, "%s: %s", path, cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
|
||||
if (c != NULL && c->session == NULL)
|
||||
cwd = c->cwd;
|
||||
else if ((s = cmd_find_current(cmdq)) != NULL)
|
||||
cwd = s->cwd;
|
||||
else
|
||||
cwd = AT_FDCWD;
|
||||
|
||||
if ((fd = openat(cwd, path, O_RDONLY)) == -1 ||
|
||||
(f = fdopen(fd, "rb")) == NULL) {
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
cmdq_error(cmdq, "%s: %s", path, strerror(errno));
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
pdata = NULL;
|
||||
psize = 0;
|
||||
while ((ch = getc(f)) != EOF) {
|
||||
/* Do not let the server die due to memory exhaustion. */
|
||||
if ((new_pdata = realloc(pdata, psize + 2)) == NULL) {
|
||||
cmdq_error(cmdq, "realloc error: %s", strerror(errno));
|
||||
goto error;
|
||||
}
|
||||
pdata = new_pdata;
|
||||
pdata[psize++] = ch;
|
||||
}
|
||||
if (ferror(f)) {
|
||||
cmdq_error(cmdq, "%s: read error", path);
|
||||
goto error;
|
||||
}
|
||||
if (pdata != NULL)
|
||||
pdata[psize] = '\0';
|
||||
|
||||
fclose(f);
|
||||
|
||||
if (paste_set(pdata, psize, bufname, &cause) != 0) {
|
||||
cmdq_error(cmdq, "%s", cause);
|
||||
free(pdata);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
error:
|
||||
free(pdata);
|
||||
if (f != NULL)
|
||||
fclose(f);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_load_buffer_callback(struct client *c, int closed, void *data)
|
||||
{
|
||||
const char *bufname = data;
|
||||
char *pdata, *cause;
|
||||
size_t psize;
|
||||
struct cmd_load_buffer_data *cdata = data;
|
||||
struct cmdq_item *item = cdata->item;
|
||||
void *bdata = EVBUFFER_DATA(buffer);
|
||||
size_t bsize = EVBUFFER_LENGTH(buffer);
|
||||
void *copy;
|
||||
char *cause;
|
||||
|
||||
if (!closed)
|
||||
return;
|
||||
c->stdin_callback = NULL;
|
||||
|
||||
server_client_unref(c);
|
||||
if (c->flags & CLIENT_DEAD)
|
||||
return;
|
||||
|
||||
psize = EVBUFFER_LENGTH(c->stdin_data);
|
||||
if (psize == 0 || (pdata = malloc(psize + 1)) == NULL)
|
||||
goto out;
|
||||
|
||||
memcpy(pdata, EVBUFFER_DATA(c->stdin_data), psize);
|
||||
pdata[psize] = '\0';
|
||||
evbuffer_drain(c->stdin_data, psize);
|
||||
|
||||
if (paste_set(pdata, psize, bufname, &cause) != 0) {
|
||||
/* No context so can't use server_client_msg_error. */
|
||||
evbuffer_add_printf(c->stderr_data, "%s", cause);
|
||||
server_push_stderr(c);
|
||||
free(pdata);
|
||||
free(cause);
|
||||
if (error != 0)
|
||||
cmdq_error(item, "%s: %s", path, strerror(error));
|
||||
else if (bsize != 0) {
|
||||
copy = xmalloc(bsize);
|
||||
memcpy(copy, bdata, bsize);
|
||||
if (paste_set(copy, bsize, cdata->name, &cause) != 0) {
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
free(copy);
|
||||
}
|
||||
}
|
||||
cmdq_continue(item);
|
||||
|
||||
out:
|
||||
cmdq_continue(c->cmdq);
|
||||
free(cdata->name);
|
||||
free(cdata);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct cmd_load_buffer_data *cdata;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
const char *bufname = args_get(args, 'b');
|
||||
char *path;
|
||||
|
||||
cdata = xmalloc(sizeof *cdata);
|
||||
cdata->item = item;
|
||||
if (bufname != NULL)
|
||||
cdata->name = xstrdup(bufname);
|
||||
else
|
||||
cdata->name = NULL;
|
||||
|
||||
path = format_single(item, args->argv[0], c, s, wl, wp);
|
||||
file_read(item->client, path, cmd_load_buffer_done, cdata);
|
||||
free(path);
|
||||
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -24,49 +24,55 @@
|
||||
* 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 = {
|
||||
"lock-server", "lock",
|
||||
"", 0, 0,
|
||||
"",
|
||||
0,
|
||||
cmd_lock_server_exec
|
||||
.name = "lock-server",
|
||||
.alias = "lock",
|
||||
|
||||
.args = { "", 0, 0 },
|
||||
.usage = "",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_lock_server_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_lock_session_entry = {
|
||||
"lock-session", "locks",
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
cmd_lock_server_exec
|
||||
.name = "lock-session",
|
||||
.alias = "locks",
|
||||
|
||||
.args = { "t:", 0, 0 },
|
||||
.usage = CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_lock_server_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_lock_client_entry = {
|
||||
"lock-client", "lockc",
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_CLIENT_USAGE,
|
||||
0,
|
||||
cmd_lock_server_exec
|
||||
.name = "lock-client",
|
||||
.alias = "lockc",
|
||||
|
||||
.args = { "t:", 0, 0 },
|
||||
.usage = CMD_TARGET_CLIENT_USAGE,
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_lock_server_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_lock_server_exec(struct cmd *self, unused struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_lock_server_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
struct session *s;
|
||||
|
||||
if (self->entry == &cmd_lock_server_entry)
|
||||
server_lock();
|
||||
else if (self->entry == &cmd_lock_session_entry) {
|
||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
||||
if (s == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
server_lock_session(s);
|
||||
} else {
|
||||
c = cmd_find_client(cmdq, args_get(args, 't'), 0);
|
||||
if (c == NULL)
|
||||
else if (self->entry == &cmd_lock_session_entry)
|
||||
server_lock_session(item->target.s);
|
||||
else {
|
||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
server_lock_client(c);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -26,64 +26,78 @@
|
||||
* 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 = {
|
||||
"move-window", "movew",
|
||||
"adkrs:t:", 0, 0,
|
||||
"[-dkr] " CMD_SRCDST_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_move_window_exec
|
||||
.name = "move-window",
|
||||
.alias = "movew",
|
||||
|
||||
.args = { "adkrs:t:", 0, 0 },
|
||||
.usage = "[-dkr] " CMD_SRCDST_WINDOW_USAGE,
|
||||
|
||||
.source = { 's', CMD_FIND_WINDOW, 0 },
|
||||
/* -t is special */
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_move_window_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_link_window_entry = {
|
||||
"link-window", "linkw",
|
||||
"adks:t:", 0, 0,
|
||||
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_move_window_exec
|
||||
.name = "link-window",
|
||||
.alias = "linkw",
|
||||
|
||||
.args = { "adks:t:", 0, 0 },
|
||||
.usage = "[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
||||
|
||||
.source = { 's', CMD_FIND_WINDOW, 0 },
|
||||
/* -t is special */
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_move_window_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_move_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *src, *dst, *s;
|
||||
const char *tflag = args_get(args, 't');
|
||||
struct session *src;
|
||||
struct session *dst;
|
||||
struct winlink *wl;
|
||||
char *cause;
|
||||
int idx, kflag, dflag, sflag;
|
||||
|
||||
if (args_has(args, 'r')) {
|
||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
||||
if (s == NULL)
|
||||
if (cmd_find_target(&item->target, item, tflag,
|
||||
CMD_FIND_SESSION, CMD_FIND_QUIET) != 0)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
session_renumber_windows(s);
|
||||
session_renumber_windows(item->target.s);
|
||||
recalculate_sizes();
|
||||
server_status_session(item->target.s);
|
||||
|
||||
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)
|
||||
if (cmd_find_target(&item->target, item, tflag, CMD_FIND_WINDOW,
|
||||
CMD_FIND_WINDOW_INDEX) != 0)
|
||||
return (CMD_RETURN_ERROR);
|
||||
src = item->source.s;
|
||||
dst = item->target.s;
|
||||
wl = item->source.wl;
|
||||
idx = item->target.idx;
|
||||
|
||||
kflag = args_has(self->args, 'k');
|
||||
dflag = args_has(self->args, 'd');
|
||||
sflag = args_has(self->args, 's');
|
||||
|
||||
if (args_has(self->args, 'a')) {
|
||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
||||
if (s == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
if ((idx = winlink_shuffle_up(s, s->curw)) == -1)
|
||||
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(cmdq, "can't link window: %s", cause);
|
||||
cmdq_error(item, "can't link window: %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
@@ -95,7 +109,7 @@ cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
* session already has the correct winlink id to us, either
|
||||
* automatically or specified by -s.
|
||||
*/
|
||||
if (!sflag && options_get_number(&src->options, "renumber-windows"))
|
||||
if (!sflag && options_get_number(src->options, "renumber-windows"))
|
||||
session_renumber_windows(src);
|
||||
|
||||
recalculate_sizes();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -33,84 +33,123 @@
|
||||
|
||||
#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 = {
|
||||
"new-session", "new",
|
||||
"Ac:dDEF:n:Ps:t:x:y:", 0, -1,
|
||||
"[-AdDEP] [-c start-directory] [-F format] [-n window-name] "
|
||||
"[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
|
||||
"[-y height] [command]",
|
||||
CMD_STARTSERVER,
|
||||
cmd_new_session_exec
|
||||
.name = "new-session",
|
||||
.alias = "new",
|
||||
|
||||
.args = { "Ac:dDEF:n:Ps:t:x:Xy:", 0, -1 },
|
||||
.usage = "[-AdDEPX] [-c start-directory] [-F format] [-n window-name] "
|
||||
"[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
|
||||
"[-y height] [command]",
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = CMD_STARTSERVER,
|
||||
.exec = cmd_new_session_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_has_session_entry = {
|
||||
"has-session", "has",
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
cmd_new_session_exec
|
||||
.name = "has-session",
|
||||
.alias = "has",
|
||||
|
||||
.args = { "t:", 0, 0 },
|
||||
.usage = CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_new_session_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c = cmdq->client, *c0;
|
||||
struct session *s, *groupwith;
|
||||
struct window *w;
|
||||
struct environ env;
|
||||
struct client *c = item->client;
|
||||
struct session *s, *as, *groupwith;
|
||||
struct environ *env;
|
||||
struct options *oo;
|
||||
struct termios tio, *tiop;
|
||||
const char *newname, *target, *update, *errstr, *template;
|
||||
const char *path;
|
||||
char **argv, *cmd, *cause, *cp;
|
||||
int detached, already_attached, idx, cwd, fd = -1;
|
||||
int argc;
|
||||
u_int sx, sy;
|
||||
struct format_tree *ft;
|
||||
struct environ_entry *envent;
|
||||
struct session_group *sg;
|
||||
const char *errstr, *template, *group, *prefix, *tmp;
|
||||
char *cause, *cwd = NULL, *cp, *newname = NULL;
|
||||
int detached, already_attached, is_control = 0;
|
||||
u_int sx, sy, dsx, dsy;
|
||||
struct spawn_context sc;
|
||||
enum cmd_retval retval;
|
||||
struct cmd_find_state fs;
|
||||
|
||||
if (self->entry == &cmd_has_session_entry) {
|
||||
if (cmd_find_session(cmdq, args_get(args, 't'), 0) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
/*
|
||||
* cmd_find_target() will fail if the session cannot be found,
|
||||
* so always return success here.
|
||||
*/
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) {
|
||||
cmdq_error(cmdq, "command or window name given with target");
|
||||
cmdq_error(item, "command or window name given with target");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
newname = args_get(args, 's');
|
||||
if (newname != NULL) {
|
||||
tmp = args_get(args, 's');
|
||||
if (tmp != NULL) {
|
||||
newname = format_single(item, tmp, c, NULL, NULL, NULL);
|
||||
if (!session_check_name(newname)) {
|
||||
cmdq_error(cmdq, "bad session name: %s", newname);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (session_find(newname) != NULL) {
|
||||
if (args_has(args, 'A')) {
|
||||
return (cmd_attach_session(cmdq, newname,
|
||||
args_has(args, 'D'), 0, NULL,
|
||||
args_has(args, 'E')));
|
||||
}
|
||||
cmdq_error(cmdq, "duplicate session: %s", newname);
|
||||
return (CMD_RETURN_ERROR);
|
||||
cmdq_error(item, "bad session name: %s", newname);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
if (args_has(args, 'A')) {
|
||||
if (newname != NULL)
|
||||
as = session_find(newname);
|
||||
else
|
||||
as = item->target.s;
|
||||
if (as != NULL) {
|
||||
retval = cmd_attach_session(item, as->name,
|
||||
args_has(args, 'D'), args_has(args, 'X'), 0, NULL,
|
||||
args_has(args, 'E'));
|
||||
free(newname);
|
||||
return (retval);
|
||||
}
|
||||
}
|
||||
if (newname != NULL && session_find(newname) != NULL) {
|
||||
cmdq_error(item, "duplicate session: %s", newname);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
target = args_get(args, 't');
|
||||
if (target != NULL) {
|
||||
groupwith = cmd_find_session(cmdq, target, 0);
|
||||
if (groupwith == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
} else
|
||||
/* Is this going to be part of a session group? */
|
||||
group = args_get(args, 't');
|
||||
if (group != NULL) {
|
||||
groupwith = item->target.s;
|
||||
if (groupwith == NULL) {
|
||||
if (!session_check_name(group)) {
|
||||
cmdq_error(item, "bad group name: %s", group);
|
||||
goto fail;
|
||||
}
|
||||
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;
|
||||
sg = NULL;
|
||||
prefix = NULL;
|
||||
}
|
||||
|
||||
/* Set -d if no client. */
|
||||
detached = args_has(args, 'd');
|
||||
if (c == NULL)
|
||||
detached = 1;
|
||||
else if (c->flags & CLIENT_CONTROL)
|
||||
is_control = 1;
|
||||
|
||||
/* Is this client already attached? */
|
||||
already_attached = 0;
|
||||
@@ -118,32 +157,10 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
already_attached = 1;
|
||||
|
||||
/* Get the new session working directory. */
|
||||
if (args_has(args, 'c')) {
|
||||
ft = format_create();
|
||||
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), NULL, NULL,
|
||||
NULL);
|
||||
cp = format_expand(ft, args_get(args, 'c'));
|
||||
format_free(ft);
|
||||
|
||||
if (cp != NULL && *cp != '\0') {
|
||||
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
||||
free(cp);
|
||||
if (fd == -1) {
|
||||
cmdq_error(cmdq, "bad working directory: %s",
|
||||
strerror(errno));
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else if (cp != NULL)
|
||||
free(cp);
|
||||
cwd = fd;
|
||||
} else if (c != NULL && c->session == NULL)
|
||||
cwd = c->cwd;
|
||||
else if ((c0 = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
||||
cwd = c0->session->cwd;
|
||||
else {
|
||||
fd = open(".", O_RDONLY);
|
||||
cwd = fd;
|
||||
}
|
||||
if ((tmp = args_get(args, 'c')) != NULL)
|
||||
cwd = format_single(item, tmp, c, NULL, NULL, NULL);
|
||||
else
|
||||
cwd = xstrdup(server_client_get_cwd(c, NULL));
|
||||
|
||||
/*
|
||||
* If this is a new client, check for nesting and save the termios
|
||||
@@ -155,10 +172,10 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
* over.
|
||||
*/
|
||||
if (!detached && !already_attached && c->tty.fd != -1) {
|
||||
if (server_client_check_nested(cmdq->client)) {
|
||||
cmdq_error(cmdq, "sessions should be nested with care, "
|
||||
if (server_client_check_nested(item->client)) {
|
||||
cmdq_error(item, "sessions should be nested with care, "
|
||||
"unset $TMUX to force");
|
||||
return (CMD_RETURN_ERROR);
|
||||
goto fail;
|
||||
}
|
||||
if (tcgetattr(c->tty.fd, &tio) != 0)
|
||||
fatal("tcgetattr failed");
|
||||
@@ -169,114 +186,136 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
/* Open the terminal if necessary. */
|
||||
if (!detached && !already_attached) {
|
||||
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);
|
||||
goto error;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get default session size. */
|
||||
if (args_has(args, 'x')) {
|
||||
tmp = args_get(args, 'x');
|
||||
if (strcmp(tmp, "-") == 0) {
|
||||
if (c != NULL)
|
||||
dsx = c->tty.sx;
|
||||
else
|
||||
dsx = 80;
|
||||
} else {
|
||||
dsx = strtonum(tmp, 1, USHRT_MAX, &errstr);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(item, "width %s", errstr);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args_has(args, 'y')) {
|
||||
tmp = args_get(args, 'y');
|
||||
if (strcmp(tmp, "-") == 0) {
|
||||
if (c != NULL)
|
||||
dsy = c->tty.sy;
|
||||
else
|
||||
dsy = 24;
|
||||
} else {
|
||||
dsy = strtonum(tmp, 1, USHRT_MAX, &errstr);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(item, "height %s", errstr);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Find new session size. */
|
||||
if (c != NULL) {
|
||||
if (!detached && !is_control) {
|
||||
sx = c->tty.sx;
|
||||
sy = c->tty.sy;
|
||||
if (sy > 0 && options_get_number(global_s_options, "status"))
|
||||
sy--;
|
||||
} else {
|
||||
sx = 80;
|
||||
sy = 24;
|
||||
}
|
||||
if (detached && args_has(args, 'x')) {
|
||||
sx = strtonum(args_get(args, 'x'), 1, USHRT_MAX, &errstr);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(cmdq, "width %s", errstr);
|
||||
goto error;
|
||||
tmp = options_get_string(global_s_options, "default-size");
|
||||
if (sscanf(tmp, "%ux%u", &sx, &sy) != 2) {
|
||||
sx = 80;
|
||||
sy = 24;
|
||||
}
|
||||
if (args_has(args, 'x'))
|
||||
sx = dsx;
|
||||
if (args_has(args, 'y'))
|
||||
sy = dsy;
|
||||
}
|
||||
if (detached && args_has(args, 'y')) {
|
||||
sy = strtonum(args_get(args, 'y'), 1, USHRT_MAX, &errstr);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(cmdq, "height %s", errstr);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (sy > 0 && options_get_number(&global_s_options, "status"))
|
||||
sy--;
|
||||
if (sx == 0)
|
||||
sx = 1;
|
||||
if (sy == 0)
|
||||
sy = 1;
|
||||
|
||||
/* Figure out the command for the new window. */
|
||||
argc = -1;
|
||||
argv = NULL;
|
||||
if (target == NULL && args->argc != 0) {
|
||||
argc = args->argc;
|
||||
argv = args->argv;
|
||||
} else if (target == NULL) {
|
||||
cmd = options_get_string(&global_s_options, "default-command");
|
||||
if (cmd != NULL && *cmd != '\0') {
|
||||
argc = 1;
|
||||
argv = &cmd;
|
||||
} else {
|
||||
argc = 0;
|
||||
argv = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
path = NULL;
|
||||
if (c != NULL && c->session == NULL)
|
||||
envent = environ_find(&c->environ, "PATH");
|
||||
else
|
||||
envent = environ_find(&global_environ, "PATH");
|
||||
if (envent != NULL)
|
||||
path = envent->value;
|
||||
|
||||
/* Construct the environment. */
|
||||
environ_init(&env);
|
||||
if (c != NULL && !args_has(args, 'E')) {
|
||||
update = options_get_string(&global_s_options,
|
||||
"update-environment");
|
||||
environ_update(update, &c->environ, &env);
|
||||
}
|
||||
|
||||
/* Create the new session. */
|
||||
idx = -1 - options_get_number(&global_s_options, "base-index");
|
||||
s = session_create(newname, argc, argv, path, cwd, &env, tiop, idx, sx,
|
||||
sy, &cause);
|
||||
if (s == NULL) {
|
||||
cmdq_error(cmdq, "create session failed: %s", cause);
|
||||
free(cause);
|
||||
goto error;
|
||||
oo = options_create(global_s_options);
|
||||
if (args_has(args, 'x') || args_has(args, 'y')) {
|
||||
if (!args_has(args, 'x'))
|
||||
dsx = sx;
|
||||
if (!args_has(args, 'y'))
|
||||
dsy = sy;
|
||||
options_set_string(oo, "default-size", 0, "%ux%u", dsx, dsy);
|
||||
}
|
||||
environ_free(&env);
|
||||
env = environ_create();
|
||||
if (c != NULL && !args_has(args, 'E'))
|
||||
environ_update(global_s_options, c->environ, env);
|
||||
s = session_create(prefix, newname, cwd, env, oo, tiop);
|
||||
|
||||
/* Set the initial window name if one given. */
|
||||
if (argc >= 0 && args_has(args, 'n')) {
|
||||
w = s->curw->window;
|
||||
window_set_name(w, args_get(args, 'n'));
|
||||
options_set_number(&w->options, "automatic-rename", 0);
|
||||
/* Spawn the initial window. */
|
||||
memset(&sc, 0, sizeof sc);
|
||||
sc.item = item;
|
||||
sc.s = s;
|
||||
sc.c = c;
|
||||
|
||||
sc.name = args_get(args, 'n');
|
||||
sc.argc = args->argc;
|
||||
sc.argv = args->argv;
|
||||
|
||||
sc.idx = -1;
|
||||
sc.cwd = args_get(args, 'c');
|
||||
|
||||
sc.flags = 0;
|
||||
|
||||
if (spawn_window(&sc, &cause) == NULL) {
|
||||
session_destroy(s, 0, __func__);
|
||||
cmdq_error(item, "create window failed: %s", cause);
|
||||
free(cause);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/*
|
||||
* If a target session is given, this is to be part of a session group,
|
||||
* so add it to the group and synchronize.
|
||||
*/
|
||||
if (groupwith != NULL) {
|
||||
session_group_add(groupwith, s);
|
||||
if (group != NULL) {
|
||||
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_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
|
||||
* taking this session and needs to get MSG_READY and stay around.
|
||||
*/
|
||||
if (!detached) {
|
||||
if (!already_attached)
|
||||
server_write_ready(c);
|
||||
else if (c->session != NULL)
|
||||
if (!already_attached) {
|
||||
if (~c->flags & CLIENT_CONTROL)
|
||||
proc_send(c->peer, MSG_READY, -1, NULL, 0);
|
||||
} else if (c->session != NULL)
|
||||
c->last_session = c->session;
|
||||
c->session = s;
|
||||
if (~item->shared->flags & CMDQ_SHARED_REPEAT)
|
||||
server_client_set_key_table(c, NULL);
|
||||
tty_update_client_offset(c);
|
||||
status_timer_start(c);
|
||||
notify_attached_session_changed(c);
|
||||
notify_client("client-session-changed", c);
|
||||
session_update_activity(s, NULL);
|
||||
gettimeofday(&s->last_attached_time, NULL);
|
||||
server_redraw_client(c);
|
||||
@@ -295,27 +334,25 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
if (args_has(args, 'P')) {
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = NEW_SESSION_TEMPLATE;
|
||||
|
||||
ft = format_create();
|
||||
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, NULL,
|
||||
NULL);
|
||||
|
||||
cp = format_expand(ft, template);
|
||||
cmdq_print(cmdq, "%s", cp);
|
||||
cp = format_single(item, template, c, s, NULL, NULL);
|
||||
cmdq_print(item, "%s", cp);
|
||||
free(cp);
|
||||
|
||||
format_free(ft);
|
||||
}
|
||||
|
||||
if (!detached)
|
||||
cmdq->client_exit = 0;
|
||||
if (!detached) {
|
||||
c->flags |= CLIENT_ATTACHED;
|
||||
cmd_find_from_session(&item->shared->current, s, 0);
|
||||
}
|
||||
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
cmd_find_from_session(&fs, s, 0);
|
||||
cmdq_insert_hook(s, item, &fs, "after-new-session");
|
||||
|
||||
free(cwd);
|
||||
free(newname);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
error:
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
fail:
|
||||
free(cwd);
|
||||
free(newname);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
177
cmd-new-window.c
177
cmd-new-window.c
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -32,120 +32,75 @@
|
||||
|
||||
#define NEW_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||
|
||||
enum cmd_retval cmd_new_window_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_new_window_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_new_window_entry = {
|
||||
"new-window", "neww",
|
||||
"ac:dF:kn:Pt:", 0, -1,
|
||||
"[-adkP] [-c start-directory] [-F format] [-n window-name] "
|
||||
CMD_TARGET_WINDOW_USAGE " [command]",
|
||||
0,
|
||||
cmd_new_window_exec
|
||||
.name = "new-window",
|
||||
.alias = "neww",
|
||||
|
||||
.args = { "ac:de:F:kn:Pt:", 0, -1 },
|
||||
.usage = "[-adkP] [-c start-directory] [-e environment] [-F format] "
|
||||
"[-n window-name] " CMD_TARGET_WINDOW_USAGE " [command]",
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_new_window_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
const char *cmd, *path, *template;
|
||||
char **argv, *cause, *cp;
|
||||
int argc, idx, detached, cwd, fd = -1;
|
||||
struct format_tree *ft;
|
||||
struct environ_entry *envent;
|
||||
struct cmd_find_state *current = &item->shared->current;
|
||||
struct spawn_context sc;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
int idx = item->target.idx;
|
||||
struct winlink *new_wl;
|
||||
char *cause = NULL, *cp;
|
||||
const char *template, *add;
|
||||
struct cmd_find_state fs;
|
||||
struct args_value *value;
|
||||
|
||||
if (args_has(args, 'a')) {
|
||||
wl = cmd_find_window(cmdq, args_get(args, 't'), &s);
|
||||
if (wl == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
if ((idx = winlink_shuffle_up(s, wl)) == -1) {
|
||||
cmdq_error(cmdq, "no free window indexes");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else {
|
||||
idx = cmd_find_index(cmdq, args_get(args, 't'), &s);
|
||||
if (idx == -2)
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
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;
|
||||
if (args_has(args, 'a') && (idx = winlink_shuffle_up(s, wl)) == -1) {
|
||||
cmdq_error(item, "couldn't get a window index");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
path = NULL;
|
||||
if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||
envent = environ_find(&cmdq->client->environ, "PATH");
|
||||
else
|
||||
envent = environ_find(&s->environ, "PATH");
|
||||
if (envent != NULL)
|
||||
path = envent->value;
|
||||
memset(&sc, 0, sizeof sc);
|
||||
sc.item = item;
|
||||
sc.s = s;
|
||||
sc.c = c;
|
||||
|
||||
if (args_has(args, 'c')) {
|
||||
ft = format_create();
|
||||
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, NULL,
|
||||
NULL);
|
||||
cp = format_expand(ft, args_get(args, 'c'));
|
||||
format_free(ft);
|
||||
sc.name = args_get(args, 'n');
|
||||
sc.argc = args->argc;
|
||||
sc.argv = args->argv;
|
||||
sc.environ = environ_create();
|
||||
|
||||
if (cp != NULL && *cp != '\0') {
|
||||
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
||||
free(cp);
|
||||
if (fd == -1) {
|
||||
cmdq_error(cmdq, "bad working directory: %s",
|
||||
strerror(errno));
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else if (cp != NULL)
|
||||
free(cp);
|
||||
cwd = fd;
|
||||
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||
cwd = cmdq->client->cwd;
|
||||
else
|
||||
cwd = s->cwd;
|
||||
|
||||
wl = NULL;
|
||||
if (idx != -1)
|
||||
wl = winlink_find_by_index(&s->windows, idx);
|
||||
if (wl != NULL && args_has(args, 'k')) {
|
||||
/*
|
||||
* Can't use session_detach as it will destroy session if this
|
||||
* makes it empty.
|
||||
*/
|
||||
notify_window_unlinked(s, wl->window);
|
||||
wl->flags &= ~WINLINK_ALERTFLAGS;
|
||||
winlink_stack_remove(&s->lastw, wl);
|
||||
winlink_remove(&s->windows, wl);
|
||||
|
||||
/* Force select/redraw if current. */
|
||||
if (wl == s->curw) {
|
||||
detached = 0;
|
||||
s->curw = NULL;
|
||||
}
|
||||
add = args_first_value(args, 'e', &value);
|
||||
while (add != NULL) {
|
||||
environ_put(sc.environ, add);
|
||||
add = args_next_value(&value);
|
||||
}
|
||||
|
||||
if (idx == -1)
|
||||
idx = -1 - options_get_number(&s->options, "base-index");
|
||||
wl = session_new(s, args_get(args, 'n'), argc, argv, path, cwd, idx,
|
||||
&cause);
|
||||
if (wl == NULL) {
|
||||
cmdq_error(cmdq, "create window failed: %s", cause);
|
||||
sc.idx = idx;
|
||||
sc.cwd = args_get(args, 'c');
|
||||
|
||||
sc.flags = 0;
|
||||
if (args_has(args, 'd'))
|
||||
sc.flags |= SPAWN_DETACHED;
|
||||
if (args_has(args, 'k'))
|
||||
sc.flags |= SPAWN_KILL;
|
||||
|
||||
if ((new_wl = spawn_window(&sc, &cause)) == NULL) {
|
||||
cmdq_error(item, "create window failed: %s", cause);
|
||||
free(cause);
|
||||
goto error;
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (!detached) {
|
||||
session_select(s, wl->idx);
|
||||
if (!args_has(args, 'd') || new_wl == s->curw) {
|
||||
cmd_find_from_winlink(current, new_wl, 0);
|
||||
server_redraw_session_group(s);
|
||||
} else
|
||||
server_status_session_group(s);
|
||||
@@ -153,24 +108,14 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
if (args_has(args, 'P')) {
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = NEW_WINDOW_TEMPLATE;
|
||||
|
||||
ft = format_create();
|
||||
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, wl,
|
||||
NULL);
|
||||
|
||||
cp = format_expand(ft, template);
|
||||
cmdq_print(cmdq, "%s", cp);
|
||||
cp = format_single(item, template, c, s, new_wl, NULL);
|
||||
cmdq_print(item, "%s", cp);
|
||||
free(cp);
|
||||
|
||||
format_free(ft);
|
||||
}
|
||||
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
cmd_find_from_winlink(&fs, new_wl, 0);
|
||||
cmdq_insert_hook(s, item, &fs, "after-new-window");
|
||||
|
||||
error:
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
return (CMD_RETURN_ERROR);
|
||||
environ_free(sc.environ);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
1567
cmd-parse.y
Normal file
1567
cmd-parse.y
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -27,33 +27,32 @@
|
||||
* Paste paste buffer if present.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_paste_buffer_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
void cmd_paste_buffer_filter(struct window_pane *,
|
||||
const char *, size_t, const char *, int);
|
||||
static enum cmd_retval cmd_paste_buffer_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_paste_buffer_entry = {
|
||||
"paste-buffer", "pasteb",
|
||||
"db:prs:t:", 0, 0,
|
||||
"[-dpr] [-s separator] " CMD_BUFFER_USAGE " " CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
cmd_paste_buffer_exec
|
||||
.name = "paste-buffer",
|
||||
.alias = "pasteb",
|
||||
|
||||
.args = { "db:prs:t:", 0, 0 },
|
||||
.usage = "[-dpr] [-s separator] " CMD_BUFFER_USAGE " "
|
||||
CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_paste_buffer_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct window_pane *wp;
|
||||
struct session *s;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct paste_buffer *pb;
|
||||
const char *sepstr, *bufname, *bufdata, *bufend, *line;
|
||||
size_t seplen, bufsize;
|
||||
int bracket = args_has(args, 'p');
|
||||
|
||||
if (cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
bufname = NULL;
|
||||
if (args_has(args, 'b'))
|
||||
bufname = args_get(args, 'b');
|
||||
@@ -63,7 +62,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
else {
|
||||
pb = paste_get_name(bufname);
|
||||
if (pb == NULL) {
|
||||
cmdq_error(cmdq, "no buffer %s", bufname);
|
||||
cmdq_error(item, "no buffer %s", bufname);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
157
cmd-pipe-pane.c
157
cmd-pipe-pane.c
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
@@ -32,33 +33,37 @@
|
||||
* 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_read_callback(struct bufferevent *, void *);
|
||||
static void cmd_pipe_pane_write_callback(struct bufferevent *, void *);
|
||||
static void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
|
||||
|
||||
const struct cmd_entry cmd_pipe_pane_entry = {
|
||||
"pipe-pane", "pipep",
|
||||
"ot:", 0, 1,
|
||||
"[-o] " CMD_TARGET_PANE_USAGE " [command]",
|
||||
0,
|
||||
cmd_pipe_pane_exec
|
||||
.name = "pipe-pane",
|
||||
.alias = "pipep",
|
||||
|
||||
.args = { "IOot:", 0, 1 },
|
||||
.usage = "[-IOo] " CMD_TARGET_PANE_USAGE " [command]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_pipe_pane_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
struct window_pane *wp;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
char *cmd;
|
||||
int old_fd, pipe_fd[2], null_fd;
|
||||
int old_fd, pipe_fd[2], null_fd, in, out;
|
||||
struct format_tree *ft;
|
||||
|
||||
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
c = cmd_find_client(cmdq, NULL, 1);
|
||||
sigset_t set, oldset;
|
||||
|
||||
/* Destroy the old pipe. */
|
||||
old_fd = wp->pipe_fd;
|
||||
@@ -66,6 +71,11 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
bufferevent_free(wp->pipe_event);
|
||||
close(wp->pipe_fd);
|
||||
wp->pipe_fd = -1;
|
||||
|
||||
if (window_pane_destroy_ready(wp)) {
|
||||
server_destroy_pane(wp, 1);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
/* If no pipe command, that is enough. */
|
||||
@@ -81,72 +91,135 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
if (args_has(self->args, 'o') && old_fd != -1)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
/* What do we want to do? Neither -I or -O is -O. */
|
||||
if (args_has(self->args, 'I')) {
|
||||
in = 1;
|
||||
out = args_has(self->args, 'O');
|
||||
} else {
|
||||
in = 0;
|
||||
out = 1;
|
||||
}
|
||||
|
||||
/* Open the new pipe. */
|
||||
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);
|
||||
}
|
||||
|
||||
/* Expand the command. */
|
||||
ft = format_create();
|
||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
||||
format_defaults(ft, c, s, wl, wp);
|
||||
cmd = format_expand_time(ft, args->argv[0], time(NULL));
|
||||
cmd = format_expand_time(ft, args->argv[0]);
|
||||
format_free(ft);
|
||||
|
||||
/* Fork the child. */
|
||||
sigfillset(&set);
|
||||
sigprocmask(SIG_BLOCK, &set, &oldset);
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
cmdq_error(cmdq, "fork error: %s", strerror(errno));
|
||||
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||
cmdq_error(item, "fork error: %s", strerror(errno));
|
||||
|
||||
free(cmd);
|
||||
return (CMD_RETURN_ERROR);
|
||||
case 0:
|
||||
/* Child process. */
|
||||
proc_clear_signals(server_proc, 1);
|
||||
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||
close(pipe_fd[0]);
|
||||
clear_signals(1);
|
||||
|
||||
if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
|
||||
_exit(1);
|
||||
if (pipe_fd[1] != STDIN_FILENO)
|
||||
close(pipe_fd[1]);
|
||||
|
||||
null_fd = open(_PATH_DEVNULL, O_WRONLY, 0);
|
||||
if (dup2(null_fd, STDOUT_FILENO) == -1)
|
||||
_exit(1);
|
||||
if (out) {
|
||||
if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
|
||||
_exit(1);
|
||||
} else {
|
||||
if (dup2(null_fd, STDIN_FILENO) == -1)
|
||||
_exit(1);
|
||||
}
|
||||
if (in) {
|
||||
if (dup2(pipe_fd[1], STDOUT_FILENO) == -1)
|
||||
_exit(1);
|
||||
if (pipe_fd[1] != STDOUT_FILENO)
|
||||
close(pipe_fd[1]);
|
||||
} else {
|
||||
if (dup2(null_fd, STDOUT_FILENO) == -1)
|
||||
_exit(1);
|
||||
}
|
||||
if (dup2(null_fd, STDERR_FILENO) == -1)
|
||||
_exit(1);
|
||||
if (null_fd != STDOUT_FILENO && null_fd != STDERR_FILENO)
|
||||
close(null_fd);
|
||||
|
||||
closefrom(STDERR_FILENO + 1);
|
||||
|
||||
execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);
|
||||
_exit(1);
|
||||
default:
|
||||
/* Parent process. */
|
||||
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||
close(pipe_fd[1]);
|
||||
|
||||
wp->pipe_fd = pipe_fd[0];
|
||||
wp->pipe_off = EVBUFFER_LENGTH(wp->event->input);
|
||||
|
||||
wp->pipe_event = bufferevent_new(wp->pipe_fd,
|
||||
NULL, NULL, cmd_pipe_pane_error_callback, wp);
|
||||
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
||||
if (wp->fd != -1)
|
||||
wp->pipe_off = EVBUFFER_LENGTH(wp->event->input);
|
||||
else
|
||||
wp->pipe_off = 0;
|
||||
|
||||
setblocking(wp->pipe_fd, 0);
|
||||
wp->pipe_event = bufferevent_new(wp->pipe_fd,
|
||||
cmd_pipe_pane_read_callback,
|
||||
cmd_pipe_pane_write_callback,
|
||||
cmd_pipe_pane_error_callback,
|
||||
wp);
|
||||
if (wp->pipe_event == NULL)
|
||||
fatalx("out of memory");
|
||||
if (out)
|
||||
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
||||
if (in)
|
||||
bufferevent_enable(wp->pipe_event, EV_READ);
|
||||
|
||||
free(cmd);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cmd_pipe_pane_error_callback(
|
||||
unused struct bufferevent *bufev, unused short what, void *data)
|
||||
static void
|
||||
cmd_pipe_pane_read_callback(__unused struct bufferevent *bufev, void *data)
|
||||
{
|
||||
struct window_pane *wp = data;
|
||||
struct evbuffer *evb = wp->pipe_event->input;
|
||||
size_t available;
|
||||
|
||||
available = EVBUFFER_LENGTH(evb);
|
||||
log_debug("%%%u pipe read %zu", wp->id, available);
|
||||
|
||||
bufferevent_write(wp->event, EVBUFFER_DATA(evb), available);
|
||||
evbuffer_drain(evb, available);
|
||||
|
||||
if (window_pane_destroy_ready(wp))
|
||||
server_destroy_pane(wp, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_pipe_pane_write_callback(__unused struct bufferevent *bufev, void *data)
|
||||
{
|
||||
struct window_pane *wp = data;
|
||||
|
||||
log_debug("%%%u pipe empty", wp->id);
|
||||
|
||||
if (window_pane_destroy_ready(wp))
|
||||
server_destroy_pane(wp, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_pipe_pane_error_callback(__unused struct bufferevent *bufev,
|
||||
__unused short what, void *data)
|
||||
{
|
||||
struct window_pane *wp = data;
|
||||
|
||||
log_debug("%%%u pipe error", wp->id);
|
||||
|
||||
bufferevent_free(wp->pipe_event);
|
||||
close(wp->pipe_fd);
|
||||
wp->pipe_fd = -1;
|
||||
|
||||
if (window_pane_destroy_ready(wp))
|
||||
server_destroy_pane(wp, 1);
|
||||
}
|
||||
|
||||
692
cmd-queue.c
692
cmd-queue.c
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -25,94 +25,536 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
enum cmd_retval cmdq_continue_one(struct cmd_q *);
|
||||
/* Global command queue. */
|
||||
static struct cmdq_list global_queue = TAILQ_HEAD_INITIALIZER(global_queue);
|
||||
|
||||
/* Create new command queue. */
|
||||
struct cmd_q *
|
||||
cmdq_new(struct client *c)
|
||||
/* Get command queue name. */
|
||||
static const char *
|
||||
cmdq_name(struct client *c)
|
||||
{
|
||||
struct cmd_q *cmdq;
|
||||
static char s[256];
|
||||
|
||||
cmdq = xcalloc(1, sizeof *cmdq);
|
||||
cmdq->references = 1;
|
||||
cmdq->flags = 0;
|
||||
|
||||
cmdq->client = c;
|
||||
cmdq->client_exit = -1;
|
||||
|
||||
TAILQ_INIT(&cmdq->queue);
|
||||
cmdq->item = NULL;
|
||||
cmdq->cmd = NULL;
|
||||
|
||||
return (cmdq);
|
||||
if (c == NULL)
|
||||
return ("<global>");
|
||||
if (c->name != NULL)
|
||||
xsnprintf(s, sizeof s, "<%s>", c->name);
|
||||
else
|
||||
xsnprintf(s, sizeof s, "<%p>", c);
|
||||
return (s);
|
||||
}
|
||||
|
||||
/* Free command queue */
|
||||
int
|
||||
cmdq_free(struct cmd_q *cmdq)
|
||||
/* Get command queue from client. */
|
||||
static struct cmdq_list *
|
||||
cmdq_get(struct client *c)
|
||||
{
|
||||
if (--cmdq->references != 0) {
|
||||
if (cmdq->flags & CMD_Q_DEAD)
|
||||
return (1);
|
||||
if (c == NULL)
|
||||
return (&global_queue);
|
||||
return (&c->queue);
|
||||
}
|
||||
|
||||
/* Append an item. */
|
||||
struct cmdq_item *
|
||||
cmdq_append(struct client *c, struct cmdq_item *item)
|
||||
{
|
||||
struct cmdq_list *queue = cmdq_get(c);
|
||||
struct cmdq_item *next;
|
||||
|
||||
TAILQ_FOREACH(next, queue, entry) {
|
||||
log_debug("%s %s: queue %s (%u)", __func__, cmdq_name(c),
|
||||
next->name, next->group);
|
||||
}
|
||||
do {
|
||||
next = item->next;
|
||||
item->next = NULL;
|
||||
|
||||
if (c != NULL)
|
||||
c->references++;
|
||||
item->client = c;
|
||||
|
||||
item->queue = queue;
|
||||
TAILQ_INSERT_TAIL(queue, item, entry);
|
||||
log_debug("%s %s: %s", __func__, cmdq_name(c), item->name);
|
||||
|
||||
item = next;
|
||||
} while (item != NULL);
|
||||
return (TAILQ_LAST(queue, cmdq_list));
|
||||
}
|
||||
|
||||
/* Insert an item. */
|
||||
struct cmdq_item *
|
||||
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;
|
||||
|
||||
TAILQ_FOREACH(next, queue, entry) {
|
||||
log_debug("%s %s: queue %s (%u)", __func__, cmdq_name(c),
|
||||
next->name, next->group);
|
||||
}
|
||||
do {
|
||||
next = item->next;
|
||||
item->next = after->next;
|
||||
after->next = item;
|
||||
|
||||
if (c != NULL)
|
||||
c->references++;
|
||||
item->client = c;
|
||||
|
||||
item->queue = queue;
|
||||
TAILQ_INSERT_AFTER(queue, after, item, entry);
|
||||
log_debug("%s %s: %s after %s", __func__, cmdq_name(c),
|
||||
item->name, after->name);
|
||||
|
||||
after = item;
|
||||
item = next;
|
||||
} while (item != NULL);
|
||||
return (after);
|
||||
}
|
||||
|
||||
/* Insert a hook. */
|
||||
void
|
||||
cmdq_insert_hook(struct session *s, struct cmdq_item *item,
|
||||
struct cmd_find_state *fs, const char *fmt, ...)
|
||||
{
|
||||
struct options *oo;
|
||||
va_list ap;
|
||||
char *name;
|
||||
struct cmdq_item *new_item;
|
||||
struct options_entry *o;
|
||||
struct options_array_item *a;
|
||||
struct cmd_list *cmdlist;
|
||||
|
||||
if (item->flags & CMDQ_NOHOOKS)
|
||||
return;
|
||||
if (s == NULL)
|
||||
oo = global_s_options;
|
||||
else
|
||||
oo = s->options;
|
||||
|
||||
va_start(ap, fmt);
|
||||
xvasprintf(&name, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
o = options_get(oo, name);
|
||||
if (o == NULL) {
|
||||
free(name);
|
||||
return;
|
||||
}
|
||||
log_debug("running hook %s (parent %p)", name, item);
|
||||
|
||||
a = options_array_first(o);
|
||||
while (a != NULL) {
|
||||
cmdlist = options_array_item_value(a)->cmdlist;
|
||||
if (cmdlist == NULL) {
|
||||
a = options_array_next(a);
|
||||
continue;
|
||||
}
|
||||
|
||||
new_item = cmdq_get_command(cmdlist, fs, NULL, CMDQ_NOHOOKS);
|
||||
cmdq_format(new_item, "hook", "%s", name);
|
||||
if (item != NULL)
|
||||
item = cmdq_insert_after(item, new_item);
|
||||
else
|
||||
item = cmdq_append(NULL, new_item);
|
||||
|
||||
a = options_array_next(a);
|
||||
}
|
||||
|
||||
free(name);
|
||||
}
|
||||
|
||||
/* Continue processing command queue. */
|
||||
void
|
||||
cmdq_continue(struct cmdq_item *item)
|
||||
{
|
||||
item->flags &= ~CMDQ_WAITING;
|
||||
}
|
||||
|
||||
/* Remove an item. */
|
||||
static void
|
||||
cmdq_remove(struct cmdq_item *item)
|
||||
{
|
||||
if (item->shared != NULL && --item->shared->references == 0) {
|
||||
if (item->shared->formats != NULL)
|
||||
format_free(item->shared->formats);
|
||||
free(item->shared);
|
||||
}
|
||||
|
||||
if (item->client != NULL)
|
||||
server_client_unref(item->client);
|
||||
|
||||
if (item->cmdlist != NULL)
|
||||
cmd_list_free(item->cmdlist);
|
||||
|
||||
TAILQ_REMOVE(item->queue, item, entry);
|
||||
|
||||
free(item->name);
|
||||
free(item);
|
||||
}
|
||||
|
||||
/* Remove all subsequent items that match this item's group. */
|
||||
static void
|
||||
cmdq_remove_group(struct cmdq_item *item)
|
||||
{
|
||||
struct cmdq_item *this, *next;
|
||||
|
||||
if (item->group == 0)
|
||||
return;
|
||||
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;
|
||||
struct cmdq_shared *shared = NULL;
|
||||
u_int group = 0;
|
||||
|
||||
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||
if (cmd->group != group) {
|
||||
shared = xcalloc(1, sizeof *shared);
|
||||
if (current != NULL)
|
||||
cmd_find_copy_state(&shared->current, current);
|
||||
else
|
||||
cmd_find_clear_state(&shared->current, 0);
|
||||
if (m != NULL)
|
||||
memcpy(&shared->mouse, m, sizeof shared->mouse);
|
||||
group = cmd->group;
|
||||
}
|
||||
|
||||
item = xcalloc(1, sizeof *item);
|
||||
xasprintf(&item->name, "[%s/%p]", cmd->entry->name, item);
|
||||
item->type = CMDQ_COMMAND;
|
||||
|
||||
item->group = cmd->group;
|
||||
item->flags = flags;
|
||||
|
||||
item->shared = shared;
|
||||
item->cmdlist = cmdlist;
|
||||
item->cmd = cmd;
|
||||
|
||||
log_debug("%s: %s group %u", __func__, item->name, item->group);
|
||||
|
||||
shared->references++;
|
||||
cmdlist->references++;
|
||||
|
||||
if (first == NULL)
|
||||
first = item;
|
||||
if (last != NULL)
|
||||
last->next = item;
|
||||
last = item;
|
||||
}
|
||||
return (first);
|
||||
}
|
||||
|
||||
/* Fill in flag for a command. */
|
||||
static enum cmd_retval
|
||||
cmdq_find_flag(struct cmdq_item *item, struct cmd_find_state *fs,
|
||||
const struct cmd_entry_flag *flag)
|
||||
{
|
||||
const char *value;
|
||||
|
||||
if (flag->flag == 0) {
|
||||
cmd_find_clear_state(fs, 0);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
value = args_get(item->cmd->args, flag->flag);
|
||||
if (cmd_find_target(fs, item, value, flag->type, flag->flags) != 0) {
|
||||
cmd_find_clear_state(fs, 0);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
/* Fire command on command queue. */
|
||||
static enum cmd_retval
|
||||
cmdq_fire_command(struct cmdq_item *item)
|
||||
{
|
||||
struct client *c = item->client;
|
||||
const char *name = cmdq_name(c);
|
||||
struct cmdq_shared *shared = item->shared;
|
||||
struct cmd *cmd = item->cmd;
|
||||
const struct cmd_entry *entry = cmd->entry;
|
||||
enum cmd_retval retval;
|
||||
struct cmd_find_state *fsp, fs;
|
||||
int flags;
|
||||
char *tmp;
|
||||
|
||||
if (log_get_level() > 1) {
|
||||
tmp = cmd_print(cmd);
|
||||
log_debug("%s %s: (%u) %s", __func__, name, item->group, tmp);
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
flags = !!(shared->flags & CMDQ_SHARED_CONTROL);
|
||||
cmdq_guard(item, "begin", flags);
|
||||
|
||||
if (item->client == NULL)
|
||||
item->client = cmd_find_client(item, NULL, 1);
|
||||
retval = cmdq_find_flag(item, &item->source, &entry->source);
|
||||
if (retval == CMD_RETURN_ERROR)
|
||||
goto out;
|
||||
retval = cmdq_find_flag(item, &item->target, &entry->target);
|
||||
if (retval == CMD_RETURN_ERROR)
|
||||
goto out;
|
||||
|
||||
retval = entry->exec(cmd, item);
|
||||
if (retval == CMD_RETURN_ERROR)
|
||||
goto out;
|
||||
|
||||
if (entry->flags & CMD_AFTERHOOK) {
|
||||
if (cmd_find_valid_state(&item->target))
|
||||
fsp = &item->target;
|
||||
else if (cmd_find_valid_state(&item->shared->current))
|
||||
fsp = &item->shared->current;
|
||||
else if (cmd_find_from_client(&fs, item->client, 0) == 0)
|
||||
fsp = &fs;
|
||||
else
|
||||
goto out;
|
||||
cmdq_insert_hook(fsp->s, item, fsp, "after-%s", entry->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;
|
||||
|
||||
item = xcalloc(1, sizeof *item);
|
||||
xasprintf(&item->name, "[%s/%p]", name, item);
|
||||
item->type = CMDQ_CALLBACK;
|
||||
|
||||
item->group = 0;
|
||||
item->flags = 0;
|
||||
|
||||
item->cb = cb;
|
||||
item->data = data;
|
||||
|
||||
return (item);
|
||||
}
|
||||
|
||||
/* Generic error callback. */
|
||||
static enum cmd_retval
|
||||
cmdq_error_callback(struct cmdq_item *item, void *data)
|
||||
{
|
||||
char *error = data;
|
||||
|
||||
cmdq_error(item, "%s", error);
|
||||
free(error);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
/* Get an error callback for the command queue. */
|
||||
struct cmdq_item *
|
||||
cmdq_get_error(const char *error)
|
||||
{
|
||||
return (cmdq_get_callback(cmdq_error_callback, xstrdup(error)));
|
||||
}
|
||||
|
||||
/* Fire callback on callback queue. */
|
||||
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, ...)
|
||||
{
|
||||
struct cmdq_shared *shared = item->shared;
|
||||
va_list ap;
|
||||
char *value;
|
||||
|
||||
va_start(ap, fmt);
|
||||
xvasprintf(&value, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (shared->formats == NULL)
|
||||
shared->formats = format_create(NULL, NULL, FORMAT_NONE, 0);
|
||||
format_add(shared->formats, key, "%s", value);
|
||||
|
||||
free(value);
|
||||
}
|
||||
|
||||
/* Process next item on command queue. */
|
||||
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);
|
||||
}
|
||||
|
||||
cmdq_flush(cmdq);
|
||||
free(cmdq);
|
||||
return (1);
|
||||
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;
|
||||
long t = item->time;
|
||||
u_int number = item->number;
|
||||
|
||||
if (c != NULL && (c->flags & CLIENT_CONTROL))
|
||||
file_print(c, "%%%s %ld %u %d\n", guard, t, number, flags);
|
||||
}
|
||||
|
||||
/* Show message from command. */
|
||||
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 window *w;
|
||||
va_list ap;
|
||||
struct client *c = item->client;
|
||||
struct window_pane *wp;
|
||||
struct window_mode_entry *wme;
|
||||
va_list ap;
|
||||
char *tmp, *msg;
|
||||
|
||||
va_start(ap, fmt);
|
||||
xvasprintf(&msg, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
log_debug("%s: %s", __func__, msg);
|
||||
|
||||
if (c == NULL)
|
||||
/* nothing */;
|
||||
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
||||
evbuffer_add_vprintf(c->stdout_data, fmt, ap);
|
||||
|
||||
evbuffer_add(c->stdout_data, "\n", 1);
|
||||
server_push_stdout(c);
|
||||
} else {
|
||||
w = c->session->curw->window;
|
||||
if (w->active->mode != &window_copy_mode) {
|
||||
window_pane_reset_mode(w->active);
|
||||
window_pane_set_mode(w->active, &window_copy_mode);
|
||||
window_copy_init_for_output(w->active);
|
||||
if (~c->flags & CLIENT_UTF8) {
|
||||
tmp = msg;
|
||||
msg = utf8_sanitize(tmp);
|
||||
free(tmp);
|
||||
}
|
||||
window_copy_vadd(w->active, fmt, ap);
|
||||
file_print(c, "%s\n", msg);
|
||||
} else {
|
||||
wp = c->session->curw->window->active;
|
||||
wme = TAILQ_FIRST(&wp->modes);
|
||||
if (wme == NULL || wme->mode != &window_view_mode)
|
||||
window_pane_set_mode(wp, &window_view_mode, NULL, NULL);
|
||||
window_copy_add(wp, "%s", msg);
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
free(msg);
|
||||
}
|
||||
|
||||
/* Show error from command. */
|
||||
void
|
||||
cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
|
||||
cmdq_error(struct cmdq_item *item, const char *fmt, ...)
|
||||
{
|
||||
struct client *c = cmdq->client;
|
||||
struct cmd *cmd = cmdq->cmd;
|
||||
struct client *c = item->client;
|
||||
struct cmd *cmd = item->cmd;
|
||||
va_list ap;
|
||||
char *msg;
|
||||
size_t msglen;
|
||||
char *tmp;
|
||||
|
||||
va_start(ap, fmt);
|
||||
msglen = xvasprintf(&msg, fmt, ap);
|
||||
xvasprintf(&msg, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
log_debug("%s: %s", __func__, msg);
|
||||
|
||||
if (c == NULL)
|
||||
cfg_add_cause("%s:%u: %s", cmd->file, cmd->line, msg);
|
||||
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
||||
evbuffer_add(c->stderr_data, msg, msglen);
|
||||
evbuffer_add(c->stderr_data, "\n", 1);
|
||||
|
||||
server_push_stderr(c);
|
||||
if (~c->flags & CLIENT_UTF8) {
|
||||
tmp = msg;
|
||||
msg = utf8_sanitize(tmp);
|
||||
free(tmp);
|
||||
}
|
||||
if (c->flags & CLIENT_CONTROL)
|
||||
file_print(c, "%s\n", msg);
|
||||
else
|
||||
file_error(c, "%s\n", msg);
|
||||
c->retval = 1;
|
||||
} else {
|
||||
*msg = toupper((u_char) *msg);
|
||||
@@ -121,149 +563,3 @@ cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
|
||||
|
||||
free(msg);
|
||||
}
|
||||
|
||||
/* Print a guard line. */
|
||||
void
|
||||
cmdq_guard(struct cmd_q *cmdq, const char *guard, int flags)
|
||||
{
|
||||
struct client *c = cmdq->client;
|
||||
|
||||
if (c == NULL || !(c->flags & CLIENT_CONTROL))
|
||||
return;
|
||||
|
||||
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u %d\n", guard,
|
||||
(long) cmdq->time, cmdq->number, flags);
|
||||
server_push_stdout(c);
|
||||
}
|
||||
|
||||
/* Add command list to queue and begin processing if needed. */
|
||||
void
|
||||
cmdq_run(struct cmd_q *cmdq, struct cmd_list *cmdlist, struct mouse_event *m)
|
||||
{
|
||||
cmdq_append(cmdq, cmdlist, m);
|
||||
|
||||
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 mouse_event *m)
|
||||
{
|
||||
struct cmd_q_item *item;
|
||||
|
||||
item = xcalloc(1, sizeof *item);
|
||||
item->cmdlist = cmdlist;
|
||||
TAILQ_INSERT_TAIL(&cmdq->queue, item, qentry);
|
||||
cmdlist->references++;
|
||||
|
||||
if (m != NULL)
|
||||
memcpy(&item->mouse, m, sizeof item->mouse);
|
||||
else
|
||||
item->mouse.valid = 0;
|
||||
}
|
||||
|
||||
/* Process one command. */
|
||||
enum cmd_retval
|
||||
cmdq_continue_one(struct cmd_q *cmdq)
|
||||
{
|
||||
struct cmd *cmd = cmdq->cmd;
|
||||
enum cmd_retval retval;
|
||||
char tmp[1024];
|
||||
int flags = !!(cmd->flags & CMD_CONTROL);
|
||||
|
||||
cmd_print(cmd, tmp, sizeof tmp);
|
||||
log_debug("cmdq %p: %s", cmdq, tmp);
|
||||
|
||||
cmdq->time = time(NULL);
|
||||
cmdq->number++;
|
||||
|
||||
cmdq_guard(cmdq, "begin", flags);
|
||||
|
||||
retval = cmd->entry->exec(cmd, cmdq);
|
||||
|
||||
if (retval == CMD_RETURN_ERROR)
|
||||
cmdq_guard(cmdq, "error", flags);
|
||||
else
|
||||
cmdq_guard(cmdq, "end", flags);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
/* Continue processing command queue. Returns 1 if finishes empty. */
|
||||
int
|
||||
cmdq_continue(struct cmd_q *cmdq)
|
||||
{
|
||||
struct client *c = cmdq->client;
|
||||
struct cmd_q_item *next;
|
||||
enum cmd_retval retval;
|
||||
int empty;
|
||||
|
||||
cmdq->references++;
|
||||
notify_disable();
|
||||
|
||||
log_debug("continuing cmdq %p: flags=%#x, client=%d", cmdq, cmdq->flags,
|
||||
c != NULL ? c->ibuf.fd : -1);
|
||||
|
||||
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 {
|
||||
while (cmdq->cmd != NULL) {
|
||||
retval = cmdq_continue_one(cmdq);
|
||||
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);
|
||||
}
|
||||
next = TAILQ_NEXT(cmdq->item, 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 > 0)
|
||||
cmdq->client->flags |= CLIENT_EXIT;
|
||||
if (cmdq->emptyfn != NULL)
|
||||
cmdq->emptyfn(cmdq);
|
||||
empty = 1;
|
||||
|
||||
out:
|
||||
notify_enable();
|
||||
cmdq_free(cmdq);
|
||||
|
||||
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 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -18,60 +18,144 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* 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 = {
|
||||
"refresh-client", "refresh",
|
||||
"C:St:", 0, 0,
|
||||
"[-S] [-C size] " CMD_TARGET_CLIENT_USAGE,
|
||||
0,
|
||||
cmd_refresh_client_exec
|
||||
.name = "refresh-client",
|
||||
.alias = "refresh",
|
||||
|
||||
.args = { "cC:DF:lLRSt:U", 0, 1 },
|
||||
.usage = "[-cDlLRSU] [-C XxY] [-F flags] " CMD_TARGET_CLIENT_USAGE
|
||||
" [adjustment]",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_refresh_client_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_refresh_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
const char *size;
|
||||
u_int w, h;
|
||||
struct tty *tty;
|
||||
struct window *w;
|
||||
const char *size, *errstr;
|
||||
char *copy, *next, *s;
|
||||
u_int x, y, adjust;
|
||||
|
||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
tty = &c->tty;
|
||||
|
||||
if (args_has(args, 'C')) {
|
||||
if ((size = args_get(args, 'C')) == NULL) {
|
||||
cmdq_error(cmdq, "missing size");
|
||||
return (CMD_RETURN_ERROR);
|
||||
if (args_has(args, 'c') ||
|
||||
args_has(args, 'L') ||
|
||||
args_has(args, 'R') ||
|
||||
args_has(args, 'U') ||
|
||||
args_has(args, 'D'))
|
||||
{
|
||||
if (args->argc == 0)
|
||||
adjust = 1;
|
||||
else {
|
||||
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(item, "adjustment %s", errstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
if (sscanf(size, "%u,%u", &w, &h) != 2) {
|
||||
cmdq_error(cmdq, "bad size argument");
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
if (args_has(args, 'c'))
|
||||
c->pan_window = NULL;
|
||||
else {
|
||||
w = c->session->curw->window;
|
||||
if (c->pan_window != w) {
|
||||
c->pan_window = w;
|
||||
c->pan_ox = tty->oox;
|
||||
c->pan_oy = tty->ooy;
|
||||
}
|
||||
if (args_has(args, 'L')) {
|
||||
if (c->pan_ox > adjust)
|
||||
c->pan_ox -= adjust;
|
||||
else
|
||||
c->pan_ox = 0;
|
||||
} else if (args_has(args, 'R')) {
|
||||
c->pan_ox += adjust;
|
||||
if (c->pan_ox > w->sx - tty->osx)
|
||||
c->pan_ox = w->sx - tty->osx;
|
||||
} else if (args_has(args, 'U')) {
|
||||
if (c->pan_oy > adjust)
|
||||
c->pan_oy -= adjust;
|
||||
else
|
||||
c->pan_oy = 0;
|
||||
} else if (args_has(args, 'D')) {
|
||||
c->pan_oy += adjust;
|
||||
if (c->pan_oy > w->sy - tty->osy)
|
||||
c->pan_oy = w->sy - tty->osy;
|
||||
}
|
||||
}
|
||||
if (w < PANE_MINIMUM || w > 5000 ||
|
||||
h < PANE_MINIMUM || h > 5000) {
|
||||
cmdq_error(cmdq, "size too small or too big");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (!(c->flags & CLIENT_CONTROL)) {
|
||||
cmdq_error(cmdq, "not a control client");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (tty_set_size(&c->tty, w, h))
|
||||
tty_update_client_offset(c);
|
||||
server_redraw_client(c);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 'l')) {
|
||||
if (c->session != NULL)
|
||||
tty_putcode_ptr2(&c->tty, TTYC_MS, "", "?");
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 'C') || args_has(args, 'F')) {
|
||||
if (args_has(args, 'C')) {
|
||||
if (!(c->flags & CLIENT_CONTROL)) {
|
||||
cmdq_error(item, "not a control client");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
size = args_get(args, 'C');
|
||||
if (sscanf(size, "%u,%u", &x, &y) != 2 &&
|
||||
sscanf(size, "%ux%u", &x, &y) != 2) {
|
||||
cmdq_error(item, "bad size argument");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (x < WINDOW_MINIMUM || x > WINDOW_MAXIMUM ||
|
||||
y < WINDOW_MINIMUM || y > WINDOW_MAXIMUM) {
|
||||
cmdq_error(item, "size too small or too big");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
tty_set_size(&c->tty, x, y, 0, 0);
|
||||
c->flags |= CLIENT_SIZECHANGED;
|
||||
recalculate_sizes();
|
||||
} else if (args_has(args, 'S')) {
|
||||
}
|
||||
if (args_has(args, 'F')) {
|
||||
if (!(c->flags & CLIENT_CONTROL)) {
|
||||
cmdq_error(item, "not a control client");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
s = copy = xstrdup(args_get(args, 'F'));
|
||||
while ((next = strsep(&s, ",")) != NULL) {
|
||||
/* Unknown flags are ignored. */
|
||||
if (strcmp(next, "no-output") == 0)
|
||||
c->flags |= CLIENT_CONTROL_NOOUTPUT;
|
||||
}
|
||||
free(copy);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 'S')) {
|
||||
c->flags |= CLIENT_STATUSFORCE;
|
||||
server_status_client(c);
|
||||
} else {
|
||||
c->flags |= CLIENT_STATUSFORCE;
|
||||
server_redraw_client(c);
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@@ -26,43 +27,54 @@
|
||||
* 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 = {
|
||||
"rename-session", "rename",
|
||||
"t:", 1, 1,
|
||||
CMD_TARGET_SESSION_USAGE " new-name",
|
||||
0,
|
||||
cmd_rename_session_exec
|
||||
.name = "rename-session",
|
||||
.alias = "rename",
|
||||
|
||||
.args = { "t:", 1, 1 },
|
||||
.usage = CMD_TARGET_SESSION_USAGE " new-name",
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_rename_session_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_rename_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s;
|
||||
const char *newname;
|
||||
struct args *args = self->args;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = item->target.s;
|
||||
char *newname;
|
||||
|
||||
newname = format_single(item, args->argv[0], c, s, NULL, NULL);
|
||||
if (strcmp(newname, s->name) == 0) {
|
||||
free(newname);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
newname = args->argv[0];
|
||||
if (!session_check_name(newname)) {
|
||||
cmdq_error(cmdq, "bad session name: %s", newname);
|
||||
cmdq_error(item, "bad session name: %s", newname);
|
||||
free(newname);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (session_find(newname) != NULL) {
|
||||
cmdq_error(cmdq, "duplicate session: %s", newname);
|
||||
cmdq_error(item, "duplicate session: %s", newname);
|
||||
free(newname);
|
||||
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);
|
||||
free(s->name);
|
||||
s->name = xstrdup(newname);
|
||||
s->name = newname;
|
||||
RB_INSERT(sessions, &sessions, s);
|
||||
|
||||
server_status_session(s);
|
||||
notify_session_renamed(s);
|
||||
notify_session("session-renamed", s);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -26,30 +26,37 @@
|
||||
* 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 = {
|
||||
"rename-window", "renamew",
|
||||
"t:", 1, 1,
|
||||
CMD_TARGET_WINDOW_USAGE " new-name",
|
||||
0,
|
||||
cmd_rename_window_exec
|
||||
.name = "rename-window",
|
||||
.alias = "renamew",
|
||||
|
||||
.args = { "t:", 1, 1 },
|
||||
.usage = CMD_TARGET_WINDOW_USAGE " new-name",
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_rename_window_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_rename_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_rename_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
char *newname;
|
||||
|
||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
window_set_name(wl->window, args->argv[0]);
|
||||
options_set_number(&wl->window->options, "automatic-rename", 0);
|
||||
newname = format_single(item, args->argv[0], c, s, wl, NULL);
|
||||
window_set_name(wl->window, newname);
|
||||
options_set_number(wl->window->options, "automatic-rename", 0);
|
||||
|
||||
server_status_window(wl->window);
|
||||
free(newname);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@@ -26,47 +27,51 @@
|
||||
* Increase or decrease pane size.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
void cmd_resize_pane_mouse_update(struct client *, struct mouse_event *);
|
||||
static void cmd_resize_pane_mouse_update(struct client *,
|
||||
struct mouse_event *);
|
||||
|
||||
const struct cmd_entry cmd_resize_pane_entry = {
|
||||
"resize-pane", "resizep",
|
||||
"DLMRt:Ux:y:Z", 0, 1,
|
||||
"[-DLMRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE
|
||||
" [adjustment]",
|
||||
0,
|
||||
cmd_resize_pane_exec
|
||||
.name = "resize-pane",
|
||||
.alias = "resizep",
|
||||
|
||||
.args = { "DLMRt:Ux:y:Z", 0, 1 },
|
||||
.usage = "[-DLMRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " "
|
||||
"[adjustment]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_resize_pane_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c = cmdq->client;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
struct window *w;
|
||||
const char *errstr;
|
||||
char *cause;
|
||||
struct window_pane *wp;
|
||||
struct cmdq_shared *shared = item->shared;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window *w = wl->window;
|
||||
struct client *c = item->client;
|
||||
struct session *s = item->target.s;
|
||||
const char *errstr, *p;
|
||||
char *cause, *copy;
|
||||
u_int adjust;
|
||||
int x, y;
|
||||
int x, y, percentage;
|
||||
size_t plen;
|
||||
|
||||
if (args_has(args, 'M')) {
|
||||
if (cmd_mouse_window(&cmdq->item->mouse, &s) == NULL)
|
||||
if (cmd_mouse_window(&shared->mouse, &s) == NULL)
|
||||
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, &cmdq->item->mouse);
|
||||
cmd_resize_pane_mouse_update(c, &shared->mouse);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
w = wl->window;
|
||||
|
||||
if (args_has(args, 'Z')) {
|
||||
if (w->flags & WINDOW_ZOOMED)
|
||||
window_unzoom(w);
|
||||
@@ -83,88 +88,142 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
else {
|
||||
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(cmdq, "adjustment %s", errstr);
|
||||
cmdq_error(item, "adjustment %s", errstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
if (args_has(self->args, 'x')) {
|
||||
x = args_strtonum(self->args, 'x', PANE_MINIMUM, INT_MAX,
|
||||
&cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(cmdq, "width %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
if ((p = args_get(args, 'x')) != NULL) {
|
||||
plen = strlen(p);
|
||||
if (p[plen - 1] == '%') {
|
||||
copy = xstrdup(p);
|
||||
copy[plen - 1] = '\0';
|
||||
percentage = strtonum(copy, 0, INT_MAX, &errstr);
|
||||
free(copy);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(item, "width %s", errstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
x = (w->sx * percentage) / 100;
|
||||
if (x < PANE_MINIMUM)
|
||||
x = PANE_MINIMUM;
|
||||
if (x > INT_MAX)
|
||||
x = INT_MAX;
|
||||
} else {
|
||||
x = args_strtonum(args, 'x', PANE_MINIMUM, INT_MAX,
|
||||
&cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "width %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
layout_resize_pane_to(wp, LAYOUT_LEFTRIGHT, x);
|
||||
}
|
||||
if (args_has(self->args, 'y')) {
|
||||
y = args_strtonum(self->args, 'y', PANE_MINIMUM, INT_MAX,
|
||||
&cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(cmdq, "height %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
if ((p = args_get(args, 'y')) != NULL) {
|
||||
plen = strlen(p);
|
||||
if (p[plen - 1] == '%') {
|
||||
copy = xstrdup(p);
|
||||
copy[plen - 1] = '\0';
|
||||
percentage = strtonum(copy, 0, INT_MAX, &errstr);
|
||||
free(copy);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(item, "height %s", errstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
y = (w->sy * percentage) / 100;
|
||||
if (y < PANE_MINIMUM)
|
||||
y = PANE_MINIMUM;
|
||||
if (y > INT_MAX)
|
||||
y = INT_MAX;
|
||||
}
|
||||
else {
|
||||
y = args_strtonum(args, 'y', PANE_MINIMUM, INT_MAX,
|
||||
&cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "height %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y);
|
||||
}
|
||||
|
||||
if (args_has(self->args, 'L'))
|
||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
|
||||
else if (args_has(self->args, 'R'))
|
||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust);
|
||||
else if (args_has(self->args, 'U'))
|
||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust);
|
||||
else if (args_has(self->args, 'D'))
|
||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
|
||||
if (args_has(args, 'L'))
|
||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust, 1);
|
||||
else if (args_has(args, 'R'))
|
||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust, 1);
|
||||
else if (args_has(args, 'U'))
|
||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust, 1);
|
||||
else if (args_has(args, 'D'))
|
||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust, 1);
|
||||
server_redraw_window(wl->window);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
void
|
||||
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;
|
||||
struct window *w;
|
||||
u_int y, ly, x, lx;
|
||||
static const int offsets[][2] = {
|
||||
{ 0, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 },
|
||||
};
|
||||
struct layout_cell *cells[nitems(offsets)], *lc;
|
||||
u_int ncells = 0, i, j, resizes = 0;
|
||||
enum layout_type type;
|
||||
|
||||
wl = cmd_mouse_window(m, NULL);
|
||||
if (wl == NULL) {
|
||||
c->tty.mouse_drag_update = NULL;
|
||||
return;
|
||||
}
|
||||
w = wl->window;
|
||||
|
||||
y = m->y;
|
||||
if (m->statusat == 0 && y > 0)
|
||||
y--;
|
||||
y = m->y + m->oy; x = m->x + m->ox;
|
||||
if (m->statusat == 0 && y >= m->statuslines)
|
||||
y -= m->statuslines;
|
||||
else if (m->statusat > 0 && y >= (u_int)m->statusat)
|
||||
y = m->statusat - 1;
|
||||
ly = m->ly;
|
||||
if (m->statusat == 0 && ly > 0)
|
||||
ly--;
|
||||
ly = m->ly + m->oy; lx = m->lx + m->ox;
|
||||
if (m->statusat == 0 && ly >= m->statuslines)
|
||||
ly -= m->statuslines;
|
||||
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))
|
||||
for (i = 0; i < nitems(cells); i++) {
|
||||
lc = layout_search_by_border(w->layout_root, lx + offsets[i][0],
|
||||
ly + offsets[i][1]);
|
||||
if (lc == NULL)
|
||||
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);
|
||||
found = 1;
|
||||
for (j = 0; j < ncells; j++) {
|
||||
if (cells[j] == lc) {
|
||||
lc = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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);
|
||||
found = 1;
|
||||
if (lc == NULL)
|
||||
continue;
|
||||
|
||||
cells[ncells] = lc;
|
||||
ncells++;
|
||||
}
|
||||
if (ncells == 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < ncells; i++) {
|
||||
type = cells[i]->parent->type;
|
||||
if (y != ly && type == LAYOUT_TOPBOTTOM) {
|
||||
layout_resize_layout(w, cells[i], type, y - ly, 0);
|
||||
resizes++;
|
||||
} else if (x != lx && type == LAYOUT_LEFTRIGHT) {
|
||||
layout_resize_layout(w, cells[i], type, x - lx, 0);
|
||||
resizes++;
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
server_redraw_window(wl->window);
|
||||
else
|
||||
c->tty.mouse_drag_update = NULL;
|
||||
if (resizes != 0)
|
||||
server_redraw_window(w);
|
||||
}
|
||||
|
||||
113
cmd-resize-window.c
Normal file
113
cmd-resize-window.c
Normal file
@@ -0,0 +1,113 @@
|
||||
/* $OpenBSD$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Increase or decrease window size.
|
||||
*/
|
||||
|
||||
static enum cmd_retval cmd_resize_window_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_resize_window_entry = {
|
||||
.name = "resize-window",
|
||||
.alias = "resizew",
|
||||
|
||||
.args = { "aADLRt:Ux:y:", 0, 1 },
|
||||
.usage = "[-aADLRU] [-x width] [-y height] " CMD_TARGET_WINDOW_USAGE " "
|
||||
"[adjustment]",
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_resize_window_exec
|
||||
};
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window *w = wl->window;
|
||||
struct session *s = item->target.s;
|
||||
const char *errstr;
|
||||
char *cause;
|
||||
u_int adjust, sx, sy;
|
||||
int xpixel = -1, ypixel = -1;
|
||||
|
||||
if (args->argc == 0)
|
||||
adjust = 1;
|
||||
else {
|
||||
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(item, "adjustment %s", errstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
sx = w->sx;
|
||||
sy = w->sy;
|
||||
|
||||
if (args_has(args, 'x')) {
|
||||
sx = args_strtonum(args, 'x', WINDOW_MINIMUM, WINDOW_MAXIMUM,
|
||||
&cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "width %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
if (args_has(args, 'y')) {
|
||||
sy = args_strtonum(args, 'y', WINDOW_MINIMUM, WINDOW_MAXIMUM,
|
||||
&cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "height %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
if (args_has(args, 'L')) {
|
||||
if (sx >= adjust)
|
||||
sx -= adjust;
|
||||
} else if (args_has(args, 'R'))
|
||||
sx += adjust;
|
||||
else if (args_has(args, 'U')) {
|
||||
if (sy >= adjust)
|
||||
sy -= adjust;
|
||||
} else if (args_has(args, 'D'))
|
||||
sy += adjust;
|
||||
|
||||
if (args_has(args, 'A')) {
|
||||
default_window_size(NULL, s, w, &sx, &sy, &xpixel, &ypixel,
|
||||
WINDOW_SIZE_LARGEST);
|
||||
} else if (args_has(args, 'a')) {
|
||||
default_window_size(NULL, s, w, &sx, &sy, &xpixel, &ypixel,
|
||||
WINDOW_SIZE_SMALLEST);
|
||||
}
|
||||
|
||||
options_set_number(w->options, "window-size", WINDOW_SIZE_MANUAL);
|
||||
resize_window(w, sx, sy, xpixel, ypixel);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@@ -28,69 +28,69 @@
|
||||
* 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 = {
|
||||
"respawn-pane", "respawnp",
|
||||
"kt:", 0, -1,
|
||||
"[-k] " CMD_TARGET_PANE_USAGE " [command]",
|
||||
0,
|
||||
cmd_respawn_pane_exec
|
||||
.name = "respawn-pane",
|
||||
.alias = "respawnp",
|
||||
|
||||
.args = { "c:e:kt:", 0, -1 },
|
||||
.usage = "[-k] [-c start-directory] [-e environment] "
|
||||
CMD_TARGET_PANE_USAGE " [command]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_respawn_pane_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl;
|
||||
struct window *w;
|
||||
struct window_pane *wp;
|
||||
struct session *s;
|
||||
struct environ env;
|
||||
const char *path;
|
||||
char *cause;
|
||||
u_int idx;
|
||||
struct environ_entry *envent;
|
||||
struct spawn_context sc;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
char *cause = NULL;
|
||||
const char *add;
|
||||
struct args_value *value;
|
||||
|
||||
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
w = wl->window;
|
||||
memset(&sc, 0, sizeof sc);
|
||||
sc.item = item;
|
||||
sc.s = s;
|
||||
sc.wl = wl;
|
||||
|
||||
if (!args_has(self->args, 'k') && wp->fd != -1) {
|
||||
if (window_pane_index(wp, &idx) != 0)
|
||||
fatalx("index not found");
|
||||
cmdq_error(cmdq, "pane still active: %s:%d.%u",
|
||||
s->name, wl->idx, idx);
|
||||
return (CMD_RETURN_ERROR);
|
||||
sc.wp0 = wp;
|
||||
sc.lc = NULL;
|
||||
|
||||
sc.name = NULL;
|
||||
sc.argc = args->argc;
|
||||
sc.argv = args->argv;
|
||||
sc.environ = environ_create();
|
||||
|
||||
add = args_first_value(args, 'e', &value);
|
||||
while (add != NULL) {
|
||||
environ_put(sc.environ, add);
|
||||
add = args_next_value(&value);
|
||||
}
|
||||
|
||||
environ_init(&env);
|
||||
environ_copy(&global_environ, &env);
|
||||
environ_copy(&s->environ, &env);
|
||||
server_fill_environ(s, &env);
|
||||
sc.idx = -1;
|
||||
sc.cwd = args_get(args, 'c');
|
||||
|
||||
window_pane_reset_mode(wp);
|
||||
screen_reinit(&wp->base);
|
||||
input_init(wp);
|
||||
sc.flags = SPAWN_RESPAWN;
|
||||
if (args_has(args, 'k'))
|
||||
sc.flags |= SPAWN_KILL;
|
||||
|
||||
path = NULL;
|
||||
if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||
envent = environ_find(&cmdq->client->environ, "PATH");
|
||||
else
|
||||
envent = environ_find(&s->environ, "PATH");
|
||||
if (envent != NULL)
|
||||
path = envent->value;
|
||||
|
||||
if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, -1, &env,
|
||||
s->tio, &cause) != 0) {
|
||||
cmdq_error(cmdq, "respawn pane failed: %s", cause);
|
||||
if (spawn_pane(&sc, &cause) == NULL) {
|
||||
cmdq_error(item, "respawn pane failed: %s", cause);
|
||||
free(cause);
|
||||
environ_free(&env);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
wp->flags |= PANE_REDRAW;
|
||||
server_status_window(w);
|
||||
|
||||
environ_free(&env);
|
||||
wp->flags |= PANE_REDRAW;
|
||||
server_status_window(wp->window);
|
||||
|
||||
environ_free(sc.environ);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@@ -27,80 +27,66 @@
|
||||
* 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 = {
|
||||
"respawn-window", "respawnw",
|
||||
"kt:", 0, -1,
|
||||
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
|
||||
0,
|
||||
cmd_respawn_window_exec
|
||||
.name = "respawn-window",
|
||||
.alias = "respawnw",
|
||||
|
||||
.args = { "c:e:kt:", 0, -1 },
|
||||
.usage = "[-k] [-c start-directory] [-e environment] "
|
||||
CMD_TARGET_WINDOW_USAGE " [command]",
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_respawn_window_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl;
|
||||
struct window *w;
|
||||
struct window_pane *wp;
|
||||
struct session *s;
|
||||
struct environ env;
|
||||
const char *path;
|
||||
char *cause;
|
||||
struct environ_entry *envent;
|
||||
struct spawn_context sc;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
char *cause = NULL;
|
||||
const char *add;
|
||||
struct args_value *value;
|
||||
|
||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
w = wl->window;
|
||||
memset(&sc, 0, sizeof sc);
|
||||
sc.item = item;
|
||||
sc.s = s;
|
||||
sc.wl = wl;
|
||||
sc.c = cmd_find_client(item, NULL, 1);
|
||||
|
||||
if (!args_has(self->args, 'k')) {
|
||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||
if (wp->fd == -1)
|
||||
continue;
|
||||
cmdq_error(cmdq,
|
||||
"window still active: %s:%d", s->name, wl->idx);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
sc.name = NULL;
|
||||
sc.argc = args->argc;
|
||||
sc.argv = args->argv;
|
||||
sc.environ = environ_create();
|
||||
|
||||
add = args_first_value(args, 'e', &value);
|
||||
while (add != NULL) {
|
||||
environ_put(sc.environ, add);
|
||||
add = args_next_value(&value);
|
||||
}
|
||||
|
||||
environ_init(&env);
|
||||
environ_copy(&global_environ, &env);
|
||||
environ_copy(&s->environ, &env);
|
||||
server_fill_environ(s, &env);
|
||||
sc.idx = -1;
|
||||
sc.cwd = args_get(args, 'c');
|
||||
|
||||
wp = TAILQ_FIRST(&w->panes);
|
||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||
layout_free(w);
|
||||
window_destroy_panes(w);
|
||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||
window_pane_resize(wp, w->sx, w->sy);
|
||||
sc.flags = SPAWN_RESPAWN;
|
||||
if (args_has(args, 'k'))
|
||||
sc.flags |= SPAWN_KILL;
|
||||
|
||||
path = NULL;
|
||||
if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||
envent = environ_find(&cmdq->client->environ, "PATH");
|
||||
else
|
||||
envent = environ_find(&s->environ, "PATH");
|
||||
if (envent != NULL)
|
||||
path = envent->value;
|
||||
|
||||
if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, -1, &env,
|
||||
s->tio, &cause) != 0) {
|
||||
cmdq_error(cmdq, "respawn window failed: %s", cause);
|
||||
if (spawn_window(&sc, &cause) == NULL) {
|
||||
cmdq_error(item, "respawn window failed: %s", cause);
|
||||
free(cause);
|
||||
environ_free(&env);
|
||||
server_destroy_pane(wp);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
layout_init(w, wp);
|
||||
window_pane_reset_mode(wp);
|
||||
screen_reinit(&wp->base);
|
||||
input_init(wp);
|
||||
window_set_active_pane(w, wp);
|
||||
|
||||
recalculate_sizes();
|
||||
server_redraw_window(w);
|
||||
server_redraw_window(wl->window);
|
||||
|
||||
environ_free(&env);
|
||||
environ_free(sc.environ);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -24,29 +24,33 @@
|
||||
* Rotate the panes in a window.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_rotate_window_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_rotate_window_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_rotate_window_entry = {
|
||||
"rotate-window", "rotatew",
|
||||
"Dt:U", 0, 0,
|
||||
"[-DU] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_rotate_window_exec
|
||||
.name = "rotate-window",
|
||||
.alias = "rotatew",
|
||||
|
||||
.args = { "Dt:UZ", 0, 0 },
|
||||
.usage = "[-DUZ] " CMD_TARGET_WINDOW_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_rotate_window_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_rotate_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl;
|
||||
struct window *w;
|
||||
struct cmd_find_state *current = &item->shared->current;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window *w = wl->window;
|
||||
struct window_pane *wp, *wp2;
|
||||
struct layout_cell *lc;
|
||||
u_int sx, sy, xoff, yoff;
|
||||
|
||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
w = wl->window;
|
||||
window_push_zoom(w, args_has(self->args, 'Z'));
|
||||
|
||||
if (args_has(self->args, 'D')) {
|
||||
wp = TAILQ_LAST(&w->panes, window_panes);
|
||||
@@ -73,8 +77,6 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
|
||||
if ((wp = TAILQ_PREV(w->active, window_panes, entry)) == NULL)
|
||||
wp = TAILQ_LAST(&w->panes, window_panes);
|
||||
window_set_active_pane(w, wp);
|
||||
server_redraw_window(w);
|
||||
} else {
|
||||
wp = TAILQ_FIRST(&w->panes);
|
||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||
@@ -100,9 +102,12 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
|
||||
if ((wp = TAILQ_NEXT(w->active, entry)) == NULL)
|
||||
wp = TAILQ_FIRST(&w->panes);
|
||||
window_set_active_pane(w, wp);
|
||||
server_redraw_window(w);
|
||||
}
|
||||
|
||||
window_set_active_pane(w, wp, 1);
|
||||
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||
window_pop_zoom(w);
|
||||
server_redraw_window(w);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
163
cmd-run-shell.c
163
cmd-run-shell.c
@@ -29,154 +29,139 @@
|
||||
* 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 *);
|
||||
void cmd_run_shell_free(void *);
|
||||
void cmd_run_shell_print(struct job *, const char *);
|
||||
static void cmd_run_shell_callback(struct job *);
|
||||
static void cmd_run_shell_free(void *);
|
||||
static void cmd_run_shell_print(struct job *, const char *);
|
||||
|
||||
const struct cmd_entry cmd_run_shell_entry = {
|
||||
"run-shell", "run",
|
||||
"bt:", 1, 1,
|
||||
"[-b] " CMD_TARGET_PANE_USAGE " shell-command",
|
||||
0,
|
||||
cmd_run_shell_exec
|
||||
.name = "run-shell",
|
||||
.alias = "run",
|
||||
|
||||
.args = { "bt:", 1, 1 },
|
||||
.usage = "[-b] " CMD_TARGET_PANE_USAGE " shell-command",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_run_shell_exec
|
||||
};
|
||||
|
||||
struct cmd_run_shell_data {
|
||||
char *cmd;
|
||||
struct cmd_q *cmdq;
|
||||
int bflag;
|
||||
int wp_id;
|
||||
char *cmd;
|
||||
struct cmdq_item *item;
|
||||
int wp_id;
|
||||
};
|
||||
|
||||
void
|
||||
static void
|
||||
cmd_run_shell_print(struct job *job, const char *msg)
|
||||
{
|
||||
struct cmd_run_shell_data *cdata = job->data;
|
||||
struct cmd_run_shell_data *cdata = job_get_data(job);
|
||||
struct window_pane *wp = NULL;
|
||||
struct cmd_find_state fs;
|
||||
struct window_mode_entry *wme;
|
||||
|
||||
if (cdata->wp_id != -1)
|
||||
wp = window_pane_find_by_id(cdata->wp_id);
|
||||
if (wp == NULL) {
|
||||
cmdq_print(cdata->cmdq, "%s", msg);
|
||||
return;
|
||||
if (cdata->item != NULL) {
|
||||
cmdq_print(cdata->item, "%s", msg);
|
||||
return;
|
||||
}
|
||||
if (cmd_find_from_nothing(&fs, 0) != 0)
|
||||
return;
|
||||
wp = fs.wp;
|
||||
if (wp == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
if (window_pane_set_mode(wp, &window_copy_mode) == 0)
|
||||
window_copy_init_for_output(wp);
|
||||
if (wp->mode == &window_copy_mode)
|
||||
window_copy_add(wp, "%s", msg);
|
||||
wme = TAILQ_FIRST(&wp->modes);
|
||||
if (wme == NULL || wme->mode != &window_view_mode)
|
||||
window_pane_set_mode(wp, &window_view_mode, NULL, NULL);
|
||||
window_copy_add(wp, "%s", msg);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct cmd_run_shell_data *cdata;
|
||||
char *shellcmd;
|
||||
struct client *c;
|
||||
struct session *s = NULL;
|
||||
struct winlink *wl = NULL;
|
||||
struct window_pane *wp = NULL;
|
||||
struct format_tree *ft;
|
||||
int cwd;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
|
||||
if (args_has(args, 't')) {
|
||||
wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
|
||||
cwd = wp->cwd;
|
||||
} else {
|
||||
c = cmd_find_client(cmdq, NULL, 1);
|
||||
if (c != NULL && c->session != NULL) {
|
||||
s = c->session;
|
||||
wl = s->curw;
|
||||
wp = wl->window->active;
|
||||
}
|
||||
if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||
cwd = cmdq->client->cwd;
|
||||
else if (s != NULL)
|
||||
cwd = s->cwd;
|
||||
else
|
||||
cwd = -1;
|
||||
cdata = xcalloc(1, sizeof *cdata);
|
||||
cdata->cmd = format_single(item, args->argv[0], c, s, wl, wp);
|
||||
|
||||
if (args_has(args, 't') && wp != NULL)
|
||||
cdata->wp_id = wp->id;
|
||||
else
|
||||
cdata->wp_id = -1;
|
||||
|
||||
if (!args_has(args, 'b'))
|
||||
cdata->item = item;
|
||||
|
||||
if (job_run(cdata->cmd, s, server_client_get_cwd(item->client, s), NULL,
|
||||
cmd_run_shell_callback, cmd_run_shell_free, cdata, 0) == NULL) {
|
||||
cmdq_error(item, "failed to run command: %s", cdata->cmd);
|
||||
free(cdata);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
ft = format_create();
|
||||
format_defaults(ft, NULL, s, wl, wp);
|
||||
shellcmd = format_expand(ft, args->argv[0]);
|
||||
format_free(ft);
|
||||
|
||||
cdata = xmalloc(sizeof *cdata);
|
||||
cdata->cmd = shellcmd;
|
||||
cdata->bflag = args_has(args, 'b');
|
||||
cdata->wp_id = wp != NULL ? (int) wp->id : -1;
|
||||
|
||||
cdata->cmdq = cmdq;
|
||||
cmdq->references++;
|
||||
|
||||
job_run(shellcmd, 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_WAIT);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
cmd_run_shell_callback(struct job *job)
|
||||
{
|
||||
struct cmd_run_shell_data *cdata = job->data;
|
||||
struct cmd_q *cmdq = cdata->cmdq;
|
||||
char *cmd, *msg, *line;
|
||||
struct cmd_run_shell_data *cdata = job_get_data(job);
|
||||
struct bufferevent *event = job_get_event(job);
|
||||
char *cmd = cdata->cmd, *msg = NULL, *line;
|
||||
size_t size;
|
||||
int retcode;
|
||||
u_int lines;
|
||||
int retcode, status;
|
||||
|
||||
if (cmdq->flags & CMD_Q_DEAD)
|
||||
return;
|
||||
cmd = cdata->cmd;
|
||||
|
||||
lines = 0;
|
||||
do {
|
||||
if ((line = evbuffer_readline(job->event->input)) != NULL) {
|
||||
if ((line = evbuffer_readline(event->input)) != NULL) {
|
||||
cmd_run_shell_print(job, line);
|
||||
free(line);
|
||||
lines++;
|
||||
}
|
||||
} while (line != NULL);
|
||||
|
||||
size = EVBUFFER_LENGTH(job->event->input);
|
||||
size = EVBUFFER_LENGTH(event->input);
|
||||
if (size != 0) {
|
||||
line = xmalloc(size + 1);
|
||||
memcpy(line, EVBUFFER_DATA(job->event->input), size);
|
||||
memcpy(line, EVBUFFER_DATA(event->input), size);
|
||||
line[size] = '\0';
|
||||
|
||||
cmd_run_shell_print(job, line);
|
||||
lines++;
|
||||
|
||||
free(line);
|
||||
}
|
||||
|
||||
msg = NULL;
|
||||
if (WIFEXITED(job->status)) {
|
||||
if ((retcode = WEXITSTATUS(job->status)) != 0)
|
||||
status = job_get_status(job);
|
||||
if (WIFEXITED(status)) {
|
||||
if ((retcode = WEXITSTATUS(status)) != 0)
|
||||
xasprintf(&msg, "'%s' returned %d", cmd, retcode);
|
||||
} else if (WIFSIGNALED(job->status)) {
|
||||
retcode = WTERMSIG(job->status);
|
||||
} else if (WIFSIGNALED(status)) {
|
||||
retcode = WTERMSIG(status);
|
||||
xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode);
|
||||
}
|
||||
if (msg != NULL)
|
||||
cmd_run_shell_print(job, msg);
|
||||
free(msg);
|
||||
|
||||
if (cdata->item != NULL)
|
||||
cmdq_continue(cdata->item);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
cmd_run_shell_free(void *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);
|
||||
|
||||
@@ -31,128 +31,83 @@
|
||||
* 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 = {
|
||||
"save-buffer", "saveb",
|
||||
"ab:", 1, 1,
|
||||
"[-a] " CMD_BUFFER_USAGE " path",
|
||||
0,
|
||||
cmd_save_buffer_exec
|
||||
.name = "save-buffer",
|
||||
.alias = "saveb",
|
||||
|
||||
.args = { "ab:", 1, 1 },
|
||||
.usage = "[-a] " CMD_BUFFER_USAGE " path",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_save_buffer_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_show_buffer_entry = {
|
||||
"show-buffer", "showb",
|
||||
"b:", 0, 0,
|
||||
CMD_BUFFER_USAGE,
|
||||
0,
|
||||
cmd_save_buffer_exec
|
||||
.name = "show-buffer",
|
||||
.alias = "showb",
|
||||
|
||||
.args = { "b:", 0, 0 },
|
||||
.usage = CMD_BUFFER_USAGE,
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_save_buffer_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static void
|
||||
cmd_save_buffer_done(__unused struct client *c, const char *path, int error,
|
||||
__unused int closed, __unused struct evbuffer *buffer, void *data)
|
||||
{
|
||||
struct cmdq_item *item = data;
|
||||
|
||||
if (!closed)
|
||||
return;
|
||||
|
||||
if (error != 0)
|
||||
cmdq_error(item, "%s: %s", path, strerror(error));
|
||||
cmdq_continue(item);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c = cmdq->client;
|
||||
struct session *s;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct paste_buffer *pb;
|
||||
const char *path, *bufname, *bufdata, *start, *end;
|
||||
char *msg;
|
||||
size_t size, used, msglen, bufsize;
|
||||
int cwd, fd;
|
||||
FILE *f;
|
||||
int flags;
|
||||
const char *bufname = args_get(args, 'b'), *bufdata;
|
||||
size_t bufsize;
|
||||
char *path;
|
||||
|
||||
if (!args_has(args, 'b')) {
|
||||
if (bufname == NULL) {
|
||||
if ((pb = paste_get_top(NULL)) == NULL) {
|
||||
cmdq_error(cmdq, "no buffers");
|
||||
cmdq_error(item, "no buffers");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else {
|
||||
bufname = args_get(args, 'b');
|
||||
pb = paste_get_name(bufname);
|
||||
if (pb == NULL) {
|
||||
cmdq_error(cmdq, "no buffer %s", bufname);
|
||||
cmdq_error(item, "no buffer %s", bufname);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
bufdata = paste_buffer_data(pb, &bufsize);
|
||||
|
||||
if (self->entry == &cmd_show_buffer_entry)
|
||||
path = "-";
|
||||
path = xstrdup("-");
|
||||
else
|
||||
path = args->argv[0];
|
||||
if (strcmp(path, "-") == 0) {
|
||||
if (c == NULL) {
|
||||
cmdq_error(cmdq, "can't write to stdout");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (c->session == NULL || (c->flags & CLIENT_CONTROL))
|
||||
goto do_stdout;
|
||||
goto do_print;
|
||||
}
|
||||
|
||||
if (c != NULL && c->session == NULL)
|
||||
cwd = c->cwd;
|
||||
else if ((s = cmd_find_current(cmdq)) != NULL)
|
||||
cwd = s->cwd;
|
||||
path = format_single(item, args->argv[0], c, s, wl, wp);
|
||||
if (args_has(self->args, 'a'))
|
||||
flags = O_APPEND;
|
||||
else
|
||||
cwd = AT_FDCWD;
|
||||
flags = 0;
|
||||
file_write(item->client, path, flags, bufdata, bufsize,
|
||||
cmd_save_buffer_done, item);
|
||||
free(path);
|
||||
|
||||
f = NULL;
|
||||
if (args_has(self->args, 'a')) {
|
||||
fd = openat(cwd, path, O_CREAT|O_RDWR|O_APPEND, 0600);
|
||||
if (fd != -1)
|
||||
f = fdopen(fd, "ab");
|
||||
} else {
|
||||
fd = openat(cwd, path, O_CREAT|O_RDWR|O_TRUNC, 0600);
|
||||
if (fd != -1)
|
||||
f = fdopen(fd, "wb");
|
||||
}
|
||||
if (f == NULL) {
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
cmdq_error(cmdq, "%s: %s", path, strerror(errno));
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (fwrite(bufdata, 1, bufsize, f) != bufsize) {
|
||||
cmdq_error(cmdq, "%s: fwrite error", path);
|
||||
fclose(f);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
do_stdout:
|
||||
evbuffer_add(c->stdout_data, bufdata, bufsize);
|
||||
server_push_stdout(c);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
do_print:
|
||||
if (bufsize > (INT_MAX / 4) - 1) {
|
||||
cmdq_error(cmdq, "buffer too big");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
msg = NULL;
|
||||
|
||||
used = 0;
|
||||
while (used != bufsize) {
|
||||
start = bufdata + used;
|
||||
end = memchr(start, '\n', bufsize - used);
|
||||
if (end != NULL)
|
||||
size = end - start;
|
||||
else
|
||||
size = bufsize - used;
|
||||
|
||||
msglen = size * 4 + 1;
|
||||
msg = xrealloc(msg, msglen);
|
||||
|
||||
strvisx(msg, start, size, VIS_OCTAL|VIS_TAB);
|
||||
cmdq_print(cmdq, "%s", msg);
|
||||
|
||||
used += size + (end != NULL);
|
||||
}
|
||||
|
||||
free(msg);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -26,45 +26,58 @@
|
||||
* Switch window to selected layout.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_select_layout_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_select_layout_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_select_layout_entry = {
|
||||
"select-layout", "selectl",
|
||||
"nopt:", 0, 1,
|
||||
"[-nop] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
||||
0,
|
||||
cmd_select_layout_exec
|
||||
.name = "select-layout",
|
||||
.alias = "selectl",
|
||||
|
||||
.args = { "Enopt:", 0, 1 },
|
||||
.usage = "[-Enop] " CMD_TARGET_PANE_USAGE " [layout-name]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_select_layout_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_next_layout_entry = {
|
||||
"next-layout", "nextl",
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_select_layout_exec
|
||||
.name = "next-layout",
|
||||
.alias = "nextl",
|
||||
|
||||
.args = { "t:", 0, 0 },
|
||||
.usage = CMD_TARGET_WINDOW_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_select_layout_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_previous_layout_entry = {
|
||||
"previous-layout", "prevl",
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_select_layout_exec
|
||||
.name = "previous-layout",
|
||||
.alias = "prevl",
|
||||
|
||||
.args = { "t:", 0, 0 },
|
||||
.usage = CMD_TARGET_WINDOW_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_select_layout_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl;
|
||||
struct window *w;
|
||||
const char *layoutname;
|
||||
char *oldlayout;
|
||||
int next, previous, layout;
|
||||
|
||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
w = wl->window;
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window *w = wl->window;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
const char *layoutname;
|
||||
char *oldlayout;
|
||||
int next, previous, layout;
|
||||
|
||||
server_unzoom_window(w);
|
||||
|
||||
@@ -86,6 +99,11 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
goto changed;
|
||||
}
|
||||
|
||||
if (args_has(args, 'E')) {
|
||||
layout_spread_out(wp);
|
||||
goto changed;
|
||||
}
|
||||
|
||||
if (!args_has(args, 'o')) {
|
||||
if (args->argc == 0)
|
||||
layout = w->lastlayout;
|
||||
@@ -106,7 +124,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
|
||||
if (layoutname != NULL) {
|
||||
if (layout_parse(w, layoutname) == -1) {
|
||||
cmdq_error(cmdq, "can't set layout: %s", layoutname);
|
||||
cmdq_error(item, "can't set layout: %s", layoutname);
|
||||
goto error;
|
||||
}
|
||||
goto changed;
|
||||
@@ -117,7 +135,9 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
|
||||
changed:
|
||||
free(oldlayout);
|
||||
recalculate_sizes();
|
||||
server_redraw_window(w);
|
||||
notify_window("window-layout-changed", w);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
error:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -18,81 +18,122 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Select pane.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_select_pane_entry = {
|
||||
"select-pane", "selectp",
|
||||
"DdegLlMmP:Rt:U", 0, 0,
|
||||
"[-DdegLlMmRU] [-P style] " CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
cmd_select_pane_exec
|
||||
.name = "select-pane",
|
||||
.alias = "selectp",
|
||||
|
||||
.args = { "DdegLlMmP:RT:t:UZ", 0, 0 }, /* -P and -g deprecated */
|
||||
.usage = "[-DdeLlMmRUZ] [-T title] " CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_select_pane_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_last_pane_entry = {
|
||||
"last-pane", "lastp",
|
||||
"det:", 0, 0,
|
||||
"[-de] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_select_pane_exec
|
||||
.name = "last-pane",
|
||||
.alias = "lastp",
|
||||
|
||||
.args = { "det:Z", 0, 0 },
|
||||
.usage = "[-deZ] " CMD_TARGET_WINDOW_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_select_pane_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static void
|
||||
cmd_select_pane_redraw(struct window *w)
|
||||
{
|
||||
struct client *c;
|
||||
|
||||
/*
|
||||
* Redraw entire window if it is bigger than the client (the
|
||||
* offset may change), otherwise just draw borders.
|
||||
*/
|
||||
|
||||
TAILQ_FOREACH(c, &clients, entry) {
|
||||
if (c->session == NULL || (c->flags & CLIENT_CONTROL))
|
||||
continue;
|
||||
if (c->session->curw->window == w && tty_window_bigger(&c->tty))
|
||||
server_redraw_client(c);
|
||||
else {
|
||||
if (c->session->curw->window == w)
|
||||
c->flags |= CLIENT_REDRAWBORDERS;
|
||||
if (session_has(c->session, w))
|
||||
c->flags |= CLIENT_REDRAWSTATUS;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl;
|
||||
struct window *w;
|
||||
struct session *s;
|
||||
struct window_pane *wp, *lastwp, *markedwp;
|
||||
struct cmd_find_state *current = &item->shared->current;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window *w = wl->window;
|
||||
struct session *s = item->target.s;
|
||||
struct window_pane *wp = item->target.wp, *lastwp, *markedwp;
|
||||
char *pane_title;
|
||||
const char *style;
|
||||
struct style *sy;
|
||||
struct options_entry *o;
|
||||
|
||||
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);
|
||||
w = wl->window;
|
||||
|
||||
if (w->last == NULL) {
|
||||
cmdq_error(cmdq, "no last pane");
|
||||
lastwp = w->last;
|
||||
if (lastwp == NULL && window_count_panes(w) == 2) {
|
||||
lastwp = TAILQ_PREV(w->active, window_panes, entry);
|
||||
if (lastwp == NULL)
|
||||
lastwp = TAILQ_NEXT(w->active, entry);
|
||||
}
|
||||
if (lastwp == NULL) {
|
||||
cmdq_error(item, "no last pane");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
if (args_has(self->args, 'e'))
|
||||
w->last->flags &= ~PANE_INPUTOFF;
|
||||
lastwp->flags &= ~PANE_INPUTOFF;
|
||||
else if (args_has(self->args, 'd'))
|
||||
w->last->flags |= PANE_INPUTOFF;
|
||||
lastwp->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);
|
||||
if (window_push_zoom(w, args_has(self->args, 'Z')))
|
||||
server_redraw_window(w);
|
||||
window_redraw_active_switch(w, lastwp);
|
||||
if (window_set_active_pane(w, lastwp, 1)) {
|
||||
cmd_find_from_winlink(current, wl, 0);
|
||||
cmd_select_pane_redraw(w);
|
||||
}
|
||||
if (window_pop_zoom(w))
|
||||
server_redraw_window(w);
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
w = wl->window;
|
||||
|
||||
if (args_has(args, 'm') || args_has(args, 'M')) {
|
||||
if (args_has(args, 'm') && !window_pane_visible(wp))
|
||||
return (CMD_RETURN_NORMAL);
|
||||
lastwp = marked_window_pane;
|
||||
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_window_pane;
|
||||
markedwp = marked_pane.wp;
|
||||
|
||||
if (lastwp != NULL) {
|
||||
server_redraw_window_borders(lastwp->window);
|
||||
@@ -106,28 +147,41 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
}
|
||||
|
||||
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(cmdq, "bad style: %s", style);
|
||||
if ((style = args_get(args, 'P')) != NULL) {
|
||||
o = options_set_style(wp->options, "window-style", 0,
|
||||
style);
|
||||
if (o == NULL) {
|
||||
cmdq_error(item, "bad style: %s", style);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
wp->flags |= PANE_REDRAW;
|
||||
options_set_style(wp->options, "window-active-style", 0,
|
||||
style);
|
||||
wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED);
|
||||
}
|
||||
if (args_has(self->args, 'g')) {
|
||||
sy = options_get_style(wp->options, "window-style");
|
||||
cmdq_print(item, "%s", style_tostring(sy));
|
||||
}
|
||||
if (args_has(self->args, 'g'))
|
||||
cmdq_print(cmdq, "%s", style_tostring(&wp->colgc));
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(self->args, 'L'))
|
||||
if (args_has(self->args, 'L')) {
|
||||
window_push_zoom(w, 1);
|
||||
wp = window_pane_find_left(wp);
|
||||
else if (args_has(self->args, 'R'))
|
||||
window_pop_zoom(w);
|
||||
} else if (args_has(self->args, 'R')) {
|
||||
window_push_zoom(w, 1);
|
||||
wp = window_pane_find_right(wp);
|
||||
else if (args_has(self->args, 'U'))
|
||||
window_pop_zoom(w);
|
||||
} else if (args_has(self->args, 'U')) {
|
||||
window_push_zoom(w, 1);
|
||||
wp = window_pane_find_up(wp);
|
||||
else if (args_has(self->args, 'D'))
|
||||
window_pop_zoom(w);
|
||||
} else if (args_has(self->args, 'D')) {
|
||||
window_push_zoom(w, 1);
|
||||
wp = window_pane_find_down(wp);
|
||||
window_pop_zoom(w);
|
||||
}
|
||||
if (wp == NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
@@ -140,18 +194,27 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(self->args, 'T')) {
|
||||
pane_title = format_single(item, args_get(self->args, 'T'),
|
||||
c, s, wl, wp);
|
||||
if (screen_set_title(&wp->base, pane_title))
|
||||
server_status_window(wp->window);
|
||||
free(pane_title);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (wp == w->active)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
server_unzoom_window(wp->window);
|
||||
if (!window_pane_visible(wp)) {
|
||||
cmdq_error(cmdq, "pane not visible");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (window_push_zoom(w, args_has(self->args, 'Z')))
|
||||
server_redraw_window(w);
|
||||
window_redraw_active_switch(w, wp);
|
||||
if (window_set_active_pane(w, wp)) {
|
||||
server_status_window(w);
|
||||
server_redraw_window_borders(w);
|
||||
if (window_set_active_pane(w, wp, 1)) {
|
||||
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||
cmdq_insert_hook(s, item, current, "after-select-pane");
|
||||
cmd_select_pane_redraw(w);
|
||||
}
|
||||
if (window_pop_zoom(w))
|
||||
server_redraw_window(w);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -26,47 +26,68 @@
|
||||
* Select window by index.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_select_window_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_select_window_entry = {
|
||||
"select-window", "selectw",
|
||||
"lnpTt:", 0, 0,
|
||||
"[-lnpT] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_select_window_exec
|
||||
.name = "select-window",
|
||||
.alias = "selectw",
|
||||
|
||||
.args = { "lnpTt:", 0, 0 },
|
||||
.usage = "[-lnpT] " CMD_TARGET_WINDOW_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_select_window_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_next_window_entry = {
|
||||
"next-window", "next",
|
||||
"at:", 0, 0,
|
||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
cmd_select_window_exec
|
||||
.name = "next-window",
|
||||
.alias = "next",
|
||||
|
||||
.args = { "at:", 0, 0 },
|
||||
.usage = "[-a] " CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_select_window_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_previous_window_entry = {
|
||||
"previous-window", "prev",
|
||||
"at:", 0, 0,
|
||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
cmd_select_window_exec
|
||||
.name = "previous-window",
|
||||
.alias = "prev",
|
||||
|
||||
.args = { "at:", 0, 0 },
|
||||
.usage = "[-a] " CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_select_window_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_last_window_entry = {
|
||||
"last-window", "last",
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
cmd_select_window_exec
|
||||
.name = "last-window",
|
||||
.alias = "last",
|
||||
|
||||
.args = { "t:", 0, 0 },
|
||||
.usage = CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_select_window_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_select_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl;
|
||||
struct session *s;
|
||||
int next, previous, last, activity;
|
||||
struct cmd_find_state *current = &item->shared->current;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct session *s = item->target.s;
|
||||
int next, previous, last, activity;
|
||||
|
||||
next = self->entry == &cmd_next_window_entry;
|
||||
if (args_has(self->args, 'n'))
|
||||
@@ -79,46 +100,44 @@ cmd_select_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
last = 1;
|
||||
|
||||
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');
|
||||
if (next) {
|
||||
if (session_next(s, activity) != 0) {
|
||||
cmdq_error(cmdq, "no next window");
|
||||
cmdq_error(item, "no next window");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else if (previous) {
|
||||
if (session_previous(s, activity) != 0) {
|
||||
cmdq_error(cmdq, "no previous window");
|
||||
cmdq_error(item, "no previous window");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else {
|
||||
if (session_last(s) != 0) {
|
||||
cmdq_error(cmdq, "no last window");
|
||||
cmdq_error(item, "no last window");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
cmd_find_from_session(current, s, 0);
|
||||
server_redraw_session(s);
|
||||
cmdq_insert_hook(s, item, current, "after-select-window");
|
||||
} 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
|
||||
* current, switch to previous window.
|
||||
*/
|
||||
if (args_has(self->args, 'T') && wl == s->curw) {
|
||||
if (session_last(s) != 0) {
|
||||
cmdq_error(cmdq, "no last window");
|
||||
cmdq_error(item, "no last window");
|
||||
return (-1);
|
||||
}
|
||||
if (current->s == s)
|
||||
cmd_find_from_session(current, s, 0);
|
||||
server_redraw_session(s);
|
||||
} else if (session_select(s, wl->idx) == 0)
|
||||
} else if (session_select(s, wl->idx) == 0) {
|
||||
cmd_find_from_session(current, s, 0);
|
||||
server_redraw_session(s);
|
||||
}
|
||||
cmdq_insert_hook(s, item, current, "after-select-window");
|
||||
}
|
||||
recalculate_sizes();
|
||||
|
||||
|
||||
188
cmd-send-keys.c
188
cmd-send-keys.c
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -27,69 +27,177 @@
|
||||
* 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 = {
|
||||
"send-keys", "send",
|
||||
"lRMt:", 0, -1,
|
||||
"[-lRM] " CMD_TARGET_PANE_USAGE " key ...",
|
||||
0,
|
||||
cmd_send_keys_exec
|
||||
.name = "send-keys",
|
||||
.alias = "send",
|
||||
|
||||
.args = { "FHlMN:Rt:X", 0, -1 },
|
||||
.usage = "[-FHlMRX] [-N repeat-count] " CMD_TARGET_PANE_USAGE
|
||||
" key ...",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_send_keys_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_send_prefix_entry = {
|
||||
"send-prefix", NULL,
|
||||
"2t:", 0, 0,
|
||||
"[-2] " CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
cmd_send_keys_exec
|
||||
.name = "send-prefix",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "2t:", 0, 0 },
|
||||
.usage = "[-2] " CMD_TARGET_PANE_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_send_keys_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_send_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static struct cmdq_item *
|
||||
cmd_send_keys_inject_key(struct client *c, struct cmd_find_state *fs,
|
||||
struct cmdq_item *item, key_code key)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct mouse_event *m = &cmdq->item->mouse;
|
||||
struct window_pane *wp;
|
||||
struct session *s;
|
||||
const u_char *str;
|
||||
int i, key;
|
||||
struct session *s = fs->s;
|
||||
struct winlink *wl = fs->wl;
|
||||
struct window_pane *wp = fs->wp;
|
||||
struct window_mode_entry *wme;
|
||||
struct key_table *table;
|
||||
struct key_binding *bd;
|
||||
|
||||
wme = TAILQ_FIRST(&fs->wp->modes);
|
||||
if (wme == NULL || wme->mode->key_table == NULL) {
|
||||
if (options_get_number(fs->wp->window->options, "xterm-keys"))
|
||||
key |= KEYC_XTERM;
|
||||
if (window_pane_key(wp, item->client, s, wl, key, NULL) != 0)
|
||||
return (NULL);
|
||||
return (item);
|
||||
}
|
||||
table = key_bindings_get_table(wme->mode->key_table(wme), 1);
|
||||
|
||||
bd = key_bindings_get(table, key & ~KEYC_XTERM);
|
||||
if (bd != NULL) {
|
||||
table->references++;
|
||||
item = key_bindings_dispatch(bd, item, c, NULL, &item->target);
|
||||
key_bindings_unref_table(table);
|
||||
}
|
||||
return (item);
|
||||
}
|
||||
|
||||
static struct cmdq_item *
|
||||
cmd_send_keys_inject_string(struct client *c, struct cmd_find_state *fs,
|
||||
struct cmdq_item *item, struct args *args, int i)
|
||||
{
|
||||
const char *s = args->argv[i];
|
||||
struct cmdq_item *new_item;
|
||||
struct utf8_data *ud, *uc;
|
||||
wchar_t wc;
|
||||
key_code key;
|
||||
char *endptr;
|
||||
long n;
|
||||
int literal;
|
||||
|
||||
if (args_has(args, 'H')) {
|
||||
n = strtol(s, &endptr, 16);
|
||||
if (*s =='\0' || n < 0 || n > 0xff || *endptr != '\0')
|
||||
return (item);
|
||||
return (cmd_send_keys_inject_key(c, fs, item, KEYC_LITERAL|n));
|
||||
}
|
||||
|
||||
literal = args_has(args, 'l');
|
||||
if (!literal) {
|
||||
key = key_string_lookup_string(s);
|
||||
if (key != KEYC_NONE && key != KEYC_UNKNOWN) {
|
||||
new_item = cmd_send_keys_inject_key(c, fs, item, key);
|
||||
if (new_item != NULL)
|
||||
return (new_item);
|
||||
}
|
||||
literal = 1;
|
||||
}
|
||||
if (literal) {
|
||||
ud = utf8_fromcstr(s);
|
||||
for (uc = ud; uc->size != 0; uc++) {
|
||||
if (utf8_combine(uc, &wc) != UTF8_DONE)
|
||||
continue;
|
||||
item = cmd_send_keys_inject_key(c, fs, item, wc);
|
||||
}
|
||||
free(ud);
|
||||
}
|
||||
return (item);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct cmd_find_state *fs = &item->target;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct mouse_event *m = &item->shared->mouse;
|
||||
struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes);
|
||||
int i;
|
||||
key_code key;
|
||||
u_int np = 1;
|
||||
char *cause = NULL;
|
||||
|
||||
if (args_has(args, 'N')) {
|
||||
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 (wme != NULL && (args_has(args, 'X') || args->argc == 0)) {
|
||||
if (wme == NULL || wme->mode->command == NULL) {
|
||||
cmdq_error(item, "not in a mode");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
wme->prefix = np;
|
||||
}
|
||||
}
|
||||
|
||||
if (args_has(args, 'X')) {
|
||||
if (wme == NULL || wme->mode->command == NULL) {
|
||||
cmdq_error(item, "not in a mode");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (!m->valid)
|
||||
m = NULL;
|
||||
wme->mode->command(wme, c, s, wl, args, m);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 'M')) {
|
||||
wp = cmd_mouse_pane(m, &s, NULL);
|
||||
if (wp == NULL) {
|
||||
cmdq_error(cmdq, "no mouse target");
|
||||
cmdq_error(item, "no mouse target");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
window_pane_key(wp, NULL, s, m->key, m);
|
||||
window_pane_key(wp, item->client, s, wl, m->key, m);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
if (self->entry == &cmd_send_prefix_entry) {
|
||||
if (args_has(args, '2'))
|
||||
key = options_get_number(&s->options, "prefix2");
|
||||
key = options_get_number(s->options, "prefix2");
|
||||
else
|
||||
key = options_get_number(&s->options, "prefix");
|
||||
window_pane_key(wp, NULL, s, key, NULL);
|
||||
key = options_get_number(s->options, "prefix");
|
||||
cmd_send_keys_inject_key(c, fs, item, key);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 'R'))
|
||||
input_reset(wp);
|
||||
if (args_has(args, 'R')) {
|
||||
window_pane_reset_palette(wp);
|
||||
input_reset(wp, 1);
|
||||
}
|
||||
|
||||
for (i = 0; i < args->argc; i++) {
|
||||
str = args->argv[i];
|
||||
|
||||
if (!args_has(args, 'l') &&
|
||||
(key = key_string_lookup_string(str)) != KEYC_NONE) {
|
||||
window_pane_key(wp, NULL, s, key, NULL);
|
||||
} else {
|
||||
for (; *str != '\0'; str++)
|
||||
window_pane_key(wp, NULL, s, *str, NULL);
|
||||
}
|
||||
for (; np != 0; np--) {
|
||||
for (i = 0; i < args->argc; i++)
|
||||
item = cmd_send_keys_inject_string(c, fs, item, args, i);
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -27,26 +27,32 @@
|
||||
* 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 = {
|
||||
"set-buffer", "setb",
|
||||
"ab:n:", 0, 1,
|
||||
"[-a] " CMD_BUFFER_USAGE " [-n new-buffer-name] data",
|
||||
0,
|
||||
cmd_set_buffer_exec
|
||||
.name = "set-buffer",
|
||||
.alias = "setb",
|
||||
|
||||
.args = { "ab:n:", 0, 1 },
|
||||
.usage = "[-a] " CMD_BUFFER_USAGE " [-n new-buffer-name] data",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_set_buffer_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_delete_buffer_entry = {
|
||||
"delete-buffer", "deleteb",
|
||||
"b:", 0, 0,
|
||||
CMD_BUFFER_USAGE,
|
||||
0,
|
||||
cmd_set_buffer_exec
|
||||
.name = "delete-buffer",
|
||||
.alias = "deleteb",
|
||||
|
||||
.args = { "b:", 0, 0 },
|
||||
.usage = CMD_BUFFER_USAGE,
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_set_buffer_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct paste_buffer *pb;
|
||||
@@ -64,7 +70,7 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
if (pb == NULL)
|
||||
pb = paste_get_top(&bufname);
|
||||
if (pb == NULL) {
|
||||
cmdq_error(cmdq, "no buffer");
|
||||
cmdq_error(item, "no buffer");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
paste_free(pb);
|
||||
@@ -75,11 +81,11 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
if (pb == NULL)
|
||||
pb = paste_get_top(&bufname);
|
||||
if (pb == NULL) {
|
||||
cmdq_error(cmdq, "no buffer");
|
||||
cmdq_error(item, "no buffer");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (paste_rename(bufname, args_get(args, 'n'), &cause) != 0) {
|
||||
cmdq_error(cmdq, "%s", cause);
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
@@ -87,7 +93,7 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
}
|
||||
|
||||
if (args->argc != 1) {
|
||||
cmdq_error(cmdq, "no data specified");
|
||||
cmdq_error(item, "no data specified");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if ((newsize = strlen(args->argv[0])) == 0)
|
||||
@@ -107,7 +113,7 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
bufsize += newsize;
|
||||
|
||||
if (paste_set(bufdata, bufsize, bufname, &cause) != 0) {
|
||||
cmdq_error(cmdq, "%s", cause);
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(bufdata);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -27,31 +27,36 @@
|
||||
* 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 = {
|
||||
"set-environment", "setenv",
|
||||
"grt:u", 1, 2,
|
||||
"[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
||||
0,
|
||||
cmd_set_environment_exec
|
||||
.name = "set-environment",
|
||||
.alias = "setenv",
|
||||
|
||||
.args = { "grt:u", 1, 2 },
|
||||
.usage = "[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_set_environment_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s;
|
||||
struct environ *env;
|
||||
const char *name, *value;
|
||||
const char *name, *value, *target;
|
||||
|
||||
name = args->argv[0];
|
||||
if (*name == '\0') {
|
||||
cmdq_error(cmdq, "empty variable name");
|
||||
cmdq_error(item, "empty variable name");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (strchr(name, '=') != NULL) {
|
||||
cmdq_error(cmdq, "variable name contains =");
|
||||
cmdq_error(item, "variable name contains =");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
@@ -61,31 +66,37 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
value = args->argv[1];
|
||||
|
||||
if (args_has(self->args, 'g'))
|
||||
env = &global_environ;
|
||||
env = global_environ;
|
||||
else {
|
||||
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||
if (item->target.s == NULL) {
|
||||
target = args_get(args, 't');
|
||||
if (target != NULL)
|
||||
cmdq_error(item, "no such session: %s", target);
|
||||
else
|
||||
cmdq_error(item, "no current session");
|
||||
return (CMD_RETURN_ERROR);
|
||||
env = &s->environ;
|
||||
}
|
||||
env = item->target.s->environ;
|
||||
}
|
||||
|
||||
if (args_has(self->args, 'u')) {
|
||||
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);
|
||||
}
|
||||
environ_unset(env, name);
|
||||
} else if (args_has(self->args, 'r')) {
|
||||
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);
|
||||
}
|
||||
environ_set(env, name, NULL);
|
||||
environ_clear(env, name);
|
||||
} else {
|
||||
if (value == NULL) {
|
||||
cmdq_error(cmdq, "no value specified");
|
||||
cmdq_error(item, "no value specified");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
environ_set(env, name, value);
|
||||
environ_set(env, name, "%s", value);
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
709
cmd-set-option.c
709
cmd-set-option.c
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -27,418 +28,337 @@
|
||||
* 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 *,
|
||||
const char *, const char *);
|
||||
|
||||
int cmd_set_option_unset(struct cmd *, struct cmd_q *,
|
||||
const struct options_table_entry *, struct options *,
|
||||
const char *);
|
||||
int cmd_set_option_set(struct cmd *, struct cmd_q *,
|
||||
const struct options_table_entry *, struct options *,
|
||||
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 *);
|
||||
struct options_entry *cmd_set_option_style(struct cmd *, struct cmd_q *,
|
||||
const struct options_table_entry *, struct options *,
|
||||
const char *);
|
||||
static int cmd_set_option_set(struct cmd *, struct cmdq_item *,
|
||||
struct options *, struct options_entry *, const char *);
|
||||
static int cmd_set_option_flag(struct cmdq_item *,
|
||||
const struct options_table_entry *, struct options *,
|
||||
const char *);
|
||||
static int cmd_set_option_choice(struct cmdq_item *,
|
||||
const struct options_table_entry *, struct options *,
|
||||
const char *);
|
||||
|
||||
const struct cmd_entry cmd_set_option_entry = {
|
||||
"set-option", "set",
|
||||
"agoqst:uw", 1, 2,
|
||||
"[-agosquw] [-t target-session|target-window] option [value]",
|
||||
0,
|
||||
cmd_set_option_exec
|
||||
.name = "set-option",
|
||||
.alias = "set",
|
||||
|
||||
.args = { "aFgopqst:uw", 1, 2 },
|
||||
.usage = "[-aFgopqsuw] " CMD_TARGET_PANE_USAGE " option [value]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_set_option_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_set_window_option_entry = {
|
||||
"set-window-option", "setw",
|
||||
"agoqt:u", 1, 2,
|
||||
"[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
||||
0,
|
||||
cmd_set_option_exec
|
||||
.name = "set-window-option",
|
||||
.alias = "setw",
|
||||
|
||||
.args = { "aFgoqt:u", 1, 2 },
|
||||
.usage = "[-aFgoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_set_option_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
const struct options_table_entry *table, *oe;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
struct client *c;
|
||||
struct options *oo;
|
||||
struct window *w;
|
||||
const char *optstr, *valstr;
|
||||
const struct cmd_entry cmd_set_hook_entry = {
|
||||
.name = "set-hook",
|
||||
.alias = NULL,
|
||||
|
||||
/* Get the option name and value. */
|
||||
optstr = args->argv[0];
|
||||
if (*optstr == '\0') {
|
||||
cmdq_error(cmdq, "invalid option");
|
||||
return (CMD_RETURN_ERROR);
|
||||
.args = { "agRt:u", 1, 2 },
|
||||
.usage = "[-agRu] " CMD_TARGET_SESSION_USAGE " hook [command]",
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_set_option_exec
|
||||
};
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
int append = args_has(args, 'a');
|
||||
struct cmd_find_state *fs = &item->target;
|
||||
struct client *c, *loop;
|
||||
struct session *s = fs->s;
|
||||
struct winlink *wl = fs->wl;
|
||||
struct window *w;
|
||||
struct window_pane *wp;
|
||||
struct options *oo;
|
||||
struct options_entry *parent, *o;
|
||||
char *name, *argument, *value = NULL, *cause;
|
||||
int window, idx, already, error, ambiguous;
|
||||
int scope;
|
||||
struct style *sy;
|
||||
|
||||
window = (self->entry == &cmd_set_window_option_entry);
|
||||
|
||||
/* Expand argument. */
|
||||
c = cmd_find_client(item, NULL, 1);
|
||||
argument = format_single(item, args->argv[0], c, s, wl, NULL);
|
||||
|
||||
/* If set-hook -R, fire the hook straight away. */
|
||||
if (self->entry == &cmd_set_hook_entry && args_has(args, 'R')) {
|
||||
notify_hook(item, argument);
|
||||
free(argument);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
/* Parse option name and index. */
|
||||
name = options_match(argument, &idx, &ambiguous);
|
||||
if (name == NULL) {
|
||||
if (args_has(args, 'q'))
|
||||
goto out;
|
||||
if (ambiguous)
|
||||
cmdq_error(item, "ambiguous option: %s", argument);
|
||||
else
|
||||
cmdq_error(item, "invalid option: %s", argument);
|
||||
goto fail;
|
||||
}
|
||||
if (args->argc < 2)
|
||||
valstr = NULL;
|
||||
value = NULL;
|
||||
else if (args_has(args, 'F'))
|
||||
value = format_single(item, args->argv[1], c, s, wl, NULL);
|
||||
else
|
||||
valstr = args->argv[1];
|
||||
value = xstrdup(args->argv[1]);
|
||||
|
||||
/* Is this a user option? */
|
||||
if (*optstr == '@')
|
||||
return (cmd_set_option_user(self, cmdq, optstr, valstr));
|
||||
|
||||
/* Find the option entry, try each table. */
|
||||
table = oe = NULL;
|
||||
if (options_table_find(optstr, &table, &oe) != 0) {
|
||||
if (!args_has(args, 'q')) {
|
||||
cmdq_error(cmdq, "ambiguous option: %s", optstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
/* Get the scope and table for the option .*/
|
||||
scope = options_scope_from_name(args, window, name, fs, &oo, &cause);
|
||||
if (scope == OPTIONS_TABLE_NONE) {
|
||||
if (args_has(args, 'q'))
|
||||
goto out;
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
goto fail;
|
||||
}
|
||||
if (oe == NULL) {
|
||||
if (!args_has(args, 'q')) {
|
||||
cmdq_error(cmdq, "unknown option: %s", optstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
o = options_get_only(oo, name);
|
||||
parent = options_get(oo, name);
|
||||
|
||||
/* Check that array options and indexes match up. */
|
||||
if (idx != -1 && (*name == '@' || !options_isarray(parent))) {
|
||||
cmdq_error(item, "not an array: %s", argument);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
/* 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 {
|
||||
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
|
||||
if (wl == NULL) {
|
||||
cmdq_error(cmdq,
|
||||
"couldn't set '%s'%s", optstr,
|
||||
(!args_has(args, 't') && !args_has(args,
|
||||
'g')) ? " need target window or -g" : "");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
oo = &wl->window->options;
|
||||
if (o == NULL)
|
||||
already = 0;
|
||||
else
|
||||
already = (options_array_get(o, idx) != NULL);
|
||||
}
|
||||
} 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) {
|
||||
cmdq_error(cmdq,
|
||||
"couldn't set '%s'%s", optstr,
|
||||
(!args_has(args, 't') && !args_has(args,
|
||||
'g')) ? " need target session or -g" : "");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
oo = &s->options;
|
||||
if (already) {
|
||||
if (args_has(args, 'q'))
|
||||
goto out;
|
||||
cmdq_error(item, "already set: %s", argument);
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
cmdq_error(cmdq, "unknown table");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
/* Unset or set the option. */
|
||||
/* Change the option. */
|
||||
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_error(cmdq, "already set: %s", optstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
if (o == NULL)
|
||||
goto out;
|
||||
if (idx == -1) {
|
||||
if (*name == '@')
|
||||
options_remove(o);
|
||||
else if (oo == global_options ||
|
||||
oo == global_s_options ||
|
||||
oo == global_w_options)
|
||||
options_default(oo, options_table_entry(o));
|
||||
else
|
||||
options_remove(o);
|
||||
} else if (options_array_set(o, idx, NULL, 0, &cause) != 0) {
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
goto fail;
|
||||
}
|
||||
} else if (*name == '@') {
|
||||
if (value == NULL) {
|
||||
cmdq_error(item, "empty value");
|
||||
goto fail;
|
||||
}
|
||||
options_set_string(oo, name, append, "%s", value);
|
||||
} else if (idx == -1 && !options_isarray(parent)) {
|
||||
error = cmd_set_option_set(self, item, oo, parent, value);
|
||||
if (error != 0)
|
||||
goto fail;
|
||||
} else {
|
||||
if (value == NULL) {
|
||||
cmdq_error(item, "empty value");
|
||||
goto fail;
|
||||
}
|
||||
if (o == NULL)
|
||||
o = options_empty(oo, options_table_entry(parent));
|
||||
if (idx == -1) {
|
||||
if (!append)
|
||||
options_array_clear(o);
|
||||
if (options_array_assign(o, value, &cause) != 0) {
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
goto fail;
|
||||
}
|
||||
} else if (options_array_set(o, idx, value, append,
|
||||
&cause) != 0) {
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
goto fail;
|
||||
}
|
||||
if (cmd_set_option_set(self, cmdq, oe, oo, valstr) != 0)
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
/* Start or stop timers if necessary. */
|
||||
if (strcmp(oe->name, "automatic-rename") == 0) {
|
||||
/* Update timers and so on for various options. */
|
||||
if (strcmp(name, "automatic-rename") == 0) {
|
||||
RB_FOREACH(w, windows, &windows) {
|
||||
if (options_get_number(&w->options, "automatic-rename"))
|
||||
if (w->active == NULL)
|
||||
continue;
|
||||
if (options_get_number(w->options, "automatic-rename"))
|
||||
w->active->flags |= PANE_CHANGED;
|
||||
}
|
||||
}
|
||||
if (strcmp(oe->name, "status") == 0 ||
|
||||
strcmp(oe->name, "status-interval") == 0)
|
||||
if (strcmp(name, "key-table") == 0) {
|
||||
TAILQ_FOREACH(loop, &clients, entry)
|
||||
server_client_set_key_table(loop, NULL);
|
||||
}
|
||||
if (strcmp(name, "user-keys") == 0) {
|
||||
TAILQ_FOREACH(loop, &clients, entry) {
|
||||
if (loop->tty.flags & TTY_OPENED)
|
||||
tty_keys_build(&loop->tty);
|
||||
}
|
||||
}
|
||||
if (strcmp(name, "status-fg") == 0 || strcmp(name, "status-bg") == 0) {
|
||||
sy = options_get_style(oo, "status-style");
|
||||
sy->gc.fg = options_get_number(oo, "status-fg");
|
||||
sy->gc.bg = options_get_number(oo, "status-bg");
|
||||
}
|
||||
if (strcmp(name, "status-style") == 0) {
|
||||
sy = options_get_style(oo, "status-style");
|
||||
options_set_number(oo, "status-fg", sy->gc.fg);
|
||||
options_set_number(oo, "status-bg", sy->gc.bg);
|
||||
}
|
||||
if (strcmp(name, "status") == 0 ||
|
||||
strcmp(name, "status-interval") == 0)
|
||||
status_timer_start_all();
|
||||
if (strcmp(oe->name, "monitor-silence") == 0)
|
||||
if (strcmp(name, "monitor-silence") == 0)
|
||||
alerts_reset_all();
|
||||
if (strcmp(name, "window-style") == 0 ||
|
||||
strcmp(name, "window-active-style") == 0) {
|
||||
RB_FOREACH(wp, window_pane_tree, &all_window_panes)
|
||||
wp->flags |= PANE_STYLECHANGED;
|
||||
}
|
||||
if (strcmp(name, "pane-border-status") == 0) {
|
||||
RB_FOREACH(w, windows, &windows)
|
||||
layout_fix_panes(w);
|
||||
}
|
||||
RB_FOREACH(s, sessions, &sessions)
|
||||
status_update_cache(s);
|
||||
|
||||
/* Update sizes and redraw. May not need it but meh. */
|
||||
/*
|
||||
* Update sizes and redraw. May not always be necessary but do it
|
||||
* anyway.
|
||||
*/
|
||||
recalculate_sizes();
|
||||
TAILQ_FOREACH(c, &clients, entry) {
|
||||
if (c->session != NULL)
|
||||
server_redraw_client(c);
|
||||
TAILQ_FOREACH(loop, &clients, entry) {
|
||||
if (loop->session != NULL)
|
||||
server_redraw_client(loop);
|
||||
}
|
||||
|
||||
out:
|
||||
free(argument);
|
||||
free(value);
|
||||
free(name);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
fail:
|
||||
free(argument);
|
||||
free(value);
|
||||
free(name);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
/* Set user option. */
|
||||
enum cmd_retval
|
||||
cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr,
|
||||
const char *valstr)
|
||||
static int
|
||||
cmd_set_option_set(struct cmd *self, struct cmdq_item *item, struct options *oo,
|
||||
struct options_entry *parent, const char *value)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
struct options *oo;
|
||||
const struct options_table_entry *oe;
|
||||
struct args *args = self->args;
|
||||
int append = args_has(args, 'a');
|
||||
struct options_entry *o;
|
||||
long long number;
|
||||
const char *errstr, *new;
|
||||
char *old;
|
||||
key_code key;
|
||||
|
||||
if (args_has(args, 's'))
|
||||
oo = &global_options;
|
||||
else if (args_has(self->args, 'w') ||
|
||||
self->entry == &cmd_set_window_option_entry) {
|
||||
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 (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) {
|
||||
if (!args_has(args, 'q')) {
|
||||
cmdq_error(cmdq, "unknown option: %s", optstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
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_error(cmdq, "already set: %s", optstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
options_set_string(oo, optstr, "%s", 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 (value != NULL) {
|
||||
cmdq_error(cmdq, "value passed to unset option: %s", oe->name);
|
||||
oe = options_table_entry(parent);
|
||||
if (value == NULL &&
|
||||
oe->type != OPTIONS_TABLE_FLAG &&
|
||||
oe->type != OPTIONS_TABLE_CHOICE) {
|
||||
cmdq_error(item, "empty value");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (args_has(args, 'g') || oo == &global_options) {
|
||||
switch (oe->type) {
|
||||
case OPTIONS_TABLE_STRING:
|
||||
options_set_string(oo, oe->name, "%s", oe->default_str);
|
||||
break;
|
||||
case OPTIONS_TABLE_STYLE:
|
||||
options_set_style(oo, oe->name, oe->default_str, 0);
|
||||
break;
|
||||
default:
|
||||
options_set_number(oo, oe->name, oe->default_num);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
options_remove(oo, 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 options_entry *o;
|
||||
|
||||
switch (oe->type) {
|
||||
case OPTIONS_TABLE_FLAG:
|
||||
case OPTIONS_TABLE_CHOICE:
|
||||
break;
|
||||
default:
|
||||
if (value == NULL) {
|
||||
cmdq_error(cmdq, "empty value");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
o = NULL;
|
||||
switch (oe->type) {
|
||||
case OPTIONS_TABLE_STRING:
|
||||
o = cmd_set_option_string(self, cmdq, oe, oo, value);
|
||||
break;
|
||||
old = xstrdup(options_get_string(oo, oe->name));
|
||||
options_set_string(oo, oe->name, append, "%s", value);
|
||||
new = options_get_string(oo, oe->name);
|
||||
if (oe->pattern != NULL && fnmatch(oe->pattern, new, 0) != 0) {
|
||||
options_set_string(oo, oe->name, 0, "%s", old);
|
||||
free(old);
|
||||
cmdq_error(item, "value is invalid: %s", value);
|
||||
return (-1);
|
||||
}
|
||||
free(old);
|
||||
return (0);
|
||||
case OPTIONS_TABLE_NUMBER:
|
||||
o = cmd_set_option_number(self, cmdq, oe, oo, value);
|
||||
break;
|
||||
number = strtonum(value, oe->minimum, oe->maximum, &errstr);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(item, "value is %s: %s", errstr, value);
|
||||
return (-1);
|
||||
}
|
||||
options_set_number(oo, oe->name, number);
|
||||
return (0);
|
||||
case OPTIONS_TABLE_KEY:
|
||||
o = cmd_set_option_key(self, cmdq, oe, oo, value);
|
||||
break;
|
||||
key = key_string_lookup_string(value);
|
||||
if (key == KEYC_UNKNOWN) {
|
||||
cmdq_error(item, "bad key: %s", value);
|
||||
return (-1);
|
||||
}
|
||||
options_set_number(oo, oe->name, key);
|
||||
return (0);
|
||||
case OPTIONS_TABLE_COLOUR:
|
||||
o = cmd_set_option_colour(self, cmdq, oe, oo, value);
|
||||
if (o != NULL)
|
||||
style_update_new(oo, o->name, oe->style);
|
||||
break;
|
||||
case OPTIONS_TABLE_ATTRIBUTES:
|
||||
o = cmd_set_option_attributes(self, cmdq, oe, oo, value);
|
||||
if (o != NULL)
|
||||
style_update_new(oo, o->name, oe->style);
|
||||
break;
|
||||
if ((number = colour_fromstring(value)) == -1) {
|
||||
cmdq_error(item, "bad colour: %s", value);
|
||||
return (-1);
|
||||
}
|
||||
options_set_number(oo, oe->name, number);
|
||||
return (0);
|
||||
case OPTIONS_TABLE_FLAG:
|
||||
o = cmd_set_option_flag(self, cmdq, oe, oo, value);
|
||||
break;
|
||||
return (cmd_set_option_flag(item, oe, oo, value));
|
||||
case OPTIONS_TABLE_CHOICE:
|
||||
o = cmd_set_option_choice(self, cmdq, oe, oo, value);
|
||||
break;
|
||||
return (cmd_set_option_choice(item, oe, oo, value));
|
||||
case OPTIONS_TABLE_STYLE:
|
||||
o = cmd_set_option_style(self, cmdq, oe, oo, value);
|
||||
o = options_set_style(oo, oe->name, append, value);
|
||||
if (o == NULL) {
|
||||
cmdq_error(item, "bad style: %s", value);
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
case OPTIONS_TABLE_COMMAND:
|
||||
break;
|
||||
}
|
||||
if (o == NULL)
|
||||
return (-1);
|
||||
return (0);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Set a string option. */
|
||||
struct options_entry *
|
||||
cmd_set_option_string(struct cmd *self, unused 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;
|
||||
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,
|
||||
static int
|
||||
cmd_set_option_flag(struct cmdq_item *item,
|
||||
const struct options_table_entry *oe, struct options *oo,
|
||||
const char *value)
|
||||
{
|
||||
@@ -446,31 +366,28 @@ cmd_set_option_flag(unused struct cmd *self, struct cmd_q *cmdq,
|
||||
|
||||
if (value == NULL || *value == '\0')
|
||||
flag = !options_get_number(oo, oe->name);
|
||||
else if (strcmp(value, "1") == 0 ||
|
||||
strcasecmp(value, "on") == 0 ||
|
||||
strcasecmp(value, "yes") == 0)
|
||||
flag = 1;
|
||||
else if (strcmp(value, "0") == 0 ||
|
||||
strcasecmp(value, "off") == 0 ||
|
||||
strcasecmp(value, "no") == 0)
|
||||
flag = 0;
|
||||
else {
|
||||
if ((value[0] == '1' && value[1] == '\0') ||
|
||||
strcasecmp(value, "on") == 0 ||
|
||||
strcasecmp(value, "yes") == 0)
|
||||
flag = 1;
|
||||
else if ((value[0] == '0' && value[1] == '\0') ||
|
||||
strcasecmp(value, "off") == 0 ||
|
||||
strcasecmp(value, "no") == 0)
|
||||
flag = 0;
|
||||
else {
|
||||
cmdq_error(cmdq, "bad value: %s", value);
|
||||
return (NULL);
|
||||
}
|
||||
cmdq_error(item, "bad value: %s", value);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (options_set_number(oo, oe->name, flag));
|
||||
options_set_number(oo, oe->name, flag);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Set a choice option. */
|
||||
struct options_entry *
|
||||
cmd_set_option_choice(unused struct cmd *self, struct cmd_q *cmdq,
|
||||
static int
|
||||
cmd_set_option_choice(struct cmdq_item *item,
|
||||
const struct options_table_entry *oe, struct options *oo,
|
||||
const char *value)
|
||||
{
|
||||
const char **choicep;
|
||||
const char **cp;
|
||||
int n, choice = -1;
|
||||
|
||||
if (value == NULL) {
|
||||
@@ -479,42 +396,16 @@ cmd_set_option_choice(unused struct cmd *self, struct cmd_q *cmdq,
|
||||
choice = !choice;
|
||||
} else {
|
||||
n = 0;
|
||||
for (choicep = oe->choices; *choicep != NULL; choicep++) {
|
||||
for (cp = oe->choices; *cp != NULL; cp++) {
|
||||
if (strcmp(*cp, value) == 0)
|
||||
choice = n;
|
||||
n++;
|
||||
if (strncmp(*choicep, value, strlen(value)) != 0)
|
||||
continue;
|
||||
|
||||
if (choice != -1) {
|
||||
cmdq_error(cmdq, "ambiguous value: %s", value);
|
||||
return (NULL);
|
||||
}
|
||||
choice = n - 1;
|
||||
}
|
||||
if (choice == -1) {
|
||||
cmdq_error(cmdq, "unknown value: %s", value);
|
||||
return (NULL);
|
||||
cmdq_error(item, "unknown value: %s", value);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
return (options_set_number(oo, oe->name, choice));
|
||||
}
|
||||
|
||||
/* Set a style option. */
|
||||
struct options_entry *
|
||||
cmd_set_option_style(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;
|
||||
int append;
|
||||
|
||||
append = args_has(args, 'a');
|
||||
if ((o = options_set_style(oo, oe->name, value, append)) == NULL) {
|
||||
cmdq_error(cmdq, "bad style: %s", value);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
style_update_old(oo, oe->name, &o->style);
|
||||
return (o);
|
||||
options_set_number(oo, oe->name, choice);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -27,21 +27,27 @@
|
||||
* 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 *);
|
||||
|
||||
char *cmd_show_environment_escape(struct environ_entry *);
|
||||
void cmd_show_environment_print(struct cmd *, struct cmd_q *,
|
||||
struct environ_entry *);
|
||||
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 = {
|
||||
"show-environment", "showenv",
|
||||
"gst:", 0, 1,
|
||||
"[-gs] " CMD_TARGET_SESSION_USAGE " [name]",
|
||||
0,
|
||||
cmd_show_environment_exec
|
||||
.name = "show-environment",
|
||||
.alias = "showenv",
|
||||
|
||||
.args = { "gst:", 0, 1 },
|
||||
.usage = "[-gs] " CMD_TARGET_SESSION_USAGE " [name]",
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_show_environment_exec
|
||||
};
|
||||
|
||||
char *
|
||||
static char *
|
||||
cmd_show_environment_escape(struct environ_entry *envent)
|
||||
{
|
||||
const char *value = envent->value;
|
||||
@@ -59,57 +65,72 @@ cmd_show_environment_escape(struct environ_entry *envent)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_show_environment_print(struct cmd *self, struct cmd_q *cmdq,
|
||||
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(cmdq, "%s=%s", envent->name, envent->value);
|
||||
cmdq_print(item, "%s=%s", envent->name, envent->value);
|
||||
else
|
||||
cmdq_print(cmdq, "-%s", envent->name);
|
||||
cmdq_print(item, "-%s", envent->name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (envent->value != NULL) {
|
||||
escaped = cmd_show_environment_escape(envent);
|
||||
cmdq_print(cmdq, "%s=\"%s\"; export %s;", envent->name, escaped,
|
||||
cmdq_print(item, "%s=\"%s\"; export %s;", envent->name, escaped,
|
||||
envent->name);
|
||||
free(escaped);
|
||||
} else
|
||||
cmdq_print(cmdq, "unset %s;", envent->name);
|
||||
cmdq_print(item, "unset %s;", envent->name);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_show_environment_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s;
|
||||
struct environ *env;
|
||||
struct environ_entry *envent;
|
||||
const char *target;
|
||||
|
||||
if ((target = args_get(args, 't')) != NULL) {
|
||||
if (item->target.s == NULL) {
|
||||
cmdq_error(item, "no such session: %s", target);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
if (args_has(self->args, 'g'))
|
||||
env = &global_environ;
|
||||
env = global_environ;
|
||||
else {
|
||||
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
||||
if (s == NULL)
|
||||
if (item->target.s == NULL) {
|
||||
target = args_get(args, 't');
|
||||
if (target != NULL)
|
||||
cmdq_error(item, "no such session: %s", target);
|
||||
else
|
||||
cmdq_error(item, "no current session");
|
||||
return (CMD_RETURN_ERROR);
|
||||
env = &s->environ;
|
||||
}
|
||||
env = item->target.s->environ;
|
||||
}
|
||||
|
||||
if (args->argc != 0) {
|
||||
envent = environ_find(env, args->argv[0]);
|
||||
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);
|
||||
}
|
||||
cmd_show_environment_print(self, cmdq, envent);
|
||||
cmd_show_environment_print(self, item, envent);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
RB_FOREACH(envent, environ, env)
|
||||
cmd_show_environment_print(self, cmdq, envent);
|
||||
envent = environ_first(env);
|
||||
while (envent != NULL) {
|
||||
cmd_show_environment_print(self, item, envent);
|
||||
envent = environ_next(envent);
|
||||
}
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -28,46 +28,24 @@
|
||||
* 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 = {
|
||||
"show-messages", "showmsgs",
|
||||
"IJTt:", 0, 0,
|
||||
"[-IJT] " CMD_TARGET_CLIENT_USAGE,
|
||||
0,
|
||||
cmd_show_messages_exec
|
||||
.name = "show-messages",
|
||||
.alias = "showmsgs",
|
||||
|
||||
.args = { "JTt:", 0, 0 },
|
||||
.usage = "[-JT] " CMD_TARGET_CLIENT_USAGE,
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_show_messages_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_server_info_entry = {
|
||||
"server-info", "info",
|
||||
"", 0, 0,
|
||||
"",
|
||||
0,
|
||||
cmd_show_messages_exec
|
||||
};
|
||||
static int cmd_show_messages_terminals(struct cmdq_item *, int);
|
||||
|
||||
int cmd_show_messages_server(struct cmd_q *);
|
||||
int cmd_show_messages_terminals(struct cmd_q *, int);
|
||||
int cmd_show_messages_jobs(struct cmd_q *, int);
|
||||
|
||||
int
|
||||
cmd_show_messages_server(struct cmd_q *cmdq)
|
||||
{
|
||||
char *tim;
|
||||
|
||||
tim = ctime(&start_time);
|
||||
*strchr(tim, '\n') = '\0';
|
||||
|
||||
cmdq_print(cmdq, "started %s", tim);
|
||||
cmdq_print(cmdq, "socket path %s", socket_path);
|
||||
cmdq_print(cmdq, "debug level %d", debug_level);
|
||||
cmdq_print(cmdq, "protocol version %d", PROTOCOL_VERSION);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
cmd_show_messages_terminals(struct cmd_q *cmdq, int blank)
|
||||
static int
|
||||
cmd_show_messages_terminals(struct cmdq_item *item, int blank)
|
||||
{
|
||||
struct tty_term *term;
|
||||
u_int i, n;
|
||||
@@ -75,39 +53,20 @@ cmd_show_messages_terminals(struct cmd_q *cmdq, int blank)
|
||||
n = 0;
|
||||
LIST_FOREACH(term, &tty_terms, entry) {
|
||||
if (blank) {
|
||||
cmdq_print(cmdq, "%s", "");
|
||||
cmdq_print(item, "%s", "");
|
||||
blank = 0;
|
||||
}
|
||||
cmdq_print(cmdq, "Terminal %u: %s [references=%u, flags=0x%x]:",
|
||||
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(cmdq, "%s", tty_term_describe(term, i));
|
||||
cmdq_print(item, "%s", tty_term_describe(term, i));
|
||||
}
|
||||
return (n != 0);
|
||||
}
|
||||
|
||||
int
|
||||
cmd_show_messages_jobs(struct cmd_q *cmdq, int blank)
|
||||
{
|
||||
struct job *job;
|
||||
u_int n;
|
||||
|
||||
n = 0;
|
||||
LIST_FOREACH(job, &all_jobs, lentry) {
|
||||
if (blank) {
|
||||
cmdq_print(cmdq, "%s", "");
|
||||
blank = 0;
|
||||
}
|
||||
cmdq_print(cmdq, "Job %u: %s [fd=%d, pid=%d, status=%d]",
|
||||
n, job->cmd, job->fd, job->pid, job->status);
|
||||
n++;
|
||||
}
|
||||
return (n != 0);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_show_messages_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
@@ -115,30 +74,26 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
char *tim;
|
||||
int done, blank;
|
||||
|
||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
done = blank = 0;
|
||||
if (args_has(args, 'I') || self->entry == &cmd_server_info_entry) {
|
||||
blank = cmd_show_messages_server(cmdq);
|
||||
if (args_has(args, 'T')) {
|
||||
blank = cmd_show_messages_terminals(item, blank);
|
||||
done = 1;
|
||||
}
|
||||
if (args_has(args, 'T') || self->entry == &cmd_server_info_entry) {
|
||||
blank = cmd_show_messages_terminals(cmdq, blank);
|
||||
done = 1;
|
||||
}
|
||||
if (args_has(args, 'J') || self->entry == &cmd_server_info_entry) {
|
||||
cmd_show_messages_jobs(cmdq, blank);
|
||||
if (args_has(args, 'J')) {
|
||||
job_print_summary(item, blank);
|
||||
done = 1;
|
||||
}
|
||||
if (done)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
TAILQ_FOREACH(msg, &c->message_log, entry) {
|
||||
tim = ctime(&msg->msg_time);
|
||||
*strchr(tim, '\n') = '\0';
|
||||
|
||||
cmdq_print(cmdq, "%s %s", tim, msg->msg);
|
||||
cmdq_print(item, "%s %s", tim, msg->msg);
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -27,151 +27,226 @@
|
||||
* 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 *,
|
||||
struct options *, int);
|
||||
enum cmd_retval cmd_show_options_all(struct cmd *, struct cmd_q *,
|
||||
const struct options_table_entry *, struct options *);
|
||||
static void cmd_show_options_print(struct cmd *, struct cmdq_item *,
|
||||
struct options_entry *, int, int);
|
||||
static enum cmd_retval cmd_show_options_all(struct cmd *, struct cmdq_item *,
|
||||
int, struct options *);
|
||||
|
||||
const struct cmd_entry cmd_show_options_entry = {
|
||||
"show-options", "show",
|
||||
"gqst:vw", 0, 1,
|
||||
"[-gqsvw] [-t target-session|target-window] [option]",
|
||||
0,
|
||||
cmd_show_options_exec
|
||||
.name = "show-options",
|
||||
.alias = "show",
|
||||
|
||||
.args = { "AgHpqst:vw", 0, 1 },
|
||||
.usage = "[-AgHpqsvw] " CMD_TARGET_PANE_USAGE " [option]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_show_options_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_show_window_options_entry = {
|
||||
"show-window-options", "showw",
|
||||
"gvt:", 0, 1,
|
||||
"[-gv] " CMD_TARGET_WINDOW_USAGE " [option]",
|
||||
0,
|
||||
cmd_show_options_exec
|
||||
.name = "show-window-options",
|
||||
.alias = "showw",
|
||||
|
||||
.args = { "gvt:", 0, 1 },
|
||||
.usage = "[-gv] " CMD_TARGET_WINDOW_USAGE " [option]",
|
||||
|
||||
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_show_options_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
const struct cmd_entry cmd_show_hooks_entry = {
|
||||
.name = "show-hooks",
|
||||
.alias = NULL,
|
||||
|
||||
.args = { "gt:", 0, 1 },
|
||||
.usage = "[-g] " CMD_TARGET_SESSION_USAGE,
|
||||
|
||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_show_options_exec
|
||||
};
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
const struct options_table_entry *table;
|
||||
struct options *oo;
|
||||
int quiet;
|
||||
struct args *args = self->args;
|
||||
struct cmd_find_state *fs = &item->target;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct options *oo;
|
||||
char *argument, *name = NULL, *cause;
|
||||
int window, idx, ambiguous, parent, scope;
|
||||
struct options_entry *o;
|
||||
|
||||
if (args_has(self->args, 's')) {
|
||||
oo = &global_options;
|
||||
table = server_options_table;
|
||||
} else if (args_has(self->args, 'w') ||
|
||||
self->entry == &cmd_show_window_options_entry) {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
}
|
||||
window = (self->entry == &cmd_show_window_options_entry);
|
||||
|
||||
quiet = args_has(self->args, 'q');
|
||||
if (args->argc == 0)
|
||||
return (cmd_show_options_all(self, cmdq, table, oo));
|
||||
else
|
||||
return (cmd_show_options_one(self, cmdq, oo, quiet));
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_show_options_one(struct cmd *self, struct cmd_q *cmdq,
|
||||
struct options *oo, int quiet)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
const char *name = args->argv[0];
|
||||
const struct options_table_entry *table, *oe;
|
||||
struct options_entry *o;
|
||||
const char *optval;
|
||||
|
||||
retry:
|
||||
if (*name == '@') {
|
||||
if ((o = options_find1(oo, name)) == NULL) {
|
||||
if (quiet)
|
||||
if (args->argc == 0) {
|
||||
scope = options_scope_from_flags(args, window, fs, &oo, &cause);
|
||||
if (scope == OPTIONS_TABLE_NONE) {
|
||||
if (args_has(args, 'q'))
|
||||
return (CMD_RETURN_NORMAL);
|
||||
cmdq_error(cmdq, "unknown option: %s", name);
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (args_has(self->args, 'v'))
|
||||
cmdq_print(cmdq, "%s", o->str);
|
||||
else
|
||||
cmdq_print(cmdq, "%s \"%s\"", o->name, o->str);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
return (cmd_show_options_all(self, item, scope, oo));
|
||||
}
|
||||
argument = format_single(item, args->argv[0], c, s, wl, NULL);
|
||||
|
||||
table = oe = NULL;
|
||||
if (options_table_find(name, &table, &oe) != 0) {
|
||||
cmdq_error(cmdq, "ambiguous option: %s", name);
|
||||
return (CMD_RETURN_ERROR);
|
||||
name = options_match(argument, &idx, &ambiguous);
|
||||
if (name == NULL) {
|
||||
if (args_has(args, 'q'))
|
||||
goto fail;
|
||||
if (ambiguous)
|
||||
cmdq_error(item, "ambiguous option: %s", argument);
|
||||
else
|
||||
cmdq_error(item, "invalid option: %s", argument);
|
||||
goto fail;
|
||||
}
|
||||
if (oe == NULL) {
|
||||
if (quiet)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
cmdq_error(cmdq, "unknown option: %s", name);
|
||||
return (CMD_RETURN_ERROR);
|
||||
scope = options_scope_from_name(args, window, name, fs, &oo, &cause);
|
||||
if (scope == OPTIONS_TABLE_NONE) {
|
||||
if (args_has(args, 'q'))
|
||||
goto fail;
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
goto fail;
|
||||
}
|
||||
if (oe->style != NULL) {
|
||||
name = oe->style;
|
||||
goto retry;
|
||||
}
|
||||
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);
|
||||
o = options_get_only(oo, name);
|
||||
if (args_has(args, 'A') && o == NULL) {
|
||||
o = options_get(oo, name);
|
||||
parent = 1;
|
||||
} else
|
||||
parent = 0;
|
||||
if (o != NULL)
|
||||
cmd_show_options_print(self, item, o, idx, parent);
|
||||
|
||||
free(name);
|
||||
free(argument);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
fail:
|
||||
free(name);
|
||||
free(argument);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_show_options_all(struct cmd *self, struct cmd_q *cmdq,
|
||||
const struct options_table_entry *table, struct options *oo)
|
||||
static void
|
||||
cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
|
||||
struct options_entry *o, int idx, int parent)
|
||||
{
|
||||
struct options_array_item *a;
|
||||
const char *name = options_name(o);
|
||||
char *value, *tmp = NULL, *escaped;
|
||||
|
||||
if (idx != -1) {
|
||||
xasprintf(&tmp, "%s[%d]", name, idx);
|
||||
name = tmp;
|
||||
} else {
|
||||
if (options_isarray(o)) {
|
||||
a = options_array_first(o);
|
||||
if (a == NULL) {
|
||||
if (!args_has(self->args, 'v'))
|
||||
cmdq_print(item, "%s", name);
|
||||
return;
|
||||
}
|
||||
while (a != NULL) {
|
||||
idx = options_array_item_index(a);
|
||||
cmd_show_options_print(self, item, o, idx,
|
||||
parent);
|
||||
a = options_array_next(a);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
value = options_tostring(o, idx, 0);
|
||||
if (args_has(self->args, 'v'))
|
||||
cmdq_print(item, "%s", value);
|
||||
else if (options_isstring(o)) {
|
||||
escaped = args_escape(value);
|
||||
if (parent)
|
||||
cmdq_print(item, "%s* %s", name, escaped);
|
||||
else
|
||||
cmdq_print(item, "%s %s", name, escaped);
|
||||
free(escaped);
|
||||
} else {
|
||||
if (parent)
|
||||
cmdq_print(item, "%s* %s", name, value);
|
||||
else
|
||||
cmdq_print(item, "%s %s", name, value);
|
||||
}
|
||||
free(value);
|
||||
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope,
|
||||
struct options *oo)
|
||||
{
|
||||
const struct options_table_entry *oe;
|
||||
struct options_entry *o;
|
||||
const char *optval;
|
||||
struct options_array_item *a;
|
||||
const char *name;
|
||||
u_int idx;
|
||||
int parent;
|
||||
|
||||
RB_FOREACH(o, options_tree, &oo->tree) {
|
||||
if (*o->name == '@') {
|
||||
if (args_has(self->args, 'v'))
|
||||
cmdq_print(cmdq, "%s", o->str);
|
||||
else
|
||||
cmdq_print(cmdq, "%s \"%s\"", o->name, o->str);
|
||||
o = options_first(oo);
|
||||
while (o != NULL) {
|
||||
if (options_table_entry(o) == NULL)
|
||||
cmd_show_options_print(self, item, o, -1, 0);
|
||||
o = options_next(o);
|
||||
}
|
||||
for (oe = options_table; oe->name != NULL; oe++) {
|
||||
if (~oe->scope & scope)
|
||||
continue;
|
||||
|
||||
if ((self->entry != &cmd_show_hooks_entry &&
|
||||
!args_has(self->args, 'H') &&
|
||||
oe != NULL &&
|
||||
(oe->flags & OPTIONS_TABLE_IS_HOOK)) ||
|
||||
(self->entry == &cmd_show_hooks_entry &&
|
||||
(oe == NULL ||
|
||||
(~oe->flags & OPTIONS_TABLE_IS_HOOK))))
|
||||
continue;
|
||||
|
||||
o = options_get_only(oo, oe->name);
|
||||
if (o == NULL) {
|
||||
if (!args_has(self->args, 'A'))
|
||||
continue;
|
||||
o = options_get(oo, oe->name);
|
||||
if (o == NULL)
|
||||
continue;
|
||||
parent = 1;
|
||||
} else
|
||||
parent = 0;
|
||||
|
||||
if (!options_isarray(o))
|
||||
cmd_show_options_print(self, item, o, -1, parent);
|
||||
else if ((a = options_array_first(o)) == NULL) {
|
||||
if (!args_has(self->args, 'v')) {
|
||||
name = options_name(o);
|
||||
if (parent)
|
||||
cmdq_print(item, "%s*", name);
|
||||
else
|
||||
cmdq_print(item, "%s", name);
|
||||
}
|
||||
} else {
|
||||
while (a != NULL) {
|
||||
idx = options_array_item_index(a);
|
||||
cmd_show_options_print(self, item, o, idx,
|
||||
parent);
|
||||
a = options_array_next(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (oe = table; oe->name != NULL; oe++) {
|
||||
if (oe->style != NULL)
|
||||
continue;
|
||||
if ((o = options_find1(oo, oe->name)) == NULL)
|
||||
continue;
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,10 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <glob.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@@ -26,71 +29,164 @@
|
||||
* Sources a configuration file.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
void cmd_source_file_done(struct cmd_q *);
|
||||
static enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_source_file_entry = {
|
||||
"source-file", "source",
|
||||
"", 1, 1,
|
||||
"path",
|
||||
0,
|
||||
cmd_source_file_exec
|
||||
.name = "source-file",
|
||||
.alias = "source",
|
||||
|
||||
.args = { "nqv", 1, -1 },
|
||||
.usage = "[-nqv] path ...",
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_source_file_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_source_file_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
struct cmd_source_file_data {
|
||||
struct cmdq_item *item;
|
||||
int flags;
|
||||
|
||||
struct cmdq_item *after;
|
||||
enum cmd_retval retval;
|
||||
|
||||
u_int current;
|
||||
char **files;
|
||||
u_int nfiles;
|
||||
};
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_source_file_complete_cb(struct cmdq_item *item, __unused void *data)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct cmd_q *cmdq1;
|
||||
char *cause;
|
||||
cfg_print_causes(item);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
cmdq1 = cmdq_new(NULL);
|
||||
cmdq1->client = cmdq->client;
|
||||
cmdq1->emptyfn = cmd_source_file_done;
|
||||
cmdq1->data = cmdq;
|
||||
static void
|
||||
cmd_source_file_complete(struct client *c, struct cmd_source_file_data *cdata)
|
||||
{
|
||||
struct cmdq_item *new_item;
|
||||
|
||||
switch (load_cfg(args->argv[0], cmdq1, &cause)) {
|
||||
case -1:
|
||||
if (cfg_references == 0) {
|
||||
cmdq_free(cmdq1);
|
||||
cmdq_error(cmdq, "%s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
cfg_add_cause("%s", cause);
|
||||
free(cause);
|
||||
/* FALLTHROUGH */
|
||||
case 0:
|
||||
if (cfg_references == 0)
|
||||
cfg_print_causes(cmdq);
|
||||
cmdq_free(cmdq1);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
if (cfg_finished) {
|
||||
if (cdata->retval == CMD_RETURN_ERROR && c->session == NULL)
|
||||
c->retval = 1;
|
||||
new_item = cmdq_get_callback(cmd_source_file_complete_cb, NULL);
|
||||
cmdq_insert_after(cdata->after, new_item);
|
||||
}
|
||||
|
||||
cmdq->references++;
|
||||
cfg_references++;
|
||||
|
||||
cmdq_continue(cmdq1);
|
||||
return (CMD_RETURN_WAIT);
|
||||
free(cdata->files);
|
||||
free(cdata);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_source_file_done(struct cmd_q *cmdq1)
|
||||
static void
|
||||
cmd_source_file_done(struct client *c, const char *path, int error,
|
||||
int closed, struct evbuffer *buffer, void *data)
|
||||
{
|
||||
struct cmd_q *cmdq = cmdq1->data;
|
||||
struct cmd_source_file_data *cdata = data;
|
||||
struct cmdq_item *item = cdata->item;
|
||||
void *bdata = EVBUFFER_DATA(buffer);
|
||||
size_t bsize = EVBUFFER_LENGTH(buffer);
|
||||
u_int n;
|
||||
struct cmdq_item *new_item;
|
||||
|
||||
if (cmdq1->client_exit >= 0)
|
||||
cmdq->client_exit = cmdq1->client_exit;
|
||||
|
||||
cmdq_free(cmdq1);
|
||||
|
||||
cfg_references--;
|
||||
|
||||
if (cmdq_free(cmdq))
|
||||
if (!closed)
|
||||
return;
|
||||
|
||||
if (cfg_references == 0)
|
||||
cfg_print_causes(cmdq);
|
||||
cmdq_continue(cmdq);
|
||||
if (error != 0)
|
||||
cmdq_error(item, "%s: %s", path, strerror(error));
|
||||
else if (bsize != 0) {
|
||||
if (load_cfg_from_buffer(bdata, bsize, path, c, cdata->after,
|
||||
cdata->flags, &new_item) < 0)
|
||||
cdata->retval = CMD_RETURN_ERROR;
|
||||
else if (new_item != NULL)
|
||||
cdata->after = new_item;
|
||||
}
|
||||
|
||||
n = ++cdata->current;
|
||||
if (n < cdata->nfiles)
|
||||
file_read(c, cdata->files[n], cmd_source_file_done, cdata);
|
||||
else {
|
||||
cmd_source_file_complete(c, cdata);
|
||||
cmdq_continue(item);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_source_file_add(struct cmd_source_file_data *cdata, const char *path)
|
||||
{
|
||||
log_debug("%s: %s", __func__, path);
|
||||
cdata->files = xreallocarray(cdata->files, cdata->nfiles + 1,
|
||||
sizeof *cdata->files);
|
||||
cdata->files[cdata->nfiles++] = xstrdup(path);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct cmd_source_file_data *cdata;
|
||||
struct client *c = item->client;
|
||||
enum cmd_retval retval = CMD_RETURN_NORMAL;
|
||||
char *pattern, *cwd;
|
||||
const char *path, *error;
|
||||
glob_t g;
|
||||
int i, result;
|
||||
u_int j;
|
||||
|
||||
cdata = xcalloc(1, sizeof *cdata);
|
||||
cdata->item = item;
|
||||
|
||||
if (args_has(args, 'q'))
|
||||
cdata->flags |= CMD_PARSE_QUIET;
|
||||
if (args_has(args, 'n'))
|
||||
cdata->flags |= CMD_PARSE_PARSEONLY;
|
||||
if (args_has(args, 'v'))
|
||||
cdata->flags |= CMD_PARSE_VERBOSE;
|
||||
|
||||
utf8_stravis(&cwd, server_client_get_cwd(c, NULL), VIS_GLOB);
|
||||
|
||||
for (i = 0; i < args->argc; i++) {
|
||||
path = args->argv[i];
|
||||
if (strcmp(path, "-") == 0) {
|
||||
cmd_source_file_add(cdata, "-");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*path == '/')
|
||||
pattern = xstrdup(path);
|
||||
else
|
||||
xasprintf(&pattern, "%s/%s", cwd, path);
|
||||
log_debug("%s: %s", __func__, pattern);
|
||||
|
||||
if ((result = glob(pattern, 0, NULL, &g)) != 0) {
|
||||
if (result != GLOB_NOMATCH ||
|
||||
(~cdata->flags & CMD_PARSE_QUIET)) {
|
||||
if (result == GLOB_NOMATCH)
|
||||
error = strerror(ENOENT);
|
||||
else if (result == GLOB_NOSPACE)
|
||||
error = strerror(ENOMEM);
|
||||
else
|
||||
error = strerror(EINVAL);
|
||||
cmdq_error(item, "%s: %s", path, error);
|
||||
retval = CMD_RETURN_ERROR;
|
||||
}
|
||||
free(pattern);
|
||||
continue;
|
||||
}
|
||||
free(pattern);
|
||||
|
||||
for (j = 0; j < g.gl_pathc; j++)
|
||||
cmd_source_file_add(cdata, g.gl_pathv[j]);
|
||||
}
|
||||
|
||||
cdata->after = item;
|
||||
cdata->retval = retval;
|
||||
|
||||
if (cdata->nfiles != 0) {
|
||||
file_read(c, cdata->files[0], cmd_source_file_done, cdata);
|
||||
retval = CMD_RETURN_WAIT;
|
||||
} else
|
||||
cmd_source_file_complete(c, cdata);
|
||||
|
||||
free(cwd);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -32,174 +32,157 @@
|
||||
|
||||
#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 = {
|
||||
"split-window", "splitw",
|
||||
"bc:dF:l:hp:Pt:v", 0, -1,
|
||||
"[-bdhvP] [-c start-directory] [-F format] [-p percentage|-l size] "
|
||||
CMD_TARGET_PANE_USAGE " [command]",
|
||||
0,
|
||||
cmd_split_window_exec
|
||||
.name = "split-window",
|
||||
.alias = "splitw",
|
||||
|
||||
.args = { "bc:de:fF:hIl:p:Pt:v", 0, -1 },
|
||||
.usage = "[-bdefhIPv] [-c start-directory] [-e environment] "
|
||||
"[-F format] [-l size] " CMD_TARGET_PANE_USAGE " [command]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_split_window_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
struct window *w;
|
||||
struct window_pane *wp, *new_wp = NULL;
|
||||
struct environ env;
|
||||
const char *cmd, *path, *shell, *template;
|
||||
char **argv, *cause, *new_cause, *cp;
|
||||
u_int hlimit;
|
||||
int argc, size, percentage, cwd, fd = -1;
|
||||
struct cmd_find_state *current = &item->shared->current;
|
||||
struct spawn_context sc;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *wp = item->target.wp, *new_wp;
|
||||
enum layout_type type;
|
||||
struct layout_cell *lc;
|
||||
struct format_tree *ft;
|
||||
struct environ_entry *envent;
|
||||
struct cmd_find_state fs;
|
||||
int size, percentage, flags, input;
|
||||
const char *template, *add, *errstr, *p;
|
||||
char *cause, *cp, *copy;
|
||||
size_t plen;
|
||||
struct args_value *value;
|
||||
|
||||
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
w = wl->window;
|
||||
server_unzoom_window(w);
|
||||
|
||||
environ_init(&env);
|
||||
environ_copy(&global_environ, &env);
|
||||
environ_copy(&s->environ, &env);
|
||||
server_fill_environ(s, &env);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (args_has(args, 'c')) {
|
||||
ft = format_create();
|
||||
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, NULL,
|
||||
NULL);
|
||||
cp = format_expand(ft, args_get(args, 'c'));
|
||||
format_free(ft);
|
||||
|
||||
if (cp != NULL && *cp != '\0') {
|
||||
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
||||
free(cp);
|
||||
if (fd == -1) {
|
||||
cmdq_error(cmdq, "bad working directory: %s",
|
||||
strerror(errno));
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else if (cp != NULL)
|
||||
free(cp);
|
||||
cwd = fd;
|
||||
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||
cwd = cmdq->client->cwd;
|
||||
else
|
||||
cwd = s->cwd;
|
||||
|
||||
type = LAYOUT_TOPBOTTOM;
|
||||
if (args_has(args, 'h'))
|
||||
type = LAYOUT_LEFTRIGHT;
|
||||
|
||||
size = -1;
|
||||
if (args_has(args, 'l')) {
|
||||
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
||||
if (cause != NULL) {
|
||||
xasprintf(&new_cause, "size %s", cause);
|
||||
free(cause);
|
||||
cause = new_cause;
|
||||
goto error;
|
||||
else
|
||||
type = LAYOUT_TOPBOTTOM;
|
||||
if ((p = args_get(args, 'l')) != NULL) {
|
||||
plen = strlen(p);
|
||||
if (p[plen - 1] == '%') {
|
||||
copy = xstrdup(p);
|
||||
copy[plen - 1] = '\0';
|
||||
percentage = strtonum(copy, 0, INT_MAX, &errstr);
|
||||
free(copy);
|
||||
if (errstr != NULL) {
|
||||
cmdq_error(item, "percentage %s", errstr);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (type == LAYOUT_TOPBOTTOM)
|
||||
size = (wp->sy * percentage) / 100;
|
||||
else
|
||||
size = (wp->sx * percentage) / 100;
|
||||
} else {
|
||||
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "lines %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
} else if (args_has(args, 'p')) {
|
||||
percentage = args_strtonum(args, 'p', 0, INT_MAX, &cause);
|
||||
if (cause != NULL) {
|
||||
xasprintf(&new_cause, "percentage %s", cause);
|
||||
cmdq_error(item, "create pane failed: -p %s", cause);
|
||||
free(cause);
|
||||
cause = new_cause;
|
||||
goto error;
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (type == LAYOUT_TOPBOTTOM)
|
||||
size = (wp->sy * percentage) / 100;
|
||||
else
|
||||
size = (wp->sx * percentage) / 100;
|
||||
}
|
||||
hlimit = options_get_number(&s->options, "history-limit");
|
||||
|
||||
shell = options_get_string(&s->options, "default-shell");
|
||||
if (*shell == '\0' || areshell(shell))
|
||||
shell = _PATH_BSHELL;
|
||||
|
||||
lc = layout_split_pane(wp, type, size, args_has(args, 'b'));
|
||||
if (lc == NULL) {
|
||||
cause = xstrdup("pane too small");
|
||||
goto error;
|
||||
}
|
||||
new_wp = window_add_pane(w, hlimit);
|
||||
layout_assign_pane(lc, new_wp);
|
||||
|
||||
path = NULL;
|
||||
if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||
envent = environ_find(&cmdq->client->environ, "PATH");
|
||||
else
|
||||
envent = environ_find(&s->environ, "PATH");
|
||||
if (envent != NULL)
|
||||
path = envent->value;
|
||||
|
||||
if (window_pane_spawn(new_wp, argc, argv, path, shell, cwd, &env,
|
||||
s->tio, &cause) != 0)
|
||||
goto error;
|
||||
|
||||
server_redraw_window(w);
|
||||
|
||||
if (!args_has(args, 'd')) {
|
||||
window_set_active_pane(w, new_wp);
|
||||
session_select(s, wl->idx);
|
||||
server_redraw_session(s);
|
||||
} else
|
||||
server_status_session(s);
|
||||
size = -1;
|
||||
|
||||
environ_free(&env);
|
||||
server_unzoom_window(wp->window);
|
||||
input = (args_has(args, 'I') && args->argc == 0);
|
||||
|
||||
flags = 0;
|
||||
if (args_has(args, 'b'))
|
||||
flags |= SPAWN_BEFORE;
|
||||
if (args_has(args, 'f'))
|
||||
flags |= SPAWN_FULLSIZE;
|
||||
if (input || (args->argc == 1 && *args->argv[0] == '\0'))
|
||||
flags |= SPAWN_EMPTY;
|
||||
|
||||
lc = layout_split_pane(wp, type, size, flags);
|
||||
if (lc == NULL) {
|
||||
cmdq_error(item, "no space for new pane");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
memset(&sc, 0, sizeof sc);
|
||||
sc.item = item;
|
||||
sc.s = s;
|
||||
sc.wl = wl;
|
||||
|
||||
sc.wp0 = wp;
|
||||
sc.lc = lc;
|
||||
|
||||
sc.name = NULL;
|
||||
sc.argc = args->argc;
|
||||
sc.argv = args->argv;
|
||||
sc.environ = environ_create();
|
||||
|
||||
add = args_first_value(args, 'e', &value);
|
||||
while (add != NULL) {
|
||||
environ_put(sc.environ, add);
|
||||
add = args_next_value(&value);
|
||||
}
|
||||
|
||||
sc.idx = -1;
|
||||
sc.cwd = args_get(args, 'c');
|
||||
|
||||
sc.flags = flags;
|
||||
if (args_has(args, 'd'))
|
||||
sc.flags |= SPAWN_DETACHED;
|
||||
|
||||
if ((new_wp = spawn_pane(&sc, &cause)) == NULL) {
|
||||
layout_close_pane(new_wp);
|
||||
cmdq_error(item, "create pane failed: %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (input && window_pane_start_input(new_wp, item, &cause) != 0) {
|
||||
layout_close_pane(new_wp);
|
||||
window_remove_pane(wp->window, new_wp);
|
||||
cmdq_error(item, "%s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (!args_has(args, 'd'))
|
||||
cmd_find_from_winlink_pane(current, wl, new_wp, 0);
|
||||
server_redraw_window(wp->window);
|
||||
server_status_session(s);
|
||||
|
||||
if (args_has(args, 'P')) {
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = SPLIT_WINDOW_TEMPLATE;
|
||||
|
||||
ft = format_create();
|
||||
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, wl,
|
||||
new_wp);
|
||||
|
||||
cp = format_expand(ft, template);
|
||||
cmdq_print(cmdq, "%s", cp);
|
||||
cp = format_single(item, template, c, s, wl, new_wp);
|
||||
cmdq_print(item, "%s", cp);
|
||||
free(cp);
|
||||
|
||||
format_free(ft);
|
||||
}
|
||||
notify_window_layout_changed(w);
|
||||
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
cmd_find_from_winlink_pane(&fs, wl, new_wp, 0);
|
||||
cmdq_insert_hook(s, item, &fs, "after-split-window");
|
||||
|
||||
environ_free(sc.environ);
|
||||
if (input)
|
||||
return (CMD_RETURN_WAIT);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
error:
|
||||
environ_free(&env);
|
||||
if (new_wp != NULL) {
|
||||
layout_close_pane(new_wp);
|
||||
window_remove_pane(w, new_wp);
|
||||
}
|
||||
cmdq_error(cmdq, "create pane failed: %s", cause);
|
||||
free(cause);
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
359
cmd-string.c
359
cmd-string.c
@@ -1,359 +0,0 @@
|
||||
/* $OpenBSD$ */
|
||||
|
||||
/*
|
||||
* 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 <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Parse a command from a string.
|
||||
*/
|
||||
|
||||
int cmd_string_getc(const char *, size_t *);
|
||||
void cmd_string_ungetc(size_t *);
|
||||
void cmd_string_copy(char **, char *, size_t *);
|
||||
char *cmd_string_string(const char *, size_t *, char, int);
|
||||
char *cmd_string_variable(const char *, size_t *);
|
||||
char *cmd_string_expand_tilde(const char *, size_t *);
|
||||
|
||||
int
|
||||
cmd_string_getc(const char *s, size_t *p)
|
||||
{
|
||||
const u_char *ucs = s;
|
||||
|
||||
if (ucs[*p] == '\0')
|
||||
return (EOF);
|
||||
return (ucs[(*p)++]);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_string_ungetc(size_t *p)
|
||||
{
|
||||
(*p)--;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse command string. Returns -1 on error. If returning -1, cause is error
|
||||
* string, or NULL for empty command.
|
||||
*/
|
||||
int
|
||||
cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file,
|
||||
u_int line, char **cause)
|
||||
{
|
||||
size_t p;
|
||||
int ch, i, argc, rval;
|
||||
char **argv, *buf, *t;
|
||||
const char *whitespace, *equals;
|
||||
size_t len;
|
||||
|
||||
argv = NULL;
|
||||
argc = 0;
|
||||
|
||||
buf = NULL;
|
||||
len = 0;
|
||||
|
||||
*cause = NULL;
|
||||
|
||||
*cmdlist = NULL;
|
||||
rval = -1;
|
||||
|
||||
p = 0;
|
||||
for (;;) {
|
||||
ch = cmd_string_getc(s, &p);
|
||||
switch (ch) {
|
||||
case '\'':
|
||||
if ((t = cmd_string_string(s, &p, '\'', 0)) == NULL)
|
||||
goto error;
|
||||
cmd_string_copy(&buf, t, &len);
|
||||
break;
|
||||
case '"':
|
||||
if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
|
||||
goto error;
|
||||
cmd_string_copy(&buf, t, &len);
|
||||
break;
|
||||
case '$':
|
||||
if ((t = cmd_string_variable(s, &p)) == NULL)
|
||||
goto error;
|
||||
cmd_string_copy(&buf, t, &len);
|
||||
break;
|
||||
case '#':
|
||||
/* Comment: discard rest of line. */
|
||||
while ((ch = cmd_string_getc(s, &p)) != EOF)
|
||||
;
|
||||
/* FALLTHROUGH */
|
||||
case EOF:
|
||||
case ' ':
|
||||
case '\t':
|
||||
if (buf != NULL) {
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len] = '\0';
|
||||
|
||||
argv = xreallocarray(argv, argc + 1,
|
||||
sizeof *argv);
|
||||
argv[argc++] = buf;
|
||||
|
||||
buf = NULL;
|
||||
len = 0;
|
||||
}
|
||||
|
||||
if (ch != EOF)
|
||||
break;
|
||||
|
||||
while (argc != 0) {
|
||||
equals = strchr(argv[0], '=');
|
||||
whitespace = argv[0] + strcspn(argv[0], " \t");
|
||||
if (equals == NULL || equals > whitespace)
|
||||
break;
|
||||
environ_put(&global_environ, argv[0]);
|
||||
argc--;
|
||||
memmove(argv, argv + 1, argc * (sizeof *argv));
|
||||
}
|
||||
if (argc == 0)
|
||||
goto out;
|
||||
|
||||
*cmdlist = cmd_list_parse(argc, argv, file, line, cause);
|
||||
if (*cmdlist == NULL)
|
||||
goto out;
|
||||
|
||||
rval = 0;
|
||||
goto out;
|
||||
case '~':
|
||||
if (buf == NULL) {
|
||||
t = cmd_string_expand_tilde(s, &p);
|
||||
if (t == NULL)
|
||||
goto error;
|
||||
cmd_string_copy(&buf, t, &len);
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
if (len >= SIZE_MAX - 2)
|
||||
goto error;
|
||||
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len++] = ch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
error:
|
||||
xasprintf(cause, "invalid or unknown command: %s", s);
|
||||
|
||||
out:
|
||||
free(buf);
|
||||
|
||||
if (argv != NULL) {
|
||||
for (i = 0; i < argc; i++)
|
||||
free(argv[i]);
|
||||
free(argv);
|
||||
}
|
||||
|
||||
return (rval);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_string_copy(char **dst, char *src, size_t *len)
|
||||
{
|
||||
size_t srclen;
|
||||
|
||||
srclen = strlen(src);
|
||||
|
||||
*dst = xrealloc(*dst, *len + srclen + 1);
|
||||
strlcpy(*dst + *len, src, srclen + 1);
|
||||
|
||||
*len += srclen;
|
||||
free(src);
|
||||
}
|
||||
|
||||
char *
|
||||
cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
||||
{
|
||||
int ch;
|
||||
char *buf, *t;
|
||||
size_t len;
|
||||
|
||||
buf = NULL;
|
||||
len = 0;
|
||||
|
||||
while ((ch = cmd_string_getc(s, p)) != endch) {
|
||||
switch (ch) {
|
||||
case EOF:
|
||||
goto error;
|
||||
case '\\':
|
||||
if (!esc)
|
||||
break;
|
||||
switch (ch = cmd_string_getc(s, p)) {
|
||||
case EOF:
|
||||
goto error;
|
||||
case 'e':
|
||||
ch = '\033';
|
||||
break;
|
||||
case 'r':
|
||||
ch = '\r';
|
||||
break;
|
||||
case 'n':
|
||||
ch = '\n';
|
||||
break;
|
||||
case 't':
|
||||
ch = '\t';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '$':
|
||||
if (!esc)
|
||||
break;
|
||||
if ((t = cmd_string_variable(s, p)) == NULL)
|
||||
goto error;
|
||||
cmd_string_copy(&buf, t, &len);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (len >= SIZE_MAX - 2)
|
||||
goto error;
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len++] = ch;
|
||||
}
|
||||
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len] = '\0';
|
||||
return (buf);
|
||||
|
||||
error:
|
||||
free(buf);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
cmd_string_variable(const char *s, size_t *p)
|
||||
{
|
||||
int ch, fch;
|
||||
char *buf, *t;
|
||||
size_t len;
|
||||
struct environ_entry *envent;
|
||||
|
||||
#define cmd_string_first(ch) ((ch) == '_' || \
|
||||
((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z'))
|
||||
#define cmd_string_other(ch) ((ch) == '_' || \
|
||||
((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z') || \
|
||||
((ch) >= '0' && (ch) <= '9'))
|
||||
|
||||
buf = NULL;
|
||||
len = 0;
|
||||
|
||||
fch = EOF;
|
||||
switch (ch = cmd_string_getc(s, p)) {
|
||||
case EOF:
|
||||
goto error;
|
||||
case '{':
|
||||
fch = '{';
|
||||
|
||||
ch = cmd_string_getc(s, p);
|
||||
if (!cmd_string_first(ch))
|
||||
goto error;
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
if (!cmd_string_first(ch)) {
|
||||
xasprintf(&t, "$%c", ch);
|
||||
return (t);
|
||||
}
|
||||
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len++] = ch;
|
||||
|
||||
for (;;) {
|
||||
ch = cmd_string_getc(s, p);
|
||||
if (ch == EOF || !cmd_string_other(ch))
|
||||
break;
|
||||
else {
|
||||
if (len >= SIZE_MAX - 3)
|
||||
goto error;
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len++] = ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fch == '{' && ch != '}')
|
||||
goto error;
|
||||
if (ch != EOF && fch != '{')
|
||||
cmd_string_ungetc(p); /* ch */
|
||||
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len] = '\0';
|
||||
|
||||
envent = environ_find(&global_environ, buf);
|
||||
free(buf);
|
||||
if (envent == NULL)
|
||||
return (xstrdup(""));
|
||||
return (xstrdup(envent->value));
|
||||
|
||||
error:
|
||||
free(buf);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
cmd_string_expand_tilde(const char *s, size_t *p)
|
||||
{
|
||||
struct passwd *pw;
|
||||
struct environ_entry *envent;
|
||||
char *home, *path, *user, *cp;
|
||||
int last;
|
||||
|
||||
home = NULL;
|
||||
|
||||
last = cmd_string_getc(s, p);
|
||||
if (last == EOF || last == '/' || last == ' '|| last == '\t') {
|
||||
envent = environ_find(&global_environ, "HOME");
|
||||
if (envent != NULL && *envent->value != '\0')
|
||||
home = envent->value;
|
||||
else if ((pw = getpwuid(getuid())) != NULL)
|
||||
home = pw->pw_dir;
|
||||
} else {
|
||||
cmd_string_ungetc(p);
|
||||
|
||||
cp = user = xmalloc(strlen(s));
|
||||
for (;;) {
|
||||
last = cmd_string_getc(s, p);
|
||||
if (last == EOF || last == '/' || last == ' '|| last == '\t')
|
||||
break;
|
||||
*cp++ = last;
|
||||
}
|
||||
*cp = '\0';
|
||||
|
||||
if ((pw = getpwnam(user)) != NULL)
|
||||
home = pw->pw_dir;
|
||||
free(user);
|
||||
}
|
||||
|
||||
if (home == NULL)
|
||||
return (NULL);
|
||||
|
||||
if (last != EOF)
|
||||
xasprintf(&path, "%s%c", home, last);
|
||||
else
|
||||
xasprintf(&path, "%s", home);
|
||||
return (path);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -26,60 +26,56 @@
|
||||
* Swap two panes.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_swap_pane_entry = {
|
||||
"swap-pane", "swapp",
|
||||
"dDs:t:U", 0, 0,
|
||||
"[-dDU] " CMD_SRCDST_PANE_USAGE,
|
||||
0,
|
||||
cmd_swap_pane_exec
|
||||
.name = "swap-pane",
|
||||
.alias = "swapp",
|
||||
|
||||
.args = { "dDs:t:UZ", 0, 0 },
|
||||
.usage = "[-dDUZ] " CMD_SRCDST_PANE_USAGE,
|
||||
|
||||
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_swap_pane_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct winlink *src_wl, *dst_wl;
|
||||
struct window *src_w, *dst_w;
|
||||
struct window_pane *tmp_wp, *src_wp, *dst_wp;
|
||||
struct layout_cell *src_lc, *dst_lc;
|
||||
u_int sx, sy, xoff, yoff;
|
||||
|
||||
dst_wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &dst_wp);
|
||||
if (dst_wl == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
dst_w = dst_wl->window;
|
||||
server_unzoom_window(dst_w);
|
||||
dst_w = item->target.wl->window;
|
||||
dst_wp = item->target.wp;
|
||||
src_w = item->source.wl->window;
|
||||
src_wp = item->source.wp;
|
||||
|
||||
if (!args_has(args, 's')) {
|
||||
if (window_push_zoom(dst_w, args_has(args, 'Z')))
|
||||
server_redraw_window(dst_w);
|
||||
|
||||
if (args_has(args, 'D')) {
|
||||
src_w = dst_w;
|
||||
if (args_has(self->args, 'D')) {
|
||||
src_wp = TAILQ_NEXT(dst_wp, entry);
|
||||
if (src_wp == NULL)
|
||||
src_wp = TAILQ_FIRST(&dst_w->panes);
|
||||
} else if (args_has(self->args, 'U')) {
|
||||
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||
if (src_wp == NULL)
|
||||
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
||||
} else {
|
||||
src_wl = cmd_find_pane_marked(cmdq, NULL, NULL,
|
||||
&src_wp);
|
||||
if (src_wl == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
src_w = src_wl->window;
|
||||
}
|
||||
} else {
|
||||
src_wl = cmd_find_pane_marked(cmdq, args_get(args, 's'), NULL,
|
||||
&src_wp);
|
||||
if (src_wl == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
src_w = src_wl->window;
|
||||
src_wp = TAILQ_NEXT(dst_wp, entry);
|
||||
if (src_wp == NULL)
|
||||
src_wp = TAILQ_FIRST(&dst_w->panes);
|
||||
} else if (args_has(args, 'U')) {
|
||||
src_w = dst_w;
|
||||
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||
if (src_wp == NULL)
|
||||
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
||||
}
|
||||
server_unzoom_window(src_w);
|
||||
|
||||
if (src_w != dst_w && window_push_zoom(src_w, args_has(args, 'Z')))
|
||||
server_redraw_window(src_w);
|
||||
|
||||
if (src_wp == dst_wp)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
goto out;
|
||||
|
||||
tmp_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||
TAILQ_REMOVE(&dst_w->panes, dst_wp, entry);
|
||||
@@ -99,7 +95,11 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
src_wp->layout_cell = dst_lc;
|
||||
|
||||
src_wp->window = dst_w;
|
||||
options_set_parent(src_wp->options, dst_w->options);
|
||||
src_wp->flags |= PANE_STYLECHANGED;
|
||||
dst_wp->window = src_w;
|
||||
options_set_parent(dst_wp->options, src_w->options);
|
||||
dst_wp->flags |= PANE_STYLECHANGED;
|
||||
|
||||
sx = src_wp->sx; sy = src_wp->sy;
|
||||
xoff = src_wp->xoff; yoff = src_wp->yoff;
|
||||
@@ -108,21 +108,19 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
dst_wp->xoff = xoff; dst_wp->yoff = yoff;
|
||||
window_pane_resize(dst_wp, sx, sy);
|
||||
|
||||
if (!args_has(self->args, 'd')) {
|
||||
if (!args_has(args, 'd')) {
|
||||
if (src_w != dst_w) {
|
||||
window_set_active_pane(src_w, dst_wp);
|
||||
window_set_active_pane(dst_w, src_wp);
|
||||
window_set_active_pane(src_w, dst_wp, 1);
|
||||
window_set_active_pane(dst_w, src_wp, 1);
|
||||
} else {
|
||||
tmp_wp = dst_wp;
|
||||
if (!window_pane_visible(tmp_wp))
|
||||
tmp_wp = src_wp;
|
||||
window_set_active_pane(src_w, tmp_wp);
|
||||
window_set_active_pane(src_w, tmp_wp, 1);
|
||||
}
|
||||
} else {
|
||||
if (src_w->active == src_wp)
|
||||
window_set_active_pane(src_w, dst_wp);
|
||||
window_set_active_pane(src_w, dst_wp, 1);
|
||||
if (dst_w->active == dst_wp)
|
||||
window_set_active_pane(dst_w, src_wp);
|
||||
window_set_active_pane(dst_w, src_wp, 1);
|
||||
}
|
||||
if (src_w != dst_w) {
|
||||
if (src_w->last == src_wp)
|
||||
@@ -133,5 +131,10 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
server_redraw_window(src_w);
|
||||
server_redraw_window(dst_w);
|
||||
|
||||
out:
|
||||
if (window_pop_zoom(src_w))
|
||||
server_redraw_window(src_w);
|
||||
if (src_w != dst_w && window_pop_zoom(dst_w))
|
||||
server_redraw_window(dst_w);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -26,49 +26,58 @@
|
||||
* 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 = {
|
||||
"swap-window", "swapw",
|
||||
"ds:t:", 0, 0,
|
||||
"[-d] " CMD_SRCDST_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_swap_window_exec
|
||||
.name = "swap-window",
|
||||
.alias = "swapw",
|
||||
|
||||
.args = { "ds:t:", 0, 0 },
|
||||
.usage = "[-d] " CMD_SRCDST_WINDOW_USAGE,
|
||||
|
||||
.source = { 's', CMD_FIND_WINDOW, CMD_FIND_DEFAULT_MARKED },
|
||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_swap_window_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_swap_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
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_group *sg_src, *sg_dst;
|
||||
struct winlink *wl_src, *wl_dst;
|
||||
struct window *w;
|
||||
struct window *w_src, *w_dst;
|
||||
|
||||
target_src = args_get(args, 's');
|
||||
if ((wl_src = cmd_find_window_marked(cmdq, target_src, &src)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
target_dst = args_get(args, 't');
|
||||
if ((wl_dst = cmd_find_window(cmdq, target_dst, &dst)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
wl_src = item->source.wl;
|
||||
src = item->source.s;
|
||||
sg_src = session_group_contains(src);
|
||||
|
||||
sg_src = session_group_find(src);
|
||||
sg_dst = session_group_find(dst);
|
||||
if (src != dst &&
|
||||
sg_src != NULL && sg_dst != NULL && sg_src == sg_dst) {
|
||||
cmdq_error(cmdq, "can't move window, sessions are grouped");
|
||||
wl_dst = item->target.wl;
|
||||
dst = item->target.s;
|
||||
sg_dst = session_group_contains(dst);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (wl_dst->window == wl_src->window)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
w = wl_dst->window;
|
||||
wl_dst->window = wl_src->window;
|
||||
wl_src->window = w;
|
||||
w_dst = wl_dst->window;
|
||||
TAILQ_REMOVE(&w_dst->winlinks, wl_dst, wentry);
|
||||
w_src = wl_src->window;
|
||||
TAILQ_REMOVE(&w_src->winlinks, wl_src, wentry);
|
||||
|
||||
if (!args_has(self->args, 'd')) {
|
||||
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')) {
|
||||
session_select(dst, wl_dst->idx);
|
||||
if (src != dst)
|
||||
session_select(src, wl_src->idx);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -27,107 +27,118 @@
|
||||
* Switch client to a different session.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_q *);
|
||||
static enum cmd_retval cmd_switch_client_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_switch_client_entry = {
|
||||
"switch-client", "switchc",
|
||||
"lc:Enpt:rT:", 0, 0,
|
||||
"[-Elnpr] [-c target-client] [-t target-session] [-T key-table]",
|
||||
CMD_READONLY,
|
||||
cmd_switch_client_exec
|
||||
.name = "switch-client",
|
||||
.alias = "switchc",
|
||||
|
||||
.args = { "lc:Enpt:rT:Z", 0, 0 },
|
||||
.usage = "[-ElnprZ] [-c target-client] [-t target-session] "
|
||||
"[-T key-table]",
|
||||
|
||||
/* -t is special */
|
||||
|
||||
.flags = CMD_READONLY,
|
||||
.exec = cmd_switch_client_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
const char *tflag = args_get(args, 't');
|
||||
enum cmd_find_type type;
|
||||
int flags;
|
||||
struct client *c;
|
||||
struct session *s = NULL;
|
||||
struct winlink *wl = NULL;
|
||||
struct window *w = NULL;
|
||||
struct window_pane *wp = NULL;
|
||||
const char *tflag, *tablename, *update;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
struct window *w;
|
||||
struct window_pane *wp;
|
||||
const char *tablename;
|
||||
struct key_table *table;
|
||||
|
||||
if ((c = cmd_find_client(cmdq, args_get(args, 'c'), 0)) == NULL)
|
||||
if ((c = cmd_find_client(item, args_get(args, 'c'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
if (args_has(args, 'r')) {
|
||||
if (c->flags & CLIENT_READONLY)
|
||||
c->flags &= ~CLIENT_READONLY;
|
||||
else
|
||||
c->flags |= CLIENT_READONLY;
|
||||
if (tflag != NULL && tflag[strcspn(tflag, ":.%")] != '\0') {
|
||||
type = CMD_FIND_PANE;
|
||||
flags = 0;
|
||||
} else {
|
||||
type = CMD_FIND_SESSION;
|
||||
flags = CMD_FIND_PREFER_UNATTACHED;
|
||||
}
|
||||
if (cmd_find_target(&item->target, item, tflag, type, flags) != 0)
|
||||
return (CMD_RETURN_ERROR);
|
||||
s = item->target.s;
|
||||
wl = item->target.wl;
|
||||
w = wl->window;
|
||||
wp = item->target.wp;
|
||||
|
||||
if (args_has(args, 'r'))
|
||||
c->flags ^= CLIENT_READONLY;
|
||||
|
||||
tablename = args_get(args, 'T');
|
||||
if (tablename != NULL) {
|
||||
table = key_bindings_get_table(tablename, 0);
|
||||
if (table == NULL) {
|
||||
cmdq_error(cmdq, "table %s doesn't exist", tablename);
|
||||
cmdq_error(item, "table %s doesn't exist", tablename);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
table->references++;
|
||||
key_bindings_unref_table(c->keytable);
|
||||
c->keytable = table;
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
tflag = args_get(args, 't');
|
||||
if (args_has(args, 'n')) {
|
||||
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);
|
||||
}
|
||||
} else if (args_has(args, 'p')) {
|
||||
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);
|
||||
}
|
||||
} else if (args_has(args, 'l')) {
|
||||
if (c->last_session != NULL && session_alive(c->last_session))
|
||||
s = c->last_session;
|
||||
else
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
if (tflag == NULL) {
|
||||
if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
} else if (tflag[strcspn(tflag, ":.")] != '\0') {
|
||||
if ((wl = cmd_find_pane(cmdq, tflag, &s, &wp)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
} else {
|
||||
if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
w = window_find_by_id_str(tflag);
|
||||
if (w == NULL) {
|
||||
wp = window_pane_find_by_id_str(tflag);
|
||||
if (wp != NULL)
|
||||
w = wp->window;
|
||||
}
|
||||
if (w != NULL)
|
||||
wl = winlink_find_by_window(&s->windows, w);
|
||||
}
|
||||
|
||||
if (cmdq->client == NULL)
|
||||
if (item->client == NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
if (wl != NULL && wp != NULL) {
|
||||
if (window_push_zoom(w, args_has(self->args, 'Z')))
|
||||
server_redraw_window(w);
|
||||
window_redraw_active_switch(w, wp);
|
||||
window_set_active_pane(w, wp, 1);
|
||||
if (window_pop_zoom(w))
|
||||
server_redraw_window(w);
|
||||
}
|
||||
if (wl != NULL) {
|
||||
if (wp != NULL)
|
||||
window_set_active_pane(wp->window, wp);
|
||||
session_set_current(s, wl);
|
||||
cmd_find_from_session(&item->shared->current, s, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (c != NULL && !args_has(args, 'E')) {
|
||||
update = options_get_string(&s->options, "update-environment");
|
||||
environ_update(update, &c->environ, &s->environ);
|
||||
}
|
||||
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->session = s;
|
||||
if (~item->shared->flags & CMDQ_SHARED_REPEAT)
|
||||
server_client_set_key_table(c, NULL);
|
||||
tty_update_client_offset(c);
|
||||
status_timer_start(c);
|
||||
notify_client("client-session-changed", c);
|
||||
session_update_activity(s, NULL);
|
||||
gettimeofday(&s->last_attached_time, NULL);
|
||||
|
||||
@@ -135,6 +146,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
server_check_unattached();
|
||||
server_redraw_client(c);
|
||||
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||
alerts_check_session(s);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -26,46 +26,45 @@
|
||||
* Unbind key from command.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmd_q *);
|
||||
enum cmd_retval cmd_unbind_key_mode_table(struct cmd *, struct cmd_q *, int);
|
||||
static enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmdq_item *);
|
||||
|
||||
const struct cmd_entry cmd_unbind_key_entry = {
|
||||
"unbind-key", "unbind",
|
||||
"acnt:T:", 0, 1,
|
||||
"[-acn] [-t mode-table] [-T key-table] key",
|
||||
0,
|
||||
cmd_unbind_key_exec
|
||||
.name = "unbind-key",
|
||||
.alias = "unbind",
|
||||
|
||||
.args = { "anT:", 0, 1 },
|
||||
.usage = "[-an] [-T key-table] key",
|
||||
|
||||
.flags = CMD_AFTERHOOK,
|
||||
.exec = cmd_unbind_key_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
int key;
|
||||
key_code key;
|
||||
const char *tablename;
|
||||
|
||||
if (!args_has(args, 'a')) {
|
||||
if (args->argc != 1) {
|
||||
cmdq_error(cmdq, "missing key");
|
||||
cmdq_error(item, "missing key");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
key = key_string_lookup_string(args->argv[0]);
|
||||
if (key == KEYC_NONE) {
|
||||
cmdq_error(cmdq, "unknown key: %s", args->argv[0]);
|
||||
if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
|
||||
cmdq_error(item, "unknown key: %s", args->argv[0]);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else {
|
||||
if (args->argc != 0) {
|
||||
cmdq_error(cmdq, "key given with -a");
|
||||
cmdq_error(item, "key given with -a");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
key = KEYC_NONE;
|
||||
key = KEYC_UNKNOWN;
|
||||
}
|
||||
|
||||
if (args_has(args, 't'))
|
||||
return (cmd_unbind_key_mode_table(self, cmdq, key));
|
||||
|
||||
if (key == KEYC_NONE) {
|
||||
if (key == KEYC_UNKNOWN) {
|
||||
tablename = args_get(args, 'T');
|
||||
if (tablename == NULL) {
|
||||
key_bindings_remove_table("root");
|
||||
@@ -73,7 +72,7 @@ cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
if (key_bindings_get_table(tablename, 0) == NULL) {
|
||||
cmdq_error(cmdq, "table %s doesn't exist", tablename);
|
||||
cmdq_error(item, "table %s doesn't exist", tablename);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
key_bindings_remove_table(tablename);
|
||||
@@ -83,7 +82,7 @@ cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
if (args_has(args, 'T')) {
|
||||
tablename = args_get(args, 'T');
|
||||
if (key_bindings_get_table(tablename, 0) == NULL) {
|
||||
cmdq_error(cmdq, "table %s doesn't exist", tablename);
|
||||
cmdq_error(item, "table %s doesn't exist", tablename);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else if (args_has(args, 'n'))
|
||||
@@ -93,35 +92,3 @@ cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
key_bindings_remove(tablename, key);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_unbind_key_mode_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);
|
||||
}
|
||||
|
||||
mtmp.key = key;
|
||||
mtmp.mode = !!args_has(args, 'c');
|
||||
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);
|
||||
}
|
||||
|
||||
156
cmd-wait-for.c
156
cmd-wait-for.c
@@ -1,7 +1,7 @@
|
||||
/* $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>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
@@ -28,14 +28,22 @@
|
||||
* 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 = {
|
||||
"wait-for", "wait",
|
||||
"LSU", 1, 1,
|
||||
"[-L|-S|-U] channel",
|
||||
0,
|
||||
cmd_wait_for_exec
|
||||
.name = "wait-for",
|
||||
.alias = "wait",
|
||||
|
||||
.args = { "LSU", 1, 1 },
|
||||
.usage = "[-L|-S|-U] channel",
|
||||
|
||||
.flags = 0,
|
||||
.exec = cmd_wait_for_exec
|
||||
};
|
||||
|
||||
struct wait_item {
|
||||
struct cmdq_item *item;
|
||||
TAILQ_ENTRY(wait_item) entry;
|
||||
};
|
||||
|
||||
struct wait_channel {
|
||||
@@ -43,37 +51,36 @@ struct wait_channel {
|
||||
int locked;
|
||||
int woken;
|
||||
|
||||
TAILQ_HEAD(, cmd_q) waiters;
|
||||
TAILQ_HEAD(, cmd_q) lockers;
|
||||
TAILQ_HEAD(, wait_item) waiters;
|
||||
TAILQ_HEAD(, wait_item) lockers;
|
||||
|
||||
RB_ENTRY(wait_channel) entry;
|
||||
};
|
||||
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 *);
|
||||
RB_PROTOTYPE(wait_channels, wait_channel, entry, wait_channel_cmp);
|
||||
RB_GENERATE(wait_channels, wait_channel, entry, wait_channel_cmp);
|
||||
static int wait_channel_cmp(struct wait_channel *, struct wait_channel *);
|
||||
RB_GENERATE_STATIC(wait_channels, wait_channel, entry, wait_channel_cmp);
|
||||
|
||||
int
|
||||
static int
|
||||
wait_channel_cmp(struct wait_channel *wc1, struct wait_channel *wc2)
|
||||
{
|
||||
return (strcmp(wc1->name, wc2->name));
|
||||
}
|
||||
|
||||
enum cmd_retval cmd_wait_for_signal(struct cmd_q *, const char *,
|
||||
struct wait_channel *);
|
||||
enum cmd_retval cmd_wait_for_wait(struct cmd_q *, const char *,
|
||||
struct wait_channel *);
|
||||
enum cmd_retval cmd_wait_for_lock(struct cmd_q *, const char *,
|
||||
struct wait_channel *);
|
||||
enum cmd_retval cmd_wait_for_unlock(struct cmd_q *, const char *,
|
||||
struct wait_channel *);
|
||||
static enum cmd_retval cmd_wait_for_signal(struct cmdq_item *, const char *,
|
||||
struct wait_channel *);
|
||||
static enum cmd_retval cmd_wait_for_wait(struct cmdq_item *, const char *,
|
||||
struct wait_channel *);
|
||||
static enum cmd_retval cmd_wait_for_lock(struct cmdq_item *, const char *,
|
||||
struct wait_channel *);
|
||||
static enum cmd_retval cmd_wait_for_unlock(struct cmdq_item *, const char *,
|
||||
struct wait_channel *);
|
||||
|
||||
struct wait_channel *cmd_wait_for_add(const char *);
|
||||
void cmd_wait_for_remove(struct wait_channel *wc);
|
||||
static struct wait_channel *cmd_wait_for_add(const char *);
|
||||
static void cmd_wait_for_remove(struct wait_channel *);
|
||||
|
||||
struct wait_channel *
|
||||
static struct wait_channel *
|
||||
cmd_wait_for_add(const char *name)
|
||||
{
|
||||
struct wait_channel *wc;
|
||||
@@ -94,7 +101,7 @@ cmd_wait_for_add(const char *name)
|
||||
return (wc);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
cmd_wait_for_remove(struct wait_channel *wc)
|
||||
{
|
||||
if (wc->locked)
|
||||
@@ -110,8 +117,8 @@ cmd_wait_for_remove(struct wait_channel *wc)
|
||||
free(wc);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_wait_for_exec(struct cmd *self, unused struct cmd_q *cmdq)
|
||||
static enum cmd_retval
|
||||
cmd_wait_for_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
const char *name = args->argv[0];
|
||||
@@ -121,19 +128,19 @@ cmd_wait_for_exec(struct cmd *self, unused struct cmd_q *cmdq)
|
||||
wc = RB_FIND(wait_channels, &wait_channels, &wc0);
|
||||
|
||||
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'))
|
||||
return (cmd_wait_for_lock(cmdq, name, wc));
|
||||
return (cmd_wait_for_lock(item, name, wc));
|
||||
if (args_has(args, 'U'))
|
||||
return (cmd_wait_for_unlock(cmdq, name, wc));
|
||||
return (cmd_wait_for_wait(cmdq, name, wc));
|
||||
return (cmd_wait_for_unlock(item, name, wc));
|
||||
return (cmd_wait_for_wait(item, name, wc));
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_wait_for_signal(unused struct cmd_q *cmdq, const char *name,
|
||||
static enum cmd_retval
|
||||
cmd_wait_for_signal(__unused struct cmdq_item *item, const char *name,
|
||||
struct wait_channel *wc)
|
||||
{
|
||||
struct cmd_q *wq, *wq1;
|
||||
struct wait_item *wi, *wi1;
|
||||
|
||||
if (wc == NULL)
|
||||
wc = cmd_wait_for_add(name);
|
||||
@@ -145,24 +152,26 @@ cmd_wait_for_signal(unused struct cmd_q *cmdq, const char *name,
|
||||
}
|
||||
log_debug("signal wait channel %s, with waiters", wc->name);
|
||||
|
||||
TAILQ_FOREACH_SAFE(wq, &wc->waiters, waitentry, wq1) {
|
||||
TAILQ_REMOVE(&wc->waiters, wq, waitentry);
|
||||
if (!cmdq_free(wq))
|
||||
cmdq_continue(wq);
|
||||
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
|
||||
cmdq_continue(wi->item);
|
||||
|
||||
TAILQ_REMOVE(&wc->waiters, wi, entry);
|
||||
free(wi);
|
||||
}
|
||||
|
||||
cmd_wait_for_remove(wc);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_wait_for_wait(struct cmd_q *cmdq, const char *name,
|
||||
static enum cmd_retval
|
||||
cmd_wait_for_wait(struct cmdq_item *item, const char *name,
|
||||
struct wait_channel *wc)
|
||||
{
|
||||
struct client *c = cmdq->client;
|
||||
struct client *c = item->client;
|
||||
struct wait_item *wi;
|
||||
|
||||
if (c == NULL || c->session != NULL) {
|
||||
cmdq_error(cmdq, "not able to wait");
|
||||
if (c == NULL) {
|
||||
cmdq_error(item, "not able to wait");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
@@ -170,25 +179,27 @@ cmd_wait_for_wait(struct cmd_q *cmdq, const char *name,
|
||||
wc = cmd_wait_for_add(name);
|
||||
|
||||
if (wc->woken) {
|
||||
log_debug("wait channel %s already woken (client %d)", wc->name,
|
||||
c->tty.fd);
|
||||
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 (client %d)", wc->name, c->tty.fd);
|
||||
log_debug("wait channel %s not woken (%p)", wc->name, c);
|
||||
|
||||
TAILQ_INSERT_TAIL(&wc->waiters, cmdq, waitentry);
|
||||
cmdq->references++;
|
||||
wi = xcalloc(1, sizeof *wi);
|
||||
wi->item = item;
|
||||
TAILQ_INSERT_TAIL(&wc->waiters, wi, entry);
|
||||
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_wait_for_lock(struct cmd_q *cmdq, const char *name,
|
||||
static enum cmd_retval
|
||||
cmd_wait_for_lock(struct cmdq_item *item, const char *name,
|
||||
struct wait_channel *wc)
|
||||
{
|
||||
if (cmdq->client == NULL || cmdq->client->session != NULL) {
|
||||
cmdq_error(cmdq, "not able to lock");
|
||||
struct wait_item *wi;
|
||||
|
||||
if (item->client == NULL) {
|
||||
cmdq_error(item, "not able to lock");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
@@ -196,8 +207,9 @@ cmd_wait_for_lock(struct cmd_q *cmdq, const char *name,
|
||||
wc = cmd_wait_for_add(name);
|
||||
|
||||
if (wc->locked) {
|
||||
TAILQ_INSERT_TAIL(&wc->lockers, cmdq, waitentry);
|
||||
cmdq->references++;
|
||||
wi = xcalloc(1, sizeof *wi);
|
||||
wi->item = item;
|
||||
TAILQ_INSERT_TAIL(&wc->lockers, wi, entry);
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
wc->locked = 1;
|
||||
@@ -205,21 +217,21 @@ cmd_wait_for_lock(struct cmd_q *cmdq, const char *name,
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_wait_for_unlock(struct cmd_q *cmdq, const char *name,
|
||||
static enum cmd_retval
|
||||
cmd_wait_for_unlock(struct cmdq_item *item, const char *name,
|
||||
struct wait_channel *wc)
|
||||
{
|
||||
struct cmd_q *wq;
|
||||
struct wait_item *wi;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if ((wq = TAILQ_FIRST(&wc->lockers)) != NULL) {
|
||||
TAILQ_REMOVE(&wc->lockers, wq, waitentry);
|
||||
if (!cmdq_free(wq))
|
||||
cmdq_continue(wq);
|
||||
if ((wi = TAILQ_FIRST(&wc->lockers)) != NULL) {
|
||||
cmdq_continue(wi->item);
|
||||
TAILQ_REMOVE(&wc->lockers, wi, entry);
|
||||
free(wi);
|
||||
} else {
|
||||
wc->locked = 0;
|
||||
cmd_wait_for_remove(wc);
|
||||
@@ -232,19 +244,19 @@ void
|
||||
cmd_wait_for_flush(void)
|
||||
{
|
||||
struct wait_channel *wc, *wc1;
|
||||
struct cmd_q *wq, *wq1;
|
||||
struct wait_item *wi, *wi1;
|
||||
|
||||
RB_FOREACH_SAFE(wc, wait_channels, &wait_channels, wc1) {
|
||||
TAILQ_FOREACH_SAFE(wq, &wc->waiters, waitentry, wq1) {
|
||||
TAILQ_REMOVE(&wc->waiters, wq, waitentry);
|
||||
if (!cmdq_free(wq))
|
||||
cmdq_continue(wq);
|
||||
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
|
||||
cmdq_continue(wi->item);
|
||||
TAILQ_REMOVE(&wc->waiters, wi, entry);
|
||||
free(wi);
|
||||
}
|
||||
wc->woken = 1;
|
||||
TAILQ_FOREACH_SAFE(wq, &wc->lockers, waitentry, wq1) {
|
||||
TAILQ_REMOVE(&wc->lockers, wq, waitentry);
|
||||
if (!cmdq_free(wq))
|
||||
cmdq_continue(wq);
|
||||
TAILQ_FOREACH_SAFE(wi, &wc->lockers, entry, wi1) {
|
||||
cmdq_continue(wi->item);
|
||||
TAILQ_REMOVE(&wc->lockers, wi, entry);
|
||||
free(wi);
|
||||
}
|
||||
wc->locked = 0;
|
||||
cmd_wait_for_remove(wc);
|
||||
|
||||
354
cmd.c
354
cmd.c
@@ -1,7 +1,7 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -33,9 +33,7 @@ extern const struct cmd_entry cmd_break_pane_entry;
|
||||
extern const struct cmd_entry cmd_capture_pane_entry;
|
||||
extern const struct cmd_entry cmd_choose_buffer_entry;
|
||||
extern const struct cmd_entry cmd_choose_client_entry;
|
||||
extern const struct cmd_entry cmd_choose_session_entry;
|
||||
extern const struct cmd_entry cmd_choose_tree_entry;
|
||||
extern const struct cmd_entry cmd_choose_window_entry;
|
||||
extern const struct cmd_entry cmd_clear_history_entry;
|
||||
extern const struct cmd_entry cmd_clock_mode_entry;
|
||||
extern const struct cmd_entry cmd_command_prompt_entry;
|
||||
@@ -43,6 +41,7 @@ extern const struct cmd_entry cmd_confirm_before_entry;
|
||||
extern const struct cmd_entry cmd_copy_mode_entry;
|
||||
extern const struct cmd_entry cmd_delete_buffer_entry;
|
||||
extern const struct cmd_entry cmd_detach_client_entry;
|
||||
extern const struct cmd_entry cmd_display_menu_entry;
|
||||
extern const struct cmd_entry cmd_display_message_entry;
|
||||
extern const struct cmd_entry cmd_display_panes_entry;
|
||||
extern const struct cmd_entry cmd_down_pane_entry;
|
||||
@@ -82,6 +81,7 @@ extern const struct cmd_entry cmd_refresh_client_entry;
|
||||
extern const struct cmd_entry cmd_rename_session_entry;
|
||||
extern const struct cmd_entry cmd_rename_window_entry;
|
||||
extern const struct cmd_entry cmd_resize_pane_entry;
|
||||
extern const struct cmd_entry cmd_resize_window_entry;
|
||||
extern const struct cmd_entry cmd_respawn_pane_entry;
|
||||
extern const struct cmd_entry cmd_respawn_window_entry;
|
||||
extern const struct cmd_entry cmd_rotate_window_entry;
|
||||
@@ -92,13 +92,14 @@ extern const struct cmd_entry cmd_select_pane_entry;
|
||||
extern const struct cmd_entry cmd_select_window_entry;
|
||||
extern const struct cmd_entry cmd_send_keys_entry;
|
||||
extern const struct cmd_entry cmd_send_prefix_entry;
|
||||
extern const struct cmd_entry cmd_server_info_entry;
|
||||
extern const struct cmd_entry cmd_set_buffer_entry;
|
||||
extern const struct cmd_entry cmd_set_environment_entry;
|
||||
extern const struct cmd_entry cmd_set_hook_entry;
|
||||
extern const struct cmd_entry cmd_set_option_entry;
|
||||
extern const struct cmd_entry cmd_set_window_option_entry;
|
||||
extern const struct cmd_entry cmd_show_buffer_entry;
|
||||
extern const struct cmd_entry cmd_show_environment_entry;
|
||||
extern const struct cmd_entry cmd_show_hooks_entry;
|
||||
extern const struct cmd_entry cmd_show_messages_entry;
|
||||
extern const struct cmd_entry cmd_show_options_entry;
|
||||
extern const struct cmd_entry cmd_show_window_options_entry;
|
||||
@@ -121,9 +122,7 @@ const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_capture_pane_entry,
|
||||
&cmd_choose_buffer_entry,
|
||||
&cmd_choose_client_entry,
|
||||
&cmd_choose_session_entry,
|
||||
&cmd_choose_tree_entry,
|
||||
&cmd_choose_window_entry,
|
||||
&cmd_clear_history_entry,
|
||||
&cmd_clock_mode_entry,
|
||||
&cmd_command_prompt_entry,
|
||||
@@ -131,6 +130,7 @@ const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_copy_mode_entry,
|
||||
&cmd_delete_buffer_entry,
|
||||
&cmd_detach_client_entry,
|
||||
&cmd_display_menu_entry,
|
||||
&cmd_display_message_entry,
|
||||
&cmd_display_panes_entry,
|
||||
&cmd_find_window_entry,
|
||||
@@ -169,6 +169,7 @@ const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_rename_session_entry,
|
||||
&cmd_rename_window_entry,
|
||||
&cmd_resize_pane_entry,
|
||||
&cmd_resize_window_entry,
|
||||
&cmd_respawn_pane_entry,
|
||||
&cmd_respawn_window_entry,
|
||||
&cmd_rotate_window_entry,
|
||||
@@ -179,13 +180,14 @@ const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_select_window_entry,
|
||||
&cmd_send_keys_entry,
|
||||
&cmd_send_prefix_entry,
|
||||
&cmd_server_info_entry,
|
||||
&cmd_set_buffer_entry,
|
||||
&cmd_set_environment_entry,
|
||||
&cmd_set_hook_entry,
|
||||
&cmd_set_option_entry,
|
||||
&cmd_set_window_option_entry,
|
||||
&cmd_show_buffer_entry,
|
||||
&cmd_show_environment_entry,
|
||||
&cmd_show_hooks_entry,
|
||||
&cmd_show_messages_entry,
|
||||
&cmd_show_options_entry,
|
||||
&cmd_show_window_options_entry,
|
||||
@@ -202,6 +204,47 @@ const struct cmd_entry *cmd_table[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static u_int cmd_list_next_group = 1;
|
||||
|
||||
void printflike(3, 4)
|
||||
cmd_log_argv(int argc, char **argv, const char *fmt, ...)
|
||||
{
|
||||
char *prefix;
|
||||
va_list ap;
|
||||
int i;
|
||||
|
||||
va_start(ap, fmt);
|
||||
xvasprintf(&prefix, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
log_debug("%s: argv[%d]=%s", prefix, i, argv[i]);
|
||||
free(prefix);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_prepend_argv(int *argc, char ***argv, char *arg)
|
||||
{
|
||||
char **new_argv;
|
||||
int i;
|
||||
|
||||
new_argv = xreallocarray(NULL, (*argc) + 1, sizeof *new_argv);
|
||||
new_argv[0] = xstrdup(arg);
|
||||
for (i = 0; i < *argc; i++)
|
||||
new_argv[1 + i] = (*argv)[i];
|
||||
|
||||
free(*argv);
|
||||
*argv = new_argv;
|
||||
(*argc)++;
|
||||
}
|
||||
|
||||
void
|
||||
cmd_append_argv(int *argc, char ***argv, char *arg)
|
||||
{
|
||||
*argv = xreallocarray(*argv, (*argc) + 1, sizeof **argv);
|
||||
(*argv)[(*argc)++] = xstrdup(arg);
|
||||
}
|
||||
|
||||
int
|
||||
cmd_pack_argv(int argc, char **argv, char *buf, size_t len)
|
||||
{
|
||||
@@ -210,6 +253,7 @@ cmd_pack_argv(int argc, char **argv, char *buf, size_t len)
|
||||
|
||||
if (argc == 0)
|
||||
return (0);
|
||||
cmd_log_argv(argc, argv, "%s", __func__);
|
||||
|
||||
*buf = '\0';
|
||||
for (i = 0; i < argc; i++) {
|
||||
@@ -242,9 +286,11 @@ cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv)
|
||||
|
||||
arglen = strlen(buf) + 1;
|
||||
(*argv)[i] = xstrdup(buf);
|
||||
|
||||
buf += arglen;
|
||||
len -= arglen;
|
||||
}
|
||||
cmd_log_argv(argc, *argv, "%s", __func__);
|
||||
|
||||
return (0);
|
||||
}
|
||||
@@ -303,53 +349,110 @@ cmd_stringify_argv(int argc, char **argv)
|
||||
return (buf);
|
||||
}
|
||||
|
||||
struct cmd *
|
||||
cmd_parse(int argc, char **argv, const char *file, u_int line, char **cause)
|
||||
char *
|
||||
cmd_get_alias(const char *name)
|
||||
{
|
||||
const struct cmd_entry **entryp, *entry;
|
||||
struct cmd *cmd;
|
||||
struct args *args;
|
||||
char s[BUFSIZ];
|
||||
int ambiguous = 0;
|
||||
struct options_entry *o;
|
||||
struct options_array_item *a;
|
||||
union options_value *ov;
|
||||
size_t wanted, n;
|
||||
const char *equals;
|
||||
|
||||
*cause = NULL;
|
||||
if (argc == 0) {
|
||||
xasprintf(cause, "no command");
|
||||
o = options_get_only(global_options, "command-alias");
|
||||
if (o == NULL)
|
||||
return (NULL);
|
||||
}
|
||||
wanted = strlen(name);
|
||||
|
||||
entry = NULL;
|
||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
||||
if ((*entryp)->alias != NULL &&
|
||||
strcmp((*entryp)->alias, argv[0]) == 0) {
|
||||
a = options_array_first(o);
|
||||
while (a != NULL) {
|
||||
ov = options_array_item_value(a);
|
||||
|
||||
equals = strchr(ov->string, '=');
|
||||
if (equals != NULL) {
|
||||
n = equals - ov->string;
|
||||
if (n == wanted && strncmp(name, ov->string, n) == 0)
|
||||
return (xstrdup(equals + 1));
|
||||
}
|
||||
|
||||
a = options_array_next(a);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static const struct cmd_entry *
|
||||
cmd_find(const char *name, char **cause)
|
||||
{
|
||||
const struct cmd_entry **loop, *entry, *found = NULL;
|
||||
int ambiguous;
|
||||
char s[8192];
|
||||
|
||||
ambiguous = 0;
|
||||
for (loop = cmd_table; *loop != NULL; loop++) {
|
||||
entry = *loop;
|
||||
if (entry->alias != NULL && strcmp(entry->alias, name) == 0) {
|
||||
ambiguous = 0;
|
||||
entry = *entryp;
|
||||
found = entry;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strncmp((*entryp)->name, argv[0], strlen(argv[0])) != 0)
|
||||
if (strncmp(entry->name, name, strlen(name)) != 0)
|
||||
continue;
|
||||
if (entry != NULL)
|
||||
if (found != NULL)
|
||||
ambiguous = 1;
|
||||
entry = *entryp;
|
||||
found = entry;
|
||||
|
||||
/* Bail now if an exact match. */
|
||||
if (strcmp(entry->name, argv[0]) == 0)
|
||||
if (strcmp(entry->name, name) == 0)
|
||||
break;
|
||||
}
|
||||
if (ambiguous)
|
||||
goto ambiguous;
|
||||
if (entry == NULL) {
|
||||
xasprintf(cause, "unknown command: %s", argv[0]);
|
||||
if (found == NULL) {
|
||||
xasprintf(cause, "unknown command: %s", name);
|
||||
return (NULL);
|
||||
}
|
||||
return (found);
|
||||
|
||||
args = args_parse(entry->args_template, argc, argv);
|
||||
ambiguous:
|
||||
*s = '\0';
|
||||
for (loop = cmd_table; *loop != NULL; loop++) {
|
||||
entry = *loop;
|
||||
if (strncmp(entry->name, name, strlen(name)) != 0)
|
||||
continue;
|
||||
if (strlcat(s, entry->name, sizeof s) >= sizeof s)
|
||||
break;
|
||||
if (strlcat(s, ", ", sizeof s) >= sizeof s)
|
||||
break;
|
||||
}
|
||||
s[strlen(s) - 2] = '\0';
|
||||
xasprintf(cause, "ambiguous command: %s, could be: %s", name, s);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
struct cmd *
|
||||
cmd_parse(int argc, char **argv, const char *file, u_int line, char **cause)
|
||||
{
|
||||
const struct cmd_entry *entry;
|
||||
const char *name;
|
||||
struct cmd *cmd;
|
||||
struct args *args;
|
||||
|
||||
if (argc == 0) {
|
||||
xasprintf(cause, "no command");
|
||||
return (NULL);
|
||||
}
|
||||
name = argv[0];
|
||||
|
||||
entry = cmd_find(name, cause);
|
||||
if (entry == NULL)
|
||||
return (NULL);
|
||||
cmd_log_argv(argc, argv, "%s: %s", __func__, entry->name);
|
||||
|
||||
args = args_parse(entry->args.template, argc, argv);
|
||||
if (args == NULL)
|
||||
goto usage;
|
||||
if (entry->args_lower != -1 && args->argc < entry->args_lower)
|
||||
if (entry->args.lower != -1 && args->argc < entry->args.lower)
|
||||
goto usage;
|
||||
if (entry->args_upper != -1 && args->argc > entry->args_upper)
|
||||
if (entry->args.upper != -1 && args->argc > entry->args.upper)
|
||||
goto usage;
|
||||
|
||||
cmd = xcalloc(1, sizeof *cmd);
|
||||
@@ -360,21 +463,11 @@ cmd_parse(int argc, char **argv, const char *file, u_int line, char **cause)
|
||||
cmd->file = xstrdup(file);
|
||||
cmd->line = line;
|
||||
|
||||
return (cmd);
|
||||
cmd->alias = NULL;
|
||||
cmd->argc = argc;
|
||||
cmd->argv = cmd_copy_argv(argc, argv);
|
||||
|
||||
ambiguous:
|
||||
*s = '\0';
|
||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
||||
if (strncmp((*entryp)->name, argv[0], strlen(argv[0])) != 0)
|
||||
continue;
|
||||
if (strlcat(s, (*entryp)->name, sizeof s) >= sizeof s)
|
||||
break;
|
||||
if (strlcat(s, ", ", sizeof s) >= sizeof s)
|
||||
break;
|
||||
}
|
||||
s[strlen(s) - 2] = '\0';
|
||||
xasprintf(cause, "ambiguous command: %s, could be: %s", argv[0], s);
|
||||
return (NULL);
|
||||
return (cmd);
|
||||
|
||||
usage:
|
||||
if (args != NULL)
|
||||
@@ -383,21 +476,108 @@ usage:
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
size_t
|
||||
cmd_print(struct cmd *cmd, char *buf, size_t len)
|
||||
void
|
||||
cmd_free(struct cmd *cmd)
|
||||
{
|
||||
size_t off, used;
|
||||
free(cmd->alias);
|
||||
cmd_free_argv(cmd->argc, cmd->argv);
|
||||
|
||||
off = xsnprintf(buf, len, "%s ", cmd->entry->name);
|
||||
if (off + 1 < len) {
|
||||
used = args_print(cmd->args, buf + off, len - off - 1);
|
||||
if (used == 0)
|
||||
off--;
|
||||
else
|
||||
off += used;
|
||||
buf[off] = '\0';
|
||||
free(cmd->file);
|
||||
|
||||
args_free(cmd->args);
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
char *
|
||||
cmd_print(struct cmd *cmd)
|
||||
{
|
||||
char *out, *s;
|
||||
|
||||
s = args_print(cmd->args);
|
||||
if (*s != '\0')
|
||||
xasprintf(&out, "%s %s", cmd->entry->name, s);
|
||||
else
|
||||
out = xstrdup(cmd->entry->name);
|
||||
free(s);
|
||||
|
||||
return (out);
|
||||
}
|
||||
|
||||
struct cmd_list *
|
||||
cmd_list_new(void)
|
||||
{
|
||||
struct cmd_list *cmdlist;
|
||||
|
||||
cmdlist = xcalloc(1, sizeof *cmdlist);
|
||||
cmdlist->references = 1;
|
||||
cmdlist->group = cmd_list_next_group++;
|
||||
TAILQ_INIT(&cmdlist->list);
|
||||
return (cmdlist);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_list_append(struct cmd_list *cmdlist, struct cmd *cmd)
|
||||
{
|
||||
cmd->group = cmdlist->group;
|
||||
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_list_move(struct cmd_list *cmdlist, struct cmd_list *from)
|
||||
{
|
||||
struct cmd *cmd, *cmd1;
|
||||
|
||||
TAILQ_FOREACH_SAFE(cmd, &from->list, qentry, cmd1) {
|
||||
TAILQ_REMOVE(&from->list, cmd, qentry);
|
||||
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
||||
}
|
||||
return (off);
|
||||
cmdlist->group = cmd_list_next_group++;
|
||||
}
|
||||
|
||||
void
|
||||
cmd_list_free(struct cmd_list *cmdlist)
|
||||
{
|
||||
struct cmd *cmd, *cmd1;
|
||||
|
||||
if (--cmdlist->references != 0)
|
||||
return;
|
||||
|
||||
TAILQ_FOREACH_SAFE(cmd, &cmdlist->list, qentry, cmd1) {
|
||||
TAILQ_REMOVE(&cmdlist->list, cmd, qentry);
|
||||
cmd_free(cmd);
|
||||
}
|
||||
|
||||
free(cmdlist);
|
||||
}
|
||||
|
||||
char *
|
||||
cmd_list_print(struct cmd_list *cmdlist, int escaped)
|
||||
{
|
||||
struct cmd *cmd;
|
||||
char *buf, *this;
|
||||
size_t len;
|
||||
|
||||
len = 1;
|
||||
buf = xcalloc(1, len);
|
||||
|
||||
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||
this = cmd_print(cmd);
|
||||
|
||||
len += strlen(this) + 4;
|
||||
buf = xrealloc(buf, len);
|
||||
|
||||
strlcat(buf, this, len);
|
||||
if (TAILQ_NEXT(cmd, qentry) != NULL) {
|
||||
if (escaped)
|
||||
strlcat(buf, " \\; ", len);
|
||||
else
|
||||
strlcat(buf, " ; ", len);
|
||||
}
|
||||
|
||||
free(this);
|
||||
}
|
||||
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/* Adjust current mouse position for a pane. */
|
||||
@@ -408,25 +588,26 @@ cmd_mouse_at(struct window_pane *wp, struct mouse_event *m, u_int *xp,
|
||||
u_int x, y;
|
||||
|
||||
if (last) {
|
||||
x = m->lx;
|
||||
y = m->ly;
|
||||
x = m->lx + m->ox;
|
||||
y = m->ly + m->oy;
|
||||
} else {
|
||||
x = m->x;
|
||||
y = m->y;
|
||||
x = m->x + m->ox;
|
||||
y = m->y + m->oy;
|
||||
}
|
||||
log_debug("%s: x=%u, y=%u%s", __func__, x, y, last ? " (last)" : "");
|
||||
|
||||
if (m->statusat == 0 && y > 0)
|
||||
y--;
|
||||
else if (m->statusat > 0 && y >= (u_int)m->statusat)
|
||||
y = m->statusat - 1;
|
||||
if (m->statusat == 0 && y >= m->statuslines)
|
||||
y -= m->statuslines;
|
||||
|
||||
if (x < wp->xoff || x >= wp->xoff + wp->sx)
|
||||
return (-1);
|
||||
if (y < wp->yoff || y >= wp->yoff + wp->sy)
|
||||
return (-1);
|
||||
|
||||
*xp = x - wp->xoff;
|
||||
*yp = y - wp->yoff;
|
||||
if (xp != NULL)
|
||||
*xp = x - wp->xoff;
|
||||
if (yp != NULL)
|
||||
*yp = y - wp->yoff;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -436,17 +617,22 @@ cmd_mouse_window(struct mouse_event *m, struct session **sp)
|
||||
{
|
||||
struct session *s;
|
||||
struct window *w;
|
||||
struct winlink *wl;
|
||||
|
||||
if (!m->valid || m->s == -1 || m->w == -1)
|
||||
if (!m->valid)
|
||||
return (NULL);
|
||||
if ((s = session_find_by_id(m->s)) == NULL)
|
||||
if (m->s == -1 || (s = session_find_by_id(m->s)) == NULL)
|
||||
return (NULL);
|
||||
if ((w = window_find_by_id(m->w)) == NULL)
|
||||
return (NULL);
|
||||
|
||||
if (m->w == -1)
|
||||
wl = s->curw;
|
||||
else {
|
||||
if ((w = window_find_by_id(m->w)) == NULL)
|
||||
return (NULL);
|
||||
wl = winlink_find_by_window(&s->windows, w);
|
||||
}
|
||||
if (sp != NULL)
|
||||
*sp = s;
|
||||
return (winlink_find_by_window(&s->windows, w));
|
||||
return (wl);
|
||||
}
|
||||
|
||||
/* Get current mouse pane if any. */
|
||||
@@ -474,8 +660,8 @@ char *
|
||||
cmd_template_replace(const char *template, const char *s, int idx)
|
||||
{
|
||||
char ch, *buf;
|
||||
const char *ptr;
|
||||
int replaced;
|
||||
const char *ptr, *cp, quote[] = "\"\\$;~";
|
||||
int replaced, quoted;
|
||||
size_t len;
|
||||
|
||||
if (strchr(template, '%') == NULL)
|
||||
@@ -497,9 +683,17 @@ cmd_template_replace(const char *template, const char *s, int idx)
|
||||
}
|
||||
ptr++;
|
||||
|
||||
len += strlen(s);
|
||||
buf = xrealloc(buf, len + 1);
|
||||
strlcat(buf, s, len + 1);
|
||||
quoted = (*ptr == '%');
|
||||
if (quoted)
|
||||
ptr++;
|
||||
|
||||
buf = xrealloc(buf, len + (strlen(s) * 3) + 1);
|
||||
for (cp = s; *cp != '\0'; cp++) {
|
||||
if (quoted && strchr(quote, *cp) != NULL)
|
||||
buf[len++] = '\\';
|
||||
buf[len++] = *cp;
|
||||
}
|
||||
buf[len] = '\0';
|
||||
continue;
|
||||
}
|
||||
buf = xrealloc(buf, len + 2);
|
||||
|
||||
486
colour.c
486
colour.c
@@ -1,7 +1,8 @@
|
||||
/* $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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -24,334 +25,83 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Colour to string conversion functions. Bit 8 of the colour means it is one
|
||||
* of the 256 colour palette.
|
||||
*/
|
||||
|
||||
struct colour_rgb {
|
||||
u_char i;
|
||||
u_char r;
|
||||
u_char g;
|
||||
u_char b;
|
||||
};
|
||||
|
||||
const struct colour_rgb colour_from_256[] = {
|
||||
{ 0, 0x00, 0x00, 0x00 }, { 1, 0x00, 0x00, 0x5f },
|
||||
{ 2, 0x00, 0x00, 0x87 }, { 3, 0x00, 0x00, 0xaf },
|
||||
{ 4, 0x00, 0x00, 0xd7 }, { 5, 0x00, 0x00, 0xff },
|
||||
{ 6, 0x00, 0x5f, 0x00 }, { 7, 0x00, 0x5f, 0x5f },
|
||||
{ 8, 0x00, 0x5f, 0x87 }, { 9, 0x00, 0x5f, 0xaf },
|
||||
{ 10, 0x00, 0x5f, 0xd7 }, { 11, 0x00, 0x5f, 0xff },
|
||||
{ 12, 0x00, 0x87, 0x00 }, { 13, 0x00, 0x87, 0x5f },
|
||||
{ 14, 0x00, 0x87, 0x87 }, { 15, 0x00, 0x87, 0xaf },
|
||||
{ 16, 0x00, 0x87, 0xd7 }, { 17, 0x00, 0x87, 0xff },
|
||||
{ 18, 0x00, 0xaf, 0x00 }, { 19, 0x00, 0xaf, 0x5f },
|
||||
{ 20, 0x00, 0xaf, 0x87 }, { 21, 0x00, 0xaf, 0xaf },
|
||||
{ 22, 0x00, 0xaf, 0xd7 }, { 23, 0x00, 0xaf, 0xff },
|
||||
{ 24, 0x00, 0xd7, 0x00 }, { 25, 0x00, 0xd7, 0x5f },
|
||||
{ 26, 0x00, 0xd7, 0x87 }, { 27, 0x00, 0xd7, 0xaf },
|
||||
{ 28, 0x00, 0xd7, 0xd7 }, { 29, 0x00, 0xd7, 0xff },
|
||||
{ 30, 0x00, 0xff, 0x00 }, { 31, 0x00, 0xff, 0x5f },
|
||||
{ 32, 0x00, 0xff, 0x87 }, { 33, 0x00, 0xff, 0xaf },
|
||||
{ 34, 0x00, 0xff, 0xd7 }, { 35, 0x00, 0xff, 0xff },
|
||||
{ 36, 0x5f, 0x00, 0x00 }, { 37, 0x5f, 0x00, 0x5f },
|
||||
{ 38, 0x5f, 0x00, 0x87 }, { 39, 0x5f, 0x00, 0xaf },
|
||||
{ 40, 0x5f, 0x00, 0xd7 }, { 41, 0x5f, 0x00, 0xff },
|
||||
{ 42, 0x5f, 0x5f, 0x00 }, { 43, 0x5f, 0x5f, 0x5f },
|
||||
{ 44, 0x5f, 0x5f, 0x87 }, { 45, 0x5f, 0x5f, 0xaf },
|
||||
{ 46, 0x5f, 0x5f, 0xd7 }, { 47, 0x5f, 0x5f, 0xff },
|
||||
{ 48, 0x5f, 0x87, 0x00 }, { 49, 0x5f, 0x87, 0x5f },
|
||||
{ 50, 0x5f, 0x87, 0x87 }, { 51, 0x5f, 0x87, 0xaf },
|
||||
{ 52, 0x5f, 0x87, 0xd7 }, { 53, 0x5f, 0x87, 0xff },
|
||||
{ 54, 0x5f, 0xaf, 0x00 }, { 55, 0x5f, 0xaf, 0x5f },
|
||||
{ 56, 0x5f, 0xaf, 0x87 }, { 57, 0x5f, 0xaf, 0xaf },
|
||||
{ 58, 0x5f, 0xaf, 0xd7 }, { 59, 0x5f, 0xaf, 0xff },
|
||||
{ 60, 0x5f, 0xd7, 0x00 }, { 61, 0x5f, 0xd7, 0x5f },
|
||||
{ 62, 0x5f, 0xd7, 0x87 }, { 63, 0x5f, 0xd7, 0xaf },
|
||||
{ 64, 0x5f, 0xd7, 0xd7 }, { 65, 0x5f, 0xd7, 0xff },
|
||||
{ 66, 0x5f, 0xff, 0x00 }, { 67, 0x5f, 0xff, 0x5f },
|
||||
{ 68, 0x5f, 0xff, 0x87 }, { 69, 0x5f, 0xff, 0xaf },
|
||||
{ 70, 0x5f, 0xff, 0xd7 }, { 71, 0x5f, 0xff, 0xff },
|
||||
{ 72, 0x87, 0x00, 0x00 }, { 73, 0x87, 0x00, 0x5f },
|
||||
{ 74, 0x87, 0x00, 0x87 }, { 75, 0x87, 0x00, 0xaf },
|
||||
{ 76, 0x87, 0x00, 0xd7 }, { 77, 0x87, 0x00, 0xff },
|
||||
{ 78, 0x87, 0x5f, 0x00 }, { 79, 0x87, 0x5f, 0x5f },
|
||||
{ 80, 0x87, 0x5f, 0x87 }, { 81, 0x87, 0x5f, 0xaf },
|
||||
{ 82, 0x87, 0x5f, 0xd7 }, { 83, 0x87, 0x5f, 0xff },
|
||||
{ 84, 0x87, 0x87, 0x00 }, { 85, 0x87, 0x87, 0x5f },
|
||||
{ 86, 0x87, 0x87, 0x87 }, { 87, 0x87, 0x87, 0xaf },
|
||||
{ 88, 0x87, 0x87, 0xd7 }, { 89, 0x87, 0x87, 0xff },
|
||||
{ 90, 0x87, 0xaf, 0x00 }, { 91, 0x87, 0xaf, 0x5f },
|
||||
{ 92, 0x87, 0xaf, 0x87 }, { 93, 0x87, 0xaf, 0xaf },
|
||||
{ 94, 0x87, 0xaf, 0xd7 }, { 95, 0x87, 0xaf, 0xff },
|
||||
{ 96, 0x87, 0xd7, 0x00 }, { 97, 0x87, 0xd7, 0x5f },
|
||||
{ 98, 0x87, 0xd7, 0x87 }, { 99, 0x87, 0xd7, 0xaf },
|
||||
{ 100, 0x87, 0xd7, 0xd7 }, { 101, 0x87, 0xd7, 0xff },
|
||||
{ 102, 0x87, 0xff, 0x00 }, { 103, 0x87, 0xff, 0x5f },
|
||||
{ 104, 0x87, 0xff, 0x87 }, { 105, 0x87, 0xff, 0xaf },
|
||||
{ 106, 0x87, 0xff, 0xd7 }, { 107, 0x87, 0xff, 0xff },
|
||||
{ 108, 0xaf, 0x00, 0x00 }, { 109, 0xaf, 0x00, 0x5f },
|
||||
{ 110, 0xaf, 0x00, 0x87 }, { 111, 0xaf, 0x00, 0xaf },
|
||||
{ 112, 0xaf, 0x00, 0xd7 }, { 113, 0xaf, 0x00, 0xff },
|
||||
{ 114, 0xaf, 0x5f, 0x00 }, { 115, 0xaf, 0x5f, 0x5f },
|
||||
{ 116, 0xaf, 0x5f, 0x87 }, { 117, 0xaf, 0x5f, 0xaf },
|
||||
{ 118, 0xaf, 0x5f, 0xd7 }, { 119, 0xaf, 0x5f, 0xff },
|
||||
{ 120, 0xaf, 0x87, 0x00 }, { 121, 0xaf, 0x87, 0x5f },
|
||||
{ 122, 0xaf, 0x87, 0x87 }, { 123, 0xaf, 0x87, 0xaf },
|
||||
{ 124, 0xaf, 0x87, 0xd7 }, { 125, 0xaf, 0x87, 0xff },
|
||||
{ 126, 0xaf, 0xaf, 0x00 }, { 127, 0xaf, 0xaf, 0x5f },
|
||||
{ 128, 0xaf, 0xaf, 0x87 }, { 129, 0xaf, 0xaf, 0xaf },
|
||||
{ 130, 0xaf, 0xaf, 0xd7 }, { 131, 0xaf, 0xaf, 0xff },
|
||||
{ 132, 0xaf, 0xd7, 0x00 }, { 133, 0xaf, 0xd7, 0x5f },
|
||||
{ 134, 0xaf, 0xd7, 0x87 }, { 135, 0xaf, 0xd7, 0xaf },
|
||||
{ 136, 0xaf, 0xd7, 0xd7 }, { 137, 0xaf, 0xd7, 0xff },
|
||||
{ 138, 0xaf, 0xff, 0x00 }, { 139, 0xaf, 0xff, 0x5f },
|
||||
{ 140, 0xaf, 0xff, 0x87 }, { 141, 0xaf, 0xff, 0xaf },
|
||||
{ 142, 0xaf, 0xff, 0xd7 }, { 143, 0xaf, 0xff, 0xff },
|
||||
{ 144, 0xd7, 0x00, 0x00 }, { 145, 0xd7, 0x00, 0x5f },
|
||||
{ 146, 0xd7, 0x00, 0x87 }, { 147, 0xd7, 0x00, 0xaf },
|
||||
{ 148, 0xd7, 0x00, 0xd7 }, { 149, 0xd7, 0x00, 0xff },
|
||||
{ 150, 0xd7, 0x5f, 0x00 }, { 151, 0xd7, 0x5f, 0x5f },
|
||||
{ 152, 0xd7, 0x5f, 0x87 }, { 153, 0xd7, 0x5f, 0xaf },
|
||||
{ 154, 0xd7, 0x5f, 0xd7 }, { 155, 0xd7, 0x5f, 0xff },
|
||||
{ 156, 0xd7, 0x87, 0x00 }, { 157, 0xd7, 0x87, 0x5f },
|
||||
{ 158, 0xd7, 0x87, 0x87 }, { 159, 0xd7, 0x87, 0xaf },
|
||||
{ 160, 0xd7, 0x87, 0xd7 }, { 161, 0xd7, 0x87, 0xff },
|
||||
{ 162, 0xd7, 0xaf, 0x00 }, { 163, 0xd7, 0xaf, 0x5f },
|
||||
{ 164, 0xd7, 0xaf, 0x87 }, { 165, 0xd7, 0xaf, 0xaf },
|
||||
{ 166, 0xd7, 0xaf, 0xd7 }, { 167, 0xd7, 0xaf, 0xff },
|
||||
{ 168, 0xd7, 0xd7, 0x00 }, { 169, 0xd7, 0xd7, 0x5f },
|
||||
{ 170, 0xd7, 0xd7, 0x87 }, { 171, 0xd7, 0xd7, 0xaf },
|
||||
{ 172, 0xd7, 0xd7, 0xd7 }, { 173, 0xd7, 0xd7, 0xff },
|
||||
{ 174, 0xd7, 0xff, 0x00 }, { 175, 0xd7, 0xff, 0x5f },
|
||||
{ 176, 0xd7, 0xff, 0x87 }, { 177, 0xd7, 0xff, 0xaf },
|
||||
{ 178, 0xd7, 0xff, 0xd7 }, { 179, 0xd7, 0xff, 0xff },
|
||||
{ 180, 0xff, 0x00, 0x00 }, { 181, 0xff, 0x00, 0x5f },
|
||||
{ 182, 0xff, 0x00, 0x87 }, { 183, 0xff, 0x00, 0xaf },
|
||||
{ 184, 0xff, 0x00, 0xd7 }, { 185, 0xff, 0x00, 0xff },
|
||||
{ 186, 0xff, 0x5f, 0x00 }, { 187, 0xff, 0x5f, 0x5f },
|
||||
{ 188, 0xff, 0x5f, 0x87 }, { 189, 0xff, 0x5f, 0xaf },
|
||||
{ 190, 0xff, 0x5f, 0xd7 }, { 191, 0xff, 0x5f, 0xff },
|
||||
{ 192, 0xff, 0x87, 0x00 }, { 193, 0xff, 0x87, 0x5f },
|
||||
{ 194, 0xff, 0x87, 0x87 }, { 195, 0xff, 0x87, 0xaf },
|
||||
{ 196, 0xff, 0x87, 0xd7 }, { 197, 0xff, 0x87, 0xff },
|
||||
{ 198, 0xff, 0xaf, 0x00 }, { 199, 0xff, 0xaf, 0x5f },
|
||||
{ 200, 0xff, 0xaf, 0x87 }, { 201, 0xff, 0xaf, 0xaf },
|
||||
{ 202, 0xff, 0xaf, 0xd7 }, { 203, 0xff, 0xaf, 0xff },
|
||||
{ 204, 0xff, 0xd7, 0x00 }, { 205, 0xff, 0xd7, 0x5f },
|
||||
{ 206, 0xff, 0xd7, 0x87 }, { 207, 0xff, 0xd7, 0xaf },
|
||||
{ 208, 0xff, 0xd7, 0xd7 }, { 209, 0xff, 0xd7, 0xff },
|
||||
{ 210, 0xff, 0xff, 0x00 }, { 211, 0xff, 0xff, 0x5f },
|
||||
{ 212, 0xff, 0xff, 0x87 }, { 213, 0xff, 0xff, 0xaf },
|
||||
{ 214, 0xff, 0xff, 0xd7 }, { 215, 0xff, 0xff, 0xff },
|
||||
{ 216, 0x08, 0x08, 0x08 }, { 217, 0x12, 0x12, 0x12 },
|
||||
{ 218, 0x1c, 0x1c, 0x1c }, { 219, 0x26, 0x26, 0x26 },
|
||||
{ 220, 0x30, 0x30, 0x30 }, { 221, 0x3a, 0x3a, 0x3a },
|
||||
{ 222, 0x44, 0x44, 0x44 }, { 223, 0x4e, 0x4e, 0x4e },
|
||||
{ 224, 0x58, 0x58, 0x58 }, { 225, 0x62, 0x62, 0x62 },
|
||||
{ 226, 0x6c, 0x6c, 0x6c }, { 227, 0x76, 0x76, 0x76 },
|
||||
{ 228, 0x80, 0x80, 0x80 }, { 229, 0x8a, 0x8a, 0x8a },
|
||||
{ 230, 0x94, 0x94, 0x94 }, { 231, 0x9e, 0x9e, 0x9e },
|
||||
{ 232, 0xa8, 0xa8, 0xa8 }, { 233, 0xb2, 0xb2, 0xb2 },
|
||||
{ 234, 0xbc, 0xbc, 0xbc }, { 235, 0xc6, 0xc6, 0xc6 },
|
||||
{ 236, 0xd0, 0xd0, 0xd0 }, { 237, 0xda, 0xda, 0xda },
|
||||
{ 238, 0xe4, 0xe4, 0xe4 }, { 239, 0xee, 0xee, 0xee },
|
||||
};
|
||||
const struct colour_rgb colour_to_256[] = {
|
||||
{ 0, 0x00, 0x00, 0x00 }, { 1, 0x00, 0x00, 0x5f },
|
||||
{ 2, 0x00, 0x00, 0x87 }, { 3, 0x00, 0x00, 0xaf },
|
||||
{ 4, 0x00, 0x00, 0xd7 }, { 5, 0x00, 0x00, 0xff },
|
||||
{ 6, 0x00, 0x5f, 0x00 }, { 7, 0x00, 0x5f, 0x5f },
|
||||
{ 8, 0x00, 0x5f, 0x87 }, { 9, 0x00, 0x5f, 0xaf },
|
||||
{ 10, 0x00, 0x5f, 0xd7 }, { 11, 0x00, 0x5f, 0xff },
|
||||
{ 12, 0x00, 0x87, 0x00 }, { 13, 0x00, 0x87, 0x5f },
|
||||
{ 14, 0x00, 0x87, 0x87 }, { 15, 0x00, 0x87, 0xaf },
|
||||
{ 16, 0x00, 0x87, 0xd7 }, { 17, 0x00, 0x87, 0xff },
|
||||
{ 18, 0x00, 0xaf, 0x00 }, { 19, 0x00, 0xaf, 0x5f },
|
||||
{ 20, 0x00, 0xaf, 0x87 }, { 21, 0x00, 0xaf, 0xaf },
|
||||
{ 22, 0x00, 0xaf, 0xd7 }, { 23, 0x00, 0xaf, 0xff },
|
||||
{ 24, 0x00, 0xd7, 0x00 }, { 25, 0x00, 0xd7, 0x5f },
|
||||
{ 26, 0x00, 0xd7, 0x87 }, { 27, 0x00, 0xd7, 0xaf },
|
||||
{ 28, 0x00, 0xd7, 0xd7 }, { 29, 0x00, 0xd7, 0xff },
|
||||
{ 30, 0x00, 0xff, 0x00 }, { 31, 0x00, 0xff, 0x5f },
|
||||
{ 32, 0x00, 0xff, 0x87 }, { 33, 0x00, 0xff, 0xaf },
|
||||
{ 34, 0x00, 0xff, 0xd7 }, { 35, 0x00, 0xff, 0xff },
|
||||
{ 216, 0x08, 0x08, 0x08 }, { 217, 0x12, 0x12, 0x12 },
|
||||
{ 218, 0x1c, 0x1c, 0x1c }, { 219, 0x26, 0x26, 0x26 },
|
||||
{ 220, 0x30, 0x30, 0x30 }, { 221, 0x3a, 0x3a, 0x3a },
|
||||
{ 222, 0x44, 0x44, 0x44 }, { 223, 0x4e, 0x4e, 0x4e },
|
||||
{ 224, 0x58, 0x58, 0x58 }, { 36, 0x5f, 0x00, 0x00 },
|
||||
{ 37, 0x5f, 0x00, 0x5f }, { 38, 0x5f, 0x00, 0x87 },
|
||||
{ 39, 0x5f, 0x00, 0xaf }, { 40, 0x5f, 0x00, 0xd7 },
|
||||
{ 41, 0x5f, 0x00, 0xff }, { 42, 0x5f, 0x5f, 0x00 },
|
||||
{ 43, 0x5f, 0x5f, 0x5f }, { 44, 0x5f, 0x5f, 0x87 },
|
||||
{ 45, 0x5f, 0x5f, 0xaf }, { 46, 0x5f, 0x5f, 0xd7 },
|
||||
{ 47, 0x5f, 0x5f, 0xff }, { 48, 0x5f, 0x87, 0x00 },
|
||||
{ 49, 0x5f, 0x87, 0x5f }, { 50, 0x5f, 0x87, 0x87 },
|
||||
{ 51, 0x5f, 0x87, 0xaf }, { 52, 0x5f, 0x87, 0xd7 },
|
||||
{ 53, 0x5f, 0x87, 0xff }, { 54, 0x5f, 0xaf, 0x00 },
|
||||
{ 55, 0x5f, 0xaf, 0x5f }, { 56, 0x5f, 0xaf, 0x87 },
|
||||
{ 57, 0x5f, 0xaf, 0xaf }, { 58, 0x5f, 0xaf, 0xd7 },
|
||||
{ 59, 0x5f, 0xaf, 0xff }, { 60, 0x5f, 0xd7, 0x00 },
|
||||
{ 61, 0x5f, 0xd7, 0x5f }, { 62, 0x5f, 0xd7, 0x87 },
|
||||
{ 63, 0x5f, 0xd7, 0xaf }, { 64, 0x5f, 0xd7, 0xd7 },
|
||||
{ 65, 0x5f, 0xd7, 0xff }, { 66, 0x5f, 0xff, 0x00 },
|
||||
{ 67, 0x5f, 0xff, 0x5f }, { 68, 0x5f, 0xff, 0x87 },
|
||||
{ 69, 0x5f, 0xff, 0xaf }, { 70, 0x5f, 0xff, 0xd7 },
|
||||
{ 71, 0x5f, 0xff, 0xff }, { 225, 0x62, 0x62, 0x62 },
|
||||
{ 226, 0x6c, 0x6c, 0x6c }, { 227, 0x76, 0x76, 0x76 },
|
||||
{ 228, 0x80, 0x80, 0x80 }, { 72, 0x87, 0x00, 0x00 },
|
||||
{ 73, 0x87, 0x00, 0x5f }, { 74, 0x87, 0x00, 0x87 },
|
||||
{ 75, 0x87, 0x00, 0xaf }, { 76, 0x87, 0x00, 0xd7 },
|
||||
{ 77, 0x87, 0x00, 0xff }, { 78, 0x87, 0x5f, 0x00 },
|
||||
{ 79, 0x87, 0x5f, 0x5f }, { 80, 0x87, 0x5f, 0x87 },
|
||||
{ 81, 0x87, 0x5f, 0xaf }, { 82, 0x87, 0x5f, 0xd7 },
|
||||
{ 83, 0x87, 0x5f, 0xff }, { 84, 0x87, 0x87, 0x00 },
|
||||
{ 85, 0x87, 0x87, 0x5f }, { 86, 0x87, 0x87, 0x87 },
|
||||
{ 87, 0x87, 0x87, 0xaf }, { 88, 0x87, 0x87, 0xd7 },
|
||||
{ 89, 0x87, 0x87, 0xff }, { 90, 0x87, 0xaf, 0x00 },
|
||||
{ 91, 0x87, 0xaf, 0x5f }, { 92, 0x87, 0xaf, 0x87 },
|
||||
{ 93, 0x87, 0xaf, 0xaf }, { 94, 0x87, 0xaf, 0xd7 },
|
||||
{ 95, 0x87, 0xaf, 0xff }, { 96, 0x87, 0xd7, 0x00 },
|
||||
{ 97, 0x87, 0xd7, 0x5f }, { 98, 0x87, 0xd7, 0x87 },
|
||||
{ 99, 0x87, 0xd7, 0xaf }, { 100, 0x87, 0xd7, 0xd7 },
|
||||
{ 101, 0x87, 0xd7, 0xff }, { 102, 0x87, 0xff, 0x00 },
|
||||
{ 103, 0x87, 0xff, 0x5f }, { 104, 0x87, 0xff, 0x87 },
|
||||
{ 105, 0x87, 0xff, 0xaf }, { 106, 0x87, 0xff, 0xd7 },
|
||||
{ 107, 0x87, 0xff, 0xff }, { 229, 0x8a, 0x8a, 0x8a },
|
||||
{ 230, 0x94, 0x94, 0x94 }, { 231, 0x9e, 0x9e, 0x9e },
|
||||
{ 232, 0xa8, 0xa8, 0xa8 }, { 108, 0xaf, 0x00, 0x00 },
|
||||
{ 109, 0xaf, 0x00, 0x5f }, { 110, 0xaf, 0x00, 0x87 },
|
||||
{ 111, 0xaf, 0x00, 0xaf }, { 112, 0xaf, 0x00, 0xd7 },
|
||||
{ 113, 0xaf, 0x00, 0xff }, { 114, 0xaf, 0x5f, 0x00 },
|
||||
{ 115, 0xaf, 0x5f, 0x5f }, { 116, 0xaf, 0x5f, 0x87 },
|
||||
{ 117, 0xaf, 0x5f, 0xaf }, { 118, 0xaf, 0x5f, 0xd7 },
|
||||
{ 119, 0xaf, 0x5f, 0xff }, { 120, 0xaf, 0x87, 0x00 },
|
||||
{ 121, 0xaf, 0x87, 0x5f }, { 122, 0xaf, 0x87, 0x87 },
|
||||
{ 123, 0xaf, 0x87, 0xaf }, { 124, 0xaf, 0x87, 0xd7 },
|
||||
{ 125, 0xaf, 0x87, 0xff }, { 126, 0xaf, 0xaf, 0x00 },
|
||||
{ 127, 0xaf, 0xaf, 0x5f }, { 128, 0xaf, 0xaf, 0x87 },
|
||||
{ 129, 0xaf, 0xaf, 0xaf }, { 130, 0xaf, 0xaf, 0xd7 },
|
||||
{ 131, 0xaf, 0xaf, 0xff }, { 132, 0xaf, 0xd7, 0x00 },
|
||||
{ 133, 0xaf, 0xd7, 0x5f }, { 134, 0xaf, 0xd7, 0x87 },
|
||||
{ 135, 0xaf, 0xd7, 0xaf }, { 136, 0xaf, 0xd7, 0xd7 },
|
||||
{ 137, 0xaf, 0xd7, 0xff }, { 138, 0xaf, 0xff, 0x00 },
|
||||
{ 139, 0xaf, 0xff, 0x5f }, { 140, 0xaf, 0xff, 0x87 },
|
||||
{ 141, 0xaf, 0xff, 0xaf }, { 142, 0xaf, 0xff, 0xd7 },
|
||||
{ 143, 0xaf, 0xff, 0xff }, { 233, 0xb2, 0xb2, 0xb2 },
|
||||
{ 234, 0xbc, 0xbc, 0xbc }, { 235, 0xc6, 0xc6, 0xc6 },
|
||||
{ 236, 0xd0, 0xd0, 0xd0 }, { 144, 0xd7, 0x00, 0x00 },
|
||||
{ 145, 0xd7, 0x00, 0x5f }, { 146, 0xd7, 0x00, 0x87 },
|
||||
{ 147, 0xd7, 0x00, 0xaf }, { 148, 0xd7, 0x00, 0xd7 },
|
||||
{ 149, 0xd7, 0x00, 0xff }, { 150, 0xd7, 0x5f, 0x00 },
|
||||
{ 151, 0xd7, 0x5f, 0x5f }, { 152, 0xd7, 0x5f, 0x87 },
|
||||
{ 153, 0xd7, 0x5f, 0xaf }, { 154, 0xd7, 0x5f, 0xd7 },
|
||||
{ 155, 0xd7, 0x5f, 0xff }, { 156, 0xd7, 0x87, 0x00 },
|
||||
{ 157, 0xd7, 0x87, 0x5f }, { 158, 0xd7, 0x87, 0x87 },
|
||||
{ 159, 0xd7, 0x87, 0xaf }, { 160, 0xd7, 0x87, 0xd7 },
|
||||
{ 161, 0xd7, 0x87, 0xff }, { 162, 0xd7, 0xaf, 0x00 },
|
||||
{ 163, 0xd7, 0xaf, 0x5f }, { 164, 0xd7, 0xaf, 0x87 },
|
||||
{ 165, 0xd7, 0xaf, 0xaf }, { 166, 0xd7, 0xaf, 0xd7 },
|
||||
{ 167, 0xd7, 0xaf, 0xff }, { 168, 0xd7, 0xd7, 0x00 },
|
||||
{ 169, 0xd7, 0xd7, 0x5f }, { 170, 0xd7, 0xd7, 0x87 },
|
||||
{ 171, 0xd7, 0xd7, 0xaf }, { 172, 0xd7, 0xd7, 0xd7 },
|
||||
{ 173, 0xd7, 0xd7, 0xff }, { 174, 0xd7, 0xff, 0x00 },
|
||||
{ 175, 0xd7, 0xff, 0x5f }, { 176, 0xd7, 0xff, 0x87 },
|
||||
{ 177, 0xd7, 0xff, 0xaf }, { 178, 0xd7, 0xff, 0xd7 },
|
||||
{ 179, 0xd7, 0xff, 0xff }, { 237, 0xda, 0xda, 0xda },
|
||||
{ 238, 0xe4, 0xe4, 0xe4 }, { 239, 0xee, 0xee, 0xee },
|
||||
{ 180, 0xff, 0x00, 0x00 }, { 181, 0xff, 0x00, 0x5f },
|
||||
{ 182, 0xff, 0x00, 0x87 }, { 183, 0xff, 0x00, 0xaf },
|
||||
{ 184, 0xff, 0x00, 0xd7 }, { 185, 0xff, 0x00, 0xff },
|
||||
{ 186, 0xff, 0x5f, 0x00 }, { 187, 0xff, 0x5f, 0x5f },
|
||||
{ 188, 0xff, 0x5f, 0x87 }, { 189, 0xff, 0x5f, 0xaf },
|
||||
{ 190, 0xff, 0x5f, 0xd7 }, { 191, 0xff, 0x5f, 0xff },
|
||||
{ 192, 0xff, 0x87, 0x00 }, { 193, 0xff, 0x87, 0x5f },
|
||||
{ 194, 0xff, 0x87, 0x87 }, { 195, 0xff, 0x87, 0xaf },
|
||||
{ 196, 0xff, 0x87, 0xd7 }, { 197, 0xff, 0x87, 0xff },
|
||||
{ 198, 0xff, 0xaf, 0x00 }, { 199, 0xff, 0xaf, 0x5f },
|
||||
{ 200, 0xff, 0xaf, 0x87 }, { 201, 0xff, 0xaf, 0xaf },
|
||||
{ 202, 0xff, 0xaf, 0xd7 }, { 203, 0xff, 0xaf, 0xff },
|
||||
{ 204, 0xff, 0xd7, 0x00 }, { 205, 0xff, 0xd7, 0x5f },
|
||||
{ 206, 0xff, 0xd7, 0x87 }, { 207, 0xff, 0xd7, 0xaf },
|
||||
{ 208, 0xff, 0xd7, 0xd7 }, { 209, 0xff, 0xd7, 0xff },
|
||||
{ 210, 0xff, 0xff, 0x00 }, { 211, 0xff, 0xff, 0x5f },
|
||||
{ 212, 0xff, 0xff, 0x87 }, { 213, 0xff, 0xff, 0xaf },
|
||||
{ 214, 0xff, 0xff, 0xd7 }, { 215, 0xff, 0xff, 0xff },
|
||||
};
|
||||
|
||||
int colour_cmp_rgb(const void *, const void *);
|
||||
|
||||
/* Compare function for bsearch(). */
|
||||
int
|
||||
colour_cmp_rgb(const void *lhs0, const void *rhs0)
|
||||
static int
|
||||
colour_dist_sq(int R, int G, int B, int r, int g, int b)
|
||||
{
|
||||
const struct colour_rgb *lhs = lhs0, *rhs = rhs0;
|
||||
|
||||
if (lhs->r < rhs->r)
|
||||
return (-1);
|
||||
if (lhs->r > rhs->r)
|
||||
return (1);
|
||||
|
||||
if (lhs->g < rhs->g)
|
||||
return (-1);
|
||||
if (lhs->g > rhs->g)
|
||||
return (1);
|
||||
|
||||
if (lhs->b < rhs->b)
|
||||
return (-1);
|
||||
if (lhs->b > rhs->b)
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
return ((R - r) * (R - r) + (G - g) * (G - g) + (B - b) * (B - b));
|
||||
}
|
||||
|
||||
/* Work out the nearest colour from the 256 colour set. */
|
||||
static int
|
||||
colour_to_6cube(int v)
|
||||
{
|
||||
if (v < 48)
|
||||
return (0);
|
||||
if (v < 114)
|
||||
return (1);
|
||||
return ((v - 35) / 40);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an RGB triplet to the xterm(1) 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).
|
||||
*/
|
||||
int
|
||||
colour_find_rgb(u_char r, u_char g, u_char b)
|
||||
{
|
||||
struct colour_rgb rgb = { .r = r, .g = g, .b = b }, *found;
|
||||
u_int distance, lowest, colour, i;
|
||||
int dr, dg, db;
|
||||
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;
|
||||
|
||||
found = bsearch(&rgb, colour_to_256, nitems(colour_to_256),
|
||||
sizeof colour_to_256[0], colour_cmp_rgb);
|
||||
if (found != NULL)
|
||||
return (16 + found->i);
|
||||
/* Map RGB to 6x6x6 cube. */
|
||||
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;
|
||||
lowest = UINT_MAX;
|
||||
for (i = 0; i < 240; i++) {
|
||||
dr = (int)colour_from_256[i].r - r;
|
||||
dg = (int)colour_from_256[i].g - g;
|
||||
db = (int)colour_from_256[i].b - b;
|
||||
/* If we have hit the colour exactly, return early. */
|
||||
if (cr == r && cg == g && cb == b)
|
||||
return ((16 + (36 * qr) + (6 * qg) + qb) | COLOUR_FLAG_256);
|
||||
|
||||
distance = dr * dr + dg * dg + db * db;
|
||||
if (distance < lowest) {
|
||||
lowest = distance;
|
||||
colour = 16 + i;
|
||||
}
|
||||
}
|
||||
return (colour);
|
||||
/* Work out the closest grey (average of RGB). */
|
||||
grey_avg = (r + g + b) / 3;
|
||||
if (grey_avg > 238)
|
||||
grey_idx = 23;
|
||||
else
|
||||
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. */
|
||||
void
|
||||
colour_set_fg(struct grid_cell *gc, int c)
|
||||
/* Join RGB into a colour. */
|
||||
int
|
||||
colour_join_rgb(u_char r, u_char g, u_char b)
|
||||
{
|
||||
if (c & 0x100)
|
||||
gc->flags |= GRID_FLAG_FG256;
|
||||
gc->fg = c;
|
||||
return ((((int)((r) & 0xff)) << 16) |
|
||||
(((int)((g) & 0xff)) << 8) |
|
||||
(((int)((b) & 0xff))) | COLOUR_FLAG_RGB);
|
||||
}
|
||||
|
||||
/* Set grid cell background colour. */
|
||||
/* Split colour into RGB. */
|
||||
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)
|
||||
gc->flags |= GRID_FLAG_BG256;
|
||||
gc->bg = c;
|
||||
*r = (c >> 16) & 0xff;
|
||||
*g = (c >> 8) & 0xff;
|
||||
*b = c & 0xff;
|
||||
}
|
||||
|
||||
/* Convert colour to a string. */
|
||||
@@ -359,9 +109,16 @@ const char *
|
||||
colour_tostring(int c)
|
||||
{
|
||||
static char s[32];
|
||||
u_char r, g, b;
|
||||
|
||||
if (c & 0x100) {
|
||||
xsnprintf(s, sizeof s, "colour%d", c & ~0x100);
|
||||
if (c & COLOUR_FLAG_RGB) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -384,6 +141,8 @@ colour_tostring(int c)
|
||||
return ("white");
|
||||
case 8:
|
||||
return ("default");
|
||||
case 9:
|
||||
return ("terminal");
|
||||
case 90:
|
||||
return ("brightblack");
|
||||
case 91:
|
||||
@@ -401,7 +160,7 @@ colour_tostring(int c)
|
||||
case 97:
|
||||
return ("brightwhite");
|
||||
}
|
||||
return (NULL);
|
||||
return ("invalid");
|
||||
}
|
||||
|
||||
/* Convert colour from string. */
|
||||
@@ -421,16 +180,21 @@ colour_fromstring(const char *s)
|
||||
n = sscanf(s + 1, "%2hhx%2hhx%2hhx", &r, &g, &b);
|
||||
if (n != 3)
|
||||
return (-1);
|
||||
return (colour_find_rgb(r, g, b) | 0x100);
|
||||
return (colour_join_rgb(r, g, b));
|
||||
}
|
||||
|
||||
if (strncasecmp(s, "colour", (sizeof "colour") - 1) == 0) {
|
||||
n = strtonum(s + (sizeof "colour") - 1, 0, 255, &errstr);
|
||||
if (errstr != NULL)
|
||||
return (-1);
|
||||
return (n | 0x100);
|
||||
return (n | COLOUR_FLAG_256);
|
||||
}
|
||||
|
||||
if (strcasecmp(s, "default") == 0)
|
||||
return (8);
|
||||
if (strcasecmp(s, "terminal") == 0)
|
||||
return (9);
|
||||
|
||||
if (strcasecmp(s, "black") == 0 || strcmp(s, "0") == 0)
|
||||
return (0);
|
||||
if (strcasecmp(s, "red") == 0 || strcmp(s, "1") == 0)
|
||||
@@ -447,8 +211,6 @@ colour_fromstring(const char *s)
|
||||
return (6);
|
||||
if (strcasecmp(s, "white") == 0 || strcmp(s, "7") == 0)
|
||||
return (7);
|
||||
if (strcasecmp(s, "default") == 0 || strcmp(s, "8") == 0)
|
||||
return (8);
|
||||
if (strcasecmp(s, "brightblack") == 0 || strcmp(s, "90") == 0)
|
||||
return (90);
|
||||
if (strcasecmp(s, "brightred") == 0 || strcmp(s, "91") == 0)
|
||||
@@ -468,11 +230,85 @@ colour_fromstring(const char *s)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Convert 256 colour palette to 16. */
|
||||
u_char
|
||||
colour_256to16(u_char c)
|
||||
/* Convert 256 colour to RGB colour. */
|
||||
int
|
||||
colour_256toRGB(int c)
|
||||
{
|
||||
static const u_char table[256] = {
|
||||
static const int table[256] = {
|
||||
0x000000, 0x800000, 0x008000, 0x808000,
|
||||
0x000080, 0x800080, 0x008080, 0xc0c0c0,
|
||||
0x808080, 0xff0000, 0x00ff00, 0xffff00,
|
||||
0x0000ff, 0xff00ff, 0x00ffff, 0xffffff,
|
||||
0x000000, 0x00005f, 0x000087, 0x0000af,
|
||||
0x0000d7, 0x0000ff, 0x005f00, 0x005f5f,
|
||||
0x005f87, 0x005faf, 0x005fd7, 0x005fff,
|
||||
0x008700, 0x00875f, 0x008787, 0x0087af,
|
||||
0x0087d7, 0x0087ff, 0x00af00, 0x00af5f,
|
||||
0x00af87, 0x00afaf, 0x00afd7, 0x00afff,
|
||||
0x00d700, 0x00d75f, 0x00d787, 0x00d7af,
|
||||
0x00d7d7, 0x00d7ff, 0x00ff00, 0x00ff5f,
|
||||
0x00ff87, 0x00ffaf, 0x00ffd7, 0x00ffff,
|
||||
0x5f0000, 0x5f005f, 0x5f0087, 0x5f00af,
|
||||
0x5f00d7, 0x5f00ff, 0x5f5f00, 0x5f5f5f,
|
||||
0x5f5f87, 0x5f5faf, 0x5f5fd7, 0x5f5fff,
|
||||
0x5f8700, 0x5f875f, 0x5f8787, 0x5f87af,
|
||||
0x5f87d7, 0x5f87ff, 0x5faf00, 0x5faf5f,
|
||||
0x5faf87, 0x5fafaf, 0x5fafd7, 0x5fafff,
|
||||
0x5fd700, 0x5fd75f, 0x5fd787, 0x5fd7af,
|
||||
0x5fd7d7, 0x5fd7ff, 0x5fff00, 0x5fff5f,
|
||||
0x5fff87, 0x5fffaf, 0x5fffd7, 0x5fffff,
|
||||
0x870000, 0x87005f, 0x870087, 0x8700af,
|
||||
0x8700d7, 0x8700ff, 0x875f00, 0x875f5f,
|
||||
0x875f87, 0x875faf, 0x875fd7, 0x875fff,
|
||||
0x878700, 0x87875f, 0x878787, 0x8787af,
|
||||
0x8787d7, 0x8787ff, 0x87af00, 0x87af5f,
|
||||
0x87af87, 0x87afaf, 0x87afd7, 0x87afff,
|
||||
0x87d700, 0x87d75f, 0x87d787, 0x87d7af,
|
||||
0x87d7d7, 0x87d7ff, 0x87ff00, 0x87ff5f,
|
||||
0x87ff87, 0x87ffaf, 0x87ffd7, 0x87ffff,
|
||||
0xaf0000, 0xaf005f, 0xaf0087, 0xaf00af,
|
||||
0xaf00d7, 0xaf00ff, 0xaf5f00, 0xaf5f5f,
|
||||
0xaf5f87, 0xaf5faf, 0xaf5fd7, 0xaf5fff,
|
||||
0xaf8700, 0xaf875f, 0xaf8787, 0xaf87af,
|
||||
0xaf87d7, 0xaf87ff, 0xafaf00, 0xafaf5f,
|
||||
0xafaf87, 0xafafaf, 0xafafd7, 0xafafff,
|
||||
0xafd700, 0xafd75f, 0xafd787, 0xafd7af,
|
||||
0xafd7d7, 0xafd7ff, 0xafff00, 0xafff5f,
|
||||
0xafff87, 0xafffaf, 0xafffd7, 0xafffff,
|
||||
0xd70000, 0xd7005f, 0xd70087, 0xd700af,
|
||||
0xd700d7, 0xd700ff, 0xd75f00, 0xd75f5f,
|
||||
0xd75f87, 0xd75faf, 0xd75fd7, 0xd75fff,
|
||||
0xd78700, 0xd7875f, 0xd78787, 0xd787af,
|
||||
0xd787d7, 0xd787ff, 0xd7af00, 0xd7af5f,
|
||||
0xd7af87, 0xd7afaf, 0xd7afd7, 0xd7afff,
|
||||
0xd7d700, 0xd7d75f, 0xd7d787, 0xd7d7af,
|
||||
0xd7d7d7, 0xd7d7ff, 0xd7ff00, 0xd7ff5f,
|
||||
0xd7ff87, 0xd7ffaf, 0xd7ffd7, 0xd7ffff,
|
||||
0xff0000, 0xff005f, 0xff0087, 0xff00af,
|
||||
0xff00d7, 0xff00ff, 0xff5f00, 0xff5f5f,
|
||||
0xff5f87, 0xff5faf, 0xff5fd7, 0xff5fff,
|
||||
0xff8700, 0xff875f, 0xff8787, 0xff87af,
|
||||
0xff87d7, 0xff87ff, 0xffaf00, 0xffaf5f,
|
||||
0xffaf87, 0xffafaf, 0xffafd7, 0xffafff,
|
||||
0xffd700, 0xffd75f, 0xffd787, 0xffd7af,
|
||||
0xffd7d7, 0xffd7ff, 0xffff00, 0xffff5f,
|
||||
0xffff87, 0xffffaf, 0xffffd7, 0xffffff,
|
||||
0x080808, 0x121212, 0x1c1c1c, 0x262626,
|
||||
0x303030, 0x3a3a3a, 0x444444, 0x4e4e4e,
|
||||
0x585858, 0x626262, 0x6c6c6c, 0x767676,
|
||||
0x808080, 0x8a8a8a, 0x949494, 0x9e9e9e,
|
||||
0xa8a8a8, 0xb2b2b2, 0xbcbcbc, 0xc6c6c6,
|
||||
0xd0d0d0, 0xdadada, 0xe4e4e4, 0xeeeeee
|
||||
};
|
||||
|
||||
return (table[c & 0xff] | COLOUR_FLAG_RGB);
|
||||
}
|
||||
|
||||
/* Convert 256 colour to 16 colour. */
|
||||
int
|
||||
colour_256to16(int c)
|
||||
{
|
||||
static const char table[256] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
0, 4, 4, 4, 12, 12, 2, 6, 4, 4, 12, 12, 2, 2, 6, 4,
|
||||
12, 12, 2, 2, 2, 6, 12, 12, 10, 10, 10, 10, 14, 12, 10, 10,
|
||||
@@ -491,5 +327,5 @@ colour_256to16(u_char c)
|
||||
8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 15, 15, 15, 15, 15, 15
|
||||
};
|
||||
|
||||
return (table[c]);
|
||||
return (table[c & 0xff]);
|
||||
}
|
||||
|
||||
178
compat.h
178
compat.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -17,10 +17,23 @@
|
||||
#ifndef COMPAT_H
|
||||
#define COMPAT_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(a)
|
||||
#endif
|
||||
|
||||
#ifndef __unused
|
||||
#define __unused __attribute__ ((__unused__))
|
||||
#endif
|
||||
#ifndef __dead
|
||||
#define __dead __attribute__ ((__noreturn__))
|
||||
#endif
|
||||
@@ -32,21 +45,61 @@
|
||||
#define ECHOPRT 0
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_BSD_TYPES
|
||||
typedef uint8_t u_int8_t;
|
||||
typedef uint16_t u_int16_t;
|
||||
typedef uint32_t u_int32_t;
|
||||
typedef uint64_t u_int64_t;
|
||||
#ifndef ACCESSPERMS
|
||||
#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_PATHS_H
|
||||
#define _PATH_BSHELL "/bin/sh"
|
||||
#define _PATH_TMP "/tmp/"
|
||||
#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
|
||||
|
||||
#ifdef HAVE_PATHS_H
|
||||
#include <paths.h>
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_BSHELL
|
||||
#define _PATH_BSHELL "/bin/sh"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_TMP
|
||||
#define _PATH_TMP "/tmp/"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DEVNULL
|
||||
#define _PATH_DEVNULL "/dev/null"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_TTY
|
||||
#define _PATH_TTY "/dev/tty"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DEV
|
||||
#define _PATH_DEV "/dev/"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DEFPATH
|
||||
#define _PATH_DEFPATH "/usr/bin:/bin"
|
||||
#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
|
||||
#include <sys/queue.h>
|
||||
#else
|
||||
@@ -65,21 +118,17 @@ typedef uint64_t u_int64_t;
|
||||
#include "compat/bitstring.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PATHS_H
|
||||
#include <paths.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FORKPTY
|
||||
#ifdef HAVE_LIBUTIL_H
|
||||
#include <libutil.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTY_H
|
||||
#include <pty.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UTIL_H
|
||||
#include <util.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VIS
|
||||
#include <vis.h>
|
||||
@@ -93,12 +142,6 @@ typedef uint64_t u_int64_t;
|
||||
#include "compat/imsg.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#ifdef BROKEN_CMSG_FIRSTHDR
|
||||
#undef CMSG_FIRSTHDR
|
||||
#define CMSG_FIRSTHDR(mhdr) \
|
||||
@@ -127,6 +170,14 @@ typedef uint64_t u_int64_t;
|
||||
#define O_DIRECTORY 0
|
||||
#endif
|
||||
|
||||
#ifndef FNM_CASEFOLD
|
||||
#ifdef FNM_IGNORECASE
|
||||
#define FNM_CASEFOLD FNM_IGNORECASE
|
||||
#else
|
||||
#define FNM_CASEFOLD 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef INFTIM
|
||||
#define INFTIM -1
|
||||
#endif
|
||||
@@ -185,9 +236,19 @@ typedef uint64_t u_int64_t;
|
||||
#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
|
||||
|
||||
#ifndef HAVE_CLOSEFROM
|
||||
/* closefrom.c */
|
||||
void closefrom(int);
|
||||
void closefrom(int);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASESTR
|
||||
@@ -215,20 +276,53 @@ size_t strlcpy(char *, const char *, size_t);
|
||||
size_t strlcat(char *, const char *, size_t);
|
||||
#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_MEMMEM
|
||||
/* memmem.c */
|
||||
void *memmem(const void *, size_t, const void *, size_t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DAEMON
|
||||
/* daemon.c */
|
||||
int daemon(int, int);
|
||||
#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
|
||||
/* b64_ntop.c */
|
||||
#undef b64_ntop /* for Cygwin */
|
||||
/* base64.c */
|
||||
#undef b64_ntop
|
||||
#undef b64_pton
|
||||
int b64_ntop(const char *, size_t, char *, size_t);
|
||||
int b64_pton(const char *, u_char *, size_t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FDFORKPTY
|
||||
/* fdforkpty.c */
|
||||
int getptmfd(void);
|
||||
pid_t fdforkpty(int, int *, char *, struct termios *,
|
||||
struct winsize *);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FORKPTY
|
||||
/* forkpty.c */
|
||||
#include <sys/ioctl.h>
|
||||
pid_t forkpty(int *, char *, struct termios *, struct winsize *);
|
||||
#endif
|
||||
|
||||
@@ -243,10 +337,6 @@ int vasprintf(char **, const char *, va_list);
|
||||
char *fgetln(FILE *, size_t *);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FPARSELN
|
||||
char *fparseln(FILE *, size_t *, size_t *, const char *, int);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SETENV
|
||||
/* setenv.c */
|
||||
int setenv(const char *, const char *, int);
|
||||
@@ -255,18 +345,32 @@ int unsetenv(const char *);
|
||||
|
||||
#ifndef HAVE_CFMAKERAW
|
||||
/* cfmakeraw.c */
|
||||
void cfmakeraw(struct termios *);
|
||||
void cfmakeraw(struct termios *);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_OPENAT
|
||||
/* openat.c */
|
||||
#define AT_FDCWD -100
|
||||
int openat(int, const char *, int, ...);
|
||||
#ifndef HAVE_FREEZERO
|
||||
/* freezero.c */
|
||||
void freezero(void *, size_t);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETOPT
|
||||
#include <getopt.h>
|
||||
#else
|
||||
#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
|
||||
|
||||
#ifndef HAVE_GETOPT
|
||||
/* getopt.c */
|
||||
extern int BSDopterr;
|
||||
extern int BSDoptind;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -14,16 +14,15 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tmux.h"
|
||||
#include "compat.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
int
|
||||
asprintf(char **ret, const char *fmt, ...)
|
||||
|
||||
@@ -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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -41,19 +43,18 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define Assert(Cond) if (!(Cond)) abort()
|
||||
|
||||
static const char Base64[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
static const char Pad64 = '=';
|
||||
@@ -122,11 +123,16 @@ static const char Pad64 = '=';
|
||||
*/
|
||||
|
||||
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;
|
||||
uint8_t input[3];
|
||||
uint8_t output[4];
|
||||
size_t i;
|
||||
u_char input[3];
|
||||
u_char output[4];
|
||||
int i;
|
||||
|
||||
while (2 < srclength) {
|
||||
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[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|
||||
output[3] = input[2] & 0x3f;
|
||||
Assert(output[0] < 64);
|
||||
Assert(output[1] < 64);
|
||||
Assert(output[2] < 64);
|
||||
Assert(output[3] < 64);
|
||||
|
||||
if (datalength + 4 > targsize)
|
||||
return (-1);
|
||||
@@ -161,9 +163,6 @@ b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
|
||||
output[0] = input[0] >> 2;
|
||||
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
|
||||
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|
||||
Assert(output[0] < 64);
|
||||
Assert(output[1] < 64);
|
||||
Assert(output[2] < 64);
|
||||
|
||||
if (datalength + 4 > targsize)
|
||||
return (-1);
|
||||
@@ -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. */
|
||||
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,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Dagobert Michelsen
|
||||
* 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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -15,9 +15,12 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "tmux.h"
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
void
|
||||
cfmakeraw(struct termios *tio)
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
#ifndef HAVE_CLOSEFROM
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -47,6 +45,8 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
#ifndef OPEN_MAX
|
||||
# define OPEN_MAX 256
|
||||
#endif
|
||||
|
||||
85
compat/daemon-darwin.c
Normal file
85
compat/daemon-darwin.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2017 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2013, Chris Johnsen <chris_johnsen@pobox.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <mach/mach.h>
|
||||
|
||||
#include <Availability.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void daemon_darwin(void);
|
||||
|
||||
#ifdef __MAC_10_10
|
||||
|
||||
extern kern_return_t bootstrap_look_up_per_user(mach_port_t, const char *,
|
||||
uid_t, mach_port_t *);
|
||||
extern kern_return_t bootstrap_get_root(mach_port_t, mach_port_t *);
|
||||
|
||||
void
|
||||
daemon_darwin(void)
|
||||
{
|
||||
mach_port_t root = MACH_PORT_NULL;
|
||||
mach_port_t s = MACH_PORT_NULL;
|
||||
uid_t uid;
|
||||
|
||||
uid = getuid();
|
||||
if (bootstrap_get_root(bootstrap_port, &root) == KERN_SUCCESS &&
|
||||
bootstrap_look_up_per_user(root, NULL, uid, &s) == KERN_SUCCESS &&
|
||||
task_set_bootstrap_port(mach_task_self(), s) == KERN_SUCCESS &&
|
||||
mach_port_deallocate(mach_task_self(), bootstrap_port) == KERN_SUCCESS)
|
||||
bootstrap_port = s;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
daemon_darwin(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -28,11 +28,17 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tmux.h"
|
||||
#include "compat.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
extern void daemon_darwin(void);
|
||||
#endif
|
||||
|
||||
int
|
||||
daemon(int nochdir, int noclose)
|
||||
@@ -61,5 +67,9 @@ daemon(int nochdir, int noclose)
|
||||
if (fd > 2)
|
||||
(void)close (fd);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
daemon_darwin();
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
93
compat/err.c
Normal file
93
compat/err.c
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
void
|
||||
err(int eval, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int saved_errno = errno;
|
||||
|
||||
fprintf(stderr, "%s: ", getprogname());
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL) {
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, ": ");
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
fprintf(stderr, "%s\n", strerror(saved_errno));
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
void
|
||||
errx(int eval, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
fprintf(stderr, "%s: ", getprogname());
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL)
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
putc('\n', stderr);
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
void
|
||||
warn(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int saved_errno = errno;
|
||||
|
||||
fprintf(stderr, "%s: ", getprogname());
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL) {
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, ": ");
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
fprintf(stderr, "%s\n", strerror(saved_errno));
|
||||
}
|
||||
|
||||
void
|
||||
warnx(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
fprintf(stderr, "%s: ", getprogname());
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL)
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
putc('\n', stderr);
|
||||
}
|
||||
15
compat/explicit_bzero.c
Normal file
15
compat/explicit_bzero.c
Normal file
@@ -0,0 +1,15 @@
|
||||
/* $OpenBSD: explicit_bzero.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */
|
||||
/*
|
||||
* Public domain.
|
||||
* Written by Matthew Dempsky.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
void
|
||||
explicit_bzero(void *buf, size_t len)
|
||||
{
|
||||
memset(buf, 0, len);
|
||||
}
|
||||
34
compat/fdforkpty.c
Normal file
34
compat/fdforkpty.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2017 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 <limits.h>
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
int
|
||||
getptmfd(void)
|
||||
{
|
||||
return (INT_MAX);
|
||||
}
|
||||
|
||||
pid_t
|
||||
fdforkpty(__unused int ptmfd, int *master, char *name, struct termios *tio,
|
||||
struct winsize *ws)
|
||||
{
|
||||
return (forkpty(master, name, tio, ws));
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user