From 0f6bbc3da36a77fbdd07e801fd1755702b157a6e Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 27 Jul 2014 21:05:37 +0300 Subject: [PATCH] Support horizontal scrolling of bidirectional text. lisp/scroll-bar.el (scroll-bar-toolkit-horizontal-scroll): Add rudimentary support for bidirectional text. --- lisp/ChangeLog | 5 +++++ lisp/scroll-bar.el | 30 +++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3f97396ca02..dd87a610057 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-07-27 Eli Zaretskii + + * scroll-bar.el (scroll-bar-toolkit-horizontal-scroll): Add + rudimentary support for bidirectional text. + 2014-07-27 Martin Rudalics * frame.el (frame-notice-user-settings): Rewrite using diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el index 09f30d5d3f0..739670cb1c9 100644 --- a/lisp/scroll-bar.el +++ b/lisp/scroll-bar.el @@ -451,6 +451,9 @@ EVENT should be a scroll bar click." (let* ((end-position (event-end event)) (window (nth 0 end-position)) (part (nth 4 end-position)) + (bidi-factor (if (eq (current-bidi-paragraph-direction) 'left-to-right) + 1 + -1)) before-scroll) (cond ((eq part 'end-scroll)) @@ -462,27 +465,32 @@ EVENT should be a scroll bar click." (setq before-scroll (or before-scroll (point))) (cond ((eq part 'before-handle) - (scroll-right 4)) + (scroll-right (* bidi-factor 4))) ((eq part 'after-handle) - (scroll-left 4)) + (scroll-left (* bidi-factor 4))) ((eq part 'ratio) (let* ((portion-whole (nth 2 end-position)) (columns (scroll-bar-scale portion-whole (1- (window-width))))) (scroll-right - (cond - ((not (zerop columns)) - columns) - ((< (car portion-whole) 0) -1) - (t 1))))) + (* (cond + ((not (zerop columns)) + columns) + ((< (car portion-whole) 0) -1) + (t 1)) + bidi-factor)))) ((eq part 'left) - (scroll-right 1)) + (scroll-right (* bidi-factor 1))) ((eq part 'right) - (scroll-left 1)) + (scroll-left (* bidi-factor 1))) ((eq part 'leftmost) - (goto-char (line-beginning-position))) + (goto-char (if (eq bidi-factor 1) + (line-beginning-position) + (line-end-position)))) ((eq part 'rightmost) - (goto-char (line-end-position))) + (goto-char (if (eq bidi-factor 1) + (line-end-position) + (line-beginning-position)))) ((eq part 'horizontal-handle) (scroll-bar-horizontal-drag-1 event)))) (sit-for 0) -- 2.39.2