summaryrefslogtreecommitdiff
path: root/widgets/status.go
diff options
context:
space:
mode:
authorMarkus Ongyerth <aerc@ongy.net>2018-06-01 09:58:00 +0200
committerDrew DeVault <sir@cmpwn.com>2018-06-01 16:04:43 -0700
commit80e891a8024ac10a60daa790131e04f0326b0c73 (patch)
tree7a07cc26b2885e43e57e1672d2895c7fae2b173e /widgets/status.go
parent3836d240c9aa26615e7d768a57436d171edc3831 (diff)
downloadaerc-80e891a8024ac10a60daa790131e04f0326b0c73.zip
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
Diffstat (limited to 'widgets/status.go')
-rw-r--r--widgets/status.go30
1 files changed, 13 insertions, 17 deletions
diff --git a/widgets/status.go b/widgets/status.go
index bb87d33..3b4dbcc 100644
--- a/widgets/status.go
+++ b/widgets/status.go
@@ -3,7 +3,7 @@ package widgets
import (
"time"
- tb "github.com/nsf/termbox-go"
+ "github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc2/lib/ui"
)
@@ -16,16 +16,16 @@ type StatusLine struct {
}
type StatusMessage struct {
- bg tb.Attribute
- fg tb.Attribute
+ bg tcell.Color
+ fg tcell.Color
message string
}
func NewStatusLine() *StatusLine {
return &StatusLine{
fallback: StatusMessage{
- bg: tb.ColorWhite,
- fg: tb.ColorBlack,
+ bg: tcell.ColorWhite,
+ fg: tcell.ColorBlack,
message: "Idle",
},
}
@@ -46,19 +46,15 @@ func (status *StatusLine) Draw(ctx *ui.Context) {
if len(status.stack) != 0 {
line = status.stack[len(status.stack)-1]
}
- cell := tb.Cell{
- Fg: line.fg,
- Bg: line.bg,
- Ch: ' ',
- }
- ctx.Fill(0, 0, ctx.Width(), ctx.Height(), cell)
- ctx.Printf(0, 0, cell, "%s", line.message)
+ style := tcell.StyleDefault.Background(line.bg).Foreground(line.fg)
+ ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', style)
+ ctx.Printf(0, 0, style, "%s", line.message)
}
func (status *StatusLine) Set(text string) *StatusMessage {
status.fallback = StatusMessage{
- bg: tb.ColorWhite,
- fg: tb.ColorBlack,
+ bg: tcell.ColorWhite,
+ fg: tcell.ColorBlack,
message: text,
}
status.Invalidate()
@@ -67,8 +63,8 @@ func (status *StatusLine) Set(text string) *StatusMessage {
func (status *StatusLine) Push(text string, expiry time.Duration) *StatusMessage {
msg := &StatusMessage{
- bg: tb.ColorWhite,
- fg: tb.ColorBlack,
+ bg: tcell.ColorWhite,
+ fg: tcell.ColorBlack,
message: text,
}
status.stack = append(status.stack, msg)
@@ -85,7 +81,7 @@ func (status *StatusLine) Push(text string, expiry time.Duration) *StatusMessage
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.fg = fg
}