Add "Random" for 255 colors mode
Thus we can specify "random" for 8 colors mode, or "Random" for 255 colors.
This commit is contained in:
parent
811ef56bcb
commit
eba7c1462d
2 changed files with 10 additions and 2 deletions
|
|
@ -20,11 +20,14 @@ If you ask for less colors, the last one will be duplicated across remaining
|
||||||
groups.
|
groups.
|
||||||
|
|
||||||
Available colors are: blue, black, yellow, cyan, green, magenta, white, red,
|
Available colors are: blue, black, yellow, cyan, green, magenta, white, red,
|
||||||
rainbow, random, or any number between 0 and 255.
|
rainbow, random, Random or any number between 0 and 255.
|
||||||
|
|
||||||
Available styles are: normal, bold, faint, italic, underline, blink,
|
Available styles are: normal, bold, faint, italic, underline, blink,
|
||||||
rapid_blink, reverse, conceal or random.
|
rapid_blink, reverse, conceal or random.
|
||||||
|
|
||||||
|
`Random` will color each matching pattern with a random color among the 255
|
||||||
|
available in the ANSI table. `random` will do the same in 8 colors mode.
|
||||||
|
|
||||||
When not specified, a *COLOR* defaults to _red_ and a *STYLE* defaults to _bold_.
|
When not specified, a *COLOR* defaults to _red_ and a *STYLE* defaults to _bold_.
|
||||||
|
|
||||||
`colout` is released under the GNU Public License v3.
|
`colout` is released under the GNU Public License v3.
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ def colorin( text, color = "red", style = "normal" ):
|
||||||
stop = "\033[0m"
|
stop = "\033[0m"
|
||||||
|
|
||||||
# Convert the style code
|
# Convert the style code
|
||||||
if style == "random":
|
if style == "random" or style == "Random":
|
||||||
style = random.choice(list(styles.keys()))
|
style = random.choice(list(styles.keys()))
|
||||||
else:
|
else:
|
||||||
assert( style in styles)
|
assert( style in styles)
|
||||||
|
|
@ -62,6 +62,11 @@ def colorin( text, color = "red", style = "normal" ):
|
||||||
color_code = random.choice(list(colors.values()))
|
color_code = random.choice(list(colors.values()))
|
||||||
color_code = str( 30 + color_code )
|
color_code = str( 30 + color_code )
|
||||||
|
|
||||||
|
elif color == "Random":
|
||||||
|
mode = 256
|
||||||
|
color_nb = random.randint(0,255)
|
||||||
|
color_code = str( color_nb )
|
||||||
|
|
||||||
elif color == "rainbow":
|
elif color == "rainbow":
|
||||||
global rainbow_idx
|
global rainbow_idx
|
||||||
mode = 8
|
mode = 8
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue