sessions

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: MIT Imports: 17 Imported by: 0

README

sessions

Package sessions contains a data type for recorded terminal sessions and a range of utilities for (de)serializing, searching through, and exporting them.

Documentation

Index

Constants

View Source
const (
	SESSION_FILE_VERSION = 1
)

Variables

This section is empty.

Functions

func EnsureDirectory added in v0.1.1

func EnsureDirectory(path string) error

EnsureDirectory creates a directory if it does not exist and checks whether other users can read and write files in it.

func GetFilename added in v0.1.1

func GetFilename(dataDir string, path string) (string, error)

func WriteAsciinema added in v0.1.10

func WriteAsciinema(filename string, events []Event) error

Write `events` to the given file with path `filename` in the Asciicast v2 format. See https://docs.asciinema.org/manual/asciicast/v2/ for more information.

Types

type Event

type Event struct {
	Stamp   time.Time
	Message P.Message
}

type EventHandler added in v0.1.13

type EventHandler interface {
	Process(event Event) error
}

An EventHandler handles a stream of terminal events.

type EventStream added in v0.1.13

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

An EventStream is a proxy for a Stream that turns everything that happens on that Stream into Event structs and passes them to the provided handler.

func NewEventStream added in v0.1.13

func NewEventStream(stream stream.Stream, handler EventHandler) *EventStream

func (*EventStream) Kill added in v0.2.0

func (s *EventStream) Kill()

func (*EventStream) Read added in v0.1.13

func (s *EventStream) Read(p []byte) (n int, err error)

func (*EventStream) Resize added in v0.1.13

func (s *EventStream) Resize(size stream.Size) error

func (*EventStream) Write added in v0.1.13

func (s *EventStream) Write(data []byte) (n int, err error)

type FileRecorder added in v0.1.13

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

A FileRecorder writes incoming events to a file.

func NewFileRecorder added in v0.1.13

func NewFileRecorder(ctx context.Context, filename string) (*FileRecorder, error)

func (*FileRecorder) Process added in v0.1.13

func (f *FileRecorder) Process(event Event) error

type MemoryRecorder added in v0.1.13

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

A MemoryRecorder stores Events in memory.

func NewMemoryRecorder added in v0.1.13

func NewMemoryRecorder() *MemoryRecorder

func (*MemoryRecorder) Events added in v0.1.13

func (r *MemoryRecorder) Events() []Event

func (*MemoryRecorder) Process added in v0.1.13

func (r *MemoryRecorder) Process(event Event) error

type MultiplexHandler added in v0.1.13

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

A MultiplexHandler chains multiple EventHandlers together in sequence, but returns a single EventHandler.

func NewMultiplexHandler added in v0.1.13

func NewMultiplexHandler(handlers ...EventHandler) *MultiplexHandler

func (*MultiplexHandler) Process added in v0.1.13

func (m *MultiplexHandler) Process(event Event) error

type SessionReader added in v0.1.1

type SessionReader interface {
	Read() (Event, error)
}

func Open added in v0.1.1

func Open(filename string) (SessionReader, error)

type SessionWriter added in v0.1.1

type SessionWriter interface {
	Write(event Event) error
	Close() error
}

func Create added in v0.1.1

func Create(filename string) (SessionWriter, error)

type Simulator added in v0.1.5

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

Simulator is a convenient way of building recorded sessions programmatically, primarily for testing.

func NewSimulator added in v0.1.5

func NewSimulator() *Simulator

func (*Simulator) Add added in v0.1.5

func (s *Simulator) Add(events ...interface{}) *Simulator

func (*Simulator) AddTime added in v0.1.5

func (s *Simulator) AddTime(delta time.Duration, event interface{}) *Simulator

func (*Simulator) Defaults added in v0.1.13

func (s *Simulator) Defaults() *Simulator

Defaults adds events to reset the terminal's size to DEFAULT_SIZE and changes it to LineFeedMode.

func (*Simulator) Events added in v0.1.5

func (s *Simulator) Events() []Event

func (*Simulator) Resize added in v0.1.5

func (s *Simulator) Resize(size geom.Size) *Simulator

func (*Simulator) ResizeTime added in v0.1.5

func (s *Simulator) ResizeTime(delta time.Duration, size geom.Size) *Simulator

func (*Simulator) Term added in v0.1.5

func (s *Simulator) Term(i int, v ...interface{}) *Simulator

Term invokes terminfo's Printf method and adds it to the session.

func (*Simulator) TermTime added in v0.1.5

func (s *Simulator) TermTime(delta time.Duration, i int, v ...interface{}) *Simulator

func (*Simulator) Terminal added in v0.1.13

func (s *Simulator) Terminal() emu.Terminal

Terminal processes all of the events in the simulator in a new terminal and returns it.

func (*Simulator) Write added in v0.1.5

func (s *Simulator) Write(data []byte) *Simulator

func (*Simulator) WriteTime added in v0.1.5

func (s *Simulator) WriteTime(delta time.Duration, data []byte) *Simulator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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