Cast files

Reference docs

Asciicast.Header — Type
Base.@kwdef struct Header
    version::Int=2
    width::Int=80
    height::Int=24
    timestamp::Union{Int, Nothing}=floor(Int, datetime2unix(now()))
    duration::Union{Float64, Nothing}=nothing
    idle_time_limit::Union{Float64, Nothing}=nothing
    command::Union{String, Nothing}=nothing
    title::Union{String, Nothing}=nothing
    env::Union{Dict{String, String},Nothing}=Dict{String, String}("SHELL" => get(ENV, "SHELL", "/bin/bash"))
    theme::Union{Dict{String, String},Nothing}=nothing
    term_type::Union{String, Nothing}=get(ENV, "TERM", "xterm-256color")
    term_version::Union{String, Nothing}=nothing
    tags::Union{Vector{String}, Nothing}=nothing
end

The header of an asciicast file, for both the v2 and v3 formats. Fields set to nothing are omitted when the header is written.

version selects the format used when a Cast is written: 2 (the default) or 3. parse_cast sets it to the version of the file it reads.

The fields correspond to the two formats as follows:

  • width and height are width and height in v2, and term.cols and term.rows in v3.
  • theme is theme in v2, and term.theme in v3.
  • term_type is term.type in v3. v2 has no such field, so it is written as env["TERM"] if env is not nothing and has no TERM entry, and read from env["TERM"] (removing it from env).
  • term_version and tags exist only in v3, and are not written to v2 files.
  • duration exists only in v2, and is not written to v3 files.
  • The other fields have the same name in both formats.
source
Asciicast.EventType — Type
Asciicast.EventType

An enum of asciicast event types:

  • Asciicast.OutputEvent (code "o")
  • Asciicast.InputEvent (code "i")
  • Asciicast.MarkerEvent (code "m")
  • Asciicast.ResizeEvent (code "r", data "{COLS}x{ROWS}")
  • Asciicast.ExitEvent (code "x", data is the exit status; defined in asciicast v3)

write_event! writes a lone in the data of OutputEvent and InputEvent as , and writes the data of the other types unchanged.

source
Asciicast.Event — Type
struct Event
    time::Float64
    type::EventType
    event_data::String
end

Represents an event in a cast file. time is the time in seconds since the start of the recording, for both v2 and v3 casts (v3 files store the interval since the previous event; parse_cast and write_event! convert between the two). event_data is kept as read by parse_cast; write_event! normalises line endings in the data of output and input events only. See also EventType.

source
Asciicast.parse_cast — Function
Asciicast.parse_cast(io::IO) -> header, events

Returns a tuple consisting of a Header and vector of Event's.

Both asciicast v2 and v3 files are supported. For v3 files, event intervals are converted to times since the start of the recording, and lines starting with # (comments) are skipped. See Header for how the header fields of each version are read. Empty lines and events with unknown event codes are skipped, as required by both specifications.

source