-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support color in NINJA_STATUS #713
Comments
I think bash handles this by special markers that delimit regions that have brevity due to phone |
On Tue, Jan 28, 2014 at 08:54:00 -0800, Evan Martin wrote:
Looking at zsh, it uses %0{$zero_width%} to denote such sections. I |
It looks like bash uses '[' and ']' to delimit zero-width portions. Do you have a preference? Maybe something else? |
Why not just hard-code an ignore for ansi escape codes (or at least ansi escape color codes) when counting the characters as #912 is trying to do? This seems to be going about it the hard way, adding complexity both to the code and to the language. Current situation: no ansi codes are supported in This could have been a twenty minute patch, but now it's turned into a five-year ordeal due to difficult decisions finding the perfect syntax. |
Adds support for ANSI escape sequences used for colorization to the job status indicator, and updates `ElideMiddle()` to account for the non-obvious change in text width. As an example, the following will now emit the job status in green: env NINJA_STATUS="\\033[32m[%f/%t] \\033[0m" ninja; Invalid color escape codes are treated as plain text (as before). ANSI escape sequences apart from `\033...m` are not supported. Closes ninja-build#713. Closes ninja-build#912.
Adds support for ANSI escape sequences used for colorization to the job status indicator, and updates `ElideMiddle()` to account for the non-obvious change in text width. As an example, the following will now emit the job status in green: env NINJA_STATUS="\\033[32m[%f/%t] \\033[0m" ninja; Invalid color escape codes are treated as plain text (as before). ANSI escape sequences apart from `\033...m` are not supported. Closes ninja-build#713. Closes ninja-build#912.
Yes, that sounds like the best idea. Ideally that counting should only be done once (when parsing
It's supported: env $'NINJA_STATUS=\x1b[32m[%f/%t] \x1b[0m' ninja The problem is |
To do the count once, a map of console width to string length would be necessary. But it is possible to elide it as long as the |
Adds support for ANSI escape sequences used for colorization to the job status indicator, and updates `ElideMiddle()` to account for the non-obvious change in text width. As an example, the following will now emit the job status in green: env NINJA_STATUS="\\033[32m[%f/%t] \\033[0m" ninja; Invalid color escape codes are treated as plain text (as before). ANSI escape sequences apart from `\033...m` are not supported. Closes ninja-build#713. Closes ninja-build#912.
I was happy to see that |
See #1584. |
@mathstuf As far as I can tell #1584 is about stripping color codes for non-color capable terminals/output. The problem reported above is that ninja's eliding logic doesn't take escape codes into account. It should, when deciding how to elide the output, regardless of the output terminal's capabilities. |
Sorry, I meant #1494. |
Correctly handle ANSI Escape Codes in ElideMiddle, fix #713
It would be nice if ninja understood color natively. Currently, I have a wrapper script which tests stdout for being a terminal and changes NINJA_STATUS accordingly. The problem is that ninja doesn't know that the color escape sequences are really zero-width when printed on the terminal and causes elision to happen at improper places.
The text was updated successfully, but these errors were encountered: