Documentation
¶
Overview ¶
Package rowtext lays out the text of one row of cells across the columns on screen, as Sheets does: values formatted and aligned, text running on into blank neighbors, cut to column boundaries in a single pass. It reads the sheet and nothing else, so drawing the grid can be measured and tested on its own.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Line ¶ added in v0.3.0
type Line struct{ K, N int }
Line is one line of a row: the K-th of its N, from 0 at the top.
type Scratch ¶ added in v0.3.0
type Scratch struct {
// contains filtered or unexported fields
}
Scratch keeps the slices a layout works in, so the lines of a frame reuse them rather than allocate their own. The spans a layout through it returns hold until its next layout.
type Shape ¶ added in v0.3.0
Shape is how a row is laid out: whether a border line comes above it, and how many lines its cells take.
type Shapes ¶ added in v0.3.0
type Shapes struct {
// contains filtered or unexported fields
}
Shapes works out the shape of rows as the grid asks for them, and keeps them until the sheet changes.
type Span ¶
type Span struct {
Lead int
Text string
Trail int
Style sheet.Style
Owner int // column of the cell the text belongs to
// Left for the caller to fill in from the owner's value.
Link string // the owner's link target, drawn as a hyperlink
Error bool // the owner shows an error: its text gets the error mark
// Invalid is set when the owner fails its data validation: its text
// gets the invalid mark.
Invalid bool
}
Span is what one grid column shows in a row: blank columns, the text, blank columns. Only the text takes the owning cell's text style, so an underline doesn't run into the padding.
func Layout ¶
Layout lays out ncols columns of row from lo, each span exactly its column's width. Text may run in from columns between minCol and maxCol, so it stops at the frozen columns' divider. Values are formatted with their cell's number format and aligned as Sheets does: numbers right, text left, booleans and errors centered, unless the cell sets an alignment. Text runs on into blank neighbors: to the right when left-aligned, to the left when right-aligned, both ways when centered. It can come from cells outside the viewport, so the scan starts at the nearest filled cell on each side.
func LayoutLine ¶ added in v0.3.0
LayoutLine is Layout for one line of a row N lines tall. Values sit on the row's last line, as Sheets aligns them to the bottom, or its first or middle one as the cell's vertical alignment says, and text that wraps (sheet.WrapOn) fills lines of its own column around there, cut at the bottom when the row is too short. Clipped text (sheet.WrapClip) stays in its column. Text doesn't run on across a border or into merged cells, whose contents the caller draws (see Merged).