Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyScrollToContent(content string, scrollOffset, viewHeight int) string
- func BrowserCmd(url string) *exec.Cmd
- func ClampScroll(totalLines, viewHeight, scrollOffset int) int
- func ClearLogo() string
- func CommitToggleLineOffset(node BranchNodeData) int
- func EnsureVisible(startLine, endLine, scrollOffset, viewHeight int) int
- func FilesToggleLineOffset(node BranchNodeData) int
- func HeaderHeightFor(cfg HeaderConfig) int
- func LogoAvailable() bool
- func NodeLineCount(node BranchNodeData) int
- func OpenBrowserInBackground(url string)
- func PRLabelColumns(node BranchNodeData) (int, int)
- func RenderBranchHeader(b *strings.Builder, node BranchNodeData, isFocused bool, ...)
- func RenderBranchLine(b *strings.Builder, node BranchNodeData, connector string, ...)
- func RenderCommits(b *strings.Builder, node BranchNodeData, connector string, ...)
- func RenderDiffStats(b *strings.Builder, node BranchNodeData)
- func RenderFiles(b *strings.Builder, node BranchNodeData, connector string, ...)
- func RenderHeader(b *strings.Builder, cfg HeaderConfig, width, height int)
- func RenderMergedSeparator(b *strings.Builder)
- func RenderNode(b *strings.Builder, node BranchNodeData, isFocused bool, width int, ...)
- func RenderPRHeader(b *strings.Builder, node BranchNodeData, isFocused bool, ...)
- func RenderQueuedSeparator(b *strings.Builder)
- func RenderTrunk(b *strings.Builder, trunkBranch string)
- func ResolveConnectorStyle(node BranchNodeData, isFocused bool) (string, lipgloss.Style)
- func ShouldShowHeader(width, height int) bool
- func ShouldShowShortcuts(width int) bool
- func StatusIcon(node BranchNodeData) string
- func TimeAgo(t time.Time) string
- type BranchNodeData
- type ClickResult
- type HeaderConfig
- type HeaderInfoLine
- type NodeAnnotation
- type ShortcutEntry
Constants ¶
const MinHeightForArt = 30
MinHeightForArt is the minimum terminal height to show the logo. It is a bit higher than MinHeightForHeader: at very short heights a vertical resize can leave a transient ghost of the inline image (kitty graphics live in a layer the text renderer can't repaint cleanly mid-resize), so the logo is dropped a little before the rest of the header to avoid the artifact.
const MinHeightForHeader = 25
MinHeightForHeader is the minimum terminal height to show the header.
const MinWidthForArt = 96
MinWidthForArt is the minimum width to show the logo in the header.
const MinWidthForHeader = 53
MinWidthForHeader is the minimum width to show the header at all.
const MinWidthForShortcuts = 65
MinWidthForShortcuts is the minimum width to show keyboard shortcuts.
Variables ¶
var ( // Branch name styles CurrentBranchStyle = lipgloss.NewStyle().Foreground(ColorAccent).Bold(true) NormalBranchStyle = lipgloss.NewStyle().Foreground(ColorText) MergedBranchStyle = lipgloss.NewStyle().Foreground(ColorTextMuted) TrunkStyle = lipgloss.NewStyle().Foreground(ColorTextMuted).Italic(true) // PR status styles PRLinkStyle = lipgloss.NewStyle().Foreground(ColorText).Underline(true) PROpenStyle = lipgloss.NewStyle().Foreground(ColorGreen) PRMergedStyle = lipgloss.NewStyle().Foreground(ColorPurple) PRClosedStyle = lipgloss.NewStyle().Foreground(ColorRed) PRDraftStyle = lipgloss.NewStyle().Foreground(ColorGray) PRQueuedStyle = lipgloss.NewStyle().Foreground(ColorYellow) // Diff stats AdditionsStyle = lipgloss.NewStyle().Foreground(ColorGreen) DeletionsStyle = lipgloss.NewStyle().Foreground(ColorRed) // Commit lines CommitSHAStyle = lipgloss.NewStyle().Foreground(ColorYellow) CommitSubjectStyle = lipgloss.NewStyle().Foreground(ColorText) CommitTimeStyle = lipgloss.NewStyle().Foreground(ColorTextMuted) // Connector lines ConnectorStyle = lipgloss.NewStyle().Foreground(ColorBorder) ConnectorDashedStyle = lipgloss.NewStyle().Foreground(ColorYellow) ConnectorFocusedStyle = lipgloss.NewStyle().Foreground(ColorText) ConnectorCurrentStyle = lipgloss.NewStyle().Foreground(ColorAccent) ConnectorMergedStyle = lipgloss.NewStyle().Foreground(ColorPurple) ConnectorQueuedStyle = lipgloss.NewStyle().Foreground(ColorYellow) // Dim text DimStyle = lipgloss.NewStyle().Foreground(ColorTextFaint) // Header styles HeaderBorderStyle = lipgloss.NewStyle().Foreground(ColorBorder) HeaderTitleStyle = lipgloss.NewStyle().Foreground(ColorText).Bold(true) HeaderInfoStyle = lipgloss.NewStyle().Foreground(ColorAccent) HeaderInfoLabelStyle = lipgloss.NewStyle().Foreground(ColorTextMuted) HeaderShortcutKey = lipgloss.NewStyle().Foreground(ColorText) HeaderShortcutDesc = lipgloss.NewStyle().Foreground(ColorTextMuted) // Expand/collapse icons ExpandedIcon = "▾" CollapsedIcon = "▸" )
var ( ColorText = theme.ColorText ColorTextMuted = theme.ColorTextMuted ColorTextFaint = theme.ColorTextFaint ColorBorder = theme.ColorBorder ColorRowShade = theme.ColorRowShade ColorAccent = theme.ColorAccent ColorBlue = theme.ColorBlue ColorGreen = theme.ColorGreen ColorGray = theme.ColorGray ColorYellow = theme.ColorYellow ColorPurple = theme.ColorPurple ColorRed = theme.ColorRed ColorOnFill = theme.ColorOnFill ColorButtonBg = theme.ColorButtonBg ColorButtonFg = theme.ColorButtonFg )
The background-aware color palette lives in internal/theme so it can be shared by both the TUIs and ordinary command output. These aliases keep the TUI code referring to shared.ColorX.
Functions ¶
func ApplyScrollToContent ¶
ApplyScrollToContent takes rendered content, splits into lines, applies scroll offset, and returns the visible portion as a string.
func BrowserCmd ¶
BrowserCmd returns an exec.Cmd to open a URL in the default browser.
func ClampScroll ¶
ClampScroll ensures scrollOffset doesn't exceed content bounds.
func ClearLogo ¶ added in v0.0.7
func ClearLogo() string
ClearLogo returns an escape that removes a previously-drawn logo. kitty graphics live in a layer the text renderer cannot clear, so callers must emit this when they stop drawing the header (e.g. the header is hidden) to keep the image from lingering. It returns "" when there is nothing to clear (iTerm2 images occupy text cells and are overwritten normally; no protocol => nothing).
func CommitToggleLineOffset ¶
func CommitToggleLineOffset(node BranchNodeData) int
CommitToggleLineOffset returns the line offset from node start to the commits toggle.
func EnsureVisible ¶
EnsureVisible adjusts scrollOffset so the cursor's line range is visible.
func FilesToggleLineOffset ¶
func FilesToggleLineOffset(node BranchNodeData) int
FilesToggleLineOffset returns the line offset from node start to the files toggle.
func HeaderHeightFor ¶ added in v0.0.7
func HeaderHeightFor(cfg HeaderConfig) int
HeaderHeightFor returns the number of screen lines the header occupies for the given config (its content rows plus the top and bottom borders).
func LogoAvailable ¶ added in v0.0.7
func LogoAvailable() bool
LogoAvailable reports whether the inline-image logo can be drawn (a supported protocol is detected on a real TTY outside tmux/screen). When false, the header shows no logo at all — there is no ASCII fallback.
func NodeLineCount ¶
func NodeLineCount(node BranchNodeData) int
NodeLineCount returns how many rendered lines a node occupies.
func OpenBrowserInBackground ¶
func OpenBrowserInBackground(url string)
OpenBrowserInBackground launches the system browser for the given URL.
func PRLabelColumns ¶
func PRLabelColumns(node BranchNodeData) (int, int)
PRLabelColumns returns the start and end X columns of the PR number label.
func RenderBranchHeader ¶
func RenderBranchHeader(b *strings.Builder, node BranchNodeData, isFocused bool, connStyle lipgloss.Style, annotation *NodeAnnotation)
RenderBranchHeader renders header when no PR exists: bullet + icon + branch + stats + annotation.
func RenderBranchLine ¶
func RenderBranchLine(b *strings.Builder, node BranchNodeData, connector string, connStyle lipgloss.Style, annotation *NodeAnnotation)
RenderBranchLine renders branch name + diff stats below a PR header.
func RenderCommits ¶
func RenderCommits(b *strings.Builder, node BranchNodeData, connector string, connStyle lipgloss.Style, width int)
RenderCommits renders the commits toggle and optionally expanded commits.
func RenderDiffStats ¶
func RenderDiffStats(b *strings.Builder, node BranchNodeData)
RenderDiffStats appends +N -N diff stats.
func RenderFiles ¶
func RenderFiles(b *strings.Builder, node BranchNodeData, connector string, connStyle lipgloss.Style, width int)
RenderFiles renders the files toggle and optionally expanded file list.
func RenderHeader ¶
func RenderHeader(b *strings.Builder, cfg HeaderConfig, width, height int)
RenderHeader renders the full-width header box. Progressive disclosure as width narrows: first hides the art, then the info text, keeping keyboard shortcuts always visible.
func RenderMergedSeparator ¶
RenderMergedSeparator renders the merged section separator.
func RenderNode ¶
func RenderNode(b *strings.Builder, node BranchNodeData, isFocused bool, width int, annotation *NodeAnnotation)
RenderNode renders a single branch node with all its sub-sections. annotation is optional — pass nil for plain view, or a NodeAnnotation to add a badge.
func RenderPRHeader ¶
func RenderPRHeader(b *strings.Builder, node BranchNodeData, isFocused bool, connStyle lipgloss.Style, annotation *NodeAnnotation)
RenderPRHeader renders the top line with PR info: bullet + status icon + PR# + state + optional annotation.
func RenderQueuedSeparator ¶
RenderQueuedSeparator renders the queued section separator.
func RenderTrunk ¶
RenderTrunk renders the trunk line.
func ResolveConnectorStyle ¶
func ResolveConnectorStyle(node BranchNodeData, isFocused bool) (string, lipgloss.Style)
ResolveConnectorStyle determines the connector character and style for a node.
func ShouldShowHeader ¶
ShouldShowHeader returns whether the header should be displayed.
func ShouldShowShortcuts ¶
ShouldShowShortcuts returns whether shortcuts should be displayed.
func StatusIcon ¶
func StatusIcon(node BranchNodeData) string
StatusIcon returns the appropriate status icon for a branch.
Types ¶
type BranchNodeData ¶
type BranchNodeData struct {
Ref stack.BranchRef
IsCurrent bool
IsLinear bool
BaseBranch string
Commits []git.CommitInfo
FilesChanged []git.FileDiffStat
PR *ghapi.PRDetails
Additions int
Deletions int
CommitsExpanded bool
FilesExpanded bool
// ShowCurrentLabel controls whether "(current)" is appended and cyan
// styling is used for the current branch. View sets this true; Modify
// leaves it false so all branches look uniform.
ShowCurrentLabel bool
// BranchNameStyleOverride, when non-nil, overrides the default branch
// name style. Used by Modify to render dropped branches in red
// strikethrough and folded branches in yellow strikethrough.
BranchNameStyleOverride *lipgloss.Style
// ForceDashedConnector, when true, forces the connector line to use
// the dashed style (┊) regardless of linearity. Used by Modify for
// branches marked for drop or fold.
ForceDashedConnector bool
// ConnectorStyleOverride, when non-nil, overrides the default connector
// color for dashed lines. Used to make drop connectors red and fold
// connectors yellow.
ConnectorStyleOverride *lipgloss.Style
}
BranchNodeData is the interface for branch data that can be rendered. Both stackview.BranchNode and modifyview.ModifyBranchNode satisfy this.
type ClickResult ¶
type ClickResult struct {
NodeIndex int // which node was clicked (-1 if none)
ToggleFiles bool // should toggle files expansion
ToggleCommits bool // should toggle commits expansion
OpenURL string // URL to open in browser (empty if none)
}
ClickResult describes what happened when a node was clicked.
func HandleClick ¶
func HandleClick(screenX, screenY int, nodes []BranchNodeData, width, height, scrollOffset int, headerHeight int, hasSeparators bool) ClickResult
HandleClick maps a screen click to a node action. nodes is the list of BranchNodeData in display order. headerHeight is the number of rows the header occupies (0 when it is hidden). scrollOffset is the current scroll position. hasSeparators controls whether merged/queued separator lines are accounted for.
type HeaderConfig ¶
type HeaderConfig struct {
ShowArt bool // whether to display GitHub logo
Title string // heading next to logo art
Subtitle string // version string, or empty
InfoLines []HeaderInfoLine // info rows (stack info)
Shortcuts []ShortcutEntry // keyboard shortcuts
ShortcutColumns int // number of columns for shortcuts (default 1; set 2 for side-by-side)
}
HeaderConfig controls what the header displays.
type HeaderInfoLine ¶
type HeaderInfoLine struct {
Icon string
Label string
IconStyle *lipgloss.Style // optional override; nil uses default HeaderInfoStyle (cyan)
}
HeaderInfoLine represents an info line in the header (icon + label).
type NodeAnnotation ¶
NodeAnnotation is an optional annotation to display after the branch info.
type ShortcutEntry ¶
type ShortcutEntry struct {
Key string
Desc string
Disabled bool // when true, rendered in gray (dimmed)
}
ShortcutEntry represents a keyboard shortcut for the header.