mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Opening docs in browser is working, but only for keyboard modules
This needs to work for all modules, which means effectively every module just became a keyboard module, if it is focusable. That's an interesting development. Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
parent
3521ebf6e8
commit
2430fe9f56
@ -7,6 +7,7 @@ import (
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/rivo/tview"
|
||||
"github.com/wtfutil/wtf/cfg"
|
||||
"github.com/wtfutil/wtf/utils"
|
||||
)
|
||||
|
||||
type helpItem struct {
|
||||
@ -80,6 +81,7 @@ func (widget *KeyboardWidget) SetKeyboardKey(key tcell.Key, fn func(), helpText
|
||||
// all widgets that accept keyboard input
|
||||
func (widget *KeyboardWidget) InitializeCommonControls(refreshFunc func()) {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("\\", widget.OpenDocs, "Open the docs in a browser")
|
||||
|
||||
if refreshFunc != nil {
|
||||
widget.SetKeyboardChar("r", refreshFunc, "Refresh widget")
|
||||
@ -127,10 +129,18 @@ func (widget *KeyboardWidget) HelpText() string {
|
||||
return str
|
||||
}
|
||||
|
||||
// OpenDocs opens the module docs in a browser
|
||||
func (widget *KeyboardWidget) OpenDocs() {
|
||||
url := "https://wtfutil.com/modules/" + widget.settings.Name
|
||||
utils.OpenFile(url)
|
||||
}
|
||||
|
||||
// SetView assigns the passed-in tview.TextView view to this widget
|
||||
func (widget *KeyboardWidget) SetView(view *tview.TextView) {
|
||||
widget.view = view
|
||||
}
|
||||
|
||||
// ShowHelp displays the modal help dialog for a module
|
||||
func (widget *KeyboardWidget) ShowHelp() {
|
||||
closeFunc := func() {
|
||||
widget.pages.RemovePage("help")
|
||||
|
Loading…
x
Reference in New Issue
Block a user