简体   繁体   English

xterm-color 和 xterm-256color 有什么区别?

[英]What is the difference between xterm-color & xterm-256color?

I've come across both xterm-color and xterm-256color as options when trying to set up my terminal program to use color - ie you can set your TERM environment variable to either one.在尝试设置我的终端程序以使用颜色时,我遇到了xterm-colorxterm-256color作为选项——也就是说,您可以将TERM环境变量设置为任何一个。

I was wondering if anyone can describe the difference between the two?我想知道是否有人可以描述两者之间的区别?

I've searched for documentation on my Ubuntu server as well as my mac but haven't found any.我已经在我的 Ubuntu 服务器以及我的 mac 上搜索了文档,但没有找到任何文档。 I've only been able to find various binary files in /usr/share/terminfo .我只能在/usr/share/terminfo中找到各种二进制文件。

xterm-256color describes Xterm with support for 256 colors enabled. xterm-256color描述了支持 256 colors 的 Xterm。 xterm-color describes an older branch of Xterm that supports eight colors. xterm-color is not recommended, since it describes a variant of Xterm that's less functional and that you're not likely to be using. xterm-color描述了支持八个 colors 的 Xterm 的旧分支。不推荐使用xterm-color ,因为它描述了功能较差且您不太可能使用的 Xterm 变体。 Usually you'll want to use xterm , xterm-16color or xterm-256color .通常您需要使用xtermxterm-16colorxterm-256color

In particular, xterm-256color is the default for Terminal starting with Mac OS X 10.7 Lion, with the next-best recommended values being xterm-16color or xterm (which only describes support for eight ANSI colors).特别是, xterm-256color是从 Mac OS X 10.7 Lion 开始的终端的默认值,下一个最佳推荐值是xterm-16colorxterm (仅描述了对八种 ANSI 颜色的支持)。 Prior to 10.7, xterm-color was the default because Terminal didn't support some critical features described by the recommended Xterm terminfo values, eg, Background Color Erase (BCE), modern codes for switching main/alternate screens, 256 colors.在 10.7 之前, xterm-color是默认设置,因为终端不支持推荐的 Xterm terminfo 值描述的一些关键功能,例如背景颜色擦除 (BCE)、用于切换主/备用屏幕的现代代码、256 colors。

Sometimes people explicitly set TERM to xterm-color (as opposed to the recommended Xterm values) to disable functionality or work around incompatibilities between the available terminfo values on a particular computer and the terminal emulator being used.有时人们明确地将TERM设置为xterm-color (与推荐的 Xterm 值相反)以禁用功能或解决特定计算机上可用的 terminfo 值与正在使用的终端仿真器之间的不兼容问题。

Note that technically Terminal should have its own up-to-date terminfo values that describe exactly which features it supports, instead of using the values for Xterm, but:请注意,从技术上讲,Terminal 应该有自己最新的 terminfo 值来准确描述它支持的功能,而不是使用 Xterm 的值,但是:

  1. There isn't one that's up to date currently.目前没有一个是最新的。 nsterm represents Terminal's ancestor from NeXTSTEP. nsterm代表 Terminal 来自 NeXTSTEP 的祖先。 Someone apparently has updated nsterm recently (sometime in the past couple of years), but I don't know whether that has made its way into the ncurses distribution, and it may not be completely up to date with Terminal in 10.7.显然有人最近更新nsterm (过去几年的某个时候),但我不知道它是否已经进入 ncurses 发行版,并且它可能不完全与 10.7 中的终端同步。
  2. A number of programs and shell customization scripts explicitly check whether $TERM starts with (or is equal to) xterm .许多程序和 shell 自定义脚本明确检查$TERM是否以(或等于) xterm开头。 So some users would still need to know about using the recommended Xterm values with Terminal for compatibility with those.因此,一些用户仍然需要了解如何将推荐的 Xterm 值与终端一起使用以与这些值兼容。

If you're not familiar with the terminfo system, take a look at the x-man-page://5/terminfo man page.如果您不熟悉 terminfo 系统,请查看 x-man-page://5/terminfo 手册页。 Also, you can use the infocmp command to view the current terminfo settings or compare two different ones, eg, infocmp xterm-color xterm-256color will show you all the differences between those two.此外,您可以使用infocmp命令查看当前的 terminfo 设置或比较两个不同的设置,例如, infocmp xterm-color xterm-256color将向您显示这两者之间的所有差异。

It appears that xterm-256color is Terminal.app on OS/X.看起来xterm-256color是 OS/X 上的 Terminal.app。 The differences are not tiny - I infocmp'd xterm-color and xterm-256color on an Ubuntu box and normalized them a bit, and got quite a few differences.差异并不小——我在 Ubuntu 盒子上使用 infocmp'd xterm-colorxterm-256color并对它们进行了一些标准化,得到了很多差异。 I might even say xterm-256color isn't really xterm anymore.我什至可以说xterm-256color不再是真正的 xterm。

