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
18 lines
827 B
Go
18 lines
827 B
Go
package hackernews
|
|
|
|
import "github.com/gdamore/tcell"
|
|
|
|
func (widget *Widget) initializeKeyboardControls() {
|
|
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, "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")
|
|
}
|