v0.1.2 moved xterm color functionality to color package, adapters added for compatibility

This commit is contained in:
2026-07-19 05:48:02 -04:00
parent 9853ac0270
commit e5c78a87f2
12 changed files with 210 additions and 228 deletions
+32
View File
@@ -0,0 +1,32 @@
//go:build windows
package inline
import (
"os"
"golang.org/x/sys/windows"
)
func detectColorMode() colorMode {
if os.Getenv("WT_SESSION") != "" || os.Getenv("WT_PROFILE_ID") != "" {
return colorModeTrueColor
}
if ct := os.Getenv("COLORTERM"); ct == "truecolor" || ct == "24bit" {
return colorModeTrueColor
}
return colorMode256
}
func windowSize(f *os.File) (w, h int, ok bool) {
var info windows.ConsoleScreenBufferInfo
if err := windows.GetConsoleScreenBufferInfo(windows.Handle(f.Fd()), &info); err != nil {
return 0, 0, false
}
width := int(info.Window.Right-info.Window.Left) + 1
height := int(info.Window.Bottom-info.Window.Top) + 1
if width < 1 || height < 1 {
return 0, 0, false
}
return width, height, true
}