summaryrefslogtreecommitdiffstats
path: root/TreeView.hs
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-01-01 23:53:30 +0100
committertv <tv@shackspace.de>2015-01-01 23:53:30 +0100
commit5d556b147a593f1b8c8127883055ad07ee347af9 (patch)
tree6697766faff1510492cb1c7f38c8fc1790838add /TreeView.hs
parent67aa6764bfafabda51eb270e01aaf0fc638f380f (diff)
colorize quoted lines
Diffstat (limited to 'TreeView.hs')
-rw-r--r--TreeView.hs20
1 files changed, 19 insertions, 1 deletions
diff --git a/TreeView.hs b/TreeView.hs
index 4edf9b3..6397c4f 100644
--- a/TreeView.hs
+++ b/TreeView.hs
@@ -27,6 +27,7 @@ data TreeView
= TVMessage Message
| TVMessageHeaderField Message (CI.CI T.Text)
| TVMessagePart Message MessagePart
+ | TVMessageQuoteLine Message MessagePart LineNr String
| TVMessageLine Message MessagePart LineNr String
| TVSearch String
| TVSearchResult SearchResult
@@ -46,6 +47,9 @@ instance Eq TreeView where
TVMessageLine m1 mp1 ln1 _s1 == TVMessageLine m2 mp2 ln2 _s2 =
m1 == m2 && mp1 == mp2 && ln1 == ln2
+ TVMessageQuoteLine m1 mp1 ln1 _s1 == TVMessageQuoteLine m2 mp2 ln2 _s2 =
+ m1 == m2 && mp1 == mp2 && ln1 == ln2
+
TVSearch s1 == TVSearch s2 =
s1 == s2
@@ -60,6 +64,7 @@ getMessage = \case
TVMessage m -> Just m
TVMessageHeaderField m _ -> Just m
TVMessagePart m _ -> Just m
+ TVMessageQuoteLine m _ _ _ -> Just m
TVMessageLine m _ _ _ -> Just m
_ -> Nothing
@@ -127,4 +132,17 @@ xconvPart2 m p =
xconvLine
:: Message -> MessagePart -> (LineNr, T.Text) -> Tree TreeView
xconvLine m p (i, s) =
- Node (TVMessageLine m p i $ T.unpack s) []
+ Node (ctor m p i $ T.unpack s) []
+ where
+ ctor =
+ if isQuoteLine s
+ then TVMessageQuoteLine
+ else TVMessageLine
+
+
+isQuoteLine :: T.Text -> Bool
+isQuoteLine s0 = do
+ let s = T.stripStart s0
+
+ -- /^\s*>/
+ not (T.null s) && T.head s == '>'