-
Notifications
You must be signed in to change notification settings - Fork 5
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
Ignore ANSI terminal escape sequences in length calculations #21
Comments
@Xitian9 - you wrote the fairly complex code for computing real lengths. How hard would it be to have it ignore ANSI escape sequences? I think that for the majority of widely used ones it would suffice to start the match on 'ESC [' and end on any ascii letter. |
This is an issue I'm fairly familiar with, as we've tried different ways of dealing with it in hledger. Dealing with malformed ANSI escape sequences is what makes this especially tricky. I currently think that the best approach is to not keep your ANSI markup in the string itself, but keep it separated in a data type and only stick it all together after you're done with any need to measure its length. See for example here: https://github.com/muesli4/table-layout/blob/master/src/Text/Layout/Table/Cell/Formatted.hs. You might be interested in using the |
Impressive work, @silby. Thank you! |
Ignoring ANSI escape sequences would allow to layout marked up text in the terminal. Escape sequences for text markup all follow the pattern
\ESC[([0-9;]*m
.Initial discussion: hslua/hslua-module-doclayout#2
The text was updated successfully, but these errors were encountered: