[comp.sys.sgi] Alternatives to /usr/sbin/bindkey for window pop/push ?

tim@bhpmrl.oz.au (Tim Monks) (01/08/91)

Is there any way of popping/pushing windows without touching the mouse ?

I have been using /usr/sbin/bindkey and the following key-bindings for a
while  :

    /usr/sbin/bindkey -l f1,push
    /usr/sbin/bindkey -l f2,pop

and have become quite accustomed to using the F1/F2 keys to toggle overlapping
windows.  It saves a lot of mousework.

I have just started using tcsh, (tcsh 5.20.02 Cornell, 240GTX, Irix 3.3.1.) and
love the command line editing.  But there is an incompatibility somewhere 
between vi, tcsh and bindkey (the /usr/sbin/bindkey not, tcsh's bindkey). 
If I try any command in vi which requires variable expansion, then I get
an error message.  For example, under csh the following command in vi :

	:r $tlib/abort.c

works quite happily and reads in the file /ipada/tim/tomography/abort.c
but under tcsh I get the following message :

    "^[P103;146.ypush^[\^[P103;147.ypop^[\/ipada/tim/tomography/lib/abort" 
    No such file or directory

The problem is caused by /usr/sbin/bindkey, since if I remove the two lines
from my .cshrc which bind F1/F2 to window pop/push, vi under tcsh does 
variable expansion quite happily.


So can anyone suggest alternative ways to bind pop/push facilities to the 
F keys without breaking vi under tcsh ?  

I shall post a summary of replies if warranted.
--
Dr. Tim Monks                                
Image Processing & Data Analysis Group   |   (direct) (+61-3)566-7448
BHP Research - Melbourne Laboratories    |   (switch) (+61-3)560-7066
245 Wellington Rd, Mulgrave, 3170,       |   (fax)    (+61-3)561-6709
AUSTRALIA                                |   (EMAIL)  tim@bhpmrl.oz.au

chawley@sundiver.esd.sgi.com (Christopher J. Hawley) (01/09/91)

    In article <1991Jan8.015407.22178@bhpmrl.oz.au>, tim@bhpmrl.oz.au
(Tim Monks) writes:

|> Is there any way of popping/pushing windows without touching the mouse ?

    Yes.  From Table A-2 in my (old) copy of the _4Sight Programmer's Guide_
"Using the GL/DGL Interfaces", Appendix A, pg. GA-4:

	Sequence		Semantics
	========		==============================================

	CSI n {;n...} / y	SGI command
				    n = 3:	pushes the  wsh  window
				    n = 4:	pops the  wsh  window

So, the commands

		/bin/echo  "\033[3/y\c" >/dev/ttyq4
		/bin/echo  "\033[4/y\c" >/dev/ttyq4

can be used to (respectively) push and pop a window, in this  ttyq4 .

|> I have been using /usr/sbin/bindkey and the following key-bindings for a
|> while  :
|>     /usr/sbin/bindkey -l f1,push
|>     /usr/sbin/bindkey -l f2,pop
|> and have become quite accustomed to using the F1/F2 keys to toggle
|> overlapping windows.  It saves a lot of mousework.

    Agreed!

|> I have just started using tcsh, (tcsh 5.20.02 Cornell, 240GTX, Irix 3.3.1.) and
|> love the command line editing.  But there is an incompatibility somewhere 
|> between vi, tcsh and bindkey (the /usr/sbin/bindkey not, tcsh's bindkey). 
|> If I try any command in vi which requires variable expansion, then I get
|> an error message.  For example, under csh the following command in vi :
|> 
|> 	:r $tlib/abort.c
|> 
|> works quite happily and reads in the file /ipada/tim/tomography/abort.c
|> but under tcsh I get the following message :
|> 
|>     "^[P103;146.ypush^[\^[P103;147.ypop^[\/ipada/tim/tomography/lib/abort" 
|>     No such file or directory
|> 
|> The problem is caused by /usr/sbin/bindkey, since if I remove the two lines
|> from my .cshrc which bind F1/F2 to window pop/push, vi under tcsh does 
|> variable expansion quite happily.

    In fact, from my understanding of  bindkey , it simply generates the
appropriate device control string(s) and sends them on to the  wsh  from which
it is invoked; see the continuation of Table A-2.  The problem appears when
 vi  needs to use the shell to perform variable expansion, as in your example
above, and your  .cshrc  contains commands which cause output to the tty; I
imagine that  vi  does something like

		popen("echo  $tlib/abort.c", r)

and gets the output of  bindkey(1)  thrown in, which confuses the issue.

|> So can anyone suggest alternative ways to bind pop/push facilities to the 
|> F keys without breaking vi under tcsh ?  

    About all I can recommend is that you move the key binding commands out
of  .cshrc  and into  .login  (or anyplace where they don't get executed for
***every*** shell forked).  Do you really need to set them for each shell?
Alternatively, you could specify that  vi  should use a different shell
for subcommands:
		set sh=/bin/csh
if that's an acceptable solution.

|> Dr. Tim Monks                                
|> Image Processing & Data Analysis Group   |   (direct) (+61-3)566-7448
|> BHP Research - Melbourne Laboratories    |   (switch) (+61-3)560-7066
|> 245 Wellington Rd, Mulgrave, 3170,       |   (fax)    (+61-3)561-6709
|> AUSTRALIA                                |   (EMAIL)  tim@bhpmrl.oz.au

#include	"std_disclaimer.h"
---
    Christopher J. Hawley / esper               chawley@sundiver.esd.sgi.com
    Silicon Graphics, Inc.    1L-945            phone:  415 / 335-1621
    Mountain View, CA   94039-7311  USA                 408 / 243-1042
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "Nicht nur wie schnell Sie fahren, sondern _wie_ Sie schnell fahren."

gold@sgi.com (Michael Gold) (01/15/91)

In article <1991Jan8.015407.22178@bhpmrl.oz.au> tim@bhpmrl.oz.au (Tim Monks) writes:
>
>I have been using /usr/sbin/bindkey and the following key-bindings for a
>while  :
>
>    /usr/sbin/bindkey -l f1,push
>    /usr/sbin/bindkey -l f2,pop
>
>If I try any command in vi which requires variable expansion, then I get
>an error message.  For example, under csh the following command in vi :
>
>	:r $tlib/abort.c
>
>works quite happily and reads in the file /ipada/tim/tomography/abort.c
>but under tcsh I get the following message :
>
>    "^[P103;146.ypush^[\^[P103;147.ypop^[\/ipada/tim/tomography/lib/abort" 
>    No such file or directory
>
>The problem is caused by /usr/sbin/bindkey, since if I remove the two lines
>from my .cshrc which bind F1/F2 to window pop/push, vi under tcsh does 
>variable expansion quite happily.
>

The problem is in your .cshrc .  When vi forks a tcsh to expand the
variable, the tcsh runs your .cshrc, which runs bindkey, which sends a
control string to stdout.  To fix this, you need to conditionalize your
.cshrc:

if ($?prompt) then
    /usr/sbin/bindkey -l f1,push
    /usr/sbin/bindkey -l f2,pop
endif

This way, bindkey is only run if you start up a tcsh (or csh) for normal,
interactive use.  Note that if you set your prompt in your .cshrc it should
be done after the `if' (and preferably inside it!).  Most of my .cshrc sits
inside the `if' statement: all but my PATH definition and commands to protect
me from myself (such as "alias rm \rm -i").
--
    Michael I. Gold	 	You go your way, I'll go mine,
    Silicon Graphics Inc.	I don't care if we get there on time,
    Internet: gold@sgi.com	Everybody's searching for something they say,
    Voice: (415) 335-1709	I'll get my kicks on the way...