termtest

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package termtest is a tiny terminal emulator for tests: it plays the bytes the chat writes (carriage returns, newlines, cursor up and right, clearing, colors) onto a screen of rows, so a test can assert what a person would see, and where the cursor is.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Term

type Term struct {
	Width int

	R, C int // the cursor
	// contains filtered or unexported fields
}

Term is a screen of a fixed width. Colors and other styles are ignored.

func New

func New(width int) *Term

New returns an empty screen of the given width.

func Play

func Play(width int, out string) *Term

Play runs a whole output through a fresh screen.

func (*Term) CursorLine

func (t *Term) CursorLine() string

CursorLine is the text of the row the cursor is on.

func (*Term) Lines

func (t *Term) Lines() []string

Lines are the screen's rows without trailing spaces; empty rows at the end are dropped.

func (*Term) Write

func (t *Term) Write(p []byte) (int, error)

Write plays bytes onto the screen.

Jump to

Keyboard shortcuts

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