mihnita / ansi-econsole

Eclipse plugin that understands ANSI escape sequences to color the Eclipse console output.
http://www.mihai-nita.net/java/
Other
91 stars 25 forks source link

CDT default colors are lost #75

Closed ydaveluy closed 2 years ago

ydaveluy commented 2 years ago

Hello,

Thanks for this great plugin !

In the Eclipse CDT console (C/C++) some colors are handled directly by CDT. When ansi-econsole is enabled, these colors are lost. The first and last following lines are generated by CDT and should be blue: ` 18:34:18 Build of configuration Default for project Test

make

18:34:18 Build Finished. 0 errors, 0 warnings. (took 391ms) ` I think that existing styles should be kept when no custom AnsiPosition are found.

Moving line https://github.com/mihnita/ansi-econsole/blob/73a4791870ee9a6b326988bd2e99e78647867114/AnsiConsole/src/mnita/ansiconsole/participants/AnsiConsoleStyleListener.java#L154 to https://github.com/mihnita/ansi-econsole/blob/73a4791870ee9a6b326988bd2e99e78647867114/AnsiConsole/src/mnita/ansiconsole/participants/AnsiConsoleStyleListener.java#L157 seems to solve the problem.

Regards,

Yannick

mihnita commented 2 years ago

Thank you for reporting this.

Unfortunately I can't reproduce it. I've tried it on Windows (with "Visual Studio" toolchain), macos (with "MacOSX GCC" and "Makefile project"), and Linux (gcc and Makefile project) Can you provide some more info?


Do you have more than one C/C++ project opened? There might be a chance it is issue #50?


Something you can try WARNING: will need cleanup afterwards, meaning uninstall the plugin, remove the test site, and reinstall from Marketplace

"Help" (main menu) --> "Install New Software..." --> Manage (button, top-right) Sort by Location, find https://www.mihai-nita.net/eclipse, and change it to https://www.mihai-nita.net/eclipse_test (or make a copy, your call) "Apply and Close" (button)

In the "Work with:" drop-down-list (combo-box) select "Mihai's Eclipse plugins - https://www.mihai-nita.net/eclipse_test"

You should see an update (1.4.7.202205170912) Install it, and see if it solves the problem.


To cleanup:

WARNING: that test folder will go away at some point (after the next release), so don't keep it around. And what's there should be considered beta / pre-release / unstable / not-properly-tested :-)

Mihai

ydaveluy commented 2 years ago

Hello,

To reproduce with Eclipse 2022-03 (C++) on Linux with ansi-econsole 1.4.6, create an Hello World C++ Makefile Project (Project->New->C/C+->C++ Project->Makefile Project->Hello World C++ Makefile Project) from a new workspace.

In the Makefile add -fdiagnostics-color flag: CXXFLAGS = -O2 -g -Wall -fmessage-length=0 -fdiagnostics-color

In the cpp file add an invalid statement, for example: invalid_type i;

Build the project:

` 11:06:37 Incremental Build of configuration Default for project Test make all g++ -O2 -g -Wall -fmessage-length=0 -fdiagnostics-color -c -o Test.o Test.cpp [01m[KTest.cpp:13:1:[m[K [01;31m[Kerror: [m[K‘[01m[Kinvalid_type[m[K’ does not name a type invalid_type i; [01;32m[K ^[m[K make: *** [Test.o] Error 1 "make all" terminated with exit code 2. Build might be incomplete.

11:06:37 Build Failed. 2 errors, 0 warnings. (took 147ms) `

Colors are not correctly escaped.

With the beta release, the text between 11:06:37 Incremental Build of configuration Default for project Test and 11:06:37 Build Failed. 2 errors, 0 warnings. (took 147ms) is correctly colored.

The remaining issue is that color is lost for the first and last lines: 11:06:37 Incremental Build of configuration Default for project Test and 11:06:37 Build Failed. 2 errors, 0 warnings. (took 147ms)

Can you reproduce the problem ?

mihnita commented 2 years ago

Reproduced.

It was working fine for non-Makefile projects, and for the Makefile ones I just didn't see it. The kind of thing where you look at it and don't see it :-)

And your fix seems to be right on.

I am adding it as a fix, but I need to do some proper testing before releasing. Most likely this week-end.

Thanks! Mihai

ydaveluy commented 2 years ago

Sorry, there is a regression with this fix when a color is on multiple lines:

In the following example all lines should be green ` [33;32mcolor is ok

no color here

color is ok [0m ` If I have time this weekend I will investigate to find a better fix.

Yannick

ydaveluy commented 2 years ago

Hello,

Feel free to discuss about the following PR: https://github.com/mihnita/ansi-econsole/pull/76

Yannick

mihnita commented 2 years ago

Sorry, I have a fix already. I will give it some time to test it, but seems to be fine.

mihnita commented 2 years ago

OK, I've decided to not take the PR. I have a fix already, and that PR did a big refactoring that seem to break some existing functionality.

mihnita commented 2 years ago

Thank you for the attempt.

A new build published in the test folder, and my fix is already pushed to github.

I will test a bit more, and will release in a few days.

ydaveluy commented 2 years ago

Hello Mihai,

Thanks for your answer.

I understand that my PR is big and there was functionalities I didn't know how to test. I did this refactoring to solve random issues when launching the build of all projects in parallel (project->build all). I performed more test today and it does not break existing functionalities: stdErrColor and hyperlinks are correctly working.

I don't want to insist but I encourage you to give it a try: https://github.com/ydaveluy/ansi-econsole/tree/bugfix/issue_75

Yannick