在XML中支持ANSI终端颜色转义序列? [英] Support ANSI terminal color escape sequences in XML?

查看:630
本文介绍了在XML中支持ANSI终端颜色转义序列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在测试脚本中使用termcolor和colored打印一些有色词语。

I am using "termcolor" and "colored" for printing some colored words in my test script.

>>> from termcolor import colored
>>> result = colored("pass", "red")
>>> print result
pass ----> ("appears in red")
>>> result = '\033[1m' + result  + '\033[0m'
>>> print result
pass ------> ("appears in red and bold")

上述在Mac和CentOS上正常工作,但无法打印它在红色或大胆在eclipse(在CentOS)。它打印这样的东西?[32mPASS?[0m - 这不帮助太多..

The above works fine on Mac and CentOS but fails to print it in red or bold in eclipse (on CentOS). It prints something like this "?[32mPASS?[0m" -- which does not help much..

我想补充一点,上面的文本是在在eclipse中打开的XML文件。编码格式可能在这里发挥作用。现在我在XML中看到UTF-8作为编码格式。

I want to add that, the above text is seen on an XML file opened in eclipse. The encoding format probably has a role to play here. Right now I see "UTF-8" in the XML as encoding format.

推荐答案

问题是,默认Eclipse控制台不知道如何处理提供颜色信息的 ANSI转义序列

The issue is that unlike most terminals, the default Eclipse console does not know how to deal with the ANSI escape sequences that provide the color information.

然而,在Eclipse市场中提供了一个名为控制台中的ANSI Escape 的插件,扩展了标准Eclipse控制台以便能够处理这些ANSI颜色转义序列:

There is however a plugin called ANSI Escape in Console available from the Eclipse marketplace that augments the standard Eclipse console to be able to deal with these ANSI color escape sequences:

http://marketplace.eclipse.org/content/ansi-escape-console#.U978fXV515Q

插件作者的博客提供了一些更多信息:

The plugin author's blog provides some more information:

http://mihai-nita.net/2013/06/03/eclipse-plugin-ansi-in-console/

这篇关于在XML中支持ANSI终端颜色转义序列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