1- *channel.txt* For Vim version 7.4. Last change: 2016 Jan 31
1+ *channel.txt* For Vim version 7.4. Last change: 2016 Feb 04
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -11,7 +11,7 @@ DRAFT DRAFT DRAFT DRAFT DRAFT DRAFT DRAFT DRAFT DRAFT DRAFT
1111Vim uses channels to communicate with other processes.
1212A channel uses a socket. *socket-interface*
1313
14- Vim current supports up to 10 simultanious channels.
14+ Vim current supports up to 10 simultaneous channels.
1515The Netbeans interface also uses a channel. | netbeans |
1616
17171. Demo | channel-demo |
@@ -32,13 +32,13 @@ $VIMRUNTIME/tools/demoserver.py
3232Run it in one terminal. We will call this T1.
3333
3434Run Vim in another terminal. Connect to the demo server with: >
35- let handle = connect ('localhost:8765', 'json')
35+ let handle = ch_open ('localhost:8765', 'json')
3636
3737 In T1 you should see:
3838 === socket opened === ~
3939
4040You can now send a message to the server: >
41- echo sendexpr (handle, 'hello!')
41+ echo ch_sendexpr (handle, 'hello!')
4242
4343 The message is received in T1 and a response is sent back to Vim.
4444You can see the raw messages in T1. What Vim sends is:
@@ -57,19 +57,19 @@ To handle asynchronous communication a callback needs to be used: >
5757 func MyHandler(handle, msg)
5858 echo "from the handler: " . a:msg
5959 endfunc
60- call sendexpr (handle, 'hello!', "MyHandler")
60+ call ch_sendexpr (handle, 'hello!', "MyHandler")
6161
6262 Instead of giving a callback with every send call, it can also be specified
6363when opening the channel: >
64- call disconnect (handle)
65- let handle = connect ('localhost:8765', 'json', "MyHandler")
66- call sendexpr (handle, 'hello!', 0)
64+ call ch_close (handle)
65+ let handle = ch_open ('localhost:8765', 'json', "MyHandler")
66+ call ch_sendexpr (handle, 'hello!', 0)
6767
6868==============================================================================
69692. Opening a channel *channel-open*
7070
71- To open a channel:
72- let handle = connect ({address} , {mode} , {callback} )
71+ To open a channel: >
72+ let handle = ch_open ({address}, {mode}, {callback})
7373
7474{address} has the form "hostname:port". E.g., "localhost:8765".
7575
@@ -84,7 +84,7 @@ message. Example: >
8484 func Handle(handle, msg)
8585 echo 'Received: ' . a:msg
8686 endfunc
87- let handle = connect ("localhost:8765", 'json', "Handle")
87+ let handle = ch_open ("localhost:8765", 'json', "Handle")
8888
8989 When {mode} is "json" the "msg" argument is the body of the received message,
9090converted to Vim types.
@@ -94,11 +94,11 @@ When {mode} is "json" the {callback} is optional. When omitted it is only
9494possible to receive a message after sending one.
9595
9696The handler can be added or changed later: >
97- call sethandler (handle, {callback})
97+ call ch_setcallback (handle, {callback})
9898 When {callback} is empty (zero or an empty string) the handler is removed.
9999
100100Once done with the channel, disconnect it like this: >
101- call disconnect (handle)
101+ call ch_close (handle)
102102
103103 Currently up to 10 channels can be in use at the same time. *E897*
104104
@@ -112,15 +112,15 @@ If there is an error reading or writing a channel it will be closed.
1121123. Using a JSON channel *channel-use*
113113
114114If {mode} is "json" then a message can be sent synchronously like this: >
115- let response = sendexpr (handle, {expr})
115+ let response = ch_sendexpr (handle, {expr})
116116 This awaits a response from the other side.
117117
118118To send a message, without handling a response: >
119- call sendexpr (handle, {expr}, 0)
119+ call ch_sendexpr (handle, {expr}, 0)
120120
121121 To send a message and letting the response handled by a specific function,
122122asynchronously: >
123- call sendexpr (handle, {expr}, {callback})
123+ call ch_sendexpr (handle, {expr}, {callback})
124124
125125 The {expr} is converted to JSON and wrapped in an array. An example of the
126126message that the receiver will get when {expr} is the string "hello":
@@ -148,7 +148,7 @@ message, it must use the number zero:
148148Then channel handler will then get {response} converted to Vim types. If the
149149channel does not have a handler the message is dropped.
150150
151- On read error or disconnect () the string "DETACH" is sent, if still possible.
151+ On read error or ch_close () the string "DETACH" is sent, if still possible.
152152The channel will then be inactive.
153153
154154==============================================================================
@@ -200,7 +200,7 @@ You can also use "call |feedkeys()|" to insert any key sequence.
200200
201201Command "normal" ~
202202
203- The "normal" command is executed like with | :normal! | , commands are not
203+ The "normal" command is executed like with " :normal!" , commands are not
204204mapped. Example to open the folds under the cursor:
205205 ["normal" "zO"]
206206
@@ -230,19 +230,19 @@ Example:
2302305. Using a raw channel *channel-raw*
231231
232232If {mode} is "raw" then a message can be send like this: >
233- let response = sendraw (handle, {string})
233+ let response = ch_sendraw (handle, {string})
234234 The {string} is sent as-is. The response will be what can be read from the
235235channel right away. Since Vim doesn't know how to recognize the end of the
236236message you need to take care of it yourself.
237237
238238To send a message, without expecting a response: >
239- call sendraw (handle, {string}, 0)
239+ call ch_sendraw (handle, {string}, 0)
240240 The process can send back a response, the channel handler will be called with
241241it.
242242
243243To send a message and letting the response handled by a specific function,
244244asynchronously: >
245- call sendraw (handle, {string}, {callback})
245+ call ch_sendraw (handle, {string}, {callback})
246246
247247 This {string} can also be JSON, use | jsonencode() | to create it and
248248| jsondecode() | to handle a received JSON message.
0 commit comments