Update to tcell v2

This commit is contained in:
Zachary Yedidia 2020-09-05 14:52:35 -04:00
parent f35f507832
commit 11104fd093
21 changed files with 32 additions and 39 deletions

View 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()
}

View 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

2
go.mod
View file

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

2
go.sum
View file

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

View 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

View 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,

View 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

View file

@ -6,7 +6,7 @@ import (
"fmt"
"strings"
"github.com/zyedidia/tcell"
"github.com/zyedidia/tcell/v2"
)
type Event interface {

View 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)

View file

@ -3,7 +3,7 @@ package action
import (
"bytes"
"github.com/zyedidia/tcell"
"github.com/zyedidia/tcell/v2"
)
type PaneKeyAction func(Pane) bool

View 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 {

View 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

View 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"
)

View 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

View 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{}

View file

@ -6,7 +6,7 @@ import (
"strconv"
"strings"
"github.com/zyedidia/tcell"
"github.com/zyedidia/tcell/v2"
)
// Micro's default style

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

View 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

View 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 {

View 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"
)

View 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