Previous part: Command line task manager - 2

In this part we will make our task manager more interactive by scrolling up and downn.

We don’t have to do this, but in order to make our code more readable, it’s better to use descriptive constructors:

type Move = Scroller List
 
pattern Down x = This x :: Move
pattern Lift x = That x :: Move

After listing all tasks we have, let’s wait for an user input until any letter button pressed - match splits a sum type to an interesting part and uninteresting one (in our case it’s Letter and other ASCII symbols respectively):

 `yuk___` World `hv___` input `yok` Retry `ha` apply `ha_` on @Glyph `ho'ho` on @Letter `ho` row

If we got a Letter we compare it to either J or K lowercase letters and designate commands, otherwise throw an error (which gotta be caught by Retry and wait for another button press):

apply = is @(ASCII `MN` Glyph `ML_` Glyph `MN` Letter) `hu` it Wrong
 `la____` press `hv` Lower J `hv` Down
 `lo'ys'la` press `hv` Lower K `hv` Lift

As soon as there is a command to move, we feed it to scroll method:

 `yok___` State `ho` New `ha` Event `ha` scroll

And well, we also need to run this event loop again to emulate uninterruptible user interface:

 `yok___` Again `ha` Once

Just picking up items doesn’t seem useful. Probably we should introduce task statuses?

Full source code is available here.

Continue this tutorial