【问题标题】:Support ANSI terminal color escape sequences in XML?支持 XML 中的 ANSI 终端颜色转义序列?
【发布时间】:2014-09-26 11:49:20
【问题描述】:

我正在使用“termcolor”和“colored”在我的测试脚本中打印一些彩色单词。

>>> 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””的东西——这没有多大帮助..

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

【问题讨论】:

    标签: eclipse text colors centos format


    【解决方案1】:

    问题在于,与大多数终端不同,默认的 Eclipse 控制台不知道如何处理提供颜色信息的ANSI escape sequences

    然而,Eclipse 市场提供了一个名为 ANSI Escape in Console 的插件,它增强了标准 Eclipse 控制台,使其能够处理这些 ANSI 颜色转义序列:

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

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

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

    【讨论】:

    • 不——罗比试过了,没用。我仍然有以下没有颜色或没有粗体的 -
    • 等一下,您添加到问题中的 XML 文件是什么?您是想在 Eclipse 控制台还是在 Eclipse XML 编辑器中查看这些颜色?
    • Eclipse 生成一个 XML 文件——所以我认为添加该信息会很好。
    • 因此您需要一个支持 ANSI 终端颜色转义序列的 Eclipse XML 编辑器。恐怕没有插件。
    • 哦.. 好的 那么——我还能做些什么来解决这个问题吗?
    猜你喜欢
    • 1970-01-01
    • 2011-06-18
    • 2018-09-30
    • 1970-01-01
    • 2021-01-14
    • 1970-01-01
    • 2020-09-29
    • 2010-09-19
    • 1970-01-01
    相关资源
    最近更新 更多