summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2022-01-06 14:41:42 +0100
committertv <tv@krebsco.de>2022-01-06 14:45:50 +0100
commit77357335a3a88a4b93f91a46ab939a1a9b192977 (patch)
tree4b69e0db30fe7c93c272bfaff7f54b24bf00e8d4 /src
parent29749366052a8f6c05b314f1ff17201717855ad7 (diff)
RenderTreeView.renderFrom: admit <address>1.3.1
Diffstat (limited to 'src')
-rw-r--r--src/Much/RenderTreeView.hs25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/Much/RenderTreeView.hs b/src/Much/RenderTreeView.hs
index 6babb29..ebed6e0 100644
--- a/src/Much/RenderTreeView.hs
+++ b/src/Much/RenderTreeView.hs
@@ -212,8 +212,13 @@ renderDate now = \case
renderFrom :: Maybe T.Text -> Blessings String
renderFrom = \case
- Just fromLine -> Plain $ dropAddress $ T.unpack fromLine
- Nothing -> SGR [35,1] "Anonymous"
+ Just fromLine ->
+ Plain $
+ case readFrom (T.unpack fromLine) of
+ ("", address) -> address
+ (name, _) -> name
+ Nothing ->
+ SGR [35,1] "Anonymous"
renderTags :: State -> [Tag] -> Blessings String
@@ -230,8 +235,16 @@ renderTag state tag = case M.lookup tag $ runIdentity $ tagMap $ colorConfig sta
plain = Plain $ T.unpack $ fromMaybe tag $ M.lookup tag (aliases state)
-dropAddress :: String -> String
-dropAddress xs =
+readFrom :: String -> (String, String)
+readFrom xs =
case L.elemIndices '<' xs of
- [] -> xs
- is -> L.dropWhileEnd isSpace $ take (last is) xs
+ [] ->
+ ("", xs)
+ is ->
+ readName *** readAddress $ splitAt (last is - 1) xs
+ where
+ readAddress :: String -> String
+ readAddress = L.takeWhile (/='>') . dropWhile (=='<')
+
+ readName :: String -> String
+ readName = L.dropWhileEnd isSpace