/[emacs]/emacs/lisp/term.el
ViewVC logotype

Diff of /emacs/lisp/term.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.47.2.6 by miles, Thu Sep 16 00:12:21 2004 UTC revision 1.47.2.7 by miles, Wed Oct 6 05:21:52 2004 UTC
# Line 396  Line 396 
396    
397  ;; This is passed to the inferior in the EMACS environment variable,  ;; This is passed to the inferior in the EMACS environment variable,
398  ;; so it is important to increase it if there are protocol-relevant changes.  ;; so it is important to increase it if there are protocol-relevant changes.
399  (defconst term-protocol-version "0.95")  (defconst term-protocol-version "0.96")
400    
401  (eval-when-compile  (eval-when-compile
402    (require 'ange-ftp))    (require 'ange-ftp))
# Line 457  Line 457 
457  ;;              we want suppressed.  ;;              we want suppressed.
458  (defvar term-terminal-parameter)  (defvar term-terminal-parameter)
459  (defvar term-terminal-previous-parameter)  (defvar term-terminal-previous-parameter)
460  (defvar term-current-face 'term-default)  (defvar term-current-face 'default)
461  (defvar term-scroll-start 0) ;; Top-most line (inclusive) of scrolling region.  (defvar term-scroll-start 0) ;; Top-most line (inclusive) of scrolling region.
462  (defvar term-scroll-end) ;; Number of line (zero-based) after scrolling region.  (defvar term-scroll-end) ;; Number of line (zero-based) after scrolling region.
463  (defvar term-pager-count nil) ;; If nil, paging is disabled.  (defvar term-pager-count nil) ;; If nil, paging is disabled.
# Line 1365  The main purpose is to get rid of the lo Line 1365  The main purpose is to get rid of the lo
1365  (defvar term-termcap-format  (defvar term-termcap-format
1366    "%s%s:li#%d:co#%d:cl=\\E[H\\E[J:cd=\\E[J:bs:am:xn:cm=\\E[%%i%%d;%%dH\    "%s%s:li#%d:co#%d:cl=\\E[H\\E[J:cd=\\E[J:bs:am:xn:cm=\\E[%%i%%d;%%dH\
1367  :nd=\\E[C:up=\\E[A:ce=\\E[K:ho=\\E[H:pt\  :nd=\\E[C:up=\\E[A:ce=\\E[K:ho=\\E[H:pt\
1368  :al=\\E[L:dl=\\E[M:DL=\\E[%%dM:AL=\\E[%%dL:cs=\\E[%%i%%d;%%dr:sf=\\n\  :al=\\E[L:dl=\\E[M:DL=\\E[%%dM:AL=\\E[%%dL:cs=\\E[%%i%%d;%%dr:sf=^J\
1369  :te=\\E[2J\\E[?47l\\E8:ti=\\E7\\E[?47h\  :te=\\E[2J\\E[?47l\\E8:ti=\\E7\\E[?47h\
1370  :dc=\\E[P:DC=\\E[%%dP:IC=\\E[%%d@:im=\\E[4h:ei=\\E[4l:mi:\  :dc=\\E[P:DC=\\E[%%dP:IC=\\E[%%d@:im=\\E[4h:ei=\\E[4l:mi:\
1371  :so=\\E[7m:se=\\E[m:us=\\E[4m:ue=\\E[m:md=\\E[1m:mr=\\E[7m:me=\\E[m\  :so=\\E[7m:se=\\E[m:us=\\E[4m:ue=\\E[m:md=\\E[1m:mr=\\E[7m:me=\\E[m\
1372  :UP=\\E[%%dA:DO=\\E[%%dB:LE=\\E[%%dD:RI=\\E[%%dC"  :UP=\\E[%%dA:DO=\\E[%%dB:LE=\\E[%%dD:RI=\\E[%%dC\
1373    :kl=\\EOD:kd=\\EOB:kr=\\EOC:ku=\\EOA:kN=\\E[6~:kP=\\E[5~:@7=\\E[4~:kh=\\E[1~\
1374    :mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#8:pa#64:AB=\\E[4%%dm:AF=\\E[3%%dm:cr=^M\
1375    :bl=^G:do=^J:le=^H:ta=^I:se=\E[27m:ue=\E24m:"
1376  ;;; : -undefine ic  ;;; : -undefine ic
1377    "termcap capabilities supported")    "termcap capabilities supported")
1378    
# Line 1386  The main purpose is to get rid of the lo Line 1389  The main purpose is to get rid of the lo
1389           (nconc           (nconc
1390            (list            (list
1391             (format "TERM=%s" term-term-name)             (format "TERM=%s" term-term-name)
1392             (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)             (format "TERMINFO=%s" data-directory)
1393                 (format "TERMINFO=%s" data-directory)             (format term-termcap-format "TERMCAP="
1394              (format term-termcap-format "TERMCAP="                     term-term-name term-height term-width)
                     term-term-name term-height term-width))  
1395             ;; Breaks `./configure' of w3 and url which try to run $EMACS.             ;; Breaks `./configure' of w3 and url which try to run $EMACS.
1396             (format "EMACS=%s (term:%s)" emacs-version term-protocol-version)             (format "EMACS=%s (term:%s)" emacs-version term-protocol-version)
1397             (format "LINES=%d" term-height)             (format "LINES=%d" term-height)
# Line 1409  if [ $1 = .. ]; then shift; fi; exec \"$ Line 1411  if [ $1 = .. ]; then shift; fi; exec \"$
1411             ".."             ".."
1412             command switches)))             command switches)))
1413    
 ;;; This should be in Emacs, but it isn't.  
 (defun term-mem (item list &optional elt=)  
   "Test to see if ITEM is equal to an item in LIST.  
 Option comparison function ELT= defaults to equal."  
   (let ((elt= (or elt= (function equal)))  
         (done nil))  
     (while (and list (not done))  
       (if (funcall elt= item (car list))  
           (setq done list)  
           (setq list (cdr list))))  
     done))  
   
1414    
1415  ;;; Input history processing in a buffer  ;;; Input history processing in a buffer
1416  ;;; ===========================================================================  ;;; ===========================================================================
# Line 2645  See `term-prompt-regexp'." Line 2635  See `term-prompt-regexp'."
2635  ;;; It emulates (most of the features of) a VT100/ANSI-style terminal.  ;;; It emulates (most of the features of) a VT100/ANSI-style terminal.
2636    
2637  (defun term-emulate-terminal (proc str)  (defun term-emulate-terminal (proc str)
2638    (let* ((previous-buffer (current-buffer))    (with-current-buffer (process-buffer proc)
2639           (i 0) char funny count save-point save-marker old-point temp win      (let* ((i 0) char funny count save-point save-marker old-point temp win
2640           (selected (selected-window))             (buffer-undo-list t)
2641           last-win             (selected (selected-window))
2642           (str-length (length str)))             last-win
2643      (unwind-protect             (str-length (length str)))
2644          (progn        (save-selected-window
           (set-buffer (process-buffer proc))  
2645    
2646  ;;; Let's handle the messages. -mm          ;; Let's handle the messages. -mm
2647    
2648            (setq str (term-handle-ansi-terminal-messages str))          (setq str (term-handle-ansi-terminal-messages str))
2649            (setq str-length (length str))          (setq str-length (length str))
2650    
2651            (if (marker-buffer term-pending-delete-marker)          (if (marker-buffer term-pending-delete-marker)
2652                (progn              (progn
2653                  ;; Delete text following term-pending-delete-marker.                ;; Delete text following term-pending-delete-marker.
2654                  (delete-region term-pending-delete-marker (process-mark proc))                (delete-region term-pending-delete-marker (process-mark proc))
2655                  (set-marker term-pending-delete-marker nil)))                (set-marker term-pending-delete-marker nil)))
2656    
2657            (if (eq (window-buffer) (current-buffer))          (if (eq (window-buffer) (current-buffer))
2658                (progn              (progn
2659                  (setq term-vertical-motion (symbol-function 'vertical-motion))                (setq term-vertical-motion (symbol-function 'vertical-motion))
2660                  (term-check-size proc))                (term-check-size proc))
2661              (setq term-vertical-motion            (setq term-vertical-motion
2662                    (symbol-function 'buffer-vertical-motion)))                  (symbol-function 'buffer-vertical-motion)))
2663    
2664            (setq save-marker (copy-marker (process-mark proc)))          (setq save-marker (copy-marker (process-mark proc)))
2665    
2666            (if (/= (point) (process-mark proc))          (if (/= (point) (process-mark proc))
2667                (progn (setq save-point (point-marker))              (progn (setq save-point (point-marker))
2668                       (goto-char (process-mark proc))))                     (goto-char (process-mark proc))))
2669    
2670            (save-restriction          (save-restriction
2671              ;; If the buffer is in line mode, and there is a partial            ;; If the buffer is in line mode, and there is a partial
2672              ;; input line, save the line (by narrowing to leave it            ;; input line, save the line (by narrowing to leave it
2673              ;; outside the restriction ) until we're done with output.            ;; outside the restriction ) until we're done with output.
2674              (if (and (> (point-max) (process-mark proc))            (if (and (> (point-max) (process-mark proc))
2675                       (term-in-line-mode))                     (term-in-line-mode))
2676                  (narrow-to-region (point-min) (process-mark proc)))                (narrow-to-region (point-min) (process-mark proc)))
2677    
2678              (if term-log-buffer            (if term-log-buffer
2679                  (princ str term-log-buffer))                (princ str term-log-buffer))
2680              (cond ((eq term-terminal-state 4) ;; Have saved pending output.            (cond ((eq term-terminal-state 4) ;; Have saved pending output.
2681                     (setq str (concat term-terminal-parameter str))                   (setq str (concat term-terminal-parameter str))
2682                     (setq term-terminal-parameter nil)                   (setq term-terminal-parameter nil)
2683                     (setq str-length (length str))                   (setq str-length (length str))
2684                     (setq term-terminal-state 0)))                   (setq term-terminal-state 0)))
2685    
2686              (while (< i str-length)            (while (< i str-length)
2687                (setq char (aref str i))              (setq char (aref str i))
2688                (cond ((< term-terminal-state 2)              (cond ((< term-terminal-state 2)
2689                       ;; Look for prefix of regular chars                     ;; Look for prefix of regular chars
2690                       (setq funny                     (setq funny
2691                             (string-match "[\r\n\000\007\033\t\b\032\016\017]"                           (string-match "[\r\n\000\007\033\t\b\032\016\017]"
2692                                           str i))                                         str i))
2693                       (if (not funny) (setq funny str-length))                     (if (not funny) (setq funny str-length))
2694                       (cond ((> funny i)                     (cond ((> funny i)
2695                              (cond ((eq term-terminal-state 1)                            (cond ((eq term-terminal-state 1)
2696                                     (term-move-columns 1)                                   (term-move-columns 1)
2697                                     (setq term-terminal-state 0)))                                   (setq term-terminal-state 0)))
2698                              (setq count (- funny i))                            (setq count (- funny i))
2699                              (setq temp (- (+ (term-horizontal-column) count)                            (setq temp (- (+ (term-horizontal-column) count)
2700                                            term-width))                                          term-width))
2701                              (cond ((<= temp 0)) ;; All count chars fit in line.                            (cond ((<= temp 0)) ;; All count chars fit in line.
2702                                    ((> count temp) ;; Some chars fit.                                  ((> count temp) ;; Some chars fit.
2703                                     ;; This iteration, handle only what fits.                                   ;; This iteration, handle only what fits.
2704                                     (setq count (- count temp))                                   (setq count (- count temp))
2705                                     (setq funny (+ count i)))                                   (setq funny (+ count i)))
2706                                    ((or (not (or term-pager-count                                  ((or (not (or term-pager-count
2707                                                  term-scroll-with-delete))                                                term-scroll-with-delete))
2708                                         (>  (term-handle-scroll 1) 0))                                       (>  (term-handle-scroll 1) 0))
2709                                     (term-adjust-current-row-cache 1)                                   (term-adjust-current-row-cache 1)
2710                                     (setq count (min count term-width))                                   (setq count (min count term-width))
2711                                     (setq funny (+ count i))                                   (setq funny (+ count i))
2712                                     (setq term-start-line-column                                   (setq term-start-line-column
2713                                           term-current-column))                                         term-current-column))
2714                                    (t ;; Doing PAGER processing.                                  (t ;; Doing PAGER processing.
2715                                     (setq count 0 funny i)                                   (setq count 0 funny i)
2716                                     (setq term-current-column nil)                                   (setq term-current-column nil)
2717                                     (setq term-start-line-column nil)))                                   (setq term-start-line-column nil)))
2718                              (setq old-point (point))                            (setq old-point (point))
2719    
2720                              ;; Insert a string, check how many columns                            ;; Insert a string, check how many columns
2721                              ;; we moved, then delete that many columns                            ;; we moved, then delete that many columns
2722                              ;; following point if not eob nor insert-mode.                            ;; following point if not eob nor insert-mode.
2723                              (let ((old-column (current-column))                            (let ((old-column (current-column))
2724                                    columns pos)                                  columns pos)
2725                                (insert (substring str i funny))                              (insert (substring str i funny))
2726                                (setq term-current-column (current-column)                              (setq term-current-column (current-column)
2727                                      columns (- term-current-column old-column))                                    columns (- term-current-column old-column))
2728                                (when (not (or (eobp) term-insert-mode))                              (when (not (or (eobp) term-insert-mode))
2729                                  (setq pos (point))                                (setq pos (point))
2730                                  (term-move-columns columns)                                (term-move-columns columns)
2731                                  (delete-region pos (point))))                                (delete-region pos (point))))
2732                              (setq term-current-column nil)                            (setq term-current-column nil)
2733    
2734                              (put-text-property old-point (point)                            (put-text-property old-point (point)
2735                                                 'face term-current-face)                                               'face term-current-face)
2736                              ;; If the last char was written in last column,                            ;; If the last char was written in last column,
2737                              ;; back up one column, but remember we did so.                            ;; back up one column, but remember we did so.
2738                              ;; Thus we emulate xterm/vt100-style line-wrapping.                            ;; Thus we emulate xterm/vt100-style line-wrapping.
2739                              (cond ((eq temp 0)                            (cond ((eq temp 0)
2740                                     (term-move-columns -1)                                   (term-move-columns -1)
2741                                     (setq term-terminal-state 1)))                                   (setq term-terminal-state 1)))
2742                              (setq i (1- funny)))                            (setq i (1- funny)))
2743                             ((and (setq term-terminal-state 0)                           ((and (setq term-terminal-state 0)
2744                              (eq char ?\^I)) ; TAB                                 (eq char ?\^I)) ; TAB
2745                              ;; FIXME:  Does not handle line wrap!                            ;; FIXME:  Does not handle line wrap!
2746                              (setq count (term-current-column))                            (setq count (term-current-column))
2747                              (setq count (+ count 8 (- (mod count 8))))                            (setq count (+ count 8 (- (mod count 8))))
2748                              (if (< (move-to-column count nil) count)                            (if (< (move-to-column count nil) count)
2749                                  (term-insert-char char 1))                                (term-insert-char char 1))
2750                              (setq term-current-column count))                            (setq term-current-column count))
2751                             ((eq char ?\r)                           ((eq char ?\r)
2752                              ;; Optimize CRLF at end of buffer:                            ;; Optimize CRLF at end of buffer:
2753                              (cond ((and (< (setq temp (1+ i)) str-length)                            (cond ((and (< (setq temp (1+ i)) str-length)
2754                                          (eq (aref str temp) ?\n)                                        (eq (aref str temp) ?\n)
2755                                          (= (point) (point-max))                                        (= (point) (point-max))
2756                                          (not (or term-pager-count                                        (not (or term-pager-count
2757                                                   term-kill-echo-list                                                 term-kill-echo-list
2758                                                   term-scroll-with-delete)))                                                 term-scroll-with-delete)))
2759                                     (insert ?\n)                                   (insert ?\n)
2760                                     (term-adjust-current-row-cache 1)                                   (term-adjust-current-row-cache 1)
2761                                     (setq term-start-line-column 0)                                   (setq term-start-line-column 0)
2762                                     (setq term-current-column 0)                                   (setq term-current-column 0)
2763                                     (setq i temp))                                   (setq i temp))
2764                                    (t ;; Not followed by LF or can't optimize:                                  (t ;; Not followed by LF or can't optimize:
2765                                     (term-vertical-motion 0)                                   (term-vertical-motion 0)
2766                                     (setq term-current-column term-start-line-column))))                                   (setq term-current-column term-start-line-column))))
2767                             ((eq char ?\n)                           ((eq char ?\n)
2768                              (if (not (and term-kill-echo-list                            (if (not (and term-kill-echo-list
2769                                            (term-check-kill-echo-list)))                                          (term-check-kill-echo-list)))
2770                                  (term-down 1 t)))                                (term-down 1 t)))
2771                             ((eq char ?\b)                           ((eq char ?\b)
2772                              (term-move-columns -1))                            (term-move-columns -1))
2773                             ((eq char ?\033) ; Escape                           ((eq char ?\033) ; Escape
2774                              (setq term-terminal-state 2))                            (setq term-terminal-state 2))
2775                             ((eq char 0)) ; NUL: Do nothing                           ((eq char 0))         ; NUL: Do nothing
2776                             ((eq char ?\016)) ; Shift Out - ignored                           ((eq char ?\016))     ; Shift Out - ignored
2777                             ((eq char ?\017)) ; Shift In - ignored                           ((eq char ?\017))     ; Shift In - ignored
2778                             ((eq char ?\^G)                           ((eq char ?\^G)
2779                              (beep t)) ; Bell                            (beep t))     ; Bell
2780                             ((eq char ?\032)                           ((eq char ?\032)
2781                              (let ((end (string-match "\r?$" str i)))                            (let ((end (string-match "\r?$" str i)))
2782                                (if end                              (if end
2783                                    (funcall term-command-hook                                  (funcall term-command-hook
2784                                             (prog1 (substring str (1+ i) end)                                           (prog1 (substring str (1+ i) end)
2785                                               (setq i (match-end 0))))                                             (setq i (match-end 0))))
2786                                  (setq term-terminal-parameter                                (setq term-terminal-parameter
2787                                        (substring str i))                                      (substring str i))
2788                                  (setq term-terminal-state 4)                                (setq term-terminal-state 4)
2789                                  (setq i str-length))))                                (setq i str-length))))
2790                             (t ; insert char FIXME: Should never happen                           (t   ; insert char FIXME: Should never happen
2791                              (term-move-columns 1)                            (term-move-columns 1)
2792                              (backward-delete-char 1)                            (backward-delete-char 1)
2793                              (insert char))))                            (insert char))))
2794                      ((eq term-terminal-state 2) ; Seen Esc                    ((eq term-terminal-state 2)     ; Seen Esc
2795                       (cond ((eq char ?\133) ;; ?\133 = ?[                     (cond ((eq char ?\133)         ;; ?\133 = ?[
2796    
2797  ;;; Some modifications to cope with multiple settings like ^[[01;32;43m -mm  ;;; Some modifications to cope with multiple settings like ^[[01;32;43m -mm
2798  ;;; Note that now the init value of term-terminal-previous-parameter has  ;;; Note that now the init value of term-terminal-previous-parameter has
2799  ;;; been changed to -1  ;;; been changed to -1
2800    
2801                              (make-local-variable 'term-terminal-parameter)                            (make-local-variable 'term-terminal-parameter)
2802                              (make-local-variable 'term-terminal-previous-parameter)                            (make-local-variable 'term-terminal-previous-parameter)
2803                              (make-local-variable 'term-terminal-previous-parameter-2)                            (make-local-variable 'term-terminal-previous-parameter-2)
2804                              (make-local-variable 'term-terminal-previous-parameter-3)                            (make-local-variable 'term-terminal-previous-parameter-3)
2805                              (make-local-variable 'term-terminal-previous-parameter-4)                            (make-local-variable 'term-terminal-previous-parameter-4)
2806                              (make-local-variable 'term-terminal-more-parameters)                            (make-local-variable 'term-terminal-more-parameters)
2807                              (setq term-terminal-parameter 0)                            (setq term-terminal-parameter 0)
2808                              (setq term-terminal-previous-parameter -1)                            (setq term-terminal-previous-parameter -1)
2809                              (setq term-terminal-previous-parameter-2 -1)                            (setq term-terminal-previous-parameter-2 -1)
2810                              (setq term-terminal-previous-parameter-3 -1)                            (setq term-terminal-previous-parameter-3 -1)
2811                              (setq term-terminal-previous-parameter-4 -1)                            (setq term-terminal-previous-parameter-4 -1)
2812                              (setq term-terminal-more-parameters 0)                            (setq term-terminal-more-parameters 0)
2813                              (setq term-terminal-state 3))                            (setq term-terminal-state 3))
2814                             ((eq char ?D) ;; scroll forward                           ((eq char ?D) ;; scroll forward
2815                              (term-handle-deferred-scroll)                            (term-handle-deferred-scroll)
2816                              (term-down 1 t)                            (term-down 1 t)
2817                              (setq term-terminal-state 0))                            (setq term-terminal-state 0))
2818                             ((eq char ?M) ;; scroll reversed                           ((eq char ?M) ;; scroll reversed
2819                              (term-insert-lines 1)                            (term-insert-lines 1)
2820                              (setq term-terminal-state 0))                            (setq term-terminal-state 0))
2821                             ((eq char ?7) ;; Save cursor                           ((eq char ?7) ;; Save cursor
2822                              (term-handle-deferred-scroll)                            (term-handle-deferred-scroll)
2823                              (setq term-saved-cursor                            (setq term-saved-cursor
2824                                    (cons (term-current-row)                                  (cons (term-current-row)
2825                                          (term-horizontal-column)))                                        (term-horizontal-column)))
2826                              (setq term-terminal-state 0))                            (setq term-terminal-state 0))
2827                             ((eq char ?8) ;; Restore cursor                           ((eq char ?8) ;; Restore cursor
2828                              (if term-saved-cursor                            (if term-saved-cursor
2829                                  (term-goto (car term-saved-cursor)                                (term-goto (car term-saved-cursor)
2830                                             (cdr term-saved-cursor)))                                           (cdr term-saved-cursor)))
2831                              (setq term-terminal-state 0))                            (setq term-terminal-state 0))
2832                             ((setq term-terminal-state 0))))                           ((setq term-terminal-state 0))))
2833                      ((eq term-terminal-state 3) ; Seen Esc [                    ((eq term-terminal-state 3) ; Seen Esc [
2834                       (cond ((and (>= char ?0) (<= char ?9))                     (cond ((and (>= char ?0) (<= char ?9))
2835                              (setq term-terminal-parameter                            (setq term-terminal-parameter
2836                                    (+ (* 10 term-terminal-parameter) (- char ?0))))                                  (+ (* 10 term-terminal-parameter) (- char ?0))))
2837                             ((eq char ?\;)                           ((eq char ?\;)
2838  ;;; Some modifications to cope with multiple settings like ^[[01;32;43m -mm  ;;; Some modifications to cope with multiple settings like ^[[01;32;43m -mm
2839                              (setq term-terminal-more-parameters 1)                            (setq term-terminal-more-parameters 1)
2840                              (setq term-terminal-previous-parameter-4                            (setq term-terminal-previous-parameter-4
2841                                            term-terminal-previous-parameter-3)                                  term-terminal-previous-parameter-3)
2842                              (setq term-terminal-previous-parameter-3                            (setq term-terminal-previous-parameter-3
2843                                            term-terminal-previous-parameter-2)                                  term-terminal-previous-parameter-2)
2844                              (setq term-terminal-previous-parameter-2                            (setq term-terminal-previous-parameter-2
2845                                            term-terminal-previous-parameter)                                  term-terminal-previous-parameter)
2846                              (setq term-terminal-previous-parameter                            (setq term-terminal-previous-parameter
2847                                            term-terminal-parameter)                                  term-terminal-parameter)
2848                              (setq term-terminal-parameter 0))                            (setq term-terminal-parameter 0))
2849                             ((eq char ??)) ; Ignore ?                           ((eq char ??)) ; Ignore ?
2850                             (t                           (t
2851                              (term-handle-ansi-escape proc char)                            (term-handle-ansi-escape proc char)
2852                              (setq term-terminal-more-parameters 0)                            (setq term-terminal-more-parameters 0)
2853                              (setq term-terminal-previous-parameter-4 -1)                            (setq term-terminal-previous-parameter-4 -1)
2854                              (setq term-terminal-previous-parameter-3 -1)                            (setq term-terminal-previous-parameter-3 -1)
2855                              (setq term-terminal-previous-parameter-2 -1)                            (setq term-terminal-previous-parameter-2 -1)
2856                              (setq term-terminal-previous-parameter -1)                            (setq term-terminal-previous-parameter -1)
2857                              (setq term-terminal-state 0)))))                            (setq term-terminal-state 0)))))
2858                (if (term-handling-pager)              (if (term-handling-pager)
2859                    ;; Finish stuff to get ready to handle PAGER.                  ;; Finish stuff to get ready to handle PAGER.
2860                    (progn                  (progn
2861                      (if (> (% (current-column) term-width) 0)                    (if (> (% (current-column) term-width) 0)
2862                          (setq term-terminal-parameter
2863                                (substring str i))
2864                        ;; We're at column 0.  Goto end of buffer; to compensate,
2865                        ;; prepend a ?\r for later.  This looks more consistent.
2866                        (if (zerop i)
2867                          (setq term-terminal-parameter                          (setq term-terminal-parameter
2868                                (substring str i))                                (concat "\r" (substring str i)))
2869                        ;; We're at column 0.  Goto end of buffer; to compensate,                        (setq term-terminal-parameter (substring str (1- i)))
2870                        ;; prepend a ?\r for later.  This looks more consistent.                        (aset term-terminal-parameter 0 ?\r))
2871                        (if (zerop i)                      (goto-char (point-max)))
2872                            (setq term-terminal-parameter                    (setq term-terminal-state 4)
2873                                  (concat "\r" (substring str i)))                    (make-local-variable 'term-pager-old-filter)
2874                          (setq term-terminal-parameter (substring str (1- i)))                    (setq term-pager-old-filter (process-filter proc))
2875                          (aset term-terminal-parameter 0 ?\r))                    (set-process-filter proc term-pager-filter)
2876                        (goto-char (point-max)))                    (setq i str-length)))
2877                      (setq term-terminal-state 4)              (setq i (1+ i))))
2878                      (make-local-variable 'term-pager-old-filter)  
2879                      (setq term-pager-old-filter (process-filter proc))          (if (>= (term-current-row) term-height)
2880                      (set-process-filter proc term-pager-filter)              (term-handle-deferred-scroll))
2881                      (setq i str-length)))  
2882                (setq i (1+ i))))          (set-marker (process-mark proc) (point))
2883            (if save-point
2884            (if (>= (term-current-row) term-height)              (progn (goto-char save-point)
2885                (term-handle-deferred-scroll))                     (set-marker save-point nil)))
2886    
2887            (set-marker (process-mark proc) (point))          ;; Check for a pending filename-and-line number to display.
2888            (if save-point          ;; We do this before scrolling, because we might create a new window.
2889                (progn (goto-char save-point)          (if (and term-pending-frame
2890                       (set-marker save-point nil)))                   (eq (window-buffer selected) (current-buffer)))
2891                (progn (term-display-line (car term-pending-frame)
2892            ;; Check for a pending filename-and-line number to display.                                        (cdr term-pending-frame))
2893            ;; We do this before scrolling, because we might create a new window.                     (setq term-pending-frame nil)
2894            (if (and term-pending-frame                     ;; We have created a new window, so check the window size.
2895                     (eq (window-buffer selected) (current-buffer)))                     (term-check-size proc)))
2896                (progn (term-display-line (car term-pending-frame)  
2897                                          (cdr term-pending-frame))          ;; Scroll each window displaying the buffer but (by default)
2898                       (setq term-pending-frame nil)          ;; only if the point matches the process-mark we started with.
2899                   ;; We have created a new window, so check the window size.          (setq win selected)
2900                       (term-check-size proc)))          ;; Avoid infinite loop in strange case where minibuffer window
2901            ;; is selected but not active.
2902            ;; Scroll each window displaying the buffer but (by default)          (while (window-minibuffer-p win)
2903            ;; only if the point matches the process-mark we started with.            (setq win (next-window win nil t)))
2904            (setq win selected)          (setq last-win win)
2905            ;; Avoid infinite loop in strange case where minibuffer window          (while (progn
2906            ;; is selected but not active.                   (setq win (next-window win nil t))
2907            (while (window-minibuffer-p win)                   (if (eq (window-buffer win) (process-buffer proc))
2908              (setq win (next-window win nil t)))                       (let ((scroll term-scroll-to-bottom-on-output))
2909            (setq last-win win)                         (select-window win)
2910            (while (progn                         (if (or (= (point) save-marker)
2911                     (setq win (next-window win nil t))                                 (eq scroll t) (eq scroll 'all)
2912                     (if (eq (window-buffer win) (process-buffer proc))                                 ;; Maybe user wants point to jump to the end.
2913                         (let ((scroll term-scroll-to-bottom-on-output))                                 (and (eq selected win)
2914                           (select-window win)                                      (or (eq scroll 'this) (not save-point)))
2915                           (if (or (= (point) save-marker)                                 (and (eq scroll 'others)
2916                                   (eq scroll t) (eq scroll 'all)                                      (not (eq selected win))))
2917                                   ;; Maybe user wants point to jump to the end.                             (progn
2918                                   (and (eq selected win)                               (goto-char term-home-marker)
2919                                        (or (eq scroll 'this) (not save-point)))                               (recenter 0)
2920                                   (and (eq scroll 'others)                               (goto-char (process-mark proc))
2921                                        (not (eq selected win))))                               (if (not (pos-visible-in-window-p (point) win))
2922                               (progn                                   (recenter -1))))
2923                                 (goto-char term-home-marker)                         ;; Optionally scroll so that the text
2924                                 (recenter 0)                         ;; ends at the bottom of the window.
2925                                 (goto-char (process-mark proc))                         (if (and term-scroll-show-maximum-output
2926                                 (if (not (pos-visible-in-window-p (point) win))                                  (>= (point) (process-mark proc)))
2927                                     (recenter -1))))                             (save-excursion
2928                           ;; Optionally scroll so that the text                               (goto-char (point-max))
2929                           ;; ends at the bottom of the window.                               (recenter -1)))))
2930                           (if (and term-scroll-show-maximum-output                   (not (eq win last-win))))
                                   (>= (point) (process-mark proc)))  
                              (save-excursion  
                                (goto-char (point-max))  
                                (recenter -1)))))  
                    (not (eq win last-win))))  
2931    
2932  ;;; Stolen from comint.el and adapted -mm  ;;; Stolen from comint.el and adapted -mm
2933            (if (> term-buffer-maximum-size 0)          (if (> term-buffer-maximum-size 0)
2934                    (save-excursion              (save-excursion
2935                          (goto-char (process-mark (get-buffer-process (current-buffer))))                (goto-char (process-mark (get-buffer-process (current-buffer))))
2936                          (forward-line (- term-buffer-maximum-size))                (forward-line (- term-buffer-maximum-size))
2937                          (beginning-of-line)                (beginning-of-line)
2938                          (delete-region (point-min) (point))))                (delete-region (point-min) (point))))
2939  ;;;  ;;;
2940    
2941            (set-marker save-marker nil))          (set-marker save-marker nil)))))
       ;; unwind-protect cleanup-forms follow:  
       (set-buffer previous-buffer)  
       (select-window selected))))  
2942    
2943  (defun term-handle-deferred-scroll ()  (defun term-handle-deferred-scroll ()
2944    (let ((count (- (term-current-row) term-height)))    (let ((count (- (term-current-row) term-height)))
# Line 2990  See `term-prompt-regexp'." Line 2976  See `term-prompt-regexp'."
2976     ((eq parameter 8)     ((eq parameter 8)
2977      (setq term-ansi-current-invisible 1))      (setq term-ansi-current-invisible 1))
2978    
2979    ;;; Reset reverse (i.e. terminfo rmso)
2980       ((eq parameter 24)
2981        (setq term-ansi-current-reverse 0))
2982    
2983    ;;; Reset underline (i.e. terminfo rmul)
2984       ((eq parameter 27)
2985        (setq term-ansi-current-underline 0))
2986    
2987  ;;; Foreground  ;;; Foreground
2988     ((and (>= parameter 30) (<= parameter 37))     ((and (>= parameter 30) (<= parameter 37))
2989      (setq term-ansi-current-color (- parameter 29)))      (setq term-ansi-current-color (- parameter 29)))
# Line 3044  See `term-prompt-regexp'." Line 3038  See `term-prompt-regexp'."
3038                      )                      )
3039              (setq term-current-face              (setq term-current-face
3040                    (list :background                    (list :background
3041                          (elt ansi-term-color-vector term-ansi-current-color)                          (if (= term-ansi-current-color 0)
3042                                (face-foreground 'default)
3043                                (elt ansi-term-color-vector term-ansi-current-color))
3044                          :foreground                          :foreground
3045                          (elt ansi-term-color-vector term-ansi-current-bg-color)))                          (if (= term-ansi-current-bg-color 0)
3046                                (face-background 'default)
3047                            (elt ansi-term-color-vector term-ansi-current-bg-color))))
3048              (if (= term-ansi-current-bold 1)              (if (= term-ansi-current-bold 1)
3049                  (setq term-current-face                  (setq term-current-face
3050                        (append '(:weight bold) term-current-face)))                        (append '(:weight bold) term-current-face)))
# Line 3503  all pending output has been dealt with." Line 3501  all pending output has been dealt with."
3501      (if (and check-for-scroll (or term-scroll-with-delete term-pager-count))      (if (and check-for-scroll (or term-scroll-with-delete term-pager-count))
3502          (setq down (term-handle-scroll down)))          (setq down (term-handle-scroll down)))
3503      (term-adjust-current-row-cache down)      (term-adjust-current-row-cache down)
3504      (if (/= (point) (point-max))      (if (or (/= (point) (point-max)) (< down 0))
3505          (setq down (- down (term-vertical-motion down))))          (setq down (- down (term-vertical-motion down))))
3506      ;; Extend buffer with extra blank lines if needed.      ;; Extend buffer with extra blank lines if needed.
3507      (cond ((> down 0)      (cond ((> down 0)

Legend:
Removed from v.1.47.2.6  
changed lines
  Added in v.1.47.2.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26