Documentation
¶
Overview ¶
Package theme holds the lipgloss styles shared by the model and its panels: a rounded-border panel box (bright when focused, dim otherwise), a panel title, and the status line.
Kept tiny and dependency-free so both ux and panels can import it without a cycle.
Index ¶
- Constants
- func Accent() lipgloss.Style
- func Chip() lipgloss.Style
- func Dim() lipgloss.Style
- func Dir() lipgloss.Style
- func Follower() lipgloss.Style
- func Gutter() lipgloss.Style
- func Match() lipgloss.Style
- func Modal() lipgloss.Style
- func ModalAt(textW int) lipgloss.Style
- func Panel(w, h int, focused bool) lipgloss.Style
- func Selected() lipgloss.Style
- func SevError() lipgloss.Style
- func SevHint() lipgloss.Style
- func SevWarn() lipgloss.Style
- func Stale() lipgloss.Style
- func Status() lipgloss.Style
- func Syntax(k SyntaxKind) lipgloss.Style
- func Title(focused bool) lipgloss.Style
- type Span
- type SyntaxKind
Constants ¶
const ModalChromeW = 2 + 2*modalPadH
ModalChromeW is how many columns a modal's frame costs on top of its text.
The padding on both sides, plus a border column on each.
For an overlay whose text WRAPS, and which therefore has to choose a width the terminal can hold. An overlay whose lines cannot be broken should not use this to clip itself - wrapping a laid-out table is worse than letting it run off the edge.
Variables ¶
This section is empty.
Functions ¶
func Chip ¶
Chip styles a small standing badge in the header.
Currently the h: help hint, which has to survive a crowded header line without being mistaken for one more status field.
func Dim ¶ added in v0.36.4
Dim styles secondary text that should recede.
Currently a diagnostic's trailing code, which is a lookup key rather than something read on every row.
Shares its colour with Status; they are separate functions because they are separate decisions, and a status line that stopped being dim should not drag the diagnostics pane with it.
func Follower ¶
Follower styles a cross-ref line in the pane that is MIRRORING the driver.
A muted tint of Selected, so at a glance it is obvious which pane leads and which one is being dragged along.
func Gutter ¶
Gutter styles the link markers in the spec pane's and source viewer's gutter.
Dim on purpose: they are a hint about what is navigable, not content.
func Modal ¶
Modal styles a centered popup box (e.g. the scanner-options dialog).
It sizes to its content, which is right for a modal showing all of itself at once. An overlay that SCROLLS must use ModalAt instead: left to size itself, the frame tracks whichever lines happen to be visible and the box changes width as the content scrolls under it.
func ModalAt ¶ added in v0.36.4
ModalAt is Modal pinned to a fixed width of textW columns of TEXT.
The padding is added back on top, because lipgloss counts padding INSIDE the width it is given: a caller passing the width it measured its own text at would otherwise have its longest lines wrapped by exactly the padding - which is both wrong and hard to see, since it only bites the widest line.
func Panel ¶
Panel returns a rounded-border box style whose OUTER dimensions are w×h (the border consumes one cell on each side).
The border is bright when focused and dim otherwise.
func Selected ¶
Selected styles the cursor row in a navigable panel - the DRIVER line, i.e. the one the user is actually moving.
Strong reverse-video bar.
func SevError ¶
SevError styles an error-severity diagnostic label.
SevError, SevWarn and SevHint colour the severity label in the diagnostics pane red, amber and blue, matching the order of the severities themselves.
func Stale ¶
Stale styles the follow-mode badge shown while the source buffer has unsaved edits.
That is the state in which the cross-ref positions are older than what is on screen.
func Syntax ¶
func Syntax(k SyntaxKind) lipgloss.Style
Syntax returns the style for a syntax class.
The diagnostic classes underline as well as recolour: underline is the terminal's squiggle, and it survives a palette where the severity colour is close to a syntax one.
Types ¶
type Span ¶
type Span struct {
Col int // 1-based column of the run's first character
Kind SyntaxKind
}
Span is one lexical run on a rendered line, identified by where it STARTS.
A run extends to the next span's column (or the end of the line), which is what lets the renderer slice raw text at known boundaries instead of truncating already-coloured output - the operation that corrupts escapes.
type SyntaxKind ¶
type SyntaxKind uint8
SyntaxKind classifies a lexical run for highlighting.
It is deliberately source-language-neutral: the JSON or YAML lexers and go/scanner both map onto it, so the renderer and the palette are shared rather than duplicated per pane.
const ( SyntaxPlain SyntaxKind = iota SyntaxKey SyntaxString SyntaxNumber SyntaxKeyword SyntaxPunct SyntaxComment SyntaxDiagError SyntaxDiagWarn SyntaxDiagHint )
The syntax classes.
Plain is the zero value, so an unmapped token simply renders unstyled rather than wrong.
The Diag* classes are the exception to "lexical": they are not what a token IS but what the scanner said ABOUT it, overlaid on the run the diagnostic points at. They ride the same span mechanism because a diagnostic and a token address the same thing - a (line, column) run - and giving them a second mechanism would mean two ways to paint one line.