Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

support for ansi escapes in text #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mikecarlton-illumio
Copy link

This PR adds support for ansi escapes, allowing you to have colorized text in tables.

@aptinio
Copy link
Owner

aptinio commented Nov 2, 2015

Thanks for the PR @mikecarlton-illumio. The request to be able to colorize the cell contents has come up before. I've been wanting to add this feature and I've been thinking of doing so through a formatter block. Something like:

table.formatter = ->(cell) {
  colorize(cell.value)
}

This way, width computation is done before formatting (colorizing) the cell value.

@mikecarlton-illumio
Copy link
Author

That's interesting, but if I understand your comment correctly, I would define a function to apply color to a cell as a whole?

I think our use case is slightly different -- I'm including status info by coloring the text (green or red). Thus the color isn't a function of the cell or of the value itself, but is only known when the text is added to the cell.
Here's a sample:
image

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants