[comp.sys.apollo] Mods to GNU Emacs 18.48 for Apollo SR9.6

broman@cod.NOSC.MIL (Vincent P. Broman) (11/19/87)

<>

I append my modifications to GNU Emacs 18.48, as implemented by
Leonard Zubkoff @Lucid using Apollo's GPR graphics calls.  Praises go to
Zubkoff for a high-class implementation of the screen driver.
My changes make the entire apollo keyboard useable under Emacs,
and bind functions to the keypad keys which are analogous to those
supplied by the Display Manager.  I also removed certain key-binding
decisions from the C code in order to set them in Elisp code.

There was one bug in the supplied screen driver which I didn't even try to
track down.  When the screen is a certain width, the character cursor becomes
invisible when it sits in column 1.  The workaround is just to change the
width of the screen slightly.

One item on my wish list:  someone make the mouse cursor invisible
when it has been motionless for N seconds, till it's moved again.

Here follows a diff and a replacement file:
--------cut here for diff of src/apollo.c ------------------------
*** apollo.c.org	Fri Nov 13 15:14:37 1987
--- apollo.c	Wed Nov 18 10:15:00 1987
***************
*** 46,49
  #define Ctrl(Character)	    ((Character) & 0x1F)
  #define Meta(Character)	    ((Character) | 0x80)
  
  #define MouseCursorHeight   16

--- 46,50 -----
  #define Ctrl(Character)	    ((Character) & 0x1F)
  #define Meta(Character)	    ((Character) | 0x80)
+ #define SPECIALKEYINTRO     Meta('*')     /* prefixes Special key strokes */
  
  #define MouseCursorHeight   16
***************
*** 128,133
  
  
! hidden enum {Normal, Ignore, Disable, MetaOn, MetaOff, ScrollUp,
! 	     ScrollDn, Again, Save, DMCopy, DMCut, DMPaste}
  	KeyClass[256];
  

--- 129,133 -----
  
  
! hidden enum {Normal, Disable, MetaOn, MetaOff, Special}
  	KeyClass[256];
  
***************
*** 137,142
  	MetaOnShiftKey =    KBD_$L9S;
  	MetaOffKey =	    KBD_$L9U;
- 	KeyMap[256],
- 	MetaMap[256];
  
  

--- 137,140 -----
  	MetaOnShiftKey =    KBD_$L9S;
  	MetaOffKey =	    KBD_$L9U;
  
  
***************
*** 140,151
  	MetaMap[256];
  
- 
- hidden procedure AssignKeystroke(Keystroke,Character,MetaCharacter)
- 	unsigned char Keystroke, Character;
-     begin
- 	KeyClass[Keystroke] = Normal;
- 	KeyMap[Keystroke] = Character;
- 	MetaMap[Keystroke] = MetaCharacter;
-     end
  
  hidden procedure InitKeyboardMapping()

--- 138,141 -----
  	MetaOffKey =	    KBD_$L9U;
  
  
  hidden procedure InitKeyboardMapping()
***************
*** 154,159
  	status_$t Status;
  	short i;
! 	for (i=0; i<128; i++) do AssignKeystroke(i,i,Meta(i));
! 	for (i=128; i<255; i++) do KeyClass[i] = Disable;
  	KeyClass[Ctrl('G')] = Disable;
  	AssignKeystroke(KBD_$BS,0x7F,Meta(0x7F));

--- 144,159 -----
  	status_$t Status;
  	short i;
! 	for (i=0; i<128; i++) do KeyClass[i] = Normal;
! 	for (i=128; i<256; i++) do KeyClass[i] = Disable;
! 
!         /* interested only in downstrokes, not upstrokes */
!         for (i=0x81; i<=0x99; i++) do KeyClass[i] = Special;
!         for (i=0xb5; i<=0xb8; i++) do KeyClass[i] = Special;
!         for (i=0xba; i<=0xbb; i++) do KeyClass[i] = Special;
!         for (i=0xbe; i<=0xdf; i++) do KeyClass[i] = Special;
!         for (i=0xe8; i<=0xe9; i++) do KeyClass[i] = Special;
!         for (i=0xeb; i<=0xf7; i++) do KeyClass[i] = Special;
!         for (i=0xfc; i<=0xfd; i++) do KeyClass[i] = Special;
! 
  	KeyClass[Ctrl('G')] = Disable;
  	KeyClass[MetaOnKey] = MetaOn;
***************
*** 157,175
  	for (i=128; i<255; i++) do KeyClass[i] = Disable;
  	KeyClass[Ctrl('G')] = Disable;
- 	AssignKeystroke(KBD_$BS,0x7F,Meta(0x7F));
- 	AssignKeystroke(KBD_$CR,Ctrl('M'),Meta(Ctrl('M')));
- 	AssignKeystroke(KBD_$TAB,Ctrl('I'),Meta(Ctrl('I')));
- 	AssignKeystroke(KBD_$STAB,Ctrl('I'),Meta(Ctrl('I')));
- 	AssignKeystroke(KBD_$CTAB,Ctrl('I'),Meta(Ctrl('I')));
- 	AssignKeystroke(KBD_$LINE_DEL,Ctrl('K'),Ctrl('K'));
- 	AssignKeystroke(KBD_$CHAR_DEL,Ctrl('D'),Ctrl('D'));
- 	AssignKeystroke(KBD_$UP_ARROW,Ctrl('P'),Ctrl('P'));
- 	AssignKeystroke(KBD_$LEFT_ARROW,Ctrl('B'),Ctrl('B'));
- 	AssignKeystroke(KBD_$RIGHT_ARROW,Ctrl('F'),Ctrl('F'));
- 	AssignKeystroke(KBD_$DOWN_ARROW,Ctrl('N'),Ctrl('N'));
- 	AssignKeystroke(KBD_$L_BAR_ARROW,Ctrl('A'),Ctrl('A'));
- 	AssignKeystroke(KBD_$R_BAR_ARROW,Ctrl('E'),Ctrl('E'));
- 	KeyClass[KBD_$L_BOX_ARROW] = Ignore;
- 	KeyClass[KBD_$R_BOX_ARROW] = Ignore;
  	KeyClass[MetaOnKey] = MetaOn;
  	KeyClass[MetaOnShiftKey] = MetaOn;

--- 157,160 -----
  
  	KeyClass[Ctrl('G')] = Disable;
  	KeyClass[MetaOnKey] = MetaOn;
  	KeyClass[MetaOnShiftKey] = MetaOn;
***************
*** 175,204
  	KeyClass[MetaOnShiftKey] = MetaOn;
  	KeyClass[MetaOffKey] = MetaOff;
! 	KeyClass[KBD_$L8S] = ScrollUp;
! 	KeyClass[KBD_$LES] = ScrollDn;
! 	if (Keyboard == 1) then
! 	    begin
! 		AssignKeystroke(KBD_$DOWN_BOX_ARROW1,Ctrl('V'),Ctrl('V'));
! 		AssignKeystroke(KBD_$UP_BOX_ARROW1,Meta('V'),Meta('V'));
! 		AssignKeystroke(KBD_$LFS,Meta('<'),Meta('<'));
! 		AssignKeystroke(KBD_$LDS,Meta('>'),Meta('>'));
! 		AssignKeystroke(KBD_$MARK1,Ctrl('@'),Ctrl('@'));
! 	    end
! 	else
! 	    begin
! 		AssignKeystroke(KBD_$DOWN_BOX_ARROW2,Ctrl('V'),Ctrl('V'));
! 		AssignKeystroke(KBD_$UP_BOX_ARROW2,Meta('V'),Meta('V'));
! 		AssignKeystroke(KBD_$LDS,Meta('<'),Meta('<'));
! 		AssignKeystroke(KBD_$LFS,Meta('>'),Meta('>'));
! 		AssignKeystroke(KBD_$MARK2,Ctrl('@'),Ctrl('@'));
! 		KeyClass[KBD_$COPY] = DMCopy;
! 		KeyClass[KBD_$CUT] = DMCut;
! 		KeyClass[KBD_$PASTE] = DMPaste;
! 		AssignKeystroke(KBD_$UNDO,Ctrl('_'),Ctrl('_'));
! 		AssignKeystroke(KBD_$LAS,Meta('B'),Meta('B'));
! 		AssignKeystroke(KBD_$LCS,Meta('F'),Meta('F'));
! 		KeyClass[KBD_$AGAIN] = Again;
! 		KeyClass[KBD_$SAVE] = Save;
! 	    end;
  	lib_$init_set(KeySet,256);
  	for (i=0; i<256; i++) do

