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.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
smallhadroncollider committed Feb 16, 2018
2 parents 02e3bbc + 46880d1 commit 14ac9c4
Show file tree
Hide file tree
Showing 29 changed files with 544 additions and 239 deletions.
4 changes: 2 additions & 2 deletions .bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ if [ -z "$1" ]; then
exit
fi

stack build
stack build --docker
stack build --ghc-options -O3
stack build --docker --ghc-options -O3

mkdir -p "releases/$1/taskell/DEBIAN"
mkdir -p "releases/$1/taskell/usr/local/bin"
Expand Down
2 changes: 1 addition & 1 deletion .bin/taskell
Original file line number Diff line number Diff line change
@@ -1 +1 @@
stack build && stack exec taskell $@
stack build --fast --trace && stack exec taskell $@
49 changes: 20 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,7 @@ Run `sudo dnf install ncurses-compat-libs` then download and run binary as descr

## Controls

- `a`: add a task to bottom (`Enter`/`Esc` to stop)
- `o`: add a task below
- `O`: add a task above
- `e`/`i`/`A`: edit a task (`Enter`/`Esc` to stop)
- `C`: change task
- `j`: move down
- `k`: move up
- `h`: move left
- `l`: move right
- `G`: go to bottom of list
- `1`-`9`: select list
- `J`: shift task down
- `K`: shift task up
- `H`: shift task left (current selection follows task)
- `L`: shift task right (current selection follows task)
- `Space`: shift task right (current selection stays put)
- `D`: delete task
- `u`: undo
- `N`: new list
- `E`: edit list title (`Enter`/`Esc` to stop)
- `X`: delete list
- `<`/`>`: move list left/right
- `/`: search (`Enter` to navigate, `Esc` to leave)
- `q`: quit
Press `?` for a [list of controls](https://github.com/smallhadroncollider/taskell/blob/master/templates/controls.md)

### Tips

Expand All @@ -84,19 +61,33 @@ By default stores in a `taskell.md` file in the working directory:

## Theming

You can edit Taskell's colourscheme by editing `~/.taskell/theme.ini`:
You can edit Taskell's colour-scheme by editing `~/.taskell/theme.ini`:

```ini
[default]
default.bg = brightBlack
default.fg = white

[other]

; list title
title.fg = green

; current list title
titleCurrent.fg = blue

; current task
taskCurrent.fg = magenta
```

You can also change the background and default text colour:

```ini
[default]

; the app background colour
default.bg = brightBlack

; the app text colour
default.fg = white
```

The available colours are: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `brightBlack`, `brightRed`, `brightGreen`, `brightYellow`, `brightBlue`, `brightMagenta`, `brightCyan`, `brightWhite`, or `default`

---
Expand Down
13 changes: 2 additions & 11 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,14 @@ import Control.Monad (when)
import Events.State (create)
import IO.Taskell (exists, readFile)
import IO.Config (Config, setup)
import System.Console.Terminal.Size (Window(..), size)

import App (go)

getSize :: IO (Int, Int)
getSize = do
s <- size
case s of
Just (Window h w) -> return (w, h)
Nothing -> return (80, 30)

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

-- if taskell.md exists/created then start
main :: IO ()
Expand Down
26 changes: 21 additions & 5 deletions roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,35 @@
- Add some tests
- Avoid having to normalise the state?
- Use Reader monad to pass around config
- Rename Persistence to IO.Taskell
- Remove duplication of config - currently using ini and hard-coded
- Move Help modal creation into Template Haskell
- Use lenses for nested data?

## Bugs

- Items near bottom of the list jump in position
- List titles sometimes go missing
- 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
- Help modal needs to scroll on smaller windows

## To Do

- Move between lists with `m` - shows possible lists
- Left/Right arrow keys in insert mode
- If column width is more than the screen width then padding and width should be reduced so that it fits (within reason)
- Add tags/labels with `t`
- Move between lists with `m` - shows possible lists
- On `?` show keyboard commands
- Add due dates to tasks with `d`
- URL field - plus config to run specific command when selected (e.g. `open -a Chrome.app #{url}`)
- Copy and paste?
- Add custom key support
- If column width is more than the screen width then padding and width should be reduced so that it fits (within reason)
- Add Trello import

## In Progress


## Done

- `a` to add
Expand Down Expand Up @@ -107,3 +112,14 @@
- `C` doesn't work properly
- Custom colours
- `.taskell` config file in home directory
- Rename Persistence to IO.Taskell
- List titles sometimes go missing
- Use Template Haskell to import in config file templates
- On `?` show keyboard commands
- Remove size from state
- Sub-lists
* ~Scrolling in sub-tasks~
* ~Press Enter to create next~
* ~Word wrapping~
* ~Searching~
* ~Delete items~
26 changes: 14 additions & 12 deletions src/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,36 @@ module App (go) where
import Control.Monad (void)
import Control.Monad.IO.Class (liftIO)
import Control.Concurrent (forkIO)
import Events.State (State, Mode(..), lists, continue, path, mode)
import Events.State (State, Mode(..), continue, path, mode, io)
import Data.Taskell.Lists (Lists)
import Brick

import IO.Taskell (writeFile)
import IO.Config (Config, LayoutConfig, layout, generateAttrMap)
import IO.Config (Config, layout, generateAttrMap)

import Events.Actions (event)

import UI.Draw (draw, chooseCursor, scroll)
import UI.Draw (draw, chooseCursor)
import UI.Types (ResourceName(..))

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

-- App code
handleEvent :: LayoutConfig -> State -> BrickEvent ResourceName e -> EventM ResourceName (Next State)
handleEvent lo s' (VtyEvent e) = let s = event e s' in
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 lo s >> liftIO (store s) >>= Brick.continue
_ -> scroll lo s >> Brick.continue s
handleEvent _ s _ = Brick.continue s
_ -> case io s of
Just ls -> liftIO (store ls s) >>= Brick.continue
Nothing -> Brick.continue s
handleEvent s _ = Brick.continue s

go :: Config -> State -> IO ()
go config initial = do
attrMap' <- const <$> generateAttrMap
let app = App (draw $ layout config) chooseCursor (handleEvent $ layout config) return attrMap'
let app = App (draw $ layout config) chooseCursor handleEvent return attrMap'
void (defaultMain app initial)
16 changes: 11 additions & 5 deletions src/Data/Taskell/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Data.Taskell.List where
import Data.Text (Text)

import Prelude hiding (splitAt, filter)
import Data.Sequence (Seq, (|>), (!?), (><), deleteAt, splitAt, filter)
import Data.Sequence as S (Seq, (|>), (!?), (><), deleteAt, splitAt, filter, adjust', update, empty)
import qualified Data.Taskell.Seq as S

import Data.Taskell.Task (Task, blank, contains)
Expand All @@ -23,6 +23,9 @@ empty t = List {
new :: List -> List
new = append blank

count :: List -> Int
count = length . tasks

updateTitle :: List -> Text -> List
updateTitle ls s = ls { title = s }

Expand All @@ -39,10 +42,13 @@ extract i l = do
(xs, x) <- S.extract i (tasks l)
return (l { tasks = xs }, x)

update :: Int -> (Task -> Task) -> List -> Maybe List
update i fn l = do
ts' <- S.updateFn i fn (tasks l)
return $ l { tasks = ts' }
updateFn :: Int -> (Task -> Task) -> List -> List
updateFn i fn l = l { tasks = ts }
where ts = adjust' fn i (tasks l)

update :: Int -> Task -> List -> List
update i t l = l { tasks = ts }
where ts = S.update i t (tasks l)

move :: Int -> Int -> List -> Maybe List
move from dir l = do
Expand Down
13 changes: 7 additions & 6 deletions src/Data/Taskell/Lists.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{-# LANGUAGE OverloadedStrings #-}
module Data.Taskell.Lists where

import Prelude hiding (length)
import Data.Text (Text)
import Data.Maybe (fromMaybe)
import Data.Sequence (Seq, fromList, (!?), (|>), deleteAt, length)
import Data.Sequence as S (Seq, fromList, (!?), (|>), deleteAt, length, update)
import qualified Data.Taskell.Seq as S
import Data.Taskell.Task (Task)
import Data.Taskell.List (List(..), empty, extract, append, searchFor)
Expand All @@ -13,8 +14,8 @@ type Lists = Seq List
initial :: Lists
initial = fromList [empty "To Do", empty "Done"]

update :: Int -> Lists -> List -> Lists
update = S.update
updateLists :: Int -> Lists -> List -> Lists
updateLists i ls l = S.update i l ls

count :: Int -> Lists -> Int
count i ts = case ts !? i of
Expand All @@ -31,8 +32,8 @@ changeList (list, i) ts dir = do
b <- ts !? next -- get next list
(a', task) <- extract i a -- extract selected task
let b' = append task b -- add selected task to next list
let list' = update list ts a' -- update extracted list
return $ update next list' b' -- update next list
let list' = updateLists list ts a' -- update extracted list
return $ updateLists next list' b' -- update next list

newList :: Text -> Lists -> Lists
newList s ts = ts |> empty s
Expand All @@ -56,7 +57,7 @@ appendToLast' t ls = do
let i = length ls - 1
l <- ls !? i
let l' = append t l
return $ update i ls l'
return $ updateLists i ls l'

appendToLast :: Task -> Lists -> Lists
appendToLast t ls = fromMaybe ls $ appendToLast' t ls
23 changes: 1 addition & 22 deletions src/Data/Taskell/Seq.hs
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
module Data.Taskell.Seq where

import Prelude hiding (splitAt, drop)
import Data.Sequence (Seq, (!?), (|>), (><), insertAt, deleteAt, splitAt, drop, fromList)

type Split a = (Seq a, a, Seq a)

empty :: Seq a
empty = fromList []
import Data.Sequence (Seq, (!?), insertAt, deleteAt)

extract :: Int -> Seq a -> Maybe (Seq a, a)
extract i xs = do
c <- xs !? i
let a = deleteAt i xs
return (a, c)

splitOn :: Int -> Seq a -> Maybe (Split a)
splitOn i xs = do
let (a, b) = splitAt i xs
current <- b !? 0
let b' = drop 1 b
return (a, current, b')

update :: Int -> Seq a -> a -> Seq a
update i xs x = insertAt i x $ deleteAt i xs

updateFn :: Int -> (a -> a) -> Seq a -> Maybe (Seq a)
updateFn i fn xs = do
(a, c, b) <- splitOn i xs
return ((a |> fn c) >< b)

shiftBy :: Int -> Int -> Seq a -> Maybe (Seq a)
shiftBy from dir xs | from == 0 && dir < 0 = Nothing
| otherwise = do
Expand Down
Loading

0 comments on commit 14ac9c4

Please sign in to comment.