



                        edt-vt100-kbd  V1.03



                An edt keypad patch script for Linux



                    EDV-Beratung Kurt Schneider
                       Hans-Vogel-Strasse 137
                           D-90765 Fuerth
                     Tel. +49 / 911 / 79 29 93
                    Fax. +49 / 911 / 79 40 722
             e-mail: kschneid@biologie.uni-erlangen.de

1    Who needs this code?


This code is especially intended for people who work both with keypad
editors (EDT, KED, K52) as they are found on DEC machines and with
Linux.  This code enables you to use your skill learned on the DEC
machines also on the Linux boxes. Anybody who finds vi and emacs good,
but keypad editors better, will be happy with this keyboard remapping.
Furthermore you can use it for patching your keyboard layout in order
to conform to VT100, so that you can run applications that expect VT100
escape codes.



2    Introduction


edt-vt100-kbd is a shell script to map your keyboard to VAX-VMS-EDT
style under Linux.
GNU emacs has a VAX-VMS-EDT emulation mode, that makes it look like the
wellknown EDT keypad editor of VAX (and KED on PDP11, maybe).  One
problem that you will encounter is that this works fine on DEC VT220
and VT320 terminals, but not so on the console. This is because DEC
terminals have a feature to remap the keypad keys whenever emacs starts
up. PCs are missing that so we have to map the keypad keys as needed.



3    What the package includes


You should have got the following files:


          _File_________________Description____________________________

           README              _a very short description of the package
           edt-vt100-1.03.lsm _ a short description of the package
           edt-vt100-kbd.sh   _ the installation script
           edt                 _a script for calling emacs in edt mode
           .emacs.edt          _emacs startup script with edt functionality
           edt-vt100-kbd.tex  _ description of the package (TEX-source)
           edt-vt100-kbd.dvi  _ description of the package (TEX-dvi-file)
           edt-vt100-kbd.ps   _ description of the package (ready to print)
           edt-vt100-kbd.txt  _ description of the package (plain ASCII)



4    Prerequisites


If you want the VT100 functionality, you need:


   - Linux (maybe this piece of code works on other platforms, but I
	haven't tested it).  Should there be any need, please let me know


   - this package (edt-vt100-kbd)


If you want edt functionality, you need additionaly:


   - GNU Emacs


   - some lisp scripts that came with GNU Emacs (e. g. tpu-edt.el)



5    Installation


I've tried to make the installation as easy as possible. Installation
is a four step process:


   1.back up your machine (when have you done it for the last time??)


   2.unpacking the distribution file (supposedly you have done this
	already) ;-)


                                        1

   3.making and installing the new keyboard table. This produces VT100
	keyboard mapping


   4.preparation of the edt scripts


5.1   Unpacking the distribution file


To unpack the distribution file, you should do the following:


   - make a temporary directory (maybe $HOME/tmp)


   - change to this new directory


   - copy your original keytable to this new directory


   - copy the edt-vt100-kbd package to this new directory


   - unzip and untar the package (tar xzvf edt-vt100-kbd-1.03.tar.gz)


   - that's it



5.2   Making and installing the new keyboard table


There is a shell wrapper called edt-vt100-kbd.sh, which does the following:


   - it asks you where your original keytable resides. I strongly
	recommend to use a copy of the original one in case anything
	goes wrong, although edt-vt100-kbd.sh doesn't modify this file


   - it searches the offending key descriptions and modifies them as needed


   - it writes a new table called edt-vt100-kbd.map


   - if you didn't load a keytable up to now, grab one that fits your
	taste and modify this one