--- 160,164 -----
  	KeyClass[MetaOnShiftKey] = MetaOn;
  	KeyClass[MetaOffKey] = MetaOff;
! 
  	lib_$init_set(KeySet,256);
  	for (i=0; i<256; i++) do
***************
*** 748,759
  	status_$t *StatusP;
      begin
- 	static char ScrollUpString[] = { Meta('1'), Meta('V') };
- 	static char ScrollDnString[] = { Meta('1'), Ctrl('V') };
- 	static char AgainString[] = { Ctrl('@'), Ctrl('E'),
- 				      Meta('W'), Meta('>'), Ctrl('Y') };
- 	static char SaveString[] = { Ctrl('X'), Ctrl('S') };
- 	static char DMCopyString[] = { Ctrl('C'), 'R' };
- 	static char DMCutString[] = { Ctrl('C'), 'W' };
- 	static char DMPasteString[] = { Ctrl('C'), 'Y' };
  	static char InputBuffer[10];
  	static long InputBufferLength;

--- 708,711 -----
  	status_$t *StatusP;
      begin
  	static char InputBuffer[10];
  	static long InputBufferLength;
***************
*** 793,798
  			begin
  		    case Normal:    if (MetaDepressed) then
! 					InputBuffer[0] = MetaMap[EventData[0]];
! 				    else InputBuffer[0] = KeyMap[EventData[0]];
  				    InputBufferLength = 1;
  				    break;

--- 745,751 -----
  			begin
  		    case Normal:    if (MetaDepressed) then
! 					InputBuffer[0] = Meta(EventData[0]);
! 				    else
!                                         InputBuffer[0] = EventData[0];
  				    InputBufferLength = 1;
  				    break;
***************
*** 801,832
  		    case MetaOff:   MetaDepressed = false;
  				    break;
! 		    case ScrollUp:  bcopy(ScrollUpString,InputBuffer,
! 					  sizeof(ScrollUpString));
! 				    InputBufferLength = sizeof(ScrollUpString);
! 				    break;
! 		    case ScrollDn:  bcopy(ScrollDnString,InputBuffer,
! 					  sizeof(ScrollDnString));
! 				    InputBufferLength = sizeof(ScrollDnString);
! 				    break;
! 		    case Again:     bcopy(AgainString,InputBuffer,
! 					  sizeof(AgainString));
! 				    InputBufferLength = sizeof(AgainString);
! 				    break;
! 		    case Save:      bcopy(SaveString,InputBuffer,
! 					  sizeof(SaveString));
! 				    InputBufferLength = sizeof(SaveString);
! 				    break;
! 		    case DMCopy:    bcopy(DMCopyString,InputBuffer,
! 					  sizeof(DMCopyString));
! 				    InputBufferLength = sizeof(DMCopyString);
! 				    break;
! 		    case DMCut:	    bcopy(DMCutString,InputBuffer,
! 					  sizeof(DMCutString));
! 				    InputBufferLength = sizeof(DMCutString);
! 				    break;
! 		    case DMPaste:   bcopy(DMPasteString,InputBuffer,
! 					  sizeof(DMPasteString));
! 				    InputBufferLength = sizeof(DMPasteString);
! 				    break;
  			end
  

--- 754,786 -----
  		    case MetaOff:   MetaDepressed = false;
  				    break;
! 
!                     /* BackSpace and CarriageReturn ignore Meta */
!                     case Special:   if (EventData[0] == KBD_$BS) then
!                                       begin
!                                         InputBuffer[0] = 0x7F; /* DEL */
!                                         InputBufferLength = 1;
!                                       end
!                                     else if (EventData[0] == KBD_$CR) then
!                                       begin
!                                         InputBuffer[0] = Ctrl('M');
!                                         InputBufferLength = 1;
!                                       end
!                                     else if (EventData[0] == KBD_$TAB
!                                           || EventData[0] == KBD_$STAB
!                                           || EventData[0] == KBD_$CTAB) then
!                                       begin
!                                         InputBuffer[0] = MetaDepressed?
!                                                            Meta(Ctrl('I')):
!                                                            Ctrl('I');
!                                         InputBufferLength = 1;
!                                       end
!                                     else
!                                       begin
!                                         InputBuffer[0] = SPECIALKEYINTRO;
!                                         InputBuffer[1] = EventData[0] - 0x80;
!                                         /* must not collide with mouse event */
!                                         InputBufferLength = 2;
!                                       end
!                                     break;
  			end
  
