diff options
author | Richard M. Stallman <rms@gnu.org> | 1993-05-08 23:49:17 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1993-05-08 23:49:17 +0000 |
commit | e532b0166158d7b19dae058b97c5309e1c080f20 (patch) | |
tree | 16f5c44b084a20b3e23b897c920b5061ccbb7bc8 /lisp/scroll-bar.el | |
parent | b1fe93044958d59828f768c7a8bc97be10cc3d16 (diff) | |
download | emacs-e532b0166158d7b19dae058b97c5309e1c080f20.tar.gz |
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Put scroll-bar-drag on down-mouse-2 in scroll bar.
Leave up-events on mouse-2 unbound.
Diffstat (limited to 'lisp/scroll-bar.el')
-rw-r--r-- | lisp/scroll-bar.el | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el index 2aaf0d8e163..86f6ea07e46 100644 --- a/lisp/scroll-bar.el +++ b/lisp/scroll-bar.el @@ -79,6 +79,7 @@ turn off scroll bars; otherwise, turn on scroll bars." ;;;; Buffer navigation using the scroll bar. +;;; This was used for up-events on button 2, but no longer. (defun scroll-bar-set-window-start (event) "Set the window start according to where the scroll bar is dragged. EVENT should be a scroll bar click or drag event." @@ -93,6 +94,34 @@ EVENT should be a scroll bar click or drag event." (beginning-of-line) (set-window-start window (point)))))) +;; Scroll the window to the proper position for EVENT. +(defun scroll-bar-drag-1 (event) + (let* ((start-position (event-start event)) + (window (nth 0 start-position)) + (portion-whole (nth 2 start-position))) + (save-excursion + (set-buffer (window-buffer window)) + (goto-char (scroll-bar-scale portion-whole (buffer-size))) + (beginning-of-line) + (set-window-start window (point))))) + +(defun scroll-bar-drag (event) + "Scroll the window by dragging the scroll bar slider. +If you click outside the slider, the window scrolls to bring the slider there." + (interactive "e") + (let* (done) + (scroll-bar-drag-1 event) + (track-mouse + (while (not done) + (setq event (read-event)) + (if (eq (car-safe event) 'mouse-movement) + (setq event (read-event))) + (cond ((eq (car-safe event) 'scroll-bar-movement) + (scroll-bar-drag-1 event)) + (t + ;; Exit when we get the drag event; ignore that event. + (setq done t))))))) + (defun scroll-bar-scroll-down (event) "Scroll the window's top line down to the location of the scroll bar click. EVENT should be a scroll bar click." @@ -130,9 +159,8 @@ EVENT should be a scroll bar click." (global-set-key [vertical-scroll-bar mouse-1] 'scroll-bar-scroll-up) (global-set-key [vertical-scroll-bar drag-mouse-1] 'scroll-bar-scroll-up) -(global-set-key [vertical-scroll-bar mouse-2] 'scroll-bar-set-window-start) -(global-set-key [vertical-scroll-bar drag-mouse-2] 'scroll-bar-set-window-start) - +(global-set-key [vertical-scroll-bar down-mouse-2] 'scroll-bar-drag) + (global-set-key [vertical-scroll-bar mouse-3] 'scroll-bar-scroll-down) (global-set-key [vertical-scroll-bar drag-mouse-3] 'scroll-bar-scroll-down) |