Documentation ¶
Index ¶
- type Dimensions
- type Direction
- type Grid
- func (g *Grid) Add(s ...string) *Grid
- func (g Grid) Cells() []string
- func (g *Grid) Delete(i ...int) *Grid
- func (g Grid) Direction() Direction
- func (g Grid) FitIntoColumns(max int) (dim Dimensions, ok bool)
- func (g Grid) FitIntoWidth(max int) (dim Dimensions, ok bool)
- func (g *Grid) Insert(i int, s ...string) *Grid
- func (g Grid) Separator() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dimensions ¶
type Dimensions struct {
// contains filtered or unexported fields
}
Dimensions contains the dimensions of the grid and the possibility to format it.
func (Dimensions) Bytes ¶
func (d Dimensions) Bytes() []byte
Bytes formats the grid into a byte slice.
func (Dimensions) Columns ¶
func (d Dimensions) Columns() int
Columns represents the quantity of columns the grid has.
func (Dimensions) Lines ¶
func (d Dimensions) Lines() int
Lines represents the quantity of lines the grid has.
func (Dimensions) String ¶
func (d Dimensions) String() string
String formats the grid into a string.
func (Dimensions) Widths ¶
func (d Dimensions) Widths() []int
Widths represents the widths of each column in the grid.
type Direction ¶
type Direction int8
Direction represents the direction in which the values will be written.
const ( // LeftToRight is a direction in which the values will be written. // It goes from the first cell (0,0) to the end of the line, returning to the beginning of the second line. // Exactly the same as a typewritter. LeftToRight Direction = iota // TopToBottom is a direction in which the values will be written. // It goes from the first cell (0,0) to the bottom of the column, returning to the top of the second column. // Exactly the same as how `ls` command works by default. TopToBottom )
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
Grid represents the values' grid, that will be exported as a pretty formatted string.
func New ¶
New returns a new Grid. `d` represents the direction in which the values will be written. `sep` represents the separator; a string that will be between each column. `s` is the cells that will be added right after initialization.
func (*Grid) Delete ¶
Delete deletes a value in a specified position in the grid. `i` the position of the value.
func (Grid) FitIntoColumns ¶
func (g Grid) FitIntoColumns(max int) (dim Dimensions, ok bool)
FitIntoColumns formats the grid, based on a maximum quantity of columns. `max` represents the maximum quantity of columns of the grid. `dim` represents the dimensions of the grid, used for formatting. See `Dimensions`. `ok` says whether the the grid fits in the maximum width informed. If false, discard `dim`.
func (Grid) FitIntoWidth ¶
func (g Grid) FitIntoWidth(max int) (dim Dimensions, ok bool)
FitIntoWidth formats the grid, based on a maximum width. `max` represents the maximum width of the grid, based on characters. `dim` represents the dimensions of the grid, used for formatting. See `Dimensions`. `ok` says whether the the grid fits in the maximum width informed. If false, discard `dim`.