-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyle.go
More file actions
136 lines (126 loc) · 3.9 KB
/
Copy pathstyle.go
File metadata and controls
136 lines (126 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package main
import (
"fmt"
"strings"
"github.com/charmbracelet/lipgloss"
)
// eighth-block chars for sub-cell-precision bars and sparklines.
var blockEighths = []rune{' ', '▏', '▎', '▍', '▌', '▋', '▊', '▉', '█'}
var sparkBars = []rune{'▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'}
// sparkline renders a compact unicode sparkline from a 0..maxVal series.
// width caps the rendered cells; oldest data is left-truncated.
func sparkline(series []float64, width int, c lipgloss.Color) string {
if width <= 0 || len(series) == 0 {
return strings.Repeat(" ", width)
}
start := 0
if len(series) > width {
start = len(series) - width
}
s := series[start:]
maxV := 1.0
for _, v := range s {
if v > maxV {
maxV = v
}
}
st := lipgloss.NewStyle().Foreground(c)
var b strings.Builder
for _, v := range s {
idx := int(v / maxV * float64(len(sparkBars)-1))
if idx < 0 {
idx = 0
}
if idx >= len(sparkBars) {
idx = len(sparkBars) - 1
}
b.WriteString(st.Render(string(sparkBars[idx])))
}
if pad := width - len(s); pad > 0 {
b.WriteString(strings.Repeat(" ", pad))
}
return b.String()
}
// trendGlyph: arrow + delta. flat returns empty string for quiet rows.
func trendGlyph(trend int8, deltaMB float64) string {
switch {
case trend > 0:
return lipgloss.NewStyle().Foreground(colWarn).Render(fmt.Sprintf("▲%.0f", deltaMB))
case trend < 0:
return lipgloss.NewStyle().Foreground(colOk).Render(fmt.Sprintf("▼%.0f", -deltaMB))
}
return ""
}
// palette — neutral chrome, single warm accent, plus per-category hues
var (
colFg = lipgloss.Color("#e6e6e6")
colMute = lipgloss.Color("#a8a8a8")
colDim = lipgloss.Color("#6c6c6c")
colDimmer = lipgloss.Color("#2a2a2a")
colBg = lipgloss.Color("#0a0a0a")
colAccent = lipgloss.Color("#ff9f0a") // honey
colWarn = lipgloss.Color("#ffb340")
colCrit = lipgloss.Color("#ff453a")
colCool = lipgloss.Color("#64d2ff")
colOk = lipgloss.Color("#30d158")
colSel = lipgloss.Color("#ffffff")
// category hues — desaturated, distinct
colCatClaude = lipgloss.Color("#bf8cf2") // violet
colCatLLM = lipgloss.Color("#64d2ff") // cyan
colCatBrowser = lipgloss.Color("#ffd060") // amber
colCatEditor = lipgloss.Color("#7fd182") // sage
colCatVM = lipgloss.Color("#ff8a65") // coral
colCatSystem = lipgloss.Color("#7a8290") // slate
colCatRuntime = lipgloss.Color("#e6c66b") // wheat
colCatOther = lipgloss.Color("#9a9a9a") // grey
styleTitle = lipgloss.NewStyle().Bold(true).Foreground(colFg)
styleSub = lipgloss.NewStyle().Foreground(colMute)
styleDim = lipgloss.NewStyle().Foreground(colDim)
styleDimmer = lipgloss.NewStyle().Foreground(colDimmer)
styleAccent = lipgloss.NewStyle().Foreground(colAccent)
styleWarn = lipgloss.NewStyle().Foreground(colWarn)
styleCrit = lipgloss.NewStyle().Foreground(colCrit).Bold(true)
styleOk = lipgloss.NewStyle().Foreground(colOk)
styleSelRow = lipgloss.NewStyle().Foreground(colSel).Bold(true)
styleHint = lipgloss.NewStyle().Foreground(colDim)
styleSection = lipgloss.NewStyle().Foreground(colMute)
stylePane = lipgloss.NewStyle().Padding(1, 2)
styleConfirm = lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(colAccent).
Padding(0, 2).
Foreground(colFg)
styleDetail = lipgloss.NewStyle().
Border(lipgloss.NormalBorder(), false, false, false, true).
BorderForeground(colDimmer).
PaddingLeft(2).
Foreground(colFg)
styleSelBg = lipgloss.NewStyle().
Background(lipgloss.Color("#1a1410")).
Foreground(colSel).
Bold(true)
)
func memColor(pct float64) lipgloss.Color {
switch {
case pct >= 90:
return colCrit
case pct >= 75:
return colWarn
case pct >= 50:
return colAccent
default:
return colOk
}
}
func cpuColor(pct float64) lipgloss.Color {
switch {
case pct >= 80:
return colCrit
case pct >= 60:
return colWarn
case pct >= 30:
return colCool
default:
return colOk
}
}