diff options
Diffstat (limited to 'src/Much')
-rw-r--r-- | src/Much/Action.hs | 8 | ||||
-rw-r--r-- | src/Much/Core.hs | 2 | ||||
-rw-r--r-- | src/Much/TreeView.hs | 22 |
3 files changed, 24 insertions, 8 deletions
diff --git a/src/Much/Action.hs b/src/Much/Action.hs index 6613eb1..d76e503 100644 --- a/src/Much/Action.hs +++ b/src/Much/Action.hs @@ -3,15 +3,15 @@ {-# LANGUAGE RecordWildCards #-} module Much.Action where -import Blessings.String +import Blessings.String.WCWidth import Data.Maybe +import Data.Tree.Extra (setSubForest) import Scanner import Much.State import Much.TagUtils import Much.TreeSearch import Much.TreeView import Much.TreeZipperUtils -import qualified Data.Tree as Tree import qualified Data.Tree.Zipper as Z import qualified Notmuch import qualified Notmuch.Message as Notmuch @@ -216,7 +216,3 @@ topOverrun State{..} = botOverrun :: State -> Int botOverrun State{..} = max 0 (linearPos cursor - yoffset - (screenHeight - length headBuffer - 1)) - - -setSubForest :: Tree.Forest a -> Tree.Tree a -> Tree.Tree a -setSubForest sf t = t { Tree.subForest = sf } diff --git a/src/Much/Core.hs b/src/Much/Core.hs index 2ce5ad7..1c8daa7 100644 --- a/src/Much/Core.hs +++ b/src/Much/Core.hs @@ -4,7 +4,7 @@ {-# LANGUAGE RecordWildCards #-} module Much.Core where -import Blessings.String (Blessings(Plain,SGR),pp) +import Blessings.String.WCWidth (Blessings(Plain,SGR),pp) import Control.Concurrent import Control.Monad import Data.Aeson diff --git a/src/Much/TreeView.hs b/src/Much/TreeView.hs index e963497..9b309bc 100644 --- a/src/Much/TreeView.hs +++ b/src/Much/TreeView.hs @@ -25,6 +25,8 @@ import Notmuch import Notmuch.Message import Notmuch.SearchResult import Much.TreeView.Types as Export +import System.Exit (ExitCode(ExitSuccess)) +import System.Process.ByteString.Lazy (readProcessWithExitCode) getMessage :: TreeView -> Maybe Message @@ -144,8 +146,26 @@ loadSubForest = \case . findFirsts messageMatch <$> notmuchShow (termFromMessage m) + TVMessagePart m mp@MessagePart{partContentType="text/html"} -> + notmuchShowPartRaw (termFromMessage m) (partID mp) >>= \case + Left e -> return $ Left $ show e + Right html -> + readProcessWithExitCode + "lynx" + [ "-dump" + , "-nomargins" + , "-stdin" + ] + html + >>= \case + (ExitSuccess, out, _err) -> + return $ Right $ + zipWith (\i s -> Node (TVMessageLine m mp i s) []) [0..] (lines . LBS8.unpack $ out) + + (exitCode, _out, err) -> + return $ Left $ show exitCode <> ": " <> LBS8.unpack err + TVMessagePart m mp -> - -- TODO parse --format=raw notmuchShowPart (termFromMessage m) (partID mp) >>= return . \case Left e -> Left $ show e Right mp' -> |