/
stringsPlate.go
94 lines (77 loc) · 1.74 KB
/
stringsPlate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package cmSlide
import (
"github.com/bhbosman/gocommon/model"
"github.com/rivo/tview"
"strconv"
)
type stringsPlate struct {
data []model.KeyValue
}
func newStringsPlate(data []model.KeyValue) *stringsPlate {
return &stringsPlate{data: data}
}
func (self *stringsPlate) GetCell(row, column int) *tview.TableCell {
if row == -1 || column == -1 {
return emptyCell
}
switch row {
case 0:
switch column {
case 0:
return tview.NewTableCell("*").SetSelectable(false)
case 1:
return tview.NewTableCell("Key").SetSelectable(false)
case 2:
return tview.NewTableCell("Value").SetSelectable(false)
}
default:
switch column {
case 0:
return tview.NewTableCell(strconv.Itoa(row)).SetSelectable(false).SetAlign(tview.AlignRight)
case 1:
n := row - 1
c := len(self.data)
if c > n {
return tview.NewTableCell(self.data[row-1].Key)
}
break
case 2:
n := row - 1
c := len(self.data)
if c > n {
return tview.NewTableCell(self.data[row-1].Value)
}
break
}
}
return emptyCell
}
func (self *stringsPlate) GetRowCount() int {
return len(self.data) + 1
}
func (self *stringsPlate) GetColumnCount() int {
return 3
}
func (self *stringsPlate) SetCell(row, column int, cell *tview.TableCell) {
}
func (self *stringsPlate) RemoveRow(row int) {
}
func (self *stringsPlate) RemoveColumn(column int) {
}
func (self *stringsPlate) InsertRow(row int) {
}
func (self *stringsPlate) InsertColumn(column int) {
}
func (self *stringsPlate) Clear() {
}
func (self *stringsPlate) GetItem(row int) (model.KeyValue, bool) {
if row == -1 {
return model.KeyValue{}, false
}
index := row - 1
count := len(self.data)
if index >= 0 && count > index {
return self.data[index], true
}
return model.KeyValue{}, false
}