-
Notifications
You must be signed in to change notification settings - Fork 1
/
render.go
40 lines (33 loc) · 1.41 KB
/
render.go
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
package main
import (
"github.com/charmbracelet/lipgloss"
)
var (
cursorRendererNormal = newCursorRenderer(lipgloss.NewStyle().SetString(" "))
cursorRendererMarked = newCursorRenderer(lipgloss.NewStyle().SetString("+"))
cursorRendererSelected = newCursorRenderer(lipgloss.NewStyle().Bold(true).SetString(">"))
cursorRendererSelectedMarked = newCursorRenderer(lipgloss.NewStyle().Bold(true).SetString("+"))
barRendererLocation = lipgloss.NewStyle().Background(lipgloss.Color("#5C5C5C")).Foreground(lipgloss.Color("#FFFFFF"))
barRendererSearch = lipgloss.NewStyle().Background(lipgloss.Color("#499F1C")).Foreground(lipgloss.Color("#FFFFFF"))
barRendererStatus = lipgloss.NewStyle().Background(lipgloss.Color("#494949")).Foreground(lipgloss.Color("#FFFFFF"))
barRendererError = lipgloss.NewStyle().Background(lipgloss.Color("#EB5B34")).Foreground(lipgloss.Color("#FFFFFF"))
barRendererOK = lipgloss.NewStyle().Background(lipgloss.Color("#499F1C")).Foreground(lipgloss.Color("#FFFFFF"))
)
type cursorRenderer struct {
style lipgloss.Style
pad string
}
func newCursorRenderer(style lipgloss.Style) *cursorRenderer {
pad := ""
padLen := columnSeparatorLen - len(style.Value()) - 1
if padLen > 0 {
pad = columnSeparator[:padLen]
}
return &cursorRenderer{
style: style,
pad: pad,
}
}
func (r *cursorRenderer) Render(name string) string {
return r.style.Render(name) + r.pad
}