mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Merge branch 'Seanstoppable-autohelp'
This commit is contained in:
commit
5fec87812e
@ -6,6 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
goFlags "github.com/jessevdk/go-flags"
|
||||
"github.com/olebedev/config"
|
||||
"github.com/wtfutil/wtf/help"
|
||||
"github.com/wtfutil/wtf/utils"
|
||||
)
|
||||
@ -28,9 +29,9 @@ func (flags *Flags) ConfigFilePath() string {
|
||||
return flags.Config
|
||||
}
|
||||
|
||||
func (flags *Flags) Display(version string) {
|
||||
func (flags *Flags) Display(version string, config *config.Config) {
|
||||
if flags.HasModule() {
|
||||
help.Display(flags.Module)
|
||||
help.Display(flags.Module, config)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
33
help/help.go
33
help/help.go
@ -3,37 +3,20 @@ package help
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/wtfutil/wtf/modules/git"
|
||||
"github.com/wtfutil/wtf/modules/github"
|
||||
"github.com/wtfutil/wtf/modules/textfile"
|
||||
"github.com/wtfutil/wtf/modules/todo"
|
||||
"github.com/wtfutil/wtf/modules/todoist"
|
||||
"github.com/wtfutil/wtf/modules/weatherservices/weather"
|
||||
//"github.com/wtfutil/wtf/cfg"
|
||||
"github.com/olebedev/config"
|
||||
"github.com/wtfutil/wtf/maker"
|
||||
)
|
||||
|
||||
func Display(moduleName string) {
|
||||
func Display(moduleName string, config *config.Config) {
|
||||
if moduleName == "" {
|
||||
fmt.Println("\n --module takes a module name as an argument, i.e: '--module=github'")
|
||||
} else {
|
||||
fmt.Printf("%s\n", helpFor(moduleName))
|
||||
fmt.Printf("%s\n", helpFor(moduleName, config))
|
||||
}
|
||||
}
|
||||
|
||||
func helpFor(moduleName string) string {
|
||||
switch moduleName {
|
||||
case "git":
|
||||
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)
|
||||
}
|
||||
func helpFor(moduleName string, config *config.Config) string {
|
||||
widget := maker.MakeWidget(nil, nil, moduleName, moduleName, config, config)
|
||||
return widget.HelpText()
|
||||
}
|
||||
|
5
main.go
5
main.go
@ -114,14 +114,13 @@ func main() {
|
||||
|
||||
flags := flags.NewFlags()
|
||||
flags.Parse()
|
||||
flags.Display(version)
|
||||
config := cfg.LoadConfigFile(flags.ConfigFilePath())
|
||||
flags.Display(version, config)
|
||||
|
||||
cfg.MigrateOldConfig()
|
||||
cfg.CreateConfigDir()
|
||||
cfg.CreateConfigFile()
|
||||
|
||||
config := cfg.LoadConfigFile(flags.ConfigFilePath())
|
||||
|
||||
if flags.Profile {
|
||||
defer profile.Start(profile.MemProfile).Stop()
|
||||
}
|
||||
|
@ -5,13 +5,13 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("j", widget.Next)
|
||||
widget.SetKeyboardChar("k", widget.Prev)
|
||||
widget.SetKeyboardChar("o", widget.openItem)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("o", widget.openItem, "Open item in browser")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openItem)
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect)
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item")
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openItem, "Open item in browser")
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection")
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item")
|
||||
}
|
||||
|
@ -8,21 +8,7 @@ import (
|
||||
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 {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.ScrollableWidget
|
||||
|
||||
@ -32,8 +18,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true),
|
||||
|
||||
settings: settings,
|
||||
@ -43,7 +28,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -79,6 +64,10 @@ func (widget *Widget) Render() {
|
||||
widget.Redraw(widget.CommonSettings.Title, content, false)
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) contentFrom(triggeredMonitors []datadog.Monitor) string {
|
||||
|
@ -5,17 +5,17 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.prevProject)
|
||||
widget.SetKeyboardChar("l", widget.nextProject)
|
||||
widget.SetKeyboardChar("j", widget.nextReview)
|
||||
widget.SetKeyboardChar("k", widget.prevReview)
|
||||
widget.SetKeyboardChar("r", widget.Refresh)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help window")
|
||||
widget.SetKeyboardChar("h", widget.prevProject, "Select previous project")
|
||||
widget.SetKeyboardChar("l", widget.nextProject, "Select next project")
|
||||
widget.SetKeyboardChar("j", widget.nextReview, "Select next review")
|
||||
widget.SetKeyboardChar("k", widget.prevReview, "Select previous review")
|
||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh items")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.prevProject)
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.nextProject)
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.nextReview)
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.prevReview)
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openReview)
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.unselect)
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.prevProject, "Select previous project")
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.nextProject, "Select next project")
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.nextReview, "Select next review")
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.prevReview, "Select previous review")
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openReview, "Open review in browser")
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.unselect, "Clear selection")
|
||||
}
|
||||
|
@ -11,26 +11,7 @@ import (
|
||||
"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 {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
@ -49,8 +30,7 @@ var (
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
Idx: 0,
|
||||
@ -61,7 +41,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
widget.unselect()
|
||||
|
||||
@ -110,6 +90,10 @@ func (widget *Widget) Refresh() {
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) nextProject() {
|
||||
|
@ -3,12 +3,12 @@ package git
|
||||
import "github.com/gdamore/tcell"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.Prev)
|
||||
widget.SetKeyboardChar("l", widget.Next)
|
||||
widget.SetKeyboardChar("p", widget.Pull)
|
||||
widget.SetKeyboardChar("c", widget.Checkout)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help window")
|
||||
widget.SetKeyboardChar("h", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("l", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("p", widget.Pull, "Pull repo")
|
||||
widget.SetKeyboardChar("c", widget.Checkout, "Checkout branch")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item")
|
||||
}
|
||||
|
@ -11,25 +11,11 @@ import (
|
||||
"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 modalWidth = 80
|
||||
const modalHeight = 7
|
||||
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.MultiSourceWidget
|
||||
wtf.TextWidget
|
||||
@ -43,8 +29,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"),
|
||||
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.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -100,6 +85,10 @@ func (widget *Widget) Refresh() {
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) addCheckoutButton(form *tview.Form, fctn func()) {
|
||||
|
@ -5,13 +5,13 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.Prev)
|
||||
widget.SetKeyboardChar("l", widget.Next)
|
||||
widget.SetKeyboardChar("o", widget.openRepo)
|
||||
widget.SetKeyboardChar("r", widget.Refresh)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("h", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("l", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("o", widget.openRepo, "Open item in browser")
|
||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openRepo)
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openRepo, "Open item in browser")
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item")
|
||||
}
|
||||
|
@ -5,22 +5,7 @@ import (
|
||||
"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 {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
@ -33,8 +18,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
Idx: 0,
|
||||
@ -48,7 +32,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -83,6 +67,10 @@ func (widget *Widget) Prev() {
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) buildRepoCollection(repoData map[string]interface{}) []*GithubRepo {
|
||||
|
@ -3,11 +3,11 @@ package gitlab
|
||||
import "github.com/gdamore/tcell"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.Prev)
|
||||
widget.SetKeyboardChar("l", widget.Next)
|
||||
widget.SetKeyboardChar("r", widget.Refresh)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("h", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("l", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item")
|
||||
}
|
||||
|
@ -6,20 +6,7 @@ import (
|
||||
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 {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
@ -39,8 +26,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
}
|
||||
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
Idx: 0,
|
||||
@ -54,7 +40,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -87,6 +73,10 @@ func (widget *Widget) Prev() {
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) buildProjectCollection(projectData map[string]interface{}) []*GitlabProject {
|
||||
|
@ -3,12 +3,12 @@ package gitter
|
||||
import "github.com/gdamore/tcell"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("j", widget.Next)
|
||||
widget.SetKeyboardChar("k", widget.Prev)
|
||||
widget.SetKeyboardChar("r", widget.Refresh)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect)
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item")
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection")
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item")
|
||||
}
|
||||
|
@ -7,21 +7,8 @@ import (
|
||||
"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
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.ScrollableWidget
|
||||
|
||||
@ -32,8 +19,7 @@ type Widget struct {
|
||||
// NewWidget creates a new instance of a widget
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true),
|
||||
|
||||
settings: settings,
|
||||
@ -43,7 +29,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -78,6 +64,10 @@ func (widget *Widget) Refresh() {
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) display() {
|
||||
|
@ -3,15 +3,15 @@ package hackernews
|
||||
import "github.com/gdamore/tcell"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("j", widget.Next)
|
||||
widget.SetKeyboardChar("k", widget.Prev)
|
||||
widget.SetKeyboardChar("o", widget.openStory)
|
||||
widget.SetKeyboardChar("r", widget.Refresh)
|
||||
widget.SetKeyboardChar("c", widget.openComments)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help widget")
|
||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("o", widget.openStory, "Open story in browser")
|
||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
||||
widget.SetKeyboardChar("c", widget.openComments, "Open comments in browser")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openStory)
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect)
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item")
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openStory, "Open story in browser")
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection")
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item")
|
||||
}
|
||||
|
@ -9,23 +9,7 @@ import (
|
||||
"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 {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.ScrollableWidget
|
||||
|
||||
@ -35,8 +19,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true),
|
||||
|
||||
settings: settings,
|
||||
@ -46,7 +29,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
|
@ -3,14 +3,14 @@ package jenkins
|
||||
import "github.com/gdamore/tcell"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("j", widget.Next)
|
||||
widget.SetKeyboardChar("k", widget.Prev)
|
||||
widget.SetKeyboardChar("o", widget.openJob)
|
||||
widget.SetKeyboardChar("r", widget.Refresh)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("o", widget.openJob, "Open job in browser")
|
||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openJob)
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect)
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item")
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openJob, "Open job in browser")
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection")
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item")
|
||||
}
|
||||
|
@ -8,22 +8,7 @@ import (
|
||||
"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 {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.ScrollableWidget
|
||||
|
||||
@ -33,8 +18,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true),
|
||||
|
||||
settings: settings,
|
||||
@ -44,7 +28,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
|
@ -5,13 +5,13 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("j", widget.Next)
|
||||
widget.SetKeyboardChar("k", widget.Prev)
|
||||
widget.SetKeyboardChar("o", widget.openItem)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("o", widget.openItem, "Open item in browser")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openItem)
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect)
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item")
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openItem, "Open item in browser")
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection")
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item")
|
||||
}
|
||||
|
@ -7,21 +7,7 @@ import (
|
||||
"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 {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.ScrollableWidget
|
||||
|
||||
@ -31,8 +17,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true),
|
||||
|
||||
settings: settings,
|
||||
@ -42,7 +27,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
|
@ -3,12 +3,12 @@ package mercurial
|
||||
import "github.com/gdamore/tcell"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.Prev)
|
||||
widget.SetKeyboardChar("l", widget.Next)
|
||||
widget.SetKeyboardChar("p", widget.Pull)
|
||||
widget.SetKeyboardChar("c", widget.Checkout)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("h", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("l", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("p", widget.Pull, "Pull repo")
|
||||
widget.SetKeyboardChar("c", widget.Checkout, "Checkout branch")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item")
|
||||
}
|
||||
|
@ -6,26 +6,12 @@ import (
|
||||
"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 modalWidth = 80
|
||||
const modalHeight = 7
|
||||
|
||||
// A Widget represents a Mercurial widget
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.MultiSourceWidget
|
||||
wtf.TextWidget
|
||||
@ -39,8 +25,7 @@ type Widget struct {
|
||||
// NewWidget creates a new instance of a widget
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
@ -54,7 +39,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -94,6 +79,10 @@ func (widget *Widget) Refresh() {
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) addCheckoutButton(form *tview.Form, fctn func()) {
|
||||
|
@ -3,13 +3,13 @@ package nbascore
|
||||
import "github.com/gdamore/tcell"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.prev)
|
||||
widget.SetKeyboardChar("l", widget.next)
|
||||
widget.SetKeyboardChar("c", widget.center)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("h", widget.prev, "Select previous item")
|
||||
widget.SetKeyboardChar("l", widget.next, "Select next item")
|
||||
widget.SetKeyboardChar("c", widget.center, "???")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.prev)
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.next)
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.prev, "Select previous item")
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.next, "Select next item")
|
||||
}
|
||||
|
||||
func (widget *Widget) center() {
|
||||
|
@ -12,16 +12,8 @@ import (
|
||||
"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
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
@ -35,8 +27,7 @@ var offset = 0
|
||||
// NewWidget creates a new instance of a widget
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
settings: settings,
|
||||
@ -47,7 +38,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
|
||||
widget.View.SetScrollable(true)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -56,6 +47,10 @@ func (widget *Widget) Refresh() {
|
||||
widget.Redraw(widget.CommonSettings.Title, widget.nbascore(), false)
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
func (widget *Widget) nbascore() string {
|
||||
cur := time.Now().AddDate(0, 0, offset) // Go back/forward offset days
|
||||
curString := cur.Format("20060102") // Need 20060102 format to feed to api
|
||||
|
@ -3,15 +3,15 @@ package rollbar
|
||||
import "github.com/gdamore/tcell"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("j", widget.Next)
|
||||
widget.SetKeyboardChar("k", widget.Prev)
|
||||
widget.SetKeyboardChar("o", widget.openBuild)
|
||||
widget.SetKeyboardChar("r", widget.Refresh)
|
||||
widget.SetKeyboardChar("u", widget.Unselect)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("o", widget.openBuild, "Open item in browser")
|
||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
||||
widget.SetKeyboardChar("u", widget.Unselect, "Clear selection")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openBuild)
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect)
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item")
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openBuild, "Open item in browser")
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection")
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item")
|
||||
}
|
||||
|
@ -7,24 +7,8 @@ import (
|
||||
"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
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.ScrollableWidget
|
||||
|
||||
@ -35,8 +19,7 @@ type Widget struct {
|
||||
// NewWidget creates a new instance of a widget
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true),
|
||||
|
||||
settings: settings,
|
||||
@ -46,7 +29,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.previous)
|
||||
widget.SetKeyboardChar("l", widget.next)
|
||||
widget.SetKeyboardChar(" ", widget.playPause)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("h", widget.previous, "Select previous item")
|
||||
widget.SetKeyboardChar("l", widget.next, "Select next item")
|
||||
widget.SetKeyboardChar(" ", widget.playPause, "Play/pause song")
|
||||
}
|
||||
|
||||
func (widget *Widget) previous() {
|
||||
|
@ -8,16 +8,8 @@ import (
|
||||
"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
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
@ -30,8 +22,7 @@ type Widget struct {
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
spotifyClient := spotigopher.NewClient()
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
Info: spotigopher.Info{},
|
||||
@ -48,7 +39,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetWordWrap(true)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -63,6 +54,10 @@ func (w *Widget) Refresh() {
|
||||
w.render()
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
func (w *Widget) render() {
|
||||
err := w.refreshSpotifyInfos()
|
||||
var content string
|
||||
|
@ -5,11 +5,11 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.selectPrevious)
|
||||
widget.SetKeyboardChar("l", widget.selectNext)
|
||||
widget.SetKeyboardChar(" ", widget.playPause)
|
||||
widget.SetKeyboardChar("s", widget.toggleShuffle)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("h", widget.selectPrevious, "Select previous item")
|
||||
widget.SetKeyboardChar("l", widget.selectNext, "Select next item")
|
||||
widget.SetKeyboardChar(" ", widget.playPause, "Play/pause")
|
||||
widget.SetKeyboardChar("s", widget.toggleShuffle, "Toggle shuffle")
|
||||
}
|
||||
|
||||
func (widget *Widget) selectPrevious() {
|
||||
|
@ -11,26 +11,6 @@ import (
|
||||
"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
|
||||
type Info struct {
|
||||
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
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
@ -92,8 +71,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
var playerState *spotify.PlayerState
|
||||
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
Info: Info{},
|
||||
@ -145,7 +123,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetWordWrap(true)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -186,6 +164,10 @@ func (w *Widget) Refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
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]Title:[white] %v\n", w.Info.Title), w.Width())
|
||||
|
@ -6,13 +6,13 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.Prev)
|
||||
widget.SetKeyboardChar("l", widget.Next)
|
||||
widget.SetKeyboardChar("o", widget.openFile)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("h", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("l", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("o", widget.openFile, "Open item")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item")
|
||||
}
|
||||
|
||||
func (widget *Widget) openFile() {
|
||||
|
@ -18,20 +18,7 @@ import (
|
||||
"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 {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.MultiSourceWidget
|
||||
wtf.TextWidget
|
||||
@ -43,8 +30,7 @@ type Widget struct {
|
||||
// NewWidget creates a new instance of a widget
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "filePath", "filePaths"),
|
||||
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.SetWrap(true)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
go widget.watchForFileChanges()
|
||||
|
||||
@ -77,6 +63,10 @@ func (widget *Widget) Refresh() {
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) display() {
|
||||
|
@ -9,20 +9,20 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar(" ", widget.toggleChecked)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("j", widget.displayNext)
|
||||
widget.SetKeyboardChar("k", widget.displayPrev)
|
||||
widget.SetKeyboardChar("n", widget.newItem)
|
||||
widget.SetKeyboardChar("o", widget.openFile)
|
||||
widget.SetKeyboardChar(" ", widget.toggleChecked, "Toggle checkmark")
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("j", widget.displayNext, "Select next item")
|
||||
widget.SetKeyboardChar("k", widget.displayPrev, "Select previous item")
|
||||
widget.SetKeyboardChar("n", widget.newItem, "Create new item")
|
||||
widget.SetKeyboardChar("o", widget.openFile, "Open file")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyCtrlD, widget.deleteSelected)
|
||||
widget.SetKeyboardKey(tcell.KeyCtrlJ, widget.demoteSelected)
|
||||
widget.SetKeyboardKey(tcell.KeyCtrlK, widget.promoteSelected)
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.displayNext)
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.editSelected)
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.unselect)
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.displayPrev)
|
||||
widget.SetKeyboardKey(tcell.KeyCtrlD, widget.deleteSelected, "Delete item")
|
||||
widget.SetKeyboardKey(tcell.KeyCtrlJ, widget.demoteSelected, "Demote item")
|
||||
widget.SetKeyboardKey(tcell.KeyCtrlK, widget.promoteSelected, "Promote item")
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.displayNext, "Select next item")
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.editSelected, "Edit item")
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.unselect, "Clear selection")
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.displayPrev, "Select previous item")
|
||||
}
|
||||
|
||||
func (widget *Widget) deleteSelected() {
|
||||
|
@ -12,32 +12,12 @@ import (
|
||||
"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 modalWidth = 80
|
||||
const modalHeight = 7
|
||||
|
||||
// A Widget represents a Todo widget
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
@ -51,8 +31,7 @@ type Widget struct {
|
||||
// NewWidget creates a new instance of a widget
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
app: app,
|
||||
@ -70,7 +49,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.View.SetRegions(true)
|
||||
widget.View.SetScrollable(true)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -86,6 +65,10 @@ func (widget *Widget) SetList(list checklist.Checklist) {
|
||||
widget.list = list
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
// 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"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("c", widget.Close)
|
||||
widget.SetKeyboardChar("d", widget.Delete)
|
||||
widget.SetKeyboardChar("h", widget.PreviousProject)
|
||||
widget.SetKeyboardChar("j", widget.Up)
|
||||
widget.SetKeyboardChar("k", widget.Down)
|
||||
widget.SetKeyboardChar("l", widget.NextProject)
|
||||
widget.SetKeyboardChar("r", widget.Refresh)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("c", widget.Close, "Close item")
|
||||
widget.SetKeyboardChar("d", widget.Delete, "Delete item")
|
||||
widget.SetKeyboardChar("h", widget.PreviousProject, "Select previous project")
|
||||
widget.SetKeyboardChar("j", widget.Up, "Select previous item")
|
||||
widget.SetKeyboardChar("k", widget.Down, "Select next item")
|
||||
widget.SetKeyboardChar("l", widget.NextProject, "Select next project")
|
||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Down)
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.PreviousProject)
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.NextProject)
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Up)
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Down, "Select next item")
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.PreviousProject, "Select previous project")
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.NextProject, "Select next project")
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Up, "Select previous item")
|
||||
}
|
||||
|
@ -7,27 +7,8 @@ import (
|
||||
"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
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
@ -39,8 +20,7 @@ type Widget struct {
|
||||
// NewWidget creates a new instance of a widget
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
settings: settings,
|
||||
@ -52,7 +32,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -97,6 +77,10 @@ func (w *Widget) Refresh() {
|
||||
w.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Keyboard Movement -------------------- */
|
||||
|
||||
// Down selects the next item in the list
|
||||
|
@ -3,14 +3,14 @@ package travisci
|
||||
import "github.com/gdamore/tcell"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("j", widget.Next)
|
||||
widget.SetKeyboardChar("k", widget.Prev)
|
||||
widget.SetKeyboardChar("o", widget.openBuild)
|
||||
widget.SetKeyboardChar("r", widget.Refresh)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("o", widget.openBuild, "Open item in browser")
|
||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openBuild)
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect)
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item")
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openBuild, "Open item in browser")
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection")
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item")
|
||||
}
|
||||
|
@ -8,22 +8,7 @@ import (
|
||||
"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 {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.ScrollableWidget
|
||||
|
||||
@ -33,8 +18,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true),
|
||||
|
||||
settings: settings,
|
||||
@ -44,7 +28,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
|
@ -6,14 +6,14 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.Prev)
|
||||
widget.SetKeyboardChar("l", widget.Next)
|
||||
widget.SetKeyboardChar("o", widget.openFile)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("h", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("l", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("o", widget.openFile, "Open item")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openFile)
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openFile, "Open item")
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item")
|
||||
}
|
||||
|
||||
func (widget *Widget) openFile() {
|
||||
|
@ -10,20 +10,7 @@ import (
|
||||
"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 {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.MultiSourceWidget
|
||||
wtf.TextWidget
|
||||
@ -36,8 +23,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "screenName", "screenNames"),
|
||||
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.SetWordWrap(true)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -68,6 +54,10 @@ func (widget *Widget) Refresh() {
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) display() {
|
||||
|
@ -7,15 +7,6 @@ import (
|
||||
"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
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
@ -3,10 +3,10 @@ package weather
|
||||
import "github.com/gdamore/tcell"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.Prev)
|
||||
widget.SetKeyboardChar("l", widget.Next)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("h", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("l", widget.Next, "Select next item")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item")
|
||||
}
|
||||
|
@ -6,20 +6,8 @@ import (
|
||||
"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.
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
@ -33,8 +21,7 @@ type Widget struct {
|
||||
// NewWidget creates and returns a new instance of the weather Widget
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
Idx: 0,
|
||||
@ -45,7 +32,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
@ -100,6 +87,10 @@ func (widget *Widget) Prev() {
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) HelpText() string {
|
||||
return widget.KeyboardWidget.HelpText()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) apiKeyValid() bool {
|
||||
|
@ -3,12 +3,13 @@ package zendesk
|
||||
import "github.com/gdamore/tcell"
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("j", widget.Next)
|
||||
widget.SetKeyboardChar("k", widget.Prev)
|
||||
widget.SetKeyboardChar("o", widget.openTicket)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardChar("o", widget.openTicket, "Open item")
|
||||
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next)
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev)
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openTicket)
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect)
|
||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item")
|
||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item")
|
||||
widget.SetKeyboardKey(tcell.KeyEnter, widget.openTicket, "Open item")
|
||||
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Clear selection")
|
||||
}
|
||||
|
@ -8,23 +8,8 @@ import (
|
||||
"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
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.ScrollableWidget
|
||||
|
||||
@ -35,10 +20,9 @@ type Widget struct {
|
||||
// NewWidget creates a new instance of a widget
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true),
|
||||
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true),
|
||||
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -46,6 +30,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.initializeKeyboardControls()
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,10 @@ func (widget *BarGraph) TextView() *tview.TextView {
|
||||
return widget.View
|
||||
}
|
||||
|
||||
func (widget *BarGraph) HelpText() string {
|
||||
return "No help available for this widget"
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
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
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"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
|
||||
type KeyboardWidget struct {
|
||||
charMap map[string]func()
|
||||
keyMap map[tcell.Key]func()
|
||||
app *tview.Application
|
||||
pages *tview.Pages
|
||||
view *tview.TextView
|
||||
settings *cfg.Common
|
||||
|
||||
charMap map[string]func()
|
||||
keyMap map[tcell.Key]func()
|
||||
charHelp []helpItem
|
||||
keyHelp []helpItem
|
||||
maxKey int
|
||||
}
|
||||
|
||||
// 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{
|
||||
charMap: make(map[string]func()),
|
||||
keyMap: make(map[tcell.Key]func()),
|
||||
app: app,
|
||||
pages: pages,
|
||||
settings: settings,
|
||||
charMap: make(map[string]func()),
|
||||
keyMap: make(map[tcell.Key]func()),
|
||||
charHelp: []helpItem{},
|
||||
keyHelp: []helpItem{},
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,8 +45,9 @@ func NewKeyboardWidget() KeyboardWidget {
|
||||
//
|
||||
// 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.charHelp = append(widget.charHelp, helpItem{char, helpText})
|
||||
}
|
||||
|
||||
// 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)
|
||||
//
|
||||
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.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
|
||||
@ -56,3 +83,39 @@ func (widget *KeyboardWidget) InputCapture(event *tcell.EventKey) *tcell.EventKe
|
||||
|
||||
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 -------------------- */
|
||||
|
||||
func (widget *TextWidget) addView() *tview.TextView {
|
||||
|
@ -14,6 +14,7 @@ type Wtfable interface {
|
||||
Name() string
|
||||
SetFocusChar(string)
|
||||
TextView() *tview.TextView
|
||||
HelpText() string
|
||||
|
||||
Height() int
|
||||
Left() int
|
||||
|
Loading…
x
Reference in New Issue
Block a user