Skip to content

Commit ab322a7

Browse files
committed
Merge branch 'develop' (w/ support tmux).
2 parents 788e98c + 8b37bc3 commit ab322a7

File tree

11 files changed

+421
-387
lines changed

11 files changed

+421
-387
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module github.com/idlephysicist/cave-logger
33
go 1.16
44

55
require (
6-
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200831155531-da485f47343b
6+
code.rocketnine.space/tslocum/cview v1.5.7
7+
github.com/gdamore/tcell/v2 v2.4.1-0.20210828201608-73703f7ed490
78
github.com/sirupsen/logrus v1.4.2
89
github.com/spf13/pflag v1.0.5
9-
gitlab.com/tslocum/cview v1.4.9-0.20200901224443-f35f86924a49
1010
modernc.org/sqlite v1.9.0
1111
)

go.sum

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
1+
code.rocketnine.space/tslocum/cbind v0.1.5 h1:i6NkeLLNPNMS4NWNi3302Ay3zSU6MrqOT+yJskiodxE=
2+
code.rocketnine.space/tslocum/cbind v0.1.5/go.mod h1:LtfqJTzM7qhg88nAvNhx+VnTjZ0SXBJtxBObbfBWo/M=
3+
code.rocketnine.space/tslocum/cview v1.5.7 h1:dUL6jyNp/ubUfeds7G7zq8R3sZY+He+sPGxu3Qn21tY=
4+
code.rocketnine.space/tslocum/cview v1.5.7/go.mod h1:4Wx6exftTIbeRai3s0VVjzVaSNyHlXTg9eHd3s89v9Q=
15
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
26
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
37
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
48
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
59
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
610
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
7-
github.com/gdamore/tcell/v2 v2.0.0-dev/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
8-
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200831155531-da485f47343b h1:j9fvrLkgzxR1S/ZWI6fbw8hjNxU5/lxnVXBX2tuYGVA=
9-
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200831155531-da485f47343b/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
11+
github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
12+
github.com/gdamore/tcell/v2 v2.4.1-0.20210828201608-73703f7ed490 h1:GtCvI6MZUKinE4yNoN9AanNi0aavmFHp+CyzXLUptVw=
13+
github.com/gdamore/tcell/v2 v2.4.1-0.20210828201608-73703f7ed490/go.mod h1:Az6Jt+M5idSED2YPGtwnfJV0kXohgdCBPmHGSYc1r04=
1014
github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo=
1115
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
1216
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
1317
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
1418
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
1519
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
16-
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
1720
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
21+
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
22+
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
1823
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
1924
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
20-
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
21-
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
22-
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
25+
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
26+
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
27+
github.com/mattn/go-runewidth v0.0.14-0.20210830053702-dc8fe66265af h1:Vz2tUCLqu+a1igkarhrqNG+OFBs0uJqB3ADWFsQA9jM=
28+
github.com/mattn/go-runewidth v0.0.14-0.20210830053702-dc8fe66265af/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
2329
github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg=
2430
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
2531
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2632
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2733
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
2834
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
29-
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
3035
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
36+
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
37+
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
3138
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
3239
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
3340
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
@@ -36,10 +43,6 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
3643
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
3744
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
3845
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
39-
gitlab.com/tslocum/cbind v0.1.2-0.20200826214515-b5f2c6a8711a h1:6u2QDDcKdeFhyHT/srxPDzLfDJqwKTgy1v+3209LYBY=
40-
gitlab.com/tslocum/cbind v0.1.2-0.20200826214515-b5f2c6a8711a/go.mod h1:HfB7qAhHSZbn1rFK8M9SvSN5NG6ScAg/3h3iE6xdeeI=
41-
gitlab.com/tslocum/cview v1.4.9-0.20200901224443-f35f86924a49 h1:BQCW6LMs3qK/j0ZIyD3EF9AUsS1RZs9SvuDPdPkEqmw=
42-
gitlab.com/tslocum/cview v1.4.9-0.20200901224443-f35f86924a49/go.mod h1:yC/rMZkRxbKb6kUvnRyVjNEpb7ZREKG0ynEMHJq+Sgo=
4346
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
4447
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
4548
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@@ -53,17 +56,25 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
5356
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5457
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5558
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
56-
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5759
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
58-
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
59-
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6060
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
61+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6162
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
62-
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
6363
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
64+
golang.org/x/sys v0.0.0-20210309040221-94ec62e08169/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
65+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
66+
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e h1:XMgFehsDnnLGtjvjOfqWSUzt0alpTR1RSEuznObga2c=
67+
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
68+
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
69+
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
70+
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE=
71+
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
6472
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
65-
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
6673
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
74+
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
75+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
76+
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
77+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
6778
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
6879
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
6980
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78 h1:M8tBwCtWD/cZV9DZpFYRUgaymAYAr+aIUTWzDaM3uPs=

internal/gui/cavers.go

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,26 @@ import (
55
"strings"
66
"time"
77

8+
"code.rocketnine.space/tslocum/cview"
89
"github.com/gdamore/tcell/v2"
9-
tview "gitlab.com/tslocum/cview"
1010

1111
"github.com/idlephysicist/cave-logger/internal/model"
1212
)
1313

1414
type cavers struct {
15-
*tview.Table
16-
cavers chan *model.Caver
17-
filterCol, filterTerm, filterAction string
15+
*cview.Table
16+
filterCol, filterTerm string
1817
}
1918

2019
func newCavers(g *Gui) *cavers {
21-
cavers := &cavers{
22-
Table: tview.NewTable().
23-
SetScrollBarVisibility(tview.ScrollBarNever).
24-
SetSelectable(true, false).
25-
Select(0, 0).
26-
SetFixed(1, 1),
27-
}
28-
29-
cavers.SetTitle(``).SetTitleAlign(tview.AlignLeft)
20+
t := cview.NewTable()
21+
t.SetScrollBarVisibility(cview.ScrollBarNever)
22+
t.SetSelectable(true, false)
23+
t.SetSortClicked(false)
24+
t.Select(0, 0)
25+
t.SetFixed(1, 1)
26+
27+
cavers := &cavers{Table: t}
3028
cavers.SetBorder(true)
3129
cavers.setEntries(g)
3230
cavers.setKeybinding(g)
@@ -64,47 +62,54 @@ func (c *cavers) setKeybinding(g *Gui) {
6462

6563
func (c *cavers) setEntries(g *Gui) {
6664
c.entries(g)
67-
table := c.Clear()
65+
c.Clear()
6866

69-
headers := []string{
70-
"Name",
71-
"Club",
72-
"Count",
73-
"Last Trip",
67+
headers := [][]byte{
68+
[]byte("Name"),
69+
[]byte("Club"),
70+
[]byte("Count"),
71+
[]byte("Last Trip"),
7472
}
7573

7674
for i, header := range headers {
77-
table.SetCell(0, i, &tview.TableCell{
75+
c.SetCell(0, i, &cview.TableCell{
7876
Text: header,
7977
NotSelectable: true,
80-
Align: tview.AlignLeft,
81-
Color: tview.Styles.PrimaryTextColor,
82-
BackgroundColor: tview.Styles.PrimitiveBackgroundColor,
78+
Align: cview.AlignLeft,
79+
Color: cview.Styles.PrimaryTextColor,
80+
BackgroundColor: cview.Styles.PrimitiveBackgroundColor,
8381
Attributes: tcell.AttrBold,
8482
})
8583
}
8684

85+
var cell *cview.TableCell
8786
for i, caver := range g.state.resources.people {
88-
table.SetCell(i+1, 0, tview.NewTableCell(caver.Name).
89-
SetTextColor(tview.Styles.PrimaryTextColor).
90-
SetMaxWidth(30).
91-
SetExpansion(1))
92-
93-
table.SetCell(i+1, 1, tview.NewTableCell(caver.Club).
94-
SetTextColor(tview.Styles.PrimaryTextColor).
95-
SetMaxWidth(0).
96-
SetExpansion(1))
97-
98-
table.SetCell(i+1, 2, tview.NewTableCell(strconv.FormatInt(caver.Count, 10)).
99-
SetTextColor(tview.Styles.PrimaryTextColor).
100-
SetMaxWidth(0).
101-
SetExpansion(1))
102-
103-
table.SetCell(i+1, 3, tview.NewTableCell(caver.LastTrip).
104-
SetTextColor(tview.Styles.PrimaryTextColor).
105-
SetMaxWidth(0).
106-
SetExpansion(1))
87+
cell = cview.NewTableCell(caver.Name)
88+
cell.SetTextColor(cview.Styles.PrimaryTextColor)
89+
cell.SetMaxWidth(30)
90+
cell.SetExpansion(1)
91+
c.SetCell(i+1, 0, cell)
92+
93+
cell = cview.NewTableCell(caver.Club)
94+
cell.SetTextColor(cview.Styles.PrimaryTextColor)
95+
cell.SetMaxWidth(0)
96+
cell.SetExpansion(1)
97+
c.SetCell(i+1, 1, cell)
98+
99+
cell = cview.NewTableCell(strconv.FormatInt(caver.Count, 10))
100+
cell.SetTextColor(cview.Styles.PrimaryTextColor)
101+
cell.SetMaxWidth(0)
102+
cell.SetExpansion(1)
103+
c.SetCell(i+1, 2, cell)
104+
105+
cell = cview.NewTableCell(caver.LastTrip)
106+
cell.SetTextColor(cview.Styles.PrimaryTextColor)
107+
cell.SetMaxWidth(0)
108+
cell.SetExpansion(1)
109+
c.SetCell(i+1, 3, cell)
107110
}
111+
112+
c.Select(1, 1)
108113
}
109114

110115
func (c *cavers) updateEntries(g *Gui) {

internal/gui/caves.go

Lines changed: 62 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,26 @@ import (
55
"strings"
66
"time"
77

8+
"code.rocketnine.space/tslocum/cview"
89
"github.com/gdamore/tcell/v2"
9-
tview "gitlab.com/tslocum/cview"
1010

1111
"github.com/idlephysicist/cave-logger/internal/model"
1212
)
1313

1414
type caves struct {
15-
*tview.Table
16-
caves chan *model.Cave
17-
filterCol, filterTerm, filterAction string
15+
*cview.Table
16+
filterCol, filterTerm string
1817
}
1918

2019
func newCaves(g *Gui) *caves {
21-
caves := &caves{
22-
Table: tview.NewTable().
23-
SetScrollBarVisibility(tview.ScrollBarNever).
24-
SetSelectable(true, false).
25-
Select(0, 0).
26-
SetFixed(1, 1),
27-
}
28-
29-
caves.SetTitle(``).SetTitleAlign(tview.AlignLeft)
20+
t := cview.NewTable()
21+
t.SetScrollBarVisibility(cview.ScrollBarNever)
22+
t.SetSelectable(true, false)
23+
t.SetSortClicked(false)
24+
t.Select(0, 0)
25+
t.SetFixed(1, 1)
26+
27+
caves := &caves{Table: t}
3028
caves.SetBorder(true)
3129
caves.setEntries(g)
3230
caves.setKeybinding(g)
@@ -80,59 +78,68 @@ func (c *caves) entries(g *Gui) {
8078

8179
func (c *caves) setEntries(g *Gui) {
8280
c.entries(g)
83-
table := c.Clear()
84-
85-
headers := []string{
86-
"Name",
87-
"Region",
88-
"Country",
89-
"SRT",
90-
"Visits",
91-
"Last Visit",
81+
c.Clear()
82+
83+
headers := [][]byte{
84+
[]byte("Name"),
85+
[]byte("Region"),
86+
[]byte("Country"),
87+
[]byte("SRT"),
88+
[]byte("Visits"),
89+
[]byte("Last Visit"),
9290
}
9391

9492
for i, header := range headers {
95-
table.SetCell(0, i, &tview.TableCell{
93+
c.SetCell(0, i, &cview.TableCell{
9694
Text: header,
9795
NotSelectable: true,
98-
Align: tview.AlignLeft,
99-
Color: tview.Styles.PrimaryTextColor,
100-
BackgroundColor: tview.Styles.PrimitiveBackgroundColor,
96+
Align: cview.AlignLeft,
97+
Color: cview.Styles.PrimaryTextColor,
98+
BackgroundColor: cview.Styles.PrimitiveBackgroundColor,
10199
Attributes: tcell.AttrBold,
102100
})
103101
}
104102

103+
var cell *cview.TableCell
105104
for i, cave := range g.state.resources.locations {
106-
table.SetCell(i+1, 0, tview.NewTableCell(cave.Name).
107-
SetTextColor(tview.Styles.PrimaryTextColor).
108-
SetMaxWidth(30).
109-
SetExpansion(1))
110-
111-
table.SetCell(i+1, 1, tview.NewTableCell(cave.Region).
112-
SetTextColor(tview.Styles.PrimaryTextColor).
113-
SetMaxWidth(30).
114-
SetExpansion(1))
115-
116-
table.SetCell(i+1, 2, tview.NewTableCell(cave.Country).
117-
SetTextColor(tview.Styles.PrimaryTextColor).
118-
SetMaxWidth(0).
119-
SetExpansion(1))
120-
121-
table.SetCell(i+1, 3, tview.NewTableCell(yesOrNo(cave.SRT)).
122-
SetTextColor(tview.Styles.PrimaryTextColor).
123-
SetMaxWidth(0).
124-
SetExpansion(1))
125-
126-
table.SetCell(i+1, 4, tview.NewTableCell(strconv.FormatInt(cave.Visits, 10)).
127-
SetTextColor(tview.Styles.PrimaryTextColor).
128-
SetMaxWidth(0).
129-
SetExpansion(1))
130-
131-
table.SetCell(i+1, 5, tview.NewTableCell(cave.LastVisit).
132-
SetTextColor(tview.Styles.PrimaryTextColor).
133-
SetMaxWidth(0).
134-
SetExpansion(1))
105+
cell = cview.NewTableCell(cave.Name)
106+
cell.SetTextColor(cview.Styles.PrimaryTextColor)
107+
cell.SetMaxWidth(30)
108+
cell.SetExpansion(1)
109+
c.SetCell(i+1, 0, cell)
110+
111+
cell = cview.NewTableCell(cave.Region)
112+
cell.SetTextColor(cview.Styles.PrimaryTextColor)
113+
cell.SetMaxWidth(30)
114+
cell.SetExpansion(1)
115+
c.SetCell(i+1, 1, cell)
116+
117+
cell = cview.NewTableCell(cave.Country)
118+
cell.SetTextColor(cview.Styles.PrimaryTextColor)
119+
cell.SetMaxWidth(0)
120+
cell.SetExpansion(1)
121+
c.SetCell(i+1, 2, cell)
122+
123+
cell = cview.NewTableCell(yesOrNo(cave.SRT))
124+
cell.SetTextColor(cview.Styles.PrimaryTextColor)
125+
cell.SetMaxWidth(0)
126+
cell.SetExpansion(1)
127+
c.SetCell(i+1, 3, cell)
128+
129+
cell = cview.NewTableCell(strconv.FormatInt(cave.Visits, 10))
130+
cell.SetTextColor(cview.Styles.PrimaryTextColor)
131+
cell.SetMaxWidth(0)
132+
cell.SetExpansion(1)
133+
c.SetCell(i+1, 4, cell)
134+
135+
cell = cview.NewTableCell(cave.LastVisit)
136+
cell.SetTextColor(cview.Styles.PrimaryTextColor)
137+
cell.SetMaxWidth(0)
138+
cell.SetExpansion(1)
139+
c.SetCell(i+1, 5, cell)
135140
}
141+
142+
c.Select(1, 1)
136143
}
137144

138145
func (c *caves) updateEntries(g *Gui) {

0 commit comments

Comments
 (0)