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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user