Documentation
¶
Overview ¶
Text rendering shared by every card, markdown, code, diffs, tables and small formatters tuned to the theme
Index ¶
- Constants
- func Bad(text string, t theme.Theme) string
- func Beside(boxes [][]string, width int) []string
- func Bytes(n int64) string
- func ChartInk(recency float64) float64
- func CodeStyle(t theme.Theme) string
- func Columns(cols []Column, rows [][]string, width int) (xs, widths []int)
- func Cool(text string, t theme.Theme) string
- func Dim(text string, t theme.Theme) string
- func Divider(width int, t theme.Theme) string
- func Elapsed(d time.Duration) string
- func Fit(s string, width int, t theme.Theme) string
- func Good(text string, t theme.Theme) string
- func Group(text string, t theme.Theme) string
- func Head(cols []Column) int
- func Heading(text string, t theme.Theme) string
- func Lay(rows, stack []string, corner Corner, width int) []string
- func Money(f float64) string
- func Natural(cols []Column, rows [][]string) []int
- func On(at time.Time) string
- func Paint(st lipgloss.Style, text string) string
- func PaintTimeline(rows [][]ChartRun, colors []color.Color, t theme.Theme, selected int) []string
- func Percent(f float64) string
- func Relative(at time.Time) string
- func ScrollCap(chord, arrow string, t theme.Theme) (glyph, label string)
- func Settled(text string) int
- func ShareBar(n, top int64, width int, t theme.Theme) string
- func Spark(counts []int64, t theme.Theme) string
- func Spinner(tick int, t theme.Theme) string
- func Spread(cols []Column, natural []int, width int) (xs, widths []int)
- func Stretches(moments []Moment, series, rows int, location *time.Location) ([]Stretch, Grain)
- func StyleConfig(t theme.Theme) ansi.StyleConfig
- func Table(cols []Column, rows [][]string, width int, t theme.Theme) string
- func TableEdit(cols []Column, rows [][]string, width int, selected int, edit *Edit, ...) string
- func TableMarked(cols []Column, rows [][]string, width int, selected int, marked func(int) bool, ...) string
- func TableResting(cols []Column, rows [][]string, width int, selected int, t theme.Theme) string
- func Timeline(stretches []Stretch, width int, glyphs ChartGlyphs) [][]ChartRun
- func Tokens(n int) string
- func ToolGlyph(icon string, t theme.Theme) string
- func Truncate(s string, width int, t theme.Theme) string
- func Unmarked(markdown string) string
- func Warm(text string, t theme.Theme) string
- func When(at time.Time) string
- func Widest(cols []Column, cells [][]int) []int
- func Widths(cells []string) []int
- func Wrap(s string, width int) string
- type ChartGlyphs
- type ChartPart
- type ChartRun
- type Column
- type Corner
- type Edit
- type Grain
- type Grid
- type Line
- type Mark
- type Markdown
- type Moment
- type Op
- type ScrollHit
- type Scrollbar
- type Scrolled
- type Stream
- type Stretch
Constants ¶
const ChartLeadIn = 0.06
Recency of the oldest stretch, just off none, so it is still drawn
const MaxDiffLines = 6000
Lines beyond which a diff is summarized instead of computed
const ScrollbarWidth = 40
Width a view needs before it spends its last two columns on a scrollbar, a space and the bar
const TableHead = 2
Rows a table with column titles spends above its first row, the header and the rule under it
Variables ¶
This section is empty.
Functions ¶
func Beside ¶
Boxes side by side at the right of rows of the width, one blank column after each, a box shorter than the tallest padded with blank rows and a row narrower than the widest of its box padded with blanks, so the box after it stands straight
func Bytes ¶
Byte count in the largest unit that fits, as every screen says a size: 512 bytes, 1.5 KB, 5 MB
func ChartInk ¶
Ink of a stretch of the recency, from quiet for the oldest to bright for the newest along an eased gradient
func Divider ¶
Dashed rule of width with the theme info mark at its middle, dashes alone when too narrow for one
func Head ¶
Rows the table of these columns spends above its first row, none when no column has a title
func Lay ¶
Rows of the width with the stack laid over the corner, the stack cut to the rows there are; the rows given are left as they are
func Natural ¶
Width every column takes before it is fitted to a table, over the rows: the widest of its title and its cells, kept to its Max
func On ¶
When something happened as a sentence says it after a verb, in the person's own zone: at the time for today, on the day for this year, else on the day and the year; empty for no time
func Paint ¶
Renders text in the style, restarting the style after every reset inside the text so its background runs unbroken
func PaintTimeline ¶
The rows of a chart painted in the theme: each series in its color, faded toward the background the older its stretch is, the label of the row selected bright, the axis and the counts between series quiet
func Relative ¶
A time to come or gone, in words: now, in 5 minutes, 3 hours ago, or the day and time past a day either way; empty for no time
func ScrollCap ¶
Cap of a paging chord, the theme symbol of its key or an arrow with the chord spelled beside it
func Settled ¶
Offset in the text where the block that later text can still change starts, so everything before it may be printed as it stands: the start of the last paragraph or heading after a blank line, outside fenced code and raw HTML; 0 while no block is closed yet
func ShareBar ¶
Bar of the count's share of the top count in cells of the full width, at least one cell for a count above none
func Spark ¶
The counts as one row of bars of eight heights, the highest count the tallest and none blank
func Spread ¶
Left edge and width of every column at the width, from the widths Natural or Widest gave them, zero for columns dropped from the right to fit
func Stretches ¶
The stretches the moments fall in, oldest first, at the finest grain whose stretches fit the rows, a month of days whatever the rows: stretches holding nothing are left out, and so are moments of no time
func StyleConfig ¶
func StyleConfig(t theme.Theme) ansi.StyleConfig
Glamour style derived from the theme, starting from the dark, light or ASCII set
func TableEdit ¶
func TableEdit(cols []Column, rows [][]string, width int, selected int, edit *Edit, t theme.Theme) string
Renders the table with one cell of the selected row shown as it is being typed into
func TableMarked ¶
func TableMarked(cols []Column, rows [][]string, width int, selected int, marked func(int) bool, edit *Edit, t theme.Theme) string
Renders the table with the cursor row lit and every other marked row tinted as part of the selection
func TableResting ¶
Renders the table of a list that does not have the keys: the row in hand only marked, its cursor dim and its text bold on no lit background
func Timeline ¶
func Timeline(stretches []Stretch, width int, glyphs ChartGlyphs) [][]ChartRun
Rows of a chart of the stretches at the width, one a stretch and under them the trail of what happened in all: each the label of its stretch, the axis, a bar of each series as long as its share of the busiest stretch and never none for a series the stretch holds, the count of each series it holds, now beside the newest stretch and peak beside the busiest. A width too small for notes leaves them out
func ToolGlyph ¶
Glyph of a tool icon a tool registers, such as "read" or "shell", the plain tool glyph for an unknown icon
func Unmarked ¶
The text of markdown with its marks taken out, the words and the lines kept. Emphasis that touches emphasis is taken out on a second pass, as one pass leaves the second of two marks that share the space between them
func When ¶
When something happened, in the person's own zone: the time for today, the day for this year, else the day and the year; empty for no time
Types ¶
type ChartGlyphs ¶
type ChartGlyphs struct {
// Cell of a bar, the axis, and a dot and a star of the trail
Fill, Axis, Dot, Star string
// Notes beside the newest stretch and the busiest
Now, Peak string
}
Marks a chart is drawn with
func ChartGlyphsOf ¶
func ChartGlyphsOf(t theme.Theme) ChartGlyphs
Marks of a chart in the theme: its bar fill and separator, with ASCII marks where the theme draws in ASCII alone
type ChartPart ¶
type ChartPart int
What a run of a row of a chart draws
const ( // Label of a stretch PartLabel ChartPart = iota // The axis between the labels and the bars PartAxis // Bar of one series PartBar // Count of one series, or the plus between two PartCount // Now beside the newest stretch, peak beside the busiest PartNote // Trail of what happened in all, under the bars PartTrail // Cells left blank PartGap )
type ChartRun ¶
type ChartRun struct {
Text string
Part ChartPart
// Series it draws or counts, -1 for none
Series int
// How recent its stretch is, from ChartLeadIn for the oldest to 1 for the newest, which a painter fades older stretches by
Recency float64
}
One run of cells of a row of a chart
type Column ¶
type Column struct {
Title string
// Share of spare width the column takes, zero fitting it to its content
Flex int
// Right aligns the cells, for numbers
Right bool
// Largest width the column grows to, unlimited when zero
Max int
// Holds sentences, which are never cut: a list shows the column only at a width that holds every cell of it whole
Whole bool
}
Column of a table with how its cells align
type Edit ¶
Cell of the selected row being typed into in place, its text with the caret at a rune offset, shown selected until the first keystroke
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
Table at column widths laid out beforehand that paints each line on its own, in styles made once: a long table paints only its rows in view, and its columns, measured over every row, hold still as it scrolls
func NewGrid ¶
Grid of the columns at the widths Columns or Spread laid them out at, in a table width cells wide
type Markdown ¶
type Markdown struct {
// contains filtered or unexported fields
}
Markdown renderer cached per theme and width
func NewMarkdown ¶
func NewMarkdown() *Markdown
func (*Markdown) Lines ¶
Lines of markdown at width in the theme, without the blank lines around them
type Moment ¶
A thing that happened, as a timeline draws it: when, the series it counts in, and the index its owner knows it by
type Scrollbar ¶
type Scrollbar struct {
// Rows tall, lines of content in all, the first line in view and the lines in view
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
}
Scrollbar beside content that scrolls: a column of one cell per row, its caps naming the paging keys, its track a timeline of turns and matches. Pages, lists, forms, the detail of a list, the palette and the transcript of a window all draw this one, in the last column
func (Scrollbar) Column ¶
Cells of the scrollbar from the top, one per row, blank while nothing scrolls
func (Scrollbar) Grab ¶
Row of the thumb a press on row y took hold of, its middle for a press on the track beside it
func (Scrollbar) Hit ¶
Meaning of a click on row y of the scrollbar, and for a jump the first line to show
func (Scrollbar) OnTrack ¶
Reports whether row y lies on the track between the caps while the content scrolls
type Scrolled ¶
type Scrolled struct {
// contains filtered or unexported fields
}
Rows of a body laid beside a scrollbar as last composed: the scrollbar's column drawn again only once the scrollbar changed, and each row composed again only once its text, its cell of the scrollbar or its label changed, so a view that only moved a spinner composes one row again
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Markdown of a text that grows at its end, such as a reply as it streams in. Each run of blocks that no later text can change is rendered once and kept; only the block still open after them is rendered again as the text grows, so a long reply costs the same per word as a short one. The lines read as the whole text rendered at once does