From dfc048fe285939d9de3b5753f723c935d042cc2b Mon Sep 17 00:00:00 2001 From: Daniel Bridges Date: Mon, 15 Jul 2019 11:56:44 -0700 Subject: Display user specified headers in viewer if present --- lib/ui/grid.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/ui') 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 -- cgit 1.4.1-2-gfad0