Update to tcell v2.0.0 (#358)

Migrate tcell to 2.0.0

* tview.TreeView#SetSelectedStyle removed
* tview.Primitives don't allow directly setting attributes for now (might change again with tview 2.+)
This commit is contained in:
Marcel Schramm 2020-10-24 13:22:48 +02:00 committed by GitHub
parent 62946ab52f
commit 52ee681981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 170 additions and 234 deletions

View File

@ -7,7 +7,7 @@ import (
"path/filepath" "path/filepath"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
// Theme is a wrapper around the tview.Theme. This wrapper can be extended with // Theme is a wrapper around the tview.Theme. This wrapper can be extended with

View File

@ -1,7 +1,7 @@
package femto package femto
import ( import (
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth" "github.com/mattn/go-runewidth"
) )

View File

@ -6,7 +6,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
// Colorscheme is a map from string to style -- it represents a colorscheme // Colorscheme is a map from string to style -- it represents a colorscheme

2
go.mod
View File

@ -10,7 +10,7 @@ require (
github.com/alecthomas/chroma v0.6.6 github.com/alecthomas/chroma v0.6.6
github.com/atotto/clipboard v0.1.2 github.com/atotto/clipboard v0.1.2
github.com/dlclark/regexp2 v1.2.0 // indirect github.com/dlclark/regexp2 v1.2.0 // indirect
github.com/gdamore/tcell v1.4.0 github.com/gdamore/tcell/v2 v2.0.0
github.com/gen2brain/beeep v0.0.0-20200526185328-e9c15c258e28 github.com/gen2brain/beeep v0.0.0-20200526185328-e9c15c258e28
github.com/google/go-github/v29 v29.0.3 github.com/google/go-github/v29 v29.0.3
github.com/lucasb-eyer/go-colorful v1.0.3 github.com/lucasb-eyer/go-colorful v1.0.3

4
go.sum
View File

@ -33,8 +33,8 @@ github.com/dlclark/regexp2 v1.2.0 h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk
github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= 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/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell v1.4.0 h1:vUnHwJRvcPQa3tzi+0QI4U9JINXYJlOz9yiaiPQ2wMU= github.com/gdamore/tcell/v2 v2.0.0 h1:GRWG8aLfWAlekj9Q6W29bVvkHENc6hp79XOqG4AWDOs=
github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0= github.com/gdamore/tcell/v2 v2.0.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
github.com/gen2brain/beeep v0.0.0-20200526185328-e9c15c258e28 h1:M2Zt3G2w6Q57GZndOYk42p7RvMeO8izO8yKTfIxGqxA= github.com/gen2brain/beeep v0.0.0-20200526185328-e9c15c258e28 h1:M2Zt3G2w6Q57GZndOYk42p7RvMeO8izO8yKTfIxGqxA=
github.com/gen2brain/beeep v0.0.0-20200526185328-e9c15c258e28/go.mod h1:ElSskYZe3oM8kThaHGJ+kiN2yyUMVXMZ7WxF9QqLDS8= github.com/gen2brain/beeep v0.0.0-20200526185328-e9c15c258e28/go.mod h1:ElSskYZe3oM8kThaHGJ+kiN2yyUMVXMZ7WxF9QqLDS8=
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE= github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE=

View File

@ -8,7 +8,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/config" "github.com/Bios-Marcel/cordless/config"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
func main() { func main() {

View File

@ -2,7 +2,7 @@ package main
import ( import (
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
func main() { func main() {

View File

@ -7,7 +7,7 @@ import (
"strings" "strings"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/config" "github.com/Bios-Marcel/cordless/config"
) )

View File

@ -3,7 +3,7 @@ package tview
import ( import (
"sync" "sync"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
// The size of the event/update/redraw channels. // The size of the event/update/redraw channels.

View File

@ -1,7 +1,7 @@
package tview package tview
import ( import (
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
// Box implements Primitive with a background and optional elements such as a // Box implements Primitive with a background and optional elements such as a
@ -41,11 +41,7 @@ type Box struct {
// The color of the border when the box has focus. // The color of the border when the box has focus.
borderFocusColor tcell.Color borderFocusColor tcell.Color
// The style attributes of the border. borderBlinking bool
borderAttributes tcell.AttrMask
// The style attributes of the border when the box has focus.
borderFocusAttributes tcell.AttrMask
// If set to true, the text view will show down and up arrows if there is // If set to true, the text view will show down and up arrows if there is
// content out of sight. While box doesn't implement scrolling, this is // content out of sight. While box doesn't implement scrolling, this is
@ -99,7 +95,6 @@ func NewBox() *Box {
backgroundColor: Styles.PrimitiveBackgroundColor, backgroundColor: Styles.PrimitiveBackgroundColor,
borderColor: Styles.BorderColor, borderColor: Styles.BorderColor,
borderFocusColor: Styles.BorderFocusColor, borderFocusColor: Styles.BorderFocusColor,
borderFocusAttributes: tcell.AttrNone,
titleColor: Styles.TitleColor, titleColor: Styles.TitleColor,
titleAlign: AlignCenter, titleAlign: AlignCenter,
borderTop: true, borderTop: true,
@ -110,10 +105,6 @@ func NewBox() *Box {
nextFocusableComponents: make(map[FocusDirection][]Primitive), nextFocusableComponents: make(map[FocusDirection][]Primitive),
} }
if IsVtxxx {
b.borderFocusAttributes = tcell.AttrBold
}
b.focus = b b.focus = b
return b return b
} }
@ -346,21 +337,8 @@ func (b *Box) IsBorderLeft() bool {
return b.border && b.borderLeft return b.border && b.borderLeft
} }
// SetBorderAttributes sets the border's style attributes. You can combine func (b *Box) SetBorderBlinking(blinking bool) *Box {
// different attributes using bitmask operations: b.borderBlinking = blinking
//
// box.SetBorderAttributes(tcell.AttrUnderline | tcell.AttrBold)
func (b *Box) SetBorderAttributes(attr tcell.AttrMask) *Box {
b.borderAttributes = attr
return b
}
// SetBorderFocusAttributes sets the border's style attributes when focused. You can combine
// different attributes using bitmask operations:
//
// box.SetBorderFocusAttributes(tcell.AttrUnderline | tcell.AttrBold)
func (b *Box) SetBorderFocusAttributes(attr tcell.AttrMask) *Box {
b.borderFocusAttributes = attr
return b return b
} }
@ -402,16 +380,20 @@ func (b *Box) Draw(screen tcell.Screen) bool {
// Draw border. // Draw border.
if b.border && b.width >= 2 && b.height >= 1 { if b.border && b.width >= 2 && b.height >= 1 {
var border tcell.Style var borderStyle tcell.Style
if b.hasFocus { if b.hasFocus {
if b.borderFocusAttributes != 0 { borderStyle = background.Foreground(b.borderFocusColor)
border = background.Foreground(b.borderFocusColor) | tcell.Style(b.borderFocusAttributes) if IsVtxxx {
} else { borderStyle = borderStyle.Bold(true)
border = background.Foreground(b.borderFocusColor) | tcell.Style(b.borderAttributes)
} }
} else { } else {
border = background.Foreground(b.borderColor) | tcell.Style(b.borderAttributes) borderStyle = background.Foreground(b.borderColor)
} }
if b.borderBlinking {
borderStyle = borderStyle.Blink(true)
}
var vertical, horizontal, topLeft, topRight, bottomLeft, bottomRight rune var vertical, horizontal, topLeft, topRight, bottomLeft, bottomRight rune
horizontal = Borders.Horizontal horizontal = Borders.Horizontal
@ -424,19 +406,19 @@ func (b *Box) Draw(screen tcell.Screen) bool {
//Special case in order to render only the title-line of something properly. //Special case in order to render only the title-line of something properly.
if b.borderTop { if b.borderTop {
for x := b.x + 1; x < b.x+b.width-1; x++ { 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, horizontal, nil, borderStyle)
} }
if b.borderLeft { if b.borderLeft {
screen.SetContent(b.x, b.y, topLeft, nil, border) screen.SetContent(b.x, b.y, topLeft, nil, borderStyle)
} else { } else {
screen.SetContent(b.x, b.y, horizontal, nil, border) screen.SetContent(b.x, b.y, horizontal, nil, borderStyle)
} }
if b.borderRight { if b.borderRight {
screen.SetContent(b.x+b.width-1, b.y, topRight, nil, border) screen.SetContent(b.x+b.width-1, b.y, topRight, nil, borderStyle)
} else { } else {
screen.SetContent(b.x+b.width-1, b.y, horizontal, nil, border) screen.SetContent(b.x+b.width-1, b.y, horizontal, nil, borderStyle)
} }
} }
@ -444,62 +426,62 @@ func (b *Box) Draw(screen tcell.Screen) bool {
if b.height > 1 { if b.height > 1 {
if b.borderBottom { if b.borderBottom {
for x := b.x + 1; x < b.x+b.width-1; x++ { for x := b.x + 1; x < b.x+b.width-1; x++ {
screen.SetContent(x, b.y+b.height-1, horizontal, nil, border) screen.SetContent(x, b.y+b.height-1, horizontal, nil, borderStyle)
} }
if b.borderLeft { if b.borderLeft {
screen.SetContent(b.x, b.y+b.height-1, bottomLeft, nil, border) screen.SetContent(b.x, b.y+b.height-1, bottomLeft, nil, borderStyle)
} else { } else {
screen.SetContent(b.x, b.y+b.height-1, horizontal, nil, border) screen.SetContent(b.x, b.y+b.height-1, horizontal, nil, borderStyle)
} }
if b.borderRight { if b.borderRight {
screen.SetContent(b.x+b.width-1, b.y+b.height-1, bottomRight, nil, border) screen.SetContent(b.x+b.width-1, b.y+b.height-1, bottomRight, nil, borderStyle)
} else { } else {
screen.SetContent(b.x+b.width-1, b.y+b.height-1, horizontal, nil, border) screen.SetContent(b.x+b.width-1, b.y+b.height-1, horizontal, nil, borderStyle)
} }
} }
if b.borderLeft { if b.borderLeft {
for y := b.y + 1; y < b.y+b.height-1; y++ { for y := b.y + 1; y < b.y+b.height-1; y++ {
screen.SetContent(b.x, y, vertical, nil, border) screen.SetContent(b.x, y, vertical, nil, borderStyle)
} }
if b.borderTop { if b.borderTop {
screen.SetContent(b.x, b.y, topLeft, nil, border) screen.SetContent(b.x, b.y, topLeft, nil, borderStyle)
} else { } else {
screen.SetContent(b.x, b.y, vertical, nil, border) screen.SetContent(b.x, b.y, vertical, nil, borderStyle)
} }
if b.borderBottom { if b.borderBottom {
screen.SetContent(b.x, b.y+b.height-1, bottomLeft, nil, border) screen.SetContent(b.x, b.y+b.height-1, bottomLeft, nil, borderStyle)
} else { } else {
screen.SetContent(b.x, b.y+b.height-1, vertical, nil, border) screen.SetContent(b.x, b.y+b.height-1, vertical, nil, borderStyle)
} }
} }
if b.borderRight { if b.borderRight {
for y := b.y + 1; y < b.y+b.height-1; y++ { for y := b.y + 1; y < b.y+b.height-1; y++ {
screen.SetContent(b.x+b.width-1, y, vertical, nil, border) screen.SetContent(b.x+b.width-1, y, vertical, nil, borderStyle)
} }
if b.borderTop { if b.borderTop {
screen.SetContent(b.x+b.width-1, b.y, topRight, nil, border) screen.SetContent(b.x+b.width-1, b.y, topRight, nil, borderStyle)
} else { } else {
screen.SetContent(b.x+b.width-1, b.y, vertical, nil, border) screen.SetContent(b.x+b.width-1, b.y, vertical, nil, borderStyle)
} }
if b.borderBottom { if b.borderBottom {
screen.SetContent(b.x+b.width-1, b.y+b.height-1, bottomRight, nil, border) screen.SetContent(b.x+b.width-1, b.y+b.height-1, bottomRight, nil, borderStyle)
} else { } else {
screen.SetContent(b.x+b.width-1, b.y+b.height-1, vertical, nil, border) screen.SetContent(b.x+b.width-1, b.y+b.height-1, vertical, nil, borderStyle)
} }
} }
} else if b.height == 1 && !b.borderTop && !b.borderBottom { } else if b.height == 1 && !b.borderTop && !b.borderBottom {
if b.borderLeft { if b.borderLeft {
screen.SetContent(b.x, b.y, vertical, nil, border) screen.SetContent(b.x, b.y, vertical, nil, borderStyle)
} }
if b.borderRight { if b.borderRight {
screen.SetContent(b.x+b.width-1, b.y+b.height-1, vertical, nil, border) screen.SetContent(b.x+b.width-1, b.y+b.height-1, vertical, nil, borderStyle)
} }
} }

View File

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

View File

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

View File

@ -2,14 +2,12 @@
package main package main
import ( import (
"github.com/gdamore/tcell"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )
func main() { func main() {
box := tview.NewBox(). box := tview.NewBox().
SetBorder(true). SetBorder(true).
SetBorderAttributes(tcell.AttrBold).
SetTitle("A [red]c[yellow]o[green]l[darkcyan]o[blue]r[darkmagenta]f[red]u[yellow]l[white] [black:red]c[:yellow]o[:green]l[:darkcyan]o[:blue]r[:darkmagenta]f[:red]u[:yellow]l[white:] [::bu]title") SetTitle("A [red]c[yellow]o[green]l[darkcyan]o[blue]r[darkmagenta]f[red]u[yellow]l[white] [black:red]c[:yellow]o[:green]l[:darkcyan]o[:blue]r[:darkmagenta]f[:red]u[:yellow]l[white:] [::bu]title")
if err := tview.NewApplication().SetRoot(box, true).Run(); err != nil { if err := tview.NewApplication().SetRoot(box, true).Run(); err != nil {
panic(err) panic(err)

View File

@ -2,7 +2,7 @@
package main package main
import ( import (
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -2,7 +2,7 @@ package main
import ( import (
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
func main() { func main() {

View File

@ -2,7 +2,7 @@
package main package main
import ( import (
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -4,7 +4,7 @@ package main
import ( import (
"strings" "strings"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -3,7 +3,7 @@ package main
import ( import (
"strings" "strings"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -3,7 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -1,7 +1,7 @@
package main package main
import ( import (
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -1,7 +1,7 @@
package main package main
import ( import (
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -1,7 +1,7 @@
package main package main
import ( import (
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -1,7 +1,7 @@
package main package main
import ( import (
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )
@ -10,7 +10,7 @@ const inputField = `[green]package[white] main
[green]import[white] ( [green]import[white] (
[red]"strconv"[white] [red]"strconv"[white]
[red]"github.com/gdamore/tcell"[white] [red]tcell "github.com/gdamore/tcell/v2"[white]
[red]"github.com/Bios-Marcel/cordless/tview"[white] [red]"github.com/Bios-Marcel/cordless/tview"[white]
) )

View File

@ -16,7 +16,7 @@ import (
"fmt" "fmt"
"strconv" "strconv"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -5,7 +5,7 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )
@ -59,7 +59,7 @@ const textView2 = `[green]package[white] main
[green]import[white] ( [green]import[white] (
[red]"strconv"[white] [red]"strconv"[white]
[red]"github.com/gdamore/tcell"[white] [red]tcell "github.com/gdamore/tcell/v2"[white]
[red]"github.com/Bios-Marcel/cordless/tview"[white] [red]"github.com/Bios-Marcel/cordless/tview"[white]
) )

View File

@ -3,7 +3,7 @@ package main
import ( import (
"strings" "strings"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
// RadioButtons implements a simple primitive for radio button selections. // RadioButtons implements a simple primitive for radio button selections.

View File

@ -4,7 +4,7 @@ package main
import ( import (
"strings" "strings"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -7,7 +7,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

@ -5,7 +5,7 @@ import (
"io/ioutil" "io/ioutil"
"path/filepath" "path/filepath"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
) )

View File

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

View File

@ -1,7 +1,7 @@
package tview package tview
import ( import (
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
// Configuration values. // Configuration values.

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ import (
"strings" "strings"
"unicode/utf8" "unicode/utf8"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
// InputField is a one-line box (three lines if there is a title) where the // InputField is a one-line box (three lines if there is a title) where the

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
// listItem represents one item in a List. // listItem represents one item in a List.

View File

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

View File

@ -1,6 +1,6 @@
package tview package tview
import "github.com/gdamore/tcell" import tcell "github.com/gdamore/tcell/v2"
// MouseSupport defines wether a component supports accepting mouse events // MouseSupport defines wether a component supports accepting mouse events
type MouseSupport interface { type MouseSupport interface {

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
package tview package tview
import "github.com/gdamore/tcell" import tcell "github.com/gdamore/tcell/v2"
// Theme defines the colors used when primitives are initialized. // Theme defines the colors used when primitives are initialized.
type Theme struct { type Theme struct {

View File

@ -3,7 +3,7 @@ package tview
import ( import (
"sort" "sort"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
colorful "github.com/lucasb-eyer/go-colorful" colorful "github.com/lucasb-eyer/go-colorful"
) )
@ -247,10 +247,6 @@ type Table struct {
// The number of visible rows the last time the table was drawn. // The number of visible rows the last time the table was drawn.
visibleRows int visibleRows int
// The style of the selected rows. If this value is 0, selected rows are
// simply inverted.
selectedStyle tcell.Style
// An optional function which gets called when the user presses Enter on a // An optional function which gets called when the user presses Enter on a
// selected cell. If entire rows selected, the column value is undefined. // selected cell. If entire rows selected, the column value is undefined.
// Likewise for entire columns. // Likewise for entire columns.
@ -296,18 +292,6 @@ func (t *Table) SetBordersColor(color tcell.Color) *Table {
return t return t
} }
// SetSelectedStyle sets a specific style for selected cells. If no such style
// is set, per default, selected cells are inverted (i.e. their foreground and
// background colors are swapped).
//
// 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)
return t
}
// SetSeparator sets the character used to fill the space between two // SetSeparator sets the character used to fill the space between two
// neighboring cells. This is a space character ' ' per default but you may // neighboring cells. This is a space character ' ' per default but you may
// want to set it to Borders.Vertical (or any other rune) if the column // want to set it to Borders.Vertical (or any other rune) if the column
@ -804,7 +788,7 @@ ColumnLoop:
finalWidth = width - columnX - 1 finalWidth = width - columnX - 1
} }
cell.x, cell.y, cell.width = x+columnX+1, y+rowY, finalWidth 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))
if TaggedStringWidth(cell.Text)-printed > 0 && printed > 0 { if TaggedStringWidth(cell.Text)-printed > 0 && printed > 0 {
_, _, style, _ := screen.GetContent(x+columnX+1+finalWidth-1, y+rowY) _, _, style, _ := screen.GetContent(x+columnX+1+finalWidth-1, y+rowY)
printWithStyle(screen, string(SemigraphicsHorizontalEllipsis), x+columnX+1+finalWidth-1, y+rowY, 1, AlignLeft, style) printWithStyle(screen, string(SemigraphicsHorizontalEllipsis), x+columnX+1+finalWidth-1, y+rowY, 1, AlignLeft, style)
@ -854,27 +838,14 @@ ColumnLoop:
for by := 0; by < h && fromY+by < y+height; by++ { for by := 0; by < h && fromY+by < y+height; by++ {
for bx := 0; bx < w && fromX+bx < x+width; bx++ { for bx := 0; bx < w && fromX+bx < x+width; bx++ {
m, c, style, _ := screen.GetContent(fromX+bx, fromY+by) m, c, style, _ := screen.GetContent(fromX+bx, fromY+by)
fg, bg, a := style.Decompose() fg, bg, _ := style.Decompose()
if invert { if backgroundColor != tcell.ColorDefault {
if fg == textColor || fg == t.bordersColor { bg = backgroundColor
fg = backgroundColor
}
if fg == tcell.ColorDefault {
fg = t.backgroundColor
}
style = style.Background(textColor).Foreground(fg)
} else {
if backgroundColor != tcell.ColorDefault {
bg = backgroundColor
}
if textColor != tcell.ColorDefault {
fg = textColor
}
if attr != 0 {
a = attr
}
style = style.Background(bg).Foreground(fg) | tcell.Style(a)
} }
if textColor != tcell.ColorDefault {
fg = textColor
}
style = style.Background(bg).Foreground(fg).Reverse(invert)
screen.SetContent(fromX+bx, fromY+by, m, c, style) screen.SetContent(fromX+bx, fromY+by, m, c, style)
} }
} }
@ -931,16 +902,11 @@ ColumnLoop:
_, _, lj := c.Hcl() _, _, lj := c.Hcl()
return li < lj return li < lj
}) })
selFg, selBg, selAttr := t.selectedStyle.Decompose()
for _, bgColor := range backgroundColors { for _, bgColor := range backgroundColors {
entries := cellsByBackgroundColor[bgColor] entries := cellsByBackgroundColor[bgColor]
for _, cell := range entries { for _, cell := range entries {
if cell.selected { if cell.selected {
if t.selectedStyle != 0 { defer colorBackground(cell.x, cell.y, cell.w, cell.h, bgColor, cell.text, 0, true)
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)
}
} else { } else {
colorBackground(cell.x, cell.y, cell.w, cell.h, bgColor, tcell.ColorDefault, 0, false) colorBackground(cell.x, cell.y, cell.w, cell.h, bgColor, tcell.ColorDefault, 0, false)
} }

View File

@ -8,7 +8,7 @@ import (
"sync" "sync"
"unicode/utf8" "unicode/utf8"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
colorful "github.com/lucasb-eyer/go-colorful" colorful "github.com/lucasb-eyer/go-colorful"
runewidth "github.com/mattn/go-runewidth" runewidth "github.com/mattn/go-runewidth"
) )

View File

@ -5,7 +5,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
// Tree navigation events. // Tree navigation events.
@ -36,8 +36,9 @@ type TreeNode struct {
// The text color. // The text color.
color tcell.Color color tcell.Color
// The text attributes. blinking bool
attr tcell.AttrMask
underline bool
// Whether or not this node can be selected. // Whether or not this node can be selected.
selectable bool selectable bool
@ -263,15 +264,12 @@ func (n *TreeNode) SetColor(color tcell.Color) *TreeNode {
return n return n
} }
// GetAttributes gets the node's attributes. func (n *TreeNode) SetUnderline(underline bool) {
func (n *TreeNode) GetAttributes() tcell.AttrMask { n.underline = underline
return n.attr
} }
// SetAttributes sets the node's attributes. func (n *TreeNode) SetBlinking(blinking bool) {
func (n *TreeNode) SetAttributes(attr tcell.AttrMask) *TreeNode { n.blinking = blinking
n.attr = attr
return n
} }
// SetIndent sets an additional indentation for this node's text. A value of 0 // SetIndent sets an additional indentation for this node's text. A value of 0
@ -801,14 +799,20 @@ func (t *TreeView) Draw(screen tcell.Screen) bool {
// Text. // Text.
if node.textX+bulletCharacterWidth < width { if node.textX+bulletCharacterWidth < width {
style := tcell.StyleDefault.Foreground(node.color) | tcell.Style(node.attr) style := tcell.StyleDefault.Foreground(node.color)
if node == t.currentNode { if node == t.currentNode {
if IsVtxxx { if IsVtxxx {
style = tcell.StyleDefault.Reverse(true) style = tcell.StyleDefault.Reverse(true)
} else { } else {
style = tcell.StyleDefault.Background(node.color).Foreground(t.backgroundColor) | tcell.Style(node.attr) style = tcell.StyleDefault.Background(node.color).Foreground(t.backgroundColor)
} }
} }
if node.blinking {
style = style.Blink(true)
}
if node.underline {
style = style.Underline(true)
}
var fullPrefix string var fullPrefix string
for _, prefix := range node.prefixes { for _, prefix := range node.prefixes {
fullPrefix += prefix fullPrefix += prefix

View File

@ -7,7 +7,7 @@ import (
"sort" "sort"
"strconv" "strconv"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
runewidth "github.com/mattn/go-runewidth" runewidth "github.com/mattn/go-runewidth"
"github.com/rivo/uniseg" "github.com/rivo/uniseg"
) )

View File

@ -4,8 +4,6 @@ import (
"sort" "sort"
"sync" "sync"
"github.com/gdamore/tcell"
"github.com/Bios-Marcel/cordless/ui/tviewutil" "github.com/Bios-Marcel/cordless/ui/tviewutil"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
@ -295,7 +293,8 @@ func (channelTree *ChannelTree) MarkAsUnread(channelID string) {
func (channelTree *ChannelTree) markNodeAsUnread(node *tview.TreeNode) { func (channelTree *ChannelTree) markNodeAsUnread(node *tview.TreeNode) {
if tview.IsVtxxx { if tview.IsVtxxx {
node.SetAttributes(tcell.AttrBlink) node.SetBlinking(true)
node.SetUnderline(false)
} else { } else {
node.SetColor(config.GetTheme().AttentionColor) node.SetColor(config.GetTheme().AttentionColor)
} }
@ -312,7 +311,8 @@ func (channelTree *ChannelTree) MarkAsRead(channelID string) {
func (channelTree *ChannelTree) markNodeAsRead(node *tview.TreeNode) { func (channelTree *ChannelTree) markNodeAsRead(node *tview.TreeNode) {
if tview.IsVtxxx { if tview.IsVtxxx {
node.SetAttributes(tcell.AttrNone) node.SetBlinking(false)
node.SetUnderline(false)
} else { } else {
node.SetColor(config.GetTheme().PrimaryTextColor) node.SetColor(config.GetTheme().PrimaryTextColor)
} }
@ -371,7 +371,8 @@ func (channelTree *ChannelTree) MarkAsLoaded(channelID string) {
func (channelTree *ChannelTree) markNodeAsLoaded(node *tview.TreeNode) { func (channelTree *ChannelTree) markNodeAsLoaded(node *tview.TreeNode) {
if tview.IsVtxxx { if tview.IsVtxxx {
node.SetAttributes(tcell.AttrUnderline) node.SetUnderline(true)
node.SetBlinking(false)
} else { } else {
node.SetColor(tview.Styles.ContrastBackgroundColor) node.SetColor(tview.Styles.ContrastBackgroundColor)
} }

View File

@ -4,7 +4,7 @@ import (
"testing" "testing"
"github.com/Bios-Marcel/discordgo" "github.com/Bios-Marcel/discordgo"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
func TestChannelTree(t *testing.T) { func TestChannelTree(t *testing.T) {

View File

@ -11,7 +11,7 @@ import (
"sync" "sync"
linkshortener "github.com/Bios-Marcel/shortnotforlong" linkshortener "github.com/Bios-Marcel/shortnotforlong"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/config" "github.com/Bios-Marcel/cordless/config"
"github.com/Bios-Marcel/cordless/discordutil" "github.com/Bios-Marcel/cordless/discordutil"

View File

@ -4,7 +4,7 @@ import (
"strings" "strings"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
const noHistoryIndexSelected = -1 const noHistoryIndexSelected = -1

View File

@ -1,11 +1,11 @@
package ui package components
import ( import (
"sync" "sync"
"github.com/Bios-Marcel/cordless/config" "github.com/Bios-Marcel/cordless/config"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth" "github.com/mattn/go-runewidth"
"github.com/rivo/uniseg" "github.com/rivo/uniseg"
) )

View File

@ -1,10 +1,10 @@
package ui package components
import ( import (
"strings" "strings"
"testing" "testing"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
func TestBottomBar(t *testing.T) { func TestBottomBar(t *testing.T) {

View File

@ -4,7 +4,7 @@ import (
"github.com/Bios-Marcel/cordless/shortcuts" "github.com/Bios-Marcel/cordless/shortcuts"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/atotto/clipboard" "github.com/atotto/clipboard"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
// PrompSecretSingleLineInput shows a fullscreen input dialog that masks the // PrompSecretSingleLineInput shows a fullscreen input dialog that masks the

View File

@ -5,7 +5,7 @@ import (
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/atotto/clipboard" "github.com/atotto/clipboard"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/config" "github.com/Bios-Marcel/cordless/config"
"github.com/Bios-Marcel/cordless/femto" "github.com/Bios-Marcel/cordless/femto"
@ -599,16 +599,9 @@ func (editor *Editor) SetBorderColor(color tcell.Color) {
editor.internalTextView.SetBorderColor(color) editor.internalTextView.SetBorderColor(color)
} }
// SetBorderAttributes delegates to the underlying components SetBorderAttributes // SetBorderBlinking sets the blinking attribute of the border in tview.
// method. func (editor *Editor) SetBorderBlinking(blinking bool) {
func (editor *Editor) SetBorderAttributes(attr tcell.AttrMask) { editor.internalTextView.SetBorderBlinking(blinking)
editor.internalTextView.SetBorderAttributes(attr)
}
// SetBorderFocusAttributes delegates to the underlying components SetBorderFocusAttributes
// method.
func (editor *Editor) SetBorderFocusAttributes(attr tcell.AttrMask) {
editor.internalTextView.SetBorderFocusAttributes(attr)
} }
// SetInputCapture sets the alternative input capture that will be used if the // SetInputCapture sets the alternative input capture that will be used if the

View File

@ -6,7 +6,6 @@ import (
"github.com/Bios-Marcel/cordless/readstate" "github.com/Bios-Marcel/cordless/readstate"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/Bios-Marcel/discordgo" "github.com/Bios-Marcel/discordgo"
"github.com/gdamore/tcell"
"github.com/Bios-Marcel/cordless/config" "github.com/Bios-Marcel/cordless/config"
"github.com/Bios-Marcel/cordless/ui/tviewutil" "github.com/Bios-Marcel/cordless/ui/tviewutil"
@ -77,14 +76,18 @@ func (g *GuildList) updateNodeState(guild *discordgo.Guild, node *tview.TreeNode
if loaded { if loaded {
g.markNodeAsLoaded(node) g.markNodeAsLoaded(node)
} else { } else {
//Reset to avoid mistakes
if tview.IsVtxxx {
node.SetBlinking(false)
node.SetUnderline(false)
}
if !readstate.HasGuildBeenRead(guild.ID) { if !readstate.HasGuildBeenRead(guild.ID) {
if tview.IsVtxxx { if tview.IsVtxxx {
node.SetAttributes(tcell.AttrBlink) node.SetBlinking(true)
} else { } else {
node.SetColor(config.GetTheme().AttentionColor) node.SetColor(config.GetTheme().AttentionColor)
} }
} else { } else {
node.SetAttributes(tcell.AttrNone)
node.SetColor(tview.Styles.PrimaryTextColor) node.SetColor(tview.Styles.PrimaryTextColor)
} }
} }
@ -164,9 +167,11 @@ func (g *GuildList) MarkAsLoaded(guildID string) {
} }
func (g *GuildList) markNodeAsLoaded(node *tview.TreeNode) { func (g *GuildList) markNodeAsLoaded(node *tview.TreeNode) {
node.SetBlinking(false)
if tview.IsVtxxx { if tview.IsVtxxx {
node.SetAttributes(tcell.AttrUnderline) node.SetUnderline(true)
} else { } else {
node.SetUnderline(false)
node.SetColor(tview.Styles.ContrastBackgroundColor) node.SetColor(tview.Styles.ContrastBackgroundColor)
} }
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/Bios-Marcel/discordgo" "github.com/Bios-Marcel/discordgo"
"github.com/atotto/clipboard" "github.com/atotto/clipboard"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/ui/tviewutil" "github.com/Bios-Marcel/cordless/ui/tviewutil"
"github.com/Bios-Marcel/cordless/util/text" "github.com/Bios-Marcel/cordless/util/text"

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"sort" "sort"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/discordutil" "github.com/Bios-Marcel/cordless/discordutil"
"github.com/Bios-Marcel/cordless/readstate" "github.com/Bios-Marcel/cordless/readstate"
@ -132,7 +132,7 @@ func (privateList *PrivateChatList) addChannel(channel *discordgo.Channel) {
if !readstate.HasBeenRead(channel, channel.LastMessageID) { if !readstate.HasBeenRead(channel, channel.LastMessageID) {
privateList.privateChannelStates[newNode] = unread privateList.privateChannelStates[newNode] = unread
if tview.IsVtxxx { if tview.IsVtxxx {
newNode.SetAttributes(tcell.AttrBlink) newNode.SetBlinking(true)
} else { } else {
newNode.SetColor(config.GetTheme().AttentionColor) newNode.SetColor(config.GetTheme().AttentionColor)
} }
@ -228,7 +228,7 @@ func (privateList *PrivateChatList) MarkAsUnread(channelID string) {
privateList.privateChannelStates[node] = unread privateList.privateChannelStates[node] = unread
privateList.setNotificationCount(privateList.amountOfUnreadChannels()) privateList.setNotificationCount(privateList.amountOfUnreadChannels())
if tview.IsVtxxx { if tview.IsVtxxx {
node.SetAttributes(tcell.AttrBlink) node.SetBlinking(true)
} else { } else {
node.SetColor(config.GetTheme().AttentionColor) node.SetColor(config.GetTheme().AttentionColor)
} }
@ -253,7 +253,8 @@ func (privateList *PrivateChatList) MarkAsRead(channelID string) {
privateList.setNotificationCount(privateList.amountOfUnreadChannels()) privateList.setNotificationCount(privateList.amountOfUnreadChannels())
privateList.privateChannelStates[node] = read privateList.privateChannelStates[node] = read
if tview.IsVtxxx { if tview.IsVtxxx {
node.SetAttributes(tcell.AttrNone) node.SetBlinking(false)
node.SetUnderline(false)
} else { } else {
node.SetColor(config.GetTheme().PrimaryTextColor) node.SetColor(config.GetTheme().PrimaryTextColor)
} }
@ -297,7 +298,8 @@ func (privateList *PrivateChatList) MarkAsLoaded(channelID string) {
if state == loaded { if state == loaded {
privateList.privateChannelStates[node] = read privateList.privateChannelStates[node] = read
if tview.IsVtxxx { if tview.IsVtxxx {
node.SetAttributes(tcell.AttrNone) node.SetBlinking(false)
node.SetUnderline(false)
} else { } else {
node.SetColor(config.GetTheme().PrimaryTextColor) node.SetColor(config.GetTheme().PrimaryTextColor)
} }
@ -309,8 +311,8 @@ func (privateList *PrivateChatList) MarkAsLoaded(channelID string) {
referenceChannelID, ok := node.GetReference().(string) referenceChannelID, ok := node.GetReference().(string)
if ok && referenceChannelID == channelID { if ok && referenceChannelID == channelID {
privateList.privateChannelStates[node] = loaded privateList.privateChannelStates[node] = loaded
if tview.IsVtxxx { if !tview.IsVtxxx {
node.SetAttributes(tcell.AttrUnderline) node.SetUnderline(true)
} else { } else {
node.SetColor(tview.Styles.ContrastBackgroundColor) node.SetColor(tview.Styles.ContrastBackgroundColor)
} }

View File

@ -5,15 +5,13 @@ import (
"github.com/Bios-Marcel/cordless/shortcuts" "github.com/Bios-Marcel/cordless/shortcuts"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell" "github.com/Bios-Marcel/cordless/ui/components"
tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/config"
"github.com/Bios-Marcel/cordless/ui/tviewutil"
) )
func ShowShortcutsDialog(app *tview.Application, onClose func()) { func ShowShortcutsDialog(app *tview.Application, onClose func()) {
var table *ShortcutTable var table *ShortcutTable
var shortcutDescription *tview.TextView var shortcutDescription *components.BottomBar
var exitButton *tview.Button var exitButton *tview.Button
var resetButton *tview.Button var resetButton *tview.Button
@ -55,22 +53,14 @@ func ShowShortcutsDialog(app *tview.Application, onClose func()) {
return nil return nil
}) })
primitiveBGColor := tviewutil.ColorToHex(config.GetTheme().PrimitiveBackgroundColor) shortcutDescription = components.NewBottomBar()
primaryTextColor := tviewutil.ColorToHex(config.GetTheme().PrimaryTextColor) shortcutDescription.SetBorderPadding(1, 0, 0, 0)
shortcutDescription.AddItem("R - Reset shortcut")
shortcutDescription.AddItem("Backspace - Delete shortcut")
shortcutDescription.AddItem("Enter - Change shortcut")
shortcutDescription.AddItem("ESC - Close dialog")
shortcutDescription = tview.NewTextView()
shortcutDescription.SetDynamicColors(true).SetBorderPadding(1, 0, 0, 0)
if tview.IsVtxxx {
shortcutDescription.SetText("R [::r]Reset shortcut[::-]" +
"[::-] Backspace [::r]Delete shortcut" +
"[::-] Enter [::r]Change shortcut" +
"[::-] Esc [::r]Close dialog")
} else {
shortcutDescription.SetText("[" + primaryTextColor + "][:" + primitiveBGColor + "]R [:" + primaryTextColor + "][" + primitiveBGColor + "]Reset shortcut" +
"[" + primaryTextColor + "][:" + primitiveBGColor + "] Backspace [:" + primaryTextColor + "][" + primitiveBGColor + "]Delete shortcut" +
"[" + primaryTextColor + "][:" + primitiveBGColor + "] Enter [:" + primaryTextColor + "][" + primitiveBGColor + "]Change shortcut" +
"[" + primaryTextColor + "][:" + primitiveBGColor + "] Esc [:" + primaryTextColor + "][" + primitiveBGColor + "]Close dialog")
}
table.SetFocusNext(func() { app.SetFocus(resetButton) }) table.SetFocusNext(func() { app.SetFocus(resetButton) })
table.SetFocusPrevious(func() { app.SetFocus(exitButton) }) table.SetFocusPrevious(func() { app.SetFocus(exitButton) })

View File

@ -6,7 +6,7 @@ import (
"github.com/Bios-Marcel/cordless/shortcuts" "github.com/Bios-Marcel/cordless/shortcuts"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
const ( const (
@ -35,9 +35,6 @@ func NewShortcutTable() *ShortcutTable {
table.SetSelectable(true, false) table.SetSelectable(true, false)
table.SetBorder(true) table.SetBorder(true)
if tview.IsVtxxx {
table.SetSelectedStyle(tcell.ColorBlack, tcell.ColorWhite, tcell.AttrReverse)
}
//Header + emptyrow //Header + emptyrow
table.SetFixed(2, 3) table.SetFixed(2, 3)

View File

@ -3,7 +3,7 @@ package tviewutil
import ( import (
"fmt" "fmt"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
var ( var (

View File

@ -3,7 +3,7 @@ package tviewutil
import ( import (
"testing" "testing"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
func TestColorToHex(t *testing.T) { func TestColorToHex(t *testing.T) {

View File

@ -2,7 +2,7 @@ package tviewutil
import ( import (
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
func CreateFocusTextViewOnTypeInputHandler(app *tview.Application, component *tview.TextView) func(event *tcell.EventKey) *tcell.EventKey { func CreateFocusTextViewOnTypeInputHandler(app *tview.Application, component *tview.TextView) func(event *tcell.EventKey) *tcell.EventKey {

View File

@ -10,7 +10,7 @@ import (
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
"github.com/Bios-Marcel/discordgo" "github.com/Bios-Marcel/discordgo"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
) )
// UserTree represents the visual list of users in a guild. // UserTree represents the visual list of users in a guild.

View File

@ -26,7 +26,7 @@ import (
"github.com/atotto/clipboard" "github.com/atotto/clipboard"
"github.com/Bios-Marcel/discordgo" "github.com/Bios-Marcel/discordgo"
"github.com/gdamore/tcell" tcell "github.com/gdamore/tcell/v2"
"github.com/gen2brain/beeep" "github.com/gen2brain/beeep"
"github.com/Bios-Marcel/cordless/tview" "github.com/Bios-Marcel/cordless/tview"
@ -38,6 +38,7 @@ import (
"github.com/Bios-Marcel/cordless/scripting" "github.com/Bios-Marcel/cordless/scripting"
"github.com/Bios-Marcel/cordless/scripting/js" "github.com/Bios-Marcel/cordless/scripting/js"
"github.com/Bios-Marcel/cordless/shortcuts" "github.com/Bios-Marcel/cordless/shortcuts"
"github.com/Bios-Marcel/cordless/ui/components"
"github.com/Bios-Marcel/cordless/ui/shortcutdialog" "github.com/Bios-Marcel/cordless/ui/shortcutdialog"
"github.com/Bios-Marcel/cordless/ui/tviewutil" "github.com/Bios-Marcel/cordless/ui/tviewutil"
"github.com/Bios-Marcel/cordless/util/maths" "github.com/Bios-Marcel/cordless/util/maths"
@ -861,7 +862,7 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
window.rootContainer.AddItem(window.dialogReplacement, 2, 0, false) window.rootContainer.AddItem(window.dialogReplacement, 2, 0, false)
if config.Current.ShowBottomBar { if config.Current.ShowBottomBar {
bottomBar := NewBottomBar() bottomBar := components.NewBottomBar()
bottomBar.AddItem(fmt.Sprintf("Logged in as: '%s'", tviewutil.Escape(session.State.User.Username))) bottomBar.AddItem(fmt.Sprintf("Logged in as: '%s'", tviewutil.Escape(session.State.User.Username)))
bottomBar.AddItem(fmt.Sprintf("View / Change shortcuts: %s", shortcutdialog.EventToString(shortcutsDialogShortcut))) bottomBar.AddItem(fmt.Sprintf("View / Change shortcuts: %s", shortcutdialog.EventToString(shortcutsDialogShortcut)))
window.rootContainer.AddItem(bottomBar, 1, 0, false) window.rootContainer.AddItem(bottomBar, 1, 0, false)
@ -2343,9 +2344,8 @@ func (window *Window) startEditingMessage(message *discordgo.Message) {
window.messageInput.SetText(message.Content) window.messageInput.SetText(message.Content)
window.messageInput.SetBorderColor(tcell.ColorYellow) window.messageInput.SetBorderColor(tcell.ColorYellow)
window.messageInput.SetBorderFocusColor(tcell.ColorYellow) window.messageInput.SetBorderFocusColor(tcell.ColorYellow)
if tview.IsVtxxx { //On Vtxxx the yellow color won't work, so we blink instead.
window.messageInput.SetBorderFocusAttributes(tcell.AttrBlink | tcell.AttrBold) window.messageInput.SetBorderBlinking(tview.IsVtxxx)
}
window.editingMessageID = &message.ID window.editingMessageID = &message.ID
window.app.SetFocus(window.messageInput.GetPrimitive()) window.app.SetFocus(window.messageInput.GetPrimitive())
} }
@ -2360,12 +2360,10 @@ func (window *Window) exitMessageEditMode() {
func (window *Window) exitMessageEditModeAndKeepText() { func (window *Window) exitMessageEditModeAndKeepText() {
window.editingMessageID = nil window.editingMessageID = nil
//On Vtxxx the yellow color won't work, so we blink instead.
window.messageInput.SetBorderBlinking(false)
window.messageInput.SetBorderColor(tview.Styles.BorderColor) window.messageInput.SetBorderColor(tview.Styles.BorderColor)
window.messageInput.SetBorderFocusColor(tview.Styles.BorderFocusColor) window.messageInput.SetBorderFocusColor(tview.Styles.BorderFocusColor)
if tview.IsVtxxx {
window.messageInput.SetBorderFocusAttributes(tcell.AttrBold)
window.messageInput.SetBorderAttributes(tcell.AttrNone)
}
} }
// ShowErrorDialog shows a simple error dialog that has only an Okay button, // ShowErrorDialog shows a simple error dialog that has only an Okay button,