Add :quit command
This commit is contained in:
parent
22f453f56a
commit
f406bf5a3b
14
aerc.go
14
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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue