From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/elisp/accessing-scroll.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 devdocs/elisp/accessing-scroll.html (limited to 'devdocs/elisp/accessing-scroll.html') diff --git a/devdocs/elisp/accessing-scroll.html b/devdocs/elisp/accessing-scroll.html new file mode 100644 index 00000000..03550d55 --- /dev/null +++ b/devdocs/elisp/accessing-scroll.html @@ -0,0 +1,17 @@ +

Accessing Scroll Bar Events

These functions are useful for decoding scroll bar events.

Function: scroll-bar-event-ratio event +

This function returns the fractional vertical position of a scroll bar event within the scroll bar. The value is a cons cell (portion . whole) containing two integers whose ratio is the fractional position.

+
Function: scroll-bar-scale ratio total +
+

This function multiplies (in effect) ratio by total, rounding the result to an integer. The argument ratio is not a number, but rather a pair (num . denom)—typically a value returned by scroll-bar-event-ratio.

This function is handy for scaling a position on a scroll bar into a buffer position. Here’s how to do that:

(+ (point-min)
+   (scroll-bar-scale
+      (posn-x-y (event-start event))
+      (- (point-max) (point-min))))
+
+

Recall that scroll bar events have two integers forming a ratio, in place of a pair of x and y coordinates.

+
+
+

+ Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc.
Licensed under the GNU GPL license.
+ https://www.gnu.org/software/emacs/manual/html_node/elisp/Accessing-Scroll.html +

+
-- cgit v1.2.3