Skip to content

Commit 78cf54e

Browse files
author
Oliver
committed
Merge branch 'virtualtable'
2 parents f7430b8 + 9b6f0f0 commit 78cf54e

File tree

4 files changed

+519
-211
lines changed

4 files changed

+519
-211
lines changed

demos/table/virtualtable/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
![Screenshot](screenshot.png)

demos/table/virtualtable/main.go

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"math"
6+
7+
"github.com/rivo/tview"
8+
)
9+
10+
type TableData struct {
11+
tview.TableContentReadOnly
12+
}
13+
14+
func (d *TableData) GetCell(row, column int) *tview.TableCell {
15+
letters := [...]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'A' + byte(row%26)} // log(math.MaxInt64) / log(26) ~= 14
16+
start := len(letters) - 1
17+
row /= 26
18+
for row > 0 {
19+
start--
20+
row--
21+
letters[start] = 'A' + byte(row%26)
22+
row /= 26
23+
}
24+
return tview.NewTableCell(fmt.Sprintf("[red]%s[green]%d", letters[start:], column))
25+
}
26+
27+
func (d *TableData) GetRowCount() int {
28+
return math.MaxInt64
29+
}
30+
31+
func (d *TableData) GetColumnCount() int {
32+
return math.MaxInt64
33+
}
34+
35+
func main() {
36+
data := &TableData{}
37+
table := tview.NewTable().
38+
SetBorders(false).
39+
SetSelectable(true, true).
40+
SetContent(data)
41+
if err := tview.NewApplication().SetRoot(table, true).EnableMouse(true).Run(); err != nil {
42+
panic(err)
43+
}
44+
}
63.7 KB
Loading

0 commit comments

Comments
 (0)