Function: term-erase-in-line

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

Signature

(term-erase-in-line KIND)

Source Code

;; Defined in /usr/src/emacs/lisp/term.el.gz
(defun term-erase-in-line (kind)
  (when (= kind 1) ;; erase left of point
    (let ((cols (term-horizontal-column)) (saved-point (point)))
      (term-vertical-motion 0)
      (delete-region (point) saved-point)
      (term-insert-char ?  cols)))
  (when (not (eq kind 1)) ;; erase right of point
    (let ((saved-point (point))
	  (wrapped (and (zerop (term-horizontal-column))
			(not (zerop (term-current-column))))))
      (term-vertical-motion 1)
      (delete-region saved-point (point))
      ;; wrapped is true if we're at the beginning of screen line,
      ;; but not a buffer line.  If we delete the current screen line
      ;; that will make the previous line no longer wrap, and (because
      ;; of the way Emacs display works) point will be at the end of
      ;; the previous screen line rather then the beginning of the
      ;; current one.  To avoid that, we make sure that current line
      ;; contain a space, to force the previous line to continue to wrap.
      ;; We could do this always, but it seems preferable to not add the
      ;; extra space when wrapped is false.
      (when wrapped
	(insert ? ))
      (insert ?\n)
      (put-text-property saved-point (point) 'font-lock-face 'default)
      (goto-char saved-point))))