1846842 Members
8182 Online
110256 Solutions
New Discussion

VI Query

 
SOLVED
Go to solution
Rudi Martin
Advisor

VI Query

Hi there all

I am busy doing some menus in VI and want them to look nicer and more user friendly. HP-UX 11 using VT220 emulations.

I've got the \t (tab) and \n (newline) as well as the $hi $lo down , but need to know if there's any way to make bold , underline or even italic characters.

Thank you
Regards
Rudi
5 REPLIES 5
Chris Wilshaw
Honored Contributor
Solution

Re: VI Query

The best way to do this is with the tput command.

The man page has details on how to set variables for different emulations

eg:

bold=`tput smso`
Graham Cameron_1
Honored Contributor

Re: VI Query

This isn't really a vi issue I don't think.
Are your menus driven by shell scripts?
If so, take a look at tput (man tput).

eg
tput bold;echo THIS IS BOLD;tput sgr0

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Bill Hassell
Honored Contributor

Re: VI Query

tput is the way to perform these tasks. tput uses the Curses library which looks at the terminal's capability via $TERM. In turn, $TERM must match the 'terminal' you are using, in this case, a VT220 emulator. You'll have to read the emulator's manual to determine what it actually supports (there are emulators and there are cheap imitations...). To see what HP-UX thinks a VT220 can do, type this command:

untic vt220

and you'll see what Curses will do with each of the characteristics (like bold, clear, smso, etc). To decode the somewhat cryptic feature list, use man terminfo. Here is a general list:

export HB=$(/usr/bin/tput dim) # dim text
export HV=$(/usr/bin/tput smso) # 1/2 bright inverse
export IV=$(/usr/bin/tput bold) # inverse
export UL=$(/usr/bin/tput smul) # underline
export BL=$(/usr/bin/tput blink) # blink
export EE=$(/usr/bin/tput sgr0) # end all enhancements

# Some terminals do not have 1/2 bright inverse so let's test this
# capability and substitute underline rather than $HV

if tput smso > /dev/null
then
HVUL=$HV
else
HVUL=$UL
fi

Another idea:

alias c="tput khome;tput clear" # quick clear all of memory

You can reach virtually all features available for the VT220 using tput including randomly moving the cursor around the screen using tput, but the even better news is that it will work with other terminals such as hpterm and xterm. tput is terminal-neutral by using the Curses library, so as long as the feature exists in the terminal *and* the terminfo database (see /usr/lib/terminfo/*) has an entry for that terminal, you'll be able to do some very fancy menu work.


Bill Hassell, sysadmin
Keith Bevan_1
Trusted Contributor

Re: VI Query

Rudi,

tput blink # Turns on blink

tput bold # Turns on bold

Try a man on tput for more information :-

man tput


Keith
You are either part of the solution or part of the problem
Rudi Martin
Advisor

Re: VI Query

Thank you to all for your help. It's working perfectly and looks stunning.

Cheers