Documentation
¶
Overview ¶
Package workspace implements a tab-referencing split tree. It owns geometry, not tab models or keyboard focus; callers supply the active tab identity.
Index ¶
- Constants
- type Arrangement
- type Axis
- type Direction
- type Layout
- func (l Layout) Arrange(width, height int) Arrangement
- func (l Layout) CanSplit(target string, axis Axis, width, height int) error
- func (l Layout) Contains(tab string) bool
- func (l Layout) Count() int
- func (l Layout) Cycle(tab string, step, width, height int) string
- func (l Layout) First() string
- func (l *Layout) Move(tab string, direction Direction, width, height int) bool
- func (l Layout) Neighbour(tab string, direction Direction, width, height int) string
- func (l Layout) PaneNumber(tab string) int
- func (l Layout) PaneOrder() []string
- func (l *Layout) Remove(tab string) string
- func (l *Layout) Resize(tab string, axis Axis, steps, width, height int) bool
- func (l Layout) Revision() uint64
- func (l *Layout) Select(target, tab string) bool
- func (l Layout) Snapshot(focus string, refs map[string]string) State
- func (l *Layout) Split(target, tab string, axis Axis, width, height int) error
- func (l Layout) SplitAxis(tab string) Axis
- func (l *Layout) Swap(tab string, direction Direction, width, height int) bool
- type Node
- type Pane
- type Rect
- type State
Constants ¶
const ( MinWidth = 24 MinHeight = 8 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arrangement ¶
Arrangement uses virtual minimum-sized bounds when Fits is false. This lets callers navigate the whole layout while drawing only their focused pane.
type Layout ¶
type Layout struct {
// contains filtered or unexported fields
}
Layout's zero value is an empty workspace. It deliberately has no active-tab field: the tab registry remains the single source of truth for activation.
func Restore ¶
Restore validates and copies a serialized tree, pruning missing/duplicate tab references and collapsing empty branches. It never changes the caller's tabs. Cyclic/aliased node graphs are pruned without imposing a pane/depth cap. Version 1 binary splits are migrated to sibling containers with the same ratio.
func (Layout) Arrange ¶
func (l Layout) Arrange(width, height int) Arrangement
Arrange allocates every cell exactly once, including one-cell dividers. Terminal resizing never rewrites preferred proportions.
func (Layout) CanSplit ¶
CanSplit checks a prospective split before asking the user to select a tab.
func (*Layout) Move ¶
Move is i3-like directional movement. A pane first swaps contents with its nearest neighbour. At the edge of a nested container it moves one level up the tree: it leaves its container and becomes a sibling of that container in the container above, on the requested side.
At the root there is no container above, so the pane cannot lift. There the previous re-dock is kept: the rest of the layout becomes one half of a new root split and the pane the other half, which is how a row becomes a stack (or the reverse). i3 itself refuses that move; changing the root's orientation is worth keeping.
func (Layout) Neighbour ¶
Neighbour prefers the closest edge sharing the requested direction, then the closest perpendicular centre. Reading order is the deterministic tie-breaker.
func (Layout) PaneNumber ¶
PaneNumber returns the 1-based tree/reading order index used by both tab badges and pane headers, or 0 when the tab is not assigned.
func (Layout) PaneOrder ¶
PaneOrder returns assigned tabs in the same tree order as PaneNumber/Arrange.
func (*Layout) Remove ¶
Remove drops the pane and collapses a container that is left with one child. It returns the tab that should take focus, which the caller uses only when it removed the focused pane.
func (*Layout) Resize ¶
Resize moves the divider next to the focused pane by five-percent steps. Positive steps grow the focused child, even when it is not the first child of the container. It edits the deepest matching container on the pane's path.
func (*Layout) Select ¶
Select assigns an unassigned tab to the target pane, or creates the initial pane. An already assigned tab is left alone; its activation is the caller's job.
func (*Layout) Split ¶
Split is atomic, including fit validation. It never creates an empty pane. A pane whose container already splits along axis joins it as an equal sibling (i3's container list); otherwise the target is wrapped in a new container.
type Node ¶
type Node struct {
Tab string `json:"tab,omitempty"`
Axis Axis `json:"axis,omitempty"`
Children []*Node `json:"children,omitempty"`
Weights []int `json:"weights,omitempty"`
// Deprecated: version 1 layout fields, decode-only.
Ratio int `json:"ratio,omitempty"`
First *Node `json:"first,omitempty"`
Second *Node `json:"second,omitempty"`
}
Node is a serialized tree node: either a leaf (Tab) or a container (Axis with Children, one weight per child). Like i3, a container is a list of siblings, so adding a pane next to an existing one never deepens the tree.
Ratio, First and Second are the version 1 binary-split fields. They are only read to migrate old sessions and are never written.