Skip to content

Commit

Permalink
Merge pull request #462 from Seanstoppable/gitlabmultisource
Browse files Browse the repository at this point in the history
Migrate gitlab to multisource widget
  • Loading branch information
senorprogrammer committed May 25, 2019
2 parents ce72341 + ba9ed05 commit cfd5dfe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
8 changes: 4 additions & 4 deletions modules/gitlab/keyboard.go
Expand Up @@ -5,9 +5,9 @@ import "github.com/gdamore/tcell"
func (widget *Widget) initializeKeyboardControls() {
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
widget.SetKeyboardChar("h", widget.Prev, "Select previous item")
widget.SetKeyboardChar("l", widget.Next, "Select next item")
widget.SetKeyboardChar("h", widget.PrevSource, "Select previous project")
widget.SetKeyboardChar("l", widget.NextSource, "Select next project")

widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item")
widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item")
widget.SetKeyboardKey(tcell.KeyLeft, widget.PrevSource, "Select previous project")
widget.SetKeyboardKey(tcell.KeyRight, widget.NextSource, "Select next project")
}
28 changes: 5 additions & 23 deletions modules/gitlab/widget.go
Expand Up @@ -8,10 +8,10 @@ import (

type Widget struct {
wtf.KeyboardWidget
wtf.MultiSourceWidget
wtf.TextWidget

GitlabProjects []*GitlabProject
Idx int

gitlab *glb.Client
settings *Settings
Expand All @@ -26,10 +26,9 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
}

widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
TextWidget: wtf.NewTextWidget(app, settings.common, true),

Idx: 0,
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"),
TextWidget: wtf.NewTextWidget(app, settings.common, true),

gitlab: gitlab,
settings: settings,
Expand All @@ -39,6 +38,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *

widget.initializeKeyboardControls()
widget.View.SetInputCapture(widget.InputCapture)
widget.SetDisplayFunction(widget.display)

widget.KeyboardWidget.SetView(widget.View)

Expand All @@ -55,24 +55,6 @@ func (widget *Widget) Refresh() {
widget.display()
}

func (widget *Widget) Next() {
widget.Idx++
if widget.Idx == len(widget.GitlabProjects) {
widget.Idx = 0
}

widget.display()
}

func (widget *Widget) Prev() {
widget.Idx--
if widget.Idx < 0 {
widget.Idx = len(widget.GitlabProjects) - 1
}

widget.display()
}

func (widget *Widget) HelpText() string {
return widget.KeyboardWidget.HelpText()
}
Expand Down

0 comments on commit cfd5dfe

Please sign in to comment.