This PR contains solutions for adaptive colors, background color detection, and colorprofile-based writers. It also updates all tests and examples for v2.
The big changes in here are:
// Background color detection.
hasDarkBG, err := lipgloss.HasDarkBackground(os.Stdin, os.Stdout)
if err != nil {
log.Fatal("Uh oh:", err)
}
// Adaptive color helper.
lightDark := lipgloss.LightDark(hasDarkBG)
c := lightDark.Color(lightDark(0x212121, 0xf1f1f1))
// Color downsampling happens via a writer.
str := lipgloss.NewStyle().Foreground(c).Render("Hello!")
lipgloss.Println(str)
This PR contains solutions for adaptive colors, background color detection, and colorprofile-based writers. It also updates all tests and examples for
v2
.The big changes in here are:
Available writer utilties are:
Writer
(writes to stdout)Print(v ...any)
Println(...any)
Printf(string, ...any)
Fprint(io.Writer, ...any)
Fprintf(io.Writer, string, ...any)
Supersedes #392. Supersedes #389.