mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Migrate gitlab to multisource widget
This commit is contained in:
parent
9a877b5e04
commit
a283dd8ed8
@ -5,9 +5,9 @@ import "github.com/gdamore/tcell"
|
|||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
||||||
widget.SetKeyboardChar("h", widget.Prev, "Select previous item")
|
widget.SetKeyboardChar("h", widget.PrevSource, "Select previous project")
|
||||||
widget.SetKeyboardChar("l", widget.Next, "Select next item")
|
widget.SetKeyboardChar("l", widget.NextSource, "Select next project")
|
||||||
|
|
||||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item")
|
widget.SetKeyboardKey(tcell.KeyLeft, widget.PrevSource, "Select previous project")
|
||||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item")
|
widget.SetKeyboardKey(tcell.KeyRight, widget.NextSource, "Select next project")
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@ import (
|
|||||||
|
|
||||||
type Widget struct {
|
type Widget struct {
|
||||||
wtf.KeyboardWidget
|
wtf.KeyboardWidget
|
||||||
|
wtf.MultiSourceWidget
|
||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
|
||||||
GitlabProjects []*GitlabProject
|
GitlabProjects []*GitlabProject
|
||||||
Idx int
|
|
||||||
|
|
||||||
gitlab *glb.Client
|
gitlab *glb.Client
|
||||||
settings *Settings
|
settings *Settings
|
||||||
@ -26,10 +26,9 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
}
|
}
|
||||||
|
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"),
|
||||||
|
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||||
Idx: 0,
|
|
||||||
|
|
||||||
gitlab: gitlab,
|
gitlab: gitlab,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
@ -39,6 +38,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
widget.View.SetInputCapture(widget.InputCapture)
|
widget.View.SetInputCapture(widget.InputCapture)
|
||||||
|
widget.SetDisplayFunction(widget.display)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
widget.KeyboardWidget.SetView(widget.View)
|
||||||
|
|
||||||
@ -55,24 +55,6 @@ func (widget *Widget) Refresh() {
|
|||||||
widget.display()
|
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 {
|
func (widget *Widget) HelpText() string {
|
||||||
return widget.KeyboardWidget.HelpText()
|
return widget.KeyboardWidget.HelpText()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user