aerc

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

commit 10dd23f05d271a27ad40a6fafffb5fe2c3e5fe57
parent 8126d82956636a2525263e2d0d985d721fdb8074
Author: Drew DeVault <sir@cmpwn.com>
Date:   Thu, 21 Mar 2019 16:32:22 -0400

Add terminal command context

Diffstat:
Maerc.go | 8+++++++-
Dcommands/term-close.go | 24------------------------
Acommands/terminal/close.go | 23+++++++++++++++++++++++
Acommands/terminal/terminal.go | 16++++++++++++++++
4 files changed, 46 insertions(+), 25 deletions(-)

diff --git a/aerc.go b/aerc.go @@ -12,6 +12,7 @@ import ( "git.sr.ht/~sircmpwn/aerc2/config" "git.sr.ht/~sircmpwn/aerc2/commands" "git.sr.ht/~sircmpwn/aerc2/commands/account" + "git.sr.ht/~sircmpwn/aerc2/commands/terminal" libui "git.sr.ht/~sircmpwn/aerc2/lib/ui" "git.sr.ht/~sircmpwn/aerc2/widgets" ) @@ -20,8 +21,13 @@ func getCommands(selected libui.Drawable) []*commands.Commands { switch selected.(type) { case *widgets.AccountView: return []*commands.Commands{ - commands.GlobalCommands, account.AccountCommands, + commands.GlobalCommands, + } + case *widgets.TermHost: + return []*commands.Commands{ + terminal.TerminalCommands, + commands.GlobalCommands, } default: return []*commands.Commands{commands.GlobalCommands} diff --git a/commands/term-close.go b/commands/term-close.go @@ -1,24 +0,0 @@ -package commands - -import ( - "errors" - - "git.sr.ht/~sircmpwn/aerc2/widgets" -) - -func init() { - // TODO: Move this command into a terminal-specific command set - register("close", TermClose) -} - -func TermClose(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 -} diff --git a/commands/terminal/close.go b/commands/terminal/close.go @@ -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 +} diff --git a/commands/terminal/terminal.go b/commands/terminal/terminal.go @@ -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) +}