Documentation ¶
Index ¶
- Constants
- type Ordered
- type Table
- func (r *Table) AddRows(rows [][]any) (*Table, error)
- func (r *Table) ClearRows() *Table
- func (r *Table) CursorDown() *Table
- func (r *Table) CursorLeft() *Table
- func (r *Table) CursorRight() *Table
- func (r *Table) CursorUp() *Table
- func (r *Table) GetCursorLocation() (int, int)
- func (r *Table) GetCursorValue() string
- func (r *Table) GetFilter() (columnIndex int, s string)
- func (r *Table) GetOrder() (int, int)
- func (r *Table) MustAddRows(rows [][]any) *Table
- func (r *Table) OrderByAsc(index int) *Table
- func (r *Table) OrderByColumn(index int) *Table
- func (r *Table) OrderByDesc(index int) *Table
- func (r *Table) Render() string
- func (r *Table) SetFilter(columnIndex int, s string) *Table
- func (r *Table) SetHeight(value int) *Table
- func (r *Table) SetMinWidth(values []int) *Table
- func (r *Table) SetRatio(values []int) *Table
- func (r *Table) SetStylePassing(value bool) *Table
- func (r *Table) SetStyles(styles map[TableStyleKey]lipgloss.Style) *Table
- func (r *Table) SetTypes(columnTypes ...any) (*Table, error)
- func (r *Table) SetWidth(value int) *Table
- func (r *Table) UnsetFilter() *Table
- type TableBadCellTypeError
- type TableBadTypeError
- type TableRowLenError
- type TableSingleType
- type TableSortingOrderKey
- type TableStyleKey
Constants ¶
const ( TableSortingAscending = 0 TableSortingDescending = 1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table responsive, x/y scrollable table that uses magic of FlexBox
func (*Table) AddRows ¶
AddRows add multiple rows, will return error on the first instance of a row that does not match the type set on table will update rows only when there are no errors
func (*Table) ClearRows ¶ added in v1.4.1
ClearRows removes all previously added rows, can be used as part of an update loop
func (*Table) CursorRight ¶
CursorRight move table cursor right
func (*Table) GetCursorLocation ¶
GetCursorLocation returns the current x,y position of the cursor
func (*Table) GetCursorValue ¶
GetCursorValue returns the string of the cell under the cursor
func (*Table) GetFilter ¶
GetFilter returns string used for filtering and the column index TODO: enable multi column filtering
func (*Table) GetOrder ¶ added in v1.4.1
GetOrder returns the current order column index and phase (0 for asc, 1 for desc)
func (*Table) MustAddRows ¶
MustAddRows executes AddRows and panics if there is an error
func (*Table) OrderByAsc ¶ added in v1.4.1
OrderByAsc orders rows by a column with index n, in ascending order
func (*Table) OrderByColumn ¶
OrderByColumn orders rows by a column with the index n, simple bubble sort, nothing too fancy does not apply when there is less than 2 row in a table Deprecated: this function will be removed in a future release TODO: this messes up numbering that one might use, implement automatic indexing of rows TODO: allow user to disable ordering
func (*Table) OrderByDesc ¶ added in v1.4.1
OrderByDesc orders rows by a column with index n, in descending order
func (*Table) SetMinWidth ¶
SetMinWidth replaces the minimum width slice, it has to be exactly the len of the headers/rows slices if it's not matching len it will trigger fatal error
func (*Table) SetRatio ¶
SetRatio replaces the ratio slice, it has to be exactly the len of the headers/rows slices also each value have to be greater than 0, if either fails we panic
func (*Table) SetStylePassing ¶
SetStylePassing sets the style passing flag, if true, styles are passed all the way down from box to cell
func (*Table) SetStyles ¶
func (r *Table) SetStyles(styles map[TableStyleKey]lipgloss.Style) *Table
SetStyles allows overrides of styling elements of the table When only a partial set of overrides are provided, the default styling will be used
func (*Table) SetTypes ¶
SetTypes sets the column type, setting this will remove all the rows so make sure you do it when instantiating Table object or add new rows after this, types have to be one of Ordered interface types
type TableBadCellTypeError ¶
type TableBadCellTypeError struct {
// contains filtered or unexported fields
}
TableBadCellTypeError type of cell does not match type of column
func (TableBadCellTypeError) Error ¶
func (e TableBadCellTypeError) Error() string
type TableBadTypeError ¶
type TableBadTypeError struct {
// contains filtered or unexported fields
}
TableBadTypeError type does not match Ordered interface types
func (TableBadTypeError) Error ¶
func (e TableBadTypeError) Error() string
type TableRowLenError ¶
type TableRowLenError struct {
// contains filtered or unexported fields
}
TableRowLenError row length is not matching headers len
func (TableRowLenError) Error ¶
func (e TableRowLenError) Error() string
type TableSingleType ¶
TableSingleType is Table that is using only 1 type for rows allowing for easier AddRows with fewer errors
func NewTableSingleType ¶
func NewTableSingleType[T Ordered](width, height int, columnHeaders []string) *TableSingleType[T]
NewTableSingleType initialize TableSingleType object with defaults
func (*TableSingleType[T]) AddRows ¶
func (r *TableSingleType[T]) AddRows(rows [][]T) *TableSingleType[T]
func (*TableSingleType[T]) MustAddRows ¶
func (r *TableSingleType[T]) MustAddRows(rows [][]T) *TableSingleType[T]
func (*TableSingleType[T]) SetTypes ¶
func (r *TableSingleType[T]) SetTypes()
SetTypes overridden for TableSimple
type TableSortingOrderKey ¶
type TableSortingOrderKey int
type TableStyleKey ¶
type TableStyleKey int
const ( TableHeaderStyleKey TableStyleKey = iota TableRowsStyleKey TableRowsSubsequentStyleKey TableRowsCursorStyleKey TableCellCursorStyleKey )