summaryrefslogtreecommitdiffstats
path: root/src/os_win32.c
diff options
context:
space:
mode:
authorK.Takata <kentkt@csc.jp>2022-09-01 13:20:16 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-01 13:20:16 +0100
commitdf5320c439e9a7f7bf1ebff3cb455d45e223547a (patch)
tree844eaa8fddaa8e590d6b5f83876f6ca1bf76f546 /src/os_win32.c
parentd3de178e5352fedf0f30b979f46a2fcbca24ea40 (diff)
patch 9.0.0347: MS-Windows: cannot set cursor shape in Windows Terminalv9.0.0347
Problem: MS-Windows: cannot set cursor shape in Windows Terminal. Solution: Make cursor shape work with Windows Terminal. (Ken Takata, closes #11028, closes #6576)
Diffstat (limited to 'src/os_win32.c')
-rw-r--r--src/os_win32.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index e6ffcbac92..f6bf91d9fa 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -1528,13 +1528,27 @@ decode_mouse_event(
static void
mch_set_cursor_shape(int thickness)
{
- CONSOLE_CURSOR_INFO ConsoleCursorInfo;
- ConsoleCursorInfo.dwSize = thickness;
- ConsoleCursorInfo.bVisible = s_cursor_visible;
+ if (USE_VTP || USE_WT)
+ {
+ if (*T_CSI == NUL)
+ {
+ // If 't_SI' is not set, use the default cursor styles.
+ if (thickness < 50)
+ vtp_printf("\033[3 q"); // underline
+ else
+ vtp_printf("\033[0 q"); // default
+ }
+ }
+ else
+ {
+ CONSOLE_CURSOR_INFO ConsoleCursorInfo;
+ ConsoleCursorInfo.dwSize = thickness;
+ ConsoleCursorInfo.bVisible = s_cursor_visible;
- SetConsoleCursorInfo(g_hConOut, &ConsoleCursorInfo);
- if (s_cursor_visible)
- SetConsoleCursorPosition(g_hConOut, g_coord);
+ SetConsoleCursorInfo(g_hConOut, &ConsoleCursorInfo);
+ if (s_cursor_visible)
+ SetConsoleCursorPosition(g_hConOut, g_coord);
+ }
}
void
@@ -6770,6 +6784,21 @@ notsgr:
}
# endif
}
+ else if (s[0] == ESC && len >= 3-1 && s[1] == '[')
+ {
+ int l = 2;
+
+ if (isdigit(s[l]))
+ l++;
+ if (s[l] == ' ' && s[l + 1] == 'q')
+ {
+ // DECSCUSR (cursor style) sequences
+ if (USE_VTP || USE_WT)
+ vtp_printf("%.*s", l + 2, s); // Pass through
+ s += l + 2;
+ len -= l + 1;
+ }
+ }
else
{
// Write a single character
@@ -7953,7 +7982,7 @@ vtp_sgr_bulks(
if (argc == 0)
{
sgrfgr = sgrbgr = -1;
- vtp_printf("033[m");
+ vtp_printf("\033[m");
return;
}