diff options
author | inwit <inwit@sindominio.net> | 2024-01-29 20:45:47 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-01-29 22:45:25 +0100 |
commit | 0c2af2e354541632c708a1a7d6eb04c1e2a951ae (patch) | |
tree | 94bf8c468cc2ab423294630055a696dbb3a8014e /app/msglist.go | |
parent | c48d27b07b90fab54198287c552646607f401228 (diff) | |
download | aerc-0c2af2e354541632c708a1a7d6eb04c1e2a951ae.tar.gz |
ui: allow thread arrow customization
The thread prefix appearance is inspired by mutt and has been regarded
by some as too wide and not very aesthetically pleasing. Nevertheless,
it has some technical limitations, like not being able to show if a
thread is folded.
Allow for full customisation of the thread prefix by introducing 14 new
config options.
Dirlist is not affected.
Changelog-added: Thread arrow prefixes are now fully configurable.
Co-authored-by: Robin Jarry <robin@jarry.cc>
Signed-off-by: inwit <inwit@sindominio.net>
Tested-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'app/msglist.go')
-rw-r--r-- | app/msglist.go | 91 |
1 files changed, 72 insertions, 19 deletions
diff --git a/app/msglist.go b/app/msglist.go index 7948e6a1..63089536 100644 --- a/app/msglist.go +++ b/app/msglist.go @@ -417,36 +417,89 @@ func unreadInThread(thread *types.Thread, store *lib.MessageStore) (ctr int) { return } -func threadPrefix(t *types.Thread, reverse bool, point bool) string { - var arrow string - var tip string - if point { - tip = ">" - } - arrowPrefixSibling := "├─" + tip - arrowPrefixReverse := "┌─" + tip - arrowPrefixEnd := "└─" + tip - arrowStem := "│" - arrowIndent := strings.Repeat(" ", runewidth.StringWidth(arrowPrefixSibling)-1) +func threadPrefix(t *types.Thread, reverse bool, msglist bool) string { + uiConfig := SelectedAccountUiConfig() + var tip, prefix, firstChild, lastSibling, orphan string + if msglist { + tip = uiConfig.ThreadPrefixTip + } else { + threadPrefixSibling := "├─" + threadPrefixReverse := "┌─" + threadPrefixEnd := "└─" + threadStem := "│" + threadIndent := strings.Repeat(" ", runewidth.StringWidth(threadPrefixSibling)-1) + + switch { + case t.Parent != nil && t.NextSibling != nil: + prefix += threadPrefixSibling + case t.Parent != nil && reverse: + prefix += threadPrefixReverse + case t.Parent != nil: + prefix += threadPrefixEnd + } + + for n := t.Parent; n != nil && n.Parent != nil; n = n.Parent { + if n.NextSibling != nil { + prefix = threadStem + threadIndent + prefix + } else { + prefix = " " + threadIndent + prefix + } + } + + return prefix + } + + if reverse { + firstChild = uiConfig.ThreadPrefixFirstChildReverse + lastSibling = uiConfig.ThreadPrefixLastSiblingReverse + orphan = uiConfig.ThreadPrefixOrphanReverse + } else { + firstChild = uiConfig.ThreadPrefixFirstChild + lastSibling = uiConfig.ThreadPrefixLastSibling + orphan = uiConfig.ThreadPrefixOrphan + } + + var hiddenOffspring bool = t.FirstChild != nil && t.FirstChild.Hidden > 0 + var parentAndSiblings bool = t.Parent != nil && t.NextSibling != nil switch { - case t.Parent != nil && t.NextSibling != nil: - arrow += arrowPrefixSibling - case t.Parent != nil && reverse: - arrow += arrowPrefixReverse + case parentAndSiblings && hiddenOffspring: + prefix = uiConfig.ThreadPrefixHasSiblings + + uiConfig.ThreadPrefixFolded + case parentAndSiblings && t.FirstChild != nil: + prefix = uiConfig.ThreadPrefixHasSiblings + + firstChild + tip + case parentAndSiblings: + prefix = uiConfig.ThreadPrefixHasSiblings + + uiConfig.ThreadPrefixLimb + + uiConfig.ThreadPrefixUnfolded + tip + case t.Parent != nil && hiddenOffspring: + prefix = lastSibling + uiConfig.ThreadPrefixFolded + case t.Parent != nil && t.FirstChild != nil: + prefix = lastSibling + firstChild + tip + case t.Parent != nil && t.FirstChild == nil: + prefix = lastSibling + uiConfig.ThreadPrefixLimb + tip case t.Parent != nil: - arrow += arrowPrefixEnd + prefix = lastSibling + uiConfig.ThreadPrefixUnfolded + + uiConfig.ThreadPrefixTip + case t.Parent == nil && hiddenOffspring: + prefix = uiConfig.ThreadPrefixFolded + case t.Parent == nil && t.FirstChild != nil: + prefix = orphan + case t.Parent == nil && t.FirstChild == nil: + prefix = uiConfig.ThreadPrefixLone } for n := t.Parent; n != nil && n.Parent != nil; n = n.Parent { if n.NextSibling != nil { - arrow = arrowStem + arrowIndent + arrow + prefix = uiConfig.ThreadPrefixStem + + uiConfig.ThreadPrefixIndent + prefix } else { - arrow = " " + arrowIndent + arrow + prefix = " " + uiConfig.ThreadPrefixIndent + prefix } } - return arrow + return prefix } func sameParent(left, right *types.Thread) bool { |