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 CommitToggleLineOffset(node BranchNodeData) int
- func EnsureVisible(startLine, endLine, scrollOffset, viewHeight int) int
- func FilesToggleLineOffset(node BranchNodeData) int
- 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 ArtDisplayWidth = 20
ArtDisplayWidth is the visual column width of each art line.
const HeaderHeight = 12
HeaderHeight is the total number of lines the header occupies.
const MinHeightForHeader = 25
MinHeightForHeader is the minimum terminal height to show the header.
const MinWidthForArt = 88
MinWidthForArt is the minimum width to show ASCII art in the header.
const MinWidthForHeader = 50
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(lipgloss.Color("14")).Bold(true) NormalBranchStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("15")) MergedBranchStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) TrunkStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8")).Italic(true) // Status indicators MergedIcon = lipgloss.NewStyle().Foreground(lipgloss.Color("5")).Render("✓") WarningIcon = lipgloss.NewStyle().Foreground(lipgloss.Color("3")).Render("⚠") OpenIcon = lipgloss.NewStyle().Foreground(lipgloss.Color("2")).Render("○") QueuedIcon = lipgloss.NewStyle().Foreground(lipgloss.Color("130")).Render("◎") // PR status styles PRLinkStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("15")).Underline(true) PROpenStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("2")) PRMergedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("5")) PRClosedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("1")) PRDraftStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) PRQueuedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("130")) // Diff stats AdditionsStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("2")) DeletionsStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("1")) // Commit lines CommitSHAStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("3")) CommitSubjectStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("15")) CommitTimeStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) // Connector lines ConnectorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) ConnectorDashedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("3")) ConnectorFocusedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("15")) ConnectorCurrentStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("14")) ConnectorMergedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("5")) ConnectorQueuedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("130")) // Dim text DimStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240")) // Header styles HeaderBorderStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) HeaderTitleStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("15")).Bold(true) HeaderInfoStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("14")) HeaderInfoLabelStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) HeaderShortcutKey = lipgloss.NewStyle().Foreground(lipgloss.Color("15")) HeaderShortcutDesc = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) // Expand/collapse icons ExpandedIcon = "▾" CollapsedIcon = "▸" )
var ArtLines = [10]string{
"⠀⠀⠀⠀⠀⠀⣀⣤⣤⣤⣤⣤⣤⣀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⣠⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣄⠀⠀⠀",
"⠀⢀⣼⣿⣿⠛⠛⠿⠿⠿⠿⠿⠿⠛⠛⣿⣿⣷⡀⠀",
"⠀⣾⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣷⡀",
"⢸⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⡇",
"⢸⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⡇",
"⠘⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⢀⣤⣿⣿⣿⣿⠇",
"⠀⠹⣿⣦⡈⠻⢿⠟⠀⠀⠀⠀⢻⣿⣿⣿⣿⣿⠏⠀",
"⠀⠀⠈⠻⣷⣤⣀⡀⠀⠀⠀⠀⢸⣿⣿⣿⡿⠃⠀⠀",
"⠀⠀⠀⠀⠈⠙⠻⠇⠀⠀⠀⠀⠸⠟⠛⠁⠀⠀⠀⠀",
}
ArtLines is the braille ASCII art for the View header.
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 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 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, showHeader, hasSeparators bool) ClickResult
HandleClick maps a screen click to a node action. nodes is the list of BranchNodeData in display order. showHeader indicates whether the header is visible. 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.