Documentation
¶
Overview ¶
Package theme manages viewkit's process-global palette, styles, and screen background rendering.
Index ¶
- Constants
- Variables
- func AppMargin(body string) string
- func Bullet(msg string) string
- func DisplayName(key string) string
- func FillLine(c lipgloss.TerminalColor, width int) string
- func Icon(icon string, hue int) string
- func Keys() []string
- func PadBlock(c lipgloss.TerminalColor, width, rows int, lines ...string) string
- func Register(key, name string, p Palette)
- func Screen(body string, width, height int) string
- func SeverityColor(s glyph.Severity) lipgloss.TerminalColor
- func SeverityGlyph(s glyph.Severity) string
- func SeverityStyle(s glyph.Severity) lipgloss.Style
- func StripBg() lipgloss.TerminalColor
- func StripBlock(width int, lines ...string) string
- func StripBold(fg lipgloss.TerminalColor, s string) string
- func StripText(fg lipgloss.TerminalColor, s string) string
- func Success(msg string) string
- func Use(t Theme)
- type Palette
- type Theme
Examples ¶
Constants ¶
const ( BodyWidth = 81 MinBodyWidth = 24 MinScreenWidth = 80 MinBodyHeight = 35 TallBodyHeight = 46 AppMarginY = 1 AppMarginX = 2 ListItemGapY = 1 ScreenPaddingWidth = AppMarginX*2 + 4 MinScreenBodyWidth = MinScreenWidth - ScreenPaddingWidth RuleWidth = BodyWidth + 4 )
const ( DefaultTooNarrowTitle = "TERMINAL TOO NARROW" DefaultTooNarrowNeed = "Need at least %d columns." DefaultTooNarrowBody = "Current width: %s columns. Resize the terminal to at least %d characters wide to use this screen." )
Variables ¶
var ( TitleSty lipgloss.Style AccentSty lipgloss.Style DimSty lipgloss.Style ValSty lipgloss.Style KeySty lipgloss.Style CanSty lipgloss.Style CantSty lipgloss.Style AppFrame lipgloss.Style PanelSty lipgloss.Style PanelFocusSty lipgloss.Style PanelTitleSty lipgloss.Style CardSty lipgloss.Style NotifPositiveSty lipgloss.Style NotifNeutralSty lipgloss.Style NotifWarningSty lipgloss.Style NotifNegativeSty lipgloss.Style NotifIdleSty lipgloss.Style NotifTitleSty lipgloss.Style Series []lipgloss.Style )
These package-level styles are a snapshot of the default theme taken during package initialization. They are written once, before any goroutine can observe them, and are never written again — so they are safe to read concurrently but they do not follow Use. Cur() is the sanctioned path to the active theme; prefer Cur().Dim over DimSty in anything that renders after a theme has been applied.
Functions ¶
func DisplayName ¶
func PadBlock ¶ added in v0.0.3
func PadBlock(c lipgloss.TerminalColor, width, rows int, lines ...string) string
func SeverityColor ¶ added in v0.0.4
func SeverityColor(s glyph.Severity) lipgloss.TerminalColor
SeverityColor maps glyph.Severity to the active theme's terminal color. glyph.Severity is the sole severity vocabulary; theme only supplies color.
func SeverityGlyph ¶ added in v0.0.4
SeverityGlyph returns the status-strip glyph for s (StatusOK/Warn/Bad/Muted).
func SeverityStyle ¶ added in v0.1.6
SeverityStyle maps glyph.Severity to the active theme's style for that severity. Use it when rendering text; use SeverityColor when only the foreground color is needed.
func StripBg ¶ added in v0.0.4
func StripBg() lipgloss.TerminalColor
func StripBlock ¶ added in v0.0.4
func Use ¶
func Use(t Theme)
Use makes t the active theme. Safe to call while other goroutines render.
Example ¶
package main
import (
"github.com/codyconfer/viewkit/theme"
)
func main() {
defer theme.Use(theme.Default())
if th, ok := theme.Named("monokai"); ok {
theme.Use(th)
}
body := theme.Cur().Accent.Render("ready")
_ = theme.Screen(body, theme.MinScreenWidth, theme.MinBodyHeight)
}
Output:
Types ¶
type Theme ¶
type Theme struct {
Title lipgloss.Style
Accent lipgloss.Style
Dim lipgloss.Style
Val lipgloss.Style
Key lipgloss.Style
Can lipgloss.Style
Cant lipgloss.Style
Panel lipgloss.Style
PanelFocus lipgloss.Style
PanelTitle lipgloss.Style
Card lipgloss.Style
AppFrame lipgloss.Style
NotifPositive lipgloss.Style
NotifNeutral lipgloss.Style
NotifWarning lipgloss.Style
NotifNegative lipgloss.Style
NotifIdle lipgloss.Style
NotifTitle lipgloss.Style
Series []lipgloss.Style
Bg lipgloss.Color
TooNarrowTitle string
TooNarrowNeed string
TooNarrowBody string
// contains filtered or unexported fields
}