render

package
v2.0.5-main.4 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 28 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 render has the text rendering that every card shares: markdown, code, diffs, tables and small formatters tuned to the theme.

Index

Constants

View Source
const BarWidth = 1

BarWidth is the number of columns that the scrollbar itself takes, in the last column inside a pane's rail. The rail's other columns are always blank, so a highlighted row's background never reaches the bar.

View Source
const ChartLeadIn = 0.06

ChartLeadIn is the oldest stretch's recency, just above zero, so the stretch is still drawn.

View Source
const ColumnGap = 3

ColumnGap is the number of blank columns between two cells in a row.

View Source
const MaxDiffLines = 6000

MaxDiffLines is the line count above which a diff is summarized instead of computed.

View Source
const ScrollbarWidth = 40

ScrollbarWidth is the width that a view needs before it gives the scrollbar's rail its last space.Rail columns.

View Source
const Stays = math.MaxInt

Stays is the rank for a column that never leaves, such as a list's name column after a mark column. A staying column wider than its share of the width wraps its cells over more lines. The first column always stays.

View Source
const TabWidth = 4

TabWidth is the number of cells between two tab stops when Untab expands the tabs in text that a card shows.

Variables

This section is empty.

Functions

func Axis

func Axis(width int, ticks ...Tick) string

Axis returns a row up to width cells wide that sets each tick's label at its column, measured in cells, under one-cell marks such as a spark line. A label that would run into the previous label or past the width is left out.

func Bad

func Bad(text string, t theme.Theme) string

Text in the alarm color

func Beside

func Beside(boxes [][]string, width, gap int) []string

Beside returns boxes side by side at the right of rows at the width, with gap blank columns between each two boxes, the inset that windows keep between each other. A box shorter than the tallest box is padded with blank rows, and a row narrower than its box's widest row is padded with blanks, so the next box lines up.

func Blocks

func Blocks(blocks ...[]string) []string

Blocks returns the blocks in order with space.Gap blank rows between each two, the way a pane sets its own blocks apart. Empty blocks are left out, so a missing block never doubles a gap.

func Bytes

func Bytes(n int64) string

Bytes returns a byte count in the largest unit that fits, the way every screen shows a size: 512 bytes, 1.5 KB, 5 MB.

func Carry

func Carry(lines []string) []string

Carry carries the styling of lines cut from one text over the breaks between them, in place. Each line opens with the style sequences in force at the previous line's end, and a line that leaves a style in force ends with a reset, so every line keeps the style it had in the text.

func ChartInk

func ChartInk(recency float64) float64

ChartInk returns the ink for a stretch at the recency, from quiet for the oldest stretch to bright for the newest, along an eased gradient.

func Clock

func Clock(d time.Duration) string

Clock returns a running time in whole seconds with every part it has reached: seconds, then minutes and seconds, then hours, minutes and seconds. A part never leaves once it shows, so the text only grows as the time runs, and a time that has run for hours shows to the second as it did in its first minute.

func CodeStyle

func CodeStyle(t theme.Theme) string

CodeStyle returns the chroma style name that suits the theme.

func Cool

func Cool(text string, t theme.Theme) string

Text in the ice color

func Dim

func Dim(text string, t theme.Theme) string

Dim text for secondary information

func Divider

func Divider(width int, t theme.Theme) string

Divider returns a dashed rule that is width cells wide, with the theme's info mark in its middle by the same rule that centers text: an odd dash goes to the right of the mark. A rule too narrow for the mark has only dashes.

func Elapsed

func Elapsed(d time.Duration) string

Duration rounded to a readable unit

func Facts

func Facts(facts []Fact, width int, t theme.Theme) []string

Facts returns the facts in two columns that fit in width cells, laid out like a form's labels and values: each label dim in a column as wide as the widest label, ColumnGap blank columns, then its value. A value wraps in its own column, and a label too wide for its column wraps in it. A width too narrow for both columns puts each value under its label. A fact with a value that shows nothing, such as an empty or only styled value, is left out.

func Fit

func Fit(s string, width int) string

Fit pads a line with blanks to width columns. It never cuts: the caller wraps its text to the width first (Wrap), so a line wider than the width comes back unchanged.

func Good

func Good(text string, t theme.Theme) string

Text in the alive color

func Group

func Group(text string, t theme.Theme) string

Group returns a list's group heading, in capitals.

func Heading

func Heading(text string, t theme.Theme) string

Section heading in bold text

func Height

func Height(cells []string, sizes, widths []int) int

Height returns the number of lines that a row takes with its columns at the widths: one, and more where a cell is wider than its column and wraps in it. Sizes has the cells' widths measured beforehand, so only a cell wider than its column is wrapped to count its lines. It counts the lines exactly the way Grid.Lines paints them.

func Item

func Item(mark string, lines []string, width int) []string

Item returns a list item's lines that fit in width cells: the mark, such as a number or a bullet, a blank, then the first line, with every other line and every wrapped part set under the text after the mark. Without a mark the lines are only wrapped.

func Lay

func Lay(rows, stack []string, corner Corner, width int) []string

Lay returns the rows at the width with the stack over the corner. Each covered row splits at the stack's edge: the stack's row takes the columns it covers, and the row keeps the rest. This composes the two without cutting any text out of the stack. The caller sizes the stack to fit the rows, and stack rows past the last row only guard against a taller stack. It leaves the given rows unchanged.

func LeftCells

func LeftCells(cols []Column, left []bool, cells []string, width int, t theme.Theme) []string

LeftCells returns a row's cells in the left columns, laid out in width cells: first the untitled columns' cells, each wrapped on its own lines, then the other cells as labeled values under their column titles (Facts). Empty cells are left out.

func Money

func Money(f float64) string

Money returns dollars with cents, or with cent fractions for tiny amounts.

func Natural

func Natural(cols []Column, rows [][]string) []int

Natural returns each column's natural width over the rows: its title's width in capitals or its widest cell's width, whichever is larger.

func Nested

func Nested(depth int, text string) string

Nested returns the text set in by depth levels of space.Lead cells, for a row in a tree such as a report's rows under a row.

func On

func On(at time.Time) string

On returns the moment the way a sentence puts it after a verb, in the user's own zone: at the time for today, on the day for this year, otherwise on the day and the year. It returns empty text for a zero time.

func Paint

func Paint(st lipgloss.Style, text string) string

Renders text in the style, restarting the style after every reset inside the text so its background runs unbroken

func PaintTimeline

func PaintTimeline(rows [][]ChartRun, colors []color.Color, t theme.Theme, selected int) []string

PaintTimeline returns a chart's rows painted in the theme: each series in its color, faded toward the background by its stretch's age, the selected row's label bright, and the axis and the pluses between counts quiet.

func Percent

func Percent(f float64) string

Share as a whole percentage

func Relative

func Relative(at time.Time) string

Relative returns a future or past time in words: now, in 5 minutes, 3 hours ago, or the day and time beyond a day either way. It returns empty text for a zero time.

func Section

func Section(title string, lines []string, t theme.Theme) []string

Section returns a block under a heading in a list's group heading style: the heading's row, then the lines. It returns nil for empty lines, so an empty section never shows a bare heading.

func Settled

func Settled(text string) int

Settled returns the offset where the text's block that later text can still change starts, so everything before it can print unchanged: the start of the last paragraph or heading after a blank line, outside fenced code and raw HTML. It returns 0 while no block is closed yet.

func ShareBar

func ShareBar(n, top int64, width int, t theme.Theme) string

ShareBar returns a bar for n's share of top, where top fills width cells, and at least one cell for a count above zero.

func Spark

func Spark(counts []int64, t theme.Theme) string

Spark returns the counts as one row of bars in eight heights, the highest count the tallest and a zero count blank.

func Spinner

func Spinner(tick int, t theme.Theme) string

Spinner frame for a tick from the theme frames

func Stretches

func Stretches(moments []Moment, series, rows int, location *time.Location) ([]Stretch, Grain)

Stretches returns the stretches around the moments, oldest first, at the finest grain with stretches that fit the rows, and in days for a month of days regardless of the rows. Empty stretches are left out, and so are moments without a time.

func StyleConfig

func StyleConfig(t theme.Theme) ansi.StyleConfig

StyleConfig returns a glamour style made from the theme, starting from the dark, light or ASCII set.

func Table

func Table(cols []Column, rows [][]string, width int, t theme.Theme) string

Table renders a read-only table, such as a report: the titles, then the rows, each starting at column zero. Every cell shows whole: a cell wider than its staying column wraps over more lines, and each left column's cells show under their row, set in by space.Lead (LeftCells).

func Timeline

func Timeline(stretches []Stretch, width, inset int, glyphs ChartGlyphs) [][]ChartRun

