comparison runtime/doc/eval.txt @ 8178:e77efd7a7dad v7.4.1382

commit https://github.com/vim/vim/commit/02e83b438ea7071fdb176dabbaefea319ab2d686 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 21 20:10:26 2016 +0100 patch 7.4.1382 Problem: Can't get the job of a channel. Solution: Add ch_getjob().
author Christian Brabandt <cb@256bit.org>
date Sun, 21 Feb 2016 20:15:04 +0100
parents f5da459c5698
children 3456e2ebebd4
comparison
equal deleted inserted replaced
8177:0e3185eea369 8178:e77efd7a7dad
1 *eval.txt* For Vim version 7.4. Last change: 2016 Feb 19 1 *eval.txt* For Vim version 7.4. Last change: 2016 Feb 21
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
57 Example: {'blue': "#0000ff", 'red': "#ff0000"} 57 Example: {'blue': "#0000ff", 'red': "#ff0000"}
58 58
59 Funcref A reference to a function |Funcref|. 59 Funcref A reference to a function |Funcref|.
60 Example: function("strlen") 60 Example: function("strlen")
61 61
62 Special v:false, v:true, v:none and v:null 62 Special |v:false|, |v:true|, |v:none| and |v:null|. *Special*
63 63
64 Job Used for a job, see |job_start()|. 64 Job Used for a job, see |job_start()|. *Job*
65 65
66 Channel Used for a channel, see |ch_open()|. 66 Channel Used for a channel, see |ch_open()|. *Channel*
67 67
68 The Number and String types are converted automatically, depending on how they 68 The Number and String types are converted automatically, depending on how they
69 are used. 69 are used.
70 70
71 Conversion from a Number to a String is by making the ASCII representation of 71 Conversion from a Number to a String is by making the ASCII representation of
1815 byteidx( {expr}, {nr}) Number byte index of {nr}'th char in {expr} 1815 byteidx( {expr}, {nr}) Number byte index of {nr}'th char in {expr}
1816 byteidxcomp( {expr}, {nr}) Number byte index of {nr}'th char in {expr} 1816 byteidxcomp( {expr}, {nr}) Number byte index of {nr}'th char in {expr}
1817 call( {func}, {arglist} [, {dict}]) 1817 call( {func}, {arglist} [, {dict}])
1818 any call {func} with arguments {arglist} 1818 any call {func} with arguments {arglist}
1819 ceil( {expr}) Float round {expr} up 1819 ceil( {expr}) Float round {expr} up
1820 ch_close( {handle}) none close a channel 1820 ch_close( {channel}) none close {channel}
1821 ch_getjob( {channel}) Job get the Job of {channel}
1821 ch_log( {msg} [, {channel}]) none write {msg} in the channel log file 1822 ch_log( {msg} [, {channel}]) none write {msg} in the channel log file
1822 ch_logfile( {fname} [, {mode}]) none start logging channel activity 1823 ch_logfile( {fname} [, {mode}]) none start logging channel activity
1823 ch_open( {address} [, {options}]) Channel open a channel to {address} 1824 ch_open( {address} [, {options}]) Channel open a channel to {address}
1824 ch_readraw( {handle}) String read from channel {handle} 1825 ch_read( {channel} [, {options}]) String read from {channel}
1825 ch_sendexpr( {handle}, {expr} [, {options}]) 1826 ch_readraw( {channel} [, {options}]) String read raw from {channel}
1826 any send {expr} over JSON channel {handle} 1827 ch_sendexpr( {channel}, {expr} [, {options}])
1827 ch_sendraw( {handle}, {string} [, {options}]) 1828 any send {expr} over JSON {channel}
1828 any send {string} over raw channel {handle} 1829 ch_sendraw( {channel}, {string} [, {options}])
1829 ch_setoptions( {handle}, {options}) none set options for channel {handle} 1830 any send {string} over raw {channel}
1830 ch_status( {handle}) String status of channel {handle} 1831 ch_setoptions( {channel}, {options}) none set options for {channel}
1832 ch_status( {channel}) String status of {channel}
1831 changenr() Number current change number 1833 changenr() Number current change number
1832 char2nr( {expr}[, {utf8}]) Number ASCII/UTF8 value of first char in {expr} 1834 char2nr( {expr}[, {utf8}]) Number ASCII/UTF8 value of first char in {expr}
1833 cindent( {lnum}) Number C indent for line {lnum} 1835 cindent( {lnum}) Number C indent for line {lnum}
1834 clearmatches() none clear all matches 1836 clearmatches() none clear all matches
1835 col( {expr}) Number column nr of cursor or mark 1837 col( {expr}) Number column nr of cursor or mark
1958 insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] 1960 insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}]
1959 invert( {expr}) Number bitwise invert 1961 invert( {expr}) Number bitwise invert
1960 isdirectory( {directory}) Number TRUE if {directory} is a directory 1962 isdirectory( {directory}) Number TRUE if {directory} is a directory
1961 islocked( {expr}) Number TRUE if {expr} is locked 1963 islocked( {expr}) Number TRUE if {expr} is locked
1962 items( {dict}) List key-value pairs in {dict} 1964 items( {dict}) List key-value pairs in {dict}
1963 job_getchannel( {job}) Number get the channel handle for {job} 1965 job_getchannel( {job}) Channel get the channel handle for {job}
1964 job_start( {command} [, {options}]) Job start a job 1966 job_setoptions( {job}, {options}) none set options for {job}
1965 job_status( {job}) String get the status of a job 1967 job_start( {command} [, {options}]) Job start a job
1966 job_stop( {job} [, {how}]) Number stop a job 1968 job_status( {job}) String get the status of {job}
1969 job_stop( {job} [, {how}]) Number stop {job}
1967 join( {list} [, {sep}]) String join {list} items into one String 1970 join( {list} [, {sep}]) String join {list} items into one String
1968 js_decode( {string}) any decode JS style JSON 1971 js_decode( {string}) any decode JS style JSON
1969 js_encode( {expr}) String encode JS style JSON 1972 js_encode( {expr}) String encode JS style JSON
1970 json_decode( {string}) any decode JSON 1973 json_decode( {string}) any decode JSON
1971 json_encode( {expr}) String encode JSON 1974 json_encode( {expr}) String encode JSON
2682 the buttons are always put vertically. Otherwise, confirm() 2685 the buttons are always put vertically. Otherwise, confirm()
2683 tries to put the buttons in one horizontal line. If they 2686 tries to put the buttons in one horizontal line. If they
2684 don't fit, a vertical layout is used anyway. For some systems 2687 don't fit, a vertical layout is used anyway. For some systems
2685 the horizontal layout is always used. 2688 the horizontal layout is always used.
2686 2689
2687 ch_close({handle}) *ch_close()* 2690 ch_close({channel}) *ch_close()*
2688 Close channel {handle}. See |channel|. 2691 Close {channel}. See |channel-close|.
2689 {only available when compiled with the |+channel| feature} 2692 {only available when compiled with the |+channel| feature}
2693
2694 ch_getjob({channel}) *ch_getjob()*
2695 Get the Job associated with {channel}.
2696 If there is no job calling |job_status()| on the returned Job
2697 will result in "fail".
2698
2699 {only available when compiled with the |+channel| and
2700 |+job| features}
2690 2701
2691 ch_log({msg} [, {channel}]) *ch_log()* 2702 ch_log({msg} [, {channel}]) *ch_log()*
2692 Write {msg} in the channel log file, if it was opened with 2703 Write {msg} in the channel log file, if it was opened with
2693 |ch_logfile()|. 2704 |ch_logfile()|.
2694 When {channel} is passed the channel number is used for the 2705 When {channel} is passed the channel number is used for the
2704 The file is flushed after every message, on Unix you can use 2715 The file is flushed after every message, on Unix you can use
2705 "tail -f" to see what is going on in real time. 2716 "tail -f" to see what is going on in real time.
2706 2717
2707 ch_open({address} [, {options}]) *ch_open()* 2718 ch_open({address} [, {options}]) *ch_open()*
2708 Open a channel to {address}. See |channel|. 2719 Open a channel to {address}. See |channel|.
2709 Returns the channel handle on success. Returns a negative 2720 Returns a Channel. Use |ch_status()| to check for
2710 number for failure. 2721 failure.
2711 2722
2712 {address} has the form "hostname:port", e.g., 2723 {address} has the form "hostname:port", e.g.,
2713 "localhost:8765". 2724 "localhost:8765".
2714 2725
2715 If {options} is given it must be a |Dictionary|. The optional 2726 If {options} is given it must be a |Dictionary|. The optional
2720 sequence number. See |channel-callback|. 2731 sequence number. See |channel-callback|.
2721 Default: none. 2732 Default: none.
2722 waittime Specify connect timeout as milliseconds. 2733 waittime Specify connect timeout as milliseconds.
2723 Negative means forever. 2734 Negative means forever.
2724 Default: 0 (don't wait) 2735 Default: 0 (don't wait)
2725 timeout Specify response read timeout value as 2736 timeout Specify response read timeout value in
2726 milliseconds. 2737 milliseconds.
2727 Default: 2000. 2738 Default: 2000.
2728 {only available when compiled with the |+channel| feature} 2739 {only available when compiled with the |+channel| feature}
2729 2740
2730 ch_readraw({handle}) *ch_readraw()* 2741 ch_read({channel} [, {options}]) *ch_read()*
2731 Read from channel {handle} and return the received message. 2742 Read from {channel} and return the received message.
2743
2732 This uses the channel timeout. When there is nothing to read 2744 This uses the channel timeout. When there is nothing to read
2733 within that time an empty string is returned. 2745 within that time an empty string is returned. To specify a
2734 TODO: depends on channel mode. 2746 different timeout in msec use the "timeout" option:
2735 2747 {"timeout": 123} ~
2736 ch_sendexpr({handle}, {expr} [, {options}]) *ch_sendexpr()* 2748 To read from the error output use the "part" option:
2737 Send {expr} over channel {handle}. The {expr} is encoded 2749 {"part": "err"} ~
2750 To read a message with a specific ID, on a JS or JSON channel:
2751 {"id": 99} ~
2752 When no ID is specified or the ID is -1, the first message is
2753 returned. This overrules any callback waiting for this
2754 message.
2755
2756 For a RAW channel this returns whatever is available, since
2757 Vim does not know where a message ends.
2758 For a NL channel this returns one message.
2759 For a JS or JSON channel this returns one decoded message.
2760 This includes any sequence number.
2761
2762 ch_readraw({channel} [, {options}]) *ch_readraw()*
2763 Like ch_read() but for a JS and JSON channel does not decode
2764 the message.
2765
2766 ch_sendexpr({channel}, {expr} [, {options}]) *ch_sendexpr()*
2767 Send {expr} over {channel}. The {expr} is encoded
2738 according to the type of channel. The function cannot be used 2768 according to the type of channel. The function cannot be used
2739 with a raw channel. See |channel-use|. *E912* 2769 with a raw channel. See |channel-use|. *E912*
2740 2770
2741 {options} must be a Dictionary. 2771 {options} must be a Dictionary.
2742 When "callback" is a Funcref or the name of a function, 2772 When "callback" is a Funcref or the name of a function,
2749 2779
2750 When "callback" is zero no response is expected. 2780 When "callback" is zero no response is expected.
2751 2781
2752 {only available when compiled with the |+channel| feature} 2782 {only available when compiled with the |+channel| feature}
2753 2783
2754 ch_sendraw({handle}, {string} [, {options}]) *ch_sendraw()* 2784 ch_sendraw({channel}, {string} [, {options}]) *ch_sendraw()*
2755 Send {string} over channel {handle}. 2785 Send {string} over {channel}.
2756 Works like |ch_sendexpr()|, but does not encode the request or 2786 Works like |ch_sendexpr()|, but does not encode the request or
2757 decode the response. The caller is responsible for the 2787 decode the response. The caller is responsible for the
2758 correct contents. Also does not add a newline for a channel 2788 correct contents. Also does not add a newline for a channel
2759 in NL mode, the caller must do that. The NL in the response 2789 in NL mode, the caller must do that. The NL in the response
2760 is removed. 2790 is removed.
2761 See |channel-use|. 2791 See |channel-use|.
2762 2792
2763 {only available when compiled with the |+channel| feature} 2793 {only available when compiled with the |+channel| feature}
2764 2794
2765 ch_setoptions({handle}, {options}) *ch_setoptions()* 2795 ch_setoptions({channel}, {options}) *ch_setoptions()*
2766 Set options on channel {handle}: 2796 Set options on {channel}:
2767 "callback" the channel callback 2797 "callback" the channel callback
2768 "timeout" default read timeout in msec 2798 "timeout" default read timeout in msec
2799 "mode" mode for the whole channel
2769 See |ch_open()| for more explanation. 2800 See |ch_open()| for more explanation.
2770 2801
2802 Note that changing the mode may cause queued messages to be
2803 lost.
2804
2771 These options cannot be changed: 2805 These options cannot be changed:
2772 "mode" cannot be changed once channel is open
2773 "waittime" only applies to "ch_open()| 2806 "waittime" only applies to "ch_open()|
2774 2807
2775 ch_status({handle}) *ch_status()* 2808 ch_status({channel}) *ch_status()*
2776 Return the status of channel {handle}: 2809 Return the status of {channel}:
2777 "fail" failed to open the channel 2810 "fail" failed to open the channel
2778 "open" channel can be used 2811 "open" channel can be used
2779 "closed" channel can not be used 2812 "closed" channel can not be used
2780 2813
2781 *copy()* 2814 *copy()*
4368 Return a |List| with all the key-value pairs of {dict}. Each 4401 Return a |List| with all the key-value pairs of {dict}. Each
4369 |List| item is a list with two items: the key of a {dict} 4402 |List| item is a list with two items: the key of a {dict}
4370 entry and the value of this entry. The |List| is in arbitrary 4403 entry and the value of this entry. The |List| is in arbitrary
4371 order. 4404 order.
4372 4405
4373
4374 job_getchannel({job}) *job_getchannel()* 4406 job_getchannel({job}) *job_getchannel()*
4375 Get the channel handle that {job} is using. 4407 Get the channel handle that {job} is using.
4376 {only available when compiled with the |+job| feature} 4408 {only available when compiled with the |+job| feature}
4409
4410 job_setoptions({job}, {options}) *job_setoptions()*
4411 Change options for {job}. Supported are:
4412 "stoponexit" |job-stoponexit|
4413 "exit-cb" |job-exit-cb|
4377 4414
4378 job_start({command} [, {options}]) *job_start()* 4415 job_start({command} [, {options}]) *job_start()*
4379 Start a job and return a Job object. Unlike |system()| and 4416 Start a job and return a Job object. Unlike |system()| and
4380 |:!cmd| this does not wait for the job to finish. 4417 |:!cmd| this does not wait for the job to finish.
4381 4418
4413 {options} must be a Dictionary. It can contain many optional 4450 {options} must be a Dictionary. It can contain many optional
4414 items, see |job-options|. 4451 items, see |job-options|.
4415 4452
4416 {only available when compiled with the |+job| feature} 4453 {only available when compiled with the |+job| feature}
4417 4454
4418 job_status({job}) *job_status()* 4455 job_status({job}) *job_status()* *E916*
4419 Returns a String with the status of {job}: 4456 Returns a String with the status of {job}:
4420 "run" job is running 4457 "run" job is running
4421 "fail" job failed to start 4458 "fail" job failed to start
4422 "dead" job died or was stopped after running 4459 "dead" job died or was stopped after running
4460
4461 If an exit callback was set with the "exit-cb" option and the
4462 job is now detected to be "dead" the callback will be invoked.
4423 4463
4424 {only available when compiled with the |+job| feature} 4464 {only available when compiled with the |+job| feature}
4425 4465
4426 job_stop({job} [, {how}]) *job_stop()* 4466 job_stop({job} [, {how}]) *job_stop()*
4427 Stop the {job}. This can also be used to signal the job. 4467 Stop the {job}. This can also be used to signal the job.
7373 |blockwise-operators|. 7413 |blockwise-operators|.
7374 vms VMS version of Vim. 7414 vms VMS version of Vim.
7375 vreplace Compiled with |gR| and |gr| commands. 7415 vreplace Compiled with |gR| and |gr| commands.
7376 wildignore Compiled with 'wildignore' option. 7416 wildignore Compiled with 'wildignore' option.
7377 wildmenu Compiled with 'wildmenu' option. 7417 wildmenu Compiled with 'wildmenu' option.
7378 win16 Win16 version of Vim (MS-Windows 3.1).
7379 win32 Win32 version of Vim (MS-Windows 95 and later, 32 or 7418 win32 Win32 version of Vim (MS-Windows 95 and later, 32 or
7380 64 bits) 7419 64 bits)
7381 win32unix Win32 version of Vim, using Unix files (Cygwin) 7420 win32unix Win32 version of Vim, using Unix files (Cygwin)
7382 win64 Win64 version of Vim (MS-Windows 64 bit). 7421 win64 Win64 version of Vim (MS-Windows 64 bit).
7383 win95 Win32 version for MS-Windows 95/98/ME. 7422 win95 Win32 version for MS-Windows 95/98/ME.