Browse Source

Upgrade tcell to v2

Resolves #32.
tablepad
Trevor Slocum 10 months ago
parent
commit
8292f9baf2
46 changed files with 141 additions and 142 deletions
  1. +1
    -0
      CHANGELOG
  2. +1
    -1
      application.go
  3. +2
    -2
      box.go
  4. +1
    -1
      button.go
  5. +1
    -1
      checkbox.go
  6. +1
    -1
      demos/box/main.go
  7. +8
    -8
      demos/frame/main.go
  8. +1
    -1
      demos/inputfield/autocomplete/main.go
  9. +1
    -1
      demos/inputfield/autocompleteasync/main.go
  10. +1
    -1
      demos/inputfield/simple/main.go
  11. +1
    -1
      demos/presentation/colors.go
  12. +6
    -6
      demos/presentation/cover.go
  13. +1
    -1
      demos/presentation/end.go
  14. +1
    -1
      demos/presentation/flex.go
  15. +1
    -1
      demos/presentation/grid.go
  16. +1
    -1
      demos/presentation/inputfield.go
  17. +1
    -1
      demos/presentation/main.go
  18. +22
    -22
      demos/presentation/table.go
  19. +3
    -3
      demos/presentation/textview.go
  20. +3
    -3
      demos/presentation/treeview.go
  21. +2
    -2
      demos/primitive/main.go
  22. +4
    -4
      demos/table/main.go
  23. +1
    -1
      demos/textview/main.go
  24. +3
    -3
      demos/treeview/main.go
  25. +1
    -1
      doc_test.go
  26. +1
    -1
      dropdown.go
  27. +1
    -1
      flex.go
  28. +1
    -1
      form.go
  29. +1
    -1
      frame.go
  30. +3
    -4
      go.mod
  31. +9
    -21
      go.sum
  32. +1
    -1
      grid.go
  33. +1
    -1
      inputfield.go
  34. +1
    -1
      keys.go
  35. +4
    -4
      list.go
  36. +1
    -1
      modal.go
  37. +1
    -1
      pages.go
  38. +1
    -1
      primitive.go
  39. +1
    -1
      progressbar.go
  40. +1
    -1
      semigraphics.go
  41. +17
    -17
      styles.go
  42. +7
    -7
      table.go
  43. +3
    -3
      textview.go
  44. +2
    -2
      treeview.go
  45. +14
    -3
      util.go
  46. +1
    -1
      util_test.go

+ 1
- 0
CHANGELOG View File

@ -1,5 +1,6 @@
v1.4.9 (WIP)
- Add InputField.GetCursorPosition and InputField.SetCursorPosition
- Upgrade tcell to v2
v1.4.8 (2020-08-11)
- Add italic text formatting flag


+ 1
- 1
application.go View File

@ -5,7 +5,7 @@ import (
"sync"
"time"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
const (


+ 2
- 2
box.go View File

@ -3,7 +3,7 @@ package cview
import (
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// Box is the base Primitive for all widgets. It has a background color and
@ -397,7 +397,7 @@ 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)
border := SetAttributes(background.Foreground(b.borderColor), b.borderAttributes)
var vertical, horizontal, topLeft, topRight, bottomLeft, bottomRight rune
var hasFocus bool


+ 1
- 1
button.go View File

@ -3,7 +3,7 @@ package cview
import (
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// Button is labeled box that triggers an action when selected.


+ 1
- 1
checkbox.go View File

@ -3,7 +3,7 @@ package cview
import (
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// CheckBox implements a simple box for boolean values which can be checked and


+ 1
- 1
demos/box/main.go View File

@ -2,7 +2,7 @@
package main
import (
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)


+ 8
- 8
demos/frame/main.go View File

@ -2,20 +2,20 @@
package main
import (
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)
func main() {
app := cview.NewApplication()
frame := cview.NewFrame(cview.NewBox().SetBackgroundColor(tcell.ColorBlue)).
frame := cview.NewFrame(cview.NewBox().SetBackgroundColor(tcell.ColorBlue.TrueColor())).
SetBorders(2, 2, 2, 2, 4, 4).
AddText("Header left", true, cview.AlignLeft, tcell.ColorWhite).
AddText("Header middle", true, cview.AlignCenter, tcell.ColorWhite).
AddText("Header right", true, cview.AlignRight, tcell.ColorWhite).
AddText("Header second middle", true, cview.AlignCenter, tcell.ColorRed).
AddText("Footer middle", false, cview.AlignCenter, tcell.ColorGreen).
AddText("Footer second middle", false, cview.AlignCenter, tcell.ColorGreen)
AddText("Header left", true, cview.AlignLeft, tcell.ColorWhite.TrueColor()).
AddText("Header middle", true, cview.AlignCenter, tcell.ColorWhite.TrueColor()).
AddText("Header right", true, cview.AlignRight, tcell.ColorWhite.TrueColor()).
AddText("Header second middle", true, cview.AlignCenter, tcell.ColorRed.TrueColor()).
AddText("Footer middle", false, cview.AlignCenter, tcell.ColorGreen.TrueColor()).
AddText("Footer second middle", false, cview.AlignCenter, tcell.ColorGreen.TrueColor())
if err := app.SetRoot(frame, true).EnableMouse(true).Run(); err != nil {
panic(err)
}


+ 1
- 1
demos/inputfield/autocomplete/main.go View File

@ -3,7 +3,7 @@ package main
import (
"strings"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)


+ 1
- 1
demos/inputfield/autocompleteasync/main.go View File

@ -7,7 +7,7 @@ import (
"strings"
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)


+ 1
- 1
demos/inputfield/simple/main.go View File

@ -2,7 +2,7 @@
package main
import (
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)


+ 1
- 1
demos/presentation/colors.go View File

@ -1,7 +1,7 @@
package main
import (
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)


+ 6
- 6
demos/presentation/cover.go View File

@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)
@ -34,7 +34,7 @@ func Cover(nextSlide func()) (title string, content cview.Primitive) {
}
}
logoBox := cview.NewTextView().
SetTextColor(tcell.ColorGreen).
SetTextColor(tcell.ColorGreen.TrueColor()).
SetDoneFunc(func(key tcell.Key) {
nextSlide()
})
@ -43,10 +43,10 @@ func Cover(nextSlide func()) (title string, content cview.Primitive) {
// Create a frame for the subtitle and navigation infos.
frame := cview.NewFrame(cview.NewBox()).
SetBorders(0, 0, 0, 0, 0, 0).
AddText(subtitle, true, cview.AlignCenter, tcell.ColorWhite).
AddText("", true, cview.AlignCenter, tcell.ColorWhite).
AddText(mouse, true, cview.AlignCenter, tcell.ColorDarkMagenta).
AddText(navigation, true, cview.AlignCenter, tcell.ColorDarkMagenta)
AddText(subtitle, true, cview.AlignCenter, tcell.ColorWhite.TrueColor()).
AddText("", true, cview.AlignCenter, tcell.ColorWhite.TrueColor()).
AddText(mouse, true, cview.AlignCenter, tcell.ColorDarkMagenta.TrueColor()).
AddText(navigation, true, cview.AlignCenter, tcell.ColorDarkMagenta.TrueColor())
// Create a Flex layout that centers the logo and subtitle.
flex := cview.NewFlex().


+ 1
- 1
demos/presentation/end.go View File

@ -3,7 +3,7 @@ package main
import (
"fmt"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)


+ 1
- 1
demos/presentation/flex.go View File

@ -1,7 +1,7 @@
package main
import (
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)


+ 1
- 1
demos/presentation/grid.go View File

@ -1,7 +1,7 @@
package main
import (
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)


+ 1
- 1
demos/presentation/inputfield.go View File

@ -1,7 +1,7 @@
package main
import (
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)


+ 1
- 1
demos/presentation/main.go View File

@ -20,7 +20,7 @@ import (
_ "net/http/pprof"
"strconv"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)


+ 22
- 22
demos/presentation/table.go View File

@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)
@ -58,11 +58,11 @@ const tableBasic = `[green]func[white] [yellow]main[white]() {
[yellow]SetFixed[white]([red]1[white], [red]1[white])
[yellow]for[white] row := [red]0[white]; row < [red]40[white]; row++ {
[yellow]for[white] column := [red]0[white]; column < [red]7[white]; column++ {
color := tcell.ColorWhite
color := tcell.ColorWhite.TrueColor()
[yellow]if[white] row == [red]0[white] {
color = tcell.ColorYellow
color = tcell.ColorYellow.TrueColor()
} [yellow]else[white] [yellow]if[white] column == [red]0[white] {
color = tcell.ColorDarkCyan
color = tcell.ColorDarkCyan.TrueColor()
}
align := cview.AlignLeft
[yellow]if[white] row == [red]0[white] {
@ -90,11 +90,11 @@ const tableSeparator = `[green]func[white] [yellow]main[white]() {
[yellow]SetSeparator[white](Borders.Vertical)
[yellow]for[white] row := [red]0[white]; row < [red]40[white]; row++ {
[yellow]for[white] column := [red]0[white]; column < [red]7[white]; column++ {
color := tcell.ColorWhite
color := tcell.ColorWhite.TrueColor()
[yellow]if[white] row == [red]0[white] {
color = tcell.ColorYellow
color = tcell.ColorYellow.TrueColor()
} [yellow]else[white] [yellow]if[white] column == [red]0[white] {
color = tcell.ColorDarkCyan
color = tcell.ColorDarkCyan.TrueColor()
}
align := cview.AlignLeft
[yellow]if[white] row == [red]0[white] {
@ -122,11 +122,11 @@ const tableBorders = `[green]func[white] [yellow]main[white]() {
[yellow]SetBorders[white](true)
[yellow]for[white] row := [red]0[white]; row < [red]40[white]; row++ {
[yellow]for[white] column := [red]0[white]; column < [red]7[white]; column++ {
color := tcell.ColorWhite
color := tcell.ColorWhite.TrueColor()
[yellow]if[white] row == [red]0[white] {
color = tcell.ColorYellow
color = tcell.ColorYellow.TrueColor()
} [yellow]else[white] [yellow]if[white] column == [red]0[white] {
color = tcell.ColorDarkCyan
color = tcell.ColorDarkCyan.TrueColor()
}
align := cview.AlignLeft
[yellow]if[white] row == [red]0[white] {
@ -154,11 +154,11 @@ const tableSelectRow = `[green]func[white] [yellow]main[white]() {
[yellow]SetSelectable[white](true, false)
[yellow]for[white] row := [red]0[white]; row < [red]40[white]; row++ {
[yellow]for[white] column := [red]0[white]; column < [red]7[white]; column++ {
color := tcell.ColorWhite
color := tcell.ColorWhite.TrueColor()
[yellow]if[white] row == [red]0[white] {
color = tcell.ColorYellow
color = tcell.ColorYellow.TrueColor()
} [yellow]else[white] [yellow]if[white] column == [red]0[white] {
color = tcell.ColorDarkCyan
color = tcell.ColorDarkCyan.TrueColor()
}
align := cview.AlignLeft
[yellow]if[white] row == [red]0[white] {
@ -187,11 +187,11 @@ const tableSelectColumn = `[green]func[white] [yellow]main[white]() {
[yellow]SetSelectable[white](false, true)
[yellow]for[white] row := [red]0[white]; row < [red]40[white]; row++ {
[yellow]for[white] column := [red]0[white]; column < [red]7[white]; column++ {
color := tcell.ColorWhite
color := tcell.ColorWhite.TrueColor()
[yellow]if[white] row == [red]0[white] {
color = tcell.ColorYellow
color = tcell.ColorYellow.TrueColor()
} [yellow]else[white] [yellow]if[white] column == [red]0[white] {
color = tcell.ColorDarkCyan
color = tcell.ColorDarkCyan.TrueColor()
}
align := cview.AlignLeft
[yellow]if[white] row == [red]0[white] {
@ -220,11 +220,11 @@ const tableSelectCell = `[green]func[white] [yellow]main[white]() {
[yellow]SetSelectable[white](true, true)
[yellow]for[white] row := [red]0[white]; row < [red]40[white]; row++ {
[yellow]for[white] column := [red]0[white]; column < [red]7[white]; column++ {
color := tcell.ColorWhite
color := tcell.ColorWhite.TrueColor()
[yellow]if[white] row == [red]0[white] {
color = tcell.ColorYellow
color = tcell.ColorYellow.TrueColor()
} [yellow]else[white] [yellow]if[white] column == [red]0[white] {
color = tcell.ColorDarkCyan
color = tcell.ColorDarkCyan.TrueColor()
}
align := cview.AlignLeft
[yellow]if[white] row == [red]0[white] {
@ -253,11 +253,11 @@ func Table(nextSlide func()) (title string, content cview.Primitive) {
SetFixed(1, 1)
for row, line := range strings.Split(tableData, "\n") {
for column, cell := range strings.Split(line, "|") {
color := tcell.ColorWhite
color := tcell.ColorWhite.TrueColor()
if row == 0 {
color = tcell.ColorYellow
color = tcell.ColorYellow.TrueColor()
} else if column == 0 {
color = tcell.ColorDarkCyan
color = tcell.ColorDarkCyan.TrueColor()
}
align := cview.AlignLeft
if row == 0 {


+ 3
- 3
demos/presentation/textview.go View File

@ -5,14 +5,14 @@ import (
"strconv"
"time"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)
const textView1 = `[green]func[white] [yellow]main[white]() {
app := cview.[yellow]NewApplication[white]()
textView := cview.[yellow]NewTextView[white]().
[yellow]SetTextColor[white](tcell.ColorYellow).
[yellow]SetTextColor[white](tcell.ColorYellow.TrueColor()).
[yellow]SetScrollable[white](false).
[yellow]SetChangedFunc[white]([yellow]func[white]() {
app.[yellow]Draw[white]()
@ -32,7 +32,7 @@ const textView1 = `[green]func[white] [yellow]main[white]() {
// TextView1 demonstrates the basic text view.
func TextView1(nextSlide func()) (title string, content cview.Primitive) {
textView := cview.NewTextView().
SetTextColor(tcell.ColorYellow).
SetTextColor(tcell.ColorYellow.TrueColor()).
SetScrollable(false).
SetDoneFunc(func(key tcell.Key) {
nextSlide()


+ 3
- 3
demos/presentation/treeview.go View File

@ -3,7 +3,7 @@ package main
import (
"strings"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)
@ -119,9 +119,9 @@ func TreeView(nextSlide func()) (title string, content cview.Primitive) {
SetExpanded(target == rootNode).
SetReference(target)
if target.expand {
node.SetColor(tcell.ColorGreen)
node.SetColor(tcell.ColorGreen.TrueColor())
} else if target.selected != nil {
node.SetColor(tcell.ColorRed)
node.SetColor(tcell.ColorRed.TrueColor())
}
for _, child := range target.children {
node.AddChild(add(child))


+ 2
- 2
demos/primitive/main.go View File

@ -4,7 +4,7 @@ package main
import (
"fmt"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)
@ -37,7 +37,7 @@ func (r *RadioButtons) Draw(screen tcell.Screen) {
radioButton = "\u25c9" // Checked.
}
line := fmt.Sprintf(`%s[white] %s`, radioButton, option)
cview.Print(screen, line, x, y+index, width, cview.AlignLeft, tcell.ColorYellow)
cview.Print(screen, line, x, y+index, width, cview.AlignLeft, tcell.ColorYellow.TrueColor())
}
}


+ 4
- 4
demos/table/main.go View File

@ -4,7 +4,7 @@ package main
import (
"strings"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)
@ -17,9 +17,9 @@ func main() {
word := 0
for r := 0; r < rows; r++ {
for c := 0; c < cols; c++ {
color := tcell.ColorWhite
color := tcell.ColorWhite.TrueColor()
if c < 1 || r < 1 {
color = tcell.ColorYellow
color = tcell.ColorYellow.TrueColor()
}
table.SetCell(r, c,
cview.NewTableCell(lorem[word]).
@ -36,7 +36,7 @@ func main() {
table.SetSelectable(true, true)
}
}).SetSelectedFunc(func(row int, column int) {
table.GetCell(row, column).SetTextColor(tcell.ColorRed)
table.GetCell(row, column).SetTextColor(tcell.ColorRed.TrueColor())
table.SetSelectable(false, false)
})
if err := app.SetRoot(table, true).EnableMouse(true).Run(); err != nil {


+ 1
- 1
demos/textview/main.go View File

@ -7,7 +7,7 @@ import (
"strings"
"time"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)


+ 3
- 3
demos/treeview/main.go View File

@ -5,7 +5,7 @@ import (
"io/ioutil"
"path/filepath"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)
@ -13,7 +13,7 @@ import (
func main() {
rootDir := "."
root := cview.NewTreeNode(rootDir).
SetColor(tcell.ColorRed)
SetColor(tcell.ColorRed.TrueColor())
tree := cview.NewTreeView().
SetRoot(root).
SetCurrentNode(root)
@ -30,7 +30,7 @@ func main() {
SetReference(filepath.Join(path, file.Name())).
SetSelectable(file.IsDir())
if file.IsDir() {
node.SetColor(tcell.ColorGreen)
node.SetColor(tcell.ColorGreen.TrueColor())
}
target.AddChild(node)
}


+ 1
- 1
doc_test.go View File

@ -3,7 +3,7 @@ package cview
import (
"fmt"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// Example of an application with multiple layouts.


+ 1
- 1
dropdown.go View File

@ -4,7 +4,7 @@ import (
"strings"
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// dropDownOption is one option that can be selected in a drop-down primitive.


+ 1
- 1
flex.go View File

@ -3,7 +3,7 @@ package cview
import (
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// Configuration values.


+ 1
- 1
form.go View File

@ -3,7 +3,7 @@ package cview
import (
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// DefaultFormFieldWidth is the default field screen width of form elements


+ 1
- 1
frame.go View File

@ -3,7 +3,7 @@ package cview
import (
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// frameText holds information about a line of text shown in the frame.


+ 3
- 4
go.mod View File

@ -3,11 +3,10 @@ module gitlab.com/tslocum/cview
go 1.12
require (
github.com/gdamore/tcell v1.3.1-0.20200823221337-776d98d3850b
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200830100347-23606a43e286
github.com/lucasb-eyer/go-colorful v1.0.3
github.com/mattn/go-runewidth v0.0.9
github.com/rivo/uniseg v0.1.0
gitlab.com/tslocum/cbind v0.1.1
golang.org/x/sys v0.0.0-20200824131525-c12d262b63d8 // indirect
golang.org/x/text v0.3.3 // indirect
gitlab.com/tslocum/cbind v0.1.2-0.20200826214515-b5f2c6a8711a
golang.org/x/sys v0.0.0-20200828194041-157a740278f4 // indirect
)

+ 9
- 21
go.sum View File

@ -1,35 +1,23 @@
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/gdamore/tcell v1.3.1-0.20200823221337-776d98d3850b h1:i5YlGe2SivCwep7niKxoTEgya61QwQRtkv6vclekai8=
github.com/gdamore/tcell v1.3.1-0.20200823221337-776d98d3850b/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0=
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-dev/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200830100347-23606a43e286 h1:29adRtDgT5AaOR9RiDQaZeiY+lb8mbQwz9WklTK6EuQ=
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200830100347-23606a43e286/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.8/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=
gitlab.com/tslocum/cbind v0.1.1 h1:JXXtxMWHgWLvoF+QkrvcNvOQ59juy7OE1RhT7hZfdt0=
gitlab.com/tslocum/cbind v0.1.1/go.mod h1:rX7vkl0pUSg/yy427MmD1FZAf99S7WwpUlxF/qTpPqk=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10=
gitlab.com/tslocum/cbind v0.1.2-0.20200826214515-b5f2c6a8711a h1:6u2QDDcKdeFhyHT/srxPDzLfDJqwKTgy1v+3209LYBY=
gitlab.com/tslocum/cbind v0.1.2-0.20200826214515-b5f2c6a8711a/go.mod h1:HfB7qAhHSZbn1rFK8M9SvSN5NG6ScAg/3h3iE6xdeeI=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200824131525-c12d262b63d8 h1:AvbQYmiaaaza3cW3QXRyPo5kYgpFIzOAfeAAN7m3qQ4=
golang.org/x/sys v0.0.0-20200824131525-c12d262b63d8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6 h1:DvY3Zkh7KabQE/kfzMvYvKirSiguP9Q/veMtkYyf0o8=
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200828194041-157a740278f4 h1:kCCpuwSAoYJPkNc6x0xT9yTtV4oKtARo4RGBQWOfg9E=
golang.org/x/sys v0.0.0-20200828194041-157a740278f4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
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 h1:FDhOuMEY4JVRztM/gsbk+IKUQ8kj74bxZrgw87eMMVc=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

+ 1
- 1
grid.go View File

@ -4,7 +4,7 @@ import (
"math"
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// gridItem represents one primitive and its possible position on a grid.


+ 1
- 1
inputfield.go View File

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


+ 1
- 1
keys.go View File

@ -1,7 +1,7 @@
package cview
import (
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cbind"
)


+ 4
- 4
list.go View File

@ -5,7 +5,7 @@ import (
"strings"
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// listItem represents one item in a List.
@ -763,11 +763,11 @@ func (l *List) Draw(screen tcell.Screen) {
} else if !item.Enabled { // Disabled item
// Shortcuts.
if showShortcuts && item.Shortcut != 0 {
Print(screen, fmt.Sprintf("(%s)", string(item.Shortcut)), x-5, y, 4, AlignRight, tcell.ColorDarkSlateGray)
Print(screen, fmt.Sprintf("(%s)", string(item.Shortcut)), x-5, y, 4, AlignRight, tcell.ColorDarkSlateGray.TrueColor())
}
// Main text.
Print(screen, item.MainText, x, y, width, AlignLeft, tcell.ColorGray)
Print(screen, item.MainText, x, y, width, AlignLeft, tcell.ColorGray.TrueColor())
RenderScrollBar(screen, l.scrollBarVisibility, scrollBarX, y, scrollBarHeight, len(l.items), l.currentItem, index-l.offset, l.hasFocus, l.scrollBarColor)
y++
@ -797,7 +797,7 @@ func (l *List) Draw(screen tcell.Screen) {
if fg == l.mainTextColor {
fg = l.selectedTextColor
}
style = style.Background(l.selectedBackgroundColor).Foreground(fg) | tcell.Style(l.selectedTextAttributes)
style = SetAttributes(style.Background(l.selectedBackgroundColor).Foreground(fg), l.selectedTextAttributes)
screen.SetContent(x+bx, y, m, c, style)
}
}


+ 1
- 1
modal.go View File

@ -3,7 +3,7 @@ package cview
import (
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// Modal is a centered message window used to inform the user or prompt them


+ 1
- 1
pages.go View File

@ -3,7 +3,7 @@ package cview
import (
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// page represents one page of a Pages object.


+ 1
- 1
primitive.go View File

@ -1,6 +1,6 @@
package cview
import "github.com/gdamore/tcell"
import "github.com/gdamore/tcell/v2"
// Primitive is the top-most interface for all graphical primitives.
type Primitive interface {


+ 1
- 1
progressbar.go View File

@ -4,7 +4,7 @@ import (
"math"
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// ProgressBar indicates the progress of an operation.


+ 1
- 1
semigraphics.go View File

@ -1,6 +1,6 @@
package cview
import "github.com/gdamore/tcell"
import "github.com/gdamore/tcell/v2"
// Semigraphics provides an easy way to access unicode characters for drawing.
//


+ 17
- 17
styles.go View File

@ -1,6 +1,6 @@
package cview
import "github.com/gdamore/tcell"
import "github.com/gdamore/tcell/v2"
// Theme defines the colors used when primitives are initialized.
type Theme struct {
@ -21,38 +21,38 @@ type Theme struct {
ContrastBackgroundColor tcell.Color // Background color for contrasting elements.
MoreContrastBackgroundColor tcell.Color // Background color for even more contrasting elements.
// Scroll bar
ScrollBarColor tcell.Color // Scroll bar color.
// Context menu
ContextMenuPaddingTop int // Top padding.
ContextMenuPaddingBottom int // Bottom padding.
ContextMenuPaddingLeft int // Left padding.
ContextMenuPaddingRight int // Right padding.
// Scroll bar
ScrollBarColor tcell.Color // Scroll bar color.
}
// Styles defines the appearance of an application. The default is for a black
// background and some basic colors: black, white, yellow, green, cyan, and
// blue.
var Styles = Theme{
TitleColor: tcell.ColorWhite,
BorderColor: tcell.ColorWhite,
GraphicsColor: tcell.ColorWhite,
TitleColor: tcell.ColorWhite.TrueColor(),
BorderColor: tcell.ColorWhite.TrueColor(),
GraphicsColor: tcell.ColorWhite.TrueColor(),
PrimaryTextColor: tcell.ColorWhite,
SecondaryTextColor: tcell.ColorYellow,
TertiaryTextColor: tcell.ColorGreen,
InverseTextColor: tcell.ColorBlue,
ContrastSecondaryTextColor: tcell.ColorDarkCyan,
PrimaryTextColor: tcell.ColorWhite.TrueColor(),
SecondaryTextColor: tcell.ColorYellow.TrueColor(),
TertiaryTextColor: tcell.ColorGreen.TrueColor(),
InverseTextColor: tcell.ColorBlue.TrueColor(),
ContrastSecondaryTextColor: tcell.ColorDarkCyan.TrueColor(),
PrimitiveBackgroundColor: tcell.ColorBlack,
ContrastBackgroundColor: tcell.ColorBlue,
MoreContrastBackgroundColor: tcell.ColorGreen,
PrimitiveBackgroundColor: tcell.ColorBlack.TrueColor(),
ContrastBackgroundColor: tcell.ColorBlue.TrueColor(),
MoreContrastBackgroundColor: tcell.ColorGreen.TrueColor(),
ScrollBarColor: tcell.ColorWhite.TrueColor(),
ContextMenuPaddingTop: 0,
ContextMenuPaddingBottom: 0,
ContextMenuPaddingLeft: 1,
ContextMenuPaddingRight: 1,
ScrollBarColor: tcell.ColorWhite,
}

+ 7
- 7
table.go View File

@ -4,7 +4,7 @@ import (
"sort"
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
colorful "github.com/lucasb-eyer/go-colorful"
)
@ -301,8 +301,8 @@ type Table struct {
// The scroll bar color.
scrollBarColor tcell.Color
// 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 StyleDefault, selected rows
// are simply inverted.
selectedStyle tcell.Style
// An optional function which gets called when the user presses Enter on a
@ -392,7 +392,7 @@ func (t *Table) SetSelectedStyle(foregroundColor, backgroundColor tcell.Color, a
t.Lock()
defer t.Unlock()
t.selectedStyle = tcell.StyleDefault.Foreground(foregroundColor).Background(backgroundColor) | tcell.Style(attributes)
t.selectedStyle = SetAttributes(tcell.StyleDefault.Foreground(foregroundColor).Background(backgroundColor), attributes)
return t
}
@ -1024,7 +1024,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, SetAttributes(tcell.StyleDefault.Foreground(cell.Color), 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)
@ -1125,7 +1125,7 @@ ColumnLoop:
if attr != 0 {
a = attr
}
style = style.Background(bg).Foreground(fg) | tcell.Style(a)
style = SetAttributes(style.Background(bg).Foreground(fg), a)
}
screen.SetContent(fromX+bx, fromY+by, m, c, style)
}
@ -1188,7 +1188,7 @@ ColumnLoop:
entries := cellsByBackgroundColor[bgColor]
for _, cell := range entries {
if cell.selected {
if t.selectedStyle != 0 {
if t.selectedStyle != tcell.StyleDefault {
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)


+ 3
- 3
textview.go View File

@ -7,7 +7,7 @@ import (
"sync"
"unicode/utf8"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"github.com/lucasb-eyer/go-colorful"
"github.com/mattn/go-runewidth"
"github.com/rivo/uniseg"
@ -1126,9 +1126,9 @@ func (t *TextView) Draw(screen tcell.Screen) {
c := colorful.Color{R: float64(r) / 255, G: float64(g) / 255, B: float64(b) / 255}
_, _, li := c.Hcl()
if li < .5 {
bg = tcell.ColorWhite
bg = tcell.ColorWhite.TrueColor()
} else {
bg = tcell.ColorBlack
bg = tcell.ColorBlack.TrueColor()
}
}
style = style.Background(fg).Foreground(bg)


+ 2
- 2
treeview.go View File

@ -3,7 +3,7 @@ package cview
import (
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// Tree navigation events.
@ -855,7 +855,7 @@ func (t *TreeView) Draw(screen tcell.Screen) {
}
// Draw scroll bar.
RenderScrollBar(screen, t.scrollBarVisibility, x+(width-1), posY, height, rows, cursor, posY-y, t.hasFocus, tcell.ColorWhite)
RenderScrollBar(screen, t.scrollBarVisibility, x+(width-1), posY, height, rows, cursor, posY-y, t.hasFocus, tcell.ColorWhite.TrueColor())
// Advance.
posY++


+ 14
- 3
util.go View File

@ -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"
)
@ -142,14 +142,14 @@ func overlayStyle(background tcell.Color, defaultStyle tcell.Style, fgColor, bgC
if fgColor == "-" {
style = style.Foreground(defFg)
} else {
style = style.Foreground(tcell.GetColor(fgColor))
style = style.Foreground(tcell.GetColor(fgColor).TrueColor())
}
}
if bgColor == "-" || bgColor == "" && defBg != tcell.ColorDefault {
style = style.Background(defBg)
} else if bgColor != "" {
style = style.Background(tcell.GetColor(bgColor))
style = style.Background(tcell.GetColor(bgColor).TrueColor())
}
if attributes == "-" {
@ -182,6 +182,17 @@ func overlayStyle(background tcell.Color, defaultStyle tcell.Style, fgColor, bgC
return style
}
// SetAttributes sets attributes on a style.
func SetAttributes(style tcell.Style, attrs tcell.AttrMask) tcell.Style {
return style.
Blink(attrs&tcell.AttrBlink != 0).
Bold(attrs&tcell.AttrBold != 0).
Dim(attrs&tcell.AttrDim != 0).
Italic(attrs&tcell.AttrItalic != 0).
Reverse(attrs&tcell.AttrReverse != 0).
Underline(attrs&tcell.AttrUnderline != 0)
}
// decomposeString returns information about a string which may contain color
// tags or region tags, depending on which ones are requested to be found. It
// returns the indices of the color tags (as returned by


+ 1
- 1
util_test.go View File

@ -1,7 +1,7 @@
package cview
import (
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
// newTestApp returns a new application connected to a simulation screen.


Loading…
Cancel
Save