Function: ghostel--balance-top-pad

ghostel--balance-top-pad is a natively compiled function defined in ghostel.el.

Signature

(ghostel--balance-top-pad WINDOW TARGET)

Documentation

Return WINDOW's pixel anchor for TARGET, its free space padded on top.

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--balance-top-pad (window target)
  "Return WINDOW's pixel anchor for TARGET, its free space padded on top."
  ;; Measure with the pad cleared: whether a measurement counts the pad
  ;; line varies with build and geometry, and a tainted leftover feeds
  ;; back into the next pad.
  (ghostel--top-pad-set 0)
  (when-let* ((anchor (ghostel--pixel-anchor window target)))
    (when (memq ghostel-window-padding-balance '(center bottom t))
      (let ((leftover most-positive-fixnum))
        (dolist (w (ghostel--windows (current-buffer) t))
          (when (display-graphic-p (window-frame w))
            (setq leftover
                  (min leftover
                       (ghostel--top-pad-leftover
                        w target (and (eq w window) anchor))))))
        ;; A row or more means an unfilled grid, not a fractional-row gap.
        (unless (>= leftover (default-font-height))
          (ghostel--top-pad-set
           (if (eq ghostel-window-padding-balance 'bottom)
               leftover
             (/ leftover 2))))))
    anchor))