Timeline returns a chart's rows for the stretches at the width: one row per stretch, then the running total's trail. Each row has the stretch's label, the axis, a bar per series as long as its share of the busiest stretch, at least one cell for every series in the stretch, the count per series, now beside the newest stretch and peak beside the busiest stretch. The axis is a vertical line, so inset blank columns sit on each side of it: the inset that a frame keeps inside its border. The bars, the counts and the notes are ColumnGap apart, like a table's columns. Every row fits the width, and a width too small for all of it gives way in this order, never by giving up a blank: the notes leave first, then the counts while the bars stay at least barLeast wide, then the axis and the bars leave with the trail and the labels keep their counts beside them, then the counts leave too, and a width too small for the labels leaves the rows empty.

func Titled

func Titled(cols []Column) bool

Titled reports whether any column has a title, so a table with these columns has a row of titles above its rows.

func Tokens

func Tokens(n int) string

Token count with a k or M suffix past a thousand

func ToolGlyph

func ToolGlyph(icon string, t theme.Theme) string

ToolGlyph returns the glyph for a tool icon that a tool registers, such as "read" or "shell", and the plain tool glyph for an unknown icon.

func Unmarked

func Unmarked(markdown string) string

Unmarked returns the markdown's text without its markup, with the words and the lines kept. Emphasis next to emphasis comes out on a second pass, because one pass leaves the second of two marks that share the space between them.

func Untab

func Untab(text string) string

Untab returns the text with each tab expanded to blanks up to the next tab stop, counted in cells from the start of the tab's line. A card measures its text in cells, and a tab has no width until the terminal draws it, so text with tabs would not line up.

func Warm

func Warm(text string, t theme.Theme) string

Text in the accent color

func When

func When(at time.Time) string

When returns the moment in the user's own zone: the time for today, the day for this year, otherwise the day and the year. It returns empty text for a zero time.

func Widest

func Widest(cols []Column, cells [][]int) []int

Widest returns each column's natural width from cell widths measured beforehand row by row: its title's width in capitals or its widest cell's width, whichever is larger. A long table measures each cell once and lays its columns out again from those widths. The title is measured in capitals because the titles row shows it that way, and a capital can be wider than its small letter.

func Widths

func Widths(cells []string) []int

Widths returns the width of every cell.

func Wrap

func Wrap(s string, width int) string

Wrap wraps a string at width, breaking long words. Styling carries over the breaks, so each line reads in the style the text had there.

Types

type ChartGlyphs

type ChartGlyphs struct {
	// Fill is a bar's cell, Axis is the axis, and Dot and Star are the trail's marks
	Fill, Axis, Dot, Star string
	// Now and Peak are the notes beside the newest stretch and the busiest stretch
	Now, Peak string
}

ChartGlyphs has a chart's marks.

func ChartGlyphsOf

func ChartGlyphsOf(t theme.Theme) ChartGlyphs

ChartGlyphsOf returns a chart's marks in the theme: its bar fill and separator, with ASCII marks when the theme draws only in ASCII.

type ChartPart

type ChartPart int

ChartPart is what a run in a chart row draws.

const (
	// PartLabel is a stretch's label
	PartLabel ChartPart = iota
	// PartAxis is the axis between the labels and the bars
	PartAxis
	// PartBar is one series' bar
	PartBar
	// PartCount is one series' count, or the plus between two counts
	PartCount
	// PartNote is now beside the newest stretch, or peak beside the busiest stretch
	PartNote
	// PartTrail is the running total's trail under the bars
	PartTrail
	// PartGap is blank cells
	PartGap
)

type ChartRun

type ChartRun struct {
	Text string
	Part ChartPart
	// Series is the series that the run draws or counts, and -1 when it has no series
	Series int
	// Recency is the stretch's recency, from ChartLeadIn for the oldest stretch to 1 for the newest stretch. A painter fades older
	// stretches by it
	Recency float64
}

ChartRun is one run of cells in a chart row.

type Column

type Column struct {
	Title string
	// Flex is the column's share of the width that the shown columns leave spare. A column without a share is as wide as its widest cell
	// or its title, whichever is wider.
	Flex int
	// Right aligns the cells to the right, for numbers.
	Right bool
	// Rank orders the columns that leave when the width cannot fit every column at its natural width. The column with the lowest rank
	// leaves first, and of two columns with one rank the later column leaves first, so a table without ranks loses its columns from the
	// last toward the first. Zero is the default rank. A column that should leave before the default, such as a long free-text column, has
	// a negative rank, and a column that should outlast the default has a positive rank. The first column, and every column ranked Stays,
	// never leaves. A left column's cells are not lost: a list shows them first in the selected row's detail pane, and a static table shows
	// them under each row (LeftCells).
	Rank int
}

