This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I was just looking through the output2 code, with the hopes of being able to write text of different colors. I see that there is a hard-coded distinction between 3 colors: one for links (blue), one for isErr()==true (brown), and the normal black. It would be nice if there were some way for module developers to extend this, either by specifying the color directly in OutputWriter.println(), or perhaps by specifying a color reference like "nb.output.foreground". (How are these configured, anyway?)
Or, if an API change is too much to ask, how about the ability to say, "this line is this color", and if I want that ability, I have to declare a dependency on the implementing module. (After all, right now I'm declaring a dependency on core/term to get this.) In the long run, though, I still think it's a good API addition, and the underlying implementation is certainly capable of it.
are we talking about SPI to plug custom colors for hyperlinks or an API that lets UI users of the output2 module to write lines in multiple colors? spi is ok with me, preferably through the UImanager configurations. I'd rather not add a new method to OutputWriter that would allow custom colors for any line. Currently color is only used to distinguish stdout from stderr and to mark hyperlink lines. Having custom coloring on would mean that multiple parts of the IDe will choose their coloring differently, thus creating UI inconsistency in the output window.
I wasn't talking about hyperlinks. I understand your concern about module writers creating something that looks inconsistent, color-wise, with the rest of the IDE, but as of now there's NO way for me to write out lines in different colors, short of using the ansi terminal module (which is what I'm doing). My use case is: I'm using the output window to simulate a conversation between a human and a computer (think Eliza). I want different colors for the different parties, and a third color for system messages that may come in during the "conversation". Tim had told me this would be a simple thing to add. Why not add it at the implementation layer, even if it's not exposed all the way up to IOProvider? I'm just saying I'd rather use the new output2 module (instead of term), for a number of other reasons, and this is the only thing preventing me.
Vile and psycho way to implement this with no API change at all, in the editor kit class: if (listenerForLine instanceof Color) { //..paint with it ...
Created attachment 24387 [details] Patch to support colored output
I just attached a patch that will do this. It doesn't create any API, but since a couple people have asked for this, if they want to patch their copy of core/output2 and do an implementation dependency on it, this will work. How to use it: Use the standard IOProvider way of getting an output handle. Cast the result of either io.getOut() or io.getErr() to o.n.c.o2.LineColoredOutputWriter Use the one method of that interface: println (String, Color). Enjoy...
Created attachment 24388 [details] Second diff - last one had an undeleted println() or two
Reassigning to new module owner Tomas Holy.
Any plans to implement this? This enhancement has been requested several times (see Issue #124366) during usability studies and would be helpful for support of quick information recognition in the output window. Seems like it shouldn't be much work since the patch is already done thanks to Tim.
Fixed in core-main #b846993e69a9