如何从perl脚本设置调色板颜色



我有一个perl脚本,它为我的终端随机选择FG和BG颜色。我使用以下打印命令来设置飞行中的FG和BG:

print "33]10;<fg_color>07";
print "33]11;<bg_color>07";

我也需要设置调色板的颜色,但我很难找到一个如何做到这一点的例子。有人能帮我吗?

如果您的终端实现了问题中所示的xterm的OSC 10和OSC 11,那么它可能也实现了OSC 4:

Ps=4c规范⇒将颜色编号c更改为该颜色由规范指定。

例如

print "33]4;1;green07";
print "33]4;1;green33\";

使用绿色代替颜色1(红色(,其中xterm也将接受RGB设置:

/*
* Set or query entries in the Acolors[] array by parsing pairs of color/name
* values from the given buffer.
*
* The color can be any legal index into Acolors[], which consists of the
* 16/88/256 "ANSI" colors, followed by special color values for the various
* colorXX resources.  The indices for the special color values are not
* simple to work with, so an alternative is to use the calls which pass in
* 'first' set to the beginning of those indices.
*
* If the name is "?", report to the host the current value for the color.
*/

spec的合法值由XParseColor确定(在xterm中——对于其他终端,它依赖于实现,通常没有文档记录,这使该方面偏离了主题(。

我不认为你可以设置调色板。您可以从选项板中进行选择。有关示例,请参见此处。

调色板取决于您的终端。对于XTerm,调色板设置在~/.Xresources中。这是我目前的配置:

XTerm*color0:     rgb:00/00/00
XTerm*color1:     rgb:80/00/00
XTerm*color2:     rgb:00/80/00
XTerm*color3:     rgb:80/80/00
XTerm*color4:     rgb:00/00/80
XTerm*color5:     rgb:80/00/80
XTerm*color6:     rgb:00/80/80
XTerm*color7:     rgb:c0/c0/c0
XTerm*color8:     rgb:80/80/80
XTerm*color9:     rgb:aa/00/00
XTerm*color10:    rgb:00/aa/00
XTerm*color11:    rgb:aa/aa/00
XTerm*color12:    rgb:00/00/aa
XTerm*color13:    rgb:aa/00/aa
XTerm*color14:    rgb:00/aa/aa
XTerm*color15:    rgb:ff/ff/ff

最新更新