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:
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):
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):
As soon as there is a command to move, we feed it to scroll
method:
And well, we also need to run this event loop again to emulate uninterruptible user interface:
Just picking up items doesn’t seem useful. Probably we should introduce task statuses?
Full source code is available here.