[comp.sys.ibm.pc] Video Attributes

terryt@auvax.UUCP (Terry Tanski) (02/05/88)

How do you change the video attributes on an IBM PC. I would like to
bold,reverse,underline strings on the screen but don't know how or
what escape sequences to use.

Can anyone help?

Terry Tanski - Systems Analyst
	       Athabasca University
	       Athabasca, Alberta CANADA

(!alberta!auvax!terryt)

cramer@optilink.UUCP (Clayton Cramer) (02/09/88)

> 
> How do you change the video attributes on an IBM PC. I would like to
> bold,reverse,underline strings on the screen but don't know how or
> what escape sequences to use.
> 
> Terry Tanski - Systems Analyst

Make sure that you have ANSI.SYS installed.

Send the following sequences for controlling attributes:

^[[0m	normal
^[[1m	bold
^[[4m	underline (on monochrome cards)
^[[5m	blink
^[[7m	reverse

Experiment with:

^[[30m - ^[[37m and
^[[40m - ^[[47m 

for a variety of foreground and background colors.

Note that using the ANSI driver is very slow -- adequate for very simple
programs, but not for a commercial product.

Clayton E. Cramer

alb7e@uvacs.CS.VIRGINIA.EDU (Lynn Barbee) (02/09/88)

In article <518@auvax.UUCP>, terryt@auvax.UUCP (Terry Tanski) writes:
> 
> How do you change the video attributes on an IBM PC. I would like to
> bold,reverse,underline strings on the screen but don't know how or
> what escape sequences to use.
> 
> Can anyone help?
> 
> Terry Tanski - Systems Analyst
> 	       Athabasca University
> 	       Athabasca, Alberta CANADA
> 
> (!alberta!auvax!terryt)


Subject: Re: Video Attributes

ASSUMPTION: using MS-DOS

A PC uses ANSI escape sequences to print underlined, blinking , etc
characters.  First you must have device=ansi.sys in your config.sys
file and of course have ansi.sys available.  ANSI.SYS should be on
your MS-DOS diskette.  The following is an incomplete set of ANSI
sequence's :

	ESC code sequence		Function
	-----------------		--------

Erase Functions:

	ESC[2J				Clear screen and home cursor

	ESC[K				clear to end of line

Set graphics rendition:

	ESC[#;#;...;#m			Set display attributes where # is

					0 for normal display

					1 for bold on

					4 underline (mono only)

					5 blink on
					
					8 invisible

					30 black foreground

					31 red foreground

					32 green foreground

					33 yellow foreground
		
					34 blue foreground

					35 magenta foreground

					36 cyan foreground

					37 white foreground

					40 - 47 background colors in same order
						as above foreground

ESC[=#;7h				Put screen in mode #

					0 for 40 x 25 mono

					2 for 80 x 25 mono

This is no where near all of them but maybe it's a start.
Hope it helps.

Lynn Barbee
Bell Communications Research
GSP to Univ. Of Virginia

dan@srs.UUCP (Dan Kegel) (02/10/88)

Clayton Cramer writes:
>> How do you change the video attributes on an IBM PC. I would like to
>> bold,reverse,underline strings on the screen...
> Use ANSI.SYS, but note that using the ANSI driver is very slow --
> adequate for very simple programs, but not for a commercial product.

True enough, but there are public domain replacements for the ANSI driver
that are very fast, and quite adequate for commercial products.
The two I know about are NANSI.SYS (my favorite :-) and the recently posted
QWIKANSI.SYS.  If your application sets RAW mode on the console fd
(this is done with the IOCTL system call) and uses NANSI, plain old
puts and printf statements run ten times faster than before.
-- 
   Dan Kegel
   srs!dan@cs.rochester.edu  dan%srs.uucp@cs.rochester.edu  rochester!srs!dan