player

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Player

type Player struct {
	emu.Terminal
	// contains filtered or unexported fields
}

func FromBorgContext added in v1.10.0

func FromBorgContext(
	ctx context.Context,
	path string,
	progress chan<- int,
) (p *Player, err error)

FromBorgContext loads a .borg file from disk, processing events as it reads. If `progress` is not nil, it receives percent updates from 0-100 and is closed once loading completes.

func FromEvents

func FromEvents(events []sessions.Event) *Player

func FromEventsContext added in v1.2.0

func FromEventsContext(
	ctx context.Context,
	events []sessions.Event,
) (*Player, error)

FromEventsContext creates a Player from the given events, but stops if the context is cancelled.

func New

func New(options ...detect.Option) *Player

func (*Player) Acquire

func (p *Player) Acquire()

func (*Player) Commands

func (p *Player) Commands() []detect.Command

func (*Player) Events

func (p *Player) Events() []sessions.Event

func (*Player) Goto

func (p *Player) Goto(index, offset int)

Goto moves the player to the specified event index and byte offset. If the index and offset are before the current location, the player will reset the terminal and start from the beginning, since there's no way to "rewind" a terminal session. This means that playing backwards is very slow on long sessions.

func (*Player) GotoProgress added in v0.10.0

func (p *Player) GotoProgress(
	index, offset int,
	progress chan<- int,
)

GotoProgress is the same as Goto, but it allows for a progress channel to be passed in. The channel will receive progress updates as the player moves through the events.

func (*Player) Lines added in v1.12.0

func (p *Player) Lines() string

Lines returns all Flow lines from the terminal joined into a single string.

func (*Player) Location

func (p *Player) Location() search.Address

func (*Player) Output added in v0.9.0

func (p *Player) Output(start, end int) (data []byte, ok bool)

Output gets all of the output written in the range [start, end).

func (*Player) Preview

func (p *Player) Preview(
	params *params.Parameters,
	viewport, location geom.Vec2,
	highlights []movement.Highlight,
) *tty.State

Preview captures a preview with the size `viewport` at `location` in the scrollback of the terminal. You may also provide `highlights` that will be passed to the Flow renderer. Returns nil if the player is "in use", which is only used by replay mode to jump back in time.

func (*Player) Process

func (p *Player) Process(event sessions.Event) error

func (*Player) Release

func (p *Player) Release()

func (*Player) ReleaseProgress added in v1.10.0

func (p *Player) ReleaseProgress(update func(done, total int))

ReleaseProgress releases the player from replay mode and replays any events that were buffered while it was acquired. If update is non-nil, it will be called with (done,total) as buffered events are processed.

func (*Player) SetHistoryLimit added in v1.10.0

func (p *Player) SetHistoryLimit(limit int)

SetHistoryLimit bounds the amount of terminal scrollback kept in memory. This method is destructive and is intended to be called before any events are processed.

func (*Player) SetRetainOutputData added in v1.10.0

func (p *Player) SetRetainOutputData(retain bool)

SetRetainOutputData controls whether output bytes are kept in memory as part of the player's event log. Disabling this prevents seeking and Output() from working, but reduces memory usage when the recording is already persisted to disk.

Jump to

Keyboard shortcuts

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