Documentation
¶
Overview ¶
Package panereposition owns the host-independent interaction state for repositioning a pane. Structural policy remains in panelayout; surfaces only provide their current tree, geometry, persistence, and user-visible notice.
Index ¶
- Constants
- func ApplyLeafGraft(fresh *panelayout.Node, graft LeafGraft, leaf *panelayout.Node) *panelayout.Node
- func ApplyLive(live *panelayout.Node, plan panelayout.MovePlan) (*panelayout.Node, int, string)
- func BoundaryReason(direction panelayout.Direction) string
- func ComposeHeader(tabsRow string, width int, closable, layoutHovered, closeHovered bool) string
- func ComposeMovableHeader(tabsRow string, width int, movable, closable, layoutHovered, closeHovered bool) string
- func Fingerprint(root *panelayout.Node) string
- func Movable(root *panelayout.Node) bool
- func Reason(reason string) string
- func TrialMove(live *panelayout.Node, plan panelayout.MovePlan) *panelayout.Node
- type CommitResult
- type Controller
- func (c *Controller) Commit(scope string, live *panelayout.Node, box panelayout.Box, ...) CommitResult
- func (c *Controller) Draft() *panelayout.Node
- func (c *Controller) HandleKey(msg tea.KeyPressMsg) (ModalResult, tea.Cmd)
- func (c *Controller) HandleMouse(msg tea.MouseMsg, handler *mouse.Handler) ModalResult
- func (c *Controller) LeafID() int
- func (c *Controller) Modal() *modal.Modal
- func (c *Controller) Render(width, height int, handler *mouse.Handler) string
- func (c *Controller) String() string
- func (c *Controller) Zoomed() bool
- type HeaderReserve
- type LeafGraft
- type ModalAction
- type ModalResult
- type Zoom
Constants ¶
const ( CommandMove = "move-pane" LayoutChangedReason = "the pane layout changed; try again" )
const (
ModalContext = "pane-reposition"
)
Variables ¶
This section is empty.
Functions ¶
func ApplyLeafGraft ¶
func ApplyLeafGraft(fresh *panelayout.Node, graft LeafGraft, leaf *panelayout.Node) *panelayout.Node
ApplyLeafGraft attaches the exact leaf object to fresh at its captured anchor/order/axis/ratio. If the passive projection removed the anchor, the whole fresh tree is the stable fallback, matching the existing Sessions behavior. Split identity is retained when it does not collide.
func ApplyLive ¶
func ApplyLive(live *panelayout.Node, plan panelayout.MovePlan) (*panelayout.Node, int, string)
ApplyLive installs one accepted plan on the LIVE tree and guarantees what the modal's replay guarantees for each of its steps: the moved leaf is the same *Node it was before, carrying the same ID, so host-owned terminal, deck, and tab state keyed by either identity travels with the pane instead of being rebuilt.
It exists so the agent verb and the modal cannot answer this differently. The modal replays a sequence and needs its own rollback; a single-call move needs exactly this. Both go through panelayout.ApplyMove, and neither host writes a structural edit of its own.
A non-empty reason means the live tree was not touched.
func BoundaryReason ¶
func BoundaryReason(direction panelayout.Direction) string
func ComposeHeader ¶
ComposeHeader joins an already-padded tab row to the controls described by ReserveHeader. Hover never changes their measured width.
func ComposeMovableHeader ¶
func ComposeMovableHeader(tabsRow string, width int, movable, closable, layoutHovered, closeHovered bool) string
ComposeMovableHeader is ComposeHeader for a header that may have no leaf to move. It must be given the same movable value its reserve was.
func Fingerprint ¶
func Fingerprint(root *panelayout.Node) string
Fingerprint is a deterministic structural generation for a pane tree. It changes for in-place rewrites as well as root replacement, while remaining stable across reads of the same tree.
func Movable ¶
func Movable(root *panelayout.Node) bool
Movable reports whether a leaf of this tree can be repositioned at all.
A tree with fewer than two leaves has nowhere to send one — PlanMove answers every destination on it with MoveUnchanged — and a surface drawing a pane header with no tree behind it has no leaf to move in the first place. Neither offers the control: a button that cannot act is a target the user aims at for nothing, and it makes the same header two different widths for a reason nothing on screen explains.
Each host asks this once per frame and passes the answer to both its header renderer and its region sink, so the drawn glyph and its hit box can never disagree.
func Reason ¶
Reason guarantees every refused/no-op path has something user-visible to say even if a future structural outcome forgets its explanatory copy.
func TrialMove ¶
func TrialMove(live *panelayout.Node, plan panelayout.MovePlan) *panelayout.Node
TrialMove answers what a plan would produce without touching the live tree. Hosts use it to ask a content deck whether it can adopt the result before the move is real, which is the same order the modal commits in.
Types ¶
type CommitResult ¶
CommitResult is an atomic replay result. Root is the original live root with source leaves grafted in place; the controller never returns its draft clone.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller owns one modal draft. It is presentation-neutral about the host: scope identifies the active surface, root identity catches replacement, and fingerprint catches in-place structural edits while the modal is open.
func NewController ¶
func NewController(scope string, root *panelayout.Node, leafID int, box panelayout.Box, floors panelayout.Floors, zoomed bool, title string) *Controller
NewController starts a detached draft for one live leaf.
func (*Controller) Commit ¶
func (c *Controller) Commit(scope string, live *panelayout.Node, box panelayout.Box, floors panelayout.Floors) CommitResult
Commit revalidates every accepted draft move against a fresh clone of the still-active live tree before touching the live nodes. A stale scope, tree replacement, in-place structural change, or newly refused step returns the original root untouched.
func (*Controller) Draft ¶
func (c *Controller) Draft() *panelayout.Node
func (*Controller) HandleKey ¶
func (c *Controller) HandleKey(msg tea.KeyPressMsg) (ModalResult, tea.Cmd)
HandleKey owns every key while the modal is open. Its custom movement keys are intercepted before modal.HandleKey so Enter always commits and Esc always discards, independent of which miniature cell the pointer last hovered.
func (*Controller) HandleMouse ¶
func (c *Controller) HandleMouse(msg tea.MouseMsg, handler *mouse.Handler) ModalResult
func (*Controller) LeafID ¶
func (c *Controller) LeafID() int
func (*Controller) Modal ¶
func (c *Controller) Modal() *modal.Modal
Modal exposes the declarative modal for wheel-boundary routing.
func (*Controller) Render ¶
func (c *Controller) Render(width, height int, handler *mouse.Handler) string
Render draws the declarative modal. Hosts overlay the result onto their own background so the controller never needs to know which surface owns it.
func (*Controller) String ¶
func (c *Controller) String() string
func (*Controller) Zoomed ¶
func (c *Controller) Zoomed() bool
type HeaderReserve ¶
type HeaderReserve struct {
TabsWidth int
LayoutCol int
LayoutW int
CloseCol int
CloseW int
Width int
}
HeaderReserve is the pane header's shared tab/layout/close geometry. The layout control is the first to drop as the pane narrows; close is retained until it cannot be drawn whole.
func ReserveHeader ¶
func ReserveHeader(width int, closable bool) HeaderReserve
ReserveHeader is the one feature-flag check for pane header chrome. Keymap availability is the other; hosts derive both painting and hit regions from this result instead of checking the flag independently.
It assumes the header belongs to a leaf that can be moved. A surface drawing a pane header with no pane tree behind it has nothing to reposition and must call ReserveMovableHeader with movable=false instead.
func ReserveMovableHeader ¶
func ReserveMovableHeader(width int, movable, closable bool) HeaderReserve
ReserveMovableHeader is ReserveHeader for a header that may have no leaf. A control that cannot act is worse than an absent one: it occupies a target the user will aim at, and it makes the same header two different widths for reasons nothing on screen explains.
type LeafGraft ¶
type LeafGraft struct {
LeafID int
AnchorID int
SplitID int
Axis panelayout.Axis
Ratio int
LeafFirst bool
}
LeafGraft records the exact split that attached a host-owned leaf to a passive tree. A content deck can replace the passive projection without knowing about that leaf; the host replays this record afterward.
func CaptureLeafGrafts ¶
func CaptureLeafGrafts(root *panelayout.Node, kind panelayout.Kind) []LeafGraft
CaptureLeafGrafts finds direct split attachments for leaves of kind.
type ModalAction ¶
type ModalAction int
ModalAction is a host-facing result from the shared reposition controller.
const ( ModalIdle ModalAction = iota ModalChanged ModalCommit ModalCancel )
type ModalResult ¶
type ModalResult struct {
Action ModalAction
Reason string
}
ModalResult separates modal lifecycle from a refused/no-op move. Reason is display-ready and never implies that the draft or live tree was mutated.