Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/12/84; site nbs-amrf.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!amdcad!lll-crg!gymble!neurad!nbs-amrf!manheime From: manheime@nbs-amrf.UUCP (Ken Manheimer) Newsgroups: net.emacs Subject: Re: Re: emacs mouse support (an mlisp/gosmacs employment) Message-ID: <113@nbs-amrf.UUCP> Date: Fri, 17-Jan-86 14:49:51 EST Article-I.D.: nbs-amrf.113 Posted: Fri Jan 17 14:49:51 1986 Date-Received: Sun, 19-Jan-86 04:26:13 EST References: <912@mit-eddie.UUCP> <5@emacs.UUCP> <112@nbs-amrf.UUCP> Organization: National Bureau of Standards Lines: 127 > [Me, in prior (or subsequent, depending on the vagaries of > transmission) article:] > In any case, i'd like to summarize the functions i provided and, in > case anyone is interested in using them, i'll post the mlisp in a > separate message. The code of interest is 'new-mouse-filter'. ; ; Special key bindings for Sun Microsystems workstation console ; ; klm 7-Jun-85 Added scroll-region (mouse click in minibuffer) refinements ; klm 6-Jun-85 Made bounded-dot-to-x-y to circumvent mouse bug - mouse ; may put dot beyond end-of buffer ; klm 31-May-85 Adding function to move line containing dot to selected line ; (swapping buffers if necessary) and altered keypad bindings a little ; klm lost in obscurity Developed alternative "new-mouse-filter" ; function. (bind-to-key "new-mouse-filter" "\eM") ; ESC-M = mouse report-code prefix. (bind-to-key "describe-key" "\e[208z") ; keypad R1 (bind-to-key "line-to-top-of-window" "\e[209z") ; keypad R2 (bind-to-key "shell" "\e[210z") ; keypad R3 (bind-to-key "dot-to-left-margin" "\e[211z") ; keypad R4 (bind-to-key "dot-to-centre" "\e[212z") ; keypad R5 (bind-to-key "dot-to-right-margin" "\e[213z") ; keypad R6 (bind-to-key "scroll-one-line-down" "\e[214z") ; keypad R7 (bind-to-key "previous-line" "\e[A") ; keypad R8 (up-arrow) (bind-to-key "previous-page" "\e[216z") ; keypad R9 (bind-to-key "backward-character" "\e[D") ; keypad R10 (left-arrow) (bind-to-key "set-mark" "\e[218z") ; keypad R11 (bind-to-key "forward-character" "\e[C") ; keypad R12 (right-arrow) (bind-to-key "scroll-one-line-up" "\e[220z") ; keypad R13 (bind-to-key "next-line" "\e[B") ; keypad R14 (down-arrow) (bind-to-key "next-page" "\e[222z") ; keypad R15 (autoload "dot-to-left-margin" "shift.ml") (autoload "dot-to-right-margin" "shift.ml") (defun (bounded-dot-to-x-y (move-dot-to-x-y (arg 1 "X coordinate: ") (arg 2 "Y coordinate: ")) (if (> (dot) (buffer-size)) (end-of-file)) ) (new-mouse-filter button mouse-x mouse-y (setq button (get-tty-character)) (setq mouse-x (get-tty-character)) (setq mouse-y (get-tty-character)) ; (setq single-step (breakpoint)) ; uncomment this line for debugging (if (= button '1') ; left ; - The left mouse button sets an anonymous mark at the dot if the mouse is ; within a buffer, (i.e. not in minibuffer) otherwise exchanges dot and mark. (if (error-occurred (save-excursion (bounded-dot-to-x-y mouse-x mouse-y))) (exchange-dot-and-mark) (progn (set-mark) (message "Mark set.")) ) (= button '2') ; middle ; - The middle moves the dot to the mouse if the mouse is within (or on ; the mode line of) a non-minibuffer buffer; the dot is moved across buffers ; if necessary). If the mouse is in the minibuffer the dot is moved to a ; position in the current buffer proportional to the position of the ; mouse the minibuffer line (first and last character positions in the ; the minibuffer line insured to map to the beginning and end of the buffer). (if (error-occurred (bounded-dot-to-x-y mouse-x mouse-y)) (if (= mouse-x 1) (beginning-of-file) (= mouse-x (window-width)) (end-of-file) (goto-character ; the 100s are there for emacs integer math (/ (* (/ (* mouse-x 100) (window-width)) (buffer-size)) 100) ) ) ) (= button '3') ; right ; - The right, when clicked in the same buffer as the cursor, moves the ; line containing the cursor to the selected line. If the mouse is in ; another (non minibuffer) window then the cursor's buffer is swapped ; into the selected window and vice-versa. If clicked in the minibuffer the ; current buffer window is moved backward/forward a portion of a page ; proportional to the distance of the mouse from the minibuffers center, ; with full left going back and full right going forward a full page. (progn start-buffer start-dot swap-with-buffer distance (setq start-buffer (current-buffer-name)) (setq start-dot (dot)) (if (! (error-occurred (save-excursion (bounded-dot-to-x-y mouse-x mouse-y) (if (= start-buffer (setq swap-with-buffer (current-buffer-name))) (progn (setq swap-with-buffer "") (setq distance (line-distance start-dot (dot)) )))) )) ; do the selection scroll or swap (if (!= swap-with-buffer "") ; if switch is to be made... (progn (switch-to-buffer swap-with-buffer) (bounded-dot-to-x-y mouse-x mouse-y) (switch-to-buffer start-buffer)) (provide-prefix-argument distance (scroll-one-line-down))) ; do the proportional scroll (provide-prefix-argument ; 100s are for emacs integer math (* (- (/ (* (/ (* mouse-x 100) ; proportional position (window-width)) (window-height)) 100) (/ (window-height) 2)) ; midway in minibuffer 2) ; full scroll (scroll-one-line-up)) ) )) ) ) (novalue)