• Home
  • Raw
  • Download

Lines Matching +full:no +full:- +full:useless +full:- +full:escape

15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 # include "uv/stdint-msvc2008.h"
39 #include "handle-inl.h"
40 #include "stream-inl.h"
41 #include "req-inl.h"
97 * inconvenient, it makes absolute cursor movement pretty useless. There is
107 * mean that it would extend beyond the bottom of the screen buffer - in that
118 static int uv_tty_virtual_offset = -1;
119 static int uv_tty_virtual_height = -1;
120 static int uv_tty_virtual_width = -1;
128 static int uv__tty_console_height = -1;
129 static int uv__tty_console_width = -1;
184 uv__tty_console_height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1; in uv__console_init()
204 /* In order to avoid closing a stdio file descriptor 0-2, duplicate the in uv_tty_init()
207 * but then there would be no reliable way to cancel pending read operations in uv_tty_init()
218 fd = -1; in uv_tty_init()
252 tty->handle = handle; in uv_tty_init()
253 tty->u.fd = fd; in uv_tty_init()
254 tty->reqs_pending = 0; in uv_tty_init()
255 tty->flags |= UV_HANDLE_BOUND; in uv_tty_init()
259 tty->flags |= UV_HANDLE_TTY_READABLE | UV_HANDLE_READABLE; in uv_tty_init()
261 tty->tty.rd.unused_ = NULL; in uv_tty_init()
262 tty->tty.rd.read_line_buffer = uv_null_buf_; in uv_tty_init()
263 tty->tty.rd.read_raw_wait = NULL; in uv_tty_init()
265 /* Init keycode-to-vt100 mapper state. */ in uv_tty_init()
266 tty->tty.rd.last_key_len = 0; in uv_tty_init()
267 tty->tty.rd.last_key_offset = 0; in uv_tty_init()
268 tty->tty.rd.last_utf16_high_surrogate = 0; in uv_tty_init()
269 memset(&tty->tty.rd.last_input_record, 0, sizeof tty->tty.rd.last_input_record); in uv_tty_init()
272 tty->flags |= UV_HANDLE_WRITABLE; in uv_tty_init()
274 /* Init utf8-to-utf16 conversion state. */ in uv_tty_init()
275 tty->tty.wr.utf8_bytes_left = 0; in uv_tty_init()
276 tty->tty.wr.utf8_codepoint = 0; in uv_tty_init()
279 tty->tty.wr.previous_eol = 0; in uv_tty_init()
282 tty->tty.wr.ansi_parser_state = ANSI_NORMAL; in uv_tty_init()
303 uv_tty_default_text_attributes = screen_buffer_info->wAttributes; in uv__tty_capture_initial_style()
357 if (!(tty->flags & UV_HANDLE_TTY_READABLE)) { in uv_tty_set_mode()
361 if (!!mode == !!(tty->flags & UV_HANDLE_TTY_RAW)) { in uv_tty_set_mode()
379 if (tty->flags & UV_HANDLE_READING) { in uv_tty_set_mode()
381 alloc_cb = tty->alloc_cb; in uv_tty_set_mode()
382 read_cb = tty->read_cb; in uv_tty_set_mode()
394 if (!SetConsoleMode(tty->handle, flags)) { in uv_tty_set_mode()
402 tty->flags &= ~UV_HANDLE_TTY_RAW; in uv_tty_set_mode()
403 tty->flags |= mode ? UV_HANDLE_TTY_RAW : 0; in uv_tty_set_mode()
420 if (!GetConsoleScreenBufferInfo(tty->handle, &info)) { in uv_tty_get_winsize()
444 handle = (uv_tty_t*) req->data; in uv_tty_post_raw_read()
445 loop = handle->loop; in uv_tty_post_raw_read()
447 UnregisterWait(handle->tty.rd.read_raw_wait); in uv_tty_post_raw_read()
448 handle->tty.rd.read_raw_wait = NULL; in uv_tty_post_raw_read()
459 assert(handle->flags & UV_HANDLE_READING); in uv__tty_queue_read_raw()
460 assert(!(handle->flags & UV_HANDLE_READ_PENDING)); in uv__tty_queue_read_raw()
462 assert(handle->handle && handle->handle != INVALID_HANDLE_VALUE); in uv__tty_queue_read_raw()
464 handle->tty.rd.read_line_buffer = uv_null_buf_; in uv__tty_queue_read_raw()
466 req = &handle->read_req; in uv__tty_queue_read_raw()
467 memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); in uv__tty_queue_read_raw()
469 r = RegisterWaitForSingleObject(&handle->tty.rd.read_raw_wait, in uv__tty_queue_read_raw()
470 handle->handle, in uv__tty_queue_read_raw()
476 handle->tty.rd.read_raw_wait = NULL; in uv__tty_queue_read_raw()
481 handle->flags |= UV_HANDLE_READ_PENDING; in uv__tty_queue_read_raw()
482 handle->reqs_pending++; in uv__tty_queue_read_raw()
500 handle = (uv_tty_t*) req->data; in uv_tty_line_read_thread()
501 loop = handle->loop; in uv_tty_line_read_thread()
503 assert(handle->tty.rd.read_line_buffer.base != NULL); in uv_tty_line_read_thread()
504 assert(handle->tty.rd.read_line_buffer.len > 0); in uv_tty_line_read_thread()
507 if (handle->tty.rd.read_line_buffer.len < MAX_INPUT_BUFFER_LENGTH) { in uv_tty_line_read_thread()
508 bytes = handle->tty.rd.read_line_buffer.len; in uv_tty_line_read_thread()
513 /* At last, unicode! One utf-16 codeunit never takes more than 3 utf-8 in uv_tty_line_read_thread()
521 req->u.io.overlapped.InternalHigh = 0; in uv_tty_line_read_thread()
526 read_console_success = ReadConsoleW(handle->handle, in uv_tty_line_read_thread()
537 handle->tty.rd.read_line_buffer.base, in uv_tty_line_read_thread()
542 req->u.io.overlapped.InternalHigh = read_bytes; in uv_tty_line_read_thread()
568 if (pos.Y == uv__saved_screen_state.dwSize.Y - 1) in uv_tty_line_read_thread()
569 pos.Y--; in uv_tty_line_read_thread()
586 assert(handle->flags & UV_HANDLE_READING); in uv__tty_queue_read_line()
587 assert(!(handle->flags & UV_HANDLE_READ_PENDING)); in uv__tty_queue_read_line()
588 assert(handle->handle && handle->handle != INVALID_HANDLE_VALUE); in uv__tty_queue_read_line()
590 req = &handle->read_req; in uv__tty_queue_read_line()
591 memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); in uv__tty_queue_read_line()
593 handle->tty.rd.read_line_buffer = uv_buf_init(NULL, 0); in uv__tty_queue_read_line()
594 handle->alloc_cb((uv_handle_t*) handle, 8192, &handle->tty.rd.read_line_buffer); in uv__tty_queue_read_line()
595 if (handle->tty.rd.read_line_buffer.base == NULL || in uv__tty_queue_read_line()
596 handle->tty.rd.read_line_buffer.len == 0) { in uv__tty_queue_read_line()
597 handle->read_cb((uv_stream_t*) handle, in uv__tty_queue_read_line()
599 &handle->tty.rd.read_line_buffer); in uv__tty_queue_read_line()
602 assert(handle->tty.rd.read_line_buffer.base != NULL); in uv__tty_queue_read_line()
604 /* Reset flags No locking is required since there cannot be a line read in uv__tty_queue_read_line()
617 handle->flags |= UV_HANDLE_READ_PENDING; in uv__tty_queue_read_line()
618 handle->reqs_pending++; in uv__tty_queue_read_line()
623 if (handle->flags & UV_HANDLE_TTY_RAW) { in uv__tty_queue_read()
650 /* These mappings are the same as Cygwin's. Unmodified and alt-modified in get_vt100_fn_key()
652 * modifier usage. F1. f12 and shift-f1. f10 comply with linux console, f6. in get_vt100_fn_key()
699 /* Shortcut for handle->tty.rd.last_input_record.Event.KeyEvent. */ in uv_process_tty_read_raw_req()
700 #define KEV handle->tty.rd.last_input_record.Event.KeyEvent in uv_process_tty_read_raw_req()
706 assert(handle->type == UV_TTY); in uv_process_tty_read_raw_req()
707 assert(handle->flags & UV_HANDLE_TTY_READABLE); in uv_process_tty_read_raw_req()
708 handle->flags &= ~UV_HANDLE_READ_PENDING; in uv_process_tty_read_raw_req()
710 if (!(handle->flags & UV_HANDLE_READING) || in uv_process_tty_read_raw_req()
711 !(handle->flags & UV_HANDLE_TTY_RAW)) { in uv_process_tty_read_raw_req()
717 if ((handle->flags & UV_HANDLE_READING)) { in uv_process_tty_read_raw_req()
718 handle->flags &= ~UV_HANDLE_READING; in uv_process_tty_read_raw_req()
719 handle->read_cb((uv_stream_t*)handle, in uv_process_tty_read_raw_req()
727 if (!GetNumberOfConsoleInputEvents(handle->handle, &records_left)) { in uv_process_tty_read_raw_req()
728 handle->flags &= ~UV_HANDLE_READING; in uv_process_tty_read_raw_req()
730 handle->read_cb((uv_stream_t*)handle, in uv_process_tty_read_raw_req()
741 while ((records_left > 0 || handle->tty.rd.last_key_len > 0) && in uv_process_tty_read_raw_req()
742 (handle->flags & UV_HANDLE_READING)) { in uv_process_tty_read_raw_req()
743 if (handle->tty.rd.last_key_len == 0) { in uv_process_tty_read_raw_req()
745 if (!ReadConsoleInputW(handle->handle, in uv_process_tty_read_raw_req()
746 &handle->tty.rd.last_input_record, in uv_process_tty_read_raw_req()
749 handle->flags &= ~UV_HANDLE_READING; in uv_process_tty_read_raw_req()
751 handle->read_cb((uv_stream_t*) handle, in uv_process_tty_read_raw_req()
756 records_left--; in uv_process_tty_read_raw_req()
760 if (handle->tty.rd.last_input_record.EventType == WINDOW_BUFFER_SIZE_EVENT) { in uv_process_tty_read_raw_req()
765 if (handle->tty.rd.last_input_record.EventType != KEY_EVENT) { in uv_process_tty_read_raw_req()
811 /* UTF-16 high surrogate */ in uv_process_tty_read_raw_req()
812 handle->tty.rd.last_utf16_high_surrogate = KEV.uChar.UnicodeChar; in uv_process_tty_read_raw_req()
821 handle->tty.rd.last_key[0] = '\033'; in uv_process_tty_read_raw_req()
829 /* UTF-16 surrogate pair */ in uv_process_tty_read_raw_req()
831 utf16_buffer[0] = handle->tty.rd.last_utf16_high_surrogate; in uv_process_tty_read_raw_req()
837 &handle->tty.rd.last_key[prefix_len], in uv_process_tty_read_raw_req()
838 sizeof handle->tty.rd.last_key, in uv_process_tty_read_raw_req()
842 /* Single UTF-16 character */ in uv_process_tty_read_raw_req()
847 &handle->tty.rd.last_key[prefix_len], in uv_process_tty_read_raw_req()
848 sizeof handle->tty.rd.last_key, in uv_process_tty_read_raw_req()
854 handle->tty.rd.last_utf16_high_surrogate = 0; in uv_process_tty_read_raw_req()
859 handle->flags &= ~UV_HANDLE_READING; in uv_process_tty_read_raw_req()
861 handle->read_cb((uv_stream_t*) handle, in uv_process_tty_read_raw_req()
867 handle->tty.rd.last_key_len = (unsigned char) (prefix_len + char_len); in uv_process_tty_read_raw_req()
868 handle->tty.rd.last_key_offset = 0; in uv_process_tty_read_raw_req()
890 handle->tty.rd.last_key[0] = '\033'; in uv_process_tty_read_raw_req()
897 assert(prefix_len + vt100_len < sizeof handle->tty.rd.last_key); in uv_process_tty_read_raw_req()
898 memcpy(&handle->tty.rd.last_key[prefix_len], vt100, vt100_len); in uv_process_tty_read_raw_req()
900 handle->tty.rd.last_key_len = (unsigned char) (prefix_len + vt100_len); in uv_process_tty_read_raw_req()
901 handle->tty.rd.last_key_offset = 0; in uv_process_tty_read_raw_req()
906 if (handle->tty.rd.last_key_offset < handle->tty.rd.last_key_len) { in uv_process_tty_read_raw_req()
910 handle->alloc_cb((uv_handle_t*) handle, 1024, &buf); in uv_process_tty_read_raw_req()
912 handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf); in uv_process_tty_read_raw_req()
918 buf.base[buf_used++] = handle->tty.rd.last_key[handle->tty.rd.last_key_offset++]; in uv_process_tty_read_raw_req()
922 handle->read_cb((uv_stream_t*) handle, buf_used, &buf); in uv_process_tty_read_raw_req()
931 if (--KEV.wRepeatCount > 0) { in uv_process_tty_read_raw_req()
932 handle->tty.rd.last_key_offset = 0; in uv_process_tty_read_raw_req()
936 handle->tty.rd.last_key_len = 0; in uv_process_tty_read_raw_req()
943 handle->read_cb((uv_stream_t*) handle, buf_used, &buf); in uv_process_tty_read_raw_req()
948 if ((handle->flags & UV_HANDLE_READING) && in uv_process_tty_read_raw_req()
949 !(handle->flags & UV_HANDLE_READ_PENDING)) { in uv_process_tty_read_raw_req()
964 assert(handle->type == UV_TTY); in uv_process_tty_read_line_req()
965 assert(handle->flags & UV_HANDLE_TTY_READABLE); in uv_process_tty_read_line_req()
967 buf = handle->tty.rd.read_line_buffer; in uv_process_tty_read_line_req()
969 handle->flags &= ~UV_HANDLE_READ_PENDING; in uv_process_tty_read_line_req()
970 handle->tty.rd.read_line_buffer = uv_null_buf_; in uv_process_tty_read_line_req()
974 if (handle->flags & UV_HANDLE_READING) { in uv_process_tty_read_line_req()
976 handle->flags &= ~UV_HANDLE_READING; in uv_process_tty_read_line_req()
978 handle->read_cb((uv_stream_t*) handle, in uv_process_tty_read_line_req()
983 if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING) && in uv_process_tty_read_line_req()
984 req->u.io.overlapped.InternalHigh != 0) { in uv_process_tty_read_line_req()
985 /* Read successful. TODO: read unicode, convert to utf-8 */ in uv_process_tty_read_line_req()
986 DWORD bytes = req->u.io.overlapped.InternalHigh; in uv_process_tty_read_line_req()
987 handle->read_cb((uv_stream_t*) handle, bytes, &buf); in uv_process_tty_read_line_req()
989 handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING; in uv_process_tty_read_line_req()
993 if ((handle->flags & UV_HANDLE_READING) && in uv_process_tty_read_line_req()
994 !(handle->flags & UV_HANDLE_READ_PENDING)) { in uv_process_tty_read_line_req()
1004 assert(handle->type == UV_TTY); in uv__process_tty_read_req()
1005 assert(handle->flags & UV_HANDLE_TTY_READABLE); in uv__process_tty_read_req()
1008 * Otherwise it was a line-buffered read. FIXME: This is quite obscure. Use a in uv__process_tty_read_req()
1010 if (handle->tty.rd.read_line_buffer.len == 0) { in uv__process_tty_read_req()
1020 uv_loop_t* loop = handle->loop; in uv__tty_read_start()
1022 if (!(handle->flags & UV_HANDLE_TTY_READABLE)) { in uv__tty_read_start()
1026 handle->flags |= UV_HANDLE_READING; in uv__tty_read_start()
1028 handle->read_cb = read_cb; in uv__tty_read_start()
1029 handle->alloc_cb = alloc_cb; in uv__tty_read_start()
1033 if (handle->flags & UV_HANDLE_READ_PENDING) { in uv__tty_read_start()
1037 /* Maybe the user stopped reading half-way while processing key events. in uv__tty_read_start()
1038 * Short-circuit if this could be the case. */ in uv__tty_read_start()
1039 if (handle->tty.rd.last_key_len > 0) { in uv__tty_read_start()
1040 SET_REQ_SUCCESS(&handle->read_req); in uv__tty_read_start()
1041 uv__insert_pending_req(handle->loop, (uv_req_t*) &handle->read_req); in uv__tty_read_start()
1042 /* Make sure no attempt is made to insert it again until it's handled. */ in uv__tty_read_start()
1043 handle->flags |= UV_HANDLE_READ_PENDING; in uv__tty_read_start()
1044 handle->reqs_pending++; in uv__tty_read_start()
1058 handle->flags &= ~UV_HANDLE_READING; in uv__tty_read_stop()
1059 DECREASE_ACTIVE_COUNT(handle->loop, handle); in uv__tty_read_stop()
1061 if (!(handle->flags & UV_HANDLE_READ_PENDING)) in uv__tty_read_stop()
1064 if (handle->flags & UV_HANDLE_TTY_RAW) { in uv__tty_read_stop()
1069 if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) { in uv__tty_read_stop()
1072 } else if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) { in uv__tty_read_stop()
1073 /* Cancel line-buffered read if not already pending */ in uv__tty_read_stop()
1078 handle->flags |= UV_HANDLE_CANCELLATION_PENDING; in uv__tty_read_stop()
1091 assert(!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)); in uv__cancel_read_console()
1130 if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) in uv__cancel_read_console()
1141 uv_tty_virtual_width = info->dwSize.X; in uv__tty_update_virtual_window()
1142 uv_tty_virtual_height = info->srWindow.Bottom - info->srWindow.Top + 1; in uv__tty_update_virtual_window()
1145 if (uv_tty_virtual_offset == -1) { in uv__tty_update_virtual_window()
1146 uv_tty_virtual_offset = info->dwCursorPosition.Y; in uv__tty_update_virtual_window()
1147 } else if (uv_tty_virtual_offset < info->dwCursorPosition.Y - in uv__tty_update_virtual_window()
1151 uv_tty_virtual_offset = info->dwCursorPosition.Y - in uv__tty_update_virtual_window()
1154 if (uv_tty_virtual_offset + uv_tty_virtual_height > info->dwSize.Y) { in uv__tty_update_virtual_window()
1155 uv_tty_virtual_offset = info->dwSize.Y - uv_tty_virtual_height; in uv__tty_update_virtual_window()
1172 y = info->dwCursorPosition.Y + y; in uv__tty_make_real_coord()
1180 y = uv_tty_virtual_offset + uv_tty_virtual_height - 1; in uv__tty_make_real_coord()
1185 x = info->dwCursorPosition.X + x; in uv__tty_make_real_coord()
1191 x = uv_tty_virtual_width - 1; in uv__tty_make_real_coord()
1205 return -1; in uv__tty_emit_text()
1208 if (!WriteConsoleW(handle->handle, in uv__tty_emit_text()
1214 return -1; in uv__tty_emit_text()
1227 return -1; in uv__tty_move_caret()
1231 if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { in uv__tty_move_caret()
1237 if (!SetConsoleCursorPosition(handle->handle, pos)) { in uv__tty_move_caret()
1239 /* The console may be resized - retry */ in uv__tty_move_caret()
1243 return -1; in uv__tty_move_caret()
1258 return -1; in uv__tty_reset()
1262 if (!SetConsoleTextAttribute(handle->handle, char_attrs)) { in uv__tty_reset()
1264 return -1; in uv__tty_reset()
1268 if (!SetConsoleCursorPosition(handle->handle, origin)) { in uv__tty_reset()
1270 return -1; in uv__tty_reset()
1275 if (!GetConsoleScreenBufferInfo(handle->handle, &screen_buffer_info)) { in uv__tty_reset()
1277 return -1; in uv__tty_reset()
1282 if (!(FillConsoleOutputCharacterW(handle->handle, in uv__tty_reset()
1287 FillConsoleOutputAttribute(handle->handle, in uv__tty_reset()
1293 /* The console may be resized - retry */ in uv__tty_reset()
1297 return -1; in uv__tty_reset()
1306 if (!SetConsoleCursorInfo(handle->handle, &uv_tty_default_cursor_info)) { in uv__tty_reset()
1308 return -1; in uv__tty_reset()
1325 return -1; in uv__tty_clear()
1362 if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { in uv__tty_clear()
1364 return -1; in uv__tty_clear()
1369 count = (end.Y * info.dwSize.X + end.X) - in uv__tty_clear()
1372 if (!(FillConsoleOutputCharacterW(handle->handle, in uv__tty_clear()
1377 FillConsoleOutputAttribute(handle->handle, in uv__tty_clear()
1383 /* The console may be resized - retry */ in uv__tty_clear()
1387 return -1; in uv__tty_clear()
1404 unsigned short argc = handle->tty.wr.ansi_csi_argc; in uv__tty_set_style()
1405 unsigned short* argv = handle->tty.wr.ansi_csi_argv; in uv__tty_set_style()
1409 char fg_color = -1, bg_color = -1; in uv__tty_set_style()
1410 char fg_bright = -1, bg_bright = -1; in uv__tty_set_style()
1411 char inverse = -1; in uv__tty_set_style()
1464 fg_color = arg - 30; in uv__tty_set_style()
1473 bg_color = arg - 40; in uv__tty_set_style()
1483 fg_color = arg - 90; in uv__tty_set_style()
1488 bg_color = arg - 100; in uv__tty_set_style()
1493 if (fg_color == -1 && bg_color == -1 && fg_bright == -1 && in uv__tty_set_style()
1494 bg_bright == -1 && inverse == -1) { in uv__tty_set_style()
1499 if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { in uv__tty_set_style()
1501 return -1; in uv__tty_set_style()
1508 if (fg_color != -1) { in uv__tty_set_style()
1515 if (fg_bright != -1) { in uv__tty_set_style()
1523 if (bg_color != -1) { in uv__tty_set_style()
1530 if (bg_bright != -1) { in uv__tty_set_style()
1538 if (inverse != -1) { in uv__tty_set_style()
1550 if (!SetConsoleTextAttribute(handle->handle, info.wAttributes)) { in uv__tty_set_style()
1552 return -1; in uv__tty_set_style()
1564 return -1; in uv__tty_save_state()
1567 if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { in uv__tty_save_state()
1569 return -1; in uv__tty_save_state()
1574 handle->tty.wr.saved_position.X = info.dwCursorPosition.X; in uv__tty_save_state()
1575 handle->tty.wr.saved_position.Y = info.dwCursorPosition.Y - in uv__tty_save_state()
1577 handle->flags |= UV_HANDLE_TTY_SAVED_POSITION; in uv__tty_save_state()
1580 handle->tty.wr.saved_attributes = info.wAttributes & in uv__tty_save_state()
1582 handle->flags |= UV_HANDLE_TTY_SAVED_ATTRIBUTES; in uv__tty_save_state()
1595 return -1; in uv__tty_restore_state()
1598 if (handle->flags & UV_HANDLE_TTY_SAVED_POSITION) { in uv__tty_restore_state()
1600 handle->tty.wr.saved_position.X, in uv__tty_restore_state()
1602 handle->tty.wr.saved_position.Y, in uv__tty_restore_state()
1605 return -1; in uv__tty_restore_state()
1610 (handle->flags & UV_HANDLE_TTY_SAVED_ATTRIBUTES)) { in uv__tty_restore_state()
1611 if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { in uv__tty_restore_state()
1613 return -1; in uv__tty_restore_state()
1618 new_attributes |= handle->tty.wr.saved_attributes; in uv__tty_restore_state()
1620 if (!SetConsoleTextAttribute(handle->handle, new_attributes)) { in uv__tty_restore_state()
1622 return -1; in uv__tty_restore_state()
1634 if (!GetConsoleCursorInfo(handle->handle, &cursor_info)) { in uv__tty_set_cursor_visibility()
1636 return -1; in uv__tty_set_cursor_visibility()
1641 if (!SetConsoleCursorInfo(handle->handle, &cursor_info)) { in uv__tty_set_cursor_visibility()
1643 return -1; in uv__tty_set_cursor_visibility()
1652 if (!GetConsoleCursorInfo(handle->handle, &cursor_info)) { in uv__tty_set_cursor_shape()
1654 return -1; in uv__tty_set_cursor_shape()
1665 if (!SetConsoleCursorInfo(handle->handle, &cursor_info)) { in uv__tty_set_cursor_shape()
1667 return -1; in uv__tty_set_cursor_shape()
1693 if (wchars_needed > ARRAY_SIZE(utf16_buf) - utf16_buf_used) { \
1698 unsigned char utf8_bytes_left = handle->tty.wr.utf8_bytes_left;
1699 unsigned int utf8_codepoint = handle->tty.wr.utf8_codepoint;
1700 unsigned char previous_eol = handle->tty.wr.previous_eol;
1701 unsigned short ansi_parser_state = handle->tty.wr.ansi_parser_state;
1717 * shortest form encodings and invalid code points - there's no real harm
1720 /* Read utf-8 start byte */
1727 first_zero_bit = (sizeof(int) * 8) - 1 - __builtin_clz(not_c);
1730 /* Ascii - pass right through */
1735 utf8_codepoint = (0xff >> (8 - first_zero_bit)) & c;
1736 utf8_bytes_left = (char) (6 - first_zero_bit);
1744 /* 0xff -- invalid */
1749 /* Valid continuation of utf-8 multibyte sequence */
1750 utf8_bytes_left--;
1760 j--;
1768 /* Parse vt100/ansi escape codes */
1770 /* Pass through escape codes if conhost supports them. */
1779 handle->tty.wr.ansi_csi_argc = 0;
1787 handle->tty.wr.ansi_csi_argc = 0;
1800 /* Ignore double escape. */
1826 /* Single-char control. */
1830 /* Invalid - proceed as normal, */
1849 int style = handle->tty.wr.ansi_csi_argc
1850 ? handle->tty.wr.ansi_csi_argv[0] : 1;
1857 /* Sequence ended - go back to normal state. */
1874 if (handle->tty.wr.ansi_csi_argc >=
1875 ARRAY_SIZE(handle->tty.wr.ansi_csi_argv)) {
1880 handle->tty.wr.ansi_csi_argc++;
1881 handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] =
1882 (unsigned short) utf8_codepoint - '0';
1888 handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1];
1896 handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] =
1897 (unsigned short) value + (utf8_codepoint - '0');
1912 if (handle->tty.wr.ansi_csi_argc >=
1914 ARRAY_SIZE(handle->tty.wr.ansi_csi_argv)) {
1919 handle->tty.wr.ansi_csi_argc++;
1920 handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] = 0;
1927 handle->tty.wr.ansi_csi_argc == 0) {
1948 if (handle->tty.wr.ansi_csi_argc == 1 &&
1949 handle->tty.wr.ansi_csi_argv[0] == 25) {
1957 if (handle->tty.wr.ansi_csi_argc == 1 &&
1958 handle->tty.wr.ansi_csi_argv[0] == 25) {
1972 y = -(handle->tty.wr.ansi_csi_argc
1973 ? handle->tty.wr.ansi_csi_argv[0] : 1);
1980 y = handle->tty.wr.ansi_csi_argc
1981 ? handle->tty.wr.ansi_csi_argv[0] : 1;
1988 x = handle->tty.wr.ansi_csi_argc
1989 ? handle->tty.wr.ansi_csi_argv[0] : 1;
1996 x = -(handle->tty.wr.ansi_csi_argc
1997 ? handle->tty.wr.ansi_csi_argv[0] : 1);
2004 y = handle->tty.wr.ansi_csi_argc
2005 ? handle->tty.wr.ansi_csi_argv[0] : 1;
2012 y = -(handle->tty.wr.ansi_csi_argc
2013 ? handle->tty.wr.ansi_csi_argv[0] : 1);
2020 x = (handle->tty.wr.ansi_csi_argc >= 1 &&
2021 handle->tty.wr.ansi_csi_argv[0])
2022 ? handle->tty.wr.ansi_csi_argv[0] - 1 : 0;
2030 y = (handle->tty.wr.ansi_csi_argc >= 1 &&
2031 handle->tty.wr.ansi_csi_argv[0])
2032 ? handle->tty.wr.ansi_csi_argv[0] - 1 : 0;
2033 x = (handle->tty.wr.ansi_csi_argc >= 2 &&
2034 handle->tty.wr.ansi_csi_argv[1])
2035 ? handle->tty.wr.ansi_csi_argv[1] - 1 : 0;
2042 d = handle->tty.wr.ansi_csi_argc
2043 ? handle->tty.wr.ansi_csi_argv[0] : 0;
2052 d = handle->tty.wr.ansi_csi_argc
2053 ? handle->tty.wr.ansi_csi_argv[0] : 0;
2079 /* Sequence ended - go back to normal state. */
2109 /* Escape character */
2127 /* EOL conversion - emit \r\n when we see \n. */
2140 /* \r without \n; print \r as-is. */
2148 /* Encode character into utf-16 buffer. */
2154 utf8_codepoint -= 0x10000;
2166 handle->tty.wr.utf8_bytes_left = utf8_bytes_left;
2167 handle->tty.wr.utf8_codepoint = utf8_codepoint;
2168 handle->tty.wr.previous_eol = previous_eol;
2169 handle->tty.wr.ansi_parser_state = ansi_parser_state;
2176 return -1;
2192 req->handle = (uv_stream_t*) handle;
2193 req->cb = cb;
2195 handle->reqs_pending++;
2196 handle->stream.conn.write_reqs_pending++;
2199 req->u.io.queued_bytes = 0;
2218 if (handle->stream.conn.write_reqs_pending > 0)
2232 handle->write_queue_size -= req->u.io.queued_bytes;
2235 if (req->cb) {
2237 req->cb(req, uv_translate_sys_error(err));
2240 handle->stream.conn.write_reqs_pending--;
2241 if (handle->stream.conn.shutdown_req != NULL &&
2242 handle->stream.conn.write_reqs_pending == 0) {
2251 assert(handle->u.fd == -1 || handle->u.fd > 2);
2252 if (handle->flags & UV_HANDLE_READING)
2255 if (handle->u.fd == -1)
2256 CloseHandle(handle->handle);
2258 close(handle->u.fd);
2260 handle->u.fd = -1;
2261 handle->handle = INVALID_HANDLE_VALUE;
2262 handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
2265 if (handle->reqs_pending == 0) {
2266 uv__want_endgame(handle->loop, (uv_handle_t*) handle);
2272 if (!(handle->flags & UV_HANDLE_TTY_READABLE) &&
2273 handle->stream.conn.shutdown_req != NULL &&
2274 handle->stream.conn.write_reqs_pending == 0) {
2275 UNREGISTER_HANDLE_REQ(loop, handle, handle->stream.conn.shutdown_req);
2277 /* TTY shutdown is really just a no-op */
2278 if (handle->stream.conn.shutdown_req->cb) {
2279 if (handle->flags & UV_HANDLE_CLOSING) {
2280 handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, UV_ECANCELED);
2282 handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, 0);
2286 handle->stream.conn.shutdown_req = NULL;
2292 if (handle->flags & UV_HANDLE_CLOSING &&
2293 handle->reqs_pending == 0) {
2296 assert(!(handle->flags & UV_HANDLE_TTY_READABLE) ||
2297 handle->tty.rd.read_raw_wait == NULL);
2299 assert(!(handle->flags & UV_HANDLE_CLOSED));
2366 * is a 32-bit process running on 64-bit Windows. Fall back to receiving
2427 height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1;
2430 assert(uv__tty_console_width != -1 && uv__tty_console_height != -1);