Documentation
¶
Index ¶
- Constants
- Variables
- type Manager
- func (m *Manager) Collapse(pane int, noSelect bool) error
- func (m *Manager) Enter(minPanes int) error
- func (m *Manager) Exit() error
- func (m *Manager) Expand(pane int, noSelect bool) error
- func (m *Manager) GetStatus() (*Status, error)
- func (m *Manager) IsStackMode() (bool, error)
- func (m *Manager) JumpTo(pane int, tmuxArgs []string) error
- func (m *Manager) Move(direction string) error
- func (m *Manager) New(args []string) error
- func (m *Manager) Next(tmuxArgs []string) error
- func (m *Manager) Prev(tmuxArgs []string) error
- func (m *Manager) PrintStatus(w io.Writer, asJSON bool) error
- func (m *Manager) SetStackMode(enabled bool) error
- func (m *Manager) SetStderr(w io.Writer)
- func (m *Manager) SetTitle(title string) error
- func (m *Manager) Toggle() error
- type MockTmuxClient
- func (m *MockTmuxClient) DisplayMessage(message string) error
- func (m *MockTmuxClient) GetCurrentPane() (int, error)
- func (m *MockTmuxClient) GetEnvironment(key string) (string, error)
- func (m *MockTmuxClient) GetPaneCount() (int, error)
- func (m *MockTmuxClient) GetWindowLayout() (string, error)
- func (m *MockTmuxClient) ListPanes() ([]Pane, error)
- func (m *MockTmuxClient) ResizePane(index int, height string) error
- func (m *MockTmuxClient) SelectLayout(layout string) error
- func (m *MockTmuxClient) SelectPane(index int, args []string) error
- func (m *MockTmuxClient) SetEnvironment(key, value string) error
- func (m *MockTmuxClient) SetPaneTitle(title string) error
- func (m *MockTmuxClient) SplitWindow(args []string) error
- func (m *MockTmuxClient) SwapPane(direction string) error
- type Pane
- type PaneStatus
- type RealTmuxClient
- func (c *RealTmuxClient) DisplayMessage(message string) error
- func (c *RealTmuxClient) GetCurrentPane() (int, error)
- func (c *RealTmuxClient) GetEnvironment(key string) (string, error)
- func (c *RealTmuxClient) GetPaneCount() (int, error)
- func (c *RealTmuxClient) GetWindowLayout() (string, error)
- func (c *RealTmuxClient) ListPanes() ([]Pane, error)
- func (c *RealTmuxClient) ResizePane(index int, height string) error
- func (c *RealTmuxClient) SelectLayout(layout string) error
- func (c *RealTmuxClient) SelectPane(index int, args []string) error
- func (c *RealTmuxClient) SetEnvironment(key, value string) error
- func (c *RealTmuxClient) SetPaneTitle(title string) error
- func (c *RealTmuxClient) SplitWindow(splitArgs []string) error
- func (c *RealTmuxClient) SwapPane(direction string) error
- type ResizePaneCall
- type SelectPaneCall
- type SetEnvCall
- type Status
- type TmuxClient
Constants ¶
const ( // EnvStackMode stores whether stack mode is active ("on" or "off"). EnvStackMode = "TMUX_STACK_MODE" // EnvPreviousLayout stores the window layout before entering stack mode. EnvPreviousLayout = "TMUX_STACK_LAYOUT" // CollapsedHeight is the height of collapsed panes (1 line). CollapsedHeight = "1" // ExpandedHeight is the percentage height of the expanded pane. ExpandedHeight = "95%" // StackModeOn indicates stack mode is active. StackModeOn = "on" // StackModeOff indicates stack mode is inactive. StackModeOff = "off" )
Variables ¶
var ErrStackModeOff = errors.New("stack mode off")
ErrStackModeOff is returned when stack mode is off and a quiet check is requested. Used by the status -q command to return exit code 1 without printing an error.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles stack operations.
func NewWithClient ¶
func NewWithClient(tmux TmuxClient) *Manager
NewWithClient creates a new stack Manager with a custom tmux client. Useful for testing.
func (*Manager) Collapse ¶
Collapse collapses the specified pane to 1 line. If pane is -1, collapses the current pane. If noSelect is false, selects the pane before collapsing.
func (*Manager) Enter ¶ added in v0.25.0
Enter enters stack mode. If minPanes > 0, ensures at least that many panes exist. Does nothing if already in stack mode.
func (*Manager) Exit ¶
Exit exits stack mode and restores the previous layout. Does nothing if not in stack mode.
func (*Manager) Expand ¶
Expand expands the specified pane. If pane is -1, expands the current pane. If noSelect is false, selects the pane before expanding. In stack mode, collapses all other panes. Outside stack mode, just resizes the pane to 95%.
func (*Manager) IsStackMode ¶
IsStackMode returns true if stack mode is currently active.
func (*Manager) JumpTo ¶ added in v0.25.0
JumpTo jumps to the specified pane. tmuxArgs are passed to the select-pane command (e.g., "-Z" to keep zoom). In stack mode, also applies the stack layout. If the pane doesn't exist, warns and jumps to the last pane.
func (*Manager) Move ¶
Move moves the current pane up or down in the stack. Direction should be "up" or "down". Does nothing silently if at boundary. In stack mode, re-applies the stack layout after moving.
func (*Manager) New ¶ added in v0.25.0
New adds a new pane with optional split-window arguments. In stack mode, applies the stack layout after creating the pane. Outside stack mode, just splits the window.
func (*Manager) Next ¶
Next moves to the next pane. tmuxArgs are passed to the select-pane command (e.g., "-Z" to keep zoom). In stack mode, also applies the stack layout. Does nothing silently if already at the last pane (no wrapping).
func (*Manager) Prev ¶
Prev moves to the previous pane. tmuxArgs are passed to the select-pane command (e.g., "-Z" to keep zoom). In stack mode, also applies the stack layout. Does nothing silently if already at the first pane (no wrapping).
func (*Manager) PrintStatus ¶
PrintStatus prints the current stack status to the given writer.
func (*Manager) SetStackMode ¶
SetStackMode enables or disables stack mode.
type MockTmuxClient ¶
type MockTmuxClient struct {
// Panes to return from ListPanes
Panes []Pane
// CurrentPane to return from GetCurrentPane
CurrentPane int
// WindowLayout to return from GetWindowLayout
WindowLayout string
// Environment variables
Environment map[string]string
// Track calls for verification
SelectPaneCalls []SelectPaneCall
ResizePaneCalls []ResizePaneCall
SplitWindowCalls [][]string
SwapPaneCalls []string
SetTitleCalls []string
SelectLayoutCalls []string
SetEnvCalls []SetEnvCall
DisplayMessageCalls []string
// Errors to return
ListPanesErr error
GetCurrentPaneErr error
SelectPaneErr error
ResizePaneErr error
SplitWindowErr error
SwapPaneErr error
SetTitleErr error
SelectLayoutErr error
GetLayoutErr error
GetEnvErr error
SetEnvErr error
DisplayMessageErr error
}
MockTmuxClient is a mock implementation of TmuxClient for testing.
func NewMockTmuxClient ¶
func NewMockTmuxClient() *MockTmuxClient
NewMockTmuxClient creates a new MockTmuxClient.
func (*MockTmuxClient) DisplayMessage ¶ added in v0.25.1
func (m *MockTmuxClient) DisplayMessage(message string) error
DisplayMessage records the call.
func (*MockTmuxClient) GetCurrentPane ¶
func (m *MockTmuxClient) GetCurrentPane() (int, error)
GetCurrentPane returns the configured current pane.
func (*MockTmuxClient) GetEnvironment ¶
func (m *MockTmuxClient) GetEnvironment(key string) (string, error)
GetEnvironment returns the value from the Environment map.
func (*MockTmuxClient) GetPaneCount ¶
func (m *MockTmuxClient) GetPaneCount() (int, error)
GetPaneCount returns the number of configured panes.
func (*MockTmuxClient) GetWindowLayout ¶
func (m *MockTmuxClient) GetWindowLayout() (string, error)
GetWindowLayout returns the configured layout.
func (*MockTmuxClient) ListPanes ¶
func (m *MockTmuxClient) ListPanes() ([]Pane, error)
ListPanes returns the configured panes.
func (*MockTmuxClient) ResizePane ¶
func (m *MockTmuxClient) ResizePane(index int, height string) error
ResizePane records the call.
func (*MockTmuxClient) SelectLayout ¶
func (m *MockTmuxClient) SelectLayout(layout string) error
SelectLayout records the call.
func (*MockTmuxClient) SelectPane ¶
func (m *MockTmuxClient) SelectPane(index int, args []string) error
SelectPane records the call and updates CurrentPane.
func (*MockTmuxClient) SetEnvironment ¶
func (m *MockTmuxClient) SetEnvironment(key, value string) error
SetEnvironment records the call and updates the Environment map.
func (*MockTmuxClient) SetPaneTitle ¶
func (m *MockTmuxClient) SetPaneTitle(title string) error
SetPaneTitle records the call.
func (*MockTmuxClient) SplitWindow ¶
func (m *MockTmuxClient) SplitWindow(args []string) error
SplitWindow records the call and adds a new pane.
func (*MockTmuxClient) SwapPane ¶
func (m *MockTmuxClient) SwapPane(direction string) error
SwapPane records the call.
type PaneStatus ¶
type PaneStatus struct {
Index int `json:"index"`
Height int `json:"height"`
Title string `json:"title"`
Active bool `json:"active"`
Collapsed bool `json:"collapsed"`
Command string `json:"command,omitempty"`
}
PaneStatus represents a pane's status for reporting.
type RealTmuxClient ¶
type RealTmuxClient struct{}
RealTmuxClient implements TmuxClient using actual tmux commands.
func NewTmuxClient ¶
func NewTmuxClient() *RealTmuxClient
NewTmuxClient creates a new RealTmuxClient.
func (*RealTmuxClient) DisplayMessage ¶ added in v0.25.1
func (c *RealTmuxClient) DisplayMessage(message string) error
DisplayMessage displays a message in the tmux status line.
func (*RealTmuxClient) GetCurrentPane ¶
func (c *RealTmuxClient) GetCurrentPane() (int, error)
GetCurrentPane returns the index of the currently active pane.
func (*RealTmuxClient) GetEnvironment ¶
func (c *RealTmuxClient) GetEnvironment(key string) (string, error)
GetEnvironment retrieves the value of a tmux environment variable. Returns empty string if the variable is not set.
func (*RealTmuxClient) GetPaneCount ¶
func (c *RealTmuxClient) GetPaneCount() (int, error)
GetPaneCount returns the number of panes in the current window.
func (*RealTmuxClient) GetWindowLayout ¶
func (c *RealTmuxClient) GetWindowLayout() (string, error)
GetWindowLayout returns the current window's layout string.
func (*RealTmuxClient) ListPanes ¶
func (c *RealTmuxClient) ListPanes() ([]Pane, error)
ListPanes returns all panes in the current window.
func (*RealTmuxClient) ResizePane ¶
func (c *RealTmuxClient) ResizePane(index int, height string) error
ResizePane resizes the pane with the given index to the specified height. Height can be an absolute number or a percentage (e.g., "95%").
func (*RealTmuxClient) SelectLayout ¶
func (c *RealTmuxClient) SelectLayout(layout string) error
SelectLayout applies a layout to the current window. Layout can be a preset name (e.g., "even-vertical") or a layout string.
func (*RealTmuxClient) SelectPane ¶
func (c *RealTmuxClient) SelectPane(index int, args []string) error
SelectPane selects the pane with the given index. Additional args are passed directly to tmux select-pane (e.g., "-Z" to keep zoom).
func (*RealTmuxClient) SetEnvironment ¶
func (c *RealTmuxClient) SetEnvironment(key, value string) error
SetEnvironment sets a tmux environment variable.
func (*RealTmuxClient) SetPaneTitle ¶
func (c *RealTmuxClient) SetPaneTitle(title string) error
SetPaneTitle sets the title of the current pane.
func (*RealTmuxClient) SplitWindow ¶
func (c *RealTmuxClient) SplitWindow(splitArgs []string) error
SplitWindow creates a new pane by splitting the current window vertically. Additional args are passed directly to tmux split-window (e.g., "-c", "#{pane_current_path}").
func (*RealTmuxClient) SwapPane ¶
func (c *RealTmuxClient) SwapPane(direction string) error
SwapPane swaps the current pane with an adjacent pane. Direction should be "U" for up or "D" for down.
type ResizePaneCall ¶
ResizePaneCall records a call to ResizePane.
type SelectPaneCall ¶ added in v0.27.0
SelectPaneCall records a call to SelectPane.
type SetEnvCall ¶
SetEnvCall records a call to SetEnvironment.
type Status ¶
type Status struct {
Mode bool `json:"mode"`
PreviousLayout string `json:"previous_layout,omitempty"`
TotalPanes int `json:"total_panes"`
ActivePane int `json:"active_pane"`
Panes []PaneStatus `json:"panes"`
}
Status represents the current stack state.
type TmuxClient ¶
type TmuxClient interface {
ListPanes() ([]Pane, error)
GetPaneCount() (int, error)
GetCurrentPane() (int, error)
SelectPane(index int, args []string) error
ResizePane(index int, height string) error
SplitWindow(args []string) error
SwapPane(direction string) error
SetPaneTitle(title string) error
SelectLayout(layout string) error
GetWindowLayout() (string, error)
GetEnvironment(key string) (string, error)
SetEnvironment(key, value string) error
DisplayMessage(message string) error
}
TmuxClient abstracts tmux command execution for testability.