Column is a table column: its title, how its cells align, its share of the spare width, and its rank among the columns that leave a width too narrow for every column. A table never cuts a cell. Every column it shows is as wide as its widest cell and its title, and a column that does not fit leaves whole.

type Corner

type Corner int

Corner is the corner of the rows that Lay puts a stack of rows over.

const (
	TopLeft Corner = iota
	TopRight
	BottomLeft
	BottomRight
)

type Edit

type Edit struct {
	Col      int
	Text     string
	Cursor   int
	Selected bool
}

Edit is the selected row's cell that is being typed into in place: its text with the caret at a rune offset, shown selected until the first keystroke.

type Fact

type Fact struct {
	Label string
	Value string
}

Fact is one labeled value that Facts lays out, such as a profile's folder.

type Grain

type Grain int

Grain is the length of each stretch in a timeline.

const (
	Daily Grain = iota
	Weekly
	Monthly
	Yearly
)

type Grid

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

Grid is a table at column widths laid out beforehand, which paints each row on its own in styles made once. A long table paints only its visible rows, and its columns, measured over every row, stay still while it scrolls. Each line is width columns: lead columns before the first cell, with the selected row's mark in their first column on the row's first line, then the cells. A cell wider than its column wraps in it, so its row takes more lines. A lit row's background runs the full width on every line of the row.

func NewGrid

func NewGrid(cols []Column, widths []int, lead, width int, t theme.Theme) *Grid

NewGrid returns a grid for the columns at the widths from Columns or Spread. Lead is the number of columns before the first cell, and width is every line's width with the lead.

func (*Grid) EditSpot

func (g *Grid) EditSpot(ed Edit, tall int) (x, line int)

EditSpot returns where the edit's caret shows in a row that takes tall lines: its column, counted from the line's first column, and its line in the row. The typed text shows in the edit's column, or across every shown column when that column left the width.

func (*Grid) Height

func (g *Grid) Height(cells []string) int

Height returns the number of lines that Lines paints a row's cells in at the grid's column widths.

func (*Grid) Lines

func (g *Grid) Lines(cells []string, mark Mark, edit *Edit) []string

Lines returns a row's lines painted as marked, the cell that the edit names shown as it is being typed into on the lit row. A row takes one line, and more where a cell is wider than its column and wraps in it (Height counts them). Every line of the row has the row's look, and only the first line has the row's mark.

func (*Grid) Titles

func (g *Grid) Titles() []string

Titles returns the lines above the rows: the column titles in capitals, dim, the same look as a group heading. A title wider than its column, which happens only to a staying column narrowed to the width, wraps in it over more lines. It returns none when no column has a title.

type Grip

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

Grip is a scrollbar's pointer state, which every scrolling pane keeps beside its bar: the bar row under the pointer, which lights the part there, and the thumb row held through a drag. A pane dresses its bar with the grip (On) whenever it builds the bar.

func (*Grip) Drag

func (g *Grip) Drag(s Scrollbar, y int, pressed bool) (int, bool)

Drag follows the pointer at bar row y while the thumb is held, wherever the pointer is, and returns the offset that keeps the held thumb row under the pointer. pressed is false when the pointer moved with no button down: the release was missed, so the thumb is released. It reports false while the thumb is not held.

func (*Grip) Drop

func (g *Grip) Drop() bool

Drop forgets the pointer and releases the thumb, for a bar that is no longer drawn, and reports whether either was set.

func (Grip) Holding

func (g Grip) Holding() bool

Holding reports whether the thumb is held through a drag.

func (*Grip) Hover

func (g *Grip) Hover(s Scrollbar, y int, on bool) bool

Hover puts the pointer on bar row y while on is true, and off the bar otherwise, and reports whether the bar's lit part changed, which is the only case in which the pane draws again.

func (Grip) On

func (g Grip) On(s Scrollbar) Scrollbar

On returns the bar with the grip's pointer and hold on it, so the bar lights the part the pointer is on.

func (*Grip) Press

func (g *Grip) Press(s Scrollbar, y int) (ScrollHit, int)

Press takes a left press on bar row y. A cap returns its page request, which the pane carries out with its own paging. A press on the track grabs the thumb and returns ScrollJump with the offset to show: the same offset on the thumb, and beside it the offset that puts the thumb's middle under the pointer. The drag then follows the pointer until the button comes up (Drag).

