diff options
author | Daniel Bridges <bridges2@gmail.com> | 2019-07-15 11:56:44 -0700 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-07-17 17:26:43 -0400 |
commit | dfc048fe285939d9de3b5753f723c935d042cc2b (patch) | |
tree | ea037462fb702d0f503a34bfc8edd310d4dbfaeb /lib/ui/grid.go | |
parent | d7975132b62942530da6c4907bed3eb3ab99e4a3 (diff) |
Display user specified headers in viewer if present
Diffstat (limited to 'lib/ui/grid.go')
-rw-r--r-- | lib/ui/grid.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/ui/grid.go b/lib/ui/grid.go index 3f5dd60..96da1cb 100644 --- a/lib/ui/grid.go +++ b/lib/ui/grid.go @@ -54,6 +54,20 @@ func NewGrid() *Grid { return &Grid{invalid: true} } +// MakeGrid creates a grid with the specified number of columns and rows. Each +// cell has a size of 1. +func MakeGrid(numRows, numCols, rowStrategy, colStrategy int) *Grid { + rows := make([]GridSpec, numRows) + for i := 0; i < numRows; i++ { + rows[i] = GridSpec{rowStrategy, 1} + } + cols := make([]GridSpec, numCols) + for i := 0; i < numCols; i++ { + cols[i] = GridSpec{colStrategy, 1} + } + return NewGrid().Rows(rows).Columns(cols) +} + func (cell *GridCell) At(row, col int) *GridCell { cell.Row = row cell.Column = col |