Actually the ANSI escapes span lines so newline position is really immaterial (except from a neatness point of view). In fact AFAIK they remain active until reset, and this status outlives the life of your program as you are effectively manipulating defaults on your term.
$ cat col.pl
#!/usr/bin/perl
# default black background
use constant BLUE => "\e[0;34;40m";
use constant RED => "\e[0;31;40m";
use constant DEFAULT => "\e[0;37;40m";
print "The flag is:
", RED, "
red
", DEFAULT, "
white &
", BLUE,"
blue.
ANSI color escapes
will span", DEFAULT, " at least with
putty as the terminal emulation.
", BLUE;
$ ./col.pl
The flag is:
red
white &
blue.
ANSI color escapes
will span at least with
putty as the terminal emulation.
$
$ echo Oops forgot to reset blue mode
Oops forgot to reset blue mode
$ perl -e 'print "\e[0;37;40m"';
$ echo Fixed....
Fixed....
|