• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/term/

Lines Matching defs:mouse

1 ;;; sun-mouse.el --- mouse handling for Sun windows
36 ;; define-mouse, global-set-mouse, local-set-mouse,
38 ;; mouse-lookup, describe-mouse-bindings
63 ;;; initialize mouse maps
72 (defun define-mouse (mousemap mouse-list def)
74 MOUSE-LIST is a list of atoms specifying a mouse hit according to these rules:
86 See sun-mouse-handler for the treatment of the form DEF."
87 (mousemap-set (mouse-list-to-mouse-code mouse-list) mousemap def))
89 (defun global-set-mouse (mouse-list def)
91 See define-mouse for a description of MOUSE-EVENT-LIST and DEF.
95 (define-mouse current-global-mousemap mouse-list def))
97 (defun local-set-mouse (mouse-list def)
99 See define-mouse for a description of the arguments.
105 (define-mouse current-local-mousemap mouse-list def))
121 ;;; Called when mouse-prefix is sent to emacs, additional
242 (defun sun-mouse-handler (&optional hit)
243 "Evaluates the function or list associated with a mouse hit.
245 A form bound to button by define-mouse is found by mouse-lookup.
246 The variables: *mouse-window*, *mouse-x*, *mouse-y* are bound.
247 If the form is a symbol (symbolp), it is funcall'ed with *mouse-window*,
248 *mouse-x*, and *mouse-y* as arguments; if the form is a list (listp),
254 (let ((*mouse-window* (sm::loc-w loc))
255 (*mouse-x* (sm::loc-x loc))
256 (*mouse-y* (sm::loc-y loc))
257 (mouse-code (mouse-event-code hit loc)))
258 (let ((form (eval-in-buffer (window-buffer *mouse-window*)
259 (mouse-lookup mouse-code))))
262 (error "Undefined mouse event: %s"
264 (mouse-code-to-mouse-list mouse-code)))))
267 (funcall form *mouse-window* *mouse-x* *mouse-y*))
274 ;; Don't let 'sun-mouse-handler get on last-command,
276 (if (eq this-command 'sun-mouse-handler)
282 "Read and return next mouse-hit, include possible double click"
283 (let ((hit1 (mouse-hit-read)))
285 (let ((hit2 (mouse-second-hit extra-click-wait)))
295 (defun mouse-hit-read ()
296 "Read mouse-hit list from keyboard. Like (read 'read-char),
306 ;;; if prefix is not mouse-prefix, need a way to unread the char...
307 ;;; or else have mouse flush input queue, or else need a peek at next char.
310 ;;; have to flush the queue when the command after a mouse click
311 ;;; starts with mouse-prefix1 (see below).
313 ;;; execute them ourselves after doing the mouse command (using
316 (defvar mouse-prefix1 24 ; C-x
317 "First char of mouse-prefix. Used to detect double clicks and chords.")
319 (defvar mouse-prefix2 0 ; C-@
320 "Second char of mouse-prefix. Used to detect double clicks and chords.")
323 (defun mouse-second-hit (hit-wait)
324 "Returns the next mouse hit occurring within HIT-WAIT milliseconds."
327 (if (or (not (equal pc1 mouse-prefix1))
328 (sit-for-millisecs 3)) ; a mouse prefix will have second char
331 nil) ; Next input not mouse event.
333 (if (not (equal pc2 mouse-prefix2))
338 nil) ; This input is not a mouse event.
339 ;; Next input has mouse prefix and is within time limit.
340 (let ((new-hit (mouse-hit-read))) ; Read the new hit.
342 (mouse-second-hit (- hit-wait (sm::hit-delta new-hit)))
371 ;;If x,y from a real mouse click, we shouldn't get here.
388 ;; mouse within scrollbar-width of edge.
390 ;; mouse a few chars past the end of line.
401 ;;; The encoding of mouse events into a mousemap.
410 (defun mouse-event-code (hit loc)
411 "Maps MOUSE-HIT and LOC into a mouse-code."
414 (mouse-region-to-code (sm::window-region loc))))
416 (defun mouse-region-to-code (region)
417 "Returns partial mouse-code for specified REGION."
420 (defun mouse-list-to-mouse-code (mouse-list)
421 "Map a MOUSE-LIST to a mouse-code."
425 mouse-list)))
427 (defun mouse-code-to-mouse-list (mouse-code)
428 "Map a MOUSE-CODE to a mouse-list."
431 (if (logtest mouse-code (cdr x))
445 (defun mouse-lookup (mouse-code)
447 (or (mousemap-get mouse-code current-local-mousemap)
448 (mousemap-get mouse-code current-global-mousemap)))
454 (defun mouse-mask-lookup (mask list)
464 (defun mouse-union (l l-unique)
465 "Return the union of list of mouse (code . form) pairs L and L-UNIQUE,
475 (defun mouse-union-first-preferred (l1 l2)
476 "Return the union of lists of mouse (code . form) pairs L1 and L2,
478 (mouse-union l2 (mouse-union l1 nil)))
480 (defun mouse-code-function-pairs-of-region (region)
483 (let ((mask (mouse-region-to-code region)))
484 (mouse-union-first-preferred
485 (mouse-mask-lookup mask (cdr current-local-mousemap))
486 (mouse-mask-lookup mask (cdr current-global-mousemap))
492 ;;; And other mouse documentation functions
507 (defun print-mouse-format (binding)
511 (lambda (mouse-list)
512 (princ mouse-list)
521 (defun print-mouse-bindings (region)
522 "Prints mouse-event bindings for REGION."
523 (mapcar 'print-mouse-format (sm::event-bindings region)))
526 "Returns an alist of (function . (mouse-list1 ... mouse-listN)) for REGION,
527 where each mouse-list is bound to the function in REGION."
528 (let ((mouse-bindings (mouse-code-function-pairs-of-region region))
530 (while mouse-bindings
531 (let* ((code-function-pair (car mouse-bindings))
535 (cons (mouse-code-to-mouse-list (car code-function-pair))
538 (list (mouse-code-to-mouse-list
541 (setq mouse-bindings (cdr mouse-bindings))
545 (defun describe-mouse-bindings ()
546 "Lists all current mouse-event bindings."
551 (print-mouse-bindings 'text) (terpri)
554 (print-mouse-bindings 'modeline) (terpri)
557 (print-mouse-bindings 'scrollbar)))
559 (defun describe-mouse-briefly (mouse-list)
561 (interactive "xDescribe mouse list briefly: ")
562 (let ((function (mouse-lookup (mouse-list-to-mouse-code mouse-list))))
564 (message "%s runs the command %s" mouse-list function)
565 (message "%s is undefined" mouse-list))))
567 (defun mouse-help-menu (function-and-binding)
573 (defun mouse-help-region (w x y &optional region)
574 "Displays a menu of mouse functions callable in this region."
576 (mlist (mapcar (function mouse-help-menu)
686 (provide 'sun-mouse)
687 (provide 'term/sun-mouse) ; have to (require 'term/sun-mouse)
690 ;;; sun-mouse.el ends here