kinstrey@wsqtba.crd.ge.com (M. A. Kinstrey) (01/22/91)
;;; Copyright (C) 1990 General Electric Company.
;;; Written by Michael A. Kinstrey, for the
;;; DICE (DARPA Initiative in Concurrent Engineering) project.
;;;
;;; This file is for use with GNU Emacs 18.55 or later,
;;; or Epoch, a modified version of GNU Emacs.
;;; Requires Epoch 3.2 or later.
;;;
;;; This code is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY. No author or distributor accepts
;;; responsibility to anyone for the consequences of using this code
;;; or for whether it serves any particular purpose or works at all,
;;; unless explicitly stated in a written agreement. Refer to the
;;; GNU Emacs General Public License for full details.
;;;
;;; Everyone is granted permission to copy, modify and redistribute
;;; this code, but only under the conditions described in the
;;; GNU Emacs General Public License.
;;; Among other things, the copyright notice and this notice
;;; must be preserved on all copies.
(cond (running-epoch (require 'mouse)) ;; epoch mouse-support
((string-equal window-system "x")
(require 'x-mouse)) ;; xemacs mouse-support
(t (message "mouse features not installed"))) ;; regular emacs running?
(require 'mouse-double-click-functions) ;; this will load only once
;; DO NOT do a (provide 'mouse-double-click) anymore, because
;; the variables are all local now, so when a
;; (require 'mouse-double-click) is done, a local set of
;; vars are installed each time
(make-local-variable 'single-mouse-map)
(make-local-variable 'double-mouse-map)
(make-local-variable 'double-clicks-allowed)
(if running-epoch
(setq double-mouse-map (create-mouse-map mouse::global-map))
(setq single-mouse-map (copy-keymap mouse-map))
(setq double-mouse-map (copy-keymap mouse-map)))
(make-local-variable 'current_click_time)
(make-local-variable 'prev_click_time)
(make-local-variable 'prev_click_list)
(make-local-variable 'prev_screen)
(make-local-variable 'double_button_click)
(make-local-variable 'prev_local_mouse_map)
(make-local-variable 'single-mouse-map-before-hooks)
(make-local-variable 'single-mouse-map-after-hooks)
(make-local-variable 'double-mouse-map-before-hooks)
(make-local-variable 'double-mouse-map-after-hooks)
(make-local-variable 'run-hooks-on-mouse-down-event)
;; initialize all variables everytime this file is loaded
(setq double-clicks-allowed t)
(setq current_click_time nil)
(setq prev_click_time nil)
(setq prev_click_list nil)
(setq prev_screen nil)
(setq double_button_click nil)
(setq prev_local_mouse_map nil)
(setq single-mouse-map-before-hooks nil)
(setq single-mouse-map-after-hooks nil)
(setq double-mouse-map-before-hooks nil)
(setq double-mouse-map-after-hooks nil)
(setq run-hooks-on-mouse-down-event nil)
;; ------------------------------------------------------------------
;; ------------ VERSION-SPECIFIC EVENT_HANDLER INSTALLATION ---------
;; ------------------------------------------------------------------
(cond (running-epoch
;; epoch mouse set-up
(push-event 'button 'mouse::double-click-handler) ;; install epoch event-handler
(setq epoch::mouse-events t)) ;; make epoch realize the change
((string-equal window-system "x")
;; X-mouse set-up
(define-key mouse-map x-button-left 'x-double-click))) ;; install xemacs event-handler
;; ------------------------------------------------------------------
;; ------------ CALL-BACK FUNCTIONS ---------------------------------
;; ------------------------------------------------------------------
;; two example call-backs
(defun single-click (&optional arg button)
(message "single-click function called...")(sleep-for 1))
(defun double-click (&optional arg button)
(message "double-click function called...")(sleep-for 1))
;; ------------------------------------------------------------------
;; ----------- CALL-BACK INSTALLATION -------------------------------
;; ------------------------------------------------------------------
;; list of functions to execute before/after actual call-back is executed
(setq single-mouse-map-before-hooks nil)
(setq single-mouse-map-after-hooks nil)
(setq double-mouse-map-before-hooks nil)
(setq double-mouse-map-after-hooks nil)
(setq run-hooks-on-mouse-down-event nil) ;; not applicable under Xemacs- can't distinguish up vs. down.
(cond (running-epoch ;; epoch configuration
(define-mouse double-mouse-map mouse-left mouse-down 'double-click))
((string-equal window-system "x") ;; xemacs configuration
(define-key single-mouse-map x-button-left 'x-mouse-set-point) ;; defaults
(define-key single-mouse-map x-button-middle 'x-paste-text) ;; put into
(define-key single-mouse-map x-button-right 'x-cut-text) ;; single-mouse map
(define-key double-mouse-map x-button-left 'double-click)))
-----------------------------------------------------------------------------
kinstrey@wsqtba.crd.ge.com | Sattinger's Law:
uunet!crdgw1!wsqtba!kinstrey| It works better if you plug it in.
____________________________|________________________________________________