mirror of
https://github.com/tmux/tmux.git
synced 2026-03-14 12:47:24 +00:00
Compare commits
2404 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80d9964a30 | ||
|
|
150ef86800 | ||
|
|
315d45a0eb | ||
|
|
2a412fad04 | ||
|
|
fe6f520054 | ||
|
|
c7f3599ebc | ||
|
|
b7589750a1 | ||
|
|
c310212d28 | ||
|
|
94d99d5462 | ||
|
|
9120df33ef | ||
|
|
1ab0745f8e | ||
|
|
c5d2de7ec0 | ||
|
|
ca1d78f523 | ||
|
|
6daf06b1ad | ||
|
|
69b7c496ac | ||
|
|
1e981f4c6d | ||
|
|
d325104d10 | ||
|
|
b3de4a3dec | ||
|
|
81db6bab91 | ||
|
|
f2e54e1e2f | ||
|
|
e9d32f901a | ||
|
|
f835be4bb2 | ||
|
|
3aadc9d665 | ||
|
|
bfb700cf41 | ||
|
|
d0accdba88 | ||
|
|
f58721a9e8 | ||
|
|
325396046a | ||
|
|
c52548f6fd | ||
|
|
8edbbb9865 | ||
|
|
73c125f248 | ||
|
|
1721056f35 | ||
|
|
6eef24c37a | ||
|
|
973de5a704 | ||
|
|
57332be8da | ||
|
|
44737b06db | ||
|
|
d50e47fc4a | ||
|
|
9f02feb9d0 | ||
|
|
72d1be5ddd | ||
|
|
1935eb5c1e | ||
|
|
62e0ed5d7e | ||
|
|
945339b443 | ||
|
|
c930fd5ff6 | ||
|
|
dda70d4ef1 | ||
|
|
7d3d996383 | ||
|
|
d23561f381 | ||
|
|
cbf9224c5f | ||
|
|
c965870585 | ||
|
|
9ee93b3ea3 | ||
|
|
df680d7257 | ||
|
|
d02c4bda3a | ||
|
|
938768ed3d | ||
|
|
3368b602a8 | ||
|
|
b185449d07 | ||
|
|
c2cac69a22 | ||
|
|
1a0d3cd5d3 | ||
|
|
adc1f21eae | ||
|
|
994cb872cf | ||
|
|
66829ee12e | ||
|
|
1751da76d5 | ||
|
|
ba014c1a60 | ||
|
|
886c282679 | ||
|
|
ccf39fcdc1 | ||
|
|
ee65bde130 | ||
|
|
b091790622 | ||
|
|
a352570e9f | ||
|
|
d459314517 | ||
|
|
1286c56188 | ||
|
|
40982a01fb | ||
|
|
7aeb4473ad | ||
|
|
72a4602b88 | ||
|
|
30275bc610 | ||
|
|
3e498cdb49 | ||
|
|
7624800ddc | ||
|
|
f0ed61f53c | ||
|
|
a6cd84869e | ||
|
|
7fa55b0419 | ||
|
|
bf35441608 | ||
|
|
f52eac6225 | ||
|
|
2c08a3a559 | ||
|
|
2eb6d6e31b | ||
|
|
334c28afe7 | ||
|
|
5944230c50 | ||
|
|
8bcdd8fc21 | ||
|
|
d518067be6 | ||
|
|
f703a30dfe | ||
|
|
1a0951959f | ||
|
|
b347a994fd | ||
|
|
6126fa0995 | ||
|
|
85df418728 | ||
|
|
558e5639d0 | ||
|
|
d8d746b4b8 | ||
|
|
570028e9c0 | ||
|
|
7c3e7d6535 | ||
|
|
5b065e93b3 | ||
|
|
d3f37566e2 | ||
|
|
b8b31ad53e | ||
|
|
7f479ffdce | ||
|
|
4901d9ddc8 | ||
|
|
ffba21a60c | ||
|
|
98b81e9834 | ||
|
|
17ec688ced | ||
|
|
0b77d17b35 | ||
|
|
d0566a474a | ||
|
|
99e3cbc526 | ||
|
|
b85de1ddb3 | ||
|
|
c1ccefc62d | ||
|
|
6ac7abe8f0 | ||
|
|
909e1c1a86 | ||
|
|
7936ce3874 | ||
|
|
b8b85fbb0c | ||
|
|
282c5f9644 | ||
|
|
165aa59760 | ||
|
|
10c38436aa | ||
|
|
a0404b6902 | ||
|
|
eb26dbd072 | ||
|
|
6c093010e0 | ||
|
|
d2160e3f83 | ||
|
|
b822d24b15 | ||
|
|
fc54bfe6b0 | ||
|
|
1a49ebaa9f | ||
|
|
e4dc1568ce | ||
|
|
1bd0851ee8 | ||
|
|
1b7c2dd056 | ||
|
|
d45c12b6c9 | ||
|
|
90ae7682ed | ||
|
|
e6af0ad23e | ||
|
|
34674bb180 | ||
|
|
784b711393 | ||
|
|
81a548bcc4 | ||
|
|
fd1750af49 | ||
|
|
2bf2f5d58e | ||
|
|
40811eb8d4 | ||
|
|
2756d12750 | ||
|
|
7839993fe7 | ||
|
|
47a4a9992c | ||
|
|
d75dd2ab1c | ||
|
|
6e665708fc | ||
|
|
d3830e622f | ||
|
|
0538676aa3 | ||
|
|
4c9f41f1ad | ||
|
|
e588ddb5d6 | ||
|
|
f3ec8693e3 | ||
|
|
e9b09faab2 | ||
|
|
5ea6148362 | ||
|
|
9e0d7bddc0 | ||
|
|
aa0a57fd56 | ||
|
|
d86c70af96 | ||
|
|
4538c269d0 | ||
|
|
446eb11cde | ||
|
|
fa1375c09f | ||
|
|
f141e9b37a | ||
|
|
3fba377ddd | ||
|
|
01a4752503 | ||
|
|
d66cbf20f7 | ||
|
|
7e4314eccb | ||
|
|
7c71c3e27d | ||
|
|
5eeee39cc1 | ||
|
|
796974ddf6 | ||
|
|
75f5b3dab6 | ||
|
|
9f330897a8 | ||
|
|
710eeb2a33 | ||
|
|
3493b7dac7 | ||
|
|
d51b4f92d7 | ||
|
|
3d8a8ea0c6 | ||
|
|
2057812c8f | ||
|
|
13360ad541 | ||
|
|
9389cfbec9 | ||
|
|
7be152412e | ||
|
|
d0fa48db1e | ||
|
|
884a21d0f5 | ||
|
|
21bca549d3 | ||
|
|
bda970b3b1 | ||
|
|
75ec17f0b5 | ||
|
|
d62121e7bb | ||
|
|
06d101657f | ||
|
|
2f7ffab0e8 | ||
|
|
3ed5e56a39 | ||
|
|
a0802dd486 | ||
|
|
f2675cdf04 | ||
|
|
e3864c383f | ||
|
|
25c0dc5e6e | ||
|
|
8954d01f96 | ||
|
|
b2fe9bff3f | ||
|
|
a36da3a878 | ||
|
|
c103f2fbcb | ||
|
|
aa4920fea3 | ||
|
|
5532766b19 | ||
|
|
5dbf3cb036 | ||
|
|
ddf929390e | ||
|
|
23519fc0b4 | ||
|
|
04288fcd4c | ||
|
|
84c22d053b | ||
|
|
7581762c8e | ||
|
|
7673732c0f | ||
|
|
2dfd3fbd71 | ||
|
|
3a13e066ba | ||
|
|
bcd9bcae2a | ||
|
|
939f796f08 | ||
|
|
27364345bf | ||
|
|
35c19ffc28 | ||
|
|
b0b5cad496 | ||
|
|
965edf8a5c | ||
|
|
1c271852fc | ||
|
|
7ea560261c | ||
|
|
304ea079d2 | ||
|
|
c190c73240 | ||
|
|
e8567098a4 | ||
|
|
a9ebb62d54 | ||
|
|
bdea2f9eda | ||
|
|
f5b041e394 | ||
|
|
e496a548d7 | ||
|
|
3d39b18e31 | ||
|
|
a96a8a1aab | ||
|
|
064124cc5f | ||
|
|
7af5fec038 | ||
|
|
f884fff869 | ||
|
|
c7a121cfc0 | ||
|
|
777be296ee | ||
|
|
a0172a6ae5 | ||
|
|
1099442c0a | ||
|
|
18989cd430 | ||
|
|
828145456c | ||
|
|
097a046e4a | ||
|
|
3977dba761 | ||
|
|
a41cd8d75b | ||
|
|
662d471215 | ||
|
|
06b5805479 | ||
|
|
d6debc21c7 | ||
|
|
ddb52a2b15 | ||
|
|
13441e8cb8 | ||
|
|
a97d5b8e60 | ||
|
|
399d7380a5 | ||
|
|
c231381aa3 | ||
|
|
c30d60f7ae | ||
|
|
9fb9f78e43 | ||
|
|
a0cf65db77 | ||
|
|
2ee9c4df12 | ||
|
|
e6c77e7afb | ||
|
|
76cb088d16 | ||
|
|
907ad00300 | ||
|
|
88a4da9747 | ||
|
|
25c430b1cd | ||
|
|
772d61f3ed | ||
|
|
5b1cf02f2e | ||
|
|
66f4c60a84 | ||
|
|
fce095665c | ||
|
|
2555ac58cc | ||
|
|
e323101ede | ||
|
|
ce52e45d44 | ||
|
|
4f3c31a6b6 | ||
|
|
70bc8ef845 | ||
|
|
cd60e57b6a | ||
|
|
3d2b7d5bce | ||
|
|
04f54ab38f | ||
|
|
46c7dbef0f | ||
|
|
11b90bc959 | ||
|
|
792e2856c9 | ||
|
|
d89b35e682 | ||
|
|
a46ccbd883 | ||
|
|
5dda1abc32 | ||
|
|
55640a31b3 | ||
|
|
88428cff3a | ||
|
|
c24b58e2ee | ||
|
|
9e537c808b | ||
|
|
2c4543b9e9 | ||
|
|
b58bca9a72 | ||
|
|
27dcf470dc | ||
|
|
caa8290510 | ||
|
|
7f9b225cc2 | ||
|
|
4ccb2e2c21 | ||
|
|
cbee283c26 | ||
|
|
9fcda95a6f | ||
|
|
7ada64d5f8 | ||
|
|
20f0d917be | ||
|
|
e312db1408 | ||
|
|
743bd1275f | ||
|
|
69c86379e3 | ||
|
|
46b3c1a025 | ||
|
|
3ea893464f | ||
|
|
738e789dbd | ||
|
|
66afcf5be0 | ||
|
|
4b0ed56e32 | ||
|
|
dc2af8347b | ||
|
|
64ea8829af | ||
|
|
629cfec8a3 | ||
|
|
7f63658709 | ||
|
|
5e4d9a3197 | ||
|
|
982354765b | ||
|
|
5fe0576dcb | ||
|
|
1b083aa0fd | ||
|
|
399a15b9fc | ||
|
|
dfac36b6c3 | ||
|
|
771d7db3a6 | ||
|
|
00af2df102 | ||
|
|
be390c1991 | ||
|
|
2fd0cb7600 | ||
|
|
5f5d413408 | ||
|
|
972da2d498 | ||
|
|
e44bd9f750 | ||
|
|
777edd0269 | ||
|
|
855d6fe1fe | ||
|
|
b625ad6d8b | ||
|
|
97b5df35b1 | ||
|
|
7a87c7eff6 | ||
|
|
f90eb43fcb | ||
|
|
a09d8e88fc | ||
|
|
b5fda7ad2a | ||
|
|
58bb6f8c56 | ||
|
|
673eb160d4 | ||
|
|
e97e0d7e54 | ||
|
|
4119c476aa | ||
|
|
e2295014d9 | ||
|
|
43fb9835fa | ||
|
|
599dd2a560 | ||
|
|
d28a39d01d | ||
|
|
270d90ce1e | ||
|
|
0c969a7dfd | ||
|
|
111d993e75 | ||
|
|
0ef24f9912 | ||
|
|
87fe1c0b0e | ||
|
|
114d822d27 | ||
|
|
88b92df849 | ||
|
|
e4c0730bf1 | ||
|
|
8a40e10d55 | ||
|
|
e0961dfdf4 | ||
|
|
446fb0cb9c | ||
|
|
6fee3e9e4b | ||
|
|
748acdc77c | ||
|
|
410a3abbef | ||
|
|
304336a591 | ||
|
|
35452b3e55 | ||
|
|
ebd9c615c8 | ||
|
|
e9cef8bf30 | ||
|
|
e85f764f23 | ||
|
|
e2e85650ac | ||
|
|
2c14a771a8 | ||
|
|
d39b1a87a5 | ||
|
|
62db3c8efe | ||
|
|
efa06643b0 | ||
|
|
14fad6a5cc | ||
|
|
c71844de63 | ||
|
|
a05b8c4143 | ||
|
|
20636d956d | ||
|
|
66edb3392b | ||
|
|
86adcd4b26 | ||
|
|
a60687f9ba | ||
|
|
bb8457b166 | ||
|
|
3eae71b5b2 | ||
|
|
8094e82287 | ||
|
|
1ec4354998 | ||
|
|
ac1fe83596 | ||
|
|
c7d1849e1c | ||
|
|
7f191c7951 | ||
|
|
702ab8bab0 | ||
|
|
eaaeb28cda | ||
|
|
295d86911e | ||
|
|
c519f9a84c | ||
|
|
2243cfbe75 | ||
|
|
d644e5143f | ||
|
|
58932295fc | ||
|
|
8478895eeb | ||
|
|
8a6fbfa148 | ||
|
|
a1722d5c2e | ||
|
|
0ff9275ad7 | ||
|
|
d1e6ce2672 | ||
|
|
0ccd84d2ef | ||
|
|
29613f2f31 | ||
|
|
8c545bbfa8 | ||
|
|
f19836550b | ||
|
|
79f5fe6f5b | ||
|
|
2f5fa4ee9d | ||
|
|
db66d85176 | ||
|
|
f0efa576e0 | ||
|
|
ad5df9bc2f | ||
|
|
22a2949bd2 | ||
|
|
67b4d5b609 | ||
|
|
ad760b3bf7 | ||
|
|
8d59b189cc | ||
|
|
306a3b8d80 | ||
|
|
041a911c43 | ||
|
|
10682b9e7e | ||
|
|
c5504af4a6 | ||
|
|
49ac5b5fe0 | ||
|
|
d4785fe798 | ||
|
|
3d24c75d0f | ||
|
|
78543cce30 | ||
|
|
55bf2ecc68 | ||
|
|
51ac2a3202 | ||
|
|
48291f0eeb | ||
|
|
d5139d1401 | ||
|
|
3665be7c44 | ||
|
|
801d64a16e | ||
|
|
dd46c95e23 | ||
|
|
4920306486 | ||
|
|
66414029a1 | ||
|
|
51d989f5df | ||
|
|
c982279950 | ||
|
|
0c0953f3bd | ||
|
|
69fe5ca567 | ||
|
|
63b4fd5cac | ||
|
|
dd76497ab0 | ||
|
|
9b7e18f166 | ||
|
|
180faf73af | ||
|
|
6ddb06d372 | ||
|
|
69d97f6d4b | ||
|
|
f5de847a0c | ||
|
|
6bdc947f6b | ||
|
|
919bde7cb1 | ||
|
|
3d974b7267 | ||
|
|
c5ad47ee7c | ||
|
|
4d38b6d1fa | ||
|
|
9e879b4aab | ||
|
|
99934bf998 | ||
|
|
8840f2d629 | ||
|
|
d32a546d6e | ||
|
|
8aa40ec1c7 | ||
|
|
543420ccd2 | ||
|
|
064022548b | ||
|
|
7c00950967 | ||
|
|
b5516771d3 | ||
|
|
7b4084a15a | ||
|
|
412ac6bc3a | ||
|
|
a6ad44f111 | ||
|
|
97620bb5be | ||
|
|
49ed75d883 | ||
|
|
c41d92d27a | ||
|
|
a060aa2bf0 | ||
|
|
2ac6501698 | ||
|
|
06ac399ce6 | ||
|
|
dde5d49a5e | ||
|
|
89d3f13945 | ||
|
|
f47a063841 | ||
|
|
e964ff70e6 | ||
|
|
bc3580fa06 | ||
|
|
7fd4d49d56 | ||
|
|
ec75f9d1a3 | ||
|
|
6405fceee2 | ||
|
|
f9e46a373f | ||
|
|
d05debbe19 | ||
|
|
f8c86a9515 | ||
|
|
2c9cddd876 | ||
|
|
aaeee34c32 | ||
|
|
70397e4a95 | ||
|
|
43d904dbf3 | ||
|
|
1da64bf786 | ||
|
|
1cb1fb5bd4 | ||
|
|
208881a735 | ||
|
|
a2f52d4224 | ||
|
|
2ccb67cae4 | ||
|
|
b2a61348dd | ||
|
|
234f6d27c1 | ||
|
|
f339cfd315 | ||
|
|
c5239c5984 | ||
|
|
be13479f09 | ||
|
|
69a8d64716 | ||
|
|
3964309c67 | ||
|
|
243244d285 | ||
|
|
497b27dafb | ||
|
|
ca6d9f799e | ||
|
|
f1aa5f6a1d | ||
|
|
dc50de782a | ||
|
|
2e85eeea37 | ||
|
|
357da035b9 | ||
|
|
5aa54c863d | ||
|
|
42735d446e | ||
|
|
57eb334d5b | ||
|
|
5f904aa350 | ||
|
|
ee0f8adfac | ||
|
|
1ed37385c6 | ||
|
|
3a2e9d805a | ||
|
|
911ef4e69a | ||
|
|
1994ae4640 | ||
|
|
dbd8e47846 | ||
|
|
ce7bf1083e | ||
|
|
1db4ec6e63 | ||
|
|
1c82cf7660 | ||
|
|
e43fc6f08a | ||
|
|
31407b70e0 | ||
|
|
7d3c1016ce | ||
|
|
4c9f9438ff | ||
|
|
374dae6635 | ||
|
|
8c50f625b0 | ||
|
|
6fc96978c2 | ||
|
|
8e3767e344 | ||
|
|
b8b5631d9d | ||
|
|
c577b47cd5 | ||
|
|
cb6f36655e | ||
|
|
7905f4600d | ||
|
|
41c39e9bd9 | ||
|
|
f81d723264 | ||
|
|
afd5e978cf | ||
|
|
e68b9abd04 | ||
|
|
e487b87f6f | ||
|
|
1e20153b6e | ||
|
|
4621a52183 | ||
|
|
e90a742db8 | ||
|
|
b219d54503 | ||
|
|
3108d80b7e | ||
|
|
8a7d463b87 | ||
|
|
c3859d1df1 | ||
|
|
5a5e285be8 | ||
|
|
4d1d4d6e8e | ||
|
|
a96dd1932a | ||
|
|
693244795c | ||
|
|
255a4f8ce3 | ||
|
|
e2b26d910c | ||
|
|
293e331d69 | ||
|
|
2a91025581 | ||
|
|
37d34b6b83 | ||
|
|
44452823b7 | ||
|
|
e4bb87032e | ||
|
|
a6c4c2cca0 | ||
|
|
ba3b8ccc1d | ||
|
|
e5eee7de0c | ||
|
|
d8261019f1 | ||
|
|
9d165df18a | ||
|
|
7d1a8f7e9e | ||
|
|
8df3ec612a | ||
|
|
4c91c153cb | ||
|
|
cf2c0237f4 | ||
|
|
3d9fd1c7f2 | ||
|
|
d1e8fb33da | ||
|
|
1e3a4f2331 | ||
|
|
2ac1d46f46 | ||
|
|
77a2174685 | ||
|
|
3e270af17a | ||
|
|
10db7ec51b | ||
|
|
4f01bfc4bc | ||
|
|
1d591ada76 | ||
|
|
2bdc59fac8 | ||
|
|
784a74df0b | ||
|
|
82355d2f2d | ||
|
|
97a99d8718 | ||
|
|
755d4863c8 | ||
|
|
28544391f5 | ||
|
|
931b0103cd | ||
|
|
6e03b50771 | ||
|
|
362c460767 | ||
|
|
f4c815a1d9 | ||
|
|
fc6f08d5b7 | ||
|
|
68e370574a | ||
|
|
544c80d715 | ||
|
|
36fe146a74 | ||
|
|
caa29af2a9 | ||
|
|
0f31d231db | ||
|
|
102cb77435 | ||
|
|
7360ff4496 | ||
|
|
a6fd92bd8d | ||
|
|
06ac4b628d | ||
|
|
6c53a1ed68 | ||
|
|
6ad2c5c40f | ||
|
|
99cc0015f8 | ||
|
|
f1ce95915c | ||
|
|
aadc87f5a7 | ||
|
|
4d382ae8e6 | ||
|
|
418ba99078 | ||
|
|
648ce2f56a | ||
|
|
0648c58716 | ||
|
|
01da28efb1 | ||
|
|
6d6e1581b5 | ||
|
|
64da762c15 | ||
|
|
8903c1f167 | ||
|
|
a5521597b0 | ||
|
|
fe00607816 | ||
|
|
6e6d756109 | ||
|
|
85531fd404 | ||
|
|
c4c98df4f2 | ||
|
|
a3f4eb7b24 | ||
|
|
fdbfc7e349 | ||
|
|
c2e2107063 | ||
|
|
2ca8b7f359 | ||
|
|
3a09e01a8e | ||
|
|
d31315884c | ||
|
|
57ca428975 | ||
|
|
b0e2ef1a7d | ||
|
|
b237d9dd95 | ||
|
|
de194016ec | ||
|
|
e33ba57c13 | ||
|
|
44f8e1caff | ||
|
|
bc2e4a36df | ||
|
|
675c6b3773 | ||
|
|
f4472c16b2 | ||
|
|
854e8ae04d | ||
|
|
3e6d45acf6 | ||
|
|
a2c8af97e9 | ||
|
|
b18ff67646 | ||
|
|
6a5adfc0ba | ||
|
|
9714880283 | ||
|
|
3a0016a78a | ||
|
|
fb83914bd7 | ||
|
|
d5de489dc4 | ||
|
|
3fa4f691e3 | ||
|
|
8600fe054b | ||
|
|
8378be03d1 | ||
|
|
51a1dbfe09 | ||
|
|
8264e92b37 | ||
|
|
739a76634c | ||
|
|
47c097cb51 | ||
|
|
24d7d073ff | ||
|
|
39631edb98 | ||
|
|
9b8998aeec | ||
|
|
4aa4e9fb26 | ||
|
|
1fcc7f50ac | ||
|
|
6ef4f8e16c | ||
|
|
93224260ae | ||
|
|
991bfcf443 | ||
|
|
d762ced298 | ||
|
|
1bc910a963 | ||
|
|
63f451965c | ||
|
|
260419f48e | ||
|
|
c04aa90207 | ||
|
|
0679eb6a6d | ||
|
|
9a7e5bd1d3 | ||
|
|
827b311c81 | ||
|
|
e4679172e3 | ||
|
|
be10e8eee6 | ||
|
|
cb4553bd06 | ||
|
|
c68efec6c0 | ||
|
|
a75801320d | ||
|
|
241a746f32 | ||
|
|
47fbf87185 | ||
|
|
d210d99cce | ||
|
|
31f93d8445 | ||
|
|
2a609b332f | ||
|
|
18236c1c1b | ||
|
|
596e9d8068 | ||
|
|
589b4b8c6a | ||
|
|
60808bbded | ||
|
|
d4dc52ec84 | ||
|
|
c695c0c085 | ||
|
|
a91c598971 | ||
|
|
bf45619441 | ||
|
|
9b2aabb752 | ||
|
|
c0fb5edff9 | ||
|
|
5cdc9591d3 | ||
|
|
2b5c3fc49f | ||
|
|
b4ad1759b8 | ||
|
|
6589120667 | ||
|
|
0cdcae3532 | ||
|
|
0e87430462 | ||
|
|
43d2b6a648 | ||
|
|
8249fbfb60 | ||
|
|
3a545376f0 | ||
|
|
5cc9380bfa | ||
|
|
ca84659ca1 | ||
|
|
8dc78377d1 | ||
|
|
64deb34c3b | ||
|
|
8b05d84ece | ||
|
|
619ffe1f4f | ||
|
|
9107b0c69a | ||
|
|
ea289bc457 | ||
|
|
9763282dc1 | ||
|
|
44dccf7ea2 | ||
|
|
80b5c0e076 | ||
|
|
7a3ec77dbd | ||
|
|
48750022c0 | ||
|
|
ce0b285aad | ||
|
|
17bbf90393 | ||
|
|
0d0b3cf9a4 | ||
|
|
149f5bac05 | ||
|
|
253f1395a0 | ||
|
|
e342304134 | ||
|
|
d785c37ee2 | ||
|
|
69683ba7b4 | ||
|
|
7b189f1ad7 | ||
|
|
84612a8196 | ||
|
|
5d60bc7f7c | ||
|
|
42272dfbd5 | ||
|
|
5b85efeb93 | ||
|
|
eb0ad181e9 | ||
|
|
dc3df931d7 | ||
|
|
d3d48fa3e7 | ||
|
|
73f29094d0 | ||
|
|
a043b975ca | ||
|
|
68cc635ed5 | ||
|
|
b2a9f4115f | ||
|
|
b433886840 | ||
|
|
248cd423a1 | ||
|
|
b79f86e32a | ||
|
|
40505e59f1 | ||
|
|
a1cd0eee1b | ||
|
|
c914fcfacb | ||
|
|
4d7967de7a | ||
|
|
28fd3a3835 | ||
|
|
996a636713 | ||
|
|
41a448193f | ||
|
|
0304555184 | ||
|
|
f536dc47c4 | ||
|
|
d6066552ee | ||
|
|
59c760dfcd | ||
|
|
c06b2e4fb9 | ||
|
|
1f29f6ac4d | ||
|
|
3ad812cbd5 | ||
|
|
53c430eced | ||
|
|
6307d63715 | ||
|
|
4f8a6867fa | ||
|
|
9e7bbc7281 | ||
|
|
c96a2a3c9e | ||
|
|
7263fa36eb | ||
|
|
adc9fad4ac | ||
|
|
9247c90d69 | ||
|
|
a679a4a708 | ||
|
|
2e43372d0b | ||
|
|
473911fb73 | ||
|
|
686d461144 | ||
|
|
554f19eb05 | ||
|
|
fc8d3f7a56 | ||
|
|
56e37487a8 | ||
|
|
674545f7e6 | ||
|
|
35690fb3a5 | ||
|
|
1c608031b5 | ||
|
|
84a4007b06 | ||
|
|
753775033a | ||
|
|
d39c58c01c | ||
|
|
58e8e0eac8 | ||
|
|
d50f157f7e | ||
|
|
a1e4908ed7 | ||
|
|
f61fc576d9 | ||
|
|
73c6785538 | ||
|
|
6804d5841e | ||
|
|
96aaa87df6 | ||
|
|
454e7d9c3a | ||
|
|
db27dc82f0 | ||
|
|
061027fefc | ||
|
|
45d68963ab | ||
|
|
200b0e5821 | ||
|
|
30b801decf | ||
|
|
ca3f92e78c | ||
|
|
c8849ac990 | ||
|
|
44307712ed | ||
|
|
20129b7bf9 | ||
|
|
a194430e5d | ||
|
|
cf2e65c0e2 | ||
|
|
8889a48f9b | ||
|
|
a3dec6bece | ||
|
|
ff4097e02c | ||
|
|
c081af2963 | ||
|
|
89a96b05fa | ||
|
|
5385a9bb34 | ||
|
|
d697b5ef20 | ||
|
|
81858d7891 | ||
|
|
7a583b1e54 | ||
|
|
35a8a61254 | ||
|
|
513bd8f62d | ||
|
|
1f5e6e35d5 | ||
|
|
a432fcd306 | ||
|
|
06d27e94b2 | ||
|
|
188be9718e | ||
|
|
bbd3e822c7 | ||
|
|
45a2e2d6c6 | ||
|
|
a10143a2d1 | ||
|
|
38530de622 | ||
|
|
f040bc249f | ||
|
|
ede8312d59 | ||
|
|
df912e3540 | ||
|
|
3886f60671 | ||
|
|
a3391692ad | ||
|
|
91f54b59ac | ||
|
|
b0f4f94b5b | ||
|
|
f20c6fe009 | ||
|
|
191a92c0c6 | ||
|
|
adba3d35b1 | ||
|
|
63f5c38023 | ||
|
|
7e02d2f459 | ||
|
|
5761712799 | ||
|
|
9bb97522d5 | ||
|
|
f4053bc217 | ||
|
|
67b926cf3c | ||
|
|
5b6f78186c | ||
|
|
39abca401a | ||
|
|
a7917430d8 | ||
|
|
202c04414c | ||
|
|
bc47596313 | ||
|
|
dfc845e7f9 | ||
|
|
0159c74a32 | ||
|
|
a401420273 | ||
|
|
fce30422f3 | ||
|
|
2a36a0a067 | ||
|
|
1c15848c47 | ||
|
|
4a634a7da4 | ||
|
|
576f2694b1 | ||
|
|
0f00c3b47a | ||
|
|
2942eca895 | ||
|
|
7c39850d1f | ||
|
|
a13b4a819a | ||
|
|
a4a2c68fa9 | ||
|
|
2113115cdd | ||
|
|
038e8b770d | ||
|
|
04ac61ecd7 | ||
|
|
eed7d9b473 | ||
|
|
021e95b09f | ||
|
|
bf4b02cea2 | ||
|
|
e96d514247 | ||
|
|
bcda6eed63 | ||
|
|
2e3a260315 | ||
|
|
b24829a99c | ||
|
|
7c7bd14c61 | ||
|
|
30b23baaf5 | ||
|
|
169d362945 | ||
|
|
c6fc8771a9 | ||
|
|
626c8aa8e7 | ||
|
|
db20f2d907 | ||
|
|
63d109fb7f | ||
|
|
226f9fa012 | ||
|
|
f51c55c3f0 | ||
|
|
fbf2bd865c | ||
|
|
1845800651 | ||
|
|
993f1b96a3 | ||
|
|
196710e2d3 | ||
|
|
ed85c5a198 | ||
|
|
1f23f6d686 | ||
|
|
17da2f7d5f | ||
|
|
fff7c0b276 | ||
|
|
5cc4961fd2 | ||
|
|
baafc17a1e | ||
|
|
49b2a255b6 | ||
|
|
d9cb07df3b | ||
|
|
a97f22ff2b | ||
|
|
ffab6dbc9a | ||
|
|
04bf0d8efc | ||
|
|
3604b31b6f | ||
|
|
84c708f355 | ||
|
|
fe4f00834d | ||
|
|
ebf94bc9cb | ||
|
|
682884edc5 | ||
|
|
82b053a811 | ||
|
|
2f93affb98 | ||
|
|
243d12752c | ||
|
|
7a4679a17f | ||
|
|
d61c572c92 | ||
|
|
cae8d02b2e | ||
|
|
ac7e2f13e9 | ||
|
|
50cefec497 | ||
|
|
1340c012b0 | ||
|
|
2f0db58777 | ||
|
|
470f521410 | ||
|
|
8f29eeaae6 | ||
|
|
f2f9bc0181 | ||
|
|
5f92f62ac3 | ||
|
|
673b1abe5f | ||
|
|
37f9bb46d8 | ||
|
|
218b692221 | ||
|
|
96a34a0c0a | ||
|
|
132403b6be | ||
|
|
3e6454f2d6 | ||
|
|
f66b105c21 | ||
|
|
b74b875f25 | ||
|
|
e79c647052 | ||
|
|
b728970c65 | ||
|
|
e45dc6ae59 | ||
|
|
d0907861f9 | ||
|
|
cc979bda0f | ||
|
|
a6c22d650b | ||
|
|
e60f48ab09 | ||
|
|
ff5155f719 | ||
|
|
714416074a | ||
|
|
bea5155fee | ||
|
|
995c9a50ab | ||
|
|
c8c6a23d66 | ||
|
|
6df8953f4f | ||
|
|
00e2e35740 | ||
|
|
31cf5314ee | ||
|
|
bdfbb52951 | ||
|
|
94795eb48e | ||
|
|
d3e432069b | ||
|
|
0f9e0d1cfe | ||
|
|
48e6ebbe1e | ||
|
|
e02d1bce98 | ||
|
|
ed58b2d353 | ||
|
|
5cbca2e70f | ||
|
|
e8dff68588 | ||
|
|
e65c5ad56c | ||
|
|
bae2701289 | ||
|
|
c6e0af9bdb | ||
|
|
6703ca8d26 | ||
|
|
ce67a44a94 | ||
|
|
14e5cdf02e | ||
|
|
21f62c2cee | ||
|
|
bd6153195f | ||
|
|
e5b3858944 | ||
|
|
09e6b7c137 | ||
|
|
36ece3fcf5 | ||
|
|
f99de22808 | ||
|
|
b58d7f78a1 | ||
|
|
2ce636a315 | ||
|
|
2c4e8b92ab | ||
|
|
86c1335452 | ||
|
|
631d6b59fd | ||
|
|
ed54f01d2f | ||
|
|
711d2205dd | ||
|
|
18d3498fb2 | ||
|
|
c829bdf537 | ||
|
|
20d10c608d | ||
|
|
e1273fb6a1 | ||
|
|
85f5485cb5 | ||
|
|
b831f86354 | ||
|
|
c11da7ca88 | ||
|
|
f881ff1c18 | ||
|
|
cd8e536c43 | ||
|
|
58e5442d37 | ||
|
|
faf51d748e | ||
|
|
407f66ccbc | ||
|
|
bfc9f475c6 | ||
|
|
8121b541e0 | ||
|
|
65748fb197 | ||
|
|
37e5b5d947 | ||
|
|
8ff20a5c6d | ||
|
|
f9f6eea444 | ||
|
|
621fa0a686 | ||
|
|
0edaa34bfd | ||
|
|
c0cfbe12e4 | ||
|
|
7c9d003e99 | ||
|
|
49ce38b09a | ||
|
|
b1e4b8769b | ||
|
|
90bf560fe4 | ||
|
|
5672f2ce6b | ||
|
|
01f2b5d64b | ||
|
|
f59971276a | ||
|
|
2e2c9bd623 | ||
|
|
bf9e7a1c68 | ||
|
|
df31f1dfc9 | ||
|
|
0f9f30de2e | ||
|
|
f41efd9d89 | ||
|
|
ba7278373d | ||
|
|
e4eb43ec71 | ||
|
|
dc83ba0372 | ||
|
|
cf8faa3b33 | ||
|
|
68ba5377e3 | ||
|
|
be4d77e60f | ||
|
|
bde45cdd9c | ||
|
|
a7c615a794 | ||
|
|
92c522228b | ||
|
|
3a902f4196 | ||
|
|
0987d55231 | ||
|
|
5aa28473dd | ||
|
|
21ab66569c | ||
|
|
070d266aae | ||
|
|
3b990ef6b2 | ||
|
|
e920fa3e36 | ||
|
|
84207f06b7 | ||
|
|
c7f078dcbc | ||
|
|
3893cc17a4 | ||
|
|
4d1c513968 | ||
|
|
14d6a4ab26 | ||
|
|
e678ba3943 | ||
|
|
166681eee9 | ||
|
|
1fdac2adf1 | ||
|
|
40b1d64ce7 | ||
|
|
d8805af66b | ||
|
|
46210344a6 | ||
|
|
4f480c901d | ||
|
|
50f5d2a7ec | ||
|
|
95f48a219a | ||
|
|
87d092d226 | ||
|
|
e87d4b43ab | ||
|
|
f152379e5a | ||
|
|
889fe42e11 | ||
|
|
164e85cca7 | ||
|
|
0b34fefe6e | ||
|
|
928f40615c | ||
|
|
7ad052583a | ||
|
|
d3c842d367 | ||
|
|
a597e3546c | ||
|
|
0489213b1b | ||
|
|
9b8fc982ec | ||
|
|
92a720157b | ||
|
|
c8c0d68128 | ||
|
|
523ed3873d | ||
|
|
005566f915 | ||
|
|
698361ccde | ||
|
|
71df37c247 | ||
|
|
21c11c7f48 | ||
|
|
4e05a2c0ae | ||
|
|
575bfa4b4b | ||
|
|
31ddae7735 | ||
|
|
33fac234c0 | ||
|
|
1bbb793263 | ||
|
|
799f437eff | ||
|
|
be63fef872 | ||
|
|
ac9ebc29a2 | ||
|
|
3307813a07 | ||
|
|
3d98adaf91 | ||
|
|
cf11809cd4 | ||
|
|
32a6092f71 | ||
|
|
e7c7024907 | ||
|
|
3275e9bd5b | ||
|
|
9d79a56402 | ||
|
|
18012f5b18 | ||
|
|
03dca66ae2 | ||
|
|
178a20718c | ||
|
|
30f4c30ca3 | ||
|
|
8b68ea1462 | ||
|
|
f4fdddc930 | ||
|
|
e4f1fbd008 | ||
|
|
89ab147093 | ||
|
|
95f427c34e | ||
|
|
e0d2221879 | ||
|
|
4b8bb7770f | ||
|
|
07ac16807f | ||
|
|
82f4db0d10 | ||
|
|
4d9ccd3229 | ||
|
|
b801118fe5 | ||
|
|
952ffdd288 | ||
|
|
4e7de210e4 | ||
|
|
aaf0bfccf4 | ||
|
|
a870a596bc | ||
|
|
88f25bb677 | ||
|
|
290636bc86 | ||
|
|
3e94fa70f9 | ||
|
|
cfa6ac9161 | ||
|
|
6e6e8046ba | ||
|
|
d7ea1ac847 | ||
|
|
fe055c89f5 | ||
|
|
fddbd44c18 | ||
|
|
67949de0a1 | ||
|
|
3f49137f90 | ||
|
|
fe7cf0ba90 | ||
|
|
94e46dd724 | ||
|
|
c82e06804e | ||
|
|
509a7e8b73 | ||
|
|
98e24b9f70 | ||
|
|
0fd0030a2a | ||
|
|
4bb01c1768 | ||
|
|
efb639e1d2 | ||
|
|
8363d19307 | ||
|
|
fdeaa73342 | ||
|
|
d1ae2d9757 | ||
|
|
908a22e41c | ||
|
|
c2176afe9c | ||
|
|
6b3988b749 | ||
|
|
896c55291f | ||
|
|
2ee0d851d9 | ||
|
|
c08a532440 | ||
|
|
49a5a587ec | ||
|
|
677ed3e5f0 | ||
|
|
f188345b33 | ||
|
|
0e59bc75fd | ||
|
|
937173ff11 | ||
|
|
e4a7cefe0c | ||
|
|
e23df3af5a | ||
|
|
9c1d3046ca | ||
|
|
c846298747 | ||
|
|
230d0fbc9e | ||
|
|
9bbc63ed65 | ||
|
|
ad2cc63412 | ||
|
|
a7a44bfcd9 | ||
|
|
d2d2df1365 | ||
|
|
224255cb89 | ||
|
|
74b2eaa73e | ||
|
|
e254aeb9f9 | ||
|
|
1d4c54717c | ||
|
|
30b816f101 | ||
|
|
9803aee98e | ||
|
|
a34a72d2d9 | ||
|
|
4d80980e50 | ||
|
|
85152ef35c | ||
|
|
678e67437f | ||
|
|
b92e81a1aa | ||
|
|
ebce251183 | ||
|
|
e870a3f3ec | ||
|
|
a3c1b730c9 | ||
|
|
a7b0b30bdd | ||
|
|
d4c2a935f2 | ||
|
|
cc967ffeb9 | ||
|
|
4bea559037 | ||
|
|
674de910ca | ||
|
|
8ed9124f3f | ||
|
|
535286c05a | ||
|
|
7f24020cbe | ||
|
|
be7b56a613 | ||
|
|
66f04514cf | ||
|
|
cd10f7322a | ||
|
|
5434a2759a | ||
|
|
b7551c9193 | ||
|
|
d4312281da | ||
|
|
d9eb34b28d | ||
|
|
b79189958f | ||
|
|
ad5c4e719b | ||
|
|
db7570daab | ||
|
|
8332413305 | ||
|
|
8cf19ab770 | ||
|
|
199d148740 | ||
|
|
dcad13155b | ||
|
|
e6519d3e27 | ||
|
|
299a8fd4a3 | ||
|
|
60069fe8fe | ||
|
|
d817f88fec | ||
|
|
eeaf92ad06 | ||
|
|
16f9667620 | ||
|
|
90b331ea46 | ||
|
|
e2d59a6c17 | ||
|
|
2ca1849350 | ||
|
|
e210abf335 | ||
|
|
f9b4095188 | ||
|
|
d1f0138653 | ||
|
|
92aef64c5a | ||
|
|
fdd1d0b72e | ||
|
|
d377a68593 | ||
|
|
5db593e5c2 | ||
|
|
d71e4b9aca | ||
|
|
9e7ec2e971 | ||
|
|
3a9a24a7c0 | ||
|
|
da145e7c20 | ||
|
|
d655566ce7 | ||
|
|
c1b9948525 | ||
|
|
f308ba93aa | ||
|
|
76862acf3e | ||
|
|
f308663ad4 | ||
|
|
876f46abb9 | ||
|
|
620a87db25 | ||
|
|
e04d13f6a6 | ||
|
|
c44d2d854f | ||
|
|
31f13e49d8 | ||
|
|
2397083f7e | ||
|
|
08014af243 | ||
|
|
774bffb3c6 | ||
|
|
9c920214e6 | ||
|
|
5cc3d50289 | ||
|
|
9ec457575d | ||
|
|
fc5f8804ec | ||
|
|
fd25d35868 | ||
|
|
7c9bc377a3 | ||
|
|
57df442916 | ||
|
|
398af28d2a | ||
|
|
8798079ab0 | ||
|
|
c26ec766cb | ||
|
|
c3794d4303 | ||
|
|
4fbb296438 | ||
|
|
21128fea1e | ||
|
|
9f738dd2fe | ||
|
|
693c106a1d | ||
|
|
6c1c304fc3 | ||
|
|
e5bf63cb59 | ||
|
|
046d8b096f | ||
|
|
0cbab892d5 | ||
|
|
b44f78fe9f | ||
|
|
3f5ec24b5a | ||
|
|
d8d9c2af98 | ||
|
|
e5d6df8979 | ||
|
|
cf317412d9 | ||
|
|
b2ee98b8d7 | ||
|
|
5213d9674b | ||
|
|
0ff42d975b | ||
|
|
5ed3daf28b | ||
|
|
f5a73c5433 | ||
|
|
0e45ca1718 | ||
|
|
c1eeac86fe | ||
|
|
03ee7f7edf | ||
|
|
a8ca1340ad | ||
|
|
7d169a3679 | ||
|
|
98e500f598 | ||
|
|
1c1797e4f2 | ||
|
|
653d1e2fc8 | ||
|
|
9b48c77493 | ||
|
|
96146a8c6f | ||
|
|
e3225bc4e3 | ||
|
|
f0aad68aee | ||
|
|
7d53e2c946 | ||
|
|
7ff4cf9405 | ||
|
|
179d0686d7 | ||
|
|
b32254acda | ||
|
|
16d75a6bf2 | ||
|
|
e63909655c | ||
|
|
213deb5c66 | ||
|
|
69c1521895 | ||
|
|
6821ccc882 | ||
|
|
17e6dc4405 | ||
|
|
a7341715c1 | ||
|
|
521bf41d12 | ||
|
|
f0c3e9babe | ||
|
|
edd59d9e0f | ||
|
|
326c5bf1b4 | ||
|
|
550906cb09 | ||
|
|
175d82c95b | ||
|
|
49ef0b4af3 | ||
|
|
3740f8f846 | ||
|
|
adfa5050d5 | ||
|
|
f62dcc1ea1 | ||
|
|
b1ed2d5bd9 | ||
|
|
e6a59c4bee | ||
|
|
d6dc4c30f4 | ||
|
|
f14da260c8 | ||
|
|
d635d79042 | ||
|
|
b8ce435a54 | ||
|
|
b6bd9515ea | ||
|
|
6e0c097d9f | ||
|
|
d9807eeba1 | ||
|
|
cb752f9938 | ||
|
|
2e98603db9 | ||
|
|
39628e8280 | ||
|
|
40af1a854c | ||
|
|
fb5b958837 | ||
|
|
99f78340af | ||
|
|
5985143813 | ||
|
|
9800eaa63f | ||
|
|
423649b2c6 | ||
|
|
2888843a18 | ||
|
|
4a5dff3f11 | ||
|
|
4a01da19df | ||
|
|
d390a90bf0 | ||
|
|
c41a93d130 | ||
|
|
0a4fd0f7a4 | ||
|
|
a54e670301 | ||
|
|
4697b35d4f | ||
|
|
0588168a64 | ||
|
|
f01b7191a3 | ||
|
|
029c34ce6b | ||
|
|
47d41d0203 | ||
|
|
2651c0d69c | ||
|
|
87a2a13f68 | ||
|
|
5775074f73 | ||
|
|
abb4af7a14 | ||
|
|
b9bbe1d81c | ||
|
|
3657aa675e | ||
|
|
88e9079870 | ||
|
|
cd62411d78 | ||
|
|
f95f792ddf | ||
|
|
2fc84c7c34 | ||
|
|
6b734d1074 | ||
|
|
e39c5a9e14 | ||
|
|
b2fe881307 | ||
|
|
b6659dc563 | ||
|
|
3ce1b91b1b | ||
|
|
2589d117b0 | ||
|
|
8aec4c93eb | ||
|
|
9960a06a67 | ||
|
|
cf90f2a29c | ||
|
|
cc5bcbfb59 | ||
|
|
be179f6d7e | ||
|
|
0ecb11fe4f | ||
|
|
7d604ab717 | ||
|
|
ee5e97926d | ||
|
|
0252796a57 | ||
|
|
e9ebdac3dd | ||
|
|
5339b8ce3a | ||
|
|
20134fa9f4 | ||
|
|
1f01dd8c0a | ||
|
|
25eb48aea3 | ||
|
|
e5cee89727 | ||
|
|
d86c6b2fff | ||
|
|
5175db270d | ||
|
|
8d63a99390 | ||
|
|
f16b6aeabb | ||
|
|
df69ee07e2 | ||
|
|
31def00f59 | ||
|
|
27bd09f075 | ||
|
|
391f1f08c0 | ||
|
|
8357a55d76 | ||
|
|
5f38f8cd64 | ||
|
|
5ae4b4acc0 | ||
|
|
7e423ea491 | ||
|
|
9dacc1700b | ||
|
|
67e70770c8 | ||
|
|
d5269a2eed | ||
|
|
bcacbb1a89 | ||
|
|
a8e9654b65 | ||
|
|
bba822105b | ||
|
|
dc2c174496 | ||
|
|
2de9b1e005 | ||
|
|
b4b3d9c936 | ||
|
|
6c4166ce20 | ||
|
|
5dad3166f9 | ||
|
|
e80e7b38bb | ||
|
|
26aa0689a5 | ||
|
|
6457052a93 | ||
|
|
d91bf78e8a | ||
|
|
a70379d8f9 | ||
|
|
bc8d09ef84 | ||
|
|
8144e5cb7e | ||
|
|
fce026eb32 | ||
|
|
5e90476b25 | ||
|
|
e097f0b4ee | ||
|
|
ff7343c203 | ||
|
|
3d47b5cd07 | ||
|
|
f12158bc25 | ||
|
|
94f86edfee | ||
|
|
ad60a2c952 | ||
|
|
6ce5ed60a6 | ||
|
|
1202284f37 | ||
|
|
c80f75f4f4 | ||
|
|
4564624f2c | ||
|
|
84aa9c34f8 | ||
|
|
db7d3a3966 | ||
|
|
f513898e92 | ||
|
|
7407459ed1 | ||
|
|
fa0f10d77a | ||
|
|
ddade84e0a | ||
|
|
0503f83c64 | ||
|
|
65177b82be | ||
|
|
1cf916ca73 | ||
|
|
2b60c648c4 | ||
|
|
12544ccd41 | ||
|
|
dac6e55e0a | ||
|
|
f537870909 | ||
|
|
213544a30a | ||
|
|
159faa4ed7 | ||
|
|
f9cb06cf2c | ||
|
|
28427efbac | ||
|
|
e14bf9bb8f | ||
|
|
34e5ec1807 | ||
|
|
d0f362a503 | ||
|
|
480e48aa66 | ||
|
|
70d232289b | ||
|
|
ea6844b5b7 | ||
|
|
def72b2985 | ||
|
|
a0b271a8a0 | ||
|
|
7a529cc32a | ||
|
|
f89d0c3c2c | ||
|
|
4bf85ecbb0 | ||
|
|
cae34a8ce7 | ||
|
|
07377d5a97 | ||
|
|
b5b630229a | ||
|
|
d256660a78 | ||
|
|
b2f301f4e2 | ||
|
|
719755574d | ||
|
|
89f35125b4 | ||
|
|
e7f3be9187 | ||
|
|
240cae4c92 | ||
|
|
1af2021de6 | ||
|
|
3ea5e06bfb | ||
|
|
944b5e6fa0 | ||
|
|
0cad8a5808 | ||
|
|
69e0aabcdf | ||
|
|
3cb428bc7e | ||
|
|
e0fcd3b247 | ||
|
|
21140d426d | ||
|
|
13d5ac6f9e | ||
|
|
1e7cea407d | ||
|
|
bb38112ec8 | ||
|
|
1d2b487c84 | ||
|
|
4efd45628d | ||
|
|
4fcbf4b872 | ||
|
|
96e7f33da3 | ||
|
|
046e8363b4 | ||
|
|
58908fd8c5 | ||
|
|
992dbdedd8 | ||
|
|
d344816d91 | ||
|
|
f702dbfea2 | ||
|
|
fb527c1bad | ||
|
|
75e7c7eed5 | ||
|
|
4b6babcfa2 | ||
|
|
ec3efab01e | ||
|
|
583c885d68 | ||
|
|
acfabf3a50 | ||
|
|
538af37c35 | ||
|
|
6f08472049 | ||
|
|
f3741f0653 | ||
|
|
295ace6820 | ||
|
|
268a2efb16 | ||
|
|
b5812013ef | ||
|
|
a734b41fda | ||
|
|
4846af8f95 | ||
|
|
b0a88ebead | ||
|
|
a70df70d20 | ||
|
|
b1dfc740a3 | ||
|
|
7dddf56c08 | ||
|
|
075816eb72 | ||
|
|
341f67e827 | ||
|
|
38611d3207 | ||
|
|
215ee46106 | ||
|
|
d5150484d1 | ||
|
|
eb288aae32 | ||
|
|
dc8fb9fb23 | ||
|
|
8738141913 | ||
|
|
656a668473 | ||
|
|
3970853feb | ||
|
|
7aafee7e48 | ||
|
|
dc6bd98425 | ||
|
|
34a331aa99 | ||
|
|
6351940744 | ||
|
|
65fc8ef43a | ||
|
|
d5ab166307 | ||
|
|
a6456f4db3 | ||
|
|
dd34cc012a | ||
|
|
0f97ac4221 | ||
|
|
0bb2119781 | ||
|
|
4e75e82cc3 | ||
|
|
2c0846569d | ||
|
|
f4432030ee | ||
|
|
044c0f978f | ||
|
|
afbbdff581 | ||
|
|
cb60ea1bdb | ||
|
|
3aee28c58b | ||
|
|
088232e0e0 | ||
|
|
5e5acbeccd | ||
|
|
3dc7b805d3 | ||
|
|
f0843d2173 | ||
|
|
457147d59d | ||
|
|
735f87bc66 | ||
|
|
98d450ac3a | ||
|
|
48a1169f4e | ||
|
|
75f218dc73 | ||
|
|
0a09d04e1b | ||
|
|
1d00f88757 | ||
|
|
e5f4bf3f3e | ||
|
|
13c54a04a0 | ||
|
|
4e452a2e11 | ||
|
|
ae5954d30a | ||
|
|
01f5f041d3 | ||
|
|
d9cb059e34 | ||
|
|
ec3be580ec | ||
|
|
02462e5e57 | ||
|
|
ffce6b34b2 | ||
|
|
108fb38cbc | ||
|
|
0a2b3492c3 | ||
|
|
8ab7fcf7eb | ||
|
|
129f0dc893 | ||
|
|
2b508f7f6b | ||
|
|
536fc24653 | ||
|
|
ec89eb9552 | ||
|
|
95832241aa | ||
|
|
c8a14def9f | ||
|
|
5d519ba526 | ||
|
|
f16ea60cc0 | ||
|
|
f8a218882a | ||
|
|
f7e9aedf10 | ||
|
|
beb6db9b5f | ||
|
|
25d551e8b2 | ||
|
|
d88c20e718 | ||
|
|
f19a4bf9d1 | ||
|
|
82e0165c49 | ||
|
|
8091dcdd97 | ||
|
|
fa6abac98d | ||
|
|
f8dbfb0aa7 | ||
|
|
b9216d9566 | ||
|
|
71e8e26ccc | ||
|
|
7ce8fee4f3 | ||
|
|
808502ac3d | ||
|
|
d74e5bffba | ||
|
|
a9eb5e12ec | ||
|
|
164c2cbcb0 | ||
|
|
20e17604b5 | ||
|
|
a0295b4c2f | ||
|
|
9bc44043a4 | ||
|
|
d0cca3924e | ||
|
|
54456d5602 | ||
|
|
0a404aabd3 | ||
|
|
79e30daeae | ||
|
|
34bb013b92 | ||
|
|
d5ed5fb08f | ||
|
|
4cb976b408 | ||
|
|
c0888f3fd1 | ||
|
|
c36f67a288 | ||
|
|
7954126dcd | ||
|
|
9def6baaba | ||
|
|
c7624fd25d | ||
|
|
32de1d52ea | ||
|
|
677286bc0e | ||
|
|
19e81ffda5 | ||
|
|
d718a14bd0 | ||
|
|
04ce5cc2d1 | ||
|
|
065384056b | ||
|
|
3d7b8105e1 | ||
|
|
3b56ebce6d | ||
|
|
2ab568fa88 | ||
|
|
4e4568cade | ||
|
|
d0d1c0e486 | ||
|
|
d37650dc4f | ||
|
|
cf3b73167d | ||
|
|
5532615bc0 | ||
|
|
ce91520e12 | ||
|
|
8ec3e5725c | ||
|
|
7462c03281 | ||
|
|
567741caf5 | ||
|
|
9fc2c34a3b | ||
|
|
b6bb350289 | ||
|
|
bcc7c689c1 | ||
|
|
0fa8d18775 | ||
|
|
db7a89b1ee | ||
|
|
4dfb29fa38 | ||
|
|
ecc22c521d | ||
|
|
1270f8fed8 | ||
|
|
5cbdd84686 | ||
|
|
1df3355438 | ||
|
|
2be75a0129 | ||
|
|
8820aa9f65 | ||
|
|
3872e24847 | ||
|
|
b8023044c3 | ||
|
|
ec3a764c76 | ||
|
|
e3defd9b25 | ||
|
|
1930181b18 | ||
|
|
332bfbf273 | ||
|
|
7a68cff1db | ||
|
|
6d9fe6c3aa | ||
|
|
c2ed0186de | ||
|
|
3866988f87 | ||
|
|
43f8d62f6a | ||
|
|
a880639f48 | ||
|
|
57eb948c48 | ||
|
|
6c3186a19a | ||
|
|
10a5a2175e | ||
|
|
be7cec5640 | ||
|
|
492e3aa437 | ||
|
|
6b19621112 | ||
|
|
324ffe20e9 | ||
|
|
38f169113e | ||
|
|
e34c6fd187 | ||
|
|
1377427e70 | ||
|
|
3de1700f61 | ||
|
|
8f8e81c0c9 | ||
|
|
4f34e25dd8 | ||
|
|
ac01c2025a | ||
|
|
e08a40be56 | ||
|
|
9ad9e8c5dd | ||
|
|
fa4a75cdab | ||
|
|
2d82567070 | ||
|
|
588ebb5393 | ||
|
|
96ab50a701 | ||
|
|
b3438c86bf | ||
|
|
abd1f615b2 | ||
|
|
a7b6445cc3 | ||
|
|
96fe3b26c1 | ||
|
|
93fd9cc29d | ||
|
|
47e18f4cea | ||
|
|
87841b4f91 | ||
|
|
17f1cd5be8 | ||
|
|
c3041eb9f0 | ||
|
|
69cb1f830e | ||
|
|
703160b5d6 | ||
|
|
676c62647c | ||
|
|
30f6d9b167 | ||
|
|
1cb579d0fd | ||
|
|
3d4ebeb1b0 | ||
|
|
0fc4353fb3 | ||
|
|
ca413cf270 | ||
|
|
b2b5d88f3f | ||
|
|
ecec113b63 | ||
|
|
0740d3dbb8 | ||
|
|
9301eeb4dd | ||
|
|
1df427bc7b | ||
|
|
219442cff7 | ||
|
|
3aaf5b9b1e | ||
|
|
b463d3de54 | ||
|
|
64f02dab7c | ||
|
|
f705c0e013 | ||
|
|
11dcbd7556 | ||
|
|
96c37fa80a | ||
|
|
55346b0d10 | ||
|
|
7502cb3adb | ||
|
|
03ec2482c9 | ||
|
|
a2387330ce | ||
|
|
3689640b4e | ||
|
|
36c7c7537a | ||
|
|
2bdae526ad | ||
|
|
69f6b23945 | ||
|
|
ac3b78a841 | ||
|
|
a0e7facee6 | ||
|
|
a24b67fc5a | ||
|
|
521247bedb | ||
|
|
9ad028e8ee | ||
|
|
d9c848d3a6 | ||
|
|
66fb24c3a5 | ||
|
|
d3c04b74ec | ||
|
|
09ef2c9f40 | ||
|
|
5158dd9a8d | ||
|
|
edc298d0a1 | ||
|
|
703baa8769 | ||
|
|
3e8124009f | ||
|
|
0d77e5e959 | ||
|
|
c120d09a5e | ||
|
|
a4515ce138 | ||
|
|
3a0d40b84d | ||
|
|
234211a6f6 | ||
|
|
f833b885a1 | ||
|
|
67ee86085c | ||
|
|
5d0cfe079b | ||
|
|
1c86713afd | ||
|
|
7ecbc18d5d | ||
|
|
dc7fb15251 | ||
|
|
b6950ed8aa | ||
|
|
04b32fa734 | ||
|
|
91218f8714 | ||
|
|
ce79d6081f | ||
|
|
d5a63c21b4 | ||
|
|
b066ad0fd8 | ||
|
|
620b59e843 | ||
|
|
f71b3054cd | ||
|
|
60dd440082 | ||
|
|
f72f21951c | ||
|
|
67b333ec84 | ||
|
|
b9f36cc226 | ||
|
|
1a1efd5bc9 | ||
|
|
4fb1045f5a | ||
|
|
2b3c2fd852 | ||
|
|
cc42614fa9 | ||
|
|
bbf44d6ff3 | ||
|
|
9ebee6aef8 | ||
|
|
095e1b410a | ||
|
|
210b4553a5 | ||
|
|
2231e72968 | ||
|
|
e0ad1e5706 | ||
|
|
436f3b357e | ||
|
|
f7c42c21ba | ||
|
|
230e39ec35 | ||
|
|
ba89a048ed | ||
|
|
efa8c93664 | ||
|
|
3e0bc052e1 | ||
|
|
d3d25365f1 | ||
|
|
6fd2b5b87f | ||
|
|
acf13ce978 | ||
|
|
1b8488ee75 | ||
|
|
6fcdc714b6 | ||
|
|
8705c6b435 | ||
|
|
9358cfaf4a | ||
|
|
a51dcdc430 | ||
|
|
c65d4220f0 | ||
|
|
c198664d15 | ||
|
|
8715247a43 | ||
|
|
51487ed22f | ||
|
|
20ed20ea1e | ||
|
|
9802fea615 | ||
|
|
7ce77ffc9c | ||
|
|
6be32c89c5 | ||
|
|
1f18523565 | ||
|
|
e26a351865 | ||
|
|
ebd0eb4fb4 | ||
|
|
ef9b2eb566 | ||
|
|
9a1b4f9ed3 | ||
|
|
7e542d119b | ||
|
|
503edae26f | ||
|
|
e4e728664b | ||
|
|
17b56562c4 | ||
|
|
c7fccfa299 | ||
|
|
023137a891 | ||
|
|
34d05ea7cd | ||
|
|
5de84eca3d | ||
|
|
a3efd2ab5a | ||
|
|
139754b9fe | ||
|
|
248fb14f08 | ||
|
|
31954339d1 | ||
|
|
f56b4ec2ff | ||
|
|
6c42f1a89e | ||
|
|
65ff5b00bd | ||
|
|
f6cd0342f6 | ||
|
|
1580afdfdf | ||
|
|
7aef2994e4 | ||
|
|
08bcd6978c | ||
|
|
4789a4ee1f | ||
|
|
9a7cde0c9b | ||
|
|
66152010a7 | ||
|
|
2772557d15 | ||
|
|
ea4487c6da | ||
|
|
cb564bb427 | ||
|
|
3696cce4ae | ||
|
|
c1c5f43a01 | ||
|
|
a22a6deda5 | ||
|
|
bbf743769b | ||
|
|
de68c2a7da | ||
|
|
5309252053 | ||
|
|
8e8e0f1d53 | ||
|
|
f69ce39a6c | ||
|
|
fc9f08235b | ||
|
|
5f5104e782 | ||
|
|
e3be9b1951 | ||
|
|
c2822ca119 | ||
|
|
828f12b748 | ||
|
|
ae70071494 | ||
|
|
3999886901 | ||
|
|
cc474b4ede | ||
|
|
8363e31953 | ||
|
|
933dc48de3 | ||
|
|
4274a7ec89 | ||
|
|
77f9c49829 | ||
|
|
c87187f913 | ||
|
|
bf09b00fe9 | ||
|
|
a97b7ad11c | ||
|
|
2b80ede963 | ||
|
|
2a0f3f0d79 | ||
|
|
a471b5de9c | ||
|
|
43355fa75c | ||
|
|
b9c873cdaa | ||
|
|
b4b9b831ee | ||
|
|
552c9cd83f | ||
|
|
76bbdeb586 | ||
|
|
07a71fd432 | ||
|
|
26524c99f6 | ||
|
|
34464da8d3 | ||
|
|
42e2413978 | ||
|
|
ef7293379f | ||
|
|
386849edc1 | ||
|
|
e63f0546a1 | ||
|
|
447a07e9f8 | ||
|
|
ad466a69aa | ||
|
|
5afb820d23 | ||
|
|
278d9bc721 | ||
|
|
1484eb8a51 | ||
|
|
dcc100f165 | ||
|
|
4e3bed2035 | ||
|
|
510ec3fb9e | ||
|
|
ceed5cc9a9 | ||
|
|
0440d325d9 | ||
|
|
36c0871c23 | ||
|
|
b88ec14f0e | ||
|
|
cc724f327a | ||
|
|
43fa9a9ba6 | ||
|
|
e1e120de1c | ||
|
|
7b7397241f | ||
|
|
1618f3eae6 | ||
|
|
c47d66f49b | ||
|
|
1e8faaa217 | ||
|
|
608eef731a | ||
|
|
4f5c5b37b8 | ||
|
|
0ed727a012 | ||
|
|
d91127958d | ||
|
|
4af4d12475 | ||
|
|
e5f01febd7 | ||
|
|
72d1afa169 | ||
|
|
e0f4697e7c | ||
|
|
c4a2fdf15b | ||
|
|
af5e0bd15a | ||
|
|
ec1d37b1b2 | ||
|
|
c919139433 | ||
|
|
fc09ec3025 | ||
|
|
99e54f46c7 | ||
|
|
2240199dbf | ||
|
|
83e1a33ff5 | ||
|
|
d529e7e14e | ||
|
|
6769115df2 | ||
|
|
261b6b8615 | ||
|
|
3ae1b82695 | ||
|
|
67dd5df876 | ||
|
|
622593a77f | ||
|
|
a6d52405a8 | ||
|
|
842bc2b855 | ||
|
|
a2c86dcbf6 | ||
|
|
ac9daf92d7 | ||
|
|
f81190a793 | ||
|
|
6704c86301 | ||
|
|
680f920b55 | ||
|
|
089c33f5be | ||
|
|
46d5c14b17 | ||
|
|
b02cd35354 | ||
|
|
7425122c1c | ||
|
|
56481a46bf | ||
|
|
41f90bd08f | ||
|
|
d3d85c3df9 | ||
|
|
d267845cfc | ||
|
|
c550e66e85 | ||
|
|
e16b7b8399 | ||
|
|
9abbe349af | ||
|
|
509ce7f766 | ||
|
|
0ac6efa6d5 | ||
|
|
6f04866044 | ||
|
|
021037c419 | ||
|
|
4baafd8126 | ||
|
|
48dd72005e | ||
|
|
7bc3f5dd8a | ||
|
|
56a33b157b | ||
|
|
c7046b9a0c | ||
|
|
6ac3343617 | ||
|
|
f1dd95650b | ||
|
|
6767072c9d | ||
|
|
efbcf8747d | ||
|
|
73b8c3ebf3 | ||
|
|
25211020bf | ||
|
|
24634b6281 | ||
|
|
3a89d1ef7f | ||
|
|
a61b8a2033 | ||
|
|
c164f5886f | ||
|
|
d285f7fd4d | ||
|
|
44ded35d5d | ||
|
|
f429057072 | ||
|
|
11dedde511 | ||
|
|
2dc74f2e4d | ||
|
|
4651180503 | ||
|
|
bb53c20c18 | ||
|
|
0a86d3579e | ||
|
|
4a5017d1d8 | ||
|
|
3ef3802629 | ||
|
|
8aba77b7be | ||
|
|
5e6a7c85cc | ||
|
|
e7c6f81016 | ||
|
|
604b02cfaa | ||
|
|
d6bd9c0e7f | ||
|
|
9ffe549ab1 | ||
|
|
06ce9da32a | ||
|
|
c29bfd2ff3 | ||
|
|
383c682563 | ||
|
|
8a37a1cc2d | ||
|
|
65c9004550 | ||
|
|
6abd984608 | ||
|
|
f941879c15 | ||
|
|
05213e4c8c | ||
|
|
3e2cc2d2c4 | ||
|
|
ba6dedbbbd | ||
|
|
f26312ffbf | ||
|
|
e31480cf44 | ||
|
|
1e5a94fdb5 | ||
|
|
75e13c8977 | ||
|
|
b9ade6e6bb | ||
|
|
c0d3e4315c | ||
|
|
8865eb2866 | ||
|
|
097a501414 | ||
|
|
7d75dbbdda | ||
|
|
f569950664 | ||
|
|
a4ebd9af33 | ||
|
|
d5d0a36f66 | ||
|
|
8f301ed62d | ||
|
|
3211bc5f23 | ||
|
|
6789088dce | ||
|
|
6a45fab608 | ||
|
|
519c6fc7e7 | ||
|
|
ac46e87685 | ||
|
|
526bb6f3e9 | ||
|
|
462a11301a | ||
|
|
ad8509f361 | ||
|
|
739b937b74 | ||
|
|
7e4f8b45b6 | ||
|
|
121ba57b55 | ||
|
|
9ee979167a | ||
|
|
a775107f5f | ||
|
|
cd9b1b1fd3 | ||
|
|
a3715e7867 | ||
|
|
4feee126b8 | ||
|
|
19ea306606 | ||
|
|
0dda866679 | ||
|
|
84d2e6c8a0 | ||
|
|
30962cb200 | ||
|
|
3f58cbaae9 | ||
|
|
a4c9a80dac | ||
|
|
6311bd119e | ||
|
|
796eb522ac | ||
|
|
e755475475 | ||
|
|
15a64b805e | ||
|
|
6c9862662f | ||
|
|
6bbc92a6f5 | ||
|
|
459e9de81a | ||
|
|
0926a23014 | ||
|
|
f27fefd7b8 | ||
|
|
29a5931c6a | ||
|
|
2182e1badc | ||
|
|
106ee8f30a | ||
|
|
1acf066fb9 | ||
|
|
e7f4319ac6 | ||
|
|
c2eb869f72 | ||
|
|
8cb410c63c | ||
|
|
ba5404d93e | ||
|
|
4ca857e0e9 | ||
|
|
621dabd44e | ||
|
|
3e147967e2 | ||
|
|
9c0147915e | ||
|
|
d31d4c05cf | ||
|
|
094bca5ac3 | ||
|
|
87821fce0e | ||
|
|
fce47e2e63 | ||
|
|
9b9d26f80e | ||
|
|
58688c48aa | ||
|
|
5d56225d95 | ||
|
|
070e3b4178 | ||
|
|
2cea9433c2 | ||
|
|
33b337f618 | ||
|
|
543fb99bc6 | ||
|
|
8b8a211185 | ||
|
|
4a38189349 | ||
|
|
ed781e84ee | ||
|
|
ac5b7d518e | ||
|
|
8d4eae5662 | ||
|
|
a78cc98c8b | ||
|
|
8db145da1e | ||
|
|
68f5c9c72d | ||
|
|
a9ca8df8e3 | ||
|
|
67bf0933e2 | ||
|
|
5d7bff4051 | ||
|
|
9f6d685c05 | ||
|
|
10e05f9867 | ||
|
|
76ef8770cd | ||
|
|
dafa0f022c | ||
|
|
390472566c | ||
|
|
a18a374d51 | ||
|
|
8e47966225 | ||
|
|
1415eb3dd2 | ||
|
|
5d397462e4 | ||
|
|
5ae542e7ee | ||
|
|
d9deb4b530 | ||
|
|
89763f2ace | ||
|
|
9df4e7597d | ||
|
|
08a8ccf46b | ||
|
|
2756437f4b | ||
|
|
15b9946a40 | ||
|
|
d9961f40bf | ||
|
|
05831b52c4 | ||
|
|
b92fcf23fd | ||
|
|
38f64b3da3 | ||
|
|
9f47c6083a | ||
|
|
6609093625 | ||
|
|
591fa23f6e | ||
|
|
daf150c38d | ||
|
|
f98d13e7dc | ||
|
|
bed8153ba0 | ||
|
|
297ebb1160 | ||
|
|
ff55eb5bfa | ||
|
|
80e0158112 | ||
|
|
05855393f0 | ||
|
|
a790e16fa2 | ||
|
|
25c604fb1c | ||
|
|
38e13942ac | ||
|
|
b58bf49e91 | ||
|
|
80444436f3 | ||
|
|
44d6a2c435 | ||
|
|
946ed97273 | ||
|
|
b1264a7416 | ||
|
|
b3c4956efe | ||
|
|
6a6a42aa3a | ||
|
|
862fe15c32 | ||
|
|
fde36fccc3 | ||
|
|
5bebbd81d7 | ||
|
|
a02c7e804c | ||
|
|
06ffed3216 | ||
|
|
91ad830c88 | ||
|
|
7342615c7d | ||
|
|
abb728684b | ||
|
|
4d6091379b | ||
|
|
ea8c8c5f33 | ||
|
|
abf3a5d50e | ||
|
|
f575e39b0a | ||
|
|
10f58cb1bc | ||
|
|
a94535f318 | ||
|
|
d2dfbef05a | ||
|
|
d8332e6373 | ||
|
|
0785f2872f | ||
|
|
5761ab6b55 | ||
|
|
5289da29ba | ||
|
|
c95f1d1ff9 | ||
|
|
01943062b4 | ||
|
|
86182f33c3 | ||
|
|
1c853c6860 | ||
|
|
2a585dc4ed | ||
|
|
42fd44f1db | ||
|
|
992dd86309 | ||
|
|
2f813ef75d | ||
|
|
32299e4010 | ||
|
|
e8b25188ad | ||
|
|
dc3fdc8dc7 | ||
|
|
1eaefbf169 | ||
|
|
5730cbf3e3 | ||
|
|
eb5f4460d1 | ||
|
|
37ffdff5ba | ||
|
|
ed62d1263c | ||
|
|
a8b1379ccb | ||
|
|
6b804f3a4a | ||
|
|
539c73bdb1 | ||
|
|
6dc6333323 | ||
|
|
353f2a2ad4 | ||
|
|
53957dcbaa | ||
|
|
e831649b64 | ||
|
|
fd2ef18a70 | ||
|
|
c92c2bfb10 | ||
|
|
bbca6fe5b0 | ||
|
|
5cce40d4c3 | ||
|
|
d0aa883e07 | ||
|
|
fcd3b260ac | ||
|
|
a0ec4a11ee | ||
|
|
25d2000625 | ||
|
|
b3604dcf83 | ||
|
|
db4452d307 | ||
|
|
10a656eedb | ||
|
|
3c9619bb0a | ||
|
|
48b6d18e7f | ||
|
|
3a7636ff0f | ||
|
|
5bed597e61 | ||
|
|
7b4f0398c3 | ||
|
|
385236e967 | ||
|
|
df818c1b69 | ||
|
|
c2b8f3b55a | ||
|
|
1f22a199fb | ||
|
|
9c40a4edc5 | ||
|
|
eddcc3dfa9 | ||
|
|
fd35b6f836 | ||
|
|
eb0c33cba4 | ||
|
|
284b94662a | ||
|
|
d69b364b5f | ||
|
|
90ad041fa5 | ||
|
|
59e667906f | ||
|
|
a22c06a2d6 | ||
|
|
9a4855295b | ||
|
|
dd46f634fe | ||
|
|
af2b0f452c | ||
|
|
9b5da97e6f | ||
|
|
683ddbc466 | ||
|
|
7825871d6a | ||
|
|
9afb0d739e | ||
|
|
6f2169037e | ||
|
|
480f5d3184 | ||
|
|
1af09d6330 | ||
|
|
62f234ce3b | ||
|
|
387f4d42cc | ||
|
|
d1e6388fed | ||
|
|
2afe395ff2 | ||
|
|
daa26079ee | ||
|
|
fe26b5d25f | ||
|
|
43d62c1ae3 | ||
|
|
70355021d8 | ||
|
|
dba0d54cf5 | ||
|
|
1a3c334c75 | ||
|
|
adad557499 | ||
|
|
ad566a86de | ||
|
|
71dc6e04e8 | ||
|
|
38df960e68 | ||
|
|
0907ca1931 | ||
|
|
760e39e405 | ||
|
|
5d78371628 | ||
|
|
9294cb099f | ||
|
|
4dcb5040a0 | ||
|
|
d7626cd9d7 | ||
|
|
8608c6970d | ||
|
|
693b3d03e6 | ||
|
|
eb9826f65d | ||
|
|
56157444de | ||
|
|
0aab5811ca | ||
|
|
687c4a9fab | ||
|
|
33ae063cae | ||
|
|
762459954f | ||
|
|
972a6f5656 | ||
|
|
f05b32f7ad | ||
|
|
0a2a354499 | ||
|
|
b4ef3e5071 | ||
|
|
fbb030d7f7 | ||
|
|
64b5f39656 | ||
|
|
325e20d76d | ||
|
|
88f3ffe86e | ||
|
|
cebc988dd4 | ||
|
|
abedfa77da | ||
|
|
ff4b4e667a | ||
|
|
4bc0f6e7e9 | ||
|
|
f68ade7b1d | ||
|
|
095ecf2d90 | ||
|
|
b7c364a853 | ||
|
|
5aa49e695e | ||
|
|
2988c594cc | ||
|
|
9ed62eeb91 | ||
|
|
6bca92db4d | ||
|
|
4658c063d5 | ||
|
|
3a20a05a49 | ||
|
|
9dd72b9583 | ||
|
|
b7d031cc92 | ||
|
|
93b353d353 | ||
|
|
bf38a311da | ||
|
|
3af09ac946 | ||
|
|
d528184836 | ||
|
|
2cb2bb8257 | ||
|
|
56ddd3c0b1 | ||
|
|
82efcc32ec | ||
|
|
35ca994ba2 | ||
|
|
9400fdac77 | ||
|
|
4ca2200d83 | ||
|
|
45043ebf3e | ||
|
|
d42b86d22b | ||
|
|
c734789b18 | ||
|
|
205857b232 | ||
|
|
97ca5711f9 | ||
|
|
123ae9e103 | ||
|
|
8fa1858a2c | ||
|
|
1764ef81ef | ||
|
|
fecf8dc44e | ||
|
|
9200a0be7a | ||
|
|
18ea820cb0 | ||
|
|
631a618238 | ||
|
|
b01dcd7971 | ||
|
|
962fa20b36 | ||
|
|
64caf59e84 | ||
|
|
0a9005678d | ||
|
|
96dd3e8eb9 | ||
|
|
6fab9a3e6f | ||
|
|
a448524424 | ||
|
|
6b37b2d79d | ||
|
|
e3c3d746f7 | ||
|
|
b769aa59d3 | ||
|
|
fc9107a16a | ||
|
|
c7a8db5543 | ||
|
|
14ebcab5b0 | ||
|
|
105ce36792 | ||
|
|
9b5f5ed8e8 | ||
|
|
273f1b385c | ||
|
|
63d499f480 | ||
|
|
5c60162e3c | ||
|
|
a6dd9e8e7e | ||
|
|
4278199101 | ||
|
|
f39865e8e4 | ||
|
|
8548624676 | ||
|
|
8a873b97a3 | ||
|
|
8cb8a0da8d | ||
|
|
d771614d33 | ||
|
|
372a8cb1d9 | ||
|
|
3f3b01c7ce | ||
|
|
51c95747d8 | ||
|
|
e323f6620d | ||
|
|
ccba613e5b | ||
|
|
e97006b102 | ||
|
|
ffab22bb35 | ||
|
|
83af55bed4 | ||
|
|
be0d6faa15 | ||
|
|
751a2fa915 | ||
|
|
81a457e6fb | ||
|
|
459abafcea | ||
|
|
7a4bac82d7 | ||
|
|
74c35c513e | ||
|
|
c5ac2579ba | ||
|
|
61b7dc522d | ||
|
|
c089e19020 | ||
|
|
7d5e494716 | ||
|
|
f8aa5821be | ||
|
|
34bb735a65 | ||
|
|
04319964b9 | ||
|
|
8102ec3be5 | ||
|
|
71ede76c68 | ||
|
|
2e5b3ab8bc | ||
|
|
ddf97f8289 | ||
|
|
1ba5ce9cb3 | ||
|
|
f949107a32 | ||
|
|
be16f79438 | ||
|
|
7b847ced4a | ||
|
|
4f1d81c4ce | ||
|
|
90400ae96a | ||
|
|
a910b38a35 | ||
|
|
c7394ac4e0 | ||
|
|
43cd40e87a | ||
|
|
1eb303e6d4 | ||
|
|
926b52b600 | ||
|
|
915a1913e1 | ||
|
|
65ac8e9f0c | ||
|
|
f817a338d0 | ||
|
|
0198bb6bf3 | ||
|
|
1501b3fbbd | ||
|
|
234ad54b2c | ||
|
|
bf121f7c60 | ||
|
|
c741f2f4a6 | ||
|
|
55336657d4 | ||
|
|
c41aa49059 | ||
|
|
3f4418d84d | ||
|
|
036de0c5e4 | ||
|
|
c488e5e40d | ||
|
|
8b7be5861e | ||
|
|
fa617467b1 | ||
|
|
145ba777e8 | ||
|
|
dc6271cd79 | ||
|
|
003a2e6479 | ||
|
|
840fff5e5e | ||
|
|
1c58b94141 | ||
|
|
406fc209ac | ||
|
|
feaf91ab93 | ||
|
|
c828c2f366 | ||
|
|
e7cd547457 | ||
|
|
5cf994856f | ||
|
|
09cbd0c695 | ||
|
|
7a359c00ac | ||
|
|
39154402e5 | ||
|
|
375be90fd1 | ||
|
|
3ad4de6c8c | ||
|
|
3026118c70 | ||
|
|
e2ff51f93f | ||
|
|
52793e7a3f | ||
|
|
2e3bb5a511 | ||
|
|
b02e429788 | ||
|
|
7a005b91b3 | ||
|
|
bc497dbb92 | ||
|
|
9a52ef099a | ||
|
|
85e8b70625 | ||
|
|
e0a19abb99 | ||
|
|
4310282a4c | ||
|
|
4ec8ade11c | ||
|
|
ff65e37545 | ||
|
|
f0635717b3 | ||
|
|
60db6e3df4 | ||
|
|
edcb22a6fb | ||
|
|
181e1bcffd | ||
|
|
fa64c1235e | ||
|
|
ec0c33b844 | ||
|
|
de73fed73d | ||
|
|
d7de29e1e5 | ||
|
|
ad18e45206 | ||
|
|
57381aa560 | ||
|
|
b3107d26df | ||
|
|
05f1680efa | ||
|
|
6491274f60 | ||
|
|
e985629440 | ||
|
|
90f8151ffd | ||
|
|
92cc3a6914 | ||
|
|
06ddd3dcf8 | ||
|
|
5e01b6d663 | ||
|
|
e89e70e715 | ||
|
|
ccaf8724e4 | ||
|
|
04e97e8aef | ||
|
|
746fe5832a | ||
|
|
4027335fa9 | ||
|
|
bcddddf98d | ||
|
|
12ef3ceda1 | ||
|
|
a0647f1616 | ||
|
|
9e3bb986d5 | ||
|
|
93bf2a1d72 | ||
|
|
6b69b93b53 | ||
|
|
189fb08e13 | ||
|
|
ac54dee9bb | ||
|
|
9a391b3320 | ||
|
|
1673735f02 | ||
|
|
e4bb08e1f5 | ||
|
|
5db47ed53a | ||
|
|
95caeaa5dc | ||
|
|
97f105cde2 | ||
|
|
61f3fc7e4d | ||
|
|
8df3035831 | ||
|
|
6d86882ed4 | ||
|
|
9f1dd4d0af | ||
|
|
5f13bb0c3a | ||
|
|
479d614884 | ||
|
|
071494d8fa | ||
|
|
a87228b4ff | ||
|
|
a419e73f7a | ||
|
|
2b331084b4 | ||
|
|
c1d6d7ac6b | ||
|
|
d3c461097b | ||
|
|
f596be9950 | ||
|
|
9e5d585ba4 | ||
|
|
86785004ba | ||
|
|
2da4864483 | ||
|
|
309b76fb32 | ||
|
|
d95274c5f2 | ||
|
|
13e29dd7b5 | ||
|
|
ad0aad21d5 | ||
|
|
fc65da1eed | ||
|
|
584eda8339 | ||
|
|
639fbe0392 | ||
|
|
55d8c01c33 | ||
|
|
6b3b852ebc | ||
|
|
34a82e7629 | ||
|
|
2bb89bc5bc | ||
|
|
133173850c | ||
|
|
c6dac5c3c9 | ||
|
|
029599c02c | ||
|
|
1d1ea681f0 | ||
|
|
5a1a106637 | ||
|
|
ce4eb6559e | ||
|
|
4a04b498db | ||
|
|
16e017d5a6 | ||
|
|
ba84ddcf8e | ||
|
|
895171478f | ||
|
|
e0d1954840 | ||
|
|
96a7cf1e6a | ||
|
|
05b511f96a | ||
|
|
bb14c36a27 | ||
|
|
5ee84436c8 | ||
|
|
f7df0bac96 | ||
|
|
dd4a3b24fc | ||
|
|
ddad0be5f7 | ||
|
|
bb4bab4c26 | ||
|
|
2ec2837daa | ||
|
|
6a309c53a8 | ||
|
|
5bd72ec629 | ||
|
|
e43b6a2dd2 | ||
|
|
3eb6080de3 | ||
|
|
76a9d98562 | ||
|
|
6945e86fd7 | ||
|
|
044ebf1952 | ||
|
|
b9a179089b | ||
|
|
725938fb85 | ||
|
|
c6012aaabc | ||
|
|
c0862dae45 | ||
|
|
54afcfbfb4 | ||
|
|
b292f71c49 | ||
|
|
e32e0d5692 | ||
|
|
73732ffa05 | ||
|
|
ff2cc0e387 | ||
|
|
550b855c9d | ||
|
|
6036bdd06c | ||
|
|
fc6a65c620 | ||
|
|
0ca6f667e3 | ||
|
|
6f5150a943 | ||
|
|
ad006bc6b6 | ||
|
|
ce53936a2b | ||
|
|
1938c994e7 | ||
|
|
7ddba901a4 | ||
|
|
d3b5c242cc | ||
|
|
216df07688 | ||
|
|
65deba3a35 | ||
|
|
9642f0373f | ||
|
|
3e9d9a2119 | ||
|
|
924bf8477f | ||
|
|
92da443a9e | ||
|
|
780fd8f7a6 | ||
|
|
aa3403a343 | ||
|
|
9601b72e4c | ||
|
|
ca617d679f | ||
|
|
615d85fb23 | ||
|
|
f08c9b2217 | ||
|
|
ae2ea52575 | ||
|
|
e76caa0017 | ||
|
|
975f516f51 | ||
|
|
fe20c0d89e | ||
|
|
4a9b01eb0d | ||
|
|
6910458a92 | ||
|
|
ceace9c6bd | ||
|
|
5f108d9df6 | ||
|
|
5d91555c7c | ||
|
|
cba885a67c | ||
|
|
cf411053c7 | ||
|
|
023d8d38ec | ||
|
|
359285928b | ||
|
|
0b788a3d61 | ||
|
|
88555d96d5 | ||
|
|
9e49ec6cd3 | ||
|
|
22d51ec1ea | ||
|
|
fa8333eddb | ||
|
|
22355ce947 | ||
|
|
bd098c273b | ||
|
|
e415ead361 | ||
|
|
2f7198246e | ||
|
|
289320a9b1 | ||
|
|
4cbbbddf22 | ||
|
|
9cd5ba40d3 | ||
|
|
4a6d62e401 | ||
|
|
daa1faa905 | ||
|
|
25d5734496 | ||
|
|
58361eb965 | ||
|
|
5f2f07ed8a | ||
|
|
81181bfb72 | ||
|
|
24e1327d0d | ||
|
|
29f9d5f335 | ||
|
|
86c93c6e34 | ||
|
|
643c219d18 | ||
|
|
f63761eabc | ||
|
|
8c497ecac0 | ||
|
|
084d07f4eb | ||
|
|
b4efd1ca89 | ||
|
|
923ccfa2e8 | ||
|
|
474fdebb7a | ||
|
|
9ced016cbc | ||
|
|
e538d4adae | ||
|
|
eb424cf63d | ||
|
|
69e150b7e3 | ||
|
|
fe5edad1fc | ||
|
|
4c5c125173 | ||
|
|
68e06fb6b7 | ||
|
|
003e8e65f7 | ||
|
|
710393e388 | ||
|
|
2660692fb1 | ||
|
|
916669a244 | ||
|
|
46f80d01ff | ||
|
|
b11b1dd1c0 | ||
|
|
1ec736a3dc | ||
|
|
c506e7f711 | ||
|
|
eb8ab96980 | ||
|
|
e225ce0fd7 | ||
|
|
e8c10f5b34 | ||
|
|
5050171f6b | ||
|
|
dbbb297d5f | ||
|
|
be17ac1eb2 | ||
|
|
40c242a6d5 | ||
|
|
a7075f1c66 | ||
|
|
1675ddb4d1 | ||
|
|
ed8350422e | ||
|
|
9144d30848 | ||
|
|
83078bdcbc | ||
|
|
74d0851ac5 | ||
|
|
23326e40cf | ||
|
|
3db2433448 | ||
|
|
7e796dea03 | ||
|
|
096cbf2ea5 | ||
|
|
f4b8f00255 | ||
|
|
da8401d8be | ||
|
|
2de599ac0e | ||
|
|
7b4077ef87 | ||
|
|
27cfa81110 | ||
|
|
013b88dfc3 | ||
|
|
6d2830a473 | ||
|
|
69f3c24647 | ||
|
|
c2b0fdae5b | ||
|
|
89262c62fe | ||
|
|
18665b8cc9 | ||
|
|
a3c32841e6 | ||
|
|
1156467726 | ||
|
|
74749e8705 | ||
|
|
85e0d8a221 | ||
|
|
38b2c42f63 | ||
|
|
50bd094856 | ||
|
|
f031975dc0 | ||
|
|
d42fb43f4f | ||
|
|
d6015824dd | ||
|
|
6c1f03578d | ||
|
|
8dd2f0da3f | ||
|
|
0ba85cc326 | ||
|
|
c1a4c0186a | ||
|
|
52ec9b9ec4 | ||
|
|
ebe07c2726 | ||
|
|
3f16fcb30a | ||
|
|
2faec76afa | ||
|
|
655a1aea6c | ||
|
|
6521427a45 | ||
|
|
7d45e29683 | ||
|
|
41d985ace3 | ||
|
|
e659aa86b9 | ||
|
|
5823854b5e | ||
|
|
c5dbec9e85 | ||
|
|
646cfa6983 | ||
|
|
fdda4142bf | ||
|
|
3f76a973ee | ||
|
|
4215d009a5 | ||
|
|
a35630838f | ||
|
|
dc373abba8 | ||
|
|
f60bc7e03b | ||
|
|
49c776ea59 | ||
|
|
3686645e77 | ||
|
|
df91860b52 | ||
|
|
29d4016572 | ||
|
|
6e3f673ef7 | ||
|
|
35876eaab9 |
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
*.o
|
||||||
|
*~
|
||||||
|
*.diff
|
||||||
|
*.patch
|
||||||
|
*.core
|
||||||
|
core
|
||||||
|
tags
|
||||||
|
.deps/
|
||||||
|
compat/.dirstamp
|
||||||
|
aclocal.m4
|
||||||
|
autom4te.cache/
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
etc/
|
||||||
|
tmux
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
configure
|
||||||
|
tmux.1.*
|
||||||
24
.mailmap
Normal file
24
.mailmap
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
Bob Beck <beck@openbsd.org> beck <beck>
|
||||||
|
Igor Sobrado <sobrado@openbsd.org> sobrado <sobrado>
|
||||||
|
Jacek Masiulaniec <jacekm@openbsd.org> jacekm <jacekm>
|
||||||
|
Jason McIntyre <jmc@openbsd.org> jcm <jcm>
|
||||||
|
Joel Sing <jsing@openbsd.org> jsing <jsing>
|
||||||
|
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>
|
||||||
|
Miod Vallat <miod@openbsd.org> miod <miod>
|
||||||
|
Nicholas Marriott <nicm@openbsd.org> nicm <nicm>
|
||||||
|
Nicholas Marriott <nicm@openbsd.org> no_author <no_author@example.org>
|
||||||
|
<nicm@openbsd.org> <nicholas.marriott@gmail.com>
|
||||||
|
Okan Demirmen <okan@openbsd.org> okan <okan>
|
||||||
|
Philip Guenther <guenther@openbsd.org> guenther <guenther>
|
||||||
|
Pierre-Yves Ritschard <pyr@openbsd.org> pyr <pyr>
|
||||||
|
Ray Lai <ray@openbsd.org> ray <ray>
|
||||||
|
Ryan McBride <mcbride@openbsd.org> mcbride <mcbride>
|
||||||
|
Stefan Sperling <stsp@openbsd.org> stsp <stsp>
|
||||||
|
Stuart Henderson <sthen@openbsd.org> sthen <sthen>
|
||||||
|
Ted Unangst <tedu@openbsd.org> tedu <tedu>
|
||||||
|
Theo Deraadt <deraadt@openbsd.org> deraadt <deraadt>
|
||||||
|
Thomas Adam <thomas@xteddy.org> Thomas <thomas@xteddy.org>
|
||||||
|
William Yodlowsky <william@openbsd.org> william <william>
|
||||||
314
CHANGES
314
CHANGES
@@ -1,3 +1,315 @@
|
|||||||
|
CHANGES FROM 1.9 to 1.9a 22 February 2014
|
||||||
|
|
||||||
|
NOTE: This is a bug-fix release to address some important bugs which just
|
||||||
|
missed the 1.9 deadline, but were found afterwards.
|
||||||
|
|
||||||
|
Normal Changes
|
||||||
|
==============
|
||||||
|
|
||||||
|
* Fix crash due to uninitialized lastwp member of layout_cell
|
||||||
|
* Fix -fg/-bg/-style with 256 colour terminals.
|
||||||
|
|
||||||
|
CHANGES FROM 1.8 to 1.9, 20 February 2014
|
||||||
|
|
||||||
|
NOTE: This release has bumped the tmux protocol version. It is therefore
|
||||||
|
advised that the prior tmux server is restarted when this version of tmux is
|
||||||
|
installed, to avoid protocol mismatch errors for newer clients trying to
|
||||||
|
talk to an older running tmux server.
|
||||||
|
|
||||||
|
Incompatible Changes
|
||||||
|
====================
|
||||||
|
|
||||||
|
* 88 colour support has been removed.
|
||||||
|
* 'default-path' has been removed. The new-window command accepts '-c' to
|
||||||
|
cater for this. The previous value of "." can be replaced with: 'neww -c
|
||||||
|
$PWD', the previous value of '' which meant current path of the pane can
|
||||||
|
be specified as: 'neww -c "#{pane_current_path}"'
|
||||||
|
|
||||||
|
Deprecated Changes
|
||||||
|
==================
|
||||||
|
|
||||||
|
* The single format specifiers: #A -> #Z (where defined) have been
|
||||||
|
deprecated and replaced with longer-named equivalents, as listed in the
|
||||||
|
FORMATS section of the tmux manpage.
|
||||||
|
* The various foo-{fg,bg,attr} commands have been deprecated and replaced
|
||||||
|
with equivalent foo-style option instead. Currently this is still
|
||||||
|
backwards-compatible, but will be removed over time.
|
||||||
|
|
||||||
|
Normal Changes
|
||||||
|
==============
|
||||||
|
|
||||||
|
* A new environment variable TMUX_TMPDIR is now honoured, allowing the
|
||||||
|
socket directory to be set outside of TMPDIR (/tmp/ if not set).
|
||||||
|
* If -s not given to swap-pane the current pane is assumed.
|
||||||
|
* A #{pane_syncronized} format specifier has been added to be a conditional
|
||||||
|
format if a pane is in a syncronised mode (c.f. syncronize-panes)
|
||||||
|
* Tmux now runs under Cygwin natively.
|
||||||
|
* Formats can now be nested within each other and expanded accordingly.
|
||||||
|
* Added 'automatic-rename-format' option to allow the automatic rename
|
||||||
|
mechanism to use something other than the default of
|
||||||
|
#{pane_current_command}.
|
||||||
|
* new-session learnt '-c' to specify the starting directory for that session
|
||||||
|
and all subsequent windows therein.
|
||||||
|
* The session name is now shown in the message printed to the terminal when
|
||||||
|
a session is detached.
|
||||||
|
* Lots more format specifiers have been added.
|
||||||
|
* Server race conditions have been fixed; in particular commands are not run
|
||||||
|
until after the configuration file is read completely.
|
||||||
|
* Case insensitive searching in tmux's copy-mode is now possible.
|
||||||
|
* attach-session and switch-client learnt the '-t' option to accept a window
|
||||||
|
and/or a pane to use.
|
||||||
|
* Copy-mode is only exited if no selection is in progress.
|
||||||
|
* Paste key in copy-mode is now possible to enter text from the clipboard.
|
||||||
|
* status-interval set to '0' now works as intended.
|
||||||
|
* tmux now supports 256 colours running under fbterm.
|
||||||
|
* Many bug fixes!
|
||||||
|
|
||||||
|
CHANGES FROM 1.7 to 1.8, 26 March 2013
|
||||||
|
|
||||||
|
Incompatible Changes
|
||||||
|
====================
|
||||||
|
|
||||||
|
* layout redo/undo has been removed.
|
||||||
|
|
||||||
|
Normal Changes
|
||||||
|
==============
|
||||||
|
|
||||||
|
* Add halfpage up/down bindings to copy mode.
|
||||||
|
* Session choosing fixed to work with unattached sessions.
|
||||||
|
* New window options window-status-last-{attr,bg,fg} to denote the last
|
||||||
|
window which was active.
|
||||||
|
* Scrolling in copy-mode now scrolls the region without moving the mouse
|
||||||
|
cursor.
|
||||||
|
* run-shell learnt '-t' to specify the pane to use when displaying output.
|
||||||
|
* Support for middle-click pasting.
|
||||||
|
* choose-tree learns '-u' to start uncollapsed.
|
||||||
|
* select-window learnt '-T' to toggle to the last window if it's already
|
||||||
|
current.
|
||||||
|
* New session option 'assume-paste-time' for pasting text versus key-binding
|
||||||
|
actions.
|
||||||
|
* choose-* commands now work outside of an attached client.
|
||||||
|
* Aliases are now shown for list-commands command.
|
||||||
|
* Status learns about formats.
|
||||||
|
* Free-form options can be set with set-option if prepended with an '@'
|
||||||
|
sign.
|
||||||
|
* capture-pane learnt '-p' to send to stdout, and '-e' for capturing escape
|
||||||
|
sequences, and '-a' to capture the alternate screen, and '-P' to dump
|
||||||
|
pending output.
|
||||||
|
* Many new formats added (client_session, client_last_session, etc.)
|
||||||
|
* Control mode, which is a way for a client to send tmux commands.
|
||||||
|
Currently more useful to users of iterm2.
|
||||||
|
* resize-pane learnt '-x' and '-y' for absolute pane sizing.
|
||||||
|
* Config file loading now reports errors from all files which are loaded via
|
||||||
|
the 'source-file' command.
|
||||||
|
* 'copy-pipe' mode command to copy selection and pipe the selection to a
|
||||||
|
command.
|
||||||
|
* Panes can now emit focus notifications for certain applications
|
||||||
|
which use those.
|
||||||
|
* run-shell and if-shell now accept formats.
|
||||||
|
* resize-pane learnt '-Z' for zooming a pane temporarily.
|
||||||
|
* new-session learnt '-A' to make it behave like attach-session.
|
||||||
|
* set-option learnt '-o' to prevent setting an option which is already set.
|
||||||
|
* capture-pane and show-options learns '-q' to silence errors.
|
||||||
|
* New command 'wait-for' which blocks a client until woken up again.
|
||||||
|
* Resizing panes will now reflow the text inside them.
|
||||||
|
* Lots and lots of bug fixes, fixing memory-leaks, etc.
|
||||||
|
* Various manpage improvements.
|
||||||
|
|
||||||
|
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.
|
||||||
|
* New option status-position to move the status line to the top or bottom of
|
||||||
|
the screen.
|
||||||
|
* Enforce history-limit option when clearing the screen.
|
||||||
|
* Give each window a unique id, like panes but prefixed with @.
|
||||||
|
* Add pane id to each pane in layout description (while still accepting
|
||||||
|
the old form).
|
||||||
|
* Provide defined ways to set the various default-path possibilities: ~
|
||||||
|
for home directory, . for server start directory, - for session start
|
||||||
|
directory and empty for the pane's working directory (the default). All
|
||||||
|
can also be used as part of a relative path (eg -/foo). Also provide -c
|
||||||
|
flags to neww and splitw to override default-path setting.
|
||||||
|
* Add -l flag to send-keys to send input literally (without translating
|
||||||
|
key names).
|
||||||
|
* Allow a single option to be specified to show-options to show just that
|
||||||
|
option.
|
||||||
|
* New command "move-pane" (like join-pane but allows the same window).
|
||||||
|
* join-pane and move-pane commands learn "-b" option to place the pane to
|
||||||
|
the left or above.
|
||||||
|
* Support for bracketed-paste mode.
|
||||||
|
* Allow send-keys command to accept hex values.
|
||||||
|
* Add locking around "start-server" to avoid race-conditions.
|
||||||
|
* break-pane learns -P/-F arguments for display formatting.
|
||||||
|
* set-option learns "-q" to make it quiet, and not print out anything.
|
||||||
|
* copy mode learns "wrap-search" option.
|
||||||
|
* Add a simple form of output rate limiting by counting the number of
|
||||||
|
certain C0 sequences (linefeeds, backspaces, carriage returns) and if it
|
||||||
|
exceeds a threshold (current default 250/millisecond), start to redraw
|
||||||
|
the pane every 100 milliseconds instead of making each change as it
|
||||||
|
comes. Two configuration options - c0-change-trigger and
|
||||||
|
c0-change-interval.
|
||||||
|
* find-window learns new flags: "-C", "-N", "-T" to match against either or
|
||||||
|
all of a window's content, name, or title. Defaults to all three options
|
||||||
|
if none specified.
|
||||||
|
* find-window automatically selects the appropriate pane for the found
|
||||||
|
matches.
|
||||||
|
* show-environment can now accept one option to show that environment value.
|
||||||
|
* Exit mouse mode when end-of-screen reached when scrolling with the mouse
|
||||||
|
wheel.
|
||||||
|
* select-layout learns -u and -U for layout history stacks.
|
||||||
|
* kill-window, detach-client, kill-session all learn "-a" option for
|
||||||
|
killing all but the current thing specified.
|
||||||
|
* move-window learns "-r" option to renumber window sequentially in a
|
||||||
|
session.
|
||||||
|
* New session option "renumber-windows" to automatically renumber windows in
|
||||||
|
a session when a window is closed. (see "move-window -r").
|
||||||
|
* Only enter copy-mode on scroll up.
|
||||||
|
* choose-* and list-* commands all use "-F" for format specifiers.
|
||||||
|
* When spawning external commands, the value from the "default-shell" option
|
||||||
|
is now used, rather than assuming /bin/sh.
|
||||||
|
* New choose-tree command to render window/sessions as a tree for selection.
|
||||||
|
* display-message learns new format options.
|
||||||
|
* For linked-windows across sessions, all flags for that window are now
|
||||||
|
cleared across sessions.
|
||||||
|
* Lots and lots of bug fixes, fixing memory-leaks, etc.
|
||||||
|
* Various manpage improvements.
|
||||||
|
|
||||||
|
CHANGES FROM 1.5 TO 1.6, 23 January 2012
|
||||||
|
|
||||||
|
* Extend the mode-mouse option to add a third choice which means the mouse
|
||||||
|
does not enter copy mode.
|
||||||
|
* Add a -r flag to switch-client to toggle the client read-only flag.
|
||||||
|
* Add pane-base-index option.
|
||||||
|
* Support \ for line continuation in the configuration file.
|
||||||
|
* Framework for more powerful formatting of command output and use it for
|
||||||
|
list-{panes,windows,sessions}. This allows more descriptive replacements
|
||||||
|
(such as #{session_name}) and conditionals.
|
||||||
|
* Mark dead panes with some text saying they are dead.
|
||||||
|
* Reject $SHELL if it is not a full path.
|
||||||
|
* Add -S option to refresh-client to redraw status line.
|
||||||
|
* Add an else clause for if-shell.
|
||||||
|
* Try to resolve relative paths for loadb and saveb (first, using client
|
||||||
|
working directory, if any, then default-path or session working directory).
|
||||||
|
* Support for \e[3J to clear the history and send the corresponding
|
||||||
|
terminfo code (E3) before locking.
|
||||||
|
* When in copy mode, make repeat count indicate buffer to replace, if used.
|
||||||
|
* Add screen*:XT to terminal-overrides for tmux-in-tmux.
|
||||||
|
* Status-line message attributes added.
|
||||||
|
* Move word-separators to be a session rather than window option.
|
||||||
|
* Change the way the working directory for new processes is discovered. If
|
||||||
|
default-path isn't empty, it is used. Otherwise, if a new window is created
|
||||||
|
from the command-line, the working directory of the client is used. If not,
|
||||||
|
platform specific code is used to retrieve the current working directory
|
||||||
|
of the process in the active pane. If that fails, the directory where the
|
||||||
|
session was created is used, instead.
|
||||||
|
* Do not change the current pane if both mouse-select-{pane,window} are
|
||||||
|
enabled.
|
||||||
|
* Add \033[s and \033[u to save and restore cursor position.
|
||||||
|
* Allow $HOME to be used as default-path.
|
||||||
|
* Add CNL and CPL escape sequences.
|
||||||
|
* Calculate last position correctly for UTF-8 wide characters.
|
||||||
|
* Add an option allow-rename to disable the window rename escape sequence.
|
||||||
|
* Attributes for each type of status-line alert (ie bell, content and
|
||||||
|
activity) added. Therefore, remove the superfluous options
|
||||||
|
window-status-alert-{attr,bg,fg}.
|
||||||
|
* Add a -R flag to send-keys to reset the terminal.
|
||||||
|
* Add strings to allow the aixterm bright colours to be used when
|
||||||
|
configuring colours.
|
||||||
|
* Drop the ability to have a list of keys in the prefix in favour of two
|
||||||
|
separate options, prefix and prefix2.
|
||||||
|
* Flag -2 added to send-prefix to send the secondary prefix key.
|
||||||
|
* Show pane size in top right of display panes mode.
|
||||||
|
* Some memory leaks plugged.
|
||||||
|
* More command-prompt editing improvements.
|
||||||
|
* Various manpage improvements.
|
||||||
|
* More Vi mode improvements.
|
||||||
|
|
||||||
|
CHANGES FROM 1.4 TO 1.5, 09 July 2011
|
||||||
|
|
||||||
|
* Support xterm mouse modes 1002 and 1003.
|
||||||
|
* Change from a per-session stack of buffers to one global stack. This renders
|
||||||
|
copy-buffer useless and makes buffer-limit now a server option.
|
||||||
|
* Fix most-recently-used choice by avoiding reset the activity timer for
|
||||||
|
unattached sessions every second.
|
||||||
|
* Add a -P option to new-window and split-window to print the new window or
|
||||||
|
pane index in target form (useful to pass it into other commands).
|
||||||
|
* Handle a # at the end of a replacement string (such as status-left)
|
||||||
|
correctly.
|
||||||
|
* Support for UTF-8 mouse input (\033[1005h) which was added in xterm 262.
|
||||||
|
If the new mouse-utf8 option is on, UTF-8 mouse input is enabled for all
|
||||||
|
UTF-8 terminals. The option defaults to on if LANG etc are set in the same
|
||||||
|
manner as the utf8 option.
|
||||||
|
* Support for HP-UX.
|
||||||
|
* Accept colours of the hex form #ffffff and translate to the nearest from the
|
||||||
|
xterm(1) 256-colour set.
|
||||||
|
* Clear the non-blocking IO flag (O_NONBLOCK) on the stdio file descriptors
|
||||||
|
before closing them (fixes things like "tmux ls && cat").
|
||||||
|
* Use TMPDIR if set.
|
||||||
|
* Fix next and previous session functions to actually work.
|
||||||
|
* Support -x and -y for new-session to specify the initial size of the window
|
||||||
|
if created detached with -d.
|
||||||
|
* Make bind-key accept characters with the top-bit-set and print them as octal.
|
||||||
|
* Set $TMUX without the session when background jobs are run.
|
||||||
|
* Simplify the way jobs work and drop the persist type, so all jobs are
|
||||||
|
fire-and-forget.
|
||||||
|
* Accept tcgetattr/tcsetattr(3) failure, fixes problems with fatal() if the
|
||||||
|
terminal disappears while locked.
|
||||||
|
* Add a -P option to detach to HUP the client's parent process (usually causing
|
||||||
|
it to exit as well).
|
||||||
|
* Support passing through escape sequences to the underlying terminal by using
|
||||||
|
DCS with a "tmux;" prefix.
|
||||||
|
* Prevent tiled producing a corrupt layout when only one column is needed.
|
||||||
|
* Give each pane created in a tmux server a unique id (starting from 0), put it
|
||||||
|
in the TMUX_PANE environment variable and accept it as a target.
|
||||||
|
* Allow a start and end line to be specified for capture-pane which may be
|
||||||
|
negative to capture part of the history.
|
||||||
|
* Add -a and -s options to lsp to list all panes in the server or session
|
||||||
|
respectively. Likewise add -s to lsw.
|
||||||
|
* Change -t on display-message to be target-pane for the #[A-Z] replacements
|
||||||
|
and add -c as target-client.
|
||||||
|
* The attach-session command now prefers the most recently used unattached
|
||||||
|
session.
|
||||||
|
* Add -s option to detach-client to detach all clients attached to a session.
|
||||||
|
* Add -t to list-clients.
|
||||||
|
* Change window with mouse wheel over status line if mouse-select-window is on.
|
||||||
|
* When mode-mouse is on, automatically enter copy mode when the mouse is
|
||||||
|
dragged or the mouse wheel is used. Also exit copy mode when the mouse wheel
|
||||||
|
is scrolled off the bottom.
|
||||||
|
* Provide #h character pair for short hostname (no domain).
|
||||||
|
* Don't use strnvis(3) for the title as it breaks UTF-8.
|
||||||
|
* Use the tsl and fsl terminfo(5) capabilities to update terminal title and
|
||||||
|
automatically fill them in on terminals with the XT capability (which means
|
||||||
|
their title setting is xterm-compatible).
|
||||||
|
* Add a new option, mouse-resize-pane. When on, panes may be resized by
|
||||||
|
dragging their borders.
|
||||||
|
* Fix crash by resetting last pane on {break,swap}-pane across windows.
|
||||||
|
* Add three new copy-mode commands - select-line, copy-line, copy-end-of-line.
|
||||||
|
* Support setting the xterm clipboard when copying from copy mode using the
|
||||||
|
xterm escape sequence for the purpose (if xterm is configured to allow it).
|
||||||
|
* Support xterm(1) cursor colour change sequences through terminfo(5) Cc
|
||||||
|
(set) and Cr (reset) extensions.
|
||||||
|
* Support DECSCUSR sequence to set the cursor style with two new terminfo(5)
|
||||||
|
extensions, Cs and Csr.
|
||||||
|
* Make the command-prompt custom prompts recognize the status-left option
|
||||||
|
character pairs.
|
||||||
|
* Add a respawn-pane command.
|
||||||
|
* Add a couple of extra xterm-style keys that gnome terminal provides.
|
||||||
|
* Allow the initial context on prompts to be set with the new -I option to
|
||||||
|
command-prompt. Include the current window and session name in the prompt
|
||||||
|
when renaming and add a new key binding ($) for rename session.
|
||||||
|
* Option bell-on-alert added to trigger the terminal bell when there is an
|
||||||
|
alert.
|
||||||
|
* Change the list-keys format so that it shows the keys using actual tmux
|
||||||
|
commands which should be able to be directly copied into the config file.
|
||||||
|
* Show full targets for lsp/lsw -a.
|
||||||
|
* Make confirm-before prompt customizable with -p option like command-prompt
|
||||||
|
and add the character pairs #W and #P to the default kill-{pane,window}
|
||||||
|
prompts.
|
||||||
|
* Avoid sending data to suspended/locked clients.
|
||||||
|
* Small memory leaks in error paths plugged.
|
||||||
|
* Vi mode improvements.
|
||||||
|
|
||||||
CHANGES FROM 1.3 TO 1.4, 27 December 2010
|
CHANGES FROM 1.3 TO 1.4, 27 December 2010
|
||||||
|
|
||||||
* Window bell reporting fixed.
|
* Window bell reporting fixed.
|
||||||
@@ -1554,7 +1866,7 @@ The list of older changes is below.
|
|||||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||||
customisation.
|
customisation.
|
||||||
|
|
||||||
$Id: CHANGES,v 1.304 2010-12-27 21:37:42 tcunha Exp $
|
$Id$
|
||||||
|
|
||||||
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
|
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
|
||||||
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
|
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
|
||||||
|
|||||||
21
COPYING
Normal file
21
COPYING
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
THIS IS FOR INFORMATION ONLY, CODE IS UNDER THE LICENCE AT THE TOP OF ITS FILE.
|
||||||
|
|
||||||
|
The README, CHANGES, FAQ and TODO files are licensed under the ISC
|
||||||
|
license. Files under examples/ remain copyright their authors unless otherwise
|
||||||
|
stated in the file but permission has been received to distribute them with
|
||||||
|
tmux. All other files have a license and copyright notice at their start,
|
||||||
|
typically:
|
||||||
|
|
||||||
|
Copyright (c) <author>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
151
FAQ
151
FAQ
@@ -103,8 +103,7 @@ aware of are (bearing in mind I haven't used screen for a few years now):
|
|||||||
- tmux tends to be more demanding on the terminal so tends to show up terminal
|
- tmux tends to be more demanding on the terminal so tends to show up terminal
|
||||||
and application bugs which screen does not.
|
and application bugs which screen does not.
|
||||||
|
|
||||||
- screen has wider platform support, for example IRIX and HP-UX, and for odd
|
- screen has wider platform support, for example IRIX, and for odd terminals.
|
||||||
terminals.
|
|
||||||
|
|
||||||
* I found a bug! What do I do?
|
* I found a bug! What do I do?
|
||||||
|
|
||||||
@@ -239,6 +238,31 @@ would be welcome.
|
|||||||
|
|
||||||
vim users may also want to set the "ttyfast" option inside tmux.
|
vim users may also want to set the "ttyfast" option inside tmux.
|
||||||
|
|
||||||
|
* How do I make ctrl and shift arrow keys work in emacs?
|
||||||
|
|
||||||
|
The terminal-init-screen function in term/screen.el is called for new frames,
|
||||||
|
but it doesn't configure any function keys.
|
||||||
|
|
||||||
|
If the tmux xterm-keys option is on, it is enough to define the same keys as
|
||||||
|
xterm. Add the following to init.el or .emacs to do this:
|
||||||
|
|
||||||
|
(defadvice terminal-init-screen
|
||||||
|
;; The advice is named `tmux', and is run before `terminal-init-screen' runs.
|
||||||
|
(before tmux activate)
|
||||||
|
;; Docstring. This describes the advice and is made available inside emacs;
|
||||||
|
;; for example when doing C-h f terminal-init-screen RET
|
||||||
|
"Apply xterm keymap, allowing use of keys passed through tmux."
|
||||||
|
;; This is the elisp code that is run before `terminal-init-screen'.
|
||||||
|
(if (getenv "TMUX")
|
||||||
|
(let ((map (copy-keymap xterm-function-map)))
|
||||||
|
(set-keymap-parent map (keymap-parent input-decode-map))
|
||||||
|
(set-keymap-parent input-decode-map map))))
|
||||||
|
|
||||||
|
And ensure .tmux.conf contains "set -g xterm-keys on".
|
||||||
|
|
||||||
|
Alternatively, the screen.el file can be copied to the load path and
|
||||||
|
customized.
|
||||||
|
|
||||||
* Why doesn't elinks set the window title inside tmux?
|
* Why doesn't elinks set the window title inside tmux?
|
||||||
|
|
||||||
There isn't a way to detect if a terminal supports setting the window title, so
|
There isn't a way to detect if a terminal supports setting the window title, so
|
||||||
@@ -327,49 +351,114 @@ lock(1) or vlock(1)) by using the following:
|
|||||||
|
|
||||||
bind x set lock-command '/usr/bin/vlock' \; lock-client \; set lock-command 'tput civis && read -s -n1'
|
bind x set lock-command '/usr/bin/vlock' \; lock-client \; set lock-command 'tput civis && read -s -n1'
|
||||||
|
|
||||||
* How can I open a new window in the same directory as the current window?
|
* vim displays reverse video instead of italics, while less displays italics
|
||||||
|
(or just regular text) instead of reverse. What's wrong?
|
||||||
|
|
||||||
One option is to just run "TMUX= tmux" in the window. However, this only works if no
|
Screen's terminfo description lacks italics mode and has standout mode in its
|
||||||
command is running, so that you can input the command.
|
place, but using the same escape sequence that urxvt uses for italics. This
|
||||||
|
means applications (like vim) looking for italics will not find it and might
|
||||||
|
turn to reverse in its place, while applications (like less) asking for
|
||||||
|
standout will end up with italics instead of reverse. To make applications
|
||||||
|
aware that tmux supports italics and to use a proper escape sequence for
|
||||||
|
standout, you'll need to create a new terminfo file with modified sgr, smso,
|
||||||
|
rmso, sitm and ritm entries:
|
||||||
|
|
||||||
A workaround is to let tmux know about the current path through an environment
|
$ mkdir $HOME/.terminfo/
|
||||||
variable. To do so, use the following command:
|
$ screen_terminfo="screen"
|
||||||
|
$ infocmp "$screen_terminfo" | sed \
|
||||||
|
-e 's/^screen[^|]*|[^,]*,/screen-it|screen with italics support,/' \
|
||||||
|
-e 's/%?%p1%t;3%/%?%p1%t;7%/' \
|
||||||
|
-e 's/smso=[^,]*,/smso=\\E[7m,/' \
|
||||||
|
-e 's/rmso=[^,]*,/rmso=\\E[27m,/' \
|
||||||
|
-e '$s/$/ sitm=\\E[3m, ritm=\\E[23m,/' > /tmp/screen.terminfo
|
||||||
|
$ tic /tmp/screen.terminfo
|
||||||
|
|
||||||
[ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I") $PWD
|
And tell tmux to use it in ~/.tmux.conf:
|
||||||
|
|
||||||
|
set -g default-terminal "screen-it"
|
||||||
|
|
||||||
Which sets TMUXPWD_i (where i is the number of the current window) to the path
|
If your terminal supports 256 colors, use:
|
||||||
of the current directory. This command can be added to PS1, for example:
|
|
||||||
|
|
||||||
PS1='$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I") $PWD)\h$ '
|
$ screen_terminfo="screen-256color"
|
||||||
|
|
||||||
When a new window is created, the shell should be asked to change
|
instead of "screen". See the FAQ entry about 256 colors support for more info.
|
||||||
directory. You can define a new binding (for example, if using GNU bash):
|
Also note that tmux will still display reverse video on terminals that do not
|
||||||
|
support italics.
|
||||||
|
|
||||||
bind-key C-c run-shell 'tmux neww "cd $(tmux display -p "\$TMUXPWD_#I"); exec bash"'
|
If your urxvt cannot display italics at all, make sure you have an italics
|
||||||
|
capable font enabled, for example, add to ~/.Xdefaults:
|
||||||
|
|
||||||
This solution will work even if a command is currently running in the terminal,
|
urxvt.italicFont: xft:Bitstream Vera Sans Mono:italic:autohint=true
|
||||||
but it will not work from a window that has just been swapped with another
|
|
||||||
because TMUXPWD_i will not be updated after a swap. However, once a new prompt
|
|
||||||
is displayed, TMUXPWD_i is updated properly.
|
|
||||||
|
|
||||||
* tmux doesn't start with "daemon failed"
|
* How can I make tmux use my terminal's scrollback buffer?
|
||||||
|
|
||||||
tmux shows something similar to this when started:
|
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.
|
||||||
|
|
||||||
fatal: server_start: daemon failed: No such file or directory
|
You can make tmux use the normal screen by telling it that your terminal does
|
||||||
fatal: main_dispatch: imsg_read failed
|
not have an alternate screen. Put the following in ~/.tmux.conf:
|
||||||
|
|
||||||
A possible reason is that /dev/null is not a character device or is otherwise
|
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
|
||||||
inaccessible.
|
|
||||||
|
|
||||||
Check with:
|
Adjust if your $TERM does not start with xterm.
|
||||||
|
|
||||||
file /dev/null
|
tmux will still emulate the alternate screen for applications run under tmux,
|
||||||
ls -l /dev/null
|
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.
|
||||||
|
|
||||||
If it is not a character device or has incorrect permissions, it can typically
|
* How do I see the default configuration?
|
||||||
be recreated with:
|
|
||||||
|
|
||||||
cd /dev && rm null && ./MAKEDEV null
|
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
|
||||||
|
|
||||||
$Id: FAQ,v 1.41 2010-12-15 23:31:30 nicm Exp $
|
* 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
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|||||||
87
GNUmakefile
87
GNUmakefile
@@ -1,87 +0,0 @@
|
|||||||
# $Id: GNUmakefile,v 1.130 2010-12-27 21:32:16 tcunha Exp $
|
|
||||||
#
|
|
||||||
# Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
#
|
|
||||||
# Permission to use, copy, modify, and distribute this software for any
|
|
||||||
# purpose with or without fee is hereby granted, provided that the above
|
|
||||||
# copyright notice and this permission notice appear in all copies.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
# WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
#
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
VERSION= 1.4
|
|
||||||
|
|
||||||
#FDEBUG= 1
|
|
||||||
|
|
||||||
CC?= cc
|
|
||||||
CFLAGS+= -DBUILD="\"$(VERSION)\""
|
|
||||||
LDFLAGS+= -L/usr/local/lib
|
|
||||||
LIBS+=
|
|
||||||
|
|
||||||
# Sun CC
|
|
||||||
ifneq ($(shell ($(CC) -V 2>&1|awk '/Sun C/' || true)), )
|
|
||||||
CFLAGS+= -erroff=E_EMPTY_DECLARATION
|
|
||||||
FDEBUG=
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef FDEBUG
|
|
||||||
CFLAGS+= -g -ggdb -DDEBUG
|
|
||||||
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
|
|
||||||
endif
|
|
||||||
|
|
||||||
# This sort of sucks but gets rid of the stupid warning and should work on
|
|
||||||
# most platforms...
|
|
||||||
ifeq ($(shell (LC_ALL=C $(CC) -v 2>&1|awk '/gcc version 4|clang/') || true), )
|
|
||||||
CPPFLAGS:= -I. -I- $(CPPFLAGS)
|
|
||||||
else
|
|
||||||
CPPFLAGS:= -iquote. $(CPPFLAGS)
|
|
||||||
ifdef FDEBUG
|
|
||||||
CFLAGS+= -Wno-pointer-sign
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
PREFIX?= /usr/local
|
|
||||||
INSTALL?= install
|
|
||||||
INSTALLDIR= $(INSTALL) -d
|
|
||||||
INSTALLBIN= $(INSTALL) -m 555
|
|
||||||
INSTALLMAN= $(INSTALL) -m 444
|
|
||||||
|
|
||||||
SRCS= $(shell echo *.c|LC_ALL=C sed 's|osdep-[a-z0-9]*.c||g')
|
|
||||||
include config.mk
|
|
||||||
OBJS= $(patsubst %.c,%.o,$(SRCS))
|
|
||||||
|
|
||||||
all: tmux
|
|
||||||
|
|
||||||
tmux: $(OBJS)
|
|
||||||
$(CC) $(LDFLAGS) -o tmux $+ $(LIBS)
|
|
||||||
|
|
||||||
depend: $(SRCS)
|
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -MM $(SRCS) > .depend
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f tmux *.o *~ *.core *.log compat/*.o compat/*~
|
|
||||||
|
|
||||||
clean-depend:
|
|
||||||
rm -f .depend
|
|
||||||
|
|
||||||
clean-all: clean clean-depend
|
|
||||||
rm -f config.h config.mk
|
|
||||||
|
|
||||||
install: all
|
|
||||||
$(INSTALLDIR) $(DESTDIR)$(PREFIX)/bin
|
|
||||||
$(INSTALLBIN) tmux $(DESTDIR)$(PREFIX)/bin/tmux
|
|
||||||
$(INSTALLDIR) $(DESTDIR)$(PREFIX)/man/man1
|
|
||||||
$(INSTALLMAN) tmux.1 $(DESTDIR)$(PREFIX)/man/man1/tmux.1
|
|
||||||
|
|
||||||
-include .depend
|
|
||||||
84
Makefile
84
Makefile
@@ -1,84 +0,0 @@
|
|||||||
# $Id: Makefile,v 1.162 2010-12-27 21:32:16 tcunha Exp $
|
|
||||||
#
|
|
||||||
# Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
#
|
|
||||||
# Permission to use, copy, modify, and distribute this software for any
|
|
||||||
# purpose with or without fee is hereby granted, provided that the above
|
|
||||||
# copyright notice and this permission notice appear in all copies.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
# WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
#
|
|
||||||
|
|
||||||
.SUFFIXES: .c .o
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
VERSION= 1.4
|
|
||||||
|
|
||||||
#FDEBUG= 1
|
|
||||||
|
|
||||||
CC?= cc
|
|
||||||
CFLAGS+= -DBUILD="\"$(VERSION)\""
|
|
||||||
LDFLAGS+= -L/usr/local/lib
|
|
||||||
LIBS+=
|
|
||||||
|
|
||||||
.ifdef FDEBUG
|
|
||||||
CFLAGS+= -g -ggdb -DDEBUG
|
|
||||||
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
|
|
||||||
.endif
|
|
||||||
|
|
||||||
# This sort of sucks but gets rid of the stupid warning and should work on
|
|
||||||
# most platforms...
|
|
||||||
CCV!= (LC_ALL=C ${CC} -v 2>&1|awk '/gcc version 4|clang/') || true
|
|
||||||
.if empty(CCV)
|
|
||||||
CPPFLAGS:= -I. -I- -I/usr/local/include ${CPPFLAGS}
|
|
||||||
.else
|
|
||||||
CPPFLAGS:= -iquote. -I/usr/local/include ${CPPFLAGS}
|
|
||||||
.ifdef FDEBUG
|
|
||||||
CFLAGS+= -Wno-pointer-sign
|
|
||||||
.endif
|
|
||||||
.endif
|
|
||||||
|
|
||||||
PREFIX?= /usr/local
|
|
||||||
INSTALL?= install
|
|
||||||
INSTALLDIR= ${INSTALL} -d
|
|
||||||
INSTALLBIN= ${INSTALL} -m 555
|
|
||||||
INSTALLMAN= ${INSTALL} -m 444
|
|
||||||
|
|
||||||
SRCS!= echo *.c|LC_ALL=C sed 's|osdep-[a-z0-9]*.c||g'
|
|
||||||
.include "config.mk"
|
|
||||||
OBJS= ${SRCS:S/.c/.o/}
|
|
||||||
|
|
||||||
.c.o:
|
|
||||||
${CC} ${CPPFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
|
|
||||||
|
|
||||||
all: tmux
|
|
||||||
|
|
||||||
tmux: ${OBJS}
|
|
||||||
${CC} ${LDFLAGS} -o tmux ${OBJS} ${LIBS}
|
|
||||||
|
|
||||||
depend:
|
|
||||||
mkdep ${CPPFLAGS} ${CFLAGS} ${SRCS:M*.c}
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f tmux *.o *~ *.core *.log compat/*.o compat/*~
|
|
||||||
|
|
||||||
clean-depend:
|
|
||||||
rm -f .depend
|
|
||||||
|
|
||||||
clean-all: clean clean-depend
|
|
||||||
rm -f config.h config.mk
|
|
||||||
|
|
||||||
install: all
|
|
||||||
${INSTALLDIR} ${DESTDIR}${PREFIX}/bin
|
|
||||||
${INSTALLBIN} tmux ${DESTDIR}${PREFIX}/bin/
|
|
||||||
${INSTALLDIR} ${DESTDIR}${PREFIX}/man/man1
|
|
||||||
${INSTALLMAN} tmux.1 ${DESTDIR}${PREFIX}/man/man1/
|
|
||||||
271
Makefile.am
Normal file
271
Makefile.am
Normal file
@@ -0,0 +1,271 @@
|
|||||||
|
# $Id$
|
||||||
|
|
||||||
|
# Obvious program stuff.
|
||||||
|
bin_PROGRAMS = tmux
|
||||||
|
CLEANFILES = tmux.1.mdoc tmux.1.man
|
||||||
|
|
||||||
|
# Distribution tarball options.
|
||||||
|
EXTRA_DIST = \
|
||||||
|
CHANGES FAQ README TODO COPYING examples compat \
|
||||||
|
array.h compat.h tmux.h osdep-*.c mdoc2man.awk tmux.1
|
||||||
|
dist-hook:
|
||||||
|
make clean
|
||||||
|
grep "^#found_debug=" configure
|
||||||
|
find $(distdir) -name .svn -type d|xargs rm -Rf
|
||||||
|
|
||||||
|
# Preprocessor flags.
|
||||||
|
CPPFLAGS += @XOPEN_DEFINES@ -DTMUX_CONF="\"$(sysconfdir)/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
|
||||||
|
|
||||||
|
# Set flags for gcc. gcc4 whines abouts silly stuff so it needs slightly
|
||||||
|
# different flags.
|
||||||
|
if IS_GCC
|
||||||
|
CFLAGS += -std=gnu99
|
||||||
|
if IS_DEBUG
|
||||||
|
CFLAGS += -O0 -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
|
||||||
|
CPPFLAGS += -DDEBUG
|
||||||
|
else
|
||||||
|
CFLAGS += -O2
|
||||||
|
endif
|
||||||
|
if IS_GCC4
|
||||||
|
CPPFLAGS += -iquote. -I/usr/local/include
|
||||||
|
if IS_DEBUG
|
||||||
|
CFLAGS += -Wno-pointer-sign
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
CPPFLAGS += -I. -I- -I/usr/local/include
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Set flags for Solaris.
|
||||||
|
if IS_SUNOS
|
||||||
|
if IS_GCC
|
||||||
|
CPPFLAGS += -D_XPG6 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS
|
||||||
|
else
|
||||||
|
CPPFLAGS += -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Set flags for Sun CC.
|
||||||
|
if IS_SUNCC
|
||||||
|
CFLAGS += -erroff=E_EMPTY_DECLARATION
|
||||||
|
endif
|
||||||
|
|
||||||
|
# List of sources.
|
||||||
|
dist_tmux_SOURCES = \
|
||||||
|
arguments.c \
|
||||||
|
attributes.c \
|
||||||
|
cfg.c \
|
||||||
|
client.c \
|
||||||
|
clock.c \
|
||||||
|
cmd-attach-session.c \
|
||||||
|
cmd-bind-key.c \
|
||||||
|
cmd-break-pane.c \
|
||||||
|
cmd-capture-pane.c \
|
||||||
|
cmd-choose-buffer.c \
|
||||||
|
cmd-choose-client.c \
|
||||||
|
cmd-choose-list.c \
|
||||||
|
cmd-choose-tree.c \
|
||||||
|
cmd-clear-history.c \
|
||||||
|
cmd-clock-mode.c \
|
||||||
|
cmd-command-prompt.c \
|
||||||
|
cmd-confirm-before.c \
|
||||||
|
cmd-copy-mode.c \
|
||||||
|
cmd-delete-buffer.c \
|
||||||
|
cmd-detach-client.c \
|
||||||
|
cmd-display-message.c \
|
||||||
|
cmd-display-panes.c \
|
||||||
|
cmd-find-window.c \
|
||||||
|
cmd-has-session.c \
|
||||||
|
cmd-if-shell.c \
|
||||||
|
cmd-join-pane.c \
|
||||||
|
cmd-kill-pane.c \
|
||||||
|
cmd-kill-server.c \
|
||||||
|
cmd-kill-session.c \
|
||||||
|
cmd-kill-window.c \
|
||||||
|
cmd-link-window.c \
|
||||||
|
cmd-list-buffers.c \
|
||||||
|
cmd-list-clients.c \
|
||||||
|
cmd-list-commands.c \
|
||||||
|
cmd-list-keys.c \
|
||||||
|
cmd-list-panes.c \
|
||||||
|
cmd-list-sessions.c \
|
||||||
|
cmd-list-windows.c \
|
||||||
|
cmd-list.c \
|
||||||
|
cmd-load-buffer.c \
|
||||||
|
cmd-lock-server.c \
|
||||||
|
cmd-move-window.c \
|
||||||
|
cmd-new-session.c \
|
||||||
|
cmd-new-window.c \
|
||||||
|
cmd-paste-buffer.c \
|
||||||
|
cmd-pipe-pane.c \
|
||||||
|
cmd-queue.c \
|
||||||
|
cmd-refresh-client.c \
|
||||||
|
cmd-rename-session.c \
|
||||||
|
cmd-rename-window.c \
|
||||||
|
cmd-resize-pane.c \
|
||||||
|
cmd-respawn-pane.c \
|
||||||
|
cmd-respawn-window.c \
|
||||||
|
cmd-rotate-window.c \
|
||||||
|
cmd-run-shell.c \
|
||||||
|
cmd-save-buffer.c \
|
||||||
|
cmd-select-layout.c \
|
||||||
|
cmd-select-pane.c \
|
||||||
|
cmd-select-window.c \
|
||||||
|
cmd-send-keys.c \
|
||||||
|
cmd-set-buffer.c \
|
||||||
|
cmd-set-environment.c \
|
||||||
|
cmd-set-option.c \
|
||||||
|
cmd-show-environment.c \
|
||||||
|
cmd-show-messages.c \
|
||||||
|
cmd-show-options.c \
|
||||||
|
cmd-source-file.c \
|
||||||
|
cmd-split-window.c \
|
||||||
|
cmd-string.c \
|
||||||
|
cmd-suspend-client.c \
|
||||||
|
cmd-swap-pane.c \
|
||||||
|
cmd-swap-window.c \
|
||||||
|
cmd-switch-client.c \
|
||||||
|
cmd-unbind-key.c \
|
||||||
|
cmd-unlink-window.c \
|
||||||
|
cmd-wait-for.c \
|
||||||
|
cmd.c \
|
||||||
|
colour.c \
|
||||||
|
control.c \
|
||||||
|
control-notify.c \
|
||||||
|
environ.c \
|
||||||
|
format.c \
|
||||||
|
grid-cell.c \
|
||||||
|
grid-view.c \
|
||||||
|
grid.c \
|
||||||
|
input-keys.c \
|
||||||
|
input.c \
|
||||||
|
job.c \
|
||||||
|
key-bindings.c \
|
||||||
|
key-string.c \
|
||||||
|
layout-custom.c \
|
||||||
|
layout-set.c \
|
||||||
|
layout.c \
|
||||||
|
log.c \
|
||||||
|
mode-key.c \
|
||||||
|
names.c \
|
||||||
|
notify.c \
|
||||||
|
options-table.c \
|
||||||
|
options.c \
|
||||||
|
paste.c \
|
||||||
|
resize.c \
|
||||||
|
screen-redraw.c \
|
||||||
|
screen-write.c \
|
||||||
|
screen.c \
|
||||||
|
server-client.c \
|
||||||
|
server-fn.c \
|
||||||
|
server-window.c \
|
||||||
|
server.c \
|
||||||
|
session.c \
|
||||||
|
signal.c \
|
||||||
|
status.c \
|
||||||
|
style.c \
|
||||||
|
tmux.c \
|
||||||
|
tty-acs.c \
|
||||||
|
tty-keys.c \
|
||||||
|
tty-term.c \
|
||||||
|
tty.c \
|
||||||
|
utf8.c \
|
||||||
|
window-choose.c \
|
||||||
|
window-clock.c \
|
||||||
|
window-copy.c \
|
||||||
|
window.c \
|
||||||
|
xmalloc.c \
|
||||||
|
xterm-keys.c
|
||||||
|
nodist_tmux_SOURCES = osdep-@PLATFORM@.c
|
||||||
|
|
||||||
|
# Pile in all the compat/ stuff that is needed.
|
||||||
|
if NO_FORKPTY
|
||||||
|
nodist_tmux_SOURCES += compat/forkpty-@PLATFORM@.c
|
||||||
|
endif
|
||||||
|
if NO_IMSG
|
||||||
|
nodist_tmux_SOURCES += compat/imsg.c compat/imsg-buffer.c
|
||||||
|
endif
|
||||||
|
if NO_CLOSEFROM
|
||||||
|
nodist_tmux_SOURCES += compat/closefrom.c
|
||||||
|
endif
|
||||||
|
if NO_DAEMON
|
||||||
|
nodist_tmux_SOURCES += compat/daemon.c
|
||||||
|
endif
|
||||||
|
if NO_SETENV
|
||||||
|
nodist_tmux_SOURCES += compat/setenv.c
|
||||||
|
endif
|
||||||
|
if NO_STRLCAT
|
||||||
|
nodist_tmux_SOURCES += compat/strlcat.c
|
||||||
|
endif
|
||||||
|
if NO_STRLCPY
|
||||||
|
nodist_tmux_SOURCES += compat/strlcpy.c
|
||||||
|
endif
|
||||||
|
if NO_ASPRINTF
|
||||||
|
nodist_tmux_SOURCES += compat/asprintf.c
|
||||||
|
endif
|
||||||
|
if NO_FGETLN
|
||||||
|
nodist_tmux_SOURCES += compat/fgetln.c
|
||||||
|
endif
|
||||||
|
if NO_GETOPT
|
||||||
|
nodist_tmux_SOURCES += compat/getopt.c
|
||||||
|
endif
|
||||||
|
if NO_STRCASESTR
|
||||||
|
nodist_tmux_SOURCES += compat/strcasestr.c
|
||||||
|
endif
|
||||||
|
if NO_STRSEP
|
||||||
|
nodist_tmux_SOURCES += compat/strsep.c
|
||||||
|
endif
|
||||||
|
if NO_VIS
|
||||||
|
nodist_tmux_SOURCES += compat/vis.c compat/unvis.c
|
||||||
|
endif
|
||||||
|
if NO_STRTONUM
|
||||||
|
nodist_tmux_SOURCES += compat/strtonum.c
|
||||||
|
endif
|
||||||
|
if NO_B64_NTOP
|
||||||
|
nodist_tmux_SOURCES += compat/b64_ntop.c
|
||||||
|
endif
|
||||||
|
if NO_CFMAKERAW
|
||||||
|
nodist_tmux_SOURCES += compat/cfmakeraw.c
|
||||||
|
endif
|
||||||
|
if NO_OPENAT
|
||||||
|
nodist_tmux_SOURCES += compat/openat.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Install tmux.1 in the right format.
|
||||||
|
install-exec-hook:
|
||||||
|
if test x@MANFORMAT@ = xmdoc; then \
|
||||||
|
sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" $(srcdir)/tmux.1 \
|
||||||
|
>$(srcdir)/tmux.1.mdoc; \
|
||||||
|
else \
|
||||||
|
sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" $(srcdir)/tmux.1| \
|
||||||
|
$(AWK) -fmdoc2man.awk >$(srcdir)/tmux.1.man; \
|
||||||
|
fi
|
||||||
|
$(MKDIR_P) $(DESTDIR)$(mandir)/man1
|
||||||
|
$(INSTALL_DATA) $(srcdir)/tmux.1.@MANFORMAT@ \
|
||||||
|
$(DESTDIR)$(mandir)/man1/tmux.1
|
||||||
|
|
||||||
|
# Update SF web site.
|
||||||
|
upload-index.html: update-index.html
|
||||||
|
scp www/index.html www/main.css www/images/*.png \
|
||||||
|
${USER},tmux@web.sf.net:/home/groups/t/tm/tmux/htdocs
|
||||||
|
rm -f www/index.html www/images/small-*
|
||||||
|
|
||||||
|
update-index.html:
|
||||||
|
(cd www/images && \
|
||||||
|
rm -f small-* && \
|
||||||
|
for i in *.png; do \
|
||||||
|
convert "$$i" -resize 200x150 "small-$$i"; \
|
||||||
|
done \
|
||||||
|
)
|
||||||
|
sed "s/%%VERSION%%/${VERSION}/g" www/index.html.in >www/index.html
|
||||||
66
NOTES
66
NOTES
@@ -1,66 +0,0 @@
|
|||||||
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.
|
|
||||||
|
|
||||||
This release runs on OpenBSD, FreeBSD, NetBSD, Linux and OS X and may still
|
|
||||||
run on Solaris and AIX (although they haven't been tested in a while). It is
|
|
||||||
usable, although there remain a number of missing features and some remaining
|
|
||||||
bugs are expected.
|
|
||||||
|
|
||||||
Since the 1.2 release that tmux depends on libevent. Download the stable
|
|
||||||
version from:
|
|
||||||
|
|
||||||
http://www.monkey.org/~provos/libevent/
|
|
||||||
|
|
||||||
tmux consists of a server part and multiple clients. The server is created when
|
|
||||||
required and runs continuously unless killed by the user. Clients access the
|
|
||||||
server through a socket in /tmp. Multiple sessions may be created on a single
|
|
||||||
server and attached to a number of clients. Each session may then have a number
|
|
||||||
of windows and windows may be linked to a number of sessions. Commands are
|
|
||||||
available to create, rename and destroy windows and sessions; to attach and
|
|
||||||
detach sessions from client terminals; to set configuration options; to split
|
|
||||||
windows into several simultaneously displayed panes; and to bind and unbind
|
|
||||||
command keys (invoked preceded by a prefix key, by default ctrl-b). Please see
|
|
||||||
the tmux(1) man page for further information.
|
|
||||||
|
|
||||||
A more extensive, but rough, todo list is included in the TODO file.
|
|
||||||
|
|
||||||
tmux also depends on several features of the client terminal (TERM), if these
|
|
||||||
are missing it may refuse to run, or not behave correctly.
|
|
||||||
|
|
||||||
A Vim syntax file is available in the examples directory. To install it:
|
|
||||||
|
|
||||||
- Drop the file in the syntax directory in your runtimepath (such as
|
|
||||||
~/.vim/syntax/tmux.vim).
|
|
||||||
- Make the filetype recognisable by adding the following to filetype.vim
|
|
||||||
in your runtimepath (~/.vim/filetype.vim):
|
|
||||||
|
|
||||||
augroup filetypedetect
|
|
||||||
au BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
- Switch on syntax highlighting by adding "syntax enable" to your vimrc file.
|
|
||||||
|
|
||||||
For debugging, running tmux with -v or -vv will generate server and client log
|
|
||||||
files in the current directory.
|
|
||||||
|
|
||||||
tmux mailing lists are available; visit:
|
|
||||||
|
|
||||||
https://sourceforge.net/mail/?group_id=200378
|
|
||||||
|
|
||||||
Bug reports, feature suggestions and especially code contributions are most
|
|
||||||
welcome. Please send by email to:
|
|
||||||
|
|
||||||
nicm@users.sf.net
|
|
||||||
|
|
||||||
This file and the CHANGES, FAQ and TODO files are licensed under the ISC
|
|
||||||
license. Files under examples/ remain copyright their authors unless otherwise
|
|
||||||
stated in the file but permission has been received to distribute them with
|
|
||||||
tmux. All other files have a license and copyright notice at their
|
|
||||||
start. Please contact me with any queries.
|
|
||||||
|
|
||||||
-- Nicholas Marriott <nicm@users.sf.net>
|
|
||||||
|
|
||||||
$Id: NOTES,v 1.54 2010-12-27 21:36:37 tcunha Exp $
|
|
||||||
60
README
Normal file
60
README
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
|
This release runs on OpenBSD, FreeBSD, NetBSD, Linux and OS X and may still
|
||||||
|
run on Solaris and AIX (although they haven't been tested in a while).
|
||||||
|
|
||||||
|
tmux depends on libevent 2.x. Download it from:
|
||||||
|
|
||||||
|
http://www.monkey.org/~provos/libevent/
|
||||||
|
|
||||||
|
To build tmux from a release tarball, do:
|
||||||
|
|
||||||
|
$ ./configure && make
|
||||||
|
$ sudo make install
|
||||||
|
|
||||||
|
To get and build the latest from version control:
|
||||||
|
|
||||||
|
$ git clone git://git.code.sf.net/p/tmux/tmux-code tmux
|
||||||
|
$ cd tmux
|
||||||
|
$ sh autogen.sh
|
||||||
|
$ ./configure && make
|
||||||
|
|
||||||
|
For more information see https://sourceforge.net/scm/?type=git&group_id=200378
|
||||||
|
and http://git-scm.com. Patches should be sent by email to the mailing list at
|
||||||
|
tmux-users@lists.sourceforge.net.
|
||||||
|
|
||||||
|
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. Visit:
|
||||||
|
|
||||||
|
https://sourceforge.net/mail/?group_id=200378
|
||||||
|
|
||||||
|
Bug reports, feature suggestions and especially code contributions are most
|
||||||
|
welcome. Please send by email to:
|
||||||
|
|
||||||
|
tmux-users@lists.sourceforge.net
|
||||||
|
|
||||||
|
This file and the CHANGES, FAQ and TODO files are licensed under the ISC
|
||||||
|
license. Files under examples/ remain copyright their authors unless otherwise
|
||||||
|
stated in the file but permission has been received to distribute them with
|
||||||
|
tmux. All other files have a license and copyright notice at their start.
|
||||||
|
|
||||||
|
-- Nicholas Marriott <nicm@users.sf.net>
|
||||||
|
|
||||||
|
$Id$
|
||||||
174
SYNCING
Normal file
174
SYNCING
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
Preamble
|
||||||
|
========
|
||||||
|
|
||||||
|
Tmux on SourceForge has two git repositories [1] "tmux-code" and "tmux-openbsd".
|
||||||
|
Here's a description of them:
|
||||||
|
|
||||||
|
* "tmux-code" is the portable version, the one which contains code for other
|
||||||
|
operating systems, and autotools, etc., which isn't found or needed in the
|
||||||
|
OpenBSD base system.
|
||||||
|
|
||||||
|
* "tmux-openbsd" is the version of tmux in OpenBSD base system which provides
|
||||||
|
the basis of the portable tmux version.
|
||||||
|
|
||||||
|
Note: The "tmux-openbsd" repository is actually handled by "git cvsimport"
|
||||||
|
running at 15 minute intervals, so a commit made to OpenBSD's tmux CVS
|
||||||
|
repository will take at least that long to appear in this git repository.
|
||||||
|
(It might take longer, depending on the CVS mirror used to import the
|
||||||
|
OpenBSD code).
|
||||||
|
|
||||||
|
It is assumed that the person doing the sync has read/write access to the
|
||||||
|
tmux-code repository on SourceForge already.
|
||||||
|
|
||||||
|
If you've never used git before, git tracks meta-data about the committer
|
||||||
|
and the author, as part of a commit, hence:
|
||||||
|
|
||||||
|
% git config [--global] user.name "Your name"
|
||||||
|
% git config [--global] user.email "you@yourdomain.com"
|
||||||
|
|
||||||
|
Note that, if you already have this in the global ~/.gitconfig option, then
|
||||||
|
this will be used. Setting this per-repository would involve not using the
|
||||||
|
"--global" flag above. If you wish to use the same credentials always,
|
||||||
|
pass the "--global" option, as shown.
|
||||||
|
|
||||||
|
This is a one-off operation once the repository has been cloned, assuming
|
||||||
|
this information has ever been set before.
|
||||||
|
|
||||||
|
Cloning repositories
|
||||||
|
====================
|
||||||
|
|
||||||
|
This involves having both tmux-code and tmux-openbsd cloned, as in:
|
||||||
|
|
||||||
|
% cd /some/where/useful
|
||||||
|
% git clone ssh://${USER}@git.code.sf.net/p/tmux/tmux
|
||||||
|
% git clone ssh://${USER}@git.code.sf.net/p/tmux/tmux-openbsd
|
||||||
|
|
||||||
|
Note that you do not need additional checkouts to manage the sync -- an
|
||||||
|
existing clone of either repositories will suffice. So if you already have
|
||||||
|
these checkouts existing, skip that.
|
||||||
|
|
||||||
|
Adding in git-remotes
|
||||||
|
=====================
|
||||||
|
|
||||||
|
Because the portable "tmux-code" git repository and the "tmux-openbsd"
|
||||||
|
repository do not inherently share any history between each other, the
|
||||||
|
history has been faked between them. This "faking of history" is something
|
||||||
|
which has to be told to git for the purposes of comparing the "tmux" and
|
||||||
|
"tmux-openbsd" repositories for syncing. To do this, we must reference the
|
||||||
|
clone of the "tmux-openbsd" repository from the "tmux-code" repository, as
|
||||||
|
shown by the following command:
|
||||||
|
|
||||||
|
% cd /path/to/tmux-code
|
||||||
|
% git remote add obsd-tmux file:///path/to/tmux-openbsd
|
||||||
|
|
||||||
|
So that now, the remote "obsd-tmux" can be used to reference branches and
|
||||||
|
commits from the "tmux-openbsd" repository, but from the context of the
|
||||||
|
portable "tmux-code" repository, which makes sense because it's the "tmux"
|
||||||
|
repository which will have the updates applied to them.
|
||||||
|
|
||||||
|
Fetching updates
|
||||||
|
================
|
||||||
|
|
||||||
|
To ensure the latest commits from "tmux-openbsd" can be found from within
|
||||||
|
"tmux-code", we have to ensure the "master" branch from "tmux-openbsd" is
|
||||||
|
up-to-date first, and then reference that update in "tmux-code", as in:
|
||||||
|
|
||||||
|
% cd /path/to/tmux-openbsd
|
||||||
|
% git checkout master
|
||||||
|
% git pull
|
||||||
|
|
||||||
|
Then back in "tmux-code":
|
||||||
|
|
||||||
|
% cd /path/to/tmux-code
|
||||||
|
% git fetch obsd-tmux-code
|
||||||
|
|
||||||
|
Creating the necessary branches
|
||||||
|
===============================
|
||||||
|
|
||||||
|
Now that "tmux-code" can see commits and branches from "tmux-openbsd" by way
|
||||||
|
of the remote name "obsd-tmux", we can now create the master branch from
|
||||||
|
"tmux-openbsd" in the "tmux-code" repository:
|
||||||
|
|
||||||
|
% git checkout -b obsd-master obsd-tmux/master
|
||||||
|
|
||||||
|
Adding in the fake history points
|
||||||
|
=================================
|
||||||
|
|
||||||
|
To tie both the "master" branch from "tmux-code" and the "obsd-master"
|
||||||
|
branch from "tmux-openbsd" together, the fake history points added to the
|
||||||
|
"tmux-code" repository need to be added. To do this, we must add an
|
||||||
|
additional refspec line, as in:
|
||||||
|
|
||||||
|
% cd /path/to/tmux-code
|
||||||
|
% git config --add remote.origin.fetch '+refs/replace/*:refs/replace/*'
|
||||||
|
% git fetch origin
|
||||||
|
|
||||||
|
Performing the Sync
|
||||||
|
===================
|
||||||
|
|
||||||
|
Make sure the "master" branch is checked out:
|
||||||
|
|
||||||
|
% git checkout master
|
||||||
|
|
||||||
|
The following will show commits on OpenBSD not yet synched with "tmux-code":
|
||||||
|
|
||||||
|
% git log master..obsd-master
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
% make clean && ./autogen.sh && ./configure && make
|
||||||
|
|
||||||
|
Compare the git merge result with what's on origin/master -- that is, check
|
||||||
|
which commits you're about to push:
|
||||||
|
|
||||||
|
% git log origin/master..master
|
||||||
|
|
||||||
|
And if happy:
|
||||||
|
|
||||||
|
% git push origin master
|
||||||
|
|
||||||
|
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
|
||||||
|
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.
|
||||||
|
|
||||||
|
3. Tag with:
|
||||||
|
|
||||||
|
% git tag -a 1.X
|
||||||
|
|
||||||
|
Where "1.X" is the next version.
|
||||||
|
|
||||||
|
Push the tag out with:
|
||||||
|
|
||||||
|
% git push 1.X
|
||||||
|
|
||||||
|
4. Build the tarball with make dist. Now that it's using autoconf there
|
||||||
|
shouldn't be any weird files (such as the original and rejection files
|
||||||
|
from patch(1)) but it doesn't hurt taking a quick look at it.
|
||||||
|
|
||||||
|
5. Split the release changes into a new file. This should be named
|
||||||
|
tmux-$VERSION-readme to make sourceforge show it automagically in specific
|
||||||
|
parts of the project page.
|
||||||
|
|
||||||
|
6. Upload the tarball and the above file. Make the tarball the default
|
||||||
|
download by selecting all operating systems under the file details.
|
||||||
|
|
||||||
|
7. Run make update-index.html upload-index.html to replace %%VERSION%%.
|
||||||
|
|
||||||
|
8. Bump version in configure.ac and uncomment "found_debug=yes" to create
|
||||||
|
a debug build by default.
|
||||||
|
|
||||||
|
9. Update freshmeat.
|
||||||
|
|
||||||
|
[1] https://sourceforge.net/p/tmux/_list/git
|
||||||
261
TODO
261
TODO
@@ -1,130 +1,133 @@
|
|||||||
- better errors when creating new windows/sessions (how?)
|
- command bits and pieces:
|
||||||
- implicitly add exec to the commands for new windows (switch to disable it)?
|
* use "--" to mark start of command w/ neww etc to avoid quoting
|
||||||
- it would be nice to have multichar commands eg C-b K K
|
* why doesn't command-prompt work if made read-only?
|
||||||
- commands:
|
* allow multiple targets: fnmatch for -t/-c, for example detach all
|
||||||
extend list-clients to list clients attached to a session (-a for all?)
|
clients with -t*
|
||||||
bring back detach-session to detach all clients on a session?
|
* add -c for new-session like new-window
|
||||||
- allow fnmatch for -c, so that you can, eg, detach all clients
|
* attach should take a pane and select it as well as attaching
|
||||||
- garbage collect window history (100 lines at a time?) if it hasn't been used
|
* ' and " should be parsed the same (eg "\e" vs '\e') in config
|
||||||
in $x time
|
and command prompt
|
||||||
- lift SHRT_MAX limits for history?
|
* last-pane across sessions
|
||||||
- flags to centre screen in window
|
* exact match operator for targets (or break the substring match
|
||||||
- activity/bell should be per-window not per-link? what if it is cur win in
|
and require eg x* instead of just x)
|
||||||
session not being watched?
|
|
||||||
- next prev word etc in command prompt
|
- make command sequences more usable
|
||||||
- use a better termcap internally instead of screen, perhaps xterm
|
* don't require space after ;
|
||||||
- should be able to move to a hidden pane and it would be moved into view. pane
|
* options for error handling: && and ||?
|
||||||
number in status line/top-right would be cool for this
|
|
||||||
- support other mouse modes (highlight etc) and use it in copy mode
|
- options bits and pieces:
|
||||||
- set-remain-on-exit is a bit of a hack, some way to do it generically?
|
* set-remain-on-exit is a complete hack
|
||||||
- clear window title on exit
|
* way to set socket path from config file
|
||||||
- would be nice to be able to use "--" to mark start of command w/ neww etc
|
|
||||||
to avoid quoting
|
- format improvements:
|
||||||
- make command sequences more usable: don't require space after ;, handle
|
* option to quote format (#{session_name:quoted})
|
||||||
errors better
|
* formats need conditions for >0 (for #P)
|
||||||
- attach should have a flag to create session if it doesn't exist
|
* some way to pad # stuff with spaces, #!2T maybe
|
||||||
- choice and more mode would be better per client than per window?
|
* status stuff is redundant with formats
|
||||||
- hooks to which commands may be attached, for example: tmux add-hook
|
* last window update time and format for it
|
||||||
"new-session" if-shell "[ -e $HOME/.tmux-session.conf ]" source-file
|
* formats to show if a window is linked into multiple sessions, into
|
||||||
$HOME/.tmux-session.conf
|
multiple attached sessions, and is the active window in multiple
|
||||||
- get it passing all the vttest tests that don't require resizing the terminal
|
attached sessions?
|
||||||
- way to set socket path from config file
|
|
||||||
- what about utmp etc? can tmux update it like screen? setgid?
|
- choose mode improvements:
|
||||||
- warts on current naming:
|
* choose-pane command (augment choose-tree to do this?)
|
||||||
- display-time but message-fg/bg/attr
|
* choose-mode and copy-mode are very similar, make choose-mode a subset?
|
||||||
- list-* vs show-*
|
* flag to choose-* for sort order
|
||||||
- server-info
|
* choose mode would be better per client than per window
|
||||||
- up-pane/down-pane/swap-pane -U/swap-pane -D vs next-*/previous-*
|
* two choices (first one then second, for swap-pane and join-pane)
|
||||||
- split-window -> split-pane??
|
|
||||||
- a way for force-width/height to apply to only one pane (how?)
|
- improve monitor-*:
|
||||||
- command to list what is actually running in each window with command line,
|
* straighten out rules for multiple clients
|
||||||
pid (need some adaption of the osdep code)
|
* think about what happens across sessions
|
||||||
- support for bce
|
* monitor changes within a region
|
||||||
- some way to force a screen to use the entire terminal even if it is forced
|
* perhaps monitor /all/ panes in the window not just one
|
||||||
to be smaller by other clients. pan smaller terminal? (like screen F)
|
|
||||||
-- idea of a "view" onto a window, need base x/y offsets for redraw
|
- improve mouse support:
|
||||||
- handle resize better in copy mode
|
* bind commands to mouse in different areas?
|
||||||
- way to copy stuff that is off screen due to resize
|
* more fine-grained options
|
||||||
- commands should be able to succeed or fail and have || or && for command
|
* commands executed when clicking on a pattern (URL)
|
||||||
lists
|
* send arrow key sequences for mouse scroll wheel in alternate screen
|
||||||
- some way to KEEP a command running continually and just use its LAST line of
|
* mouse-select-pane will screw up with !MODE_MOUSE_STANDARD (it sets
|
||||||
output
|
the flag on w/o checking the others before calling tty_update_mode)
|
||||||
- bind commands to mouse buttons
|
|
||||||
- UTF-8 to a non-UTF-8 terminal should not be able to balls up
|
- hooks!
|
||||||
the terminal - www/ruby-addressable; make regress
|
|
||||||
- multiple keys could be done with tables, ie have prefixes go and instead
|
- warts on current naming:
|
||||||
bind -n ^A prefix-table "default"
|
* display-time but message-fg/bg/attr
|
||||||
where prefix-table sets command lookup table and sets prefix flag, then next
|
* list-* vs show-*
|
||||||
key is looked up in that table
|
* split-window -> split-pane??
|
||||||
- support esc-esc to quit in modes
|
|
||||||
- fix ctrl+F1-F4 output. to what?
|
- better UTF-8 support:
|
||||||
- look into xterm clearing its selection when scrolling etc
|
* #22T can split in the middle of UTF-8 characters!
|
||||||
- better utf8 support: window names, prompt input, message display
|
* window names and titles
|
||||||
- session history for client and last-session command
|
* message display
|
||||||
- option to change status line colour when current window is in a mode?
|
* prompt input
|
||||||
- option to move copy mode indicator into status line
|
* multibyte key input
|
||||||
- list-buffer/show-buffer should display UTF-8
|
* buffer_sample and the choose-* could show UTF-8 properly
|
||||||
- selection behaviour closer to vi in vi mode
|
|
||||||
- live update: server started with -U connects to server, requests sessions and
|
- copy/paste improvements:
|
||||||
windows, receives fds
|
* incremental searching
|
||||||
- command to show a tree of sessions-windows-panes (active marked with *)
|
* append to buffer
|
||||||
- sort out inheriting config from shell on new sessions/windows:
|
* paste w/o trailing whitespace
|
||||||
should pick up default-path/termios/etc from client if possible,
|
* named buffers and allow gaps in the stack
|
||||||
else leave empty/default
|
* command to toggle selection not to move it in copy-mode
|
||||||
- link panes into multiple windows
|
|
||||||
- -h option to capture-pane to capture the history as well
|
- layout stuff
|
||||||
- bells should be passed between sessions with visual-bell etc
|
* way to tag a layout as a number/name
|
||||||
- use screen-256color when started on 256 colour terminal??
|
* maybe keep last layout + size around and if size reverts just put it
|
||||||
- if-shell/run-shell should block further command execution in the same command
|
back
|
||||||
sequence until its shell exits, to allow them to be used from the config file
|
* revamp layouts: they are too complicated, should be more closely
|
||||||
- better session sharing: create-socket command to create socket somewhere (-r
|
integrated, should support hints, layout sets should just be a
|
||||||
flag for readonly)
|
special case of custom layouts, and we should support panes that are
|
||||||
- allow buffer to be specified when copying in copy mode
|
not attached to a cell at all. this could be the time to introduce
|
||||||
- multiline status line (no?)
|
panelink to replace layout_cell
|
||||||
- flag for absolute pane size to resize-pane
|
* way to set hints/limits about pane size for resizing
|
||||||
- sanity check input to socket
|
* panning over window (window larger than visible)
|
||||||
- select-buffer command
|
|
||||||
- support title stack, both internally and externally
|
- terminfo bits
|
||||||
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=1149299+0+archive/2010/freebsd-questions/20100207.freebsd-questions
|
* use a better termcap internally instead of screen, perhaps xterm
|
||||||
- copy buffers should be global, limit can be server option, nuke copy-buffer
|
* use screen-256color when started on 256 colour terminal?
|
||||||
command
|
* need a tmux terminfo entry to document the extensions we are using in
|
||||||
- command to show status line information briefly when it is off
|
upstream terminfo
|
||||||
- some way to pad # stuff with spaces, #!2T maybe
|
* support title stack, both internally and externally (restore on
|
||||||
- FreeBSD console problems
|
detach) http://docs.freebsd.org/cgi/getmsg.cgi?fetch=1149299+0+archive/2010/freebsd-questions/20100207.freebsd-questions
|
||||||
- a binding to "scroll down and exit at bottom" copy mode
|
|
||||||
- some way to pass keystrokes in copy mode through to underlying window
|
- code cleanup
|
||||||
- last window update time and # replacement for it for display-message
|
* instead of separate window and session options, just one master
|
||||||
- find-window across sessions - other ways to make session handling easier?
|
options list with each option having a type (window or session), then
|
||||||
- ' and " should be parsed the same (eg "\e" vs '\e') in config and command
|
options on window, on session, and global. for window options we look
|
||||||
prompt?
|
window->session->global, and for session we look session->global
|
||||||
- command to toggle selection not to move it in copy-mode
|
* the way pane, window, session destroy is handled is too complicated
|
||||||
- why are alerts per-winlink? try per window?
|
and the distinction between session.c, window.c and server-fn.c
|
||||||
- audit of escape sequence support vs xterm
|
functions is not clear. could we just have kill_pane(),
|
||||||
- support binding keys to mouse (mouse-select-pane -> mouse-keys or something,
|
kill_window(), unlink_window(), kill_session() that fix up all data
|
||||||
mouse click == select-pane -t %%, mouse scroll up == copy-mode)
|
structures (flagging sessions as dead) and return a value to say
|
||||||
- something for -t "last window in session" so a session can be used as a stack
|
whether clients need to be checked for dead sessions? sort of like
|
||||||
- synchronous commands - client sends cmd and blocks, neww/splitw saves client
|
session_detach now but more so. or some other scheme to make it
|
||||||
ptr then when program inside died, sends MSG_SOMETHING with wait status to
|
simpler and clearer? also would be nice to remove/rename server-fn.c
|
||||||
client
|
* more readable way to work out the various things commands need to
|
||||||
- documentation improvements - rlpowell's tutorial - build instructions
|
know about the client, notably:
|
||||||
- better configure? with-libevent
|
- is this the config file? (cmdq->c == NULL)
|
||||||
- bind commands to key sequences?
|
- is this a command client? (cmdq->c != NULL &&
|
||||||
- monitor, bell etc should monitor /all/ panes in the window not just one
|
cmdq->c->session == NULL)
|
||||||
- a history of commands that can be reversed (reverse member of each command,
|
- is this a control client?
|
||||||
and a buffer) info() when changing to same window
|
- can i do stdin or stdout to this client?
|
||||||
- don't pass UTF-8 through vis for titles
|
or even guarantee that cmdq->c != NULL and provide a better way to
|
||||||
- clearing screen should push lines into history
|
tell when in the config file - then we use cmdq->c if we need a
|
||||||
- add a unique ever-increasing pane id to each pane, export it in $TMUX_PANE
|
client w/o a session else cmd_current_client
|
||||||
(as %1, %2 etc) and allow it to be used as a target
|
* optimize pane redraws, 20120318184853.GK10965@yelena.nicm.ath.cx
|
||||||
- way to add dest for break-pane; maybe some easier way to unbreak-pane
|
|
||||||
- case insensitive searching
|
- miscellaneous
|
||||||
- dynamically generated jobs (eg "date ...") do not work well because
|
* way to keep a job running just read its last line of output for #()
|
||||||
their entries are never collected, should either store status jobs in
|
* link panes into multiple windows
|
||||||
a different tree or flush all unused persist jobs every update rather
|
* live update: server started with -U connects to server, requests
|
||||||
than just updating them
|
sessions and windows, receives file descriptors
|
||||||
- pane-index option like base-index
|
* there are inconsistencies in what we get from old shell and what
|
||||||
- option to move status line to top
|
comes from config for new sessions and windows
|
||||||
- support "xterm2" mouse mode
|
* multiline status line?
|
||||||
- respawn-pane command
|
* bind commands to key sequences -- make it so ALL keys go through a
|
||||||
- configurable borders and empty space filler for when panes < window?
|
table, first an implicit table in which C-b is the only default
|
||||||
|
binding to a command that says "next key from $othertable" and so
|
||||||
|
on. means -n can go away as well
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
251
arguments.c
Normal file
251
arguments.c
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Manipulate command arguments.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct args_entry *args_find(struct args *, u_char);
|
||||||
|
|
||||||
|
RB_GENERATE(args_tree, args_entry, entry, args_cmp);
|
||||||
|
|
||||||
|
/* Arguments tree comparison function. */
|
||||||
|
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 *
|
||||||
|
args_find(struct args *args, u_char ch)
|
||||||
|
{
|
||||||
|
struct args_entry entry;
|
||||||
|
|
||||||
|
entry.flag = ch;
|
||||||
|
return (RB_FIND(args_tree, &args->tree, &entry));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse an argv and argc into a new argument set. */
|
||||||
|
struct args *
|
||||||
|
args_parse(const char *template, int argc, char **argv)
|
||||||
|
{
|
||||||
|
struct args *args;
|
||||||
|
int opt;
|
||||||
|
|
||||||
|
args = xcalloc(1, sizeof *args);
|
||||||
|
|
||||||
|
optreset = 1;
|
||||||
|
optind = 1;
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, template)) != -1) {
|
||||||
|
if (opt < 0)
|
||||||
|
continue;
|
||||||
|
if (opt == '?' || strchr(template, opt) == NULL) {
|
||||||
|
args_free(args);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
args_set(args, opt, optarg);
|
||||||
|
}
|
||||||
|
argc -= optind;
|
||||||
|
argv += optind;
|
||||||
|
|
||||||
|
args->argc = argc;
|
||||||
|
args->argv = cmd_copy_argv(argc, argv);
|
||||||
|
|
||||||
|
return (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free an arguments set. */
|
||||||
|
void
|
||||||
|
args_free(struct args *args)
|
||||||
|
{
|
||||||
|
struct args_entry *entry;
|
||||||
|
struct args_entry *entry1;
|
||||||
|
|
||||||
|
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);
|
||||||
|
free(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print a set of arguments. */
|
||||||
|
size_t
|
||||||
|
args_print(struct args *args, char *buf, size_t len)
|
||||||
|
{
|
||||||
|
size_t off;
|
||||||
|
int i;
|
||||||
|
const char *quotes;
|
||||||
|
struct args_entry *entry;
|
||||||
|
|
||||||
|
/* There must be at least one byte at the start. */
|
||||||
|
if (len == 0)
|
||||||
|
return (0);
|
||||||
|
off = 0;
|
||||||
|
|
||||||
|
/* Process the flags first. */
|
||||||
|
buf[off++] = '-';
|
||||||
|
RB_FOREACH(entry, args_tree, &args->tree) {
|
||||||
|
if (entry->value != NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (off == len - 1) {
|
||||||
|
buf[off] = '\0';
|
||||||
|
return (len);
|
||||||
|
}
|
||||||
|
buf[off++] = entry->flag;
|
||||||
|
buf[off] = '\0';
|
||||||
|
}
|
||||||
|
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 = "";
|
||||||
|
off += xsnprintf(buf + off, len - off, "%s-%c %s%s%s",
|
||||||
|
off != 0 ? " " : "", entry->flag, quotes, entry->value,
|
||||||
|
quotes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* And finally the argument vector. */
|
||||||
|
for (i = 0; i < args->argc; i++) {
|
||||||
|
if (off >= len) {
|
||||||
|
/* snprintf will have zero terminated. */
|
||||||
|
return (len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strchr(args->argv[i], ' ') != NULL)
|
||||||
|
quotes = "\"";
|
||||||
|
else
|
||||||
|
quotes = "";
|
||||||
|
off += xsnprintf(buf + off, len - off, "%s%s%s%s",
|
||||||
|
off != 0 ? " " : "", quotes, args->argv[i], quotes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (off);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return if an argument is present. */
|
||||||
|
int
|
||||||
|
args_has(struct args *args, u_char ch)
|
||||||
|
{
|
||||||
|
return (args_find(args, ch) == NULL ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set argument value in the arguments tree. */
|
||||||
|
void
|
||||||
|
args_set(struct args *args, u_char ch, const char *value)
|
||||||
|
{
|
||||||
|
struct args_entry *entry;
|
||||||
|
|
||||||
|
/* Replace existing argument. */
|
||||||
|
if ((entry = args_find(args, ch)) != NULL) {
|
||||||
|
free(entry->value);
|
||||||
|
entry->value = NULL;
|
||||||
|
} else {
|
||||||
|
entry = xcalloc(1, sizeof *entry);
|
||||||
|
entry->flag = ch;
|
||||||
|
RB_INSERT(args_tree, &args->tree, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value != NULL)
|
||||||
|
entry->value = xstrdup(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get argument value. Will be NULL if it isn't present. */
|
||||||
|
const char *
|
||||||
|
args_get(struct args *args, u_char ch)
|
||||||
|
{
|
||||||
|
struct args_entry *entry;
|
||||||
|
|
||||||
|
if ((entry = args_find(args, ch)) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
return (entry->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert an argument value to a number. */
|
||||||
|
long long
|
||||||
|
args_strtonum(struct args *args, u_char ch, long long minval, long long maxval,
|
||||||
|
char **cause)
|
||||||
|
{
|
||||||
|
const char *errstr;
|
||||||
|
long long ll;
|
||||||
|
struct args_entry *entry;
|
||||||
|
|
||||||
|
if ((entry = args_find(args, ch)) == NULL) {
|
||||||
|
*cause = xstrdup("missing");
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ll = strtonum(entry->value, minval, maxval, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
*cause = xstrdup(errstr);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
*cause = NULL;
|
||||||
|
return (ll);
|
||||||
|
}
|
||||||
7
array.h
7
array.h
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: array.h,v 1.11 2010-06-06 00:27:08 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -109,13 +109,12 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ARRAY_FREE(a) do { \
|
#define ARRAY_FREE(a) do { \
|
||||||
if ((a)->list != NULL) \
|
free((a)->list); \
|
||||||
xfree((a)->list); \
|
|
||||||
ARRAY_INIT(a); \
|
ARRAY_INIT(a); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define ARRAY_FREEALL(a) do { \
|
#define ARRAY_FREEALL(a) do { \
|
||||||
ARRAY_FREE(a); \
|
ARRAY_FREE(a); \
|
||||||
xfree(a); \
|
free(a); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
30
attributes.c
30
attributes.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: attributes.c,v 1.4 2010-06-05 23:54:51 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
|
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
|
||||||
@@ -26,27 +26,21 @@ const char *
|
|||||||
attributes_tostring(u_char attr)
|
attributes_tostring(u_char attr)
|
||||||
{
|
{
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (attr == 0)
|
if (attr == 0)
|
||||||
return ("none");
|
return ("none");
|
||||||
|
|
||||||
buf[0] = '\0';
|
len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s",
|
||||||
if (attr & GRID_ATTR_BRIGHT)
|
attr & GRID_ATTR_BRIGHT ? "bright," : "",
|
||||||
strlcat(buf, "bright,", sizeof (buf));
|
attr & GRID_ATTR_DIM ? "dim," : "",
|
||||||
if (attr & GRID_ATTR_DIM)
|
attr & GRID_ATTR_UNDERSCORE ? "underscore," : "",
|
||||||
strlcat(buf, "dim,", sizeof (buf));
|
attr & GRID_ATTR_BLINK ? "blink," : "",
|
||||||
if (attr & GRID_ATTR_UNDERSCORE)
|
attr & GRID_ATTR_REVERSE ? "reverse," : "",
|
||||||
strlcat(buf, "underscore,", sizeof (buf));
|
attr & GRID_ATTR_HIDDEN ? "hidden," : "",
|
||||||
if (attr & GRID_ATTR_BLINK)
|
attr & GRID_ATTR_ITALICS ? "italics," : "");
|
||||||
strlcat(buf, "blink,", sizeof (buf));
|
if (len > 0)
|
||||||
if (attr & GRID_ATTR_REVERSE)
|
buf[len - 1] = '\0';
|
||||||
strlcat(buf, "reverse,", sizeof (buf));
|
|
||||||
if (attr & GRID_ATTR_HIDDEN)
|
|
||||||
strlcat(buf, "hidden,", sizeof (buf));
|
|
||||||
if (attr & GRID_ATTR_ITALICS)
|
|
||||||
strlcat(buf, "italics,", sizeof (buf));
|
|
||||||
if (*buf != '\0')
|
|
||||||
*(strrchr(buf, ',')) = '\0';
|
|
||||||
|
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|||||||
18
autogen.sh
Executable file
18
autogen.sh
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
if [ "x$(uname)" = "xOpenBSD" ]; then
|
||||||
|
[ -z "$AUTOMAKE_VERSION" ] && export AUTOMAKE_VERSION=1.10
|
||||||
|
[ -z "$AUTOCONF_VERSION" ] && export AUTOCONF_VERSION=2.65
|
||||||
|
fi
|
||||||
|
|
||||||
|
die()
|
||||||
|
{
|
||||||
|
echo "$@" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir -p etc
|
||||||
|
aclocal || die "aclocal failed"
|
||||||
|
automake --add-missing --force-missing --copy --foreign || die "automake failed"
|
||||||
|
autoreconf || die "autoreconf failed"
|
||||||
203
cfg.c
203
cfg.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cfg.c,v 1.27 2010-06-06 00:04:18 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -19,125 +19,148 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
struct cmd_q *cfg_cmd_q;
|
||||||
* Config file parser. Pretty quick and simple, each line is parsed into a
|
int cfg_finished;
|
||||||
* argv array and executed as a command.
|
int cfg_references;
|
||||||
*/
|
struct causelist cfg_causes;
|
||||||
|
struct client *cfg_client;
|
||||||
|
|
||||||
void printflike2 cfg_print(struct cmd_ctx *, const char *, ...);
|
|
||||||
void printflike2 cfg_error(struct cmd_ctx *, const char *, ...);
|
|
||||||
|
|
||||||
char *cfg_cause;
|
|
||||||
int cfg_finished;
|
|
||||||
struct causelist cfg_causes = ARRAY_INITIALIZER;
|
|
||||||
|
|
||||||
/* ARGSUSED */
|
|
||||||
void printflike2
|
|
||||||
cfg_print(unused struct cmd_ctx *ctx, unused const char *fmt, ...)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ARGSUSED */
|
|
||||||
void printflike2
|
|
||||||
cfg_error(unused struct cmd_ctx *ctx, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
xvasprintf(&cfg_cause, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void printflike2
|
|
||||||
cfg_add_cause(struct causelist *causes, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
char *cause;
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
xvasprintf(&cause, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
ARRAY_ADD(causes, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Load configuration file. Returns -1 for an error with a list of messages in
|
|
||||||
* causes. Note that causes must be initialised by the caller!
|
|
||||||
*/
|
|
||||||
int
|
int
|
||||||
load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
|
load_cfg(const char *path, struct cmd_q *cmdq, char **cause)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
u_int n;
|
u_int n, found;
|
||||||
char *buf, *line, *cause;
|
char *buf, *copy, *line, *cause1, *msg;
|
||||||
size_t len;
|
size_t len, oldlen;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd_ctx ctx;
|
|
||||||
|
|
||||||
|
log_debug("loading %s", path);
|
||||||
if ((f = fopen(path, "rb")) == NULL) {
|
if ((f = fopen(path, "rb")) == NULL) {
|
||||||
cfg_add_cause(causes, "%s: %s", path, strerror(errno));
|
xasprintf(cause, "%s: %s", path, strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
n = 0;
|
|
||||||
|
|
||||||
|
n = found = 0;
|
||||||
line = NULL;
|
line = NULL;
|
||||||
while ((buf = fgetln(f, &len))) {
|
while ((buf = fgetln(f, &len))) {
|
||||||
|
/* Trim \n. */
|
||||||
if (buf[len - 1] == '\n')
|
if (buf[len - 1] == '\n')
|
||||||
buf[len - 1] = '\0';
|
len--;
|
||||||
else {
|
log_debug("%s: %.*s", path, (int)len, buf);
|
||||||
line = xrealloc(line, 1, len + 1);
|
|
||||||
memcpy(line, buf, len);
|
/* Current line is the continuation of the previous one. */
|
||||||
line[len] = '\0';
|
if (line != NULL) {
|
||||||
buf = line;
|
oldlen = strlen(line);
|
||||||
|
line = xrealloc(line, 1, oldlen + len + 1);
|
||||||
|
} else {
|
||||||
|
oldlen = 0;
|
||||||
|
line = xmalloc(len + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Append current line to the previous. */
|
||||||
|
memcpy(line + oldlen, buf, len);
|
||||||
|
line[oldlen + len] = '\0';
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
if (cmd_string_parse(buf, &cmdlist, &cause) != 0) {
|
/* Continuation: get next line? */
|
||||||
if (cause == NULL)
|
len = strlen(line);
|
||||||
|
if (len > 0 && line[len - 1] == '\\') {
|
||||||
|
line[len - 1] = '\0';
|
||||||
|
|
||||||
|
/* Ignore escaped backslash at EOL. */
|
||||||
|
if (len > 1 && line[len - 2] != '\\')
|
||||||
continue;
|
continue;
|
||||||
cfg_add_cause(causes, "%s: %u: %s", path, n, cause);
|
}
|
||||||
xfree(cause);
|
copy = line;
|
||||||
|
line = NULL;
|
||||||
|
|
||||||
|
/* Skip empty lines. */
|
||||||
|
buf = copy;
|
||||||
|
while (isspace((u_char)*buf))
|
||||||
|
buf++;
|
||||||
|
if (*buf == '\0') {
|
||||||
|
free(copy);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Parse and run the command. */
|
||||||
|
if (cmd_string_parse(buf, &cmdlist, path, n, &cause1) != 0) {
|
||||||
|
free(copy);
|
||||||
|
if (cause1 == NULL)
|
||||||
|
continue;
|
||||||
|
xasprintf(&msg, "%s:%u: %s", path, n, cause1);
|
||||||
|
ARRAY_ADD(&cfg_causes, msg);
|
||||||
|
free(cause1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
free(copy);
|
||||||
|
|
||||||
if (cmdlist == NULL)
|
if (cmdlist == NULL)
|
||||||
continue;
|
continue;
|
||||||
cfg_cause = NULL;
|
cmdq_append(cmdq, cmdlist);
|
||||||
|
|
||||||
if (ctxin == NULL) {
|
|
||||||
ctx.msgdata = NULL;
|
|
||||||
ctx.curclient = NULL;
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
} else {
|
|
||||||
ctx.msgdata = ctxin->msgdata;
|
|
||||||
ctx.curclient = ctxin->curclient;
|
|
||||||
ctx.cmdclient = ctxin->cmdclient;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.error = cfg_error;
|
|
||||||
ctx.print = cfg_print;
|
|
||||||
ctx.info = cfg_print;
|
|
||||||
|
|
||||||
cfg_cause = NULL;
|
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
if (cfg_cause != NULL) {
|
found++;
|
||||||
cfg_add_cause(causes, "%s: %d: %s", path, n, cfg_cause);
|
|
||||||
xfree(cfg_cause);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (line != NULL)
|
if (line != NULL)
|
||||||
xfree(line);
|
free(line);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if (ARRAY_LENGTH(causes) != 0)
|
return (found);
|
||||||
return (-1);
|
}
|
||||||
return (0);
|
|
||||||
|
void
|
||||||
|
cfg_default_done(unused struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
if (--cfg_references != 0)
|
||||||
|
return;
|
||||||
|
cfg_finished = 1;
|
||||||
|
|
||||||
|
if (!RB_EMPTY(&sessions))
|
||||||
|
cfg_show_causes(RB_MIN(sessions, &sessions));
|
||||||
|
|
||||||
|
cmdq_free(cfg_cmd_q);
|
||||||
|
cfg_cmd_q = NULL;
|
||||||
|
|
||||||
|
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);
|
||||||
|
cfg_client->references--;
|
||||||
|
cfg_client = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cfg_show_causes(struct session *s)
|
||||||
|
{
|
||||||
|
struct window_pane *wp;
|
||||||
|
char *cause;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
if (s == NULL || ARRAY_EMPTY(&cfg_causes))
|
||||||
|
return;
|
||||||
|
wp = s->curw->window->active;
|
||||||
|
|
||||||
|
window_pane_set_mode(wp, &window_copy_mode);
|
||||||
|
window_copy_init_for_output(wp);
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
|
||||||
|
cause = ARRAY_ITEM(&cfg_causes, i);
|
||||||
|
window_copy_add(wp, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
}
|
||||||
|
ARRAY_FREE(&cfg_causes);
|
||||||
}
|
}
|
||||||
|
|||||||
454
client.c
454
client.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: client.c,v 1.100 2010-10-24 19:54:41 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/file.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
@@ -34,19 +35,59 @@
|
|||||||
|
|
||||||
struct imsgbuf client_ibuf;
|
struct imsgbuf client_ibuf;
|
||||||
struct event client_event;
|
struct event client_event;
|
||||||
const char *client_exitmsg;
|
struct event client_stdin;
|
||||||
|
enum {
|
||||||
|
CLIENT_EXIT_NONE,
|
||||||
|
CLIENT_EXIT_DETACHED,
|
||||||
|
CLIENT_EXIT_DETACHED_HUP,
|
||||||
|
CLIENT_EXIT_LOST_TTY,
|
||||||
|
CLIENT_EXIT_TERMINATED,
|
||||||
|
CLIENT_EXIT_LOST_SERVER,
|
||||||
|
CLIENT_EXIT_EXITED,
|
||||||
|
CLIENT_EXIT_SERVER_EXITED,
|
||||||
|
} client_exitreason = CLIENT_EXIT_NONE;
|
||||||
int client_exitval;
|
int client_exitval;
|
||||||
|
enum msgtype client_exittype;
|
||||||
|
const char *client_exitsession;
|
||||||
int client_attached;
|
int client_attached;
|
||||||
|
|
||||||
|
int client_get_lock(char *);
|
||||||
int client_connect(char *, int);
|
int client_connect(char *, int);
|
||||||
void client_send_identify(int);
|
void client_send_identify(int);
|
||||||
void client_send_environ(void);
|
int client_write_one(enum msgtype, int, const void *, size_t);
|
||||||
void client_write_server(enum msgtype, void *, size_t);
|
int client_write_server(enum msgtype, const void *, size_t);
|
||||||
void client_update_event(void);
|
void client_update_event(void);
|
||||||
void client_signal(int, short, void *);
|
void client_signal(int, short, void *);
|
||||||
|
void client_stdin_callback(int, short, void *);
|
||||||
|
void client_write(int, const char *, size_t);
|
||||||
void client_callback(int, short, void *);
|
void client_callback(int, short, void *);
|
||||||
int client_dispatch_attached(void);
|
int client_dispatch_attached(void);
|
||||||
int client_dispatch_wait(void *);
|
int client_dispatch_wait(void *);
|
||||||
|
const char *client_exit_message(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get server create lock. If already held then server start is happening in
|
||||||
|
* another client, so block until the lock is released and return -1 to
|
||||||
|
* retry. Ignore other errors - just continue and start the server without the
|
||||||
|
* lock.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
client_get_lock(char *lockfile)
|
||||||
|
{
|
||||||
|
int lockfd;
|
||||||
|
|
||||||
|
if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1)
|
||||||
|
fatal("open failed");
|
||||||
|
|
||||||
|
if (lockf(lockfd, F_TLOCK, 0) == -1 && errno == EAGAIN) {
|
||||||
|
while (lockf(lockfd, F_LOCK, 0) == -1 && errno == EINTR)
|
||||||
|
/* nothing */;
|
||||||
|
close(lockfd);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (lockfd);
|
||||||
|
}
|
||||||
|
|
||||||
/* Connect client to server. */
|
/* Connect client to server. */
|
||||||
int
|
int
|
||||||
@@ -54,7 +95,8 @@ client_connect(char *path, int start_server)
|
|||||||
{
|
{
|
||||||
struct sockaddr_un sa;
|
struct sockaddr_un sa;
|
||||||
size_t size;
|
size_t size;
|
||||||
int fd, mode;
|
int fd, lockfd;
|
||||||
|
char *lockfile;
|
||||||
|
|
||||||
memset(&sa, 0, sizeof sa);
|
memset(&sa, 0, sizeof sa);
|
||||||
sa.sun_family = AF_UNIX;
|
sa.sun_family = AF_UNIX;
|
||||||
@@ -64,30 +106,33 @@ client_connect(char *path, int start_server)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retry:
|
||||||
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
||||||
fatal("socket failed");
|
fatal("socket failed");
|
||||||
|
|
||||||
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
||||||
|
if (errno != ECONNREFUSED && errno != ENOENT)
|
||||||
|
goto failed;
|
||||||
if (!start_server)
|
if (!start_server)
|
||||||
goto failed;
|
goto failed;
|
||||||
switch (errno) {
|
close(fd);
|
||||||
case ECONNREFUSED:
|
|
||||||
if (unlink(path) != 0)
|
xasprintf(&lockfile, "%s.lock", path);
|
||||||
goto failed;
|
if ((lockfd = client_get_lock(lockfile)) == -1) {
|
||||||
/* FALLTHROUGH */
|
free(lockfile);
|
||||||
case ENOENT:
|
goto retry;
|
||||||
if ((fd = server_start()) == -1)
|
|
||||||
goto failed;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto failed;
|
|
||||||
}
|
}
|
||||||
|
if (unlink(path) != 0 && errno != ENOENT) {
|
||||||
|
free(lockfile);
|
||||||
|
close(lockfd);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
fd = server_start(lockfd, lockfile);
|
||||||
|
free(lockfile);
|
||||||
|
close(lockfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mode = fcntl(fd, F_GETFL)) == -1)
|
setblocking(fd, 0);
|
||||||
fatal("fcntl failed");
|
|
||||||
if (fcntl(fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
|
||||||
fatal("fcntl failed");
|
|
||||||
return (fd);
|
return (fd);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
@@ -95,16 +140,56 @@ failed:
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get exit string from reason number. */
|
||||||
|
const char *
|
||||||
|
client_exit_message(void)
|
||||||
|
{
|
||||||
|
static char msg[256];
|
||||||
|
|
||||||
|
switch (client_exitreason) {
|
||||||
|
case CLIENT_EXIT_NONE:
|
||||||
|
break;
|
||||||
|
case CLIENT_EXIT_DETACHED:
|
||||||
|
if (client_exitsession != NULL) {
|
||||||
|
xsnprintf(msg, sizeof msg, "detached "
|
||||||
|
"(from session %s)", client_exitsession);
|
||||||
|
return (msg);
|
||||||
|
}
|
||||||
|
return ("detached");
|
||||||
|
case CLIENT_EXIT_DETACHED_HUP:
|
||||||
|
if (client_exitsession != NULL) {
|
||||||
|
xsnprintf(msg, sizeof msg, "detached and SIGHUP "
|
||||||
|
"(from session %s)", client_exitsession);
|
||||||
|
return (msg);
|
||||||
|
}
|
||||||
|
return ("detached and SIGHUP");
|
||||||
|
case CLIENT_EXIT_LOST_TTY:
|
||||||
|
return ("lost tty");
|
||||||
|
case CLIENT_EXIT_TERMINATED:
|
||||||
|
return ("terminated");
|
||||||
|
case CLIENT_EXIT_LOST_SERVER:
|
||||||
|
return ("lost server");
|
||||||
|
case CLIENT_EXIT_EXITED:
|
||||||
|
return ("exited");
|
||||||
|
case CLIENT_EXIT_SERVER_EXITED:
|
||||||
|
return ("server exited");
|
||||||
|
}
|
||||||
|
return ("unknown reason");
|
||||||
|
}
|
||||||
|
|
||||||
/* Client main loop. */
|
/* Client main loop. */
|
||||||
int
|
int
|
||||||
client_main(int argc, char **argv, int flags)
|
client_main(int argc, char **argv, int flags)
|
||||||
{
|
{
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct msg_command_data cmddata;
|
struct msg_command_data *data;
|
||||||
int cmdflags, fd;
|
int cmdflags, fd, i;
|
||||||
|
pid_t ppid;
|
||||||
enum msgtype msg;
|
enum msgtype msg;
|
||||||
char *cause;
|
char *cause;
|
||||||
|
struct termios tio, saved_tio;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
/* Set up the initial command. */
|
/* Set up the initial command. */
|
||||||
cmdflags = 0;
|
cmdflags = 0;
|
||||||
@@ -113,7 +198,7 @@ client_main(int argc, char **argv, int flags)
|
|||||||
cmdflags = CMD_STARTSERVER;
|
cmdflags = CMD_STARTSERVER;
|
||||||
} else if (argc == 0) {
|
} else if (argc == 0) {
|
||||||
msg = MSG_COMMAND;
|
msg = MSG_COMMAND;
|
||||||
cmdflags = CMD_STARTSERVER|CMD_SENDENVIRON|CMD_CANTNEST;
|
cmdflags = CMD_STARTSERVER|CMD_CANTNEST;
|
||||||
} else {
|
} else {
|
||||||
msg = MSG_COMMAND;
|
msg = MSG_COMMAND;
|
||||||
|
|
||||||
@@ -122,16 +207,15 @@ client_main(int argc, char **argv, int flags)
|
|||||||
* later in server) but it is necessary to get the start server
|
* later in server) but it is necessary to get the start server
|
||||||
* flag.
|
* flag.
|
||||||
*/
|
*/
|
||||||
if ((cmdlist = cmd_list_parse(argc, argv, &cause)) == NULL) {
|
cmdlist = cmd_list_parse(argc, argv, NULL, 0, &cause);
|
||||||
log_warnx("%s", cause);
|
if (cmdlist == NULL) {
|
||||||
|
fprintf(stderr, "%s\n", cause);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
cmdflags &= ~CMD_STARTSERVER;
|
cmdflags &= ~CMD_STARTSERVER;
|
||||||
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||||
if (cmd->entry->flags & CMD_STARTSERVER)
|
if (cmd->entry->flags & CMD_STARTSERVER)
|
||||||
cmdflags |= CMD_STARTSERVER;
|
cmdflags |= CMD_STARTSERVER;
|
||||||
if (cmd->entry->flags & CMD_SENDENVIRON)
|
|
||||||
cmdflags |= CMD_SENDENVIRON;
|
|
||||||
if (cmd->entry->flags & CMD_CANTNEST)
|
if (cmd->entry->flags & CMD_CANTNEST)
|
||||||
cmdflags |= CMD_CANTNEST;
|
cmdflags |= CMD_CANTNEST;
|
||||||
}
|
}
|
||||||
@@ -143,16 +227,18 @@ client_main(int argc, char **argv, int flags)
|
|||||||
* if the socket path matches $TMUX, this is probably the same server.
|
* if the socket path matches $TMUX, this is probably the same server.
|
||||||
*/
|
*/
|
||||||
if (shell_cmd == NULL && environ_path != NULL &&
|
if (shell_cmd == NULL && environ_path != NULL &&
|
||||||
cmdflags & CMD_CANTNEST && strcmp(socket_path, environ_path) == 0) {
|
(cmdflags & CMD_CANTNEST) &&
|
||||||
log_warnx("sessions should be nested with care. "
|
strcmp(socket_path, environ_path) == 0) {
|
||||||
"unset $TMUX to force.");
|
fprintf(stderr, "sessions should be nested with care, "
|
||||||
|
"unset $TMUX to force\n");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise the client socket and start the server. */
|
/* Initialise the client socket and start the server. */
|
||||||
fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
|
fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
log_warn("failed to connect to server");
|
fprintf(stderr, "failed to connect to server: %s\n",
|
||||||
|
strerror(errno));
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,29 +252,60 @@ client_main(int argc, char **argv, int flags)
|
|||||||
imsg_init(&client_ibuf, fd);
|
imsg_init(&client_ibuf, fd);
|
||||||
event_set(&client_event, fd, EV_READ, client_callback, shell_cmd);
|
event_set(&client_event, fd, EV_READ, client_callback, shell_cmd);
|
||||||
|
|
||||||
|
/* Create stdin handler. */
|
||||||
|
setblocking(STDIN_FILENO, 0);
|
||||||
|
event_set(&client_stdin, STDIN_FILENO, EV_READ|EV_PERSIST,
|
||||||
|
client_stdin_callback, NULL);
|
||||||
|
if (flags & CLIENT_CONTROLCONTROL) {
|
||||||
|
if (tcgetattr(STDIN_FILENO, &saved_tio) != 0) {
|
||||||
|
fprintf(stderr, "tcgetattr failed: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
cfmakeraw(&tio);
|
||||||
|
tio.c_iflag = ICRNL|IXANY;
|
||||||
|
tio.c_oflag = OPOST|ONLCR;
|
||||||
|
#ifdef NOKERNINFO
|
||||||
|
tio.c_lflag = NOKERNINFO;
|
||||||
|
#endif
|
||||||
|
tio.c_cflag = CREAD|CS8|HUPCL;
|
||||||
|
tio.c_cc[VMIN] = 1;
|
||||||
|
tio.c_cc[VTIME] = 0;
|
||||||
|
cfsetispeed(&tio, cfgetispeed(&saved_tio));
|
||||||
|
cfsetospeed(&tio, cfgetospeed(&saved_tio));
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &tio);
|
||||||
|
}
|
||||||
|
|
||||||
/* Establish signal handlers. */
|
/* Establish signal handlers. */
|
||||||
set_signals(client_signal);
|
set_signals(client_signal);
|
||||||
|
|
||||||
/* Send initial environment. */
|
/* Send identify messages. */
|
||||||
if (cmdflags & CMD_SENDENVIRON)
|
|
||||||
client_send_environ();
|
|
||||||
client_send_identify(flags);
|
client_send_identify(flags);
|
||||||
|
|
||||||
/* Send first command. */
|
/* Send first command. */
|
||||||
if (msg == MSG_COMMAND) {
|
if (msg == MSG_COMMAND) {
|
||||||
/* Fill in command line arguments. */
|
/* How big is the command? */
|
||||||
cmddata.pid = environ_pid;
|
size = 0;
|
||||||
cmddata.idx = environ_idx;
|
for (i = 0; i < argc; i++)
|
||||||
|
size += strlen(argv[i]) + 1;
|
||||||
|
data = xmalloc((sizeof *data) + size);
|
||||||
|
|
||||||
/* Prepare command for server. */
|
/* Prepare command for server. */
|
||||||
cmddata.argc = argc;
|
data->argc = argc;
|
||||||
if (cmd_pack_argv(
|
if (cmd_pack_argv(argc, argv, (char*)(data + 1), size) != 0) {
|
||||||
argc, argv, cmddata.argv, sizeof cmddata.argv) != 0) {
|
fprintf(stderr, "command too long\n");
|
||||||
log_warnx("command too long");
|
free(data);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
size += sizeof *data;
|
||||||
|
|
||||||
client_write_server(msg, &cmddata, sizeof cmddata);
|
/* Send the command. */
|
||||||
|
if (client_write_server(msg, data, size) != 0) {
|
||||||
|
fprintf(stderr, "failed to send command\n");
|
||||||
|
free(data);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
free(data);
|
||||||
} else if (msg == MSG_SHELL)
|
} else if (msg == MSG_SHELL)
|
||||||
client_write_server(msg, NULL, 0);
|
client_write_server(msg, NULL, 0);
|
||||||
|
|
||||||
@@ -197,64 +314,82 @@ client_main(int argc, char **argv, int flags)
|
|||||||
event_dispatch();
|
event_dispatch();
|
||||||
|
|
||||||
/* Print the exit message, if any, and exit. */
|
/* Print the exit message, if any, and exit. */
|
||||||
if (client_attached && client_exitmsg != NULL && !login_shell)
|
if (client_attached) {
|
||||||
printf("[%s]\n", client_exitmsg);
|
if (client_exitreason != CLIENT_EXIT_NONE && !login_shell)
|
||||||
|
printf("[%s]\n", client_exit_message());
|
||||||
|
|
||||||
|
ppid = getppid();
|
||||||
|
if (client_exittype == MSG_DETACHKILL && ppid > 1)
|
||||||
|
kill(ppid, SIGHUP);
|
||||||
|
} else if (flags & CLIENT_CONTROLCONTROL) {
|
||||||
|
if (client_exitreason != CLIENT_EXIT_NONE)
|
||||||
|
printf("%%exit %s\n", client_exit_message());
|
||||||
|
else
|
||||||
|
printf("%%exit\n");
|
||||||
|
printf("\033\\");
|
||||||
|
tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
|
||||||
|
}
|
||||||
|
setblocking(STDIN_FILENO, 1);
|
||||||
return (client_exitval);
|
return (client_exitval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send identify message to server with the file descriptors. */
|
/* Send identify messages to server. */
|
||||||
void
|
void
|
||||||
client_send_identify(int flags)
|
client_send_identify(int flags)
|
||||||
{
|
{
|
||||||
struct msg_identify_data data;
|
const char *s;
|
||||||
char *term;
|
char **ss;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
data.flags = flags;
|
client_write_one(MSG_IDENTIFY_FLAGS, -1, &flags, sizeof flags);
|
||||||
|
|
||||||
if (getcwd(data.cwd, sizeof data.cwd) == NULL)
|
if ((s = getenv("TERM")) == NULL)
|
||||||
*data.cwd = '\0';
|
s = "";
|
||||||
|
client_write_one(MSG_IDENTIFY_TERM, -1, s, strlen(s) + 1);
|
||||||
|
|
||||||
term = getenv("TERM");
|
if ((s = ttyname(STDIN_FILENO)) == NULL)
|
||||||
if (term == NULL ||
|
s = "";
|
||||||
strlcpy(data.term, term, sizeof data.term) >= sizeof data.term)
|
client_write_one(MSG_IDENTIFY_TTYNAME, -1, s, strlen(s) + 1);
|
||||||
*data.term = '\0';
|
|
||||||
|
if ((fd = open(".", O_RDONLY)) == -1)
|
||||||
|
fd = open("/", O_RDONLY);
|
||||||
|
client_write_one(MSG_IDENTIFY_CWD, fd, NULL, 0);
|
||||||
|
|
||||||
if ((fd = dup(STDIN_FILENO)) == -1)
|
if ((fd = dup(STDIN_FILENO)) == -1)
|
||||||
fatal("dup failed");
|
fatal("dup failed");
|
||||||
imsg_compose(&client_ibuf,
|
client_write_one(MSG_IDENTIFY_STDIN, fd, NULL, 0);
|
||||||
MSG_IDENTIFY, PROTOCOL_VERSION, -1, fd, &data, sizeof data);
|
|
||||||
|
|
||||||
if ((fd = dup(STDOUT_FILENO)) == -1)
|
for (ss = environ; *ss != NULL; ss++)
|
||||||
fatal("dup failed");
|
client_write_one(MSG_IDENTIFY_ENVIRON, -1, *ss, strlen(*ss) + 1);
|
||||||
imsg_compose(&client_ibuf,
|
|
||||||
MSG_STDOUT, PROTOCOL_VERSION, -1, fd, NULL, 0);
|
|
||||||
|
|
||||||
if ((fd = dup(STDERR_FILENO)) == -1)
|
client_write_one(MSG_IDENTIFY_DONE, -1, NULL, 0);
|
||||||
fatal("dup failed");
|
|
||||||
imsg_compose(&client_ibuf,
|
client_update_event();
|
||||||
MSG_STDERR, PROTOCOL_VERSION, -1, fd, NULL, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Forward entire environment to server. */
|
/* Helper to send one message. */
|
||||||
void
|
int
|
||||||
client_send_environ(void)
|
client_write_one(enum msgtype type, int fd, const void *buf, size_t len)
|
||||||
{
|
{
|
||||||
struct msg_environ_data data;
|
int retval;
|
||||||
char **var;
|
|
||||||
|
|
||||||
for (var = environ; *var != NULL; var++) {
|
retval = imsg_compose(&client_ibuf, type, PROTOCOL_VERSION, -1, fd,
|
||||||
if (strlcpy(data.var, *var, sizeof data.var) >= sizeof data.var)
|
(void*)buf, len);
|
||||||
continue;
|
if (retval != 1)
|
||||||
client_write_server(MSG_ENVIRON, &data, sizeof data);
|
return (-1);
|
||||||
}
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write a message to the server without a file descriptor. */
|
/* Write a message to the server without a file descriptor. */
|
||||||
void
|
int
|
||||||
client_write_server(enum msgtype type, void *buf, size_t len)
|
client_write_server(enum msgtype type, const void *buf, size_t len)
|
||||||
{
|
{
|
||||||
imsg_compose(&client_ibuf, type, PROTOCOL_VERSION, -1, -1, buf, len);
|
int retval;
|
||||||
|
|
||||||
|
retval = client_write_one(type, -1, buf, len);
|
||||||
|
if (retval == 0)
|
||||||
|
client_update_event();
|
||||||
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update client event based on whether it needs to read or read and write. */
|
/* Update client event based on whether it needs to read or read and write. */
|
||||||
@@ -273,7 +408,6 @@ client_update_event(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Callback to handle signals in the client. */
|
/* Callback to handle signals in the client. */
|
||||||
/* ARGSUSED */
|
|
||||||
void
|
void
|
||||||
client_signal(int sig, unused short events, unused void *data)
|
client_signal(int sig, unused short events, unused void *data)
|
||||||
{
|
{
|
||||||
@@ -292,12 +426,12 @@ client_signal(int sig, unused short events, unused void *data)
|
|||||||
} else {
|
} else {
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
case SIGHUP:
|
case SIGHUP:
|
||||||
client_exitmsg = "lost tty";
|
client_exitreason = CLIENT_EXIT_LOST_TTY;
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
client_write_server(MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
break;
|
break;
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
client_exitmsg = "terminated";
|
client_exitreason = CLIENT_EXIT_TERMINATED;
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
client_write_server(MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
break;
|
break;
|
||||||
@@ -320,7 +454,6 @@ client_signal(int sig, unused short events, unused void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Callback for client imsg read events. */
|
/* Callback for client imsg read events. */
|
||||||
/* ARGSUSED */
|
|
||||||
void
|
void
|
||||||
client_callback(unused int fd, short events, void *data)
|
client_callback(unused int fd, short events, void *data)
|
||||||
{
|
{
|
||||||
@@ -341,7 +474,7 @@ client_callback(unused int fd, short events, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (events & EV_WRITE) {
|
if (events & EV_WRITE) {
|
||||||
if (msgbuf_write(&client_ibuf.w) < 0)
|
if (msgbuf_write(&client_ibuf.w) < 0 && errno != EAGAIN)
|
||||||
goto lost_server;
|
goto lost_server;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,40 +482,74 @@ client_callback(unused int fd, short events, void *data)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
lost_server:
|
lost_server:
|
||||||
client_exitmsg = "lost server";
|
client_exitreason = CLIENT_EXIT_LOST_SERVER;
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
event_loopexit(NULL);
|
event_loopexit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Callback for client stdin read events. */
|
||||||
|
void
|
||||||
|
client_stdin_callback(unused int fd, unused short events, unused void *data1)
|
||||||
|
{
|
||||||
|
struct msg_stdin_data data;
|
||||||
|
|
||||||
|
data.size = read(STDIN_FILENO, data.data, sizeof data.data);
|
||||||
|
if (data.size < 0 && (errno == EINTR || errno == EAGAIN))
|
||||||
|
return;
|
||||||
|
|
||||||
|
client_write_server(MSG_STDIN, &data, sizeof data);
|
||||||
|
if (data.size <= 0)
|
||||||
|
event_del(&client_stdin);
|
||||||
|
client_update_event();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Force write to file descriptor. */
|
||||||
|
void
|
||||||
|
client_write(int fd, const char *data, size_t size)
|
||||||
|
{
|
||||||
|
ssize_t used;
|
||||||
|
|
||||||
|
while (size != 0) {
|
||||||
|
used = write(fd, data, size);
|
||||||
|
if (used == -1) {
|
||||||
|
if (errno == EINTR || errno == EAGAIN)
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
data += used;
|
||||||
|
size -= used;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Dispatch imsgs when in wait state (before MSG_READY). */
|
/* Dispatch imsgs when in wait state (before MSG_READY). */
|
||||||
int
|
int
|
||||||
client_dispatch_wait(void *data)
|
client_dispatch_wait(void *data0)
|
||||||
{
|
{
|
||||||
struct imsg imsg;
|
struct imsg imsg;
|
||||||
ssize_t n, datalen;
|
char *data;
|
||||||
struct msg_shell_data shelldata;
|
ssize_t n, datalen;
|
||||||
struct msg_exit_data exitdata;
|
struct msg_stdout_data stdoutdata;
|
||||||
const char *shellcmd = data;
|
struct msg_stderr_data stderrdata;
|
||||||
|
int retval;
|
||||||
if ((n = imsg_read(&client_ibuf)) == -1 || n == 0)
|
|
||||||
fatalx("imsg_read failed");
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
|
if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
|
||||||
fatalx("imsg_get failed");
|
fatalx("imsg_get failed");
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
data = imsg.data;
|
||||||
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
|
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
|
||||||
|
|
||||||
|
log_debug("got %d from server", imsg.hdr.type);
|
||||||
switch (imsg.hdr.type) {
|
switch (imsg.hdr.type) {
|
||||||
case MSG_EXIT:
|
case MSG_EXIT:
|
||||||
case MSG_SHUTDOWN:
|
case MSG_SHUTDOWN:
|
||||||
if (datalen != sizeof exitdata) {
|
if (datalen != sizeof retval && datalen != 0)
|
||||||
if (datalen != 0)
|
fatalx("bad MSG_EXIT size");
|
||||||
fatalx("bad MSG_EXIT size");
|
if (datalen == sizeof retval) {
|
||||||
} else {
|
memcpy(&retval, data, sizeof retval);
|
||||||
memcpy(&exitdata, imsg.data, sizeof exitdata);
|
client_exitval = retval;
|
||||||
client_exitval = exitdata.retcode;
|
|
||||||
}
|
}
|
||||||
imsg_free(&imsg);
|
imsg_free(&imsg);
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -390,30 +557,57 @@ client_dispatch_wait(void *data)
|
|||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
fatalx("bad MSG_READY size");
|
fatalx("bad MSG_READY size");
|
||||||
|
|
||||||
|
event_del(&client_stdin);
|
||||||
client_attached = 1;
|
client_attached = 1;
|
||||||
|
client_write_server(MSG_RESIZE, NULL, 0);
|
||||||
|
break;
|
||||||
|
case MSG_STDIN:
|
||||||
|
if (datalen != 0)
|
||||||
|
fatalx("bad MSG_STDIN size");
|
||||||
|
|
||||||
|
event_add(&client_stdin, NULL);
|
||||||
|
break;
|
||||||
|
case MSG_STDOUT:
|
||||||
|
if (datalen != sizeof stdoutdata)
|
||||||
|
fatalx("bad MSG_STDOUT size");
|
||||||
|
memcpy(&stdoutdata, data, sizeof stdoutdata);
|
||||||
|
|
||||||
|
client_write(STDOUT_FILENO, stdoutdata.data,
|
||||||
|
stdoutdata.size);
|
||||||
|
break;
|
||||||
|
case MSG_STDERR:
|
||||||
|
if (datalen != sizeof stderrdata)
|
||||||
|
fatalx("bad MSG_STDERR size");
|
||||||
|
memcpy(&stderrdata, data, sizeof stderrdata);
|
||||||
|
|
||||||
|
client_write(STDERR_FILENO, stderrdata.data,
|
||||||
|
stderrdata.size);
|
||||||
break;
|
break;
|
||||||
case MSG_VERSION:
|
case MSG_VERSION:
|
||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
fatalx("bad MSG_VERSION size");
|
fatalx("bad MSG_VERSION size");
|
||||||
|
|
||||||
log_warnx("protocol version mismatch (client %u, "
|
fprintf(stderr, "protocol version mismatch "
|
||||||
"server %u)", PROTOCOL_VERSION, imsg.hdr.peerid);
|
"(client %u, server %u)\n", PROTOCOL_VERSION,
|
||||||
|
imsg.hdr.peerid);
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
|
|
||||||
imsg_free(&imsg);
|
imsg_free(&imsg);
|
||||||
return (-1);
|
return (-1);
|
||||||
case MSG_SHELL:
|
case MSG_SHELL:
|
||||||
if (datalen != sizeof shelldata)
|
if (datalen == 0 || data[datalen - 1] != '\0')
|
||||||
fatalx("bad MSG_SHELL size");
|
fatalx("bad MSG_SHELL string");
|
||||||
memcpy(&shelldata, imsg.data, sizeof shelldata);
|
|
||||||
shelldata.shell[(sizeof shelldata.shell) - 1] = '\0';
|
|
||||||
|
|
||||||
clear_signals(0);
|
clear_signals(0);
|
||||||
|
shell_exec(data, data0);
|
||||||
shell_exec(shelldata.shell, shellcmd);
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
default:
|
case MSG_DETACH:
|
||||||
fatalx("unexpected message");
|
case MSG_DETACHKILL:
|
||||||
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
|
break;
|
||||||
|
case MSG_EXITED:
|
||||||
|
imsg_free(&imsg);
|
||||||
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
imsg_free(&imsg);
|
imsg_free(&imsg);
|
||||||
@@ -421,38 +615,44 @@ client_dispatch_wait(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Dispatch imsgs in attached state (after MSG_READY). */
|
/* Dispatch imsgs in attached state (after MSG_READY). */
|
||||||
/* ARGSUSED */
|
|
||||||
int
|
int
|
||||||
client_dispatch_attached(void)
|
client_dispatch_attached(void)
|
||||||
{
|
{
|
||||||
struct imsg imsg;
|
struct imsg imsg;
|
||||||
struct msg_lock_data lockdata;
|
struct sigaction sigact;
|
||||||
struct sigaction sigact;
|
char *data;
|
||||||
ssize_t n, datalen;
|
ssize_t n, datalen;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
|
if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
|
||||||
fatalx("imsg_get failed");
|
fatalx("imsg_get failed");
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
data = imsg.data;
|
||||||
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
|
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
|
||||||
|
|
||||||
log_debug("client got %d", imsg.hdr.type);
|
log_debug("got %d from server", imsg.hdr.type);
|
||||||
switch (imsg.hdr.type) {
|
switch (imsg.hdr.type) {
|
||||||
case MSG_DETACH:
|
case MSG_DETACH:
|
||||||
if (datalen != 0)
|
case MSG_DETACHKILL:
|
||||||
fatalx("bad MSG_DETACH size");
|
if (datalen == 0 || data[datalen - 1] != '\0')
|
||||||
|
fatalx("bad MSG_DETACH string");
|
||||||
|
|
||||||
|
client_exitsession = xstrdup(data);
|
||||||
|
client_exittype = imsg.hdr.type;
|
||||||
|
if (imsg.hdr.type == MSG_DETACHKILL)
|
||||||
|
client_exitreason = CLIENT_EXIT_DETACHED_HUP;
|
||||||
|
else
|
||||||
|
client_exitreason = CLIENT_EXIT_DETACHED;
|
||||||
client_write_server(MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
client_exitmsg = "detached";
|
|
||||||
break;
|
break;
|
||||||
case MSG_EXIT:
|
case MSG_EXIT:
|
||||||
if (datalen != 0 &&
|
if (datalen != 0 && datalen != sizeof (int))
|
||||||
datalen != sizeof (struct msg_exit_data))
|
|
||||||
fatalx("bad MSG_EXIT size");
|
fatalx("bad MSG_EXIT size");
|
||||||
|
|
||||||
client_write_server(MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
client_exitmsg = "exited";
|
client_exitreason = CLIENT_EXIT_EXITED;
|
||||||
break;
|
break;
|
||||||
case MSG_EXITED:
|
case MSG_EXITED:
|
||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
@@ -465,7 +665,7 @@ client_dispatch_attached(void)
|
|||||||
fatalx("bad MSG_SHUTDOWN size");
|
fatalx("bad MSG_SHUTDOWN size");
|
||||||
|
|
||||||
client_write_server(MSG_EXITING, NULL, 0);
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
client_exitmsg = "server exited";
|
client_exitreason = CLIENT_EXIT_SERVER_EXITED;
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
break;
|
break;
|
||||||
case MSG_SUSPEND:
|
case MSG_SUSPEND:
|
||||||
@@ -481,16 +681,12 @@ client_dispatch_attached(void)
|
|||||||
kill(getpid(), SIGTSTP);
|
kill(getpid(), SIGTSTP);
|
||||||
break;
|
break;
|
||||||
case MSG_LOCK:
|
case MSG_LOCK:
|
||||||
if (datalen != sizeof lockdata)
|
if (datalen == 0 || data[datalen - 1] != '\0')
|
||||||
fatalx("bad MSG_LOCK size");
|
fatalx("bad MSG_LOCK string");
|
||||||
memcpy(&lockdata, imsg.data, sizeof lockdata);
|
|
||||||
|
|
||||||
lockdata.cmd[(sizeof lockdata.cmd) - 1] = '\0';
|
system(data);
|
||||||
system(lockdata.cmd);
|
|
||||||
client_write_server(MSG_UNLOCK, NULL, 0);
|
client_write_server(MSG_UNLOCK, NULL, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
fatalx("unexpected message");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
imsg_free(&imsg);
|
imsg_free(&imsg);
|
||||||
|
|||||||
17
clock.c
17
clock.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: clock.c,v 1.9 2009-12-04 22:14:47 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -103,13 +103,20 @@ clock_draw(struct screen_write_ctx *ctx, int colour, int style)
|
|||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
char tim[64], *ptr;
|
char tim[64], *ptr;
|
||||||
time_t t;
|
time_t t;
|
||||||
|
struct tm *tm;
|
||||||
u_int i, j, x, y, idx;
|
u_int i, j, x, y, idx;
|
||||||
|
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
if (style == 0)
|
tm = localtime(&t);
|
||||||
strftime(tim, sizeof tim, "%l:%M %p", localtime(&t));
|
if (style == 0) {
|
||||||
else
|
strftime(tim, sizeof tim, "%l:%M ", localtime(&t));
|
||||||
strftime(tim, sizeof tim, "%H:%M", localtime(&t));
|
if (tm->tm_hour >= 12)
|
||||||
|
strlcat(tim, "PM", sizeof tim);
|
||||||
|
else
|
||||||
|
strlcat(tim, "AM", sizeof tim);
|
||||||
|
} else
|
||||||
|
strftime(tim, sizeof tim, "%H:%M", tm);
|
||||||
|
|
||||||
|
|
||||||
screen_write_clearscreen(ctx);
|
screen_write_clearscreen(ctx);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-attach-session.c,v 1.37 2010-12-22 15:36:44 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,47 +18,77 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attach existing session to the current terminal.
|
* Attach existing session to the current terminal.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_attach_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_attach_session_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_attach_session_entry = {
|
const struct cmd_entry cmd_attach_session_entry = {
|
||||||
"attach-session", "attach",
|
"attach-session", "attach",
|
||||||
"[-dr] " CMD_TARGET_SESSION_USAGE,
|
"c:drt:", 0, 0,
|
||||||
CMD_CANTNEST|CMD_STARTSERVER|CMD_SENDENVIRON, "dr",
|
"[-dr] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
|
||||||
cmd_target_init,
|
CMD_CANTNEST|CMD_STARTSERVER,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_attach_session_exec,
|
cmd_attach_session_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
|
||||||
|
const char *cflag)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
struct winlink *wl = NULL;
|
||||||
|
struct window *w = NULL;
|
||||||
|
struct window_pane *wp = NULL;
|
||||||
const char *update;
|
const char *update;
|
||||||
char *overrides, *cause;
|
char *cause;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
int fd;
|
||||||
|
struct format_tree *ft;
|
||||||
|
char *cp;
|
||||||
|
|
||||||
if (RB_EMPTY(&sessions)) {
|
if (RB_EMPTY(&sessions)) {
|
||||||
ctx->error(ctx, "no sessions");
|
cmdq_error(cmdq, "no sessions");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (ctx->cmdclient == NULL && ctx->curclient == NULL)
|
if (tflag == NULL) {
|
||||||
return (0);
|
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 = cmd_lookup_windowid(tflag);
|
||||||
|
if (w == NULL && (wp = cmd_lookup_paneid(tflag)) != NULL)
|
||||||
|
w = wp->window;
|
||||||
|
if (w != NULL)
|
||||||
|
wl = winlink_find_by_window(&s->windows, w);
|
||||||
|
}
|
||||||
|
|
||||||
if (ctx->cmdclient == NULL) {
|
if (cmdq->client == NULL)
|
||||||
if (cmd_check_flag(data->chflags, 'd')) {
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
if (wl != NULL) {
|
||||||
|
if (wp != NULL)
|
||||||
|
window_set_active_pane(wp->window, wp);
|
||||||
|
session_set_current(s, wl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmdq->client->session != NULL) {
|
||||||
|
if (dflag) {
|
||||||
/*
|
/*
|
||||||
* Can't use server_write_session in case attaching to
|
* Can't use server_write_session in case attaching to
|
||||||
* the same session as currently attached to.
|
* the same session as currently attached to.
|
||||||
@@ -67,44 +97,99 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
if (c == NULL || c->session != s)
|
if (c == NULL || c->session != s)
|
||||||
continue;
|
continue;
|
||||||
if (c == ctx->curclient)
|
if (c == cmdq->client)
|
||||||
continue;
|
continue;
|
||||||
server_write_client(c, MSG_DETACH, NULL, 0);
|
server_write_client(c, MSG_DETACH,
|
||||||
|
c->session->name,
|
||||||
|
strlen(c->session->name) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->curclient->session = s;
|
if (cflag != NULL) {
|
||||||
server_redraw_client(ctx->curclient);
|
ft = format_create();
|
||||||
|
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
||||||
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, s->curw);
|
||||||
|
format_window_pane(ft, s->curw->window->active);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdq->client->session = s;
|
||||||
|
notify_attached_session_changed(cmdq->client);
|
||||||
|
session_update_activity(s);
|
||||||
|
server_redraw_client(cmdq->client);
|
||||||
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
} else {
|
} else {
|
||||||
if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
|
if (server_client_open(cmdq->client, s, &cause) != 0) {
|
||||||
ctx->error(ctx, "not a terminal");
|
cmdq_error(cmdq, "open terminal failed: %s", cause);
|
||||||
return (-1);
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
overrides =
|
if (cflag != NULL) {
|
||||||
options_get_string(&s->options, "terminal-overrides");
|
ft = format_create();
|
||||||
if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
|
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
||||||
ctx->error(ctx, "terminal open failed: %s", cause);
|
format_client(ft, c);
|
||||||
xfree(cause);
|
format_session(ft, s);
|
||||||
return (-1);
|
format_winlink(ft, s, s->curw);
|
||||||
|
format_window_pane(ft, s->curw->window->active);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'r'))
|
if (rflag)
|
||||||
ctx->cmdclient->flags |= CLIENT_READONLY;
|
cmdq->client->flags |= CLIENT_READONLY;
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'd'))
|
if (dflag) {
|
||||||
server_write_session(s, MSG_DETACH, NULL, 0);
|
server_write_session(s, MSG_DETACH, s->name,
|
||||||
|
strlen(s->name) + 1);
|
||||||
ctx->cmdclient->session = s;
|
}
|
||||||
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
|
||||||
|
|
||||||
update = options_get_string(&s->options, "update-environment");
|
update = options_get_string(&s->options, "update-environment");
|
||||||
environ_update(update, &ctx->cmdclient->environ, &s->environ);
|
environ_update(update, &cmdq->client->environ, &s->environ);
|
||||||
|
|
||||||
server_redraw_client(ctx->cmdclient);
|
cmdq->client->session = s;
|
||||||
|
notify_attached_session_changed(cmdq->client);
|
||||||
|
session_update_activity(s);
|
||||||
|
server_redraw_client(cmdq->client);
|
||||||
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
|
|
||||||
|
server_write_ready(cmdq->client);
|
||||||
|
cmdq->client_exit = 0;
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_update_socket();
|
server_update_socket();
|
||||||
|
|
||||||
return (1); /* 1 means don't tell command client to exit */
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
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')));
|
||||||
}
|
}
|
||||||
|
|||||||
226
cmd-bind-key.c
226
cmd-bind-key.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-bind-key.c,v 1.29 2010-07-02 02:43:01 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,186 +27,107 @@
|
|||||||
* Bind a key to a command, this recurses through cmd_*.
|
* Bind a key to a command, this recurses through cmd_*.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_bind_key_parse(struct cmd *, int, char **, char **);
|
enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmd_q *);
|
||||||
int cmd_bind_key_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_bind_key_free(struct cmd *);
|
|
||||||
size_t cmd_bind_key_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
int cmd_bind_key_table(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_bind_key_table(struct cmd *, struct cmd_q *, int);
|
||||||
|
|
||||||
struct cmd_bind_key_data {
|
|
||||||
int key;
|
|
||||||
int can_repeat;
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
|
|
||||||
int command_key;
|
|
||||||
char *tablename;
|
|
||||||
char *modecmd;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_bind_key_entry = {
|
const struct cmd_entry cmd_bind_key_entry = {
|
||||||
"bind-key", "bind",
|
"bind-key", "bind",
|
||||||
|
"cnrt:", 1, -1,
|
||||||
"[-cnr] [-t key-table] key command [arguments]",
|
"[-cnr] [-t key-table] key command [arguments]",
|
||||||
0, "",
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_bind_key_parse,
|
cmd_bind_key_exec
|
||||||
cmd_bind_key_exec,
|
|
||||||
cmd_bind_key_free,
|
|
||||||
cmd_bind_key_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_bind_key_parse(struct cmd *self, int argc, char **argv, char **cause)
|
cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_bind_key_data *data;
|
struct args *args = self->args;
|
||||||
int opt, no_prefix = 0;
|
char *cause;
|
||||||
|
struct cmd_list *cmdlist;
|
||||||
|
int key;
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
if (args_has(args, 't')) {
|
||||||
data->can_repeat = 0;
|
if (args->argc != 2 && args->argc != 3) {
|
||||||
data->cmdlist = NULL;
|
cmdq_error(cmdq, "not enough arguments");
|
||||||
data->command_key = 0;
|
return (CMD_RETURN_ERROR);
|
||||||
data->tablename = NULL;
|
}
|
||||||
data->modecmd = NULL;
|
} else {
|
||||||
|
if (args->argc < 2) {
|
||||||
while ((opt = getopt(argc, argv, "cnrt:")) != -1) {
|
cmdq_error(cmdq, "not enough arguments");
|
||||||
switch (opt) {
|
return (CMD_RETURN_ERROR);
|
||||||
case 'c':
|
|
||||||
data->command_key = 1;
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
no_prefix = 1;
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
data->can_repeat = 1;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->tablename == NULL)
|
|
||||||
data->tablename = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc < 1)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
if ((data->key = key_string_lookup_string(argv[0])) == KEYC_NONE) {
|
key = key_string_lookup_string(args->argv[0]);
|
||||||
xasprintf(cause, "unknown key: %s", argv[0]);
|
if (key == KEYC_NONE) {
|
||||||
goto error;
|
cmdq_error(cmdq, "unknown key: %s", args->argv[0]);
|
||||||
}
|
return (CMD_RETURN_ERROR);
|
||||||
if (!no_prefix)
|
|
||||||
data->key |= KEYC_PREFIX;
|
|
||||||
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
if (data->tablename != NULL) {
|
|
||||||
if (argc != 1)
|
|
||||||
goto usage;
|
|
||||||
data->modecmd = xstrdup(argv[0]);
|
|
||||||
} else {
|
|
||||||
if ((data->cmdlist = cmd_list_parse(argc, argv, cause)) == NULL)
|
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
if (args_has(args, 't'))
|
||||||
|
return (cmd_bind_key_table(self, cmdq, key));
|
||||||
|
|
||||||
usage:
|
cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, NULL, 0,
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
&cause);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
|
cmdq_error(cmdq, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
error:
|
if (!args_has(args, 'n'))
|
||||||
self->entry->free(self);
|
key |= KEYC_PREFIX;
|
||||||
return (-1);
|
key_bindings_add(key, args_has(args, 'r'), cmdlist);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_bind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_bind_key_table(struct cmd *self, struct cmd_q *cmdq, int key)
|
||||||
{
|
{
|
||||||
struct cmd_bind_key_data *data = self->data;
|
struct args *args = self->args;
|
||||||
|
const char *tablename;
|
||||||
if (data == NULL)
|
|
||||||
return (0);
|
|
||||||
if (data->tablename != NULL)
|
|
||||||
return (cmd_bind_key_table(self, ctx));
|
|
||||||
|
|
||||||
key_bindings_add(data->key, data->can_repeat, data->cmdlist);
|
|
||||||
data->cmdlist->references++;
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_bind_key_table(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_bind_key_data *data = self->data;
|
|
||||||
const struct mode_key_table *mtab;
|
const struct mode_key_table *mtab;
|
||||||
struct mode_key_binding *mbind, mtmp;
|
struct mode_key_binding *mbind, mtmp;
|
||||||
enum mode_key_cmd cmd;
|
enum mode_key_cmd cmd;
|
||||||
|
const char *arg;
|
||||||
|
|
||||||
if ((mtab = mode_key_findtable(data->tablename)) == NULL) {
|
tablename = args_get(args, 't');
|
||||||
ctx->error(ctx, "unknown key table: %s", data->tablename);
|
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
||||||
return (-1);
|
cmdq_error(cmdq, "unknown key table: %s", tablename);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = mode_key_fromstring(mtab->cmdstr, data->modecmd);
|
cmd = mode_key_fromstring(mtab->cmdstr, args->argv[1]);
|
||||||
if (cmd == MODEKEY_NONE) {
|
if (cmd == MODEKEY_NONE) {
|
||||||
ctx->error(ctx, "unknown command: %s", data->modecmd);
|
cmdq_error(cmdq, "unknown command: %s", args->argv[1]);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtmp.key = data->key & ~KEYC_PREFIX;
|
if (cmd != MODEKEYCOPY_COPYPIPE) {
|
||||||
mtmp.mode = data->command_key ? 1 : 0;
|
if (args->argc != 2) {
|
||||||
if ((mbind = SPLAY_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {
|
cmdq_error(cmdq, "no argument allowed");
|
||||||
mbind->cmd = cmd;
|
return (CMD_RETURN_ERROR);
|
||||||
return (0);
|
}
|
||||||
|
arg = NULL;
|
||||||
|
} else {
|
||||||
|
if (args->argc != 3) {
|
||||||
|
cmdq_error(cmdq, "no argument given");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
arg = args->argv[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
mtmp.key = key;
|
||||||
|
mtmp.mode = !!args_has(args, 'c');
|
||||||
|
if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) == NULL) {
|
||||||
|
mbind = xmalloc(sizeof *mbind);
|
||||||
|
mbind->key = mtmp.key;
|
||||||
|
mbind->mode = mtmp.mode;
|
||||||
|
RB_INSERT(mode_key_tree, mtab->tree, mbind);
|
||||||
}
|
}
|
||||||
mbind = xmalloc(sizeof *mbind);
|
|
||||||
mbind->key = mtmp.key;
|
|
||||||
mbind->mode = mtmp.mode;
|
|
||||||
mbind->cmd = cmd;
|
mbind->cmd = cmd;
|
||||||
SPLAY_INSERT(mode_key_tree, mtab->tree, mbind);
|
mbind->arg = arg != NULL ? xstrdup(arg) : NULL;
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_bind_key_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_bind_key_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->cmdlist != NULL)
|
|
||||||
cmd_list_free(data->cmdlist);
|
|
||||||
if (data->tablename != NULL)
|
|
||||||
xfree(data->tablename);
|
|
||||||
if (data->modecmd != NULL)
|
|
||||||
xfree(data->modecmd);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_bind_key_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_bind_key_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
const char *skey;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
|
|
||||||
if (off < len && data->command_key)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -c");
|
|
||||||
if (off < len && !(data->key & KEYC_PREFIX))
|
|
||||||
off += xsnprintf(buf + off, len - off, " -n");
|
|
||||||
if (off < len && data->can_repeat)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -r");
|
|
||||||
if (off < len && data->tablename != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->tablename);
|
|
||||||
if (off < len) {
|
|
||||||
skey = key_string_lookup_key(data->key & ~KEYC_PREFIX);
|
|
||||||
off += xsnprintf(buf + off, len - off, " %s ", skey);
|
|
||||||
}
|
|
||||||
if (off < len)
|
|
||||||
off += cmd_list_print(data->cmdlist, buf + off, len - off);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-break-pane.c,v 1.11 2009-12-04 22:14:47 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,59 +26,89 @@
|
|||||||
* Break pane off into a window.
|
* Break pane off into a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_break_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_break_pane_entry = {
|
const struct cmd_entry cmd_break_pane_entry = {
|
||||||
"break-pane", "breakp",
|
"break-pane", "breakp",
|
||||||
CMD_TARGET_PANE_USAGE " [-d]",
|
"dPF:t:", 0, 0,
|
||||||
0, "d",
|
"[-dP] [-F format] " CMD_TARGET_PANE_USAGE,
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_break_pane_exec,
|
cmd_break_pane_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
|
char *name;
|
||||||
char *cause;
|
char *cause;
|
||||||
int base_idx;
|
int base_idx;
|
||||||
|
struct client *c;
|
||||||
|
struct format_tree *ft;
|
||||||
|
const char *template;
|
||||||
|
char *cp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, data->target, &s, &wp)) == NULL)
|
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_count_panes(wl->window) == 1) {
|
if (window_count_panes(wl->window) == 1) {
|
||||||
ctx->error(ctx, "can't break with only one pane");
|
cmdq_error(cmdq, "can't break with only one pane");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_REMOVE(&wl->window->panes, wp, entry);
|
w = wl->window;
|
||||||
if (wl->window->active == wp) {
|
server_unzoom_window(w);
|
||||||
wl->window->active = TAILQ_PREV(wp, window_panes, entry);
|
|
||||||
if (wl->window->active == NULL)
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
wl->window->active = TAILQ_NEXT(wp, entry);
|
if (wp == w->active) {
|
||||||
}
|
w->active = w->last;
|
||||||
|
w->last = NULL;
|
||||||
|
if (w->active == NULL) {
|
||||||
|
w->active = TAILQ_PREV(wp, window_panes, entry);
|
||||||
|
if (w->active == NULL)
|
||||||
|
w->active = TAILQ_NEXT(wp, entry);
|
||||||
|
}
|
||||||
|
} else if (wp == w->last)
|
||||||
|
w->last = NULL;
|
||||||
layout_close_pane(wp);
|
layout_close_pane(wp);
|
||||||
|
|
||||||
w = wp->window = window_create1(s->sx, s->sy);
|
w = wp->window = window_create1(s->sx, s->sy);
|
||||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||||
w->active = wp;
|
w->active = wp;
|
||||||
w->name = default_window_name(w);
|
name = default_window_name(w);
|
||||||
layout_init(w);
|
window_set_name(w, name);
|
||||||
|
free(name);
|
||||||
|
layout_init(w, wp);
|
||||||
|
|
||||||
base_idx = options_get_number(&s->options, "base-index");
|
base_idx = options_get_number(&s->options, "base-index");
|
||||||
wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */
|
wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */
|
||||||
if (!cmd_check_flag(data->chflags, 'd'))
|
if (!args_has(self->args, 'd'))
|
||||||
session_select(s, wl->idx);
|
session_select(s, wl->idx);
|
||||||
|
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
server_status_session_group(s);
|
server_status_session_group(s);
|
||||||
|
|
||||||
return (0);
|
if (args_has(args, 'P')) {
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = BREAK_PANE_TEMPLATE;
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
||||||
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, wp);
|
||||||
|
|
||||||
|
cp = format_expand(ft, template);
|
||||||
|
cmdq_print(cmdq, "%s", cp);
|
||||||
|
free(cp);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-capture-pane.c,v 1.3 2010-01-22 17:29:19 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net>
|
* Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net>
|
||||||
@@ -18,66 +18,200 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write the entire contents of a pane to a buffer.
|
* Write the entire contents of a pane to a buffer or stdout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_capture_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
|
char *cmd_capture_pane_append(char *, size_t *, char *, size_t);
|
||||||
|
char *cmd_capture_pane_pending(struct args *, struct window_pane *,
|
||||||
|
size_t *);
|
||||||
|
char *cmd_capture_pane_history(struct args *, struct cmd_q *,
|
||||||
|
struct window_pane *, size_t *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_capture_pane_entry = {
|
const struct cmd_entry cmd_capture_pane_entry = {
|
||||||
"capture-pane", "capturep",
|
"capture-pane", "capturep",
|
||||||
CMD_BUFFER_PANE_USAGE,
|
"ab:CeE:JpPqS:t:", 0, 0,
|
||||||
0, "",
|
"[-aCeJpPq] [-b buffer-index] [-E end-line] [-S start-line]"
|
||||||
cmd_buffer_init,
|
CMD_TARGET_PANE_USAGE,
|
||||||
cmd_buffer_parse,
|
0,
|
||||||
cmd_capture_pane_exec,
|
NULL,
|
||||||
cmd_buffer_free,
|
cmd_capture_pane_exec
|
||||||
cmd_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
char *
|
||||||
cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen)
|
||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
buf = xrealloc(buf, 1, *len + linelen + 1);
|
||||||
struct window_pane *wp;
|
memcpy(buf + *len, line, linelen);
|
||||||
char *buf, *line;
|
*len += linelen;
|
||||||
struct screen *s;
|
return (buf);
|
||||||
struct session *sess;
|
}
|
||||||
u_int i, limit;
|
|
||||||
size_t len, linelen;
|
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, data->target, &sess, &wp) == NULL)
|
char *
|
||||||
return (-1);
|
cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
||||||
s = &wp->base;
|
size_t *len)
|
||||||
|
{
|
||||||
|
char *buf, *line, tmp[5];
|
||||||
|
size_t linelen;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
if (wp->ictx.since_ground == NULL)
|
||||||
|
return (xstrdup(""));
|
||||||
|
|
||||||
|
line = EVBUFFER_DATA(wp->ictx.since_ground);
|
||||||
|
linelen = EVBUFFER_LENGTH(wp->ictx.since_ground);
|
||||||
|
|
||||||
|
buf = xstrdup("");
|
||||||
|
if (args_has(args, 'C')) {
|
||||||
|
for (i = 0; i < linelen; i++) {
|
||||||
|
if (line[i] >= ' ') {
|
||||||
|
tmp[0] = line[i];
|
||||||
|
tmp[1] = '\0';
|
||||||
|
} else
|
||||||
|
xsnprintf(tmp, sizeof tmp, "\\%03o", line[i]);
|
||||||
|
buf = cmd_capture_pane_append(buf, len, tmp,
|
||||||
|
strlen(tmp));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
buf = cmd_capture_pane_append(buf, len, line, linelen);
|
||||||
|
return (buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
|
||||||
|
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;
|
||||||
|
u_int i, sx, top, bottom, tmp;
|
||||||
|
char *cause, *buf, *line;
|
||||||
|
size_t linelen;
|
||||||
|
|
||||||
|
sx = screen_size_x(&wp->base);
|
||||||
|
if (args_has(args, 'a')) {
|
||||||
|
gd = wp->saved_grid;
|
||||||
|
if (gd == NULL) {
|
||||||
|
if (!args_has(args, 'q')) {
|
||||||
|
cmdq_error(cmdq, "no alternate screen");
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
return (xstrdup(""));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
gd = wp->base.grid;
|
||||||
|
|
||||||
|
n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
top = gd->hsize;
|
||||||
|
free(cause);
|
||||||
|
} else if (n < 0 && (u_int) -n > gd->hsize)
|
||||||
|
top = 0;
|
||||||
|
else
|
||||||
|
top = gd->hsize + n;
|
||||||
|
if (top > gd->hsize + gd->sy - 1)
|
||||||
|
top = gd->hsize + gd->sy - 1;
|
||||||
|
|
||||||
|
n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
bottom = gd->hsize + gd->sy - 1;
|
||||||
|
free(cause);
|
||||||
|
} else if (n < 0 && (u_int) -n > gd->hsize)
|
||||||
|
bottom = 0;
|
||||||
|
else
|
||||||
|
bottom = gd->hsize + n;
|
||||||
|
if (bottom > gd->hsize + gd->sy - 1)
|
||||||
|
bottom = gd->hsize + gd->sy - 1;
|
||||||
|
|
||||||
|
if (bottom < top) {
|
||||||
|
tmp = bottom;
|
||||||
|
bottom = top;
|
||||||
|
top = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
with_codes = args_has(args, 'e');
|
||||||
|
escape_c0 = args_has(args, 'C');
|
||||||
|
join_lines = args_has(args, 'J');
|
||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
len = 0;
|
for (i = top; i <= bottom; i++) {
|
||||||
|
line = grid_string_cells(gd, 0, i, sx, &gc, with_codes,
|
||||||
|
escape_c0, !join_lines);
|
||||||
|
linelen = strlen(line);
|
||||||
|
|
||||||
for (i = 0; i < screen_size_y(s); i++) {
|
buf = cmd_capture_pane_append(buf, len, line, linelen);
|
||||||
line = grid_view_string_cells(s->grid, 0, i, screen_size_x(s));
|
|
||||||
linelen = strlen(line);
|
|
||||||
|
|
||||||
buf = xrealloc(buf, 1, len + linelen + 1);
|
gl = grid_peek_line(gd, i);
|
||||||
memcpy(buf + len, line, linelen);
|
if (!join_lines || !(gl->flags & GRID_LINE_WRAPPED))
|
||||||
len += linelen;
|
buf[(*len)++] = '\n';
|
||||||
buf[len++] = '\n';
|
|
||||||
|
|
||||||
xfree(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
return (buf);
|
||||||
limit = options_get_number(&sess->options, "buffer-limit");
|
}
|
||||||
if (data->buffer == -1) {
|
|
||||||
paste_add(&sess->buffers, buf, len, limit);
|
enum cmd_retval
|
||||||
return (0);
|
cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
}
|
{
|
||||||
if (paste_replace(&sess->buffers, data->buffer, buf, len) != 0) {
|
struct args *args = self->args;
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
struct client *c;
|
||||||
xfree(buf);
|
struct window_pane *wp;
|
||||||
return (-1);
|
char *buf, *cause;
|
||||||
}
|
int buffer;
|
||||||
return (0);
|
u_int limit;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
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);
|
||||||
|
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");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
evbuffer_add(c->stdout_data, buf, len);
|
||||||
|
if (args_has(args, 'P') && len > 0)
|
||||||
|
evbuffer_add(c->stdout_data, "\n", 1);
|
||||||
|
server_push_stdout(c);
|
||||||
|
} else {
|
||||||
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
|
if (!args_has(args, 'b')) {
|
||||||
|
paste_add(&global_buffers, buf, len, limit);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(cmdq, "buffer %s", cause);
|
||||||
|
free(buf);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paste_replace(&global_buffers, buffer, buf, len) != 0) {
|
||||||
|
cmdq_error(cmdq, "no buffer %d", buffer);
|
||||||
|
free(buf);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-choose-buffer.c,v 1.1 2010-06-22 23:35:20 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,121 +27,69 @@
|
|||||||
* Enter choice mode to choose a buffer.
|
* Enter choice mode to choose a buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_choose_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_choose_buffer_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
void cmd_choose_buffer_callback(void *, int);
|
|
||||||
void cmd_choose_buffer_free(void *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_buffer_entry = {
|
const struct cmd_entry cmd_choose_buffer_entry = {
|
||||||
"choose-buffer", NULL,
|
"choose-buffer", NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE " [template]",
|
"F:t:", 0, 1,
|
||||||
CMD_ARG01, "",
|
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_choose_buffer_exec,
|
cmd_choose_buffer_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_choose_buffer_data {
|
enum cmd_retval
|
||||||
struct client *client;
|
cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
char *template;
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct cmd_choose_buffer_data *cdata;
|
struct client *c;
|
||||||
struct session *s;
|
struct window_choose_data *cdata;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
|
char *action, *action_data;
|
||||||
|
const char *template;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
char *tmp;
|
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if ((c = cmd_current_client(cmdq)) == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
cmdq_error(cmdq, "no client available");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
s = ctx->curclient->session;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
return (-1);
|
template = CHOOSE_BUFFER_TEMPLATE;
|
||||||
|
|
||||||
if (paste_get_top(&s->buffers) == NULL)
|
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (0);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if (paste_get_top(&global_buffers) == NULL)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
if (args->argc != 0)
|
||||||
|
action = xstrdup(args->argv[0]);
|
||||||
|
else
|
||||||
|
action = xstrdup("paste-buffer -b '%%'");
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) {
|
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
|
||||||
tmp = paste_print(pb, 50);
|
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
||||||
window_choose_add(wl->window->active, idx - 1,
|
cdata->idx = idx - 1;
|
||||||
"%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp);
|
|
||||||
xfree(tmp);
|
cdata->ft_template = xstrdup(template);
|
||||||
|
format_add(cdata->ft, "line", "%u", idx - 1);
|
||||||
|
format_paste_buffer(cdata->ft, pb);
|
||||||
|
|
||||||
|
xasprintf(&action_data, "%u", idx - 1);
|
||||||
|
cdata->command = cmd_template_replace(action, action_data, 1);
|
||||||
|
free(action_data);
|
||||||
|
|
||||||
|
window_choose_add(wl->window->active, cdata);
|
||||||
}
|
}
|
||||||
|
free(action);
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
window_choose_ready(wl->window->active, 0, NULL);
|
||||||
if (data->arg != NULL)
|
|
||||||
cdata->template = xstrdup(data->arg);
|
|
||||||
else
|
|
||||||
cdata->template = xstrdup("paste-buffer -b '%%'");
|
|
||||||
cdata->client = ctx->curclient;
|
|
||||||
cdata->client->references++;
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active,
|
return (CMD_RETURN_NORMAL);
|
||||||
0, cmd_choose_buffer_callback, cmd_choose_buffer_free, cdata);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_choose_buffer_callback(void *data, int idx)
|
|
||||||
{
|
|
||||||
struct cmd_choose_buffer_data *cdata = data;
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmd_ctx ctx;
|
|
||||||
char *template, *cause, tmp[16];
|
|
||||||
|
|
||||||
if (idx == -1)
|
|
||||||
return;
|
|
||||||
if (cdata->client->flags & CLIENT_DEAD)
|
|
||||||
return;
|
|
||||||
|
|
||||||
xsnprintf(tmp, sizeof tmp, "%u", idx);
|
|
||||||
template = cmd_template_replace(cdata->template, tmp, 1);
|
|
||||||
|
|
||||||
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
|
||||||
if (cause != NULL) {
|
|
||||||
*cause = toupper((u_char) *cause);
|
|
||||||
status_message_set(cdata->client, "%s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
|
||||||
ctx.curclient = cdata->client;
|
|
||||||
|
|
||||||
ctx.error = key_bindings_error;
|
|
||||||
ctx.print = key_bindings_print;
|
|
||||||
ctx.info = key_bindings_info;
|
|
||||||
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
|
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_choose_buffer_free(void *data)
|
|
||||||
{
|
|
||||||
struct cmd_choose_buffer_data *cdata = data;
|
|
||||||
|
|
||||||
cdata->client->references--;
|
|
||||||
xfree(cdata->template);
|
|
||||||
xfree(cdata);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-choose-client.c,v 1.4 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,127 +27,98 @@
|
|||||||
* Enter choice mode to choose a client.
|
* Enter choice mode to choose a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_choose_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_choose_client_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
void cmd_choose_client_callback(void *, int);
|
void cmd_choose_client_callback(struct window_choose_data *);
|
||||||
void cmd_choose_client_free(void *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_client_entry = {
|
const struct cmd_entry cmd_choose_client_entry = {
|
||||||
"choose-client", NULL,
|
"choose-client", NULL,
|
||||||
CMD_TARGET_WINDOW_USAGE " [template]",
|
"F:t:", 0, 1,
|
||||||
CMD_ARG01, "",
|
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_choose_client_exec,
|
cmd_choose_client_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_choose_client_data {
|
struct cmd_choose_client_data {
|
||||||
struct client *client;
|
struct client *client;
|
||||||
char *template;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct cmd_choose_client_data *cdata;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
struct client *c1;
|
||||||
|
struct window_choose_data *cdata;
|
||||||
|
struct winlink *wl;
|
||||||
|
const char *template;
|
||||||
|
char *action;
|
||||||
u_int i, idx, cur;
|
u_int i, idx, cur;
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if ((c = cmd_current_client(cmdq)) == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
cmdq_error(cmdq, "no client available");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
return (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;
|
cur = idx = 0;
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
c1 = ARRAY_ITEM(&clients, i);
|
||||||
if (c == NULL || c->session == NULL)
|
if (c1 == NULL || c1->session == NULL || c1->tty.path == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (c == ctx->curclient)
|
if (c1 == cmdq->client)
|
||||||
cur = idx;
|
cur = idx;
|
||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
window_choose_add(wl->window->active, i,
|
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
||||||
"%s: %s [%ux%u %s]%s", c->tty.path,
|
cdata->idx = i;
|
||||||
c->session->name, c->tty.sx, c->tty.sy,
|
|
||||||
c->tty.termname, c->tty.flags & TTY_UTF8 ? " (utf8)" : "");
|
cdata->ft_template = xstrdup(template);
|
||||||
|
format_add(cdata->ft, "line", "%u", i);
|
||||||
|
format_session(cdata->ft, c1->session);
|
||||||
|
format_client(cdata->ft, c1);
|
||||||
|
|
||||||
|
cdata->command = cmd_template_replace(action, c1->tty.path, 1);
|
||||||
|
|
||||||
|
window_choose_add(wl->window->active, cdata);
|
||||||
}
|
}
|
||||||
|
free(action);
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
window_choose_ready(wl->window->active, cur,
|
||||||
if (data->arg != NULL)
|
cmd_choose_client_callback);
|
||||||
cdata->template = xstrdup(data->arg);
|
|
||||||
else
|
|
||||||
cdata->template = xstrdup("detach-client -t '%%'");
|
|
||||||
cdata->client = ctx->curclient;
|
|
||||||
cdata->client->references++;
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active,
|
return (CMD_RETURN_NORMAL);
|
||||||
cur, cmd_choose_client_callback, cmd_choose_client_free, cdata);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_choose_client_callback(void *data, int idx)
|
cmd_choose_client_callback(struct window_choose_data *cdata)
|
||||||
{
|
{
|
||||||
struct cmd_choose_client_data *cdata = data;
|
struct client *c;
|
||||||
struct client *c;
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmd_ctx ctx;
|
|
||||||
char *template, *cause;
|
|
||||||
|
|
||||||
if (idx == -1)
|
if (cdata == NULL)
|
||||||
return;
|
return;
|
||||||
if (cdata->client->flags & CLIENT_DEAD)
|
if (cdata->start_client->flags & CLIENT_DEAD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((u_int) idx > ARRAY_LENGTH(&clients) - 1)
|
if (cdata->idx > ARRAY_LENGTH(&clients) - 1)
|
||||||
return;
|
return;
|
||||||
c = ARRAY_ITEM(&clients, idx);
|
c = ARRAY_ITEM(&clients, cdata->idx);
|
||||||
if (c == NULL || c->session == NULL)
|
if (c == NULL || c->session == NULL)
|
||||||
return;
|
return;
|
||||||
template = cmd_template_replace(cdata->template, c->tty.path, 1);
|
|
||||||
|
|
||||||
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
window_choose_data_run(cdata);
|
||||||
if (cause != NULL) {
|
|
||||||
*cause = toupper((u_char) *cause);
|
|
||||||
status_message_set(c, "%s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
|
||||||
ctx.curclient = cdata->client;
|
|
||||||
|
|
||||||
ctx.error = key_bindings_error;
|
|
||||||
ctx.print = key_bindings_print;
|
|
||||||
ctx.info = key_bindings_info;
|
|
||||||
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
|
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_choose_client_free(void *data)
|
|
||||||
{
|
|
||||||
struct cmd_choose_client_data *cdata = data;
|
|
||||||
|
|
||||||
cdata->client->references--;
|
|
||||||
xfree(cdata->template);
|
|
||||||
xfree(cdata);
|
|
||||||
}
|
}
|
||||||
|
|||||||
97
cmd-choose-list.c
Normal file
97
cmd-choose-list.c
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.org>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
#define CMD_CHOOSE_LIST_DEFAULT_TEMPLATE "run-shell '%%'"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enter choose mode to choose a custom list.
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum cmd_retval cmd_choose_list_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_choose_list_entry = {
|
||||||
|
"choose-list", NULL,
|
||||||
|
"l:t:", 0, 1,
|
||||||
|
"[-l items] " CMD_TARGET_WINDOW_USAGE "[template]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
cmd_choose_list_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_choose_list_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct client *c;
|
||||||
|
struct winlink *wl;
|
||||||
|
const char *list1;
|
||||||
|
char *template, *item, *copy, *list;
|
||||||
|
u_int idx;
|
||||||
|
|
||||||
|
if ((c = cmd_current_client(cmdq)) == NULL) {
|
||||||
|
cmdq_error(cmdq, "no client available");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((list1 = args_get(args, 'l')) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
if (args->argc != 0)
|
||||||
|
template = xstrdup(args->argv[0]);
|
||||||
|
else
|
||||||
|
template = xstrdup(CMD_CHOOSE_LIST_DEFAULT_TEMPLATE);
|
||||||
|
|
||||||
|
copy = list = xstrdup(list1);
|
||||||
|
idx = 0;
|
||||||
|
while ((item = strsep(&list, ",")) != NULL)
|
||||||
|
{
|
||||||
|
if (*item == '\0') /* no empty entries */
|
||||||
|
continue;
|
||||||
|
window_choose_add_item(wl->window->active, c, wl, item,
|
||||||
|
template, idx);
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
free(copy);
|
||||||
|
|
||||||
|
if (idx == 0) {
|
||||||
|
free(template);
|
||||||
|
window_pane_reset_mode(wl->window->active);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
window_choose_ready(wl->window->active, 0, NULL);
|
||||||
|
|
||||||
|
free(template);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
@@ -1,157 +0,0 @@
|
|||||||
/* $Id: cmd-choose-session.c,v 1.17 2010-12-22 15:36:44 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enter choice mode to choose a session.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_choose_session_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
void cmd_choose_session_callback(void *, int);
|
|
||||||
void cmd_choose_session_free(void *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_session_entry = {
|
|
||||||
"choose-session", NULL,
|
|
||||||
CMD_TARGET_WINDOW_USAGE " [template]",
|
|
||||||
CMD_ARG01, "",
|
|
||||||
cmd_target_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_choose_session_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
struct cmd_choose_session_data {
|
|
||||||
struct client *client;
|
|
||||||
char *template;
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct cmd_choose_session_data *cdata;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct session *s;
|
|
||||||
struct session_group *sg;
|
|
||||||
u_int idx, sgidx, cur;
|
|
||||||
char tmp[64];
|
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
|
||||||
ctx->error(ctx, "must be run interactively");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
cur = idx = 0;
|
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
|
||||||
if (s == ctx->curclient->session)
|
|
||||||
cur = idx;
|
|
||||||
idx++;
|
|
||||||
|
|
||||||
sg = session_group_find(s);
|
|
||||||
if (sg == NULL)
|
|
||||||
*tmp = '\0';
|
|
||||||
else {
|
|
||||||
sgidx = session_group_index(sg);
|
|
||||||
xsnprintf(tmp, sizeof tmp, " (group %u)", sgidx);
|
|
||||||
}
|
|
||||||
|
|
||||||
window_choose_add(wl->window->active, s->idx,
|
|
||||||
"%s: %u windows [%ux%u]%s%s", s->name,
|
|
||||||
winlink_count(&s->windows), s->sx, s->sy,
|
|
||||||
tmp, s->flags & SESSION_UNATTACHED ? "" : " (attached)");
|
|
||||||
}
|
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
|
||||||
if (data->arg != NULL)
|
|
||||||
cdata->template = xstrdup(data->arg);
|
|
||||||
else
|
|
||||||
cdata->template = xstrdup("switch-client -t '%%'");
|
|
||||||
cdata->client = ctx->curclient;
|
|
||||||
cdata->client->references++;
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active,
|
|
||||||
cur, cmd_choose_session_callback, cmd_choose_session_free, cdata);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_choose_session_callback(void *data, int idx)
|
|
||||||
{
|
|
||||||
struct cmd_choose_session_data *cdata = data;
|
|
||||||
struct session *s;
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmd_ctx ctx;
|
|
||||||
char *template, *cause;
|
|
||||||
|
|
||||||
if (idx == -1)
|
|
||||||
return;
|
|
||||||
if (cdata->client->flags & CLIENT_DEAD)
|
|
||||||
return;
|
|
||||||
|
|
||||||
s = session_find_by_index(idx);
|
|
||||||
if (s == NULL)
|
|
||||||
return;
|
|
||||||
template = cmd_template_replace(cdata->template, s->name, 1);
|
|
||||||
|
|
||||||
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
|
||||||
if (cause != NULL) {
|
|
||||||
*cause = toupper((u_char) *cause);
|
|
||||||
status_message_set(cdata->client, "%s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
|
||||||
ctx.curclient = cdata->client;
|
|
||||||
|
|
||||||
ctx.error = key_bindings_error;
|
|
||||||
ctx.print = key_bindings_print;
|
|
||||||
ctx.info = key_bindings_info;
|
|
||||||
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
|
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_choose_session_free(void *data)
|
|
||||||
{
|
|
||||||
struct cmd_choose_session_data *cdata = data;
|
|
||||||
|
|
||||||
cdata->client->references--;
|
|
||||||
xfree(cdata->template);
|
|
||||||
xfree(cdata);
|
|
||||||
}
|
|
||||||
235
cmd-choose-tree.c
Normal file
235
cmd-choose-tree.c
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.org>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
#define CMD_CHOOSE_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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
|
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,
|
||||||
|
NULL,
|
||||||
|
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,
|
||||||
|
NULL,
|
||||||
|
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,
|
||||||
|
NULL,
|
||||||
|
cmd_choose_tree_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_choose_tree_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
ses_template = win_template = NULL;
|
||||||
|
ses_action = win_action = NULL;
|
||||||
|
|
||||||
|
if ((c = cmd_current_client(cmdq)) == 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);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
@@ -1,181 +0,0 @@
|
|||||||
/* $Id: cmd-choose-window.c,v 1.24 2010-12-22 15:28:50 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enter choice mode to choose a window.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_choose_window_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
void cmd_choose_window_callback(void *, int);
|
|
||||||
void cmd_choose_window_free(void *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_choose_window_entry = {
|
|
||||||
"choose-window", NULL,
|
|
||||||
CMD_TARGET_WINDOW_USAGE " [template]",
|
|
||||||
CMD_ARG01, "",
|
|
||||||
cmd_target_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_choose_window_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
struct cmd_choose_window_data {
|
|
||||||
struct client *client;
|
|
||||||
struct session *session;
|
|
||||||
char *template;
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct cmd_choose_window_data *cdata;
|
|
||||||
struct session *s;
|
|
||||||
struct winlink *wl, *wm;
|
|
||||||
struct window *w;
|
|
||||||
u_int idx, cur;
|
|
||||||
char flag, *title;
|
|
||||||
const char *left, *right;
|
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
|
||||||
ctx->error(ctx, "must be run interactively");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
s = ctx->curclient->session;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
cur = idx = 0;
|
|
||||||
RB_FOREACH(wm, winlinks, &s->windows) {
|
|
||||||
w = wm->window;
|
|
||||||
|
|
||||||
if (wm == s->curw)
|
|
||||||
cur = idx;
|
|
||||||
idx++;
|
|
||||||
|
|
||||||
flag = ' ';
|
|
||||||
if (wm->flags & WINLINK_ACTIVITY)
|
|
||||||
flag = '#';
|
|
||||||
else if (wm->flags & WINLINK_BELL)
|
|
||||||
flag = '!';
|
|
||||||
else if (wm->flags & WINLINK_CONTENT)
|
|
||||||
flag = '+';
|
|
||||||
else if (wm->flags & WINLINK_SILENCE)
|
|
||||||
flag = '~';
|
|
||||||
else if (wm == s->curw)
|
|
||||||
flag = '*';
|
|
||||||
else if (wm == TAILQ_FIRST(&s->lastw))
|
|
||||||
flag = '-';
|
|
||||||
|
|
||||||
title = w->active->screen->title;
|
|
||||||
if (wm == wl)
|
|
||||||
title = w->active->base.title;
|
|
||||||
left = " \"";
|
|
||||||
right = "\"";
|
|
||||||
if (*title == '\0')
|
|
||||||
left = right = "";
|
|
||||||
|
|
||||||
window_choose_add(wl->window->active,
|
|
||||||
wm->idx, "%3d: %s%c [%ux%u] (%u panes%s)%s%s%s",
|
|
||||||
wm->idx, w->name, flag, w->sx, w->sy, window_count_panes(w),
|
|
||||||
w->active->fd == -1 ? ", dead" : "",
|
|
||||||
left, title, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
|
||||||
if (data->arg != NULL)
|
|
||||||
cdata->template = xstrdup(data->arg);
|
|
||||||
else
|
|
||||||
cdata->template = xstrdup("select-window -t '%%'");
|
|
||||||
cdata->session = s;
|
|
||||||
cdata->session->references++;
|
|
||||||
cdata->client = ctx->curclient;
|
|
||||||
cdata->client->references++;
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active,
|
|
||||||
cur, cmd_choose_window_callback, cmd_choose_window_free, cdata);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_choose_window_callback(void *data, int idx)
|
|
||||||
{
|
|
||||||
struct cmd_choose_window_data *cdata = data;
|
|
||||||
struct session *s = cdata->session;
|
|
||||||
struct cmd_list *cmdlist;
|
|
||||||
struct cmd_ctx ctx;
|
|
||||||
char *target, *template, *cause;
|
|
||||||
|
|
||||||
if (idx == -1)
|
|
||||||
return;
|
|
||||||
if (!session_alive(s))
|
|
||||||
return;
|
|
||||||
if (cdata->client->flags & CLIENT_DEAD)
|
|
||||||
return;
|
|
||||||
|
|
||||||
xasprintf(&target, "%s:%d", s->name, idx);
|
|
||||||
template = cmd_template_replace(cdata->template, target, 1);
|
|
||||||
xfree(target);
|
|
||||||
|
|
||||||
if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
|
|
||||||
if (cause != NULL) {
|
|
||||||
*cause = toupper((u_char) *cause);
|
|
||||||
status_message_set(cdata->client, "%s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
xfree(template);
|
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
|
||||||
ctx.curclient = cdata->client;
|
|
||||||
|
|
||||||
ctx.error = key_bindings_error;
|
|
||||||
ctx.print = key_bindings_print;
|
|
||||||
ctx.info = key_bindings_info;
|
|
||||||
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
|
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_choose_window_free(void *data)
|
|
||||||
{
|
|
||||||
struct cmd_choose_window_data *cdata = data;
|
|
||||||
|
|
||||||
cdata->session->references--;
|
|
||||||
cdata->client->references--;
|
|
||||||
xfree(cdata->template);
|
|
||||||
xfree(cdata);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-clear-history.c,v 1.8 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,32 +24,30 @@
|
|||||||
* Clear pane history.
|
* Clear pane history.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_clear_history_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_clear_history_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_clear_history_entry = {
|
const struct cmd_entry cmd_clear_history_entry = {
|
||||||
"clear-history", "clearhist",
|
"clear-history", "clearhist",
|
||||||
|
"t:", 0, 0,
|
||||||
CMD_TARGET_PANE_USAGE,
|
CMD_TARGET_PANE_USAGE,
|
||||||
0, "",
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_clear_history_exec
|
||||||
cmd_clear_history_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_clear_history_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_clear_history_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct grid *gd;
|
struct grid *gd;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
|
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
gd = wp->base.grid;
|
gd = wp->base.grid;
|
||||||
|
|
||||||
grid_move_lines(gd, 0, gd->hsize, gd->sy);
|
grid_move_lines(gd, 0, gd->hsize, gd->sy);
|
||||||
gd->hsize = 0;
|
gd->hsize = 0;
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-clock-mode.c,v 1.7 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,29 +24,27 @@
|
|||||||
* Enter clock mode.
|
* Enter clock mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_clock_mode_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_clock_mode_entry = {
|
const struct cmd_entry cmd_clock_mode_entry = {
|
||||||
"clock-mode", NULL,
|
"clock-mode", NULL,
|
||||||
|
"t:", 0, 0,
|
||||||
CMD_TARGET_PANE_USAGE,
|
CMD_TARGET_PANE_USAGE,
|
||||||
0, "",
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_clock_mode_exec
|
||||||
cmd_clock_mode_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_clock_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_clock_mode_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
|
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
window_pane_set_mode(wp, &window_clock_mode);
|
window_pane_set_mode(wp, &window_clock_mode);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-command-prompt.c,v 1.28 2010-05-14 14:33:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -19,7 +19,9 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -27,34 +29,25 @@
|
|||||||
* Prompt for command in client.
|
* Prompt for command in client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_command_prompt_init(struct cmd *, int);
|
void cmd_command_prompt_key_binding(struct cmd *, int);
|
||||||
int cmd_command_prompt_parse(struct cmd *, int, char **, char **);
|
enum cmd_retval cmd_command_prompt_exec(struct cmd *, struct cmd_q *);
|
||||||
int cmd_command_prompt_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_command_prompt_free(struct cmd *);
|
|
||||||
size_t cmd_command_prompt_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
int cmd_command_prompt_callback(void *, const char *);
|
int cmd_command_prompt_callback(void *, const char *);
|
||||||
void cmd_command_prompt_cfree(void *);
|
void cmd_command_prompt_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_command_prompt_entry = {
|
const struct cmd_entry cmd_command_prompt_entry = {
|
||||||
"command-prompt", NULL,
|
"command-prompt", NULL,
|
||||||
CMD_TARGET_CLIENT_USAGE " [-p prompts] [template]",
|
"I:p:t:", 0, 1,
|
||||||
0, "",
|
"[-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " [template]",
|
||||||
cmd_command_prompt_init,
|
0,
|
||||||
cmd_command_prompt_parse,
|
cmd_command_prompt_key_binding,
|
||||||
cmd_command_prompt_exec,
|
cmd_command_prompt_exec
|
||||||
cmd_command_prompt_free,
|
|
||||||
cmd_command_prompt_print
|
|
||||||
};
|
|
||||||
|
|
||||||
struct cmd_command_prompt_data {
|
|
||||||
char *prompts;
|
|
||||||
char *target;
|
|
||||||
char *template;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_command_prompt_cdata {
|
struct cmd_command_prompt_cdata {
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
char *inputs;
|
||||||
|
char *next_input;
|
||||||
char *next_prompt;
|
char *next_prompt;
|
||||||
char *prompts;
|
char *prompts;
|
||||||
char *template;
|
char *template;
|
||||||
@@ -62,149 +55,91 @@ struct cmd_command_prompt_cdata {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_command_prompt_init(struct cmd *self, int key)
|
cmd_command_prompt_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_command_prompt_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->prompts = NULL;
|
|
||||||
data->target = NULL;
|
|
||||||
data->template = NULL;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
case '$':
|
||||||
|
self->args = args_create(1, "rename-session '%%'");
|
||||||
|
args_set(self->args, 'I', "#S");
|
||||||
|
break;
|
||||||
case ',':
|
case ',':
|
||||||
data->template = xstrdup("rename-window '%%'");
|
self->args = args_create(1, "rename-window '%%'");
|
||||||
|
args_set(self->args, 'I', "#W");
|
||||||
break;
|
break;
|
||||||
case '.':
|
case '.':
|
||||||
data->template = xstrdup("move-window -t '%%'");
|
self->args = args_create(1, "move-window -t '%%'");
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
data->template = xstrdup("find-window '%%'");
|
self->args = args_create(1, "find-window '%%'");
|
||||||
break;
|
break;
|
||||||
case '\'':
|
case '\'':
|
||||||
data->template = xstrdup("select-window -t ':%%'");
|
self->args = args_create(1, "select-window -t ':%%'");
|
||||||
data->prompts = xstrdup("index");
|
args_set(self->args, 'p', "index");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
self->args = args_create(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_command_prompt_parse(struct cmd *self, int argc, char **argv, char **cause)
|
cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_command_prompt_data *data;
|
struct args *args = self->args;
|
||||||
int opt;
|
const char *inputs, *prompts;
|
||||||
|
|
||||||
self->entry->init(self, KEYC_NONE);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "p:t:")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'p':
|
|
||||||
if (data->prompts == NULL)
|
|
||||||
data->prompts = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 0 && argc != 1)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
if (argc == 1)
|
|
||||||
data->template = xstrdup(argv[0]);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_command_prompt_data *data = self->data;
|
|
||||||
struct cmd_command_prompt_cdata *cdata;
|
struct cmd_command_prompt_cdata *cdata;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
char *prompt, *ptr;
|
char *prompt, *ptr, *input = NULL;
|
||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (c->prompt_string != NULL)
|
if (c->prompt_string != NULL)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
cdata->c = c;
|
cdata->c = c;
|
||||||
cdata->idx = 1;
|
cdata->idx = 1;
|
||||||
|
cdata->inputs = NULL;
|
||||||
|
cdata->next_input = NULL;
|
||||||
cdata->next_prompt = NULL;
|
cdata->next_prompt = NULL;
|
||||||
cdata->prompts = NULL;
|
cdata->prompts = NULL;
|
||||||
cdata->template = NULL;
|
cdata->template = NULL;
|
||||||
|
|
||||||
if (data->template != NULL)
|
if (args->argc != 0)
|
||||||
cdata->template = xstrdup(data->template);
|
cdata->template = xstrdup(args->argv[0]);
|
||||||
else
|
else
|
||||||
cdata->template = xstrdup("%1");
|
cdata->template = xstrdup("%1");
|
||||||
if (data->prompts != NULL)
|
|
||||||
cdata->prompts = xstrdup(data->prompts);
|
if ((prompts = args_get(args, 'p')) != NULL)
|
||||||
else if (data->template != NULL) {
|
cdata->prompts = xstrdup(prompts);
|
||||||
n = strcspn(data->template, " ,");
|
else if (args->argc != 0) {
|
||||||
xasprintf(&cdata->prompts, "(%.*s) ", (int) n, data->template);
|
n = strcspn(cdata->template, " ,");
|
||||||
|
xasprintf(&cdata->prompts, "(%.*s) ", (int) n, cdata->template);
|
||||||
} else
|
} else
|
||||||
cdata->prompts = xstrdup(":");
|
cdata->prompts = xstrdup(":");
|
||||||
|
|
||||||
|
/* Get first prompt. */
|
||||||
cdata->next_prompt = cdata->prompts;
|
cdata->next_prompt = cdata->prompts;
|
||||||
ptr = strsep(&cdata->next_prompt, ",");
|
ptr = strsep(&cdata->next_prompt, ",");
|
||||||
if (data->prompts == NULL)
|
if (prompts == NULL)
|
||||||
prompt = xstrdup(ptr);
|
prompt = xstrdup(ptr);
|
||||||
else
|
else
|
||||||
xasprintf(&prompt, "%s ", ptr);
|
xasprintf(&prompt, "%s ", ptr);
|
||||||
status_prompt_set(c, prompt, cmd_command_prompt_callback,
|
|
||||||
cmd_command_prompt_cfree, cdata, 0);
|
|
||||||
xfree(prompt);
|
|
||||||
|
|
||||||
return (0);
|
/* Get initial prompt input. */
|
||||||
}
|
if ((inputs = args_get(args, 'I')) != NULL) {
|
||||||
|
cdata->inputs = xstrdup(inputs);
|
||||||
|
cdata->next_input = cdata->inputs;
|
||||||
|
input = strsep(&cdata->next_input, ",");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
status_prompt_set(c, prompt, input, cmd_command_prompt_callback,
|
||||||
cmd_command_prompt_free(struct cmd *self)
|
cmd_command_prompt_free, cdata, 0);
|
||||||
{
|
free(prompt);
|
||||||
struct cmd_command_prompt_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->prompts != NULL)
|
return (CMD_RETURN_NORMAL);
|
||||||
xfree(data->prompts);
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
if (data->template != NULL)
|
|
||||||
xfree(data->template);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_command_prompt_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_command_prompt_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->prompts != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -p ", data->prompts);
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->template != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->template);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -213,43 +148,40 @@ cmd_command_prompt_callback(void *data, const char *s)
|
|||||||
struct cmd_command_prompt_cdata *cdata = data;
|
struct cmd_command_prompt_cdata *cdata = data;
|
||||||
struct client *c = cdata->c;
|
struct client *c = cdata->c;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd_ctx ctx;
|
char *cause, *new_template, *prompt, *ptr;
|
||||||
char *cause, *newtempl, *prompt, *ptr;
|
char *input = NULL;
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
newtempl = cmd_template_replace(cdata->template, s, cdata->idx);
|
new_template = cmd_template_replace(cdata->template, s, cdata->idx);
|
||||||
xfree(cdata->template);
|
free(cdata->template);
|
||||||
cdata->template = newtempl;
|
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 ((ptr = strsep(&cdata->next_prompt, ",")) != NULL) {
|
||||||
xasprintf(&prompt, "%s ", ptr);
|
xasprintf(&prompt, "%s ", ptr);
|
||||||
status_prompt_update(c, prompt);
|
input = strsep(&cdata->next_input, ",");
|
||||||
xfree(prompt);
|
status_prompt_update(c, prompt, input);
|
||||||
|
|
||||||
|
free(prompt);
|
||||||
cdata->idx++;
|
cdata->idx++;
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd_string_parse(newtempl, &cmdlist, &cause) != 0) {
|
if (cmd_string_parse(new_template, &cmdlist, NULL, 0, &cause) != 0) {
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
*cause = toupper((u_char) *cause);
|
*cause = toupper((u_char) *cause);
|
||||||
status_message_set(c, "%s", cause);
|
status_message_set(c, "%s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
cmdq_run(c->cmdq, cmdlist);
|
||||||
ctx.curclient = c;
|
|
||||||
|
|
||||||
ctx.error = key_bindings_error;
|
|
||||||
ctx.print = key_bindings_print;
|
|
||||||
ctx.info = key_bindings_info;
|
|
||||||
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
|
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
|
|
||||||
if (c->prompt_callbackfn != (void *) &cmd_command_prompt_callback)
|
if (c->prompt_callbackfn != (void *) &cmd_command_prompt_callback)
|
||||||
@@ -258,13 +190,12 @@ cmd_command_prompt_callback(void *data, const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_command_prompt_cfree(void *data)
|
cmd_command_prompt_free(void *data)
|
||||||
{
|
{
|
||||||
struct cmd_command_prompt_cdata *cdata = data;
|
struct cmd_command_prompt_cdata *cdata = data;
|
||||||
|
|
||||||
if (cdata->prompts != NULL)
|
free(cdata->inputs);
|
||||||
xfree(cdata->prompts);
|
free(cdata->prompts);
|
||||||
if (cdata->template != NULL)
|
free(cdata->template);
|
||||||
xfree(cdata->template);
|
free(cdata);
|
||||||
xfree(cdata);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-confirm-before.c,v 1.12 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -25,112 +26,104 @@
|
|||||||
* Asks for confirmation before executing a command.
|
* Asks for confirmation before executing a command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_confirm_before_exec(struct cmd *, struct cmd_ctx *);
|
void cmd_confirm_before_key_binding(struct cmd *, int);
|
||||||
void cmd_confirm_before_init(struct cmd *, int);
|
enum cmd_retval cmd_confirm_before_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
int cmd_confirm_before_callback(void *, const char *);
|
int cmd_confirm_before_callback(void *, const char *);
|
||||||
void cmd_confirm_before_free(void *);
|
void cmd_confirm_before_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_confirm_before_entry = {
|
const struct cmd_entry cmd_confirm_before_entry = {
|
||||||
"confirm-before", "confirm",
|
"confirm-before", "confirm",
|
||||||
CMD_TARGET_CLIENT_USAGE " command",
|
"p:t:", 1, 1,
|
||||||
CMD_ARG1, "",
|
"[-p prompt] " CMD_TARGET_CLIENT_USAGE " command",
|
||||||
cmd_confirm_before_init,
|
0,
|
||||||
cmd_target_parse,
|
cmd_confirm_before_key_binding,
|
||||||
cmd_confirm_before_exec,
|
cmd_confirm_before_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_confirm_before_data {
|
struct cmd_confirm_before_data {
|
||||||
struct client *c;
|
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
struct client *client;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_confirm_before_init(struct cmd *self, int key)
|
cmd_confirm_before_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data;
|
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case '&':
|
case '&':
|
||||||
data->arg = xstrdup("kill-window");
|
self->args = args_create(1, "kill-window");
|
||||||
|
args_set(self->args, 'p', "kill-window #W? (y/n)");
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
data->arg = xstrdup("kill-pane");
|
self->args = args_create(1, "kill-pane");
|
||||||
|
args_set(self->args, 'p', "kill-pane #P? (y/n)");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
self->args = args_create(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct cmd_confirm_before_data *cdata;
|
struct cmd_confirm_before_data *cdata;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
char *buf, *cmd, *ptr;
|
char *cmd, *copy, *new_prompt, *ptr;
|
||||||
|
const char *prompt;
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
ctx->error(ctx, "must be run interactively");
|
return (CMD_RETURN_ERROR);
|
||||||
return (-1);
|
|
||||||
|
if ((prompt = args_get(args, 'p')) != NULL)
|
||||||
|
xasprintf(&new_prompt, "%s ", prompt);
|
||||||
|
else {
|
||||||
|
ptr = copy = xstrdup(args->argv[0]);
|
||||||
|
cmd = strsep(&ptr, " \t");
|
||||||
|
xasprintf(&new_prompt, "Confirm '%s'? (y/n) ", cmd);
|
||||||
|
free(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
ptr = xstrdup(data->arg);
|
|
||||||
if ((cmd = strtok(ptr, " \t")) == NULL)
|
|
||||||
cmd = ptr;
|
|
||||||
xasprintf(&buf, "Confirm '%s'? (y/n) ", cmd);
|
|
||||||
xfree(ptr);
|
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
cdata->cmd = xstrdup(data->arg);
|
cdata->cmd = xstrdup(args->argv[0]);
|
||||||
cdata->c = c;
|
|
||||||
status_prompt_set(cdata->c, buf,
|
cdata->client = c;
|
||||||
|
cdata->client->references++;
|
||||||
|
|
||||||
|
status_prompt_set(c, new_prompt, NULL,
|
||||||
cmd_confirm_before_callback, cmd_confirm_before_free, cdata,
|
cmd_confirm_before_callback, cmd_confirm_before_free, cdata,
|
||||||
PROMPT_SINGLE);
|
PROMPT_SINGLE);
|
||||||
|
|
||||||
xfree(buf);
|
free(new_prompt);
|
||||||
return (1);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_confirm_before_callback(void *data, const char *s)
|
cmd_confirm_before_callback(void *data, const char *s)
|
||||||
{
|
{
|
||||||
struct cmd_confirm_before_data *cdata = data;
|
struct cmd_confirm_before_data *cdata = data;
|
||||||
struct client *c = cdata->c;
|
struct client *c = cdata->client;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd_ctx ctx;
|
|
||||||
char *cause;
|
char *cause;
|
||||||
|
|
||||||
|
if (c->flags & CLIENT_DEAD)
|
||||||
|
return (0);
|
||||||
|
|
||||||
if (s == NULL || *s == '\0')
|
if (s == NULL || *s == '\0')
|
||||||
return (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);
|
return (0);
|
||||||
|
|
||||||
if (cmd_string_parse(cdata->cmd, &cmdlist, &cause) != 0) {
|
if (cmd_string_parse(cdata->cmd, &cmdlist, NULL, 0, &cause) != 0) {
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
*cause = toupper((u_char) *cause);
|
cmdq_error(c->cmdq, "%s", cause);
|
||||||
status_message_set(c, "%s", cause);
|
free(cause);
|
||||||
xfree(cause);
|
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.msgdata = NULL;
|
cmdq_run(c->cmdq, cmdlist);
|
||||||
ctx.curclient = c;
|
|
||||||
|
|
||||||
ctx.error = key_bindings_error;
|
|
||||||
ctx.print = key_bindings_print;
|
|
||||||
ctx.info = key_bindings_info;
|
|
||||||
|
|
||||||
ctx.cmdclient = NULL;
|
|
||||||
|
|
||||||
cmd_list_exec(cmdlist, &ctx);
|
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
@@ -140,8 +133,10 @@ void
|
|||||||
cmd_confirm_before_free(void *data)
|
cmd_confirm_before_free(void *data)
|
||||||
{
|
{
|
||||||
struct cmd_confirm_before_data *cdata = data;
|
struct cmd_confirm_before_data *cdata = data;
|
||||||
|
struct client *c = cdata->client;
|
||||||
|
|
||||||
if (cdata->cmd != NULL)
|
c->references--;
|
||||||
xfree(cdata->cmd);
|
|
||||||
xfree(cdata);
|
free(cdata->cmd);
|
||||||
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,205 +0,0 @@
|
|||||||
/* $Id: cmd-copy-buffer.c,v 1.7 2009-11-28 14:50:36 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copies a session paste buffer to another session.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_copy_buffer_parse(struct cmd *, int, char **, char **);
|
|
||||||
int cmd_copy_buffer_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_copy_buffer_free(struct cmd *);
|
|
||||||
void cmd_copy_buffer_init(struct cmd *, int);
|
|
||||||
size_t cmd_copy_buffer_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_copy_buffer_data {
|
|
||||||
char *dst_session;
|
|
||||||
char *src_session;
|
|
||||||
int dst_idx;
|
|
||||||
int src_idx;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_copy_buffer_entry = {
|
|
||||||
"copy-buffer", "copyb",
|
|
||||||
"[-a src-index] [-b dst-index] [-s src-session] [-t dst-session]",
|
|
||||||
0, "",
|
|
||||||
cmd_copy_buffer_init,
|
|
||||||
cmd_copy_buffer_parse,
|
|
||||||
cmd_copy_buffer_exec,
|
|
||||||
cmd_copy_buffer_free,
|
|
||||||
cmd_copy_buffer_print
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ARGSUSED */
|
|
||||||
void
|
|
||||||
cmd_copy_buffer_init(struct cmd *self, unused int arg)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->dst_session = NULL;
|
|
||||||
data->src_session = NULL;
|
|
||||||
data->dst_idx = -1;
|
|
||||||
data->src_idx = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_copy_buffer_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data;
|
|
||||||
const char *errstr;
|
|
||||||
int n, opt;
|
|
||||||
|
|
||||||
self->entry->init(self, KEYC_NONE);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "a:b:s:t:")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'a':
|
|
||||||
if (data->src_idx == -1) {
|
|
||||||
n = strtonum(optarg, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "buffer %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->src_idx = n;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'b':
|
|
||||||
if (data->dst_idx == -1) {
|
|
||||||
n = strtonum(optarg, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "buffer %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->dst_idx = n;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
if (data->src_session == NULL)
|
|
||||||
data->src_session = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->dst_session == NULL)
|
|
||||||
data->dst_session = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
error:
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_copy_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data = self->data;
|
|
||||||
struct paste_buffer *pb;
|
|
||||||
struct paste_stack *dst_ps, *src_ps;
|
|
||||||
u_char *pdata;
|
|
||||||
struct session *dst_session, *src_session;
|
|
||||||
u_int limit;
|
|
||||||
|
|
||||||
if ((dst_session = cmd_find_session(ctx, data->dst_session)) == NULL ||
|
|
||||||
(src_session = cmd_find_session(ctx, data->src_session)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
dst_ps = &dst_session->buffers;
|
|
||||||
src_ps = &src_session->buffers;
|
|
||||||
|
|
||||||
if (data->src_idx == -1) {
|
|
||||||
if ((pb = paste_get_top(src_ps)) == NULL) {
|
|
||||||
ctx->error(ctx, "no buffers");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((pb = paste_get_index(src_ps, data->src_idx)) == NULL) {
|
|
||||||
ctx->error(ctx, "no buffer %d", data->src_idx);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
limit = options_get_number(&dst_session->options, "buffer-limit");
|
|
||||||
|
|
||||||
pdata = xmalloc(pb->size);
|
|
||||||
memcpy(pdata, pb->data, pb->size);
|
|
||||||
|
|
||||||
if (data->dst_idx == -1)
|
|
||||||
paste_add(dst_ps, pdata, pb->size, limit);
|
|
||||||
else if (paste_replace(dst_ps, data->dst_idx, pdata, pb->size) != 0) {
|
|
||||||
ctx->error(ctx, "no buffer %d", data->dst_idx);
|
|
||||||
xfree(pdata);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_copy_buffer_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->dst_session != NULL)
|
|
||||||
xfree(data->dst_session);
|
|
||||||
if (data->src_session != NULL)
|
|
||||||
xfree(data->src_session);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_copy_buffer_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_copy_buffer_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->src_idx != -1) {
|
|
||||||
off += xsnprintf(buf + off, len - off, " -a %d",
|
|
||||||
data->src_idx);
|
|
||||||
}
|
|
||||||
if (off < len && data->dst_idx != -1) {
|
|
||||||
off += xsnprintf(buf + off, len - off, " -b %d",
|
|
||||||
data->dst_idx);
|
|
||||||
}
|
|
||||||
if (off < len && data->src_session != NULL) {
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -s ",
|
|
||||||
data->src_session);
|
|
||||||
}
|
|
||||||
if (off < len && data->dst_session != NULL) {
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ",
|
|
||||||
data->dst_session);
|
|
||||||
}
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-copy-mode.c,v 1.28 2010-08-11 22:18:28 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,49 +24,42 @@
|
|||||||
* Enter copy mode.
|
* Enter copy mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_copy_mode_init(struct cmd *, int);
|
void cmd_copy_mode_key_binding(struct cmd *, int);
|
||||||
int cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_copy_mode_entry = {
|
const struct cmd_entry cmd_copy_mode_entry = {
|
||||||
"copy-mode", NULL,
|
"copy-mode", NULL,
|
||||||
|
"t:u", 0, 0,
|
||||||
"[-u] " CMD_TARGET_PANE_USAGE,
|
"[-u] " CMD_TARGET_PANE_USAGE,
|
||||||
0, "u",
|
0,
|
||||||
cmd_copy_mode_init,
|
cmd_copy_mode_key_binding,
|
||||||
cmd_target_parse,
|
cmd_copy_mode_exec
|
||||||
cmd_copy_mode_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_copy_mode_init(struct cmd *self, int key)
|
cmd_copy_mode_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data;
|
self->args = args_create(0);
|
||||||
|
if (key == KEYC_PPAGE)
|
||||||
cmd_target_init(self, key);
|
args_set(self->args, 'u', NULL);
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
switch (key) {
|
|
||||||
case KEYC_PPAGE:
|
|
||||||
cmd_set_flag(&data->chflags, 'u');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
|
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
if (wp->mode != &window_copy_mode) {
|
||||||
return (0);
|
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
||||||
window_copy_init_from_pane(wp);
|
return (CMD_RETURN_NORMAL);
|
||||||
if (wp->mode == &window_copy_mode && cmd_check_flag(data->chflags, 'u'))
|
window_copy_init_from_pane(wp);
|
||||||
|
}
|
||||||
|
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
|
||||||
window_copy_pageup(wp);
|
window_copy_pageup(wp);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-delete-buffer.c,v 1.8 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,34 +26,40 @@
|
|||||||
* Delete a paste buffer.
|
* Delete a paste buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_delete_buffer_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_delete_buffer_entry = {
|
const struct cmd_entry cmd_delete_buffer_entry = {
|
||||||
"delete-buffer", "deleteb",
|
"delete-buffer", "deleteb",
|
||||||
CMD_BUFFER_SESSION_USAGE,
|
"b:", 0, 0,
|
||||||
0, "",
|
CMD_BUFFER_USAGE,
|
||||||
cmd_buffer_init,
|
0,
|
||||||
cmd_buffer_parse,
|
NULL,
|
||||||
cmd_delete_buffer_exec,
|
cmd_delete_buffer_exec
|
||||||
cmd_buffer_free,
|
|
||||||
cmd_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_delete_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
char *cause;
|
||||||
|
int buffer;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if (!args_has(args, 'b')) {
|
||||||
return (-1);
|
paste_free_top(&global_buffers);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
if (data->buffer == -1)
|
|
||||||
paste_free_top(&s->buffers);
|
|
||||||
else if (paste_free_index(&s->buffers, data->buffer) != 0) {
|
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(cmdq, "buffer %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paste_free_index(&global_buffers, buffer) != 0) {
|
||||||
|
cmdq_error(cmdq, "no buffer %d", buffer);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-detach-client.c,v 1.11 2010-02-08 18:27:34 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,35 +18,71 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Detach a client.
|
* Detach a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_detach_client_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_detach_client_entry = {
|
const struct cmd_entry cmd_detach_client_entry = {
|
||||||
"detach-client", "detach",
|
"detach-client", "detach",
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
"as:t:P", 0, 0,
|
||||||
CMD_READONLY, "",
|
"[-P] [-a] [-s target-session] " CMD_TARGET_CLIENT_USAGE,
|
||||||
cmd_target_init,
|
CMD_READONLY,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_detach_client_exec,
|
cmd_detach_client_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c, *c2;
|
||||||
|
struct session *s;
|
||||||
|
enum msgtype msgtype;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
if (args_has(args, 'P'))
|
||||||
return (-1);
|
msgtype = MSG_DETACHKILL;
|
||||||
|
else
|
||||||
|
msgtype = MSG_DETACH;
|
||||||
|
|
||||||
server_write_client(c, MSG_DETACH, NULL, 0);
|
if (args_has(args, 's')) {
|
||||||
|
s = cmd_find_session(cmdq, args_get(args, 's'), 0);
|
||||||
|
if (s == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
return (0);
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c == NULL || c->session != s)
|
||||||
|
continue;
|
||||||
|
server_write_client(c, msgtype, c->session->name,
|
||||||
|
strlen(c->session->name) + 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
c = cmd_find_client(cmdq, args_get(args, 't'), 0);
|
||||||
|
if (c == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if (args_has(args, 'a')) {
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c2 = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c2 == NULL || c2->session == NULL ||
|
||||||
|
c2 == c)
|
||||||
|
continue;
|
||||||
|
server_write_client(c2, msgtype,
|
||||||
|
c2->session->name,
|
||||||
|
strlen(c2->session->name) + 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
server_write_client(c, msgtype, c->session->name,
|
||||||
|
strlen(c->session->name) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CMD_RETURN_STOP);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-display-message.c,v 1.7 2009-11-28 14:39:53 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,41 +27,84 @@
|
|||||||
* Displays a message in the status line.
|
* Displays a message in the status line.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_display_message_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_display_message_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_display_message_entry = {
|
const struct cmd_entry cmd_display_message_entry = {
|
||||||
"display-message", "display",
|
"display-message", "display",
|
||||||
"[-p] " CMD_TARGET_CLIENT_USAGE " [message]",
|
"c:pt:F:", 0, 1,
|
||||||
CMD_ARG01, "p",
|
"[-p] [-c target-client] [-F format] " CMD_TARGET_PANE_USAGE
|
||||||
cmd_target_init,
|
" [message]",
|
||||||
cmd_target_parse,
|
0,
|
||||||
cmd_display_message_exec,
|
NULL,
|
||||||
cmd_target_free,
|
cmd_display_message_exec
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_display_message_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
struct session *s;
|
||||||
|
struct winlink *wl;
|
||||||
|
struct window_pane *wp;
|
||||||
const char *template;
|
const char *template;
|
||||||
char *msg;
|
char *msg;
|
||||||
|
struct format_tree *ft;
|
||||||
|
char out[BUFSIZ];
|
||||||
|
time_t t;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
if (args_has(args, 't')) {
|
||||||
return (-1);
|
wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
|
||||||
|
if (wl == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
} else {
|
||||||
|
wl = cmd_find_pane(cmdq, NULL, &s, &wp);
|
||||||
|
if (wl == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
if (data->arg == NULL)
|
if (args_has(args, 'F') && args->argc != 0) {
|
||||||
template = "[#S] #I:#W, current pane #P - (%H:%M %d-%b-%y)";
|
cmdq_error(cmdq, "only one of -F or argument must be given");
|
||||||
else
|
return (CMD_RETURN_ERROR);
|
||||||
template = data->arg;
|
}
|
||||||
|
|
||||||
msg = status_replace(c, NULL, template, time(NULL), 0);
|
if (args_has(args, 'c')) {
|
||||||
if (cmd_check_flag(data->chflags, 'p'))
|
c = cmd_find_client(cmdq, args_get(args, 'c'), 0);
|
||||||
ctx->print(ctx, "%s", msg);
|
if (c == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
} else {
|
||||||
|
c = cmd_current_client(cmdq);
|
||||||
|
if (c == NULL && !args_has(self->args, 'p')) {
|
||||||
|
cmdq_error(cmdq, "no client available");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template = args_get(args, 'F');
|
||||||
|
if (args->argc != 0)
|
||||||
|
template = args->argv[0];
|
||||||
|
if (template == NULL)
|
||||||
|
template = DISPLAY_MESSAGE_TEMPLATE;
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
if (c != NULL)
|
||||||
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, 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);
|
||||||
else
|
else
|
||||||
status_message_set(c, "%s", msg);
|
status_message_set(c, "%s", msg);
|
||||||
xfree(msg);
|
free(msg);
|
||||||
|
format_free(ft);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-display-panes.c,v 1.2 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,29 +24,27 @@
|
|||||||
* Display panes on a client.
|
* Display panes on a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_display_panes_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_display_panes_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_display_panes_entry = {
|
const struct cmd_entry cmd_display_panes_entry = {
|
||||||
"display-panes", "displayp",
|
"display-panes", "displayp",
|
||||||
|
"t:", 0, 0,
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
0, "",
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_display_panes_exec
|
||||||
cmd_display_panes_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_display_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_display_panes_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
server_set_identify(c);
|
server_set_identify(c);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-find-window.c,v 1.15 2010-12-22 15:28:50 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -27,93 +28,146 @@
|
|||||||
* Find window containing text.
|
* Find window containing text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_find_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
void cmd_find_window_callback(void *, int);
|
void cmd_find_window_callback(struct window_choose_data *);
|
||||||
void cmd_find_window_free(void *);
|
|
||||||
|
/* Flags for determining matching behavior. */
|
||||||
|
#define CMD_FIND_WINDOW_BY_TITLE 0x1
|
||||||
|
#define CMD_FIND_WINDOW_BY_CONTENT 0x2
|
||||||
|
#define CMD_FIND_WINDOW_BY_NAME 0x4
|
||||||
|
|
||||||
|
#define CMD_FIND_WINDOW_ALL \
|
||||||
|
(CMD_FIND_WINDOW_BY_TITLE | \
|
||||||
|
CMD_FIND_WINDOW_BY_CONTENT | \
|
||||||
|
CMD_FIND_WINDOW_BY_NAME)
|
||||||
|
|
||||||
const struct cmd_entry cmd_find_window_entry = {
|
const struct cmd_entry cmd_find_window_entry = {
|
||||||
"find-window", "findw",
|
"find-window", "findw",
|
||||||
CMD_TARGET_WINDOW_USAGE " match-string",
|
"F:CNt:T", 1, 4,
|
||||||
CMD_ARG1, "",
|
"[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string",
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_find_window_exec,
|
cmd_find_window_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_find_window_data {
|
struct cmd_find_window_data {
|
||||||
struct session *session;
|
struct winlink *wl;
|
||||||
|
char *list_ctx;
|
||||||
|
u_int pane_id;
|
||||||
};
|
};
|
||||||
|
ARRAY_DECL(cmd_find_window_data_list, struct cmd_find_window_data);
|
||||||
|
|
||||||
int
|
u_int cmd_find_window_match_flags(struct args *);
|
||||||
cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
void cmd_find_window_match(struct cmd_find_window_data_list *, int,
|
||||||
|
struct winlink *, const char *, const char *);
|
||||||
|
|
||||||
|
u_int
|
||||||
|
cmd_find_window_match_flags(struct args *args)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
u_int match_flags = 0;
|
||||||
struct cmd_find_window_data *cdata;
|
|
||||||
struct session *s;
|
/* Turn on flags based on the options. */
|
||||||
struct winlink *wl, *wm;
|
if (args_has(args, 'T'))
|
||||||
struct window *w;
|
match_flags |= CMD_FIND_WINDOW_BY_TITLE;
|
||||||
|
if (args_has(args, 'C'))
|
||||||
|
match_flags |= CMD_FIND_WINDOW_BY_CONTENT;
|
||||||
|
if (args_has(args, 'N'))
|
||||||
|
match_flags |= CMD_FIND_WINDOW_BY_NAME;
|
||||||
|
|
||||||
|
/* If none of the flags were set, default to matching anything. */
|
||||||
|
if (match_flags == 0)
|
||||||
|
match_flags = CMD_FIND_WINDOW_ALL;
|
||||||
|
|
||||||
|
return (match_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_find_window_match(struct cmd_find_window_data_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;
|
struct window_pane *wp;
|
||||||
ARRAY_DECL(, u_int) list_idx;
|
|
||||||
ARRAY_DECL(, char *) list_ctx;
|
|
||||||
char *sres, *sctx, *searchstr;
|
|
||||||
u_int i, line;
|
u_int i, line;
|
||||||
|
char *sres;
|
||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
memset(&find_data, 0, sizeof find_data);
|
||||||
ctx->error(ctx, "must be run interactively");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
s = ctx->curclient->session;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
i = 0;
|
||||||
return (-1);
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||||
|
i++;
|
||||||
|
|
||||||
ARRAY_INIT(&list_idx);
|
if ((match_flags & CMD_FIND_WINDOW_BY_NAME) &&
|
||||||
ARRAY_INIT(&list_ctx);
|
fnmatch(searchstr, wl->window->name, 0) == 0) {
|
||||||
|
find_data.list_ctx = xstrdup("");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
xasprintf(&searchstr, "*%s*", data->arg);
|
if ((match_flags & CMD_FIND_WINDOW_BY_TITLE) &&
|
||||||
RB_FOREACH(wm, winlinks, &s->windows) {
|
fnmatch(searchstr, wp->base.title, 0) == 0) {
|
||||||
i = 0;
|
xasprintf(&find_data.list_ctx,
|
||||||
TAILQ_FOREACH(wp, &wm->window->panes, entry) {
|
"pane %u title: \"%s\"", i - 1, wp->base.title);
|
||||||
i++;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (fnmatch(searchstr, wm->window->name, 0) == 0)
|
if (match_flags & CMD_FIND_WINDOW_BY_CONTENT &&
|
||||||
sctx = xstrdup("");
|
(sres = window_pane_search(wp, str, &line)) != NULL) {
|
||||||
else {
|
xasprintf(&find_data.list_ctx,
|
||||||
sres = window_pane_search(wp, data->arg, &line);
|
"pane %u line %u: \"%s\"", i - 1, line + 1, sres);
|
||||||
if (sres == NULL &&
|
free(sres);
|
||||||
fnmatch(searchstr, wp->base.title, 0) != 0)
|
break;
|
||||||
continue;
|
|
||||||
|
|
||||||
if (sres == NULL) {
|
|
||||||
xasprintf(&sctx,
|
|
||||||
"pane %u title: \"%s\"", i - 1,
|
|
||||||
wp->base.title);
|
|
||||||
} else {
|
|
||||||
xasprintf(&sctx,
|
|
||||||
"pane %u line %u: \"%s\"", i - 1,
|
|
||||||
line + 1, sres);
|
|
||||||
xfree(sres);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ARRAY_ADD(&list_idx, wm->idx);
|
|
||||||
ARRAY_ADD(&list_ctx, sctx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xfree(searchstr);
|
if (find_data.list_ctx != NULL) {
|
||||||
|
find_data.wl = wl;
|
||||||
|
find_data.pane_id = i - 1;
|
||||||
|
ARRAY_ADD(find_list, find_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ARRAY_LENGTH(&list_idx) == 0) {
|
enum cmd_retval
|
||||||
ctx->error(ctx, "no windows matching: %s", data->arg);
|
cmd_find_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
ARRAY_FREE(&list_idx);
|
{
|
||||||
ARRAY_FREE(&list_ctx);
|
struct args *args = self->args;
|
||||||
return (-1);
|
struct client *c;
|
||||||
|
struct window_choose_data *cdata;
|
||||||
|
struct session *s;
|
||||||
|
struct winlink *wl, *wm;
|
||||||
|
struct cmd_find_window_data_list find_list;
|
||||||
|
char *str, *searchstr;
|
||||||
|
const char *template;
|
||||||
|
u_int i, match_flags;
|
||||||
|
|
||||||
|
if ((c = cmd_current_client(cmdq)) == NULL) {
|
||||||
|
cmdq_error(cmdq, "no client available");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
s = c->session;
|
||||||
|
|
||||||
|
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = FIND_WINDOW_TEMPLATE;
|
||||||
|
|
||||||
|
match_flags = cmd_find_window_match_flags(args);
|
||||||
|
str = args->argv[0];
|
||||||
|
|
||||||
|
ARRAY_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 (ARRAY_LENGTH(&find_list) == 0) {
|
||||||
|
cmdq_error(cmdq, "no windows matching: %s", str);
|
||||||
|
ARRAY_FREE(&find_list);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ARRAY_LENGTH(&list_idx) == 1) {
|
if (ARRAY_LENGTH(&find_list) == 1) {
|
||||||
if (session_select(s, ARRAY_FIRST(&list_idx)) == 0)
|
if (session_select(s, ARRAY_FIRST(&find_list).wl->idx) == 0)
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
goto out;
|
goto out;
|
||||||
@@ -122,54 +176,52 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&list_idx); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&find_list); i++) {
|
||||||
wm = winlink_find_by_index(
|
wm = ARRAY_ITEM(&find_list, i).wl;
|
||||||
&s->windows, ARRAY_ITEM(&list_idx, i));
|
|
||||||
w = wm->window;
|
|
||||||
|
|
||||||
sctx = ARRAY_ITEM(&list_ctx, i);
|
cdata = window_choose_data_create(TREE_OTHER, c, c->session);
|
||||||
window_choose_add(wl->window->active,
|
cdata->idx = wm->idx;
|
||||||
wm->idx, "%3d: %s [%ux%u] (%u panes) %s", wm->idx, w->name,
|
cdata->wl = wm;
|
||||||
w->sx, w->sy, window_count_panes(w), sctx);
|
|
||||||
xfree(sctx);
|
cdata->ft_template = xstrdup(template);
|
||||||
|
cdata->pane_id = ARRAY_ITEM(&find_list, i).pane_id;
|
||||||
|
|
||||||
|
format_add(cdata->ft, "line", "%u", i);
|
||||||
|
format_add(cdata->ft, "window_find_matches", "%s",
|
||||||
|
ARRAY_ITEM(&find_list, i).list_ctx);
|
||||||
|
format_session(cdata->ft, s);
|
||||||
|
format_winlink(cdata->ft, s, wm);
|
||||||
|
format_window_pane(cdata->ft, wm->window->active);
|
||||||
|
|
||||||
|
window_choose_add(wl->window->active, cdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
window_choose_ready(wl->window->active, 0, cmd_find_window_callback);
|
||||||
cdata->session = s;
|
|
||||||
cdata->session->references++;
|
|
||||||
|
|
||||||
window_choose_ready(wl->window->active,
|
|
||||||
0, cmd_find_window_callback, cmd_find_window_free, cdata);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
ARRAY_FREE(&list_idx);
|
ARRAY_FREE(&find_list);
|
||||||
ARRAY_FREE(&list_ctx);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_find_window_callback(void *data, int idx)
|
cmd_find_window_callback(struct window_choose_data *cdata)
|
||||||
{
|
{
|
||||||
struct cmd_find_window_data *cdata = data;
|
struct session *s;
|
||||||
struct session *s = cdata->session;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if (idx == -1)
|
if (cdata == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
s = cdata->start_session;
|
||||||
if (!session_alive(s))
|
if (!session_alive(s))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (session_select(s, idx) == 0) {
|
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);
|
server_redraw_session(s);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
cmd_find_window_free(void *data)
|
|
||||||
{
|
|
||||||
struct cmd_find_window_data *cdata = data;
|
|
||||||
|
|
||||||
cdata->session->references--;
|
|
||||||
xfree(cdata);
|
|
||||||
}
|
|
||||||
|
|||||||
423
cmd-generic.c
423
cmd-generic.c
@@ -1,423 +0,0 @@
|
|||||||
/* $Id: cmd-generic.c,v 1.38 2009-12-04 22:14:47 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
int cmd_getopt(int, char **, const char *, const char *);
|
|
||||||
int cmd_parse_flags(int, const char *, uint64_t *);
|
|
||||||
size_t cmd_print_flags(char *, size_t, size_t, uint64_t);
|
|
||||||
int cmd_fill_argument(int, char **, char **, int, char **);
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_prarg(char *buf, size_t len, const char *prefix, char *arg)
|
|
||||||
{
|
|
||||||
if (strchr(arg, ' ') != NULL)
|
|
||||||
return (xsnprintf(buf, len, "%s\"%s\"", prefix, arg));
|
|
||||||
return (xsnprintf(buf, len, "%s%s", prefix, arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Append two flag strings together and call getopt. */
|
|
||||||
int
|
|
||||||
cmd_getopt(int argc, char **argv, const char *flagstr, const char *chflagstr)
|
|
||||||
{
|
|
||||||
char tmp[BUFSIZ];
|
|
||||||
|
|
||||||
if (strlcpy(tmp, flagstr, sizeof tmp) >= sizeof tmp)
|
|
||||||
fatalx("strlcpy overflow");
|
|
||||||
if (strlcat(tmp, chflagstr, sizeof tmp) >= sizeof tmp)
|
|
||||||
fatalx("strlcat overflow");
|
|
||||||
return (getopt(argc, argv, tmp));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return if flag character is set. */
|
|
||||||
int
|
|
||||||
cmd_check_flag(uint64_t chflags, int flag)
|
|
||||||
{
|
|
||||||
if (flag >= 'A' && flag <= 'Z')
|
|
||||||
flag = 26 + flag - 'A';
|
|
||||||
else if (flag >= 'a' && flag <= 'z')
|
|
||||||
flag = flag - 'a';
|
|
||||||
else
|
|
||||||
return (0);
|
|
||||||
return ((chflags & (1ULL << flag)) != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set flag character. */
|
|
||||||
void
|
|
||||||
cmd_set_flag(uint64_t *chflags, int flag)
|
|
||||||
{
|
|
||||||
if (flag >= 'A' && flag <= 'Z')
|
|
||||||
flag = 26 + flag - 'A';
|
|
||||||
else if (flag >= 'a' && flag <= 'z')
|
|
||||||
flag = flag - 'a';
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
(*chflags) |= (1ULL << flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If this option is expected, set it in chflags, otherwise return -1. */
|
|
||||||
int
|
|
||||||
cmd_parse_flags(int opt, const char *chflagstr, uint64_t *chflags)
|
|
||||||
{
|
|
||||||
if (strchr(chflagstr, opt) == NULL)
|
|
||||||
return (-1);
|
|
||||||
cmd_set_flag(chflags, opt);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Print the flags present in chflags. */
|
|
||||||
size_t
|
|
||||||
cmd_print_flags(char *buf, size_t len, size_t off, uint64_t chflags)
|
|
||||||
{
|
|
||||||
u_char ch;
|
|
||||||
size_t boff = off;
|
|
||||||
|
|
||||||
if (chflags == 0)
|
|
||||||
return (0);
|
|
||||||
off += xsnprintf(buf + off, len - off, " -");
|
|
||||||
|
|
||||||
for (ch = 0; ch < 26; ch++) {
|
|
||||||
if (cmd_check_flag(chflags, 'a' + ch))
|
|
||||||
off += xsnprintf(buf + off, len - off, "%c", 'a' + ch);
|
|
||||||
if (cmd_check_flag(chflags, 'A' + ch))
|
|
||||||
off += xsnprintf(buf + off, len - off, "%c", 'A' + ch);
|
|
||||||
}
|
|
||||||
return (off - boff);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_fill_argument(int flags, char **arg, char **arg2, int argc, char **argv)
|
|
||||||
{
|
|
||||||
*arg = NULL;
|
|
||||||
*arg2 = NULL;
|
|
||||||
|
|
||||||
if (flags & CMD_ARG1) {
|
|
||||||
if (argc != 1)
|
|
||||||
return (-1);
|
|
||||||
*arg = xstrdup(argv[0]);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & CMD_ARG01) {
|
|
||||||
if (argc != 0 && argc != 1)
|
|
||||||
return (-1);
|
|
||||||
if (argc == 1)
|
|
||||||
*arg = xstrdup(argv[0]);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & CMD_ARG2) {
|
|
||||||
if (argc != 2)
|
|
||||||
return (-1);
|
|
||||||
*arg = xstrdup(argv[0]);
|
|
||||||
*arg2 = xstrdup(argv[1]);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & CMD_ARG12) {
|
|
||||||
if (argc != 1 && argc != 2)
|
|
||||||
return (-1);
|
|
||||||
*arg = xstrdup(argv[0]);
|
|
||||||
if (argc == 2)
|
|
||||||
*arg2 = xstrdup(argv[1]);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc != 0)
|
|
||||||
return (-1);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ARGSUSED */
|
|
||||||
void
|
|
||||||
cmd_target_init(struct cmd *self, unused int key)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->chflags = 0;
|
|
||||||
data->target = NULL;
|
|
||||||
data->arg = NULL;
|
|
||||||
data->arg2 = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_target_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data;
|
|
||||||
const struct cmd_entry *entry = self->entry;
|
|
||||||
int opt;
|
|
||||||
|
|
||||||
/* Don't use the entry version since it may be dependent on key. */
|
|
||||||
cmd_target_init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = cmd_getopt(argc, argv, "t:", entry->chflags)) != -1) {
|
|
||||||
if (cmd_parse_flags(opt, entry->chflags, &data->chflags) == 0)
|
|
||||||
continue;
|
|
||||||
switch (opt) {
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (cmd_fill_argument(
|
|
||||||
self->entry->flags, &data->arg, &data->arg2, argc, argv) != 0)
|
|
||||||
goto usage;
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_target_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
if (data->arg != NULL)
|
|
||||||
xfree(data->arg);
|
|
||||||
if (data->arg2 != NULL)
|
|
||||||
xfree(data->arg2);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_target_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
off += cmd_print_flags(buf, len, off, data->chflags);
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->arg != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
|
||||||
if (off < len && data->arg2 != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg2);
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ARGSUSED */
|
|
||||||
void
|
|
||||||
cmd_srcdst_init(struct cmd *self, unused int key)
|
|
||||||
{
|
|
||||||
struct cmd_srcdst_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->chflags = 0;
|
|
||||||
data->src = NULL;
|
|
||||||
data->dst = NULL;
|
|
||||||
data->arg = NULL;
|
|
||||||
data->arg2 = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_srcdst_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_srcdst_data *data;
|
|
||||||
const struct cmd_entry *entry = self->entry;
|
|
||||||
int opt;
|
|
||||||
|
|
||||||
cmd_srcdst_init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = cmd_getopt(argc, argv, "s:t:", entry->chflags)) != -1) {
|
|
||||||
if (cmd_parse_flags(opt, entry->chflags, &data->chflags) == 0)
|
|
||||||
continue;
|
|
||||||
switch (opt) {
|
|
||||||
case 's':
|
|
||||||
if (data->src == NULL)
|
|
||||||
data->src = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->dst == NULL)
|
|
||||||
data->dst = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (cmd_fill_argument(
|
|
||||||
self->entry->flags, &data->arg, &data->arg2, argc, argv) != 0)
|
|
||||||
goto usage;
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_srcdst_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_srcdst_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->src != NULL)
|
|
||||||
xfree(data->src);
|
|
||||||
if (data->dst != NULL)
|
|
||||||
xfree(data->dst);
|
|
||||||
if (data->arg != NULL)
|
|
||||||
xfree(data->arg);
|
|
||||||
if (data->arg2 != NULL)
|
|
||||||
xfree(data->arg2);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_srcdst_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_srcdst_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
off += cmd_print_flags(buf, len, off, data->chflags);
|
|
||||||
if (off < len && data->src != NULL)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -s %s", data->src);
|
|
||||||
if (off < len && data->dst != NULL)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -t %s", data->dst);
|
|
||||||
if (off < len && data->arg != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
|
||||||
if (off < len && data->arg2 != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg2);
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ARGSUSED */
|
|
||||||
void
|
|
||||||
cmd_buffer_init(struct cmd *self, unused int key)
|
|
||||||
{
|
|
||||||
struct cmd_buffer_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->chflags = 0;
|
|
||||||
data->target = NULL;
|
|
||||||
data->buffer = -1;
|
|
||||||
data->arg = NULL;
|
|
||||||
data->arg2 = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_buffer_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_buffer_data *data;
|
|
||||||
const struct cmd_entry *entry = self->entry;
|
|
||||||
int opt, n;
|
|
||||||
const char *errstr;
|
|
||||||
|
|
||||||
cmd_buffer_init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = cmd_getopt(argc, argv, "b:t:", entry->chflags)) != -1) {
|
|
||||||
if (cmd_parse_flags(opt, entry->chflags, &data->chflags) == 0)
|
|
||||||
continue;
|
|
||||||
switch (opt) {
|
|
||||||
case 'b':
|
|
||||||
if (data->buffer == -1) {
|
|
||||||
n = strtonum(optarg, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "buffer %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->buffer = n;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (cmd_fill_argument(
|
|
||||||
self->entry->flags, &data->arg, &data->arg2, argc, argv) != 0)
|
|
||||||
goto usage;
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
error:
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_buffer_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_buffer_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
if (data->arg != NULL)
|
|
||||||
xfree(data->arg);
|
|
||||||
if (data->arg2 != NULL)
|
|
||||||
xfree(data->arg2);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_buffer_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_buffer_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
off += cmd_print_flags(buf, len, off, data->chflags);
|
|
||||||
if (off < len && data->buffer != -1)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -b %d", data->buffer);
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->arg != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg);
|
|
||||||
if (off < len && data->arg2 != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->arg2);
|
|
||||||
return (off);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-has-session.c,v 1.15 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,26 +24,24 @@
|
|||||||
* Cause client to report an error and exit with 1 if session doesn't exist.
|
* Cause client to report an error and exit with 1 if session doesn't exist.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_has_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_has_session_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_has_session_entry = {
|
const struct cmd_entry cmd_has_session_entry = {
|
||||||
"has-session", "has",
|
"has-session", "has",
|
||||||
|
"t:", 0, 0,
|
||||||
CMD_TARGET_SESSION_USAGE,
|
CMD_TARGET_SESSION_USAGE,
|
||||||
0, "",
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_has_session_exec
|
||||||
cmd_has_session_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_has_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_has_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
|
|
||||||
if (cmd_find_session(ctx, data->target) == NULL)
|
if (cmd_find_session(cmdq, args_get(args, 't'), 0) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
153
cmd-if-shell.c
153
cmd-if-shell.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-if-shell.c,v 1.10 2010-08-09 21:44:25 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -20,100 +20,159 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Executes a tmux command if a shell command returns true.
|
* Executes a tmux command if a shell command returns true or false.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_if_shell_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_if_shell_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
void cmd_if_shell_callback(struct job *);
|
void cmd_if_shell_callback(struct job *);
|
||||||
|
void cmd_if_shell_done(struct cmd_q *);
|
||||||
void cmd_if_shell_free(void *);
|
void cmd_if_shell_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_if_shell_entry = {
|
const struct cmd_entry cmd_if_shell_entry = {
|
||||||
"if-shell", "if",
|
"if-shell", "if",
|
||||||
"shell-command command",
|
"bt:", 2, 3,
|
||||||
CMD_ARG2, "",
|
"[-b] " CMD_TARGET_PANE_USAGE " shell-command command [command]",
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_if_shell_exec,
|
cmd_if_shell_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_if_shell_data {
|
struct cmd_if_shell_data {
|
||||||
char *cmd;
|
char *cmd_if;
|
||||||
struct cmd_ctx ctx;
|
char *cmd_else;
|
||||||
|
struct cmd_q *cmdq;
|
||||||
|
int bflag;
|
||||||
|
int started;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct cmd_if_shell_data *cdata;
|
struct cmd_if_shell_data *cdata;
|
||||||
struct job *job;
|
char *shellcmd;
|
||||||
|
struct client *c;
|
||||||
|
struct session *s = NULL;
|
||||||
|
struct winlink *wl = NULL;
|
||||||
|
struct window_pane *wp = NULL;
|
||||||
|
struct format_tree *ft;
|
||||||
|
|
||||||
|
if (args_has(args, 't'))
|
||||||
|
wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
|
||||||
|
else {
|
||||||
|
c = cmd_find_client(cmdq, NULL, 1);
|
||||||
|
if (c != NULL && c->session != NULL) {
|
||||||
|
s = c->session;
|
||||||
|
wl = s->curw;
|
||||||
|
wp = wl->window->active;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
if (s != NULL)
|
||||||
|
format_session(ft, s);
|
||||||
|
if (s != NULL && wl != NULL)
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
if (wp != NULL)
|
||||||
|
format_window_pane(ft, wp);
|
||||||
|
shellcmd = format_expand(ft, args->argv[0]);
|
||||||
|
format_free(ft);
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
cdata->cmd = xstrdup(data->arg2);
|
cdata->cmd_if = xstrdup(args->argv[1]);
|
||||||
memcpy(&cdata->ctx, ctx, sizeof cdata->ctx);
|
if (args->argc == 3)
|
||||||
|
cdata->cmd_else = xstrdup(args->argv[2]);
|
||||||
|
else
|
||||||
|
cdata->cmd_else = NULL;
|
||||||
|
cdata->bflag = args_has(args, 'b');
|
||||||
|
|
||||||
if (ctx->cmdclient != NULL)
|
cdata->started = 0;
|
||||||
ctx->cmdclient->references++;
|
cdata->cmdq = cmdq;
|
||||||
if (ctx->curclient != NULL)
|
cmdq->references++;
|
||||||
ctx->curclient->references++;
|
|
||||||
|
|
||||||
job = job_add(NULL, 0, NULL,
|
job_run(shellcmd, s, cmd_if_shell_callback, cmd_if_shell_free, cdata);
|
||||||
data->arg, cmd_if_shell_callback, cmd_if_shell_free, cdata);
|
free(shellcmd);
|
||||||
job_run(job);
|
|
||||||
|
|
||||||
return (1); /* don't let client exit */
|
if (cdata->bflag)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
return (CMD_RETURN_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_if_shell_callback(struct job *job)
|
cmd_if_shell_callback(struct job *job)
|
||||||
{
|
{
|
||||||
struct cmd_if_shell_data *cdata = job->data;
|
struct cmd_if_shell_data *cdata = job->data;
|
||||||
struct cmd_ctx *ctx = &cdata->ctx;
|
struct cmd_q *cmdq = cdata->cmdq, *cmdq1;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
char *cause;
|
char *cause, *cmd;
|
||||||
|
|
||||||
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0)
|
if (cmdq->dead)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cmd_string_parse(cdata->cmd, &cmdlist, &cause) != 0) {
|
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0)
|
||||||
|
cmd = cdata->cmd_else;
|
||||||
|
else
|
||||||
|
cmd = cdata->cmd_if;
|
||||||
|
if (cmd == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cmd_string_parse(cmd, &cmdlist, NULL, 0, &cause) != 0) {
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "%s", cause);
|
cmdq_error(cmdq, "%s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd_list_exec(cmdlist, ctx) < 0) {
|
cdata->started = 1;
|
||||||
cmd_list_free(cmdlist);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
cmdq1 = cmdq_new(cmdq->client);
|
||||||
|
cmdq1->emptyfn = cmd_if_shell_done;
|
||||||
|
cmdq1->data = cdata;
|
||||||
|
|
||||||
|
cmdq_run(cmdq1, cmdlist);
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (!cmdq_free(cmdq) && !cdata->bflag)
|
||||||
|
cmdq_continue(cmdq);
|
||||||
|
|
||||||
|
cmdq_free(cmdq1);
|
||||||
|
|
||||||
|
free(cdata->cmd_else);
|
||||||
|
free(cdata->cmd_if);
|
||||||
|
free(cdata);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_if_shell_free(void *data)
|
cmd_if_shell_free(void *data)
|
||||||
{
|
{
|
||||||
struct cmd_if_shell_data *cdata = data;
|
struct cmd_if_shell_data *cdata = data;
|
||||||
struct cmd_ctx *ctx = &cdata->ctx;
|
struct cmd_q *cmdq = cdata->cmdq;
|
||||||
struct msg_exit_data exitdata;
|
|
||||||
|
|
||||||
if (ctx->cmdclient != NULL) {
|
if (cdata->started)
|
||||||
ctx->cmdclient->references--;
|
return;
|
||||||
exitdata.retcode = ctx->cmdclient->retcode;
|
|
||||||
ctx->cmdclient->flags |= CLIENT_EXIT;
|
|
||||||
}
|
|
||||||
if (ctx->curclient != NULL)
|
|
||||||
ctx->curclient->references--;
|
|
||||||
|
|
||||||
xfree(cdata->cmd);
|
if (!cmdq_free(cmdq) && !cdata->bflag)
|
||||||
xfree(cdata);
|
cmdq_continue(cmdq);
|
||||||
|
|
||||||
|
free(cdata->cmd_else);
|
||||||
|
free(cdata->cmd_if);
|
||||||
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
246
cmd-join-pane.c
246
cmd-join-pane.c
@@ -1,6 +1,7 @@
|
|||||||
/* $Id: cmd-join-pane.c,v 1.5 2010-08-11 22:17:32 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
* Copyright (c) 2011 George Nachman <tmux@georgester.com>
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
@@ -24,167 +25,115 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Join a pane into another (like split/swap/kill).
|
* Join or move a pane into another (like split/swap/kill).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_join_pane_parse(struct cmd *, int, char **, char **);
|
void cmd_join_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_join_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmd_q *);
|
||||||
void cmd_join_pane_free(struct cmd *);
|
|
||||||
void cmd_join_pane_init(struct cmd *, int);
|
|
||||||
size_t cmd_join_pane_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_join_pane_data {
|
enum cmd_retval join_pane(struct cmd *, struct cmd_q *, int);
|
||||||
char *src;
|
|
||||||
char *dst;
|
|
||||||
int flag_detached;
|
|
||||||
int flag_horizontal;
|
|
||||||
int percentage;
|
|
||||||
int size;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_join_pane_entry = {
|
const struct cmd_entry cmd_join_pane_entry = {
|
||||||
"join-pane", "joinp",
|
"join-pane", "joinp",
|
||||||
"[-dhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
"bdhvp:l:s:t:", 0, 0,
|
||||||
0, "",
|
"[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
||||||
cmd_join_pane_init,
|
0,
|
||||||
cmd_join_pane_parse,
|
cmd_join_pane_key_binding,
|
||||||
cmd_join_pane_exec,
|
cmd_join_pane_exec
|
||||||
cmd_join_pane_free,
|
};
|
||||||
cmd_join_pane_print
|
|
||||||
|
const struct cmd_entry cmd_move_pane_entry = {
|
||||||
|
"move-pane", "movep",
|
||||||
|
"bdhvp:l:s:t:", 0, 0,
|
||||||
|
"[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
cmd_join_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_join_pane_init(struct cmd *self, int key)
|
cmd_join_pane_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_join_pane_data *data;
|
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->src = NULL;
|
|
||||||
data->dst = NULL;
|
|
||||||
data->flag_detached = 0;
|
|
||||||
data->flag_horizontal = 0;
|
|
||||||
data->percentage = -1;
|
|
||||||
data->size = -1;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case '%':
|
case '%':
|
||||||
data->flag_horizontal = 1;
|
self->args = args_create(0);
|
||||||
|
args_set(self->args, 'h', NULL);
|
||||||
break;
|
break;
|
||||||
case '"':
|
default:
|
||||||
data->flag_horizontal = 0;
|
self->args = args_create(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_join_pane_parse(struct cmd *self, int argc, char **argv, char **cause)
|
cmd_join_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_join_pane_data *data;
|
return (join_pane(self, cmdq, self->entry == &cmd_join_pane_entry));
|
||||||
int opt;
|
|
||||||
const char *errstr;
|
|
||||||
|
|
||||||
self->entry->init(self, KEYC_NONE);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "dhl:p:s:t:v")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'd':
|
|
||||||
data->flag_detached = 1;
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
data->flag_horizontal = 1;
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
if (data->src == NULL)
|
|
||||||
data->src = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->dst == NULL)
|
|
||||||
data->dst = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
if (data->percentage != -1 || data->size != -1)
|
|
||||||
break;
|
|
||||||
data->size = strtonum(optarg, 1, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "size %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
if (data->size != -1 || data->percentage != -1)
|
|
||||||
break;
|
|
||||||
data->percentage = strtonum(optarg, 1, 100, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "percentage %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
data->flag_horizontal = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 0)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
error:
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
|
||||||
{
|
{
|
||||||
struct cmd_join_pane_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *dst_s;
|
struct session *dst_s;
|
||||||
struct winlink *src_wl, *dst_wl;
|
struct winlink *src_wl, *dst_wl;
|
||||||
struct window *src_w, *dst_w;
|
struct window *src_w, *dst_w;
|
||||||
struct window_pane *src_wp, *dst_wp;
|
struct window_pane *src_wp, *dst_wp;
|
||||||
int size, dst_idx;
|
char *cause;
|
||||||
enum layout_type type;
|
int size, percentage, dst_idx;
|
||||||
struct layout_cell *lc;
|
enum layout_type type;
|
||||||
|
struct layout_cell *lc;
|
||||||
|
|
||||||
if ((dst_wl = cmd_find_pane(ctx, data->dst, &dst_s, &dst_wp)) == NULL)
|
dst_wl = cmd_find_pane(cmdq, args_get(args, 't'), &dst_s, &dst_wp);
|
||||||
return (-1);
|
if (dst_wl == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
dst_w = dst_wl->window;
|
dst_w = dst_wl->window;
|
||||||
dst_idx = dst_wl->idx;
|
dst_idx = dst_wl->idx;
|
||||||
|
server_unzoom_window(dst_w);
|
||||||
|
|
||||||
if ((src_wl = cmd_find_pane(ctx, data->src, NULL, &src_wp)) == NULL)
|
src_wl = cmd_find_pane(cmdq, args_get(args, 's'), NULL, &src_wp);
|
||||||
return (-1);
|
if (src_wl == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
src_w = src_wl->window;
|
src_w = src_wl->window;
|
||||||
|
server_unzoom_window(src_w);
|
||||||
|
|
||||||
if (src_w == dst_w) {
|
if (not_same_window && src_w == dst_w) {
|
||||||
ctx->error(ctx, "can't join a pane to its own window");
|
cmdq_error(cmdq, "can't join a pane to its own window");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (!not_same_window && src_wp == dst_wp) {
|
||||||
|
cmdq_error(cmdq, "source and target panes must be different");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
type = LAYOUT_TOPBOTTOM;
|
type = LAYOUT_TOPBOTTOM;
|
||||||
if (data->flag_horizontal)
|
if (args_has(args, 'h'))
|
||||||
type = LAYOUT_LEFTRIGHT;
|
type = LAYOUT_LEFTRIGHT;
|
||||||
|
|
||||||
size = -1;
|
size = -1;
|
||||||
if (data->size != -1)
|
if (args_has(args, 'l')) {
|
||||||
size = data->size;
|
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
||||||
else if (data->percentage != -1) {
|
if (cause != NULL) {
|
||||||
|
cmdq_error(cmdq, "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);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
if (type == LAYOUT_TOPBOTTOM)
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
size = (dst_wp->sy * data->percentage) / 100;
|
size = (dst_wp->sy * percentage) / 100;
|
||||||
else
|
else
|
||||||
size = (dst_wp->sx * data->percentage) / 100;
|
size = (dst_wp->sx * percentage) / 100;
|
||||||
}
|
}
|
||||||
|
lc = layout_split_pane(dst_wp, type, size, args_has(args, 'b'));
|
||||||
if ((lc = layout_split_pane(dst_wp, type, size)) == NULL) {
|
if (lc == NULL) {
|
||||||
ctx->error(ctx, "create pane failed: pane too small");
|
cmdq_error(cmdq, "create pane failed: pane too small");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout_close_pane(src_wp);
|
layout_close_pane(src_wp);
|
||||||
@@ -198,6 +147,8 @@ cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (window_count_panes(src_w) == 0)
|
if (window_count_panes(src_w) == 0)
|
||||||
server_kill_window(src_w);
|
server_kill_window(src_w);
|
||||||
|
else
|
||||||
|
notify_window_layout_changed(src_w);
|
||||||
|
|
||||||
src_wp->window = dst_w;
|
src_wp->window = dst_w;
|
||||||
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
||||||
@@ -208,50 +159,13 @@ cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_window(src_w);
|
server_redraw_window(src_w);
|
||||||
server_redraw_window(dst_w);
|
server_redraw_window(dst_w);
|
||||||
|
|
||||||
if (!data->flag_detached) {
|
if (!args_has(args, 'd')) {
|
||||||
window_set_active_pane(dst_w, src_wp);
|
window_set_active_pane(dst_w, src_wp);
|
||||||
session_select(dst_s, dst_idx);
|
session_select(dst_s, dst_idx);
|
||||||
server_redraw_session(dst_s);
|
server_redraw_session(dst_s);
|
||||||
} else
|
} else
|
||||||
server_status_session(dst_s);
|
server_status_session(dst_s);
|
||||||
|
|
||||||
return (0);
|
notify_window_layout_changed(dst_w);
|
||||||
}
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
void
|
|
||||||
cmd_join_pane_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_join_pane_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->src != NULL)
|
|
||||||
xfree(data->src);
|
|
||||||
if (data->dst != NULL)
|
|
||||||
xfree(data->dst);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_join_pane_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_join_pane_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->flag_detached)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -d");
|
|
||||||
if (off < len && data->flag_horizontal)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -h");
|
|
||||||
if (off < len && data->size > 0)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -l %d", data->size);
|
|
||||||
if (off < len && data->percentage > 0) {
|
|
||||||
off += xsnprintf(
|
|
||||||
buf + off, len - off, " -p %d", data->percentage);
|
|
||||||
}
|
|
||||||
if (off < len && data->src != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -s ", data->src);
|
|
||||||
if (off < len && data->dst != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->dst);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-kill-pane.c,v 1.15 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,45 +26,41 @@
|
|||||||
* Kill pane.
|
* Kill pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_pane_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_pane_entry = {
|
const struct cmd_entry cmd_kill_pane_entry = {
|
||||||
"kill-pane", "killp",
|
"kill-pane", "killp",
|
||||||
|
"at:", 0, 0,
|
||||||
"[-a] " CMD_TARGET_PANE_USAGE,
|
"[-a] " CMD_TARGET_PANE_USAGE,
|
||||||
0, "a",
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_kill_pane_exec
|
||||||
cmd_kill_pane_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window_pane *loopwp, *nextwp, *wp;
|
struct window_pane *loopwp, *tmpwp, *wp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, data->target, NULL, &wp)) == NULL)
|
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
server_unzoom_window(wl->window);
|
||||||
|
|
||||||
if (window_count_panes(wl->window) == 1) {
|
if (window_count_panes(wl->window) == 1) {
|
||||||
/* Only one pane, kill the window. */
|
/* Only one pane, kill the window. */
|
||||||
server_kill_window(wl->window);
|
server_kill_window(wl->window);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'a')) {
|
if (args_has(self->args, 'a')) {
|
||||||
loopwp = TAILQ_FIRST(&wl->window->panes);
|
TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) {
|
||||||
while (loopwp != NULL) {
|
if (loopwp == wp)
|
||||||
nextwp = TAILQ_NEXT(loopwp, entry);
|
continue;
|
||||||
if (loopwp != wp) {
|
layout_close_pane(loopwp);
|
||||||
layout_close_pane(loopwp);
|
window_remove_pane(wl->window, loopwp);
|
||||||
window_remove_pane(wl->window, loopwp);
|
|
||||||
}
|
|
||||||
loopwp = nextwp;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
layout_close_pane(wp);
|
layout_close_pane(wp);
|
||||||
@@ -72,5 +68,5 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-kill-server.c,v 1.11 2009-11-28 14:50:36 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -27,24 +27,31 @@
|
|||||||
* Kill the server and do nothing else.
|
* Kill the server and do nothing else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_server_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_server_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_server_entry = {
|
const struct cmd_entry cmd_kill_server_entry = {
|
||||||
"kill-server", NULL,
|
"kill-server", NULL,
|
||||||
|
"", 0, 0,
|
||||||
"",
|
"",
|
||||||
0, "",
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
cmd_kill_server_exec
|
||||||
cmd_kill_server_exec,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
const struct cmd_entry cmd_start_server_entry = {
|
||||||
int
|
"start-server", "start",
|
||||||
cmd_kill_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
"", 0, 0,
|
||||||
{
|
"",
|
||||||
kill(getpid(), SIGTERM);
|
CMD_STARTSERVER,
|
||||||
|
NULL,
|
||||||
|
cmd_kill_server_exec
|
||||||
|
};
|
||||||
|
|
||||||
return (0);
|
enum cmd_retval
|
||||||
|
cmd_kill_server_exec(struct cmd *self, unused struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
if (self->entry == &cmd_kill_server_entry)
|
||||||
|
kill(getpid(), SIGTERM);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-kill-session.c,v 1.18 2010-07-02 02:43:50 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -27,30 +27,36 @@
|
|||||||
* Note this deliberately has no alias to make it hard to hit by accident.
|
* Note this deliberately has no alias to make it hard to hit by accident.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_session_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_session_entry = {
|
const struct cmd_entry cmd_kill_session_entry = {
|
||||||
"kill-session", NULL,
|
"kill-session", NULL,
|
||||||
CMD_TARGET_SESSION_USAGE,
|
"at:", 0, 0,
|
||||||
0, "",
|
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_kill_session_exec,
|
cmd_kill_session_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_kill_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s, *s2, *s3;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
server_destroy_session(s);
|
if (args_has(args, 'a')) {
|
||||||
session_destroy(s);
|
RB_FOREACH_SAFE(s2, sessions, &sessions, s3) {
|
||||||
|
if (s != s2) {
|
||||||
return (0);
|
server_destroy_session(s2);
|
||||||
|
session_destroy(s2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
server_destroy_session(s);
|
||||||
|
session_destroy(s);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-kill-window.c,v 1.21 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,30 +24,35 @@
|
|||||||
* Destroy window.
|
* Destroy window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_window_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_window_entry = {
|
const struct cmd_entry cmd_kill_window_entry = {
|
||||||
"kill-window", "killw",
|
"kill-window", "killw",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"at:", 0, 0,
|
||||||
0, "",
|
"[-a] " CMD_TARGET_WINDOW_USAGE,
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_kill_window_exec,
|
cmd_kill_window_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl, *wl2, *wl3;
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
if (args_has(args, 'a')) {
|
||||||
|
RB_FOREACH_SAFE(wl2, winlinks, &s->windows, wl3) {
|
||||||
|
if (wl != wl2)
|
||||||
|
server_kill_window(wl2->window);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
server_kill_window(wl->window);
|
||||||
|
|
||||||
server_kill_window(wl->window);
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
/* $Id: cmd-last-pane.c,v 1.1 2010-10-24 01:34:30 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Move to last pane.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_last_pane_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_last_pane_entry = {
|
|
||||||
"last-pane", "lastp",
|
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
|
||||||
0, "",
|
|
||||||
cmd_target_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_last_pane_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_last_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct window *w;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
w = wl->window;
|
|
||||||
|
|
||||||
if (w->last == NULL) {
|
|
||||||
ctx->error(ctx, "no last pane");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
window_set_active_pane(w, w->last);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/* $Id: cmd-last-window.c,v 1.19 2009-11-14 17:56:39 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Move to last window.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_last_window_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_last_window_entry = {
|
|
||||||
"last-window", "last",
|
|
||||||
CMD_TARGET_SESSION_USAGE,
|
|
||||||
0, "",
|
|
||||||
cmd_target_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_last_window_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_last_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct session *s;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (session_last(s) == 0)
|
|
||||||
server_redraw_session(s);
|
|
||||||
else {
|
|
||||||
ctx->error(ctx, "no last window");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-link-window.c,v 1.36 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,41 +26,39 @@
|
|||||||
* Link a window into another session.
|
* Link a window into another session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_link_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_link_window_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_link_window_entry = {
|
const struct cmd_entry cmd_link_window_entry = {
|
||||||
"link-window", "linkw",
|
"link-window", "linkw",
|
||||||
|
"dks:t:", 0, 0,
|
||||||
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
0, "dk",
|
0,
|
||||||
cmd_srcdst_init,
|
NULL,
|
||||||
cmd_srcdst_parse,
|
cmd_link_window_exec
|
||||||
cmd_link_window_exec,
|
|
||||||
cmd_srcdst_free,
|
|
||||||
cmd_srcdst_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_link_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_srcdst_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *src, *dst;
|
struct session *src, *dst;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
char *cause;
|
char *cause;
|
||||||
int idx, kflag, dflag;
|
int idx, kflag, dflag;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->src, &src)) == NULL)
|
if ((wl = cmd_find_window(cmdq, args_get(args, 's'), &src)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
if ((idx = cmd_find_index(ctx, data->dst, &dst)) == -2)
|
if ((idx = cmd_find_index(cmdq, args_get(args, 't'), &dst)) == -2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
kflag = cmd_check_flag(data->chflags, 'k');
|
kflag = args_has(self->args, 'k');
|
||||||
dflag = cmd_check_flag(data->chflags, 'd');
|
dflag = args_has(self->args, 'd');
|
||||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||||
ctx->error(ctx, "can't link window: %s", cause);
|
cmdq_error(cmdq, "can't link window: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-buffers.c,v 1.16 2010-06-22 23:35:20 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,38 +27,42 @@
|
|||||||
* List paste buffers.
|
* List paste buffers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_buffers_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_buffers_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_buffers_entry = {
|
const struct cmd_entry cmd_list_buffers_entry = {
|
||||||
"list-buffers", "lsb",
|
"list-buffers", "lsb",
|
||||||
CMD_TARGET_SESSION_USAGE,
|
"F:", 0, 0,
|
||||||
0, "",
|
"[-F format]",
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_list_buffers_exec,
|
cmd_list_buffers_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_buffers_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_buffers_exec(unused struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
|
struct format_tree *ft;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
char *tmp;
|
char *line;
|
||||||
|
const char *template;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
return (-1);
|
template = LIST_BUFFERS_TEMPLATE;
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) {
|
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
|
||||||
tmp = paste_print(pb, 50);
|
ft = format_create();
|
||||||
ctx->print(ctx,
|
format_add(ft, "line", "%u", idx - 1);
|
||||||
"%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp);
|
format_paste_buffer(ft, pb);
|
||||||
xfree(tmp);
|
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
cmdq_print(cmdq, "%s", line);
|
||||||
|
free(line);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-clients.c,v 1.20 2009-11-28 14:50:36 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -27,40 +28,57 @@
|
|||||||
* List all clients.
|
* List all clients.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_clients_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_clients_entry = {
|
const struct cmd_entry cmd_list_clients_entry = {
|
||||||
"list-clients", "lsc",
|
"list-clients", "lsc",
|
||||||
"",
|
"F:t:", 0, 0,
|
||||||
0, "",
|
"[-F format] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
CMD_READONLY,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
cmd_list_clients_exec
|
||||||
cmd_list_clients_exec,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
enum cmd_retval
|
||||||
int
|
cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
cmd_list_clients_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
{
|
||||||
struct client *c;
|
struct args *args = self->args;
|
||||||
u_int i;
|
struct client *c;
|
||||||
const char *s_utf8;
|
struct session *s;
|
||||||
|
struct format_tree *ft;
|
||||||
|
const char *template;
|
||||||
|
u_int i;
|
||||||
|
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
|
||||||
|
s = NULL;
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = LIST_CLIENTS_TEMPLATE;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
if (c == NULL || c->session == NULL)
|
if (c == NULL || c->session == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (c->tty.flags & TTY_UTF8)
|
if (s != NULL && s != c->session)
|
||||||
s_utf8 = " (utf8)";
|
continue;
|
||||||
else
|
|
||||||
s_utf8 = "";
|
ft = format_create();
|
||||||
ctx->print(ctx, "%s: %s [%ux%u %s]%s", c->tty.path,
|
format_add(ft, "line", "%u", i);
|
||||||
c->session->name, c->tty.sx, c->tty.sy,
|
format_session(ft, c->session);
|
||||||
c->tty.termname, s_utf8);
|
format_client(ft, c);
|
||||||
|
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
cmdq_print(cmdq, "%s", line);
|
||||||
|
free(line);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-commands.c,v 1.7 2009-11-28 14:50:36 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,27 +24,31 @@
|
|||||||
* List all commands with usages.
|
* List all commands with usages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_commands_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_commands_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_commands_entry = {
|
const struct cmd_entry cmd_list_commands_entry = {
|
||||||
"list-commands", "lscm",
|
"list-commands", "lscm",
|
||||||
|
"", 0, 0,
|
||||||
"",
|
"",
|
||||||
0, "",
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
cmd_list_commands_exec
|
||||||
cmd_list_commands_exec,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
enum cmd_retval
|
||||||
int
|
cmd_list_commands_exec(unused struct cmd *self, struct cmd_q *cmdq)
|
||||||
cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
{
|
||||||
const struct cmd_entry **entryp;
|
const struct cmd_entry **entryp;
|
||||||
|
|
||||||
for (entryp = cmd_table; *entryp != NULL; entryp++)
|
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
||||||
ctx->print(ctx, "%s %s", (*entryp)->name, (*entryp)->usage);
|
if ((*entryp)->alias != NULL) {
|
||||||
|
cmdq_print(cmdq, "%s (%s) %s", (*entryp)->name,
|
||||||
|
(*entryp)->alias, (*entryp)->usage);
|
||||||
|
} else {
|
||||||
|
cmdq_print(cmdq, "%s %s", (*entryp)->name,
|
||||||
|
(*entryp)->usage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
112
cmd-list-keys.c
112
cmd-list-keys.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-keys.c,v 1.25 2010-10-24 01:31:57 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,109 +26,125 @@
|
|||||||
* List key bindings.
|
* List key bindings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_keys_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmd_q *);
|
||||||
|
enum cmd_retval cmd_list_keys_table(struct cmd *, struct cmd_q *);
|
||||||
int cmd_list_keys_table(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_keys_entry = {
|
const struct cmd_entry cmd_list_keys_entry = {
|
||||||
"list-keys", "lsk",
|
"list-keys", "lsk",
|
||||||
|
"t:", 0, 0,
|
||||||
"[-t key-table]",
|
"[-t key-table]",
|
||||||
0, "",
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_list_keys_exec
|
||||||
cmd_list_keys_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
const char *key;
|
const char *key;
|
||||||
char tmp[BUFSIZ];
|
char tmp[BUFSIZ], flags[8];
|
||||||
size_t used;
|
size_t used;
|
||||||
int width, keywidth;
|
int width, keywidth;
|
||||||
|
|
||||||
if (data->target != NULL)
|
if (args_has(args, 't'))
|
||||||
return (cmd_list_keys_table(self, ctx));
|
return (cmd_list_keys_table(self, cmdq));
|
||||||
|
|
||||||
width = 0;
|
width = 0;
|
||||||
SPLAY_FOREACH(bd, key_bindings, &key_bindings) {
|
|
||||||
|
RB_FOREACH(bd, key_bindings, &key_bindings) {
|
||||||
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
keywidth = strlen(key) + 1;
|
keywidth = strlen(key);
|
||||||
if (!(bd->key & KEYC_PREFIX))
|
if (!(bd->key & KEYC_PREFIX)) {
|
||||||
keywidth += 2;
|
if (bd->can_repeat)
|
||||||
|
keywidth += 4;
|
||||||
|
else
|
||||||
|
keywidth += 3;
|
||||||
|
} else if (bd->can_repeat)
|
||||||
|
keywidth += 3;
|
||||||
if (keywidth > width)
|
if (keywidth > width)
|
||||||
width = keywidth;
|
width = keywidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPLAY_FOREACH(bd, key_bindings, &key_bindings) {
|
RB_FOREACH(bd, key_bindings, &key_bindings) {
|
||||||
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
continue;
|
continue;
|
||||||
used = xsnprintf(tmp, sizeof tmp, "%*s: ", width, key);
|
|
||||||
|
*flags = '\0';
|
||||||
|
if (!(bd->key & KEYC_PREFIX)) {
|
||||||
|
if (bd->can_repeat)
|
||||||
|
xsnprintf(flags, sizeof flags, "-rn ");
|
||||||
|
else
|
||||||
|
xsnprintf(flags, sizeof flags, "-n ");
|
||||||
|
} else if (bd->can_repeat)
|
||||||
|
xsnprintf(flags, sizeof flags, "-r ");
|
||||||
|
|
||||||
|
used = xsnprintf(tmp, sizeof tmp, "%s%*s ",
|
||||||
|
flags, (int) (width - strlen(flags)), key);
|
||||||
if (used >= sizeof tmp)
|
if (used >= sizeof tmp)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!(bd->key & KEYC_PREFIX)) {
|
|
||||||
used = strlcat(tmp, "(no prefix) ", sizeof tmp);
|
|
||||||
if (used >= sizeof tmp)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (bd->can_repeat) {
|
|
||||||
used = strlcat(tmp, "(repeat) ", sizeof tmp);
|
|
||||||
if (used >= sizeof tmp)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
cmd_list_print(bd->cmdlist, tmp + used, (sizeof tmp) - used);
|
cmd_list_print(bd->cmdlist, tmp + used, (sizeof tmp) - used);
|
||||||
ctx->print(ctx, "%s", tmp);
|
cmdq_print(cmdq, "bind-key %s", tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_keys_table(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
|
const char *tablename;
|
||||||
const struct mode_key_table *mtab;
|
const struct mode_key_table *mtab;
|
||||||
struct mode_key_binding *mbind;
|
struct mode_key_binding *mbind;
|
||||||
const char *key, *cmdstr, *mode;
|
const char *key, *cmdstr, *mode;
|
||||||
int width, keywidth;
|
int width, keywidth, any_mode;
|
||||||
|
|
||||||
if ((mtab = mode_key_findtable(data->target)) == NULL) {
|
tablename = args_get(args, 't');
|
||||||
ctx->error(ctx, "unknown key table: %s", data->target);
|
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
||||||
return (-1);
|
cmdq_error(cmdq, "unknown key table: %s", tablename);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
width = 0;
|
width = 0;
|
||||||
SPLAY_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
any_mode = 0;
|
||||||
|
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
||||||
key = key_string_lookup_key(mbind->key);
|
key = key_string_lookup_key(mbind->key);
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
keywidth = strlen(key) + 1;
|
if (mbind->mode != 0)
|
||||||
|
any_mode = 1;
|
||||||
|
|
||||||
|
keywidth = strlen(key);
|
||||||
if (keywidth > width)
|
if (keywidth > width)
|
||||||
width = keywidth;
|
width = keywidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPLAY_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
||||||
key = key_string_lookup_key(mbind->key);
|
key = key_string_lookup_key(mbind->key);
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mode = "";
|
mode = "";
|
||||||
if (mbind->mode != 0)
|
if (mbind->mode != 0)
|
||||||
mode = "(command mode) ";
|
mode = "c";
|
||||||
cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd);
|
cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd);
|
||||||
if (cmdstr != NULL)
|
if (cmdstr != NULL) {
|
||||||
ctx->print(ctx, "%*s: %s%s", width, key, mode, cmdstr);
|
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 (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
135
cmd-list-panes.c
135
cmd-list-panes.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-panes.c,v 1.6 2010-12-06 21:56:32 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,51 +27,117 @@
|
|||||||
* List panes on given window.
|
* List panes on given window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_panes_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_panes_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_panes_entry = {
|
const struct cmd_entry cmd_list_panes_entry = {
|
||||||
"list-panes", "lsp",
|
"list-panes", "lsp",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"asF:t:", 0, 0,
|
||||||
0, "",
|
"[-as] [-F format] " CMD_TARGET_WINDOW_USAGE,
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_list_panes_exec,
|
cmd_list_panes_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_panes_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct session *s;
|
||||||
struct window_pane *wp;
|
struct winlink *wl;
|
||||||
struct grid *gd;
|
|
||||||
struct grid_line *gl;
|
|
||||||
u_int i, n;
|
|
||||||
unsigned long long size;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if (args_has(args, 'a'))
|
||||||
return (-1);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_list_panes_server(struct cmd *self, struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
|
RB_FOREACH(s, sessions, &sessions)
|
||||||
|
cmd_list_panes_session(self, s, cmdq, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_list_panes_session(
|
||||||
|
struct cmd *self, struct session *s, struct cmd_q *cmdq, int type)
|
||||||
|
{
|
||||||
|
struct winlink *wl;
|
||||||
|
|
||||||
|
RB_FOREACH(wl, winlinks, &s->windows)
|
||||||
|
cmd_list_panes_window(self, s, wl, cmdq, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_list_panes_window(struct cmd *self,
|
||||||
|
struct session *s, struct winlink *wl, struct cmd_q *cmdq, int type)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct window_pane *wp;
|
||||||
|
u_int n;
|
||||||
|
struct format_tree *ft;
|
||||||
|
const char *template;
|
||||||
|
char *line;
|
||||||
|
|
||||||
|
template = args_get(args, 'F');
|
||||||
|
if (template == NULL) {
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
template = "#{pane_index}: "
|
||||||
|
"[#{pane_width}x#{pane_height}] [history "
|
||||||
|
"#{history_size}/#{history_limit}, "
|
||||||
|
"#{history_bytes} bytes] #{pane_id}"
|
||||||
|
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
template = "#{window_index}.#{pane_index}: "
|
||||||
|
"[#{pane_width}x#{pane_height}] [history "
|
||||||
|
"#{history_size}/#{history_limit}, "
|
||||||
|
"#{history_bytes} bytes] #{pane_id}"
|
||||||
|
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
template = "#{session_name}:#{window_index}.#{pane_index}: "
|
||||||
|
"[#{pane_width}x#{pane_height}] [history "
|
||||||
|
"#{history_size}/#{history_limit}, "
|
||||||
|
"#{history_bytes} bytes] #{pane_id}"
|
||||||
|
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||||
gd = wp->base.grid;
|
ft = format_create();
|
||||||
|
format_add(ft, "line", "%u", n);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, wp);
|
||||||
|
|
||||||
size = 0;
|
line = format_expand(ft, template);
|
||||||
for (i = 0; i < gd->hsize; i++) {
|
cmdq_print(cmdq, "%s", line);
|
||||||
gl = &gd->linedata[i];
|
free(line);
|
||||||
size += gl->cellsize * sizeof *gl->celldata;
|
|
||||||
size += gl->utf8size * sizeof *gl->utf8data;
|
|
||||||
}
|
|
||||||
size += gd->hsize * sizeof *gd->linedata;
|
|
||||||
|
|
||||||
ctx->print(ctx, "%u: [%ux%u] [history %u/%u, %llu bytes]%s%s",
|
format_free(ft);
|
||||||
n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size,
|
|
||||||
wp == wp->window->active ? " (active)" : "",
|
|
||||||
wp->fd == -1 ? " (dead)" : "");
|
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-sessions.c,v 1.26 2010-12-22 15:36:44 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -27,45 +28,43 @@
|
|||||||
* List all sessions.
|
* List all sessions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_sessions_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_sessions_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_sessions_entry = {
|
const struct cmd_entry cmd_list_sessions_entry = {
|
||||||
"list-sessions", "ls", "",
|
"list-sessions", "ls",
|
||||||
0, "",
|
"F:", 0, 0,
|
||||||
|
"[-F format]",
|
||||||
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
cmd_list_sessions_exec
|
||||||
cmd_list_sessions_exec,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
enum cmd_retval
|
||||||
int
|
cmd_list_sessions_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
cmd_list_sessions_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct session_group *sg;
|
u_int n;
|
||||||
char *tim, tmp[64];
|
struct format_tree *ft;
|
||||||
u_int idx;
|
const char *template;
|
||||||
time_t t;
|
char *line;
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = LIST_SESSIONS_TEMPLATE;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
sg = session_group_find(s);
|
ft = format_create();
|
||||||
if (sg == NULL)
|
format_add(ft, "line", "%u", n);
|
||||||
*tmp = '\0';
|
format_session(ft, s);
|
||||||
else {
|
|
||||||
idx = session_group_index(sg);
|
|
||||||
xsnprintf(tmp, sizeof tmp, " (group %u)", idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
t = s->creation_time.tv_sec;
|
line = format_expand(ft, template);
|
||||||
tim = ctime(&t);
|
cmdq_print(cmdq, "%s", line);
|
||||||
*strchr(tim, '\n') = '\0';
|
free(line);
|
||||||
|
|
||||||
ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]%s%s",
|
format_free(ft);
|
||||||
s->name, winlink_count(&s->windows), tim, s->sx, s->sy,
|
n++;
|
||||||
tmp, s->flags & SESSION_UNATTACHED ? "" : " (attached)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-windows.c,v 1.44 2010-12-06 21:56:32 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,37 +27,84 @@
|
|||||||
* List windows on given session.
|
* List windows on given session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_windows_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
|
void cmd_list_windows_server(struct cmd *, struct cmd_q *);
|
||||||
|
void cmd_list_windows_session(
|
||||||
|
struct cmd *, struct session *, struct cmd_q *, int);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_windows_entry = {
|
const struct cmd_entry cmd_list_windows_entry = {
|
||||||
"list-windows", "lsw",
|
"list-windows", "lsw",
|
||||||
CMD_TARGET_SESSION_USAGE,
|
"F:at:", 0, 0,
|
||||||
0, "",
|
"[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_list_windows_exec,
|
cmd_list_windows_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_windows_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
|
||||||
char *layout;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if (args_has(args, 'a'))
|
||||||
return (-1);
|
cmd_list_windows_server(self, cmdq);
|
||||||
|
else {
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
||||||
layout = layout_dump(wl->window);
|
if (s == NULL)
|
||||||
ctx->print(ctx, "%d: %s [%ux%u] [layout %s]%s",
|
return (CMD_RETURN_ERROR);
|
||||||
wl->idx, wl->window->name, wl->window->sx, wl->window->sy,
|
cmd_list_windows_session(self, s, cmdq, 0);
|
||||||
layout, wl == s->curw ? " (active)" : "");
|
|
||||||
xfree(layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_list_windows_server(struct cmd *self, struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
|
RB_FOREACH(s, sessions, &sessions)
|
||||||
|
cmd_list_windows_session(self, s, cmdq, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_list_windows_session(
|
||||||
|
struct cmd *self, struct session *s, struct cmd_q *cmdq, int type)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct winlink *wl;
|
||||||
|
u_int n;
|
||||||
|
struct format_tree *ft;
|
||||||
|
const char *template;
|
||||||
|
char *line;
|
||||||
|
|
||||||
|
template = args_get(args, 'F');
|
||||||
|
if (template == NULL) {
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
template = LIST_WINDOWS_TEMPLATE;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
template = LIST_WINDOWS_WITH_SESSION_TEMPLATE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
|
ft = format_create();
|
||||||
|
format_add(ft, "line", "%u", n);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, wl->window->active);
|
||||||
|
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
cmdq_print(cmdq, "%s", line);
|
||||||
|
free(line);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
61
cmd-list.c
61
cmd-list.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list.c,v 1.10 2010-12-06 21:48:56 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,12 +18,14 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
struct cmd_list *
|
struct cmd_list *
|
||||||
cmd_list_parse(int argc, char **argv, char **cause)
|
cmd_list_parse(int argc, char **argv, const char* file, u_int line,
|
||||||
|
char **cause)
|
||||||
{
|
{
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
@@ -33,7 +35,7 @@ cmd_list_parse(int argc, char **argv, char **cause)
|
|||||||
|
|
||||||
copy_argv = cmd_copy_argv(argc, argv);
|
copy_argv = cmd_copy_argv(argc, argv);
|
||||||
|
|
||||||
cmdlist = xmalloc(sizeof *cmdlist);
|
cmdlist = xcalloc(1, sizeof *cmdlist);
|
||||||
cmdlist->references = 1;
|
cmdlist->references = 1;
|
||||||
TAILQ_INIT(&cmdlist->list);
|
TAILQ_INIT(&cmdlist->list);
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ cmd_list_parse(int argc, char **argv, char **cause)
|
|||||||
if (arglen != 1)
|
if (arglen != 1)
|
||||||
new_argc++;
|
new_argc++;
|
||||||
|
|
||||||
cmd = cmd_parse(new_argc, new_argv, cause);
|
cmd = cmd_parse(new_argc, new_argv, file, line, cause);
|
||||||
if (cmd == NULL)
|
if (cmd == NULL)
|
||||||
goto bad;
|
goto bad;
|
||||||
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
||||||
@@ -63,7 +65,8 @@ cmd_list_parse(int argc, char **argv, char **cause)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lastsplit != argc) {
|
if (lastsplit != argc) {
|
||||||
cmd = cmd_parse(argc - lastsplit, copy_argv + lastsplit, cause);
|
cmd = cmd_parse(argc - lastsplit, copy_argv + lastsplit,
|
||||||
|
file, line, cause);
|
||||||
if (cmd == NULL)
|
if (cmd == NULL)
|
||||||
goto bad;
|
goto bad;
|
||||||
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
|
||||||
@@ -78,56 +81,22 @@ bad:
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd *cmd;
|
|
||||||
int n, retval;
|
|
||||||
|
|
||||||
retval = 0;
|
|
||||||
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
|
||||||
if ((n = cmd_exec(cmd, ctx)) == -1)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A 1 return value means the command client is being attached
|
|
||||||
* (sent MSG_READY).
|
|
||||||
*/
|
|
||||||
if (n == 1) {
|
|
||||||
retval = 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The command client has been attached, so mangle the
|
|
||||||
* context to treat any following commands as if they
|
|
||||||
* were called from inside.
|
|
||||||
*/
|
|
||||||
if (ctx->curclient == NULL) {
|
|
||||||
ctx->curclient = ctx->cmdclient;
|
|
||||||
ctx->cmdclient = NULL;
|
|
||||||
|
|
||||||
ctx->error = key_bindings_error;
|
|
||||||
ctx->print = key_bindings_print;
|
|
||||||
ctx->info = key_bindings_info;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (retval);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_list_free(struct cmd_list *cmdlist)
|
cmd_list_free(struct cmd_list *cmdlist)
|
||||||
{
|
{
|
||||||
struct cmd *cmd;
|
struct cmd *cmd, *cmd1;
|
||||||
|
|
||||||
if (--cmdlist->references != 0)
|
if (--cmdlist->references != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (!TAILQ_EMPTY(&cmdlist->list)) {
|
TAILQ_FOREACH_SAFE(cmd, &cmdlist->list, qentry, cmd1) {
|
||||||
cmd = TAILQ_FIRST(&cmdlist->list);
|
|
||||||
TAILQ_REMOVE(&cmdlist->list, cmd, qentry);
|
TAILQ_REMOVE(&cmdlist->list, cmd, qentry);
|
||||||
cmd_free(cmd);
|
args_free(cmd->args);
|
||||||
|
free(cmd->file);
|
||||||
|
free(cmd);
|
||||||
}
|
}
|
||||||
xfree(cmdlist);
|
|
||||||
|
free(cmdlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-load-buffer.c,v 1.18 2010-12-22 15:28:50 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -27,73 +28,73 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loads a session paste buffer from a file.
|
* Loads a paste buffer from a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_load_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmd_q *);
|
||||||
void cmd_load_buffer_callback(struct client *, void *);
|
void cmd_load_buffer_callback(struct client *, int, void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_load_buffer_entry = {
|
const struct cmd_entry cmd_load_buffer_entry = {
|
||||||
"load-buffer", "loadb",
|
"load-buffer", "loadb",
|
||||||
CMD_BUFFER_SESSION_USAGE " path",
|
"b:", 1, 1,
|
||||||
CMD_ARG1, "",
|
CMD_BUFFER_USAGE " path",
|
||||||
cmd_buffer_init,
|
0,
|
||||||
cmd_buffer_parse,
|
NULL,
|
||||||
cmd_load_buffer_exec,
|
cmd_load_buffer_exec
|
||||||
cmd_buffer_free,
|
|
||||||
cmd_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_load_buffer_cdata {
|
enum cmd_retval
|
||||||
struct session *session;
|
cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
int buffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct cmd_load_buffer_cdata *cdata;
|
struct client *c = cmdq->client;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct client *c = ctx->cmdclient;
|
FILE *f;
|
||||||
FILE *f;
|
const char *path;
|
||||||
char *pdata, *new_pdata;
|
char *pdata, *new_pdata, *cause;
|
||||||
size_t psize;
|
size_t psize;
|
||||||
u_int limit;
|
u_int limit;
|
||||||
int ch;
|
int ch, error, buffer, *buffer_ptr, cwd, fd;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if (!args_has(args, 'b'))
|
||||||
return (-1);
|
buffer = -1;
|
||||||
|
else {
|
||||||
if (strcmp(data->arg, "-") == 0) {
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
if (c == NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "%s: can't read from stdin", data->arg);
|
cmdq_error(cmdq, "buffer %s", cause);
|
||||||
return (-1);
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (c->flags & CLIENT_TERMINAL) {
|
|
||||||
ctx->error(ctx, "%s: stdin is a tty", data->arg);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (c->stdin_fd == -1) {
|
|
||||||
ctx->error(ctx, "%s: can't read from stdin", data->arg);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
|
||||||
cdata->session = s;
|
|
||||||
cdata->session->references++;
|
|
||||||
cdata->buffer = data->buffer;
|
|
||||||
c->stdin_data = cdata;
|
|
||||||
c->stdin_callback = cmd_load_buffer_callback;
|
|
||||||
|
|
||||||
c->references++;
|
|
||||||
bufferevent_enable(c->stdin_event, EV_READ);
|
|
||||||
return (1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((f = fopen(data->arg, "rb")) == NULL) {
|
path = args->argv[0];
|
||||||
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
|
if (strcmp(path, "-") == 0) {
|
||||||
return (-1);
|
buffer_ptr = xmalloc(sizeof *buffer_ptr);
|
||||||
|
*buffer_ptr = buffer;
|
||||||
|
|
||||||
|
error = server_set_stdin_callback(c, cmd_load_buffer_callback,
|
||||||
|
buffer_ptr, &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_current_session(cmdq, 0)) != 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;
|
pdata = NULL;
|
||||||
@@ -101,85 +102,78 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
while ((ch = getc(f)) != EOF) {
|
while ((ch = getc(f)) != EOF) {
|
||||||
/* Do not let the server die due to memory exhaustion. */
|
/* Do not let the server die due to memory exhaustion. */
|
||||||
if ((new_pdata = realloc(pdata, psize + 2)) == NULL) {
|
if ((new_pdata = realloc(pdata, psize + 2)) == NULL) {
|
||||||
ctx->error(ctx, "realloc error: %s", strerror(errno));
|
cmdq_error(cmdq, "realloc error: %s", strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
pdata = new_pdata;
|
pdata = new_pdata;
|
||||||
pdata[psize++] = ch;
|
pdata[psize++] = ch;
|
||||||
}
|
}
|
||||||
if (ferror(f)) {
|
if (ferror(f)) {
|
||||||
ctx->error(ctx, "%s: read error", data->arg);
|
cmdq_error(cmdq, "%s: read error", path);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (pdata != NULL)
|
if (pdata != NULL)
|
||||||
pdata[psize] = '\0';
|
pdata[psize] = '\0';
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
f = NULL;
|
|
||||||
|
|
||||||
limit = options_get_number(&s->options, "buffer-limit");
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
if (data->buffer == -1) {
|
if (buffer == -1) {
|
||||||
paste_add(&s->buffers, pdata, psize, limit);
|
paste_add(&global_buffers, pdata, psize, limit);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
if (paste_replace(&s->buffers, data->buffer, pdata, psize) != 0) {
|
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
cmdq_error(cmdq, "no buffer %d", buffer);
|
||||||
return (-1);
|
free(pdata);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (pdata != NULL)
|
free(pdata);
|
||||||
xfree(pdata);
|
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_load_buffer_callback(struct client *c, void *data)
|
cmd_load_buffer_callback(struct client *c, int closed, void *data)
|
||||||
{
|
{
|
||||||
struct cmd_load_buffer_cdata *cdata = data;
|
int *buffer = data;
|
||||||
struct session *s = cdata->session;
|
char *pdata;
|
||||||
char *pdata;
|
size_t psize;
|
||||||
size_t psize;
|
u_int limit;
|
||||||
u_int limit;
|
|
||||||
|
|
||||||
/*
|
if (!closed)
|
||||||
* Event callback has already checked client is not dead and reduced
|
return;
|
||||||
* its reference count. But tell it to exit.
|
c->stdin_callback = NULL;
|
||||||
*/
|
|
||||||
c->flags |= CLIENT_EXIT;
|
|
||||||
|
|
||||||
/* Does the target session still exist? */
|
c->references--;
|
||||||
if (!session_alive(s))
|
if (c->flags & CLIENT_DEAD)
|
||||||
|
return;
|
||||||
|
|
||||||
|
psize = EVBUFFER_LENGTH(c->stdin_data);
|
||||||
|
if (psize == 0 || (pdata = malloc(psize + 1)) == NULL) {
|
||||||
|
free(data);
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
psize = EVBUFFER_LENGTH(c->stdin_event->input);
|
memcpy(pdata, EVBUFFER_DATA(c->stdin_data), psize);
|
||||||
if (psize == 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
pdata = malloc(psize + 1);
|
|
||||||
if (pdata == NULL)
|
|
||||||
goto out;
|
|
||||||
bufferevent_read(c->stdin_event, pdata, psize);
|
|
||||||
pdata[psize] = '\0';
|
pdata[psize] = '\0';
|
||||||
|
evbuffer_drain(c->stdin_data, psize);
|
||||||
|
|
||||||
limit = options_get_number(&s->options, "buffer-limit");
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
if (cdata->buffer == -1) {
|
if (*buffer == -1)
|
||||||
paste_add(&s->buffers, pdata, psize, limit);
|
paste_add(&global_buffers, pdata, psize, limit);
|
||||||
goto out;
|
else if (paste_replace(&global_buffers, *buffer, pdata, psize) != 0) {
|
||||||
}
|
|
||||||
if (paste_replace(&s->buffers, cdata->buffer, pdata, psize) != 0) {
|
|
||||||
/* No context so can't use server_client_msg_error. */
|
/* No context so can't use server_client_msg_error. */
|
||||||
evbuffer_add_printf(
|
evbuffer_add_printf(c->stderr_data, "no buffer %d\n", *buffer);
|
||||||
c->stderr_event->output, "no buffer %d\n", cdata->buffer);
|
server_push_stderr(c);
|
||||||
bufferevent_enable(c->stderr_event, EV_WRITE);
|
free(pdata);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
cdata->session->references--;
|
cmdq_continue(c->cmdq);
|
||||||
xfree(cdata);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-lock-server.c,v 1.9 2009-11-28 14:50:36 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -25,28 +25,59 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock server.
|
* Lock commands.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_lock_server_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_lock_server_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_lock_server_entry = {
|
const struct cmd_entry cmd_lock_server_entry = {
|
||||||
"lock-server", "lock",
|
"lock-server", "lock",
|
||||||
|
"", 0, 0,
|
||||||
"",
|
"",
|
||||||
0, "",
|
0,
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_lock_server_exec,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
NULL,
|
||||||
|
cmd_lock_server_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
const struct cmd_entry cmd_lock_session_entry = {
|
||||||
int
|
"lock-session", "locks",
|
||||||
cmd_lock_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_SESSION_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
cmd_lock_server_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_lock_client_entry = {
|
||||||
|
"lock-client", "lockc",
|
||||||
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
cmd_lock_server_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_lock_server_exec(struct cmd *self, unused struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
server_lock();
|
struct args *args = self->args;
|
||||||
|
struct client *c;
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
|
if (self->entry == &cmd_lock_server_entry)
|
||||||
|
server_lock();
|
||||||
|
else if (self->entry == &cmd_lock_session_entry) {
|
||||||
|
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)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
server_lock_client(c);
|
||||||
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-move-window.c,v 1.13 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,42 +26,50 @@
|
|||||||
* Move a window.
|
* Move a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_move_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_move_window_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_move_window_entry = {
|
const struct cmd_entry cmd_move_window_entry = {
|
||||||
"move-window", "movew",
|
"move-window", "movew",
|
||||||
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
"dkrs:t:", 0, 0,
|
||||||
0, "dk",
|
"[-dkr] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
cmd_srcdst_init,
|
0,
|
||||||
cmd_srcdst_parse,
|
NULL,
|
||||||
cmd_move_window_exec,
|
cmd_move_window_exec
|
||||||
cmd_srcdst_free,
|
|
||||||
cmd_srcdst_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_srcdst_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *src, *dst;
|
struct session *src, *dst, *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
char *cause;
|
char *cause;
|
||||||
int idx, kflag, dflag;
|
int idx, kflag, dflag;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->src, &src)) == NULL)
|
if (args_has(args, 'r')) {
|
||||||
return (-1);
|
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
if ((idx = cmd_find_index(ctx, data->dst, &dst)) == -2)
|
return (CMD_RETURN_ERROR);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
kflag = cmd_check_flag(data->chflags, 'k');
|
session_renumber_windows(s);
|
||||||
dflag = cmd_check_flag(data->chflags, 'd');
|
recalculate_sizes();
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((wl = cmd_find_window(cmdq, args_get(args, 's'), &src)) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
if ((idx = cmd_find_index(cmdq, args_get(args, 't'), &dst)) == -2)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
kflag = args_has(self->args, 'k');
|
||||||
|
dflag = args_has(self->args, 'd');
|
||||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||||
ctx->error(ctx, "can't move window: %s", cause);
|
cmdq_error(cmdq, "can't move window: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
server_unlink_window(src, wl);
|
server_unlink_window(src, wl);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-new-session.c,v 1.80 2010-12-22 15:31:00 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,7 +18,10 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -29,143 +32,101 @@
|
|||||||
* Create a new session and attach to the current terminal unless -d is given.
|
* Create a new session and attach to the current terminal unless -d is given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_new_session_parse(struct cmd *, int, char **, char **);
|
enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_q *);
|
||||||
int cmd_new_session_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_new_session_free(struct cmd *);
|
|
||||||
void cmd_new_session_init(struct cmd *, int);
|
|
||||||
size_t cmd_new_session_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_new_session_data {
|
|
||||||
char *target;
|
|
||||||
char *newname;
|
|
||||||
char *winname;
|
|
||||||
char *cmd;
|
|
||||||
int flag_detached;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_new_session_entry = {
|
const struct cmd_entry cmd_new_session_entry = {
|
||||||
"new-session", "new",
|
"new-session", "new",
|
||||||
"[-d] [-n window-name] [-s session-name] [-t target-session] [command]",
|
"Ac:dDF:n:Ps:t:x:y:", 0, 1,
|
||||||
CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON, "",
|
"[-AdDP] [-c start-directory] [-F format] [-n window-name] "
|
||||||
cmd_new_session_init,
|
"[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] [-y height] "
|
||||||
cmd_new_session_parse,
|
"[command]",
|
||||||
cmd_new_session_exec,
|
CMD_STARTSERVER|CMD_CANTNEST,
|
||||||
cmd_new_session_free,
|
NULL,
|
||||||
cmd_new_session_print
|
cmd_new_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
enum cmd_retval
|
||||||
void
|
cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
cmd_new_session_init(struct cmd *self, unused int arg)
|
|
||||||
{
|
{
|
||||||
struct cmd_new_session_data *data;
|
struct args *args = self->args;
|
||||||
|
struct client *c = cmdq->client, *c0;
|
||||||
|
struct session *s, *groupwith;
|
||||||
|
struct window *w;
|
||||||
|
struct environ env;
|
||||||
|
struct termios tio, *tiop;
|
||||||
|
const char *newname, *target, *update, *errstr, *template;
|
||||||
|
char *cmd, *cause, *cp;
|
||||||
|
int detached, already_attached, idx, cwd, fd = -1;
|
||||||
|
u_int sx, sy;
|
||||||
|
struct format_tree *ft;
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) {
|
||||||
data->flag_detached = 0;
|
cmdq_error(cmdq, "command or window name given with target");
|
||||||
data->target = NULL;
|
return (CMD_RETURN_ERROR);
|
||||||
data->newname = NULL;
|
}
|
||||||
data->winname = NULL;
|
|
||||||
data->cmd = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
newname = args_get(args, 's');
|
||||||
cmd_new_session_parse(struct cmd *self, int argc, char **argv, char **cause)
|
if (newname != NULL) {
|
||||||
{
|
if (!session_check_name(newname)) {
|
||||||
struct cmd_new_session_data *data;
|
cmdq_error(cmdq, "bad session name: %s", newname);
|
||||||
int opt;
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
self->entry->init(self, KEYC_NONE);
|
if (session_find(newname) != NULL) {
|
||||||
data = self->data;
|
if (args_has(args, 'A')) {
|
||||||
|
return (cmd_attach_session(cmdq, newname,
|
||||||
while ((opt = getopt(argc, argv, "ds:t:n:")) != -1) {
|
args_has(args, 'D'), 0, NULL));
|
||||||
switch (opt) {
|
}
|
||||||
case 'd':
|
cmdq_error(cmdq, "duplicate session: %s", newname);
|
||||||
data->flag_detached = 1;
|
return (CMD_RETURN_ERROR);
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
if (data->newname == NULL)
|
|
||||||
data->newname = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
if (data->winname == NULL)
|
|
||||||
data->winname = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 0 && argc != 1)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
if (data->target != NULL && (argc == 1 || data->winname != NULL))
|
target = args_get(args, 't');
|
||||||
goto usage;
|
if (target != NULL) {
|
||||||
|
groupwith = cmd_find_session(cmdq, target, 0);
|
||||||
if (argc == 1)
|
if (groupwith == NULL)
|
||||||
data->cmd = xstrdup(argv[0]);
|
return (CMD_RETURN_ERROR);
|
||||||
|
} else
|
||||||
return (0);
|
groupwith = NULL;
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_new_session_data *data = self->data;
|
|
||||||
struct session *s, *old_s, *groupwith;
|
|
||||||
struct window *w;
|
|
||||||
struct window_pane *wp;
|
|
||||||
struct environ env;
|
|
||||||
struct termios tio, *tiop;
|
|
||||||
struct passwd *pw;
|
|
||||||
const char *update, *cwd;
|
|
||||||
char *overrides, *cmd, *cause;
|
|
||||||
int detached, idx;
|
|
||||||
u_int sx, sy, i;
|
|
||||||
|
|
||||||
if (data->newname != NULL && session_find(data->newname) != NULL) {
|
|
||||||
ctx->error(ctx, "duplicate session: %s", data->newname);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
groupwith = NULL;
|
|
||||||
if (data->target != NULL &&
|
|
||||||
(groupwith = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* There are three cases:
|
|
||||||
*
|
|
||||||
* 1. If cmdclient is non-NULL, new-session has been called from the
|
|
||||||
* command-line - cmdclient is to become a new attached, interactive
|
|
||||||
* client. Unless -d is given, the terminal must be opened and then
|
|
||||||
* the client sent MSG_READY.
|
|
||||||
*
|
|
||||||
* 2. If cmdclient is NULL, new-session has been called from an
|
|
||||||
* existing client (such as a key binding).
|
|
||||||
*
|
|
||||||
* 3. Both are NULL, the command was in the configuration file. Treat
|
|
||||||
* this as if -d was given even if it was not.
|
|
||||||
*
|
|
||||||
* In all cases, a new additional session needs to be created and
|
|
||||||
* (unless -d) set as the current session for the client.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Set -d if no client. */
|
/* Set -d if no client. */
|
||||||
detached = data->flag_detached;
|
detached = args_has(args, 'd');
|
||||||
if (ctx->cmdclient == NULL && ctx->curclient == NULL)
|
if (c == NULL)
|
||||||
detached = 1;
|
detached = 1;
|
||||||
|
|
||||||
|
/* Is this client already attached? */
|
||||||
|
already_attached = 0;
|
||||||
|
if (c != NULL && c->session != NULL)
|
||||||
|
already_attached = 1;
|
||||||
|
|
||||||
|
/* Get the new session working directory. */
|
||||||
|
if (args_has(args, 'c')) {
|
||||||
|
ft = format_create();
|
||||||
|
if ((c0 = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
||||||
|
format_client(ft, c0);
|
||||||
|
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_current_client(cmdq)) != NULL)
|
||||||
|
cwd = c0->session->cwd;
|
||||||
|
else {
|
||||||
|
fd = open(".", O_RDONLY);
|
||||||
|
cwd = fd;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Save the termios settings, part of which is used for new windows in
|
* Save the termios settings, part of which is used for new windows in
|
||||||
* this session.
|
* this session.
|
||||||
@@ -175,50 +136,43 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
* before opening the terminal as that calls tcsetattr() to prepare for
|
* before opening the terminal as that calls tcsetattr() to prepare for
|
||||||
* tmux taking over.
|
* tmux taking over.
|
||||||
*/
|
*/
|
||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->tty.fd != -1) {
|
if (!detached && !already_attached && c->tty.fd != -1) {
|
||||||
if (tcgetattr(ctx->cmdclient->tty.fd, &tio) != 0)
|
if (tcgetattr(c->tty.fd, &tio) != 0)
|
||||||
fatal("tcgetattr failed");
|
fatal("tcgetattr failed");
|
||||||
tiop = &tio;
|
tiop = &tio;
|
||||||
} else
|
} else
|
||||||
tiop = NULL;
|
tiop = NULL;
|
||||||
|
|
||||||
/* Open the terminal if necessary. */
|
/* Open the terminal if necessary. */
|
||||||
if (!detached && ctx->cmdclient != NULL) {
|
if (!detached && !already_attached) {
|
||||||
if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
|
if (server_client_open(c, NULL, &cause) != 0) {
|
||||||
ctx->error(ctx, "not a terminal");
|
cmdq_error(cmdq, "open terminal failed: %s", cause);
|
||||||
return (-1);
|
free(cause);
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
overrides =
|
|
||||||
options_get_string(&global_s_options, "terminal-overrides");
|
|
||||||
if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
|
|
||||||
ctx->error(ctx, "open terminal failed: %s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the new session working directory. */
|
|
||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
|
||||||
cwd = ctx->cmdclient->cwd;
|
|
||||||
else {
|
|
||||||
pw = getpwuid(getuid());
|
|
||||||
if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
|
|
||||||
cwd = pw->pw_dir;
|
|
||||||
else
|
|
||||||
cwd = "/";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find new session size. */
|
/* Find new session size. */
|
||||||
if (detached) {
|
if (c != NULL) {
|
||||||
|
sx = c->tty.sx;
|
||||||
|
sy = c->tty.sy;
|
||||||
|
} else {
|
||||||
sx = 80;
|
sx = 80;
|
||||||
sy = 24;
|
sy = 24;
|
||||||
} else if (ctx->cmdclient != NULL) {
|
}
|
||||||
sx = ctx->cmdclient->tty.sx;
|
if (detached && args_has(args, 'x')) {
|
||||||
sy = ctx->cmdclient->tty.sy;
|
sx = strtonum(args_get(args, 'x'), 1, USHRT_MAX, &errstr);
|
||||||
} else {
|
if (errstr != NULL) {
|
||||||
sx = ctx->curclient->tty.sx;
|
cmdq_error(cmdq, "width %s", errstr);
|
||||||
sy = ctx->curclient->tty.sy;
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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"))
|
if (sy > 0 && options_get_number(&global_s_options, "status"))
|
||||||
sy--;
|
sy--;
|
||||||
@@ -228,37 +182,33 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
sy = 1;
|
sy = 1;
|
||||||
|
|
||||||
/* Figure out the command for the new window. */
|
/* Figure out the command for the new window. */
|
||||||
if (data->target != NULL)
|
if (target != NULL)
|
||||||
cmd = NULL;
|
cmd = NULL;
|
||||||
else if (data->cmd != NULL)
|
else if (args->argc != 0)
|
||||||
cmd = data->cmd;
|
cmd = args->argv[0];
|
||||||
else
|
else
|
||||||
cmd = options_get_string(&global_s_options, "default-command");
|
cmd = options_get_string(&global_s_options, "default-command");
|
||||||
|
|
||||||
/* Construct the environment. */
|
/* Construct the environment. */
|
||||||
environ_init(&env);
|
environ_init(&env);
|
||||||
update = options_get_string(&global_s_options, "update-environment");
|
update = options_get_string(&global_s_options, "update-environment");
|
||||||
if (ctx->cmdclient != NULL)
|
if (c != NULL)
|
||||||
environ_update(update, &ctx->cmdclient->environ, &env);
|
environ_update(update, &c->environ, &env);
|
||||||
|
|
||||||
/* Create the new session. */
|
/* Create the new session. */
|
||||||
idx = -1 - options_get_number(&global_s_options, "base-index");
|
idx = -1 - options_get_number(&global_s_options, "base-index");
|
||||||
s = session_create(
|
s = session_create(newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause);
|
||||||
data->newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause);
|
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
ctx->error(ctx, "create session failed: %s", cause);
|
cmdq_error(cmdq, "create session failed: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
goto error;
|
||||||
}
|
}
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
|
|
||||||
/* Set the initial window name if one given. */
|
/* Set the initial window name if one given. */
|
||||||
if (cmd != NULL && data->winname != NULL) {
|
if (cmd != NULL && args_has(args, 'n')) {
|
||||||
w = s->curw->window;
|
w = s->curw->window;
|
||||||
|
window_set_name(w, args_get(args, 'n'));
|
||||||
xfree(w->name);
|
|
||||||
w->name = xstrdup(data->winname);
|
|
||||||
|
|
||||||
options_set_number(&w->options, "automatic-rename", 0);
|
options_set_number(&w->options, "automatic-rename", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,21 +227,14 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
* taking this session and needs to get MSG_READY and stay around.
|
* taking this session and needs to get MSG_READY and stay around.
|
||||||
*/
|
*/
|
||||||
if (!detached) {
|
if (!detached) {
|
||||||
if (ctx->cmdclient != NULL) {
|
if (!already_attached)
|
||||||
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
server_write_ready(c);
|
||||||
|
else if (c->session != NULL)
|
||||||
old_s = ctx->cmdclient->session;
|
c->last_session = c->session;
|
||||||
if (old_s != NULL)
|
c->session = s;
|
||||||
ctx->cmdclient->last_session = old_s;
|
notify_attached_session_changed(c);
|
||||||
ctx->cmdclient->session = s;
|
session_update_activity(s);
|
||||||
server_redraw_client(ctx->cmdclient);
|
server_redraw_client(c);
|
||||||
} else {
|
|
||||||
old_s = ctx->curclient->session;
|
|
||||||
if (old_s != NULL)
|
|
||||||
ctx->curclient->last_session = old_s;
|
|
||||||
ctx->curclient->session = s;
|
|
||||||
server_redraw_client(ctx->curclient);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_update_socket();
|
server_update_socket();
|
||||||
@@ -300,53 +243,35 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
* If there are still configuration file errors to display, put the new
|
* If there are still configuration file errors to display, put the new
|
||||||
* session's current window into more mode and display them now.
|
* session's current window into more mode and display them now.
|
||||||
*/
|
*/
|
||||||
if (cfg_finished && !ARRAY_EMPTY(&cfg_causes)) {
|
if (cfg_finished)
|
||||||
wp = s->curw->window->active;
|
cfg_show_causes(s);
|
||||||
window_pane_set_mode(wp, &window_copy_mode);
|
|
||||||
window_copy_init_for_output(wp);
|
/* Print if requested. */
|
||||||
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
|
if (args_has(args, 'P')) {
|
||||||
cause = ARRAY_ITEM(&cfg_causes, i);
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
window_copy_add(wp, "%s", cause);
|
template = NEW_SESSION_TEMPLATE;
|
||||||
xfree(cause);
|
|
||||||
}
|
ft = format_create();
|
||||||
ARRAY_FREE(&cfg_causes);
|
if ((c0 = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
||||||
|
format_client(ft, c0);
|
||||||
|
format_session(ft, s);
|
||||||
|
|
||||||
|
cp = format_expand(ft, template);
|
||||||
|
cmdq_print(cmdq, "%s", cp);
|
||||||
|
free(cp);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (!detached); /* 1 means don't tell command client to exit */
|
if (!detached)
|
||||||
}
|
cmdq->client_exit = 0;
|
||||||
|
|
||||||
void
|
if (fd != -1)
|
||||||
cmd_new_session_free(struct cmd *self)
|
close(fd);
|
||||||
{
|
return (CMD_RETURN_NORMAL);
|
||||||
struct cmd_new_session_data *data = self->data;
|
|
||||||
|
error:
|
||||||
if (data->newname != NULL)
|
if (fd != -1)
|
||||||
xfree(data->newname);
|
close(fd);
|
||||||
if (data->winname != NULL)
|
return (CMD_RETURN_ERROR);
|
||||||
xfree(data->winname);
|
|
||||||
if (data->cmd != NULL)
|
|
||||||
xfree(data->cmd);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_new_session_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_new_session_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->flag_detached)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -d");
|
|
||||||
if (off < len && data->winname != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -n ", data->winname);
|
|
||||||
if (off < len && data->newname != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -s ", data->newname);
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->cmd != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->cmd);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
252
cmd-new-window.c
252
cmd-new-window.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-new-window.c,v 1.47 2010-07-02 02:49:19 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,7 +18,11 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,111 +30,34 @@
|
|||||||
* Create a new window.
|
* Create a new window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_new_window_parse(struct cmd *, int, char **, char **);
|
enum cmd_retval cmd_new_window_exec(struct cmd *, struct cmd_q *);
|
||||||
int cmd_new_window_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_new_window_free(struct cmd *);
|
|
||||||
void cmd_new_window_init(struct cmd *, int);
|
|
||||||
size_t cmd_new_window_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_new_window_data {
|
|
||||||
char *target;
|
|
||||||
char *name;
|
|
||||||
char *cmd;
|
|
||||||
int flag_insert_after;
|
|
||||||
int flag_detached;
|
|
||||||
int flag_kill;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_new_window_entry = {
|
const struct cmd_entry cmd_new_window_entry = {
|
||||||
"new-window", "neww",
|
"new-window", "neww",
|
||||||
"[-adk] [-n window-name] [-t target-window] [command]",
|
"ac:dF:kn:Pt:", 0, 1,
|
||||||
0, "",
|
"[-adkP] [-c start-directory] [-F format] [-n window-name] "
|
||||||
cmd_new_window_init,
|
CMD_TARGET_WINDOW_USAGE " [command]",
|
||||||
cmd_new_window_parse,
|
0,
|
||||||
cmd_new_window_exec,
|
NULL,
|
||||||
cmd_new_window_free,
|
cmd_new_window_exec
|
||||||
cmd_new_window_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
enum cmd_retval
|
||||||
void
|
cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
cmd_new_window_init(struct cmd *self, unused int arg)
|
|
||||||
{
|
{
|
||||||
struct cmd_new_window_data *data;
|
struct args *args = self->args;
|
||||||
|
struct session *s;
|
||||||
|
struct winlink *wl;
|
||||||
|
struct client *c;
|
||||||
|
const char *cmd, *template;
|
||||||
|
char *cause, *cp;
|
||||||
|
int idx, last, detached, cwd, fd = -1;
|
||||||
|
struct format_tree *ft;
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
if (args_has(args, 'a')) {
|
||||||
data->target = NULL;
|
wl = cmd_find_window(cmdq, args_get(args, 't'), &s);
|
||||||
data->name = NULL;
|
if (wl == NULL)
|
||||||
data->cmd = NULL;
|
return (CMD_RETURN_ERROR);
|
||||||
data->flag_insert_after = 0;
|
|
||||||
data->flag_detached = 0;
|
|
||||||
data->flag_kill = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_new_window_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|
||||||
{
|
|
||||||
struct cmd_new_window_data *data;
|
|
||||||
int opt;
|
|
||||||
|
|
||||||
self->entry->init(self, KEYC_NONE);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "adkt:n:")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'a':
|
|
||||||
data->flag_insert_after = 1;
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
data->flag_detached = 1;
|
|
||||||
break;
|
|
||||||
case 'k':
|
|
||||||
data->flag_kill = 1;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
if (data->name == NULL)
|
|
||||||
data->name = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 0 && argc != 1)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
if (argc == 1)
|
|
||||||
data->cmd = xstrdup(argv[0]);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_new_window_data *data = self->data;
|
|
||||||
struct session *s;
|
|
||||||
struct winlink *wl;
|
|
||||||
char *cmd, *cwd, *cause;
|
|
||||||
int idx, last;
|
|
||||||
|
|
||||||
if (data == NULL)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
if (data->flag_insert_after) {
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
idx = wl->idx + 1;
|
idx = wl->idx + 1;
|
||||||
|
|
||||||
/* Find the next free index. */
|
/* Find the next free index. */
|
||||||
@@ -139,8 +66,8 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (last == INT_MAX) {
|
if (last == INT_MAX) {
|
||||||
ctx->error(ctx, "no free window indexes");
|
cmdq_error(cmdq, "no free window indexes");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move everything from last - 1 to idx up a bit. */
|
/* Move everything from last - 1 to idx up a bit. */
|
||||||
@@ -150,87 +77,100 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_unlink_window(s, wl);
|
server_unlink_window(s, wl);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((idx = cmd_find_index(ctx, data->target, &s)) == -2)
|
if ((idx = cmd_find_index(cmdq, args_get(args, 't'), &s)) == -2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
detached = args_has(args, 'd');
|
||||||
|
|
||||||
|
if (args->argc == 0)
|
||||||
|
cmd = options_get_string(&s->options, "default-command");
|
||||||
|
else
|
||||||
|
cmd = args->argv[0];
|
||||||
|
|
||||||
|
if (args_has(args, 'c')) {
|
||||||
|
ft = format_create();
|
||||||
|
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
||||||
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, s->curw);
|
||||||
|
format_window_pane(ft, s->curw->window->active);
|
||||||
|
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;
|
||||||
|
|
||||||
wl = NULL;
|
wl = NULL;
|
||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
wl = winlink_find_by_index(&s->windows, idx);
|
wl = winlink_find_by_index(&s->windows, idx);
|
||||||
if (wl != NULL && data->flag_kill) {
|
if (wl != NULL && args_has(args, 'k')) {
|
||||||
/*
|
/*
|
||||||
* Can't use session_detach as it will destroy session if this
|
* Can't use session_detach as it will destroy session if this
|
||||||
* makes it empty.
|
* makes it empty.
|
||||||
*/
|
*/
|
||||||
|
notify_window_unlinked(s, wl->window);
|
||||||
wl->flags &= ~WINLINK_ALERTFLAGS;
|
wl->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
winlink_stack_remove(&s->lastw, wl);
|
winlink_stack_remove(&s->lastw, wl);
|
||||||
winlink_remove(&s->windows, wl);
|
winlink_remove(&s->windows, wl);
|
||||||
|
|
||||||
/* Force select/redraw if current. */
|
/* Force select/redraw if current. */
|
||||||
if (wl == s->curw) {
|
if (wl == s->curw) {
|
||||||
data->flag_detached = 0;
|
detached = 0;
|
||||||
s->curw = NULL;
|
s->curw = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = data->cmd;
|
|
||||||
if (cmd == NULL)
|
|
||||||
cmd = options_get_string(&s->options, "default-command");
|
|
||||||
cwd = options_get_string(&s->options, "default-path");
|
|
||||||
if (*cwd == '\0') {
|
|
||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
|
||||||
cwd = ctx->cmdclient->cwd;
|
|
||||||
else
|
|
||||||
cwd = s->cwd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
idx = -1 - options_get_number(&s->options, "base-index");
|
idx = -1 - options_get_number(&s->options, "base-index");
|
||||||
wl = session_new(s, data->name, cmd, cwd, idx, &cause);
|
wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause);
|
||||||
if (wl == NULL) {
|
if (wl == NULL) {
|
||||||
ctx->error(ctx, "create window failed: %s", cause);
|
cmdq_error(cmdq, "create window failed: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
goto error;
|
||||||
}
|
}
|
||||||
if (!data->flag_detached) {
|
if (!detached) {
|
||||||
session_select(s, wl->idx);
|
session_select(s, wl->idx);
|
||||||
server_redraw_session_group(s);
|
server_redraw_session_group(s);
|
||||||
} else
|
} else
|
||||||
server_status_session_group(s);
|
server_status_session_group(s);
|
||||||
|
|
||||||
return (0);
|
if (args_has(args, 'P')) {
|
||||||
}
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = NEW_WINDOW_TEMPLATE;
|
||||||
void
|
|
||||||
cmd_new_window_free(struct cmd *self)
|
ft = format_create();
|
||||||
{
|
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
||||||
struct cmd_new_window_data *data = self->data;
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
if (data->target != NULL)
|
format_winlink(ft, s, wl);
|
||||||
xfree(data->target);
|
format_window_pane(ft, wl->window->active);
|
||||||
if (data->name != NULL)
|
|
||||||
xfree(data->name);
|
cp = format_expand(ft, template);
|
||||||
if (data->cmd != NULL)
|
cmdq_print(cmdq, "%s", cp);
|
||||||
xfree(data->cmd);
|
free(cp);
|
||||||
xfree(data);
|
|
||||||
}
|
format_free(ft);
|
||||||
|
}
|
||||||
size_t
|
|
||||||
cmd_new_window_print(struct cmd *self, char *buf, size_t len)
|
if (fd != -1)
|
||||||
{
|
close(fd);
|
||||||
struct cmd_new_window_data *data = self->data;
|
return (CMD_RETURN_NORMAL);
|
||||||
size_t off = 0;
|
|
||||||
|
error:
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
if (fd != -1)
|
||||||
if (data == NULL)
|
close(fd);
|
||||||
return (off);
|
return (CMD_RETURN_ERROR);
|
||||||
if (off < len && data->flag_detached)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -d");
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->name != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -n ", data->name);
|
|
||||||
if (off < len && data->cmd != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->cmd);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
/* $Id: cmd-next-layout.c,v 1.6 2009-11-14 17:56:39 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Switch window to next layout.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_next_layout_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_next_layout_entry = {
|
|
||||||
"next-layout", "nextl",
|
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
|
||||||
0, "",
|
|
||||||
cmd_target_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_next_layout_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_next_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct winlink *wl;
|
|
||||||
u_int layout;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
layout = layout_set_next(wl->window);
|
|
||||||
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
/* $Id: cmd-next-window.c,v 1.21 2009-11-14 17:56:39 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Move to next window.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void cmd_next_window_init(struct cmd *, int);
|
|
||||||
int cmd_next_window_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_next_window_entry = {
|
|
||||||
"next-window", "next",
|
|
||||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
|
||||||
0, "a",
|
|
||||||
cmd_next_window_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_next_window_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_next_window_init(struct cmd *self, int key)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data;
|
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
if (key == ('n' | KEYC_ESCAPE))
|
|
||||||
cmd_set_flag(&data->chflags, 'a');
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_next_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct session *s;
|
|
||||||
int activity;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
activity = 0;
|
|
||||||
if (cmd_check_flag(data->chflags, 'a'))
|
|
||||||
activity = 1;
|
|
||||||
|
|
||||||
if (session_next(s, activity) == 0)
|
|
||||||
server_redraw_session(s);
|
|
||||||
else {
|
|
||||||
ctx->error(ctx, "no next window");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-paste-buffer.c,v 1.29 2010-08-11 22:17:32 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -27,196 +27,75 @@
|
|||||||
* Paste paste buffer if present.
|
* Paste paste buffer if present.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct cmd_paste_buffer_data {
|
enum cmd_retval cmd_paste_buffer_exec(struct cmd *, struct cmd_q *);
|
||||||
char *target;
|
|
||||||
int buffer;
|
|
||||||
|
|
||||||
int flag_delete;
|
void cmd_paste_buffer_filter(struct window_pane *,
|
||||||
char *sepstr;
|
const char *, size_t, const char *, int);
|
||||||
};
|
|
||||||
|
|
||||||
void cmd_paste_buffer_init(struct cmd *, int);
|
|
||||||
int cmd_paste_buffer_parse(struct cmd *, int, char **, char **);
|
|
||||||
int cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_paste_buffer_filter(
|
|
||||||
struct window_pane *, const char *, size_t, char *);
|
|
||||||
void cmd_paste_buffer_free(struct cmd *);
|
|
||||||
size_t cmd_paste_buffer_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_paste_buffer_entry = {
|
const struct cmd_entry cmd_paste_buffer_entry = {
|
||||||
"paste-buffer", "pasteb",
|
"paste-buffer", "pasteb",
|
||||||
"[-dr] [-s separator] [-b buffer-index] [-t target-pane]",
|
"db:prs:t:", 0, 0,
|
||||||
0, "",
|
"[-dpr] [-s separator] [-b buffer-index] " CMD_TARGET_PANE_USAGE,
|
||||||
cmd_paste_buffer_init,
|
0,
|
||||||
cmd_paste_buffer_parse,
|
NULL,
|
||||||
cmd_paste_buffer_exec,
|
cmd_paste_buffer_exec
|
||||||
cmd_paste_buffer_free,
|
|
||||||
cmd_paste_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
enum cmd_retval
|
||||||
void
|
cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
cmd_paste_buffer_init(struct cmd *self, unused int arg)
|
|
||||||
{
|
{
|
||||||
struct cmd_paste_buffer_data *data;
|
struct args *args = self->args;
|
||||||
|
struct window_pane *wp;
|
||||||
|
struct session *s;
|
||||||
|
struct paste_buffer *pb;
|
||||||
|
const char *sepstr;
|
||||||
|
char *cause;
|
||||||
|
int buffer;
|
||||||
|
int pflag;
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
if (cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp) == NULL)
|
||||||
data->target = NULL;
|
return (CMD_RETURN_ERROR);
|
||||||
data->buffer = -1;
|
|
||||||
data->flag_delete = 0;
|
|
||||||
data->sepstr = xstrdup("\r");
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
if (!args_has(args, 'b'))
|
||||||
cmd_paste_buffer_parse(struct cmd *self, int argc, char **argv, char **cause)
|
buffer = -1;
|
||||||
{
|
|
||||||
struct cmd_paste_buffer_data *data;
|
|
||||||
int opt, n;
|
|
||||||
const char *errstr;
|
|
||||||
|
|
||||||
cmd_paste_buffer_init(self, 0);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "b:ds:t:r")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'b':
|
|
||||||
if (data->buffer == -1) {
|
|
||||||
n = strtonum(optarg, 0, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "buffer %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
data->buffer = n;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
data->flag_delete = 1;
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
if (data->sepstr != NULL)
|
|
||||||
xfree(data->sepstr);
|
|
||||||
data->sepstr = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
if (data->sepstr != NULL)
|
|
||||||
xfree(data->sepstr);
|
|
||||||
data->sepstr = xstrdup("\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
error:
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_paste_buffer_data *data = self->data;
|
|
||||||
struct window_pane *wp;
|
|
||||||
struct session *s;
|
|
||||||
struct paste_buffer *pb;
|
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, data->target, &s, &wp) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (data->buffer == -1)
|
|
||||||
pb = paste_get_top(&s->buffers);
|
|
||||||
else {
|
else {
|
||||||
if ((pb = paste_get_index(&s->buffers, data->buffer)) == NULL) {
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
if (cause != NULL) {
|
||||||
return (-1);
|
cmdq_error(cmdq, "buffer %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb != NULL)
|
if (buffer == -1)
|
||||||
cmd_paste_buffer_filter(wp, pb->data, pb->size, data->sepstr);
|
pb = paste_get_top(&global_buffers);
|
||||||
|
else {
|
||||||
|
pb = paste_get_index(&global_buffers, buffer);
|
||||||
|
if (pb == NULL) {
|
||||||
|
cmdq_error(cmdq, "no buffer %d", buffer);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pb != NULL) {
|
||||||
|
sepstr = args_get(args, 's');
|
||||||
|
if (sepstr == NULL) {
|
||||||
|
if (args_has(args, 'r'))
|
||||||
|
sepstr = "\n";
|
||||||
|
else
|
||||||
|
sepstr = "\r";
|
||||||
|
}
|
||||||
|
pflag = (wp->screen->mode & MODE_BRACKETPASTE);
|
||||||
|
paste_send_pane(pb, wp, sepstr, args_has(args, 'p') && pflag);
|
||||||
|
}
|
||||||
|
|
||||||
/* Delete the buffer if -d. */
|
/* Delete the buffer if -d. */
|
||||||
if (data->flag_delete) {
|
if (args_has(args, 'd')) {
|
||||||
if (data->buffer == -1)
|
if (buffer == -1)
|
||||||
paste_free_top(&s->buffers);
|
paste_free_top(&global_buffers);
|
||||||
else
|
else
|
||||||
paste_free_index(&s->buffers, data->buffer);
|
paste_free_index(&global_buffers, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
|
||||||
|
|
||||||
/* Add bytes to a buffer and filter '\n' according to separator. */
|
|
||||||
void
|
|
||||||
cmd_paste_buffer_filter(
|
|
||||||
struct window_pane *wp, const char *data, size_t size, char *sep)
|
|
||||||
{
|
|
||||||
const char *end = data + size;
|
|
||||||
const char *lf;
|
|
||||||
size_t seplen;
|
|
||||||
|
|
||||||
seplen = strlen(sep);
|
|
||||||
while ((lf = memchr(data, '\n', end - data)) != NULL) {
|
|
||||||
if (lf != data)
|
|
||||||
bufferevent_write(wp->event, data, lf - data);
|
|
||||||
bufferevent_write(wp->event, sep, seplen);
|
|
||||||
data = lf + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (end != data)
|
|
||||||
bufferevent_write(wp->event, data, end - data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_paste_buffer_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_paste_buffer_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
if (data->sepstr != NULL)
|
|
||||||
xfree(data->sepstr);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_paste_buffer_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_paste_buffer_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
char tmp[BUFSIZ];
|
|
||||||
int r_flag;
|
|
||||||
|
|
||||||
r_flag = 0;
|
|
||||||
if (data->sepstr != NULL)
|
|
||||||
r_flag = (data->sepstr[0] == '\n' && data->sepstr[1] == '\0');
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->flag_delete)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -d");
|
|
||||||
if (off < len && r_flag)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -r");
|
|
||||||
if (off < len && data->buffer != -1)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -b %d", data->buffer);
|
|
||||||
if (off < len && data->sepstr != NULL && !r_flag) {
|
|
||||||
strnvis(
|
|
||||||
tmp, data->sepstr, sizeof tmp, VIS_OCTAL|VIS_TAB|VIS_NL);
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -s ", tmp);
|
|
||||||
}
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-pipe-pane.c,v 1.15 2010-10-24 00:45:57 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,35 +31,31 @@
|
|||||||
* Open pipe to redirect pane output. If already open, close first.
|
* Open pipe to redirect pane output. If already open, close first.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_pipe_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
|
void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_pipe_pane_entry = {
|
const struct cmd_entry cmd_pipe_pane_entry = {
|
||||||
"pipe-pane", "pipep",
|
"pipe-pane", "pipep",
|
||||||
CMD_TARGET_PANE_USAGE "[-o] [command]",
|
"ot:", 0, 1,
|
||||||
CMD_ARG01, "o",
|
"[-o] " CMD_TARGET_PANE_USAGE " [command]",
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_pipe_pane_exec,
|
cmd_pipe_pane_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
char *command;
|
char *command;
|
||||||
int old_fd, pipe_fd[2], null_fd, mode;
|
int old_fd, pipe_fd[2], null_fd;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, NULL)) == NULL)
|
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
c = cmd_find_client(cmdq, NULL, 1);
|
||||||
if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
/* Destroy the old pipe. */
|
/* Destroy the old pipe. */
|
||||||
old_fd = wp->pipe_fd;
|
old_fd = wp->pipe_fd;
|
||||||
@@ -70,8 +66,8 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If no pipe command, that is enough. */
|
/* If no pipe command, that is enough. */
|
||||||
if (data->arg == NULL || *data->arg == '\0')
|
if (args->argc == 0 || *args->argv[0] == '\0')
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* With -o, only open the new pipe if there was no previous one. This
|
* With -o, only open the new pipe if there was no previous one. This
|
||||||
@@ -79,20 +75,20 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
*
|
*
|
||||||
* bind ^p pipep -o 'cat >>~/output'
|
* bind ^p pipep -o 'cat >>~/output'
|
||||||
*/
|
*/
|
||||||
if (cmd_check_flag(data->chflags, 'o') && old_fd != -1)
|
if (args_has(self->args, 'o') && old_fd != -1)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
/* Open the new pipe. */
|
/* Open the new pipe. */
|
||||||
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_fd) != 0) {
|
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_fd) != 0) {
|
||||||
ctx->error(ctx, "socketpair error: %s", strerror(errno));
|
cmdq_error(cmdq, "socketpair error: %s", strerror(errno));
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fork the child. */
|
/* Fork the child. */
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
ctx->error(ctx, "fork error: %s", strerror(errno));
|
cmdq_error(cmdq, "fork error: %s", strerror(errno));
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
case 0:
|
case 0:
|
||||||
/* Child process. */
|
/* Child process. */
|
||||||
close(pipe_fd[0]);
|
close(pipe_fd[0]);
|
||||||
@@ -113,7 +109,8 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
closefrom(STDERR_FILENO + 1);
|
closefrom(STDERR_FILENO + 1);
|
||||||
|
|
||||||
command = status_replace(c, NULL, data->arg, time(NULL), 0);
|
command = status_replace(
|
||||||
|
c, NULL, NULL, NULL, args->argv[0], time(NULL), 0);
|
||||||
execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL);
|
execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
default:
|
default:
|
||||||
@@ -127,15 +124,11 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
NULL, NULL, cmd_pipe_pane_error_callback, wp);
|
NULL, NULL, cmd_pipe_pane_error_callback, wp);
|
||||||
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
||||||
|
|
||||||
if ((mode = fcntl(wp->pipe_fd, F_GETFL)) == -1)
|
setblocking(wp->pipe_fd, 0);
|
||||||
fatal("fcntl failed");
|
return (CMD_RETURN_NORMAL);
|
||||||
if (fcntl(wp->pipe_fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
|
||||||
fatal("fcntl failed");
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
|
||||||
void
|
void
|
||||||
cmd_pipe_pane_error_callback(
|
cmd_pipe_pane_error_callback(
|
||||||
unused struct bufferevent *bufev, unused short what, void *data)
|
unused struct bufferevent *bufev, unused short what, void *data)
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
/* $Id: cmd-previous-layout.c,v 1.6 2009-12-04 22:14:47 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Switch window to previous layout.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_previous_layout_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_previous_layout_entry = {
|
|
||||||
"previous-layout", "prevl",
|
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
|
||||||
0, "",
|
|
||||||
cmd_target_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_previous_layout_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_previous_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct winlink *wl;
|
|
||||||
u_int layout;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
layout = layout_set_previous(wl->window);
|
|
||||||
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
/* $Id: cmd-previous-window.c,v 1.21 2009-11-14 17:56:39 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Move to previous window.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void cmd_previous_window_init(struct cmd *, int);
|
|
||||||
int cmd_previous_window_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_previous_window_entry = {
|
|
||||||
"previous-window", "prev",
|
|
||||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
|
||||||
0, "a",
|
|
||||||
cmd_previous_window_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_previous_window_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_previous_window_init(struct cmd *self, int key)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data;
|
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
if (key == ('p' | KEYC_ESCAPE))
|
|
||||||
cmd_set_flag(&data->chflags, 'a');
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_previous_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct session *s;
|
|
||||||
int activity;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
activity = 0;
|
|
||||||
if (cmd_check_flag(data->chflags, 'a'))
|
|
||||||
activity = 1;
|
|
||||||
|
|
||||||
if (session_previous(s, activity) == 0)
|
|
||||||
server_redraw_session(s);
|
|
||||||
else {
|
|
||||||
ctx->error(ctx, "no previous window");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
recalculate_sizes();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
281
cmd-queue.c
Normal file
281
cmd-queue.c
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013 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 <time.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/* Create new command queue. */
|
||||||
|
struct cmd_q *
|
||||||
|
cmdq_new(struct client *c)
|
||||||
|
{
|
||||||
|
struct cmd_q *cmdq;
|
||||||
|
|
||||||
|
cmdq = xcalloc(1, sizeof *cmdq);
|
||||||
|
cmdq->references = 1;
|
||||||
|
cmdq->dead = 0;
|
||||||
|
|
||||||
|
cmdq->client = c;
|
||||||
|
cmdq->client_exit = -1;
|
||||||
|
|
||||||
|
TAILQ_INIT(&cmdq->queue);
|
||||||
|
cmdq->item = NULL;
|
||||||
|
cmdq->cmd = NULL;
|
||||||
|
|
||||||
|
return (cmdq);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free command queue */
|
||||||
|
int
|
||||||
|
cmdq_free(struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
if (--cmdq->references != 0)
|
||||||
|
return (cmdq->dead);
|
||||||
|
|
||||||
|
cmdq_flush(cmdq);
|
||||||
|
free(cmdq);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show message from command. */
|
||||||
|
void printflike2
|
||||||
|
cmdq_print(struct cmd_q *cmdq, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
struct client *c = cmdq->client;
|
||||||
|
struct window *w;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
window_copy_vadd(w->active, fmt, ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show info from command. */
|
||||||
|
void printflike2
|
||||||
|
cmdq_info(struct cmd_q *cmdq, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
struct client *c = cmdq->client;
|
||||||
|
va_list ap;
|
||||||
|
char *msg;
|
||||||
|
|
||||||
|
if (options_get_number(&global_options, "quiet"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
|
||||||
|
if (c == NULL)
|
||||||
|
/* nothing */;
|
||||||
|
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
||||||
|
evbuffer_add_vprintf(c->stdout_data, fmt, ap);
|
||||||
|
|
||||||
|
evbuffer_add(c->stdout_data, "\n", 1);
|
||||||
|
server_push_stdout(c);
|
||||||
|
} else {
|
||||||
|
xvasprintf(&msg, fmt, ap);
|
||||||
|
*msg = toupper((u_char) *msg);
|
||||||
|
status_message_set(c, "%s", msg);
|
||||||
|
free(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show error from command. */
|
||||||
|
void printflike2
|
||||||
|
cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
struct client *c = cmdq->client;
|
||||||
|
struct cmd *cmd = cmdq->cmd;
|
||||||
|
va_list ap;
|
||||||
|
char *msg, *cause;
|
||||||
|
size_t msglen;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
msglen = xvasprintf(&msg, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (c == NULL) {
|
||||||
|
xasprintf(&cause, "%s:%u: %s", cmd->file, cmd->line, msg);
|
||||||
|
ARRAY_ADD(&cfg_causes, cause);
|
||||||
|
} 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);
|
||||||
|
c->retval = 1;
|
||||||
|
} else {
|
||||||
|
*msg = toupper((u_char) *msg);
|
||||||
|
status_message_set(c, "%s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print a guard line. */
|
||||||
|
int
|
||||||
|
cmdq_guard(struct cmd_q *cmdq, const char *guard, int flags)
|
||||||
|
{
|
||||||
|
struct client *c = cmdq->client;
|
||||||
|
|
||||||
|
if (c == NULL)
|
||||||
|
return 0;
|
||||||
|
if (!(c->flags & CLIENT_CONTROL))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u %d\n", guard,
|
||||||
|
(long) cmdq->time, cmdq->number, flags);
|
||||||
|
server_push_stdout(c);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add command list to queue and begin processing if needed. */
|
||||||
|
void
|
||||||
|
cmdq_run(struct cmd_q *cmdq, struct cmd_list *cmdlist)
|
||||||
|
{
|
||||||
|
cmdq_append(cmdq, cmdlist);
|
||||||
|
|
||||||
|
if (cmdq->item == NULL) {
|
||||||
|
cmdq->cmd = NULL;
|
||||||
|
cmdq_continue(cmdq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add command list to queue. */
|
||||||
|
void
|
||||||
|
cmdq_append(struct cmd_q *cmdq, struct cmd_list *cmdlist)
|
||||||
|
{
|
||||||
|
struct cmd_q_item *item;
|
||||||
|
|
||||||
|
item = xcalloc(1, sizeof *item);
|
||||||
|
item->cmdlist = cmdlist;
|
||||||
|
TAILQ_INSERT_TAIL(&cmdq->queue, item, qentry);
|
||||||
|
cmdlist->references++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Continue processing command queue. Returns 1 if finishes empty. */
|
||||||
|
int
|
||||||
|
cmdq_continue(struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct cmd_q_item *next;
|
||||||
|
enum cmd_retval retval;
|
||||||
|
int empty, guard, flags;
|
||||||
|
char s[1024];
|
||||||
|
|
||||||
|
notify_disable();
|
||||||
|
|
||||||
|
empty = TAILQ_EMPTY(&cmdq->queue);
|
||||||
|
if (empty)
|
||||||
|
goto empty;
|
||||||
|
|
||||||
|
if (cmdq->item == NULL) {
|
||||||
|
cmdq->item = TAILQ_FIRST(&cmdq->queue);
|
||||||
|
cmdq->cmd = TAILQ_FIRST(&cmdq->item->cmdlist->list);
|
||||||
|
} else
|
||||||
|
cmdq->cmd = TAILQ_NEXT(cmdq->cmd, qentry);
|
||||||
|
|
||||||
|
do {
|
||||||
|
next = TAILQ_NEXT(cmdq->item, qentry);
|
||||||
|
|
||||||
|
while (cmdq->cmd != NULL) {
|
||||||
|
cmd_print(cmdq->cmd, s, sizeof s);
|
||||||
|
log_debug("cmdq %p: %s (client %d)", cmdq, s,
|
||||||
|
cmdq->client != NULL ? cmdq->client->ibuf.fd : -1);
|
||||||
|
|
||||||
|
cmdq->time = time(NULL);
|
||||||
|
cmdq->number++;
|
||||||
|
|
||||||
|
flags = !!(cmdq->cmd->flags & CMD_CONTROL);
|
||||||
|
guard = cmdq_guard(cmdq, "begin", flags);
|
||||||
|
|
||||||
|
retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq);
|
||||||
|
|
||||||
|
if (guard) {
|
||||||
|
if (retval == CMD_RETURN_ERROR)
|
||||||
|
cmdq_guard(cmdq, "error", flags);
|
||||||
|
else
|
||||||
|
cmdq_guard(cmdq, "end", flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retval == CMD_RETURN_ERROR)
|
||||||
|
break;
|
||||||
|
if (retval == CMD_RETURN_WAIT)
|
||||||
|
goto out;
|
||||||
|
if (retval == CMD_RETURN_STOP) {
|
||||||
|
cmdq_flush(cmdq);
|
||||||
|
goto empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdq->cmd = TAILQ_NEXT(cmdq->cmd, qentry);
|
||||||
|
}
|
||||||
|
|
||||||
|
TAILQ_REMOVE(&cmdq->queue, cmdq->item, qentry);
|
||||||
|
cmd_list_free(cmdq->item->cmdlist);
|
||||||
|
free(cmdq->item);
|
||||||
|
|
||||||
|
cmdq->item = next;
|
||||||
|
if (cmdq->item != NULL)
|
||||||
|
cmdq->cmd = TAILQ_FIRST(&cmdq->item->cmdlist->list);
|
||||||
|
} while (cmdq->item != NULL);
|
||||||
|
|
||||||
|
empty:
|
||||||
|
if (cmdq->client_exit > 0)
|
||||||
|
cmdq->client->flags |= CLIENT_EXIT;
|
||||||
|
if (cmdq->emptyfn != NULL)
|
||||||
|
cmdq->emptyfn(cmdq); /* may free cmdq */
|
||||||
|
empty = 1;
|
||||||
|
|
||||||
|
out:
|
||||||
|
notify_enable();
|
||||||
|
return (empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Flush command queue. */
|
||||||
|
void
|
||||||
|
cmdq_flush(struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct cmd_q_item *item, *item1;
|
||||||
|
|
||||||
|
TAILQ_FOREACH_SAFE(item, &cmdq->queue, qentry, item1) {
|
||||||
|
TAILQ_REMOVE(&cmdq->queue, item, qentry);
|
||||||
|
cmd_list_free(item->cmdlist);
|
||||||
|
free(item);
|
||||||
|
}
|
||||||
|
cmdq->item = NULL;
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-refresh-client.c,v 1.11 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,29 +24,53 @@
|
|||||||
* Refresh client.
|
* Refresh client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_refresh_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_refresh_client_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_refresh_client_entry = {
|
const struct cmd_entry cmd_refresh_client_entry = {
|
||||||
"refresh-client", "refresh",
|
"refresh-client", "refresh",
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
"C:St:", 0, 0,
|
||||||
0, "",
|
"[-S] [-C size] " CMD_TARGET_CLIENT_USAGE,
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_refresh_client_exec,
|
cmd_refresh_client_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_refresh_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_refresh_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
const char *size;
|
||||||
|
u_int w, h;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
server_redraw_client(c);
|
if (args_has(args, 'C')) {
|
||||||
|
if ((size = args_get(args, 'C')) == NULL) {
|
||||||
|
cmdq_error(cmdq, "missing size");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (sscanf(size, "%u,%u", &w, &h) != 2) {
|
||||||
|
cmdq_error(cmdq, "bad size argument");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
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))
|
||||||
|
recalculate_sizes();
|
||||||
|
} else if (args_has(args, 'S')) {
|
||||||
|
status_update_jobs(c);
|
||||||
|
server_status_client(c);
|
||||||
|
} else
|
||||||
|
server_redraw_client(c);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-rename-session.c,v 1.21 2010-12-22 15:36:44 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,39 +26,44 @@
|
|||||||
* Change session name.
|
* Change session name.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_rename_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_rename_session_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rename_session_entry = {
|
const struct cmd_entry cmd_rename_session_entry = {
|
||||||
"rename-session", "rename",
|
"rename-session", "rename",
|
||||||
|
"t:", 1, 1,
|
||||||
CMD_TARGET_SESSION_USAGE " new-name",
|
CMD_TARGET_SESSION_USAGE " new-name",
|
||||||
CMD_ARG1, "",
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_rename_session_exec
|
||||||
cmd_rename_session_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rename_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
const char *newname;
|
||||||
|
|
||||||
if (data->arg != NULL && session_find(data->arg) != NULL) {
|
newname = args->argv[0];
|
||||||
ctx->error(ctx, "duplicate session: %s", data->arg);
|
if (!session_check_name(newname)) {
|
||||||
return (-1);
|
cmdq_error(cmdq, "bad session name: %s", newname);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (session_find(newname) != NULL) {
|
||||||
|
cmdq_error(cmdq, "duplicate session: %s", newname);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
RB_REMOVE(sessions, &sessions, s);
|
RB_REMOVE(sessions, &sessions, s);
|
||||||
xfree(s->name);
|
free(s->name);
|
||||||
s->name = xstrdup(data->arg);
|
s->name = xstrdup(newname);
|
||||||
RB_INSERT(sessions, &sessions, s);
|
RB_INSERT(sessions, &sessions, s);
|
||||||
|
|
||||||
server_status_session(s);
|
server_status_session(s);
|
||||||
|
notify_session_renamed(s);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-rename-window.c,v 1.31 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,34 +26,31 @@
|
|||||||
* Rename a window.
|
* Rename a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_rename_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_rename_window_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rename_window_entry = {
|
const struct cmd_entry cmd_rename_window_entry = {
|
||||||
"rename-window", "renamew",
|
"rename-window", "renamew",
|
||||||
|
"t:", 1, 1,
|
||||||
CMD_TARGET_WINDOW_USAGE " new-name",
|
CMD_TARGET_WINDOW_USAGE " new-name",
|
||||||
CMD_ARG1, "",
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_rename_window_exec
|
||||||
cmd_rename_window_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rename_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
xfree(wl->window->name);
|
window_set_name(wl->window, args->argv[0]);
|
||||||
wl->window->name = xstrdup(data->arg);
|
|
||||||
options_set_number(&wl->window->options, "automatic-rename", 0);
|
options_set_number(&wl->window->options, "automatic-rename", 0);
|
||||||
|
|
||||||
server_status_window(wl->window);
|
server_status_window(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-resize-pane.c,v 1.14 2009-12-04 22:14:47 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,86 +26,131 @@
|
|||||||
* Increase or decrease pane size.
|
* Increase or decrease pane size.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_resize_pane_init(struct cmd *, int);
|
void cmd_resize_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_resize_pane_entry = {
|
const struct cmd_entry cmd_resize_pane_entry = {
|
||||||
"resize-pane", "resizep",
|
"resize-pane", "resizep",
|
||||||
"[-DLRU] " CMD_TARGET_PANE_USAGE " [adjustment]",
|
"DLRt:Ux:y:Z", 0, 1,
|
||||||
CMD_ARG01, "DLRU",
|
"[-DLRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " [adjustment]",
|
||||||
cmd_resize_pane_init,
|
0,
|
||||||
cmd_target_parse,
|
cmd_resize_pane_key_binding,
|
||||||
cmd_resize_pane_exec,
|
cmd_resize_pane_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_resize_pane_init(struct cmd *self, int key)
|
cmd_resize_pane_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data;
|
switch (key) {
|
||||||
|
case KEYC_UP | KEYC_CTRL:
|
||||||
cmd_target_init(self, key);
|
self->args = args_create(0);
|
||||||
data = self->data;
|
args_set(self->args, 'U', NULL);
|
||||||
|
break;
|
||||||
if (key == (KEYC_UP | KEYC_CTRL))
|
case KEYC_DOWN | KEYC_CTRL:
|
||||||
cmd_set_flag(&data->chflags, 'U');
|
self->args = args_create(0);
|
||||||
if (key == (KEYC_DOWN | KEYC_CTRL))
|
args_set(self->args, 'D', NULL);
|
||||||
cmd_set_flag(&data->chflags, 'D');
|
break;
|
||||||
if (key == (KEYC_LEFT | KEYC_CTRL))
|
case KEYC_LEFT | KEYC_CTRL:
|
||||||
cmd_set_flag(&data->chflags, 'L');
|
self->args = args_create(0);
|
||||||
if (key == (KEYC_RIGHT | KEYC_CTRL))
|
args_set(self->args, 'L', NULL);
|
||||||
cmd_set_flag(&data->chflags, 'R');
|
break;
|
||||||
|
case KEYC_RIGHT | KEYC_CTRL:
|
||||||
if (key == (KEYC_UP | KEYC_ESCAPE)) {
|
self->args = args_create(0);
|
||||||
cmd_set_flag(&data->chflags, 'U');
|
args_set(self->args, 'R', NULL);
|
||||||
data->arg = xstrdup("5");
|
break;
|
||||||
}
|
case KEYC_UP | KEYC_ESCAPE:
|
||||||
if (key == (KEYC_DOWN | KEYC_ESCAPE)) {
|
self->args = args_create(1, "5");
|
||||||
cmd_set_flag(&data->chflags, 'D');
|
args_set(self->args, 'U', NULL);
|
||||||
data->arg = xstrdup("5");
|
break;
|
||||||
}
|
case KEYC_DOWN | KEYC_ESCAPE:
|
||||||
if (key == (KEYC_LEFT | KEYC_ESCAPE)) {
|
self->args = args_create(1, "5");
|
||||||
cmd_set_flag(&data->chflags, 'L');
|
args_set(self->args, 'D', NULL);
|
||||||
data->arg = xstrdup("5");
|
break;
|
||||||
}
|
case KEYC_LEFT | KEYC_ESCAPE:
|
||||||
if (key == (KEYC_RIGHT | KEYC_ESCAPE)) {
|
self->args = args_create(1, "5");
|
||||||
cmd_set_flag(&data->chflags, 'R');
|
args_set(self->args, 'L', NULL);
|
||||||
data->arg = xstrdup("5");
|
break;
|
||||||
|
case KEYC_RIGHT | KEYC_ESCAPE:
|
||||||
|
self->args = args_create(1, "5");
|
||||||
|
args_set(self->args, 'R', NULL);
|
||||||
|
break;
|
||||||
|
case 'z':
|
||||||
|
self->args = args_create(0);
|
||||||
|
args_set(self->args, 'Z', NULL);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
self->args = args_create(0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
struct window *w;
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
|
char *cause;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
u_int adjust;
|
u_int adjust;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, data->target, NULL, &wp)) == NULL)
|
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
w = wl->window;
|
||||||
|
|
||||||
if (data->arg == NULL)
|
if (args_has(args, 'Z')) {
|
||||||
|
if (w->flags & WINDOW_ZOOMED)
|
||||||
|
window_unzoom(w);
|
||||||
|
else
|
||||||
|
window_zoom(wp);
|
||||||
|
server_redraw_window(w);
|
||||||
|
server_status_window(w);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
server_unzoom_window(w);
|
||||||
|
|
||||||
|
if (args->argc == 0)
|
||||||
adjust = 1;
|
adjust = 1;
|
||||||
else {
|
else {
|
||||||
adjust = strtonum(data->arg, 1, INT_MAX, &errstr);
|
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
ctx->error(ctx, "adjustment %s: %s", errstr, data->arg);
|
cmdq_error(cmdq, "adjustment %s", errstr);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'L'))
|
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);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(self->args, 'L'))
|
||||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
|
||||||
else if (cmd_check_flag(data->chflags, 'R'))
|
else if (args_has(self->args, 'R'))
|
||||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust);
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust);
|
||||||
else if (cmd_check_flag(data->chflags, 'U'))
|
else if (args_has(self->args, 'U'))
|
||||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust);
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust);
|
||||||
else if (cmd_check_flag(data->chflags, 'D'))
|
else if (args_has(self->args, 'D'))
|
||||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
91
cmd-respawn-pane.c
Normal file
91
cmd-respawn-pane.c
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
* Copyright (c) 2011 Marcel P. Partap <mpartap@gmx.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Respawn a pane (restart the command). Kill existing if -k given.
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum cmd_retval cmd_respawn_pane_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_respawn_pane_entry = {
|
||||||
|
"respawn-pane", "respawnp",
|
||||||
|
"kt:", 0, 1,
|
||||||
|
"[-k] " CMD_TARGET_PANE_USAGE " [command]",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
cmd_respawn_pane_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct winlink *wl;
|
||||||
|
struct window *w;
|
||||||
|
struct window_pane *wp;
|
||||||
|
struct session *s;
|
||||||
|
struct environ env;
|
||||||
|
const char *cmd;
|
||||||
|
char *cause;
|
||||||
|
u_int idx;
|
||||||
|
|
||||||
|
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
w = wl->window;
|
||||||
|
|
||||||
|
if (!args_has(self->args, 'k') && wp->fd != -1) {
|
||||||
|
if (window_pane_index(wp, &idx) != 0)
|
||||||
|
fatalx("index not found");
|
||||||
|
cmdq_error(cmdq, "pane still active: %s:%u.%u",
|
||||||
|
s->name, wl->idx, idx);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
environ_init(&env);
|
||||||
|
environ_copy(&global_environ, &env);
|
||||||
|
environ_copy(&s->environ, &env);
|
||||||
|
server_fill_environ(s, &env);
|
||||||
|
|
||||||
|
window_pane_reset_mode(wp);
|
||||||
|
screen_reinit(&wp->base);
|
||||||
|
input_init(wp);
|
||||||
|
|
||||||
|
if (args->argc != 0)
|
||||||
|
cmd = args->argv[0];
|
||||||
|
else
|
||||||
|
cmd = NULL;
|
||||||
|
if (window_pane_spawn(wp, cmd, NULL, -1, &env, s->tio, &cause) != 0) {
|
||||||
|
cmdq_error(cmdq, "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);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-respawn-window.c,v 1.25 2009-12-04 22:14:47 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -26,41 +27,40 @@
|
|||||||
* Respawn a window (restart the command). Kill existing if -k given.
|
* Respawn a window (restart the command). Kill existing if -k given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_respawn_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_respawn_window_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_respawn_window_entry = {
|
const struct cmd_entry cmd_respawn_window_entry = {
|
||||||
"respawn-window", "respawnw",
|
"respawn-window", "respawnw",
|
||||||
|
"kt:", 0, 1,
|
||||||
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
|
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
|
||||||
CMD_ARG01, "k",
|
0,
|
||||||
cmd_target_init,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_respawn_window_exec
|
||||||
cmd_respawn_window_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct environ env;
|
struct environ env;
|
||||||
|
const char *cmd;
|
||||||
char *cause;
|
char *cause;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (!cmd_check_flag(data->chflags, 'k')) {
|
if (!args_has(self->args, 'k')) {
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
if (wp->fd == -1)
|
if (wp->fd == -1)
|
||||||
continue;
|
continue;
|
||||||
ctx->error(ctx,
|
cmdq_error(cmdq,
|
||||||
"window still active: %s:%d", s->name, wl->idx);
|
"window still active: %s:%d", s->name, wl->idx);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,21 +75,26 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
window_destroy_panes(w);
|
window_destroy_panes(w);
|
||||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||||
window_pane_resize(wp, w->sx, w->sy);
|
window_pane_resize(wp, w->sx, w->sy);
|
||||||
if (window_pane_spawn(
|
if (args->argc != 0)
|
||||||
wp, data->arg, NULL, NULL, &env, s->tio, &cause) != 0) {
|
cmd = args->argv[0];
|
||||||
ctx->error(ctx, "respawn window failed: %s", cause);
|
else
|
||||||
xfree(cause);
|
cmd = NULL;
|
||||||
|
if (window_pane_spawn(wp, cmd, NULL, -1, &env, s->tio, &cause) != 0) {
|
||||||
|
cmdq_error(cmdq, "respawn window failed: %s", cause);
|
||||||
|
free(cause);
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
server_destroy_pane(wp);
|
server_destroy_pane(wp);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
layout_init(w);
|
layout_init(w, wp);
|
||||||
|
window_pane_reset_mode(wp);
|
||||||
screen_reinit(&wp->base);
|
screen_reinit(&wp->base);
|
||||||
|
input_init(wp);
|
||||||
window_set_active_pane(w, wp);
|
window_set_active_pane(w, wp);
|
||||||
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
|
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-rotate-window.c,v 1.10 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,47 +24,41 @@
|
|||||||
* Rotate the panes in a window.
|
* Rotate the panes in a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_rotate_window_init(struct cmd *, int);
|
void cmd_rotate_window_key_binding(struct cmd *, int);
|
||||||
int cmd_rotate_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_rotate_window_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rotate_window_entry = {
|
const struct cmd_entry cmd_rotate_window_entry = {
|
||||||
"rotate-window", "rotatew",
|
"rotate-window", "rotatew",
|
||||||
|
"Dt:U", 0, 0,
|
||||||
"[-DU] " CMD_TARGET_WINDOW_USAGE,
|
"[-DU] " CMD_TARGET_WINDOW_USAGE,
|
||||||
0, "DU",
|
0,
|
||||||
cmd_rotate_window_init,
|
cmd_rotate_window_key_binding,
|
||||||
cmd_target_parse,
|
cmd_rotate_window_exec
|
||||||
cmd_rotate_window_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_rotate_window_init(struct cmd *self, int key)
|
cmd_rotate_window_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data;
|
self->args = args_create(0);
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
if (key == ('o' | KEYC_ESCAPE))
|
if (key == ('o' | KEYC_ESCAPE))
|
||||||
cmd_set_flag(&data->chflags, 'D');
|
args_set(self->args, 'D', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rotate_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
struct window_pane *wp, *wp2;
|
struct window_pane *wp, *wp2;
|
||||||
struct layout_cell *lc;
|
struct layout_cell *lc;
|
||||||
u_int sx, sy, xoff, yoff;
|
u_int sx, sy, xoff, yoff;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'D')) {
|
if (args_has(self->args, 'D')) {
|
||||||
wp = TAILQ_LAST(&w->panes, window_panes);
|
wp = TAILQ_LAST(&w->panes, window_panes);
|
||||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||||
@@ -120,5 +114,5 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
132
cmd-run-shell.c
132
cmd-run-shell.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-run-shell.c,v 1.9 2010-08-09 21:44:25 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -28,69 +29,114 @@
|
|||||||
* Runs a command without a window.
|
* Runs a command without a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_run_shell_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_run_shell_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
void cmd_run_shell_callback(struct job *);
|
void cmd_run_shell_callback(struct job *);
|
||||||
void cmd_run_shell_free(void *);
|
void cmd_run_shell_free(void *);
|
||||||
|
void cmd_run_shell_print(struct job *, const char *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_run_shell_entry = {
|
const struct cmd_entry cmd_run_shell_entry = {
|
||||||
"run-shell", "run",
|
"run-shell", "run",
|
||||||
"command",
|
"bt:", 1, 1,
|
||||||
CMD_ARG1, "",
|
"[-b] " CMD_TARGET_PANE_USAGE " shell-command",
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_run_shell_exec,
|
cmd_run_shell_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_run_shell_data {
|
struct cmd_run_shell_data {
|
||||||
char *cmd;
|
char *cmd;
|
||||||
struct cmd_ctx ctx;
|
struct cmd_q *cmdq;
|
||||||
|
int bflag;
|
||||||
|
int wp_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
void
|
||||||
cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_run_shell_print(struct job *job, const char *msg)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct cmd_run_shell_data *cdata = job->data;
|
||||||
|
struct window_pane *wp = NULL;
|
||||||
|
|
||||||
|
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 (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);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
struct cmd_run_shell_data *cdata;
|
struct cmd_run_shell_data *cdata;
|
||||||
struct job *job;
|
char *shellcmd;
|
||||||
|
struct client *c;
|
||||||
|
struct session *s = NULL;
|
||||||
|
struct winlink *wl = NULL;
|
||||||
|
struct window_pane *wp = NULL;
|
||||||
|
struct format_tree *ft;
|
||||||
|
|
||||||
|
if (args_has(args, 't'))
|
||||||
|
wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
|
||||||
|
else {
|
||||||
|
c = cmd_find_client(cmdq, NULL, 1);
|
||||||
|
if (c != NULL && c->session != NULL) {
|
||||||
|
s = c->session;
|
||||||
|
wl = s->curw;
|
||||||
|
wp = wl->window->active;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
if (s != NULL)
|
||||||
|
format_session(ft, s);
|
||||||
|
if (s != NULL && wl != NULL)
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
if (wp != NULL)
|
||||||
|
format_window_pane(ft, wp);
|
||||||
|
shellcmd = format_expand(ft, args->argv[0]);
|
||||||
|
format_free(ft);
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
cdata->cmd = xstrdup(data->arg);
|
cdata->cmd = shellcmd;
|
||||||
memcpy(&cdata->ctx, ctx, sizeof cdata->ctx);
|
cdata->bflag = args_has(args, 'b');
|
||||||
|
cdata->wp_id = wp != NULL ? (int) wp->id : -1;
|
||||||
|
|
||||||
if (ctx->cmdclient != NULL)
|
cdata->cmdq = cmdq;
|
||||||
ctx->cmdclient->references++;
|
cmdq->references++;
|
||||||
if (ctx->curclient != NULL)
|
|
||||||
ctx->curclient->references++;
|
|
||||||
|
|
||||||
job = job_add(NULL, 0, NULL,
|
job_run(shellcmd, s, cmd_run_shell_callback, cmd_run_shell_free, cdata);
|
||||||
data->arg, cmd_run_shell_callback, cmd_run_shell_free, cdata);
|
|
||||||
job_run(job);
|
|
||||||
|
|
||||||
return (1); /* don't let client exit */
|
if (cdata->bflag)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
return (CMD_RETURN_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_run_shell_callback(struct job *job)
|
cmd_run_shell_callback(struct job *job)
|
||||||
{
|
{
|
||||||
struct cmd_run_shell_data *cdata = job->data;
|
struct cmd_run_shell_data *cdata = job->data;
|
||||||
struct cmd_ctx *ctx = &cdata->ctx;
|
struct cmd_q *cmdq = cdata->cmdq;
|
||||||
char *cmd, *msg, *line;
|
char *cmd, *msg, *line;
|
||||||
size_t size;
|
size_t size;
|
||||||
int retcode;
|
int retcode;
|
||||||
u_int lines;
|
u_int lines;
|
||||||
|
|
||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->flags & CLIENT_DEAD)
|
if (cmdq->dead)
|
||||||
return;
|
|
||||||
if (ctx->curclient != NULL && ctx->curclient->flags & CLIENT_DEAD)
|
|
||||||
return;
|
return;
|
||||||
|
cmd = cdata->cmd;
|
||||||
|
|
||||||
lines = 0;
|
lines = 0;
|
||||||
do {
|
do {
|
||||||
if ((line = evbuffer_readline(job->event->input)) != NULL) {
|
if ((line = evbuffer_readline(job->event->input)) != NULL) {
|
||||||
ctx->print(ctx, "%s", line);
|
cmd_run_shell_print(job, line);
|
||||||
|
free(line);
|
||||||
lines++;
|
lines++;
|
||||||
}
|
}
|
||||||
} while (line != NULL);
|
} while (line != NULL);
|
||||||
@@ -101,14 +147,12 @@ cmd_run_shell_callback(struct job *job)
|
|||||||
memcpy(line, EVBUFFER_DATA(job->event->input), size);
|
memcpy(line, EVBUFFER_DATA(job->event->input), size);
|
||||||
line[size] = '\0';
|
line[size] = '\0';
|
||||||
|
|
||||||
ctx->print(ctx, "%s", line);
|
cmd_run_shell_print(job, line);
|
||||||
lines++;
|
lines++;
|
||||||
|
|
||||||
xfree(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = cdata->cmd;
|
|
||||||
|
|
||||||
msg = NULL;
|
msg = NULL;
|
||||||
if (WIFEXITED(job->status)) {
|
if (WIFEXITED(job->status)) {
|
||||||
if ((retcode = WEXITSTATUS(job->status)) != 0)
|
if ((retcode = WEXITSTATUS(job->status)) != 0)
|
||||||
@@ -118,11 +162,11 @@ cmd_run_shell_callback(struct job *job)
|
|||||||
xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode);
|
xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode);
|
||||||
}
|
}
|
||||||
if (msg != NULL) {
|
if (msg != NULL) {
|
||||||
if (lines != 0)
|
if (lines == 0)
|
||||||
ctx->print(ctx, "%s", msg);
|
cmdq_info(cmdq, "%s", msg);
|
||||||
else
|
else
|
||||||
ctx->info(ctx, "%s", msg);
|
cmd_run_shell_print(job, msg);
|
||||||
xfree(msg);
|
free(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,15 +174,11 @@ void
|
|||||||
cmd_run_shell_free(void *data)
|
cmd_run_shell_free(void *data)
|
||||||
{
|
{
|
||||||
struct cmd_run_shell_data *cdata = data;
|
struct cmd_run_shell_data *cdata = data;
|
||||||
struct cmd_ctx *ctx = &cdata->ctx;
|
struct cmd_q *cmdq = cdata->cmdq;
|
||||||
|
|
||||||
if (ctx->cmdclient != NULL) {
|
if (!cmdq_free(cmdq) && !cdata->bflag)
|
||||||
ctx->cmdclient->references--;
|
cmdq_continue(cmdq);
|
||||||
ctx->cmdclient->flags |= CLIENT_EXIT;
|
|
||||||
}
|
|
||||||
if (ctx->curclient != NULL)
|
|
||||||
ctx->curclient->references--;
|
|
||||||
|
|
||||||
xfree(cdata->cmd);
|
free(cdata->cmd);
|
||||||
xfree(cdata);
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-save-buffer.c,v 1.12 2010-08-09 21:44:25 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -20,76 +20,147 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Saves a session paste buffer to a file.
|
* Saves a paste buffer to a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_save_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_save_buffer_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_save_buffer_entry = {
|
const struct cmd_entry cmd_save_buffer_entry = {
|
||||||
"save-buffer", "saveb",
|
"save-buffer", "saveb",
|
||||||
"[-a] " CMD_BUFFER_SESSION_USAGE " path",
|
"ab:", 1, 1,
|
||||||
CMD_ARG1, "a",
|
"[-a] " CMD_BUFFER_USAGE " path",
|
||||||
cmd_buffer_init,
|
0,
|
||||||
cmd_buffer_parse,
|
NULL,
|
||||||
cmd_save_buffer_exec,
|
cmd_save_buffer_exec
|
||||||
cmd_buffer_free,
|
|
||||||
cmd_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
const struct cmd_entry cmd_show_buffer_entry = {
|
||||||
cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
"show-buffer", "showb",
|
||||||
|
"b:", 0, 0,
|
||||||
|
CMD_BUFFER_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
cmd_save_buffer_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct client *c = cmdq->client;
|
||||||
|
struct session *s;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
mode_t mask;
|
const char *path;
|
||||||
|
char *cause, *start, *end, *msg;
|
||||||
|
size_t size, used, msglen;
|
||||||
|
int cwd, fd, buffer;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if (!args_has(args, 'b')) {
|
||||||
return (-1);
|
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
||||||
|
cmdq_error(cmdq, "no buffers");
|
||||||
if (data->buffer == -1) {
|
return (CMD_RETURN_ERROR);
|
||||||
if ((pb = paste_get_top(&s->buffers)) == NULL) {
|
|
||||||
ctx->error(ctx, "no buffers");
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((pb = paste_get_index(&s->buffers, data->buffer)) == NULL) {
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
if (cause != NULL) {
|
||||||
return (-1);
|
cmdq_error(cmdq, "buffer %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
pb = paste_get_index(&global_buffers, buffer);
|
||||||
|
if (pb == NULL) {
|
||||||
|
cmdq_error(cmdq, "no buffer %d", buffer);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(data->arg, "-") == 0) {
|
if (self->entry == &cmd_show_buffer_entry)
|
||||||
if (ctx->cmdclient == NULL) {
|
path = "-";
|
||||||
ctx->error(ctx, "%s: can't write to stdout", data->arg);
|
else
|
||||||
return (-1);
|
path = args->argv[0];
|
||||||
|
if (strcmp(path, "-") == 0) {
|
||||||
|
if (c == NULL) {
|
||||||
|
cmdq_error(cmdq, "can't write to stdout");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
bufferevent_write(
|
if (c->session == NULL || (c->flags & CLIENT_CONTROL))
|
||||||
ctx->cmdclient->stdout_event, pb->data, pb->size);
|
goto do_stdout;
|
||||||
|
goto do_print;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c != NULL && c->session == NULL)
|
||||||
|
cwd = c->cwd;
|
||||||
|
else if ((s = cmd_current_session(cmdq, 0)) != NULL)
|
||||||
|
cwd = s->cwd;
|
||||||
|
else
|
||||||
|
cwd = AT_FDCWD;
|
||||||
|
|
||||||
|
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 {
|
} else {
|
||||||
mask = umask(S_IRWXG | S_IRWXO);
|
fd = openat(cwd, path, O_CREAT|O_RDWR, 0600);
|
||||||
if (cmd_check_flag(data->chflags, 'a'))
|
if (fd != -1)
|
||||||
f = fopen(data->arg, "ab");
|
f = fdopen(fd, "wb");
|
||||||
else
|
}
|
||||||
f = fopen(data->arg, "wb");
|
if (f == NULL) {
|
||||||
umask(mask);
|
if (fd != -1)
|
||||||
if (f == NULL) {
|
close(fd);
|
||||||
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
|
cmdq_error(cmdq, "%s: %s", path, strerror(errno));
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
|
if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
|
||||||
ctx->error(ctx, "%s: fwrite error", data->arg);
|
cmdq_error(cmdq, "%s: fwrite error", path);
|
||||||
fclose(f);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
do_stdout:
|
||||||
|
evbuffer_add(c->stdout_data, pb->data, pb->size);
|
||||||
|
server_push_stdout(c);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
do_print:
|
||||||
|
if (pb->size > (INT_MAX / 4) - 1) {
|
||||||
|
cmdq_error(cmdq, "buffer too big");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
msg = NULL;
|
||||||
|
msglen = 0;
|
||||||
|
|
||||||
|
used = 0;
|
||||||
|
while (used != pb->size) {
|
||||||
|
start = pb->data + used;
|
||||||
|
end = memchr(start, '\n', pb->size - used);
|
||||||
|
if (end != NULL)
|
||||||
|
size = end - start;
|
||||||
|
else
|
||||||
|
size = pb->size - used;
|
||||||
|
|
||||||
|
msglen = size * 4 + 1;
|
||||||
|
msg = xrealloc(msg, 1, msglen);
|
||||||
|
|
||||||
|
strvisx(msg, start, size, VIS_OCTAL|VIS_TAB);
|
||||||
|
cmdq_print(cmdq, "%s", msg);
|
||||||
|
|
||||||
|
used += size + (end != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
free(msg);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-select-layout.c,v 1.12 2010-07-02 02:54:52 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,71 +24,109 @@
|
|||||||
* Switch window to selected layout.
|
* Switch window to selected layout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_layout_init(struct cmd *, int);
|
void cmd_select_layout_key_binding(struct cmd *, int);
|
||||||
int cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_select_layout_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_layout_entry = {
|
const struct cmd_entry cmd_select_layout_entry = {
|
||||||
"select-layout", "selectl",
|
"select-layout", "selectl",
|
||||||
CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
"npt:", 0, 1,
|
||||||
CMD_ARG01, "",
|
"[-np] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
||||||
cmd_select_layout_init,
|
0,
|
||||||
cmd_target_parse,
|
cmd_select_layout_key_binding,
|
||||||
cmd_select_layout_exec,
|
cmd_select_layout_exec
|
||||||
cmd_target_free,
|
};
|
||||||
cmd_target_print
|
|
||||||
|
const struct cmd_entry cmd_next_layout_entry = {
|
||||||
|
"next-layout", "nextl",
|
||||||
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
cmd_select_layout_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_previous_layout_entry = {
|
||||||
|
"previous-layout", "prevl",
|
||||||
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
cmd_select_layout_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_select_layout_init(struct cmd *self, int key)
|
cmd_select_layout_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data;
|
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case ('1' | KEYC_ESCAPE):
|
case '1' | KEYC_ESCAPE:
|
||||||
data->arg = xstrdup("even-horizontal");
|
self->args = args_create(1, "even-horizontal");
|
||||||
break;
|
break;
|
||||||
case ('2' | KEYC_ESCAPE):
|
case '2' | KEYC_ESCAPE:
|
||||||
data->arg = xstrdup("even-vertical");
|
self->args = args_create(1, "even-vertical");
|
||||||
break;
|
break;
|
||||||
case ('3' | KEYC_ESCAPE):
|
case '3' | KEYC_ESCAPE:
|
||||||
data->arg = xstrdup("main-horizontal");
|
self->args = args_create(1, "main-horizontal");
|
||||||
break;
|
break;
|
||||||
case ('4' | KEYC_ESCAPE):
|
case '4' | KEYC_ESCAPE:
|
||||||
data->arg = xstrdup("main-vertical");
|
self->args = args_create(1, "main-vertical");
|
||||||
break;
|
break;
|
||||||
case ('5' | KEYC_ESCAPE):
|
case '5' | KEYC_ESCAPE:
|
||||||
data->arg = xstrdup("tiled");
|
self->args = args_create(1, "tiled");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
self->args = args_create(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
int layout;
|
const char *layoutname;
|
||||||
|
int next, previous, layout;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
server_unzoom_window(wl->window);
|
||||||
|
|
||||||
if (data->arg == NULL) {
|
next = self->entry == &cmd_next_layout_entry;
|
||||||
layout = wl->window->lastlayout;
|
if (args_has(self->args, 'n'))
|
||||||
if (layout == -1)
|
next = 1;
|
||||||
return (0);
|
previous = self->entry == &cmd_previous_layout_entry;
|
||||||
} else if ((layout = layout_set_lookup(data->arg)) != -1) {
|
if (args_has(self->args, 'p'))
|
||||||
layout = layout_set_select(wl->window, layout);
|
previous = 1;
|
||||||
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
|
||||||
} else {
|
if (next || previous) {
|
||||||
if (layout_parse(wl->window, data->arg) == -1) {
|
if (next)
|
||||||
ctx->error(ctx, "can't set layout: %s", data->arg);
|
layout = layout_set_next(wl->window);
|
||||||
return (-1);
|
else
|
||||||
}
|
layout = layout_set_previous(wl->window);
|
||||||
ctx->info(ctx, "arranging in: %s", data->arg);
|
server_redraw_window(wl->window);
|
||||||
|
cmdq_info(cmdq, "arranging in: %s", layout_set_name(layout));
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
if (args->argc == 0)
|
||||||
|
layout = wl->window->lastlayout;
|
||||||
|
else
|
||||||
|
layout = layout_set_lookup(args->argv[0]);
|
||||||
|
if (layout != -1) {
|
||||||
|
layout = layout_set_select(wl->window, layout);
|
||||||
|
server_redraw_window(wl->window);
|
||||||
|
cmdq_info(cmdq, "arranging in: %s", layout_set_name(layout));
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args->argc != 0) {
|
||||||
|
layoutname = args->argv[0];
|
||||||
|
if (layout_parse(wl->window, layoutname) == -1) {
|
||||||
|
cmdq_error(cmdq, "can't set layout: %s", layoutname);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
server_redraw_window(wl->window);
|
||||||
|
cmdq_info(cmdq, "arranging in: %s", layoutname);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-select-pane.c,v 1.13 2010-03-15 22:03:38 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -24,71 +24,93 @@
|
|||||||
* Select pane.
|
* Select pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_pane_init(struct cmd *, int);
|
void cmd_select_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_select_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_pane_entry = {
|
const struct cmd_entry cmd_select_pane_entry = {
|
||||||
"select-pane", "selectp",
|
"select-pane", "selectp",
|
||||||
"[-DLRU] " CMD_TARGET_PANE_USAGE,
|
"lDLRt:U", 0, 0,
|
||||||
0, "DLRU",
|
"[-lDLRU] " CMD_TARGET_PANE_USAGE,
|
||||||
cmd_select_pane_init,
|
0,
|
||||||
cmd_target_parse,
|
cmd_select_pane_key_binding,
|
||||||
cmd_select_pane_exec,
|
cmd_select_pane_exec
|
||||||
cmd_target_free,
|
};
|
||||||
cmd_target_print
|
|
||||||
|
const struct cmd_entry cmd_last_pane_entry = {
|
||||||
|
"last-pane", "lastp",
|
||||||
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_WINDOW_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
cmd_select_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_select_pane_init(struct cmd *self, int key)
|
cmd_select_pane_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data;
|
self->args = args_create(0);
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
if (key == KEYC_UP)
|
if (key == KEYC_UP)
|
||||||
cmd_set_flag(&data->chflags, 'U');
|
args_set(self->args, 'U', NULL);
|
||||||
if (key == KEYC_DOWN)
|
if (key == KEYC_DOWN)
|
||||||
cmd_set_flag(&data->chflags, 'D');
|
args_set(self->args, 'D', NULL);
|
||||||
if (key == KEYC_LEFT)
|
if (key == KEYC_LEFT)
|
||||||
cmd_set_flag(&data->chflags, 'L');
|
args_set(self->args, 'L', NULL);
|
||||||
if (key == KEYC_RIGHT)
|
if (key == KEYC_RIGHT)
|
||||||
cmd_set_flag(&data->chflags, 'R');
|
args_set(self->args, 'R', NULL);
|
||||||
if (key == 'o')
|
if (key == 'o')
|
||||||
data->target = xstrdup(":.+");
|
args_set(self->args, 't', ":.+");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, data->target, NULL, &wp)) == NULL)
|
if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) {
|
||||||
return (-1);
|
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
|
||||||
|
if (wl == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (!window_pane_visible(wp)) {
|
if (wl->window->last == NULL) {
|
||||||
ctx->error(ctx, "pane not visible: %s", data->target);
|
cmdq_error(cmdq, "no last pane");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
server_unzoom_window(wl->window);
|
||||||
|
window_set_active_pane(wl->window, wl->window->last);
|
||||||
|
server_status_window(wl->window);
|
||||||
|
server_redraw_window_borders(wl->window);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'L'))
|
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
server_unzoom_window(wp->window);
|
||||||
|
if (!window_pane_visible(wp)) {
|
||||||
|
cmdq_error(cmdq, "pane not visible");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(self->args, 'L'))
|
||||||
wp = window_pane_find_left(wp);
|
wp = window_pane_find_left(wp);
|
||||||
else if (cmd_check_flag(data->chflags, 'R'))
|
else if (args_has(self->args, 'R'))
|
||||||
wp = window_pane_find_right(wp);
|
wp = window_pane_find_right(wp);
|
||||||
else if (cmd_check_flag(data->chflags, 'U'))
|
else if (args_has(self->args, 'U'))
|
||||||
wp = window_pane_find_up(wp);
|
wp = window_pane_find_up(wp);
|
||||||
else if (cmd_check_flag(data->chflags, 'D'))
|
else if (args_has(self->args, 'D'))
|
||||||
wp = window_pane_find_down(wp);
|
wp = window_pane_find_down(wp);
|
||||||
if (wp == NULL) {
|
if (wp == NULL) {
|
||||||
ctx->error(ctx, "pane not found");
|
cmdq_error(cmdq, "pane not found");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
window_set_active_pane(wl->window, wp);
|
window_set_active_pane(wl->window, wp);
|
||||||
server_status_window(wl->window);
|
server_status_window(wl->window);
|
||||||
server_redraw_window_borders(wl->window);
|
server_redraw_window_borders(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-select-window.c,v 1.24 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,44 +26,120 @@
|
|||||||
* Select window by index.
|
* Select window by index.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_window_init(struct cmd *, int);
|
void cmd_select_window_key_binding(struct cmd *, int);
|
||||||
int cmd_select_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_window_entry = {
|
const struct cmd_entry cmd_select_window_entry = {
|
||||||
"select-window", "selectw",
|
"select-window", "selectw",
|
||||||
CMD_TARGET_WINDOW_USAGE,
|
"lnpTt:", 0, 0,
|
||||||
0, "",
|
"[-lnpT] " CMD_TARGET_WINDOW_USAGE,
|
||||||
cmd_select_window_init,
|
0,
|
||||||
cmd_target_parse,
|
cmd_select_window_key_binding,
|
||||||
cmd_select_window_exec,
|
cmd_select_window_exec
|
||||||
cmd_target_free,
|
};
|
||||||
cmd_target_print
|
|
||||||
|
const struct cmd_entry cmd_next_window_entry = {
|
||||||
|
"next-window", "next",
|
||||||
|
"at:", 0, 0,
|
||||||
|
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
0,
|
||||||
|
cmd_select_window_key_binding,
|
||||||
|
cmd_select_window_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_previous_window_entry = {
|
||||||
|
"previous-window", "prev",
|
||||||
|
"at:", 0, 0,
|
||||||
|
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
0,
|
||||||
|
cmd_select_window_key_binding,
|
||||||
|
cmd_select_window_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_last_window_entry = {
|
||||||
|
"last-window", "last",
|
||||||
|
"t:", 0, 0,
|
||||||
|
CMD_TARGET_SESSION_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
cmd_select_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_select_window_init(struct cmd *self, int key)
|
cmd_select_window_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data;
|
char tmp[16];
|
||||||
|
|
||||||
cmd_target_init(self, key);
|
self->args = args_create(0);
|
||||||
data = self->data;
|
if (key >= '0' && key <= '9') {
|
||||||
|
xsnprintf(tmp, sizeof tmp, ":%d", key - '0');
|
||||||
xasprintf(&data->target, ":%d", key - '0');
|
args_set(self->args, 't', tmp);
|
||||||
|
}
|
||||||
|
if (key == ('n' | KEYC_ESCAPE) || key == ('p' | KEYC_ESCAPE))
|
||||||
|
args_set(self->args, 'a', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
int next, previous, last, activity;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
|
next = self->entry == &cmd_next_window_entry;
|
||||||
return (-1);
|
if (args_has(self->args, 'n'))
|
||||||
|
next = 1;
|
||||||
|
previous = self->entry == &cmd_previous_window_entry;
|
||||||
|
if (args_has(self->args, 'p'))
|
||||||
|
previous = 1;
|
||||||
|
last = self->entry == &cmd_last_window_entry;
|
||||||
|
if (args_has(self->args, 'l'))
|
||||||
|
last = 1;
|
||||||
|
|
||||||
|
if (next || previous || last) {
|
||||||
|
s = cmd_find_session(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");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
} else if (previous) {
|
||||||
|
if (session_previous(s, activity) != 0) {
|
||||||
|
cmdq_error(cmdq, "no previous window");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (session_last(s) != 0) {
|
||||||
|
cmdq_error(cmdq, "no last window");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (session_select(s, wl->idx) == 0)
|
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
|
} 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");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
server_redraw_session(s);
|
||||||
|
} else if (session_select(s, wl->idx) == 0)
|
||||||
|
server_redraw_session(s);
|
||||||
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
168
cmd-send-keys.c
168
cmd-send-keys.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-send-keys.c,v 1.25 2010-05-22 21:56:04 micahcowan Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -26,128 +27,75 @@
|
|||||||
* Send keys to client.
|
* Send keys to client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_send_keys_parse(struct cmd *, int, char **, char **);
|
enum cmd_retval cmd_send_keys_exec(struct cmd *, struct cmd_q *);
|
||||||
int cmd_send_keys_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_send_keys_free(struct cmd *);
|
|
||||||
size_t cmd_send_keys_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_send_keys_data {
|
|
||||||
char *target;
|
|
||||||
u_int nkeys;
|
|
||||||
int *keys;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_send_keys_entry = {
|
const struct cmd_entry cmd_send_keys_entry = {
|
||||||
"send-keys", "send",
|
"send-keys", "send",
|
||||||
"[-t target-pane] key ...",
|
"lRt:", 0, -1,
|
||||||
0, "",
|
"[-lR] " CMD_TARGET_PANE_USAGE " key ...",
|
||||||
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_send_keys_parse,
|
cmd_send_keys_exec
|
||||||
cmd_send_keys_exec,
|
|
||||||
cmd_send_keys_free,
|
|
||||||
cmd_send_keys_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
const struct cmd_entry cmd_send_prefix_entry = {
|
||||||
cmd_send_keys_parse(struct cmd *self, int argc, char **argv, char **cause)
|
"send-prefix", NULL,
|
||||||
|
"2t:", 0, 0,
|
||||||
|
"[-2] " CMD_TARGET_PANE_USAGE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
cmd_send_keys_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_send_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_send_keys_data *data;
|
struct args *args = self->args;
|
||||||
int opt, key;
|
struct window_pane *wp;
|
||||||
char *s;
|
struct session *s;
|
||||||
|
struct input_ctx *ictx;
|
||||||
|
const u_char *str;
|
||||||
|
int i, key;
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
if (cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp) == NULL)
|
||||||
data->target = NULL;
|
return (CMD_RETURN_ERROR);
|
||||||
data->nkeys = 0;
|
|
||||||
data->keys = NULL;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "t:")) != -1) {
|
if (self->entry == &cmd_send_prefix_entry) {
|
||||||
switch (opt) {
|
if (args_has(args, '2'))
|
||||||
case 't':
|
key = options_get_number(&s->options, "prefix2");
|
||||||
if (data->target == NULL)
|
else
|
||||||
data->target = xstrdup(optarg);
|
key = options_get_number(&s->options, "prefix");
|
||||||
break;
|
window_pane_key(wp, s, key);
|
||||||
default:
|
return (CMD_RETURN_NORMAL);
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc == 0)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
while (argc-- != 0) {
|
if (args_has(args, 'R')) {
|
||||||
if ((key = key_string_lookup_string(*argv)) != KEYC_NONE) {
|
ictx = &wp->ictx;
|
||||||
data->keys = xrealloc(
|
|
||||||
data->keys, data->nkeys + 1, sizeof *data->keys);
|
memcpy(&ictx->cell, &grid_default_cell, sizeof ictx->cell);
|
||||||
data->keys[data->nkeys++] = key;
|
memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell);
|
||||||
|
ictx->old_cx = 0;
|
||||||
|
ictx->old_cy = 0;
|
||||||
|
|
||||||
|
if (wp->mode == NULL)
|
||||||
|
screen_write_start(&ictx->ctx, wp, &wp->base);
|
||||||
|
else
|
||||||
|
screen_write_start(&ictx->ctx, NULL, &wp->base);
|
||||||
|
screen_write_reset(&ictx->ctx);
|
||||||
|
screen_write_stop(&ictx->ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < args->argc; i++) {
|
||||||
|
str = args->argv[i];
|
||||||
|
|
||||||
|
if (!args_has(args, 'l') &&
|
||||||
|
(key = key_string_lookup_string(str)) != KEYC_NONE) {
|
||||||
|
window_pane_key(wp, s, key);
|
||||||
} else {
|
} else {
|
||||||
for (s = *argv; *s != '\0'; s++) {
|
for (; *str != '\0'; str++)
|
||||||
data->keys = xrealloc(data->keys,
|
window_pane_key(wp, s, *str);
|
||||||
data->nkeys + 1, sizeof *data->keys);
|
|
||||||
data->keys[data->nkeys++] = *s;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
argv++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_send_keys_data *data = self->data;
|
|
||||||
struct window_pane *wp;
|
|
||||||
struct session *s;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
if (data == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, data->target, &s, &wp) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
for (i = 0; i < data->nkeys; i++)
|
|
||||||
window_pane_key(wp, s, data->keys[i]);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_send_keys_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_send_keys_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_send_keys_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_send_keys_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
|
|
||||||
for (i = 0; i < data->nkeys; i++) {
|
|
||||||
if (off >= len)
|
|
||||||
break;
|
|
||||||
off += xsnprintf(buf + off,
|
|
||||||
len - off, " %s", key_string_lookup_key(data->keys[i]));
|
|
||||||
}
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
/* $Id: cmd-send-prefix.c,v 1.29 2010-05-22 21:56:04 micahcowan Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Send prefix key as a key.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_send_prefix_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_send_prefix_entry = {
|
|
||||||
"send-prefix", NULL,
|
|
||||||
CMD_TARGET_PANE_USAGE,
|
|
||||||
0, "",
|
|
||||||
cmd_target_init,
|
|
||||||
cmd_target_parse,
|
|
||||||
cmd_send_prefix_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_target_data *data = self->data;
|
|
||||||
struct session *s;
|
|
||||||
struct window_pane *wp;
|
|
||||||
struct keylist *keylist;
|
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, data->target, &s, &wp) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
keylist = options_get_data(&s->options, "prefix");
|
|
||||||
window_pane_key(wp, s, ARRAY_FIRST(keylist));
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
/* $Id: cmd-server-info.c,v 1.38 2010-12-22 15:36:44 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Show various information about server.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_server_info_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_server_info_entry = {
|
|
||||||
"server-info", "info",
|
|
||||||
"",
|
|
||||||
0, "",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_server_info_exec,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ARGSUSED */
|
|
||||||
int
|
|
||||||
cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct tty_term *term;
|
|
||||||
struct client *c;
|
|
||||||
struct session *s;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct window *w;
|
|
||||||
struct window_pane *wp;
|
|
||||||
struct tty_code *code;
|
|
||||||
struct tty_term_code_entry *ent;
|
|
||||||
struct utsname un;
|
|
||||||
struct job *job;
|
|
||||||
struct grid *gd;
|
|
||||||
struct grid_line *gl;
|
|
||||||
u_int i, j, k;
|
|
||||||
char out[80];
|
|
||||||
char *tim;
|
|
||||||
time_t t;
|
|
||||||
u_int lines, ulines;
|
|
||||||
size_t size, usize;
|
|
||||||
|
|
||||||
tim = ctime(&start_time);
|
|
||||||
*strchr(tim, '\n') = '\0';
|
|
||||||
ctx->print(ctx,
|
|
||||||
"tmux " BUILD ", pid %ld, started %s", (long) getpid(), tim);
|
|
||||||
ctx->print(
|
|
||||||
ctx, "socket path %s, debug level %d", socket_path, debug_level);
|
|
||||||
if (uname(&un) == 0) {
|
|
||||||
ctx->print(ctx, "system is %s %s %s %s",
|
|
||||||
un.sysname, un.release, un.version, un.machine);
|
|
||||||
}
|
|
||||||
if (cfg_file != NULL)
|
|
||||||
ctx->print(ctx, "configuration file is %s", cfg_file);
|
|
||||||
else
|
|
||||||
ctx->print(ctx, "configuration file not specified");
|
|
||||||
ctx->print(ctx, "protocol version is %d", PROTOCOL_VERSION);
|
|
||||||
ctx->print(ctx, "%s", "");
|
|
||||||
|
|
||||||
ctx->print(ctx, "Clients:");
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
|
||||||
c = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c == NULL || c->session == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ctx->print(ctx, "%2d: %s (%d, %d): %s [%ux%u %s] "
|
|
||||||
"[flags=0x%x/0x%x, references=%u]", i, c->tty.path,
|
|
||||||
c->ibuf.fd, c->tty.fd, c->session->name,
|
|
||||||
c->tty.sx, c->tty.sy, c->tty.termname, c->flags,
|
|
||||||
c->tty.flags, c->references);
|
|
||||||
}
|
|
||||||
ctx->print(ctx, "%s", "");
|
|
||||||
|
|
||||||
ctx->print(ctx, "Sessions: [%zu/%zu]",
|
|
||||||
sizeof (struct grid_cell), sizeof (struct grid_utf8));
|
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
|
||||||
t = s->creation_time.tv_sec;
|
|
||||||
tim = ctime(&t);
|
|
||||||
*strchr(tim, '\n') = '\0';
|
|
||||||
|
|
||||||
ctx->print(ctx, "%2u: %s: %u windows (created %s) [%ux%u] "
|
|
||||||
"[flags=0x%x]", s->idx, s->name,
|
|
||||||
winlink_count(&s->windows), tim, s->sx, s->sy, s->flags);
|
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
|
||||||
w = wl->window;
|
|
||||||
ctx->print(ctx, "%4u: %s [%ux%u] [flags=0x%x, "
|
|
||||||
"references=%u, last layout=%d]", wl->idx, w->name,
|
|
||||||
w->sx, w->sy, w->flags, w->references,
|
|
||||||
w->lastlayout);
|
|
||||||
j = 0;
|
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
|
||||||
lines = ulines = size = usize = 0;
|
|
||||||
gd = wp->base.grid;
|
|
||||||
for (k = 0; k < gd->hsize + gd->sy; k++) {
|
|
||||||
gl = &gd->linedata[k];
|
|
||||||
if (gl->celldata != NULL) {
|
|
||||||
lines++;
|
|
||||||
size += gl->cellsize *
|
|
||||||
sizeof *gl->celldata;
|
|
||||||
}
|
|
||||||
if (gl->utf8data != NULL) {
|
|
||||||
ulines++;
|
|
||||||
usize += gl->utf8size *
|
|
||||||
sizeof *gl->utf8data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctx->print(ctx, "%6u: %s %lu %d %u/%u, %zu "
|
|
||||||
"bytes; UTF-8 %u/%u, %zu bytes", j,
|
|
||||||
wp->tty, (u_long) wp->pid, wp->fd, lines,
|
|
||||||
gd->hsize + gd->sy, size, ulines,
|
|
||||||
gd->hsize + gd->sy, usize);
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctx->print(ctx, "%s", "");
|
|
||||||
|
|
||||||
ctx->print(ctx, "Terminals:");
|
|
||||||
SLIST_FOREACH(term, &tty_terms, entry) {
|
|
||||||
ctx->print(ctx, "%s [references=%u, flags=0x%x]:",
|
|
||||||
term->name, term->references, term->flags);
|
|
||||||
for (i = 0; i < NTTYCODE; i++) {
|
|
||||||
ent = &tty_term_codes[i];
|
|
||||||
code = &term->codes[ent->code];
|
|
||||||
switch (code->type) {
|
|
||||||
case TTYCODE_NONE:
|
|
||||||
ctx->print(ctx, "%2u: %s: [missing]",
|
|
||||||
ent->code, ent->name);
|
|
||||||
break;
|
|
||||||
case TTYCODE_STRING:
|
|
||||||
strnvis(out, code->value.string, sizeof out,
|
|
||||||
VIS_OCTAL|VIS_TAB|VIS_NL);
|
|
||||||
ctx->print(ctx, "%2u: %s: (string) %s",
|
|
||||||
ent->code, ent->name, out);
|
|
||||||
break;
|
|
||||||
case TTYCODE_NUMBER:
|
|
||||||
ctx->print(ctx, "%2u: %s: (number) %d",
|
|
||||||
ent->code, ent->name, code->value.number);
|
|
||||||
break;
|
|
||||||
case TTYCODE_FLAG:
|
|
||||||
ctx->print(ctx, "%2u: %s: (flag) %s",
|
|
||||||
ent->code, ent->name,
|
|
||||||
code->value.flag ? "true" : "false");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctx->print(ctx, "%s", "");
|
|
||||||
|
|
||||||
ctx->print(ctx, "Jobs:");
|
|
||||||
SLIST_FOREACH(job, &all_jobs, lentry) {
|
|
||||||
ctx->print(ctx, "%s [fd=%d, pid=%d, status=%d, flags=0x%x]",
|
|
||||||
job->cmd, job->fd, job->pid, job->status, job->flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-buffer.c,v 1.12 2009-11-28 14:54:12 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,51 +18,58 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add or set a session paste buffer.
|
* Add or set a paste buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_set_buffer_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_buffer_entry = {
|
const struct cmd_entry cmd_set_buffer_entry = {
|
||||||
"set-buffer", "setb",
|
"set-buffer", "setb",
|
||||||
CMD_BUFFER_SESSION_USAGE " data",
|
"b:", 1, 1,
|
||||||
CMD_ARG1, "",
|
CMD_BUFFER_USAGE " data",
|
||||||
cmd_buffer_init,
|
0,
|
||||||
cmd_buffer_parse,
|
NULL,
|
||||||
cmd_set_buffer_exec,
|
cmd_set_buffer_exec
|
||||||
cmd_buffer_free,
|
|
||||||
cmd_buffer_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
u_int limit;
|
||||||
u_int limit;
|
char *pdata, *cause;
|
||||||
char *pdata;
|
size_t psize;
|
||||||
size_t psize;
|
int buffer;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
return (-1);
|
|
||||||
limit = options_get_number(&s->options, "buffer-limit");
|
|
||||||
|
|
||||||
pdata = xstrdup(data->arg);
|
pdata = xstrdup(args->argv[0]);
|
||||||
psize = strlen(pdata);
|
psize = strlen(pdata);
|
||||||
|
|
||||||
if (data->buffer == -1) {
|
if (!args_has(args, 'b')) {
|
||||||
paste_add(&s->buffers, pdata, psize, limit);
|
paste_add(&global_buffers, pdata, psize, limit);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
if (paste_replace(&s->buffers, data->buffer, pdata, psize) != 0) {
|
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
xfree(pdata);
|
if (cause != NULL) {
|
||||||
return (-1);
|
cmdq_error(cmdq, "buffer %s", cause);
|
||||||
|
free(cause);
|
||||||
|
free(pdata);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
return (0);
|
|
||||||
|
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
||||||
|
cmdq_error(cmdq, "no buffer %d", buffer);
|
||||||
|
free(pdata);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-environment.c,v 1.3 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -27,62 +27,67 @@
|
|||||||
* Set an environment variable.
|
* Set an environment variable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_set_environment_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_set_environment_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_environment_entry = {
|
const struct cmd_entry cmd_set_environment_entry = {
|
||||||
"set-environment", "setenv",
|
"set-environment", "setenv",
|
||||||
|
"grt:u", 1, 2,
|
||||||
"[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
"[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
||||||
CMD_ARG12, "gru",
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_set_environment_exec
|
||||||
cmd_set_environment_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct environ *env;
|
struct environ *env;
|
||||||
|
const char *name, *value;
|
||||||
|
|
||||||
if (*data->arg == '\0') {
|
name = args->argv[0];
|
||||||
ctx->error(ctx, "empty variable name");
|
if (*name == '\0') {
|
||||||
return (-1);
|
cmdq_error(cmdq, "empty variable name");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (strchr(data->arg, '=') != NULL) {
|
if (strchr(name, '=') != NULL) {
|
||||||
ctx->error(ctx, "variable name contains =");
|
cmdq_error(cmdq, "variable name contains =");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'g'))
|
if (args->argc < 2)
|
||||||
|
value = NULL;
|
||||||
|
else
|
||||||
|
value = args->argv[1];
|
||||||
|
|
||||||
|
if (args_has(self->args, 'g'))
|
||||||
env = &global_environ;
|
env = &global_environ;
|
||||||
else {
|
else {
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
env = &s->environ;
|
env = &s->environ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'u')) {
|
if (args_has(self->args, 'u')) {
|
||||||
if (data->arg2 != NULL) {
|
if (value != NULL) {
|
||||||
ctx->error(ctx, "can't specify a value with -u");
|
cmdq_error(cmdq, "can't specify a value with -u");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_unset(env, data->arg);
|
environ_unset(env, name);
|
||||||
} else if (cmd_check_flag(data->chflags, 'r')) {
|
} else if (args_has(self->args, 'r')) {
|
||||||
if (data->arg2 != NULL) {
|
if (value != NULL) {
|
||||||
ctx->error(ctx, "can't specify a value with -r");
|
cmdq_error(cmdq, "can't specify a value with -r");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_set(env, data->arg, NULL);
|
environ_set(env, name, NULL);
|
||||||
} else {
|
} else {
|
||||||
if (data->arg2 == NULL) {
|
if (value == NULL) {
|
||||||
ctx->error(ctx, "no value specified");
|
cmdq_error(cmdq, "no value specified");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_set(env, data->arg, data->arg2);
|
environ_set(env, name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
785
cmd-set-option.c
785
cmd-set-option.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-option.c,v 1.102 2010-12-22 15:23:59 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -27,264 +27,163 @@
|
|||||||
* Set an option.
|
* Set an option.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const char *cmd_set_option_print(
|
enum cmd_retval cmd_set_option_user(struct cmd *, struct cmd_q *,
|
||||||
const struct set_option_entry *, struct options_entry *);
|
const char *, const char *);
|
||||||
void cmd_set_option_string(struct cmd_ctx *,
|
|
||||||
struct options *, const struct set_option_entry *, char *, int);
|
int cmd_set_option_unset(struct cmd *, struct cmd_q *,
|
||||||
void cmd_set_option_number(struct cmd_ctx *,
|
const struct options_table_entry *, struct options *,
|
||||||
struct options *, const struct set_option_entry *, char *);
|
const char *);
|
||||||
void cmd_set_option_keys(struct cmd_ctx *,
|
int cmd_set_option_set(struct cmd *, struct cmd_q *,
|
||||||
struct options *, const struct set_option_entry *, char *);
|
const struct options_table_entry *, struct options *,
|
||||||
void cmd_set_option_colour(struct cmd_ctx *,
|
const char *);
|
||||||
struct options *, const struct set_option_entry *, char *);
|
|
||||||
void cmd_set_option_attributes(struct cmd_ctx *,
|
struct options_entry *cmd_set_option_string(struct cmd *, struct cmd_q *,
|
||||||
struct options *, const struct set_option_entry *, char *);
|
const struct options_table_entry *, struct options *,
|
||||||
void cmd_set_option_flag(struct cmd_ctx *,
|
const char *);
|
||||||
struct options *, const struct set_option_entry *, char *);
|
struct options_entry *cmd_set_option_number(struct cmd *, struct cmd_q *,
|
||||||
void cmd_set_option_choice(struct cmd_ctx *,
|
const struct options_table_entry *, struct options *,
|
||||||
struct options *, const struct set_option_entry *, char *);
|
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 *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_option_entry = {
|
const struct cmd_entry cmd_set_option_entry = {
|
||||||
"set-option", "set",
|
"set-option", "set",
|
||||||
"[-agsuw] [-t target-session|target-window] option [value]",
|
"agoqst:uw", 1, 2,
|
||||||
CMD_ARG12, "agsuw",
|
"[-agosquw] [-t target-session|target-window] option [value]",
|
||||||
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_set_option_exec
|
||||||
cmd_set_option_exec,
|
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *set_option_mode_keys_list[] = {
|
const struct cmd_entry cmd_set_window_option_entry = {
|
||||||
"emacs", "vi", NULL
|
"set-window-option", "setw",
|
||||||
};
|
"agoqt:u", 1, 2,
|
||||||
const char *set_option_clock_mode_style_list[] = {
|
"[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
||||||
"12", "24", NULL
|
0,
|
||||||
};
|
NULL,
|
||||||
const char *set_option_status_keys_list[] = {
|
cmd_set_option_exec
|
||||||
"emacs", "vi", NULL
|
|
||||||
};
|
|
||||||
const char *set_option_status_justify_list[] = {
|
|
||||||
"left", "centre", "right", NULL
|
|
||||||
};
|
|
||||||
const char *set_option_bell_action_list[] = {
|
|
||||||
"none", "any", "current", NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct set_option_entry set_option_table[] = {
|
enum cmd_retval
|
||||||
{ "escape-time", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{ "exit-unattached", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "quiet", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ NULL, 0, 0, 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct set_option_entry set_session_option_table[] = {
|
|
||||||
{ "base-index", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "bell-action", SET_OPTION_CHOICE, 0, 0, set_option_bell_action_list },
|
|
||||||
{ "buffer-limit", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
|
||||||
{ "default-command", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "default-path", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "default-shell", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "default-terminal", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "destroy-unattached", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "detach-on-destroy", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "display-panes-colour", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "display-panes-active-colour", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "display-panes-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
|
||||||
{ "display-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
|
||||||
{ "history-limit", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "lock-after-time", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "lock-command", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "lock-server", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "message-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "message-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "message-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "message-limit", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "mouse-select-pane", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "pane-active-border-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "pane-active-border-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "pane-border-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "pane-border-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "prefix", SET_OPTION_KEYS, 0, 0, NULL },
|
|
||||||
{ "repeat-time", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
|
||||||
{ "set-remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "set-titles", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "set-titles-string", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "status", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "status-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "status-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "status-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "status-interval", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "status-justify",
|
|
||||||
SET_OPTION_CHOICE, 0, 0, set_option_status_justify_list },
|
|
||||||
{ "status-keys", SET_OPTION_CHOICE, 0, 0, set_option_status_keys_list },
|
|
||||||
{ "status-left", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "status-left-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "status-left-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "status-left-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "status-left-length", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
|
||||||
{ "status-right", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "status-right-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "status-right-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "status-right-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "status-right-length", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
|
||||||
{ "status-utf8", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "terminal-overrides", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "update-environment", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "visual-activity", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "visual-bell", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "visual-content", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "visual-silence", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ NULL, 0, 0, 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct set_option_entry set_window_option_table[] = {
|
|
||||||
{ "aggressive-resize", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "alternate-screen", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "automatic-rename", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "clock-mode-colour", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "clock-mode-style",
|
|
||||||
SET_OPTION_CHOICE, 0, 0, set_option_clock_mode_style_list },
|
|
||||||
{ "force-height", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "force-width", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "main-pane-height", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
|
||||||
{ "main-pane-width", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
|
||||||
{ "mode-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "mode-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "mode-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "mode-keys", SET_OPTION_CHOICE, 0, 0, set_option_mode_keys_list },
|
|
||||||
{ "mode-mouse", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "monitor-activity", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "monitor-content", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "monitor-silence",SET_OPTION_NUMBER, 0, INT_MAX, NULL},
|
|
||||||
{ "other-pane-height", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "other-pane-width", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
|
||||||
{ "remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "synchronize-panes", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "utf8", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ "window-status-alert-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "window-status-alert-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "window-status-alert-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "window-status-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "window-status-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "window-status-current-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
|
||||||
{ "window-status-current-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "window-status-current-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "window-status-current-format", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "window-status-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
|
||||||
{ "window-status-format", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "word-separators", SET_OPTION_STRING, 0, 0, NULL },
|
|
||||||
{ "xterm-keys", SET_OPTION_FLAG, 0, 0, NULL },
|
|
||||||
{ NULL, 0, 0, 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
const struct set_option_entry *table;
|
const struct options_table_entry *table, *oe;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct options *oo;
|
struct options *oo;
|
||||||
const struct set_option_entry *entry, *opt;
|
struct window *w;
|
||||||
struct jobs *jobs;
|
const char *optstr, *valstr;
|
||||||
struct job *job, *nextjob;
|
u_int i;
|
||||||
u_int i;
|
|
||||||
int try_again;
|
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 's')) {
|
/* Get the option name and value. */
|
||||||
|
optstr = args->argv[0];
|
||||||
|
if (*optstr == '\0') {
|
||||||
|
cmdq_error(cmdq, "invalid option");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (args->argc < 2)
|
||||||
|
valstr = NULL;
|
||||||
|
else
|
||||||
|
valstr = 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) {
|
||||||
|
cmdq_error(cmdq, "ambiguous option: %s", optstr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (oe == NULL) {
|
||||||
|
cmdq_error(cmdq, "unknown option: %s", optstr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Work out the tree from the table. */
|
||||||
|
if (table == server_options_table)
|
||||||
oo = &global_options;
|
oo = &global_options;
|
||||||
table = set_option_table;
|
else if (table == window_options_table) {
|
||||||
} else if (cmd_check_flag(data->chflags, 'w')) {
|
if (args_has(self->args, 'g'))
|
||||||
table = set_window_option_table;
|
|
||||||
if (cmd_check_flag(data->chflags, 'g'))
|
|
||||||
oo = &global_w_options;
|
oo = &global_w_options;
|
||||||
else {
|
else {
|
||||||
wl = cmd_find_window(ctx, data->target, NULL);
|
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
|
||||||
if (wl == NULL)
|
if (wl == NULL) {
|
||||||
return (-1);
|
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;
|
oo = &wl->window->options;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (table == session_options_table) {
|
||||||
table = set_session_option_table;
|
if (args_has(self->args, 'g'))
|
||||||
if (cmd_check_flag(data->chflags, 'g'))
|
|
||||||
oo = &global_s_options;
|
oo = &global_s_options;
|
||||||
else {
|
else {
|
||||||
s = cmd_find_session(ctx, data->target);
|
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL) {
|
||||||
return (-1);
|
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;
|
oo = &s->options;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (*data->arg == '\0') {
|
|
||||||
ctx->error(ctx, "invalid option");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
entry = NULL;
|
|
||||||
for (opt = table; opt->name != NULL; opt++) {
|
|
||||||
if (strncmp(opt->name, data->arg, strlen(data->arg)) != 0)
|
|
||||||
continue;
|
|
||||||
if (entry != NULL) {
|
|
||||||
ctx->error(ctx, "ambiguous option: %s", data->arg);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
entry = opt;
|
|
||||||
|
|
||||||
/* Bail now if an exact match. */
|
|
||||||
if (strcmp(entry->name, data->arg) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (entry == NULL) {
|
|
||||||
ctx->error(ctx, "unknown option: %s", data->arg);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'u')) {
|
|
||||||
if (cmd_check_flag(data->chflags, 'g')) {
|
|
||||||
ctx->error(ctx,
|
|
||||||
"can't unset global option: %s", entry->name);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (data->arg2 != NULL) {
|
|
||||||
ctx->error(ctx,
|
|
||||||
"value passed to unset option: %s", entry->name);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
options_remove(oo, entry->name);
|
|
||||||
ctx->info(ctx, "unset option: %s", entry->name);
|
|
||||||
} else {
|
} else {
|
||||||
switch (entry->type) {
|
cmdq_error(cmdq, "unknown table");
|
||||||
case SET_OPTION_STRING:
|
return (CMD_RETURN_ERROR);
|
||||||
cmd_set_option_string(ctx, oo, entry,
|
}
|
||||||
data->arg2, cmd_check_flag(data->chflags, 'a'));
|
|
||||||
break;
|
/* Unset or set the option. */
|
||||||
case SET_OPTION_NUMBER:
|
if (args_has(args, 'u')) {
|
||||||
cmd_set_option_number(ctx, oo, entry, data->arg2);
|
if (cmd_set_option_unset(self, cmdq, oe, oo, valstr) != 0)
|
||||||
break;
|
return (CMD_RETURN_ERROR);
|
||||||
case SET_OPTION_KEYS:
|
} else {
|
||||||
cmd_set_option_keys(ctx, oo, entry, data->arg2);
|
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
|
||||||
break;
|
if (!args_has(args, 'q'))
|
||||||
case SET_OPTION_COLOUR:
|
cmdq_print(cmdq, "already set: %s", optstr);
|
||||||
cmd_set_option_colour(ctx, oo, entry, data->arg2);
|
return (CMD_RETURN_NORMAL);
|
||||||
break;
|
}
|
||||||
case SET_OPTION_ATTRIBUTES:
|
if (cmd_set_option_set(self, cmdq, oe, oo, valstr) != 0)
|
||||||
cmd_set_option_attributes(ctx, oo, entry, data->arg2);
|
return (CMD_RETURN_ERROR);
|
||||||
break;
|
}
|
||||||
case SET_OPTION_FLAG:
|
|
||||||
cmd_set_option_flag(ctx, oo, entry, data->arg2);
|
/* Start or stop timers when automatic-rename changed. */
|
||||||
break;
|
if (strcmp(oe->name, "automatic-rename") == 0) {
|
||||||
case SET_OPTION_CHOICE:
|
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
|
||||||
cmd_set_option_choice(ctx, oo, entry, data->arg2);
|
if ((w = ARRAY_ITEM(&windows, i)) == NULL)
|
||||||
break;
|
continue;
|
||||||
|
if (options_get_number(&w->options, "automatic-rename"))
|
||||||
|
queue_window_name(w);
|
||||||
|
else if (event_initialized(&w->name_timer))
|
||||||
|
evtimer_del(&w->name_timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update sizes and redraw. May not need it but meh. */
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
@@ -292,227 +191,241 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
return (CMD_RETURN_NORMAL);
|
||||||
* Special-case: kill all persistent jobs if status-left, status-right
|
}
|
||||||
* or set-titles-string have changed. Persistent jobs are only used by
|
|
||||||
* the status line at the moment so this works XXX.
|
|
||||||
*/
|
|
||||||
if (strcmp(entry->name, "status-left") == 0 ||
|
|
||||||
strcmp(entry->name, "status-right") == 0 ||
|
|
||||||
strcmp(entry->name, "status") == 0 ||
|
|
||||||
strcmp(entry->name, "set-titles-string") == 0 ||
|
|
||||||
strcmp(entry->name, "window-status-format") == 0) {
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
|
||||||
c = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c == NULL || c->session == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
jobs = &c->status_jobs;
|
/* Set user option. */
|
||||||
do {
|
enum cmd_retval
|
||||||
try_again = 0;
|
cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char* optstr,
|
||||||
job = RB_ROOT(jobs);
|
const char *valstr)
|
||||||
while (job != NULL) {
|
{
|
||||||
nextjob = RB_NEXT(jobs, jobs, job);
|
struct args *args = self->args;
|
||||||
if (job->flags & JOB_PERSIST) {
|
struct session *s;
|
||||||
job_remove(jobs, job);
|
struct winlink *wl;
|
||||||
try_again = 1;
|
struct options *oo;
|
||||||
break;
|
|
||||||
}
|
if (args_has(args, 's'))
|
||||||
job = nextjob;
|
oo = &global_options;
|
||||||
}
|
else if (args_has(self->args, 'w') ||
|
||||||
} while (try_again);
|
self->entry == &cmd_set_window_option_entry) {
|
||||||
server_redraw_client(c);
|
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) {
|
||||||
|
cmdq_error(cmdq, "unknown option: %s", optstr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (valstr != NULL) {
|
||||||
|
cmdq_error(cmdq, "value passed to unset option: %s",
|
||||||
|
optstr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
options_remove(oo, optstr);
|
||||||
|
} else {
|
||||||
|
if (valstr == NULL) {
|
||||||
|
cmdq_error(cmdq, "empty value");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
|
||||||
|
if (!args_has(args, 'q'))
|
||||||
|
cmdq_print(cmdq, "already set: %s", optstr);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
options_set_string(oo, optstr, "%s", valstr);
|
||||||
|
if (!args_has(args, 'q')) {
|
||||||
|
cmdq_info(cmdq, "set option: %s -> %s", optstr,
|
||||||
|
valstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Unset an option. */
|
||||||
|
int
|
||||||
|
cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
|
||||||
|
if (args_has(args, 'g')) {
|
||||||
|
cmdq_error(cmdq, "can't unset global option: %s", oe->name);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (value != NULL) {
|
||||||
|
cmdq_error(cmdq, "value passed to unset option: %s", oe->name);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
options_remove(oo, oe->name);
|
||||||
|
if (!args_has(args, 'q'))
|
||||||
|
cmdq_info(cmdq, "unset option: %s", oe->name);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
/* Set an option. */
|
||||||
cmd_set_option_print(
|
int
|
||||||
const struct set_option_entry *entry, struct options_entry *o)
|
cmd_set_option_set(struct cmd *self, struct cmd_q *cmdq,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
{
|
{
|
||||||
static char out[BUFSIZ];
|
struct args *args = self->args;
|
||||||
const char *s;
|
struct options_entry *o;
|
||||||
struct keylist *keylist;
|
const char *s;
|
||||||
u_int i;
|
|
||||||
|
|
||||||
*out = '\0';
|
if (oe->type != OPTIONS_TABLE_FLAG && value == NULL) {
|
||||||
switch (entry->type) {
|
cmdq_error(cmdq, "empty value");
|
||||||
case SET_OPTION_STRING:
|
return (-1);
|
||||||
xsnprintf(out, sizeof out, "\"%s\"", o->str);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_NUMBER:
|
|
||||||
xsnprintf(out, sizeof out, "%lld", o->num);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_KEYS:
|
|
||||||
keylist = o->data;
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(keylist); i++) {
|
|
||||||
strlcat(out, key_string_lookup_key(
|
|
||||||
ARRAY_ITEM(keylist, i)), sizeof out);
|
|
||||||
if (i != ARRAY_LENGTH(keylist) - 1)
|
|
||||||
strlcat(out, ",", sizeof out);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SET_OPTION_COLOUR:
|
|
||||||
s = colour_tostring(o->num);
|
|
||||||
xsnprintf(out, sizeof out, "%s", s);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_ATTRIBUTES:
|
|
||||||
s = attributes_tostring(o->num);
|
|
||||||
xsnprintf(out, sizeof out, "%s", s);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_FLAG:
|
|
||||||
if (o->num)
|
|
||||||
strlcpy(out, "on", sizeof out);
|
|
||||||
else
|
|
||||||
strlcpy(out, "off", sizeof out);
|
|
||||||
break;
|
|
||||||
case SET_OPTION_CHOICE:
|
|
||||||
s = entry->choices[o->num];
|
|
||||||
xsnprintf(out, sizeof out, "%s", s);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return (out);
|
|
||||||
|
o = NULL;
|
||||||
|
switch (oe->type) {
|
||||||
|
case OPTIONS_TABLE_STRING:
|
||||||
|
o = cmd_set_option_string(self, cmdq, oe, oo, value);
|
||||||
|
break;
|
||||||
|
case OPTIONS_TABLE_NUMBER:
|
||||||
|
o = cmd_set_option_number(self, cmdq, oe, oo, value);
|
||||||
|
break;
|
||||||
|
case OPTIONS_TABLE_KEY:
|
||||||
|
o = cmd_set_option_key(self, cmdq, oe, oo, value);
|
||||||
|
break;
|
||||||
|
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;
|
||||||
|
case OPTIONS_TABLE_FLAG:
|
||||||
|
o = cmd_set_option_flag(self, cmdq, oe, oo, value);
|
||||||
|
break;
|
||||||
|
case OPTIONS_TABLE_CHOICE:
|
||||||
|
o = cmd_set_option_choice(self, cmdq, oe, oo, value);
|
||||||
|
break;
|
||||||
|
case OPTIONS_TABLE_STYLE:
|
||||||
|
o = cmd_set_option_style(self, cmdq, oe, oo, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (o == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
s = options_table_print_entry(oe, o, 0);
|
||||||
|
if (!args_has(args, 'q'))
|
||||||
|
cmdq_info(cmdq, "set option: %s -> %s", oe->name, s);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* Set a string option. */
|
||||||
cmd_set_option_string(struct cmd_ctx *ctx, struct options *oo,
|
struct options_entry *
|
||||||
const struct set_option_entry *entry, char *value, int append)
|
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;
|
struct options_entry *o;
|
||||||
char *oldvalue, *newvalue;
|
char *oldval, *newval;
|
||||||
|
|
||||||
if (value == NULL) {
|
if (args_has(args, 'a')) {
|
||||||
ctx->error(ctx, "empty value");
|
oldval = options_get_string(oo, oe->name);
|
||||||
return;
|
xasprintf(&newval, "%s%s", oldval, value);
|
||||||
}
|
|
||||||
|
|
||||||
if (append) {
|
|
||||||
oldvalue = options_get_string(oo, entry->name);
|
|
||||||
xasprintf(&newvalue, "%s%s", oldvalue, value);
|
|
||||||
} else
|
} else
|
||||||
newvalue = value;
|
newval = xstrdup(value);
|
||||||
|
|
||||||
o = options_set_string(oo, entry->name, "%s", newvalue);
|
o = options_set_string(oo, oe->name, "%s", newval);
|
||||||
ctx->info(ctx,
|
|
||||||
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
|
||||||
|
|
||||||
if (newvalue != value)
|
free(newval);
|
||||||
xfree(newvalue);
|
return (o);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* Set a number option. */
|
||||||
cmd_set_option_number(struct cmd_ctx *ctx, struct options *oo,
|
struct options_entry *
|
||||||
const struct set_option_entry *entry, char *value)
|
cmd_set_option_number(unused struct cmd *self, struct cmd_q *cmdq,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
{
|
{
|
||||||
struct options_entry *o;
|
long long ll;
|
||||||
long long number;
|
const char *errstr;
|
||||||
const char *errstr;
|
|
||||||
|
|
||||||
if (value == NULL) {
|
ll = strtonum(value, oe->minimum, oe->maximum, &errstr);
|
||||||
ctx->error(ctx, "empty value");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
number = strtonum(value, entry->minimum, entry->maximum, &errstr);
|
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
ctx->error(ctx, "value is %s: %s", errstr, value);
|
cmdq_error(cmdq, "value is %s: %s", errstr, value);
|
||||||
return;
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
o = options_set_number(oo, entry->name, number);
|
return (options_set_number(oo, oe->name, ll));
|
||||||
ctx->info(ctx,
|
|
||||||
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* Set a key option. */
|
||||||
cmd_set_option_keys(struct cmd_ctx *ctx, struct options *oo,
|
struct options_entry *
|
||||||
const struct set_option_entry *entry, char *value)
|
cmd_set_option_key(unused struct cmd *self, struct cmd_q *cmdq,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
{
|
{
|
||||||
struct options_entry *o;
|
int key;
|
||||||
struct keylist *keylist;
|
|
||||||
char *copyvalue, *ptr, *str;
|
|
||||||
int key;
|
|
||||||
|
|
||||||
if (value == NULL) {
|
if ((key = key_string_lookup_string(value)) == KEYC_NONE) {
|
||||||
ctx->error(ctx, "empty value");
|
cmdq_error(cmdq, "bad key: %s", value);
|
||||||
return;
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
keylist = xmalloc(sizeof *keylist);
|
return (options_set_number(oo, oe->name, key));
|
||||||
ARRAY_INIT(keylist);
|
|
||||||
|
|
||||||
ptr = copyvalue = xstrdup(value);
|
|
||||||
while ((str = strsep(&ptr, ",")) != NULL) {
|
|
||||||
if ((key = key_string_lookup_string(str)) == KEYC_NONE) {
|
|
||||||
xfree(keylist);
|
|
||||||
ctx->error(ctx, "unknown key: %s", str);
|
|
||||||
xfree(copyvalue);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ARRAY_ADD(keylist, key);
|
|
||||||
}
|
|
||||||
xfree(copyvalue);
|
|
||||||
|
|
||||||
o = options_set_data(oo, entry->name, keylist, xfree);
|
|
||||||
ctx->info(ctx,
|
|
||||||
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* Set a colour option. */
|
||||||
cmd_set_option_colour(struct cmd_ctx *ctx, struct options *oo,
|
struct options_entry *
|
||||||
const struct set_option_entry *entry, char *value)
|
cmd_set_option_colour(unused struct cmd *self, struct cmd_q *cmdq,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
{
|
{
|
||||||
struct options_entry *o;
|
int colour;
|
||||||
int colour;
|
|
||||||
|
|
||||||
if (value == NULL) {
|
|
||||||
ctx->error(ctx, "empty value");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((colour = colour_fromstring(value)) == -1) {
|
if ((colour = colour_fromstring(value)) == -1) {
|
||||||
ctx->error(ctx, "bad colour: %s", value);
|
cmdq_error(cmdq, "bad colour: %s", value);
|
||||||
return;
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
o = options_set_number(oo, entry->name, colour);
|
return (options_set_number(oo, oe->name, colour));
|
||||||
ctx->info(ctx,
|
|
||||||
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* Set an attributes option. */
|
||||||
cmd_set_option_attributes(struct cmd_ctx *ctx, struct options *oo,
|
struct options_entry *
|
||||||
const struct set_option_entry *entry, char *value)
|
cmd_set_option_attributes(unused struct cmd *self, struct cmd_q *cmdq,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
{
|
{
|
||||||
struct options_entry *o;
|
int attr;
|
||||||
int attr;
|
|
||||||
|
|
||||||
if (value == NULL) {
|
|
||||||
ctx->error(ctx, "empty value");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((attr = attributes_fromstring(value)) == -1) {
|
if ((attr = attributes_fromstring(value)) == -1) {
|
||||||
ctx->error(ctx, "bad attributes: %s", value);
|
cmdq_error(cmdq, "bad attributes: %s", value);
|
||||||
return;
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
o = options_set_number(oo, entry->name, attr);
|
return (options_set_number(oo, oe->name, attr));
|
||||||
ctx->info(ctx,
|
|
||||||
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* Set a flag option. */
|
||||||
cmd_set_option_flag(struct cmd_ctx *ctx, struct options *oo,
|
struct options_entry *
|
||||||
const struct set_option_entry *entry, char *value)
|
cmd_set_option_flag(unused struct cmd *self, struct cmd_q *cmdq,
|
||||||
|
const struct options_table_entry *oe, struct options *oo, const char *value)
|
||||||
{
|
{
|
||||||
struct options_entry *o;
|
int flag;
|
||||||
int flag;
|
|
||||||
|
|
||||||
if (value == NULL || *value == '\0')
|
if (value == NULL || *value == '\0')
|
||||||
flag = !options_get_number(oo, entry->name);
|
flag = !options_get_number(oo, oe->name);
|
||||||
else {
|
else {
|
||||||
if ((value[0] == '1' && value[1] == '\0') ||
|
if ((value[0] == '1' && value[1] == '\0') ||
|
||||||
strcasecmp(value, "on") == 0 ||
|
strcasecmp(value, "on") == 0 ||
|
||||||
@@ -523,47 +436,59 @@ cmd_set_option_flag(struct cmd_ctx *ctx, struct options *oo,
|
|||||||
strcasecmp(value, "no") == 0)
|
strcasecmp(value, "no") == 0)
|
||||||
flag = 0;
|
flag = 0;
|
||||||
else {
|
else {
|
||||||
ctx->error(ctx, "bad value: %s", value);
|
cmdq_error(cmdq, "bad value: %s", value);
|
||||||
return;
|
return (NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
o = options_set_number(oo, entry->name, flag);
|
return (options_set_number(oo, oe->name, flag));
|
||||||
ctx->info(ctx,
|
|
||||||
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* Set a choice option. */
|
||||||
cmd_set_option_choice(struct cmd_ctx *ctx, struct options *oo,
|
struct options_entry *
|
||||||
const struct set_option_entry *entry, char *value)
|
cmd_set_option_choice(unused struct cmd *self, struct cmd_q *cmdq,
|
||||||
|
const struct options_table_entry *oe, struct options *oo,
|
||||||
|
const char *value)
|
||||||
{
|
{
|
||||||
struct options_entry *o;
|
const char **choicep;
|
||||||
const char **choicep;
|
int n, choice = -1;
|
||||||
int n, choice = -1;
|
|
||||||
|
|
||||||
if (value == NULL) {
|
|
||||||
ctx->error(ctx, "empty value");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
for (choicep = entry->choices; *choicep != NULL; choicep++) {
|
for (choicep = oe->choices; *choicep != NULL; choicep++) {
|
||||||
n++;
|
n++;
|
||||||
if (strncmp(*choicep, value, strlen(value)) != 0)
|
if (strncmp(*choicep, value, strlen(value)) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (choice != -1) {
|
if (choice != -1) {
|
||||||
ctx->error(ctx, "ambiguous option value: %s", value);
|
cmdq_error(cmdq, "ambiguous value: %s", value);
|
||||||
return;
|
return (NULL);
|
||||||
}
|
}
|
||||||
choice = n - 1;
|
choice = n - 1;
|
||||||
}
|
}
|
||||||
if (choice == -1) {
|
if (choice == -1) {
|
||||||
ctx->error(ctx, "unknown option value: %s", value);
|
cmdq_error(cmdq, "unknown value: %s", value);
|
||||||
return;
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
o = options_set_number(oo, entry->name, choice);
|
return (options_set_number(oo, oe->name, choice));
|
||||||
ctx->info(ctx,
|
}
|
||||||
"set option: %s -> %s", o->name, cmd_set_option_print(entry, o));
|
|
||||||
|
/* 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
/* $Id: cmd-show-buffer.c,v 1.12 2009-12-04 22:14:47 tcunha Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Show a session paste buffer.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int cmd_show_buffer_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_buffer_entry = {
|
|
||||||
"show-buffer", "showb",
|
|
||||||
CMD_BUFFER_SESSION_USAGE,
|
|
||||||
0, "",
|
|
||||||
cmd_buffer_init,
|
|
||||||
cmd_buffer_parse,
|
|
||||||
cmd_show_buffer_exec,
|
|
||||||
cmd_buffer_free,
|
|
||||||
cmd_buffer_print
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_buffer_data *data = self->data;
|
|
||||||
struct session *s;
|
|
||||||
struct paste_buffer *pb;
|
|
||||||
char *in, *buf, *ptr;
|
|
||||||
size_t size, len;
|
|
||||||
u_int width;
|
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (data->buffer == -1) {
|
|
||||||
if ((pb = paste_get_top(&s->buffers)) == NULL) {
|
|
||||||
ctx->error(ctx, "no buffers");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} else if ((pb = paste_get_index(&s->buffers, data->buffer)) == NULL) {
|
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (pb == NULL)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
size = pb->size;
|
|
||||||
if (size > SIZE_MAX / 4 - 1)
|
|
||||||
size = SIZE_MAX / 4 - 1;
|
|
||||||
in = xmalloc(size * 4 + 1);
|
|
||||||
strvisx(in, pb->data, size, VIS_OCTAL|VIS_TAB);
|
|
||||||
|
|
||||||
width = s->sx;
|
|
||||||
if (ctx->cmdclient != NULL)
|
|
||||||
width = ctx->cmdclient->tty.sx;
|
|
||||||
|
|
||||||
buf = xmalloc(width + 1);
|
|
||||||
len = 0;
|
|
||||||
|
|
||||||
ptr = in;
|
|
||||||
do {
|
|
||||||
buf[len++] = *ptr++;
|
|
||||||
|
|
||||||
if (len == width || buf[len - 1] == '\n') {
|
|
||||||
if (buf[len - 1] == '\n')
|
|
||||||
len--;
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
ctx->print(ctx, "%s", buf);
|
|
||||||
len = 0;
|
|
||||||
}
|
|
||||||
} while (*ptr != '\0');
|
|
||||||
|
|
||||||
if (len != 0) {
|
|
||||||
buf[len] = '\0';
|
|
||||||
ctx->print(ctx, "%s", buf);
|
|
||||||
}
|
|
||||||
xfree(buf);
|
|
||||||
|
|
||||||
xfree(in);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-show-environment.c,v 1.2 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -27,41 +27,52 @@
|
|||||||
* Show environment.
|
* Show environment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_environment_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_show_environment_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_environment_entry = {
|
const struct cmd_entry cmd_show_environment_entry = {
|
||||||
"show-environment", "showenv",
|
"show-environment", "showenv",
|
||||||
"[-g] " CMD_TARGET_SESSION_USAGE,
|
"gt:", 0, 1,
|
||||||
0, "g",
|
"[-g] " CMD_TARGET_SESSION_USAGE " [name]",
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_show_environment_exec,
|
cmd_show_environment_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_environment_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct environ *env;
|
struct environ *env;
|
||||||
struct environ_entry *envent;
|
struct environ_entry *envent;
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'g'))
|
if (args_has(self->args, 'g'))
|
||||||
env = &global_environ;
|
env = &global_environ;
|
||||||
else {
|
else {
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
env = &s->environ;
|
env = &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]);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (envent->value != NULL)
|
||||||
|
cmdq_print(cmdq, "%s=%s", envent->name, envent->value);
|
||||||
|
else
|
||||||
|
cmdq_print(cmdq, "-%s", envent->name);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
RB_FOREACH(envent, environ, env) {
|
RB_FOREACH(envent, environ, env) {
|
||||||
if (envent->value != NULL)
|
if (envent->value != NULL)
|
||||||
ctx->print(ctx, "%s=%s", envent->name, envent->value);
|
cmdq_print(cmdq, "%s=%s", envent->name, envent->value);
|
||||||
else
|
else
|
||||||
ctx->print(ctx, "-%s", envent->name);
|
cmdq_print(cmdq, "-%s", envent->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-show-messages.c,v 1.2 2009-12-04 22:14:47 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@@ -27,30 +28,134 @@
|
|||||||
* Show client message log.
|
* Show client message log.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_messages_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_show_messages_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_messages_entry = {
|
const struct cmd_entry cmd_show_messages_entry = {
|
||||||
"show-messages", "showmsgs",
|
"show-messages", "showmsgs",
|
||||||
CMD_TARGET_CLIENT_USAGE,
|
"IJTt:", 0, 0,
|
||||||
0, "",
|
"[-IJT] " CMD_TARGET_CLIENT_USAGE,
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_show_messages_exec,
|
cmd_show_messages_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
const struct cmd_entry cmd_server_info_entry = {
|
||||||
cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
"server-info", "info",
|
||||||
{
|
"", 0, 0,
|
||||||
struct cmd_target_data *data = self->data;
|
"",
|
||||||
struct client *c;
|
0,
|
||||||
struct message_entry *msg;
|
NULL,
|
||||||
char *tim;
|
cmd_show_messages_exec
|
||||||
u_int i;
|
};
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
void cmd_show_messages_server(struct cmd_q *);
|
||||||
return (-1);
|
void cmd_show_messages_terminals(struct cmd_q *);
|
||||||
|
void cmd_show_messages_jobs(struct cmd_q *);
|
||||||
|
|
||||||
|
void
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_show_messages_terminals(struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct tty_term *term;
|
||||||
|
const struct tty_term_code_entry *ent;
|
||||||
|
struct tty_code *code;
|
||||||
|
u_int i, n;
|
||||||
|
char out[80];
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
LIST_FOREACH(term, &tty_terms, entry) {
|
||||||
|
cmdq_print(cmdq,
|
||||||
|
"Terminal %u: %s [references=%u, flags=0x%x]:",
|
||||||
|
n, term->name, term->references, term->flags);
|
||||||
|
n++;
|
||||||
|
for (i = 0; i < NTTYCODE; i++) {
|
||||||
|
ent = &tty_term_codes[i];
|
||||||
|
code = &term->codes[ent->code];
|
||||||
|
switch (code->type) {
|
||||||
|
case TTYCODE_NONE:
|
||||||
|
cmdq_print(cmdq, "%4u: %s: [missing]",
|
||||||
|
ent->code, ent->name);
|
||||||
|
break;
|
||||||
|
case TTYCODE_STRING:
|
||||||
|
strnvis(out, code->value.string, sizeof out,
|
||||||
|
VIS_OCTAL|VIS_TAB|VIS_NL);
|
||||||
|
cmdq_print(cmdq, "%4u: %s: (string) %s",
|
||||||
|
ent->code, ent->name, out);
|
||||||
|
break;
|
||||||
|
case TTYCODE_NUMBER:
|
||||||
|
cmdq_print(cmdq, "%4u: %s: (number) %d",
|
||||||
|
ent->code, ent->name, code->value.number);
|
||||||
|
break;
|
||||||
|
case TTYCODE_FLAG:
|
||||||
|
cmdq_print(cmdq, "%4u: %s: (flag) %s",
|
||||||
|
ent->code, ent->name,
|
||||||
|
code->value.flag ? "true" : "false");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_show_messages_jobs(struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct job *job;
|
||||||
|
u_int n;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
LIST_FOREACH(job, &all_jobs, lentry) {
|
||||||
|
cmdq_print(cmdq,
|
||||||
|
"Job %u: %s [fd=%d, pid=%d, status=%d]",
|
||||||
|
n, job->cmd, job->fd, job->pid, job->status);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct client *c;
|
||||||
|
struct message_entry *msg;
|
||||||
|
char *tim;
|
||||||
|
u_int i;
|
||||||
|
int done;
|
||||||
|
|
||||||
|
done = 0;
|
||||||
|
if (args_has(args, 'I') || self->entry == &cmd_server_info_entry) {
|
||||||
|
cmd_show_messages_server(cmdq);
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
if (args_has(args, 'T') || self->entry == &cmd_server_info_entry) {
|
||||||
|
if (done)
|
||||||
|
cmdq_print(cmdq, "%s", "");
|
||||||
|
cmd_show_messages_terminals(cmdq);
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
if (args_has(args, 'J') || self->entry == &cmd_server_info_entry) {
|
||||||
|
if (done)
|
||||||
|
cmdq_print(cmdq, "%s", "");
|
||||||
|
cmd_show_messages_jobs(cmdq);
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
if (done)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
|
||||||
msg = &ARRAY_ITEM(&c->message_log, i);
|
msg = &ARRAY_ITEM(&c->message_log, i);
|
||||||
@@ -58,8 +163,8 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
tim = ctime(&msg->msg_time);
|
tim = ctime(&msg->msg_time);
|
||||||
*strchr(tim, '\n') = '\0';
|
*strchr(tim, '\n') = '\0';
|
||||||
|
|
||||||
ctx->print(ctx, "%s %s", tim, msg->msg);
|
cmdq_print(cmdq, "%s %s", tim, msg->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-show-options.c,v 1.21 2009-12-10 16:59:02 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -27,62 +27,145 @@
|
|||||||
* Show options.
|
* Show options.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_options_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
|
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 *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_options_entry = {
|
const struct cmd_entry cmd_show_options_entry = {
|
||||||
"show-options", "show",
|
"show-options", "show",
|
||||||
"[-gsw] [-t target-session|target-window]",
|
"gqst:vw", 0, 1,
|
||||||
0, "gsw",
|
"[-gqsvw] [-t target-session|target-window] [option]",
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_show_options_exec,
|
cmd_show_options_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
const struct cmd_entry cmd_show_window_options_entry = {
|
||||||
cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
"show-window-options", "showw",
|
||||||
{
|
"gvt:", 0, 1,
|
||||||
struct cmd_target_data *data = self->data;
|
"[-gv] " CMD_TARGET_WINDOW_USAGE " [option]",
|
||||||
const struct set_option_entry *table;
|
0,
|
||||||
struct session *s;
|
NULL,
|
||||||
struct winlink *wl;
|
cmd_show_options_exec
|
||||||
struct options *oo;
|
};
|
||||||
struct options_entry *o;
|
|
||||||
const struct set_option_entry *entry;
|
|
||||||
const char *optval;
|
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 's')) {
|
enum cmd_retval
|
||||||
|
cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
|
struct session *s;
|
||||||
|
struct winlink *wl;
|
||||||
|
const struct options_table_entry *table;
|
||||||
|
struct options *oo;
|
||||||
|
int quiet;
|
||||||
|
|
||||||
|
if (args_has(self->args, 's')) {
|
||||||
oo = &global_options;
|
oo = &global_options;
|
||||||
table = set_option_table;
|
table = server_options_table;
|
||||||
} else if (cmd_check_flag(data->chflags, 'w')) {
|
} else if (args_has(self->args, 'w') ||
|
||||||
table = set_window_option_table;
|
self->entry == &cmd_show_window_options_entry) {
|
||||||
if (cmd_check_flag(data->chflags, 'g'))
|
table = window_options_table;
|
||||||
|
if (args_has(self->args, 'g'))
|
||||||
oo = &global_w_options;
|
oo = &global_w_options;
|
||||||
else {
|
else {
|
||||||
wl = cmd_find_window(ctx, data->target, NULL);
|
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
oo = &wl->window->options;
|
oo = &wl->window->options;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
table = set_session_option_table;
|
table = session_options_table;
|
||||||
if (cmd_check_flag(data->chflags, 'g'))
|
if (args_has(self->args, 'g'))
|
||||||
oo = &global_s_options;
|
oo = &global_s_options;
|
||||||
else {
|
else {
|
||||||
s = cmd_find_session(ctx, data->target);
|
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
oo = &s->options;
|
oo = &s->options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (entry = table; entry->name != NULL; entry++) {
|
quiet = args_has(self->args, 'q');
|
||||||
if ((o = options_find1(oo, entry->name)) == NULL)
|
if (args->argc == 0)
|
||||||
continue;
|
return (cmd_show_options_all(self, cmdq, table, oo));
|
||||||
optval = cmd_set_option_print(entry, o);
|
else
|
||||||
ctx->print(ctx, "%s %s", entry->name, optval);
|
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 struct options_table_entry *table, *oe;
|
||||||
|
struct options_entry *o;
|
||||||
|
const char *optval;
|
||||||
|
|
||||||
|
if (*args->argv[0] == '@') {
|
||||||
|
if ((o = options_find1(oo, args->argv[0])) == NULL) {
|
||||||
|
if (quiet)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
cmdq_error(cmdq, "unknown option: %s", args->argv[0]);
|
||||||
|
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 (0);
|
table = oe = NULL;
|
||||||
|
if (options_table_find(args->argv[0], &table, &oe) != 0) {
|
||||||
|
cmdq_error(cmdq, "ambiguous option: %s", args->argv[0]);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if (oe == NULL) {
|
||||||
|
if (quiet)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
cmdq_error(cmdq, "unknown option: %s", args->argv[0]);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
if ((o = options_find1(oo, oe->name)) == NULL)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
optval = options_table_print_entry(oe, o, args_has(self->args, 'v'));
|
||||||
|
if (args_has(self->args, 'v'))
|
||||||
|
cmdq_print(cmdq, "%s", optval);
|
||||||
|
else
|
||||||
|
cmdq_print(cmdq, "%s %s", oe->name, optval);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
|
cmd_show_options_all(struct cmd *self, struct cmd_q *cmdq,
|
||||||
|
const struct options_table_entry *table, struct options *oo)
|
||||||
|
{
|
||||||
|
const struct options_table_entry *oe;
|
||||||
|
struct options_entry *o;
|
||||||
|
const char *optval;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (oe = table; oe->name != NULL; oe++) {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-source-file.c,v 1.13 2010-02-08 18:29:32 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -18,114 +18,94 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sources a configuration file.
|
* Sources a configuration file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_source_file_parse(struct cmd *, int, char **, char **);
|
enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmd_q *);
|
||||||
int cmd_source_file_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_source_file_free(struct cmd *);
|
|
||||||
void cmd_source_file_init(struct cmd *, int);
|
|
||||||
size_t cmd_source_file_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_source_file_data {
|
void cmd_source_file_show(struct cmd_q *);
|
||||||
char *path;
|
void cmd_source_file_done(struct cmd_q *);
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_source_file_entry = {
|
const struct cmd_entry cmd_source_file_entry = {
|
||||||
"source-file", "source",
|
"source-file", "source",
|
||||||
|
"", 1, 1,
|
||||||
"path",
|
"path",
|
||||||
0, "",
|
0,
|
||||||
cmd_source_file_init,
|
NULL,
|
||||||
cmd_source_file_parse,
|
cmd_source_file_exec
|
||||||
cmd_source_file_exec,
|
|
||||||
cmd_source_file_free,
|
|
||||||
cmd_source_file_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
enum cmd_retval
|
||||||
void
|
cmd_source_file_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
cmd_source_file_init(struct cmd *self, unused int arg)
|
|
||||||
{
|
{
|
||||||
struct cmd_source_file_data *data;
|
struct args *args = self->args;
|
||||||
|
struct cmd_q *cmdq1;
|
||||||
|
char *cause;
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
cmdq1 = cmdq_new(NULL);
|
||||||
data->path = NULL;
|
cmdq1->client = cmdq->client;
|
||||||
}
|
cmdq1->emptyfn = cmd_source_file_done;
|
||||||
|
cmdq1->data = cmdq;
|
||||||
|
|
||||||
int
|
switch (load_cfg(args->argv[0], cmdq1, &cause)) {
|
||||||
cmd_source_file_parse(struct cmd *self, int argc, char **argv, char **cause)
|
case -1:
|
||||||
{
|
if (cfg_references == 0) {
|
||||||
struct cmd_source_file_data *data;
|
cmdq_free(cmdq1);
|
||||||
int opt;
|
cmdq_error(cmdq, "%s", cause);
|
||||||
|
free(cause);
|
||||||
self->entry->init(self, KEYC_NONE);
|
return (CMD_RETURN_ERROR);
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
}
|
||||||
}
|
ARRAY_ADD(&cfg_causes, cause);
|
||||||
argc -= optind;
|
/* FALLTHROUGH */
|
||||||
argv += optind;
|
case 0:
|
||||||
if (argc != 1)
|
if (cfg_references == 0)
|
||||||
goto usage;
|
cmd_source_file_show(cmdq);
|
||||||
|
cmdq_free(cmdq1);
|
||||||
data->path = xstrdup(argv[0]);
|
return (CMD_RETURN_NORMAL);
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_source_file_data *data = self->data;
|
|
||||||
struct causelist causes;
|
|
||||||
char *cause;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
ARRAY_INIT(&causes);
|
|
||||||
if (load_cfg(data->path, ctx, &causes) != 0) {
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&causes); i++) {
|
|
||||||
cause = ARRAY_ITEM(&causes, i);
|
|
||||||
ctx->print(ctx, "%s", cause);
|
|
||||||
xfree(cause);
|
|
||||||
}
|
|
||||||
ARRAY_FREE(&causes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
cmdq->references++;
|
||||||
|
cfg_references++;
|
||||||
|
|
||||||
|
cmdq_continue(cmdq1);
|
||||||
|
return (CMD_RETURN_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_source_file_free(struct cmd *self)
|
cmd_source_file_show(struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_source_file_data *data = self->data;
|
u_int i;
|
||||||
|
char *cause;
|
||||||
|
|
||||||
if (data->path != NULL)
|
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
|
||||||
xfree(data->path);
|
cause = ARRAY_ITEM(&cfg_causes, i);
|
||||||
xfree(data);
|
cmdq_print(cmdq, "%s", cause);
|
||||||
|
free(cause);
|
||||||
|
}
|
||||||
|
ARRAY_FREE(&cfg_causes);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
void
|
||||||
cmd_source_file_print(struct cmd *self, char *buf, size_t len)
|
cmd_source_file_done(struct cmd_q *cmdq1)
|
||||||
{
|
{
|
||||||
struct cmd_source_file_data *data = self->data;
|
struct cmd_q *cmdq = cmdq1->data;
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
if (cmdq1->client_exit >= 0)
|
||||||
if (data == NULL)
|
cmdq->client_exit = cmdq1->client_exit;
|
||||||
return (off);
|
|
||||||
if (off < len && data->path != NULL)
|
cmdq_free(cmdq1);
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->path);
|
|
||||||
return (off);
|
cfg_references--;
|
||||||
|
|
||||||
|
if (cmdq_free(cmdq))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cfg_references == 0)
|
||||||
|
cmd_source_file_show(cmdq);
|
||||||
|
cmdq_continue(cmdq);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-split-window.c,v 1.35 2010-07-02 02:49:19 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -18,7 +18,10 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
@@ -27,168 +30,111 @@
|
|||||||
* Split a window (add a new pane).
|
* Split a window (add a new pane).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_split_window_parse(struct cmd *, int, char **, char **);
|
void cmd_split_window_key_binding(struct cmd *, int);
|
||||||
int cmd_split_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmd_q *);
|
||||||
void cmd_split_window_free(struct cmd *);
|
|
||||||
void cmd_split_window_init(struct cmd *, int);
|
|
||||||
size_t cmd_split_window_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_split_window_data {
|
|
||||||
char *target;
|
|
||||||
char *cmd;
|
|
||||||
int flag_detached;
|
|
||||||
int flag_horizontal;
|
|
||||||
int percentage;
|
|
||||||
int size;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_split_window_entry = {
|
const struct cmd_entry cmd_split_window_entry = {
|
||||||
"split-window", "splitw",
|
"split-window", "splitw",
|
||||||
"[-dhv] [-p percentage|-l size] [-t target-pane] [command]",
|
"c:dF:l:hp:Pt:v", 0, 1,
|
||||||
0, "",
|
"[-dhvP] [-c start-directory] [-F format] [-p percentage|-l size] "
|
||||||
cmd_split_window_init,
|
CMD_TARGET_PANE_USAGE " [command]",
|
||||||
cmd_split_window_parse,
|
0,
|
||||||
cmd_split_window_exec,
|
cmd_split_window_key_binding,
|
||||||
cmd_split_window_free,
|
cmd_split_window_exec
|
||||||
cmd_split_window_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_split_window_init(struct cmd *self, int key)
|
cmd_split_window_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_split_window_data *data;
|
self->args = args_create(0);
|
||||||
|
if (key == '%')
|
||||||
self->data = data = xmalloc(sizeof *data);
|
args_set(self->args, 'h', NULL);
|
||||||
data->target = NULL;
|
|
||||||
data->cmd = NULL;
|
|
||||||
data->flag_detached = 0;
|
|
||||||
data->flag_horizontal = 0;
|
|
||||||
data->percentage = -1;
|
|
||||||
data->size = -1;
|
|
||||||
|
|
||||||
switch (key) {
|
|
||||||
case '%':
|
|
||||||
data->flag_horizontal = 1;
|
|
||||||
break;
|
|
||||||
case '"':
|
|
||||||
data->flag_horizontal = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_split_window_parse(struct cmd *self, int argc, char **argv, char **cause)
|
cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_split_window_data *data;
|
struct args *args = self->args;
|
||||||
int opt;
|
struct session *s;
|
||||||
const char *errstr;
|
struct winlink *wl;
|
||||||
|
struct window *w;
|
||||||
|
struct window_pane *wp, *new_wp = NULL;
|
||||||
|
struct environ env;
|
||||||
|
const char *cmd, *shell, *template;
|
||||||
|
char *cause, *new_cause, *cp;
|
||||||
|
u_int hlimit;
|
||||||
|
int size, percentage, cwd, fd = -1;
|
||||||
|
enum layout_type type;
|
||||||
|
struct layout_cell *lc;
|
||||||
|
struct client *c;
|
||||||
|
struct format_tree *ft;
|
||||||
|
|
||||||
self->entry->init(self, KEYC_NONE);
|
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
data = self->data;
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "dhl:p:t:v")) != -1) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'd':
|
|
||||||
data->flag_detached = 1;
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
data->flag_horizontal = 1;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
if (data->percentage != -1 || data->size != -1)
|
|
||||||
break;
|
|
||||||
data->size = strtonum(optarg, 1, INT_MAX, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "size %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
if (data->size != -1 || data->percentage != -1)
|
|
||||||
break;
|
|
||||||
data->percentage = strtonum(optarg, 1, 100, &errstr);
|
|
||||||
if (errstr != NULL) {
|
|
||||||
xasprintf(cause, "percentage %s", errstr);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
data->flag_horizontal = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 0 && argc != 1)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
if (argc == 1)
|
|
||||||
data->cmd = xstrdup(argv[0]);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
error:
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_split_window_data *data = self->data;
|
|
||||||
struct session *s;
|
|
||||||
struct winlink *wl;
|
|
||||||
struct window *w;
|
|
||||||
struct window_pane *wp, *new_wp = NULL;
|
|
||||||
struct environ env;
|
|
||||||
char *cmd, *cwd, *cause;
|
|
||||||
const char *shell;
|
|
||||||
u_int hlimit;
|
|
||||||
int size;
|
|
||||||
enum layout_type type;
|
|
||||||
struct layout_cell *lc;
|
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, data->target, &s, &wp)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
server_unzoom_window(w);
|
||||||
|
|
||||||
environ_init(&env);
|
environ_init(&env);
|
||||||
environ_copy(&global_environ, &env);
|
environ_copy(&global_environ, &env);
|
||||||
environ_copy(&s->environ, &env);
|
environ_copy(&s->environ, &env);
|
||||||
server_fill_environ(s, &env);
|
server_fill_environ(s, &env);
|
||||||
|
|
||||||
cmd = data->cmd;
|
if (args->argc == 0)
|
||||||
if (cmd == NULL)
|
|
||||||
cmd = options_get_string(&s->options, "default-command");
|
cmd = options_get_string(&s->options, "default-command");
|
||||||
cwd = options_get_string(&s->options, "default-path");
|
else
|
||||||
if (*cwd == '\0') {
|
cmd = args->argv[0];
|
||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
|
||||||
cwd = ctx->cmdclient->cwd;
|
if (args_has(args, 'c')) {
|
||||||
else
|
ft = format_create();
|
||||||
cwd = s->cwd;
|
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
||||||
}
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, s->curw);
|
||||||
|
format_window_pane(ft, s->curw->window->active);
|
||||||
|
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;
|
type = LAYOUT_TOPBOTTOM;
|
||||||
if (data->flag_horizontal)
|
if (args_has(args, 'h'))
|
||||||
type = LAYOUT_LEFTRIGHT;
|
type = LAYOUT_LEFTRIGHT;
|
||||||
|
|
||||||
size = -1;
|
size = -1;
|
||||||
if (data->size != -1)
|
if (args_has(args, 'l')) {
|
||||||
size = data->size;
|
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
|
||||||
else if (data->percentage != -1) {
|
if (cause != NULL) {
|
||||||
|
xasprintf(&new_cause, "size %s", cause);
|
||||||
|
free(cause);
|
||||||
|
cause = new_cause;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
} else if (args_has(args, 'p')) {
|
||||||
|
percentage = args_strtonum(args, 'p', 0, INT_MAX, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
xasprintf(&new_cause, "percentage %s", cause);
|
||||||
|
free(cause);
|
||||||
|
cause = new_cause;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
if (type == LAYOUT_TOPBOTTOM)
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
size = (wp->sy * data->percentage) / 100;
|
size = (wp->sy * percentage) / 100;
|
||||||
else
|
else
|
||||||
size = (wp->sx * data->percentage) / 100;
|
size = (wp->sx * percentage) / 100;
|
||||||
}
|
}
|
||||||
hlimit = options_get_number(&s->options, "history-limit");
|
hlimit = options_get_number(&s->options, "history-limit");
|
||||||
|
|
||||||
@@ -196,7 +142,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (*shell == '\0' || areshell(shell))
|
if (*shell == '\0' || areshell(shell))
|
||||||
shell = _PATH_BSHELL;
|
shell = _PATH_BSHELL;
|
||||||
|
|
||||||
if ((lc = layout_split_pane(wp, type, size)) == NULL) {
|
if ((lc = layout_split_pane(wp, type, size, 0)) == NULL) {
|
||||||
cause = xstrdup("pane too small");
|
cause = xstrdup("pane too small");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@@ -208,7 +154,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
|
|
||||||
if (!data->flag_detached) {
|
if (!args_has(args, 'd')) {
|
||||||
window_set_active_pane(w, new_wp);
|
window_set_active_pane(w, new_wp);
|
||||||
session_select(s, wl->idx);
|
session_select(s, wl->idx);
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
@@ -216,51 +162,37 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_status_session(s);
|
server_status_session(s);
|
||||||
|
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
return (0);
|
|
||||||
|
if (args_has(args, 'P')) {
|
||||||
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
|
template = SPLIT_WINDOW_TEMPLATE;
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
|
||||||
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, new_wp);
|
||||||
|
|
||||||
|
cp = format_expand(ft, template);
|
||||||
|
cmdq_print(cmdq, "%s", cp);
|
||||||
|
free(cp);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
}
|
||||||
|
notify_window_layout_changed(w);
|
||||||
|
|
||||||
|
if (fd != -1)
|
||||||
|
close(fd);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
if (new_wp != NULL)
|
if (new_wp != NULL)
|
||||||
window_remove_pane(w, new_wp);
|
window_remove_pane(w, new_wp);
|
||||||
ctx->error(ctx, "create pane failed: %s", cause);
|
cmdq_error(cmdq, "create pane failed: %s", cause);
|
||||||
xfree(cause);
|
free(cause);
|
||||||
return (-1);
|
if (fd != -1)
|
||||||
}
|
close(fd);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
void
|
|
||||||
cmd_split_window_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_split_window_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
if (data->cmd != NULL)
|
|
||||||
xfree(data->cmd);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_split_window_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_split_window_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->flag_detached)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -d");
|
|
||||||
if (off < len && data->flag_horizontal)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -h");
|
|
||||||
if (off < len && data->size > 0)
|
|
||||||
off += xsnprintf(buf + off, len - off, " -l %d", data->size);
|
|
||||||
if (off < len && data->percentage > 0) {
|
|
||||||
off += xsnprintf(
|
|
||||||
buf + off, len - off, " -p %d", data->percentage);
|
|
||||||
}
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
if (off < len && data->cmd != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " ", data->cmd);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
104
cmd-string.c
104
cmd-string.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-string.c,v 1.32 2010-12-13 22:53:56 nicm Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -31,11 +31,12 @@
|
|||||||
* Parse a command from a string.
|
* Parse a command from a string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_string_getc(const char *, size_t *);
|
int cmd_string_getc(const char *, size_t *);
|
||||||
void cmd_string_ungetc(size_t *);
|
void cmd_string_ungetc(size_t *);
|
||||||
char *cmd_string_string(const char *, size_t *, char, int);
|
void cmd_string_copy(char **, char *, size_t *);
|
||||||
char *cmd_string_variable(const char *, size_t *);
|
char *cmd_string_string(const char *, size_t *, char, int);
|
||||||
char *cmd_string_expand_tilde(const char *, size_t *);
|
char *cmd_string_variable(const char *, size_t *);
|
||||||
|
char *cmd_string_expand_tilde(const char *, size_t *);
|
||||||
|
|
||||||
int
|
int
|
||||||
cmd_string_getc(const char *s, size_t *p)
|
cmd_string_getc(const char *s, size_t *p)
|
||||||
@@ -58,7 +59,8 @@ cmd_string_ungetc(size_t *p)
|
|||||||
* string, or NULL for empty command.
|
* string, or NULL for empty command.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file,
|
||||||
|
u_int line, char **cause)
|
||||||
{
|
{
|
||||||
size_t p;
|
size_t p;
|
||||||
int ch, i, argc, rval;
|
int ch, i, argc, rval;
|
||||||
@@ -84,26 +86,17 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
case '\'':
|
case '\'':
|
||||||
if ((t = cmd_string_string(s, &p, '\'', 0)) == NULL)
|
if ((t = cmd_string_string(s, &p, '\'', 0)) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
cmd_string_copy(&buf, t, &len);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
|
||||||
len += strlen(t);
|
|
||||||
xfree(t);
|
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
|
if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
cmd_string_copy(&buf, t, &len);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
|
||||||
len += strlen(t);
|
|
||||||
xfree(t);
|
|
||||||
break;
|
break;
|
||||||
case '$':
|
case '$':
|
||||||
if ((t = cmd_string_variable(s, &p)) == NULL)
|
if ((t = cmd_string_variable(s, &p)) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
cmd_string_copy(&buf, t, &len);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
|
||||||
len += strlen(t);
|
|
||||||
xfree(t);
|
|
||||||
break;
|
break;
|
||||||
case '#':
|
case '#':
|
||||||
/* Comment: discard rest of line. */
|
/* Comment: discard rest of line. */
|
||||||
@@ -139,7 +132,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
*cmdlist = cmd_list_parse(argc, argv, cause);
|
*cmdlist = cmd_list_parse(argc, argv, file, line, cause);
|
||||||
if (*cmdlist == NULL)
|
if (*cmdlist == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@@ -147,12 +140,10 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
goto out;
|
goto out;
|
||||||
case '~':
|
case '~':
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
if ((t = cmd_string_expand_tilde(s, &p)) == NULL)
|
t = cmd_string_expand_tilde(s, &p);
|
||||||
|
if (t == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
cmd_string_copy(&buf, t, &len);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
|
||||||
len += strlen(t);
|
|
||||||
xfree(t);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
@@ -170,18 +161,31 @@ error:
|
|||||||
xasprintf(cause, "invalid or unknown command: %s", s);
|
xasprintf(cause, "invalid or unknown command: %s", s);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (buf != NULL)
|
free(buf);
|
||||||
xfree(buf);
|
|
||||||
|
|
||||||
if (argv != NULL) {
|
if (argv != NULL) {
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
xfree(argv[i]);
|
free(argv[i]);
|
||||||
xfree(argv);
|
free(argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (rval);
|
return (rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_string_copy(char **dst, char *src, size_t *len)
|
||||||
|
{
|
||||||
|
size_t srclen;
|
||||||
|
|
||||||
|
srclen = strlen(src);
|
||||||
|
|
||||||
|
*dst = xrealloc(*dst, 1, *len + srclen + 1);
|
||||||
|
strlcpy(*dst + *len, src, srclen + 1);
|
||||||
|
|
||||||
|
*len += srclen;
|
||||||
|
free(src);
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
||||||
{
|
{
|
||||||
@@ -221,10 +225,7 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
|||||||
break;
|
break;
|
||||||
if ((t = cmd_string_variable(s, p)) == NULL)
|
if ((t = cmd_string_variable(s, p)) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
cmd_string_copy(&buf, t, &len);
|
||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
|
||||||
len += strlen(t);
|
|
||||||
xfree(t);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,8 +240,7 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
|||||||
return (buf);
|
return (buf);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (buf != NULL)
|
free(buf);
|
||||||
xfree(buf);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,14 +303,13 @@ cmd_string_variable(const char *s, size_t *p)
|
|||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
envent = environ_find(&global_environ, buf);
|
envent = environ_find(&global_environ, buf);
|
||||||
xfree(buf);
|
free(buf);
|
||||||
if (envent == NULL)
|
if (envent == NULL)
|
||||||
return (xstrdup(""));
|
return (xstrdup(""));
|
||||||
return (xstrdup(envent->value));
|
return (xstrdup(envent->value));
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (buf != NULL)
|
free(buf);
|
||||||
xfree(buf);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,10 +318,13 @@ cmd_string_expand_tilde(const char *s, size_t *p)
|
|||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
struct environ_entry *envent;
|
struct environ_entry *envent;
|
||||||
char *home, *path, *username;
|
char *home, *path, *user, *cp;
|
||||||
|
int last;
|
||||||
|
|
||||||
home = NULL;
|
home = NULL;
|
||||||
if (cmd_string_getc(s, p) == '/') {
|
|
||||||
|
last = cmd_string_getc(s, p);
|
||||||
|
if (last == EOF || last == '/' || last == ' '|| last == '\t') {
|
||||||
envent = environ_find(&global_environ, "HOME");
|
envent = environ_find(&global_environ, "HOME");
|
||||||
if (envent != NULL && *envent->value != '\0')
|
if (envent != NULL && *envent->value != '\0')
|
||||||
home = envent->value;
|
home = envent->value;
|
||||||
@@ -330,15 +332,27 @@ cmd_string_expand_tilde(const char *s, size_t *p)
|
|||||||
home = pw->pw_dir;
|
home = pw->pw_dir;
|
||||||
} else {
|
} else {
|
||||||
cmd_string_ungetc(p);
|
cmd_string_ungetc(p);
|
||||||
if ((username = cmd_string_string(s, p, '/', 0)) == NULL)
|
|
||||||
return (NULL);
|
cp = user = xmalloc(strlen(s));
|
||||||
if ((pw = getpwnam(username)) != NULL)
|
for (;;) {
|
||||||
|
last = cmd_string_getc(s, p);
|
||||||
|
if (last == EOF || last == '/' || last == ' '|| last == '\t')
|
||||||
|
break;
|
||||||
|
*cp++ = last;
|
||||||
|
}
|
||||||
|
*cp = '\0';
|
||||||
|
|
||||||
|
if ((pw = getpwnam(user)) != NULL)
|
||||||
home = pw->pw_dir;
|
home = pw->pw_dir;
|
||||||
xfree(username);
|
free(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (home == NULL)
|
if (home == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
xasprintf(&path, "%s/", home);
|
if (last != EOF)
|
||||||
|
xasprintf(&path, "%s%c", home, last);
|
||||||
|
else
|
||||||
|
xasprintf(&path, "%s", home);
|
||||||
return (path);
|
return (path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-suspend-client.c,v 1.5 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -27,36 +27,29 @@
|
|||||||
* Suspend client with SIGTSTP.
|
* Suspend client with SIGTSTP.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_suspend_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_suspend_client_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
struct cmd_suspend_client_data {
|
|
||||||
char *name;
|
|
||||||
char *target;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_suspend_client_entry = {
|
const struct cmd_entry cmd_suspend_client_entry = {
|
||||||
"suspend-client", "suspendc",
|
"suspend-client", "suspendc",
|
||||||
"[-c target-client]",
|
"t:", 0, 0,
|
||||||
0, "",
|
CMD_TARGET_CLIENT_USAGE,
|
||||||
cmd_target_init,
|
0,
|
||||||
cmd_target_parse,
|
NULL,
|
||||||
cmd_suspend_client_exec,
|
cmd_suspend_client_exec
|
||||||
cmd_target_free,
|
|
||||||
cmd_target_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_suspend_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_suspend_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
tty_stop_tty(&c->tty);
|
tty_stop_tty(&c->tty);
|
||||||
c->flags |= CLIENT_SUSPENDED;
|
c->flags |= CLIENT_SUSPENDED;
|
||||||
server_write_client(c, MSG_SUSPEND, NULL, 0);
|
server_write_client(c, MSG_SUSPEND, NULL, 0);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-swap-pane.c,v 1.15 2009-12-04 22:14:47 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,73 +26,70 @@
|
|||||||
* Swap two panes.
|
* Swap two panes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_swap_pane_init(struct cmd *, int);
|
void cmd_swap_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_swap_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_swap_pane_entry = {
|
const struct cmd_entry cmd_swap_pane_entry = {
|
||||||
"swap-pane", "swapp",
|
"swap-pane", "swapp",
|
||||||
|
"dDs:t:U", 0, 0,
|
||||||
"[-dDU] " CMD_SRCDST_PANE_USAGE,
|
"[-dDU] " CMD_SRCDST_PANE_USAGE,
|
||||||
0, "dDU",
|
0,
|
||||||
cmd_swap_pane_init,
|
cmd_swap_pane_key_binding,
|
||||||
cmd_srcdst_parse,
|
cmd_swap_pane_exec
|
||||||
cmd_swap_pane_exec,
|
|
||||||
cmd_srcdst_free,
|
|
||||||
cmd_srcdst_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_swap_pane_init(struct cmd *self, int key)
|
cmd_swap_pane_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_target_data *data;
|
self->args = args_create(0);
|
||||||
|
|
||||||
cmd_srcdst_init(self, key);
|
|
||||||
data = self->data;
|
|
||||||
|
|
||||||
if (key == '{')
|
if (key == '{')
|
||||||
cmd_set_flag(&data->chflags, 'U');
|
args_set(self->args, 'U', NULL);
|
||||||
else if (key == '}')
|
else if (key == '}')
|
||||||
cmd_set_flag(&data->chflags, 'D');
|
args_set(self->args, 'D', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum cmd_retval
|
||||||
int
|
cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
{
|
||||||
struct cmd_srcdst_data *data = self->data;
|
struct args *args = self->args;
|
||||||
struct winlink *src_wl, *dst_wl;
|
struct winlink *src_wl, *dst_wl;
|
||||||
struct window *src_w, *dst_w;
|
struct window *src_w, *dst_w;
|
||||||
struct window_pane *tmp_wp, *src_wp, *dst_wp;
|
struct window_pane *tmp_wp, *src_wp, *dst_wp;
|
||||||
struct layout_cell *src_lc, *dst_lc;
|
struct layout_cell *src_lc, *dst_lc;
|
||||||
u_int sx, sy, xoff, yoff;
|
u_int sx, sy, xoff, yoff;
|
||||||
|
|
||||||
if (data == NULL)
|
dst_wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &dst_wp);
|
||||||
return (0);
|
if (dst_wl == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
if ((dst_wl = cmd_find_pane(ctx, data->dst, NULL, &dst_wp)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
dst_w = dst_wl->window;
|
dst_w = dst_wl->window;
|
||||||
|
server_unzoom_window(dst_w);
|
||||||
|
|
||||||
if (data->src == NULL) {
|
if (!args_has(args, 's')) {
|
||||||
src_w = dst_w;
|
src_w = dst_w;
|
||||||
if (cmd_check_flag(data->chflags, 'D')) {
|
if (args_has(self->args, 'D')) {
|
||||||
src_wp = TAILQ_NEXT(dst_wp, entry);
|
src_wp = TAILQ_NEXT(dst_wp, entry);
|
||||||
if (src_wp == NULL)
|
if (src_wp == NULL)
|
||||||
src_wp = TAILQ_FIRST(&dst_w->panes);
|
src_wp = TAILQ_FIRST(&dst_w->panes);
|
||||||
} else if (cmd_check_flag(data->chflags, 'U')) {
|
} else if (args_has(self->args, 'U')) {
|
||||||
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||||
if (src_wp == NULL)
|
if (src_wp == NULL)
|
||||||
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
||||||
} else
|
} else {
|
||||||
return (0);
|
src_wl = cmd_find_pane(cmdq, NULL, NULL, &src_wp);
|
||||||
|
if (src_wl == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
src_w = src_wl->window;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
src_wl = cmd_find_pane(ctx, data->src, NULL, &src_wp);
|
src_wl = cmd_find_pane(cmdq, args_get(args, 's'), NULL, &src_wp);
|
||||||
if (src_wl == NULL)
|
if (src_wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
src_w = src_wl->window;
|
src_w = src_wl->window;
|
||||||
}
|
}
|
||||||
|
server_unzoom_window(src_w);
|
||||||
|
|
||||||
if (src_wp == dst_wp)
|
if (src_wp == dst_wp)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
tmp_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
tmp_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||||
TAILQ_REMOVE(&dst_w->panes, dst_wp, entry);
|
TAILQ_REMOVE(&dst_w->panes, dst_wp, entry);
|
||||||
@@ -121,7 +118,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
dst_wp->xoff = xoff; dst_wp->yoff = yoff;
|
dst_wp->xoff = xoff; dst_wp->yoff = yoff;
|
||||||
window_pane_resize(dst_wp, sx, sy);
|
window_pane_resize(dst_wp, sx, sy);
|
||||||
|
|
||||||
if (!cmd_check_flag(data->chflags, 'd')) {
|
if (!args_has(self->args, 'd')) {
|
||||||
if (src_w != dst_w) {
|
if (src_w != dst_w) {
|
||||||
window_set_active_pane(src_w, dst_wp);
|
window_set_active_pane(src_w, dst_wp);
|
||||||
window_set_active_pane(dst_w, src_wp);
|
window_set_active_pane(dst_w, src_wp);
|
||||||
@@ -137,8 +134,14 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (dst_w->active == dst_wp)
|
if (dst_w->active == dst_wp)
|
||||||
window_set_active_pane(dst_w, src_wp);
|
window_set_active_pane(dst_w, src_wp);
|
||||||
}
|
}
|
||||||
|
if (src_w != dst_w) {
|
||||||
|
if (src_w->last == src_wp)
|
||||||
|
src_w->last = NULL;
|
||||||
|
if (dst_w->last == dst_wp)
|
||||||
|
dst_w->last = NULL;
|
||||||
|
}
|
||||||
server_redraw_window(src_w);
|
server_redraw_window(src_w);
|
||||||
server_redraw_window(dst_w);
|
server_redraw_window(dst_w);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-swap-window.c,v 1.19 2009-11-14 17:56:39 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -26,49 +26,50 @@
|
|||||||
* Swap one window with another.
|
* Swap one window with another.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_swap_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_swap_window_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_swap_window_entry = {
|
const struct cmd_entry cmd_swap_window_entry = {
|
||||||
"swap-window", "swapw",
|
"swap-window", "swapw",
|
||||||
|
"ds:t:", 0, 0,
|
||||||
"[-d] " CMD_SRCDST_WINDOW_USAGE,
|
"[-d] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
0, "d",
|
0,
|
||||||
cmd_srcdst_init,
|
NULL,
|
||||||
cmd_srcdst_parse,
|
cmd_swap_window_exec
|
||||||
cmd_swap_window_exec,
|
|
||||||
cmd_srcdst_free,
|
|
||||||
cmd_srcdst_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_swap_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_srcdst_data *data = self->data;
|
struct args *args = self->args;
|
||||||
|
const char *target_src, *target_dst;
|
||||||
struct session *src, *dst;
|
struct session *src, *dst;
|
||||||
struct session_group *sg_src, *sg_dst;
|
struct session_group *sg_src, *sg_dst;
|
||||||
struct winlink *wl_src, *wl_dst;
|
struct winlink *wl_src, *wl_dst;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
|
|
||||||
if ((wl_src = cmd_find_window(ctx, data->src, &src)) == NULL)
|
target_src = args_get(args, 's');
|
||||||
return (-1);
|
if ((wl_src = cmd_find_window(cmdq, target_src, &src)) == NULL)
|
||||||
if ((wl_dst = cmd_find_window(ctx, data->dst, &dst)) == NULL)
|
return (CMD_RETURN_ERROR);
|
||||||
return (-1);
|
target_dst = args_get(args, 't');
|
||||||
|
if ((wl_dst = cmd_find_window(cmdq, target_dst, &dst)) == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
sg_src = session_group_find(src);
|
sg_src = session_group_find(src);
|
||||||
sg_dst = session_group_find(dst);
|
sg_dst = session_group_find(dst);
|
||||||
if (src != dst &&
|
if (src != dst &&
|
||||||
sg_src != NULL && sg_dst != NULL && sg_src == sg_dst) {
|
sg_src != NULL && sg_dst != NULL && sg_src == sg_dst) {
|
||||||
ctx->error(ctx, "can't move window, sessions are grouped");
|
cmdq_error(cmdq, "can't move window, sessions are grouped");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_dst->window == wl_src->window)
|
if (wl_dst->window == wl_src->window)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
w = wl_dst->window;
|
w = wl_dst->window;
|
||||||
wl_dst->window = wl_src->window;
|
wl_dst->window = wl_src->window;
|
||||||
wl_src->window = w;
|
wl_src->window = w;
|
||||||
|
|
||||||
if (!cmd_check_flag(data->chflags, 'd')) {
|
if (!args_has(self->args, 'd')) {
|
||||||
session_select(dst, wl_dst->idx);
|
session_select(dst, wl_dst->idx);
|
||||||
if (src != dst)
|
if (src != dst)
|
||||||
session_select(src, wl_src->idx);
|
session_select(src, wl_src->idx);
|
||||||
@@ -81,5 +82,5 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-switch-client.c,v 1.23 2010-12-22 15:31:00 tcunha Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@@ -27,190 +27,114 @@
|
|||||||
* Switch client to a different session.
|
* Switch client to a different session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_switch_client_init(struct cmd *, int);
|
void cmd_switch_client_key_binding(struct cmd *, int);
|
||||||
int cmd_switch_client_parse(struct cmd *, int, char **, char **);
|
enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_q *);
|
||||||
int cmd_switch_client_exec(struct cmd *, struct cmd_ctx *);
|
|
||||||
void cmd_switch_client_free(struct cmd *);
|
|
||||||
size_t cmd_switch_client_print(struct cmd *, char *, size_t);
|
|
||||||
|
|
||||||
struct cmd_switch_client_data {
|
|
||||||
char *name;
|
|
||||||
char *target;
|
|
||||||
int flag_last;
|
|
||||||
int flag_next;
|
|
||||||
int flag_previous;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_switch_client_entry = {
|
const struct cmd_entry cmd_switch_client_entry = {
|
||||||
"switch-client", "switchc",
|
"switch-client", "switchc",
|
||||||
"[-lnp] [-c target-client] [-t target-session]",
|
"lc:npt:r", 0, 0,
|
||||||
0, "",
|
"[-lnpr] [-c target-client] [-t target-session]",
|
||||||
cmd_switch_client_init,
|
CMD_READONLY,
|
||||||
cmd_switch_client_parse,
|
cmd_switch_client_key_binding,
|
||||||
cmd_switch_client_exec,
|
cmd_switch_client_exec
|
||||||
cmd_switch_client_free,
|
|
||||||
cmd_switch_client_print
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_switch_client_init(struct cmd *self, int key)
|
cmd_switch_client_key_binding(struct cmd *self, int key)
|
||||||
{
|
{
|
||||||
struct cmd_switch_client_data *data;
|
self->args = args_create(0);
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
|
||||||
data->name = NULL;
|
|
||||||
data->target = NULL;
|
|
||||||
data->flag_last = 0;
|
|
||||||
data->flag_next = 0;
|
|
||||||
data->flag_previous = 0;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case '(':
|
case '(':
|
||||||
data->flag_previous = 1;
|
args_set(self->args, 'p', NULL);
|
||||||
break;
|
break;
|
||||||
case ')':
|
case ')':
|
||||||
data->flag_next = 1;
|
args_set(self->args, 'n', NULL);
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
data->flag_last = 1;
|
args_set(self->args, 'l', NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_switch_client_parse(struct cmd *self, int argc, char **argv, char **cause)
|
cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_switch_client_data *data;
|
struct args *args = self->args;
|
||||||
int opt;
|
struct client *c;
|
||||||
|
struct session *s = NULL;
|
||||||
|
struct winlink *wl = NULL;
|
||||||
|
struct window *w = NULL;
|
||||||
|
struct window_pane *wp = NULL;
|
||||||
|
const char *tflag;
|
||||||
|
|
||||||
self->entry->init(self, KEYC_NONE);
|
if ((c = cmd_find_client(cmdq, args_get(args, 'c'), 0)) == NULL)
|
||||||
data = self->data;
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "c:lnpt:")) != -1) {
|
if (args_has(args, 'r')) {
|
||||||
switch (opt) {
|
if (c->flags & CLIENT_READONLY) {
|
||||||
case 'c':
|
c->flags &= ~CLIENT_READONLY;
|
||||||
if (data->name == NULL)
|
cmdq_info(cmdq, "made client writable");
|
||||||
data->name = xstrdup(optarg);
|
} else {
|
||||||
break;
|
c->flags |= CLIENT_READONLY;
|
||||||
case 'l':
|
cmdq_info(cmdq, "made client read-only");
|
||||||
if (data->flag_next || data->flag_previous ||
|
|
||||||
data->target != NULL)
|
|
||||||
goto usage;
|
|
||||||
data->flag_last = 1;
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
if (data->flag_previous || data->flag_last ||
|
|
||||||
data->target != NULL)
|
|
||||||
goto usage;
|
|
||||||
data->flag_next = 1;
|
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
if (data->flag_next || data->flag_last ||
|
|
||||||
data->target != NULL)
|
|
||||||
goto usage;
|
|
||||||
data->flag_next = 1;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (data->flag_next || data->flag_previous)
|
|
||||||
goto usage;
|
|
||||||
if (data->target == NULL)
|
|
||||||
data->target = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc != 0)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
return (0);
|
tflag = args_get(args, 't');
|
||||||
|
if (args_has(args, 'n')) {
|
||||||
usage:
|
|
||||||
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
|
|
||||||
|
|
||||||
self->entry->free(self);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct cmd_switch_client_data *data = self->data;
|
|
||||||
struct client *c;
|
|
||||||
struct session *s;
|
|
||||||
|
|
||||||
if (data == NULL)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, data->name)) == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
s = NULL;
|
|
||||||
if (data->flag_next) {
|
|
||||||
if ((s = session_next_session(c->session)) == NULL) {
|
if ((s = session_next_session(c->session)) == NULL) {
|
||||||
ctx->error(ctx, "can't find next session");
|
cmdq_error(cmdq, "can't find next session");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (data->flag_previous) {
|
} else if (args_has(args, 'p')) {
|
||||||
if ((s = session_previous_session(c->session)) == NULL) {
|
if ((s = session_previous_session(c->session)) == NULL) {
|
||||||
ctx->error(ctx, "can't find previous session");
|
cmdq_error(cmdq, "can't find previous session");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (data->flag_last) {
|
} else if (args_has(args, 'l')) {
|
||||||
if (c->last_session != NULL && session_alive(c->last_session))
|
if (c->last_session != NULL && session_alive(c->last_session))
|
||||||
s = c->last_session;
|
s = c->last_session;
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
ctx->error(ctx, "can't find last session");
|
cmdq_error(cmdq, "can't find last session");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
s = cmd_find_session(ctx, data->target);
|
if (tflag == NULL) {
|
||||||
if (s == NULL)
|
if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
|
||||||
return (-1);
|
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 = cmd_lookup_windowid(tflag);
|
||||||
|
if (w == NULL &&
|
||||||
|
(wp = cmd_lookup_paneid(tflag)) != NULL)
|
||||||
|
w = wp->window;
|
||||||
|
if (w != NULL)
|
||||||
|
wl = winlink_find_by_window(&s->windows, w);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmdq->client == NULL)
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
if (wl != NULL) {
|
||||||
|
if (wp != NULL)
|
||||||
|
window_set_active_pane(wp->window, wp);
|
||||||
|
session_set_current(s, wl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (c->session != NULL)
|
if (c->session != NULL)
|
||||||
c->last_session = c->session;
|
c->last_session = c->session;
|
||||||
c->session = s;
|
c->session = s;
|
||||||
|
session_update_activity(s);
|
||||||
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_check_unattached();
|
server_check_unattached();
|
||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_switch_client_free(struct cmd *self)
|
|
||||||
{
|
|
||||||
struct cmd_switch_client_data *data = self->data;
|
|
||||||
|
|
||||||
if (data->name != NULL)
|
|
||||||
xfree(data->name);
|
|
||||||
if (data->target != NULL)
|
|
||||||
xfree(data->target);
|
|
||||||
xfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cmd_switch_client_print(struct cmd *self, char *buf, size_t len)
|
|
||||||
{
|
|
||||||
struct cmd_switch_client_data *data = self->data;
|
|
||||||
size_t off = 0;
|
|
||||||
|
|
||||||
off += xsnprintf(buf, len, "%s", self->entry->name);
|
|
||||||
if (data == NULL)
|
|
||||||
return (off);
|
|
||||||
if (off < len && data->flag_last)
|
|
||||||
off += xsnprintf(buf + off, len - off, "%s", " -l");
|
|
||||||
if (off < len && data->flag_next)
|
|
||||||
off += xsnprintf(buf + off, len - off, "%s", " -n");
|
|
||||||
if (off < len && data->flag_previous)
|
|
||||||
off += xsnprintf(buf + off, len - off, "%s", " -p");
|
|
||||||
if (off < len && data->name != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -c ", data->name);
|
|
||||||
if (off < len && data->target != NULL)
|
|
||||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
|
||||||
return (off);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user