From bc8698e1f088cf144a797d2d0b8f875138a79967 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Tue, 6 Aug 2024 21:55:50 +0200 Subject: aerc: add quake-mode terminal Add a drop-down (quake-mode) terminal which is a persistent terminal session that overlays aerc at the top and can be toggled on or off. Enable quake mode by setting [General].enable-quake-mode=true. The height of the drop-down terminal can be set with [ui].quake-terminal-height (default: 20). Toggling is hardcoded to the F1 key. Note that this key should not be used in your key bindings when you enable Quake mode. Signed-off-by: Koni Marti Tested-by: Inwit Acked-by: Robin Jarry --- app/aerc.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'app/aerc.go') diff --git a/app/aerc.go b/app/aerc.go index beef6328..107fc1f3 100644 --- a/app/aerc.go +++ b/app/aerc.go @@ -190,16 +190,15 @@ func (aerc *Aerc) Draw(ctx *ui.Context) { } aerc.grid.Draw(ctx) if aerc.dialog != nil { - if w, h := ctx.Width(), ctx.Height(); w > 8 && h > 4 { - if d, ok := aerc.dialog.(Dialog); ok { - xstart, width := d.ContextWidth() - ystart, height := d.ContextHeight() - aerc.dialog.Draw( - ctx.Subcontext(xstart(w), ystart(h), - width(w), height(h))) - } else { - aerc.dialog.Draw(ctx.Subcontext(4, h/2-2, w-8, 4)) - } + w, h := ctx.Width(), ctx.Height() + if d, ok := aerc.dialog.(Dialog); ok { + xstart, width := d.ContextWidth() + ystart, height := d.ContextHeight() + aerc.dialog.Draw( + ctx.Subcontext(xstart(w), ystart(h), + width(w), height(h))) + } else if w > 8 && h > 4 { + aerc.dialog.Draw(ctx.Subcontext(4, h/2-2, w-8, 4)) } } } @@ -329,6 +328,13 @@ func (aerc *Aerc) simulate(strokes []config.KeyStroke) { } func (aerc *Aerc) Event(event vaxis.Event) bool { + if config.General.QuakeMode { + if e, ok := event.(vaxis.Key); ok && e.MatchString("F1") { + ToggleQuake() + return true + } + } + if aerc.dialog != nil { return aerc.dialog.Event(event) } -- cgit