Normally when you use a specific terminal emulator, you need to "just know" which terminfo entry works best with it.通常,当您使用特定的终端仿真器时,您需要“只知道”哪个 terminfo 条目最适合它。 They're a matching pair, though sometimes you can, EG, use a vt100 terminfo entry on a vt220 terminal.它们是一对匹配的,尽管有时您可以,例如,在 vt220 终端上使用 vt100 terminfo 条目。

On the plus side, almost everything is vt100-compatible today.从好的方面来说,今天几乎所有东西都与 vt100 兼容。

According to the ncurses FAQ , xterm-color is long obsolete:根据ncurses FAQxterm-color早已过时:

Originally, xterm-color corresponded to the color_xterm from the mid-1990s.最初,xterm-color 对应于 1990 年代中期的 color_xterm。 That was superseded by XFree86 xterm in 1996.它在 1996 年被 XFree86 xterm 取代。

and the terminal database gives details.终端数据库提供了详细信息。 It was originally intended as a generic terminal description, but from the outset that never was successful because it did not match XFree86 xterm , in particular the color behavior (ie, the back color erase feature).它最初打算用作通用终端描述,但从一开始就没有成功,因为它不匹配XFree86 xterm ,尤其是颜色行为(即背景颜色擦除功能)。 No one uses nxterm now.现在没有人使用nxterm

The xterm-256color terminal description is built up from the (XFree86) xterm terminal description by modifying the color behavior (adding more colors, but not the background color erase feature. Use infocmp to see the difference: xterm-256color终端描述是通过修改颜色行为(添加更多 colors,但添加背景颜色擦除功能)从 (XFree86) xterm 终端描述构建的。使用infocmp查看差异:

$ infocmp xterm-color xterm-256color |wc -l
122
$ infocmp xterm xterm-256color |wc -l
14
$ infocmp xterm xterm-256color
comparing xterm to xterm-256color.
    comparing booleans.
        ccc: F:T.
    comparing numbers.
        colors: 8, 256.
        pairs: 64, 32767.
    comparing strings.
        initc: NULL, '\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\'.
        oc: NULL, '\E]104\007'.
        rs1: '\Ec', '\Ec\E]104\007'.
        setab: '\E[4%p1%dm', '\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m'.
        setaf: '\E[3%p1%dm', '\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m'.
        setb: '\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m', NULL.
        setf: '\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m', NULL.

Because xterm-color was obsolete, it was largely ignored until some (anonymous, of course) developer at Apple decided to reuse it for Terminal.app (in 10.5 Leopard ), although it was a poor fit.因为 xterm-color 已经过时,它在很大程度上被忽略了,直到 Apple 的一些(当然是匿名的)开发人员决定将它重新用于 Terminal.app(在 10.5 Leopard中),尽管它不太合适。 The nsterm-16color description in ncurses was contributed by someone (apparently outside Apple), to match the 10.5 behavior. ncurses 中的nsterm-16color描述是由某人(显然在 Apple 之外)贡献的,以匹配 10.5 的行为。 Although xterm-color uses 8 colors, nsterm-16color as one might guess uses 16 .虽然 xterm-color 使用8 colors,但人们可能会猜测 nsterm-16color 使用16 Perhaps that contributed to users' confusion.也许这导致了用户的困惑。 In any case, the choice of terminal description for Terminal.app had no effect on Terminal.app other than to set the TERM environment variable, which many applications use to decide how to use the terminal.在任何情况下,Terminal.app 的终端描述选择对 Terminal.app 没有影响,除了设置TERM环境变量,许多应用程序使用它来决定如何使用终端。

Interesting enough, although much of the MacOS userland is from the BSDs, its ncurses configuration is not.有趣的是,尽管大部分 MacOS 用户区都来自 BSD,但它的 ncurses 配置却不是。 MacOS has tic/infocmp utilities, unlike the BSDs (though Apple has not updated it for more than ten years: ncurses 5.7 was released in 2008 ). MacOS 有 tic/infocmp 实用程序,与 BSD 不同(尽管 Apple 已经十多年没有更新它了:ncurses 5.7 于2008年发布)。 In later releases of MacOS, Terminal.app's developers changed the menu to provide "xterm-256color" rather than "xterm-color".在更高版本的 MacOS 中,Terminal.app 的开发人员更改了菜单以提供“xterm-256color”而不是“xterm-color”。 That did not improve the user experience because the terminal behavior using the corresponding terminal descriptions was still different.这并没有改善用户体验,因为使用相应终端描述的终端行为仍然不同。 The ncurses FAQ mentions that: ncurses 常见问题解答提到:

Additionally, Mac OS X 10.7 is reported to use xterm-256color as a default $TERM value.此外,据报道 Mac OS X 10.7 使用 xterm-256color 作为默认 $TERM 值。 This differs from xterm-color in several ways, in particular, the support for bce.这在几个方面不同于 xterm-color,特别是对 bce 的支持。 It also differs from the recommended nsterm-256color (infocmp reports 111 differences).它还不同于推荐的 nsterm-256color(infocmp 报告 111 个差异)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM