From 80e891a8024ac10a60daa790131e04f0326b0c73 Mon Sep 17 00:00:00 2001 From: Markus Ongyerth Date: Fri, 1 Jun 2018 09:58:00 +0200 Subject: 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 --- widgets/aerc.go | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'widgets/aerc.go') diff --git a/widgets/aerc.go b/widgets/aerc.go index 5563275..19ddfdd 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -5,7 +5,7 @@ import ( "log" "time" - tb "github.com/nsf/termbox-go" + "github.com/gdamore/tcell" 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 grid.AddChild(libui.NewText("aerc"). Strategy(libui.TEXT_CENTER). - Color(tb.ColorBlack, tb.ColorWhite)) + Color(tcell.ColorBlack, tcell.ColorWhite)) // sidebar placeholder: grid.AddChild(libui.NewBordered( 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) } -func (aerc *Aerc) Event(event tb.Event) bool { - switch event.Type { - case tb.EventKey: - if event.Ch == ':' { +func (aerc *Aerc) Event(event tcell.Event) bool { + switch event := event.(type) { + case *tcell.EventKey: + if event.Rune() == ':' { exline := NewExLine(func(command string) { aerc.statusline.Push(fmt.Sprintf("TODO: execute %s", command), 3 * time.Second) @@ -92,12 +92,10 @@ func (aerc *Aerc) Event(event tb.Event) bool { aerc.statusbar.Push(exline) return true } - fallthrough - default: - if aerc.interactive != nil { - return aerc.interactive.Event(event) - } else { - return false - } + } + if aerc.interactive != nil { + return aerc.interactive.Event(event) + } else { + return false } } -- cgit v1.2.3