movemode

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorSelection = 0x3498db // Blue - window selection
	ColorGrabbed   = 0x27ae60 // Green - grabbed window
	ColorTarget    = 0x7f8c8d // Gray - target slot / empty slot preview
	ColorInactive  = 0x95a5a6 // Light gray - non-selected terminals
	ColorHintText  = 0xf5f7fa // Light text for hint overlay
	ColorHintBg    = 0x1f2933 // Dark hint background
)

Border colors

View Source
const BorderThickness = 4

Border thickness in pixels

View Source
const DefaultTimeout = 10

Default timeout for move mode (in seconds)

Variables

This section is empty.

Functions

func FindClosestSlot

func FindClosestSlot(x, y int, state *State) int

FindClosestSlot finds the slot index whose position is closest to the given point. Used when entering grabbed mode to start at the current window's slot.

func FindTerminalAtSlot

func FindTerminalAtSlot(slotIdx int, state *State) int

FindTerminalAtSlot returns the index of the terminal at the given slot, or -1 if empty.

func NavigateSlot(currentIdx int, dir Direction, rows, cols int) int

NavigateSlot calculates the new slot index after moving in a direction. Uses spatial navigation: arrow keys move in the grid based on direction. Wraps around at edges. NOTE: This assumes a uniform grid. For layouts with variable columns per row (like flexible_last_row), use NavigateSlotSpatial instead.

func NavigateSlotSpatial(currentIdx int, dir Direction, positions []tiling.Rect, rows, cols int) int

NavigateSlotSpatial navigates slots using actual slot positions. This handles layouts with variable columns per row (like flexible_last_row). Falls back to grid math if positions is empty.

func NavigateTerminal(currentIdx int, dir Direction, count int) int

NavigateTerminal cycles through terminals in a list. For PhaseSelecting: cycles through available terminals. Wraps around at edges.

Types

type Action

type Action int

Action represents a terminal action from move mode.

const (
	// ActionNone means no action is pending.
	ActionNone Action = iota
	// ActionDeleteSelected removes the selected slot (requires confirmation).
	ActionDeleteSelected
	// ActionInsertAfterSelected inserts a terminal after the selected slot.
	ActionInsertAfterSelected
	// ActionAppend appends a terminal at the end.
	ActionAppend
)

func (Action) String

func (a Action) String() string

String returns a readable action name.

type BorderOverlay

type BorderOverlay struct {
	Top    xproto.Window
	Bottom xproto.Window
	Left   xproto.Window
	Right  xproto.Window
	// contains filtered or unexported fields
}

BorderOverlay represents a rectangular border made of 4 thin windows

type Direction

type Direction int

Direction represents an arrow key direction

const (
	DirUp Direction = iota
	DirDown
	DirLeft
	DirRight
)

type HintPhase

type HintPhase int

HintPhase controls which key legend is shown in the on-screen hint overlay.

const (
	HintPhaseNone HintPhase = iota
	HintPhaseSelecting
	HintPhaseMove
	HintPhaseConfirmDelete
)

type LayoutProvider

type LayoutProvider interface {
	GetActiveLayoutName() string
}

LayoutProvider supplies the currently active layout name.

type Mode

type Mode struct {

	// OnMoveComplete is called after a successful move/swap operation.
	OnMoveComplete OnMoveCompleteFunc
	// contains filtered or unexported fields
}

Mode is the main move mode controller

func NewMode

func NewMode(backend platform.Backend, detector *terminals.Detector, cfg *config.Config, layoutProvider LayoutProvider) *Mode

NewMode creates a new move mode controller

func (*Mode) Enter

func (m *Mode) Enter() error

Enter activates move mode, starting in the selecting phase

func (*Mode) Exit

func (m *Mode) Exit()

Exit deactivates move mode

func (*Mode) HandleArrowKey

func (m *Mode) HandleArrowKey(dir Direction)

HandleArrowKey processes an arrow key press

func (*Mode) HandleCancel

func (m *Mode) HandleCancel()

HandleCancel processes the Escape key press

func (*Mode) HandleConfirm

func (m *Mode) HandleConfirm()

HandleConfirm processes the Enter key press

func (*Mode) IsActive

func (m *Mode) IsActive() bool

IsActive returns true if move mode is currently active

func (*Mode) UpdateConfig

func (m *Mode) UpdateConfig(cfg *config.Config)

UpdateConfig updates the mode's configuration reference

type MoveResult

type MoveResult struct {
	// SourceSlot is the original slot index of the moved window.
	SourceSlot int
	// TargetSlot is the new slot index of the moved window.
	TargetSlot int
	// IsSwap indicates whether two windows were swapped.
	IsSwap bool
}

MoveResult contains information about a completed move operation.

type OnMoveCompleteFunc

type OnMoveCompleteFunc func(result MoveResult)

OnMoveCompleteFunc is called after a move operation completes. It receives the move result for post-processing (e.g., renaming tmux sessions).

type OverlayManager

type OverlayManager struct {
	// contains filtered or unexported fields
}

OverlayManager manages overlay windows for move mode

func NewOverlayManager

func NewOverlayManager(xu *xgbutil.XUtil, root xproto.Window) *OverlayManager

NewOverlayManager creates a new overlay manager

func (*OverlayManager) Cleanup

func (m *OverlayManager) Cleanup()

Cleanup destroys all overlay windows

func (*OverlayManager) HideAll

func (m *OverlayManager) HideAll()

HideAll hides all overlays without destroying them.

func (*OverlayManager) Render

func (m *OverlayManager) Render(terminalRects []tiling.Rect, terminalColors []uint32, slotRects []tiling.Rect, slotColors []uint32, allSlotRects []tiling.Rect, hintPhase HintPhase) error

Render draws borders for all terminals and all grid slots.

Slots are rendered first and terminals after, so terminal borders appear on top.

type Phase

type Phase int

Phase represents the current phase of move mode

const (
	// PhaseInactive means move mode is not active
	PhaseInactive Phase = iota
	// PhaseSelecting means user is choosing which window to move
	PhaseSelecting
	// PhaseGrabbed means a window is grabbed and user is choosing target slot
	PhaseGrabbed
	// PhaseConfirmDelete means user must confirm terminal deletion
	PhaseConfirmDelete
)

func (Phase) String

func (p Phase) String() string

String returns the string representation of the phase

type State

type State struct {
	Phase           Phase
	SelectedIndex   int               // Index of highlighted terminal in Terminals slice
	GrabbedWindow   platform.WindowID // Window ID of grabbed window (0 if none)
	TargetSlotIndex int               // Target slot index for grabbed window
	PendingAction   Action            // Pending action awaiting confirmation
	PendingSlot     int               // Slot index targeted by the pending action (-1 if none)
	Terminals       []TerminalSlot    // Windows with slot assignments
	SlotPositions   []tiling.Rect     // Grid slot geometries
	GridRows        int               // Number of rows in the grid
	GridCols        int               // Number of columns in the grid
}

State holds the current move mode state

func NewState

func NewState() *State

NewState creates a new inactive state

func (*State) BeginDeleteConfirmation

func (s *State) BeginDeleteConfirmation(slot int)

BeginDeleteConfirmation transitions state into delete-confirm mode.

func (*State) ClearPendingAction

func (s *State) ClearPendingAction()

ClearPendingAction clears any pending in-mode action.

func (*State) Reset

func (s *State) Reset()

Reset resets the state to inactive

func (*State) SelectedTerminal

func (s *State) SelectedTerminal() *TerminalSlot

SelectedTerminal returns the currently selected terminal, or nil if none

func (*State) TargetSlotRect

func (s *State) TargetSlotRect() *tiling.Rect

TargetSlotRect returns the rect for the current target slot, or nil if invalid

type TerminalActionRunner

type TerminalActionRunner func(args []string) error

TerminalActionRunner executes existing terminal CLI subcommands.

type TerminalSlot

type TerminalSlot struct {
	Window   terminals.TerminalWindow
	SlotIdx  int // Index in the grid (0-based)
	SlotRect tiling.Rect
}

TerminalSlot represents a terminal window with its assigned slot

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL