mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Git module now uses the MultiSourceWidget composition
This commit is contained in:
parent
ad431ee3a7
commit
4a90383f0d
@ -25,24 +25,27 @@ const modalHeight = 7
|
||||
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.MultiSourceWidget
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
Data []*GitRepo
|
||||
Idx int
|
||||
pages *tview.Pages
|
||||
}
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("Git", "git", true),
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
MultiSourceWidget: wtf.NewMultiSourceWidget("git", "repository", "repositories"),
|
||||
TextWidget: wtf.NewTextWidget("Git", "git", true),
|
||||
|
||||
app: app,
|
||||
Idx: 0,
|
||||
pages: pages,
|
||||
}
|
||||
|
||||
widget.LoadSources()
|
||||
widget.SetDisplayFunction(widget.display)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.View.SetInputCapture(widget.keyboardIntercept)
|
||||
|
||||
@ -68,24 +71,6 @@ func (widget *Widget) Checkout() {
|
||||
widget.modalFocus(form)
|
||||
}
|
||||
|
||||
func (widget *Widget) Next() {
|
||||
widget.Idx = widget.Idx + 1
|
||||
if widget.Idx == len(widget.Data) {
|
||||
widget.Idx = 0
|
||||
}
|
||||
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) Prev() {
|
||||
widget.Idx = widget.Idx - 1
|
||||
if widget.Idx < 0 {
|
||||
widget.Idx = len(widget.Data) - 1
|
||||
}
|
||||
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) Pull() {
|
||||
repoToPull := widget.Data[widget.Idx]
|
||||
repoToPull.pull()
|
||||
|
Loading…
x
Reference in New Issue
Block a user