From f509d95a26e18fd8e424a0d0fb8fffb3879d0836 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Mon, 27 Nov 2023 08:37:54 -0800 Subject: [PATCH] fix: use const colors to skip reading querying for the terminal bg color (#93) Don't use AdaptiveColors and use regular colors instead. This makes the default styles _not_ use HasDarkBackground to determine the terminal background color. HasDarkBackground will query the terminal for the background color using `OSC 11` to determine which color to use in AdaptiveColor. For users who still want to use AdaptiveColors, they can supply their own custom styles. Fixes: https://github.com/charmbracelet/log/issues/90 --- styles.go | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/styles.go b/styles.go index 14d261d..5a4e545 100644 --- a/styles.go +++ b/styles.go @@ -54,42 +54,27 @@ func DefaultStyles() *Styles { SetString(strings.ToUpper(DebugLevel.String())). Bold(true). MaxWidth(4). - Foreground(lipgloss.AdaptiveColor{ - Light: "63", - Dark: "63", - }), + Foreground(lipgloss.Color("63")), InfoLevel: lipgloss.NewStyle(). SetString(strings.ToUpper(InfoLevel.String())). Bold(true). MaxWidth(4). - Foreground(lipgloss.AdaptiveColor{ - Light: "39", - Dark: "86", - }), + Foreground(lipgloss.Color("86")), WarnLevel: lipgloss.NewStyle(). SetString(strings.ToUpper(WarnLevel.String())). Bold(true). MaxWidth(4). - Foreground(lipgloss.AdaptiveColor{ - Light: "208", - Dark: "192", - }), + Foreground(lipgloss.Color("192")), ErrorLevel: lipgloss.NewStyle(). SetString(strings.ToUpper(ErrorLevel.String())). Bold(true). MaxWidth(4). - Foreground(lipgloss.AdaptiveColor{ - Light: "203", - Dark: "204", - }), + Foreground(lipgloss.Color("204")), FatalLevel: lipgloss.NewStyle(). SetString(strings.ToUpper(FatalLevel.String())). Bold(true). MaxWidth(4). - Foreground(lipgloss.AdaptiveColor{ - Light: "133", - Dark: "134", - }), + Foreground(lipgloss.Color("134")), }, Keys: map[string]lipgloss.Style{}, Values: map[string]lipgloss.Style{},