terminal

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPaneNotRunning = fmt.Errorf("pane is not running")

Functions

This section is empty.

Types

type ExitFocusMsg

type ExitFocusMsg struct{}

ExitFocusMsg signals to return to board view

type ExitMsg

type ExitMsg struct {
	PaneID string
	Err    error
}

ExitMsg indicates the process has exited

type OutputMsg

type OutputMsg struct {
	PaneID string
	Data   []byte
}

OutputMsg carries data read from the PTY

type Pane

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

func New

func New(id string, width, height int, scrollbackSize int) *Pane

func (*Pane) ExitErr

func (p *Pane) ExitErr() error

ExitErr returns any error from the process exit

func (*Pane) GetContent

func (p *Pane) GetContent() string

GetContent returns the current terminal content as plain text for analysis.

func (*Pane) GetWorkdir

func (p *Pane) GetWorkdir() string

func (*Pane) HandleKey

func (p *Pane) HandleKey(msg tea.KeyMsg) tea.Msg

HandleKey processes a key event and sends to PTY

func (*Pane) HandleMouse

func (p *Pane) HandleMouse(msg tea.MouseMsg)

func (*Pane) ID

func (p *Pane) ID() string

ID returns the pane's identifier

func (*Pane) IsAltScreenActive added in v0.0.37

func (p *Pane) IsAltScreenActive() bool

IsAltScreenActive returns whether the terminal is in alternate screen mode.

func (*Pane) Running

func (p *Pane) Running() bool

Running returns whether the pane has a running process

func (*Pane) ScrollbackLen added in v0.0.37

func (p *Pane) ScrollbackLen() int

ScrollbackLen returns the number of lines in the scrollback buffer.

func (*Pane) SetSessionName added in v0.0.26

func (p *Pane) SetSessionName(name string)

SetSessionName sets the session name for OPENKANBAN_SESSION env var

func (*Pane) SetSize

func (p *Pane) SetSize(width, height int)

func (*Pane) SetWorkdir

func (p *Pane) SetWorkdir(dir string)

SetWorkdir sets the working directory for commands

func (*Pane) Size

func (p *Pane) Size() (width, height int)

Size returns the current dimensions

func (*Pane) Start

func (p *Pane) Start(command string, args ...string) tea.Cmd

Start launches a command in a PTY and returns a Cmd to begin reading

func (*Pane) Stop

func (p *Pane) Stop() error

func (*Pane) StopGraceful

func (p *Pane) StopGraceful(timeout time.Duration) error

StopGraceful sends SIGTERM, waits for timeout, then SIGKILL if needed.

func (*Pane) Update

func (p *Pane) Update(msg tea.Msg) tea.Cmd

Update handles messages for this pane, returns commands to execute

func (*Pane) View

func (p *Pane) View() string

View returns the rendered terminal content

func (*Pane) ViewportOffset added in v0.0.37

func (p *Pane) ViewportOffset() int

ViewportOffset returns how many lines the viewport is scrolled back.

func (*Pane) WriteInput

func (p *Pane) WriteInput(data []byte) (int, error)

type Position added in v0.0.37

type Position struct {
	Row int // Logical row (negative = scrollback, positive = live screen)
	Col int
}

Position represents a coordinate in the terminal.

type RenderTickMsg

type RenderTickMsg struct {
	PaneID string
}

RenderTickMsg triggers a throttled render

type ScrollbackBuffer added in v0.0.37

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

ScrollbackBuffer is a ring buffer for storing terminal scrollback history. It stores lines that have scrolled off the top of the terminal screen.

func NewScrollbackBuffer added in v0.0.37

func NewScrollbackBuffer(capacity int) *ScrollbackBuffer

NewScrollbackBuffer creates a new scrollback buffer with the given capacity.

func (*ScrollbackBuffer) Capacity added in v0.0.37

func (sb *ScrollbackBuffer) Capacity() int

Capacity returns the maximum number of lines the buffer can hold.

func (*ScrollbackBuffer) Clear added in v0.0.37

func (sb *ScrollbackBuffer) Clear()

Clear removes all lines from the buffer.

func (*ScrollbackBuffer) Get added in v0.0.37

func (sb *ScrollbackBuffer) Get(index int) []vt10x.Glyph

Get returns the line at the given index (0 = oldest line in buffer). Returns nil if index is out of bounds.

func (*ScrollbackBuffer) GetRange added in v0.0.37

func (sb *ScrollbackBuffer) GetRange(startIndex, endIndex int) [][]vt10x.Glyph

GetRange returns lines from startIndex to endIndex (exclusive). Useful for rendering a viewport of scrollback history.

func (*ScrollbackBuffer) Len added in v0.0.37

func (sb *ScrollbackBuffer) Len() int

Len returns the number of lines in the buffer.

func (*ScrollbackBuffer) Push added in v0.0.37

func (sb *ScrollbackBuffer) Push(line []vt10x.Glyph)

Push adds a line to the scrollback buffer. If the buffer is full, the oldest line is overwritten.

type SelectionMode added in v0.0.37

type SelectionMode int

SelectionMode represents the current state of text selection.

const (
	SelectionIdle SelectionMode = iota
	SelectionSelecting
	SelectionSelected
)

type SelectionState added in v0.0.37

type SelectionState struct {
	Mode   SelectionMode
	Anchor Position // Where selection started (click position)
	Cursor Position // Current end of selection (drag position)
}

SelectionState manages mouse text selection in the terminal.

func NewSelectionState added in v0.0.37

func NewSelectionState() *SelectionState

NewSelectionState creates a new selection state in idle mode.

func (*SelectionState) Bounds added in v0.0.37

func (s *SelectionState) Bounds() (start, end Position)

Bounds returns the normalized selection bounds (start before end).

func (*SelectionState) Clear added in v0.0.37

func (s *SelectionState) Clear()

Clear cancels any active selection.

func (*SelectionState) Contains added in v0.0.37

func (s *SelectionState) Contains(pos Position) bool

Contains checks if a position is within the selection.

func (*SelectionState) ExtractText added in v0.0.37

func (s *SelectionState) ExtractText(
	scrollbackLines [][]vt10x.Glyph,
	liveScreen func(col, row int) vt10x.Glyph,
	liveRows int,
	scrollbackLen int,
) string

ExtractText extracts selected text from scrollback buffer and live screen. scrollbackLines: lines from scrollback buffer (oldest first) liveScreen: function to get a glyph from live screen (col, row) liveRows: number of rows in live screen scrollbackLen: total lines in scrollback

func (*SelectionState) Finish added in v0.0.37

func (s *SelectionState) Finish()

Finish completes the selection (mouse release).

func (*SelectionState) IsActive added in v0.0.37

func (s *SelectionState) IsActive() bool

IsActive returns true if there's an active or completed selection.

func (*SelectionState) Start added in v0.0.37

func (s *SelectionState) Start(pos Position)

Start begins a new selection at the given position.

func (*SelectionState) Update added in v0.0.37

func (s *SelectionState) Update(pos Position)

Update extends the selection to the new cursor position.

Jump to

Keyboard shortcuts

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