summaryrefslogtreecommitdiffstats
path: root/termui/grid.go
diff options
context:
space:
mode:
Diffstat (limited to 'termui/grid.go')
-rw-r--r--termui/grid.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/termui/grid.go b/termui/grid.go
index b0eb7e4..c8321a2 100644
--- a/termui/grid.go
+++ b/termui/grid.go
@@ -9,19 +9,21 @@ type GridBufferer interface {
SetGrid(int, int, int, int)
}
+// Grid holds widgets and information about terminal dimensions.
+// Widgets are adjusted and rendered through the grid.
type Grid struct {
Widgets []GridBufferer
Width int
Height int
Cols int
Rows int
- BgColor Color
}
func NewGrid() *Grid {
return &Grid{}
}
+// Set takes a widget along with it's grid dimensions to be controlled by the grid.
func (g *Grid) Set(x0, y0, x1, y1 int, widget GridBufferer) {
if widget == nil {
return
@@ -36,13 +38,14 @@ func (g *Grid) Set(x0, y0, x1, y1 int, widget GridBufferer) {
g.Widgets = append(g.Widgets, widget)
}
+// Resize resizes each widget in the grid's control.
func (g *Grid) Resize() {
for _, w := range g.Widgets {
w.Resize(g.Width, g.Height, g.Cols, g.Rows)
}
}
-// Buffer implements Bufferer interface.
+// Buffer implements Bufferer interface and merges each widget into one buffer.
func (g *Grid) Buffer() *Buffer {
buf := NewFilledBuffer(0, 0, g.Width, g.Height, Cell{' ', ColorDefault, Theme.Bg})
for _, w := range g.Widgets {