mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Merge branch 'master' into pagerduty-schedule-specifications
This commit is contained in:
		
						commit
						2f2599b34f
					
				| @ -6,6 +6,7 @@ import ( | |||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 
 | 
 | ||||||
| 	goFlags "github.com/jessevdk/go-flags" | 	goFlags "github.com/jessevdk/go-flags" | ||||||
|  | 	"github.com/olebedev/config" | ||||||
| 	"github.com/wtfutil/wtf/help" | 	"github.com/wtfutil/wtf/help" | ||||||
| 	"github.com/wtfutil/wtf/utils" | 	"github.com/wtfutil/wtf/utils" | ||||||
| ) | ) | ||||||
| @ -28,9 +29,9 @@ func (flags *Flags) ConfigFilePath() string { | |||||||
| 	return flags.Config | 	return flags.Config | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (flags *Flags) Display(version string) { | func (flags *Flags) Display(version string, config *config.Config) { | ||||||
| 	if flags.HasModule() { | 	if flags.HasModule() { | ||||||
| 		help.Display(flags.Module) | 		help.Display(flags.Module, config) | ||||||
| 		os.Exit(0) | 		os.Exit(0) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										33
									
								
								help/help.go
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								help/help.go
									
									
									
									
									
								
							| @ -3,37 +3,20 @@ package help | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 
 | 
 | ||||||
| 	"github.com/wtfutil/wtf/modules/git" | 	//"github.com/wtfutil/wtf/cfg" | ||||||
| 	"github.com/wtfutil/wtf/modules/github" | 	"github.com/olebedev/config" | ||||||
| 	"github.com/wtfutil/wtf/modules/textfile" | 	"github.com/wtfutil/wtf/maker" | ||||||
| 	"github.com/wtfutil/wtf/modules/todo" |  | ||||||
| 	"github.com/wtfutil/wtf/modules/todoist" |  | ||||||
| 	"github.com/wtfutil/wtf/modules/weatherservices/weather" |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func Display(moduleName string) { | func Display(moduleName string, config *config.Config) { | ||||||
| 	if moduleName == "" { | 	if moduleName == "" { | ||||||
| 		fmt.Println("\n  --module takes a module name as an argument, i.e: '--module=github'") | 		fmt.Println("\n  --module takes a module name as an argument, i.e: '--module=github'") | ||||||
| 	} else { | 	} else { | ||||||
| 		fmt.Printf("%s\n", helpFor(moduleName)) | 		fmt.Printf("%s\n", helpFor(moduleName, config)) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func helpFor(moduleName string) string { | func helpFor(moduleName string, config *config.Config) string { | ||||||
| 	switch moduleName { | 	widget := maker.MakeWidget(nil, nil, moduleName, moduleName, config, config) | ||||||
| 	case "git": | 	return widget.HelpText() | ||||||
| 		return git.HelpText |  | ||||||
| 	case "github": |  | ||||||
| 		return github.HelpText |  | ||||||
| 	case "textfile": |  | ||||||
| 		return textfile.HelpText |  | ||||||
| 	case "todo": |  | ||||||
| 		return todo.HelpText |  | ||||||
| 	case "todoist": |  | ||||||
| 		return todoist.HelpText |  | ||||||
| 	case "weather": |  | ||||||
| 		return weather.HelpText |  | ||||||
| 	default: |  | ||||||
| 		return fmt.Sprintf("\n  There is no help available for '%s'", moduleName) |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										5
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								main.go
									
									
									
									
									
								
							| @ -114,14 +114,13 @@ func main() { | |||||||
| 
 | 
 | ||||||
| 	flags := flags.NewFlags() | 	flags := flags.NewFlags() | ||||||
| 	flags.Parse() | 	flags.Parse() | ||||||
| 	flags.Display(version) | 	config := cfg.LoadConfigFile(flags.ConfigFilePath()) | ||||||
|  | 	flags.Display(version, config) | ||||||
| 
 | 
 | ||||||
| 	cfg.MigrateOldConfig() | 	cfg.MigrateOldConfig() | ||||||
| 	cfg.CreateConfigDir() | 	cfg.CreateConfigDir() | ||||||
| 	cfg.CreateConfigFile() | 	cfg.CreateConfigFile() | ||||||
| 
 | 
 | ||||||
| 	config := cfg.LoadConfigFile(flags.ConfigFilePath()) |  | ||||||
| 
 |  | ||||||
| 	if flags.Profile { | 	if flags.Profile { | ||||||
| 		defer profile.Start(profile.MemProfile).Stop() | 		defer profile.Start(profile.MemProfile).Stop() | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -6,7 +6,8 @@ import ( | |||||||
| 
 | 
 | ||||||
| func (widget *Widget) display(clocks []Clock, dateFormat string, timeFormat string) { | func (widget *Widget) display(clocks []Clock, dateFormat string, timeFormat string) { | ||||||
| 	if len(clocks) == 0 { | 	if len(clocks) == 0 { | ||||||
| 		widget.View.SetText(fmt.Sprintf("\n%s", " no timezone data available")) | 		title := fmt.Sprintf("\n%s", " no timezone data available") | ||||||
|  | 		widget.Redraw(widget.CommonSettings.Title, title, true) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -8,12 +8,12 @@ import ( | |||||||
| 
 | 
 | ||||||
| func (widget *Widget) display() { | func (widget *Widget) display() { | ||||||
| 	if ok == false { | 	if ok == false { | ||||||
| 		widget.View.SetText(errorText) | 		widget.Redraw(widget.CommonSettings.Title, errorText, true) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	summaryText := widget.summaryText(&widget.summaryList) | 	summaryText := widget.summaryText(&widget.summaryList) | ||||||
| 	widget.View.SetText(summaryText) | 	widget.Redraw(widget.CommonSettings.Title, summaryText, false) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) summaryText(list *summaryList) string { | func (widget *Widget) summaryText(list *summaryList) string { | ||||||
|  | |||||||
| @ -80,9 +80,7 @@ func makeMarketCurrency(name string) *mCurrency { | |||||||
| func (widget *Widget) Refresh() { | func (widget *Widget) Refresh() { | ||||||
| 	widget.updateSummary() | 	widget.updateSummary() | ||||||
| 
 | 
 | ||||||
| 	widget.app.QueueUpdateDraw(func() { |  | ||||||
| 	widget.display() | 	widget.display() | ||||||
| 	}) |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| @ -142,9 +140,7 @@ func (widget *Widget) updateSummary() { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	widget.app.QueueUpdateDraw(func() { |  | ||||||
| 	widget.display() | 	widget.display() | ||||||
| 	}) |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func makeRequest(baseName, marketName string) *http.Request { | func makeRequest(baseName, marketName string) *http.Request { | ||||||
|  | |||||||
| @ -36,15 +36,13 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget { | |||||||
| func (widget *Widget) Refresh() { | func (widget *Widget) Refresh() { | ||||||
| 	positions, err := Fetch(widget.device_token) | 	positions, err := Fetch(widget.device_token) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  | 		widget.Redraw(widget.CommonSettings.Title, err.Error(), true) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	content := widget.contentFrom(positions) | 	content := widget.contentFrom(positions) | ||||||
| 
 | 
 | ||||||
| 	widget.app.QueueUpdateDraw(func() { | 	widget.Redraw(widget.CommonSettings.Title, content, false) | ||||||
| 		widget.View.SetTitle(widget.CommonSettings.Title) |  | ||||||
| 		widget.View.SetText(content) |  | ||||||
| 	}) |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
|  | |||||||
| @ -48,9 +48,7 @@ func (widget *Widget) Refresh() { | |||||||
| 	widget.toplistWidget.Refresh(&wg) | 	widget.toplistWidget.Refresh(&wg) | ||||||
| 	wg.Wait() | 	wg.Wait() | ||||||
| 
 | 
 | ||||||
| 	widget.app.QueueUpdateDraw(func() { |  | ||||||
| 	widget.display() | 	widget.display() | ||||||
| 	}) |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| @ -60,5 +58,5 @@ func (widget *Widget) display() { | |||||||
| 	str += widget.priceWidget.Result | 	str += widget.priceWidget.Result | ||||||
| 	str += widget.toplistWidget.Result | 	str += widget.toplistWidget.Result | ||||||
| 
 | 
 | ||||||
| 	widget.View.SetText(fmt.Sprintf("\n%s", str)) | 	widget.Redraw(widget.CommonSettings.Title, fmt.Sprintf("\n%s", str), false) | ||||||
| } | } | ||||||
|  | |||||||
| @ -5,13 +5,13 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("j", widget.Next) | 	widget.SetKeyboardChar("j", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("k", widget.Prev) | 	widget.SetKeyboardChar("k", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("o", widget.openItem) | 	widget.SetKeyboardChar("o", widget.openItem, "Open item in browser") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openItem) | 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openItem, "Open item in browser") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect) | 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,21 +8,7 @@ import ( | |||||||
| 	datadog "github.com/zorkian/go-datadog-api" | 	datadog "github.com/zorkian/go-datadog-api" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|  Keyboard commands for Datadog: |  | ||||||
| 
 |  | ||||||
|    /: Show/hide this help window |  | ||||||
|    j: Select the next item in the list |  | ||||||
|    k: Select the previous item in the list |  | ||||||
| 
 |  | ||||||
|    arrow down: Select the next item in the list |  | ||||||
|    arrow up:   Select the previous item in the list |  | ||||||
| 
 |  | ||||||
|    return: Open the selected issue in a browser |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.ScrollableWidget | 	wtf.ScrollableWidget | ||||||
| 
 | 
 | ||||||
| @ -32,8 +18,7 @@ type Widget struct { | |||||||
| 
 | 
 | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:    wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:   wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget:   wtf.NewKeyboardWidget(), |  | ||||||
| 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		settings: settings, | 		settings: settings, | ||||||
| @ -43,7 +28,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -79,6 +64,10 @@ func (widget *Widget) Render() { | |||||||
| 	widget.Redraw(widget.CommonSettings.Title, content, false) | 	widget.Redraw(widget.CommonSettings.Title, content, false) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) contentFrom(triggeredMonitors []datadog.Monitor) string { | func (widget *Widget) contentFrom(triggeredMonitors []datadog.Monitor) string { | ||||||
|  | |||||||
| @ -5,17 +5,17 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help window") | ||||||
| 	widget.SetKeyboardChar("h", widget.prevProject) | 	widget.SetKeyboardChar("h", widget.prevProject, "Select previous project") | ||||||
| 	widget.SetKeyboardChar("l", widget.nextProject) | 	widget.SetKeyboardChar("l", widget.nextProject, "Select next project") | ||||||
| 	widget.SetKeyboardChar("j", widget.nextReview) | 	widget.SetKeyboardChar("j", widget.nextReview, "Select next review") | ||||||
| 	widget.SetKeyboardChar("k", widget.prevReview) | 	widget.SetKeyboardChar("k", widget.prevReview, "Select previous review") | ||||||
| 	widget.SetKeyboardChar("r", widget.Refresh) | 	widget.SetKeyboardChar("r", widget.Refresh, "Refresh items") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyLeft, widget.prevProject) | 	widget.SetKeyboardKey(tcell.KeyLeft, widget.prevProject, "Select previous project") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyRight, widget.nextProject) | 	widget.SetKeyboardKey(tcell.KeyRight, widget.nextProject, "Select next project") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.nextReview) | 	widget.SetKeyboardKey(tcell.KeyDown, widget.nextReview, "Select next review") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.prevReview) | 	widget.SetKeyboardKey(tcell.KeyUp, widget.prevReview, "Select previous review") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openReview) | 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openReview, "Open review in browser") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEsc, widget.unselect) | 	widget.SetKeyboardKey(tcell.KeyEsc, widget.unselect, "Clear selection") | ||||||
| } | } | ||||||
|  | |||||||
| @ -11,26 +11,7 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|   Keyboard commands for Gerrit: |  | ||||||
| 
 |  | ||||||
|     /: Show/hide this help window |  | ||||||
|     h: Show the previous project |  | ||||||
|     l: Show the next project |  | ||||||
|     j: Select the next review in the list |  | ||||||
|     k: Select the previous review in the list |  | ||||||
|     r: Refresh the data |  | ||||||
| 
 |  | ||||||
|     arrow left:  Show the previous project |  | ||||||
|     arrow right: Show the next project |  | ||||||
|     arrow down:  Select the next review in the list |  | ||||||
| 	arrow up:    Select the previous review in the list |  | ||||||
| 
 |  | ||||||
| 	return: Open the selected review in a browser |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -49,8 +30,7 @@ var ( | |||||||
| 
 | 
 | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:  wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget: wtf.NewKeyboardWidget(), |  | ||||||
| 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		Idx: 0, | 		Idx: 0, | ||||||
| @ -61,7 +41,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	widget.unselect() | 	widget.unselect() | ||||||
| 
 | 
 | ||||||
| @ -110,6 +90,10 @@ func (widget *Widget) Refresh() { | |||||||
| 	widget.display() | 	widget.display() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) nextProject() { | func (widget *Widget) nextProject() { | ||||||
|  | |||||||
| @ -3,12 +3,12 @@ package git | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help window") | ||||||
| 	widget.SetKeyboardChar("h", widget.Prev) | 	widget.SetKeyboardChar("h", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("l", widget.Next) | 	widget.SetKeyboardChar("l", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("p", widget.Pull) | 	widget.SetKeyboardChar("p", widget.Pull, "Pull repo") | ||||||
| 	widget.SetKeyboardChar("c", widget.Checkout) | 	widget.SetKeyboardChar("c", widget.Checkout, "Checkout branch") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -11,25 +11,11 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|   Keyboard commands for Git: |  | ||||||
| 
 |  | ||||||
|     /: Show/hide this help window |  | ||||||
|     c: Checkout to branch |  | ||||||
|     h: Previous git repository |  | ||||||
|     l: Next git repository |  | ||||||
|     p: Pull current git repository |  | ||||||
| 
 |  | ||||||
|     arrow left:  Previous git repository |  | ||||||
|     arrow right: Next git repository |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| const offscreen = -1000 | const offscreen = -1000 | ||||||
| const modalWidth = 80 | const modalWidth = 80 | ||||||
| const modalHeight = 7 | const modalHeight = 7 | ||||||
| 
 | 
 | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.MultiSourceWidget | 	wtf.MultiSourceWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| @ -43,8 +29,7 @@ type Widget struct { | |||||||
| 
 | 
 | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:     wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:    wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget:    wtf.NewKeyboardWidget(), |  | ||||||
| 		MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), | 		MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), | ||||||
| 		TextWidget:        wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:        wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| @ -58,7 +43,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * | |||||||
| 
 | 
 | ||||||
| 	widget.SetDisplayFunction(widget.display) | 	widget.SetDisplayFunction(widget.display) | ||||||
| 
 | 
 | ||||||
| 	widget.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -100,6 +85,10 @@ func (widget *Widget) Refresh() { | |||||||
| 	widget.display() | 	widget.display() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) addCheckoutButton(form *tview.Form, fctn func()) { | func (widget *Widget) addCheckoutButton(form *tview.Form, fctn func()) { | ||||||
|  | |||||||
| @ -5,13 +5,13 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("h", widget.Prev) | 	widget.SetKeyboardChar("h", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("l", widget.Next) | 	widget.SetKeyboardChar("l", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("o", widget.openRepo) | 	widget.SetKeyboardChar("o", widget.openRepo, "Open item in browser") | ||||||
| 	widget.SetKeyboardChar("r", widget.Refresh) | 	widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openRepo) | 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openRepo, "Open item in browser") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -5,22 +5,7 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|   Keyboard commands for GitHub: |  | ||||||
| 
 |  | ||||||
|     /: Show/hide this help window |  | ||||||
|     h: Previous git repository |  | ||||||
|     l: Next git repository |  | ||||||
|     r: Refresh the data |  | ||||||
| 
 |  | ||||||
|     arrow left:  Previous git repository |  | ||||||
|     arrow right: Next git repository |  | ||||||
| 
 |  | ||||||
|     return: Open the selected repository in a browser |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -33,8 +18,7 @@ type Widget struct { | |||||||
| 
 | 
 | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:  wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget: wtf.NewKeyboardWidget(), |  | ||||||
| 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		Idx: 0, | 		Idx: 0, | ||||||
| @ -48,7 +32,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -83,6 +67,10 @@ func (widget *Widget) Prev() { | |||||||
| 	widget.display() | 	widget.display() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) buildRepoCollection(repoData map[string]interface{}) []*GithubRepo { | func (widget *Widget) buildRepoCollection(repoData map[string]interface{}) []*GithubRepo { | ||||||
|  | |||||||
| @ -3,11 +3,11 @@ package gitlab | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("h", widget.Prev) | 	widget.SetKeyboardChar("h", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("l", widget.Next) | 	widget.SetKeyboardChar("l", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("r", widget.Refresh) | 	widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -6,20 +6,7 @@ import ( | |||||||
| 	glb "github.com/xanzy/go-gitlab" | 	glb "github.com/xanzy/go-gitlab" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|   Keyboard commands for Gitlab: |  | ||||||
| 
 |  | ||||||
|     /: Show/hide this help window |  | ||||||
|     h: Previous project |  | ||||||
|     l: Next project |  | ||||||
|     r: Refresh the data |  | ||||||
| 
 |  | ||||||
|     arrow left:  Previous project |  | ||||||
|     arrow right: Next project |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -39,8 +26,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:  wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget: wtf.NewKeyboardWidget(), |  | ||||||
| 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		Idx: 0, | 		Idx: 0, | ||||||
| @ -54,7 +40,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -87,6 +73,10 @@ func (widget *Widget) Prev() { | |||||||
| 	widget.display() | 	widget.display() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) buildProjectCollection(projectData map[string]interface{}) []*GitlabProject { | func (widget *Widget) buildProjectCollection(projectData map[string]interface{}) []*GitlabProject { | ||||||
|  | |||||||
| @ -3,12 +3,12 @@ package gitter | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("j", widget.Next) | 	widget.SetKeyboardChar("j", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("k", widget.Prev) | 	widget.SetKeyboardChar("k", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("r", widget.Refresh) | 	widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect) | 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -7,21 +7,8 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|  Keyboard commands for Gitter: |  | ||||||
| 
 |  | ||||||
|    /: Show/hide this help window |  | ||||||
|    j: Select the next message in the list |  | ||||||
|    k: Select the previous message in the list |  | ||||||
|    r: Refresh the data |  | ||||||
| 
 |  | ||||||
|    arrow down: Select the next message in the list |  | ||||||
|    arrow up:   Select the previous message in the list |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| // A Widget represents a Gitter widget | // A Widget represents a Gitter widget | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.ScrollableWidget | 	wtf.ScrollableWidget | ||||||
| 
 | 
 | ||||||
| @ -32,8 +19,7 @@ type Widget struct { | |||||||
| // NewWidget creates a new instance of a widget | // NewWidget creates a new instance of a widget | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:    wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:   wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget:   wtf.NewKeyboardWidget(), |  | ||||||
| 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		settings: settings, | 		settings: settings, | ||||||
| @ -43,7 +29,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -78,6 +64,10 @@ func (widget *Widget) Refresh() { | |||||||
| 	widget.display() | 	widget.display() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) display() { | func (widget *Widget) display() { | ||||||
|  | |||||||
| @ -3,15 +3,15 @@ package hackernews | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help widget") | ||||||
| 	widget.SetKeyboardChar("j", widget.Next) | 	widget.SetKeyboardChar("j", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("k", widget.Prev) | 	widget.SetKeyboardChar("k", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("o", widget.openStory) | 	widget.SetKeyboardChar("o", widget.openStory, "Open story in browser") | ||||||
| 	widget.SetKeyboardChar("r", widget.Refresh) | 	widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget") | ||||||
| 	widget.SetKeyboardChar("c", widget.openComments) | 	widget.SetKeyboardChar("c", widget.openComments, "Open comments in browser") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openStory) | 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openStory, "Open story in browser") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect) | 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -9,23 +9,7 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|  Keyboard commands for Hacker News: |  | ||||||
| 
 |  | ||||||
|    /: Show/hide this help window |  | ||||||
|    j: Select the next story in the list |  | ||||||
|    k: Select the previous story in the list |  | ||||||
|    r: Refresh the data |  | ||||||
| 
 |  | ||||||
|    arrow down: Select the next story in the list |  | ||||||
|    arrow up:   Select the previous story in the list |  | ||||||
| 
 |  | ||||||
|    return: Open the selected story in a browser |  | ||||||
|    c: Open the comments of the article |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.ScrollableWidget | 	wtf.ScrollableWidget | ||||||
| 
 | 
 | ||||||
| @ -35,8 +19,7 @@ type Widget struct { | |||||||
| 
 | 
 | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:    wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:   wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget:   wtf.NewKeyboardWidget(), |  | ||||||
| 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		settings: settings, | 		settings: settings, | ||||||
| @ -46,7 +29,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
|  | |||||||
| @ -54,9 +54,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget { | |||||||
| func (widget *Widget) Refresh() { | func (widget *Widget) Refresh() { | ||||||
| 	widget.ipinfo() | 	widget.ipinfo() | ||||||
| 
 | 
 | ||||||
| 	widget.app.QueueUpdateDraw(func() { | 	widget.Redraw(widget.CommonSettings.Title, widget.result, false) | ||||||
| 		widget.View.SetText(widget.result) |  | ||||||
| 	}) |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| //this method reads the config and calls ipinfo for ip information | //this method reads the config and calls ipinfo for ip information | ||||||
|  | |||||||
| @ -3,14 +3,14 @@ package jenkins | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("j", widget.Next) | 	widget.SetKeyboardChar("j", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("k", widget.Prev) | 	widget.SetKeyboardChar("k", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("o", widget.openJob) | 	widget.SetKeyboardChar("o", widget.openJob, "Open job in browser") | ||||||
| 	widget.SetKeyboardChar("r", widget.Refresh) | 	widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openJob) | 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openJob, "Open job in browser") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect) | 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,22 +8,7 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|  Keyboard commands for Jenkins: |  | ||||||
| 
 |  | ||||||
|    /: Show/hide this help window |  | ||||||
|    j: Select the next job in the list |  | ||||||
|    k: Select the previous job in the list |  | ||||||
|    r: Refresh the data |  | ||||||
| 
 |  | ||||||
|    arrow down: Select the next job in the list |  | ||||||
|    arrow up:   Select the previous job in the list |  | ||||||
| 
 |  | ||||||
|    return: Open the selected job in a browser |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.ScrollableWidget | 	wtf.ScrollableWidget | ||||||
| 
 | 
 | ||||||
| @ -33,8 +18,7 @@ type Widget struct { | |||||||
| 
 | 
 | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:    wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:   wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget:   wtf.NewKeyboardWidget(), |  | ||||||
| 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		settings: settings, | 		settings: settings, | ||||||
| @ -44,7 +28,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
|  | |||||||
| @ -5,13 +5,13 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("j", widget.Next) | 	widget.SetKeyboardChar("j", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("k", widget.Prev) | 	widget.SetKeyboardChar("k", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("o", widget.openItem) | 	widget.SetKeyboardChar("o", widget.openItem, "Open item in browser") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openItem) | 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openItem, "Open item in browser") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect) | 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -7,21 +7,7 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|  Keyboard commands for Jira: |  | ||||||
| 
 |  | ||||||
|    /: Show/hide this help window |  | ||||||
|    j: Select the next item in the list |  | ||||||
|    k: Select the previous item in the list |  | ||||||
| 
 |  | ||||||
|    arrow down: Select the next item in the list |  | ||||||
|    arrow up:   Select the previous item in the list |  | ||||||
| 
 |  | ||||||
|    return: Open the selected issue in a browser |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.ScrollableWidget | 	wtf.ScrollableWidget | ||||||
| 
 | 
 | ||||||
| @ -31,8 +17,7 @@ type Widget struct { | |||||||
| 
 | 
 | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:    wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:   wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget:   wtf.NewKeyboardWidget(), |  | ||||||
| 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		settings: settings, | 		settings: settings, | ||||||
| @ -42,7 +27,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
|  | |||||||
| @ -40,10 +40,7 @@ func (widget *Widget) Refresh() { | |||||||
| 
 | 
 | ||||||
| 	logLines := widget.tailFile() | 	logLines := widget.tailFile() | ||||||
| 
 | 
 | ||||||
| 	widget.app.QueueUpdateDraw(func() { | 	widget.Redraw(widget.CommonSettings.Title, widget.contentFrom(logLines), false) | ||||||
| 		widget.View.SetTitle(widget.CommonSettings.Title) |  | ||||||
| 		widget.View.SetText(widget.contentFrom(logLines)) |  | ||||||
| 	}) |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
|  | |||||||
| @ -3,12 +3,12 @@ package mercurial | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("h", widget.Prev) | 	widget.SetKeyboardChar("h", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("l", widget.Next) | 	widget.SetKeyboardChar("l", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("p", widget.Pull) | 	widget.SetKeyboardChar("p", widget.Pull, "Pull repo") | ||||||
| 	widget.SetKeyboardChar("c", widget.Checkout) | 	widget.SetKeyboardChar("c", widget.Checkout, "Checkout branch") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -6,26 +6,12 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|   Keyboard commands for Mercurial: |  | ||||||
| 
 |  | ||||||
|     /: Show/hide this help window |  | ||||||
|     c: Checkout to branch |  | ||||||
|     h: Previous mercurial repository |  | ||||||
|     l: Next mercurial repository |  | ||||||
|     p: Pull current mercurial repository |  | ||||||
| 
 |  | ||||||
|     arrow left:  Previous mercurial repository |  | ||||||
|     arrow right: Next mercurial repository |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| const offscreen = -1000 | const offscreen = -1000 | ||||||
| const modalWidth = 80 | const modalWidth = 80 | ||||||
| const modalHeight = 7 | const modalHeight = 7 | ||||||
| 
 | 
 | ||||||
| // A Widget represents a Mercurial widget | // A Widget represents a Mercurial widget | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.MultiSourceWidget | 	wtf.MultiSourceWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| @ -39,8 +25,7 @@ type Widget struct { | |||||||
| // NewWidget creates a new instance of a widget | // NewWidget creates a new instance of a widget | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:     wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:    wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget:    wtf.NewKeyboardWidget(), |  | ||||||
| 		MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), | 		MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), | ||||||
| 		TextWidget:        wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:        wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| @ -54,7 +39,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -94,6 +79,10 @@ func (widget *Widget) Refresh() { | |||||||
| 	widget.display() | 	widget.display() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) addCheckoutButton(form *tview.Form, fctn func()) { | func (widget *Widget) addCheckoutButton(form *tview.Form, fctn func()) { | ||||||
|  | |||||||
| @ -3,13 +3,13 @@ package nbascore | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("h", widget.prev) | 	widget.SetKeyboardChar("h", widget.prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("l", widget.next) | 	widget.SetKeyboardChar("l", widget.next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("c", widget.center) | 	widget.SetKeyboardChar("c", widget.center, "???") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyLeft, widget.prev) | 	widget.SetKeyboardKey(tcell.KeyLeft, widget.prev, "Select previous item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyRight, widget.next) | 	widget.SetKeyboardKey(tcell.KeyRight, widget.next, "Select next item") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) center() { | func (widget *Widget) center() { | ||||||
|  | |||||||
| @ -12,16 +12,8 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|  Keyboard commands for NBA Score: |  | ||||||
|    h: Go to previous day |  | ||||||
|    l: Go to next day |  | ||||||
|    c: Go back to current day |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| // A Widget represents an NBA Score  widget | // A Widget represents an NBA Score  widget | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -35,8 +27,7 @@ var offset = 0 | |||||||
| // NewWidget creates a new instance of a widget | // NewWidget creates a new instance of a widget | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:  wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget: wtf.NewKeyboardWidget(), |  | ||||||
| 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		settings: settings, | 		settings: settings, | ||||||
| @ -47,7 +38,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * | |||||||
| 
 | 
 | ||||||
| 	widget.View.SetScrollable(true) | 	widget.View.SetScrollable(true) | ||||||
| 
 | 
 | ||||||
| 	widget.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -56,6 +47,10 @@ func (widget *Widget) Refresh() { | |||||||
| 	widget.Redraw(widget.CommonSettings.Title, widget.nbascore(), false) | 	widget.Redraw(widget.CommonSettings.Title, widget.nbascore(), false) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (widget *Widget) nbascore() string { | func (widget *Widget) nbascore() string { | ||||||
| 	cur := time.Now().AddDate(0, 0, offset) // Go back/forward offset days | 	cur := time.Now().AddDate(0, 0, offset) // Go back/forward offset days | ||||||
| 	curString := cur.Format("20060102")     // Need 20060102 format to feed to api | 	curString := cur.Format("20060102")     // Need 20060102 format to feed to api | ||||||
|  | |||||||
| @ -3,15 +3,15 @@ package rollbar | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("j", widget.Next) | 	widget.SetKeyboardChar("j", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("k", widget.Prev) | 	widget.SetKeyboardChar("k", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("o", widget.openBuild) | 	widget.SetKeyboardChar("o", widget.openBuild, "Open item in browser") | ||||||
| 	widget.SetKeyboardChar("r", widget.Refresh) | 	widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget") | ||||||
| 	widget.SetKeyboardChar("u", widget.Unselect) | 	widget.SetKeyboardChar("u", widget.Unselect, "Clear selection") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openBuild) | 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openBuild, "Open item in browser") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect) | 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -7,24 +7,8 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|  Keyboard commands for Rollbar: |  | ||||||
| 
 |  | ||||||
|    /: Show/hide this help window |  | ||||||
|    j: Select the next item in the list |  | ||||||
|    k: Select the previous item in the list |  | ||||||
|    r: Refresh the data |  | ||||||
|    u: unselect the current item(removes item being perma highlighted) |  | ||||||
| 
 |  | ||||||
|    arrow down: Select the next item in the list |  | ||||||
|    arrow up:   Select the previous item in the list |  | ||||||
| 
 |  | ||||||
|    return: Open the selected item in a browser |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| // A Widget represents a Rollbar widget | // A Widget represents a Rollbar widget | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.ScrollableWidget | 	wtf.ScrollableWidget | ||||||
| 
 | 
 | ||||||
| @ -35,8 +19,7 @@ type Widget struct { | |||||||
| // NewWidget creates a new instance of a widget | // NewWidget creates a new instance of a widget | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:    wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:   wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget:   wtf.NewKeyboardWidget(), |  | ||||||
| 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		settings: settings, | 		settings: settings, | ||||||
| @ -46,7 +29,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
|  | |||||||
| @ -5,10 +5,10 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("h", widget.previous) | 	widget.SetKeyboardChar("h", widget.previous, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("l", widget.next) | 	widget.SetKeyboardChar("l", widget.next, "Select next item") | ||||||
| 	widget.SetKeyboardChar(" ", widget.playPause) | 	widget.SetKeyboardChar(" ", widget.playPause, "Play/pause song") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) previous() { | func (widget *Widget) previous() { | ||||||
|  | |||||||
| @ -8,16 +8,8 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
| 	To control Spotify use: |  | ||||||
| 		[Spacebar] for Play & Pause |  | ||||||
| 		[h] for Previous Song |  | ||||||
| 		[l] for Next Song |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| // A Widget represents a Spotify widget | // A Widget represents a Spotify widget | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -30,8 +22,7 @@ type Widget struct { | |||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	spotifyClient := spotigopher.NewClient() | 	spotifyClient := spotigopher.NewClient() | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:  wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget: wtf.NewKeyboardWidget(), |  | ||||||
| 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		Info:          spotigopher.Info{}, | 		Info:          spotigopher.Info{}, | ||||||
| @ -47,9 +38,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * | |||||||
| 
 | 
 | ||||||
| 	widget.View.SetWrap(true) | 	widget.View.SetWrap(true) | ||||||
| 	widget.View.SetWordWrap(true) | 	widget.View.SetWordWrap(true) | ||||||
| 	widget.View.SetTitle(fmt.Sprint("[green]Spotify[white]")) |  | ||||||
| 
 | 
 | ||||||
| 	widget.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -64,6 +54,10 @@ func (w *Widget) Refresh() { | |||||||
| 	w.render() | 	w.render() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (w *Widget) render() { | func (w *Widget) render() { | ||||||
| 	err := w.refreshSpotifyInfos() | 	err := w.refreshSpotifyInfos() | ||||||
| 	var content string | 	var content string | ||||||
|  | |||||||
| @ -5,11 +5,11 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("h", widget.selectPrevious) | 	widget.SetKeyboardChar("h", widget.selectPrevious, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("l", widget.selectNext) | 	widget.SetKeyboardChar("l", widget.selectNext, "Select next item") | ||||||
| 	widget.SetKeyboardChar(" ", widget.playPause) | 	widget.SetKeyboardChar(" ", widget.playPause, "Play/pause") | ||||||
| 	widget.SetKeyboardChar("s", widget.toggleShuffle) | 	widget.SetKeyboardChar("s", widget.toggleShuffle, "Toggle shuffle") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) selectPrevious() { | func (widget *Widget) selectPrevious() { | ||||||
|  | |||||||
| @ -11,26 +11,6 @@ import ( | |||||||
| 	"github.com/zmb3/spotify" | 	"github.com/zmb3/spotify" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // HelpText contains the help text for the Spotify Web API widget. |  | ||||||
| const HelpText = ` |  | ||||||
| Keyboard commands for Spotify Web: |  | ||||||
| 
 |  | ||||||
| 	Before any of these commands are used, you should authenticate using the |  | ||||||
| 	URL provided by the widget. |  | ||||||
| 
 |  | ||||||
| 	The widget should automatically open a browser window for you, otherwise |  | ||||||
| 	you should check out the logs for the URL. |  | ||||||
| 
 |  | ||||||
| 	/: Show/hide this help window |  | ||||||
| 	h: Switch to previous song in Spotify queue |  | ||||||
| 	l: Switch to next song in Spotify queue |  | ||||||
| 	s: Toggle shuffle |  | ||||||
| 
 |  | ||||||
| 	[space]: Pause/play current song |  | ||||||
| 
 |  | ||||||
| 	esc: Unselect the Spotify Web module |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| // Info is the struct that contains all the information the Spotify player displays to the user | // Info is the struct that contains all the information the Spotify player displays to the user | ||||||
| type Info struct { | type Info struct { | ||||||
| 	Artists     string | 	Artists     string | ||||||
| @ -42,7 +22,6 @@ type Info struct { | |||||||
| 
 | 
 | ||||||
| // Widget is the struct used by all WTF widgets to transfer to the main widget controller | // Widget is the struct used by all WTF widgets to transfer to the main widget controller | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -92,8 +71,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * | |||||||
| 	var playerState *spotify.PlayerState | 	var playerState *spotify.PlayerState | ||||||
| 
 | 
 | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:  wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget: wtf.NewKeyboardWidget(), |  | ||||||
| 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		Info: Info{}, | 		Info: Info{}, | ||||||
| @ -144,9 +122,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * | |||||||
| 
 | 
 | ||||||
| 	widget.View.SetWrap(true) | 	widget.View.SetWrap(true) | ||||||
| 	widget.View.SetWordWrap(true) | 	widget.View.SetWordWrap(true) | ||||||
| 	widget.View.SetTitle("[green]Spotify Web[white]") |  | ||||||
| 
 | 
 | ||||||
| 	widget.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -187,6 +164,10 @@ func (w *Widget) Refresh() { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (w *Widget) createOutput() string { | func (w *Widget) createOutput() string { | ||||||
| 	output := wtf.CenterText(fmt.Sprintf("[green]Now %v [white]\n", w.Info.Status), w.Width()) | 	output := wtf.CenterText(fmt.Sprintf("[green]Now %v [white]\n", w.Info.Status), w.Width()) | ||||||
| 	output += wtf.CenterText(fmt.Sprintf("[green]Title:[white] %v\n", w.Info.Title), w.Width()) | 	output += wtf.CenterText(fmt.Sprintf("[green]Title:[white] %v\n", w.Info.Title), w.Width()) | ||||||
|  | |||||||
| @ -6,13 +6,13 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("h", widget.Prev) | 	widget.SetKeyboardChar("h", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("l", widget.Next) | 	widget.SetKeyboardChar("l", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("o", widget.openFile) | 	widget.SetKeyboardChar("o", widget.openFile, "Open item") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) openFile() { | func (widget *Widget) openFile() { | ||||||
|  | |||||||
| @ -18,20 +18,7 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|   Keyboard commands for Textfile: |  | ||||||
| 
 |  | ||||||
|     /: Show/hide this help window |  | ||||||
|     h: Previous text file |  | ||||||
|     l: Next text file |  | ||||||
|     o: Open the text file in the operating system |  | ||||||
| 
 |  | ||||||
|     arrow left:  Previous text file |  | ||||||
|     arrow right: Next text file |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.MultiSourceWidget | 	wtf.MultiSourceWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| @ -43,8 +30,7 @@ type Widget struct { | |||||||
| // NewWidget creates a new instance of a widget | // NewWidget creates a new instance of a widget | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:     wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:    wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget:    wtf.NewKeyboardWidget(), |  | ||||||
| 		MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "filePath", "filePaths"), | 		MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "filePath", "filePaths"), | ||||||
| 		TextWidget:        wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:        wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| @ -62,7 +48,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * | |||||||
| 	widget.View.SetWordWrap(true) | 	widget.View.SetWordWrap(true) | ||||||
| 	widget.View.SetWrap(true) | 	widget.View.SetWrap(true) | ||||||
| 
 | 
 | ||||||
| 	widget.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	go widget.watchForFileChanges() | 	go widget.watchForFileChanges() | ||||||
| 
 | 
 | ||||||
| @ -77,6 +63,10 @@ func (widget *Widget) Refresh() { | |||||||
| 	widget.display() | 	widget.display() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) display() { | func (widget *Widget) display() { | ||||||
|  | |||||||
| @ -9,20 +9,20 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar(" ", widget.toggleChecked) | 	widget.SetKeyboardChar(" ", widget.toggleChecked, "Toggle checkmark") | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("j", widget.displayNext) | 	widget.SetKeyboardChar("j", widget.displayNext, "Select next item") | ||||||
| 	widget.SetKeyboardChar("k", widget.displayPrev) | 	widget.SetKeyboardChar("k", widget.displayPrev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("n", widget.newItem) | 	widget.SetKeyboardChar("n", widget.newItem, "Create new item") | ||||||
| 	widget.SetKeyboardChar("o", widget.openFile) | 	widget.SetKeyboardChar("o", widget.openFile, "Open file") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyCtrlD, widget.deleteSelected) | 	widget.SetKeyboardKey(tcell.KeyCtrlD, widget.deleteSelected, "Delete item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyCtrlJ, widget.demoteSelected) | 	widget.SetKeyboardKey(tcell.KeyCtrlJ, widget.demoteSelected, "Demote item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyCtrlK, widget.promoteSelected) | 	widget.SetKeyboardKey(tcell.KeyCtrlK, widget.promoteSelected, "Promote item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.displayNext) | 	widget.SetKeyboardKey(tcell.KeyDown, widget.displayNext, "Select next item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEnter, widget.editSelected) | 	widget.SetKeyboardKey(tcell.KeyEnter, widget.editSelected, "Edit item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEsc, widget.unselect) | 	widget.SetKeyboardKey(tcell.KeyEsc, widget.unselect, "Clear selection") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.displayPrev) | 	widget.SetKeyboardKey(tcell.KeyUp, widget.displayPrev, "Select previous item") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) deleteSelected() { | func (widget *Widget) deleteSelected() { | ||||||
|  | |||||||
| @ -12,32 +12,12 @@ import ( | |||||||
| 	"gopkg.in/yaml.v2" | 	"gopkg.in/yaml.v2" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|  Keyboard commands for Todo: |  | ||||||
| 
 |  | ||||||
|    /: Show/hide this help window |  | ||||||
|    j: Select the next item in the list |  | ||||||
|    k: Select the previous item in the list |  | ||||||
|    n: Create a new list item |  | ||||||
|    o: Open the todo file in the operating system |  | ||||||
| 
 |  | ||||||
|    arrow down: Select the next item in the list |  | ||||||
|    arrow up:   Select the previous item in the list |  | ||||||
| 
 |  | ||||||
|    ctrl-d: Delete the selected item |  | ||||||
| 
 |  | ||||||
|    esc:    Unselect the todo list |  | ||||||
|    return: Edit selected item |  | ||||||
|    space:  Check the selected item on or off |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| const offscreen = -1000 | const offscreen = -1000 | ||||||
| const modalWidth = 80 | const modalWidth = 80 | ||||||
| const modalHeight = 7 | const modalHeight = 7 | ||||||
| 
 | 
 | ||||||
| // A Widget represents a Todo widget | // A Widget represents a Todo widget | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -51,8 +31,7 @@ type Widget struct { | |||||||
| // NewWidget creates a new instance of a widget | // NewWidget creates a new instance of a widget | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:  wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget: wtf.NewKeyboardWidget(), |  | ||||||
| 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		app:      app, | 		app:      app, | ||||||
| @ -70,7 +49,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * | |||||||
| 	widget.View.SetRegions(true) | 	widget.View.SetRegions(true) | ||||||
| 	widget.View.SetScrollable(true) | 	widget.View.SetScrollable(true) | ||||||
| 
 | 
 | ||||||
| 	widget.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -86,6 +65,10 @@ func (widget *Widget) SetList(list checklist.Checklist) { | |||||||
| 	widget.list = list | 	widget.list = list | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| // edit opens a modal dialog that permits editing the text of the currently-selected item | // edit opens a modal dialog that permits editing the text of the currently-selected item | ||||||
|  | |||||||
| @ -3,17 +3,17 @@ package todoist | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("c", widget.Close) | 	widget.SetKeyboardChar("c", widget.Close, "Close item") | ||||||
| 	widget.SetKeyboardChar("d", widget.Delete) | 	widget.SetKeyboardChar("d", widget.Delete, "Delete item") | ||||||
| 	widget.SetKeyboardChar("h", widget.PreviousProject) | 	widget.SetKeyboardChar("h", widget.PreviousProject, "Select previous project") | ||||||
| 	widget.SetKeyboardChar("j", widget.Up) | 	widget.SetKeyboardChar("j", widget.Up, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("k", widget.Down) | 	widget.SetKeyboardChar("k", widget.Down, "Select next item") | ||||||
| 	widget.SetKeyboardChar("l", widget.NextProject) | 	widget.SetKeyboardChar("l", widget.NextProject, "Select next project") | ||||||
| 	widget.SetKeyboardChar("r", widget.Refresh) | 	widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.Down) | 	widget.SetKeyboardKey(tcell.KeyDown, widget.Down, "Select next item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyLeft, widget.PreviousProject) | 	widget.SetKeyboardKey(tcell.KeyLeft, widget.PreviousProject, "Select previous project") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyRight, widget.NextProject) | 	widget.SetKeyboardKey(tcell.KeyRight, widget.NextProject, "Select next project") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.Up) | 	widget.SetKeyboardKey(tcell.KeyUp, widget.Up, "Select previous item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -7,27 +7,8 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|  Keyboard commands for Todoist: |  | ||||||
| 
 |  | ||||||
|    /: Show/hide this help window |  | ||||||
|    c: Close the selected item |  | ||||||
|    d: Delete the selected item |  | ||||||
|    h: Previous Todoist list |  | ||||||
|    j: Select the next item in the list |  | ||||||
|    k: Select the previous item in the list |  | ||||||
|    l: Next Todoist list |  | ||||||
|    r: Refresh the todo list data |  | ||||||
| 
 |  | ||||||
|    arrow down: Select the next item in the list |  | ||||||
|    arrow left: Previous Todoist list |  | ||||||
|    arrow right: Next Todoist list |  | ||||||
|    arrow up: Select the previous item in the list |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| // A Widget represents a Todoist widget | // A Widget represents a Todoist widget | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -39,8 +20,7 @@ type Widget struct { | |||||||
| // NewWidget creates a new instance of a widget | // NewWidget creates a new instance of a widget | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:  wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget: wtf.NewKeyboardWidget(), |  | ||||||
| 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		settings: settings, | 		settings: settings, | ||||||
| @ -52,7 +32,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -97,6 +77,10 @@ func (w *Widget) Refresh() { | |||||||
| 	w.display() | 	w.display() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Keyboard Movement -------------------- */ | /* -------------------- Keyboard Movement -------------------- */ | ||||||
| 
 | 
 | ||||||
| // Down selects the next item in the list | // Down selects the next item in the list | ||||||
|  | |||||||
| @ -3,14 +3,14 @@ package travisci | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("j", widget.Next) | 	widget.SetKeyboardChar("j", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("k", widget.Prev) | 	widget.SetKeyboardChar("k", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("o", widget.openBuild) | 	widget.SetKeyboardChar("o", widget.openBuild, "Open item in browser") | ||||||
| 	widget.SetKeyboardChar("r", widget.Refresh) | 	widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openBuild) | 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openBuild, "Open item in browser") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect) | 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,22 +8,7 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|  Keyboard commands for Travis CI: |  | ||||||
| 
 |  | ||||||
|    /: Show/hide this help window |  | ||||||
|    j: Select the next build in the list |  | ||||||
|    k: Select the previous build in the list |  | ||||||
|    r: Refresh the data |  | ||||||
| 
 |  | ||||||
|    arrow down: Select the next build in the list |  | ||||||
|    arrow up:   Select the previous build in the list |  | ||||||
| 
 |  | ||||||
|    return: Open the selected build in a browser |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.ScrollableWidget | 	wtf.ScrollableWidget | ||||||
| 
 | 
 | ||||||
| @ -33,8 +18,7 @@ type Widget struct { | |||||||
| 
 | 
 | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:    wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:   wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget:   wtf.NewKeyboardWidget(), |  | ||||||
| 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		settings: settings, | 		settings: settings, | ||||||
| @ -44,7 +28,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
|  | |||||||
| @ -6,14 +6,14 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("h", widget.Prev) | 	widget.SetKeyboardChar("h", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("l", widget.Next) | 	widget.SetKeyboardChar("l", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("o", widget.openFile) | 	widget.SetKeyboardChar("o", widget.openFile, "Open item") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openFile) | 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openFile, "Open item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) openFile() { | func (widget *Widget) openFile() { | ||||||
|  | |||||||
| @ -10,20 +10,7 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|   Keyboard commands for Twitter: |  | ||||||
| 
 |  | ||||||
|     /: Show/hide this help window |  | ||||||
|     h: Previous Twitter name |  | ||||||
|     l: Next Twitter name |  | ||||||
|     o: Open the Twitter handle in a browser |  | ||||||
| 
 |  | ||||||
|     arrow left:  Previous Twitter name |  | ||||||
|     arrow right: Next Twitter name |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.MultiSourceWidget | 	wtf.MultiSourceWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| @ -36,8 +23,7 @@ type Widget struct { | |||||||
| 
 | 
 | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:     wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:    wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget:    wtf.NewKeyboardWidget(), |  | ||||||
| 		MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "screenName", "screenNames"), | 		MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "screenName", "screenNames"), | ||||||
| 		TextWidget:        wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:        wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| @ -56,7 +42,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * | |||||||
| 	widget.View.SetWrap(true) | 	widget.View.SetWrap(true) | ||||||
| 	widget.View.SetWordWrap(true) | 	widget.View.SetWordWrap(true) | ||||||
| 
 | 
 | ||||||
| 	widget.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -68,6 +54,10 @@ func (widget *Widget) Refresh() { | |||||||
| 	widget.display() | 	widget.display() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) display() { | func (widget *Widget) display() { | ||||||
| @ -78,7 +68,7 @@ func (widget *Widget) display() { | |||||||
| 
 | 
 | ||||||
| 	if len(tweets) == 0 { | 	if len(tweets) == 0 { | ||||||
| 		str := fmt.Sprintf("\n\n\n%s", wtf.CenterText("[lightblue]No Tweets[white]", 50)) | 		str := fmt.Sprintf("\n\n\n%s", wtf.CenterText("[lightblue]No Tweets[white]", 50)) | ||||||
| 		widget.View.SetText(str) | 		widget.Redraw(title, str, true) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -7,15 +7,6 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // HelpText to display to users |  | ||||||
| const HelpText = ` |  | ||||||
| 	Keyboard commands for VictorOps |  | ||||||
| 
 |  | ||||||
| 	/: Show/hide this help window |  | ||||||
| 	arrow down: Scroll down the list |  | ||||||
| 	arrow up: Scroll up the list |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| // Widget contains text info | // Widget contains text info | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| @ -43,7 +34,6 @@ func (widget *Widget) Refresh() { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	teams, err := Fetch(widget.settings.apiID, widget.settings.apiKey) | 	teams, err := Fetch(widget.settings.apiID, widget.settings.apiKey) | ||||||
| 	widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title)) |  | ||||||
| 
 | 
 | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		widget.Redraw(widget.CommonSettings.Title, err.Error(), true) | 		widget.Redraw(widget.CommonSettings.Title, err.Error(), true) | ||||||
| @ -53,16 +43,6 @@ func (widget *Widget) Refresh() { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) display() { |  | ||||||
| 	if widget.teams == nil { |  | ||||||
| 		return |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	widget.View.SetWrap(false) |  | ||||||
| 	widget.View.Clear() |  | ||||||
| 	widget.View.SetText(widget.contentFrom(widget.teams)) |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (widget *Widget) contentFrom(teams []OnCallTeam) string { | func (widget *Widget) contentFrom(teams []OnCallTeam) string { | ||||||
| 	var str string | 	var str string | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -3,10 +3,10 @@ package weather | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("/", widget.ShowHelp) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("h", widget.Prev) | 	widget.SetKeyboardChar("h", widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardChar("l", widget.Next) | 	widget.SetKeyboardChar("l", widget.Next, "Select next item") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item") | ||||||
| } | } | ||||||
|  | |||||||
| @ -6,20 +6,8 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|   Keyboard commands for Weather: |  | ||||||
| 
 |  | ||||||
|     /: Show/hide this help window |  | ||||||
|     h: Previous weather location |  | ||||||
|     l: Next weather location |  | ||||||
| 
 |  | ||||||
|     arrow left:  Previous weather location |  | ||||||
|     arrow right: Next weather location |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| // Widget is the container for weather data. | // Widget is the container for weather data. | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -33,8 +21,7 @@ type Widget struct { | |||||||
| // NewWidget creates and returns a new instance of the weather Widget | // NewWidget creates and returns a new instance of the weather Widget | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:  wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget: wtf.NewKeyboardWidget(), |  | ||||||
| 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | 		TextWidget:     wtf.NewTextWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		Idx: 0, | 		Idx: 0, | ||||||
| @ -45,7 +32,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.HelpfulWidget.SetView(widget.View) | 	widget.KeyboardWidget.SetView(widget.View) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| @ -100,6 +87,10 @@ func (widget *Widget) Prev() { | |||||||
| 	widget.display() | 	widget.display() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *Widget) HelpText() string { | ||||||
|  | 	return widget.KeyboardWidget.HelpText() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) apiKeyValid() bool { | func (widget *Widget) apiKeyValid() bool { | ||||||
|  | |||||||
| @ -3,12 +3,13 @@ package zendesk | |||||||
| import "github.com/gdamore/tcell" | import "github.com/gdamore/tcell" | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) initializeKeyboardControls() { | func (widget *Widget) initializeKeyboardControls() { | ||||||
| 	widget.SetKeyboardChar("j", widget.Next) | 	widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt") | ||||||
| 	widget.SetKeyboardChar("k", widget.Prev) | 	widget.SetKeyboardChar("j", widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardChar("o", widget.openTicket) | 	widget.SetKeyboardChar("k", widget.Prev, "Select previous item") | ||||||
|  | 	widget.SetKeyboardChar("o", widget.openTicket, "Open item") | ||||||
| 
 | 
 | ||||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next) | 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev) | 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openTicket) | 	widget.SetKeyboardKey(tcell.KeyEnter, widget.openTicket, "Open item") | ||||||
| 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect) | 	widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection") | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,23 +8,8 @@ import ( | |||||||
| 	"github.com/wtfutil/wtf/wtf" | 	"github.com/wtfutil/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const HelpText = ` |  | ||||||
|  Keyboard commands for Zendesk: |  | ||||||
| 
 |  | ||||||
|    /: Show/hide this help window |  | ||||||
|    j: Select the next item in the list |  | ||||||
|    k: Select the previous item in the list |  | ||||||
|    o: Open the selected item in a browser |  | ||||||
| 
 |  | ||||||
|    arrow down: Select the next item in the list |  | ||||||
|    arrow up:   Select the previous item in the list |  | ||||||
| 
 |  | ||||||
|    return: Open the selected item in a browser |  | ||||||
| ` |  | ||||||
| 
 |  | ||||||
| // A Widget represents a Zendesk widget | // A Widget represents a Zendesk widget | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.HelpfulWidget |  | ||||||
| 	wtf.KeyboardWidget | 	wtf.KeyboardWidget | ||||||
| 	wtf.ScrollableWidget | 	wtf.ScrollableWidget | ||||||
| 
 | 
 | ||||||
| @ -35,8 +20,7 @@ type Widget struct { | |||||||
| // NewWidget creates a new instance of a widget | // NewWidget creates a new instance of a widget | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		HelpfulWidget:  wtf.NewHelpfulWidget(app, pages, HelpText), | 		KeyboardWidget:   wtf.NewKeyboardWidget(app, pages, settings.common), | ||||||
| 		KeyboardWidget: wtf.NewKeyboardWidget(), |  | ||||||
| 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | 		ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), | ||||||
| 
 | 
 | ||||||
| 		settings: settings, | 		settings: settings, | ||||||
| @ -46,6 +30,8 @@ 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.KeyboardWidget.SetView(widget.View) | ||||||
|  | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -112,6 +112,10 @@ func (widget *BarGraph) TextView() *tview.TextView { | |||||||
| 	return widget.View | 	return widget.View | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *BarGraph) HelpText() string { | ||||||
|  | 	return "No help available for this widget" | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *BarGraph) addView() *tview.TextView { | func (widget *BarGraph) addView() *tview.TextView { | ||||||
|  | |||||||
| @ -1,40 +0,0 @@ | |||||||
| package wtf |  | ||||||
| 
 |  | ||||||
| import ( |  | ||||||
| 	"github.com/rivo/tview" |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| type HelpfulWidget struct { |  | ||||||
| 	app      *tview.Application |  | ||||||
| 	helpText string |  | ||||||
| 	pages    *tview.Pages |  | ||||||
| 	view     *tview.TextView |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func NewHelpfulWidget(app *tview.Application, pages *tview.Pages, helpText string) HelpfulWidget { |  | ||||||
| 	return HelpfulWidget{ |  | ||||||
| 		app:      app, |  | ||||||
| 		helpText: helpText, |  | ||||||
| 		pages:    pages, |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (widget *HelpfulWidget) SetView(view *tview.TextView) { |  | ||||||
| 	widget.view = view |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (widget *HelpfulWidget) ShowHelp() { |  | ||||||
| 	closeFunc := func() { |  | ||||||
| 		widget.pages.RemovePage("help") |  | ||||||
| 		widget.app.SetFocus(widget.view) |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	modal := NewBillboardModal(widget.helpText, closeFunc) |  | ||||||
| 
 |  | ||||||
| 	widget.pages.AddPage("help", modal, false, true) |  | ||||||
| 	widget.app.SetFocus(modal) |  | ||||||
| 
 |  | ||||||
| 	widget.app.QueueUpdate(func() { |  | ||||||
| 		widget.app.Draw() |  | ||||||
| 	}) |  | ||||||
| } |  | ||||||
| @ -1,20 +1,42 @@ | |||||||
| package wtf | package wtf | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 
 | ||||||
| 	"github.com/gdamore/tcell" | 	"github.com/gdamore/tcell" | ||||||
|  | 	"github.com/rivo/tview" | ||||||
|  | 	"github.com/wtfutil/wtf/cfg" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | type helpItem struct { | ||||||
|  | 	Key  string | ||||||
|  | 	Text string | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // KeyboardWidget manages keyboard control for a widget | // KeyboardWidget manages keyboard control for a widget | ||||||
| type KeyboardWidget struct { | type KeyboardWidget struct { | ||||||
|  | 	app      *tview.Application | ||||||
|  | 	pages    *tview.Pages | ||||||
|  | 	view     *tview.TextView | ||||||
|  | 	settings *cfg.Common | ||||||
|  | 
 | ||||||
| 	charMap  map[string]func() | 	charMap  map[string]func() | ||||||
| 	keyMap   map[tcell.Key]func() | 	keyMap   map[tcell.Key]func() | ||||||
|  | 	charHelp []helpItem | ||||||
|  | 	keyHelp  []helpItem | ||||||
|  | 	maxKey   int | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // NewKeyboardWidget creates and returns a new instance of KeyboardWidget | // NewKeyboardWidget creates and returns a new instance of KeyboardWidget | ||||||
| func NewKeyboardWidget() KeyboardWidget { | func NewKeyboardWidget(app *tview.Application, pages *tview.Pages, settings *cfg.Common) KeyboardWidget { | ||||||
| 	return KeyboardWidget{ | 	return KeyboardWidget{ | ||||||
|  | 		app:      app, | ||||||
|  | 		pages:    pages, | ||||||
|  | 		settings: settings, | ||||||
| 		charMap:  make(map[string]func()), | 		charMap:  make(map[string]func()), | ||||||
| 		keyMap:   make(map[tcell.Key]func()), | 		keyMap:   make(map[tcell.Key]func()), | ||||||
|  | 		charHelp: []helpItem{}, | ||||||
|  | 		keyHelp:  []helpItem{}, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -23,8 +45,9 @@ func NewKeyboardWidget() KeyboardWidget { | |||||||
| // | // | ||||||
| //    widget.SetKeyboardChar("d", widget.deleteSelectedItem) | //    widget.SetKeyboardChar("d", widget.deleteSelectedItem) | ||||||
| // | // | ||||||
| func (widget *KeyboardWidget) SetKeyboardChar(char string, fn func()) { | func (widget *KeyboardWidget) SetKeyboardChar(char string, fn func(), helpText string) { | ||||||
| 	widget.charMap[char] = fn | 	widget.charMap[char] = fn | ||||||
|  | 	widget.charHelp = append(widget.charHelp, helpItem{char, helpText}) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // SetKeyboardKey sets a tcell.Key/function combination that responds to key presses | // SetKeyboardKey sets a tcell.Key/function combination that responds to key presses | ||||||
| @ -32,8 +55,12 @@ func (widget *KeyboardWidget) SetKeyboardChar(char string, fn func()) { | |||||||
| // | // | ||||||
| //    widget.SetKeyboardKey(tcell.KeyCtrlD, widget.deleteSelectedItem) | //    widget.SetKeyboardKey(tcell.KeyCtrlD, widget.deleteSelectedItem) | ||||||
| // | // | ||||||
| func (widget *KeyboardWidget) SetKeyboardKey(key tcell.Key, fn func()) { | func (widget *KeyboardWidget) SetKeyboardKey(key tcell.Key, fn func(), helpText string) { | ||||||
| 	widget.keyMap[key] = fn | 	widget.keyMap[key] = fn | ||||||
|  | 	widget.keyHelp = append(widget.keyHelp, helpItem{tcell.KeyNames[key], helpText}) | ||||||
|  | 	if len(tcell.KeyNames[key]) > widget.maxKey { | ||||||
|  | 		widget.maxKey = len(tcell.KeyNames[key]) | ||||||
|  | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // InputCapture is the function passed to tview's SetInputCapture() function | // InputCapture is the function passed to tview's SetInputCapture() function | ||||||
| @ -56,3 +83,39 @@ func (widget *KeyboardWidget) InputCapture(event *tcell.EventKey) *tcell.EventKe | |||||||
| 
 | 
 | ||||||
| 	return event | 	return event | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | func (widget *KeyboardWidget) HelpText() string { | ||||||
|  | 
 | ||||||
|  | 	str := "Keyboard commands for " + widget.settings.Module.Type + "\n\n" | ||||||
|  | 
 | ||||||
|  | 	for _, item := range widget.charHelp { | ||||||
|  | 		str = str + fmt.Sprintf("  [%s]: %s\n", item.Key, item.Text) | ||||||
|  | 	} | ||||||
|  | 	str = str + "\n\n" | ||||||
|  | 
 | ||||||
|  | 	for _, item := range widget.keyHelp { | ||||||
|  | 		str = str + fmt.Sprintf("  [%-*s]: %s\n", widget.maxKey, item.Key, item.Text) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return str | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (widget *KeyboardWidget) SetView(view *tview.TextView) { | ||||||
|  | 	widget.view = view | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (widget *KeyboardWidget) ShowHelp() { | ||||||
|  | 	closeFunc := func() { | ||||||
|  | 		widget.pages.RemovePage("help") | ||||||
|  | 		widget.app.SetFocus(widget.view) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	modal := NewBillboardModal(widget.HelpText(), closeFunc) | ||||||
|  | 
 | ||||||
|  | 	widget.pages.AddPage("help", modal, false, true) | ||||||
|  | 	widget.app.SetFocus(modal) | ||||||
|  | 
 | ||||||
|  | 	widget.app.QueueUpdate(func() { | ||||||
|  | 		widget.app.Draw() | ||||||
|  | 	}) | ||||||
|  | } | ||||||
|  | |||||||
| @ -119,6 +119,10 @@ func (widget *TextWidget) Redraw(title, text string, wrap bool) { | |||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (widget *TextWidget) HelpText() string { | ||||||
|  | 	return fmt.Sprintf("\n  There is no help available for widget %s", widget.CommonSettings.Module.Type) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *TextWidget) addView() *tview.TextView { | func (widget *TextWidget) addView() *tview.TextView { | ||||||
|  | |||||||
| @ -14,6 +14,7 @@ type Wtfable interface { | |||||||
| 	Name() string | 	Name() string | ||||||
| 	SetFocusChar(string) | 	SetFocusChar(string) | ||||||
| 	TextView() *tview.TextView | 	TextView() *tview.TextView | ||||||
|  | 	HelpText() string | ||||||
| 
 | 
 | ||||||
| 	Height() int | 	Height() int | ||||||
| 	Left() int | 	Left() int | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user