在Windows XP上使用Groovy的ANSI颜色支持

时间:2021-09-07 06:15:53

Trying out the examples found on pleac.sf.net, I'm not able to get an example of ANSI colors to work on my WinXP box (Works fine on MacOS). What I've found is that on my WinXP machine, in both cygwin & DOS prompts, groovysh --color (and 'groovysh --terminal=unix') shows escape codes rather than the expected colored prompt. grep --color works just fine in the cygwin terminal. I can't find anything obvious that I'm doing wrong. Any ideas?

尝试在pleac.sf.net上找到的示例,我无法获得ANSI颜色的示例以在我的WinXP框上工作(在MacOS上正常工作)。我发现在我的WinXP机器上,在cygwin和DOS提示符中,groovysh --color(和'groovysh --terminal = unix')显示转义码而不是预期的彩色提示。 grep --color在cygwin终端中运行得很好。我找不到任何明显我做错的事。有任何想法吗?

Note: I'm using Groovy 1.6.0

注意:我正在使用Groovy 1.6.0

Update: I've tried adding ANSI.sys to my config.nt mentioned here Groovy-dev Mailing List but it didn't fix the problem (tried rebooting too).

更新:我已经尝试将ANSI.sys添加到我的config.nt这里提到的Groovy-dev邮件列表,但它没有解决问题(尝试重新启动)。

4 个解决方案

#1


The thing is, you'd have to add DOSONLY to your CONFIG.NT as well to make the ANSI.SYS driver work, and then it would only work for COMMAND.COM which emulates DOS 5.0. Regular Command Prompts (CMD.EXE) do not support ANSI colors at all, afaict.

问题是,您必须将DOSONLY添加到您的CONFIG.NT以使ANSI.SYS驱动程序工作,然后它只适用于模拟DOS 5.0的COMMAND.COM。常规命令提示符(CMD.EXE)根本不支持ANSI颜色。

I don't know much about how cygwin handles it.

我不太了解cygwin如何处理它。

#2


I have the same problem, my solution is ugly but simple: Pipe groovy output to cygwin cat.exe Suppose your script red.groovy is:

我有同样的问题,我的解决方案很难但很简单:管道groovy输出到cygwin cat.exe假设你的脚本red.groovy是:

println "\u001B[31mI'm Red\u001B[0m Now not"

Then from command shell

然后从命令shell

groovy.bat red.groovy | cat

will display the right colors. Of course you can write your own native code that handle the ANSI codes.

将显示正确的颜色。当然,您可以编写自己的本机代码来处理ANSI代码。

#3


The Groovy site says to do this for cygwin:

Groovy网站说要为cygwin做这件事:

groovysh --terminal=unix    

For the winxp command shell, as far as I know, there is no ANSI support at all, not even with ansi.sys. Colors are supported through some MS API only.

对于winxp命令shell,据我所知,根本没有ANSI支持,甚至没有ansi.sys。仅通过某些MS API支持颜色。

#4


A workaround in cygwin is to launch xterm or rxvt and run it there.

cygwin中的一个解决方法是启动xterm或rxvt并在那里运行它。

#1


The thing is, you'd have to add DOSONLY to your CONFIG.NT as well to make the ANSI.SYS driver work, and then it would only work for COMMAND.COM which emulates DOS 5.0. Regular Command Prompts (CMD.EXE) do not support ANSI colors at all, afaict.

问题是,您必须将DOSONLY添加到您的CONFIG.NT以使ANSI.SYS驱动程序工作,然后它只适用于模拟DOS 5.0的COMMAND.COM。常规命令提示符(CMD.EXE)根本不支持ANSI颜色。

I don't know much about how cygwin handles it.

我不太了解cygwin如何处理它。

#2


I have the same problem, my solution is ugly but simple: Pipe groovy output to cygwin cat.exe Suppose your script red.groovy is:

我有同样的问题,我的解决方案很难但很简单:管道groovy输出到cygwin cat.exe假设你的脚本red.groovy是:

println "\u001B[31mI'm Red\u001B[0m Now not"

Then from command shell

然后从命令shell

groovy.bat red.groovy | cat

will display the right colors. Of course you can write your own native code that handle the ANSI codes.

将显示正确的颜色。当然,您可以编写自己的本机代码来处理ANSI代码。

#3


The Groovy site says to do this for cygwin:

Groovy网站说要为cygwin做这件事:

groovysh --terminal=unix    

For the winxp command shell, as far as I know, there is no ANSI support at all, not even with ansi.sys. Colors are supported through some MS API only.

对于winxp命令shell,据我所知,根本没有ANSI支持,甚至没有ansi.sys。仅通过某些MS API支持颜色。

#4


A workaround in cygwin is to launch xterm or rxvt and run it there.

cygwin中的一个解决方法是启动xterm或rxvt并在那里运行它。