Summon exline on demand

This commit is contained in:
Drew DeVault 2018-02-27 21:33:47 -05:00
parent 30c85dd4ab
commit cea98463c9

View file

@ -48,15 +48,6 @@ func NewAerc(logger *log.Logger) *Aerc {
statusline := NewStatusLine() statusline := NewStatusLine()
statusbar.Push(statusline) statusbar.Push(statusline)
exline := NewExLine(func(command string) {
statusline.Push(fmt.Sprintf("TODO: execute %s", command),
3 * time.Second)
statusbar.Pop()
}, func() {
statusbar.Pop()
})
statusbar.Push(exline)
go (func() { go (func() {
for { for {
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
@ -66,7 +57,6 @@ func NewAerc(logger *log.Logger) *Aerc {
return &Aerc{ return &Aerc{
grid: grid, grid: grid,
interactive: exline,
statusbar: statusbar, statusbar: statusbar,
statusline: statusline, statusline: statusline,
tabs: tabs, tabs: tabs,
@ -86,5 +76,28 @@ func (aerc *Aerc) Draw(ctx *libui.Context) {
} }
func (aerc *Aerc) Event(event tb.Event) bool { func (aerc *Aerc) Event(event tb.Event) bool {
switch event.Type {
case tb.EventKey:
if event.Ch == ':' {
exline := NewExLine(func(command string) {
aerc.statusline.Push(fmt.Sprintf("TODO: execute %s", command),
3 * time.Second)
aerc.statusbar.Pop()
aerc.interactive = nil
}, func() {
aerc.statusbar.Pop()
aerc.interactive = nil
})
aerc.interactive = exline
aerc.statusbar.Push(exline)
return true
}
fallthrough
default:
if aerc.interactive != nil {
return aerc.interactive.Event(event) return aerc.interactive.Event(event)
} else {
return false
}
}
} }