summary refs log tree commit diff stats
path: root/widgets/aerc.go
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/aerc.go')
-rw-r--r--widgets/aerc.go46
1 files changed, 38 insertions, 8 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index af2d0df..8d456b1 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -94,6 +94,24 @@ func (aerc *Aerc) Draw(ctx *libui.Context) {
 	aerc.grid.Draw(ctx)
 }
 
+func (aerc *Aerc) getBindings() *config.KeyBindings {
+	switch aerc.SelectedTab().(type) {
+	case *AccountView:
+		return aerc.conf.Bindings.MessageList
+	default:
+		return aerc.conf.Bindings.Global
+	}
+}
+
+func (aerc *Aerc) simulate(strokes []config.KeyStroke) {
+	aerc.pendingKeys = []config.KeyStroke{}
+	for _, stroke := range strokes {
+		simulated := tcell.NewEventKey(
+			stroke.Key, stroke.Rune, tcell.ModNone)
+		aerc.Event(simulated)
+	}
+}
+
 func (aerc *Aerc) Event(event tcell.Event) bool {
 	if aerc.focused != nil {
 		return aerc.focused.Event(event)
@@ -105,18 +123,30 @@ func (aerc *Aerc) Event(event tcell.Event) bool {
 			Key:  event.Key(),
 			Rune: event.Rune(),
 		})
-		result, output := aerc.conf.Lbinds.GetBinding(aerc.pendingKeys)
+		bindings := aerc.getBindings()
+		incomplete := false
+		result, strokes := bindings.GetBinding(aerc.pendingKeys)
 		switch result {
 		case config.BINDING_FOUND:
-			aerc.pendingKeys = []config.KeyStroke{}
-			for _, stroke := range output {
-				simulated := tcell.NewEventKey(
-					stroke.Key, stroke.Rune, tcell.ModNone)
-				aerc.Event(simulated)
-			}
+			aerc.simulate(strokes)
+			return true
 		case config.BINDING_INCOMPLETE:
-			return false
+			incomplete = true
 		case config.BINDING_NOT_FOUND:
+		}
+		if bindings.Globals {
+			result, strokes = aerc.conf.Bindings.Global.
+				GetBinding(aerc.pendingKeys)
+			switch result {
+			case config.BINDING_FOUND:
+				aerc.simulate(strokes)
+				return true
+			case config.BINDING_INCOMPLETE:
+				incomplete = true
+			case config.BINDING_NOT_FOUND:
+			}
+		}
+		if !incomplete {
 			aerc.pendingKeys = []config.KeyStroke{}
 			if event.Rune() == ':' {
 				aerc.BeginExCommand()
ecs/aerc/blame/ui/account.go?h=0.5.2&id=3139148c7b9ad6ed4fb9cd8cd3e4160a9b9ee46f'>^
d24e471 ^


cfe8241 ^
d24e471 ^

cfe8241 ^

cc03f6f ^
cfe8241 ^




77a0f68 ^





77a0f68 ^





4074445 ^
77a0f68 ^


4074445 ^

55e8453 ^




77a0f68 ^
4074445 ^

d24e471 ^
3139148 ^

4074445 ^
d24e471 ^
3139148 ^

cc03f6f ^
3139148 ^



d24e471 ^
3139148 ^
cfe8241 ^
a21afda ^
d24e471 ^
3139148 ^
cfe8241 ^
a21afda ^
4074445 ^
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90