This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
361 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
stack build --pedantic && stack exec taskell $@ | ||
stack build && stack exec taskell $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module App (go) where | ||
|
||
import Control.Monad (void) | ||
import Control.Monad.IO.Class (liftIO) | ||
import Flow.State (State, Mode(..), lists, continue, path, mode) | ||
import Brick | ||
import Persistence.Taskell (writeFile) | ||
|
||
import Flow.Actions (event) | ||
|
||
import UI.Draw (draw, chooseCursor, scroll) | ||
import UI.Attr (attrMap') | ||
import UI.Types (ResourceName(..)) | ||
|
||
-- store | ||
store :: State -> IO State | ||
store s = do | ||
Persistence.Taskell.writeFile (lists s) (path s) | ||
return (Flow.State.continue s) | ||
|
||
-- App code | ||
handleEvent :: State -> BrickEvent ResourceName e -> EventM ResourceName (Next State) | ||
handleEvent s' (VtyEvent e) = let s = event e s' in | ||
case mode s of | ||
Shutdown -> Brick.halt s | ||
Write _ -> scroll s >> liftIO (store s) >>= Brick.continue | ||
_ -> scroll s >> Brick.continue s | ||
handleEvent s _ = Brick.continue s | ||
|
||
app :: App State e ResourceName | ||
app = App draw chooseCursor handleEvent return attrMap' | ||
|
||
go :: State -> IO () | ||
go initial = void (defaultMain app initial) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,32 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
|
||
module Data.Taskell.Task where | ||
|
||
import GHC.Generics (Generic) | ||
import Data.Aeson (FromJSON, ToJSON) | ||
import Data.List (isInfixOf) | ||
import qualified Data.Taskell.String as S | ||
import Data.Text (Text, snoc, length, null, isInfixOf) | ||
import qualified Data.Taskell.Text as T | ||
|
||
newtype Task = Task { | ||
description :: String | ||
} deriving (Generic, Show, Eq) | ||
|
||
instance ToJSON Task | ||
instance FromJSON Task | ||
description :: Text | ||
} deriving (Show, Eq) | ||
|
||
blank :: Task | ||
blank = Task { description = "" } | ||
|
||
clear :: Task -> Task | ||
clear _ = blank | ||
|
||
new :: String -> Task | ||
new :: Text -> Task | ||
new s = Task { description = s } | ||
|
||
append :: Char -> Task -> Task | ||
append c t = t { description = description t ++ [c] } | ||
append c t = t { description = Data.Text.snoc (description t) c } | ||
|
||
backspace :: Task -> Task | ||
backspace t = t { description = S.backspace (description t) } | ||
backspace t = t { description = T.backspace (description t) } | ||
|
||
characters :: Task -> Int | ||
characters = length . description | ||
characters = Data.Text.length . description | ||
|
||
contains :: String -> Task -> Bool | ||
contains s t = s `isInfixOf` description t | ||
contains :: Text -> Task -> Bool | ||
contains s t = s `Data.Text.isInfixOf` description t | ||
|
||
isBlank :: Task -> Bool | ||
isBlank t = null $ description t | ||
isBlank t = Data.Text.null $ description t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Data.Taskell.Text ( | ||
backspace, | ||
wrap | ||
) where | ||
|
||
import Data.Text (Text, foldl', singleton, snoc, init, null, append, strip, empty) | ||
import Data.List (foldl') | ||
import Brick.Widgets.Core (textWidth) | ||
|
||
backspace :: Text -> Text | ||
backspace s = if not (Data.Text.null s) then Data.Text.init s else s | ||
|
||
-- wrapping | ||
spl' :: [Text] -> Char -> [Text] | ||
spl' ts c | ||
| c == ' ' = ts ++ [" "] ++ [empty] | ||
| Prelude.null ts = [Data.Text.singleton c] | ||
| otherwise = Prelude.init ts ++ [Data.Text.snoc (Prelude.last ts) c] | ||
|
||
spl :: Text -> [Text] | ||
spl = Data.Text.foldl' spl' [empty] | ||
|
||
wrap :: Int -> Text -> [Text] | ||
wrap width = Data.List.foldl' (combine width) [] . spl | ||
|
||
combine :: Int -> [Text] -> Text -> [Text] | ||
combine width acc s = if nl then acc ++ [strip s] else Data.Taskell.Text.append (l `Data.Text.append` s) acc | ||
where l = if Prelude.null acc then "" else last acc | ||
nl = textWidth l + textWidth s > width | ||
|
||
append :: Text -> [Text] -> [Text] | ||
append s l = l' ++ [s] | ||
where l' = if Prelude.null l then l else Prelude.init l |
Oops, something went wrong.