1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/textfile/keyboard.go
Sean Smith a2f5db7847 Harmonize keyboard controls
Make sure everyone has a refresh option
Have specific ordering:
 - Help
 - Refresh
 - Select next
 - Select prev
 - ...

Add unselect where applicable
2019-05-20 18:45:08 -04:00

23 lines
735 B
Go

package textfile
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("l", widget.NextSource, "Select next file")
widget.SetKeyboardChar("h", widget.PrevSource, "Select previous file")
widget.SetKeyboardChar("o", widget.openFile, "Open file")
widget.SetKeyboardKey(tcell.KeyRight, widget.NextSource, "Select next file")
widget.SetKeyboardKey(tcell.KeyLeft, widget.PrevSource, "Select previous file")
widget.SetKeyboardKey(tcell.KeyEnter, widget.openFile, "Open file")
}
func (widget *Widget) openFile() {
src := widget.CurrentSource()
wtf.OpenFile(src)
}