vi editor enhancement request

Dan Mercer mercer at ncrcce.StPaul.NCR.COM
Tue Nov 21 07:31:36 AEST 1989


In article <371 at bilver.UUCP> bill at bilver.UUCP (Bill Vermillion) writes:
:In article <1634 at novavax.UUCP> rwright at novavax.UUCP (Ronald K. Wright) writes:
:>wali at tron.UUCP (Saleem Wali) writes:
:>> .... utility which allows "vi" to display ....at the top of the screen.
: 
:>Such is available on the ATT 3B1 when using an ATT610 terminal.
:>Likewise, in Tandy Xenix using the ATT610.  I have no idea what
:>drives it, but when you are in insert, a small ins appear on the
:>bottom of the 610's screen.  Thus there is a signal about insert.
:>
:>No other terminal machine which I have used seems to have it.
:
:Many terminals that have a "status" line available do it in the Xenix's I use.
:Don't recall if it does it on the Unix ones, don't have one available right
:now to test, but I seem to remember it works the same.
:
:On a Wsye 60 (for example) anytime I am inserting an INS appears on the top of
:the screen when it is in extended format mode.  Standard mode gives time of
:day but no INS.   
:
:
:-- 
:Bill Vermillion - UUCP: {uiucuxc,hoptoad,petsd}!peora!tarpit!bilver!bill
:                      : bill at bilver.UUCP

To understand why you get this message,  you have to understand that many
ascii terminals support hardware insertion modes.   If you have a
terminfo based vi,  and the mir flag is set,  and the smir and rmir
strings are set (in termcap mir=mi, smir=im, rmir=ei) then when you
enter insert mode,  the smir string will be sent.  When you hit escape,
the rmir string will be sent.  The ascii terminal detects the string,
and if it supports a status line,  reflects that mode on the status
line.  ADDS Viewpoint 90's support this capability.

If you set showmode in SYSV vi,  the string "INPUT MODE" will appear
in the right hand side of the command line.
(Unless of course,  you happen to move the cursor with the cursor keys.
Entering a new line will restore the string.

As for using the top line for a status line,  that would be relatively
easy on any terminal that supports scrolling regions (vt100's,
ADDS Viewpoint 60's and 90's,  most Wyse's,  at least in emulation mode).
Using your own terminfo database,  change cup to reflect lines 2-24.
Change line#23.  Change home to point to 2,1.  Change clear to move
to 2,1 and clear to end of screen.  Set hs (HasStatusline).  Set up
tsl to write ToStatusLine (this may require setting scrolling region
to 1,1, moving the cursor to 1,1 and clearing the line.  Set up fsl
to leave FromStatusLine (change scrolling region to 2-24,  move cursor
to 2,1).

Vi will now only write in the bottom 23 lines.  You then need to write
a wrapper shell script to write to the status line and invoke vi.
Be sure to trap out interrupts.  Add a few refinements to your .exrc
file,  and you can modify the status line when you change files.

For instance,  to change files,  set up a pf key:

map #1 :e `modF
map #2 :n `modF

Then,  enter file name(s)`<CR>

modF is as follows:

======================================================================

TSL=${TSL:-`tput tsl`}
FSL=${FSL:-`tput fsl`}

if [ $# -eq 0 ]
	then
	echo "${TSL}     unnamed        size 0${FSL}\c" >/dev/tty
	exit
fi

if [ -f $1 ]
	then
	size=`set -- \`ls -l $1\`;echo $4`
else
	size=0
fi

echo "${TSL}     $1        size $size${FSL}\c" >/dev/tty

echo $@
======================================================================

note,  status line commands must be piped directly to terminal,  not
stdout.

Want vi in split screen mode,  that's possible too,  with different
TERMINFO settings for the top and bottom and the right .exrc functions
to swap between.

Since tput is rather slow,  I read it once during my profile and store
the useful strings in my environment (which makes env output a nightmare).
I've even written a cup function that uses argv[1] as the cup string
for cursor positioning.


-- 

Dan Mercer
Reply-To: mercer at ncrcce.StPaul.NCR.COM (Dan Mercer)



More information about the Comp.unix.questions mailing list