From 2401bc98ee5ec31d111e912b09b33e0c5c377a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Sun, 17 Dec 2023 20:22:54 +0100 Subject: [PATCH 1/2] console_win: Try to activate modeVtOutput by default --- console_win.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/console_win.go b/console_win.go index c946c02c..65a0da45 100644 --- a/console_win.go +++ b/console_win.go @@ -215,19 +215,13 @@ func (s *cScreen) Init() error { s.fini = false s.setInMode(modeResizeEn | modeExtndFlg) - - // 24-bit color is opt-in for now, because we can't figure out - // to make it work consistently. - if s.truecolor { - s.setOutMode(modeVtOutput | modeNoAutoNL | modeCookedOut) - var omode uint32 - s.getOutMode(&omode) - if omode&modeVtOutput == modeVtOutput { - s.vten = true - } else { - s.truecolor = false - } + s.setOutMode(modeVtOutput | modeNoAutoNL | modeCookedOut) + var omode uint32 + s.getOutMode(&omode) + if omode&modeVtOutput == modeVtOutput { + s.vten = true } else { + s.truecolor = false s.setOutMode(0) } From 09e15ee9d62d01f6b3e9fb9134be8ea665eebf78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Sun, 17 Dec 2023 20:23:43 +0100 Subject: [PATCH 2/2] console_win: Switch to alternate screen mode in case of modeVtOutput --- console_win.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/console_win.go b/console_win.go index 65a0da45..64d80640 100644 --- a/console_win.go +++ b/console_win.go @@ -146,6 +146,8 @@ const ( vtSetBg = "\x1b[48;5;%dm" vtSetFgRGB = "\x1b[38;2;%d;%d;%dm" // RGB vtSetBgRGB = "\x1b[48;2;%d;%d;%dm" // RGB + vtEnterCA = "\x1b[?1049h\x1b[22;0;0t" // activate alternate screen + store title + vtExitCA = "\x1b[?1049l\x1b[23;0;0t" // deactivate alternate screen + restore title ) // NewConsoleScreen returns a Screen for the Windows console associated @@ -225,6 +227,10 @@ func (s *cScreen) Init() error { s.setOutMode(0) } + if s.vten { + s.emitVtString(vtEnterCA) + } + s.clearScreen(s.style) s.hideCursor() s.Unlock() @@ -251,6 +257,10 @@ func (s *cScreen) Fini() { } func (s *cScreen) finish() { + if s.vten { + s.emitVtString(vtExitCA) + } + s.Lock() s.style = StyleDefault s.curx = -1