From 9735f6dda8cfa7ff445608b475359c024baa0a50 Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Thu, 28 Feb 2019 18:36:03 -0800 Subject: [PATCH] Add ColumnResizer field to table --- widgets/table.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/widgets/table.go b/widgets/table.go index 3a9708c..929580a 100644 --- a/widgets/table.go +++ b/widgets/table.go @@ -28,20 +28,26 @@ type Table struct { TextAlignment Alignment RowStyles map[int]Style FillRow bool + + // ColumnResizer is called on each Draw. Can be used for custom column sizing. + ColumnResizer func() } func NewTable() *Table { return &Table{ - Block: *NewBlock(), - TextStyle: Theme.Table.Text, - RowSeparator: true, - RowStyles: make(map[int]Style), + Block: *NewBlock(), + TextStyle: Theme.Table.Text, + RowSeparator: true, + RowStyles: make(map[int]Style), + ColumnResizer: func() {}, } } func (self *Table) Draw(buf *Buffer) { self.Block.Draw(buf) + self.ColumnResizer() + columnWidths := self.ColumnWidths if len(columnWidths) == 0 { columnCount := len(self.Rows[0])