mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 05:58:33 +00:00

This is a structural refactor with no logical changes, yet. Done in preparation for simplifying rstream/rbuffer which will require more state inline in RStream. The initial idea was to have RStream and WStream as sub-types symetrically but that doesn't work, as sockets are both reading and writing. Also there is very little write-specific state to start with, so the benefit of a separate WStream struct is a lot smaller. Just document what fields in `Stream` are write specific.
62 lines
1.2 KiB
C
62 lines
1.2 KiB
C
#pragma once
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "nvim/event/defs.h"
|
|
|
|
#define CHAN_STDIO 1
|
|
#define CHAN_STDERR 2
|
|
|
|
typedef enum {
|
|
kChannelStreamProc,
|
|
kChannelStreamSocket,
|
|
kChannelStreamStdio,
|
|
kChannelStreamStderr,
|
|
kChannelStreamInternal,
|
|
} ChannelStreamType;
|
|
|
|
typedef enum {
|
|
kChannelPartStdin,
|
|
kChannelPartStdout,
|
|
kChannelPartStderr,
|
|
kChannelPartRpc,
|
|
kChannelPartAll,
|
|
} ChannelPart;
|
|
|
|
typedef enum {
|
|
kChannelStdinPipe,
|
|
kChannelStdinNull,
|
|
} ChannelStdinMode;
|
|
|
|
typedef struct {
|
|
RStream in;
|
|
Stream out;
|
|
} StdioPair;
|
|
|
|
typedef struct {
|
|
bool closed;
|
|
} StderrState;
|
|
|
|
typedef struct {
|
|
LuaRef cb;
|
|
bool closed;
|
|
} InternalState;
|
|
|
|
typedef struct {
|
|
Callback cb;
|
|
dict_T *self;
|
|
garray_T buffer;
|
|
bool eof;
|
|
bool buffered;
|
|
bool fwd_err;
|
|
const char *type;
|
|
} CallbackReader;
|
|
|
|
#define CALLBACK_READER_INIT ((CallbackReader){ .cb = CALLBACK_NONE, \
|
|
.self = NULL, \
|
|
.buffer = GA_EMPTY_INIT_VALUE, \
|
|
.buffered = false, \
|
|
.fwd_err = false, \
|
|
.type = NULL })
|