1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Move common nav controls into MultiSourceWidget

This commit is contained in:
Chris Cummer
2018-09-01 17:37:09 -07:00
parent e760561027
commit ad431ee3a7
3 changed files with 51 additions and 47 deletions

View File

@@ -36,11 +36,12 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
widget := Widget{
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
MultiSourceWidget: wtf.NewMultiSourceWidget(),
MultiSourceWidget: wtf.NewMultiSourceWidget("textfile", "filePath", "filePaths"),
TextWidget: wtf.NewTextWidget("TextFile", "textfile", true),
}
widget.LoadSources("textfile", "filePath", "filePaths")
widget.LoadSources()
widget.SetDisplayFunction(widget.display)
widget.HelpfulWidget.SetView(widget.View)
@@ -53,24 +54,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Next() {
widget.Idx = widget.Idx + 1
if widget.Idx == len(widget.Sources) {
widget.Idx = 0
}
widget.display()
}
func (widget *Widget) Prev() {
widget.Idx = widget.Idx - 1
if widget.Idx < 0 {
widget.Idx = len(widget.Sources) - 1
}
widget.display()
}
// Refresh is called on the interval and refreshes the data
func (widget *Widget) Refresh() {
widget.UpdateRefreshedAt()
widget.display()