您可以在vt100转义码中使用十六进制颜色值吗? [英] Can you use hex color values with vt100 escape codes c++

查看:93
本文介绍了您可以在vt100转义码中使用十六进制颜色值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚学习了如何使用vt100转义码来更改终端中的背景和文本颜色( \ 033 [30m \ 033 [40m )).我想知道是否有一种方法可以使用十六进制颜色代码,而不是仅限于使用30-37或40-47所获得的8种颜色.例如: \ 033 [#48FF1Fm .如果这是不可能的,我不会感到惊讶,但我认为值得一问.

I just learned how to use vt100 escape code do change background and text colors in the terminal (\033[30mand\033[40m). I was wondering if there was a way to use hex color codes instead of being limited to the 8 colors that you get for using 30 - 37 or 40 - 47. Something like:\033[#48FF1Fm. I wouldn't be surprised if this was impossible but I thought it was worth asking.

推荐答案

VT-100是一个旧的终端,令我惊讶的是它具有颜色的转义码!

VT-100 is an old terminal and I was surprised that it had escape codes for colors!

另请参阅此堆栈溢出具有ANSI颜色转义序列的列表,其中包含一些好的答案.

See also this stack overflow List of ANSI color escape sequences which has some good answers.

ANSI/VT100终端控制转义序列的以下部分提供了一个例子.

The following section from ANSI/VT100 Terminal Control Escape Sequences provides an example.

Set Attribute Mode  <ESC>[{attr1};...;{attrn}m
Sets multiple display attribute settings. The following lists standard attributes:
0   Reset all attributes
1   Bright
2   Dim
4   Underscore  
5   Blink
7   Reverse
8   Hidden

    Foreground Colours
30  Black
31  Red
32  Green
33  Yellow
34  Blue
35  Magenta
36  Cyan
37  White

    Background Colours
40  Black
41  Red
42  Green
43  Yellow
44  Blue
45  Magenta
46  Cyan
47  White

但是,看起来不仅是您发现的标准颜色,而且还取决于设备支持,看起来还有什么调色板机制.

However it looks like not only the standard colors you have found, depending on the device support there are also what looks to be a color palette mechanism.

不过,请参见本文提示技巧:颜色和格式(ANSI/VT100控制序列适用于包含更多链接的更密集的列表.

However see this article Bash tips: Colors and formatting (ANSI/VT100 Control Sequences for a much more intensive list with additional links.

对于256种前景色,转义序列为"[38; 5; ColorNumberm",其中颜色编号ColorNumber来自提供的表.看起来'm'是色号后的必需字符.

For 256 foreground colors the escape sequence is "[38;5;ColorNumberm" where the color number,ColorNumber, is from the provided table. Looks like the 'm' is a required character after the color number.

对于256种背景色,转义顺序为"[48; 5; ColorNumberm".

For 256 background colors the escape sequence is "[48;5;ColorNumberm".

这篇关于您可以在vt100转义码中使用十六进制颜色值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