[comp.editors] resizing shelltool containing vi

pete@TIRS.oz.au (Peter Bartel) (03/05/91)

I want to be able to resize an OpenWindows shelltool/cmdtool in
which I'm running vi (on SunOS 4.1). A crude fix would be sufficient
such as:
    1 resize the window
    2 quit vi
    3 restart vi at the same location in the file from where I quit

But how can steps 2 and 3 be automated? Or is there a nicer
solution?
_______________________________________________________________________
Peter Bartel	Senior Software Engineer	International
Phone:		+61-8-232-1740			Railroad
Faxstream:	+61-8-232-2274			Systems
E-mail:		pete@TIRS.oz.au			(Electronics)
Snail:		209-217 Wakefield St, Adelaide, South Australia, 5000

tchrist@convex.COM (Tom Christiansen) (03/06/91)

From the keyboard of pete@TIRS.oz.au (Peter Bartel):
:I want to be able to resize an OpenWindows shelltool/cmdtool in
:which I'm running vi (on SunOS 4.1). A crude fix would be sufficient
:such as:
:    1 resize the window
:    2 quit vi
:    3 restart vi at the same location in the file from where I quit
:
:But how can steps 2 and 3 be automated? Or is there a nicer
:solution?

Your vi should catch the SIGWINCH and recompute your screen size.
You shouldn't ahve to do anything.

--tom
--
	I get so tired of utilities with arbitrary, undocumented,
	compiled-in limits.  Don't you?

Tom Christiansen		tchrist@convex.com	convex!tchrist

ian@unipalm.uucp (Ian Phillipps) (03/06/91)

pete@TIRS.oz.au (Peter Bartel) writes:

>I want to be able to resize an OpenWindows shelltool/cmdtool in
>which I'm running vi (on SunOS 4.1).


Nearly two years ago we ( a software developers' conference organised
by Sun & AT&T. ) were promised that

(1) The next version of Sun OS will be SVR4

(2) The "vi" on this release will act on SIGWINCH (which is what you need).
So, all you need to do is wait :-). Or use emacs. ;-)

Ian

mayoff@cs.utexas.edu (Robert Mayoff) (03/07/91)

>From the keyboard of pete@TIRS.oz.au (Peter Bartel):
>:I want to be able to resize an OpenWindows shelltool/cmdtool in
>:which I'm running vi (on SunOS 4.1). A crude fix would be sufficient
>:such as:
>:    1 resize the window
>:    2 quit vi
>:    3 restart vi at the same location in the file from where I quit

In article <1991Mar06.034658.17775@convex.com> tchrist@convex.COM (Tom Christiansen) writes:
>Your vi should catch the SIGWINCH and recompute your screen size.
>You shouldn't ahve to do anything.

The program is that SunOS vi does not support SIGWINCH.  This is incredibly
stupid, in my opinion, since Suns are designed with the idea of running a
window system.  The :ve command in SunOS vi gives "Version SVR3.1".  The
administrators around here have installed a different version of vi (:ve gives
"Version 3.7, 6/7/85.") which handles SIGWINCH.  However, you can still get vi
to resize itself even if it does not support SIGWINCH, but you cannot put the
commands in a macro.  What you have to do is type

Q			this quits vi mode and leaves you in ex
set term=xterm		..or whatever terminal you're on; ex will examine
			the stty parameters and find the new window size
