Function: ghostel--forward-scroll-event
ghostel--forward-scroll-event is a natively compiled function defined
in ghostel.el.
Signature
(ghostel--forward-scroll-event EVENT BUTTON)
Documentation
Try to forward a scroll EVENT as mouse BUTTON to the terminal.
Return non-nil if the terminal consumed the event.
With mwheel-coalesce-scroll-events nil (pixel-scroll-precision-mode(var)/pixel-scroll-precision-mode(fun),
ultra-scroll) every trackpad tick is its own EVENT, so pixel deltas are
accumulated and one press sent per full row of travel.
A mouse-wheel notch is never fewer than one press.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--forward-scroll-event (event button)
"Try to forward a scroll EVENT as mouse BUTTON to the terminal.
Return non-nil if the terminal consumed the event.
With `mwheel-coalesce-scroll-events' nil (`pixel-scroll-precision-mode',
ultra-scroll) every trackpad tick is its own EVENT, so pixel deltas are
accumulated and one press sent per full row of travel.
A mouse-wheel notch is never fewer than one press."
(when (and event (ghostel--terminal-input-mode-p)
(ghostel--mouse-tracking-p ghostel--term))
(let* ((posn (event-start event))
(col-row (ghostel--posn-cell posn))
(delta (cdr (nth 4 event)))
(presses 1))
(when (and delta (not mwheel-coalesce-scroll-events)
;; X11 and pgtk report a mouse notch as several rows
;; of pixels with no line count.
(not (and (fboundp 'device-class) ; Emacs 29+
(eq (device-class last-event-frame
last-event-device)
'mouse))))
(let* ((row-px (with-selected-window (ghostel--event-window event)
(default-line-height)))
(pending (+ ghostel--scroll-pending delta))
(rows (truncate pending row-px)))
;; LINES is 0 for a sub-row trackpad tick, but macOS reports a notch
;; as one line and fewer pixels than a row when `line-spacing' is set.
(setq presses (max (abs rows) (min 1 (or (nth 3 event) 0)))
ghostel--scroll-pending (- pending (* rows row-px)))))
(dotimes (_ presses)
(ghostel--mouse-event ghostel--term
0 ; press
button
(cdr col-row) (car col-row)
(ghostel--mouse-mods event)))
t)))