| 1 | package mainscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/table/virtualtable`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/" |
| 5 | "mathscip-go gomod github.com/golang/go/src go1.18 math/" |
| 6 | |
| 7 | "github.com/darkhz/tviewscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/" |
| 8 | ) |
| 9 | |
| 10 | type TableDatascip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/table/virtualtable`/TableData# struct { |
| 11 | tviewscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/.TableContentReadOnlyscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/table/virtualtable`/TableData#TableContentReadOnly. |
| 12 | } |
| 13 | |
| 14 | func (d *TableDatascip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/table/virtualtable`/TableData#) GetCellscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/table/virtualtable`/TableData#GetCell().(row, column int) *tviewscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/.TableCellscip-go gomod github.com/darkhz/tview . `github.com/darkhz/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 tviewscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/.NewTableCellscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/NewTableCell().(fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("[red]%s[green]%d", letters[start:], column)) |
| 25 | } |
| 26 | |
| 27 | func (d *TableDatascip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/table/virtualtable`/TableData#) GetRowCountscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/table/virtualtable`/TableData#GetRowCount().() int { |
| 28 | return mathscip-go gomod github.com/golang/go/src go1.18 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.18 math/MaxInt64. |
| 29 | } |
| 30 | |
| 31 | func (d *TableDatascip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/table/virtualtable`/TableData#) GetColumnCountscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/table/virtualtable`/TableData#GetColumnCount().() int { |
| 32 | return mathscip-go gomod github.com/golang/go/src go1.18 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.18 math/MaxInt64. |
| 33 | } |
| 34 | |
| 35 | func mainscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/table/virtualtable`/main().() { |
| 36 | data := &TableDatascip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/table/virtualtable`/TableData#{} |
| 37 | table := tviewscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/.NewTablescip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/NewTable().(). |
| 38 | SetBordersscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/Table#SetBorders().(false). |
| 39 | SetSelectablescip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/Table#SetSelectable().(true, true). |
| 40 | SetContentscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/Table#SetContent().(data) |
| 41 | if err := tviewscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/.NewApplicationscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/NewApplication().().SetRootscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/Application#SetRoot().(table, true).EnableMousescip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/Application#EnableMouse().(true).Runscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/Application#Run().(); err != nil { |
| 42 | panic(err) |
| 43 | } |
| 44 | } |