[comp.sys.amiga] DNET/FTERM and GNU-emacs

kasper@iesd.auc.dk (Kasper Osterbye) (03/27/90)

I am using DNET directly with a sun. When I "setenv TERM amiga" everything
works fine! Really fine actually!

What I am wondering is, if any one has set up a configuration for GNU-emacs
on the unix-side so that one can use the amiga function keys and cursor
keys? (noone has touched the mouse in connection with DNet yet?)

Some of the problems I see, is that the function keys sends variable
length characters ended with a "~" character, something that it is not
obvious to me to have emacs handle gracefully.

Am I alone on this one? - redefining the amiga keymap is an option, but
then the programs on the amiga side gets confused. At what time does DNET
read the keymap bindings - I could set up a keyboard that would be set only
when Dnet reads its keyboard...

--Kasper

-- 
Kasper Osterbye                     Internet: kasper@iesd.auc.dk
Institute for electronic systems    UUCP: ...!mcvax!iesd!kasper
Strandvejen 19, 9000 Aalborg
DENMARK. (W) +45 98 13 87 88-285  (H) +45 98 37 30 65

kent@swrinde.nde.swri.edu (Kent D. Polk) (03/29/90)

In article <1990Mar27.153542.2577@iesd.auc.dk> kasper@iesd.auc.dk (Kasper Osterbye) writes:
>I am using DNET directly with a sun. When I "setenv TERM amiga" everything
>works fine! Really fine actually!
>
>What I am wondering is, if any one has set up a configuration for GNU-emacs
>on the unix-side so that one can use the amiga function keys and cursor
>keys? (noone has touched the mouse in connection with DNet yet?)

Haven't tried it with emacs, but my amiga termcap recently posted
handles the arrow keys and the function keys correctly. Funtion keys
just go up to F10 - used to go to F20, but I couldn't find anything
which supported F11-F20, so I dropped them. Also used to support the
'Help' key and several other 'sent by' bindings. Removed them also, but
they can all be put back in very easily. My Amiga termcap was recently
posted to comp.sources.amiga.

Sorry if this sounds like an ad, but...
====================================================================
Kent Polk - Southwest Research Institute - kent@swrinde.nde.swri.edu
        Motto : "Anything worth doing is worth overdoing"
====================================================================

mk59200@korppi.tut.fi (Kolkka Markku Olavi) (03/29/90)

In article <25774@swrinde.nde.swri.edu> kent@swrinde.UUCP (Kent D. Polk) writes:
>
>Haven't tried it with emacs, but my amiga termcap recently posted
>handles the arrow keys and the function keys correctly.

Correctly?? The arrow keys don't work with tcsh, emacs or
anything else. I'm using an 8-bit connection throgh a terminal server
to a SunOS 4.0 machine, and the latest posted version of DNet.

GNU-Emacs doesn't says 'terminal type amiga unknown' and exits,
tcsh just blinks the screen.

--
	Markku Kolkka
	mk59200@tut.fi

andrewt@watnow.waterloo.edu (Andrew Thomas) (03/29/90)

In article <1990Mar27.153542.2577@iesd.auc.dk> kasper@iesd.auc.dk (Kasper Osterbye) writes:
> What I am wondering is, if any one has set up a configuration for GNU-emacs
> on the unix-side so that one can use the amiga function keys and cursor
> keys? (noone has touched the mouse in connection with DNet yet?)
> 
> Some of the problems I see, is that the function keys sends variable
> length characters ended with a "~" character, something that it is not
> obvious to me to have emacs handle gracefully.

GNU emacs will normally handle multi-character keystrokes.  The only
limitation on them is that you cannot remap any character sequence
for which some part of it, starting at the beginning of the sequence,
also has a function.  For example, we have a keyboard here which sends
the characters  ESC F ~  from a function key.  In this case, since
ESC F  also has a meaning, you can't map the function key to anything.
You will get the behaviour of ESC F  plus a tilde inserted after.

The VT220 keyboards here send ESC[227z  and  ESC[22~  kinds of
sequences.  These can be mapped by doing:

(global-unset-key "\e[")
;; VT100 function keys
(global-set-key "\e[A" 'previous-line)
(global-set-key "\e[B" 'next-line)
(global-set-key "\e[D" 'backward-char)
(global-set-key "\e[C" 'forward-char)
;; some SUN console function keys
(global-set-key "\e[32~" 'scroll-up)
(global-set-key "\e[34~" 'scroll-down)
(global-set-key "\e[31~" 'save-buffer)
(global-set-key "\e[33~" 'suspend-emacs)
;; more SUN console keys
(global-unset-key "\eO")
(global-set-key "\eOA" 'previous-line)
(global-set-key "\eOB" 'next-line)
(global-set-key "\eOD" 'backward-char)
(global-set-key "\eOC" 'forward-char)

for example.  What you have to do is global-unset-key any prefixes
to the sequence which might have a meaning, and then simply bind the
longer sequences to emacs commands.  If you want it to be
buffer-local, then use local-unset-key and local-set-key.  Note that
keys can only be bound to interactive commands (those available using
ESC X), so if you write your own, be sure to put (interactive) as the
first line in your defun.

Hope this helps.

--

Andrew Thomas
andrewt@watnow.waterloo.edu	Systems Design Eng.	University of Waterloo
"If a million people do a stupid thing, it's still a stupid thing." - Opus

kent@swrinde.nde.swri.edu (Kent D. Polk) (03/29/90)

In article <12117@etana.tut.fi> mk59200@korppi.tut.fi (Kolkka Markku Olavi) writes:
>In article <25774@swrinde.nde.swri.edu> kent@swrinde.UUCP (Kent D. Polk) writes:
>>
>>Haven't tried it with emacs, but my amiga termcap recently posted
>>handles the arrow keys and the function keys correctly.
>
>Correctly?? The arrow keys don't work with tcsh, emacs or
>anything else. I'm using an 8-bit connection throgh a terminal server
>to a SunOS 4.0 machine, and the latest posted version of DNet.
>
>GNU-Emacs doesn't says 'terminal type amiga unknown' and exits,
>tcsh just blinks the screen.

Do you have it installed correctly? What does 'env' have to say:
Should be something similar to this: (Probably will get trashed in
transmission)

TERMCAP=AA|amiga:co#80:li#49:am:bs:bw:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:LE=
\E[%dD:RI=\E[%dC:SF=\E[%dS:SR=\E[%dT:UP=\E[%dA:ae=\017:al=\E[L:as=\016:bl=\007:bt
=\E[Z:cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:dc=\E[P:dl=\E[M:do=\E[B:ho=\E[H:
ic=\E[@:is=\E[20l:k1=\E0~:k2=\E1~:k3=\E2~:k4=\E3~:k5=\E4~:k6=\E5~:k7=\E6~:k8=\E7~
:k9=\E8~:k0=\E9~:kb=^H:kd=\EB:kl=\ED:kr=\EC:ku=\EA:le=\E[D:mb=\E[7;2m:md=\E[1m:me
=\E[0m:mh=\E[2m:mk=\E[8m:mr=\E[7m:nd=\E[C:nl=\E[B:rs=\Ec:se=\E[0m:sf=\E[S:so=\E[7
m:sr=\E[T:ue=\E[0m:up=\E[A:us=\E[4m:ve=\E[\040p:vi=\E[\060\040p:xn:

(oops, li#49 is li#24 in my released version)

If it is not in your /etc/termcap file than you can put it in <path>/amiga,
insert this alias, and type 'amiga' when you want to activate (or
invoke it from .login, etc.)
 
alias amiga "setenv TERMCAP path/amiga; set term = amiga"

Note that this is for a csh, but it has been used in many other
environments & with various emacs. Also works with things like ELM
and everything else I know of that uses the termcap facility. If you
still can't get it working, email me & we'll see if something can't
be done.

====================================================================
Kent Polk - Southwest Research Institute - kent@swrinde.nde.swri.edu
        Motto : "Anything worth doing is worth overdoing"
====================================================================

rusty@fe2o3.UUCP (Rusty Haddock) (03/30/90)

In article <1990Mar27.153542.2577@iesd.auc.dk> kasper@iesd.auc.dk (Kasper Osterbye) writes:
   >I am using DNET directly with a sun. When I "setenv TERM amiga" everything
   >works fine! Really fine actually!
   >
   >What I am wondering is, if any one has set up a configuration for GNU-emacs
   >on the unix-side so that one can use the amiga function keys and cursor
   >keys? (noone has touched the mouse in connection with DNet yet?)

Here you go folks, not only a termcap file but an amiga.el for your
GNU Emacs lisp/term directory (personal or system).   Note that my
selection for the various function keys may appear weird but you can
change them to whatever functions you'd like them to have.

The two files are separated by a FORMFEED, ^L.

This amiga.el file is running under GNU Emacs version 18.5x
and version 18.4x.

;; keybinding for standard default Amiga ANSI window keys
;; Converted Jeff Peck's "lisp/term/sun.el" for a standard
;;    Amiga ANSI window/keyboard like you'd get using DNet/Fterm.
;;    11/16/88 Rusty Haddock

(defun ignore-key ()
  "interactive version of ignore"
  (interactive)
  (ignore))

(defun remove-indent ()
  "Remove any white space at beginning of line."
  (interactive)
  (beginning-of-line)
  (delete-horizontal-space))

(defun backward-other-window ()
  "The function (other-window) used in the reverse direction."
  (interactive)
  (other-window -1))

(defun cursor-to-top ()
  "Move cursor to top line in window."
  (interactive)
  (move-to-window-line 0))

(defun cursor-to-bottom ()
  "Move cursor to bottom line in window."
  (interactive)
  (move-to-window-line -1))


;;;
;;; handle the Amiga's function keys
;;;
(defvar meta-flag t)		; The USA-0 keymap doesn't possess a true META
				; key so don't try doing CTRL-META-<letter>
				; 'cause it don't go.  Fortunately, things like
				; META-F and such do work.

				; LATE FLASH: Email me for a fully-functioning
				; keymap that emits ALL 8-bit codes using the
				; ALT keys as TRUE meta-keys (8th-bit shifters).
(defvar amiga-meta-esc t
  "*If non-nil, rebind \233 as prefix for Amiga function keys.")

(defvar amiga-map (make-sparse-keymap)
  "*Keymap for \\233 encoded keyboard")

(define-key amiga-map "0~" 'scroll-one-line-up)		; f1
(define-key amiga-map "1~" 'scroll-one-line-down)	; f2
(define-key amiga-map "2~" 'beginning-of-buffer)	; f3
(define-key amiga-map "3~" 'end-of-buffer)		; f4
(define-key amiga-map "4~" 'line-to-top-of-window)	; f5
(define-key amiga-map "5~" 'line-to-bottom-of-window)	; f6
(define-key amiga-map "6~" 'other-window)		; f7
(define-key amiga-map "7~" 'backward-other-window)	; f8
(define-key amiga-map "8~" 'describe-key-briefly)	; f9
(define-key amiga-map "9~" 'undo)			; f10

; Shifted function keys
(define-key amiga-map "10~" 'eval-expression)		; F1
(define-key amiga-map "11~" 'ignore-key)	; F2
(define-key amiga-map "12~" 'ignore-key)	; F3
(define-key amiga-map "13~" 'ignore-key)	; F4
(define-key amiga-map "14~" 'cursor-to-top)		; F5
(define-key amiga-map "15~" 'cursor-to-bottom)		; F6
(define-key amiga-map "16~" 'mail)			; F7
(define-key amiga-map "17~" 'rmail)			; F8
(define-key amiga-map "18~" 'save-buffers-kill-emacs)	; F9
(define-key amiga-map "19~" 'save-buffer)		; F10

; Cursor keys
(define-key amiga-map "A" 'scroll-down)	; up arrow (unshifted)
(define-key amiga-map "B" 'scroll-up)		; down arrow
(define-key amiga-map "C" 'cursor-to-bottom)	; right arrow
(define-key amiga-map "D" 'cursor-to-top)	; left arrow
(define-key amiga-map "T" 'backward-paragraph)	; UP ARROW (shifted)
(define-key amiga-map "S" 'forward-paragraph)	; DOWN ARROW
(define-key amiga-map " @" 'forward-word)	; RIGHT ARROW
(define-key amiga-map " A" 'backward-word)	; LEFT ARROW
(define-key amiga-map "?~" 'help-command)	; Help key
(define-key amiga-map "Z" 'tab-to-tab-stop)	; Shift TAB

; I'm sorry that I don't have those extra keys around the keypad
; that you A500/2000 folks have.  -Rusty-

(if amiga-meta-esc
    (progn
      (define-key esc-map "\033" amiga-map)		; Install amiga-map
      (define-key amiga-map "\033" 'eval-expression)))	; original ESC-ESC
	; Yuck!  I know, I know... triple ESC

;;; Since .emacs gets loaded before this file, a hook is supplied
;;; for you to put your own bindings in.

(defvar amiga-map-hooks nil
  "List of forms to evaluate after setting amiga-map.")

(let ((hooks amiga-map-hooks))
  (while hooks
    (eval (car hooks))
    (setq hooks (cdr hooks))
    ))



#
#	Commodore Amiga ANSI Termcap
#
#	Rusty Haddock
#	April 18, 1989
#
#
Am|dnet|Amiga ANSI for AmigaKermit or DNet:\
	:%1=\E?~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\
	:F1=\E10~:F2=\E11~:F3=\E12~:F4=\E13~:F5=\E14~:\
	:F6=\E15~:F7=\E16~:F8=\E17~:F9=\E18~:FA=\E19~:\
	:LE=\E[%dD:RI=\E[%dC:SF=\E[%dS:SR=\E[%dT:UP=\E[%dA:\
	:ae=^O:al=\E[L:am:as=^N:bs:bw:\
	:cd=\E[J:ce=\E[K:cl=^L:cm=\E[%i%d;%dH:co#77:\
	:dc=\E[P:dl=\E[M:do=\E[B:ei=:ic=\E[@:im=:is=\E[c\E[20l:\
	:k1=\E0~:k2=\E1~:k3=\E2~:k4=\E3~:k5=\E4~:\
	:k6=\E5~:k7=\E6~:k8=\E7~:k9=\E8~:k0=\E9~:\
	:kb=^H:kd=\EB:kl=\ED:kr=\EC:ku=\EA:\
	:l0=F10:l1=F1:l2=F2:l3=F3:l4=F4:\
	:l5=F5:l6=F6:l7=F7:l8=F8:l9=F9:\
	:li#23:ms:nl=\E[B:pt:rs=\Ec:se=\E[31;40;0m:sf=\E[S:so=\E[30;43m:\
	:sr=\E[T:ue=\E[0m:ul:up=\E[A:us=\E[4m:\
	:vb=^G:ve=\E[ p:vi=\E[0 p:xn:

A1|dneta|Amiga ANSI for interlace w/ topaz-11 font:\
	:li#34:tc=Am:

A2|dnetb|Amiga ANSI for interlace w/ pearl 8 font:\
	:li#48:tc=Am:

A3|dnetc|Amiga ANSI for interlace w/ FTerm 8 font:\
	:li#48:co#88:tc=Am:

A4|dnetd|Amiga ANSI for interlace w/ topaz-11 font morerow'd:\
	:li#34:co#80:tc=Am:

A5|dnete|Amiga ANSI for interlace w/ topaz-11 font morerow'd but with 8-pxl title:\
	:li#35:co#80:tc=Am:

A6|dnetf|Amiga ANSI for interlace w/ topaz-8 font morerow'd:\
	:li#48:co#80:tc=Am:

AS|net|AmigaSlip|Amiga ANSI using KA9Q TCP/SLIP:\
	:co#79:li#22:tc=Am:

-- 
Rusty Haddock		o  {uunet,rutgers}!mimsy.umd.edu!fe2o3!rusty
Laurel, Maryland	o  rusty%fe2o3@mimsy.umd.edu
    -=> This .signature protected by Smith & Wesson <=-