Operating System - HP-UX
1755703 Members
3701 Online
108837 Solutions
New Discussion юеВ

'C' printf - Highlight, Reverse Video

 
SOLVED
Go to solution
Tom Dawson
Regular Advisor

'C' printf - Highlight, Reverse Video

I'm using 'C' and the printf command to do text output to a VT220. Is it possible to turn on highlighting or reverse video in this mode?

If so, can someone point me to some documentation?

TIA!
Tom
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: 'C' printf - Highlight, Reverse Video

Hi Tom:

Yes, it is possible but you are really going about it in the wrong way. You should be using the 'curses' package so that the video functions do not rely on hard-coded sequences. If you use curses, the the reverse video, cursor positioning, underlining, graphics, ... are all determined at run-time by reading the terminfo database that are in turn determined by the setting of the TERM environment variable. The beauty of this method is that this will work with any defined terminal and you don't have to change a line of code. Man curses for details.



Regards, Clay
If it ain't broke, I can fix that.
Steven Gillard_2
Honored Contributor

Re: 'C' printf - Highlight, Reverse Video

You should probably have a look at using curses library routines for this task. See the curses_intro(3x) and curses(5) man pages for further details.

If you want to do it yourself, the following page contains the vt220 escape sequences:

http://www.fastlane.net/~generic9/vt220.html

Regards,
Steve

Carlos Fernandez Riera
Honored Contributor

Re: 'C' printf - Highlight, Reverse Video

If you dont like to do a full implementation of curses, you can do a little trick:

BOLD=`tput bold`
UND=`tput smul`
END_UND=`tput sgr0`

use getenv in your c source and use it:

char *bold;

bold=getenv("BOLD"):

printf (" %s, bold \n", bold);




I guess c code is write ( it so long to me...).
unsupported