aerc

Working clone of aerc-mail.org
git clone git://git.danielmoch.com/aerc.git
Log | Files | Refs | README | LICENSE

commit 72e4b5e2b2e0de50b8572f195f73ccdd8e9d9461
parent 8fa458323058c8998408f88b80d07c687fccd521
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat, 11 May 2019 13:20:29 -0400

Refactor ctx stashing out of exline

Diffstat:
Mlib/ui/textinput.go | 2++
Mwidgets/exline.go | 10++--------
2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go @@ -57,6 +57,8 @@ func (ti *TextInput) Focus(focus bool) { if focus && ti.ctx != nil { cells := runewidth.StringWidth(string(ti.text[:ti.index])) ti.ctx.SetCursor(cells+1, 0) + } else if !focus && ti.ctx != nil { + ti.ctx.HideCursor() } } diff --git a/widgets/exline.go b/widgets/exline.go @@ -10,7 +10,6 @@ type ExLine struct { ui.Invalidatable cancel func() commit func(cmd string) - ctx *ui.Context input *ui.TextInput } @@ -32,7 +31,6 @@ func (ex *ExLine) Invalidate() { } func (ex *ExLine) Draw(ctx *ui.Context) { - ex.ctx = ctx // gross ex.input.Draw(ctx) } @@ -45,14 +43,10 @@ func (ex *ExLine) Event(event tcell.Event) bool { case *tcell.EventKey: switch event.Key() { case tcell.KeyEnter: - if ex.ctx != nil { - ex.ctx.HideCursor() - } + ex.input.Focus(false) ex.commit(ex.input.String()) case tcell.KeyEsc, tcell.KeyCtrlC: - if ex.ctx != nil { - ex.ctx.HideCursor() - } + ex.input.Focus(false) ex.cancel() default: return ex.input.Event(event)