Skip to content

Instantly share code, notes, and snippets.

@piscisaureus
Created July 19, 2011 19:11
Show Gist options
  • Save piscisaureus/1093443 to your computer and use it in GitHub Desktop.
Save piscisaureus/1093443 to your computer and use it in GitHub Desktop.
enum uv_tty_event_t {
UV_KEY_ENTER,
UV_KEY_UP,
UV_KEY_DOWN,
UV_KEY_LEFT,
UV_KEY_RIGHT,
/* Any other character key */
UV_KEY_OTHER,
/* UV_PASTE means the user has pasted text into the console instead. */
/* In this case the nread field can be longer than 1 character */
UV_PASTE,
/* On windows console resize events are reported as tty input events. */
UV_RESIZE
};
/* TODO: maybe we should not use a buffer to read a single character every time? */
typedef void (*uv_read_events_cb)(uv_stream_t* tcp, ssize_t nread, uv_buf_t buf,
uv_tty_event_t event, unsigned int event_flags);
/* Yes the stream argument is not right here */
int uv_stdin_init(uv_stream_t* handle)
int uv_stdout_init(uv_stream_t* handle)
int uv_stderr_init(uv_stream_t* handle)
/* Tell me if the stream is a TTY input stream */
int uv_is_tty_input(uv_stream_t* handle);
/* Tell me if the stream is a TTY output stream */
int uv_is_tty_output(uv_stream_t* handle);
/* Start reading events (e.g. keypresses) from a stream. This is only */
/* possible for tty input streams. It will disable line buffering for as */
/* long as events are being read. It is not possible to do normal and 'event' */
/* reads at the same time, these are mutually exclusive. If you try to do this */
/* uv_read_event_start will return -1 and set the error code to UV_EALREADY. */
int uv_read_event_start(uv_stream_t*, uv_alloc_cb alloc_cb, uv_read_events_cb read_cb);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment