asciicast

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: MIT Imports: 10 Imported by: 0

README

asciicast

Implementation of asciicast (a tty recorder)

Documentation

Index

Constants

View Source
const ContentType = "application/x-asciicast"

ContentType is the asciicast v2 MIME type.

View Source
const Version = 2

Version 2 is supposed by this package.

Variables

View Source
var ErrVersion = errors.New("asciicast: not a version 2 header")

ErrVersion is returned by Decoder/Reader if the version in the header is not version 2.

Functions

This section is empty.

Types

type Decoder

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

Decoder for asciicast v2 recordings.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new Decoder for the provided Reader.

func (*Decoder) DecodeEvent

func (d *Decoder) DecodeEvent() (*Event, error)

DecodeEvent decodes the next Event.

func (*Decoder) DecodeHeader

func (d *Decoder) DecodeHeader() (*Header, error)

DecodeHeader decodes the recording meta-data. DecodeHeader can be called multiple times and will only read the header from the Reader once.

type Encoder

type Encoder struct {
	// Header contains recording meta-data.
	Header
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer, width, height int) *Encoder

NewEncoder can emit an asciicast v2 stream.

func NewEncoderEx

func NewEncoderEx(w io.Writer, header Header) *Encoder

NewEncoderEx can emit an asciicast v2 stream.

func (*Encoder) Write

func (e *Encoder) Write(p []byte) (int, error)

Write writes output. If WriteHeader wasn't called, it will be called first.

func (*Encoder) WriteEvent

func (e *Encoder) WriteEvent(kind EventType, data string) error

WriteEvent writes an event. If WriteHeader wasn't called, it will be called first.

func (*Encoder) WriteHeader

func (e *Encoder) WriteHeader() error

WriteHeader writes the recording meta-data.

func (*Encoder) WriteInput

func (e *Encoder) WriteInput(p []byte) (int, error)

WriteInput writes input. If WriteHeader wasn't called, it will be called first.

func (*Encoder) WriteRawEvent

func (e *Encoder) WriteRawEvent(event Event) error

WriteRawEvent writes a raw event.

type Event

type Event struct {
	Time float64
	Type EventType
	Data string
}

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(b []byte) error

type EventType

type EventType string
const (
	// Output signals data written to standard output.
	Output EventType = "o"

	// Input signals data read from standard input.
	Input EventType = "i"
)
type Header struct {
	Version       int               `json:"version"`
	Width         int               `json:"width"`
	Height        int               `json:"height"`
	Timestamp     int64             `json:"timestamp,omitempty"`
	Duration      float64           `json:"duration,omitempty"`
	IdleTimeLimit float64           `json:"idle_time_limit,omitempty"`
	Command       string            `json:"command,omitempty"`
	Title         string            `json:"title,omitempty"`
	Env           map[string]string `json:"env,omitempty"`
	Theme         *Theme            `json:"theme,omitempty"`
}

Header contains contains recording meta-data.

type Palette

type Palette color.Palette

func (Palette) MarshalJSON

func (p Palette) MarshalJSON() ([]byte, error)

func (*Palette) UnmarshalJSON

func (p *Palette) UnmarshalJSON(b []byte) error

type Reader

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

Reader for one event type.

func NewReader

func NewReader(r io.Reader, eventType EventType) (*Reader, error)

NewReader returns a new reader for the selected EventType.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

type Theme

type Theme struct {
	Foreground string  `json:"fg"`
	Background string  `json:"bg"`
	Palette    Palette `json:"palette"`
}

Theme of the recorded terminal.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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