widget

package
v0.1.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package widget implements more complex user interface components on top of the primitives offered in the ui package.

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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 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) Err

func (b *BranchSplit) Err() error

Err returns nil.

func (*BranchSplit) Init

func (b *BranchSplit) Init() tea.Cmd

Init initializes 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 CommitSummary

type CommitSummary struct {
	ShortHash  git.Hash
	Subject    string
	AuthorDate time.Time
}

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

type CommitSummaryStyle struct {
	Hash    lipgloss.Style
	Subject lipgloss.Style
	Time    lipgloss.Style
}

CommitSummaryStyle is the style for rendering a CommitSummary.

func (CommitSummaryStyle) Faint

Faint returns a copy of the style with the faint attribute set to f.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL