xonecas.io
62159
Sy

symb / commit e041596

fix: theme is consistent, scrolling is smooth, app looks like a real

deal and not a joke

xonecas2026-02-13 e0415966cd0689cc3f7e050d9080d8f90c30f219 parent 777dafe

4 files changed

internal/constants/constants.go+4−1
@@ -47,8 +47,11 @@ package constants
4747 // - vs - Visual Studio light
4848 // - xcode - Xcode light theme
4949 //
50+// Pure black (#000000) background:
51+// - average, modus-vivendi, rrt, swapoff, vim
52+//
5053 // Other themes:
5154 // - fruity, autumn, friendly, colorful, tango, algol, arduino
5255 // - base16-snazzy, borland, emacs, pygments, rainbow_dash
5356 // - and more...
54-const SyntaxTheme = "github-dark"
57+const SyntaxTheme = "swapoff"
internal/tui/editor/editor.go+49−10
@@ -28,8 +28,8 @@ var (
2828 hlCacheMu sync.RWMutex
2929 )
3030
31-func cachedHighlight(text, language, theme string) string {
32- cacheKey := language + ":" + theme + ":" + text
31+func cachedHighlight(text, language, theme, bgHex string) string {
32+ cacheKey := language + ":" + theme + ":" + bgHex + ":" + text
3333 hlCacheMu.RLock()
3434 if v, ok := hlCache[cacheKey]; ok {
3535 hlCacheMu.RUnlock()
@@ -55,7 +55,13 @@ func cachedHighlight(text, language, theme string) string {
5555 if err := fmtr.Format(&buf, sty, it); err != nil {
5656 return text
5757 }
58- result := strings.TrimRight(buf.String(), "\n")
58+ raw := strings.TrimRight(buf.String(), "\n")
59+
60+ // Chroma's terminal16m formatter skips bg on tokens that inherit from
61+ // the Background entry, and every \x1b[0m reset clears bg. Fix by
62+ // replacing resets with reset+bg so the background is always active.
63+ bgSeq := hexToBgSeq(bgHex)
64+ result := bgSeq + strings.ReplaceAll(raw, "\x1b[0m", "\x1b[0m"+bgSeq)
5965
6066 hlCacheMu.Lock()
6167 if len(hlCache) > 2000 {
@@ -66,6 +72,33 @@ func cachedHighlight(text, language, theme string) string {
6672 return result
6773 }
6874
75+// hexToBgSeq converts "#rrggbb" to an ANSI 24-bit background escape sequence.
76+func hexToBgSeq(hex string) string {
77+ if len(hex) != 7 || hex[0] != '#' {
78+ return ""
79+ }
80+ r := hexByte(hex[1], hex[2])
81+ g := hexByte(hex[3], hex[4])
82+ b := hexByte(hex[5], hex[6])
83+ return fmt.Sprintf("\x1b[48;2;%d;%d;%dm", r, g, b)
84+}
85+
86+func hexByte(hi, lo byte) int {
87+ return hexNibble(hi)<<4 | hexNibble(lo)
88+}
89+
90+func hexNibble(c byte) int {
91+ switch {
92+ case c >= '0' && c <= '9':
93+ return int(c - '0')
94+ case c >= 'a' && c <= 'f':
95+ return int(c-'a') + 10
96+ case c >= 'A' && c <= 'F':
97+ return int(c-'A') + 10
98+ }
99+ return 0
100+}
101+
69102 // themeBg extracts the background hex color from a Chroma style.
70103 // Returns "" if no background is set.
71104 func themeBg(theme string) string {
@@ -396,15 +429,20 @@ func (m *Model) expandedColToBufferCol(bufRow, expandedCol int) int {
396429 return len(line)
397430 }
398431
399-// bgForRender returns the background style. Extracts from syntax theme if
400-// available, falls back to BgColor.
401-func (m *Model) bgForRender() lipgloss.Style {
432+// bgHexForRender returns the background hex color. Prefers the syntax theme
433+// background, falls back to BgColor.
434+func (m *Model) bgHexForRender() string {
402435 if m.Language != "" && m.SyntaxTheme != "" {
403436 if hex := themeBg(m.SyntaxTheme); hex != "" {
404- return lipgloss.NewStyle().Background(lipgloss.Color(hex))
437+ return hex
405438 }
406439 }
407- return lipgloss.NewStyle().Background(m.BgColor)
440+ return string(m.BgColor)
441+}
442+
443+// bgForRender returns the background as a lipgloss style.
444+func (m *Model) bgForRender() lipgloss.Style {
445+ return lipgloss.NewStyle().Background(lipgloss.Color(m.bgHexForRender()))
408446 }
409447
410448 // ---------------------------------------------------------------------------
@@ -735,7 +773,8 @@ func (m Model) View() string {
735773 }
736774
737775 tw := m.textWidth()
738- bg := m.bgForRender()
776+ bgHex := m.bgHexForRender()
777+ bg := lipgloss.NewStyle().Background(lipgloss.Color(bgHex))
739778 lineNumSty := m.LineNumStyle.Background(bg.GetBackground())
740779
741780 // Build a flat list of visual rows from visible buffer lines.
@@ -768,7 +807,7 @@ func (m Model) View() string {
768807 // Highlight the full line once for all its segments.
769808 var fullHL string
770809 if hasSyntax {
771- fullHL = cachedHighlight(lineStr, m.Language, m.SyntaxTheme)
810+ fullHL = cachedHighlight(lineStr, m.Language, m.SyntaxTheme, bgHex)
772811 }
773812
774813 firstSub := 0
internal/tui/styles.go+1−1
@@ -5,7 +5,7 @@ import "github.com/charmbracelet/lipgloss"
55 // Semantic color palette — grayscale "suit and tie" with a single accent.
66 var (
77 // Accent — used sparingly: cursor, spinner, active indicators.
8- ColorMatrix = lipgloss.Color("#00AA00")
8+ ColorHighlight = lipgloss.Color("#00E5CC")
99
1010 // Backgrounds
1111 ColorBg = lipgloss.Color("#000000") // Pure black — consistent everywhere
internal/tui/tui.go+1−1
@@ -248,7 +248,7 @@ type Model struct {
248248 // New creates a new TUI model.
249249 func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool, modelID string) Model {
250250 sty := DefaultStyles()
251- cursorStyle := lipgloss.NewStyle().Foreground(ColorMatrix)
251+ cursorStyle := lipgloss.NewStyle().Foreground(ColorHighlight)
252252
253253 s := spinner.New()
254254 s.Spinner = spinner.Dot