diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-02-27 21:02:56 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-02-27 21:02:56 -0500 |
commit | a073d7613fac7c79b7909d93a0dd7bfea05d5c9d (patch) | |
tree | 32a7f15b637e56a5df0b2e59715f0e4e9f786c00 /widgets/exline.go | |
parent | 46756487fb56acf26122a7b5d46be2ff8ee3c051 (diff) | |
download | aerc-a073d7613fac7c79b7909d93a0dd7bfea05d5c9d.tar.gz |
Add statusline widget
Diffstat (limited to 'widgets/exline.go')
-rw-r--r-- | widgets/exline.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/widgets/exline.go b/widgets/exline.go index e13b50dc..05223717 100644 --- a/widgets/exline.go +++ b/widgets/exline.go @@ -9,21 +9,24 @@ import ( // TODO: history // TODO: tab completion -// TODO: commit -// TODO: cancel (via esc/ctrl+c) // TODO: scrolling type ExLine struct { command []rune - commit func(cmd *string) + commit func(cmd string) + cancel func() index int scroll int onInvalidate func(d ui.Drawable) } -func NewExLine() *ExLine { - return &ExLine{command: []rune{}} +func NewExLine(commit func (cmd string), cancel func()) *ExLine { + return &ExLine{ + cancel: cancel, + commit: commit, + command: []rune{}, + } } func (ex *ExLine) OnInvalidate(onInvalidate func(d ui.Drawable)) { @@ -118,6 +121,12 @@ func (ex *ExLine) Event(event tb.Event) bool { ex.Invalidate() case tb.KeyCtrlW: ex.deleteWord() + case tb.KeyEnter: + tb.HideCursor() + ex.commit(string(ex.command)) + case tb.KeyEsc, tb.KeyCtrlC: + tb.HideCursor() + ex.cancel() default: if event.Ch != 0 { ex.insert(event.Ch) |