Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Update to tcell v2.0.0 #358

Merged
merged 2 commits into from Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/theme.go
Expand Up @@ -7,7 +7,7 @@ import (
"path/filepath"

"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
Expand Down
2 changes: 1 addition & 1 deletion femto/cellview.go
@@ -1,7 +1,7 @@
package femto

import (
"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth"
)

Expand Down
2 changes: 1 addition & 1 deletion femto/colorscheme.go
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"strings"

"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
)

// Colorscheme is a map from string to style -- it represents a colorscheme
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -10,7 +10,7 @@ require (
github.com/alecthomas/chroma v0.6.6
github.com/atotto/clipboard v0.1.2
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/google/go-github/v29 v29.0.3
github.com/lucasb-eyer/go-colorful v1.0.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -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/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.4.0 h1:vUnHwJRvcPQa3tzi+0QI4U9JINXYJlOz9yiaiPQ2wMU=
github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0=
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/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/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE=
Expand Down
2 changes: 1 addition & 1 deletion shortcuts/shortcuts.go
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"path/filepath"

"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"

"github.com/Bios-Marcel/cordless/config"
"github.com/Bios-Marcel/cordless/tview"
Expand Down
2 changes: 1 addition & 1 deletion tools/keyevents/main.go
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion tools/layout/main.go
Expand Up @@ -2,7 +2,7 @@ package main

import (
"github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion tools/theme/theme.go
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"

"github.com/Bios-Marcel/cordless/config"
)
Expand Down
2 changes: 1 addition & 1 deletion tview/application.go
Expand Up @@ -3,7 +3,7 @@ package tview
import (
"sync"

"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
)

// The size of the event/update/redraw channels.
Expand Down
90 changes: 36 additions & 54 deletions tview/box.go
@@ -1,7 +1,7 @@
package tview

import (
"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
)

// Box implements Primitive with a background and optional elements such as a
Expand Down Expand Up @@ -41,11 +41,7 @@ type Box struct {
// The color of the border when the box has focus.
borderFocusColor tcell.Color

// The style attributes of the border.
borderAttributes tcell.AttrMask

// The style attributes of the border when the box has focus.
borderFocusAttributes tcell.AttrMask
borderBlinking bool

// 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
Expand Down Expand Up @@ -99,7 +95,6 @@ func NewBox() *Box {
backgroundColor: Styles.PrimitiveBackgroundColor,
borderColor: Styles.BorderColor,
borderFocusColor: Styles.BorderFocusColor,
borderFocusAttributes: tcell.AttrNone,
titleColor: Styles.TitleColor,
titleAlign: AlignCenter,
borderTop: true,
Expand All @@ -110,10 +105,6 @@ func NewBox() *Box {
nextFocusableComponents: make(map[FocusDirection][]Primitive),
}

if IsVtxxx {
b.borderFocusAttributes = tcell.AttrBold
}

b.focus = b
return b
}
Expand Down Expand Up @@ -346,21 +337,8 @@ func (b *Box) IsBorderLeft() bool {
return b.border && b.borderLeft
}

// SetBorderAttributes sets the border's style attributes. You can combine
// different attributes using bitmask operations:
//
// 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
func (b *Box) SetBorderBlinking(blinking bool) *Box {
b.borderBlinking = blinking
return b
}

Expand Down Expand Up @@ -402,16 +380,20 @@ func (b *Box) Draw(screen tcell.Screen) bool {

// Draw border.
if b.border && b.width >= 2 && b.height >= 1 {
var border tcell.Style
var borderStyle tcell.Style
if b.hasFocus {
if b.borderFocusAttributes != 0 {
border = background.Foreground(b.borderFocusColor) | tcell.Style(b.borderFocusAttributes)
} else {
border = background.Foreground(b.borderFocusColor) | tcell.Style(b.borderAttributes)
borderStyle = background.Foreground(b.borderFocusColor)
if IsVtxxx {
borderStyle = borderStyle.Bold(true)
}
} 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

horizontal = Borders.Horizontal
Expand All @@ -424,82 +406,82 @@ func (b *Box) Draw(screen tcell.Screen) bool {
//Special case in order to render only the title-line of something properly.
if b.borderTop {
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 {
screen.SetContent(b.x, b.y, topLeft, nil, border)
screen.SetContent(b.x, b.y, topLeft, nil, borderStyle)
} else {
screen.SetContent(b.x, b.y, horizontal, nil, border)
screen.SetContent(b.x, b.y, horizontal, nil, borderStyle)
}

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 {
screen.SetContent(b.x+b.width-1, b.y, horizontal, nil, border)
screen.SetContent(b.x+b.width-1, b.y, horizontal, nil, borderStyle)
}
}

//Special case in order to render only the title-line of something properly.
if b.height > 1 {
if b.borderBottom {
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 {
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 {
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 {
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 {
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 {
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 {
screen.SetContent(b.x, b.y, topLeft, nil, border)
screen.SetContent(b.x, b.y, topLeft, nil, borderStyle)
} else {
screen.SetContent(b.x, b.y, vertical, nil, border)
screen.SetContent(b.x, b.y, vertical, nil, borderStyle)
}

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 {
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 {
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 {
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 {
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 {
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 {
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 {
if b.borderLeft {
screen.SetContent(b.x, b.y, vertical, nil, border)
screen.SetContent(b.x, b.y, vertical, nil, borderStyle)
}
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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tview/button.go
@@ -1,7 +1,7 @@
package tview

import (
"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
)

// Button is labeled box that triggers an action when selected.
Expand Down
2 changes: 1 addition & 1 deletion tview/checkbox.go
@@ -1,7 +1,7 @@
package tview

import (
"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
)

// Checkbox implements a simple box for boolean values which can be checked and
Expand Down
2 changes: 0 additions & 2 deletions tview/demos/box/main.go
Expand Up @@ -2,14 +2,12 @@
package main

import (
"github.com/gdamore/tcell"
"github.com/Bios-Marcel/cordless/tview"
)

func main() {
box := tview.NewBox().
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")
if err := tview.NewApplication().SetRoot(box, true).Run(); err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion tview/demos/frame/main.go
Expand Up @@ -2,7 +2,7 @@
package main

import (
"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview"
)

Expand Down
2 changes: 1 addition & 1 deletion tview/demos/inputfield-paste/main.go
Expand Up @@ -2,7 +2,7 @@ package main

import (
"github.com/Bios-Marcel/cordless/tview"
"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion tview/demos/inputfield/main.go
Expand Up @@ -2,7 +2,7 @@
package main

import (
"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview"
)

Expand Down
2 changes: 1 addition & 1 deletion tview/demos/modal/main.go
Expand Up @@ -4,7 +4,7 @@ package main
import (
"strings"

"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"

"github.com/Bios-Marcel/cordless/tview"
)
Expand Down
2 changes: 1 addition & 1 deletion tview/demos/presentation/colors.go
Expand Up @@ -3,7 +3,7 @@ package main
import (
"strings"

"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview"
)

Expand Down
2 changes: 1 addition & 1 deletion tview/demos/presentation/cover.go
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview"
)

Expand Down
2 changes: 1 addition & 1 deletion tview/demos/presentation/end.go
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview"
)

Expand Down
2 changes: 1 addition & 1 deletion tview/demos/presentation/flex.go
@@ -1,7 +1,7 @@
package main

import (
"github.com/gdamore/tcell"
tcell "github.com/gdamore/tcell/v2"
"github.com/Bios-Marcel/cordless/tview"
)

Expand Down