Minicom 黑色背景颜色不受尊重

Minicom black background color is not respected

如果我在终端中使用带有选项“-c on”的颜色启动 minicom,黑色背景实际上是灰色的。

minicom -c on

如果我在设置中设置了任何颜色,比如红色,背景颜色会被尊重

minicom -c on -s
#Go to "Screen and keyboard", change "Background Color (term)"

但是黑色肯定是灰色的。知道这是为什么吗?

由于调色板的不同,在某些终端上 "gray" 黑色将是 "gray",而在其他终端上则不是。 Minicom 使用 curses 支持八种 ANSI 颜色。使用的实际 颜色没有标准。 "ANSI"(实际上是 ECMA-48)只给出颜色的 names,对于给定的 numbers.

gnome-terminal 和 konsole 的用户都注意到他们的"black"背景实际上是灰色。显然,他们的开发人员这样做是为了让终端在桌面上看起来 更好;没有考虑实际 使用 终端。 xterm 和 rxvt 使用 black(或 white,取决于资源设置)。对于前者,您通常可以编辑个人资料首选项并更改调色板颜色分配。

以下是我的 Debian 7 机器的示例屏幕截图,用于说明您可能看到的差异:

首先,xterm

然后是 gnome 终端

和控制台:

延伸阅读:

但这只是故事的一部分。 Minicom 最初是专门为 Linux 控制台编写的。这些终端可以显示 8 种前景颜色和 8 种背景颜色。但是他们用 bold 属性做了一些有趣的事情:

  • 粗体前景色更亮
  • 粗体背景也可能更亮。

源代码不是特别复杂,它绘制的颜色和属性(例如粗体)假定它们彼此独立。它不使用 ncurses。如果是,它(通过 ncurses)将注意 ncv 功能。引用自 terminfo(5):

   no_color_video                ncv        NC        video attributes
                                                      that cannot be used 
                                                      with colors

   On  some color terminals, colors collide with highlights.  You can reg‐
   ister these collisions with the ncv capability.  This is a bit-mask  of
   attributes  not to be used when colors are enabled.  The correspondence
   with the attributes understood by curses is as follows:

                Attribute                   Bit    Decimal
                A_STANDOUT                  0     1
                A_UNDERLINE                 1     2  
                A_REVERSE                   2     4
                A_BLINK                     3     8
                A_DIM                       4     16  
                A_BOLD                      5     32
                A_INVIS                     6     64
                A_PROTECT                   7     128  
                A_ALTCHARSET                8     256

   For example, on many IBM PC consoles, the underline attribute  collides  
   with  the  foreground  color  blue  and is not available in color mode.
   These should have an ncv capability of 2.

如果用infocmp看,"linux"终端描述使用ncv:

linux|linux console,
        am, bce, ccc, eo, mir, msgr, xenl, xon,
        colors#8, it#8, ncv#18, pairs#64,

这(再次)是故事的一部分(您可能会注意到这里的 ncv 中未编码粗体)。 ncurses also 命令更新屏幕以防止意外制作粗体背景 — 正确处理 Linux 控制台。