***************
*** 844,848
  			MouseCursorPosition = EventPosition;
  			ReleaseDisplay(CursorsInteract);
! 			InputBuffer[0] = Ctrl('C');
  			InputBuffer[1] = EventData[0];
  			InputBuffer[2] = (MouseCursorPosition.x_coord

--- 798,804 -----
  			MouseCursorPosition = EventPosition;
  			ReleaseDisplay(CursorsInteract);
! 
!                 /* gives SPECIALKEYINTRO followed by [abcd1234] and <x><y> */
! 			InputBuffer[0] = SPECIALKEYINTRO;
  			InputBuffer[1] = EventData[0];
                          if (EventData[0] < 'a') then
***************
*** 846,849
  			InputBuffer[0] = Ctrl('C');
  			InputBuffer[1] = EventData[0];
  			InputBuffer[2] = (MouseCursorPosition.x_coord
  					  +MouseCursorXOrigin)/FontWidth;

--- 802,809 -----
  			InputBuffer[0] = SPECIALKEYINTRO;
  			InputBuffer[1] = EventData[0];
+                         if (EventData[0] < 'a') then
+                             InputBuffer[1] -= ('A' - '1');
+                             /* so as not to collide with Special keystrokes */
+ 
  			InputBuffer[2] = (MouseCursorPosition.x_coord
  					  +MouseCursorXOrigin)/FontWidth;
***************
*** 1244,1247
  
  
  
  

--- 1204,1214 -----
  
  
+ DEFUN ("apollo-keyboard-type", Fapollo_keyboard_type, Sapollo_keyboard_type,
+   0, 0, 0,
+   "Return as integer the keyboard type attached to this apollo console.")
+   ()
+ {
+   return Keyboard;
+ }
  
  
***************
*** 1246,1249
  
  
  visible procedure syms_of_apollo()
      begin

--- 1213,1217 -----
  
  
+ 
  visible procedure syms_of_apollo()
      begin
***************
*** 1252,1254
  	defsubr(&Sselect_APOLLO_protection_style);
  	defsubr(&Sexecute_DM_command);
      end

--- 1220,1223 -----
  	defsubr(&Sselect_APOLLO_protection_style);
  	defsubr(&Sexecute_DM_command);
+         defsubr(&Sapollo_keyboard_type);
      end
---------end diff of src/apollo.c ---------------------------
---------cut here for new lisp/term/apollo.el ---------------
;;; GNU/Apollo DM interface - allows GNU emacs to be treated just like
;;; another apollo window in the way the keypad editing keys work.
;;; Requires the GNU is running with Zubkoff's GPR interface (will NOT work
;;; if GNU is running under VT100)
;;;
;;;    J.W. Peterson, University of Utah
;;;
;;; Mouse support added on 15-Jan-87 by Leonard N. Zubkoff, LUCID Incorporated:
;;;
;;; The APOLLO mouse supports up to four buttons whose transitions are reported
;;; as gpr_$buttons events with event data "a".."d" for DOWN transitions and
;;; "A".."D" for UP transitions.  In order to use the mouse, the function
;;; enable-APOLLO-mouse-buttons must be called to enable one or more of the
;;; buttons.  It takes a string argument and searches it for "a".."d" and
;;; "A".."D", enabling the corresponding button transition.  Button transitions
;;; are reported to EMACS as M-* <button-transition-letter> <x> <y>,
;;; where button-transition-letter is one of [abcd1234], the up transitions
;;; being translated to digits because of a collision with fn-keys f2-f5.
;;
;;; More complete key bindings for keypads by:
;;;        Vincent Broman, broman@nosc.mil, 17 November 1987.
;;; Down transitions for keypad keys become M-* followed by the keycode
;;; listed in /sys/ins/kbd.ins.* less 128.  Up transitions not reported.
;;


