Colorist is lightweight and makes it easy to print colorful text in many terminals.A HTML color code is an identifier used to represent a color on the web and within other digital assets. PS: In full disclosure, I'm the author of the Colorist package. I recommend these articles to explore further: There's a column for xterm in this table on the Wikipedia page for ANSI escape codes International Organization for Standardization. Information technology- Open Document Architecture (ODA) and Interchange Format: Character content architectures.Information technology - Open Document Architecture (ODA) and interchange format: Character content architectures.Information technology - Open Document Architecture (ODA) and interchange format: Document structures.SGR 38 and 48 were originally reserved by ECMA-48, but were fleshed out a few years later in a joint ITU, IEC, and ISO standard, which comes in several parts and which (amongst a whole lot of other things) documents the SGR 38/48 control sequences for direct colour and indexed colour: Print("\\033[u - Restore cursor position\n")ĮCMA-48 - Control Functions for Coded Character Sets, 5th edition (June 1991) -Ī standard defining the color control codes, that is apparently supported also by xterm. Print("\\033[D - Move the cursor backward N columns\n") Print("\\033[C - Move the cursor forward N columns") Print("\\033[B - Move the cursor down N lines") Print("\\033[A - Move the cursor up N lines") Print("\\033[ H or \\033[ f - Put the cursor at line L and column C.") Since I'm often in the position of trying to remember what colours are what, I have a handy script called: ~/bin/ansi_colours: #!/usr/bin/env python3 Much of the above is drawn from the Wikipedia page " ANSI escape code". Support for "true color" terminals is listed here. So you can put pinkish text on a brownish background using \033[38 2 255 82 197 48 2 155 106 0mHello Now we are living in the future, and the full RGB spectrum is available using: \033[38 2 m #Select RGB foreground color The 8-bit colours are arranged like so: 0x00-0x07: standard colors (same as the 4-bit colours)Ġx10-0圎7: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)Ġ圎8-0xFF: grayscale from black to white in 24 steps Using these above, you can make pink text like so: \033[38 5 206m #That is, \033[38 5 mĪnd make an early-morning blue background using \033[48 5 57m #That is, \033[48 5 mĪnd, of course, you can combine these: \033[38 5 206 48 5 57m Technology advanced, and tables of 256 pre-selected colours became available, as shown below. Generally speaking, the naming, use, and grouping of colours in human languages is fascinating. However, digging deeper into these languages shows that each uses colour in distinct ways. ( More information here)ĭifferences between languages are also interesting: note the profusion of distinct colour words used by English vs. Red appears 15 times, while yellow and green appear only 10 times. Homer's Odyssey contains black almost 200 times and white about 100 times. It may also be why the Bible does not contain the colour blue. This may be why story Beowulf only contains the colours black, white, and red.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |