Add ColumnResizer field to table
This commit is contained in:
parent
3006e4efe4
commit
9735f6dda8
|
@ -28,20 +28,26 @@ type Table struct {
|
||||||
TextAlignment Alignment
|
TextAlignment Alignment
|
||||||
RowStyles map[int]Style
|
RowStyles map[int]Style
|
||||||
FillRow bool
|
FillRow bool
|
||||||
|
|
||||||
|
// ColumnResizer is called on each Draw. Can be used for custom column sizing.
|
||||||
|
ColumnResizer func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTable() *Table {
|
func NewTable() *Table {
|
||||||
return &Table{
|
return &Table{
|
||||||
Block: *NewBlock(),
|
Block: *NewBlock(),
|
||||||
TextStyle: Theme.Table.Text,
|
TextStyle: Theme.Table.Text,
|
||||||
RowSeparator: true,
|
RowSeparator: true,
|
||||||
RowStyles: make(map[int]Style),
|
RowStyles: make(map[int]Style),
|
||||||
|
ColumnResizer: func() {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Table) Draw(buf *Buffer) {
|
func (self *Table) Draw(buf *Buffer) {
|
||||||
self.Block.Draw(buf)
|
self.Block.Draw(buf)
|
||||||
|
|
||||||
|
self.ColumnResizer()
|
||||||
|
|
||||||
columnWidths := self.ColumnWidths
|
columnWidths := self.ColumnWidths
|
||||||
if len(columnWidths) == 0 {
|
if len(columnWidths) == 0 {
|
||||||
columnCount := len(self.Rows[0])
|
columnCount := len(self.Rows[0])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user