diff --git a/go.mod b/go.mod index 2951f7c..9e28b42 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/creack/pty v1.1.9 github.com/gdamore/tcell v1.3.0 github.com/gofrs/uuid v3.2.0+incompatible + github.com/micmonay/keybd_event v1.0.0 github.com/mitchellh/go-homedir v1.1.0 github.com/rivo/tview v0.0.0-20190324182152-8a9e26fab0ff github.com/rivo/uniseg v0.1.0 // indirect diff --git a/go.sum b/go.sum index 0124856..a3e31e6 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,8 @@ github.com/lucasb-eyer/go-colorful v1.0.2 h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09 github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s= github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/micmonay/keybd_event v1.0.0 h1:gq5S9QdUx/KHsWwT+bTgib4vCZlXuS+xplkEqwhu6Zo= +github.com/micmonay/keybd_event v1.0.0/go.mod h1:QS2Kfz0PbPezFqMPEot+l/cK78/tHLZtZ7AbYUCRKsQ= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/rivo/tview v0.0.0-20190324182152-8a9e26fab0ff h1:GrQgx8/nVONecTx4oGQ6O78pD8lVehvpQqeHGGPrCQM= diff --git a/gui/gui.go b/gui/gui.go index e522d61..a098d91 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -17,6 +17,7 @@ import ( "github.com/creack/pty" "github.com/gdamore/tcell" + "github.com/micmonay/keybd_event" "github.com/rivo/tview" "golang.org/x/crypto/ssh/terminal" ) @@ -25,6 +26,8 @@ var ( ErrEmptyJSON = errors.New("empty json") ) +var kb keybd_event.KeyBonding + type Gui struct { Tree *Tree Navi *Navi @@ -43,6 +46,20 @@ func New() *Gui { } func (g *Gui) Run(i interface{}) error { + var err error + kb, err = keybd_event.NewKeyBonding() + if err != nil { + panic(err) + } + + // For linux, it is very important wait 2 seconds + //if runtime.GOOS == "linux" { + // time.Sleep(2 * time.Second) + //} + + //set keys + kb.SetKeys(keybd_event.VK_A, keybd_event.VK_B) + g.Tree.UpdateView(g, i) g.Tree.SetKeybindings(g) g.Navi.UpdateView() @@ -428,6 +445,10 @@ func (g *Gui) EditWithEditor() { g.Tree.UpdateView(g, i) }) + + if err := kb.Launching(); err != nil { + panic(err) + } } func UnMarshalJSON(in io.Reader) (interface{}, error) {