How can I set the brown color using ANSI escape sequence?

只谈情不闲聊 提交于 2019-12-12 04:17:21

问题


Can I use only the sequence Esc[Value,Valuem to set the brown color of background? (not only Black, Red, Green, Yellow, Blue, Magenta, Cyan, White... I want use more colors).

How to implement it easily? I want to implement it in my boot code, so I haven't the opportunity to use standard libraries.

Which parameters should I use?


回答1:


ANSI defined only 8 colors. None are brown (though some people call the non-bright "yellow" a "brown", e.g., Yellow appears as brown in konsole).

If you want to use different colors in your Linux boot code, you could use the Linux console color palette escape sequence to alter one of the entries in the console's palette. Referring to console_codes(4) manual page:

   ESC ]     OSC      (Should be: Operating system command) ESC ] P
                      nrrggbb: set palette, with parameter given in 7
                      hexadecimal digits after the final P :-(.  Here n
                      is the color (0-15), and rrggbb indicates the
                      red/green/blue values (0-255).  ESC ] R: reset
                      palette

Some people have written programs (or scripts) using this feature, e.g., setcolors - Change your Linux VT color palette (at boot time too!).

To alter colors in terminal emulators, e.g., after booting and logging into your desktop, these other terminals may have control sequences for setting entries in their color palettes.



来源:https://stackoverflow.com/questions/34201443/how-can-i-set-the-brown-color-using-ansi-escape-sequence

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!