Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.11.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
smallhadroncollider committed Feb 19, 2018
2 parents 14ac9c4 + c6b5840 commit 4b42e86
Show file tree
Hide file tree
Showing 13 changed files with 288 additions and 116 deletions.
5 changes: 4 additions & 1 deletion .bin/taskell
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
stack build --fast --trace && stack exec taskell $@
rm ~/.taskell/config.ini
rm ~/.taskell/theme.ini
stack build --fast --trace
stack exec taskell $@
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Run `sudo dnf install ncurses-compat-libs` then download and run binary as descr

Press `?` for a [list of controls](https://github.com/smallhadroncollider/taskell/blob/master/templates/controls.md)

### Tips
## Tips

- If you're using a simple two-column "To Do" and "Done" then use the space bar to mark an item as complete while staying in the "To Do" list. If you're using a more complicated column setup then you will want to use `H`/`L` to move tasks between columns.

Expand All @@ -59,6 +59,51 @@ By default stores in a `taskell.md` file in the working directory:
- Do That
```

## Configuration

You can edit Taskell's settings by editing `~/.taskell/config.ini`:

```ini
[general]
; the default filename to create/look for
filename = taskell.md

[layout]
; the width of a column
column_width = 24

; the padding of a column
; for both sides, so 3 would give a gap of 6 between two columns
column_padding = 3

[markdown]
; the markdown to start a title line with
title = "##"

; the markdown to start a task line with
task = "-"

; the markdown to start a sub-task line with
subtask = " *"
```

Make sure that the values in the `[markdown]` section are surrounded by **double**-quotes.

If you always use sub-tasks, an alternative setup for `[markdown]` might be:

```ini
[markdown]
title = "##"

; each task is a header
task = "###"

; subtasks are list items under the header
subtask = "-"
```

**Warning**: currently if you change your `[markdown]` settings any older files stored with different settings will not be readable.

## Theming

You can edit Taskell's colour-scheme by editing `~/.taskell/theme.ini`:
Expand Down Expand Up @@ -95,3 +140,7 @@ The available colours are: `black`, `red`, `green`, `yellow`, `blue`, `magenta`,
## Roadmap

See [roadmap.md](https://github.com/smallhadroncollider/taskell/blob/develop/roadmap.md) for planned features

## Contributing

Please check the [roadmap.md](https://github.com/smallhadroncollider/taskell/blob/develop/roadmap.md) before adding any bugs/feature requests to Issues.
21 changes: 10 additions & 11 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ module Main where

import Control.Monad (when)
import Events.State (create)
import IO.Taskell (exists, readFile)
import IO.Config (Config, setup)
import qualified IO.Taskell as T (exists, readFile)
import IO.Config (setup)

import App (go)

-- read file then render
start :: Config -> FilePath -> IO ()
start config path = do
state <- create path <$> IO.Taskell.readFile path
go config state

-- if taskell.md exists/created then start
main :: IO ()
main = do
config <- setup
(ex, path) <- exists config
when ex $ start config path
(exists, path) <- T.exists config

when exists $ do
content <- T.readFile config path

case content of
Right lists -> go config $ create path lists
Left err -> putStrLn $ path ++ ": " ++ err
22 changes: 19 additions & 3 deletions roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@
- Remove duplication of config - currently using ini and hard-coded
- Move Help modal creation into Template Haskell
- Use lenses for nested data?
- Split up Draw/Modal code into more logical chunks
- Share code between tasks and sub-tasks lists?

## Bugs

- Items near bottom of the list jump in position
- Up and down in search gets a bit lost
- Editing list title doesn't always have visibility
- Vertical spacing doesn't work if the current item is blank
- Cursor goes missing on the left hand side at the end of a line
- One bad config line stops all config from working - needs to merge with defaultConfig
- Cursor goes missing on the left hand side at the end of a line - needs to wrap
- Help modal needs to scroll on smaller windows
- Sub-task count not visible on last item in a list longer than the vertical height
- Pressing Enter on empty list shows an subtasks box with an error
- Empty tasks - i.e. just a space - don't show up
- No obvious way to know if there are more items in a list off-screen

## To Do

- Task body - e.g. as well as sub lists, have a longer description
- Move between lists with `m` - shows possible lists
- Left/Right arrow keys in insert mode
- Add tags/labels with `t`
Expand All @@ -39,6 +44,7 @@

## In Progress

- One bad config line stops all config from working - needs to merge with defaultConfig

## Done

Expand Down Expand Up @@ -123,3 +129,13 @@
* ~Word wrapping~
* ~Searching~
* ~Delete items~
- No cursor in sub-task view
* ~Single line~
* ~Multi-line~
- Customisable Markdown format
* ~Change top level headers~
* ~Change top level list item: e.g. to H3 instead of li~
* ~Change sub-list: e.g. from " *" to "-"~
- Feels sluggish in sub-task view - cache main view?
- Leaving search only refreshes current list
- Display a warning if any line of the file could not be parsed - otherwise could lead to data loss
46 changes: 33 additions & 13 deletions src/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ module App (go) where
import Control.Monad (void)
import Control.Monad.IO.Class (liftIO)
import Control.Concurrent (forkIO)
import Events.State (State, Mode(..), continue, path, mode, io)
import Events.State (State, Mode(..), continue, path, mode, io, current)
import Data.Taskell.Lists (Lists)
import Brick
import Graphics.Vty.Input.Events (Event(..))

import IO.Taskell (writeFile)
import IO.Config (Config, layout, generateAttrMap)
Expand All @@ -16,23 +17,42 @@ import UI.Draw (draw, chooseCursor)
import UI.Types (ResourceName(..))

-- store
store :: Lists -> State -> IO State
store ls s = do
forkIO $ IO.Taskell.writeFile ls (path s)
store :: Config -> Lists -> State -> IO State
store config ls s = do
forkIO $ IO.Taskell.writeFile config ls (path s)
return (Events.State.continue s)

next :: Config -> State -> EventM ResourceName (Next State)
next config s = case io s of
Just ls -> liftIO (store config ls s) >>= Brick.continue
Nothing -> Brick.continue s

clearCache :: State -> EventM ResourceName ()
clearCache state = do
let (li, ti) = current state
invalidateCacheEntry (RNList li)
invalidateCacheEntry (RNTask (li, ti))

handleVtyEvent :: Config -> State -> Event -> EventM ResourceName (Next State)
handleVtyEvent config previousState e = do
let state = event e previousState

case mode previousState of
Search _ _ -> invalidateCache
_ -> return ()

case mode state of
Shutdown -> Brick.halt state
_ -> clearCache previousState >> clearCache state >> next config state

-- 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
_ -> case io s of
Just ls -> liftIO (store ls s) >>= Brick.continue
Nothing -> Brick.continue s
handleEvent s _ = Brick.continue s
handleEvent :: Config -> State -> BrickEvent ResourceName e -> EventM ResourceName (Next State)
handleEvent _ state (VtyEvent (EvResize _ _ )) = invalidateCache >> Brick.continue state
handleEvent config state (VtyEvent ev) = handleVtyEvent config state ev
handleEvent _ state _ = Brick.continue state

go :: Config -> State -> IO ()
go config initial = do
attrMap' <- const <$> generateAttrMap
let app = App (draw $ layout config) chooseCursor handleEvent return attrMap'
let app = App (draw $ layout config) chooseCursor (handleEvent config) return attrMap'
void (defaultMain app initial)
30 changes: 27 additions & 3 deletions src/IO/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ module IO.Config where

import System.Directory
import Data.Ini.Config

import Data.FileEmbed (embedFile)
import qualified Data.ByteString as B (writeFile)

import UI.Theme
import Brick.Themes (themeToAttrMap, loadCustomizations)
import Brick (AttrMap)
import Data.Text (Text, strip, dropAround)
import qualified Data.Text.IO as T

data GeneralConfig = GeneralConfig {
Expand All @@ -22,9 +22,16 @@ data LayoutConfig = LayoutConfig {
columnPadding :: Int
}

data MarkdownConfig = MarkdownConfig {
titleOutput :: Text,
taskOutput :: Text,
subtaskOutput :: Text
}

data Config = Config {
general :: GeneralConfig,
layout :: LayoutConfig
layout :: LayoutConfig,
markdown :: MarkdownConfig
}

defaultConfig :: Config
Expand All @@ -35,9 +42,17 @@ defaultConfig = Config {
layout = LayoutConfig {
columnWidth = 24,
columnPadding = 3
},
markdown = MarkdownConfig {
titleOutput = "##",
taskOutput = "-",
subtaskOutput = " *"
}
}

parseString :: Text -> Text
parseString = dropAround (== '"') . strip

getDir :: IO FilePath
getDir = (++ "/.taskell") <$> getHomeDirectory

Expand Down Expand Up @@ -81,7 +96,16 @@ configParser = do
columnWidthCf <- fieldOf "column_width" number
columnPaddingCf <- fieldOf "column_padding" number
return LayoutConfig { columnWidth = columnWidthCf, columnPadding = columnPaddingCf }
return Config { general = generalCf, layout = layoutCf }
markdownCf <- section "markdown" $ do
titleOutputCf <- parseString <$> fieldOf "title" string
taskOutputCf <- parseString <$> fieldOf "task" string
subtaskOutputCf <- parseString <$> fieldOf "subtask" string
return MarkdownConfig {
titleOutput = titleOutputCf,
taskOutput = taskOutputCf,
subtaskOutput = subtaskOutputCf
}
return Config { general = generalCf, layout = layoutCf, markdown = markdownCf }

getConfig :: IO Config
getConfig = do
Expand Down
Loading

0 comments on commit 4b42e86

Please sign in to comment.