console

package
v0.0.0-...-53ebdf5 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmbeddedRun

func EmbeddedRun(stdin io.Reader, stdout, stderr io.Writer) int

EmbeddedRun runs the embedded shell directly (no PTY, no status bar). Used as last-resort fallback when no external shell is found.

func Run

func Run(shell pty.DetectedShell) (int, error)

Run starts the multiplexed console with the given shell and returns the exit code.

Types

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

All fields are accessed only while mux.mu is held.

func NewMenu

func NewMenu(out io.Writer, width, height int, userItems []string,
	cfg *config.Config, cfgPath string, onCfgSave func(*config.Config), store *script.Store) *Menu

NewMenu creates a Menu. userItems are labels appended after the built-ins, encoded as "Label\x00command". cfg/cfgPath/onCfgSave are used by SETTINGS.

func (m *Menu) Close()

Close deactivates the menu without any screen cleanup (caller handles that).

func (m *Menu) Draw()

Draw redraws the full overlay.

func (m *Menu) HandleEscSeq(seq []byte) MenuAction

HandleEscSeq processes a CSI escape sequence collected after the leading \x1b by the input parser. seq is e.g. []byte{'[','A'} for Up arrow.

func (m *Menu) HandleKey(b byte) MenuAction

HandleKey processes one raw input byte and returns the resulting action.

func (m *Menu) IsActive() bool

IsActive reports whether the overlay is currently visible.

func (m *Menu) Open()

Open activates the menu in main-menu mode and draws it.

func (m *Menu) Resize(width, height int)

Resize updates dimensions. If active, redraws immediately.

func (m *Menu) SelectedExec() string

SelectedExec returns the exec string of the item chosen in the last MenuLaunch action.

type MenuAction int

MenuAction is returned by HandleKey / HandleEscSeq to tell the caller what happened.

const (
	MenuNone        MenuAction = iota
	MenuClose                  // user dismissed the menu (Esc at top level)
	MenuLaunch                 // user selected an item to launch
	MenuDumpHistory            // user requested a history buffer dump
)

type Mux

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

Mux manages multiple tab sessions in a single terminal.

func NewMux

func NewMux(shell pty.DetectedShell, out io.Writer, menuUserItems []string,
	cfg *config.Config, cfgPath string, onCfgSave func(*config.Config),
	engines []*script.Engine, builtinEngines []*script.Engine, store *script.Store) *Mux

NewMux creates a Mux. Call Run() to start the main loop. builtinEngines are loaded before user engines for widget registration.

func (*Mux) Run

func (m *Mux) Run() int

Run sets up the terminal, opens the first tab, and drives the I/O loops. Returns the exit code of the last surviving tab.

type StatusBar

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

StatusBar manages a single-row status bar pinned to the TOP of the terminal. It uses DECSTBM (scroll region) to reserve row 1 so PTY output scrolls in rows 2..N.

func NewStatusBar

func NewStatusBar(shell pty.DetectedShell, width, height int, out io.Writer) *StatusBar

NewStatusBar creates a StatusBar. Call Setup() before starting the PTY.

func (*StatusBar) ClearRename

func (s *StatusBar) ClearRename()

ClearRename exits rename mode.

func (*StatusBar) ConstraintEscape

func (s *StatusBar) ConstraintEscape() string

ConstraintEscape returns the DECSTBM escape that enforces our scroll region. Used by the PTY output filter to replace rogue \x1b[r resets.

func (*StatusBar) Draw

func (s *StatusBar) Draw()

Draw redraws the bar without touching the scroll region. Caller must hold any shared mutex.

func (*StatusBar) Reapply

func (s *StatusBar) Reapply()

Reapply re-asserts the DECSTBM scroll region bounds after a ring buffer replay. Wraps the DECSTBM write with DEC save/restore so the shell's cursor position is not disturbed — DECSTBM homes the cursor per VT100 spec.

func (*StatusBar) Resize

func (s *StatusBar) Resize(width, height int)

Resize redraws the bar and updates the scroll region for the new dimensions. Caller must hold any shared mutex.

func (*StatusBar) SetRename

func (s *StatusBar) SetRename(tabNum int, buf string)

SetRename puts the bar into rename-input mode.

func (*StatusBar) SetTabs

func (s *StatusBar) SetTabs(tabs []tabInfo)

SetTabs updates the tab list shown in the bar.

func (*StatusBar) SetWidgets

func (s *StatusBar) SetWidgets(w string)

SetWidgets updates the right-side widget strip string shown in the bar.

func (*StatusBar) Setup

func (s *StatusBar) Setup()

Setup draws the status bar on row 1, applies the scroll region to rows 2..N, enables DECOM so PTY cursor addressing is relative to the scroll region, and positions the cursor at the top of the PTY area.

func (*StatusBar) Teardown