1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Todo and TextFile have keyboard short-cut to open file in OS

This commit is contained in:
Chris Cummer
2018-04-24 11:00:59 -07:00
parent 42559c396d
commit ed52835650
3 changed files with 36 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"time"
"github.com/gdamore/tcell"
"github.com/olebedev/config"
"github.com/senorprogrammer/wtf/wtf"
)
@@ -26,6 +27,8 @@ func NewWidget() *Widget {
widget.View.SetWrap(true)
widget.View.SetWordWrap(true)
widget.View.SetInputCapture(widget.keyboardIntercept)
return &widget
}
@@ -49,3 +52,14 @@ func (widget *Widget) Refresh() {
fmt.Fprintf(widget.View, "%s", fileData)
}
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
switch string(event.Rune()) {
case "o":
wtf.OpenFile(widget.FilePath)
return nil
}
return event
}