⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 term::ansicolor.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
you're using background colors, since a background color that persistsacross a newline is often interpreted by the terminal as providing thedefault background color for the next line.  Programs like pagers can alsobe confused by attributes that span lines.  Normally you'll want to set\&\f(CW$Term::ANSIColor::EACHLINE\fR to \f(CW"\en"\fR to use this feature..PPAlternately, if you import \f(CW\*(C`:constants\*(C'\fR, you can use the constants \s-1CLEAR\s0,\&\s-1RESET\s0, \s-1BOLD\s0, \s-1DARK\s0, \s-1UNDERLINE\s0, \s-1UNDERSCORE\s0, \s-1BLINK\s0, \s-1REVERSE\s0, \s-1CONCEALED\s0, \s-1BLACK\s0,\&\s-1RED\s0, \s-1GREEN\s0, \s-1YELLOW\s0, \s-1BLUE\s0, \s-1MAGENTA\s0, \s-1CYAN\s0, \s-1WHITE\s0, \s-1ON_BLACK\s0, \s-1ON_RED\s0, \s-1ON_GREEN\s0,\&\s-1ON_YELLOW\s0, \s-1ON_BLUE\s0, \s-1ON_MAGENTA\s0, \s-1ON_CYAN\s0, and \s-1ON_WHITE\s0 directly.  These arethe same as color('attribute') and can be used if you prefer typing:.PP.Vb 1\&    print BOLD BLUE ON_WHITE "Text", RESET, "\en";.Ve.PPto.PP.Vb 1\&    print colored ("Text", \*(Aqbold blue on_white\*(Aq), "\en";.Ve.PP(Note that the newline is kept separate to avoid confusing the terminal asdescribed above since a background color is being used.).PPWhen using the constants, if you don't want to have to remember to add the\&\f(CW\*(C`, RESET\*(C'\fR at the end of each print line, you can set\&\f(CW$Term::ANSIColor::AUTORESET\fR to a true value.  Then, the display mode willautomatically be reset if there is no comma after the constant.  In otherwords, with that variable set:.PP.Vb 1\&    print BOLD BLUE "Text\en";.Ve.PPwill reset the display mode afterwards, whereas:.PP.Vb 1\&    print BOLD, BLUE, "Text\en";.Ve.PPwill not.  If you are using background colors, you will probably want toprint the newline with a separate print statement to avoid confusing theterminal..PPThe subroutine interface has the advantage over the constants interface inthat only two subroutines are exported into your namespace, versustwenty-two in the constants interface.  On the flip side, the constantsinterface has the advantage of better compile time error checking, sincemisspelled names of colors or attributes in calls to \fIcolor()\fR and \fIcolored()\fRwon't be caught until runtime whereas misspelled names of constants will becaught at compile time.  So, pollute your namespace with almost two dozensubroutines that you may not even use that often, or risk a silly bug bymistyping an attribute.  Your choice, \s-1TMTOWTDI\s0 after all..SH "DIAGNOSTICS".IX Header "DIAGNOSTICS".ie n .IP "Bad escape sequence %s" 4.el .IP "Bad escape sequence \f(CW%s\fR" 4.IX Item "Bad escape sequence %s"(F) You passed an invalid \s-1ANSI\s0 escape sequence to \fIuncolor()\fR..ie n .IP "Bareword ""%s"" not allowed while ""strict subs"" in use" 4.el .IP "Bareword ``%s'' not allowed while ``strict subs'' in use" 4.IX Item "Bareword %s not allowed while strict subs in use"(F) You probably mistyped a constant color name such as:.Sp.Vb 1\&    $Foobar = FOOBAR . "This line should be blue\en";.Ve.Spor:.Sp.Vb 1\&    @Foobar = FOOBAR, "This line should be blue\en";.Ve.SpThis will only show up under use strict (another good reason to run underuse strict)..ie n .IP "Invalid attribute name %s" 4.el .IP "Invalid attribute name \f(CW%s\fR" 4.IX Item "Invalid attribute name %s"(F) You passed an invalid attribute name to either \fIcolor()\fR or \fIcolored()\fR..ie n .IP "Name ""%s"" used only once: possible typo" 4.el .IP "Name ``%s'' used only once: possible typo" 4.IX Item "Name %s used only once: possible typo"(W) You probably mistyped a constant color name such as:.Sp.Vb 1\&    print FOOBAR "This text is color FOOBAR\en";.Ve.SpIt's probably better to always use commas after constant names in order toforce the next error..IP "No comma allowed after filehandle" 4.IX Item "No comma allowed after filehandle"(F) You probably mistyped a constant color name such as:.Sp.Vb 1\&    print FOOBAR, "This text is color FOOBAR\en";.Ve.SpGenerating this fatal compile error is one of the main advantages of usingthe constants interface, since you'll immediately know if you mistype acolor name..ie n .IP "No name for escape sequence %s" 4.el .IP "No name for escape sequence \f(CW%s\fR" 4.IX Item "No name for escape sequence %s"(F) The \s-1ANSI\s0 escape sequence passed to \fIuncolor()\fR contains escapes whicharen't recognized and can't be translated to names..SH "ENVIRONMENT".IX Header "ENVIRONMENT".IP "\s-1ANSI_COLORS_DISABLED\s0" 4.IX Item "ANSI_COLORS_DISABLED"If this environment variable is set, all of the functions defined by thismodule (\fIcolor()\fR, \fIcolored()\fR, and all of the constants not previously used inthe program) will not output any escape sequences and instead will justreturn the empty string or pass through the original text as appropriate.This is intended to support easy use of scripts using this module onplatforms that don't support \s-1ANSI\s0 escape sequences..SpFor it to have its proper effect, this environment variable must be setbefore any color constants are used in the program..SH "RESTRICTIONS".IX Header "RESTRICTIONS"It would be nice if one could leave off the commas around the constantsentirely and just say:.PP.Vb 1\&    print BOLD BLUE ON_WHITE "Text\en" RESET;.Ve.PPbut the syntax of Perl doesn't allow this.  You need a comma after thestring.  (Of course, you may consider it a bug that commas between all theconstants aren't required, in which case you may feel free to insert commasunless you're using \f(CW$Term::ANSIColor::AUTORESET\fR.).PPFor easier debugging, you may prefer to always use the commas when notsetting \f(CW$Term::ANSIColor::AUTORESET\fR so that you'll get a fatal compile errorrather than a warning..SH "NOTES".IX Header "NOTES"The codes generated by this module are standard terminal control codes,complying with \s-1ECMA\-48\s0 and \s-1ISO\s0 6429 (generally referred to as \*(L"\s-1ANSI\s0 color\*(R"for the color codes).  The non-color control codes (bold, dark, italic,underline, and reverse) are part of the earlier \s-1ANSI\s0 X3.64 standard forcontrol sequences for video terminals and peripherals..PPNote that not all displays are \s-1ISO\s0 6429\-compliant, or even X3.64\-compliant(or are even attempting to be so).  This module will not work as expected ondisplays that do not honor these escape sequences, such as cmd.exe, 4nt.exe,and command.com under either Windows \s-1NT\s0 or Windows 2000.  They may just beignored, or they may display as an \s-1ESC\s0 character followed by some apparentgarbage..PPJean Delvare provided the following table of different common terminalemulators and their support for the various attributes and others have helpedme flesh it out:.PP.Vb 12\&              clear    bold     dark    under    blink   reverse  conceal\& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\& xterm         yes      yes      no      yes     bold      yes      yes\& linux         yes      yes      yes    bold      yes      yes      no\& rxvt          yes      yes      no      yes  bold/black   yes      no\& dtterm        yes      yes      yes     yes    reverse    yes      yes\& teraterm      yes    reverse    no      yes    rev/red    yes      no\& aixterm      kinda   normal     no      yes      no       yes      yes\& PuTTY         yes     color     no      yes      no       yes      no\& Windows       yes      no       no      no       no       yes      no\& Cygwin SSH    yes      yes      no     color    color    color     yes\& Mac Terminal  yes      yes      no      yes      yes      yes      yes.Ve.PPWindows is Windows telnet, Cygwin \s-1SSH\s0 is the OpenSSH implementation underCygwin on Windows \s-1NT\s0, and Mac Terminal is the Terminal application in Mac \s-1OS\s0X.  Where the entry is other than yes or no, that emulator displays thegiven attribute as something else instead.  Note that on an aixterm, cleardoesn't reset colors; you have to explicitly set the colors back to what youwant.  More entries in this table are welcome..PPNote that codes 3 (italic), 6 (rapid blink), and 9 (strikethrough) arespecified in \s-1ANSI\s0 X3.64 and \s-1ECMA\-048\s0 but are not commonly supported by mostdisplays and emulators and therefore aren't supported by this module at thepresent time.  \s-1ECMA\-048\s0 also specifies a large number of other attributes,including a sequence of attributes for font changes, Fraktur characters,double-underlining, framing, circling, and overlining.  As none of theseattributes are widely supported or useful, they also aren't currentlysupported by this module..SH "SEE ALSO".IX Header "SEE ALSO"\&\s-1ECMA\-048\s0 is available on-line (at least at the time of this writing) at<http://www.ecma\-international.org/publications/standards/ECMA\-048.HTM>..PP\&\s-1ISO\s0 6429 is available from \s-1ISO\s0 for a charge; the author of this module doesnot own a copy of it.  Since the source material for \s-1ISO\s0 6429 was \s-1ECMA\-048\s0and the latter is available for free, there seems little reason to obtainthe \s-1ISO\s0 standard..PPThe current version of this module is always available from its web site at<http://www.eyrie.org/~eagle/software/ansicolor/>.  It is also part of thePerl core distribution as of 5.6.0..SH "AUTHORS".IX Header "AUTHORS"Original idea (using constants) by Zenin, reimplemented using subs by RussAllbery <rra@stanford.edu>, and then combined with the original idea by Russwith input from Zenin.  Russ Allbery now maintains this module..SH "COPYRIGHT AND LICENSE".IX Header "COPYRIGHT AND LICENSE"Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006 Russ Allbery<rra@stanford.edu> and Zenin.  This program is free software; you mayredistribute it and/or modify it under the same terms as Perl itself.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -