From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.bugs Subject: bug#31193: 26.1; error in `term-down' after window configuration change Date: Wed, 18 Apr 2018 13:04:13 +1200 Message-ID: <032fbfe050521617bf7b8c9a76479a16@webmail.orcon.net.nz> References: <5480f11459b73e4cf0aabe12da5ce675@webmail.orcon.net.nz> <87sh7ut199.fsf@gmail.com> <7063321d07dcc711cc24699e095dfb9d@webmail.orcon.net.nz> <87muy1tm0i.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1524013404 26388 195.159.176.226 (18 Apr 2018 01:03:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 18 Apr 2018 01:03:24 +0000 (UTC) User-Agent: Orcon Webmail Cc: 31193@debbugs.gnu.org, bug-gnu-emacs To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 18 03:03:20 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8bVH-0006lH-Ae for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Apr 2018 03:03:19 +0200 Original-Received: from localhost ([::1]:46843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8bXM-0006Fv-Gg for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Apr 2018 21:05:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8bX4-000681-OT for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 21:05:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8bWw-00023p-DL for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 21:05:10 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f8bWw-00023e-5m for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 21:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f8bWv-0003qX-R3 for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 21:05:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Phil Sainty Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Apr 2018 01:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31193 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 31193-submit@debbugs.gnu.org id=B31193.152401346714693 (code B ref 31193); Wed, 18 Apr 2018 01:05:01 +0000 Original-Received: (at 31193) by debbugs.gnu.org; 18 Apr 2018 01:04:27 +0000 Original-Received: from localhost ([127.0.0.1]:58276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8bWK-0003os-Hq for submit@debbugs.gnu.org; Tue, 17 Apr 2018 21:04:27 -0400 Original-Received: from smtp-2.orcon.net.nz ([60.234.4.43]:53088) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8bWG-0003oe-S0 for 31193@debbugs.gnu.org; Tue, 17 Apr 2018 21:04:24 -0400 Original-Received: from [10.253.37.70] (port=54406 helo=webmail.orcon.net.nz) by smtp-2.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1f8bWA-0002Sq-BF; Wed, 18 Apr 2018 13:04:18 +1200 Original-Received: from wlgwil-nat-office.catalyst.net.nz ([202.78.240.7]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Wed, 18 Apr 2018 13:04:13 +1200 In-Reply-To: <87muy1tm0i.fsf@gmail.com> X-Sender: psainty@orcon.net.nz X-GeoIP: -- X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:145543 Archived-At: 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(# "\015\033[K$ \015\n\032//home/phil/emacs/26/26.1rc1/usr/local/share/emacs/26.1/lisp\015\n")