(window (nth 0 start-position))
(portion-whole (nth 2 start-position))
(unit (frame-char-width (window-frame window))))
- (set-window-hscroll
- window (/ (1- (+ (car portion-whole) unit)) unit))))
+ (if (eq (current-bidi-paragraph-direction) 'left-to-right)
+ (set-window-hscroll
+ window (/ (1- (+ (car portion-whole) unit)) unit))
+ (set-window-hscroll
+ window (/ (1- (+ (cdr portion-whole) unit)) unit)))))
(defun scroll-bar-horizontal-drag (event)
"Scroll the window horizontally by dragging the scroll bar slider.
+2014-08-16 Martin Rudalics <rudalics@gmx.at>
+
+ * w32term.c (w32_horizontal_scroll_bar_handle_click): In y part
+ of emacs_event return length from si.nPage to si.nMax.
+ * xdisp.c (set_horizontal_scroll_bar): For right-to-left text
+ interchange start and end of thumb.
+
2014-08-15 Ken Brown <kbrown@cornell.edu>
* gmalloc.c (_malloc_mutex, _aligned_blocks_mutex) [CYGWIN]: Use
{
int left_range = HORIZONTAL_SCROLL_BAR_LEFT_RANGE (f, bar->width);
- int x;
+ int x, y;
int dragging = bar->dragging;
SCROLLINFO si;
si.cbSize = sizeof (si);
- si.fMask = SIF_POS;
-
+ si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
GetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si);
x = si.nPos;
+ y = si.nMax - si.nPos - si.nPage;
bar->dragging = 0;
FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
}
XSETINT (emacs_event->x, x);
- XSETINT (emacs_event->y, left_range);
+ XSETINT (emacs_event->y, y);
return TRUE;
}
void
set_horizontal_scroll_bar (struct window *w)
{
- int start, end, whole, box_width;
+ int start, end, whole, portion;
if (!MINI_WINDOW_P (w)
|| (w == XWINDOW (minibuf_window)
MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); */
start = w->hscroll * FRAME_COLUMN_WIDTH (WINDOW_XFRAME (w));
- box_width = window_box_width (w, TEXT_AREA);
- end = start + box_width;
+ end = start + window_box_width (w, TEXT_AREA);
+ portion = end - start;
+ /* After enlarging a horizontally scrolled window such that it
+ gets at least as wide as the text it contains, make sure that
+ the thumb doesn't fill the entire scroll bar so we can still
+ drag it back to see the entire text. */
+ whole = max (whole, end);
- /* The following is needed to ensure that if after maximizing a
- window we get hscroll > 0, we can still drag the thumb to the
- left. */
- whole = max (whole, w->hscroll + box_width);
- whole = max (whole, end - start);
+ if (it.bidi_p)
+ {
+ Lisp_Object pdir;
+
+ pdir = Fcurrent_bidi_paragraph_direction (Qnil);
+ if (EQ (pdir, Qright_to_left))
+ {
+ start = whole - end;
+ end = start + portion;
+ }
+ }
if (old_buffer)
set_buffer_internal (old_buffer);
/* Indicate what this scroll bar ought to be displaying now. */
if (FRAME_TERMINAL (XFRAME (w->frame))->set_horizontal_scroll_bar_hook)
(*FRAME_TERMINAL (XFRAME (w->frame))->set_horizontal_scroll_bar_hook)
- (w, end - start, whole, start);
+ (w, portion, whole, start);
}