Help us shape the future of Go! Take the 2026 Go Developer Survey

splitpreview

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package splitpreview renders the read-only summary of a pending multi-way split, one row per tag with its destination and the amount of work assigned to it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DestinationSpec

type DestinationSpec struct {
	ChangeID    string
	Description string
	Type        DestinationType
}

DestinationSpec is where one tag's hunks land. ChangeID is empty for DestNewCommit, where Description becomes the message of the commit that gets created.

type DestinationType

type DestinationType int

DestinationType separates a destination that already exists from one that will be created.

const (
	DestExistingRevision DestinationType = iota
	DestNewCommit
)

Destinations a tag can be sent to. DestExistingRevision is the zero value, so a DestinationSpec that was never filled in reads as targeting an existing revision.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the preview modal. It only displays what the parent hands it and has no cursor of its own.

func New

func New() Model

New returns a hidden preview with no summaries.

func (*Model) Hide

func (m *Model) Hide()

Hide closes the preview.

func (*Model) IsVisible

func (m *Model) IsVisible() bool

IsVisible reports whether the preview is open, which is how the parent decides to route keys here.

func (*Model) SetSummaries

func (m *Model) SetSummaries(summaries []SplitSummary)

SetSummaries replaces the rows. The parent recomputes them, because the counts go stale as soon as a hunk's tag changes.

func (*Model) Show

func (m *Model) Show()

Show opens the preview.

func (Model) View

func (m Model) View(width, _ int) string

View renders the preview centered in the given terminal size, returning the empty string while hidden.

type SplitSummary

type SplitSummary struct {
	Destination DestinationSpec
	FileCount   int
	HunkCount   int
	Tag         SplitTag
}

SplitSummary is one row of the preview. FileCount and HunkCount are what the tag currently holds, so they are recomputed by the parent rather than tracked here.

type SplitTag

type SplitTag rune

SplitTag is the single character a hunk carries while a multi-way split is being assembled. It is declared here rather than shared with the parent model so this component imports nothing from it.

Jump to

Keyboard shortcuts

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