switch to tcell from termbox

This is a simple mostly straight forward switch to tcell in favor of
termbox.
It uses the tcell native api (not the compat layer) but does not make
use of most features.

Further changes should include moving to tcell's views.TextArea and the
general built in widget behaviour instead of the current ad hoc
implementation.

Regression: Cursor isn't shown in ex-line
This commit is contained in:
Markus Ongyerth 2018-06-01 09:58:00 +02:00 committed by Drew DeVault
parent 3836d240c9
commit 80e891a802
12 changed files with 151 additions and 159 deletions

1
go.mod
View File

@ -6,4 +6,5 @@ require (
"github.com/mattn/go-isatty" v0.0.3 "github.com/mattn/go-isatty" v0.0.3
"github.com/mattn/go-runewidth" v0.0.2 "github.com/mattn/go-runewidth" v0.0.2
"github.com/nsf/termbox-go" v0.0.0-20180129072728-88b7b944be8b "github.com/nsf/termbox-go" v0.0.0-20180129072728-88b7b944be8b
"github.com/gdamore/tcell" v1.0.0
) )

View File

@ -1,7 +1,7 @@
package ui package ui
import ( import (
tb "github.com/nsf/termbox-go" "github.com/gdamore/tcell"
) )
const ( const (
@ -45,27 +45,23 @@ func (bordered *Bordered) Draw(ctx *Context) {
y := 0 y := 0
width := ctx.Width() width := ctx.Width()
height := ctx.Height() height := ctx.Height()
cell := tb.Cell{ style := tcell.StyleDefault.Background(tcell.ColorWhite).Foreground(tcell.ColorBlack)
Ch: ' ',
Fg: tb.ColorBlack,
Bg: tb.ColorWhite,
}
if bordered.borders&BORDER_LEFT != 0 { if bordered.borders&BORDER_LEFT != 0 {
ctx.Fill(0, 0, 1, ctx.Height(), cell) ctx.Fill(0, 0, 1, ctx.Height(), ' ', style)
x += 1 x += 1
width -= 1 width -= 1
} }
if bordered.borders&BORDER_TOP != 0 { if bordered.borders&BORDER_TOP != 0 {
ctx.Fill(0, 0, ctx.Width(), 1, cell) ctx.Fill(0, 0, ctx.Width(), 1, ' ', style)
y += 1 y += 1
height -= 1 height -= 1
} }
if bordered.borders&BORDER_RIGHT != 0 { if bordered.borders&BORDER_RIGHT != 0 {
ctx.Fill(ctx.Width()-1, 0, 1, ctx.Height(), cell) ctx.Fill(ctx.Width()-1, 0, 1, ctx.Height(), ' ', style)
width -= 1 width -= 1
} }
if bordered.borders&BORDER_BOTTOM != 0 { if bordered.borders&BORDER_BOTTOM != 0 {
ctx.Fill(0, ctx.Height()-1, ctx.Width(), 1, cell) ctx.Fill(0, ctx.Height()-1, ctx.Width(), 1, ' ', style)
height -= 1 height -= 1
} }
subctx := ctx.Subcontext(x, y, width, height) subctx := ctx.Subcontext(x, y, width, height)

View File

@ -4,73 +4,77 @@ import (
"fmt" "fmt"
"github.com/mattn/go-runewidth" "github.com/mattn/go-runewidth"
tb "github.com/nsf/termbox-go" "github.com/gdamore/tcell"
"github.com/gdamore/tcell/views"
) )
// A context allows you to draw in a sub-region of the terminal // A context allows you to draw in a sub-region of the terminal
type Context struct { type Context struct {
x int viewport *views.ViewPort
y int
width int
height int
} }
func (ctx *Context) X() int { func (ctx *Context) X() int {
return ctx.x x, _, _, _ := ctx.viewport.GetPhysical()
return x
} }
func (ctx *Context) Y() int { func (ctx *Context) Y() int {
return ctx.y _, y, _, _ := ctx.viewport.GetPhysical()
return y
} }
func (ctx *Context) Width() int { func (ctx *Context) Width() int {
return ctx.width width, _ := ctx.viewport.Size()
return width
} }
func (ctx *Context) Height() int { func (ctx *Context) Height() int {
return ctx.height _, height := ctx.viewport.Size()
return height
} }
func NewContext(width, height int) *Context { func NewContext(width, height int, screen tcell.Screen) *Context {
return &Context{0, 0, width, height} vp := views.NewViewPort(screen, 0, 0, width, height)
return &Context{vp}
} }
func (ctx *Context) Subcontext(x, y, width, height int) *Context { func (ctx *Context) Subcontext(x, y, width, height int) *Context {
if x+width > ctx.width || y+height > ctx.height { vp_width, vp_height := ctx.viewport.Size()
if (x < 0 || y < 0) {
panic(fmt.Errorf("Attempted to create context with negative offset"))
}
if (x + width > vp_width || y + height > vp_height) {
panic(fmt.Errorf("Attempted to create context larger than parent")) panic(fmt.Errorf("Attempted to create context larger than parent"))
} }
return &Context{ vp := views.NewViewPort(ctx.viewport, x, y, width, height)
x: ctx.x + x, return &Context{vp}
y: ctx.y + y,
width: width,
height: height,
}
} }
func (ctx *Context) SetCell(x, y int, ch rune, fg, bg tb.Attribute) { func (ctx *Context) SetCell(x, y int, ch rune, style tcell.Style) {
if x >= ctx.width || y >= ctx.height { width, height := ctx.viewport.Size()
if x >= width || y >= height {
panic(fmt.Errorf("Attempted to draw outside of context")) panic(fmt.Errorf("Attempted to draw outside of context"))
} }
tb.SetCell(ctx.x+x, ctx.y+y, ch, fg, bg) crunes := []rune{}
ctx.viewport.SetContent(x, y, ch, crunes, style)
} }
func (ctx *Context) Printf(x, y int, ref tb.Cell, func (ctx *Context) Printf(x, y int, style tcell.Style,
format string, a ...interface{}) int { format string, a ...interface{}) int {
width, height := ctx.viewport.Size()
if x >= ctx.width || y >= ctx.height { if x >= width || y >= height {
panic(fmt.Errorf("Attempted to draw outside of context")) panic(fmt.Errorf("Attempted to draw outside of context"))
} }
str := fmt.Sprintf(format, a...) str := fmt.Sprintf(format, a...)
x += ctx.x
y += ctx.y
old_x := x old_x := x
newline := func() bool { newline := func() bool {
x = old_x x = old_x
y++ y++
return y < ctx.height return y < height
} }
for _, ch := range str { for _, ch := range str {
if str == " こんにちは " { if str == " こんにちは " {
@ -84,9 +88,10 @@ func (ctx *Context) Printf(x, y int, ref tb.Cell,
case '\r': case '\r':
x = old_x x = old_x
default: default:
tb.SetCell(x, y, ch, ref.Fg, ref.Bg) crunes := []rune{}
ctx.viewport.SetContent(x, y, ch, crunes, style)
x += runewidth.RuneWidth(ch) x += runewidth.RuneWidth(ch)
if x == old_x+ctx.width { if x == old_x + width {
if !newline() { if !newline() {
return runewidth.StringWidth(str) return runewidth.StringWidth(str)
} }
@ -97,13 +102,20 @@ func (ctx *Context) Printf(x, y int, ref tb.Cell,
return runewidth.StringWidth(str) return runewidth.StringWidth(str)
} }
func (ctx *Context) Fill(x, y, width, height int, ref tb.Cell) { //func (ctx *Context) Screen() tcell.Screen {
_x := x // return ctx.screen
_y := y //}
for ; y < _y+height && y < ctx.height; y++ {
for ; x < _x+width && x < ctx.width; x++ { func (ctx *Context) Fill(x, y, width, height int, rune rune, style tcell.Style) {
ctx.SetCell(x, y, ref.Ch, ref.Fg, ref.Bg) vp := views.NewViewPort(ctx.viewport, x, y, width, height)
} vp.Fill(rune, style)
x = _x }
}
func (ctx *Context) SetCursor(x, y int) {
// FIXME: Cursor needs to be set on tcell.Screen, or layout has to
// provide a CellModel
// cv := views.NewCellView()
// cv.Init()
// cv.SetView(ctx.viewport)
// cv.SetCursor(x, y)
} }

View File

@ -1,7 +1,7 @@
package ui package ui
import ( import (
tb "github.com/nsf/termbox-go" "github.com/gdamore/tcell"
) )
type Fill rune type Fill rune
@ -13,7 +13,7 @@ func NewFill(f rune) Fill {
func (f Fill) Draw(ctx *Context) { func (f Fill) Draw(ctx *Context) {
for x := 0; x < ctx.Width(); x += 1 { for x := 0; x < ctx.Width(); x += 1 {
for y := 0; y < ctx.Height(); y += 1 { for y := 0; y < ctx.Height(); y += 1 {
ctx.SetCell(x, y, rune(f), tb.ColorDefault, tb.ColorDefault) ctx.SetCell(x, y, rune(f), tcell.StyleDefault)
} }
} }
} }

View File

@ -1,17 +1,17 @@
package ui package ui
import ( import (
tb "github.com/nsf/termbox-go" "github.com/gdamore/tcell"
) )
type Interactive interface { type Interactive interface {
// Returns true if the event was handled by this component // Returns true if the event was handled by this component
Event(event tb.Event) bool Event(event tcell.Event) bool
} }
type Simulator interface { type Simulator interface {
// Queues up the given input events for simulation // Queues up the given input events for simulation
Simulate(events []tb.Event) Simulate(events []tcell.Event)
} }
type DrawableInteractive interface { type DrawableInteractive interface {

View File

@ -3,7 +3,7 @@ package ui
import ( import (
"fmt" "fmt"
tb "github.com/nsf/termbox-go" "github.com/gdamore/tcell"
) )
type Stack struct { type Stack struct {
@ -29,12 +29,7 @@ func (stack *Stack) Draw(ctx *Context) {
if len(stack.children) > 0 { if len(stack.children) > 0 {
stack.Peek().Draw(ctx) stack.Peek().Draw(ctx)
} else { } else {
cell := tb.Cell{ ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
Fg: tb.ColorDefault,
Bg: tb.ColorDefault,
Ch: ' ',
}
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), cell)
} }
} }

View File

@ -1,7 +1,7 @@
package ui package ui
import ( import (
tb "github.com/nsf/termbox-go" "github.com/gdamore/tcell"
) )
type Tabs struct { type Tabs struct {
@ -72,21 +72,14 @@ func (tabs *Tabs) Select(index int) {
func (strip *TabStrip) Draw(ctx *Context) { func (strip *TabStrip) Draw(ctx *Context) {
x := 0 x := 0
for i, tab := range strip.Tabs { for i, tab := range strip.Tabs {
cell := tb.Cell{ style := tcell.StyleDefault.Background(tcell.ColorWhite).Foreground(tcell.ColorBlack)
Fg: tb.ColorBlack,
Bg: tb.ColorWhite,
}
if strip.Selected == i { if strip.Selected == i {
cell.Fg = tb.ColorDefault style = style.Reverse(true)
cell.Bg = tb.ColorDefault
} }
x += ctx.Printf(x, 0, cell, " %s ", tab.Name) x += ctx.Printf(x, 0, style, " %s ", tab.Name)
} }
cell := tb.Cell{ style := tcell.StyleDefault.Background(tcell.ColorWhite).Foreground(tcell.ColorBlack)
Fg: tb.ColorBlack, ctx.Fill(x, 0, ctx.Width()-x, 1, ' ', style)
Bg: tb.ColorWhite,
}
ctx.Fill(x, 0, ctx.Width()-x, 1, cell)
} }
func (strip *TabStrip) Invalidate() { func (strip *TabStrip) Invalidate() {

View File

@ -2,7 +2,7 @@ package ui
import ( import (
"github.com/mattn/go-runewidth" "github.com/mattn/go-runewidth"
tb "github.com/nsf/termbox-go" "github.com/gdamore/tcell"
) )
const ( const (
@ -14,8 +14,8 @@ const (
type Text struct { type Text struct {
text string text string
strategy uint strategy uint
fg tb.Attribute fg tcell.Color
bg tb.Attribute bg tcell.Color
onInvalidate func(d Drawable) onInvalidate func(d Drawable)
} }
@ -35,7 +35,7 @@ func (t *Text) Strategy(strategy uint) *Text {
return t return t
} }
func (t *Text) Color(fg tb.Attribute, bg tb.Attribute) *Text { func (t *Text) Color(fg tcell.Color, bg tcell.Color) *Text {
t.fg = fg t.fg = fg
t.bg = bg t.bg = bg
t.Invalidate() t.Invalidate()
@ -44,11 +44,6 @@ func (t *Text) Color(fg tb.Attribute, bg tb.Attribute) *Text {
func (t *Text) Draw(ctx *Context) { func (t *Text) Draw(ctx *Context) {
size := runewidth.StringWidth(t.text) size := runewidth.StringWidth(t.text)
cell := tb.Cell{
Ch: ' ',
Fg: t.fg,
Bg: t.bg,
}
x := 0 x := 0
if t.strategy == TEXT_CENTER { if t.strategy == TEXT_CENTER {
x = (ctx.Width() - size) / 2 x = (ctx.Width() - size) / 2
@ -56,8 +51,9 @@ func (t *Text) Draw(ctx *Context) {
if t.strategy == TEXT_RIGHT { if t.strategy == TEXT_RIGHT {
x = ctx.Width() - size x = ctx.Width() - size
} }
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), cell) style := tcell.StyleDefault.Background(t.bg).Foreground(t.fg)
ctx.Printf(x, 0, cell, "%s", t.text) ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', style)
ctx.Printf(x, 0, style, t.text)
} }
func (t *Text) OnInvalidate(onInvalidate func(d Drawable)) { func (t *Text) OnInvalidate(onInvalidate func(d Drawable)) {

View File

@ -1,7 +1,7 @@
package ui package ui
import ( import (
tb "github.com/nsf/termbox-go" "github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc2/config" "git.sr.ht/~sircmpwn/aerc2/config"
) )
@ -10,30 +10,41 @@ type UI struct {
Exit bool Exit bool
Content DrawableInteractive Content DrawableInteractive
ctx *Context ctx *Context
screen tcell.Screen
tbEvents chan tb.Event tcEvents chan tcell.Event
invalidations chan interface{} invalidations chan interface{}
} }
func Initialize(conf *config.AercConfig, func Initialize(conf *config.AercConfig,
content DrawableInteractive) (*UI, error) { content DrawableInteractive) (*UI, error) {
if err := tb.Init(); err != nil { screen, err := tcell.NewScreen()
if err != nil {
return nil, err return nil, err
} }
width, height := tb.Size()
if err = screen.Init(); err != nil {
return nil, err
}
screen.Clear()
screen.HideCursor()
width, height := screen.Size()
state := UI{ state := UI{
Content: content, Content: content,
ctx: NewContext(width, height), ctx: NewContext(width, height, screen),
screen: screen,
tbEvents: make(chan tb.Event, 10), tcEvents: make(chan tcell.Event, 10),
invalidations: make(chan interface{}), invalidations: make(chan interface{}),
} }
tb.SetInputMode(tb.InputEsc | tb.InputMouse) //tb.SetOutputMode(tb.Output256)
tb.SetOutputMode(tb.Output256)
go (func() { go (func() {
for !state.Exit { for !state.Exit {
state.tbEvents <- tb.PollEvent() state.tcEvents <- screen.PollEvent()
} }
})() })()
go (func() { state.invalidations <- nil })() go (func() { state.invalidations <- nil })()
@ -44,27 +55,28 @@ func Initialize(conf *config.AercConfig,
} }
func (state *UI) Close() { func (state *UI) Close() {
tb.Close() state.screen.Fini()
} }
func (state *UI) Tick() bool { func (state *UI) Tick() bool {
select { select {
case event := <-state.tbEvents: case event := <-state.tcEvents:
switch event.Type { switch event := event.(type) {
case tb.EventKey: case *tcell.EventKey:
// TODO: temporary // TODO: temporary
if event.Key == tb.KeyEsc { if event.Key() == tcell.KeyEsc {
state.Exit = true state.Exit = true
} }
case tb.EventResize: case *tcell.EventResize:
tb.Clear(tb.ColorDefault, tb.ColorDefault) state.screen.Clear()
state.ctx = NewContext(event.Width, event.Height) width, height := event.Size()
state.ctx = NewContext(width, height, state.screen)
state.Content.Invalidate() state.Content.Invalidate()
} }
state.Content.Event(event) state.Content.Event(event)
case <-state.invalidations: case <-state.invalidations:
state.Content.Draw(state.ctx) state.Content.Draw(state.ctx)
tb.Flush() state.screen.Show()
default: default:
return false return false
} }

View File

@ -5,7 +5,7 @@ import (
"log" "log"
"time" "time"
tb "github.com/nsf/termbox-go" "github.com/gdamore/tcell"
libui "git.sr.ht/~sircmpwn/aerc2/lib/ui" libui "git.sr.ht/~sircmpwn/aerc2/lib/ui"
) )
@ -35,7 +35,7 @@ func NewAerc(logger *log.Logger) *Aerc {
// TODO: move sidebar into tab content, probably // TODO: move sidebar into tab content, probably
grid.AddChild(libui.NewText("aerc"). grid.AddChild(libui.NewText("aerc").
Strategy(libui.TEXT_CENTER). Strategy(libui.TEXT_CENTER).
Color(tb.ColorBlack, tb.ColorWhite)) Color(tcell.ColorBlack, tcell.ColorWhite))
// sidebar placeholder: // sidebar placeholder:
grid.AddChild(libui.NewBordered( grid.AddChild(libui.NewBordered(
libui.NewFill('.'), libui.BORDER_RIGHT)).At(1, 0).Span(2, 1) libui.NewFill('.'), libui.BORDER_RIGHT)).At(1, 0).Span(2, 1)
@ -75,10 +75,10 @@ func (aerc *Aerc) Draw(ctx *libui.Context) {
aerc.grid.Draw(ctx) aerc.grid.Draw(ctx)
} }
func (aerc *Aerc) Event(event tb.Event) bool { func (aerc *Aerc) Event(event tcell.Event) bool {
switch event.Type { switch event := event.(type) {
case tb.EventKey: case *tcell.EventKey:
if event.Ch == ':' { if event.Rune() == ':' {
exline := NewExLine(func(command string) { exline := NewExLine(func(command string) {
aerc.statusline.Push(fmt.Sprintf("TODO: execute %s", command), aerc.statusline.Push(fmt.Sprintf("TODO: execute %s", command),
3 * time.Second) 3 * time.Second)
@ -92,12 +92,10 @@ func (aerc *Aerc) Event(event tb.Event) bool {
aerc.statusbar.Push(exline) aerc.statusbar.Push(exline)
return true return true
} }
fallthrough }
default: if aerc.interactive != nil {
if aerc.interactive != nil { return aerc.interactive.Event(event)
return aerc.interactive.Event(event) } else {
} else { return false
return false
}
} }
} }

View File

@ -2,7 +2,7 @@ package widgets
import ( import (
"github.com/mattn/go-runewidth" "github.com/mattn/go-runewidth"
tb "github.com/nsf/termbox-go" "github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc2/lib/ui" "git.sr.ht/~sircmpwn/aerc2/lib/ui"
) )
@ -40,15 +40,10 @@ func (ex *ExLine) Invalidate() {
} }
func (ex *ExLine) Draw(ctx *ui.Context) { func (ex *ExLine) Draw(ctx *ui.Context) {
cell := tb.Cell{ ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
Fg: tb.ColorDefault, ctx.Printf(0, 0, tcell.StyleDefault, ":%s", string(ex.command))
Bg: tb.ColorDefault,
Ch: ' ',
}
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), cell)
ctx.Printf(0, 0, cell, ":%s", string(ex.command))
cells := runewidth.StringWidth(string(ex.command[:ex.index])) cells := runewidth.StringWidth(string(ex.command[:ex.index]))
tb.SetCursor(ctx.X()+cells+1, ctx.Y()) ctx.SetCursor(cells + 1, 0)
} }
func (ex *ExLine) insert(ch rune) { func (ex *ExLine) insert(ch rune) {
@ -93,43 +88,41 @@ func (ex *ExLine) backspace() {
} }
} }
func (ex *ExLine) Event(event tb.Event) bool { func (ex *ExLine) Event(event tcell.Event) bool {
switch event.Type { switch event := event.(type) {
case tb.EventKey: case *tcell.EventKey:
switch event.Key { switch event.Key() {
case tb.KeySpace: case tcell.KeyBackspace, tcell.KeyBackspace2:
ex.insert(' ')
case tb.KeyBackspace, tb.KeyBackspace2:
ex.backspace() ex.backspace()
case tb.KeyCtrlD, tb.KeyDelete: case tcell.KeyCtrlD, tcell.KeyDelete:
ex.deleteChar() ex.deleteChar()
case tb.KeyCtrlB, tb.KeyArrowLeft: case tcell.KeyCtrlB, tcell.KeyLeft:
if ex.index > 0 { if ex.index > 0 {
ex.index-- ex.index--
ex.Invalidate() ex.Invalidate()
} }
case tb.KeyCtrlF, tb.KeyArrowRight: case tcell.KeyCtrlF, tcell.KeyRight:
if ex.index < len(ex.command) { if ex.index < len(ex.command) {
ex.index++ ex.index++
ex.Invalidate() ex.Invalidate()
} }
case tb.KeyCtrlA, tb.KeyHome: case tcell.KeyCtrlA, tcell.KeyHome:
ex.index = 0 ex.index = 0
ex.Invalidate() ex.Invalidate()
case tb.KeyCtrlE, tb.KeyEnd: case tcell.KeyCtrlE, tcell.KeyEnd:
ex.index = len(ex.command) ex.index = len(ex.command)
ex.Invalidate() ex.Invalidate()
case tb.KeyCtrlW: case tcell.KeyCtrlW:
ex.deleteWord() ex.deleteWord()
case tb.KeyEnter: case tcell.KeyEnter:
tb.HideCursor() //ex.ctx.Screen().HideCursor()
ex.commit(string(ex.command)) ex.commit(string(ex.command))
case tb.KeyEsc, tb.KeyCtrlC: case tcell.KeyEsc, tcell.KeyCtrlC:
tb.HideCursor() //ex.ctx.Screen().HideCursor()
ex.cancel() ex.cancel()
default: default:
if event.Ch != 0 { if event.Rune() != 0 {
ex.insert(event.Ch) ex.insert(event.Rune())
} }
} }
} }

View File

@ -3,7 +3,7 @@ package widgets
import ( import (
"time" "time"
tb "github.com/nsf/termbox-go" "github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc2/lib/ui" "git.sr.ht/~sircmpwn/aerc2/lib/ui"
) )
@ -16,16 +16,16 @@ type StatusLine struct {
} }
type StatusMessage struct { type StatusMessage struct {
bg tb.Attribute bg tcell.Color
fg tb.Attribute fg tcell.Color
message string message string
} }
func NewStatusLine() *StatusLine { func NewStatusLine() *StatusLine {
return &StatusLine{ return &StatusLine{
fallback: StatusMessage{ fallback: StatusMessage{
bg: tb.ColorWhite, bg: tcell.ColorWhite,
fg: tb.ColorBlack, fg: tcell.ColorBlack,
message: "Idle", message: "Idle",
}, },
} }
@ -46,19 +46,15 @@ func (status *StatusLine) Draw(ctx *ui.Context) {
if len(status.stack) != 0 { if len(status.stack) != 0 {
line = status.stack[len(status.stack)-1] line = status.stack[len(status.stack)-1]
} }
cell := tb.Cell{ style := tcell.StyleDefault.Background(line.bg).Foreground(line.fg)
Fg: line.fg, ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', style)
Bg: line.bg, ctx.Printf(0, 0, style, "%s", line.message)
Ch: ' ',
}
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), cell)
ctx.Printf(0, 0, cell, "%s", line.message)
} }
func (status *StatusLine) Set(text string) *StatusMessage { func (status *StatusLine) Set(text string) *StatusMessage {
status.fallback = StatusMessage{ status.fallback = StatusMessage{
bg: tb.ColorWhite, bg: tcell.ColorWhite,
fg: tb.ColorBlack, fg: tcell.ColorBlack,
message: text, message: text,
} }
status.Invalidate() status.Invalidate()
@ -67,8 +63,8 @@ func (status *StatusLine) Set(text string) *StatusMessage {
func (status *StatusLine) Push(text string, expiry time.Duration) *StatusMessage { func (status *StatusLine) Push(text string, expiry time.Duration) *StatusMessage {
msg := &StatusMessage{ msg := &StatusMessage{
bg: tb.ColorWhite, bg: tcell.ColorWhite,
fg: tb.ColorBlack, fg: tcell.ColorBlack,
message: text, message: text,
} }
status.stack = append(status.stack, msg) status.stack = append(status.stack, msg)
@ -85,7 +81,7 @@ func (status *StatusLine) Push(text string, expiry time.Duration) *StatusMessage
return msg return msg
} }
func (msg *StatusMessage) Color(bg tb.Attribute, fg tb.Attribute) { func (msg *StatusMessage) Color(bg tcell.Color, fg tcell.Color) {
msg.bg = bg msg.bg = bg
msg.fg = fg msg.fg = fg
} }