Documentation
¶
Overview ¶
Package layout keeps SSHYard's workspace: tabs, each a tree of split panes, each pane showing one item. An item is of a kind: a terminal session, a files (SFTP) browser, an editor of a remote file, an AI assistant, a remote desktop, or a tool on the sessions (the broadcast, the session logs, the snippets, the command history, the system monitor, the process usage, the host's details, Docker, tmux). All are panes alike, so any of them can sit in any split cell, be dragged onto another pane's edge, be focused and closed. An item lives in exactly one pane; moving it (by drag and drop) takes it out of its old pane. Item IDs are unique across kinds.
Index ¶
- type Axis
- type Edge
- type Item
- type Kind
- type Node
- type Tab
- type Workspace
- func (w *Workspace) Activate(id int) bool
- func (w *Workspace) ActiveTab() *Tab
- func (w *Workspace) AddTab(root *Node, focus int)
- func (w *Workspace) AdoptTab(t *Tab) bool
- func (w *Workspace) Close(id int) bool
- func (w *Workspace) CloseTab(tabID int) []Item
- func (w *Workspace) Detach(id int) bool
- func (w *Workspace) FreshID() int
- func (w *Workspace) Items() []Item
- func (w *Workspace) Locate(id int) (*Tab, *Node)
- func (w *Workspace) Move(id, targetPane int, edge Edge) bool
- func (w *Workspace) MoveTab(tabID, target int, after bool) bool
- func (w *Workspace) Open(item Item) *Tab
- func (w *Workspace) Place(item Item, targetPane int, edge Edge) bool
- func (w *Workspace) Replace(old int, item Item) bool
- func (w *Workspace) Sibling() *Workspace
- func (w *Workspace) SplitFocused(axis Axis, item Item) *Node
- func (w *Workspace) TabOf(pane int) *Tab
- func (w *Workspace) Take(id int) (Item, bool)
- func (w *Workspace) TakeTab(tabID int) *Tab
- func (w *Workspace) Ungroup(tabID int) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kind ¶
type Kind int
Kind is what a pane shows.
const ( // Terminal is a terminal session. Terminal Kind = iota // Files is a files (SFTP) browser. Files // Editor edits a remote file. Editor // AI is an assistant bound to one host. It does not open a connection. AI // Broadcast sends a command to several terminals; Logs keeps their // session logs; Snippets and History send saved and past commands to // the focused terminal; Monitor, Usage, HostInfo, Docker and Tmux show // and work on the focused session's host. None is bound to a host. Broadcast Logs Snippets History Monitor Usage HostInfo Docker Tmux // Desktop is a remote desktop (RDP) session, the one pane an RDP host // opens. Desktop )
type Tab ¶
type Tab struct {
ID int
Root *Node
Focus int // the focused pane
// Title is the name the user gave the tab, "" for its host's.
Title string
// Color is the name of the tint the user gave the tab (the theme's
// tint names), "" for none.
Color string
}
Tab is one tab of the workspace.
type Workspace ¶
type Workspace struct {
Tabs []*Tab
Active int // index into Tabs, -1 when empty
// contains filtered or unexported fields
}
Workspace is the set of tabs of one window. Workspaces made with Sibling share their IDs, so a tab or a pane moves from one to another (TakeTab, AdoptTab, Take) without clashing with the IDs there.
func (*Workspace) AddTab ¶
AddTab appends a tab whose root the caller built with FreshID, and shows it. focus is a pane id in root; an unknown focus lands on the first pane.
func (*Workspace) AdoptTab ¶ added in v1.8.0
AdoptTab adds a tab taken from a Sibling (TakeTab) at the end, and shows it. A tab that is already here, or holds no pane, is left.
func (*Workspace) Detach ¶
Detach moves an item out to a tab of its own, just after the tab it leaves, and shows it.
func (*Workspace) Move ¶
Move drops an item on a pane: at the Center the two items swap places; at an edge the target pane splits and the item takes the new half. The item leaves its old pane, and a tab left empty closes. Kinds mix freely.
func (*Workspace) MoveTab ¶ added in v0.0.18
MoveTab puts the tab of ID tabID before the tab of ID target, or after it, and keeps the shown tab shown. It reports whether the order changed.
func (*Workspace) Place ¶
Place puts an item that is in no pane yet on a pane: at an edge the pane splits and the item takes the new half; at the Center it takes the pane, and the item it showed moves out to a tab of its own, so that nothing is lost.
func (*Workspace) Replace ¶
Replace shows item, which is in no pane yet, in the pane showing the item with ID old, which leaves the workspace. The pane is focused.
func (*Workspace) Sibling ¶ added in v1.8.0
Sibling makes an empty workspace whose IDs never clash with w's, for another window.
func (*Workspace) SplitFocused ¶
SplitFocused splits the active tab's focused pane, showing item in the new pane (right of or below it), and focuses the new pane. With no tab it opens one.
func (*Workspace) Take ¶ added in v1.8.0
Take takes the pane showing the item with ID id out of its tab, as Close does, and returns the item, to Open or Place it on a Sibling.
func (*Workspace) TakeTab ¶ added in v1.8.0
TakeTab takes the tab of ID tabID out of the workspace, its items still in it, for AdoptTab on a Sibling; nil when there is none.
func (*Workspace) Ungroup ¶ added in v1.8.0
Ungroup splits the tab of ID tabID into a tab for each of its panes, in reading order: the first keeps the tab, with its name and color, and the others follow it. The tab of the pane that was focused is shown. It reports whether the tab had more than one pane.