From: MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 21-JAN-1993 22:51:36.38 To: info-vax@kl.sri.com CC: Subj: Re: How do I use colour under VMS? In article <1993Jan19.231922.94@ittpub.nl>, david@ittpub.nl (David P. Morgan) writes: > In article <1993Jan19.105241.12734@reks.uia.ac.be>, derijkp@reks.uia.ac.be (Peter De Rijk) writes: >> I am working on a C program on a VAXstation. I currently use the Curses >> library for output to terminal or DECterm. I would like to be able to >> display text in different colours (if the terminal supports it). The Curses >> package under VMS does not support colour. Programming in X woul take too >> much time ( especially since I still would have to learn it). Is there >> another, easy, way to get colour. I only need the very basic output >> commands: put a cursor on specified position, and print characters (but in >> colour). >> Any help would be greatly appreciated, > > On the colour terminals I have seen (240, 340, DECterm) changing video > attributes from normal to bold, reverse, blinking or a combination will (also) > cause a change of colour (on the VT240 it was possible to get red, green and > blue simultaneously). There are other methods of choosing the screen colours; > check the terminal handbook, and just output the escape sequences explicitly. > It's quick 'n' dirty but I think that's what you wanted. The VT240 and VT340 do allow you to use the bold and reverse attributes as separate colors, as David noted. But the DECterm on the VAXstation allows you to use ANSI video mode escape sequences to change the color as well. For some reason, this is supported on the DECterm but not on the VT240 or the VT340. To use these sequences, you have to write: ESC [ p1 m to the terminal, where the possible values for p1 are: 30 - Black foreground 40 - Black background 31 - Red foreground 41 - Red background 32 - Green foreground 42 - Green background 33 - Yellow foreground 43 - Yellow background 34 - Blue foreground 44 - Blue background 35 - Magenta foreground 45 - Magenta background 36 - Cyan foreground 46 - Cyan background 37 - White foreground 47 - White background As with other video mode sequences, you can combine the values, so that to have yellow text on a blue background you would write: ESC [33;44m The following command file demonstrates the use of these sequences. $! $! COLORS.COM - Demonstrate the use of colors on the VAXstation $! using ANSI escape sequences under DECterm. $! $ esc[0,8] = 27 $ fore = 30 $ back = 40 $ say := write sys$output $ loop: say f$fao ("!AS[!SL;!SLm Foreground = !SL Background = !SL", - esc, fore, back, fore, back) $ fore = fore + 1 $ if fore .le. 37 then goto loop $ fore = 30 $ back = back + 1 $ if back .le. 47 then goto loop $ say esc+"[m" $ exit Bruce C. Wright