vi			this will get back into vi
-- 
/_  rob		<mayoff@cs.utexas.edu>
 /_ Fun things to do with UNIX (#2 in a series):
  / echo "rsh `hostname` -n source eat.cpu &" > eat.cpu; source eat.cpu

jhon@dubhe.gsfc.nasa.gov (Honce. Jhon) (03/07/91)

In article <1991Mar06.034658.17775@convex.com> tchrist@convex.COM (Tom Christiansen) writes:
 |:But how can steps 2 and 3 be automated? Or is there a nicer
 |:solution?
 |
 |Your vi should catch the SIGWINCH and recompute your screen size.
 |You shouldn't ahve to do anything.

SCO ODT does not do this, you can't use their 'resize' command with the
csh and xterm.  So I had to set the env variable LINES to make vi
happy.  Because of the env variable I can't auotmate my solution from
within vi.

 |	I get so tired of utilities with arbitrary, undocumented,
 |	compiled-in limits.  Don't you?

/jwh
Jhon Honce -- jhon@dubhe.gsfc.nasa.gov -- (301) 286-{7164|7778}
/jwh
Jhon Honce -- jhon@dubhe.gsfc.nasa.gov -- (301) 286-{7164|7778}

tchrist@convex.COM (Tom Christiansen) (03/07/91)

From the keyboard of mayoff@cs.utexas.edu (Robert Mayoff):
:>From the keyboard of pete@TIRS.oz.au (Peter Bartel):
:>:I want to be able to resize an OpenWindows shelltool/cmdtool in
:>:which I'm running vi (on SunOS 4.1). A crude fix would be sufficient
:>:such as:
:>:    1 resize the window
:>:    2 quit vi
:>:    3 restart vi at the same location in the file from where I quit
:
:In article <1991Mar06.034658.17775@convex.com> tchrist@convex.COM (Tom Christiansen) writes:
:>Your vi should catch the SIGWINCH and recompute your screen size.
:>You shouldn't ahve to do anything.
:
:The problem is that SunOS vi does not support SIGWINCH.  

What an act of monumental stupidity!!!  They switch from a BSD vi to a SysV
one (which is pretty dumb -- think where vi came from and who wrote it) 
and they lose the ability to handle window size changes.  Plus it no
longer respects $TERMCAP.  I'm sure they won't back down on the 
2nd one cause they're weasels, but if they don't fix the window thing,
they don't give a damn about their customers.

--tom
--
	I get so tired of utilities with arbitrary, undocumented,
	compiled-in limits.  Don't you?

Tom Christiansen		tchrist@convex.com	convex!tchrist

pete@TIRS.oz.au (Peter Bartel) (03/07/91)

From article <1991Mar06.034658.17775@convex.com>, by tchrist@convex.COM 
(Tom Christiansen):
> From the keyboard of pete@TIRS.oz.au (Peter Bartel):
> :I want to be able to resize an OpenWindows shelltool/cmdtool in
> :which I'm running vi (on SunOS 4.1). A crude fix would be sufficient
> :such as:
> :    1 resize the window
> :    2 quit vi
> :    3 restart vi at the same location in the file from where I quit
> :
> :But how can steps 2 and 3 be automated? Or is there a nicer
> :solution?
> 
> Your vi should catch the SIGWINCH and recompute your screen size.
> You shouldn't ahve to do anything.
> 
Unfortunately, this lack of automatic readjustment is a documented bug in
SunOS 4.1
_______________________________________________________________________
Peter Bartel	Senior Software Engineer	International
Phone:		+61-8-232-1740			Railroad
Faxstream:	+61-8-232-2274			Systems
E-mail:		pete@TIRS.oz.au			(Electronics)
Snail:		209-217 Wakefield St, Adelaide, South Australia, 5000

guy@auspex.auspex.com (Guy Harris) (03/08/91)

>Your vi should catch the SIGWINCH and recompute your screen size.

*And* not fuck up if the "vi" happens to be doing something when it gets
the SIGWINCH; alas, the BSD "vi" *does* fuck up - the way it "handles"
(to put it loosely) SIGWINCH is that it does a monster "longjmp" out of
the main command loop.  If you were in the middle of reading in a file,
say, you lose.

The SunOS "vi" doesn't catch SIGWINCH, in order to prevent that problem. 
A better fix might be to check it at the top of the command loop, so
that it won't respond to a SIGWINCH unless it's in a reasonable position
to do so. 

Oh, another thing the BSD one doesn't do - it doesn't resize the screen
if you're in the middle of an "insert" command.

guy@auspex.auspex.com (Guy Harris) (03/09/91)

>What an act of monumental stupidity!!!  They switch from a BSD vi to a SysV
>one (which is pretty dumb -- think where vi came from and who wrote it) 
>and they lose the ability to handle window size changes.

Nice rant, but unfortunately, it doesn't match reality:

1) the ability to handle window size changes was removed from the
   *B*S*D* version of "vi" by Sun, not from the S5 version.  The switch
   from a BSD "vi" to a System V "vi" had nothing to do with that; had we made
   the BSD handle window size changes *properly* (which, as I've noted,
   the BSD version does *NOT* do), we would have folded that change into
   the S5 "vi", just as we folded the other bug fixes, and the "tag
   stack" stuff, into the S5 "vi".

