theme

package
v0.1.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 5 Imported by: 4 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package theme manages viewkit's process-global palette, styles, and screen background rendering.

Index

Examples

Constants

View Source
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
)
View Source
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

View Source
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 AppMargin added in v0.0.3

func AppMargin(body string) string

func Bullet added in v0.0.4

func Bullet(msg string) string

func DisplayName

func DisplayName(key string) string

func FillLine added in v0.0.3

func FillLine(c lipgloss.TerminalColor, width int) string

func Icon added in v0.0.4

func Icon(icon string, hue int) string

func Keys

func Keys() []string

func PadBlock added in v0.0.3

func PadBlock(c lipgloss.TerminalColor, width, rows int, lines ...string) string

func Register added in v0.0.1

func Register(key, name string, p Palette)

func Screen

func Screen(body string, width, height int) 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

func SeverityGlyph(s glyph.Severity) string

SeverityGlyph returns the status-strip glyph for s (StatusOK/Warn/Bad/Muted).

func SeverityStyle added in v0.1.6

func SeverityStyle(s glyph.Severity) lipgloss.Style

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 StripBlock(width int, lines ...string) string

func StripBold added in v0.0.4

func StripBold(fg lipgloss.TerminalColor, s string) string

func StripText added in v0.0.4

func StripText(fg lipgloss.TerminalColor, s string) string

func Success added in v0.0.4

func Success(msg string) string

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)
}

Types

type Palette

type Palette struct {
	Accent   lipgloss.Color
	Border   lipgloss.Color
	Muted    lipgloss.Color
	Text     lipgloss.Color
	Selected lipgloss.Color
	Success  lipgloss.Color
	Warning  lipgloss.Color
	Failure  lipgloss.Color
	Info     lipgloss.Color
	Series2  lipgloss.Color
	Series3  lipgloss.Color
	Bg       lipgloss.Color
}

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
}

func Cur

func Cur() *Theme

func Default

func Default() Theme

func Named

func Named(key string) (Theme, bool)

func New

func New(p Palette) Theme

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL