🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.epoch.misc
Article #1994

mouse-double-click.el

#1994
From: kinstrey
Date: Fri, 19 Apr 1991 20:01
116 lines
5665 bytes
;;; 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)))
Technical Details
Message-ID: <9104192002.AA00969@wsqtba..steinmetz>
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!caen!hellgate.utah.edu!dog.ee.lbl.gov!ucbvax!tut.cis.ohio-state.edu!unreplyable!garbage

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc7ee,bf81eb0b2bee123f,start
X-Google-Attributes: gidfc7ee,public
X-Google-ArrivalTime: 1991-04-19 20:23:18 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!caen!hellgate.utah.edu!dog.ee.lbl.gov!ucbvax!tut.cis.ohio-state.edu!unreplyable!garbage
From: kinstrey@wsqtba.crd.ge.com
Newsgroups: gnu.epoch.misc
Subject: mouse-double-click.el
Message-ID: <9104192002.AA00969@wsqtba..steinmetz>
Date: 19 Apr 91 20:01:53 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 116