2) the reason Sun switched to the S5 version of "vi" was that the latter
   version can cope with 8-bit character sets, while the BSD version
   can't, and a large amount of ugly surgery would have been involved in
   an attempt to fix up the BSD version.  Yes, there *are* people who
   want "vi" to handle 8-bit characters; in a recent posting in one of
   the "comp.unix.*" groups, somebody asked whether there was any way to
   get their "vi" to do so.  (The fact that it also supported "set
   showmode" was a nice bonus; yes, people had complained about the
   lack of *that* as well in the previous SunOS "vi".)

As for "where 'vi' came from and who wrote it", well, "who wrote it"
wasn't *at* Berkeley any more, and hadn't been there for a while, and
hadn't had anything to do with "vi" for a while.  I agree, it would have
been *wonderful* to have stuck our esteemed Vice President for Research
and Development in a room and said "you're not leaving this room until
you 1) fix up the other guy's botch in implementing SIGWINCH handling in
"vi" and 2) make the damn thing handle 8-bit character sets", but
somehow, I don't think that would have been possible.... 

guy@auspex.auspex.com (Guy Harris) (03/09/91)

>The program is that SunOS vi does not support SIGWINCH.  This is incredibly
>stupid, in my opinion, since Suns are designed with the idea of running a
>window system.  The :ve command in SunOS vi gives "Version SVR3.1".  The
>administrators around here have installed a different version of vi (:ve gives
>"Version 3.7, 6/7/85.")

The ":ve" command in the SunOS 4.1[.x] "vi" gives "Version SVR3.1".  The
":ve" command in the SunOS 4.0[.x] "vi" gives - wait for it - "Version
3.7, 6/7/85."; that version doesn't support SIGWINCH, either.

> which handles SIGWINCH.

OK, just for laughs, try resizing the window while it's reading in a
large file, and see whether it finishes reading in the file or just
bails out as soon as you resize the window.  If it doesn't bail out,
find out where that version of "vi" came from, and ask them to send the
fixes back to Berkeley....

mh@roger.imsd.contel.com (Mike Hoegeman) (03/09/91)

In article <6486@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes:
>>Your vi should catch the SIGWINCH and recompute your screen size.
>
>*And* not fuck up if the "vi" happens to be doing something when it gets
>the SIGWINCH; alas, the BSD "vi" *does* fuck up - the way it "handles"
>(to put it loosely) SIGWINCH is that it does a monster "longjmp" out of
>the main command loop.  If you were in the middle of reading in a file,
>say, you lose.
>

For all you out there who find SIGWINCH desirable while editing. you
might want to check the vi clone "elvis". It's pretty close to the real
vi in functionality. I just tried doing all kinds of resizes of my NeWS
version of elvis (in insert mode , etc.. ) and it seems to handle it
well. If anybody is interested drop me line and I can make the source
available for ftp. The NeWS version will fall back to a termcap mode of
operation if it cannot connect to the news server. Even if you are not
interested in having a NeWS version you might want to check it out
anyway. It should be pretty easy to port to Xview since the NeWS wire
service and Xview's Notifier are pretty similar in concept. As a quick
hack You could probably just rip out the PostScript calls and stuff a
ttysw Xview object in it's place

I'm sure it would be a decent starting point for other X toolkits but
it would probably be a little more work.

mike hoegeman, mh@roger.imsd.contel.com