支持 Windows 的 ANSI 代码渲染的文本编辑器/查看器

发布于 2024-08-22 02:27:17 字数 1539 浏览 6 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

趁年轻赶紧闹 2024-08-29 02:27:17

开源编辑器 Atom 具有包 语言-ansi-styles。它支持除 ;r;g;b 之外的所有格式。

输入图像描述这里
输入图像描述这里

The open-source editor Atom has the package language-ansi-styles. It supports all kinds of formatting except ;r;g;b.

enter image description here
enter image description here

叹梦 2024-08-29 02:27:17

您可能会更幸运地使用 ASCII/ANSI 实用程序,例如此处列出的实用程序:
ASCII/ANSI/NFO 实用程序列表< /a>

**注意:此页面上的某些文件可能已过时,您可能会在各自的主页上找到这些实用程序的较新版本。*

例如,可以在此处找到最新版本的 NFOPad

You might have some more luck with ASCII/ANSI utilities, like the ones listed here:
List of ASCII/ANSI/NFO utilities

**Note: some files on this page might be outdated, you might find newer versions of these utilities on their respective homepages.*

For example, the latest version of NFOPad can be found here.

烦人精 2024-08-29 02:27:17

我一直在寻找一种显示 ANSI 颜色的解决方案(用于程序调试输出的可读性),并偶然发现了 Sublime Text(带有试用版的付费软件 http://www.sublimetext.com/) 和 ANSIescape 包 (https: //github.com/aziz/SublimeANSI 或通过包控件安装)。

它支持着色,并且粗体转义被识别但不显示,尽管可以在设置文件中为其分配特殊颜色。另外值得注意的是,该插件以只读模式显示文本,如果需要编辑,则需要关闭。

这是github上提供的屏幕截图,我亲自尝试过并验证它是否有效:

在此处输入图像描述

I've been looking for a solution to display the ANSI colors as well (for program debug output readability) and stumbled upon Sublime Text (paid software with trial http://www.sublimetext.com/) with a the ANSIescape package (https://github.com/aziz/SublimeANSI or installed through the package control).

It supports coloring and the bold escape is recognized but not displayed, although a special color can be assigned to it in the settings file. Also worth noting that this plugin shows text in read-only mode, and needs to be turned off if editing is necessary.

Here is the screenshot provided on the github, and I have personally tried it and verified it works:

enter image description here

情徒 2024-08-29 02:27:17

如果您主要感兴趣的是查看文件而不是编辑它,Ansifilter 会将其转换为 HTML,然后您可以查看并至少在浏览器中进行搜索,或者如果写字板足够好的话,则转换为 RTF(很难想象)。呵呵,下载页面好像也有notepad++插件版本,如果能加载到notepad++就完美了。
http://www.andre-simon.de/doku/ansifilter/ansifilter.html

还有一个不同的 vim 插件,它根据 ANSI 代码为文本着色。
http://www.vim.org/scripts/script.php?script_id=302

然而,虽然它以正确的颜色突出显示文本,但它却将 ANSI 代码本身保留在那里(以褪色的、接近背景的颜色),这可能会弄乱文件中的任何对齐格式,并使得在文件中移动更加困难(大量“空白空间”需要光标穿过,如果中间有 ansi 代码,则搜索单词将不匹配,等等)。它也可以利用一个补丁来隐藏代码,但这需要打补丁,然后从源代码重新编译 vim 本身。

是的,如果你还不是 vim 用户,建议 vim 是没有什么帮助的,我知道它的学习曲线太大了。但它可能对 vim 用户有用。

If you're primarily interested in viewing the file instead of editing it, Ansifilter will convert it to HTML, which you can then view and at least search in your browser, or RTF if wordpad would be good enough (hard to imagine). Huh, looks like there's a notepad++ plugin version on the download page, too, so that might be perfect if it allows you to load into notepad++.
http://www.andre-simon.de/doku/ansifilter/ansifilter.html

There's also a different plugin for vim which colors text according to ANSI codes.
http://www.vim.org/scripts/script.php?script_id=302

However, while it highlights the text in the correct color, it leaves the ANSI codes themselves in there (in a faded, near-background color) which probably will mess up any alignment formatting in the file, as well as making it harder to move around the file (lots of "empty space" to wade the cursor through, searching for a word won't match if there's an ansi code in the middle of it, etc.). There's a patch it can take advantage of to hide the codes too, but that would require patching and then recompiling vim itself from source.

Yeah, suggesting vim is pretty unhelpful if you aren't a vim user already, it has too huge of a learning curve, I know. But it might be useful to the vim users out there.

客…行舟 2024-08-29 02:27:17

我知道这不会有太大帮助 - 但我一直在 Linux 上寻找完全相同的东西;只是想查看一些内部包含 bash ANSI 颜色代码的日志输出。不幸的是,这些 ANSI 颜色代码分布在几行中 - 意味着对文件进行“cat”并通过管道传输到“less -R”、“most”和类似工具,只会显示颜色起源的起始行,而不是显示颜色的起始行。应该着色的后续行。

有趣的是,我认为常用的 Linux 工具,如“nano”、“gedit”、“vim”等都具有在文本文件中处理 ANSI 颜色代码的功能,但在这些文本文件中提供有关 ANSI 颜色的信息的能力非常有限。编辑们。我只找到了测试编辑器“joe”的 ANSI 颜色信息:

便宜的 ANSI 颜色! - http://tldp.org/LDP/LG/issue01to08/articles.html #ansi

但无法让那里的建议起作用(也无法让“emacs”起作用,至少不能直接读取内部包含 ANSI 颜色字符的文本文件)。

好消息 - 如果您需要文本中的 ANSI 颜色,似乎您需要的是按照上面推荐的方式查找 ASCII art / NFO 实用程序 - 我最终找到并为我工作的实用程序是 tetradraw (通过 www.linux.org/apps/AppId_42.html ;可以在 Ubuntu 中安装 sudo apt-get ...实际上,tetradraw 是绘图/编辑器部分的名称 - 然而有一个单独的查看器也适用于 ANSI 颜色代码,tetraview)。

好吧,谁会想到,您需要找到一个 ASCII 艺术实用程序,才能读取日志文件:)

无论如何,希望这也能以某种方式帮助进一步搜索 Windows 的 ANSI 彩色文本编辑器。干杯!

I know it won't be of much help - but I was looking for the exact same thing on linux; was just trying to view some log outputs that had bash ANSI color codes inside. Unfortunately, those ANSI color codes were spread across several lines - meaning 'cat'-ing the file and piping into 'less -R', 'most' and similar tools, would simply display the starting line where the color originated, but not the subsequent lines that should've been colored.

Funnily enough, I thought usual Linux tools like 'nano', 'gedit', 'vim' and whatnot would have capabilities for ANSI color codes in a text file, but it's very modest out there with info on ANSI color in text files in these editors. I've only found info on ANSI color for the test editor 'joe':

Cheap ANSI Color! - http://tldp.org/LDP/LG/issue01to08/articles.html#ansi

but couldn't get the recommendations there to work (also couldn't get 'emacs' to work either, at least not by directly reading a text file with ANSI color characters inside).

The good thing - it seems what you need, if you need ANSI color in text, is to look for ASCII art / NFO utilities as recommended above - and the one that I finally found, and was working for me, was tetradraw (via www.linux.org/apps/AppId_42.html ; can be sudo apt-get installed in Ubuntu ... actually, tetradraw is the name of the drawing/editor part - however there is a separate viewer that also works with ANSI color codes, tetraview).

Well, who would have thought, that you need to track down an ASCII art utility, in order to read log files :)

Anyways, hope this may somehow help in the further search of ANSI color text editors for Windows, too.. Cheers!

可遇━不可求 2024-08-29 02:27:17

如果您只想查看,那么终端程序“Tera Term”可以做到这一点。只需点击“文件”-> “重播日志”并选择包含 ANSI 代码的文件。

您可以通过以下方式下载 Tera Term

