.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Term::ExtendedColor 3pm" .TH Term::ExtendedColor 3pm "2019-11-23" "perl v5.30.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Term::ExtendedColor \- Color screen output using 256 colors .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Term::ExtendedColor qw(:all); \& \& # Or use the \*(Aqattributes\*(Aq tag to only import the functions for setting \& # attributes. \& # This will import the following functions: \& \& # fg(), bg(), bold(), underline(), inverse(), italic(), clear() \& use Term::ExtendedColor \*(Aq:attributes\*(Aq; \& \& ## Foreground colors \& \& my $red_text = fg(\*(Aqred2\*(Aq, \*(Aqthis is in red\*(Aq); \& my $spring = fg(\*(Aqspringgreen3\*(Aq, \*(Aqthis is green\*(Aq); \& \& ## Background colors \& \& print bg(\*(Aqred5\*(Aq, "Default foreground text on dark red background"), "\en"; \& my $red_on_green = fg(\*(Aqred3\*(Aq, bg(\*(Aqgreen12\*(Aq, \*(AqRed text on green background\*(Aq)); \& print "$red_on_green\en"; \& \& ## Fall\-through attributes \& \& Term::ExtendedColor::autoreset(0); \& my $bold = fg(\*(Aqbold\*(Aq, \*(AqThis is bold\*(Aq); \& my $red = fg(\*(Aqred2\*(Aq, \*(AqThis is red... and bold\*(Aq); \& my $green = bg(\*(Aqgreen28\*(Aq, \*(AqThis is bold red on green background\*(Aq); \& \& # Make sure to clear all attributes when autoreset turned OFF, \& # or else the users shell will be messed up \& \& my $clear = clear(); \& print "$bold\en"; \& print "$red\en"; \& print "$green $clear\en"; \& \& ## Non\-color attributes \& \& # Turn on autoreset again \& Term::ExtendedColor::autoreset(1); \& \& for(qw(italic underline blink reverse bold)) { \& print fg($_, $_), "\en"; \& } \& \& # For convenience \& \& my $bolded = bold("Bold text!"); \& my $italic = italic("Text in italics!"); \& \& ## Remove all attributes from input data \& my @colored; \& push(@colored, fg(\*(Aqbold\*(Aq, fg(\*(Aqred2\*(Aq, \*(AqBold and red\*(Aq))); \& push(@colored, fg(\*(Aqgreen13\*(Aq, fg(\*(Aqitalic\*(Aq, \*(AqGreen, italic\*(Aq))); \& \& print "$_\en" for @colored; \& print "$_\en" for uncolor(@colored); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBTerm::ExtendedColor\fR provides functions for sending so called extended escape sequences to the terminal. This ought to be used with a 256\-color compatible terminal; see the \s-1NOTES\s0 section for a matrix of terminal emulators currently supporting this. .SH "EXPORTS" .IX Header "EXPORTS" None by default. .PP Two tags are provided for convience: .PP .Vb 2 \& # Import all functions \& use Term::ExtendedColor qw(:all); \& \& # Import functions for setting attributes \& # fg(), bg(), bold(), italic(), underline(), inverse(), clear() \& use Term::ExtendedColor qw(:attributes); .Ve .SH "FUNCTIONS" .IX Header "FUNCTIONS" .ie n .SS "fg($color, $string)" .el .SS "fg($color, \f(CW$string\fP)" .IX Subsection "fg($color, $string)" .Vb 2 \& my $green = fg(\*(Aqgreen2\*(Aq, \*(Aqgreen foreground\*(Aq); \& my @blue = fg(\*(Aqblue4\*(Aq, [\*(Aqtakes arrayrefs as well\*(Aq]); \& \& my $x_color = fg(\*(Aqmediumorchid1\*(Aq, \*(AqUsing mappings from the X11 rgb.txt\*(Aq); \& \& my $arbitary_color = fg(4, \*(AqThis is colored in the fifth ANSI color\*(Aq); \& \& my $raw_seq = fg(\*(Aq38;5;197;48;5;53;1;3;4;5;7\*(Aq, \*(Aqthis works too\*(Aq); .Ve .PP Set foreground colors and attributes. .PP See \*(L"\s-1COLORS AND ATTRIBUTES\*(R"\s0 for valid first arguments. Additionally, colors can be specified using their index value: .PP .Vb 1 \& my $yellow = fg(220, \*(AqYellow\*(Aq); .Ve .PP If the internal \f(CW$AUTORESET\fR variable is non-zero (default), every element in the list of strings will be wrapped in escape sequences in such a way that the requested attributes will be set before the string and reset to defaults after the string. .PP Fall-through attributes can be enabled by setting \f(CW$AUTORESET\fR to a false value. .PP .Vb 3 \& Term::ExtendedColor::autoreset( 0 ); \& my $red = fg(\*(Aqred1\*(Aq, \*(AqRed\*(Aq); \& my $green = fg(\*(Aqgreen1\*(Aq, \*(AqGreen\*(Aq); \& \& print "Text after $red is red until $green\en"; \& print "Text is still green, ", bold(\*(Aqand now bold as well!\*(Aq); \& \& # If you exit now without resetting the colors and attributes, chances are \& # your prompt will be messed up. \& \& clear(); # All back to normal .Ve .PP If an invalid attribute is passed, the original data will be returned unmodified. .PP If no attribute is passed, thrown an exception. .ie n .SS "bg($color, $string)" .el .SS "bg($color, \f(CW$string\fP)" .IX Subsection "bg($color, $string)" .Vb 2 \& my $green_bg = bg(\*(Aqgreen4\*(Aq, \*(Aqgreen background\*(Aq); \& my @blue_bg = bg(\*(Aqblue6\*(Aq, [\*(Aqblue background\*(Aq]); .Ve .PP Like \f(CW\*(C`fg()\*(C'\fR, but sets background color. .SS "uncolor($string) | uncolour($string)" .IX Subsection "uncolor($string) | uncolour($string)" .Vb 3 \& my $stripped = uncolor($colored_data); \& my @no_color = uncolor(\e@colored); \& my @no_color = uncolor(@colored); .Ve .PP Remove all attribute and color escape sequences from the input. .PP See uncolor for a command-line utility using this function. .SS "\fBget_colors()\fP | \fBget_colours()\fP" .IX Subsection "get_colors() | get_colours()" .Vb 1 \& my $colors = get_colors(); .Ve .PP Returns a hash reference with all available attributes and colors. .SS "\fBclear()\fP" .IX Subsection "clear()" When called in scalar context, returns the escape sequence that resets all attributes to their defaults. .PP When called in void context, prints it directly. .SS "\fBautoreset()\fP" .IX Subsection "autoreset()" Turn autoreset on/off. Enabled by default. .PP .Vb 1 \& Term::ExtendedColor::autoreset( 0 ); # Turn off autoreset .Ve .SS "bold(\e@data)" .IX Subsection "bold(@data)" Convenience function that might be used in place of \f(CW\*(C`fg(\*(Aqbold\*(Aq, \e@data)\*(C'\fR; .PP When called without arguments, returns a a string that turns off the bold attribute. .SS "italic(\e@data)" .IX Subsection "italic(@data)" Convenience function that might be used in place of \f(CW\*(C`fg(\*(Aqitalic\*(Aq, \e@data)\*(C'\fR; .PP When called without arguments, returns a a string that turns off the italics attribute. .SS "underline(\e@data)" .IX Subsection "underline(@data)" Convenience function that might be used in place of \f(CW\*(C`fg(\*(Aqunderline\*(Aq, \e@data)\*(C'\fR; .PP When called without arguments, returns a a string that turns off the underline attribute. .SS "inverse(\e@data)" .IX Subsection "inverse(@data)" Reverse video / inverse. Convenience function that might be used in place of \f(CW\*(C`fg(\*(Aqinverse\*(Aq, \e@data)\*(C'\fR; .PP When called without arguments, returns a a string that turns off the inverse attribute. .SH "NOTES" .IX Header "NOTES" The codes generated by this module complies to the extension of the \s-1ANSI\s0 colors standard first implemented in xterm in 1999. The first 16 color indexes (0 \- 15) is the regular \s-1ANSI\s0 colors, while index 16 \- 255 is the extension. Not all terminal emulators support this extension, though I've had a hard time finding one that doesn't. :) .PP .Vb 10 \& Terminal 256 colors \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& aterm no \& eterm yes \& gnome\-terminal yes \& konsole yes \& lxterminal yes \& mrxvt yes \& roxterm yes \& rxvt no \& rxvt\-unicode yes * \& sakura yes \& terminal yes \& terminator yes \& vte yes \& xterm yes \& iTerm2 yes \& Terminal.app no \& \& GNU Screen yes \& tmux yes \& TTY/VC no .Ve .PP * Previously needed a patch. Full support was added in version 9.09. .PP There's no way to give these extended colors meaningful names. .PP Our first thought was to map them against some standard color names, like those in the \s-1HTML 4.0\s0 specification or the \s-1SVG\s0 one. They didn't match. .PP Therefore, they are named by their base color (red, green, magenta) plus index; The first index (always 1) is the brightest shade of that particular color, while the last index is the darkest. .PP It's also possible to use some X color names, as defined in \f(CW\*(C`rgb.txt\*(C'\fR. Do note that the color values do not match exactly; it's just an approximation. .PP A full list of available colors can be retrieved with \f(CW\*(C`get_colors()\*(C'\fR. See \*(L"\s-1COLORS AND ATTRIBUTES\*(R"\s0 for full list. All mapped colors can also be retrieved programmatically with \f(CW\*(C`get_colors()\*(C'\fR. .SH "COLORS AND ATTRIBUTES" .IX Header "COLORS AND ATTRIBUTES" .SS "Attributes" .IX Subsection "Attributes" .Vb 9 \& reset, clear, normal reset all attributes \& bold, bright bold or bright, depending on implementation \& faint decreased intensity (not widely supported) \& italic, cursive italic or cursive \& underline, underscore underline \& blink slow blink \& blink_ms rapid blink (only supported in MS DOS) \& reverse, inverse, negative reverse video \& conceal conceal, or hide (not widely supported) .Ve .SS "Standard color map" .IX Subsection "Standard color map" .Vb 1 \& FIRST LAST \& \& red1 red5 \& blue1 blue17 \& cyan1 cyan24 \& gray1 gray24 \& green1 green28 \& orange1 orange5 \& purple1 purple30 \& yellow1 yellow18 \& magenta1 magenta26 .Ve .SS "X color names" .IX Subsection "X color names" .Vb 10 \& aquamarine1 \& aquamarine3 \& blueviolet \& cadetblue1 \& cadetblue2 \& chartreuse1 \& chartreuse2 \& chartreuse3 \& chartreuse4 \& cornflowerblue \& cornsilk1 \& darkblue \& darkcyan \& darkgoldenrod \& darkgreen \& darkkhaki \& darkmagenta1 \& darkmagenta2 \& darkolivegreen1 \& darkolivegreen2 \& darkolivegreen3 \& darkolivegreen4 \& darkolivegreen5 \& darkorange3 \& darkorange4 \& darkorange1 \& darkred1 \& darkred2 \& darkseagreen1 \& darkseagreen2 \& darkseagreen3 \& darkseagreen4 \& darkslategray1 \& darkslategray2 \& darkslategray3 \& darkturquoise \& darkviolet \& deeppink1 \& deeppink2 \& deeppink3 \& deeppink4 \& deepskyblue1 \& deepskyblue2 \& deepskyblue3 \& deepskyblue4 \& deepskyblue4 \& dodgerblue1 \& dodgerblue2 \& dodgerblue3 \& gold1 \& gold3 \& greenyellow \& grey0 \& grey100 \& grey11 \& grey15 \& grey19 \& grey23 \& grey27 \& grey30 \& grey3 \& grey35 \& grey37 \& grey39 \& grey42 \& grey46 \& grey50 \& grey53 \& grey54 \& grey58 \& grey62 \& grey63 \& grey66 \& grey69 \& grey70 \& grey74 \& grey7 \& grey78 \& grey82 \& grey84 \& grey85 \& grey89 \& grey93 \& honeydew2 \& hotpink2 \& hotpink3 \& hotpink \& indianred1 \& indianred \& khaki1 \& khaki3 \& lightcoral \& lightcyan1 \& lightcyan3 \& lightgoldenrod1 \& lightgoldenrod2 \& lightgoldenrod3 \& lightgreen \& lightpink1 \& lightpink3 \& lightpink4 \& lightsalmon1 \& lightsalmon3 \& lightsalmon3 \& lightseagreen \& lightskyblue1 \& lightskyblue3 \& lightskyblue3 \& lightslateblue \& lightslategrey \& lightsteelblue1 \& lightsteelblue3 \& lightsteelblue \& lightyellow3 \& mediumorchid1 \& mediumorchid3 \& mediumorchid \& mediumpurple1 \& mediumpurple2 \& mediumpurple3 \& mediumpurple4 \& mediumpurple \& mediumspringgreen \& mediumturquoise \& mediumvioletred \& mistyrose1 \& mistyrose3 \& navajowhite1 \& navajowhite3 \& navyblue \& orangered1 \& orchid1 \& orchid2 \& orchid \& palegreen1 \& palegreen3 \& paleturquoise1 \& paleturquoise4 \& palevioletred1 \& pink1 \& pink3 \& plum1 \& plum2 \& plum3 \& plum4 \& purple \& rosybrown \& royalblue1 \& salmon1 \& sandybrown \& seagreen1 \& seagreen2 \& seagreen3 \& skyblue1 \& skyblue2 \& skyblue3 \& slateblue1 \& slateblue3 \& springgreen1 \& springgreen2 \& springgreen3 \& springgreen4 \& steelblue1 \& steelblue3 \& steelblue \& tan \& thistle1 \& thistle3 \& turquoise2 \& turquoise4 \& violet \& wheat1 \& wheat4 .Ve .PP In addition, it's also possible to pass raw color;attr strings like so: .PP .Vb 1 \& my $foo = fg(\*(Aq48;5;89;38;5;197;1;3;4;7\*(Aq, \*(Aqfoo\*(Aq); .Ve .PP Even though the \fBfg()\fR function is used, we set the following attributes: .PP .Vb 6 \& background => 89 \& foreground => 197 \& bold \& italic \& underline \& reverse .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Term::ExtendedColor::Xresources Term::ExtendedColor::TTY Term::ANSIColor .SH "AUTHOR" .IX Header "AUTHOR" .Vb 5 \& Magnus Woldrich \& CPAN ID: WOLDRICH \& m@japh.se \& http://github.com/trapd00r \& http://japh.se .Ve .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" Varadinsky .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2010, 2011, 2018, 2019\- the \fBTerm::ExtendedColor\fR \*(L"\s-1AUTHOR\*(R"\s0 and \*(L"\s-1CONTRIBUTORS\*(R"\s0 as listed above. .SH "LICENSE" .IX Header "LICENSE" This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself.