Function: term-down

term-down is a byte-compiled function defined in term.el.gz.

Signature

(term-down DOWN &optional CHECK-FOR-SCROLL)

Documentation

Move down DOWN screen lines vertically.

Source Code

;; Defined in /usr/src/emacs/lisp/term.el.gz
(defun term-down (down &optional check-for-scroll)
  "Move down DOWN screen lines vertically."
  (let ((start-column (term-horizontal-column)))
    (when (and check-for-scroll (or term-scroll-with-delete term-pager-count))
      (setq down (term-handle-scroll down)))
    (unless (and (= (term-current-row) 0) (< down 0))
      (term-adjust-current-row-cache down)
      (when (or (/= (point) (point-max)) (< down 0))
	(setq down (- down (term-vertical-motion down)))))
    (cond ((>= down 0)
	   ;; Extend buffer with extra blank lines if needed.
	   (term-insert-char ?\n down)
	   (setq term-current-column 0)
	   (setq term-start-line-column 0))
	  (t
	   (when (= (term-current-row) 0)
	     ;; Insert lines if at the beginning.
	     (save-excursion (term-insert-char ?\n (- down)))
	     (save-excursion
	       (let (p)
		 ;; Delete lines from the end.
		 (forward-line term-height)
		 (setq p (point))
		 (forward-line (- down))
		 (delete-region p (point)))))
	   (setq term-current-column 0)
	   (setq term-start-line-column (current-column))))
    (when start-column
      (term-move-columns start-column))))