Add terminal command context

This commit is contained in:
Drew DeVault 2019-03-21 16:32:22 -04:00
parent 8126d82956
commit 10dd23f05d
3 changed files with 26 additions and 5 deletions
commands/terminal

View file

@ -0,0 +1,23 @@
package terminal
import (
"errors"
"git.sr.ht/~sircmpwn/aerc2/widgets"
)
func init() {
register("close", CommandClose)
}
func CommandClose(aerc *widgets.Aerc, args []string) error {
if len(args) != 1 {
return errors.New("Usage: close")
}
thost, ok := aerc.SelectedTab().(*widgets.TermHost)
if !ok {
return errors.New("Error: not a terminal")
}
thost.Terminal().Close(nil)
return nil
}

View file

@ -0,0 +1,16 @@
package terminal
import (
"git.sr.ht/~sircmpwn/aerc2/commands"
)
var (
TerminalCommands *commands.Commands
)
func register(name string, cmd commands.AercCommand) {
if TerminalCommands == nil {
TerminalCommands = commands.NewCommands()
}
TerminalCommands.Register(name, cmd)
}