taskell 1.9.0.0 → 1.9.1.0
raw patch · 11 files changed
+115/−72 lines, 11 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Taskell.Date: instance GHC.Classes.Eq Data.Taskell.Date.Deadline
- Data.Taskell.Date: instance GHC.Classes.Eq Data.Taskell.Date.Due
- Data.Taskell.Date: instance GHC.Classes.Ord Data.Taskell.Date.Due
- Data.Taskell.Date: instance GHC.Show.Show Data.Taskell.Date.Deadline
- Data.Taskell.Date: instance GHC.Show.Show Data.Taskell.Date.Due
- Data.Taskell.Date.RelativeParser: parseRelative :: UTCTime -> Text -> Either Text UTCTime
+ Data.Taskell.Date.RelativeParser: parseRelative :: UTCTime -> Text -> Either Text Due
- Events.State.Types: future :: forall a_aVof. Lens' (History a_aVof) [a_aVof]
+ Events.State.Types: future :: forall a_aVL0. Lens' (History a_aVL0) [a_aVL0]
- Events.State.Types: past :: forall a_aVof. Lens' (History a_aVof) [a_aVof]
+ Events.State.Types: past :: forall a_aVL0. Lens' (History a_aVL0) [a_aVL0]
- Events.State.Types: present :: forall a_aVof. Lens' (History a_aVof) a_aVof
+ Events.State.Types: present :: forall a_aVL0. Lens' (History a_aVL0) a_aVL0
Files
- README.md +6/−0
- src/Config.hs +1/−1
- src/Data/Taskell/Date.hs +2/−20
- src/Data/Taskell/Date/RelativeParser.hs +27/−17
- src/Data/Taskell/Date/Types.hs +27/−0
- src/IO/Config/Layout.hs +25/−15
- src/UI/Draw/Main.hs +10/−3
- src/Utility/Parser.hs +3/−0
- taskell.cabal +2/−1
- templates/config.ini +2/−0
- test/Data/Taskell/Date/RelativeParserTest.hs +10/−15
README.md view
@@ -209,6 +209,9 @@ filename = taskell.md [layout]+; top/bottom padding for the taskell window+padding = 1+ ; the width of a column column_width = 30 @@ -219,6 +222,9 @@ ; the icon to use when a task has a description ; the default icon may not display on all systems description_indicator = "≡"++; whether to show the statusbar+statusbar = true [markdown] ; the markdown to start a title line with
src/Config.hs view
@@ -9,7 +9,7 @@ import Data.FileEmbed (embedFile) version :: Text-version = "1.9.0"+version = "1.9.1" usage :: Text usage = decodeUtf8 $(embedFile "templates/usage.txt")
src/Data/Taskell/Date.hs view
@@ -26,25 +26,7 @@ import Data.Time.Format (FormatTime, ParseTime, formatTime, iso8601DateFormat, parseTimeM) import Data.Taskell.Date.RelativeParser (parseRelative)--data Due- = DueTime UTCTime- | DueDate Day- deriving (Show, Eq)--instance Ord Due where- compare (DueTime t) (DueDate d) = t `compare` UTCTime d 0- compare (DueDate d) (DueTime t) = UTCTime d 0 `compare` t- compare (DueDate d1) (DueDate d2) = d1 `compare` d2- compare (DueTime t1) (DueTime t2) = t1 `compare` t2--data Deadline- = Passed- | Today- | Tomorrow- | ThisWeek- | Plenty- deriving (Show, Eq)+import Data.Taskell.Date.Types (Deadline (..), Due (..)) -- formats dateFormat :: String@@ -112,7 +94,7 @@ inputToTime tz now txt = parseDate txt <?> (DueTime . localTimeToUTCTZ tz <$> parseT timeDisplayFormat txt) <?> case parseRelative now txt of- Right utc -> Just $ DueTime utc+ Right due -> Just due Left _ -> Nothing isoToTime :: Text -> Maybe Due
src/Data/Taskell/Date/RelativeParser.hs view
@@ -11,9 +11,14 @@ import Data.Time.Clock (addUTCTime) -import Utility.Parser (lexeme)+import Data.Taskell.Date.Types (Due (DueDate, DueTime))+import Utility.Parser (lexeme, only) --- relative date parsing+-- utility functions+addP :: (Integral a) => Parser a -> UTCTime -> Parser UTCTime+addP p now = ($ now) . addUTCTime . fromIntegral . sum <$> many1 p++-- relative time parsing minute :: Int minute = 60 @@ -26,32 +31,37 @@ week :: Int week = day * 7 -periodP :: Char -> Parser Int-periodP c = lexeme decimal <* char c+timePeriodP :: Char -> Parser Int+timePeriodP c = lexeme decimal <* char c wP :: Parser Int-wP = (* week) <$> periodP 'w'+wP = (* week) <$> timePeriodP 'w' dP :: Parser Int-dP = (* day) <$> periodP 'd'+dP = (* day) <$> timePeriodP 'd' hP :: Parser Int-hP = (* hour) <$> periodP 'h'+hP = (* hour) <$> timePeriodP 'h' mP :: Parser Int-mP = (* minute) <$> periodP 'm'+mP = (* minute) <$> timePeriodP 'm' sP :: Parser Int-sP = periodP 's'+sP = timePeriodP 's' -relativeP :: UTCTime -> Parser (Maybe UTCTime)-relativeP now =- lexeme $ do- period <- fromIntegral . sum <$> many1 (sP <|> mP <|> hP <|> dP <|> wP)- pure $ Just (addUTCTime period now)+timeP :: UTCTime -> Parser (Maybe Due)+timeP now = only . lexeme $ Just . DueTime <$> addP (sP <|> mP <|> hP <|> dP <|> wP) now -parseRelative :: UTCTime -> Text -> Either Text UTCTime+-- relative date parsing+dateP :: UTCTime -> Parser (Maybe Due)+dateP now = only . lexeme $ Just . DueDate . utctDay <$> addP (dP <|> wP) now++-- relative parser+relativeP :: UTCTime -> Parser (Maybe Due)+relativeP now = dateP now <|> timeP now++parseRelative :: UTCTime -> Text -> Either Text Due parseRelative now text = case parseOnly (relativeP now) text of- Right (Just time) -> Right time- _ -> Left "Could not parse date."+ Right (Just due) -> Right due+ _ -> Left "Could not parse date."
+ src/Data/Taskell/Date/Types.hs view
@@ -0,0 +1,27 @@+{-# LANGUAGE NoImplicitPrelude #-}++module Data.Taskell.Date.Types+ ( Deadline(..)+ , Due(..)+ ) where++import ClassyPrelude++data Due+ = DueTime UTCTime+ | DueDate Day+ deriving (Show, Eq)++instance Ord Due where+ compare (DueTime t) (DueDate d) = t `compare` UTCTime d 0+ compare (DueDate d) (DueTime t) = UTCTime d 0 `compare` t+ compare (DueDate d1) (DueDate d2) = d1 `compare` d2+ compare (DueTime t1) (DueTime t2) = t1 `compare` t2++data Deadline+ = Passed+ | Today+ | Tomorrow+ | ThisWeek+ | Plenty+ deriving (Show, Eq)
src/IO/Config/Layout.hs view
@@ -7,29 +7,39 @@ import IO.Config.Parser (noEmpty, parseText) data Config = Config- { columnWidth :: Int+ { padding :: Int+ , columnWidth :: Int , columnPadding :: Int , descriptionIndicator :: Text+ , statusBar :: Bool } defaultConfig :: Config-defaultConfig = Config {columnWidth = 30, columnPadding = 3, descriptionIndicator = "≡"}+defaultConfig =+ Config+ {padding = 1, columnWidth = 30, columnPadding = 3, descriptionIndicator = "≡", statusBar = True} +paddingP :: SectionParser Int+paddingP = fromMaybe (padding defaultConfig) <$> fieldMbOf "padding" number++columnWidthP :: SectionParser Int+columnWidthP = fromMaybe (columnWidth defaultConfig) <$> fieldMbOf "column_width" number++columnPaddingP :: SectionParser Int+columnPaddingP = fromMaybe (columnPadding defaultConfig) <$> fieldMbOf "column_padding" number++descriptionIndicatorP :: SectionParser Text+descriptionIndicatorP =+ fromMaybe (descriptionIndicator defaultConfig) . (noEmpty . parseText =<<) <$>+ fieldMb "description_indicator"++statusBarP :: SectionParser Bool+statusBarP = fieldFlagDef "statusbar" (statusBar defaultConfig)+ parser :: IniParser Config parser = fromMaybe defaultConfig <$> sectionMb "layout"- (do columnWidthCf <-- fromMaybe (columnWidth defaultConfig) <$> fieldMbOf "column_width" number- columnPaddingCf <-- fromMaybe (columnPadding defaultConfig) <$> fieldMbOf "column_padding" number- descriptionIndicatorCf <-- fromMaybe (descriptionIndicator defaultConfig) . (noEmpty . parseText =<<) <$>- fieldMb "description_indicator"- pure- Config- { columnWidth = columnWidthCf- , columnPadding = columnPaddingCf- , descriptionIndicator = descriptionIndicatorCf- })+ (Config <$> paddingP <*> columnWidthP <*> columnPaddingP <*> descriptionIndicatorP <*>+ statusBarP)
src/UI/Draw/Main.hs view
@@ -11,6 +11,7 @@ import Data.Sequence (mapWithIndex) import Events.State.Types (lists)+import IO.Config.Layout (padding, statusBar) import UI.Draw.Main.List (renderList) import UI.Draw.Main.Search (renderSearch) import UI.Draw.Main.StatusBar (renderStatusBar)@@ -21,6 +22,12 @@ renderMain = do ls <- (^. lists) <$> asks dsState listWidgets <- toList <$> sequence (renderList `mapWithIndex` ls)- let mainWidget = viewport RNLists Horizontal . padTopBottom 1 $ hBox listWidgets- statusBar <- renderStatusBar- renderSearch (mainWidget <=> statusBar)+ pad <- padding <$> asks dsLayout+ let mainWidget = viewport RNLists Horizontal . padTopBottom pad $ hBox listWidgets+ showStatusBar <- statusBar <$> asks dsLayout+ sb <- renderStatusBar+ let sb' =+ if showStatusBar+ then sb+ else emptyWidget+ renderSearch (mainWidget <=> sb')
src/Utility/Parser.hs view
@@ -6,6 +6,9 @@ import Data.Attoparsec.Text +only :: Parser a -> Parser a+only p = p <* endOfInput+ lexeme :: Parser a -> Parser a lexeme p = skipSpace *> p <* skipSpace
taskell.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: taskell-version: 1.9.0.0+version: 1.9.1.0 license: BSD3 license-file: LICENSE copyright: 2019 Mark Wales@@ -62,6 +62,7 @@ hs-source-dirs: src other-modules: Config+ Data.Taskell.Date.Types Events.Actions Events.Actions.Insert Events.Actions.Modal
templates/config.ini view
@@ -2,9 +2,11 @@ filename = taskell.md [layout]+padding = 1 column_width = 30 column_padding = 3 description_indicator = "≡"+statusbar = true [markdown] title = "##"
test/Data/Taskell/Date/RelativeParserTest.hs view
@@ -13,14 +13,18 @@ import Data.Time.Calendar (fromGregorian) import Data.Time.Clock (secondsToDiffTime) +import Data.Taskell.Date (Due (DueDate, DueTime)) import Data.Taskell.Date.RelativeParser (parseRelative) -toTime :: (Integer, Int, Int) -> Integer -> UTCTime-toTime (y, m, d) seconds = UTCTime (fromGregorian y m d) (secondsToDiffTime seconds)+toTime :: (Integer, Int, Int) -> Integer -> Due+toTime (y, m, d) seconds = DueTime $ UTCTime (fromGregorian y m d) (secondsToDiffTime seconds) +toDay :: (Integer, Int, Int) -> Due+toDay (y, m, d) = DueDate $ fromGregorian y m d+ -- 08:53:03 18th December 2019 time :: UTCTime-time = toTime (2019, 12, 18) 31983+time = UTCTime (fromGregorian 2019 12 18) 31983 -- tests test_relative_parser :: TestTree@@ -47,22 +51,13 @@ (parseRelative time "1h")) , testCase "Day"- (assertEqual- "Adds a day"- (Right (toTime (2019, 12, 19) 31983))- (parseRelative time "1d"))+ (assertEqual "Adds a day" (Right (toDay (2019, 12, 19))) (parseRelative time "1d")) , testCase "Days"- (assertEqual- "Adds 29 days"- (Right (toTime (2020, 1, 16) 31983))- (parseRelative time "29 d"))+ (assertEqual "Adds 29 days" (Right (toDay (2020, 1, 16))) (parseRelative time "29 d")) , testCase "Week"- (assertEqual- "Adds a week"- (Right (toTime (2019, 12, 25) 31983))- (parseRelative time "1w"))+ (assertEqual "Adds a week" (Right (toDay (2019, 12, 25))) (parseRelative time "1w ")) , testCase "Mix" (assertEqual