]> git.lizzy.rs Git - micro.git/commitdiff
Replace meta with alt automatically, update tcell
authorZachary Yedidia <zyedidia@gmail.com>
Sun, 6 Sep 2020 01:59:19 +0000 (21:59 -0400)
committerZachary Yedidia <zyedidia@gmail.com>
Sun, 6 Sep 2020 01:59:19 +0000 (21:59 -0400)
go.mod
go.sum
internal/action/bufpane.go
internal/action/events.go
internal/action/infopane.go
internal/action/termpane.go

diff --git a/go.mod b/go.mod
index 5b81536e0eb30684f1058470542820c9344d06d0..136d901f6b687711125c66fccd98361ac17dd58d 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,8 @@ require (
        github.com/zyedidia/highlight v0.0.0-20170330143449-201131ce5cf5
        github.com/zyedidia/json5 v0.0.0-20200102012142-2da050b1a98d
        github.com/zyedidia/pty v2.0.0+incompatible // indirect
-       github.com/zyedidia/tcell/v2 v2.0.0
+       github.com/zyedidia/tcell v1.4.12
+       github.com/zyedidia/tcell/v2 v2.0.1
        github.com/zyedidia/terminal v0.0.0-20180726154117-533c623e2415
        golang.org/x/text v0.3.2
        gopkg.in/sourcemap.v1 v1.0.5 // indirect
diff --git a/go.sum b/go.sum
index 9a36f2fb72f084fc27fd098f92f8e6f427932913..90c1d5969e29654095bd4f37ae0572efa63879bc 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -35,6 +35,8 @@ github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/xo/terminfo v0.0.0-20200218205459-454e5b68f9e8 h1:woqigIZtZUZxws1zZA99nAvuz2mQrxtWsuZSR9c8I/A=
+github.com/xo/terminfo v0.0.0-20200218205459-454e5b68f9e8/go.mod h1:6Yhx5ZJl5942QrNRWLwITArVT9okUXc5c3brgWJMoDc=
 github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
 github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb h1:ZkM6LRnq40pR1Ox0hTHlnpkcOTuFIDQpZ1IN8rKKhX0=
 github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
@@ -54,8 +56,8 @@ github.com/zyedidia/pty v2.0.0+incompatible h1:Ou5vXL6tvjst+RV8sUFISbuKDnUJPhnpy
 github.com/zyedidia/pty v2.0.0+incompatible/go.mod h1:4y9l9yJZNxRa7GB/fB+mmDmGkG3CqmzLf4vUxGGotEA=
 github.com/zyedidia/tcell v1.4.12 h1:PwsWfTKDvgSsMKL8QfFqxrD2qxZk6apxxKOJwjhLbxs=
 github.com/zyedidia/tcell v1.4.12/go.mod h1:HhlbMSCcGX15rFDB+Q1Lk3pKEOocsCUAQC3zhZ9sadA=
-github.com/zyedidia/tcell/v2 v2.0.0 h1:d6q7nFhAkbCdK3znpOfsStRIbavCvHX0wb7h3NJ4Lzc=
-github.com/zyedidia/tcell/v2 v2.0.0/go.mod h1:PT4YXe+nkU4iuQAPFfkMAZAYFQEnscyAxKsZ9B5Kl1w=
+github.com/zyedidia/tcell/v2 v2.0.1 h1:mGHCwOxIcvd8/x4W4fV+A2Z9pf06sYiepADvyhmD7D8=
+github.com/zyedidia/tcell/v2 v2.0.1/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
 github.com/zyedidia/terminal v0.0.0-20180726154117-533c623e2415 h1:752dTQ5OatJ9M5ULK2+9lor+nzyZz+LYDo3WGngg3Rc=
 github.com/zyedidia/terminal v0.0.0-20180726154117-533c623e2415/go.mod h1:8leT8G0Cm8NoJHdrrKHyR9MirWoF4YW7pZh06B6H+1E=
 golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
index 89a372c9f4c4699889421b3bdfd05b7953629542..129de8b4605b071d6e079ccb9c66c2899a2db872 100644 (file)
@@ -345,7 +345,7 @@ func (h *BufPane) HandleEvent(event tcell.Event) {
        case *tcell.EventKey:
                ke := KeyEvent{
                        code: e.Key(),
-                       mod:  e.Modifiers(),
+                       mod:  metaToAlt(e.Modifiers()),
                        r:    e.Rune(),
                }
 
@@ -395,7 +395,7 @@ func (h *BufPane) HandleEvent(event tcell.Event) {
                if !cancel {
                        me := MouseEvent{
                                btn: e.Buttons(),
-                               mod: e.Modifiers(),
+                               mod: metaToAlt(e.Modifiers()),
                        }
                        h.DoMouseEvent(me, e)
                }
index cf86a4ae221c5fe471ee83cd43a41fc2acc29ba6..3a4834f6c94e9e75e0297b65d39bcf9d4742c74c 100644 (file)
@@ -36,6 +36,14 @@ type KeyEvent struct {
        any  bool
 }
 
+func metaToAlt(mod tcell.ModMask) tcell.ModMask {
+       if mod&tcell.ModMeta != 0 {
+               mod &= ^tcell.ModMeta
+               mod |= tcell.ModAlt
+       }
+       return mod
+}
+
 func (k KeyEvent) Name() string {
        if k.any {
                return "<any>"
@@ -132,7 +140,7 @@ func ConstructEvent(event tcell.Event) (Event, error) {
        case *tcell.EventKey:
                return KeyEvent{
                        code: e.Key(),
-                       mod:  e.Modifiers(),
+                       mod:  metaToAlt(e.Modifiers()),
                        r:    e.Rune(),
                }, nil
        case *tcell.EventRaw:
@@ -142,7 +150,7 @@ func ConstructEvent(event tcell.Event) (Event, error) {
        case *tcell.EventMouse:
                return MouseEvent{
                        btn: e.Buttons(),
-                       mod: e.Modifiers(),
+                       mod: metaToAlt(e.Modifiers()),
                }, nil
        }
        return nil, errors.New("No micro event equivalent")
index acf8563da446b4f65874c9a8fe05c249688b9ed2..f1518558c32b9c8661b9c84cf41b34f32821aee6 100644 (file)
@@ -83,7 +83,7 @@ func (h *InfoPane) HandleEvent(event tcell.Event) {
        case *tcell.EventKey:
                ke := KeyEvent{
                        code: e.Key(),
-                       mod:  e.Modifiers(),
+                       mod:  metaToAlt(e.Modifiers()),
                        r:    e.Rune(),
                }
 
index cf5e33c416d7c7c37e64adf820d6c04a0a9e6cb4..ec52faffd3d1cf965066441a323b8847c090387e 100644 (file)
@@ -120,7 +120,7 @@ func (t *TermPane) HandleEvent(event tcell.Event) {
        if e, ok := event.(*tcell.EventKey); ok {
                ke := KeyEvent{
                        code: e.Key(),
-                       mod:  e.Modifiers(),
+                       mod:  metaToAlt(e.Modifiers()),
                        r:    e.Rune(),
                }
                action, more := TermBindings.NextEvent(ke, nil)