logbuf

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: GPL-3.0 Imports: 1 Imported by: 1 module, 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 logbuf holds the log line store with its selection state. It has no rendering dependencies so its logic is testable headless; the ui package draws it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer is the log line store with its selection. It lives for the application lifetime while the widgets rendering it come and go with UI rebuilds. Lines carry monotonic IDs (firstID + index) so the selection stays put when appends trim the front of the buffer.

func New

func New(max int) *Buffer

New creates a buffer bounded to max lines.

func (*Buffer) Append

func (b *Buffer) Append(line string)

Append adds one line and trims the front past the cap. A selection whose lines are trimmed away shrinks with them.

func (*Buffer) ClearSelection

func (b *Buffer) ClearSelection()

ClearSelection drops the selection.

func (*Buffer) DragTo

func (b *Buffer) DragTo(id uint64, col int)

DragTo extends the selection from its anchor to a character.

func (*Buffer) FirstID

func (b *Buffer) FirstID() uint64

FirstID returns the ID of the oldest retained line.

func (*Buffer) HasSelection

func (b *Buffer) HasSelection() bool

HasSelection reports whether a selection exists.

func (*Buffer) Line

func (b *Buffer) Line(id uint64) string

Line returns the text of a line by ID.

func (*Buffer) LineCount

func (b *Buffer) LineCount() int

LineCount returns the number of retained lines.

func (*Buffer) MaxCols

func (b *Buffer) MaxCols() int

MaxCols returns the widest line length ever held.

func (*Buffer) SelSpan

func (b *Buffer) SelSpan(id uint64) (int, int, bool)

SelSpan returns the selected column range of one line, inclusive, and whether the line intersects the selection at all.

func (*Buffer) SelectedText

func (b *Buffer) SelectedText() string

SelectedText renders the selection as plain text with newlines. Lines are stored in full, so clipped display never truncates a copy.

func (*Buffer) StartSelection

func (b *Buffer) StartSelection(id uint64, col int)

StartSelection anchors a new selection at one character.

Jump to

Keyboard shortcuts

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