aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorAlan Third2016-05-01 13:04:07 +0200
committerMartin Rudalics2016-05-01 13:04:07 +0200
commite683a2570be6f2e4f8defa4e7ee35a7d87f18918 (patch)
tree0b749572bb70a6222d333d932bda7a29b18e5729 /lisp
parent80a1e3b9b58aaeb71913737e07bb305d9eb54437 (diff)
downloademacs-e683a2570be6f2e4f8defa4e7ee35a7d87f18918.tar.gz
emacs-e683a2570be6f2e4f8defa4e7ee35a7d87f18918.zip
Implement horizontal scroll bars on NS
* lisp/scroll-bar.el (horizontal-scroll-bars-available-p): Remove NS check. * lisp/term/ns-win.el: Remove custom NS scroll-bar handlers and bind scroll-bar mouse clicks to standard handlers. * src/nsterm.h (EmacsScroller): Add 'horizontal' property and rename pixel_height to pixel_length. * src/nsterm.m (x_set_window_size): Remove left-hand scroll-bar code. It caused scroll-bars to be over-drawn and the best working solution appears to be complete removal. (ns_set_horizontal_scroll_bar): Rewrite to handle horizontal scrollers correctly. (ns_set_vertical_scroll_bar): Set width to actual scroller width. (setFrame): Handle horizontal case. (dealloc): Handle horizontal case. (judge): Handle horizontal case. (setPosition): Rename pixel_height to pixel_length. (sendScrollEventAtLoc): Handle horizontal case. (mouseDown): Handle horizontal case and general tidy up of code. (mouseDragged): Handle horizontal case. Call sendScrollEventAtLoc with absolute pixel size instead of ratio. * src/window.h: Remove NS check.
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.