commit c388b84

delthas  ·  2025-03-05 16:56:57 +0000 UTC
parent cbbc006
Add workaround support for RGB colors on Windows Terminal
1 files changed,  +12, -0
+12, -0
 1@@ -3,7 +3,9 @@ package ui
 2 import (
 3 	"fmt"
 4 	"image"
 5+	"os"
 6 	"reflect"
 7+	"runtime"
 8 	"strings"
 9 	"sync/atomic"
10 	"time"
11@@ -94,6 +96,16 @@ func New(config Config) (ui *UI, colors ConfigColors, err error) {
12 		ui.memberWidth = config.MemberColWidth
13 	}
14 
15+	if runtime.GOOS == "windows" {
16+		// Work around broken RGB colors on Windows Terminal.
17+		// Sadly the Windows Terminal does not support TerminalID, so we rely on GOOS here.
18+		if os.Getenv("COLORTERM") == "" {
19+			os.Setenv("COLORTERM", "truecolor")
20+		}
21+		if os.Getenv("VAXIS_FORCE_LEGACY_SGR") == "" {
22+			os.Setenv("VAXIS_FORCE_LEGACY_SGR", "true")
23+		}
24+	}
25 	var vx *vaxis.Vaxis
26 	vx, err = vaxis.New(vaxis.Options{
27 		DisableMouse: !config.Mouse,