5/7/2023 0 Comments Ansi escape sequences![]() ![]() 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. |