mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
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
23 lines
713 B
Go
23 lines
713 B
Go
package twitter
|
|
|
|
import (
|
|
"github.com/gdamore/tcell"
|
|
"github.com/wtfutil/wtf/wtf"
|
|
)
|
|
|
|
func (widget *Widget) initializeKeyboardControls() {
|
|
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, "Open item")
|
|
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous item")
|
|
widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next item")
|
|
}
|
|
|
|
func (widget *Widget) openFile() {
|
|
src := widget.currentSourceURI()
|
|
wtf.OpenFile(src)
|
|
}
|