Mercurial > vim
comparison runtime/doc/channel.txt @ 8094:18a3f0f05244 v7.4.1341
commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 16 21:03:07 2016 +0100
patch 7.4.1341
Problem: It's difficult to add more arguments to ch_sendraw() and
ch_sendexpr().
Solution: Make the third option a dictionary.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 16 Feb 2016 21:15:05 +0100 |
parents | abd64cf67bcf |
children | f5da459c5698 |
comparison
equal
deleted
inserted
replaced
8093:4ffd0f8167f8 | 8094:18a3f0f05244 |
---|---|
1 *channel.txt* For Vim version 7.4. Last change: 2016 Feb 15 | 1 *channel.txt* For Vim version 7.4. Last change: 2016 Feb 16 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
115 | 115 |
116 {options} is a dictionary with optional entries: | 116 {options} is a dictionary with optional entries: |
117 | 117 |
118 "mode" can be: *channel-mode* | 118 "mode" can be: *channel-mode* |
119 "json" - Use JSON, see below; most convenient way. Default. | 119 "json" - Use JSON, see below; most convenient way. Default. |
120 "js" - Use JavaScript encoding, more efficient than JSON. | 120 "js" - Use JS (JavaScript) encoding, more efficient than JSON. |
121 "nl" - Use messages that end in a NL character | 121 "nl" - Use messages that end in a NL character |
122 "raw" - Use raw messages | 122 "raw" - Use raw messages |
123 | 123 |
124 *channel-callback* | 124 *channel-callback* |
125 "callback" A function that is called when a message is received that is | 125 "callback" A function that is called when a message is received that is |
186 *E896* *E630* *E631* | 186 *E896* *E630* *E631* |
187 | 187 |
188 ============================================================================== | 188 ============================================================================== |
189 4. Using a JSON or JS channel *channel-use* | 189 4. Using a JSON or JS channel *channel-use* |
190 | 190 |
191 If {mode} is "json" then a message can be sent synchronously like this: > | 191 If mode is JSON then a message can be sent synchronously like this: > |
192 let response = ch_sendexpr(channel, {expr}) | 192 let response = ch_sendexpr(channel, {expr}) |
193 This awaits a response from the other side. | 193 This awaits a response from the other side. |
194 | 194 |
195 When {mode} is "js" this works the same, except that the messages use | 195 When mode is JS this works the same, except that the messages use |
196 JavaScript encoding. See |js_encode()| for the difference. | 196 JavaScript encoding. See |js_encode()| for the difference. |
197 | 197 |
198 To send a message, without handling a response: > | 198 To send a message, without handling a response: > |
199 call ch_sendexpr(channel, {expr}, 0) | 199 call ch_sendexpr(channel, {expr}, 0) |
200 | 200 |
240 is then completely responsible for correct encoding and decoding. | 240 is then completely responsible for correct encoding and decoding. |
241 | 241 |
242 ============================================================================== | 242 ============================================================================== |
243 5. Channel commands *channel-commands* | 243 5. Channel commands *channel-commands* |
244 | 244 |
245 With a "json" channel the process can send commands to Vim that will be | 245 With a JSON channel the process can send commands to Vim that will be |
246 handled by Vim internally, it does not require a handler for the channel. | 246 handled by Vim internally, it does not require a handler for the channel. |
247 | 247 |
248 Possible commands are: *E903* *E904* *E905* | 248 Possible commands are: *E903* *E904* *E905* |
249 ["redraw" {forced}] | 249 ["redraw" {forced}] |
250 ["ex", {Ex command}] | 250 ["ex", {Ex command}] |
314 ["expr","setline('$', ['one', 'two', 'three'])"] ~ | 314 ["expr","setline('$', ['one', 'two', 'three'])"] ~ |
315 | 315 |
316 ============================================================================== | 316 ============================================================================== |
317 6. Using a RAW or NL channel *channel-raw* | 317 6. Using a RAW or NL channel *channel-raw* |
318 | 318 |
319 If {mode} is "raw" then a message can be send like this: > | 319 If mode is RAW or NL then a message can be send like this: > |
320 let response = ch_sendraw(channel, {string}) | 320 let response = ch_sendraw(channel, {string}) |
321 | |
321 The {string} is sent as-is. The response will be what can be read from the | 322 The {string} is sent as-is. The response will be what can be read from the |
322 channel right away. Since Vim doesn't know how to recognize the end of the | 323 channel right away. Since Vim doesn't know how to recognize the end of the |
323 message you need to take care of it yourself. The timeout applies for reading | 324 message you need to take care of it yourself. The timeout applies for reading |
324 the first byte, after that it will not wait for anything more. | 325 the first byte, after that it will not wait for anything more. |
325 | 326 |
326 If {mode} is "nl" you can send a message in a similar way. You are expected | 327 If mode is "nl" you can send a message in a similar way. You are expected |
327 to put in the NL after each message. Thus you can also send several messages | 328 to put in the NL after each message. Thus you can also send several messages |
328 ending in a NL at once. The response will be the text up to and including the | 329 ending in a NL at once. The response will be the text up to and including the |
329 first NL. This can also be just the NL for an empty response. | 330 first NL. This can also be just the NL for an empty response. |
330 If no NL was read before the channel timeout an empty string is returned. | 331 If no NL was read before the channel timeout an empty string is returned. |
331 | 332 |
448 | 449 |
449 The {options} argument in job_start() is a dictionary. All entries are | 450 The {options} argument in job_start() is a dictionary. All entries are |
450 optional. The same options can be used with job_setoptions(job, {options}). | 451 optional. The same options can be used with job_setoptions(job, {options}). |
451 | 452 |
452 TODO: *job-out-cb* | 453 TODO: *job-out-cb* |
454 "callback": handler | |
453 "out-cb": handler Callback for when there is something to read on | 455 "out-cb": handler Callback for when there is something to read on |
454 stdout. | 456 stdout. |
455 TODO: *job-err-cb* | 457 TODO: *job-err-cb* |
456 "err-cb": handler Callback for when there is something to read on | 458 "err-cb": handler Callback for when there is something to read on |
457 stderr. Defaults to the same callback as "out-cb". | 459 stderr. Defaults to the same callback as "out-cb". |
482 "out-file": "/path/file" the file to write to | 484 "out-file": "/path/file" the file to write to |
483 "out-io": "buffer" stdout appends to a buffer | 485 "out-io": "buffer" stdout appends to a buffer |
484 "out-buffer": "name" buffer to append to | 486 "out-buffer": "name" buffer to append to |
485 | 487 |
486 TODO: *job-err-io* | 488 TODO: *job-err-io* |
487 "err-io": "out" same as stdout (default) | 489 "err-io": "out" same type as stdout (default) |
488 "err-io": "null" disconnect stderr | 490 "err-io": "null" disconnect stderr |
489 "err-io": "pipe" stderr is connected to the channel | 491 "err-io": "pipe" stderr is connected to the channel |
490 "err-io": "file" stderr writes to a file | 492 "err-io": "file" stderr writes to a file |
491 "err-file": "/path/file" the file to write to | 493 "err-file": "/path/file" the file to write to |
492 "err-io": "buffer" stderr appends to a buffer | 494 "err-io": "buffer" stderr appends to a buffer |