![]() ![]() on_ variants of all of these colors are also provided. The grey and RGB colors are also available as ansi16 through ansi255 if you want simple names for all 256 colors. The RGB colors are of the form rgb RGB where R, G, and B are numbers from 0 to 5 giving the intensity of red, green, and blue. Even better, offer the user a way to configure the colors for a given application to fit their terminal emulator.įor 256-color emulators, this module additionally provides ansi0 through ansi15, which are the same as colors 0 through 15 in sixteen-color emulators but use the 256-color escape syntax, grey0 through grey23 ranging from nearly black to nearly white, and a set of RGB colors. If you know the display is one of those emulators, you may wish to use the bright variants instead. However, they will appear dark in sixteen-color terminal emulators, including most common emulators in UNIX X environments. The most conservative choice is to use only the regular colors, which are at least displayed on all emulators. There is unfortunately no way to know whether the current emulator supports more than eight colors, which makes the choice of colors difficult. Capitalize these strings for the constant interface. The same applies for background colors: on_red is the normal color and on_bright_red is the bright color. For example, red is color 1 and bright_red is color 9. For every normal color (0 through 7), the corresponding bright color (8 through 15) is obtained by prepending the string bright_ to the normal color name. Some sixteen-color terminal emulators also treat normal yellow (color 3) as orange or brown, and bright yellow (color 11) as yellow.įollowing the normal convention of sixteen-color emulators, this module provides a pair of attributes for each color. Bright black usually is a dark grey color, although some terminals display it as pure black. ![]() On such emulators, the "normal" white (color 7) usually is shown as pale grey, requiring bright white (15) to be used to get a real white color. Emulators that support 16 colors, such as gnome-terminal, normally display colors 0 through 7 as dim or darker versions and colors 8 through 15 as normal brightness. Emulators that only support eight colors (such as the Linux console) will display colors 0 through 7 with normal brightness and ignore colors 8 through 15, treating them the same as white. Unfortunately, interpretation of colors 0 through 7 often depends on whether the emulator supports eight colors or sixteen colors. ![]() These colors are referred to as ANSI colors 0 through 7 (normal), 8 through 15 (16-color), 16 through 255 (256-color), and true color (called direct-color by xterm). This module provides the ANSI escape codes for all of them. Terminal emulators that support color divide into four types: ones that support only eight colors, ones that support sixteen, ones that support 256, and ones that support 24-bit color. See "COMPATIBILITY" for the versions of Term::ANSIColor that introduced particular features and the versions of Perl that included them. See "Supporting CLICOLOR" for more information. If you are using Term::ANSIColor in a console command, consider supporting the CLICOLOR standard. It also offers the utility functions uncolor(), colorstrip(), colorvalid(), and coloralias(), which have to be explicitly imported to be used (see "SYNOPSIS"). This module has two interfaces, one through color() and colored() and the other through constants. Print POPCOLOR "Back to whatever we started as.\n" DESCRIPTION Print ON_BLUE "This text is red on blue.\n" Print LOCALCOLOR GREEN ON_BLUE "This text is green on blue.\n" Print POPCOLOR "Back to red on green.\n" Print RESET BRIGHT_BLUE "This text is just bright blue.\n" Print PUSHCOLOR BRIGHT_BLUE "This text is bright blue on green.\n" Print PUSHCOLOR RED ON_GREEN "This text is red on green.\n" Print BOLD BLUE "This text is in bold blue.\n" Print BOLD, BLUE, "This text is in bold blue.\n", RESET Print colored("This is in red.", 'alert'), "\n" Print "Alert is ", coloralias('alert'), "\n" Print "Color string is ", $valid ? "valid\n" : "invalid\n" My $valid = colorvalid('blue bold', 'on_magenta') Print colorstrip("\e[1mThis is bold\e[0m"), "\n" # Map escape sequences back to color names. Print colored(, 'Bright red on black.', "\n") Print colored(, 'Red on bright yellow.', "\n") ![]() Print colored(, 'Yellow on magenta.', "\n") Print colored("Yellow on magenta.", 'yellow on_magenta'), "\n" Term::ANSIColor - Color screen output using ANSI escape sequences SYNOPSIS use Term::ANSIColor ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |