Skip to content

Commit d7ede3f

Browse files
authored
zrepl status: switch back to tview from cview & upgrade to latest (#846)
While investigating #700 I checked in on `zrepl status` dependencies and found that `cview`, which was/is a fork of tview, appears to be unmaintained. We switched to it 4.5 years ago in a58ce74. Checking now, `github.com/rivo/tview` seems to be somewhat maintained again. I also checked what k9s uses because that tool came to mind as a Go terminal UI app. It does use `tview`, but, a fork that has diverged substantially. Maybe in another 4.5 years stuff the ecosystem has consolidated... refs #700
1 parent bca37c7 commit d7ede3f

4 files changed

Lines changed: 15 additions & 14 deletions

File tree

‎go.mod‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module github.com/zrepl/zrepl
22

33
go 1.22.7
4+
45
toolchain go1.23.1
56

67
require (
7-
code.rocketnine.space/tslocum/cview v1.5.9
88
github.com/bits-and-blooms/bitset v1.14.3
99
github.com/fatih/color v1.7.0
1010
github.com/gdamore/tcell/v2 v2.7.4
@@ -70,7 +70,8 @@ require (
7070
github.com/pmezard/go-difflib v1.0.0 // indirect
7171
github.com/prometheus/client_model v0.6.1 // indirect
7272
github.com/prometheus/procfs v0.15.1 // indirect
73-
github.com/rivo/uniseg v0.4.6 // indirect
73+
github.com/rivo/tview v0.0.0-20241103174730-c76f7879f592
74+
github.com/rivo/uniseg v0.4.7 // indirect
7475
github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44 // indirect; go1.12 thinks it needs this
7576
github.com/theckman/goconstraint v1.11.0 // indirect
7677
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect; go1.12 thinks it needs this

‎go.sum‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,15 @@ github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJ
122122
github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0=
123123
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
124124
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
125+
github.com/rivo/tview v0.0.0-20241103174730-c76f7879f592 h1:YIJ+B1hePP6AgynC5TcqpO0H9k3SSoZa2BGyL6vDUzM=
126+
github.com/rivo/tview v0.0.0-20241103174730-c76f7879f592/go.mod h1:02iFIz7K/A9jGCvrizLPvoqr4cEIx7q54RH5Qudkrss=
125127
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
126128
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
127129
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
128130
github.com/rivo/uniseg v0.4.6 h1:Sovz9sDSwbOz9tgUy8JpT+KgCkPYJEN/oYzlJiYTNLg=
129131
github.com/rivo/uniseg v0.4.6/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
132+
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
133+
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
130134
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
131135
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
132136
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=

‎internal/client/status/status_interactive.go‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import (
77
"sync"
88
"time"
99

10-
tview "code.rocketnine.space/tslocum/cview"
1110
"github.com/gdamore/tcell/v2"
12-
11+
"github.com/rivo/tview"
1312
"github.com/zrepl/zrepl/internal/client/status/viewmodel"
1413
)
1514

@@ -29,7 +28,6 @@ func interactive(c Client, flag statusFlags) error {
2928
jobMenuRoot.SetSelectable(true)
3029
jobMenu.SetRoot(jobMenuRoot)
3130
jobMenu.SetCurrentNode(jobMenuRoot)
32-
jobMenu.SetSelectedTextColor(tcell.ColorGreen)
3331
jobTextDetail := tview.NewTextView()
3432
jobTextDetail.SetWrap(false)
3533

@@ -110,10 +108,8 @@ func interactive(c Client, flag statusFlags) error {
110108
}
111109
app.SetRoot(toolbarSplit, true)
112110
app.SetFocus(preModalFocus)
113-
app.Draw()
114111
})
115112
app.SetRoot(m, true)
116-
app.Draw()
117113
}
118114

119115
app.SetRoot(toolbarSplit, true)
@@ -170,12 +166,14 @@ func interactive(c Client, flag statusFlags) error {
170166
redrawJobsList = true
171167
}
172168
if redrawJobsList {
169+
selectedTextStyle := tcell.StyleDefault.Bold(true)
173170
selectedJobN = nil
174171
children := make([]*tview.TreeNode, len(jobs))
175172
for i := range jobs {
176173
jobN := tview.NewTreeNode(jobs[i].JobTreeTitle())
177174
jobN.SetReference(jobs[i])
178175
jobN.SetSelectable(true)
176+
jobN.SetSelectedTextStyle(selectedTextStyle)
179177
children[i] = jobN
180178
jobN.SetSelectedFunc(func() {
181179
viewmodelupdate(func(p *viewmodel.Params) {
@@ -187,6 +185,7 @@ func interactive(c Client, flag statusFlags) error {
187185
}
188186
}
189187
jobMenuRoot.SetChildren(children)
188+
jobMenuRoot.SetSelectedTextStyle(selectedTextStyle)
190189
}
191190

192191
if selectedJobN != nil && jobMenu.GetCurrentNode() != selectedJobN {
@@ -207,9 +206,6 @@ func interactive(c Client, flag statusFlags) error {
207206
bottombar.ResizeItem(bottombarDateView, len(bottombardatestring), 0)
208207

209208
bottomBarStatus.SetText(m.BottomBarStatus())
210-
211-
app.Draw()
212-
213209
}
214210

215211
go func() {
@@ -252,6 +248,7 @@ func interactive(c Client, flag statusFlags) error {
252248

253249
app.SetInputCapture(func(e *tcell.EventKey) *tcell.EventKey {
254250
if e.Key() == tcell.KeyTab {
251+
// TODO: only if there's no modal showing (long-time bug in zrepl status)
255252
tabbableCycle()
256253
return nil
257254
}
@@ -284,9 +281,8 @@ func interactive(c Client, flag statusFlags) error {
284281
signals := []string{"wakeup", "reset"}
285282
clientFuncs := []func(job string) error{c.SignalWakeup, c.SignalReset}
286283
sigMod := tview.NewModal()
287-
sigMod.SetBackgroundColor(tcell.ColorDefault)
288284
sigMod.SetBorder(true)
289-
sigMod.GetForm().SetButtonTextColorFocused(tcell.ColorGreen)
285+
sigMod.SetButtonActivatedStyle(tcell.StyleDefault.Bold(true).Reverse(true))
290286
sigMod.AddButtons(signals)
291287
sigMod.SetText(fmt.Sprintf("Send a signal to job %q", job.Name()))
292288
showModal(sigMod, func(idx int, _ string) {

‎internal/client/status/status_legacy.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
"sync"
88
"time"
99

10-
tview "code.rocketnine.space/tslocum/cview"
1110
"github.com/gdamore/tcell/v2"
1211
"github.com/mattn/go-isatty"
1312
"github.com/pkg/errors"
13+
"github.com/rivo/tview"
1414

1515
"github.com/zrepl/zrepl/internal/client/status/viewmodel"
1616
)
@@ -28,7 +28,7 @@ func legacy(c Client, flag statusFlags) error {
2828
textView := tview.NewTextView()
2929
textView.SetWrap(true)
3030
textView.SetScrollable(true) // so that it allows us to set scroll position
31-
textView.SetScrollBarVisibility(tview.ScrollBarNever)
31+
// textView.SetScrollBarVisibility(tview.ScrollBarNever)
3232

3333
app.SetRoot(textView, true)
3434

0 commit comments

Comments
 (0)