mirror of
https://github.com/crazy-max/diun.git
synced 2024-12-22 19:38:28 +00:00
6f7b5b313d
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.5.9 to 6.6.5. - [Release notes](https://github.com/jedib0t/go-pretty/releases) - [Commits](https://github.com/jedib0t/go-pretty/compare/v6.5.9...v6.6.5) --- updated-dependencies: - dependency-name: github.com/jedib0t/go-pretty/v6 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package table
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/jedib0t/go-pretty/v6/text"
|
|
)
|
|
|
|
// Row defines a single row in the Table.
|
|
type Row []interface{}
|
|
|
|
func (r Row) findColumnNumber(colName string) int {
|
|
for colIdx, col := range r {
|
|
if fmt.Sprint(col) == colName {
|
|
return colIdx + 1
|
|
}
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// RowAttributes contains properties about the Row during the render.
|
|
type RowAttributes struct {
|
|
Number int // Row Number (1-indexed) as appended
|
|
NumberSorted int // Row number (1-indexed) after sorting
|
|
}
|
|
|
|
// RowPainter is a custom function that takes a Row as input and returns the
|
|
// text.Colors{} to use on the entire row
|
|
type RowPainter func(row Row) text.Colors
|
|
|
|
// RowPainterWithAttributes is the same as RowPainter but passes in additional
|
|
// attributes from render time
|
|
type RowPainterWithAttributes func(row Row, attr RowAttributes) text.Colors
|
|
|
|
// rowStr defines a single row in the Table comprised of just string objects.
|
|
type rowStr []string
|
|
|
|
// areEqual returns true if the contents of the 2 given columns are the same
|
|
func (row rowStr) areEqual(colIdx1 int, colIdx2 int) bool {
|
|
return colIdx1 >= 0 && colIdx1 < len(row) &&
|
|
colIdx2 >= 0 && colIdx2 < len(row) &&
|
|
row[colIdx1] == row[colIdx2]
|
|
}
|