|
NAMETerm::ANSIScreen - Terminal control using ANSI escape sequencesSYNOPSIS# qw/:color/ is exported by default, i.e. color() & colored() use Term::ANSIScreen qw/:color :cursor :screen :keyboard/; print setmode(1), setkey('a','b'); print "40x25 mode now, with 'a' mapped to 'b'."; <STDIN>; resetkey; setmode 3; cls; locate 1, 1; print "@ This is (1,1)", savepos; print locate(24,60), "@ This is (24,60)"; loadpos; print down(2), clline, "@ This is (3,15)\n"; setscroll 1, 20; color 'black on white'; clline; print "This line is black on white.\n"; print color 'reset'; print "This text is normal.\n"; print colored ("This text is bold blue.\n", 'bold blue'); print "This text is normal.\n"; print colored ['bold blue'], "This text is bold blue.\n"; print "This text is normal.\n"; use Term::ANSIScreen qw/:constants/; # constants mode print BLUE ON GREEN . "Blue on green.\n"; $Term::ANSIScreen::AUTORESET = 1; print BOLD GREEN . ON_BLUE "Bold green on blue.", CLEAR; print "\nThis text is normal.\n"; # Win32::Console emulation mode # this returns a Win32::Console object on a Win32 platform my $console = Term::ANSIScreen->new; $console->Cls; # also works on non-Win32 platform DESCRIPTIONTerm::ANSIScreen is a superset of Term::ANSIColor (as of version 1.04 of that module). In addition to color-sequence generating subroutines exported by ":color" and ":constants", this module also features ":cursor" for cursor positioning, ":screen" for screen control, as well as ":keyboard" for key mapping.NOTES
FUNCTIONSWin32::Console emulation modeWhen used in a object-oriented fashion, Term::ANSIScreen acts as a Win32::Console clone:use Term::ANSIScreen; my $console = Term::ANSIScreen->new; $console->Cls(); # unbuffered $console->Cursor(0, 0); # same as locate(1, 1) $console->Display(); # really a no-op On the Win32 platform, the "new" constructor simply returns a geniune Win32::Console object, if that module exists in the system. This feature is intended for people who has to port Win32 console applications to other platforms, or to write cross-platform application that needs terminal controls. The ":color" function set (exported by default)Term::ANSIScreen recognizes (case-insensitively) following color attributes: clear, reset, bold, underline, underscore, blink, reverse, concealed, black, red, green, blue, white, yellow, magenta, cyan, on_black, on_red, on_green, on_blue, on_white, on_yellow, on_magenta, and on_cyan.The color alone sets the foreground color, and on_color sets the background color. You may also use on_color without the underscore, e.g. "black on white".
The ":constants" function setIf you import ":constants" you can use the constants CLEAR, RESET, BOLD, UNDERLINE, UNDERSCORE, BLINK, REVERSE, CONCEALED, BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, ON_BLACK, ON_RED, ON_GREEN, ON_YELLOW, ON_BLUE, ON_MAGENTA, ON_CYAN, and ON_WHITE directly. These are the same as color('attribute') and can be used if you prefer typing:print BOLD BLUE ON_WHITE "Text\n", RESET; print BOLD BLUE ON WHITE "Text\n", RESET; # _ is optional to print colored ("Text\n", 'bold blue on_white'); When using the constants, if you don't want to have to remember to add the ", RESET" at the end of each print line, you can set $Term::ANSIScreen::AUTORESET to a true value. Then, the display mode will automatically be reset if there is no comma after the constant. In other words, with that variable set: print BOLD BLUE "Text\n"; will reset the display mode afterwards, whereas: print BOLD, BLUE, "Text\n"; will not. The ":cursor" function set
The ":screen" function set
The ":keyboard" function set
DIAGNOSTICS
SEE ALSOTerm::ANSIColor, Win32::ConsoleAUTHORS唐鳳 <cpan@audreyt.org>CC0 1.0 UniversalTo the extent possible under law, 唐鳳 has waived all copyright and related or neighboring rights to Term-ANSIScreen.This work is published from Taiwan. <http://creativecommons.org/publicdomain/zero/1.0> POD ERRORSHey! The above document had some coding errors, which are explained below:
Visit the GSP FreeBSD Man Page Interface. |