mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Have keyboard widget manage its own help
Define help with keys This means that keys and help are automatically in sync This means that you can't define keys, but forget help This unfortunately also means that formatting may not be quite as good
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user