Lines Matching refs:tty
109 * Since all tty i/o happens on the same console, this window is shared
185 int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int unused) {
244 uv__stream_init(loop, (uv_stream_t*) tty, UV_TTY);
245 uv__connection_init((uv_stream_t*) tty);
247 tty->handle = handle;
248 tty->u.fd = fd;
249 tty->reqs_pending = 0;
250 tty->flags |= UV_HANDLE_BOUND;
254 tty->flags |= UV_HANDLE_TTY_READABLE | UV_HANDLE_READABLE;
256 tty->tty.rd.unused_ = NULL;
257 tty->tty.rd.read_line_buffer = uv_null_buf_;
258 tty->tty.rd.read_raw_wait = NULL;
261 tty->tty.rd.last_key_len = 0;
262 tty->tty.rd.last_key_offset = 0;
263 tty->tty.rd.last_utf16_high_surrogate = 0;
264 memset(&tty->tty.rd.last_input_record, 0, sizeof tty->tty.rd.last_input_record);
267 tty->flags |= UV_HANDLE_WRITABLE;
270 tty->tty.wr.utf8_bytes_left = 0;
271 tty->tty.wr.utf8_codepoint = 0;
274 tty->tty.wr.previous_eol = 0;
277 tty->tty.wr.ansi_parser_state = ANSI_NORMAL;
345 int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) {
352 if (!(tty->flags & UV_HANDLE_TTY_READABLE)) {
356 if (!!mode == !!(tty->flags & UV_HANDLE_TTY_RAW)) {
374 if (tty->flags & UV_HANDLE_READING) {
376 alloc_cb = tty->alloc_cb;
377 read_cb = tty->read_cb;
378 err = uv__tty_read_stop(tty);
389 if (!SetConsoleMode(tty->handle, flags)) {
397 tty->flags &= ~UV_HANDLE_TTY_RAW;
398 tty->flags |= mode ? UV_HANDLE_TTY_RAW : 0;
402 err = uv__tty_read_start(tty, alloc_cb, read_cb);
412 int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) {
415 if (!GetConsoleScreenBufferInfo(tty->handle, &info)) {
442 UnregisterWait(handle->tty.rd.read_raw_wait);
443 handle->tty.rd.read_raw_wait = NULL;
459 handle->tty.rd.read_line_buffer = uv_null_buf_;
464 r = RegisterWaitForSingleObject(&handle->tty.rd.read_raw_wait,
471 handle->tty.rd.read_raw_wait = NULL;
500 assert(handle->tty.rd.read_line_buffer.base != NULL);
501 assert(handle->tty.rd.read_line_buffer.len > 0);
504 if (handle->tty.rd.read_line_buffer.len < MAX_INPUT_BUFFER_LENGTH) {
505 bytes = handle->tty.rd.read_line_buffer.len;
533 &handle->tty.rd.read_line_buffer.base,
587 handle->tty.rd.read_line_buffer = uv_buf_init(NULL, 0);
588 handle->alloc_cb((uv_handle_t*) handle, 8192, &handle->tty.rd.read_line_buffer);
589 if (handle->tty.rd.read_line_buffer.base == NULL ||
590 handle->tty.rd.read_line_buffer.len == 0) {
593 &handle->tty.rd.read_line_buffer);
596 assert(handle->tty.rd.read_line_buffer.base != NULL);
693 /* Shortcut for handle->tty.rd.last_input_record.Event.KeyEvent. */
694 #define KEV handle->tty.rd.last_input_record.Event.KeyEvent
735 while ((records_left > 0 || handle->tty.rd.last_key_len > 0) &&
737 if (handle->tty.rd.last_key_len == 0) {
740 &handle->tty.rd.last_input_record,
754 if (handle->tty.rd.last_input_record.EventType == WINDOW_BUFFER_SIZE_EVENT) {
759 if (handle->tty.rd.last_input_record.EventType != KEY_EVENT) {
808 handle->tty.rd.last_utf16_high_surrogate = KEV.uChar.UnicodeChar;
817 handle->tty.rd.last_key[0] = '\033';
823 char_len = sizeof handle->tty.rd.last_key;
824 last_key_buf = &handle->tty.rd.last_key[prefix_len];
825 if (handle->tty.rd.last_utf16_high_surrogate) {
828 utf16_buffer[0] = handle->tty.rd.last_utf16_high_surrogate;
835 handle->tty.rd.last_utf16_high_surrogate = 0;
856 handle->tty.rd.last_key_len = (unsigned char) (prefix_len + char_len);
857 handle->tty.rd.last_key_offset = 0;
879 handle->tty.rd.last_key[0] = '\033';
886 assert(prefix_len + vt100_len < sizeof handle->tty.rd.last_key);
887 memcpy(&handle->tty.rd.last_key[prefix_len], vt100, vt100_len);
889 handle->tty.rd.last_key_len = (unsigned char) (prefix_len + vt100_len);
890 handle->tty.rd.last_key_offset = 0;
895 if (handle->tty.rd.last_key_offset < handle->tty.rd.last_key_len) {
907 buf.base[buf_used++] = handle->tty.rd.last_key[handle->tty.rd.last_key_offset++];
921 handle->tty.rd.last_key_offset = 0;
925 handle->tty.rd.last_key_len = 0;
956 buf = handle->tty.rd.read_line_buffer;
959 handle->tty.rd.read_line_buffer = uv_null_buf_;
999 if (handle->tty.rd.read_line_buffer.len == 0) {
1028 if (handle->tty.rd.last_key_len > 0) {
1393 unsigned short argc = handle->tty.wr.ansi_csi_argc;
1394 unsigned short* argv = handle->tty.wr.ansi_csi_argv;
1563 handle->tty.wr.saved_position.X = info.dwCursorPosition.X;
1564 handle->tty.wr.saved_position.Y = info.dwCursorPosition.Y -
1569 handle->tty.wr.saved_attributes = info.wAttributes &
1589 handle->tty.wr.saved_position.X,
1591 handle->tty.wr.saved_position.Y,
1607 new_attributes |= handle->tty.wr.saved_attributes;
1687 unsigned char utf8_bytes_left = handle->tty.wr.utf8_bytes_left;
1688 unsigned int utf8_codepoint = handle->tty.wr.utf8_codepoint;
1689 unsigned char previous_eol = handle->tty.wr.previous_eol;
1690 unsigned short ansi_parser_state = handle->tty.wr.ansi_parser_state;
1768 handle->tty.wr.ansi_csi_argc = 0;
1776 handle->tty.wr.ansi_csi_argc = 0;
1838 int style = handle->tty.wr.ansi_csi_argc
1839 ? handle->tty.wr.ansi_csi_argv[0] : 1;
1863 if (handle->tty.wr.ansi_csi_argc >=
1864 ARRAY_SIZE(handle->tty.wr.ansi_csi_argv)) {
1869 handle->tty.wr.ansi_csi_argc++;
1870 handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] =
1877 handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1];
1885 handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] =
1901 if (handle->tty.wr.ansi_csi_argc >=
1903 ARRAY_SIZE(handle->tty.wr.ansi_csi_argv)) {
1908 handle->tty.wr.ansi_csi_argc++;
1909 handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] = 0;
1916 handle->tty.wr.ansi_csi_argc == 0) {
1937 if (handle->tty.wr.ansi_csi_argc == 1 &&
1938 handle->tty.wr.ansi_csi_argv[0] == 25) {
1946 if (handle->tty.wr.ansi_csi_argc == 1 &&
1947 handle->tty.wr.ansi_csi_argv[0] == 25) {
1961 y = -(handle->tty.wr.ansi_csi_argc
1962 ? handle->tty.wr.ansi_csi_argv[0] : 1);
1969 y = handle->tty.wr.ansi_csi_argc
1970 ? handle->tty.wr.ansi_csi_argv[0] : 1;
1977 x = handle->tty.wr.ansi_csi_argc
1978 ? handle->tty.wr.ansi_csi_argv[0] : 1;
1985 x = -(handle->tty.wr.ansi_csi_argc
1986 ? handle->tty.wr.ansi_csi_argv[0] : 1);
1993 y = handle->tty.wr.ansi_csi_argc
1994 ? handle->tty.wr.ansi_csi_argv[0] : 1;
2001 y = -(handle->tty.wr.ansi_csi_argc
2002 ? handle->tty.wr.ansi_csi_argv[0] : 1);
2009 x = (handle->tty.wr.ansi_csi_argc >= 1 &&
2010 handle->tty.wr.ansi_csi_argv[0])
2011 ? handle->tty.wr.ansi_csi_argv[0] - 1 : 0;
2019 y = (handle->tty.wr.ansi_csi_argc >= 1 &&
2020 handle->tty.wr.ansi_csi_argv[0])
2021 ? handle->tty.wr.ansi_csi_argv[0] - 1 : 0;
2022 x = (handle->tty.wr.ansi_csi_argc >= 2 &&
2023 handle->tty.wr.ansi_csi_argv[1])
2024 ? handle->tty.wr.ansi_csi_argv[1] - 1 : 0;
2031 d = handle->tty.wr.ansi_csi_argc
2032 ? handle->tty.wr.ansi_csi_argv[0] : 0;
2041 d = handle->tty.wr.ansi_csi_argc
2042 ? handle->tty.wr.ansi_csi_argv[0] : 0;
2155 handle->tty.wr.utf8_bytes_left = utf8_bytes_left;
2156 handle->tty.wr.utf8_codepoint = utf8_codepoint;
2157 handle->tty.wr.previous_eol = previous_eol;
2158 handle->tty.wr.ansi_parser_state = ansi_parser_state;
2288 handle->tty.rd.read_raw_wait == NULL);