Skip to content

Commit

Permalink
Introduce 'g' keybinding to go to the top of the list
Browse files Browse the repository at this point in the history
This keybinding is the opposite of 'G' which goes to the end of the
list.

Closes: #59
  • Loading branch information
jelly authored and smallhadroncollider committed Jan 20, 2020
1 parent 11eba52 commit 7551f2a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Events/Actions/Normal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ events
, (A.Left, left)
, (A.Right, right)
, (A.Bottom, bottom)
, (A.Top, top)
-- new tasks
, (A.New, (startCreate =<<) . (newItem =<<) . store)
, (A.NewAbove, (startCreate =<<) . (above =<<) . store)
Expand Down
2 changes: 2 additions & 0 deletions src/Events/Actions/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data ActionType
| Left
| Right
| Bottom
| Top
| New
| NewAbove
| NewBelow
Expand Down Expand Up @@ -56,6 +57,7 @@ read "next" = Next
read "left" = Left
read "right" = Right
read "bottom" = Bottom
read "top" = Top
read "new" = New
read "newAbove" = NewAbove
read "newBelow" = NewBelow
Expand Down
7 changes: 7 additions & 0 deletions src/Events/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module Events.State
, above
, below
, bottom
, top
, previous
, duplicate
, next
Expand Down Expand Up @@ -206,6 +207,12 @@ bottom = pure . selectLast
selectLast :: InternalStateful
selectLast state = setIndex state (countCurrent state - 1)

top :: Stateful
top = pure . selectFirst

selectFirst :: InternalStateful
selectFirst state = setIndex state (0)

removeBlank :: Stateful
removeBlank state = do
currentTask <- getCurrentTask state
Expand Down
3 changes: 2 additions & 1 deletion src/IO/Keyboard.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ defaultBindings =
, (BChar 'j', A.Next)
, (BChar 'h', A.Left)
, (BChar 'l', A.Right)
, (BChar 'g', A.Bottom)
, (BChar 'G', A.Bottom)
, (BChar 'g', A.Top)
, (BChar 'a', A.New)
, (BChar 'O', A.NewAbove)
, (BChar 'o', A.NewBelow)
Expand Down
1 change: 1 addition & 0 deletions src/UI/Draw/Modal/Help.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ descriptions =
, ([A.Due], "Show tasks with due dates")
, ([A.Previous, A.Next, A.Left, A.Right], "Move down / up / left / right")
, ([A.Bottom], "Go to bottom of list")
, ([A.Top], "Go to top of list")
, ([A.New], "Add a task")
, ([A.NewAbove, A.NewBelow], "Add a task above / below")
, ([A.Duplicate], "Duplicate a task")
Expand Down
1 change: 1 addition & 0 deletions templates/bindings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ next = j
left = h
right = l
bottom = G
top = g

# new tasks
new = a
Expand Down
3 changes: 2 additions & 1 deletion test/IO/Keyboard/TypesTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ notFullResult =
, (BChar 'j', A.Next)
, (BChar 'h', A.Left)
, (BChar 'l', A.Right)
, (BChar 'g', A.Bottom)
, (BChar 'G', A.Bottom)
, (BChar 'g', A.Top)
, (BChar 'a', A.New)
, (BChar 'O', A.NewAbove)
, (BChar 'o', A.NewBelow)
Expand Down

0 comments on commit 7551f2a

Please sign in to comment.