summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-01-07 00:38:36 +0100
committertv <tv@shackspace.de>2015-01-07 00:47:06 +0100
commit9e22cbd730da34afa0f8d3c03b9cb7f61e83d5f5 (patch)
tree1ccabb3e061de55956c908bf3b20f6c4bce111d9
parent615f91d2db515ad387abcf7f7f50ef93be10163a (diff)
add treeViewId
-rw-r--r--TreeView.hs47
-rw-r--r--test5.hs3
2 files changed, 35 insertions, 15 deletions
diff --git a/TreeView.hs b/TreeView.hs
index a03b3ee..a878572 100644
--- a/TreeView.hs
+++ b/TreeView.hs
@@ -10,6 +10,7 @@ module TreeView
, fromSearchResults
, fromMessageForest
, fromMessageTree
+ , treeViewId
) where
@@ -36,28 +37,44 @@ data TreeView
instance Eq TreeView where
- TVMessage m1 == TVMessage m2 =
- m1 == m2
+ x1 == x2 = treeViewId x1 == treeViewId x2
- TVMessageHeaderField m1 mhf1 == TVMessageHeaderField m2 mhf2 =
- m1 == m2 && mhf1 == mhf2
- TVMessagePart m1 mp1 == TVMessagePart m2 mp2 =
- m1 == m2 && mp1 == mp2
+data TreeViewId
+ = TVIDMessage T.Text
+ | TVIDMessageHeaderField T.Text T.Text
+ | TVIDMessagePart T.Text Int
+ | TVIDMessageLine T.Text Int Int
+ | TVIDSearch T.Text
+ | TVIDSearchResult T.Text
+ deriving (Eq,Show)
- 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
+treeViewId :: TreeView -> TreeViewId
+treeViewId = \case
+ TVMessage m ->
+ TVIDMessage (fromMessage m)
- TVSearch s1 == TVSearch s2 =
- s1 == s2
+ TVMessageHeaderField m mhf ->
+ TVIDMessageHeaderField (fromMessage m) (CI.foldedCase mhf)
- TVSearchResult s1 == TVSearchResult s2 =
- s1 == s2
+ TVMessagePart m mp ->
+ TVIDMessagePart (fromMessage m) (partID mp)
- _ == _ = False
+ TVMessageLine m mp lineNr _ ->
+ TVIDMessageLine (fromMessage m) (partID mp) lineNr
+
+ TVMessageQuoteLine m mp lineNr _ ->
+ TVIDMessageLine (fromMessage m) (partID mp) lineNr
+
+ TVSearch s ->
+ TVIDSearch (T.pack s)
+
+ TVSearchResult sr ->
+ TVIDSearch (T.pack $ unThreadID $ searchThread sr)
+
+ where
+ fromMessage = T.pack . unMessageID . messageId
getMessage :: TreeView -> Maybe Message
diff --git a/test5.hs b/test5.hs
index f1516c3..b8071b1 100644
--- a/test5.hs
+++ b/test5.hs
@@ -237,6 +237,9 @@ keymap "\ESC[Z" = moveCursorUpToPrevUnread -- S-Tab
keymap "\t" = moveCursorDownToNextUnread
keymap "\DEL" = moveToParent -- backspace
+keymap "\ESC[11~" = \q@State{..} ->
+ return q { flashMessage = Plain $ show $ treeViewId $ Z.label cursor }
+
-- TODO Stuff Vim sends after exit (also there is more...)
keymap "\ESC[2;2R" = \q -> return q { flashMessage = flashMessage q <> " " <> Plain "stupid" }
keymap "\ESC[>85;95;0c" = \q -> return q { flashMessage = flashMessage q <> " " <> Plain "stupid" }