asciicast: maze.io/x/asciicast Index | Files | Directories

package asciicast

import "maze.io/x/asciicast"

Index

Package Files

asciicast.go reader.go writer.go

Constants

const ContentType = "application/x-asciicast"

ContentType is the asciicast v2 MIME type.

const Version = 2

Version 2 is supposed by this package.

Variables

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.

type Decoder Uses

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

Decoder for asciicast v2 recordings.

func NewDecoder Uses

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new Decoder for the provided Reader.

func (*Decoder) DecodeEvent Uses

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

DecodeEvent decodes the next Event.

func (*Decoder) DecodeHeader Uses

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 Uses

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

func NewEncoder Uses

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

NewEncoder can emit an asciicast v2 stream.

func NewEncoderEx Uses

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

NewEncoderEx can emit an asciicast v2 stream.

func (*Encoder) Write Uses

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

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

func (*Encoder) WriteEvent Uses

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 Uses

func (e *Encoder) WriteHeader() error

WriteHeader writes the recording meta-data.

func (*Encoder) WriteInput Uses

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

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

func (*Encoder) WriteRawEvent Uses

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

WriteRawEvent writes a raw event.

type Event Uses

type Event struct {
    Time float64
    Type EventType
    Data string
}

func (Event) MarshalJSON Uses

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

func (*Event) UnmarshalJSON Uses

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

type EventType Uses

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 Uses

type Palette color.Palette

func (Palette) MarshalJSON Uses

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

func (*Palette) UnmarshalJSON Uses

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

type Reader Uses

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

Reader for one event type.

func NewReader Uses

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

NewReader returns a new reader for the selected EventType.

func (*Reader) Read Uses

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

type Theme Uses

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

Theme of the recorded terminal.

Directories

PathSynopsis
convert

Package asciicast imports 10 packages (graph). Updated 2019-09-12. Refresh now. Tools for package owners.