about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-21 16:32:22 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-21 16:32:22 -0400
commit10dd23f05d271a27ad40a6fafffb5fe2c3e5fe57 (patch)
treea2fe85d9e0de5a972bfa7705558e7d50e95445c3
parent8126d82956636a2525263e2d0d985d721fdb8074 (diff)
downloadaerc-10dd23f05d271a27ad40a6fafffb5fe2c3e5fe57.tar.gz
Add terminal command context
-rw-r--r--aerc.go8
-rw-r--r--commands/terminal/close.go (renamed from commands/term-close.go)7
-rw-r--r--commands/terminal/terminal.go16
3 files changed, 26 insertions, 5 deletions
diff --git a/aerc.go b/aerc.go
index d086f85..c2bc69c 100644
--- 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/terminal/close.go
index 7da4f42..68be6ac 100644
--- a/commands/term-close.go
+++ b/commands/terminal/close.go
@@ -1,4 +1,4 @@
-package commands
+package terminal
 
 import (
 	"errors"
@@ -7,11 +7,10 @@ import (
 )
 
 func init() {
-	// TODO: Move this command into a terminal-specific command set
-	register("close", TermClose)
+	register("close", CommandClose)
 }
 
-func TermClose(aerc *widgets.Aerc, args []string) error {
+func CommandClose(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: close")
 	}
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)
+}