mterm

package
v0.0.36 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 8 Imported by: ? 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

Index

Constants

View Source
const (
	Color16  = 1
	Color256 = 2
	Color16M = 3
)
View Source
const (
	FlagBold uint8 = 1 << iota
	FlagDim
	FlagItalic
	FlagUnderline
	FlagBlink
	FlagInverse
	FlagInvisible
	FlagStrike
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	Char rune

	SGRState
	// contains filtered or unexported fields
}

Cell is a single cell in the terminal

type Color

type Color [3]byte

type EscapeError

type EscapeError struct {
	Err    error
	Offset int
}

func (EscapeError) Error

func (e EscapeError) Error() string

type Grid added in v0.0.18

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

func (*Grid) Resize added in v0.0.18

func (g *Grid) Resize(rows, cols int)

Resize regular resize without reflow, it will chomp any extra lines/columns

func (*Grid) ResizeAndReflow added in v0.0.18

func (g *Grid) ResizeAndReflow(rows, cols int)

ResizeAndReflow resize the grid and reflow based on newline markers

func (*Grid) Size added in v0.0.18

func (g *Grid) Size() (rows, cols int)

type SGRState added in v0.0.15

type SGRState struct {
	FG        Color
	BG        Color
	UL        Color // underline color
	ColorType uint8 // 0b00uubbff (u underline, b BG, f FG color types)
	Flags     uint8
}

func (*SGRState) Set added in v0.0.15

func (s *SGRState) Set(p ...int) error

Set the Set based on CSI parameters

type Terminal

type Terminal struct {
	Title   string
	TabSize int
	// contains filtered or unexported fields
}

Terminal is an in memory terminal emulator

func New

func New(rows, cols int) *Terminal

New returns a new terminal with the given rows and cols

func (*Terminal) AltScreenActive added in v0.0.29

func (t *Terminal) AltScreenActive() bool

AltScreenActive reports whether the alternate screen is in use.

func (*Terminal) Clear

func (t *Terminal) Clear()

Clear clears the terminal moving cursor to 0,0

func (*Terminal) CursorPos added in v0.0.13

func (t *Terminal) CursorPos() (int, int)

GetCursorPos returns the current cursor position in lines, cols

func (*Terminal) GetHistoryAsAnsi added in v0.0.28

func (t *Terminal) GetHistoryAsAnsi() []byte

GetHistoryAsAnsi returns the scrollback backlog — the lines above the visible screen — rendered as ANSI, one \r\n-terminated line per row, ending with an SGR reset so the last line's attributes never bleed into whatever is written next. On the alt screen the whole primary screen counts as history: it is what was on display before the alt-screen app took over.

func (*Terminal) GetModesAsAnsi added in v0.0.29

func (t *Terminal) GetModesAsAnsi() []byte

GetModesAsAnsi returns the escape sequences that restore terminal state the screen content alone cannot carry. Today that is the DECSTBM scroll region: without it a reconnected viewer scrolls the whole screen where the host (e.g. tmux protecting its status line) scrolls only a region, leaving a stale copy of the protected line behind. Empty when the region is the full screen. DECSTBM homes the cursor, so callers must emit this before the final cursor position.

func (*Terminal) GetScreenAsAnsi

func (t *Terminal) GetScreenAsAnsi() []byte

func (*Terminal) Resize

func (t *Terminal) Resize(rows, cols int)

func (*Terminal) Write

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

Write implements io.Writer and writes the given bytes to the terminal

Jump to

Keyboard shortcuts

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