From 7ade7aa2138b410d289e159408795ea74febf137 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 28 Dec 2014 21:17:22 +0100 Subject: colorize TVSearchResult & TVMessage --- TreeViewRaw.hs | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/TreeViewRaw.hs b/TreeViewRaw.hs index 9fc6c9e..114e75a 100644 --- a/TreeViewRaw.hs +++ b/TreeViewRaw.hs @@ -34,19 +34,34 @@ renderTreeView1 hasFocus = \case TVSearch s -> Plain s - TVSearchResult sr -> Plain $ - (padl 11 ' ' $ T.unpack $ Notmuch.searchDateRel sr) - ++ "(" - ++ (show $ Notmuch.searchMatched sr) - ++ ") " - ++ (T.unpack $ Notmuch.searchSubject sr) - -- ++ " " - -- ++ (let Notmuch.ThreadID tid = Notmuch.searchThread sr in tid) - - TVMessage m -> Plain $ - (Notmuch.unMessageID $ Notmuch.messageId m) - ++ " " - ++ T.unpack (T.intercalate (T.pack ",") $ Notmuch.messageTags m) + TVSearchResult sr -> + let c = case (hasFocus, "unread" `elem` Notmuch.searchTags sr) of + (False, False) -> SGR [38,5,240] + (False, True) -> SGR [38,5,250] + (True, False) -> SGR [38,5,088] + (True, True) -> SGR [38,5,160] + in c $ + Plain ( + (padl 11 ' ' $ T.unpack $ Notmuch.searchDateRel sr) + ++ " (" ++ (show $ Notmuch.searchMatched sr) ++ ") " + ++ (T.unpack $ Notmuch.searchSubject sr) + ++ " " + ) + <> + mconcat (L.intersperse " " (map (SGR [38,5,036] . Plain . T.unpack) $ Notmuch.searchTags sr)) + + TVMessage m -> + let c = case (hasFocus, "unread" `elem` Notmuch.messageTags m) of + (False, False) -> SGR [38,5,240] + (False, True) -> SGR [38,5,250] + (True, False) -> SGR [38,5,088] + (True, True) -> SGR [38,5,160] + in c $ + Plain ( + (Notmuch.unMessageID $ Notmuch.messageId m) + ++ " " + ++ T.unpack (T.intercalate (T.pack ",") $ Notmuch.messageTags m) + ) TVMessageHeaderField m fieldName -> Plain $ let k = T.unpack $ CI.original fieldName -- cgit v1.2.3