Function: ghostel--invalidate

ghostel--invalidate is a natively compiled function defined in ghostel.el.

Signature

(ghostel--invalidate)

Documentation

Trigger a redraw for pending terminal output.

Visible output arriving within ghostel-immediate-redraw-interval of the last keystroke is redrawn immediately; other visible output uses a coalescing timer. Hidden output remains pending until the buffer is displayed.

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--invalidate ()
  "Trigger a redraw for pending terminal output.
Visible output arriving within `ghostel-immediate-redraw-interval' of the
last keystroke is redrawn immediately; other visible output uses a coalescing
timer.  Hidden output remains pending until the buffer is displayed."
  (if (ghostel--get-render-window (current-buffer))
      ;; Interactive echo: output arriving within
      ;; `ghostel-immediate-redraw-interval' of the last keystroke.
      (if (and ghostel--last-send-time
               (< (float-time (time-subtract (current-time)
                                             ghostel--last-send-time))
                  ghostel-immediate-redraw-interval))
          (ghostel--redraw-now (current-buffer))
        ;; Bulk output: schedule a later redraw.
        (unless ghostel--redraw-timer
          (let ((delay (if (and ghostel-adaptive-fps ghostel--last-output-time)
                           (let ((idle-secs
                                  (float-time
                                   (time-subtract
                                    (current-time) ghostel--last-output-time))))
                             ;; If idle for more than 100ms, use a short delay
                             ;; for snappy first-frame response.
                             (if (> idle-secs 0.1)
                                 (min 0.016 ghostel-timer-delay)
                               ghostel-timer-delay))
                         ghostel-timer-delay)))
            (setq ghostel--last-output-time (current-time))
            (setq ghostel--redraw-timer
                  (run-with-timer delay nil
                                  #'ghostel--redraw-now
                                  (current-buffer))))))
    (when ghostel--redraw-timer
      (cancel-timer ghostel--redraw-timer)
      (setq ghostel--redraw-timer nil))
    (setq ghostel--pending-redraw t)))