Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StringStyler ¶ added in v0.4.0
StringStyler attempts to match a string to the lookup map of styles. If the string does not match, it is not changed.
It's useful for styling cells in a table, using the lipgloss.Style Transform method.
Types ¶
type CellStyle ¶
type CellStyle struct {
// Style is the style for the cell.
Style lipgloss.Style
// Format is a printf-style format string for the cell value.
// If not specified, the default format is "%v".
Format string
}
CellStyle specifies a customized style for a cell in a column, overriding the table's Cell and Selected styles.
NOTE: Table renders the row by taking this style and inheriting from the table's Selected/Cell style, Any style attributes from the base Style are overridden if also specified in Selected/Cell style. This may result in unexpected behavior. E.g., if the base Style has a background color, but the base style has a black background, then the column's row will have a black background, which is probably not what you want.
type Column ¶
type Column struct {
// RowStyle overrides the style for row cells in this column, as specified in Styles.Selected and Styles.Cell.
//
// NOTE: Table renders the row by taking this style and inheriting from the table's Selected/Cell style,
// This may result in unexpected behavior. E.g., if the RowStyle specifies a background color,
// but row's style calls for a different background, then the cell will have the RowStyle background,
// which is probably not what you want.
//
// It is recommended to limit use of the CellStyle to set alignment of the cell
// and use the Transform functionality.
RowStyle CellStyle
// Name of the column.
Name string
// Width <= 0 indicates flexible (auto) width to be computed from available space.
Width int
}
Column specifies a column in the table (the name and width), as well as an optional CellStyle to override the table's Cell and Selected styles.
type FilterKeyMap ¶
func DefaultFilterKeyMap ¶ added in v0.4.0
func DefaultFilterKeyMap() FilterKeyMap
func (FilterKeyMap) FullHelp ¶
func (f FilterKeyMap) FullHelp() [][]key.Binding
func (FilterKeyMap) ShortHelp ¶
func (f FilterKeyMap) ShortHelp() []key.Binding
type FilterStateChangeMsg ¶ added in v0.2.0
type FilterStateChangeMsg struct {
State bool
}
FilterStateChangeMsg is sent when the filter is switched on or off. State indicates the new state.
type FilterStyles ¶
type FilterTable ¶ added in v0.4.0
type FilterTable struct {
*Table
// contains filtered or unexported fields
}
func NewFilterTable ¶ added in v0.4.0
func NewFilterTable(title string, cols Columns, rows []Row, styles FilterTableStyles, keymap FilterTableKeyMap) *FilterTable
func (*FilterTable) Init ¶ added in v0.4.0
func (f *FilterTable) Init() tea.Cmd
func (*FilterTable) SetRows ¶ added in v0.6.1
func (f *FilterTable) SetRows(rows []Row)
func (*FilterTable) SetSize ¶ added in v0.6.1
func (f *FilterTable) SetSize(width, height int)
func (*FilterTable) View ¶ added in v0.4.0
func (f *FilterTable) View() string
type FilterTableKeyMap ¶ added in v0.4.0
type FilterTableKeyMap struct {
TableKeyMap KeyMap
FilterKeyMap FilterKeyMap
}
func DefaultFilterTableKeyMap ¶ added in v0.4.0
func DefaultFilterTableKeyMap() FilterTableKeyMap
func (FilterTableKeyMap) FullHelp ¶ added in v0.4.0
func (f FilterTableKeyMap) FullHelp() [][]key.Binding
func (FilterTableKeyMap) ShortHelp ¶ added in v0.4.0
func (f FilterTableKeyMap) ShortHelp() []key.Binding
type FilterTableStyles ¶ added in v0.4.0
type FilterTableStyles struct {
Table Styles
Filter FilterStyles
}
type KeyMap ¶
func DefaultKeyMap ¶ added in v0.4.0
func DefaultKeyMap() KeyMap
type Row ¶
type Row []any
Row is a single row of the table. It is a slice of any type.
By default, row items are formatted with the `fmt.Sprintf("%v", item)` function and styled with the table's Selected & Cell styles. You can override this by setting the `RowStyle` of a column.
For example, to format a cell containing an int as a hex number, you could do this:
table.Column{
Title: "Percentage",
RowStyle: table.CellStyle{Format: "%x"},
}
The number of items in the slice must match the number of columns.
type Table ¶
type Table struct {
SelectedRow Row
// contains filtered or unexported fields
}
func (*Table) Init ¶ added in v0.3.0
Init is called once when the program starts. Always returns nil (no initialization required).