Archived
Replace the Pinned/Checkout/Tip rows and the list of commits between pin and tip with one line of history, newest on top: a node per commit with its roles (pin, tip, you, staged, HEAD) and the number of commits between two nodes. A staged pin shows the committed pin as its own node and notes when it moves back. All three on one commit read "in sync". Add Status.Drift, Committed and CommittedDrift and Status.Spine(); drop Status.Between and Repo.FetchedAt. The fetch age moves from the header to the detail pane (right-aligned in the name's line). The header summary is right-aligned, ordered by importance and cut with an ellipsis if too narrow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
71 lines
2.3 KiB
Go
71 lines
2.3 KiB
Go
// Package theme holds the colors, glyphs and shared styles for the TUI.
|
||
package theme
|
||
|
||
import (
|
||
"os"
|
||
|
||
"github.com/charmbracelet/lipgloss"
|
||
)
|
||
|
||
// Theme uses the 16 ANSI colors for everything that carries meaning, so
|
||
// the TUI follows the user's terminal color scheme. Only background shades
|
||
// and the dimmed backdrop, which have no ANSI equivalent, use adaptive
|
||
// 256-color values.
|
||
type Theme struct {
|
||
Primary lipgloss.TerminalColor // accent: branch names, commit hashes
|
||
Info lipgloss.TerminalColor
|
||
Added lipgloss.TerminalColor // added lines and files
|
||
Warn lipgloss.TerminalColor
|
||
Danger lipgloss.TerminalColor
|
||
Muted lipgloss.TerminalColor
|
||
Text lipgloss.TerminalColor
|
||
Border lipgloss.TerminalColor // pane separators, help separators
|
||
Bar lipgloss.TerminalColor // background of the header bar
|
||
Selected lipgloss.TerminalColor // background of the selected row
|
||
Backdrop lipgloss.TerminalColor // the screen behind a popup, dimmed
|
||
Glyphs Glyphs
|
||
}
|
||
|
||
func Default() Theme {
|
||
g := Unicode()
|
||
if os.Getenv("SUBMARINE_ASCII") != "" {
|
||
g = ASCII()
|
||
}
|
||
return Theme{
|
||
Primary: lipgloss.Color("6"), // cyan
|
||
Info: lipgloss.Color("4"), // blue
|
||
Added: lipgloss.Color("2"), // green
|
||
Warn: lipgloss.Color("3"), // yellow
|
||
Danger: lipgloss.Color("1"), // red
|
||
Muted: lipgloss.Color("8"), // bright black / grey
|
||
Text: lipgloss.NoColor{}, // terminal default foreground
|
||
Border: lipgloss.Color("8"),
|
||
Bar: lipgloss.AdaptiveColor{Light: "254", Dark: "235"},
|
||
Selected: lipgloss.AdaptiveColor{Light: "253", Dark: "237"},
|
||
Backdrop: lipgloss.AdaptiveColor{Light: "252", Dark: "238"},
|
||
Glyphs: g,
|
||
}
|
||
}
|
||
|
||
// Fg returns a style with the given foreground color.
|
||
func Fg(c lipgloss.TerminalColor) lipgloss.Style {
|
||
return lipgloss.NewStyle().Foreground(c)
|
||
}
|
||
|
||
// Glyphs are the few symbols used next to the state words.
|
||
type Glyphs struct {
|
||
Staged, Ahead, Behind, Collapsed, Expanded, Problems, Minus, From, Rule, Node, Gap string
|
||
}
|
||
|
||
func Unicode() Glyphs {
|
||
return Glyphs{
|
||
Staged: "●", Ahead: "↑", Behind: "↓", Collapsed: "▸", Expanded: "▾", Problems: "·", Minus: "−", From: "←", Rule: "─", Node: "●", Gap: "┊",
|
||
}
|
||
}
|
||
|
||
func ASCII() Glyphs {
|
||
return Glyphs{
|
||
Staged: "*", Ahead: "^", Behind: "v", Collapsed: ">", Expanded: "v", Problems: ".", Minus: "-", From: "<-", Rule: "-", Node: "o", Gap: ":",
|
||
}
|
||
}
|