aerc

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

commit f406bf5a3bb953426a00f2feac1f2863a29ab269
parent 22f453f56a18da91c987baa3a47fa91f666d8b7a
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri, 15 Mar 2019 20:32:09 -0400

Add :quit command

Diffstat:
Maerc.go | 14+++++++++++---
Acommands/quit.go | 24++++++++++++++++++++++++
Mlib/ui/ui.go | 5-----
3 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/aerc.go b/aerc.go @@ -33,12 +33,20 @@ func main() { panic(err) } - var aerc *widgets.Aerc + var ( + aerc *widgets.Aerc + ui *libui.UI + ) aerc = widgets.NewAerc(conf, logger, func(cmd string) error { - return commands.ExecuteCommand(aerc, cmd) + err = commands.ExecuteCommand(aerc, cmd) + if _, ok := err.(commands.ErrorExit); ok { + ui.Exit = true + return nil + } + return err }) - ui, err := libui.Initialize(conf, aerc) + ui, err = libui.Initialize(conf, aerc) if err != nil { panic(err) } diff --git a/commands/quit.go b/commands/quit.go @@ -0,0 +1,24 @@ +package commands + +import ( + "errors" + + "git.sr.ht/~sircmpwn/aerc2/widgets" +) + +func init() { + Register("quit", ChangeQuit) +} + +type ErrorExit int + +func (err ErrorExit) Error() string { + return "exit" +} + +func ChangeQuit(aerc *widgets.Aerc, args []string) error { + if len(args) != 1 { + return errors.New("Usage: quit") + } + return ErrorExit(1) +} diff --git a/lib/ui/ui.go b/lib/ui/ui.go @@ -65,11 +65,6 @@ func (state *UI) Tick() bool { select { case event := <-state.tcEvents: switch event := event.(type) { - case *tcell.EventKey: - // TODO: temporary - if event.Key() == tcell.KeyEsc { - state.Exit = true - } case *tcell.EventResize: state.screen.Clear() width, height := event.Size()