简体   繁体   English

如何获得 FreeBSD 无头控制台/终端的 256 色支持?

[英]How to get 256 color support for FreeBSD headless console/terminal?

How can I get 256 color support on FreeBSD 13 headless machine using console/terminal?如何使用控制台/终端在 FreeBSD 13 无头机器上获得 256 色支持?

I have an overkill GPU "AMD Radeon PRO WX 2100" installed to the machine.我在机器上安装了一个矫枉过正的 GPU“AMD Radeon PRO WX 2100”。

Basically want to avoid a desktop environment since I only need to use the machine purely based only for "text" wise.基本上想避免使用桌面环境,因为我只需要使用纯粹基于“文本”的机器。

The machine will be used to display real time stock pricing and I would like to use color highlighting to make the text based real time charting terminal/console application more user friendly and readable.该机器将用于显示实时股票定价,我想使用颜色突出显示使基于文本的实时图表终端/控制台应用程序更加用户友好和可读。

I can not find any comprehensible or easy guide to do so and have no idea where to begin.我找不到任何可理解或简单的指南来这样做,也不知道从哪里开始。

I am using ncurses to make the app.我正在使用 ncurses 来制作应用程序。

When I type tput color to the console, I get a return of a value 80 .当我在控制台输入tput color时,我得到一个返回值80

OP misuses the term "headless" for non-desktop, but the intent is clear from the reference to ncurses. OP 误用了“无头”一词来表示非桌面,但从对 ncurses 的引用中可以清楚地看出其意图。 This refers to text-mode in a FreeBSD console.这指的是 FreeBSD 控制台中的文本模式。

Short: you can't do that.简而言之:你不能那样做。

Longer: without X (desktop), unless you're going to develop a terminal emulator in which to run ncurses using 256-colors on FreeBSD, you're out of luck.更长:没有 X(桌面),除非你要开发一个终端模拟器,在 FreeBSD 上使用 256 色运行 ncurses,否则你就不走运了。 See for instance concol (perhaps a starting point, but nothing that you could actually use with ncurses).参见例如concol (也许是一个起点,但没有什么可以与 ncurses 一起使用)。

Many users are misled by a FreeBSD developer's choice to set the TERM variable of the newer console terminal emulator to "xterm", supposing that it can display 256 colors.许多用户被 FreeBSD 开发人员选择将较新的控制台终端仿真器的TERM变量设置为“xterm”的选择误导了,假设它可以显示 256 色。 This is mentioned near the end of the XTerm FAQ "Can I set a color by its number" , which goes into some detail explaining how the 256-color feature came about.这在 XTerm 常见问题解答“我可以通过它的数字设置颜色吗”的末尾提到,其中详细解释了 256 色功能是如何产生的。 There's a screenshot for teken (the proper name for the FreeBSD console emulator) which shows its inability to render 256-colors. teken(FreeBSD 控制台模拟器的专有名称)的 屏幕截图显示它无法呈现 256 色。 Aside from changing the palette to shift it toward the red colors, it's unchanged since 2014.除了更改调色板以将其移向红色之外,它自 2014 年以来没有变化。

xterm 与 FreeBSD 256 色

FreeBSD documentation refers to teken as "vt". FreeBSD 文档将teken称为“vt”。 Like the older "sc" (syscons), that only works for VGA colors (8 ANSI colors combined with bright/bold attribute to simulate 16 colors).与旧的“sc”(syscons)一样,它仅适用于 VGA 颜色(8 种 ANSI 颜色与明亮/粗体属性相结合以模拟 16 种颜色)。

The FreeBSD console terminal emulator is documented in the ncurses terminal database section on the FreeBSD console emulators. FreeBSD 控制台终端仿真器记录在 FreeBSD 控制台仿真器的 ncurses 终端数据库部分。 In particular, there is a lengthy comment on this one before the teken-2018 entry.特别是,在teken-2018条目之前,对此有很长的评论。


Regarding this:关于这一点:

When I type tput color to the console, I get a return of a value 80.当我在控制台输入 tput color 时,我得到一个值 80 的返回值。

That is a misfeature of the FreeBSD configuration.这是 FreeBSD 配置的错误特征。 Its system utility tput imitates the older termcap-based utility which (see themanual page ) Keith Bostic wrote in 1989 imitating the AT&T tput utility.它的系统实用程序tput模仿了旧的基于 termcap 的实用程序(参见手册页),Keith Bostic 在 1989 年编写的模仿 AT&T tput实用程序。 That's actually a few years too late to be regarded as "original termcap", but most users don't know the difference.这实际上已经晚了几年才能被视为“原始termcap”,但大多数用户不知道其中的区别。 Anyway, as a termcap utility (on the surface), only the first two characters of that color are used, giving co (termcap equivalent for columns ).无论如何,作为一个termcap实用程序(表面上),只使用该color的前两个字符,给出co (termcap 等效于columns )。 The termcap name for colors is Co (see manual page ): colors的术语名称是Co (参见手册页):

      max_colors                  colors    Co     maximum number of
                                                   colors on screen

A termcap application would not understand the terminal descriptions used for colors in ncurses. termcap 应用程序无法理解 ncurses 中用于颜色的终端描述。 This happens to sort-of work (for 16 colors) in the FreeBSD console because underneath the facade it is the terminfo-based ncurses library.这发生在 FreeBSD 控制台中的某种工作(16 色)中,因为在外观下面是基于 terminfo 的 ncurses 库。


Some users are confused by the distinction between text and graphical VGA modes.一些用户对文本和图形 VGA 模式之间的区别感到困惑。 A non-desktop environment uses text mode, which provides for 3 bits (8 text colors) combined with one bit which is often treated as bold , making 16 colors.非桌面环境使用文本模式,它提供 3 位(8 种文本颜色)和 1 位(通常被视为粗体),形成 16 种颜色。

In a graphical mode, one can use a splash screen , with 256 colors.图形模式下,可以使用 256 色的闪屏 That is unrelated to text modes.这与文本模式无关。

The vidcontrol program shows the available colors for the current video mode. vidcontrol程序显示当前视频模式的可用颜色。 It can list available modes as shown here.它可以列出可用的模式,如此处所示。 Only a few are usable for text (and all of those are as noted VGA):只有少数可用于文本(所有这些都是如前所述的 VGA):

vidcontrol 显示视频模式摘要

It can also show the colors with the caveat that different releases of FreeBSD have widely differing video capabilities.它还可以显示不同版本的 FreeBSD 具有大不相同的视频功能的警告。 Here are screenshots from FreeBSD 11这是来自 FreeBSD 11 的屏幕截图

FreeBSD 11 vidcontrol 显示

FreeBSD 12自由BSD 12

FreeBSD 12 vidcontrol 显示

and FreeBSD 13 (where vidcontrol presents no choices):和 FreeBSD 13(其中 vidcontrol 没有选择):

FreeBSD 13 vidcontrol 显示

Perhaps the lack of mode information from the FreeBSD 13 indicates that someone intends making it work with one of the graphic modes, as hinted in the manual page.也许 FreeBSD 13 缺少模式信息表明有人打算让它使用其中一种图形模式,如手册页中所暗示的那样。 But the color palette is not improved, yet.但是调色板还没有改进。 The manual page says for example手册页例如说

Note: The vt VGA hardware driver does not support palette configuration.注意:vt VGA 硬件驱动程序不支持调色板配置。

Further reading:进一步阅读:

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

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