From e8df81ebef24ffa4d069005ca9d9ae8b7057f79e Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 9 Oct 2021 02:01:04 -0400 Subject: [PATCH] [windows] exit if we can't get ConsoleHandles #2244 --- src/lib/termdesc.c | 18 +++++++++++++----- src/lib/windows.c | 3 +-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index 961f7270b..427b36e95 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -501,6 +501,11 @@ static int apply_term_heuristics(tinfo* ti, const char* termname, queried_terminals_e qterm, size_t* tablelen, size_t* tableused, bool* invertsixel, unsigned nonewfonts){ +#ifdef __MINGW64__ + if(qterm == TERMINAL_UNKNOWN){ + qterm = TERMINAL_MSTERMINAL; + } +#endif if(!termname){ // setupterm interprets a missing/empty TERM variable as the special value “unknown”. termname = ti->termname ? ti->termname : "unknown"; @@ -596,6 +601,9 @@ apply_term_heuristics(tinfo* ti, const char* termname, queried_terminals_e qterm *invertsixel = true; } ti->bce = true; + }else if(qterm == TERMINAL_MSTERMINAL){ + ti->termname = "Windows Terminal"; + ti->caps.rgb = true; }else if(qterm == TERMINAL_CONTOUR){ termname = "Contour"; ti->caps.quadrants = true; @@ -744,11 +752,11 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut if(termtype){ logwarn("termtype (%s) ignored on windows\n", termtype); } - if(prepare_windows_terminal(ti, &tablelen, &tableused) == 0){ - ti->qterm = TERMINAL_MSTERMINAL; - if(cursor_y && cursor_x){ - locate_cursor(ti, cursor_y, cursor_x); - } + if(prepare_windows_terminal(ti, &tablelen, &tableused)){ + return -1; + } + if(cursor_y && cursor_x){ + locate_cursor(ti, cursor_y, cursor_x); } #elif defined(__linux__) ti->linux_fb_fd = -1; diff --git a/src/lib/windows.c b/src/lib/windows.c index 8a936eaea..ba1c4bda7 100644 --- a/src/lib/windows.c +++ b/src/lib/windows.c @@ -87,8 +87,7 @@ int prepare_windows_terminal(tinfo* ti, size_t* tablelen, size_t* tableused){ logerror("couldn't set output console mode\n"); return -1; } - ti->termname = "Windows Terminal"; - loginfo("verified Windows Terminal\n"); + loginfo("verified Windows ConPTY\n"); return 0; } #endif