mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Remove common functionality from KeyboardWidget and into Base
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
		
							parent
							
								
									aae98e40e3
								
							
						
					
					
						commit
						d6c8e08c2f
					
				@ -12,17 +12,18 @@ type WtfAppManager struct {
 | 
				
			|||||||
// NewAppManager creates and returns an instance of AppManager
 | 
					// NewAppManager creates and returns an instance of AppManager
 | 
				
			||||||
func NewAppManager() WtfAppManager {
 | 
					func NewAppManager() WtfAppManager {
 | 
				
			||||||
	appMan := WtfAppManager{
 | 
						appMan := WtfAppManager{
 | 
				
			||||||
 | 
							WtfApps: []*WtfApp{},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		selected: 0,
 | 
							selected: 0,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return appMan
 | 
						return appMan
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// AddApp adds a WtfApp to the collection of apps that the AppManager manages.
 | 
					// Add adds a WtfApp to the collection of apps that the AppManager manages.
 | 
				
			||||||
// This app is then available for display onscreen.
 | 
					// This app is then available for display onscreen.
 | 
				
			||||||
func (appMan *WtfAppManager) AddApp(wtfApp *WtfApp) error {
 | 
					func (appMan *WtfAppManager) Add(wtfApp *WtfApp) {
 | 
				
			||||||
	appMan.WtfApps = append(appMan.WtfApps, wtfApp)
 | 
						appMan.WtfApps = append(appMan.WtfApps, wtfApp)
 | 
				
			||||||
	return nil
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Current returns the currently-displaying instance of WtfApp
 | 
					// Current returns the currently-displaying instance of WtfApp
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.go
									
									
									
									
									
								
							@ -77,7 +77,7 @@ func main() {
 | 
				
			|||||||
	wtfApp := makeWtfApp(config, flags.Config)
 | 
						wtfApp := makeWtfApp(config, flags.Config)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	appMan := app.NewAppManager()
 | 
						appMan := app.NewAppManager()
 | 
				
			||||||
	appMan.AddApp(&wtfApp)
 | 
						appMan.Add(&wtfApp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	currentApp, err := appMan.Current()
 | 
						currentApp, err := appMan.Current()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
package buildkite
 | 
					package buildkite
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next workflow")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next workflow")
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next workflow")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next workflow")
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next line")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next line")
 | 
				
			||||||
 | 
				
			|||||||
@ -8,7 +8,6 @@ import (
 | 
				
			|||||||
type Widget struct {
 | 
					type Widget struct {
 | 
				
			||||||
	view.TextWidget
 | 
						view.TextWidget
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// app        *tview.Application
 | 
					 | 
				
			||||||
	clockColl  ClockCollection
 | 
						clockColl  ClockCollection
 | 
				
			||||||
	dateFormat string
 | 
						dateFormat string
 | 
				
			||||||
	timeFormat string
 | 
						timeFormat string
 | 
				
			||||||
@ -19,7 +18,6 @@ func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
 | 
				
			|||||||
	widget := Widget{
 | 
						widget := Widget{
 | 
				
			||||||
		TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
 | 
							TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// app:        app,
 | 
					 | 
				
			||||||
		settings:   settings,
 | 
							settings:   settings,
 | 
				
			||||||
		dateFormat: settings.dateFormat,
 | 
							dateFormat: settings.dateFormat,
 | 
				
			||||||
		timeFormat: settings.timeFormat,
 | 
							timeFormat: settings.timeFormat,
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package devto
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("d", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("d", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package digitalocean
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("?", widget.showInfo, "Show info about the selected droplet")
 | 
						widget.SetKeyboardChar("?", widget.showInfo, "Show info about the selected droplet")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package feedreader
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("h", widget.prevProject, "Select previous project")
 | 
						widget.SetKeyboardChar("h", widget.prevProject, "Select previous project")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package git
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("l", widget.NextSource, "Select next source")
 | 
						widget.SetKeyboardChar("l", widget.NextSource, "Select next source")
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package gitlabtodo
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package gitter
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package hackernews
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package jenkins
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package mercurial
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("l", widget.NextSource, "Select next source")
 | 
						widget.SetKeyboardChar("l", widget.NextSource, "Select next source")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package nbascore
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("l", widget.next, "Select next item")
 | 
						widget.SetKeyboardChar("l", widget.next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
package pihole
 | 
					package pihole
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("d", widget.disable, "disable Pi-hole")
 | 
						widget.SetKeyboardChar("d", widget.disable, "disable Pi-hole")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package pocket
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("a", widget.toggleLink, "Toggle Link")
 | 
						widget.SetKeyboardChar("a", widget.toggleLink, "Toggle Link")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package rollbar
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("l", widget.next, "Select next item")
 | 
						widget.SetKeyboardChar("l", widget.next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("h", widget.selectPrevious, "Select previous item")
 | 
						widget.SetKeyboardChar("h", widget.selectPrevious, "Select previous item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package subreddit
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -6,6 +6,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(nil)
 | 
						widget.InitializeRefreshKeyboardControl(nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("l", widget.NextSource, "Select next file")
 | 
						widget.SetKeyboardChar("l", widget.NextSource, "Select next file")
 | 
				
			||||||
 | 
				
			|||||||
@ -9,6 +9,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package todo_plus
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("d", widget.Delete, "Delete item")
 | 
						widget.SetKeyboardChar("d", widget.Delete, "Delete item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package transmission
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(nil)
 | 
						widget.InitializeRefreshKeyboardControl(nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Prev, "Select previous item")
 | 
						widget.SetKeyboardChar("j", widget.Prev, "Select previous item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package travisci
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package twitch
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -6,6 +6,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("l", widget.NextSource, "Select next source")
 | 
						widget.SetKeyboardChar("l", widget.NextSource, "Select next source")
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
package uptimerobot
 | 
					package uptimerobot
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package weather
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("h", widget.PrevSource, "Select previous city")
 | 
						widget.SetKeyboardChar("h", widget.PrevSource, "Select previous city")
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package zendesk
 | 
				
			|||||||
import "github.com/gdamore/tcell"
 | 
					import "github.com/gdamore/tcell"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (widget *Widget) initializeKeyboardControls() {
 | 
					func (widget *Widget) initializeKeyboardControls() {
 | 
				
			||||||
 | 
						widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
 | 
				
			||||||
	widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
						widget.InitializeRefreshKeyboardControl(widget.Refresh)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
						widget.SetKeyboardChar("j", widget.Next, "Select next item")
 | 
				
			||||||
 | 
				
			|||||||
@ -32,8 +32,8 @@ type Bar struct {
 | 
				
			|||||||
// NewBarGraph creates and returns an instance of BarGraph
 | 
					// NewBarGraph creates and returns an instance of BarGraph
 | 
				
			||||||
func NewBarGraph(tviewApp *tview.Application, name string, commonSettings *cfg.Common) BarGraph {
 | 
					func NewBarGraph(tviewApp *tview.Application, name string, commonSettings *cfg.Common) BarGraph {
 | 
				
			||||||
	widget := BarGraph{
 | 
						widget := BarGraph{
 | 
				
			||||||
		Base:           NewBase(commonSettings),
 | 
							Base:           NewBase(tviewApp, nil, commonSettings),
 | 
				
			||||||
		KeyboardWidget: NewKeyboardWidget(tviewApp, nil, commonSettings),
 | 
							KeyboardWidget: NewKeyboardWidget(commonSettings),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		maxStars: commonSettings.Config.UInt("graphStars", 20),
 | 
							maxStars: commonSettings.Config.UInt("graphStars", 20),
 | 
				
			||||||
		starChar: commonSettings.Config.UString("graphIcon", "|"),
 | 
							starChar: commonSettings.Config.UString("graphIcon", "|"),
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										35
									
								
								view/base.go
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								view/base.go
									
									
									
									
									
								
							@ -4,6 +4,7 @@ import (
 | 
				
			|||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/rivo/tview"
 | 
				
			||||||
	"github.com/wtfutil/wtf/cfg"
 | 
						"github.com/wtfutil/wtf/cfg"
 | 
				
			||||||
	"github.com/wtfutil/wtf/utils"
 | 
						"github.com/wtfutil/wtf/utils"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@ -15,15 +16,19 @@ type Base struct {
 | 
				
			|||||||
	enabledMutex    *sync.Mutex
 | 
						enabledMutex    *sync.Mutex
 | 
				
			||||||
	focusChar       string
 | 
						focusChar       string
 | 
				
			||||||
	focusable       bool
 | 
						focusable       bool
 | 
				
			||||||
 | 
						helpTextFunc    func() string
 | 
				
			||||||
	name            string
 | 
						name            string
 | 
				
			||||||
 | 
						pages           *tview.Pages
 | 
				
			||||||
	quitChan        chan bool
 | 
						quitChan        chan bool
 | 
				
			||||||
	refreshInterval int
 | 
						refreshInterval int
 | 
				
			||||||
	refreshing      bool
 | 
						refreshing      bool
 | 
				
			||||||
 | 
						tviewApp        *tview.Application
 | 
				
			||||||
 | 
						view            *tview.TextView
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewBase creates and returns an instance of the Base module, the lowest-level
 | 
					// NewBase creates and returns an instance of the Base module, the lowest-level
 | 
				
			||||||
// primitive module from which all others are derived
 | 
					// primitive module from which all others are derived
 | 
				
			||||||
func NewBase(commonSettings *cfg.Common) *Base {
 | 
					func NewBase(tviewApp *tview.Application, pages *tview.Pages, commonSettings *cfg.Common) *Base {
 | 
				
			||||||
	base := &Base{
 | 
						base := &Base{
 | 
				
			||||||
		commonSettings: commonSettings,
 | 
							commonSettings: commonSettings,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -33,9 +38,11 @@ func NewBase(commonSettings *cfg.Common) *Base {
 | 
				
			|||||||
		focusChar:       commonSettings.FocusChar(),
 | 
							focusChar:       commonSettings.FocusChar(),
 | 
				
			||||||
		focusable:       commonSettings.Focusable,
 | 
							focusable:       commonSettings.Focusable,
 | 
				
			||||||
		name:            commonSettings.Name,
 | 
							name:            commonSettings.Name,
 | 
				
			||||||
 | 
							pages:           pages,
 | 
				
			||||||
		quitChan:        make(chan bool),
 | 
							quitChan:        make(chan bool),
 | 
				
			||||||
		refreshInterval: commonSettings.RefreshInterval,
 | 
							refreshInterval: commonSettings.RefreshInterval,
 | 
				
			||||||
		refreshing:      false,
 | 
							refreshing:      false,
 | 
				
			||||||
 | 
							tviewApp:        tviewApp,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return base
 | 
						return base
 | 
				
			||||||
@ -131,6 +138,32 @@ func (base *Base) SetFocusChar(char string) {
 | 
				
			|||||||
	base.focusChar = char
 | 
						base.focusChar = char
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// SetView assigns the passed-in tview.TextView view to this widget
 | 
				
			||||||
 | 
					func (base *Base) SetView(view *tview.TextView) {
 | 
				
			||||||
 | 
						base.view = view
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ShowHelp displays the modal help dialog for a module
 | 
				
			||||||
 | 
					func (base *Base) ShowHelp() {
 | 
				
			||||||
 | 
						if base.pages == nil {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						closeFunc := func() {
 | 
				
			||||||
 | 
							base.pages.RemovePage("help")
 | 
				
			||||||
 | 
							base.tviewApp.SetFocus(base.view)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						modal := NewBillboardModal(base.helpTextFunc(), closeFunc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						base.pages.AddPage("help", modal, false, true)
 | 
				
			||||||
 | 
						base.tviewApp.SetFocus(modal)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						base.tviewApp.QueueUpdate(func() {
 | 
				
			||||||
 | 
							base.tviewApp.Draw()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (base *Base) Stop() {
 | 
					func (base *Base) Stop() {
 | 
				
			||||||
	base.enabledMutex.Lock()
 | 
						base.enabledMutex.Lock()
 | 
				
			||||||
	base.enabled = false
 | 
						base.enabled = false
 | 
				
			||||||
 | 
				
			|||||||
@ -5,11 +5,11 @@ import (
 | 
				
			|||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gdamore/tcell"
 | 
						"github.com/gdamore/tcell"
 | 
				
			||||||
	"github.com/rivo/tview"
 | 
					 | 
				
			||||||
	"github.com/wtfutil/wtf/cfg"
 | 
						"github.com/wtfutil/wtf/cfg"
 | 
				
			||||||
	"github.com/wtfutil/wtf/utils"
 | 
						"github.com/wtfutil/wtf/utils"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const helpKeyChar = "/"
 | 
				
			||||||
const refreshKeyChar = "r"
 | 
					const refreshKeyChar = "r"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type helpItem struct {
 | 
					type helpItem struct {
 | 
				
			||||||
@ -19,10 +19,7 @@ type helpItem struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// KeyboardWidget manages keyboard control for a widget
 | 
					// KeyboardWidget manages keyboard control for a widget
 | 
				
			||||||
type KeyboardWidget struct {
 | 
					type KeyboardWidget struct {
 | 
				
			||||||
	pages    *tview.Pages
 | 
					 | 
				
			||||||
	settings *cfg.Common
 | 
						settings *cfg.Common
 | 
				
			||||||
	tviewApp *tview.Application
 | 
					 | 
				
			||||||
	view     *tview.TextView
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	charMap  map[string]func()
 | 
						charMap  map[string]func()
 | 
				
			||||||
	keyMap   map[tcell.Key]func()
 | 
						keyMap   map[tcell.Key]func()
 | 
				
			||||||
@ -32,10 +29,9 @@ type KeyboardWidget struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewKeyboardWidget creates and returns a new instance of KeyboardWidget
 | 
					// NewKeyboardWidget creates and returns a new instance of KeyboardWidget
 | 
				
			||||||
func NewKeyboardWidget(tviewApp *tview.Application, pages *tview.Pages, settings *cfg.Common) *KeyboardWidget {
 | 
					// func NewKeyboardWidget(tviewApp *tview.Application, pages *tview.Pages, settings *cfg.Common) *KeyboardWidget {
 | 
				
			||||||
 | 
					func NewKeyboardWidget(settings *cfg.Common) *KeyboardWidget {
 | 
				
			||||||
	keyWidget := &KeyboardWidget{
 | 
						keyWidget := &KeyboardWidget{
 | 
				
			||||||
		tviewApp: tviewApp,
 | 
					 | 
				
			||||||
		pages:    pages,
 | 
					 | 
				
			||||||
		settings: settings,
 | 
							settings: settings,
 | 
				
			||||||
		charMap:  make(map[string]func()),
 | 
							charMap:  make(map[string]func()),
 | 
				
			||||||
		keyMap:   make(map[tcell.Key]func()),
 | 
							keyMap:   make(map[tcell.Key]func()),
 | 
				
			||||||
@ -78,6 +74,14 @@ func (widget *KeyboardWidget) HelpText() string {
 | 
				
			|||||||
	return str
 | 
						return str
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// InitializeHelpTextKeyboardControl assigns the function that displays help text to the
 | 
				
			||||||
 | 
					// common help text key value
 | 
				
			||||||
 | 
					func (widget *KeyboardWidget) InitializeHelpTextKeyboardControl(helpFunc func()) {
 | 
				
			||||||
 | 
						if helpFunc != nil {
 | 
				
			||||||
 | 
							widget.SetKeyboardChar(helpKeyChar, helpFunc, "Show/hide this help prompt")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// InitializeRefreshKeyboardControl assigns the module's explicit refresh function to
 | 
					// InitializeRefreshKeyboardControl assigns the module's explicit refresh function to
 | 
				
			||||||
// the commom refresh key value
 | 
					// the commom refresh key value
 | 
				
			||||||
func (widget *KeyboardWidget) InitializeRefreshKeyboardControl(refreshFunc func()) {
 | 
					func (widget *KeyboardWidget) InitializeRefreshKeyboardControl(refreshFunc func()) {
 | 
				
			||||||
@ -155,37 +159,10 @@ func (widget *KeyboardWidget) SetKeyboardKey(key tcell.Key, fn func(), helpText
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SetView assigns the passed-in tview.TextView view to this widget
 | 
					 | 
				
			||||||
func (widget *KeyboardWidget) SetView(view *tview.TextView) {
 | 
					 | 
				
			||||||
	widget.view = view
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// ShowHelp displays the modal help dialog for a module
 | 
					 | 
				
			||||||
func (widget *KeyboardWidget) ShowHelp() {
 | 
					 | 
				
			||||||
	if widget.pages == nil {
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	closeFunc := func() {
 | 
					 | 
				
			||||||
		widget.pages.RemovePage("help")
 | 
					 | 
				
			||||||
		widget.tviewApp.SetFocus(widget.view)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	modal := NewBillboardModal(widget.HelpText(), closeFunc)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	widget.pages.AddPage("help", modal, false, true)
 | 
					 | 
				
			||||||
	widget.tviewApp.SetFocus(modal)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	widget.tviewApp.QueueUpdate(func() {
 | 
					 | 
				
			||||||
		widget.tviewApp.Draw()
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* -------------------- Unexported Functions -------------------- */
 | 
					/* -------------------- Unexported Functions -------------------- */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// initializeCommonKeyboardControls sets up the keyboard controls that are common to
 | 
					// initializeCommonKeyboardControls sets up the keyboard controls that are common to
 | 
				
			||||||
// all widgets that accept keyboard input
 | 
					// all widgets that accept keyboard input
 | 
				
			||||||
func (widget *KeyboardWidget) initializeCommonKeyboardControls() {
 | 
					func (widget *KeyboardWidget) initializeCommonKeyboardControls() {
 | 
				
			||||||
	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
 | 
					 | 
				
			||||||
	widget.SetKeyboardChar("\\", widget.LaunchDocumentation, "Open the documentation for this module in a browser")
 | 
						widget.SetKeyboardChar("\\", widget.LaunchDocumentation, "Open the documentation for this module in a browser")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -4,7 +4,6 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gdamore/tcell"
 | 
						"github.com/gdamore/tcell"
 | 
				
			||||||
	"github.com/rivo/tview"
 | 
					 | 
				
			||||||
	"github.com/stretchr/testify/assert"
 | 
						"github.com/stretchr/testify/assert"
 | 
				
			||||||
	"github.com/wtfutil/wtf/cfg"
 | 
						"github.com/wtfutil/wtf/cfg"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@ -13,8 +12,6 @@ func test() {}
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func testKeyboardWidget() *KeyboardWidget {
 | 
					func testKeyboardWidget() *KeyboardWidget {
 | 
				
			||||||
	keyWid := NewKeyboardWidget(
 | 
						keyWid := NewKeyboardWidget(
 | 
				
			||||||
		tview.NewApplication(),
 | 
					 | 
				
			||||||
		tview.NewPages(),
 | 
					 | 
				
			||||||
		&cfg.Common{
 | 
							&cfg.Common{
 | 
				
			||||||
			Module: cfg.Module{
 | 
								Module: cfg.Module{
 | 
				
			||||||
				Name: "testWidget",
 | 
									Name: "testWidget",
 | 
				
			||||||
@ -178,7 +175,6 @@ func Test_initializeCommonKeyboardControls(t *testing.T) {
 | 
				
			|||||||
	t.Run("nil refreshFunc", func(t *testing.T) {
 | 
						t.Run("nil refreshFunc", func(t *testing.T) {
 | 
				
			||||||
		keyWid := testKeyboardWidget()
 | 
							keyWid := testKeyboardWidget()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		assert.NotNil(t, keyWid.charMap["/"])
 | 
					 | 
				
			||||||
		assert.NotNil(t, keyWid.charMap["\\"])
 | 
							assert.NotNil(t, keyWid.charMap["\\"])
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -206,18 +202,3 @@ func Test_HelpText(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	assert.NotNil(t, keyWid.HelpText())
 | 
						assert.NotNil(t, keyWid.HelpText())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func Test_SetView(t *testing.T) {
 | 
					 | 
				
			||||||
	keyWid := testKeyboardWidget()
 | 
					 | 
				
			||||||
	assert.Nil(t, keyWid.view)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	view := &tview.TextView{}
 | 
					 | 
				
			||||||
	keyWid.SetView(view)
 | 
					 | 
				
			||||||
	assert.Equal(t, view, keyWid.view)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func Test_ShowHelp(t *testing.T) {
 | 
					 | 
				
			||||||
	keyWid := testKeyboardWidget()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	assert.NotPanics(t, func() { keyWid.ShowHelp() })
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -21,8 +21,8 @@ type TextWidget struct {
 | 
				
			|||||||
// NewTextWidget creates and returns an instance of TextWidget
 | 
					// NewTextWidget creates and returns an instance of TextWidget
 | 
				
			||||||
func NewTextWidget(tviewApp *tview.Application, pages *tview.Pages, commonSettings *cfg.Common) TextWidget {
 | 
					func NewTextWidget(tviewApp *tview.Application, pages *tview.Pages, commonSettings *cfg.Common) TextWidget {
 | 
				
			||||||
	widget := TextWidget{
 | 
						widget := TextWidget{
 | 
				
			||||||
		Base:           NewBase(commonSettings),
 | 
							Base:           NewBase(tviewApp, pages, commonSettings),
 | 
				
			||||||
		KeyboardWidget: NewKeyboardWidget(tviewApp, pages, commonSettings),
 | 
							KeyboardWidget: NewKeyboardWidget(commonSettings),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		tviewApp: tviewApp,
 | 
							tviewApp: tviewApp,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -30,7 +30,8 @@ func NewTextWidget(tviewApp *tview.Application, pages *tview.Pages, commonSettin
 | 
				
			|||||||
	widget.View = widget.createView(widget.bordered)
 | 
						widget.View = widget.createView(widget.bordered)
 | 
				
			||||||
	widget.View.SetInputCapture(widget.KeyboardWidget.InputCapture)
 | 
						widget.View.SetInputCapture(widget.KeyboardWidget.InputCapture)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.KeyboardWidget.SetView(widget.View)
 | 
						widget.Base.SetView(widget.View)
 | 
				
			||||||
 | 
						widget.Base.helpTextFunc = widget.KeyboardWidget.HelpText
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return widget
 | 
						return widget
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -42,8 +43,8 @@ func (widget *TextWidget) TextView() *tview.TextView {
 | 
				
			|||||||
	return widget.View
 | 
						return widget.View
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Redraw forces a refresh of the onscreen text content of this widget
 | 
				
			||||||
func (widget *TextWidget) Redraw(data func() (string, string, bool)) {
 | 
					func (widget *TextWidget) Redraw(data func() (string, string, bool)) {
 | 
				
			||||||
	// FIXME: This is coming from KeyboardWidget, which seems wrong
 | 
					 | 
				
			||||||
	widget.tviewApp.QueueUpdateDraw(func() {
 | 
						widget.tviewApp.QueueUpdateDraw(func() {
 | 
				
			||||||
		title, content, wrap := data()
 | 
							title, content, wrap := data()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user