Function: ghostel--window-anchored-p

ghostel--window-anchored-p is a natively compiled function defined in ghostel.el.

Signature

(ghostel--window-anchored-p WINDOW &optional BODY-PIXEL-HEIGHT)

Documentation

Non-nil if WINDOW is scrolled to follow the live terminal output.

WINDOW follows the output when the lines from its window-start to point-max fit within its body, measured from BODY-PIXEL-HEIGHT (default window-body-height in pixels, excluding the mode-line and header-line to match the terminal grid), plus one line of tolerance for the partial top line the graphical anchor leaves via window-vscroll.

A cursor-clamped anchor (see ghostel--anchor-window) can start above that geometric bound; WINDOW also counts as anchored while its window-start sits exactly on the live cursor's line. WINDOW additionally follows only while ghostel--window-follows-p holds.

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--window-anchored-p (window &optional body-pixel-height)
  "Non-nil if WINDOW is scrolled to follow the live terminal output.
WINDOW follows the output when the lines from its `window-start' to
`point-max' fit within its body, measured from BODY-PIXEL-HEIGHT (default
`window-body-height' in pixels, excluding the mode-line and header-line to
match the terminal grid), plus one line of tolerance for the partial top
line the graphical anchor leaves via `window-vscroll'.

A cursor-clamped anchor (see `ghostel--anchor-window') can start above
that geometric bound; WINDOW also counts as anchored while its
`window-start' sits exactly on the live cursor's line.
WINDOW additionally follows only while `ghostel--window-follows-p'
holds."
  (with-current-buffer (window-buffer window)
    (when (and (derived-mode-p 'ghostel-mode)
               (ghostel--window-follows-p window))
      (or (and ghostel--cursor-char-pos
               (not (eq ghostel--input-mode 'line))
               (eql (window-start window)
                    (save-excursion
                      (goto-char ghostel--cursor-char-pos)
                      (line-beginning-position))))
          (when-let* ((dlh (with-selected-window window
                             (default-line-height)))
                      (body-pixel-height (or body-pixel-height
                                             (window-body-height window t)))
                      (screen-lines (/ (float body-pixel-height)
                                       (float dlh)))
                      (ws (window-start window))
                      (ws-lines-to-end (count-lines ws (point-max))))
            (<= ws-lines-to-end (1+ (floor screen-lines))))))))