Added a Screen Class that manage all the writing to stdout.
Added the possibility to switch to the legacy method with a boolean flag:
Legacy: it uses console.clear() before every refresh, so it cause a black flash on all the area.
New method: it only move the cursor to [0, 0] and clear the screen from the last Y to the bottom, so there's no more black frame flash!
To make it work it needs to know the max Y cursor drawn and so I've introduced the Screen.startDraw() and Screen.endDraw() methods to start count the max cursor position and reset it at the end.
This is not solving all the flashing trouble:
To solve this we need to create the screen buffer and then flush to the stdout only once per frame. Actually we do it for each screen layer, so sometimes it's possible to see for an istant what is on the bottom of the current Widget.
The difficulty is to manage this keeping the styled strings (chalk) working.
Changed the draw screen algorytm:
This is not solving all the flashing trouble:
To solve this we need to create the screen buffer and then flush to the stdout only once per frame. Actually we do it for each screen layer, so sometimes it's possible to see for an istant what is on the bottom of the current Widget. The difficulty is to manage this keeping the styled strings (chalk) working.