一个遵循 ANSI 颜色代码的 Eclipse 控制台视图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6286701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 20:14:33  来源:igfitidea点击:

An Eclipse console view that respects ANSI color codes?

eclipseconsoleansi

提问by Duncan McGregor

The output from ScalaTest is colored to distinguish different states, but these end up as control codes and

ScalaTest 的输出被着色以区分不同的状态,但这些最终作为控制代码和

[34m Annoying garbage 

Is there any way to convince the Eclipse console to either respect or ignore these sequences, or to plug in a view that will?

有没有办法说服 Eclipse 控制台尊重或忽略这些序列,或者插入一个视图?

回答by thegreendroid

I am successfully using this plugin for Eclipse - ANSIConsole

我成功地将此插件用于 Eclipse - ANSIConsole

回答by Jim Hurne

The Target Management Terminalplugin for Eclipse understands ANSI escape characters, including color codes. I use it to run sbtwith ScalaTest.

Eclipse的目标管理终端插件理解 ANSI 转义字符,包括颜色代码。我用它来运行sbt使用ScalaTest

The original Target Management Terminalplugin was designed to access remote systems. However, if you are running on Linux, Mac, or Solaris but not Windows, you can use the Local Terminalplugin which adds the ability to attach directly to a local shell or program.

最初的目标管理终端插件旨在访问远程系统。但是,如果您在 Linux、Mac 或 Solaris 而不是 Windows 上运行,您可以使用本地终端插件,该插件添加了直接附加到本地 shell 或程序的能力。

Installing the Local Terminalplugin automatically installs the Target Management Terminal, so you just need to install the local terminal:

安装Local Terminal插件会自动安装Target Management Terminal,因此您只需要安装本地终端:

Installing the Local Terminalplugin

安装本地终端插件

  1. Select Help -> Install New Software...from the Eclipse menu
  2. Select the primary update site for you release of Eclipse (e.g., Ganymede, Helios, Indigo)
  3. Select General Tools -> Local Terminal
  4. Follow normal procedure to install the plugin (click next, accept license, restart eclipse, etc).
  1. 从 Eclipse 菜单中选择Help -> Install New Software...
  2. 为您的 Eclipse 版本选择主要更新站点(例如,Ganymede、Helios、Indigo)
  3. 选择通用工具 -> 本地终端
  4. 按照正常程序安装插件(单击下一步,接受许可,重新启动 eclipse 等)。

If you are running on a platform not supported by the Local Terminalplugin, you can still use Target Management Terminalwith SSH or Telnet:

如果您在本地终端插件不支持的平台上运行,您仍然可以通过 SSH 或 Telnet使用目标管理终端

Installing the Target Management Terminalplugin

安装目标管理终端插件

  1. Select Help -> Install New Software...from the Eclipse menu
  2. Select the primary update site for you release of Eclipse (e.g., Ganymede, Helios, Indigo)
  3. Select Mobile and Device Development -> Target Management Console
  4. Follow normal procedure to install the plugin (click next, accept license, restart eclipse, etc).
  1. 从 Eclipse 菜单中选择Help -> Install New Software...
  2. 为您的 Eclipse 版本选择主要更新站点(例如,Ganymede、Helios、Indigo)
  3. 选择移动和设备开发 -> 目标管理控制台
  4. 按照正常程序安装插件(单击下一步,接受许可,重新启动 eclipse 等)。

Using

使用

  1. Select Window -> Show View -> Otherfrom the Eclipse menu
  2. Select the Terminal -> Terminalview.
  3. Click the green Connect button in the view, and enter details to connect to your local system. If you installed the Local Terminal plugin, one of the options is "Local Program". By default, there is program defined for your local shell, but you can setup others. For example, I have an entry for sbt.
  1. 从 Eclipse 菜单中选择Window -> Show View -> Other
  2. 选择终端 -> 终端视图。
  3. 单击视图中的绿色连接按钮,然后输入详细信息以连接到本地系统。如果您安装了本地终端插件,选项之一是“本地程序”。默认情况下,为您的本地 shell 定义了程序,但您可以设置其他程序。例如,我有一个 sbt 条目。

If you are more used to white-on-black, you might want to:

如果您更习惯于黑底白字,您可能想要:

  1. Open Eclipse preferences
  2. Select Terminal
  3. Check Invert terminal colors
  1. 打开 Eclipse 首选项
  2. 选择终端
  3. 检查反转终端颜色

回答by ianinini

This works brilliantly for me:

这对我来说非常有效:

https://marketplace.eclipse.org/content/ansi-escape-console

https://marketplace.eclipse.org/content/ansi-escape-console

Simply install it and it automatically modifies the behaviour of Eclipse's default console. (You can easily disable it with a button provided.)

只需安装它,它就会自动修改 Eclipse 的默认控制台的行为。(您可以使用提供的按钮轻松禁用它。)

I have used this for running code that outputs escape codes to modify the text colour. It behaves exactly as expected.

我已经用它来运行输出转义码来修改文本颜色的代码。它的行为完全符合预期。

回答by James Scriven

How about redirecting your output to a file and then just "tail -f" it? Similar to this question: How can I make Eclipse output std:out to a standard windows console

如何将您的输出重定向到一个文件,然后只是“tail -f”呢?与此问题类似:How can I make Eclipse output std:out to a standard windows console

Update: there are also some options listed at Colorize logs in eclipse console. Even if that doesn't work, it might be a starting point on how to swap out the standard console plugin.

更新:在 Eclipse 控制台中的着色日志中还列出了一些选项。即使这不起作用,它也可能是如何换出标准控制台插件的起点。