vt

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package vt provides a virtual terminal that implements tuist.Terminal backed by midterm.Terminal. It interprets all ANSI escape sequences exactly as a real terminal would — cursor movement, colors, line clearing, synchronized output, etc. — making it ideal for testing, headless rendering, and golden file snapshots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Frame added in v0.0.6

type Frame struct {
	Number      int
	Lines       []string // all content lines (full output)
	Width       int      // terminal width (0 if not recorded)
	Height      int      // terminal height (viewport)
	ViewportTop int
}

Frame holds the parsed content of a single TUIST_FRAMES dump file.

func ParseFrame added in v0.0.6

func ParseFrame(data string) (Frame, error)

ParseFrame parses a single TUIST_FRAMES dump file.

func ParseFrameFile added in v0.0.6

func ParseFrameFile(path string) (Frame, error)

ParseFrameFile reads and parses a TUIST_FRAMES dump file from disk.

type Terminal

type Terminal struct {
	// VT is the underlying virtual terminal. Access it directly to
	// inspect content, cursor position, cell formatting, etc.
	VT *midterm.Terminal
}

Terminal implements tuist.Terminal backed by a midterm.Terminal. All output from the TUI is interpreted by the virtual terminal, producing a pixel-perfect representation of what a real terminal would display.

func New

func New(cols, rows int) *Terminal

New creates a Terminal with the given dimensions.

func Replay added in v0.0.6

func Replay(frames []Frame, width int) *Terminal

Replay feeds a sequence of frames through a TUI backed by a virtual terminal, returning the terminal after the last frame. Each frame is rendered via tuist.TUI.RenderOnce.

Width must be provided if the frame files don't include it (pre-width format). Pass 0 to use the width from the frame header.

func (*Terminal) Columns

func (m *Terminal) Columns() int

func (*Terminal) HideCursor

func (m *Terminal) HideCursor()

func (*Terminal) Render

func (m *Terminal) Render() string

Render returns the virtual terminal's content as a string including ANSI escape sequences for colors and formatting, capturing the full styled appearance as a real terminal would display it.

func (*Terminal) Rows

func (m *Terminal) Rows() int

func (*Terminal) SetInputPassthrough

func (m *Terminal) SetInputPassthrough(io.Writer)

func (*Terminal) ShowCursor

func (m *Terminal) ShowCursor()

func (*Terminal) Start

func (m *Terminal) Start(onInput func([]byte), onResize func()) error

func (*Terminal) Stop

func (m *Terminal) Stop()

func (*Terminal) Write

func (m *Terminal) Write(p []byte)

func (*Terminal) WriteString

func (m *Terminal) WriteString(s string)

Jump to

Keyboard shortcuts

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