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 {
|
type Widget struct {
|
||||||
wtf.HelpfulWidget
|
wtf.HelpfulWidget
|
||||||
|
wtf.MultiSourceWidget
|
||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
|
||||||
app *tview.Application
|
app *tview.Application
|
||||||
Data []*GitRepo
|
Data []*GitRepo
|
||||||
Idx int
|
|
||||||
pages *tview.Pages
|
pages *tview.Pages
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget("Git", "git", true),
|
MultiSourceWidget: wtf.NewMultiSourceWidget("git", "repository", "repositories"),
|
||||||
|
TextWidget: wtf.NewTextWidget("Git", "git", true),
|
||||||
|
|
||||||
app: app,
|
app: app,
|
||||||
Idx: 0,
|
|
||||||
pages: pages,
|
pages: pages,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widget.LoadSources()
|
||||||
|
widget.SetDisplayFunction(widget.display)
|
||||||
|
|
||||||
widget.HelpfulWidget.SetView(widget.View)
|
widget.HelpfulWidget.SetView(widget.View)
|
||||||
widget.View.SetInputCapture(widget.keyboardIntercept)
|
widget.View.SetInputCapture(widget.keyboardIntercept)
|
||||||
|
|
||||||
@ -68,24 +71,6 @@ func (widget *Widget) Checkout() {
|
|||||||
widget.modalFocus(form)
|
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() {
|
func (widget *Widget) Pull() {
|
||||||
repoToPull := widget.Data[widget.Idx]
|
repoToPull := widget.Data[widget.Idx]
|
||||||
repoToPull.pull()
|
repoToPull.pull()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user