From 21b1b87d12a36e7912a8237241267402c91e5162 Mon Sep 17 00:00:00 2001 From: JD Ballard Date: Wed, 30 Apr 2014 12:54:10 -0600 Subject: [PATCH] windows: add VT100 codes ?25l and ?25h --- src/win/tty.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/win/tty.c b/src/win/tty.c index 7840fb286..fee5786af 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -1316,6 +1316,25 @@ static int uv_tty_restore_state(uv_tty_t* handle, return 0; } +static int uv_tty_set_cursor_visibility(uv_tty_t* handle, + BOOL visible, + DWORD* error) { + CONSOLE_CURSOR_INFO cursor_info; + + if (!GetConsoleCursorInfo(handle->handle, &cursor_info)) { + *error = GetLastError(); + return -1; + } + + cursor_info.bVisible = visible; + + if (!SetConsoleCursorInfo(handle->handle, &cursor_info)) { + *error = GetLastError(); + return -1; + } + + return 0; +} static int uv_tty_write_bufs(uv_tty_t* handle, const uv_buf_t bufs[], @@ -1527,6 +1546,13 @@ static int uv_tty_write_bufs(uv_tty_t* handle, continue; } + } else if (utf8_codepoint == '?' && !(ansi_parser_state & ANSI_IN_ARG) && + handle->ansi_csi_argc == 0) { + /* Ignores '?' if it is the first character after CSI[ */ + /* This is an extension character from the VT100 codeset */ + /* that is supported and used by most ANSI terminals today. */ + continue; + } else if (utf8_codepoint >= '@' && utf8_codepoint <= '~' && (handle->ansi_csi_argc > 0 || utf8_codepoint != '[')) { int x, y, d; @@ -1629,6 +1655,24 @@ static int uv_tty_write_bufs(uv_tty_t* handle, FLUSH_TEXT(); uv_tty_restore_state(handle, 0, error); break; + + case 'l': + /* Hide the cursor */ + if (handle->ansi_csi_argc == 1 && + handle->ansi_csi_argv[0] == 25) { + FLUSH_TEXT(); + uv_tty_set_cursor_visibility(handle, 0, error); + } + break; + + case 'h': + /* Show the cursor */ + if (handle->ansi_csi_argc == 1 && + handle->ansi_csi_argv[0] == 25) { + FLUSH_TEXT(); + uv_tty_set_cursor_visibility(handle, 1, error); + } + break; } /* Sequence ended - go back to normal state. */