func (*Grip) Release

func (g *Grip) Release() bool

Release releases the thumb and reports whether it was held.

type Layout

type Layout struct {
	// Xs has each column's left edge, counted from the first cell, and Widths has its width. A column without width takes no room in a row,
	// not even the gap before it, so the next column starts where it would have started. A column that left has no width, and neither has
	// a column without a title, cells or a share of the spare width.
	Xs, Widths []int
	// Left marks the columns that left because the width cannot fit them. A column without a title or cells never counts as left.
	Left []bool
}

Layout is a table's columns fitted to a width.

func Columns

func Columns(cols []Column, rows [][]string, width int) Layout

Columns returns the columns fitted to cells width columns wide over the rows (Spread).

func Spread

func Spread(cols []Column, natural []int, width int) Layout

Spread fits the columns, at the natural widths that Natural or Widest gave them, into cells width columns wide. While the columns do not fit, they leave whole one by one in rank order (Column.Rank). If the columns that stay are still wider than the width, their widest column narrows until they fit and wraps its cells over more lines. The flex columns share the width that the columns leave spare. Which columns leave depends on the width and the natural widths only, so it is the same for every row.

func (Layout) Gone

func (l Layout) Gone() bool

Gone reports whether any column left the width.

type Line

type Line struct {
	Op   Op
	Text string
	Old  int
	New  int
}

Line is one diff line with its line numbers before and after the change.

type Mark

type Mark int

Mark says how a table row is painted.

const (
	// A row like the others
	Plain Mark = iota
	// The selected row, lit
	Lit
	// An unfocused table's selected row, only marked: its cursor dim and its text bold, without a lit background
	Held
)

type Markdown

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

Markdown is a markdown renderer cached per theme and width. It lays out the tables in the markdown itself, and glamour renders the rest.

func NewMarkdown

func NewMarkdown() *Markdown

NewMarkdown returns a markdown renderer with an empty cache.

func (*Markdown) Lines

func (m *Markdown) Lines(src string, width int, t theme.Theme) []string

Lines returns the markdown's lines at width in the theme, without the blank lines around them, except the space.Gap blank rows that set a horizontal rule at either end apart from whatever a card shows beside the lines. A tab in the source takes the columns up to its next stop, no line is wider than the width, so a pane's text never runs on past its last text column (see fitted), and a rule keeps space.Gap rows from the text around it (see ruledApart and layTable).

func (*Markdown) Render

func (m *Markdown) Render(src string, width int, t theme.Theme) string

Render returns the markdown's lines from Lines, joined into one string.

type Moment

type Moment struct {
	At     time.Time
	Series int
	Index  int
}

Moment is an event that a timeline draws: its time, its series, and its index in the owner's list.

type Op

type Op int

Op is a diff line's kind.

const (
	Same Op = iota
	Added
	Removed
)

type ScrollHit

type ScrollHit int

ScrollHit is the request that a click on a scrollbar makes.

const (
	// ScrollNone is a click that misses the scrollbar, or a click while nothing scrolls.
	ScrollNone ScrollHit = iota
	// ScrollPageUp is a page toward the start, from the top cap.
	ScrollPageUp
	// ScrollPageDown is a page toward the end, from the bottom cap.
	ScrollPageDown
	// ScrollJump is a press on the track, which grabs the thumb: on the thumb it keeps the offset, and beside it the thumb's middle jumps
	// to the pressed place.
	ScrollJump
)

type ScrollPart

type ScrollPart int

ScrollPart is a part of a scrollbar, which lights while the pointer is on it.

const (
	// PartNone means that the pointer is off the bar, or that nothing scrolls.
	PartNone ScrollPart = iota
	// PartUp is the top cap, which pages toward the start.
	PartUp
	// PartDown is the bottom cap, which pages toward the end.
	PartDown
	// PartTrack is the track beside the thumb.
	PartTrack
	// PartThumb is the thumb.
	PartThumb
)

type Scrollbar

type Scrollbar struct {
	// Height in rows, the total content lines, the first visible line and the visible line count
	Height, Total, Offset, Visible int
	// Lines that start a turn, ticked along the track, and lines holding a search match
	Marks, Hits []int
	// Chords that page up and down, shown on the caps
	Up, Down string
	// Point is one past the bar row under the pointer, and zero while the pointer is off the bar. Held reports whether the thumb is held
	// through a drag. Together they light the part of the bar that the pointer is on.
	Point int
	Held  bool
}

