Documentation
¶
Overview ¶
Package tabs is a content-neutral ordered tab group and strip layout. Hosts own keys, labels, and values; this package does not know about files, issues, panes, or workspaces.
Index ¶
- Constants
- func VisibleRange(widths []int, active, maxWidth int) (start, end int, showLeft, showRight bool)
- type CloseResult
- type FitLabel
- type Group
- func (g Group[T]) ActiveItem() (Item[T], bool)
- func (g *Group[T]) Append(key string, value T)
- func (g *Group[T]) AppendItem(item Item[T])
- func (g *Group[T]) CloseActive() CloseResult[T]
- func (g *Group[T]) CloseAt(index int) CloseResult[T]
- func (g *Group[T]) CloseMatching(pred func(Item[T]) bool) CloseResult[T]
- func (g *Group[T]) Cycle(delta int)
- func (g Group[T]) Find(key string) int
- func (g *Group[T]) OpenOrFocus(key string, value T) (index int, created bool)
- func (g *Group[T]) Select(i int)
- func (g Group[T]) VisibleRange(widths []int, maxWidth int) (start, end int, showLeft, showRight bool)
- type Hit
- type Item
- type Label
- type Strip
Constants ¶
const MinBudget = 8
MinBudget is the floor for one tab's column share, chrome included.
Variables ¶
This section is empty.
Functions ¶
func VisibleRange ¶
VisibleRange is the inclusive [start, end] window of tabs that fit in maxWidth given their rendered widths, keeping the active tab visible. showLeft and showRight are the overflow markers for tabs outside the window.
Types ¶
type CloseResult ¶
CloseResult tells a host what CloseMatching removed so it can clean values and decide whether to load the survivor. The group does not know about tmux, file deletion, or preview reset.
type FitLabel ¶
FitLabel shortens a tab's text so the rendered pill fits in maxWidth. maxWidth is the label column budget (chrome already reserved). The function returns label text, not the painted tab.
type Group ¶
Group is an ordered tab set with one active index.
func (Group[T]) ActiveItem ¶
ActiveItem is the selected tab, or false when the group is empty or Active is out of range.
func (*Group[T]) AppendItem ¶
AppendItem always adds item and selects it.
func (*Group[T]) CloseActive ¶
func (g *Group[T]) CloseActive() CloseResult[T]
CloseActive removes the selected tab. An empty group leaves Active at 0.
func (*Group[T]) CloseAt ¶
func (g *Group[T]) CloseAt(index int) CloseResult[T]
CloseAt removes the tab at index. Out of range is a no-op.
func (*Group[T]) CloseMatching ¶
func (g *Group[T]) CloseMatching(pred func(Item[T]) bool) CloseResult[T]
CloseMatching removes every item for which pred is true. Removals before the original Active are counted once, then Active is clamped.
func (*Group[T]) Cycle ¶
Cycle moves Active by delta, wrapping at the ends. Fewer than two tabs is a no-op.
func (*Group[T]) OpenOrFocus ¶
OpenOrFocus selects the first item with key, or appends value and selects it.
type Hit ¶
Hit is a drawn tab's click target. Col is relative to the strip's first column; Width is the rendered pill.