Documentation
¶
Overview ¶
Package theme loads hunk's color themes: two built-ins, plus TOML files a user writes locally or pulls from a GitHub repo.
Index ¶
Constants ¶
const DefaultName = "hunk-dark"
DefaultName is the theme hunk uses when nothing else is asked for.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Diff ¶
type Diff struct {
AddedFg string `toml:"added_fg"`
AddedBg string `toml:"added_bg"`
RemovedFg string `toml:"removed_fg"`
RemovedBg string `toml:"removed_bg"`
ContextFg string `toml:"context_fg"`
AddedWordBg string `toml:"added_word_bg"`
RemovedWordBg string `toml:"removed_word_bg"`
}
Diff colors the changes themselves, including the intra-line emphasis that marks which words on a line actually moved.
type Loader ¶
type Loader struct {
// ConfigDir holds themes/ ; defaults to ConfigDir().
ConfigDir string
// BaseURL is where github.com/... references are fetched from. Tests point
// this at an httptest server so no test ever touches the network.
BaseURL string
// Refresh re-downloads remote themes instead of using the cached copy.
Refresh bool
}
Loader resolves a theme reference into a Theme.
type Theme ¶
type Theme struct {
Name string `toml:"name"`
// Syntax is the chroma style name used for syntax highlighting. It is not a
// color, so it sits outside UI/Diff and is skipped by the hex validation.
Syntax string `toml:"syntax"`
UI UI `toml:"ui"`
Diff Diff `toml:"diff"`
}
Theme is the full set of colors hunk can paint with. Every field is a hex color string ("#rgb" or "#rrggbb"); the UI converts them to terminal colors.
func Decode ¶
Decode parses TOML on top of the default theme, so a file that specifies only a few keys is a valid theme: everything it leaves out is inherited.
Unknown keys are reported as warnings rather than failing the load — a typo should cost you one color, not your diff.
type UI ¶
type UI struct {
Background string `toml:"background"`
Foreground string `toml:"foreground"`
Border string `toml:"border"`
LineNumber string `toml:"line_number"`
FileHeader string `toml:"file_header"`
Accent string `toml:"accent"`
SidebarFg string `toml:"sidebar_fg"`
}
UI colors the frame: panes, headers, sidebar, status bar.
Accent is the one highlight color: every place hunk points at something — the @@ line, the current hunk, a change block's outline, the status bar, the selected file — is painted with it, so a theme changes its highlight once.