ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> activeperl
activeperl
RE: Reset in ANSIColor sets the background to black
by Erich Singer other posts by this author
Mar 27 2009 12:31PM messages near this date
RE: Reset in ANSIColor sets the background to black | Looking for a module to process & merge TIF files.
Hello
 
I am using ver 5.10.0.
In the example, I ignore the current background and foreground colors (
because I do not know how to get them...) and force a bold green on a
blue background. Error messages should be bold red on a blue background.
I have added the code in bold e.g. system ("cls"); 
Issue the color changes at the beginning of your program, and this way
you minimize the effect of the cls command, e.g. you do not loose too
much data already displayed on the screen
 
HTH
 
Erich
 
use strict;
use warnings;
use Win32::Console::ANSI;
use Term::ANSIColor;
use Term::ANSIScreen qw/:color :cursor :screen/;
color 'bold green on blue';
system ("cls");
print "\nPrior to error\n";
print colored ("\nThis is an error\n", 'bold red',);
color 'bold green on blue';
print "\nAfter error\n";
__END__

 

________________________________

From: Perl Help [mailto:perlhelp60@[...].com] 
Sent: Friday, March 27, 2009 3:12 PM
To: Singer, Erich
Cc: Bill Luebkert; activeperl@[...].com
Subject: Re: Reset in ANSIColor sets the background to black


Hi,

I tried this code, but it shows the same results in cmd.exe. Also, is
there a way I can read the current background and foreground color of
dos window from perl?

Thanks,
Jai!


On Fri, Mar 27, 2009 at 7:01 AM, Singer, Erich
<Erich.Singer@[...].com>  wrote:


	Hello
	 
	Please try
	 
	Thanks
	Erich
	 
	
	use strict;
	use warnings;
	use Win32::Console::ANSI;
	use Term::ANSIColor;
	
	use Term::ANSIScreen qw/:color :cursor :screen/;
	color 'bold green on blue';
	print "\nPrior to error\n";
	print colored ("\nThis is an error\n", 'bold red',);
	color 'bold green on blue';
	print "\nAfter error\n";
	__END__
	

________________________________

	From: activeperl-bounces@[...].com
[mailto:activeperl-bounces@[...].com] On Behalf Of Perl
Help
	Sent: Thursday, March 26, 2009 11:33 PM
	To: Bill Luebkert
	Cc: activeperl@[...].com
	Subject: Re: Reset in ANSIColor sets the background to black
	
	
	Hi Bill,
	
	Thanks for your response. DId you try running CLS command after
executing the code. When I do that, it switches my FG/BG color to
default that is White on Black. More so, my code is not showing the same
results as you described. Is there any other file I need to take care
off? Do you want me to send you the screen shot how it looks like when I
run the program?
	
	Thanks once again for your help,
	
	~Jai!
	
	
	On Thu, Mar 26, 2009 at 3:53 PM, Bill Luebkert
<dbecoll@[...].com>  wrote:
	

		Perl Help wrote:
		

			Hi,
			
			My current DOS background color is white with
Black text. I use ANSIColor module to print error messages in Red color.
I use the Color command and I face two issues:
			
			1. The Red color error message text thats
printed on DOS has black background, instead of white only.
			2. On typing CLS the background color changes to
black and text color changes to white.
			
			What is my Expectation:
			1. On prinitng the text in red color should not
have the background color black but use the current DOS background
color(White in my case).
			
			2. On doing CLS on DOS, the dos should maintain
its background color(White in my case) rather then setting it to default
black background color.
			
			My Code:
			use Win32::Console::ANSI;
			use Term::ANSIColor;
			print color "Bold Red";
			print "ERROR_MSG = xyz";
			print color 'reset';
			


		Seems OK to me on 5.8.8 B820.  5.001 & 5.006 on the
modules, resp.
		
		>  p test.pl             [switched my FG/BG to reverse
(black on white) prior to test
		Prior to error          [black on white]
		ERROR_MSG = xyz         [this was red on white]
		Done                    [black on white]
		
		Everything came out fine as near as I can tell.
		
		My code:
		
		use strict;
		use warnings; 

		use Win32::Console::ANSI;
		use Term::ANSIColor;
		
		
		print "Prior to error\n";
		print color "Bold Red";
		print "ERROR_MSG = xyz\n";
		print color 'reset';
		print "Done\n";
		
		__END__
		
		
Thread:
Perl Help
Bill Luebkert
Perl Help
Bill Luebkert
Erich Singer
Perl Help
Bill Luebkert
Perl Help
Erich Singer
Erich Singer

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved