Bug 192779 - X3.64 escape sequence support in output window
X3.64 escape sequence support in output window
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Output Window
6.x
All All
: P3 with 1 vote (vote)
: 7.0
Assigned To: Jesse Glick
issues@platform
:
Depends on: 197114 197540
Blocks:
  Show dependency treegraph
 
Reported: 2010-12-02 09:44 UTC by eclesia
Modified: 2011-04-07 16:39 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description eclesia 2010-12-02 09:44:01 UTC
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.

http://www.markcrocker.com/rexxtipsntricks/rxtt28.2.0777.html 


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.
Comment 1 Jesse Glick 2010-12-02 14:13:36 UTC
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.)
Comment 2 Jesse Glick 2010-12-02 16:28:57 UTC
Supporting basic color escape sequences: core-main #48ee6806b8a6

Linux test case: sudo apt-get install source-highlight, then make an Ant script with

    <target name="testme">
        <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"/>
    </target>
Comment 3 Quality Engineering 2010-12-03 06:19:14 UTC
Integrated into 'main-golden', will be available in build *201012030001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/48ee6806b8a6
User: Jesse Glick <jglick@netbeans.org>
Log: #192779: support ANSI color escape sequences.
Comment 4 eclesia 2010-12-03 08:42:08 UTC
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 ?
Comment 5 Jesse Glick 2010-12-03 11:54:23 UTC
(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.
Comment 6 Jesse Glick 2010-12-07 16:27:06 UTC
2 & 39 implemented: core-main #7fd6595b8b3e
Comment 7 Quality Engineering 2010-12-08 06:36:25 UTC
Integrated into 'main-golden', will be available in build *201012080001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/7fd6595b8b3e
User: Jesse Glick <jglick@netbeans.org>
Log: #192779 cont'd: support for SGR params 2 & 29.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo