From 10dd23f05d271a27ad40a6fafffb5fe2c3e5fe57 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 21 Mar 2019 16:32:22 -0400 Subject: Add terminal command context --- commands/term-close.go | 24 ------------------------ commands/terminal/close.go | 23 +++++++++++++++++++++++ commands/terminal/terminal.go | 16 ++++++++++++++++ 3 files changed, 39 insertions(+), 24 deletions(-) delete mode 100644 commands/term-close.go create mode 100644 commands/terminal/close.go create mode 100644 commands/terminal/terminal.go (limited to 'commands') diff --git a/commands/term-close.go b/commands/term-close.go deleted file mode 100644 index 7da4f42..0000000 --- a/commands/term-close.go +++ /dev/null @@ -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 new file mode 100644 index 0000000..68be6ac --- /dev/null +++ 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 new file mode 100644 index 0000000..f438582 --- /dev/null +++ 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) +} -- cgit v1.2.3