Documentation ¶
Overview ¶
Package widget implements more complex user interface components on top of the primitives offered in the ui package.
Index ¶
- Variables
- type BranchSelectKeyMap
- type BranchSplit
- func (b *BranchSplit) Description() string
- func (b *BranchSplit) Err() error
- func (b *BranchSplit) Init() tea.Cmd
- func (b *BranchSplit) Render(w ui.Writer)
- func (b *BranchSplit) Selected() []int
- func (b *BranchSplit) Title() string
- func (b *BranchSplit) Update(msg tea.Msg) tea.Cmd
- func (b *BranchSplit) WithCommits(commits ...CommitSummary) *BranchSplit
- func (b *BranchSplit) WithDescription(desc string) *BranchSplit
- func (b *BranchSplit) WithHEAD(head string) *BranchSplit
- func (b *BranchSplit) WithTitle(title string) *BranchSplit
- type BranchSplitStyle
- type BranchTreeItem
- type BranchTreeSelect
- func (b *BranchTreeSelect) Description() string
- func (b *BranchTreeSelect) Err() error
- func (b *BranchTreeSelect) Init() tea.Cmd
- func (b *BranchTreeSelect) Render(w ui.Writer)
- func (b *BranchTreeSelect) Title() string
- func (b *BranchTreeSelect) Update(msg tea.Msg) tea.Cmd
- func (b *BranchTreeSelect) Value() string
- func (b *BranchTreeSelect) WithDescription(description string) *BranchTreeSelect
- func (b *BranchTreeSelect) WithItems(items ...BranchTreeItem) *BranchTreeSelect
- func (b *BranchTreeSelect) WithTitle(title string) *BranchTreeSelect
- func (b *BranchTreeSelect) WithValue(value *string) *BranchTreeSelect
- type BranchTreeSelectStyle
- type CommitSummary
- type CommitSummaryStyle
Constants ¶
This section is empty.
Variables ¶
var DefaultBranchSelectKeyMap = BranchSelectKeyMap{ Up: key.NewBinding( key.WithKeys("up"), key.WithHelp("up", "go up"), ), Down: key.NewBinding( key.WithKeys("down"), key.WithHelp("down", "go down"), ), Accept: key.NewBinding( key.WithKeys("enter", "tab"), key.WithHelp("enter/tab", "accept"), ), Delete: key.NewBinding( key.WithKeys("backspace", "ctrl+h"), key.WithHelp("backspace", "delete filter character"), ), }
DefaultBranchSelectKeyMap is the default key map for a [Select].
var DefaultBranchSplitStyle = BranchSplitStyle{ Commit: DefaultCommitSummaryStyle, HeadCommit: DefaultCommitSummaryStyle.Faint(true), SplitMarker: ui.NewStyle().SetString("□"), HeadMarker: ui.NewStyle().SetString("■"), }
DefaultBranchSplitStyle is the default style for a BranchSplit.
var DefaultBranchTreeSelectStyle = BranchTreeSelectStyle{ Name: ui.NewStyle(), SelectedName: ui.NewStyle().Bold(true).Foreground(ui.Yellow), DisabedName: ui.NewStyle().Foreground(ui.Gray), HighlightedName: ui.NewStyle().Foreground(ui.Cyan), Marker: ui.NewStyle().Foreground(ui.Yellow).Bold(true).SetString("◀"), }
DefaultBranchTreeSelectStyle is the default style for a BranchTreeSelect widget.
var DefaultCommitSummaryStyle = CommitSummaryStyle{ Hash: ui.NewStyle().Foreground(ui.Yellow), Subject: ui.NewStyle().Foreground(ui.Plain), Time: ui.NewStyle().Foreground(ui.Gray), }
DefaultCommitSummaryStyle is the default style for rendering a CommitSummary.
Functions ¶
This section is empty.
Types ¶
type BranchSelectKeyMap ¶
type BranchSelectKeyMap struct { Up key.Binding // move up the list Down key.Binding // move down the list Accept key.Binding // accept the focused option Delete key.Binding // delete the last character in the filter }
BranchSelectKeyMap defines the key bindings for [Select].
type BranchSplit ¶
type BranchSplit struct { Style BranchSplitStyle // contains filtered or unexported fields }
BranchSplit is a widget that allows users to pick out commits to split from the current branch.
It displays a list of commits, the last of which is not selectable.
func NewBranchSplit ¶
func NewBranchSplit() *BranchSplit
NewBranchSplit creates a new BranchSplit widget.
func (*BranchSplit) Description ¶
func (b *BranchSplit) Description() string
Description returns the description of the widget.
func (*BranchSplit) Render ¶
func (b *BranchSplit) Render(w ui.Writer)
Render renders the widget to the given writer.
func (*BranchSplit) Selected ¶
func (b *BranchSplit) Selected() []int
Selected returns the indexes of the selected commits.
func (*BranchSplit) Title ¶
func (b *BranchSplit) Title() string
Title returns the title of the widget.
func (*BranchSplit) Update ¶
func (b *BranchSplit) Update(msg tea.Msg) tea.Cmd
Update updates the widget based on the message.
func (*BranchSplit) WithCommits ¶
func (b *BranchSplit) WithCommits(commits ...CommitSummary) *BranchSplit
WithCommits sets the commits to be listed in a branch split widget.
func (*BranchSplit) WithDescription ¶
func (b *BranchSplit) WithDescription(desc string) *BranchSplit
WithDescription sets the description of the widget.
func (*BranchSplit) WithHEAD ¶
func (b *BranchSplit) WithHEAD(head string) *BranchSplit
WithHEAD sets the name of the head commit: the last commit in the branch. This name, if present, is shown next to the head commit.
func (*BranchSplit) WithTitle ¶
func (b *BranchSplit) WithTitle(title string) *BranchSplit
WithTitle sets the title of the widget.
type BranchSplitStyle ¶
type BranchSplitStyle struct { Commit CommitSummaryStyle HeadCommit CommitSummaryStyle SplitMarker lipgloss.Style HeadMarker lipgloss.Style }
BranchSplitStyle defines the styles for BranchSplit.
type BranchTreeItem ¶
type BranchTreeItem struct { // Branch is the name of the branch. Branch string // Base is the name of the branch this branch is on top of. // This will be used to create a tree view of branches. // Branches with no base are considered root branches. Base string // Disabled indicates that this branch cannot be selected. // It will appear grayed out in the list. Disabled bool }
BranchTreeItem is a single item in a BranchTreeSelect.
type BranchTreeSelect ¶
type BranchTreeSelect struct { Style BranchTreeSelectStyle KeyMap BranchSelectKeyMap // contains filtered or unexported fields }
BranchTreeSelect is a prompt that allows selecting a branch from a tree-view of branches. The trunk branch is shown at the bottom of the tree similarly to 'gs ls'.
In addition to arrow-based navigation, it allows fuzzy filtering branches by typing the branch name.
func NewBranchTreeSelect ¶
func NewBranchTreeSelect() *BranchTreeSelect
NewBranchTreeSelect creates a new BranchTreeSelect widget.
func (*BranchTreeSelect) Description ¶
func (b *BranchTreeSelect) Description() string
Description returns the description of the widget.
func (*BranchTreeSelect) Err ¶
func (b *BranchTreeSelect) Err() error
Err reports any errors in the current state of the widget.
func (*BranchTreeSelect) Init ¶
func (b *BranchTreeSelect) Init() tea.Cmd
Init initializes the widget.
func (*BranchTreeSelect) Render ¶
func (b *BranchTreeSelect) Render(w ui.Writer)
Render renders the widget.
func (*BranchTreeSelect) Title ¶
func (b *BranchTreeSelect) Title() string
Title returns the title of the widget.
func (*BranchTreeSelect) Update ¶
func (b *BranchTreeSelect) Update(msg tea.Msg) tea.Cmd
Update updates the state of the widget based on a bubbletea message.
func (*BranchTreeSelect) Value ¶
func (b *BranchTreeSelect) Value() string
Value returns the selected branch name.
func (*BranchTreeSelect) WithDescription ¶
func (b *BranchTreeSelect) WithDescription(description string) *BranchTreeSelect
WithDescription sets the description of the widget.
func (*BranchTreeSelect) WithItems ¶
func (b *BranchTreeSelect) WithItems(items ...BranchTreeItem) *BranchTreeSelect
WithItems adds a branch and its base to the widget with the given base. The named branch can be selected, but the base cannot.
func (*BranchTreeSelect) WithTitle ¶
func (b *BranchTreeSelect) WithTitle(title string) *BranchTreeSelect
WithTitle sets the title of the widget.
func (*BranchTreeSelect) WithValue ¶
func (b *BranchTreeSelect) WithValue(value *string) *BranchTreeSelect
WithValue specifies the destination for the selected branch. If the existing value matches a branch name, it will be selected.
type BranchTreeSelectStyle ¶
type BranchTreeSelectStyle struct { Name lipgloss.Style DisabedName lipgloss.Style SelectedName lipgloss.Style HighlightedName lipgloss.Style Marker lipgloss.Style }
BranchTreeSelectStyle defines the styling for a BranchTreeSelect widget.
type CommitSummary ¶
CommitSummary is the summary of a single commit.
func (*CommitSummary) Render ¶
func (c *CommitSummary) Render(w ui.Writer, style CommitSummaryStyle)
Render renders a CommitSummary to the given writer.
type CommitSummaryStyle ¶
CommitSummaryStyle is the style for rendering a CommitSummary.
func (CommitSummaryStyle) Faint ¶
func (s CommitSummaryStyle) Faint(f bool) CommitSummaryStyle
Faint returns a copy of the style with the faint attribute set to f.