You have to be superuser to make these changes:

   - call ./edt-vt100-kbd.sh and answer the question


   - move the new keytable to where the other ones reside (supposedly
	in the directory /var/lib/kbd/keytables). Don't overwrite
	another file


   - this map should be loaded at startup by one of your rc* files,
	/etc/rc, /etc/rc.local or /etc/rc.d/rc.keymap. Have a look
	at these files. If you don't use US-style keyboard
	layout, you should find two lines that read like this:


     echo 'Loading keyboard map "de-lat1-nd.map"...'

     loadkeys /var/lib/kbd/keytables/de-lat1-nd.map


     (or similar). If you find them, make a copy of them, comment the
	original (by prepending a # in front of each line) and change
	the copy to:


     echo 'Loading keyboard map "edt-vt100-kbd.map"...'

     loadkeys /var/lib/kbd/keytables/edt-vt100-kbd.map


     If you use US-style keyboard layout or didn't load a keytable up
	to now, insert these two lines, preferedly at the end of the file.


   - reboot your machine

If you only need VT100 keyboard layout and no edt emulation, you're done
with the installation.



                                        2

5.3   Prepation of the edt scripts


If you need edt emulation, there is another file for you called edt.
It does the following:


   - it starts up emacs in edt-emulation mode



And there is still another file called .emacs.edt, which should be
copied to the home directory of anyone who wants to work with edt.


You have to:


   - copy the file edt to where your executables reside, maybe /usr/local/bin


   - copy .emacs.edt to the home directory of anyone who wants to work
	with edt (don't forget to make these users owner of the file)


   - copy the file $HOME/.emacs to $HOME/.emacs.org. It will be copied
	to $HOME/.emacs if you don't need EDT compatibility



5.4   After the installation: Starting EDT


If you have installed edt-vt100-kbd, you can call it with


$ edt file


instead of


$ emacs file


and have the functionality of EDT as on your VAX.

There is an option that resembles the EDT-call


EDT/OU:FILE1 FILE2


on the VAX. Here you have to input the following line:


edt -o file1 file2


This reads the contents of file2 (the input file), lets you edit the
text, and when you exit edt, the text is saved under the name file1
(the output file). If file1 already existed before, its contents is
moved to file1~. Should you leave edt with quit without writing,
everything is as it was before. I. e. if file1 didn't exist, it doesn't
exist now. If file1 existed before, it exists under its original name
(it is moved back from file1~ to file1). This option doesn't work if
you don't have write or execute permission in the output directory
and it doesn't work if file2 doesn't exist.



6    Deinstallation


Should you ever want to get rid of this package, do the following:

If (and only if) no one wants to use it anymore, then:


   - restore the entries in your startup file /etc/rc, /etc/rc.local
	or in the file called /etc/rc.d/rc.keymap. You've kept a copy
	of the original line, haven't you?


   - should you have loaded no keytable before, remove the lines that
	load the new keytable edt-vt100-kbd.map



                                        3

7    Bugs, Problems and Limitations


I've tested edt-vt100-kbd on Slackware Linux and it worked fine.


   1.Since the PC-keyboards have only three keys on the right side of
	the keypad, I wasn't able to implement DelC and UnDelC (delete
	and undelete character). You could remap it to the Del key,
	but then there is no more Ctrl-Alt-Del. Any suggestions anyone?


   2.You can't use <NL> within search strings, since the search starts
	as soon as you press Return, but this seems to be a limitation
	of emacs. Instead you should use text^V^Jtext to search for an
	embedded <NL> (^V escapes the <NL>).


   3.There is some interference with emacs commands.  I didn't bother
	much, because if anything goes wrong, you can use them to
	leave emacs


   4.A search doesn't start when you press advance or backup but only
	if you hit Enter.  This seems to be a bug in some older
	versions of the edt-emulation of emacs.  Older emulations
	showed this feature, the newer releases (I tested Slackware 1.2.6)
	are o.k.


   5.There is no journal file in case the machine or emacs dies.  It is
	an emacs feature to write a file called #filename#, which contains
	the actual state of the document (well, within some hundred key
	strokes).


   6.I had to remap some function keys (starting with F10) in order to
	provide full keypad functionality. Programs relying on function
	keys starting with F10 wouldn't work correctly with this keymap.
	You have to unload it temporarily.


   7.If you stand within a line and say REVERSE - LINE, the cursor is
	moved to the line before the current one and not to the
	beginning of the actual one. This is a bug. The fix should
	make it into emacs version 19.30. If you have an older one, here is
	a patch from Rob Riepel: there is a function tpu-backward-line
	in both tpu-edt.el and tpu-extras.el.

     The line that must be added is:

     (or (bolp) (>= 0 num) (setq num (- num 1)))

     The context is in tpu-edt.el:


     (defun tpu-backward-line (num)
       "Move to beginning of previous line.
     Prefix argument serves as repeat count."
       (interactive "p")
       (or (bolp) (>= 0 num) (setq num (- num 1)))
       (forward-line (- num)))


     and in tpu-extras.el:


     (defun tpu-backward-line (num)
       "Move to beginning of previous line.
     Prefix argument serves as repeat count."
       (interactive "p")
       (let ((beg (tpu-current-line)))
         (or (bolp) (>= 0 num) (setq num (- num 1)))
         (next-line-internal (- num))
         (tpu-top-check beg num)
         (beginning-of-line)))


     If you make these changes in your copy, be sure to byte-compile
	the changed file so the *.elc files are updated.



                                        4

8    History


V1.00:  The very beginning.  Since I grew up with DEC machines like
	PDP11 and VAX, the keypad editor was the most missing tool
	when I moved from these computers to Unix.  Since there was
	an EDT emulation script for Emacs written by Rob Riepel
	(riepel@networking.stanford.edu), I tried it out and found
	that it worked well on VT220/VT320 terminals, but not so on
	the PC-console.  So I decided to patch the keymapping in
	order to make the EDT emulation work.


V1.01:  What was missing from the first version was the command
	set screen 5:20, which moves the screen up/down when the
	cursor has only a distance of 5 lines from the bottom/top
	of the screen, so that you can see what comes next under/above
	the current line. This is achieved by the line

      (tpu-set-scroll-margins "5" "5")  ;  Set scroll margins.

	in the file $HOME/.emacs.edt, which is copied into place as
	needed. Since edt-emulation is activated from within
	$HOME/.emacs.edt, there is no more need to supply a path to
	the emulation scripts.


V1.02:  From this version on the package is called edt-vt100-kbd to
	stress the VTxxx escape code feature of the code


        - use of /bin/sh instead of /bin/ksh to interpret the scripts

        - the keytables are loaded permanently, decreasing the startup
		time.  Leaving edt doesn't remap the keyboard, so that
		you can work with edt on different virtual consoles at
		the same time without interference

        - since the keytables are loaded permanently, they are remapped
		local so that edt-vt100-kbd runs transparently over the
		network now


V1.03:  Included the -o option to specify a different output file



9    Thanks


I wish to thank:


   - Ken Thompson and Dennis Ritchie for giving us Unix


   - Linus Torvalds for providing us with one of the best operating
	systems in the world


   - Richard Stallman and the staff from the Free Software Foundation
	for doing excellent work


   - Rob Riepel (riepel@networking.stanford.edu), for making emacs work
	like EDT does. I would never have been able to write this code.
	His suggestions to edt-vt100-kbd are appreciated


   - Digital Equipment Corporation for supplying us with hard- and
	software in a quality that many other suppliers can only dream of



                                        5

A     Disclaimer


This software is put into the GPL. There is no guarantee whatsoever that
it does anything useful.
This is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either this version, or (at your option) any later
version.
This code is distributed in the hope that it will be useful, but without
any warranty; without even the implied warranty of merchantability or
fitness for a particular purpose. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with GNU Emacs; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
I would be glad to here from you if this piece of code was of any help
for you. Suggestions and bug reports are welcome. Please email to:


                      kschneid@biologie.uni-erlangen.de



B    Keypad Layout


I've only implemented the keypad proper (i. e. numerical keys, PF1,
PF2, Enter ...):. Their layout is as follows:

                     ________________________________________
                     |   Gold   | HELP   | FndNxt |   Del L |
                     |    key   | E-Help |  Find  | Undel_L |
                     |----------|--------|--------|---------|
                     |   Page   | Sect   | Append |         |
                     |    Do    |  Fill  | Replace|  Del W  |
                     |----------|--------|--------| Undel W |
                     |  Forward | Reverse| Remove |         |
                     |  Bottom  |  Top   | Insert |         |
                     |----------|--------|--------|---------|
                     |   Word   | EOL    |  Char  |         |
                     | ChngCas  |Del_EOL | SpecIns|  Enter  |
                     |----------|--------|--------|  Subs   |
                     |        Line       | Select |         |
                     |      Open_Line    |  Reset |         |
                     ----------------------------------------


Please see your genuine EDT documentation for further details.



                                        6
