formatters

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ASCIICast = asciiCast{
	// contains filtered or unexported fields
}

ASCIICast is an empty struct to help format into Asciicast/Asciinema format. See https://github.com/asciinema/asciinema/blob/develop/doc/asciicast-v2.md for more details on the format

Functions

func AddNewline

func AddNewline(bytes []byte, err error) ([]byte, error)

AddNewline is a small helper function to append a newline character (\n) to the end of a byte slice, if the provided error is not nil. The input is the same as the output for json.Marshal so that they can be chained easily.

Types

type ASCIICastHeader

type ASCIICastHeader struct {
	// only first 3 are required
	Version       int               `json:"version"`
	Width         uint16            `json:"width"`
	Height        uint16            `json:"height"`
	Timestamp     int64             `json:"timestamp"`
	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"`
	Theme         *ASCIICastTheme   `json:"theme,omitempty"`
}

ASCIICastHeader is a structure for representing Asciinema formatted files. See here: https://github.com/asciinema/asciinema/blob/develop/doc/asciicast-v2.md Note that this compatible with V2 explicitly. Future revisions are not guaranteed.

type ASCIICastTheme

type ASCIICastTheme struct {
	Foreground string `json:"fg,omitempty"`
	Background string `json:"bg,omitempty"`
	Palette    string `json:"palette,omitempty"`
}

ASCIICastTheme is the struct that represents the Asciinema file theme sub-structure

type ASCIInemaEvent

type ASCIInemaEvent struct {
	When float64
	Type string
	Data string
}

ASCIInemaEvent is the struct that represents the Asciinema file event sub-structure Note: in the asciicast format, the data is represented as an array, so there is no explicit json field naming here. See (f ASCIICast) WriteEvent for how these get turned into the proper format

type Formatter

type Formatter interface {
	WriteHeader(Metadata) ([]byte, error)
	WriteFooter(Metadata) ([]byte, error)
	WriteEvent(evt common.Event) ([]byte, error)
}

Formatter is a small interface for building up a file (in the form of bytes). The separation allows for streaming parts of a file

type Metadata

type Metadata struct {
	StartTimeUnix   int64
	DurationSeconds float64
	Title           string
	Shell           string
	Term            string
}

Metadata allows for the capture of data for a particular recording session.

func (Metadata) String

func (m Metadata) String() string

Jump to

Keyboard shortcuts

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