refactor: add a clean termstyle file for styling

This commit is contained in:
2026-03-21 05:58:44 +00:00
parent e2d29aa9d8
commit 1a5364a696
2 changed files with 72 additions and 12 deletions
+2 -12
View File
@@ -7,12 +7,6 @@ import (
"strings"
)
const (
bold = "\x1b[1m"
italic = "\x1b[3m"
reset = "\x1b[0m"
)
var (
palette = struct {
miroPrefixGreen uint32
@@ -22,18 +16,14 @@ var (
miroChevronTeal: 0x1DD3B0,
}
chevron = ansiColor(palette.miroChevronTeal)
prefix = ansiColor(palette.miroPrefixGreen) + bold + italic + "miro" + reset + " " + chevron + bold + italic + "" + reset + " "
chevron = NewStyle().FG(palette.miroChevronTeal).Bold().Italic().Apply("")
prefix = NewStyle().FG(palette.miroPrefixGreen).Bold().Italic().Apply("miro") + " " + chevron + " "
)
func Prefix() string {
return prefix
}
func ansiColor(rgb uint32) string {
return fmt.Sprintf("\x1b[38;2;%d;%d;%dm", byte(rgb>>16), byte(rgb>>8), byte(rgb))
}
func Format(msg string) string {
body := strings.TrimRight(msg, "\n")
suffix := msg[len(body):]