This repository has been archived on 2026-10-25. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
submarine/internal/tui/theme/theme.go
T
Simon FrankenandClaude Opus 5.5 19c6f17eb2 Preview uncommitted changes in the detail pane
For a dirty submodule, list the changed files so the user can remember
what they were doing there:

  Changes   5 files · 2M 1A 1D 1R · +37 −12
            ──────────────────────────────────
            M  render.go  src/render/  +20 −4  3d ago
            ?  scratch.txt                     5m ago

- Status.Changes: files changed against HEAD (staged and unstaged
  combined) with kind, line counts and modification time; sorted by kind,
  then by size; capped at 200 with totals over all files.
- Git provider: parse `status --porcelain=v2 -z` and one
  `diff HEAD --numstat -z -M`, only for dirty submodules.
- Detail pane: flat list with a colored status letter per file, like IDE
  source-control views; counts and age in compact columns; up to 10 files,
  every kind keeps a line, the rest is summarized as "n more".
- Fixture gains libs/work with every kind of change; mock data extended.
- Docs: F24, change preview in the UX guide, D17.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 15:55:46 +02:00

68 lines
2.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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,
// 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
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"},
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 string
}
func Unicode() Glyphs {
return Glyphs{
Staged: "●", Ahead: "↑", Behind: "↓", Collapsed: "▸", Expanded: "▾", Problems: "·", Minus: "−", From: "←", Rule: "─",
}
}
func ASCII() Glyphs {
return Glyphs{
Staged: "*", Ahead: "^", Behind: "v", Collapsed: ">", Expanded: "v", Problems: ".", Minus: "-", From: "<-", Rule: "-",
}
}