-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Color not printed if BColor not specified #6
Comments
Sorry for the late reply, I did not get a notification -- it won't happen again 😉 I could not reproduce the issue. I'm on Mac 10.11.6, using IntelliJ and the message was printed with color (see the gif below). Can you provide more info about your env (e.g. OS in use, console in use, versions of Java and JCDP)? Can you also update to JCDP 2.0.2? I upgraded the version of our Jansi dependency, as they have been doing some work around Cygwin. |
I created a branch to address this, with a new unit test that includes your example (and that is currently passing, without the need of any fix): https://github.com/dialex/JCDP/tree/issues/6 |
I am having the exact same problem on a Mac. Unless you specify a background color (also can't be BColor.NONE), the text printed to the terminal is completely default. I actually thought this library didn't do anything until I added a background color. |
I wasn't using IntelliJ's terminal, I was using the Mac terminal. I don't know what it is, but $TERM replies xterm-256color. I created instantiated the ColoredPrinter with the ColoredPrinterBuilder, so it wasn't exactly like the gif. Java 1.8, JCDP 2.0.3.1 I won't be able to re-test on the Mac until Monday. |
*Compiling with 1.8 but down to 1.7 source level |
Same problem, even trying the exact method in the gif. The gif is using a different version of JCDP than I am. |
Tested on Intellij terminal and Linux terminal. No color - just prints message. |
Thanks for your effort Blake, I'll have a look this week. |
So the same thing happens to me, but I suspect I know why. In my case I have a custom console logger for Fitnesse tests. When I run the logger directly from say a jUnit test its fine but when run as part of a fitnesse test runner it fails. My hunch is that somewhere along the lines the terminal information is being lost. How exactly does jcdp determine the terminal? Can it be passed to it? I don't see anything in ColoredPrinter that looks like I can tell it? |
Hey @ryber. JCDP uses your Java's standard out (source), so it doesn't really choose the terminal -- that's Java's responsibility. However, this line of code tries to guess your Operating System, and picks an ColoredPrinter implementation accordingly. If you use polymorphism and do ...does it fix the issue? |
Sure @jdemeule, |
I fact I only notice that specifying a "empty" background color is disturbing for macOS terminal but do not specifying it is ok ( If I take a look at the code generating this escape sequence, it seems that the pair foreground/background is always generated. @Override
public String generateCode(Attribute attr, FColor fg, BColor bg) {
return Ansi.PREFIX +
attr.toString() + Ansi.SEPARATOR +
fg.toString() + Ansi.SEPARATOR +
bg.toString() + Ansi.POSTFIX;
} I could suggest to adapt this function this way: @Override
public String generateCode(Attribute attr, FColor fg, BColor bg) {
if (bg == BColor.NONE)
return Ansi.PREFIX +
attr.toString() + Ansi.SEPARATOR +
fg.toString() + Ansi.POSTFIX;
return Ansi.PREFIX +
attr.toString() + Ansi.SEPARATOR +
fg.toString() + Ansi.SEPARATOR +
bg.toString() + Ansi.POSTFIX;
} I think at a reproducible test case could be the one from the original issue final ColoredPrinter cp = new ColoredPrinter.Builder(1, false)
.foreground(Ansi.FColor.GREEN)
.build(); |
Hello, I have the same issue here. On windows where I normally develop everything is fine. But the same jar file does not produce color on the Linux (Fedora 30) comment line without having a background specified. I may be doing something wrong so I created a simple java app that has this issue occur. It's a very basic maven project using JCDP 3.0.0 and is located here: https://github.com/frossm/colortest You should be able to just use "mvn package" to get the full jar file in the Target directory. I also uploaded it as a release if you don't want to go through that. Here is the program output in Windows: ** Here is the same running in Linux:** I love the software and use it all the time. I'm happy to help figure this out, just let me know how I can help. Thank you very much. Michael |
Thanks a lot for the examples, that are precious for my debugging. Currently I'm on working on #21, as soon as I close that I'll move to this one. |
I cloned your repo and was able to reproduce your issue. Both IntelliJ's and Mac's console trigger a IntelliJ (unexpected behaviour): There's two things wrong with IntelliJ:
This wrong behaviour only happens on IntelliJ. The same code running on iTerm prints as expected. I opened a ticket on IntelliJ's support. |
Possible solutions:
|
Hello. For my issues on Linux I was not using IntelliJ. I tried on Fedora using Gnome Terminal and Tormentor using it's terminal (which I'm not sure if it's Gnome). Both displayed the same issue running the same colortest jar file. |
Thank you Diogo. Maven repository had the new version and I just tested
it. Seems to work great in Linux now. I need to do a bit more testing,
but looking good! Thank you.
Happy holidays.
Michael
…On Sun, Dec 22, 2019 at 9:58 AM Diogo Nunes ***@***.***> wrote:
My latest PR (#34 <#34>) should fix
your issue, already tested it locally.
I published a new release 3.0.1
<https://github.com/dialex/JCDP/releases/tag/v3.0.1> on maven, but it
will takes a while to appear. Have a go with that new version, and let me
know if it worked.
Thank you for your patience and happy festivities 😉
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMLETYDJF6AYIYDNAVWW4LQZ6FCLANCNFSM4C3EQWGA>
.
|
Color printing isn't working unless BColor is specified.
For example, I'd expect this to work:
But it will just print text regularly, until BColor is set as well:
Setting BColor.None gives same no-op results
The text was updated successfully, but these errors were encountered: