diff options
author | Kierán Meinhardt <kieran.meinhardt@gmail.com> | 2020-09-23 17:44:40 +0200 |
---|---|---|
committer | Kierán Meinhardt <kieran.meinhardt@gmail.com> | 2020-09-23 17:44:40 +0200 |
commit | 8e92e6e11d2b3b0bfb5ac9d68f347219493e6380 (patch) | |
tree | 6484ca42d85ca89475e922f7b45039c116ebbf97 | |
parent | 6a6ad3aecd53ffd89101a0dee2b4ea576d4964d4 (diff) |
split into library + executables
-rw-r--r-- | config/kmein.hs | 10 | ||||
-rw-r--r-- | config/tv.hs | 16 | ||||
-rw-r--r-- | much.cabal | 129 | ||||
-rw-r--r-- | src/Codec/MIME/Base64.hs (renamed from Codec/MIME/Base64.hs) | 19 | ||||
-rw-r--r-- | src/Codec/MIME/Decode.hs (renamed from Codec/MIME/Decode.hs) | 0 | ||||
-rw-r--r-- | src/Codec/MIME/Parse.hs (renamed from Codec/MIME/Parse.hs) | 0 | ||||
-rw-r--r-- | src/Codec/MIME/QuotedPrintable.hs (renamed from Codec/MIME/QuotedPrintable.hs) | 0 | ||||
-rw-r--r-- | src/Codec/MIME/Type.hs (renamed from Codec/MIME/Type.hs) | 0 | ||||
-rw-r--r-- | src/Codec/MIME/Utils.hs (renamed from Codec/MIME/Utils.hs) | 0 | ||||
-rw-r--r-- | src/Data/Aeson/Extends.hs (renamed from Data/Aeson/Extends.hs) | 0 | ||||
-rw-r--r-- | src/Much/Action.hs (renamed from Action.hs) | 12 | ||||
-rw-r--r-- | src/Much/Core.hs (renamed from Core.hs) | 18 | ||||
-rw-r--r-- | src/Much/Event.hs (renamed from Event.hs) | 2 | ||||
-rw-r--r-- | src/Much/MBox.hs (renamed from MBox.hs) | 2 | ||||
-rw-r--r-- | src/Much/MappedSets.hs (renamed from MappedSets.hs) | 2 | ||||
-rw-r--r-- | src/Much/ParseMail.hs (renamed from ParseMail.hs) | 2 | ||||
-rw-r--r-- | src/Much/RenderTreeView.hs (renamed from RenderTreeView.hs) | 18 | ||||
-rw-r--r-- | src/Much/Screen.hs (renamed from Screen.hs) | 2 | ||||
-rw-r--r-- | src/Much/State.hs (renamed from State.hs) | 4 | ||||
-rw-r--r-- | src/Much/TagUtils.hs (renamed from TagUtils.hs) | 4 | ||||
-rw-r--r-- | src/Much/TreeSearch.hs (renamed from TreeSearch.hs) | 2 | ||||
-rw-r--r-- | src/Much/TreeView.hs (renamed from TreeView.hs) | 4 | ||||
-rw-r--r-- | src/Much/TreeView/Types.hs (renamed from TreeView/Types.hs) | 2 | ||||
-rw-r--r-- | src/Much/TreeZipperUtils.hs (renamed from TreeZipperUtils.hs) | 2 | ||||
-rw-r--r-- | src/Much/Utils.hs (renamed from Utils.hs) | 2 | ||||
-rw-r--r-- | src/Network/Mail/Mime.hs (renamed from Network/Mail/Mime.hs) | 0 | ||||
-rw-r--r-- | src/Notmuch.hs (renamed from Notmuch.hs) | 4 | ||||
-rw-r--r-- | src/Notmuch/Class.hs (renamed from Notmuch/Class.hs) | 0 | ||||
-rw-r--r-- | src/Notmuch/Message.hs (renamed from Notmuch/Message.hs) | 0 | ||||
-rw-r--r-- | src/Notmuch/SearchResult.hs (renamed from Notmuch/SearchResult.hs) | 0 |
30 files changed, 159 insertions, 97 deletions
diff --git a/config/kmein.hs b/config/kmein.hs index 0ffdba1..1483df2 100644 --- a/config/kmein.hs +++ b/config/kmein.hs @@ -3,9 +3,11 @@ module Main (main) where -import Action -import Core -import State +import Much.Action +import Much.Core +import Much.State +import Much.TreeView +import qualified Notmuch.Message as Notmuch import Blessings.String import Control.Monad @@ -14,10 +16,8 @@ import Scanner import System.Posix.Signals import Text.Hyphenation import Text.LineBreak -import TreeView import qualified Data.Tree as Tree import qualified Data.Tree.Zipper as Z -import qualified Notmuch.Message as Notmuch {- notmuch's special tags are: diff --git a/config/tv.hs b/config/tv.hs index b2ff124..a00756d 100644 --- a/config/tv.hs +++ b/config/tv.hs @@ -4,7 +4,7 @@ module Main (main) where -import Action +import Much.Action import Blessings.String import Control.Concurrent import Control.DeepSeq (rnf) @@ -12,28 +12,28 @@ import Control.Exception import Control.Monad import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Except -import Core +import Much.Core import Data.Aeson (eitherDecode') import Data.CaseInsensitive (CI) import Data.Foldable (foldrM) import Data.List (intercalate) import Data.Maybe import Data.Time -import ParseMail (readMail) +import Much.ParseMail (readMail) import Safe import Scanner -import State +import Much.State import System.Directory import System.Environment import System.Exit import System.IO import System.Process -import TagUtils +import Much.TagUtils import Text.Hyphenation import Text.LineBreak -import TreeSearch -import TreeView -import Utils +import Much.TreeSearch +import Much.TreeView +import Much.Utils import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy.Char8 as LBS8 import qualified Data.CaseInsensitive as CI @@ -6,38 +6,101 @@ maintainer: tv@krebsco.de build-type: Simple cabal-version: >=1.10 -executable much - main-is: test5.hs - build-depends: base - , aeson - , attoparsec - , base64-bytestring - , blaze-builder - , blessings - , bytestring - , case-insensitive - , containers - , deepseq - , directory - , docopt - , email-header - , filepath - , friendly-time - , hyphenation - , linebreak - , old-locale - , process - , random - , rosezipper - , safe - , scanner - , split - , terminal-size - , text - , time - , transformers - , transformers-compat - , unix - , vector +executable much-tv + hs-source-dirs: config + main-is: tv.hs + default-language: Haskell2010 + ghc-options: -O2 -threaded -with-rtsopts=-N + build-depends: much + , base + , blessings + , deepseq + , transformers + , aeson + , case-insensitive + , time + , safe + , scanner + , directory + , hyphenation + , linebreak + , bytestring + , process + , text + , containers + , rosezipper + +executable much-kmein + hs-source-dirs: config + main-is: kmein.hs + default-language: Haskell2010 + ghc-options: -O2 -threaded -with-rtsopts=-N + build-depends: much + , base + , unix + , scanner + , blessings + , hyphenation + , linebreak + , containers + , rosezipper + +library + hs-source-dirs: src + exposed-modules: Much.Core + , Much.Action + , Much.Event + , Much.ParseMail + , Much.RenderTreeView + , Much.Screen + , Much.State + , Much.TagUtils + , Much.TreeSearch + , Much.TreeView + , Much.TreeView.Types + , Much.TreeZipperUtils + , Much.Utils + , Network.Mail.Mime + , Notmuch + , Notmuch.Class + , Notmuch.Message + , Notmuch.SearchResult + other-modules: Codec.MIME.Base64 + , Codec.MIME.Decode + , Codec.MIME.Parse + , Codec.MIME.QuotedPrintable + , Codec.MIME.Type + , Data.Aeson.Extends + build-depends: base + , aeson + , attoparsec + , base64-bytestring + , blaze-builder + , blessings + , bytestring + , case-insensitive + , containers + , deepseq + , directory + , docopt + , email-header + , filepath + , friendly-time + , hyphenation + , linebreak + , old-locale + , process + , random + , rosezipper + , safe + , scanner + , split + , terminal-size + , text + , time + , transformers + , transformers-compat + , unix + , vector default-language: Haskell2010 ghc-options: -O2 -Wall -threaded diff --git a/Codec/MIME/Base64.hs b/src/Codec/MIME/Base64.hs index f60419b..4372a7f 100644 --- a/Codec/MIME/Base64.hs +++ b/src/Codec/MIME/Base64.hs @@ -1,21 +1,21 @@ -------------------------------------------------------------------- -- | -- Module : Codec.MIME.Base64 --- Copyright : (c) 2006-2009, Galois, Inc. +-- Copyright : (c) 2006-2009, Galois, Inc. -- License : BSD3 -- -- Maintainer: Sigbjorn Finne <sigbjorn.finne@gmail.com> -- Stability : provisional -- Portability: portable -- --- +-- -- Base64 decoding and encoding routines, multiple entry -- points for either depending on use and level of control -- wanted over the encoded output (and its input form on the -- decoding side.) --- +-- -------------------------------------------------------------------- -module Codec.MIME.Base64 +module Codec.MIME.Base64 ( encodeRaw -- :: Bool -> String -> [Word8] , encodeRawString -- :: Bool -> String -> String , encodeRawPrim -- :: Bool -> Char -> Char -> [Word8] -> String @@ -64,14 +64,14 @@ encodeRawPrim trail ch62 ch63 ls = encoder ls trailer xs ys | not trail = xs | otherwise = xs ++ ys - f = fromB64 ch62 ch63 + f = fromB64 ch62 ch63 encoder [] = [] encoder [x] = trailer (take 2 (encode3 f x 0 0 "")) "==" encoder [x,y] = trailer (take 3 (encode3 f x y 0 "")) "=" encoder (x:y:z:ws) = encode3 f x y z (encoder ws) encode3 :: (Word8 -> Char) -> Word8 -> Word8 -> Word8 -> String -> String -encode3 f a b c rs = +encode3 f a b c rs = f (low6 (w24 `shiftR` 18)) : f (low6 (w24 `shiftR` 12)) : f (low6 (w24 `shiftR` 6)) : @@ -79,7 +79,7 @@ encode3 f a b c rs = where w24 :: Word32 w24 = (fromIntegral a `shiftL` 16) + - (fromIntegral b `shiftL` 8) + + (fromIntegral b `shiftL` 8) + fromIntegral c decodeToString :: String -> String @@ -93,7 +93,7 @@ decodePrim ch62 ch63 str = decoder $ takeUntilEnd str where takeUntilEnd "" = [] takeUntilEnd ('=':_) = [] - takeUntilEnd (x:xs) = + takeUntilEnd (x:xs) = case toB64 ch62 ch63 x of Nothing -> takeUntilEnd xs Just b -> b : takeUntilEnd xs @@ -128,7 +128,7 @@ toB64 a b ch | otherwise = Nothing fromB64 :: Char -> Char -> Word8 -> Char -fromB64 ch62 ch63 x +fromB64 ch62 ch63 x | x < 26 = chr (ord 'A' + xi) | x < 52 = chr (ord 'a' + (xi-26)) | x < 62 = chr (ord '0' + (xi-52)) @@ -144,4 +144,3 @@ low6 x = fromIntegral (x .&. 0x3f) lowByte :: Word32 -> Word8 lowByte x = (fromIntegral x) .&. 0xff - diff --git a/Codec/MIME/Decode.hs b/src/Codec/MIME/Decode.hs index 278d6f6..278d6f6 100644 --- a/Codec/MIME/Decode.hs +++ b/src/Codec/MIME/Decode.hs diff --git a/Codec/MIME/Parse.hs b/src/Codec/MIME/Parse.hs index c5392fe..c5392fe 100644 --- a/Codec/MIME/Parse.hs +++ b/src/Codec/MIME/Parse.hs diff --git a/Codec/MIME/QuotedPrintable.hs b/src/Codec/MIME/QuotedPrintable.hs index cdc2266..cdc2266 100644 --- a/Codec/MIME/QuotedPrintable.hs +++ b/src/Codec/MIME/QuotedPrintable.hs diff --git a/Codec/MIME/Type.hs b/src/Codec/MIME/Type.hs index 72ec94f..72ec94f 100644 --- a/Codec/MIME/Type.hs +++ b/src/Codec/MIME/Type.hs diff --git a/Codec/MIME/Utils.hs b/src/Codec/MIME/Utils.hs index dd54860..dd54860 100644 --- a/Codec/MIME/Utils.hs +++ b/src/Codec/MIME/Utils.hs diff --git a/Data/Aeson/Extends.hs b/src/Data/Aeson/Extends.hs index d78f81d..d78f81d 100644 --- a/Data/Aeson/Extends.hs +++ b/src/Data/Aeson/Extends.hs diff --git a/Action.hs b/src/Much/Action.hs index 95bc7ca..5872964 100644 --- a/Action.hs +++ b/src/Much/Action.hs @@ -1,15 +1,15 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} -module Action where +module Much.Action where import Blessings.String import Scanner -import State -import TagUtils -import TreeSearch -import TreeView -import TreeZipperUtils +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 diff --git a/Core.hs b/src/Much/Core.hs index 5971769..353f248 100644 --- a/Core.hs +++ b/src/Much/Core.hs @@ -2,25 +2,25 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} -module Core where +module Much.Core where -import Action +import Much.Action import Blessings.String (Blessings(Plain,SGR),pp) import Control.Concurrent import Control.Monad import Data.Time -import Event -import RenderTreeView (renderTreeView) +import Much.Event +import Much.RenderTreeView (renderTreeView) import Scanner (scan,Scan(..)) -import Screen -import State +import Much.Screen +import Much.State import System.Console.Docopt.NoTH (getArgWithDefault, parseArgsOrExit, parseUsageOrExit, shortOption) import System.Environment import System.IO import System.Posix.Signals -import TreeSearch -import TreeView -import Utils +import Much.TreeSearch +import Much.TreeView +import Much.Utils import qualified Blessings.Internal as Blessings import qualified Data.Tree as Tree import qualified Data.Tree.Zipper as Z diff --git a/Event.hs b/src/Much/Event.hs index 5790aac..9842327 100644 --- a/Event.hs +++ b/src/Much/Event.hs @@ -1,4 +1,4 @@ -module Event where +module Much.Event where import Blessings import Scanner diff --git a/MBox.hs b/src/Much/MBox.hs index 5071e48..9299eea 100644 --- a/MBox.hs +++ b/src/Much/MBox.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} -module MBox +module Much.MBox ( -- TODO don't re-export MBox but use our own Message type module Export diff --git a/MappedSets.hs b/src/Much/MappedSets.hs index c3045c6..ec0ae73 100644 --- a/MappedSets.hs +++ b/src/Much/MappedSets.hs @@ -1,4 +1,4 @@ -module MappedSets (invert, mk) where +module Much.MappedSets (invert, mk) where import Control.Arrow import Data.Map.Strict (Map) diff --git a/ParseMail.hs b/src/Much/ParseMail.hs index bf2ee3d..e12737a 100644 --- a/ParseMail.hs +++ b/src/Much/ParseMail.hs @@ -1,7 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} -module ParseMail (readMail) where +module Much.ParseMail (readMail) where import qualified Data.Attoparsec.ByteString.Char8 as A8 import qualified Data.ByteString as BS diff --git a/RenderTreeView.hs b/src/Much/RenderTreeView.hs index 6579ffb..60b48d6 100644 --- a/RenderTreeView.hs +++ b/src/Much/RenderTreeView.hs @@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} -module RenderTreeView (renderTreeView) where +module Much.RenderTreeView (renderTreeView) where import qualified Notmuch.Message as Notmuch import qualified Notmuch.SearchResult as Notmuch @@ -11,16 +11,16 @@ import qualified Data.List as L import qualified Data.Map as M import qualified Data.Text as T import qualified Data.Tree.Zipper as Z -import qualified TreeZipperUtils as Z +import qualified Much.TreeZipperUtils as Z import Blessings import Data.Char import Data.Maybe import Data.Time import Data.Time.Format.Human import Data.Tree -import State -import TagUtils (Tag) -import TreeView +import Much.State +import Much.TagUtils (Tag) +import Much.TreeView -- TODO make configurable @@ -127,9 +127,9 @@ renderTreeView1 q@State{..} hasFocus x = case x of isUnread = "unread" `elem` Notmuch.searchTags sr authors = Plain $ T.unpack $ Notmuch.searchAuthors sr - date = State.date colorConfig $ renderDate now x + date = Much.State.date colorConfig $ renderDate now x subject = Plain $ T.unpack $ Notmuch.searchSubject sr - tags = State.tags colorConfig $ renderTags q (Notmuch.searchTags sr) + tags = Much.State.tags colorConfig $ renderTags q (Notmuch.searchTags sr) title = if subject /= "" then subject else c_authors authors in c $ title <> " " <> date <> " " <> tags @@ -140,8 +140,8 @@ renderTreeView1 q@State{..} hasFocus x = case x of | "unread" `elem` Notmuch.messageTags m = unreadMessage colorConfig | otherwise = boringMessage colorConfig from = fromSGR $ renderFrom (M.lookup "from" $ Notmuch.messageHeaders m) - date = State.date colorConfig $ renderDate now x - tags = State.tags colorConfig $ renderTags q (Notmuch.messageTags m) -- TODO filter common tags + date = Much.State.date colorConfig $ renderDate now x + tags = Much.State.tags colorConfig $ renderTags q (Notmuch.messageTags m) -- TODO filter common tags in from <> " " <> date <> " " <> tags TVMessageHeaderField m fieldName -> diff --git a/Screen.hs b/src/Much/Screen.hs index 2bf0329..47bb90c 100644 --- a/Screen.hs +++ b/src/Much/Screen.hs @@ -1,5 +1,5 @@ {-# LANGUAGE RecordWildCards #-} -module Screen (Screen(..), setScreen, withScreen) where +module Much.Screen (Screen(..), setScreen, withScreen) where import Control.Exception import Data.List diff --git a/State.hs b/src/Much/State.hs index a291a53..a522e99 100644 --- a/State.hs +++ b/src/Much/State.hs @@ -1,4 +1,4 @@ -module State where +module Much.State where import Blessings.String (Blessings) import qualified Data.Text as T @@ -6,7 +6,7 @@ import Data.Time import qualified Data.Tree.Zipper as Z import Scanner import System.Posix.Signals -import TreeView (TreeView) +import Much.TreeView (TreeView) data State = State { cursor :: Z.TreePos Z.Full TreeView diff --git a/TagUtils.hs b/src/Much/TagUtils.hs index 99d957d..d4e4d30 100644 --- a/TagUtils.hs +++ b/src/Much/TagUtils.hs @@ -1,6 +1,6 @@ {-# LANGUAGE LambdaCase #-} -module TagUtils where +module Much.TagUtils where import qualified Data.Set as Set import qualified Data.Text as T @@ -9,7 +9,7 @@ import Data.List.Split (wordsBy) import Data.Tree import Notmuch.Message import Notmuch.SearchResult -import TreeView.Types +import Much.TreeView.Types type Tag = T.Text diff --git a/TreeSearch.hs b/src/Much/TreeSearch.hs index 518c4d9..d66eb83 100644 --- a/TreeSearch.hs +++ b/src/Much/TreeSearch.hs @@ -1,4 +1,4 @@ -module TreeSearch where +module Much.TreeSearch where import Data.Tree.Zipper diff --git a/TreeView.hs b/src/Much/TreeView.hs index ecd25c8..9487f74 100644 --- a/TreeView.hs +++ b/src/Much/TreeView.hs @@ -3,7 +3,7 @@ {-# LANGUAGE RecordWildCards #-} -module TreeView +module Much.TreeView ( module Export , getMessage , getSearchTerm @@ -23,7 +23,7 @@ import Data.Tree import Notmuch import Notmuch.Message import Notmuch.SearchResult -import TreeView.Types as Export +import Much.TreeView.Types as Export getMessage :: TreeView -> Maybe Message diff --git a/TreeView/Types.hs b/src/Much/TreeView/Types.hs index 0dd1290..6e4ac6b 100644 --- a/TreeView/Types.hs +++ b/src/Much/TreeView/Types.hs @@ -1,6 +1,6 @@ {-# LANGUAGE LambdaCase #-} -module TreeView.Types where +module Much.TreeView.Types where import qualified Data.CaseInsensitive as CI import qualified Data.Text as T diff --git a/TreeZipperUtils.hs b/src/Much/TreeZipperUtils.hs index 0c6dc00..5257c2f 100644 --- a/TreeZipperUtils.hs +++ b/src/Much/TreeZipperUtils.hs @@ -1,4 +1,4 @@ -module TreeZipperUtils where +module Much.TreeZipperUtils where import Data.Maybe import Data.Tree diff --git a/Utils.hs b/src/Much/Utils.hs index a14be89..80615fc 100644 --- a/Utils.hs +++ b/src/Much/Utils.hs @@ -1,4 +1,4 @@ -module Utils where +module Much.Utils where import Control.Exception import System.Directory diff --git a/Network/Mail/Mime.hs b/src/Network/Mail/Mime.hs index 8fd9fe1..8fd9fe1 100644 --- a/Network/Mail/Mime.hs +++ b/src/Network/Mail/Mime.hs diff --git a/Notmuch.hs b/src/Notmuch.hs index fc24d0e..f86bd3d 100644 --- a/Notmuch.hs +++ b/src/Notmuch.hs @@ -15,11 +15,11 @@ import Data.Tree import Notmuch.Class import Notmuch.Message import Notmuch.SearchResult -import ParseMail (readMail) +import Much.ParseMail (readMail) import System.Exit import System.IO import System.Process -import TagUtils +import Much.TagUtils -- | Fork a thread while doing something else, but kill it if there's an diff --git a/Notmuch/Class.hs b/src/Notmuch/Class.hs index 2d2b416..2d2b416 100644 --- a/Notmuch/Class.hs +++ b/src/Notmuch/Class.hs diff --git a/Notmuch/Message.hs b/src/Notmuch/Message.hs index d08be39..d08be39 100644 --- a/Notmuch/Message.hs +++ b/src/Notmuch/Message.hs diff --git a/Notmuch/SearchResult.hs b/src/Notmuch/SearchResult.hs index a59fa9c..a59fa9c 100644 --- a/Notmuch/SearchResult.hs +++ b/src/Notmuch/SearchResult.hs |