mirror of
https://github.com/rivo/tview.git
synced 2025-04-26 13:49:06 +08:00
Merge branch 'virtualtable'
This commit is contained in:
commit
78cf54e830
1
demos/table/virtualtable/README.md
Normal file
1
demos/table/virtualtable/README.md
Normal file
@ -0,0 +1 @@
|
||||

|
44
demos/table/virtualtable/main.go
Normal file
44
demos/table/virtualtable/main.go
Normal file
@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
type TableData struct {
|
||||
tview.TableContentReadOnly
|
||||
}
|
||||
|
||||
func (d *TableData) GetCell(row, column int) *tview.TableCell {
|
||||
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
|
||||
start := len(letters) - 1
|
||||
row /= 26
|
||||
for row > 0 {
|
||||
start--
|
||||
row--
|
||||
letters[start] = 'A' + byte(row%26)
|
||||
row /= 26
|
||||
}
|
||||
return tview.NewTableCell(fmt.Sprintf("[red]%s[green]%d", letters[start:], column))
|
||||
}
|
||||
|
||||
func (d *TableData) GetRowCount() int {
|
||||
return math.MaxInt64
|
||||
}
|
||||
|
||||
func (d *TableData) GetColumnCount() int {
|
||||
return math.MaxInt64
|
||||
}
|
||||
|
||||
func main() {
|
||||
data := &TableData{}
|
||||
table := tview.NewTable().
|
||||
SetBorders(false).
|
||||
SetSelectable(true, true).
|
||||
SetContent(data)
|
||||
if err := tview.NewApplication().SetRoot(table, true).EnableMouse(true).Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
BIN
demos/table/virtualtable/screenshot.png
Normal file
BIN
demos/table/virtualtable/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
Loading…
x
Reference in New Issue
Block a user