Scrollbar is the scrollbar beside scrolling content: a column with one cell per row, caps that show the paging keys, and a track that marks turns and matches, with a thumb as long as the content's visible share. Every scrolling pane draws it in its rail's last column, and a Grip keeps its pointer state.

The bar shows only while the content runs past the visible rows. Three rows or more show both caps and a track between them, two rows show only the caps, and one row shows the one cap that pages toward the content left to see: down until the end, then up.

func (Scrollbar) Column

func (s Scrollbar) Column(t theme.Theme) []string

Column returns the scrollbar's cells from the top, one per row, blank while nothing scrolls. It draws from the theme's colors and glyphs, so the bar reads the same way in the ASCII glyph set and the plain style.

func (Scrollbar) DragTo

func (s Scrollbar) DragTo(y, held int) int

DragTo returns the offset that puts the thumb's held row under bar row y. The pointer may be anywhere, above or under the bar included: the thumb stops at its track's ends. An offset that keeps the thumb in place stays unchanged, so grabbing the thumb never moves the content, and the thumb at either end of its track shows the content's start or its end exactly. Between the ends, it returns the offset that puts the thumb nearest the pointer.

func (Scrollbar) Grab

func (s Scrollbar) Grab(y int) int

Grab returns the thumb row that a press on row y grabbed, or the thumb's middle for a press on the track beside it, where the thumb then jumps.

func (Scrollbar) Hit

func (s Scrollbar) Hit(y int) (ScrollHit, int)

Hit returns the meaning of a press on scrollbar row y, and for a press on the track the offset it moves to: the offset unchanged on the thumb, and beside the thumb the offset that puts the thumb's middle on the row pressed.

func (Scrollbar) Lit

func (s Scrollbar) Lit() ScrollPart

Lit returns the part of the bar that lights: the thumb while it is held, otherwise the part under the pointer.

func (Scrollbar) OnTrack

func (s Scrollbar) OnTrack(y int) bool

OnTrack reports whether row y lies on the track between the caps while the content scrolls, where a press grabs the thumb.

func (Scrollbar) Part

func (s Scrollbar) Part(y int) ScrollPart

Part returns the part of the bar on row y, PartNone off the bar or while nothing scrolls.

func (Scrollbar) Same

func (s Scrollbar) Same(o Scrollbar) bool

Same reports whether two scrollbars draw the same, including their marks, their hits and their lit part.

func (Scrollbar) Scrolls

func (s Scrollbar) Scrolls() bool

Scrolls reports whether the content runs past the visible rows.

type Scrolled

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

Scrolled keeps a body's rows laid beside a scrollbar at the last paint. The scrollbar's column is drawn again only when the scrollbar changed, and each row is composed again only when its text or its scrollbar cell changed, so a view that only moved a spinner composes one row again.

func (*Scrolled) Lay

func (b *Scrolled) Lay(bar Scrollbar, body []string, w int, t theme.Theme) []string

Lay returns the body's rows beside the scrollbar in a pane w columns wide, one row for each scrollbar row: each row fitted to the pane's width less the bar, then the scrollbar's cell in the pane's last column. A row, a highlighted row's background included, ends before the rail, so the rail's blank columns stay blank and set every row and every highlight apart from the bar.

type Stream

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

Stream renders the markdown for a text that grows at its end, such as a streaming reply. Each run of blocks that no later text can change is rendered once and kept. Only the open block after them is rendered again as the text grows, so a long reply costs the same per word as a short one. The lines equal the full text rendered at once.

func (*Stream) Lines

func (s *Stream) Lines(m *Markdown, text string, width int, t theme.Theme) []string

Lines returns the text's lines at width in the theme. When the text is the last text with more after it, only the open block renders again. Any other text, width or theme starts over.

func (*Stream) Reset

func (s *Stream) Reset()

Reset forgets the rendered lines, such as for a text that was removed with its session.

type Stretch

type Stretch struct {
	// Start is its first moment, and End is the next stretch's first moment
	Start, End time.Time
	Label      string
	// Counts has each series' moment count in the stretch, and Moments has the moments, oldest first
	Counts  []int
	Moments []Moment
}

Stretch is a stretch in a timeline, with the moments in it.

func (Stretch) Total

func (s Stretch) Total() int

Total returns the stretch's moment count over every series.

type Tick

type Tick struct {
	At   int
	Text string
	End  bool
}

Tick is a label that Axis sets under a row with one-cell marks. It starts at column At, or ends there when End is set.

Jump to

Keyboard shortcuts

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