Documentation
¶
Index ¶
- Variables
- type Align
- type Cell
- type Classes
- type Column
- type ColumnGroup
- type ColumnMove
- type ContextMenu
- type DataTable
- type Dump
- type HeaderCell
- type Press
- type Ref
- func (r *Ref) Blur()
- func (r *Ref) ClearMenuTarget()
- func (r *Ref) ColumnWidths() []core.Points
- func (r *Ref) Copy()
- func (r *Ref) Dump(start, end int) Dump
- func (r *Ref) FitColumn(key string) (core.Points, bool)
- func (r *Ref) Focus()
- func (r *Ref) MenuTarget() (Selection, bool)
- func (r *Ref) ScrollToColumn(key string, animated bool)
- func (r *Ref) ScrollToRow(row int, animated bool)
- func (r *Ref) Select(s Selection)
- func (r *Ref) SelectRows(rows []int)
- func (r *Ref) SelectedRows() []int
- func (r *Ref) Selection() Selection
- func (r *Ref) SetColumnWidth(key string, width core.Points)
- func (r *Ref) VisibleColumns() (start, end int)
- func (r *Ref) VisibleRows() (start, end int)
- type Rows
- type Selection
- type Sort
- type Styles
Constants ¶
This section is empty.
Variables ¶
var NoTableSelection = Selection{-1, -1}
NoTableSelection selects nothing.
Functions ¶
This section is empty.
Types ¶
type Cell ¶
type Cell struct {
Row, Column int
Key, Text string
Selected bool
// Tooltip is what CellTooltip says of the cell, empty without one.
Tooltip string
}
Cell is what RenderCell draws: a cell, its text as the table would show it, and whether it, or its row, is selected.
type Classes ¶
type Classes struct {
// Root is the table's box, under its Class.
Root string
Header, GroupCell, HeaderCell, HeaderContent string
HeaderCellDragging, HeaderCellSorted, HeaderCellSelected string
SortIndicator, SortAscending, SortDescending string
ResizeHandle, MoveIndicator string
Row, RowOdd, RowHover, RowSelected, RowActive string
Cell, CellSelected, CellActive, CellColumnSelected string
RowHeader, RowHeaderCorner, FixedEdge, Empty string
CellTooltip string
}
Classes are the Tailwind classes of a DataTable's parts, named as Styles names them, each under its part's style; a state's part follows the part it follows.
type Column ¶
type Column struct {
// Key names the column among the others: the name events and the ref
// use.
Key string
// Title is its title's text; Key when empty.
Title string
// Width is its width (120 when 0); MinWidth and MaxWidth bound what a
// drag or a fit makes it (20 and 1200 when 0).
Width, MinWidth, MaxWidth core.Points
// FitPadding is room for the app's padding, icons or badges, added to
// the widest title or cell text when fitting the column.
FitPadding core.Points
Align Align
// Sortable gives its title a sort button that asks for a sort.
Sortable bool
// Fixed keeps it at the left while the other columns scroll under it;
// fixed columns lead, in their order. With FixedRight too it stays at
// the right instead, those columns closing the order.
Fixed, FixedRight bool
// NoResize and NoMove keep a drag of its edge or title from resizing
// or moving it; NoSelect keeps it and its cells out of selection (a
// column of buttons).
NoResize, NoMove, NoSelect bool
// CellStyle styles its cells after the Cell part, HeaderStyle its
// title after the HeaderCell part, and PositiveStyle and NegativeStyle
// its cells that hold a rise or a fall: a number above or below zero,
// or a text starting with + or -. Their classes go under them.
CellClass, HeaderClass string
PositiveClass, NegativeClass string
CellStyle, HeaderStyle core.Style
PositiveStyle, NegativeStyle core.Style
}
Column is a column of a DataTable.
type ColumnGroup ¶
ColumnGroup is a label over Span columns (1 when 0), or over Span groups of the level below.
type ColumnMove ¶
ColumnMove is a column the user moved: its key, from and to its places as shown, and every column's key in the order shown.
type ContextMenu ¶
ContextMenu is where a context menu was asked for: the row and column under the pointer (-1 for none: a title has no row, a row number no column) and the point in the root view to open the app's Menu at.
type DataTable ¶
type DataTable struct {
Columns func() []Column
// RowCount is how many rows there are; Text the text of a row's cell
// in a column, by its index in Columns.
RowCount func() int
Text func(row, column int) string
// Data holds the rows from DataStart, read by the columns' keys, in
// place of Text: rows outside it show empty until it has them, and
// RowCount, when nil, is where it ends.
Data func() *Rows
DataStart func() int
// RowStyle is a row's own look, after the row's parts, and RowClass
// its classes, after the row's parts' classes.
RowClass func(row int) string
RowStyle func(row int) core.Style
// RowHeight is a body row's height (32 when 0); HeaderHeight a title
// row's (RowHeight when 0).
RowHeight, HeaderHeight core.Points
// Groups are labels above the columns, the lowest level first.
Groups func() [][]ColumnGroup
Sort func() Sort
// What presses and keys select: rows and columns unless NoRowSelect
// and NoColumnSelect, cells while CellSelect returns true. A press with
// Shift or the command key held selects a row unless
// NoSelectOnModifierPress, for an app keeping its own selection of
// several rows with OnRowPress.
NoRowSelect, NoColumnSelect bool
CellSelect func() bool
NoSelectOnModifierPress bool
// MultiSelect makes row selection hold several rows, unless NoRowSelect; cells and columns do not select then, and NoSelectOnModifierPress has no effect. SelectedRows is the app's selected rows when set; otherwise the table keeps them. A plain press or arrow key selects one row, a press with the command key (Control off Apple's keys) toggles one, and a press with Shift selects the range from the anchor, the row last pressed or reached without Shift. Shifted arrows, Page Up/Down and Home/End extend that range, only while the table has the keyboard. Escape clears the rows, and with none selected gives up the keyboard. Selection and Ref.Selection then name only the keyboard's row, and OnSelectionChange does not run: OnSelectedRowsChange reports the rows.
MultiSelect bool
SelectedRows func() []int
// Selection, when set, is the selection; the table keeps its own
// otherwise.
Selection func() Selection
// NoLoopSelection stops the arrow keys at the ends.
NoLoopSelection bool
// RowHeader shows a column of row numbers at the left, which selects
// rows; it shows by default with CellSelect, unless NoRowHeader.
RowHeader, NoRowHeader bool
// Stripe gives the odd rows the RowOdd part while it returns true.
Stripe func() bool
// NoResizeColumns and NoMoveColumns keep every column from being
// resized or moved.
NoResizeColumns, NoMoveColumns bool
// Loading shows LoadingView over the rows and holds OnLoadMore, which
// fires once per number of rows as the rows in view come within
// LoadMoreThreshold (20 when 0) of the last while HasMore.
Loading func() bool
HasMore func() bool
LoadMoreThreshold int
// FontFamily and FontSize (14 when 0) are the cells' font, which
// fitting a column measures in.
FontFamily string
FontSize core.Points
// NoScrollbar hides the scroll bars; NoVerticalScrollbar and
// NoHorizontalScrollbar one of them. NoBounce stops the bounce at the
// ends.
NoScrollbar, NoVerticalScrollbar, NoHorizontalScrollbar bool
NoBounce bool
// Bar draws the scroll bars, over the app's (Scope.SetScrollbars).
Bar core.ScrollbarMaker
// RenderCell and RenderHeaderCell draw the cells and the titles in
// place of their texts, once per slot, the cell it shows changing as
// the table scrolls. What they draw takes no pointer, the table hit
// testing for it, so a ui.Tooltip in a cell never shows: CellTooltip
// gives a cell its tooltip.
RenderCell func(cx *core.Scope, cell func() Cell) core.Node
RenderHeaderCell func(cx *core.Scope, cell func() HeaderCell) core.Node
// CellTooltip is a body cell's tooltip, by row and column index as Text: on desktops it shows above the cell once the pointer has rested on the cell for half a second, until the pointer leaves the cell or presses, and it is the cell's accessibility description. Styles.CellTooltip gives it its look; an empty text shows none. RenderCell's cells read it as Cell.Tooltip.
CellTooltip func(row, column int) string
// Empty shows when there are no rows; LoadingView while Loading.
Empty, LoadingView core.Node
Classes Classes
Styles Styles
StylesFunc func() Styles
// Label is what screen readers call the table, a grid of column
// headers and cells.
Label string
LabelFunc func() string
Class string
Style core.Style
StyleFunc func() core.Style
Ref *Ref
TestID string
// OnLayout and Tooltip are its view's, as a core.View's.
OnLayout func(core.Bounds)
Tooltip core.Node
OnSelectionChange func(Selection)
// OnSelectedRowsChange receives the rows a user selected in MultiSelect mode, in ascending order. It does not run for app or Ref writes.
OnSelectedRowsChange func([]int)
OnRowPress func(Press)
// OnDoublePress receives a row, a cell or a title pressed twice: its
// row and column, -1 for none.
OnDoublePress func(row, column int)
OnContextMenu func(ContextMenu)
// OnSortChange receives the next sort of the cycle unsorted, ascending,
// descending as a sort button is pressed; the zero value clears it.
OnSortChange func(Sort)
// OnColumnResize receives a column's width at every step of a drag
// and when a fit sets it.
OnColumnResize func(key string, width core.Points)
OnColumnMove func(ColumnMove)
// OnVisibleRowsChange and OnVisibleColumnsChange receive the rows and
// the scrolling columns (display indexes) in view, end excluded.
OnVisibleRowsChange func(start, end int)
OnVisibleColumnsChange func(start, end int)
OnLoadMore func()
}
DataTable shows rows and columns as a spreadsheet does and scrolls both ways over any number of either, as gpui-component's: only the cells in view and a reach around them exist as views, made once and given other rows and columns as it scrolls. Rows, columns or cells select with the pointer and the keyboard; columns resize with a drag of their edge (a double press fits them), move with a drag of their title, stay at the left when Fixed and ask for a sort. MultiSelect makes rows toggle and extend with the usual modifiers. It has no look of its own: Styles gives every part its padding, colors and borders.
The rows are the app's: Text gives a cell's text, read where the cells in view show it, so a change of what it reads updates those cells only; OnVisibleRowsChange tells the app which rows to have ready. Sorting is the app's too: OnSortChange asks, and Sort shows what the app did. Past a few million points of content the scroll range is scaled, so a million rows still scroll to every row.
type HeaderCell ¶
HeaderCell is what RenderHeaderCell draws: a column's title, its sort and whether the column is selected.
type Press ¶
Press is a press of a row: the row, the column under it (-1 on a row number), the clicks in a row and the modifier keys.
type Ref ¶
type Ref struct {
// contains filtered or unexported fields
}
Ref is a DataTable's methods, bound once it mounts.
func (*Ref) ClearMenuTarget ¶
func (r *Ref) ClearMenuTarget()
ClearMenuTarget drops the context menu's mark, as the app's menu closes.
func (*Ref) ColumnWidths ¶
ColumnWidths returns the widths now, in the order of Columns.
func (*Ref) Copy ¶
func (r *Ref) Copy()
Copy puts the selection's text on the clipboard: a row's cells with tabs between, a column's with line breaks, a cell's text; in MultiSelect mode the selected rows', one per line.
func (*Ref) FitColumn ¶
FitColumn sets the column key as wide as its widest text and title need, among the rows in view and up to 500 more each side, and returns the width; false for no such column.
func (*Ref) Focus ¶
func (r *Ref) Focus()
Focus gives the table the keyboard, and Blur takes it back.
func (*Ref) MenuTarget ¶
MenuTarget returns what the last context menu was asked for at: a cell, a row or a column, as a selection names them; false when no mark is shown.
func (*Ref) ScrollToColumn ¶
ScrollToColumn scrolls the column key into view.
func (*Ref) ScrollToRow ¶
ScrollToRow scrolls row into view.
func (*Ref) SelectRows ¶ added in v0.2.0
SelectRows selects rows in MultiSelect mode, without OnSelectedRowsChange, and brings the last one into view; Shift extends from it.
func (*Ref) SelectedRows ¶ added in v0.2.0
SelectedRows returns the rows selected in MultiSelect mode, in ascending order. It returns nil for a table that is not in that mode.
func (*Ref) SetColumnWidth ¶
SetColumnWidth sets the column key's width, within its limits.
func (*Ref) VisibleColumns ¶
VisibleColumns returns the scrolling columns in view, as display indexes, end excluded.
func (*Ref) VisibleRows ¶
VisibleRows returns the rows in view, end excluded.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows are a table's rows a column at a time, each column of one type, so a million rows take a slice a column and a cell's text is made only when the cell shows.
func NewRows ¶
NewRows returns length rows with no columns: a cell of a column they do not have is empty.
func (*Rows) Numbers ¶
Numbers sets the column of key to values, shown without a trailing .0; NaN is a gap.
type Selection ¶
type Selection struct{ Row, Column int }
Selection is what a DataTable selects: a row, a column (its index in Columns), or both for a cell; -1 for neither. NoTableSelection selects nothing.
type Sort ¶
Sort is what the data is sorted by: a column's key and the direction. The zero value is unsorted.
type Styles ¶
type Styles struct {
// Header is the header across the table; GroupCell a group label;
// HeaderCell every title, HeaderContent the row of its label and sort
// button, and HeaderCellDragging, HeaderCellSorted and
// HeaderCellSelected the dragged, sorted and selected column's title.
Header, GroupCell, HeaderCell, HeaderContent core.Style
HeaderCellDragging, HeaderCellSorted, HeaderCellSelected core.Style
// SortIndicator is a sortable column's sort button; SortAscending and
// SortDescending its chevrons, whose Selected state is the sorted
// direction's.
SortIndicator, SortAscending, SortDescending core.Style
// ResizeHandle is the line at a column's trailing edge a drag resizes;
// MoveIndicator the line where a dragged column will drop.
ResizeHandle, MoveIndicator core.Style
// Row is every body row; RowOdd the odd ones (Stripe), RowHover the one
// under the pointer, RowSelected the selected one and RowActive the
// one a context menu was asked for where cells do not select.
Row, RowOdd, RowHover, RowSelected, RowActive core.Style
// Cell is every body cell; CellSelected the selected one, CellActive
// the one a context menu was asked for, CellColumnSelected those of the
// selected column.
Cell, CellSelected, CellActive, CellColumnSelected core.Style
// RowHeader is a row number's cell and RowHeaderCorner the corner
// above them; FixedEdge the line at the fixed columns' trailing edge;
// Empty the box of the Empty node.
RowHeader, RowHeaderCorner, FixedEdge, Empty core.Style
// CellTooltip is the box of a cell's tooltip (DataTable.CellTooltip), around its text.
CellTooltip core.Style
}
Styles are the styles of a DataTable's parts, which supply its whole look; a state's part merges over the part it follows.