summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TreeView.hs (renamed from ThreadView.hs)36
-rw-r--r--test3.hs22
2 files changed, 29 insertions, 29 deletions
diff --git a/ThreadView.hs b/TreeView.hs
index 2b1c1fb..89a4883 100644
--- a/ThreadView.hs
+++ b/TreeView.hs
@@ -2,7 +2,7 @@
{-# LANGUAGE LambdaCase #-}
-module ThreadView where
+module TreeView where
import Data.Default
import Graphics.Vty
@@ -37,7 +37,7 @@ import Safe
type LineNr = Int
-data ThreadView
+data TreeView
= TVMessage Message
| TVMessagePart Message MessagePart
| TVMessageLine Message MessagePart LineNr String
@@ -45,7 +45,7 @@ data ThreadView
| TVSearchResult SearchResult
deriving (Show)
-instance Eq ThreadView where
+instance Eq TreeView where
TVMessage m1 == TVMessage m2 =
m1 == m2
@@ -64,12 +64,12 @@ instance Eq ThreadView where
_ == _ = False
-isTVSearchResult :: ThreadView -> Bool
+isTVSearchResult :: TreeView -> Bool
isTVSearchResult (TVSearchResult _) = True
isTVSearchResult _ = False
-describe :: ThreadView -> String
+describe :: TreeView -> String
describe (TVMessage m) = "TVMessage " <> unMessageID (messageId m)
describe (TVMessagePart m p) = "TVMessagePart " <> (unMessageID $ messageId m) <> " " <> show (partID p)
describe (TVMessageLine _ _ _ s) = "TVMessageLine " <> show s
@@ -77,44 +77,44 @@ describe (TVSearch s) = "TVSearch " <> show s
describe (TVSearchResult sr) = "TVSearchResult " <> show (searchTotal sr)
-findMessage :: MessageID -> Tree ThreadView -> Maybe ThreadView
+findMessage :: MessageID -> Tree TreeView -> Maybe TreeView
findMessage i =
find p . flatten
where
p (TVMessage m) = i == messageId m
p _ = False
-findTV :: ThreadView -> Tree ThreadView -> Maybe ThreadView
+findTV :: TreeView -> Tree TreeView -> Maybe TreeView
findTV x =
find (==x) . flatten
-fromSearchResults :: String -> [SearchResult] -> Tree ThreadView
+fromSearchResults :: String -> [SearchResult] -> Tree TreeView
fromSearchResults query =
Node (TVSearch query) . map (\r -> Node (TVSearchResult r) [])
-fromMessageTree :: Tree Message -> Tree ThreadView
+fromMessageTree :: Tree Message -> Tree TreeView
fromMessageTree (Node m ms) =
Node m' ms'
where
- m' :: ThreadView
+ m' :: TreeView
m' = TVMessage m
- ms' :: Forest ThreadView
+ ms' :: Forest TreeView
ms' = if isOpen m
then xconvBody m <> map fromMessageTree ms
else map fromMessageTree ms
-xconvBody :: Message -> Forest ThreadView
+xconvBody :: Message -> Forest TreeView
xconvBody m = mconcat $ map (xconvPart m) (messageBody m)
-xconvPart :: Message -> MessagePart -> Forest ThreadView
+xconvPart :: Message -> MessagePart -> Forest TreeView
xconvPart m p = xconvPartContent m p $ partContent p
xconvPartContent
- :: Message -> MessagePart -> MessageContent -> Forest ThreadView
+ :: Message -> MessagePart -> MessageContent -> Forest TreeView
xconvPartContent m p = \case
ContentText t ->
map (xconvLine m p) $ zip [0..] (T.lines t)
@@ -125,20 +125,20 @@ xconvPartContent m p = \case
[Node (TVMessageLine m p 0 "ContentMsgRFC822") []]
-xconvPart2 :: Message -> MessagePart -> Tree ThreadView
+xconvPart2 :: Message -> MessagePart -> Tree TreeView
xconvPart2 m p =
Node (TVMessagePart m p) $ xconvPartContent m p (partContent p)
xconvLine
- :: Message -> MessagePart -> (LineNr, T.Text) -> Tree ThreadView
+ :: Message -> MessagePart -> (LineNr, T.Text) -> Tree TreeView
xconvLine m p (i, s) =
Node (TVMessageLine m p i $ T.unpack s) []
-threadViewImage :: Bool -> ThreadView -> Image
-threadViewImage hasFocus = \case
+treeViewImage :: Bool -> TreeView -> Image
+treeViewImage hasFocus = \case
TVMessage m ->
let col = if isOpen m then om else cm
in
diff --git a/test3.hs b/test3.hs
index 6de1617..e35db25 100644
--- a/test3.hs
+++ b/test3.hs
@@ -38,7 +38,7 @@ import Notmuch.SearchResult
import Control.Exception
-import ThreadView
+import TreeView
import TreeSearch
@@ -105,8 +105,8 @@ main =
rec vty 0 (Z.fromTree v)
--rec vty t_cur t = do
- --rec :: Vty -> Int -> Z.TreePos Z.Full ThreadView -> Tree ThreadView -> IO ()
- rec :: Vty -> Int -> Z.TreePos Z.Full ThreadView -> IO ()
+ --rec :: Vty -> Int -> Z.TreePos Z.Full TreeView -> Tree TreeView -> IO ()
+ rec :: Vty -> Int -> Z.TreePos Z.Full TreeView -> IO ()
rec vty i c = do
let
img =
@@ -117,7 +117,7 @@ main =
--string def (maybe "Nothing" describe (focusPrev v c)) <->
--string def (describe $ Z.label c) <->
--string def (maybe "Nothing" describe (focusNext v c)) <->
- threadImage (Just $ Z.label c) (Z.toTree c)
+ treeImage (Just $ Z.label c) (Z.toTree c)
pic = picForImage img
v = Z.root c
update vty pic
@@ -166,17 +166,17 @@ main =
rec vty 0 $ Z.modifyTree (\(Node l _) -> Node l t_) loc
-threadImage :: Maybe ThreadView -> Tree ThreadView -> Image
---threadImage t_cur (Node n ns) =
-threadImage c (Node n ns) =
+treeImage :: Maybe TreeView -> Tree TreeView -> Image
+--treeImage t_cur (Node n ns) =
+treeImage c (Node n ns) =
--messageImage hasFocus n
- --threadViewImage (hasFocus n) n
- threadViewImage (c == Just n) n
+ --treeViewImage (hasFocus n) n
+ treeViewImage (c == Just n) n
<->
- translateX 2 (vertCat $ map (threadImage c) ns)
+ translateX 2 (vertCat $ map (treeImage c) ns)
--where
-- --hasFocus = t_cur == messageId n
- -- hasFocus :: ThreadView -> Bool
+ -- hasFocus :: TreeView -> Bool
-- hasFocus (TVMessage m) = c == m
-- hasFocus _ = False