summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-12-28 21:17:22 +0100
committertv <tv@shackspace.de>2014-12-28 21:17:22 +0100
commit7ade7aa2138b410d289e159408795ea74febf137 (patch)
treef2054abb56f0a867cd15aeaac30f9062123cacd7
parent51e3df5fd288c72ab427dda980d6a9f2d6f8adf9 (diff)
colorize TVSearchResult & TVMessage
-rw-r--r--TreeViewRaw.hs41
1 files 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