Instead of a regular List we better to use a Scrolling List - it consists of a focused item, items left behind (since they are already passed through) and future ones.
This time we render a point prefix to distiguish a focused item from the rest:
If we want to render it so it looks like a regular List we have to do it in a bit tricky way.
To render a focused value, we will use -> prefix to designate a cursor:
What about the rest? Previously passed items we need to traverse backwards, and future ones - forwards:
This is how the program should work if you run it:
So we used an advanced data structure for scrolling our list - it’s time to make it scrollable.