summary refs log tree commit diff stats
path: root/widgets
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-02-27 21:33:47 -0500
committerDrew DeVault <sir@cmpwn.com>2018-02-27 21:33:47 -0500
commitcea98463c9fa551c81407edefe48a4fb2763ced0 (patch)
tree0f17e361d1f9493a621280e57421c4c53bafd420 /widgets
parent30c85dd4ab090ee6cec154ecd451129ecd6f0edb (diff)
downloadaerc-cea98463c9fa551c81407edefe48a4fb2763ced0.tar.gz
Summon exline on demand
Diffstat (limited to 'widgets')
-rw-r--r--widgets/aerc.go35
1 files changed, 24 insertions, 11 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index beceb96..5563275 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -48,15 +48,6 @@ func NewAerc(logger *log.Logger) *Aerc {
 	statusline := NewStatusLine()
 	statusbar.Push(statusline)
 
-	exline := NewExLine(func(command string) {
-		statusline.Push(fmt.Sprintf("TODO: execute %s", command),
-			3 * time.Second)
-		statusbar.Pop()
-	}, func() {
-		statusbar.Pop()
-	})
-	statusbar.Push(exline)
-
 	go (func() {
 		for {
 			time.Sleep(1 * time.Second)
@@ -66,7 +57,6 @@ func NewAerc(logger *log.Logger) *Aerc {
 
 	return &Aerc{
 		grid:        grid,
-		interactive: exline,
 		statusbar:   statusbar,
 		statusline:  statusline,
 		tabs:        tabs,
@@ -86,5 +76,28 @@ func (aerc *Aerc) Draw(ctx *libui.Context) {
 }
 
 func (aerc *Aerc) Event(event tb.Event) bool {
-	return aerc.interactive.Event(event)
+	switch event.Type {
+	case tb.EventKey:
+		if event.Ch == ':' {
+			exline := NewExLine(func(command string) {
+				aerc.statusline.Push(fmt.Sprintf("TODO: execute %s", command),
+					3 * time.Second)
+				aerc.statusbar.Pop()
+				aerc.interactive = nil
+			}, func() {
+				aerc.statusbar.Pop()
+				aerc.interactive = nil
+			})
+			aerc.interactive = exline
+			aerc.statusbar.Push(exline)
+			return true
+		}
+		fallthrough
+	default:
+		if aerc.interactive != nil {
+			return aerc.interactive.Event(event)
+		} else {
+			return false
+		}
+	}
 }