For application which are not Swing or JSF but makes use of the terminal output capabilities.
X3.64 define a set commands reconized on all systems to display/edit output texts.
A basic fonctionality is coloring text.
Since Netbeans IDE redirect all System.out message in it's output TopComponent,
he should try to behave like a normal terminal, and handle thoses special strings. Perhaps not all of them but the most commonly used one.
For real terminal functionality, you have to use the Terminal window. It seems to support color output, though it also seems to be too buggy to run nethack or emacs -nw properly (some issue with cursor movement). Terminal maintains a fixed character grid and operates with "raw" I/O (individual keypresses and render commands).
Currently it is not supported to use Terminal as the default for Java SE projects, but that is a separate issue which is complicated by how such programs are launched; see bug #68770 for some discussion. You can of course open the Terminal manually and run the program from a shell prompt - just less conveniently (not much improvement over running e.g. gnome-terminal outside the IDE).
An alternate interpretation of this RFE is a limited enhancement to the Output Window. OW is not a terminal at all but more like an append-only log viewer with infinite scrollback and unlimited line length with retroactive linewrap display; it operates with "cooked" I/O (lines of text entered and lines of text printed). Emacs shell-mode is a decent analogue (though unlike OW it supports ^H to redraw portions of the current line, e.g. in ASCII progress bars). Since OW does support color output, it would be possible for it to interpret those ANSI escape sequences which just control color of forthcoming text. (Underlining etc. are not supported.)
There is probably no TERM variable appropriate for an environment which only handles color escapes and not cursor movement etc., so the program would just have to optimistically assume that these escape sequences were supported.
Probably http://en.wikipedia.org/wiki/ANSI_escape_code#Colors is everything that needs to be interpreted in core.output2. E.g. "some \u001B[01;34mstuff\u001B[0m here" should display as "some stuff here" with "stuff" in blue. (GNU) ls --color is an easy test case.
(It should actually be possible to implement this for Ant output using an AntLogger, even in a plugin, but that is less general - would not work for Maven output, server console output, etc.)
Supporting basic color escape sequences: core-main #48ee6806b8a6
Linux test case: sudo apt-get install source-highlight, then make an Ant script with
<exec command="source-highlight --out-format esc --style-file /usr/share/source-highlight/esc.style -o /dev/stdout -i /path/to/some/big/SourceFile.java"/>
Integrated into 'main-golden', will be available in build *201012030001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Jesse Glick <email@example.com>
Log: #192779: support ANSI color escape sequences.
I tryed the 201012030001 build.
Colors are here but uncorrectly used.
He starts colors correctly but do not end them when asked to, so the color continue until the end of the line.
This escape sequence is used to reset the foreground color :
"\u001B[" +(byte)39 + "m"
This escape sequence is used to set bold font :
"\u001B[" +(byte)1 + "m"
This escape sequence is used to set 'faint'(something like color.darker()) color :
"\u001B[" +(byte)2 + "m"
This escape sequence is used to reset all colors and font :
"\u001B[" +(byte)0 + "m"
We also perform a naive check to see if the terminal handle x3.64 using
System.getenv("COLORTERM") != null
or Integer.parseInt( System.getenv("CLICOLOR") ) !=0
So the netbeans output is not reconized and the application automaticly disable x3.64 outputs. Maybe one of those vars could be set ?
(In reply to comment #4)
> This escape sequence is used to reset the foreground color :
> "\u001B[" +(byte)39 + "m"
Never saw that one in use, but should be easy to treat it like 30.
> This escape sequence is used to set bold font :
> "\u001B[" +(byte)1 + "m"
The OW does not support boldfacing, sorry.
> This escape sequence is used to set 'faint'(something like color.darker())
> color :
> "\u001B[" +(byte)2 + "m"
Wikipedia lists this as "not widely supported" but it does not sound difficult to implement. I have no test case for it.
> This escape sequence is used to reset all colors and font :
> "\u001B[" +(byte)0 + "m"
That should already work.
> We also perform a naive check to see if the terminal handle x3.64 using
> System.getenv("COLORTERM") != null
Override -init-macrodef-java in build.xml and add <env key="COLORTERM" value="ansi"/> or whatever. (NB Ant-based Java SE projects do not support this as a standard config parameter since Ant does not seem to support an <envset> that could be read from properties akin to <syspropertyset>.) Or set it in the wrapper for NetBeans itself.
2 & 39 implemented: core-main #7fd6595b8b3e
Integrated into 'main-golden', will be available in build *201012080001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Jesse Glick <firstname.lastname@example.org>
Log: #192779 cont'd: support for SGR params 2 & 29.