From e4d167311d7708471e449a05b3d1c9dfb061abfc Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 18 Oct 2020 14:15:57 +0200 Subject: [PATCH] Upgraded to latest tcell version. Results in a minor incompatibility in the Table class. --- README.md | 10 ++++++- application.go | 2 +- box.go | 38 +++++++++++++-------------- button.go | 12 ++++----- checkbox.go | 2 +- demos/box/main.go | 2 +- demos/frame/main.go | 2 +- demos/inputfield/autocomplete.go | 2 +- demos/inputfield/autocompleteasync.go | 2 +- demos/inputfield/main.go | 2 +- demos/presentation/colors.go | 2 +- demos/presentation/cover.go | 2 +- demos/presentation/end.go | 2 +- demos/presentation/flex.go | 2 +- demos/presentation/grid.go | 2 +- demos/presentation/helloworld.go | 2 +- demos/presentation/inputfield.go | 4 +-- demos/presentation/main.go | 2 +- demos/presentation/table.go | 2 +- demos/presentation/textview.go | 4 +-- demos/presentation/treeview.go | 2 +- demos/primitive/main.go | 2 +- demos/table/main.go | 2 +- demos/textview/main.go | 2 +- demos/treeview/main.go | 2 +- dropdown.go | 2 +- flex.go | 2 +- form.go | 2 +- frame.go | 2 +- go.mod | 6 ++--- go.sum | 21 +++++++-------- grid.go | 2 +- inputfield.go | 2 +- list.go | 2 +- modal.go | 2 +- pages.go | 2 +- primitive.go | 2 +- semigraphics.go | 2 +- styles.go | 2 +- table.go | 16 +++++------ textview.go | 2 +- treeview.go | 2 +- util.go | 2 +- 43 files changed, 92 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index 9375a87..65c6547 100644 --- a/README.md +++ b/README.md @@ -86,12 +86,20 @@ For a presentation highlighting this package, compile and run the program found ## Documentation -Refer to https://pkg.go.dev/github.com/rivo/tview for the package's documentation. +Refer to https://pkg.go.dev/github.com/rivo/tview for the package's documentation. Also check out the [Wiki](https://github.com/rivo/tview/wiki). ## Dependencies This package is based on [github.com/gdamore/tcell](https://github.com/gdamore/tcell) (and its dependencies) as well as on [github.com/rivo/uniseg](https://github.com/rivo/uniseg). +## Versioning and Backwards-Compatibility + +I try really hard to keep this project backwards compatible. Your software should not break when you upgrade `tview`. But this also means that some of its shortcomings that were present in the initial versions will remain. In addition, at least for the time being, you won't find any version tags in this repo. The newest version shoud be the one to upgrade to. It has all the bugfixes and latest features. Having said that, backwards compatibility may still break when: + +- a new version of an imported package (most likely [`tcell`](https://github.com/gdamore/tcell)) changes in such a way that forces me to make changes in `tview` as well, +- I fix something that I consider a bug, rather than a feature, something that does not work as originally intended, +- I make changes to "internal" interfaces such as [`Primitive`](https://pkg.go.dev/github.com/rivo/tview#Primitive) or [`Focusable`](https://pkg.go.dev/github.com/rivo/tview#Focusable). You shouldn't need these interfaces unless you're writing your own primitives for `tview`. + ## Your Feedback Add your issue here on GitHub. Feel free to get in touch if you have any questions. diff --git a/application.go b/application.go index cd504d6..03a6f28 100644 --- a/application.go +++ b/application.go @@ -4,7 +4,7 @@ import ( "sync" "time" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) const ( diff --git a/box.go b/box.go index 6cc34b7..2193c00 100644 --- a/box.go +++ b/box.go @@ -1,7 +1,7 @@ package tview import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // Box implements the Primitive interface with an empty background and optional @@ -30,11 +30,8 @@ type Box struct { // two in width and height. border bool - // The color of the border. - borderColor tcell.Color - - // The style attributes of the border. - borderAttributes tcell.AttrMask + // The border style. + borderStyle tcell.Style // The title. Only visible if there is a border, too. title string @@ -73,7 +70,7 @@ func NewBox() *Box { height: 10, innerX: -1, // Mark as uninitialized. backgroundColor: Styles.PrimitiveBackgroundColor, - borderColor: Styles.BorderColor, + borderStyle: tcell.StyleDefault.Foreground(Styles.BorderColor), titleColor: Styles.TitleColor, titleAlign: AlignCenter, } @@ -267,7 +264,7 @@ func (b *Box) SetBorder(show bool) *Box { // SetBorderColor sets the box's border color. func (b *Box) SetBorderColor(color tcell.Color) *Box { - b.borderColor = color + b.borderStyle = b.borderStyle.Foreground(color) return b } @@ -276,18 +273,20 @@ func (b *Box) SetBorderColor(color tcell.Color) *Box { // // box.SetBorderAttributes(tcell.AttrUnderline | tcell.AttrBold) func (b *Box) SetBorderAttributes(attr tcell.AttrMask) *Box { - b.borderAttributes = attr + b.borderStyle = b.borderStyle.Attributes(attr) return b } // GetBorderAttributes returns the border's style attributes. func (b *Box) GetBorderAttributes() tcell.AttrMask { - return b.borderAttributes + _, _, attr := b.borderStyle.Decompose() + return attr } // GetBorderColor returns the box's border color. func (b *Box) GetBorderColor() tcell.Color { - return b.borderColor + color, _, _ := b.borderStyle.Decompose() + return color } // GetBackgroundColor returns the box's background color. @@ -340,7 +339,6 @@ func (b *Box) Draw(screen tcell.Screen) { // Draw border. if b.border && b.width >= 2 && b.height >= 2 { - border := background.Foreground(b.borderColor) | tcell.Style(b.borderAttributes) var vertical, horizontal, topLeft, topRight, bottomLeft, bottomRight rune if b.focus.HasFocus() { horizontal = Borders.HorizontalFocus @@ -358,17 +356,17 @@ func (b *Box) Draw(screen tcell.Screen) { bottomRight = Borders.BottomRight } for x := b.x + 1; x < b.x+b.width-1; x++ { - screen.SetContent(x, b.y, horizontal, nil, border) - screen.SetContent(x, b.y+b.height-1, horizontal, nil, border) + screen.SetContent(x, b.y, horizontal, nil, b.borderStyle) + screen.SetContent(x, b.y+b.height-1, horizontal, nil, b.borderStyle) } for y := b.y + 1; y < b.y+b.height-1; y++ { - screen.SetContent(b.x, y, vertical, nil, border) - screen.SetContent(b.x+b.width-1, y, vertical, nil, border) + screen.SetContent(b.x, y, vertical, nil, b.borderStyle) + screen.SetContent(b.x+b.width-1, y, vertical, nil, b.borderStyle) } - screen.SetContent(b.x, b.y, topLeft, nil, border) - screen.SetContent(b.x+b.width-1, b.y, topRight, nil, border) - screen.SetContent(b.x, b.y+b.height-1, bottomLeft, nil, border) - screen.SetContent(b.x+b.width-1, b.y+b.height-1, bottomRight, nil, border) + screen.SetContent(b.x, b.y, topLeft, nil, b.borderStyle) + screen.SetContent(b.x+b.width-1, b.y, topRight, nil, b.borderStyle) + screen.SetContent(b.x, b.y+b.height-1, bottomLeft, nil, b.borderStyle) + screen.SetContent(b.x+b.width-1, b.y+b.height-1, bottomRight, nil, b.borderStyle) // Draw title. if b.title != "" && b.width >= 4 { diff --git a/button.go b/button.go index fd7c234..0e499a4 100644 --- a/button.go +++ b/button.go @@ -1,7 +1,7 @@ package tview import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // Button is labeled box that triggers an action when selected. @@ -95,13 +95,13 @@ func (b *Button) SetBlurFunc(handler func(key tcell.Key)) *Button { // Draw draws this primitive onto the screen. func (b *Button) Draw(screen tcell.Screen) { // Draw the box. - borderColor := b.borderColor - backgroundColor := b.backgroundColor + borderColor := b.GetBorderColor() + backgroundColor := b.GetBackgroundColor() if b.focus.HasFocus() { - b.backgroundColor = b.backgroundColorActivated - b.borderColor = b.labelColorActivated + b.SetBackgroundColor(b.backgroundColorActivated) + b.SetBorderColor(b.labelColorActivated) defer func() { - b.borderColor = borderColor + b.SetBorderColor(borderColor) }() } b.Box.Draw(screen) diff --git a/checkbox.go b/checkbox.go index 7c4b505..3d20f8c 100644 --- a/checkbox.go +++ b/checkbox.go @@ -1,7 +1,7 @@ package tview import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // Checkbox implements a simple box for boolean values which can be checked and diff --git a/demos/box/main.go b/demos/box/main.go index 8f4ec19..9de4b8d 100644 --- a/demos/box/main.go +++ b/demos/box/main.go @@ -2,7 +2,7 @@ package main import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/frame/main.go b/demos/frame/main.go index db6e184..eb32179 100644 --- a/demos/frame/main.go +++ b/demos/frame/main.go @@ -2,7 +2,7 @@ package main import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/inputfield/autocomplete.go b/demos/inputfield/autocomplete.go index 3437112..7459369 100644 --- a/demos/inputfield/autocomplete.go +++ b/demos/inputfield/autocomplete.go @@ -3,7 +3,7 @@ package main import ( "strings" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/inputfield/autocompleteasync.go b/demos/inputfield/autocompleteasync.go index 9831c03..0cfe75c 100644 --- a/demos/inputfield/autocompleteasync.go +++ b/demos/inputfield/autocompleteasync.go @@ -7,7 +7,7 @@ import ( "strings" "sync" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/inputfield/main.go b/demos/inputfield/main.go index 923bf2d..1666ac8 100644 --- a/demos/inputfield/main.go +++ b/demos/inputfield/main.go @@ -2,7 +2,7 @@ package main import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/presentation/colors.go b/demos/presentation/colors.go index 8e4bc48..3b0ae81 100644 --- a/demos/presentation/colors.go +++ b/demos/presentation/colors.go @@ -3,7 +3,7 @@ package main import ( "strings" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/presentation/cover.go b/demos/presentation/cover.go index 6027561..eaeea9d 100644 --- a/demos/presentation/cover.go +++ b/demos/presentation/cover.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/presentation/end.go b/demos/presentation/end.go index 119b676..c085b31 100644 --- a/demos/presentation/end.go +++ b/demos/presentation/end.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/presentation/flex.go b/demos/presentation/flex.go index c9c75a6..2e8e5dd 100644 --- a/demos/presentation/flex.go +++ b/demos/presentation/flex.go @@ -1,7 +1,7 @@ package main import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/presentation/grid.go b/demos/presentation/grid.go index 3a04d14..38d325e 100644 --- a/demos/presentation/grid.go +++ b/demos/presentation/grid.go @@ -1,7 +1,7 @@ package main import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/presentation/helloworld.go b/demos/presentation/helloworld.go index f312a79..86fb527 100644 --- a/demos/presentation/helloworld.go +++ b/demos/presentation/helloworld.go @@ -1,7 +1,7 @@ package main import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/presentation/inputfield.go b/demos/presentation/inputfield.go index 9700041..dde6d4f 100644 --- a/demos/presentation/inputfield.go +++ b/demos/presentation/inputfield.go @@ -1,7 +1,7 @@ package main import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) @@ -10,7 +10,7 @@ const inputField = `[green]package[white] main [green]import[white] ( [red]"strconv"[white] - [red]"github.com/gdamore/tcell"[white] + [red]"github.com/gdamore/tcell/v2"[white] [red]"github.com/rivo/tview"[white] ) diff --git a/demos/presentation/main.go b/demos/presentation/main.go index 2510830..42172cb 100644 --- a/demos/presentation/main.go +++ b/demos/presentation/main.go @@ -16,7 +16,7 @@ import ( "fmt" "strconv" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/presentation/table.go b/demos/presentation/table.go index 798c11c..36600b9 100644 --- a/demos/presentation/table.go +++ b/demos/presentation/table.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/presentation/textview.go b/demos/presentation/textview.go index 244de80..5c6f282 100644 --- a/demos/presentation/textview.go +++ b/demos/presentation/textview.go @@ -5,7 +5,7 @@ import ( "strconv" "time" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) @@ -68,7 +68,7 @@ const textView2 = `[green]package[white] main [green]import[white] ( [red]"strconv"[white] - [red]"github.com/gdamore/tcell"[white] + [red]"github.com/gdamore/tcell/v2"[white] [red]"github.com/rivo/tview"[white] ) diff --git a/demos/presentation/treeview.go b/demos/presentation/treeview.go index 68349cd..0dd8b86 100644 --- a/demos/presentation/treeview.go +++ b/demos/presentation/treeview.go @@ -3,7 +3,7 @@ package main import ( "strings" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/primitive/main.go b/demos/primitive/main.go index e2d911a..a98172b 100644 --- a/demos/primitive/main.go +++ b/demos/primitive/main.go @@ -4,7 +4,7 @@ package main import ( "fmt" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/table/main.go b/demos/table/main.go index 906ed56..e67a83d 100644 --- a/demos/table/main.go +++ b/demos/table/main.go @@ -4,7 +4,7 @@ package main import ( "strings" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/textview/main.go b/demos/textview/main.go index 701a9c1..1235a83 100644 --- a/demos/textview/main.go +++ b/demos/textview/main.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/demos/treeview/main.go b/demos/treeview/main.go index 5a6805d..ee81d4a 100644 --- a/demos/treeview/main.go +++ b/demos/treeview/main.go @@ -5,7 +5,7 @@ import ( "io/ioutil" "path/filepath" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) diff --git a/dropdown.go b/dropdown.go index 4e54e4b..360e12b 100644 --- a/dropdown.go +++ b/dropdown.go @@ -3,7 +3,7 @@ package tview import ( "strings" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // dropDownOption is one option that can be selected in a drop-down primitive. diff --git a/flex.go b/flex.go index 20e26a5..fda3f70 100644 --- a/flex.go +++ b/flex.go @@ -1,7 +1,7 @@ package tview import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // Configuration values. diff --git a/form.go b/form.go index 71b26c3..b576b91 100644 --- a/form.go +++ b/form.go @@ -1,7 +1,7 @@ package tview import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // DefaultFormFieldWidth is the default field screen width of form elements diff --git a/frame.go b/frame.go index eb8c900..7beddc8 100644 --- a/frame.go +++ b/frame.go @@ -1,7 +1,7 @@ package tview import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // frameText holds information about a line of text shown in the frame. diff --git a/go.mod b/go.mod index dc77408..af11394 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module github.com/rivo/tview go 1.12 require ( - github.com/gdamore/tcell v1.3.0 + github.com/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591 github.com/lucasb-eyer/go-colorful v1.0.3 github.com/mattn/go-runewidth v0.0.9 github.com/rivo/uniseg v0.1.0 - golang.org/x/sys v0.0.0-20200817155316-9781c653f443 // indirect - golang.org/x/text v0.3.2 // indirect + golang.org/x/sys v0.0.0-20201017003518-b09fb700fbb7 // indirect + golang.org/x/text v0.3.3 // indirect ) diff --git a/go.sum b/go.sum index 7566d43..9417892 100644 --- a/go.sum +++ b/go.sum @@ -1,25 +1,22 @@ -github.com/DATA-DOG/go-sqlmock v1.3.3 h1:CWUqKXe0s8A2z6qCgkP4Kru7wC11YoAnoupUKFDnH08= -github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= 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 v1.3.0 h1:r35w0JBADPZCVQijYebl6YMWWtHRqVEGt7kL2eBADRM= -github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= -github.com/lucasb-eyer/go-colorful v1.0.2 h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09mS6CXfO4= -github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s= +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/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591 h1:0WWUDZ1oxq7NxVyGo8M3KI5jbkiwNAdZFFzAdC68up4= +github.com/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA= 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/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/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10= golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200817155316-9781c653f443 h1:X18bCaipMcoJGm27Nv7zr4XYPKGUy92GtqboKC2Hxaw= -golang.org/x/sys v0.0.0-20200817155316-9781c653f443/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201017003518-b09fb700fbb7 h1:XtNJkfEjb4zR3q20BBBcYUykVOEMgZeIUOpBPfNYgxg= +golang.org/x/sys v0.0.0-20201017003518-b09fb700fbb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/grid.go b/grid.go index 8066384..718c9e0 100644 --- a/grid.go +++ b/grid.go @@ -3,7 +3,7 @@ package tview import ( "math" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // gridItem represents one primitive and its possible position on a grid. diff --git a/inputfield.go b/inputfield.go index 82e54c8..68db2ee 100644 --- a/inputfield.go +++ b/inputfield.go @@ -7,7 +7,7 @@ import ( "sync" "unicode/utf8" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // InputField is a one-line box (three lines if there is a title) where the diff --git a/list.go b/list.go index 692eb11..74e2c79 100644 --- a/list.go +++ b/list.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // listItem represents one item in a List. diff --git a/modal.go b/modal.go index 2d557f0..5df65aa 100644 --- a/modal.go +++ b/modal.go @@ -1,7 +1,7 @@ package tview import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // Modal is a centered message window used to inform the user or prompt them diff --git a/pages.go b/pages.go index 0ce9656..b9010d2 100644 --- a/pages.go +++ b/pages.go @@ -1,7 +1,7 @@ package tview import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // page represents one page of a Pages object. diff --git a/primitive.go b/primitive.go index 416d708..30c82e9 100644 --- a/primitive.go +++ b/primitive.go @@ -1,6 +1,6 @@ package tview -import "github.com/gdamore/tcell" +import "github.com/gdamore/tcell/v2" // Primitive is the top-most interface for all graphical primitives. type Primitive interface { diff --git a/semigraphics.go b/semigraphics.go index 3b66c5f..1815bfa 100644 --- a/semigraphics.go +++ b/semigraphics.go @@ -1,6 +1,6 @@ package tview -import "github.com/gdamore/tcell" +import "github.com/gdamore/tcell/v2" // Semigraphics provides an easy way to access unicode characters for drawing. // diff --git a/styles.go b/styles.go index 4f0448f..16f1fef 100644 --- a/styles.go +++ b/styles.go @@ -1,6 +1,6 @@ package tview -import "github.com/gdamore/tcell" +import "github.com/gdamore/tcell/v2" // Theme defines the colors used when primitives are initialized. type Theme struct { diff --git a/table.go b/table.go index 5d06466..4b509b5 100644 --- a/table.go +++ b/table.go @@ -3,7 +3,7 @@ package tview import ( "sort" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" colorful "github.com/lucasb-eyer/go-colorful" ) @@ -271,8 +271,8 @@ type Table struct { // drawn. visibleColumnWidths []int - // The style of the selected rows. If this value is 0, selected rows are - // simply inverted. + // The style of the selected rows. If this value is the empty struct, + // selected rows are simply inverted. selectedStyle tcell.Style // An optional function which gets called when the user presses Enter on a @@ -327,8 +327,8 @@ func (t *Table) SetBordersColor(color tcell.Color) *Table { // To reset a previous setting to its default, make the following call: // // table.SetSelectedStyle(tcell.ColorDefault, tcell.ColorDefault, 0) -func (t *Table) SetSelectedStyle(foregroundColor, backgroundColor tcell.Color, attributes tcell.AttrMask) *Table { - t.selectedStyle = tcell.StyleDefault.Foreground(foregroundColor).Background(backgroundColor) | tcell.Style(attributes) +func (t *Table) SetSelectedStyle(style tcell.Style) *Table { + t.selectedStyle = style return t } @@ -885,7 +885,7 @@ ColumnLoop: finalWidth = width - columnX - 1 } cell.x, cell.y, cell.width = x+columnX+1, y+rowY, finalWidth - _, printed := printWithStyle(screen, cell.Text, x+columnX+1, y+rowY, finalWidth, cell.Align, tcell.StyleDefault.Foreground(cell.Color)|tcell.Style(cell.Attributes)) + _, printed := printWithStyle(screen, cell.Text, x+columnX+1, y+rowY, finalWidth, cell.Align, tcell.StyleDefault.Foreground(cell.Color).Attributes(cell.Attributes)) if TaggedStringWidth(cell.Text)-printed > 0 && printed > 0 { _, _, style, _ := screen.GetContent(x+columnX+finalWidth, y+rowY) printWithStyle(screen, string(SemigraphicsHorizontalEllipsis), x+columnX+finalWidth, y+rowY, 1, AlignLeft, style) @@ -954,7 +954,7 @@ ColumnLoop: if attr != 0 { a = attr } - style = style.Background(bg).Foreground(fg) | tcell.Style(a) + style = style.Background(bg).Foreground(fg).Attributes(a) } screen.SetContent(fromX+bx, fromY+by, m, c, style) } @@ -1017,7 +1017,7 @@ ColumnLoop: entries := cellsByBackgroundColor[bgColor] for _, cell := range entries { if cell.selected { - if t.selectedStyle != 0 { + if t.selectedStyle != (tcell.Style{}) { defer colorBackground(cell.x, cell.y, cell.w, cell.h, selBg, selFg, selAttr, false) } else { defer colorBackground(cell.x, cell.y, cell.w, cell.h, bgColor, cell.text, 0, true) diff --git a/textview.go b/textview.go index 585cbd9..e4f2a84 100644 --- a/textview.go +++ b/textview.go @@ -8,7 +8,7 @@ import ( "sync" "unicode/utf8" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" colorful "github.com/lucasb-eyer/go-colorful" runewidth "github.com/mattn/go-runewidth" "github.com/rivo/uniseg" diff --git a/treeview.go b/treeview.go index ea4585a..800f5cc 100644 --- a/treeview.go +++ b/treeview.go @@ -1,7 +1,7 @@ package tview import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" ) // Tree navigation events. diff --git a/util.go b/util.go index 5ddad6b..2e19160 100644 --- a/util.go +++ b/util.go @@ -6,7 +6,7 @@ import ( "sort" "strconv" - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" runewidth "github.com/mattn/go-runewidth" "github.com/rivo/uniseg" )