From 03650474e2190ef6e54413d433b3d1f63dc9993e Mon Sep 17 00:00:00 2001 From: y0ast Date: Mon, 30 Nov 2020 22:07:03 +0000 Subject: [PATCH] update tcell to v2 and enable TrueColor support Also update to the tcell v2 PaletteColor api, which should keep the chosen theme of the user intact. Note, that if $TRUECOLOR is defined and a truecolor given, aerc will now stop clipping the value to one of the theme colors. Generally this is desired behaviour though. --- commands/util.go | 2 +- config/bindings.go | 2 +- config/bindings_test.go | 2 +- config/config.go | 2 +- config/style.go | 2 +- go.mod | 5 +---- go.sum | 8 +++----- lib/ui/borders.go | 2 +- lib/ui/context.go | 4 ++-- lib/ui/fill.go | 2 +- lib/ui/grid.go | 2 +- lib/ui/interfaces.go | 2 +- lib/ui/popover.go | 2 +- lib/ui/stack.go | 2 +- lib/ui/tab.go | 2 +- lib/ui/text.go | 2 +- lib/ui/textinput.go | 2 +- lib/ui/ui.go | 2 +- widgets/account-wizard.go | 2 +- widgets/account.go | 2 +- widgets/aerc.go | 2 +- widgets/compose.go | 2 +- widgets/dirlist.go | 2 +- widgets/exline.go | 2 +- widgets/getpasswd.go | 2 +- widgets/msglist.go | 2 +- widgets/msgviewer.go | 2 +- widgets/selector.go | 2 +- widgets/spinner.go | 2 +- widgets/status.go | 2 +- widgets/terminal.go | 6 +++--- 31 files changed, 36 insertions(+), 41 deletions(-) diff --git a/commands/util.go b/commands/util.go index fdf20bd..b1872bc 100644 --- a/commands/util.go +++ b/commands/util.go @@ -13,7 +13,7 @@ import ( "git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/models" "git.sr.ht/~sircmpwn/aerc/widgets" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/mitchellh/go-homedir" ) diff --git a/config/bindings.go b/config/bindings.go index a19d4f3..9956b41 100644 --- a/config/bindings.go +++ b/config/bindings.go @@ -7,7 +7,7 @@ import ( "io" "strings" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) type KeyStroke struct { diff --git a/config/bindings_test.go b/config/bindings_test.go index 1d1cbfe..4459736 100644 --- a/config/bindings_test.go +++ b/config/bindings_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/stretchr/testify/assert" ) diff --git a/config/config.go b/config/config.go index 51982d2..e646133 100644 --- a/config/config.go +++ b/config/config.go @@ -14,7 +14,7 @@ import ( "time" "unicode" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/go-ini/ini" "github.com/imdario/mergo" "github.com/kyoh86/xdg" diff --git a/config/style.go b/config/style.go index af7241d..c3e8503 100644 --- a/config/style.go +++ b/config/style.go @@ -8,7 +8,7 @@ import ( "regexp" "strings" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/go-ini/ini" "github.com/mitchellh/go-homedir" ) diff --git a/go.mod b/go.mod index 9e324bd..44030e1 100644 --- a/go.mod +++ b/go.mod @@ -16,14 +16,13 @@ require ( github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 github.com/emersion/go-smtp v0.12.1 github.com/fsnotify/fsnotify v1.4.7 - github.com/gdamore/tcell v1.3.0 + github.com/gdamore/tcell/v2 v2.0.0 github.com/go-ini/ini v1.52.0 github.com/golang/protobuf v1.3.4 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c // indirect github.com/imdario/mergo v0.3.8 github.com/kyoh86/xdg v1.2.0 - github.com/lucasb-eyer/go-colorful v1.0.3 // indirect github.com/mattn/go-isatty v0.0.12 github.com/mattn/go-pointer v0.0.0-20190911064623-a0a44394634f // indirect github.com/mattn/go-runewidth v0.0.8 @@ -46,6 +45,4 @@ require ( replace golang.org/x/crypto => github.com/ProtonMail/crypto v0.0.0-20200420072808-71bec3603bf3 -replace github.com/gdamore/tcell => git.sr.ht/~sircmpwn/tcell v0.0.0-20190807054800-3fdb6bc01a50 - replace github.com/zenhack/go.notmuch => github.com/brunnre8/go.notmuch v0.0.0-20201126061756-caa2daf7093c diff --git a/go.sum b/go.sum index 134b35b..83b19ae 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,6 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= git.sr.ht/~sircmpwn/getopt v0.0.0-20190808004552-daaf1274538b h1:da5JBQ6dcW14aWnEf/pFRIMV2PsqTQEWmR+V2sw5oxU= git.sr.ht/~sircmpwn/getopt v0.0.0-20190808004552-daaf1274538b/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw= -git.sr.ht/~sircmpwn/tcell v0.0.0-20190807054800-3fdb6bc01a50 h1:GEZXdK3vfsEGlRwlybiAvOnYLA4YKaVWxAQSn/BSkNw= -git.sr.ht/~sircmpwn/tcell v0.0.0-20190807054800-3fdb6bc01a50/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= -github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/ProtonMail/crypto v0.0.0-20200420072808-71bec3603bf3 h1:JW27/kGLQzeM1Fxg5YQhdkTEAU7HIAHMgSag35zVTnY= github.com/ProtonMail/crypto v0.0.0-20200420072808-71bec3603bf3/go.mod h1:Pxr7w4gA2ikI4sWyYwEffm+oew1WAJHzG1SiDpQMkrI= github.com/brunnre8/go.notmuch v0.0.0-20201126061756-caa2daf7093c h1:dh58QrW3/S/aCnQPFoeRRE9zMauKooDFd5zh1dLtxXs= @@ -48,6 +45,8 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= +github.com/gdamore/tcell/v2 v2.0.0 h1:GRWG8aLfWAlekj9Q6W29bVvkHENc6hp79XOqG4AWDOs= +github.com/gdamore/tcell/v2 v2.0.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA= github.com/go-ini/ini v1.52.0 h1:3UeUAveYUTCYV/G0jNDiIrrtIeAl1oAjshYyU2PaAlQ= github.com/go-ini/ini v1.52.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -65,7 +64,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kyoh86/xdg v1.2.0 h1:CERuT/ShdTDj+A2UaX3hQ3mOV369+Sj+wyn2nIRIIkI= github.com/kyoh86/xdg v1.2.0/go.mod h1:/mg8zwu1+qe76oTFUBnyS7rJzk7LLC0VGEzJyJ19DHs= -github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s= github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/martinlindhe/base36 v0.0.0-20190418230009-7c6542dfbb41/go.mod h1:+AtEs8xrBpCeYgSLoY/aJ6Wf37jtBuR0s35750M27+8= @@ -78,7 +76,7 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky github.com/mattn/go-pointer v0.0.0-20180825124634-49522c3f3791/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= github.com/mattn/go-pointer v0.0.0-20190911064623-a0a44394634f h1:QTRRO+ozoYgT3CQRIzNVYJRU3DB8HRnkZv6mr4ISmMA= github.com/mattn/go-pointer v0.0.0-20190911064623-a0a44394634f/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= -github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.8 h1:3tS41NlGYSmhhe/8fhGRzc+z3AYCw1Fe1WAyLuujKs0= github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/miolini/datacounter v1.0.2 h1:mGTL0vqEAtH7mwNJS1JIpd6jwTAP6cBQQ2P8apaCIm8= diff --git a/lib/ui/borders.go b/lib/ui/borders.go index 99d6880..fd49e7f 100644 --- a/lib/ui/borders.go +++ b/lib/ui/borders.go @@ -1,7 +1,7 @@ package ui import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "git.sr.ht/~sircmpwn/aerc/config" ) diff --git a/lib/ui/context.go b/lib/ui/context.go index 6bdf76a..7936f35 100644 --- a/lib/ui/context.go +++ b/lib/ui/context.go @@ -3,8 +3,8 @@ package ui import ( "fmt" - "github.com/gdamore/tcell" - "github.com/gdamore/tcell/views" + "github.com/gdamore/tcell/v2" + "github.com/gdamore/tcell/v2/views" "github.com/mattn/go-runewidth" ) diff --git a/lib/ui/fill.go b/lib/ui/fill.go index 4d36478..0ab4f74 100644 --- a/lib/ui/fill.go +++ b/lib/ui/fill.go @@ -1,7 +1,7 @@ package ui import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) type Fill rune diff --git a/lib/ui/grid.go b/lib/ui/grid.go index cff5577..f505ce0 100644 --- a/lib/ui/grid.go +++ b/lib/ui/grid.go @@ -6,7 +6,7 @@ import ( "sync" "sync/atomic" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) type Grid struct { diff --git a/lib/ui/interfaces.go b/lib/ui/interfaces.go index 1f2f284..7e11725 100644 --- a/lib/ui/interfaces.go +++ b/lib/ui/interfaces.go @@ -1,7 +1,7 @@ package ui import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // Drawable is a UI component that can draw. Unless specified, all methods must diff --git a/lib/ui/popover.go b/lib/ui/popover.go index a76f222..7a539de 100644 --- a/lib/ui/popover.go +++ b/lib/ui/popover.go @@ -1,6 +1,6 @@ package ui -import "github.com/gdamore/tcell" +import "github.com/gdamore/tcell/v2" type Popover struct { x, y, width, height int diff --git a/lib/ui/stack.go b/lib/ui/stack.go index c9004a0..5371408 100644 --- a/lib/ui/stack.go +++ b/lib/ui/stack.go @@ -5,7 +5,7 @@ import ( "git.sr.ht/~sircmpwn/aerc/config" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) type Stack struct { diff --git a/lib/ui/tab.go b/lib/ui/tab.go index cd5f448..2cd8828 100644 --- a/lib/ui/tab.go +++ b/lib/ui/tab.go @@ -3,7 +3,7 @@ package ui import ( "io" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/mattn/go-runewidth" "git.sr.ht/~sircmpwn/aerc/config" diff --git a/lib/ui/text.go b/lib/ui/text.go index 455c2eb..ffae193 100644 --- a/lib/ui/text.go +++ b/lib/ui/text.go @@ -1,7 +1,7 @@ package ui import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/mattn/go-runewidth" ) diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go index 2445065..e96499a 100644 --- a/lib/ui/textinput.go +++ b/lib/ui/textinput.go @@ -4,7 +4,7 @@ import ( "math" "time" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/mattn/go-runewidth" "git.sr.ht/~sircmpwn/aerc/config" diff --git a/lib/ui/ui.go b/lib/ui/ui.go index ee71f8e..66c2a05 100644 --- a/lib/ui/ui.go +++ b/lib/ui/ui.go @@ -3,7 +3,7 @@ package ui import ( "sync/atomic" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) type UI struct { diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go index f47e97e..71ba6e1 100644 --- a/widgets/account-wizard.go +++ b/widgets/account-wizard.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/go-ini/ini" "github.com/kyoh86/xdg" diff --git a/widgets/account.go b/widgets/account.go index f279513..fc746a4 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -5,7 +5,7 @@ import ( "fmt" "log" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "git.sr.ht/~sircmpwn/aerc/config" "git.sr.ht/~sircmpwn/aerc/lib" diff --git a/widgets/aerc.go b/widgets/aerc.go index b5e8dd1..70bee7c 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -10,7 +10,7 @@ import ( "time" "github.com/emersion/go-message/mail" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/google/shlex" "golang.org/x/crypto/openpgp" diff --git a/widgets/compose.go b/widgets/compose.go index e139f9a..aab3308 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -16,7 +16,7 @@ import ( "time" "github.com/emersion/go-message/mail" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/mattn/go-runewidth" "github.com/mitchellh/go-homedir" "github.com/pkg/errors" diff --git a/widgets/dirlist.go b/widgets/dirlist.go index aca1491..5711fe4 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -7,7 +7,7 @@ import ( "regexp" "sort" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/mattn/go-runewidth" "git.sr.ht/~sircmpwn/aerc/config" diff --git a/widgets/exline.go b/widgets/exline.go index 692c8e2..24c39c1 100644 --- a/widgets/exline.go +++ b/widgets/exline.go @@ -1,7 +1,7 @@ package widgets import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "git.sr.ht/~sircmpwn/aerc/config" "git.sr.ht/~sircmpwn/aerc/lib" diff --git a/widgets/getpasswd.go b/widgets/getpasswd.go index 3cdc5cf..b5c3d0e 100644 --- a/widgets/getpasswd.go +++ b/widgets/getpasswd.go @@ -3,7 +3,7 @@ package widgets import ( "fmt" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "git.sr.ht/~sircmpwn/aerc/config" "git.sr.ht/~sircmpwn/aerc/lib/ui" diff --git a/widgets/msglist.go b/widgets/msglist.go index 61738a8..827282b 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -5,7 +5,7 @@ import ( "log" "math" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/mattn/go-runewidth" "git.sr.ht/~sircmpwn/aerc/config" diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index 6c69577..216a8c5 100644 --- a/widgets/msgviewer.go +++ b/widgets/msgviewer.go @@ -11,7 +11,7 @@ import ( "strings" "github.com/danwakefield/fnmatch" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/google/shlex" "github.com/mattn/go-runewidth" diff --git a/widgets/selector.go b/widgets/selector.go index d19d38f..196601b 100644 --- a/widgets/selector.go +++ b/widgets/selector.go @@ -1,7 +1,7 @@ package widgets import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "git.sr.ht/~sircmpwn/aerc/config" "git.sr.ht/~sircmpwn/aerc/lib/ui" diff --git a/widgets/spinner.go b/widgets/spinner.go index 0c72422..f49256a 100644 --- a/widgets/spinner.go +++ b/widgets/spinner.go @@ -5,7 +5,7 @@ import ( "sync/atomic" "time" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "git.sr.ht/~sircmpwn/aerc/config" "git.sr.ht/~sircmpwn/aerc/lib/ui" diff --git a/widgets/status.go b/widgets/status.go index 122ca5f..dfad08c 100644 --- a/widgets/status.go +++ b/widgets/status.go @@ -3,7 +3,7 @@ package widgets import ( "time" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/mattn/go-runewidth" "git.sr.ht/~sircmpwn/aerc/config" diff --git a/widgets/terminal.go b/widgets/terminal.go index 77da71e..e83c812 100644 --- a/widgets/terminal.go +++ b/widgets/terminal.go @@ -10,7 +10,7 @@ import ( "github.com/creack/pty" "github.com/ddevault/go-libvterm" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) type vtermKey struct { @@ -406,7 +406,7 @@ func (term *Terminal) styleFromCell(cell *vterm.ScreenCell) tcell.Style { if background.IsDefaultBg() { bg = tcell.ColorDefault } else if background.IsIndexed() { - bg = tcell.Color(background.GetIndex()) + bg = tcell.Color(tcell.PaletteColor(int(background.GetIndex()))) } else if background.IsRgb() { r, g, b := background.GetRGB() bg = tcell.NewRGBColor(int32(r), int32(g), int32(b)) @@ -414,7 +414,7 @@ func (term *Terminal) styleFromCell(cell *vterm.ScreenCell) tcell.Style { if foreground.IsDefaultFg() { fg = tcell.ColorDefault } else if foreground.IsIndexed() { - fg = tcell.Color(foreground.GetIndex()) + fg = tcell.Color(tcell.PaletteColor(int(foreground.GetIndex()))) } else if foreground.IsRgb() { r, g, b := foreground.GetRGB() fg = tcell.NewRGBColor(int32(r), int32(g), int32(b))