[comp.sys.next] Disabling cmd-q in Terminal

Lovstrand@EuroPARC.Xerox.COM (Lennart Lovstrand) (06/03/91)

$&#(@&%#!  I just managed to nuke all my Terminal windows again for
the umpteenth time by accidently hitting cmd-q with the wrong input
focus.  It's incredibly how easy it can happen when switching between
development work in a terminal window and test running a new app.
Boom, there went all my remote login sessions and random stopped jobs!

So... Anyone know how to disable cmd-q in Terminal -- preferrably, but
not necessarily, without patching the app?  Wouldn't mind getting rid
of cmd-w at the same time.  At second best (and for possible future
releases), a way of persuading Terminal to ask for confirmation before
closing a window with a live shell would be a real win.

OS 2.1, /NextApps/Terminal dated 30 Oct 1990

Feel free to suggest "use Stuart instead" if that will make me happier.
(Or "tie lead around your fingers", although not quite so appreciated.)

Thanks,
--Lennart (don't read me wrong, I really do love my NeXT box, seriously)
--
--Lennart <Lovstrand@EuroPARC.Xerox.COM>		R   _A _  N_   K
Rank Xerox EuroPARC, 61 Regent St, Cambridge, UK	\/ |_ |_) | | \/
Heart-of-Gold, NeXTcube at EuroPARC, NeXT Mach 2(1)	/\ |_ | \ |_| /\
TOPS-20 Command processor 7(109)-8 [alpha]		E u r o  P A R C

izumi@mindseye.berkeley.edu (Izumi Ohzawa) (06/03/91)

In article <1991Jun2.235028.21517@parc.xerox.com>
 Lovstrand@EuroPARC.Xerox.COM (Lennart Lovstrand) writes:
>
>So... Anyone know how to disable cmd-q in Terminal -- preferrably, but
>not necessarily, without patching the app?  Wouldn't mind getting rid
>of cmd-w at the same time.  At second best (and for possible future
>releases), a way of persuading Terminal to ask for confirmation before
>closing a window with a live shell would be a real win.
>
>OS 2.1, /NextApps/Terminal dated 30 Oct 1990
>

OK, this is relatively easy.
Using InterfaceBuilder, you can do this kind of modifications
quite easily.  This will patch the app (One of the nib files in
__NIB Mach-O segment).

Make a working copy of /NextApps/Terminal in a directory.
Then,

segedit Terminal -extract __NIB Terminal.nib Terminal.nib

You will get Terminal.nib in your directory.  Double click on
Terminal.nib.  IB will start up.  On the Terminal's menu in
IB, double click on the 'q' letter in the "Quit" menu item.
A square will surround the letter 'q', so use Delete key to
wipe out the letter.  Do the same for "Window" "Close" menu's
letter 'w'.

Save the nib file (Command-s).
Then do,

segedit Terminal -replace __NIB Terminal.nib Terminal.nib -o Terminal.new
chmod 4755 Terminal.new

Double click on Terminal.new and see if you have successfully removed
the command equivalents for 'q', and 'w'.

As root, copy over Terminal.new into /NextApps/Terminal.
Or you probably should copy it to /LocalApps and delete the
orginal just to indicate that this is a modified version.


