From: Phil Sainty <psainty@orcon.net.nz>
To: Noam Postavsky <npostavs@gmail.com>
Cc: 31193@debbugs.gnu.org,
bug-gnu-emacs
<bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org>
Subject: bug#31193: 26.1; error in `term-down' after window configuration change
Date: Wed, 18 Apr 2018 13:04:13 +1200 [thread overview]
Message-ID: <032fbfe050521617bf7b8c9a76479a16@webmail.orcon.net.nz> (raw)
In-Reply-To: <87muy1tm0i.fsf@gmail.com>
On 2018-04-18 12:07, Noam Postavsky wrote:
> Hmm, maybe it's a difference in bash versions? I tried adding a
> newline
> to my prompt with PS1=$'one\ntwo$ ', but bash doesn't send the newline
> after the terminal resizes. Seems it's clever enough just to redraw
> the
> last line.
>
> GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
Mine is:
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
> Can you show the backtrace with PS1="$ "?
Sure. This is with a .bashrc containing only that setting, and an
otherwise blank-slate $HOME directory, in case anything else I was
doing had an effect. It might still be due to system-wide config,
but the bash version difference seems as likely as anything else?
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p
nil)
=(nil 0)
(and (= term-current-row 0) (< down 0))
(if (and (= term-current-row 0) (< down 0)) nil
(term-adjust-current-row-cache down) (if (or (/= (point) (point-max)) (<
down 0)) (progn (setq down (- down (funcall term-vertical-motion
down))))))
(let ((start-column (term-horizontal-column))) (if (and
check-for-scroll (or term-scroll-with-delete term-pager-count)) (progn
(setq down (term-handle-scroll down)))) (if (and (= term-current-row 0)
(< down 0)) nil (term-adjust-current-row-cache down) (if (or (/= (point)
(point-max)) (< down 0)) (progn (setq down (- down (funcall
term-vertical-motion down)))))) (cond ((>= down 0) (term-insert-char 10
down) (setq term-current-column 0) (setq term-start-line-column 0)) (t
(if (= term-current-row 0) (progn (save-excursion (term-insert-char 10
(- down))) (save-excursion (let (p) (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))))
(if start-column (progn (term-move-columns start-column))))
term-down(1 t)
(if (and term-kill-echo-list (term-check-kill-echo-list)) nil
(term-down 1 t))
(cond ((> funny i) (cond ((eq term-terminal-state 1) (term-down 1 t)
(term-move-columns (- (term-current-column))) (setq term-terminal-state
0))) (setq decoded-substring (decode-coding-string (substring str i
funny) locale-coding-system)) (setq count (length decoded-substring))
(if (= funny str-length) (progn (let ((partial 0)) (while (eq
(char-charset (aref decoded-substring (- count 1 partial))) 'eight-bit)
(setq partial (1+ partial))) (if (> partial 0) (progn (setq
term-terminal-undecoded-bytes (substring decoded-substring (- partial)))
(setq decoded-substring (substring decoded-substring 0 (- partial)))
(setq str-length (- str-length partial)) (setq count (- count partial))
(setq funny (- funny partial))))))) (setq temp (- (+
(term-horizontal-column) count) term-width)) (cond ((or
term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (-
count temp)) (setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+
count-bytes i))) ((or (not (or term-pager-count
term-scroll-with-delete)) (> (term-handle-scroll 1) 0))
(term-adjust-current-row-cache 1) (setq count (min count term-width))
(setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i))
(setq term-start-line-column term-current-column)) (t (setq count 0
funny i) (setq term-current-column nil) (setq term-start-line-column
nil))) (setq old-point (point)) (let ((old-column (current-column))
columns pos) (insert (decode-coding-string (substring str i funny)
locale-coding-system)) (setq term-current-column (current-column)
columns (- term-current-column old-column)) (if (not (or (eobp)
term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns)
(delete-region pos (point)))) (if term-insert-mode (progn (setq pos
(point)) (end-of-line) (if (> (current-column) term-width) (progn
(delete-region (- (point) (- (current-column) term-width)) (point))))
(goto-char pos)))) (setq term-current-column nil) (put-text-property
old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0)
(term-move-columns -1) (setq term-terminal-state 1))) (setq i (1-
funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count
(term-current-column)) (setq count (min term-width (+ count 8 (- (mod
count 8))))) (if (> term-width count) (progn (term-move-columns (- count
(term-current-column))) (setq term-current-column count)) (if (>
term-width (term-current-column)) (progn (term-move-columns (1- (-
term-width (term-current-column)))))) (if (= term-width
(term-current-column)) (progn (term-move-columns -1))))) ((eq char 13)
(funcall term-vertical-motion 0) (setq term-current-column
term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list
(term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8)
(term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq
char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char
26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if
handled-ansi-message nil (funcall term-command-hook
(decode-coding-string (substring str (1+ i) end) locale-coding-system)))
(setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring
str i)) (setq term-terminal-state 4) (setq i str-length)))) (t
(term-move-columns 1) (backward-delete-char 1) (insert char)))
(cond ((< term-terminal-state 2) (setq funny (string-match
"[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn
(setq funny str-length))) (cond ((> funny i) (cond ((eq
term-terminal-state 1) (term-down 1 t) (term-move-columns (-
(term-current-column))) (setq term-terminal-state 0))) (setq
decoded-substring (decode-coding-string (substring str i funny)
locale-coding-system)) (setq count (length decoded-substring)) (if (=
funny str-length) (progn (let ((partial 0)) (while (eq (char-charset
(aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial
(1+ partial))) (if (> partial 0) (progn (setq
term-terminal-undecoded-bytes (substring decoded-substring (- partial)))
(setq decoded-substring (substring decoded-substring 0 (- partial)))
(setq str-length (- str-length partial)) (setq count (- count partial))
(setq funny (- funny partial))))))) (setq temp (- (+
(term-horizontal-column) count) term-width)) (cond ((or
term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (-
count temp)) (setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+
count-bytes i))) ((or (not (or term-pager-count
term-scroll-with-delete)) (> (term-handle-scroll 1) 0))
(term-adjust-current-row-cache 1) (setq count (min count term-width))
(setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i))
(setq term-start-line-column term-current-column)) (t (setq count 0
funny i) (setq term-current-column nil) (setq term-start-line-column
nil))) (setq old-point (point)) (let ((old-column (current-column))
columns pos) (insert (decode-coding-string (substring str i funny)
locale-coding-system)) (setq term-current-column (current-column)
columns (- term-current-column old-column)) (if (not (or (eobp)
term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns)
(delete-region pos (point)))) (if term-insert-mode (progn (setq pos
(point)) (end-of-line) (if (> (current-column) term-width) (progn
(delete-region (- (point) (- (current-column) term-width)) (point))))
(goto-char pos)))) (setq term-current-column nil) (put-text-property
old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0)
(term-move-columns -1) (setq term-terminal-state 1))) (setq i (1-
funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count
(term-current-column)) (setq count (min term-width (+ count 8 (- (mod
count 8))))) (if (> term-width count) (progn (term-move-columns (- count
(term-current-column))) (setq term-current-column count)) (if (>
term-width (term-current-column)) (progn (term-move-columns (1- (-
term-width (term-current-column)))))) (if (= term-width
(term-current-column)) (progn (term-move-columns -1))))) ((eq char 13)
(funcall term-vertical-motion 0) (setq term-current-column
term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list
(term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8)
(term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq
char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char
26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if
handled-ansi-message nil (funcall term-command-hook
(decode-coding-string (substring str (1+ i) end) locale-coding-system)))
(setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring
str i)) (setq term-terminal-state 4) (setq i str-length)))) (t
(term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq
term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter
0) (setq term-terminal-previous-parameter -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char
68) (term-handle-deferred-scroll) (term-down 1 t) (setq
term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row)
term-scroll-start) (>= (1- (term-current-row)) term-scroll-start))
(term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char
55) (term-handle-deferred-scroll) (setq term-saved-cursor (list
(term-current-row) (term-horizontal-column) term-ansi-current-bg-color
term-ansi-current-bold term-ansi-current-color
term-ansi-current-invisible term-ansi-current-reverse
term-ansi-current-underline term-current-face)) (setq
term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn
(term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq
term-ansi-current-bg-color (nth 2 term-saved-cursor)
term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color
(nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5
term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor)
term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face
(nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99)
(setq term-terminal-state 0) (term-reset-terminal)) ((setq
term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>=
char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10
term-terminal-parameter) (- char 48)))) ((eq char 59) (setq
term-terminal-more-parameters 1) (setq
term-terminal-previous-parameter-4 term-terminal-previous-parameter-3)
(setq term-terminal-previous-parameter-3
term-terminal-previous-parameter-2) (setq
term-terminal-previous-parameter-2 term-terminal-previous-parameter)
(setq term-terminal-previous-parameter term-terminal-parameter) (setq
term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape
proc char) (setq term-terminal-more-parameters 0) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter -1) (setq term-terminal-state 0)))))
(while (< i str-length) (setq char (aref str i)) (cond ((<
term-terminal-state 2) (setq funny (string-match
"[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn
(setq funny str-length))) (cond ((> funny i) (cond ((eq
term-terminal-state 1) (term-down 1 t) (term-move-columns (-
(term-current-column))) (setq term-terminal-state 0))) (setq
decoded-substring (decode-coding-string (substring str i funny)
locale-coding-system)) (setq count (length decoded-substring)) (if (=
funny str-length) (progn (let ((partial 0)) (while (eq (char-charset
(aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial
(1+ partial))) (if (> partial 0) (progn (setq
term-terminal-undecoded-bytes (substring decoded-substring (- partial)))
(setq decoded-substring (substring decoded-substring 0 (- partial)))
(setq str-length (- str-length partial)) (setq count (- count partial))
(setq funny (- funny partial))))))) (setq temp (- (+
(term-horizontal-column) count) term-width)) (cond ((or
term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (-
count temp)) (setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+
count-bytes i))) ((or (not (or term-pager-count
term-scroll-with-delete)) (> (term-handle-scroll 1) 0))
(term-adjust-current-row-cache 1) (setq count (min count term-width))
(setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i))
(setq term-start-line-column term-current-column)) (t (setq count 0
funny i) (setq term-current-column nil) (setq term-start-line-column
nil))) (setq old-point (point)) (let ((old-column (current-column))
columns pos) (insert (decode-coding-string (substring str i funny)
locale-coding-system)) (setq term-current-column (current-column)
columns (- term-current-column old-column)) (if (not (or (eobp)
term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns)
(delete-region pos (point)))) (if term-insert-mode (progn (setq pos
(point)) (end-of-line) (if (> (current-column) term-width) (progn
(delete-region (- (point) (- (current-column) term-width)) (point))))
(goto-char pos)))) (setq term-current-column nil) (put-text-property
old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0)
(term-move-columns -1) (setq term-terminal-state 1))) (setq i (1-
funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count
(term-current-column)) (setq count (min term-width (+ count 8 (- (mod
count 8))))) (if (> term-width count) (progn (term-move-columns (- count
(term-current-column))) (setq term-current-column count)) (if (>
term-width (term-current-column)) (progn (term-move-columns (1- (-
term-width (term-current-column)))))) (if (= term-width
(term-current-column)) (progn (term-move-columns -1))))) ((eq char 13)
(funcall term-vertical-motion 0) (setq term-current-column
term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list
(term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8)
(term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq
char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char
26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if
handled-ansi-message nil (funcall term-command-hook
(decode-coding-string (substring str (1+ i) end) locale-coding-system)))
(setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring
str i)) (setq term-terminal-state 4) (setq i str-length)))) (t
(term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq
term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter
0) (setq term-terminal-previous-parameter -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char
68) (term-handle-deferred-scroll) (term-down 1 t) (setq
term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row)
term-scroll-start) (>= (1- (term-current-row)) term-scroll-start))
(term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char
55) (term-handle-deferred-scroll) (setq term-saved-cursor (list
(term-current-row) (term-horizontal-column) term-ansi-current-bg-color
term-ansi-current-bold term-ansi-current-color
term-ansi-current-invisible term-ansi-current-reverse
term-ansi-current-underline term-current-face)) (setq
term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn
(term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq
term-ansi-current-bg-color (nth 2 term-saved-cursor)
term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color
(nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5
term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor)
term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face
(nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99)
(setq term-terminal-state 0) (term-reset-terminal)) ((setq
term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>=
char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10
term-terminal-parameter) (- char 48)))) ((eq char 59) (setq
term-terminal-more-parameters 1) (setq
term-terminal-previous-parameter-4 term-terminal-previous-parameter-3)
(setq term-terminal-previous-parameter-3
term-terminal-previous-parameter-2) (setq
term-terminal-previous-parameter-2 term-terminal-previous-parameter)
(setq term-terminal-previous-parameter term-terminal-parameter) (setq
term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape
proc char) (setq term-terminal-more-parameters 0) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter -1) (setq term-terminal-state 0)))))
(if term-pager-old-local-map (progn (if (> (% (current-column)
term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0
i) (setq term-terminal-parameter (concat "\015" (substring str i)))
(setq term-terminal-parameter (substring str (1- i))) (aset
term-terminal-parameter 0 13)) (goto-char (point-max))) (setq
term-terminal-state 4) (make-local-variable 'term-pager-old-filter)
(setq term-pager-old-filter (process-filter proc)) (set-process-filter
proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))
(save-restriction (if (and (> (point-max) (process-mark proc)) (not
(eq (current-local-map) term-raw-map))) (progn (narrow-to-region
(point-min) (process-mark proc)))) (if term-log-buffer (progn (princ str
term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str
(concat term-terminal-undecoded-bytes str)) (setq str-length (length
str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq
term-terminal-state 4) (setq str (concat term-terminal-parameter str))
(setq term-terminal-parameter nil) (setq str-length (length str)) (setq
term-terminal-state 0))) (while (< i str-length) (setq char (aref str
i)) (cond ((< term-terminal-state 2) (setq funny (string-match
"[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn
(setq funny str-length))) (cond ((> funny i) (cond ((eq
term-terminal-state 1) (term-down 1 t) (term-move-columns (-
(term-current-column))) (setq term-terminal-state 0))) (setq
decoded-substring (decode-coding-string (substring str i funny)
locale-coding-system)) (setq count (length decoded-substring)) (if (=
funny str-length) (progn (let ((partial 0)) (while (eq (char-charset
(aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial
(1+ partial))) (if (> partial 0) (progn (setq
term-terminal-undecoded-bytes (substring decoded-substring (- partial)))
(setq decoded-substring (substring decoded-substring 0 (- partial)))
(setq str-length (- str-length partial)) (setq count (- count partial))
(setq funny (- funny partial))))))) (setq temp (- (+
(term-horizontal-column) count) term-width)) (cond ((or
term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (-
count temp)) (setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+
count-bytes i))) ((or (not (or term-pager-count
term-scroll-with-delete)) (> (term-handle-scroll 1) 0))
(term-adjust-current-row-cache 1) (setq count (min count term-width))
(setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i))
(setq term-start-line-column term-current-column)) (t (setq count 0
funny i) (setq term-current-column nil) (setq term-start-line-column
nil))) (setq old-point (point)) (let ((old-column (current-column))
columns pos) (insert (decode-coding-string (substring str i funny)
locale-coding-system)) (setq term-current-column (current-column)
columns (- term-current-column old-column)) (if (not (or (eobp)
term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns)
(delete-region pos (point)))) (if term-insert-mode (progn (setq pos
(point)) (end-of-line) (if (> (current-column) term-width) (progn
(delete-region (- (point) (- (current-column) term-width)) (point))))
(goto-char pos)))) (setq term-current-column nil) (put-text-property
old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0)
(term-move-columns -1) (setq term-terminal-state 1))) (setq i (1-
funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count
(term-current-column)) (setq count (min term-width (+ count 8 (- (mod
count 8))))) (if (> term-width count) (progn (term-move-columns (- count
(term-current-column))) (setq term-current-column count)) (if (>
term-width (term-current-column)) (progn (term-move-columns (1- (-
term-width (term-current-column)))))) (if (= term-width
(term-current-column)) (progn (term-move-columns -1))))) ((eq char 13)
(funcall term-vertical-motion 0) (setq term-current-column
term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list
(term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8)
(term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq
char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char
26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if
handled-ansi-message nil (funcall term-command-hook
(decode-coding-string (substring str (1+ i) end) locale-coding-system)))
(setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring
str i)) (setq term-terminal-state 4) (setq i str-length)))) (t
(term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq
term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter
0) (setq term-terminal-previous-parameter -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char
68) (term-handle-deferred-scroll) (term-down 1 t) (setq
term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row)
term-scroll-start) (>= (1- (term-current-row)) term-scroll-start))
(term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char
55) (term-handle-deferred-scroll) (setq term-saved-cursor (list
(term-current-row) (term-horizontal-column) term-ansi-current-bg-color
term-ansi-current-bold term-ansi-current-color
term-ansi-current-invisible term-ansi-current-reverse
term-ansi-current-underline term-current-face)) (setq
term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn
(term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq
term-ansi-current-bg-color (nth 2 term-saved-cursor)
term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color
(nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5
term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor)
term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face
(nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99)
(setq term-terminal-state 0) (term-reset-terminal)) ((setq
term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>=
char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10
term-terminal-parameter) (- char 48)))) ((eq char 59) (setq
term-terminal-more-parameters 1) (setq
term-terminal-previous-parameter-4 term-terminal-previous-parameter-3)
(setq term-terminal-previous-parameter-3
term-terminal-previous-parameter-2) (setq
term-terminal-previous-parameter-2 term-terminal-previous-parameter)
(setq term-terminal-previous-parameter term-terminal-parameter) (setq
term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape
proc char) (setq term-terminal-more-parameters 0) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter -1) (setq term-terminal-state 0)))))
(if term-pager-old-local-map (progn (if (> (% (current-column)
term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0
i) (setq term-terminal-parameter (concat "\015" (substring str i)))
(setq term-terminal-parameter (substring str (1- i))) (aset
term-terminal-parameter 0 13)) (goto-char (point-max))) (setq
term-terminal-state 4) (make-local-variable 'term-pager-old-filter)
(setq term-pager-old-filter (process-filter proc)) (set-process-filter
proc term-pager-filter) (setq i str-length))) (setq i (1+ i))))
(progn (let ((newstr (term-handle-ansi-terminal-messages str))) (if
(eq str newstr) nil (setq handled-ansi-message t str newstr))) (setq
str-length (length str)) (if (marker-buffer term-pending-delete-marker)
(progn (delete-region term-pending-delete-marker (process-mark proc))
(set-marker term-pending-delete-marker nil))) (if (/= (point)
(process-mark proc)) (progn (setq save-point (point-marker)))) (setq
term-vertical-motion (if (eq (window-buffer) (current-buffer))
'vertical-motion 'term-buffer-vertical-motion)) (setq save-marker
(copy-marker (process-mark proc))) (goto-char (process-mark proc))
(save-restriction (if (and (> (point-max) (process-mark proc)) (not (eq
(current-local-map) term-raw-map))) (progn (narrow-to-region (point-min)
(process-mark proc)))) (if term-log-buffer (progn (princ str
term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str
(concat term-terminal-undecoded-bytes str)) (setq str-length (length
str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq
term-terminal-state 4) (setq str (concat term-terminal-parameter str))
(setq term-terminal-parameter nil) (setq str-length (length str)) (setq
term-terminal-state 0))) (while (< i str-length) (setq char (aref str
i)) (cond ((< term-terminal-state 2) (setq funny (string-match
"[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn
(setq funny str-length))) (cond ((> funny i) (cond ((eq
term-terminal-state 1) (term-down 1 t) (term-move-columns (-
(term-current-column))) (setq term-terminal-state 0))) (setq
decoded-substring (decode-coding-string (substring str i funny)
locale-coding-system)) (setq count (length decoded-substring)) (if (=
funny str-length) (progn (let ((partial 0)) (while (eq (char-charset
(aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial
(1+ partial))) (if (> partial 0) (progn (setq
term-terminal-undecoded-bytes (substring decoded-substring (- partial)))
(setq decoded-substring (substring decoded-substring 0 (- partial)))
(setq str-length (- str-length partial)) (setq count (- count partial))
(setq funny (- funny partial))))))) (setq temp (- (+
(term-horizontal-column) count) term-width)) (cond ((or
term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (-
count temp)) (setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+
count-bytes i))) ((or (not (or term-pager-count
term-scroll-with-delete)) (> (term-handle-scroll 1) 0))
(term-adjust-current-row-cache 1) (setq count (min count term-width))
(setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i))
(setq term-start-line-column term-current-column)) (t (setq count 0
funny i) (setq term-current-column nil) (setq term-start-line-column
nil))) (setq old-point (point)) (let ((old-column (current-column))
columns pos) (insert (decode-coding-string (substring str i funny)
locale-coding-system)) (setq term-current-column (current-column)
columns (- term-current-column old-column)) (if (not (or (eobp)
term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns)
(delete-region pos (point)))) (if term-insert-mode (progn (setq pos
(point)) (end-of-line) (if (> (current-column) term-width) (progn
(delete-region (- (point) (- (current-column) term-width)) (point))))
(goto-char pos)))) (setq term-current-column nil) (put-text-property
old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0)
(term-move-columns -1) (setq term-terminal-state 1))) (setq i (1-
funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count
(term-current-column)) (setq count (min term-width (+ count 8 (- (mod
count 8))))) (if (> term-width count) (progn (term-move-columns (- count
(term-current-column))) (setq term-current-column count)) (if (>
term-width (term-current-column)) (progn (term-move-columns (1- (-
term-width (term-current-column)))))) (if (= term-width
(term-current-column)) (progn (term-move-columns -1))))) ((eq char 13)
(funcall term-vertical-motion 0) (setq term-current-column
term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list
(term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8)
(term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq
char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char
26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if
handled-ansi-message nil (funcall term-command-hook
(decode-coding-string (substring str (1+ i) end) locale-coding-system)))
(setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring
str i)) (setq term-terminal-state 4) (setq i str-length)))) (t
(term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq
term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter
0) (setq term-terminal-previous-parameter -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char
68) (term-handle-deferred-scroll) (term-down 1 t) (setq
term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row)
term-scroll-start) (>= (1- (term-current-row)) term-scroll-start))
(term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char
55) (term-handle-deferred-scroll) (setq term-saved-cursor (list
(term-current-row) (term-horizontal-column) term-ansi-current-bg-color
term-ansi-current-bold term-ansi-current-color
term-ansi-current-invisible term-ansi-current-reverse
term-ansi-current-underline term-current-face)) (setq
term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn
(term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq
term-ansi-current-bg-color (nth 2 term-saved-cursor)
term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color
(nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5
term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor)
term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face
(nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99)
(setq term-terminal-state 0) (term-reset-terminal)) ((setq
term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>=
char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10
term-terminal-parameter) (- char 48)))) ((eq char 59) (setq
term-terminal-more-parameters 1) (setq
term-terminal-previous-parameter-4 term-terminal-previous-parameter-3)
(setq term-terminal-previous-parameter-3
term-terminal-previous-parameter-2) (setq
term-terminal-previous-parameter-2 term-terminal-previous-parameter)
(setq term-terminal-previous-parameter term-terminal-parameter) (setq
term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape
proc char) (setq term-terminal-more-parameters 0) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter -1) (setq term-terminal-state 0)))))
(if term-pager-old-local-map (progn (if (> (% (current-column)
term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0
i) (setq term-terminal-parameter (concat "\015" (substring str i)))
(setq term-terminal-parameter (substring str (1- i))) (aset
term-terminal-parameter 0 13)) (goto-char (point-max))) (setq
term-terminal-state 4) (make-local-variable 'term-pager-old-filter)
(setq term-pager-old-filter (process-filter proc)) (set-process-filter
proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>=
(term-current-row) term-height) (progn (term-handle-deferred-scroll)))
(set-marker (process-mark proc) (point)) (if save-point (progn
(goto-char save-point) (set-marker save-point nil))) (if (and
term-pending-frame (eq (window-buffer selected) (current-buffer)))
(progn (term-display-line (car term-pending-frame) (cdr
term-pending-frame)) (setq term-pending-frame nil))) (setq win selected)
(while (window-minibuffer-p win) (setq win (next-window win nil t)))
(setq last-win win) (while (progn (setq win (next-window win nil t)) (if
(eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll
term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point)
save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or
(eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq
selected win)))) (progn (goto-char term-home-marker) (recenter 0)
(goto-char (process-mark proc)) (if (not (pos-visible-in-window-p
(point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output
(>= (point) (process-mark proc))) (progn (save-excursion (goto-char
(point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (>
term-buffer-maximum-size 0) (progn (save-excursion (goto-char
(process-mark (get-buffer-process (current-buffer)))) (forward-line (-
term-buffer-maximum-size)) (beginning-of-line) (delete-region
(point-min) (point))))) (set-marker save-marker nil))
(unwind-protect (progn (let ((newstr
(term-handle-ansi-terminal-messages str))) (if (eq str newstr) nil (setq
handled-ansi-message t str newstr))) (setq str-length (length str)) (if
(marker-buffer term-pending-delete-marker) (progn (delete-region
term-pending-delete-marker (process-mark proc)) (set-marker
term-pending-delete-marker nil))) (if (/= (point) (process-mark proc))
(progn (setq save-point (point-marker)))) (setq term-vertical-motion (if
(eq (window-buffer) (current-buffer)) 'vertical-motion
'term-buffer-vertical-motion)) (setq save-marker (copy-marker
(process-mark proc))) (goto-char (process-mark proc)) (save-restriction
(if (and (> (point-max) (process-mark proc)) (not (eq
(current-local-map) term-raw-map))) (progn (narrow-to-region (point-min)
(process-mark proc)))) (if term-log-buffer (progn (princ str
term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str
(concat term-terminal-undecoded-bytes str)) (setq str-length (length
str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq
term-terminal-state 4) (setq str (concat term-terminal-parameter str))
(setq term-terminal-parameter nil) (setq str-length (length str)) (setq
term-terminal-state 0))) (while (< i str-length) (setq char (aref str
i)) (cond ((< term-terminal-state 2) (setq funny (string-match
"[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn
(setq funny str-length))) (cond ((> funny i) (cond ((eq
term-terminal-state 1) (term-down 1 t) (term-move-columns (-
(term-current-column))) (setq term-terminal-state 0))) (setq
decoded-substring (decode-coding-string (substring str i funny)
locale-coding-system)) (setq count (length decoded-substring)) (if (=
funny str-length) (progn (let ((partial 0)) (while (eq (char-charset
(aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial
(1+ partial))) (if (> partial 0) (progn (setq
term-terminal-undecoded-bytes (substring decoded-substring (- partial)))
(setq decoded-substring (substring decoded-substring 0 (- partial)))
(setq str-length (- str-length partial)) (setq count (- count partial))
(setq funny (- funny partial))))))) (setq temp (- (+
(term-horizontal-column) count) term-width)) (cond ((or
term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (-
count temp)) (setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+
count-bytes i))) ((or (not (or term-pager-count
term-scroll-with-delete)) (> (term-handle-scroll 1) 0))
(term-adjust-current-row-cache 1) (setq count (min count term-width))
(setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i))
(setq term-start-line-column term-current-column)) (t (setq count 0
funny i) (setq term-current-column nil) (setq term-start-line-column
nil))) (setq old-point (point)) (let ((old-column (current-column))
columns pos) (insert (decode-coding-string (substring str i funny)
locale-coding-system)) (setq term-current-column (current-column)
columns (- term-current-column old-column)) (if (not (or (eobp)
term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns)
(delete-region pos (point)))) (if term-insert-mode (progn (setq pos
(point)) (end-of-line) (if (> (current-column) term-width) (progn
(delete-region (- (point) (- (current-column) term-width)) (point))))
(goto-char pos)))) (setq term-current-column nil) (put-text-property
old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0)
(term-move-columns -1) (setq term-terminal-state 1))) (setq i (1-
funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count
(term-current-column)) (setq count (min term-width (+ count 8 (- (mod
count 8))))) (if (> term-width count) (progn (term-move-columns (- count
(term-current-column))) (setq term-current-column count)) (if (>
term-width (term-current-column)) (progn (term-move-columns (1- (-
term-width (term-current-column)))))) (if (= term-width
(term-current-column)) (progn (term-move-columns -1))))) ((eq char 13)
(funcall term-vertical-motion 0) (setq term-current-column
term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list
(term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8)
(term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq
char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char
26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if
handled-ansi-message nil (funcall term-command-hook
(decode-coding-string (substring str (1+ i) end) locale-coding-system)))
(setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring
str i)) (setq term-terminal-state 4) (setq i str-length)))) (t
(term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq
term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter
0) (setq term-terminal-previous-parameter -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char
68) (term-handle-deferred-scroll) (term-down 1 t) (setq
term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row)
term-scroll-start) (>= (1- (term-current-row)) term-scroll-start))
(term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char
55) (term-handle-deferred-scroll) (setq term-saved-cursor (list
(term-current-row) (term-horizontal-column) term-ansi-current-bg-color
term-ansi-current-bold term-ansi-current-color
term-ansi-current-invisible term-ansi-current-reverse
term-ansi-current-underline term-current-face)) (setq
term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn
(term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq
term-ansi-current-bg-color (nth 2 term-saved-cursor)
term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color
(nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5
term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor)
term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face
(nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99)
(setq term-terminal-state 0) (term-reset-terminal)) ((setq
term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>=
char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10
term-terminal-parameter) (- char 48)))) ((eq char 59) (setq
term-terminal-more-parameters 1) (setq
term-terminal-previous-parameter-4 term-terminal-previous-parameter-3)
(setq term-terminal-previous-parameter-3
term-terminal-previous-parameter-2) (setq
term-terminal-previous-parameter-2 term-terminal-previous-parameter)
(setq term-terminal-previous-parameter term-terminal-parameter) (setq
term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape
proc char) (setq term-terminal-more-parameters 0) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter -1) (setq term-terminal-state 0)))))
(if term-pager-old-local-map (progn (if (> (% (current-column)
term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0
i) (setq term-terminal-parameter (concat "\015" (substring str i)))
(setq term-terminal-parameter (substring str (1- i))) (aset
term-terminal-parameter 0 13)) (goto-char (point-max))) (setq
term-terminal-state 4) (make-local-variable 'term-pager-old-filter)
(setq term-pager-old-filter (process-filter proc)) (set-process-filter
proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>=
(term-current-row) term-height) (progn (term-handle-deferred-scroll)))
(set-marker (process-mark proc) (point)) (if save-point (progn
(goto-char save-point) (set-marker save-point nil))) (if (and
term-pending-frame (eq (window-buffer selected) (current-buffer)))
(progn (term-display-line (car term-pending-frame) (cdr
term-pending-frame)) (setq term-pending-frame nil))) (setq win selected)
(while (window-minibuffer-p win) (setq win (next-window win nil t)))
(setq last-win win) (while (progn (setq win (next-window win nil t)) (if
(eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll
term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point)
save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or
(eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq
selected win)))) (progn (goto-char term-home-marker) (recenter 0)
(goto-char (process-mark proc)) (if (not (pos-visible-in-window-p
(point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output
(>= (point) (process-mark proc))) (progn (save-excursion (goto-char
(point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (>
term-buffer-maximum-size 0) (progn (save-excursion (goto-char
(process-mark (get-buffer-process (current-buffer)))) (forward-line (-
term-buffer-maximum-size)) (beginning-of-line) (delete-region
(point-min) (point))))) (set-marker save-marker nil))
(internal--after-save-selected-window save-selected-window--state))
(save-current-buffer (unwind-protect (progn (let ((newstr
(term-handle-ansi-terminal-messages str))) (if (eq str newstr) nil (setq
handled-ansi-message t str newstr))) (setq str-length (length str)) (if
(marker-buffer term-pending-delete-marker) (progn (delete-region
term-pending-delete-marker (process-mark proc)) (set-marker
term-pending-delete-marker nil))) (if (/= (point) (process-mark proc))
(progn (setq save-point (point-marker)))) (setq term-vertical-motion (if
(eq (window-buffer) (current-buffer)) 'vertical-motion
'term-buffer-vertical-motion)) (setq save-marker (copy-marker
(process-mark proc))) (goto-char (process-mark proc)) (save-restriction
(if (and (> (point-max) (process-mark proc)) (not (eq
(current-local-map) term-raw-map))) (progn (narrow-to-region (point-min)
(process-mark proc)))) (if term-log-buffer (progn (princ str
term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str
(concat term-terminal-undecoded-bytes str)) (setq str-length (length
str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq
term-terminal-state 4) (setq str (concat term-terminal-parameter str))
(setq term-terminal-parameter nil) (setq str-length (length str)) (setq
term-terminal-state 0))) (while (< i str-length) (setq char (aref str
i)) (cond ((< term-terminal-state 2) (setq funny (string-match
"[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn
(setq funny str-length))) (cond ((> funny i) (cond ((eq
term-terminal-state 1) (term-down 1 t) (term-move-columns (-
(term-current-column))) (setq term-terminal-state 0))) (setq
decoded-substring (decode-coding-string (substring str i funny)
locale-coding-system)) (setq count (length decoded-substring)) (if (=
funny str-length) (progn (let ((partial 0)) (while (eq (char-charset
(aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial
(1+ partial))) (if (> partial 0) (progn (setq
term-terminal-undecoded-bytes (substring decoded-substring (- partial)))
(setq decoded-substring (substring decoded-substring 0 (- partial)))
(setq str-length (- str-length partial)) (setq count (- count partial))
(setq funny (- funny partial))))))) (setq temp (- (+
(term-horizontal-column) count) term-width)) (cond ((or
term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (-
count temp)) (setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+
count-bytes i))) ((or (not (or term-pager-count
term-scroll-with-delete)) (> (term-handle-scroll 1) 0))
(term-adjust-current-row-cache 1) (setq count (min count term-width))
(setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i))
(setq term-start-line-column term-current-column)) (t (setq count 0
funny i) (setq term-current-column nil) (setq term-start-line-column
nil))) (setq old-point (point)) (let ((old-column (current-column))
columns pos) (insert (decode-coding-string (substring str i funny)
locale-coding-system)) (setq term-current-column (current-column)
columns (- term-current-column old-column)) (if (not (or (eobp)
term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns)
(delete-region pos (point)))) (if term-insert-mode (progn (setq pos
(point)) (end-of-line) (if (> (current-column) term-width) (progn
(delete-region (- (point) (- (current-column) term-width)) (point))))
(goto-char pos)))) (setq term-current-column nil) (put-text-property
old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0)
(term-move-columns -1) (setq term-terminal-state 1))) (setq i (1-
funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count
(term-current-column)) (setq count (min term-width (+ count 8 (- (mod
count 8))))) (if (> term-width count) (progn (term-move-columns (- count
(term-current-column))) (setq term-current-column count)) (if (>
term-width (term-current-column)) (progn (term-move-columns (1- (-
term-width (term-current-column)))))) (if (= term-width
(term-current-column)) (progn (term-move-columns -1))))) ((eq char 13)
(funcall term-vertical-motion 0) (setq term-current-column
term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list
(term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8)
(term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq
char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char
26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if
handled-ansi-message nil (funcall term-command-hook
(decode-coding-string (substring str (1+ i) end) locale-coding-system)))
(setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring
str i)) (setq term-terminal-state 4) (setq i str-length)))) (t
(term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq
term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter
0) (setq term-terminal-previous-parameter -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char
68) (term-handle-deferred-scroll) (term-down 1 t) (setq
term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row)
term-scroll-start) (>= (1- (term-current-row)) term-scroll-start))
(term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char
55) (term-handle-deferred-scroll) (setq term-saved-cursor (list
(term-current-row) (term-horizontal-column) term-ansi-current-bg-color
term-ansi-current-bold term-ansi-current-color
term-ansi-current-invisible term-ansi-current-reverse
term-ansi-current-underline term-current-face)) (setq
term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn
(term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq
term-ansi-current-bg-color (nth 2 term-saved-cursor)
term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color
(nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5
term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor)
term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face
(nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99)
(setq term-terminal-state 0) (term-reset-terminal)) ((setq
term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>=
char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10
term-terminal-parameter) (- char 48)))) ((eq char 59) (setq
term-terminal-more-parameters 1) (setq
term-terminal-previous-parameter-4 term-terminal-previous-parameter-3)
(setq term-terminal-previous-parameter-3
term-terminal-previous-parameter-2) (setq
term-terminal-previous-parameter-2 term-terminal-previous-parameter)
(setq term-terminal-previous-parameter term-terminal-parameter) (setq
term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape
proc char) (setq term-terminal-more-parameters 0) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter -1) (setq term-terminal-state 0)))))
(if term-pager-old-local-map (progn (if (> (% (current-column)
term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0
i) (setq term-terminal-parameter (concat "\015" (substring str i)))
(setq term-terminal-parameter (substring str (1- i))) (aset
term-terminal-parameter 0 13)) (goto-char (point-max))) (setq
term-terminal-state 4) (make-local-variable 'term-pager-old-filter)
(setq term-pager-old-filter (process-filter proc)) (set-process-filter
proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>=
(term-current-row) term-height) (progn (term-handle-deferred-scroll)))
(set-marker (process-mark proc) (point)) (if save-point (progn
(goto-char save-point) (set-marker save-point nil))) (if (and
term-pending-frame (eq (window-buffer selected) (current-buffer)))
(progn (term-display-line (car term-pending-frame) (cdr
term-pending-frame)) (setq term-pending-frame nil))) (setq win selected)
(while (window-minibuffer-p win) (setq win (next-window win nil t)))
(setq last-win win) (while (progn (setq win (next-window win nil t)) (if
(eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll
term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point)
save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or
(eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq
selected win)))) (progn (goto-char term-home-marker) (recenter 0)
(goto-char (process-mark proc)) (if (not (pos-visible-in-window-p
(point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output
(>= (point) (process-mark proc))) (progn (save-excursion (goto-char
(point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (>
term-buffer-maximum-size 0) (progn (save-excursion (goto-char
(process-mark (get-buffer-process (current-buffer)))) (forward-line (-
term-buffer-maximum-size)) (beginning-of-line) (delete-region
(point-min) (point))))) (set-marker save-marker nil))
(internal--after-save-selected-window save-selected-window--state)))
(let ((save-selected-window--state
(internal--before-save-selected-window))) (save-current-buffer
(unwind-protect (progn (let ((newstr (term-handle-ansi-terminal-messages
str))) (if (eq str newstr) nil (setq handled-ansi-message t str
newstr))) (setq str-length (length str)) (if (marker-buffer
term-pending-delete-marker) (progn (delete-region
term-pending-delete-marker (process-mark proc)) (set-marker
term-pending-delete-marker nil))) (if (/= (point) (process-mark proc))
(progn (setq save-point (point-marker)))) (setq term-vertical-motion (if
(eq (window-buffer) (current-buffer)) 'vertical-motion
'term-buffer-vertical-motion)) (setq save-marker (copy-marker
(process-mark proc))) (goto-char (process-mark proc)) (save-restriction
(if (and (> (point-max) (process-mark proc)) (not (eq
(current-local-map) term-raw-map))) (progn (narrow-to-region (point-min)
(process-mark proc)))) (if term-log-buffer (progn (princ str
term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str
(concat term-terminal-undecoded-bytes str)) (setq str-length (length
str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq
term-terminal-state 4) (setq str (concat term-terminal-parameter str))
(setq term-terminal-parameter nil) (setq str-length (length str)) (setq
term-terminal-state 0))) (while (< i str-length) (setq char (aref str
i)) (cond ((< term-terminal-state 2) (setq funny (string-match
"[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn
(setq funny str-length))) (cond ((> funny i) (cond ((eq
term-terminal-state 1) (term-down 1 t) (term-move-columns (-
(term-current-column))) (setq term-terminal-state 0))) (setq
decoded-substring (decode-coding-string (substring str i funny)
locale-coding-system)) (setq count (length decoded-substring)) (if (=
funny str-length) (progn (let ((partial 0)) (while (eq (char-charset
(aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial
(1+ partial))) (if (> partial 0) (progn (setq
term-terminal-undecoded-bytes (substring decoded-substring (- partial)))
(setq decoded-substring (substring decoded-substring 0 (- partial)))
(setq str-length (- str-length partial)) (setq count (- count partial))
(setq funny (- funny partial))))))) (setq temp (- (+
(term-horizontal-column) count) term-width)) (cond ((or
term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (-
count temp)) (setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+
count-bytes i))) ((or (not (or term-pager-count
term-scroll-with-delete)) (> (term-handle-scroll 1) 0))
(term-adjust-current-row-cache 1) (setq count (min count term-width))
(setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i))
(setq term-start-line-column term-current-column)) (t (setq count 0
funny i) (setq term-current-column nil) (setq term-start-line-column
nil))) (setq old-point (point)) (let ((old-column (current-column))
columns pos) (insert (decode-coding-string (substring str i funny)
locale-coding-system)) (setq term-current-column (current-column)
columns (- term-current-column old-column)) (if (not (or (eobp)
term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns)
(delete-region pos (point)))) (if term-insert-mode (progn (setq pos
(point)) (end-of-line) (if (> (current-column) term-width) (progn
(delete-region (- (point) (- (current-column) term-width)) (point))))
(goto-char pos)))) (setq term-current-column nil) (put-text-property
old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0)
(term-move-columns -1) (setq term-terminal-state 1))) (setq i (1-
funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count
(term-current-column)) (setq count (min term-width (+ count 8 (- (mod
count 8))))) (if (> term-width count) (progn (term-move-columns (- count
(term-current-column))) (setq term-current-column count)) (if (>
term-width (term-current-column)) (progn (term-move-columns (1- (-
term-width (term-current-column)))))) (if (= term-width
(term-current-column)) (progn (term-move-columns -1))))) ((eq char 13)
(funcall term-vertical-motion 0) (setq term-current-column
term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list
(term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8)
(term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq
char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char
26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if
handled-ansi-message nil (funcall term-command-hook
(decode-coding-string (substring str (1+ i) end) locale-coding-system)))
(setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring
str i)) (setq term-terminal-state 4) (setq i str-length)))) (t
(term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq
term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter
0) (setq term-terminal-previous-parameter -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char
68) (term-handle-deferred-scroll) (term-down 1 t) (setq
term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row)
term-scroll-start) (>= (1- (term-current-row)) term-scroll-start))
(term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char
55) (term-handle-deferred-scroll) (setq term-saved-cursor (list
(term-current-row) (term-horizontal-column) term-ansi-current-bg-color
term-ansi-current-bold term-ansi-current-color
term-ansi-current-invisible term-ansi-current-reverse
term-ansi-current-underline term-current-face)) (setq
term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn
(term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq
term-ansi-current-bg-color (nth 2 term-saved-cursor)
term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color
(nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5
term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor)
term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face
(nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99)
(setq term-terminal-state 0) (term-reset-terminal)) ((setq
term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>=
char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10
term-terminal-parameter) (- char 48)))) ((eq char 59) (setq
term-terminal-more-parameters 1) (setq
term-terminal-previous-parameter-4 term-terminal-previous-parameter-3)
(setq term-terminal-previous-parameter-3
term-terminal-previous-parameter-2) (setq
term-terminal-previous-parameter-2 term-terminal-previous-parameter)
(setq term-terminal-previous-parameter term-terminal-parameter) (setq
term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape
proc char) (setq term-terminal-more-parameters 0) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter -1) (setq term-terminal-state 0)))))
(if term-pager-old-local-map (progn (if (> (% (current-column)
term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0
i) (setq term-terminal-parameter (concat "\015" (substring str i)))
(setq term-terminal-parameter (substring str (1- i))) (aset
term-terminal-parameter 0 13)) (goto-char (point-max))) (setq
term-terminal-state 4) (make-local-variable 'term-pager-old-filter)
(setq term-pager-old-filter (process-filter proc)) (set-process-filter
proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>=
(term-current-row) term-height) (progn (term-handle-deferred-scroll)))
(set-marker (process-mark proc) (point)) (if save-point (progn
(goto-char save-point) (set-marker save-point nil))) (if (and
term-pending-frame (eq (window-buffer selected) (current-buffer)))
(progn (term-display-line (car term-pending-frame) (cdr
term-pending-frame)) (setq term-pending-frame nil))) (setq win selected)
(while (window-minibuffer-p win) (setq win (next-window win nil t)))
(setq last-win win) (while (progn (setq win (next-window win nil t)) (if
(eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll
term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point)
save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or
(eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq
selected win)))) (progn (goto-char term-home-marker) (recenter 0)
(goto-char (process-mark proc)) (if (not (pos-visible-in-window-p
(point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output
(>= (point) (process-mark proc))) (progn (save-excursion (goto-char
(point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (>
term-buffer-maximum-size 0) (progn (save-excursion (goto-char
(process-mark (get-buffer-process (current-buffer)))) (forward-line (-
term-buffer-maximum-size)) (beginning-of-line) (delete-region
(point-min) (point))))) (set-marker save-marker nil))
(internal--after-save-selected-window save-selected-window--state))))
(let* ((i 0) char funny count count-bytes decoded-substring save-point
save-marker old-point temp win (inhibit-read-only t) (buffer-undo-list
t) (selected (selected-window)) last-win handled-ansi-message
(str-length (length str))) (let ((save-selected-window--state
(internal--before-save-selected-window))) (save-current-buffer
(unwind-protect (progn (let ((newstr (term-handle-ansi-terminal-messages
str))) (if (eq str newstr) nil (setq handled-ansi-message t str
newstr))) (setq str-length (length str)) (if (marker-buffer
term-pending-delete-marker) (progn (delete-region
term-pending-delete-marker (process-mark proc)) (set-marker
term-pending-delete-marker nil))) (if (/= (point) (process-mark proc))
(progn (setq save-point (point-marker)))) (setq term-vertical-motion (if
(eq (window-buffer) (current-buffer)) 'vertical-motion
'term-buffer-vertical-motion)) (setq save-marker (copy-marker
(process-mark proc))) (goto-char (process-mark proc)) (save-restriction
(if (and (> (point-max) (process-mark proc)) (not (eq
(current-local-map) term-raw-map))) (progn (narrow-to-region (point-min)
(process-mark proc)))) (if term-log-buffer (progn (princ str
term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str
(concat term-terminal-undecoded-bytes str)) (setq str-length (length
str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq
term-terminal-state 4) (setq str (concat term-terminal-parameter str))
(setq term-terminal-parameter nil) (setq str-length (length str)) (setq
term-terminal-state 0))) (while (< i str-length) (setq char (aref str
i)) (cond ((< term-terminal-state 2) (setq funny (string-match
"[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn
(setq funny str-length))) (cond ((> funny i) (cond ((eq
term-terminal-state 1) (term-down 1 t) (term-move-columns (-
(term-current-column))) (setq term-terminal-state 0))) (setq
decoded-substring (decode-coding-string (substring str i funny)
locale-coding-system)) (setq count (length decoded-substring)) (if (=
funny str-length) (progn (let ((partial 0)) (while (eq (char-charset
(aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial
(1+ partial))) (if (> partial 0) (progn (setq
term-terminal-undecoded-bytes (substring decoded-substring (- partial)))
(setq decoded-substring (substring decoded-substring 0 (- partial)))
(setq str-length (- str-length partial)) (setq count (- count partial))
(setq funny (- funny partial))))))) (setq temp (- (+
(term-horizontal-column) count) term-width)) (cond ((or
term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (-
count temp)) (setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+
count-bytes i))) ((or (not (or term-pager-count
term-scroll-with-delete)) (> (term-handle-scroll 1) 0))
(term-adjust-current-row-cache 1) (setq count (min count term-width))
(setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i))
(setq term-start-line-column term-current-column)) (t (setq count 0
funny i) (setq term-current-column nil) (setq term-start-line-column
nil))) (setq old-point (point)) (let ((old-column (current-column))
columns pos) (insert (decode-coding-string (substring str i funny)
locale-coding-system)) (setq term-current-column (current-column)
columns (- term-current-column old-column)) (if (not (or (eobp)
term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns)
(delete-region pos (point)))) (if term-insert-mode (progn (setq pos
(point)) (end-of-line) (if (> (current-column) term-width) (progn
(delete-region (- (point) (- (current-column) term-width)) (point))))
(goto-char pos)))) (setq term-current-column nil) (put-text-property
old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0)
(term-move-columns -1) (setq term-terminal-state 1))) (setq i (1-
funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count
(term-current-column)) (setq count (min term-width (+ count 8 (- (mod
count 8))))) (if (> term-width count) (progn (term-move-columns (- count
(term-current-column))) (setq term-current-column count)) (if (>
term-width (term-current-column)) (progn (term-move-columns (1- (-
term-width (term-current-column)))))) (if (= term-width
(term-current-column)) (progn (term-move-columns -1))))) ((eq char 13)
(funcall term-vertical-motion 0) (setq term-current-column
term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list
(term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8)
(term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq
char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char
26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if
handled-ansi-message nil (funcall term-command-hook
(decode-coding-string (substring str (1+ i) end) locale-coding-system)))
(setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring
str i)) (setq term-terminal-state 4) (setq i str-length)))) (t
(term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq
term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter
0) (setq term-terminal-previous-parameter -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char
68) (term-handle-deferred-scroll) (term-down 1 t) (setq
term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row)
term-scroll-start) (>= (1- (term-current-row)) term-scroll-start))
(term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char
55) (term-handle-deferred-scroll) (setq term-saved-cursor (list
(term-current-row) (term-horizontal-column) term-ansi-current-bg-color
term-ansi-current-bold term-ansi-current-color
term-ansi-current-invisible term-ansi-current-reverse
term-ansi-current-underline term-current-face)) (setq
term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn
(term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq
term-ansi-current-bg-color (nth 2 term-saved-cursor)
term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color
(nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5
term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor)
term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face
(nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99)
(setq term-terminal-state 0) (term-reset-terminal)) ((setq
term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>=
char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10
term-terminal-parameter) (- char 48)))) ((eq char 59) (setq
term-terminal-more-parameters 1) (setq
term-terminal-previous-parameter-4 term-terminal-previous-parameter-3)
(setq term-terminal-previous-parameter-3
term-terminal-previous-parameter-2) (setq
term-terminal-previous-parameter-2 term-terminal-previous-parameter)
(setq term-terminal-previous-parameter term-terminal-parameter) (setq
term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape
proc char) (setq term-terminal-more-parameters 0) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter -1) (setq term-terminal-state 0)))))
(if term-pager-old-local-map (progn (if (> (% (current-column)
term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0
i) (setq term-terminal-parameter (concat "\015" (substring str i)))
(setq term-terminal-parameter (substring str (1- i))) (aset
term-terminal-parameter 0 13)) (goto-char (point-max))) (setq
term-terminal-state 4) (make-local-variable 'term-pager-old-filter)
(setq term-pager-old-filter (process-filter proc)) (set-process-filter
proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>=
(term-current-row) term-height) (progn (term-handle-deferred-scroll)))
(set-marker (process-mark proc) (point)) (if save-point (progn
(goto-char save-point) (set-marker save-point nil))) (if (and
term-pending-frame (eq (window-buffer selected) (current-buffer)))
(progn (term-display-line (car term-pending-frame) (cdr
term-pending-frame)) (setq term-pending-frame nil))) (setq win selected)
(while (window-minibuffer-p win) (setq win (next-window win nil t)))
(setq last-win win) (while (progn (setq win (next-window win nil t)) (if
(eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll
term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point)
save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or
(eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq
selected win)))) (progn (goto-char term-home-marker) (recenter 0)
(goto-char (process-mark proc)) (if (not (pos-visible-in-window-p
(point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output
(>= (point) (process-mark proc))) (progn (save-excursion (goto-char
(point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (>
term-buffer-maximum-size 0) (progn (save-excursion (goto-char
(process-mark (get-buffer-process (current-buffer)))) (forward-line (-
term-buffer-maximum-size)) (beginning-of-line) (delete-region
(point-min) (point))))) (set-marker save-marker nil))
(internal--after-save-selected-window save-selected-window--state)))))
(save-current-buffer (set-buffer (process-buffer proc)) (let* ((i 0)
char funny count count-bytes decoded-substring save-point save-marker
old-point temp win (inhibit-read-only t) (buffer-undo-list t) (selected
(selected-window)) last-win handled-ansi-message (str-length (length
str))) (let ((save-selected-window--state
(internal--before-save-selected-window))) (save-current-buffer
(unwind-protect (progn (let ((newstr (term-handle-ansi-terminal-messages
str))) (if (eq str newstr) nil (setq handled-ansi-message t str
newstr))) (setq str-length (length str)) (if (marker-buffer
term-pending-delete-marker) (progn (delete-region
term-pending-delete-marker (process-mark proc)) (set-marker
term-pending-delete-marker nil))) (if (/= (point) (process-mark proc))
(progn (setq save-point (point-marker)))) (setq term-vertical-motion (if
(eq (window-buffer) (current-buffer)) 'vertical-motion
'term-buffer-vertical-motion)) (setq save-marker (copy-marker
(process-mark proc))) (goto-char (process-mark proc)) (save-restriction
(if (and (> (point-max) (process-mark proc)) (not (eq
(current-local-map) term-raw-map))) (progn (narrow-to-region (point-min)
(process-mark proc)))) (if term-log-buffer (progn (princ str
term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str
(concat term-terminal-undecoded-bytes str)) (setq str-length (length
str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq
term-terminal-state 4) (setq str (concat term-terminal-parameter str))
(setq term-terminal-parameter nil) (setq str-length (length str)) (setq
term-terminal-state 0))) (while (< i str-length) (setq char (aref str
i)) (cond ((< term-terminal-state 2) (setq funny (string-match
"[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn
(setq funny str-length))) (cond ((> funny i) (cond ((eq
term-terminal-state 1) (term-down 1 t) (term-move-columns (-
(term-current-column))) (setq term-terminal-state 0))) (setq
decoded-substring (decode-coding-string (substring str i funny)
locale-coding-system)) (setq count (length decoded-substring)) (if (=
funny str-length) (progn (let ((partial 0)) (while (eq (char-charset
(aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial
(1+ partial))) (if (> partial 0) (progn (setq
term-terminal-undecoded-bytes (substring decoded-substring (- partial)))
(setq decoded-substring (substring decoded-substring 0 (- partial)))
(setq str-length (- str-length partial)) (setq count (- count partial))
(setq funny (- funny partial))))))) (setq temp (- (+
(term-horizontal-column) count) term-width)) (cond ((or
term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (-
count temp)) (setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+
count-bytes i))) ((or (not (or term-pager-count
term-scroll-with-delete)) (> (term-handle-scroll 1) 0))
(term-adjust-current-row-cache 1) (setq count (min count term-width))
(setq count-bytes (length (encode-coding-string (substring
decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i))
(setq term-start-line-column term-current-column)) (t (setq count 0
funny i) (setq term-current-column nil) (setq term-start-line-column
nil))) (setq old-point (point)) (let ((old-column (current-column))
columns pos) (insert (decode-coding-string (substring str i funny)
locale-coding-system)) (setq term-current-column (current-column)
columns (- term-current-column old-column)) (if (not (or (eobp)
term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns)
(delete-region pos (point)))) (if term-insert-mode (progn (setq pos
(point)) (end-of-line) (if (> (current-column) term-width) (progn
(delete-region (- (point) (- (current-column) term-width)) (point))))
(goto-char pos)))) (setq term-current-column nil) (put-text-property
old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0)
(term-move-columns -1) (setq term-terminal-state 1))) (setq i (1-
funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count
(term-current-column)) (setq count (min term-width (+ count 8 (- (mod
count 8))))) (if (> term-width count) (progn (term-move-columns (- count
(term-current-column))) (setq term-current-column count)) (if (>
term-width (term-current-column)) (progn (term-move-columns (1- (-
term-width (term-current-column)))))) (if (= term-width
(term-current-column)) (progn (term-move-columns -1))))) ((eq char 13)
(funcall term-vertical-motion 0) (setq term-current-column
term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list
(term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8)
(term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq
char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char
26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if
handled-ansi-message nil (funcall term-command-hook
(decode-coding-string (substring str (1+ i) end) locale-coding-system)))
(setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring
str i)) (setq term-terminal-state 4) (setq i str-length)))) (t
(term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq
term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter
0) (setq term-terminal-previous-parameter -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char
68) (term-handle-deferred-scroll) (term-down 1 t) (setq
term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row)
term-scroll-start) (>= (1- (term-current-row)) term-scroll-start))
(term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char
55) (term-handle-deferred-scroll) (setq term-saved-cursor (list
(term-current-row) (term-horizontal-column) term-ansi-current-bg-color
term-ansi-current-bold term-ansi-current-color
term-ansi-current-invisible term-ansi-current-reverse
term-ansi-current-underline term-current-face)) (setq
term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn
(term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq
term-ansi-current-bg-color (nth 2 term-saved-cursor)
term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color
(nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5
term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor)
term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face
(nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99)
(setq term-terminal-state 0) (term-reset-terminal)) ((setq
term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>=
char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10
term-terminal-parameter) (- char 48)))) ((eq char 59) (setq
term-terminal-more-parameters 1) (setq
term-terminal-previous-parameter-4 term-terminal-previous-parameter-3)
(setq term-terminal-previous-parameter-3
term-terminal-previous-parameter-2) (setq
term-terminal-previous-parameter-2 term-terminal-previous-parameter)
(setq term-terminal-previous-parameter term-terminal-parameter) (setq
term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape
proc char) (setq term-terminal-more-parameters 0) (setq
term-terminal-previous-parameter-4 -1) (setq
term-terminal-previous-parameter-3 -1) (setq
term-terminal-previous-parameter-2 -1) (setq
term-terminal-previous-parameter -1) (setq term-terminal-state 0)))))
(if term-pager-old-local-map (progn (if (> (% (current-column)
term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0
i) (setq term-terminal-parameter (concat "\015" (substring str i)))
(setq term-terminal-parameter (substring str (1- i))) (aset
term-terminal-parameter 0 13)) (goto-char (point-max))) (setq
term-terminal-state 4) (make-local-variable 'term-pager-old-filter)
(setq term-pager-old-filter (process-filter proc)) (set-process-filter
proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>=
(term-current-row) term-height) (progn (term-handle-deferred-scroll)))
(set-marker (process-mark proc) (point)) (if save-point (progn
(goto-char save-point) (set-marker save-point nil))) (if (and
term-pending-frame (eq (window-buffer selected) (current-buffer)))
(progn (term-display-line (car term-pending-frame) (cdr
term-pending-frame)) (setq term-pending-frame nil))) (setq win selected)
(while (window-minibuffer-p win) (setq win (next-window win nil t)))
(setq last-win win) (while (progn (setq win (next-window win nil t)) (if
(eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll
term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point)
save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or
(eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq
selected win)))) (progn (goto-char term-home-marker) (recenter 0)
(goto-char (process-mark proc)) (if (not (pos-visible-in-window-p
(point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output
(>= (point) (process-mark proc))) (progn (save-excursion (goto-char
(point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (>
term-buffer-maximum-size 0) (progn (save-excursion (goto-char
(process-mark (get-buffer-process (current-buffer)))) (forward-line (-
term-buffer-maximum-size)) (beginning-of-line) (delete-region
(point-min) (point))))) (set-marker save-marker nil))
(internal--after-save-selected-window save-selected-window--state)))))
(if (get-buffer-window (current-buffer)) (progn (redisplay))))
term-emulate-terminal(#<process terminal> "\015\033[K$
\015\n\032//home/phil/emacs/26/26.1rc1/usr/local/share/emacs/26.1/lisp\015\n")
next prev parent reply other threads:[~2018-04-18 1:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 13:00 bug#31193: 26.1; error in `term-down' after window configuration change Phil Sainty
2018-04-17 13:23 ` Noam Postavsky
2018-04-17 13:49 ` Phil Sainty
2018-04-18 0:07 ` Noam Postavsky
2018-04-18 1:04 ` Phil Sainty [this message]
2018-04-18 2:04 ` Noam Postavsky
2018-04-18 4:23 ` Phil Sainty
2018-04-18 12:15 ` Noam Postavsky
2018-04-18 5:05 ` Phil Sainty
2018-04-18 5:37 ` Phil Sainty
2018-04-18 6:25 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=032fbfe050521617bf7b8c9a76479a16@webmail.orcon.net.nz \
--to=psainty@orcon.net.nz \
--cc=31193@debbugs.gnu.org \
--cc=bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org \
--cc=npostavs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).