If you just want to view then the terminal program "Tera Term" can do this. Just click "File" -> "Replay Log" and select your file containing the ANSI codes.

You can download Tera Term via:

婴鹅 2024-08-29 02:27:17

在 Emacs 中,只需在打开 .nfo 文件之前评估以下内容:

(add-to-list 'auto-coding-alist '("\\.nfo\\'" .cp437-dos))

In Emacs, just eval the following before opening your .nfo file:

(add-to-list 'auto-coding-alist '("\\.nfo\\'" . cp437-dos))

ゞ花落谁相伴 2024-08-29 02:27:17

我已经在 Andras Vass 引用的 URL 上测试了多个程序,但没有结果(它们不显示颜色,或者不断将 ANSI 代码显示为一堆字符)。

厌倦了搜索,我终于找到了 ANSIFilter (不是 NotePad++ 插件引用的Jeffson),唯一对我有用的。
我已将其添加到 Windows 上下文菜单中,因此我现在可以轻松打开 ANSI 文本文件。

I have been a while testing multiple programs on the URL refered by Andras Vass with no results (they don't show colors, or they keep showing ANSI codes as a mess of characters).

Tired of searching I have finally found ANSIFilter (not the NotePad++ plugin refered by Jeffson), the only that works for me.
I have added it to Windows context menu, so I can now easily open my ANSI text files.

吾家有女初长成 2024-08-29 02:27:17

如果 emacs 不能做到这一点,我会感到惊讶。
至少有嵌入式外壳。
有:

更新:如有人指出,它们只是术语输出着色器。但是,如果您也可以在 emacs 中编辑 shell 缓冲区内容,例如。 cat 文件 &&着色。

但是等一下,我刚刚找到了这些:

I would be surprised if emacs can't do that.
At least with the embeded shell.
There are:

Update: as it had been pointed, they are just term output colorizers. But if you can edit the shell buffer contents in emacs too, eg. cat file && colorize.

But wait a minute, I had just found these:

情深缘浅 2024-08-29 02:27:17

如果您的应用程序的调试日志记录通过 1 个类/函数,您可以尝试拆分输出,以便:

  • 类似 ANSI 的日志记录显示在终端/控制台上
  • 类似 HTML 的日志记录写入文件

对于您的应用程序,所有日志记录都会转到这个类,这个类将输出分割到终端/控制台和文件。

在日志类中制定一个“标准”来指定颜色和粗体(例如,预定义代码,如 Ctrl-A 表示红色,Ctrl-B 表示粗体,...,或日志类中用于设置颜色和粗体的特定方法,或者甚至可能是 ANSI 代码),并将其在您的中央日志记录类中翻译为:

  • 终端上正确的 ANSI 代码
  • 文件中正确的 HTML 代码

另外,我认为您也可以使用富文本而不是 HTML,但我不这样做我不知道富文本的所有可能性,因此您可能需要查找一下。

If the debug logging of your application goes via 1 class/function, you could try to split the output so that:

  • ANSI-like logging is shown on the terminal/console
  • HTML-like logging is written to file

For your application all logging goes to this class, and this class splits the output to terminal/console and file.

Make a 'standard' in your logging class for specifying colors and boldness (e.g. predefined codes like Ctrl-A means red, Ctrl-B means bold, ..., or specific methods in the logging class for setting the color and boldness, or maybe even the ANSI-codes), and translate this in your central logging class to:

  • the correct ANSI codes on terminal
  • the correct HTML codes in file

Alternatively, I think that instead of HTML you also could use rich-text, but I don't know all the possibilities of rich text so you may have to look this up.

好久不见√ 2024-08-29 02:27:17

您可以尝试记事本++(请参阅http://notepad-plus.sourceforge.net/uk/ site.htm)。它非常强大(基于 Scintilla),并且可以选择查看不可打印的字符(如换行符等)。

You could try notepad++ (see http://notepad-plus.sourceforge.net/uk/site.htm). It's pretty powerful (Scintilla based) and has an option to view non-printable characters (like line-breaks and the like).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文