🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #100007

Function Keys

#100007
From: meissner
Date: Fri, 02 Mar 1990 21:22
296 lines
11651 bytes
| 	I am having a hell of a time binding the function keys
| (f1-f12, l0-l10, and r1-r15) on my Sparcstation 1.  Can someone who
| has done this give me a clue?

Here are exerpts from my .emacs file (the sun stuff hasn't been used
in about 6 months):

(defvar terminal-type     (getenv "TERM") "Terminal type.")

(defvar terminal-sun      nil "True if the terminal is a sun terminal.")
(defvar terminal-suntools nil "True if running under suntools.")
(defvar terminal-x        nil "True if running under X windows.")
(defvar terminal-epoch    nil "True if running under epoch [X windows].")

(defun mrm-extra-sun-keys ()
  "Define extra sun function keys."

  (interactive)

  (if (not (boundp 'suntool-map))
      (defvar suntool-map (make-sparse-keymap)
	"*Keymap for Emacstool bindings."))

	; Rectangle support without emacstool
  (define-key sun-raw-map "208z" 'kill-rectangle)		; R1
  (define-key sun-raw-map "209z" 'yank-rectangle)		; R2
  (define-key sun-raw-map "210z" 'open-rectangle)		; R3

	; Rectangle support with emacstool
  (define-key suntool-map "ar" 'kill-rectangle)			; R1
  (define-key suntool-map "br" 'yank-rectangle)			; R2
  (define-key suntool-map "cr" 'open-rectangle)			; R3

	; Mark support without emacstool
  (define-key sun-raw-map "211z" 'mark-beginning-of-buffer)	; R4
  (define-key sun-raw-map "212z" 'mark-whole-buffer)		; R5
  (define-key sun-raw-map "213z" 'mark-end-of-buffer)		; R6

	; Mark support with emacstool
  (define-key suntool-map "dr" 'mark-beginning-of-buffer)	; R4
  (define-key suntool-map "er" 'mark-whole-buffer)		; R5
  (define-key suntool-map "fr" 'mark-end-of-buffer)		; R6

	; Replacement for scrolling commands
  (define-key sun-raw-map "216z" 'sip-scroll-down-in-place)	; R9
  (define-key suntool-map "ir"   'sip-scroll-down-in-place)	; R9

  (define-key sun-raw-map "222z" 'sip-scroll-up-in-place)	; R15
  (define-key suntool-map "or"   'sip-scroll-up-in-place)	; R15

	; 'Home' key
  (define-key sun-raw-map "218z" 'beginning-of-line)		; R18
  (define-key suntool-map "kr"   'beginning-of-line)		; R18

  	; Top keys with emacstool, with xterm, and bare
  (define-key sun-raw-map "224z" 'compare-windows)		; T1
  (define-key sun-raw-map "11~"  'compare-windows)		; T1
  (define-key suntool-map "at"   'compare-windows)		; T1

  (define-key sun-raw-map "225z" 'goto-line)			; T2
  (define-key sun-raw-map "12~"  'goto-line)			; T2
  (define-key suntool-map "bt"   'goto-line)			; T2

  (define-key sun-raw-map "226z" 'goto-char)			; T3
  (define-key sun-raw-map "13~"  'goto-char)			; T3
  (define-key suntool-map "ct"   'goto-char)			; T3

  (define-key sun-raw-map "227z" 'buffer-menu)			; T4
  (define-key sun-raw-map "14~"  'buffer-menu)			; T4
  (define-key suntool-map "dt"   'buffer-menu)			; T4

  (define-key sun-raw-map "228z" 'vm)				; T5
  (define-key sun-raw-map "15~"  'vm)				; T5
  (define-key suntool-map "et"   'vm)				; T5

  (define-key sun-raw-map "229z" 'shrink-window)		; T6
  (define-key sun-raw-map "16~"  'shrink-window)		; T6
  (define-key suntool-map "ft"   'shrink-window)		; T6

  (define-key sun-raw-map "230z" 'enlarge-window)		; T7
  (define-key sun-raw-map "17~"  'enlarge-window)		; T7
  (define-key suntool-map "gt"   'enlarge-window)		; T7

  (define-key sun-raw-map "231z" 'compile)			; T8
  (define-key sun-raw-map "18~"  'compile)			; T8
  (define-key suntool-map "ht"   'compile)			; T8

  (define-key sun-raw-map "232z" 'kill-entire-line)		; T9
  (define-key sun-raw-map "19~"  'kill-entire-line)		; T9
  (define-key suntool-map "it"   'kill-entire-line)		; T9
)

(defun mrm-extra-vt-keys ()
  "Define vtxxx function keys."

  (interactive)
  (send-string-to-terminal "\e=")		; application keypad mode

  (global-set-key "\e[17~" 'compare-windows)	; F6
  (global-set-key "\e[18~" 'goto-line)		; F7
  (global-set-key "\e[19~" 'goto-char)		; F8
  (global-set-key "\e[20~" 'buffer-menu)	; F9
  (global-set-key "\e[21~" 'vm)			; F10
  (global-set-key "\e[23~" 'kill-entire-line)	; F11
  (global-set-key "\e[24~" 'compile)		; F12
  (global-set-key "\e[25~" 'beep)		; F13
  (global-set-key "\e[26~" 'beep)		; F14
  (global-set-key "\e[28~" 'beep)		; Help
  (global-set-key "\e[29~" 'beep)		; Do
  (global-set-key "\e[31~" 'beep)		; F17
  (global-set-key "\e[32~" 'beep)		; F18
  (global-set-key "\e[33~" 'beep)		; F19
  (global-set-key "\e[34~" 'beep)		; F20

  (global-set-key "\e[1~"  'isearch-forward)		; Find
  (global-set-key "\e[2~"  'quoted-insert)		; Insert Here
  (global-set-key "\e[3~"  'kill-entire-line)		; Remove
  (global-set-key "\e[4~"  'beep)			; Select
  (global-set-key "\e[5~"  'sip-scroll-down-in-place)	; prev screen
  (global-set-key "\e[6~"  'sip-scroll-up-in-place)	; next screen

  (global-set-key "\eOP"   'beep)			; PF1
  (global-set-key "\eOQ"   'beep)			; PF2
  (global-set-key "\eOR"   'beep)			; PF3
  (global-set-key "\eOS"   'beep)			; PF4

  (global-set-key "\eOw"   'sip-scroll-down-in-place)	; Keypad 7
  (global-set-key "\eOx"   'previous-line)		; Keypad 8
  (global-set-key "\eOy"   'mark-beginning-of-buffer)	; Keypad 9
  (global-set-key "\eOt"   'backward-char)		; Keypad 4
  (global-set-key "\eOu"   'beginning-of-line)		; Keypad 5
  (global-set-key "\eOv"   'forward-char)		; Keypad 6
  (global-set-key "\eOq"   'sip-scroll-up-in-place)	; Keypad 1
  (global-set-key "\eOr"   'next-line)			; Keypad 2
  (global-set-key "\eOs"   'mark-end-of-buffer)		; Keypad 3
  (global-set-key "\eOp"   'beep)			; Keypad 0

  (global-set-key "\eOm"   'beep)			; Keypad -
  (global-set-key "\eOl"   'beep)			; Keypad ,
  (global-set-key "\eOn"   'beep)			; Keypad .
  (global-set-key "\eOM"   'newline-and-indent)		; Keypad Enter
)


(defun x-mouse-scroll-down (arg)
  "Scrolls down a page of the window the mouse is pointing at."
  (setq curr-window (selected-window))
  (x-mouse-select arg)
  (condition-case nil (sip-scroll-down-in-place nil) (beginning-of-buffer))
  (select-window curr-window)
)

(defun x-mouse-scroll-up (arg)
  "Scrolls down a page of the window the mouse is pointing at."
  (setq curr-window (selected-window))
  (x-mouse-select arg)
  (condition-case nil (sip-scroll-up-in-place nil) (end-of-buffer))
  (select-window curr-window)
)

(defun mrm-extra-x11-keys ()
  "Define x11 function keys."

  (interactive)

  (setq mrm-x11-map (make-sparse-keymap))
  (define-key mrm-x11-map "11~" 'compare-windows)		; F1
  (define-key mrm-x11-map "12~" 'goto-line)			; F2
  (define-key mrm-x11-map "13~" 'goto-char)			; F3
  (define-key mrm-x11-map "14~" 'buffer-menu)			; F4
  (define-key mrm-x11-map "15~" 'vm)				; F5
  (define-key mrm-x11-map "17~" 'kill-entire-line)		; F6
  (define-key mrm-x11-map "18~" 'compile)			; F7
  (define-key mrm-x11-map "19~" 'shrink-window)			; F8
  (define-key mrm-x11-map "20~" 'enlarge-window)		; F9
  (define-key mrm-x11-map "21~"	'beep)				; F10
  (define-key mrm-x11-map "24~"	'beep)				; F12
  (define-key mrm-x11-map "25~"	'beep)				; F13
  (define-key mrm-x11-map "26~"	'beep)				; F14
  (define-key mrm-x11-map "31~"	'beep)				; F17
  (define-key mrm-x11-map "32~"	'beep)				; F18
  (define-key mrm-x11-map "33~"	'beep)				; F19
  (define-key mrm-x11-map "34~"	'beep)				; F20

  (define-key mrm-x11-map "1~"	'isearch-forward)		; Find
  (define-key mrm-x11-map "2~"	'beep)				; Insert Here
  (define-key mrm-x11-map "3~"	'beep)				; Remove
  (define-key mrm-x11-map "4~"	'beep)				; Select
  (define-key mrm-x11-map "5~"	'sip-scroll-down-in-place)	; prev screen
  (define-key mrm-x11-map "6~"	'sip-scroll-up-in-place)	; next screen
  (define-key mrm-x11-map "28~"	'Helper-help)			; Help
  (define-key mrm-x11-map "29~"	'beep)				; Do
  (define-key mrm-x11-map "t~"	'mark-beginning-of-buffer)	; Keypad 9
  (define-key mrm-x11-map "b~"	'mark-end-of-buffer)		; Keypad 3

  (define-key mrm-x11-map "A"	'previous-line)			; up    arrow
  (define-key mrm-x11-map "B"	'next-line)			; down  arrow
  (define-key mrm-x11-map "C"	'forward-char)			; right arrow
  (define-key mrm-x11-map "D"	'backward-char)			; left  arrow

  (global-unset-key "\e[")
  (define-key esc-map "[" mrm-x11-map)

  (define-key mouse-map x-button-c-left  'x-mouse-scroll-down)
  (define-key mouse-map x-button-c-right 'x-mouse-scroll-up)
)

(if (string-match "^sun" terminal-type)
    (progn
      (setq terminal-sun t)
      (setq sun-esc-bracket t)
      (setq term-setup-hook 'mrm-extra-sun-keys)
      (if (and (fboundp 'sun-window-init)
               (>= (sun-window-init) 0))
		 (progn
		   (setq terminal-suntools t)
		   (global-set-key "\C-z" 'suntools-icon)
		 )
      )
    )

    (if (and (eq window-system 'x) (= window-system-version 11))
	(progn
	  (setq terminal-x t)
	  (setq term-setup-hook 'mrm-extra-x11-keys)
	  (load "term/x-win")
	  (setq term-file-prefix nil)
	  (if (not (boundp 'epoch::version))
	      (progn
		(x-set-bell t)
		(x-flip-color))
	    (progn
	      (setq terminal-epoch t)
	      (setq load-path
		    (append load-path
			    (list "/project/osc/sandboxes/meissner/epoch-3.1/epoch-lisp-files")))
	      (load "epoch")
	      (load "smk-x-mouse")
	      (load "motion")
	      ;; (global-set-key "\C-zo" 'mrm-switch-screen)
	      (setq epoch::screen-properties (append (list
						      (cons 'font "terminal_narrow14")
						      (cons 'geometry "100x54")
						      (cons 'reverse "True"))
						     epoch::screen-properties))
	      (epoch::move-screen 7 68)
	      (epoch::rebind-key "Prior"  0 "\e[5~")
	      (epoch::rebind-key "Next"   0 "\e[6~")
	      (epoch::rebind-key "KP_1"   0 "\C-v")
	      (epoch::rebind-key "KP_2"   0 "\C-n")
	      (epoch::rebind-key "KP_3"   0 "\e[b~")
	      (epoch::rebind-key "KP_4"   0 "\C-b")
	      (epoch::rebind-key "KP_5"   0 "\C-a")
	      (epoch::rebind-key "KP_6"   0 "\C-f")
	      (epoch::rebind-key "KP_7"   0 "\M-v")
	      (epoch::rebind-key "KP_8"   0 "\C-p")
	      (epoch::rebind-key "KP_9"   0 "\e[t~")
	      (epoch::title "Epoch")))))

    (progn
      (if (string-match "vt1[0-9][0-9]" terminal-type)
	  (progn
	    (setq terminal-dec t)
	    (setq term-setup-hook 'mrm-extra-vt-keys)
	    (load "term/vt100.el")
	    (enable-arrow-keys)
	    (setq term-file-prefix nil)
	  )
      )

      (if (string-match "vt[2-9][0-9][0-9]" terminal-type)
	  (progn
	    (setq terminal-dec t)
	    (setq term-setup-hook 'mrm-extra-vt-keys)
	    (load "term/vt200.el")
	    (enable-arrow-keys)
	    (setq term-file-prefix nil)
	  )
      )

      (if (and (string-match "xterm" terminal-type)
	       (not (and (eq window-system 'x)
			 (= window-system-version 11))))
	  (progn
	    (setq terminal-sun t)
	    (setq term-setup-hook 'mrm-extra-x11-keys)
	  )
      )
    )
)

--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA

Catproof is an oxymoron, Childproof is nearly so
Technical Details
Message-ID: <9003022122.AA08338@curley.osf.org.osf.org>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!snorkelwacker!tut.cis.ohio-state.edu!osf.org!meissner

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,339c83da3a9aa0f0,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-03-02 13:22:09 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!snorkelwacker!tut.cis.ohio-state.edu!osf.org!meissner
From: meissner@osf.org
Newsgroups: gnu.emacs.bug
Subject: Function Keys
Message-ID: <9003022122.AA08338@curley.osf.org.osf.org>
Date: 2 Mar 90 21:22:09 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 296
Posted: Fri Mar  2 22:22:09 1990