Skip to content

Conversation

connorjak
Copy link
Contributor

@connorjak connorjak commented Aug 13, 2020

text_ansi() and text_ansi_colored() are added. They have the exact same interface as text() and text_colored(), with the exception of logic going on inside to find and react to ANSI escape sequences. I find this useful for displaying logged colored terminal output. colorama.Fore colors should all work; no init() required.

I do not know if adding ANSI escape sequences and using text_ansi() is computationally slower than a series of text_colored() calls. That would be interesting to figure out for use cases besides having ANSI codes already embedded in the input.

C++ implementation from here: https://gist.github.com/ddovod/be210315f285becc6b0e455b775286e1

Sorry for no tests yet; I haven't been able to get the test build configuration correct yet.

@swistakm
Copy link
Member

Thanks. Could you take a look at builds failing on AppVeyor?


std::string seq( &s[2], seqEnd );
std::string colorStr;
for (const auto& el : jet::split(seq, ";")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI build is failing here on the const auto&. This syntax is probably too new; it should be replaced with a less-modern substitute.

@connorjak
Copy link
Contributor Author

Otherwise, looks like there's some sort of deprecation thing going on with Sphinx? I can't make sense of the other errors.

Doing this online, so no guarantees this fixes it immediately.
@coveralls
Copy link

coveralls commented Aug 19, 2020

Coverage Status

Coverage decreased (-3.8%) to 49.552% when pulling f49f82d on connorjak:AnsiText into f9f45a5 on swistakm:master.

@connorjak
Copy link
Contributor Author

These changes might have fixed the tests-build on my computer. I'll get on to writing some tests soon.

@swistakm swistakm merged commit bf29609 into pyimgui:master Dec 14, 2020
@swistakm swistakm added the release pending Merged but still needs official release label Dec 14, 2020
@swistakm
Copy link
Member

Sorry it took so long, when the pipelines finish I will release it as new version. I made slight changes to the file names to keep everything more consistent with existing code.

@swistakm swistakm mentioned this pull request Dec 15, 2020
@swistakm
Copy link
Member

I had to spend 6 hours on investigating CI issues. Seems like we're almost there. But in the meantime I've noticed that this relies on some ImGui internals that have some risk of being changed often. That's I will make a small change to expose it in extra submodule. This way users will be aware that this isn't something available out-of-the box in the base library.

Does it sound reasonable?

@connorjak
Copy link
Contributor Author

Sure, that sounds reasonable. I think the implementation I used (linked above) copied the internals of imgui's text() function, so while it should be rather straightforward to keep up to date, and the API should stay rock-solid, it needs to be maintained.

@swistakm swistakm removed the release pending Merged but still needs official release label Dec 16, 2020
@swistakm
Copy link
Member

Released as 1.3.0:

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

Successfully merging this pull request may close these issues.

3 participants