Documentation
¶
Index ¶
- Variables
- type Cell
- type Color
- type PTY
- type Style
- type Terminal
- func (t *Terminal) Close() error
- func (t *Terminal) CursorPos() (x, y int)
- func (t *Terminal) GetBuffer() []string
- func (t *Terminal) GetBufferCells() [][]Cell
- func (t *Terminal) GetBufferRunes() [][]rune
- func (t *Terminal) GetLine(y int) string
- func (t *Terminal) IsRunning() bool
- func (t *Terminal) Resize(rows, cols int) error
- func (t *Terminal) SnapshotCells() (lines [][]Cell, cursorX, cursorY int)
- func (t *Terminal) SnapshotRunes() (lines [][]rune, cursorX, cursorY int)
- func (t *Terminal) Write(data []byte) error
- func (t *Terminal) WriteString(s string) error
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("terminal closed")
Functions ¶
This section is empty.
Types ¶
type Color ¶
type Color int32
Color represents a terminal color.
const ( ColorDefault Color = -1 ColorBlack Color = 0 ColorRed Color = 1 ColorGreen Color = 2 ColorYellow Color = 3 ColorBlue Color = 4 ColorMagenta Color = 5 ColorCyan Color = 6 ColorWhite Color = 7 // Bright colors (8-15) ColorBrightBlack Color = 8 ColorBrightRed Color = 9 ColorBrightGreen Color = 10 ColorBrightYellow Color = 11 ColorBrightBlue Color = 12 ColorBrightMagenta Color = 13 ColorBrightCyan Color = 14 ColorBrightWhite Color = 15 )
Standard ANSI colors
type PTY ¶
PTY represents a pseudo-terminal pair.
func (*PTY) StartProcess ¶
StartProcess starts a process attached to the PTY.
func (*PTY) StartShell ¶
StartShell starts the default shell attached to the PTY.
type Style ¶
type Style struct {
Fg Color
Bg Color
Bold bool
Dim bool
Italic bool
Underline bool
Blink bool
Reverse bool
}
Style holds text attributes for a cell.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal represents a terminal session with a PTY and process.
func NewTerminal ¶
NewTerminal creates a new terminal with the given size.
func (*Terminal) GetBuffer ¶
GetBuffer returns the entire buffer as strings (characters only, no styles).
func (*Terminal) GetBufferCells ¶
GetBufferCells returns the entire buffer with styles. This is the preferred method for rendering with color support.
func (*Terminal) GetBufferRunes ¶
GetBufferRunes returns the entire buffer as rune slices (characters only, no styles). This is more efficient for rendering as it avoids UTF-8 encoding/decoding and provides correct column indices.
func (*Terminal) GetLine ¶
GetLine returns a line from the buffer as a string (characters only, no styles).
func (*Terminal) SnapshotCells ¶
SnapshotCells returns scrollback + active buffer with styles and absolute cursor position. Cursor Y is relative to the returned lines.
func (*Terminal) SnapshotRunes ¶
SnapshotRunes returns scrollback + active buffer and the absolute cursor position. Cursor Y is relative to the returned lines.
func (*Terminal) WriteString ¶
WriteString sends a string to the terminal.