mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-22 00:13:52 +01:00
zrepl status: switch back to tview from cview & upgrade to latest (#846)
While investigating https://github.com/zrepl/zrepl/issues/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 https://github.com/zrepl/zrepl/issues/700
This commit is contained in:
parent
bca37c741c
commit
d7ede3f82c
5
go.mod
5
go.mod
@ -1,10 +1,10 @@
|
|||||||
module github.com/zrepl/zrepl
|
module github.com/zrepl/zrepl
|
||||||
|
|
||||||
go 1.22.7
|
go 1.22.7
|
||||||
|
|
||||||
toolchain go1.23.1
|
toolchain go1.23.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
code.rocketnine.space/tslocum/cview v1.5.9
|
|
||||||
github.com/bits-and-blooms/bitset v1.14.3
|
github.com/bits-and-blooms/bitset v1.14.3
|
||||||
github.com/fatih/color v1.7.0
|
github.com/fatih/color v1.7.0
|
||||||
github.com/gdamore/tcell/v2 v2.7.4
|
github.com/gdamore/tcell/v2 v2.7.4
|
||||||
@ -70,7 +70,8 @@ require (
|
|||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/prometheus/client_model v0.6.1 // indirect
|
github.com/prometheus/client_model v0.6.1 // indirect
|
||||||
github.com/prometheus/procfs v0.15.1 // indirect
|
github.com/prometheus/procfs v0.15.1 // indirect
|
||||||
github.com/rivo/uniseg v0.4.6 // indirect
|
github.com/rivo/tview v0.0.0-20241103174730-c76f7879f592
|
||||||
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44 // indirect; go1.12 thinks it needs this
|
github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44 // indirect; go1.12 thinks it needs this
|
||||||
github.com/theckman/goconstraint v1.11.0 // indirect
|
github.com/theckman/goconstraint v1.11.0 // indirect
|
||||||
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect; go1.12 thinks it needs this
|
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect; go1.12 thinks it needs this
|
||||||
|
4
go.sum
4
go.sum
@ -122,11 +122,15 @@ github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJ
|
|||||||
github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0=
|
github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0=
|
||||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||||
|
github.com/rivo/tview v0.0.0-20241103174730-c76f7879f592 h1:YIJ+B1hePP6AgynC5TcqpO0H9k3SSoZa2BGyL6vDUzM=
|
||||||
|
github.com/rivo/tview v0.0.0-20241103174730-c76f7879f592/go.mod h1:02iFIz7K/A9jGCvrizLPvoqr4cEIx7q54RH5Qudkrss=
|
||||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/rivo/uniseg v0.4.6 h1:Sovz9sDSwbOz9tgUy8JpT+KgCkPYJEN/oYzlJiYTNLg=
|
github.com/rivo/uniseg v0.4.6 h1:Sovz9sDSwbOz9tgUy8JpT+KgCkPYJEN/oYzlJiYTNLg=
|
||||||
github.com/rivo/uniseg v0.4.6/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.6/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
|
@ -7,9 +7,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
tview "code.rocketnine.space/tslocum/cview"
|
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/zrepl/zrepl/internal/client/status/viewmodel"
|
"github.com/zrepl/zrepl/internal/client/status/viewmodel"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,7 +28,6 @@ func interactive(c Client, flag statusFlags) error {
|
|||||||
jobMenuRoot.SetSelectable(true)
|
jobMenuRoot.SetSelectable(true)
|
||||||
jobMenu.SetRoot(jobMenuRoot)
|
jobMenu.SetRoot(jobMenuRoot)
|
||||||
jobMenu.SetCurrentNode(jobMenuRoot)
|
jobMenu.SetCurrentNode(jobMenuRoot)
|
||||||
jobMenu.SetSelectedTextColor(tcell.ColorGreen)
|
|
||||||
jobTextDetail := tview.NewTextView()
|
jobTextDetail := tview.NewTextView()
|
||||||
jobTextDetail.SetWrap(false)
|
jobTextDetail.SetWrap(false)
|
||||||
|
|
||||||
@ -110,10 +108,8 @@ func interactive(c Client, flag statusFlags) error {
|
|||||||
}
|
}
|
||||||
app.SetRoot(toolbarSplit, true)
|
app.SetRoot(toolbarSplit, true)
|
||||||
app.SetFocus(preModalFocus)
|
app.SetFocus(preModalFocus)
|
||||||
app.Draw()
|
|
||||||
})
|
})
|
||||||
app.SetRoot(m, true)
|
app.SetRoot(m, true)
|
||||||
app.Draw()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.SetRoot(toolbarSplit, true)
|
app.SetRoot(toolbarSplit, true)
|
||||||
@ -170,12 +166,14 @@ func interactive(c Client, flag statusFlags) error {
|
|||||||
redrawJobsList = true
|
redrawJobsList = true
|
||||||
}
|
}
|
||||||
if redrawJobsList {
|
if redrawJobsList {
|
||||||
|
selectedTextStyle := tcell.StyleDefault.Bold(true)
|
||||||
selectedJobN = nil
|
selectedJobN = nil
|
||||||
children := make([]*tview.TreeNode, len(jobs))
|
children := make([]*tview.TreeNode, len(jobs))
|
||||||
for i := range jobs {
|
for i := range jobs {
|
||||||
jobN := tview.NewTreeNode(jobs[i].JobTreeTitle())
|
jobN := tview.NewTreeNode(jobs[i].JobTreeTitle())
|
||||||
jobN.SetReference(jobs[i])
|
jobN.SetReference(jobs[i])
|
||||||
jobN.SetSelectable(true)
|
jobN.SetSelectable(true)
|
||||||
|
jobN.SetSelectedTextStyle(selectedTextStyle)
|
||||||
children[i] = jobN
|
children[i] = jobN
|
||||||
jobN.SetSelectedFunc(func() {
|
jobN.SetSelectedFunc(func() {
|
||||||
viewmodelupdate(func(p *viewmodel.Params) {
|
viewmodelupdate(func(p *viewmodel.Params) {
|
||||||
@ -187,6 +185,7 @@ func interactive(c Client, flag statusFlags) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobMenuRoot.SetChildren(children)
|
jobMenuRoot.SetChildren(children)
|
||||||
|
jobMenuRoot.SetSelectedTextStyle(selectedTextStyle)
|
||||||
}
|
}
|
||||||
|
|
||||||
if selectedJobN != nil && jobMenu.GetCurrentNode() != selectedJobN {
|
if selectedJobN != nil && jobMenu.GetCurrentNode() != selectedJobN {
|
||||||
@ -207,9 +206,6 @@ func interactive(c Client, flag statusFlags) error {
|
|||||||
bottombar.ResizeItem(bottombarDateView, len(bottombardatestring), 0)
|
bottombar.ResizeItem(bottombarDateView, len(bottombardatestring), 0)
|
||||||
|
|
||||||
bottomBarStatus.SetText(m.BottomBarStatus())
|
bottomBarStatus.SetText(m.BottomBarStatus())
|
||||||
|
|
||||||
app.Draw()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
@ -252,6 +248,7 @@ func interactive(c Client, flag statusFlags) error {
|
|||||||
|
|
||||||
app.SetInputCapture(func(e *tcell.EventKey) *tcell.EventKey {
|
app.SetInputCapture(func(e *tcell.EventKey) *tcell.EventKey {
|
||||||
if e.Key() == tcell.KeyTab {
|
if e.Key() == tcell.KeyTab {
|
||||||
|
// TODO: only if there's no modal showing (long-time bug in zrepl status)
|
||||||
tabbableCycle()
|
tabbableCycle()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -284,9 +281,8 @@ func interactive(c Client, flag statusFlags) error {
|
|||||||
signals := []string{"wakeup", "reset"}
|
signals := []string{"wakeup", "reset"}
|
||||||
clientFuncs := []func(job string) error{c.SignalWakeup, c.SignalReset}
|
clientFuncs := []func(job string) error{c.SignalWakeup, c.SignalReset}
|
||||||
sigMod := tview.NewModal()
|
sigMod := tview.NewModal()
|
||||||
sigMod.SetBackgroundColor(tcell.ColorDefault)
|
|
||||||
sigMod.SetBorder(true)
|
sigMod.SetBorder(true)
|
||||||
sigMod.GetForm().SetButtonTextColorFocused(tcell.ColorGreen)
|
sigMod.SetButtonActivatedStyle(tcell.StyleDefault.Bold(true).Reverse(true))
|
||||||
sigMod.AddButtons(signals)
|
sigMod.AddButtons(signals)
|
||||||
sigMod.SetText(fmt.Sprintf("Send a signal to job %q", job.Name()))
|
sigMod.SetText(fmt.Sprintf("Send a signal to job %q", job.Name()))
|
||||||
showModal(sigMod, func(idx int, _ string) {
|
showModal(sigMod, func(idx int, _ string) {
|
||||||
|
@ -7,10 +7,10 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
tview "code.rocketnine.space/tslocum/cview"
|
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/rivo/tview"
|
||||||
|
|
||||||
"github.com/zrepl/zrepl/internal/client/status/viewmodel"
|
"github.com/zrepl/zrepl/internal/client/status/viewmodel"
|
||||||
)
|
)
|
||||||
@ -28,7 +28,7 @@ func legacy(c Client, flag statusFlags) error {
|
|||||||
textView := tview.NewTextView()
|
textView := tview.NewTextView()
|
||||||
textView.SetWrap(true)
|
textView.SetWrap(true)
|
||||||
textView.SetScrollable(true) // so that it allows us to set scroll position
|
textView.SetScrollable(true) // so that it allows us to set scroll position
|
||||||
textView.SetScrollBarVisibility(tview.ScrollBarNever)
|
// textView.SetScrollBarVisibility(tview.ScrollBarNever)
|
||||||
|
|
||||||
app.SetRoot(textView, true)
|
app.SetRoot(textView, true)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user