x

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 11 Imported by: ? 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 x holds specialised widgets built on kit and kit/ui: a log view and a lyrics view. They follow kit/ui's props-struct shape.

Index

Constants

View Source
const DefaultLogCap = 10000

DefaultLogCap is the capacity of a LogBuffer whose Cap is zero or negative.

Variables

This section is empty.

Functions

func ActiveLyric

func ActiveLyric(lines []LyricLine, at time.Duration) int

ActiveLyric returns the index of the line current at time at, or -1 before the first one. lines must be sorted by At.

Types

type LogBuffer

type LogBuffer struct {
	// Cap is the most lines held; zero or negative means DefaultLogCap. It
	// may change at any time and takes effect at the next Append, which
	// first drops the oldest lines beyond the new capacity.
	Cap int
	// contains filtered or unexported fields
}

LogBuffer is a fixed-capacity ring of log lines: once full, each Append drops the oldest line. The zero value is an empty buffer of DefaultLogCap lines.

Like all app state it belongs to the UI goroutine: append from elsewhere via App.Post.

func (*LogBuffer) Append

func (b *LogBuffer) Append(ls ...LogLine)

Append adds lines at the newest end, dropping the oldest lines beyond the capacity.

func (*LogBuffer) At

func (b *LogBuffer) At(i int) LogLine

At returns the i-th oldest line held. It panics unless 0 <= i < Len().

func (*LogBuffer) Clear

func (b *LogBuffer) Clear()

Clear drops every line and releases the references the buffer held. It keeps the allocated capacity.

func (*LogBuffer) Len

func (b *LogBuffer) Len() int

Len is the number of lines held.

type LogLevel

type LogLevel int

LogLevel orders log severity, lowest first. It is independent of log/slog's Level: map slog records onto these four levels when feeding a LogBuffer.

const (
	LogDebug LogLevel = iota // diagnostics, usually hidden
	LogInfo                  // normal operation
	LogWarn                  // something needs attention
	LogError                 // something failed
)

func (LogLevel) String

func (l LogLevel) String() string

String returns the level's column label ("DEBUG", "INFO", "WARN", "ERROR"), or "LogLevel(n)" for an undefined value.

type LogLine

type LogLine struct {
	Time   time.Time // when it was logged; zero hides the timestamp
	Level  LogLevel  // colours the line and filters it (LogViewState.MinLevel)
	Source string    // optional: component, logger name
	Text   string    // the message
}

LogLine is one log record.

type LogView

type LogView struct {
	ID     string     // the scroll region's id; the jump button is ID/jump
	Buffer *LogBuffer // the lines; must not be nil
}

LogView shows Buffer: virtualized, monospace, coloured by level. It follows the tail while scrolled to the bottom; scrolling up pauses that and shows a "jump to latest" button (ID/jump). Filtering is incremental, so it stays cheap on large buffers. The scroll region's id is ID.

func (LogView) Layout

func (lv LogView) Layout(gtx layout.Context, th *kit.Theme, v *LogViewState) layout.Dimensions

Layout handles the jump button, syncs the filter index and draws the view. It fills the constraints.

type LogViewState

type LogViewState struct {
	Filter   string   // case-insensitive substring of Text or Source; "" shows everything
	MinLevel LogLevel // hide lines below this level
	NoTime   bool     // hide the timestamp column
	// contains filtered or unexported fields
}

LogViewState is a LogView's filter, scroll position and filter index. The filter fields are state-owned values: set them directly and the index rebuilds at the next Count or Layout. The zero value shows every line and follows the tail. A LogViewState indexes one LogBuffer; use a new state for a different buffer.

func (*LogViewState) Count

func (v *LogViewState) Count(b *LogBuffer) int

Count is the number of lines of b the view shows. It syncs the filter index first, so it is safe to draw above the view (a toolbar) in the same frame.

func (*LogViewState) Following

func (v *LogViewState) Following() bool

Following reports whether the view is pinned to the newest line.

func (*LogViewState) ListPos

func (v *LogViewState) ListPos() layout.Position

ListPos returns the list's scroll position as of the last layout, for tests and debugging.

type LyricLine

type LyricLine struct {
	At   time.Duration // start time from the beginning of the track
	Text string        // the line; "" draws an empty line
}

LyricLine starts at At and remains current until the next line starts.

type Lyrics

type Lyrics struct {
	ID    string        // the scroll region's id
	Lines []LyricLine   // sorted by At
	At    time.Duration // the playback position
}

Lyrics is a timed, scrollable line view of Lines at time At; the current line is highlighted and, while following, kept in view. The scroll region's id is ID. Lines must be sorted by At.

func (Lyrics) Layout

func (ly Lyrics) Layout(gtx layout.Context, th *kit.Theme, st *LyricsState) layout.Dimensions

Layout draws the lines, scrolling to the current one when it changes while following, and turns Follow off when the listener scrolls.

type LyricsState

type LyricsState struct {
	List   kit.List // the scroll position
	Follow bool     // keep the current line in view; set it to jump there
	// contains filtered or unexported fields
}

LyricsState is a Lyrics' scroll position and follow mode. Follow turns off when the listener scrolls the transcript; turning it on jumps to the current line. The zero value does not follow.

Directories

Path Synopsis
Package video draws streaming images (video, camera, remote screens) with Video, from a paint.Stream (in giokit's Gio fork).
Package video draws streaming images (video, camera, remote screens) with Video, from a paint.Stream (in giokit's Gio fork).

Jump to

Keyboard shortcuts

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