transcript

package
v1.0.0-rc.8 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package transcript is the chat log: rows appended in order, drawn on demand, and a reader position that survives every redraw.

The transcript owns its viewport (ADR 0007). A reveal, a timestamp toggle or a resize changes how many screen lines each row takes, so the reader's place is held as an anchor, a row rather than a line offset, read before any mutation and restored after. Keeping the viewport inside is what makes that ordering an invariant of this package instead of something every caller has to remember.

Rows arrive already classified and stamped: the transcript styles what it is told and never reads the clock or the network. Username and HTML are treated as hostile and sanitized on draw; Text is trusted as the caller rendered it.

Index

Constants

View Source
const MaxRows = 2000

MaxRows caps the transcript. An evening of chat must not grow without bound; the oldest rows are dropped first, the same loss a reconnect gap is.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind int

Kind says what a row is, which decides how it is drawn.

const (
	// Chat is an ordinary line: a styled speaker, then the body.
	Chat Kind = iota
	// Me is a /me action. The server's HTML already leads with the
	// actor's name, as the web client relies on; only the "* " is ours.
	Me
	// Slap is drawn like Me.
	Slap
	// Server is a server-authored message: HTML drawn as an event.
	Server
	// DM is a direct message, marked "[DM]" before the speaker.
	DM
	// Event is something that happened (a join, a notice, the MOTD):
	// plain Text drawn faint.
	Event
	// Error is something that failed: plain Text in the error color.
	Error
	// Roster is the /who listing: plain Text drawn as given, since it
	// carries its own dimming for away users.
	Roster
	// Gap marks a reconnect whose backfill did not overlap what was
	// already shown; older messages are gone.
	Gap
)

type Options

type Options struct {
	RevealSpoilers bool
	ShowTimes      bool
}

Options are the reader's display toggles.

type Row

type Row struct {
	Kind     Kind
	Username string
	Mod      bool
	Self     bool
	Mention  bool
	Spoiler  bool
	HTML     string
	Text     string
	At       time.Time
}

Row is one entry in the transcript. HTML is for Chat, Me, Slap, Server and DM and is converted on every draw so a reveal can show what a hidden spoiler held; Text is for Event, Error and Roster and must already be rendered and sanitized. At is always the caller's: the transcript never substitutes the current time.

type Transcript

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

Transcript is the chat log and the viewport it is read through. The zero value is not usable; call New. It is a value type like the viewport it holds, so a Bubble Tea model can carry it by value.

func New

func New(t theme.Theme) Transcript

New builds an empty transcript drawing with the theme's roles.

func (*Transcript) Append

func (t *Transcript) Append(r Row)

Append adds a row at the bottom. A reader following the newest row keeps following; one scrolled up stays on the row they were reading, even when the cap drops rows above it.

func (*Transcript) Follow

func (t *Transcript) Follow()

Follow jumps to the newest row and keeps the reader there.

func (Transcript) Following

func (t Transcript) Following() bool

Following reports whether the reader is at the bottom. Before the first Resize there is nothing to be scrolled up in, so it is true.

func (Transcript) Height

func (t Transcript) Height() int

Height is the viewport's row count as of the last Resize.

func (Transcript) Options

func (t Transcript) Options() Options

Options reports the current display toggles.

func (*Transcript) PageDown

func (t *Transcript) PageDown()

PageDown scrolls forward one screen.

func (*Transcript) PageUp

func (t *Transcript) PageUp()

PageUp scrolls back one screen; the reader stops following.

func (*Transcript) Resize

func (t *Transcript) Resize(w, h int)

Resize fits the transcript to w columns and h rows. A new width re-wraps every row around the reader's anchor; a height-only change keeps the content and only reclamps, so a reader at the bottom stays there and one left past the bottom by a shrink snaps back.

func (Transcript) Rows

func (t Transcript) Rows() []Row

Rows is what the transcript holds, oldest first. The slice is the transcript's own; callers read it and do not keep it.

func (*Transcript) SetOptions

func (t *Transcript) SetOptions(o Options)

SetOptions changes the display toggles and redraws every row around the reader's anchor.

func (Transcript) View

func (t Transcript) View() string

View draws the visible screen lines, or nothing before the first Resize.

Jump to

Keyboard shortcuts

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