Skip to content

Commit

Permalink
Git module now uses the MultiSourceWidget composition
Browse files Browse the repository at this point in the history
  • Loading branch information
senorprogrammer committed Sep 2, 2018
1 parent ad431ee commit 4a90383
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions git/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()
Expand Down

0 comments on commit 4a90383

Please sign in to comment.