Mercurial > hg > xemacs-beta
comparison lisp/mouse.el @ 223:2c611d1463a6 r20-4b10
Import from CVS: tag r20-4b10
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:10:54 +0200 |
parents | 41ff10fd062f |
children | 0e522484dd2a |
comparison
equal
deleted
inserted
replaced
222:aae4c8b01452 | 223:2c611d1463a6 |
---|---|
380 (defun mouse-ignore () | 380 (defun mouse-ignore () |
381 "Don't do anything." | 381 "Don't do anything." |
382 (interactive)) | 382 (interactive)) |
383 | 383 |
384 | 384 |
385 ;; | |
386 ;; Commands for the scroll bar. | |
387 ;; | |
388 | |
389 ;; this stuff has never ever been used and should be junked. | |
390 | |
391 ;; Vertical bar | |
392 | |
393 ;(defun mouse-scroll-down (nlines) | |
394 ; "Junk me, please." | |
395 ; (interactive "@p") | |
396 ; (scroll-down nlines)) | |
397 | |
398 ;(defun mouse-scroll-up (nlines) | |
399 ; "Junk me, please." | |
400 ; (interactive "@p") | |
401 ; (scroll-up nlines)) | |
402 | |
403 ;(defun mouse-scroll-down-full () | |
404 ; "Junk me, please." | |
405 ; (interactive "@") | |
406 ; (scroll-down nil)) | |
407 | |
408 ;(defun mouse-scroll-up-full () | |
409 ; "Junk me, please." | |
410 ; (interactive "@") | |
411 ; (scroll-up nil)) | |
412 | |
413 ;(defun mouse-scroll-move-cursor (nlines) | |
414 ; "Junk me, please." | |
415 ; (interactive "@p") | |
416 ; (move-to-window-line nlines)) | |
417 | |
418 ;(defun mouse-scroll-absolute (event) | |
419 ; "Junk me, please." | |
420 ; (interactive "@e") | |
421 ; (let* ((position (event-x event)) | |
422 ; (length (event-y event)) | |
423 ; (size (buffer-size)) | |
424 ; (scale-factor (max 1 (/ 8000000 size))) | |
425 ; (newpos (* (/ (* (/ size scale-factor) position) length) | |
426 ; scale-factor))) | |
427 ; (goto-char newpos) | |
428 ; (recenter '(4)))) | |
429 | |
430 ;; These scroll while the invoking button is depressed. | |
431 | |
432 ;(defvar scrolled-lines 0) | |
433 ;(defvar scroll-speed 1) | |
434 | |
435 ;(defun incr-scroll-down (event) | |
436 ; "Junk me, please." | |
437 ; (interactive "@e") | |
438 ; (setq scrolled-lines 0) | |
439 ; (incremental-scroll scroll-speed)) | |
440 | |
441 ;(defun incr-scroll-up (event) | |
442 ; "Junk me, please." | |
443 ; (interactive "@e") | |
444 ; (setq scrolled-lines 0) | |
445 ; (incremental-scroll (- scroll-speed))) | |
446 | |
447 ;(defun incremental-scroll (n) | |
448 ; "Junk me, please." | |
449 ; (let ((down t)) | |
450 ; (while down | |
451 ; (sit-for mouse-track-scroll-delay) | |
452 ; (cond ((input-pending-p) | |
453 ; (let ((event (next-command-event))) | |
454 ; (if (or (button-press-event-p event) | |
455 ; (button-release-event-p event)) | |
456 ; (setq down nil)) | |
457 ; (dispatch-event event)))) | |
458 ; (setq scrolled-lines (1+ (* scroll-speed scrolled-lines))) | |
459 ; (scroll-down n)))) | |
460 | |
461 ;(defun incr-scroll-stop (event) | |
462 ; "Junk me, please." | |
463 ; (interactive "@e") | |
464 ; (setq scrolled-lines 0) | |
465 ; (sleep-for 1)) | |
466 | |
467 | |
468 ;(defun mouse-scroll-left (ncolumns) | |
469 ; "Junk me, please." | |
470 ; (interactive "@p") | |
471 ; (scroll-left ncolumns)) | |
472 | |
473 ;(defun mouse-scroll-right (ncolumns) | |
474 ; "Junk me, please." | |
475 ; (interactive "@p") | |
476 ; (scroll-right ncolumns)) | |
477 | |
478 ;(defun mouse-scroll-left-full () | |
479 ; "Junk me, please." | |
480 ; (interactive "@") | |
481 ; (scroll-left nil)) | |
482 | |
483 ;(defun mouse-scroll-right-full () | |
484 ; "Junk me, please." | |
485 ; (interactive "@") | |
486 ; (scroll-right nil)) | |
487 | |
488 ;(defun mouse-scroll-move-cursor-horizontally (ncolumns) | |
489 ; "Junk me, please." | |
490 ; (interactive "@p") | |
491 ; (move-to-column ncolumns)) | |
492 | |
493 ;(defun mouse-scroll-absolute-horizontally (event) | |
494 ; "Junk me, please." | |
495 ; (interactive "@e") | |
496 ; (set-window-hscroll (selected-window) 33)) | |
497 | |
498 | |
499 | |
500 ;;; mouse/selection tracking | 385 ;;; mouse/selection tracking |
501 ;;; generalized mouse-track | 386 ;;; generalized mouse-track |
502 | 387 |
503 (defvar default-mouse-track-normalize-point-function | 388 (defvar default-mouse-track-normalize-point-function |
504 'default-mouse-track-normalize-point | 389 'default-mouse-track-normalize-point |
651 (add-timeout (/ mouse-track-scroll-delay 1000.0) | 536 (add-timeout (/ mouse-track-scroll-delay 1000.0) |
652 'mouse-track-scroll-undefined | 537 'mouse-track-scroll-undefined |
653 (copy-event event))))) | 538 (copy-event event))))) |
654 | 539 |
655 (defun mouse-track-run-hook (hook event &rest args) | 540 (defun mouse-track-run-hook (hook event &rest args) |
656 ;; ugh, can't use run-special-hook-with-args because we | 541 ;; ugh, can't use run-hook-with-args-until-success because we have |
657 ;; have to get the value using symbol-value-in-buffer. | 542 ;; to get the value using symbol-value-in-buffer. Doing a |
658 ;; Doing a save-excursion/set-buffer is wrong because | 543 ;; save-excursion/set-buffer is wrong because the hook might want to |
659 ;; the hook might want to change the buffer, but just | 544 ;; change the buffer, but just doing a set-buffer is wrong because |
660 ;; doing a set-buffer is wrong because the hook might | 545 ;; the hook might not want to change the buffer. |
661 ;; not want to change the buffer. | 546 ;; #### What we need here is a Lisp interface to |
547 ;; run_hook_with_args_in_buffer. Here is a poor man's version. | |
662 (let ((buffer (event-buffer event))) | 548 (let ((buffer (event-buffer event))) |
663 (if mouse-grabbed-buffer (setq buffer mouse-grabbed-buffer)) | 549 (and mouse-grabbed-buffer (setq buffer mouse-grabbed-buffer)) |
664 (if buffer | 550 (when buffer |
665 (let ((value (symbol-value-in-buffer hook buffer nil))) | 551 (let ((value (symbol-value-in-buffer hook buffer nil))) |
666 (if (and (listp value) (not (eq (car value) 'lambda))) | 552 (if (and (listp value) (not (eq (car value) 'lambda))) |
667 (let (retval) | 553 ;; List of functions. |
668 (while (and value | 554 (let (retval) |
669 (not (setq retval (apply (car value) event args)))) | 555 (while (and value (null retval)) |
670 (setq value (cdr value))) | 556 ;; Found `t': should process default value. We could |
671 retval) | 557 ;; splice it into the buffer-local value, but that |
672 (apply value event args)))))) | 558 ;; would cons, which is not a good thing for |
559 ;; mouse-track hooks. | |
560 (if (eq (car value) t) | |
561 (let ((global (default-value hook))) | |
562 (if (and (listp global) (not (eq (car global) 'lambda))) | |
563 ;; List of functions. | |
564 (while (and global | |
565 (null (setq retval | |
566 (apply (car global) event args)))) | |
567 (pop global)) | |
568 ;; lambda | |
569 (setq retval (apply (car global) event args)))) | |
570 (setq retval (apply (car value) event args))) | |
571 (pop value)) | |
572 retval) | |
573 ;; lambda | |
574 (apply value event args)))))) | |
673 | 575 |
674 (defun mouse-track-scroll-undefined (random) | 576 (defun mouse-track-scroll-undefined (random) |
675 ;; the old implementation didn't actually define this function, | 577 ;; the old implementation didn't actually define this function, |
676 ;; and in normal use it won't ever be called because the timeout | 578 ;; and in normal use it won't ever be called because the timeout |
677 ;; will either be removed before it fires or will be picked off | 579 ;; will either be removed before it fires or will be picked off |