(defconst *paste_buffer_link* "/sys/node_data/paste_buffers/"
  "This string must contain a filename that points to `node_data/paste_buffers.
The above definition is adequate for disked nodes.  Because GNU (and indeed,
most Unix programs) refuse to deal with a filename containing a leading
backquote, it easier just make a link to it with a reasonable name.  To make
such a link, give the /com/sh command:
     crl //a/utah/gnu/paste_data_link `node_data/paste_buffers
(where the first filename where you decide the link should live).
")

(defun write-apollo-paste-buffer (bufname)
  "Write the region between dot and mark to a named DM paste buffer"
  (interactive "s")
  (let* ((paste-fname
	  (concat *paste_buffer_link* bufname)))
    (write-region (mark) (point) paste-fname nil 1)))

(defun DM-copy ()
  "Copy region between point and mark to the default DM paste buffer"
  (interactive)
  (write-apollo-paste-buffer "default.txt")
  (message "Copied"))

(defun read-apollo-paste-buffer (bufname)
  "Read the named DM paste buffer into the text after point.
Set mark after the inserted text."
  (interactive "s")
  (let* ((paste-fname
	  (concat *paste_buffer_link* bufname)))
    (insert-file paste-fname)))

(defun DM-paste ()
  "Copy region between point and mark to the default DM paste buffer"
  (interactive)
  (read-apollo-paste-buffer "default.txt")
  (message "Pasted and Mark set"))

(defun cut-apollo-paste-buffer (bufname)
  "Cut out the text between point and mark into the named DM paste buffer"
  (interactive "s")
  (let* ((paste-fname
	  (concat *paste_buffer_link* bufname)))
    (write-region (mark) (point) paste-fname nil 1)
    (kill-region)
    ))

(defun DM-cut ()
  "Copy region between point and mark to the default DM paste buffer"
  (interactive)
  (cut-apollo-paste-buffer "default.txt")
  (message "Cut"))

(defun DM-move-window ()
  "Move the Emacs window using rubberbanding."
  (interactive)
  (execute-DM-command "wme"))

(defun DM-again ()
  "Copy tail of line to end of buffer.  Useful in shell-mode."
  (interactive)
  (let ((DM-again-start (point))
	(apollo-paste-buffer (concat *paste_buffer_link* "default.txt")))
    (end-of-line)
    (write-region DM-again-start (point) apollo-paste-buffer nil 1)
    (end-of-buffer)
    (insert-file apollo-paste-buffer)
    (message "Again")
    (exchange-point-and-mark)))

(defun DM-exit ()
  "Save this buffer, if modified, and kill the buffer."
  (interactive)
  (save-buffer)
  (kill-buffer (current-buffer)))

(defun DM-abort ()
  "Kill the current buffer; consult user if buffer was modified and not saved."
  (interactive)
  (kill-buffer (current-buffer)))

(defun delete-whole-line ()
  "Kill the line containing point.  Try to retain column cursor is on."
  (interactive)
  (let ((dwl-old-column (current-column)))
    (beginning-of-line)
    (kill-line 1)
    (move-to-column dwl-old-column)))

(defun scroll-halfway-down ()
  "Scroll the text displayed in the buffer halfway down the window.
This pans the window upwards, if you identify with the window instead."
  (interactive)
  (scroll-down (/ (window-height) 2)))

(defun scroll-halfway-up ()
  "Scroll the text displayed in the buffer halfway up the window.
This pans the window downwards, if you identify with the window instead."
  (interactive)
  (scroll-up (/ (window-height) 2)))

(defun scroll-one-down ()
  "Scroll the text down one line in the window."
  (interactive)
  (scroll-down 1))

(defun scroll-one-up ()
  "Scroll the text up one line in the window."
  (interactive)
  (scroll-up 1))

(defun to-window-top ()
  "Move cursor to the first line in the window, in the same column."
  (interactive)
  (let ((twt-cur-col (current-column)))
    (move-to-window-line 0)
    (move-to-column twt-cur-col)))

(defun to-window-bottom ()
  "Move cursor to the last text line in the window, in the same column."
  (interactive)
  (let ((twb-cur-col (current-column)))
    (move-to-window-line (- (window-height) 2))
    (move-to-column twb-cur-col)))

;;;
;;; These keys correspond to the definitions made by the keypads
;;;
;;; first those available on all keypads, then those depending on type.
;;;
(global-set-key "\e*\C-b" 'delete-whole-line)   ; line_del
(global-set-key "\e*\C-c" 'delete-char)         ; char_del
(global-set-key "\e*\C-e" 'execute-DM-command)  ; cmd
(global-set-key "\e*\C-h" 'previous-line)       ; up_arrow
(global-set-key "\e*\C-j" 'backward-char)       ; left_arrow
(global-set-key "\e*\C-k" 'other-window)        ; next_wndw
(global-set-key "\e*\C-l" 'forward-char)        ; right_arrow
(global-set-key "\e*\C-n" 'next-line)           ; down_arrow
(global-set-key "\e*\C-d" 'beginning-of-line)   ; l_bar_arrow
(global-set-key "\e*\C-f" 'end-of-line)         ; r_bar_arrow
(global-set-key "\e*\C-g" nil)                  ; l_box_arrow unused
(global-set-key "\e*\C-i" nil)                  ; r_box_arrow normally META
(global-set-key "\e*\C-r" 'find-file-read-only) ; read
(global-set-key "\e*\C-s" 'find-file)           ; edit

(if (and (fboundp 'apollo-keyboard-type) (equal 1 (apollo-keyboard-type)))
  (progn
    (global-set-key "\e*\C-m" 'scroll-halfway-up)     ; down_box_arrow1
    (global-set-key "\e*\C-o" 'scroll-halfway-down)   ; up_box_arrow1
    (global-set-key "\e*\C-a" 'overwrite-mode)        ; ins_mode1
    (global-set-key "\e*\C-p" 'set-mark-command)      ; mark1
    (global-set-key "\e*\C-q" 'shell)                 ; shell1
    (global-set-key "\e*\C-t" 'previous-line))        ; hold1
  (progn
    (global-set-key "\e*\C-o" 'scroll-halfway-up)     ; down_box_arrow2
    (global-set-key "\e*\C-m" 'scroll-halfway-down)   ; up_box_arrow2
    (global-set-key "\e*I" 'overwrite-mode)           ; ins_mode2
    (global-set-key "\e*h" 'DM-copy)                  ; copy
    (global-set-key "\e*l" 'DM-cut)                   ; cut
    (global-set-key "\e*i" 'DM-paste)                 ; paste
    (global-set-key "\e*m" 'advertised-undo)          ; undo
    (global-set-key "\e*\C-a" 'set-mark-command)      ; mark2
    (global-set-key "\e*M" 'shell)                    ; shell
    (global-set-key "\e*j" 'enlarge-window)           ; grow
    (global-set-key "\e*n" 'DM-move-window)           ; move
    (global-set-key "\e*\C-p" 'switch-to-buffer)      ; pop
    (global-set-key "\e*\C-q" 'DM-again)              ; again
    (global-set-key "\e*\C-t" 'DM-exit)               ; exit
    (global-set-key "\e*k" 'previous-line)            ; hold2
    (global-set-key "\e*7" 'save-buffer)              ; save
    (global-set-key "\e*8" 'DM-abort)                 ; abort
    (global-set-key "\e*0" 'describe-function)        ; help
    ))

; (global-set-key "\e*:" nil)              ;f0
; (global-set-key "\e*@" nil)              ;f1
; (global-set-key "\e*A" nil)              ;f2
; (global-set-key "\e*B" nil)              ;f3
; (global-set-key "\e*C" nil)              ;f4
; (global-set-key "\e*D" nil)              ;f5
; (global-set-key "\e*E" nil)              ;f6
; (global-set-key "\e*F" nil)              ;f7
; (global-set-key "\e*G" nil)              ;f8
; (global-set-key "\e*;" nil)              ;f9

; (global-set-key "\e*>" nil)              ;F0
; (global-set-key "\e*P" nil)              ;F1
; (global-set-key "\e*Q" nil)              ;F2
; (global-set-key "\e*R" nil)              ;F3
; (global-set-key "\e*S" nil)              ;F4
; (global-set-key "\e*T" nil)              ;F5
; (global-set-key "\e*U" nil)              ;F6
; (global-set-key "\e*V" nil)              ;F7
; (global-set-key "\e*W" nil)              ;F8
; (global-set-key "\e*?" nil)              ;F9

; (global-set-key "\e*|" nil)              ;^f0
; (global-set-key "\e*p" nil)              ;^f1
; (global-set-key "\e*q" nil)              ;^f2
; (global-set-key "\e*r" nil)              ;^f3
; (global-set-key "\e*s" nil)              ;^f4
; (global-set-key "\e*t" nil)              ;^f5
; (global-set-key "\e*u" nil)              ;^f6
; (global-set-key "\e*v" nil)              ;^f7
; (global-set-key "\e*w" nil)              ;^f8
; (global-set-key "\e*}" nil)              ;^f9

;; These bindings differ from the defaults installed by apollo in the DM,
;; in that the shifted keys are more analogous to the unshifted ones.
;; The box_arrow keys move the window and
;; all plain arrow keys move the cursor.

  (global-set-key "\e*L" 'beginning-of-buffer) ; shift l_bar_arrow
  (global-set-key "\e*N" 'end-of-buffer)   ; shift r_bar_arrow
; (global-set-key "\e*O" nil)              ; shift l_box_arrow
; (global-set-key "\e*Y" nil)              ; shift r_box_arrow
  (global-set-key "\e*]" 'scroll-one-down) ; shift up_box_arrow2
  (global-set-key "\e*_" 'scroll-one-up)   ; shift down_box_arrow2
  (global-set-key "\e*X" 'to-window-top)   ; shift up_arrow
  (global-set-key "\e*Z" 'backward-word)   ; shift left_arrow
  (global-set-key "\e*\\" 'forward-word)   ; shift right_arrow
  (global-set-key "\e*^" 'to-window-bottom); shift down_arrow
  (global-set-key "\e*[" 'delete-window)   ; shift next_win
  (global-set-key "\e*H" 'suspend-emacs)   ; shift pop


;;; Setup the Left mouse button to move point to the mouse position.

(defun apollo-mouse-move-point ()
  "Move point to the position of the mouse cursor.
If already at point (e.g. when double-clicking) set mark."
  (interactive)
  (let* ((x (read-char))
	 (y (read-char))
	 (edges (window-edges))
	 (window nil))
    (while (and (not (eq window (selected-window)))
		(or (<  y (nth 1 edges))
		    (>= y (nth 3 edges))
		    (<  x (nth 0 edges))
		    (>= x (nth 2 edges))))
      (setq window (next-window window t))
      (setq edges (window-edges window)))
    (if window (select-window window))
    (let ((ammp-old-point (point)))
      (move-to-window-line (- y (nth 1 edges)))
      (move-to-column (- x (nth 0 edges)))
      (if (equal ammp-old-point (point)) (push-mark)))))


(defun apollo-mouse-cut ()
  "Move point to mouse position and kill region."
  (interactive)
  (apollo-mouse-move-point)
  (kill-region (mark) (point)))

(defun apollo-mouse-paste ()
  "Move point to mouse position and yank there."
  (interactive)
  (apollo-mouse-move-point)
  (yank))


(defun apollo-mouse-get-name (amff-start-name amff-end-name)
  "Return as string the file name in the buffer between these points.
Ignores a '*' or '@' appended in ls -F output."
  (let* ((amfn-string (buffer-substring amff-start-name amff-end-name))
	 (amfn-end (substring amfn-string -1)))
    (if (or (string-equal "*" amfn-end)
	    (string-equal "@" amfn-end))
	(substring amfn-string 0 -1)
      amfn-string)))

(defun apollo-mouse-find-file ()
  "Find the file in another window whose name the mouse cursor points at."
  (interactive)
  (let ((amff-file-name nil))
    (save-excursion
      (apollo-mouse-move-point)
      (skip-chars-backward "!#-%*-:=?-{}~")     ; most printable chars
      (let ((amff-start-name (point)))
	(skip-chars-forward "!#-%*-:=?-{}~")
	(setq amff-file-name (apollo-mouse-get-name amff-start-name (point)))))
    (find-file-other-window amff-file-name)))


(global-set-key "\e*a" 'apollo-mouse-move-point)             ; M1 Down
(global-set-key "\e*b" 'apollo-mouse-cut)                    ; M2 Down
(global-set-key "\e*2" 'apollo-mouse-paste)                  ; M2 Up
;; since Up and Down must occur in pairs, this binding is useful
;; mainly for copying and moving, not cutting alone nor pasting alone.
(global-set-key "\e*c" 'apollo-mouse-find-file)              ; M3 Down

(if (fboundp 'enable-APOLLO-mouse-buttons)
    (enable-APOLLO-mouse-buttons "abBc"))
-------------end lisp/term/apollo.el ------------------------------

Vincent Broman,  code 632, Naval Ocean Systems Center, San Diego, CA 92152, USA
Phone: +1 619 225 2365    Internet: broman@nosc.mil   Uucp: sdcsvax!nosc!broman