aboutsummaryrefslogtreecommitdiffstats
path: root/app/msglist.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2024-01-29 23:52:28 +0100
committerRobin Jarry <robin@jarry.cc>2024-02-11 22:03:56 +0100
commit05874f867c76c8e9b8c1e67a57dc702e63d6d54b (patch)
treeedb8ba9a4800511f30810c5be90a709df695147e /app/msglist.go
parent635fe05d4e8ee5a6dbadf7d10b6d8340efcbc84d (diff)
downloadaerc-05874f867c76c8e9b8c1e67a57dc702e63d6d54b.tar.gz
commands: add align
Add a new :align command that aligns the selected message vertically at the top, center, or bottom of the message list. The command requires a position argument that can either be: "top", "center", or "bottom". Create the following default keybinds: zz = :align center<Enter> zt = :align top<Enter> zb = :align bottom<Enter> Changelog-added: Add new `:align` command to align the selected message at the top, center, or bottom of the message list. Suggested-by: Ángel Castañeda <angel@acsq.me> Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'app/msglist.go')
-rw-r--r--app/msglist.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/msglist.go b/app/msglist.go
index a5e5fbb6..38970123 100644
--- a/app/msglist.go
+++ b/app/msglist.go
@@ -51,6 +51,23 @@ type messageRowParams struct {
headers *mail.Header
}
+// AlignMessage aligns the selected message to position pos.
+func (ml *MessageList) AlignMessage(pos AlignPosition) {
+ store := ml.Store()
+ if store == nil {
+ return
+ }
+ idx := 0
+ iter := store.UidsIterator()
+ for i := 0; iter.Next(); i++ {
+ if store.SelectedUid() == iter.Value().(uint32) {
+ idx = i
+ break
+ }
+ }
+ ml.Align(idx, pos)
+}
+
func (ml *MessageList) Draw(ctx *ui.Context) {
ml.height = ctx.Height()
ml.width = ctx.Width()