-
Notifications
You must be signed in to change notification settings - Fork 608
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
Add basic support for ANSI terminal escape sequences #39
Conversation
- when printing the cells of the view, we look for escape codes, and update the attributes of the cell accordingly. This is done via the escapeIntepreter struct and methods - add a colors.go example The code currently only supports the 8 basic colors, and bold, underscore and reverse.
Make the escape interpreter global to the whole printing of the view, not just the current line, so that the context isn't reset when we move to a new line
Updated the branch with a fix so that attributes carry over the new line |
f5a7dbc
to
2e9e6e5
Compare
First of all, sorry for the late response. Thanks for the contribution! I'll review it to see if it fits with the internals refactoring I have in progress. Basically, I want to use some kind of cell struct (containing color info) instead of |
No worries. I see that there are conflicts now, let me know when you're closer to a review, and I'll update the PR. Thanks! |
Hi @deweerdt , I just pushed a commit that adds support for colored text (b342d3a). Basically, now contents are stored as cells (rune + fgcolor + bgcolor) and ESC sequences are processed when the data is written to the View via View.Write(). This way:
For ESC sequences, I used your On the other hand, looks like you know quite well how ANSI colors work, would it be possible for you to create some tests for Please, check if everything works as expected. I also added a little example under Thanks a lot for your great contribution! :) |
I forgot the mandatory screenshot :) BTW note that everything is in the branch colors. |
That sounds good, I'll take a look at b342d3a this week-end. Thanks! |
Cool! Bear in mind that I pushed more commits to the branch |
The changes in b342d3a look good to me, thanks! |
Closing this #PR in favor of b342d3a |
Merged in master! Thanks! :D |
update the attributes of the cell accordingly. This is done via the
escapeIntepreter struct and methods
The code currently only supports the 8 basic colors, and bold,
underscore and reverse.