feat(theme): add catppuccin themes with transparency and 256-color support

Add a theme package providing all four catppuccin flavors (mocha,
frappe, macchiato, latte) mapped to the xterm-256 palette. Themes are
selected with -theme or the CTOP_THEME environment variable; -i inverts
the flavor. Background slots use the terminal's native color for
transparency (opt out with -solid / CTOP_SOLID), and termbox is switched
to Output256 so colors render correctly. Replace hardcoded colors in the
compact and single views with ctheme portrait slots.
This commit is contained in:
ahp
2026-09-14 14:06:49 +03:30
parent 59f00dd6aa
commit 78e85dc4df
12 changed files with 454 additions and 67 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ import (
"github.com/bcicen/ctop/cwidgets"
"github.com/bcicen/ctop/models"
"github.com/bcicen/ctop/theme"
ui "github.com/gizak/termui"
)
@@ -75,7 +76,7 @@ func (w *GaugeCol) Buffer() ui.Buffer {
// percentage value and low-contrast color for structure
if w.Percent < 5 {
w.Percent = 5
w.BarColor = ui.ColorBlack
w.BarColor = theme.Attr("crust")
}
return w.Gauge.Buffer()
+5 -4
View File
@@ -2,6 +2,7 @@ package compact
import (
"github.com/bcicen/ctop/models"
"github.com/bcicen/ctop/theme"
ui "github.com/gizak/termui"
)
@@ -45,7 +46,7 @@ func (s *Status) Header() string { return "" }
func (s *Status) FixedWidth() int { return 3 }
func (s *Status) setState(val string) {
color := ui.ColorDefault
color := theme.Attr("text")
var mark string
switch val {
@@ -66,11 +67,11 @@ func (s *Status) setState(val string) {
log.Warningf("unknown status string: \"%v\"", val)
}
s.status = ui.TextCells(mark, color, ui.ColorDefault)
s.status = ui.TextCells(mark, color, theme.Attr("bg"))
}
func (s *Status) setHealth(val string) {
color := ui.ColorDefault
color := theme.Attr("text")
var mark string
switch val {
@@ -90,5 +91,5 @@ func (s *Status) setHealth(val string) {
log.Warningf("unknown health state string: \"%v\"", val)
}
s.health = ui.TextCells(mark, color, ui.ColorDefault)
s.health = ui.TextCells(mark, color, theme.Attr("bg"))
}
+3 -2
View File
@@ -5,6 +5,7 @@ import (
"strings"
"github.com/bcicen/ctop/cwidgets"
"github.com/bcicen/ctop/theme"
ui "github.com/gizak/termui"
)
@@ -26,13 +27,13 @@ func NewIO() *IO {
read.Title = "READ"
read.Height = 1
read.Data = io.readHist.Data
read.LineColor = ui.ColorGreen
read.LineColor = theme.Attr("io.read")
write := ui.NewSparkline()
write.Title = "WRITE"
write.Height = 1
write.Data = io.writeHist.Data
write.LineColor = ui.ColorYellow
write.LineColor = theme.Attr("io.write")
io.Lines = []ui.Sparkline{read, write}
return io
+3 -2
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/bcicen/ctop/cwidgets"
"github.com/bcicen/ctop/theme"
ui "github.com/gizak/termui"
)
@@ -67,8 +68,8 @@ func newMemChart() *ui.MBarChart {
mbar.BarGap = 1
mbar.BarWidth = 6
mbar.BarColor[1] = ui.ColorBlack
mbar.NumColor[1] = ui.ColorBlack
mbar.BarColor[1] = theme.Attr("crust")
mbar.NumColor[1] = theme.Attr("crust")
mbar.NumFmt = cwidgets.ByteFormatShort
//mbar.ShowScale = true
+3 -2
View File
@@ -5,6 +5,7 @@ import (
"strings"
"github.com/bcicen/ctop/cwidgets"
"github.com/bcicen/ctop/theme"
ui "github.com/gizak/termui"
)
@@ -26,13 +27,13 @@ func NewNet() *Net {
rx.Title = "RX"
rx.Height = 1
rx.Data = net.rxHist.Data
rx.LineColor = ui.ColorGreen
rx.LineColor = theme.Attr("net.rx")
tx := ui.NewSparkline()
tx.Title = "TX"
tx.Height = 1
tx.Data = net.txHist.Data
tx.LineColor = ui.ColorYellow
tx.LineColor = theme.Attr("net.tx")
net.Lines = []ui.Sparkline{rx, tx}
return net