aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/scroll-bar.el3
-rw-r--r--lisp/term/ns-win.el56
2 files changed, 5 insertions, 54 deletions
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el
index 5cfa2c4353b..838f9bf80cd 100644
--- a/lisp/scroll-bar.el
+++ b/lisp/scroll-bar.el
@@ -148,8 +148,7 @@ created in the future."
148 "Return non-nil when horizontal scroll bars are available on this system." 148 "Return non-nil when horizontal scroll bars are available on this system."
149 (and (display-graphic-p) 149 (and (display-graphic-p)
150 (boundp 'x-toolkit-scroll-bars) 150 (boundp 'x-toolkit-scroll-bars)
151 x-toolkit-scroll-bars 151 x-toolkit-scroll-bars))
152 (not (eq (window-system) 'ns))))
153 152
154(define-minor-mode horizontal-scroll-bar-mode 153(define-minor-mode horizontal-scroll-bar-mode
155 "Toggle horizontal scroll bars on all frames (Horizontal Scroll Bar mode). 154 "Toggle horizontal scroll bars on all frames (Horizontal Scroll Bar mode).
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 452c68d0176..5080ed0a8f7 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -717,60 +717,12 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
717 717
718;;;; Scrollbar handling. 718;;;; Scrollbar handling.
719 719
720(global-set-key [vertical-scroll-bar down-mouse-1] 'ns-handle-scroll-bar-event) 720(global-set-key [vertical-scroll-bar down-mouse-1] 'scroll-bar-toolkit-scroll)
721(global-set-key [horizontal-scroll-bar down-mouse-1] 'scroll-bar-toolkit-horizontal-scroll)
721(global-unset-key [vertical-scroll-bar mouse-1]) 722(global-unset-key [vertical-scroll-bar mouse-1])
722(global-unset-key [vertical-scroll-bar drag-mouse-1]) 723(global-unset-key [vertical-scroll-bar drag-mouse-1])
723 724(global-unset-key [horizontal-scroll-bar mouse-1])
724(declare-function scroll-bar-scale "scroll-bar" (num-denom whole)) 725(global-unset-key [horizontal-scroll-bar drag-mouse-1])
725
726(defun ns-scroll-bar-move (event)
727 "Scroll the frame according to a Nextstep scroller event."
728 (interactive "e")
729 (let* ((pos (event-end event))
730 (window (nth 0 pos))
731 (scale (nth 2 pos)))
732 (with-current-buffer (window-buffer window)
733 (cond
734 ((eq (car scale) (cdr scale))
735 (goto-char (point-max)))
736 ((= (car scale) 0)
737 (goto-char (point-min)))
738 (t
739 (goto-char (+ (point-min) 1
740 (scroll-bar-scale scale (- (point-max) (point-min)))))))
741 (beginning-of-line)
742 (set-window-start window (point))
743 (vertical-motion (/ (window-height window) 2) window))))
744
745(defun ns-handle-scroll-bar-event (event)
746 "Handle scroll bar EVENT to emulate Nextstep style scrolling."
747 (interactive "e")
748 (let* ((position (event-start event))
749 (bar-part (nth 4 position))
750 (window (nth 0 position))
751 (old-window (selected-window)))
752 (cond
753 ((eq bar-part 'ratio)
754 (ns-scroll-bar-move event))
755 ((eq bar-part 'handle)
756 (if (eq window (selected-window))
757 (track-mouse (ns-scroll-bar-move event))
758 ;; track-mouse faster for selected window, slower for unselected.
759 (ns-scroll-bar-move event)))
760 (t
761 (select-window window)
762 (cond
763 ((eq bar-part 'up)
764 (goto-char (window-start window))
765 (scroll-down 1))
766 ((eq bar-part 'above-handle)
767 (scroll-down))
768 ((eq bar-part 'below-handle)
769 (scroll-up))
770 ((eq bar-part 'down)
771 (goto-char (window-start window))
772 (scroll-up 1)))
773 (select-window old-window)))))
774 726
775 727
776;;;; Color support. 728;;;; Color support.