Izumi Ohzawa             [ $@Bg_78^=;(J ]
USMail: University of California, 360 Minor Hall, Berkeley, CA 94720
Telephone: (415) 642-6440             Fax:  (415) 642-3323
Internet: izumi@violet.berkeley.edu   NeXTmail: izumi@pinoko.berkeley.edu 

bchen@nntp-server.caltech.edu (Bing-Qing Chen) (06/03/91)

In article <1991Jun2.235028.21517@parc.xerox.com> Lovstrand@EuroPARC.Xerox.COM (Lennart Lovstrand) writes:
>
>So... Anyone know how to disable cmd-q in Terminal -- preferrably, but
>not necessarily, without patching the app?  Wouldn't mind getting rid
>of cmd-w at the same time.  At second best (and for possible future
>releases), a way of persuading Terminal to ask for confirmation before
>closing a window with a live shell would be a real win.
>
Try
dwrite Terminal NXCommandKeys "Quit,Q,Close Window,W"
which will make cmd-Q instead of cmd-q to quit and cmd-W instead of cmd-w to
close the window. Of course, you can replace "Q" or "W" with whatever character
you want.

Bing Chen
bchen@pooh.caltech.edu

isbell@ucscf.UCSC.EDU (Art Isbell) (06/03/91)

In article <1991Jun2.235028.21517@parc.xerox.com> Lovstrand@EuroPARC.Xerox.COM (Lennart Lovstrand) writes:
>So... Anyone know how to disable cmd-q in Terminal -- preferrably, but
>not necessarily, without patching the app?  Wouldn't mind getting rid
>of cmd-w at the same time.  At second best (and for possible future
>releases), a way of persuading Terminal to ask for confirmation before
>closing a window with a live shell would be a real win.
>
Grab Simon Garfinkel's nibeditor from your favorite NeXT archive site:

   1.  Extract Terminal's .nib files using the extract utility.
   2.  Open Terminal.nib in Interface Builder.
   3.  Select and delete the "q" in the Quit cell in Terminal's menu.
   4.  Repeat for any other keyboard alternatives you want to change.
   5.  Save your changes and exit IB.
   6.  Run the combine utility to produce a new version of Terminal with your
       changes implemented.

You may consider this a patch, but it's pretty trivial because no source code
is changed (you don't even have the source code :-)  I haven't tried it, but
you might even be able to add alert panels similar to the logout alert panel
so you can cancel the Terminal Quit or cancel the closing of a Terminal
window before it happens.
-- 
                                          _____   ____
Art Isbell                 |\   |  HELP!  |    |  |   \    315 Moon Meadow Lane
NeXT Registered Developer  | \  |   ___   |____|  |    |  Felton, CA 95018-9442
isbell@ucscf.UCSC.EDU      |  \ |  |___|  |  \    |    |          (408)335-1154
=> I NEED TO FIND NeXT ==> |   \|  |___   |   \   |___/ ==> DEVELOPMENT WORK <=

glenn@heaven.woodside.ca.us (Glenn Reid) (06/03/91)

Bing-Qing Chen writes

> dwrite Terminal NXCommandKeys "Quit,Q,Close Window,W"

Wow.  How did you learn about that dwrite?  That's really powerful
and great!  Beats the heck out of nibediting the application itself.
After some snooping around, I see that it's supported by all apps.
Why haven't people made a bigger deal out of this?  Is it undocumented?
Who's gonna write the app that lets you change the command-key
equivalents for any applications?

I like it.

--
 Glenn Reid				RightBrain Software
 glenn@heaven.woodside.ca.us		NeXT/PostScript developers
 ..{adobe,next}!heaven!glenn		415-326-2974 (NeXTfax 326-2977)

Lovstrand@EuroPARC.Xerox.COM (Lennart Lovstrand) (06/03/91)

In article <1991Jun3.051146.2818@nntp-server.caltech.edu>  
bchen@nntp-server.caltech.edu (Bing-Qing Chen) writes:
> In article <1991Jun2.235028.21517@parc.xerox.com>  
Lovstrand@EuroPARC.Xerox.COM (Lennart Lovstrand) writes:
> >So... Anyone know how to disable cmd-q in Terminal -- preferrably, but
> >not necessarily, without patching the app?  Wouldn't mind getting rid
> >of cmd-w at the same time.
> >
> Try
> dwrite Terminal NXCommandKeys "Quit,Q,Close Window,W"
> which will make cmd-Q instead of cmd-q to quit and cmd-W instead of cmd-w to
> close the window.
> 
> Bing Chen
> bchen@pooh.caltech.edu

Wow, this is great!  Less than 6 hours after I sent the query (literally  
overnight), I get a reply with exactly the kind of answer that I was looking  
for.  Plus a number of suggestions for using extract + combine, which are also  
much appreciated.

A quick dive into Digital Librarian shows that NXCommandKeys really is --  
although somewhat crudely -- documented in NextDev/ReleaseNotes/AppKit.rtf:

<<A new default NXCommandKeys allows the specification of a command key for a  
given menu item name.  The format is comma delineated menu item name, then  
command key.  Example: "Page Layout..., P, Heavier, H, Lighter, L".  There is  
no user-interface as yet to support this feature of the Application Kit.   This  
functionality is available directly to users via the Preferences application.>>

Thanks all, you've been swell!
--
--Lennart <Lovstrand@EuroPARC.Xerox.COM>		R   _A _  N_   K
Rank Xerox EuroPARC, 61 Regent St, Cambridge, UK	\/ |_ |_) | | \/
Heart-of-Gold, NeXTcube at EuroPARC, NeXT Mach 2(1)	/\ |_ | \ |_| /\
TOPS-20 Command processor 7(109)-8 [alpha]		E u r o  P A R C

pbiron@keynes.ucsd.edu (Paul Biron) (06/03/91)

In article <517@heaven.woodside.ca.us> glenn@heaven.woodside.ca.us (Glenn Reid) writes:
>Bing-Qing Chen writes
>
>> dwrite Terminal NXCommandKeys "Quit,Q,Close Window,W"
>
>Wow.  How did you learn about that dwrite?  That's really powerful
>and great!  Beats the heck out of nibediting the application itself.
>After some snooping around, I see that it's supported by all apps.
>Why haven't people made a bigger deal out of this?  Is it undocumented?
>Who's gonna write the app that lets you change the command-key
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>equivalents for any applications?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>I like it.
>
>--
> Glenn Reid				RightBrain Software
> glenn@heaven.woodside.ca.us		NeXT/PostScript developers
> ..{adobe,next}!heaven!glenn		415-326-2974 (NeXTfax 326-2977)

Richard Williamson already has, its called Preferences (2.0 and up).
Fire up Preferences and look in the section with the picture of a
menu.  Check out the right side, labeled Keyboard Alternatives.

I guess I knew about this since I got 2.0, but never really thought
to *do* anything with it until this discussion came up.

I just set cmd-Q to be quit *in all apps* on my machine.  Note that
for this to take effect for any app which is currently running, you
must quit and restart that app.

-----------------------------------------------------------------------
            Fighting for peace is like fucking for virginity!
-----------------------------------------------------------------------
Paul Biron     garp!pbiron@keynes.ucsd.edu    (can have NeXT attachments)
SnUG/SIGHaCK   San Diego NeXT Users Group/HaCKer's SIG

"Outside of a dog, a book is man's best friend.
 Inside of a dog, it's too dark to read."
                         --Groucho Marx

pbiron@keynes.ucsd.edu (Paul Biron) (06/03/91)

In article <5423@network.ucsd.edu> pbiron@keynes.ucsd.edu (Paul Biron) writes:
>In article <517@heaven.woodside.ca.us> glenn@heaven.woodside.ca.us (Glenn Reid) writes:
>>Bing-Qing Chen writes
>>
>>> dwrite Terminal NXCommandKeys "Quit,Q,Close Window,W"
>>
>>Who's gonna write the app that lets you change the command-key
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>equivalents for any applications?
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>Richard Williamson already has, its called Preferences (2.0 and up).
>Fire up Preferences and look in the section with the picture of a
>menu.  Check out the right side, labeled Keyboard Alternatives.
>

Just after posting the above, I realized that there is even an
easier way of doing this.  Just use:

dwrite System NXCommandKeys "Quit,Q,Close Window,W"

Basically, that's what Prefs does when you use it to change the
Keyboard Alternatives.

-----------------------------------------------------------------------
            Fighting for peace is like fucking for virginity!
-----------------------------------------------------------------------
Paul Biron     garp!pbiron@keynes.ucsd.edu    (can have NeXT attachments)
SnUG/SIGHaCK   San Diego NeXT Users Group/HaCKer's SIG

"Outside of a dog, a book is man's best friend.
 Inside of a dog, it's too dark to read."
                         --Groucho Marx

louie@sayshell.umd.edu (Louis A. Mamakos) (06/04/91)

I think that I remember seeing another solution to the Terminal problem; that
was to have a warning panel pop up when you typed command-Q.  I think the
solution was to extract the NIB file, add a new panel, change the Quit menu
item to display the new panel.  Then you hooked the "OK" button on the panel
to the original destination of the Quit menu item.  The Cancel button simply
closed the panel.

louie

glenn@heaven.woodside.ca.us (Glenn Reid) (06/04/91)

Paul Biron writes
> In article <517@heaven.woodside.ca.us> I wrote: 
> >Wow.  How did you learn about that dwrite? 
> >Who's gonna write the app that lets you change the command-key
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >equivalents for any applications?
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Richard Williamson already has, its called Preferences (2.0 and up).
> I just set cmd-Q to be quit *in all apps* on my machine.

Exactly.  *in all apps*.  But you can't do it for individual apps
with the Preferences app, which is what I was asking about.

I knew about the Preferences feature, but it changes the systemwide
default, not for a particular App.  I didn't realize it was a more
general default/preference in the database, settable for any app.
I also don't really like the fact that it's indexed by character strings.
Some features are spelled slightly differently from one App to the
next, and you can't globally set a preference for all of them.  Plus,
you often can't set global key equivalents without their conflicting
with local key equivalents for particular apps, since anything goes
beyond the few strictly governed ones.  Just try setting a key equivalent
for "C" or "{" or whatever.

So (I think) we still need the KeyEquiv program that will let you
register these defaults for individual applications, rather than for
the whole system.  Plus it needs a better interface than having to type
in exactly what is displayed on the menu button.  I wonder what happens
with menus that change dynamically, as in "Hide Rulers" and "Show Rulers"?
I suppose you need a preference for both of them :-(

--
 Glenn Reid				RightBrain Software
 glenn@heaven.woodside.ca.us		NeXT/PostScript developers
 ..{adobe,next}!heaven!glenn		415-326-2974 (NeXTfax 326-2977)

mcohen@ac-next2 (Michael Cohen) (06/04/91)

Yeah, thanks; i used bchen's suggestion immediately to

dwrite -g NXCommandKeys "Page Layout..., P"

This globally fixes the annoying ommision in WriteNow and anything else that  
elided the shortcut.

-------------
Michael Cohen
Room S-08               
NTT Human Interface Labs
3-9-11, Midori-cho, Musashino-shi 
Tokyo 180

mcohen@ac-next2 (Michael Cohen) (06/04/91)

For what it's worth, i've been putting a confirmation panel in all my
apps, via 

Quit          q

following another menu command

Quick Quit    Q

which skips this confirmation.  The chord is hard enough to press
accidentally, but oftimes convenient.  Besides, i like alliteration.

-------------
Michael Cohen
Room S-08               
NTT Human Interface Labs
3-9-11, Midori-cho, Musashino-shi 
Tokyo 180

scott@mcs-server.gac.edu (Scott Hess) (06/04/91)

In article <5423@network.ucsd.edu> pbiron@keynes.ucsd.edu (Paul Biron) writes:
   In article <517@heaven.woodside.ca.us> glenn@heaven.woodside.ca.us (Glenn Reid) writes:
   >Bing-Qing Chen writes
   >
   >> dwrite Terminal NXCommandKeys "Quit,Q,Close Window,W"
   >
   >Wow.  How did you learn about that dwrite?  That's really powerful
   >and great!  Beats the heck out of nibediting the application itself.
   >After some snooping around, I see that it's supported by all apps.
   >Why haven't people made a bigger deal out of this?  Is it undocumented?
   >Who's gonna write the app that lets you change the command-key
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   >equivalents for any applications?
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   Richard Williamson already has, its called Preferences (2.0 and up).
   Fire up Preferences and look in the section with the picture of a
   menu.  Check out the right side, labeled Keyboard Alternatives.

Well, not really.  Preferences sets the Keyboard Alternatives for
_every_ application, not for _any_ applications.  I would like to
have a specific version that could be used in a finer manner -
even though the NeXT is quite consistent in it's usage of command-
keys, the very keys that you'd like to change are going to be the
non-standard ones, which means different vendors are using different
keys for them (they aren't required to register, or anything!).
Changing a single app's equivalents via Preferences is a little
cumbersome . . .

With a version that could target single apps, you could make more
of the apps look more similar on your own (I don't like how, for
instance, the command-equiv for "center", as in "center text"
seems to differ between most apps, command-- in some, command-,
in others, etc, etc.)

Later,
--
scott hess                      scott@gac.edu
Independent NeXT Developer	Graduated GAC Undergrad!
<I still speak for nobody>
Note:  I have moved home for a time.  My email address will still be
valid.  Any SnailMail should be redirected, along with phone calls.
At the least, my parents can tell you how to get hold of me, or
forward any mail . . .
Old:	PO 829, GAC, St. Peter, MN  56082	(507) 933-8466
New:	RR#4 Box 227 Pipestone, MN  56164	(507) 825-2788

eps@toaster.SFSU.EDU (Eric P. Scott) (06/04/91)

In article <17707@siva.ntt.JP> mcohen@ac-next2 (Michael Cohen) writes:
>Yeah, thanks; i used bchen's suggestion immediately to
>
>dwrite -g NXCommandKeys "Page Layout..., P"
>
>This globally fixes the annoying ommision in WriteNow and anything else that  
>elided the shortcut.

Unfortunately, WriteNow uses P for View Page.  I can't just set
it back to j (as in previous versions), since that's now used for
Find>Jump to Selection.  I ended up with

	Underline,_
	Hide Graphics,u
	View Page,V
	View Headers/Footers,k
	View Footnotes,l
	Insert Footer,O
	Page Layout...,P

before I was happy.

I left Keep on Same Page as K, since S is better for Save As...

					-=EPS=-