Skip to content

Commit

Permalink
Make the horizontal scrolling example more easily configurable for te…
Browse files Browse the repository at this point in the history
…sting/playing (#96)
  • Loading branch information
Evertras committed Jun 11, 2022
1 parent 3cc81a5 commit 8d190c5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions examples/scrolling/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const (

numCols = 100
numRows = 10
idWidth = 5

colWidth = 3
maxWidth = 30
)

type Model struct {
Expand All @@ -30,7 +34,7 @@ func genRow(id int) table.Row {
}

for i := 0; i < numCols; i++ {
data[colKey(i)] = i + 1
data[colKey(i)] = colWidth
}

return table.NewRow(data)
Expand All @@ -44,16 +48,16 @@ func NewModel() Model {
}

cols := []table.Column{
table.NewColumn(columnKeyID, "ID", 5),
table.NewColumn(columnKeyID, "ID", idWidth),
}

for i := 0; i < numCols; i++ {
cols = append(cols, table.NewColumn(colKey(i), colKey(i+1), 5))
cols = append(cols, table.NewColumn(colKey(i), colKey(i+1), colWidth))
}

t := table.New(cols).
WithRows(rows).
WithMaxTotalWidth(30).
WithMaxTotalWidth(maxWidth).
WithHorizontalFreezeColumnCount(1).
WithStaticFooter("A footer").
Focused(true)
Expand Down

0 comments on commit 8d190c5

Please sign in to comment.