-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] use ANSI escape sequences in ProgressBar overwrite method #18496
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
Conversation
…ly printed output
👍 |
1 similar comment
👍 |
ANSI codes are very "unreadable". So, what do you think changing code like this: // Erase the line
$this->output->write("\x1B[2K"); By something like this? $eraseLineCode = "\x1B[2K";
// ...
$this->output->write($eraseLineCode); Or: $ansiCodes = array(
'eraseLine' => "\x1B[2K"
);
// ...
$this->output->write($ansiCodes['eraseLine']); Maybe in a separate PR? |
We can write them as class constants, but what do you think about implementing a class to build escape sequences? |
@alekitto Probably a very good idea but out of the scope of this PR. |
Thank you @alekitto. |
…te method (alekitto) This PR was squashed before being merged into the 2.7 branch (closes #18496). Discussion ---------- [Console] use ANSI escape sequences in ProgressBar overwrite method | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | maybe | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16957 | License | MIT | Doc PR | Rewritten `overwrite` method in ProgressBar class to use ANSI escape sequences to erase lines. This removes the need to store the last message length as it is not needed to fill the buffer with spaces anymore. As a plus it correctly resets the cursor position while clearing the output If the output is not decorated the behavior has not been changed. Could possibly cause a BC break if testing against the decorated emitted output as binary string Commits ------- b6cca4c [Console] use ANSI escape sequences in ProgressBar overwrite method
@fabpot Great! I'll open a new PR against the master branch for the escape sequences builder |
@alekitto please before sending a PR, open an issue to discuss about it. A "escape sequence builder" sounds too complex for this simple problem. Thanks! |
Rewritten
overwrite
method in ProgressBar class to use ANSI escape sequences to erase lines.This removes the need to store the last message length as it is not needed to fill the buffer with spaces anymore. As a plus it correctly resets the cursor position while clearing the output
If the output is not decorated the behavior has not been changed.
Could possibly cause a BC break if testing against the decorated emitted output as binary string