Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't clean terminal on each redraw but... #83

Merged
merged 3 commits into from
May 1, 2018

Conversation

Lynesth
Copy link
Collaborator

@Lynesth Lynesth commented Apr 30, 2018

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[1E which means "move the cursor to the beginning of the next line" and \033[J which 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.

@codecov-io
Copy link

codecov-io commented Apr 30, 2018

Codecov Report

Merging #83 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #83   +/-   ##
=========================================
  Coverage     96.47%   96.47%           
  Complexity      278      278           
=========================================
  Files            22       22           
  Lines           879      879           
=========================================
  Hits            848      848           
  Misses           31       31
Impacted Files Coverage Δ Complexity Δ
src/CliMenu.php 90.34% <100%> (ø) 60 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c883fb...b175ebb. Read the comment docs.

@mikeymike
Copy link
Member

@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.
@AydinHassan
Copy link
Member

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 UnixTerminal ?

@AydinHassan AydinHassan merged commit beaa41c into php-school:master May 1, 2018
@AydinHassan AydinHassan added this to the 3.0 milestone May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants