Don't clean terminal on each redraw but...#83
Conversation
redraw directly on existing output !
Codecov Report
@@ Coverage Diff @@
## master #83 +/- ##
=========================================
Coverage 96.47% 96.47%
Complexity 278 278
=========================================
Files 22 22
Lines 879 879
=========================================
Hits 848 848
Misses 31 31
Continue to review full report at Codecov.
|
|
@Lynesth this works really well, the test fixtures need to be updated and I think the new escape code should be added into the terminal package. |
When adding newlines using Frame->newline(), it only adds "\n" to the next row of the frame. If the new output was smaller than the previous one (by removing items for example), simply writing"\n" over the line doesn't clear it, so I'm using \033[2K to clear the line beforehand.
|
This looks fine to me - I can have a look at the tests later, they are pretty hard to modify - I usually just xdebug in to the assertions and copy the output from there to preserve the escape codes. @Lynesth let me know and I can take over the test fixes for this and maybe you want to send a PR to php-school/terminal with these escape codes in the |
redraw directly on existing output !
It's different from my last PR but it correctly removes flickering (at least for me, others will have to test) so everything seems very smooth.
It uses
\033[1Ewhich means "move the cursor to the beginning of the next line" and\033[Jwhich means "Clear everything from the cursor to the end of the terminal".I guess those two could be made into UnixTerminal functions.
Edit: Last change removed the use of \033[1E to put back new lines.