diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-03-17 17:23:53 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-03-17 17:23:53 -0400 |
commit | dee0f8938b62d668ed9105c96313fbd8b8bbd098 (patch) | |
tree | 2a6d9f1a427d7c4c4dabd371cff5ca0f3fb5ad70 /commands/term-close.go | |
parent | 16c3f0a89309541e36a2de22e91176fd13c67898 (diff) | |
download | aerc-dee0f8938b62d668ed9105c96313fbd8b8bbd098.tar.gz |
Add :term-close
Diffstat (limited to 'commands/term-close.go')
-rw-r--r-- | commands/term-close.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/commands/term-close.go b/commands/term-close.go new file mode 100644 index 00000000..38fcc27f --- /dev/null +++ b/commands/term-close.go @@ -0,0 +1,29 @@ +package commands + +import ( + "errors" + + "git.sr.ht/~sircmpwn/aerc2/lib/ui" + "git.sr.ht/~sircmpwn/aerc2/widgets" +) + +func init() { + Register("term-close", TermClose) +} + +func TermClose(aerc *widgets.Aerc, args []string) error { + if len(args) != 1 { + return errors.New("Usage: term-close") + } + grid, ok := aerc.SelectedTab().(*ui.Grid) + if !ok { + return errors.New("Error: not a terminal") + } + for _, child := range grid.Children() { + if term, ok := child.(*widgets.Terminal); ok { + term.Close(nil) + return nil + } + } + return errors.New("Error: not a terminal") +} |