Documentation
¶
Overview ¶
Package panecodec owns the projection between *state.PaneLayoutJSON and (contentpanes.State + live-leaf records).
Per-kind tab identity — tree shape, refs, scroll, unknown-kind collapse — already lives in contentpanes.Encode/Decode. This package maps the two vocabularies (kind names, split axis names, tab field names) and supplies the live-leaf persistence shape termpanes lacks: session name, leaf name, and the parent split's axis/ratio for Primary and Shell leaves.
PaneLayoutJSON uses kind terminal|shell|doc|issue|note|diff|resource and axis cols|rows. contentpanes.State uses primary|document|issue|note|diff| resource and axis columns|rows. "document" and "primary" are never written into PaneLayoutJSON. Session on a shell leaf is a tmux session name, never a pane id.
A shell node is represented in contentpanes.State as Kind "shell" so the tree round-trips through this package. contentpanes.Decode treats that as an unknown kind and drops it; hosts re-request the leaf from Live records.
Index ¶
Constants ¶
const ( KindTerminal = "terminal" KindShell = "shell" KindDoc = "doc" KindIssue = "issue" KindNote = "note" KindDiff = "diff" KindResource = "resource" )
Wire kind names for PaneLayoutJSON. These are the only spellings Encode writes.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
func Encode(st contentpanes.State, opts Options) *state.PaneLayoutJSON
Encode projects contentpanes.State plus live-leaf records onto PaneLayoutJSON. Empty content leaves (no tabs) are omitted the way encodePaneNode omitted them. Root, Surface, and Open are host policy and are left unset.
Types ¶
type Live ¶
type Live struct {
Kind string // KindTerminal or KindShell
Session string // tmux session name, never a pane id
Name string
// Axis and Ratio describe the parent split that placed this leaf, in
// PaneLayoutJSON vocabulary (cols/rows). They let a host re-splice a
// shell that contentpanes.Decode dropped.
Axis string
Ratio int
NewFirst bool
}
Live is the persistable identity of one live terminal leaf.
func Decode ¶
func Decode(layout *state.PaneLayoutJSON, opts Options) (contentpanes.State, []Live)
Decode projects PaneLayoutJSON onto contentpanes.State plus live-leaf records. Unknown kinds are preserved in State so contentpanes.Decode can drop them and collapse their splits. Legacy issue Issue/Scroll becomes a one-tab IssueTabs.
type Options ¶
type Options struct {
Live []Live
// AcceptTab, when set, is host-owned tab admission. Decode drops a tab
// for which it returns false. Nil admits every structurally valid tab.
AcceptTab func(kind string, tab contentpanes.TabState) bool
}
Options carries host-owned input the projection cannot invent. Encode reads Live to overlay session/name onto terminal and shell leaves. Decode uses AcceptTab for host target resolution (missing files, path escape) and returns the live-leaf records it extracted.