fix lost keystrok when restore suspend

develop
skanehira 5 years ago
parent 7e19c80c78
commit e05007d4d0

@ -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

@ -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=

@ -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) {

Loading…
Cancel
Save