summary refs log tree commit diff stats
path: root/commands
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-30 21:45:41 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-30 21:45:41 -0400
commit5d0402aeea1dcc69adb46227ab1cd73b5e768880 (patch)
treefeac387ac2441d36a8bca272efa182884c11f05c /commands
parent04d9ab3ce6b8161ef7bc0ec4e5011f6ceadb73b6 (diff)
downloadaerc-5d0402aeea1dcc69adb46227ab1cd73b5e768880.tar.gz
Add message view commands, :close
Diffstat (limited to 'commands')
-rw-r--r--commands/msgview/close.go21
-rw-r--r--commands/msgview/msgview.go16
-rw-r--r--commands/terminal/close.go5
3 files changed, 38 insertions, 4 deletions
diff --git a/commands/msgview/close.go b/commands/msgview/close.go
new file mode 100644
index 0000000..404bb1c
--- /dev/null
+++ b/commands/msgview/close.go
@@ -0,0 +1,21 @@
+package msgview
+
+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")
+	}
+	mv, _ := aerc.SelectedTab().(*widgets.MessageViewer)
+	aerc.RemoveTab(mv)
+	return nil
+}
+
diff --git a/commands/msgview/msgview.go b/commands/msgview/msgview.go
new file mode 100644
index 0000000..e3db828
--- /dev/null
+++ b/commands/msgview/msgview.go
@@ -0,0 +1,16 @@
+package msgview
+
+import (
+	"git.sr.ht/~sircmpwn/aerc2/commands"
+)
+
+var (
+	MessageViewCommands *commands.Commands
+)
+
+func register(name string, cmd commands.AercCommand) {
+	if MessageViewCommands == nil {
+		MessageViewCommands = commands.NewCommands()
+	}
+	MessageViewCommands.Register(name, cmd)
+}
diff --git a/commands/terminal/close.go b/commands/terminal/close.go
index 0a9d100..aee7f3e 100644
--- a/commands/terminal/close.go
+++ b/commands/terminal/close.go
@@ -14,10 +14,7 @@ func CommandClose(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: close")
 	}
-	term, ok := aerc.SelectedTab().(*widgets.Terminal)
-	if !ok {
-		return errors.New("Error: not a terminal")
-	}
+	term, _ := aerc.SelectedTab().(*widgets.Terminal)
 	term.Close(nil)
 	aerc.RemoveTab(term)
 	return nil
t/baremetal/313index-bounds-check.subx?h=main&id=a8dd0d40942485a65995ac59c3f1bc4a6727e236'>a8dd0d40 ^
28037488 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60