-
Notifications
You must be signed in to change notification settings - Fork 78
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
ANSIStrings could handle spaces specially #21
Comments
This is an interesting performance improvement! It's actually something that could be put to use in exa — there are quite a few places where it paints something in one colour, follows that with a default-coloured space, and then prints something in the same colour again. It could elide two of the colour codes if it knew that the spaces wouldn't actually affect anything. the problem with doing it automatically is that it requires a runtime check, and that's not going to be appropriate in all cases. (Especially as we'd have to check for Unicode space characters, too.) Instead, I think this is possible with a two-step approach:
It would have to be clever and detect styles that do affect just spaces, such as underline or background colours, but it's certainly possible. How does this sound? |
whoops hit the wrong button |
I'd be hesitant to add this much cleverness around spaces, when the application code could also avoid styling the spaces. This would also take carefully analyzing things like "print styled space, position cursor, print over the space". Does this case come up often enough to make it worth trying to omit the escape sequence? |
I see a potential improvement to ANSIStrings, where you can drop foreground colour changes for strings that are only whitespace.
I.E.
could not bother switching to blue in the middle.
The text was updated successfully, but these errors were encountered: