channel.c File Reference
#include "nvim/api/private/converter.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/ui.h"
#include "nvim/channel.h"
#include "nvim/eval.h"
#include "nvim/eval/encode.h"
#include "nvim/event/socket.h"
#include "nvim/fileio.h"
#include "nvim/lua/executor.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/msgpack_rpc/server.h"
#include "nvim/os/shell.h"
#include "nvim/ascii.h"
#include "nvim/path.h"


void channel_teardown (void)
 Teardown the module. More...
bool channel_close (uint64_t id, ChannelPart part, const char **error)
void channel_init (void)
 Initializes the module. More...
Channelchannel_alloc (ChannelStreamType type) FUNC_ATTR_NONNULL_RET
void channel_create_event (Channel *chan, const char *ext_source)
void channel_incref (Channel *chan)
void channel_decref (Channel *chan)
void callback_reader_free (CallbackReader *reader)
void callback_reader_start (CallbackReader *reader, const char *type)
Channelchannel_job_start (char **argv, CallbackReader on_stdout, CallbackReader on_stderr, Callback on_exit, bool pty, bool rpc, bool overlapped, bool detach, ChannelStdinMode stdin_mode, const char *cwd, uint16_t pty_width, uint16_t pty_height, dict_T *env, varnumber_T *status_out)
uint64_t channel_connect (bool tcp, const char *address, bool rpc, CallbackReader on_output, int timeout, const char **error)
void channel_from_connection (SocketWatcher *watcher)
uint64_t channel_from_stdio (bool rpc, CallbackReader on_output, const char **error) FUNC_ATTR_NONNULL_ALL
size_t channel_send (uint64_t id, char *data, size_t len, bool data_owned, const char **error) FUNC_ATTR_NONNULL_ALL
void on_channel_data (Stream *stream, RBuffer *buf, size_t count, void *data, bool eof)
void on_job_stderr (Stream *stream, RBuffer *buf, size_t count, void *data, bool eof)
void channel_reader_callbacks (Channel *chan, CallbackReader *reader)
void channel_terminal_open (buf_T *buf, Channel *chan)
void channel_info_changed (Channel *chan, bool new)
bool channel_job_running (uint64_t id)
Dictionary channel_info (uint64_t id)
Array channel_all_info (void)

Function Documentation

◆ callback_reader_free()

void callback_reader_free ( CallbackReader reader)

◆ callback_reader_start()

void callback_reader_start ( CallbackReader reader,
const char *  type 

◆ channel_all_info()

Array channel_all_info ( void  )

◆ channel_alloc()

Channel* channel_alloc ( ChannelStreamType  type)

Allocates a channel.

Channel is allocated with refcount 1, which should be decreased when the underlying stream closes.

◆ channel_close()

bool channel_close ( uint64_t  id,
ChannelPart  part,
const char **  error 

Closes a channel

idThe channel id
true if successful, false otherwise

◆ channel_connect()

uint64_t channel_connect ( bool  tcp,
const char *  address,
bool  rpc,
CallbackReader  on_output,
int  timeout,
const char **  error 

◆ channel_create_event()

void channel_create_event ( Channel chan,
const char *  ext_source 

◆ channel_decref()

void channel_decref ( Channel chan)

◆ channel_from_connection()

void channel_from_connection ( SocketWatcher watcher)

Creates an RPC channel from a tcp/pipe socket connection

watcherThe SocketWatcher ready to accept the connection

◆ channel_from_stdio()

uint64_t channel_from_stdio ( bool  rpc,
CallbackReader  on_output,
const char **  error 

Creates an API channel from stdin/stdout. This is used when embedding Neovim

◆ channel_incref()

void channel_incref ( Channel chan)

◆ channel_info()

Dictionary channel_info ( uint64_t  id)

◆ channel_info_changed()

void channel_info_changed ( Channel chan,
bool  new 

◆ channel_init()

void channel_init ( void  )

Initializes the module.

◆ channel_job_running()

bool channel_job_running ( uint64_t  id)

◆ channel_job_start()

Channel* channel_job_start ( char **  argv,
CallbackReader  on_stdout,
CallbackReader  on_stderr,
Callback  on_exit,
bool  pty,
bool  rpc,
bool  overlapped,
bool  detach,
ChannelStdinMode  stdin_mode,
const char *  cwd,
uint16_t  pty_width,
uint16_t  pty_height,
dict_T env,
varnumber_T status_out 

Starts a job and returns the associated channel

[in]argvArguments vector specifying the command to run, NULL-terminated
[in]on_stdoutCallback to read the job's stdout
[in]on_stderrCallback to read the job's stderr
[in]on_exitCallback to receive the job's exit status
[in]ptyTrue if the job should run attached to a pty
[in]rpcTrue to communicate with the job using msgpack-rpc, on_stdout is ignored
[in]detachTrue if the job should not be killed when nvim exits, ignored if pty is true
[in]stdin_modeStdin mode. Either kChannelStdinPipe to open a channel for stdin or kChannelStdinNull to leave stdin disconnected.
[in]cwdInitial working directory for the job. Nvim's working directory if cwd is NULL
[in]pty_widthWidth of the pty, ignored if pty is false
[in]pty_heightHeight of the pty, ignored if pty is false
[in]envNvim's configured environment is used if this is NULL, otherwise defines all environment variables
[out]status_out0 for invalid arguments, > 0 for the channel id, < 0 if the job can't start
[allocated] channel

◆ channel_reader_callbacks()

void channel_reader_callbacks ( Channel chan,
CallbackReader reader 

◆ channel_send()

size_t channel_send ( uint64_t  id,
char *  data,
size_t  len,
bool  data_owned,
const char **  error 
datawill be consumed

◆ channel_teardown()

void channel_teardown ( void  )

Teardown the module.

◆ channel_terminal_open()

void channel_terminal_open ( buf_T buf,
Channel chan 

Open terminal for channel

Channel chan is assumed to be an open pty channel, and buf is assumed to be a new, unmodified buffer.

◆ on_channel_data()

void on_channel_data ( Stream stream,
RBuffer buf,
size_t  count,
void data,
bool  eof 

◆ on_job_stderr()

void on_job_stderr ( Stream stream,
RBuffer buf,
size_t  count,
void data,
bool  eof