]> git.lizzy.rs Git - micro.git/commitdiff
Update to tcell v2
authorZachary Yedidia <zyedidia@gmail.com>
Sat, 5 Sep 2020 18:52:35 +0000 (14:52 -0400)
committerZachary Yedidia <zyedidia@gmail.com>
Sat, 5 Sep 2020 18:52:35 +0000 (14:52 -0400)
21 files changed:
cmd/micro/micro.go
cmd/micro/micro_test.go
go.mod
go.sum
internal/action/actions.go
internal/action/bindings.go
internal/action/bufpane.go
internal/action/events.go
internal/action/infopane.go
internal/action/keytree.go
internal/action/rawpane.go
internal/action/tab.go
internal/action/termpane.go
internal/buffer/message.go
internal/clipboard/terminal.go
internal/config/colorscheme.go
internal/config/colorscheme_test.go
internal/display/bufwindow.go
internal/display/infowindow.go
internal/display/termwindow.go
internal/screen/screen.go

index 520d7fb40c51d9100813591bfcee4f789cd93a8f..e669d4dbef1d8bdc0749b69d10e93867bf6766d2 100644 (file)
@@ -24,7 +24,7 @@ import (
        "github.com/zyedidia/micro/v2/internal/screen"
        "github.com/zyedidia/micro/v2/internal/shell"
        "github.com/zyedidia/micro/v2/internal/util"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 var (
@@ -297,13 +297,15 @@ func main() {
                        if screen.Screen != nil {
                                screen.Screen.Fini()
                        }
-                       fmt.Println("Micro encountered an error:", err)
+                       if e, ok := err.(*lua.ApiError); ok {
+                               fmt.Println("Lua API error:", e)
+                       } else {
+                               fmt.Println("Micro encountered an error:", errors.Wrap(err, 2).ErrorStack(), "\nIf you can reproduce this error, please report it at https://github.com/zyedidia/micro/issues")
+                       }
                        // backup all open buffers
                        for _, b := range buffer.OpenBuffers {
                                b.Backup()
                        }
-                       // Print the stack trace too
-                       fmt.Print(errors.Wrap(err, 2).ErrorStack())
                        os.Exit(1)
                }
        }()
@@ -380,9 +382,6 @@ func main() {
                // time out after 10ms
        }
 
-       // Since this loop is very slow (waits for user input every time) it's
-       // okay to be inefficient and run it via a function every time
-       // We do this so we can recover from panics without crashing the editor
        for {
                DoEvent()
        }
@@ -392,16 +391,6 @@ func main() {
 func DoEvent() {
        var event tcell.Event
 
-       // recover from errors without crashing the editor
-       defer func() {
-               if err := recover(); err != nil {
-                       if e, ok := err.(*lua.ApiError); ok {
-                               screen.TermMessage("Lua API error:", e)
-                       } else {
-                               screen.TermMessage("Micro encountered an error:", errors.Wrap(err, 2).ErrorStack(), "\nIf you can reproduce this error, please report it at https://github.com/zyedidia/micro/issues")
-                       }
-               }
-       }()
        // Display everything
        screen.Screen.Fill(' ', config.DefStyle)
        screen.Screen.HideCursor()
@@ -435,10 +424,12 @@ func DoEvent() {
        }
 
        ulua.Lock.Lock()
+       // if event != nil {
        if action.InfoBar.HasPrompt {
                action.InfoBar.HandleEvent(event)
        } else {
                action.Tabs.HandleEvent(event)
        }
+       // }
        ulua.Lock.Unlock()
 }
index 0a52bc8f635e5ada8d307bd53146f5034f2769c7..c5b64ef9d77af83fdd5f0f58e540b897c2404877 100644 (file)
@@ -13,7 +13,7 @@ import (
        "github.com/zyedidia/micro/v2/internal/buffer"
        "github.com/zyedidia/micro/v2/internal/config"
        "github.com/zyedidia/micro/v2/internal/screen"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 var tempDir string
diff --git a/go.mod b/go.mod
index 3a963294f2398e1fe92a1b6ca8d4a6ffcf671fc1..5b81536e0eb30684f1058470542820c9344d06d0 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,7 @@ 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 v1.4.12
+       github.com/zyedidia/tcell/v2 v2.0.0
        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 aa2f7752c303c94379cfffcff92a0a2f3b47ca9f..9a36f2fb72f084fc27fd098f92f8e6f427932913 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -54,6 +54,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/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 b80ff67ba16411b9a7c465933f8b75c80203e389..4bc5034b69d5ee4b5abcb9aa54e978b0c9f9c7fa 100644 (file)
@@ -13,7 +13,7 @@ import (
        "github.com/zyedidia/micro/v2/internal/screen"
        "github.com/zyedidia/micro/v2/internal/shell"
        "github.com/zyedidia/micro/v2/internal/util"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 // ScrollUp is not an action
index b3976c79fb48d8171f2d4ee3831d83d124b81c4d..fcd557bb9f8898505d9ef5b56ab9f2301037e7c7 100644 (file)
@@ -13,7 +13,7 @@ import (
        "github.com/zyedidia/json5"
        "github.com/zyedidia/micro/v2/internal/config"
        "github.com/zyedidia/micro/v2/internal/screen"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 var Binder = map[string]func(e Event, action string){
@@ -334,9 +334,9 @@ func UnbindKey(k string) error {
 }
 
 var mouseEvents = map[string]tcell.ButtonMask{
-       "MouseLeft":       tcell.Button1,
-       "MouseMiddle":     tcell.Button2,
-       "MouseRight":      tcell.Button3,
+       "MouseLeft":       tcell.ButtonPrimary,
+       "MouseMiddle":     tcell.ButtonMiddle,
+       "MouseRight":      tcell.ButtonSecondary,
        "MouseWheelUp":    tcell.WheelUp,
        "MouseWheelDown":  tcell.WheelDown,
        "MouseWheelLeft":  tcell.WheelLeft,
index 9f35df1b29e45995db442a5fea8ed9702d33acbf..89a372c9f4c4699889421b3bdfd05b7953629542 100644 (file)
@@ -13,7 +13,7 @@ import (
        "github.com/zyedidia/micro/v2/internal/display"
        ulua "github.com/zyedidia/micro/v2/internal/lua"
        "github.com/zyedidia/micro/v2/internal/screen"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 type BufKeyAction func(*BufPane) bool
index 3378f5ccb50a41f3454d9c980ff354f9d30e8a67..cf86a4ae221c5fe471ee83cd43a41fc2acc29ba6 100644 (file)
@@ -6,7 +6,7 @@ import (
        "fmt"
        "strings"
 
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 type Event interface {
index ed4aea291a74bef92998d8b02e8e27832990cdad..acf8563da446b4f65874c9a8fe05c249688b9ed2 100644 (file)
@@ -7,7 +7,7 @@ import (
        "github.com/zyedidia/micro/v2/internal/display"
        "github.com/zyedidia/micro/v2/internal/info"
        "github.com/zyedidia/micro/v2/internal/util"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 type InfoKeyAction func(*InfoPane)
index 5b19640ebf741bedf34dc01bd2ff5f6b82c39a82..d507eb11163321c224f652c05aa8049379ec78ab 100644 (file)
@@ -3,7 +3,7 @@ package action
 import (
        "bytes"
 
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 type PaneKeyAction func(Pane) bool
index bc8ade2a968d3c6e96df17093fee006a4ec05b06..7d0c57cc1f3fbae1f5937bbea8a717b8a627604f 100644 (file)
@@ -6,7 +6,7 @@ import (
 
        "github.com/zyedidia/micro/v2/internal/buffer"
        "github.com/zyedidia/micro/v2/internal/display"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 type RawPane struct {
index 66a21c6f2c053198172b41ca45cdc349dbd70c0d..54f693ec64e08d86f7f203360428cff5fe88ab27 100644 (file)
@@ -6,7 +6,7 @@ import (
        "github.com/zyedidia/micro/v2/internal/display"
        "github.com/zyedidia/micro/v2/internal/screen"
        "github.com/zyedidia/micro/v2/internal/views"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 // The TabList is a list of tabs and a window to display the tab bar
index 59ee7e84e4e9c308a3958bcc7041a7b5e7a58d81..cf5e33c416d7c7c37e64adf820d6c04a0a9e6cb4 100644 (file)
@@ -8,7 +8,7 @@ import (
        "github.com/zyedidia/micro/v2/internal/display"
        "github.com/zyedidia/micro/v2/internal/screen"
        "github.com/zyedidia/micro/v2/internal/shell"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
        "github.com/zyedidia/terminal"
 )
 
index ce3d4547c6d148d163027d083e0a34b67e645745..31c963265792b62cf1a1475349c83e37aa7087f3 100644 (file)
@@ -2,7 +2,7 @@ package buffer
 
 import (
        "github.com/zyedidia/micro/v2/internal/config"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 type MsgType int
index fca42967d04cae7070d61c16ff27689c0015579d..e3a05287938844e54ed5eaa6acf5701f5e8ea336 100644 (file)
@@ -5,7 +5,7 @@ import (
        "time"
 
        "github.com/zyedidia/micro/v2/internal/screen"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 type terminalClipboard struct{}
index 8109d07a6e06f18528b99abee058af320b6541f5..7d2fd9cf6929d1d636bc6ff20d9dd07eeb288d9c 100644 (file)
@@ -6,7 +6,7 @@ import (
        "strconv"
        "strings"
 
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 // Micro's default style
index 106fd1be0215ca558afc983302e8b5ee9e5d7951..2785c58118fe096698bc99be7f9dd6e7a1184bae 100644 (file)
@@ -4,7 +4,7 @@ import (
        "testing"
 
        "github.com/stretchr/testify/assert"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 func TestSimpleStringToStyle(t *testing.T) {
index 5eaec35d6cb51cff310a583b118b5533159bc266..f6c01de46a503b9c224c55a76a56ef728e723d61 100644 (file)
@@ -8,7 +8,7 @@ import (
        "github.com/zyedidia/micro/v2/internal/config"
        "github.com/zyedidia/micro/v2/internal/screen"
        "github.com/zyedidia/micro/v2/internal/util"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 // The BufWindow provides a way of displaying a certain section
index 32662be2ca77f4dd37f618f29b5a56f03eb6eed4..a5d02c7b67993e46ffa251622993f4a3b19f03d8 100644 (file)
@@ -7,7 +7,7 @@ import (
        "github.com/zyedidia/micro/v2/internal/info"
        "github.com/zyedidia/micro/v2/internal/screen"
        "github.com/zyedidia/micro/v2/internal/util"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 type InfoWindow struct {
index 6250fea906c18046d0f1d811262e8733fdef5a20..6d85654cba5f5576ce89c5f278353d1b046a8d53 100644 (file)
@@ -6,7 +6,7 @@ import (
        "github.com/zyedidia/micro/v2/internal/screen"
        "github.com/zyedidia/micro/v2/internal/shell"
        "github.com/zyedidia/micro/v2/internal/util"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
        "github.com/zyedidia/terminal"
 )
 
index 4991529b4bc96a8570581ec20f5bacc63c03c994..bd9005acce7bf69db10a5f3b16de662d22fb9983 100644 (file)
@@ -7,7 +7,7 @@ import (
 
        "github.com/zyedidia/micro/v2/internal/config"
        "github.com/zyedidia/micro/v2/internal/util"
-       "github.com/zyedidia/tcell"
+       "github.com/zyedidia/tcell/v2"
 )
 
 // Screen is the tcell screen we use to draw to the terminal