Forum Moderators: coopster & phranque

Message Too Old, No Replies

Changing DOS Colors in Perl

         

adni18

12:38 pm on May 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello. I was wondering if there is a way to change background colors and font colors in DOS via perl. Also I was wondering if it is possible to detect where the user's mouse is and to detect when the user clicks it.

Is there a Tk module for this?

Please respond ASAP.

lexipixel

1:38 pm on May 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Have you tried Term::ANSIColor?

It should work on terminals and console windows (ie Telnet), and operating systems where ANSI color (ISO 6429) and/or ANSI X3.64 are implemented.

You may need to load ANSI.SYS beforehand on some systems, (ie- older WIN/DOS machines).

It's not 100% predictable and is not 100% cross platform compatable.

What are you trying to do?

balam

5:07 pm on May 1, 2005 (gmt 0)

10+ Year Member



A little FYI: Term::ANSIColor doesn't work under Windows 2000. I seem to recall that it did work under Win98, though - needed to load ANSI.SYS first.

adni18

7:04 pm on May 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



And how would I go about loading ANSI.SYS?

balam

8:00 pm on May 1, 2005 (gmt 0)

10+ Year Member



In your CONFIG.SYS file, located in the root of your C drive, you need to add the line:

device=c:\windowsdirectory\somesubdir\ansi.sys

Search your drive to find where ANSI.SYS is located, and edit the above line as is appropriate. After a reboot, ANSI.SYS will be loaded.

Just reading the man page for Term::ANSIColor and noticed this, further clarifying what lexipixel & I said earlier:

Note that not all displays are ISO 6429-compliant, or even X3.64-compliant (or are even attempting to be so). This module will not work as expected on displays that do not honor these escape sequences, such as cmd.exe, 4nt.exe, and command.com under either Windows NT or Windows 2000. They may just be ignored, or they may display as an ESC character followed by some apparent garbage.

adni18

1:35 am on May 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks. Also I was wondering if it is possible to detect where the user's mouse is and to detect when the user clicks it.

lexipixel

7:52 am on May 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Also I was wondering if it is possible to detect where the user's mouse is and to detect when the user clicks it.

In what type of screen mode? (ie- on an ANSI screen, in a web browser or using some other protocol or emulation)?

adni18

4:19 pm on May 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



DOS. I guess ANSI.

lexipixel

6:27 pm on May 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The only way I know of to detect the x,y (row column) position of the cursor is via mouse interupt. You read the position as well as the button status, (ie- left button click if you want to know when the mouse was clicked and then find where, or poll for position and read when button is up but position is at "x,y" to know when you're hovering over something...

Search for: perl with "signal", "interrupt", "mouse", etc..

Post some code if you get it going!